@warp-drive/core 5.7.0-alpha.0 → 5.7.0-alpha.10

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.
Files changed (48) hide show
  1. package/declarations/reactive/-private/default-mode.d.ts +73 -0
  2. package/declarations/reactive/-private/fields/get-field-key.d.ts +8 -0
  3. package/declarations/reactive/-private/fields/managed-array.d.ts +3 -5
  4. package/declarations/reactive/-private/fields/managed-object.d.ts +5 -3
  5. package/declarations/reactive/-private/kind/alias-field.d.ts +4 -0
  6. package/declarations/reactive/-private/kind/array-field.d.ts +4 -0
  7. package/declarations/reactive/-private/kind/attribute-field.d.ts +4 -0
  8. package/declarations/reactive/-private/kind/belongs-to-field.d.ts +4 -0
  9. package/declarations/reactive/-private/kind/collection-field.d.ts +4 -0
  10. package/declarations/reactive/-private/kind/derived-field.d.ts +4 -0
  11. package/declarations/reactive/-private/kind/generic-field.d.ts +4 -0
  12. package/declarations/reactive/-private/kind/has-many-field.d.ts +4 -0
  13. package/declarations/reactive/-private/kind/hash-field.d.ts +4 -0
  14. package/declarations/reactive/-private/kind/identity-field.d.ts +4 -0
  15. package/declarations/reactive/-private/kind/local-field.d.ts +4 -0
  16. package/declarations/reactive/-private/kind/object-field.d.ts +4 -0
  17. package/declarations/reactive/-private/kind/resource-field.d.ts +4 -0
  18. package/declarations/reactive/-private/kind/schema-array-field.d.ts +4 -0
  19. package/declarations/reactive/-private/kind/schema-object-field.d.ts +4 -0
  20. package/declarations/reactive/-private/record.d.ts +2 -4
  21. package/declarations/reactive/-private/schema.d.ts +47 -3
  22. package/declarations/reactive.d.ts +1 -0
  23. package/declarations/request/-private/fetch.d.ts +2 -0
  24. package/declarations/store/-private/caches/instance-cache.d.ts +1 -8
  25. package/declarations/store/-private/store-service.d.ts +17 -777
  26. package/declarations/store/-private.d.ts +3 -2
  27. package/declarations/store/-types/q/schema-service.d.ts +56 -32
  28. package/declarations/store/-types/q/store.d.ts +6 -7
  29. package/declarations/store/deprecated/-private.d.ts +235 -0
  30. package/declarations/store/deprecated/store.d.ts +788 -0
  31. package/declarations/types/cache.d.ts +0 -2
  32. package/declarations/types/params.d.ts +2 -3
  33. package/declarations/types/request.d.ts +6 -6
  34. package/declarations/types/schema/fields.d.ts +361 -11
  35. package/declarations/types.d.ts +2 -1
  36. package/dist/graph/-private.js +1 -1
  37. package/dist/{handler-C2T-IyJK.js → handler-SdXlte1w.js} +1 -1
  38. package/dist/index.js +2 -2
  39. package/dist/reactive.js +1287 -589
  40. package/dist/{request-state-CjLph1LP.js → request-state-CeN66aML.js} +851 -1346
  41. package/dist/store/-private.js +2 -2
  42. package/dist/types/-private.js +1 -1
  43. package/dist/types/schema/fields.js +17 -2
  44. package/package.json +3 -3
  45. package/declarations/reactive/-private/fields/compute.d.ts +0 -43
  46. package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
  47. package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
  48. package/declarations/store/-types/q/ds-model.d.ts +0 -21
