Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add consumer types for Model APIs #9245

Merged
merged 20 commits into from
Mar 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions docs-generator/yui-docs-preprocessor.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,29 @@
function hasProp(obj, prop) {
return Object.hasOwnProperty.call(obj, prop);
}

function fixTags(item) {
if (item.description) {
const lines = item.description.split('\n');
let lastIndex = lines.length;
while (lastIndex-- > 0) {
let value = lines[lastIndex].trim();
if (value.startsWith('@')) {
let [tag, v] = value.split(' ');
tag = tag.substring(1);
if (!item[tag]) {
item[tag] = v || '';
}
} else {
break;
}
}
}
}

function shouldKeepItem(item, excludedTags) {
fixTags(item);

for (let i = 0; i < excludedTags.length; i++) {
if (hasProp(item, excludedTags[i])) return false;
}
@@ -11,14 +33,14 @@ function shouldKeepItem(item, excludedTags) {
}

module.exports = function (data, options) {
console.log('Running ember-data preprocessor...');
console.log(`Running ember-data preprocessor.`);

if (!options.excludeTags) {
console.log('no tags to exclude, exiting');
return;
}
const excludedTags = [...options.excludeTags];
console.log('Skipping items with the tags: ' + excludedTags);
console.log('Filtering items with the tags: ' + excludedTags.join(`, `));

let acceptedWarnings = [];

19 changes: 19 additions & 0 deletions packages/core-types/src/symbols.ts
Original file line number Diff line number Diff line change
@@ -18,3 +18,22 @@ export const RecordStore = Symbol('Store');
* @typedoc
*/
export const ResourceType = Symbol('$type');

/**
* Symbol for the name of a transform.
*
* This is an optional feature that can be used by
* transform implementations to provide a typescript
* hint for the name of the transform.
*
* If not used, `attr<Transform>('name')` will
* allow any string name. `attr('name')` will always
* allow any string name.
*
* If used, `attr<Transform>('name')` will enforce
* that the name is the same as the transform name.
*
* @type {Symbol}
* @typedoc
*/
export const TransformName = Symbol('$TransformName');
1 change: 1 addition & 0 deletions packages/model/package.json
Original file line number Diff line number Diff line change
@@ -145,6 +145,7 @@
"@warp-drive/internal-config": "workspace:5.4.0-alpha.28",
"ember-inflector": "^4.0.2",
"ember-source": "~5.6.0",
"expect-type": "^0.18.0",
"rollup": "^4.9.6",
"typescript": "^5.3.3",
"walk-sync": "^3.0.0",
1 change: 1 addition & 0 deletions packages/model/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ export default {
'@ember/object/mixin',
'@ember/application',
'@ember/polyfills',
'expect-type',
]),

plugins: [
10 changes: 5 additions & 5 deletions packages/model/src/-private.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export { default as attr } from './-private/attr';
export { default as belongsTo } from './-private/belongs-to';
export { default as hasMany } from './-private/has-many';
export { default as Model } from './-private/model';
export { attr } from './-private/attr';
export { belongsTo } from './-private/belongs-to';
export { hasMany } from './-private/has-many';
export { Model } from './-private/model';
export { default as Errors } from './-private/errors';

export { default as ManyArray } from './-private/many-array';
export { default as PromiseBelongsTo } from './-private/promise-belongs-to';
export { PromiseBelongsTo } from './-private/promise-belongs-to';
export { default as PromiseManyArray } from './-private/promise-many-array';

// // Used by tests, migration support
167 changes: 0 additions & 167 deletions packages/model/src/-private/attr.js

This file was deleted.

Loading
Loading