@warp-drive/legacy 5.8.0-alpha.3 → 5.8.0-alpha.32
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/README.md +14 -27
- package/declarations/adapter/error.d.ts +5 -5
- package/declarations/adapter/json-api.d.ts +6 -8
- package/declarations/adapter/rest.d.ts +5 -8
- package/declarations/adapter.d.ts +4 -6
- package/declarations/compat/-private.d.ts +1 -1
- 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/extensions.d.ts +1 -1
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +7 -9
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +20 -30
- package/declarations/compat/utils.d.ts +17 -17
- package/declarations/compat.d.ts +35 -11
- package/declarations/index.d.ts +70 -0
- package/declarations/model/-private/attr.d.ts +5 -6
- package/declarations/model/-private/belongs-to.d.ts +4 -5
- package/declarations/model/-private/has-many.d.ts +4 -5
- package/declarations/model/-private/hooks.d.ts +1 -1
- package/declarations/model/-private/legacy-relationships-support.d.ts +2 -2
- package/declarations/model/-private/model.d.ts +8 -8
- package/declarations/model/-private/record-state.d.ts +1 -1
- package/declarations/model/-private/references/belongs-to.d.ts +5 -5
- package/declarations/model/-private/references/has-many.d.ts +3 -3
- package/declarations/model/migration-support.d.ts +46 -21
- package/declarations/model-fragments/extensions/fragment-array.d.ts +16 -0
- package/declarations/model-fragments/extensions/fragment.d.ts +15 -0
- package/declarations/model-fragments/hooks/model-for.d.ts +20 -0
- package/declarations/model-fragments/index.d.ts +5 -0
- package/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +9 -0
- package/declarations/model-fragments/utilities/with-array-defaults.d.ts +15 -0
- package/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +20 -0
- package/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +19 -0
- package/declarations/model-fragments/utilities/with-legacy.d.ts +3 -0
- package/declarations/model-fragments.d.ts +9 -0
- package/declarations/model.d.ts +2 -2
- package/declarations/serializer/-private/embedded-records-mixin.d.ts +1 -6
- package/declarations/serializer/-private/transforms/boolean.d.ts +2 -2
- package/declarations/serializer/-private/transforms/date.d.ts +2 -2
- package/declarations/serializer/-private/transforms/number.d.ts +1 -1
- package/declarations/serializer/-private/transforms/string.d.ts +1 -1
- package/declarations/serializer/json-api.d.ts +7 -9
- package/declarations/serializer/json.d.ts +7 -9
- package/declarations/serializer/rest.d.ts +4 -6
- package/declarations/serializer.d.ts +9 -12
- package/dist/{-private-8UmnAf9J.js → -private-B1pSSN52.js} +1 -1
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.js +12 -13
- package/dist/adapter/json-api.js +4 -1
- package/dist/adapter/rest.js +6 -9
- package/dist/adapter.js +4 -6
- package/dist/compat/-private.js +1 -1
- package/dist/compat/builders.js +26 -26
- package/dist/compat/utils.js +17 -18
- package/dist/compat.js +58 -41
- package/dist/{errors-8kD2mSe_.js → errors-CIGPcDvd.js} +87 -65
- package/dist/hooks-QqRnX108.js +74 -0
- package/dist/index.js +195 -0
- package/dist/{json-DziiodPf.js → json-BNrV8EYG.js} +12 -16
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +54 -24
- package/dist/model-for-CqXsIKws.js +221 -0
- package/dist/model-fragments.js +76 -0
- package/dist/model.js +18 -90
- package/dist/{schema-provider-DQu4Rjco.js → schema-provider-g5MfTj8n.js} +18 -20
- package/dist/{serialize-into-hash-CS0MIv4F.js → serialize-into-hash-BnYvPex3.js} +1 -1
- package/dist/serializer/json-api.js +17 -44
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.js +14 -21
- package/dist/serializer/transform.js +15 -6
- package/dist/serializer.js +9 -13
- package/dist/store.js +3 -0
- 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/logos/README.md +2 -2
- package/logos/logo-yellow-slab.svg +1 -0
- package/logos/word-mark-black.svg +1 -0
- package/logos/word-mark-white.svg +1 -0
- package/package.json +6 -6
- package/logos/NCC-1701-a-blue.svg +0 -4
- package/logos/NCC-1701-a-gold.svg +0 -4
- package/logos/NCC-1701-a-gold_100.svg +0 -1
- package/logos/NCC-1701-a-gold_base-64.txt +0 -1
- package/logos/NCC-1701-a.svg +0 -4
- package/logos/docs-badge.svg +0 -2
- package/logos/ember-data-logo-dark.svg +0 -12
- package/logos/ember-data-logo-light.svg +0 -12
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +0 -4
- package/logos/warp-drive-logo-gold.svg +0 -4
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
import { warn } from '@ember/debug';
|
|
2
|
+
import { dasherize, pluralize, singularize } from '@warp-drive/utilities/string';
|
|
3
|
+
import { J as JSONSerializer } from "../json-BNrV8EYG.js";
|
|
4
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
5
|
+
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
9
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
10
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
11
|
+
const JSONAPISerializer = JSONSerializer.extend({
|
|
12
|
+
/**
|
|
13
|
+
@private
|
|
14
|
+
*/
|
|
15
|
+
_normalizeDocumentHelper(documentHash) {
|
|
16
|
+
if (Array.isArray(documentHash.data)) {
|
|
17
|
+
const ret = new Array(documentHash.data.length);
|
|
18
|
+
for (let i = 0; i < documentHash.data.length; i++) {
|
|
19
|
+
const data = documentHash.data[i];
|
|
20
|
+
ret[i] = this._normalizeResourceHelper(data);
|
|
21
|
+
}
|
|
22
|
+
documentHash.data = ret;
|
|
23
|
+
} else if (documentHash.data && typeof documentHash.data === 'object') {
|
|
24
|
+
documentHash.data = this._normalizeResourceHelper(documentHash.data);
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(documentHash.included)) {
|
|
27
|
+
const ret = [];
|
|
28
|
+
for (let i = 0; i < documentHash.included.length; i++) {
|
|
29
|
+
const included = documentHash.included[i];
|
|
30
|
+
const normalized = this._normalizeResourceHelper(included);
|
|
31
|
+
if (normalized !== null) {
|
|
32
|
+
// @ts-expect-error untyped
|
|
33
|
+
// can be null when unknown type is encountered
|
|
34
|
+
ret.push(normalized);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
documentHash.included = ret;
|
|
38
|
+
}
|
|
39
|
+
return documentHash;
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
@private
|
|
43
|
+
*/
|
|
44
|
+
_normalizeRelationshipDataHelper(relationshipDataHash) {
|
|
45
|
+
relationshipDataHash.type = this.modelNameFromPayloadKey(relationshipDataHash.type);
|
|
46
|
+
return relationshipDataHash;
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
@private
|
|
50
|
+
*/
|
|
51
|
+
_normalizeResourceHelper(resourceHash) {
|
|
52
|
+
// @ts-expect-error untyped
|
|
53
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
54
|
+
if (!test) {
|
|
55
|
+
throw new Error(this.warnMessageForUndefinedType());
|
|
56
|
+
}
|
|
57
|
+
})(resourceHash.type) : {};
|
|
58
|
+
const type = this.modelNameFromPayloadKey(resourceHash.type);
|
|
59
|
+
|
|
60
|
+
// @ts-expect-error store is dynamically added
|
|
61
|
+
if (!this.store.schema.hasResource({
|
|
62
|
+
type
|
|
63
|
+
})) {
|
|
64
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
65
|
+
// @ts-expect-error untyped
|
|
66
|
+
warn(this.warnMessageNoModelForType(type, resourceHash.type, 'modelNameFromPayloadKey'), false, {
|
|
67
|
+
id: 'ds.serializer.model-for-type-missing'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// @ts-expect-error store is dynamically added
|
|
74
|
+
const modelClass = this.store.modelFor(type);
|
|
75
|
+
// @ts-expect-error store is dynamically added
|
|
76
|
+
const serializer = this.store.serializerFor(type);
|
|
77
|
+
const {
|
|
78
|
+
data
|
|
79
|
+
} = serializer.normalize(modelClass, resourceHash);
|
|
80
|
+
return data;
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
Normalize some data and push it into the store.
|
|
84
|
+
@public
|
|
85
|
+
*/
|
|
86
|
+
pushPayload(store, payload) {
|
|
87
|
+
const normalizedPayload = this._normalizeDocumentHelper(payload);
|
|
88
|
+
store.push(normalizedPayload);
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
@return A {json:api} Document
|
|
92
|
+
@private
|
|
93
|
+
*/
|
|
94
|
+
_normalizeResponse(store, primaryModelClass, payload, id, requestType, isSingle) {
|
|
95
|
+
const normalizedPayload = this._normalizeDocumentHelper(payload);
|
|
96
|
+
return normalizedPayload;
|
|
97
|
+
},
|
|
98
|
+
normalizeQueryRecordResponse() {
|
|
99
|
+
// @ts-expect-error untyped
|
|
100
|
+
const normalized = this._super(...arguments);
|
|
101
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
102
|
+
if (!test) {
|
|
103
|
+
throw new Error('Expected the primary data returned by the serializer for a `queryRecord` response to be a single object but instead it was an array.');
|
|
104
|
+
}
|
|
105
|
+
})(!Array.isArray(normalized.data)) : {};
|
|
106
|
+
return normalized;
|
|
107
|
+
},
|
|
108
|
+
extractAttributes(modelClass, resourceHash) {
|
|
109
|
+
const attributes = {};
|
|
110
|
+
if (resourceHash.attributes) {
|
|
111
|
+
modelClass.eachAttribute(key => {
|
|
112
|
+
const attributeKey = this.keyForAttribute(key, 'deserialize');
|
|
113
|
+
if (resourceHash.attributes[attributeKey] !== undefined) {
|
|
114
|
+
attributes[key] = resourceHash.attributes[attributeKey];
|
|
115
|
+
}
|
|
116
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
117
|
+
if (resourceHash.attributes[attributeKey] === undefined && resourceHash.attributes[key] !== undefined) {
|
|
118
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
119
|
+
{
|
|
120
|
+
throw new Error(`Your payload for '${modelClass.modelName}' contains '${key}', but your serializer is setup to look for '${attributeKey}'. This is most likely because Ember Data's JSON API serializer dasherizes attribute keys by default. You should subclass JSONAPISerializer and implement 'keyForAttribute(key) { return key; }' to prevent Ember Data from customizing your attribute keys.`);
|
|
121
|
+
}
|
|
122
|
+
})() : {};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return attributes;
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
Returns a relationship formatted as a JSON-API "relationship object".
|
|
131
|
+
http://jsonapi.org/format/#document-resource-object-relationships
|
|
132
|
+
@public
|
|
133
|
+
*/
|
|
134
|
+
extractRelationship(relationshipHash) {
|
|
135
|
+
if (Array.isArray(relationshipHash.data)) {
|
|
136
|
+
const ret = new Array(relationshipHash.data.length);
|
|
137
|
+
for (let i = 0; i < relationshipHash.data.length; i++) {
|
|
138
|
+
const data = relationshipHash.data[i];
|
|
139
|
+
ret[i] = this._normalizeRelationshipDataHelper(data);
|
|
140
|
+
}
|
|
141
|
+
relationshipHash.data = ret;
|
|
142
|
+
} else if (relationshipHash.data && typeof relationshipHash.data === 'object') {
|
|
143
|
+
relationshipHash.data = this._normalizeRelationshipDataHelper(relationshipHash.data);
|
|
144
|
+
}
|
|
145
|
+
return relationshipHash;
|
|
146
|
+
},
|
|
147
|
+
/**
|
|
148
|
+
Returns the resource's relationships formatted as a JSON-API "relationships object".
|
|
149
|
+
http://jsonapi.org/format/#document-resource-object-relationships
|
|
150
|
+
@public
|
|
151
|
+
*/
|
|
152
|
+
extractRelationships(modelClass, resourceHash) {
|
|
153
|
+
const relationships = {};
|
|
154
|
+
if (resourceHash.relationships) {
|
|
155
|
+
modelClass.eachRelationship((key, relationshipMeta) => {
|
|
156
|
+
const relationshipKey = this.keyForRelationship(key, relationshipMeta.kind, 'deserialize');
|
|
157
|
+
if (resourceHash.relationships[relationshipKey] !== undefined) {
|
|
158
|
+
const relationshipHash = resourceHash.relationships[relationshipKey];
|
|
159
|
+
relationships[key] = this.extractRelationship(relationshipHash);
|
|
160
|
+
}
|
|
161
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
162
|
+
if (resourceHash.relationships[relationshipKey] === undefined && resourceHash.relationships[key] !== undefined) {
|
|
163
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
164
|
+
{
|
|
165
|
+
throw new Error(`Your payload for '${modelClass.modelName}' contains '${key}', but your serializer is setup to look for '${relationshipKey}'. This is most likely because Ember Data's JSON API serializer dasherizes relationship keys by default. You should subclass JSONAPISerializer and implement 'keyForRelationship(key) { return key; }' to prevent Ember Data from customizing your relationship keys.`);
|
|
166
|
+
}
|
|
167
|
+
})() : {};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return relationships;
|
|
173
|
+
},
|
|
174
|
+
/**
|
|
175
|
+
@private
|
|
176
|
+
*/
|
|
177
|
+
_extractType(modelClass, resourceHash) {
|
|
178
|
+
return this.modelNameFromPayloadKey(resourceHash.type);
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
Dasherizes and singularizes the model name in the payload to match
|
|
182
|
+
the format Ember Data uses internally for the model name.
|
|
183
|
+
For example the key `posts` would be converted to `post` and the
|
|
184
|
+
key `studentAssesments` would be converted to `student-assesment`.
|
|
185
|
+
@public
|
|
186
|
+
@return the model's modelName
|
|
187
|
+
*/
|
|
188
|
+
modelNameFromPayloadKey(key) {
|
|
189
|
+
return dasherize(singularize(key));
|
|
190
|
+
},
|
|
191
|
+
/**
|
|
192
|
+
Converts the model name to a pluralized version of the model name.
|
|
193
|
+
For example `post` would be converted to `posts` and
|
|
194
|
+
`student-assesment` would be converted to `student-assesments`.
|
|
195
|
+
@public
|
|
196
|
+
*/
|
|
197
|
+
payloadKeyFromModelName(modelName) {
|
|
198
|
+
return pluralize(modelName);
|
|
199
|
+
},
|
|
200
|
+
normalize(modelClass, resourceHash) {
|
|
201
|
+
if (resourceHash.attributes) {
|
|
202
|
+
// @ts-expect-error untyped
|
|
203
|
+
this.normalizeUsingDeclaredMapping(modelClass, resourceHash.attributes);
|
|
204
|
+
}
|
|
205
|
+
if (resourceHash.relationships) {
|
|
206
|
+
// @ts-expect-error untyped
|
|
207
|
+
this.normalizeUsingDeclaredMapping(modelClass, resourceHash.relationships);
|
|
208
|
+
}
|
|
209
|
+
const data = {
|
|
210
|
+
// @ts-expect-error untyped
|
|
211
|
+
id: this.extractId(modelClass, resourceHash),
|
|
212
|
+
type: this._extractType(modelClass, resourceHash),
|
|
213
|
+
attributes: this.extractAttributes(modelClass, resourceHash),
|
|
214
|
+
relationships: this.extractRelationships(modelClass, resourceHash)
|
|
215
|
+
};
|
|
216
|
+
if (resourceHash.lid) {
|
|
217
|
+
// @ts-expect-error untyped
|
|
218
|
+
data.lid = resourceHash.lid;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// @ts-expect-error untyped
|
|
222
|
+
this.applyTransforms(modelClass, data.attributes);
|
|
223
|
+
return {
|
|
224
|
+
data
|
|
225
|
+
};
|
|
226
|
+
},
|
|
227
|
+
/**
|
|
228
|
+
`keyForAttribute` can be used to define rules for how to convert an
|
|
229
|
+
attribute name in your model to a key in your JSON.
|
|
230
|
+
By default `JSONAPISerializer` follows the format used on the examples of
|
|
231
|
+
http://jsonapi.org/format and uses dashes as the word separator in the JSON
|
|
232
|
+
attribute keys.
|
|
233
|
+
This behaviour can be easily customized by extending this method.
|
|
234
|
+
Example
|
|
235
|
+
```js [app/serializers/application.js]
|
|
236
|
+
import JSONAPISerializer from '@warp-drive/legacy/serializer/json-api';
|
|
237
|
+
import { dasherize } from '<app-name>/utils/string-utils';
|
|
238
|
+
export default class ApplicationSerializer extends JSONAPISerializer {
|
|
239
|
+
keyForAttribute(attr, method) {
|
|
240
|
+
return dasherize(attr).toUpperCase();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
@public
|
|
245
|
+
@return normalized key
|
|
246
|
+
*/
|
|
247
|
+
keyForAttribute(key, method) {
|
|
248
|
+
return dasherize(key);
|
|
249
|
+
},
|
|
250
|
+
/**
|
|
251
|
+
`keyForRelationship` can be used to define a custom key when
|
|
252
|
+
serializing and deserializing relationship properties.
|
|
253
|
+
By default `JSONAPISerializer` follows the format used on the examples of
|
|
254
|
+
http://jsonapi.org/format and uses dashes as word separators in
|
|
255
|
+
relationship properties.
|
|
256
|
+
This behaviour can be easily customized by extending this method.
|
|
257
|
+
Example
|
|
258
|
+
```js [app/serializers/post.js]
|
|
259
|
+
import JSONAPISerializer from '@warp-drive/legacy/serializer/json-api';
|
|
260
|
+
import { underscore } from '<app-name>/utils/string-utils';
|
|
261
|
+
export default class ApplicationSerializer extends JSONAPISerializer {
|
|
262
|
+
keyForRelationship(key, relationship, method) {
|
|
263
|
+
return underscore(key);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
@public
|
|
268
|
+
@return the normalized key
|
|
269
|
+
*/
|
|
270
|
+
keyForRelationship(key, typeClass, method) {
|
|
271
|
+
return dasherize(key);
|
|
272
|
+
},
|
|
273
|
+
/**
|
|
274
|
+
Called when a record is saved in order to convert the
|
|
275
|
+
record into JSON.
|
|
276
|
+
For example, consider this model:
|
|
277
|
+
```js [app/models/comment.js]
|
|
278
|
+
import Model, { attr, belongsTo } from '@warp-drive/legacy/model';
|
|
279
|
+
export default class CommentModel extends Model {
|
|
280
|
+
@attr title;
|
|
281
|
+
@attr body;
|
|
282
|
+
@belongsTo('user', { async: false, inverse: null })
|
|
283
|
+
author;
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
The default serialization would create a JSON-API resource object like:
|
|
287
|
+
```javascript
|
|
288
|
+
{
|
|
289
|
+
"data": {
|
|
290
|
+
"type": "comments",
|
|
291
|
+
"attributes": {
|
|
292
|
+
"title": "Rails is unagi",
|
|
293
|
+
"body": "Rails? Omakase? O_O",
|
|
294
|
+
},
|
|
295
|
+
"relationships": {
|
|
296
|
+
"author": {
|
|
297
|
+
"data": {
|
|
298
|
+
"id": "12",
|
|
299
|
+
"type": "users"
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
By default, attributes are passed through as-is, unless
|
|
307
|
+
you specified an attribute type (`attr('date')`). If
|
|
308
|
+
you specify a transform, the JavaScript value will be
|
|
309
|
+
serialized when inserted into the attributes hash.
|
|
310
|
+
Belongs-to relationships are converted into JSON-API
|
|
311
|
+
resource identifier objects.
|
|
312
|
+
## IDs
|
|
313
|
+
`serialize` takes an options hash with a single option:
|
|
314
|
+
`includeId`. If this option is `true`, `serialize` will,
|
|
315
|
+
by default include the ID in the JSON object it builds.
|
|
316
|
+
The JSONAPIAdapter passes in `includeId: true` when serializing a record
|
|
317
|
+
for `createRecord` or `updateRecord`.
|
|
318
|
+
## Customization
|
|
319
|
+
Your server may expect data in a different format than the
|
|
320
|
+
built-in serialization format.
|
|
321
|
+
In that case, you can implement `serialize` yourself and
|
|
322
|
+
return data formatted to match your API's expectations, or override
|
|
323
|
+
the invoked adapter method and do the serialization in the adapter directly
|
|
324
|
+
by using the provided snapshot.
|
|
325
|
+
If your API's format differs greatly from the JSON:API spec, you should
|
|
326
|
+
consider authoring your own adapter and serializer instead of extending
|
|
327
|
+
this class.
|
|
328
|
+
```js [app/serializers/post.js]
|
|
329
|
+
import JSONAPISerializer from '@warp-drive/legacy/serializer/json-api';
|
|
330
|
+
export default class PostSerializer extends JSONAPISerializer {
|
|
331
|
+
serialize(snapshot, options) {
|
|
332
|
+
let json = {
|
|
333
|
+
POST_TTL: snapshot.attr('title'),
|
|
334
|
+
POST_BDY: snapshot.attr('body'),
|
|
335
|
+
POST_CMS: snapshot.hasMany('comments', { ids: true })
|
|
336
|
+
};
|
|
337
|
+
if (options.includeId) {
|
|
338
|
+
json.POST_ID_ = snapshot.id;
|
|
339
|
+
}
|
|
340
|
+
return json;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
## Customizing an App-Wide Serializer
|
|
345
|
+
If you want to define a serializer for your entire
|
|
346
|
+
application, you'll probably want to use `eachAttribute`
|
|
347
|
+
and `eachRelationship` on the record.
|
|
348
|
+
```js [app/serializers/application.js]
|
|
349
|
+
import JSONAPISerializer from '@warp-drive/legacy/serializer/json-api';
|
|
350
|
+
import { underscore, singularize } from '<app-name>/utils/string-utils';
|
|
351
|
+
export default class ApplicationSerializer extends JSONAPISerializer {
|
|
352
|
+
serialize(snapshot, options) {
|
|
353
|
+
let json = {};
|
|
354
|
+
snapshot.eachAttribute((name) => {
|
|
355
|
+
json[serverAttributeName(name)] = snapshot.attr(name);
|
|
356
|
+
});
|
|
357
|
+
snapshot.eachRelationship((name, relationship) => {
|
|
358
|
+
if (relationship.kind === 'hasMany') {
|
|
359
|
+
json[serverHasManyName(name)] = snapshot.hasMany(name, { ids: true });
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
if (options.includeId) {
|
|
363
|
+
json.ID_ = snapshot.id;
|
|
364
|
+
}
|
|
365
|
+
return json;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function serverAttributeName(attribute) {
|
|
369
|
+
return underscore(attribute).toUpperCase();
|
|
370
|
+
}
|
|
371
|
+
function serverHasManyName(name) {
|
|
372
|
+
return serverAttributeName(singularize(name)) + '_IDS';
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
This serializer will generate JSON that looks like this:
|
|
376
|
+
```javascript
|
|
377
|
+
{
|
|
378
|
+
"TITLE": "Rails is omakase",
|
|
379
|
+
"BODY": "Yep. Omakase.",
|
|
380
|
+
"COMMENT_IDS": [ "1", "2", "3" ]
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
## Tweaking the Default Formatting
|
|
384
|
+
If you just want to do some small tweaks on the default JSON:API formatted response,
|
|
385
|
+
you can call `super.serialize` first and make the tweaks
|
|
386
|
+
on the returned object.
|
|
387
|
+
```js [app/serializers/post.js]
|
|
388
|
+
import JSONAPISerializer from '@warp-drive/legacy/serializer/json-api';
|
|
389
|
+
export default class PostSerializer extends JSONAPISerializer {
|
|
390
|
+
serialize(snapshot, options) {
|
|
391
|
+
let json = super.serialize(...arguments);
|
|
392
|
+
json.data.attributes.subject = json.data.attributes.title;
|
|
393
|
+
delete json.data.attributes.title;
|
|
394
|
+
return json;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
@public
|
|
399
|
+
*/
|
|
400
|
+
serialize(snapshot, options) {
|
|
401
|
+
// @ts-expect-error untyped
|
|
402
|
+
const data = this._super(...arguments);
|
|
403
|
+
data.type = this.payloadKeyFromModelName(snapshot.modelName);
|
|
404
|
+
return {
|
|
405
|
+
data
|
|
406
|
+
};
|
|
407
|
+
},
|
|
408
|
+
serializeAttribute(snapshot, json, key, attribute) {
|
|
409
|
+
const type = attribute.type;
|
|
410
|
+
|
|
411
|
+
// @ts-expect-error untyped
|
|
412
|
+
if (this._canSerialize(key)) {
|
|
413
|
+
json.attributes = json.attributes || {};
|
|
414
|
+
let value = snapshot.attr(key);
|
|
415
|
+
if (type) {
|
|
416
|
+
// @ts-expect-error untyped
|
|
417
|
+
const transform = this.transformFor(type);
|
|
418
|
+
value = transform.serialize(value, attribute.options);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// @ts-expect-error store is dynamically added
|
|
422
|
+
const schema = this.store.modelFor(snapshot.modelName);
|
|
423
|
+
// @ts-expect-error untyped
|
|
424
|
+
let payloadKey = this._getMappedKey(key, schema);
|
|
425
|
+
if (payloadKey === key) {
|
|
426
|
+
payloadKey = this.keyForAttribute(key, 'serialize');
|
|
427
|
+
}
|
|
428
|
+
json.attributes[payloadKey] = value;
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
serializeBelongsTo(snapshot, json, relationship) {
|
|
432
|
+
const name = relationship.name;
|
|
433
|
+
|
|
434
|
+
// @ts-expect-error untyped
|
|
435
|
+
if (this._canSerialize(name)) {
|
|
436
|
+
const belongsTo = snapshot.belongsTo(name);
|
|
437
|
+
// @ts-expect-error not narrowed
|
|
438
|
+
const belongsToIsNotNew = belongsTo && !belongsTo.isNew;
|
|
439
|
+
if (belongsTo === null || belongsToIsNotNew) {
|
|
440
|
+
json.relationships = json.relationships || {};
|
|
441
|
+
|
|
442
|
+
// @ts-expect-error store is dynamically added
|
|
443
|
+
const schema = this.store.modelFor(snapshot.modelName);
|
|
444
|
+
// @ts-expect-error untyped
|
|
445
|
+
let payloadKey = this._getMappedKey(name, schema);
|
|
446
|
+
if (payloadKey === name) {
|
|
447
|
+
payloadKey = this.keyForRelationship(name, 'belongsTo', 'serialize');
|
|
448
|
+
}
|
|
449
|
+
let data = null;
|
|
450
|
+
if (belongsTo) {
|
|
451
|
+
// @ts-expect-error not narrowed
|
|
452
|
+
const payloadType = this.payloadKeyFromModelName(belongsTo.modelName);
|
|
453
|
+
|
|
454
|
+
// @ts-expect-error untyped
|
|
455
|
+
data = {
|
|
456
|
+
type: payloadType,
|
|
457
|
+
// @ts-expect-error not narrowed
|
|
458
|
+
id: belongsTo.id
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
json.relationships[payloadKey] = {
|
|
462
|
+
data
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
serializeHasMany(snapshot, json, relationship) {
|
|
468
|
+
const name = relationship.name;
|
|
469
|
+
|
|
470
|
+
// @ts-expect-error untyped
|
|
471
|
+
if (this.shouldSerializeHasMany(snapshot, name, relationship)) {
|
|
472
|
+
const hasMany = snapshot.hasMany(name);
|
|
473
|
+
if (hasMany !== undefined) {
|
|
474
|
+
json.relationships = json.relationships || {};
|
|
475
|
+
|
|
476
|
+
// @ts-expect-error store is dynamically added
|
|
477
|
+
const schema = this.store.modelFor(snapshot.modelName);
|
|
478
|
+
// @ts-expect-error untyped
|
|
479
|
+
let payloadKey = this._getMappedKey(name, schema);
|
|
480
|
+
if (payloadKey === name && this.keyForRelationship) {
|
|
481
|
+
payloadKey = this.keyForRelationship(name, 'hasMany', 'serialize');
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// only serialize has many relationships that are not new
|
|
485
|
+
// @ts-expect-error not narrowed
|
|
486
|
+
const nonNewHasMany = hasMany.filter(item => !item.isNew);
|
|
487
|
+
const data = new Array(nonNewHasMany.length);
|
|
488
|
+
for (let i = 0; i < nonNewHasMany.length; i++) {
|
|
489
|
+
const item = hasMany[i];
|
|
490
|
+
// @ts-expect-error not narrowed
|
|
491
|
+
const payloadType = this.payloadKeyFromModelName(item.modelName);
|
|
492
|
+
data[i] = {
|
|
493
|
+
type: payloadType,
|
|
494
|
+
// @ts-expect-error not narrowed
|
|
495
|
+
id: item.id
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
json.relationships[payloadKey] = {
|
|
499
|
+
data
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
506
|
+
JSONAPISerializer.reopen({
|
|
507
|
+
init(...args) {
|
|
508
|
+
this._super(...args);
|
|
509
|
+
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
510
|
+
if (!test) {
|
|
511
|
+
throw new Error(`You've used the EmbeddedRecordsMixin in ${this.toString()} which is not fully compatible with the JSON:API specification. Please confirm that this works for your specific API and add \`this.isEmbeddedRecordsMixinCompatible = true\` to your serializer.`);
|
|
512
|
+
}
|
|
513
|
+
})(!this.isEmbeddedRecordsMixin || this.isEmbeddedRecordsMixinCompatible === true) : {};
|
|
514
|
+
const constructor = this.constructor;
|
|
515
|
+
warn(`You've defined 'extractMeta' in ${constructor.toString()} which is not used for serializers extending JSONAPISerializer. Read more at https://api.emberjs.com/ember-data/release/classes/JSONAPISerializer on how to customize meta when using JSON API.`, this.extractMeta === JSONSerializer.prototype.extractMeta, {
|
|
516
|
+
id: 'ds.serializer.json-api.extractMeta'
|
|
517
|
+
});
|
|
518
|
+
},
|
|
519
|
+
warnMessageForUndefinedType() {
|
|
520
|
+
return 'Encountered a resource object with an undefined type (resolved resource using ' + this.constructor.toString() + ')';
|
|
521
|
+
},
|
|
522
|
+
warnMessageNoModelForType(modelName, originalType, usedLookup) {
|
|
523
|
+
return `Encountered a resource object with type "${originalType}", but no model was found for model name "${modelName}" (resolved model name using '${this.constructor.toString()}.${usedLookup}("${originalType}")').`;
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
export { JSONAPISerializer };
|