@warp-drive/legacy 5.10.0-alpha.2 → 5.10.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -8
- package/blueprints/adapter/files/__root__/__path__/__name__.js +1 -0
- package/blueprints/adapter/index.js +27 -0
- package/blueprints/adapter-test/index.js +33 -0
- package/blueprints/adapter-test/qunit-files/__root__/__path__/__test__.js +1 -0
- package/blueprints/model/HELP.md +26 -0
- package/blueprints/model/files/__root__/__path__/__name__.js +1 -0
- package/blueprints/model/index.js +27 -0
- package/blueprints/model-test/index.js +33 -0
- package/blueprints/model-test/qunit-files/__root__/__path__/__test__.js +1 -0
- package/blueprints/serializer/files/__root__/__path__/__name__.js +1 -0
- package/blueprints/serializer/index.js +27 -0
- package/blueprints/serializer-test/index.js +33 -0
- package/blueprints/serializer-test/qunit-files/__root__/__path__/__test__.js +1 -0
- package/blueprints/transform/files/__root__/__path__/__name__.js +1 -0
- package/blueprints/transform/index.js +17 -0
- package/blueprints/transform-test/index.js +33 -0
- package/blueprints/transform-test/qunit-files/__root__/__path__/__test__.js +1 -0
- package/dist/{-private-DccRZQsm.js → -private-0_Oc-M3x.js} +10 -17
- package/dist/-private-0_Oc-M3x.js.map +1 -0
- package/dist/{-private-DQ6Iap2t.js → -private-L2BtGGYa.js} +8 -14
- package/dist/{-private-DQ6Iap2t.js.map → -private-L2BtGGYa.js.map} +1 -1
- package/dist/adapter/-private.d.ts +2 -12
- package/dist/adapter/-private.d.ts.map +1 -1
- package/dist/adapter/-private.js +1 -1
- package/dist/adapter/error.d.ts +1 -1
- package/dist/adapter/error.js +54 -2
- package/dist/adapter/error.js.map +1 -1
- package/dist/adapter/json-api.d.ts +5 -5
- package/dist/adapter/json-api.d.ts.map +1 -1
- package/dist/adapter/json-api.js +10 -4
- package/dist/adapter/json-api.js.map +1 -1
- package/dist/adapter/rest.d.ts +1 -1
- package/dist/adapter/rest.js +23 -5
- package/dist/adapter/rest.js.map +1 -1
- package/dist/{adapter-eYo2pIuM.js → adapter-AwGvdMSZ.js} +45 -6
- package/dist/adapter-AwGvdMSZ.js.map +1 -0
- package/dist/{adapter-CARrK3-8.d.ts → adapter-DvDVeaCc.d.ts} +9 -6
- package/dist/adapter-DvDVeaCc.d.ts.map +1 -0
- package/dist/adapter.d.ts +1 -1
- package/dist/adapter.js +1 -1
- package/dist/compat/-private.d.ts +1 -1
- package/dist/compat/-private.js +1 -1
- package/dist/compat/builders.d.ts +10 -8
- package/dist/compat/builders.d.ts.map +1 -1
- package/dist/compat/builders.js +15 -9
- package/dist/compat/builders.js.map +1 -1
- package/dist/compat/extensions.d.ts +1 -1
- package/dist/compat/extensions.js +23 -2
- package/dist/compat/extensions.js.map +1 -1
- package/dist/compat/utils.d.ts +17 -2
- package/dist/compat/utils.d.ts.map +1 -1
- package/dist/compat/utils.js +19 -2
- package/dist/compat/utils.js.map +1 -1
- package/dist/{compat-DcHVxuuZ.js → compat-C-yQnbkF.js} +61 -8
- package/dist/compat-C-yQnbkF.js.map +1 -0
- package/dist/{compat-BbNNmTM-.d.ts → compat-DoWEarkU.d.ts} +30 -17
- package/dist/compat-DoWEarkU.d.ts.map +1 -0
- package/dist/compat.d.ts +1 -1
- package/dist/compat.js +1 -1
- package/dist/{error-CzkyXr1Q.d.ts → error-798wGD3r.d.ts} +49 -3
- package/dist/error-798wGD3r.d.ts.map +1 -0
- package/dist/{errors-CS110tMl.js → errors-BEExAZtv.js} +42 -32
- package/dist/errors-BEExAZtv.js.map +1 -0
- package/dist/{extensions-DumNm4dA.d.ts → extensions-DcEz1lKv.d.ts} +18 -3
- package/dist/extensions-DcEz1lKv.d.ts.map +1 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -7
- package/dist/index.js.map +1 -1
- package/dist/{json-BXNPTlcH.js → json-Baaga4BP.js} +10 -5
- package/dist/json-Baaga4BP.js.map +1 -0
- package/dist/model/-private.d.ts +1 -1
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.d.ts +19 -4
- package/dist/model/migration-support.d.ts.map +1 -1
- package/dist/model/migration-support.js +25 -7
- package/dist/model/migration-support.js.map +1 -1
- package/dist/{model-DWH9f__L.js → model-Be-e84FX.js} +19 -12
- package/dist/model-Be-e84FX.js.map +1 -0
- package/dist/{model-62hn5_PD.d.ts → model-DAdY1ibr.d.ts} +13 -26
- package/dist/model-DAdY1ibr.d.ts.map +1 -0
- package/dist/{unpkg/dev-deprecated/model-fragments-DSqu0ptR.js → model-fragments-DCHMDr5f.js} +32 -18
- package/dist/model-fragments-DCHMDr5f.js.map +1 -0
- package/dist/model-fragments.d.ts +31 -19
- package/dist/model-fragments.d.ts.map +1 -1
- package/dist/model-fragments.js +1 -1
- package/dist/model.d.ts +12 -11
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +2 -2
- package/dist/{rest-0NhtexIq.d.ts → rest-CmFneLJH.d.ts} +18 -8
- package/dist/rest-CmFneLJH.d.ts.map +1 -0
- package/dist/{runtime--fcdnjmJ-DMTJ0Kb3.js → runtime--fcdnjmJ-5yaSpa-d.js} +2 -3
- package/dist/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
- package/dist/{schema-provider-DguGmQDS.js → schema-provider-BAB8DyMr.js} +22 -21
- package/dist/schema-provider-BAB8DyMr.js.map +1 -0
- package/dist/serializer/json-api.d.ts +1 -2
- package/dist/serializer/json-api.d.ts.map +1 -1
- package/dist/serializer/json-api.js +7 -3
- package/dist/serializer/json-api.js.map +1 -1
- package/dist/serializer/json.d.ts +2 -2
- package/dist/serializer/json.d.ts.map +1 -1
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.d.ts +4 -4
- package/dist/serializer/rest.d.ts.map +1 -1
- package/dist/serializer/rest.js +12 -5
- package/dist/serializer/rest.js.map +1 -1
- package/dist/serializer/transform.d.ts +9 -10
- package/dist/serializer/transform.d.ts.map +1 -1
- package/dist/serializer/transform.js +14 -10
- package/dist/serializer/transform.js.map +1 -1
- package/dist/serializer.d.ts +2 -2
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +42 -3
- package/dist/serializer.js.map +1 -1
- package/dist/{store-C4qYzXei.js → store-BLKEsJyw.js} +13 -7
- package/dist/store-BLKEsJyw.js.map +1 -0
- package/dist/store.d.ts +3 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +1 -1
- package/dist/unpkg/dev/{-private-CrEyBE-B.js → -private-BprUAEe_.js} +8 -14
- package/dist/unpkg/{dev-deprecated/-private-CrEyBE-B.js.map → dev/-private-BprUAEe_.js.map} +1 -1
- package/dist/unpkg/dev/{-private-vOhxVExH.js → -private-Dch4SxkU.js} +10 -17
- package/dist/unpkg/dev/-private-Dch4SxkU.js.map +1 -0
- package/dist/unpkg/dev/adapter/-private.js +1 -1
- package/dist/unpkg/dev/adapter/error.js +54 -2
- package/dist/unpkg/dev/adapter/error.js.map +1 -1
- package/dist/unpkg/dev/adapter/json-api.js +10 -4
- package/dist/unpkg/dev/adapter/json-api.js.map +1 -1
- package/dist/unpkg/dev/adapter/rest.js +23 -5
- package/dist/unpkg/dev/adapter/rest.js.map +1 -1
- package/dist/unpkg/dev/{adapter-oLwyr47q.js → adapter-BAn4SeUA.js} +45 -6
- package/dist/unpkg/dev/adapter-BAn4SeUA.js.map +1 -0
- package/dist/unpkg/dev/adapter.js +1 -1
- package/dist/unpkg/dev/compat/-private.js +1 -1
- package/dist/unpkg/dev/compat/builders.js +15 -9
- package/dist/unpkg/dev/compat/builders.js.map +1 -1
- package/dist/unpkg/dev/compat/extensions.js +23 -2
- package/dist/unpkg/dev/compat/extensions.js.map +1 -1
- package/dist/unpkg/dev/compat/utils.js +19 -2
- package/dist/unpkg/dev/compat/utils.js.map +1 -1
- package/dist/unpkg/dev/{compat-DNQT2TQx.js → compat-BdovRRzQ.js} +62 -10
- package/dist/unpkg/dev/compat-BdovRRzQ.js.map +1 -0
- package/dist/unpkg/dev/compat.js +1 -1
- package/dist/unpkg/dev/{errors-DnzvLM2A.js → errors-CGvbM6WH.js} +42 -32
- package/dist/unpkg/dev/errors-CGvbM6WH.js.map +1 -0
- package/dist/unpkg/dev/index.js +25 -7
- package/dist/unpkg/dev/index.js.map +1 -1
- package/dist/unpkg/{dev-deprecated/json-DDJji3V3.js → dev/json-BlSBe84o.js} +10 -5
- package/dist/unpkg/dev/json-BlSBe84o.js.map +1 -0
- package/dist/unpkg/dev/model/-private.js +1 -1
- package/dist/unpkg/dev/model/migration-support.js +24 -6
- package/dist/unpkg/dev/model/migration-support.js.map +1 -1
- package/dist/unpkg/dev/{model-BxPIR7m2.js → model-QCZr8eec.js} +19 -12
- package/dist/unpkg/dev/model-QCZr8eec.js.map +1 -0
- package/dist/{model-fragments-DSqu0ptR.js → unpkg/dev/model-fragments-DCHMDr5f.js} +32 -18
- package/dist/unpkg/dev/model-fragments-DCHMDr5f.js.map +1 -0
- package/dist/unpkg/dev/model-fragments.js +1 -1
- package/dist/unpkg/dev/model.js +2 -2
- package/dist/unpkg/dev/{runtime--fcdnjmJ-DMTJ0Kb3.js → runtime--fcdnjmJ-5yaSpa-d.js} +2 -3
- package/dist/unpkg/dev/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
- package/dist/unpkg/dev/{schema-provider-CI_a48ja.js → schema-provider-IMFO9Kgw.js} +18 -17
- package/dist/unpkg/dev/schema-provider-IMFO9Kgw.js.map +1 -0
- package/dist/unpkg/dev/serializer/json-api.js +7 -3
- package/dist/unpkg/dev/serializer/json-api.js.map +1 -1
- package/dist/unpkg/dev/serializer/json.js +1 -1
- package/dist/unpkg/dev/serializer/rest.js +12 -5
- package/dist/unpkg/dev/serializer/rest.js.map +1 -1
- package/dist/unpkg/dev/serializer/transform.js +14 -10
- package/dist/unpkg/dev/serializer/transform.js.map +1 -1
- package/dist/unpkg/dev/serializer.js +42 -3
- package/dist/unpkg/dev/serializer.js.map +1 -1
- package/dist/unpkg/dev/{store-D_V8-HQl.js → store-BiXsLLAu.js} +13 -7
- package/dist/unpkg/dev/store-BiXsLLAu.js.map +1 -0
- package/dist/unpkg/dev/store.js +1 -1
- package/dist/unpkg/dev/{util-dSKEgQDp.js → util-CI7b4vAE.js} +2 -3
- package/dist/unpkg/dev/{util-dSKEgQDp.js.map → util-CI7b4vAE.js.map} +1 -1
- package/dist/unpkg/{prod/utils-DYC9utVJ.js → dev/utils-_O0MjUTU.js} +2 -3
- package/dist/unpkg/dev/{utils-DYC9utVJ.js.map → utils-_O0MjUTU.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/{-private-CrEyBE-B.js → -private-BprUAEe_.js} +8 -14
- package/dist/unpkg/{dev/-private-CrEyBE-B.js.map → dev-deprecated/-private-BprUAEe_.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/{-private-vOhxVExH.js → -private-Dch4SxkU.js} +10 -17
- package/dist/unpkg/dev-deprecated/-private-Dch4SxkU.js.map +1 -0
- package/dist/unpkg/dev-deprecated/adapter/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/adapter/error.js +54 -2
- package/dist/unpkg/dev-deprecated/adapter/error.js.map +1 -1
- package/dist/unpkg/dev-deprecated/adapter/json-api.js +10 -4
- package/dist/unpkg/dev-deprecated/adapter/json-api.js.map +1 -1
- package/dist/unpkg/dev-deprecated/adapter/rest.js +23 -5
- package/dist/unpkg/dev-deprecated/adapter/rest.js.map +1 -1
- package/dist/unpkg/dev-deprecated/{adapter-oLwyr47q.js → adapter-BAn4SeUA.js} +45 -6
- package/dist/unpkg/dev-deprecated/adapter-BAn4SeUA.js.map +1 -0
- package/dist/unpkg/dev-deprecated/adapter.js +1 -1
- package/dist/unpkg/dev-deprecated/compat/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/compat/builders.js +15 -9
- package/dist/unpkg/dev-deprecated/compat/builders.js.map +1 -1
- package/dist/unpkg/dev-deprecated/compat/extensions.js +23 -2
- package/dist/unpkg/dev-deprecated/compat/extensions.js.map +1 -1
- package/dist/unpkg/dev-deprecated/compat/utils.js +19 -2
- package/dist/unpkg/dev-deprecated/compat/utils.js.map +1 -1
- package/dist/unpkg/dev-deprecated/{compat-CeT0PnVX.js → compat-CPVriwH0.js} +62 -10
- package/dist/unpkg/dev-deprecated/compat-CPVriwH0.js.map +1 -0
- package/dist/unpkg/dev-deprecated/compat.js +1 -1
- package/dist/unpkg/dev-deprecated/{errors-jHQESeNQ.js → errors-yPc7D7r3.js} +42 -32
- package/dist/unpkg/dev-deprecated/errors-yPc7D7r3.js.map +1 -0
- package/dist/unpkg/dev-deprecated/index.js +25 -7
- package/dist/unpkg/dev-deprecated/index.js.map +1 -1
- package/dist/unpkg/{dev/json-DDJji3V3.js → dev-deprecated/json-BlSBe84o.js} +10 -5
- package/dist/unpkg/dev-deprecated/json-BlSBe84o.js.map +1 -0
- package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/model/migration-support.js +24 -6
- package/dist/unpkg/dev-deprecated/model/migration-support.js.map +1 -1
- package/dist/unpkg/dev-deprecated/{model-BeGORt6h.js → model-B0ZNLaHO.js} +19 -12
- package/dist/unpkg/dev-deprecated/model-B0ZNLaHO.js.map +1 -0
- package/dist/unpkg/{prod-deprecated/model-fragments-DSqu0ptR.js → dev-deprecated/model-fragments-DCHMDr5f.js} +32 -18
- package/dist/unpkg/dev-deprecated/model-fragments-DCHMDr5f.js.map +1 -0
- package/dist/unpkg/dev-deprecated/model-fragments.js +1 -1
- package/dist/unpkg/dev-deprecated/model.js +2 -2
- package/dist/unpkg/dev-deprecated/{runtime--fcdnjmJ-DMTJ0Kb3.js → runtime--fcdnjmJ-5yaSpa-d.js} +2 -3
- package/dist/unpkg/dev-deprecated/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/{schema-provider-NmtdR4n_.js → schema-provider-DGWYnFno.js} +18 -17
- package/dist/unpkg/dev-deprecated/schema-provider-DGWYnFno.js.map +1 -0
- package/dist/unpkg/dev-deprecated/serializer/json-api.js +7 -3
- package/dist/unpkg/dev-deprecated/serializer/json-api.js.map +1 -1
- package/dist/unpkg/dev-deprecated/serializer/json.js +1 -1
- package/dist/unpkg/dev-deprecated/serializer/rest.js +12 -5
- package/dist/unpkg/dev-deprecated/serializer/rest.js.map +1 -1
- package/dist/unpkg/dev-deprecated/serializer/transform.js +14 -10
- package/dist/unpkg/dev-deprecated/serializer/transform.js.map +1 -1
- package/dist/unpkg/dev-deprecated/serializer.js +42 -3
- package/dist/unpkg/dev-deprecated/serializer.js.map +1 -1
- package/dist/unpkg/dev-deprecated/{store-BCOLSC6z.js → store-Ci8k7Lh6.js} +13 -7
- package/dist/unpkg/dev-deprecated/store-Ci8k7Lh6.js.map +1 -0
- package/dist/unpkg/dev-deprecated/store.js +1 -1
- package/dist/unpkg/dev-deprecated/{util-CXA3RNYH.js → util-DL_8JecH.js} +2 -3
- package/dist/unpkg/dev-deprecated/{util-CXA3RNYH.js.map → util-DL_8JecH.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/{utils-DQkMqhDv.js → utils-DyGjRZ14.js} +2 -3
- package/dist/unpkg/dev-deprecated/{utils-DQkMqhDv.js.map → utils-DyGjRZ14.js.map} +1 -1
- package/dist/unpkg/{prod-deprecated/-private-B4bxoTuK.js → prod/-private-Dc9yg98O.js} +8 -14
- package/dist/unpkg/{prod-deprecated/-private-B4bxoTuK.js.map → prod/-private-Dc9yg98O.js.map} +1 -1
- package/dist/unpkg/prod/{-private-SfXkkHKd.js → -private-DuRzYAyW.js} +9 -15
- package/dist/unpkg/prod/-private-DuRzYAyW.js.map +1 -0
- package/dist/unpkg/prod/adapter/-private.js +1 -1
- package/dist/unpkg/prod/adapter/error.js +54 -2
- package/dist/unpkg/prod/adapter/error.js.map +1 -1
- package/dist/unpkg/prod/adapter/json-api.js +10 -4
- package/dist/unpkg/prod/adapter/json-api.js.map +1 -1
- package/dist/unpkg/prod/adapter/rest.js +23 -5
- package/dist/unpkg/prod/adapter/rest.js.map +1 -1
- package/dist/unpkg/prod/{adapter-DQ9UA7FC.js → adapter-D0HCLrwm.js} +45 -6
- package/dist/unpkg/prod/adapter-D0HCLrwm.js.map +1 -0
- package/dist/unpkg/prod/adapter.js +1 -1
- package/dist/unpkg/prod/compat/-private.js +1 -1
- package/dist/unpkg/prod/compat/builders.js +15 -9
- package/dist/unpkg/prod/compat/builders.js.map +1 -1
- package/dist/unpkg/prod/compat/extensions.js +23 -2
- package/dist/unpkg/prod/compat/extensions.js.map +1 -1
- package/dist/unpkg/prod/compat/utils.js +19 -2
- package/dist/unpkg/prod/compat/utils.js.map +1 -1
- package/dist/unpkg/{prod-deprecated/compat-DxiVkCUb.js → prod/compat-PrUuencH.js} +62 -10
- package/dist/unpkg/prod/compat-PrUuencH.js.map +1 -0
- package/dist/unpkg/prod/compat.js +1 -1
- package/dist/unpkg/prod/{errors-DQDfNqVx.js → errors-Bw8niCo8.js} +38 -27
- package/dist/unpkg/prod/errors-Bw8niCo8.js.map +1 -0
- package/dist/unpkg/prod/index.js +25 -7
- package/dist/unpkg/prod/index.js.map +1 -1
- package/dist/unpkg/prod/{json-BD1kRTfB.js → json-D1bH8enA.js} +10 -5
- package/dist/unpkg/prod/json-D1bH8enA.js.map +1 -0
- package/dist/unpkg/prod/model/-private.js +1 -1
- package/dist/unpkg/prod/model/migration-support.js +24 -6
- package/dist/unpkg/prod/model/migration-support.js.map +1 -1
- package/dist/unpkg/prod/{model-CYMA-e_S.js → model-QtC0IWbE.js} +19 -12
- package/dist/unpkg/prod/model-QtC0IWbE.js.map +1 -0
- package/dist/unpkg/prod/model-fragments-DCHMDr5f.js +348 -0
- package/dist/unpkg/prod/model-fragments-DCHMDr5f.js.map +1 -0
- package/dist/unpkg/prod/model-fragments.js +1 -1
- package/dist/unpkg/prod/model.js +2 -2
- package/dist/unpkg/prod/runtime--fcdnjmJ-5yaSpa-d.js +52 -0
- package/dist/unpkg/prod/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
- package/dist/unpkg/prod/{schema-provider-05U1H-Kl.js → schema-provider-DPOzTa8e.js} +18 -17
- package/dist/unpkg/prod/schema-provider-DPOzTa8e.js.map +1 -0
- package/dist/unpkg/prod/serializer/json-api.js +7 -3
- package/dist/unpkg/prod/serializer/json-api.js.map +1 -1
- package/dist/unpkg/prod/serializer/json.js +1 -1
- package/dist/unpkg/prod/serializer/rest.js +12 -5
- package/dist/unpkg/prod/serializer/rest.js.map +1 -1
- package/dist/unpkg/prod/serializer/transform.js +14 -10
- package/dist/unpkg/prod/serializer/transform.js.map +1 -1
- package/dist/unpkg/prod/serializer.js +42 -3
- package/dist/unpkg/prod/serializer.js.map +1 -1
- package/dist/unpkg/{prod-deprecated/store-0L2CkYzh.js → prod/store-BsSkzWgk.js} +13 -7
- package/dist/unpkg/{prod-deprecated/store-0L2CkYzh.js.map → prod/store-BsSkzWgk.js.map} +1 -1
- package/dist/unpkg/prod/store.js +1 -1
- package/dist/unpkg/prod/{util-dSKEgQDp.js → util-CI7b4vAE.js} +2 -3
- package/dist/unpkg/prod/{util-dSKEgQDp.js.map → util-CI7b4vAE.js.map} +1 -1
- package/dist/unpkg/{dev/utils-DYC9utVJ.js → prod/utils-_O0MjUTU.js} +2 -3
- package/dist/unpkg/prod/{utils-DYC9utVJ.js.map → utils-_O0MjUTU.js.map} +1 -1
- package/dist/unpkg/{prod/-private-B4bxoTuK.js → prod-deprecated/-private-Dc9yg98O.js} +8 -14
- package/dist/unpkg/{prod/-private-B4bxoTuK.js.map → prod-deprecated/-private-Dc9yg98O.js.map} +1 -1
- package/dist/unpkg/prod-deprecated/{-private-SfXkkHKd.js → -private-DuRzYAyW.js} +9 -15
- package/dist/unpkg/prod-deprecated/-private-DuRzYAyW.js.map +1 -0
- package/dist/unpkg/prod-deprecated/adapter/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/adapter/error.js +54 -2
- package/dist/unpkg/prod-deprecated/adapter/error.js.map +1 -1
- package/dist/unpkg/prod-deprecated/adapter/json-api.js +10 -4
- package/dist/unpkg/prod-deprecated/adapter/json-api.js.map +1 -1
- package/dist/unpkg/prod-deprecated/adapter/rest.js +23 -5
- package/dist/unpkg/prod-deprecated/adapter/rest.js.map +1 -1
- package/dist/unpkg/prod-deprecated/{adapter-DQ9UA7FC.js → adapter-D0HCLrwm.js} +45 -6
- package/dist/unpkg/prod-deprecated/adapter-D0HCLrwm.js.map +1 -0
- package/dist/unpkg/prod-deprecated/adapter.js +1 -1
- package/dist/unpkg/prod-deprecated/compat/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/compat/builders.js +15 -9
- package/dist/unpkg/prod-deprecated/compat/builders.js.map +1 -1
- package/dist/unpkg/prod-deprecated/compat/extensions.js +23 -2
- package/dist/unpkg/prod-deprecated/compat/extensions.js.map +1 -1
- package/dist/unpkg/prod-deprecated/compat/utils.js +19 -2
- package/dist/unpkg/prod-deprecated/compat/utils.js.map +1 -1
- package/dist/unpkg/{prod/compat-DxiVkCUb.js → prod-deprecated/compat-PrUuencH.js} +62 -10
- package/dist/unpkg/prod-deprecated/compat-PrUuencH.js.map +1 -0
- package/dist/unpkg/prod-deprecated/compat.js +1 -1
- package/dist/unpkg/prod-deprecated/{errors-ii4L43_1.js → errors-D20lKboZ.js} +38 -27
- package/dist/unpkg/prod-deprecated/errors-D20lKboZ.js.map +1 -0
- package/dist/unpkg/prod-deprecated/index.js +25 -7
- package/dist/unpkg/prod-deprecated/index.js.map +1 -1
- package/dist/unpkg/prod-deprecated/{json-BD1kRTfB.js → json-D1bH8enA.js} +10 -5
- package/dist/unpkg/prod-deprecated/json-D1bH8enA.js.map +1 -0
- package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/model/migration-support.js +24 -6
- package/dist/unpkg/prod-deprecated/model/migration-support.js.map +1 -1
- package/dist/unpkg/prod-deprecated/{model-D3oCPHtM.js → model-B946S2pl.js} +19 -12
- package/dist/unpkg/prod-deprecated/model-B946S2pl.js.map +1 -0
- package/dist/unpkg/{dev/model-fragments-DSqu0ptR.js → prod-deprecated/model-fragments-DCHMDr5f.js} +32 -18
- package/dist/unpkg/prod-deprecated/model-fragments-DCHMDr5f.js.map +1 -0
- package/dist/unpkg/prod-deprecated/model-fragments.js +1 -1
- package/dist/unpkg/prod-deprecated/model.js +2 -2
- package/dist/unpkg/prod-deprecated/{runtime--fcdnjmJ-DMTJ0Kb3.js → runtime--fcdnjmJ-5yaSpa-d.js} +2 -3
- package/dist/unpkg/prod-deprecated/{runtime--fcdnjmJ-DMTJ0Kb3.js.map → runtime--fcdnjmJ-5yaSpa-d.js.map} +1 -1
- package/dist/unpkg/prod-deprecated/{schema-provider-CKH_bnnS.js → schema-provider-xcaytn9y.js} +18 -17
- package/dist/unpkg/prod-deprecated/schema-provider-xcaytn9y.js.map +1 -0
- package/dist/unpkg/prod-deprecated/serializer/json-api.js +7 -3
- package/dist/unpkg/prod-deprecated/serializer/json-api.js.map +1 -1
- package/dist/unpkg/prod-deprecated/serializer/json.js +1 -1
- package/dist/unpkg/prod-deprecated/serializer/rest.js +12 -5
- package/dist/unpkg/prod-deprecated/serializer/rest.js.map +1 -1
- package/dist/unpkg/prod-deprecated/serializer/transform.js +14 -10
- package/dist/unpkg/prod-deprecated/serializer/transform.js.map +1 -1
- package/dist/unpkg/prod-deprecated/serializer.js +42 -3
- package/dist/unpkg/prod-deprecated/serializer.js.map +1 -1
- package/dist/unpkg/{prod/store-RGGc1ilN.js → prod-deprecated/store-Dsw2f4s-.js} +13 -7
- package/dist/unpkg/{prod/store-RGGc1ilN.js.map → prod-deprecated/store-Dsw2f4s-.js.map} +1 -1
- package/dist/unpkg/prod-deprecated/store.js +1 -1
- package/dist/unpkg/prod-deprecated/{util-CQQdHX3n.js → util-CVu5_VeN.js} +2 -3
- package/dist/unpkg/prod-deprecated/{util-CQQdHX3n.js.map → util-CVu5_VeN.js.map} +1 -1
- package/dist/unpkg/prod-deprecated/{utils-BMI_JwFP.js → utils-z1h-zTls.js} +2 -3
- package/dist/unpkg/prod-deprecated/{utils-BMI_JwFP.js.map → utils-z1h-zTls.js.map} +1 -1
- package/dist/{util-Bnx8nm-D.js → util-fMuLguoj.js} +2 -3
- package/dist/{util-Bnx8nm-D.js.map → util-fMuLguoj.js.map} +1 -1
- package/dist/{utils-ZAytYep8.js → utils-UqBsN9IU.js} +2 -3
- package/dist/{utils-ZAytYep8.js.map → utils-UqBsN9IU.js.map} +1 -1
- package/logos/README.md +1 -1
- package/package.json +17 -12
- package/dist/-private-DccRZQsm.js.map +0 -1
- package/dist/adapter-CARrK3-8.d.ts.map +0 -1
- package/dist/adapter-eYo2pIuM.js.map +0 -1
- package/dist/compat-BbNNmTM-.d.ts.map +0 -1
- package/dist/compat-DcHVxuuZ.js.map +0 -1
- package/dist/error-CzkyXr1Q.d.ts.map +0 -1
- package/dist/errors-CS110tMl.js.map +0 -1
- package/dist/extensions-DumNm4dA.d.ts.map +0 -1
- package/dist/json-BXNPTlcH.js.map +0 -1
- package/dist/model-62hn5_PD.d.ts.map +0 -1
- package/dist/model-DWH9f__L.js.map +0 -1
- package/dist/model-fragments-DSqu0ptR.js.map +0 -1
- package/dist/rest-0NhtexIq.d.ts.map +0 -1
- package/dist/schema-provider-DguGmQDS.js.map +0 -1
- package/dist/store-C4qYzXei.js.map +0 -1
- package/dist/unpkg/dev/-private-vOhxVExH.js.map +0 -1
- package/dist/unpkg/dev/adapter-oLwyr47q.js.map +0 -1
- package/dist/unpkg/dev/compat-DNQT2TQx.js.map +0 -1
- package/dist/unpkg/dev/errors-DnzvLM2A.js.map +0 -1
- package/dist/unpkg/dev/json-DDJji3V3.js.map +0 -1
- package/dist/unpkg/dev/model-BxPIR7m2.js.map +0 -1
- package/dist/unpkg/dev/model-fragments-DSqu0ptR.js.map +0 -1
- package/dist/unpkg/dev/schema-provider-CI_a48ja.js.map +0 -1
- package/dist/unpkg/dev/store-D_V8-HQl.js.map +0 -1
- package/dist/unpkg/dev-deprecated/-private-vOhxVExH.js.map +0 -1
- package/dist/unpkg/dev-deprecated/adapter-oLwyr47q.js.map +0 -1
- package/dist/unpkg/dev-deprecated/compat-CeT0PnVX.js.map +0 -1
- package/dist/unpkg/dev-deprecated/errors-jHQESeNQ.js.map +0 -1
- package/dist/unpkg/dev-deprecated/json-DDJji3V3.js.map +0 -1
- package/dist/unpkg/dev-deprecated/model-BeGORt6h.js.map +0 -1
- package/dist/unpkg/dev-deprecated/model-fragments-DSqu0ptR.js.map +0 -1
- package/dist/unpkg/dev-deprecated/schema-provider-NmtdR4n_.js.map +0 -1
- package/dist/unpkg/dev-deprecated/store-BCOLSC6z.js.map +0 -1
- package/dist/unpkg/prod/-private-SfXkkHKd.js.map +0 -1
- package/dist/unpkg/prod/adapter-DQ9UA7FC.js.map +0 -1
- package/dist/unpkg/prod/compat-DxiVkCUb.js.map +0 -1
- package/dist/unpkg/prod/errors-DQDfNqVx.js.map +0 -1
- package/dist/unpkg/prod/json-BD1kRTfB.js.map +0 -1
- package/dist/unpkg/prod/model-CYMA-e_S.js.map +0 -1
- package/dist/unpkg/prod/model-fragments-DSqu0ptR.js +0 -334
- package/dist/unpkg/prod/model-fragments-DSqu0ptR.js.map +0 -1
- package/dist/unpkg/prod/runtime--fcdnjmJ-DMTJ0Kb3.js +0 -53
- package/dist/unpkg/prod/schema-provider-05U1H-Kl.js.map +0 -1
- package/dist/unpkg/prod-deprecated/-private-SfXkkHKd.js.map +0 -1
- package/dist/unpkg/prod-deprecated/adapter-DQ9UA7FC.js.map +0 -1
- package/dist/unpkg/prod-deprecated/compat-DxiVkCUb.js.map +0 -1
- package/dist/unpkg/prod-deprecated/errors-ii4L43_1.js.map +0 -1
- package/dist/unpkg/prod-deprecated/json-BD1kRTfB.js.map +0 -1
- package/dist/unpkg/prod-deprecated/model-D3oCPHtM.js.map +0 -1
- package/dist/unpkg/prod-deprecated/model-fragments-DSqu0ptR.js.map +0 -1
- package/dist/unpkg/prod-deprecated/schema-provider-CKH_bnnS.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"-private-Dch4SxkU.js","names":["Context","upgradeStore","SnapshotRecordArray","constructor","store","type","options","__store","_snapshots","modelName","adapterOptions","include","_recordArray","peekAll","length","snapshots","_fetchManager","LiveArrayContext","source","map","identifier","createSnapshot","assertIdentifierHasId","identifier","test","Error","id","validateDocumentStructure","doc","errors","push","data","Array","isArray","meta","links","jsonapi","included","test","Error","join","length","normalizeResponseHelper","serializer","store","modelClass","payload","id","requestType","normalizedResponse","normalizeResponse","assertPrivateStore","upgradeStore","Snapshot","constructor","options","identifier","store","_store","__attributes","_belongsToRelationships","Object","create","_belongsToIds","_hasManyRelationships","_hasManyIds","hasRecord","_instanceCache","peek","modelName","type","_attributes","id","adapterOptions","include","cache","_changedAttributes","changedAttrs","record","peekRecord","test","Error","lid","attributes","eachAttribute","key","meta","getAttr","isNew","attr","keyName","changedAttributes","changedAttributeKeys","keys","i","length","slice","belongsTo","returnModeIsId","result","relationshipMeta","schema","fields","get","kind","_graph","relationship","value","getRelationship","data","inverseIdentifier","cacheKeyManager","getOrCreateRecordIdentifier","undefined","isDeleted","_fetchManager","createSnapshot","hasMany","returnModeIsIds","ids","results","cachedIds","cachedSnapshots","forEach","member","push","callback","binding","modelFor","modelSchema","field","call","eachRelationship","serialize","serializer","serializerFor","createDeferred","waitFor","assertPrivateStore","coerceId","getOrSetGlobal","upgradeStore","assertIdentifierHasId","payloadIsNotBlank","normalizeResponseHelper","Snapshot","SaveOp","Symbol","FetchManager","constructor","store","_store","_pendingFetch","Map","requestCache","getRequestStateService","isDestroyed","createSnapshot","identifier","options","scheduleSave","resolver","query","op","recordIdentifier","queryRequest","data","snapshot","pendingSaveItem","monitored","_enqueue","promise","_flushPendingSave","scheduleFetch","request","pendingFetch","getPendingFetch","modelName","type","pendingFetchItem","resolverPromise","isInitialLoad","_instanceCache","recordIsLoaded","then","payload","Array","isArray","lid","potentiallyNewIm","_push","reload","error","test","Error","cache","isEmpty","isReleasable","_graph","graph","unload","_enableAsyncFlush","unloadRecord","size","Promise","resolve","setTimeout","flushAllPendingFetches","fetchesByType","fetchesById","get","set","requestsForIdentifier","push","disableTestWaiter","pendingFetches","matchingPendingFetch","find","fetch","isSameRequest","forEach","fetchItem","_flushPendingFetchForType","clear","fetchDataIfNeededForIdentifier","_isEmpty","isLoading","_isLoading","Object","assign","destroy","instanceCache","isNew","isDeleted","req","isLoaded","getPendingRequestsForRecord","some","r","includesSatisfies","current","existing","length","arrCurrent","toSorted","split","sort","arrExisting","join","i","includes","optionsSatisfies","keys","existingOptions","adapterOptions","include","_findMany","adapter","snapshots","modelClass","modelFor","ids","map","s","id","every","v","findMany","ret","undefined","adapterPayload","serializer","serializerFor","rejectFetchedItems","fetchMap","l","pair","reject","handleFoundRecords","coalescedPayload","snapshotsById","snapshotGroup","included","resources","resource","delete","rejected","snapshotArray","console","warn","values","_fetchRecord","findRecord","_fetchManager","klass","isDestroying","_processCoalescedGroup","group","payloads","catch","pendingFetchMap","adapterFor","shouldCoalesce","coalesceFindRequests","pendingFetchItems","totalItems","groups","groupRecordsForFindMany","pending","operation","SnapshotRecordArray","SaveOp","FetchManager","Snapshot","upgradeStore","store"],"sources":["../../../src/compat/legacy-network-handler/snapshot-record-array.ts","../../../src/compat/legacy-network-handler/identifier-has-id.ts","../../../src/compat/legacy-network-handler/legacy-data-utils.ts","../../../src/compat/legacy-network-handler/serializer-response.ts","../../../src/compat/legacy-network-handler/snapshot.ts","../../../src/compat/legacy-network-handler/fetch-manager.ts","../../../src/compat/-private.ts"],"sourcesContent":["import type { Store } from '@warp-drive/core';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport type { LegacyLiveArray, PrivateReactiveResourceArray } from '@warp-drive/core/store/-private';\nimport type { FindAllOptions, ModelSchema } from '@warp-drive/core/types';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\n\nimport { upgradeStore } from '../-private.ts';\nimport type { Snapshot } from './snapshot.ts';\n/**\n SnapshotRecordArray is not directly instantiable.\n Instances are provided to consuming application's\n adapters for certain `findAll` requests.\n\n @hideconstructor\n @public\n*/\nexport class SnapshotRecordArray {\n /**\n * An array of snapshots\n *\n * @internal\n */\n declare private _snapshots: Snapshot[] | null;\n\n /** @internal */\n declare private _type: ModelSchema | null;\n\n /**\n * The ResourceType of the underlying records for the {@link Snapshot | Snapshots} in the array\n */\n declare modelName: string;\n\n /** @internal */\n declare private __store: Store;\n\n /**\n * A hash of adapter options passed into the store method for this request.\n\n Example\n\n ```js [app/adapters/post.js]\n import MyCustomAdapter from './custom-adapter';\n\n export default class PostAdapter extends MyCustomAdapter {\n findAll(store, type, sinceToken, snapshotRecordArray) {\n if (snapshotRecordArray.adapterOptions.subscribe) {\n // ...\n }\n // ...\n }\n }\n ```\n */\n declare adapterOptions?: Record<string, unknown>;\n /**\n * The relationships to include for this request.\n\n Example\n\n ```js [app/adapters/application.js]\n import Adapter from '@ember-data/adapter';\n\n export default class ApplicationAdapter extends Adapter {\n findAll(store, type, snapshotRecordArray) {\n let url = `/${type.modelName}?include=${encodeURIComponent(snapshotRecordArray.include)}`;\n\n return fetch(url).then((response) => response.json())\n }\n }\n ```\n */\n declare include?: string | string[];\n\n /**\n SnapshotRecordArray is not directly instantiable.\n Instances are provided to consuming application's\n adapters and serializers for certain requests.\n\n @private\n @constructor\n @param {Store} store\n @param {String} type\n @param options\n */\n constructor(store: Store, type: string, options: FindAllOptions = {}) {\n this.__store = store;\n this._snapshots = null;\n this.modelName = type;\n this.adapterOptions = options.adapterOptions;\n this.include = options.include;\n }\n\n /**\n An array of records\n\n @internal\n */\n get _recordArray(): LegacyLiveArray {\n return this.__store.peekAll(this.modelName);\n }\n\n /**\n Number of records in the array\n\n Example\n\n ```js [app/adapters/post.js]\n import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\n export default class PostAdapter extends JSONAPIAdapter {\n shouldReloadAll(store, snapshotRecordArray) {\n return !snapshotRecordArray.length;\n }\n });\n ```\n */\n get length(): number {\n return this._recordArray.length;\n }\n\n /**\n Get snapshots of the underlying record array\n\n Example\n\n ```js [app/adapters/post.js]\n import JSONAPIAdapter from '@ember-data/adapter/json-api';\n\n export default class PostAdapter extends JSONAPIAdapter {\n shouldReloadAll(store, snapshotArray) {\n let snapshots = snapshotArray.snapshots();\n\n return snapshots.any(function(ticketSnapshot) {\n let timeDiff = moment().diff(ticketSnapshot.attr('lastAccessedAt'), 'minutes');\n if (timeDiff > 20) {\n return true;\n } else {\n return false;\n }\n });\n }\n }\n ```\n\n @public\n @return Array of snapshots\n */\n snapshots(): Snapshot[] {\n if (this._snapshots !== null) {\n return this._snapshots;\n }\n upgradeStore(this.__store);\n\n const { _fetchManager } = this.__store;\n const LiveArrayContext = (this._recordArray as unknown as PrivateReactiveResourceArray)[Context];\n this._snapshots = LiveArrayContext.source.map((identifier: ResourceKey) =>\n _fetchManager.createSnapshot(identifier)\n );\n\n return this._snapshots;\n }\n}\n","import { assert } from '@warp-drive/core/build-config/macros';\nimport type { PersistedResourceKey } from '@warp-drive/core/types/identifier';\n\nexport function assertIdentifierHasId(identifier: unknown): asserts identifier is PersistedResourceKey {\n assert(\n `Attempted to schedule a fetch for a record without an id.`,\n identifier && (identifier as PersistedResourceKey).id !== null\n );\n}\n","import type { AdapterPayload } from './minimum-adapter-interface.ts';\n\ntype IteratorCB<T> = ((o: T, index: number) => T) | ((o: T) => T);\n\nexport function iterateData<T>(data: T[] | T, fn: IteratorCB<T>): T | T[] {\n if (Array.isArray(data)) {\n return data.map(fn);\n } else {\n return fn(data, 0);\n }\n}\n\nexport function payloadIsNotBlank<T>(adapterPayload: T | AdapterPayload): adapterPayload is AdapterPayload {\n if (Array.isArray(adapterPayload)) {\n return true;\n } else {\n return Object.keys(adapterPayload || {}).length !== 0;\n }\n}\n","import type { Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { ModelSchema } from '@warp-drive/core/types';\nimport type { JsonApiDocument } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport type { AdapterPayload } from './minimum-adapter-interface.ts';\nimport type { MinimumSerializerInterface, RequestType } from './minimum-serializer-interface.ts';\n\n/**\n This is a helper method that validates a JSON API top-level document\n\n The format of a document is described here:\n http://jsonapi.org/format/#document-top-level\n\n @internal\n*/\nfunction validateDocumentStructure(doc?: AdapterPayload | JsonApiDocument): asserts doc is JsonApiDocument {\n if (DEBUG) {\n const errors: string[] = [];\n if (!doc || typeof doc !== 'object') {\n errors.push('Top level of a JSON API document must be an object');\n } else {\n if (!('data' in doc) && !('errors' in doc) && !('meta' in doc)) {\n errors.push('One or more of the following keys must be present: \"data\", \"errors\", \"meta\".');\n } else {\n if ('data' in doc && 'errors' in doc) {\n errors.push('Top level keys \"errors\" and \"data\" cannot both be present in a JSON API document');\n }\n }\n if ('data' in doc) {\n if (!(doc.data === null || Array.isArray(doc.data) || typeof doc.data === 'object')) {\n errors.push('data must be null, an object, or an array');\n }\n }\n if ('meta' in doc) {\n if (typeof doc.meta !== 'object') {\n errors.push('meta must be an object');\n }\n }\n if ('errors' in doc) {\n if (!Array.isArray(doc.errors)) {\n errors.push('errors must be an array');\n }\n }\n if ('links' in doc) {\n if (typeof doc.links !== 'object') {\n errors.push('links must be an object');\n }\n }\n if ('jsonapi' in doc) {\n if (typeof doc.jsonapi !== 'object') {\n errors.push('jsonapi must be an object');\n }\n }\n if ('included' in doc) {\n if (typeof doc.included !== 'object') {\n errors.push('included must be an array');\n }\n }\n }\n\n assert(\n `Response must be normalized to a valid JSON API document:\\n\\t* ${errors.join('\\n\\t* ')}`,\n errors.length === 0\n );\n }\n}\n\nexport function normalizeResponseHelper(\n serializer: MinimumSerializerInterface | null,\n store: Store,\n modelClass: ModelSchema,\n payload: AdapterPayload,\n id: string | null,\n requestType: RequestType\n): JsonApiDocument {\n const normalizedResponse = serializer\n ? serializer.normalizeResponse(store, modelClass, payload, id, requestType)\n : payload;\n\n validateDocumentStructure(normalizedResponse);\n\n return normalizedResponse;\n}\n","import type { Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { FindRecordOptions } from '@warp-drive/core/types';\nimport type { ChangedAttributesHash } from '@warp-drive/core/types/cache';\nimport type { CollectionRelationship } from '@warp-drive/core/types/cache/relationship';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { Value } from '@warp-drive/core/types/json/raw';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { LegacyAttributeField, LegacyRelationshipField } from '@warp-drive/core/types/schema/fields';\n\nimport { upgradeStore } from '../-private';\nimport type { SerializerOptions } from './minimum-serializer-interface';\n\ntype RecordId = string | null;\n\n/**\n Snapshot is not directly instantiable.\n Instances are provided to a consuming application's\n adapters and serializers for certain requests.\n\n Snapshots are only available when using `@ember-data/legacy-compat`\n for legacy compatibility with adapters and serializers.\n\n For serialization of records in modern paradigms, request data from\n the cache or off the record directly.\n\n @hideconstructor\n @public\n*/\nexport class Snapshot<R = unknown> {\n /** @internal */\n declare private __attributes: Record<keyof R & string, unknown> | null;\n /** @internal */\n declare private _belongsToRelationships: Record<string, Snapshot>;\n /** @internal */\n declare private _belongsToIds: Record<string, RecordId>;\n /** @internal */\n declare private _hasManyRelationships: Record<string, Snapshot[]>;\n /** @internal */\n declare private _hasManyIds: Record<string, RecordId[]>;\n /** @internal */\n declare private _changedAttributes: ChangedAttributesHash;\n /** @internal */\n declare private _store: Store;\n\n /**\n The unique ResourceKey associated with this Snapshot.\n\n @public\n */\n declare identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>;\n\n /**\n The ResourceType of the underlying record for this Snapshot, as a string.\n\n @public\n */\n declare modelName: R extends TypedRecordInstance ? TypeFromInstance<R> : string;\n\n /**\n The id of the snapshot's underlying record\n\n Example\n\n ```js\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postSnapshot.id; // => '1'\n ```\n\n @public\n */\n declare id: string | null;\n\n /**\n If `include` was passed to the options for the request, the value\n would be available here.\n\n @public\n */\n declare include?: string | string[];\n\n /**\n The adapterOptions passed to the request which generated this Snapshot, if any\n\n @public\n */\n declare adapterOptions?: Record<string, unknown>;\n\n constructor(\n options: FindRecordOptions,\n identifier: ResourceKey<R extends TypedRecordInstance ? TypeFromInstance<R> : string>,\n store: Store\n ) {\n this._store = store;\n\n this.__attributes = null;\n this._belongsToRelationships = Object.create(null) as Record<string, Snapshot>;\n this._belongsToIds = Object.create(null) as Record<string, RecordId>;\n this._hasManyRelationships = Object.create(null) as Record<string, Snapshot[]>;\n this._hasManyIds = Object.create(null) as Record<string, RecordId[]>;\n\n assertPrivateStore(store);\n const hasRecord = !!store._instanceCache.peek(identifier);\n this.modelName = identifier.type;\n this.identifier = identifier;\n\n /*\n If the we do not yet have a record, then we are\n likely a snapshot being provided to a find request, so we\n populate __attributes lazily. Else, to preserve the \"moment\n in time\" in which a snapshot is created, we greedily grab\n the values.\n */\n if (hasRecord) {\n // oxlint-disable-next-line no-unused-expressions\n this._attributes;\n }\n\n this.id = identifier.id;\n this.adapterOptions = options.adapterOptions;\n this.include = options.include;\n this.modelName = identifier.type;\n\n if (hasRecord) {\n const cache = this._store.cache;\n this._changedAttributes = cache.changedAttrs(identifier);\n }\n }\n\n /**\n The underlying record for this snapshot. Can be used to access methods and\n properties defined on the record.\n\n ```js\n const someValue = snapshot.record.someProp;\n ```\n\n @property record\n @public\n */\n get record(): R | null {\n const record = this._store.peekRecord<R>(this.identifier);\n assert(\n `Record ${this.identifier.type} ${this.identifier.id} (${this.identifier.lid}) is not yet loaded and thus cannot be accessed from the Snapshot during serialization`,\n record !== null\n );\n return record;\n }\n\n /** @internal */\n private get _attributes(): Record<keyof R & string, unknown> {\n if (this.__attributes !== null) {\n return this.__attributes;\n }\n const attributes = (this.__attributes = Object.create(null) as Record<string, unknown>);\n const { identifier } = this;\n const cache = this._store.cache;\n\n this.eachAttribute((key: string, meta: LegacyAttributeField) => {\n attributes[key] = cache.getAttr(identifier, key);\n });\n\n return attributes;\n }\n\n get isNew(): boolean {\n const cache = this._store.cache;\n return cache?.isNew(this.identifier) || false;\n }\n\n /**\n Returns the value of an attribute.\n\n Example\n\n ```javascript\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postSnapshot.attr('author'); // => 'Tomster'\n postSnapshot.attr('title'); // => 'Ember.js rocks'\n ```\n\n Note: Values are loaded eagerly and cached when the snapshot is created.\n\n @return The attribute value or undefined\n @public\n */\n attr(keyName: keyof R & string): unknown {\n if (keyName in this._attributes) {\n return this._attributes[keyName];\n }\n assert(`Model '${this.identifier.lid}' has no attribute named '${keyName}' defined.`, false);\n }\n\n /**\n Returns all attributes and their corresponding values.\n\n ::: warning ⚠️ WARNING\n Attributes are SHALLOW copied from the cache.\n Because they are NOT deep copied from the cache, mutating\n any object or array fields will cause unintended side-effects\n and bugs.\n :::\n\n Example\n\n ```js\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }\n ```\n\n @return All attributes of the current snapshot\n @public\n */\n attributes(): Record<keyof R & string, unknown> {\n return { ...this._attributes };\n }\n\n /**\n Returns all changed attributes and their old and new values.\n\n Example\n\n ```js\n // store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });\n postModel.set('title', 'Ember.js rocks!');\n postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }\n ```\n\n @return All changed attributes of the current snapshot\n @public\n */\n changedAttributes(): ChangedAttributesHash {\n const changedAttributes = Object.create(null) as ChangedAttributesHash;\n if (!this._changedAttributes) {\n return changedAttributes;\n }\n\n const changedAttributeKeys = Object.keys(this._changedAttributes);\n\n for (let i = 0, length = changedAttributeKeys.length; i < length; i++) {\n const key = changedAttributeKeys[i];\n changedAttributes[key] = this._changedAttributes[key].slice() as [Value | undefined, Value];\n }\n\n return changedAttributes;\n }\n\n /**\n Returns the current value of a belongsTo relationship.\n\n `belongsTo` takes an optional hash of options as a second parameter,\n currently supported options are:\n\n - `id`: set to `true` if you only want the ID of the related record to be\n returned.\n\n Example\n\n ```js\n // store.push('post', { id: 1, title: 'Hello World' });\n // store.createRecord('comment', { body: 'Lorem ipsum', post: post });\n commentSnapshot.belongsTo('post'); // => Snapshot\n commentSnapshot.belongsTo('post', { id: true }); // => '1'\n\n // store.push('comment', { id: 1, body: 'Lorem ipsum' });\n commentSnapshot.belongsTo('post'); // => undefined\n ```\n\n Calling `belongsTo` will return a new Snapshot as long as there's any known\n data for the relationship available, such as an ID. If the relationship is\n known but unset, `belongsTo` will return `null`. If the contents of the\n relationship is unknown `belongsTo` will return `undefined`.\n\n Note: Relationships are loaded lazily and cached upon first access.\n\n @public\n @return A snapshot or ID of a known relationship or null if the\n relationship is known but unset. undefined will be returned if the\n contents of the relationship are unknown.\n */\n belongsTo(keyName: string, options?: { id?: boolean }): Snapshot | RecordId | undefined {\n const returnModeIsId = !!(options && options.id);\n let result: Snapshot | RecordId | undefined;\n const store = this._store;\n\n if (returnModeIsId === true && keyName in this._belongsToIds) {\n return this._belongsToIds[keyName];\n }\n\n if (returnModeIsId === false && keyName in this._belongsToRelationships) {\n return this._belongsToRelationships[keyName];\n }\n\n const relationshipMeta = store.schema.fields({ type: this.modelName }).get(keyName);\n assert(\n `Model '${this.identifier.lid}' has no belongsTo relationship named '${keyName}' defined.`,\n relationshipMeta && relationshipMeta.kind === 'belongsTo'\n );\n\n assert(`snapshot.belongsTo only supported when using a cache that supports the graph`, this._store._graph);\n\n const { identifier } = this;\n\n if (DEBUG) {\n const relationship = this._store.schema.fields(identifier)?.get(keyName);\n assert(\n `You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but no such relationship was found.`,\n relationship\n );\n assert(\n `You looked up the ${keyName} belongsTo relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but that relationship is a hasMany.`,\n relationship.kind === 'belongsTo'\n );\n }\n\n const value = this._store.cache.getRelationship(identifier, keyName);\n const data = value && value.data;\n upgradeStore(store);\n\n const inverseIdentifier = data ? store.cacheKeyManager.getOrCreateRecordIdentifier(data) : null;\n\n if (value && value.data !== undefined) {\n const cache = store.cache;\n\n if (inverseIdentifier && !cache.isDeleted(inverseIdentifier)) {\n if (returnModeIsId) {\n result = inverseIdentifier.id;\n } else {\n result = store._fetchManager.createSnapshot(inverseIdentifier);\n }\n } else {\n result = null;\n }\n }\n\n if (returnModeIsId) {\n this._belongsToIds[keyName] = result as RecordId;\n } else {\n this._belongsToRelationships[keyName] = result as Snapshot;\n }\n\n return result;\n }\n\n /**\n Returns the current value of a hasMany relationship.\n\n `hasMany` takes an optional hash of options as a second parameter,\n currently supported options are:\n\n - `ids`: set to `true` if you only want the IDs of the related records to be\n returned.\n\n Example\n\n ```javascript\n // store.push('post', { id: 1, title: 'Hello World', comments: [2, 3] });\n postSnapshot.hasMany('comments'); // => [Snapshot, Snapshot]\n postSnapshot.hasMany('comments', { ids: true }); // => ['2', '3']\n\n // store.push('post', { id: 1, title: 'Hello World' });\n postSnapshot.hasMany('comments'); // => undefined\n ```\n\n Note: Relationships are loaded lazily and cached upon first access.\n\n @public\n @return An array of snapshots or IDs of a known\n relationship or an empty array if the relationship is known but unset.\n undefined will be returned if the contents of the relationship is unknown.\n */\n hasMany(keyName: string, options?: { ids?: boolean }): RecordId[] | Snapshot[] | undefined {\n const returnModeIsIds = !!(options && options.ids);\n let results: RecordId[] | Snapshot[] | undefined;\n const cachedIds: RecordId[] | undefined = this._hasManyIds[keyName];\n const cachedSnapshots: Snapshot[] | undefined = this._hasManyRelationships[keyName];\n\n if (returnModeIsIds === true && keyName in this._hasManyIds) {\n return cachedIds;\n }\n\n if (returnModeIsIds === false && keyName in this._hasManyRelationships) {\n return cachedSnapshots;\n }\n\n const store = this._store;\n upgradeStore(store);\n const relationshipMeta = store.schema.fields({ type: this.modelName }).get(keyName);\n assert(\n `Model '${this.identifier.lid}' has no hasMany relationship named '${keyName}' defined.`,\n relationshipMeta && relationshipMeta.kind === 'hasMany'\n );\n\n // TODO @runspired it seems this code branch would not work with CUSTOM_MODEL_CLASSes\n // this check is not a regression in behavior because relationships don't currently\n // function without access to intimate API contracts between RecordData and Model.\n // This is a requirement we should fix as soon as the relationship layer does not require\n // this intimate API usage.\n assert(`snapshot.hasMany only supported when using a cache that supports the graph`, this._store._graph);\n\n const { identifier } = this;\n if (DEBUG) {\n const relationship = this._store.schema.fields(identifier)?.get(keyName);\n assert(\n `You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but no such relationship was found.`,\n relationship\n );\n assert(\n `You looked up the ${keyName} hasMany relationship for { type: ${identifier.type}, id: ${\n identifier.id || ''\n }, lid: ${identifier.lid} but that relationship is a belongsTo.`,\n relationship.kind === 'hasMany'\n );\n }\n\n const value = this._store.cache.getRelationship(identifier, keyName) as CollectionRelationship;\n\n if (value.data) {\n results = [];\n value.data.forEach((member) => {\n const inverseIdentifier = store.cacheKeyManager.getOrCreateRecordIdentifier(member);\n const cache = store.cache;\n\n if (!cache.isDeleted(inverseIdentifier)) {\n if (returnModeIsIds) {\n (results as RecordId[]).push(inverseIdentifier.id);\n } else {\n (results as Snapshot[]).push(store._fetchManager.createSnapshot(inverseIdentifier));\n }\n }\n });\n }\n\n // we assign even if `undefined` so that we don't reprocess the relationship\n // on next access. This works with the `keyName in` checks above.\n if (returnModeIsIds) {\n this._hasManyIds[keyName] = results as RecordId[];\n } else {\n this._hasManyRelationships[keyName] = results as Snapshot[];\n }\n\n return results;\n }\n\n /**\n Iterates through all the attributes of the model, calling the passed\n function on each attribute.\n\n Example\n\n ```javascript\n snapshot.eachAttribute(function(name, meta) {\n // ...\n });\n ```\n\n @param callback the callback to execute\n @param binding the optional value to which the callback's `this` should be bound\n @public\n */\n eachAttribute(callback: (key: string, meta: LegacyAttributeField) => void, binding?: unknown): void {\n // if the store has a modelFor implementation, we use it to iterate attributes. This allows\n // a custom \"ModelSchema\" class for legacy serializers to adapt to new fields if desired.\n if (typeof this._store.modelFor === 'function') {\n const modelSchema = this._store.modelFor(this.identifier.type);\n modelSchema.eachAttribute(callback, binding);\n } else {\n const fields = this._store.schema.fields(this.identifier);\n fields.forEach((field, key) => {\n if (field.kind === 'attribute') {\n callback.call(binding, key, field);\n }\n });\n }\n }\n\n /**\n Iterates through all the relationships of the model, calling the passed\n function on each relationship.\n\n Example\n\n ```javascript\n snapshot.eachRelationship(function(name, relationship) {\n // ...\n });\n ```\n\n @param callback the callback to execute\n @param binding the optional value to which the callback's `this` should be bound\n @public\n */\n eachRelationship(callback: (key: string, meta: LegacyRelationshipField) => void, binding?: unknown): void {\n // if the store has a modelFor implementation, we use it to iterate relationships. This allows\n // a custom \"ModelSchema\" class for legacy serializers to adapt to new fields if desired.\n if (typeof this._store.modelFor === 'function') {\n const modelSchema = this._store.modelFor(this.identifier.type);\n modelSchema.eachRelationship(callback, binding);\n } else {\n const fields = this._store.schema.fields(this.identifier);\n fields.forEach((field, key) => {\n if (field.kind === 'belongsTo' || field.kind === 'hasMany') {\n callback.call(binding, key, field);\n }\n });\n }\n }\n\n /**\n Serializes the snapshot using the serializer for the model.\n\n Example\n\n ```js [app/adapters/application.js]\n import Adapter from '@ember-data/adapter';\n\n export default Adapter.extend({\n createRecord(store, type, snapshot) {\n let data = snapshot.serialize({ includeId: true });\n let url = `/${type.modelName}`;\n\n return fetch(url, {\n method: 'POST',\n body: data,\n }).then((response) => response.json())\n }\n });\n ```\n\n @return an object whose values are primitive JSON values only\n @public\n */\n serialize(options?: SerializerOptions): unknown {\n upgradeStore(this._store);\n const serializer = this._store.serializerFor(this.modelName);\n assert(`Cannot serialize record, no serializer found`, serializer);\n return serializer.serialize(this, options);\n }\n}\n","import { warn } from '@ember/debug';\n\nimport type { Store } from '@warp-drive/core';\nimport { DEBUG, TESTING } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { createDeferred } from '@warp-drive/core/request';\nimport { waitFor } from '@warp-drive/core/signals/-leaked';\nimport type {\n FindRecordQuery,\n InstanceCache,\n PrivateRequestStateService,\n PrivateStore,\n Request,\n SaveRecordMutation,\n} from '@warp-drive/core/store/-private';\nimport { assertPrivateStore, coerceId } from '@warp-drive/core/store/-private';\nimport type { FindRecordOptions, ModelSchema } from '@warp-drive/core/types';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { PersistedResourceKey, ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { ImmutableRequestInfo } from '@warp-drive/core/types/request';\nimport type { CollectionResourceDocument, SingleResourceDocument } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { upgradeStore } from '../-private.ts';\nimport { assertIdentifierHasId } from './identifier-has-id.ts';\nimport { payloadIsNotBlank } from './legacy-data-utils.ts';\nimport type { AdapterPayload, MinimumAdapterInterface } from './minimum-adapter-interface.ts';\nimport type { MinimumSerializerInterface } from './minimum-serializer-interface.ts';\nimport { normalizeResponseHelper } from './serializer-response.ts';\nimport { Snapshot } from './snapshot.ts';\n\ntype Deferred<T> = ReturnType<typeof createDeferred<T>>;\ntype AdapterErrors = Error & { errors?: string[]; isAdapterError?: true };\ntype SerializerWithParseErrors = MinimumSerializerInterface & {\n extractErrors?(store: Store, modelClass: ModelSchema, error: AdapterErrors, recordId: string | null): unknown;\n};\n\nexport const SaveOp: '___(unique) Symbol(SaveOp)' = getOrSetGlobal('SaveOp', Symbol('SaveOp'));\n\nexport type FetchMutationOptions = FindRecordOptions & { [SaveOp]: 'createRecord' | 'deleteRecord' | 'updateRecord' };\n\ninterface PendingFetchItem {\n identifier: PersistedResourceKey;\n queryRequest: Request;\n // oxlint-disable-next-line typescript/no-explicit-any\n resolver: Deferred<any>;\n options: FindRecordOptions;\n trace?: unknown;\n promise: Promise<PersistedResourceKey>;\n}\n\ninterface PendingSaveItem {\n // oxlint-disable-next-line typescript/no-explicit-any\n resolver: Deferred<any>;\n snapshot: Snapshot;\n identifier: ResourceKey;\n options: FetchMutationOptions;\n queryRequest: Request;\n}\n\n/**\n * @private\n */\nexport class FetchManager {\n /**\n * @internal\n */\n declare isDestroyed: boolean;\n /** @internal */\n declare private requestCache: PrivateRequestStateService;\n // fetches pending in the runloop, waiting to be coalesced\n /**\n * @internal\n */\n declare _pendingFetch: Map<string, Map<PersistedResourceKey, PendingFetchItem[]>>;\n\n /** @internal */\n declare private _store: PrivateStore;\n\n constructor(store: Store) {\n assertPrivateStore(store);\n this._store = store;\n // used to keep track of all the find requests that need to be coalesced\n this._pendingFetch = new Map();\n this.requestCache = store.getRequestStateService();\n this.isDestroyed = false;\n }\n\n createSnapshot<T>(identifier: ResourceKey<TypeFromInstance<T>>, options?: FindRecordOptions): Snapshot<T>;\n createSnapshot(identifier: ResourceKey, options?: FindRecordOptions): Snapshot;\n createSnapshot(identifier: ResourceKey, options: FindRecordOptions = {}): Snapshot {\n return new Snapshot(options, identifier, this._store);\n }\n\n /**\n This method is called by `record.save`, and gets passed a\n resolver for the promise that `record.save` returns.\n\n It schedules saving to happen at the end of the run loop.\n\n @private\n */\n scheduleSave(identifier: ResourceKey, options: FetchMutationOptions): Promise<null | SingleResourceDocument> {\n const resolver = createDeferred<SingleResourceDocument | null>();\n const query: SaveRecordMutation = {\n op: 'saveRecord',\n recordIdentifier: identifier,\n options,\n };\n\n const queryRequest: Request = {\n data: [query],\n };\n\n const snapshot = this.createSnapshot(identifier, options);\n const pendingSaveItem: PendingSaveItem = {\n snapshot: snapshot,\n resolver: resolver,\n identifier,\n options,\n queryRequest,\n };\n\n const monitored = this.requestCache._enqueue(resolver.promise, pendingSaveItem.queryRequest);\n _flushPendingSave(this._store, pendingSaveItem);\n\n return monitored;\n }\n\n scheduleFetch(\n identifier: PersistedResourceKey,\n options: FindRecordOptions,\n request: ImmutableRequestInfo\n ): Promise<PersistedResourceKey> {\n const query: FindRecordQuery = {\n op: 'findRecord',\n recordIdentifier: identifier,\n options,\n };\n\n const queryRequest: Request = {\n data: [query],\n };\n\n const pendingFetch = this.getPendingFetch(identifier, options);\n if (pendingFetch) {\n return pendingFetch;\n }\n\n const modelName = identifier.type;\n\n const resolver = createDeferred<SingleResourceDocument>();\n const pendingFetchItem: PendingFetchItem = {\n identifier,\n resolver,\n options,\n queryRequest,\n } as PendingFetchItem;\n\n const resolverPromise = resolver.promise;\n const store = this._store;\n const isInitialLoad = !store._instanceCache.recordIsLoaded(identifier); // we don't use isLoading directly because we are the request\n\n const monitored = this.requestCache._enqueue(resolverPromise, pendingFetchItem.queryRequest);\n let promise = monitored.then(\n (payload) => {\n // ensure that regardless of id returned we assign to the correct record\n if (payload.data && !Array.isArray(payload.data)) {\n payload.data.lid = identifier.lid;\n }\n\n // additional data received in the payload\n // may result in the merging of identifiers (and thus records)\n const potentiallyNewIm = store._push(payload, options.reload);\n if (potentiallyNewIm && !Array.isArray(potentiallyNewIm)) {\n return potentiallyNewIm;\n }\n\n return identifier;\n },\n (error) => {\n assert(`Async Leak Detected: Expected the store to not be destroyed`, !store.isDestroyed);\n const cache = store.cache;\n if (!cache || cache.isEmpty(identifier) || isInitialLoad) {\n let isReleasable = true;\n if (store._graph) {\n const graph = store._graph;\n if (!cache) {\n isReleasable = graph.isReleasable(identifier);\n if (!isReleasable) {\n graph.unload(identifier, true);\n }\n }\n }\n if (cache || isReleasable) {\n store._enableAsyncFlush = true;\n store._instanceCache.unloadRecord(identifier);\n store._enableAsyncFlush = null;\n }\n }\n throw error;\n }\n );\n\n if (this._pendingFetch.size === 0) {\n void new Promise((resolve) => setTimeout(resolve, 0)).then(() => {\n this.flushAllPendingFetches();\n });\n }\n\n const fetchesByType = this._pendingFetch;\n let fetchesById = fetchesByType.get(modelName);\n\n if (!fetchesById) {\n fetchesById = new Map();\n fetchesByType.set(modelName, fetchesById);\n }\n\n let requestsForIdentifier = fetchesById.get(identifier);\n if (!requestsForIdentifier) {\n requestsForIdentifier = [];\n fetchesById.set(identifier, requestsForIdentifier);\n }\n\n requestsForIdentifier.push(pendingFetchItem);\n\n if (TESTING) {\n if (!request.disableTestWaiter) {\n promise = waitFor(promise);\n }\n }\n\n pendingFetchItem.promise = promise;\n return promise;\n }\n\n getPendingFetch(\n identifier: PersistedResourceKey,\n options: FindRecordOptions\n ): Promise<PersistedResourceKey> | undefined {\n const pendingFetches = this._pendingFetch.get(identifier.type)?.get(identifier);\n\n // We already have a pending fetch for this\n if (pendingFetches) {\n const matchingPendingFetch = pendingFetches.find((fetch) => isSameRequest(options, fetch.options));\n if (matchingPendingFetch) {\n return matchingPendingFetch.promise;\n }\n }\n }\n\n flushAllPendingFetches(): void {\n if (this.isDestroyed) {\n return;\n }\n\n const store = this._store;\n this._pendingFetch.forEach((fetchItem, type) => _flushPendingFetchForType(store, fetchItem, type));\n this._pendingFetch.clear();\n }\n\n fetchDataIfNeededForIdentifier(\n identifier: PersistedResourceKey,\n options: FindRecordOptions | undefined = {},\n request: ImmutableRequestInfo\n ): Promise<PersistedResourceKey> {\n // pre-loading will change the isEmpty value\n const isEmpty = _isEmpty(this._store._instanceCache, identifier);\n const isLoading = _isLoading(this._store._instanceCache, identifier);\n\n let promise: Promise<PersistedResourceKey>;\n if (isEmpty) {\n assertIdentifierHasId(identifier);\n\n if (DEBUG) {\n promise = this.scheduleFetch(identifier, Object.assign({}, options, { reload: true }), request);\n } else {\n options.reload = true;\n promise = this.scheduleFetch(identifier, options, request);\n }\n } else if (isLoading) {\n promise = this.getPendingFetch(identifier, options)!;\n assert(`Expected to find a pending request for a record in the loading state, but found none`, promise);\n } else {\n promise = Promise.resolve(identifier);\n }\n\n return promise;\n }\n\n destroy(): void {\n this.isDestroyed = true;\n }\n}\n\n/**\n * This type exists for internal use only for\n * where intimate contracts still exist either for\n * the Test Suite or for Legacy code.\n *\n * @private\n */\nexport interface PrivateFetchManager extends FetchManager {\n _pendingFetch: Map<string, Map<PersistedResourceKey, PendingFetchItem[]>>;\n}\n\nfunction _isEmpty(instanceCache: InstanceCache, identifier: ResourceKey): boolean {\n const cache = instanceCache.cache;\n if (!cache) {\n return true;\n }\n const isNew = cache.isNew(identifier);\n const isDeleted = cache.isDeleted(identifier);\n const isEmpty = cache.isEmpty(identifier);\n\n return (!isNew || isDeleted) && isEmpty;\n}\n\nfunction _isLoading(cache: InstanceCache, identifier: ResourceKey): boolean {\n const req = cache.store.getRequestStateService();\n // const fulfilled = req.getLastRequestForRecord(identifier);\n const isLoaded = cache.recordIsLoaded(identifier);\n\n return (\n !isLoaded &&\n // fulfilled === null &&\n req.getPendingRequestsForRecord(identifier).some((r) => r.type === 'query')\n );\n}\n\nfunction includesSatisfies(current: undefined | string | string[], existing: undefined | string | string[]): boolean {\n // if we have no includes we are good\n if (!current?.length) {\n return true;\n }\n\n // if we are here we have includes,\n // and if existing has no includes then we will need a new request\n if (!existing?.length) {\n return false;\n }\n\n // toSorted for the array branch: these arrays belong to the request options\n // the caller passed us, sorting them in place would reorder their state.\n const arrCurrent = Array.isArray(current) ? current.toSorted() : current.split(',').sort();\n const arrExisting = Array.isArray(existing) ? existing.toSorted() : existing.split(',').sort();\n\n // includes are identical\n if (arrCurrent.join(',') === arrExisting.join(',')) {\n return true;\n }\n\n // if all of current includes are in existing includes then we are good\n // so if we find one that is not in existing then we need a new request\n for (let i = 0; i < arrCurrent.length; i++) {\n if (!arrExisting.includes(arrCurrent[i])) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction optionsSatisfies(current: object | undefined, existing: object | undefined): boolean {\n return !current || current === existing || Object.keys(current).length === 0;\n}\n\n// this function helps resolve whether we have a pending request that we should use instead\nfunction isSameRequest(options: FindRecordOptions = {}, existingOptions: FindRecordOptions = {}) {\n return (\n optionsSatisfies(options.adapterOptions, existingOptions.adapterOptions) &&\n includesSatisfies(options.include, existingOptions.include)\n );\n}\n\nfunction _findMany(\n store: Store,\n adapter: MinimumAdapterInterface,\n modelName: string,\n snapshots: Snapshot[]\n): Promise<CollectionResourceDocument> {\n const modelClass = store.modelFor(modelName); // `adapter.findMany` gets the modelClass still\n const promise = Promise.resolve().then(() => {\n const ids = snapshots.map((s) => s.id!);\n assert(\n `Cannot fetch a record without an id`,\n ids.every((v) => v !== null)\n );\n // oxlint-disable-next-line typescript/unbound-method\n assert(`Expected this adapter to implement findMany for coalescing`, adapter.findMany);\n const ret = adapter.findMany(store, modelClass, ids, snapshots);\n assert('adapter.findMany returned undefined, this was very likely a mistake', ret !== undefined);\n return ret;\n });\n upgradeStore(store);\n\n return promise.then((adapterPayload) => {\n assert(\n `You made a 'findMany' request for '${modelName}' records with ids '[${snapshots\n .map((s) => s.id!)\n .join(',')}]', but the adapter's response did not have any data`,\n !!payloadIsNotBlank(adapterPayload)\n );\n const serializer = store.serializerFor(modelName);\n const payload = normalizeResponseHelper(serializer, store, modelClass, adapterPayload, null, 'findMany');\n return payload as CollectionResourceDocument;\n });\n}\n\nfunction rejectFetchedItems(fetchMap: Map<Snapshot, PendingFetchItem>, snapshots: Snapshot[], error?: Error) {\n for (let i = 0, l = snapshots.length; i < l; i++) {\n const snapshot = snapshots[i];\n const pair = fetchMap.get(snapshot);\n\n if (pair) {\n pair.resolver.reject(\n error ||\n new Error(\n `Expected: '<${\n snapshot.modelName\n }:${snapshot.id!}>' to be present in the adapter provided payload, but it was not found.`\n )\n );\n }\n }\n}\n\nfunction handleFoundRecords(\n store: Store,\n fetchMap: Map<Snapshot, PendingFetchItem>,\n snapshots: Snapshot[],\n coalescedPayload: CollectionResourceDocument\n) {\n /*\n It is possible that the same ID is included multiple times\n via multiple snapshots. This happens when more than one\n options hash was supplied, each of which must be uniquely\n accounted for.\n\n However, since we can't map from response to a specific\n options object, we resolve all snapshots by id with\n the first response we see.\n */\n const snapshotsById = new Map<string, Snapshot[]>();\n for (let i = 0; i < snapshots.length; i++) {\n const id = snapshots[i].id!;\n let snapshotGroup = snapshotsById.get(id);\n if (!snapshotGroup) {\n snapshotGroup = [];\n snapshotsById.set(id, snapshotGroup);\n }\n snapshotGroup.push(snapshots[i]);\n }\n\n const included = Array.isArray(coalescedPayload.included) ? coalescedPayload.included : [];\n\n // resolve found records\n const resources = coalescedPayload.data;\n for (let i = 0, l = resources.length; i < l; i++) {\n const resource = resources[i];\n const snapshotGroup = snapshotsById.get(resource.id);\n snapshotsById.delete(resource.id);\n\n if (!snapshotGroup) {\n // TODO consider whether this should be a deprecation/assertion\n included.push(resource);\n } else {\n snapshotGroup.forEach((snapshot) => {\n const pair = fetchMap.get(snapshot)!;\n const resolver = pair.resolver;\n resolver.resolve({ data: resource });\n });\n }\n }\n\n if (included.length > 0) {\n store._push({ data: null, included }, true);\n }\n\n if (snapshotsById.size === 0) {\n return;\n }\n\n // reject missing records\n const rejected: Snapshot[] = [];\n snapshotsById.forEach((snapshotArray) => {\n rejected.push(...snapshotArray);\n });\n warn(\n 'Ember Data expected to find records with the following ids in the adapter response from findMany but they were missing: [ \"' +\n [...snapshotsById.values()].map((r) => r[0].id).join('\", \"') +\n '\" ]',\n {\n id: 'ds.store.missing-records-from-adapter',\n }\n );\n\n rejectFetchedItems(fetchMap, rejected);\n}\n\nfunction _fetchRecord(store: Store, adapter: MinimumAdapterInterface, fetchItem: PendingFetchItem) {\n upgradeStore(store);\n const identifier = fetchItem.identifier;\n const modelName = identifier.type;\n\n assert(`You tried to find a record but you have no adapter (for ${modelName})`, adapter);\n assert(\n `You tried to find a record but your adapter (for ${modelName}) does not implement 'findRecord'`,\n typeof adapter.findRecord === 'function'\n );\n\n const snapshot = store._fetchManager.createSnapshot(identifier, fetchItem.options);\n const klass = store.modelFor(identifier.type);\n const id = identifier.id;\n\n let promise = Promise.resolve().then(() => {\n return adapter.findRecord(store, klass, identifier.id, snapshot);\n });\n\n promise = promise.then((adapterPayload) => {\n assert(`Async Leak Detected: Expected the store to not be destroyed`, !(store.isDestroyed || store.isDestroying));\n assert(\n `You made a 'findRecord' request for a '${modelName}' with id '${id}', but the adapter's response did not have any data`,\n !!payloadIsNotBlank(adapterPayload)\n );\n const serializer = store.serializerFor(modelName);\n const payload = normalizeResponseHelper(serializer, store, klass, adapterPayload, id, 'findRecord');\n assert(\n `Ember Data expected the primary data returned from a 'findRecord' response to be an object but instead it found an array.`,\n !Array.isArray(payload.data)\n );\n assert(\n `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.`,\n 'data' in payload && payload.data !== null && typeof payload.data === 'object'\n );\n\n warn(\n `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.`,\n coerceId(payload.data.id) === coerceId(id),\n {\n id: 'ds.store.findRecord.id-mismatch',\n }\n );\n\n return payload;\n });\n\n fetchItem.resolver.resolve(promise);\n}\n\nfunction _processCoalescedGroup(\n store: Store,\n fetchMap: Map<Snapshot, PendingFetchItem>,\n group: Snapshot[],\n adapter: MinimumAdapterInterface,\n modelName: string\n) {\n if (group.length > 1) {\n _findMany(store, adapter, modelName, group)\n .then((payloads: CollectionResourceDocument) => {\n handleFoundRecords(store, fetchMap, group, payloads);\n })\n .catch((error: Error) => {\n rejectFetchedItems(fetchMap, group, error);\n });\n } else if (group.length === 1) {\n _fetchRecord(store, adapter, fetchMap.get(group[0])!);\n } else {\n assert(\"You cannot return an empty array from adapter's method groupRecordsForFindMany\", false);\n }\n}\n\nfunction _flushPendingFetchForType(\n store: Store,\n pendingFetchMap: Map<PersistedResourceKey, PendingFetchItem[]>,\n modelName: string\n) {\n upgradeStore(store);\n const adapter = store.adapterFor(modelName);\n const shouldCoalesce = !!adapter.findMany && adapter.coalesceFindRequests;\n\n if (shouldCoalesce) {\n const pendingFetchItems: PendingFetchItem[] = [];\n pendingFetchMap.forEach((requestsForIdentifier, identifier) => {\n if (requestsForIdentifier.length > 1) {\n return;\n }\n\n // remove this entry from the map so it's not processed again\n pendingFetchMap.delete(identifier);\n pendingFetchItems.push(requestsForIdentifier[0]);\n });\n\n const totalItems = pendingFetchItems.length;\n\n if (totalItems > 1) {\n const snapshots = new Array<Snapshot>(totalItems);\n const fetchMap = new Map<Snapshot, PendingFetchItem>();\n for (let i = 0; i < totalItems; i++) {\n const fetchItem = pendingFetchItems[i];\n snapshots[i] = store._fetchManager.createSnapshot(fetchItem.identifier, fetchItem.options);\n fetchMap.set(snapshots[i], fetchItem);\n }\n\n let groups: Snapshot[][];\n if (adapter.groupRecordsForFindMany) {\n groups = adapter.groupRecordsForFindMany(store, snapshots);\n } else {\n groups = [snapshots];\n }\n\n for (let i = 0, l = groups.length; i < l; i++) {\n _processCoalescedGroup(store, fetchMap, groups[i], adapter, modelName);\n }\n } else if (totalItems === 1) {\n _fetchRecord(store, adapter, pendingFetchItems[0]);\n }\n }\n\n pendingFetchMap.forEach((pendingFetchItems) => {\n pendingFetchItems.forEach((pendingFetchItem) => {\n _fetchRecord(store, adapter, pendingFetchItem);\n });\n });\n}\n\nfunction _flushPendingSave(store: Store, pending: PendingSaveItem) {\n const { snapshot, resolver, identifier, options } = pending;\n upgradeStore(store);\n const adapter = store.adapterFor(identifier.type);\n const operation = options[SaveOp];\n\n const modelName = snapshot.modelName;\n const modelClass = store.modelFor(modelName);\n\n assert(`You tried to update a record but you have no adapter (for ${modelName})`, adapter);\n assert(\n `You tried to update a record but your adapter (for ${modelName}) does not implement '${operation}'`,\n typeof adapter[operation] === 'function'\n );\n\n let promise: Promise<AdapterPayload> = Promise.resolve().then(() => adapter[operation](store, modelClass, snapshot));\n const serializer: SerializerWithParseErrors | null = store.serializerFor(modelName);\n\n assert(\n `Your adapter's '${operation}' method must return a value, but it returned 'undefined'`,\n promise !== undefined\n );\n\n promise = promise.then((adapterPayload) => {\n if (adapterPayload) {\n return normalizeResponseHelper(serializer, store, modelClass, adapterPayload, snapshot.id, operation);\n }\n }) as Promise<AdapterPayload>;\n\n resolver.resolve(promise);\n}\n","import type { Store } from '@warp-drive/core';\n\nimport type { CompatStore } from '../compat.ts';\n\n/**\n * Utilities - often temporary - for maintaining backwards compatibility with\n * older parts of WarpDrive.\n *\n * @summary Legacy internals of the adapter-based network layer, such as `Snapshot` and `FetchManager`, shared across\n * the legacy packages.\n @module\n*/\nexport { SnapshotRecordArray } from './legacy-network-handler/snapshot-record-array.ts';\nexport { SaveOp } from './legacy-network-handler/fetch-manager.ts';\nexport { FetchManager } from './legacy-network-handler/fetch-manager.ts';\nexport { Snapshot } from './legacy-network-handler/snapshot.ts';\n\nexport function upgradeStore(store: Store): asserts store is CompatStore {}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,IAAaE,sBAAb,MAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoE/BC,YAAYC,OAAcC,MAAcC,UAA0B,CAAC,GAAG;EACpE,KAAKC,UAAUH;EACf,KAAKI,aAAa;EAClB,KAAKC,YAAYJ;EACjB,KAAKK,iBAAiBJ,QAAQI;EAC9B,KAAKC,UAAUL,QAAQK;CACzB;;;;;CAOA,IAAIC,eAAgC;EAClC,OAAO,KAAKL,QAAQM,QAAQ,KAAKJ,SAAS;CAC5C;;;;;;;;;;;;;CAiBA,IAAIK,SAAiB;EACnB,OAAO,KAAKF,aAAaE;CAC3B;;;;;;;;;;;;;;;;;;;;;;;CA6BAC,YAAwB;EACtB,IAAI,KAAKP,eAAe,MACtB,OAAO,KAAKA;EAEdP,6BAAa,KAAKM,OAAO;EAEzB,MAAM,EAAES,kBAAkB,KAAKT;EAC/B,MAAMU,mBAAoB,KAAKL,aAAyDZ;EACxF,KAAKQ,aAAaS,iBAAiBC,OAAOC,KAAKC,eAC7CJ,cA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S9E,gBAAgB;EAC/C,CAAC;CACH,CAAC;AACH;AAEA,SAASP,kBAAkBtB,OAAc8J,SAA0B;CACjE,MAAM,EAAE7I,UAAUN,UAAUH,YAAYC,YAAYqJ;CACpDvK,6BAAaS,KAAK;CAClB,MAAM2G,UAAU3G,MAAMuJ,WAAW/I,WAAWoB,IAAI;CAChD,MAAMmI,YAAYtJ,QAAQb;CAE1B,MAAM+B,YAAYV,SAASU;CAC3B,MAAMkF,aAAa7G,MAAM8G,SAASnF,SAAS;CAE3C,EAAAgB,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,6DAA6DjB,UAAS,EAAG;CAAA,EAAA,CAAEgF,OAAO;CACzF,EAAAhE,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,sDAAsDjB,UAAS,wBAAyBoI,UAAS,EAAG;CAAA,EAAA,CACpG,OAAOpD,QAAQoD,eAAe,UAAU;CAG1C,IAAI1I,UAAmCiC,QAAQC,QAAQ,CAAC,CAACrB,WAAWyE,QAAQoD,UAAU,CAAC/J,OAAO6G,YAAY5F,QAAQ,CAAC;CACnH,MAAMwG,aAA+CzH,MAAM0H,cAAc/F,SAAS;CAElF,EAAAgB,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,mBAAmBmH,UAAS,0DAA2D;CAAA,EAAA,CACvF1I,YAAYkG,MAAS;CAGvBlG,UAAUA,QAAQa,MAAMsF,mBAAmB;EACzC,IAAIA,gBACF,OAAO9H,wBAAwB+H,YAAYzH,OAAO6G,YAAYW,gBAAgBvG,SAASiG,IAAI6C,SAAS;CAExG,CAAC;CAEDpJ,SAAS4C,QAAQlC,OAAO;AAC1B;;;AC/nBA,SAAgB+I,aAAaC,OAA4C,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as determineBodyPromise, i as serializeQueryParams, n as getFetchFunction, o as parseResponseHeaders, r as setupFastboot, t as serializeIntoHash } from "../-private-
|
|
1
|
+
import { a as determineBodyPromise, i as serializeQueryParams, n as getFetchFunction, o as parseResponseHeaders, r as setupFastboot, t as serializeIntoHash } from "../-private-BprUAEe_.js";
|
|
2
2
|
|
|
3
3
|
export { determineBodyPromise, getFetchFunction as fetch, parseResponseHeaders, serializeIntoHash, serializeQueryParams, setupFastboot };
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { getOrSetGlobal } from "@warp-drive/core/types/-private";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/adapter/error.ts
|
|
4
|
+
/**
|
|
5
|
+
* @module
|
|
6
|
+
* @summary Legacy adapter errors, such as `AdapterError`, `InvalidError` and `NotFoundError`, that an adapter returns
|
|
7
|
+
* or throws to signal a failed API request.
|
|
8
|
+
*/
|
|
4
9
|
function _AdapterError(errors, message = "Adapter operation failed") {
|
|
5
10
|
this.isAdapterError = true;
|
|
6
11
|
const error = Error.call(this, message);
|
|
@@ -20,16 +25,25 @@ function _AdapterError(errors, message = "Adapter operation failed") {
|
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
* The shape of the errors thrown/returned by {@link AdapterError} and its subclasses.
|
|
28
|
+
*
|
|
29
|
+
* @summary Legacy adapter error shape: an `Error` flagged `isAdapterError` with a `code` string and a {json:api}
|
|
30
|
+
* `errors` array, as thrown by `AdapterError` and its subclasses.
|
|
23
31
|
*/
|
|
24
32
|
/**
|
|
25
33
|
* The static interface shared by {@link AdapterError} and its subclasses,
|
|
26
34
|
* allowing further subclassing via {@link AdapterRequestErrorConstructor.extend | extend}.
|
|
35
|
+
*
|
|
36
|
+
* @summary Static side of the legacy adapter error constructors: `new (errors?, message?)` plus `extend({ message })`
|
|
37
|
+
* for creating further error subclasses.
|
|
27
38
|
*/
|
|
28
39
|
_AdapterError.prototype = Object.create(Error.prototype);
|
|
29
40
|
_AdapterError.prototype.code = "AdapterError";
|
|
30
41
|
_AdapterError.extend = extendFn(_AdapterError);
|
|
31
42
|
/**
|
|
32
43
|
* The {@link AdapterRequestError} shape thrown by the {@link AdapterError} constructor.
|
|
44
|
+
*
|
|
45
|
+
* @summary Legacy base error an adapter returns or throws to signal a failed API request; extend it to define
|
|
46
|
+
* app-specific error types.
|
|
33
47
|
*/
|
|
34
48
|
/**
|
|
35
49
|
* :::danger
|
|
@@ -127,6 +141,8 @@ _AdapterError.extend = extendFn(_AdapterError);
|
|
|
127
141
|
* or on whichever of the {@link AdapterError} subclasses' `code` values
|
|
128
142
|
* (e.g. `'InvalidError'`, `'NotFoundError'`) the error's `code` matches.
|
|
129
143
|
*
|
|
144
|
+
* @summary Legacy base error constructor an adapter uses to signal a failed API request; call `extend` on it to
|
|
145
|
+
* define app-specific error types.
|
|
130
146
|
* @public
|
|
131
147
|
*/
|
|
132
148
|
const AdapterError = getOrSetGlobal("AdapterError", _AdapterError);
|
|
@@ -148,6 +164,8 @@ function extend(ParentErrorClass, defaultMessage) {
|
|
|
148
164
|
}
|
|
149
165
|
/**
|
|
150
166
|
* The {@link AdapterRequestError} shape thrown by the {@link InvalidError} constructor.
|
|
167
|
+
* @summary Instance type of the legacy `InvalidError`, the adapter error for a request the API rejected as
|
|
168
|
+
* semantically invalid.
|
|
151
169
|
*/
|
|
152
170
|
/**
|
|
153
171
|
* An `InvalidError` is used by an adapter to signal that the external API
|
|
@@ -204,12 +222,16 @@ function extend(ParentErrorClass, defaultMessage) {
|
|
|
204
222
|
* model. As a result, it is safe for the `InvalidError` to wrap the error
|
|
205
223
|
* payload unaltered.
|
|
206
224
|
*
|
|
225
|
+
* @summary Legacy adapter error signaling that the API rejected a request as semantically invalid, typically failed
|
|
226
|
+
* server-side validation, putting the record in the `invalid` state.
|
|
207
227
|
* @public
|
|
208
228
|
*/
|
|
209
229
|
const InvalidError = getOrSetGlobal("InvalidError", extend(AdapterError, "The adapter rejected the commit because it was invalid"));
|
|
210
230
|
InvalidError.prototype.code = "InvalidError";
|
|
211
231
|
/**
|
|
212
232
|
* The {@link AdapterRequestError} shape thrown by the {@link TimeoutError} constructor.
|
|
233
|
+
*
|
|
234
|
+
* @summary Legacy adapter error signaling that a request to the API timed out without receiving a response.
|
|
213
235
|
*/
|
|
214
236
|
/**
|
|
215
237
|
* A `TimeoutError` is used by an adapter to signal that a request to the
|
|
@@ -236,12 +258,16 @@ InvalidError.prototype.code = "InvalidError";
|
|
|
236
258
|
* }
|
|
237
259
|
* ```
|
|
238
260
|
*
|
|
261
|
+
* @summary Legacy adapter error constructor for signaling that a request to the API timed out without receiving a
|
|
262
|
+
* response.
|
|
239
263
|
* @public
|
|
240
264
|
*/
|
|
241
265
|
const TimeoutError = getOrSetGlobal("TimeoutError", extend(AdapterError, "The adapter operation timed out"));
|
|
242
266
|
TimeoutError.prototype.code = "TimeoutError";
|
|
243
267
|
/**
|
|
244
268
|
* The {@link AdapterRequestError} shape thrown by the {@link AbortError} constructor.
|
|
269
|
+
*
|
|
270
|
+
* @summary Legacy adapter error signaling that a request to the API was aborted before a response arrived.
|
|
245
271
|
*/
|
|
246
272
|
/**
|
|
247
273
|
* An `AbortError` is used by an adapter to signal that a request to the
|
|
@@ -270,12 +296,17 @@ TimeoutError.prototype.code = "TimeoutError";
|
|
|
270
296
|
* }
|
|
271
297
|
* ```
|
|
272
298
|
*
|
|
299
|
+
* @summary Legacy adapter error constructor for signaling that a request to the API was aborted before a response
|
|
300
|
+
* arrived.
|
|
273
301
|
* @public
|
|
274
302
|
*/
|
|
275
303
|
const AbortError = getOrSetGlobal("AbortError", extend(AdapterError, "The adapter operation was aborted"));
|
|
276
304
|
AbortError.prototype.code = "AbortError";
|
|
277
305
|
/**
|
|
278
306
|
* The {@link AdapterRequestError} shape thrown by the {@link UnauthorizedError} constructor.
|
|
307
|
+
*
|
|
308
|
+
* @summary Legacy adapter error for an HTTP 401 response, signaling that authorization is required and failed or
|
|
309
|
+
* was not provided.
|
|
279
310
|
*/
|
|
280
311
|
/**
|
|
281
312
|
* A `UnauthorizedError` equates to an HTTP `401 Unauthorized` response
|
|
@@ -303,12 +334,17 @@ AbortError.prototype.code = "AbortError";
|
|
|
303
334
|
* }
|
|
304
335
|
* ```
|
|
305
336
|
*
|
|
337
|
+
* @summary Legacy adapter error constructor for an HTTP 401 response, signaling that authorization is required and
|
|
338
|
+
* failed or was not provided.
|
|
306
339
|
* @public
|
|
307
340
|
*/
|
|
308
341
|
const UnauthorizedError = getOrSetGlobal("UnauthorizedError", extend(AdapterError, "The adapter operation is unauthorized"));
|
|
309
342
|
UnauthorizedError.prototype.code = "UnauthorizedError";
|
|
310
343
|
/**
|
|
311
344
|
* The {@link AdapterRequestError} shape thrown by the {@link ForbiddenError} constructor.
|
|
345
|
+
*
|
|
346
|
+
* @summary Legacy adapter error for an HTTP 403 response, signaling that the server refused a valid request the
|
|
347
|
+
* user lacks permission for.
|
|
312
348
|
*/
|
|
313
349
|
/**
|
|
314
350
|
* A `ForbiddenError` equates to an HTTP `403 Forbidden` response status.
|
|
@@ -338,12 +374,17 @@ UnauthorizedError.prototype.code = "UnauthorizedError";
|
|
|
338
374
|
* }
|
|
339
375
|
* ```
|
|
340
376
|
*
|
|
377
|
+
* @summary Legacy adapter error constructor for an HTTP 403 response, signaling that the server refused a valid
|
|
378
|
+
* request the user lacks permission for.
|
|
341
379
|
* @public
|
|
342
380
|
*/
|
|
343
381
|
const ForbiddenError = getOrSetGlobal("ForbiddenError", extend(AdapterError, "The adapter operation is forbidden"));
|
|
344
382
|
ForbiddenError.prototype.code = "ForbiddenError";
|
|
345
383
|
/**
|
|
346
384
|
* The {@link AdapterRequestError} shape thrown by the {@link NotFoundError} constructor.
|
|
385
|
+
*
|
|
386
|
+
* @summary Legacy adapter error for an HTTP 404 response, signaling that the requested resource does not exist on
|
|
387
|
+
* the API.
|
|
347
388
|
*/
|
|
348
389
|
/**
|
|
349
390
|
* A `NotFoundError` equates to an HTTP `404 Not Found` response status.
|
|
@@ -374,12 +415,17 @@ ForbiddenError.prototype.code = "ForbiddenError";
|
|
|
374
415
|
* }
|
|
375
416
|
* ```
|
|
376
417
|
*
|
|
418
|
+
* @summary Legacy adapter error constructor for an HTTP 404 response, signaling that the requested resource does not
|
|
419
|
+
* exist on the API.
|
|
377
420
|
* @public
|
|
378
421
|
*/
|
|
379
422
|
const NotFoundError = getOrSetGlobal("NotFoundError", extend(AdapterError, "The adapter could not find the resource"));
|
|
380
423
|
NotFoundError.prototype.code = "NotFoundError";
|
|
381
424
|
/**
|
|
382
425
|
* The {@link AdapterRequestError} shape thrown by the {@link ConflictError} constructor.
|
|
426
|
+
*
|
|
427
|
+
* @summary Legacy adapter error for an HTTP 409 response, signaling that the request conflicts with existing
|
|
428
|
+
* server state, such as a duplicate client-generated id.
|
|
383
429
|
*/
|
|
384
430
|
/**
|
|
385
431
|
* A `ConflictError` equates to an HTTP `409 Conflict` response status.
|
|
@@ -407,12 +453,17 @@ NotFoundError.prototype.code = "NotFoundError";
|
|
|
407
453
|
* }
|
|
408
454
|
* ```
|
|
409
455
|
*
|
|
456
|
+
* @summary Legacy adapter error constructor for an HTTP 409 response, signaling that the request conflicts with
|
|
457
|
+
* existing server state, such as a duplicate client-generated id.
|
|
410
458
|
* @public
|
|
411
459
|
*/
|
|
412
460
|
const ConflictError = getOrSetGlobal("ConflictError", extend(AdapterError, "The adapter operation failed due to a conflict"));
|
|
413
461
|
ConflictError.prototype.code = "ConflictError";
|
|
414
462
|
/**
|
|
415
463
|
* The {@link AdapterRequestError} shape thrown by the {@link ServerError} constructor.
|
|
464
|
+
*
|
|
465
|
+
* @summary Legacy adapter error for an HTTP 500 response, signaling that the API failed internally and an
|
|
466
|
+
* immediate retry is unlikely to succeed.
|
|
416
467
|
*/
|
|
417
468
|
/**
|
|
418
469
|
* A `ServerError` equates to an HTTP `500 Internal Server Error` response
|
|
@@ -439,11 +490,12 @@ ConflictError.prototype.code = "ConflictError";
|
|
|
439
490
|
* }
|
|
440
491
|
* ```
|
|
441
492
|
*
|
|
493
|
+
* @summary Legacy adapter error constructor for an HTTP 500 response, signaling that the API failed internally and
|
|
494
|
+
* an immediate retry is unlikely to succeed.
|
|
442
495
|
* @public
|
|
443
496
|
*/
|
|
444
497
|
const ServerError = getOrSetGlobal("ServerError", extend(AdapterError, "The adapter operation failed due to a server error"));
|
|
445
498
|
ServerError.prototype.code = "ServerError";
|
|
446
499
|
|
|
447
|
-
//#endregion
|
|
448
500
|
export { AbortError, AdapterError, ConflictError, ForbiddenError, InvalidError, NotFoundError, ServerError, TimeoutError, UnauthorizedError };
|
|
449
501
|
//# sourceMappingURL=error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","names":["getOrSetGlobal","_AdapterError","errors","message","isAdapterError","error","Error","call","stack","description","fileName","lineNumber","name","number","title","detail","prototype","Object","create","code","extend","extendFn","AdapterError","ErrorClass","defaultMessage","ParentErrorClass","test","Array","isArray","InvalidError","TimeoutError","AbortError","UnauthorizedError","ForbiddenError","NotFoundError","ConflictError","ServerError"],"sources":["../../../../src/adapter/error.ts"],"sourcesContent":["/* oxlint-disable typescript/no-unsafe-assignment */\n/* oxlint-disable typescript/no-unsafe-member-access */\n// oxlint-disable-next-line no-unused-vars\nimport type { RequestManager } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\n// oxlint-disable-next-line no-unused-vars\nimport type { Handler } from '@warp-drive/core/request';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { ApiError } from '@warp-drive/core/types/spec/error';\n\nfunction _AdapterError(this: AdapterRequestError, errors: ApiError[], message = 'Adapter operation failed') {\n this.isAdapterError = true;\n const error = Error.call(this, message);\n\n if (error) {\n this.stack = error.stack;\n // @ts-expect-error untyped\n this.description = error.description;\n // @ts-expect-error untyped\n this.fileName = error.fileName;\n // @ts-expect-error untyped\n this.lineNumber = error.lineNumber;\n this.message = error.message;\n this.name = error.name;\n // @ts-expect-error untyped\n this.number = error.number;\n }\n\n this.errors = errors || [\n {\n title: 'Adapter Error',\n detail: message,\n },\n ];\n}\n\n/**\n * The shape of the errors thrown/returned by {@link AdapterError} and its subclasses.\n */\nexport interface AdapterRequestError<T extends string = string> extends Error {\n /**\n * A property signifying that an Error uses the {@link AdapterRequestError} interface.\n */\n isAdapterError: true;\n /**\n * A short code identifying the kind of error, e.g. `'NotFoundError'`.\n */\n code: T;\n /**\n * The {json:api} formatted errors associated with the request.\n */\n errors: ApiError[];\n}\n/**\n * The static interface shared by {@link AdapterError} and its subclasses,\n * allowing further subclassing via {@link AdapterRequestErrorConstructor.extend | extend}.\n */\nexport interface AdapterRequestErrorConstructor<Instance extends AdapterRequestError = AdapterRequestError> {\n new (errors?: unknown[], message?: string): Instance;\n /**\n * Creates a new {@link AdapterRequestErrorConstructor} that inherits from this one.\n */\n extend(options: { message: string }): AdapterRequestErrorConstructor;\n}\n\n_AdapterError.prototype = Object.create(Error.prototype);\n\n_AdapterError.prototype.code = 'AdapterError';\n_AdapterError.extend = extendFn(_AdapterError as unknown as AdapterRequestErrorConstructor);\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link AdapterError} constructor.\n */\nexport type AdapterError = AdapterRequestError<'AdapterError'>;\n/**\n * :::danger\n * ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.\n * If starting a new app or thinking of implementing a new adapter, consider writing a\n * {@link Handler} instead to be used with the {@link RequestManager}\n * :::\n *\n * An `AdapterError` is used by an adapter to signal that an error occurred\n * during a request to an external API. It indicates a generic error, and\n * subclasses are used to indicate specific error states.\n *\n * To create a custom error to signal a specific error state in communicating\n * with an external API, extend the `AdapterError`. For example, if the\n * external API exclusively used HTTP `503 Service Unavailable` to indicate\n * it was closed for maintenance:\n *\n * ```js [app/adapters/maintenance-error.js]\n * import AdapterError from '@warp-drive/legacy/adapter/error';\n *\n * export default AdapterError.extend({ message: \"Down for maintenance.\" });\n * ```\n *\n * This error would then be returned by an adapter's `handleResponse` method:\n *\n * ```js [app/adapters/application.js]\n * import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';\n * import MaintenanceError from './maintenance-error';\n *\n * export default class ApplicationAdapter extends JSONAPIAdapter {\n * handleResponse(status) {\n * if (503 === status) {\n * return new MaintenanceError();\n * }\n *\n * return super.handleResponse(...arguments);\n * }\n * }\n * ```\n *\n * And can then be detected in an application and used to send the user to an\n * `under-maintenance` route:\n *\n * ```js [app/routes/application.js]\n * import MaintenanceError from '../adapters/maintenance-error';\n *\n * export default class ApplicationRoute extends Route {\n * actions: {\n * error(error, transition) {\n * if (error instanceof MaintenanceError) {\n * this.transitionTo('under-maintenance');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * }\n * ```\n *\n * ### Signaling an Error Without Extending `AdapterError`\n *\n * Extending `AdapterError` (or one of its subclasses) is a convenience, not\n * a requirement. WarpDrive only inspects an error for the {@link AdapterRequestError}\n * shape: an `isAdapterError` flag, a `code`, and an {json:api}-formatted\n * `errors` array. Any object satisfying that shape — including a plain\n * `Error` with those properties attached — will be handled identically to\n * an instance created via `new AdapterError()` or one of its subclasses.\n *\n * This is useful when you'd rather not introduce a class hierarchy, or\n * when the error needs to be constructed from data you don't control\n * (for example, re-throwing an error surfaced by a third-party library):\n *\n * ```js [app/adapters/application.js]\n * import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';\n *\n * export default class ApplicationAdapter extends JSONAPIAdapter {\n * handleResponse(status, headers, payload) {\n * if (status === 503) {\n * const error = new Error('Down for maintenance.');\n * error.isAdapterError = true;\n * error.code = 'MaintenanceError';\n * error.errors = [{ title: 'Service Unavailable', detail: 'Down for maintenance.' }];\n * return error;\n * }\n *\n * return super.handleResponse(status, headers, payload);\n * }\n * }\n * ```\n *\n * Because `code` is just a string you control, `error instanceof AdapterError`\n * checks won't match a plain object built this way — consumers should\n * instead branch on `error.isAdapterError && error.code === 'MaintenanceError'`,\n * or on whichever of the {@link AdapterError} subclasses' `code` values\n * (e.g. `'InvalidError'`, `'NotFoundError'`) the error's `code` matches.\n *\n * @public\n */\nexport const AdapterError: AdapterRequestErrorConstructor<AdapterError> = getOrSetGlobal(\n 'AdapterError',\n _AdapterError as unknown as AdapterRequestErrorConstructor<AdapterError>\n);\ntype ErrorExtender = (opts: { message?: string }) => AdapterRequestErrorConstructor;\nfunction extendFn(ErrorClass: AdapterRequestErrorConstructor): ErrorExtender {\n return function ({ message: defaultMessage }: { message?: string } = {}) {\n return extend(ErrorClass, defaultMessage);\n };\n}\n\nfunction extend<Final extends AdapterRequestError>(\n ParentErrorClass: AdapterRequestErrorConstructor,\n defaultMessage?: string\n): AdapterRequestErrorConstructor<Final> {\n const ErrorClass = function (this: AdapterRequestError, errors: ApiError[], message?: string) {\n assert('`AdapterError` expects json-api formatted errors array.', Array.isArray(errors || []));\n ParentErrorClass.call(this, errors, message || defaultMessage);\n };\n // oxlint-disable-next-line typescript/no-unsafe-argument\n ErrorClass.prototype = Object.create(ParentErrorClass.prototype);\n ErrorClass.extend = extendFn(ErrorClass as unknown as AdapterRequestErrorConstructor);\n\n return ErrorClass as unknown as AdapterRequestErrorConstructor<Final>;\n}\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link InvalidError} constructor.\n */\n// TODO @deprecate extractError documentation\nexport type InvalidError = AdapterRequestError<'InvalidError'>;\n/**\n * An `InvalidError` is used by an adapter to signal that the external API\n * was unable to process a request because the content was not semantically\n * correct or meaningful per the API. Usually, this means a record failed\n * some form of server-side validation. When a promise from an adapter is\n * rejected with an `InvalidError` the record will transition to the\n * `invalid` state and the errors will be set to the `errors` property on\n * the record.\n *\n * For WarpDrive to correctly map errors to their corresponding properties\n * on the model, WarpDrive expects each error to be a valid {json:api} error\n * object with a `source.pointer` that matches the property name. For\n * example, if you had a `Post` model that looked like this:\n *\n * ```js [app/models/post.js]\n * import { Model, attr } from '@warp-drive/legacy/model';\n *\n * export default class PostModel extends Model {\n * @attr('string') title;\n * @attr('string') content;\n * }\n * ```\n *\n * To show an error from the server related to the `title` and `content`\n * properties your adapter could return a promise that rejects with an\n * `InvalidError` that looks like this:\n *\n * ```js [app/adapters/post.js]\n * import RSVP from 'RSVP';\n * import RESTAdapter from '@warp-drive/legacy/adapter/rest';\n * import { InvalidError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationAdapter extends RESTAdapter {\n * updateRecord() {\n * // Fictional adapter that always rejects\n * return RSVP.reject(new InvalidError([\n * {\n * detail: 'Must be unique',\n * source: { pointer: '/data/attributes/title' }\n * },\n * {\n * detail: 'Must not be blank',\n * source: { pointer: '/data/attributes/content' }\n * }\n * ]));\n * }\n * }\n * ```\n *\n * Your backend may use different property names for your records; the\n * store will attempt to extract and normalize the errors using the\n * serializer's `extractErrors` method before the errors get added to the\n * model. As a result, it is safe for the `InvalidError` to wrap the error\n * payload unaltered.\n *\n * @public\n */\nexport const InvalidError: AdapterRequestErrorConstructor<InvalidError> = getOrSetGlobal(\n 'InvalidError',\n extend<InvalidError>(AdapterError, 'The adapter rejected the commit because it was invalid')\n);\nInvalidError.prototype.code = 'InvalidError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link TimeoutError} constructor.\n */\nexport type TimeoutError = AdapterRequestError<'TimeoutError'>;\n/**\n * A `TimeoutError` is used by an adapter to signal that a request to the\n * external API has timed out, i.e. no response was received from the\n * external API within an allowed time period.\n *\n * An example use case would be to warn the user to check their internet\n * connection if an adapter operation has timed out:\n *\n * ```js [app/routes/application.js]\n * import { TimeoutError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof TimeoutError) {\n * // alert the user\n * alert('Are you still connected to the Internet?');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const TimeoutError: AdapterRequestErrorConstructor<TimeoutError> = getOrSetGlobal(\n 'TimeoutError',\n extend(AdapterError, 'The adapter operation timed out')\n);\nTimeoutError.prototype.code = 'TimeoutError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link AbortError} constructor.\n */\nexport type AbortError = AdapterRequestError<'AbortError'>;\n/**\n * An `AbortError` is used by an adapter to signal that a request to the\n * external API was aborted. For example, this can occur if the user\n * navigates away from the current page after a request to the external API\n * has been initiated but before a response has been received.\n *\n * Because an aborted request is typically expected (the user chose to\n * navigate away, or a newer request superseded this one) rather than\n * exceptional, an example use case would be to silently ignore it instead\n * of surfacing an error to the user:\n *\n * ```js [app/routes/application.js]\n * import { AbortError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof AbortError) {\n * // the request was aborted, nothing to report\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const AbortError: AdapterRequestErrorConstructor<AbortError> = getOrSetGlobal(\n 'AbortError',\n extend(AdapterError, 'The adapter operation was aborted')\n);\nAbortError.prototype.code = 'AbortError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link UnauthorizedError} constructor.\n */\nexport type UnauthorizedError = AdapterRequestError<'UnauthorizedError'>;\n/**\n * A `UnauthorizedError` equates to an HTTP `401 Unauthorized` response\n * status. It is used by an adapter to signal that a request to the external\n * API was rejected because authorization is required and has failed or has\n * not yet been provided.\n *\n * An example use case would be to redirect the user to a login route if a\n * request is unauthorized:\n *\n * ```js [app/routes/application.js]\n * import { UnauthorizedError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof UnauthorizedError) {\n * // go to the login route\n * this.transitionTo('login');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const UnauthorizedError: AdapterRequestErrorConstructor<UnauthorizedError> = getOrSetGlobal(\n 'UnauthorizedError',\n extend(AdapterError, 'The adapter operation is unauthorized')\n);\nUnauthorizedError.prototype.code = 'UnauthorizedError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link ForbiddenError} constructor.\n */\nexport type ForbiddenError = AdapterRequestError<'ForbiddenError'>;\n/**\n * A `ForbiddenError` equates to an HTTP `403 Forbidden` response status.\n * It is used by an adapter to signal that a request to the external API was\n * valid but the server is refusing to respond to it. If authorization was\n * provided and is valid, then the authenticated user does not have the\n * necessary permissions for the request.\n *\n * Unlike an {@link UnauthorizedError}, retrying the request with different\n * credentials will not help; the currently authenticated user simply lacks\n * permission. An example use case would be to show the user a \"you don't\n * have access to this\" message rather than redirecting them to log in:\n *\n * ```js [app/routes/application.js]\n * import { ForbiddenError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof ForbiddenError) {\n * this.transitionTo('forbidden');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const ForbiddenError: AdapterRequestErrorConstructor<ForbiddenError> = getOrSetGlobal(\n 'ForbiddenError',\n extend(AdapterError, 'The adapter operation is forbidden')\n);\nForbiddenError.prototype.code = 'ForbiddenError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link NotFoundError} constructor.\n */\nexport type NotFoundError = AdapterRequestError<'NotFoundError'>;\n/**\n * A `NotFoundError` equates to an HTTP `404 Not Found` response status.\n * It is used by an adapter to signal that a request to the external API\n * was rejected because the resource could not be found on the API.\n *\n * An example use case would be to detect if the user has entered a route\n * for a specific model that does not exist. For example:\n *\n * ```js [app/routes/post.js]\n * import { NotFoundError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class PostRoute extends Route {\n * @service store;\n * model(params) {\n * return this.store.findRecord('post', params.post_id);\n * }\n * @action\n * error(error, transition) {\n * if (error instanceof NotFoundError) {\n * // redirect to a list of all posts instead\n * this.transitionTo('posts');\n * } else {\n * // otherwise let the error bubble\n * return true;\n * }\n * }\n * }\n * ```\n *\n * @public\n */\nexport const NotFoundError: AdapterRequestErrorConstructor<NotFoundError> = getOrSetGlobal(\n 'NotFoundError',\n extend(AdapterError, 'The adapter could not find the resource')\n);\nNotFoundError.prototype.code = 'NotFoundError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link ConflictError} constructor.\n */\nexport type ConflictError = AdapterRequestError<'ConflictError'>;\n/**\n * A `ConflictError` equates to an HTTP `409 Conflict` response status.\n * It is used by an adapter to indicate that the request could not be\n * processed because of a conflict in the request. An example scenario\n * would be when creating a record with a client-generated ID but that ID\n * is already known to the external API.\n *\n * An example use case would be to surface a conflict-specific message so\n * the user can retry with different input:\n *\n * ```js [app/routes/application.js]\n * import { ConflictError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof ConflictError) {\n * alert('That identifier is already in use, please choose another.');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const ConflictError: AdapterRequestErrorConstructor<ConflictError> = getOrSetGlobal(\n 'ConflictError',\n extend(AdapterError, 'The adapter operation failed due to a conflict')\n);\nConflictError.prototype.code = 'ConflictError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link ServerError} constructor.\n */\nexport type ServerError = AdapterRequestError<'ServerError'>;\n/**\n * A `ServerError` equates to an HTTP `500 Internal Server Error` response\n * status. It is used by the adapter to indicate that a request has failed\n * because of an error in the external API, and is unlikely to succeed if\n * retried immediately.\n *\n * An example use case would be to show a generic \"something went wrong on\n * our end\" message rather than one implying the user made a mistake:\n *\n * ```js [app/routes/application.js]\n * import { ServerError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof ServerError) {\n * alert('Something went wrong on our end. Please try again later.');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @public\n */\nexport const ServerError: AdapterRequestErrorConstructor<ServerError> = getOrSetGlobal(\n 'ServerError',\n extend(AdapterError, 'The adapter operation failed due to a server error')\n);\nServerError.prototype.code = 'ServerError';\n"],"mappings":";;;AAUA,SAASC,cAAyCC,QAAoBC,UAAU,4BAA4B;CAC1G,KAAKC,iBAAiB;CACtB,MAAMC,QAAQC,MAAM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,OAAqBE,cAAc,wDAAwD,CAC7F;AACAO,aAAab,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiC9B,MAAaW,eAA6D9B,eACxE,gBACAoB,OAAOE,cAAc,iCAAiC,CACxD;AACAQ,aAAad,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmC9B,MAAaY,aAAyD/B,eACpE,cACAoB,OAAOE,cAAc,mCAAmC,CAC1D;AACAS,WAAWf,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkC5B,MAAaa,oBAAuEhC,eAClF,qBACAoB,OAAOE,cAAc,uCAAuC,CAC9D;AACAU,kBAAkBhB,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCnC,MAAac,iBAAiEjC,eAC5E,kBACAoB,OAAOE,cAAc,oCAAoC,CAC3D;AACAW,eAAejB,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqChC,MAAae,gBAA+DlC,eAC1E,iBACAoB,OAAOE,cAAc,yCAAyC,CAChE;AACAY,cAAclB,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkC/B,MAAagB,gBAA+DnC,eAC1E,iBACAoB,OAAOE,cAAc,gDAAgD,CACvE;AACAa,cAAcnB,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiC/B,MAAaiB,cAA2DpC,eACtE,eACAoB,OAAOE,cAAc,oDAAoD,CAC3E;AACAc,YAAYpB,UAAUG,OAAO"}
|
|
1
|
+
{"version":3,"file":"error.js","names":["getOrSetGlobal","_AdapterError","errors","message","isAdapterError","error","Error","call","stack","description","fileName","lineNumber","name","number","title","detail","prototype","Object","create","code","extend","extendFn","AdapterError","ErrorClass","defaultMessage","ParentErrorClass","test","Array","isArray","InvalidError","TimeoutError","AbortError","UnauthorizedError","ForbiddenError","NotFoundError","ConflictError","ServerError"],"sources":["../../../../src/adapter/error.ts"],"sourcesContent":["/* oxlint-disable typescript/no-unsafe-assignment */\n/* oxlint-disable typescript/no-unsafe-member-access */\n/**\n * @module\n * @summary Legacy adapter errors, such as `AdapterError`, `InvalidError` and `NotFoundError`, that an adapter returns\n * or throws to signal a failed API request.\n */\n\n// oxlint-disable-next-line no-unused-vars\nimport type { RequestManager } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\n// oxlint-disable-next-line no-unused-vars\nimport type { Handler } from '@warp-drive/core/request';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { ApiError } from '@warp-drive/core/types/spec/error';\n\nfunction _AdapterError(this: AdapterRequestError, errors: ApiError[], message = 'Adapter operation failed') {\n this.isAdapterError = true;\n const error = Error.call(this, message);\n\n if (error) {\n this.stack = error.stack;\n // @ts-expect-error untyped\n this.description = error.description;\n // @ts-expect-error untyped\n this.fileName = error.fileName;\n // @ts-expect-error untyped\n this.lineNumber = error.lineNumber;\n this.message = error.message;\n this.name = error.name;\n // @ts-expect-error untyped\n this.number = error.number;\n }\n\n this.errors = errors || [\n {\n title: 'Adapter Error',\n detail: message,\n },\n ];\n}\n\n/**\n * The shape of the errors thrown/returned by {@link AdapterError} and its subclasses.\n *\n * @summary Legacy adapter error shape: an `Error` flagged `isAdapterError` with a `code` string and a {json:api}\n * `errors` array, as thrown by `AdapterError` and its subclasses.\n */\nexport interface AdapterRequestError<T extends string = string> extends Error {\n /**\n * A property signifying that an Error uses the {@link AdapterRequestError} interface.\n */\n isAdapterError: true;\n /**\n * A short code identifying the kind of error, e.g. `'NotFoundError'`.\n */\n code: T;\n /**\n * The {json:api} formatted errors associated with the request.\n */\n errors: ApiError[];\n}\n/**\n * The static interface shared by {@link AdapterError} and its subclasses,\n * allowing further subclassing via {@link AdapterRequestErrorConstructor.extend | extend}.\n *\n * @summary Static side of the legacy adapter error constructors: `new (errors?, message?)` plus `extend({ message })`\n * for creating further error subclasses.\n */\nexport interface AdapterRequestErrorConstructor<Instance extends AdapterRequestError = AdapterRequestError> {\n new (errors?: unknown[], message?: string): Instance;\n /**\n * Creates a new {@link AdapterRequestErrorConstructor} that inherits from this one.\n */\n extend(options: { message: string }): AdapterRequestErrorConstructor;\n}\n\n_AdapterError.prototype = Object.create(Error.prototype);\n\n_AdapterError.prototype.code = 'AdapterError';\n_AdapterError.extend = extendFn(_AdapterError as unknown as AdapterRequestErrorConstructor);\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link AdapterError} constructor.\n *\n * @summary Legacy base error an adapter returns or throws to signal a failed API request; extend it to define\n * app-specific error types.\n */\nexport type AdapterError = AdapterRequestError<'AdapterError'>;\n/**\n * :::danger\n * ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.\n * If starting a new app or thinking of implementing a new adapter, consider writing a\n * {@link Handler} instead to be used with the {@link RequestManager}\n * :::\n *\n * An `AdapterError` is used by an adapter to signal that an error occurred\n * during a request to an external API. It indicates a generic error, and\n * subclasses are used to indicate specific error states.\n *\n * To create a custom error to signal a specific error state in communicating\n * with an external API, extend the `AdapterError`. For example, if the\n * external API exclusively used HTTP `503 Service Unavailable` to indicate\n * it was closed for maintenance:\n *\n * ```js [app/adapters/maintenance-error.js]\n * import AdapterError from '@warp-drive/legacy/adapter/error';\n *\n * export default AdapterError.extend({ message: \"Down for maintenance.\" });\n * ```\n *\n * This error would then be returned by an adapter's `handleResponse` method:\n *\n * ```js [app/adapters/application.js]\n * import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';\n * import MaintenanceError from './maintenance-error';\n *\n * export default class ApplicationAdapter extends JSONAPIAdapter {\n * handleResponse(status) {\n * if (503 === status) {\n * return new MaintenanceError();\n * }\n *\n * return super.handleResponse(...arguments);\n * }\n * }\n * ```\n *\n * And can then be detected in an application and used to send the user to an\n * `under-maintenance` route:\n *\n * ```js [app/routes/application.js]\n * import MaintenanceError from '../adapters/maintenance-error';\n *\n * export default class ApplicationRoute extends Route {\n * actions: {\n * error(error, transition) {\n * if (error instanceof MaintenanceError) {\n * this.transitionTo('under-maintenance');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * }\n * ```\n *\n * ### Signaling an Error Without Extending `AdapterError`\n *\n * Extending `AdapterError` (or one of its subclasses) is a convenience, not\n * a requirement. WarpDrive only inspects an error for the {@link AdapterRequestError}\n * shape: an `isAdapterError` flag, a `code`, and an {json:api}-formatted\n * `errors` array. Any object satisfying that shape — including a plain\n * `Error` with those properties attached — will be handled identically to\n * an instance created via `new AdapterError()` or one of its subclasses.\n *\n * This is useful when you'd rather not introduce a class hierarchy, or\n * when the error needs to be constructed from data you don't control\n * (for example, re-throwing an error surfaced by a third-party library):\n *\n * ```js [app/adapters/application.js]\n * import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';\n *\n * export default class ApplicationAdapter extends JSONAPIAdapter {\n * handleResponse(status, headers, payload) {\n * if (status === 503) {\n * const error = new Error('Down for maintenance.');\n * error.isAdapterError = true;\n * error.code = 'MaintenanceError';\n * error.errors = [{ title: 'Service Unavailable', detail: 'Down for maintenance.' }];\n * return error;\n * }\n *\n * return super.handleResponse(status, headers, payload);\n * }\n * }\n * ```\n *\n * Because `code` is just a string you control, `error instanceof AdapterError`\n * checks won't match a plain object built this way — consumers should\n * instead branch on `error.isAdapterError && error.code === 'MaintenanceError'`,\n * or on whichever of the {@link AdapterError} subclasses' `code` values\n * (e.g. `'InvalidError'`, `'NotFoundError'`) the error's `code` matches.\n *\n * @summary Legacy base error constructor an adapter uses to signal a failed API request; call `extend` on it to\n * define app-specific error types.\n * @public\n */\nexport const AdapterError: AdapterRequestErrorConstructor<AdapterError> = getOrSetGlobal(\n 'AdapterError',\n _AdapterError as unknown as AdapterRequestErrorConstructor<AdapterError>\n);\ntype ErrorExtender = (opts: { message?: string }) => AdapterRequestErrorConstructor;\nfunction extendFn(ErrorClass: AdapterRequestErrorConstructor): ErrorExtender {\n return function ({ message: defaultMessage }: { message?: string } = {}) {\n return extend(ErrorClass, defaultMessage);\n };\n}\n\nfunction extend<Final extends AdapterRequestError>(\n ParentErrorClass: AdapterRequestErrorConstructor,\n defaultMessage?: string\n): AdapterRequestErrorConstructor<Final> {\n const ErrorClass = function (this: AdapterRequestError, errors: ApiError[], message?: string) {\n assert('`AdapterError` expects json-api formatted errors array.', Array.isArray(errors || []));\n ParentErrorClass.call(this, errors, message || defaultMessage);\n };\n // oxlint-disable-next-line typescript/no-unsafe-argument\n ErrorClass.prototype = Object.create(ParentErrorClass.prototype);\n ErrorClass.extend = extendFn(ErrorClass as unknown as AdapterRequestErrorConstructor);\n\n return ErrorClass as unknown as AdapterRequestErrorConstructor<Final>;\n}\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link InvalidError} constructor.\n * @summary Instance type of the legacy `InvalidError`, the adapter error for a request the API rejected as\n * semantically invalid.\n */\n// TODO @deprecate extractError documentation\nexport type InvalidError = AdapterRequestError<'InvalidError'>;\n/**\n * An `InvalidError` is used by an adapter to signal that the external API\n * was unable to process a request because the content was not semantically\n * correct or meaningful per the API. Usually, this means a record failed\n * some form of server-side validation. When a promise from an adapter is\n * rejected with an `InvalidError` the record will transition to the\n * `invalid` state and the errors will be set to the `errors` property on\n * the record.\n *\n * For WarpDrive to correctly map errors to their corresponding properties\n * on the model, WarpDrive expects each error to be a valid {json:api} error\n * object with a `source.pointer` that matches the property name. For\n * example, if you had a `Post` model that looked like this:\n *\n * ```js [app/models/post.js]\n * import { Model, attr } from '@warp-drive/legacy/model';\n *\n * export default class PostModel extends Model {\n * @attr('string') title;\n * @attr('string') content;\n * }\n * ```\n *\n * To show an error from the server related to the `title` and `content`\n * properties your adapter could return a promise that rejects with an\n * `InvalidError` that looks like this:\n *\n * ```js [app/adapters/post.js]\n * import RSVP from 'RSVP';\n * import RESTAdapter from '@warp-drive/legacy/adapter/rest';\n * import { InvalidError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationAdapter extends RESTAdapter {\n * updateRecord() {\n * // Fictional adapter that always rejects\n * return RSVP.reject(new InvalidError([\n * {\n * detail: 'Must be unique',\n * source: { pointer: '/data/attributes/title' }\n * },\n * {\n * detail: 'Must not be blank',\n * source: { pointer: '/data/attributes/content' }\n * }\n * ]));\n * }\n * }\n * ```\n *\n * Your backend may use different property names for your records; the\n * store will attempt to extract and normalize the errors using the\n * serializer's `extractErrors` method before the errors get added to the\n * model. As a result, it is safe for the `InvalidError` to wrap the error\n * payload unaltered.\n *\n * @summary Legacy adapter error signaling that the API rejected a request as semantically invalid, typically failed\n * server-side validation, putting the record in the `invalid` state.\n * @public\n */\nexport const InvalidError: AdapterRequestErrorConstructor<InvalidError> = getOrSetGlobal(\n 'InvalidError',\n extend<InvalidError>(AdapterError, 'The adapter rejected the commit because it was invalid')\n);\nInvalidError.prototype.code = 'InvalidError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link TimeoutError} constructor.\n *\n * @summary Legacy adapter error signaling that a request to the API timed out without receiving a response.\n */\nexport type TimeoutError = AdapterRequestError<'TimeoutError'>;\n/**\n * A `TimeoutError` is used by an adapter to signal that a request to the\n * external API has timed out, i.e. no response was received from the\n * external API within an allowed time period.\n *\n * An example use case would be to warn the user to check their internet\n * connection if an adapter operation has timed out:\n *\n * ```js [app/routes/application.js]\n * import { TimeoutError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof TimeoutError) {\n * // alert the user\n * alert('Are you still connected to the Internet?');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @summary Legacy adapter error constructor for signaling that a request to the API timed out without receiving a\n * response.\n * @public\n */\nexport const TimeoutError: AdapterRequestErrorConstructor<TimeoutError> = getOrSetGlobal(\n 'TimeoutError',\n extend(AdapterError, 'The adapter operation timed out')\n);\nTimeoutError.prototype.code = 'TimeoutError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link AbortError} constructor.\n *\n * @summary Legacy adapter error signaling that a request to the API was aborted before a response arrived.\n */\nexport type AbortError = AdapterRequestError<'AbortError'>;\n/**\n * An `AbortError` is used by an adapter to signal that a request to the\n * external API was aborted. For example, this can occur if the user\n * navigates away from the current page after a request to the external API\n * has been initiated but before a response has been received.\n *\n * Because an aborted request is typically expected (the user chose to\n * navigate away, or a newer request superseded this one) rather than\n * exceptional, an example use case would be to silently ignore it instead\n * of surfacing an error to the user:\n *\n * ```js [app/routes/application.js]\n * import { AbortError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof AbortError) {\n * // the request was aborted, nothing to report\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @summary Legacy adapter error constructor for signaling that a request to the API was aborted before a response\n * arrived.\n * @public\n */\nexport const AbortError: AdapterRequestErrorConstructor<AbortError> = getOrSetGlobal(\n 'AbortError',\n extend(AdapterError, 'The adapter operation was aborted')\n);\nAbortError.prototype.code = 'AbortError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link UnauthorizedError} constructor.\n *\n * @summary Legacy adapter error for an HTTP 401 response, signaling that authorization is required and failed or\n * was not provided.\n */\nexport type UnauthorizedError = AdapterRequestError<'UnauthorizedError'>;\n/**\n * A `UnauthorizedError` equates to an HTTP `401 Unauthorized` response\n * status. It is used by an adapter to signal that a request to the external\n * API was rejected because authorization is required and has failed or has\n * not yet been provided.\n *\n * An example use case would be to redirect the user to a login route if a\n * request is unauthorized:\n *\n * ```js [app/routes/application.js]\n * import { UnauthorizedError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof UnauthorizedError) {\n * // go to the login route\n * this.transitionTo('login');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @summary Legacy adapter error constructor for an HTTP 401 response, signaling that authorization is required and\n * failed or was not provided.\n * @public\n */\nexport const UnauthorizedError: AdapterRequestErrorConstructor<UnauthorizedError> = getOrSetGlobal(\n 'UnauthorizedError',\n extend(AdapterError, 'The adapter operation is unauthorized')\n);\nUnauthorizedError.prototype.code = 'UnauthorizedError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link ForbiddenError} constructor.\n *\n * @summary Legacy adapter error for an HTTP 403 response, signaling that the server refused a valid request the\n * user lacks permission for.\n */\nexport type ForbiddenError = AdapterRequestError<'ForbiddenError'>;\n/**\n * A `ForbiddenError` equates to an HTTP `403 Forbidden` response status.\n * It is used by an adapter to signal that a request to the external API was\n * valid but the server is refusing to respond to it. If authorization was\n * provided and is valid, then the authenticated user does not have the\n * necessary permissions for the request.\n *\n * Unlike an {@link UnauthorizedError}, retrying the request with different\n * credentials will not help; the currently authenticated user simply lacks\n * permission. An example use case would be to show the user a \"you don't\n * have access to this\" message rather than redirecting them to log in:\n *\n * ```js [app/routes/application.js]\n * import { ForbiddenError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof ForbiddenError) {\n * this.transitionTo('forbidden');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @summary Legacy adapter error constructor for an HTTP 403 response, signaling that the server refused a valid\n * request the user lacks permission for.\n * @public\n */\nexport const ForbiddenError: AdapterRequestErrorConstructor<ForbiddenError> = getOrSetGlobal(\n 'ForbiddenError',\n extend(AdapterError, 'The adapter operation is forbidden')\n);\nForbiddenError.prototype.code = 'ForbiddenError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link NotFoundError} constructor.\n *\n * @summary Legacy adapter error for an HTTP 404 response, signaling that the requested resource does not exist on\n * the API.\n */\nexport type NotFoundError = AdapterRequestError<'NotFoundError'>;\n/**\n * A `NotFoundError` equates to an HTTP `404 Not Found` response status.\n * It is used by an adapter to signal that a request to the external API\n * was rejected because the resource could not be found on the API.\n *\n * An example use case would be to detect if the user has entered a route\n * for a specific model that does not exist. For example:\n *\n * ```js [app/routes/post.js]\n * import { NotFoundError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class PostRoute extends Route {\n * @service store;\n * model(params) {\n * return this.store.findRecord('post', params.post_id);\n * }\n * @action\n * error(error, transition) {\n * if (error instanceof NotFoundError) {\n * // redirect to a list of all posts instead\n * this.transitionTo('posts');\n * } else {\n * // otherwise let the error bubble\n * return true;\n * }\n * }\n * }\n * ```\n *\n * @summary Legacy adapter error constructor for an HTTP 404 response, signaling that the requested resource does not\n * exist on the API.\n * @public\n */\nexport const NotFoundError: AdapterRequestErrorConstructor<NotFoundError> = getOrSetGlobal(\n 'NotFoundError',\n extend(AdapterError, 'The adapter could not find the resource')\n);\nNotFoundError.prototype.code = 'NotFoundError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link ConflictError} constructor.\n *\n * @summary Legacy adapter error for an HTTP 409 response, signaling that the request conflicts with existing\n * server state, such as a duplicate client-generated id.\n */\nexport type ConflictError = AdapterRequestError<'ConflictError'>;\n/**\n * A `ConflictError` equates to an HTTP `409 Conflict` response status.\n * It is used by an adapter to indicate that the request could not be\n * processed because of a conflict in the request. An example scenario\n * would be when creating a record with a client-generated ID but that ID\n * is already known to the external API.\n *\n * An example use case would be to surface a conflict-specific message so\n * the user can retry with different input:\n *\n * ```js [app/routes/application.js]\n * import { ConflictError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof ConflictError) {\n * alert('That identifier is already in use, please choose another.');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @summary Legacy adapter error constructor for an HTTP 409 response, signaling that the request conflicts with\n * existing server state, such as a duplicate client-generated id.\n * @public\n */\nexport const ConflictError: AdapterRequestErrorConstructor<ConflictError> = getOrSetGlobal(\n 'ConflictError',\n extend(AdapterError, 'The adapter operation failed due to a conflict')\n);\nConflictError.prototype.code = 'ConflictError';\n\n/**\n * The {@link AdapterRequestError} shape thrown by the {@link ServerError} constructor.\n *\n * @summary Legacy adapter error for an HTTP 500 response, signaling that the API failed internally and an\n * immediate retry is unlikely to succeed.\n */\nexport type ServerError = AdapterRequestError<'ServerError'>;\n/**\n * A `ServerError` equates to an HTTP `500 Internal Server Error` response\n * status. It is used by the adapter to indicate that a request has failed\n * because of an error in the external API, and is unlikely to succeed if\n * retried immediately.\n *\n * An example use case would be to show a generic \"something went wrong on\n * our end\" message rather than one implying the user made a mistake:\n *\n * ```js [app/routes/application.js]\n * import { ServerError } from '@warp-drive/legacy/adapter/error';\n *\n * export default class ApplicationRoute extends Route {\n * @action\n * error(error, transition) {\n * if (error instanceof ServerError) {\n * alert('Something went wrong on our end. Please try again later.');\n * return;\n * }\n *\n * // ...other error handling logic\n * }\n * }\n * ```\n *\n * @summary Legacy adapter error constructor for an HTTP 500 response, signaling that the API failed internally and\n * an immediate retry is unlikely to succeed.\n * @public\n */\nexport const ServerError: AdapterRequestErrorConstructor<ServerError> = getOrSetGlobal(\n 'ServerError',\n extend(AdapterError, 'The adapter operation failed due to a server error')\n);\nServerError.prototype.code = 'ServerError';\n"],"mappings":";;;;;;;;AAgBA,SAASC,cAAyCC,QAAoBC,UAAU,4BAA4B;CAC1G,KAAKC,iBAAiB;CACtB,MAAMC,QAAQC,MAAMC,KAAK,MAAMJ,OAAO;CAEtC,IAAIE,OAAO;EACT,KAAKG,QAAQH,MAAMG;EAEnB,KAAKC,cAAcJ,MAAMI;EAEzB,KAAKC,WAAWL,MAAMK;EAEtB,KAAKC,aAAaN,MAAMM;EACxB,KAAKR,UAAUE,MAAMF;EACrB,KAAKS,OAAOP,MAAMO;EAElB,KAAKC,SAASR,MAAMQ;CACtB;CAEA,KAAKX,SAASA,UAAU,CACtB;EACEY,OAAO;EACPC,QAAQZ;CACV,CAAC;AAEL;;;;;;;;;;;;;;AAqCAF,cAAce,YAAYC,OAAOC,OAAOZ,MAAMU,SAAS;AAEvDf,cAAce,UAAUG,OAAO;AAC/BlB,cAAcmB,SAASC,SAASpB,a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AuC,CAC9D;AACAU,kBAAkBhB,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCnC,MAAac,iBAAiEjC,eAC5E,kBACAoB,OAAOE,cAAc,oCAAoC,CAC3D;AACAW,eAAejB,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0ChC,MAAae,gBAA+DlC,eAC1E,iBACAoB,OAAOE,cAAc,yCAAyC,CAChE;AACAY,cAAclB,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuC/B,MAAagB,gBAA+DnC,eAC1E,iBACAoB,OAAOE,cAAc,gDAAgD,CACvE;AACAa,cAAcnB,UAAUG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsC/B,MAAaiB,cAA2DpC,eACtE,eACAoB,OAAOE,cAAc,oDAAoD,CAC3E;AACAc,YAAYpB,UAAUG,OAAO"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { t as serializeIntoHash } from "../-private-
|
|
1
|
+
import { t as serializeIntoHash } from "../-private-BprUAEe_.js";
|
|
2
2
|
import { RESTAdapter } from "./rest.js";
|
|
3
3
|
import { dasherize, pluralize } from "@warp-drive/utilities/string";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/adapter/json-api.ts
|
|
6
|
+
/**
|
|
7
|
+
* @module
|
|
8
|
+
* @summary Legacy `JSONAPIAdapter`, which turns store requests into HTTP requests following JSON:API URL, verb and
|
|
9
|
+
* header conventions.
|
|
10
|
+
*/
|
|
6
11
|
/**
|
|
7
12
|
## Overview
|
|
8
13
|
|
|
@@ -12,7 +17,7 @@ If starting a new app or thinking of implementing a new adapter, consider writin
|
|
|
12
17
|
{@link Handler} instead to be used with the {@link RequestManager}
|
|
13
18
|
:::
|
|
14
19
|
|
|
15
|
-
The `JSONAPIAdapter` is an adapter
|
|
20
|
+
The `JSONAPIAdapter` is an adapter which transforms the store's
|
|
16
21
|
requests into HTTP requests that follow the [JSON API format](http://jsonapi.org/format/).
|
|
17
22
|
|
|
18
23
|
## JSON API Conventions
|
|
@@ -139,6 +144,8 @@ host = 'https://api.example.com';
|
|
|
139
144
|
Requests for the `person` model would now target
|
|
140
145
|
`https://api.example.com/people/1`.
|
|
141
146
|
|
|
147
|
+
@summary Legacy adapter that turns store requests into HTTP requests following JSON:API URL, verb, and
|
|
148
|
+
`application/vnd.api+json` conventions.
|
|
142
149
|
@since 1.13.0
|
|
143
150
|
@class JSONAPIAdapter
|
|
144
151
|
@public
|
|
@@ -260,6 +267,5 @@ var JSONAPIAdapter = class extends RESTAdapter {
|
|
|
260
267
|
}
|
|
261
268
|
};
|
|
262
269
|
|
|
263
|
-
//#endregion
|
|
264
270
|
export { JSONAPIAdapter };
|
|
265
271
|
//# sourceMappingURL=json-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-api.js","names":["dasherize","pluralize","serializeIntoHash","RESTAdapter","JSONAPIAdapter","_defaultContentType","ajaxOptions","url","type","options","hash","headers","coalesceFindRequests","_coalesceFindRequests","value","findMany","store","ids","snapshots","buildURL","modelName","ajax","data","filter","id","join","pathForType","dasherized","updateRecord","schema","snapshot","test","Error","length","buildQuery","query","include","normalizedInclude","Array","isArray"],"sources":["../../../../src/adapter/json-api.ts"],"sourcesContent":["// oxlint-disable-next-line no-unused-vars\nimport type { RequestManager, Store } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\n// oxlint-disable-next-line no-unused-vars\nimport type { Handler } from '@warp-drive/core/request';\nimport type { ModelSchema } from '@warp-drive/core/types';\nimport type { HTTPMethod } from '@warp-drive/core/types/request';\nimport { dasherize, pluralize } from '@warp-drive/utilities/string';\n\nimport type { AdapterPayload } from '../compat.ts';\nimport type { Snapshot, SnapshotRecordArray } from '../compat/-private.ts';\nimport { serializeIntoHash } from './-private.ts';\nimport type { FetchRequestInit, JQueryRequestInit, QueryState } from './rest.ts';\nimport { RESTAdapter } from './rest.ts';\n/**\n ## Overview\n\n :::danger\n ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.\n If starting a new app or thinking of implementing a new adapter, consider writing a\n {@link Handler} instead to be used with the {@link RequestManager}\n :::\n\n The `JSONAPIAdapter` is an adapter whichtransforms the store's\n requests into HTTP requests that follow the [JSON API format](http://jsonapi.org/format/).\n\n ## JSON API Conventions\n\n The JSONAPIAdapter uses JSON API conventions for building the URL\n for a record and selecting the HTTP verb to use with a request. The\n actions you can take on a record map onto the following URLs in the\n JSON API adapter:\n\n<table>\n <tr>\n <th>\n Action\n </th>\n <th>\n HTTP Verb\n </th>\n <th>\n URL\n </th>\n </tr>\n <tr>\n <th>\n `store.findRecord('post', 123)`\n </th>\n <td>\n GET\n </td>\n <td>\n /posts/123\n </td>\n </tr>\n <tr>\n <th>\n `store.findAll('post')`\n </th>\n <td>\n GET\n </td>\n <td>\n /posts\n </td>\n </tr>\n <tr>\n <th>\n Update `postRecord.save()`\n </th>\n <td>\n PATCH\n </td>\n <td>\n /posts/123\n </td>\n </tr>\n <tr>\n <th>\n Create `store.createRecord('post').save()`\n </th>\n <td>\n POST\n </td>\n <td>\n /posts\n </td>\n </tr>\n <tr>\n <th>\n Delete `postRecord.destroyRecord()`\n </th>\n <td>\n DELETE\n </td>\n <td>\n /posts/123\n </td>\n </tr>\n</table>\n\n ## Success and failure\n\n The JSONAPIAdapter will consider a success any response with a\n status code of the 2xx family (\"Success\"), as well as 304 (\"Not\n Modified\"). Any other status code will be considered a failure.\n\n On success, the request promise will be resolved with the full\n response payload.\n\n Failed responses with status code 422 (\"Unprocessable Entity\") will\n be considered \"invalid\". The response will be discarded, except for\n the `errors` key. The request promise will be rejected with a\n `InvalidError`. This error object will encapsulate the saved\n `errors` value.\n\n Any other status codes will be treated as an adapter error. The\n request promise will be rejected, similarly to the invalid case,\n but with an instance of `AdapterError` instead.\n\n ### Endpoint path customization\n\n Endpoint paths can be prefixed with a `namespace` by setting the\n namespace property on the adapter:\n\n ```js [app/adapters/application.js]\n import { JSONAPIAdapter } from '@warp-drive/legacy/adapter/json-api';\n\n export default class ApplicationAdapter extends JSONAPIAdapter {\n namespace = 'api/1';\n }\n ```\n Requests for the `person` model would now target `/api/1/people/1`.\n\n ### Host customization\n\n An adapter can target other hosts by setting the `host` property.\n\n ```js [app/adapters/application.js]\n import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';\n\n export default class ApplicationAdapter extends JSONAPIAdapter {\n host = 'https://api.example.com';\n }\n ```\n\n Requests for the `person` model would now target\n `https://api.example.com/people/1`.\n\n @since 1.13.0\n @class JSONAPIAdapter\n @public\n @constructor\n*/\nclass JSONAPIAdapter extends RESTAdapter {\n /**\n * The `Content-Type` header used when serializing request bodies\n * that don't otherwise specify one.\n */\n _defaultContentType = 'application/vnd.api+json';\n\n /**\n @private\n @param {String} url\n @param {String} type The request type GET, POST, PUT, DELETE etc.\n @param {Object} options\n @return {Object}\n */\n ajaxOptions(\n url: string,\n type: HTTPMethod,\n options: JQueryAjaxSettings | RequestInit = {}\n ): JQueryRequestInit | FetchRequestInit {\n const hash = super.ajaxOptions(url, type, options) as FetchRequestInit;\n const headers: HeadersInit = (hash.headers = hash.headers || {});\n headers['Accept'] = (headers['Accept'] as string) || 'application/vnd.api+json';\n\n return hash;\n }\n\n /**\n By default the JSONAPIAdapter will send each find request coming from a `store.find`\n or from accessing a relationship separately to the server. If your server supports passing\n ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests\n within a single runloop.\n\n For example, if you have an initial payload of:\n\n ```javascript\n {\n data: {\n id: 1,\n type: 'post',\n relationship: {\n comments: {\n data: [\n { id: 1, type: 'comment' },\n { id: 2, type: 'comment' }\n ]\n }\n }\n }\n }\n ```\n\n By default calling `post.comments` will trigger the following requests(assuming the\n comments haven't been loaded before):\n\n ```\n GET /comments/1\n GET /comments/2\n ```\n\n If you set coalesceFindRequests to `true` it will instead trigger the following request:\n\n ```\n GET /comments?filter[id]=1,2\n ```\n\n Setting coalesceFindRequests to `true` also works for `store.find` requests and `belongsTo`\n relationships accessed within the same runloop. If you set `coalesceFindRequests: true`\n\n ```javascript\n store.findRecord('comment', 1);\n store.findRecord('comment', 2);\n ```\n\n will also send a request to: `GET /comments?filter[id]=1,2`\n\n Note: Requests coalescing rely on URL building strategy. So if you override `buildURL` in your app\n `groupRecordsForFindMany` more likely should be overridden as well in order for coalescing to work.\n\n @property coalesceFindRequests\n @public\n @type {Boolean}\n */\n get coalesceFindRequests() {\n const coalesceFindRequests = this._coalesceFindRequests;\n if (typeof coalesceFindRequests === 'boolean') {\n return coalesceFindRequests;\n }\n return (this._coalesceFindRequests = false);\n }\n\n set coalesceFindRequests(value: boolean) {\n this._coalesceFindRequests = value;\n }\n\n findMany(store: Store, type: ModelSchema, ids: string[], snapshots: Snapshot[]): Promise<AdapterPayload> {\n const url = this.buildURL(type.modelName, ids, snapshots, 'findMany');\n return this.ajax(url, 'GET', { data: { filter: { id: ids.join(',') } } });\n }\n\n /**\n * Determines the pathname for a given type.\n *\n * Unlike the base `BuildURLMixin` implementation, dasherizes (rather\n * than camelizes) the type name before pluralizing it, per the\n * {json:api} convention for member names.\n */\n pathForType(modelName: string): string {\n const dasherized = dasherize(modelName);\n return pluralize(dasherized);\n }\n\n updateRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload> {\n const data = serializeIntoHash(store, schema, snapshot);\n const type = snapshot.modelName;\n const id = snapshot.id;\n assert(`Attempted to update the ${type} record, but the record has no id`, typeof id === 'string' && id.length > 0);\n\n const url = this.buildURL(type, id, snapshot, 'updateRecord');\n\n return this.ajax(url, 'PATCH', { data: data });\n }\n\n /**\n Used by `findAll` and `findRecord` to build the query's `data` hash\n supplied to the ajax method.\n\n @since 2.5.0\n @public\n @param {Snapshot} snapshot\n @return {Object}\n */\n buildQuery(snapshot: Snapshot | SnapshotRecordArray): QueryState {\n const query: QueryState = {};\n\n if (snapshot) {\n const { include } = snapshot;\n const normalizedInclude = Array.isArray(include) ? include.join(',') : include;\n\n if (normalizedInclude) {\n query.include = normalizedInclude;\n }\n }\n\n return query;\n }\n}\n\nexport { JSONAPIAdapter };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2JA,IAAMI,iBAAN,cAA6BD,YAAY;;;;;CAKvCE,sBAAsB;;;;;;;;CAStBC,YACEC,KACAC,MACAC,UAA4C,CAAC,GACP;EACtC,MAAMC,OAAO,MAAMJ,YAAYC,KAAKC,MAAMC,OAAO;EACjD,MAAME,UAAwBD,KAAKC,UAAUD,KAAKC,WAAW,CAAC;EAC9DA,QAAQ,YAAaA,QAAQ,aAAwB;EAErD,OAAOD;CACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DA,IAAIE,uBAAuB;EACzB,MAAMA,uBAAuB,KAAKC;EAClC,IAAI,OAAOD,yBAAyB,WAClC,OAAOA;EAET,OAAQ,KAAKC,wBAAwB;CACvC;CAEA,IAAID,qBAAqBE,OAAgB;EACvC,KAAKD,wBAAwBC;CAC/B;CAEAC,SAASC,OAAcR,MAAmBS,KAAeC,WAAgD;EACvG,MAAMX,MAAM,KAAKY,SAASX,KAAKY,WAAWH,KAAKC,WAAW,UAAU;EACpE,OAAO,KAAKG,KAAKd,KAAK,OAAO,EAAEe,MAAM,EAAEC,QAAQ,EAAEC,IAAIP,IAAIQ,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC;CAC1E;;;;;;;;CASAC,YAAYN,WAA2B;EACrC,MAAMO,aAAa3B,UAAUoB,SAAS;EACtC,OAAOnB,UAAU0B,UAAU;CAC7B;CAEAC,aAAaZ,OAAca,QAAqBC,UAA6C;EAC3F,MAAMR,OAAOpB,kBAAkBc,OAAOa,QAAQC,QAAQ;EACtD,MAAMtB,OAAOsB,SAASV;EACtB,MAAMI,KAAKM,SAASN;EACpB,EAAAO,SAAA;GAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,2BAA2BxB,KAAI,kCAAmC;EAAA,EAAA,CAAE,OAAOgB,OAAO,YAAYA,GAAGS,SAAS,CAAC;EAElH,MAAM1B,MAAM,KAAKY,SAASX,MAAMgB,IAAIM,UAAU,cAAc;EAE5D,OAAO,KAAKT,KAAKd,KAAK,SAAS,EAAQe,KAAK,CAAC;CAC/C;;;;;;;;;CAWAY,WAAWJ,UAAsD;EAC/D,MAAMK,QAAoB,CAAC;EAE3B,IAAIL,UAAU;GACZ,MAAM,EAAEM,YAAYN;GACpB,MAAMO,oBAAoBC,MAAMC,QAAQH,OAAO,IAAIA,QAAQX,KAAK,GAAG,IAAIW;GAEvE,IAAIC,mBACFF,MAAMC,UAAUC;EAEpB;EAEA,OAAOF;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"json-api.js","names":["dasherize","pluralize","serializeIntoHash","RESTAdapter","JSONAPIAdapter","_defaultContentType","ajaxOptions","url","type","options","hash","headers","coalesceFindRequests","_coalesceFindRequests","value","findMany","store","ids","snapshots","buildURL","modelName","ajax","data","filter","id","join","pathForType","dasherized","updateRecord","schema","snapshot","test","Error","length","buildQuery","query","include","normalizedInclude","Array","isArray"],"sources":["../../../../src/adapter/json-api.ts"],"sourcesContent":["/**\n * @module\n * @summary Legacy `JSONAPIAdapter`, which turns store requests into HTTP requests following JSON:API URL, verb and\n * header conventions.\n */\n\n// oxlint-disable-next-line no-unused-vars\nimport type { RequestManager, Store } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\n// oxlint-disable-next-line no-unused-vars\nimport type { Handler } from '@warp-drive/core/request';\nimport type { ModelSchema } from '@warp-drive/core/types';\nimport type { HTTPMethod } from '@warp-drive/core/types/request';\nimport { dasherize, pluralize } from '@warp-drive/utilities/string';\n\nimport type { AdapterPayload } from '../compat.ts';\nimport type { Snapshot, SnapshotRecordArray } from '../compat/-private.ts';\nimport { serializeIntoHash } from './-private.ts';\nimport type { FetchRequestInit, JQueryRequestInit, QueryState } from './rest.ts';\nimport { RESTAdapter } from './rest.ts';\n/**\n ## Overview\n\n :::danger\n ⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.\n If starting a new app or thinking of implementing a new adapter, consider writing a\n {@link Handler} instead to be used with the {@link RequestManager}\n :::\n\n The `JSONAPIAdapter` is an adapter which transforms the store's\n requests into HTTP requests that follow the [JSON API format](http://jsonapi.org/format/).\n\n ## JSON API Conventions\n\n The JSONAPIAdapter uses JSON API conventions for building the URL\n for a record and selecting the HTTP verb to use with a request. The\n actions you can take on a record map onto the following URLs in the\n JSON API adapter:\n\n<table>\n <tr>\n <th>\n Action\n </th>\n <th>\n HTTP Verb\n </th>\n <th>\n URL\n </th>\n </tr>\n <tr>\n <th>\n `store.findRecord('post', 123)`\n </th>\n <td>\n GET\n </td>\n <td>\n /posts/123\n </td>\n </tr>\n <tr>\n <th>\n `store.findAll('post')`\n </th>\n <td>\n GET\n </td>\n <td>\n /posts\n </td>\n </tr>\n <tr>\n <th>\n Update `postRecord.save()`\n </th>\n <td>\n PATCH\n </td>\n <td>\n /posts/123\n </td>\n </tr>\n <tr>\n <th>\n Create `store.createRecord('post').save()`\n </th>\n <td>\n POST\n </td>\n <td>\n /posts\n </td>\n </tr>\n <tr>\n <th>\n Delete `postRecord.destroyRecord()`\n </th>\n <td>\n DELETE\n </td>\n <td>\n /posts/123\n </td>\n </tr>\n</table>\n\n ## Success and failure\n\n The JSONAPIAdapter will consider a success any response with a\n status code of the 2xx family (\"Success\"), as well as 304 (\"Not\n Modified\"). Any other status code will be considered a failure.\n\n On success, the request promise will be resolved with the full\n response payload.\n\n Failed responses with status code 422 (\"Unprocessable Entity\") will\n be considered \"invalid\". The response will be discarded, except for\n the `errors` key. The request promise will be rejected with a\n `InvalidError`. This error object will encapsulate the saved\n `errors` value.\n\n Any other status codes will be treated as an adapter error. The\n request promise will be rejected, similarly to the invalid case,\n but with an instance of `AdapterError` instead.\n\n ### Endpoint path customization\n\n Endpoint paths can be prefixed with a `namespace` by setting the\n namespace property on the adapter:\n\n ```js [app/adapters/application.js]\n import { JSONAPIAdapter } from '@warp-drive/legacy/adapter/json-api';\n\n export default class ApplicationAdapter extends JSONAPIAdapter {\n namespace = 'api/1';\n }\n ```\n Requests for the `person` model would now target `/api/1/people/1`.\n\n ### Host customization\n\n An adapter can target other hosts by setting the `host` property.\n\n ```js [app/adapters/application.js]\n import JSONAPIAdapter from '@warp-drive/legacy/adapter/json-api';\n\n export default class ApplicationAdapter extends JSONAPIAdapter {\n host = 'https://api.example.com';\n }\n ```\n\n Requests for the `person` model would now target\n `https://api.example.com/people/1`.\n\n @summary Legacy adapter that turns store requests into HTTP requests following JSON:API URL, verb, and\n `application/vnd.api+json` conventions.\n @since 1.13.0\n @class JSONAPIAdapter\n @public\n @constructor\n*/\nclass JSONAPIAdapter extends RESTAdapter {\n /**\n * The `Content-Type` header used when serializing request bodies\n * that don't otherwise specify one.\n */\n _defaultContentType = 'application/vnd.api+json';\n\n /**\n @private\n @param {String} url\n @param {String} type The request type GET, POST, PUT, DELETE etc.\n @param {Object} options\n @return {Object}\n */\n ajaxOptions(\n url: string,\n type: HTTPMethod,\n options: JQueryAjaxSettings | RequestInit = {}\n ): JQueryRequestInit | FetchRequestInit {\n const hash = super.ajaxOptions(url, type, options) as FetchRequestInit;\n const headers: HeadersInit = (hash.headers = hash.headers || {});\n headers['Accept'] = (headers['Accept'] as string) || 'application/vnd.api+json';\n\n return hash;\n }\n\n /**\n By default the JSONAPIAdapter will send each find request coming from a `store.find`\n or from accessing a relationship separately to the server. If your server supports passing\n ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests\n within a single runloop.\n\n For example, if you have an initial payload of:\n\n ```javascript\n {\n data: {\n id: 1,\n type: 'post',\n relationship: {\n comments: {\n data: [\n { id: 1, type: 'comment' },\n { id: 2, type: 'comment' }\n ]\n }\n }\n }\n }\n ```\n\n By default calling `post.comments` will trigger the following requests(assuming the\n comments haven't been loaded before):\n\n ```\n GET /comments/1\n GET /comments/2\n ```\n\n If you set coalesceFindRequests to `true` it will instead trigger the following request:\n\n ```\n GET /comments?filter[id]=1,2\n ```\n\n Setting coalesceFindRequests to `true` also works for `store.find` requests and `belongsTo`\n relationships accessed within the same runloop. If you set `coalesceFindRequests: true`\n\n ```javascript\n store.findRecord('comment', 1);\n store.findRecord('comment', 2);\n ```\n\n will also send a request to: `GET /comments?filter[id]=1,2`\n\n Note: Requests coalescing rely on URL building strategy. So if you override `buildURL` in your app\n `groupRecordsForFindMany` more likely should be overridden as well in order for coalescing to work.\n\n @property coalesceFindRequests\n @public\n @type {Boolean}\n */\n get coalesceFindRequests() {\n const coalesceFindRequests = this._coalesceFindRequests;\n if (typeof coalesceFindRequests === 'boolean') {\n return coalesceFindRequests;\n }\n return (this._coalesceFindRequests = false);\n }\n\n set coalesceFindRequests(value: boolean) {\n this._coalesceFindRequests = value;\n }\n\n findMany(store: Store, type: ModelSchema, ids: string[], snapshots: Snapshot[]): Promise<AdapterPayload> {\n const url = this.buildURL(type.modelName, ids, snapshots, 'findMany');\n return this.ajax(url, 'GET', { data: { filter: { id: ids.join(',') } } });\n }\n\n /**\n * Determines the pathname for a given type.\n *\n * Unlike the base `BuildURLMixin` implementation, dasherizes (rather\n * than camelizes) the type name before pluralizing it, per the\n * {json:api} convention for member names.\n */\n pathForType(modelName: string): string {\n const dasherized = dasherize(modelName);\n return pluralize(dasherized);\n }\n\n updateRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload> {\n const data = serializeIntoHash(store, schema, snapshot);\n const type = snapshot.modelName;\n const id = snapshot.id;\n assert(`Attempted to update the ${type} record, but the record has no id`, typeof id === 'string' && id.length > 0);\n\n const url = this.buildURL(type, id, snapshot, 'updateRecord');\n\n return this.ajax(url, 'PATCH', { data: data });\n }\n\n /**\n Used by `findAll` and `findRecord` to build the query's `data` hash\n supplied to the ajax method.\n\n @since 2.5.0\n @public\n @param {Snapshot} snapshot\n @return {Object}\n */\n buildQuery(snapshot: Snapshot | SnapshotRecordArray): QueryState {\n const query: QueryState = {};\n\n if (snapshot) {\n const { include } = snapshot;\n const normalizedInclude = Array.isArray(include) ? include.join(',') : include;\n\n if (normalizedInclude) {\n query.include = normalizedInclude;\n }\n }\n\n return query;\n }\n}\n\nexport { JSONAPIAdapter };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmKA,IAAMI,iBAAN,cAA6BD,YAAY;;;;;CAKvCE,sBAAsB;;;;;;;;CAStBC,YACEC,KACAC,MACAC,UAA4C,CAAC,GACP;EACtC,MAAMC,OAAO,MAAMJ,YAAYC,KAAKC,MAAMC,OAAO;EACjD,MAAME,UAAwBD,KAAKC,UAAUD,KAAKC,WAAW,CAAC;EAC9DA,QAAQ,YAAaA,QAAQ,aAAwB;EAErD,OAAOD;CACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DA,IAAIE,uBAAuB;EACzB,MAAMA,uBAAuB,KAAKC;EAClC,IAAI,OAAOD,yBAAyB,WAClC,OAAOA;EAET,OAAQ,KAAKC,wBAAwB;CACvC;CAEA,IAAID,qBAAqBE,OAAgB;EACvC,KAAKD,wBAAwBC;CAC/B;CAEAC,SAASC,OAAcR,MAAmBS,KAAeC,WAAgD;EACvG,MAAMX,MAAM,KAAKY,SAASX,KAAKY,WAAWH,KAAKC,WAAW,UAAU;EACpE,OAAO,KAAKG,KAAKd,KAAK,OAAO,EAAEe,MAAM,EAAEC,QAAQ,EAAEC,IAAIP,IAAIQ,KAAK,GAAG,EAAE,EAAE,EA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