@warp-drive/schema-record 0.0.0-alpha.49 → 0.0.0-alpha.56
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 +253 -62
- package/dist/record.js.map +1 -0
- package/dist/schema.js +242 -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 +63 -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-main.cjs
ADDED
package/{addon → dist}/hooks.js
RENAMED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { SchemaRecord
|
|
1
|
+
import { SchemaRecord } from "./record";
|
|
2
|
+
import { E as Editable, L as Legacy, D as Destroy } from "./symbols-CAUfvZjq";
|
|
2
3
|
function instantiateRecord(store, identifier, createArgs) {
|
|
3
4
|
const schema = store.schema;
|
|
4
|
-
const isLegacy = schema.
|
|
5
|
+
const isLegacy = schema.resource(identifier)?.legacy ?? false;
|
|
5
6
|
const isEditable = isLegacy || Boolean(createArgs);
|
|
6
7
|
const record = new SchemaRecord(store, identifier, {
|
|
7
8
|
[Editable]: isEditable,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../src/hooks.ts"],"sourcesContent":["import type Store from '@ember-data/store';\nimport type { StableRecordIdentifier } from '@warp-drive/core-types';\n\nimport { SchemaRecord } from './record';\nimport type { SchemaService } from './schema';\nimport { Destroy, Editable, Legacy } from './symbols';\n\nexport function instantiateRecord(\n store: Store,\n identifier: StableRecordIdentifier,\n createArgs?: Record<string, unknown>\n): SchemaRecord {\n const schema = store.schema as unknown as SchemaService;\n const isLegacy = schema.resource(identifier)?.legacy ?? false;\n const isEditable = isLegacy || Boolean(createArgs);\n const record = new SchemaRecord(store, identifier, {\n [Editable]: isEditable,\n [Legacy]: isLegacy,\n });\n\n if (createArgs) {\n Object.assign(record, createArgs);\n }\n\n return record;\n}\n\nexport function teardownRecord(record: SchemaRecord): void {\n record[Destroy]();\n}\n"],"names":["instantiateRecord","store","identifier","createArgs","schema","isLegacy","resource","legacy","isEditable","Boolean","record","SchemaRecord","Editable","Legacy","Object","assign","teardownRecord","Destroy"],"mappings":";;;AAOO,SAASA,iBAAiBA,CAC/BC,KAAY,EACZC,UAAkC,EAClCC,UAAoC,EACtB;AACd,EAAA,MAAMC,MAAM,GAAGH,KAAK,CAACG,MAAkC,CAAA;EACvD,MAAMC,QAAQ,GAAGD,MAAM,CAACE,QAAQ,CAACJ,UAAU,CAAC,EAAEK,MAAM,IAAI,KAAK,CAAA;AAC7D,EAAA,MAAMC,UAAU,GAAGH,QAAQ,IAAII,OAAO,CAACN,UAAU,CAAC,CAAA;EAClD,MAAMO,MAAM,GAAG,IAAIC,YAAY,CAACV,KAAK,EAAEC,UAAU,EAAE;IACjD,CAACU,QAAQ,GAAGJ,UAAU;AACtB,IAAA,CAACK,MAAM,GAAGR,QAAAA;AACZ,GAAC,CAAC,CAAA;AAEF,EAAA,IAAIF,UAAU,EAAE;AACdW,IAAAA,MAAM,CAACC,MAAM,CAACL,MAAM,EAAEP,UAAU,CAAC,CAAA;AACnC,GAAA;AAEA,EAAA,OAAOO,MAAM,CAAA;AACf,CAAA;AAEO,SAASM,cAAcA,CAACN,MAAoB,EAAQ;AACzDA,EAAAA,MAAM,CAACO,OAAO,CAAC,EAAE,CAAA;AACnB;;;;"}
|
package/{addon → dist}/record.js
RENAMED
|
@@ -1,14 +1,174 @@
|
|
|
1
|
-
import { assert } from '@ember/debug';
|
|
2
1
|
import { createSignal, subscribe, defineSignal, Signals, addToTransaction, entangleSignal, getSignal, peekSignal } from '@ember-data/tracking/-private';
|
|
2
|
+
import { getOrSetGlobal } from '@warp-drive/core-types/-private';
|
|
3
3
|
import { STRUCTURED } from '@warp-drive/core-types/request';
|
|
4
4
|
import { RecordStore } from '@warp-drive/core-types/symbols';
|
|
5
|
-
import { ARRAY_SIGNAL,
|
|
6
|
-
import { macroCondition,
|
|
7
|
-
const
|
|
8
|
-
const
|
|
5
|
+
import { S as SOURCE, A as ARRAY_SIGNAL, O as OBJECT_SIGNAL, D as Destroy, I as Identifier, E as Editable, P as Parent, C as Checkout, L as Legacy } from "./symbols-CAUfvZjq";
|
|
6
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
7
|
+
const ARRAY_GETTER_METHODS = new Set([Symbol.iterator, 'concat', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'map', 'reduce', 'reduceRight', 'slice', 'some', 'values']);
|
|
8
|
+
// const ARRAY_SETTER_METHODS = new Set<KeyType>(['push', 'pop', 'unshift', 'shift', 'splice', 'sort']);
|
|
9
|
+
const SYNC_PROPS = new Set(['[]', 'length']);
|
|
10
|
+
function isArrayGetter(prop) {
|
|
11
|
+
return ARRAY_GETTER_METHODS.has(prop);
|
|
12
|
+
}
|
|
13
|
+
// function isArraySetter<T>(prop: KeyType): prop is keyof Array<T> {
|
|
14
|
+
// return ARRAY_SETTER_METHODS.has(prop);
|
|
15
|
+
// }
|
|
16
|
+
// function isSelfProp<T extends object>(self: T, prop: KeyType): prop is keyof T {
|
|
17
|
+
// return prop in self;
|
|
18
|
+
// }
|
|
19
|
+
|
|
20
|
+
function convertToInt(prop) {
|
|
21
|
+
if (typeof prop === 'symbol') return null;
|
|
22
|
+
const num = Number(prop);
|
|
23
|
+
if (isNaN(num)) return null;
|
|
24
|
+
return num % 1 === 0 ? num : null;
|
|
25
|
+
}
|
|
26
|
+
function safeForEach(instance, arr, store, callback, target) {
|
|
27
|
+
if (target === undefined) {
|
|
28
|
+
target = null;
|
|
29
|
+
}
|
|
30
|
+
// clone to prevent mutation
|
|
31
|
+
arr = arr.slice();
|
|
32
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
33
|
+
if (!test) {
|
|
34
|
+
throw new Error('`forEach` expects a function as first argument.');
|
|
35
|
+
}
|
|
36
|
+
})(typeof callback === 'function') : {};
|
|
37
|
+
|
|
38
|
+
// because we retrieveLatest above we need not worry if array is mutated during iteration
|
|
39
|
+
// by unloadRecord/rollbackAttributes
|
|
40
|
+
// push/add/removeObject may still be problematic
|
|
41
|
+
// but this is a more traditionally expected forEach bug.
|
|
42
|
+
const length = arr.length; // we need to access length to ensure we are consumed
|
|
43
|
+
|
|
44
|
+
for (let index = 0; index < length; index++) {
|
|
45
|
+
callback.call(target, arr[index], index, instance);
|
|
46
|
+
}
|
|
47
|
+
return instance;
|
|
48
|
+
}
|
|
49
|
+
class ManagedArray {
|
|
50
|
+
[SOURCE];
|
|
51
|
+
constructor(store, schema, cache, field, data, address, key, owner) {
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
53
|
+
const self = this;
|
|
54
|
+
this[SOURCE] = data?.slice();
|
|
55
|
+
this[ARRAY_SIGNAL] = createSignal(this, 'length');
|
|
56
|
+
const _SIGNAL = this[ARRAY_SIGNAL];
|
|
57
|
+
const boundFns = new Map();
|
|
58
|
+
this.address = address;
|
|
59
|
+
this.key = key;
|
|
60
|
+
this.owner = owner;
|
|
61
|
+
let transaction = false;
|
|
62
|
+
const proxy = new Proxy(this[SOURCE], {
|
|
63
|
+
get(target, prop, receiver) {
|
|
64
|
+
if (prop === ARRAY_SIGNAL) {
|
|
65
|
+
return _SIGNAL;
|
|
66
|
+
}
|
|
67
|
+
if (prop === 'address') {
|
|
68
|
+
return self.address;
|
|
69
|
+
}
|
|
70
|
+
if (prop === 'key') {
|
|
71
|
+
return self.key;
|
|
72
|
+
}
|
|
73
|
+
if (prop === 'owner') {
|
|
74
|
+
return self.owner;
|
|
75
|
+
}
|
|
76
|
+
const index = convertToInt(prop);
|
|
77
|
+
if (_SIGNAL.shouldReset && (index !== null || SYNC_PROPS.has(prop) || isArrayGetter(prop))) {
|
|
78
|
+
_SIGNAL.t = false;
|
|
79
|
+
_SIGNAL.shouldReset = false;
|
|
80
|
+
const newData = cache.getAttr(self.address, self.key);
|
|
81
|
+
if (newData && newData !== self[SOURCE]) {
|
|
82
|
+
self[SOURCE].length = 0;
|
|
83
|
+
self[SOURCE].push(...newData);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (index !== null) {
|
|
87
|
+
const val = target[index];
|
|
88
|
+
if (!transaction) {
|
|
89
|
+
subscribe(_SIGNAL);
|
|
90
|
+
}
|
|
91
|
+
if (field.type) {
|
|
92
|
+
const transform = schema.transformation(field.type);
|
|
93
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
94
|
+
if (!test) {
|
|
95
|
+
throw new Error(`No '${field.type}' transform defined for use by ${address.type}.${String(prop)}`);
|
|
96
|
+
}
|
|
97
|
+
})(transform) : {};
|
|
98
|
+
return transform.hydrate(val, field.options ?? null, self.owner);
|
|
99
|
+
}
|
|
100
|
+
return val;
|
|
101
|
+
}
|
|
102
|
+
if (isArrayGetter(prop)) {
|
|
103
|
+
let fn = boundFns.get(prop);
|
|
104
|
+
if (fn === undefined) {
|
|
105
|
+
if (prop === 'forEach') {
|
|
106
|
+
fn = function () {
|
|
107
|
+
subscribe(_SIGNAL);
|
|
108
|
+
transaction = true;
|
|
109
|
+
const result = safeForEach(receiver, target, store, arguments[0], arguments[1]);
|
|
110
|
+
transaction = false;
|
|
111
|
+
return result;
|
|
112
|
+
};
|
|
113
|
+
} else {
|
|
114
|
+
fn = function () {
|
|
115
|
+
subscribe(_SIGNAL);
|
|
116
|
+
// array functions must run through Reflect to work properly
|
|
117
|
+
// binding via other means will not work.
|
|
118
|
+
transaction = true;
|
|
119
|
+
const result = Reflect.apply(target[prop], receiver, arguments);
|
|
120
|
+
transaction = false;
|
|
121
|
+
return result;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
boundFns.set(prop, fn);
|
|
125
|
+
}
|
|
126
|
+
return fn;
|
|
127
|
+
}
|
|
128
|
+
return Reflect.get(target, prop, receiver);
|
|
129
|
+
},
|
|
130
|
+
set(target, prop, value, receiver) {
|
|
131
|
+
if (prop === 'address') {
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
133
|
+
self.address = value;
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
if (prop === 'key') {
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
138
|
+
self.key = value;
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
if (prop === 'owner') {
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
143
|
+
self.owner = value;
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
const reflect = Reflect.set(target, prop, value, receiver);
|
|
147
|
+
if (reflect) {
|
|
148
|
+
if (!field.type) {
|
|
149
|
+
cache.setAttr(self.address, self.key, self[SOURCE]);
|
|
150
|
+
_SIGNAL.shouldReset = true;
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
const transform = schema.transformation(field.type);
|
|
154
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
155
|
+
if (!test) {
|
|
156
|
+
throw new Error(`No '${field.type}' transform defined for use by ${address.type}.${String(prop)}`);
|
|
157
|
+
}
|
|
158
|
+
})(transform) : {};
|
|
159
|
+
const rawValue = self[SOURCE].map(item => transform.serialize(item, field.options ?? null, self.owner));
|
|
160
|
+
cache.setAttr(self.address, self.key, rawValue);
|
|
161
|
+
_SIGNAL.shouldReset = true;
|
|
162
|
+
}
|
|
163
|
+
return reflect;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return proxy;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
9
169
|
class ManagedObject {
|
|
170
|
+
[SOURCE];
|
|
10
171
|
constructor(store, schema, cache, field, data, address, key, owner) {
|
|
11
|
-
this[SOURCE] = void 0;
|
|
12
172
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
13
173
|
const self = this;
|
|
14
174
|
this[SOURCE] = {
|
|
@@ -39,11 +199,13 @@ class ManagedObject {
|
|
|
39
199
|
_SIGNAL.shouldReset = false;
|
|
40
200
|
let newData = cache.getAttr(self.address, self.key);
|
|
41
201
|
if (newData && newData !== self[SOURCE]) {
|
|
42
|
-
if (field.type
|
|
43
|
-
const transform = schema.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
202
|
+
if (field.type) {
|
|
203
|
+
const transform = schema.transformation(field.type);
|
|
204
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
205
|
+
if (!test) {
|
|
206
|
+
throw new Error(`No '${field.type}' transform defined for use by ${address.type}.${String(prop)}`);
|
|
207
|
+
}
|
|
208
|
+
})(transform) : {};
|
|
47
209
|
newData = transform.hydrate(newData, field.options ?? null, self.owner);
|
|
48
210
|
}
|
|
49
211
|
self[SOURCE] = {
|
|
@@ -77,15 +239,17 @@ class ManagedObject {
|
|
|
77
239
|
}
|
|
78
240
|
const reflect = Reflect.set(target, prop, value, receiver);
|
|
79
241
|
if (reflect) {
|
|
80
|
-
if (field.type
|
|
242
|
+
if (!field.type) {
|
|
81
243
|
cache.setAttr(self.address, self.key, self[SOURCE]);
|
|
82
244
|
_SIGNAL.shouldReset = true;
|
|
83
245
|
return true;
|
|
84
246
|
}
|
|
85
|
-
const transform = schema.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
247
|
+
const transform = schema.transformation(field.type);
|
|
248
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
249
|
+
if (!test) {
|
|
250
|
+
throw new Error(`No '${field.type}' transform defined for use by ${address.type}.${String(prop)}`);
|
|
251
|
+
}
|
|
252
|
+
})(transform) : {};
|
|
89
253
|
const val = transform.serialize(self[SOURCE], field.options ?? null, self.owner);
|
|
90
254
|
cache.setAttr(self.address, self.key, val);
|
|
91
255
|
_SIGNAL.shouldReset = true;
|
|
@@ -96,16 +260,11 @@ class ManagedObject {
|
|
|
96
260
|
return proxy;
|
|
97
261
|
}
|
|
98
262
|
}
|
|
99
|
-
const Destroy = Symbol('Destroy');
|
|
100
|
-
const Identifier = Symbol('Identifier');
|
|
101
|
-
const Editable = Symbol('Editable');
|
|
102
|
-
const Parent = Symbol('Parent');
|
|
103
|
-
const Checkout = Symbol('Checkout');
|
|
104
|
-
const Legacy = Symbol('Legacy');
|
|
105
263
|
const IgnoredGlobalFields = new Set(['then', STRUCTURED]);
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
264
|
+
const symbolList = [Destroy, RecordStore, Identifier, Editable, Parent, Checkout, Legacy, Signals];
|
|
265
|
+
const RecordSymbols = new Set(symbolList);
|
|
266
|
+
const ManagedArrayMap = getOrSetGlobal('ManagedArrayMap', new Map());
|
|
267
|
+
const ManagedObjectMap = getOrSetGlobal('ManagedObjectMap', new Map());
|
|
109
268
|
function computeLocal(record, field, prop) {
|
|
110
269
|
let signal = peekSignal(record, prop);
|
|
111
270
|
if (!signal) {
|
|
@@ -128,13 +287,15 @@ function peekManagedObject(record, field) {
|
|
|
128
287
|
}
|
|
129
288
|
function computeField(schema, cache, record, identifier, field, prop) {
|
|
130
289
|
const rawValue = cache.getAttr(identifier, prop);
|
|
131
|
-
if (field.type
|
|
290
|
+
if (!field.type) {
|
|
132
291
|
return rawValue;
|
|
133
292
|
}
|
|
134
|
-
const transform = schema.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
293
|
+
const transform = schema.transformation(field.type);
|
|
294
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
295
|
+
if (!test) {
|
|
296
|
+
throw new Error(`No '${field.type}' transform defined for use by ${identifier.type}.${String(prop)}`);
|
|
297
|
+
}
|
|
298
|
+
})(transform) : {};
|
|
138
299
|
return transform.hydrate(rawValue, field.options ?? null, record);
|
|
139
300
|
}
|
|
140
301
|
function computeArray(store, schema, cache, record, identifier, field, prop) {
|
|
@@ -179,11 +340,13 @@ function computeObject(store, schema, cache, record, identifier, field, prop) {
|
|
|
179
340
|
return null;
|
|
180
341
|
}
|
|
181
342
|
if (field.kind === 'object') {
|
|
182
|
-
if (field.type
|
|
183
|
-
const transform = schema.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
343
|
+
if (field.type) {
|
|
344
|
+
const transform = schema.transformation(field.type);
|
|
345
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
346
|
+
if (!test) {
|
|
347
|
+
throw new Error(`No '${field.type}' transform defined for use by ${identifier.type}.${String(prop)}`);
|
|
348
|
+
}
|
|
349
|
+
})(transform) : {};
|
|
187
350
|
rawValue = transform.hydrate(rawValue, field.options ?? null, record);
|
|
188
351
|
}
|
|
189
352
|
}
|
|
@@ -200,13 +363,15 @@ function computeAttribute(cache, identifier, prop) {
|
|
|
200
363
|
return cache.getAttr(identifier, prop);
|
|
201
364
|
}
|
|
202
365
|
function computeDerivation(schema, record, identifier, field, prop) {
|
|
203
|
-
if (field.type
|
|
366
|
+
if (!field.type) {
|
|
204
367
|
throw new Error(`The schema for ${identifier.type}.${String(prop)} is missing the type of the derivation`);
|
|
205
368
|
}
|
|
206
|
-
const derivation = schema.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
369
|
+
const derivation = schema.derivation(field.type);
|
|
370
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
371
|
+
if (!test) {
|
|
372
|
+
throw new Error(`No '${field.type}' derivation defined for use by ${identifier.type}.${String(prop)}`);
|
|
373
|
+
}
|
|
374
|
+
})(derivation) : {};
|
|
210
375
|
return derivation(record, field.options ?? null, prop);
|
|
211
376
|
}
|
|
212
377
|
|
|
@@ -222,7 +387,7 @@ class ResourceRelationship {
|
|
|
222
387
|
this.lid = rawValue.lid ?? rawValue.links?.self ?? `relationship:${identifier.lid}.${name}`;
|
|
223
388
|
this.data = rawValue.data ? store.peekRecord(rawValue.data) : null;
|
|
224
389
|
this.name = name;
|
|
225
|
-
if (macroCondition(
|
|
390
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
226
391
|
this.links = Object.freeze(Object.assign({}, rawValue.links));
|
|
227
392
|
this.meta = Object.freeze(Object.assign({}, rawValue.meta));
|
|
228
393
|
} else {
|
|
@@ -272,6 +437,7 @@ class SchemaRecord {
|
|
|
272
437
|
this[Legacy] = Mode[Legacy] ?? false;
|
|
273
438
|
const schema = store.schema;
|
|
274
439
|
const cache = store.cache;
|
|
440
|
+
const identityField = schema.resource(identifier).identity;
|
|
275
441
|
const fields = schema.fields(identifier);
|
|
276
442
|
const signals = new Map();
|
|
277
443
|
this[Signals] = signals;
|
|
@@ -309,7 +475,7 @@ class SchemaRecord {
|
|
|
309
475
|
// for its own usage.
|
|
310
476
|
// _, @, $, *
|
|
311
477
|
|
|
312
|
-
const field = fields.get(prop);
|
|
478
|
+
const field = prop === identityField?.name ? identityField : fields.get(prop);
|
|
313
479
|
if (!field) {
|
|
314
480
|
if (IgnoredGlobalFields.has(prop)) {
|
|
315
481
|
return undefined;
|
|
@@ -320,6 +486,9 @@ class SchemaRecord {
|
|
|
320
486
|
case '@id':
|
|
321
487
|
entangleSignal(signals, receiver, '@identity');
|
|
322
488
|
return identifier.id;
|
|
489
|
+
case '@hash':
|
|
490
|
+
// TODO pass actual cache value not {}
|
|
491
|
+
return schema.hashFn(field.type)({}, field.options ?? null, field.name ?? null);
|
|
323
492
|
case '@local':
|
|
324
493
|
{
|
|
325
494
|
const lastValue = computeLocal(receiver, field, prop);
|
|
@@ -327,14 +496,22 @@ class SchemaRecord {
|
|
|
327
496
|
return lastValue;
|
|
328
497
|
}
|
|
329
498
|
case 'field':
|
|
330
|
-
|
|
499
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
500
|
+
if (!test) {
|
|
501
|
+
throw new Error(`SchemaRecord.${field.name} is not available in legacy mode because it has type '${field.kind}'`);
|
|
502
|
+
}
|
|
503
|
+
})(!target[Legacy]) : {};
|
|
331
504
|
entangleSignal(signals, receiver, field.name);
|
|
332
505
|
return computeField(schema, cache, target, identifier, field, prop);
|
|
333
506
|
case 'attribute':
|
|
334
507
|
entangleSignal(signals, receiver, field.name);
|
|
335
508
|
return computeAttribute(cache, identifier, prop);
|
|
336
509
|
case 'resource':
|
|
337
|
-
|
|
510
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
511
|
+
if (!test) {
|
|
512
|
+
throw new Error(`SchemaRecord.${field.name} is not available in legacy mode because it has type '${field.kind}'`);
|
|
513
|
+
}
|
|
514
|
+
})(!target[Legacy]) : {};
|
|
338
515
|
entangleSignal(signals, receiver, field.name);
|
|
339
516
|
return computeResource(store, cache, target, identifier, field, prop);
|
|
340
517
|
case 'derived':
|
|
@@ -342,7 +519,11 @@ class SchemaRecord {
|
|
|
342
519
|
case 'schema-array':
|
|
343
520
|
throw new Error(`Not Implemented`);
|
|
344
521
|
case 'array':
|
|
345
|
-
|
|
522
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
523
|
+
if (!test) {
|
|
524
|
+
throw new Error(`SchemaRecord.${field.name} is not available in legacy mode because it has type '${field.kind}'`);
|
|
525
|
+
}
|
|
526
|
+
})(!target[Legacy]) : {};
|
|
346
527
|
entangleSignal(signals, receiver, field.name);
|
|
347
528
|
return computeArray(store, schema, cache, target, identifier, field, prop);
|
|
348
529
|
case 'schema-object':
|
|
@@ -350,7 +531,11 @@ class SchemaRecord {
|
|
|
350
531
|
// use raw cache value as the object to manage
|
|
351
532
|
throw new Error(`Not Implemented`);
|
|
352
533
|
case 'object':
|
|
353
|
-
|
|
534
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
535
|
+
if (!test) {
|
|
536
|
+
throw new Error(`SchemaRecord.${field.name} is not available in legacy mode because it has type '${field.kind}'`);
|
|
537
|
+
}
|
|
538
|
+
})(!target[Legacy]) : {};
|
|
354
539
|
entangleSignal(signals, receiver, field.name);
|
|
355
540
|
// run transform, then use that value as the object to manage
|
|
356
541
|
return computeObject(store, schema, cache, target, identifier, field, prop);
|
|
@@ -378,14 +563,16 @@ class SchemaRecord {
|
|
|
378
563
|
}
|
|
379
564
|
case 'field':
|
|
380
565
|
{
|
|
381
|
-
if (field.type
|
|
566
|
+
if (!field.type) {
|
|
382
567
|
cache.setAttr(identifier, prop, value);
|
|
383
568
|
return true;
|
|
384
569
|
}
|
|
385
|
-
const transform = schema.
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
570
|
+
const transform = schema.transformation(field.type);
|
|
571
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
572
|
+
if (!test) {
|
|
573
|
+
throw new Error(`No '${field.type}' transform defined for use by ${identifier.type}.${String(prop)}`);
|
|
574
|
+
}
|
|
575
|
+
})(transform) : {};
|
|
389
576
|
const rawValue = transform.serialize(value, field.options ?? null, target);
|
|
390
577
|
cache.setAttr(identifier, prop, rawValue);
|
|
391
578
|
return true;
|
|
@@ -397,7 +584,7 @@ class SchemaRecord {
|
|
|
397
584
|
}
|
|
398
585
|
case 'array':
|
|
399
586
|
{
|
|
400
|
-
if (field.type
|
|
587
|
+
if (!field.type) {
|
|
401
588
|
cache.setAttr(identifier, prop, value?.slice());
|
|
402
589
|
const peeked = peekManagedArray(self, field);
|
|
403
590
|
if (peeked) {
|
|
@@ -409,10 +596,12 @@ class SchemaRecord {
|
|
|
409
596
|
}
|
|
410
597
|
return true;
|
|
411
598
|
}
|
|
412
|
-
const transform = schema.
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
599
|
+
const transform = schema.transformation(field.type);
|
|
600
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
601
|
+
if (!test) {
|
|
602
|
+
throw new Error(`No '${field.type}' transform defined for use by ${identifier.type}.${String(prop)}`);
|
|
603
|
+
}
|
|
604
|
+
})(transform) : {};
|
|
416
605
|
const rawValue = value.map(item => transform.serialize(item, field.options ?? null, target));
|
|
417
606
|
cache.setAttr(identifier, prop, rawValue);
|
|
418
607
|
const peeked = peekManagedArray(self, field);
|
|
@@ -424,7 +613,7 @@ class SchemaRecord {
|
|
|
424
613
|
}
|
|
425
614
|
case 'object':
|
|
426
615
|
{
|
|
427
|
-
if (field.type
|
|
616
|
+
if (!field.type) {
|
|
428
617
|
let newValue = value;
|
|
429
618
|
if (value !== null) {
|
|
430
619
|
newValue = {
|
|
@@ -441,10 +630,12 @@ class SchemaRecord {
|
|
|
441
630
|
}
|
|
442
631
|
return true;
|
|
443
632
|
}
|
|
444
|
-
const transform = schema.
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
633
|
+
const transform = schema.transformation(field.type);
|
|
634
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
635
|
+
if (!test) {
|
|
636
|
+
throw new Error(`No '${field.type}' transform defined for use by ${identifier.type}.${String(prop)}`);
|
|
637
|
+
}
|
|
638
|
+
})(transform) : {};
|
|
448
639
|
const rawValue = transform.serialize({
|
|
449
640
|
...value
|
|
450
641
|
}, field.options ?? null, target);
|
|
@@ -479,4 +670,4 @@ class SchemaRecord {
|
|
|
479
670
|
return Promise.resolve(this);
|
|
480
671
|
}
|
|
481
672
|
}
|
|
482
|
-
export {
|
|
673
|
+
export { Editable, Legacy, SchemaRecord };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","sources":["../src/managed-array.ts","../src/managed-object.ts","../src/record.ts"],"sourcesContent":["import type Store from '@ember-data/store';\nimport type { Signal } from '@ember-data/tracking/-private';\nimport { addToTransaction, createSignal, subscribe } from '@ember-data/tracking/-private';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { StableRecordIdentifier } from '@warp-drive/core-types';\nimport type { Cache } from '@warp-drive/core-types/cache';\nimport type { ArrayValue, Value } from '@warp-drive/core-types/json/raw';\nimport type { OpaqueRecordInstance } from '@warp-drive/core-types/record';\nimport type { ArrayField } from '@warp-drive/core-types/schema/fields';\n\nimport type { SchemaRecord } from './record';\nimport type { SchemaService } from './schema';\nimport { ARRAY_SIGNAL, MUTATE, SOURCE } from './symbols';\n\nexport function notifyArray(arr: ManagedArray) {\n addToTransaction(arr[ARRAY_SIGNAL]);\n}\n\ntype KeyType = string | symbol | number;\nconst ARRAY_GETTER_METHODS = new Set<KeyType>([\n Symbol.iterator,\n 'concat',\n 'entries',\n 'every',\n 'fill',\n 'filter',\n 'find',\n 'findIndex',\n 'flat',\n 'flatMap',\n 'forEach',\n 'includes',\n 'indexOf',\n 'join',\n 'keys',\n 'lastIndexOf',\n 'map',\n 'reduce',\n 'reduceRight',\n 'slice',\n 'some',\n 'values',\n]);\n// const ARRAY_SETTER_METHODS = new Set<KeyType>(['push', 'pop', 'unshift', 'shift', 'splice', 'sort']);\nconst SYNC_PROPS = new Set<KeyType>(['[]', 'length']);\nfunction isArrayGetter<T>(prop: KeyType): prop is keyof Array<T> {\n return ARRAY_GETTER_METHODS.has(prop);\n}\n// function isArraySetter<T>(prop: KeyType): prop is keyof Array<T> {\n// return ARRAY_SETTER_METHODS.has(prop);\n// }\n// function isSelfProp<T extends object>(self: T, prop: KeyType): prop is keyof T {\n// return prop in self;\n// }\n\nfunction convertToInt(prop: KeyType): number | null {\n if (typeof prop === 'symbol') return null;\n\n const num = Number(prop);\n\n if (isNaN(num)) return null;\n\n return num % 1 === 0 ? num : null;\n}\n\ntype ProxiedMethod = (...args: unknown[]) => unknown;\n\ntype ForEachCB = (record: OpaqueRecordInstance, index: number, context: typeof Proxy<unknown[]>) => void;\nfunction safeForEach(\n instance: typeof Proxy<unknown[]>,\n arr: unknown[],\n store: Store,\n callback: ForEachCB,\n target: unknown\n) {\n if (target === undefined) {\n target = null;\n }\n // clone to prevent mutation\n arr = arr.slice();\n assert('`forEach` expects a function as first argument.', typeof callback === 'function');\n\n // because we retrieveLatest above we need not worry if array is mutated during iteration\n // by unloadRecord/rollbackAttributes\n // push/add/removeObject may still be problematic\n // but this is a more traditionally expected forEach bug.\n const length = arr.length; // we need to access length to ensure we are consumed\n\n for (let index = 0; index < length; index++) {\n callback.call(target, arr[index], index, instance);\n }\n\n return instance;\n}\n\nexport interface ManagedArray extends Omit<Array<unknown>, '[]'> {\n [MUTATE]?(\n target: unknown[],\n receiver: typeof Proxy<unknown[]>,\n prop: string,\n args: unknown[],\n _SIGNAL: Signal\n ): unknown;\n}\n\nexport class ManagedArray {\n [SOURCE]: unknown[];\n declare address: StableRecordIdentifier;\n declare key: string;\n declare owner: SchemaRecord;\n declare [ARRAY_SIGNAL]: Signal;\n\n constructor(\n store: Store,\n schema: SchemaService,\n cache: Cache,\n field: ArrayField,\n data: unknown[],\n address: StableRecordIdentifier,\n key: string,\n owner: SchemaRecord\n ) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n this[SOURCE] = data?.slice();\n this[ARRAY_SIGNAL] = createSignal(this, 'length');\n const _SIGNAL = this[ARRAY_SIGNAL];\n const boundFns = new Map<KeyType, ProxiedMethod>();\n this.address = address;\n this.key = key;\n this.owner = owner;\n let transaction = false;\n\n const proxy = new Proxy(this[SOURCE], {\n get<R extends typeof Proxy<unknown[]>>(target: unknown[], prop: keyof R, receiver: R) {\n if (prop === ARRAY_SIGNAL) {\n return _SIGNAL;\n }\n if (prop === 'address') {\n return self.address;\n }\n if (prop === 'key') {\n return self.key;\n }\n if (prop === 'owner') {\n return self.owner;\n }\n\n const index = convertToInt(prop);\n if (_SIGNAL.shouldReset && (index !== null || SYNC_PROPS.has(prop) || isArrayGetter(prop))) {\n _SIGNAL.t = false;\n _SIGNAL.shouldReset = false;\n const newData = cache.getAttr(self.address, self.key);\n if (newData && newData !== self[SOURCE]) {\n self[SOURCE].length = 0;\n self[SOURCE].push(...(newData as ArrayValue));\n }\n }\n\n if (index !== null) {\n const val = target[index];\n if (!transaction) {\n subscribe(_SIGNAL);\n }\n if (field.type) {\n const transform = schema.transformation(field.type);\n assert(`No '${field.type}' transform defined for use by ${address.type}.${String(prop)}`, transform);\n return transform.hydrate(val as Value, field.options ?? null, self.owner);\n }\n return val;\n }\n\n if (isArrayGetter(prop)) {\n let fn = boundFns.get(prop);\n\n if (fn === undefined) {\n if (prop === 'forEach') {\n fn = function () {\n subscribe(_SIGNAL);\n transaction = true;\n const result = safeForEach(receiver, target, store, arguments[0] as ForEachCB, arguments[1]);\n transaction = false;\n return result;\n };\n } else {\n fn = function () {\n subscribe(_SIGNAL);\n // array functions must run through Reflect to work properly\n // binding via other means will not work.\n transaction = true;\n const result = Reflect.apply(target[prop] as ProxiedMethod, receiver, arguments) as unknown;\n transaction = false;\n return result;\n };\n }\n boundFns.set(prop, fn);\n }\n return fn;\n }\n\n return Reflect.get(target, prop, receiver);\n },\n set(target, prop: KeyType, value, receiver) {\n if (prop === 'address') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n self.address = value;\n return true;\n }\n if (prop === 'key') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n self.key = value;\n return true;\n }\n if (prop === 'owner') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n self.owner = value;\n return true;\n }\n const reflect = Reflect.set(target, prop, value, receiver);\n\n if (reflect) {\n if (!field.type) {\n cache.setAttr(self.address, self.key, self[SOURCE] as Value);\n _SIGNAL.shouldReset = true;\n return true;\n }\n\n const transform = schema.transformation(field.type);\n assert(`No '${field.type}' transform defined for use by ${address.type}.${String(prop)}`, transform);\n const rawValue = (self[SOURCE] as ArrayValue).map((item) =>\n transform.serialize(item, field.options ?? null, self.owner)\n );\n cache.setAttr(self.address, self.key, rawValue as Value);\n _SIGNAL.shouldReset = true;\n }\n return reflect;\n },\n }) as ManagedArray;\n\n return proxy;\n }\n}\n","import type Store from '@ember-data/store';\nimport type { Signal } from '@ember-data/tracking/-private';\nimport { addToTransaction, createSignal, subscribe } from '@ember-data/tracking/-private';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { StableRecordIdentifier } from '@warp-drive/core-types';\nimport type { Cache } from '@warp-drive/core-types/cache';\nimport type { ObjectValue, Value } from '@warp-drive/core-types/json/raw';\nimport type { ObjectField } from '@warp-drive/core-types/schema/fields';\n\nimport type { SchemaRecord } from './record';\nimport type { SchemaService } from './schema';\nimport { MUTATE, OBJECT_SIGNAL, SOURCE } from './symbols';\n\nexport function notifyObject(obj: ManagedObject) {\n addToTransaction(obj[OBJECT_SIGNAL]);\n}\n\ntype KeyType = string | symbol | number;\n\nexport interface ManagedObject {\n [MUTATE]?(\n target: unknown[],\n receiver: typeof Proxy<unknown[]>,\n prop: string,\n args: unknown[],\n _SIGNAL: Signal\n ): unknown;\n}\n\nexport class ManagedObject {\n [SOURCE]: object;\n declare address: StableRecordIdentifier;\n declare key: string;\n declare owner: SchemaRecord;\n declare [OBJECT_SIGNAL]: Signal;\n\n constructor(\n store: Store,\n schema: SchemaService,\n cache: Cache,\n field: ObjectField,\n data: object,\n address: StableRecordIdentifier,\n key: string,\n owner: SchemaRecord\n ) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n this[SOURCE] = { ...data };\n this[OBJECT_SIGNAL] = createSignal(this, 'length');\n const _SIGNAL = this[OBJECT_SIGNAL];\n // const boundFns = new Map<KeyType, ProxiedMethod>();\n this.address = address;\n this.key = key;\n this.owner = owner;\n const transaction = false;\n\n const proxy = new Proxy(this[SOURCE], {\n get<R extends typeof Proxy<object>>(target: object, prop: keyof R, receiver: R) {\n if (prop === OBJECT_SIGNAL) {\n return _SIGNAL;\n }\n if (prop === 'address') {\n return self.address;\n }\n if (prop === 'key') {\n return self.key;\n }\n if (prop === 'owner') {\n return self.owner;\n }\n\n if (_SIGNAL.shouldReset) {\n _SIGNAL.t = false;\n _SIGNAL.shouldReset = false;\n let newData = cache.getAttr(self.address, self.key);\n if (newData && newData !== self[SOURCE]) {\n if (field.type) {\n const transform = schema.transformation(field.type);\n assert(`No '${field.type}' transform defined for use by ${address.type}.${String(prop)}`, transform);\n newData = transform.hydrate(newData as ObjectValue, field.options ?? null, self.owner) as ObjectValue;\n }\n self[SOURCE] = { ...(newData as ObjectValue) }; // Add type assertion for newData\n }\n }\n\n if (prop in self[SOURCE]) {\n if (!transaction) {\n subscribe(_SIGNAL);\n }\n\n return (self[SOURCE] as R)[prop];\n }\n return Reflect.get(target, prop, receiver) as R;\n },\n\n set(target, prop: KeyType, value, receiver) {\n if (prop === 'address') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n self.address = value;\n return true;\n }\n if (prop === 'key') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n self.key = value;\n return true;\n }\n if (prop === 'owner') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n self.owner = value;\n return true;\n }\n const reflect = Reflect.set(target, prop, value, receiver);\n\n if (reflect) {\n if (!field.type) {\n cache.setAttr(self.address, self.key, self[SOURCE] as Value);\n _SIGNAL.shouldReset = true;\n return true;\n }\n\n const transform = schema.transformation(field.type);\n assert(`No '${field.type}' transform defined for use by ${address.type}.${String(prop)}`, transform);\n const val = transform.serialize(self[SOURCE], field.options ?? null, self.owner);\n cache.setAttr(self.address, self.key, val);\n _SIGNAL.shouldReset = true;\n }\n return reflect;\n },\n }) as ManagedObject;\n\n return proxy;\n }\n}\n","import type { Future } from '@ember-data/request';\nimport type Store from '@ember-data/store';\nimport type { NotificationType, StoreRequestInput } from '@ember-data/store';\nimport {\n addToTransaction,\n defineSignal,\n entangleSignal,\n getSignal,\n peekSignal,\n type Signal,\n Signals,\n} from '@ember-data/tracking/-private';\nimport { DEBUG } from '@warp-drive/build-config/env';\nimport { assert } from '@warp-drive/build-config/macros';\nimport type { StableRecordIdentifier } from '@warp-drive/core-types';\nimport { getOrSetGlobal } from '@warp-drive/core-types/-private';\nimport type { Cache } from '@warp-drive/core-types/cache';\nimport type { ResourceRelationship as SingleResourceRelationship } from '@warp-drive/core-types/cache/relationship';\nimport type { ArrayValue, ObjectValue, Value } from '@warp-drive/core-types/json/raw';\nimport { STRUCTURED } from '@warp-drive/core-types/request';\nimport type {\n ArrayField,\n DerivedField,\n FieldSchema,\n GenericField,\n LocalField,\n ObjectField,\n} from '@warp-drive/core-types/schema/fields';\nimport type { Link, Links } from '@warp-drive/core-types/spec/json-api-raw';\nimport { RecordStore } from '@warp-drive/core-types/symbols';\n\nimport { ManagedArray } from './managed-array';\nimport { ManagedObject } from './managed-object';\nimport type { SchemaService } from './schema';\nimport { ARRAY_SIGNAL, Checkout, Destroy, Editable, Identifier, Legacy, OBJECT_SIGNAL, Parent } from './symbols';\n\nexport { Editable, Legacy } from './symbols';\nconst IgnoredGlobalFields = new Set<string>(['then', STRUCTURED]);\nconst symbolList = [Destroy, RecordStore, Identifier, Editable, Parent, Checkout, Legacy, Signals];\nconst RecordSymbols = new Set(symbolList);\n\ntype RecordSymbol = (typeof symbolList)[number];\n\nconst ManagedArrayMap = getOrSetGlobal('ManagedArrayMap', new Map<SchemaRecord, Map<FieldSchema, ManagedArray>>());\nconst ManagedObjectMap = getOrSetGlobal('ManagedObjectMap', new Map<SchemaRecord, Map<FieldSchema, ManagedObject>>());\n\nfunction computeLocal(record: typeof Proxy<SchemaRecord>, field: LocalField, prop: string): unknown {\n let signal = peekSignal(record, prop);\n\n if (!signal) {\n signal = getSignal(record, prop, false);\n signal.lastValue = field.options?.defaultValue ?? null;\n }\n\n return signal.lastValue;\n}\n\nfunction peekManagedArray(record: SchemaRecord, field: FieldSchema): ManagedArray | undefined {\n const managedArrayMapForRecord = ManagedArrayMap.get(record);\n if (managedArrayMapForRecord) {\n return managedArrayMapForRecord.get(field);\n }\n}\n\nfunction peekManagedObject(record: SchemaRecord, field: FieldSchema): ManagedObject | undefined {\n const managedObjectMapForRecord = ManagedObjectMap.get(record);\n if (managedObjectMapForRecord) {\n return managedObjectMapForRecord.get(field);\n }\n}\n\nfunction computeField(\n schema: SchemaService,\n cache: Cache,\n record: SchemaRecord,\n identifier: StableRecordIdentifier,\n field: GenericField,\n prop: string\n): unknown {\n const rawValue = cache.getAttr(identifier, prop);\n if (!field.type) {\n return rawValue;\n }\n const transform = schema.transformation(field.type);\n assert(`No '${field.type}' transform defined for use by ${identifier.type}.${String(prop)}`, transform);\n return transform.hydrate(rawValue, field.options ?? null, record);\n}\n\nfunction computeArray(\n store: Store,\n schema: SchemaService,\n cache: Cache,\n record: SchemaRecord,\n identifier: StableRecordIdentifier,\n field: ArrayField,\n prop: string\n) {\n // the thing we hand out needs to know its owner and path in a private manner\n // its \"address\" is the parent identifier (identifier) + field name (field.name)\n // in the nested object case field name here is the full dot path from root resource to this value\n // its \"key\" is the field on the parent record\n // its \"owner\" is the parent record\n\n const managedArrayMapForRecord = ManagedArrayMap.get(record);\n let managedArray;\n if (managedArrayMapForRecord) {\n managedArray = managedArrayMapForRecord.get(field);\n }\n if (managedArray) {\n return managedArray;\n } else {\n const rawValue = cache.getAttr(identifier, prop) as unknown[];\n if (!rawValue) {\n return null;\n }\n managedArray = new ManagedArray(store, schema, cache, field, rawValue, identifier, prop, record);\n if (!managedArrayMapForRecord) {\n ManagedArrayMap.set(record, new Map([[field, managedArray]]));\n } else {\n managedArrayMapForRecord.set(field, managedArray);\n }\n }\n return managedArray;\n}\n\nfunction computeObject(\n store: Store,\n schema: SchemaService,\n cache: Cache,\n record: SchemaRecord,\n identifier: StableRecordIdentifier,\n field: ObjectField,\n prop: string\n) {\n const managedObjectMapForRecord = ManagedObjectMap.get(record);\n let managedObject;\n if (managedObjectMapForRecord) {\n managedObject = managedObjectMapForRecord.get(field);\n }\n if (managedObject) {\n return managedObject;\n } else {\n let rawValue = cache.getAttr(identifier, prop) as object;\n if (!rawValue) {\n return null;\n }\n if (field.kind === 'object') {\n if (field.type) {\n const transform = schema.transformation(field.type);\n assert(`No '${field.type}' transform defined for use by ${identifier.type}.${String(prop)}`, transform);\n rawValue = transform.hydrate(rawValue as ObjectValue, field.options ?? null, record) as object;\n }\n }\n managedObject = new ManagedObject(store, schema, cache, field, rawValue, identifier, prop, record);\n if (!managedObjectMapForRecord) {\n ManagedObjectMap.set(record, new Map([[field, managedObject]]));\n } else {\n managedObjectMapForRecord.set(field, managedObject);\n }\n }\n return managedObject;\n}\n\nfunction computeAttribute(cache: Cache, identifier: StableRecordIdentifier, prop: string): unknown {\n return cache.getAttr(identifier, prop);\n}\n\nfunction computeDerivation(\n schema: SchemaService,\n record: SchemaRecord,\n identifier: StableRecordIdentifier,\n field: DerivedField,\n prop: string\n): unknown {\n if (!field.type) {\n throw new Error(`The schema for ${identifier.type}.${String(prop)} is missing the type of the derivation`);\n }\n\n const derivation = schema.derivation(field.type);\n assert(`No '${field.type}' derivation defined for use by ${identifier.type}.${String(prop)}`, derivation);\n return derivation(record, field.options ?? null, prop);\n}\n\n// TODO probably this should just be a Document\n// but its separate until we work out the lid situation\nclass ResourceRelationship<T extends SchemaRecord = SchemaRecord> {\n declare lid: string;\n declare [Parent]: SchemaRecord;\n declare [RecordStore]: Store;\n declare name: string;\n\n declare data: T | null;\n declare links: Links;\n declare meta: Record<string, unknown>;\n\n constructor(\n store: Store,\n cache: Cache,\n parent: SchemaRecord,\n identifier: StableRecordIdentifier,\n field: FieldSchema,\n name: string\n ) {\n const rawValue = cache.getRelationship(identifier, name) as SingleResourceRelationship;\n\n // TODO setup true lids for relationship documents\n // @ts-expect-error we need to give relationship documents a lid\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n this.lid = rawValue.lid ?? rawValue.links?.self ?? `relationship:${identifier.lid}.${name}`;\n this.data = rawValue.data ? store.peekRecord<T>(rawValue.data) : null;\n this.name = name;\n\n if (DEBUG) {\n this.links = Object.freeze(Object.assign({}, rawValue.links));\n this.meta = Object.freeze(Object.assign({}, rawValue.meta));\n } else {\n this.links = rawValue.links ?? {};\n this.meta = rawValue.meta ?? {};\n }\n\n this[RecordStore] = store;\n this[Parent] = parent;\n }\n\n fetch(options?: StoreRequestInput<T, T>): Future<T> {\n const url = options?.url ?? getHref(this.links.related) ?? getHref(this.links.self) ?? null;\n\n if (!url) {\n throw new Error(\n `Cannot ${options?.method ?? 'fetch'} ${this[Parent][Identifier].type}.${String(\n this.name\n )} because it has no related link`\n );\n }\n const request = Object.assign(\n {\n url,\n method: 'GET',\n },\n options\n );\n\n return this[RecordStore].request<T>(request);\n }\n}\n\ndefineSignal(ResourceRelationship.prototype, 'data');\ndefineSignal(ResourceRelationship.prototype, 'links');\ndefineSignal(ResourceRelationship.prototype, 'meta');\n\nfunction getHref(link?: Link | null): string | null {\n if (!link) {\n return null;\n }\n if (typeof link === 'string') {\n return link;\n }\n return link.href;\n}\n\nfunction computeResource<T extends SchemaRecord>(\n store: Store,\n cache: Cache,\n parent: SchemaRecord,\n identifier: StableRecordIdentifier,\n field: FieldSchema,\n prop: string\n): ResourceRelationship<T> {\n if (field.kind !== 'resource') {\n throw new Error(`The schema for ${identifier.type}.${String(prop)} is not a resource relationship`);\n }\n\n return new ResourceRelationship<T>(store, cache, parent, identifier, field, prop);\n}\n\nexport class SchemaRecord {\n declare [RecordStore]: Store;\n declare [Identifier]: StableRecordIdentifier;\n declare [Editable]: boolean;\n declare [Legacy]: boolean;\n declare [Signals]: Map<string, Signal>;\n declare ___notifications: object;\n\n constructor(store: Store, identifier: StableRecordIdentifier, Mode: { [Editable]: boolean; [Legacy]: boolean }) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const self = this;\n this[RecordStore] = store;\n this[Identifier] = identifier;\n const IS_EDITABLE = (this[Editable] = Mode[Editable] ?? false);\n this[Legacy] = Mode[Legacy] ?? false;\n\n const schema = store.schema as unknown as SchemaService;\n const cache = store.cache;\n const identityField = schema.resource(identifier).identity;\n const fields = schema.fields(identifier);\n\n const signals: Map<string, Signal> = new Map();\n this[Signals] = signals;\n this.___notifications = store.notifications.subscribe(\n identifier,\n (_: StableRecordIdentifier, type: NotificationType, key?: string) => {\n switch (type) {\n case 'attributes':\n if (key) {\n const signal = signals.get(key);\n if (signal) {\n addToTransaction(signal);\n }\n const field = fields.get(key);\n if (field?.kind === 'array') {\n const peeked = peekManagedArray(self, field);\n if (peeked) {\n const arrSignal = peeked[ARRAY_SIGNAL];\n arrSignal.shouldReset = true;\n addToTransaction(arrSignal);\n }\n }\n }\n break;\n }\n }\n );\n\n return new Proxy(this, {\n get(target: SchemaRecord, prop: string | number | symbol, receiver: typeof Proxy<SchemaRecord>) {\n if (RecordSymbols.has(prop as RecordSymbol)) {\n return target[prop as keyof SchemaRecord];\n }\n\n if (prop === '___notifications') {\n return target.___notifications;\n }\n\n // SchemaRecord reserves use of keys that begin with these characters\n // for its own usage.\n // _, @, $, *\n\n const field = prop === identityField?.name ? identityField : fields.get(prop as string);\n if (!field) {\n if (IgnoredGlobalFields.has(prop as string)) {\n return undefined;\n }\n throw new Error(`No field named ${String(prop)} on ${identifier.type}`);\n }\n\n switch (field.kind) {\n case '@id':\n entangleSignal(signals, receiver, '@identity');\n return identifier.id;\n case '@hash':\n // TODO pass actual cache value not {}\n return schema.hashFn(field.type)({}, field.options ?? null, field.name ?? null);\n case '@local': {\n const lastValue = computeLocal(receiver, field, prop as string);\n entangleSignal(signals, receiver, prop as string);\n return lastValue;\n }\n case 'field':\n assert(\n `SchemaRecord.${field.name} is not available in legacy mode because it has type '${field.kind}'`,\n !target[Legacy]\n );\n entangleSignal(signals, receiver, field.name);\n return computeField(schema, cache, target, identifier, field, prop as string);\n case 'attribute':\n entangleSignal(signals, receiver, field.name);\n return computeAttribute(cache, identifier, prop as string);\n case 'resource':\n assert(\n `SchemaRecord.${field.name} is not available in legacy mode because it has type '${field.kind}'`,\n !target[Legacy]\n );\n entangleSignal(signals, receiver, field.name);\n return computeResource(store, cache, target, identifier, field, prop as string);\n case 'derived':\n return computeDerivation(schema, receiver as unknown as SchemaRecord, identifier, field, prop as string);\n case 'schema-array':\n throw new Error(`Not Implemented`);\n case 'array':\n assert(\n `SchemaRecord.${field.name} is not available in legacy mode because it has type '${field.kind}'`,\n !target[Legacy]\n );\n entangleSignal(signals, receiver, field.name);\n return computeArray(store, schema, cache, target, identifier, field, prop as string);\n case 'schema-object':\n // validate any access off of schema, no transform to run\n // use raw cache value as the object to manage\n throw new Error(`Not Implemented`);\n case 'object':\n assert(\n `SchemaRecord.${field.name} is not available in legacy mode because it has type '${field.kind}'`,\n !target[Legacy]\n );\n entangleSignal(signals, receiver, field.name);\n // run transform, then use that value as the object to manage\n return computeObject(store, schema, cache, target, identifier, field, prop as string);\n default:\n throw new Error(`Field '${String(prop)}' on '${identifier.type}' has the unknown kind '${field.kind}'`);\n }\n },\n set(target: SchemaRecord, prop: string | number | symbol, value: unknown, receiver: typeof Proxy<SchemaRecord>) {\n if (!IS_EDITABLE) {\n throw new Error(`Cannot set ${String(prop)} on ${identifier.type} because the record is not editable`);\n }\n\n const field = fields.get(prop as string);\n if (!field) {\n throw new Error(`There is no field named ${String(prop)} on ${identifier.type}`);\n }\n\n switch (field.kind) {\n case '@local': {\n const signal = getSignal(receiver, prop as string, true);\n if (signal.lastValue !== value) {\n signal.lastValue = value;\n addToTransaction(signal);\n }\n return true;\n }\n case 'field': {\n if (!field.type) {\n cache.setAttr(identifier, prop as string, value as Value);\n return true;\n }\n const transform = schema.transformation(field.type);\n assert(`No '${field.type}' transform defined for use by ${identifier.type}.${String(prop)}`, transform);\n\n const rawValue = transform.serialize(value, field.options ?? null, target);\n cache.setAttr(identifier, prop as string, rawValue);\n return true;\n }\n case 'attribute': {\n cache.setAttr(identifier, prop as string, value as Value);\n return true;\n }\n case 'array': {\n if (!field.type) {\n cache.setAttr(identifier, prop as string, (value as ArrayValue)?.slice());\n const peeked = peekManagedArray(self, field);\n if (peeked) {\n const arrSignal = peeked[ARRAY_SIGNAL];\n arrSignal.shouldReset = true;\n }\n if (!Array.isArray(value)) {\n ManagedArrayMap.delete(target);\n }\n return true;\n }\n\n const transform = schema.transformation(field.type);\n assert(`No '${field.type}' transform defined for use by ${identifier.type}.${String(prop)}`, transform);\n\n const rawValue = (value as ArrayValue).map((item) =>\n transform.serialize(item, field.options ?? null, target)\n );\n cache.setAttr(identifier, prop as string, rawValue);\n const peeked = peekManagedArray(self, field);\n if (peeked) {\n const arrSignal = peeked[ARRAY_SIGNAL];\n arrSignal.shouldReset = true;\n }\n return true;\n }\n case 'object': {\n if (!field.type) {\n let newValue = value;\n if (value !== null) {\n newValue = { ...(value as ObjectValue) };\n } else {\n ManagedObjectMap.delete(target);\n }\n\n cache.setAttr(identifier, prop as string, newValue as Value);\n\n const peeked = peekManagedObject(self, field);\n if (peeked) {\n const objSignal = peeked[OBJECT_SIGNAL];\n objSignal.shouldReset = true;\n }\n return true;\n }\n const transform = schema.transformation(field.type);\n assert(`No '${field.type}' transform defined for use by ${identifier.type}.${String(prop)}`, transform);\n const rawValue = transform.serialize({ ...(value as ObjectValue) }, field.options ?? null, target);\n\n cache.setAttr(identifier, prop as string, rawValue);\n const peeked = peekManagedObject(self, field);\n if (peeked) {\n const objSignal = peeked[OBJECT_SIGNAL];\n objSignal.shouldReset = true;\n }\n return true;\n }\n case 'derived': {\n throw new Error(`Cannot set ${String(prop)} on ${identifier.type} because it is derived`);\n }\n default:\n throw new Error(`Unknown field kind ${field.kind}`);\n }\n },\n });\n }\n\n [Destroy](): void {\n if (this[Legacy]) {\n // @ts-expect-error\n this.isDestroying = true;\n // @ts-expect-error\n this.isDestroyed = true;\n }\n this[RecordStore].notifications.unsubscribe(this.___notifications);\n }\n [Checkout](): Promise<SchemaRecord> {\n return Promise.resolve(this);\n }\n}\n"],"names":["ARRAY_GETTER_METHODS","Set","Symbol","iterator","SYNC_PROPS","isArrayGetter","prop","has","convertToInt","num","Number","isNaN","safeForEach","instance","arr","store","callback","target","undefined","slice","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","length","index","call","ManagedArray","SOURCE","constructor","schema","cache","field","data","address","key","owner","self","ARRAY_SIGNAL","createSignal","_SIGNAL","boundFns","Map","transaction","proxy","Proxy","get","receiver","shouldReset","t","newData","getAttr","push","val","subscribe","type","transform","transformation","String","hydrate","options","fn","result","arguments","Reflect","apply","set","value","reflect","setAttr","rawValue","map","item","serialize","ManagedObject","OBJECT_SIGNAL","IgnoredGlobalFields","STRUCTURED","symbolList","Destroy","RecordStore","Identifier","Editable","Parent","Checkout","Legacy","Signals","RecordSymbols","ManagedArrayMap","getOrSetGlobal","ManagedObjectMap","computeLocal","record","signal","peekSignal","getSignal","lastValue","defaultValue","peekManagedArray","managedArrayMapForRecord","peekManagedObject","managedObjectMapForRecord","computeField","identifier","computeArray","managedArray","computeObject","managedObject","kind","computeAttribute","computeDerivation","derivation","ResourceRelationship","parent","name","getRelationship","lid","links","peekRecord","Object","freeze","assign","meta","fetch","url","getHref","related","method","request","defineSignal","prototype","link","href","computeResource","SchemaRecord","Mode","IS_EDITABLE","identityField","resource","identity","fields","signals","___notifications","notifications","_","addToTransaction","peeked","arrSignal","entangleSignal","id","hashFn","Array","isArray","delete","newValue","obj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