@warp-drive-mirror/schema-record 0.0.0-alpha.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +12 -0
- package/NCC-1701-a-blue.svg +4 -0
- package/NCC-1701-a.svg +4 -0
- package/README.md +265 -0
- package/addon/hooks.js +18 -0
- package/addon/hooks.js.map +1 -0
- package/addon/managed-array.js +164 -0
- package/addon/managed-array.js.map +1 -0
- package/addon/record.js +482 -0
- package/addon/record.js.map +1 -0
- package/addon/schema.js +152 -0
- package/addon/schema.js.map +1 -0
- package/addon-main.js +94 -0
- package/package.json +105 -0
- package/unstable-preview-types/-base-fields.d.ts +23 -0
- package/unstable-preview-types/-base-fields.d.ts.map +1 -0
- package/unstable-preview-types/hooks.d.ts +8 -0
- package/unstable-preview-types/hooks.d.ts.map +1 -0
- package/unstable-preview-types/index.d.ts +6 -0
- package/unstable-preview-types/managed-array.d.ts +26 -0
- package/unstable-preview-types/managed-array.d.ts.map +1 -0
- package/unstable-preview-types/managed-object.d.ts +26 -0
- package/unstable-preview-types/managed-object.d.ts.map +1 -0
- package/unstable-preview-types/record.d.ts +27 -0
- package/unstable-preview-types/record.d.ts.map +1 -0
- package/unstable-preview-types/schema.d.ts +68 -0
- package/unstable-preview-types/schema.d.ts.map +1 -0
package/addon/schema.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { assert } from '@ember/debug';
|
|
2
|
+
import { createCache, getValue } from '@ember-data-mirror/tracking';
|
|
3
|
+
import { Signals } from '@ember-data-mirror/tracking/-private';
|
|
4
|
+
import { recordIdentifierFor } from '@ember-data-mirror/store';
|
|
5
|
+
import { Identifier } from "./record";
|
|
6
|
+
const Support = new WeakMap();
|
|
7
|
+
const SchemaRecordFields = [{
|
|
8
|
+
type: '@constructor',
|
|
9
|
+
name: 'constructor',
|
|
10
|
+
kind: 'derived'
|
|
11
|
+
}, {
|
|
12
|
+
name: 'id',
|
|
13
|
+
kind: '@id',
|
|
14
|
+
type: null
|
|
15
|
+
}, {
|
|
16
|
+
type: '@identity',
|
|
17
|
+
name: '$type',
|
|
18
|
+
kind: 'derived',
|
|
19
|
+
options: {
|
|
20
|
+
key: 'type'
|
|
21
|
+
}
|
|
22
|
+
}];
|
|
23
|
+
const _constructor = function (record) {
|
|
24
|
+
let state = Support.get(record);
|
|
25
|
+
if (!state) {
|
|
26
|
+
state = {};
|
|
27
|
+
Support.set(record, state);
|
|
28
|
+
}
|
|
29
|
+
return state._constructor = state._constructor || {
|
|
30
|
+
name: `SchemaRecord<${recordIdentifierFor(record).type}>`,
|
|
31
|
+
get modelName() {
|
|
32
|
+
throw new Error('Cannot access record.constructor.modelName on non-Legacy Schema Records.');
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
function withFields(fields) {
|
|
37
|
+
fields.push(...SchemaRecordFields);
|
|
38
|
+
return fields;
|
|
39
|
+
}
|
|
40
|
+
function fromIdentity(record, options, key) {
|
|
41
|
+
const identifier = record[Identifier];
|
|
42
|
+
assert(`Cannot compute @identity for a record without an identifier`, identifier);
|
|
43
|
+
assert(`Expected to receive a key to compute @identity, but got ${String(options)}`, options?.key && ['lid', 'id', 'type', '^'].includes(options.key));
|
|
44
|
+
return options.key === '^' ? identifier : identifier[options.key];
|
|
45
|
+
}
|
|
46
|
+
function registerDerivations(schema) {
|
|
47
|
+
schema.registerDerivation('@identity', fromIdentity);
|
|
48
|
+
schema.registerDerivation('@constructor', _constructor);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The full schema for a resource
|
|
53
|
+
*
|
|
54
|
+
* @class FieldSpec
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Wraps a derivation in a new function with Derivation signature but that looks
|
|
60
|
+
* up the value in the cache before recomputing.
|
|
61
|
+
*
|
|
62
|
+
* @param record
|
|
63
|
+
* @param options
|
|
64
|
+
* @param prop
|
|
65
|
+
*/
|
|
66
|
+
function makeCachedDerivation(derivation) {
|
|
67
|
+
return (record, options, prop) => {
|
|
68
|
+
const signals = record[Signals];
|
|
69
|
+
let signal = signals.get(prop);
|
|
70
|
+
if (!signal) {
|
|
71
|
+
signal = createCache(() => {
|
|
72
|
+
return derivation(record, options, prop);
|
|
73
|
+
}); // a total lie, for convenience of reusing the storage
|
|
74
|
+
signals.set(prop, signal);
|
|
75
|
+
}
|
|
76
|
+
return getValue(signal);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
class SchemaService {
|
|
80
|
+
constructor() {
|
|
81
|
+
this.schemas = new Map();
|
|
82
|
+
this.transforms = new Map();
|
|
83
|
+
this.derivations = new Map();
|
|
84
|
+
}
|
|
85
|
+
registerTransform(type, transform) {
|
|
86
|
+
this.transforms.set(type, transform);
|
|
87
|
+
}
|
|
88
|
+
registerDerivation(type, derivation) {
|
|
89
|
+
this.derivations.set(type, makeCachedDerivation(derivation));
|
|
90
|
+
}
|
|
91
|
+
defineSchema(name, schema) {
|
|
92
|
+
const {
|
|
93
|
+
legacy,
|
|
94
|
+
fields
|
|
95
|
+
} = schema;
|
|
96
|
+
const fieldSpec = {
|
|
97
|
+
'@id': null,
|
|
98
|
+
attributes: {},
|
|
99
|
+
relationships: {},
|
|
100
|
+
fields: new Map(),
|
|
101
|
+
legacy: legacy ?? false
|
|
102
|
+
};
|
|
103
|
+
assert(`Only one field can be defined as @id, ${name} has more than one: ${fields.filter(f => f.kind === '@id').map(f => f.name).join(' ')}`, fields.filter(f => f.kind === '@id').length <= 1);
|
|
104
|
+
fields.forEach(field => {
|
|
105
|
+
fieldSpec.fields.set(field.name, field);
|
|
106
|
+
if (field.kind === '@id') {
|
|
107
|
+
fieldSpec['@id'] = field;
|
|
108
|
+
} else if (field.kind === 'field') ;else if (field.kind === 'attribute') {
|
|
109
|
+
fieldSpec.attributes[field.name] = field;
|
|
110
|
+
} else if (field.kind === 'resource' || field.kind === 'collection') {
|
|
111
|
+
const relSchema = Object.assign({}, field, {
|
|
112
|
+
kind: field.kind === 'resource' ? 'belongsTo' : 'hasMany'
|
|
113
|
+
});
|
|
114
|
+
fieldSpec.relationships[field.name] = relSchema;
|
|
115
|
+
} else if (field.kind !== 'derived' && field.kind !== '@local' && field.kind !== 'array' && field.kind !== 'object') {
|
|
116
|
+
throw new Error(`Unknown field kind ${field.kind}`);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
this.schemas.set(name, fieldSpec);
|
|
120
|
+
}
|
|
121
|
+
fields({
|
|
122
|
+
type
|
|
123
|
+
}) {
|
|
124
|
+
const schema = this.schemas.get(type);
|
|
125
|
+
if (!schema) {
|
|
126
|
+
throw new Error(`No schema defined for ${type}`);
|
|
127
|
+
}
|
|
128
|
+
return schema.fields;
|
|
129
|
+
}
|
|
130
|
+
attributesDefinitionFor({
|
|
131
|
+
type
|
|
132
|
+
}) {
|
|
133
|
+
const schema = this.schemas.get(type);
|
|
134
|
+
if (!schema) {
|
|
135
|
+
throw new Error(`No schema defined for ${type}`);
|
|
136
|
+
}
|
|
137
|
+
return schema.attributes;
|
|
138
|
+
}
|
|
139
|
+
relationshipsDefinitionFor({
|
|
140
|
+
type
|
|
141
|
+
}) {
|
|
142
|
+
const schema = this.schemas.get(type);
|
|
143
|
+
if (!schema) {
|
|
144
|
+
throw new Error(`No schema defined for ${type}`);
|
|
145
|
+
}
|
|
146
|
+
return schema.relationships;
|
|
147
|
+
}
|
|
148
|
+
doesTypeExist(type) {
|
|
149
|
+
return this.schemas.has(type);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
export { SchemaService, registerDerivations, withFields };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sources":["../src/-base-fields.ts","../src/schema.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport { recordIdentifierFor } from '@ember-data-mirror/store';\nimport type { OpaqueRecordInstance } from '@ember-data-mirror/store/-types/q/record-instance';\nimport type { FieldSchema } from '@ember-data-mirror/store/-types/q/schema-service';\nimport type { StableRecordIdentifier } from '@warp-drive-mirror/core-types';\n\nimport { Identifier, type SchemaRecord } from './record';\nimport type { Derivation, SchemaService } from './schema';\n\nconst Support = new WeakMap<WeakKey, Record<string, unknown>>();\n\nexport const SchemaRecordFields: FieldSchema[] = [\n {\n type: '@constructor',\n name: 'constructor',\n kind: 'derived',\n },\n {\n name: 'id',\n kind: '@id',\n type: null,\n },\n {\n type: '@identity',\n name: '$type',\n kind: 'derived',\n options: { key: 'type' },\n },\n];\n\nconst _constructor: Derivation<OpaqueRecordInstance, unknown> = function (record) {\n let state = Support.get(record as WeakKey);\n if (!state) {\n state = {};\n Support.set(record as WeakKey, state);\n }\n\n return (state._constructor = state._constructor || {\n name: `SchemaRecord<${recordIdentifierFor(record).type}>`,\n get modelName() {\n throw new Error('Cannot access record.constructor.modelName on non-Legacy Schema Records.');\n },\n });\n};\n\nexport function withFields(fields: FieldSchema[]) {\n fields.push(...SchemaRecordFields);\n return fields;\n}\n\nexport function fromIdentity(record: SchemaRecord, options: null, key: string): asserts options;\nexport function fromIdentity(record: SchemaRecord, options: { key: 'lid' }, key: string): string;\nexport function fromIdentity(record: SchemaRecord, options: { key: 'type' }, key: string): string;\nexport function fromIdentity(record: SchemaRecord, options: { key: 'id' }, key: string): string | null;\nexport function fromIdentity(record: SchemaRecord, options: { key: '^' }, key: string): StableRecordIdentifier;\nexport function fromIdentity(\n record: SchemaRecord,\n options: { key: 'id' | 'lid' | 'type' | '^' } | null,\n key: string\n): StableRecordIdentifier | string | null {\n const identifier = record[Identifier];\n assert(`Cannot compute @identity for a record without an identifier`, identifier);\n assert(\n `Expected to receive a key to compute @identity, but got ${String(options)}`,\n options?.key && ['lid', 'id', 'type', '^'].includes(options.key)\n );\n\n return options.key === '^' ? identifier : identifier[options.key];\n}\n\nexport function registerDerivations(schema: SchemaService) {\n schema.registerDerivation(\n '@identity',\n fromIdentity as Derivation<SchemaRecord, StableRecordIdentifier | string | null>\n );\n schema.registerDerivation('@constructor', _constructor);\n}\n","import { assert } from '@ember/debug';\n\nimport type { FieldSchema } from '@ember-data-mirror/store/-types/q/schema-service';\nimport { createCache, getValue } from '@ember-data-mirror/tracking';\nimport { type Signal, Signals } from '@ember-data-mirror/tracking/-private';\nimport type { StableRecordIdentifier } from '@warp-drive-mirror/core-types';\nimport type { Value } from '@warp-drive-mirror/core-types/json/raw';\nimport type { AttributeSchema, RelationshipSchema } from '@warp-drive-mirror/core-types/schema';\n\nimport type { SchemaRecord } from './record';\n\nexport { withFields, registerDerivations } from './-base-fields';\n\n/**\n * The full schema for a resource\n *\n * @class FieldSpec\n * @internal\n */\ntype FieldSpec = {\n '@id': FieldSchema | null;\n /**\n * legacy schema service separated attribute\n * from relationship lookup\n * @internal\n */\n attributes: Record<string, AttributeSchema>;\n /**\n * legacy schema service separated attribute\n * from relationship lookup\n * @internal\n */\n relationships: Record<string, RelationshipSchema>;\n /**\n * new schema service is fields based\n * @internal\n */\n fields: Map<string, FieldSchema>;\n /**\n * legacy model mode support\n * @internal\n */\n legacy?: boolean;\n};\n\nexport type Transform<T extends Value = string, PT = unknown> = {\n serialize(value: PT, options: Record<string, unknown> | null, record: SchemaRecord): T;\n hydrate(value: T | undefined, options: Record<string, unknown> | null, record: SchemaRecord): PT;\n defaultValue?(options: Record<string, unknown> | null, identifier: StableRecordIdentifier): T;\n};\n\nexport type Derivation<R, T> = (record: R, options: Record<string, unknown> | null, prop: string) => T;\n\n/**\n * Wraps a derivation in a new function with Derivation signature but that looks\n * up the value in the cache before recomputing.\n *\n * @param record\n * @param options\n * @param prop\n */\nfunction makeCachedDerivation<R, T>(derivation: Derivation<R, T>): Derivation<R, T> {\n return (record: R, options: Record<string, unknown> | null, prop: string): T => {\n const signals = (record as { [Signals]: Map<string, Signal> })[Signals];\n let signal = signals.get(prop);\n if (!signal) {\n signal = createCache(() => {\n return derivation(record, options, prop);\n }) as unknown as Signal; // a total lie, for convenience of reusing the storage\n signals.set(prop, signal);\n }\n\n return getValue(signal as unknown as ReturnType<typeof createCache>) as T;\n };\n}\n\nexport class SchemaService {\n declare schemas: Map<string, FieldSpec>;\n declare transforms: Map<string, Transform<Value>>;\n declare derivations: Map<string, Derivation<unknown, unknown>>;\n\n constructor() {\n this.schemas = new Map();\n this.transforms = new Map();\n this.derivations = new Map();\n }\n\n registerTransform<T extends Value = string, PT = unknown>(type: string, transform: Transform<T, PT>): void {\n this.transforms.set(type, transform);\n }\n\n registerDerivation<R, T>(type: string, derivation: Derivation<R, T>): void {\n this.derivations.set(type, makeCachedDerivation(derivation) as Derivation<unknown, unknown>);\n }\n\n defineSchema(name: string, schema: { legacy?: boolean; fields: FieldSchema[] }): void {\n const { legacy, fields } = schema;\n const fieldSpec: FieldSpec = {\n '@id': null,\n attributes: {},\n relationships: {},\n fields: new Map(),\n legacy: legacy ?? false,\n };\n\n assert(\n `Only one field can be defined as @id, ${name} has more than one: ${fields\n .filter((f) => f.kind === '@id')\n .map((f) => f.name)\n .join(' ')}`,\n fields.filter((f) => f.kind === '@id').length <= 1\n );\n fields.forEach((field) => {\n fieldSpec.fields.set(field.name, field);\n\n if (field.kind === '@id') {\n fieldSpec['@id'] = field;\n } else if (field.kind === 'field') {\n // We don't add 'field' fields to attributes in order to allow simpler\n // migration between transformation behaviors\n // serializers and things which call attributesDefinitionFor will\n // only run on the things that are legacy attribute mode, while all fields\n // will have their serialize/hydrate logic managed by the cache and record\n //\n // This means that if you want to normalize fields pre-cache insertion\n // Or pre-api call you wil need to use the newer `schema.fields()` API\n // To opt-in to that ability (which note, is now an anti-pattern)\n //\n // const attr = Object.assign({}, field, { kind: 'attribute' }) as AttributeSchema;\n // fieldSpec.attributes[attr.name] = attr;\n } else if (field.kind === 'attribute') {\n fieldSpec.attributes[field.name] = field as AttributeSchema;\n } else if (field.kind === 'resource' || field.kind === 'collection') {\n const relSchema = Object.assign({}, field, {\n kind: field.kind === 'resource' ? 'belongsTo' : 'hasMany',\n }) as unknown as RelationshipSchema;\n fieldSpec.relationships[field.name] = relSchema;\n } else if (\n field.kind !== 'derived' &&\n field.kind !== '@local' &&\n field.kind !== 'array' &&\n field.kind !== 'object'\n ) {\n throw new Error(`Unknown field kind ${field.kind}`);\n }\n });\n\n this.schemas.set(name, fieldSpec);\n }\n\n fields({ type }: { type: string }): FieldSpec['fields'] {\n const schema = this.schemas.get(type);\n\n if (!schema) {\n throw new Error(`No schema defined for ${type}`);\n }\n\n return schema.fields;\n }\n\n attributesDefinitionFor({ type }: { type: string }): FieldSpec['attributes'] {\n const schema = this.schemas.get(type);\n\n if (!schema) {\n throw new Error(`No schema defined for ${type}`);\n }\n\n return schema.attributes;\n }\n\n relationshipsDefinitionFor({ type }: { type: string }): FieldSpec['relationships'] {\n const schema = this.schemas.get(type);\n\n if (!schema) {\n throw new Error(`No schema defined for ${type}`);\n }\n\n return schema.relationships;\n }\n\n doesTypeExist(type: string): boolean {\n return this.schemas.has(type);\n }\n}\n"],"names":["Support","WeakMap","SchemaRecordFields","type","name","kind","options","key","_constructor","record","state","get","set","recordIdentifierFor","modelName","Error","withFields","fields","push","fromIdentity","identifier","Identifier","assert","String","includes","registerDerivations","schema","registerDerivation","makeCachedDerivation","derivation","prop","signals","Signals","signal","createCache","getValue","SchemaService","constructor","schemas","Map","transforms","derivations","registerTransform","transform","defineSchema","legacy","fieldSpec","attributes","relationships","filter","f","map","join","length","forEach","field","relSchema","Object","assign","attributesDefinitionFor","relationshipsDefinitionFor","doesTypeExist","has"],"mappings":";;;;;;AAUA,MAAMA,OAAO,GAAG,IAAIC,OAAO,EAAoC,CAAA;AAExD,MAAMC,kBAAiC,GAAG,CAC/C;AACEC,EAAAA,IAAI,EAAE,cAAc;AACpBC,EAAAA,IAAI,EAAE,aAAa;AACnBC,EAAAA,IAAI,EAAE,SAAA;AACR,CAAC,EACD;AACED,EAAAA,IAAI,EAAE,IAAI;AACVC,EAAAA,IAAI,EAAE,KAAK;AACXF,EAAAA,IAAI,EAAE,IAA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,IAAI,CAAC,CAAA;IAErC,IAAI,CAACuB,MAAM,EAAE;AACX,MAAA,MAAM,IAAIX,KAAK,CAAE,CAAwBZ,sBAAAA,EAAAA,IAAK,EAAC,CAAC,CAAA;AAClD,KAAA;IAEA,OAAOuB,MAAM,CAACT,MAAM,CAAA;AACtB,GAAA;AAEA0C,EAAAA,uBAAuBA,CAAC;AAAExD,IAAAA,IAAAA;AAAuB,GAAC,EAA2B;IAC3E,MAAMuB,MAAM,GAAG,IAAI,CAACY,OAAO,CAAC3B,GAAG,CAACR,IAAI,CAAC,CAAA;IAErC,IAAI,CAACuB,MAAM,EAAE;AACX,MAAA,MAAM,IAAIX,KAAK,CAAE,CAAwBZ,sBAAAA,EAAAA,IAAK,EAAC,CAAC,CAAA;AAClD,KAAA;IAEA,OAAOuB,MAAM,CAACqB,UAAU,CAAA;AAC1B,GAAA;AAEAa,EAAAA,0BAA0BA,CAAC;AAAEzD,IAAAA,IAAAA;AAAuB,GAAC,EAA8B;IACjF,MAAMuB,MAAM,GAAG,IAAI,CAACY,OAAO,CAAC3B,GAAG,CAACR,IAAI,CAAC,CAAA;IAErC,IAAI,CAACuB,MAAM,EAAE;AACX,MAAA,MAAM,IAAIX,KAAK,CAAE,CAAwBZ,sBAAAA,EAAAA,IAAK,EAAC,CAAC,CAAA;AAClD,KAAA;IAEA,OAAOuB,MAAM,CAACsB,aAAa,CAAA;AAC7B,GAAA;EAEAa,aAAaA,CAAC1D,IAAY,EAAW;AACnC,IAAA,OAAO,IAAI,CAACmC,OAAO,CAACwB,GAAG,CAAC3D,IAAI,CAAC,CAAA;AAC/B,GAAA;AACF;;;;"}
|
package/addon-main.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const requireModule = require('@ember-data-mirror/private-build-infra/src/utilities/require-module');
|
|
2
|
+
const getEnv = require('@ember-data-mirror/private-build-infra/src/utilities/get-env');
|
|
3
|
+
const detectModule = require('@ember-data-mirror/private-build-infra/src/utilities/detect-module');
|
|
4
|
+
|
|
5
|
+
const pkg = require('./package.json');
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
name: pkg.name,
|
|
9
|
+
|
|
10
|
+
options: {
|
|
11
|
+
'@embroider/macros': {
|
|
12
|
+
setOwnConfig: {},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
_emberDataConfig: null,
|
|
17
|
+
configureEmberData() {
|
|
18
|
+
if (this._emberDataConfig) {
|
|
19
|
+
return this._emberDataConfig;
|
|
20
|
+
}
|
|
21
|
+
const app = this._findHost();
|
|
22
|
+
const isProd = /production/.test(process.env.EMBER_ENV);
|
|
23
|
+
const hostOptions = app.options?.emberData || {};
|
|
24
|
+
const debugOptions = Object.assign(
|
|
25
|
+
{
|
|
26
|
+
LOG_PAYLOADS: false,
|
|
27
|
+
LOG_OPERATIONS: false,
|
|
28
|
+
LOG_MUTATIONS: false,
|
|
29
|
+
LOG_NOTIFICATIONS: false,
|
|
30
|
+
LOG_REQUESTS: false,
|
|
31
|
+
LOG_REQUEST_STATUS: false,
|
|
32
|
+
LOG_IDENTIFIERS: false,
|
|
33
|
+
LOG_GRAPH: false,
|
|
34
|
+
LOG_INSTANCE_CACHE: false,
|
|
35
|
+
},
|
|
36
|
+
hostOptions.debug || {}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const HAS_DEBUG_PACKAGE = detectModule(require, '@ember-data-mirror/debug', __dirname, pkg);
|
|
40
|
+
const HAS_META_PACKAGE = detectModule(require, 'ember-data-mirror', __dirname, pkg);
|
|
41
|
+
|
|
42
|
+
const includeDataAdapterInProduction =
|
|
43
|
+
typeof hostOptions.includeDataAdapterInProduction === 'boolean'
|
|
44
|
+
? hostOptions.includeDataAdapterInProduction
|
|
45
|
+
: HAS_META_PACKAGE;
|
|
46
|
+
|
|
47
|
+
const includeDataAdapter = HAS_DEBUG_PACKAGE ? (isProd ? includeDataAdapterInProduction : true) : false;
|
|
48
|
+
const DEPRECATIONS = require('@ember-data-mirror/private-build-infra/src/deprecations')(hostOptions.compatWith || null);
|
|
49
|
+
const FEATURES = require('@ember-data-mirror/private-build-infra/src/features')(isProd);
|
|
50
|
+
|
|
51
|
+
const ALL_PACKAGES = requireModule('@ember-data-mirror/private-build-infra/virtual-packages/packages.js');
|
|
52
|
+
const MACRO_PACKAGE_FLAGS = Object.assign({}, ALL_PACKAGES.default);
|
|
53
|
+
delete MACRO_PACKAGE_FLAGS['HAS_DEBUG_PACKAGE'];
|
|
54
|
+
|
|
55
|
+
Object.keys(MACRO_PACKAGE_FLAGS).forEach((key) => {
|
|
56
|
+
MACRO_PACKAGE_FLAGS[key] = detectModule(require, MACRO_PACKAGE_FLAGS[key], __dirname, pkg);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// copy configs forward
|
|
60
|
+
const ownConfig = this.options['@embroider/macros'].setOwnConfig;
|
|
61
|
+
ownConfig.polyfillUUID = hostOptions.polyfillUUID ?? false;
|
|
62
|
+
ownConfig.compatWith = hostOptions.compatWith || null;
|
|
63
|
+
ownConfig.debug = debugOptions;
|
|
64
|
+
ownConfig.deprecations = Object.assign(DEPRECATIONS, ownConfig.deprecations || {}, hostOptions.deprecations || {});
|
|
65
|
+
ownConfig.features = Object.assign({}, FEATURES);
|
|
66
|
+
ownConfig.includeDataAdapter = includeDataAdapter;
|
|
67
|
+
ownConfig.packages = MACRO_PACKAGE_FLAGS;
|
|
68
|
+
ownConfig.env = getEnv(ownConfig);
|
|
69
|
+
|
|
70
|
+
this._emberDataConfig = ownConfig;
|
|
71
|
+
return ownConfig;
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
included() {
|
|
75
|
+
this.configureEmberData();
|
|
76
|
+
return this._super.included.call(this, ...arguments);
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
treeForVendor() {
|
|
80
|
+
return;
|
|
81
|
+
},
|
|
82
|
+
treeForPublic() {
|
|
83
|
+
return;
|
|
84
|
+
},
|
|
85
|
+
treeForStyles() {
|
|
86
|
+
return;
|
|
87
|
+
},
|
|
88
|
+
treeForAddonStyles() {
|
|
89
|
+
return;
|
|
90
|
+
},
|
|
91
|
+
treeForApp() {
|
|
92
|
+
return;
|
|
93
|
+
},
|
|
94
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@warp-drive-mirror/schema-record",
|
|
3
|
+
"version": "0.0.0-alpha.49",
|
|
4
|
+
"description": "Schema Driven Resource Presentation for WarpDrive and EmberData",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ember-addon"
|
|
7
|
+
],
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+ssh://git@github.com:emberjs/data.git",
|
|
11
|
+
"directory": "packages/schema-record"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
|
|
17
|
+
"build:runtime": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
|
|
18
|
+
"build:types": "tsc --build",
|
|
19
|
+
"_build": "bun run build:runtime && bun run build:types",
|
|
20
|
+
"_syncPnpm": "bun run sync-dependencies-meta-injected"
|
|
21
|
+
},
|
|
22
|
+
"ember-addon": {
|
|
23
|
+
"main": "addon-main.js",
|
|
24
|
+
"type": "addon",
|
|
25
|
+
"version": 1
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"addon-main.js",
|
|
29
|
+
"addon",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE.md",
|
|
32
|
+
"NCC-1701-a.svg",
|
|
33
|
+
"NCC-1701-a-blue.svg",
|
|
34
|
+
"unstable-preview-types"
|
|
35
|
+
],
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@ember-data-mirror/store": "5.4.0-alpha.63",
|
|
38
|
+
"@warp-drive-mirror/core-types": "0.0.0-alpha.49",
|
|
39
|
+
"@ember-data-mirror/tracking": "5.4.0-alpha.63"
|
|
40
|
+
},
|
|
41
|
+
"dependenciesMeta": {
|
|
42
|
+
"@ember-data-mirror/private-build-infra": {
|
|
43
|
+
"injected": true
|
|
44
|
+
},
|
|
45
|
+
"@ember-data-mirror/request": {
|
|
46
|
+
"injected": true
|
|
47
|
+
},
|
|
48
|
+
"@ember-data-mirror/store": {
|
|
49
|
+
"injected": true
|
|
50
|
+
},
|
|
51
|
+
"@ember-data-mirror/tracking": {
|
|
52
|
+
"injected": true
|
|
53
|
+
},
|
|
54
|
+
"@warp-drive-mirror/core-types": {
|
|
55
|
+
"injected": true
|
|
56
|
+
},
|
|
57
|
+
"@ember/string": {
|
|
58
|
+
"injected": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@ember-data-mirror/private-build-infra": "5.4.0-alpha.63",
|
|
63
|
+
"@ember/edition-utils": "^1.2.0",
|
|
64
|
+
"@embroider/macros": "^1.15.1",
|
|
65
|
+
"ember-cli-babel": "^8.2.0"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@babel/cli": "^7.24.1",
|
|
69
|
+
"@babel/core": "^7.24.4",
|
|
70
|
+
"@babel/plugin-proposal-decorators": "^7.24.1",
|
|
71
|
+
"@babel/plugin-transform-class-properties": "^7.24.1",
|
|
72
|
+
"@babel/plugin-transform-private-methods": "^7.24.1",
|
|
73
|
+
"@babel/plugin-transform-runtime": "^7.24.3",
|
|
74
|
+
"@babel/plugin-transform-typescript": "^7.24.4",
|
|
75
|
+
"@babel/preset-env": "^7.24.4",
|
|
76
|
+
"@babel/preset-typescript": "^7.24.1",
|
|
77
|
+
"@babel/runtime": "^7.24.4",
|
|
78
|
+
"@ember-data-mirror/request": "5.4.0-alpha.63",
|
|
79
|
+
"@ember-data-mirror/store": "5.4.0-alpha.63",
|
|
80
|
+
"@ember-data-mirror/tracking": "5.4.0-alpha.63",
|
|
81
|
+
"@embroider/addon-dev": "^4.3.1",
|
|
82
|
+
"@glimmer/component": "^1.1.2",
|
|
83
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
84
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
85
|
+
"@warp-drive-mirror/core-types": "0.0.0-alpha.49",
|
|
86
|
+
"@warp-drive/internal-config": "5.4.0-alpha.63",
|
|
87
|
+
"ember-source": "~5.7.0",
|
|
88
|
+
"pnpm-sync-dependencies-meta-injected": "0.0.10",
|
|
89
|
+
"rollup": "^4.14.3",
|
|
90
|
+
"typescript": "^5.4.5",
|
|
91
|
+
"walk-sync": "^3.0.0",
|
|
92
|
+
"webpack": "^5.91.0",
|
|
93
|
+
"@ember/string": "^3.1.1"
|
|
94
|
+
},
|
|
95
|
+
"ember": {
|
|
96
|
+
"edition": "octane"
|
|
97
|
+
},
|
|
98
|
+
"engines": {
|
|
99
|
+
"node": ">= 18.20.2"
|
|
100
|
+
},
|
|
101
|
+
"volta": {
|
|
102
|
+
"extends": "../../../../../../package.json"
|
|
103
|
+
},
|
|
104
|
+
"packageManager": "pnpm@8.15.6"
|
|
105
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare module '@warp-drive-mirror/schema-record/-base-fields' {
|
|
2
|
+
import type { FieldSchema } from '@ember-data-mirror/store/-types/q/schema-service';
|
|
3
|
+
import type { StableRecordIdentifier } from '@warp-drive-mirror/core-types';
|
|
4
|
+
import { type SchemaRecord } from '@warp-drive-mirror/schema-record/record';
|
|
5
|
+
import type { SchemaService } from '@warp-drive-mirror/schema-record/schema';
|
|
6
|
+
export const SchemaRecordFields: FieldSchema[];
|
|
7
|
+
export function withFields(fields: FieldSchema[]): FieldSchema[];
|
|
8
|
+
export function fromIdentity(record: SchemaRecord, options: null, key: string): asserts options;
|
|
9
|
+
export function fromIdentity(record: SchemaRecord, options: {
|
|
10
|
+
key: 'lid';
|
|
11
|
+
}, key: string): string;
|
|
12
|
+
export function fromIdentity(record: SchemaRecord, options: {
|
|
13
|
+
key: 'type';
|
|
14
|
+
}, key: string): string;
|
|
15
|
+
export function fromIdentity(record: SchemaRecord, options: {
|
|
16
|
+
key: 'id';
|
|
17
|
+
}, key: string): string | null;
|
|
18
|
+
export function fromIdentity(record: SchemaRecord, options: {
|
|
19
|
+
key: '^';
|
|
20
|
+
}, key: string): StableRecordIdentifier;
|
|
21
|
+
export function registerDerivations(schema: SchemaService): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=-base-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"-base-fields.d.ts","sourceRoot":"","sources":["../src/-base-fields.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,UAAU,CAAC;AAI1D,eAAO,MAAM,kBAAkB,EAAE,WAAW,EAiB3C,CAAC;AAiBF,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,iBAG/C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;AAChG,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE;IAAE,GAAG,EAAE,KAAK,CAAA;CAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;AACjG,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;AAClG,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE;IAAE,GAAG,EAAE,IAAI,CAAA;CAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AACvG,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE;IAAE,GAAG,EAAE,GAAG,CAAA;CAAE,EAAE,GAAG,EAAE,MAAM,GAAG,sBAAsB,CAAC;AAgB/G,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,QAMxD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare module '@warp-drive-mirror/schema-record/hooks' {
|
|
2
|
+
import type Store from '@ember-data-mirror/store';
|
|
3
|
+
import type { StableRecordIdentifier } from '@warp-drive-mirror/core-types';
|
|
4
|
+
import { SchemaRecord } from '@warp-drive-mirror/schema-record/record';
|
|
5
|
+
export function instantiateRecord(store: Store, identifier: StableRecordIdentifier, createArgs?: Record<string, unknown>): SchemaRecord;
|
|
6
|
+
export function teardownRecord(record: SchemaRecord): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,OAAO,EAA6B,YAAY,EAAE,MAAM,UAAU,CAAC;AAGnE,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,sBAAsB,EAClC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,YAAY,CAcd;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAEzD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare module '@warp-drive-mirror/schema-record/managed-array' {
|
|
2
|
+
import type Store from '@ember-data-mirror/store';
|
|
3
|
+
import type { FieldSchema } from '@ember-data-mirror/store/-types/q/schema-service';
|
|
4
|
+
import type { Signal } from '@ember-data-mirror/tracking/-private';
|
|
5
|
+
import type { StableRecordIdentifier } from '@warp-drive-mirror/core-types';
|
|
6
|
+
import type { Cache } from '@warp-drive-mirror/core-types/cache';
|
|
7
|
+
import type { SchemaRecord } from '@warp-drive-mirror/schema-record/record';
|
|
8
|
+
import type { SchemaService } from '@warp-drive-mirror/schema-record/schema';
|
|
9
|
+
export const SOURCE: unique symbol;
|
|
10
|
+
export const MUTATE: unique symbol;
|
|
11
|
+
export const ARRAY_SIGNAL: unique symbol;
|
|
12
|
+
export const NOTIFY: unique symbol;
|
|
13
|
+
export function notifyArray(arr: ManagedArray): void;
|
|
14
|
+
export interface ManagedArray extends Omit<Array<unknown>, '[]'> {
|
|
15
|
+
[MUTATE]?(target: unknown[], receiver: typeof Proxy<unknown[]>, prop: string, args: unknown[], _SIGNAL: Signal): unknown;
|
|
16
|
+
}
|
|
17
|
+
export class ManagedArray {
|
|
18
|
+
[SOURCE]: unknown[];
|
|
19
|
+
address: StableRecordIdentifier;
|
|
20
|
+
key: string;
|
|
21
|
+
owner: SchemaRecord;
|
|
22
|
+
[ARRAY_SIGNAL]: Signal;
|
|
23
|
+
constructor(store: Store, schema: SchemaService, cache: Cache, field: FieldSchema, data: unknown[], address: StableRecordIdentifier, key: string, owner: SchemaRecord);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=managed-array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managed-array.d.ts","sourceRoot":"","sources":["../src/managed-array.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,KAA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warp-drive-mirror/schema-record/managed-object' {
|
|
2
|
+
import type Store from '@ember-data-mirror/store';
|
|
3
|
+
import type { FieldSchema } from '@ember-data-mirror/store/-types/q/schema-service';
|
|
4
|
+
import type { Signal } from '@ember-data-mirror/tracking/-private';
|
|
5
|
+
import type { StableRecordIdentifier } from '@warp-drive-mirror/core-types';
|
|
6
|
+
import type { Cache } from '@warp-drive-mirror/core-types/cache';
|
|
7
|
+
import type { SchemaRecord } from '@warp-drive-mirror/schema-record/record';
|
|
8
|
+
import type { SchemaService } from '@warp-drive-mirror/schema-record/schema';
|
|
9
|
+
export const SOURCE: unique symbol;
|
|
10
|
+
export const MUTATE: unique symbol;
|
|
11
|
+
export const OBJECT_SIGNAL: unique symbol;
|
|
12
|
+
export const NOTIFY: unique symbol;
|
|
13
|
+
export function notifyObject(obj: ManagedObject): void;
|
|
14
|
+
export interface ManagedObject {
|
|
15
|
+
[MUTATE]?(target: unknown[], receiver: typeof Proxy<unknown[]>, prop: string, args: unknown[], _SIGNAL: Signal): unknown;
|
|
16
|
+
}
|
|
17
|
+
export class ManagedObject {
|
|
18
|
+
[SOURCE]: object;
|
|
19
|
+
address: StableRecordIdentifier;
|
|
20
|
+
key: string;
|
|
21
|
+
owner: SchemaRecord;
|
|
22
|
+
[OBJECT_SIGNAL]: Signal;
|
|
23
|
+
constructor(store: Store, schema: SchemaService, cache: Cache, field: FieldSchema, data: object, address: StableRecordIdentifier, key: string, owner: SchemaRecord);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=managed-object.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managed-object.d.ts","sourceRoot":"","sources":["../src/managed-object.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAE5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAG1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,eAAO,MAAM,MAAM,eAAoB,CAAC;AACxC,eAAO,MAAM,MAAM,eAAoB,CAAC;AACxC,eAAO,MAAM,aAAa,eAAoB,CAAC;AAC/C,eAAO,MAAM,MAAM,eAAoB,CAAC;AAExC,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,QAE9C;AAID,MAAM,WAAW,aAAa;IAC5B,CAAC,MAAM,CAAC,CAAC,CACP,MAAM,EAAE,OAAO,EAAE,EACjB,QAAQ,EAAE,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC,EACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EAAE,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;CACZ;AAED,qBAAa,aAAa;IACxB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACT,OAAO,EAAE,sBAAsB,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,YAAY,CAAC;IACpB,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;gBAG9B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,sBAAsB,EAC/B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,YAAY;CA6FtB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare module '@warp-drive-mirror/schema-record/record' {
|
|
2
|
+
import type Store from '@ember-data-mirror/store';
|
|
3
|
+
import { type Signal, Signals } from '@ember-data-mirror/tracking/-private';
|
|
4
|
+
import type { StableRecordIdentifier } from '@warp-drive-mirror/core-types';
|
|
5
|
+
import { RecordStore } from '@warp-drive-mirror/core-types/symbols';
|
|
6
|
+
export const Destroy: unique symbol;
|
|
7
|
+
export const Identifier: unique symbol;
|
|
8
|
+
export const Editable: unique symbol;
|
|
9
|
+
export const Parent: unique symbol;
|
|
10
|
+
export const Checkout: unique symbol;
|
|
11
|
+
export const Legacy: unique symbol;
|
|
12
|
+
export class SchemaRecord {
|
|
13
|
+
[RecordStore]: Store;
|
|
14
|
+
[Identifier]: StableRecordIdentifier;
|
|
15
|
+
[Editable]: boolean;
|
|
16
|
+
[Legacy]: boolean;
|
|
17
|
+
[Signals]: Map<string, Signal>;
|
|
18
|
+
___notifications: object;
|
|
19
|
+
constructor(store: Store, identifier: StableRecordIdentifier, Mode: {
|
|
20
|
+
[Editable]: boolean;
|
|
21
|
+
[Legacy]: boolean;
|
|
22
|
+
});
|
|
23
|
+
[Destroy](): void;
|
|
24
|
+
[Checkout](): Promise<SchemaRecord>;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAI3C,OAAO,EAML,KAAK,MAAM,EACX,OAAO,EACR,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAMrE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAM7D,eAAO,MAAM,OAAO,eAAoB,CAAC;AACzC,eAAO,MAAM,UAAU,eAAuB,CAAC;AAC/C,eAAO,MAAM,QAAQ,eAAqB,CAAC;AAC3C,eAAO,MAAM,MAAM,eAAmB,CAAC;AACvC,eAAO,MAAM,QAAQ,eAAqB,CAAC;AAC3C,eAAO,MAAM,MAAM,eAAmB,CAAC;AAmPvC,qBAAa,YAAY;IACf,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;IACrB,CAAC,UAAU,CAAC,EAAE,sBAAsB,CAAC;IACrC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACpB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAClB,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,gBAAgB,EAAE,MAAM,CAAC;gBAErB,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAE,IAAI,EAAE;QAAE,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE;IAgO9G,CAAC,OAAO,CAAC,IAAI,IAAI;IASjB,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC;CAGpC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
declare module '@warp-drive-mirror/schema-record/schema' {
|
|
2
|
+
import type { FieldSchema } from '@ember-data-mirror/store/-types/q/schema-service';
|
|
3
|
+
import type { StableRecordIdentifier } from '@warp-drive-mirror/core-types';
|
|
4
|
+
import type { Value } from '@warp-drive-mirror/core-types/json/raw';
|
|
5
|
+
import type { AttributeSchema, RelationshipSchema } from '@warp-drive-mirror/core-types/schema';
|
|
6
|
+
import type { SchemaRecord } from '@warp-drive-mirror/schema-record/record';
|
|
7
|
+
export { withFields, registerDerivations } from '@warp-drive-mirror/schema-record/-base-fields';
|
|
8
|
+
/**
|
|
9
|
+
* The full schema for a resource
|
|
10
|
+
*
|
|
11
|
+
* @class FieldSpec
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
type FieldSpec = {
|
|
15
|
+
'@id': FieldSchema | null;
|
|
16
|
+
/**
|
|
17
|
+
* legacy schema service separated attribute
|
|
18
|
+
* from relationship lookup
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
attributes: Record<string, AttributeSchema>;
|
|
22
|
+
/**
|
|
23
|
+
* legacy schema service separated attribute
|
|
24
|
+
* from relationship lookup
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
relationships: Record<string, RelationshipSchema>;
|
|
28
|
+
/**
|
|
29
|
+
* new schema service is fields based
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
fields: Map<string, FieldSchema>;
|
|
33
|
+
/**
|
|
34
|
+
* legacy model mode support
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
legacy?: boolean;
|
|
38
|
+
};
|
|
39
|
+
export type Transform<T extends Value = string, PT = unknown> = {
|
|
40
|
+
serialize(value: PT, options: Record<string, unknown> | null, record: SchemaRecord): T;
|
|
41
|
+
hydrate(value: T | undefined, options: Record<string, unknown> | null, record: SchemaRecord): PT;
|
|
42
|
+
defaultValue?(options: Record<string, unknown> | null, identifier: StableRecordIdentifier): T;
|
|
43
|
+
};
|
|
44
|
+
export type Derivation<R, T> = (record: R, options: Record<string, unknown> | null, prop: string) => T;
|
|
45
|
+
export class SchemaService {
|
|
46
|
+
schemas: Map<string, FieldSpec>;
|
|
47
|
+
transforms: Map<string, Transform<Value>>;
|
|
48
|
+
derivations: Map<string, Derivation<unknown, unknown>>;
|
|
49
|
+
constructor();
|
|
50
|
+
registerTransform<T extends Value = string, PT = unknown>(type: string, transform: Transform<T, PT>): void;
|
|
51
|
+
registerDerivation<R, T>(type: string, derivation: Derivation<R, T>): void;
|
|
52
|
+
defineSchema(name: string, schema: {
|
|
53
|
+
legacy?: boolean;
|
|
54
|
+
fields: FieldSchema[];
|
|
55
|
+
}): void;
|
|
56
|
+
fields({ type }: {
|
|
57
|
+
type: string;
|
|
58
|
+
}): FieldSpec['fields'];
|
|
59
|
+
attributesDefinitionFor({ type }: {
|
|
60
|
+
type: string;
|
|
61
|
+
}): FieldSpec['attributes'];
|
|
62
|
+
relationshipsDefinitionFor({ type }: {
|
|
63
|
+
type: string;
|
|
64
|
+
}): FieldSpec['relationships'];
|
|
65
|
+
doesTypeExist(type: string): boolean;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAG7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEjE;;;;;GAKG;AACH,KAAK,SAAS,GAAG;IACf,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC5C;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAClD;;;OAGG;IACH,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACjC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,KAAK,GAAG,MAAM,EAAE,EAAE,GAAG,OAAO,IAAI;IAC9D,SAAS,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,YAAY,GAAG,CAAC,CAAC;IACvF,OAAO,CAAC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