@warp-drive/legacy 5.8.0-alpha.37 → 5.8.0-alpha.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/unpkg/{prod-deprecated/-private-B1pSSN52.js → dev/-private-DbaSCSym.js} +65 -70
- package/dist/unpkg/dev/adapter/-private.js +1 -1
- package/dist/unpkg/dev/adapter/error.js +2 -3
- package/dist/unpkg/dev/adapter/json-api.js +144 -5
- package/dist/unpkg/dev/adapter/rest.js +15 -17
- package/dist/unpkg/dev/adapter.js +9 -10
- package/dist/unpkg/dev/compat/-private.js +1 -1
- package/dist/unpkg/dev/compat/builders.js +30 -28
- package/dist/unpkg/dev/compat/extensions.js +4 -5
- package/dist/unpkg/dev/compat/utils.js +2 -3
- package/dist/unpkg/dev/compat.js +226 -100
- package/dist/unpkg/{dev-deprecated/errors-CIGPcDvd.js → dev/errors-DD96TBEs.js} +78 -82
- package/dist/unpkg/{dev-deprecated/hooks-QqRnX108.js → dev/hooks-CqWjNWeL.js} +14 -15
- package/dist/unpkg/dev/index.js +23 -21
- package/dist/unpkg/dev/{json-BNrV8EYG.js → json-CCU-ZQ4b.js} +6 -9
- package/dist/unpkg/dev/model/-private.js +1 -1
- package/dist/unpkg/dev/model/migration-support.js +6 -34
- package/dist/unpkg/dev/model.js +57 -46
- package/dist/unpkg/{dev-deprecated/schema-provider-g5MfTj8n.js → dev/schema-provider-B8jiJOYC.js} +113 -222
- package/dist/unpkg/{prod/serialize-into-hash-BnYvPex3.js → dev/serialize-into-hash-CPAZXrQU.js} +16 -18
- package/dist/unpkg/dev/serializer/json-api.js +140 -19
- package/dist/unpkg/dev/serializer/json.js +1 -3
- package/dist/unpkg/dev/serializer/rest.js +12 -13
- package/dist/unpkg/dev/store.js +55 -55
- package/dist/unpkg/dev/util-DvanW33H.js +20 -0
- package/dist/unpkg/dev/utils-BhvS1iTS.js +8 -0
- package/dist/unpkg/dev-deprecated/{-private-B1pSSN52.js → -private-DbaSCSym.js} +65 -70
- package/dist/unpkg/dev-deprecated/adapter/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/adapter/error.js +2 -3
- package/dist/unpkg/dev-deprecated/adapter/json-api.js +144 -5
- package/dist/unpkg/dev-deprecated/adapter/rest.js +15 -17
- package/dist/unpkg/dev-deprecated/adapter.js +9 -10
- package/dist/unpkg/dev-deprecated/compat/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/compat/builders.js +30 -28
- package/dist/unpkg/dev-deprecated/compat/extensions.js +4 -5
- package/dist/unpkg/dev-deprecated/compat/utils.js +2 -3
- package/dist/unpkg/dev-deprecated/compat.js +226 -100
- package/dist/unpkg/{dev/errors-CIGPcDvd.js → dev-deprecated/errors-DEnabIZj.js} +78 -79
- package/dist/unpkg/{prod-deprecated/hooks-QqRnX108.js → dev-deprecated/hooks-CAll-Ets.js} +14 -15
- package/dist/unpkg/dev-deprecated/index.js +22 -21
- package/dist/unpkg/{prod-deprecated/json-BNrV8EYG.js → dev-deprecated/json-CCU-ZQ4b.js} +6 -9
- package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/model/migration-support.js +7 -18
- package/dist/unpkg/dev-deprecated/model.js +58 -43
- package/dist/unpkg/{prod-deprecated/schema-provider-g5MfTj8n.js → dev-deprecated/schema-provider-k2qXQTBg.js} +114 -198
- package/dist/unpkg/{prod-deprecated/serialize-into-hash-BnYvPex3.js → dev-deprecated/serialize-into-hash-CPAZXrQU.js} +16 -18
- package/dist/unpkg/dev-deprecated/serializer/json-api.js +140 -19
- package/dist/unpkg/dev-deprecated/serializer/json.js +1 -3
- package/dist/unpkg/dev-deprecated/serializer/rest.js +12 -13
- package/dist/unpkg/dev-deprecated/store.js +55 -55
- package/dist/unpkg/{prod-deprecated/util-Dul6TZts.js → dev-deprecated/util-CWr5WQOT.js} +2 -13
- package/dist/unpkg/dev-deprecated/utils-C9PJehtL.js +12 -0
- package/dist/unpkg/prod/{-private-B1pSSN52.js → -private-Cvf_97EG.js} +6 -246
- package/dist/unpkg/prod/adapter/-private.js +1 -1
- package/dist/unpkg/prod/adapter/error.js +0 -6
- package/dist/unpkg/prod/adapter/json-api.js +142 -8
- package/dist/unpkg/prod/adapter/rest.js +1 -40
- package/dist/unpkg/prod/adapter.js +7 -41
- package/dist/unpkg/prod/compat/-private.js +1 -1
- package/dist/unpkg/prod/compat/builders.js +4 -67
- package/dist/unpkg/prod/compat/extensions.js +0 -11
- package/dist/unpkg/prod/compat/utils.js +0 -6
- package/dist/unpkg/prod/compat.js +13 -307
- package/dist/unpkg/prod/{errors-CIGPcDvd.js → errors-CXnfnBfQ.js} +4 -256
- package/dist/unpkg/prod/hooks-DvyWhLNg.js +41 -0
- package/dist/unpkg/prod/index.js +9 -53
- package/dist/unpkg/prod/{json-BNrV8EYG.js → json-BYrUP8ao.js} +0 -16
- package/dist/unpkg/prod/model/-private.js +1 -1
- package/dist/unpkg/prod/model/migration-support.js +3 -38
- package/dist/unpkg/prod/model.js +31 -105
- package/dist/unpkg/{dev/schema-provider-g5MfTj8n.js → prod/schema-provider-CHujJvA9.js} +20 -454
- package/dist/unpkg/{dev-deprecated/serialize-into-hash-BnYvPex3.js → prod/serialize-into-hash-DYU2egXl.js} +1 -47
- package/dist/unpkg/prod/serializer/json-api.js +124 -60
- package/dist/unpkg/prod/serializer/json.js +1 -3
- package/dist/unpkg/prod/serializer/rest.js +2 -35
- package/dist/unpkg/prod/store.js +4 -136
- package/dist/unpkg/prod/util-DvanW33H.js +20 -0
- package/dist/unpkg/prod/utils-BhvS1iTS.js +8 -0
- package/dist/unpkg/{dev/-private-B1pSSN52.js → prod-deprecated/-private-Cvf_97EG.js} +6 -246
- package/dist/unpkg/prod-deprecated/adapter/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/adapter/error.js +0 -6
- package/dist/unpkg/prod-deprecated/adapter/json-api.js +142 -8
- package/dist/unpkg/prod-deprecated/adapter/rest.js +1 -40
- package/dist/unpkg/prod-deprecated/adapter.js +7 -41
- package/dist/unpkg/prod-deprecated/compat/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/compat/builders.js +4 -67
- package/dist/unpkg/prod-deprecated/compat/extensions.js +0 -11
- package/dist/unpkg/prod-deprecated/compat/utils.js +0 -6
- package/dist/unpkg/prod-deprecated/compat.js +13 -307
- package/dist/unpkg/prod-deprecated/{errors-CIGPcDvd.js → errors-CG1SPYVg.js} +4 -253
- package/dist/unpkg/prod-deprecated/hooks-BIUBiNGR.js +41 -0
- package/dist/unpkg/prod-deprecated/index.js +8 -53
- package/dist/unpkg/{dev-deprecated/json-BNrV8EYG.js → prod-deprecated/json-BYrUP8ao.js} +0 -16
- package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/model/migration-support.js +4 -22
- package/dist/unpkg/prod-deprecated/model.js +31 -102
- package/dist/unpkg/{prod/schema-provider-g5MfTj8n.js → prod-deprecated/schema-provider-BJ4TWnZf.js} +21 -412
- package/dist/unpkg/{dev/serialize-into-hash-BnYvPex3.js → prod-deprecated/serialize-into-hash-DYU2egXl.js} +1 -47
- package/dist/unpkg/prod-deprecated/serializer/json-api.js +124 -60
- package/dist/unpkg/prod-deprecated/serializer/json.js +1 -3
- package/dist/unpkg/prod-deprecated/serializer/rest.js +2 -35
- package/dist/unpkg/prod-deprecated/store.js +4 -136
- package/dist/unpkg/{dev/util-Dul6TZts.js → prod-deprecated/util-B6cn-i93.js} +1 -13
- package/dist/unpkg/prod-deprecated/utils-BUWwQwCh.js +11 -0
- package/package.json +14 -22
- package/dist/unpkg/dev/declarations/adapter/-private/build-url-mixin.d.ts +0 -33
- package/dist/unpkg/dev/declarations/adapter/-private/fastboot-interface.d.ts +0 -8
- package/dist/unpkg/dev/declarations/adapter/-private/utils/continue-on-reject.d.ts +0 -1
- package/dist/unpkg/dev/declarations/adapter/-private/utils/determine-body-promise.d.ts +0 -4
- package/dist/unpkg/dev/declarations/adapter/-private/utils/fetch.d.ts +0 -8
- package/dist/unpkg/dev/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
- package/dist/unpkg/dev/declarations/adapter/-private/utils/serialize-into-hash.d.ts +0 -6
- package/dist/unpkg/dev/declarations/adapter/-private/utils/serialize-query-params.d.ts +0 -5
- package/dist/unpkg/dev/declarations/adapter/-private.d.ts +0 -5
- package/dist/unpkg/dev/declarations/adapter/error.d.ts +0 -215
- package/dist/unpkg/dev/declarations/adapter/json-api.d.ts +0 -231
- package/dist/unpkg/dev/declarations/adapter/rest.d.ts +0 -815
- package/dist/unpkg/dev/declarations/adapter.d.ts +0 -770
- package/dist/unpkg/dev/declarations/compat/-private.d.ts +0 -13
- package/dist/unpkg/dev/declarations/compat/builders/find-all.d.ts +0 -35
- package/dist/unpkg/dev/declarations/compat/builders/find-record.d.ts +0 -56
- package/dist/unpkg/dev/declarations/compat/builders/query.d.ts +0 -66
- package/dist/unpkg/dev/declarations/compat/builders/save-record.d.ts +0 -34
- package/dist/unpkg/dev/declarations/compat/builders/utils.d.ts +0 -3
- package/dist/unpkg/dev/declarations/compat/builders.d.ts +0 -14
- package/dist/unpkg/dev/declarations/compat/extensions.d.ts +0 -59
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/fetch-manager.d.ts +0 -55
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +0 -2
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +0 -11
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +0 -5
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +0 -2
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +0 -524
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +0 -213
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/serializer-response.d.ts +0 -6
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +0 -110
- package/dist/unpkg/dev/declarations/compat/legacy-network-handler/snapshot.d.ts +0 -255
- package/dist/unpkg/dev/declarations/compat/utils.d.ts +0 -137
- package/dist/unpkg/dev/declarations/compat.d.ts +0 -157
- package/dist/unpkg/dev/declarations/index.d.ts +0 -70
- package/dist/unpkg/dev/declarations/model/-private/attr.d.ts +0 -170
- package/dist/unpkg/dev/declarations/model/-private/belongs-to.d.ts +0 -174
- package/dist/unpkg/dev/declarations/model/-private/debug/assert-polymorphic-type.d.ts +0 -5
- package/dist/unpkg/dev/declarations/model/-private/errors.d.ts +0 -289
- package/dist/unpkg/dev/declarations/model/-private/has-many.d.ts +0 -162
- package/dist/unpkg/dev/declarations/model/-private/hooks.d.ts +0 -10
- package/dist/unpkg/dev/declarations/model/-private/legacy-relationships-support.d.ts +0 -47
- package/dist/unpkg/dev/declarations/model/-private/model-for-mixin.d.ts +0 -3
- package/dist/unpkg/dev/declarations/model/-private/model-methods.d.ts +0 -39
- package/dist/unpkg/dev/declarations/model/-private/model.d.ts +0 -1269
- package/dist/unpkg/dev/declarations/model/-private/notify-changes.d.ts +0 -4
- package/dist/unpkg/dev/declarations/model/-private/promise-belongs-to.d.ts +0 -40
- package/dist/unpkg/dev/declarations/model/-private/promise-many-array.d.ts +0 -124
- package/dist/unpkg/dev/declarations/model/-private/record-state.d.ts +0 -58
- package/dist/unpkg/dev/declarations/model/-private/references/belongs-to.d.ts +0 -498
- package/dist/unpkg/dev/declarations/model/-private/references/has-many.d.ts +0 -500
- package/dist/unpkg/dev/declarations/model/-private/schema-provider.d.ts +0 -56
- package/dist/unpkg/dev/declarations/model/-private/type-utils.d.ts +0 -57
- package/dist/unpkg/dev/declarations/model/-private/util.d.ts +0 -5
- package/dist/unpkg/dev/declarations/model/-private.d.ts +0 -8
- package/dist/unpkg/dev/declarations/model/migration-support.d.ts +0 -280
- package/dist/unpkg/dev/declarations/model-fragments/extensions/fragment-array.d.ts +0 -16
- package/dist/unpkg/dev/declarations/model-fragments/extensions/fragment.d.ts +0 -15
- package/dist/unpkg/dev/declarations/model-fragments/hooks/model-for.d.ts +0 -20
- package/dist/unpkg/dev/declarations/model-fragments/index.d.ts +0 -5
- package/dist/unpkg/dev/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +0 -9
- package/dist/unpkg/dev/declarations/model-fragments/utilities/with-array-defaults.d.ts +0 -15
- package/dist/unpkg/dev/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +0 -20
- package/dist/unpkg/dev/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +0 -19
- package/dist/unpkg/dev/declarations/model-fragments/utilities/with-legacy.d.ts +0 -3
- package/dist/unpkg/dev/declarations/model-fragments.d.ts +0 -9
- package/dist/unpkg/dev/declarations/model.d.ts +0 -49
- package/dist/unpkg/dev/declarations/serializer/-private/embedded-records-mixin.d.ts +0 -91
- package/dist/unpkg/dev/declarations/serializer/-private/transforms/boolean.d.ts +0 -47
- package/dist/unpkg/dev/declarations/serializer/-private/transforms/date.d.ts +0 -28
- package/dist/unpkg/dev/declarations/serializer/-private/transforms/number.d.ts +0 -29
- package/dist/unpkg/dev/declarations/serializer/-private/transforms/string.d.ts +0 -29
- package/dist/unpkg/dev/declarations/serializer/-private/transforms/transform.d.ts +0 -118
- package/dist/unpkg/dev/declarations/serializer/-private/utils.d.ts +0 -3
- package/dist/unpkg/dev/declarations/serializer/json-api.d.ts +0 -123
- package/dist/unpkg/dev/declarations/serializer/json.d.ts +0 -75
- package/dist/unpkg/dev/declarations/serializer/rest.d.ts +0 -51
- package/dist/unpkg/dev/declarations/serializer/transform.d.ts +0 -5
- package/dist/unpkg/dev/declarations/serializer.d.ts +0 -254
- package/dist/unpkg/dev/declarations/store/-private.d.ts +0 -223
- package/dist/unpkg/dev/declarations/store.d.ts +0 -3
- package/dist/unpkg/dev/hooks-QqRnX108.js +0 -74
- package/dist/unpkg/dev/utils-Cqw9eRj5.js +0 -23
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/build-url-mixin.d.ts +0 -33
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/fastboot-interface.d.ts +0 -8
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/continue-on-reject.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/determine-body-promise.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/fetch.d.ts +0 -8
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/serialize-into-hash.d.ts +0 -6
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private/utils/serialize-query-params.d.ts +0 -5
- package/dist/unpkg/dev-deprecated/declarations/adapter/-private.d.ts +0 -5
- package/dist/unpkg/dev-deprecated/declarations/adapter/error.d.ts +0 -215
- package/dist/unpkg/dev-deprecated/declarations/adapter/json-api.d.ts +0 -231
- package/dist/unpkg/dev-deprecated/declarations/adapter/rest.d.ts +0 -815
- package/dist/unpkg/dev-deprecated/declarations/adapter.d.ts +0 -770
- package/dist/unpkg/dev-deprecated/declarations/compat/-private.d.ts +0 -13
- package/dist/unpkg/dev-deprecated/declarations/compat/builders/find-all.d.ts +0 -35
- package/dist/unpkg/dev-deprecated/declarations/compat/builders/find-record.d.ts +0 -56
- package/dist/unpkg/dev-deprecated/declarations/compat/builders/query.d.ts +0 -66
- package/dist/unpkg/dev-deprecated/declarations/compat/builders/save-record.d.ts +0 -34
- package/dist/unpkg/dev-deprecated/declarations/compat/builders/utils.d.ts +0 -3
- package/dist/unpkg/dev-deprecated/declarations/compat/builders.d.ts +0 -14
- package/dist/unpkg/dev-deprecated/declarations/compat/extensions.d.ts +0 -59
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/fetch-manager.d.ts +0 -55
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +0 -2
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +0 -11
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +0 -5
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +0 -2
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +0 -524
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +0 -213
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/serializer-response.d.ts +0 -6
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +0 -110
- package/dist/unpkg/dev-deprecated/declarations/compat/legacy-network-handler/snapshot.d.ts +0 -255
- package/dist/unpkg/dev-deprecated/declarations/compat/utils.d.ts +0 -137
- package/dist/unpkg/dev-deprecated/declarations/compat.d.ts +0 -157
- package/dist/unpkg/dev-deprecated/declarations/index.d.ts +0 -70
- package/dist/unpkg/dev-deprecated/declarations/model/-private/attr.d.ts +0 -170
- package/dist/unpkg/dev-deprecated/declarations/model/-private/belongs-to.d.ts +0 -174
- package/dist/unpkg/dev-deprecated/declarations/model/-private/debug/assert-polymorphic-type.d.ts +0 -5
- package/dist/unpkg/dev-deprecated/declarations/model/-private/errors.d.ts +0 -289
- package/dist/unpkg/dev-deprecated/declarations/model/-private/has-many.d.ts +0 -162
- package/dist/unpkg/dev-deprecated/declarations/model/-private/hooks.d.ts +0 -10
- package/dist/unpkg/dev-deprecated/declarations/model/-private/legacy-relationships-support.d.ts +0 -47
- package/dist/unpkg/dev-deprecated/declarations/model/-private/model-for-mixin.d.ts +0 -3
- package/dist/unpkg/dev-deprecated/declarations/model/-private/model-methods.d.ts +0 -39
- package/dist/unpkg/dev-deprecated/declarations/model/-private/model.d.ts +0 -1269
- package/dist/unpkg/dev-deprecated/declarations/model/-private/notify-changes.d.ts +0 -4
- package/dist/unpkg/dev-deprecated/declarations/model/-private/promise-belongs-to.d.ts +0 -40
- package/dist/unpkg/dev-deprecated/declarations/model/-private/promise-many-array.d.ts +0 -124
- package/dist/unpkg/dev-deprecated/declarations/model/-private/record-state.d.ts +0 -58
- package/dist/unpkg/dev-deprecated/declarations/model/-private/references/belongs-to.d.ts +0 -498
- package/dist/unpkg/dev-deprecated/declarations/model/-private/references/has-many.d.ts +0 -500
- package/dist/unpkg/dev-deprecated/declarations/model/-private/schema-provider.d.ts +0 -56
- package/dist/unpkg/dev-deprecated/declarations/model/-private/type-utils.d.ts +0 -57
- package/dist/unpkg/dev-deprecated/declarations/model/-private/util.d.ts +0 -5
- package/dist/unpkg/dev-deprecated/declarations/model/-private.d.ts +0 -8
- package/dist/unpkg/dev-deprecated/declarations/model/migration-support.d.ts +0 -280
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/extensions/fragment-array.d.ts +0 -16
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/extensions/fragment.d.ts +0 -15
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/hooks/model-for.d.ts +0 -20
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/index.d.ts +0 -5
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +0 -9
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-array-defaults.d.ts +0 -15
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +0 -20
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +0 -19
- package/dist/unpkg/dev-deprecated/declarations/model-fragments/utilities/with-legacy.d.ts +0 -3
- package/dist/unpkg/dev-deprecated/declarations/model-fragments.d.ts +0 -9
- package/dist/unpkg/dev-deprecated/declarations/model.d.ts +0 -49
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/embedded-records-mixin.d.ts +0 -91
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/boolean.d.ts +0 -47
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/date.d.ts +0 -28
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/number.d.ts +0 -29
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/string.d.ts +0 -29
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/transforms/transform.d.ts +0 -118
- package/dist/unpkg/dev-deprecated/declarations/serializer/-private/utils.d.ts +0 -3
- package/dist/unpkg/dev-deprecated/declarations/serializer/json-api.d.ts +0 -123
- package/dist/unpkg/dev-deprecated/declarations/serializer/json.d.ts +0 -75
- package/dist/unpkg/dev-deprecated/declarations/serializer/rest.d.ts +0 -51
- package/dist/unpkg/dev-deprecated/declarations/serializer/transform.d.ts +0 -5
- package/dist/unpkg/dev-deprecated/declarations/serializer.d.ts +0 -254
- package/dist/unpkg/dev-deprecated/declarations/store/-private.d.ts +0 -223
- package/dist/unpkg/dev-deprecated/declarations/store.d.ts +0 -3
- package/dist/unpkg/dev-deprecated/util-Dul6TZts.js +0 -35
- package/dist/unpkg/dev-deprecated/utils-Cqw9eRj5.js +0 -23
- package/dist/unpkg/prod/declarations/adapter/-private/build-url-mixin.d.ts +0 -33
- package/dist/unpkg/prod/declarations/adapter/-private/fastboot-interface.d.ts +0 -8
- package/dist/unpkg/prod/declarations/adapter/-private/utils/continue-on-reject.d.ts +0 -1
- package/dist/unpkg/prod/declarations/adapter/-private/utils/determine-body-promise.d.ts +0 -4
- package/dist/unpkg/prod/declarations/adapter/-private/utils/fetch.d.ts +0 -8
- package/dist/unpkg/prod/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
- package/dist/unpkg/prod/declarations/adapter/-private/utils/serialize-into-hash.d.ts +0 -6
- package/dist/unpkg/prod/declarations/adapter/-private/utils/serialize-query-params.d.ts +0 -5
- package/dist/unpkg/prod/declarations/adapter/-private.d.ts +0 -5
- package/dist/unpkg/prod/declarations/adapter/error.d.ts +0 -215
- package/dist/unpkg/prod/declarations/adapter/json-api.d.ts +0 -231
- package/dist/unpkg/prod/declarations/adapter/rest.d.ts +0 -815
- package/dist/unpkg/prod/declarations/adapter.d.ts +0 -770
- package/dist/unpkg/prod/declarations/compat/-private.d.ts +0 -13
- package/dist/unpkg/prod/declarations/compat/builders/find-all.d.ts +0 -35
- package/dist/unpkg/prod/declarations/compat/builders/find-record.d.ts +0 -56
- package/dist/unpkg/prod/declarations/compat/builders/query.d.ts +0 -66
- package/dist/unpkg/prod/declarations/compat/builders/save-record.d.ts +0 -34
- package/dist/unpkg/prod/declarations/compat/builders/utils.d.ts +0 -3
- package/dist/unpkg/prod/declarations/compat/builders.d.ts +0 -14
- package/dist/unpkg/prod/declarations/compat/extensions.d.ts +0 -59
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/fetch-manager.d.ts +0 -55
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +0 -2
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +0 -11
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +0 -5
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +0 -2
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +0 -524
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +0 -213
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/serializer-response.d.ts +0 -6
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +0 -110
- package/dist/unpkg/prod/declarations/compat/legacy-network-handler/snapshot.d.ts +0 -255
- package/dist/unpkg/prod/declarations/compat/utils.d.ts +0 -137
- package/dist/unpkg/prod/declarations/compat.d.ts +0 -157
- package/dist/unpkg/prod/declarations/index.d.ts +0 -70
- package/dist/unpkg/prod/declarations/model/-private/attr.d.ts +0 -170
- package/dist/unpkg/prod/declarations/model/-private/belongs-to.d.ts +0 -174
- package/dist/unpkg/prod/declarations/model/-private/debug/assert-polymorphic-type.d.ts +0 -5
- package/dist/unpkg/prod/declarations/model/-private/errors.d.ts +0 -289
- package/dist/unpkg/prod/declarations/model/-private/has-many.d.ts +0 -162
- package/dist/unpkg/prod/declarations/model/-private/hooks.d.ts +0 -10
- package/dist/unpkg/prod/declarations/model/-private/legacy-relationships-support.d.ts +0 -47
- package/dist/unpkg/prod/declarations/model/-private/model-for-mixin.d.ts +0 -3
- package/dist/unpkg/prod/declarations/model/-private/model-methods.d.ts +0 -39
- package/dist/unpkg/prod/declarations/model/-private/model.d.ts +0 -1269
- package/dist/unpkg/prod/declarations/model/-private/notify-changes.d.ts +0 -4
- package/dist/unpkg/prod/declarations/model/-private/promise-belongs-to.d.ts +0 -40
- package/dist/unpkg/prod/declarations/model/-private/promise-many-array.d.ts +0 -124
- package/dist/unpkg/prod/declarations/model/-private/record-state.d.ts +0 -58
- package/dist/unpkg/prod/declarations/model/-private/references/belongs-to.d.ts +0 -498
- package/dist/unpkg/prod/declarations/model/-private/references/has-many.d.ts +0 -500
- package/dist/unpkg/prod/declarations/model/-private/schema-provider.d.ts +0 -56
- package/dist/unpkg/prod/declarations/model/-private/type-utils.d.ts +0 -57
- package/dist/unpkg/prod/declarations/model/-private/util.d.ts +0 -5
- package/dist/unpkg/prod/declarations/model/-private.d.ts +0 -8
- package/dist/unpkg/prod/declarations/model/migration-support.d.ts +0 -280
- package/dist/unpkg/prod/declarations/model-fragments/extensions/fragment-array.d.ts +0 -16
- package/dist/unpkg/prod/declarations/model-fragments/extensions/fragment.d.ts +0 -15
- package/dist/unpkg/prod/declarations/model-fragments/hooks/model-for.d.ts +0 -20
- package/dist/unpkg/prod/declarations/model-fragments/index.d.ts +0 -5
- package/dist/unpkg/prod/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +0 -9
- package/dist/unpkg/prod/declarations/model-fragments/utilities/with-array-defaults.d.ts +0 -15
- package/dist/unpkg/prod/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +0 -20
- package/dist/unpkg/prod/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +0 -19
- package/dist/unpkg/prod/declarations/model-fragments/utilities/with-legacy.d.ts +0 -3
- package/dist/unpkg/prod/declarations/model-fragments.d.ts +0 -9
- package/dist/unpkg/prod/declarations/model.d.ts +0 -49
- package/dist/unpkg/prod/declarations/serializer/-private/embedded-records-mixin.d.ts +0 -91
- package/dist/unpkg/prod/declarations/serializer/-private/transforms/boolean.d.ts +0 -47
- package/dist/unpkg/prod/declarations/serializer/-private/transforms/date.d.ts +0 -28
- package/dist/unpkg/prod/declarations/serializer/-private/transforms/number.d.ts +0 -29
- package/dist/unpkg/prod/declarations/serializer/-private/transforms/string.d.ts +0 -29
- package/dist/unpkg/prod/declarations/serializer/-private/transforms/transform.d.ts +0 -118
- package/dist/unpkg/prod/declarations/serializer/-private/utils.d.ts +0 -3
- package/dist/unpkg/prod/declarations/serializer/json-api.d.ts +0 -123
- package/dist/unpkg/prod/declarations/serializer/json.d.ts +0 -75
- package/dist/unpkg/prod/declarations/serializer/rest.d.ts +0 -51
- package/dist/unpkg/prod/declarations/serializer/transform.d.ts +0 -5
- package/dist/unpkg/prod/declarations/serializer.d.ts +0 -254
- package/dist/unpkg/prod/declarations/store/-private.d.ts +0 -223
- package/dist/unpkg/prod/declarations/store.d.ts +0 -3
- package/dist/unpkg/prod/hooks-QqRnX108.js +0 -74
- package/dist/unpkg/prod/util-Dul6TZts.js +0 -35
- package/dist/unpkg/prod/utils-Cqw9eRj5.js +0 -23
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/build-url-mixin.d.ts +0 -33
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/fastboot-interface.d.ts +0 -8
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/continue-on-reject.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/determine-body-promise.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/fetch.d.ts +0 -8
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/serialize-into-hash.d.ts +0 -6
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private/utils/serialize-query-params.d.ts +0 -5
- package/dist/unpkg/prod-deprecated/declarations/adapter/-private.d.ts +0 -5
- package/dist/unpkg/prod-deprecated/declarations/adapter/error.d.ts +0 -215
- package/dist/unpkg/prod-deprecated/declarations/adapter/json-api.d.ts +0 -231
- package/dist/unpkg/prod-deprecated/declarations/adapter/rest.d.ts +0 -815
- package/dist/unpkg/prod-deprecated/declarations/adapter.d.ts +0 -770
- package/dist/unpkg/prod-deprecated/declarations/compat/-private.d.ts +0 -13
- package/dist/unpkg/prod-deprecated/declarations/compat/builders/find-all.d.ts +0 -35
- package/dist/unpkg/prod-deprecated/declarations/compat/builders/find-record.d.ts +0 -56
- package/dist/unpkg/prod-deprecated/declarations/compat/builders/query.d.ts +0 -66
- package/dist/unpkg/prod-deprecated/declarations/compat/builders/save-record.d.ts +0 -34
- package/dist/unpkg/prod-deprecated/declarations/compat/builders/utils.d.ts +0 -3
- package/dist/unpkg/prod-deprecated/declarations/compat/builders.d.ts +0 -14
- package/dist/unpkg/prod-deprecated/declarations/compat/extensions.d.ts +0 -59
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/fetch-manager.d.ts +0 -55
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +0 -2
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +0 -11
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +0 -5
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +0 -2
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +0 -524
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +0 -213
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/serializer-response.d.ts +0 -6
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +0 -110
- package/dist/unpkg/prod-deprecated/declarations/compat/legacy-network-handler/snapshot.d.ts +0 -255
- package/dist/unpkg/prod-deprecated/declarations/compat/utils.d.ts +0 -137
- package/dist/unpkg/prod-deprecated/declarations/compat.d.ts +0 -157
- package/dist/unpkg/prod-deprecated/declarations/index.d.ts +0 -70
- package/dist/unpkg/prod-deprecated/declarations/model/-private/attr.d.ts +0 -170
- package/dist/unpkg/prod-deprecated/declarations/model/-private/belongs-to.d.ts +0 -174
- package/dist/unpkg/prod-deprecated/declarations/model/-private/debug/assert-polymorphic-type.d.ts +0 -5
- package/dist/unpkg/prod-deprecated/declarations/model/-private/errors.d.ts +0 -289
- package/dist/unpkg/prod-deprecated/declarations/model/-private/has-many.d.ts +0 -162
- package/dist/unpkg/prod-deprecated/declarations/model/-private/hooks.d.ts +0 -10
- package/dist/unpkg/prod-deprecated/declarations/model/-private/legacy-relationships-support.d.ts +0 -47
- package/dist/unpkg/prod-deprecated/declarations/model/-private/model-for-mixin.d.ts +0 -3
- package/dist/unpkg/prod-deprecated/declarations/model/-private/model-methods.d.ts +0 -39
- package/dist/unpkg/prod-deprecated/declarations/model/-private/model.d.ts +0 -1269
- package/dist/unpkg/prod-deprecated/declarations/model/-private/notify-changes.d.ts +0 -4
- package/dist/unpkg/prod-deprecated/declarations/model/-private/promise-belongs-to.d.ts +0 -40
- package/dist/unpkg/prod-deprecated/declarations/model/-private/promise-many-array.d.ts +0 -124
- package/dist/unpkg/prod-deprecated/declarations/model/-private/record-state.d.ts +0 -58
- package/dist/unpkg/prod-deprecated/declarations/model/-private/references/belongs-to.d.ts +0 -498
- package/dist/unpkg/prod-deprecated/declarations/model/-private/references/has-many.d.ts +0 -500
- package/dist/unpkg/prod-deprecated/declarations/model/-private/schema-provider.d.ts +0 -56
- package/dist/unpkg/prod-deprecated/declarations/model/-private/type-utils.d.ts +0 -57
- package/dist/unpkg/prod-deprecated/declarations/model/-private/util.d.ts +0 -5
- package/dist/unpkg/prod-deprecated/declarations/model/-private.d.ts +0 -8
- package/dist/unpkg/prod-deprecated/declarations/model/migration-support.d.ts +0 -280
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/extensions/fragment-array.d.ts +0 -16
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/extensions/fragment.d.ts +0 -15
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/hooks/model-for.d.ts +0 -20
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/index.d.ts +0 -5
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +0 -9
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-array-defaults.d.ts +0 -15
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +0 -20
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +0 -19
- package/dist/unpkg/prod-deprecated/declarations/model-fragments/utilities/with-legacy.d.ts +0 -3
- package/dist/unpkg/prod-deprecated/declarations/model-fragments.d.ts +0 -9
- package/dist/unpkg/prod-deprecated/declarations/model.d.ts +0 -49
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/embedded-records-mixin.d.ts +0 -91
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/boolean.d.ts +0 -47
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/date.d.ts +0 -28
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/number.d.ts +0 -29
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/string.d.ts +0 -29
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/transforms/transform.d.ts +0 -118
- package/dist/unpkg/prod-deprecated/declarations/serializer/-private/utils.d.ts +0 -3
- package/dist/unpkg/prod-deprecated/declarations/serializer/json-api.d.ts +0 -123
- package/dist/unpkg/prod-deprecated/declarations/serializer/json.d.ts +0 -75
- package/dist/unpkg/prod-deprecated/declarations/serializer/rest.d.ts +0 -51
- package/dist/unpkg/prod-deprecated/declarations/serializer/transform.d.ts +0 -5
- package/dist/unpkg/prod-deprecated/declarations/serializer.d.ts +0 -254
- package/dist/unpkg/prod-deprecated/declarations/store/-private.d.ts +0 -223
- package/dist/unpkg/prod-deprecated/declarations/store.d.ts +0 -3
- package/dist/unpkg/prod-deprecated/utils-Cqw9eRj5.js +0 -23
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Context } from '@warp-drive/core/reactive/-private';
|
|
2
|
-
import { warn } from '@ember/debug';
|
|
3
2
|
import { createDeferred } from '@warp-drive/core/request';
|
|
4
|
-
import { assertPrivateStore
|
|
3
|
+
import { assertPrivateStore } from '@warp-drive/core/store/-private';
|
|
5
4
|
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
6
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
SnapshotRecordArray is not directly instantiable.
|
|
@@ -135,27 +133,6 @@ class SnapshotRecordArray {
|
|
|
135
133
|
return this._snapshots;
|
|
136
134
|
}
|
|
137
135
|
}
|
|
138
|
-
function assertIdentifierHasId(identifier) {
|
|
139
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
140
|
-
if (!test) {
|
|
141
|
-
throw new Error(`Attempted to schedule a fetch for a record without an id.`);
|
|
142
|
-
}
|
|
143
|
-
})(identifier && identifier.id !== null) : {};
|
|
144
|
-
}
|
|
145
|
-
function iterateData(data, fn) {
|
|
146
|
-
if (Array.isArray(data)) {
|
|
147
|
-
return data.map(fn);
|
|
148
|
-
} else {
|
|
149
|
-
return fn(data, 0);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
function payloadIsNotBlank(adapterPayload) {
|
|
153
|
-
if (Array.isArray(adapterPayload)) {
|
|
154
|
-
return true;
|
|
155
|
-
} else {
|
|
156
|
-
return Object.keys(adapterPayload || {}).length !== 0;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
136
|
|
|
160
137
|
/**
|
|
161
138
|
This is a helper method that validates a JSON API top-level document
|
|
@@ -165,60 +142,8 @@ function payloadIsNotBlank(adapterPayload) {
|
|
|
165
142
|
|
|
166
143
|
@internal
|
|
167
144
|
*/
|
|
168
|
-
function validateDocumentStructure(doc) {
|
|
169
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
170
|
-
const errors = [];
|
|
171
|
-
if (!doc || typeof doc !== 'object') {
|
|
172
|
-
errors.push('Top level of a JSON API document must be an object');
|
|
173
|
-
} else {
|
|
174
|
-
if (!('data' in doc) && !('errors' in doc) && !('meta' in doc)) {
|
|
175
|
-
errors.push('One or more of the following keys must be present: "data", "errors", "meta".');
|
|
176
|
-
} else {
|
|
177
|
-
if ('data' in doc && 'errors' in doc) {
|
|
178
|
-
errors.push('Top level keys "errors" and "data" cannot both be present in a JSON API document');
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if ('data' in doc) {
|
|
182
|
-
if (!(doc.data === null || Array.isArray(doc.data) || typeof doc.data === 'object')) {
|
|
183
|
-
errors.push('data must be null, an object, or an array');
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
if ('meta' in doc) {
|
|
187
|
-
if (typeof doc.meta !== 'object') {
|
|
188
|
-
errors.push('meta must be an object');
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if ('errors' in doc) {
|
|
192
|
-
if (!Array.isArray(doc.errors)) {
|
|
193
|
-
errors.push('errors must be an array');
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if ('links' in doc) {
|
|
197
|
-
if (typeof doc.links !== 'object') {
|
|
198
|
-
errors.push('links must be an object');
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
if ('jsonapi' in doc) {
|
|
202
|
-
if (typeof doc.jsonapi !== 'object') {
|
|
203
|
-
errors.push('jsonapi must be an object');
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if ('included' in doc) {
|
|
207
|
-
if (typeof doc.included !== 'object') {
|
|
208
|
-
errors.push('included must be an array');
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
213
|
-
if (!test) {
|
|
214
|
-
throw new Error(`Response must be normalized to a valid JSON API document:\n\t* ${errors.join('\n\t* ')}`);
|
|
215
|
-
}
|
|
216
|
-
})(errors.length === 0) : {};
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
145
|
function normalizeResponseHelper(serializer, store, modelClass, payload, id, requestType) {
|
|
220
146
|
const normalizedResponse = serializer ? serializer.normalizeResponse(store, modelClass, payload, id, requestType) : payload;
|
|
221
|
-
validateDocumentStructure(normalizedResponse);
|
|
222
147
|
return normalizedResponse;
|
|
223
148
|
}
|
|
224
149
|
|
|
@@ -326,11 +251,6 @@ class Snapshot {
|
|
|
326
251
|
*/
|
|
327
252
|
get record() {
|
|
328
253
|
const record = this._store.peekRecord(this.identifier);
|
|
329
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
330
|
-
if (!test) {
|
|
331
|
-
throw new Error(`Record ${this.identifier.type} ${this.identifier.id} (${this.identifier.lid}) is not yet loaded and thus cannot be accessed from the Snapshot during serialization`);
|
|
332
|
-
}
|
|
333
|
-
})(record !== null) : {};
|
|
334
254
|
return record;
|
|
335
255
|
}
|
|
336
256
|
|
|
@@ -370,11 +290,6 @@ class Snapshot {
|
|
|
370
290
|
if (keyName in this._attributes) {
|
|
371
291
|
return this._attributes[keyName];
|
|
372
292
|
}
|
|
373
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
374
|
-
{
|
|
375
|
-
throw new Error(`Model '${this.identifier.lid}' has no attribute named '${keyName}' defined.`);
|
|
376
|
-
}
|
|
377
|
-
})() : {};
|
|
378
293
|
}
|
|
379
294
|
|
|
380
295
|
/**
|
|
@@ -458,35 +373,12 @@ class Snapshot {
|
|
|
458
373
|
if (returnModeIsId === false && keyName in this._belongsToRelationships) {
|
|
459
374
|
return this._belongsToRelationships[keyName];
|
|
460
375
|
}
|
|
461
|
-
|
|
376
|
+
store.schema.fields({
|
|
462
377
|
type: this.modelName
|
|
463
378
|
}).get(keyName);
|
|
464
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
465
|
-
if (!test) {
|
|
466
|
-
throw new Error(`Model '${this.identifier.lid}' has no belongsTo relationship named '${keyName}' defined.`);
|
|
467
|
-
}
|
|
468
|
-
})(relationshipMeta && relationshipMeta.kind === 'belongsTo') : {};
|
|
469
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
470
|
-
if (!test) {
|
|
471
|
-
throw new Error(`snapshot.belongsTo only supported when using a cache that supports the graph`);
|
|
472
|
-
}
|
|
473
|
-
})(this._store._graph) : {};
|
|
474
379
|
const {
|
|
475
380
|
identifier
|
|
476
381
|
} = this;
|
|
477
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
478
|
-
const relationship = this._store.schema.fields(identifier)?.get(keyName);
|
|
479
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
480
|
-
if (!test) {
|
|
481
|
-
throw new Error(`You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but no such relationship was found.`);
|
|
482
|
-
}
|
|
483
|
-
})(relationship) : {};
|
|
484
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
485
|
-
if (!test) {
|
|
486
|
-
throw new Error(`You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but that relationship is a hasMany.`);
|
|
487
|
-
}
|
|
488
|
-
})(relationship.kind === 'belongsTo') : {};
|
|
489
|
-
}
|
|
490
382
|
const value = this._store.cache.getRelationship(identifier, keyName);
|
|
491
383
|
const data = value && value.data;
|
|
492
384
|
const inverseIdentifier = data ? store.cacheKeyManager.getOrCreateRecordIdentifier(data) : null;
|
|
@@ -542,41 +434,12 @@ class Snapshot {
|
|
|
542
434
|
return cachedSnapshots;
|
|
543
435
|
}
|
|
544
436
|
const store = this._store;
|
|
545
|
-
|
|
437
|
+
store.schema.fields({
|
|
546
438
|
type: this.modelName
|
|
547
439
|
}).get(keyName);
|
|
548
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
549
|
-
if (!test) {
|
|
550
|
-
throw new Error(`Model '${this.identifier.lid}' has no hasMany relationship named '${keyName}' defined.`);
|
|
551
|
-
}
|
|
552
|
-
})(relationshipMeta && relationshipMeta.kind === 'hasMany') : {};
|
|
553
|
-
|
|
554
|
-
// TODO @runspired it seems this code branch would not work with CUSTOM_MODEL_CLASSes
|
|
555
|
-
// this check is not a regression in behavior because relationships don't currently
|
|
556
|
-
// function without access to intimate API contracts between RecordData and Model.
|
|
557
|
-
// This is a requirement we should fix as soon as the relationship layer does not require
|
|
558
|
-
// this intimate API usage.
|
|
559
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
560
|
-
if (!test) {
|
|
561
|
-
throw new Error(`snapshot.hasMany only supported when using a cache that supports the graph`);
|
|
562
|
-
}
|
|
563
|
-
})(this._store._graph) : {};
|
|
564
440
|
const {
|
|
565
441
|
identifier
|
|
566
442
|
} = this;
|
|
567
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
568
|
-
const relationship = this._store.schema.fields(identifier)?.get(keyName);
|
|
569
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
570
|
-
if (!test) {
|
|
571
|
-
throw new Error(`You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but no such relationship was found.`);
|
|
572
|
-
}
|
|
573
|
-
})(relationship) : {};
|
|
574
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
575
|
-
if (!test) {
|
|
576
|
-
throw new Error(`You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${identifier.id || ''}, lid: ${identifier.lid} but that relationship is a belongsTo.`);
|
|
577
|
-
}
|
|
578
|
-
})(relationship.kind === 'hasMany') : {};
|
|
579
|
-
}
|
|
580
443
|
const value = this._store.cache.getRelationship(identifier, keyName);
|
|
581
444
|
if (value.data) {
|
|
582
445
|
results = [];
|
|
@@ -683,11 +546,6 @@ class Snapshot {
|
|
|
683
546
|
serialize(options) {
|
|
684
547
|
upgradeStore(this._store);
|
|
685
548
|
const serializer = this._store.serializerFor(this.modelName);
|
|
686
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
687
|
-
if (!test) {
|
|
688
|
-
throw new Error(`Cannot serialize record, no serializer found`);
|
|
689
|
-
}
|
|
690
|
-
})(serializer) : {};
|
|
691
549
|
return serializer.serialize(this, options);
|
|
692
550
|
}
|
|
693
551
|
}
|
|
@@ -789,11 +647,6 @@ class FetchManager {
|
|
|
789
647
|
}
|
|
790
648
|
return identifier;
|
|
791
649
|
}, error => {
|
|
792
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
793
|
-
if (!test) {
|
|
794
|
-
throw new Error(`Async Leak Detected: Expected the store to not be destroyed`);
|
|
795
|
-
}
|
|
796
|
-
})(!store.isDestroyed) : {};
|
|
797
650
|
const cache = store.cache;
|
|
798
651
|
if (!cache || cache.isEmpty(identifier) || isInitialLoad) {
|
|
799
652
|
let isReleasable = true;
|
|
@@ -831,11 +684,6 @@ class FetchManager {
|
|
|
831
684
|
fetchesById.set(identifier, requestsForIdentifier);
|
|
832
685
|
}
|
|
833
686
|
requestsForIdentifier.push(pendingFetchItem);
|
|
834
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.TESTING)) {
|
|
835
|
-
if (!request.disableTestWaiter) {
|
|
836
|
-
promise = waitFor(promise);
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
687
|
pendingFetchItem.promise = promise;
|
|
840
688
|
return promise;
|
|
841
689
|
}
|
|
@@ -864,22 +712,12 @@ class FetchManager {
|
|
|
864
712
|
const isLoading = _isLoading(this._store._instanceCache, identifier);
|
|
865
713
|
let promise;
|
|
866
714
|
if (isEmpty) {
|
|
867
|
-
|
|
868
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
869
|
-
promise = this.scheduleFetch(identifier, Object.assign({}, options, {
|
|
870
|
-
reload: true
|
|
871
|
-
}), request);
|
|
872
|
-
} else {
|
|
715
|
+
{
|
|
873
716
|
options.reload = true;
|
|
874
717
|
promise = this.scheduleFetch(identifier, options, request);
|
|
875
718
|
}
|
|
876
719
|
} else if (isLoading) {
|
|
877
720
|
promise = this.getPendingFetch(identifier, options);
|
|
878
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
879
|
-
if (!test) {
|
|
880
|
-
throw new Error(`Expected to find a pending request for a record in the loading state, but found none`);
|
|
881
|
-
}
|
|
882
|
-
})(promise) : {};
|
|
883
721
|
} else {
|
|
884
722
|
promise = Promise.resolve(identifier);
|
|
885
723
|
}
|
|
@@ -956,31 +794,10 @@ function _findMany(store, adapter, modelName, snapshots) {
|
|
|
956
794
|
const modelClass = store.modelFor(modelName); // `adapter.findMany` gets the modelClass still
|
|
957
795
|
const promise = Promise.resolve().then(() => {
|
|
958
796
|
const ids = snapshots.map(s => s.id);
|
|
959
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
960
|
-
if (!test) {
|
|
961
|
-
throw new Error(`Cannot fetch a record without an id`);
|
|
962
|
-
}
|
|
963
|
-
})(ids.every(v => v !== null)) : {};
|
|
964
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
965
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
966
|
-
if (!test) {
|
|
967
|
-
throw new Error(`Expected this adapter to implement findMany for coalescing`);
|
|
968
|
-
}
|
|
969
|
-
})(adapter.findMany) : {};
|
|
970
797
|
const ret = adapter.findMany(store, modelClass, ids, snapshots);
|
|
971
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
972
|
-
if (!test) {
|
|
973
|
-
throw new Error('adapter.findMany returned undefined, this was very likely a mistake');
|
|
974
|
-
}
|
|
975
|
-
})(ret !== undefined) : {};
|
|
976
798
|
return ret;
|
|
977
799
|
});
|
|
978
800
|
return promise.then(adapterPayload => {
|
|
979
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
980
|
-
if (!test) {
|
|
981
|
-
throw new Error(`You made a 'findMany' request for '${modelName}' records with ids '[${snapshots.map(s => s.id).join(',')}]', but the adapter's response did not have any data`);
|
|
982
|
-
}
|
|
983
|
-
})(!!payloadIsNotBlank(adapterPayload)) : {};
|
|
984
801
|
const serializer = store.serializerFor(modelName);
|
|
985
802
|
const payload = normalizeResponseHelper(serializer, store, modelClass, adapterPayload, null, 'findMany');
|
|
986
803
|
return payload;
|
|
@@ -1051,24 +868,11 @@ function handleFoundRecords(store, fetchMap, snapshots, coalescedPayload) {
|
|
|
1051
868
|
snapshotsById.forEach(snapshotArray => {
|
|
1052
869
|
rejected.push(...snapshotArray);
|
|
1053
870
|
});
|
|
1054
|
-
warn('Ember Data expected to find records with the following ids in the adapter response from findMany but they were missing: [ "' + [...snapshotsById.values()].map(r => r[0].id).join('", "') + '" ]', {
|
|
1055
|
-
id: 'ds.store.missing-records-from-adapter'
|
|
1056
|
-
});
|
|
1057
871
|
rejectFetchedItems(fetchMap, rejected);
|
|
1058
872
|
}
|
|
1059
873
|
function _fetchRecord(store, adapter, fetchItem) {
|
|
1060
874
|
const identifier = fetchItem.identifier;
|
|
1061
875
|
const modelName = identifier.type;
|
|
1062
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
1063
|
-
if (!test) {
|
|
1064
|
-
throw new Error(`You tried to find a record but you have no adapter (for ${modelName})`);
|
|
1065
|
-
}
|
|
1066
|
-
})(adapter) : {};
|
|
1067
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
1068
|
-
if (!test) {
|
|
1069
|
-
throw new Error(`You tried to find a record but your adapter (for ${modelName}) does not implement 'findRecord'`);
|
|
1070
|
-
}
|
|
1071
|
-
})(typeof adapter.findRecord === 'function') : {};
|
|
1072
876
|
const snapshot = store._fetchManager.createSnapshot(identifier, fetchItem.options);
|
|
1073
877
|
const klass = store.modelFor(identifier.type);
|
|
1074
878
|
const id = identifier.id;
|
|
@@ -1076,31 +880,8 @@ function _fetchRecord(store, adapter, fetchItem) {
|
|
|
1076
880
|
return adapter.findRecord(store, klass, identifier.id, snapshot);
|
|
1077
881
|
});
|
|
1078
882
|
promise = promise.then(adapterPayload => {
|
|
1079
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
1080
|
-
if (!test) {
|
|
1081
|
-
throw new Error(`Async Leak Detected: Expected the store to not be destroyed`);
|
|
1082
|
-
}
|
|
1083
|
-
})(!(store.isDestroyed || store.isDestroying)) : {};
|
|
1084
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
1085
|
-
if (!test) {
|
|
1086
|
-
throw new Error(`You made a 'findRecord' request for a '${modelName}' with id '${id}', but the adapter's response did not have any data`);
|
|
1087
|
-
}
|
|
1088
|
-
})(!!payloadIsNotBlank(adapterPayload)) : {};
|
|
1089
883
|
const serializer = store.serializerFor(modelName);
|
|
1090
884
|
const payload = normalizeResponseHelper(serializer, store, klass, adapterPayload, id, 'findRecord');
|
|
1091
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
1092
|
-
if (!test) {
|
|
1093
|
-
throw new Error(`Ember Data expected the primary data returned from a 'findRecord' response to be an object but instead it found an array.`);
|
|
1094
|
-
}
|
|
1095
|
-
})(!Array.isArray(payload.data)) : {};
|
|
1096
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
1097
|
-
if (!test) {
|
|
1098
|
-
throw new Error(`The 'findRecord' request for ${modelName}:${id} resolved indicating success but contained no primary data. To indicate a 404 not found you should either reject the promise returned by the adapter's findRecord method or throw a NotFoundError.`);
|
|
1099
|
-
}
|
|
1100
|
-
})('data' in payload && payload.data !== null && typeof payload.data === 'object') : {};
|
|
1101
|
-
warn(`You requested a record of type '${modelName}' with id '${id}' but the adapter returned a payload with primary data having an id of '${payload.data.id}'. Use 'store.findRecord()' when the requested id is the same as the one returned by the adapter. In other cases use 'store.queryRecord()' instead.`, coerceId(payload.data.id) === coerceId(id), {
|
|
1102
|
-
id: 'ds.store.findRecord.id-mismatch'
|
|
1103
|
-
});
|
|
1104
885
|
return payload;
|
|
1105
886
|
});
|
|
1106
887
|
fetchItem.resolver.resolve(promise);
|
|
@@ -1114,13 +895,7 @@ function _processCoalescedGroup(store, fetchMap, group, adapter, modelName) {
|
|
|
1114
895
|
});
|
|
1115
896
|
} else if (group.length === 1) {
|
|
1116
897
|
_fetchRecord(store, adapter, fetchMap.get(group[0]));
|
|
1117
|
-
} else
|
|
1118
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
1119
|
-
{
|
|
1120
|
-
throw new Error("You cannot return an empty array from adapter's method groupRecordsForFindMany");
|
|
1121
|
-
}
|
|
1122
|
-
})() : {};
|
|
1123
|
-
}
|
|
898
|
+
} else ;
|
|
1124
899
|
}
|
|
1125
900
|
function _flushPendingFetchForType(store, pendingFetchMap, modelName) {
|
|
1126
901
|
const adapter = store.adapterFor(modelName);
|
|
@@ -1175,23 +950,8 @@ function _flushPendingSave(store, pending) {
|
|
|
1175
950
|
const operation = options[SaveOp];
|
|
1176
951
|
const modelName = snapshot.modelName;
|
|
1177
952
|
const modelClass = store.modelFor(modelName);
|
|
1178
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
1179
|
-
if (!test) {
|
|
1180
|
-
throw new Error(`You tried to update a record but you have no adapter (for ${modelName})`);
|
|
1181
|
-
}
|
|
1182
|
-
})(adapter) : {};
|
|
1183
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
1184
|
-
if (!test) {
|
|
1185
|
-
throw new Error(`You tried to update a record but your adapter (for ${modelName}) does not implement '${operation}'`);
|
|
1186
|
-
}
|
|
1187
|
-
})(typeof adapter[operation] === 'function') : {};
|
|
1188
953
|
let promise = Promise.resolve().then(() => adapter[operation](store, modelClass, snapshot));
|
|
1189
954
|
const serializer = store.serializerFor(modelName);
|
|
1190
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
1191
|
-
if (!test) {
|
|
1192
|
-
throw new Error(`Your adapter's '${operation}' method must return a value, but it returned 'undefined'`);
|
|
1193
|
-
}
|
|
1194
|
-
})(promise !== undefined) : {};
|
|
1195
955
|
promise = promise.then(adapterPayload => {
|
|
1196
956
|
if (adapterPayload) {
|
|
1197
957
|
return normalizeResponseHelper(serializer, store, modelClass, adapterPayload, snapshot.id, operation);
|
|
@@ -1207,4 +967,4 @@ function _flushPendingSave(store, pending) {
|
|
|
1207
967
|
@module
|
|
1208
968
|
*/
|
|
1209
969
|
function upgradeStore(store) {}
|
|
1210
|
-
export { FetchManager as F, SaveOp as S,
|
|
970
|
+
export { FetchManager as F, SaveOp as S, SnapshotRecordArray as a, Snapshot as b, normalizeResponseHelper as n, upgradeStore as u };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { d as determineBodyPromise, g as fetch, p as parseResponseHeaders, b as serializeIntoHash, s as serializeQueryParams, a as setupFastboot } from "../serialize-into-hash-
|
|
1
|
+
export { d as determineBodyPromise, g as fetch, p as parseResponseHeaders, b as serializeIntoHash, s as serializeQueryParams, a as setupFastboot } from "../serialize-into-hash-DYU2egXl.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getOrSetGlobal } from '@warp-drive/core/types/-private';
|
|
2
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
3
2
|
|
|
4
3
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
5
4
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
@@ -103,11 +102,6 @@ function extendFn(ErrorClass) {
|
|
|
103
102
|
}
|
|
104
103
|
function extend(ParentErrorClass, defaultMessage) {
|
|
105
104
|
const ErrorClass = function (errors, message) {
|
|
106
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
107
|
-
if (!test) {
|
|
108
|
-
throw new Error('`AdapterError` expects json-api formatted errors array.');
|
|
109
|
-
}
|
|
110
|
-
})(Array.isArray(errors || [])) : {};
|
|
111
105
|
ParentErrorClass.call(this, errors, message || defaultMessage);
|
|
112
106
|
};
|
|
113
107
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
@@ -1,11 +1,150 @@
|
|
|
1
1
|
import { dasherize, pluralize } from '@warp-drive/utilities/string';
|
|
2
|
-
import
|
|
3
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
4
|
-
import { b as serializeIntoHash } from "../serialize-into-hash-BnYvPex3.js";
|
|
2
|
+
import { b as serializeIntoHash } from "../serialize-into-hash-DYU2egXl.js";
|
|
5
3
|
import { RESTAdapter } from './rest.js';
|
|
6
4
|
|
|
7
5
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
6
|
|
|
7
|
+
/**
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
:::danger
|
|
11
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
12
|
+
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
13
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
14
|
+
:::
|
|
15
|
+
|
|
16
|
+
The `JSONAPIAdapter` is an adapter whichtransforms the store's
|
|
17
|
+
requests into HTTP requests that follow the [JSON API format](http://jsonapi.org/format/).
|
|
18
|
+
|
|
19
|
+
## JSON API Conventions
|
|
20
|
+
|
|
21
|
+
The JSONAPIAdapter uses JSON API conventions for building the URL
|
|
22
|
+
for a record and selecting the HTTP verb to use with a request. The
|
|
23
|
+
actions you can take on a record map onto the following URLs in the
|
|
24
|
+
JSON API adapter:
|
|
25
|
+
|
|
26
|
+
<table>
|
|
27
|
+
<tr>
|
|
28
|
+
<th>
|
|
29
|
+
Action
|
|
30
|
+
</th>
|
|
31
|
+
<th>
|
|
32
|
+
HTTP Verb
|
|
33
|
+
</th>
|
|
34
|
+
<th>
|
|
35
|
+
URL
|
|
36
|
+
</th>
|
|
37
|
+
</tr>
|
|
38
|
+
<tr>
|
|
39
|
+
<th>
|
|
40
|
+
`store.findRecord('post', 123)`
|
|
41
|
+
</th>
|
|
42
|
+
<td>
|
|
43
|
+
GET
|
|
44
|
+
</td>
|
|
45
|
+
<td>
|
|
46
|
+
/posts/123
|
|
47
|
+
</td>
|
|
48
|
+
</tr>
|
|
49
|
+
<tr>
|
|
50
|
+
<th>
|
|
51
|
+
`store.findAll('post')`
|
|
52
|
+
</th>
|
|
53
|
+
<td>
|
|
54
|
+
GET
|
|
55
|
+
</td>
|
|
56
|
+
<td>
|
|
57
|
+
/posts
|
|
58
|
+
</td>
|
|
59
|
+
</tr>
|
|
60
|
+
<tr>
|
|
61
|
+
<th>
|
|
62
|
+
Update `postRecord.save()`
|
|
63
|
+
</th>
|
|
64
|
+
<td>
|
|
65
|
+
PATCH
|
|
66
|
+
</td>
|
|
67
|
+
<td>
|
|
68
|
+
/posts/123
|
|
69
|
+
</td>
|
|
70
|
+
</tr>
|
|
71
|
+
<tr>
|
|
72
|
+
<th>
|
|
73
|
+
Create `store.createRecord('post').save()`
|
|
74
|
+
</th>
|
|
75
|
+
<td>
|
|
76
|
+
POST
|
|
77
|
+
</td>
|
|
78
|
+
<td>
|
|
79
|
+
/posts
|
|
80
|
+
</td>
|
|
81
|
+
</tr>
|
|
82
|
+
<tr>
|
|
83
|
+
<th>
|
|
84
|
+
Delete `postRecord.destroyRecord()`
|
|
85
|
+
</th>
|
|
86
|
+
<td>
|
|
87
|
+
DELETE
|
|
88
|
+
</td>
|
|
89
|
+
<td>
|
|
90
|
+
/posts/123
|
|
91
|
+
</td>
|
|
92
|
+
</tr>
|
|
93
|
+
</table>
|
|
94
|
+
|
|
95
|
+
## Success and failure
|
|
96
|
+
|
|
97
|
+
The JSONAPIAdapter will consider a success any response with a
|
|
98
|
+
status code of the 2xx family ("Success"), as well as 304 ("Not
|
|
99
|
+
Modified"). Any other status code will be considered a failure.
|
|
100
|
+
|
|
101
|
+
On success, the request promise will be resolved with the full
|
|
102
|
+
response payload.
|
|
103
|
+
|
|
104
|
+
Failed responses with status code 422 ("Unprocessable Entity") will
|
|
105
|
+
be considered "invalid". The response will be discarded, except for
|
|
106
|
+
the `errors` key. The request promise will be rejected with a
|
|
107
|
+
`InvalidError`. This error object will encapsulate the saved
|
|
108
|
+
`errors` value.
|
|
109
|
+
|
|
110
|
+
Any other status codes will be treated as an adapter error. The
|
|
111
|
+
request promise will be rejected, similarly to the invalid case,
|
|
112
|
+
but with an instance of `AdapterError` instead.
|
|
113
|
+
|
|
114
|
+
### Endpoint path customization
|
|
115
|
+
|
|
116
|
+
Endpoint paths can be prefixed with a `namespace` by setting the
|
|
117
|
+
namespace property on the adapter:
|
|
118
|
+
|
|
119
|
+
```js [app/adapters/application.js]
|
|
120
|
+
import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';
|
|
121
|
+
|
|
122
|
+
export default class ApplicationAdapter extends JSONAPIAdapter {
|
|
123
|
+
namespace = 'api/1';
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
Requests for the `person` model would now target `/api/1/people/1`.
|
|
127
|
+
|
|
128
|
+
### Host customization
|
|
129
|
+
|
|
130
|
+
An adapter can target other hosts by setting the `host` property.
|
|
131
|
+
|
|
132
|
+
```js [app/adapters/application.js]
|
|
133
|
+
import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';
|
|
134
|
+
|
|
135
|
+
export default class ApplicationAdapter extends JSONAPIAdapter {
|
|
136
|
+
host = 'https://api.example.com';
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Requests for the `person` model would now target
|
|
141
|
+
`https://api.example.com/people/1`.
|
|
142
|
+
|
|
143
|
+
@since 1.13.0
|
|
144
|
+
@class JSONAPIAdapter
|
|
145
|
+
@public
|
|
146
|
+
@constructor
|
|
147
|
+
*/
|
|
9
148
|
class JSONAPIAdapter extends RESTAdapter {
|
|
10
149
|
_defaultContentType = 'application/vnd.api+json';
|
|
11
150
|
|
|
@@ -96,11 +235,6 @@ class JSONAPIAdapter extends RESTAdapter {
|
|
|
96
235
|
const data = serializeIntoHash(store, schema, snapshot);
|
|
97
236
|
const type = snapshot.modelName;
|
|
98
237
|
const id = snapshot.id;
|
|
99
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
100
|
-
if (!test) {
|
|
101
|
-
throw new Error(`Attempted to update the ${type} record, but the record has no id`);
|
|
102
|
-
}
|
|
103
|
-
})(typeof id === 'string' && id.length > 0) : {};
|
|
104
238
|
const url = this.buildURL(type, id, snapshot, 'updateRecord');
|
|
105
239
|
return this.ajax(url, 'PATCH', {
|
|
106
240
|
data: data
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { getOwner } from '@ember/application';
|
|
2
|
-
import { warn } from '@ember/debug';
|
|
3
2
|
import { computed } from '@ember/object';
|
|
4
3
|
import { Adapter, BuildURLMixin } from '../adapter.js';
|
|
5
|
-
import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-
|
|
4
|
+
import { b as serializeIntoHash, d as determineBodyPromise, g as getFetchFunction, s as serializeQueryParams, p as parseResponseHeaders } from "../serialize-into-hash-DYU2egXl.js";
|
|
6
5
|
import { InvalidError, ServerError, ConflictError, NotFoundError, ForbiddenError, UnauthorizedError, AdapterError, TimeoutError, AbortError } from './error.js';
|
|
7
|
-
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
8
6
|
import { d as decorateMethodV2 } from "../runtime-BPCpkOf1-BKOwiRJp.js";
|
|
9
7
|
|
|
10
8
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
@@ -569,11 +567,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
569
567
|
findHasMany(store, snapshot, url, relationship) {
|
|
570
568
|
const id = snapshot.id;
|
|
571
569
|
const type = snapshot.modelName;
|
|
572
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
573
|
-
if (!test) {
|
|
574
|
-
throw new Error(`Attempted to fetch the hasMany relationship for ${type}, but the record has no id`);
|
|
575
|
-
}
|
|
576
|
-
})(typeof id === 'string' && id.length > 0) : {};
|
|
577
570
|
url = this.urlPrefix(url, this.buildURL(type, id, snapshot, 'findHasMany'));
|
|
578
571
|
return this.ajax(url, 'GET');
|
|
579
572
|
}
|
|
@@ -603,11 +596,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
603
596
|
findBelongsTo(store, snapshot, url, relationship) {
|
|
604
597
|
const id = snapshot.id;
|
|
605
598
|
const type = snapshot.modelName;
|
|
606
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
607
|
-
if (!test) {
|
|
608
|
-
throw new Error(`Attempted to fetch the belongsTo relationship for ${type}, but the record has no id`);
|
|
609
|
-
}
|
|
610
|
-
})(typeof id === 'string' && id.length > 0) : {};
|
|
611
599
|
url = this.urlPrefix(url, this.buildURL(type, id, snapshot, 'findBelongsTo'));
|
|
612
600
|
return this.ajax(url, 'GET');
|
|
613
601
|
}
|
|
@@ -650,11 +638,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
650
638
|
const data = serializeIntoHash(store, schema, snapshot, {});
|
|
651
639
|
const type = snapshot.modelName;
|
|
652
640
|
const id = snapshot.id;
|
|
653
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
654
|
-
if (!test) {
|
|
655
|
-
throw new Error(`Attempted to update the ${type} record, but the record has no id`);
|
|
656
|
-
}
|
|
657
|
-
})(typeof id === 'string' && id.length > 0) : {};
|
|
658
641
|
const url = this.buildURL(type, id, snapshot, 'updateRecord');
|
|
659
642
|
return this.ajax(url, 'PUT', {
|
|
660
643
|
data
|
|
@@ -673,21 +656,11 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
673
656
|
deleteRecord(store, schema, snapshot) {
|
|
674
657
|
const type = snapshot.modelName;
|
|
675
658
|
const id = snapshot.id;
|
|
676
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
677
|
-
if (!test) {
|
|
678
|
-
throw new Error(`Attempted to delete the ${type} record, but the record has no id`);
|
|
679
|
-
}
|
|
680
|
-
})(typeof id === 'string' && id.length > 0) : {};
|
|
681
659
|
return this.ajax(this.buildURL(type, id, snapshot, 'deleteRecord'), 'DELETE');
|
|
682
660
|
}
|
|
683
661
|
_stripIDFromURL(store, snapshot) {
|
|
684
662
|
const type = snapshot.modelName;
|
|
685
663
|
const id = snapshot.id;
|
|
686
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
687
|
-
if (!test) {
|
|
688
|
-
throw new Error(`Attempted to strip the url from the ${type} record for coalescing, but the record has no id`);
|
|
689
|
-
}
|
|
690
|
-
})(typeof id === 'string' && id.length > 0) : {};
|
|
691
664
|
const url = this.buildURL(type, id, snapshot);
|
|
692
665
|
const expandedURL = url.split('/');
|
|
693
666
|
// Case when the url is of the format ...something/:id
|
|
@@ -868,11 +841,6 @@ class RESTAdapter extends AdapterWithBuildURLMixin {
|
|
|
868
841
|
@param {Object} options jQuery ajax options to be used for the ajax request
|
|
869
842
|
*/
|
|
870
843
|
_ajaxRequest(options) {
|
|
871
|
-
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
872
|
-
if (!test) {
|
|
873
|
-
throw new Error('You must install jQuery globally when `useFetch` is false');
|
|
874
|
-
}
|
|
875
|
-
})(typeof jQuery !== 'undefined') : {};
|
|
876
844
|
void jQuery.ajax(options);
|
|
877
845
|
}
|
|
878
846
|
_fetchRequest(options) {
|
|
@@ -1133,13 +1101,6 @@ function ajaxErrorHandler(adapter, jqXHR, errorThrown, requestData) {
|
|
|
1133
1101
|
const responseData = ajaxResponseData(jqXHR);
|
|
1134
1102
|
responseData.errorThrown = errorThrown;
|
|
1135
1103
|
const payload = adapter.parseErrorResponse(jqXHR.responseText);
|
|
1136
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
1137
|
-
const message = `The server returned an empty string for ${requestData.method} ${requestData.url}, which cannot be parsed into a valid JSON. Return either null or {}.`;
|
|
1138
|
-
const validJSONString = !(responseData.textStatus === 'parsererror' && payload === '');
|
|
1139
|
-
warn(message, validJSONString, {
|
|
1140
|
-
id: 'ds.adapter.returned-empty-string-as-JSON'
|
|
1141
|
-
});
|
|
1142
|
-
}
|
|
1143
1104
|
return ajaxError(adapter, payload, requestData, responseData);
|
|
1144
1105
|
}
|
|
1145
1106
|
function fetchResponseData(response) {
|