@warp-drive/core 5.7.0-alpha.8 → 5.7.0-beta.0

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 (103) hide show
  1. package/declarations/graph/-private/-diff.d.ts +7 -20
  2. package/declarations/graph/-private/-edge-definition.d.ts +3 -12
  3. package/declarations/graph/-private/-state.d.ts +0 -87
  4. package/declarations/graph/-private/-utils.d.ts +5 -11
  5. package/declarations/graph/-private/coerce-id.d.ts +0 -6
  6. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +2 -14
  7. package/declarations/graph/-private/edges/collection.d.ts +10 -10
  8. package/declarations/graph/-private/edges/implicit.d.ts +5 -5
  9. package/declarations/graph/-private/edges/resource.d.ts +6 -7
  10. package/declarations/graph/-private/graph.d.ts +17 -51
  11. package/declarations/graph/-private/normalize-link.d.ts +0 -6
  12. package/declarations/graph/-private/operations/replace-related-records.d.ts +4 -59
  13. package/declarations/graph/-private/operations/update-relationship.d.ts +3 -7
  14. package/declarations/index.d.ts +1 -1
  15. package/declarations/reactive/-private/default-mode.d.ts +2 -2
  16. package/declarations/reactive/-private/document.d.ts +11 -27
  17. package/declarations/reactive/-private/fields/managed-array.d.ts +4 -6
  18. package/declarations/reactive/-private/fields/managed-object.d.ts +2 -8
  19. package/declarations/reactive/-private/fields/many-array-manager.d.ts +2 -2
  20. package/declarations/reactive/-private/hooks.d.ts +2 -2
  21. package/declarations/reactive/-private/record.d.ts +42 -30
  22. package/declarations/reactive/-private/schema.d.ts +11 -73
  23. package/declarations/reactive/-private/symbols.d.ts +2 -33
  24. package/declarations/reactive/-private.d.ts +1 -1
  25. package/declarations/reactive.d.ts +277 -1
  26. package/declarations/request/-private/context.d.ts +3 -5
  27. package/declarations/request/-private/fetch.d.ts +2 -2
  28. package/declarations/request/-private/manager.d.ts +24 -28
  29. package/declarations/request/-private/types.d.ts +22 -24
  30. package/declarations/request/-private/utils.d.ts +44 -2
  31. package/declarations/store/-private/cache-handler/handler.d.ts +2 -8
  32. package/declarations/store/-private/cache-handler/types.d.ts +10 -10
  33. package/declarations/store/-private/cache-handler/utils.d.ts +4 -5
  34. package/declarations/store/-private/caches/instance-cache.d.ts +21 -20
  35. package/declarations/store/-private/debug/utils.d.ts +1 -0
  36. package/declarations/store/-private/default-cache-policy.d.ts +25 -40
  37. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +24 -15
  38. package/declarations/store/-private/{caches/identifier-cache.d.ts → managers/cache-key-manager.d.ts} +35 -53
  39. package/declarations/store/-private/managers/cache-manager.d.ts +46 -111
  40. package/declarations/store/-private/managers/notification-manager.d.ts +30 -45
  41. package/declarations/store/-private/managers/record-array-manager.d.ts +44 -41
  42. package/declarations/store/-private/network/request-cache.d.ts +21 -25
  43. package/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +24 -0
  44. package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +3 -41
  45. package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +14 -29
  46. package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +24 -3
  47. package/declarations/store/-private/new-core-tmp/request-state.d.ts +132 -37
  48. package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +51 -135
  49. package/declarations/store/-private/record-arrays/-utils.d.ts +80 -0
  50. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +81 -0
  51. package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +133 -0
  52. package/declarations/store/-private/record-arrays/legacy-query.d.ts +81 -0
  53. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +1 -124
  54. package/declarations/store/-private/record-arrays/resource-array.d.ts +67 -0
  55. package/declarations/store/-private/store-service.d.ts +156 -106
  56. package/declarations/store/-private/utils/coerce-id.d.ts +0 -6
  57. package/declarations/store/-private.d.ts +11 -13
  58. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +15 -24
  59. package/declarations/store/-types/q/identifier.d.ts +9 -6
  60. package/declarations/store/-types/q/record-instance.d.ts +0 -1
  61. package/declarations/store/-types/q/schema-service.d.ts +9 -9
  62. package/declarations/store/-types/q/store.d.ts +6 -7
  63. package/declarations/store/deprecated/-private.d.ts +12 -24
  64. package/declarations/store/deprecated/store.d.ts +11 -16
  65. package/declarations/types/-private.d.ts +1 -1
  66. package/declarations/types/cache/aliases.d.ts +0 -11
  67. package/declarations/types/cache/change.d.ts +2 -2
  68. package/declarations/types/cache/mutations.d.ts +13 -37
  69. package/declarations/types/cache/operations.d.ts +115 -32
  70. package/declarations/types/cache/relationship.d.ts +4 -7
  71. package/declarations/types/cache.d.ts +51 -125
  72. package/declarations/types/graph.d.ts +12 -12
  73. package/declarations/types/identifier.d.ts +52 -78
  74. package/declarations/types/params.d.ts +2 -3
  75. package/declarations/types/request.d.ts +66 -42
  76. package/declarations/types/schema/concepts.d.ts +2 -2
  77. package/declarations/types/schema/fields.d.ts +30 -3
  78. package/declarations/types/spec/document.d.ts +6 -10
  79. package/declarations/types/spec/json-api-raw.d.ts +6 -9
  80. package/declarations/types.d.ts +0 -1
  81. package/declarations/utils/string.d.ts +2 -3
  82. package/dist/{configure-B48bFHOl.js → configure-C3x8YXzL.js} +5 -5
  83. package/dist/configure.js +1 -1
  84. package/dist/{context-COmAnXUQ.js → context-C_7OLieY.js} +48 -6
  85. package/dist/graph/-private.js +137 -144
  86. package/dist/index.js +25 -14
  87. package/dist/reactive/-private.js +1 -1
  88. package/dist/reactive.js +144 -1926
  89. package/dist/{request-state-CeN66aML.js → request-state-C955e0AL.js} +5968 -3033
  90. package/dist/request.js +1 -1
  91. package/dist/store/-private.js +2 -3
  92. package/dist/store.js +32 -44
  93. package/dist/{symbols-SIstXMLI.js → symbols-sql1_mdx.js} +3 -8
  94. package/dist/types/-private.js +1 -1
  95. package/dist/types/identifier.js +19 -45
  96. package/dist/types/request.js +45 -3
  97. package/dist/types/schema/fields.js +6 -0
  98. package/dist/utils/string.js +2 -2
  99. package/package.json +11 -11
  100. package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
  101. package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
  102. package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
  103. package/dist/handler-SdXlte1w.js +0 -339
