Skip to content

Commit 65b8a06

Browse files
authored
feat: add consumer types for Model APIs (#9245)
1 parent 25da49e commit 65b8a06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1375
-704
lines changed

docs-generator/yui-docs-preprocessor.js

+24-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,29 @@
22
function hasProp(obj, prop) {
33
return Object.hasOwnProperty.call(obj, prop);
44
}
5+
6+
function fixTags(item) {
7+
if (item.description) {
8+
const lines = item.description.split('\n');
9+
let lastIndex = lines.length;
10+
while (lastIndex-- > 0) {
11+
let value = lines[lastIndex].trim();
12+
if (value.startsWith('@')) {
13+
let [tag, v] = value.split(' ');
14+
tag = tag.substring(1);
15+
if (!item[tag]) {
16+
item[tag] = v || '';
17+
}
18+
} else {
19+
break;
20+
}
21+
}
22+
}
23+
}
24+
525
function shouldKeepItem(item, excludedTags) {
26+
fixTags(item);
27+
628
for (let i = 0; i < excludedTags.length; i++) {
729
if (hasProp(item, excludedTags[i])) return false;
830
}
@@ -11,14 +33,14 @@ function shouldKeepItem(item, excludedTags) {
1133
}
1234

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

1638
if (!options.excludeTags) {
1739
console.log('no tags to exclude, exiting');
1840
return;
1941
}
2042
const excludedTags = [...options.excludeTags];
21-
console.log('Skipping items with the tags: ' + excludedTags);
43+
console.log('Filtering items with the tags: ' + excludedTags.join(`, `));
2244

2345
let acceptedWarnings = [];
2446

packages/core-types/src/symbols.ts

+19
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,22 @@ export const RecordStore = Symbol('Store');
1818
* @typedoc
1919
*/
2020
export const ResourceType = Symbol('$type');
21+
22+
/**
23+
* Symbol for the name of a transform.
24+
*
25+
* This is an optional feature that can be used by
26+
* transform implementations to provide a typescript
27+
* hint for the name of the transform.
28+
*
29+
* If not used, `attr<Transform>('name')` will
30+
* allow any string name. `attr('name')` will always
31+
* allow any string name.
32+
*
33+
* If used, `attr<Transform>('name')` will enforce
34+
* that the name is the same as the transform name.
35+
*
36+
* @type {Symbol}
37+
* @typedoc
38+
*/
39+
export const TransformName = Symbol('$TransformName');

packages/model/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
"@warp-drive/internal-config": "workspace:5.4.0-alpha.30",
146146
"ember-inflector": "^4.0.2",
147147
"ember-source": "~5.6.0",
148+
"expect-type": "^0.18.0",
148149
"rollup": "^4.9.6",
149150
"typescript": "^5.3.3",
150151
"walk-sync": "^3.0.0",

packages/model/rollup.config.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default {
3030
'@ember/object/mixin',
3131
'@ember/application',
3232
'@ember/polyfills',
33+
'expect-type',
3334
]),
3435

3536
plugins: [

packages/model/src/-private.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
export { default as attr } from './-private/attr';
2-
export { default as belongsTo } from './-private/belongs-to';
3-
export { default as hasMany } from './-private/has-many';
4-
export { default as Model } from './-private/model';
1+
export { attr } from './-private/attr';
2+
export { belongsTo } from './-private/belongs-to';
3+
export { hasMany } from './-private/has-many';
4+
export { Model } from './-private/model';
55
export { default as Errors } from './-private/errors';
66

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

1111
// // Used by tests, migration support

packages/model/src/-private/attr.js

-167
This file was deleted.

0 commit comments

Comments
 (0)