@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.
Files changed (162) hide show
  1. package/README.md +6 -0
  2. package/declarations/adapter/-private/build-url-mixin.d.ts +156 -0
  3. package/declarations/adapter/error.d.ts +385 -169
  4. package/declarations/adapter/json-api.d.ts +12 -1
  5. package/declarations/adapter/rest.d.ts +74 -0
  6. package/declarations/adapter.d.ts +6 -0
  7. package/declarations/compat/builders/find-all.d.ts +0 -1
  8. package/declarations/compat/extensions.d.ts +40 -0
  9. package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +7 -0
  10. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +4 -0
  11. package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +7 -0
  12. package/declarations/compat/utils.d.ts +11 -0
  13. package/declarations/compat.d.ts +32 -0
  14. package/declarations/index.d.ts +142 -0
  15. package/declarations/model/-private/attr.d.ts +21 -0
  16. package/declarations/model/-private/belongs-to.d.ts +21 -0
  17. package/declarations/model/-private/hooks.d.ts +26 -0
  18. package/declarations/model/-private/model.d.ts +55 -4
  19. package/declarations/model/-private/promise-many-array.d.ts +25 -1
  20. package/declarations/model/-private/schema-provider.d.ts +11 -1
  21. package/declarations/model/migration-support.d.ts +31 -5
  22. package/declarations/model-fragments/extensions/fragment-array.d.ts +38 -0
  23. package/declarations/model-fragments/extensions/fragment.d.ts +35 -0
  24. package/declarations/model-fragments/hooks/model-for.d.ts +7 -0
  25. package/declarations/model-fragments/index.d.ts +8 -0
  26. package/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +6 -0
  27. package/declarations/model-fragments/utilities/with-array-defaults.d.ts +30 -0
  28. package/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +18 -0
  29. package/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +15 -0
  30. package/declarations/model-fragments/utilities/with-legacy.d.ts +8 -0
  31. package/declarations/serializer/-private/transforms/boolean.d.ts +13 -0
  32. package/declarations/serializer/-private/transforms/date.d.ts +15 -1
  33. package/declarations/serializer/-private/transforms/number.d.ts +14 -1
  34. package/declarations/serializer/-private/transforms/string.d.ts +14 -1
  35. package/declarations/serializer/-private/utils.d.ts +24 -0
  36. package/declarations/serializer/json-api.d.ts +1 -1
  37. package/declarations/serializer.d.ts +4 -6
  38. package/declarations/store/-private.d.ts +2 -2
  39. package/declarations/store.d.ts +7 -0
  40. package/dist/adapter/error.js +386 -241
  41. package/dist/adapter/json-api.js +12 -0
  42. package/dist/adapter/rest.js +39 -3
  43. package/dist/adapter.js +23 -26
  44. package/dist/compat/builders.js +0 -1
  45. package/dist/compat/extensions.js +80 -3
  46. package/dist/compat/utils.js +14 -0
  47. package/dist/compat.js +17 -0
  48. package/dist/{errors-Cz5KrzBk.js → errors-DZKA206g.js} +24 -1
  49. package/dist/{hooks-D6diaM34.js → hooks-BvOqJBei.js} +33 -2
  50. package/dist/index.js +168 -13
  51. package/dist/{json-ChdEfB0X.js → json-DU8m1pGf.js} +83 -6
  52. package/dist/model/-private.js +1 -1
  53. package/dist/model/migration-support.js +15 -2
  54. package/dist/{unpkg/dev-deprecated/model-for-CqXsIKws.js → model-for-CXkJw59V.js} +77 -1
  55. package/dist/model-fragments.js +18 -2
  56. package/dist/model.js +12 -8
  57. package/dist/{schema-provider-DJCV_6AF.js → schema-provider-DtPOp0d7.js} +93 -6
  58. package/dist/serializer/json-api.js +8 -3
  59. package/dist/serializer/json.js +1 -1
  60. package/dist/serializer/rest.js +3 -4
  61. package/dist/serializer/transform.js +51 -3
  62. package/dist/serializer.js +4 -7
  63. package/dist/store.js +13 -7
  64. package/dist/unpkg/dev/adapter/error.js +386 -241
  65. package/dist/unpkg/dev/adapter/json-api.js +13 -1
  66. package/dist/unpkg/dev/adapter/rest.js +39 -3
  67. package/dist/unpkg/dev/adapter.js +23 -26
  68. package/dist/unpkg/dev/compat/builders.js +0 -1
  69. package/dist/unpkg/dev/compat/extensions.js +80 -3
  70. package/dist/unpkg/dev/compat/utils.js +14 -0
  71. package/dist/unpkg/dev/compat.js +34 -1
  72. package/dist/unpkg/dev/{errors-DmGGJr3T.js → errors-DngRU-If.js} +24 -1
  73. package/dist/unpkg/dev/{hooks-CkYiE6Ud.js → hooks-UuiLxWxS.js} +33 -2
  74. package/dist/unpkg/dev/index.js +171 -13
  75. package/dist/unpkg/dev/json-K2Y9z6MN.js +1333 -0
  76. package/dist/unpkg/dev/model/-private.js +1 -1
  77. package/dist/unpkg/dev/model/migration-support.js +16 -2
  78. package/dist/unpkg/{prod-deprecated/model-for-CqXsIKws.js → dev/model-for-CXkJw59V.js} +77 -1
  79. package/dist/unpkg/dev/model-fragments.js +18 -2
  80. package/dist/unpkg/dev/model.js +12 -8
  81. package/dist/unpkg/dev/{schema-provider-DDVYxmUV.js → schema-provider-0D7f-QOn.js} +92 -6
  82. package/dist/unpkg/dev/serializer/json-api.js +9 -4
  83. package/dist/unpkg/dev/serializer/json.js +1 -1
  84. package/dist/unpkg/dev/serializer/rest.js +3 -4
  85. package/dist/unpkg/dev/serializer/transform.js +51 -3
  86. package/dist/unpkg/dev/serializer.js +4 -7
  87. package/dist/unpkg/dev/store.js +21 -7
  88. package/dist/unpkg/dev-deprecated/adapter/error.js +386 -241
  89. package/dist/unpkg/dev-deprecated/adapter/json-api.js +13 -1
  90. package/dist/unpkg/dev-deprecated/adapter/rest.js +39 -3
  91. package/dist/unpkg/dev-deprecated/adapter.js +23 -26
  92. package/dist/unpkg/dev-deprecated/compat/builders.js +0 -1
  93. package/dist/unpkg/dev-deprecated/compat/extensions.js +80 -3
  94. package/dist/unpkg/dev-deprecated/compat/utils.js +14 -0
  95. package/dist/unpkg/dev-deprecated/compat.js +34 -1
  96. package/dist/unpkg/dev-deprecated/{errors-Spt6ubMd.js → errors-Bzidntpi.js} +24 -1
  97. package/dist/unpkg/dev-deprecated/{hooks-DOXegvhL.js → hooks-DVXhMW14.js} +33 -2
  98. package/dist/unpkg/dev-deprecated/index.js +171 -13
  99. package/dist/unpkg/{prod-deprecated/json-BWrZ5546.js → dev-deprecated/json-K2Y9z6MN.js} +96 -6
  100. package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
  101. package/dist/unpkg/dev-deprecated/model/migration-support.js +16 -2
  102. package/dist/unpkg/{dev/model-for-CqXsIKws.js → dev-deprecated/model-for-CXkJw59V.js} +77 -1
  103. package/dist/unpkg/dev-deprecated/model-fragments.js +18 -2
  104. package/dist/unpkg/dev-deprecated/model.js +12 -8
  105. package/dist/unpkg/dev-deprecated/{schema-provider-BP6_8N-V.js → schema-provider-ZwO5_fZw.js} +84 -3
  106. package/dist/unpkg/dev-deprecated/serializer/json-api.js +9 -4
  107. package/dist/unpkg/dev-deprecated/serializer/json.js +1 -1
  108. package/dist/unpkg/dev-deprecated/serializer/rest.js +3 -4
  109. package/dist/unpkg/dev-deprecated/serializer/transform.js +51 -3
  110. package/dist/unpkg/dev-deprecated/serializer.js +4 -7
  111. package/dist/unpkg/dev-deprecated/store.js +21 -7
  112. package/dist/unpkg/prod/adapter/error.js +386 -241
  113. package/dist/unpkg/prod/adapter/json-api.js +13 -1
  114. package/dist/unpkg/prod/adapter/rest.js +39 -3
  115. package/dist/unpkg/prod/adapter.js +23 -26
  116. package/dist/unpkg/prod/compat/builders.js +0 -1
  117. package/dist/unpkg/prod/compat/extensions.js +70 -3
  118. package/dist/unpkg/prod/compat/utils.js +14 -0
  119. package/dist/unpkg/prod/compat.js +17 -0
  120. package/dist/unpkg/prod/{errors-BGVFCBmi.js → errors-B-PWeYlW.js} +24 -1
  121. package/dist/unpkg/prod/{hooks-BztVA_x0.js → hooks-Bx-zBziU.js} +32 -1
  122. package/dist/unpkg/prod/index.js +171 -5
  123. package/dist/unpkg/{dev/json-Cu1LNgmQ.js → prod/json-Qewu-UN9.js} +63 -19
  124. package/dist/unpkg/prod/model/-private.js +1 -1
  125. package/dist/unpkg/prod/model/migration-support.js +16 -2
  126. package/dist/unpkg/prod/model-for-CXkJw59V.js +297 -0
  127. package/dist/unpkg/prod/model-fragments.js +18 -2
  128. package/dist/unpkg/prod/model.js +12 -8
  129. package/dist/unpkg/prod/{schema-provider-DJtD_8jZ.js → schema-provider-BgRqk8i9.js} +96 -6
  130. package/dist/unpkg/prod/serializer/json-api.js +9 -4
  131. package/dist/unpkg/prod/serializer/json.js +1 -1
  132. package/dist/unpkg/prod/serializer/rest.js +3 -4
  133. package/dist/unpkg/prod/serializer/transform.js +51 -3
  134. package/dist/unpkg/prod/serializer.js +4 -7
  135. package/dist/unpkg/prod/store.js +21 -7
  136. package/dist/unpkg/prod-deprecated/adapter/error.js +386 -241
  137. package/dist/unpkg/prod-deprecated/adapter/json-api.js +13 -1
  138. package/dist/unpkg/prod-deprecated/adapter/rest.js +39 -3
  139. package/dist/unpkg/prod-deprecated/adapter.js +23 -26
  140. package/dist/unpkg/prod-deprecated/compat/builders.js +0 -1
  141. package/dist/unpkg/prod-deprecated/compat/extensions.js +70 -3
  142. package/dist/unpkg/prod-deprecated/compat/utils.js +14 -0
  143. package/dist/unpkg/prod-deprecated/compat.js +17 -0
  144. package/dist/unpkg/prod-deprecated/{errors-CdDaK81x.js → errors-Dl2J9d1D.js} +24 -1
  145. package/dist/unpkg/prod-deprecated/{hooks-yId87yyG.js → hooks-Cm60wWTf.js} +32 -1
  146. package/dist/unpkg/prod-deprecated/index.js +171 -5
  147. package/dist/unpkg/{dev-deprecated/json-Cu1LNgmQ.js → prod-deprecated/json-Qewu-UN9.js} +63 -19
  148. package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
  149. package/dist/unpkg/prod-deprecated/model/migration-support.js +16 -2
  150. package/dist/{model-for-CqXsIKws.js → unpkg/prod-deprecated/model-for-CXkJw59V.js} +77 -1
  151. package/dist/unpkg/prod-deprecated/model-fragments.js +18 -2
  152. package/dist/unpkg/prod-deprecated/model.js +12 -8
  153. package/dist/unpkg/prod-deprecated/{schema-provider-CjX55uSY.js → schema-provider-Dh6tRqVI.js} +79 -3
  154. package/dist/unpkg/prod-deprecated/serializer/json-api.js +9 -4
  155. package/dist/unpkg/prod-deprecated/serializer/json.js +1 -1
  156. package/dist/unpkg/prod-deprecated/serializer/rest.js +3 -4
  157. package/dist/unpkg/prod-deprecated/serializer/transform.js +51 -3
  158. package/dist/unpkg/prod-deprecated/serializer.js +4 -7
  159. package/dist/unpkg/prod-deprecated/store.js +21 -7
  160. package/package.json +8 -8
  161. package/dist/unpkg/prod/json-BWrZ5546.js +0 -1243
  162. package/dist/unpkg/prod/model-for-CqXsIKws.js +0 -221