@@ -1,12 +1,12 @@
1
1
  import type { Store } from "../../store/-private/store-service.js";
2
- import type { StableDocumentIdentifier } from "../../types/identifier.js";
2
+ import type { RequestKey } from "../../types/identifier.js";
3
3
  import type { ImmutableRequestInfo, RequestInfo } from "../../types/request.js";
4
4
  import type { ResourceDocument } from "../../types/spec/document.js";
5
5
  import type { Meta, PaginationLinks } from "../../types/spec/json-api-raw.js";
6
6
  /**
7
7
  * A Document is a class that wraps the response content from a request to the API
8
- * returned by `Cache.put` or `Cache.peek`, converting resource-identifiers into
9
- * record instances.
8
+ * returned by `Cache.put` or `Cache.peek`, converting ResourceKeys into
9
+ * ReactiveResource instances.
10
10
  *
11
11
  * It is not directly instantiated by the user, and its properties should not
12
12
  * be directly modified. Whether individual properties are mutable or not is
@@ -16,7 +16,6 @@ import type { Meta, PaginationLinks } from "../../types/spec/json-api-raw.js";
16
16
  * @hideconstructor
17
17
  */
18
18
  export declare class ReactiveDocument<T> {
19
- #private;
20
19
  /**
21
20
  * The links object for this document, if any
22
21
  *
@@ -28,8 +27,6 @@ export declare class ReactiveDocument<T> {
28
27
  * }
29
28
  * ```
30
29
  *
31
- * @property links
32
- * @type {Object|undefined} - a links object
33
30
  * @public
34
31
  */
35
32
  readonly links?: PaginationLinks;
@@ -42,41 +39,28 @@ export declare class ReactiveDocument<T> {
42
39
  * For collections this will be an array of record instances,
43
40
  * for single resource requests it will be a single record instance or null.
44
41
  *
45
- * @property data
46
42
  * @public
47
- * @type {Object|Array<object>|null|undefined} - a data object
48
43
  */
49
44
  readonly data?: T;
50
45
  /**
51
46
  * The errors returned by the API for this request, if any
52
47
  *
53
- * @property errors
54
48
  * @public
55
- * @type {Object|undefined} - an errors object
56
49
  */
57
50
  readonly errors?: object[];
58
51
  /**
59
52
  * The meta object for this document, if any
60
53
  *
61
- * @property meta
62
54
  * @public
63
- * @type {Object|undefined} - a meta object
64
55
  */
65
56
  readonly meta?: Meta;
66
57
  /**
67
- * The identifier associated with this document, if any
58
+ * The RequestKey associated with this document, if any
68
59
  *
69
- * @property identifier
70
60
  * @public
71
- * @type {StableDocumentIdentifier|null}
72
61
  */
73
- readonly identifier: StableDocumentIdentifier | null;
74
- protected readonly _store: Store;
75
- protected readonly _localCache: {
76
- document: ResourceDocument;
77
- request: ImmutableRequestInfo;
78
- } | null;
79
- constructor(store: Store, identifier: StableDocumentIdentifier | null, localCache: {
62
+ readonly identifier: RequestKey | null;
63
+ constructor(store: Store, cacheKey: RequestKey | null, localCache: {
80
64
  document: ResourceDocument;
81
65
  request: ImmutableRequestInfo;
82
66
  } | null);
@@ -89,7 +73,7 @@ export declare class ReactiveDocument<T> {
89
73
  * @param {Object} options
90
74
  * @return {Promise<Document>}
91
75
  */
92
- fetch(options?: RequestInfo<ReactiveDocument<T>, T>): Promise<ReactiveDocument<T>>;
76
+ fetch(options?: RequestInfo<ReactiveDocument<T>>): Promise<ReactiveDocument<T>>;
93
77
  /**
94
78
  * Fetches the next link for this document, returning a promise that resolves
95
79
  * with the new document when the request completes, or null if there is no
@@ -99,7 +83,7 @@ export declare class ReactiveDocument<T> {
99
83
  * @param {Object} options
100
84
  * @return {Promise<Document | null>}
101
85
  */
102
- next(options?: RequestInfo<ReactiveDocument<T>, T>): Promise<ReactiveDocument<T> | null>;
86
+ next(options?: RequestInfo<ReactiveDocument<T>>): Promise<ReactiveDocument<T> | null>;
103
87
  /**
104
88
  * Fetches the prev link for this document, returning a promise that resolves
105
89
  * with the new document when the request completes, or null if there is no
@@ -109,7 +93,7 @@ export declare class ReactiveDocument<T> {
109
93
  * @param {Object} options
110
94
  * @return {Promise<Document | null>}
111
95
  */
112
- prev(options: RequestInfo<ReactiveDocument<T>, T>): Promise<ReactiveDocument<T> | null>;
96
+ prev(options: RequestInfo<ReactiveDocument<T>>): Promise<ReactiveDocument<T> | null>;
113
97
  /**
114
98
  * Fetches the first link for this document, returning a promise that resolves
115
99
  * with the new document when the request completes, or null if there is no
@@ -119,7 +103,7 @@ export declare class ReactiveDocument<T> {
119
103
  * @param {Object} options
120
104
  * @return {Promise<Document | null>}
121
105
  */
122
- first(options: RequestInfo<ReactiveDocument<T>, T>): Promise<ReactiveDocument<T> | null>;
106
+ first(options: RequestInfo<ReactiveDocument<T>>): Promise<ReactiveDocument<T> | null>;
123
107
  /**
124
108
  * Fetches the last link for this document, returning a promise that resolves
125
109
  * with the new document when the request completes, or null if there is no
@@ -129,7 +113,7 @@ export declare class ReactiveDocument<T> {
129
113
  * @param {Object} options
130
114
  * @return {Promise<Document | null>}
131
115
  */
132
- last(options: RequestInfo<ReactiveDocument<T>, T>): Promise<ReactiveDocument<T> | null>;
116
+ last(options: RequestInfo<ReactiveDocument<T>>): Promise<ReactiveDocument<T> | null>;
133
117
  /**
134
118
  * Implemented for `JSON.stringify` support.
135
119
  *
@@ -1,20 +1,18 @@
1
1
  import type { WarpDriveSignal } from "../../../store/-private.js";
2
2
  import { ARRAY_SIGNAL } from "../../../store/-private.js";
3
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
3
+ import type { ResourceKey } from "../../../types/identifier.js";
4
4
  import type { ArrayField, SchemaArrayField } from "../../../types/schema/fields.js";
5
5
  import type { KindContext } from "../default-mode.js";
6
6
  import { ReactiveResource } from "../record.js";
7
- import { Editable, Legacy, SOURCE } from "../symbols.js";
7
+ import { Context, SOURCE } from "../symbols.js";
8
8
  export interface ManagedArray extends Omit<Array<unknown>, "[]"> {
9
9
  [SOURCE]: unknown[];
10
- identifier: StableRecordIdentifier;
10
+ identifier: ResourceKey;
11
11
  path: string | string[];
12
12
  owner: ReactiveResource;
13
13
  [ARRAY_SIGNAL]: WarpDriveSignal;
14
- [Editable]: boolean;
15
- [Legacy]: boolean;
14
+ [Context]: KindContext<SchemaArrayField | ArrayField>;
16
15
  }
17
- // eslint-disable-next-line @typescript-eslint/no-extraneous-class
18
16
  export declare class ManagedArray {
19
17
  constructor(context: KindContext<SchemaArrayField | ArrayField>, owner: ReactiveResource, data: unknown[]);
20
18
  }
@@ -1,20 +1,14 @@
1
1
  import { OBJECT_SIGNAL, type WarpDriveSignal } from "../../../store/-private.js";
2
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
3
2
  import type { ObjectField, SchemaObjectField } from "../../../types/schema/fields.js";
4
3
  import type { KindContext } from "../default-mode.js";
5
4
  import type { ReactiveResource } from "../record.js";
6
- import { Editable, EmbeddedPath, Legacy, Parent, SOURCE } from "../symbols.js";
5
+ import { Context, SOURCE } from "../symbols.js";
7
6
  export declare function notifyObject(obj: ManagedObject): void;
8
- // const ignoredGlobalFields = new Set<string>(['setInterval', 'nodeType', 'nodeName', 'length', 'document', STRUCTURED]);
9
7
  export interface ManagedObject {
10
8
  [SOURCE]: object;
11
- [Parent]: StableRecordIdentifier;
12
- [EmbeddedPath]: string[];
9
+ [Context]: KindContext<ObjectField>;
13
10
  [OBJECT_SIGNAL]: WarpDriveSignal;
14
- [Editable]: boolean;
15
- [Legacy]: boolean;
16
11
  }
17
- // eslint-disable-next-line @typescript-eslint/no-extraneous-class
18
12
  export declare class ManagedObject {
19
13
  constructor(context: KindContext<ObjectField>);
20
14
  }
@@ -1,7 +1,7 @@
1
1
  import type { Store } from "../../../index.js";
2
2
  import type { RelatedCollection as ManyArray } from "../../../store/-private.js";
3
3
  import type { LocalRelationshipOperation } from "../../../types/graph.js";
4
- import type { StableRecordIdentifier } from "../../../types/identifier.js";
4
+ import type { ResourceKey } from "../../../types/identifier.js";
5
5
  import type { ReactiveResource } from "../record.js";
6
6
  export interface FindHasManyOptions {
7
7
  reload?: boolean;
@@ -10,7 +10,7 @@ export interface FindHasManyOptions {
10
10
  export declare class ManyArrayManager {
11
11
  record: ReactiveResource;
12
12
  store: Store;
13
- identifier: StableRecordIdentifier;
13
+ identifier: ResourceKey;
14
14
  editable: boolean;
15
15
  constructor(record: ReactiveResource, editable: boolean);
16
16
  _syncArray(array: ManyArray): void;
@@ -1,5 +1,5 @@
1
1
  import type { Store } from "../../index.js";
2
- import type { StableRecordIdentifier } from "../../types.js";
2
+ import type { ResourceKey } from "../../types.js";
3
3
  import { ReactiveResource } from "./record.js";
4
- export declare function instantiateRecord(store: Store, identifier: StableRecordIdentifier, createArgs?: Record<string, unknown>): ReactiveResource;
4
+ export declare function instantiateRecord(store: Store, identifier: ResourceKey, createArgs?: Record<string, unknown>): ReactiveResource;
5
5
  export declare function teardownRecord(record: unknown): void;
@@ -1,38 +1,14 @@
1
- import type { Store } from "../../index.js";
2
- import type { StableRecordIdentifier } from "../../types/identifier.js";
3
- import type { SchemaArrayField, SchemaObjectField } from "../../types/schema/fields.js";
4
- import { RecordStore } from "../../types/symbols.js";
5
1
  import type { ObjectContext, ResourceContext } from "./default-mode.js";
6
- import { Checkout, Destroy, Editable, EmbeddedField, EmbeddedPath, Identifier, Legacy, Parent } from "./symbols.js";
7
- export { Editable, Legacy, Checkout } from "./symbols.js";
2
+ import { Checkout } from "./symbols.js";
8
3
  export interface ReactiveResource {
9
- [Symbol.toStringTag]: `ReactiveResource<${string}>`;
10
- /** @internal */
11
- [RecordStore]: Store;
12
- /** @internal */
13
- [Identifier]: StableRecordIdentifier;
14
- /** @internal */
15
- [Parent]: StableRecordIdentifier;
16
- /** @internal */
17
- [EmbeddedField]: SchemaArrayField | SchemaObjectField | null;
18
- /** @internal */
19
- [EmbeddedPath]: string[] | null;
20
- /** @internal */
21
- [Editable]: boolean;
22
- /** @internal */
23
- [Legacy]: boolean;
24
- /** @internal */
25
- ___notifications: object;
26
- /** @internal */
27
- [Destroy](): void;
28
4
  /**
29
5
  * Create an editable copy of the record
30
6
  *
31
7
  * ReactiveResource instances are not editable by default. This method creates an editable copy of the record. To use,
32
- * import the `Checkout` symbol from `@warp-drive/schema-record` and call it on the record.
8
+ * import the `Checkout` symbol from `@warp-drive/core/reactive` and call it on the record.
33
9
  *
34
10
  * ```ts
35
- * import { Checkout } from '@warp-drive/schema-record';
11
+ * import { Checkout } from '@warp-drive/core/reactive';
36
12
  *
37
13
  * const record = store.peekRecord('user', '1');
38
14
  * const editableRecord = await record[Checkout]();
@@ -40,13 +16,13 @@ export interface ReactiveResource {
40
16
  *
41
17
  * @returns a promise that resolves to the editable record
42
18
  * @throws if the record is already editable or if the record is embedded
43
- *
19
+ * @private
44
20
  */
45
21
  [Checkout]<T>(): Promise<T>;
46
22
  }
47
23
  /**
48
24
  * A class that uses a the ResourceSchema for a ResourceType
49
- * and a ResouceKey to transform data from the cache into a rich, reactive
25
+ * and a ResourceKey to transform data from the cache into a rich, reactive
50
26
  * object.
51
27
  *
52
28
  * This class is not directly instantiable. To use it, you should
@@ -56,7 +32,43 @@ export interface ReactiveResource {
56
32
  * @hideconstructor
57
33
  * @public
58
34
  */
59
- // eslint-disable-next-line @typescript-eslint/no-extraneous-class
60
35
  export declare class ReactiveResource {
61
36
  constructor(context: ResourceContext | ObjectContext);
62
37
  }
38
+ export declare function _CHECKOUT(record: ReactiveResource): ReactiveResource;
39
+ /**
40
+ * Checkout an immutable resource for editing.
41
+ *
42
+ * {@link ReactiveResource | ReactiveResources} are not editable by default. This method
43
+ * creates an editable copy of the resource.
44
+ *
45
+ * This returns a promise which resolves with the editable
46
+ * version of the resource.
47
+ *
48
+ * ```ts
49
+ * import { checkout } from '@warp-drive/core/reactive';
50
+ *
51
+ * const immutable = store.peekRecord('user', '1');
52
+ * const editable = await checkout(immutable);
53
+ * ```
54
+ *
55
+ * Edits to editable resources will be automatically committed if a new
56
+ * payload from the cache matches their existing value.
57
+ *
58
+ * @public
59
+ *
60
+ * @returns a promise that resolves to the editable resource
61
+ * @throws if the resource is already editable or if resource is an embedded object
62
+ */
63
+ export declare function checkout<T>(resource: unknown): Promise<T & ReactiveResource>;
64
+ /**
65
+ * Forcibly commit all local changes on an editable resource to
66
+ * the remote (immutable) version.
67
+ *
68
+ * This API should only be used cautiously. Typically a better
69
+ * approach is for either the API or a Handler to reflect saved
70
+ * changes back to update the cache.
71
+ *
72
+ * @public
73
+ */
74
+ export declare function commit(record: ReactiveResource): Promise<void>;
@@ -1,9 +1,8 @@
1
- import type { Store } from "../../store/-private.js";
2
1
  import type { SchemaService as SchemaServiceInterface } from "../../types.js";
3
- import type { StableRecordIdentifier } from "../../types/identifier.js";
2
+ import type { ResourceKey } from "../../types/identifier.js";
4
3
  import type { ObjectValue, Value } from "../../types/json/raw.js";
5
4
  import type { Derivation, HashFn } from "../../types/schema/concepts.js";
6
- import { type ArrayField, type CacheableFieldSchema, type DerivedField, type FieldSchema, type GenericField, type HashField, type IdentityField, type LegacyAttributeField, type LegacyBelongsToField, type LegacyHasManyField, type LegacyRelationshipField, type ObjectField, type ObjectSchema, type PolarisResourceSchema, type ResourceSchema, type Trait } from "../../types/schema/fields.js";
5
+ import { type ArrayField, type CacheableFieldSchema, type DerivedField, type FieldSchema, type GenericField, type HashField, type IdentityField, type LegacyAttributeField, type LegacyRelationshipField, type ObjectField, type ObjectSchema, type PolarisResourceSchema, type ResourceSchema, type Trait } from "../../types/schema/fields.js";
7
6
  import { Type } from "../../types/symbols.js";
8
7
  import type { WithPartial } from "../../types/utils.js";
9
8
  import type { ReactiveResource } from "./record.js";
@@ -31,12 +30,10 @@ export interface CAUTION_MEGA_DANGER_ZONE_Extension {
31
30
  * A constructable such as a Function or Class whose prototype
32
31
  * will be iterated with getOwnPropertyNames.
33
32
  */
34
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
35
33
  features: Record<string | symbol, unknown> | Function;
36
34
  }
37
35
  export type ExtensionDef = {
38
36
  kind: "method";
39
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
40
37
  fn: Function;
41
38
  } | {
42
39
  kind: "readonly-value";
@@ -95,11 +92,11 @@ interface FromIdentityDerivation {
95
92
  }, key: string): string | null;
96
93
  (record: ReactiveResource, options: {
97
94
  key: "^";
98
- }, key: string): StableRecordIdentifier;
95
+ }, key: string): ResourceKey;
99
96
  (record: ReactiveResource, options: null, key: string): asserts options;
100
97
  (record: ReactiveResource, options: {
101
98
  key: "id" | "lid" | "type" | "^";
102
- } | null, key: string): StableRecordIdentifier | string | null;
99
+ } | null, key: string): ResourceKey | string | null;
103
100
  [Type]: "@identity";
