@warp-drive/legacy 5.8.0-alpha.30 → 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/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 +6 -6
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
import type Mixin from "@ember/object/mixin";
|
|
2
|
+
import type Owner from "@ember/owner";
|
|
3
|
+
import type { Store } from "@warp-drive/core";
|
|
4
|
+
import type { ModelSchema } from "@warp-drive/core/types";
|
|
5
|
+
import type { HTTPMethod } from "@warp-drive/core/types/request";
|
|
6
|
+
import { Adapter } from "../adapter.js";
|
|
7
|
+
import type { AdapterPayload } from "../compat.js";
|
|
8
|
+
import type { Snapshot, SnapshotRecordArray } from "../compat/-private.js";
|
|
9
|
+
import type { MixtBuildURLMixin } from "./-private/build-url-mixin.js";
|
|
10
|
+
import type { FastBoot } from "./-private/fastboot-interface.js";
|
|
11
|
+
import { AdapterError } from "./error.js";
|
|
12
|
+
type Payload = Error | Record<string, unknown> | unknown[] | string | undefined;
|
|
13
|
+
export type QueryState = {
|
|
14
|
+
include?: unknown;
|
|
15
|
+
since?: unknown;
|
|
16
|
+
};
|
|
17
|
+
export interface FetchRequestInit extends RequestInit {
|
|
18
|
+
url: string;
|
|
19
|
+
method: HTTPMethod;
|
|
20
|
+
type: HTTPMethod;
|
|
21
|
+
}
|
|
22
|
+
export interface JQueryRequestInit extends JQueryAjaxSettings {
|
|
23
|
+
url: string;
|
|
24
|
+
method: HTTPMethod;
|
|
25
|
+
type: HTTPMethod;
|
|
26
|
+
}
|
|
27
|
+
export type RequestData = {
|
|
28
|
+
url: string;
|
|
29
|
+
method: HTTPMethod;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
};
|
|
32
|
+
declare const AdapterWithBuildURLMixin: Readonly<typeof Adapter> & (new (owner?: Owner) => Adapter) & Mixin;
|
|
33
|
+
/**
|
|
34
|
+
* :::danger
|
|
35
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
36
|
+
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
37
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
38
|
+
:::
|
|
39
|
+
|
|
40
|
+
The REST adapter allows your store to communicate with an HTTP server by
|
|
41
|
+
transmitting JSON via XHR.
|
|
42
|
+
|
|
43
|
+
This adapter is designed around the idea that the JSON exchanged with
|
|
44
|
+
the server should be conventional. It builds URLs in a manner that follows
|
|
45
|
+
the structure of most common REST-style web services.
|
|
46
|
+
|
|
47
|
+
## Success and failure
|
|
48
|
+
|
|
49
|
+
The REST adapter will consider a success any response with a status code
|
|
50
|
+
of the 2xx family ("Success"), as well as 304 ("Not Modified"). Any other
|
|
51
|
+
status code will be considered a failure.
|
|
52
|
+
|
|
53
|
+
On success, the request promise will be resolved with the full response
|
|
54
|
+
payload.
|
|
55
|
+
|
|
56
|
+
Failed responses with status code 422 ("Unprocessable Entity") will be
|
|
57
|
+
considered "invalid". The response will be discarded, except for the
|
|
58
|
+
`errors` key. The request promise will be rejected with a `InvalidError`.
|
|
59
|
+
This error object will encapsulate the saved `errors` value.
|
|
60
|
+
|
|
61
|
+
Any other status codes will be treated as an "adapter error". The request
|
|
62
|
+
promise will be rejected, similarly to the "invalid" case, but with
|
|
63
|
+
an instance of `AdapterError` instead.
|
|
64
|
+
|
|
65
|
+
## JSON Structure
|
|
66
|
+
|
|
67
|
+
The REST adapter expects the JSON returned from your server to follow
|
|
68
|
+
these conventions.
|
|
69
|
+
|
|
70
|
+
### Object Root
|
|
71
|
+
|
|
72
|
+
The JSON payload should be an object that contains the record inside a
|
|
73
|
+
root property. For example, in response to a `GET` request for
|
|
74
|
+
`/posts/1`, the JSON should look like this:
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
{
|
|
78
|
+
"posts": {
|
|
79
|
+
"id": 1,
|
|
80
|
+
"title": "I'm Running to Reform the W3C",
|
|
81
|
+
"author": "Yehuda Katz"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Similarly, in response to a `GET` request for `/posts`, the JSON should
|
|
87
|
+
look like this:
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
{
|
|
91
|
+
"posts": [
|
|
92
|
+
{
|
|
93
|
+
"id": 1,
|
|
94
|
+
"title": "I'm Running to Reform the W3C",
|
|
95
|
+
"author": "Yehuda Katz"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"id": 2,
|
|
99
|
+
"title": "Rails is omakase",
|
|
100
|
+
"author": "D2H"
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Note that the object root can be pluralized for both a single-object response
|
|
107
|
+
and an array response: the REST adapter is not strict on this. Further, if the
|
|
108
|
+
HTTP server responds to a `GET` request to `/posts/1` (e.g. the response to a
|
|
109
|
+
`findRecord` query) with more than one object in the array, Ember Data will
|
|
110
|
+
only display the object with the matching ID.
|
|
111
|
+
|
|
112
|
+
### Conventional Names
|
|
113
|
+
|
|
114
|
+
Attribute names in your JSON payload should be the camelCased versions of
|
|
115
|
+
the attributes in your Ember.js models.
|
|
116
|
+
|
|
117
|
+
For example, if you have a `Person` model:
|
|
118
|
+
|
|
119
|
+
```js [app/models/person.js]
|
|
120
|
+
import { Model, attr } from '@warp-drive/legacy/model';
|
|
121
|
+
|
|
122
|
+
export default Model.extend({
|
|
123
|
+
firstName: attr('string'),
|
|
124
|
+
lastName: attr('string'),
|
|
125
|
+
occupation: attr('string')
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The JSON returned should look like this:
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
{
|
|
133
|
+
"people": {
|
|
134
|
+
"id": 5,
|
|
135
|
+
"firstName": "Zaphod",
|
|
136
|
+
"lastName": "Beeblebrox",
|
|
137
|
+
"occupation": "President"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### Relationships
|
|
143
|
+
|
|
144
|
+
Relationships are usually represented by ids to the record in the
|
|
145
|
+
relationship. The related records can then be sideloaded in the
|
|
146
|
+
response under a key for the type.
|
|
147
|
+
|
|
148
|
+
```js
|
|
149
|
+
{
|
|
150
|
+
"posts": {
|
|
151
|
+
"id": 5,
|
|
152
|
+
"title": "I'm Running to Reform the W3C",
|
|
153
|
+
"author": "Yehuda Katz",
|
|
154
|
+
"comments": [1, 2]
|
|
155
|
+
},
|
|
156
|
+
"comments": [{
|
|
157
|
+
"id": 1,
|
|
158
|
+
"author": "User 1",
|
|
159
|
+
"message": "First!",
|
|
160
|
+
}, {
|
|
161
|
+
"id": 2,
|
|
162
|
+
"author": "User 2",
|
|
163
|
+
"message": "Good Luck!",
|
|
164
|
+
}]
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
If the records in the relationship are not known when the response
|
|
169
|
+
is serialized it's also possible to represent the relationship as a
|
|
170
|
+
URL using the `links` key in the response. Ember Data will fetch
|
|
171
|
+
this URL to resolve the relationship when it is accessed for the
|
|
172
|
+
first time.
|
|
173
|
+
|
|
174
|
+
```js
|
|
175
|
+
{
|
|
176
|
+
"posts": {
|
|
177
|
+
"id": 5,
|
|
178
|
+
"title": "I'm Running to Reform the W3C",
|
|
179
|
+
"author": "Yehuda Katz",
|
|
180
|
+
"links": {
|
|
181
|
+
"comments": "/posts/5/comments"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Errors
|
|
188
|
+
|
|
189
|
+
If a response is considered a failure, the JSON payload is expected to include
|
|
190
|
+
a top-level key `errors`, detailing any specific issues. For example:
|
|
191
|
+
|
|
192
|
+
```js
|
|
193
|
+
{
|
|
194
|
+
"errors": {
|
|
195
|
+
"msg": "Something went wrong"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
This adapter does not make any assumptions as to the format of the `errors`
|
|
201
|
+
object. It will simply be passed along as is, wrapped in an instance
|
|
202
|
+
of `InvalidError` or `AdapterError`. The serializer can interpret it
|
|
203
|
+
afterwards.
|
|
204
|
+
|
|
205
|
+
## Customization
|
|
206
|
+
|
|
207
|
+
### Endpoint path customization
|
|
208
|
+
|
|
209
|
+
Endpoint paths can be prefixed with a `namespace` by setting the namespace
|
|
210
|
+
property on the adapter:
|
|
211
|
+
|
|
212
|
+
```js [app/adapters/application.js]
|
|
213
|
+
import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
|
|
214
|
+
|
|
215
|
+
export default class ApplicationAdapter extends RESTAdapter {
|
|
216
|
+
namespace = 'api/1';
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
Requests for the `Person` model would now target `/api/1/people/1`.
|
|
220
|
+
|
|
221
|
+
### Host customization
|
|
222
|
+
|
|
223
|
+
An adapter can target other hosts by setting the `host` property.
|
|
224
|
+
|
|
225
|
+
```js [app/adapters/application.js]
|
|
226
|
+
import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
|
|
227
|
+
|
|
228
|
+
export default class ApplicationAdapter extends RESTAdapter {
|
|
229
|
+
host = 'https://api.example.com';
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Headers customization
|
|
234
|
+
|
|
235
|
+
Some APIs require HTTP headers, e.g. to provide an API key. Arbitrary
|
|
236
|
+
headers can be set as key/value pairs on the `RESTAdapter`'s `headers`
|
|
237
|
+
object and WarpDrive will send them along with each ajax request.
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
```js [app/adapters/application.js]
|
|
241
|
+
import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
|
|
242
|
+
|
|
243
|
+
export default class ApplicationAdapter extends RESTAdapter {
|
|
244
|
+
get headers() {
|
|
245
|
+
return {
|
|
246
|
+
'API_KEY': 'secret key',
|
|
247
|
+
'ANOTHER_HEADER': 'Some header value'
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
@class RESTAdapter
|
|
254
|
+
@public
|
|
255
|
+
@constructor
|
|
256
|
+
@uses BuildURLMixin
|
|
257
|
+
*/
|
|
258
|
+
declare class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
259
|
+
_fastboot: FastBoot;
|
|
260
|
+
_coalesceFindRequests: boolean;
|
|
261
|
+
host: string | null;
|
|
262
|
+
namespace: string | null;
|
|
263
|
+
/**
|
|
264
|
+
This property allows ajax to still be used instead when `false`.
|
|
265
|
+
|
|
266
|
+
@property useFetch
|
|
267
|
+
@type {Boolean}
|
|
268
|
+
@default true
|
|
269
|
+
@public
|
|
270
|
+
*/
|
|
271
|
+
useFetch: boolean;
|
|
272
|
+
_defaultContentType: string;
|
|
273
|
+
get fastboot(): FastBoot;
|
|
274
|
+
set fastboot(value: FastBoot);
|
|
275
|
+
/**
|
|
276
|
+
By default, the RESTAdapter will send the query params sorted alphabetically to the
|
|
277
|
+
server.
|
|
278
|
+
|
|
279
|
+
For example:
|
|
280
|
+
|
|
281
|
+
```js
|
|
282
|
+
store.query('posts', { sort: 'price', category: 'pets' });
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
will generate a requests like this `/posts?category=pets&sort=price`, even if the
|
|
286
|
+
parameters were specified in a different order.
|
|
287
|
+
|
|
288
|
+
That way the generated URL will be deterministic and that simplifies caching mechanisms
|
|
289
|
+
in the backend.
|
|
290
|
+
|
|
291
|
+
Setting `sortQueryParams` to a falsey value will respect the original order.
|
|
292
|
+
|
|
293
|
+
In case you want to sort the query parameters with a different criteria, set
|
|
294
|
+
`sortQueryParams` to your custom sort function.
|
|
295
|
+
|
|
296
|
+
```js [app/adapters/application.js]
|
|
297
|
+
import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
|
|
298
|
+
|
|
299
|
+
export default class ApplicationAdapter extends RESTAdapter {
|
|
300
|
+
sortQueryParams(params) {
|
|
301
|
+
let sortedKeys = Object.keys(params).sort().reverse();
|
|
302
|
+
let len = sortedKeys.length, newParams = {};
|
|
303
|
+
|
|
304
|
+
for (let i = 0; i < len; i++) {
|
|
305
|
+
newParams[sortedKeys[i]] = params[sortedKeys[i]];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return newParams;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
@param {Object} obj
|
|
314
|
+
@return {Object}
|
|
315
|
+
@public
|
|
316
|
+
*/
|
|
317
|
+
sortQueryParams(obj: Record<string, unknown>): Record<string, unknown>;
|
|
318
|
+
/**
|
|
319
|
+
By default the RESTAdapter will send each find request coming from a `store.find`
|
|
320
|
+
or from accessing a relationship separately to the server. If your server supports passing
|
|
321
|
+
ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests
|
|
322
|
+
within a single runloop.
|
|
323
|
+
|
|
324
|
+
For example, if you have an initial payload of:
|
|
325
|
+
|
|
326
|
+
```javascript
|
|
327
|
+
{
|
|
328
|
+
post: {
|
|
329
|
+
id: 1,
|
|
330
|
+
comments: [1, 2]
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
By default calling `post.comments` will trigger the following requests(assuming the
|
|
336
|
+
comments haven't been loaded before):
|
|
337
|
+
|
|
338
|
+
```
|
|
339
|
+
GET /comments/1
|
|
340
|
+
GET /comments/2
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
If you set coalesceFindRequests to `true` it will instead trigger the following request:
|
|
344
|
+
|
|
345
|
+
```
|
|
346
|
+
GET /comments?ids[]=1&ids[]=2
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
Setting coalesceFindRequests to `true` also works for `store.find` requests and `belongsTo`
|
|
350
|
+
relationships accessed within the same runloop. If you set `coalesceFindRequests: true`
|
|
351
|
+
|
|
352
|
+
```javascript
|
|
353
|
+
store.findRecord('comment', 1);
|
|
354
|
+
store.findRecord('comment', 2);
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
will also send a request to: `GET /comments?ids[]=1&ids[]=2`
|
|
358
|
+
|
|
359
|
+
Note: Requests coalescing rely on URL building strategy. So if you override `buildURL` in your app
|
|
360
|
+
`groupRecordsForFindMany` more likely should be overridden as well in order for coalescing to work.
|
|
361
|
+
|
|
362
|
+
@property coalesceFindRequests
|
|
363
|
+
@public
|
|
364
|
+
@type {Boolean}
|
|
365
|
+
*/
|
|
366
|
+
get coalesceFindRequests(): boolean;
|
|
367
|
+
set coalesceFindRequests(value: boolean);
|
|
368
|
+
/**
|
|
369
|
+
Endpoint paths can be prefixed with a `namespace` by setting the namespace
|
|
370
|
+
property on the adapter:
|
|
371
|
+
|
|
372
|
+
```js [app/adapters/application.js]
|
|
373
|
+
import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
|
|
374
|
+
|
|
375
|
+
export default class ApplicationAdapter extends RESTAdapter {
|
|
376
|
+
namespace = 'api/1';
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
Requests for the `Post` model would now target `/api/1/post/`.
|
|
381
|
+
|
|
382
|
+
@property namespace
|
|
383
|
+
@public
|
|
384
|
+
@type {String}
|
|
385
|
+
*/
|
|
386
|
+
/**
|
|
387
|
+
An adapter can target other hosts by setting the `host` property.
|
|
388
|
+
|
|
389
|
+
```js [app/adapters/application.js]
|
|
390
|
+
import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
|
|
391
|
+
|
|
392
|
+
export default class ApplicationAdapter extends RESTAdapter {
|
|
393
|
+
host = 'https://api.example.com';
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
Requests for the `Post` model would now target `https://api.example.com/post/`.
|
|
398
|
+
|
|
399
|
+
@property host
|
|
400
|
+
@public
|
|
401
|
+
@type {String}
|
|
402
|
+
*/
|
|
403
|
+
/**
|
|
404
|
+
Some APIs require HTTP headers, e.g. to provide an API
|
|
405
|
+
key. Arbitrary headers can be set as key/value pairs on the
|
|
406
|
+
`RESTAdapter`'s `headers` object and Ember Data will send them
|
|
407
|
+
along with each ajax request..
|
|
408
|
+
|
|
409
|
+
```js [app/adapters/application.js]
|
|
410
|
+
import { RESTAdapter } from '@warp-drive/legacy/adapter/rest';
|
|
411
|
+
|
|
412
|
+
export default class ApplicationAdapter extends RESTAdapter {
|
|
413
|
+
get headers() {
|
|
414
|
+
return {
|
|
415
|
+
'API_KEY': 'secret key',
|
|
416
|
+
'ANOTHER_HEADER': 'Some header value'
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
@property headers
|
|
423
|
+
@public
|
|
424
|
+
@type {Object}
|
|
425
|
+
*/
|
|
426
|
+
headers: Record<string, unknown> | undefined;
|
|
427
|
+
/**
|
|
428
|
+
Called by the store in order to fetch the JSON for a given
|
|
429
|
+
type and ID.
|
|
430
|
+
|
|
431
|
+
The `findRecord` method makes an Ajax request to a URL computed by
|
|
432
|
+
`buildURL`, and returns a promise for the resulting payload.
|
|
433
|
+
|
|
434
|
+
This method performs an HTTP `GET` request with the id provided as part of the query string.
|
|
435
|
+
|
|
436
|
+
@since 1.13.0
|
|
437
|
+
@public
|
|
438
|
+
@param {Store} store
|
|
439
|
+
@param {Model} type
|
|
440
|
+
@param {String} id
|
|
441
|
+
@param {Snapshot} snapshot
|
|
442
|
+
@return {Promise} promise
|
|
443
|
+
*/
|
|
444
|
+
findRecord(store: Store, type: ModelSchema, id: string, snapshot: Snapshot): Promise<AdapterPayload>;
|
|
445
|
+
/**
|
|
446
|
+
Called by the store in order to fetch a JSON array for all
|
|
447
|
+
of the records for a given type.
|
|
448
|
+
|
|
449
|
+
The `findAll` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a
|
|
450
|
+
promise for the resulting payload.
|
|
451
|
+
|
|
452
|
+
@public
|
|
453
|
+
@param {Store} store
|
|
454
|
+
@param {Model} type
|
|
455
|
+
@param {undefined} neverSet a value is never provided to this argument
|
|
456
|
+
@param {SnapshotRecordArray} snapshotRecordArray
|
|
457
|
+
@return {Promise} promise
|
|
458
|
+
*/
|
|
459
|
+
findAll(store: Store, type: ModelSchema, sinceToken: null, snapshotRecordArray: SnapshotRecordArray): Promise<AdapterPayload>;
|
|
460
|
+
/**
|
|
461
|
+
Called by the store in order to fetch a JSON array for
|
|
462
|
+
the records that match a particular query.
|
|
463
|
+
|
|
464
|
+
The `query` method makes an Ajax (HTTP GET) request to a URL
|
|
465
|
+
computed by `buildURL`, and returns a promise for the resulting
|
|
466
|
+
payload.
|
|
467
|
+
|
|
468
|
+
The `query` argument is a simple JavaScript object that will be passed directly
|
|
469
|
+
to the server as parameters.
|
|
470
|
+
|
|
471
|
+
@public
|
|
472
|
+
@param {Store} store
|
|
473
|
+
@param {Model} type
|
|
474
|
+
@param {Object} query
|
|
475
|
+
@param {Collection} recordArray
|
|
476
|
+
@param {Object} adapterOptions
|
|
477
|
+
@return {Promise} promise
|
|
478
|
+
*/
|
|
479
|
+
query(store: Store, type: ModelSchema, query: Record<string, unknown>): Promise<AdapterPayload>;
|
|
480
|
+
/**
|
|
481
|
+
Called by the store in order to fetch a JSON object for
|
|
482
|
+
the record that matches a particular query.
|
|
483
|
+
|
|
484
|
+
The `queryRecord` method makes an Ajax (HTTP GET) request to a URL
|
|
485
|
+
computed by `buildURL`, and returns a promise for the resulting
|
|
486
|
+
payload.
|
|
487
|
+
|
|
488
|
+
The `query` argument is a simple JavaScript object that will be passed directly
|
|
489
|
+
to the server as parameters.
|
|
490
|
+
|
|
491
|
+
@since 1.13.0
|
|
492
|
+
@public
|
|
493
|
+
@param {Store} store
|
|
494
|
+
@param {Model} type
|
|
495
|
+
@param {Object} query
|
|
496
|
+
@param {Object} adapterOptions
|
|
497
|
+
@return {Promise} promise
|
|
498
|
+
*/
|
|
499
|
+
queryRecord(store: Store, type: ModelSchema, query: Record<string, unknown>, adapterOptions: Record<string, unknown>): Promise<AdapterPayload>;
|
|
500
|
+
/**
|
|
501
|
+
Called by the store in order to fetch several records together if `coalesceFindRequests` is true
|
|
502
|
+
|
|
503
|
+
For example, if the original payload looks like:
|
|
504
|
+
|
|
505
|
+
```js
|
|
506
|
+
{
|
|
507
|
+
"id": 1,
|
|
508
|
+
"title": "Rails is omakase",
|
|
509
|
+
"comments": [ 1, 2, 3 ]
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
The IDs will be passed as a URL-encoded Array of IDs, in this form:
|
|
514
|
+
|
|
515
|
+
```
|
|
516
|
+
ids[]=1&ids[]=2&ids[]=3
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
Many servers, such as Rails and PHP, will automatically convert this URL-encoded array
|
|
520
|
+
into an Array for you on the server-side. If you want to encode the
|
|
521
|
+
IDs, differently, just override this (one-line) method.
|
|
522
|
+
|
|
523
|
+
The `findMany` method makes an Ajax (HTTP GET) request to a URL computed by `buildURL`, and returns a
|
|
524
|
+
promise for the resulting payload.
|
|
525
|
+
|
|
526
|
+
@public
|
|
527
|
+
@param {Store} store
|
|
528
|
+
@param {Model} type
|
|
529
|
+
@param {Array} ids
|
|
530
|
+
@param {Array} snapshots
|
|
531
|
+
@return {Promise} promise
|
|
532
|
+
*/
|
|
533
|
+
findMany(store: Store, type: ModelSchema, ids: string[], snapshots: Snapshot[]): Promise<AdapterPayload>;
|
|
534
|
+
/**
|
|
535
|
+
Called by the store in order to fetch a JSON array for
|
|
536
|
+
the unloaded records in a has-many relationship that were originally
|
|
537
|
+
specified as a URL (inside of `links`).
|
|
538
|
+
|
|
539
|
+
For example, if your original payload looks like this:
|
|
540
|
+
|
|
541
|
+
```js
|
|
542
|
+
{
|
|
543
|
+
"post": {
|
|
544
|
+
"id": 1,
|
|
545
|
+
"title": "Rails is omakase",
|
|
546
|
+
"links": { "comments": "/posts/1/comments" }
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
This method will be called with the parent record and `/posts/1/comments`.
|
|
552
|
+
|
|
553
|
+
The `findHasMany` method will make an Ajax (HTTP GET) request to the originally specified URL.
|
|
554
|
+
|
|
555
|
+
The format of your `links` value will influence the final request URL via the `urlPrefix` method:
|
|
556
|
+
|
|
557
|
+
* Links beginning with `//`, `http://`, `https://`, will be used as is, with no further manipulation.
|
|
558
|
+
|
|
559
|
+
* Links beginning with a single `/` will have the current adapter's `host` value prepended to it.
|
|
560
|
+
|
|
561
|
+
* Links with no beginning `/` will have a parentURL prepended to it, via the current adapter's `buildURL`.
|
|
562
|
+
|
|
563
|
+
@public
|
|
564
|
+
@param {Store} store
|
|
565
|
+
@param {Snapshot} snapshot
|
|
566
|
+
@param {String} url
|
|
567
|
+
@param {Object} relationship meta object describing the relationship
|
|
568
|
+
@return {Promise} promise
|
|
569
|
+
*/
|
|
570
|
+
findHasMany(store: Store, snapshot: Snapshot, url: string, relationship: Record<string, unknown>): Promise<AdapterPayload>;
|
|
571
|
+
/**
|
|
572
|
+
Called by the store in order to fetch the JSON for the unloaded record in a
|
|
573
|
+
belongs-to relationship that was originally specified as a URL (inside of
|
|
574
|
+
`links`).
|
|
575
|
+
|
|
576
|
+
For example, if your original payload looks like this:
|
|
577
|
+
|
|
578
|
+
```js
|
|
579
|
+
{
|
|
580
|
+
"person": {
|
|
581
|
+
"id": 1,
|
|
582
|
+
"name": "Tom Dale",
|
|
583
|
+
"links": { "group": "/people/1/group" }
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
This method will be called with the parent record and `/people/1/group`.
|
|
589
|
+
|
|
590
|
+
The `findBelongsTo` method will make an Ajax (HTTP GET) request to the originally specified URL.
|
|
591
|
+
|
|
592
|
+
The format of your `links` value will influence the final request URL via the `urlPrefix` method:
|
|
593
|
+
|
|
594
|
+
* Links beginning with `//`, `http://`, `https://`, will be used as is, with no further manipulation.
|
|
595
|
+
|
|
596
|
+
* Links beginning with a single `/` will have the current adapter's `host` value prepended to it.
|
|
597
|
+
|
|
598
|
+
* Links with no beginning `/` will have a parentURL prepended to it, via the current adapter's `buildURL`.
|
|
599
|
+
|
|
600
|
+
@public
|
|
601
|
+
*/
|
|
602
|
+
findBelongsTo(store: Store, snapshot: Snapshot, url: string, relationship: unknown): Promise<AdapterPayload>;
|
|
603
|
+
/**
|
|
604
|
+
Called by the store when a newly created record is
|
|
605
|
+
saved via the `save` method on a model record instance.
|
|
606
|
+
|
|
607
|
+
The `createRecord` method serializes the record and makes an Ajax (HTTP POST) request
|
|
608
|
+
to a URL computed by `buildURL`.
|
|
609
|
+
|
|
610
|
+
See `serialize` for information on how to customize the serialized form
|
|
611
|
+
of a record.
|
|
612
|
+
|
|
613
|
+
@public
|
|
614
|
+
@param {Store} store
|
|
615
|
+
@param {Model} type
|
|
616
|
+
@param {Snapshot} snapshot
|
|
617
|
+
@return {Promise} promise
|
|
618
|
+
*/
|
|
619
|
+
createRecord(store: Store, type: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
|
|
620
|
+
/**
|
|
621
|
+
Called by the store when an existing record is saved
|
|
622
|
+
via the `save` method on a model record instance.
|
|
623
|
+
|
|
624
|
+
The `updateRecord` method serializes the record and makes an Ajax (HTTP PUT) request
|
|
625
|
+
to a URL computed by `buildURL`.
|
|
626
|
+
|
|
627
|
+
See `serialize` for information on how to customize the serialized form
|
|
628
|
+
of a record.
|
|
629
|
+
|
|
630
|
+
@public
|
|
631
|
+
@param {Store} store
|
|
632
|
+
@param {Model} schema
|
|
633
|
+
@param {Snapshot} snapshot
|
|
634
|
+
@return {Promise} promise
|
|
635
|
+
*/
|
|
636
|
+
updateRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
|
|
637
|
+
/**
|
|
638
|
+
Called by the store when a record is deleted.
|
|
639
|
+
|
|
640
|
+
The `deleteRecord` method makes an Ajax (HTTP DELETE) request to a URL computed by `buildURL`.
|
|
641
|
+
|
|
642
|
+
@public
|
|
643
|
+
@param {Store} store
|
|
644
|
+
@param {Model} type
|
|
645
|
+
@param {Snapshot} snapshot
|
|
646
|
+
@return {Promise} promise
|
|
647
|
+
*/
|
|
648
|
+
deleteRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
|
|
649
|
+
_stripIDFromURL(store: Store, snapshot: Snapshot): string;
|
|
650
|
+
maxURLLength: number;
|
|
651
|
+
/**
|
|
652
|
+
Organize records into groups, each of which is to be passed to separate
|
|
653
|
+
calls to `findMany`.
|
|
654
|
+
|
|
655
|
+
This implementation groups together records that have the same base URL but
|
|
656
|
+
differing ids. For example `/comments/1` and `/comments/2` will be grouped together
|
|
657
|
+
because we know findMany can coalesce them together as `/comments?ids[]=1&ids[]=2`
|
|
658
|
+
|
|
659
|
+
It also supports urls where ids are passed as a query param, such as `/comments?id=1`
|
|
660
|
+
but not those where there is more than 1 query param such as `/comments?id=2&name=David`
|
|
661
|
+
Currently only the query param of `id` is supported. If you need to support others, please
|
|
662
|
+
override this or the `_stripIDFromURL` method.
|
|
663
|
+
|
|
664
|
+
It does not group records that have differing base urls, such as for example: `/posts/1/comments/2`
|
|
665
|
+
and `/posts/2/comments/3`
|
|
666
|
+
|
|
667
|
+
@public
|
|
668
|
+
@param {Store} store
|
|
669
|
+
@param {Array} snapshots
|
|
670
|
+
@return {Array} an array of arrays of records, each of which is to be
|
|
671
|
+
loaded separately by `findMany`.
|
|
672
|
+
*/
|
|
673
|
+
groupRecordsForFindMany(store: Store, snapshots: Snapshot[]): Snapshot[][];
|
|
674
|
+
/**
|
|
675
|
+
Takes an ajax response, and returns the json payload or an error.
|
|
676
|
+
|
|
677
|
+
By default this hook just returns the json payload passed to it.
|
|
678
|
+
You might want to override it in two cases:
|
|
679
|
+
|
|
680
|
+
1. Your API might return useful results in the response headers.
|
|
681
|
+
Response headers are passed in as the second argument.
|
|
682
|
+
|
|
683
|
+
2. Your API might return errors as successful responses with status code
|
|
684
|
+
200 and an Errors text or object. You can return a `InvalidError` or a
|
|
685
|
+
`AdapterError` (or a sub class) from this hook and it will automatically
|
|
686
|
+
reject the promise and put your record into the invalid or error state.
|
|
687
|
+
|
|
688
|
+
Returning a `InvalidError` from this method will cause the
|
|
689
|
+
record to transition into the `invalid` state and make the
|
|
690
|
+
`errors` object available on the record. When returning an
|
|
691
|
+
`InvalidError` the store will attempt to normalize the error data
|
|
692
|
+
returned from the server using the serializer's `extractErrors`
|
|
693
|
+
method.
|
|
694
|
+
|
|
695
|
+
@since 1.13.0
|
|
696
|
+
@public
|
|
697
|
+
@param {Number} status
|
|
698
|
+
@param {Object} headers
|
|
699
|
+
@param {Object} payload
|
|
700
|
+
@param {Object} requestData - the original request information
|
|
701
|
+
@return {Object | AdapterError} response
|
|
702
|
+
*/
|
|
703
|
+
handleResponse(status: number, headers: Record<string, string>, payload: Payload, requestData: RequestData): Payload | typeof AdapterError;
|
|
704
|
+
/**
|
|
705
|
+
Default `handleResponse` implementation uses this hook to decide if the
|
|
706
|
+
response is a success.
|
|
707
|
+
|
|
708
|
+
@since 1.13.0
|
|
709
|
+
@public
|
|
710
|
+
@param {Number} status
|
|
711
|
+
@param {Object} headers
|
|
712
|
+
@param {Object} payload
|
|
713
|
+
@return {Boolean}
|
|
714
|
+
*/
|
|
715
|
+
isSuccess(status: number, _headers: Record<string, unknown>, _payload: Payload): boolean;
|
|
716
|
+
/**
|
|
717
|
+
Default `handleResponse` implementation uses this hook to decide if the
|
|
718
|
+
response is an invalid error.
|
|
719
|
+
|
|
720
|
+
@since 1.13.0
|
|
721
|
+
@public
|
|
722
|
+
@param {Number} status
|
|
723
|
+
@param {Object} headers
|
|
724
|
+
@param {Object} payload
|
|
725
|
+
@return {Boolean}
|
|
726
|
+
*/
|
|
727
|
+
isInvalid(status: number, _headers: Record<string, unknown>, _payload: Payload): boolean;
|
|
728
|
+
/**
|
|
729
|
+
Takes a URL, an HTTP method and a hash of data, and makes an
|
|
730
|
+
HTTP request.
|
|
731
|
+
|
|
732
|
+
When the server responds with a payload, Ember Data will call into `extractSingle`
|
|
733
|
+
or `extractArray` (depending on whether the original query was for one record or
|
|
734
|
+
many records).
|
|
735
|
+
|
|
736
|
+
By default, `ajax` method has the following behavior:
|
|
737
|
+
|
|
738
|
+
* It sets the response `dataType` to `"json"`
|
|
739
|
+
* If the HTTP method is not `"GET"`, it sets the `Content-Type` to be
|
|
740
|
+
`application/json; charset=utf-8`
|
|
741
|
+
* If the HTTP method is not `"GET"`, it stringifies the data passed in. The
|
|
742
|
+
data is the serialized record in the case of a save.
|
|
743
|
+
* Registers success and failure handlers.
|
|
744
|
+
|
|
745
|
+
@private
|
|
746
|
+
@param {String} url
|
|
747
|
+
@param {String} type The request type GET, POST, PUT, DELETE etc.
|
|
748
|
+
@param {Object} options
|
|
749
|
+
@return {Promise} promise
|
|
750
|
+
*/
|
|
751
|
+
ajax(url: string, type: HTTPMethod, options?: JQueryAjaxSettings | RequestInit): Promise<AdapterPayload>;
|
|
752
|
+
/**
|
|
753
|
+
@private
|
|
754
|
+
@param {Object} options jQuery ajax options to be used for the ajax request
|
|
755
|
+
*/
|
|
756
|
+
_ajaxRequest(options: JQueryRequestInit): void;
|
|
757
|
+
_fetchRequest(options: FetchRequestInit): Promise<Response>;
|
|
758
|
+
_ajax(options: FetchRequestInit | JQueryRequestInit): void;
|
|
759
|
+
/**
|
|
760
|
+
@private
|
|
761
|
+
@param {String} url
|
|
762
|
+
@param {String} type The request type GET, POST, PUT, DELETE etc.
|
|
763
|
+
@param {Object} options
|
|
764
|
+
@return {Object}
|
|
765
|
+
*/
|
|
766
|
+
ajaxOptions(url: string, method: HTTPMethod, options: JQueryAjaxSettings | RequestInit): JQueryRequestInit | FetchRequestInit;
|
|
767
|
+
_ajaxURL(url: string): string;
|
|
768
|
+
/**
|
|
769
|
+
@private
|
|
770
|
+
@param {String} responseText
|
|
771
|
+
@return {Object}
|
|
772
|
+
*/
|
|
773
|
+
parseErrorResponse(responseText: string): Record<string, unknown> | string;
|
|
774
|
+
/**
|
|
775
|
+
@private
|
|
776
|
+
@param {Number} status
|
|
777
|
+
@param {Object} headers
|
|
778
|
+
@param {Object} payload
|
|
779
|
+
@return {Array} errors payload
|
|
780
|
+
*/
|
|
781
|
+
normalizeErrorResponse(status: number, _headers: Record<string, unknown>, payload: Payload): Record<string, unknown>[];
|
|
782
|
+
/**
|
|
783
|
+
Generates a detailed ("friendly") error message, with plenty
|
|
784
|
+
of information for debugging (good luck!)
|
|
785
|
+
|
|
786
|
+
@private
|
|
787
|
+
@param {Number} status
|
|
788
|
+
@param {Object} headers
|
|
789
|
+
@param {Object} payload
|
|
790
|
+
@param {Object} requestData
|
|
791
|
+
@return {String} detailed error message
|
|
792
|
+
*/
|
|
793
|
+
generatedDetailedMessage(status: number, headers: Record<string, string>, payload: Payload, requestData: RequestData): string;
|
|
794
|
+
/**
|
|
795
|
+
Used by `findAll` and `findRecord` to build the query's `data` hash
|
|
796
|
+
supplied to the ajax method.
|
|
797
|
+
|
|
798
|
+
@since 2.5.0
|
|
799
|
+
@public
|
|
800
|
+
@param {Snapshot} snapshot
|
|
801
|
+
@return {Object}
|
|
802
|
+
*/
|
|
803
|
+
buildQuery(snapshot: Snapshot | SnapshotRecordArray): QueryState;
|
|
804
|
+
}
|
|
805
|
+
interface RESTAdapter extends MixtBuildURLMixin {}
|
|
806
|
+
/**
|
|
807
|
+
* Helper function that translates the options passed to `jQuery.ajax` into a format that `fetch` expects.
|
|
808
|
+
*
|
|
809
|
+
* @param {Object} _options
|
|
810
|
+
* @param {Adapter} adapter
|
|
811
|
+
* @private
|
|
812
|
+
* @return {Object}
|
|
813
|
+
*/
|
|
814
|
+
export declare function fetchOptions(options: JQueryRequestInit & Partial<FetchRequestInit>, adapter: RESTAdapter): FetchRequestInit;
|
|
815
|
+
export { RESTAdapter };
|