@@ -1,5 +1,8 @@
1
1
  import type { TransformName } from "@warp-drive/core/types/symbols";
2
2
  export interface StringTransform {
3
+ /**
4
+ * see {@link TransformName}
5
+ */
3
6
  [TransformName]: "string";
4
7
  }
5
8
  /**
@@ -11,7 +14,7 @@ used when `string` is passed as the type parameter to the
11
14
  Usage
12
15
 
13
16
  ```js [app/models/user.js]
14
- import Model, { attr, belongsTo } from '@ember-data/model';
17
+ import Model, { attr, belongsTo } from '@warp-drive/legacy/model';
15
18
 
16
19
  export default class UserModel extends Model {
17
20
  @attr('boolean') isAdmin;
@@ -23,7 +26,17 @@ export default class UserModel extends Model {
23
26
  @public
24
27
  */
25
28
  export declare class StringTransform {
29
+ /**
30
+ * Converts a serialized (raw payload) value into a `string`, or `null`
31
+ * if the value is falsy (and not an empty string).
32
+ */
26
33
  deserialize(serialized: unknown, _options?: Record<string, unknown>): string | null;
34
+ /**
35
+ * Converts a `string` attribute value into its serialized (raw payload) form.
36
+ */
27
37
  serialize(deserialized: unknown, _options?: Record<string, unknown>): string | null;
38
+ /**
39
+ * Creates a new instance of this transform.
40
+ */
28
41
  static create(): StringTransform;
29
42
  }
