@warp-drive/legacy 5.8.0-alpha.30 → 5.8.0-alpha.34
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/adapter/error.d.ts +5 -5
- package/declarations/adapter/json-api.d.ts +2 -2
- package/declarations/compat/builders/find-all.d.ts +6 -6
- package/declarations/compat/builders/find-record.d.ts +8 -8
- package/declarations/compat/builders/query.d.ts +12 -12
- package/declarations/compat.d.ts +3 -3
- package/declarations/model/-private/references/belongs-to.d.ts +4 -4
- package/declarations/model/-private/references/has-many.d.ts +2 -2
- package/declarations/model/migration-support.d.ts +34 -18
- package/declarations/model.d.ts +2 -2
- package/declarations/serializer/-private/embedded-records-mixin.d.ts +1 -1
- package/declarations/serializer/json-api.d.ts +3 -3
- package/declarations/serializer/json.d.ts +1 -1
- package/declarations/serializer.d.ts +1 -1
- package/dist/adapter/error.js +7 -7
- package/dist/compat/builders.js +26 -26
- package/dist/compat/utils.js +0 -1
- package/dist/compat.js +3 -3
- package/dist/{errors-B9CDPh3R.js → errors-CIGPcDvd.js} +12 -12
- package/dist/{hooks-CQXyievu.js → hooks-QqRnX108.js} +1 -1
- package/dist/index.js +4 -4
- package/dist/{json-BHxlccxF.js → json-BNrV8EYG.js} +4 -4
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +41 -24
- package/dist/{model-for-B0TSd9HU.js → model-for-CqXsIKws.js} +1 -1
- package/dist/model-fragments.js +2 -2
- package/dist/model.js +3 -3
- package/dist/{schema-provider-BnVr_CnJ.js → schema-provider-g5MfTj8n.js} +11 -11
- package/dist/serializer/json-api.js +7 -7
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +10 -10
- package/dist/serializer.js +1 -1
- package/dist/unpkg/dev/-private-B1pSSN52.js +1210 -0
- package/dist/unpkg/dev/adapter/-private.js +1 -0
- package/dist/unpkg/dev/adapter/error.js +336 -0
- package/dist/unpkg/dev/adapter/json-api.js +132 -0
- package/dist/unpkg/dev/adapter/rest.js +1257 -0
- package/dist/unpkg/dev/adapter.js +1253 -0
- package/dist/unpkg/dev/compat/-private.js +1 -0
- package/dist/unpkg/dev/compat/builders.js +273 -0
- package/dist/unpkg/dev/compat/extensions.js +243 -0
- package/dist/unpkg/dev/compat/utils.js +224 -0
- package/dist/unpkg/dev/compat.js +1020 -0
- package/dist/unpkg/dev/declarations/adapter/-private/build-url-mixin.d.ts +33 -0
- package/dist/unpkg/dev/declarations/adapter/-private/fastboot-interface.d.ts +8 -0
- package/dist/unpkg/dev/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -0
- package/dist/unpkg/dev/declarations/adapter/-private/utils/determine-body-promise.d.ts +4 -0
- package/dist/unpkg/dev/declarations/adapter/-private/utils/fetch.d.ts +8 -0
- package/dist/unpkg/dev/declarations/adapter/-private/utils/parse-response-headers.d.ts +1 -0
- package/dist/unpkg/dev/declarations/adapter/-private/utils/serialize-into-hash.d.ts +6 -0
- package/dist/unpkg/dev/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -0
- package/dist/unpkg/dev/declarations/adapter/-private.d.ts +5 -0
- package/dist/unpkg/dev/declarations/adapter/error.d.ts +215 -0
- package/dist/unpkg/dev/declarations/adapter/json-api.d.ts +231 -0
- package/dist/unpkg/dev/declarations/adapter/rest.d.ts +815 -0
- package/dist/unpkg/dev/declarations/adapter.d.ts +770 -0
- package/dist/unpkg/dev/declarations/compat/-private.d.ts +13 -0
- package/dist/unpkg/dev/declarations/compat/builders/find-all.d.ts +35 -0
- package/dist/unpkg/dev/declarations/compat/builders/find-record.d.ts +56 -0
- package/dist/unpkg/dev/declarations/compat/builders/query.d.ts +66 -0
- package/dist/unpkg/dev/declarations/compat/builders/save-record.d.ts +34 -0
- package/dist/unpkg/dev/declarations/compat/builders/utils.d.ts +3 -0
- package/dist/unpkg/dev/declarations/compat/builders.d.ts +14 -0
- package/dist/unpkg/dev/declarations/compat/extensions.d.ts +59 -0
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/fetch-manager.d.ts +55 -0
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -0
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +11 -0
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +5 -0
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +2 -0
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +524 -0
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +213 -0
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/serializer-response.d.ts +6 -0
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +110 -0
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/snapshot.d.ts +255 -0
- package/dist/unpkg/dev/declarations/compat/utils.d.ts +137 -0
- package/dist/unpkg/dev/declarations/compat.d.ts +157 -0
- package/dist/unpkg/dev/declarations/index.d.ts +70 -0
- package/dist/unpkg/dev/declarations/model/-private/attr.d.ts +170 -0
- package/dist/unpkg/dev/declarations/model/-private/belongs-to.d.ts +174 -0
- package/dist/unpkg/dev/declarations/model/-private/debug/assert-polymorphic-type.d.ts +5 -0
- package/dist/unpkg/dev/declarations/model/-private/errors.d.ts +289 -0
- package/dist/unpkg/dev/declarations/model/-private/has-many.d.ts +162 -0
- package/dist/unpkg/dev/declarations/model/-private/hooks.d.ts +10 -0
- package/dist/unpkg/dev/declarations/model/-private/legacy-relationships-support.d.ts +47 -0
- package/dist/unpkg/dev/declarations/model/-private/model-for-mixin.d.ts +3 -0
- package/dist/unpkg/dev/declarations/model/-private/model-methods.d.ts +39 -0
- package/dist/unpkg/dev/declarations/model/-private/model.d.ts +1269 -0
- package/dist/unpkg/dev/declarations/model/-private/notify-changes.d.ts +4 -0
- package/dist/unpkg/dev/declarations/model/-private/promise-belongs-to.d.ts +40 -0
- package/dist/unpkg/dev/declarations/model/-private/promise-many-array.d.ts +124 -0
- package/dist/unpkg/dev/declarations/model/-private/record-state.d.ts +58 -0
- package/dist/unpkg/dev/declarations/model/-private/references/belongs-to.d.ts +498 -0
- package/dist/unpkg/dev/declarations/model/-private/references/has-many.d.ts +500 -0
- package/dist/unpkg/dev/declarations/model/-private/schema-provider.d.ts +56 -0
- package/dist/unpkg/dev/declarations/model/-private/type-utils.d.ts +57 -0
- package/dist/unpkg/dev/declarations/model/-private/util.d.ts +5 -0
- package/dist/unpkg/dev/declarations/model/-private.d.ts +8 -0
- package/dist/unpkg/dev/declarations/model/migration-support.d.ts +280 -0
- package/dist/unpkg/dev/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
- package/dist/unpkg/dev/declarations/model-fragments/extensions/fragment.d.ts +15 -0
- package/dist/unpkg/dev/declarations/model-fragments/hooks/model-for.d.ts +20 -0
- package/dist/unpkg/dev/declarations/model-fragments/index.d.ts +5 -0
- package/dist/unpkg/dev/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
- package/dist/unpkg/dev/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
- package/dist/unpkg/dev/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
- package/dist/unpkg/dev/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
- package/dist/unpkg/dev/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
- package/dist/unpkg/dev/declarations/model-fragments.d.ts +9 -0
- package/dist/unpkg/dev/declarations/model.d.ts +49 -0
- package/dist/unpkg/dev/declarations/serializer/-private/embedded-records-mixin.d.ts +91 -0
- package/dist/unpkg/dev/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
- package/dist/unpkg/dev/declarations/serializer/-private/transforms/date.d.ts +28 -0
- package/dist/unpkg/dev/declarations/serializer/-private/transforms/number.d.ts +29 -0
- package/dist/unpkg/dev/declarations/serializer/-private/transforms/string.d.ts +29 -0
- package/dist/unpkg/dev/declarations/serializer/-private/transforms/transform.d.ts +118 -0
- package/dist/unpkg/dev/declarations/serializer/-private/utils.d.ts +3 -0
- package/dist/unpkg/dev/declarations/serializer/json-api.d.ts +123 -0
- package/dist/unpkg/dev/declarations/serializer/json.d.ts +75 -0
- package/dist/unpkg/dev/declarations/serializer/rest.d.ts +51 -0
- package/dist/unpkg/dev/declarations/serializer/transform.d.ts +5 -0
- package/dist/unpkg/dev/declarations/serializer.d.ts +254 -0
- package/dist/unpkg/dev/declarations/store/-private.d.ts +223 -0
- package/dist/unpkg/dev/declarations/store.d.ts +3 -0
- package/dist/unpkg/dev/errors-CIGPcDvd.js +2595 -0
- package/dist/unpkg/dev/hooks-QqRnX108.js +74 -0
- package/dist/unpkg/dev/index.js +195 -0
- package/dist/unpkg/dev/json-BNrV8EYG.js +1272 -0
- package/dist/unpkg/dev/model/-private.js +1 -0
- package/dist/unpkg/dev/model/migration-support.js +579 -0
- package/dist/unpkg/dev/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/dev/model-fragments.js +76 -0
- package/dist/unpkg/dev/model.js +667 -0
- package/dist/unpkg/dev/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/dev/schema-provider-g5MfTj8n.js +2338 -0
- package/dist/unpkg/dev/serialize-into-hash-BnYvPex3.js +261 -0
- package/dist/unpkg/dev/serializer/json-api.js +527 -0
- package/dist/unpkg/dev/serializer/json.js +6 -0
- package/dist/unpkg/dev/serializer/rest.js +1243 -0
- package/dist/unpkg/dev/serializer/transform.js +278 -0
- package/dist/unpkg/dev/serializer.js +248 -0
- package/dist/unpkg/dev/store.js +636 -0
- package/dist/unpkg/dev/util-Dul6TZts.js +35 -0
- package/dist/unpkg/dev/utils-Cqw9eRj5.js +23 -0
- package/dist/unpkg/dev-deprecated/-private-B1pSSN52.js +1210 -0
- package/dist/unpkg/dev-deprecated/adapter/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/adapter/error.js +336 -0
- package/dist/unpkg/dev-deprecated/adapter/json-api.js +132 -0
- package/dist/unpkg/dev-deprecated/adapter/rest.js +1257 -0
- package/dist/unpkg/dev-deprecated/adapter.js +1253 -0
- package/dist/unpkg/dev-deprecated/compat/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/compat/builders.js +273 -0
- package/dist/unpkg/dev-deprecated/compat/extensions.js +243 -0
- package/dist/unpkg/dev-deprecated/compat/utils.js +224 -0
- package/dist/unpkg/dev-deprecated/compat.js +1020 -0
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/build-url-mixin.d.ts +33 -0
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/fastboot-interface.d.ts +8 -0
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -0
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/determine-body-promise.d.ts +4 -0
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/fetch.d.ts +8 -0
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/parse-response-headers.d.ts +1 -0
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/serialize-into-hash.d.ts +6 -0
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -0
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private.d.ts +5 -0
- package/dist/unpkg/dev-deprecated/declarations/adapter/error.d.ts +215 -0
- package/dist/unpkg/dev-deprecated/declarations/adapter/json-api.d.ts +231 -0
- package/dist/unpkg/dev-deprecated/declarations/adapter/rest.d.ts +815 -0
- package/dist/unpkg/dev-deprecated/declarations/adapter.d.ts +770 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/-private.d.ts +13 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/builders/find-all.d.ts +35 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/builders/find-record.d.ts +56 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/builders/query.d.ts +66 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/builders/save-record.d.ts +34 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/builders/utils.d.ts +3 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/builders.d.ts +14 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/extensions.d.ts +59 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/fetch-manager.d.ts +55 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +11 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +5 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +2 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +524 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +213 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/serializer-response.d.ts +6 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +110 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/snapshot.d.ts +255 -0
- package/dist/unpkg/dev-deprecated/declarations/compat/utils.d.ts +137 -0
- package/dist/unpkg/dev-deprecated/declarations/compat.d.ts +157 -0
- package/dist/unpkg/dev-deprecated/declarations/index.d.ts +70 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/attr.d.ts +170 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/belongs-to.d.ts +174 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/debug/assert-polymorphic-type.d.ts +5 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/errors.d.ts +289 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/has-many.d.ts +162 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/hooks.d.ts +10 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/legacy-relationships-support.d.ts +47 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/model-for-mixin.d.ts +3 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/model-methods.d.ts +39 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/model.d.ts +1269 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/notify-changes.d.ts +4 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/promise-belongs-to.d.ts +40 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/promise-many-array.d.ts +124 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/record-state.d.ts +58 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/references/belongs-to.d.ts +498 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/references/has-many.d.ts +500 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/schema-provider.d.ts +56 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/type-utils.d.ts +57 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private/util.d.ts +5 -0
- package/dist/unpkg/dev-deprecated/declarations/model/-private.d.ts +8 -0
- package/dist/unpkg/dev-deprecated/declarations/model/migration-support.d.ts +280 -0
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/extensions/fragment.d.ts +15 -0
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/hooks/model-for.d.ts +20 -0
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/index.d.ts +5 -0
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
- package/dist/unpkg/dev-deprecated/declarations/model-fragments.d.ts +9 -0
- package/dist/unpkg/dev-deprecated/declarations/model.d.ts +49 -0
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/embedded-records-mixin.d.ts +91 -0
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/date.d.ts +28 -0
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/number.d.ts +29 -0
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/string.d.ts +29 -0
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/transform.d.ts +118 -0
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/utils.d.ts +3 -0
- package/dist/unpkg/dev-deprecated/declarations/serializer/json-api.d.ts +123 -0
- package/dist/unpkg/dev-deprecated/declarations/serializer/json.d.ts +75 -0
- package/dist/unpkg/dev-deprecated/declarations/serializer/rest.d.ts +51 -0
- package/dist/unpkg/dev-deprecated/declarations/serializer/transform.d.ts +5 -0
- package/dist/unpkg/dev-deprecated/declarations/serializer.d.ts +254 -0
- package/dist/unpkg/dev-deprecated/declarations/store/-private.d.ts +223 -0
- package/dist/unpkg/dev-deprecated/declarations/store.d.ts +3 -0
- package/dist/unpkg/dev-deprecated/errors-CIGPcDvd.js +2595 -0
- package/dist/unpkg/dev-deprecated/hooks-QqRnX108.js +74 -0
- package/dist/unpkg/dev-deprecated/index.js +195 -0
- package/dist/unpkg/dev-deprecated/json-BNrV8EYG.js +1272 -0
- package/dist/unpkg/dev-deprecated/model/-private.js +1 -0
- package/dist/unpkg/dev-deprecated/model/migration-support.js +579 -0
- package/dist/unpkg/dev-deprecated/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/dev-deprecated/model-fragments.js +76 -0
- package/dist/unpkg/dev-deprecated/model.js +667 -0
- package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/dev-deprecated/schema-provider-g5MfTj8n.js +2338 -0
- package/dist/unpkg/dev-deprecated/serialize-into-hash-BnYvPex3.js +261 -0
- package/dist/unpkg/dev-deprecated/serializer/json-api.js +527 -0
- package/dist/unpkg/dev-deprecated/serializer/json.js +6 -0
- package/dist/unpkg/dev-deprecated/serializer/rest.js +1243 -0
- package/dist/unpkg/dev-deprecated/serializer/transform.js +278 -0
- package/dist/unpkg/dev-deprecated/serializer.js +248 -0
- package/dist/unpkg/dev-deprecated/store.js +636 -0
- package/dist/unpkg/dev-deprecated/util-Dul6TZts.js +35 -0
- package/dist/unpkg/dev-deprecated/utils-Cqw9eRj5.js +23 -0
- package/dist/unpkg/prod/-private-B1pSSN52.js +1210 -0
- package/dist/unpkg/prod/adapter/-private.js +1 -0
- package/dist/unpkg/prod/adapter/error.js +336 -0
- package/dist/unpkg/prod/adapter/json-api.js +132 -0
- package/dist/unpkg/prod/adapter/rest.js +1257 -0
- package/dist/unpkg/prod/adapter.js +1253 -0
- package/dist/unpkg/prod/compat/-private.js +1 -0
- package/dist/unpkg/prod/compat/builders.js +273 -0
- package/dist/unpkg/prod/compat/extensions.js +243 -0
- package/dist/unpkg/prod/compat/utils.js +224 -0
- package/dist/unpkg/prod/compat.js +1020 -0
- package/dist/unpkg/prod/declarations/adapter/-private/build-url-mixin.d.ts +33 -0
- package/dist/unpkg/prod/declarations/adapter/-private/fastboot-interface.d.ts +8 -0
- package/dist/unpkg/prod/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -0
- package/dist/unpkg/prod/declarations/adapter/-private/utils/determine-body-promise.d.ts +4 -0
- package/dist/unpkg/prod/declarations/adapter/-private/utils/fetch.d.ts +8 -0
- package/dist/unpkg/prod/declarations/adapter/-private/utils/parse-response-headers.d.ts +1 -0
- package/dist/unpkg/prod/declarations/adapter/-private/utils/serialize-into-hash.d.ts +6 -0
- package/dist/unpkg/prod/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -0
- package/dist/unpkg/prod/declarations/adapter/-private.d.ts +5 -0
- package/dist/unpkg/prod/declarations/adapter/error.d.ts +215 -0
- package/dist/unpkg/prod/declarations/adapter/json-api.d.ts +231 -0
- package/dist/unpkg/prod/declarations/adapter/rest.d.ts +815 -0
- package/dist/unpkg/prod/declarations/adapter.d.ts +770 -0
- package/dist/unpkg/prod/declarations/compat/-private.d.ts +13 -0
- package/dist/unpkg/prod/declarations/compat/builders/find-all.d.ts +35 -0
- package/dist/unpkg/prod/declarations/compat/builders/find-record.d.ts +56 -0
- package/dist/unpkg/prod/declarations/compat/builders/query.d.ts +66 -0
- package/dist/unpkg/prod/declarations/compat/builders/save-record.d.ts +34 -0
- package/dist/unpkg/prod/declarations/compat/builders/utils.d.ts +3 -0
- package/dist/unpkg/prod/declarations/compat/builders.d.ts +14 -0
- package/dist/unpkg/prod/declarations/compat/extensions.d.ts +59 -0
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/fetch-manager.d.ts +55 -0
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -0
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +11 -0
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +5 -0
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +2 -0
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +524 -0
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +213 -0
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/serializer-response.d.ts +6 -0
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +110 -0
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/snapshot.d.ts +255 -0
- package/dist/unpkg/prod/declarations/compat/utils.d.ts +137 -0
- package/dist/unpkg/prod/declarations/compat.d.ts +157 -0
- package/dist/unpkg/prod/declarations/index.d.ts +70 -0
- package/dist/unpkg/prod/declarations/model/-private/attr.d.ts +170 -0
- package/dist/unpkg/prod/declarations/model/-private/belongs-to.d.ts +174 -0
- package/dist/unpkg/prod/declarations/model/-private/debug/assert-polymorphic-type.d.ts +5 -0
- package/dist/unpkg/prod/declarations/model/-private/errors.d.ts +289 -0
- package/dist/unpkg/prod/declarations/model/-private/has-many.d.ts +162 -0
- package/dist/unpkg/prod/declarations/model/-private/hooks.d.ts +10 -0
- package/dist/unpkg/prod/declarations/model/-private/legacy-relationships-support.d.ts +47 -0
- package/dist/unpkg/prod/declarations/model/-private/model-for-mixin.d.ts +3 -0
- package/dist/unpkg/prod/declarations/model/-private/model-methods.d.ts +39 -0
- package/dist/unpkg/prod/declarations/model/-private/model.d.ts +1269 -0
- package/dist/unpkg/prod/declarations/model/-private/notify-changes.d.ts +4 -0
- package/dist/unpkg/prod/declarations/model/-private/promise-belongs-to.d.ts +40 -0
- package/dist/unpkg/prod/declarations/model/-private/promise-many-array.d.ts +124 -0
- package/dist/unpkg/prod/declarations/model/-private/record-state.d.ts +58 -0
- package/dist/unpkg/prod/declarations/model/-private/references/belongs-to.d.ts +498 -0
- package/dist/unpkg/prod/declarations/model/-private/references/has-many.d.ts +500 -0
- package/dist/unpkg/prod/declarations/model/-private/schema-provider.d.ts +56 -0
- package/dist/unpkg/prod/declarations/model/-private/type-utils.d.ts +57 -0
- package/dist/unpkg/prod/declarations/model/-private/util.d.ts +5 -0
- package/dist/unpkg/prod/declarations/model/-private.d.ts +8 -0
- package/dist/unpkg/prod/declarations/model/migration-support.d.ts +280 -0
- package/dist/unpkg/prod/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
- package/dist/unpkg/prod/declarations/model-fragments/extensions/fragment.d.ts +15 -0
- package/dist/unpkg/prod/declarations/model-fragments/hooks/model-for.d.ts +20 -0
- package/dist/unpkg/prod/declarations/model-fragments/index.d.ts +5 -0
- package/dist/unpkg/prod/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
- package/dist/unpkg/prod/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
- package/dist/unpkg/prod/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
- package/dist/unpkg/prod/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
- package/dist/unpkg/prod/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
- package/dist/unpkg/prod/declarations/model-fragments.d.ts +9 -0
- package/dist/unpkg/prod/declarations/model.d.ts +49 -0
- package/dist/unpkg/prod/declarations/serializer/-private/embedded-records-mixin.d.ts +91 -0
- package/dist/unpkg/prod/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
- package/dist/unpkg/prod/declarations/serializer/-private/transforms/date.d.ts +28 -0
- package/dist/unpkg/prod/declarations/serializer/-private/transforms/number.d.ts +29 -0
- package/dist/unpkg/prod/declarations/serializer/-private/transforms/string.d.ts +29 -0
- package/dist/unpkg/prod/declarations/serializer/-private/transforms/transform.d.ts +118 -0
- package/dist/unpkg/prod/declarations/serializer/-private/utils.d.ts +3 -0
- package/dist/unpkg/prod/declarations/serializer/json-api.d.ts +123 -0
- package/dist/unpkg/prod/declarations/serializer/json.d.ts +75 -0
- package/dist/unpkg/prod/declarations/serializer/rest.d.ts +51 -0
- package/dist/unpkg/prod/declarations/serializer/transform.d.ts +5 -0
- package/dist/unpkg/prod/declarations/serializer.d.ts +254 -0
- package/dist/unpkg/prod/declarations/store/-private.d.ts +223 -0
- package/dist/unpkg/prod/declarations/store.d.ts +3 -0
- package/dist/unpkg/prod/errors-CIGPcDvd.js +2595 -0
- package/dist/unpkg/prod/hooks-QqRnX108.js +74 -0
- package/dist/unpkg/prod/index.js +195 -0
- package/dist/unpkg/prod/json-BNrV8EYG.js +1272 -0
- package/dist/unpkg/prod/model/-private.js +1 -0
- package/dist/unpkg/prod/model/migration-support.js +579 -0
- package/dist/unpkg/prod/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/prod/model-fragments.js +76 -0
- package/dist/unpkg/prod/model.js +667 -0
- package/dist/unpkg/prod/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/prod/schema-provider-g5MfTj8n.js +2338 -0
- package/dist/unpkg/prod/serialize-into-hash-BnYvPex3.js +261 -0
- package/dist/unpkg/prod/serializer/json-api.js +527 -0
- package/dist/unpkg/prod/serializer/json.js +6 -0
- package/dist/unpkg/prod/serializer/rest.js +1243 -0
- package/dist/unpkg/prod/serializer/transform.js +278 -0
- package/dist/unpkg/prod/serializer.js +248 -0
- package/dist/unpkg/prod/store.js +636 -0
- package/dist/unpkg/prod/util-Dul6TZts.js +35 -0
- package/dist/unpkg/prod/utils-Cqw9eRj5.js +23 -0
- package/dist/unpkg/prod-deprecated/-private-B1pSSN52.js +1210 -0
- package/dist/unpkg/prod-deprecated/adapter/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/adapter/error.js +336 -0
- package/dist/unpkg/prod-deprecated/adapter/json-api.js +132 -0
- package/dist/unpkg/prod-deprecated/adapter/rest.js +1257 -0
- package/dist/unpkg/prod-deprecated/adapter.js +1253 -0
- package/dist/unpkg/prod-deprecated/compat/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/compat/builders.js +273 -0
- package/dist/unpkg/prod-deprecated/compat/extensions.js +243 -0
- package/dist/unpkg/prod-deprecated/compat/utils.js +224 -0
- package/dist/unpkg/prod-deprecated/compat.js +1020 -0
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/build-url-mixin.d.ts +33 -0
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/fastboot-interface.d.ts +8 -0
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -0
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/determine-body-promise.d.ts +4 -0
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/fetch.d.ts +8 -0
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/parse-response-headers.d.ts +1 -0
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/serialize-into-hash.d.ts +6 -0
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/serialize-query-params.d.ts +5 -0
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private.d.ts +5 -0
- package/dist/unpkg/prod-deprecated/declarations/adapter/error.d.ts +215 -0
- package/dist/unpkg/prod-deprecated/declarations/adapter/json-api.d.ts +231 -0
- package/dist/unpkg/prod-deprecated/declarations/adapter/rest.d.ts +815 -0
- package/dist/unpkg/prod-deprecated/declarations/adapter.d.ts +770 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/-private.d.ts +13 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/builders/find-all.d.ts +35 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/builders/find-record.d.ts +56 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/builders/query.d.ts +66 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/builders/save-record.d.ts +34 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/builders/utils.d.ts +3 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/builders.d.ts +14 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/extensions.d.ts +59 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/fetch-manager.d.ts +55 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +11 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +5 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +2 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +524 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +213 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/serializer-response.d.ts +6 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +110 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/snapshot.d.ts +255 -0
- package/dist/unpkg/prod-deprecated/declarations/compat/utils.d.ts +137 -0
- package/dist/unpkg/prod-deprecated/declarations/compat.d.ts +157 -0
- package/dist/unpkg/prod-deprecated/declarations/index.d.ts +70 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/attr.d.ts +170 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/belongs-to.d.ts +174 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/debug/assert-polymorphic-type.d.ts +5 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/errors.d.ts +289 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/has-many.d.ts +162 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/hooks.d.ts +10 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/legacy-relationships-support.d.ts +47 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/model-for-mixin.d.ts +3 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/model-methods.d.ts +39 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/model.d.ts +1269 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/notify-changes.d.ts +4 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/promise-belongs-to.d.ts +40 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/promise-many-array.d.ts +124 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/record-state.d.ts +58 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/references/belongs-to.d.ts +498 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/references/has-many.d.ts +500 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/schema-provider.d.ts +56 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/type-utils.d.ts +57 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private/util.d.ts +5 -0
- package/dist/unpkg/prod-deprecated/declarations/model/-private.d.ts +8 -0
- package/dist/unpkg/prod-deprecated/declarations/model/migration-support.d.ts +280 -0
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/extensions/fragment.d.ts +15 -0
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/hooks/model-for.d.ts +20 -0
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/index.d.ts +5 -0
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
- package/dist/unpkg/prod-deprecated/declarations/model-fragments.d.ts +9 -0
- package/dist/unpkg/prod-deprecated/declarations/model.d.ts +49 -0
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/embedded-records-mixin.d.ts +91 -0
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/boolean.d.ts +47 -0
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/date.d.ts +28 -0
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/number.d.ts +29 -0
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/string.d.ts +29 -0
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/transform.d.ts +118 -0
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/utils.d.ts +3 -0
- package/dist/unpkg/prod-deprecated/declarations/serializer/json-api.d.ts +123 -0
- package/dist/unpkg/prod-deprecated/declarations/serializer/json.d.ts +75 -0
- package/dist/unpkg/prod-deprecated/declarations/serializer/rest.d.ts +51 -0
- package/dist/unpkg/prod-deprecated/declarations/serializer/transform.d.ts +5 -0
- package/dist/unpkg/prod-deprecated/declarations/serializer.d.ts +254 -0
- package/dist/unpkg/prod-deprecated/declarations/store/-private.d.ts +223 -0
- package/dist/unpkg/prod-deprecated/declarations/store.d.ts +3 -0
- package/dist/unpkg/prod-deprecated/errors-CIGPcDvd.js +2595 -0
- package/dist/unpkg/prod-deprecated/hooks-QqRnX108.js +74 -0
- package/dist/unpkg/prod-deprecated/index.js +195 -0
- package/dist/unpkg/prod-deprecated/json-BNrV8EYG.js +1272 -0
- package/dist/unpkg/prod-deprecated/model/-private.js +1 -0
- package/dist/unpkg/prod-deprecated/model/migration-support.js +579 -0
- package/dist/unpkg/prod-deprecated/model-for-CqXsIKws.js +221 -0
- package/dist/unpkg/prod-deprecated/model-fragments.js +76 -0
- package/dist/unpkg/prod-deprecated/model.js +667 -0
- package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +65 -0
- package/dist/unpkg/prod-deprecated/schema-provider-g5MfTj8n.js +2338 -0
- package/dist/unpkg/prod-deprecated/serialize-into-hash-BnYvPex3.js +261 -0
- package/dist/unpkg/prod-deprecated/serializer/json-api.js +527 -0
- package/dist/unpkg/prod-deprecated/serializer/json.js +6 -0
- package/dist/unpkg/prod-deprecated/serializer/rest.js +1243 -0
- package/dist/unpkg/prod-deprecated/serializer/transform.js +278 -0
- package/dist/unpkg/prod-deprecated/serializer.js +248 -0
- package/dist/unpkg/prod-deprecated/store.js +636 -0
- package/dist/unpkg/prod-deprecated/util-Dul6TZts.js +35 -0
- package/dist/unpkg/prod-deprecated/utils-Cqw9eRj5.js +23 -0
- package/package.json +30 -6
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
import { defineSignal, assertPrivateStore, ensureStringId, recordIdentifierFor, constructResource, storeFor } from '@warp-drive/core/store/-private';
|
|
2
|
+
import { SkipCache } from '@warp-drive/core/types/request';
|
|
3
|
+
import { i as isMaybeIdentifier } from "./utils-Cqw9eRj5.js";
|
|
4
|
+
import { n as normalizeModelName } from "./util-Dul6TZts.js";
|
|
5
|
+
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
6
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
When a find request is triggered on the store, the user can optionally pass in
|
|
10
|
+
attributes and relationships to be preloaded. These are meant to behave as if they
|
|
11
|
+
came back from the server, except the user obtained them out of band and is informing
|
|
12
|
+
the store of their existence. The most common use case is for supporting client side
|
|
13
|
+
nested URLs, such as `/posts/1/comments/2` so the user can do
|
|
14
|
+
`store.findRecord('comment', 2, { preload: { post: 1 } })` without having to fetch the post.
|
|
15
|
+
|
|
16
|
+
Preloaded data can be attributes and relationships passed in either as IDs or as actual
|
|
17
|
+
models.
|
|
18
|
+
*/
|
|
19
|
+
function preloadData(store, identifier, preload) {
|
|
20
|
+
const jsonPayload = {};
|
|
21
|
+
//TODO(Igor) consider the polymorphic case
|
|
22
|
+
const schemas = store.schema;
|
|
23
|
+
const fields = schemas.fields(identifier);
|
|
24
|
+
Object.keys(preload).forEach(key => {
|
|
25
|
+
const preloadValue = preload[key];
|
|
26
|
+
const field = fields.get(key);
|
|
27
|
+
if (field && (field.kind === 'hasMany' || field.kind === 'belongsTo')) {
|
|
28
|
+
if (!jsonPayload.relationships) {
|
|
29
|
+
jsonPayload.relationships = {};
|
|
30
|
+
}
|
|
31
|
+
jsonPayload.relationships[key] = preloadRelationship(field, preloadValue);
|
|
32
|
+
} else {
|
|
33
|
+
if (!jsonPayload.attributes) {
|
|
34
|
+
jsonPayload.attributes = {};
|
|
35
|
+
}
|
|
36
|
+
jsonPayload.attributes[key] = preloadValue;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const cache = store.cache;
|
|
40
|
+
assertPrivateStore(store);
|
|
41
|
+
const hasRecord = Boolean(store._instanceCache.peek(identifier));
|
|
42
|
+
cache.upsert(identifier, jsonPayload, hasRecord);
|
|
43
|
+
}
|
|
44
|
+
function preloadRelationship(schema, preloadValue) {
|
|
45
|
+
const relatedType = schema.type;
|
|
46
|
+
if (schema.kind === 'hasMany') {
|
|
47
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
48
|
+
if (!test) {
|
|
49
|
+
throw new Error('You need to pass in an array to set a hasMany property on a record');
|
|
50
|
+
}
|
|
51
|
+
})(Array.isArray(preloadValue)) : {};
|
|
52
|
+
return {
|
|
53
|
+
data: preloadValue.map(value => _convertPreloadRelationshipToJSON(value, relatedType))
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
57
|
+
if (!test) {
|
|
58
|
+
throw new Error('You should not pass in an array to set a belongsTo property on a record');
|
|
59
|
+
}
|
|
60
|
+
})(!Array.isArray(preloadValue)) : {};
|
|
61
|
+
return {
|
|
62
|
+
data: preloadValue ? _convertPreloadRelationshipToJSON(preloadValue, relatedType) : null
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
findRecord('user', '1', { preload: { friends: ['1'] }});
|
|
68
|
+
findRecord('user', '1', { preload: { friends: [record] }});
|
|
69
|
+
*/
|
|
70
|
+
function _convertPreloadRelationshipToJSON(value, type) {
|
|
71
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
72
|
+
return {
|
|
73
|
+
type,
|
|
74
|
+
id: ensureStringId(value)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// TODO if not a record instance assert it's an identifier
|
|
78
|
+
// and allow identifiers to be used
|
|
79
|
+
return recordIdentifierFor(value);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Minimum subset of static schema methods and properties on the
|
|
84
|
+
* "model" class.
|
|
85
|
+
*
|
|
86
|
+
* Only used when using the legacy schema-service implementation
|
|
87
|
+
* for @ember-data/model or when wrapping schema for legacy
|
|
88
|
+
* Adapters/Serializers.
|
|
89
|
+
*
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
function _resourceIsFullDeleted(identifier, cache) {
|
|
93
|
+
return cache.isDeletionCommitted(identifier) || cache.isNew(identifier) && cache.isDeleted(identifier);
|
|
94
|
+
}
|
|
95
|
+
function resourceIsFullyDeleted(instanceCache, identifier) {
|
|
96
|
+
const cache = instanceCache.cache;
|
|
97
|
+
return !cache || _resourceIsFullDeleted(identifier, cache);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
A `RecordReference` is a low-level API that allows users and
|
|
102
|
+
addon authors to perform meta-operations on a record.
|
|
103
|
+
|
|
104
|
+
@hideconstructor
|
|
105
|
+
@public
|
|
106
|
+
*/
|
|
107
|
+
class RecordReference {
|
|
108
|
+
/** @internal */
|
|
109
|
+
|
|
110
|
+
/** @internal */
|
|
111
|
+
// unsubscribe token given to us by the notification manager
|
|
112
|
+
___token;
|
|
113
|
+
/** @internal */
|
|
114
|
+
___identifier;
|
|
115
|
+
|
|
116
|
+
/** @internal */
|
|
117
|
+
|
|
118
|
+
constructor(store, identifier) {
|
|
119
|
+
this.store = store;
|
|
120
|
+
this.___identifier = identifier;
|
|
121
|
+
this.___token = store.notifications.subscribe(identifier, (_, bucket, notifiedKey) => {
|
|
122
|
+
if (bucket === 'identity' || bucket === 'attributes' && notifiedKey === 'id') {
|
|
123
|
+
this._ref++;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** @internal */
|
|
129
|
+
destroy() {
|
|
130
|
+
this.store.notifications.unsubscribe(this.___token);
|
|
131
|
+
}
|
|
132
|
+
get type() {
|
|
133
|
+
return this.identifier().type;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
The `id` of the record that this reference refers to.
|
|
138
|
+
Together, the `type` and `id` properties form a composite key for
|
|
139
|
+
the identity map.
|
|
140
|
+
Example
|
|
141
|
+
```javascript
|
|
142
|
+
let userRef = store.getReference('user', 1);
|
|
143
|
+
userRef.id(); // '1'
|
|
144
|
+
```
|
|
145
|
+
@public
|
|
146
|
+
@return The id of the record.
|
|
147
|
+
*/
|
|
148
|
+
id() {
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
150
|
+
this._ref; // consume the tracked prop
|
|
151
|
+
return this.___identifier.id;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
The `identifier` of the record that this reference refers to.
|
|
156
|
+
Together, the `type` and `id` properties form a composite key for
|
|
157
|
+
the identity map.
|
|
158
|
+
Example
|
|
159
|
+
```javascript
|
|
160
|
+
let userRef = store.getReference('user', 1);
|
|
161
|
+
userRef.identifier(); // '1'
|
|
162
|
+
```
|
|
163
|
+
@public
|
|
164
|
+
@return The identifier of the record.
|
|
165
|
+
*/
|
|
166
|
+
identifier() {
|
|
167
|
+
return this.___identifier;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
How the reference will be looked up when it is loaded. Currently
|
|
172
|
+
this always returns `identity` to signify that a record will be
|
|
173
|
+
loaded by its `type` and `id`.
|
|
174
|
+
Example
|
|
175
|
+
```javascript
|
|
176
|
+
const userRef = store.getReference('user', 1);
|
|
177
|
+
userRef.remoteType(); // 'identity'
|
|
178
|
+
```
|
|
179
|
+
@public
|
|
180
|
+
*/
|
|
181
|
+
remoteType() {
|
|
182
|
+
return 'identity';
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
This API allows you to provide a reference with new data. The
|
|
187
|
+
simplest usage of this API is similar to `store.push`: you provide a
|
|
188
|
+
normalized hash of data and the object represented by the reference
|
|
189
|
+
will update.
|
|
190
|
+
If you pass a promise to `push`, Ember Data will not ask the adapter
|
|
191
|
+
for the data if another attempt to fetch it is made in the
|
|
192
|
+
interim. When the promise resolves, the underlying object is updated
|
|
193
|
+
with the new data, and the promise returned by *this function* is resolved
|
|
194
|
+
with that object.
|
|
195
|
+
For example, `recordReference.push(promise)` will be resolved with a
|
|
196
|
+
record.
|
|
197
|
+
Example
|
|
198
|
+
```javascript
|
|
199
|
+
let userRef = store.getReference('user', 1);
|
|
200
|
+
// provide data for reference
|
|
201
|
+
userRef.push({
|
|
202
|
+
data: {
|
|
203
|
+
id: "1",
|
|
204
|
+
type: "user",
|
|
205
|
+
attributes: {
|
|
206
|
+
username: "@user"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}).then(function(user) {
|
|
210
|
+
userRef.value() === user;
|
|
211
|
+
});
|
|
212
|
+
```
|
|
213
|
+
@public
|
|
214
|
+
@param objectOrPromise a JSON:API ResourceDocument or a promise resolving to one
|
|
215
|
+
@return a promise for the value (record or relationship)
|
|
216
|
+
*/
|
|
217
|
+
push(objectOrPromise) {
|
|
218
|
+
// TODO @deprecate pushing unresolved payloads
|
|
219
|
+
return Promise.resolve(objectOrPromise).then(data => {
|
|
220
|
+
return this.store.push(data);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
If the entity referred to by the reference is already loaded, it is
|
|
226
|
+
present as `reference.value`. Otherwise the value returned by this function
|
|
227
|
+
is `null`.
|
|
228
|
+
Example
|
|
229
|
+
```javascript
|
|
230
|
+
let userRef = store.getReference('user', 1);
|
|
231
|
+
userRef.value(); // user
|
|
232
|
+
```
|
|
233
|
+
@public
|
|
234
|
+
@return {Model} the record for this RecordReference
|
|
235
|
+
*/
|
|
236
|
+
value() {
|
|
237
|
+
return this.store.peekRecord(this.___identifier);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
Triggers a fetch for the backing entity based on its `remoteType`
|
|
242
|
+
(see `remoteType` definitions per reference type).
|
|
243
|
+
Example
|
|
244
|
+
```javascript
|
|
245
|
+
let userRef = store.getReference('user', 1);
|
|
246
|
+
// load user (via store.find)
|
|
247
|
+
userRef.load().then(...)
|
|
248
|
+
```
|
|
249
|
+
@public
|
|
250
|
+
@return the record for this RecordReference
|
|
251
|
+
*/
|
|
252
|
+
load() {
|
|
253
|
+
const id = this.id();
|
|
254
|
+
if (id !== null) {
|
|
255
|
+
return this.store.findRecord(this.type, id);
|
|
256
|
+
}
|
|
257
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
258
|
+
{
|
|
259
|
+
throw new Error(`Unable to fetch record of type ${this.type} without an id`);
|
|
260
|
+
}
|
|
261
|
+
})() : {};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
Reloads the record if it is already loaded. If the record is not
|
|
266
|
+
loaded it will load the record via `store.findRecord`
|
|
267
|
+
Example
|
|
268
|
+
```javascript
|
|
269
|
+
let userRef = store.getReference('user', 1);
|
|
270
|
+
// or trigger a reload
|
|
271
|
+
userRef.reload().then(...)
|
|
272
|
+
```
|
|
273
|
+
@public
|
|
274
|
+
@return the record for this RecordReference
|
|
275
|
+
*/
|
|
276
|
+
reload() {
|
|
277
|
+
const id = this.id();
|
|
278
|
+
if (id !== null) {
|
|
279
|
+
return this.store.findRecord(this.type, id, {
|
|
280
|
+
reload: true
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
284
|
+
{
|
|
285
|
+
throw new Error(`Unable to fetch record of type ${this.type} without an id`);
|
|
286
|
+
}
|
|
287
|
+
})() : {};
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
defineSignal(RecordReference.prototype, '_ref');
|
|
291
|
+
|
|
292
|
+
// if modelFor turns out to be a bottleneck we should replace with a Map
|
|
293
|
+
// and clear it during store teardown.
|
|
294
|
+
const AvailableShims = getOrSetGlobal('AvailableShims', new WeakMap());
|
|
295
|
+
function getShimClass(store, modelName) {
|
|
296
|
+
let shims = AvailableShims.get(store);
|
|
297
|
+
if (!shims) {
|
|
298
|
+
shims = Object.create(null);
|
|
299
|
+
AvailableShims.set(store, shims);
|
|
300
|
+
}
|
|
301
|
+
let shim = shims[modelName];
|
|
302
|
+
if (shim === undefined) {
|
|
303
|
+
shim = shims[modelName] = new ShimModelClass(store, modelName);
|
|
304
|
+
}
|
|
305
|
+
return shim;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Mimics the static apis of @ember-data/model
|
|
309
|
+
class ShimModelClass {
|
|
310
|
+
constructor(store, modelName) {
|
|
311
|
+
this.__store = store;
|
|
312
|
+
this.modelName = modelName;
|
|
313
|
+
}
|
|
314
|
+
get fields() {
|
|
315
|
+
const fields = new Map();
|
|
316
|
+
const fieldSchemas = this.__store.schema.fields({
|
|
317
|
+
type: this.modelName
|
|
318
|
+
});
|
|
319
|
+
fieldSchemas.forEach((schema, key) => {
|
|
320
|
+
if (schema.kind === 'attribute' || schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
|
|
321
|
+
fields.set(key, schema.kind);
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
return fields;
|
|
325
|
+
}
|
|
326
|
+
get attributes() {
|
|
327
|
+
const attrs = new Map();
|
|
328
|
+
const fields = this.__store.schema.fields({
|
|
329
|
+
type: this.modelName
|
|
330
|
+
});
|
|
331
|
+
fields.forEach((schema, key) => {
|
|
332
|
+
if (schema.kind === 'attribute') {
|
|
333
|
+
attrs.set(key, schema);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
return attrs;
|
|
337
|
+
}
|
|
338
|
+
get relationshipsByName() {
|
|
339
|
+
const rels = new Map();
|
|
340
|
+
const fields = this.__store.schema.fields({
|
|
341
|
+
type: this.modelName
|
|
342
|
+
});
|
|
343
|
+
fields.forEach((schema, key) => {
|
|
344
|
+
if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
|
|
345
|
+
rels.set(key, schema);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
return rels;
|
|
349
|
+
}
|
|
350
|
+
eachAttribute(callback, binding) {
|
|
351
|
+
this.__store.schema.fields({
|
|
352
|
+
type: this.modelName
|
|
353
|
+
}).forEach((schema, key) => {
|
|
354
|
+
if (schema.kind === 'attribute') {
|
|
355
|
+
callback.call(binding, key, schema);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
eachRelationship(callback, binding) {
|
|
360
|
+
this.__store.schema.fields({
|
|
361
|
+
type: this.modelName
|
|
362
|
+
}).forEach((schema, key) => {
|
|
363
|
+
if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {
|
|
364
|
+
callback.call(binding, key, schema);
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
eachTransformedAttribute(callback, binding) {
|
|
369
|
+
this.__store.schema.fields({
|
|
370
|
+
type: this.modelName
|
|
371
|
+
}).forEach((schema, key) => {
|
|
372
|
+
if (schema.kind === 'attribute') {
|
|
373
|
+
const type = schema.type;
|
|
374
|
+
if (type) callback.call(binding, key, type);
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
function restoreDeprecatedStoreBehaviors(StoreKlass) {
|
|
380
|
+
StoreKlass.prototype.findRecord = function (resource, id, options) {
|
|
381
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
382
|
+
if (!test) {
|
|
383
|
+
throw new Error(`Attempted to call store.findRecord(), but the store instance has already been destroyed.`);
|
|
384
|
+
}
|
|
385
|
+
})(!(this.isDestroying || this.isDestroyed)) : {};
|
|
386
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
387
|
+
if (!test) {
|
|
388
|
+
throw new Error(`You need to pass a modelName or resource identifier as the first argument to the store's findRecord method`);
|
|
389
|
+
}
|
|
390
|
+
})(resource) : {};
|
|
391
|
+
if (isMaybeIdentifier(resource)) {
|
|
392
|
+
options = id;
|
|
393
|
+
} else {
|
|
394
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
395
|
+
if (!test) {
|
|
396
|
+
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${resource}`);
|
|
397
|
+
}
|
|
398
|
+
})(typeof resource === 'string') : {};
|
|
399
|
+
const type = normalizeModelName(resource);
|
|
400
|
+
const normalizedId = ensureStringId(id);
|
|
401
|
+
resource = constructResource(type, normalizedId);
|
|
402
|
+
}
|
|
403
|
+
const identifier = this.cacheKeyManager.getOrCreateRecordIdentifier(resource);
|
|
404
|
+
options = options || {};
|
|
405
|
+
assertPrivateStore(this);
|
|
406
|
+
if (options.preload) {
|
|
407
|
+
// force reload if we preload to ensure we don't resolve the promise
|
|
408
|
+
// until we are complete, else we will end up background-reloading
|
|
409
|
+
// even for initial load.
|
|
410
|
+
if (!this._instanceCache.recordIsLoaded(identifier)) {
|
|
411
|
+
options.reload = true;
|
|
412
|
+
}
|
|
413
|
+
this._join(() => {
|
|
414
|
+
preloadData(this, identifier, options.preload);
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
const promise = this.request({
|
|
418
|
+
op: 'findRecord',
|
|
419
|
+
data: {
|
|
420
|
+
record: identifier,
|
|
421
|
+
options
|
|
422
|
+
},
|
|
423
|
+
cacheOptions: {
|
|
424
|
+
[SkipCache]: true
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
return promise.then(document => {
|
|
428
|
+
return document.content;
|
|
429
|
+
});
|
|
430
|
+
};
|
|
431
|
+
StoreKlass.prototype.findAll = function (type, options = {}) {
|
|
432
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
433
|
+
if (!test) {
|
|
434
|
+
throw new Error(`Attempted to call store.findAll(), but the store instance has already been destroyed.`);
|
|
435
|
+
}
|
|
436
|
+
})(!(this.isDestroying || this.isDestroyed)) : {};
|
|
437
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
438
|
+
if (!test) {
|
|
439
|
+
throw new Error(`You need to pass a model name to the store's findAll method`);
|
|
440
|
+
}
|
|
441
|
+
})(type) : {};
|
|
442
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
443
|
+
if (!test) {
|
|
444
|
+
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
445
|
+
}
|
|
446
|
+
})(typeof type === 'string') : {};
|
|
447
|
+
const promise = this.request({
|
|
448
|
+
op: 'findAll',
|
|
449
|
+
data: {
|
|
450
|
+
type: normalizeModelName(type),
|
|
451
|
+
options: options || {}
|
|
452
|
+
},
|
|
453
|
+
cacheOptions: {
|
|
454
|
+
[SkipCache]: true
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
return promise.then(document => document.content);
|
|
458
|
+
};
|
|
459
|
+
StoreKlass.prototype.query = function (type, query, options = {}) {
|
|
460
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
461
|
+
if (!test) {
|
|
462
|
+
throw new Error(`Attempted to call store.query(), but the store instance has already been destroyed.`);
|
|
463
|
+
}
|
|
464
|
+
})(!(this.isDestroying || this.isDestroyed)) : {};
|
|
465
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
466
|
+
if (!test) {
|
|
467
|
+
throw new Error(`You need to pass a model name to the store's query method`);
|
|
468
|
+
}
|
|
469
|
+
})(type) : {};
|
|
470
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
471
|
+
if (!test) {
|
|
472
|
+
throw new Error(`You need to pass a query hash to the store's query method`);
|
|
473
|
+
}
|
|
474
|
+
})(query) : {};
|
|
475
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
476
|
+
if (!test) {
|
|
477
|
+
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
478
|
+
}
|
|
479
|
+
})(typeof type === 'string') : {};
|
|
480
|
+
const promise = this.request({
|
|
481
|
+
op: 'query',
|
|
482
|
+
data: {
|
|
483
|
+
type: normalizeModelName(type),
|
|
484
|
+
query,
|
|
485
|
+
options: options
|
|
486
|
+
},
|
|
487
|
+
cacheOptions: {
|
|
488
|
+
[SkipCache]: true
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
return promise.then(document => document.content);
|
|
492
|
+
};
|
|
493
|
+
StoreKlass.prototype.queryRecord = function (type, query, options) {
|
|
494
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
495
|
+
if (!test) {
|
|
496
|
+
throw new Error(`Attempted to call store.queryRecord(), but the store instance has already been destroyed.`);
|
|
497
|
+
}
|
|
498
|
+
})(!(this.isDestroying || this.isDestroyed)) : {};
|
|
499
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
500
|
+
if (!test) {
|
|
501
|
+
throw new Error(`You need to pass a model name to the store's queryRecord method`);
|
|
502
|
+
}
|
|
503
|
+
})(type) : {};
|
|
504
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
505
|
+
if (!test) {
|
|
506
|
+
throw new Error(`You need to pass a query hash to the store's queryRecord method`);
|
|
507
|
+
}
|
|
508
|
+
})(query) : {};
|
|
509
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
510
|
+
if (!test) {
|
|
511
|
+
throw new Error(`Passing classes to store methods has been removed. Please pass a dasherized string instead of ${type}`);
|
|
512
|
+
}
|
|
513
|
+
})(typeof type === 'string') : {};
|
|
514
|
+
const promise = this.request({
|
|
515
|
+
op: 'queryRecord',
|
|
516
|
+
data: {
|
|
517
|
+
type: normalizeModelName(type),
|
|
518
|
+
query,
|
|
519
|
+
options: options || {}
|
|
520
|
+
},
|
|
521
|
+
cacheOptions: {
|
|
522
|
+
[SkipCache]: true
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
return promise.then(document => document.content);
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
// do not put a ts-expect-error here, because typedoc will fail to
|
|
529
|
+
// build due to this error only occurring when references are in use in the editor
|
|
530
|
+
StoreKlass.prototype.getReference = function (resource, id) {
|
|
531
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
532
|
+
if (!test) {
|
|
533
|
+
throw new Error(`Attempted to call store.getReference(), but the store instance has already been destroyed.`);
|
|
534
|
+
}
|
|
535
|
+
})(!(this.isDestroying || this.isDestroyed)) : {};
|
|
536
|
+
let resourceIdentifier;
|
|
537
|
+
if (arguments.length === 1 && isMaybeIdentifier(resource)) {
|
|
538
|
+
resourceIdentifier = resource;
|
|
539
|
+
} else {
|
|
540
|
+
const type = normalizeModelName(resource);
|
|
541
|
+
const normalizedId = ensureStringId(id);
|
|
542
|
+
resourceIdentifier = constructResource(type, normalizedId);
|
|
543
|
+
}
|
|
544
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
545
|
+
if (!test) {
|
|
546
|
+
throw new Error('getReference expected to receive either a resource identifier or type and id as arguments');
|
|
547
|
+
}
|
|
548
|
+
})(isMaybeIdentifier(resourceIdentifier)) : {};
|
|
549
|
+
const identifier = this.cacheKeyManager.getOrCreateRecordIdentifier(resourceIdentifier);
|
|
550
|
+
assertPrivateStore(this);
|
|
551
|
+
const cache = upgradeInstanceCaches(this._instanceCache.__instances).reference;
|
|
552
|
+
let reference = cache.get(identifier);
|
|
553
|
+
if (!reference) {
|
|
554
|
+
reference = new RecordReference(this, identifier);
|
|
555
|
+
cache.set(identifier, reference);
|
|
556
|
+
}
|
|
557
|
+
return reference;
|
|
558
|
+
};
|
|
559
|
+
StoreKlass.prototype.modelFor = function (type) {
|
|
560
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
561
|
+
if (!test) {
|
|
562
|
+
throw new Error(`Attempted to call store.modelFor(), but the store instance has already been destroyed.`);
|
|
563
|
+
}
|
|
564
|
+
})(!this.isDestroyed) : {};
|
|
565
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
566
|
+
if (!test) {
|
|
567
|
+
throw new Error(`You need to pass <type> to the store's modelFor method`);
|
|
568
|
+
}
|
|
569
|
+
})(typeof type === 'string' && type.length) : {};
|
|
570
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
571
|
+
if (!test) {
|
|
572
|
+
throw new Error(`No model was found for '${type}' and no schema handles the type`);
|
|
573
|
+
}
|
|
574
|
+
})(this.schema.hasResource({
|
|
575
|
+
type
|
|
576
|
+
})) : {};
|
|
577
|
+
return getShimClass(this, type);
|
|
578
|
+
};
|
|
579
|
+
StoreKlass.prototype.saveRecord = function (record, options = {}) {
|
|
580
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
581
|
+
if (!test) {
|
|
582
|
+
throw new Error(`Attempted to call store.saveRecord(), but the store instance has already been destroyed.`);
|
|
583
|
+
}
|
|
584
|
+
})(!(this.isDestroying || this.isDestroyed)) : {};
|
|
585
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
586
|
+
if (!test) {
|
|
587
|
+
throw new Error(`Unable to initiate save for a record in a disconnected state`);
|
|
588
|
+
}
|
|
589
|
+
})(storeFor(record, true)) : {};
|
|
590
|
+
const identifier = recordIdentifierFor(record);
|
|
591
|
+
const cache = this.cache;
|
|
592
|
+
if (!identifier) {
|
|
593
|
+
// this commonly means we're disconnected
|
|
594
|
+
// but just in case we reject here to prevent bad things.
|
|
595
|
+
return Promise.reject(new Error(`Record Is Disconnected`));
|
|
596
|
+
}
|
|
597
|
+
assertPrivateStore(this);
|
|
598
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
599
|
+
if (!test) {
|
|
600
|
+
throw new Error(`Cannot initiate a save request for an unloaded record: ${identifier.lid}`);
|
|
601
|
+
}
|
|
602
|
+
})(this._instanceCache.recordIsLoaded(identifier)) : {};
|
|
603
|
+
if (resourceIsFullyDeleted(this._instanceCache, identifier)) {
|
|
604
|
+
return Promise.resolve(record);
|
|
605
|
+
}
|
|
606
|
+
if (!options) {
|
|
607
|
+
options = {};
|
|
608
|
+
}
|
|
609
|
+
let operation = 'updateRecord';
|
|
610
|
+
if (cache.isNew(identifier)) {
|
|
611
|
+
operation = 'createRecord';
|
|
612
|
+
} else if (cache.isDeleted(identifier)) {
|
|
613
|
+
operation = 'deleteRecord';
|
|
614
|
+
}
|
|
615
|
+
const request = {
|
|
616
|
+
op: operation,
|
|
617
|
+
data: {
|
|
618
|
+
options,
|
|
619
|
+
record: identifier
|
|
620
|
+
},
|
|
621
|
+
records: [identifier],
|
|
622
|
+
cacheOptions: {
|
|
623
|
+
[SkipCache]: true
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
return this.request(request).then(document => document.content);
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
function upgradeInstanceCaches(cache) {
|
|
630
|
+
const withReferences = cache;
|
|
631
|
+
if (!withReferences.reference) {
|
|
632
|
+
withReferences.reference = new WeakMap();
|
|
633
|
+
}
|
|
634
|
+
return withReferences;
|
|
635
|
+
}
|
|
636
|
+
export { restoreDeprecatedStoreBehaviors };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { deprecate } from '@ember/debug';
|
|
2
|
+
import { dasherize } from '@warp-drive/utilities/string';
|
|
3
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
|
+
function isElementDescriptor(args) {
|
|
5
|
+
const [maybeTarget, maybeKey, maybeDesc] = args;
|
|
6
|
+
return (
|
|
7
|
+
// Ensure we have the right number of args
|
|
8
|
+
args.length === 3 && (
|
|
9
|
+
// Make sure the target is a class or object (prototype)
|
|
10
|
+
typeof maybeTarget === 'function' || typeof maybeTarget === 'object' && maybeTarget !== null) &&
|
|
11
|
+
// Make sure the key is a string
|
|
12
|
+
typeof maybeKey === 'string' && (
|
|
13
|
+
// Make sure the descriptor is the right shape
|
|
14
|
+
typeof maybeDesc === 'object' && maybeDesc !== null && 'enumerable' in maybeDesc && 'configurable' in maybeDesc ||
|
|
15
|
+
// TS compatibility
|
|
16
|
+
maybeDesc === undefined)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
function normalizeModelName(type) {
|
|
20
|
+
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_NON_STRICT_TYPES)) {
|
|
21
|
+
const result = dasherize(type);
|
|
22
|
+
deprecate(`The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`, result === type, {
|
|
23
|
+
id: 'ember-data:deprecate-non-strict-types',
|
|
24
|
+
until: '6.0',
|
|
25
|
+
for: 'ember-data',
|
|
26
|
+
since: {
|
|
27
|
+
available: '4.13',
|
|
28
|
+
enabled: '5.3'
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
return type;
|
|
34
|
+
}
|
|
35
|
+
export { isElementDescriptor as i, normalizeModelName as n };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { deprecate } from '@ember/debug';
|
|
2
|
+
import { dasherize } from '@warp-drive/utilities/string';
|
|
3
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
|
+
function isMaybeIdentifier(maybeIdentifier) {
|
|
5
|
+
return Boolean(maybeIdentifier !== null && typeof maybeIdentifier === 'object' && ('id' in maybeIdentifier && 'type' in maybeIdentifier && maybeIdentifier.id && maybeIdentifier.type || maybeIdentifier.lid));
|
|
6
|
+
}
|
|
7
|
+
function normalizeModelName(type) {
|
|
8
|
+
if (macroCondition(getGlobalConfig().WarpDrive.deprecations.DEPRECATE_NON_STRICT_TYPES)) {
|
|
9
|
+
const result = dasherize(type);
|
|
10
|
+
deprecate(`The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`, result === type, {
|
|
11
|
+
id: 'ember-data:deprecate-non-strict-types',
|
|
12
|
+
until: '6.0',
|
|
13
|
+
for: 'ember-data',
|
|
14
|
+
since: {
|
|
15
|
+
available: '4.13',
|
|
16
|
+
enabled: '5.3'
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
return type;
|
|
22
|
+
}
|
|
23
|
+
export { isMaybeIdentifier as i, normalizeModelName as n };
|