104
101
  }
105
102
  /**
@@ -133,7 +130,6 @@ export declare const fromIdentity: FromIdentityDerivation;
133
130
  * ```
134
131
  *
135
132
  * @public
136
- * @param {SchemaService} schema
137
133
  */
138
134
  export declare function registerDerivations(schema: SchemaServiceInterface): void;
139
135
  interface InternalSchema {
@@ -151,20 +147,9 @@ export type Transformation<
151
147
  > = {
152
148
  serialize(value: PT, options: Record<string, unknown> | null, record: ReactiveResource): T;
153
149
  hydrate(value: T | undefined, options: Record<string, unknown> | null, record: ReactiveResource): PT;
154
- defaultValue?(options: Record<string, unknown> | null, identifier: StableRecordIdentifier): T;
150
+ defaultValue?(options: Record<string, unknown> | null, identifier: ResourceKey): T;
155
151
  [Type]: string;
156
152
  };
157
- interface KindFns {
158
- belongsTo: {
159
- get: (store: Store, record: object, resourceKey: StableRecordIdentifier, field: LegacyBelongsToField) => unknown;
160
- set: (store: Store, record: object, cacheKey: StableRecordIdentifier, field: LegacyBelongsToField, value: unknown) => void;
161
- };
162
- hasMany: {
163
- get: (store: Store, record: object, resourceKey: StableRecordIdentifier, field: LegacyHasManyField) => unknown;
164
- set: (store: Store, record: object, cacheKey: StableRecordIdentifier, field: LegacyHasManyField, value: unknown) => void;
165
- notify: (store: Store, record: object, cacheKey: StableRecordIdentifier, field: LegacyHasManyField) => boolean;
166
- };
167
- }
168
153
  export interface SchemaService {
169
154
  doesTypeExist(type: string): boolean;
170
155
  attributesDefinitionFor(identifier: {
@@ -174,45 +159,16 @@ export interface SchemaService {
174
159
  type: string;
175
160
  }): InternalSchema["relationships"];
176
161
  }
177
- interface InternalTrait {
178
- name: string;
179
- mode: "legacy" | "polaris";
180
- fields: Map<string, FieldSchema>;
181
- traits: string[];
182
- }
183
162
  /**
184
163
  * A SchemaService designed to work with dynamically registered schemas.
185
164
  *
186
- * @class SchemaService
187
165
  * @public
188
166
  */
189
167
  export declare class SchemaService implements SchemaServiceInterface {
190
- /** @internal */
191
- _schemas: Map<string, InternalSchema>;
192
- /** @internal */
193
- _transforms: Map<string, Transformation>;
194
- /** @internal */
195
- _hashFns: Map<string, HashFn>;
196
- /** @internal */
197
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
198
- _derivations: Map<string, Derivation<any, any, any>>;
199
- /** @internal */
200
- _traits: Map<string, InternalTrait>;
201
- /** @internal */
202
- _modes: Map<string, KindFns>;
203
- /** @internal */
204
- _extensions: {
205
- object: Map<string, ProcessedExtension>;
206
- array: Map<string, ProcessedExtension>;
207
- };
208
- _cachedFieldExtensionsByField: {
209
- object: Map<object, ProcessedExtension["features"] | null>;
210
- array: Map<object, ProcessedExtension["features"] | null>;
211
- };
212
168
  constructor();
213
169
  resourceTypes(): Readonly<string[]>;
214
170
  hasTrait(type: string): boolean;
215
- resourceHasTrait(resource: StableRecordIdentifier | {
171
+ resourceHasTrait(resource: ResourceKey | {
216
172
  type: string;
217
173
  }, trait: string): boolean;
218
174
  transformation(field: GenericField | ObjectField | ArrayField | {
@@ -224,7 +180,7 @@ export declare class SchemaService implements SchemaServiceInterface {
224
180
  hashFn(field: HashField | {
225
181
  type: string;
226
182
  }): HashFn;
227
- resource(resource: StableRecordIdentifier | {
183
+ resource(resource: ResourceKey | {
228
184
  type: string;
229
185
  }): ResourceSchema | ObjectSchema;
230
186
  registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void;
@@ -268,7 +224,7 @@ export declare class SchemaService implements SchemaServiceInterface {
268
224
  FM extends ObjectValue | null
269
225
  >(derivation: Derivation<R, T, FM>): void;
270
226
  CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void;
271
- CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource: StableRecordIdentifier | {
227
+ CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource: ResourceKey | {
272
228
  type: string;
273
229
  }): null | ProcessedExtension["features"];
274
230
  CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField, resolvedType: string | null): null | ProcessedExtension["features"];
@@ -278,29 +234,11 @@ export declare class SchemaService implements SchemaServiceInterface {
278
234
  name: string;
279
235
  }): boolean;
280
236
  /**
281
- * This is an internal method used to register behaviors for legacy mode.
282
- * It is not intended for public use.
237
+ * Registers a {@link HashFn} for use with a {@link HashField} for
238
+ * either {@link ObjectSchema} identity or polymorphic type calculation.
283
239
  *
284
- * We do think a generalized `kind` registration system would be useful,
285
- * but we have not yet designed it.
286
- *
287
- * See https://github.com/emberjs/data/issues/9534
288
- *
289
- * @internal
290
- */
291
- _registerMode(mode: string, kinds: KindFns): void;
292
- /**
293
- * This is an internal method used to enable legacy behaviors for legacy mode.
294
- * It is not intended for public use.
295
- *
296
- * We do think a generalized `kind` registration system would be useful,
297
- * but we have not yet designed it.
298
- *
299
- * See https://github.com/emberjs/data/issues/9534
300
- *
301
- * @internal
240
+ * @public
302
241
  */
303
- _kind<T extends keyof KindFns>(mode: string, kind: T): KindFns[T];
304
242
  registerHashFn<T extends object>(hashFn: HashFn<T>): void;
305
243
  fields({ type }: {
306
244
  type: string;
@@ -1,36 +1,5 @@
1
- // Great, got your attention with that warning didn't we?
2
- // Good. Here's the deal: typescript treats symbols as unique types.
3
- // If by accident a module creating a symbol is processed more than
4
- // once, the symbol will be different in each processing. This will
5
- // cause a type error.
6
- // It could also cause a runtime error if the symbol is used innapropriately.
7
- // However, this case is extremely hard to hit and would require other things
8
- // to go wrong first.
9
- //
10
- // So, why do the warning? And why do we lie about the types of the symbols?
11
- //
12
- // Because we intentionally create multiple copies of them within the types
13
- // at build time. This is because we rollup our d.ts files in order to give
14
- // our consumers a better experience.
15
- //
16
- // However, no tool today supports rolling up d.ts files with multiple entry
17
- // points correctly. The tool we use currently (vite-plugin-dts) uses @microsoft/api-extractor
18
- // which creates a fully unique stand-alone types file per-entry-point. Thus
19
- // every entry point that uses one of these symbols somewhere will have accidentally
20
- // created a new symbol type.
21
- //
22
- // This cast allows us to rollup these types using this tool while not encountering
23
- // the unique symbol type issue.
24
- //
25
- // Note that none of these symbols are part of the public API, these are used for
26
- // debugging DX and as a safe way to provide an intimate contract on public objects.
27
1
  export declare const SOURCE: "___(unique) Symbol(SOURCE)";
28
- export declare const MUTATE: "___(unique) Symbol(MUTATE)";
29
2
  export declare const Destroy: "___(unique) Symbol(Destroy)";
30
- export declare const Identifier: "___(unique) Symbol(Identifier)";
31
- export declare const Editable: "___(unique) Symbol(Editable)";
32
- export declare const Parent: "___(unique) Symbol(Parent)";
33
3
  export declare const Checkout: "___(unique) Symbol(Checkout)";
34
- export declare const Legacy: "___(unique) Symbol(Legacy)";
35
- export declare const EmbeddedPath: "___(unique) Symbol(EmbeddedPath)";
36
- export declare const EmbeddedField: "___(unique) Symbol(EmbeddedField)";
4
+ export declare const Commit: "___(unique) Symbol(Commit)";
5
+ export declare const Context: "___(unique) Symbol(Context)";
@@ -1 +1 @@
1
- export { Editable, Legacy } from "./-private/symbols.js";
1
+ export { Context } from "./-private/symbols.js";