@@ -1,3 +1,27 @@
1
+ import type { Store } from "@warp-drive/core";
2
+ import type { LegacyBelongsToField, LegacyHasManyField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
1
3
  type Coercable = string | number | boolean | null | undefined | symbol;
2
4
  export declare function coerceId(id: Coercable): string | null;
5
+ /**
6
+ Given the name of a relationship on a resource `type`, determines the
7
+ inverse relationship field (if any) using only the schema service.
8
+
9
+ Unlike `Model.inverseFor`, this does not require `type` to be backed by
10
+ a `Model` class, so it works for both `Model`-based and schema-only
11
+ (e.g. `withDefaults` migration-support) resources.
12
+
13
+ @private
14
+ */
15
+ export declare function inverseForRelationship(store: Store, type: string, name: string): LegacyRelationshipField | null;
16
+ /**
17
+ Given a relationship field on a resource `type`, determines the
18
+ cardinality of the relationship using only the schema service.
19
+
20
+ Unlike `Model.determineRelationshipType`, this does not require `type`
21
+ to be backed by a `Model` class, so it works for both `Model`-based and
22
+ schema-only (e.g. `withDefaults` migration-support) resources.
23
+
24
+ @private
25
+ */
26
+ export declare function determineRelationshipType(store: Store, type: string, knownSide: LegacyBelongsToField | LegacyHasManyField): "oneToOne" | "oneToMany" | "manyToOne" | "manyToMany" | "oneToNone" | "manyToNone";
3
27
  export {};
@@ -93,7 +93,7 @@ below shows how this could be done using `normalizeArrayResponse` and
93
93
  `extractRelationship`.
94
94
 
95
95
  ```js [app/serializers/application.js]
96
- import JSONAPISerializer from '@warp-drive/legacy/serializer/json-api';
96
+ import { JSONAPISerializer } from '@warp-drive/legacy/serializer/json-api';
97
97
 
98
98
  export default class ApplicationSerializer extends JSONAPISerializer {
99
99
  normalizeArrayResponse(store, primaryModelClass, payload, id, requestType) {
@@ -128,7 +128,6 @@ For an example implementation, see the included {@link JSONSerializer}.
128
128
  @public
129
129
  */
130
130
  export declare class Serializer extends EmberObject {
131
- store: Store;
132
131
  /**
133
132
  The `store` property is the application's `store` that contains
134
133
  all records. It can be used to look up serializers for other model
@@ -146,10 +145,9 @@ export declare class Serializer extends EmberObject {
146
145
  });
147
146
  ```
148
147
 
149
- @property store
150
- @type {Store}
151
148
  @public
152
149
  */
150
+ store: Store;
153
151
  /**
154
152
  The `normalizeResponse` method is used to normalize a payload from the
155
153
  server to a JSON-API Document.
@@ -246,9 +244,9 @@ export declare class Serializer extends EmberObject {
246
244
  ```
247
245
 
248
246
  @public
249
- @param {Model} typeClass
250
- @param {Object} hash
251
- @return {Object}
247
+ @param _typeClass - the model class the hash is being normalized for
248
+ @param hash - the raw payload hash to normalize
249
+ @return the normalized resource document
252
250
  */
253
251
  normalize(_typeClass: ModelSchema, hash: Record<string, unknown>): SingleResourceDocument | EmptyResourceDocument;
254
252
  }
