@warp-drive/legacy 5.9.0-alpha.2 → 5.9.0-alpha.21
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/README.md +6 -0
- package/declarations/adapter/-private/build-url-mixin.d.ts +156 -0
- package/declarations/adapter/error.d.ts +385 -169
- package/declarations/adapter/json-api.d.ts +12 -1
- package/declarations/adapter/rest.d.ts +74 -0
- package/declarations/adapter.d.ts +6 -0
- package/declarations/compat/builders/find-all.d.ts +0 -1
- package/declarations/compat/extensions.d.ts +40 -0
- package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +7 -0
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +4 -0
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +7 -0
- package/declarations/compat/utils.d.ts +11 -0
- package/declarations/compat.d.ts +32 -0
- package/declarations/index.d.ts +142 -0
- package/declarations/model/-private/attr.d.ts +21 -0
- package/declarations/model/-private/belongs-to.d.ts +21 -0
- package/declarations/model/-private/hooks.d.ts +26 -0
- package/declarations/model/-private/model.d.ts +55 -4
- package/declarations/model/-private/promise-many-array.d.ts +25 -1
- package/declarations/model/-private/schema-provider.d.ts +11 -1
- package/declarations/model/migration-support.d.ts +31 -5
- package/declarations/model-fragments/extensions/fragment-array.d.ts +38 -0
- package/declarations/model-fragments/extensions/fragment.d.ts +35 -0
- package/declarations/model-fragments/hooks/model-for.d.ts +7 -0
- package/declarations/model-fragments/index.d.ts +8 -0
- package/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +6 -0
- package/declarations/model-fragments/utilities/with-array-defaults.d.ts +30 -0
- package/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +18 -0
- package/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +15 -0
- package/declarations/model-fragments/utilities/with-legacy.d.ts +8 -0
- package/declarations/serializer/-private/transforms/boolean.d.ts +13 -0
- package/declarations/serializer/-private/transforms/date.d.ts +15 -1
- package/declarations/serializer/-private/transforms/number.d.ts +14 -1
- package/declarations/serializer/-private/transforms/string.d.ts +14 -1
- package/declarations/serializer/-private/utils.d.ts +24 -0
- package/declarations/serializer/json-api.d.ts +1 -1
- package/declarations/serializer.d.ts +4 -6
- package/declarations/store/-private.d.ts +2 -2
- package/declarations/store.d.ts +7 -0
- package/dist/adapter/error.js +386 -241
- package/dist/adapter/json-api.js +12 -0
- package/dist/adapter/rest.js +39 -3
- package/dist/adapter.js +23 -26
- package/dist/compat/builders.js +0 -1
- package/dist/compat/extensions.js +80 -3
- package/dist/compat/utils.js +14 -0
- package/dist/compat.js +17 -0
- package/dist/{errors-Cz5KrzBk.js → errors-DZKA206g.js} +24 -1
- package/dist/{hooks-D6diaM34.js → hooks-BvOqJBei.js} +33 -2
- package/dist/index.js +168 -13
- package/dist/{json-ChdEfB0X.js → json-DU8m1pGf.js} +83 -6
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +15 -2
- package/dist/{unpkg/dev-deprecated/model-for-CqXsIKws.js → model-for-CXkJw59V.js} +77 -1
- package/dist/model-fragments.js +18 -2
- package/dist/model.js +12 -8
- package/dist/{schema-provider-DJCV_6AF.js → schema-provider-DtPOp0d7.js} +93 -6
- package/dist/serializer/json-api.js +8 -3
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +3 -4
- package/dist/serializer/transform.js +51 -3
- package/dist/serializer.js +4 -7
- package/dist/store.js +13 -7
- package/dist/unpkg/dev/adapter/error.js +386 -241
- package/dist/unpkg/dev/adapter/json-api.js +13 -1
- package/dist/unpkg/dev/adapter/rest.js +39 -3
- package/dist/unpkg/dev/adapter.js +23 -26
- package/dist/unpkg/dev/compat/builders.js +0 -1
- package/dist/unpkg/dev/compat/extensions.js +80 -3
- package/dist/unpkg/dev/compat/utils.js +14 -0
- package/dist/unpkg/dev/compat.js +34 -1
- package/dist/unpkg/dev/{errors-DmGGJr3T.js → errors-DngRU-If.js} +24 -1
- package/dist/unpkg/dev/{hooks-CkYiE6Ud.js → hooks-UuiLxWxS.js} +33 -2
- package/dist/unpkg/dev/index.js +171 -13
- package/dist/unpkg/dev/json-K2Y9z6MN.js +1333 -0
- package/dist/unpkg/dev/model/-private.js +1 -1
- package/dist/unpkg/dev/model/migration-support.js +16 -2
- package/dist/unpkg/{prod-deprecated/model-for-CqXsIKws.js → dev/model-for-CXkJw59V.js} +77 -1
- package/dist/unpkg/dev/model-fragments.js +18 -2
- package/dist/unpkg/dev/model.js +12 -8
- package/dist/unpkg/dev/{schema-provider-DDVYxmUV.js → schema-provider-0D7f-QOn.js} +92 -6
- package/dist/unpkg/dev/serializer/json-api.js +9 -4
- package/dist/unpkg/dev/serializer/json.js +1 -1
- package/dist/unpkg/dev/serializer/rest.js +3 -4
- package/dist/unpkg/dev/serializer/transform.js +51 -3
- package/dist/unpkg/dev/serializer.js +4 -7
- package/dist/unpkg/dev/store.js +21 -7
- package/dist/unpkg/dev-deprecated/adapter/error.js +386 -241
- package/dist/unpkg/dev-deprecated/adapter/json-api.js +13 -1
- package/dist/unpkg/dev-deprecated/adapter/rest.js +39 -3
- package/dist/unpkg/dev-deprecated/adapter.js +23 -26
- package/dist/unpkg/dev-deprecated/compat/builders.js +0 -1
- package/dist/unpkg/dev-deprecated/compat/extensions.js +80 -3
- package/dist/unpkg/dev-deprecated/compat/utils.js +14 -0
- package/dist/unpkg/dev-deprecated/compat.js +34 -1
- package/dist/unpkg/dev-deprecated/{errors-Spt6ubMd.js → errors-Bzidntpi.js} +24 -1
- package/dist/unpkg/dev-deprecated/{hooks-DOXegvhL.js → hooks-DVXhMW14.js} +33 -2
- package/dist/unpkg/dev-deprecated/index.js +171 -13
- package/dist/unpkg/{prod-deprecated/json-BWrZ5546.js → dev-deprecated/json-K2Y9z6MN.js} +96 -6
- package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/model/migration-support.js +16 -2
- package/dist/unpkg/{dev/model-for-CqXsIKws.js → dev-deprecated/model-for-CXkJw59V.js} +77 -1
- package/dist/unpkg/dev-deprecated/model-fragments.js +18 -2
- package/dist/unpkg/dev-deprecated/model.js +12 -8
- package/dist/unpkg/dev-deprecated/{schema-provider-BP6_8N-V.js → schema-provider-ZwO5_fZw.js} +84 -3
- package/dist/unpkg/dev-deprecated/serializer/json-api.js +9 -4
- package/dist/unpkg/dev-deprecated/serializer/json.js +1 -1
- package/dist/unpkg/dev-deprecated/serializer/rest.js +3 -4
- package/dist/unpkg/dev-deprecated/serializer/transform.js +51 -3
- package/dist/unpkg/dev-deprecated/serializer.js +4 -7
- package/dist/unpkg/dev-deprecated/store.js +21 -7
- package/dist/unpkg/prod/adapter/error.js +386 -241
- package/dist/unpkg/prod/adapter/json-api.js +13 -1
- package/dist/unpkg/prod/adapter/rest.js +39 -3
- package/dist/unpkg/prod/adapter.js +23 -26
- package/dist/unpkg/prod/compat/builders.js +0 -1
- package/dist/unpkg/prod/compat/extensions.js +70 -3
- package/dist/unpkg/prod/compat/utils.js +14 -0
- package/dist/unpkg/prod/compat.js +17 -0
- package/dist/unpkg/prod/{errors-BGVFCBmi.js → errors-B-PWeYlW.js} +24 -1
- package/dist/unpkg/prod/{hooks-BztVA_x0.js → hooks-Bx-zBziU.js} +32 -1
- package/dist/unpkg/prod/index.js +171 -5
- package/dist/unpkg/{dev/json-Cu1LNgmQ.js → prod/json-Qewu-UN9.js} +63 -19
- package/dist/unpkg/prod/model/-private.js +1 -1
- package/dist/unpkg/prod/model/migration-support.js +16 -2
- package/dist/unpkg/prod/model-for-CXkJw59V.js +297 -0
- package/dist/unpkg/prod/model-fragments.js +18 -2
- package/dist/unpkg/prod/model.js +12 -8
- package/dist/unpkg/prod/{schema-provider-DJtD_8jZ.js → schema-provider-BgRqk8i9.js} +96 -6
- package/dist/unpkg/prod/serializer/json-api.js +9 -4
- package/dist/unpkg/prod/serializer/json.js +1 -1
- package/dist/unpkg/prod/serializer/rest.js +3 -4
- package/dist/unpkg/prod/serializer/transform.js +51 -3
- package/dist/unpkg/prod/serializer.js +4 -7
- package/dist/unpkg/prod/store.js +21 -7
- package/dist/unpkg/prod-deprecated/adapter/error.js +386 -241
- package/dist/unpkg/prod-deprecated/adapter/json-api.js +13 -1
- package/dist/unpkg/prod-deprecated/adapter/rest.js +39 -3
- package/dist/unpkg/prod-deprecated/adapter.js +23 -26
- package/dist/unpkg/prod-deprecated/compat/builders.js +0 -1
- package/dist/unpkg/prod-deprecated/compat/extensions.js +70 -3
- package/dist/unpkg/prod-deprecated/compat/utils.js +14 -0
- package/dist/unpkg/prod-deprecated/compat.js +17 -0
- package/dist/unpkg/prod-deprecated/{errors-CdDaK81x.js → errors-Dl2J9d1D.js} +24 -1
- package/dist/unpkg/prod-deprecated/{hooks-yId87yyG.js → hooks-Cm60wWTf.js} +32 -1
- package/dist/unpkg/prod-deprecated/index.js +171 -5
- package/dist/unpkg/{dev-deprecated/json-Cu1LNgmQ.js → prod-deprecated/json-Qewu-UN9.js} +63 -19
- package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/model/migration-support.js +16 -2
- package/dist/{model-for-CqXsIKws.js → unpkg/prod-deprecated/model-for-CXkJw59V.js} +77 -1
- package/dist/unpkg/prod-deprecated/model-fragments.js +18 -2
- package/dist/unpkg/prod-deprecated/model.js +12 -8
- package/dist/unpkg/prod-deprecated/{schema-provider-CjX55uSY.js → schema-provider-Dh6tRqVI.js} +79 -3
- package/dist/unpkg/prod-deprecated/serializer/json-api.js +9 -4
- package/dist/unpkg/prod-deprecated/serializer/json.js +1 -1
- package/dist/unpkg/prod-deprecated/serializer/rest.js +3 -4
- package/dist/unpkg/prod-deprecated/serializer/transform.js +51 -3
- package/dist/unpkg/prod-deprecated/serializer.js +4 -7
- package/dist/unpkg/prod-deprecated/store.js +21 -7
- package/package.json +8 -8
- package/dist/unpkg/prod/json-BWrZ5546.js +0 -1243
- package/dist/unpkg/prod/model-for-CqXsIKws.js +0 -221
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { tracked, cached } from '@glimmer/tracking';
|
|
2
|
-
import { Context } from '@warp-drive/core/reactive/-private';
|
|
3
|
-
import { a as decorateFieldV2, i as initializeDeferredDecorator, d as decorateMethodV2 } from "./runtime-BPCpkOf1-BKOwiRJp.js";
|
|
4
|
-
class Fragment {
|
|
5
|
-
static {
|
|
6
|
-
decorateFieldV2(this.prototype, "isDestroying", [tracked], function () {
|
|
7
|
-
return false;
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
#isDestroying = (initializeDeferredDecorator(this, "isDestroying"), void 0); // We might want to check the parent values once we move this code to warp-drive.
|
|
11
|
-
static {
|
|
12
|
-
decorateFieldV2(this.prototype, "isDestroyed", [tracked], function () {
|
|
13
|
-
return false;
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
#isDestroyed = (initializeDeferredDecorator(this, "isDestroyed"), void 0);
|
|
17
|
-
get hasDirtyAttributes() {
|
|
18
|
-
const {
|
|
19
|
-
path,
|
|
20
|
-
resourceKey,
|
|
21
|
-
store
|
|
22
|
-
} = this[Context];
|
|
23
|
-
const record = store.peekRecord(resourceKey);
|
|
24
|
-
if (record.hasDirtyAttributes && path) {
|
|
25
|
-
const root = path.at(0);
|
|
26
|
-
return root in record.changedAttributes();
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
static {
|
|
31
|
-
decorateMethodV2(this.prototype, "hasDirtyAttributes", [cached]);
|
|
32
|
-
}
|
|
33
|
-
get isFragment() {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
get $type() {
|
|
37
|
-
const {
|
|
38
|
-
field
|
|
39
|
-
} = this[Context];
|
|
40
|
-
return field?.type;
|
|
41
|
-
}
|
|
42
|
-
rollbackAttributes() {
|
|
43
|
-
const {
|
|
44
|
-
path,
|
|
45
|
-
resourceKey,
|
|
46
|
-
store
|
|
47
|
-
} = this[Context];
|
|
48
|
-
if (path) {
|
|
49
|
-
const oldValue = store.cache.getRemoteAttr(resourceKey, path);
|
|
50
|
-
store.cache.setAttr(resourceKey, path, oldValue);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const FragmentExtension = {
|
|
55
|
-
kind: 'object',
|
|
56
|
-
name: 'fragment',
|
|
57
|
-
features: Fragment
|
|
58
|
-
};
|
|
59
|
-
class FragmentArray {
|
|
60
|
-
static {
|
|
61
|
-
decorateFieldV2(this.prototype, "isDestroying", [tracked], function () {
|
|
62
|
-
return false;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
#isDestroying = (initializeDeferredDecorator(this, "isDestroying"), void 0); // We might want to check the parent values once we move this code to warp-drive.
|
|
66
|
-
static {
|
|
67
|
-
decorateFieldV2(this.prototype, "isDestroyed", [tracked], function () {
|
|
68
|
-
return false;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
#isDestroyed = (initializeDeferredDecorator(this, "isDestroyed"), void 0);
|
|
72
|
-
get hasDirtyAttributes() {
|
|
73
|
-
const {
|
|
74
|
-
path,
|
|
75
|
-
resourceKey,
|
|
76
|
-
store
|
|
77
|
-
} = this[Context];
|
|
78
|
-
const record = store.peekRecord(resourceKey);
|
|
79
|
-
if (record.hasDirtyAttributes && path) {
|
|
80
|
-
const root = path.at(0);
|
|
81
|
-
return root in record.changedAttributes();
|
|
82
|
-
}
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
static {
|
|
86
|
-
decorateMethodV2(this.prototype, "hasDirtyAttributes", [cached]);
|
|
87
|
-
}
|
|
88
|
-
addFragment(fragment) {
|
|
89
|
-
if (!fragment) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
return this.addObject(fragment);
|
|
93
|
-
}
|
|
94
|
-
createFragment(fragment) {
|
|
95
|
-
if (!fragment) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
return this.pushObject(fragment);
|
|
99
|
-
}
|
|
100
|
-
removeFragment(fragment) {
|
|
101
|
-
if (!fragment) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const index = this.indexOf(fragment);
|
|
105
|
-
if (index !== -1) {
|
|
106
|
-
this.splice(index, 1);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
rollbackAttributes() {
|
|
110
|
-
for (const fragment of this) {
|
|
111
|
-
// @ts-expect-error TODO: fix these types
|
|
112
|
-
fragment?.rollbackAttributes?.();
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const FragmentArrayExtension = {
|
|
117
|
-
kind: 'array',
|
|
118
|
-
name: 'fragment-array',
|
|
119
|
-
features: FragmentArray
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
// if modelFor turns out to be a bottleneck we should replace with a Map
|
|
123
|
-
// and clear it during store teardown.
|
|
124
|
-
const AvailableShims = new WeakMap();
|
|
125
|
-
function getShimClass(store, modelName) {
|
|
126
|
-
let shims = AvailableShims.get(store);
|
|
127
|
-
if (!shims) {
|
|
128
|
-
shims = Object.create(null);
|
|
129
|
-
AvailableShims.set(store, shims);
|
|
130
|
-
}
|
|
131
|
-
let shim = shims[modelName];
|
|
132
|
-
if (shim === undefined) {
|
|
133
|
-
shim = shims[modelName] = new ShimModelClass(store, modelName);
|
|
134
|
-
}
|
|
135
|
-
return shim;
|
|
136
|
-
}
|
|
137
|
-
const AttributeKinds = ['field', 'attribute', 'object', 'array', 'schema-object', 'schema-array'];
|
|
138
|
-
|
|
139
|
-
// Mimics the static apis of @warp-drive/legacy/model
|
|
140
|
-
class ShimModelClass {
|
|
141
|
-
constructor(store, modelName) {
|
|
142
|
-
this.__store = store;
|
|
143
|
-
this.modelName = modelName;
|
|
144
|
-
}
|
|
145
|
-
get fields() {
|
|
146
|
-
const fields = new Map();
|
|
147
|
-
const fieldSchemas = this.__store.schema.fields({
|
|
148
|
-
type: this.modelName
|
|
149
|
-
});
|
|
150
|
-
fieldSchemas.forEach((schema, key) => {
|
|
151
|
-
// @ts-expect-error checking if a string is a valid string
|
|
152
|
-
if (AttributeKinds.includes(schema.kind)) {
|
|
153
|
-
fields.set(key, 'attribute');
|
|
154
|
-
} else if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
|
|
155
|
-
fields.set(key, schema.kind);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
return fields;
|
|
159
|
-
}
|
|
160
|
-
get attributes() {
|
|
161
|
-
const attrs = new Map();
|
|
162
|
-
const fields = this.__store.schema.fields({
|
|
163
|
-
type: this.modelName
|
|
164
|
-
});
|
|
165
|
-
fields.forEach((schema, key) => {
|
|
166
|
-
if (schema.kind === 'attribute') {
|
|
167
|
-
attrs.set(key, schema);
|
|
168
|
-
// @ts-expect-error checking if a string is a valid string
|
|
169
|
-
} else if (AttributeKinds.includes(schema.kind)) {
|
|
170
|
-
attrs.set(key, {
|
|
171
|
-
kind: 'attribute',
|
|
172
|
-
name: key,
|
|
173
|
-
type: null,
|
|
174
|
-
options: schema.options ?? {}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
return attrs;
|
|
179
|
-
}
|
|
180
|
-
get relationshipsByName() {
|
|
181
|
-
const rels = new Map();
|
|
182
|
-
const fields = this.__store.schema.fields({
|
|
183
|
-
type: this.modelName
|
|
184
|
-
});
|
|
185
|
-
fields.forEach((schema, key) => {
|
|
186
|
-
if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
|
|
187
|
-
rels.set(key, schema);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
return rels;
|
|
191
|
-
}
|
|
192
|
-
eachAttribute(callback, binding) {
|
|
193
|
-
this.attributes.forEach((schema, key) => {
|
|
194
|
-
callback.call(binding, key, schema);
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
eachRelationship(callback, binding) {
|
|
198
|
-
this.__store.schema.fields({
|
|
199
|
-
type: this.modelName
|
|
200
|
-
}).forEach((schema, key) => {
|
|
201
|
-
if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
|
|
202
|
-
callback.call(binding, key, schema);
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
eachTransformedAttribute(callback, binding) {
|
|
207
|
-
this.__store.schema.fields({
|
|
208
|
-
type: this.modelName
|
|
209
|
-
}).forEach((schema, key) => {
|
|
210
|
-
if (schema.kind === 'attribute') {
|
|
211
|
-
const type = schema.type;
|
|
212
|
-
if (type) callback.call(binding, key, type);
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
function fragmentsModelFor(modelName) {
|
|
218
|
-
return getShimClass(this, modelName);
|
|
219
|
-
}
|
|
220
|
-
const modelFor = fragmentsModelFor;
|
|
221
|
-
export { FragmentExtension as F, FragmentArrayExtension as a, FragmentArray as b, Fragment as c, fragmentsModelFor as f, modelFor as m };
|