@@ -1,3 +1,3 @@
1
- export { C as CollectionRecordArray, D as DISPOSE, I as LiveArray, M as MUTATE, R as RecordArrayManager, l as RelatedCollection, d as SOURCE, A as Signals, S as Store, j as StoreMap, _ as _clearCaches, n as _deprecatingNormalize, b as coerceId, c as constructResource, G as consumeInternalSignal, t as createRequestSubscription, z as defineNonEnumerableSignal, y as defineSignal, e as ensureStringId, x as entangleSignal, f as fastPush, w as gate, H as getOrCreateInternalSignal, q as getPromiseState, u as getRequestState, a as isDocumentIdentifier, i as isStableIdentifier, m as log, o as logGroup, v as memoized, F as notifyInternalSignal, p as peekCache, B as peekInternalSignal, r as recordIdentifierFor, g as removeRecordDataFor, k as setCacheFor, h as setRecordIdentifier, s as storeFor, E as withSignalStore } from "../request-state-CjLph1LP.js";
2
- export { C as CacheHandler } from "../handler-C2T-IyJK.js";
1
+ export { C as CollectionRecordArray, D as DISPOSE, I as LiveArray, M as MUTATE, R as RecordArrayManager, l as RelatedCollection, d as SOURCE, B as Signals, S as Store, j as StoreMap, _ as _clearCaches, n as _deprecatingNormalize, b as coerceId, c as constructResource, H as consumeInternalSignal, t as createRequestSubscription, z as defineGate, A as defineNonEnumerableSignal, y as defineSignal, e as ensureStringId, x as entangleSignal, f as fastPush, w as gate, J as getOrCreateInternalSignal, q as getPromiseState, u as getRequestState, a as isDocumentIdentifier, i as isStableIdentifier, m as log, o as logGroup, v as memoized, G as notifyInternalSignal, p as peekCache, E as peekInternalSignal, r as recordIdentifierFor, g as removeRecordDataFor, k as setCacheFor, h as setRecordIdentifier, s as storeFor, F as withSignalStore } from "../request-state-CeN66aML.js";
2
+ export { C as CacheHandler } from "../handler-SdXlte1w.js";
3
3
  export { A as ARRAY_SIGNAL, O as OBJECT_SIGNAL, c as createMemo, w as waitFor } from "../configure-B48bFHOl.js";
@@ -1,6 +1,6 @@
1
1
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
2
2
  const name = "@warp-drive/core";
3
- const version = "5.7.0-alpha.0";
3
+ const version = "5.7.0-alpha.10";
4
4
 
5
5
  // in testing mode, we utilize globals to ensure only one copy exists of
6
6
  // these maps, due to bugs in ember-auto-import
@@ -1,3 +1,5 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
+
1
3
  /**
2
4
  * A generic "field" that can be used to define
3
5
  * primitive value fields.
@@ -132,7 +134,7 @@
132
134
  * perform those itself.
133
135
  *
134
136
  * A schema-array can declare its "key" value to be `@hash` if
135
- * a schema-object has such a field.
137
+ * the schema-objects it contains have such a field.
136
138
  *
137
139
  * Only one hash field is permittable per schema-object, and
138
140
  * it should be placed in the `ResourceSchema`'s `@id` field
@@ -186,11 +188,13 @@
186
188
  /**
187
189
  * Represents a field whose value is an object
188
190
  * with a well-defined structure described by
189
- * a non-resource schema.
191
+ * a schema-object (a non-resource schema).
190
192
  *
191
193
  * If the object's structure is not well-defined,
192
194
  * use 'object' instead.
193
195
  *
196
+ * By default, a SchemaObject within
197
+ *
194
198
  * @public
195
199
  */
196
200
 
@@ -374,6 +378,17 @@
374
378
  * @public
375
379
  */
376
380
 
