@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,16 +1,16 @@
|
|
|
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 { 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-
|
|
4
|
+
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";
|
|
7
5
|
import { getOrSetGlobal, peekTransient, setTransient, peekUniversalTransient, setUniversalTransient } from './types/-private.js';
|
|
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-
|
|
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
8
|
import { dasherize } from './utils/string.js';
|
|
11
|
-
import {
|
|
9
|
+
import { g as getGlobalConfig } from "./runtime-DfhJzpZH.js";
|
|
10
|
+
import { DefaultCachePolicy } from './store.js';
|
|
12
11
|
import { setLogging, getRuntimeConfig } from './types/runtime.js';
|
|
13
12
|
import { RecordStore, Type } from './types/symbols.js';
|
|
13
|
+
import * as _importSync20 from '@ember/object';
|
|
14
14
|
const INITIALIZER_PROTO = {
|
|
15
15
|
isInitializer: true
|
|
16
16
|
};
|
|
@@ -98,11 +98,11 @@ function withSignalStore(obj) {
|
|
|
98
98
|
* @private
|
|
99
99
|
*/
|
|
100
100
|
function initializeSignalStore(obj) {
|
|
101
|
-
|
|
101
|
+
(test => {
|
|
102
102
|
if (!test) {
|
|
103
103
|
throw new Error(`Signal store already exists on object`);
|
|
104
104
|
}
|
|
105
|
-
})(!obj[Signals])
|
|
105
|
+
})(!obj[Signals]);
|
|
106
106
|
obj[Signals] = new Map();
|
|
107
107
|
}
|
|
108
108
|
function createInternalSignal(signals, obj, key, initialValue) {
|
|
@@ -124,17 +124,13 @@ function getOrCreateInternalSignal(signals, obj, key, initialValue) {
|
|
|
124
124
|
return signal;
|
|
125
125
|
}
|
|
126
126
|
function createInternalMemo(signals, object, key, fn) {
|
|
127
|
-
|
|
127
|
+
(test => {
|
|
128
128
|
if (!test) {
|
|
129
129
|
throw new Error(`Expected no signal/memo to exist for key "${String(key)}"`);
|
|
130
130
|
}
|
|
131
|
-
})(!peekInternalSignal(signals, key))
|
|
132
|
-
|
|
131
|
+
})(!peekInternalSignal(signals, key));
|
|
132
|
+
{
|
|
133
133
|
return withFrame(signals, object, key, fn);
|
|
134
|
-
} else {
|
|
135
|
-
const memo = createMemo(object, key, fn);
|
|
136
|
-
signals.set(key, memo);
|
|
137
|
-
return memo;
|
|
138
134
|
}
|
|
139
135
|
}
|
|
140
136
|
function peekInternalSignal(signals, key) {
|
|
@@ -187,7 +183,7 @@ function isMemo(obj) {
|
|
|
187
183
|
// @ts-expect-error
|
|
188
184
|
return typeof obj === 'function' && obj.signals instanceof Set;
|
|
189
185
|
}
|
|
190
|
-
|
|
186
|
+
{
|
|
191
187
|
// @ts-expect-error adding to global API
|
|
192
188
|
globalThis.debugWarpDriveSignals = (obj, key) => {
|
|
193
189
|
const signals = obj[Signals];
|
|
@@ -308,6 +304,14 @@ function printMemo(memo, key, lines = [], depth = 0) {
|
|
|
308
304
|
}
|
|
309
305
|
return lines;
|
|
310
306
|
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Creates a signal for the key/object pairing and subscribes to the signal.
|
|
310
|
+
*
|
|
311
|
+
* Use when you need to ensure a signal exists and is subscribed to.
|
|
312
|
+
*
|
|
313
|
+
* @private
|
|
314
|
+
*/
|
|
311
315
|
function entangleSignal(signals, obj, key, initialValue) {
|
|
312
316
|
let internalSignal = peekInternalSignal(signals, key);
|
|
313
317
|
if (!internalSignal) {
|
|
@@ -375,16 +379,16 @@ function defineNonEnumerableSignal(obj, key, v) {
|
|
|
375
379
|
*/
|
|
376
380
|
function signal(target, key, descriptor) {
|
|
377
381
|
// Error on `@signal()`, `@signal(...args)``
|
|
378
|
-
|
|
382
|
+
(test => {
|
|
379
383
|
if (!test) {
|
|
380
384
|
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
385
|
}
|
|
382
|
-
})(target !== undefined)
|
|
383
|
-
|
|
386
|
+
})(target !== undefined);
|
|
387
|
+
(test => {
|
|
384
388
|
if (!test) {
|
|
385
389
|
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
390
|
}
|
|
387
|
-
})(typeof target === 'object' && typeof key === 'string' && typeof descriptor === 'object' && arguments.length === 3)
|
|
391
|
+
})(typeof target === 'object' && typeof key === 'string' && typeof descriptor === 'object' && arguments.length === 3);
|
|
388
392
|
return createSignalDescriptor(key, descriptor.initializer ? makeInitializer(descriptor.initializer) : null);
|
|
389
393
|
}
|
|
390
394
|
|
|
@@ -393,21 +397,21 @@ function signal(target, key, descriptor) {
|
|
|
393
397
|
*/
|
|
394
398
|
function memoized(target, key, descriptor) {
|
|
395
399
|
// Error on `@memoized()`, `@memoized(...args)`, and `@memoized propName = value;`
|
|
396
|
-
|
|
400
|
+
(test => {
|
|
397
401
|
if (!test) {
|
|
398
402
|
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
403
|
}
|
|
400
|
-
})(target !== undefined)
|
|
401
|
-
|
|
404
|
+
})(target !== undefined);
|
|
405
|
+
(test => {
|
|
402
406
|
if (!test) {
|
|
403
407
|
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
408
|
}
|
|
405
|
-
})(typeof target === 'object' && typeof key === 'string' && typeof descriptor === 'object' && arguments.length === 3)
|
|
406
|
-
|
|
409
|
+
})(typeof target === 'object' && typeof key === 'string' && typeof descriptor === 'object' && arguments.length === 3);
|
|
410
|
+
(test => {
|
|
407
411
|
if (!test) {
|
|
408
412
|
throw new Error(`The @memoized decorator must be applied to getters. '${key}' is not a getter.`);
|
|
409
413
|
}
|
|
410
|
-
})(typeof descriptor.get === 'function')
|
|
414
|
+
})(typeof descriptor.get === 'function');
|
|
411
415
|
|
|
412
416
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
413
417
|
const getter = descriptor.get;
|
|
@@ -512,11 +516,11 @@ const ReactiveDocumentProto = {
|
|
|
512
516
|
url: '',
|
|
513
517
|
method: 'GET'
|
|
514
518
|
})) {
|
|
515
|
-
|
|
519
|
+
(test => {
|
|
516
520
|
if (!test) {
|
|
517
521
|
throw new Error(`No self or related link`);
|
|
518
522
|
}
|
|
519
|
-
})(this.links?.related || this.links?.self)
|
|
523
|
+
})(this.links?.related || this.links?.self);
|
|
520
524
|
options.cacheOptions = options.cacheOptions || {};
|
|
521
525
|
options.cacheOptions.key = this.identifier?.lid;
|
|
522
526
|
return this._request(this.links.related ? 'related' : 'self', options);
|
|
@@ -551,11 +555,11 @@ const ReactiveDocumentProto = {
|
|
|
551
555
|
return data;
|
|
552
556
|
},
|
|
553
557
|
[Destroy]() {
|
|
554
|
-
|
|
558
|
+
(test => {
|
|
555
559
|
if (!test) {
|
|
556
560
|
throw new Error(`Cannot destroy a ReactiveDocument which has already been destroyed`);
|
|
557
561
|
}
|
|
558
|
-
})(this._store)
|
|
562
|
+
})(this._store);
|
|
559
563
|
if (this._subscription) {
|
|
560
564
|
this._store.notifications.unsubscribe(this._subscription);
|
|
561
565
|
// @ts-expect-error
|
|
@@ -580,11 +584,11 @@ defineGate(ReactiveDocumentProto, 'errors', {
|
|
|
580
584
|
return;
|
|
581
585
|
}
|
|
582
586
|
const doc = this._store.cache.peek(identifier);
|
|
583
|
-
|
|
587
|
+
(test => {
|
|
584
588
|
if (!test) {
|
|
585
589
|
throw new Error(`No cache data was found for the document '${identifier.lid}'`);
|
|
586
590
|
}
|
|
587
|
-
})(doc)
|
|
591
|
+
})(doc);
|
|
588
592
|
return 'errors' in doc ? doc.errors : undefined;
|
|
589
593
|
}
|
|
590
594
|
});
|
|
@@ -595,11 +599,11 @@ defineGate(ReactiveDocumentProto, 'data', {
|
|
|
595
599
|
_localCache
|
|
596
600
|
} = this;
|
|
597
601
|
const doc = identifier ? this._store.cache.peek(identifier) : _localCache.document;
|
|
598
|
-
|
|
602
|
+
(test => {
|
|
599
603
|
if (!test) {
|
|
600
604
|
throw new Error(`No cache data was found for the document '${identifier?.lid ?? '<uncached document>'}'`);
|
|
601
605
|
}
|
|
602
|
-
})(doc)
|
|
606
|
+
})(doc);
|
|
603
607
|
const data = 'data' in doc ? doc.data : undefined;
|
|
604
608
|
if (Array.isArray(data)) {
|
|
605
609
|
return identifier ? this._store.recordArrayManager.getCollection({
|
|
@@ -624,11 +628,11 @@ defineGate(ReactiveDocumentProto, 'links', {
|
|
|
624
628
|
return this._localCache.document.links;
|
|
625
629
|
}
|
|
626
630
|
const data = this._store.cache.peek(identifier);
|
|
627
|
-
|
|
631
|
+
(test => {
|
|
628
632
|
if (!test) {
|
|
629
633
|
throw new Error(`No cache data was found for the document '${identifier.lid}'`);
|
|
630
634
|
}
|
|
631
|
-
})(data)
|
|
635
|
+
})(data);
|
|
632
636
|
return data.links;
|
|
633
637
|
}
|
|
634
638
|
});
|
|
@@ -641,11 +645,11 @@ defineGate(ReactiveDocumentProto, 'meta', {
|
|
|
641
645
|
return this._localCache.document.meta;
|
|
642
646
|
}
|
|
643
647
|
const data = this._store.cache.peek(identifier);
|
|
644
|
-
|
|
648
|
+
(test => {
|
|
645
649
|
if (!test) {
|
|
646
650
|
throw new Error(`No cache data was found for the document '${identifier.lid}'`);
|
|
647
651
|
}
|
|
648
|
-
})(data)
|
|
652
|
+
})(data);
|
|
649
653
|
return data.meta;
|
|
650
654
|
}
|
|
651
655
|
});
|
|
@@ -775,31 +779,24 @@ function hasId(resource) {
|
|
|
775
779
|
function hasType(resource) {
|
|
776
780
|
return hasProp(resource, 'type');
|
|
777
781
|
}
|
|
782
|
+
|
|
783
|
+
// Used by the store to normalize IDs entering the store. Despite the fact
|
|
784
|
+
// that developers may provide IDs as numbers (e.g., `store.findRecord('person', 1)`),
|
|
785
|
+
// it is important that internally we use strings, since IDs may be serialized
|
|
786
|
+
// and lose type information. For example, Ember's router may put a record's
|
|
787
|
+
// ID into the URL, and if we later try to deserialize that URL and find the
|
|
788
|
+
// corresponding record, we will not know if it is a string or a number.
|
|
778
789
|
function coerceId(id) {
|
|
779
|
-
|
|
790
|
+
{
|
|
780
791
|
let normalized;
|
|
781
792
|
if (id === null || id === undefined || id === '') {
|
|
782
793
|
normalized = null;
|
|
783
794
|
} else {
|
|
784
795
|
normalized = String(id);
|
|
785
796
|
}
|
|
786
|
-
|
|
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
|
-
});
|
|
797
|
+
!(normalized === id) && console.warn(`The resource id '<${typeof id}> ${String(id)} ' is not normalized. Update your application code to use '${JSON.stringify(normalized)}' instead.`);
|
|
795
798
|
return normalized;
|
|
796
799
|
}
|
|
797
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
798
|
-
if (!test) {
|
|
799
|
-
throw new Error(`Resource IDs must be a non-empty string or null. Received '${String(id)}'.`);
|
|
800
|
-
}
|
|
801
|
-
})(id === null || typeof id === 'string' && id.length > 0) : {};
|
|
802
|
-
return id;
|
|
803
800
|
}
|
|
804
801
|
function ensureStringId(id) {
|
|
805
802
|
let normalized = null;
|
|
@@ -808,91 +805,38 @@ function ensureStringId(id) {
|
|
|
808
805
|
} else if (typeof id === 'number' && !isNaN(id)) {
|
|
809
806
|
normalized = String(id);
|
|
810
807
|
}
|
|
811
|
-
|
|
808
|
+
(test => {
|
|
812
809
|
if (!test) {
|
|
813
810
|
throw new Error(`Expected id to be a string or number, received ${String(id)}`);
|
|
814
811
|
}
|
|
815
|
-
})(normalized !== null)
|
|
812
|
+
})(normalized !== null);
|
|
816
813
|
return normalized;
|
|
817
814
|
}
|
|
818
815
|
function normalizeModelName(type) {
|
|
819
|
-
|
|
816
|
+
{
|
|
820
817
|
const result = dasherize(type);
|
|
821
|
-
|
|
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
|
-
});
|
|
818
|
+
!(result === type) && console.warn(`The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`);
|
|
830
819
|
return result;
|
|
831
820
|
}
|
|
832
|
-
return type;
|
|
833
|
-
}
|
|
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
821
|
}
|
|
871
822
|
function isResourceKey(identifier) {
|
|
872
|
-
|
|
823
|
+
{
|
|
873
824
|
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
825
|
}
|
|
877
826
|
}
|
|
878
827
|
function isRequestKey(identifier) {
|
|
879
|
-
|
|
828
|
+
{
|
|
880
829
|
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
830
|
}
|
|
884
831
|
}
|
|
885
832
|
const isFastBoot = typeof FastBoot !== 'undefined';
|
|
886
833
|
const _crypto = isFastBoot ? FastBoot.require('crypto') : globalThis.crypto;
|
|
887
|
-
if (macroCondition(getGlobalConfig().WarpDrive.polyfillUUID)) {
|
|
888
|
-
installPolyfill();
|
|
889
|
-
}
|
|
890
834
|
function uuidv4() {
|
|
891
|
-
|
|
835
|
+
(test => {
|
|
892
836
|
if (!test) {
|
|
893
837
|
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
838
|
}
|
|
895
|
-
})(typeof _crypto.randomUUID === 'function')
|
|
839
|
+
})(typeof _crypto.randomUUID === 'function');
|
|
896
840
|
return _crypto.randomUUID();
|
|
897
841
|
}
|
|
898
842
|
function freeze(obj) {
|
|
@@ -1088,11 +1032,11 @@ function updateTypeIdMapping(typeMap, identifier, id) {
|
|
|
1088
1032
|
}
|
|
1089
1033
|
function defaultUpdateMethod(identifier, data, bucket) {
|
|
1090
1034
|
if (bucket === 'record') {
|
|
1091
|
-
|
|
1035
|
+
(test => {
|
|
1092
1036
|
if (!test) {
|
|
1093
1037
|
throw new Error(`Expected identifier to be a ResourceKey`);
|
|
1094
1038
|
}
|
|
1095
|
-
})(isResourceKey(identifier))
|
|
1039
|
+
})(isResourceKey(identifier));
|
|
1096
1040
|
if (!identifier.id && hasId(data)) {
|
|
1097
1041
|
updateTypeIdMapping(NEW_IDENTIFIERS, identifier, data.id);
|
|
1098
1042
|
}
|
|
@@ -1102,11 +1046,11 @@ function defaultKeyInfoMethod(resource, known) {
|
|
|
1102
1046
|
// TODO RFC something to make this configurable
|
|
1103
1047
|
const id = hasId(resource) ? coerceId(resource.id) : null;
|
|
1104
1048
|
const type = hasType(resource) ? normalizeModelName(resource.type) : known ? known.type : null;
|
|
1105
|
-
|
|
1049
|
+
(test => {
|
|
1106
1050
|
if (!test) {
|
|
1107
1051
|
throw new Error(`Expected keyInfoForResource to provide a type for the resource`);
|
|
1108
1052
|
}
|
|
1109
|
-
})(type)
|
|
1053
|
+
})(type);
|
|
1110
1054
|
return {
|
|
1111
1055
|
type,
|
|
1112
1056
|
id
|
|
@@ -1117,11 +1061,11 @@ function defaultGenerationMethod(data, bucket) {
|
|
|
1117
1061
|
if (hasLid(data)) {
|
|
1118
1062
|
return data.lid;
|
|
1119
1063
|
}
|
|
1120
|
-
|
|
1064
|
+
(test => {
|
|
1121
1065
|
if (!test) {
|
|
1122
1066
|
throw new Error(`Cannot generate an identifier for a resource without a type`);
|
|
1123
1067
|
}
|
|
1124
|
-
})(hasType(data))
|
|
1068
|
+
})(hasType(data));
|
|
1125
1069
|
if (hasId(data)) {
|
|
1126
1070
|
const type = normalizeModelName(data.type);
|
|
1127
1071
|
const lid = NEW_IDENTIFIERS.get(type)?.get(data.id);
|
|
@@ -1137,18 +1081,18 @@ function defaultGenerationMethod(data, bucket) {
|
|
|
1137
1081
|
}
|
|
1138
1082
|
return null;
|
|
1139
1083
|
}
|
|
1140
|
-
|
|
1084
|
+
(test => {
|
|
1141
1085
|
{
|
|
1142
1086
|
throw new Error(`Unknown bucket ${bucket}`);
|
|
1143
1087
|
}
|
|
1144
|
-
})()
|
|
1088
|
+
})();
|
|
1145
1089
|
}
|
|
1146
1090
|
function defaultEmptyCallback(...args) {}
|
|
1147
1091
|
function defaultMergeMethod(a, _b, _c) {
|
|
1148
1092
|
return a;
|
|
1149
1093
|
}
|
|
1150
1094
|
let DEBUG_MAP;
|
|
1151
|
-
|
|
1095
|
+
{
|
|
1152
1096
|
DEBUG_MAP = getOrSetGlobal('DEBUG_MAP', new WeakMap());
|
|
1153
1097
|
}
|
|
1154
1098
|
|
|
@@ -1225,21 +1169,20 @@ class CacheKeyManager {
|
|
|
1225
1169
|
|
|
1226
1170
|
/** @internal */
|
|
1227
1171
|
_getRecordIdentifier(resource, shouldGenerate) {
|
|
1228
|
-
|
|
1172
|
+
{
|
|
1229
1173
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1230
1174
|
// eslint-disable-next-line no-console
|
|
1231
1175
|
console.groupCollapsed(`Identifiers: ${shouldGenerate ? 'Generating' : 'Peeking'} Identifier`, resource);
|
|
1232
1176
|
}
|
|
1233
|
-
}
|
|
1234
|
-
// short circuit if we're already the stable version
|
|
1177
|
+
} // short circuit if we're already the stable version
|
|
1235
1178
|
if (isResourceKey(resource)) {
|
|
1236
|
-
|
|
1179
|
+
{
|
|
1237
1180
|
// TODO should we instead just treat this case as a new generation skipping the short circuit?
|
|
1238
1181
|
if (!this._cache.resources.has(resource.lid) || this._cache.resources.get(resource.lid) !== resource) {
|
|
1239
1182
|
throw new Error(`The supplied identifier ${JSON.stringify(resource)} does not belong to this store instance`);
|
|
1240
1183
|
}
|
|
1241
1184
|
}
|
|
1242
|
-
|
|
1185
|
+
{
|
|
1243
1186
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1244
1187
|
// eslint-disable-next-line no-console
|
|
1245
1188
|
console.log(`Identifiers: cache HIT - Stable ${resource.lid}`);
|
|
@@ -1252,7 +1195,7 @@ class CacheKeyManager {
|
|
|
1252
1195
|
|
|
1253
1196
|
// the resource is unknown, ask the application to identify this data for us
|
|
1254
1197
|
const lid = this._generate(resource, 'record');
|
|
1255
|
-
|
|
1198
|
+
{
|
|
1256
1199
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1257
1200
|
// eslint-disable-next-line no-console
|
|
1258
1201
|
console.log(`Identifiers: ${lid ? 'no ' : ''}lid ${lid ? lid + ' ' : ''}determined for resource`, resource);
|
|
@@ -1260,7 +1203,7 @@ class CacheKeyManager {
|
|
|
1260
1203
|
}
|
|
1261
1204
|
let identifier = /*#__NOINLINE__*/getIdentifierFromLid(this._cache, lid, resource);
|
|
1262
1205
|
if (identifier !== null) {
|
|
1263
|
-
|
|
1206
|
+
{
|
|
1264
1207
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1265
1208
|
// eslint-disable-next-line no-console
|
|
1266
1209
|
console.groupEnd();
|
|
@@ -1269,7 +1212,7 @@ class CacheKeyManager {
|
|
|
1269
1212
|
return identifier;
|
|
1270
1213
|
}
|
|
1271
1214
|
if (shouldGenerate === 0) {
|
|
1272
|
-
|
|
1215
|
+
{
|
|
1273
1216
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1274
1217
|
// eslint-disable-next-line no-console
|
|
1275
1218
|
console.groupEnd();
|
|
@@ -1291,7 +1234,7 @@ class CacheKeyManager {
|
|
|
1291
1234
|
identifier = /*#__NOINLINE__*/makeResourceKey(keyInfo, 'record', false);
|
|
1292
1235
|
}
|
|
1293
1236
|
addResourceToCache(this._cache, identifier);
|
|
1294
|
-
|
|
1237
|
+
{
|
|
1295
1238
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1296
1239
|
// eslint-disable-next-line no-console
|
|
1297
1240
|
console.groupEnd();
|
|
@@ -1361,7 +1304,7 @@ class CacheKeyManager {
|
|
|
1361
1304
|
type: '@document',
|
|
1362
1305
|
[CACHE_OWNER]: this._id
|
|
1363
1306
|
};
|
|
1364
|
-
|
|
1307
|
+
{
|
|
1365
1308
|
Object.freeze(identifier);
|
|
1366
1309
|
}
|
|
1367
1310
|
this._cache.documents.set(cacheKey, identifier);
|
|
@@ -1400,7 +1343,7 @@ class CacheKeyManager {
|
|
|
1400
1343
|
}, 'record', true);
|
|
1401
1344
|
|
|
1402
1345
|
// populate our unique table
|
|
1403
|
-
|
|
1346
|
+
{
|
|
1404
1347
|
if (this._cache.resources.has(identifier.lid)) {
|
|
1405
1348
|
throw new Error(`The lid generated for the new record is not unique as it matches an existing identifier`);
|
|
1406
1349
|
}
|
|
@@ -1408,7 +1351,7 @@ class CacheKeyManager {
|
|
|
1408
1351
|
|
|
1409
1352
|
/*#__NOINLINE__*/
|
|
1410
1353
|
addResourceToCache(this._cache, identifier);
|
|
1411
|
-
|
|
1354
|
+
{
|
|
1412
1355
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1413
1356
|
// eslint-disable-next-line no-console
|
|
1414
1357
|
console.log(`Identifiers: created identifier ${String(identifier)} for newly generated resource`, data);
|
|
@@ -1456,7 +1399,7 @@ class CacheKeyManager {
|
|
|
1456
1399
|
if (hadLid) {
|
|
1457
1400
|
data.lid = identifier.lid;
|
|
1458
1401
|
}
|
|
1459
|
-
|
|
1402
|
+
{
|
|
1460
1403
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1461
1404
|
// eslint-disable-next-line no-console
|
|
1462
1405
|
console.log(`Identifiers: merged identifiers ${generatedIdentifier.lid} and ${existingIdentifier.lid} for resource into ${identifier.lid}`, data);
|
|
@@ -1470,23 +1413,23 @@ class CacheKeyManager {
|
|
|
1470
1413
|
|
|
1471
1414
|
// add to our own secondary lookup table
|
|
1472
1415
|
if (id !== newId && newId !== null) {
|
|
1473
|
-
|
|
1416
|
+
{
|
|
1474
1417
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1475
1418
|
// eslint-disable-next-line no-console
|
|
1476
1419
|
console.log(`Identifiers: updated id for identifier ${identifier.lid} from '${String(id)}' to '${String(newId)}' for resource`, data);
|
|
1477
1420
|
}
|
|
1478
1421
|
}
|
|
1479
1422
|
const typeSet = this._cache.resourcesByType[identifier.type];
|
|
1480
|
-
|
|
1423
|
+
(test => {
|
|
1481
1424
|
if (!test) {
|
|
1482
1425
|
throw new Error(`Expected to find a typeSet for ${identifier.type}`);
|
|
1483
1426
|
}
|
|
1484
|
-
})(typeSet)
|
|
1427
|
+
})(typeSet);
|
|
1485
1428
|
typeSet.id.set(newId, identifier);
|
|
1486
1429
|
if (id !== null) {
|
|
1487
1430
|
typeSet.id.delete(id);
|
|
1488
1431
|
}
|
|
1489
|
-
} else
|
|
1432
|
+
} else {
|
|
1490
1433
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1491
1434
|
// eslint-disable-next-line no-console
|
|
1492
1435
|
console.log(`Identifiers: updated identifier ${identifier.lid} resource`, data);
|
|
@@ -1499,11 +1442,11 @@ class CacheKeyManager {
|
|
|
1499
1442
|
* @internal
|
|
1500
1443
|
*/
|
|
1501
1444
|
_mergeRecordIdentifiers(keyInfo, identifier, existingIdentifier, data) {
|
|
1502
|
-
|
|
1445
|
+
(test => {
|
|
1503
1446
|
if (!test) {
|
|
1504
1447
|
throw new Error(`Expected keyInfo to contain an id`);
|
|
1505
1448
|
}
|
|
1506
|
-
})(hasId(keyInfo))
|
|
1449
|
+
})(hasId(keyInfo));
|
|
1507
1450
|
// delegate determining which identifier to keep to the configured MergeMethod
|
|
1508
1451
|
const kept = this._merge(identifier, existingIdentifier, data);
|
|
1509
1452
|
const abandoned = kept === identifier ? existingIdentifier : identifier;
|
|
@@ -1549,11 +1492,11 @@ class CacheKeyManager {
|
|
|
1549
1492
|
forgetRecordIdentifier(identifierObject) {
|
|
1550
1493
|
const identifier = this.getOrCreateRecordIdentifier(identifierObject);
|
|
1551
1494
|
const typeSet = this._cache.resourcesByType[identifier.type];
|
|
1552
|
-
|
|
1495
|
+
(test => {
|
|
1553
1496
|
if (!test) {
|
|
1554
1497
|
throw new Error(`Expected to find a typeSet for ${identifier.type}`);
|
|
1555
1498
|
}
|
|
1556
|
-
})(typeSet)
|
|
1499
|
+
})(typeSet);
|
|
1557
1500
|
if (identifier.id !== null) {
|
|
1558
1501
|
typeSet.id.delete(identifier.id);
|
|
1559
1502
|
}
|
|
@@ -1566,12 +1509,12 @@ class CacheKeyManager {
|
|
|
1566
1509
|
});
|
|
1567
1510
|
this._cache.polymorphicLidBackMap.delete(identifier.lid);
|
|
1568
1511
|
}
|
|
1569
|
-
|
|
1512
|
+
{
|
|
1570
1513
|
identifier[DEBUG_STALE_CACHE_OWNER] = identifier[CACHE_OWNER];
|
|
1571
1514
|
}
|
|
1572
1515
|
identifier[CACHE_OWNER] = undefined;
|
|
1573
1516
|
this._forget(identifier, 'record');
|
|
1574
|
-
|
|
1517
|
+
{
|
|
1575
1518
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1576
1519
|
// eslint-disable-next-line no-console
|
|
1577
1520
|
console.log(`Identifiers: released identifier ${identifierObject.lid}`);
|
|
@@ -1595,7 +1538,7 @@ class CacheKeyManager {
|
|
|
1595
1538
|
*/
|
|
1596
1539
|
|
|
1597
1540
|
function makeResourceKey(recordIdentifier, bucket, clientOriginated) {
|
|
1598
|
-
|
|
1541
|
+
{
|
|
1599
1542
|
// we enforce immutability in dev
|
|
1600
1543
|
// but preserve our ability to do controlled updates to the reference
|
|
1601
1544
|
let wrapper = {
|
|
@@ -1656,10 +1599,9 @@ function makeResourceKey(recordIdentifier, bucket, clientOriginated) {
|
|
|
1656
1599
|
wrapper = freeze(wrapper);
|
|
1657
1600
|
return wrapper;
|
|
1658
1601
|
}
|
|
1659
|
-
return recordIdentifier;
|
|
1660
1602
|
}
|
|
1661
1603
|
function performRecordIdentifierUpdate(identifier, keyInfo, data, updateFn) {
|
|
1662
|
-
|
|
1604
|
+
{
|
|
1663
1605
|
const {
|
|
1664
1606
|
id,
|
|
1665
1607
|
type
|
|
@@ -1677,7 +1619,7 @@ function performRecordIdentifierUpdate(identifier, keyInfo, data, updateFn) {
|
|
|
1677
1619
|
if (id && identifier.id !== null && identifier.id !== id) {
|
|
1678
1620
|
// here we warn and ignore, as this may be a mistake, but we allow the user
|
|
1679
1621
|
// 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, {
|
|
1622
|
+
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
1623
|
id: 'ember-data:multiple-ids-for-identifier'
|
|
1682
1624
|
});
|
|
1683
1625
|
}
|
|
@@ -1687,8 +1629,6 @@ function performRecordIdentifierUpdate(identifier, keyInfo, data, updateFn) {
|
|
|
1687
1629
|
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
1630
|
}
|
|
1689
1631
|
updateFn(wrapper, data, 'record');
|
|
1690
|
-
} else {
|
|
1691
|
-
updateFn(identifier, data, 'record');
|
|
1692
1632
|
}
|
|
1693
1633
|
|
|
1694
1634
|
// upgrade the ID, this is a "one time only" ability
|
|
@@ -1734,7 +1674,7 @@ function detectMerge(cache, keyInfo, identifier, data) {
|
|
|
1734
1674
|
}
|
|
1735
1675
|
function getIdentifierFromLid(cache, lid, resource) {
|
|
1736
1676
|
const identifier = cache.resources.get(lid);
|
|
1737
|
-
|
|
1677
|
+
{
|
|
1738
1678
|
if (getGlobalConfig().WarpDrive.debug.LOG_IDENTIFIERS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_IDENTIFIERS) {
|
|
1739
1679
|
// eslint-disable-next-line no-console
|
|
1740
1680
|
console.log(`Identifiers: cache ${identifier ? 'HIT' : 'MISS'} - Non-Stable ${lid}`, resource);
|
|
@@ -1816,11 +1756,11 @@ class CacheCapabilitiesManager {
|
|
|
1816
1756
|
});
|
|
1817
1757
|
}
|
|
1818
1758
|
notifyChange(identifier, namespace, key) {
|
|
1819
|
-
|
|
1759
|
+
(test => {
|
|
1820
1760
|
if (!test) {
|
|
1821
1761
|
throw new Error(`Expected a stable identifier`);
|
|
1822
1762
|
}
|
|
1823
|
-
})(isResourceKey(identifier) || isRequestKey(identifier))
|
|
1763
|
+
})(isResourceKey(identifier) || isRequestKey(identifier));
|
|
1824
1764
|
|
|
1825
1765
|
// TODO do we still get value from this?
|
|
1826
1766
|
if (namespace === 'relationships' && key) {
|
|
@@ -1835,22 +1775,22 @@ class CacheCapabilitiesManager {
|
|
|
1835
1775
|
return this._store.schema;
|
|
1836
1776
|
}
|
|
1837
1777
|
setRecordId(identifier, id) {
|
|
1838
|
-
|
|
1778
|
+
(test => {
|
|
1839
1779
|
if (!test) {
|
|
1840
1780
|
throw new Error(`Expected a stable identifier`);
|
|
1841
1781
|
}
|
|
1842
|
-
})(isResourceKey(identifier))
|
|
1782
|
+
})(isResourceKey(identifier));
|
|
1843
1783
|
this._store._instanceCache.setRecordId(identifier, id);
|
|
1844
1784
|
}
|
|
1845
1785
|
hasRecord(identifier) {
|
|
1846
1786
|
return Boolean(this._store._instanceCache.peek(identifier));
|
|
1847
1787
|
}
|
|
1848
1788
|
disconnectRecord(identifier) {
|
|
1849
|
-
|
|
1789
|
+
(test => {
|
|
1850
1790
|
if (!test) {
|
|
1851
1791
|
throw new Error(`Expected a stable identifier`);
|
|
1852
1792
|
}
|
|
1853
|
-
})(isResourceKey(identifier))
|
|
1793
|
+
})(isResourceKey(identifier));
|
|
1854
1794
|
this._store._instanceCache.disconnect(identifier);
|
|
1855
1795
|
this._pendingNotifies.delete(identifier);
|
|
1856
1796
|
}
|
|
@@ -1864,7 +1804,7 @@ class CacheCapabilitiesManager {
|
|
|
1864
1804
|
* @private
|
|
1865
1805
|
*/
|
|
1866
1806
|
|
|
1867
|
-
|
|
1807
|
+
{
|
|
1868
1808
|
CacheCapabilitiesManager.prototype.getSchemaDefinitionService = function () {
|
|
1869
1809
|
// FIXME add deprecation for this
|
|
1870
1810
|
return this.schema;
|
|
@@ -1898,15 +1838,15 @@ function peekResourceKey(record) {
|
|
|
1898
1838
|
*/
|
|
1899
1839
|
|
|
1900
1840
|
function recordIdentifierFor(record) {
|
|
1901
|
-
|
|
1841
|
+
(test => {
|
|
1902
1842
|
if (!test) {
|
|
1903
1843
|
throw new Error(`${String(record)} is not a ReactiveResource or Model known to WarpDrive`);
|
|
1904
1844
|
}
|
|
1905
|
-
})(RecordCache.has(record))
|
|
1845
|
+
})(RecordCache.has(record));
|
|
1906
1846
|
return RecordCache.get(record);
|
|
1907
1847
|
}
|
|
1908
1848
|
function setRecordIdentifier(record, identifier) {
|
|
1909
|
-
|
|
1849
|
+
{
|
|
1910
1850
|
if (RecordCache.has(record) && RecordCache.get(record) !== identifier) {
|
|
1911
1851
|
throw new Error(`${String(record)} was already assigned an identifier`);
|
|
1912
1852
|
}
|
|
@@ -1923,7 +1863,7 @@ function setRecordIdentifier(record, identifier) {
|
|
|
1923
1863
|
RecordCache.set(record, identifier);
|
|
1924
1864
|
}
|
|
1925
1865
|
function removeRecordIdentifier(record) {
|
|
1926
|
-
|
|
1866
|
+
{
|
|
1927
1867
|
if (!RecordCache.has(record)) {
|
|
1928
1868
|
throw new Error(`${String(record)} had no assigned identifier to remove`);
|
|
1929
1869
|
}
|
|
@@ -1938,11 +1878,11 @@ const StoreMap = getOrSetGlobal('StoreMap', new Map());
|
|
|
1938
1878
|
*/
|
|
1939
1879
|
function storeFor(record, ignoreMissing) {
|
|
1940
1880
|
const store = StoreMap.get(record);
|
|
1941
|
-
|
|
1881
|
+
(test => {
|
|
1942
1882
|
if (!test) {
|
|
1943
1883
|
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
1884
|
}
|
|
1945
|
-
})(ignoreMissing || store)
|
|
1885
|
+
})(ignoreMissing || store);
|
|
1946
1886
|
return store ?? null;
|
|
1947
1887
|
}
|
|
1948
1888
|
class InstanceCache {
|
|
@@ -1980,11 +1920,11 @@ class InstanceCache {
|
|
|
1980
1920
|
if ('id' in resourceData) {
|
|
1981
1921
|
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
1922
|
}
|
|
1983
|
-
|
|
1923
|
+
(test => {
|
|
1984
1924
|
{
|
|
1985
1925
|
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
1926
|
}
|
|
1987
|
-
})()
|
|
1927
|
+
})();
|
|
1988
1928
|
}
|
|
1989
1929
|
this.store.cache.patch({
|
|
1990
1930
|
op: 'mergeIdentifiers',
|
|
@@ -2044,42 +1984,40 @@ class InstanceCache {
|
|
|
2044
1984
|
}
|
|
2045
1985
|
disconnect(identifier) {
|
|
2046
1986
|
const record = this.__instances.record.get(identifier);
|
|
2047
|
-
|
|
1987
|
+
(test => {
|
|
2048
1988
|
if (!test) {
|
|
2049
1989
|
throw new Error('Cannot destroy record while it is still materialized');
|
|
2050
1990
|
}
|
|
2051
|
-
})(!isDestroyable(record) || record.isDestroyed || record.isDestroying)
|
|
1991
|
+
})(!isDestroyable(record) || record.isDestroyed || record.isDestroying);
|
|
2052
1992
|
this.store._graph?.remove(identifier);
|
|
2053
1993
|
this.store.cacheKeyManager.forgetRecordIdentifier(identifier);
|
|
2054
1994
|
StoreMap.delete(identifier);
|
|
2055
1995
|
this.store._requestCache._clearEntries(identifier);
|
|
2056
|
-
|
|
1996
|
+
{
|
|
2057
1997
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2058
1998
|
log('reactive-ui', '', identifier.type, identifier.lid, 'disconnected', '');
|
|
2059
1999
|
}
|
|
2060
2000
|
}
|
|
2061
2001
|
}
|
|
2062
2002
|
unloadRecord(identifier) {
|
|
2063
|
-
|
|
2003
|
+
{
|
|
2064
2004
|
const requests = this.store.getRequestStateService().getPendingRequestsForRecord(identifier);
|
|
2065
2005
|
if (requests.some(req => {
|
|
2066
2006
|
return req.type === 'mutation';
|
|
2067
2007
|
})) {
|
|
2068
|
-
|
|
2008
|
+
(test => {
|
|
2069
2009
|
{
|
|
2070
2010
|
throw new Error(`You can only unload a record which is not inFlight. '${String(identifier)}'`);
|
|
2071
2011
|
}
|
|
2072
|
-
})()
|
|
2012
|
+
})();
|
|
2073
2013
|
}
|
|
2074
2014
|
}
|
|
2075
|
-
|
|
2015
|
+
{
|
|
2076
2016
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2077
2017
|
// eslint-disable-next-line no-console
|
|
2078
2018
|
console.groupCollapsed(`InstanceCache: unloading record for ${String(identifier)}`);
|
|
2079
2019
|
}
|
|
2080
|
-
}
|
|
2081
|
-
|
|
2082
|
-
// TODO is this join still necessary?
|
|
2020
|
+
} // TODO is this join still necessary?
|
|
2083
2021
|
this.store._join(() => {
|
|
2084
2022
|
unloadRecord(this, identifier);
|
|
2085
2023
|
});
|
|
@@ -2115,27 +2053,27 @@ class InstanceCache {
|
|
|
2115
2053
|
const oldId = identifier.id;
|
|
2116
2054
|
|
|
2117
2055
|
// ID absolutely can't be missing if the oldID is empty (missing Id in response for a new record)
|
|
2118
|
-
|
|
2056
|
+
(test => {
|
|
2119
2057
|
if (!test) {
|
|
2120
2058
|
throw new Error(`'${type}' was saved to the server, but the response does not have an id and your record does not either.`);
|
|
2121
2059
|
}
|
|
2122
|
-
})(!(id === null && oldId === null))
|
|
2060
|
+
})(!(id === null && oldId === null));
|
|
2123
2061
|
|
|
2124
2062
|
// ID absolutely can't be different than oldID if oldID is not null
|
|
2125
2063
|
// TODO this assertion and restriction may not strictly be needed in the identifiers world
|
|
2126
|
-
|
|
2064
|
+
(test => {
|
|
2127
2065
|
if (!test) {
|
|
2128
2066
|
throw new Error(`Cannot update the id for '${type}:${lid}' from '${String(oldId)}' to '${id}'.`);
|
|
2129
2067
|
}
|
|
2130
|
-
})(!(oldId !== null && id !== oldId))
|
|
2068
|
+
})(!(oldId !== null && id !== oldId));
|
|
2131
2069
|
|
|
2132
2070
|
// ID can be null if oldID is not null (altered ID in response for a record)
|
|
2133
2071
|
// however, this is more than likely a developer error.
|
|
2134
2072
|
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));
|
|
2073
|
+
console.warn(`Your ${type} record was saved to the server, but the response does not have an id.`, !(oldId !== null && id === null));
|
|
2136
2074
|
return;
|
|
2137
2075
|
}
|
|
2138
|
-
|
|
2076
|
+
{
|
|
2139
2077
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2140
2078
|
// eslint-disable-next-line no-console
|
|
2141
2079
|
console.log(`InstanceCache: updating id to '${id}' for record ${String(identifier)}`);
|
|
@@ -2145,11 +2083,11 @@ class InstanceCache {
|
|
|
2145
2083
|
type,
|
|
2146
2084
|
id
|
|
2147
2085
|
});
|
|
2148
|
-
|
|
2086
|
+
(test => {
|
|
2149
2087
|
if (!test) {
|
|
2150
2088
|
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
2089
|
}
|
|
2152
|
-
})(!existingIdentifier || existingIdentifier === identifier)
|
|
2090
|
+
})(!existingIdentifier || existingIdentifier === identifier);
|
|
2153
2091
|
if (identifier.id === null) {
|
|
2154
2092
|
// TODO potentially this needs to handle merged result
|
|
2155
2093
|
this.store.cacheKeyManager.updateRecordIdentifier(identifier, {
|
|
@@ -2182,16 +2120,16 @@ function getNewRecord(instances, identifier, properties) {
|
|
|
2182
2120
|
return record;
|
|
2183
2121
|
}
|
|
2184
2122
|
function _createRecord(instances, identifier, properties) {
|
|
2185
|
-
|
|
2123
|
+
(test => {
|
|
2186
2124
|
if (!test) {
|
|
2187
2125
|
throw new Error(`Cannot create a new record instance while the store is being destroyed`);
|
|
2188
2126
|
}
|
|
2189
|
-
})(!instances.store.isDestroying && !instances.store.isDestroyed)
|
|
2127
|
+
})(!instances.store.isDestroying && !instances.store.isDestroyed);
|
|
2190
2128
|
const record = instances.store.instantiateRecord(identifier, properties);
|
|
2191
2129
|
setRecordIdentifier(record, identifier);
|
|
2192
2130
|
StoreMap.set(record, instances.store);
|
|
2193
2131
|
instances.__instances.record.set(identifier, record);
|
|
2194
|
-
|
|
2132
|
+
{
|
|
2195
2133
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2196
2134
|
logGroup('reactive-ui', '', identifier.type, identifier.lid, 'created', '');
|
|
2197
2135
|
// eslint-disable-next-line no-console
|
|
@@ -2212,7 +2150,7 @@ function unloadRecord(instances, identifier) {
|
|
|
2212
2150
|
instances.__instances.record.delete(identifier);
|
|
2213
2151
|
StoreMap.delete(record);
|
|
2214
2152
|
RecordCache.delete(record);
|
|
2215
|
-
|
|
2153
|
+
{
|
|
2216
2154
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2217
2155
|
// eslint-disable-next-line no-console
|
|
2218
2156
|
console.log(`InstanceCache: destroyed record for ${String(identifier)}`);
|
|
@@ -2222,7 +2160,7 @@ function unloadRecord(instances, identifier) {
|
|
|
2222
2160
|
if (cache) {
|
|
2223
2161
|
cache.unloadRecord(identifier);
|
|
2224
2162
|
StoreMap.delete(identifier);
|
|
2225
|
-
|
|
2163
|
+
{
|
|
2226
2164
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2227
2165
|
// eslint-disable-next-line no-console
|
|
2228
2166
|
console.log(`InstanceCache: destroyed cache for ${String(identifier)}`);
|
|
@@ -2232,7 +2170,7 @@ function unloadRecord(instances, identifier) {
|
|
|
2232
2170
|
instances.disconnect(identifier);
|
|
2233
2171
|
}
|
|
2234
2172
|
instances.store._requestCache._clearEntries(identifier);
|
|
2235
|
-
|
|
2173
|
+
{
|
|
2236
2174
|
if (getGlobalConfig().WarpDrive.debug.LOG_INSTANCE_CACHE || globalThis.getWarpDriveRuntimeConfig().debug.LOG_INSTANCE_CACHE) {
|
|
2237
2175
|
// eslint-disable-next-line no-console
|
|
2238
2176
|
console.log(`InstanceCache: unloaded RecordData for ${String(identifier)}`);
|
|
@@ -2746,16 +2684,16 @@ function count(label) {
|
|
|
2746
2684
|
globalThis.__WarpDriveMetricCountData[label] = (globalThis.__WarpDriveMetricCountData[label] || 0) + 1;
|
|
2747
2685
|
}
|
|
2748
2686
|
function asInternalToken(token) {
|
|
2749
|
-
|
|
2687
|
+
(test => {
|
|
2750
2688
|
if (!test) {
|
|
2751
2689
|
throw new Error(`Expected a token with a 'for' property`);
|
|
2752
2690
|
}
|
|
2753
|
-
})(token && typeof token === 'function' && 'for' in token)
|
|
2691
|
+
})(token && typeof token === 'function' && 'for' in token);
|
|
2754
2692
|
}
|
|
2755
2693
|
function _unsubscribe(token, cache) {
|
|
2756
2694
|
asInternalToken(token);
|
|
2757
2695
|
const cacheKey = token.for;
|
|
2758
|
-
|
|
2696
|
+
{
|
|
2759
2697
|
if (getGlobalConfig().WarpDrive.debug.LOG_NOTIFICATIONS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_NOTIFICATIONS) {
|
|
2760
2698
|
if (!cacheKey) {
|
|
2761
2699
|
// eslint-disable-next-line no-console
|
|
@@ -2770,11 +2708,11 @@ function _unsubscribe(token, cache) {
|
|
|
2770
2708
|
}
|
|
2771
2709
|
const index = callbacks.indexOf(token);
|
|
2772
2710
|
if (index === -1) {
|
|
2773
|
-
|
|
2711
|
+
(test => {
|
|
2774
2712
|
if (!test) {
|
|
2775
2713
|
throw new Error(`Cannot unsubscribe a token that is not subscribed`);
|
|
2776
2714
|
}
|
|
2777
|
-
})(index !== -1)
|
|
2715
|
+
})(index !== -1);
|
|
2778
2716
|
return;
|
|
2779
2717
|
}
|
|
2780
2718
|
callbacks.splice(index, 1);
|
|
@@ -2839,27 +2777,27 @@ class NotificationManager {
|
|
|
2839
2777
|
*/
|
|
2840
2778
|
|
|
2841
2779
|
subscribe(cacheKey, callback) {
|
|
2842
|
-
|
|
2780
|
+
(test => {
|
|
2843
2781
|
if (!test) {
|
|
2844
2782
|
throw new Error(`Expected not to be destroyed`);
|
|
2845
2783
|
}
|
|
2846
|
-
})(!this.isDestroyed)
|
|
2847
|
-
|
|
2784
|
+
})(!this.isDestroyed);
|
|
2785
|
+
(test => {
|
|
2848
2786
|
if (!test) {
|
|
2849
2787
|
throw new Error(`Expected to receive a stable Identifier to subscribe to`);
|
|
2850
2788
|
}
|
|
2851
|
-
})(cacheKey === 'resource' || cacheKey === 'document' || isResourceKey(cacheKey) || isRequestKey(cacheKey))
|
|
2789
|
+
})(cacheKey === 'resource' || cacheKey === 'document' || isResourceKey(cacheKey) || isRequestKey(cacheKey));
|
|
2852
2790
|
let callbacks = this._cache.get(cacheKey);
|
|
2853
|
-
|
|
2791
|
+
(test => {
|
|
2854
2792
|
if (!test) {
|
|
2855
2793
|
throw new Error(`expected to receive a valid callback`);
|
|
2856
2794
|
}
|
|
2857
|
-
})(typeof callback === 'function')
|
|
2858
|
-
|
|
2795
|
+
})(typeof callback === 'function');
|
|
2796
|
+
(test => {
|
|
2859
2797
|
if (!test) {
|
|
2860
2798
|
throw new Error(`cannot subscribe with the same callback twice`);
|
|
2861
2799
|
}
|
|
2862
|
-
})(!callbacks || !callbacks.includes(callback))
|
|
2800
|
+
})(!callbacks || !callbacks.includes(callback));
|
|
2863
2801
|
// we use the callback as the cancellation token
|
|
2864
2802
|
//@ts-expect-error
|
|
2865
2803
|
callback.for = cacheKey;
|
|
@@ -2892,13 +2830,13 @@ class NotificationManager {
|
|
|
2892
2830
|
if (this.isDestroyed) {
|
|
2893
2831
|
return false;
|
|
2894
2832
|
}
|
|
2895
|
-
|
|
2833
|
+
(test => {
|
|
2896
2834
|
if (!test) {
|
|
2897
2835
|
throw new Error(`Notify does not accept a key argument for the namespace '${value}'. Received key '${key || ''}'.`);
|
|
2898
2836
|
}
|
|
2899
|
-
})(!key || value === 'attributes' || value === 'relationships')
|
|
2837
|
+
})(!key || value === 'attributes' || value === 'relationships');
|
|
2900
2838
|
if (!isResourceKey(cacheKey) && !isRequestKey(cacheKey)) {
|
|
2901
|
-
|
|
2839
|
+
{
|
|
2902
2840
|
if (getGlobalConfig().WarpDrive.debug.LOG_NOTIFICATIONS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_NOTIFICATIONS) {
|
|
2903
2841
|
// eslint-disable-next-line no-console
|
|
2904
2842
|
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 +2852,25 @@ class NotificationManager {
|
|
|
2914
2852
|
this._buffered.set(cacheKey, buffer);
|
|
2915
2853
|
}
|
|
2916
2854
|
buffer.push([value, key || null]);
|
|
2917
|
-
|
|
2855
|
+
{
|
|
2918
2856
|
if (getGlobalConfig().WarpDrive.debug.LOG_METRIC_COUNTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_METRIC_COUNTS) {
|
|
2919
2857
|
count(`notify ${'type' in cacheKey ? cacheKey.type : '<document>'} ${value} ${key}`);
|
|
2920
2858
|
}
|
|
2921
2859
|
}
|
|
2922
2860
|
if (!this._scheduleNotify()) {
|
|
2923
|
-
|
|
2861
|
+
{
|
|
2924
2862
|
if (getGlobalConfig().WarpDrive.debug.LOG_NOTIFICATIONS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_NOTIFICATIONS) {
|
|
2925
2863
|
log('notify', 'buffered', `${'type' in cacheKey ? cacheKey.type : 'document'}`, cacheKey.lid, `${value}`, key || '');
|
|
2926
2864
|
}
|
|
2927
2865
|
}
|
|
2928
2866
|
}
|
|
2929
2867
|
} else {
|
|
2930
|
-
|
|
2868
|
+
{
|
|
2931
2869
|
if (getGlobalConfig().WarpDrive.debug.LOG_NOTIFICATIONS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_NOTIFICATIONS) {
|
|
2932
2870
|
log('notify', 'discarded', `${'type' in cacheKey ? cacheKey.type : 'document'}`, cacheKey.lid, `${value}`, key || '');
|
|
2933
2871
|
}
|
|
2934
2872
|
}
|
|
2935
|
-
|
|
2873
|
+
{
|
|
2936
2874
|
if (getGlobalConfig().WarpDrive.debug.LOG_METRIC_COUNTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_METRIC_COUNTS) {
|
|
2937
2875
|
count(`DISCARDED notify ${'type' in cacheKey ? cacheKey.type : '<document>'} ${value} ${key}`);
|
|
2938
2876
|
}
|
|
@@ -2995,13 +2933,11 @@ class NotificationManager {
|
|
|
2995
2933
|
*/
|
|
2996
2934
|
|
|
2997
2935
|
function _flushNotification(cache, cacheKey, value, key) {
|
|
2998
|
-
|
|
2936
|
+
{
|
|
2999
2937
|
if (getGlobalConfig().WarpDrive.debug.LOG_NOTIFICATIONS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_NOTIFICATIONS) {
|
|
3000
2938
|
log('notify', '', `${'type' in cacheKey ? cacheKey.type : 'document'}`, cacheKey.lid, `${value}`, key || '');
|
|
3001
2939
|
}
|
|
3002
|
-
}
|
|
3003
|
-
|
|
3004
|
-
// TODO for documents this will need to switch based on Identifier kind
|
|
2940
|
+
} // TODO for documents this will need to switch based on Identifier kind
|
|
3005
2941
|
if (isCacheOperationValue(value)) {
|
|
3006
2942
|
const callbackMap = cache.get(isRequestKey(cacheKey) ? 'document' : 'resource');
|
|
3007
2943
|
if (callbackMap) {
|
|
@@ -3072,11 +3008,11 @@ function safeForEach$1(instance, arr, store, callback, target) {
|
|
|
3072
3008
|
}
|
|
3073
3009
|
// clone to prevent mutation
|
|
3074
3010
|
arr = arr.slice();
|
|
3075
|
-
|
|
3011
|
+
(test => {
|
|
3076
3012
|
if (!test) {
|
|
3077
3013
|
throw new Error('`forEach` expects a function as first argument.');
|
|
3078
3014
|
}
|
|
3079
|
-
})(typeof callback === 'function')
|
|
3015
|
+
})(typeof callback === 'function');
|
|
3080
3016
|
|
|
3081
3017
|
// because we retrieveLatest above we need not worry if array is mutated during iteration
|
|
3082
3018
|
// by unloadRecord/rollbackAttributes
|
|
@@ -3116,20 +3052,20 @@ function performObjectExtensionGet(receiver, extensions, signals, prop) {
|
|
|
3116
3052
|
}
|
|
3117
3053
|
case 'writeonly-field':
|
|
3118
3054
|
{
|
|
3119
|
-
|
|
3055
|
+
(test => {
|
|
3120
3056
|
{
|
|
3121
3057
|
throw new Error(`Cannot get extended field ${String(prop)} as its definition has only a setter`);
|
|
3122
3058
|
}
|
|
3123
|
-
})()
|
|
3059
|
+
})();
|
|
3124
3060
|
return undefined;
|
|
3125
3061
|
}
|
|
3126
3062
|
default:
|
|
3127
3063
|
{
|
|
3128
|
-
|
|
3064
|
+
(test => {
|
|
3129
3065
|
{
|
|
3130
3066
|
throw new Error(`Unhandled extension kind ${desc.kind}`);
|
|
3131
3067
|
}
|
|
3132
|
-
})()
|
|
3068
|
+
})();
|
|
3133
3069
|
return undefined;
|
|
3134
3070
|
}
|
|
3135
3071
|
}
|
|
@@ -3140,11 +3076,11 @@ function performExtensionSet(receiver, extensions, signals, prop, value) {
|
|
|
3140
3076
|
case 'method':
|
|
3141
3077
|
case 'readonly-value':
|
|
3142
3078
|
case 'readonly-field':
|
|
3143
|
-
|
|
3079
|
+
(test => {
|
|
3144
3080
|
{
|
|
3145
3081
|
throw new Error(`Cannot set extension field ${String(prop)} as it is a ${desc.kind}`);
|
|
3146
3082
|
}
|
|
3147
|
-
})()
|
|
3083
|
+
})();
|
|
3148
3084
|
return false;
|
|
3149
3085
|
case 'mutable-value':
|
|
3150
3086
|
{
|
|
@@ -3163,11 +3099,11 @@ function performExtensionSet(receiver, extensions, signals, prop, value) {
|
|
|
3163
3099
|
}
|
|
3164
3100
|
default:
|
|
3165
3101
|
{
|
|
3166
|
-
|
|
3102
|
+
(test => {
|
|
3167
3103
|
{
|
|
3168
3104
|
throw new Error(`Unhandled extension kind ${desc.kind}`);
|
|
3169
3105
|
}
|
|
3170
|
-
})()
|
|
3106
|
+
})();
|
|
3171
3107
|
return false;
|
|
3172
3108
|
}
|
|
3173
3109
|
}
|
|
@@ -3207,20 +3143,20 @@ function performArrayExtensionGet(receiver, extensions, signals, prop, _SIGNAL,
|
|
|
3207
3143
|
}
|
|
3208
3144
|
case 'writeonly-field':
|
|
3209
3145
|
{
|
|
3210
|
-
|
|
3146
|
+
(test => {
|
|
3211
3147
|
{
|
|
3212
3148
|
throw new Error(`Cannot get extended field ${String(prop)} as its definition has only a setter`);
|
|
3213
3149
|
}
|
|
3214
|
-
})()
|
|
3150
|
+
})();
|
|
3215
3151
|
return undefined;
|
|
3216
3152
|
}
|
|
3217
3153
|
default:
|
|
3218
3154
|
{
|
|
3219
|
-
|
|
3155
|
+
(test => {
|
|
3220
3156
|
{
|
|
3221
3157
|
throw new Error(`Unhandled extension kind ${desc.kind}`);
|
|
3222
3158
|
}
|
|
3223
|
-
})()
|
|
3159
|
+
})();
|
|
3224
3160
|
return undefined;
|
|
3225
3161
|
}
|
|
3226
3162
|
}
|
|
@@ -3255,7 +3191,7 @@ const ARR_BRACKET_DESC = {
|
|
|
3255
3191
|
get: function () {
|
|
3256
3192
|
// here to support computed chains
|
|
3257
3193
|
// and {{#each}}
|
|
3258
|
-
|
|
3194
|
+
{
|
|
3259
3195
|
return this;
|
|
3260
3196
|
}
|
|
3261
3197
|
}
|
|
@@ -3343,19 +3279,19 @@ const ArrayHandler = {
|
|
|
3343
3279
|
// array functions must run through Reflect to work properly
|
|
3344
3280
|
// binding via other means will not work.
|
|
3345
3281
|
if (!CONTEXT.editable) {
|
|
3346
|
-
|
|
3282
|
+
(test => {
|
|
3347
3283
|
if (!test) {
|
|
3348
3284
|
throw new Error(`Mutating this array of records via ${String(prop)} is not allowed.`);
|
|
3349
3285
|
}
|
|
3350
|
-
})(CONTEXT.editable)
|
|
3286
|
+
})(CONTEXT.editable);
|
|
3351
3287
|
return;
|
|
3352
3288
|
}
|
|
3353
3289
|
const args = Array.prototype.slice.call(arguments);
|
|
3354
|
-
|
|
3290
|
+
(test => {
|
|
3355
3291
|
if (!test) {
|
|
3356
3292
|
throw new Error(`Cannot start a new array transaction while a previous transaction is underway`);
|
|
3357
3293
|
}
|
|
3358
|
-
})(!CONTEXT.transaction)
|
|
3294
|
+
})(!CONTEXT.transaction);
|
|
3359
3295
|
CONTEXT.transaction = true;
|
|
3360
3296
|
const result = CONTEXT.mutate(target, receiver, prop, args, CONTEXT.signal);
|
|
3361
3297
|
CONTEXT.transaction = false;
|
|
@@ -3395,11 +3331,11 @@ const ArrayHandler = {
|
|
|
3395
3331
|
return true;
|
|
3396
3332
|
}
|
|
3397
3333
|
if (!CONTEXT.editable && !MUTABLE_PROPS.includes(prop)) {
|
|
3398
|
-
|
|
3334
|
+
(test => {
|
|
3399
3335
|
if (!test) {
|
|
3400
3336
|
throw new Error(`Mutating ${String(prop)} on this Array is not allowed.`);
|
|
3401
3337
|
}
|
|
3402
|
-
})(CONTEXT.editable)
|
|
3338
|
+
})(CONTEXT.editable);
|
|
3403
3339
|
return false;
|
|
3404
3340
|
}
|
|
3405
3341
|
if (prop === 'length') {
|
|
@@ -3411,11 +3347,11 @@ const ArrayHandler = {
|
|
|
3411
3347
|
} else if (CONTEXT.transaction) {
|
|
3412
3348
|
return Reflect.set(target, prop, value);
|
|
3413
3349
|
} else {
|
|
3414
|
-
|
|
3350
|
+
(test => {
|
|
3415
3351
|
{
|
|
3416
3352
|
throw new Error(`unexpected length set`);
|
|
3417
3353
|
}
|
|
3418
|
-
})()
|
|
3354
|
+
})();
|
|
3419
3355
|
}
|
|
3420
3356
|
}
|
|
3421
3357
|
if (isContextProp(prop)) {
|
|
@@ -3448,11 +3384,11 @@ const ArrayHandler = {
|
|
|
3448
3384
|
if (index === null || index > target.length) {
|
|
3449
3385
|
if (index !== null && CONTEXT.transaction) {
|
|
3450
3386
|
const identifier = recordIdentifierFor(value);
|
|
3451
|
-
|
|
3387
|
+
(test => {
|
|
3452
3388
|
if (!test) {
|
|
3453
3389
|
throw new Error(`Cannot set index ${index} past the end of the array.`);
|
|
3454
3390
|
}
|
|
3455
|
-
})(isResourceKey(identifier))
|
|
3391
|
+
})(isResourceKey(identifier));
|
|
3456
3392
|
target[index] = identifier;
|
|
3457
3393
|
return true;
|
|
3458
3394
|
} else if (CONTEXT.features && prop in CONTEXT.features) {
|
|
@@ -3463,11 +3399,11 @@ const ArrayHandler = {
|
|
|
3463
3399
|
}
|
|
3464
3400
|
const original = target[index];
|
|
3465
3401
|
const newIdentifier = extractIdentifierFromRecord$2(value);
|
|
3466
|
-
|
|
3402
|
+
(test => {
|
|
3467
3403
|
if (!test) {
|
|
3468
3404
|
throw new Error(`Expected a record`);
|
|
3469
3405
|
}
|
|
3470
|
-
})(newIdentifier && isResourceKey(newIdentifier))
|
|
3406
|
+
})(newIdentifier && isResourceKey(newIdentifier));
|
|
3471
3407
|
// We generate "transactions" whenever a setter method on the array
|
|
3472
3408
|
// is called and might bulk update multiple array cells. Fundamentally,
|
|
3473
3409
|
// all array operations decompose into individual cell replacements.
|
|
@@ -3493,11 +3429,11 @@ const ArrayHandler = {
|
|
|
3493
3429
|
},
|
|
3494
3430
|
deleteProperty(target, prop) {
|
|
3495
3431
|
const CONTEXT = target[Context];
|
|
3496
|
-
|
|
3432
|
+
(test => {
|
|
3497
3433
|
if (!test) {
|
|
3498
3434
|
throw new Error(`Deleting keys on managed arrays is disallowed`);
|
|
3499
3435
|
}
|
|
3500
|
-
})(CONTEXT.transaction)
|
|
3436
|
+
})(CONTEXT.transaction);
|
|
3501
3437
|
if (!CONTEXT.transaction) {
|
|
3502
3438
|
return false;
|
|
3503
3439
|
}
|
|
@@ -3508,11 +3444,11 @@ const ArrayHandler = {
|
|
|
3508
3444
|
}
|
|
3509
3445
|
};
|
|
3510
3446
|
const ILLEGAL_MUTATION = () => {
|
|
3511
|
-
|
|
3447
|
+
(test => {
|
|
3512
3448
|
{
|
|
3513
3449
|
throw new Error(`ILLEGAL OPERATION: This ReactiveResourceArray is immutable`);
|
|
3514
3450
|
}
|
|
3515
|
-
})()
|
|
3451
|
+
})();
|
|
3516
3452
|
};
|
|
3517
3453
|
function createReactiveResourceArray(options) {
|
|
3518
3454
|
const TARGET = options.source;
|
|
@@ -3536,7 +3472,7 @@ function createReactiveResourceArray(options) {
|
|
|
3536
3472
|
};
|
|
3537
3473
|
TARGET[Context] = context;
|
|
3538
3474
|
const proxy = new NativeProxy(TARGET, ArrayHandler);
|
|
3539
|
-
|
|
3475
|
+
{
|
|
3540
3476
|
Object.defineProperty(TARGET, '__SHOW_ME_THE_DATA_(debug mode only)__', {
|
|
3541
3477
|
enumerable: false,
|
|
3542
3478
|
configurable: true,
|
|
@@ -3563,7 +3499,7 @@ function extractIdentifierFromRecord$2(record) {
|
|
|
3563
3499
|
if (!record) {
|
|
3564
3500
|
return null;
|
|
3565
3501
|
}
|
|
3566
|
-
|
|
3502
|
+
(test => {
|
|
3567
3503
|
if (!test) {
|
|
3568
3504
|
throw new Error(`All elements of a ReactiveResourceArray must be instances of a ReactiveResource, you passed $${typeof record}`);
|
|
3569
3505
|
}
|
|
@@ -3574,7 +3510,7 @@ function extractIdentifierFromRecord$2(record) {
|
|
|
3574
3510
|
} catch {
|
|
3575
3511
|
return false;
|
|
3576
3512
|
}
|
|
3577
|
-
}())
|
|
3513
|
+
}());
|
|
3578
3514
|
return recordIdentifierFor(record);
|
|
3579
3515
|
}
|
|
3580
3516
|
function destroy(clear) {
|
|
@@ -3601,6 +3537,69 @@ function createRequestCollection(config) {
|
|
|
3601
3537
|
});
|
|
3602
3538
|
}
|
|
3603
3539
|
|
|
3540
|
+
/**
|
|
3541
|
+
* LiveArrays contain all the known records for a given `ResourceType`.
|
|
3542
|
+
*
|
|
3543
|
+
* ### Basic Example
|
|
3544
|
+
*
|
|
3545
|
+
* For instance, if an application were to have a `'user'` type:
|
|
3546
|
+
*
|
|
3547
|
+
* ```ts
|
|
3548
|
+
* const usersLiveArray = store.peekAll('user');
|
|
3549
|
+
* ```
|
|
3550
|
+
*
|
|
3551
|
+
* ---
|
|
3552
|
+
*
|
|
3553
|
+
*
|
|
3554
|
+
*
|
|
3555
|
+
* ### LiveArrays are Arrays
|
|
3556
|
+
*
|
|
3557
|
+
* LiveArrays have all array APIs, and will report `true`
|
|
3558
|
+
* for both `liveArray instanceof Array` and `Array.isArray(liveArray)`
|
|
3559
|
+
*
|
|
3560
|
+
* ---
|
|
3561
|
+
*
|
|
3562
|
+
*
|
|
3563
|
+
*
|
|
3564
|
+
* ### Reactive
|
|
3565
|
+
*
|
|
3566
|
+
* The array is "live" as it will reactively update any time new
|
|
3567
|
+
* users are added to the store's cache.
|
|
3568
|
+
*
|
|
3569
|
+
* There is only one LiveArray instance per ResourceType, and it
|
|
3570
|
+
* can be accessed either via {@link Store.peekAll} or {@link Store.findAll}
|
|
3571
|
+
*
|
|
3572
|
+
* ```ts
|
|
3573
|
+
* const users = await store.findAll('user');
|
|
3574
|
+
* const peekedUsers = store.peekAll('user');
|
|
3575
|
+
* peekedUsers === users; // true
|
|
3576
|
+
* ```
|
|
3577
|
+
*
|
|
3578
|
+
* ---
|
|
3579
|
+
*
|
|
3580
|
+
*
|
|
3581
|
+
*
|
|
3582
|
+
* ### New Records
|
|
3583
|
+
*
|
|
3584
|
+
* Records in the `"new"` state (created locally on the client
|
|
3585
|
+
* but not yet saved) appear in LiveArrays if they are in LegacyMode.
|
|
3586
|
+
*
|
|
3587
|
+
* PolarisMode records in the `"new"` state do not appear in LiveArrays.
|
|
3588
|
+
*
|
|
3589
|
+
* ---
|
|
3590
|
+
*
|
|
3591
|
+
*
|
|
3592
|
+
*
|
|
3593
|
+
* ### Polymorphism
|
|
3594
|
+
*
|
|
3595
|
+
* LiveArrays are not polymorphic. If your application has an abstract
|
|
3596
|
+
* type "car" with concrete types "ferrari" and "bmw", then "ferrari"
|
|
3597
|
+
* and "bmw" will have populated LiveArrays, but the LiveArray for "car"
|
|
3598
|
+
* would be empty.
|
|
3599
|
+
*
|
|
3600
|
+
* @legacy we recommend againt using LiveArrays. Use {@link Store.request} instead
|
|
3601
|
+
*/
|
|
3602
|
+
|
|
3604
3603
|
/**
|
|
3605
3604
|
* The options for {@link createLegacyLiveArray}
|
|
3606
3605
|
*
|
|
@@ -3636,11 +3635,11 @@ function createLegacyLiveArray(options) {
|
|
|
3636
3635
|
}
|
|
3637
3636
|
function _updateLiveArray() {
|
|
3638
3637
|
const context = this[Context];
|
|
3639
|
-
|
|
3638
|
+
(test => {
|
|
3640
3639
|
if (!test) {
|
|
3641
3640
|
throw new Error(`_update cannot be used with this array`);
|
|
3642
3641
|
}
|
|
3643
|
-
})(this.modelName)
|
|
3642
|
+
})(this.modelName);
|
|
3644
3643
|
// @ts-expect-error typescript is unable to handle the complexity of
|
|
3645
3644
|
// T = unknown, modelName = string
|
|
3646
3645
|
// T extends TypedRecordInstance, modelName = TypeFromInstance<T>
|
|
@@ -3650,6 +3649,79 @@ function _updateLiveArray() {
|
|
|
3650
3649
|
});
|
|
3651
3650
|
}
|
|
3652
3651
|
|
|
3652
|
+
/**
|
|
3653
|
+
* QueryArrays contain the primary records returned when querying
|
|
3654
|
+
* for records by `ResourceType`.
|
|
3655
|
+
*
|
|
3656
|
+
* ### Basic Example
|
|
3657
|
+
*
|
|
3658
|
+
* For instance, if an application were to have a `'user'` type:
|
|
3659
|
+
*
|
|
3660
|
+
* ```ts
|
|
3661
|
+
* const users = await store.query('user', { name: 'Chris' });
|
|
3662
|
+
* ```
|
|
3663
|
+
*
|
|
3664
|
+
* ---
|
|
3665
|
+
*
|
|
3666
|
+
*
|
|
3667
|
+
*
|
|
3668
|
+
* ### QueryArrays are Arrays
|
|
3669
|
+
*
|
|
3670
|
+
* QueryArrays have all array APIs, and will report `true`
|
|
3671
|
+
* for both `queryArray instanceof Array` and `Array.isArray(queryArray)`
|
|
3672
|
+
*
|
|
3673
|
+
* However, any mutation of the array will throw an error.
|
|
3674
|
+
*
|
|
3675
|
+
* ---
|
|
3676
|
+
*
|
|
3677
|
+
*
|
|
3678
|
+
*
|
|
3679
|
+
* ### Reactive
|
|
3680
|
+
*
|
|
3681
|
+
* If a record in a QueryArray is deleted and unloaded, it will be
|
|
3682
|
+
* automatically removed from the array.
|
|
3683
|
+
*
|
|
3684
|
+
* ---
|
|
3685
|
+
*
|
|
3686
|
+
*
|
|
3687
|
+
*
|
|
3688
|
+
* ### Immutable
|
|
3689
|
+
*
|
|
3690
|
+
* Records cannot be directly added to or removed from a QueryArray.
|
|
3691
|
+
*
|
|
3692
|
+
* ---
|
|
3693
|
+
*
|
|
3694
|
+
*
|
|
3695
|
+
*
|
|
3696
|
+
* ### Polymorphism
|
|
3697
|
+
*
|
|
3698
|
+
* QueryArrays are not intended to be polymorphic. If your application has
|
|
3699
|
+
* an abstract type "car" with concrete types "ferrari" and "bmw", a query
|
|
3700
|
+
* which returns primary data containing both ferraris and bmws will *likely*
|
|
3701
|
+
* work, but it is not guaranteed.
|
|
3702
|
+
*
|
|
3703
|
+
* In contrast, the {@link ReactiveResourceArray} returned when using {@link Store.request}
|
|
3704
|
+
* is guaranteed to work with polymorphic responses.
|
|
3705
|
+
*
|
|
3706
|
+
* ---
|
|
3707
|
+
*
|
|
3708
|
+
*
|
|
3709
|
+
*
|
|
3710
|
+
* ### Memory Leaks
|
|
3711
|
+
*
|
|
3712
|
+
* QueryArrays are meant to be long lived. They can be refreshed using
|
|
3713
|
+
* `array.update()`, and destroyed via `array.destroy()`.
|
|
3714
|
+
*
|
|
3715
|
+
* Unlike most Reactive state in WarpDrive, applications must choose to call
|
|
3716
|
+
* `destroy` when the `QueryArray` is no longer needed, else the array instance
|
|
3717
|
+
* will be retained until either the application or the store which created it
|
|
3718
|
+
* are destroyed. Destroying a QueryArray does not remove its records
|
|
3719
|
+
* from the cache, but it does remove the array as well as the overhead it requires
|
|
3720
|
+
* from the store for book-keeping.
|
|
3721
|
+
*
|
|
3722
|
+
* @legacy we recommend againt using QueryArrays. Use {@link Store.request} instead
|
|
3723
|
+
*/
|
|
3724
|
+
|
|
3653
3725
|
/**
|
|
3654
3726
|
* The options for {@link createLegacyQueryArray}
|
|
3655
3727
|
*
|
|
@@ -3697,16 +3769,16 @@ function _updateCollection() {
|
|
|
3697
3769
|
const {
|
|
3698
3770
|
query
|
|
3699
3771
|
} = this;
|
|
3700
|
-
|
|
3772
|
+
(test => {
|
|
3701
3773
|
if (!test) {
|
|
3702
3774
|
throw new Error(`update cannot be used with this array`);
|
|
3703
3775
|
}
|
|
3704
|
-
})(this.modelName)
|
|
3705
|
-
|
|
3776
|
+
})(this.modelName);
|
|
3777
|
+
(test => {
|
|
3706
3778
|
if (!test) {
|
|
3707
3779
|
throw new Error(`update cannot be used with no query`);
|
|
3708
3780
|
}
|
|
3709
|
-
})(query)
|
|
3781
|
+
})(query);
|
|
3710
3782
|
// @ts-expect-error typescript is unable to handle the complexity of
|
|
3711
3783
|
// T = unknown, modelName = string
|
|
3712
3784
|
// T extends TypedRecordInstance, modelName = TypeFromInstance<T>
|
|
@@ -3909,11 +3981,11 @@ class RecordArrayManager {
|
|
|
3909
3981
|
// due to notification that the cache has changed
|
|
3910
3982
|
if (signal.value === 'cache-sync') {
|
|
3911
3983
|
const doc = this.store.cache.peek(identifier);
|
|
3912
|
-
|
|
3984
|
+
(test => {
|
|
3913
3985
|
if (!test) {
|
|
3914
3986
|
throw new Error(`Expected to find a document for ${identifier.lid} but found none`);
|
|
3915
3987
|
}
|
|
3916
|
-
})(doc)
|
|
3988
|
+
})(doc);
|
|
3917
3989
|
const data = !('data' in doc) || !Array.isArray(doc.data) ? [] : doc.data;
|
|
3918
3990
|
// TODO technically we should destroy here if
|
|
3919
3991
|
// !('data' in doc) || !Array.isArray(doc.data)
|
|
@@ -4072,11 +4144,11 @@ class RecordArrayManager {
|
|
|
4072
4144
|
populateManagedArray(array, identifiers, payload) {
|
|
4073
4145
|
this._pending.delete(array);
|
|
4074
4146
|
const source = array[Context].source;
|
|
4075
|
-
|
|
4147
|
+
(test => {
|
|
4076
4148
|
if (!test) {
|
|
4077
4149
|
throw new Error(`The new state of the collection should not be using the same array reference as the original state.`);
|
|
4078
4150
|
}
|
|
4079
|
-
})(source !== identifiers)
|
|
4151
|
+
})(source !== identifiers);
|
|
4080
4152
|
const old = source.slice();
|
|
4081
4153
|
source.length = 0;
|
|
4082
4154
|
fastPush(source, identifiers);
|
|
@@ -4260,7 +4332,7 @@ function isLegacyLiveArray(array) {
|
|
|
4260
4332
|
}
|
|
4261
4333
|
const Touching = getOrSetGlobal('Touching', Symbol('touching'));
|
|
4262
4334
|
const RequestPromise = getOrSetGlobal('RequestPromise', Symbol('promise'));
|
|
4263
|
-
const EMPTY_ARR =
|
|
4335
|
+
const EMPTY_ARR = Object.freeze([]);
|
|
4264
4336
|
function hasRecordIdentifier(op) {
|
|
4265
4337
|
return 'recordIdentifier' in op;
|
|
4266
4338
|
}
|
|
@@ -4338,11 +4410,11 @@ class RequestStateService {
|
|
|
4338
4410
|
throw error;
|
|
4339
4411
|
});
|
|
4340
4412
|
}
|
|
4341
|
-
|
|
4413
|
+
(test => {
|
|
4342
4414
|
{
|
|
4343
4415
|
throw new Error(`Expected a well formed query`);
|
|
4344
4416
|
}
|
|
4345
|
-
})()
|
|
4417
|
+
})();
|
|
4346
4418
|
}
|
|
4347
4419
|
|
|
4348
4420
|
/** @internal */
|
|
@@ -4479,13 +4551,23 @@ class RequestStateService {
|
|
|
4479
4551
|
* @private
|
|
4480
4552
|
*/
|
|
4481
4553
|
|
|
4554
|
+
function esCompat(m) {
|
|
4555
|
+
return m?.__esModule ? m : {
|
|
4556
|
+
default: m,
|
|
4557
|
+
...m
|
|
4558
|
+
};
|
|
4559
|
+
}
|
|
4560
|
+
|
|
4482
4561
|
// this import location is deprecated but breaks in 4.8 and older
|
|
4483
|
-
// @ts-expect-error adding to globalThis
|
|
4484
|
-
globalThis.setWarpDriveLogging = setLogging;
|
|
4485
4562
|
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4563
|
+
{
|
|
4564
|
+
// @ts-expect-error adding to globalThis
|
|
4565
|
+
globalThis.setWarpDriveLogging = setLogging;
|
|
4566
|
+
|
|
4567
|
+
// @ts-expect-error adding to globalThis
|
|
4568
|
+
globalThis.getWarpDriveRuntimeConfig = getRuntimeConfig;
|
|
4569
|
+
}
|
|
4570
|
+
{
|
|
4489
4571
|
if (getGlobalConfig().WarpDrive.debug.LOG_METRIC_COUNTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_METRIC_COUNTS) {
|
|
4490
4572
|
// @ts-expect-error adding to globalThis
|
|
4491
4573
|
// eslint-disable-next-line
|
|
@@ -4503,7 +4585,7 @@ if (macroCondition(getGlobalConfig().WarpDrive.activeLogging.LOG_METRIC_COUNTS))
|
|
|
4503
4585
|
// @ts-expect-error
|
|
4504
4586
|
globalThis.__WarpDriveMetricCountData = {};
|
|
4505
4587
|
};
|
|
4506
|
-
|
|
4588
|
+
{
|
|
4507
4589
|
if (getGlobalConfig().WarpDrive.debug.__INTERNAL_LOG_NATIVE_MAP_SET_COUNTS || globalThis.getWarpDriveRuntimeConfig().debug.__INTERNAL_LOG_NATIVE_MAP_SET_COUNTS) {
|
|
4508
4590
|
// @ts-expect-error adding to globalThis
|
|
4509
4591
|
globalThis.__primitiveInstanceId = 0;
|
|
@@ -4618,10 +4700,10 @@ const EmptyClass = class {
|
|
|
4618
4700
|
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
4619
4701
|
constructor(args) {}
|
|
4620
4702
|
};
|
|
4621
|
-
const _BaseClass =
|
|
4703
|
+
const _BaseClass = esCompat(_importSync20);
|
|
4622
4704
|
const BaseClass = _BaseClass.default ? _BaseClass.default : _BaseClass;
|
|
4623
4705
|
if (BaseClass !== EmptyClass) {
|
|
4624
|
-
|
|
4706
|
+
console.warn(`The Store class extending from EmberObject is deprecated.
|
|
4625
4707
|
Please remove usage of EmberObject APIs and mark your class as not requiring it.
|
|
4626
4708
|
|
|
4627
4709
|
To mark the class as no longer extending from EmberObject, in ember-cli-build.js
|
|
@@ -4636,16 +4718,7 @@ const app = new EmberApp(defaults, {
|
|
|
4636
4718
|
}
|
|
4637
4719
|
});
|
|
4638
4720
|
\`\`\`
|
|
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
|
-
});
|
|
4721
|
+
`);
|
|
4649
4722
|
}
|
|
4650
4723
|
/**
|
|
4651
4724
|
* ```ts
|
|
@@ -4833,13 +4906,13 @@ class Store extends BaseClass {
|
|
|
4833
4906
|
|
|
4834
4907
|
/** @internal */
|
|
4835
4908
|
_run(cb) {
|
|
4836
|
-
|
|
4909
|
+
(test => {
|
|
4837
4910
|
if (!test) {
|
|
4838
4911
|
throw new Error(`WarpDrive should never encounter a nested run`);
|
|
4839
4912
|
}
|
|
4840
|
-
})(!this._cbs)
|
|
4913
|
+
})(!this._cbs);
|
|
4841
4914
|
const _cbs = this._cbs = {};
|
|
4842
|
-
|
|
4915
|
+
{
|
|
4843
4916
|
try {
|
|
4844
4917
|
cb();
|
|
4845
4918
|
if (_cbs.coalesce) {
|
|
@@ -4854,18 +4927,6 @@ class Store extends BaseClass {
|
|
|
4854
4927
|
} finally {
|
|
4855
4928
|
this._cbs = null;
|
|
4856
4929
|
}
|
|
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
4930
|
}
|
|
4870
4931
|
}
|
|
4871
4932
|
|
|
@@ -4888,16 +4949,16 @@ class Store extends BaseClass {
|
|
|
4888
4949
|
|
|
4889
4950
|
/** @internal */
|
|
4890
4951
|
_schedule(name, cb) {
|
|
4891
|
-
|
|
4952
|
+
(test => {
|
|
4892
4953
|
if (!test) {
|
|
4893
4954
|
throw new Error(`WarpDrive expects to schedule only when there is an active run`);
|
|
4894
4955
|
}
|
|
4895
|
-
})(!!this._cbs)
|
|
4896
|
-
|
|
4956
|
+
})(!!this._cbs);
|
|
4957
|
+
(test => {
|
|
4897
4958
|
if (!test) {
|
|
4898
4959
|
throw new Error(`WarpDrive expects only one flush per queue name, cannot schedule ${name}`);
|
|
4899
4960
|
}
|
|
4900
|
-
})(!this._cbs[name])
|
|
4961
|
+
})(!this._cbs[name]);
|
|
4901
4962
|
this._cbs[name] = cb;
|
|
4902
4963
|
}
|
|
4903
4964
|
|
|
@@ -4917,7 +4978,7 @@ class Store extends BaseClass {
|
|
|
4917
4978
|
|
|
4918
4979
|
/** @internal */
|
|
4919
4980
|
_getAllPending() {
|
|
4920
|
-
|
|
4981
|
+
{
|
|
4921
4982
|
const all = [];
|
|
4922
4983
|
const pending = this._requestCache._pending;
|
|
4923
4984
|
pending.forEach(requests => {
|
|
@@ -4995,12 +5056,12 @@ class Store extends BaseClass {
|
|
|
4995
5056
|
const cacheKeyManager = this.cacheKeyManager;
|
|
4996
5057
|
opts.records = requestConfig.records.map(r => cacheKeyManager.getOrCreateRecordIdentifier(r));
|
|
4997
5058
|
}
|
|
4998
|
-
|
|
5059
|
+
{
|
|
4999
5060
|
if (this.DISABLE_WAITER) {
|
|
5000
5061
|
opts.disableTestWaiter = typeof requestConfig.disableTestWaiter === 'boolean' ? requestConfig.disableTestWaiter : true;
|
|
5001
5062
|
}
|
|
5002
5063
|
}
|
|
5003
|
-
|
|
5064
|
+
{
|
|
5004
5065
|
if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
|
|
5005
5066
|
let options;
|
|
5006
5067
|
try {
|
|
@@ -5015,13 +5076,12 @@ class Store extends BaseClass {
|
|
|
5015
5076
|
const request = Object.assign({}, requestConfig, opts);
|
|
5016
5077
|
const future = this.requestManager.request(request);
|
|
5017
5078
|
future.onFinalize(() => {
|
|
5018
|
-
|
|
5079
|
+
{
|
|
5019
5080
|
if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
|
|
5020
5081
|
// eslint-disable-next-line no-console
|
|
5021
5082
|
console.log(`request: [[FINALIZE]] ${requestConfig.op && !requestConfig.url ? '(LEGACY) ' : ''}${requestConfig.op || '<unknown operation>'} ${requestConfig.url || '<empty url>'} ${requestConfig.method || '<empty method>'}`);
|
|
5022
5083
|
}
|
|
5023
|
-
}
|
|
5024
|
-
// skip flush for legacy belongsTo
|
|
5084
|
+
} // skip flush for legacy belongsTo
|
|
5025
5085
|
if (requestConfig.op === 'findBelongsTo' && !requestConfig.url) {
|
|
5026
5086
|
return;
|
|
5027
5087
|
}
|
|
@@ -5086,19 +5146,19 @@ class Store extends BaseClass {
|
|
|
5086
5146
|
*/
|
|
5087
5147
|
|
|
5088
5148
|
createRecord(type, inputProperties, context) {
|
|
5089
|
-
|
|
5149
|
+
{
|
|
5090
5150
|
assertDestroyingStore(this, 'createRecord');
|
|
5091
5151
|
}
|
|
5092
|
-
|
|
5152
|
+
(test => {
|
|
5093
5153
|
if (!test) {
|
|
5094
5154
|
throw new Error(`You need to pass a model name to the store's createRecord method`);
|
|
5095
5155
|
}
|
|
5096
|
-
})(type)
|
|
5097
|
-
|
|
5156
|
+
})(type);
|
|
5157
|
+
(test => {
|
|
5098
5158
|
if (!test) {
|
|
5099
5159
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
5100
5160
|
}
|
|
5101
|
-
})(typeof type === 'string')
|
|
5161
|
+
})(typeof type === 'string');
|
|
5102
5162
|
|
|
5103
5163
|
// This is wrapped in a `run.join` so that in test environments users do not need to manually wrap
|
|
5104
5164
|
// calls to `createRecord`. The run loop usage here is because we batch the joining and updating
|
|
@@ -5133,22 +5193,22 @@ class Store extends BaseClass {
|
|
|
5133
5193
|
};
|
|
5134
5194
|
if (resource.id) {
|
|
5135
5195
|
const identifier = this.cacheKeyManager.peekResourceKey(resource);
|
|
5136
|
-
|
|
5196
|
+
(test => {
|
|
5137
5197
|
if (!test) {
|
|
5138
5198
|
throw new Error(`The id ${String(properties.id)} has already been used with another '${normalizedModelName}' record.`);
|
|
5139
5199
|
}
|
|
5140
|
-
})(!identifier)
|
|
5200
|
+
})(!identifier);
|
|
5141
5201
|
}
|
|
5142
5202
|
if (context?.lid) {
|
|
5143
5203
|
const identifier = this.cacheKeyManager.peekResourceKey({
|
|
5144
5204
|
lid: context?.lid
|
|
5145
5205
|
});
|
|
5146
5206
|
resource.lid = context.lid;
|
|
5147
|
-
|
|
5207
|
+
(test => {
|
|
5148
5208
|
if (!test) {
|
|
5149
5209
|
throw new Error(`The lid ${context.lid} has already been used with another '${identifier?.type}' record.`);
|
|
5150
5210
|
}
|
|
5151
|
-
})(!identifier)
|
|
5211
|
+
})(!identifier);
|
|
5152
5212
|
}
|
|
5153
5213
|
const identifier = this.cacheKeyManager.createIdentifierForNewRecord(resource);
|
|
5154
5214
|
const cache = this.cache;
|
|
@@ -5172,16 +5232,16 @@ class Store extends BaseClass {
|
|
|
5172
5232
|
@param {unknown} record
|
|
5173
5233
|
*/
|
|
5174
5234
|
deleteRecord(record) {
|
|
5175
|
-
|
|
5235
|
+
{
|
|
5176
5236
|
assertDestroyingStore(this, 'deleteRecord');
|
|
5177
5237
|
}
|
|
5178
5238
|
const identifier = peekResourceKey(record);
|
|
5179
5239
|
const cache = this.cache;
|
|
5180
|
-
|
|
5240
|
+
(test => {
|
|
5181
5241
|
if (!test) {
|
|
5182
5242
|
throw new Error(`expected the record to be connected to a cache`);
|
|
5183
5243
|
}
|
|
5184
|
-
})(identifier)
|
|
5244
|
+
})(identifier);
|
|
5185
5245
|
this._join(() => {
|
|
5186
5246
|
cache.setIsDeleted(identifier, true);
|
|
5187
5247
|
if (cache.isNew(identifier)) {
|
|
@@ -5202,7 +5262,7 @@ class Store extends BaseClass {
|
|
|
5202
5262
|
@param {Model} record
|
|
5203
5263
|
*/
|
|
5204
5264
|
unloadRecord(record) {
|
|
5205
|
-
|
|
5265
|
+
{
|
|
5206
5266
|
assertDestroyingStore(this, 'unloadRecord');
|
|
5207
5267
|
}
|
|
5208
5268
|
const identifier = peekResourceKey(record);
|
|
@@ -5250,19 +5310,19 @@ class Store extends BaseClass {
|
|
|
5250
5310
|
// this is basically an "are we not empty" query.
|
|
5251
5311
|
return isLoaded ? this._instanceCache.getRecord(stableIdentifier) : null;
|
|
5252
5312
|
}
|
|
5253
|
-
|
|
5313
|
+
{
|
|
5254
5314
|
assertDestroyingStore(this, 'peekRecord');
|
|
5255
5315
|
}
|
|
5256
|
-
|
|
5316
|
+
(test => {
|
|
5257
5317
|
if (!test) {
|
|
5258
5318
|
throw new Error(`You need to pass a model name to the store's peekRecord method`);
|
|
5259
5319
|
}
|
|
5260
|
-
})(identifier)
|
|
5261
|
-
|
|
5320
|
+
})(identifier);
|
|
5321
|
+
(test => {
|
|
5262
5322
|
if (!test) {
|
|
5263
5323
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${String(identifier)}`);
|
|
5264
5324
|
}
|
|
5265
|
-
})(typeof identifier === 'string')
|
|
5325
|
+
})(typeof identifier === 'string');
|
|
5266
5326
|
const type = normalizeModelName(identifier);
|
|
5267
5327
|
const normalizedId = ensureStringId(id);
|
|
5268
5328
|
const resource = {
|
|
@@ -5292,19 +5352,19 @@ class Store extends BaseClass {
|
|
|
5292
5352
|
*/
|
|
5293
5353
|
|
|
5294
5354
|
peekAll(type) {
|
|
5295
|
-
|
|
5355
|
+
{
|
|
5296
5356
|
assertDestroyingStore(this, 'peekAll');
|
|
5297
5357
|
}
|
|
5298
|
-
|
|
5358
|
+
(test => {
|
|
5299
5359
|
if (!test) {
|
|
5300
5360
|
throw new Error(`You need to pass a model name to the store's peekAll method`);
|
|
5301
5361
|
}
|
|
5302
|
-
})(type)
|
|
5303
|
-
|
|
5362
|
+
})(type);
|
|
5363
|
+
(test => {
|
|
5304
5364
|
if (!test) {
|
|
5305
5365
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
5306
5366
|
}
|
|
5307
|
-
})(typeof type === 'string')
|
|
5367
|
+
})(typeof type === 'string');
|
|
5308
5368
|
return this.recordArrayManager.liveArrayFor(normalizeModelName(type));
|
|
5309
5369
|
}
|
|
5310
5370
|
|
|
@@ -5321,14 +5381,14 @@ class Store extends BaseClass {
|
|
|
5321
5381
|
*/
|
|
5322
5382
|
|
|
5323
5383
|
unloadAll(type) {
|
|
5324
|
-
|
|
5384
|
+
{
|
|
5325
5385
|
assertDestroyedStoreOnly(this, 'unloadAll');
|
|
5326
5386
|
}
|
|
5327
|
-
|
|
5387
|
+
(test => {
|
|
5328
5388
|
if (!test) {
|
|
5329
5389
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${String(type)}`);
|
|
5330
5390
|
}
|
|
5331
|
-
})(!type || typeof type === 'string')
|
|
5391
|
+
})(!type || typeof type === 'string');
|
|
5332
5392
|
this._join(() => {
|
|
5333
5393
|
this._enableAsyncFlush = true;
|
|
5334
5394
|
if (type === undefined) {
|
|
@@ -5475,7 +5535,7 @@ class Store extends BaseClass {
|
|
|
5475
5535
|
*/
|
|
5476
5536
|
|
|
5477
5537
|
push(data) {
|
|
5478
|
-
|
|
5538
|
+
{
|
|
5479
5539
|
assertDestroyingStore(this, 'push');
|
|
5480
5540
|
}
|
|
5481
5541
|
const pushed = this._push(data, false);
|
|
@@ -5495,7 +5555,7 @@ class Store extends BaseClass {
|
|
|
5495
5555
|
@return identifiers for the primary records that had data loaded
|
|
5496
5556
|
*/
|
|
5497
5557
|
_push(jsonApiDoc, asyncFlush) {
|
|
5498
|
-
|
|
5558
|
+
{
|
|
5499
5559
|
assertDestroyingStore(this, '_push');
|
|
5500
5560
|
}
|
|
5501
5561
|
if (asyncFlush) {
|
|
@@ -5523,7 +5583,7 @@ class Store extends BaseClass {
|
|
|
5523
5583
|
} = this._instanceCache;
|
|
5524
5584
|
if (!cache) {
|
|
5525
5585
|
cache = this._instanceCache.cache = this.createCache(this._instanceCache._storeWrapper);
|
|
5526
|
-
|
|
5586
|
+
{
|
|
5527
5587
|
cache = this._instanceCache.cache = new CacheManager(cache);
|
|
5528
5588
|
}
|
|
5529
5589
|
}
|
|
@@ -5580,67 +5640,43 @@ function assertPrivateStore(store) {}
|
|
|
5580
5640
|
function isPrivateStore(store) {
|
|
5581
5641
|
return store;
|
|
5582
5642
|
}
|
|
5583
|
-
|
|
5643
|
+
{
|
|
5584
5644
|
Store.prototype.getSchemaDefinitionService = function () {
|
|
5585
|
-
|
|
5645
|
+
(test => {
|
|
5586
5646
|
if (!test) {
|
|
5587
5647
|
throw new Error(`You must registerSchemaDefinitionService with the store to use custom model classes`);
|
|
5588
5648
|
}
|
|
5589
|
-
})(this._schema)
|
|
5590
|
-
|
|
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
|
-
});
|
|
5649
|
+
})(this._schema);
|
|
5650
|
+
console.warn(`Use \`store.schema\` instead of \`store.getSchemaDefinitionService()\``);
|
|
5599
5651
|
return this._schema;
|
|
5600
5652
|
};
|
|
5601
5653
|
Store.prototype.registerSchemaDefinitionService = function (schema) {
|
|
5602
|
-
|
|
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
|
-
});
|
|
5654
|
+
console.warn(`Use \`store.createSchemaService\` instead of \`store.registerSchemaDefinitionService()\``);
|
|
5611
5655
|
this._schema = schema;
|
|
5612
5656
|
};
|
|
5613
5657
|
Store.prototype.registerSchema = function (schema) {
|
|
5614
|
-
|
|
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
|
-
});
|
|
5658
|
+
console.warn(`Use \`store.createSchemaService\` instead of \`store.registerSchema()\``);
|
|
5623
5659
|
this._schema = schema;
|
|
5624
5660
|
};
|
|
5625
5661
|
}
|
|
5626
5662
|
let assertDestroyingStore;
|
|
5627
5663
|
let assertDestroyedStoreOnly;
|
|
5628
|
-
|
|
5664
|
+
{
|
|
5629
5665
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
5630
5666
|
assertDestroyingStore = function assertDestroyingStore(store, method) {
|
|
5631
|
-
|
|
5667
|
+
(test => {
|
|
5632
5668
|
if (!test) {
|
|
5633
5669
|
throw new Error(`Attempted to call store.${method}(), but the store instance has already been destroyed.`);
|
|
5634
5670
|
}
|
|
5635
|
-
})(!(store.isDestroying || store.isDestroyed))
|
|
5671
|
+
})(!(store.isDestroying || store.isDestroyed));
|
|
5636
5672
|
};
|
|
5637
5673
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
5638
5674
|
assertDestroyedStoreOnly = function assertDestroyedStoreOnly(store, method) {
|
|
5639
|
-
|
|
5675
|
+
(test => {
|
|
5640
5676
|
if (!test) {
|
|
5641
5677
|
throw new Error(`Attempted to call store.${method}(), but the store instance has already been destroyed.`);
|
|
5642
5678
|
}
|
|
5643
|
-
})(!store.isDestroyed)
|
|
5679
|
+
})(!store.isDestroyed);
|
|
5644
5680
|
};
|
|
5645
5681
|
}
|
|
5646
5682
|
function isMaybeIdentifier(maybeIdentifier) {
|
|
@@ -5650,17 +5686,17 @@ function normalizeProperties(store, identifier, properties) {
|
|
|
5650
5686
|
// assert here
|
|
5651
5687
|
if (properties !== undefined) {
|
|
5652
5688
|
if ('id' in properties) {
|
|
5653
|
-
|
|
5689
|
+
(test => {
|
|
5654
5690
|
if (!test) {
|
|
5655
5691
|
throw new Error(`expected id to be a string or null`);
|
|
5656
5692
|
}
|
|
5657
|
-
})(properties.id !== undefined)
|
|
5693
|
+
})(properties.id !== undefined);
|
|
5658
5694
|
}
|
|
5659
|
-
|
|
5695
|
+
(test => {
|
|
5660
5696
|
if (!test) {
|
|
5661
5697
|
throw new Error(`You passed '${typeof properties}' as properties for record creation instead of an object.`);
|
|
5662
5698
|
}
|
|
5663
|
-
})(typeof properties === 'object' && properties !== null)
|
|
5699
|
+
})(typeof properties === 'object' && properties !== null);
|
|
5664
5700
|
const {
|
|
5665
5701
|
type
|
|
5666
5702
|
} = identifier;
|
|
@@ -5676,7 +5712,7 @@ function normalizeProperties(store, identifier, properties) {
|
|
|
5676
5712
|
const field = defs.get(prop);
|
|
5677
5713
|
if (!field) continue;
|
|
5678
5714
|
if (field.kind === 'hasMany') {
|
|
5679
|
-
|
|
5715
|
+
{
|
|
5680
5716
|
assertRecordsPassedToHasMany(properties[prop]);
|
|
5681
5717
|
}
|
|
5682
5718
|
properties[prop] = extractIdentifiersFromRecords$1(properties[prop]);
|
|
@@ -5689,12 +5725,12 @@ function normalizeProperties(store, identifier, properties) {
|
|
|
5689
5725
|
return properties;
|
|
5690
5726
|
}
|
|
5691
5727
|
function assertRecordsPassedToHasMany(records) {
|
|
5692
|
-
|
|
5728
|
+
(test => {
|
|
5693
5729
|
if (!test) {
|
|
5694
5730
|
throw new Error(`You must pass an array of records to set a hasMany relationship`);
|
|
5695
5731
|
}
|
|
5696
|
-
})(Array.isArray(records))
|
|
5697
|
-
|
|
5732
|
+
})(Array.isArray(records));
|
|
5733
|
+
(test => {
|
|
5698
5734
|
if (!test) {
|
|
5699
5735
|
throw new Error(`All elements of a hasMany relationship must be instances of Model, you passed ${records.map(r => `${typeof r}`).join(', ')}`);
|
|
5700
5736
|
}
|
|
@@ -5707,7 +5743,7 @@ function assertRecordsPassedToHasMany(records) {
|
|
|
5707
5743
|
return false;
|
|
5708
5744
|
}
|
|
5709
5745
|
});
|
|
5710
|
-
}())
|
|
5746
|
+
}());
|
|
5711
5747
|
}
|
|
5712
5748
|
function extractIdentifiersFromRecords$1(records) {
|
|
5713
5749
|
return records.map(record => extractIdentifierFromRecord$1(record));
|
|
@@ -5731,6 +5767,7 @@ function extractIdentifierFromRecord$1(recordOrPromiseRecord) {
|
|
|
5731
5767
|
Preloaded data can be attributes and relationships passed in either as IDs or as actual
|
|
5732
5768
|
models.
|
|
5733
5769
|
*/
|
|
5770
|
+
|
|
5734
5771
|
function preloadData(store, identifier, preload) {
|
|
5735
5772
|
const jsonPayload = {};
|
|
5736
5773
|
//TODO(Igor) consider the polymorphic case
|
|
@@ -5758,20 +5795,20 @@ function preloadData(store, identifier, preload) {
|
|
|
5758
5795
|
function preloadRelationship(schema, preloadValue) {
|
|
5759
5796
|
const relatedType = schema.type;
|
|
5760
5797
|
if (schema.kind === 'hasMany') {
|
|
5761
|
-
|
|
5798
|
+
(test => {
|
|
5762
5799
|
if (!test) {
|
|
5763
5800
|
throw new Error('You need to pass in an array to set a hasMany property on a record');
|
|
5764
5801
|
}
|
|
5765
|
-
})(Array.isArray(preloadValue))
|
|
5802
|
+
})(Array.isArray(preloadValue));
|
|
5766
5803
|
return {
|
|
5767
5804
|
data: preloadValue.map(value => _convertPreloadRelationshipToJSON(value, relatedType))
|
|
5768
5805
|
};
|
|
5769
5806
|
}
|
|
5770
|
-
|
|
5807
|
+
(test => {
|
|
5771
5808
|
if (!test) {
|
|
5772
5809
|
throw new Error('You should not pass in an array to set a belongsTo property on a record');
|
|
5773
5810
|
}
|
|
5774
|
-
})(!Array.isArray(preloadValue))
|
|
5811
|
+
})(!Array.isArray(preloadValue));
|
|
5775
5812
|
return {
|
|
5776
5813
|
data: preloadValue ? _convertPreloadRelationshipToJSON(preloadValue, relatedType) : null
|
|
5777
5814
|
};
|
|
@@ -5967,11 +6004,11 @@ class RecordReference {
|
|
|
5967
6004
|
if (id !== null) {
|
|
5968
6005
|
return this.store.findRecord(this.type, id);
|
|
5969
6006
|
}
|
|
5970
|
-
|
|
6007
|
+
(test => {
|
|
5971
6008
|
{
|
|
5972
6009
|
throw new Error(`Unable to fetch record of type ${this.type} without an id`);
|
|
5973
6010
|
}
|
|
5974
|
-
})()
|
|
6011
|
+
})();
|
|
5975
6012
|
}
|
|
5976
6013
|
|
|
5977
6014
|
/**
|
|
@@ -5993,11 +6030,11 @@ class RecordReference {
|
|
|
5993
6030
|
reload: true
|
|
5994
6031
|
});
|
|
5995
6032
|
}
|
|
5996
|
-
|
|
6033
|
+
(test => {
|
|
5997
6034
|
{
|
|
5998
6035
|
throw new Error(`Unable to fetch record of type ${this.type} without an id`);
|
|
5999
6036
|
}
|
|
6000
|
-
})()
|
|
6037
|
+
})();
|
|
6001
6038
|
}
|
|
6002
6039
|
}
|
|
6003
6040
|
defineSignal(RecordReference.prototype, '_ref');
|
|
@@ -6089,36 +6126,33 @@ class ShimModelClass {
|
|
|
6089
6126
|
});
|
|
6090
6127
|
}
|
|
6091
6128
|
}
|
|
6092
|
-
|
|
6129
|
+
|
|
6130
|
+
/////////////// IMPORTANT ///////////////////
|
|
6131
|
+
///// Move Module Augmentation Into The /////
|
|
6132
|
+
///// Legacy Package Once Removed Here /////
|
|
6133
|
+
/////////////////////////////////////////////
|
|
6134
|
+
|
|
6135
|
+
{
|
|
6093
6136
|
Store.prototype.findRecord = function (resource, id, options) {
|
|
6094
|
-
|
|
6095
|
-
|
|
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 => {
|
|
6137
|
+
console.warn(`store.findRecord is deprecated. Use store.request instead.`);
|
|
6138
|
+
(test => {
|
|
6105
6139
|
if (!test) {
|
|
6106
6140
|
throw new Error(`Attempted to call store.findRecord(), but the store instance has already been destroyed.`);
|
|
6107
6141
|
}
|
|
6108
|
-
})(!(this.isDestroying || this.isDestroyed))
|
|
6109
|
-
|
|
6142
|
+
})(!(this.isDestroying || this.isDestroyed));
|
|
6143
|
+
(test => {
|
|
6110
6144
|
if (!test) {
|
|
6111
6145
|
throw new Error(`You need to pass a modelName or resource identifier as the first argument to the store's findRecord method`);
|
|
6112
6146
|
}
|
|
6113
|
-
})(resource)
|
|
6147
|
+
})(resource);
|
|
6114
6148
|
if (isMaybeIdentifier(resource)) {
|
|
6115
6149
|
options = id;
|
|
6116
6150
|
} else {
|
|
6117
|
-
|
|
6151
|
+
(test => {
|
|
6118
6152
|
if (!test) {
|
|
6119
6153
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${resource}`);
|
|
6120
6154
|
}
|
|
6121
|
-
})(typeof resource === 'string')
|
|
6155
|
+
})(typeof resource === 'string');
|
|
6122
6156
|
const type = normalizeModelName(resource);
|
|
6123
6157
|
const normalizedId = ensureStringId(id);
|
|
6124
6158
|
resource = constructResource(type, normalizedId);
|
|
@@ -6151,31 +6185,22 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUES
|
|
|
6151
6185
|
});
|
|
6152
6186
|
};
|
|
6153
6187
|
Store.prototype.findAll = function (type, options = {}) {
|
|
6154
|
-
|
|
6155
|
-
|
|
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 => {
|
|
6188
|
+
console.warn(`store.findAll is deprecated. Use store.request instead.`);
|
|
6189
|
+
(test => {
|
|
6165
6190
|
if (!test) {
|
|
6166
6191
|
throw new Error(`Attempted to call store.findAll(), but the store instance has already been destroyed.`);
|
|
6167
6192
|
}
|
|
6168
|
-
})(!(this.isDestroying || this.isDestroyed))
|
|
6169
|
-
|
|
6193
|
+
})(!(this.isDestroying || this.isDestroyed));
|
|
6194
|
+
(test => {
|
|
6170
6195
|
if (!test) {
|
|
6171
6196
|
throw new Error(`You need to pass a model name to the store's findAll method`);
|
|
6172
6197
|
}
|
|
6173
|
-
})(type)
|
|
6174
|
-
|
|
6198
|
+
})(type);
|
|
6199
|
+
(test => {
|
|
6175
6200
|
if (!test) {
|
|
6176
6201
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
6177
6202
|
}
|
|
6178
|
-
})(typeof type === 'string')
|
|
6203
|
+
})(typeof type === 'string');
|
|
6179
6204
|
const promise = this.request({
|
|
6180
6205
|
op: 'findAll',
|
|
6181
6206
|
data: {
|
|
@@ -6189,36 +6214,27 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUES
|
|
|
6189
6214
|
return promise.then(document => document.content);
|
|
6190
6215
|
};
|
|
6191
6216
|
Store.prototype.query = function (type, query, options = {}) {
|
|
6192
|
-
|
|
6193
|
-
|
|
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 => {
|
|
6217
|
+
console.warn(`store.query is deprecated. Use store.request instead.`);
|
|
6218
|
+
(test => {
|
|
6203
6219
|
if (!test) {
|
|
6204
6220
|
throw new Error(`Attempted to call store.query(), but the store instance has already been destroyed.`);
|
|
6205
6221
|
}
|
|
6206
|
-
})(!(this.isDestroying || this.isDestroyed))
|
|
6207
|
-
|
|
6222
|
+
})(!(this.isDestroying || this.isDestroyed));
|
|
6223
|
+
(test => {
|
|
6208
6224
|
if (!test) {
|
|
6209
6225
|
throw new Error(`You need to pass a model name to the store's query method`);
|
|
6210
6226
|
}
|
|
6211
|
-
})(type)
|
|
6212
|
-
|
|
6227
|
+
})(type);
|
|
6228
|
+
(test => {
|
|
6213
6229
|
if (!test) {
|
|
6214
6230
|
throw new Error(`You need to pass a query hash to the store's query method`);
|
|
6215
6231
|
}
|
|
6216
|
-
})(query)
|
|
6217
|
-
|
|
6232
|
+
})(query);
|
|
6233
|
+
(test => {
|
|
6218
6234
|
if (!test) {
|
|
6219
6235
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
6220
6236
|
}
|
|
6221
|
-
})(typeof type === 'string')
|
|
6237
|
+
})(typeof type === 'string');
|
|
6222
6238
|
const promise = this.request({
|
|
6223
6239
|
op: 'query',
|
|
6224
6240
|
data: {
|
|
@@ -6233,36 +6249,27 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUES
|
|
|
6233
6249
|
return promise.then(document => document.content);
|
|
6234
6250
|
};
|
|
6235
6251
|
Store.prototype.queryRecord = function (type, query, options) {
|
|
6236
|
-
|
|
6237
|
-
|
|
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 => {
|
|
6252
|
+
console.warn(`store.queryRecord is deprecated. Use store.request instead.`);
|
|
6253
|
+
(test => {
|
|
6247
6254
|
if (!test) {
|
|
6248
6255
|
throw new Error(`Attempted to call store.queryRecord(), but the store instance has already been destroyed.`);
|
|
6249
6256
|
}
|
|
6250
|
-
})(!(this.isDestroying || this.isDestroyed))
|
|
6251
|
-
|
|
6257
|
+
})(!(this.isDestroying || this.isDestroyed));
|
|
6258
|
+
(test => {
|
|
6252
6259
|
if (!test) {
|
|
6253
6260
|
throw new Error(`You need to pass a model name to the store's queryRecord method`);
|
|
6254
6261
|
}
|
|
6255
|
-
})(type)
|
|
6256
|
-
|
|
6262
|
+
})(type);
|
|
6263
|
+
(test => {
|
|
6257
6264
|
if (!test) {
|
|
6258
6265
|
throw new Error(`You need to pass a query hash to the store's queryRecord method`);
|
|
6259
6266
|
}
|
|
6260
|
-
})(query)
|
|
6261
|
-
|
|
6267
|
+
})(query);
|
|
6268
|
+
(test => {
|
|
6262
6269
|
if (!test) {
|
|
6263
6270
|
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
6264
6271
|
}
|
|
6265
|
-
})(typeof type === 'string')
|
|
6272
|
+
})(typeof type === 'string');
|
|
6266
6273
|
const promise = this.request({
|
|
6267
6274
|
op: 'queryRecord',
|
|
6268
6275
|
data: {
|
|
@@ -6277,21 +6284,12 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUES
|
|
|
6277
6284
|
return promise.then(document => document.content);
|
|
6278
6285
|
};
|
|
6279
6286
|
Store.prototype.getReference = function (resource, id) {
|
|
6280
|
-
|
|
6281
|
-
|
|
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 => {
|
|
6287
|
+
console.warn(`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.`);
|
|
6288
|
+
(test => {
|
|
6291
6289
|
if (!test) {
|
|
6292
6290
|
throw new Error(`Attempted to call store.getReference(), but the store instance has already been destroyed.`);
|
|
6293
6291
|
}
|
|
6294
|
-
})(!(this.isDestroying || this.isDestroyed))
|
|
6292
|
+
})(!(this.isDestroying || this.isDestroyed));
|
|
6295
6293
|
let resourceIdentifier;
|
|
6296
6294
|
if (arguments.length === 1 && isMaybeIdentifier(resource)) {
|
|
6297
6295
|
resourceIdentifier = resource;
|
|
@@ -6300,11 +6298,11 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUES
|
|
|
6300
6298
|
const normalizedId = ensureStringId(id);
|
|
6301
6299
|
resourceIdentifier = constructResource(type, normalizedId);
|
|
6302
6300
|
}
|
|
6303
|
-
|
|
6301
|
+
(test => {
|
|
6304
6302
|
if (!test) {
|
|
6305
6303
|
throw new Error('getReference expected to receive either a resource identifier or type and id as arguments');
|
|
6306
6304
|
}
|
|
6307
|
-
})(isMaybeIdentifier(resourceIdentifier))
|
|
6305
|
+
})(isMaybeIdentifier(resourceIdentifier));
|
|
6308
6306
|
const identifier = this.cacheKeyManager.getOrCreateRecordIdentifier(resourceIdentifier);
|
|
6309
6307
|
const cache = upgradeInstanceCaches(this._instanceCache.__instances).reference;
|
|
6310
6308
|
let reference = cache.get(identifier);
|
|
@@ -6315,56 +6313,38 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUES
|
|
|
6315
6313
|
return reference;
|
|
6316
6314
|
};
|
|
6317
6315
|
Store.prototype.modelFor = function (type) {
|
|
6318
|
-
|
|
6319
|
-
|
|
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 => {
|
|
6316
|
+
console.warn(`store.modelFor is deprecated, please use store.schema.fields({ type: '${type}' }) to access schema information instead.`);
|
|
6317
|
+
(test => {
|
|
6329
6318
|
if (!test) {
|
|
6330
6319
|
throw new Error(`Attempted to call store.modelFor(), but the store instance has already been destroyed.`);
|
|
6331
6320
|
}
|
|
6332
|
-
})(!this.isDestroyed)
|
|
6333
|
-
|
|
6321
|
+
})(!this.isDestroyed);
|
|
6322
|
+
(test => {
|
|
6334
6323
|
if (!test) {
|
|
6335
6324
|
throw new Error(`You need to pass <type> to the store's modelFor method`);
|
|
6336
6325
|
}
|
|
6337
|
-
})(typeof type === 'string' && type.length)
|
|
6338
|
-
|
|
6326
|
+
})(typeof type === 'string' && type.length);
|
|
6327
|
+
(test => {
|
|
6339
6328
|
if (!test) {
|
|
6340
6329
|
throw new Error(`No model was found for '${type}' and no schema handles the type`);
|
|
6341
6330
|
}
|
|
6342
6331
|
})(this.schema.hasResource({
|
|
6343
6332
|
type
|
|
6344
|
-
}))
|
|
6333
|
+
}));
|
|
6345
6334
|
return getShimClass(this, type);
|
|
6346
6335
|
};
|
|
6347
6336
|
Store.prototype.saveRecord = function (record, options = {}) {
|
|
6348
|
-
|
|
6349
|
-
|
|
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 => {
|
|
6337
|
+
console.warn(`store.saveRecord is deprecated, please use store.request to initiate a save request instead.`);
|
|
6338
|
+
(test => {
|
|
6359
6339
|
if (!test) {
|
|
6360
6340
|
throw new Error(`Attempted to call store.saveRecord(), but the store instance has already been destroyed.`);
|
|
6361
6341
|
}
|
|
6362
|
-
})(!(this.isDestroying || this.isDestroyed))
|
|
6363
|
-
|
|
6342
|
+
})(!(this.isDestroying || this.isDestroyed));
|
|
6343
|
+
(test => {
|
|
6364
6344
|
if (!test) {
|
|
6365
6345
|
throw new Error(`Unable to initiate save for a record in a disconnected state`);
|
|
6366
6346
|
}
|
|
6367
|
-
})(storeFor(record, true))
|
|
6347
|
+
})(storeFor(record, true));
|
|
6368
6348
|
const identifier = recordIdentifierFor(record);
|
|
6369
6349
|
const cache = this.cache;
|
|
6370
6350
|
if (!identifier) {
|
|
@@ -6372,11 +6352,11 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_REQUES
|
|
|
6372
6352
|
// but just in case we reject here to prevent bad things.
|
|
6373
6353
|
return Promise.reject(new Error(`Record Is Disconnected`));
|
|
6374
6354
|
}
|
|
6375
|
-
|
|
6355
|
+
(test => {
|
|
6376
6356
|
if (!test) {
|
|
6377
6357
|
throw new Error(`Cannot initiate a save request for an unloaded record: ${identifier.lid}`);
|
|
6378
6358
|
}
|
|
6379
|
-
})(this._instanceCache.recordIsLoaded(identifier))
|
|
6359
|
+
})(this._instanceCache.recordIsLoaded(identifier));
|
|
6380
6360
|
if (resourceIsFullyDeleted(this._instanceCache, identifier)) {
|
|
6381
6361
|
return Promise.resolve(record);
|
|
6382
6362
|
}
|
|
@@ -6528,14 +6508,14 @@ const CacheHandler = {
|
|
|
6528
6508
|
activeRequest.priority = {
|
|
6529
6509
|
blocking: true
|
|
6530
6510
|
};
|
|
6531
|
-
|
|
6511
|
+
{
|
|
6532
6512
|
if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
|
|
6533
6513
|
log('request', '', 'DEDUPED', identifier.lid, 'blocking', '');
|
|
6534
6514
|
}
|
|
6535
6515
|
}
|
|
6536
6516
|
return activeRequest.promise;
|
|
6537
6517
|
}
|
|
6538
|
-
|
|
6518
|
+
{
|
|
6539
6519
|
if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
|
|
6540
6520
|
log('request', '', 'ISSUED', identifier?.lid ?? context.request.url ?? context.request.op ?? '<unknown request>', 'blocking', '');
|
|
6541
6521
|
}
|
|
@@ -6582,7 +6562,7 @@ const CacheHandler = {
|
|
|
6582
6562
|
store.notifications.notify(identifier, 'state', null);
|
|
6583
6563
|
});
|
|
6584
6564
|
}
|
|
6585
|
-
|
|
6565
|
+
{
|
|
6586
6566
|
if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
|
|
6587
6567
|
if (activeRequest && identifier) {
|
|
6588
6568
|
log('request', '', 'DEDUPED', identifier.lid, activeRequest.priority.blocking ? 'blocking' : 'non-blocking', '');
|
|
@@ -6593,16 +6573,16 @@ const CacheHandler = {
|
|
|
6593
6573
|
}
|
|
6594
6574
|
store.requestManager._pending.set(context.id, promise);
|
|
6595
6575
|
}
|
|
6596
|
-
|
|
6576
|
+
{
|
|
6597
6577
|
if (getGlobalConfig().WarpDrive.debug.LOG_REQUESTS || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REQUESTS) {
|
|
6598
6578
|
log('request', '', 'CACHE-HIT', identifier?.lid ?? context.request.url ?? context.request.op ?? '<unknown request>', 'cached', '');
|
|
6599
6579
|
}
|
|
6600
6580
|
}
|
|
6601
|
-
|
|
6581
|
+
(test => {
|
|
6602
6582
|
if (!test) {
|
|
6603
6583
|
throw new Error(`Expected a peeked request to be present`);
|
|
6604
6584
|
}
|
|
6605
|
-
})(peeked)
|
|
6585
|
+
})(peeked);
|
|
6606
6586
|
const shouldHydrate = context.request[EnableHydration] || false;
|
|
6607
6587
|
context.setResponse(peeked.response);
|
|
6608
6588
|
if ('error' in peeked) {
|
|
@@ -6626,11 +6606,11 @@ function maybeUpdateUiObjects(store, request, options, document) {
|
|
|
6626
6606
|
identifier
|
|
6627
6607
|
} = options;
|
|
6628
6608
|
if (!document || !options.shouldHydrate) {
|
|
6629
|
-
|
|
6609
|
+
(test => {
|
|
6630
6610
|
if (!test) {
|
|
6631
6611
|
throw new Error(`The CacheHandler expected response content but none was found`);
|
|
6632
6612
|
}
|
|
6633
|
-
})(!options.shouldHydrate)
|
|
6613
|
+
})(!options.shouldHydrate);
|
|
6634
6614
|
return document ?? null;
|
|
6635
6615
|
}
|
|
6636
6616
|
if (identifier) {
|
|
@@ -6763,11 +6743,11 @@ function fetchContentAndHydrate(next, context, identifier, priority) {
|
|
|
6763
6743
|
if (!isMut) {
|
|
6764
6744
|
return promise;
|
|
6765
6745
|
}
|
|
6766
|
-
|
|
6746
|
+
(test => {
|
|
6767
6747
|
if (!test) {
|
|
6768
6748
|
throw new Error(`Expected a mutation`);
|
|
6769
6749
|
}
|
|
6770
|
-
})(isMutation(context.request))
|
|
6750
|
+
})(isMutation(context.request));
|
|
6771
6751
|
|
|
6772
6752
|
// for mutations we need to enqueue the promise with the requestStateService
|
|
6773
6753
|
// TODO should we enque a request per record in records?
|
|
@@ -6792,16 +6772,16 @@ function constructResource(type, id, lid) {
|
|
|
6792
6772
|
if ('id' in resource) {
|
|
6793
6773
|
resource.id = coerceId(resource.id);
|
|
6794
6774
|
}
|
|
6795
|
-
|
|
6775
|
+
(test => {
|
|
6796
6776
|
if (!test) {
|
|
6797
6777
|
throw new Error('Expected either id or lid to be a valid string');
|
|
6798
6778
|
}
|
|
6799
|
-
})('id' in resource && isNonEmptyString(resource.id) || isNonEmptyString(resource.lid))
|
|
6800
|
-
|
|
6779
|
+
})('id' in resource && isNonEmptyString(resource.id) || isNonEmptyString(resource.lid));
|
|
6780
|
+
(test => {
|
|
6801
6781
|
if (!test) {
|
|
6802
6782
|
throw new Error('if id is present, the type must be a string');
|
|
6803
6783
|
}
|
|
6804
|
-
})(!('id' in resource) || typeof resource.type === 'string')
|
|
6784
|
+
})(!('id' in resource) || typeof resource.type === 'string');
|
|
6805
6785
|
return resource;
|
|
6806
6786
|
} else {
|
|
6807
6787
|
const trueId = coerceId(id);
|
|
@@ -6813,11 +6793,11 @@ function constructResource(type, id, lid) {
|
|
|
6813
6793
|
}
|
|
6814
6794
|
throw new Error('Expected either id or lid to be a valid string');
|
|
6815
6795
|
}
|
|
6816
|
-
|
|
6796
|
+
(test => {
|
|
6817
6797
|
if (!test) {
|
|
6818
6798
|
throw new Error('type must be a string');
|
|
6819
6799
|
}
|
|
6820
|
-
})(typeof type === 'string')
|
|
6800
|
+
})(typeof type === 'string');
|
|
6821
6801
|
if (isNonEmptyString(lid)) {
|
|
6822
6802
|
return {
|
|
6823
6803
|
type,
|
|
@@ -6832,6 +6812,49 @@ function constructResource(type, id, lid) {
|
|
|
6832
6812
|
}
|
|
6833
6813
|
}
|
|
6834
6814
|
|
|
6815
|
+
/**
|
|
6816
|
+
A `ManyArray` is a `MutableArray` that represents the contents of a has-many
|
|
6817
|
+
relationship.
|
|
6818
|
+
|
|
6819
|
+
The `ManyArray` is instantiated lazily the first time the relationship is
|
|
6820
|
+
requested.
|
|
6821
|
+
|
|
6822
|
+
This class is not intended to be directly instantiated by consuming applications.
|
|
6823
|
+
|
|
6824
|
+
### Inverses
|
|
6825
|
+
|
|
6826
|
+
Often, the relationships in Ember Data applications will have
|
|
6827
|
+
an inverse. For example, imagine the following models are
|
|
6828
|
+
defined:
|
|
6829
|
+
|
|
6830
|
+
```js [app/models/post.js]
|
|
6831
|
+
import Model, { hasMany } from '@ember-data/model';
|
|
6832
|
+
|
|
6833
|
+
export default class PostModel extends Model {
|
|
6834
|
+
@hasMany('comment') comments;
|
|
6835
|
+
}
|
|
6836
|
+
```
|
|
6837
|
+
|
|
6838
|
+
```js [app/models/comment.js]
|
|
6839
|
+
import { Model, belongsTo } from '@warp-drive/legacy/model';
|
|
6840
|
+
|
|
6841
|
+
export default class CommentModel extends Model {
|
|
6842
|
+
@belongsTo('post') post;
|
|
6843
|
+
}
|
|
6844
|
+
```
|
|
6845
|
+
|
|
6846
|
+
If you created a new instance of `Post` and added
|
|
6847
|
+
a `Comment` record to its `comments` has-many
|
|
6848
|
+
relationship, you would expect the comment's `post`
|
|
6849
|
+
property to be set to the post that contained
|
|
6850
|
+
the has-many.
|
|
6851
|
+
|
|
6852
|
+
We call the record to which a relationship belongs-to the
|
|
6853
|
+
relationship's _owner_.
|
|
6854
|
+
|
|
6855
|
+
@public
|
|
6856
|
+
*/
|
|
6857
|
+
|
|
6835
6858
|
/**
|
|
6836
6859
|
* The options for {@link createLegacyManyArray}
|
|
6837
6860
|
*
|
|
@@ -6896,7 +6919,7 @@ function _MUTATE(target, receiver, prop, args, _SIGNAL) {
|
|
|
6896
6919
|
{
|
|
6897
6920
|
const newValues = extractIdentifiersFromRecords(args);
|
|
6898
6921
|
assertNoDuplicates(collection, target, currentState => currentState.push(...newValues), `Cannot push duplicates to a hasMany's state.`);
|
|
6899
|
-
|
|
6922
|
+
{
|
|
6900
6923
|
// dedupe
|
|
6901
6924
|
const seen = new Set(target);
|
|
6902
6925
|
const unique = new Set();
|
|
@@ -6916,15 +6939,6 @@ function _MUTATE(target, receiver, prop, args, _SIGNAL) {
|
|
|
6916
6939
|
}
|
|
6917
6940
|
return result;
|
|
6918
6941
|
}
|
|
6919
|
-
|
|
6920
|
-
// else, no dedupe, error on duplicates
|
|
6921
|
-
const result = Reflect.apply(target[prop], receiver, args);
|
|
6922
|
-
if (newValues.length) {
|
|
6923
|
-
mutateAddToRelatedRecords(collection, {
|
|
6924
|
-
value: newValues
|
|
6925
|
-
}, _SIGNAL);
|
|
6926
|
-
}
|
|
6927
|
-
return result;
|
|
6928
6942
|
}
|
|
6929
6943
|
case 'pop':
|
|
6930
6944
|
{
|
|
@@ -6940,7 +6954,7 @@ function _MUTATE(target, receiver, prop, args, _SIGNAL) {
|
|
|
6940
6954
|
{
|
|
6941
6955
|
const newValues = extractIdentifiersFromRecords(args);
|
|
6942
6956
|
assertNoDuplicates(collection, target, currentState => currentState.unshift(...newValues), `Cannot unshift duplicates to a hasMany's state.`);
|
|
6943
|
-
|
|
6957
|
+
{
|
|
6944
6958
|
// dedupe
|
|
6945
6959
|
const seen = new Set(target);
|
|
6946
6960
|
const unique = new Set();
|
|
@@ -6961,16 +6975,6 @@ function _MUTATE(target, receiver, prop, args, _SIGNAL) {
|
|
|
6961
6975
|
}
|
|
6962
6976
|
return result;
|
|
6963
6977
|
}
|
|
6964
|
-
|
|
6965
|
-
// else, no dedupe, error on duplicates
|
|
6966
|
-
const result = Reflect.apply(target[prop], receiver, args);
|
|
6967
|
-
if (newValues.length) {
|
|
6968
|
-
mutateAddToRelatedRecords(collection, {
|
|
6969
|
-
value: newValues,
|
|
6970
|
-
index: 0
|
|
6971
|
-
}, _SIGNAL);
|
|
6972
|
-
}
|
|
6973
|
-
return result;
|
|
6974
6978
|
}
|
|
6975
6979
|
case 'shift':
|
|
6976
6980
|
{
|
|
@@ -6997,7 +7001,7 @@ function _MUTATE(target, receiver, prop, args, _SIGNAL) {
|
|
|
6997
7001
|
if (start === 0 && deleteCount === collection[Context].source.length) {
|
|
6998
7002
|
const newValues = extractIdentifiersFromRecords(adds);
|
|
6999
7003
|
assertNoDuplicates(collection, target, currentState => currentState.splice(start, deleteCount, ...newValues), `Cannot replace a hasMany's state with a new state that contains duplicates.`);
|
|
7000
|
-
|
|
7004
|
+
{
|
|
7001
7005
|
// dedupe
|
|
7002
7006
|
const current = new Set(adds);
|
|
7003
7007
|
const unique = Array.from(current);
|
|
@@ -7006,15 +7010,10 @@ function _MUTATE(target, receiver, prop, args, _SIGNAL) {
|
|
|
7006
7010
|
mutateReplaceRelatedRecords(collection, extractIdentifiersFromRecords(unique), _SIGNAL);
|
|
7007
7011
|
return result;
|
|
7008
7012
|
}
|
|
7009
|
-
|
|
7010
|
-
// else, no dedupe, error on duplicates
|
|
7011
|
-
const result = Reflect.apply(target[prop], receiver, args);
|
|
7012
|
-
mutateReplaceRelatedRecords(collection, newValues, _SIGNAL);
|
|
7013
|
-
return result;
|
|
7014
7013
|
}
|
|
7015
7014
|
const newValues = extractIdentifiersFromRecords(adds);
|
|
7016
7015
|
assertNoDuplicates(collection, target, currentState => currentState.splice(start, deleteCount, ...newValues), `Cannot splice a hasMany's state with a new state that contains duplicates.`);
|
|
7017
|
-
|
|
7016
|
+
{
|
|
7018
7017
|
// dedupe
|
|
7019
7018
|
const currentState = target.slice();
|
|
7020
7019
|
currentState.splice(start, deleteCount);
|
|
@@ -7043,29 +7042,13 @@ function _MUTATE(target, receiver, prop, args, _SIGNAL) {
|
|
|
7043
7042
|
}
|
|
7044
7043
|
return result;
|
|
7045
7044
|
}
|
|
7046
|
-
|
|
7047
|
-
// else, no dedupe, error on duplicates
|
|
7048
|
-
const result = Reflect.apply(target[prop], receiver, args);
|
|
7049
|
-
if (deleteCount > 0) {
|
|
7050
|
-
mutateRemoveFromRelatedRecords(collection, {
|
|
7051
|
-
value: result.map(recordIdentifierFor),
|
|
7052
|
-
index: start
|
|
7053
|
-
}, _SIGNAL);
|
|
7054
|
-
}
|
|
7055
|
-
if (newValues.length > 0) {
|
|
7056
|
-
mutateAddToRelatedRecords(collection, {
|
|
7057
|
-
value: newValues,
|
|
7058
|
-
index: start
|
|
7059
|
-
}, _SIGNAL);
|
|
7060
|
-
}
|
|
7061
|
-
return result;
|
|
7062
7045
|
}
|
|
7063
7046
|
default:
|
|
7064
|
-
|
|
7047
|
+
(test => {
|
|
7065
7048
|
{
|
|
7066
7049
|
throw new Error(`unable to convert ${prop} into a transaction that updates the cache state for this record array`);
|
|
7067
7050
|
}
|
|
7068
|
-
})()
|
|
7051
|
+
})();
|
|
7069
7052
|
}
|
|
7070
7053
|
}
|
|
7071
7054
|
function notify() {
|
|
@@ -7075,11 +7058,11 @@ function reload(options) {
|
|
|
7075
7058
|
const {
|
|
7076
7059
|
manager
|
|
7077
7060
|
} = this[Context];
|
|
7078
|
-
|
|
7061
|
+
(test => {
|
|
7079
7062
|
if (!test) {
|
|
7080
7063
|
throw new Error(`Expected the manager for ManyArray to implement reloadHasMany`);
|
|
7081
7064
|
}
|
|
7082
|
-
})(typeof manager.reloadHasMany === 'function')
|
|
7065
|
+
})(typeof manager.reloadHasMany === 'function');
|
|
7083
7066
|
// TODO this is odd, we don't ask the store for anything else like this?
|
|
7084
7067
|
return manager.reloadHasMany(this.key, options);
|
|
7085
7068
|
}
|
|
@@ -7087,11 +7070,11 @@ function createRecord(hash) {
|
|
|
7087
7070
|
const {
|
|
7088
7071
|
store
|
|
7089
7072
|
} = this[Context];
|
|
7090
|
-
|
|
7073
|
+
(test => {
|
|
7091
7074
|
if (!test) {
|
|
7092
7075
|
throw new Error(`Expected modelName to be set`);
|
|
7093
7076
|
}
|
|
7094
|
-
})(this.modelName)
|
|
7077
|
+
})(this.modelName);
|
|
7095
7078
|
const record = store.createRecord(this.modelName, hash);
|
|
7096
7079
|
this.push(record);
|
|
7097
7080
|
return record;
|
|
@@ -7100,7 +7083,7 @@ function destroyLegacyManyArray() {
|
|
|
7100
7083
|
destroy.call(this, false);
|
|
7101
7084
|
}
|
|
7102
7085
|
function assertRecordPassedToHasMany(record) {
|
|
7103
|
-
|
|
7086
|
+
(test => {
|
|
7104
7087
|
if (!test) {
|
|
7105
7088
|
throw new Error(`All elements of a hasMany relationship must be instances of Model, you passed ${typeof record}`);
|
|
7106
7089
|
}
|
|
@@ -7111,7 +7094,7 @@ function assertRecordPassedToHasMany(record) {
|
|
|
7111
7094
|
} catch {
|
|
7112
7095
|
return false;
|
|
7113
7096
|
}
|
|
7114
|
-
}())
|
|
7097
|
+
}());
|
|
7115
7098
|
}
|
|
7116
7099
|
function extractIdentifiersFromRecords(records) {
|
|
7117
7100
|
return records.map(extractIdentifierFromRecord);
|
|
@@ -7126,18 +7109,8 @@ function assertNoDuplicates(collection, target, callback, reason) {
|
|
|
7126
7109
|
callback(state);
|
|
7127
7110
|
if (state.length !== new Set(state).size) {
|
|
7128
7111
|
const duplicates = state.filter((currentValue, currentIndex) => state.indexOf(currentValue) !== currentIndex);
|
|
7129
|
-
|
|
7130
|
-
|
|
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 {
|
|
7140
|
-
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- ')}`);
|
|
7112
|
+
{
|
|
7113
|
+
console.warn(`${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- ')}`);
|
|
7141
7114
|
}
|
|
7142
7115
|
}
|
|
7143
7116
|
}
|
|
@@ -7200,11 +7173,11 @@ function mutate(collection, mutation, _SIGNAL) {
|
|
|
7200
7173
|
const {
|
|
7201
7174
|
manager
|
|
7202
7175
|
} = collection[Context];
|
|
7203
|
-
|
|
7176
|
+
(test => {
|
|
7204
7177
|
if (!test) {
|
|
7205
7178
|
throw new Error(`Expected the manager for ManyArray to implement mutate`);
|
|
7206
7179
|
}
|
|
7207
|
-
})(typeof manager.mutate === 'function')
|
|
7180
|
+
})(typeof manager.mutate === 'function');
|
|
7208
7181
|
manager.mutate(mutation);
|
|
7209
7182
|
notifyInternalSignal(_SIGNAL);
|
|
7210
7183
|
}
|
|
@@ -7685,11 +7658,11 @@ class RequestSubscription {
|
|
|
7685
7658
|
this._latestRequest = reqState.refresh(true);
|
|
7686
7659
|
break;
|
|
7687
7660
|
default:
|
|
7688
|
-
|
|
7661
|
+
(test => {
|
|
7689
7662
|
{
|
|
7690
7663
|
throw new Error(`Invalid ${mode ? 'update mode' : '@autorefreshBehavior'} for <Request />: ${isNeverString(val)}`);
|
|
7691
7664
|
}
|
|
7692
|
-
})()
|
|
7665
|
+
})();
|
|
7693
7666
|
}
|
|
7694
7667
|
if (val !== 'refresh') {
|
|
7695
7668
|
this._localRequest = this._latestRequest;
|
|
@@ -7776,11 +7749,11 @@ class RequestSubscription {
|
|
|
7776
7749
|
request,
|
|
7777
7750
|
query
|
|
7778
7751
|
} = this._args;
|
|
7779
|
-
|
|
7752
|
+
(test => {
|
|
7780
7753
|
if (!test) {
|
|
7781
7754
|
throw new Error(`Cannot use both @request and @query args with the <Request> component`);
|
|
7782
7755
|
}
|
|
7783
|
-
})(!request || !query)
|
|
7756
|
+
})(!request || !query);
|
|
7784
7757
|
const {
|
|
7785
7758
|
_localRequest,
|
|
7786
7759
|
_originalRequest,
|
|
@@ -7797,18 +7770,18 @@ class RequestSubscription {
|
|
|
7797
7770
|
if (request) {
|
|
7798
7771
|
return request;
|
|
7799
7772
|
}
|
|
7800
|
-
|
|
7773
|
+
(test => {
|
|
7801
7774
|
if (!test) {
|
|
7802
7775
|
throw new Error(`You must provide either @request or an @query arg with the <Request> component`);
|
|
7803
7776
|
}
|
|
7804
|
-
})(query)
|
|
7777
|
+
})(query);
|
|
7805
7778
|
return this.store.request(query);
|
|
7806
7779
|
}
|
|
7807
7780
|
static {
|
|
7808
7781
|
decorateMethodV2(this.prototype, "_request", [memoized]);
|
|
7809
7782
|
}
|
|
7810
7783
|
get request() {
|
|
7811
|
-
|
|
7784
|
+
{
|
|
7812
7785
|
try {
|
|
7813
7786
|
const request = this._request;
|
|
7814
7787
|
this._updateSubscriptions();
|
|
@@ -7820,10 +7793,6 @@ class RequestSubscription {
|
|
|
7820
7793
|
cause: e
|
|
7821
7794
|
});
|
|
7822
7795
|
}
|
|
7823
|
-
} else {
|
|
7824
|
-
const request = this._request;
|
|
7825
|
-
this._updateSubscriptions();
|
|
7826
|
-
return request;
|
|
7827
7796
|
}
|
|
7828
7797
|
}
|
|
7829
7798
|
static {
|
|
@@ -8206,21 +8175,21 @@ function createRequestState(future) {
|
|
|
8206
8175
|
promiseState._request = future;
|
|
8207
8176
|
// @ts-expect-error - we still attach it for PendingState
|
|
8208
8177
|
promiseState.reload = () => {
|
|
8209
|
-
|
|
8178
|
+
(test => {
|
|
8210
8179
|
if (!test) {
|
|
8211
8180
|
throw new Error(`Cannot reload a request that is still pending. Await or abort the original request first.`);
|
|
8212
8181
|
}
|
|
8213
|
-
})(!promiseState.isPending)
|
|
8182
|
+
})(!promiseState.isPending);
|
|
8214
8183
|
return performRefresh(future.requester, promiseState.request, true);
|
|
8215
8184
|
};
|
|
8216
8185
|
|
|
8217
8186
|
// @ts-expect-error - we still attach it for PendingState
|
|
8218
8187
|
promiseState.refresh = (usePolicy = false) => {
|
|
8219
|
-
|
|
8188
|
+
(test => {
|
|
8220
8189
|
if (!test) {
|
|
8221
8190
|
throw new Error(`Cannot refresh a request that is still pending. Await or abort the original request first.`);
|
|
8222
8191
|
}
|
|
8223
|
-
})(!promiseState.isPending)
|
|
8192
|
+
})(!promiseState.isPending);
|
|
8224
8193
|
return performRefresh(future.requester, promiseState.request, usePolicy === true ? null : false);
|
|
8225
8194
|
};
|
|
8226
8195
|
if (state) {
|
|
@@ -8334,18 +8303,18 @@ function getRequestState(future) {
|
|
|
8334
8303
|
return state;
|
|
8335
8304
|
}
|
|
8336
8305
|
function getAliasField(context) {
|
|
8337
|
-
|
|
8306
|
+
(test => {
|
|
8338
8307
|
{
|
|
8339
8308
|
throw new Error(`Alias field access is not implemented`);
|
|
8340
8309
|
}
|
|
8341
|
-
})()
|
|
8310
|
+
})();
|
|
8342
8311
|
}
|
|
8343
8312
|
function setAliasField(context) {
|
|
8344
|
-
|
|
8313
|
+
(test => {
|
|
8345
8314
|
{
|
|
8346
8315
|
throw new Error(`Alias field setting is not implemented`);
|
|
8347
8316
|
}
|
|
8348
|
-
})()
|
|
8317
|
+
})();
|
|
8349
8318
|
return false;
|
|
8350
8319
|
}
|
|
8351
8320
|
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 +8344,11 @@ function safeForEach(instance, arr, store, callback, target) {
|
|
|
8375
8344
|
}
|
|
8376
8345
|
// clone to prevent mutation
|
|
8377
8346
|
arr = arr.slice();
|
|
8378
|
-
|
|
8347
|
+
(test => {
|
|
8379
8348
|
if (!test) {
|
|
8380
8349
|
throw new Error('`forEach` expects a function as first argument.');
|
|
8381
8350
|
}
|
|
8382
|
-
})(typeof callback === 'function')
|
|
8351
|
+
})(typeof callback === 'function');
|
|
8383
8352
|
|
|
8384
8353
|
// because we retrieveLatest above we need not worry if array is mutated during iteration
|
|
8385
8354
|
// by unloadRecord/rollbackAttributes
|
|
@@ -8477,11 +8446,11 @@ class ManagedArray {
|
|
|
8477
8446
|
// the special string "@hash" which tells us to treat field.type as a hashFn name with which
|
|
8478
8447
|
// to calc the type.
|
|
8479
8448
|
if (typePath === '@hash') {
|
|
8480
|
-
|
|
8449
|
+
(test => {
|
|
8481
8450
|
if (!test) {
|
|
8482
8451
|
throw new Error(`Expected the field to define a hashFn as its type`);
|
|
8483
8452
|
}
|
|
8484
|
-
})(field.type)
|
|
8453
|
+
})(field.type);
|
|
8485
8454
|
const hashFn = schema.hashFn({
|
|
8486
8455
|
type: field.type
|
|
8487
8456
|
});
|
|
@@ -8489,18 +8458,18 @@ class ManagedArray {
|
|
|
8489
8458
|
objectType = hashFn(rawValue, null, null);
|
|
8490
8459
|
} else {
|
|
8491
8460
|
objectType = rawValue[typePath];
|
|
8492
|
-
|
|
8461
|
+
(test => {
|
|
8493
8462
|
if (!test) {
|
|
8494
8463
|
throw new Error(`Expected the type path for the field to be a value on the raw object`);
|
|
8495
8464
|
}
|
|
8496
|
-
})(typePath && objectType && typeof objectType === 'string')
|
|
8465
|
+
})(typePath && objectType && typeof objectType === 'string');
|
|
8497
8466
|
}
|
|
8498
8467
|
} else {
|
|
8499
|
-
|
|
8468
|
+
(test => {
|
|
8500
8469
|
if (!test) {
|
|
8501
8470
|
throw new Error(`A non-polymorphic SchemaArrayField must provide a SchemaObject type in its definition`);
|
|
8502
8471
|
}
|
|
8503
|
-
})(field.type)
|
|
8472
|
+
})(field.type);
|
|
8504
8473
|
objectType = field.type;
|
|
8505
8474
|
}
|
|
8506
8475
|
|
|
@@ -8525,37 +8494,37 @@ class ManagedArray {
|
|
|
8525
8494
|
// and, we likely should lookup the associated field and throw an error IF
|
|
8526
8495
|
// the given field does not exist OR
|
|
8527
8496
|
// the field is anything other than a GenericField or LegacyAttributeField.
|
|
8528
|
-
|
|
8497
|
+
{
|
|
8529
8498
|
const isPathKeyMode = KeyMode !== '@identity' && KeyMode !== '@index';
|
|
8530
8499
|
if (isPathKeyMode) {
|
|
8531
|
-
|
|
8500
|
+
(test => {
|
|
8532
8501
|
if (!test) {
|
|
8533
8502
|
throw new Error('mode must be a string');
|
|
8534
8503
|
}
|
|
8535
|
-
})(typeof KeyMode === 'string' && KeyMode !== '')
|
|
8504
|
+
})(typeof KeyMode === 'string' && KeyMode !== '');
|
|
8536
8505
|
const modeField = schema.fields({
|
|
8537
8506
|
type: objectType
|
|
8538
8507
|
}).get(KeyMode);
|
|
8539
|
-
|
|
8508
|
+
(test => {
|
|
8540
8509
|
if (!test) {
|
|
8541
8510
|
throw new Error('field must exist in schema');
|
|
8542
8511
|
}
|
|
8543
|
-
})(modeField)
|
|
8544
|
-
|
|
8512
|
+
})(modeField);
|
|
8513
|
+
(test => {
|
|
8545
8514
|
if (!test) {
|
|
8546
8515
|
throw new Error('field must be a GenericField or LegacyAttributeField');
|
|
8547
8516
|
}
|
|
8548
|
-
})(modeField.kind === 'field' || modeField.kind === 'attribute')
|
|
8517
|
+
})(modeField.kind === 'field' || modeField.kind === 'attribute');
|
|
8549
8518
|
}
|
|
8550
8519
|
}
|
|
8551
8520
|
schemaObjectKeyValue = KeyMode === '@identity' ? rawValue : KeyMode === '@index' ? index : rawValue[KeyMode];
|
|
8552
8521
|
}
|
|
8553
8522
|
if (!schemaObjectKeyValue && schemaObjectKeyValue !== 0) {
|
|
8554
|
-
|
|
8523
|
+
(test => {
|
|
8555
8524
|
{
|
|
8556
8525
|
throw new Error(`Unexpected out of bounds access on SchemaArray`);
|
|
8557
8526
|
}
|
|
8558
|
-
})()
|
|
8527
|
+
})();
|
|
8559
8528
|
return undefined;
|
|
8560
8529
|
}
|
|
8561
8530
|
const recordRef = ManagedRecordRefs.get(schemaObjectKeyValue);
|
|
@@ -8652,11 +8621,11 @@ class ManagedArray {
|
|
|
8652
8621
|
if (context.path) {
|
|
8653
8622
|
errorPath = context.path[context.path.length - 1];
|
|
8654
8623
|
}
|
|
8655
|
-
|
|
8624
|
+
(test => {
|
|
8656
8625
|
{
|
|
8657
8626
|
throw new Error(`Cannot set ${String(prop)} on ${errorPath} because the ReactiveResource is not editable`);
|
|
8658
8627
|
}
|
|
8659
|
-
})()
|
|
8628
|
+
})();
|
|
8660
8629
|
return false;
|
|
8661
8630
|
}
|
|
8662
8631
|
if (prop === 'identifier') {
|
|
@@ -8715,7 +8684,7 @@ const desc = {
|
|
|
8715
8684
|
get: function () {
|
|
8716
8685
|
// here to support computed chains
|
|
8717
8686
|
// and {{#each}}
|
|
8718
|
-
|
|
8687
|
+
{
|
|
8719
8688
|
return this;
|
|
8720
8689
|
}
|
|
8721
8690
|
}
|
|
@@ -8798,11 +8767,11 @@ function setArrayField(context) {
|
|
|
8798
8767
|
const rawValue = value === null ? null : field.type ? value.map(item => transform.serialize(item, field.options ?? null, record)) : value?.slice();
|
|
8799
8768
|
cache.setAttr(context.resourceKey, context.path, rawValue);
|
|
8800
8769
|
if (peeked) {
|
|
8801
|
-
|
|
8770
|
+
(test => {
|
|
8802
8771
|
if (!test) {
|
|
8803
8772
|
throw new Error(`Expected the peekManagedArray for ${field.kind} to return a ManagedArray`);
|
|
8804
8773
|
}
|
|
8805
|
-
})(ARRAY_SIGNAL in peeked)
|
|
8774
|
+
})(ARRAY_SIGNAL in peeked);
|
|
8806
8775
|
const arrSignal = peeked[ARRAY_SIGNAL];
|
|
8807
8776
|
arrSignal.isStale = true;
|
|
8808
8777
|
// TODO run array destroy?
|
|
@@ -8853,11 +8822,11 @@ function getBelongsToField(context) {
|
|
|
8853
8822
|
}
|
|
8854
8823
|
|
|
8855
8824
|
// FIXME move this to a "LegacyMode" make this part of "PolarisMode"
|
|
8856
|
-
|
|
8825
|
+
(test => {
|
|
8857
8826
|
if (!test) {
|
|
8858
8827
|
throw new Error(`Can only use belongsTo fields when the resource is in legacy mode`);
|
|
8859
8828
|
}
|
|
8860
|
-
})(context.legacy)
|
|
8829
|
+
})(context.legacy);
|
|
8861
8830
|
return schema._kind('@legacy', 'belongsTo').get(store, context.record, resourceKey, field);
|
|
8862
8831
|
}
|
|
8863
8832
|
function setBelongsToField(context) {
|
|
@@ -8867,28 +8836,28 @@ function setBelongsToField(context) {
|
|
|
8867
8836
|
const {
|
|
8868
8837
|
schema
|
|
8869
8838
|
} = store;
|
|
8870
|
-
|
|
8839
|
+
(test => {
|
|
8871
8840
|
if (!test) {
|
|
8872
8841
|
throw new Error(`Can only mutate belongsTo fields when the resource is in legacy mode`);
|
|
8873
8842
|
}
|
|
8874
|
-
})(context.legacy)
|
|
8843
|
+
})(context.legacy);
|
|
8875
8844
|
schema._kind('@legacy', 'belongsTo').set(store, context.record, context.resourceKey, context.field, context.value);
|
|
8876
8845
|
return true;
|
|
8877
8846
|
}
|
|
8878
8847
|
function getCollectionField(context) {
|
|
8879
8848
|
entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
8880
|
-
|
|
8849
|
+
(test => {
|
|
8881
8850
|
{
|
|
8882
8851
|
throw new Error(`Accessing collection fields is not yet implemented`);
|
|
8883
8852
|
}
|
|
8884
|
-
})()
|
|
8853
|
+
})();
|
|
8885
8854
|
}
|
|
8886
8855
|
function setCollectionField(context) {
|
|
8887
|
-
|
|
8856
|
+
(test => {
|
|
8888
8857
|
{
|
|
8889
8858
|
throw new Error(`Setting collection fields is not yet implemented`);
|
|
8890
8859
|
}
|
|
8891
|
-
})()
|
|
8860
|
+
})();
|
|
8892
8861
|
return false;
|
|
8893
8862
|
}
|
|
8894
8863
|
function getDerivedField(context) {
|
|
@@ -8898,11 +8867,11 @@ function getDerivedField(context) {
|
|
|
8898
8867
|
return schema.derivation(context.field)(context.record, context.field.options ?? null, context.field.name);
|
|
8899
8868
|
}
|
|
8900
8869
|
function setDerivedField(context) {
|
|
8901
|
-
|
|
8870
|
+
(test => {
|
|
8902
8871
|
{
|
|
8903
8872
|
throw new Error(`ILLEGAL SET: Cannot set '${context.path.join('.')}' on '${context.resourceKey.type}' as ${context.field.kind} fields are not mutable`);
|
|
8904
8873
|
}
|
|
8905
|
-
})()
|
|
8874
|
+
})();
|
|
8906
8875
|
return false;
|
|
8907
8876
|
}
|
|
8908
8877
|
function getGenericField(context) {
|
|
@@ -8977,11 +8946,11 @@ class ManyArrayManager {
|
|
|
8977
8946
|
reloadHasMany(key, options) {
|
|
8978
8947
|
// FIXME field needs to use sourceKey
|
|
8979
8948
|
const field = this.store.schema.fields(this.identifier).get(key);
|
|
8980
|
-
|
|
8949
|
+
(test => {
|
|
8981
8950
|
if (!test) {
|
|
8982
8951
|
throw new Error(`Expected a hasMany field for ${key}`);
|
|
8983
8952
|
}
|
|
8984
|
-
})(field?.kind === 'hasMany')
|
|
8953
|
+
})(field?.kind === 'hasMany');
|
|
8985
8954
|
const cacheOptions = options ? extractCacheOptions(options) : {
|
|
8986
8955
|
reload: true
|
|
8987
8956
|
};
|
|
@@ -9009,11 +8978,11 @@ class ManyArrayManager {
|
|
|
9009
8978
|
}
|
|
9010
8979
|
function getRelatedLink(resource) {
|
|
9011
8980
|
const related = resource.links?.related;
|
|
9012
|
-
|
|
8981
|
+
(test => {
|
|
9013
8982
|
if (!test) {
|
|
9014
8983
|
throw new Error(`Expected a related link`);
|
|
9015
8984
|
}
|
|
9016
|
-
})(related)
|
|
8985
|
+
})(related);
|
|
9017
8986
|
return typeof related === 'object' ? related.href : related;
|
|
9018
8987
|
}
|
|
9019
8988
|
function extractCacheOptions(options) {
|
|
@@ -9074,27 +9043,27 @@ function getHasManyField(context) {
|
|
|
9074
9043
|
signal.value = managedArray;
|
|
9075
9044
|
return managedArray;
|
|
9076
9045
|
}
|
|
9077
|
-
|
|
9046
|
+
(test => {
|
|
9078
9047
|
if (!test) {
|
|
9079
9048
|
throw new Error(`Can only use hasMany fields when the resource is in legacy mode`);
|
|
9080
9049
|
}
|
|
9081
|
-
})(context.legacy)
|
|
9050
|
+
})(context.legacy);
|
|
9082
9051
|
return store.schema._kind('@legacy', 'hasMany').get(store, context.record, context.resourceKey, field);
|
|
9083
9052
|
}
|
|
9084
9053
|
function setHasManyField(context) {
|
|
9085
9054
|
const {
|
|
9086
9055
|
store
|
|
9087
9056
|
} = context;
|
|
9088
|
-
|
|
9057
|
+
(test => {
|
|
9089
9058
|
if (!test) {
|
|
9090
9059
|
throw new Error(`Can only use hasMany fields when the resource is in legacy mode`);
|
|
9091
9060
|
}
|
|
9092
|
-
})(context.legacy)
|
|
9093
|
-
|
|
9061
|
+
})(context.legacy);
|
|
9062
|
+
(test => {
|
|
9094
9063
|
if (!test) {
|
|
9095
9064
|
throw new Error(`You must pass an array of records to set a hasMany relationship`);
|
|
9096
9065
|
}
|
|
9097
|
-
})(Array.isArray(context.value))
|
|
9066
|
+
})(Array.isArray(context.value));
|
|
9098
9067
|
store.schema._kind('@legacy', 'hasMany').set(store, context.record, context.resourceKey, context.field, context.value);
|
|
9099
9068
|
return true;
|
|
9100
9069
|
}
|
|
@@ -9108,21 +9077,21 @@ function getHashField(context) {
|
|
|
9108
9077
|
schema,
|
|
9109
9078
|
cache
|
|
9110
9079
|
} = context.store;
|
|
9111
|
-
|
|
9080
|
+
(test => {
|
|
9112
9081
|
if (!test) {
|
|
9113
9082
|
throw new Error(`Cannot use a ${field.kind} directly on a resource.`);
|
|
9114
9083
|
}
|
|
9115
|
-
})(Array.isArray(path) && path.length > 1)
|
|
9084
|
+
})(Array.isArray(path) && path.length > 1);
|
|
9116
9085
|
const realPath = path.slice(0, -1);
|
|
9117
9086
|
const rawData = context.editable ? cache.getAttr(resourceKey, realPath) : cache.getRemoteAttr(resourceKey, realPath);
|
|
9118
9087
|
return schema.hashFn(field)(rawData, field.options ?? null, field.name ?? null);
|
|
9119
9088
|
}
|
|
9120
9089
|
function setHashField(context) {
|
|
9121
|
-
|
|
9090
|
+
(test => {
|
|
9122
9091
|
{
|
|
9123
9092
|
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
9093
|
}
|
|
9125
|
-
})()
|
|
9094
|
+
})();
|
|
9126
9095
|
return false;
|
|
9127
9096
|
}
|
|
9128
9097
|
function getIdentityField(context) {
|
|
@@ -9135,18 +9104,18 @@ function setIdentityField(context) {
|
|
|
9135
9104
|
resourceKey,
|
|
9136
9105
|
store
|
|
9137
9106
|
} = context;
|
|
9138
|
-
|
|
9107
|
+
(test => {
|
|
9139
9108
|
if (!test) {
|
|
9140
9109
|
throw new Error(`Expected to receive a string id`);
|
|
9141
9110
|
}
|
|
9142
|
-
})(typeof value === 'string' && value.length)
|
|
9111
|
+
})(typeof value === 'string' && value.length);
|
|
9143
9112
|
const normalizedId = String(value);
|
|
9144
9113
|
const didChange = normalizedId !== resourceKey.id;
|
|
9145
|
-
|
|
9114
|
+
(test => {
|
|
9146
9115
|
if (!test) {
|
|
9147
9116
|
throw new Error(`Cannot set ${resourceKey.type} record's id to ${normalizedId}, because id is already ${resourceKey.id}`);
|
|
9148
9117
|
}
|
|
9149
|
-
})(!didChange || resourceKey.id === null)
|
|
9118
|
+
})(!didChange || resourceKey.id === null);
|
|
9150
9119
|
if (normalizedId !== null && didChange) {
|
|
9151
9120
|
store._instanceCache.setRecordId(resourceKey, normalizedId);
|
|
9152
9121
|
store.notifications.notify(resourceKey, 'identity', null);
|
|
@@ -9264,11 +9233,11 @@ class ManagedObject {
|
|
|
9264
9233
|
return Reflect.get(target, prop, receiver);
|
|
9265
9234
|
},
|
|
9266
9235
|
set(target, prop, value, receiver) {
|
|
9267
|
-
|
|
9236
|
+
(test => {
|
|
9268
9237
|
if (!test) {
|
|
9269
9238
|
throw new Error(`Cannot set read-only property '${String(prop)}' on ManagedObject`);
|
|
9270
9239
|
}
|
|
9271
|
-
})(context.editable)
|
|
9240
|
+
})(context.editable);
|
|
9272
9241
|
|
|
9273
9242
|
// since objects function as dictionaries, we can't defer to schema/data before extensions
|
|
9274
9243
|
// unless the prop is in the existing data.
|
|
@@ -9411,12 +9380,9 @@ class ResourceRelationship {
|
|
|
9411
9380
|
this.lid = rawValue.lid ?? rawValue.links?.self ?? `relationship:${resourceKey.lid}.${name}`;
|
|
9412
9381
|
this.data = rawValue.data ? store.peekRecord(rawValue.data) : null;
|
|
9413
9382
|
this.name = name;
|
|
9414
|
-
|
|
9383
|
+
{
|
|
9415
9384
|
this.links = Object.freeze(Object.assign({}, rawValue.links));
|
|
9416
9385
|
this.meta = Object.freeze(Object.assign({}, rawValue.meta));
|
|
9417
|
-
} else {
|
|
9418
|
-
this.links = rawValue.links ?? {};
|
|
9419
|
-
this.meta = rawValue.meta ?? {};
|
|
9420
9386
|
}
|
|
9421
9387
|
this[Context] = context;
|
|
9422
9388
|
}
|
|
@@ -9449,11 +9415,11 @@ function getResourceField(context) {
|
|
|
9449
9415
|
return new ResourceRelationship(context);
|
|
9450
9416
|
}
|
|
9451
9417
|
function setResourceField(context) {
|
|
9452
|
-
|
|
9418
|
+
(test => {
|
|
9453
9419
|
{
|
|
9454
9420
|
throw new Error(`setting resource relationships is not yet supported`);
|
|
9455
9421
|
}
|
|
9456
|
-
})()
|
|
9422
|
+
})();
|
|
9457
9423
|
return false;
|
|
9458
9424
|
}
|
|
9459
9425
|
function setSchemaArrayField(context) {
|
|
@@ -9462,11 +9428,11 @@ function setSchemaArrayField(context) {
|
|
|
9462
9428
|
const peeked = fieldSignal?.value;
|
|
9463
9429
|
context.store.cache.setAttr(context.resourceKey, context.path, arrayValue);
|
|
9464
9430
|
if (peeked) {
|
|
9465
|
-
|
|
9431
|
+
(test => {
|
|
9466
9432
|
if (!test) {
|
|
9467
9433
|
throw new Error(`Expected the peekManagedArray for ${context.field.kind} to return a ManagedArray`);
|
|
9468
9434
|
}
|
|
9469
|
-
})(ARRAY_SIGNAL in peeked)
|
|
9435
|
+
})(ARRAY_SIGNAL in peeked);
|
|
9470
9436
|
const arrSignal = peeked[ARRAY_SIGNAL];
|
|
9471
9437
|
arrSignal.isStale = true;
|
|
9472
9438
|
if (!Array.isArray(arrayValue)) {
|
|
@@ -9512,11 +9478,11 @@ function getSchemaObjectField(context) {
|
|
|
9512
9478
|
// the special string "@hash" which tells us to treat field.type as a hashFn name with which
|
|
9513
9479
|
// to calc the type.
|
|
9514
9480
|
if (typePath === '@hash') {
|
|
9515
|
-
|
|
9481
|
+
(test => {
|
|
9516
9482
|
if (!test) {
|
|
9517
9483
|
throw new Error(`Expected the field to define a hashFn as its type`);
|
|
9518
9484
|
}
|
|
9519
|
-
})(field.type)
|
|
9485
|
+
})(field.type);
|
|
9520
9486
|
const hashFn = schema.hashFn({
|
|
9521
9487
|
type: field.type
|
|
9522
9488
|
});
|
|
@@ -9524,18 +9490,18 @@ function getSchemaObjectField(context) {
|
|
|
9524
9490
|
objectType = hashFn(rawValue, null, null);
|
|
9525
9491
|
} else {
|
|
9526
9492
|
objectType = rawValue[typePath];
|
|
9527
|
-
|
|
9493
|
+
(test => {
|
|
9528
9494
|
if (!test) {
|
|
9529
9495
|
throw new Error(`Expected the type path for the field to be a value on the raw object`);
|
|
9530
9496
|
}
|
|
9531
|
-
})(typePath && objectType && typeof objectType === 'string')
|
|
9497
|
+
})(typePath && objectType && typeof objectType === 'string');
|
|
9532
9498
|
}
|
|
9533
9499
|
} else {
|
|
9534
|
-
|
|
9500
|
+
(test => {
|
|
9535
9501
|
if (!test) {
|
|
9536
9502
|
throw new Error(`A non-polymorphic SchemaObjectField must provide a SchemaObject type in its definition`);
|
|
9537
9503
|
}
|
|
9538
|
-
})(field.type)
|
|
9504
|
+
})(field.type);
|
|
9539
9505
|
objectType = field.type;
|
|
9540
9506
|
}
|
|
9541
9507
|
const hashField = schema.resource({
|
|
@@ -9577,11 +9543,11 @@ function setSchemaObjectField(context) {
|
|
|
9577
9543
|
} = context;
|
|
9578
9544
|
let newValue = value;
|
|
9579
9545
|
if (value !== null) {
|
|
9580
|
-
|
|
9546
|
+
(test => {
|
|
9581
9547
|
if (!test) {
|
|
9582
9548
|
throw new Error(`Expected value to be an object`);
|
|
9583
9549
|
}
|
|
9584
|
-
})(typeof value === 'object')
|
|
9550
|
+
})(typeof value === 'object');
|
|
9585
9551
|
newValue = {
|
|
9586
9552
|
...value
|
|
9587
9553
|
};
|
|
@@ -9591,11 +9557,11 @@ function setSchemaObjectField(context) {
|
|
|
9591
9557
|
});
|
|
9592
9558
|
for (const key of Object.keys(newValue)) {
|
|
9593
9559
|
if (!schemaFields.has(key)) {
|
|
9594
|
-
|
|
9560
|
+
(test => {
|
|
9595
9561
|
{
|
|
9596
9562
|
throw new Error(`Field ${key} does not exist on schema object ${context.field.type}`);
|
|
9597
9563
|
}
|
|
9598
|
-
})()
|
|
9564
|
+
})();
|
|
9599
9565
|
return false;
|
|
9600
9566
|
}
|
|
9601
9567
|
}
|
|
@@ -9814,11 +9780,11 @@ class ReactiveResource {
|
|
|
9814
9780
|
if (field?.kind === 'array' || field?.kind === 'schema-array') {
|
|
9815
9781
|
const peeked = signal?.value;
|
|
9816
9782
|
if (peeked) {
|
|
9817
|
-
|
|
9783
|
+
(test => {
|
|
9818
9784
|
if (!test) {
|
|
9819
9785
|
throw new Error(`Expected the peekManagedArray for ${field.kind} to return a ManagedArray`);
|
|
9820
9786
|
}
|
|
9821
|
-
})(ARRAY_SIGNAL in peeked)
|
|
9787
|
+
})(ARRAY_SIGNAL in peeked);
|
|
9822
9788
|
const arrSignal = peeked[ARRAY_SIGNAL];
|
|
9823
9789
|
notifyInternalSignal(arrSignal);
|
|
9824
9790
|
}
|
|
@@ -9839,11 +9805,11 @@ class ReactiveResource {
|
|
|
9839
9805
|
if (isEmbedded) return; // base paths never apply to embedded records
|
|
9840
9806
|
|
|
9841
9807
|
const field = cacheFields.get(key);
|
|
9842
|
-
|
|
9808
|
+
(test => {
|
|
9843
9809
|
if (!test) {
|
|
9844
9810
|
throw new Error(`Expected relationship ${key} to be the name of a field`);
|
|
9845
9811
|
}
|
|
9846
|
-
})(field)
|
|
9812
|
+
})(field);
|
|
9847
9813
|
if (field.kind === 'belongsTo') {
|
|
9848
9814
|
// TODO determine what LOGGING flag to wrap this in if any
|
|
9849
9815
|
// console.log(`Notification for ${key} on ${identifier.type}`, proxy);
|
|
@@ -9863,22 +9829,22 @@ class ReactiveResource {
|
|
|
9863
9829
|
}
|
|
9864
9830
|
return;
|
|
9865
9831
|
}
|
|
9866
|
-
|
|
9832
|
+
(test => {
|
|
9867
9833
|
if (!test) {
|
|
9868
9834
|
throw new Error(`Can only use hasMany fields when the resource is in legacy mode`);
|
|
9869
9835
|
}
|
|
9870
|
-
})(context.legacy)
|
|
9836
|
+
})(context.legacy);
|
|
9871
9837
|
if (schema._kind('@legacy', 'hasMany').notify(context.store, proxy, resourceKey, field)) {
|
|
9872
|
-
|
|
9838
|
+
(test => {
|
|
9873
9839
|
if (!test) {
|
|
9874
9840
|
throw new Error(`Expected options to exist on relationship meta`);
|
|
9875
9841
|
}
|
|
9876
|
-
})(field.options)
|
|
9877
|
-
|
|
9842
|
+
})(field.options);
|
|
9843
|
+
(test => {
|
|
9878
9844
|
if (!test) {
|
|
9879
9845
|
throw new Error(`Expected async to exist on relationship meta options`);
|
|
9880
9846
|
}
|
|
9881
|
-
})('async' in field.options)
|
|
9847
|
+
})('async' in field.options);
|
|
9882
9848
|
if (field.options.async) {
|
|
9883
9849
|
const signal = signals.get(key);
|
|
9884
9850
|
if (signal) {
|
|
@@ -9909,11 +9875,11 @@ class ReactiveResource {
|
|
|
9909
9875
|
},
|
|
9910
9876
|
getOwnPropertyDescriptor(target, prop) {
|
|
9911
9877
|
const schemaForField = prop === identityField?.name ? identityField : fields.get(prop);
|
|
9912
|
-
|
|
9878
|
+
(test => {
|
|
9913
9879
|
if (!test) {
|
|
9914
9880
|
throw new Error(`No field named ${String(prop)} on ${resourceKey.type}`);
|
|
9915
9881
|
}
|
|
9916
|
-
})(schemaForField)
|
|
9882
|
+
})(schemaForField);
|
|
9917
9883
|
if (isNonEnumerableProp(prop)) {
|
|
9918
9884
|
return {
|
|
9919
9885
|
writable: false,
|
|
@@ -10067,19 +10033,19 @@ class ReactiveResource {
|
|
|
10067
10033
|
|
|
10068
10034
|
// too many things check for random symbols
|
|
10069
10035
|
if (typeof prop === 'symbol') return undefined;
|
|
10070
|
-
|
|
10036
|
+
(test => {
|
|
10071
10037
|
{
|
|
10072
10038
|
throw new Error(`No field named ${String(prop)} on ${context.path ? context.value : resourceKey.type}`);
|
|
10073
10039
|
}
|
|
10074
|
-
})()
|
|
10040
|
+
})();
|
|
10075
10041
|
return undefined;
|
|
10076
10042
|
}
|
|
10077
10043
|
const field = maybeField.kind === 'alias' ? maybeField.options : maybeField;
|
|
10078
|
-
|
|
10044
|
+
(test => {
|
|
10079
10045
|
if (!test) {
|
|
10080
10046
|
throw new Error(`Alias fields cannot alias '@id' '@local' '@hash' or 'derived' fields`);
|
|
10081
10047
|
}
|
|
10082
|
-
})(maybeField.kind !== 'alias' || !['@id', '@local', '@hash', 'derived'].includes(maybeField.options.kind))
|
|
10048
|
+
})(maybeField.kind !== 'alias' || !['@id', '@local', '@hash', 'derived'].includes(maybeField.options.kind));
|
|
10083
10049
|
/**
|
|
10084
10050
|
* Prop Array is the path from a resource to the field including
|
|
10085
10051
|
* intermediate "links" on arrays,objects,schema-arrays and schema-objects.
|
|
@@ -10147,11 +10113,11 @@ class ReactiveResource {
|
|
|
10147
10113
|
return true;
|
|
10148
10114
|
}
|
|
10149
10115
|
if (!context.editable) {
|
|
10150
|
-
|
|
10116
|
+
(test => {
|
|
10151
10117
|
{
|
|
10152
10118
|
throw new Error(`Cannot set ${String(prop)} on ${context.path !== null ? context.value : resourceKey.type} because the ReactiveResource is not editable`);
|
|
10153
10119
|
}
|
|
10154
|
-
})()
|
|
10120
|
+
})();
|
|
10155
10121
|
return false;
|
|
10156
10122
|
}
|
|
10157
10123
|
const maybeField = prop === identityField?.name ? identityField : fields.get(prop);
|
|
@@ -10160,19 +10126,19 @@ class ReactiveResource {
|
|
|
10160
10126
|
if (isExtensionProp(extensions, prop)) {
|
|
10161
10127
|
return performExtensionSet(receiver, extensions, signals, prop, value);
|
|
10162
10128
|
}
|
|
10163
|
-
|
|
10129
|
+
(test => {
|
|
10164
10130
|
{
|
|
10165
10131
|
throw new Error(`There is no settable field named ${String(prop)} on ${type}`);
|
|
10166
10132
|
}
|
|
10167
|
-
})()
|
|
10133
|
+
})();
|
|
10168
10134
|
return false;
|
|
10169
10135
|
}
|
|
10170
10136
|
const field = maybeField.kind === 'alias' ? maybeField.options : maybeField;
|
|
10171
|
-
|
|
10137
|
+
(test => {
|
|
10172
10138
|
if (!test) {
|
|
10173
10139
|
throw new Error(`Alias fields cannot alias '@id' '@local' '@hash' or 'derived' fields`);
|
|
10174
10140
|
}
|
|
10175
|
-
})(maybeField.kind !== 'alias' || !['@id', '@local', '@hash', 'derived'].includes(maybeField.options.kind))
|
|
10141
|
+
})(maybeField.kind !== 'alias' || !['@id', '@local', '@hash', 'derived'].includes(maybeField.options.kind));
|
|
10176
10142
|
/**
|
|
10177
10143
|
* Prop Array is the path from a resource to the field including
|
|
10178
10144
|
* intermediate "links" on arrays,objects,schema-arrays and schema-objects.
|
|
@@ -10234,7 +10200,7 @@ class ReactiveResource {
|
|
|
10234
10200
|
}
|
|
10235
10201
|
}
|
|
10236
10202
|
});
|
|
10237
|
-
|
|
10203
|
+
{
|
|
10238
10204
|
Object.defineProperty(this, '__SHOW_ME_THE_DATA_(debug mode only)__', {
|
|
10239
10205
|
enumerable: false,
|
|
10240
10206
|
configurable: true,
|
|
@@ -10304,11 +10270,11 @@ function _DESTROY(record) {
|
|
|
10304
10270
|
// resource is destroyed.
|
|
10305
10271
|
}
|
|
10306
10272
|
function assertNeverField(identifier, field, path) {
|
|
10307
|
-
|
|
10273
|
+
(test => {
|
|
10308
10274
|
{
|
|
10309
10275
|
throw new Error(`Cannot use unknown field kind ${field.kind} on <${identifier.type}>.${Array.isArray(path) ? path.join('.') : path}`);
|
|
10310
10276
|
}
|
|
10311
|
-
})()
|
|
10277
|
+
})();
|
|
10312
10278
|
return false;
|
|
10313
10279
|
}
|
|
10314
10280
|
|
|
@@ -10356,11 +10322,11 @@ function commit(record) {
|
|
|
10356
10322
|
function instantiateRecord(store, identifier, createArgs) {
|
|
10357
10323
|
const schema = store.schema;
|
|
10358
10324
|
const resourceSchema = schema.resource(identifier);
|
|
10359
|
-
|
|
10325
|
+
(test => {
|
|
10360
10326
|
if (!test) {
|
|
10361
10327
|
throw new Error(`Expected a resource schema`);
|
|
10362
10328
|
}
|
|
10363
|
-
})(isResourceSchema(resourceSchema))
|
|
10329
|
+
})(isResourceSchema(resourceSchema));
|
|
10364
10330
|
const legacy = resourceSchema?.legacy ?? false;
|
|
10365
10331
|
const editable = legacy;
|
|
10366
10332
|
const record = new ReactiveResource({
|
|
@@ -10379,11 +10345,11 @@ function instantiateRecord(store, identifier, createArgs) {
|
|
|
10379
10345
|
return record;
|
|
10380
10346
|
}
|
|
10381
10347
|
function assertReactiveResource(record) {
|
|
10382
|
-
|
|
10348
|
+
(test => {
|
|
10383
10349
|
if (!test) {
|
|
10384
10350
|
throw new Error('Expected a ReactiveResource');
|
|
10385
10351
|
}
|
|
10386
|
-
})(record && typeof record === 'object' && Destroy in record)
|
|
10352
|
+
})(record && typeof record === 'object' && Destroy in record);
|
|
10387
10353
|
}
|
|
10388
10354
|
function teardownRecord(record) {
|
|
10389
10355
|
assertReactiveResource(record);
|
|
@@ -10416,11 +10382,11 @@ function _constructor(record) {
|
|
|
10416
10382
|
return state._constructor = state._constructor || {
|
|
10417
10383
|
name: `ReactiveResource<${recordIdentifierFor(record).type}>`,
|
|
10418
10384
|
get modelName() {
|
|
10419
|
-
|
|
10385
|
+
(test => {
|
|
10420
10386
|
{
|
|
10421
10387
|
throw new Error(`record.constructor.modelName is not available outside of legacy mode`);
|
|
10422
10388
|
}
|
|
10423
|
-
})()
|
|
10389
|
+
})();
|
|
10424
10390
|
return undefined;
|
|
10425
10391
|
}
|
|
10426
10392
|
};
|
|
@@ -10447,11 +10413,11 @@ function processExtension(extension) {
|
|
|
10447
10413
|
for (const key of Object.getOwnPropertyNames(baseFeatures)) {
|
|
10448
10414
|
if (BannedKeys.includes(key)) continue;
|
|
10449
10415
|
const decl = Object.getOwnPropertyDescriptor(baseFeatures, key);
|
|
10450
|
-
|
|
10416
|
+
(test => {
|
|
10451
10417
|
if (!test) {
|
|
10452
10418
|
throw new Error(`Expected to find a declaration for ${key} on extension ${name}`);
|
|
10453
10419
|
}
|
|
10454
|
-
})(decl)
|
|
10420
|
+
})(decl);
|
|
10455
10421
|
if (decl.value) {
|
|
10456
10422
|
const {
|
|
10457
10423
|
value
|
|
@@ -10488,11 +10454,11 @@ function processExtension(extension) {
|
|
|
10488
10454
|
});
|
|
10489
10455
|
continue;
|
|
10490
10456
|
}
|
|
10491
|
-
|
|
10457
|
+
(test => {
|
|
10492
10458
|
{
|
|
10493
10459
|
throw new Error(`The feature ${key} on extension ${name} is of an unknown variety.`);
|
|
10494
10460
|
}
|
|
10495
|
-
})()
|
|
10461
|
+
})();
|
|
10496
10462
|
}
|
|
10497
10463
|
return {
|
|
10498
10464
|
kind,
|
|
@@ -10502,11 +10468,11 @@ function processExtension(extension) {
|
|
|
10502
10468
|
}
|
|
10503
10469
|
function getExt(extCache, type, extName) {
|
|
10504
10470
|
const ext = extCache[type].get(extName);
|
|
10505
|
-
|
|
10471
|
+
(test => {
|
|
10506
10472
|
if (!test) {
|
|
10507
10473
|
throw new Error(`expected to have an extension named ${String(extName)} available for ${type}s`);
|
|
10508
10474
|
}
|
|
10509
|
-
})(ext)
|
|
10475
|
+
})(ext);
|
|
10510
10476
|
return ext?.features ?? null;
|
|
10511
10477
|
}
|
|
10512
10478
|
function hasObjectSchema(field) {
|
|
@@ -10618,16 +10584,16 @@ function withDefaults(schema) {
|
|
|
10618
10584
|
const fromIdentity = (record, options, key) => {
|
|
10619
10585
|
const context = record[Context];
|
|
10620
10586
|
const identifier = context.resourceKey;
|
|
10621
|
-
|
|
10587
|
+
(test => {
|
|
10622
10588
|
if (!test) {
|
|
10623
10589
|
throw new Error(`Cannot compute @identity for a record without an identifier`);
|
|
10624
10590
|
}
|
|
10625
|
-
})(identifier)
|
|
10626
|
-
|
|
10591
|
+
})(identifier);
|
|
10592
|
+
(test => {
|
|
10627
10593
|
if (!test) {
|
|
10628
10594
|
throw new Error(`Expected to receive a key to compute @identity, but got ${String(options)}`);
|
|
10629
10595
|
}
|
|
10630
|
-
})(options?.key && ['lid', 'id', 'type', '^'].includes(options.key))
|
|
10596
|
+
})(options?.key && ['lid', 'id', 'type', '^'].includes(options.key));
|
|
10631
10597
|
return options.key === '^' ? identifier : identifier[options.key];
|
|
10632
10598
|
};
|
|
10633
10599
|
fromIdentity[Type] = '@identity';
|
|
@@ -10717,69 +10683,69 @@ class SchemaService {
|
|
|
10717
10683
|
transformation(field) {
|
|
10718
10684
|
const kind = 'kind' in field ? field.kind : '<unknown kind>';
|
|
10719
10685
|
const name = 'name' in field ? field.name : '<unknown name>';
|
|
10720
|
-
|
|
10686
|
+
(test => {
|
|
10721
10687
|
if (!test) {
|
|
10722
10688
|
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
10689
|
}
|
|
10724
|
-
})(!('kind' in field) || ['field', 'object', 'array'].includes(kind))
|
|
10725
|
-
|
|
10690
|
+
})(!('kind' in field) || ['field', 'object', 'array'].includes(kind));
|
|
10691
|
+
(test => {
|
|
10726
10692
|
if (!test) {
|
|
10727
10693
|
throw new Error(`Expected the '${kind}' field '${name}' to specify a transformation via 'field.type', but none was present`);
|
|
10728
10694
|
}
|
|
10729
|
-
})(field.type)
|
|
10730
|
-
|
|
10695
|
+
})(field.type);
|
|
10696
|
+
(test => {
|
|
10731
10697
|
if (!test) {
|
|
10732
10698
|
throw new Error(`No transformation registered with name '${field.type}' for '${kind}' field '${name}'`);
|
|
10733
10699
|
}
|
|
10734
|
-
})(this._transforms.has(field.type))
|
|
10700
|
+
})(this._transforms.has(field.type));
|
|
10735
10701
|
return this._transforms.get(field.type);
|
|
10736
10702
|
}
|
|
10737
10703
|
derivation(field) {
|
|
10738
10704
|
const kind = 'kind' in field ? field.kind : '<unknown kind>';
|
|
10739
10705
|
const name = 'name' in field ? field.name : '<unknown name>';
|
|
10740
|
-
|
|
10706
|
+
(test => {
|
|
10741
10707
|
if (!test) {
|
|
10742
10708
|
throw new Error(`The '${kind}' field '${name}' is not derived and so cannot be used to lookup a derivation`);
|
|
10743
10709
|
}
|
|
10744
|
-
})(!('kind' in field) || kind === 'derived')
|
|
10745
|
-
|
|
10710
|
+
})(!('kind' in field) || kind === 'derived');
|
|
10711
|
+
(test => {
|
|
10746
10712
|
if (!test) {
|
|
10747
10713
|
throw new Error(`Expected the '${kind}' field '${name}' to specify a derivation via 'field.type', but no value was present`);
|
|
10748
10714
|
}
|
|
10749
|
-
})(field.type)
|
|
10750
|
-
|
|
10715
|
+
})(field.type);
|
|
10716
|
+
(test => {
|
|
10751
10717
|
if (!test) {
|
|
10752
10718
|
throw new Error(`No '${field.type}' derivation registered for use by the '${kind}' field '${name}'`);
|
|
10753
10719
|
}
|
|
10754
|
-
})(this._derivations.has(field.type))
|
|
10720
|
+
})(this._derivations.has(field.type));
|
|
10755
10721
|
return this._derivations.get(field.type);
|
|
10756
10722
|
}
|
|
10757
10723
|
hashFn(field) {
|
|
10758
10724
|
const kind = 'kind' in field ? field.kind : '<unknown kind>';
|
|
10759
10725
|
const name = 'name' in field ? field.name : '<unknown name>';
|
|
10760
|
-
|
|
10726
|
+
(test => {
|
|
10761
10727
|
if (!test) {
|
|
10762
10728
|
throw new Error(`The '${kind}' field '${name}' is not a HashField and so cannot be used to lookup a hash function`);
|
|
10763
10729
|
}
|
|
10764
|
-
})(!('kind' in field) || kind === '@hash')
|
|
10765
|
-
|
|
10730
|
+
})(!('kind' in field) || kind === '@hash');
|
|
10731
|
+
(test => {
|
|
10766
10732
|
if (!test) {
|
|
10767
10733
|
throw new Error(`Expected the '${kind}' field '${name}' to specify a hash function via 'field.type', but no value was present`);
|
|
10768
10734
|
}
|
|
10769
|
-
})(field.type)
|
|
10770
|
-
|
|
10735
|
+
})(field.type);
|
|
10736
|
+
(test => {
|
|
10771
10737
|
if (!test) {
|
|
10772
10738
|
throw new Error(`No '${field.type}' hash function is registered for use by the '${kind}' field '${name}'`);
|
|
10773
10739
|
}
|
|
10774
|
-
})(this._hashFns.has(field.type))
|
|
10740
|
+
})(this._hashFns.has(field.type));
|
|
10775
10741
|
return this._hashFns.get(field.type);
|
|
10776
10742
|
}
|
|
10777
10743
|
resource(resource) {
|
|
10778
|
-
|
|
10744
|
+
(test => {
|
|
10779
10745
|
if (!test) {
|
|
10780
10746
|
throw new Error(`No resource registered with name '${resource.type}'`);
|
|
10781
10747
|
}
|
|
10782
|
-
})(this._schemas.has(resource.type))
|
|
10748
|
+
})(this._schemas.has(resource.type));
|
|
10783
10749
|
return this._schemas.get(resource.type).original;
|
|
10784
10750
|
}
|
|
10785
10751
|
registerResources(schemas) {
|
|
@@ -10792,13 +10758,13 @@ class SchemaService {
|
|
|
10792
10758
|
const relationships = {};
|
|
10793
10759
|
const attributes = {};
|
|
10794
10760
|
for (const field of schema.fields) {
|
|
10795
|
-
|
|
10761
|
+
(test => {
|
|
10796
10762
|
if (!test) {
|
|
10797
10763
|
throw new Error(`${field.kind} is not valid inside a ResourceSchema's fields.`);
|
|
10798
10764
|
}
|
|
10799
10765
|
})(
|
|
10800
10766
|
// @ts-expect-error we are checking for mistakes at runtime
|
|
10801
|
-
field.kind !== '@id' && field.kind !== '@hash')
|
|
10767
|
+
field.kind !== '@id' && field.kind !== '@hash');
|
|
10802
10768
|
fields.set(field.name, field);
|
|
10803
10769
|
if (field.kind === 'attribute') {
|
|
10804
10770
|
attributes[field.name] = field;
|
|
@@ -10868,11 +10834,11 @@ class SchemaService {
|
|
|
10868
10834
|
this._derivations.set(derivation[Type], makeCachedDerivation(derivation));
|
|
10869
10835
|
}
|
|
10870
10836
|
CAUTION_MEGA_DANGER_ZONE_registerExtension(extension) {
|
|
10871
|
-
|
|
10837
|
+
(test => {
|
|
10872
10838
|
if (!test) {
|
|
10873
10839
|
throw new Error(`an extension named ${extension.name} for ${extension.kind} already exists!`);
|
|
10874
10840
|
}
|
|
10875
|
-
})(!this._extensions[extension.kind].has(extension.name))
|
|
10841
|
+
})(!this._extensions[extension.kind].has(extension.name));
|
|
10876
10842
|
this._extensions[extension.kind].set(extension.name, processExtension(extension));
|
|
10877
10843
|
}
|
|
10878
10844
|
CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource) {
|
|
@@ -10901,11 +10867,11 @@ class SchemaService {
|
|
|
10901
10867
|
* @internal
|
|
10902
10868
|
*/
|
|
10903
10869
|
_registerMode(mode, kinds) {
|
|
10904
|
-
|
|
10870
|
+
(test => {
|
|
10905
10871
|
if (!test) {
|
|
10906
10872
|
throw new Error(`Mode '${mode}' is already registered`);
|
|
10907
10873
|
}
|
|
10908
|
-
})(!this._modes.has(mode))
|
|
10874
|
+
})(!this._modes.has(mode));
|
|
10909
10875
|
this._modes.set(mode, kinds);
|
|
10910
10876
|
}
|
|
10911
10877
|
|
|
@@ -10921,17 +10887,17 @@ class SchemaService {
|
|
|
10921
10887
|
* @internal
|
|
10922
10888
|
*/
|
|
10923
10889
|
_kind(mode, kind) {
|
|
10924
|
-
|
|
10890
|
+
(test => {
|
|
10925
10891
|
if (!test) {
|
|
10926
10892
|
throw new Error(`Mode '${mode}' is not registered`);
|
|
10927
10893
|
}
|
|
10928
|
-
})(this._modes.has(mode))
|
|
10894
|
+
})(this._modes.has(mode));
|
|
10929
10895
|
const kinds = this._modes.get(mode);
|
|
10930
|
-
|
|
10896
|
+
(test => {
|
|
10931
10897
|
if (!test) {
|
|
10932
10898
|
throw new Error(`Kind '${kind}' is not registered for mode '${mode}'`);
|
|
10933
10899
|
}
|
|
10934
|
-
})(kinds[kind])
|
|
10900
|
+
})(kinds[kind]);
|
|
10935
10901
|
return kinds[kind];
|
|
10936
10902
|
}
|
|
10937
10903
|
|
|
@@ -10948,11 +10914,11 @@ class SchemaService {
|
|
|
10948
10914
|
type
|
|
10949
10915
|
}) {
|
|
10950
10916
|
const schema = this._schemas.get(type);
|
|
10951
|
-
|
|
10917
|
+
(test => {
|
|
10952
10918
|
if (!test) {
|
|
10953
10919
|
throw new Error(`No schema defined for ${type}`);
|
|
10954
10920
|
}
|
|
10955
|
-
})(schema)
|
|
10921
|
+
})(schema);
|
|
10956
10922
|
if (!schema.finalized) {
|
|
10957
10923
|
finalizeResource(this, schema);
|
|
10958
10924
|
}
|
|
@@ -10962,11 +10928,11 @@ class SchemaService {
|
|
|
10962
10928
|
type
|
|
10963
10929
|
}) {
|
|
10964
10930
|
const schema = this._schemas.get(type);
|
|
10965
|
-
|
|
10931
|
+
(test => {
|
|
10966
10932
|
if (!test) {
|
|
10967
10933
|
throw new Error(`No schema defined for ${type}`);
|
|
10968
10934
|
}
|
|
10969
|
-
})(schema)
|
|
10935
|
+
})(schema);
|
|
10970
10936
|
if (!schema.finalized) {
|
|
10971
10937
|
finalizeResource(this, schema);
|
|
10972
10938
|
}
|
|
@@ -10976,19 +10942,11 @@ class SchemaService {
|
|
|
10976
10942
|
return this._schemas.has(resource.type);
|
|
10977
10943
|
}
|
|
10978
10944
|
}
|
|
10979
|
-
|
|
10945
|
+
{
|
|
10980
10946
|
SchemaService.prototype.attributesDefinitionFor = function ({
|
|
10981
10947
|
type
|
|
10982
10948
|
}) {
|
|
10983
|
-
|
|
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
|
-
});
|
|
10949
|
+
console.warn(`Use \`schema.fields({ type })\` instead of \`schema.attributesDefinitionFor({ type })\``);
|
|
10992
10950
|
const schema = this._schemas.get(type);
|
|
10993
10951
|
if (!schema) {
|
|
10994
10952
|
throw new Error(`No schema defined for ${type}`);
|
|
@@ -10998,15 +10956,7 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_SCHEMA
|
|
|
10998
10956
|
SchemaService.prototype.relationshipsDefinitionFor = function ({
|
|
10999
10957
|
type
|
|
11000
10958
|
}) {
|
|
11001
|
-
|
|
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
|
-
});
|
|
10959
|
+
console.warn(`Use \`schema.fields({ type })\` instead of \`schema.relationshipsDefinitionFor({ type })\``);
|
|
11010
10960
|
const schema = this._schemas.get(type);
|
|
11011
10961
|
if (!schema) {
|
|
11012
10962
|
throw new Error(`No schema defined for ${type}`);
|
|
@@ -11014,15 +10964,7 @@ if (macroCondition(getGlobalConfig().WarpDrive.deprecations.ENABLE_LEGACY_SCHEMA
|
|
|
11014
10964
|
return schema.relationships;
|
|
11015
10965
|
};
|
|
11016
10966
|
SchemaService.prototype.doesTypeExist = function (type) {
|
|
11017
|
-
|
|
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
|
-
});
|
|
10967
|
+
console.warn(`Use \`schema.hasResource({ type })\` instead of \`schema.doesTypeExist(type)\``);
|
|
11026
10968
|
return this._schemas.has(type);
|
|
11027
10969
|
};
|
|
11028
10970
|
}
|
|
@@ -11051,12 +10993,12 @@ function finalizeResource(schema, resource) {
|
|
|
11051
10993
|
const seen = new Set();
|
|
11052
10994
|
for (const traitName of resource.traits) {
|
|
11053
10995
|
const trait = schema._traits.get(traitName);
|
|
11054
|
-
|
|
10996
|
+
(test => {
|
|
11055
10997
|
if (!test) {
|
|
11056
10998
|
throw new Error(`The trait ${traitName} MUST be supplied before the resource ${resource.original.type} can be finalized for use.`);
|
|
11057
10999
|
}
|
|
11058
|
-
})(trait)
|
|
11059
|
-
walkTrait(schema, trait, fields, seen, resource.original.type,
|
|
11000
|
+
})(trait);
|
|
11001
|
+
walkTrait(schema, trait, fields, seen, resource.original.type, []);
|
|
11060
11002
|
}
|
|
11061
11003
|
mergeMap(fields, resource.fields);
|
|
11062
11004
|
resource.fields = fields;
|
|
@@ -11070,11 +11012,11 @@ function getCacheFields(resource) {
|
|
|
11070
11012
|
const cacheFields = new Map();
|
|
11071
11013
|
for (const [key, value] of fields) {
|
|
11072
11014
|
if (isNonIdentityCacheableField(value)) {
|
|
11073
|
-
|
|
11015
|
+
(test => {
|
|
11074
11016
|
if (!test) {
|
|
11075
11017
|
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
11018
|
}
|
|
11077
|
-
})(!value.sourceKey || value.sourceKey === key || !fields.has(value.sourceKey))
|
|
11019
|
+
})(!value.sourceKey || value.sourceKey === key || !fields.has(value.sourceKey));
|
|
11078
11020
|
const cacheKey = getFieldCacheKeyStrict(value);
|
|
11079
11021
|
cacheFields.set(cacheKey, value);
|
|
11080
11022
|
}
|
|
@@ -11084,14 +11026,14 @@ function getCacheFields(resource) {
|
|
|
11084
11026
|
function walkTrait(schema, trait, fields, seen, type, debugPath) {
|
|
11085
11027
|
if (seen.has(trait)) {
|
|
11086
11028
|
// if the trait is in the current path, we throw a cycle error in dev.
|
|
11087
|
-
|
|
11029
|
+
{
|
|
11088
11030
|
if (debugPath.includes(trait.name)) {
|
|
11089
11031
|
throw new Error(`CycleError: The Trait '${trait.name}' utilized by the Resource '${type}' includes the following circular reference "${debugPath.join(' > ')} > ${trait.name}"`);
|
|
11090
11032
|
}
|
|
11091
11033
|
}
|
|
11092
11034
|
return;
|
|
11093
11035
|
}
|
|
11094
|
-
const ownPath =
|
|
11036
|
+
const ownPath = [...debugPath, trait.name];
|
|
11095
11037
|
|
|
11096
11038
|
// immediately mark as seen to prevent cycles
|
|
11097
11039
|
// further down the tree from looping back
|
|
@@ -11101,14 +11043,8 @@ function walkTrait(schema, trait, fields, seen, type, debugPath) {
|
|
|
11101
11043
|
if (trait.traits?.length) {
|
|
11102
11044
|
for (const traitName of trait.traits) {
|
|
11103
11045
|
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, {
|
|
11046
|
+
{
|
|
11047
|
+
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
11048
|
id: 'warp-drive:missing-trait-schema-for-resource'
|
|
11113
11049
|
});
|
|
11114
11050
|
}
|
|
@@ -11279,11 +11215,11 @@ function getPromise(promise) {
|
|
|
11279
11215
|
* See also {@link PromiseState}
|
|
11280
11216
|
*/
|
|
11281
11217
|
function getPromiseState(promise) {
|
|
11282
|
-
|
|
11218
|
+
(test => {
|
|
11283
11219
|
if (!test) {
|
|
11284
11220
|
throw new Error(`getPromiseState expects to be called with a promise: called with ${String(promise)}`);
|
|
11285
11221
|
}
|
|
11286
|
-
})(promise)
|
|
11222
|
+
})(promise);
|
|
11287
11223
|
const _promise = getPromise(promise);
|
|
11288
11224
|
let state = PromiseCache.get(_promise);
|
|
11289
11225
|
if (!state) {
|
|
@@ -11305,7 +11241,7 @@ function cloneResponse(response, overrides) {
|
|
|
11305
11241
|
return new Response(response.body, Object.assign(props, overrides));
|
|
11306
11242
|
}
|
|
11307
11243
|
let IS_MAYBE_MIRAGE = () => false;
|
|
11308
|
-
|
|
11244
|
+
{
|
|
11309
11245
|
IS_MAYBE_MIRAGE = () => Boolean(typeof window !== 'undefined' && (window.server?.pretender || window.fetch.toString().replace(/\s+/g, '') !== 'function fetch() { [native code] }'.replace(/\s+/g, '')));
|
|
11310
11246
|
}
|
|
11311
11247
|
const MUTATION_OPS = new Set(['updateRecord', 'createRecord', 'deleteRecord']);
|
|
@@ -11332,11 +11268,11 @@ const Fetch = {
|
|
|
11332
11268
|
async request(context) {
|
|
11333
11269
|
let response;
|
|
11334
11270
|
try {
|
|
11335
|
-
|
|
11271
|
+
(test => {
|
|
11336
11272
|
if (!test) {
|
|
11337
11273
|
throw new Error('The Fetch handler expects the request to have a URL, none was provided.');
|
|
11338
11274
|
}
|
|
11339
|
-
})(context.request.url && typeof context.request.url === 'string')
|
|
11275
|
+
})(context.request.url && typeof context.request.url === 'string');
|
|
11340
11276
|
response = await _fetch(context.request.url, context.request);
|
|
11341
11277
|
} catch (e) {
|
|
11342
11278
|
if (e instanceof DOMException && e.name === 'AbortError') {
|
|
@@ -11471,6 +11407,97 @@ const Fetch = {
|
|
|
11471
11407
|
function isDict(v) {
|
|
11472
11408
|
return v !== null && typeof v === 'object';
|
|
11473
11409
|
}
|
|
11410
|
+
|
|
11411
|
+
/**
|
|
11412
|
+
* ## Import
|
|
11413
|
+
*
|
|
11414
|
+
* ```js
|
|
11415
|
+
* import { RequestManager } from '@warp-drive/core';
|
|
11416
|
+
* ```
|
|
11417
|
+
*
|
|
11418
|
+
* For complete usage guide see the [RequestManager Documentation](/guides/).
|
|
11419
|
+
*
|
|
11420
|
+
* ## How It Works
|
|
11421
|
+
*
|
|
11422
|
+
* ```ts
|
|
11423
|
+
* interface RequestManager {
|
|
11424
|
+
* request<T>(req: RequestInfo): Future<T>;
|
|
11425
|
+
* }
|
|
11426
|
+
* ```
|
|
11427
|
+
*
|
|
11428
|
+
* A RequestManager provides a request/response flow in which configured
|
|
11429
|
+
* handlers are successively given the opportunity to handle, modify, or
|
|
11430
|
+
* pass-along a request.
|
|
11431
|
+
*
|
|
11432
|
+
* <img src="/images/handlers-all-labeled.gif" alt="RequestManager Flow Animation" width="100%" />
|
|
11433
|
+
*
|
|
11434
|
+
* For example:
|
|
11435
|
+
*
|
|
11436
|
+
* ::: code-group
|
|
11437
|
+
*
|
|
11438
|
+
* ```ts [Setup.ts]
|
|
11439
|
+
* import { RequestManager, Fetch } from '@warp-drive/core';
|
|
11440
|
+
* import { AutoCompress } from '@warp-drive/utilities/handlers';
|
|
11441
|
+
* import Auth from 'ember-simple-auth/handler';
|
|
11442
|
+
*
|
|
11443
|
+
* // ... create manager
|
|
11444
|
+
* const manager = new RequestManager()
|
|
11445
|
+
* .use([Auth, new AutoCompress(), Fetch]); // [!code focus]
|
|
11446
|
+
* ```
|
|
11447
|
+
*
|
|
11448
|
+
* ```ts [Usage.ts]
|
|
11449
|
+
* import Config from './config';
|
|
11450
|
+
*
|
|
11451
|
+
* const { apiUrl } = Config;
|
|
11452
|
+
*
|
|
11453
|
+
* // ... execute a request
|
|
11454
|
+
* const response = await manager.request({
|
|
11455
|
+
* url: `${apiUrl}/users`
|
|
11456
|
+
* });
|
|
11457
|
+
* ```
|
|
11458
|
+
*
|
|
11459
|
+
* :::
|
|
11460
|
+
*
|
|
11461
|
+
* ### Futures
|
|
11462
|
+
*
|
|
11463
|
+
* The return value of `manager.request` is a `Future`, which allows
|
|
11464
|
+
* access to limited information about the request while it is still
|
|
11465
|
+
* pending and fulfills with the final state when the request completes.
|
|
11466
|
+
*
|
|
11467
|
+
* A `Future` is cancellable via `abort`.
|
|
11468
|
+
*
|
|
11469
|
+
* Handlers may optionally expose a `ReadableStream` to the `Future` for
|
|
11470
|
+
* streaming data; however, when doing so the future should not resolve
|
|
11471
|
+
* until the response stream is fully read.
|
|
11472
|
+
*
|
|
11473
|
+
* ```ts
|
|
11474
|
+
* interface Future<T> extends Promise<StructuredDocument<T>> {
|
|
11475
|
+
* abort(): void;
|
|
11476
|
+
*
|
|
11477
|
+
* async getStream(): ReadableStream | null;
|
|
11478
|
+
* }
|
|
11479
|
+
* ```
|
|
11480
|
+
*
|
|
11481
|
+
* ### StructuredDocuments
|
|
11482
|
+
*
|
|
11483
|
+
* A Future resolves with a `StructuredDataDocument` or rejects with a `StructuredErrorDocument`.
|
|
11484
|
+
*
|
|
11485
|
+
* ```ts
|
|
11486
|
+
* interface StructuredDataDocument<T> {
|
|
11487
|
+
* request: ImmutableRequestInfo;
|
|
11488
|
+
* response: ImmutableResponseInfo;
|
|
11489
|
+
* content: T;
|
|
11490
|
+
* }
|
|
11491
|
+
* interface StructuredErrorDocument extends Error {
|
|
11492
|
+
* request: ImmutableRequestInfo;
|
|
11493
|
+
* response: ImmutableResponseInfo;
|
|
11494
|
+
* error: string | object;
|
|
11495
|
+
* }
|
|
11496
|
+
* type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument;
|
|
11497
|
+
* ```
|
|
11498
|
+
*
|
|
11499
|
+
* @public
|
|
11500
|
+
*/
|
|
11474
11501
|
class RequestManager {
|
|
11475
11502
|
/** @internal */
|
|
11476
11503
|
|
|
@@ -11504,7 +11531,7 @@ class RequestManager {
|
|
|
11504
11531
|
* @public
|
|
11505
11532
|
*/
|
|
11506
11533
|
useCache(cacheHandler) {
|
|
11507
|
-
|
|
11534
|
+
{
|
|
11508
11535
|
if (this._hasCacheHandler) {
|
|
11509
11536
|
throw new Error(`\`RequestManager.useCache(<handler>)\` May only be invoked once.`);
|
|
11510
11537
|
}
|
|
@@ -11529,7 +11556,7 @@ class RequestManager {
|
|
|
11529
11556
|
*/
|
|
11530
11557
|
use(newHandlers) {
|
|
11531
11558
|
const handlers = this._handlers;
|
|
11532
|
-
|
|
11559
|
+
{
|
|
11533
11560
|
if (Object.isFrozen(handlers)) {
|
|
11534
11561
|
throw new Error(`Cannot add a Handler to a RequestManager after a request has been made`);
|
|
11535
11562
|
}
|
|
@@ -11555,7 +11582,7 @@ class RequestManager {
|
|
|
11555
11582
|
*/
|
|
11556
11583
|
request(request) {
|
|
11557
11584
|
const handlers = this._handlers;
|
|
11558
|
-
|
|
11585
|
+
{
|
|
11559
11586
|
if (!Object.isFrozen(handlers)) {
|
|
11560
11587
|
Object.freeze(handlers);
|
|
11561
11588
|
}
|
|
@@ -11581,7 +11608,7 @@ class RequestManager {
|
|
|
11581
11608
|
// the cache handler will set the result of the request synchronously
|
|
11582
11609
|
// if it is able to fulfill the request from the cache
|
|
11583
11610
|
const cacheResult = getRequestResult(requestId);
|
|
11584
|
-
|
|
11611
|
+
{
|
|
11585
11612
|
if (!request.disableTestWaiter) {
|
|
11586
11613
|
const newPromise = waitFor(promise);
|
|
11587
11614
|
const finalPromise = upgradePromise(newPromise.then(result => {
|
|
@@ -11660,11 +11687,13 @@ class RequestManager {
|
|
|
11660
11687
|
* @mergeModuleWith <project>
|
|
11661
11688
|
*/
|
|
11662
11689
|
|
|
11663
|
-
|
|
11664
|
-
|
|
11690
|
+
{
|
|
11691
|
+
// @ts-expect-error adding to globalThis
|
|
11692
|
+
globalThis.setWarpDriveLogging = setLogging;
|
|
11665
11693
|
|
|
11666
|
-
// @ts-expect-error adding to globalThis
|
|
11667
|
-
globalThis.getWarpDriveRuntimeConfig = getRuntimeConfig;
|
|
11694
|
+
// @ts-expect-error adding to globalThis
|
|
11695
|
+
globalThis.getWarpDriveRuntimeConfig = getRuntimeConfig;
|
|
11696
|
+
}
|
|
11668
11697
|
|
|
11669
11698
|
/**
|
|
11670
11699
|
* Options for setting up a Store instance with `useRecommendedStore`.
|