@warp-drive/core 5.8.0-alpha.37 → 5.8.0-alpha.40
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/declarations/index.d.ts +0 -4
- package/dist/{index-D4si_DxB.js → index-BKcD4JZK.js} +12 -8
- package/dist/index.js +1 -1
- package/dist/reactive.js +1 -1
- package/dist/store/-private.js +1 -1
- package/dist/types/-private.js +1 -1
- package/dist/unpkg/{prod-deprecated/symbols-sql1_mdx.js → dev/-private-3C1OkYtZ.js} +1 -1
- package/dist/unpkg/{dev-deprecated/configure-C3x8YXzL.js → dev/configure-BC66sfNO.js} +13 -11
- package/dist/unpkg/dev/configure.js +1 -1
- package/dist/unpkg/dev/graph/-private.js +206 -449
- package/dist/unpkg/dev/{index-D4si_DxB.js → index-DqhXrNZ_.js} +741 -1327
- package/dist/unpkg/dev/index.js +5 -7
- package/dist/unpkg/dev/reactive/-private.js +1 -1
- package/dist/unpkg/dev/reactive.js +4 -6
- package/dist/unpkg/{dev-deprecated/request-oqoLC9rz.js → dev/request-CA9K0gXq.js} +10 -16
- package/dist/unpkg/dev/request.js +1 -1
- package/dist/unpkg/dev/runtime-DGG4CvlW.js +135 -0
- package/dist/unpkg/dev/store/-private.js +56 -2
- package/dist/unpkg/dev/store.js +558 -1
- package/dist/unpkg/dev/types/-private.js +5 -15
- package/dist/unpkg/dev/types/identifier.js +1 -3
- package/dist/unpkg/dev/utils/string.js +5 -6
- package/dist/unpkg/dev-deprecated/{symbols-sql1_mdx.js → -private-3C1OkYtZ.js} +1 -1
- package/dist/unpkg/{prod-deprecated/configure-C3x8YXzL.js → dev-deprecated/configure-BC66sfNO.js} +13 -11
- package/dist/unpkg/dev-deprecated/configure.js +1 -1
- package/dist/unpkg/dev-deprecated/graph/-private.js +216 -264
- package/dist/unpkg/dev-deprecated/{index-D4si_DxB.js → index-BBlq5is_.js} +834 -805
- package/dist/unpkg/dev-deprecated/index.js +4 -7
- package/dist/unpkg/dev-deprecated/reactive/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/reactive.js +4 -6
- package/dist/unpkg/{prod-deprecated/request-oqoLC9rz.js → dev-deprecated/request-CA9K0gXq.js} +10 -16
- package/dist/unpkg/dev-deprecated/request.js +1 -1
- package/dist/unpkg/dev-deprecated/runtime-DfhJzpZH.js +135 -0
- package/dist/unpkg/dev-deprecated/store/-private.js +2 -2
- package/dist/unpkg/dev-deprecated/store.js +558 -1
- package/dist/unpkg/dev-deprecated/types/-private.js +5 -15
- package/dist/unpkg/dev-deprecated/types/identifier.js +1 -3
- package/dist/unpkg/dev-deprecated/utils/string.js +5 -6
- package/dist/unpkg/{dev/symbols-sql1_mdx.js → prod/-private-3C1OkYtZ.js} +1 -1
- package/dist/unpkg/prod/{configure-C3x8YXzL.js → configure-C0C1LpG6.js} +5 -28
- package/dist/unpkg/prod/configure.js +1 -1
- package/dist/unpkg/prod/graph/-private.js +4 -1144
- package/dist/unpkg/prod/handler-LAyD1Y5l.js +1619 -0
- package/dist/unpkg/prod/hooks-BfiqDg3O.js +26 -0
- package/dist/unpkg/prod/index.js +481 -8
- package/dist/unpkg/prod/promise-state-ipG60SdD.js +6738 -0
- package/dist/unpkg/prod/reactive/-private.js +1 -1
- package/dist/unpkg/prod/reactive.js +5 -7
- package/dist/unpkg/prod/request-CN2LxbYX.js +437 -0
- package/dist/unpkg/prod/request.js +1 -1
- package/dist/unpkg/prod/store/-private.js +127 -2
- package/dist/unpkg/prod/store.js +437 -1
- package/dist/unpkg/prod/types/-private.js +4 -34
- package/dist/unpkg/prod/types/identifier.js +2 -4
- package/dist/unpkg/prod/utils/string.js +0 -20
- package/dist/unpkg/{prod/symbols-sql1_mdx.js → prod-deprecated/-private-3C1OkYtZ.js} +1 -1
- package/dist/unpkg/{dev/configure-C3x8YXzL.js → prod-deprecated/configure-BQ8CpIcW.js} +4 -27
- package/dist/unpkg/prod-deprecated/configure.js +1 -1
- package/dist/unpkg/prod-deprecated/graph/-private.js +12 -979
- package/dist/unpkg/prod-deprecated/handler-D639oFvl.js +334 -0
- package/dist/unpkg/prod-deprecated/hooks-DGvi9teJ.js +26 -0
- package/dist/unpkg/prod-deprecated/index.js +481 -8
- package/dist/unpkg/prod-deprecated/{index-D4si_DxB.js → promise-state-CYvoIPna.js} +278 -3566
- package/dist/unpkg/prod-deprecated/reactive/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/reactive.js +4 -7
- package/dist/unpkg/prod-deprecated/request-CN2LxbYX.js +437 -0
- package/dist/unpkg/prod-deprecated/request.js +1 -1
- package/dist/unpkg/prod-deprecated/store/-private.js +89 -2
- package/dist/unpkg/prod-deprecated/store.js +437 -1
- package/dist/unpkg/prod-deprecated/types/-private.js +4 -34
- package/dist/unpkg/prod-deprecated/types/identifier.js +2 -4
- package/dist/unpkg/prod-deprecated/utils/string.js +0 -20
- package/package.json +11 -19
- package/dist/unpkg/dev/declarations/build-config/babel-macros.d.ts +0 -1
- package/dist/unpkg/dev/declarations/build-config/canary-features.d.ts +0 -1
- package/dist/unpkg/dev/declarations/build-config/debugging.d.ts +0 -1
- package/dist/unpkg/dev/declarations/build-config/deprecations.d.ts +0 -1
- package/dist/unpkg/dev/declarations/build-config/env.d.ts +0 -1
- package/dist/unpkg/dev/declarations/build-config/macros.d.ts +0 -1
- package/dist/unpkg/dev/declarations/build-config.d.ts +0 -18
- package/dist/unpkg/dev/declarations/configure.d.ts +0 -7
- package/dist/unpkg/dev/declarations/graph/-private/-diff.d.ts +0 -19
- package/dist/unpkg/dev/declarations/graph/-private/-edge-definition.d.ts +0 -149
- package/dist/unpkg/dev/declarations/graph/-private/-state.d.ts +0 -9
- package/dist/unpkg/dev/declarations/graph/-private/-utils.d.ts +0 -25
- package/dist/unpkg/dev/declarations/graph/-private/coerce-id.d.ts +0 -4
- package/dist/unpkg/dev/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +0 -6
- package/dist/unpkg/dev/declarations/graph/-private/edges/collection.d.ts +0 -39
- package/dist/unpkg/dev/declarations/graph/-private/edges/implicit.d.ts +0 -43
- package/dist/unpkg/dev/declarations/graph/-private/edges/resource.d.ts +0 -23
- package/dist/unpkg/dev/declarations/graph/-private/graph.d.ts +0 -56
- package/dist/unpkg/dev/declarations/graph/-private/normalize-link.d.ts +0 -2
- package/dist/unpkg/dev/declarations/graph/-private/operations/add-to-related-records.d.ts +0 -4
- package/dist/unpkg/dev/declarations/graph/-private/operations/merge-identifier.d.ts +0 -3
- package/dist/unpkg/dev/declarations/graph/-private/operations/remove-from-related-records.d.ts +0 -4
- package/dist/unpkg/dev/declarations/graph/-private/operations/replace-related-record.d.ts +0 -3
- package/dist/unpkg/dev/declarations/graph/-private/operations/replace-related-records.d.ts +0 -7
- package/dist/unpkg/dev/declarations/graph/-private/operations/update-relationship.d.ts +0 -9
- package/dist/unpkg/dev/declarations/graph/-private.d.ts +0 -13
- package/dist/unpkg/dev/declarations/index.d.ts +0 -100
- package/dist/unpkg/dev/declarations/reactive/-private/default-mode.d.ts +0 -73
- package/dist/unpkg/dev/declarations/reactive/-private/document.d.ts +0 -142
- package/dist/unpkg/dev/declarations/reactive/-private/fields/extension.d.ts +0 -8
- package/dist/unpkg/dev/declarations/reactive/-private/fields/get-field-key.d.ts +0 -8
- package/dist/unpkg/dev/declarations/reactive/-private/fields/managed-array.d.ts +0 -18
- package/dist/unpkg/dev/declarations/reactive/-private/fields/managed-object.d.ts +0 -17
- package/dist/unpkg/dev/declarations/reactive/-private/fields/many-array-manager.d.ts +0 -19
- package/dist/unpkg/dev/declarations/reactive/-private/hooks.d.ts +0 -5
- package/dist/unpkg/dev/declarations/reactive/-private/kind/alias-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/array-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/attribute-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/belongs-to-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/collection-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/derived-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/generic-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/has-many-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/hash-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/identity-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/local-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/object-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/resource-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/schema-array-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/kind/schema-object-field.d.ts +0 -4
- package/dist/unpkg/dev/declarations/reactive/-private/record.d.ts +0 -83
- package/dist/unpkg/dev/declarations/reactive/-private/schema.d.ts +0 -326
- package/dist/unpkg/dev/declarations/reactive/-private/symbols.d.ts +0 -5
- package/dist/unpkg/dev/declarations/reactive/-private.d.ts +0 -2
- package/dist/unpkg/dev/declarations/reactive.d.ts +0 -287
- package/dist/unpkg/dev/declarations/request/-private/context.d.ts +0 -39
- package/dist/unpkg/dev/declarations/request/-private/debug.d.ts +0 -4
- package/dist/unpkg/dev/declarations/request/-private/fetch.d.ts +0 -33
- package/dist/unpkg/dev/declarations/request/-private/future.d.ts +0 -7
- package/dist/unpkg/dev/declarations/request/-private/manager.d.ts +0 -158
- package/dist/unpkg/dev/declarations/request/-private/promise-cache.d.ts +0 -28
- package/dist/unpkg/dev/declarations/request/-private/types.d.ts +0 -234
- package/dist/unpkg/dev/declarations/request/-private/utils.d.ts +0 -57
- package/dist/unpkg/dev/declarations/request.d.ts +0 -52
- package/dist/unpkg/dev/declarations/store/-private/cache-handler/handler.d.ts +0 -56
- package/dist/unpkg/dev/declarations/store/-private/cache-handler/types.d.ts +0 -98
- package/dist/unpkg/dev/declarations/store/-private/cache-handler/utils.d.ts +0 -31
- package/dist/unpkg/dev/declarations/store/-private/caches/instance-cache.d.ts +0 -58
- package/dist/unpkg/dev/declarations/store/-private/caches/resource-utils.d.ts +0 -9
- package/dist/unpkg/dev/declarations/store/-private/debug/utils.d.ts +0 -7
- package/dist/unpkg/dev/declarations/store/-private/default-cache-policy.d.ts +0 -387
- package/dist/unpkg/dev/declarations/store/-private/managers/cache-capabilities-manager.d.ts +0 -34
- package/dist/unpkg/dev/declarations/store/-private/managers/cache-key-manager.d.ts +0 -304
- package/dist/unpkg/dev/declarations/store/-private/managers/cache-manager.d.ts +0 -380
- package/dist/unpkg/dev/declarations/store/-private/managers/notification-manager.d.ts +0 -83
- package/dist/unpkg/dev/declarations/store/-private/managers/record-array-manager.d.ts +0 -100
- package/dist/unpkg/dev/declarations/store/-private/network/request-cache.d.ts +0 -103
- package/dist/unpkg/dev/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +0 -24
- package/dist/unpkg/dev/declarations/store/-private/new-core-tmp/promise-state.d.ts +0 -264
- package/dist/unpkg/dev/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +0 -138
- package/dist/unpkg/dev/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +0 -154
- package/dist/unpkg/dev/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +0 -56
- package/dist/unpkg/dev/declarations/store/-private/new-core-tmp/request-state.d.ts +0 -372
- package/dist/unpkg/dev/declarations/store/-private/new-core-tmp/request-subscription.d.ts +0 -177
- package/dist/unpkg/dev/declarations/store/-private/record-arrays/-utils.d.ts +0 -80
- package/dist/unpkg/dev/declarations/store/-private/record-arrays/legacy-live-array.d.ts +0 -81
- package/dist/unpkg/dev/declarations/store/-private/record-arrays/legacy-many-array.d.ts +0 -133
- package/dist/unpkg/dev/declarations/store/-private/record-arrays/legacy-query.d.ts +0 -81
- package/dist/unpkg/dev/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +0 -3
- package/dist/unpkg/dev/declarations/store/-private/record-arrays/resource-array.d.ts +0 -67
- package/dist/unpkg/dev/declarations/store/-private/store-service.d.ts +0 -874
- package/dist/unpkg/dev/declarations/store/-private/utils/coerce-id.d.ts +0 -4
- package/dist/unpkg/dev/declarations/store/-private/utils/construct-resource.d.ts +0 -6
- package/dist/unpkg/dev/declarations/store/-private/utils/is-non-empty-string.d.ts +0 -1
- package/dist/unpkg/dev/declarations/store/-private/utils/normalize-model-name.d.ts +0 -1
- package/dist/unpkg/dev/declarations/store/-private/utils/uuid-polyfill.d.ts +0 -1
- package/dist/unpkg/dev/declarations/store/-private.d.ts +0 -29
- package/dist/unpkg/dev/declarations/store/-types/q/cache-capabilities-manager.d.ts +0 -90
- package/dist/unpkg/dev/declarations/store/-types/q/identifier.d.ts +0 -23
- package/dist/unpkg/dev/declarations/store/-types/q/record-instance.d.ts +0 -22
- package/dist/unpkg/dev/declarations/store/-types/q/store.d.ts +0 -31
- package/dist/unpkg/dev/declarations/store/deprecated/-private.d.ts +0 -223
- package/dist/unpkg/dev/declarations/store/deprecated/store.d.ts +0 -784
- package/dist/unpkg/dev/declarations/store.d.ts +0 -2
- package/dist/unpkg/dev/declarations/types/-private.d.ts +0 -22
- package/dist/unpkg/dev/declarations/types/cache/aliases.d.ts +0 -1
- package/dist/unpkg/dev/declarations/types/cache/change.d.ts +0 -6
- package/dist/unpkg/dev/declarations/types/cache/mutations.d.ts +0 -38
- package/dist/unpkg/dev/declarations/types/cache/operations.d.ts +0 -168
- package/dist/unpkg/dev/declarations/types/cache/relationship.d.ts +0 -13
- package/dist/unpkg/dev/declarations/types/cache.d.ts +0 -429
- package/dist/unpkg/dev/declarations/types/graph.d.ts +0 -47
- package/dist/unpkg/dev/declarations/types/identifier.d.ts +0 -86
- package/dist/unpkg/dev/declarations/types/json/raw.d.ts +0 -6
- package/dist/unpkg/dev/declarations/types/params.d.ts +0 -8
- package/dist/unpkg/dev/declarations/types/record.d.ts +0 -269
- package/dist/unpkg/dev/declarations/types/request.d.ts +0 -367
- package/dist/unpkg/dev/declarations/types/runtime.d.ts +0 -14
- package/dist/unpkg/dev/declarations/types/schema/concepts.d.ts +0 -23
- package/dist/unpkg/dev/declarations/types/schema/fields.d.ts +0 -2200
- package/dist/unpkg/dev/declarations/types/schema/fields.type-test.d.ts +0 -1
- package/dist/unpkg/dev/declarations/types/schema/schema-service.d.ts +0 -380
- package/dist/unpkg/dev/declarations/types/spec/document.d.ts +0 -67
- package/dist/unpkg/dev/declarations/types/spec/error.d.ts +0 -18
- package/dist/unpkg/dev/declarations/types/spec/json-api-raw.d.ts +0 -139
- package/dist/unpkg/dev/declarations/types/symbols.d.ts +0 -78
- package/dist/unpkg/dev/declarations/types/utils.d.ts +0 -5
- package/dist/unpkg/dev/declarations/types.d.ts +0 -11
- package/dist/unpkg/dev/declarations/utils/string.d.ts +0 -47
- package/dist/unpkg/dev/default-cache-policy-D7_u4YRH.js +0 -572
- package/dist/unpkg/dev/request-oqoLC9rz.js +0 -725
- package/dist/unpkg/dev-deprecated/declarations/build-config/babel-macros.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/build-config/canary-features.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/build-config/debugging.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/build-config/deprecations.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/build-config/env.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/build-config/macros.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/build-config.d.ts +0 -18
- package/dist/unpkg/dev-deprecated/declarations/configure.d.ts +0 -7
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/-diff.d.ts +0 -19
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/-edge-definition.d.ts +0 -149
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/-state.d.ts +0 -9
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/-utils.d.ts +0 -25
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/coerce-id.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +0 -6
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/edges/collection.d.ts +0 -39
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/edges/implicit.d.ts +0 -43
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/edges/resource.d.ts +0 -23
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/graph.d.ts +0 -56
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/normalize-link.d.ts +0 -2
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/operations/add-to-related-records.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/operations/merge-identifier.d.ts +0 -3
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/operations/remove-from-related-records.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/operations/replace-related-record.d.ts +0 -3
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/operations/replace-related-records.d.ts +0 -7
- package/dist/unpkg/dev-deprecated/declarations/graph/-private/operations/update-relationship.d.ts +0 -9
- package/dist/unpkg/dev-deprecated/declarations/graph/-private.d.ts +0 -13
- package/dist/unpkg/dev-deprecated/declarations/index.d.ts +0 -100
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/default-mode.d.ts +0 -73
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/document.d.ts +0 -142
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/fields/extension.d.ts +0 -8
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/fields/get-field-key.d.ts +0 -8
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/fields/managed-array.d.ts +0 -18
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/fields/managed-object.d.ts +0 -17
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/fields/many-array-manager.d.ts +0 -19
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/hooks.d.ts +0 -5
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/alias-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/array-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/attribute-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/belongs-to-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/collection-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/derived-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/generic-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/has-many-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/hash-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/identity-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/local-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/object-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/resource-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/schema-array-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/kind/schema-object-field.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/record.d.ts +0 -83
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/schema.d.ts +0 -326
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private/symbols.d.ts +0 -5
- package/dist/unpkg/dev-deprecated/declarations/reactive/-private.d.ts +0 -2
- package/dist/unpkg/dev-deprecated/declarations/reactive.d.ts +0 -287
- package/dist/unpkg/dev-deprecated/declarations/request/-private/context.d.ts +0 -39
- package/dist/unpkg/dev-deprecated/declarations/request/-private/debug.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/request/-private/fetch.d.ts +0 -33
- package/dist/unpkg/dev-deprecated/declarations/request/-private/future.d.ts +0 -7
- package/dist/unpkg/dev-deprecated/declarations/request/-private/manager.d.ts +0 -158
- package/dist/unpkg/dev-deprecated/declarations/request/-private/promise-cache.d.ts +0 -28
- package/dist/unpkg/dev-deprecated/declarations/request/-private/types.d.ts +0 -234
- package/dist/unpkg/dev-deprecated/declarations/request/-private/utils.d.ts +0 -57
- package/dist/unpkg/dev-deprecated/declarations/request.d.ts +0 -52
- package/dist/unpkg/dev-deprecated/declarations/store/-private/cache-handler/handler.d.ts +0 -56
- package/dist/unpkg/dev-deprecated/declarations/store/-private/cache-handler/types.d.ts +0 -98
- package/dist/unpkg/dev-deprecated/declarations/store/-private/cache-handler/utils.d.ts +0 -31
- package/dist/unpkg/dev-deprecated/declarations/store/-private/caches/instance-cache.d.ts +0 -58
- package/dist/unpkg/dev-deprecated/declarations/store/-private/caches/resource-utils.d.ts +0 -9
- package/dist/unpkg/dev-deprecated/declarations/store/-private/debug/utils.d.ts +0 -7
- package/dist/unpkg/dev-deprecated/declarations/store/-private/default-cache-policy.d.ts +0 -387
- package/dist/unpkg/dev-deprecated/declarations/store/-private/managers/cache-capabilities-manager.d.ts +0 -34
- package/dist/unpkg/dev-deprecated/declarations/store/-private/managers/cache-key-manager.d.ts +0 -304
- package/dist/unpkg/dev-deprecated/declarations/store/-private/managers/cache-manager.d.ts +0 -380
- package/dist/unpkg/dev-deprecated/declarations/store/-private/managers/notification-manager.d.ts +0 -83
- package/dist/unpkg/dev-deprecated/declarations/store/-private/managers/record-array-manager.d.ts +0 -100
- package/dist/unpkg/dev-deprecated/declarations/store/-private/network/request-cache.d.ts +0 -103
- package/dist/unpkg/dev-deprecated/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +0 -24
- package/dist/unpkg/dev-deprecated/declarations/store/-private/new-core-tmp/promise-state.d.ts +0 -264
- package/dist/unpkg/dev-deprecated/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +0 -138
- package/dist/unpkg/dev-deprecated/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +0 -154
- package/dist/unpkg/dev-deprecated/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +0 -56
- package/dist/unpkg/dev-deprecated/declarations/store/-private/new-core-tmp/request-state.d.ts +0 -372
- package/dist/unpkg/dev-deprecated/declarations/store/-private/new-core-tmp/request-subscription.d.ts +0 -177
- package/dist/unpkg/dev-deprecated/declarations/store/-private/record-arrays/-utils.d.ts +0 -80
- package/dist/unpkg/dev-deprecated/declarations/store/-private/record-arrays/legacy-live-array.d.ts +0 -81
- package/dist/unpkg/dev-deprecated/declarations/store/-private/record-arrays/legacy-many-array.d.ts +0 -133
- package/dist/unpkg/dev-deprecated/declarations/store/-private/record-arrays/legacy-query.d.ts +0 -81
- package/dist/unpkg/dev-deprecated/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +0 -3
- package/dist/unpkg/dev-deprecated/declarations/store/-private/record-arrays/resource-array.d.ts +0 -67
- package/dist/unpkg/dev-deprecated/declarations/store/-private/store-service.d.ts +0 -874
- package/dist/unpkg/dev-deprecated/declarations/store/-private/utils/coerce-id.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/store/-private/utils/construct-resource.d.ts +0 -6
- package/dist/unpkg/dev-deprecated/declarations/store/-private/utils/is-non-empty-string.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/store/-private/utils/normalize-model-name.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/store/-private/utils/uuid-polyfill.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/store/-private.d.ts +0 -29
- package/dist/unpkg/dev-deprecated/declarations/store/-types/q/cache-capabilities-manager.d.ts +0 -90
- package/dist/unpkg/dev-deprecated/declarations/store/-types/q/identifier.d.ts +0 -23
- package/dist/unpkg/dev-deprecated/declarations/store/-types/q/record-instance.d.ts +0 -22
- package/dist/unpkg/dev-deprecated/declarations/store/-types/q/store.d.ts +0 -31
- package/dist/unpkg/dev-deprecated/declarations/store/deprecated/-private.d.ts +0 -223
- package/dist/unpkg/dev-deprecated/declarations/store/deprecated/store.d.ts +0 -784
- package/dist/unpkg/dev-deprecated/declarations/store.d.ts +0 -2
- package/dist/unpkg/dev-deprecated/declarations/types/-private.d.ts +0 -22
- package/dist/unpkg/dev-deprecated/declarations/types/cache/aliases.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/types/cache/change.d.ts +0 -6
- package/dist/unpkg/dev-deprecated/declarations/types/cache/mutations.d.ts +0 -38
- package/dist/unpkg/dev-deprecated/declarations/types/cache/operations.d.ts +0 -168
- package/dist/unpkg/dev-deprecated/declarations/types/cache/relationship.d.ts +0 -13
- package/dist/unpkg/dev-deprecated/declarations/types/cache.d.ts +0 -429
- package/dist/unpkg/dev-deprecated/declarations/types/graph.d.ts +0 -47
- package/dist/unpkg/dev-deprecated/declarations/types/identifier.d.ts +0 -86
- package/dist/unpkg/dev-deprecated/declarations/types/json/raw.d.ts +0 -6
- package/dist/unpkg/dev-deprecated/declarations/types/params.d.ts +0 -8
- package/dist/unpkg/dev-deprecated/declarations/types/record.d.ts +0 -269
- package/dist/unpkg/dev-deprecated/declarations/types/request.d.ts +0 -367
- package/dist/unpkg/dev-deprecated/declarations/types/runtime.d.ts +0 -14
- package/dist/unpkg/dev-deprecated/declarations/types/schema/concepts.d.ts +0 -23
- package/dist/unpkg/dev-deprecated/declarations/types/schema/fields.d.ts +0 -2200
- package/dist/unpkg/dev-deprecated/declarations/types/schema/fields.type-test.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/types/schema/schema-service.d.ts +0 -380
- package/dist/unpkg/dev-deprecated/declarations/types/spec/document.d.ts +0 -67
- package/dist/unpkg/dev-deprecated/declarations/types/spec/error.d.ts +0 -18
- package/dist/unpkg/dev-deprecated/declarations/types/spec/json-api-raw.d.ts +0 -139
- package/dist/unpkg/dev-deprecated/declarations/types/symbols.d.ts +0 -78
- package/dist/unpkg/dev-deprecated/declarations/types/utils.d.ts +0 -5
- package/dist/unpkg/dev-deprecated/declarations/types.d.ts +0 -11
- package/dist/unpkg/dev-deprecated/declarations/utils/string.d.ts +0 -47
- package/dist/unpkg/dev-deprecated/default-cache-policy-D7_u4YRH.js +0 -572
- package/dist/unpkg/prod/declarations/build-config/babel-macros.d.ts +0 -1
- package/dist/unpkg/prod/declarations/build-config/canary-features.d.ts +0 -1
- package/dist/unpkg/prod/declarations/build-config/debugging.d.ts +0 -1
- package/dist/unpkg/prod/declarations/build-config/deprecations.d.ts +0 -1
- package/dist/unpkg/prod/declarations/build-config/env.d.ts +0 -1
- package/dist/unpkg/prod/declarations/build-config/macros.d.ts +0 -1
- package/dist/unpkg/prod/declarations/build-config.d.ts +0 -18
- package/dist/unpkg/prod/declarations/configure.d.ts +0 -7
- package/dist/unpkg/prod/declarations/graph/-private/-diff.d.ts +0 -19
- package/dist/unpkg/prod/declarations/graph/-private/-edge-definition.d.ts +0 -149
- package/dist/unpkg/prod/declarations/graph/-private/-state.d.ts +0 -9
- package/dist/unpkg/prod/declarations/graph/-private/-utils.d.ts +0 -25
- package/dist/unpkg/prod/declarations/graph/-private/coerce-id.d.ts +0 -4
- package/dist/unpkg/prod/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +0 -6
- package/dist/unpkg/prod/declarations/graph/-private/edges/collection.d.ts +0 -39
- package/dist/unpkg/prod/declarations/graph/-private/edges/implicit.d.ts +0 -43
- package/dist/unpkg/prod/declarations/graph/-private/edges/resource.d.ts +0 -23
- package/dist/unpkg/prod/declarations/graph/-private/graph.d.ts +0 -56
- package/dist/unpkg/prod/declarations/graph/-private/normalize-link.d.ts +0 -2
- package/dist/unpkg/prod/declarations/graph/-private/operations/add-to-related-records.d.ts +0 -4
- package/dist/unpkg/prod/declarations/graph/-private/operations/merge-identifier.d.ts +0 -3
- package/dist/unpkg/prod/declarations/graph/-private/operations/remove-from-related-records.d.ts +0 -4
- package/dist/unpkg/prod/declarations/graph/-private/operations/replace-related-record.d.ts +0 -3
- package/dist/unpkg/prod/declarations/graph/-private/operations/replace-related-records.d.ts +0 -7
- package/dist/unpkg/prod/declarations/graph/-private/operations/update-relationship.d.ts +0 -9
- package/dist/unpkg/prod/declarations/graph/-private.d.ts +0 -13
- package/dist/unpkg/prod/declarations/index.d.ts +0 -100
- package/dist/unpkg/prod/declarations/reactive/-private/default-mode.d.ts +0 -73
- package/dist/unpkg/prod/declarations/reactive/-private/document.d.ts +0 -142
- package/dist/unpkg/prod/declarations/reactive/-private/fields/extension.d.ts +0 -8
- package/dist/unpkg/prod/declarations/reactive/-private/fields/get-field-key.d.ts +0 -8
- package/dist/unpkg/prod/declarations/reactive/-private/fields/managed-array.d.ts +0 -18
- package/dist/unpkg/prod/declarations/reactive/-private/fields/managed-object.d.ts +0 -17
- package/dist/unpkg/prod/declarations/reactive/-private/fields/many-array-manager.d.ts +0 -19
- package/dist/unpkg/prod/declarations/reactive/-private/hooks.d.ts +0 -5
- package/dist/unpkg/prod/declarations/reactive/-private/kind/alias-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/array-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/attribute-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/belongs-to-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/collection-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/derived-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/generic-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/has-many-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/hash-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/identity-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/local-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/object-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/resource-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/schema-array-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/kind/schema-object-field.d.ts +0 -4
- package/dist/unpkg/prod/declarations/reactive/-private/record.d.ts +0 -83
- package/dist/unpkg/prod/declarations/reactive/-private/schema.d.ts +0 -326
- package/dist/unpkg/prod/declarations/reactive/-private/symbols.d.ts +0 -5
- package/dist/unpkg/prod/declarations/reactive/-private.d.ts +0 -2
- package/dist/unpkg/prod/declarations/reactive.d.ts +0 -287
- package/dist/unpkg/prod/declarations/request/-private/context.d.ts +0 -39
- package/dist/unpkg/prod/declarations/request/-private/debug.d.ts +0 -4
- package/dist/unpkg/prod/declarations/request/-private/fetch.d.ts +0 -33
- package/dist/unpkg/prod/declarations/request/-private/future.d.ts +0 -7
- package/dist/unpkg/prod/declarations/request/-private/manager.d.ts +0 -158
- package/dist/unpkg/prod/declarations/request/-private/promise-cache.d.ts +0 -28
- package/dist/unpkg/prod/declarations/request/-private/types.d.ts +0 -234
- package/dist/unpkg/prod/declarations/request/-private/utils.d.ts +0 -57
- package/dist/unpkg/prod/declarations/request.d.ts +0 -52
- package/dist/unpkg/prod/declarations/store/-private/cache-handler/handler.d.ts +0 -56
- package/dist/unpkg/prod/declarations/store/-private/cache-handler/types.d.ts +0 -98
- package/dist/unpkg/prod/declarations/store/-private/cache-handler/utils.d.ts +0 -31
- package/dist/unpkg/prod/declarations/store/-private/caches/instance-cache.d.ts +0 -58
- package/dist/unpkg/prod/declarations/store/-private/caches/resource-utils.d.ts +0 -9
- package/dist/unpkg/prod/declarations/store/-private/debug/utils.d.ts +0 -7
- package/dist/unpkg/prod/declarations/store/-private/default-cache-policy.d.ts +0 -387
- package/dist/unpkg/prod/declarations/store/-private/managers/cache-capabilities-manager.d.ts +0 -34
- package/dist/unpkg/prod/declarations/store/-private/managers/cache-key-manager.d.ts +0 -304
- package/dist/unpkg/prod/declarations/store/-private/managers/cache-manager.d.ts +0 -380
- package/dist/unpkg/prod/declarations/store/-private/managers/notification-manager.d.ts +0 -83
- package/dist/unpkg/prod/declarations/store/-private/managers/record-array-manager.d.ts +0 -100
- package/dist/unpkg/prod/declarations/store/-private/network/request-cache.d.ts +0 -103
- package/dist/unpkg/prod/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +0 -24
- package/dist/unpkg/prod/declarations/store/-private/new-core-tmp/promise-state.d.ts +0 -264
- package/dist/unpkg/prod/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +0 -138
- package/dist/unpkg/prod/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +0 -154
- package/dist/unpkg/prod/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +0 -56
- package/dist/unpkg/prod/declarations/store/-private/new-core-tmp/request-state.d.ts +0 -372
- package/dist/unpkg/prod/declarations/store/-private/new-core-tmp/request-subscription.d.ts +0 -177
- package/dist/unpkg/prod/declarations/store/-private/record-arrays/-utils.d.ts +0 -80
- package/dist/unpkg/prod/declarations/store/-private/record-arrays/legacy-live-array.d.ts +0 -81
- package/dist/unpkg/prod/declarations/store/-private/record-arrays/legacy-many-array.d.ts +0 -133
- package/dist/unpkg/prod/declarations/store/-private/record-arrays/legacy-query.d.ts +0 -81
- package/dist/unpkg/prod/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +0 -3
- package/dist/unpkg/prod/declarations/store/-private/record-arrays/resource-array.d.ts +0 -67
- package/dist/unpkg/prod/declarations/store/-private/store-service.d.ts +0 -874
- package/dist/unpkg/prod/declarations/store/-private/utils/coerce-id.d.ts +0 -4
- package/dist/unpkg/prod/declarations/store/-private/utils/construct-resource.d.ts +0 -6
- package/dist/unpkg/prod/declarations/store/-private/utils/is-non-empty-string.d.ts +0 -1
- package/dist/unpkg/prod/declarations/store/-private/utils/normalize-model-name.d.ts +0 -1
- package/dist/unpkg/prod/declarations/store/-private/utils/uuid-polyfill.d.ts +0 -1
- package/dist/unpkg/prod/declarations/store/-private.d.ts +0 -29
- package/dist/unpkg/prod/declarations/store/-types/q/cache-capabilities-manager.d.ts +0 -90
- package/dist/unpkg/prod/declarations/store/-types/q/identifier.d.ts +0 -23
- package/dist/unpkg/prod/declarations/store/-types/q/record-instance.d.ts +0 -22
- package/dist/unpkg/prod/declarations/store/-types/q/store.d.ts +0 -31
- package/dist/unpkg/prod/declarations/store/deprecated/-private.d.ts +0 -223
- package/dist/unpkg/prod/declarations/store/deprecated/store.d.ts +0 -784
- package/dist/unpkg/prod/declarations/store.d.ts +0 -2
- package/dist/unpkg/prod/declarations/types/-private.d.ts +0 -22
- package/dist/unpkg/prod/declarations/types/cache/aliases.d.ts +0 -1
- package/dist/unpkg/prod/declarations/types/cache/change.d.ts +0 -6
- package/dist/unpkg/prod/declarations/types/cache/mutations.d.ts +0 -38
- package/dist/unpkg/prod/declarations/types/cache/operations.d.ts +0 -168
- package/dist/unpkg/prod/declarations/types/cache/relationship.d.ts +0 -13
- package/dist/unpkg/prod/declarations/types/cache.d.ts +0 -429
- package/dist/unpkg/prod/declarations/types/graph.d.ts +0 -47
- package/dist/unpkg/prod/declarations/types/identifier.d.ts +0 -86
- package/dist/unpkg/prod/declarations/types/json/raw.d.ts +0 -6
- package/dist/unpkg/prod/declarations/types/params.d.ts +0 -8
- package/dist/unpkg/prod/declarations/types/record.d.ts +0 -269
- package/dist/unpkg/prod/declarations/types/request.d.ts +0 -367
- package/dist/unpkg/prod/declarations/types/runtime.d.ts +0 -14
- package/dist/unpkg/prod/declarations/types/schema/concepts.d.ts +0 -23
- package/dist/unpkg/prod/declarations/types/schema/fields.d.ts +0 -2200
- package/dist/unpkg/prod/declarations/types/schema/fields.type-test.d.ts +0 -1
- package/dist/unpkg/prod/declarations/types/schema/schema-service.d.ts +0 -380
- package/dist/unpkg/prod/declarations/types/spec/document.d.ts +0 -67
- package/dist/unpkg/prod/declarations/types/spec/error.d.ts +0 -18
- package/dist/unpkg/prod/declarations/types/spec/json-api-raw.d.ts +0 -139
- package/dist/unpkg/prod/declarations/types/symbols.d.ts +0 -78
- package/dist/unpkg/prod/declarations/types/utils.d.ts +0 -5
- package/dist/unpkg/prod/declarations/types.d.ts +0 -11
- package/dist/unpkg/prod/declarations/utils/string.d.ts +0 -47
- package/dist/unpkg/prod/default-cache-policy-D7_u4YRH.js +0 -572
- package/dist/unpkg/prod/index-D4si_DxB.js +0 -11746
- package/dist/unpkg/prod/request-oqoLC9rz.js +0 -725
- package/dist/unpkg/prod-deprecated/declarations/build-config/babel-macros.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/build-config/canary-features.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/build-config/debugging.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/build-config/deprecations.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/build-config/env.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/build-config/macros.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/build-config.d.ts +0 -18
- package/dist/unpkg/prod-deprecated/declarations/configure.d.ts +0 -7
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/-diff.d.ts +0 -19
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/-edge-definition.d.ts +0 -149
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/-state.d.ts +0 -9
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/-utils.d.ts +0 -25
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/coerce-id.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +0 -6
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/edges/collection.d.ts +0 -39
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/edges/implicit.d.ts +0 -43
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/edges/resource.d.ts +0 -23
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/graph.d.ts +0 -56
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/normalize-link.d.ts +0 -2
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/operations/add-to-related-records.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/operations/merge-identifier.d.ts +0 -3
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/operations/remove-from-related-records.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/operations/replace-related-record.d.ts +0 -3
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/operations/replace-related-records.d.ts +0 -7
- package/dist/unpkg/prod-deprecated/declarations/graph/-private/operations/update-relationship.d.ts +0 -9
- package/dist/unpkg/prod-deprecated/declarations/graph/-private.d.ts +0 -13
- package/dist/unpkg/prod-deprecated/declarations/index.d.ts +0 -100
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/default-mode.d.ts +0 -73
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/document.d.ts +0 -142
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/fields/extension.d.ts +0 -8
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/fields/get-field-key.d.ts +0 -8
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/fields/managed-array.d.ts +0 -18
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/fields/managed-object.d.ts +0 -17
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/fields/many-array-manager.d.ts +0 -19
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/hooks.d.ts +0 -5
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/alias-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/array-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/attribute-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/belongs-to-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/collection-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/derived-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/generic-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/has-many-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/hash-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/identity-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/local-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/object-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/resource-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/schema-array-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/kind/schema-object-field.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/record.d.ts +0 -83
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/schema.d.ts +0 -326
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private/symbols.d.ts +0 -5
- package/dist/unpkg/prod-deprecated/declarations/reactive/-private.d.ts +0 -2
- package/dist/unpkg/prod-deprecated/declarations/reactive.d.ts +0 -287
- package/dist/unpkg/prod-deprecated/declarations/request/-private/context.d.ts +0 -39
- package/dist/unpkg/prod-deprecated/declarations/request/-private/debug.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/request/-private/fetch.d.ts +0 -33
- package/dist/unpkg/prod-deprecated/declarations/request/-private/future.d.ts +0 -7
- package/dist/unpkg/prod-deprecated/declarations/request/-private/manager.d.ts +0 -158
- package/dist/unpkg/prod-deprecated/declarations/request/-private/promise-cache.d.ts +0 -28
- package/dist/unpkg/prod-deprecated/declarations/request/-private/types.d.ts +0 -234
- package/dist/unpkg/prod-deprecated/declarations/request/-private/utils.d.ts +0 -57
- package/dist/unpkg/prod-deprecated/declarations/request.d.ts +0 -52
- package/dist/unpkg/prod-deprecated/declarations/store/-private/cache-handler/handler.d.ts +0 -56
- package/dist/unpkg/prod-deprecated/declarations/store/-private/cache-handler/types.d.ts +0 -98
- package/dist/unpkg/prod-deprecated/declarations/store/-private/cache-handler/utils.d.ts +0 -31
- package/dist/unpkg/prod-deprecated/declarations/store/-private/caches/instance-cache.d.ts +0 -58
- package/dist/unpkg/prod-deprecated/declarations/store/-private/caches/resource-utils.d.ts +0 -9
- package/dist/unpkg/prod-deprecated/declarations/store/-private/debug/utils.d.ts +0 -7
- package/dist/unpkg/prod-deprecated/declarations/store/-private/default-cache-policy.d.ts +0 -387
- package/dist/unpkg/prod-deprecated/declarations/store/-private/managers/cache-capabilities-manager.d.ts +0 -34
- package/dist/unpkg/prod-deprecated/declarations/store/-private/managers/cache-key-manager.d.ts +0 -304
- package/dist/unpkg/prod-deprecated/declarations/store/-private/managers/cache-manager.d.ts +0 -380
- package/dist/unpkg/prod-deprecated/declarations/store/-private/managers/notification-manager.d.ts +0 -83
- package/dist/unpkg/prod-deprecated/declarations/store/-private/managers/record-array-manager.d.ts +0 -100
- package/dist/unpkg/prod-deprecated/declarations/store/-private/network/request-cache.d.ts +0 -103
- package/dist/unpkg/prod-deprecated/declarations/store/-private/new-core-tmp/expensive-subscription.d.ts +0 -24
- package/dist/unpkg/prod-deprecated/declarations/store/-private/new-core-tmp/promise-state.d.ts +0 -264
- package/dist/unpkg/prod-deprecated/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +0 -138
- package/dist/unpkg/prod-deprecated/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +0 -154
- package/dist/unpkg/prod-deprecated/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +0 -56
- package/dist/unpkg/prod-deprecated/declarations/store/-private/new-core-tmp/request-state.d.ts +0 -372
- package/dist/unpkg/prod-deprecated/declarations/store/-private/new-core-tmp/request-subscription.d.ts +0 -177
- package/dist/unpkg/prod-deprecated/declarations/store/-private/record-arrays/-utils.d.ts +0 -80
- package/dist/unpkg/prod-deprecated/declarations/store/-private/record-arrays/legacy-live-array.d.ts +0 -81
- package/dist/unpkg/prod-deprecated/declarations/store/-private/record-arrays/legacy-many-array.d.ts +0 -133
- package/dist/unpkg/prod-deprecated/declarations/store/-private/record-arrays/legacy-query.d.ts +0 -81
- package/dist/unpkg/prod-deprecated/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +0 -3
- package/dist/unpkg/prod-deprecated/declarations/store/-private/record-arrays/resource-array.d.ts +0 -67
- package/dist/unpkg/prod-deprecated/declarations/store/-private/store-service.d.ts +0 -874
- package/dist/unpkg/prod-deprecated/declarations/store/-private/utils/coerce-id.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/store/-private/utils/construct-resource.d.ts +0 -6
- package/dist/unpkg/prod-deprecated/declarations/store/-private/utils/is-non-empty-string.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/store/-private/utils/normalize-model-name.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/store/-private/utils/uuid-polyfill.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/store/-private.d.ts +0 -29
- package/dist/unpkg/prod-deprecated/declarations/store/-types/q/cache-capabilities-manager.d.ts +0 -90
- package/dist/unpkg/prod-deprecated/declarations/store/-types/q/identifier.d.ts +0 -23
- package/dist/unpkg/prod-deprecated/declarations/store/-types/q/record-instance.d.ts +0 -22
- package/dist/unpkg/prod-deprecated/declarations/store/-types/q/store.d.ts +0 -31
- package/dist/unpkg/prod-deprecated/declarations/store/deprecated/-private.d.ts +0 -223
- package/dist/unpkg/prod-deprecated/declarations/store/deprecated/store.d.ts +0 -784
- package/dist/unpkg/prod-deprecated/declarations/store.d.ts +0 -2
- package/dist/unpkg/prod-deprecated/declarations/types/-private.d.ts +0 -22
- package/dist/unpkg/prod-deprecated/declarations/types/cache/aliases.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/types/cache/change.d.ts +0 -6
- package/dist/unpkg/prod-deprecated/declarations/types/cache/mutations.d.ts +0 -38
- package/dist/unpkg/prod-deprecated/declarations/types/cache/operations.d.ts +0 -168
- package/dist/unpkg/prod-deprecated/declarations/types/cache/relationship.d.ts +0 -13
- package/dist/unpkg/prod-deprecated/declarations/types/cache.d.ts +0 -429
- package/dist/unpkg/prod-deprecated/declarations/types/graph.d.ts +0 -47
- package/dist/unpkg/prod-deprecated/declarations/types/identifier.d.ts +0 -86
- package/dist/unpkg/prod-deprecated/declarations/types/json/raw.d.ts +0 -6
- package/dist/unpkg/prod-deprecated/declarations/types/params.d.ts +0 -8
- package/dist/unpkg/prod-deprecated/declarations/types/record.d.ts +0 -269
- package/dist/unpkg/prod-deprecated/declarations/types/request.d.ts +0 -367
- package/dist/unpkg/prod-deprecated/declarations/types/runtime.d.ts +0 -14
- package/dist/unpkg/prod-deprecated/declarations/types/schema/concepts.d.ts +0 -23
- package/dist/unpkg/prod-deprecated/declarations/types/schema/fields.d.ts +0 -2200
- package/dist/unpkg/prod-deprecated/declarations/types/schema/fields.type-test.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/types/schema/schema-service.d.ts +0 -380
- package/dist/unpkg/prod-deprecated/declarations/types/spec/document.d.ts +0 -67
- package/dist/unpkg/prod-deprecated/declarations/types/spec/error.d.ts +0 -18
- package/dist/unpkg/prod-deprecated/declarations/types/spec/json-api-raw.d.ts +0 -139
- package/dist/unpkg/prod-deprecated/declarations/types/symbols.d.ts +0 -78
- package/dist/unpkg/prod-deprecated/declarations/types/utils.d.ts +0 -5
- package/dist/unpkg/prod-deprecated/declarations/types.d.ts +0 -11
- package/dist/unpkg/prod-deprecated/declarations/utils/string.d.ts +0 -47
- package/dist/unpkg/prod-deprecated/default-cache-policy-D7_u4YRH.js +0 -572
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { deprecate, warn } from '@ember/debug';
|
|
2
1
|
import { EnableHydration, SkipCache, STRUCTURED } from './types/request.js';
|
|
3
|
-
import {
|
|
4
|
-
import { D as Destroy, C as Context, S as SOURCE, a as Checkout, b as Commit } from "./symbols-sql1_mdx.js";
|
|
2
|
+
import { D as Destroy, a as Context, S as SOURCE, C as Checkout, b as Commit } from "./-private-3C1OkYtZ.js";
|
|
5
3
|
import { isResourceSchema } from './types/schema/fields.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { c as createSignal, a as consumeSignal, n as notifySignal, b as createMemo, d as willSyncFlushWatchers, A as ARRAY_SIGNAL, O as OBJECT_SIGNAL, w as waitFor } from "./configure-
|
|
4
|
+
import { getOrSetGlobal, setTransient, peekTransient, peekUniversalTransient, setUniversalTransient } from './types/-private.js';
|
|
5
|
+
import { w as withBrand, g as getPromiseResult, s as setPromiseResult, c as cloneResponseProperties, I as IS_CACHE_HANDLER, a as assertValidRequest, e as executeNextHandler, b as getRequestResult, u as upgradePromise, d as clearRequestResult } from "./request-CA9K0gXq.js";
|
|
6
|
+
import { c as createSignal, a as consumeSignal, n as notifySignal, b as createMemo, d as willSyncFlushWatchers, A as ARRAY_SIGNAL, O as OBJECT_SIGNAL, w as waitFor } from "./configure-BC66sfNO.js";
|
|
9
7
|
import { CACHE_OWNER, DEBUG_STALE_CACHE_OWNER, DEBUG_KEY_TYPE, DEBUG_CLIENT_ORIGINATED } from './types/identifier.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { g as getGlobalConfig } from "./runtime-DGG4CvlW.js";
|
|
9
|
+
import { DefaultCachePolicy } from './store.js';
|
|
12
10
|
import { setLogging, getRuntimeConfig } from './types/runtime.js';
|
|
13
11
|
import { RecordStore, Type } from './types/symbols.js';
|
|
14
12
|
const INITIALIZER_PROTO = {
|
|
@@ -98,11 +96,11 @@ function withSignalStore(obj) {
|
|
|
98
96
|
* @private
|
|
99
97
|
*/
|
|
100
98
|
function initializeSignalStore(obj) {
|
|
101
|
-
|
|
99
|
+
(test => {
|
|
102
100
|
if (!test) {
|
|
103
101
|
throw new Error(`Signal store already exists on object`);
|
|
104
102
|
}
|
|
105
|
-
})(!obj[Signals])
|
|
103
|
+
})(!obj[Signals]);
|
|
106
104
|
obj[Signals] = new Map();
|
|
107
105
|
}
|
|
108
106
|
function createInternalSignal(signals, obj, key, initialValue) {
|
|
@@ -124,17 +122,13 @@ function getOrCreateInternalSignal(signals, obj, key, initialValue) {
|
|
|
124
122
|
return signal;
|
|
125
123
|
}
|
|
126
124
|
function createInternalMemo(signals, object, key, fn) {
|
|
127
|
-
|
|
125
|
+
(test => {
|
|
128
126
|
if (!test) {
|
|
129
127
|
throw new Error(`Expected no signal/memo to exist for key "${String(key)}"`);
|
|
130
128
|
}
|
|
131
|
-
})(!peekInternalSignal(signals, key))
|
|
132
|
-
|
|
129
|
+
})(!peekInternalSignal(signals, key));
|
|
130
|
+
{
|
|
133
131
|
return withFrame(signals, object, key, fn);
|
|
134
|
-
} else {
|
|
135
|
-
const memo = createMemo(object, key, fn);
|
|
136
|
-
signals.set(key, memo);
|
|
137
|
-
return memo;
|
|
138
132
|
}
|
|
139
133
|
}
|
|
140
134
|
function peekInternalSignal(signals, key) {
|
|
@@ -187,7 +181,7 @@ function isMemo(obj) {
|
|
|
187
181
|
// @ts-expect-error
|
|
188
182
|
return typeof obj === 'function' && obj.signals instanceof Set;
|
|
189
183
|
}
|
|
190
|
-
|
|
184
|
+
{
|
|
191
185
|
// @ts-expect-error adding to global API
|
|
192
186
|
globalThis.debugWarpDriveSignals = (obj, key) => {
|
|
193
187
|
const signals = obj[Signals];
|
|
@@ -308,6 +302,14 @@ function printMemo(memo, key, lines = [], depth = 0) {
|
|
|
308
302
|
}
|
|
309
303
|
return lines;
|
|
310
304
|
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Creates a signal for the key/object pairing and subscribes to the signal.
|
|
308
|
+
*
|
|
309
|
+
* Use when you need to ensure a signal exists and is subscribed to.
|
|
310
|
+
*
|
|
311
|
+
* @private
|
|
312
|
+
*/
|
|
311
313
|
function entangleSignal(signals, obj, key, initialValue) {
|
|
312
314
|
let internalSignal = peekInternalSignal(signals, key);
|
|
313
315
|
if (!internalSignal) {
|
|
@@ -375,16 +377,16 @@ function defineNonEnumerableSignal(obj, key, v) {
|
|
|
375
377
|
*/
|
|
376
378
|
function signal(target, key, descriptor) {
|
|
377
379
|
// Error on `@signal()`, `@signal(...args)``
|
|
378
|
-
|
|
380
|
+
(test => {
|
|
379
381
|
if (!test) {
|
|
380
382
|
throw new Error('You attempted to use @signal(), which is not necessary nor supported. Remove the parentheses and you will be good to go!');
|
|
381
383
|
}
|
|
382
|
-
})(target !== undefined)
|
|
383
|
-
|
|
384
|
+
})(target !== undefined);
|
|
385
|
+
(test => {
|
|
384
386
|
if (!test) {
|
|
385
387
|
throw new Error(`You attempted to use @signal on with ${arguments.length > 1 ? 'arguments' : 'an argument'} ( @signal(${Array.from(arguments).map(d => `'${d}'`).join(', ')}) ), which is not supported. Dependencies are automatically tracked, so you can just use ${'`@signal`'}`);
|
|
386
388
|
}
|
|
387
|
-
})(typeof target === 'object' && typeof key === 'string' && typeof descriptor === 'object' && arguments.length === 3)
|
|
389
|
+
})(typeof target === 'object' && typeof key === 'string' && typeof descriptor === 'object' && arguments.length === 3);
|
|
388
390
|
return createSignalDescriptor(key, descriptor.initializer ? makeInitializer(descriptor.initializer) : null);
|
|
389
391
|
}
|
|
390
392
|
|
|
@@ -393,21 +395,21 @@ function signal(target, key, descriptor) {
|
|
|
393
395
|
*/
|
|
394
396
|
function memoized(target, key, descriptor) {
|
|
395
397
|
// Error on `@memoized()`, `@memoized(...args)`, and `@memoized propName = value;`
|
|
396
|
-
|
|
398
|
+
(test => {
|
|
397
399
|
if (!test) {
|
|
398
400
|
throw new Error('You attempted to use @memoized(), which is not necessary nor supported. Remove the parentheses and you will be good to go!');
|
|
399
401
|
}
|
|
400
|
-
})(target !== undefined)
|
|
401
|
-
|
|
402
|
+
})(target !== undefined);
|
|
403
|
+
(test => {
|
|
402
404
|
if (!test) {
|
|
403
405
|
throw new Error(`You attempted to use @memoized on with ${arguments.length > 1 ? 'arguments' : 'an argument'} ( @memoized(${Array.from(arguments).map(d => `'${d}'`).join(', ')}), which is not supported. Dependencies are automatically tracked, so you can just use ${'`@memoized`'}`);
|
|
404
406
|
}
|
|
405
|
-
})(typeof target === 'object' && typeof key === 'string' && typeof descriptor === 'object' && arguments.length === 3)
|
|
406
|
-
|
|
407
|
+
})(typeof target === 'object' && typeof key === 'string' && typeof descriptor === 'object' && arguments.length === 3);
|
|
408
|
+
(test => {
|
|
407
409
|
if (!test) {
|
|
408
410
|
throw new Error(`The @memoized decorator must be applied to getters. '${key}' is not a getter.`);
|
|
409
411
|
}
|
|
410
|
-
})(typeof descriptor.get === 'function')
|
|
412
|
+
})(typeof descriptor.get === 'function');
|
|
411
413
|
|
|
412
414
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
413
415
|
const getter = descriptor.get;
|
|
@@ -512,11 +514,11 @@ const ReactiveDocumentProto = {
|
|
|
512
514
|
url: '',
|
|
513
515
|
method: 'GET'
|
|
514
516
|
})) {
|
|
515
|
-
|
|
517
|
+
(test => {
|
|
516
518
|
if (!test) {
|
|
517
519
|
throw new Error(`No self or related link`);
|
|
518
520
|
}
|
|
519
|
-
})(this.links?.related || this.links?.self)
|
|
521
|
+
})(this.links?.related || this.links?.self);
|
|
520
522
|
options.cacheOptions = options.cacheOptions || {};
|
|
521
523
|
options.cacheOptions.key = this.identifier?.lid;
|
|
522
524
|
return this._request(this.links.related ? 'related' : 'self', options);
|
|
@@ -551,11 +553,11 @@ const ReactiveDocumentProto = {
|
|
|
551
553
|
return data;
|
|
552
554
|
},
|
|
553
555
|
[Destroy]() {
|
|
554
|
-
|
|
556
|
+
(test => {
|
|
555
557
|
if (!test) {
|
|
556
558
|
throw new Error(`Cannot destroy a ReactiveDocument which has already been destroyed`);
|
|
557
559
|
}
|
|
558
|
-
})(this._store)
|
|
560
|
+
})(this._store);
|
|
559
561
|
if (this._subscription) {
|
|
560
562
|
this._store.notifications.unsubscribe(this._subscription);
|
|
561
563
|
// @ts-expect-error
|
|
@@ -580,11 +582,11 @@ defineGate(ReactiveDocumentProto, 'errors', {
|
|
|
580
582
|
return;
|
|
581
583
|
}
|
|
582
584
|
const doc = this._store.cache.peek(identifier);
|
|
583
|
-
|
|
585
|
+
(test => {
|
|
584
586
|
if (!test) {
|
|
585
587
|
throw new Error(`No cache data was found for the document '${identifier.lid}'`);
|
|
586
588
|
}
|
|
587
|
-
})(doc)
|
|
589
|
+
})(doc);
|
|
588
590
|
return 'errors' in doc ? doc.errors : undefined;
|
|
589
591
|
}
|
|
590
592
|
});
|
|
@@ -595,11 +597,11 @@ defineGate(ReactiveDocumentProto, 'data', {
|
|
|
595
597
|
_localCache
|
|
596
598
|
} = this;
|
|
597
599
|
const doc = identifier ? this._store.cache.peek(identifier) : _localCache.document;
|
|
598
|
-
|
|
600
|
+
(test => {
|
|
599
601
|
if (!test) {
|
|
600
602
|
throw new Error(`No cache data was found for the document '${identifier?.lid ?? '<uncached document>'}'`);
|
|
601
603
|
}
|
|
602
|
-
})(doc)
|
|
604
|
+
})(doc);
|
|
603
605
|
const data = 'data' in doc ? doc.data : undefined;
|
|
604
606
|
if (Array.isArray(data)) {
|
|
605
607
|
return identifier ? this._store.recordArrayManager.getCollection({
|
|
@@ -624,11 +626,11 @@ defineGate(ReactiveDocumentProto, 'links', {
|
|
|
624
626
|
return this._localCache.document.links;
|
|
625
627
|
}
|
|
626
628
|
const data = this._store.cache.peek(identifier);
|
|
627
|
-
|
|
629
|
+
(test => {
|
|
628
630
|
if (!test) {
|
|
629
631
|
throw new Error(`No cache data was found for the document '${identifier.lid}'`);
|
|
630
632
|
}
|
|
631
|
-
})(data)
|
|
633
|
+
})(data);
|
|
632
634
|
return data.links;
|
|
633
635
|
}
|
|
634
636
|
});
|
|
@@ -641,11 +643,11 @@ defineGate(ReactiveDocumentProto, 'meta', {
|
|
|
641
643
|
return this._localCache.document.meta;
|
|
642
644
|
}
|
|
643
645
|
const data = this._store.cache.peek(identifier);
|
|
644
|
-
|
|
646
|
+
(test => {
|
|
645
647
|
if (!test) {
|
|
646
648
|
throw new Error(`No cache data was found for the document '${identifier.lid}'`);
|
|
647
649
|
}
|
|
648
|
-
})(data)
|
|
650
|
+
})(data);
|
|
649
651
|
return data.meta;
|
|
650
652
|
}
|
|
651
653
|
});
|
|
@@ -775,30 +777,19 @@ function hasId(resource) {
|
|
|
775
777
|
function hasType(resource) {
|
|
776
778
|
return hasProp(resource, 'type');
|
|
777
779
|
}
|
|
780
|
+
|
|
781
|
+
// Used by the store to normalize IDs entering the store. Despite the fact
|
|
782
|
+
// that developers may provide IDs as numbers (e.g., `store.findRecord('person', 1)`),
|
|
783
|
+
// it is important that internally we use strings, since IDs may be serialized
|
|
784
|
+
// and lose type information. For example, Ember's router may put a record's
|
|
785
|
+
// ID into the URL, and if we later try to deserialize that URL and find the
|
|
786
|
+
// corresponding record, we will not know if it is a string or a number.
|
|
778
787
|
function coerceId(id) {
|
|
779
|
-
|
|
780
|
-
let normalized;
|
|
781
|
-
if (id === null || id === undefined || id === '') {
|
|
782
|
-
normalized = null;
|
|
783
|
-
} else {
|
|
784
|
-
normalized = String(id);
|
|
785
|
-
}
|
|
786
|
-
deprecate(`The resource id '<${typeof id}> ${String(id)} ' is not normalized. Update your application code to use '${JSON.stringify(normalized)}' instead.`, normalized === id, {
|
|
787
|
-
id: 'ember-data:deprecate-non-strict-id',
|
|
788
|
-
until: '6.0',
|
|
789
|
-
for: 'ember-data',
|
|
790
|
-
since: {
|
|
791
|
-
available: '4.13',
|
|
792
|
-
enabled: '5.3'
|
|
793
|
-
}
|
|
794
|
-
});
|
|
795
|
-
return normalized;
|
|
796
|
-
}
|
|
797
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
788
|
+
(test => {
|
|
798
789
|
if (!test) {
|
|
799
790
|
throw new Error(`Resource IDs must be a non-empty string or null. Received '${String(id)}'.`);
|
|
800
791
|
}
|
|
801
|
-
})(id === null || typeof id === 'string' && id.length > 0)
|
|
792
|
+
})(id === null || typeof id === 'string' && id.length > 0);
|
|
802
793
|
return id;
|
|
803
794
|
}
|
|
804
795
|
function ensureStringId(id) {
|
|
@@ -808,91 +799,34 @@ function ensureStringId(id) {
|
|
|
808
799
|
} else if (typeof id === 'number' && !isNaN(id)) {
|
|
809
800
|
normalized = String(id);
|
|
810
801
|
}
|
|
811
|
-
|
|
802
|
+
(test => {
|
|
812
803
|
if (!test) {
|
|
813
804
|
throw new Error(`Expected id to be a string or number, received ${String(id)}`);
|
|
814
805
|
}
|
|
815
|
-
})(normalized !== null)
|
|
806
|
+
})(normalized !== null);
|
|
816
807
|
return normalized;
|
|
817
808
|
}
|
|
818
809
|
function normalizeModelName(type) {
|
|
819
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_NON_STRICT_TYPES)) {
|
|
820
|
-
const result = dasherize(type);
|
|
821
|
-
deprecate(`The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`, result === type, {
|
|
822
|
-
id: 'ember-data:deprecate-non-strict-types',
|
|
823
|
-
until: '6.0',
|
|
824
|
-
for: 'ember-data',
|
|
825
|
-
since: {
|
|
826
|
-
available: '4.13',
|
|
827
|
-
enabled: '5.3'
|
|
828
|
-
}
|
|
829
|
-
});
|
|
830
|
-
return result;
|
|
831
|
-
}
|
|
832
810
|
return type;
|
|
833
811
|
}
|
|
834
|
-
function installPolyfill() {
|
|
835
|
-
const isFastBoot = typeof FastBoot !== 'undefined';
|
|
836
|
-
const CRYPTO = isFastBoot ? FastBoot.require('crypto') : globalThis.crypto;
|
|
837
|
-
if (!CRYPTO.randomUUID) {
|
|
838
|
-
// we might be able to optimize this by requesting more bytes than we need at a time
|
|
839
|
-
const rng = function () {
|
|
840
|
-
// WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto
|
|
841
|
-
const rnds8 = new Uint8Array(16);
|
|
842
|
-
if (!CRYPTO.getRandomValues && !isFastBoot) {
|
|
843
|
-
throw new Error(`Unable to generate bytes for UUID`);
|
|
844
|
-
}
|
|
845
|
-
return CRYPTO.getRandomValues ? CRYPTO.getRandomValues(rnds8) : CRYPTO.randomFillSync(rnds8);
|
|
846
|
-
};
|
|
847
|
-
|
|
848
|
-
/*
|
|
849
|
-
* Convert array of 16 byte values to UUID string format of the form:
|
|
850
|
-
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
851
|
-
*/
|
|
852
|
-
const byteToHex = [];
|
|
853
|
-
for (let i = 0; i < 256; ++i) {
|
|
854
|
-
byteToHex[i] = (i + 0x100).toString(16).substr(1);
|
|
855
|
-
}
|
|
856
|
-
const bytesToUuid = function (buf) {
|
|
857
|
-
const bth = byteToHex;
|
|
858
|
-
// join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
|
|
859
|
-
return [bth[buf[0]], bth[buf[1]], bth[buf[2]], bth[buf[3]], '-', bth[buf[4]], bth[buf[5]], '-', bth[buf[6]], bth[buf[7]], '-', bth[buf[8]], bth[buf[9]], '-', bth[buf[10]], bth[buf[11]], bth[buf[12]], bth[buf[13]], bth[buf[14]], bth[buf[15]]].join('');
|
|
860
|
-
};
|
|
861
|
-
CRYPTO.randomUUID = function uuidv4() {
|
|
862
|
-
const rnds = rng();
|
|
863
|
-
|
|
864
|
-
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
865
|
-
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
866
|
-
rnds[8] = rnds[8] & 0x3f | 0x80;
|
|
867
|
-
return bytesToUuid(rnds);
|
|
868
|
-
};
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
812
|
function isResourceKey(identifier) {
|
|
872
|
-
|
|
813
|
+
{
|
|
873
814
|
return !!identifier && typeof identifier === 'object' && 'type' in identifier && 'id' in identifier && identifier.type !== '@document' && identifier[CACHE_OWNER] !== undefined;
|
|
874
|
-
} else {
|
|
875
|
-
return identifier.type !== '@document' && identifier[CACHE_OWNER] !== undefined;
|
|
876
815
|
}
|
|
877
816
|
}
|
|
878
817
|
function isRequestKey(identifier) {
|
|
879
|
-
|
|
818
|
+
{
|
|
880
819
|
return !!identifier && typeof identifier === 'object' && 'type' in identifier && !('id' in identifier) && identifier.type === '@document' && identifier[CACHE_OWNER] !== undefined;
|
|
881
|
-
} else {
|
|
882
|
-
return identifier.type === '@document' && identifier[CACHE_OWNER] !== undefined;
|
|
883
820
|
}
|
|
884
821
|
}
|
|
885
822
|
const isFastBoot = typeof FastBoot !== 'undefined';
|
|
886
823
|
const _crypto = isFastBoot ? FastBoot.require('crypto') : globalThis.crypto;
|
|
887
|
-
if (macroCondition(getGlobalConfig().WarpDrive.polyfillUUID)) {
|
|
888
|
-
installPolyfill();
|
|
889
|
-
}
|
|
890
824
|
function uuidv4() {
|
|
891
|
-
|
|
825
|
+
(test => {
|
|
892
826
|
if (!test) {
|
|
893
827
|
throw new Error('crypto.randomUUID needs to be avaliable. Some browsers incorrectly disallow it in insecure contexts. You maybe want to enable the polyfill: https://github.com/warp-drive-data/warp-drive#randomuuid-polyfill');
|
|
894
828
|
}
|
|
895
|
-
})(typeof _crypto.randomUUID === 'function')
|
|
829
|
+
})(typeof _crypto.randomUUID === 'function');
|
|
896
830
|
return _crypto.randomUUID();
|
|
897
831
|
}
|
|
898
832
|
function freeze(obj) {
|
|
@@ -1088,11 +1022,11 @@ function updateTypeIdMapping(typeMap, identifier, id) {
|
|
|
1088
1022
|
}
|
|
1089
1023
|
function defaultUpdateMethod(identifier, data, bucket) {
|
|
1090
1024
|
if (bucket === 'record') {
|
|
1091
|
-
|
|
1025
|
+
(test => {
|
|
1092
1026
|
if (!test) {
|
|
1093
1027
|
throw new Error(`Expected identifier to be a ResourceKey`);
|
|
1094
1028
|
}
|
|
1095
|
-
})(isResourceKey(identifier))
|
|
1029
|
+
})(isResourceKey(identifier));
|
|
1096
1030
|
if (!identifier.id && hasId(data)) {
|
|
1097
1031
|
updateTypeIdMapping(NEW_IDENTIFIERS, identifier, data.id);
|
|
1098
1032
|
}
|
|
@@ -1102,11 +1036,11 @@ function defaultKeyInfoMethod(resource, known) {
|
|
|
1102
1036
|
// TODO RFC something to make this configurable
|
|
1103
1037
|
const id = hasId(resource) ? coerceId(resource.id) : null;
|
|
1104
1038
|
const type = hasType(resource) ? normalizeModelName(resource.type) : known ? known.type : null;
|
|
1105
|
-
|
|
1039
|
+
(test => {
|
|
1106
1040
|
if (!test) {
|
|
1107
1041
|
throw new Error(`Expected keyInfoForResource to provide a type for the resource`);
|
|
1108
1042
|
}
|
|
1109
|
-
})(type)
|
|
1043
|
+
})(type);
|
|
1110
1044
|
return {
|
|
1111
1045
|
type,
|
|
1112
1046
|
id
|
|
@@ -1117,11 +1051,11 @@ function defaultGenerationMethod(data, bucket) {
|
|
|
1117
1051
|
if (hasLid(data)) {
|
|
1118
1052
|
return data.lid;
|
|
1119
1053
|
}
|
|
1120
|
-
|
|
1054
|
+
(test => {
|
|
1121
1055
|
if (!test) {
|
|
1122
1056
|
throw new Error(`Cannot generate an identifier for a resource without a type`);
|
|
1123
1057
|
}
|
|
1124
|
-
})(hasType(data))
|
|
1058
|
+
})(hasType(data));
|
|
1125
1059
|
if (hasId(data)) {
|
|
1126
1060
|
const type = normalizeModelName(data.type);
|
|
1127
1061
|
const lid = NEW_IDENTIFIERS.get(type)?.get(data.id);
|
|
@@ -1137,18 +1071,18 @@ function defaultGenerationMethod(data, bucket) {
|
|
|
1137
1071
|
}
|
|
1138
1072
|
return null;
|
|
1139
1073
|
}
|
|
1140
|
-
|
|
1074
|
+
(test => {
|
|
1141
1075
|
{
|
|
1142
1076
|
throw new Error(`Unknown bucket ${bucket}`);
|
|
1143
1077
|
}
|
|
1144
|
-
})()
|
|
1078
|
+
})();
|
|
1145
1079
|
}
|
|
1146
1080
|
function defaultEmptyCallback(...args) {}
|
|
1147
1081
|
function defaultMergeMethod(a, _b, _c) {
|
|
1148
1082
|
return a;
|
|
1149
1083
|
}
|
|
1150
1084
|
let DEBUG_MAP;
|
|
1151
|
-
|
|
1085
|
+
{
|
|
1152
1086
|
DEBUG_MAP = getOrSetGlobal('DEBUG_MAP', new WeakMap());
|
|
1153
1087
|
}
|
|
1154
1088
|
|
|
@@ -1225,21 +1159,20 @@ class CacheKeyManager {
|
|
|
1225
1159
|
|
|
1226
1160
|
/** @internal */
|
|
1227
1161
|
_getRecordIdentifier(resource, shouldGenerate) {
|
|
1228
|
-
|
|
1162
|
+
{
|
|
1229
1163
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1230
1164
|
// eslint-disable-next-line no-console
|
|
1231
1165
|
console.groupCollapsed(`Identifiers: ${shouldGenerate ? 'Generating' : 'Peeking'} Identifier`, resource);
|
|
1232
1166
|
}
|
|
1233
|
-
}
|
|
1234
|
-
// short circuit if we're already the stable version
|
|
1167
|
+
} // short circuit if we're already the stable version
|
|
1235
1168
|
if (isResourceKey(resource)) {
|
|
1236
|
-
|
|
1169
|
+
{
|
|
1237
1170
|
// TODO should we instead just treat this case as a new generation skipping the short circuit?
|
|
1238
1171
|
if (!this._cache.resources.has(resource.lid) || this._cache.resources.get(resource.lid) !== resource) {
|
|
1239
1172
|
throw new Error(`The supplied identifier ${JSON.stringify(resource)} does not belong to this store instance`);
|
|
1240
1173
|
}
|
|
1241
1174
|
}
|
|
1242
|
-
|
|
1175
|
+
{
|
|
1243
1176
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1244
1177
|
// eslint-disable-next-line no-console
|
|
1245
1178
|
console.log(`Identifiers: cache HIT - Stable ${resource.lid}`);
|
|
@@ -1252,7 +1185,7 @@ class CacheKeyManager {
|
|
|
1252
1185
|
|
|
1253
1186
|
// the resource is unknown, ask the application to identify this data for us
|
|
1254
1187
|
const lid = this._generate(resource, 'record');
|
|
1255
|
-
|
|
1188
|
+
{
|
|
1256
1189
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1257
1190
|
// eslint-disable-next-line no-console
|
|
1258
1191
|
console.log(`Identifiers: ${lid ? 'no ' : ''}lid ${lid ? lid + ' ' : ''}determined for resource`, resource);
|
|
@@ -1260,7 +1193,7 @@ class CacheKeyManager {
|
|
|
1260
1193
|
}
|
|
1261
1194
|
let identifier = /*#__NOINLINE__*/getIdentifierFromLid(this._cache, lid, resource);
|
|
1262
1195
|
if (identifier !== null) {
|
|
1263
|
-
|
|
1196
|
+
{
|
|
1264
1197
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1265
1198
|
// eslint-disable-next-line no-console
|
|
1266
1199
|
console.groupEnd();
|
|
@@ -1269,7 +1202,7 @@ class CacheKeyManager {
|
|
|
1269
1202
|
return identifier;
|
|
1270
1203
|
}
|
|
1271
1204
|
if (shouldGenerate === 0) {
|
|
1272
|
-
|
|
1205
|
+
{
|
|
1273
1206
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1274
1207
|
// eslint-disable-next-line no-console
|
|
1275
1208
|
console.groupEnd();
|
|
@@ -1291,7 +1224,7 @@ class CacheKeyManager {
|
|
|
1291
1224
|
identifier = /*#__NOINLINE__*/makeResourceKey(keyInfo, 'record', false);
|
|
1292
1225
|
}
|
|
1293
1226
|
addResourceToCache(this._cache, identifier);
|
|
1294
|
-
|
|
1227
|
+
{
|
|
1295
1228
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1296
1229
|
// eslint-disable-next-line no-console
|
|
1297
1230
|
console.groupEnd();
|
|
@@ -1361,7 +1294,7 @@ class CacheKeyManager {
|
|
|
1361
1294
|
type: '@document',
|
|
1362
1295
|
[CACHE_OWNER]: this._id
|
|
1363
1296
|
};
|
|
1364
|
-
|
|
1297
|
+
{
|
|
1365
1298
|
Object.freeze(identifier);
|
|
1366
1299
|
}
|
|
1367
1300
|
this._cache.documents.set(cacheKey, identifier);
|
|
@@ -1400,7 +1333,7 @@ class CacheKeyManager {
|
|
|
1400
1333
|
}, 'record', true);
|
|
1401
1334
|
|
|
1402
1335
|
// populate our unique table
|
|
1403
|
-
|
|
1336
|
+
{
|
|
1404
1337
|
if (this._cache.resources.has(identifier.lid)) {
|
|
1405
1338
|
throw new Error(`The lid generated for the new record is not unique as it matches an existing identifier`);
|
|
1406
1339
|
}
|
|
@@ -1408,7 +1341,7 @@ class CacheKeyManager {
|
|
|
1408
1341
|
|
|
1409
1342
|
/*#__NOINLINE__*/
|
|
1410
1343
|
addResourceToCache(this._cache, identifier);
|
|
1411
|
-
|
|
1344
|
+
{
|
|
1412
1345
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1413
1346
|
// eslint-disable-next-line no-console
|
|
1414
1347
|
console.log(`Identifiers: created identifier ${String(identifier)} for newly generated resource`, data);
|
|
@@ -1456,7 +1389,7 @@ class CacheKeyManager {
|
|
|
1456
1389
|
if (hadLid) {
|
|
1457
1390
|
data.lid = identifier.lid;
|
|
1458
1391
|
}
|
|
1459
|
-
|
|
1392
|
+
{
|
|
1460
1393
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1461
1394
|
// eslint-disable-next-line no-console
|
|
1462
1395
|
console.log(`Identifiers: merged identifiers ${generatedIdentifier.lid} and ${existingIdentifier.lid} for resource into ${identifier.lid}`, data);
|
|
@@ -1470,23 +1403,23 @@ class CacheKeyManager {
|
|
|
1470
1403
|
|
|
1471
1404
|
// add to our own secondary lookup table
|
|
1472
1405
|
if (id !== newId && newId !== null) {
|
|
1473
|
-
|
|
1406
|
+
{
|
|
1474
1407
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1475
1408
|
// eslint-disable-next-line no-console
|
|
1476
1409
|
console.log(`Identifiers: updated id for identifier ${identifier.lid} from '${String(id)}' to '${String(newId)}' for resource`, data);
|
|
1477
1410
|
}
|
|
1478
1411
|
}
|
|
1479
1412
|
const typeSet = this._cache.resourcesByType[identifier.type];
|
|
1480
|
-
|
|
1413
|
+
(test => {
|
|
1481
1414
|
if (!test) {
|
|
1482
1415
|
throw new Error(`Expected to find a typeSet for ${identifier.type}`);
|
|
1483
1416
|
}
|
|
1484
|
-
})(typeSet)
|
|
1417
|
+
})(typeSet);
|
|
1485
1418
|
typeSet.id.set(newId, identifier);
|
|
1486
1419
|
if (id !== null) {
|
|
1487
1420
|
typeSet.id.delete(id);
|
|
1488
1421
|
}
|
|
1489
|
-
} else
|
|
1422
|
+
} else {
|
|
1490
1423
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1491
1424
|
// eslint-disable-next-line no-console
|
|
1492
1425
|
console.log(`Identifiers: updated identifier ${identifier.lid} resource`, data);
|
|
@@ -1499,11 +1432,11 @@ class CacheKeyManager {
|
|
|
1499
1432
|
* @internal
|
|
1500
1433
|
*/
|
|
1501
1434
|
_mergeRecordIdentifiers(keyInfo, identifier, existingIdentifier, data) {
|
|
1502
|
-
|
|
1435
|
+
(test => {
|
|
1503
1436
|
if (!test) {
|
|
1504
1437
|
throw new Error(`Expected keyInfo to contain an id`);
|
|
1505
1438
|
}
|
|
1506
|
-
})(hasId(keyInfo))
|
|
1439
|
+
})(hasId(keyInfo));
|
|
1507
1440
|
// delegate determining which identifier to keep to the configured MergeMethod
|
|
1508
1441
|
const kept = this._merge(identifier, existingIdentifier, data);
|
|
1509
1442
|
const abandoned = kept === identifier ? existingIdentifier : identifier;
|
|
@@ -1549,11 +1482,11 @@ class CacheKeyManager {
|
|
|
1549
1482
|
forgetRecordIdentifier(identifierObject) {
|
|
1550
1483
|
const identifier = this.getOrCreateRecordIdentifier(identifierObject);
|
|
1551
1484
|
const typeSet = this._cache.resourcesByType[identifier.type];
|
|
1552
|
-
|
|
1485
|
+
(test => {
|
|
1553
1486
|
if (!test) {
|
|
1554
1487
|
throw new Error(`Expected to find a typeSet for ${identifier.type}`);
|
|
1555
1488
|
}
|
|
1556
|
-
})(typeSet)
|
|
1489
|
+
})(typeSet);
|
|
1557
1490
|
if (identifier.id !== null) {
|
|
1558
1491
|
typeSet.id.delete(identifier.id);
|
|
1559
1492
|
}
|
|
@@ -1566,12 +1499,12 @@ class CacheKeyManager {
|
|
|
1566
1499
|
});
|
|
1567
1500
|
this._cache.polymorphicLidBackMap.delete(identifier.lid);
|
|
1568
1501
|
}
|
|
1569
|
-
|
|
1502
|
+
{
|
|
1570
1503
|
identifier[DEBUG_STALE_CACHE_OWNER] = identifier[CACHE_OWNER];
|
|
1571
1504
|
}
|
|
1572
1505
|
identifier[CACHE_OWNER] = undefined;
|
|
1573
1506
|
this._forget(identifier, 'record');
|
|
1574
|
-
|
|
1507
|
+
{
|
|
1575
1508
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1576
1509
|
// eslint-disable-next-line no-console
|
|
1577
1510
|
console.log(`Identifiers: released identifier ${identifierObject.lid}`);
|
|
@@ -1595,7 +1528,7 @@ class CacheKeyManager {
|
|
|
1595
1528
|
*/
|
|
1596
1529
|
|
|
1597
1530
|
function makeResourceKey(recordIdentifier, bucket, clientOriginated) {
|
|
1598
|
-
|
|
1531
|
+
{
|
|
1599
1532
|
// we enforce immutability in dev
|
|
1600
1533
|
// but preserve our ability to do controlled updates to the reference
|
|
1601
1534
|
let wrapper = {
|
|
@@ -1656,10 +1589,9 @@ function makeResourceKey(recordIdentifier, bucket, clientOriginated) {
|
|
|
1656
1589
|
wrapper = freeze(wrapper);
|
|
1657
1590
|
return wrapper;
|
|
1658
1591
|
}
|
|
1659
|
-
return recordIdentifier;
|
|
1660
1592
|
}
|
|
1661
1593
|
function performRecordIdentifierUpdate(identifier, keyInfo, data, updateFn) {
|
|
1662
|
-
|
|
1594
|
+
{
|
|
1663
1595
|
const {
|
|
1664
1596
|
id,
|
|
1665
1597
|
type
|
|
@@ -1677,7 +1609,7 @@ function performRecordIdentifierUpdate(identifier, keyInfo, data, updateFn) {
|
|
|
1677
1609
|
if (id && identifier.id !== null && identifier.id !== id) {
|
|
1678
1610
|
// here we warn and ignore, as this may be a mistake, but we allow the user
|
|
1679
1611
|
// to have multiple cache-keys pointing at a single lid so we cannot error
|
|
1680
|
-
warn(`The 'id' for a ResourceKey should not be updated once it has been set. Attempted to set id for '${wrapper.lid}' to '${id}'.`, false, {
|
|
1612
|
+
console.warn(`The 'id' for a ResourceKey should not be updated once it has been set. Attempted to set id for '${wrapper.lid}' to '${id}'.`, false, {
|
|
1681
1613
|
id: 'ember-data:multiple-ids-for-identifier'
|
|
1682
1614
|
});
|
|
1683
1615
|
}
|
|
@@ -1687,8 +1619,6 @@ function performRecordIdentifierUpdate(identifier, keyInfo, data, updateFn) {
|
|
|
1687
1619
|
throw new Error(`The 'type' for a ResourceKey cannot be updated once it has been set. Attempted to set type for '${wrapper.lid}' to '${type}'.`);
|
|
1688
1620
|
}
|
|
1689
1621
|
updateFn(wrapper, data, 'record');
|
|
1690
|
-
} else {
|
|
1691
|
-
updateFn(identifier, data, 'record');
|
|
1692
1622
|
}
|
|
1693
1623
|
|
|
1694
1624
|
// upgrade the ID, this is a "one time only" ability
|
|
@@ -1734,7 +1664,7 @@ function detectMerge(cache, keyInfo, identifier, data) {
|
|
|
1734
1664
|
}
|
|
1735
1665
|
function getIdentifierFromLid(cache, lid, resource) {
|
|
1736
1666
|
const identifier = cache.resources.get(lid);
|
|
1737
|
-
|
|
1667
|
+
{
|
|
1738
1668
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1739
1669
|
// eslint-disable-next-line no-console
|
|
1740
1670
|
console.log(`Identifiers: cache ${identifier ? 'HIT' : 'MISS'} - Non-Stable ${lid}`, resource);
|
|
@@ -1816,11 +1746,11 @@ class CacheCapabilitiesManager {
|
|
|
1816
1746
|
});
|
|
1817
1747
|
}
|
|
1818
1748
|
notifyChange(identifier, namespace, key) {
|
|
1819
|
-
|
|
1749
|
+
(test => {
|
|
1820
1750
|
if (!test) {
|
|
1821
1751
|
throw new Error(`Expected a stable identifier`);
|
|
1822
1752
|
}
|
|
1823
|
-
})(isResourceKey(identifier) || isRequestKey(identifier))
|
|
1753
|
+
})(isResourceKey(identifier) || isRequestKey(identifier));
|
|
1824
1754
|
|
|
1825
1755
|
// TODO do we still get value from this?
|
|
1826
1756
|
if (namespace === 'relationships' && key) {
|
|
@@ -1835,22 +1765,22 @@ class CacheCapabilitiesManager {
|
|
|
1835
1765
|
return this._store.schema;
|
|
1836
1766
|
}
|
|
1837
1767
|
setRecordId(identifier, id) {
|
|
1838
|
-
|
|
1768
|
+
(test => {
|
|
1839
1769
|
if (!test) {
|
|
1840
1770
|
throw new Error(`Expected a stable identifier`);
|
|
1841
1771
|
}
|
|
1842
|
-
})(isResourceKey(identifier))
|
|
1772
|
+
})(isResourceKey(identifier));
|
|
1843
1773
|
this._store._instanceCache.setRecordId(identifier, id);
|
|
1844
1774
|
}
|
|
1845
1775
|
hasRecord(identifier) {
|
|
1846
1776
|
return Boolean(this._store._instanceCache.peek(identifier));
|
|
1847
1777
|
}
|
|
1848
1778
|
disconnectRecord(identifier) {
|
|
1849
|
-
|
|
1779
|
+
(test => {
|
|
1850
1780
|
if (!test) {
|
|
1851
1781
|
throw new Error(`Expected a stable identifier`);
|
|
1852
1782
|
}
|
|
1853
|
-
})(isResourceKey(identifier))
|
|
1783
|
+
})(isResourceKey(identifier));
|
|
1854
1784
|
this._store._instanceCache.disconnect(identifier);
|
|
1855
1785
|
this._pendingNotifies.delete(identifier);
|
|
1856
1786
|
}
|
|
@@ -1864,12 +1794,6 @@ class CacheCapabilitiesManager {
|
|
|
1864
1794
|
* @private
|
|
1865
1795
|
*/
|
|
1866
1796
|
|
|
1867
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_SCHEMA_SERVICE)) {
|
|
1868
|
-
CacheCapabilitiesManager.prototype.getSchemaDefinitionService = function () {
|
|
1869
|
-
// FIXME add deprecation for this
|
|
1870
|
-
return this.schema;
|
|
1871
|
-
};
|
|
1872
|
-
}
|
|
1873
1797
|
function assertPrivateCapabilities(manager) {}
|
|
1874
1798
|
function isDestroyable(record) {
|
|
1875
1799
|
return Boolean(record && typeof record === 'object' && typeof record.destroy === 'function');
|
|
@@ -1898,15 +1822,15 @@ function peekResourceKey(record) {
|
|
|
1898
1822
|
*/
|
|
1899
1823
|
|
|
1900
1824
|
function recordIdentifierFor(record) {
|
|
1901
|
-
|
|
1825
|
+
(test => {
|
|
1902
1826
|
if (!test) {
|
|
1903
1827
|
throw new Error(`${String(record)} is not a ReactiveResource or Model known to WarpDrive`);
|
|
1904
1828
|
}
|
|
1905
|
-
})(RecordCache.has(record))
|
|
1829
|
+
})(RecordCache.has(record));
|
|
1906
1830
|
return RecordCache.get(record);
|
|
1907
1831
|
}
|
|
1908
1832
|
function setRecordIdentifier(record, identifier) {
|
|
1909
|
-
|
|
1833
|
+
{
|
|
1910
1834
|
if (RecordCache.has(record) && RecordCache.get(record) !== identifier) {
|
|
1911
1835
|
throw new Error(`${String(record)} was already assigned an identifier`);
|
|
1912
1836
|
}
|
|
@@ -1923,7 +1847,7 @@ function setRecordIdentifier(record, identifier) {
|
|
|
1923
1847
|
RecordCache.set(record, identifier);
|
|
1924
1848
|
}
|
|
1925
1849
|
function removeRecordIdentifier(record) {
|
|
1926
|
-
|
|
1850
|
+
{
|
|
1927
1851
|
if (!RecordCache.has(record)) {
|
|
1928
1852
|
throw new Error(`${String(record)} had no assigned identifier to remove`);
|
|
1929
1853
|
}
|
|
@@ -1938,11 +1862,11 @@ const StoreMap = getOrSetGlobal('StoreMap', new Map());
|
|
|
1938
1862
|
*/
|
|
1939
1863
|
function storeFor(record, ignoreMissing) {
|
|
1940
1864
|
const store = StoreMap.get(record);
|
|
1941
|
-
|
|
1865
|
+
(test => {
|
|
1942
1866
|
if (!test) {
|
|
1943
1867
|
throw new Error(`A record in a disconnected state cannot utilize the store. This typically means the record has been destroyed, most commonly by unloading it.`);
|
|
1944
1868
|
}
|
|
1945
|
-
})(ignoreMissing || store)
|
|
1869
|
+
})(ignoreMissing || store);
|
|
1946
1870
|
return store ?? null;
|
|
1947
1871
|
}
|
|
1948
1872
|
class InstanceCache {
|
|
@@ -1980,11 +1904,11 @@ class InstanceCache {
|
|
|
1980
1904
|
if ('id' in resourceData) {
|
|
1981
1905
|
throw new Error(`Failed to update the 'id' for the ResourceKey '${identifier.type}:${String(identifier.id)} (${identifier.lid})' to '${String(resourceData.id)}', because that id is already in use by '${matchedIdentifier.type}:${String(matchedIdentifier.id)} (${matchedIdentifier.lid})'`);
|
|
1982
1906
|
}
|
|
1983
|
-
|
|
1907
|
+
(test => {
|
|
1984
1908
|
{
|
|
1985
1909
|
throw new Error(`Failed to update the ResourceKey '${identifier.type}:${String(identifier.id)} (${identifier.lid})' to merge with the detected duplicate identifier '${matchedIdentifier.type}:${String(matchedIdentifier.id)} (${String(matchedIdentifier.lid)})'`);
|
|
1986
1910
|
}
|
|
1987
|
-
})()
|
|
1911
|
+
})();
|
|
1988
1912
|
}
|
|
1989
1913
|
this.store.cache.patch({
|
|
1990
1914
|
op: 'mergeIdentifiers',
|
|
@@ -2044,42 +1968,40 @@ class InstanceCache {
|
|
|
2044
1968
|
}
|
|
2045
1969
|
disconnect(identifier) {
|
|
2046
1970
|
const record = this.__instances.record.get(identifier);
|
|
2047
|
-
|
|
1971
|
+
(test => {
|
|
2048
1972
|
if (!test) {
|
|
2049
1973
|
throw new Error('Cannot destroy record while it is still materialized');
|
|
2050
1974
|
}
|
|
2051
|
-
})(!isDestroyable(record) || record.isDestroyed || record.isDestroying)
|
|
1975
|
+
})(!isDestroyable(record) || record.isDestroyed || record.isDestroying);
|
|
2052
1976
|
this.store._graph?.remove(identifier);
|
|
2053
1977
|
this.store.cacheKeyManager.forgetRecordIdentifier(identifier);
|
|
2054
1978
|
StoreMap.delete(identifier);
|
|
2055
1979
|
this.store._requestCache._clearEntries(identifier);
|
|
2056
|
-
|
|
1980
|
+
{
|
|
2057
1981
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2058
1982
|
log('reactive-ui', '', identifier.type, identifier.lid, 'disconnected', '');
|
|
2059
1983
|
}
|
|
2060
1984
|
}
|
|
2061
1985
|
}
|
|
2062
1986
|
unloadRecord(identifier) {
|
|
2063
|
-
|
|
1987
|
+
{
|
|
2064
1988
|
const requests = this.store.getRequestStateService().getPendingRequestsForRecord(identifier);
|
|
2065
1989
|
if (requests.some(req => {
|
|
2066
1990
|
return req.type === 'mutation';
|
|
2067
1991
|
})) {
|
|
2068
|
-
|
|
1992
|
+
(test => {
|
|
2069
1993
|
{
|
|
2070
1994
|
throw new Error(`You can only unload a record which is not inFlight. '${String(identifier)}'`);
|
|
2071
1995
|
}
|
|
2072
|
-
})()
|
|
1996
|
+
})();
|
|
2073
1997
|
}
|
|
2074
1998
|
}
|
|
2075
|
-
|
|
1999
|
+
{
|
|
2076
2000
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2077
2001
|
// eslint-disable-next-line no-console
|
|
2078
2002
|
console.groupCollapsed(`InstanceCache: unloading record for ${String(identifier)}`);
|
|
2079
2003
|
}
|
|
2080
|
-
}
|
|
2081
|
-
|
|
2082
|
-
// TODO is this join still necessary?
|
|
2004
|
+
} // TODO is this join still necessary?
|
|
2083
2005
|
this.store._join(() => {
|
|
2084
2006
|
unloadRecord(this, identifier);
|
|
2085
2007
|
});
|
|
@@ -2115,27 +2037,27 @@ class InstanceCache {
|
|
|
2115
2037
|
const oldId = identifier.id;
|
|
2116
2038
|
|
|
2117
2039
|
// ID absolutely can't be missing if the oldID is empty (missing Id in response for a new record)
|
|
2118
|
-
|
|
2040
|
+
(test => {
|
|
2119
2041
|
if (!test) {
|
|
2120
2042
|
throw new Error(`'${type}' was saved to the server, but the response does not have an id and your record does not either.`);
|
|
2121
2043
|
}
|
|
2122
|
-
})(!(id === null && oldId === null))
|
|
2044
|
+
})(!(id === null && oldId === null));
|
|
2123
2045
|
|
|
2124
2046
|
// ID absolutely can't be different than oldID if oldID is not null
|
|
2125
2047
|
// TODO this assertion and restriction may not strictly be needed in the identifiers world
|
|
2126
|
-
|
|
2048
|
+
(test => {
|
|
2127
2049
|
if (!test) {
|
|
2128
2050
|
throw new Error(`Cannot update the id for '${type}:${lid}' from '${String(oldId)}' to '${id}'.`);
|
|
2129
2051
|
}
|
|
2130
|
-
})(!(oldId !== null && id !== oldId))
|
|
2052
|
+
})(!(oldId !== null && id !== oldId));
|
|
2131
2053
|
|
|
2132
2054
|
// ID can be null if oldID is not null (altered ID in response for a record)
|
|
2133
2055
|
// however, this is more than likely a developer error.
|
|
2134
2056
|
if (oldId !== null && id === null) {
|
|
2135
|
-
warn(`Your ${type} record was saved to the server, but the response does not have an id.`, !(oldId !== null && id === null));
|
|
2057
|
+
console.warn(`Your ${type} record was saved to the server, but the response does not have an id.`, !(oldId !== null && id === null));
|
|
2136
2058
|
return;
|
|
2137
2059
|
}
|
|
2138
|
-
|
|
2060
|
+
{
|
|
2139
2061
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2140
2062
|
// eslint-disable-next-line no-console
|
|
2141
2063
|
console.log(`InstanceCache: updating id to '${id}' for record ${String(identifier)}`);
|
|
@@ -2145,11 +2067,11 @@ class InstanceCache {
|
|
|
2145
2067
|
type,
|
|
2146
2068
|
id
|
|
2147
2069
|
});
|
|
2148
|
-
|
|
2070
|
+
(test => {
|
|
2149
2071
|
if (!test) {
|
|
2150
2072
|
throw new Error(`'${type}' was saved to the server, but the response returned the new id '${id}', which has already been used with another record.'`);
|
|
2151
2073
|
}
|
|
2152
|
-
})(!existingIdentifier || existingIdentifier === identifier)
|
|
2074
|
+
})(!existingIdentifier || existingIdentifier === identifier);
|
|
2153
2075
|
if (identifier.id === null) {
|
|
2154
2076
|
// TODO potentially this needs to handle merged result
|
|
2155
2077
|
this.store.cacheKeyManager.updateRecordIdentifier(identifier, {
|
|
@@ -2182,16 +2104,16 @@ function getNewRecord(instances, identifier, properties) {
|
|
|
2182
2104
|
return record;
|
|
2183
2105
|
}
|
|
2184
2106
|
function _createRecord(instances, identifier, properties) {
|
|
2185
|
-
|
|
2107
|
+
(test => {
|
|
2186
2108
|
if (!test) {
|
|
2187
2109
|
throw new Error(`Cannot create a new record instance while the store is being destroyed`);
|
|
2188
2110
|
}
|
|
2189
|
-
})(!instances.store.isDestroying && !instances.store.isDestroyed)
|
|
2111
|
+
})(!instances.store.isDestroying && !instances.store.isDestroyed);
|
|
2190
2112
|
const record = instances.store.instantiateRecord(identifier, properties);
|
|
2191
2113
|
setRecordIdentifier(record, identifier);
|
|
2192
2114
|
StoreMap.set(record, instances.store);
|
|
2193
2115
|
instances.__instances.record.set(identifier, record);
|
|
2194
|
-
|
|
2116
|
+
{
|
|
2195
2117
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2196
2118
|
logGroup('reactive-ui', '', identifier.type, identifier.lid, 'created', '');
|
|
2197
2119
|
// eslint-disable-next-line no-console
|
|
@@ -2212,7 +2134,7 @@ function unloadRecord(instances, identifier) {
|
|
|
2212
2134
|
instances.__instances.record.delete(identifier);
|
|
2213
2135
|
StoreMap.delete(record);
|
|
2214
2136
|
RecordCache.delete(record);
|
|
2215
|
-
|
|
2137
|
+
{
|
|
2216
2138
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2217
2139
|
// eslint-disable-next-line no-console
|
|
2218
2140
|
console.log(`InstanceCache: destroyed record for ${String(identifier)}`);
|
|
@@ -2222,7 +2144,7 @@ function unloadRecord(instances, identifier) {
|
|
|
2222
2144
|
if (cache) {
|
|
2223
2145
|
cache.unloadRecord(identifier);
|
|
2224
2146
|
StoreMap.delete(identifier);
|
|
2225
|
-
|
|
2147
|
+
{
|
|
2226
2148
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2227
2149
|
// eslint-disable-next-line no-console
|
|
2228
2150
|
console.log(`InstanceCache: destroyed cache for ${String(identifier)}`);
|
|
@@ -2232,7 +2154,7 @@ function unloadRecord(instances, identifier) {
|
|
|
2232
2154
|
instances.disconnect(identifier);
|
|
2233
2155
|
}
|
|
2234
2156
|
instances.store._requestCache._clearEntries(identifier);
|
|
2235
|
-
|
|
2157
|
+
{
|
|
2236
2158
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2237
2159
|
// eslint-disable-next-line no-console
|
|
2238
2160
|
console.log(`InstanceCache: unloaded RecordData for ${String(identifier)}`);
|
|
@@ -2746,16 +2668,16 @@ function count(label) {
|
|
|
2746
2668
|
globalThis.__WarpDriveMetricCountData[label] = (globalThis.__WarpDriveMetricCountData[label] || 0) + 1;
|
|
2747
2669
|
}
|
|
2748
2670
|
function asInternalToken(token) {
|
|
2749
|
-
|
|
2671
|
+
(test => {
|
|
2750
2672
|
if (!test) {
|
|
2751
2673
|
throw new Error(`Expected a token with a 'for' property`);
|
|
2752
2674
|
}
|
|
2753
|
-
})(token && typeof token === 'function' && 'for' in token)
|
|
2675
|
+
})(token && typeof token === 'function' && 'for' in token);
|
|
2754
2676
|
}
|
|
2755
2677
|
function _unsubscribe(token, cache) {
|
|
2756
2678
|
asInternalToken(token);
|
|
2757
2679
|
const cacheKey = token.for;
|
|
2758
|
-
|
|
2680
|
+
{
|
|
2759
2681
|
if (getGlobalConfig().WarpDrive.debug.LOG_NOTIFICATIONS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_NOTIFICATIONS) {
|
|
2760
2682
|
if (!cacheKey) {
|
|
2761
2683
|
// eslint-disable-next-line no-console
|
|
@@ -2770,11 +2692,11 @@ function _unsubscribe(token, cache) {
|
|
|
2770
2692
|
}
|
|
2771
2693
|
const index = callbacks.indexOf(token);
|
|
2772
2694
|
if (index === -1) {
|
|
2773
|
-
|
|
2695
|
+
(test => {
|
|
2774
2696
|
if (!test) {
|
|
2775
2697
|
throw new Error(`Cannot unsubscribe a token that is not subscribed`);
|
|
2776
2698
|
}
|
|
2777
|
-
})(index !== -1)
|
|
2699
|
+
})(index !== -1);
|
|
2778
2700
|
return;
|
|
2779
2701
|
}
|
|
2780
2702
|
callbacks.splice(index, 1);
|
|
@@ -2839,27 +2761,27 @@ class NotificationManager {
|
|
|
2839
2761
|
*/
|
|
2840
2762
|
|
|
2841
2763
|
subscribe(cacheKey, callback) {
|
|
2842
|
-
|
|
2764
|
+
(test => {
|
|
2843
2765
|
if (!test) {
|
|
2844
2766
|
throw new Error(`Expected not to be destroyed`);
|
|
2845
2767
|
}
|
|
2846
|
-
})(!this.isDestroyed)
|
|
2847
|
-
|
|
2768
|
+
})(!this.isDestroyed);
|
|
2769
|
+
(test => {
|
|
2848
2770
|
if (!test) {
|
|
2849
2771
|
throw new Error(`Expected to receive a stable Identifier to subscribe to`);
|
|
2850
2772
|
}
|
|
2851
|
-
})(cacheKey === 'resource' || cacheKey === 'document' || isResourceKey(cacheKey) || isRequestKey(cacheKey))
|
|
2773
|
+
})(cacheKey === 'resource' || cacheKey === 'document' || isResourceKey(cacheKey) || isRequestKey(cacheKey));
|
|
2852
2774
|
let callbacks = this._cache.get(cacheKey);
|
|
2853
|
-
|
|
2775
|
+
(test => {
|
|
2854
2776
|
if (!test) {
|
|
2855
2777
|
throw new Error(`expected to receive a valid callback`);
|
|
2856
2778
|
}
|
|
2857
|
-
})(typeof callback === 'function')
|
|
2858
|
-
|
|
2779
|
+
})(typeof callback === 'function');
|
|
2780
|
+
(test => {
|
|
2859
2781
|
if (!test) {
|
|
2860
2782
|
throw new Error(`cannot subscribe with the same callback twice`);
|
|
2861
2783
|
}
|
|
2862
|
-
})(!callbacks || !callbacks.includes(callback))
|
|
2784
|
+
})(!callbacks || !callbacks.includes(callback));
|
|
2863
2785
|
// we use the callback as the cancellation token
|
|
2864
2786
|
//@ts-expect-error
|
|
2865
2787
|
callback.for = cacheKey;
|
|
@@ -2892,13 +2814,13 @@ class NotificationManager {
|
|
|
2892
2814
|
if (this.isDestroyed) {
|
|
2893
2815
|
return false;
|
|
2894
2816
|
}
|
|
2895
|
-
|
|
2817
|
+
(test => {
|
|
2896
2818
|
if (!test) {
|
|
2897
2819
|
throw new Error(`Notify does not accept a key argument for the namespace '${value}'. Received key '${key || ''}'.`);
|
|
2898
2820
|
}
|
|
2899
|
-
})(!key || value === 'attributes' || value === 'relationships')
|
|
2821
|
+
})(!key || value === 'attributes' || value === 'relationships');
|
|
2900
2822
|
if (!isResourceKey(cacheKey) && !isRequestKey(cacheKey)) {
|
|
2901
|
-
|
|
2823
|
+
{
|
|
2902
2824
|
if (getGlobalConfig().WarpDrive.debug.LOG_NOTIFICATIONS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_NOTIFICATIONS) {
|
|
2903
2825
|
// eslint-disable-next-line no-console
|
|
2904
2826
|
console.log(`Notifying: Expected to receive a stable Identifier to notify '${value}' '${key || ''}' with, but ${String(cacheKey)} is not in the cache`, cacheKey);
|
|
@@ -2914,25 +2836,25 @@ class NotificationManager {
|
|
|
2914
2836
|
this._buffered.set(cacheKey, buffer);
|
|
2915
2837
|
}
|
|
2916
2838
|
buffer.push([value, key || null]);
|
|
2917
|
-
|
|
2839
|
+
{
|
|
2918
2840
|
if (getGlobalConfig().WarpDrive.debug.LOG_METRIC_COUNTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_METRIC_COUNTS) {
|
|
2919
2841
|
count(`notify ${'type' in cacheKey ? cacheKey.type : '<document>'} ${value} ${key}`);
|
|
2920
2842
|
}
|
|
2921
2843
|
}
|
|
2922
2844
|
if (!this._scheduleNotify()) {
|
|
2923
|
-
|
|
2845
|
+
{
|
|
2924
2846
|
if (getGlobalConfig().WarpDrive.debug.LOG_NOTIFICATIONS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_NOTIFICATIONS) {
|
|
2925
2847
|
log('notify', 'buffered', `${'type' in cacheKey ? cacheKey.type : 'document'}`, cacheKey.lid, `${value}`, key || '');
|
|
2926
2848
|
}
|
|
2927
2849
|
}
|
|
2928
2850
|
}
|
|
2929
2851
|
} else {
|
|
2930
|
-
|
|
2852
|
+
{
|
|
2931
2853
|
if (getGlobalConfig().WarpDrive.debug.LOG_NOTIFICATIONS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_NOTIFICATIONS) {
|
|
2932
2854
|
log('notify', 'discarded', `${'type' in cacheKey ? cacheKey.type : 'document'}`, cacheKey.lid, `${value}`, key || '');
|
|
2933
2855
|
}
|
|
2934
2856
|
}
|
|
2935
|
-
|
|
2857
|
+
{
|
|
2936
2858
|
if (getGlobalConfig().WarpDrive.debug.LOG_METRIC_COUNTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_METRIC_COUNTS) {
|
|
2937
2859
|
count(`DISCARDED notify ${'type' in cacheKey ? cacheKey.type : '<document>'} ${value} ${key}`);
|
|
2938
2860
|
}
|
|
@@ -2995,13 +2917,11 @@ class NotificationManager {
|
|
|
2995
2917
|
*/
|
|
2996
2918
|
|
|
2997
2919
|
function _flushNotification(cache, cacheKey, value, key) {
|
|
2998
|
-
|
|
2920
|
+
{
|
|
2999
2921
|
if (getGlobalConfig().WarpDrive.debug.LOG_NOTIFICATIONS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_NOTIFICATIONS) {
|
|
3000
2922
|
log('notify', '', `${'type' in cacheKey ? cacheKey.type : 'document'}`, cacheKey.lid, `${value}`, key || '');
|
|
3001
2923
|
}
|
|
3002
|
-
}
|
|
3003
|
-
|
|
3004
|
-
// TODO for documents this will need to switch based on Identifier kind
|
|
2924
|
+
} // TODO for documents this will need to switch based on Identifier kind
|
|
3005
2925
|
if (isCacheOperationValue(value)) {
|
|
3006
2926
|
const callbackMap = cache.get(isRequestKey(cacheKey) ? 'document' : 'resource');
|
|
3007
2927
|
if (callbackMap) {
|
|
@@ -3072,11 +2992,11 @@ function safeForEach$1(instance, arr, store, callback, target) {
|
|
|
3072
2992
|
}
|
|
3073
2993
|
// clone to prevent mutation
|
|
3074
2994
|
arr = arr.slice();
|
|
3075
|
-
|
|
2995
|
+
(test => {
|
|
3076
2996
|
if (!test) {
|
|
3077
2997
|
throw new Error('`forEach` expects a function as first argument.');
|
|
3078
2998
|
}
|
|
3079
|
-
})(typeof callback === 'function')
|
|
2999
|
+
})(typeof callback === 'function');
|
|
3080
3000
|
|
|
3081
3001
|
// because we retrieveLatest above we need not worry if array is mutated during iteration
|
|
3082
3002
|
// by unloadRecord/rollbackAttributes
|
|
@@ -3116,20 +3036,20 @@ function performObjectExtensionGet(receiver, extensions, signals, prop) {
|
|
|
3116
3036
|
}
|
|
3117
3037
|
case 'writeonly-field':
|
|
3118
3038
|
{
|
|
3119
|
-
|
|
3039
|
+
(test => {
|
|
3120
3040
|
{
|
|
3121
3041
|
throw new Error(`Cannot get extended field ${String(prop)} as its definition has only a setter`);
|
|
3122
3042
|
}
|
|
3123
|
-
})()
|
|
3043
|
+
})();
|
|
3124
3044
|
return undefined;
|
|
3125
3045
|
}
|
|
3126
3046
|
default:
|
|
3127
3047
|
{
|
|
3128
|
-
|
|
3048
|
+
(test => {
|
|
3129
3049
|
{
|
|
3130
3050
|
throw new Error(`Unhandled extension kind ${desc.kind}`);
|
|
3131
3051
|
}
|
|
3132
|
-
})()
|
|
3052
|
+
})();
|
|
3133
3053
|
return undefined;
|
|
3134
3054
|
}
|
|
3135
3055
|
}
|
|
@@ -3140,11 +3060,11 @@ function performExtensionSet(receiver, extensions, signals, prop, value) {
|
|
|
3140
3060
|
case 'method':
|
|
3141
3061
|
case 'readonly-value':
|
|
3142
3062
|
case 'readonly-field':
|
|
3143
|
-
|
|
3063
|
+
(test => {
|
|
3144
3064
|
{
|
|
3145
3065
|
throw new Error(`Cannot set extension field ${String(prop)} as it is a ${desc.kind}`);
|
|
3146
3066
|
}
|
|
3147
|
-
})()
|
|
3067
|
+
})();
|
|
3148
3068
|
return false;
|
|
3149
3069
|
case 'mutable-value':
|
|
3150
3070
|
{
|
|
@@ -3163,11 +3083,11 @@ function performExtensionSet(receiver, extensions, signals, prop, value) {
|
|
|
3163
3083
|
}
|
|
3164
3084
|
default:
|
|
3165
3085
|
{
|
|
3166
|
-
|
|
3086
|
+
(test => {
|
|
3167
3087
|
{
|
|
3168
3088
|
throw new Error(`Unhandled extension kind ${desc.kind}`);
|
|
3169
3089
|
}
|
|
3170
|
-
})()
|
|
3090
|
+
})();
|
|
3171
3091
|
return false;
|
|
3172
3092
|
}
|
|
3173
3093
|
}
|
|
@@ -3207,20 +3127,20 @@ function performArrayExtensionGet(receiver, extensions, signals, prop, _SIGNAL,
|
|
|
3207
3127
|
}
|
|
3208
3128
|
case 'writeonly-field':
|
|
3209
3129
|
{
|
|
3210
|
-
|
|
3130
|
+
(test => {
|
|
3211
3131
|
{
|
|
3212
3132
|
throw new Error(`Cannot get extended field ${String(prop)} as its definition has only a setter`);
|
|
3213
3133
|
}
|
|
3214
|
-
})()
|
|
3134
|
+
})();
|
|
3215
3135
|
return undefined;
|
|
3216
3136
|
}
|
|
3217
3137
|
default:
|
|
3218
3138
|
{
|
|
3219
|
-
|
|
3139
|
+
(test => {
|
|
3220
3140
|
{
|
|
3221
3141
|
throw new Error(`Unhandled extension kind ${desc.kind}`);
|
|
3222
3142
|
}
|
|
3223
|
-
})()
|
|
3143
|
+
})();
|
|
3224
3144
|
return undefined;
|
|
3225
3145
|
}
|
|
3226
3146
|
}
|
|
@@ -3252,13 +3172,7 @@ const MUTABLE_PROPS = ['_updatingPromise', 'isDestroying', 'isDestroyed', 'query
|
|
|
3252
3172
|
const ARR_BRACKET_DESC = {
|
|
3253
3173
|
enumerable: true,
|
|
3254
3174
|
configurable: false,
|
|
3255
|
-
get: function () {
|
|
3256
|
-
// here to support computed chains
|
|
3257
|
-
// and {{#each}}
|
|
3258
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_COMPUTED_CHAINS)) {
|
|
3259
|
-
return this;
|
|
3260
|
-
}
|
|
3261
|
-
}
|
|
3175
|
+
get: function () {}
|
|
3262
3176
|
};
|
|
3263
3177
|
const IS_UPDATING_DESC = createSignalDescriptor('isUpdating', false);
|
|
3264
3178
|
const ArrayHandler = {
|
|
@@ -3343,19 +3257,19 @@ const ArrayHandler = {
|
|
|
3343
3257
|
// array functions must run through Reflect to work properly
|
|
3344
3258
|
// binding via other means will not work.
|
|
3345
3259
|
if (!CONTEXT.editable) {
|
|
3346
|
-
|
|
3260
|
+
(test => {
|
|
3347
3261
|
if (!test) {
|
|
3348
3262
|
throw new Error(`Mutating this array of records via ${String(prop)} is not allowed.`);
|
|
3349
3263
|
}
|
|
3350
|
-
})(CONTEXT.editable)
|
|
3264
|
+
})(CONTEXT.editable);
|
|
3351
3265
|
return;
|
|
3352
3266
|
}
|
|
3353
3267
|
const args = Array.prototype.slice.call(arguments);
|
|
3354
|
-
|
|
3268
|
+
(test => {
|
|
3355
3269
|
if (!test) {
|
|
3356
3270
|
throw new Error(`Cannot start a new array transaction while a previous transaction is underway`);
|
|
3357
3271
|
}
|
|
3358
|
-
})(!CONTEXT.transaction)
|
|
3272
|
+
})(!CONTEXT.transaction);
|
|
3359
3273
|
CONTEXT.transaction = true;
|
|
3360
3274
|
const result = CONTEXT.mutate(target, receiver, prop, args, CONTEXT.signal);
|
|
3361
3275
|
CONTEXT.transaction = false;
|
|
@@ -3395,11 +3309,11 @@ const ArrayHandler = {
|
|
|
3395
3309
|
return true;
|
|
3396
3310
|
}
|
|
3397
3311
|
if (!CONTEXT.editable && !MUTABLE_PROPS.includes(prop)) {
|
|
3398
|
-
|
|
3312
|
+
(test => {
|
|
3399
3313
|
if (!test) {
|
|
3400
3314
|
throw new Error(`Mutating ${String(prop)} on this Array is not allowed.`);
|
|
3401
3315
|
}
|
|
3402
|
-
})(CONTEXT.editable)
|
|
3316
|
+
})(CONTEXT.editable);
|
|
3403
3317
|
return false;
|
|
3404
3318
|
}
|
|
3405
3319
|
if (prop === 'length') {
|
|
@@ -3411,11 +3325,11 @@ const ArrayHandler = {
|
|
|
3411
3325
|
} else if (CONTEXT.transaction) {
|
|
3412
3326
|
return Reflect.set(target, prop, value);
|
|
3413
3327
|
} else {
|
|
3414
|
-
|
|
3328
|
+
(test => {
|
|
3415
3329
|
{
|
|
3416
3330
|
throw new Error(`unexpected length set`);
|
|
3417
3331
|
}
|
|
3418
|
-
})()
|
|
3332
|
+
})();
|
|
3419
3333
|
}
|
|
3420
3334
|
}
|
|
3421
3335
|
if (isContextProp(prop)) {
|
|
@@ -3448,11 +3362,11 @@ const ArrayHandler = {
|
|
|
3448
3362
|
if (index === null || index > target.length) {
|
|
3449
3363
|
if (index !== null && CONTEXT.transaction) {
|
|
3450
3364
|
const identifier = recordIdentifierFor(value);
|
|
3451
|
-
|
|
3365
|
+
(test => {
|
|
3452
3366
|
if (!test) {
|
|
3453
3367
|
throw new Error(`Cannot set index ${index} past the end of the array.`);
|
|
3454
3368
|
}
|
|
3455
|
-
})(isResourceKey(identifier))
|
|
3369
|
+
})(isResourceKey(identifier));
|
|
3456
3370
|
target[index] = identifier;
|
|
3457
3371
|
return true;
|
|
3458
3372
|
} else if (CONTEXT.features && prop in CONTEXT.features) {
|
|
@@ -3463,11 +3377,11 @@ const ArrayHandler = {
|
|
|
3463
3377
|
}
|
|
3464
3378
|
const original = target[index];
|
|
3465
3379
|
const newIdentifier = extractIdentifierFromRecord$2(value);
|
|
3466
|
-
|
|
3380
|
+
(test => {
|
|
3467
3381
|
if (!test) {
|
|
3468
3382
|
throw new Error(`Expected a record`);
|
|
3469
3383
|
}
|
|
3470
|
-
})(newIdentifier && isResourceKey(newIdentifier))
|
|
3384
|
+
})(newIdentifier && isResourceKey(newIdentifier));
|
|
3471
3385
|
// We generate "transactions" whenever a setter method on the array
|
|
3472
3386
|
// is called and might bulk update multiple array cells. Fundamentally,
|
|
3473
3387
|
// all array operations decompose into individual cell replacements.
|
|
@@ -3493,11 +3407,11 @@ const ArrayHandler = {
|
|
|
3493
3407
|
},
|
|
3494
3408
|
deleteProperty(target, prop) {
|
|
3495
3409
|
const CONTEXT = target[Context];
|
|
3496
|
-
|
|
3410
|
+
(test => {
|
|
3497
3411
|
if (!test) {
|
|
3498
3412
|
throw new Error(`Deleting keys on managed arrays is disallowed`);
|
|
3499
3413
|
}
|
|
3500
|
-
})(CONTEXT.transaction)
|
|
3414
|
+
})(CONTEXT.transaction);
|
|
3501
3415
|
if (!CONTEXT.transaction) {
|
|
3502
3416
|
return false;
|
|
3503
3417
|
}
|
|
@@ -3508,11 +3422,11 @@ const ArrayHandler = {
|
|
|
3508
3422
|
}
|
|
3509
3423
|
};
|
|
3510
3424
|
const ILLEGAL_MUTATION = () => {
|
|
3511
|
-
|
|
3425
|
+
(test => {
|
|
3512
3426
|
{
|
|
3513
3427
|
throw new Error(`ILLEGAL OPERATION: This ReactiveResourceArray is immutable`);
|
|
3514
3428
|
}
|
|
3515
|
-
})()
|
|
3429
|
+
})();
|
|
3516
3430
|
};
|
|
3517
3431
|
function createReactiveResourceArray(options) {
|
|
3518
3432
|
const TARGET = options.source;
|
|
@@ -3536,7 +3450,7 @@ function createReactiveResourceArray(options) {
|
|
|
3536
3450
|
};
|
|
3537
3451
|
TARGET[Context] = context;
|
|
3538
3452
|
const proxy = new NativeProxy(TARGET, ArrayHandler);
|
|
3539
|
-
|
|
3453
|
+
{
|
|
3540
3454
|
Object.defineProperty(TARGET, '__SHOW_ME_THE_DATA_(debug mode only)__', {
|
|
3541
3455
|
enumerable: false,
|
|
3542
3456
|
configurable: true,
|
|
@@ -3563,7 +3477,7 @@ function extractIdentifierFromRecord$2(record) {
|
|
|
3563
3477
|
if (!record) {
|
|
3564
3478
|
return null;
|
|
3565
3479
|
}
|
|
3566
|
-
|
|
3480
|
+
(test => {
|
|
3567
3481
|
if (!test) {
|
|
3568
3482
|
throw new Error(`All elements of a ReactiveResourceArray must be instances of a ReactiveResource, you passed $${typeof record}`);
|
|
3569
3483
|
}
|
|
@@ -3574,7 +3488,7 @@ function extractIdentifierFromRecord$2(record) {
|
|
|
3574
3488
|
} catch {
|
|
3575
3489
|
return false;
|
|
3576
3490
|
}
|
|
3577
|
-
}())
|
|
3491
|
+
}());
|
|
3578
3492
|
return recordIdentifierFor(record);
|
|
3579
3493
|
}
|
|
3580
3494
|
function destroy(clear) {
|
|
@@ -3601,6 +3515,69 @@ function createRequestCollection(config) {
|
|
|
3601
3515
|
});
|
|
3602
3516
|
}
|
|
3603
3517
|
|
|
3518
|
+
/**
|
|
3519
|
+
* LiveArrays contain all the known records for a given `ResourceType`.
|
|
3520
|
+
*
|
|
3521
|
+
* ### Basic Example
|
|
3522
|
+
*
|
|
3523
|
+
* For instance, if an application were to have a `'user'` type:
|
|
3524
|
+
*
|
|
3525
|
+
* ```ts
|
|
3526
|
+
* const usersLiveArray = store.peekAll('user');
|
|
3527
|
+
* ```
|
|
3528
|
+
*
|
|
3529
|
+
* ---
|
|
3530
|
+
*
|
|
3531
|
+
*
|
|
3532
|
+
*
|
|
3533
|
+
* ### LiveArrays are Arrays
|
|
3534
|
+
*
|
|
3535
|
+
* LiveArrays have all array APIs, and will report `true`
|
|
3536
|
+
* for both `liveArray instanceof Array` and `Array.isArray(liveArray)`
|
|
3537
|
+
*
|
|
3538
|
+
* ---
|
|
3539
|
+
*
|
|
3540
|
+
*
|
|
3541
|
+
*
|
|
3542
|
+
* ### Reactive
|
|
3543
|
+
*
|
|
3544
|
+
* The array is "live" as it will reactively update any time new
|
|
3545
|
+
* users are added to the store's cache.
|
|
3546
|
+
*
|
|
3547
|
+
* There is only one LiveArray instance per ResourceType, and it
|
|
3548
|
+
* can be accessed either via {@link Store.peekAll} or {@link Store.findAll}
|
|
3549
|
+
*
|
|
3550
|
+
* ```ts
|
|
3551
|
+
* const users = await store.findAll('user');
|
|
3552
|
+
* const peekedUsers = store.peekAll('user');
|
|
3553
|
+
* peekedUsers === users; // true
|
|
3554
|
+
* ```
|
|
3555
|
+
*
|
|
3556
|
+
* ---
|
|
3557
|
+
*
|
|
3558
|
+
*
|
|
3559
|
+
*
|
|
3560
|
+
* ### New Records
|
|
3561
|
+
*
|
|
3562
|
+
* Records in the `"new"` state (created locally on the client
|
|
3563
|
+
* but not yet saved) appear in LiveArrays if they are in LegacyMode.
|
|
3564
|
+
*
|
|
3565
|
+
* PolarisMode records in the `"new"` state do not appear in LiveArrays.
|
|
3566
|
+
*
|
|
3567
|
+
* ---
|
|
3568
|
+
*
|
|
3569
|
+
*
|
|
3570
|
+
*
|
|
3571
|
+
* ### Polymorphism
|
|
3572
|
+
*
|
|
3573
|
+
* LiveArrays are not polymorphic. If your application has an abstract
|
|
3574
|
+
* type "car" with concrete types "ferrari" and "bmw", then "ferrari"
|
|
3575
|
+
* and "bmw" will have populated LiveArrays, but the LiveArray for "car"
|
|
3576
|
+
* would be empty.
|
|
3577
|
+
*
|
|
3578
|
+
* @legacy we recommend againt using LiveArrays. Use {@link Store.request} instead
|
|
3579
|
+
*/
|
|
3580
|
+
|
|
3604
3581
|
/**
|
|
3605
3582
|
* The options for {@link createLegacyLiveArray}
|
|
3606
3583
|
*
|
|
@@ -3636,11 +3613,11 @@ function createLegacyLiveArray(options) {
|
|
|
3636
3613
|
}
|
|
3637
3614
|
function _updateLiveArray() {
|
|
3638
3615
|
const context = this[Context];
|
|
3639
|
-
|
|
3616
|
+
(test => {
|
|
3640
3617
|
if (!test) {
|
|
3641
3618
|
throw new Error(`_update cannot be used with this array`);
|
|
3642
3619
|
}
|
|
3643
|
-
})(this.modelName)
|
|
3620
|
+
})(this.modelName);
|
|
3644
3621
|
// @ts-expect-error typescript is unable to handle the complexity of
|
|
3645
3622
|
// T = unknown, modelName = string
|
|
3646
3623
|
// T extends TypedRecordInstance, modelName = TypeFromInstance<T>
|
|
@@ -3650,6 +3627,79 @@ function _updateLiveArray() {
|
|
|
3650
3627
|
});
|
|
3651
3628
|
}
|
|
3652
3629
|
|
|
3630
|
+
/**
|
|
3631
|
+
* QueryArrays contain the primary records returned when querying
|
|
3632
|
+
* for records by `ResourceType`.
|
|
3633
|
+
*
|
|
3634
|
+
* ### Basic Example
|
|
3635
|
+
*
|
|
3636
|
+
* For instance, if an application were to have a `'user'` type:
|
|
3637
|
+
*
|
|
3638
|
+
* ```ts
|
|
3639
|
+
* const users = await store.query('user', { name: 'Chris' });
|
|
3640
|
+
* ```
|
|
3641
|
+
*
|
|
3642
|
+
* ---
|
|
3643
|
+
*
|
|
3644
|
+
*
|
|
3645
|
+
*
|
|
3646
|
+
* ### QueryArrays are Arrays
|
|
3647
|
+
*
|
|
3648
|
+
* QueryArrays have all array APIs, and will report `true`
|
|
3649
|
+
* for both `queryArray instanceof Array` and `Array.isArray(queryArray)`
|
|
3650
|
+
*
|
|
3651
|
+
* However, any mutation of the array will throw an error.
|
|
3652
|
+
*
|
|
3653
|
+
* ---
|
|
3654
|
+
*
|
|
3655
|
+
*
|
|
3656
|
+
*
|
|
3657
|
+
* ### Reactive
|
|
3658
|
+
*
|
|
3659
|
+
* If a record in a QueryArray is deleted and unloaded, it will be
|
|
3660
|
+
* automatically removed from the array.
|
|
3661
|
+
*
|
|
3662
|
+
* ---
|
|
3663
|
+
*
|
|
3664
|
+
*
|
|
3665
|
+
*
|
|
3666
|
+
* ### Immutable
|
|
3667
|
+
*
|
|
3668
|
+
* Records cannot be directly added to or removed from a QueryArray.
|
|
3669
|
+
*
|
|
3670
|
+
* ---
|
|
3671
|
+
*
|
|
3672
|
+
*
|
|
3673
|
+
*
|
|
3674
|
+
* ### Polymorphism
|
|
3675
|
+
*
|
|
3676
|
+
* QueryArrays are not intended to be polymorphic. If your application has
|
|
3677
|
+
* an abstract type "car" with concrete types "ferrari" and "bmw", a query
|
|
3678
|
+
* which returns primary data containing both ferraris and bmws will *likely*
|
|
3679
|
+
* work, but it is not guaranteed.
|
|
3680
|
+
*
|
|
3681
|
+
* In contrast, the {@link ReactiveResourceArray} returned when using {@link Store.request}
|
|
3682
|
+
* is guaranteed to work with polymorphic responses.
|
|
3683
|
+
*
|
|
3684
|
+
* ---
|
|
3685
|
+
*
|
|
3686
|
+
*
|
|
3687
|
+
*
|
|
3688
|
+
* ### Memory Leaks
|
|
3689
|
+
*
|
|
3690
|
+
* QueryArrays are meant to be long lived. They can be refreshed using
|
|
3691
|
+
* `array.update()`, and destroyed via `array.destroy()`.
|
|
3692
|
+
*
|
|
3693
|
+
* Unlike most Reactive state in WarpDrive, applications must choose to call
|
|
3694
|
+
* `destroy` when the `QueryArray` is no longer needed, else the array instance
|
|
3695
|
+
* will be retained until either the application or the store which created it
|
|
3696
|
+
* are destroyed. Destroying a QueryArray does not remove its records
|
|
3697
|
+
* from the cache, but it does remove the array as well as the overhead it requires
|
|
3698
|
+
* from the store for book-keeping.
|
|
3699
|
+
*
|
|
3700
|
+
* @legacy we recommend againt using QueryArrays. Use {@link Store.request} instead
|
|
3701
|
+
*/
|
|
3702
|
+
|
|
3653
3703
|
/**
|
|
3654
3704
|
* The options for {@link createLegacyQueryArray}
|
|
3655
3705
|
*
|
|
@@ -3697,16 +3747,16 @@ function _updateCollection() {
|
|
|
3697
3747
|
const {
|
|
3698
3748
|
query
|
|
3699
3749
|
} = this;
|
|
3700
|
-
|
|
3750
|
+
(test => {
|
|
3701
3751
|
if (!test) {
|
|
3702
3752
|
throw new Error(`update cannot be used with this array`);
|
|
3703
3753
|
}
|
|
3704
|
-
})(this.modelName)
|
|
3705
|
-
|
|
3754
|
+
})(this.modelName);
|
|
3755
|
+
(test => {
|
|
3706
3756
|
if (!test) {
|
|
3707
3757
|
throw new Error(`update cannot be used with no query`);
|
|
3708
3758
|
}
|
|
3709
|
-
})(query)
|
|
3759
|
+
})(query);
|
|
3710
3760
|
// @ts-expect-error typescript is unable to handle the complexity of
|
|
3711
3761
|
// T = unknown, modelName = string
|
|
3712
3762
|
// T extends TypedRecordInstance, modelName = TypeFromInstance<T>
|
|
@@ -3909,11 +3959,11 @@ class RecordArrayManager {
|
|
|
3909
3959
|
// due to notification that the cache has changed
|
|
3910
3960
|
if (signal.value === 'cache-sync') {
|
|
3911
3961
|
const doc = this.store.cache.peek(identifier);
|
|
3912
|
-
|
|
3962
|
+
(test => {
|
|
3913
3963
|
if (!test) {
|
|
3914
3964
|
throw new Error(`Expected to find a document for ${identifier.lid} but found none`);
|
|
3915
3965
|
}
|
|
3916
|
-
})(doc)
|
|
3966
|
+
})(doc);
|
|
3917
3967
|
const data = !('data' in doc) || !Array.isArray(doc.data) ? [] : doc.data;
|
|
3918
3968
|
// TODO technically we should destroy here if
|
|
3919
3969
|
// !('data' in doc) || !Array.isArray(doc.data)
|
|
@@ -4072,11 +4122,11 @@ class RecordArrayManager {
|
|
|
4072
4122
|
populateManagedArray(array, identifiers, payload) {
|
|
4073
4123
|
this._pending.delete(array);
|
|
4074
4124
|
const source = array[Context].source;
|
|
4075
|
-
|
|
4125
|
+
(test => {
|
|
4076
4126
|
if (!test) {
|
|
4077
4127
|
throw new Error(`The new state of the collection should not be using the same array reference as the original state.`);
|
|
4078
4128
|
}
|
|
4079
|
-
})(source !== identifiers)
|
|
4129
|
+
})(source !== identifiers);
|
|
4080
4130
|
const old = source.slice();
|
|
4081
4131
|
source.length = 0;
|
|
4082
4132
|
fastPush(source, identifiers);
|
|
@@ -4260,7 +4310,7 @@ function isLegacyLiveArray(array) {
|
|
|
4260
4310
|
}
|
|
4261
4311
|
const Touching = getOrSetGlobal('Touching', Symbol('touching'));
|
|
4262
4312
|
const RequestPromise = getOrSetGlobal('RequestPromise', Symbol('promise'));
|
|
4263
|
-
const EMPTY_ARR =
|
|
4313
|
+
const EMPTY_ARR = Object.freeze([]);
|
|
4264
4314
|
function hasRecordIdentifier(op) {
|
|
4265
4315
|
return 'recordIdentifier' in op;
|
|
4266
4316
|
}
|
|
@@ -4338,11 +4388,11 @@ class RequestStateService {
|
|
|
4338
4388
|
throw error;
|
|
4339
4389
|
});
|
|
4340
4390
|
}
|
|
4341
|
-
|
|
4391
|
+
(test => {
|
|
4342
4392
|
{
|
|
4343
4393
|
throw new Error(`Expected a well formed query`);
|
|
4344
4394
|
}
|
|
4345
|
-
})()
|
|
4395
|
+
})();
|
|
4346
4396
|
}
|
|
4347
4397
|
|
|
4348
4398
|
/** @internal */
|
|
@@ -4480,12 +4530,15 @@ class RequestStateService {
|
|
|
4480
4530
|
*/
|
|
4481
4531
|
|
|
4482
4532
|
// this import location is deprecated but breaks in 4.8 and older
|
|
4483
|
-
// @ts-expect-error adding to globalThis
|
|
4484
|
-
globalThis.setWarpDriveLogging = setLogging;
|
|
4485
4533
|
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4534
|
+
{
|
|
4535
|
+
// @ts-expect-error adding to globalThis
|
|
4536
|
+
globalThis.setWarpDriveLogging = setLogging;
|
|
4537
|
+
|
|
4538
|
+
// @ts-expect-error adding to globalThis
|
|
4539
|
+
globalThis.getWarpDriveRuntimeConfig = getRuntimeConfig;
|
|
4540
|
+
}
|
|
4541
|
+
{
|
|
4489
4542
|
if (getGlobalConfig().WarpDrive.debug.LOG_METRIC_COUNTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_METRIC_COUNTS) {
|
|
4490
4543
|
// @ts-expect-error adding to globalThis
|
|
4491
4544
|
// eslint-disable-next-line
|
|
@@ -4503,7 +4556,7 @@ if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_METRIC_COUNTS))
|
|
|
4503
4556
|
// @ts-expect-error
|
|
4504
4557
|
globalThis.__WarpDriveMetricCountData = {};
|
|
4505
4558
|
};
|
|
4506
|
-
|
|
4559
|
+
{
|
|
4507
4560
|
if (getGlobalConfig().WarpDrive.debug.__INTERNAL_LOG_NATIVE_MAP_SET_COUNTS || globalThis.getWarpDriveRuntimeConfig().debug.__INTERNAL_LOG_NATIVE_MAP_SET_COUNTS) {
|
|
4508
4561
|
// @ts-expect-error adding to globalThis
|
|
4509
4562
|
globalThis.__primitiveInstanceId = 0;
|
|
@@ -4618,10 +4671,10 @@ const EmptyClass = class {
|
|
|
4618
4671
|
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
4619
4672
|
constructor(args) {}
|
|
4620
4673
|
};
|
|
4621
|
-
const _BaseClass =
|
|
4674
|
+
const _BaseClass = EmptyClass;
|
|
4622
4675
|
const BaseClass = _BaseClass.default ? _BaseClass.default : _BaseClass;
|
|
4623
4676
|
if (BaseClass !== EmptyClass) {
|
|
4624
|
-
|
|
4677
|
+
console.warn(`The Store class extending from EmberObject is deprecated.
|
|
4625
4678
|
Please remove usage of EmberObject APIs and mark your class as not requiring it.
|
|
4626
4679
|
|
|
4627
4680
|
To mark the class as no longer extending from EmberObject, in ember-cli-build.js
|
|
@@ -4636,16 +4689,7 @@ const app = new EmberApp(defaults, {
|
|
|
4636
4689
|
}
|
|
4637
4690
|
});
|
|
4638
4691
|
\`\`\`
|
|
4639
|
-
|
|
4640
|
-
id: 'ember-data:deprecate-store-extends-ember-object',
|
|
4641
|
-
until: '6.0',
|
|
4642
|
-
for: 'ember-data',
|
|
4643
|
-
url: 'https://deprecations.emberjs.com/id/ember-data-deprecate-store-extends-ember-object',
|
|
4644
|
-
since: {
|
|
4645
|
-
available: '4.13',
|
|
4646
|
-
enabled: '5.4'
|
|
4647
|
-
}
|
|
4648
|
-
});
|
|
4692
|
+
`);
|
|
4649
4693
|
}
|
|
4650
4694
|
/**
|
|
4651
4695
|
* ```ts
|
|
@@ -4833,13 +4877,13 @@ class Store extends BaseClass {
|
|
|
4833
4877
|
|
|
4834
4878
|
/** @internal */
|
|
4835
4879
|
_run(cb) {
|
|
4836
|
-
|
|
4880
|
+
(test => {
|
|
4837
4881
|
if (!test) {
|
|
4838
4882
|
throw new Error(`WarpDrive should never encounter a nested run`);
|
|
4839
4883
|
}
|
|
4840
|
-
})(!this._cbs)
|
|
4884
|
+
})(!this._cbs);
|
|
4841
4885
|
const _cbs = this._cbs = {};
|
|
4842
|
-
|
|
4886
|
+
{
|
|
4843
4887
|
try {
|
|
4844
4888
|
cb();
|
|
4845
4889
|
if (_cbs.coalesce) {
|
|
@@ -4854,18 +4898,6 @@ class Store extends BaseClass {
|
|
|
4854
4898
|
} finally {
|
|
4855
4899
|
this._cbs = null;
|
|
4856
4900
|
}
|
|
4857
|
-
} else {
|
|
4858
|
-
cb();
|
|
4859
|
-
if (_cbs.coalesce) {
|
|
4860
|
-
_cbs.coalesce();
|
|
4861
|
-
}
|
|
4862
|
-
if (_cbs.sync) {
|
|
4863
|
-
_cbs.sync();
|
|
4864
|
-
}
|
|
4865
|
-
if (_cbs.notify) {
|
|
4866
|
-
_cbs.notify();
|
|
4867
|
-
}
|
|
4868
|
-
this._cbs = null;
|
|
4869
4901
|
}
|
|
4870
4902
|
}
|
|
4871
4903
|
|
|
@@ -4888,16 +4920,16 @@ class Store extends BaseClass {
|
|
|
4888
4920
|
|
|
4889
4921
|
/** @internal */
|
|
4890
4922
|
_schedule(name, cb) {
|
|
4891
|
-
|
|
4923
|
+
(test => {
|
|
4892
4924
|
if (!test) {
|
|
4893
4925
|
throw new Error(`WarpDrive expects to schedule only when there is an active run`);
|
|
4894
4926
|
}
|
|
4895
|
-
})(!!this._cbs)
|
|
4896
|
-
|
|
4927
|
+
})(!!this._cbs);
|
|
4928
|
+
(test => {
|
|
4897
4929
|
if (!test) {
|
|
4898
4930
|
throw new Error(`WarpDrive expects only one flush per queue name, cannot schedule ${name}`);
|
|
4899
4931
|
}
|
|
4900
|
-
})(!this._cbs[name])
|
|
4932
|
+
})(!this._cbs[name]);
|
|
4901
4933
|
this._cbs[name] = cb;
|
|
4902
4934
|
}
|
|
4903
4935
|
|
|
@@ -4917,7 +4949,7 @@ class Store extends BaseClass {
|
|
|
4917
4949
|
|
|
4918
4950
|
/** @internal */
|
|
4919
4951
|
_getAllPending() {
|
|
4920
|
-
|
|
4952
|
+
{
|
|
4921
4953
|
const all = [];
|
|
4922
4954
|
const pending = this._requestCache._pending;
|
|
4923
4955
|
pending.forEach(requests => {
|
|
@@ -4995,12 +5027,12 @@ class Store extends BaseClass {
|
|
|
4995
5027
|
const cacheKeyManager = this.cacheKeyManager;
|
|
4996
5028
|
opts.records = requestConfig.records.map(r => cacheKeyManager.getOrCreateRecordIdentifier(r));
|
|
4997
5029
|
}
|
|
4998
|
-
|
|
5030
|
+
{
|
|
4999
5031
|
if (this.DISABLE_WAITER) {
|
|
5000
5032
|
opts.disableTestWaiter = typeof requestConfig.disableTestWaiter === 'boolean' ? requestConfig.disableTestWaiter : true;
|
|
5001
5033
|
}
|
|
5002
5034
|
}
|
|
5003
|
-
|
|
5035
|
+
{
|
|
5004
5036
|
if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
|
|
5005
5037
|
let options;
|
|
5006
5038
|
try {
|
|
@@ -5015,13 +5047,12 @@ class Store extends BaseClass {
|
|
|
5015
5047
|
const request = Object.assign({}, requestConfig, opts);
|
|
5016
5048
|
const future = this.requestManager.request(request);
|
|
5017
5049
|
future.onFinalize(() => {
|
|
5018
|
-
|
|
5050
|
+
{
|
|
5019
5051
|
if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
|
|
5020
5052
|
// eslint-disable-next-line no-console
|
|
5021
5053
|
console.log(`request: [[FINALIZE]] ${requestConfig.op && !requestConfig.url ? '(LEGACY) ' : ''}${requestConfig.op || '<unknown operation>'} ${requestConfig.url || '<empty url>'} ${requestConfig.method || '<empty method>'}`);
|
|
5022
5054
|
}
|
|
5023
|
-
}
|
|
5024
|
-
// skip flush for legacy belongsTo
|
|
5055
|
+
} // skip flush for legacy belongsTo
|
|
5025
5056
|
if (requestConfig.op === 'findBelongsTo' && !requestConfig.url) {
|
|
5026
5057
|
return;
|
|
5027
5058
|
}
|
|
@@ -5086,19 +5117,19 @@ class Store extends BaseClass {
|
|
|
5086
5117
|
*/
|
|
5087
5118
|
|
|
5088
5119
|
createRecord(type, inputProperties, context) {
|
|
5089
|
-
|
|
5120
|
+
{
|
|
5090
5121
|
assertDestroyingStore(this, 'createRecord');
|
|
5091
5122
|
}
|
|
5092
|
-
|
|
5123
|
+
(test => {
|
|
5093
5124
|
if (!test) {
|
|
5094
5125
|
throw new Error(`You need to pass a model name to the store's createRecord method`);
|
|
5095
5126
|
}
|
|
5096
|
-
})(type)
|
|
5097
|
-
|
|
5127
|
+
})(type);
|
|
5128
|
+
(test => {
|
|
5098
5129
|
if (!test) {
|
|
5099
5130
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
5100
5131
|
}
|
|
5101
|
-
})(typeof type === 'string')
|
|
5132
|
+
})(typeof type === 'string');
|
|
5102
5133
|
|
|
5103
5134
|
// This is wrapped in a `run.join` so that in test environments users do not need to manually wrap
|
|
5104
5135
|
// calls to `createRecord`. The run loop usage here is because we batch the joining and updating
|
|
@@ -5133,22 +5164,22 @@ class Store extends BaseClass {
|
|
|
5133
5164
|
};
|
|
5134
5165
|
if (resource.id) {
|
|
5135
5166
|
const identifier = this.cacheKeyManager.peekResourceKey(resource);
|
|
5136
|
-
|
|
5167
|
+
(test => {
|
|
5137
5168
|
if (!test) {
|
|
5138
5169
|
throw new Error(`The id ${String(properties.id)} has already been used with another '${normalizedModelName}' record.`);
|
|
5139
5170
|
}
|
|
5140
|
-
})(!identifier)
|
|
5171
|
+
})(!identifier);
|
|
5141
5172
|
}
|
|
5142
5173
|
if (context?.lid) {
|
|
5143
5174
|
const identifier = this.cacheKeyManager.peekResourceKey({
|
|
5144
5175
|
lid: context?.lid
|
|
5145
5176
|
});
|
|
5146
5177
|
resource.lid = context.lid;
|
|
5147
|
-
|
|
5178
|
+
(test => {
|
|
5148
5179
|
if (!test) {
|
|
5149
5180
|
throw new Error(`The lid ${context.lid} has already been used with another '${identifier?.type}' record.`);
|
|
5150
5181
|
}
|
|
5151
|
-
})(!identifier)
|
|
5182
|
+
})(!identifier);
|
|
5152
5183
|
}
|
|
5153
5184
|
const identifier = this.cacheKeyManager.createIdentifierForNewRecord(resource);
|
|
5154
5185
|
const cache = this.cache;
|
|
@@ -5172,16 +5203,16 @@ class Store extends BaseClass {
|
|
|
5172
5203
|
@param {unknown} record
|
|
5173
5204
|
*/
|
|
5174
5205
|
deleteRecord(record) {
|
|
5175
|
-
|
|
5206
|
+
{
|
|
5176
5207
|
assertDestroyingStore(this, 'deleteRecord');
|
|
5177
5208
|
}
|
|
5178
5209
|
const identifier = peekResourceKey(record);
|
|
5179
5210
|
const cache = this.cache;
|
|
5180
|
-
|
|
5211
|
+
(test => {
|
|
5181
5212
|
if (!test) {
|
|
5182
5213
|
throw new Error(`expected the record to be connected to a cache`);
|
|
5183
5214
|
}
|
|
5184
|
-
})(identifier)
|
|
5215
|
+
})(identifier);
|
|
5185
5216
|
this._join(() => {
|
|
5186
5217
|
cache.setIsDeleted(identifier, true);
|
|
5187
5218
|
if (cache.isNew(identifier)) {
|
|
@@ -5202,7 +5233,7 @@ class Store extends BaseClass {
|
|
|
5202
5233
|
@param {Model} record
|
|
5203
5234
|
*/
|
|
5204
5235
|
unloadRecord(record) {
|
|
5205
|
-
|
|
5236
|
+
{
|
|
5206
5237
|
assertDestroyingStore(this, 'unloadRecord');
|
|
5207
5238
|
}
|
|
5208
5239
|
const identifier = peekResourceKey(record);
|
|
@@ -5250,19 +5281,19 @@ class Store extends BaseClass {
|
|
|
5250
5281
|
// this is basically an "are we not empty" query.
|
|
5251
5282
|
return isLoaded ? this._instanceCache.getRecord(stableIdentifier) : null;
|
|
5252
5283
|
}
|
|
5253
|
-
|
|
5284
|
+
{
|
|
5254
5285
|
assertDestroyingStore(this, 'peekRecord');
|
|
5255
5286
|
}
|
|
5256
|
-
|
|
5287
|
+
(test => {
|
|
5257
5288
|
if (!test) {
|
|
5258
5289
|
throw new Error(`You need to pass a model name to the store's peekRecord method`);
|
|
5259
5290
|
}
|
|
5260
|
-
})(identifier)
|
|
5261
|
-
|
|
5291
|
+
})(identifier);
|
|
5292
|
+
(test => {
|
|
5262
5293
|
if (!test) {
|
|
5263
5294
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${String(identifier)}`);
|
|
5264
5295
|
}
|
|
5265
|
-
})(typeof identifier === 'string')
|
|
5296
|
+
})(typeof identifier === 'string');
|
|
5266
5297
|
const type = normalizeModelName(identifier);
|
|
5267
5298
|
const normalizedId = ensureStringId(id);
|
|
5268
5299
|
const resource = {
|
|
@@ -5292,19 +5323,19 @@ class Store extends BaseClass {
|
|
|
5292
5323
|
*/
|
|
5293
5324
|
|
|
5294
5325
|
peekAll(type) {
|
|
5295
|
-
|
|
5326
|
+
{
|
|
5296
5327
|
assertDestroyingStore(this, 'peekAll');
|
|
5297
5328
|
}
|
|
5298
|
-
|
|
5329
|
+
(test => {
|
|
5299
5330
|
if (!test) {
|
|
5300
5331
|
throw new Error(`You need to pass a model name to the store's peekAll method`);
|
|
5301
5332
|
}
|
|
5302
|
-
})(type)
|
|
5303
|
-
|
|
5333
|
+
})(type);
|
|
5334
|
+
(test => {
|
|
5304
5335
|
if (!test) {
|
|
5305
5336
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
5306
5337
|
}
|
|
5307
|
-
})(typeof type === 'string')
|
|
5338
|
+
})(typeof type === 'string');
|
|
5308
5339
|
return this.recordArrayManager.liveArrayFor(normalizeModelName(type));
|
|
5309
5340
|
}
|
|
5310
5341
|
|
|
@@ -5321,14 +5352,14 @@ class Store extends BaseClass {
|
|
|
5321
5352
|
*/
|
|
5322
5353
|
|
|
5323
5354
|
unloadAll(type) {
|
|
5324
|
-
|
|
5355
|
+
{
|
|
5325
5356
|
assertDestroyedStoreOnly(this, 'unloadAll');
|
|
5326
5357
|
}
|
|
5327
|
-
|
|
5358
|
+
(test => {
|
|
5328
5359
|
if (!test) {
|
|
5329
5360
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${String(type)}`);
|
|
5330
5361
|
}
|
|
5331
|
-
})(!type || typeof type === 'string')
|
|
5362
|
+
})(!type || typeof type === 'string');
|
|
5332
5363
|
this._join(() => {
|
|
5333
5364
|
this._enableAsyncFlush = true;
|
|
5334
5365
|
if (type === undefined) {
|
|
@@ -5475,7 +5506,7 @@ class Store extends BaseClass {
|
|
|
5475
5506
|
*/
|
|
5476
5507
|
|
|
5477
5508
|
push(data) {
|
|
5478
|
-
|
|
5509
|
+
{
|
|
5479
5510
|
assertDestroyingStore(this, 'push');
|
|
5480
5511
|
}
|
|
5481
5512
|
const pushed = this._push(data, false);
|
|
@@ -5495,7 +5526,7 @@ class Store extends BaseClass {
|
|
|
5495
5526
|
@return identifiers for the primary records that had data loaded
|
|
5496
5527
|
*/
|
|
5497
5528
|
_push(jsonApiDoc, asyncFlush) {
|
|
5498
|
-
|
|
5529
|
+
{
|
|
5499
5530
|
assertDestroyingStore(this, '_push');
|
|
5500
5531
|
}
|
|
5501
5532
|
if (asyncFlush) {
|
|
@@ -5523,7 +5554,7 @@ class Store extends BaseClass {
|
|
|
5523
5554
|
} = this._instanceCache;
|
|
5524
5555
|
if (!cache) {
|
|
5525
5556
|
cache = this._instanceCache.cache = this.createCache(this._instanceCache._storeWrapper);
|
|
5526
|
-
|
|
5557
|
+
{
|
|
5527
5558
|
cache = this._instanceCache.cache = new CacheManager(cache);
|
|
5528
5559
|
}
|
|
5529
5560
|
}
|
|
@@ -5580,67 +5611,24 @@ function assertPrivateStore(store) {}
|
|
|
5580
5611
|
function isPrivateStore(store) {
|
|
5581
5612
|
return store;
|
|
5582
5613
|
}
|
|
5583
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_SCHEMA_SERVICE)) {
|
|
5584
|
-
Store.prototype.getSchemaDefinitionService = function () {
|
|
5585
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
5586
|
-
if (!test) {
|
|
5587
|
-
throw new Error(`You must registerSchemaDefinitionService with the store to use custom model classes`);
|
|
5588
|
-
}
|
|
5589
|
-
})(this._schema) : {};
|
|
5590
|
-
deprecate(`Use \`store.schema\` instead of \`store.getSchemaDefinitionService()\``, false, {
|
|
5591
|
-
id: 'ember-data:schema-service-updates',
|
|
5592
|
-
until: '6.0',
|
|
5593
|
-
for: 'ember-data',
|
|
5594
|
-
since: {
|
|
5595
|
-
available: '4.13',
|
|
5596
|
-
enabled: '5.4'
|
|
5597
|
-
}
|
|
5598
|
-
});
|
|
5599
|
-
return this._schema;
|
|
5600
|
-
};
|
|
5601
|
-
Store.prototype.registerSchemaDefinitionService = function (schema) {
|
|
5602
|
-
deprecate(`Use \`store.createSchemaService\` instead of \`store.registerSchemaDefinitionService()\``, false, {
|
|
5603
|
-
id: 'ember-data:schema-service-updates',
|
|
5604
|
-
until: '6.0',
|
|
5605
|
-
for: 'ember-data',
|
|
5606
|
-
since: {
|
|
5607
|
-
available: '4.13',
|
|
5608
|
-
enabled: '5.4'
|
|
5609
|
-
}
|
|
5610
|
-
});
|
|
5611
|
-
this._schema = schema;
|
|
5612
|
-
};
|
|
5613
|
-
Store.prototype.registerSchema = function (schema) {
|
|
5614
|
-
deprecate(`Use \`store.createSchemaService\` instead of \`store.registerSchema()\``, false, {
|
|
5615
|
-
id: 'ember-data:schema-service-updates',
|
|
5616
|
-
until: '6.0',
|
|
5617
|
-
for: 'ember-data',
|
|
5618
|
-
since: {
|
|
5619
|
-
available: '4.13',
|
|
5620
|
-
enabled: '5.4'
|
|
5621
|
-
}
|
|
5622
|
-
});
|
|
5623
|
-
this._schema = schema;
|
|
5624
|
-
};
|
|
5625
|
-
}
|
|
5626
5614
|
let assertDestroyingStore;
|
|
5627
5615
|
let assertDestroyedStoreOnly;
|
|
5628
|
-
|
|
5616
|
+
{
|
|
5629
5617
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
5630
5618
|
assertDestroyingStore = function assertDestroyingStore(store, method) {
|
|
5631
|
-
|
|
5619
|
+
(test => {
|
|
5632
5620
|
if (!test) {
|
|
5633
5621
|
throw new Error(`Attempted to call store.${method}(), but the store instance has already been destroyed.`);
|
|
5634
5622
|
}
|
|
5635
|
-
})(!(store.isDestroying || store.isDestroyed))
|
|
5623
|
+
})(!(store.isDestroying || store.isDestroyed));
|
|
5636
5624
|
};
|
|
5637
5625
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
5638
5626
|
assertDestroyedStoreOnly = function assertDestroyedStoreOnly(store, method) {
|
|
5639
|
-
|
|
5627
|
+
(test => {
|
|
5640
5628
|
if (!test) {
|
|
5641
5629
|
throw new Error(`Attempted to call store.${method}(), but the store instance has already been destroyed.`);
|
|
5642
5630
|
}
|
|
5643
|
-
})(!store.isDestroyed)
|
|
5631
|
+
})(!store.isDestroyed);
|
|
5644
5632
|
};
|
|
5645
5633
|
}
|
|
5646
5634
|
function isMaybeIdentifier(maybeIdentifier) {
|
|
@@ -5650,17 +5638,17 @@ function normalizeProperties(store, identifier, properties) {
|
|
|
5650
5638
|
// assert here
|
|
5651
5639
|
if (properties !== undefined) {
|
|
5652
5640
|
if ('id' in properties) {
|
|
5653
|
-
|
|
5641
|
+
(test => {
|
|
5654
5642
|
if (!test) {
|
|
5655
5643
|
throw new Error(`expected id to be a string or null`);
|
|
5656
5644
|
}
|
|
5657
|
-
})(properties.id !== undefined)
|
|
5645
|
+
})(properties.id !== undefined);
|
|
5658
5646
|
}
|
|
5659
|
-
|
|
5647
|
+
(test => {
|
|
5660
5648
|
if (!test) {
|
|
5661
5649
|
throw new Error(`You passed '${typeof properties}' as properties for record creation instead of an object.`);
|
|
5662
5650
|
}
|
|
5663
|
-
})(typeof properties === 'object' && properties !== null)
|
|
5651
|
+
})(typeof properties === 'object' && properties !== null);
|
|
5664
5652
|
const {
|
|
5665
5653
|
type
|
|
5666
5654
|
} = identifier;
|
|
@@ -5676,7 +5664,7 @@ function normalizeProperties(store, identifier, properties) {
|
|
|
5676
5664
|
const field = defs.get(prop);
|
|
5677
5665
|
if (!field) continue;
|
|
5678
5666
|
if (field.kind === 'hasMany') {
|
|
5679
|
-
|
|
5667
|
+
{
|
|
5680
5668
|
assertRecordsPassedToHasMany(properties[prop]);
|
|
5681
5669
|
}
|
|
5682
5670
|
properties[prop] = extractIdentifiersFromRecords$1(properties[prop]);
|
|
@@ -5689,12 +5677,12 @@ function normalizeProperties(store, identifier, properties) {
|
|
|
5689
5677
|
return properties;
|
|
5690
5678
|
}
|
|
5691
5679
|
function assertRecordsPassedToHasMany(records) {
|
|
5692
|
-
|
|
5680
|
+
(test => {
|
|
5693
5681
|
if (!test) {
|
|
5694
5682
|
throw new Error(`You must pass an array of records to set a hasMany relationship`);
|
|
5695
5683
|
}
|
|
5696
|
-
})(Array.isArray(records))
|
|
5697
|
-
|
|
5684
|
+
})(Array.isArray(records));
|
|
5685
|
+
(test => {
|
|
5698
5686
|
if (!test) {
|
|
5699
5687
|
throw new Error(`All elements of a hasMany relationship must be instances of Model, you passed ${records.map(r => `${typeof r}`).join(', ')}`);
|
|
5700
5688
|
}
|
|
@@ -5707,7 +5695,7 @@ function assertRecordsPassedToHasMany(records) {
|
|
|
5707
5695
|
return false;
|
|
5708
5696
|
}
|
|
5709
5697
|
});
|
|
5710
|
-
}())
|
|
5698
|
+
}());
|
|
5711
5699
|
}
|
|
5712
5700
|
function extractIdentifiersFromRecords$1(records) {
|
|
5713
5701
|
return records.map(record => extractIdentifierFromRecord$1(record));
|
|
@@ -5720,97 +5708,6 @@ function extractIdentifierFromRecord$1(recordOrPromiseRecord) {
|
|
|
5720
5708
|
return extract(recordOrPromiseRecord);
|
|
5721
5709
|
}
|
|
5722
5710
|
|
|
5723
|
-
/*
|
|
5724
|
-
When a find request is triggered on the store, the user can optionally pass in
|
|
5725
|
-
attributes and relationships to be preloaded. These are meant to behave as if they
|
|
5726
|
-
came back from the server, except the user obtained them out of band and is informing
|
|
5727
|
-
the store of their existence. The most common use case is for supporting client side
|
|
5728
|
-
nested URLs, such as `/posts/1/comments/2` so the user can do
|
|
5729
|
-
`store.findRecord('comment', 2, { preload: { post: 1 } })` without having to fetch the post.
|
|
5730
|
-
|
|
5731
|
-
Preloaded data can be attributes and relationships passed in either as IDs or as actual
|
|
5732
|
-
models.
|
|
5733
|
-
*/
|
|
5734
|
-
function preloadData(store, identifier, preload) {
|
|
5735
|
-
const jsonPayload = {};
|
|
5736
|
-
//TODO(Igor) consider the polymorphic case
|
|
5737
|
-
const schemas = store.schema;
|
|
5738
|
-
const fields = schemas.fields(identifier);
|
|
5739
|
-
Object.keys(preload).forEach(key => {
|
|
5740
|
-
const preloadValue = preload[key];
|
|
5741
|
-
const field = fields.get(key);
|
|
5742
|
-
if (field && (field.kind === 'hasMany' || field.kind === 'belongsTo')) {
|
|
5743
|
-
if (!jsonPayload.relationships) {
|
|
5744
|
-
jsonPayload.relationships = {};
|
|
5745
|
-
}
|
|
5746
|
-
jsonPayload.relationships[key] = preloadRelationship(field, preloadValue);
|
|
5747
|
-
} else {
|
|
5748
|
-
if (!jsonPayload.attributes) {
|
|
5749
|
-
jsonPayload.attributes = {};
|
|
5750
|
-
}
|
|
5751
|
-
jsonPayload.attributes[key] = preloadValue;
|
|
5752
|
-
}
|
|
5753
|
-
});
|
|
5754
|
-
const cache = store.cache;
|
|
5755
|
-
const hasRecord = Boolean(store._instanceCache.peek(identifier));
|
|
5756
|
-
cache.upsert(identifier, jsonPayload, hasRecord);
|
|
5757
|
-
}
|
|
5758
|
-
function preloadRelationship(schema, preloadValue) {
|
|
5759
|
-
const relatedType = schema.type;
|
|
5760
|
-
if (schema.kind === 'hasMany') {
|
|
5761
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
5762
|
-
if (!test) {
|
|
5763
|
-
throw new Error('You need to pass in an array to set a hasMany property on a record');
|
|
5764
|
-
}
|
|
5765
|
-
})(Array.isArray(preloadValue)) : {};
|
|
5766
|
-
return {
|
|
5767
|
-
data: preloadValue.map(value => _convertPreloadRelationshipToJSON(value, relatedType))
|
|
5768
|
-
};
|
|
5769
|
-
}
|
|
5770
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
5771
|
-
if (!test) {
|
|
5772
|
-
throw new Error('You should not pass in an array to set a belongsTo property on a record');
|
|
5773
|
-
}
|
|
5774
|
-
})(!Array.isArray(preloadValue)) : {};
|
|
5775
|
-
return {
|
|
5776
|
-
data: preloadValue ? _convertPreloadRelationshipToJSON(preloadValue, relatedType) : null
|
|
5777
|
-
};
|
|
5778
|
-
}
|
|
5779
|
-
|
|
5780
|
-
/*
|
|
5781
|
-
findRecord('user', '1', { preload: { friends: ['1'] }});
|
|
5782
|
-
findRecord('user', '1', { preload: { friends: [record] }});
|
|
5783
|
-
*/
|
|
5784
|
-
function _convertPreloadRelationshipToJSON(value, type) {
|
|
5785
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
5786
|
-
return {
|
|
5787
|
-
type,
|
|
5788
|
-
id: ensureStringId(value)
|
|
5789
|
-
};
|
|
5790
|
-
}
|
|
5791
|
-
// TODO if not a record instance assert it's an identifier
|
|
5792
|
-
// and allow identifiers to be used
|
|
5793
|
-
return recordIdentifierFor(value);
|
|
5794
|
-
}
|
|
5795
|
-
|
|
5796
|
-
/**
|
|
5797
|
-
* Minimum subset of static schema methods and properties on the
|
|
5798
|
-
* "model" class.
|
|
5799
|
-
*
|
|
5800
|
-
* Only used when using the legacy schema-service implementation
|
|
5801
|
-
* for @warp-drive/legacy/model or when wrapping schema for legacy
|
|
5802
|
-
* Adapters/Serializers.
|
|
5803
|
-
*
|
|
5804
|
-
*/
|
|
5805
|
-
|
|
5806
|
-
function _resourceIsFullDeleted(identifier, cache) {
|
|
5807
|
-
return cache.isDeletionCommitted(identifier) || cache.isNew(identifier) && cache.isDeleted(identifier);
|
|
5808
|
-
}
|
|
5809
|
-
function resourceIsFullyDeleted(instanceCache, identifier) {
|
|
5810
|
-
const cache = instanceCache.cache;
|
|
5811
|
-
return !cache || _resourceIsFullDeleted(identifier, cache);
|
|
5812
|
-
}
|
|
5813
|
-
|
|
5814
5711
|
/**
|
|
5815
5712
|
A `RecordReference` is a low-level API that allows users and
|
|
5816
5713
|
addon authors to perform meta-operations on a record.
|
|
@@ -5967,11 +5864,11 @@ class RecordReference {
|
|
|
5967
5864
|
if (id !== null) {
|
|
5968
5865
|
return this.store.findRecord(this.type, id);
|
|
5969
5866
|
}
|
|
5970
|
-
|
|
5867
|
+
(test => {
|
|
5971
5868
|
{
|
|
5972
5869
|
throw new Error(`Unable to fetch record of type ${this.type} without an id`);
|
|
5973
5870
|
}
|
|
5974
|
-
})()
|
|
5871
|
+
})();
|
|
5975
5872
|
}
|
|
5976
5873
|
|
|
5977
5874
|
/**
|
|
@@ -5993,423 +5890,18 @@ class RecordReference {
|
|
|
5993
5890
|
reload: true
|
|
5994
5891
|
});
|
|
5995
5892
|
}
|
|
5996
|
-
|
|
5893
|
+
(test => {
|
|
5997
5894
|
{
|
|
5998
5895
|
throw new Error(`Unable to fetch record of type ${this.type} without an id`);
|
|
5999
5896
|
}
|
|
6000
|
-
})()
|
|
5897
|
+
})();
|
|
6001
5898
|
}
|
|
6002
5899
|
}
|
|
6003
5900
|
defineSignal(RecordReference.prototype, '_ref');
|
|
6004
5901
|
|
|
6005
5902
|
// if modelFor turns out to be a bottleneck we should replace with a Map
|
|
6006
5903
|
// and clear it during store teardown.
|
|
6007
|
-
|
|
6008
|
-
function getShimClass(store, modelName) {
|
|
6009
|
-
let shims = AvailableShims.get(store);
|
|
6010
|
-
if (!shims) {
|
|
6011
|
-
shims = Object.create(null);
|
|
6012
|
-
AvailableShims.set(store, shims);
|
|
6013
|
-
}
|
|
6014
|
-
let shim = shims[modelName];
|
|
6015
|
-
if (shim === undefined) {
|
|
6016
|
-
shim = shims[modelName] = new ShimModelClass(store, modelName);
|
|
6017
|
-
}
|
|
6018
|
-
return shim;
|
|
6019
|
-
}
|
|
6020
|
-
|
|
6021
|
-
// Mimics the static apis of @warp-drive/legacy/model
|
|
6022
|
-
class ShimModelClass {
|
|
6023
|
-
constructor(store, modelName) {
|
|
6024
|
-
this.__store = store;
|
|
6025
|
-
this.modelName = modelName;
|
|
6026
|
-
}
|
|
6027
|
-
get fields() {
|
|
6028
|
-
const fields = new Map();
|
|
6029
|
-
const fieldSchemas = this.__store.schema.fields({
|
|
6030
|
-
type: this.modelName
|
|
6031
|
-
});
|
|
6032
|
-
fieldSchemas.forEach((schema, key) => {
|
|
6033
|
-
if (schema.kind === 'attribute' || schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
|
|
6034
|
-
fields.set(key, schema.kind);
|
|
6035
|
-
}
|
|
6036
|
-
});
|
|
6037
|
-
return fields;
|
|
6038
|
-
}
|
|
6039
|
-
get attributes() {
|
|
6040
|
-
const attrs = new Map();
|
|
6041
|
-
const fields = this.__store.schema.fields({
|
|
6042
|
-
type: this.modelName
|
|
6043
|
-
});
|
|
6044
|
-
fields.forEach((schema, key) => {
|
|
6045
|
-
if (schema.kind === 'attribute') {
|
|
6046
|
-
attrs.set(key, schema);
|
|
6047
|
-
}
|
|
6048
|
-
});
|
|
6049
|
-
return attrs;
|
|
6050
|
-
}
|
|
6051
|
-
get relationshipsByName() {
|
|
6052
|
-
const rels = new Map();
|
|
6053
|
-
const fields = this.__store.schema.fields({
|
|
6054
|
-
type: this.modelName
|
|
6055
|
-
});
|
|
6056
|
-
fields.forEach((schema, key) => {
|
|
6057
|
-
if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
|
|
6058
|
-
rels.set(key, schema);
|
|
6059
|
-
}
|
|
6060
|
-
});
|
|
6061
|
-
return rels;
|
|
6062
|
-
}
|
|
6063
|
-
eachAttribute(callback, binding) {
|
|
6064
|
-
this.__store.schema.fields({
|
|
6065
|
-
type: this.modelName
|
|
6066
|
-
}).forEach((schema, key) => {
|
|
6067
|
-
if (schema.kind === 'attribute') {
|
|
6068
|
-
callback.call(binding, key, schema);
|
|
6069
|
-
}
|
|
6070
|
-
});
|
|
6071
|
-
}
|
|
6072
|
-
eachRelationship(callback, binding) {
|
|
6073
|
-
this.__store.schema.fields({
|
|
6074
|
-
type: this.modelName
|
|
6075
|
-
}).forEach((schema, key) => {
|
|
6076
|
-
if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
|
|
6077
|
-
callback.call(binding, key, schema);
|
|
6078
|
-
}
|
|
6079
|
-
});
|
|
6080
|
-
}
|
|
6081
|
-
eachTransformedAttribute(callback, binding) {
|
|
6082
|
-
this.__store.schema.fields({
|
|
6083
|
-
type: this.modelName
|
|
6084
|
-
}).forEach((schema, key) => {
|
|
6085
|
-
if (schema.kind === 'attribute') {
|
|
6086
|
-
const type = schema.type;
|
|
6087
|
-
if (type) callback.call(binding, key, type);
|
|
6088
|
-
}
|
|
6089
|
-
});
|
|
6090
|
-
}
|
|
6091
|
-
}
|
|
6092
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUEST_METHODS)) {
|
|
6093
|
-
Store.prototype.findRecord = function (resource, id, options) {
|
|
6094
|
-
deprecate(`store.findRecord is deprecated. Use store.request instead.`, false, {
|
|
6095
|
-
id: 'warp-drive:deprecate-legacy-request-methods',
|
|
6096
|
-
until: '6.0',
|
|
6097
|
-
for: '@warp-drive/core',
|
|
6098
|
-
url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',
|
|
6099
|
-
since: {
|
|
6100
|
-
enabled: '5.7',
|
|
6101
|
-
available: '5.7'
|
|
6102
|
-
}
|
|
6103
|
-
});
|
|
6104
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6105
|
-
if (!test) {
|
|
6106
|
-
throw new Error(`Attempted to call store.findRecord(), but the store instance has already been destroyed.`);
|
|
6107
|
-
}
|
|
6108
|
-
})(!(this.isDestroying || this.isDestroyed)) : {};
|
|
6109
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6110
|
-
if (!test) {
|
|
6111
|
-
throw new Error(`You need to pass a modelName or resource identifier as the first argument to the store's findRecord method`);
|
|
6112
|
-
}
|
|
6113
|
-
})(resource) : {};
|
|
6114
|
-
if (isMaybeIdentifier(resource)) {
|
|
6115
|
-
options = id;
|
|
6116
|
-
} else {
|
|
6117
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6118
|
-
if (!test) {
|
|
6119
|
-
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${resource}`);
|
|
6120
|
-
}
|
|
6121
|
-
})(typeof resource === 'string') : {};
|
|
6122
|
-
const type = normalizeModelName(resource);
|
|
6123
|
-
const normalizedId = ensureStringId(id);
|
|
6124
|
-
resource = constructResource(type, normalizedId);
|
|
6125
|
-
}
|
|
6126
|
-
const identifier = this.cacheKeyManager.getOrCreateRecordIdentifier(resource);
|
|
6127
|
-
options = options || {};
|
|
6128
|
-
if (options.preload) {
|
|
6129
|
-
// force reload if we preload to ensure we don't resolve the promise
|
|
6130
|
-
// until we are complete, else we will end up background-reloading
|
|
6131
|
-
// even for initial load.
|
|
6132
|
-
if (!this._instanceCache.recordIsLoaded(identifier)) {
|
|
6133
|
-
options.reload = true;
|
|
6134
|
-
}
|
|
6135
|
-
this._join(() => {
|
|
6136
|
-
preloadData(this, identifier, options.preload);
|
|
6137
|
-
});
|
|
6138
|
-
}
|
|
6139
|
-
const promise = this.request({
|
|
6140
|
-
op: 'findRecord',
|
|
6141
|
-
data: {
|
|
6142
|
-
record: identifier,
|
|
6143
|
-
options
|
|
6144
|
-
},
|
|
6145
|
-
cacheOptions: {
|
|
6146
|
-
[SkipCache]: true
|
|
6147
|
-
}
|
|
6148
|
-
});
|
|
6149
|
-
return promise.then(document => {
|
|
6150
|
-
return document.content;
|
|
6151
|
-
});
|
|
6152
|
-
};
|
|
6153
|
-
Store.prototype.findAll = function (type, options = {}) {
|
|
6154
|
-
deprecate(`store.findAll is deprecated. Use store.request instead.`, false, {
|
|
6155
|
-
id: 'warp-drive:deprecate-legacy-request-methods',
|
|
6156
|
-
until: '6.0',
|
|
6157
|
-
for: '@warp-drive/core',
|
|
6158
|
-
url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',
|
|
6159
|
-
since: {
|
|
6160
|
-
enabled: '5.7',
|
|
6161
|
-
available: '5.7'
|
|
6162
|
-
}
|
|
6163
|
-
});
|
|
6164
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6165
|
-
if (!test) {
|
|
6166
|
-
throw new Error(`Attempted to call store.findAll(), but the store instance has already been destroyed.`);
|
|
6167
|
-
}
|
|
6168
|
-
})(!(this.isDestroying || this.isDestroyed)) : {};
|
|
6169
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6170
|
-
if (!test) {
|
|
6171
|
-
throw new Error(`You need to pass a model name to the store's findAll method`);
|
|
6172
|
-
}
|
|
6173
|
-
})(type) : {};
|
|
6174
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6175
|
-
if (!test) {
|
|
6176
|
-
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
6177
|
-
}
|
|
6178
|
-
})(typeof type === 'string') : {};
|
|
6179
|
-
const promise = this.request({
|
|
6180
|
-
op: 'findAll',
|
|
6181
|
-
data: {
|
|
6182
|
-
type: normalizeModelName(type),
|
|
6183
|
-
options: options || {}
|
|
6184
|
-
},
|
|
6185
|
-
cacheOptions: {
|
|
6186
|
-
[SkipCache]: true
|
|
6187
|
-
}
|
|
6188
|
-
});
|
|
6189
|
-
return promise.then(document => document.content);
|
|
6190
|
-
};
|
|
6191
|
-
Store.prototype.query = function (type, query, options = {}) {
|
|
6192
|
-
deprecate(`store.query is deprecated. Use store.request instead.`, false, {
|
|
6193
|
-
id: 'warp-drive:deprecate-legacy-request-methods',
|
|
6194
|
-
until: '6.0',
|
|
6195
|
-
for: '@warp-drive/core',
|
|
6196
|
-
url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',
|
|
6197
|
-
since: {
|
|
6198
|
-
enabled: '5.7',
|
|
6199
|
-
available: '5.7'
|
|
6200
|
-
}
|
|
6201
|
-
});
|
|
6202
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6203
|
-
if (!test) {
|
|
6204
|
-
throw new Error(`Attempted to call store.query(), but the store instance has already been destroyed.`);
|
|
6205
|
-
}
|
|
6206
|
-
})(!(this.isDestroying || this.isDestroyed)) : {};
|
|
6207
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6208
|
-
if (!test) {
|
|
6209
|
-
throw new Error(`You need to pass a model name to the store's query method`);
|
|
6210
|
-
}
|
|
6211
|
-
})(type) : {};
|
|
6212
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6213
|
-
if (!test) {
|
|
6214
|
-
throw new Error(`You need to pass a query hash to the store's query method`);
|
|
6215
|
-
}
|
|
6216
|
-
})(query) : {};
|
|
6217
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6218
|
-
if (!test) {
|
|
6219
|
-
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
6220
|
-
}
|
|
6221
|
-
})(typeof type === 'string') : {};
|
|
6222
|
-
const promise = this.request({
|
|
6223
|
-
op: 'query',
|
|
6224
|
-
data: {
|
|
6225
|
-
type: normalizeModelName(type),
|
|
6226
|
-
query,
|
|
6227
|
-
options: options
|
|
6228
|
-
},
|
|
6229
|
-
cacheOptions: {
|
|
6230
|
-
[SkipCache]: true
|
|
6231
|
-
}
|
|
6232
|
-
});
|
|
6233
|
-
return promise.then(document => document.content);
|
|
6234
|
-
};
|
|
6235
|
-
Store.prototype.queryRecord = function (type, query, options) {
|
|
6236
|
-
deprecate(`store.queryRecord is deprecated. Use store.request instead.`, false, {
|
|
6237
|
-
id: 'warp-drive:deprecate-legacy-request-methods',
|
|
6238
|
-
until: '6.0',
|
|
6239
|
-
for: '@warp-drive/core',
|
|
6240
|
-
url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',
|
|
6241
|
-
since: {
|
|
6242
|
-
enabled: '5.7',
|
|
6243
|
-
available: '5.7'
|
|
6244
|
-
}
|
|
6245
|
-
});
|
|
6246
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6247
|
-
if (!test) {
|
|
6248
|
-
throw new Error(`Attempted to call store.queryRecord(), but the store instance has already been destroyed.`);
|
|
6249
|
-
}
|
|
6250
|
-
})(!(this.isDestroying || this.isDestroyed)) : {};
|
|
6251
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6252
|
-
if (!test) {
|
|
6253
|
-
throw new Error(`You need to pass a model name to the store's queryRecord method`);
|
|
6254
|
-
}
|
|
6255
|
-
})(type) : {};
|
|
6256
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6257
|
-
if (!test) {
|
|
6258
|
-
throw new Error(`You need to pass a query hash to the store's queryRecord method`);
|
|
6259
|
-
}
|
|
6260
|
-
})(query) : {};
|
|
6261
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6262
|
-
if (!test) {
|
|
6263
|
-
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
6264
|
-
}
|
|
6265
|
-
})(typeof type === 'string') : {};
|
|
6266
|
-
const promise = this.request({
|
|
6267
|
-
op: 'queryRecord',
|
|
6268
|
-
data: {
|
|
6269
|
-
type: normalizeModelName(type),
|
|
6270
|
-
query,
|
|
6271
|
-
options: options || {}
|
|
6272
|
-
},
|
|
6273
|
-
cacheOptions: {
|
|
6274
|
-
[SkipCache]: true
|
|
6275
|
-
}
|
|
6276
|
-
});
|
|
6277
|
-
return promise.then(document => document.content);
|
|
6278
|
-
};
|
|
6279
|
-
Store.prototype.getReference = function (resource, id) {
|
|
6280
|
-
deprecate(`store.getReference is deprecated. There is no direct replacement. For working with the cache and relationships, use the cache with the appropriate identifiers. To load, use store.request.`, false, {
|
|
6281
|
-
id: 'warp-drive:deprecate-legacy-request-methods',
|
|
6282
|
-
until: '6.0',
|
|
6283
|
-
for: '@warp-drive/core',
|
|
6284
|
-
url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',
|
|
6285
|
-
since: {
|
|
6286
|
-
enabled: '5.7',
|
|
6287
|
-
available: '5.7'
|
|
6288
|
-
}
|
|
6289
|
-
});
|
|
6290
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6291
|
-
if (!test) {
|
|
6292
|
-
throw new Error(`Attempted to call store.getReference(), but the store instance has already been destroyed.`);
|
|
6293
|
-
}
|
|
6294
|
-
})(!(this.isDestroying || this.isDestroyed)) : {};
|
|
6295
|
-
let resourceIdentifier;
|
|
6296
|
-
if (arguments.length === 1 && isMaybeIdentifier(resource)) {
|
|
6297
|
-
resourceIdentifier = resource;
|
|
6298
|
-
} else {
|
|
6299
|
-
const type = normalizeModelName(resource);
|
|
6300
|
-
const normalizedId = ensureStringId(id);
|
|
6301
|
-
resourceIdentifier = constructResource(type, normalizedId);
|
|
6302
|
-
}
|
|
6303
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6304
|
-
if (!test) {
|
|
6305
|
-
throw new Error('getReference expected to receive either a resource identifier or type and id as arguments');
|
|
6306
|
-
}
|
|
6307
|
-
})(isMaybeIdentifier(resourceIdentifier)) : {};
|
|
6308
|
-
const identifier = this.cacheKeyManager.getOrCreateRecordIdentifier(resourceIdentifier);
|
|
6309
|
-
const cache = upgradeInstanceCaches(this._instanceCache.__instances).reference;
|
|
6310
|
-
let reference = cache.get(identifier);
|
|
6311
|
-
if (!reference) {
|
|
6312
|
-
reference = new RecordReference(this, identifier);
|
|
6313
|
-
cache.set(identifier, reference);
|
|
6314
|
-
}
|
|
6315
|
-
return reference;
|
|
6316
|
-
};
|
|
6317
|
-
Store.prototype.modelFor = function (type) {
|
|
6318
|
-
deprecate(`store.modelFor is deprecated, please use store.schema.fields({ type: '${type}' }) to access schema information instead.`, false, {
|
|
6319
|
-
id: 'warp-drive:deprecate-legacy-request-methods',
|
|
6320
|
-
until: '6.0',
|
|
6321
|
-
for: '@warp-drive/core',
|
|
6322
|
-
url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',
|
|
6323
|
-
since: {
|
|
6324
|
-
enabled: '5.7',
|
|
6325
|
-
available: '5.7'
|
|
6326
|
-
}
|
|
6327
|
-
});
|
|
6328
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6329
|
-
if (!test) {
|
|
6330
|
-
throw new Error(`Attempted to call store.modelFor(), but the store instance has already been destroyed.`);
|
|
6331
|
-
}
|
|
6332
|
-
})(!this.isDestroyed) : {};
|
|
6333
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6334
|
-
if (!test) {
|
|
6335
|
-
throw new Error(`You need to pass <type> to the store's modelFor method`);
|
|
6336
|
-
}
|
|
6337
|
-
})(typeof type === 'string' && type.length) : {};
|
|
6338
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6339
|
-
if (!test) {
|
|
6340
|
-
throw new Error(`No model was found for '${type}' and no schema handles the type`);
|
|
6341
|
-
}
|
|
6342
|
-
})(this.schema.hasResource({
|
|
6343
|
-
type
|
|
6344
|
-
})) : {};
|
|
6345
|
-
return getShimClass(this, type);
|
|
6346
|
-
};
|
|
6347
|
-
Store.prototype.saveRecord = function (record, options = {}) {
|
|
6348
|
-
deprecate(`store.saveRecord is deprecated, please use store.request to initiate a save request instead.`, false, {
|
|
6349
|
-
id: 'warp-drive:deprecate-legacy-request-methods',
|
|
6350
|
-
until: '6.0',
|
|
6351
|
-
for: '@warp-drive/core',
|
|
6352
|
-
url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',
|
|
6353
|
-
since: {
|
|
6354
|
-
enabled: '5.7',
|
|
6355
|
-
available: '5.7'
|
|
6356
|
-
}
|
|
6357
|
-
});
|
|
6358
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6359
|
-
if (!test) {
|
|
6360
|
-
throw new Error(`Attempted to call store.saveRecord(), but the store instance has already been destroyed.`);
|
|
6361
|
-
}
|
|
6362
|
-
})(!(this.isDestroying || this.isDestroyed)) : {};
|
|
6363
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6364
|
-
if (!test) {
|
|
6365
|
-
throw new Error(`Unable to initiate save for a record in a disconnected state`);
|
|
6366
|
-
}
|
|
6367
|
-
})(storeFor(record, true)) : {};
|
|
6368
|
-
const identifier = recordIdentifierFor(record);
|
|
6369
|
-
const cache = this.cache;
|
|
6370
|
-
if (!identifier) {
|
|
6371
|
-
// this commonly means we're disconnected
|
|
6372
|
-
// but just in case we reject here to prevent bad things.
|
|
6373
|
-
return Promise.reject(new Error(`Record Is Disconnected`));
|
|
6374
|
-
}
|
|
6375
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6376
|
-
if (!test) {
|
|
6377
|
-
throw new Error(`Cannot initiate a save request for an unloaded record: ${identifier.lid}`);
|
|
6378
|
-
}
|
|
6379
|
-
})(this._instanceCache.recordIsLoaded(identifier)) : {};
|
|
6380
|
-
if (resourceIsFullyDeleted(this._instanceCache, identifier)) {
|
|
6381
|
-
return Promise.resolve(record);
|
|
6382
|
-
}
|
|
6383
|
-
if (!options) {
|
|
6384
|
-
options = {};
|
|
6385
|
-
}
|
|
6386
|
-
let operation = 'updateRecord';
|
|
6387
|
-
if (cache.isNew(identifier)) {
|
|
6388
|
-
operation = 'createRecord';
|
|
6389
|
-
} else if (cache.isDeleted(identifier)) {
|
|
6390
|
-
operation = 'deleteRecord';
|
|
6391
|
-
}
|
|
6392
|
-
const request = {
|
|
6393
|
-
op: operation,
|
|
6394
|
-
data: {
|
|
6395
|
-
options,
|
|
6396
|
-
record: identifier
|
|
6397
|
-
},
|
|
6398
|
-
records: [identifier],
|
|
6399
|
-
cacheOptions: {
|
|
6400
|
-
[SkipCache]: true
|
|
6401
|
-
}
|
|
6402
|
-
};
|
|
6403
|
-
return this.request(request).then(document => document.content);
|
|
6404
|
-
};
|
|
6405
|
-
}
|
|
6406
|
-
function upgradeInstanceCaches(cache) {
|
|
6407
|
-
const withReferences = cache;
|
|
6408
|
-
if (!withReferences.reference) {
|
|
6409
|
-
withReferences.reference = new WeakMap();
|
|
6410
|
-
}
|
|
6411
|
-
return withReferences;
|
|
6412
|
-
}
|
|
5904
|
+
getOrSetGlobal('AvailableShims', new WeakMap());
|
|
6413
5905
|
const MUTATION_OPS$1 = new Set(['createRecord', 'updateRecord', 'deleteRecord']);
|
|
6414
5906
|
function calcShouldFetch(store, request, hasCachedValue, identifier) {
|
|
6415
5907
|
const {
|
|
@@ -6528,14 +6020,14 @@ const CacheHandler = {
|
|
|
6528
6020
|
activeRequest.priority = {
|
|
6529
6021
|
blocking: true
|
|
6530
6022
|
};
|
|
6531
|
-
|
|
6023
|
+
{
|
|
6532
6024
|
if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
|
|
6533
6025
|
log('request', '', 'DEDUPED', identifier.lid, 'blocking', '');
|
|
6534
6026
|
}
|
|
6535
6027
|
}
|
|
6536
6028
|
return activeRequest.promise;
|
|
6537
6029
|
}
|
|
6538
|
-
|
|
6030
|
+
{
|
|
6539
6031
|
if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
|
|
6540
6032
|
log('request', '', 'ISSUED', identifier?.lid ?? context.request.url ?? context.request.op ?? '<unknown request>', 'blocking', '');
|
|
6541
6033
|
}
|
|
@@ -6582,7 +6074,7 @@ const CacheHandler = {
|
|
|
6582
6074
|
store.notifications.notify(identifier, 'state', null);
|
|
6583
6075
|
});
|
|
6584
6076
|
}
|
|
6585
|
-
|
|
6077
|
+
{
|
|
6586
6078
|
if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
|
|
6587
6079
|
if (activeRequest && identifier) {
|
|
6588
6080
|
log('request', '', 'DEDUPED', identifier.lid, activeRequest.priority.blocking ? 'blocking' : 'non-blocking', '');
|
|
@@ -6593,16 +6085,16 @@ const CacheHandler = {
|
|
|
6593
6085
|
}
|
|
6594
6086
|
store.requestManager._pending.set(context.id, promise);
|
|
6595
6087
|
}
|
|
6596
|
-
|
|
6088
|
+
{
|
|
6597
6089
|
if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
|
|
6598
6090
|
log('request', '', 'CACHE-HIT', identifier?.lid ?? context.request.url ?? context.request.op ?? '<unknown request>', 'cached', '');
|
|
6599
6091
|
}
|
|
6600
6092
|
}
|
|
6601
|
-
|
|
6093
|
+
(test => {
|
|
6602
6094
|
if (!test) {
|
|
6603
6095
|
throw new Error(`Expected a peeked request to be present`);
|
|
6604
6096
|
}
|
|
6605
|
-
})(peeked)
|
|
6097
|
+
})(peeked);
|
|
6606
6098
|
const shouldHydrate = context.request[EnableHydration] || false;
|
|
6607
6099
|
context.setResponse(peeked.response);
|
|
6608
6100
|
if ('error' in peeked) {
|
|
@@ -6626,11 +6118,11 @@ function maybeUpdateUiObjects(store, request, options, document) {
|
|
|
6626
6118
|
identifier
|
|
6627
6119
|
} = options;
|
|
6628
6120
|
if (!document || !options.shouldHydrate) {
|
|
6629
|
-
|
|
6121
|
+
(test => {
|
|
6630
6122
|
if (!test) {
|
|
6631
6123
|
throw new Error(`The CacheHandler expected response content but none was found`);
|
|
6632
6124
|
}
|
|
6633
|
-
})(!options.shouldHydrate)
|
|
6125
|
+
})(!options.shouldHydrate);
|
|
6634
6126
|
return document ?? null;
|
|
6635
6127
|
}
|
|
6636
6128
|
if (identifier) {
|
|
@@ -6763,11 +6255,11 @@ function fetchContentAndHydrate(next, context, identifier, priority) {
|
|
|
6763
6255
|
if (!isMut) {
|
|
6764
6256
|
return promise;
|
|
6765
6257
|
}
|
|
6766
|
-
|
|
6258
|
+
(test => {
|
|
6767
6259
|
if (!test) {
|
|
6768
6260
|
throw new Error(`Expected a mutation`);
|
|
6769
6261
|
}
|
|
6770
|
-
})(isMutation(context.request))
|
|
6262
|
+
})(isMutation(context.request));
|
|
6771
6263
|
|
|
6772
6264
|
// for mutations we need to enqueue the promise with the requestStateService
|
|
6773
6265
|
// TODO should we enque a request per record in records?
|
|
@@ -6780,57 +6272,49 @@ function fetchContentAndHydrate(next, context, identifier, priority) {
|
|
|
6780
6272
|
}]
|
|
6781
6273
|
});
|
|
6782
6274
|
}
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
})(!('id' in resource) || typeof resource.type === 'string') : {};
|
|
6805
|
-
return resource;
|
|
6806
|
-
} else {
|
|
6807
|
-
const trueId = coerceId(id);
|
|
6808
|
-
if (!isNonEmptyString(trueId)) {
|
|
6809
|
-
if (isNonEmptyString(lid)) {
|
|
6810
|
-
return {
|
|
6811
|
-
lid
|
|
6812
|
-
};
|
|
6813
|
-
}
|
|
6814
|
-
throw new Error('Expected either id or lid to be a valid string');
|
|
6815
|
-
}
|
|
6816
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
6817
|
-
if (!test) {
|
|
6818
|
-
throw new Error('type must be a string');
|
|
6819
|
-
}
|
|
6820
|
-
})(typeof type === 'string') : {};
|
|
6821
|
-
if (isNonEmptyString(lid)) {
|
|
6822
|
-
return {
|
|
6823
|
-
type,
|
|
6824
|
-
id: trueId,
|
|
6825
|
-
lid
|
|
6826
|
-
};
|
|
6827
|
-
}
|
|
6828
|
-
return {
|
|
6829
|
-
type,
|
|
6830
|
-
id: trueId
|
|
6831
|
-
};
|
|
6275
|
+
|
|
6276
|
+
/**
|
|
6277
|
+
A `ManyArray` is a `MutableArray` that represents the contents of a has-many
|
|
6278
|
+
relationship.
|
|
6279
|
+
|
|
6280
|
+
The `ManyArray` is instantiated lazily the first time the relationship is
|
|
6281
|
+
requested.
|
|
6282
|
+
|
|
6283
|
+
This class is not intended to be directly instantiated by consuming applications.
|
|
6284
|
+
|
|
6285
|
+
### Inverses
|
|
6286
|
+
|
|
6287
|
+
Often, the relationships in Ember Data applications will have
|
|
6288
|
+
an inverse. For example, imagine the following models are
|
|
6289
|
+
defined:
|
|
6290
|
+
|
|
6291
|
+
```js [app/models/post.js]
|
|
6292
|
+
import Model, { hasMany } from '@ember-data/model';
|
|
6293
|
+
|
|
6294
|
+
export default class PostModel extends Model {
|
|
6295
|
+
@hasMany('comment') comments;
|
|
6832
6296
|
}
|
|
6833
|
-
|
|
6297
|
+
```
|
|
6298
|
+
|
|
6299
|
+
```js [app/models/comment.js]
|
|
6300
|
+
import { Model, belongsTo } from '@warp-drive/legacy/model';
|
|
6301
|
+
|
|
6302
|
+
export default class CommentModel extends Model {
|
|
6303
|
+
@belongsTo('post') post;
|
|
6304
|
+
}
|
|
6305
|
+
```
|
|
6306
|
+
|
|
6307
|
+
If you created a new instance of `Post` and added
|
|
6308
|
+
a `Comment` record to its `comments` has-many
|
|
6309
|
+
relationship, you would expect the comment's `post`
|
|
6310
|
+
property to be set to the post that contained
|
|
6311
|
+
the has-many.
|
|
6312
|
+
|
|
6313
|
+
We call the record to which a relationship belongs-to the
|
|
6314
|
+
relationship's _owner_.
|
|
6315
|
+
|
|
6316
|
+
@public
|
|
6317
|
+
*/
|
|
6834
6318
|
|
|
6835
6319
|
/**
|
|
6836
6320
|
* The options for {@link createLegacyManyArray}
|
|
@@ -6896,27 +6380,6 @@ function _MUTATE(target, receiver, prop, args, _SIGNAL) {
|
|
|
6896
6380
|
{
|
|
6897
6381
|
const newValues = extractIdentifiersFromRecords(args);
|
|
6898
6382
|
assertNoDuplicates(collection, target, currentState => currentState.push(...newValues), `Cannot push duplicates to a hasMany's state.`);
|
|
6899
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_MANY_ARRAY_DUPLICATES)) {
|
|
6900
|
-
// dedupe
|
|
6901
|
-
const seen = new Set(target);
|
|
6902
|
-
const unique = new Set();
|
|
6903
|
-
args.forEach(item => {
|
|
6904
|
-
const identifier = recordIdentifierFor(item);
|
|
6905
|
-
if (!seen.has(identifier)) {
|
|
6906
|
-
seen.add(identifier);
|
|
6907
|
-
unique.add(item);
|
|
6908
|
-
}
|
|
6909
|
-
});
|
|
6910
|
-
const newArgs = Array.from(unique);
|
|
6911
|
-
const result = Reflect.apply(target[prop], receiver, newArgs);
|
|
6912
|
-
if (newArgs.length) {
|
|
6913
|
-
mutateAddToRelatedRecords(collection, {
|
|
6914
|
-
value: extractIdentifiersFromRecords(newArgs)
|
|
6915
|
-
}, _SIGNAL);
|
|
6916
|
-
}
|
|
6917
|
-
return result;
|
|
6918
|
-
}
|
|
6919
|
-
|
|
6920
6383
|
// else, no dedupe, error on duplicates
|
|
6921
6384
|
const result = Reflect.apply(target[prop], receiver, args);
|
|
6922
6385
|
if (newValues.length) {
|
|
@@ -6940,28 +6403,6 @@ function _MUTATE(target, receiver, prop, args, _SIGNAL) {
|
|
|
6940
6403
|
{
|
|
6941
6404
|
const newValues = extractIdentifiersFromRecords(args);
|
|
6942
6405
|
assertNoDuplicates(collection, target, currentState => currentState.unshift(...newValues), `Cannot unshift duplicates to a hasMany's state.`);
|
|
6943
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_MANY_ARRAY_DUPLICATES)) {
|
|
6944
|
-
// dedupe
|
|
6945
|
-
const seen = new Set(target);
|
|
6946
|
-
const unique = new Set();
|
|
6947
|
-
args.forEach(item => {
|
|
6948
|
-
const identifier = recordIdentifierFor(item);
|
|
6949
|
-
if (!seen.has(identifier)) {
|
|
6950
|
-
seen.add(identifier);
|
|
6951
|
-
unique.add(item);
|
|
6952
|
-
}
|
|
6953
|
-
});
|
|
6954
|
-
const newArgs = Array.from(unique);
|
|
6955
|
-
const result = Reflect.apply(target[prop], receiver, newArgs);
|
|
6956
|
-
if (newArgs.length) {
|
|
6957
|
-
mutateAddToRelatedRecords(collection, {
|
|
6958
|
-
value: extractIdentifiersFromRecords(newArgs),
|
|
6959
|
-
index: 0
|
|
6960
|
-
}, _SIGNAL);
|
|
6961
|
-
}
|
|
6962
|
-
return result;
|
|
6963
|
-
}
|
|
6964
|
-
|
|
6965
6406
|
// else, no dedupe, error on duplicates
|
|
6966
6407
|
const result = Reflect.apply(target[prop], receiver, args);
|
|
6967
6408
|
if (newValues.length) {
|
|
@@ -6997,16 +6438,6 @@ function _MUTATE(target, receiver, prop, args, _SIGNAL) {
|
|
|
6997
6438
|
if (start === 0 && deleteCount === collection[Context].source.length) {
|
|
6998
6439
|
const newValues = extractIdentifiersFromRecords(adds);
|
|
6999
6440
|
assertNoDuplicates(collection, target, currentState => currentState.splice(start, deleteCount, ...newValues), `Cannot replace a hasMany's state with a new state that contains duplicates.`);
|
|
7000
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_MANY_ARRAY_DUPLICATES)) {
|
|
7001
|
-
// dedupe
|
|
7002
|
-
const current = new Set(adds);
|
|
7003
|
-
const unique = Array.from(current);
|
|
7004
|
-
const newArgs = [start, deleteCount].concat(unique);
|
|
7005
|
-
const result = Reflect.apply(target[prop], receiver, newArgs);
|
|
7006
|
-
mutateReplaceRelatedRecords(collection, extractIdentifiersFromRecords(unique), _SIGNAL);
|
|
7007
|
-
return result;
|
|
7008
|
-
}
|
|
7009
|
-
|
|
7010
6441
|
// else, no dedupe, error on duplicates
|
|
7011
6442
|
const result = Reflect.apply(target[prop], receiver, args);
|
|
7012
6443
|
mutateReplaceRelatedRecords(collection, newValues, _SIGNAL);
|
|
@@ -7014,36 +6445,6 @@ function _MUTATE(target, receiver, prop, args, _SIGNAL) {
|
|
|
7014
6445
|
}
|
|
7015
6446
|
const newValues = extractIdentifiersFromRecords(adds);
|
|
7016
6447
|
assertNoDuplicates(collection, target, currentState => currentState.splice(start, deleteCount, ...newValues), `Cannot splice a hasMany's state with a new state that contains duplicates.`);
|
|
7017
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_MANY_ARRAY_DUPLICATES)) {
|
|
7018
|
-
// dedupe
|
|
7019
|
-
const currentState = target.slice();
|
|
7020
|
-
currentState.splice(start, deleteCount);
|
|
7021
|
-
const seen = new Set(currentState);
|
|
7022
|
-
const unique = [];
|
|
7023
|
-
adds.forEach(item => {
|
|
7024
|
-
const identifier = recordIdentifierFor(item);
|
|
7025
|
-
if (!seen.has(identifier)) {
|
|
7026
|
-
seen.add(identifier);
|
|
7027
|
-
unique.push(item);
|
|
7028
|
-
}
|
|
7029
|
-
});
|
|
7030
|
-
const newArgs = [start, deleteCount, ...unique];
|
|
7031
|
-
const result = Reflect.apply(target[prop], receiver, newArgs);
|
|
7032
|
-
if (deleteCount > 0) {
|
|
7033
|
-
mutateRemoveFromRelatedRecords(collection, {
|
|
7034
|
-
value: result.map(recordIdentifierFor),
|
|
7035
|
-
index: start
|
|
7036
|
-
}, _SIGNAL);
|
|
7037
|
-
}
|
|
7038
|
-
if (unique.length > 0) {
|
|
7039
|
-
mutateAddToRelatedRecords(collection, {
|
|
7040
|
-
value: extractIdentifiersFromRecords(unique),
|
|
7041
|
-
index: start
|
|
7042
|
-
}, _SIGNAL);
|
|
7043
|
-
}
|
|
7044
|
-
return result;
|
|
7045
|
-
}
|
|
7046
|
-
|
|
7047
6448
|
// else, no dedupe, error on duplicates
|
|
7048
6449
|
const result = Reflect.apply(target[prop], receiver, args);
|
|
7049
6450
|
if (deleteCount > 0) {
|
|
@@ -7061,11 +6462,11 @@ function _MUTATE(target, receiver, prop, args, _SIGNAL) {
|
|
|
7061
6462
|
return result;
|
|
7062
6463
|
}
|
|
7063
6464
|
default:
|
|
7064
|
-
|
|
6465
|
+
(test => {
|
|
7065
6466
|
{
|
|
7066
6467
|
throw new Error(`unable to convert ${prop} into a transaction that updates the cache state for this record array`);
|
|
7067
6468
|
}
|
|
7068
|
-
})()
|
|
6469
|
+
})();
|
|
7069
6470
|
}
|
|
7070
6471
|
}
|
|
7071
6472
|
function notify() {
|
|
@@ -7075,11 +6476,11 @@ function reload(options) {
|
|
|
7075
6476
|
const {
|
|
7076
6477
|
manager
|
|
7077
6478
|
} = this[Context];
|
|
7078
|
-
|
|
6479
|
+
(test => {
|
|
7079
6480
|
if (!test) {
|
|
7080
6481
|
throw new Error(`Expected the manager for ManyArray to implement reloadHasMany`);
|
|
7081
6482
|
}
|
|
7082
|
-
})(typeof manager.reloadHasMany === 'function')
|
|
6483
|
+
})(typeof manager.reloadHasMany === 'function');
|
|
7083
6484
|
// TODO this is odd, we don't ask the store for anything else like this?
|
|
7084
6485
|
return manager.reloadHasMany(this.key, options);
|
|
7085
6486
|
}
|
|
@@ -7087,11 +6488,11 @@ function createRecord(hash) {
|
|
|
7087
6488
|
const {
|
|
7088
6489
|
store
|
|
7089
6490
|
} = this[Context];
|
|
7090
|
-
|
|
6491
|
+
(test => {
|
|
7091
6492
|
if (!test) {
|
|
7092
6493
|
throw new Error(`Expected modelName to be set`);
|
|
7093
6494
|
}
|
|
7094
|
-
})(this.modelName)
|
|
6495
|
+
})(this.modelName);
|
|
7095
6496
|
const record = store.createRecord(this.modelName, hash);
|
|
7096
6497
|
this.push(record);
|
|
7097
6498
|
return record;
|
|
@@ -7100,7 +6501,7 @@ function destroyLegacyManyArray() {
|
|
|
7100
6501
|
destroy.call(this, false);
|
|
7101
6502
|
}
|
|
7102
6503
|
function assertRecordPassedToHasMany(record) {
|
|
7103
|
-
|
|
6504
|
+
(test => {
|
|
7104
6505
|
if (!test) {
|
|
7105
6506
|
throw new Error(`All elements of a hasMany relationship must be instances of Model, you passed ${typeof record}`);
|
|
7106
6507
|
}
|
|
@@ -7111,7 +6512,7 @@ function assertRecordPassedToHasMany(record) {
|
|
|
7111
6512
|
} catch {
|
|
7112
6513
|
return false;
|
|
7113
6514
|
}
|
|
7114
|
-
}())
|
|
6515
|
+
}());
|
|
7115
6516
|
}
|
|
7116
6517
|
function extractIdentifiersFromRecords(records) {
|
|
7117
6518
|
return records.map(extractIdentifierFromRecord);
|
|
@@ -7126,17 +6527,7 @@ function assertNoDuplicates(collection, target, callback, reason) {
|
|
|
7126
6527
|
callback(state);
|
|
7127
6528
|
if (state.length !== new Set(state).size) {
|
|
7128
6529
|
const duplicates = state.filter((currentValue, currentIndex) => state.indexOf(currentValue) !== currentIndex);
|
|
7129
|
-
|
|
7130
|
-
deprecate(`${reason} This behavior is deprecated. Found duplicates for the following records within the new state provided to \`<${identifier.type}:${identifier.id || identifier.lid}>.${collection.key}\`\n\t- ${Array.from(new Set(duplicates)).map(r => isResourceKey(r) ? r.lid : recordIdentifierFor(r).lid).sort((a, b) => a.localeCompare(b)).join('\n\t- ')}`, false, {
|
|
7131
|
-
id: 'ember-data:deprecate-many-array-duplicates',
|
|
7132
|
-
for: 'ember-data',
|
|
7133
|
-
until: '6.0',
|
|
7134
|
-
since: {
|
|
7135
|
-
enabled: '5.3',
|
|
7136
|
-
available: '4.13'
|
|
7137
|
-
}
|
|
7138
|
-
});
|
|
7139
|
-
} else {
|
|
6530
|
+
{
|
|
7140
6531
|
throw new Error(`${reason} Found duplicates for the following records within the new state provided to \`<${identifier.type}:${identifier.id || identifier.lid}>.${collection.key}\`\n\t- ${Array.from(new Set(duplicates)).map(r => isResourceKey(r) ? r.lid : recordIdentifierFor(r).lid).sort((a, b) => a.localeCompare(b)).join('\n\t- ')}`);
|
|
7141
6532
|
}
|
|
7142
6533
|
}
|
|
@@ -7200,11 +6591,11 @@ function mutate(collection, mutation, _SIGNAL) {
|
|
|
7200
6591
|
const {
|
|
7201
6592
|
manager
|
|
7202
6593
|
} = collection[Context];
|
|
7203
|
-
|
|
6594
|
+
(test => {
|
|
7204
6595
|
if (!test) {
|
|
7205
6596
|
throw new Error(`Expected the manager for ManyArray to implement mutate`);
|
|
7206
6597
|
}
|
|
7207
|
-
})(typeof manager.mutate === 'function')
|
|
6598
|
+
})(typeof manager.mutate === 'function');
|
|
7208
6599
|
manager.mutate(mutation);
|
|
7209
6600
|
notifyInternalSignal(_SIGNAL);
|
|
7210
6601
|
}
|
|
@@ -7685,11 +7076,11 @@ class RequestSubscription {
|
|
|
7685
7076
|
this._latestRequest = reqState.refresh(true);
|
|
7686
7077
|
break;
|
|
7687
7078
|
default:
|
|
7688
|
-
|
|
7079
|
+
(test => {
|
|
7689
7080
|
{
|
|
7690
7081
|
throw new Error(`Invalid ${mode ? 'update mode' : '@autorefreshBehavior'} for <Request />: ${isNeverString(val)}`);
|
|
7691
7082
|
}
|
|
7692
|
-
})()
|
|
7083
|
+
})();
|
|
7693
7084
|
}
|
|
7694
7085
|
if (val !== 'refresh') {
|
|
7695
7086
|
this._localRequest = this._latestRequest;
|
|
@@ -7776,11 +7167,11 @@ class RequestSubscription {
|
|
|
7776
7167
|
request,
|
|
7777
7168
|
query
|
|
7778
7169
|
} = this._args;
|
|
7779
|
-
|
|
7170
|
+
(test => {
|
|
7780
7171
|
if (!test) {
|
|
7781
7172
|
throw new Error(`Cannot use both @request and @query args with the <Request> component`);
|
|
7782
7173
|
}
|
|
7783
|
-
})(!request || !query)
|
|
7174
|
+
})(!request || !query);
|
|
7784
7175
|
const {
|
|
7785
7176
|
_localRequest,
|
|
7786
7177
|
_originalRequest,
|
|
@@ -7797,18 +7188,18 @@ class RequestSubscription {
|
|
|
7797
7188
|
if (request) {
|
|
7798
7189
|
return request;
|
|
7799
7190
|
}
|
|
7800
|
-
|
|
7191
|
+
(test => {
|
|
7801
7192
|
if (!test) {
|
|
7802
7193
|
throw new Error(`You must provide either @request or an @query arg with the <Request> component`);
|
|
7803
7194
|
}
|
|
7804
|
-
})(query)
|
|
7195
|
+
})(query);
|
|
7805
7196
|
return this.store.request(query);
|
|
7806
7197
|
}
|
|
7807
7198
|
static {
|
|
7808
7199
|
decorateMethodV2(this.prototype, "_request", [memoized]);
|
|
7809
7200
|
}
|
|
7810
7201
|
get request() {
|
|
7811
|
-
|
|
7202
|
+
{
|
|
7812
7203
|
try {
|
|
7813
7204
|
const request = this._request;
|
|
7814
7205
|
this._updateSubscriptions();
|
|
@@ -7820,10 +7211,6 @@ class RequestSubscription {
|
|
|
7820
7211
|
cause: e
|
|
7821
7212
|
});
|
|
7822
7213
|
}
|
|
7823
|
-
} else {
|
|
7824
|
-
const request = this._request;
|
|
7825
|
-
this._updateSubscriptions();
|
|
7826
|
-
return request;
|
|
7827
7214
|
}
|
|
7828
7215
|
}
|
|
7829
7216
|
static {
|
|
@@ -8206,21 +7593,21 @@ function createRequestState(future) {
|
|
|
8206
7593
|
promiseState._request = future;
|
|
8207
7594
|
// @ts-expect-error - we still attach it for PendingState
|
|
8208
7595
|
promiseState.reload = () => {
|
|
8209
|
-
|
|
7596
|
+
(test => {
|
|
8210
7597
|
if (!test) {
|
|
8211
7598
|
throw new Error(`Cannot reload a request that is still pending. Await or abort the original request first.`);
|
|
8212
7599
|
}
|
|
8213
|
-
})(!promiseState.isPending)
|
|
7600
|
+
})(!promiseState.isPending);
|
|
8214
7601
|
return performRefresh(future.requester, promiseState.request, true);
|
|
8215
7602
|
};
|
|
8216
7603
|
|
|
8217
7604
|
// @ts-expect-error - we still attach it for PendingState
|
|
8218
7605
|
promiseState.refresh = (usePolicy = false) => {
|
|
8219
|
-
|
|
7606
|
+
(test => {
|
|
8220
7607
|
if (!test) {
|
|
8221
7608
|
throw new Error(`Cannot refresh a request that is still pending. Await or abort the original request first.`);
|
|
8222
7609
|
}
|
|
8223
|
-
})(!promiseState.isPending)
|
|
7610
|
+
})(!promiseState.isPending);
|
|
8224
7611
|
return performRefresh(future.requester, promiseState.request, usePolicy === true ? null : false);
|
|
8225
7612
|
};
|
|
8226
7613
|
if (state) {
|
|
@@ -8334,18 +7721,18 @@ function getRequestState(future) {
|
|
|
8334
7721
|
return state;
|
|
8335
7722
|
}
|
|
8336
7723
|
function getAliasField(context) {
|
|
8337
|
-
|
|
7724
|
+
(test => {
|
|
8338
7725
|
{
|
|
8339
7726
|
throw new Error(`Alias field access is not implemented`);
|
|
8340
7727
|
}
|
|
8341
|
-
})()
|
|
7728
|
+
})();
|
|
8342
7729
|
}
|
|
8343
7730
|
function setAliasField(context) {
|
|
8344
|
-
|
|
7731
|
+
(test => {
|
|
8345
7732
|
{
|
|
8346
7733
|
throw new Error(`Alias field setting is not implemented`);
|
|
8347
7734
|
}
|
|
8348
|
-
})()
|
|
7735
|
+
})();
|
|
8349
7736
|
return false;
|
|
8350
7737
|
}
|
|
8351
7738
|
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']);
|
|
@@ -8375,11 +7762,11 @@ function safeForEach(instance, arr, store, callback, target) {
|
|
|
8375
7762
|
}
|
|
8376
7763
|
// clone to prevent mutation
|
|
8377
7764
|
arr = arr.slice();
|
|
8378
|
-
|
|
7765
|
+
(test => {
|
|
8379
7766
|
if (!test) {
|
|
8380
7767
|
throw new Error('`forEach` expects a function as first argument.');
|
|
8381
7768
|
}
|
|
8382
|
-
})(typeof callback === 'function')
|
|
7769
|
+
})(typeof callback === 'function');
|
|
8383
7770
|
|
|
8384
7771
|
// because we retrieveLatest above we need not worry if array is mutated during iteration
|
|
8385
7772
|
// by unloadRecord/rollbackAttributes
|
|
@@ -8477,11 +7864,11 @@ class ManagedArray {
|
|
|
8477
7864
|
// the special string "@hash" which tells us to treat field.type as a hashFn name with which
|
|
8478
7865
|
// to calc the type.
|
|
8479
7866
|
if (typePath === '@hash') {
|
|
8480
|
-
|
|
7867
|
+
(test => {
|
|
8481
7868
|
if (!test) {
|
|
8482
7869
|
throw new Error(`Expected the field to define a hashFn as its type`);
|
|
8483
7870
|
}
|
|
8484
|
-
})(field.type)
|
|
7871
|
+
})(field.type);
|
|
8485
7872
|
const hashFn = schema.hashFn({
|
|
8486
7873
|
type: field.type
|
|
8487
7874
|
});
|
|
@@ -8489,18 +7876,18 @@ class ManagedArray {
|
|
|
8489
7876
|
objectType = hashFn(rawValue, null, null);
|
|
8490
7877
|
} else {
|
|
8491
7878
|
objectType = rawValue[typePath];
|
|
8492
|
-
|
|
7879
|
+
(test => {
|
|
8493
7880
|
if (!test) {
|
|
8494
7881
|
throw new Error(`Expected the type path for the field to be a value on the raw object`);
|
|
8495
7882
|
}
|
|
8496
|
-
})(typePath && objectType && typeof objectType === 'string')
|
|
7883
|
+
})(typePath && objectType && typeof objectType === 'string');
|
|
8497
7884
|
}
|
|
8498
7885
|
} else {
|
|
8499
|
-
|
|
7886
|
+
(test => {
|
|
8500
7887
|
if (!test) {
|
|
8501
7888
|
throw new Error(`A non-polymorphic SchemaArrayField must provide a SchemaObject type in its definition`);
|
|
8502
7889
|
}
|
|
8503
|
-
})(field.type)
|
|
7890
|
+
})(field.type);
|
|
8504
7891
|
objectType = field.type;
|
|
8505
7892
|
}
|
|
8506
7893
|
|
|
@@ -8525,37 +7912,37 @@ class ManagedArray {
|
|
|
8525
7912
|
// and, we likely should lookup the associated field and throw an error IF
|
|
8526
7913
|
// the given field does not exist OR
|
|
8527
7914
|
// the field is anything other than a GenericField or LegacyAttributeField.
|
|
8528
|
-
|
|
7915
|
+
{
|
|
8529
7916
|
const isPathKeyMode = KeyMode !== '@identity' && KeyMode !== '@index';
|
|
8530
7917
|
if (isPathKeyMode) {
|
|
8531
|
-
|
|
7918
|
+
(test => {
|
|
8532
7919
|
if (!test) {
|
|
8533
7920
|
throw new Error('mode must be a string');
|
|
8534
7921
|
}
|
|
8535
|
-
})(typeof KeyMode === 'string' && KeyMode !== '')
|
|
7922
|
+
})(typeof KeyMode === 'string' && KeyMode !== '');
|
|
8536
7923
|
const modeField = schema.fields({
|
|
8537
7924
|
type: objectType
|
|
8538
7925
|
}).get(KeyMode);
|
|
8539
|
-
|
|
7926
|
+
(test => {
|
|
8540
7927
|
if (!test) {
|
|
8541
7928
|
throw new Error('field must exist in schema');
|
|
8542
7929
|
}
|
|
8543
|
-
})(modeField)
|
|
8544
|
-
|
|
7930
|
+
})(modeField);
|
|
7931
|
+
(test => {
|
|
8545
7932
|
if (!test) {
|
|
8546
7933
|
throw new Error('field must be a GenericField or LegacyAttributeField');
|
|
8547
7934
|
}
|
|
8548
|
-
})(modeField.kind === 'field' || modeField.kind === 'attribute')
|
|
7935
|
+
})(modeField.kind === 'field' || modeField.kind === 'attribute');
|
|
8549
7936
|
}
|
|
8550
7937
|
}
|
|
8551
7938
|
schemaObjectKeyValue = KeyMode === '@identity' ? rawValue : KeyMode === '@index' ? index : rawValue[KeyMode];
|
|
8552
7939
|
}
|
|
8553
7940
|
if (!schemaObjectKeyValue && schemaObjectKeyValue !== 0) {
|
|
8554
|
-
|
|
7941
|
+
(test => {
|
|
8555
7942
|
{
|
|
8556
7943
|
throw new Error(`Unexpected out of bounds access on SchemaArray`);
|
|
8557
7944
|
}
|
|
8558
|
-
})()
|
|
7945
|
+
})();
|
|
8559
7946
|
return undefined;
|
|
8560
7947
|
}
|
|
8561
7948
|
const recordRef = ManagedRecordRefs.get(schemaObjectKeyValue);
|
|
@@ -8652,11 +8039,11 @@ class ManagedArray {
|
|
|
8652
8039
|
if (context.path) {
|
|
8653
8040
|
errorPath = context.path[context.path.length - 1];
|
|
8654
8041
|
}
|
|
8655
|
-
|
|
8042
|
+
(test => {
|
|
8656
8043
|
{
|
|
8657
8044
|
throw new Error(`Cannot set ${String(prop)} on ${errorPath} because the ReactiveResource is not editable`);
|
|
8658
8045
|
}
|
|
8659
|
-
})()
|
|
8046
|
+
})();
|
|
8660
8047
|
return false;
|
|
8661
8048
|
}
|
|
8662
8049
|
if (prop === 'identifier') {
|
|
@@ -8712,13 +8099,7 @@ class ManagedArray {
|
|
|
8712
8099
|
const desc = {
|
|
8713
8100
|
enumerable: true,
|
|
8714
8101
|
configurable: false,
|
|
8715
|
-
get: function () {
|
|
8716
|
-
// here to support computed chains
|
|
8717
|
-
// and {{#each}}
|
|
8718
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_COMPUTED_CHAINS)) {
|
|
8719
|
-
return this;
|
|
8720
|
-
}
|
|
8721
|
-
}
|
|
8102
|
+
get: function () {}
|
|
8722
8103
|
};
|
|
8723
8104
|
// compat(desc);
|
|
8724
8105
|
Object.defineProperty(ManagedArray.prototype, '[]', desc);
|
|
@@ -8798,11 +8179,11 @@ function setArrayField(context) {
|
|
|
8798
8179
|
const rawValue = value === null ? null : field.type ? value.map(item => transform.serialize(item, field.options ?? null, record)) : value?.slice();
|
|
8799
8180
|
cache.setAttr(context.resourceKey, context.path, rawValue);
|
|
8800
8181
|
if (peeked) {
|
|
8801
|
-
|
|
8182
|
+
(test => {
|
|
8802
8183
|
if (!test) {
|
|
8803
8184
|
throw new Error(`Expected the peekManagedArray for ${field.kind} to return a ManagedArray`);
|
|
8804
8185
|
}
|
|
8805
|
-
})(ARRAY_SIGNAL in peeked)
|
|
8186
|
+
})(ARRAY_SIGNAL in peeked);
|
|
8806
8187
|
const arrSignal = peeked[ARRAY_SIGNAL];
|
|
8807
8188
|
arrSignal.isStale = true;
|
|
8808
8189
|
// TODO run array destroy?
|
|
@@ -8853,11 +8234,11 @@ function getBelongsToField(context) {
|
|
|
8853
8234
|
}
|
|
8854
8235
|
|
|
8855
8236
|
// FIXME move this to a "LegacyMode" make this part of "PolarisMode"
|
|
8856
|
-
|
|
8237
|
+
(test => {
|
|
8857
8238
|
if (!test) {
|
|
8858
8239
|
throw new Error(`Can only use belongsTo fields when the resource is in legacy mode`);
|
|
8859
8240
|
}
|
|
8860
|
-
})(context.legacy)
|
|
8241
|
+
})(context.legacy);
|
|
8861
8242
|
return schema._kind('@legacy', 'belongsTo').get(store, context.record, resourceKey, field);
|
|
8862
8243
|
}
|
|
8863
8244
|
function setBelongsToField(context) {
|
|
@@ -8867,28 +8248,28 @@ function setBelongsToField(context) {
|
|
|
8867
8248
|
const {
|
|
8868
8249
|
schema
|
|
8869
8250
|
} = store;
|
|
8870
|
-
|
|
8251
|
+
(test => {
|
|
8871
8252
|
if (!test) {
|
|
8872
8253
|
throw new Error(`Can only mutate belongsTo fields when the resource is in legacy mode`);
|
|
8873
8254
|
}
|
|
8874
|
-
})(context.legacy)
|
|
8255
|
+
})(context.legacy);
|
|
8875
8256
|
schema._kind('@legacy', 'belongsTo').set(store, context.record, context.resourceKey, context.field, context.value);
|
|
8876
8257
|
return true;
|
|
8877
8258
|
}
|
|
8878
8259
|
function getCollectionField(context) {
|
|
8879
8260
|
entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
8880
|
-
|
|
8261
|
+
(test => {
|
|
8881
8262
|
{
|
|
8882
8263
|
throw new Error(`Accessing collection fields is not yet implemented`);
|
|
8883
8264
|
}
|
|
8884
|
-
})()
|
|
8265
|
+
})();
|
|
8885
8266
|
}
|
|
8886
8267
|
function setCollectionField(context) {
|
|
8887
|
-
|
|
8268
|
+
(test => {
|
|
8888
8269
|
{
|
|
8889
8270
|
throw new Error(`Setting collection fields is not yet implemented`);
|
|
8890
8271
|
}
|
|
8891
|
-
})()
|
|
8272
|
+
})();
|
|
8892
8273
|
return false;
|
|
8893
8274
|
}
|
|
8894
8275
|
function getDerivedField(context) {
|
|
@@ -8898,11 +8279,11 @@ function getDerivedField(context) {
|
|
|
8898
8279
|
return schema.derivation(context.field)(context.record, context.field.options ?? null, context.field.name);
|
|
8899
8280
|
}
|
|
8900
8281
|
function setDerivedField(context) {
|
|
8901
|
-
|
|
8282
|
+
(test => {
|
|
8902
8283
|
{
|
|
8903
8284
|
throw new Error(`ILLEGAL SET: Cannot set '${context.path.join('.')}' on '${context.resourceKey.type}' as ${context.field.kind} fields are not mutable`);
|
|
8904
8285
|
}
|
|
8905
|
-
})()
|
|
8286
|
+
})();
|
|
8906
8287
|
return false;
|
|
8907
8288
|
}
|
|
8908
8289
|
function getGenericField(context) {
|
|
@@ -8977,11 +8358,11 @@ class ManyArrayManager {
|
|
|
8977
8358
|
reloadHasMany(key, options) {
|
|
8978
8359
|
// FIXME field needs to use sourceKey
|
|
8979
8360
|
const field = this.store.schema.fields(this.identifier).get(key);
|
|
8980
|
-
|
|
8361
|
+
(test => {
|
|
8981
8362
|
if (!test) {
|
|
8982
8363
|
throw new Error(`Expected a hasMany field for ${key}`);
|
|
8983
8364
|
}
|
|
8984
|
-
})(field?.kind === 'hasMany')
|
|
8365
|
+
})(field?.kind === 'hasMany');
|
|
8985
8366
|
const cacheOptions = options ? extractCacheOptions(options) : {
|
|
8986
8367
|
reload: true
|
|
8987
8368
|
};
|
|
@@ -9009,11 +8390,11 @@ class ManyArrayManager {
|
|
|
9009
8390
|
}
|
|
9010
8391
|
function getRelatedLink(resource) {
|
|
9011
8392
|
const related = resource.links?.related;
|
|
9012
|
-
|
|
8393
|
+
(test => {
|
|
9013
8394
|
if (!test) {
|
|
9014
8395
|
throw new Error(`Expected a related link`);
|
|
9015
8396
|
}
|
|
9016
|
-
})(related)
|
|
8397
|
+
})(related);
|
|
9017
8398
|
return typeof related === 'object' ? related.href : related;
|
|
9018
8399
|
}
|
|
9019
8400
|
function extractCacheOptions(options) {
|
|
@@ -9074,27 +8455,27 @@ function getHasManyField(context) {
|
|
|
9074
8455
|
signal.value = managedArray;
|
|
9075
8456
|
return managedArray;
|
|
9076
8457
|
}
|
|
9077
|
-
|
|
8458
|
+
(test => {
|
|
9078
8459
|
if (!test) {
|
|
9079
8460
|
throw new Error(`Can only use hasMany fields when the resource is in legacy mode`);
|
|
9080
8461
|
}
|
|
9081
|
-
})(context.legacy)
|
|
8462
|
+
})(context.legacy);
|
|
9082
8463
|
return store.schema._kind('@legacy', 'hasMany').get(store, context.record, context.resourceKey, field);
|
|
9083
8464
|
}
|
|
9084
8465
|
function setHasManyField(context) {
|
|
9085
8466
|
const {
|
|
9086
8467
|
store
|
|
9087
8468
|
} = context;
|
|
9088
|
-
|
|
8469
|
+
(test => {
|
|
9089
8470
|
if (!test) {
|
|
9090
8471
|
throw new Error(`Can only use hasMany fields when the resource is in legacy mode`);
|
|
9091
8472
|
}
|
|
9092
|
-
})(context.legacy)
|
|
9093
|
-
|
|
8473
|
+
})(context.legacy);
|
|
8474
|
+
(test => {
|
|
9094
8475
|
if (!test) {
|
|
9095
8476
|
throw new Error(`You must pass an array of records to set a hasMany relationship`);
|
|
9096
8477
|
}
|
|
9097
|
-
})(Array.isArray(context.value))
|
|
8478
|
+
})(Array.isArray(context.value));
|
|
9098
8479
|
store.schema._kind('@legacy', 'hasMany').set(store, context.record, context.resourceKey, context.field, context.value);
|
|
9099
8480
|
return true;
|
|
9100
8481
|
}
|
|
@@ -9108,21 +8489,21 @@ function getHashField(context) {
|
|
|
9108
8489
|
schema,
|
|
9109
8490
|
cache
|
|
9110
8491
|
} = context.store;
|
|
9111
|
-
|
|
8492
|
+
(test => {
|
|
9112
8493
|
if (!test) {
|
|
9113
8494
|
throw new Error(`Cannot use a ${field.kind} directly on a resource.`);
|
|
9114
8495
|
}
|
|
9115
|
-
})(Array.isArray(path) && path.length > 1)
|
|
8496
|
+
})(Array.isArray(path) && path.length > 1);
|
|
9116
8497
|
const realPath = path.slice(0, -1);
|
|
9117
8498
|
const rawData = context.editable ? cache.getAttr(resourceKey, realPath) : cache.getRemoteAttr(resourceKey, realPath);
|
|
9118
8499
|
return schema.hashFn(field)(rawData, field.options ?? null, field.name ?? null);
|
|
9119
8500
|
}
|
|
9120
8501
|
function setHashField(context) {
|
|
9121
|
-
|
|
8502
|
+
(test => {
|
|
9122
8503
|
{
|
|
9123
8504
|
throw new Error(`ILLEGAL SET: Cannot set '${Array.isArray(context.path) ? context.path.join('.') : context.path}' on '${context.resourceKey.type}' as ${context.field.kind} fields are not mutable`);
|
|
9124
8505
|
}
|
|
9125
|
-
})()
|
|
8506
|
+
})();
|
|
9126
8507
|
return false;
|
|
9127
8508
|
}
|
|
9128
8509
|
function getIdentityField(context) {
|
|
@@ -9135,18 +8516,18 @@ function setIdentityField(context) {
|
|
|
9135
8516
|
resourceKey,
|
|
9136
8517
|
store
|
|
9137
8518
|
} = context;
|
|
9138
|
-
|
|
8519
|
+
(test => {
|
|
9139
8520
|
if (!test) {
|
|
9140
8521
|
throw new Error(`Expected to receive a string id`);
|
|
9141
8522
|
}
|
|
9142
|
-
})(typeof value === 'string' && value.length)
|
|
8523
|
+
})(typeof value === 'string' && value.length);
|
|
9143
8524
|
const normalizedId = String(value);
|
|
9144
8525
|
const didChange = normalizedId !== resourceKey.id;
|
|
9145
|
-
|
|
8526
|
+
(test => {
|
|
9146
8527
|
if (!test) {
|
|
9147
8528
|
throw new Error(`Cannot set ${resourceKey.type} record's id to ${normalizedId}, because id is already ${resourceKey.id}`);
|
|
9148
8529
|
}
|
|
9149
|
-
})(!didChange || resourceKey.id === null)
|
|
8530
|
+
})(!didChange || resourceKey.id === null);
|
|
9150
8531
|
if (normalizedId !== null && didChange) {
|
|
9151
8532
|
store._instanceCache.setRecordId(resourceKey, normalizedId);
|
|
9152
8533
|
store.notifications.notify(resourceKey, 'identity', null);
|
|
@@ -9264,11 +8645,11 @@ class ManagedObject {
|
|
|
9264
8645
|
return Reflect.get(target, prop, receiver);
|
|
9265
8646
|
},
|
|
9266
8647
|
set(target, prop, value, receiver) {
|
|
9267
|
-
|
|
8648
|
+
(test => {
|
|
9268
8649
|
if (!test) {
|
|
9269
8650
|
throw new Error(`Cannot set read-only property '${String(prop)}' on ManagedObject`);
|
|
9270
8651
|
}
|
|
9271
|
-
})(context.editable)
|
|
8652
|
+
})(context.editable);
|
|
9272
8653
|
|
|
9273
8654
|
// since objects function as dictionaries, we can't defer to schema/data before extensions
|
|
9274
8655
|
// unless the prop is in the existing data.
|
|
@@ -9411,12 +8792,9 @@ class ResourceRelationship {
|
|
|
9411
8792
|
this.lid = rawValue.lid ?? rawValue.links?.self ?? `relationship:${resourceKey.lid}.${name}`;
|
|
9412
8793
|
this.data = rawValue.data ? store.peekRecord(rawValue.data) : null;
|
|
9413
8794
|
this.name = name;
|
|
9414
|
-
|
|
8795
|
+
{
|
|
9415
8796
|
this.links = Object.freeze(Object.assign({}, rawValue.links));
|
|
9416
8797
|
this.meta = Object.freeze(Object.assign({}, rawValue.meta));
|
|
9417
|
-
} else {
|
|
9418
|
-
this.links = rawValue.links ?? {};
|
|
9419
|
-
this.meta = rawValue.meta ?? {};
|
|
9420
8798
|
}
|
|
9421
8799
|
this[Context] = context;
|
|
9422
8800
|
}
|
|
@@ -9449,11 +8827,11 @@ function getResourceField(context) {
|
|
|
9449
8827
|
return new ResourceRelationship(context);
|
|
9450
8828
|
}
|
|
9451
8829
|
function setResourceField(context) {
|
|
9452
|
-
|
|
8830
|
+
(test => {
|
|
9453
8831
|
{
|
|
9454
8832
|
throw new Error(`setting resource relationships is not yet supported`);
|
|
9455
8833
|
}
|
|
9456
|
-
})()
|
|
8834
|
+
})();
|
|
9457
8835
|
return false;
|
|
9458
8836
|
}
|
|
9459
8837
|
function setSchemaArrayField(context) {
|
|
@@ -9462,11 +8840,11 @@ function setSchemaArrayField(context) {
|
|
|
9462
8840
|
const peeked = fieldSignal?.value;
|
|
9463
8841
|
context.store.cache.setAttr(context.resourceKey, context.path, arrayValue);
|
|
9464
8842
|
if (peeked) {
|
|
9465
|
-
|
|
8843
|
+
(test => {
|
|
9466
8844
|
if (!test) {
|
|
9467
8845
|
throw new Error(`Expected the peekManagedArray for ${context.field.kind} to return a ManagedArray`);
|
|
9468
8846
|
}
|
|
9469
|
-
})(ARRAY_SIGNAL in peeked)
|
|
8847
|
+
})(ARRAY_SIGNAL in peeked);
|
|
9470
8848
|
const arrSignal = peeked[ARRAY_SIGNAL];
|
|
9471
8849
|
arrSignal.isStale = true;
|
|
9472
8850
|
if (!Array.isArray(arrayValue)) {
|
|
@@ -9512,11 +8890,11 @@ function getSchemaObjectField(context) {
|
|
|
9512
8890
|
// the special string "@hash" which tells us to treat field.type as a hashFn name with which
|
|
9513
8891
|
// to calc the type.
|
|
9514
8892
|
if (typePath === '@hash') {
|
|
9515
|
-
|
|
8893
|
+
(test => {
|
|
9516
8894
|
if (!test) {
|
|
9517
8895
|
throw new Error(`Expected the field to define a hashFn as its type`);
|
|
9518
8896
|
}
|
|
9519
|
-
})(field.type)
|
|
8897
|
+
})(field.type);
|
|
9520
8898
|
const hashFn = schema.hashFn({
|
|
9521
8899
|
type: field.type
|
|
9522
8900
|
});
|
|
@@ -9524,18 +8902,18 @@ function getSchemaObjectField(context) {
|
|
|
9524
8902
|
objectType = hashFn(rawValue, null, null);
|
|
9525
8903
|
} else {
|
|
9526
8904
|
objectType = rawValue[typePath];
|
|
9527
|
-
|
|
8905
|
+
(test => {
|
|
9528
8906
|
if (!test) {
|
|
9529
8907
|
throw new Error(`Expected the type path for the field to be a value on the raw object`);
|
|
9530
8908
|
}
|
|
9531
|
-
})(typePath && objectType && typeof objectType === 'string')
|
|
8909
|
+
})(typePath && objectType && typeof objectType === 'string');
|
|
9532
8910
|
}
|
|
9533
8911
|
} else {
|
|
9534
|
-
|
|
8912
|
+
(test => {
|
|
9535
8913
|
if (!test) {
|
|
9536
8914
|
throw new Error(`A non-polymorphic SchemaObjectField must provide a SchemaObject type in its definition`);
|
|
9537
8915
|
}
|
|
9538
|
-
})(field.type)
|
|
8916
|
+
})(field.type);
|
|
9539
8917
|
objectType = field.type;
|
|
9540
8918
|
}
|
|
9541
8919
|
const hashField = schema.resource({
|
|
@@ -9577,11 +8955,11 @@ function setSchemaObjectField(context) {
|
|
|
9577
8955
|
} = context;
|
|
9578
8956
|
let newValue = value;
|
|
9579
8957
|
if (value !== null) {
|
|
9580
|
-
|
|
8958
|
+
(test => {
|
|
9581
8959
|
if (!test) {
|
|
9582
8960
|
throw new Error(`Expected value to be an object`);
|
|
9583
8961
|
}
|
|
9584
|
-
})(typeof value === 'object')
|
|
8962
|
+
})(typeof value === 'object');
|
|
9585
8963
|
newValue = {
|
|
9586
8964
|
...value
|
|
9587
8965
|
};
|
|
@@ -9591,11 +8969,11 @@ function setSchemaObjectField(context) {
|
|
|
9591
8969
|
});
|
|
9592
8970
|
for (const key of Object.keys(newValue)) {
|
|
9593
8971
|
if (!schemaFields.has(key)) {
|
|
9594
|
-
|
|
8972
|
+
(test => {
|
|
9595
8973
|
{
|
|
9596
8974
|
throw new Error(`Field ${key} does not exist on schema object ${context.field.type}`);
|
|
9597
8975
|
}
|
|
9598
|
-
})()
|
|
8976
|
+
})();
|
|
9599
8977
|
return false;
|
|
9600
8978
|
}
|
|
9601
8979
|
}
|
|
@@ -9814,11 +9192,11 @@ class ReactiveResource {
|
|
|
9814
9192
|
if (field?.kind === 'array' || field?.kind === 'schema-array') {
|
|
9815
9193
|
const peeked = signal?.value;
|
|
9816
9194
|
if (peeked) {
|
|
9817
|
-
|
|
9195
|
+
(test => {
|
|
9818
9196
|
if (!test) {
|
|
9819
9197
|
throw new Error(`Expected the peekManagedArray for ${field.kind} to return a ManagedArray`);
|
|
9820
9198
|
}
|
|
9821
|
-
})(ARRAY_SIGNAL in peeked)
|
|
9199
|
+
})(ARRAY_SIGNAL in peeked);
|
|
9822
9200
|
const arrSignal = peeked[ARRAY_SIGNAL];
|
|
9823
9201
|
notifyInternalSignal(arrSignal);
|
|
9824
9202
|
}
|
|
@@ -9839,11 +9217,11 @@ class ReactiveResource {
|
|
|
9839
9217
|
if (isEmbedded) return; // base paths never apply to embedded records
|
|
9840
9218
|
|
|
9841
9219
|
const field = cacheFields.get(key);
|
|
9842
|
-
|
|
9220
|
+
(test => {
|
|
9843
9221
|
if (!test) {
|
|
9844
9222
|
throw new Error(`Expected relationship ${key} to be the name of a field`);
|
|
9845
9223
|
}
|
|
9846
|
-
})(field)
|
|
9224
|
+
})(field);
|
|
9847
9225
|
if (field.kind === 'belongsTo') {
|
|
9848
9226
|
// TODO determine what LOGGING flag to wrap this in if any
|
|
9849
9227
|
// console.log(`Notification for ${key} on ${identifier.type}`, proxy);
|
|
@@ -9863,22 +9241,22 @@ class ReactiveResource {
|
|
|
9863
9241
|
}
|
|
9864
9242
|
return;
|
|
9865
9243
|
}
|
|
9866
|
-
|
|
9244
|
+
(test => {
|
|
9867
9245
|
if (!test) {
|
|
9868
9246
|
throw new Error(`Can only use hasMany fields when the resource is in legacy mode`);
|
|
9869
9247
|
}
|
|
9870
|
-
})(context.legacy)
|
|
9248
|
+
})(context.legacy);
|
|
9871
9249
|
if (schema._kind('@legacy', 'hasMany').notify(context.store, proxy, resourceKey, field)) {
|
|
9872
|
-
|
|
9250
|
+
(test => {
|
|
9873
9251
|
if (!test) {
|
|
9874
9252
|
throw new Error(`Expected options to exist on relationship meta`);
|
|
9875
9253
|
}
|
|
9876
|
-
})(field.options)
|
|
9877
|
-
|
|
9254
|
+
})(field.options);
|
|
9255
|
+
(test => {
|
|
9878
9256
|
if (!test) {
|
|
9879
9257
|
throw new Error(`Expected async to exist on relationship meta options`);
|
|
9880
9258
|
}
|
|
9881
|
-
})('async' in field.options)
|
|
9259
|
+
})('async' in field.options);
|
|
9882
9260
|
if (field.options.async) {
|
|
9883
9261
|
const signal = signals.get(key);
|
|
9884
9262
|
if (signal) {
|
|
@@ -9909,11 +9287,11 @@ class ReactiveResource {
|
|
|
9909
9287
|
},
|
|
9910
9288
|
getOwnPropertyDescriptor(target, prop) {
|
|
9911
9289
|
const schemaForField = prop === identityField?.name ? identityField : fields.get(prop);
|
|
9912
|
-
|
|
9290
|
+
(test => {
|
|
9913
9291
|
if (!test) {
|
|
9914
9292
|
throw new Error(`No field named ${String(prop)} on ${resourceKey.type}`);
|
|
9915
9293
|
}
|
|
9916
|
-
})(schemaForField)
|
|
9294
|
+
})(schemaForField);
|
|
9917
9295
|
if (isNonEnumerableProp(prop)) {
|
|
9918
9296
|
return {
|
|
9919
9297
|
writable: false,
|
|
@@ -10067,19 +9445,19 @@ class ReactiveResource {
|
|
|
10067
9445
|
|
|
10068
9446
|
// too many things check for random symbols
|
|
10069
9447
|
if (typeof prop === 'symbol') return undefined;
|
|
10070
|
-
|
|
9448
|
+
(test => {
|
|
10071
9449
|
{
|
|
10072
9450
|
throw new Error(`No field named ${String(prop)} on ${context.path ? context.value : resourceKey.type}`);
|
|
10073
9451
|
}
|
|
10074
|
-
})()
|
|
9452
|
+
})();
|
|
10075
9453
|
return undefined;
|
|
10076
9454
|
}
|
|
10077
9455
|
const field = maybeField.kind === 'alias' ? maybeField.options : maybeField;
|
|
10078
|
-
|
|
9456
|
+
(test => {
|
|
10079
9457
|
if (!test) {
|
|
10080
9458
|
throw new Error(`Alias fields cannot alias '@id' '@local' '@hash' or 'derived' fields`);
|
|
10081
9459
|
}
|
|
10082
|
-
})(maybeField.kind !== 'alias' || !['@id', '@local', '@hash', 'derived'].includes(maybeField.options.kind))
|
|
9460
|
+
})(maybeField.kind !== 'alias' || !['@id', '@local', '@hash', 'derived'].includes(maybeField.options.kind));
|
|
10083
9461
|
/**
|
|
10084
9462
|
* Prop Array is the path from a resource to the field including
|
|
10085
9463
|
* intermediate "links" on arrays,objects,schema-arrays and schema-objects.
|
|
@@ -10147,11 +9525,11 @@ class ReactiveResource {
|
|
|
10147
9525
|
return true;
|
|
10148
9526
|
}
|
|
10149
9527
|
if (!context.editable) {
|
|
10150
|
-
|
|
9528
|
+
(test => {
|
|
10151
9529
|
{
|
|
10152
9530
|
throw new Error(`Cannot set ${String(prop)} on ${context.path !== null ? context.value : resourceKey.type} because the ReactiveResource is not editable`);
|
|
10153
9531
|
}
|
|
10154
|
-
})()
|
|
9532
|
+
})();
|
|
10155
9533
|
return false;
|
|
10156
9534
|
}
|
|
10157
9535
|
const maybeField = prop === identityField?.name ? identityField : fields.get(prop);
|
|
@@ -10160,19 +9538,19 @@ class ReactiveResource {
|
|
|
10160
9538
|
if (isExtensionProp(extensions, prop)) {
|
|
10161
9539
|
return performExtensionSet(receiver, extensions, signals, prop, value);
|
|
10162
9540
|
}
|
|
10163
|
-
|
|
9541
|
+
(test => {
|
|
10164
9542
|
{
|
|
10165
9543
|
throw new Error(`There is no settable field named ${String(prop)} on ${type}`);
|
|
10166
9544
|
}
|
|
10167
|
-
})()
|
|
9545
|
+
})();
|
|
10168
9546
|
return false;
|
|
10169
9547
|
}
|
|
10170
9548
|
const field = maybeField.kind === 'alias' ? maybeField.options : maybeField;
|
|
10171
|
-
|
|
9549
|
+
(test => {
|
|
10172
9550
|
if (!test) {
|
|
10173
9551
|
throw new Error(`Alias fields cannot alias '@id' '@local' '@hash' or 'derived' fields`);
|
|
10174
9552
|
}
|
|
10175
|
-
})(maybeField.kind !== 'alias' || !['@id', '@local', '@hash', 'derived'].includes(maybeField.options.kind))
|
|
9553
|
+
})(maybeField.kind !== 'alias' || !['@id', '@local', '@hash', 'derived'].includes(maybeField.options.kind));
|
|
10176
9554
|
/**
|
|
10177
9555
|
* Prop Array is the path from a resource to the field including
|
|
10178
9556
|
* intermediate "links" on arrays,objects,schema-arrays and schema-objects.
|
|
@@ -10234,7 +9612,7 @@ class ReactiveResource {
|
|
|
10234
9612
|
}
|
|
10235
9613
|
}
|
|
10236
9614
|
});
|
|
10237
|
-
|
|
9615
|
+
{
|
|
10238
9616
|
Object.defineProperty(this, '__SHOW_ME_THE_DATA_(debug mode only)__', {
|
|
10239
9617
|
enumerable: false,
|
|
10240
9618
|
configurable: true,
|
|
@@ -10304,11 +9682,11 @@ function _DESTROY(record) {
|
|
|
10304
9682
|
// resource is destroyed.
|
|
10305
9683
|
}
|
|
10306
9684
|
function assertNeverField(identifier, field, path) {
|
|
10307
|
-
|
|
9685
|
+
(test => {
|
|
10308
9686
|
{
|
|
10309
9687
|
throw new Error(`Cannot use unknown field kind ${field.kind} on <${identifier.type}>.${Array.isArray(path) ? path.join('.') : path}`);
|
|
10310
9688
|
}
|
|
10311
|
-
})()
|
|
9689
|
+
})();
|
|
10312
9690
|
return false;
|
|
10313
9691
|
}
|
|
10314
9692
|
|
|
@@ -10356,11 +9734,11 @@ function commit(record) {
|
|
|
10356
9734
|
function instantiateRecord(store, identifier, createArgs) {
|
|
10357
9735
|
const schema = store.schema;
|
|
10358
9736
|
const resourceSchema = schema.resource(identifier);
|
|
10359
|
-
|
|
9737
|
+
(test => {
|
|
10360
9738
|
if (!test) {
|
|
10361
9739
|
throw new Error(`Expected a resource schema`);
|
|
10362
9740
|
}
|
|
10363
|
-
})(isResourceSchema(resourceSchema))
|
|
9741
|
+
})(isResourceSchema(resourceSchema));
|
|
10364
9742
|
const legacy = resourceSchema?.legacy ?? false;
|
|
10365
9743
|
const editable = legacy;
|
|
10366
9744
|
const record = new ReactiveResource({
|
|
@@ -10379,11 +9757,11 @@ function instantiateRecord(store, identifier, createArgs) {
|
|
|
10379
9757
|
return record;
|
|
10380
9758
|
}
|
|
10381
9759
|
function assertReactiveResource(record) {
|
|
10382
|
-
|
|
9760
|
+
(test => {
|
|
10383
9761
|
if (!test) {
|
|
10384
9762
|
throw new Error('Expected a ReactiveResource');
|
|
10385
9763
|
}
|
|
10386
|
-
})(record && typeof record === 'object' && Destroy in record)
|
|
9764
|
+
})(record && typeof record === 'object' && Destroy in record);
|
|
10387
9765
|
}
|
|
10388
9766
|
function teardownRecord(record) {
|
|
10389
9767
|
assertReactiveResource(record);
|
|
@@ -10416,11 +9794,11 @@ function _constructor(record) {
|
|
|
10416
9794
|
return state._constructor = state._constructor || {
|
|
10417
9795
|
name: `ReactiveResource<${recordIdentifierFor(record).type}>`,
|
|
10418
9796
|
get modelName() {
|
|
10419
|
-
|
|
9797
|
+
(test => {
|
|
10420
9798
|
{
|
|
10421
9799
|
throw new Error(`record.constructor.modelName is not available outside of legacy mode`);
|
|
10422
9800
|
}
|
|
10423
|
-
})()
|
|
9801
|
+
})();
|
|
10424
9802
|
return undefined;
|
|
10425
9803
|
}
|
|
10426
9804
|
};
|
|
@@ -10447,11 +9825,11 @@ function processExtension(extension) {
|
|
|
10447
9825
|
for (const key of Object.getOwnPropertyNames(baseFeatures)) {
|
|
10448
9826
|
if (BannedKeys.includes(key)) continue;
|
|
10449
9827
|
const decl = Object.getOwnPropertyDescriptor(baseFeatures, key);
|
|
10450
|
-
|
|
9828
|
+
(test => {
|
|
10451
9829
|
if (!test) {
|
|
10452
9830
|
throw new Error(`Expected to find a declaration for ${key} on extension ${name}`);
|
|
10453
9831
|
}
|
|
10454
|
-
})(decl)
|
|
9832
|
+
})(decl);
|
|
10455
9833
|
if (decl.value) {
|
|
10456
9834
|
const {
|
|
10457
9835
|
value
|
|
@@ -10488,11 +9866,11 @@ function processExtension(extension) {
|
|
|
10488
9866
|
});
|
|
10489
9867
|
continue;
|
|
10490
9868
|
}
|
|
10491
|
-
|
|
9869
|
+
(test => {
|
|
10492
9870
|
{
|
|
10493
9871
|
throw new Error(`The feature ${key} on extension ${name} is of an unknown variety.`);
|
|
10494
9872
|
}
|
|
10495
|
-
})()
|
|
9873
|
+
})();
|
|
10496
9874
|
}
|
|
10497
9875
|
return {
|
|
10498
9876
|
kind,
|
|
@@ -10502,11 +9880,11 @@ function processExtension(extension) {
|
|
|
10502
9880
|
}
|
|
10503
9881
|
function getExt(extCache, type, extName) {
|
|
10504
9882
|
const ext = extCache[type].get(extName);
|
|
10505
|
-
|
|
9883
|
+
(test => {
|
|
10506
9884
|
if (!test) {
|
|
10507
9885
|
throw new Error(`expected to have an extension named ${String(extName)} available for ${type}s`);
|
|
10508
9886
|
}
|
|
10509
|
-
})(ext)
|
|
9887
|
+
})(ext);
|
|
10510
9888
|
return ext?.features ?? null;
|
|
10511
9889
|
}
|
|
10512
9890
|
function hasObjectSchema(field) {
|
|
@@ -10618,16 +9996,16 @@ function withDefaults(schema) {
|
|
|
10618
9996
|
const fromIdentity = (record, options, key) => {
|
|
10619
9997
|
const context = record[Context];
|
|
10620
9998
|
const identifier = context.resourceKey;
|
|
10621
|
-
|
|
9999
|
+
(test => {
|
|
10622
10000
|
if (!test) {
|
|
10623
10001
|
throw new Error(`Cannot compute @identity for a record without an identifier`);
|
|
10624
10002
|
}
|
|
10625
|
-
})(identifier)
|
|
10626
|
-
|
|
10003
|
+
})(identifier);
|
|
10004
|
+
(test => {
|
|
10627
10005
|
if (!test) {
|
|
10628
10006
|
throw new Error(`Expected to receive a key to compute @identity, but got ${String(options)}`);
|
|
10629
10007
|
}
|
|
10630
|
-
})(options?.key && ['lid', 'id', 'type', '^'].includes(options.key))
|
|
10008
|
+
})(options?.key && ['lid', 'id', 'type', '^'].includes(options.key));
|
|
10631
10009
|
return options.key === '^' ? identifier : identifier[options.key];
|
|
10632
10010
|
};
|
|
10633
10011
|
fromIdentity[Type] = '@identity';
|
|
@@ -10717,69 +10095,69 @@ class SchemaService {
|
|
|
10717
10095
|
transformation(field) {
|
|
10718
10096
|
const kind = 'kind' in field ? field.kind : '<unknown kind>';
|
|
10719
10097
|
const name = 'name' in field ? field.name : '<unknown name>';
|
|
10720
|
-
|
|
10098
|
+
(test => {
|
|
10721
10099
|
if (!test) {
|
|
10722
10100
|
throw new Error(`'${kind}' fields cannot be transformed. Only fields of kind 'field' 'object' or 'array' can specify a transformation. Attempted to find '${field.type ?? '<unknown type>'}' on field '${name}'.`);
|
|
10723
10101
|
}
|
|
10724
|
-
})(!('kind' in field) || ['field', 'object', 'array'].includes(kind))
|
|
10725
|
-
|
|
10102
|
+
})(!('kind' in field) || ['field', 'object', 'array'].includes(kind));
|
|
10103
|
+
(test => {
|
|
10726
10104
|
if (!test) {
|
|
10727
10105
|
throw new Error(`Expected the '${kind}' field '${name}' to specify a transformation via 'field.type', but none was present`);
|
|
10728
10106
|
}
|
|
10729
|
-
})(field.type)
|
|
10730
|
-
|
|
10107
|
+
})(field.type);
|
|
10108
|
+
(test => {
|
|
10731
10109
|
if (!test) {
|
|
10732
10110
|
throw new Error(`No transformation registered with name '${field.type}' for '${kind}' field '${name}'`);
|
|
10733
10111
|
}
|
|
10734
|
-
})(this._transforms.has(field.type))
|
|
10112
|
+
})(this._transforms.has(field.type));
|
|
10735
10113
|
return this._transforms.get(field.type);
|
|
10736
10114
|
}
|
|
10737
10115
|
derivation(field) {
|
|
10738
10116
|
const kind = 'kind' in field ? field.kind : '<unknown kind>';
|
|
10739
10117
|
const name = 'name' in field ? field.name : '<unknown name>';
|
|
10740
|
-
|
|
10118
|
+
(test => {
|
|
10741
10119
|
if (!test) {
|
|
10742
10120
|
throw new Error(`The '${kind}' field '${name}' is not derived and so cannot be used to lookup a derivation`);
|
|
10743
10121
|
}
|
|
10744
|
-
})(!('kind' in field) || kind === 'derived')
|
|
10745
|
-
|
|
10122
|
+
})(!('kind' in field) || kind === 'derived');
|
|
10123
|
+
(test => {
|
|
10746
10124
|
if (!test) {
|
|
10747
10125
|
throw new Error(`Expected the '${kind}' field '${name}' to specify a derivation via 'field.type', but no value was present`);
|
|
10748
10126
|
}
|
|
10749
|
-
})(field.type)
|
|
10750
|
-
|
|
10127
|
+
})(field.type);
|
|
10128
|
+
(test => {
|
|
10751
10129
|
if (!test) {
|
|
10752
10130
|
throw new Error(`No '${field.type}' derivation registered for use by the '${kind}' field '${name}'`);
|
|
10753
10131
|
}
|
|
10754
|
-
})(this._derivations.has(field.type))
|
|
10132
|
+
})(this._derivations.has(field.type));
|
|
10755
10133
|
return this._derivations.get(field.type);
|
|
10756
10134
|
}
|
|
10757
10135
|
hashFn(field) {
|
|
10758
10136
|
const kind = 'kind' in field ? field.kind : '<unknown kind>';
|
|
10759
10137
|
const name = 'name' in field ? field.name : '<unknown name>';
|
|
10760
|
-
|
|
10138
|
+
(test => {
|
|
10761
10139
|
if (!test) {
|
|
10762
10140
|
throw new Error(`The '${kind}' field '${name}' is not a HashField and so cannot be used to lookup a hash function`);
|
|
10763
10141
|
}
|
|
10764
|
-
})(!('kind' in field) || kind === '@hash')
|
|
10765
|
-
|
|
10142
|
+
})(!('kind' in field) || kind === '@hash');
|
|
10143
|
+
(test => {
|
|
10766
10144
|
if (!test) {
|
|
10767
10145
|
throw new Error(`Expected the '${kind}' field '${name}' to specify a hash function via 'field.type', but no value was present`);
|
|
10768
10146
|
}
|
|
10769
|
-
})(field.type)
|
|
10770
|
-
|
|
10147
|
+
})(field.type);
|
|
10148
|
+
(test => {
|
|
10771
10149
|
if (!test) {
|
|
10772
10150
|
throw new Error(`No '${field.type}' hash function is registered for use by the '${kind}' field '${name}'`);
|
|
10773
10151
|
}
|
|
10774
|
-
})(this._hashFns.has(field.type))
|
|
10152
|
+
})(this._hashFns.has(field.type));
|
|
10775
10153
|
return this._hashFns.get(field.type);
|
|
10776
10154
|
}
|
|
10777
10155
|
resource(resource) {
|
|
10778
|
-
|
|
10156
|
+
(test => {
|
|
10779
10157
|
if (!test) {
|
|
10780
10158
|
throw new Error(`No resource registered with name '${resource.type}'`);
|
|
10781
10159
|
}
|
|
10782
|
-
})(this._schemas.has(resource.type))
|
|
10160
|
+
})(this._schemas.has(resource.type));
|
|
10783
10161
|
return this._schemas.get(resource.type).original;
|
|
10784
10162
|
}
|
|
10785
10163
|
registerResources(schemas) {
|
|
@@ -10792,13 +10170,13 @@ class SchemaService {
|
|
|
10792
10170
|
const relationships = {};
|
|
10793
10171
|
const attributes = {};
|
|
10794
10172
|
for (const field of schema.fields) {
|
|
10795
|
-
|
|
10173
|
+
(test => {
|
|
10796
10174
|
if (!test) {
|
|
10797
10175
|
throw new Error(`${field.kind} is not valid inside a ResourceSchema's fields.`);
|
|
10798
10176
|
}
|
|
10799
10177
|
})(
|
|
10800
10178
|
// @ts-expect-error we are checking for mistakes at runtime
|
|
10801
|
-
field.kind !== '@id' && field.kind !== '@hash')
|
|
10179
|
+
field.kind !== '@id' && field.kind !== '@hash');
|
|
10802
10180
|
fields.set(field.name, field);
|
|
10803
10181
|
if (field.kind === 'attribute') {
|
|
10804
10182
|
attributes[field.name] = field;
|
|
@@ -10868,11 +10246,11 @@ class SchemaService {
|
|
|
10868
10246
|
this._derivations.set(derivation[Type], makeCachedDerivation(derivation));
|
|
10869
10247
|
}
|
|
10870
10248
|
CAUTION_MEGA_DANGER_ZONE_registerExtension(extension) {
|
|
10871
|
-
|
|
10249
|
+
(test => {
|
|
10872
10250
|
if (!test) {
|
|
10873
10251
|
throw new Error(`an extension named ${extension.name} for ${extension.kind} already exists!`);
|
|
10874
10252
|
}
|
|
10875
|
-
})(!this._extensions[extension.kind].has(extension.name))
|
|
10253
|
+
})(!this._extensions[extension.kind].has(extension.name));
|
|
10876
10254
|
this._extensions[extension.kind].set(extension.name, processExtension(extension));
|
|
10877
10255
|
}
|
|
10878
10256
|
CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource) {
|
|
@@ -10901,11 +10279,11 @@ class SchemaService {
|
|
|
10901
10279
|
* @internal
|
|
10902
10280
|
*/
|
|
10903
10281
|
_registerMode(mode, kinds) {
|
|
10904
|
-
|
|
10282
|
+
(test => {
|
|
10905
10283
|
if (!test) {
|
|
10906
10284
|
throw new Error(`Mode '${mode}' is already registered`);
|
|
10907
10285
|
}
|
|
10908
|
-
})(!this._modes.has(mode))
|
|
10286
|
+
})(!this._modes.has(mode));
|
|
10909
10287
|
this._modes.set(mode, kinds);
|
|
10910
10288
|
}
|
|
10911
10289
|
|
|
@@ -10921,17 +10299,17 @@ class SchemaService {
|
|
|
10921
10299
|
* @internal
|
|
10922
10300
|
*/
|
|
10923
10301
|
_kind(mode, kind) {
|
|
10924
|
-
|
|
10302
|
+
(test => {
|
|
10925
10303
|
if (!test) {
|
|
10926
10304
|
throw new Error(`Mode '${mode}' is not registered`);
|
|
10927
10305
|
}
|
|
10928
|
-
})(this._modes.has(mode))
|
|
10306
|
+
})(this._modes.has(mode));
|
|
10929
10307
|
const kinds = this._modes.get(mode);
|
|
10930
|
-
|
|
10308
|
+
(test => {
|
|
10931
10309
|
if (!test) {
|
|
10932
10310
|
throw new Error(`Kind '${kind}' is not registered for mode '${mode}'`);
|
|
10933
10311
|
}
|
|
10934
|
-
})(kinds[kind])
|
|
10312
|
+
})(kinds[kind]);
|
|
10935
10313
|
return kinds[kind];
|
|
10936
10314
|
}
|
|
10937
10315
|
|
|
@@ -10948,11 +10326,11 @@ class SchemaService {
|
|
|
10948
10326
|
type
|
|
10949
10327
|
}) {
|
|
10950
10328
|
const schema = this._schemas.get(type);
|
|
10951
|
-
|
|
10329
|
+
(test => {
|
|
10952
10330
|
if (!test) {
|
|
10953
10331
|
throw new Error(`No schema defined for ${type}`);
|
|
10954
10332
|
}
|
|
10955
|
-
})(schema)
|
|
10333
|
+
})(schema);
|
|
10956
10334
|
if (!schema.finalized) {
|
|
10957
10335
|
finalizeResource(this, schema);
|
|
10958
10336
|
}
|
|
@@ -10962,11 +10340,11 @@ class SchemaService {
|
|
|
10962
10340
|
type
|
|
10963
10341
|
}) {
|
|
10964
10342
|
const schema = this._schemas.get(type);
|
|
10965
|
-
|
|
10343
|
+
(test => {
|
|
10966
10344
|
if (!test) {
|
|
10967
10345
|
throw new Error(`No schema defined for ${type}`);
|
|
10968
10346
|
}
|
|
10969
|
-
})(schema)
|
|
10347
|
+
})(schema);
|
|
10970
10348
|
if (!schema.finalized) {
|
|
10971
10349
|
finalizeResource(this, schema);
|
|
10972
10350
|
}
|
|
@@ -10976,57 +10354,6 @@ class SchemaService {
|
|
|
10976
10354
|
return this._schemas.has(resource.type);
|
|
10977
10355
|
}
|
|
10978
10356
|
}
|
|
10979
|
-
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_SCHEMA_SERVICE)) {
|
|
10980
|
-
SchemaService.prototype.attributesDefinitionFor = function ({
|
|
10981
|
-
type
|
|
10982
|
-
}) {
|
|
10983
|
-
deprecate(`Use \`schema.fields({ type })\` instead of \`schema.attributesDefinitionFor({ type })\``, false, {
|
|
10984
|
-
id: 'ember-data:schema-service-updates',
|
|
10985
|
-
until: '6.0',
|
|
10986
|
-
for: 'ember-data',
|
|
10987
|
-
since: {
|
|
10988
|
-
available: '4.13',
|
|
10989
|
-
enabled: '5.4'
|
|
10990
|
-
}
|
|
10991
|
-
});
|
|
10992
|
-
const schema = this._schemas.get(type);
|
|
10993
|
-
if (!schema) {
|
|
10994
|
-
throw new Error(`No schema defined for ${type}`);
|
|
10995
|
-
}
|
|
10996
|
-
return schema.attributes;
|
|
10997
|
-
};
|
|
10998
|
-
SchemaService.prototype.relationshipsDefinitionFor = function ({
|
|
10999
|
-
type
|
|
11000
|
-
}) {
|
|
11001
|
-
deprecate(`Use \`schema.fields({ type })\` instead of \`schema.relationshipsDefinitionFor({ type })\``, false, {
|
|
11002
|
-
id: 'ember-data:schema-service-updates',
|
|
11003
|
-
until: '6.0',
|
|
11004
|
-
for: 'ember-data',
|
|
11005
|
-
since: {
|
|
11006
|
-
available: '4.13',
|
|
11007
|
-
enabled: '5.4'
|
|
11008
|
-
}
|
|
11009
|
-
});
|
|
11010
|
-
const schema = this._schemas.get(type);
|
|
11011
|
-
if (!schema) {
|
|
11012
|
-
throw new Error(`No schema defined for ${type}`);
|
|
11013
|
-
}
|
|
11014
|
-
return schema.relationships;
|
|
11015
|
-
};
|
|
11016
|
-
SchemaService.prototype.doesTypeExist = function (type) {
|
|
11017
|
-
deprecate(`Use \`schema.hasResource({ type })\` instead of \`schema.doesTypeExist(type)\``, false, {
|
|
11018
|
-
id: 'ember-data:schema-service-updates',
|
|
11019
|
-
until: '6.0',
|
|
11020
|
-
for: 'ember-data',
|
|
11021
|
-
since: {
|
|
11022
|
-
available: '4.13',
|
|
11023
|
-
enabled: '5.4'
|
|
11024
|
-
}
|
|
11025
|
-
});
|
|
11026
|
-
return this._schemas.has(type);
|
|
11027
|
-
};
|
|
11028
|
-
}
|
|
11029
|
-
|
|
11030
10357
|
/**
|
|
11031
10358
|
* When we finalize a resource, we walk its traits and apply their fields
|
|
11032
10359
|
* to the resource's fields.
|
|
@@ -11051,12 +10378,12 @@ function finalizeResource(schema, resource) {
|
|
|
11051
10378
|
const seen = new Set();
|
|
11052
10379
|
for (const traitName of resource.traits) {
|
|
11053
10380
|
const trait = schema._traits.get(traitName);
|
|
11054
|
-
|
|
10381
|
+
(test => {
|
|
11055
10382
|
if (!test) {
|
|
11056
10383
|
throw new Error(`The trait ${traitName} MUST be supplied before the resource ${resource.original.type} can be finalized for use.`);
|
|
11057
10384
|
}
|
|
11058
|
-
})(trait)
|
|
11059
|
-
walkTrait(schema, trait, fields, seen, resource.original.type,
|
|
10385
|
+
})(trait);
|
|
10386
|
+
walkTrait(schema, trait, fields, seen, resource.original.type, []);
|
|
11060
10387
|
}
|
|
11061
10388
|
mergeMap(fields, resource.fields);
|
|
11062
10389
|
resource.fields = fields;
|
|
@@ -11070,11 +10397,11 @@ function getCacheFields(resource) {
|
|
|
11070
10397
|
const cacheFields = new Map();
|
|
11071
10398
|
for (const [key, value] of fields) {
|
|
11072
10399
|
if (isNonIdentityCacheableField(value)) {
|
|
11073
|
-
|
|
10400
|
+
(test => {
|
|
11074
10401
|
if (!test) {
|
|
11075
10402
|
throw new Error(`The sourceKey '${value.sourceKey}' for the field '${key}' on ${resource.original.type} is invalid because it matches the name of an existing field`);
|
|
11076
10403
|
}
|
|
11077
|
-
})(!value.sourceKey || value.sourceKey === key || !fields.has(value.sourceKey))
|
|
10404
|
+
})(!value.sourceKey || value.sourceKey === key || !fields.has(value.sourceKey));
|
|
11078
10405
|
const cacheKey = getFieldCacheKeyStrict(value);
|
|
11079
10406
|
cacheFields.set(cacheKey, value);
|
|
11080
10407
|
}
|
|
@@ -11084,14 +10411,14 @@ function getCacheFields(resource) {
|
|
|
11084
10411
|
function walkTrait(schema, trait, fields, seen, type, debugPath) {
|
|
11085
10412
|
if (seen.has(trait)) {
|
|
11086
10413
|
// if the trait is in the current path, we throw a cycle error in dev.
|
|
11087
|
-
|
|
10414
|
+
{
|
|
11088
10415
|
if (debugPath.includes(trait.name)) {
|
|
11089
10416
|
throw new Error(`CycleError: The Trait '${trait.name}' utilized by the Resource '${type}' includes the following circular reference "${debugPath.join(' > ')} > ${trait.name}"`);
|
|
11090
10417
|
}
|
|
11091
10418
|
}
|
|
11092
10419
|
return;
|
|
11093
10420
|
}
|
|
11094
|
-
const ownPath =
|
|
10421
|
+
const ownPath = [...debugPath, trait.name];
|
|
11095
10422
|
|
|
11096
10423
|
// immediately mark as seen to prevent cycles
|
|
11097
10424
|
// further down the tree from looping back
|
|
@@ -11101,14 +10428,8 @@ function walkTrait(schema, trait, fields, seen, type, debugPath) {
|
|
|
11101
10428
|
if (trait.traits?.length) {
|
|
11102
10429
|
for (const traitName of trait.traits) {
|
|
11103
10430
|
const subtrait = schema._traits.get(traitName);
|
|
11104
|
-
|
|
11105
|
-
|
|
11106
|
-
if (!test) {
|
|
11107
|
-
throw new Error(`The trait ${traitName} used by the trait ${trait.name} MUST be supplied before the resource ${type} can be finalized for use.`);
|
|
11108
|
-
}
|
|
11109
|
-
})(subtrait) : {};
|
|
11110
|
-
} else {
|
|
11111
|
-
warn(`The trait ${traitName} used by the trait ${trait.name} MUST be supplied before the resource ${type} can be finalized for use.`, !!subtrait, {
|
|
10431
|
+
{
|
|
10432
|
+
console.warn(`The trait ${traitName} used by the trait ${trait.name} MUST be supplied before the resource ${type} can be finalized for use.`, !!subtrait, {
|
|
11112
10433
|
id: 'warp-drive:missing-trait-schema-for-resource'
|
|
11113
10434
|
});
|
|
11114
10435
|
}
|
|
@@ -11279,11 +10600,11 @@ function getPromise(promise) {
|
|
|
11279
10600
|
* See also {@link PromiseState}
|
|
11280
10601
|
*/
|
|
11281
10602
|
function getPromiseState(promise) {
|
|
11282
|
-
|
|
10603
|
+
(test => {
|
|
11283
10604
|
if (!test) {
|
|
11284
10605
|
throw new Error(`getPromiseState expects to be called with a promise: called with ${String(promise)}`);
|
|
11285
10606
|
}
|
|
11286
|
-
})(promise)
|
|
10607
|
+
})(promise);
|
|
11287
10608
|
const _promise = getPromise(promise);
|
|
11288
10609
|
let state = PromiseCache.get(_promise);
|
|
11289
10610
|
if (!state) {
|
|
@@ -11305,7 +10626,7 @@ function cloneResponse(response, overrides) {
|
|
|
11305
10626
|
return new Response(response.body, Object.assign(props, overrides));
|
|
11306
10627
|
}
|
|
11307
10628
|
let IS_MAYBE_MIRAGE = () => false;
|
|
11308
|
-
|
|
10629
|
+
{
|
|
11309
10630
|
IS_MAYBE_MIRAGE = () => Boolean(typeof window !== 'undefined' && (window.server?.pretender || window.fetch.toString().replace(/\s+/g, '') !== 'function fetch() { [native code] }'.replace(/\s+/g, '')));
|
|
11310
10631
|
}
|
|
11311
10632
|
const MUTATION_OPS = new Set(['updateRecord', 'createRecord', 'deleteRecord']);
|
|
@@ -11332,11 +10653,11 @@ const Fetch = {
|
|
|
11332
10653
|
async request(context) {
|
|
11333
10654
|
let response;
|
|
11334
10655
|
try {
|
|
11335
|
-
|
|
10656
|
+
(test => {
|
|
11336
10657
|
if (!test) {
|
|
11337
10658
|
throw new Error('The Fetch handler expects the request to have a URL, none was provided.');
|
|
11338
10659
|
}
|
|
11339
|
-
})(context.request.url && typeof context.request.url === 'string')
|
|
10660
|
+
})(context.request.url && typeof context.request.url === 'string');
|
|
11340
10661
|
response = await _fetch(context.request.url, context.request);
|
|
11341
10662
|
} catch (e) {
|
|
11342
10663
|
if (e instanceof DOMException && e.name === 'AbortError') {
|
|
@@ -11471,6 +10792,97 @@ const Fetch = {
|
|
|
11471
10792
|
function isDict(v) {
|
|
11472
10793
|
return v !== null && typeof v === 'object';
|
|
11473
10794
|
}
|
|
10795
|
+
|
|
10796
|
+
/**
|
|
10797
|
+
* ## Import
|
|
10798
|
+
*
|
|
10799
|
+
* ```js
|
|
10800
|
+
* import { RequestManager } from '@warp-drive/core';
|
|
10801
|
+
* ```
|
|
10802
|
+
*
|
|
10803
|
+
* For complete usage guide see the [RequestManager Documentation](/guides/).
|
|
10804
|
+
*
|
|
10805
|
+
* ## How It Works
|
|
10806
|
+
*
|
|
10807
|
+
* ```ts
|
|
10808
|
+
* interface RequestManager {
|
|
10809
|
+
* request<T>(req: RequestInfo): Future<T>;
|
|
10810
|
+
* }
|
|
10811
|
+
* ```
|
|
10812
|
+
*
|
|
10813
|
+
* A RequestManager provides a request/response flow in which configured
|
|
10814
|
+
* handlers are successively given the opportunity to handle, modify, or
|
|
10815
|
+
* pass-along a request.
|
|
10816
|
+
*
|
|
10817
|
+
* <img src="/images/handlers-all-labeled.gif" alt="RequestManager Flow Animation" width="100%" />
|
|
10818
|
+
*
|
|
10819
|
+
* For example:
|
|
10820
|
+
*
|
|
10821
|
+
* ::: code-group
|
|
10822
|
+
*
|
|
10823
|
+
* ```ts [Setup.ts]
|
|
10824
|
+
* import { RequestManager, Fetch } from '@warp-drive/core';
|
|
10825
|
+
* import { AutoCompress } from '@warp-drive/utilities/handlers';
|
|
10826
|
+
* import Auth from 'ember-simple-auth/handler';
|
|
10827
|
+
*
|
|
10828
|
+
* // ... create manager
|
|
10829
|
+
* const manager = new RequestManager()
|
|
10830
|
+
* .use([Auth, new AutoCompress(), Fetch]); // [!code focus]
|
|
10831
|
+
* ```
|
|
10832
|
+
*
|
|
10833
|
+
* ```ts [Usage.ts]
|
|
10834
|
+
* import Config from './config';
|
|
10835
|
+
*
|
|
10836
|
+
* const { apiUrl } = Config;
|
|
10837
|
+
*
|
|
10838
|
+
* // ... execute a request
|
|
10839
|
+
* const response = await manager.request({
|
|
10840
|
+
* url: `${apiUrl}/users`
|
|
10841
|
+
* });
|
|
10842
|
+
* ```
|
|
10843
|
+
*
|
|
10844
|
+
* :::
|
|
10845
|
+
*
|
|
10846
|
+
* ### Futures
|
|
10847
|
+
*
|
|
10848
|
+
* The return value of `manager.request` is a `Future`, which allows
|
|
10849
|
+
* access to limited information about the request while it is still
|
|
10850
|
+
* pending and fulfills with the final state when the request completes.
|
|
10851
|
+
*
|
|
10852
|
+
* A `Future` is cancellable via `abort`.
|
|
10853
|
+
*
|
|
10854
|
+
* Handlers may optionally expose a `ReadableStream` to the `Future` for
|
|
10855
|
+
* streaming data; however, when doing so the future should not resolve
|
|
10856
|
+
* until the response stream is fully read.
|
|
10857
|
+
*
|
|
10858
|
+
* ```ts
|
|
10859
|
+
* interface Future<T> extends Promise<StructuredDocument<T>> {
|
|
10860
|
+
* abort(): void;
|
|
10861
|
+
*
|
|
10862
|
+
* async getStream(): ReadableStream | null;
|
|
10863
|
+
* }
|
|
10864
|
+
* ```
|
|
10865
|
+
*
|
|
10866
|
+
* ### StructuredDocuments
|
|
10867
|
+
*
|
|
10868
|
+
* A Future resolves with a `StructuredDataDocument` or rejects with a `StructuredErrorDocument`.
|
|
10869
|
+
*
|
|
10870
|
+
* ```ts
|
|
10871
|
+
* interface StructuredDataDocument<T> {
|
|
10872
|
+
* request: ImmutableRequestInfo;
|
|
10873
|
+
* response: ImmutableResponseInfo;
|
|
10874
|
+
* content: T;
|
|
10875
|
+
* }
|
|
10876
|
+
* interface StructuredErrorDocument extends Error {
|
|
10877
|
+
* request: ImmutableRequestInfo;
|
|
10878
|
+
* response: ImmutableResponseInfo;
|
|
10879
|
+
* error: string | object;
|
|
10880
|
+
* }
|
|
10881
|
+
* type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument;
|
|
10882
|
+
* ```
|
|
10883
|
+
*
|
|
10884
|
+
* @public
|
|
10885
|
+
*/
|
|
11474
10886
|
class RequestManager {
|
|
11475
10887
|
/** @internal */
|
|
11476
10888
|
|
|
@@ -11504,7 +10916,7 @@ class RequestManager {
|
|
|
11504
10916
|
* @public
|
|
11505
10917
|
*/
|
|
11506
10918
|
useCache(cacheHandler) {
|
|
11507
|
-
|
|
10919
|
+
{
|
|
11508
10920
|
if (this._hasCacheHandler) {
|
|
11509
10921
|
throw new Error(`\`RequestManager.useCache(<handler>)\` May only be invoked once.`);
|
|
11510
10922
|
}
|
|
@@ -11529,7 +10941,7 @@ class RequestManager {
|
|
|
11529
10941
|
*/
|
|
11530
10942
|
use(newHandlers) {
|
|
11531
10943
|
const handlers = this._handlers;
|
|
11532
|
-
|
|
10944
|
+
{
|
|
11533
10945
|
if (Object.isFrozen(handlers)) {
|
|
11534
10946
|
throw new Error(`Cannot add a Handler to a RequestManager after a request has been made`);
|
|
11535
10947
|
}
|
|
@@ -11555,7 +10967,7 @@ class RequestManager {
|
|
|
11555
10967
|
*/
|
|
11556
10968
|
request(request) {
|
|
11557
10969
|
const handlers = this._handlers;
|
|
11558
|
-
|
|
10970
|
+
{
|
|
11559
10971
|
if (!Object.isFrozen(handlers)) {
|
|
11560
10972
|
Object.freeze(handlers);
|
|
11561
10973
|
}
|
|
@@ -11581,7 +10993,7 @@ class RequestManager {
|
|
|
11581
10993
|
// the cache handler will set the result of the request synchronously
|
|
11582
10994
|
// if it is able to fulfill the request from the cache
|
|
11583
10995
|
const cacheResult = getRequestResult(requestId);
|
|
11584
|
-
|
|
10996
|
+
{
|
|
11585
10997
|
if (!request.disableTestWaiter) {
|
|
11586
10998
|
const newPromise = waitFor(promise);
|
|
11587
10999
|
const finalPromise = upgradePromise(newPromise.then(result => {
|
|
@@ -11660,11 +11072,13 @@ class RequestManager {
|
|
|
11660
11072
|
* @mergeModuleWith <project>
|
|
11661
11073
|
*/
|
|
11662
11074
|
|
|
11663
|
-
|
|
11664
|
-
|
|
11075
|
+
{
|
|
11076
|
+
// @ts-expect-error adding to globalThis
|
|
11077
|
+
globalThis.setWarpDriveLogging = setLogging;
|
|
11665
11078
|
|
|
11666
|
-
// @ts-expect-error adding to globalThis
|
|
11667
|
-
globalThis.getWarpDriveRuntimeConfig = getRuntimeConfig;
|
|
11079
|
+
// @ts-expect-error adding to globalThis
|
|
11080
|
+
globalThis.getWarpDriveRuntimeConfig = getRuntimeConfig;
|
|
11081
|
+
}
|
|
11668
11082
|
|
|
11669
11083
|
/**
|
|
11670
11084
|
* Options for setting up a Store instance with `useRecommendedStore`.
|
|
@@ -11743,4 +11157,4 @@ function useRecommendedStore(options, StoreKlass = Store) {
|
|
|
11743
11157
|
}
|
|
11744
11158
|
};
|
|
11745
11159
|
}
|
|
11746
|
-
export {
|
|
11160
|
+
export { setIdentifierResetMethod as $, logGroup as A, signal as B, CacheHandler as C, DISPOSE as D, memoized as E, gate as F, entangleSignal as G, entangleInitiallyStaleSignal as H, defineSignal as I, defineGate as J, defineNonEnumerableSignal as K, Signals as L, peekInternalSignal as M, createInternalMemo as N, withSignalStore as O, notifyInternalSignal as P, consumeInternalSignal as Q, RecordArrayManager as R, SchemaService as S, getOrCreateInternalSignal as T, Fetch as U, RequestManager as V, useRecommendedStore as W, setIdentifierGenerationMethod as X, setIdentifierUpdateMethod as Y, setIdentifierForgetMethod as Z, _clearCaches as _, commit as a, setKeyInfoForResource as a0, createRequestSubscription as b, checkout as c, getPromiseState as d, isResourceKey as e, fromIdentity as f, getRequestState as g, coerceId as h, instantiateRecord as i, Store as j, recordIdentifierFor as k, isRequestKey as l, ensureStringId as m, fastPush as n, assertPrivateStore as o, isPrivateStore as p, assertPrivateCapabilities as q, registerDerivations as r, storeFor as s, teardownRecord as t, setRecordIdentifier as u, StoreMap as v, withDefaults as w, normalizeModelName as x, createLegacyManyArray as y, log as z };
|