381
+ /**
382
+ * A union of all possible LegacyMode and PolarisMode
383
+ * field schemas that represent data that could be in
384
+ * the cache.
385
+ *
386
+ * In other words this will not include types like alias
387
+ * fields, local fields, or derived fields.
388
+ *
389
+ * @public
390
+ */
391
+
377
392
  /**
378
393
  * A union of all possible field schemas that can be
379
394
  * used in an ObjectSchema.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warp-drive/core",
3
- "version": "5.7.0-alpha.0",
3
+ "version": "5.7.0-alpha.10",
4
4
  "description": "Core package for WarpDrive | All the Universal Basics",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -37,13 +37,13 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@embroider/macros": "^1.16.12",
40
- "@warp-drive/build-config": "5.7.0-alpha.0"
40
+ "@warp-drive/build-config": "5.7.0-alpha.10"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/core": "^7.26.10",
44
44
  "@babel/plugin-transform-typescript": "^7.27.0",
45
45
  "@babel/preset-typescript": "^7.27.0",
46
- "@warp-drive/internal-config": "5.7.0-alpha.0",
46
+ "@warp-drive/internal-config": "5.7.0-alpha.10",
47
47
  "decorator-transforms": "^2.3.0",
48
48
  "ember-source": "~6.3.0",
49
49
  "expect-type": "^1.2.1",
@@ -1,43 +0,0 @@
1
- import type { Store, StoreRequestInput } from "../../../index.js";
2
- import type { Future } from "../../../request.js";
3
- import { RelatedCollection as ManyArray } from "../../../store/-private.js";
4
- import type { Cache } from "../../../types/cache.js";
5
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
6
- import type { ArrayField, DerivedField, FieldSchema, GenericField, LegacyHasManyField, LocalField, ObjectField, SchemaArrayField, SchemaObjectField } from "../../../types/schema/fields.js";
7
- import type { Links } from "../../../types/spec/json-api-raw.js";
8
- import { RecordStore } from "../../../types/symbols.js";
9
- import { ReactiveResource } from "../record.js";
10
- import type { SchemaService } from "../schema.js";
11
- import { Parent } from "../symbols.js";
12
- import { ManagedArray } from "./managed-array.js";
13
- import { ManagedObject } from "./managed-object.js";
14
- export declare const ManagedArrayMap: Map<ReactiveResource, Map<string, ManagedArray | ManyArray>>;
15
- export declare const ManagedObjectMap: Map<ReactiveResource, Map<string, ManagedObject | ReactiveResource>>;
16
- export declare function computeLocal(record: typeof Proxy<ReactiveResource>, field: LocalField, prop: string): unknown;
17
- export declare function peekManagedArray(record: ReactiveResource, field: FieldSchema): ManyArray | ManagedArray | undefined;
18
- export declare function peekManagedObject(record: ReactiveResource, field: ObjectField): ManagedObject | undefined;
19
- export declare function peekManagedObject(record: ReactiveResource, field: SchemaObjectField): ReactiveResource | undefined;
20
- export declare function computeField(schema: SchemaService, cache: Cache, record: ReactiveResource, identifier: StableRecordIdentifier, field: GenericField, prop: string | string[], editable: boolean): unknown;
21
- export declare function computeArray(store: Store, schema: SchemaService, cache: Cache, record: ReactiveResource, identifier: StableRecordIdentifier, field: ArrayField | SchemaArrayField, path: string[], editable: boolean, legacy: boolean): ManagedArray | null;
22
- export declare function computeObject(schema: SchemaService, cache: Cache, record: ReactiveResource, identifier: StableRecordIdentifier, field: ObjectField, path: string[], editable: boolean, legacy: boolean): ManagedObject | null;
23
- export declare function computeSchemaObject(store: Store, cache: Cache, record: ReactiveResource, identifier: StableRecordIdentifier, field: SchemaObjectField, path: string[], legacy: boolean, editable: boolean): ReactiveResource | null;
24
- export declare function computeAttribute(cache: Cache, identifier: StableRecordIdentifier, prop: string, editable: boolean): unknown;
25
- export declare function computeDerivation(schema: SchemaService, record: ReactiveResource, identifier: StableRecordIdentifier, field: DerivedField, prop: string): unknown;
26
- interface ResourceRelationship<T extends ReactiveResource = ReactiveResource> {
27
- lid: string;
28
- [Parent]: ReactiveResource;
29
- [RecordStore]: Store;
30
- name: string;
31
- data: T | null;
32
- links: Links;
33
- meta: Record<string, unknown>;
34
- }
35
- // TODO probably this should just be a Document
36
- // but its separate until we work out the lid situation
37
- declare class ResourceRelationship<T extends ReactiveResource = ReactiveResource> {
38
- constructor(store: Store, cache: Cache, parent: ReactiveResource, identifier: StableRecordIdentifier, field: FieldSchema, name: string, editable: boolean);
39
- fetch(options?: StoreRequestInput<T, T>): Future<T>;
40
- }
41
- export declare function computeResource<T extends ReactiveResource>(store: Store, cache: Cache, parent: ReactiveResource, identifier: StableRecordIdentifier, field: FieldSchema, prop: string, editable: boolean): ResourceRelationship<T>;
42
- export declare function computeHasMany(store: Store, schema: SchemaService, cache: Cache, record: ReactiveResource, identifier: StableRecordIdentifier, field: LegacyHasManyField, path: string[], editable: boolean, legacy: boolean): ManyArray | null;
43
- export {};
@@ -1,159 +0,0 @@
1
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
2
- import type { SingleResourceDocument } from "../../../types/spec/json-api-raw.js";
3
- import type { OpaqueRecordInstance } from "../../-types/q/record-instance.js";
4
- import type { Store } from "../store-service.js";
5
- /**
6
- A `RecordReference` is a low-level API that allows users and
7
- addon authors to perform meta-operations on a record.
8
-
9
- @hideconstructor
10
- @public
11
- */
12
- export default class RecordReference {
13
- private store;
14
- // unsubscribe token given to us by the notification manager
15
- private ___token;
16
- private ___identifier;
17
- private _ref;
18
- constructor(store: Store, identifier: StableRecordIdentifier);
19
- /** @internal */
20
- destroy(): void;
21
- get type(): string;
22
- /**
23
- The `id` of the record that this reference refers to.
24
-
25
- Together, the `type` and `id` properties form a composite key for
26
- the identity map.
27
-
28
- Example
29
-
30
- ```javascript
31
- let userRef = store.getReference('user', 1);
32
-
33
- userRef.id(); // '1'
34
- ```
35
-
36
- @public
37
- */
38
- id(): string | null;
39
- /**
40
- The `identifier` of the record that this reference refers to.
41
-
42
- Together, the `type` and `id` properties form a composite key for
43
- the identity map.
44
-
45
- Example
46
-
47
- ```javascript
48
- let userRef = store.getReference('user', 1);
49
-
50
- userRef.identifier(); // '1'
51
- ```
52
-
53
- @public
54
- */
55
- identifier(): StableRecordIdentifier;
56
- /**
57
- How the reference will be looked up when it is loaded. Currently
58
- this always returns `identity` to signify that a record will be
59
- loaded by its `type` and `id`.
60
-
61
- Example
62
-
63
- ```javascript
64
- const userRef = store.getReference('user', 1);
65
-
66
- userRef.remoteType(); // 'identity'
67
- ```
68
-
69
- @public
70
- */
71
- remoteType(): "identity";
72
- /**
73
- This API allows you to provide a reference with new data. The
74
- simplest usage of this API is similar to `store.push`: you provide a
75
- normalized hash of data and the object represented by the reference
76
- will update.
77
-
78
- If you pass a promise to `push`, Ember Data will not ask the adapter
79
- for the data if another attempt to fetch it is made in the
80
- interim. When the promise resolves, the underlying object is updated
81
- with the new data, and the promise returned by *this function* is resolved
82
- with that object.
83
-
84
- For example, `recordReference.push(promise)` will be resolved with a
85
- record.
86
-
87
- Example
88
-
89
- ```javascript
90
- let userRef = store.getReference('user', 1);
91
-
92
- // provide data for reference
93
- userRef.push({
94
- data: {
95
- id: "1",
96
- type: "user",
97
- attributes: {
98
- username: "@user"
99
- }
100
- }
101
- }).then(function(user) {
102
- userRef.value() === user;
103
- });
104
- ```
105
-
106
- @public
107
- @param objectOrPromise a JSON:API ResourceDocument or a promise resolving to one
108
- @return a promise for the value (record or relationship)
109
- */
110
- push(objectOrPromise: SingleResourceDocument | Promise<SingleResourceDocument>): Promise<OpaqueRecordInstance>;
111
- /**
112
- If the entity referred to by the reference is already loaded, it is
113
- present as `reference.value`. Otherwise the value returned by this function
114
- is `null`.
115
-
116
- Example
117
-
118
- ```javascript
119
- let userRef = store.getReference('user', 1);
120
-
121
- userRef.value(); // user
122
- ```
123
-
124
- @public
125
- */
126
- value(): OpaqueRecordInstance | null;
127
- /**
128
- Triggers a fetch for the backing entity based on its `remoteType`
129
- (see `remoteType` definitions per reference type).
130
-
131
- Example
132
-
133
- ```javascript
134
- let userRef = store.getReference('user', 1);
135
-
136
- // load user (via store.find)
137
- userRef.load().then(...)
138
- ```
139
-
140
- @public
141
- */
142
- load(): Promise<OpaqueRecordInstance>;
143
- /**
144
- Reloads the record if it is already loaded. If the record is not
145
- loaded it will load the record via `store.findRecord`
146
-
147
- Example
148
-
149
- ```javascript
150
- let userRef = store.getReference('user', 1);
151
-
152
- // or trigger a reload
153
- userRef.reload().then(...)
154
- ```
155
-
156
- @public
157
- */
158
- reload(): Promise<OpaqueRecordInstance>;
159
- }
@@ -1,17 +0,0 @@
1
- import type { TypedRecordInstance, TypeFromInstance } from "../../../types/record.js";
2
- import type { LegacyAttributeField, LegacyRelationshipField } from "../../../types/schema/fields.js";
3
- import type { KeyOrString, ModelSchema } from "../../-types/q/ds-model.js";
4
- import type { Store } from "../store-service.js";
5
- export declare function getShimClass<T>(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string): ShimModelClass<T>;
6
- // Mimics the static apis of @ember-data/model
7
- export default class ShimModelClass<T = unknown> implements ModelSchema<T> {
8
- private __store;
9
- modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
10
- constructor(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string);
11
- get fields(): Map<KeyOrString<T>, "attribute" | "belongsTo" | "hasMany">;
12
- get attributes(): Map<KeyOrString<T>, LegacyAttributeField>;
13
- get relationshipsByName(): Map<KeyOrString<T>, LegacyRelationshipField>;
14
- eachAttribute<K extends KeyOrString<T>>(callback: (key: K, attribute: LegacyAttributeField) => void, binding?: T): void;
15
- eachRelationship<K extends KeyOrString<T>>(callback: (key: K, relationship: LegacyRelationshipField) => void, binding?: T): void;
16
- eachTransformedAttribute<K extends KeyOrString<T>>(callback: (key: K, type: string | null) => void, binding?: T): void;
17
- }
@@ -1,21 +0,0 @@
1
- import type { TypedRecordInstance, TypeFromInstance } from "../../../types/record.js";
2
- import type { LegacyAttributeField, LegacyRelationshipField } from "../../../types/schema/fields.js";
3
- export type KeyOrString<T> = keyof T & string extends never ? string : keyof T & string;
4
- /**
5
- * Minimum subset of static schema methods and properties on the
6
- * "model" class.
7
- *
8
- * Only used when using the legacy schema-service implementation
9
- * for @ember-data/model or when wrapping schema for legacy
10
- * Adapters/Serializers.
11
- *
12
- */
13
- export interface ModelSchema<T = unknown> {
14
- modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;
15
- fields: Map<KeyOrString<T>, "attribute" | "belongsTo" | "hasMany">;
16
- attributes: Map<KeyOrString<T>, LegacyAttributeField>;
17
- relationshipsByName: Map<KeyOrString<T>, LegacyRelationshipField>;
18
- eachAttribute<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, attribute: LegacyAttributeField) => void, binding?: T): void;
19
- eachRelationship<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, relationship: LegacyRelationshipField) => void, binding?: T): void;
20
- eachTransformedAttribute<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, type: string | null) => void, binding?: T): void;
21
- }