@warp-drive/schema-record 0.0.0-alpha.50 → 0.0.0-alpha.57
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/addon-main.cjs +5 -0
- package/{addon → dist}/hooks.js +3 -2
- package/dist/hooks.js.map +1 -0
- package/{addon → dist}/record.js +202 -65
- package/dist/record.js.map +1 -0
- package/dist/schema.js +278 -0
- package/dist/schema.js.map +1 -0
- package/dist/symbols-CAUfvZjq.js +45 -0
- package/dist/symbols-CAUfvZjq.js.map +1 -0
- package/package.json +30 -42
- package/unstable-preview-types/hooks.d.ts.map +1 -1
- package/unstable-preview-types/index.d.ts +4 -4
- package/unstable-preview-types/managed-array.d.ts +3 -6
- package/unstable-preview-types/managed-array.d.ts.map +1 -1
- package/unstable-preview-types/managed-object.d.ts +3 -6
- package/unstable-preview-types/managed-object.d.ts.map +1 -1
- package/unstable-preview-types/record.d.ts +2 -6
- package/unstable-preview-types/record.d.ts.map +1 -1
- package/unstable-preview-types/schema.d.ts +69 -52
- package/unstable-preview-types/schema.d.ts.map +1 -1
- package/unstable-preview-types/symbols.d.ts +14 -0
- package/unstable-preview-types/symbols.d.ts.map +1 -0
- package/addon/hooks.js.map +0 -1
- package/addon/managed-array.js +0 -164
- package/addon/managed-array.js.map +0 -1
- package/addon/record.js.map +0 -1
- package/addon/schema.js +0 -152
- package/addon/schema.js.map +0 -1
- package/addon-main.js +0 -94
- package/unstable-preview-types/-base-fields.d.ts +0 -23
- package/unstable-preview-types/-base-fields.d.ts.map +0 -1
package/addon/schema.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { assert } from '@ember/debug';
|
|
2
|
-
import { createCache, getValue } from '@ember-data/tracking';
|
|
3
|
-
import { Signals } from '@ember-data/tracking/-private';
|
|
4
|
-
import { recordIdentifierFor } from '@ember-data/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 };
|
package/addon/schema.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/store';\nimport type { OpaqueRecordInstance } from '@ember-data/store/-types/q/record-instance';\nimport type { FieldSchema } from '@ember-data/store/-types/q/schema-service';\nimport type { StableRecordIdentifier } from '@warp-drive/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/store/-types/q/schema-service';\nimport { createCache, getValue } from '@ember-data/tracking';\nimport { type Signal, Signals } from '@ember-data/tracking/-private';\nimport type { StableRecordIdentifier } from '@warp-drive/core-types';\nimport type { Value } from '@warp-drive/core-types/json/raw';\nimport type { AttributeSchema, RelationshipSchema } from '@warp-drive/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,C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,IAAAA,IAAAA;AAAuB,GAAC,EAAuB;IACtD,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,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
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
const requireModule = require('@ember-data/private-build-infra/src/utilities/require-module');
|
|
2
|
-
const getEnv = require('@ember-data/private-build-infra/src/utilities/get-env');
|
|
3
|
-
const detectModule = require('@ember-data/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/debug', __dirname, pkg);
|
|
40
|
-
const HAS_META_PACKAGE = detectModule(require, 'ember-data', __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/private-build-infra/src/deprecations')(hostOptions.compatWith || null);
|
|
49
|
-
const FEATURES = require('@ember-data/private-build-infra/src/features')(isProd);
|
|
50
|
-
|
|
51
|
-
const ALL_PACKAGES = requireModule('@ember-data/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
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
declare module '@warp-drive/schema-record/-base-fields' {
|
|
2
|
-
import type { FieldSchema } from '@ember-data/store/-types/q/schema-service';
|
|
3
|
-
import type { StableRecordIdentifier } from '@warp-drive/core-types';
|
|
4
|
-
import { type SchemaRecord } from '@warp-drive/schema-record/record';
|
|
5
|
-
import type { SchemaService } from '@warp-drive/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
|
|
@@ -1 +0,0 @@
|
|
|
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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