@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,770 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ## Overview
|
|
3
|
-
*
|
|
4
|
-
* :::danger
|
|
5
|
-
* ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
6
|
-
* If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
7
|
-
* {@link Handler} instead to be used with the {@link RequestManager}
|
|
8
|
-
* ::::
|
|
9
|
-
*
|
|
10
|
-
* In order to properly fetch and update data, @warp-drive/legacy
|
|
11
|
-
* needs to understand how to connect to your API.
|
|
12
|
-
*
|
|
13
|
-
* `Adapters` accept various kinds of requests from the store
|
|
14
|
-
* and manage fulfillment of the request from your API.
|
|
15
|
-
*
|
|
16
|
-
* ### Request Flow
|
|
17
|
-
*
|
|
18
|
-
* When the store decides it needs to issue a request it uses the following flow to manage the request and process the data.
|
|
19
|
-
*
|
|
20
|
-
* - find the appropriate adapter
|
|
21
|
-
* - issue the request to the adapter
|
|
22
|
-
* - await the adapter's response
|
|
23
|
-
* - if an error occurs reject with the error
|
|
24
|
-
* - if no error
|
|
25
|
-
* - if there is response data
|
|
26
|
-
* - pass the response data to the appropriate serializer
|
|
27
|
-
* - update the cache using the JSON:API formatted data from the serializer's response
|
|
28
|
-
* - return the primary record(s) associated with the request
|
|
29
|
-
*
|
|
30
|
-
* ### Request Errors
|
|
31
|
-
*
|
|
32
|
-
* When a request errors and your adapter does not have the ability to recover from the error,
|
|
33
|
-
* you may either reject the promise returned by your adapter method with the error or simply
|
|
34
|
-
* throw the error.
|
|
35
|
-
*
|
|
36
|
-
* If the request was for a `createRecord` `updateRecord` or `deleteRecord` special rules
|
|
37
|
-
* apply to how this error will affect the state of the store and additional properties on
|
|
38
|
-
* the `Error` class may be used. See the documentation for these methods in
|
|
39
|
-
* {@link MinimumAdapterInterface} for more information.
|
|
40
|
-
*
|
|
41
|
-
* ### Implementing an Adapter
|
|
42
|
-
*
|
|
43
|
-
* There are seven required adapter methods, one for each of
|
|
44
|
-
* the primary request types that @warp-drive/legacy issues.
|
|
45
|
-
*
|
|
46
|
-
* They are:
|
|
47
|
-
*
|
|
48
|
-
* - findRecord
|
|
49
|
-
* - findAll
|
|
50
|
-
* - queryRecord
|
|
51
|
-
* - query
|
|
52
|
-
* - createRecord
|
|
53
|
-
* - updateRecord
|
|
54
|
-
* - deleteRecord
|
|
55
|
-
*
|
|
56
|
-
* Each of these request types has a matching store method that triggers it
|
|
57
|
-
* and matching `requestType` that is passed to the serializer's
|
|
58
|
-
* `normalizeResponse` method.
|
|
59
|
-
*
|
|
60
|
-
* If your app only reads data but never writes data, it is not necessary
|
|
61
|
-
* to implement the methods for create, update, and delete. This extends to
|
|
62
|
-
* all of the store's find methods with the exception of `findRecord` (`findAll`,
|
|
63
|
-
* `query`, `queryRecord`): if you do not use the store method in your app then
|
|
64
|
-
* your Adapter does not need the method.
|
|
65
|
-
*
|
|
66
|
-
* ```ts
|
|
67
|
-
* async function fetchData(url, options = {}) {
|
|
68
|
-
* let response = await fetch(url, options);
|
|
69
|
-
* return response.toJSON();
|
|
70
|
-
* }
|
|
71
|
-
*
|
|
72
|
-
* export default class ApplicationAdapter {
|
|
73
|
-
* findRecord(_, { modelName }, id) {
|
|
74
|
-
* return fetchData(`./${modelName}s/${id}`);
|
|
75
|
-
* }
|
|
76
|
-
*
|
|
77
|
-
* static create() {
|
|
78
|
-
* return new this();
|
|
79
|
-
* }
|
|
80
|
-
* }
|
|
81
|
-
* ```
|
|
82
|
-
*
|
|
83
|
-
* ### Adapter Resolution
|
|
84
|
-
*
|
|
85
|
-
* `store.adapterFor(name)` will lookup adapters defined in `app/adapters/` and
|
|
86
|
-
* return an instance.
|
|
87
|
-
*
|
|
88
|
-
* `adapterFor` first attempts to find an adapter with an exact match on `name`,
|
|
89
|
-
then falls back to checking for the presence of an adapter named `application`.
|
|
90
|
-
|
|
91
|
-
If no adapter is found, an error will be thrown.
|
|
92
|
-
|
|
93
|
-
```ts
|
|
94
|
-
store.adapterFor('author');
|
|
95
|
-
|
|
96
|
-
// lookup paths (in order) =>
|
|
97
|
-
// app/adapters/author.js
|
|
98
|
-
// app/adapters/application.js
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
Most requests in @warp-drive/legacy are made with respect to a particular `type` (or `modelName`)
|
|
102
|
-
(e.g., "get me the full collection of **books**" or "get me the **employee** whose id is 37"). We
|
|
103
|
-
refer to this as the **primary** resource `type`.
|
|
104
|
-
|
|
105
|
-
`adapterFor` is used by the store to find an adapter with a name matching that of the primary
|
|
106
|
-
resource `type` for the request, which then falls back to the `application` adapter.
|
|
107
|
-
|
|
108
|
-
It is recommended that applications define only a single `application` adapter and serializer
|
|
109
|
-
where possible, only implementing an adapter specific to the `type` when absolutely necessary.
|
|
110
|
-
|
|
111
|
-
If you need to support multiple API versions for the same type, the per-type strategy for
|
|
112
|
-
defining adapters might not be adequate.
|
|
113
|
-
|
|
114
|
-
If you have multiple APIs or multiple API versions and the single application adapter and per-type
|
|
115
|
-
strategy does not suite your needs, one strategy is to write an `application` adapter and serializer
|
|
116
|
-
that make use of `options` to specify the desired format when making a request, then forwards to the
|
|
117
|
-
request to the desired adapter or serializer as needed.
|
|
118
|
-
|
|
119
|
-
```js [app/adapters/application.js]
|
|
120
|
-
export default class Adapter extends EmberObject {
|
|
121
|
-
findRecord(store, schema, id, snapshot) {
|
|
122
|
-
let { apiVersion } = snapshot.adapterOptions;
|
|
123
|
-
return this.adapterFor(`-api-${apiVersion}`).findRecord(store, schema, id, snapshot);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### Overriding `Store.adapterFor`
|
|
129
|
-
|
|
130
|
-
```js
|
|
131
|
-
import Store from '@ember-data/store';
|
|
132
|
-
import Adapter from '@ember-data/adapter/json-api';
|
|
133
|
-
|
|
134
|
-
class extends Store {
|
|
135
|
-
#adapter = new Adapter();
|
|
136
|
-
|
|
137
|
-
adapterFor() {
|
|
138
|
-
return this.#adapter;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
Note: If you are using Ember and would like to make use of `service` injections in your adapter, you will want to additionally `setOwner` for the Adapter.
|
|
145
|
-
|
|
146
|
-
```js
|
|
147
|
-
import Store from '@ember-data/store';
|
|
148
|
-
import Adapter from '@ember-data/adapter/json-api';
|
|
149
|
-
import { getOwner, setOwner } from '@ember/owner';
|
|
150
|
-
|
|
151
|
-
class extends Store {
|
|
152
|
-
#adapter = null;
|
|
153
|
-
|
|
154
|
-
adapterFor() {
|
|
155
|
-
let adapter = this.#adapter;
|
|
156
|
-
if (!adapter) {
|
|
157
|
-
const owner = getOwner(this);
|
|
158
|
-
adapter = new Adapter();
|
|
159
|
-
setOwner(adapter, owner);
|
|
160
|
-
this.#adapter = adapter;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return adapter;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
By default when using with Ember you only need to implement this hook if you want your adapter usage to be statically analyzeable. *Ember***Data** will attempt to resolve adapters using Ember's resolver. To provide a single Adapter for your application like the above you would provide it as the default export of the file `app/adapters/application.{js/ts}`
|
|
169
|
-
|
|
170
|
-
### Using an Adapter
|
|
171
|
-
|
|
172
|
-
Any adapter in `app/adapters/` can be looked up by `name` using `store.adapterFor(name)`.
|
|
173
|
-
|
|
174
|
-
### Default Adapters
|
|
175
|
-
|
|
176
|
-
Applications whose API's structure endpoint URLs *very close to* or *exactly* the **REST**
|
|
177
|
-
or **JSON:API** convention, the `@ember-data/adapter` package contains implementations
|
|
178
|
-
these applications can extend.
|
|
179
|
-
|
|
180
|
-
Many applications will find writing their own adapter to be allow greater flexibility,
|
|
181
|
-
customization, and maintenance than attempting to override methods in these adapters.
|
|
182
|
-
|
|
183
|
-
@module
|
|
184
|
-
*/
|
|
185
|
-
import EmberObject from "@ember/object";
|
|
186
|
-
import type { Store } from "@warp-drive/core";
|
|
187
|
-
import type { ModelSchema } from "@warp-drive/core/types";
|
|
188
|
-
import type { AdapterPayload, MinimumAdapterInterface, SerializerOptions } from "./compat.js";
|
|
189
|
-
import type { Snapshot, SnapshotRecordArray } from "./compat/-private.js";
|
|
190
|
-
/**
|
|
191
|
-
An adapter is an object that receives requests from a store and
|
|
192
|
-
translates them into the appropriate action to take against your
|
|
193
|
-
persistence layer. The persistence layer is usually an HTTP API but
|
|
194
|
-
may be anything, such as the browser's local storage. Typically the
|
|
195
|
-
adapter is not invoked directly instead its functionality is accessed
|
|
196
|
-
through the `store`.
|
|
197
|
-
|
|
198
|
-
> ⚠️ CAUTION you likely want the docs for {@link MinimumAdapterInterface}
|
|
199
|
-
> as extending this abstract class is unnecessary.
|
|
200
|
-
|
|
201
|
-
### Creating an Adapter
|
|
202
|
-
|
|
203
|
-
Create a new subclass of `Adapter` in the `app/adapters` folder:
|
|
204
|
-
|
|
205
|
-
```js [app/adapters/application.js]
|
|
206
|
-
import { Adapter } from '@warp-drive/legacy/adapter';
|
|
207
|
-
|
|
208
|
-
export default class extends Adapter {
|
|
209
|
-
// ...your code here
|
|
210
|
-
}
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
Model-specific adapters can be created by putting your adapter
|
|
214
|
-
class in an `app/adapters/` + `model-name` + `.js` file of the application.
|
|
215
|
-
|
|
216
|
-
```js [app/adapters/post.js]
|
|
217
|
-
import { Adapter } from '@warp-drive/legacy/adapter';
|
|
218
|
-
|
|
219
|
-
export default class extends Adapter {
|
|
220
|
-
// ...Post-specific adapter code goes here
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
`Adapter` is an abstract base class that you should override in your
|
|
225
|
-
application to customize it for your backend. The minimum set of methods
|
|
226
|
-
that you should implement is:
|
|
227
|
-
|
|
228
|
-
* `findRecord()`
|
|
229
|
-
* `createRecord()`
|
|
230
|
-
* `updateRecord()`
|
|
231
|
-
* `deleteRecord()`
|
|
232
|
-
* `findAll()`
|
|
233
|
-
* `query()`
|
|
234
|
-
|
|
235
|
-
To improve the network performance of your application, you can optimize
|
|
236
|
-
your adapter by overriding these lower-level methods:
|
|
237
|
-
|
|
238
|
-
* `findMany()`
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
For an example of the implementation, see `RESTAdapter`, the
|
|
242
|
-
included REST adapter.
|
|
243
|
-
|
|
244
|
-
@public
|
|
245
|
-
*/
|
|
246
|
-
export declare class Adapter extends EmberObject implements MinimumAdapterInterface {
|
|
247
|
-
store: Store;
|
|
248
|
-
_coalesceFindRequests: boolean;
|
|
249
|
-
/**
|
|
250
|
-
The `findRecord()` method is invoked when the store is asked for a record that
|
|
251
|
-
has not previously been loaded. In response to `findRecord()` being called, you
|
|
252
|
-
should query your persistence layer for a record with the given ID. The `findRecord`
|
|
253
|
-
method should return a promise that will resolve to a JavaScript object that will be
|
|
254
|
-
normalized by the serializer.
|
|
255
|
-
|
|
256
|
-
Here is an example of the `findRecord` implementation:
|
|
257
|
-
|
|
258
|
-
```js [app/adapters/application.js]
|
|
259
|
-
import { Adapter } from '@warp-drive/legacy/adapter';
|
|
260
|
-
import RSVP from 'RSVP';
|
|
261
|
-
import $ from 'jquery';
|
|
262
|
-
|
|
263
|
-
export default class ApplicationAdapter extends Adapter {
|
|
264
|
-
findRecord(store, type, id, snapshot) {
|
|
265
|
-
return new RSVP.Promise(function(resolve, reject) {
|
|
266
|
-
$.getJSON(`/${type.modelName}/${id}`).then(function(data) {
|
|
267
|
-
resolve(data);
|
|
268
|
-
}, function(jqXHR) {
|
|
269
|
-
reject(jqXHR);
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
@public
|
|
277
|
-
*/
|
|
278
|
-
findRecord(store: Store, type: ModelSchema, id: string, snapshot: Snapshot): Promise<AdapterPayload>;
|
|
279
|
-
/**
|
|
280
|
-
The `findAll()` method is used to retrieve all records for a given type.
|
|
281
|
-
|
|
282
|
-
Example
|
|
283
|
-
|
|
284
|
-
```js [app/adapters/application.js]
|
|
285
|
-
import { Adapter } from '@warp-drive/legacy/adapter';
|
|
286
|
-
import RSVP from 'RSVP';
|
|
287
|
-
import $ from 'jquery';
|
|
288
|
-
|
|
289
|
-
export default class ApplicationAdapter extends Adapter {
|
|
290
|
-
findAll(store, type) {
|
|
291
|
-
return new RSVP.Promise(function(resolve, reject) {
|
|
292
|
-
$.getJSON(`/${type.modelName}`).then(function(data) {
|
|
293
|
-
resolve(data);
|
|
294
|
-
}, function(jqXHR) {
|
|
295
|
-
reject(jqXHR);
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
@param neverSet a value is never provided to this argument
|
|
303
|
-
@public
|
|
304
|
-
*/
|
|
305
|
-
findAll(store: Store, type: ModelSchema, neverSet: null, snapshotRecordArray: SnapshotRecordArray): Promise<AdapterPayload>;
|
|
306
|
-
/**
|
|
307
|
-
This method is called when you call `query` on the store.
|
|
308
|
-
|
|
309
|
-
Example
|
|
310
|
-
|
|
311
|
-
```js [app/adapters/application.js]
|
|
312
|
-
import { Adapter } from '@warp-drive/legacy/adapter';
|
|
313
|
-
import RSVP from 'RSVP';
|
|
314
|
-
import $ from 'jquery';
|
|
315
|
-
|
|
316
|
-
export default class ApplicationAdapter extends Adapter {
|
|
317
|
-
query(store, type, query) {
|
|
318
|
-
return new RSVP.Promise(function(resolve, reject) {
|
|
319
|
-
$.getJSON(`/${type.modelName}`, query).then(function(data) {
|
|
320
|
-
resolve(data);
|
|
321
|
-
}, function(jqXHR) {
|
|
322
|
-
reject(jqXHR);
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
@public
|
|
330
|
-
*/
|
|
331
|
-
query(store: Store, type: ModelSchema, query: Record<string, unknown>): Promise<AdapterPayload>;
|
|
332
|
-
/**
|
|
333
|
-
The `queryRecord()` method is invoked when the store is asked for a single
|
|
334
|
-
record through a query object.
|
|
335
|
-
|
|
336
|
-
In response to `queryRecord()` being called, you should always fetch fresh
|
|
337
|
-
data. Once found, you can asynchronously call the store's `push()` method
|
|
338
|
-
to push the record into the store.
|
|
339
|
-
|
|
340
|
-
Here is an example `queryRecord` implementation:
|
|
341
|
-
|
|
342
|
-
Example
|
|
343
|
-
|
|
344
|
-
```js [app/adapters/application.js]
|
|
345
|
-
import { Adapter, BuildURLMixin } from '@warp-drive/legacy/adapter';
|
|
346
|
-
|
|
347
|
-
export default class ApplicationAdapter extends Adapter.extend(BuildURLMixin) {
|
|
348
|
-
queryRecord(store, type, query) {
|
|
349
|
-
return fetch(`/${type.modelName}`, { body: JSON.stringify(query) })
|
|
350
|
-
.then((response) => response.json());
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
@public
|
|
356
|
-
*/
|
|
357
|
-
queryRecord(store: Store, type: ModelSchema, query: Record<string, unknown>, adapterOptions: object): Promise<AdapterPayload>;
|
|
358
|
-
/**
|
|
359
|
-
If the globally unique IDs for your records should be generated on the client,
|
|
360
|
-
implement the `generateIdForRecord()` method. This method will be invoked
|
|
361
|
-
each time you create a new record, and the value returned from it will be
|
|
362
|
-
assigned to the record's `primaryKey`.
|
|
363
|
-
|
|
364
|
-
Most traditional REST-like HTTP APIs will not use this method. Instead, the ID
|
|
365
|
-
of the record will be set by the server, and your adapter will update the store
|
|
366
|
-
with the new ID when it calls `didCreateRecord()`. Only implement this method if
|
|
367
|
-
you intend to generate record IDs on the client-side.
|
|
368
|
-
|
|
369
|
-
The `generateIdForRecord()` method will be invoked with the requesting store as
|
|
370
|
-
the first parameter and the newly created record as the second parameter:
|
|
371
|
-
|
|
372
|
-
```javascript
|
|
373
|
-
import { Adapter } from '@warp-drive/legacy/adapter';
|
|
374
|
-
import { v4 } from 'uuid';
|
|
375
|
-
|
|
376
|
-
export default class ApplicationAdapter extends Adapter {
|
|
377
|
-
generateIdForRecord(store, type, inputProperties) {
|
|
378
|
-
return v4();
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
@param {Store} store
|
|
384
|
-
@param {Model} type the Model class of the record
|
|
385
|
-
@param {Object} inputProperties a hash of properties to set on the
|
|
386
|
-
newly created record.
|
|
387
|
-
@return {(String|Number)} id
|
|
388
|
-
@public
|
|
389
|
-
*/
|
|
390
|
-
/**
|
|
391
|
-
Proxies to the serializer's `serialize` method.
|
|
392
|
-
|
|
393
|
-
Example
|
|
394
|
-
|
|
395
|
-
```js [app/adapters/application.js]
|
|
396
|
-
import { Adapter } from '@warp-drive/legacy/adapter';
|
|
397
|
-
|
|
398
|
-
export default class ApplicationAdapter extends Adapter {
|
|
399
|
-
createRecord(store, type, snapshot) {
|
|
400
|
-
let data = this.serialize(snapshot, { includeId: true });
|
|
401
|
-
let url = `/${type.modelName}`;
|
|
402
|
-
|
|
403
|
-
// ...
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
@public
|
|
409
|
-
*/
|
|
410
|
-
serialize(snapshot: Snapshot, options: SerializerOptions): Record<string, unknown>;
|
|
411
|
-
/**
|
|
412
|
-
Implement this method in a subclass to handle the creation of
|
|
413
|
-
new records.
|
|
414
|
-
|
|
415
|
-
Serializes the record and sends it to the server.
|
|
416
|
-
|
|
417
|
-
Example
|
|
418
|
-
|
|
419
|
-
```js [app/adapters/application.js]
|
|
420
|
-
import { Adapter } from '@warp-drive/legacy/adapter';
|
|
421
|
-
import RSVP from 'RSVP';
|
|
422
|
-
import $ from 'jquery';
|
|
423
|
-
|
|
424
|
-
export default class ApplicationAdapter extends Adapter {
|
|
425
|
-
createRecord(store, type, snapshot) {
|
|
426
|
-
let data = this.serialize(snapshot, { includeId: true });
|
|
427
|
-
|
|
428
|
-
return new RSVP.Promise(function (resolve, reject) {
|
|
429
|
-
$.ajax({
|
|
430
|
-
type: 'POST',
|
|
431
|
-
url: `/${type.modelName}`,
|
|
432
|
-
dataType: 'json',
|
|
433
|
-
data: data
|
|
434
|
-
}).then(function (data) {
|
|
435
|
-
resolve(data);
|
|
436
|
-
}, function (jqXHR) {
|
|
437
|
-
jqXHR.then = null; // tame jQuery's ill mannered promises
|
|
438
|
-
reject(jqXHR);
|
|
439
|
-
});
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
```
|
|
444
|
-
|
|
445
|
-
@public
|
|
446
|
-
*/
|
|
447
|
-
createRecord(store: Store, type: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
|
|
448
|
-
/**
|
|
449
|
-
Implement this method in a subclass to handle the updating of
|
|
450
|
-
a record.
|
|
451
|
-
|
|
452
|
-
Serializes the record update and sends it to the server.
|
|
453
|
-
|
|
454
|
-
The updateRecord method is expected to return a promise that will
|
|
455
|
-
resolve with the serialized record. This allows the backend to
|
|
456
|
-
inform the Ember Data store the current state of this record after
|
|
457
|
-
the update. If it is not possible to return a serialized record
|
|
458
|
-
the updateRecord promise can also resolve with `undefined` and the
|
|
459
|
-
Ember Data store will assume all of the updates were successfully
|
|
460
|
-
applied on the backend.
|
|
461
|
-
|
|
462
|
-
Example
|
|
463
|
-
|
|
464
|
-
```js [app/adapters/application.js]
|
|
465
|
-
import { Adapter } from '@warp-drive/legacy/adapter';
|
|
466
|
-
import RSVP from 'RSVP';
|
|
467
|
-
import $ from 'jquery';
|
|
468
|
-
|
|
469
|
-
export default class ApplicationAdapter extends Adapter {
|
|
470
|
-
updateRecord(store, type, snapshot) {
|
|
471
|
-
let data = this.serialize(snapshot, { includeId: true });
|
|
472
|
-
let id = snapshot.id;
|
|
473
|
-
|
|
474
|
-
return new RSVP.Promise(function(resolve, reject) {
|
|
475
|
-
$.ajax({
|
|
476
|
-
type: 'PUT',
|
|
477
|
-
url: `/${type.modelName}/${id}`,
|
|
478
|
-
dataType: 'json',
|
|
479
|
-
data: data
|
|
480
|
-
}).then(function(data) {
|
|
481
|
-
resolve(data);
|
|
482
|
-
}, function(jqXHR) {
|
|
483
|
-
jqXHR.then = null; // tame jQuery's ill mannered promises
|
|
484
|
-
reject(jqXHR);
|
|
485
|
-
});
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
```
|
|
490
|
-
|
|
491
|
-
@param {Store} store
|
|
492
|
-
@param {Model} type the Model class of the record
|
|
493
|
-
@param {Snapshot} snapshot
|
|
494
|
-
@return {Promise} promise
|
|
495
|
-
@public
|
|
496
|
-
*/
|
|
497
|
-
updateRecord(store: Store, type: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
|
|
498
|
-
/**
|
|
499
|
-
Implement this method in a subclass to handle the deletion of
|
|
500
|
-
a record.
|
|
501
|
-
|
|
502
|
-
Sends a delete request for the record to the server.
|
|
503
|
-
|
|
504
|
-
Example
|
|
505
|
-
|
|
506
|
-
```js [app/adapters/application.js]
|
|
507
|
-
import { Adapter } from '@warp-drive/legacy/adapter';
|
|
508
|
-
import RSVP from 'RSVP';
|
|
509
|
-
import $ from 'jquery';
|
|
510
|
-
|
|
511
|
-
export default class ApplicationAdapter extends Adapter {
|
|
512
|
-
deleteRecord(store, type, snapshot) {
|
|
513
|
-
let data = this.serialize(snapshot, { includeId: true });
|
|
514
|
-
let id = snapshot.id;
|
|
515
|
-
|
|
516
|
-
return new RSVP.Promise(function(resolve, reject) {
|
|
517
|
-
$.ajax({
|
|
518
|
-
type: 'DELETE',
|
|
519
|
-
url: `/${type.modelName}/${id}`,
|
|
520
|
-
dataType: 'json',
|
|
521
|
-
data: data
|
|
522
|
-
}).then(function(data) {
|
|
523
|
-
resolve(data)
|
|
524
|
-
}, function(jqXHR) {
|
|
525
|
-
jqXHR.then = null; // tame jQuery's ill mannered promises
|
|
526
|
-
reject(jqXHR);
|
|
527
|
-
});
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
```
|
|
532
|
-
|
|
533
|
-
@param {Store} store
|
|
534
|
-
@param {Model} type the Model class of the record
|
|
535
|
-
@param {Snapshot} snapshot
|
|
536
|
-
@return {Promise} promise
|
|
537
|
-
@public
|
|
538
|
-
*/
|
|
539
|
-
deleteRecord(store: Store, type: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
|
|
540
|
-
/**
|
|
541
|
-
By default the store will try to coalesce all `findRecord` calls within the same runloop
|
|
542
|
-
into as few requests as possible by calling groupRecordsForFindMany and passing it into a findMany call.
|
|
543
|
-
You can opt out of this behaviour by either not implementing the findMany hook or by setting
|
|
544
|
-
coalesceFindRequests to false.
|
|
545
|
-
|
|
546
|
-
@property coalesceFindRequests
|
|
547
|
-
@public
|
|
548
|
-
@type {Boolean}
|
|
549
|
-
*/
|
|
550
|
-
get coalesceFindRequests(): boolean;
|
|
551
|
-
set coalesceFindRequests(value: boolean);
|
|
552
|
-
/**
|
|
553
|
-
The store will call `findMany` instead of multiple `findRecord`
|
|
554
|
-
requests to find multiple records at once if coalesceFindRequests
|
|
555
|
-
is true.
|
|
556
|
-
|
|
557
|
-
```js [app/adapters/application.js]
|
|
558
|
-
import { Adapter } from '@warp-drive/legacy/adapter';
|
|
559
|
-
import RSVP from 'RSVP';
|
|
560
|
-
import $ from 'jquery';
|
|
561
|
-
|
|
562
|
-
export default class ApplicationAdapter extends Adapter {
|
|
563
|
-
findMany(store, type, ids, snapshots) {
|
|
564
|
-
return new RSVP.Promise(function(resolve, reject) {
|
|
565
|
-
$.ajax({
|
|
566
|
-
type: 'GET',
|
|
567
|
-
url: `/${type.modelName}/`,
|
|
568
|
-
dataType: 'json',
|
|
569
|
-
data: { filter: { id: ids.join(',') } }
|
|
570
|
-
}).then(function(data) {
|
|
571
|
-
resolve(data);
|
|
572
|
-
}, function(jqXHR) {
|
|
573
|
-
jqXHR.then = null; // tame jQuery's ill mannered promises
|
|
574
|
-
reject(jqXHR);
|
|
575
|
-
});
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
```
|
|
580
|
-
|
|
581
|
-
@param {Store} store
|
|
582
|
-
@param {Model} type the Model class of the records
|
|
583
|
-
@param {Array} ids
|
|
584
|
-
@param {Array} snapshots
|
|
585
|
-
@return {Promise} promise
|
|
586
|
-
@public
|
|
587
|
-
*/
|
|
588
|
-
/**
|
|
589
|
-
Organize records into groups, each of which is to be passed to separate
|
|
590
|
-
calls to `findMany`.
|
|
591
|
-
|
|
592
|
-
For example, if your API has nested URLs that depend on the parent, you will
|
|
593
|
-
want to group records by their parent.
|
|
594
|
-
|
|
595
|
-
The default implementation returns the records as a single group.
|
|
596
|
-
|
|
597
|
-
@public
|
|
598
|
-
@param {Store} store
|
|
599
|
-
@param {Array} snapshots
|
|
600
|
-
@return {Array} an array of arrays of records, each of which is to be
|
|
601
|
-
loaded separately by `findMany`.
|
|
602
|
-
*/
|
|
603
|
-
groupRecordsForFindMany(store: Store, snapshots: Snapshot[]): Snapshot[][];
|
|
604
|
-
/**
|
|
605
|
-
This method is used by the store to determine if the store should
|
|
606
|
-
reload a record from the adapter when a record is requested by
|
|
607
|
-
`store.findRecord`.
|
|
608
|
-
|
|
609
|
-
If this method returns `true`, the store will re-fetch a record from
|
|
610
|
-
the adapter. If this method returns `false`, the store will resolve
|
|
611
|
-
immediately using the cached record.
|
|
612
|
-
|
|
613
|
-
For example, if you are building an events ticketing system, in which users
|
|
614
|
-
can only reserve tickets for 20 minutes at a time, and want to ensure that
|
|
615
|
-
in each route you have data that is no more than 20 minutes old you could
|
|
616
|
-
write:
|
|
617
|
-
|
|
618
|
-
```javascript
|
|
619
|
-
shouldReloadRecord(store, ticketSnapshot) {
|
|
620
|
-
let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt');
|
|
621
|
-
let timeDiff = moment().diff(lastAccessedAt, 'minutes');
|
|
622
|
-
|
|
623
|
-
if (timeDiff > 20) {
|
|
624
|
-
return true;
|
|
625
|
-
} else {
|
|
626
|
-
return false;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
```
|
|
630
|
-
|
|
631
|
-
This method would ensure that whenever you do `store.findRecord('ticket',
|
|
632
|
-
id)` you will always get a ticket that is no more than 20 minutes old. In
|
|
633
|
-
case the cached version is more than 20 minutes old, `findRecord` will not
|
|
634
|
-
resolve until you fetched the latest version.
|
|
635
|
-
|
|
636
|
-
By default this hook returns `false`, as most UIs should not block user
|
|
637
|
-
interactions while waiting on data update.
|
|
638
|
-
|
|
639
|
-
Note that, with default settings, `shouldBackgroundReloadRecord` will always
|
|
640
|
-
re-fetch the records in the background even if `shouldReloadRecord` returns
|
|
641
|
-
`false`. You can override `shouldBackgroundReloadRecord` if this does not
|
|
642
|
-
suit your use case.
|
|
643
|
-
|
|
644
|
-
@since 1.13.0
|
|
645
|
-
@param {Store} store
|
|
646
|
-
@param {Snapshot} snapshot
|
|
647
|
-
@return {Boolean}
|
|
648
|
-
@public
|
|
649
|
-
*/
|
|
650
|
-
shouldReloadRecord(store: Store, snapshot: Snapshot): boolean;
|
|
651
|
-
/**
|
|
652
|
-
This method is used by the store to determine if the store should
|
|
653
|
-
reload all records from the adapter when records are requested by
|
|
654
|
-
`store.findAll`.
|
|
655
|
-
|
|
656
|
-
If this method returns `true`, the store will re-fetch all records from
|
|
657
|
-
the adapter. If this method returns `false`, the store will resolve
|
|
658
|
-
immediately using the cached records.
|
|
659
|
-
|
|
660
|
-
For example, if you are building an events ticketing system, in which users
|
|
661
|
-
can only reserve tickets for 20 minutes at a time, and want to ensure that
|
|
662
|
-
in each route you have data that is no more than 20 minutes old you could
|
|
663
|
-
write:
|
|
664
|
-
|
|
665
|
-
```javascript
|
|
666
|
-
shouldReloadAll(store, snapshotArray) {
|
|
667
|
-
let snapshots = snapshotArray.snapshots();
|
|
668
|
-
|
|
669
|
-
return snapshots.any((ticketSnapshot) => {
|
|
670
|
-
let lastAccessedAt = ticketSnapshot.attr('lastAccessedAt');
|
|
671
|
-
let timeDiff = moment().diff(lastAccessedAt, 'minutes');
|
|
672
|
-
|
|
673
|
-
if (timeDiff > 20) {
|
|
674
|
-
return true;
|
|
675
|
-
} else {
|
|
676
|
-
return false;
|
|
677
|
-
}
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
```
|
|
681
|
-
|
|
682
|
-
This method would ensure that whenever you do `store.findAll('ticket')` you
|
|
683
|
-
will always get a list of tickets that are no more than 20 minutes old. In
|
|
684
|
-
case a cached version is more than 20 minutes old, `findAll` will not
|
|
685
|
-
resolve until you fetched the latest versions.
|
|
686
|
-
|
|
687
|
-
By default, this method returns `true` if the passed `snapshotRecordArray`
|
|
688
|
-
is empty (meaning that there are no records locally available yet),
|
|
689
|
-
otherwise, it returns `false`.
|
|
690
|
-
|
|
691
|
-
Note that, with default settings, `shouldBackgroundReloadAll` will always
|
|
692
|
-
re-fetch all the records in the background even if `shouldReloadAll` returns
|
|
693
|
-
`false`. You can override `shouldBackgroundReloadAll` if this does not suit
|
|
694
|
-
your use case.
|
|
695
|
-
|
|
696
|
-
@since 1.13.0
|
|
697
|
-
@param {Store} store
|
|
698
|
-
@param {SnapshotRecordArray} snapshotRecordArray
|
|
699
|
-
@return {Boolean}
|
|
700
|
-
@public
|
|
701
|
-
*/
|
|
702
|
-
shouldReloadAll(store: Store, snapshotRecordArray: SnapshotRecordArray): boolean;
|
|
703
|
-
/**
|
|
704
|
-
This method is used by the store to determine if the store should
|
|
705
|
-
reload a record after the `store.findRecord` method resolves a
|
|
706
|
-
cached record.
|
|
707
|
-
|
|
708
|
-
This method is *only* checked by the store when the store is
|
|
709
|
-
returning a cached record.
|
|
710
|
-
|
|
711
|
-
If this method returns `true` the store will re-fetch a record from
|
|
712
|
-
the adapter.
|
|
713
|
-
|
|
714
|
-
For example, if you do not want to fetch complex data over a mobile
|
|
715
|
-
connection, or if the network is down, you can implement
|
|
716
|
-
`shouldBackgroundReloadRecord` as follows:
|
|
717
|
-
|
|
718
|
-
```javascript
|
|
719
|
-
shouldBackgroundReloadRecord(store, snapshot) {
|
|
720
|
-
let { downlink, effectiveType } = navigator.connection;
|
|
721
|
-
|
|
722
|
-
return downlink > 0 && effectiveType === '4g';
|
|
723
|
-
}
|
|
724
|
-
```
|
|
725
|
-
|
|
726
|
-
By default, this hook returns `true` so the data for the record is updated
|
|
727
|
-
in the background.
|
|
728
|
-
|
|
729
|
-
@since 1.13.0
|
|
730
|
-
@param {Store} store
|
|
731
|
-
@param {Snapshot} snapshot
|
|
732
|
-
@return {Boolean}
|
|
733
|
-
@public
|
|
734
|
-
*/
|
|
735
|
-
shouldBackgroundReloadRecord(store: Store, snapshot: Snapshot): boolean;
|
|
736
|
-
/**
|
|
737
|
-
This method is used by the store to determine if the store should
|
|
738
|
-
reload a record array after the `store.findAll` method resolves
|
|
739
|
-
with a cached record array.
|
|
740
|
-
|
|
741
|
-
This method is *only* checked by the store when the store is
|
|
742
|
-
returning a cached record array.
|
|
743
|
-
|
|
744
|
-
If this method returns `true` the store will re-fetch all records
|
|
745
|
-
from the adapter.
|
|
746
|
-
|
|
747
|
-
For example, if you do not want to fetch complex data over a mobile
|
|
748
|
-
connection, or if the network is down, you can implement
|
|
749
|
-
`shouldBackgroundReloadAll` as follows:
|
|
750
|
-
|
|
751
|
-
```javascript
|
|
752
|
-
shouldBackgroundReloadAll(store, snapshotArray) {
|
|
753
|
-
let { downlink, effectiveType } = navigator.connection;
|
|
754
|
-
|
|
755
|
-
return downlink > 0 && effectiveType === '4g';
|
|
756
|
-
}
|
|
757
|
-
```
|
|
758
|
-
|
|
759
|
-
By default this method returns `true`, indicating that a background reload
|
|
760
|
-
should always be triggered.
|
|
761
|
-
|
|
762
|
-
@since 1.13.0
|
|
763
|
-
@param {Store} store
|
|
764
|
-
@param {SnapshotRecordArray} snapshotRecordArray
|
|
765
|
-
@return {Boolean}
|
|
766
|
-
@public
|
|
767
|
-
*/
|
|
768
|
-
shouldBackgroundReloadAll(store: Store, snapshotRecordArray: SnapshotRecordArray): boolean;
|
|
769
|
-
}
|
|
770
|
-
export { BuildURLMixin } from "./adapter/-private/build-url-mixin.js";
|