@@ -124,7 +124,7 @@ export declare class RecordReference {
124
124
  normalized hash of data and the object represented by the reference
125
125
  will update.
126
126
 
127
- If you pass a promise to `push`, Ember Data will not ask the adapter
127
+ If you pass a promise to `push`, WarpDrive will not ask the adapter
128
128
  for the data if another attempt to fetch it is made in the
129
129
  interim. When the promise resolves, the underlying object is updated
130
130
  with the new data, and the promise returned by *this function* is resolved
@@ -171,7 +171,7 @@ export declare class RecordReference {
171
171
  ```
172
172
 
173
173
  @public
174
- @return {Model} the record for this RecordReference
174
+ @return the record for this RecordReference
175
175
  */
176
176
  value(): OpaqueRecordInstance | null;
177
177
  /**
@@ -1,3 +1,10 @@
1
1
  import type { Store } from "@warp-drive/core";
2
+ /**
3
+ * Restores the deprecated `findRecord`/`findAll`/`query`/`queryRecord`/
4
+ * `findBelongsTo`/`findHasMany`/`createRecord`/`deleteRecord`/`saveRecord`
5
+ * legacy-network-layer implementations of these methods onto the given
6
+ * `Store` subclass, for apps that have not yet migrated to the
7
+ * `RequestManager`-based equivalents.
8
+ */
2
9
  export declare function restoreDeprecatedStoreBehaviors(StoreKlass: typeof Store): void;
3
10
  export { Store };