@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
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as normalizeModelName, t as isMaybeIdentifier } from "../utils-
|
|
1
|
+
import { n as normalizeModelName, t as isMaybeIdentifier } from "../utils-z1h-zTls.js";
|
|
2
2
|
import { recordIdentifierFor, storeFor } from "@warp-drive/core";
|
|
3
3
|
import { assertPrivateStore, constructResource, ensureStringId } from "@warp-drive/core/store/-private";
|
|
4
4
|
import { SkipCache } from "@warp-drive/core/types/request";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/compat/builders/find-all.ts
|
|
7
7
|
/**
|
|
8
8
|
This function builds a request config to perform a `findAll` request for the given type.
|
|
9
9
|
When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request.
|
|
@@ -13,6 +13,8 @@ All `@warp-drive/legacy/compat` builders exist to enable you to migrate your cod
|
|
|
13
13
|
This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
|
|
14
14
|
To that end, these builders are deprecated and will be removed in a future version of WarpDrive.
|
|
15
15
|
|
|
16
|
+
@summary Deprecated legacy builder for a `store.request` config that behaves like `store.findAll`, easing
|
|
17
|
+
migration off adapters and serializers.
|
|
16
18
|
@deprecated
|
|
17
19
|
@public
|
|
18
20
|
@param type the name of the resource
|
|
@@ -30,8 +32,7 @@ function findAllBuilder(type, options = {}) {
|
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
//#region src/compat/builders/find-record.ts
|
|
35
|
+
// src/compat/builders/find-record.ts
|
|
35
36
|
/**
|
|
36
37
|
This function builds a request config to find the record for a given identifier or type and id combination.
|
|
37
38
|
When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request.
|
|
@@ -59,6 +60,8 @@ All `@warp-drive/legacy/compat` builders exist to enable you to migrate your cod
|
|
|
59
60
|
This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
|
|
60
61
|
To that end, these builders are deprecated and will be removed in a future version of Warp Drive.
|
|
61
62
|
|
|
63
|
+
@summary Deprecated legacy builder for a `store.request` config that behaves like `store.findRecord`, taking a
|
|
64
|
+
type and id or a resource identifier.
|
|
62
65
|
@deprecated
|
|
63
66
|
@public
|
|
64
67
|
@param resource - either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record
|
|
@@ -84,8 +87,7 @@ function findRecordBuilder(resource, idOrOptions, options) {
|
|
|
84
87
|
};
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
|
|
88
|
-
//#region src/compat/builders/query.ts
|
|
90
|
+
// src/compat/builders/query.ts
|
|
89
91
|
/**
|
|
90
92
|
This function builds a request config for a given type and query object.
|
|
91
93
|
When passed to `store.request`, this config will result in the same behavior as a `store.query` request.
|
|
@@ -95,6 +97,8 @@ All `@warp-drive/legacy/compat` builders exist to enable you to migrate your cod
|
|
|
95
97
|
This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
|
|
96
98
|
To that end, these builders are deprecated and will be removed in a future version of WarpDrive.
|
|
97
99
|
|
|
100
|
+
@summary Deprecated legacy builder for a `store.request` config that behaves like `store.query`, returning the
|
|
101
|
+
records matching a query object.
|
|
98
102
|
@deprecated
|
|
99
103
|
@public
|
|
100
104
|
@param type the name of the resource
|
|
@@ -122,6 +126,8 @@ All `@warp-drive/legacy/compat` builders exist to enable you to migrate your cod
|
|
|
122
126
|
This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
|
|
123
127
|
To that end, these builders are deprecated and will be removed in a future version of WarpDrive.
|
|
124
128
|
|
|
129
|
+
@summary Deprecated legacy builder for a `store.request` config that behaves like `store.queryRecord`, returning
|
|
130
|
+
a single record or `null` for a query object.
|
|
125
131
|
@deprecated
|
|
126
132
|
@public
|
|
127
133
|
@param type the name of the resource
|
|
@@ -141,8 +147,7 @@ function queryRecordBuilder(type, query, options) {
|
|
|
141
147
|
};
|
|
142
148
|
}
|
|
143
149
|
|
|
144
|
-
|
|
145
|
-
//#region src/compat/builders/save-record.ts
|
|
150
|
+
// src/compat/builders/save-record.ts
|
|
146
151
|
function _resourceIsFullDeleted(identifier, cache) {
|
|
147
152
|
return cache.isDeletionCommitted(identifier) || cache.isNew(identifier) && cache.isDeleted(identifier);
|
|
148
153
|
}
|
|
@@ -159,6 +164,8 @@ All `@ember-data/legacy-compat` builders exist to enable you to migrate your cod
|
|
|
159
164
|
This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.
|
|
160
165
|
To that end, these builders are deprecated and will be removed in a future version of Ember Data.
|
|
161
166
|
|
|
167
|
+
@summary Deprecated legacy builder for a `store.request` config that creates, updates, or deletes a record
|
|
168
|
+
through adapters, like the legacy `store.saveRecord`.
|
|
162
169
|
@deprecated
|
|
163
170
|
@public
|
|
164
171
|
@param {Object} record a record to save
|
|
@@ -187,6 +194,5 @@ function saveRecordBuilder(record, options = {}) {
|
|
|
187
194
|
};
|
|
188
195
|
}
|
|
189
196
|
|
|
190
|
-
//#endregion
|
|
191
197
|
export { findAllBuilder as findAll, findRecordBuilder as findRecord, queryBuilder as query, queryRecordBuilder as queryRecord, saveRecordBuilder as saveRecord };
|
|
192
198
|
//# sourceMappingURL=builders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.js","names":["SkipCache","normalizeModelName","findAllBuilder","type","options","op","data","cacheOptions","constructResource","ensureStringId","SkipCache","isMaybeIdentifier","normalizeModelName","findRecordBuilder","resource","idOrOptions","options","type","normalizedId","op","data","record","cacheOptions","SkipCache","normalizeModelName","queryBuilder","type","query","options","op","data","cacheOptions","queryRecordBuilder","recordIdentifierFor","storeFor","assertPrivateStore","SkipCache","_resourceIsFullDeleted","identifier","cache","isDeletionCommitted","isNew","isDeleted","resourceIsFullyDeleted","instanceCache","saveRecordBuilder","record","options","store","Error","_instanceCache","operation","op","data","records","cacheOptions"],"sources":["../../../../src/compat/builders/find-all.ts","../../../../src/compat/builders/find-record.ts","../../../../src/compat/builders/query.ts","../../../../src/compat/builders/save-record.ts"],"sourcesContent":["import type { StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { FindAllOptions } from '@warp-drive/core/types';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\nimport { normalizeModelName } from './utils.ts';\n\ntype FindAllRequestInput<T extends string = string, RT = unknown[]> = StoreRequestInput & {\n op: 'findAll';\n data: {\n type: T;\n options: FindAllBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype FindAllBuilderOptions = FindAllOptions;\n\n/**\n This function builds a request config to perform a `findAll` request for the given type.\n When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request.\n Additionally, it takes the same options as `store.findAll`.\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of WarpDrive.\n\n @deprecated\n @public\n @param type the name of the resource\n @param options optional, may include `adapterOptions` hash which will be passed to adapter.findAll\n @return request config\n*/\nexport function findAllBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n options?: FindAllBuilderOptions\n): FindAllRequestInput<TypeFromInstance<T>, T[]>;\nexport function findAllBuilder(type: string, options?: FindAllBuilderOptions): FindAllRequestInput;\nexport function findAllBuilder(type: string, options: FindAllBuilderOptions = {}): FindAllRequestInput {\n assert(`You need to pass a model name to the findAll builder`, type);\n assert(\n `Model name passed to the findAll builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'findAll',\n data: {\n type: normalizeModelName(type),\n options: options || {},\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","import type { StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { constructResource, ensureStringId } from '@warp-drive/core/store/-private';\nimport type { BaseFinderOptions, FindRecordOptions } from '@warp-drive/core/types';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { ResourceIdentifierObject } from '@warp-drive/core/types/spec/json-api-raw';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\nimport { isMaybeIdentifier, normalizeModelName } from './utils.ts';\n\ntype FindRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'findRecord';\n data: {\n record: ResourceIdentifierObject<T>;\n options: FindRecordBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype FindRecordBuilderOptions = Omit<FindRecordOptions, 'preload'>;\n\n/**\n This function builds a request config to find the record for a given identifier or type and id combination.\n When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request.\n Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported).\n\n **Example 1**\n\n ```ts\n import { findRecord } from '@warp-drive/legacy/compat/builders';\n const { content: post } = await store.request<Post>(findRecord<Post>('post', '1'));\n ```\n\n **Example 2**\n\n `findRecord` can be called with a single identifier argument instead of the combination\n of `type` (modelName) and `id` as separate arguments. You may recognize this combo as\n the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification)\n\n ```ts\n import { findRecord } from '@warp-drive/legacy/compat/builders';\n const { content: post } = await store.request<Post>(findRecord<Post>({ type: 'post', id }));\n ```\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of Warp Drive.\n\n @deprecated\n @public\n @param resource - either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record\n @param id - optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved\n @param options - if the first param is a string this will be the optional options for the request. See examples for available options.\n @return request config\n*/\nexport function findRecordBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n id: string,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput<TypeFromInstance<T>, T>;\nexport function findRecordBuilder(type: string, id: string, options?: FindRecordBuilderOptions): FindRecordRequestInput;\nexport function findRecordBuilder<T extends TypedRecordInstance>(\n resource: ResourceIdentifierObject<TypeFromInstance<T>>,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput<TypeFromInstance<T>, T>;\nexport function findRecordBuilder(\n resource: ResourceIdentifierObject,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput;\nexport function findRecordBuilder(\n resource: string | ResourceIdentifierObject,\n idOrOptions?: string | FindRecordBuilderOptions,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput {\n assert(\n `You need to pass a modelName or resource identifier as the first argument to the findRecord builder`,\n resource\n );\n if (isMaybeIdentifier(resource)) {\n options = idOrOptions as BaseFinderOptions | undefined;\n } else {\n assert(\n `You need to pass a modelName or resource identifier as the first argument to the findRecord builder (passed ${resource})`,\n typeof resource === 'string'\n );\n const type = normalizeModelName(resource);\n const normalizedId = ensureStringId(idOrOptions as string | number);\n resource = constructResource(type, normalizedId);\n }\n\n options = options || {};\n\n assert('findRecord builder does not support options.preload', !(options as FindRecordOptions).preload);\n\n return {\n op: 'findRecord' as const,\n data: {\n record: resource,\n options,\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","import type { StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { LegacyResourceQuery, QueryOptions } from '@warp-drive/core/types';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\nimport { normalizeModelName } from './utils.ts';\n\ntype QueryRequestInput<T extends string = string, RT = unknown[]> = StoreRequestInput & {\n op: 'query';\n data: {\n type: T;\n query: LegacyResourceQuery;\n options: QueryBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype QueryBuilderOptions = QueryOptions;\n\n/**\n This function builds a request config for a given type and query object.\n When passed to `store.request`, this config will result in the same behavior as a `store.query` request.\n Additionally, it takes the same options as `store.query`.\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of WarpDrive.\n\n @deprecated\n @public\n @param type the name of the resource\n @param query a query to be used by the adapter\n @param options optional, may include `adapterOptions` hash which will be passed to adapter.query\n @return request config\n*/\nexport function queryBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRequestInput<TypeFromInstance<T>, T[]>;\nexport function queryBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRequestInput;\nexport function queryBuilder(\n type: string,\n query: LegacyResourceQuery,\n options: QueryBuilderOptions = {}\n): QueryRequestInput {\n assert(`You need to pass a model name to the query builder`, type);\n assert(`You need to pass a query hash to the query builder`, query);\n assert(\n `Model name passed to the query builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'query' as const,\n data: {\n type: normalizeModelName(type),\n query,\n options: options,\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n\ntype QueryRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'queryRecord';\n data: {\n type: T;\n query: LegacyResourceQuery;\n options: QueryBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\n/**\n This function builds a request config for a given type and query object.\n When passed to `store.request`, this config will result in the same behavior as a `store.queryRecord` request.\n Additionally, it takes the same options as `store.queryRecord`.\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of WarpDrive.\n\n @deprecated\n @public\n @param type the name of the resource\n @param query a query to be used by the adapter\n @param options optional, may include `adapterOptions` hash which will be passed to adapter.query\n @return request config\n*/\nexport function queryRecordBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput<TypeFromInstance<T>, T | null>;\nexport function queryRecordBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput;\nexport function queryRecordBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput {\n assert(`You need to pass a model name to the queryRecord builder`, type);\n assert(`You need to pass a query hash to the queryRecord builder`, query);\n assert(\n `Model name passed to the queryRecord builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'queryRecord',\n data: {\n type: normalizeModelName(type),\n query,\n options: options || {},\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","import { recordIdentifierFor, storeFor, type StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore, type InstanceCache } from '@warp-drive/core/store/-private';\nimport type { ResourceKey } from '@warp-drive/core/types';\nimport type { Cache } from '@warp-drive/core/types/cache';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\ntype SaveRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'createRecord' | 'deleteRecord' | 'updateRecord';\n data: {\n record: ResourceKey<T>;\n options: SaveRecordBuilderOptions;\n };\n records: [ResourceKey<T>];\n [RequestSignature]?: RT;\n};\n\ntype SaveRecordBuilderOptions = Record<string, unknown>;\n\nfunction _resourceIsFullDeleted(identifier: ResourceKey, cache: Cache): boolean {\n return cache.isDeletionCommitted(identifier) || (cache.isNew(identifier) && cache.isDeleted(identifier));\n}\n\nfunction resourceIsFullyDeleted(instanceCache: InstanceCache, identifier: ResourceKey): boolean {\n const cache = instanceCache.cache;\n return !cache || _resourceIsFullDeleted(identifier, cache);\n}\n\n/**\n This function builds a request config for saving the given record (e.g. creating, updating, or deleting the record).\n When passed to `store.request`, this config will result in the same behavior as a legacy `store.saveRecord` request.\n Additionally, it takes the same options as `store.saveRecord`.\n\n All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @deprecated\n @public\n @param {Object} record a record to save\n @param {SaveRecordBuilderOptions} options optional, may include `adapterOptions` hash which will be passed to adapter.saveRecord\n @return {SaveRecordRequestInput} request config\n*/\nexport function saveRecordBuilder<T extends TypedRecordInstance>(\n record: T,\n options: Record<string, unknown> = {}\n): SaveRecordRequestInput<TypeFromInstance<T>, T> {\n const store = storeFor(record, true);\n assertPrivateStore(store);\n assert(`Unable to initiate save for a record in a disconnected state`, store);\n const identifier = recordIdentifierFor<T>(record);\n\n if (!identifier) {\n // this commonly means we're disconnected\n // but just in case we throw here to prevent bad things.\n throw new Error(`Record Is Disconnected`);\n }\n assert(\n `Cannot initiate a save request for an unloaded record: ${identifier.lid}`,\n store._instanceCache.recordIsLoaded(identifier)\n );\n\n if (resourceIsFullyDeleted(store._instanceCache, identifier)) {\n throw new Error('cannot build saveRecord request for deleted record');\n }\n\n if (!options) {\n options = {};\n }\n let operation: 'createRecord' | 'deleteRecord' | 'updateRecord' = 'updateRecord';\n\n const cache = store.cache;\n if (cache.isNew(identifier)) {\n operation = 'createRecord';\n } else if (cache.isDeleted(identifier)) {\n operation = 'deleteRecord';\n }\n\n return {\n op: operation,\n data: {\n options,\n record: identifier,\n },\n records: [identifier],\n cacheOptions: { [SkipCache]: true },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgBE,eAAeC,MAAcC,UAAiC,CAAC,GAAwB;CAOrG,OAAO;EACLC,IAAI;EACJC,MAAM;GACJH,MAAMF,mBAAmBE,IAAI;GAC7BC,SAASA,WAAW,CAAC;EACvB;EACAG,cAAc,GAAGP,YAAY,KAAK;CACpC;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACeA,SAAgBa,kBACdC,UACAC,aACAC,SACwB;CAKxB,IAAIL,kBAAkBG,QAAQ,GAC5BE,UAAUD;MACL;EAKL,MAAME,OAAOL,mBAAmBE,QAAQ;EACxC,MAAMI,eAAeT,eAAeM,WAA8B;EAClED,WAAWN,kBAAkBS,MAAMC,YAAY;CACjD;CAEAF,UAAUA,WAAW,CAAC;CAItB,OAAO;EACLG,IAAI;EACJC,MAAM;GACJC,QAAQP;GACRE;EACF;EACAM,cAAc,GAAGZ,YAAY,KAAK;CACpC;AACF;;;;;;;;;;;;;;;;;;;;ACxDA,SAAgBe,aACdC,MACAC,OACAC,UAA+B,CAAC,GACb;CAQnB,OAAO;EACLC,IAAI;EACJC,MAAM;GACJJ,MAAMF,mBAAmBE,IAAI;GAC7BC;GACSC;EACX;EACAG,cAAc,GAAGR,YAAY,KAAK;CACpC;AACF;;;;;;;;;;;;;;;;;AAsCA,SAAgBS,mBACdN,MACAC,OACAC,SACyB;CAQzB,OAAO;EACLC,IAAI;EACJC,MAAM;GACJJ,MAAMF,mBAAmBE,IAAI;GAC7BC;GACAC,SAASA,WAAW,CAAC;EACvB;EACAG,cAAc,GAAGR,YAAY,KAAK;CACpC;AACF;;;;AC1GA,SAASc,uBAAuBC,YAAyBC,OAAuB;CAC9E,OAAOA,MAAMC,oBAAoBF,UAAU,KAAMC,MAAME,MAAMH,UAAU,KAAKC,MAAMG,UAAUJ,UAAU;AACxG;AAEA,SAASK,uBAAuBC,eAA8BN,YAAkC;CAC9F,MAAMC,QAAQK,cAAcL;CAC5B,OAAO,CAACA,SAASF,uBAAuBC,YAAYC,KAAK;AAC3D;;;;;;;;;;;;;;;;AAiBA,SAAgBM,kBACdC,QACAC,UAAmC,CAAC,GACY;CAChD,MAAMC,QAAQd,SAASY,QAAQ,IAAI;CACnCX,mBAAmBa,KAAK;CAExB,MAAMV,aAAaL,oBAAuBa,MAAM;CAEhD,IAAI,CAACR,YAGH,MAAM,IAAIW,MAAM,wBAAwB;CAO1C,IAAIN,uBAAuBK,MAAME,gBAAgBZ,UAAU,GACzD,MAAM,IAAIW,MAAM,oDAAoD;CAGtE,IAAI,CAACF,SACHA,UAAU,CAAC;CAEb,IAAII,YAA8D;CAElE,MAAMZ,QAAQS,MAAMT;CACpB,IAAIA,MAAME,MAAMH,UAAU,GACxBa,YAAY;MACP,IAAIZ,MAAMG,UAAUJ,UAAU,GACnCa,YAAY;CAGd,OAAO;EACLC,IAAID;EACJE,MAAM;GACJN;GACAD,QAAQR;EACV;EACAgB,SAAS,CAAChB,UAAU;EACpBiB,cAAc,GAAGnB,YAAY,KAAK;CACpC;AACF"}
|
|
1
|
+
{"version":3,"file":"builders.js","names":["SkipCache","normalizeModelName","findAllBuilder","type","options","op","data","cacheOptions","constructResource","ensureStringId","SkipCache","isMaybeIdentifier","normalizeModelName","findRecordBuilder","resource","idOrOptions","options","type","normalizedId","op","data","record","cacheOptions","SkipCache","normalizeModelName","queryBuilder","type","query","options","op","data","cacheOptions","queryRecordBuilder","recordIdentifierFor","storeFor","assertPrivateStore","SkipCache","_resourceIsFullDeleted","identifier","cache","isDeletionCommitted","isNew","isDeleted","resourceIsFullyDeleted","instanceCache","saveRecordBuilder","record","options","store","Error","_instanceCache","operation","op","data","records","cacheOptions"],"sources":["../../../../src/compat/builders/find-all.ts","../../../../src/compat/builders/find-record.ts","../../../../src/compat/builders/query.ts","../../../../src/compat/builders/save-record.ts"],"sourcesContent":["import type { StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { FindAllOptions } from '@warp-drive/core/types';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\nimport { normalizeModelName } from './utils.ts';\n\ntype FindAllRequestInput<T extends string = string, RT = unknown[]> = StoreRequestInput & {\n op: 'findAll';\n data: {\n type: T;\n options: FindAllBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype FindAllBuilderOptions = FindAllOptions;\n\n/**\n This function builds a request config to perform a `findAll` request for the given type.\n When passed to `store.request`, this config will result in the same behavior as a `store.findAll` request.\n Additionally, it takes the same options as `store.findAll`.\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of WarpDrive.\n\n @summary Deprecated legacy builder for a `store.request` config that behaves like `store.findAll`, easing\n migration off adapters and serializers.\n @deprecated\n @public\n @param type the name of the resource\n @param options optional, may include `adapterOptions` hash which will be passed to adapter.findAll\n @return request config\n*/\nexport function findAllBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n options?: FindAllBuilderOptions\n): FindAllRequestInput<TypeFromInstance<T>, T[]>;\nexport function findAllBuilder(type: string, options?: FindAllBuilderOptions): FindAllRequestInput;\nexport function findAllBuilder(type: string, options: FindAllBuilderOptions = {}): FindAllRequestInput {\n assert(`You need to pass a model name to the findAll builder`, type);\n assert(\n `Model name passed to the findAll builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'findAll',\n data: {\n type: normalizeModelName(type),\n options: options || {},\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","import type { StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { constructResource, ensureStringId } from '@warp-drive/core/store/-private';\nimport type { BaseFinderOptions, FindRecordOptions } from '@warp-drive/core/types';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { ResourceIdentifierObject } from '@warp-drive/core/types/spec/json-api-raw';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\nimport { isMaybeIdentifier, normalizeModelName } from './utils.ts';\n\ntype FindRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'findRecord';\n data: {\n record: ResourceIdentifierObject<T>;\n options: FindRecordBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype FindRecordBuilderOptions = Omit<FindRecordOptions, 'preload'>;\n\n/**\n This function builds a request config to find the record for a given identifier or type and id combination.\n When passed to `store.request`, this config will result in the same behavior as a `store.findRecord` request.\n Additionally, it takes the same options as `store.findRecord`, with the exception of `preload` (which is unsupported).\n\n **Example 1**\n\n ```ts\n import { findRecord } from '@warp-drive/legacy/compat/builders';\n const { content: post } = await store.request<Post>(findRecord<Post>('post', '1'));\n ```\n\n **Example 2**\n\n `findRecord` can be called with a single identifier argument instead of the combination\n of `type` (modelName) and `id` as separate arguments. You may recognize this combo as\n the typical pairing from [JSON:API](https://jsonapi.org/format/#document-resource-object-identification)\n\n ```ts\n import { findRecord } from '@warp-drive/legacy/compat/builders';\n const { content: post } = await store.request<Post>(findRecord<Post>({ type: 'post', id }));\n ```\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of Warp Drive.\n\n @summary Deprecated legacy builder for a `store.request` config that behaves like `store.findRecord`, taking a\n type and id or a resource identifier.\n @deprecated\n @public\n @param resource - either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record\n @param id - optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved\n @param options - if the first param is a string this will be the optional options for the request. See examples for available options.\n @return request config\n*/\nexport function findRecordBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n id: string,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput<TypeFromInstance<T>, T>;\nexport function findRecordBuilder(type: string, id: string, options?: FindRecordBuilderOptions): FindRecordRequestInput;\nexport function findRecordBuilder<T extends TypedRecordInstance>(\n resource: ResourceIdentifierObject<TypeFromInstance<T>>,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput<TypeFromInstance<T>, T>;\nexport function findRecordBuilder(\n resource: ResourceIdentifierObject,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput;\nexport function findRecordBuilder(\n resource: string | ResourceIdentifierObject,\n idOrOptions?: string | FindRecordBuilderOptions,\n options?: FindRecordBuilderOptions\n): FindRecordRequestInput {\n assert(\n `You need to pass a modelName or resource identifier as the first argument to the findRecord builder`,\n resource\n );\n if (isMaybeIdentifier(resource)) {\n options = idOrOptions as BaseFinderOptions | undefined;\n } else {\n assert(\n `You need to pass a modelName or resource identifier as the first argument to the findRecord builder (passed ${resource})`,\n typeof resource === 'string'\n );\n const type = normalizeModelName(resource);\n const normalizedId = ensureStringId(idOrOptions as string | number);\n resource = constructResource(type, normalizedId);\n }\n\n options = options || {};\n\n assert('findRecord builder does not support options.preload', !(options as FindRecordOptions).preload);\n\n return {\n op: 'findRecord' as const,\n data: {\n record: resource,\n options,\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","import type { StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { LegacyResourceQuery, QueryOptions } from '@warp-drive/core/types';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\nimport { normalizeModelName } from './utils.ts';\n\ntype QueryRequestInput<T extends string = string, RT = unknown[]> = StoreRequestInput & {\n op: 'query';\n data: {\n type: T;\n query: LegacyResourceQuery;\n options: QueryBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\ntype QueryBuilderOptions = QueryOptions;\n\n/**\n This function builds a request config for a given type and query object.\n When passed to `store.request`, this config will result in the same behavior as a `store.query` request.\n Additionally, it takes the same options as `store.query`.\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of WarpDrive.\n\n @summary Deprecated legacy builder for a `store.request` config that behaves like `store.query`, returning the\n records matching a query object.\n @deprecated\n @public\n @param type the name of the resource\n @param query a query to be used by the adapter\n @param options optional, may include `adapterOptions` hash which will be passed to adapter.query\n @return request config\n*/\nexport function queryBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRequestInput<TypeFromInstance<T>, T[]>;\nexport function queryBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRequestInput;\nexport function queryBuilder(\n type: string,\n query: LegacyResourceQuery,\n options: QueryBuilderOptions = {}\n): QueryRequestInput {\n assert(`You need to pass a model name to the query builder`, type);\n assert(`You need to pass a query hash to the query builder`, query);\n assert(\n `Model name passed to the query builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'query' as const,\n data: {\n type: normalizeModelName(type),\n query,\n options: options,\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n\ntype QueryRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'queryRecord';\n data: {\n type: T;\n query: LegacyResourceQuery;\n options: QueryBuilderOptions;\n };\n [RequestSignature]?: RT;\n};\n\n/**\n This function builds a request config for a given type and query object.\n When passed to `store.request`, this config will result in the same behavior as a `store.queryRecord` request.\n Additionally, it takes the same options as `store.queryRecord`.\n\n All `@warp-drive/legacy/compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of WarpDrive.\n\n @summary Deprecated legacy builder for a `store.request` config that behaves like `store.queryRecord`, returning\n a single record or `null` for a query object.\n @deprecated\n @public\n @param type the name of the resource\n @param query a query to be used by the adapter\n @param options optional, may include `adapterOptions` hash which will be passed to adapter.query\n @return request config\n*/\nexport function queryRecordBuilder<T extends TypedRecordInstance>(\n type: TypeFromInstance<T>,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput<TypeFromInstance<T>, T | null>;\nexport function queryRecordBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput;\nexport function queryRecordBuilder(\n type: string,\n query: LegacyResourceQuery,\n options?: QueryBuilderOptions\n): QueryRecordRequestInput {\n assert(`You need to pass a model name to the queryRecord builder`, type);\n assert(`You need to pass a query hash to the queryRecord builder`, query);\n assert(\n `Model name passed to the queryRecord builder must be a dasherized string instead of ${type}`,\n typeof type === 'string'\n );\n\n return {\n op: 'queryRecord',\n data: {\n type: normalizeModelName(type),\n query,\n options: options || {},\n },\n cacheOptions: { [SkipCache]: true },\n };\n}\n","import { recordIdentifierFor, storeFor, type StoreRequestInput } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore, type InstanceCache } from '@warp-drive/core/store/-private';\nimport type { ResourceKey } from '@warp-drive/core/types';\nimport type { Cache } from '@warp-drive/core/types/cache';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport { SkipCache } from '@warp-drive/core/types/request';\nimport type { RequestSignature } from '@warp-drive/core/types/symbols';\n\ntype SaveRecordRequestInput<T extends string = string, RT = unknown> = StoreRequestInput & {\n op: 'createRecord' | 'deleteRecord' | 'updateRecord';\n data: {\n record: ResourceKey<T>;\n options: SaveRecordBuilderOptions;\n };\n records: [ResourceKey<T>];\n [RequestSignature]?: RT;\n};\n\ntype SaveRecordBuilderOptions = Record<string, unknown>;\n\nfunction _resourceIsFullDeleted(identifier: ResourceKey, cache: Cache): boolean {\n return cache.isDeletionCommitted(identifier) || (cache.isNew(identifier) && cache.isDeleted(identifier));\n}\n\nfunction resourceIsFullyDeleted(instanceCache: InstanceCache, identifier: ResourceKey): boolean {\n const cache = instanceCache.cache;\n return !cache || _resourceIsFullDeleted(identifier, cache);\n}\n\n/**\n This function builds a request config for saving the given record (e.g. creating, updating, or deleting the record).\n When passed to `store.request`, this config will result in the same behavior as a legacy `store.saveRecord` request.\n Additionally, it takes the same options as `store.saveRecord`.\n\n All `@ember-data/legacy-compat` builders exist to enable you to migrate your codebase to using the correct syntax for `store.request` while temporarily preserving legacy behaviors.\n This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers.\n To that end, these builders are deprecated and will be removed in a future version of Ember Data.\n\n @summary Deprecated legacy builder for a `store.request` config that creates, updates, or deletes a record\n through adapters, like the legacy `store.saveRecord`.\n @deprecated\n @public\n @param {Object} record a record to save\n @param {SaveRecordBuilderOptions} options optional, may include `adapterOptions` hash which will be passed to adapter.saveRecord\n @return {SaveRecordRequestInput} request config\n*/\nexport function saveRecordBuilder<T extends TypedRecordInstance>(\n record: T,\n options: Record<string, unknown> = {}\n): SaveRecordRequestInput<TypeFromInstance<T>, T> {\n const store = storeFor(record, true);\n assertPrivateStore(store);\n assert(`Unable to initiate save for a record in a disconnected state`, store);\n const identifier = recordIdentifierFor<T>(record);\n\n if (!identifier) {\n // this commonly means we're disconnected\n // but just in case we throw here to prevent bad things.\n throw new Error(`Record Is Disconnected`);\n }\n assert(\n `Cannot initiate a save request for an unloaded record: ${identifier.lid}`,\n store._instanceCache.recordIsLoaded(identifier)\n );\n\n if (resourceIsFullyDeleted(store._instanceCache, identifier)) {\n throw new Error('cannot build saveRecord request for deleted record');\n }\n\n if (!options) {\n options = {};\n }\n let operation: 'createRecord' | 'deleteRecord' | 'updateRecord' = 'updateRecord';\n\n const cache = store.cache;\n if (cache.isNew(identifier)) {\n operation = 'createRecord';\n } else if (cache.isDeleted(identifier)) {\n operation = 'deleteRecord';\n }\n\n return {\n op: operation,\n data: {\n options,\n record: identifier,\n },\n records: [identifier],\n cacheOptions: { [SkipCache]: true },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgBE,eAAeC,MAAcC,UAAiC,CAAC,GAAwB;CAOrG,OAAO;EACLC,IAAI;EACJC,MAAM;GACJH,MAAMF,mBAAmBE,IAAI;GAC7BC,SAASA,WAAW,CAAC;EACvB;EACAG,cAAc,GAAGP,YAAY,KAAK;CACpC;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACeA,SAAgBa,kBACdC,UACAC,aACAC,SACwB;CAKxB,IAAIL,kBAAkBG,QAAQ,GAC5BE,UAAUD;MACL;EAKL,MAAME,OAAOL,mBAAmBE,QAAQ;EACxC,MAAMI,eAAeT,eAAeM,WAA8B;EAClED,WAAWN,kBAAkBS,MAAMC,YAAY;CACjD;CAEAF,UAAUA,WAAW,CAAC;CAItB,OAAO;EACLG,IAAI;EACJC,MAAM;GACJC,QAAQP;GACRE;EACF;EACAM,cAAc,GAAGZ,YAAY,KAAK;CACpC;AACF;;;;;;;;;;;;;;;;;;;;;ACxDA,SAAg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Y,KAAK;CACpC;AACF"}
|
|
@@ -2,7 +2,12 @@ import { get, getProperties, notifyPropertyChange, set, setProperties } from "@e
|
|
|
2
2
|
import { addObserver, removeObserver } from "@ember/object/observers";
|
|
3
3
|
import { compare } from "@ember/utils";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/compat/extensions.ts
|
|
6
|
+
/**
|
|
7
|
+
* @module
|
|
8
|
+
* @summary Legacy schema extensions that give reactive objects and arrays the classic `EmberObject` and Ember array
|
|
9
|
+
* APIs, such as `get`, `set` and `mapBy`, plus matching types.
|
|
10
|
+
*/
|
|
6
11
|
const EmberObjectFeatures = {};
|
|
7
12
|
[
|
|
8
13
|
"addObserver",
|
|
@@ -49,6 +54,9 @@ const EmberObjectFeatures = {};
|
|
|
49
54
|
* `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,
|
|
50
55
|
* `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)
|
|
51
56
|
* to reactive array resources.
|
|
57
|
+
*
|
|
58
|
+
* @summary Legacy schema extension that gives reactive arrays the classic `EmberObject` API such as `get`, `set`,
|
|
59
|
+
* and observers, to ease migration from Ember objects.
|
|
52
60
|
*/
|
|
53
61
|
const EmberObjectArrayExtension = {
|
|
54
62
|
kind: "array",
|
|
@@ -60,6 +68,9 @@ const EmberObjectArrayExtension = {
|
|
|
60
68
|
* `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,
|
|
61
69
|
* `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)
|
|
62
70
|
* to reactive object resources.
|
|
71
|
+
*
|
|
72
|
+
* @summary Legacy schema extension that gives reactive objects the classic `EmberObject` API such as `get`, `set`,
|
|
73
|
+
* and observers, to ease migration from Ember objects.
|
|
63
74
|
*/
|
|
64
75
|
const EmberObjectExtension = {
|
|
65
76
|
kind: "object",
|
|
@@ -246,6 +257,9 @@ const EmberArrayLikeFeatures = {
|
|
|
246
257
|
* A schema extension that adds Ember's classic `MutableArray`/`Enumerable`
|
|
247
258
|
* style methods (`pushObject`, `removeObject`, `mapBy`, `filterBy`,
|
|
248
259
|
* `sortBy`, `firstObject`, `lastObject`, etc.) to reactive array resources.
|
|
260
|
+
*
|
|
261
|
+
* @summary Legacy schema extension that gives reactive arrays Ember array methods such as `pushObject`, `mapBy`,
|
|
262
|
+
* `filterBy`, and `firstObject`.
|
|
249
263
|
*/
|
|
250
264
|
const EmberArrayLikeExtension = {
|
|
251
265
|
kind: "array",
|
|
@@ -254,15 +268,22 @@ const EmberArrayLikeExtension = {
|
|
|
254
268
|
};
|
|
255
269
|
/**
|
|
256
270
|
* Extracts the element type of an array type, or `never` if `T` is not an array.
|
|
271
|
+
*
|
|
272
|
+
* @summary Type utility resolving to the element type of an array type, or `never` for non-arrays.
|
|
257
273
|
*/
|
|
258
274
|
/**
|
|
259
275
|
* Adds the classic `EmberObject` API (as registered by {@link EmberObjectExtension}/
|
|
260
276
|
* {@link EmberObjectArrayExtension}) to the type of a reactive resource.
|
|
277
|
+
*
|
|
278
|
+
* @summary Legacy type that adds the classic `EmberObject` methods to a reactive resource type using
|
|
279
|
+
* `EmberObjectExtension` or `EmberObjectArrayExtension`.
|
|
261
280
|
*/
|
|
262
281
|
/**
|
|
263
282
|
* Adds Ember's classic array-like API (as registered by {@link EmberArrayLikeExtension})
|
|
264
283
|
* to the type of a reactive array resource.
|
|
284
|
+
*
|
|
285
|
+
* @summary Legacy type that adds Ember array methods such as `mapBy` and `firstObject` to a reactive array type
|
|
286
|
+
* using `EmberArrayLikeExtension`.
|
|
265
287
|
*/
|
|
266
|
-
//#endregion
|
|
267
288
|
export { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension };
|
|
268
289
|
//# sourceMappingURL=extensions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.js","names":["get","getProperties","notifyPropertyChange","set","setProperties","addObserver","removeObserver","compare","EmberObjectFeatures","EmberObjectMethods","forEach","method","delegatedMethod","args","Error","keyName","decrement","increment","parseFloat","key","EmberObjectArrayExtension","kind","name","features","EmberObjectExtension","EmberArrayLikeFeatures","addObject","obj","index","indexOf","push","addObjects","objs","popObject","pop","pushObject","pushObjects","shiftObject","shift","unshiftObject","unshift","unshiftObjects","objectAt","arrIndex","Math","sign","length","objectsAt","indices","map","removeAt","splice","insertAt","removeObject","removeObjects","toArray","slice","replace","idx","amt","objects","clear","setObjects","reverseObjects","reverse","compact","filter","v","undefined","any","callback","target","some","isAny","prop","value","hasValue","arguments","isEvery","every","getEach","mapBy","findBy","find","val","Boolean","filterBy","record","sortBy","sortKeys","sort","a","b","i","propA","propB","compareValue","invoke","addArrayObserver","removeArrayObserver","arrayContentWillChange","arrayContentDidChange","reject","apply","rejectBy","setEach","item","uniq","Array","from","Set","uniqBy","seen","result","has","add","without","newArr","firstObject","at","lastObject","EmberArrayLikeExtension"],"sources":["../../../../src/compat/extensions.ts"],"sourcesContent":["import {\n type default as EmberObject,\n get,\n getProperties,\n notifyPropertyChange,\n set,\n setProperties,\n} from '@ember/object';\nimport { addObserver, removeObserver } from '@ember/object/observers';\nimport { compare } from '@ember/utils';\n\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { CAUTION_MEGA_DANGER_ZONE_Extension } from '@warp-drive/core/reactive';\n\nconst EmberObjectFeatures = {};\nconst EmberObjectMethods = [\n 'addObserver',\n 'cacheFor',\n 'decrementProperty',\n 'get',\n 'getProperties',\n 'incrementProperty',\n 'notifyPropertyChange',\n 'removeObserver',\n 'set',\n 'setProperties',\n 'toggleProperty',\n] as const;\nEmberObjectMethods.forEach((method) => {\n EmberObjectFeatures[method] = function delegatedMethod(...args: unknown[]): unknown {\n switch (method) {\n case 'addObserver':\n return (addObserver as (...args: unknown[]) => unknown)(this, ...args);\n case 'cacheFor':\n throw new Error('cacheFor has been removed and will not be replaced');\n case 'decrementProperty': {\n const keyName = args[0] as string;\n const decrement = (args[1] as number) ?? 1;\n assert(\n 'Must pass a numeric value to decrementProperty',\n (typeof decrement === 'number' || !isNaN(parseFloat(decrement))) && isFinite(decrement)\n );\n return set(this, keyName, ((get(this, keyName) as number) || 0) - decrement);\n }\n case 'get':\n // the cast is required: without it, TS resolves `get` to an overload whose\n // parameter list isn't a rest/tuple, and the spread below fails to typecheck\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion\n return (get as (...args: unknown[]) => unknown)(this, ...args);\n case 'getProperties':\n return (getProperties as (...args: unknown[]) => unknown)(this, ...args);\n case 'incrementProperty': {\n const keyName = args[0] as string;\n const increment = (args[1] as number) ?? 1;\n assert(\n 'Must pass a numeric value to incrementProperty',\n !isNaN(parseFloat(String(increment))) && isFinite(increment)\n );\n return set(this, keyName, (parseFloat(get(this, keyName) as string) || 0) + increment);\n }\n case 'notifyPropertyChange':\n return (notifyPropertyChange as (...args: unknown[]) => unknown)(this, ...args);\n case 'removeObserver':\n return (removeObserver as (...args: unknown[]) => unknown)(this, ...args);\n case 'set':\n return (set as (...args: unknown[]) => unknown)(this, ...args);\n case 'setProperties':\n return (setProperties as (...args: unknown[]) => unknown)(this, ...args);\n case 'toggleProperty': {\n const key = args[0] as string;\n return set(this, key, !get(this, key));\n }\n }\n };\n});\n/**\n * A schema extension that adds the classic `EmberObject` API (`get`, `set`,\n * `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,\n * `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)\n * to reactive array resources.\n */\nexport const EmberObjectArrayExtension: CAUTION_MEGA_DANGER_ZONE_Extension = {\n kind: 'array',\n name: 'ember-object' as const,\n features: EmberObjectFeatures,\n};\n/**\n * A schema extension that adds the classic `EmberObject` API (`get`, `set`,\n * `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,\n * `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)\n * to reactive object resources.\n */\nexport const EmberObjectExtension: CAUTION_MEGA_DANGER_ZONE_Extension = {\n kind: 'object',\n name: 'ember-object' as const,\n features: EmberObjectFeatures,\n};\n\nconst EmberArrayLikeFeatures = {\n addObject<T>(this: T[], obj: T): T[] {\n const index = this.indexOf(obj);\n if (index === -1) {\n this.push(obj);\n }\n return this;\n },\n\n addObjects<T>(this: T[], objs: T[]): T[] {\n objs.forEach((obj: T) => {\n const index = this.indexOf(obj);\n if (index === -1) {\n this.push(obj);\n }\n });\n return this;\n },\n\n popObject<T>(this: T[]): T | undefined {\n return this.pop();\n },\n\n pushObject<T>(this: T[], obj: T): T {\n this.push(obj);\n return obj;\n },\n\n pushObjects<T>(this: T[], objs: T[]): T[] {\n this.push(...objs);\n return this;\n },\n\n shiftObject<T>(this: T[]): NonNullable<T> {\n return this.shift()!;\n },\n\n unshiftObject<T>(this: T[], obj: T): T {\n this.unshift(obj);\n return obj;\n },\n\n unshiftObjects<T>(this: T[], objs: T[]): T[] {\n this.unshift(...objs);\n return this;\n },\n\n objectAt<T>(this: T[], index: number): T {\n //For negative index values go back from the end of the array\n const arrIndex = Math.sign(index) === -1 ? this.length + index : index;\n\n return this[arrIndex];\n },\n\n objectsAt<T>(this: T[], indices: number[]): T[] {\n // @ts-expect-error adding MutableArray method\n // oxlint-disable-next-line typescript/no-unsafe-return, typescript/no-unsafe-call\n return indices.map((index) => this.objectAt(index)!);\n },\n\n removeAt<T>(this: T[], index: number): T[] {\n this.splice(index, 1);\n return this;\n },\n\n insertAt<T>(this: T[], index: number, obj: T): T[] {\n this.splice(index, 0, obj);\n return this;\n },\n\n removeObject<T>(this: T[], obj: T): T[] {\n const index = this.indexOf(obj);\n if (index !== -1) {\n this.splice(index, 1);\n }\n return this;\n },\n\n removeObjects<T>(this: T[], objs: T[]): T[] {\n objs.forEach((obj) => {\n const index = this.indexOf(obj);\n if (index !== -1) {\n this.splice(index, 1);\n }\n });\n return this;\n },\n\n toArray<T>(this: T[]): T[] {\n return this.slice();\n },\n\n replace<T>(this: T[], idx: number, amt: number, objects?: T[]): void {\n if (objects) {\n this.splice(idx, amt, ...objects);\n } else {\n this.splice(idx, amt);\n }\n },\n\n clear<T>(this: T[]): T[] {\n this.splice(0, this.length);\n return this;\n },\n\n setObjects<T>(this: T[], objects: T[]): T[] {\n assert(`setObjects expects to receive an array as its argument`, Array.isArray(objects));\n this.splice(0, this.length);\n this.push(...objects);\n return this;\n },\n\n reverseObjects<T>(this: T[]): T[] {\n this.reverse();\n return this;\n },\n\n compact<T>(this: T[]): (T & {})[] {\n return this.filter((v) => v !== null && v !== undefined);\n },\n\n any<T>(this: T[], callback: Parameters<Array<T>['some']>[0], target?: unknown): boolean {\n return this.some(callback, target);\n },\n\n isAny<T>(this: T[], prop: string, value: unknown): boolean {\n const hasValue = arguments.length === 2;\n return (this as unknown as Array<Record<string, unknown>>).some((v) =>\n hasValue ? v[prop] === value : v[prop] === true\n );\n },\n\n isEvery<T>(this: T[], prop: string, value: unknown): boolean {\n const hasValue = arguments.length === 2;\n return (this as unknown as Array<Record<string, unknown>>).every((v) =>\n hasValue ? v[prop] === value : v[prop] === true\n );\n },\n\n getEach<T>(this: T[], key: string): unknown[] {\n return this.map((value) => get(value, key));\n },\n\n mapBy<T>(this: T[], key: string): unknown[] {\n return this.map((value) => get(value, key));\n },\n\n findBy<T>(this: T[], key: string, value?: unknown): T | undefined {\n if (arguments.length === 2) {\n return this.find((val) => {\n return get(val, key) === value;\n });\n } else {\n return this.find((val) => Boolean(get(val, key)));\n }\n },\n\n filterBy<T>(this: T[], key: string, value?: unknown): T[] {\n if (arguments.length === 2) {\n return this.filter((record) => {\n return get(record, key) === value;\n });\n }\n\n return this.filter((record) => {\n return Boolean(get(record, key));\n });\n },\n\n sortBy<T>(this: T[], ...sortKeys: string[]): T[] {\n return this.slice().sort((a, b) => {\n for (let i = 0; i < sortKeys.length; i++) {\n const key = sortKeys[i];\n\n const propA = get(a, key);\n\n const propB = get(b, key);\n // return 1 or -1 else continue to the next sortKey\n const compareValue = compare(propA, propB);\n\n if (compareValue) {\n return compareValue;\n }\n }\n return 0;\n });\n },\n\n invoke<T>(this: T[], key: string, ...args: unknown[]): unknown[] {\n return (this as unknown as Array<Record<string, unknown>>).map((value) =>\n (value[key] as (...args: unknown[]) => unknown)(...args)\n );\n },\n\n addArrayObserver<T>(this: T[]): void {},\n\n removeArrayObserver<T>(this: T[]): void {},\n\n arrayContentWillChange<T>(this: T[]): void {},\n\n arrayContentDidChange<T>(this: T[]): void {},\n\n reject<T>(this: T[], callback: Parameters<Array<T>['filter']>[0], target?: unknown): T[] {\n assert('`reject` expects a function as first argument.', typeof callback === 'function');\n\n return this.filter((...args) => {\n return !callback.apply(target, args);\n });\n },\n\n rejectBy<T>(this: T[], key: string, value?: unknown): T[] {\n if (arguments.length === 2) {\n return this.filter((record) => {\n return get(record, key) !== value;\n });\n }\n\n return this.filter((record) => {\n return !get(record, key);\n });\n },\n\n setEach<T>(this: T[], key: string, value: unknown): void {\n (this as unknown as Array<Record<string, unknown>>).forEach((item) => set(item, key, value));\n },\n\n uniq<T>(this: T[]): T[] {\n return Array.from(new Set(this));\n },\n\n uniqBy<T>(this: T[], key: string): T[] {\n const seen = new Set();\n const result: T[] = [];\n this.forEach((item) => {\n const value = get(item, key);\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n result.push(item);\n });\n return result;\n },\n\n without<T>(this: T[], value: T): T[] {\n const newArr = this.slice();\n const index = this.indexOf(value);\n if (index !== -1) {\n newArr.splice(index, 1);\n }\n\n return newArr;\n },\n\n get firstObject(): unknown {\n return (this as unknown as unknown[]).at(0);\n },\n\n get lastObject(): unknown {\n return (this as unknown as unknown[]).at(-1);\n },\n};\n\n/**\n * A schema extension that adds Ember's classic `MutableArray`/`Enumerable`\n * style methods (`pushObject`, `removeObject`, `mapBy`, `filterBy`,\n * `sortBy`, `firstObject`, `lastObject`, etc.) to reactive array resources.\n */\nexport const EmberArrayLikeExtension: CAUTION_MEGA_DANGER_ZONE_Extension = {\n kind: 'array',\n name: 'ember-array-like' as const,\n features: EmberArrayLikeFeatures,\n};\n\n/**\n * Extracts the element type of an array type, or `never` if `T` is not an array.\n */\nexport type ArrayType<T> = T extends ReadonlyArray<infer U> ? U : never;\n/**\n * Adds the classic `EmberObject` API (as registered by {@link EmberObjectExtension}/\n * {@link EmberObjectArrayExtension}) to the type of a reactive resource.\n */\nexport type WithEmberObject<T> = T & Pick<T & EmberObject, ArrayType<typeof EmberObjectMethods>>;\n\n/**\n * Adds Ember's classic array-like API (as registered by {@link EmberArrayLikeExtension})\n * to the type of a reactive array resource.\n */\nexport type WithArrayLike<T> =\n T extends Array<infer U>\n ? U &\n Omit<typeof EmberArrayLikeFeatures, 'firstObject' | 'lastObject'> & {\n /**\n * the first member of the array, or `undefined` if the array is empty\n */\n firstObject: T | undefined;\n /**\n * the last member of the array, or `undefined` if the array is empty\n */\n lastObject: T | undefined;\n }\n : T[] &\n Omit<typeof EmberArrayLikeFeatures, 'firstObject' | 'lastObject'> & {\n /**\n * the first member of the array, or `undefined` if the array is empty\n */\n firstObject: T | undefined;\n /**\n * the last member of the array, or `undefined` if the array is empty\n */\n lastObject: T | undefined;\n };\n"],"mappings":";;;;;AAcA,MAAMQ,sBAAsB,CAAC;AAc7BC;CAZE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEFA,CAAkB,CAACC,SAASC,WAAW;CACrCH,oBAAoBG,UAAU,SAASC,gBAAgB,GAAGC,MAA0B;EAClF,QAAQF,QAAR;GACE,KAAK,eACH,OAAQN,YAAgD,MAAM,GAAGQ,IAAI;GACvE,KAAK,YACH,MAAM,IAAIC,MAAM,oDAAoD;GACtE,KAAK,qBAAqB;IACxB,MAAMC,UAAUF,KAAK;IACrB,MAAMG,YAAaH,KAAK,MAAiB;IAKzC,OAAOV,IAAI,MAAMY,UAAWf,IAAI,MAAMe,OAAO,KAAgB,KAAKC,SAAS;GAC7E;GACA,KAAK,OAIH,OAAQhB,IAAwC,MAAM,GAAGa,IAAI;GAC/D,KAAK,iBACH,OAAQZ,cAAkD,MAAM,GAAGY,IAAI;GACzE,KAAK,qBAAqB;IACxB,MAAME,UAAUF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AIvC,KAAK,GAChB;GAEFqC,KAAKG,IAAIxC,KAAK;GACdsC,OAAOnF,KAAK4E,IAAI;EAClB,CAAC;EACD,OAAOO;CACT;CAEAG,QAAsBzC,OAAe;EACnC,MAAM0C,SAAS,KAAK7D,MAAM;EAC1B,MAAM5B,QAAQ,KAAKC,QAAQ8C,KAAK;EAChC,IAAI/C,UAAU,IACZyF,OAAOlE,OAAOvB,OAAO,CAAC;EAGxB,OAAOyF;CACT;CAEA,IAAIC,cAAuB;EACzB,OAAQ,KAA8BC,GAAG,CAAC;CAC5C;CAEA,IAAIC,aAAsB;EACxB,OAAQ,KAA8BD,GAAG,EAAE;CAC7C;AACF;;;;;;AAOA,MAAaE,0BAA8D;CACzEpG,MAAM;CACNC,MAAM;CACNC,UAAUE;AACZ"}
|
|
1
|
+
{"version":3,"file":"extensions.js","names":["get","getProperties","notifyPropertyChange","set","setProperties","addObserver","removeObserver","compare","EmberObjectFeatures","EmberObjectMethods","forEach","method","delegatedMethod","args","Error","keyName","decrement","increment","parseFloat","key","EmberObjectArrayExtension","kind","name","features","EmberObjectExtension","EmberArrayLikeFeatures","addObject","obj","index","indexOf","push","addObjects","objs","popObject","pop","pushObject","pushObjects","shiftObject","shift","unshiftObject","unshift","unshiftObjects","objectAt","arrIndex","Math","sign","length","objectsAt","indices","map","removeAt","splice","insertAt","removeObject","removeObjects","toArray","slice","replace","idx","amt","objects","clear","setObjects","reverseObjects","reverse","compact","filter","v","undefined","any","callback","target","some","isAny","prop","value","hasValue","arguments","isEvery","every","getEach","mapBy","findBy","find","val","Boolean","filterBy","record","sortBy","sortKeys","sort","a","b","i","propA","propB","compareValue","invoke","addArrayObserver","removeArrayObserver","arrayContentWillChange","arrayContentDidChange","reject","apply","rejectBy","setEach","item","uniq","Array","from","Set","uniqBy","seen","result","has","add","without","newArr","firstObject","at","lastObject","EmberArrayLikeExtension"],"sources":["../../../../src/compat/extensions.ts"],"sourcesContent":["/**\n * @module\n * @summary Legacy schema extensions that give reactive objects and arrays the classic `EmberObject` and Ember array\n * APIs, such as `get`, `set` and `mapBy`, plus matching types.\n */\n\nimport {\n type default as EmberObject,\n get,\n getProperties,\n notifyPropertyChange,\n set,\n setProperties,\n} from '@ember/object';\nimport { addObserver, removeObserver } from '@ember/object/observers';\nimport { compare } from '@ember/utils';\n\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { CAUTION_MEGA_DANGER_ZONE_Extension } from '@warp-drive/core/reactive';\n\nconst EmberObjectFeatures = {};\nconst EmberObjectMethods = [\n 'addObserver',\n 'cacheFor',\n 'decrementProperty',\n 'get',\n 'getProperties',\n 'incrementProperty',\n 'notifyPropertyChange',\n 'removeObserver',\n 'set',\n 'setProperties',\n 'toggleProperty',\n] as const;\nEmberObjectMethods.forEach((method) => {\n EmberObjectFeatures[method] = function delegatedMethod(...args: unknown[]): unknown {\n switch (method) {\n case 'addObserver':\n return (addObserver as (...args: unknown[]) => unknown)(this, ...args);\n case 'cacheFor':\n throw new Error('cacheFor has been removed and will not be replaced');\n case 'decrementProperty': {\n const keyName = args[0] as string;\n const decrement = (args[1] as number) ?? 1;\n assert(\n 'Must pass a numeric value to decrementProperty',\n (typeof decrement === 'number' || !isNaN(parseFloat(decrement))) && isFinite(decrement)\n );\n return set(this, keyName, ((get(this, keyName) as number) || 0) - decrement);\n }\n case 'get':\n // the cast is required: without it, TS resolves `get` to an overload whose\n // parameter list isn't a rest/tuple, and the spread below fails to typecheck\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion\n return (get as (...args: unknown[]) => unknown)(this, ...args);\n case 'getProperties':\n return (getProperties as (...args: unknown[]) => unknown)(this, ...args);\n case 'incrementProperty': {\n const keyName = args[0] as string;\n const increment = (args[1] as number) ?? 1;\n assert(\n 'Must pass a numeric value to incrementProperty',\n !isNaN(parseFloat(String(increment))) && isFinite(increment)\n );\n return set(this, keyName, (parseFloat(get(this, keyName) as string) || 0) + increment);\n }\n case 'notifyPropertyChange':\n return (notifyPropertyChange as (...args: unknown[]) => unknown)(this, ...args);\n case 'removeObserver':\n return (removeObserver as (...args: unknown[]) => unknown)(this, ...args);\n case 'set':\n return (set as (...args: unknown[]) => unknown)(this, ...args);\n case 'setProperties':\n return (setProperties as (...args: unknown[]) => unknown)(this, ...args);\n case 'toggleProperty': {\n const key = args[0] as string;\n return set(this, key, !get(this, key));\n }\n }\n };\n});\n/**\n * A schema extension that adds the classic `EmberObject` API (`get`, `set`,\n * `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,\n * `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)\n * to reactive array resources.\n *\n * @summary Legacy schema extension that gives reactive arrays the classic `EmberObject` API such as `get`, `set`,\n * and observers, to ease migration from Ember objects.\n */\nexport const EmberObjectArrayExtension: CAUTION_MEGA_DANGER_ZONE_Extension = {\n kind: 'array',\n name: 'ember-object' as const,\n features: EmberObjectFeatures,\n};\n/**\n * A schema extension that adds the classic `EmberObject` API (`get`, `set`,\n * `getProperties`, `setProperties`, `incrementProperty`, `decrementProperty`,\n * `toggleProperty`, `notifyPropertyChange`, `addObserver`, `removeObserver`)\n * to reactive object resources.\n *\n * @summary Legacy schema extension that gives reactive objects the classic `EmberObject` API such as `get`, `set`,\n * and observers, to ease migration from Ember objects.\n */\nexport const EmberObjectExtension: CAUTION_MEGA_DANGER_ZONE_Extension = {\n kind: 'object',\n name: 'ember-object' as const,\n features: EmberObjectFeatures,\n};\n\nconst EmberArrayLikeFeatures = {\n addObject<T>(this: T[], obj: T): T[] {\n const index = this.indexOf(obj);\n if (index === -1) {\n this.push(obj);\n }\n return this;\n },\n\n addObjects<T>(this: T[], objs: T[]): T[] {\n objs.forEach((obj: T) => {\n const index = this.indexOf(obj);\n if (index === -1) {\n this.push(obj);\n }\n });\n return this;\n },\n\n popObject<T>(this: T[]): T | undefined {\n return this.pop();\n },\n\n pushObject<T>(this: T[], obj: T): T {\n this.push(obj);\n return obj;\n },\n\n pushObjects<T>(this: T[], objs: T[]): T[] {\n this.push(...objs);\n return this;\n },\n\n shiftObject<T>(this: T[]): NonNullable<T> {\n return this.shift()!;\n },\n\n unshiftObject<T>(this: T[], obj: T): T {\n this.unshift(obj);\n return obj;\n },\n\n unshiftObjects<T>(this: T[], objs: T[]): T[] {\n this.unshift(...objs);\n return this;\n },\n\n objectAt<T>(this: T[], index: number): T {\n //For negative index values go back from the end of the array\n const arrIndex = Math.sign(index) === -1 ? this.length + index : index;\n\n return this[arrIndex];\n },\n\n objectsAt<T>(this: T[], indices: number[]): T[] {\n // @ts-expect-error adding MutableArray method\n // oxlint-disable-next-line typescript/no-unsafe-return, typescript/no-unsafe-call\n return indices.map((index) => this.objectAt(index)!);\n },\n\n removeAt<T>(this: T[], index: number): T[] {\n this.splice(index, 1);\n return this;\n },\n\n insertAt<T>(this: T[], index: number, obj: T): T[] {\n this.splice(index, 0, obj);\n return this;\n },\n\n removeObject<T>(this: T[], obj: T): T[] {\n const index = this.indexOf(obj);\n if (index !== -1) {\n this.splice(index, 1);\n }\n return this;\n },\n\n removeObjects<T>(this: T[], objs: T[]): T[] {\n objs.forEach((obj) => {\n const index = this.indexOf(obj);\n if (index !== -1) {\n this.splice(index, 1);\n }\n });\n return this;\n },\n\n toArray<T>(this: T[]): T[] {\n return this.slice();\n },\n\n replace<T>(this: T[], idx: number, amt: number, objects?: T[]): void {\n if (objects) {\n this.splice(idx, amt, ...objects);\n } else {\n this.splice(idx, amt);\n }\n },\n\n clear<T>(this: T[]): T[] {\n this.splice(0, this.length);\n return this;\n },\n\n setObjects<T>(this: T[], objects: T[]): T[] {\n assert(`setObjects expects to receive an array as its argument`, Array.isArray(objects));\n this.splice(0, this.length);\n this.push(...objects);\n return this;\n },\n\n reverseObjects<T>(this: T[]): T[] {\n this.reverse();\n return this;\n },\n\n compact<T>(this: T[]): (T & {})[] {\n return this.filter((v) => v !== null && v !== undefined);\n },\n\n any<T>(this: T[], callback: Parameters<Array<T>['some']>[0], target?: unknown): boolean {\n return this.some(callback, target);\n },\n\n isAny<T>(this: T[], prop: string, value: unknown): boolean {\n const hasValue = arguments.length === 2;\n return (this as unknown as Array<Record<string, unknown>>).some((v) =>\n hasValue ? v[prop] === value : v[prop] === true\n );\n },\n\n isEvery<T>(this: T[], prop: string, value: unknown): boolean {\n const hasValue = arguments.length === 2;\n return (this as unknown as Array<Record<string, unknown>>).every((v) =>\n hasValue ? v[prop] === value : v[prop] === true\n );\n },\n\n getEach<T>(this: T[], key: string): unknown[] {\n return this.map((value) => get(value, key));\n },\n\n mapBy<T>(this: T[], key: string): unknown[] {\n return this.map((value) => get(value, key));\n },\n\n findBy<T>(this: T[], key: string, value?: unknown): T | undefined {\n if (arguments.length === 2) {\n return this.find((val) => {\n return get(val, key) === value;\n });\n } else {\n return this.find((val) => Boolean(get(val, key)));\n }\n },\n\n filterBy<T>(this: T[], key: string, value?: unknown): T[] {\n if (arguments.length === 2) {\n return this.filter((record) => {\n return get(record, key) === value;\n });\n }\n\n return this.filter((record) => {\n return Boolean(get(record, key));\n });\n },\n\n sortBy<T>(this: T[], ...sortKeys: string[]): T[] {\n return this.slice().sort((a, b) => {\n for (let i = 0; i < sortKeys.length; i++) {\n const key = sortKeys[i];\n\n const propA = get(a, key);\n\n const propB = get(b, key);\n // return 1 or -1 else continue to the next sortKey\n const compareValue = compare(propA, propB);\n\n if (compareValue) {\n return compareValue;\n }\n }\n return 0;\n });\n },\n\n invoke<T>(this: T[], key: string, ...args: unknown[]): unknown[] {\n return (this as unknown as Array<Record<string, unknown>>).map((value) =>\n (value[key] as (...args: unknown[]) => unknown)(...args)\n );\n },\n\n addArrayObserver<T>(this: T[]): void {},\n\n removeArrayObserver<T>(this: T[]): void {},\n\n arrayContentWillChange<T>(this: T[]): void {},\n\n arrayContentDidChange<T>(this: T[]): void {},\n\n reject<T>(this: T[], callback: Parameters<Array<T>['filter']>[0], target?: unknown): T[] {\n assert('`reject` expects a function as first argument.', typeof callback === 'function');\n\n return this.filter((...args) => {\n return !callback.apply(target, args);\n });\n },\n\n rejectBy<T>(this: T[], key: string, value?: unknown): T[] {\n if (arguments.length === 2) {\n return this.filter((record) => {\n return get(record, key) !== value;\n });\n }\n\n return this.filter((record) => {\n return !get(record, key);\n });\n },\n\n setEach<T>(this: T[], key: string, value: unknown): void {\n (this as unknown as Array<Record<string, unknown>>).forEach((item) => set(item, key, value));\n },\n\n uniq<T>(this: T[]): T[] {\n return Array.from(new Set(this));\n },\n\n uniqBy<T>(this: T[], key: string): T[] {\n const seen = new Set();\n const result: T[] = [];\n this.forEach((item) => {\n const value = get(item, key);\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n result.push(item);\n });\n return result;\n },\n\n without<T>(this: T[], value: T): T[] {\n const newArr = this.slice();\n const index = this.indexOf(value);\n if (index !== -1) {\n newArr.splice(index, 1);\n }\n\n return newArr;\n },\n\n get firstObject(): unknown {\n return (this as unknown as unknown[]).at(0);\n },\n\n get lastObject(): unknown {\n return (this as unknown as unknown[]).at(-1);\n },\n};\n\n/**\n * A schema extension that adds Ember's classic `MutableArray`/`Enumerable`\n * style methods (`pushObject`, `removeObject`, `mapBy`, `filterBy`,\n * `sortBy`, `firstObject`, `lastObject`, etc.) to reactive array resources.\n *\n * @summary Legacy schema extension that gives reactive arrays Ember array methods such as `pushObject`, `mapBy`,\n * `filterBy`, and `firstObject`.\n */\nexport const EmberArrayLikeExtension: CAUTION_MEGA_DANGER_ZONE_Extension = {\n kind: 'array',\n name: 'ember-array-like' as const,\n features: EmberArrayLikeFeatures,\n};\n\n/**\n * Extracts the element type of an array type, or `never` if `T` is not an array.\n *\n * @summary Type utility resolving to the element type of an array type, or `never` for non-arrays.\n */\nexport type ArrayType<T> = T extends ReadonlyArray<infer U> ? U : never;\n/**\n * Adds the classic `EmberObject` API (as registered by {@link EmberObjectExtension}/\n * {@link EmberObjectArrayExtension}) to the type of a reactive resource.\n *\n * @summary Legacy type that adds the classic `EmberObject` methods to a reactive resource type using\n * `EmberObjectExtension` or `EmberObjectArrayExtension`.\n */\nexport type WithEmberObject<T> = T & Pick<T & EmberObject, ArrayType<typeof EmberObjectMethods>>;\n\n/**\n * Adds Ember's classic array-like API (as registered by {@link EmberArrayLikeExtension})\n * to the type of a reactive array resource.\n *\n * @summary Legacy type that adds Ember array methods such as `mapBy` and `firstObject` to a reactive array type\n * using `EmberArrayLikeExtension`.\n */\nexport type WithArrayLike<T> =\n T extends Array<infer U>\n ? U &\n Omit<typeof EmberArrayLikeFeatures, 'firstObject' | 'lastObject'> & {\n /**\n * the first member of the array, or `undefined` if the array is empty\n */\n firstObject: T | undefined;\n /**\n * the last member of the array, or `undefined` if the array is empty\n */\n lastObject: T | undefined;\n }\n : T[] &\n Omit<typeof EmberArrayLikeFeatures, 'firstObject' | 'lastObject'> & {\n /**\n * the first member of the array, or `undefined` if the array is empty\n */\n firstObject: T | undefined;\n /**\n * the last member of the array, or `undefined` if the array is empty\n */\n lastObject: T | undefined;\n };\n"],"mappings":";;;;;;;;;;AAoBA,MAAMQ,sBAAsB,CAAC;AAc7BC;CAZE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEFA,CAAkB,CAACC,SAASC,WAAW;CACrCH,oBAAoBG,UAAU,SAASC,gBAAgB,GAAGC,MAA0B;EAClF,QAAQF,QAAR;GACE,KAAK,eACH,OAAQN,YAAgD,MAAM,GAAGQ,IAAI;GACvE,KAAK,YACH,MAAM,IAAIC,MAAM,oDAAoD;GACtE,KAAK,qBAAqB;IACxB,MAAMC,UAAUF,KAAK;IACrB,MAAMG,YAAaH,KAAK,MAAiB;IAKzC,OAAOV,IAAI,MAAMY,UAAWf,IAAI,MAAMe,OAAO,KAAgB,KAAKC,SAAS;GAC7E;GACA,KAAK,OAIH,OAAQhB,IAAwC,MAAM,GAAGa,IAAI;GAC/D,KAAK,iBACH,OAAQZ,cAAkD,MAAM,GAAGY,IAAI;GACzE,KAAK,qBAAqB;IACxB,MAAME,UAAUF,KAAK;IACrB,MAAMI,YAAaJ,KAAK,MAAiB;IAKzC,OAAOV,IAAI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,OAAOnF,KAAK4E,IAAI;EAClB,CAAC;EACD,OAAOO;CACT;CAEAG,QAAsBzC,OAAe;EACnC,MAAM0C,SAAS,KAAK7D,MAAM;EAC1B,MAAM5B,QAAQ,KAAKC,QAAQ8C,KAAK;EAChC,IAAI/C,UAAU,IACZyF,OAAOlE,OAAOvB,OAAO,CAAC;EAGxB,OAAOyF;CACT;CAEA,IAAIC,cAAuB;EACzB,OAAQ,KAA8BC,GAAG,CAAC;CAC5C;CAEA,IAAIC,aAAsB;EACxB,OAAQ,KAA8BD,GAAG,EAAE;CAC7C;AACF;;;;;;;;;AAUA,MAAaE,0BAA8D;CACzEpG,MAAM;CACNC,MAAM;CACNC,UAAUE;AACZ"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { dasherize, singularize } from "@warp-drive/utilities/string";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/compat/utils.ts
|
|
4
4
|
/**
|
|
5
5
|
Utilities for helping to migrate to stricter
|
|
6
6
|
and more consistent use of IDs and types.
|
|
7
7
|
|
|
8
|
+
@summary Legacy helpers that normalize, compare, and report mismatched resource ids and types while migrating to
|
|
9
|
+
stricter formats.
|
|
8
10
|
@module
|
|
9
11
|
*/
|
|
10
12
|
let MismatchReporter = function() {};
|
|
@@ -20,6 +22,8 @@ let NormalizedType = (str) => {
|
|
|
20
22
|
* changes during normalization. This is useful for instrumenting
|
|
21
23
|
* to discover places where usage in the app is not consistent.
|
|
22
24
|
*
|
|
25
|
+
* @summary Legacy migration helper that registers a callback invoked whenever `formattedId` or `formattedType`
|
|
26
|
+
* has to change the id or type it was given.
|
|
23
27
|
* @param fn - a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value
|
|
24
28
|
* @public
|
|
25
29
|
*/
|
|
@@ -31,6 +35,8 @@ function configureMismatchReporter(fn) {
|
|
|
31
35
|
* fails validation. This is useful for instrumenting
|
|
32
36
|
* to discover places where usage in the app is not consistent.
|
|
33
37
|
*
|
|
38
|
+
* @summary Legacy migration helper that registers a callback invoked when an id or type passed to these utilities
|
|
39
|
+
* fails validation.
|
|
34
40
|
* @param fn - a function which takes a message and a condition
|
|
35
41
|
* @public
|
|
36
42
|
*/
|
|
@@ -47,6 +53,8 @@ function configureAssertFn(fn) {
|
|
|
47
53
|
* the configured mismatch reporter and assert functions will
|
|
48
54
|
* be called.
|
|
49
55
|
*
|
|
56
|
+
* @summary Legacy migration helper that replaces the singularize-and-dasherize function `formattedType` and
|
|
57
|
+
* `isEquivType` use to normalize resource types.
|
|
50
58
|
* @param fn - a function which takes a string and returns a string
|
|
51
59
|
* @public
|
|
52
60
|
*/
|
|
@@ -79,6 +87,8 @@ const NORMALIZED_TYPES = /* @__PURE__ */ new Map();
|
|
|
79
87
|
* formattedType('PostComment'); // => 'post-comment'
|
|
80
88
|
* ```
|
|
81
89
|
*
|
|
90
|
+
* @summary Legacy migration helper that normalizes a resource type to the singular dasherized form the cache
|
|
91
|
+
* expects, such as `'PostComments'` to `'post-comment'`.
|
|
82
92
|
* @param type the potentially un-normalized type
|
|
83
93
|
* @return the normalized type
|
|
84
94
|
* @public
|
|
@@ -112,6 +122,8 @@ function formattedType(type) {
|
|
|
112
122
|
* formattedId(null); // => null
|
|
113
123
|
* ```
|
|
114
124
|
*
|
|
125
|
+
* @summary Legacy migration helper that normalizes a resource id to the `string` or `null` the cache expects,
|
|
126
|
+
* asserting on invalid ids such as `''` or `0`.
|
|
115
127
|
* @param id the potentially un-normalized id
|
|
116
128
|
* @return the normalized id
|
|
117
129
|
* @public
|
|
@@ -129,6 +141,8 @@ function formattedId(id) {
|
|
|
129
141
|
* Like {@link formattedId}, but asserts that `id` is not `null` rather
|
|
130
142
|
* than allowing and passing through `null`.
|
|
131
143
|
*
|
|
144
|
+
* @summary Legacy migration helper that normalizes a resource id to a string like `formattedId`, but asserts that
|
|
145
|
+
* it is not `null`.
|
|
132
146
|
* @public
|
|
133
147
|
*/
|
|
134
148
|
/**
|
|
@@ -160,6 +174,8 @@ function expectId(id) {
|
|
|
160
174
|
* isEquivType('posts', null); // false
|
|
161
175
|
* ```
|
|
162
176
|
*
|
|
177
|
+
* @summary Legacy migration helper that reports whether two resource types match after normalization, so
|
|
178
|
+
* `'posts'` and `'post'` are equivalent.
|
|
163
179
|
* @param expected a potentially unnormalized type to match against
|
|
164
180
|
* @param actual a potentially unnormalized type to match against
|
|
165
181
|
* @return true if the types are equivalent
|
|
@@ -192,6 +208,8 @@ function isEquivType(expected, actual) {
|
|
|
192
208
|
* isEquivId(1, null); // false
|
|
193
209
|
* ```
|
|
194
210
|
*
|
|
211
|
+
* @summary Legacy migration helper that reports whether two resource ids match after normalization, so `1` and
|
|
212
|
+
* `'1'` are equivalent.
|
|
195
213
|
* @param expected a potentially un-normalized id to match against
|
|
196
214
|
* @param actual a potentially un-normalized id to match against
|
|
197
215
|
* @return true if the ids are equivalent
|
|
@@ -210,6 +228,5 @@ function isEquivId(expected, actual) {
|
|
|
210
228
|
return expected === actual || formattedId(expected) === formattedId(actual);
|
|
211
229
|
}
|
|
212
230
|
|
|
213
|
-
//#endregion
|
|
214
231
|
export { configureAssertFn, configureMismatchReporter, configureTypeNormalization, expectId, formattedId, formattedType, isEquivId, isEquivType };
|
|
215
232
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["dasherize","singularize","MismatchReporter","_AssertFn","AssertFn","message","condition","NormalizedType","str","configureMismatchReporter","fn","configureAssertFn","configureTypeNormalization","NORMALIZED_TYPES","Map","formattedType","type","undefined","length","normalized","get","set","formattedId","id","formatted","String","expectId","isEquivType","expected","actual","isEquivId"],"sources":["../../../../src/compat/utils.ts"],"sourcesContent":["/**\n Utilities for helping to migrate to stricter\n and more consistent use of IDs and types.\n\n @module\n*/\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { dasherize, singularize } from '@warp-drive/utilities/string';\n\ninterface AssertFunc {\n (desc: string, condition: unknown): asserts condition;\n (desc: string): never;\n}\n\ntype Reporter = (type: 'formatted-id' | 'formatted-type', actual: unknown, expected: unknown) => void;\ntype Normalizer = (type: string) => string;\n\nlet MismatchReporter: Reporter = function () {};\n\n// TODO: @runspired This pattern prevents AssertFn from being removed in production builds\n// but we should enable that if we can.\nlet _AssertFn: (message: string, condition: unknown) => void = function () {};\nconst AssertFn: AssertFunc = ((message: string, condition: unknown) => {\n if (!condition) {\n _AssertFn(message, condition);\n }\n assert(message, condition);\n}) as unknown as AssertFunc;\nlet NormalizedType: Normalizer = (str: string) => {\n return singularize(dasherize(str));\n};\n\n/**\n * Configure a function to be called when an id or type\n * changes during normalization. This is useful for instrumenting\n * to discover places where usage in the app is not consistent.\n *\n * @param fn - a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value\n * @public\n */\nexport function configureMismatchReporter(fn: Reporter): void {\n MismatchReporter = fn;\n}\n\n/**\n * Configure a function to be called when an id or type\n * fails validation. This is useful for instrumenting\n * to discover places where usage in the app is not consistent.\n *\n * @param fn - a function which takes a message and a condition\n * @public\n */\nexport function configureAssertFn(fn: (message: string, condition: unknown) => void): void {\n _AssertFn = fn;\n}\n\n/**\n * Configure a function to be called to normalize\n * a resource type string. Used by both formattedType\n * and isEquivType to ensure consistent normalization\n * during comparison.\n *\n * If validation fails or the type turns out be unnormalized\n * the configured mismatch reporter and assert functions will\n * be called.\n *\n * @param fn - a function which takes a string and returns a string\n * @public\n */\nexport function configureTypeNormalization(fn: (type: string) => string): void {\n NormalizedType = fn;\n}\n\nconst NORMALIZED_TYPES = new Map<string, string>();\n\n/**\n * Converts a potentially unnormalized type into the format expected\n * by our WarpDrive Cache. Currently this is singular-dasherized.\n *\n * you should not rely on this function to give you an exact format\n * for display purposes. Formatting for display should be handled\n * differently if the exact format matters.\n *\n * Asserts invalid types (undefined, null, '') in dev.\n *\n * **Usage**\n *\n * ```js\n * import formattedType from 'soxhub-client/helpers/formatted-type';\n *\n * formattedType('post'); // => 'post'\n * formattedType('posts'); // => 'post'\n * formattedType('Posts'); // => 'post'\n * formattedType('post-comment'); // => 'post-comment'\n * formattedType('post-comments'); // => 'post-comment'\n * formattedType('post_comment'); // => 'post-comment'\n * formattedType('postComment'); // => 'post-comment'\n * formattedType('PostComment'); // => 'post-comment'\n * ```\n *\n * @param type the potentially un-normalized type\n * @return the normalized type\n * @public\n */\nexport function formattedType<T extends string>(type: T | string): T {\n AssertFn('formattedType: type must not be null', type !== null);\n AssertFn('formattedType: type must not be undefined', type !== undefined);\n AssertFn('formattedType: type must be a string', typeof type === 'string');\n AssertFn('formattedType: type must not be empty', type.length > 0);\n let normalized = NORMALIZED_TYPES.get(type);\n\n if (normalized === undefined) {\n normalized = NormalizedType(type);\n NORMALIZED_TYPES.set(type, normalized);\n }\n\n if (normalized !== type) {\n MismatchReporter('formatted-type', type, normalized);\n }\n\n return normalized as T;\n}\n\n/**\n * Format an id to the format expected by the WarpDrive Cache.\n * Currently this means that id should be `string | null`.\n *\n * Asserts invalid IDs (undefined, '', 0, '0') in dev.\n *\n * **Usage**\n *\n * ```js\n * import formattedId from 'client/utils/formatted-id';\n *\n * formattedId('1'); // => '1'\n * formattedId(1); // => '1'\n * formattedId(null); // => null\n *\t```\n *\n * @param id the potentially un-normalized id\n * @return the normalized id\n * @public\n */\nexport function formattedId(id: string | number): string;\nexport function formattedId(id: null): null;\nexport function formattedId(id: string | number | null): string | null;\nexport function formattedId(id: string | number | null): string | null {\n AssertFn('formattedId: id must not be undefined', id !== undefined);\n AssertFn(\n 'formattedId: id must be a number, string or null',\n typeof id === 'number' || typeof id === 'string' || id === null\n );\n AssertFn(\n 'formattedId: id must not be empty',\n typeof id === 'number' || id === null || (typeof id === 'string' && id.length > 0)\n );\n AssertFn('formattedId: id must not be 0', id !== '0' && id !== 0);\n\n const formatted = id === null ? null : String(id);\n if (formatted !== id) {\n MismatchReporter('formatted-id', id, formatted);\n }\n return id === null ? null : String(id);\n}\n\n/**\n * Like {@link formattedId}, but asserts that `id` is not `null` rather\n * than allowing and passing through `null`.\n *\n * @public\n */\nexport function expectId(id: string | number): string;\n/**\n * Throws, since `id` is `null`.\n *\n * @public\n */\nexport function expectId(id: null): never;\nexport function expectId(id: string | number | null): string {\n AssertFn('expectId: id must not be null', id !== null);\n\n return formattedId(id);\n}\n\n/**\n * Compares two types for strict equality, converting them to\n * the format expected by the WarpDrive Cache to ensure\n * differences in format are accounted for in the comparison.\n *\n * Asserts when expected or actual are invalid types in dev.\n * Expected may never be null.\n *\n * ```js\n * isEquivType('posts', 'post'); // true\n * isEquivType('post', 'post'); // true\n * isEquivType('posts', 'posts'); // true\n * isEquivType('post-comment', 'postComment'); // true\n * isEquivType('post-comment', 'PostComment'); // true\n * isEquivType('post-comment', 'post_comment'); // true\n * isEquivType('post-comment', 'post-comment'); // true\n * isEquivType('post-comment', 'post'); // false\n * isEquivType('posts', null); // false\n * ```\n *\n * @param expected a potentially unnormalized type to match against\n * @param actual a potentially unnormalized type to match against\n * @return true if the types are equivalent\n * @public\n */\nexport function isEquivType(expected: string, actual: string): boolean {\n AssertFn('isEquivType: Expected type must not be null', expected !== null);\n AssertFn('isEquivType: Expected type must not be undefined', expected !== undefined);\n AssertFn('isEquivType: Expected type must be a string', typeof expected === 'string');\n AssertFn('isEquivType: Expected type must not be empty', expected.length > 0);\n\n AssertFn('isEquivType: Actual type must not be null', actual !== null);\n AssertFn('isEquivType: Actual type must not be undefined', actual !== undefined);\n AssertFn('isEquivType: Actual type must be a string', typeof actual === 'string');\n AssertFn('isEquivType: Actual type must not be empty', actual.length > 0);\n\n return expected === actual || formattedType(expected) === formattedType(actual);\n}\n\n/**\n * Compares two IDs for strict equality, converting them to\n * the format expected by the WarpDrive Cache to ensure\n * differences in format are accounted for in the comparison.\n *\n * Asserts when expected or actual are invalid IDs in dev.\n * Expected may never be null.\n *\n * ```js\n * isEquivId('1', 1); // true\n * isEquivId('2', '2'); // true\n * isEquivId(3, '3'); // true\n * isEquivId(4, '3'); // false\n * isEquivId(1, null); // false\n * ```\n *\n * @param expected a potentially un-normalized id to match against\n * @param actual a potentially un-normalized id to match against\n * @return true if the ids are equivalent\n * @public\n */\nexport function isEquivId(expected: string | number, actual: string | number | null): boolean {\n AssertFn('isEquivId: Expected id must not be null', expected !== null);\n AssertFn('isEquivId: Expected id must not be undefined', expected !== undefined);\n AssertFn(\n 'isEquivId: Expected id must be a number or string',\n typeof expected === 'number' || typeof expected === 'string'\n );\n AssertFn(\n 'isEquivId: Expected id must not be empty',\n typeof expected === 'number' || (typeof expected === 'string' && expected.length > 0)\n );\n AssertFn('isEquivId: Expected id must not be 0', expected !== '0' && expected !== 0);\n\n AssertFn('isEquivId: Actual id must not be undefined', actual !== undefined);\n AssertFn(\n 'isEquivId: Actual id must be a number, string or null',\n typeof actual === 'number' || typeof actual === 'string' || actual === null\n );\n AssertFn(\n 'isEquivId: Actual id must not be empty',\n actual === null || typeof actual === 'number' || (typeof actual === 'string' && actual.length > 0)\n );\n AssertFn('isEquivId: Actual id must not be 0', actual !== '0' && actual !== 0);\n\n return expected === actual || formattedId(expected) === formattedId(actual);\n}\n"],"mappings":";;;;;;;;;AAiBA,IAAIE,mBAA6B,WAAY,CAAC;AAI9C,IAAIC,YAA2D,WAAY,CAAC;AAC5E,MAAMC,YAAyBC,SAAiBC,cAAuB;CACrE,IAAI,CAACA,WACHH,UAAUE,SAASC,SAAS;AAGhC;AACA,IAAIC,kBAA8BC,QAAgB;CAChD,OAAOP,YAAYD,UAAUQ,GAAG,CAAC;AACnC;;;;;;;;;AAUA,SAAgBC,0BAA0BC,IAAoB;CAC5DR,mBAAmBQ;AACrB;;;;;;;;;AAUA,SAAgBC,kBAAkBD,IAAyD;CACzFP,YAAYO;AACd;;;;;;;;;;;;;;AAeA,SAAgBE,2BAA2BF,IAAoC;CAC7EH,iBAAiBG;AACnB;AAEA,MAAMG,mCAAmB,IAAIC,IAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BjD,SAAgBC,cAAgCC,MAAqB;CACnEZ,SAAS,wCAAwC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AkDyB,WAAWZ,MAAS;CAC/Eb,SAAS,6CAA6C,OAAOyB,WAAW,QAAQ;CAChFzB,SAAS,8CAA8CyB,OAAOX,SAAS,CAAC;CAExE,OAAOU,aAAaC,UAAUd,cAAca,QAAQ,MAAMb,cAAcc,MAAM;AAChF;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgBC,UAAUF,UAA2BC,QAAyC;CAC5FzB,SAAS,2CAA2CwB,aAAa,IAAI;CACrExB,SAAS,gDAAgDwB,aAAaX,MAAS;CAC/Eb,SACE,qDACA,OAAOwB,aAAa,YAAY,OAAOA,aAAa,QACtD;CACAxB,SACE,4CACA,OAAOwB,aAAa,YAAa,OAAOA,aAAa,YAAYA,SAASV,SAAS,CACrF;CACAd,SAAS,wCAAwCwB,aAAa,OAAOA,aAAa,CAAC;CAEnFxB,SAAS,8CAA8CyB,WAAWZ,MAAS;CAC3Eb,SACE,yDACA,OAAOyB,WAAW,YAAY,OAAOA,WAAW,YAAYA,WAAW,IACzE;CACAzB,SACE,0CACAyB,WAAW,QAAQ,OAAOA,WAAW,YAAa,OAAOA,WAAW,YAAYA,OAAOX,SAAS,CAClG;CACAd,SAAS,sCAAsCyB,WAAW,OAAOA,WAAW,CAAC;CAE7E,OAAOD,aAAaC,UAAUP,YAAYM,QAAQ,MAAMN,YAAYO,MAAM;AAC5E"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":["dasherize","singularize","MismatchReporter","_AssertFn","AssertFn","message","condition","NormalizedType","str","configureMismatchReporter","fn","configureAssertFn","configureTypeNormalization","NORMALIZED_TYPES","Map","formattedType","type","undefined","length","normalized","get","set","formattedId","id","formatted","String","expectId","isEquivType","expected","actual","isEquivId"],"sources":["../../../../src/compat/utils.ts"],"sourcesContent":["/**\n Utilities for helping to migrate to stricter\n and more consistent use of IDs and types.\n\n @summary Legacy helpers that normalize, compare, and report mismatched resource ids and types while migrating to\n stricter formats.\n @module\n*/\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { dasherize, singularize } from '@warp-drive/utilities/string';\n\ninterface AssertFunc {\n (desc: string, condition: unknown): asserts condition;\n (desc: string): never;\n}\n\ntype Reporter = (type: 'formatted-id' | 'formatted-type', actual: unknown, expected: unknown) => void;\ntype Normalizer = (type: string) => string;\n\nlet MismatchReporter: Reporter = function () {};\n\n// TODO: @runspired This pattern prevents AssertFn from being removed in production builds\n// but we should enable that if we can.\nlet _AssertFn: (message: string, condition: unknown) => void = function () {};\nconst AssertFn: AssertFunc = ((message: string, condition: unknown) => {\n if (!condition) {\n _AssertFn(message, condition);\n }\n assert(message, condition);\n}) as unknown as AssertFunc;\nlet NormalizedType: Normalizer = (str: string) => {\n return singularize(dasherize(str));\n};\n\n/**\n * Configure a function to be called when an id or type\n * changes during normalization. This is useful for instrumenting\n * to discover places where usage in the app is not consistent.\n *\n * @summary Legacy migration helper that registers a callback invoked whenever `formattedId` or `formattedType`\n * has to change the id or type it was given.\n * @param fn - a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value\n * @public\n */\nexport function configureMismatchReporter(fn: Reporter): void {\n MismatchReporter = fn;\n}\n\n/**\n * Configure a function to be called when an id or type\n * fails validation. This is useful for instrumenting\n * to discover places where usage in the app is not consistent.\n *\n * @summary Legacy migration helper that registers a callback invoked when an id or type passed to these utilities\n * fails validation.\n * @param fn - a function which takes a message and a condition\n * @public\n */\nexport function configureAssertFn(fn: (message: string, condition: unknown) => void): void {\n _AssertFn = fn;\n}\n\n/**\n * Configure a function to be called to normalize\n * a resource type string. Used by both formattedType\n * and isEquivType to ensure consistent normalization\n * during comparison.\n *\n * If validation fails or the type turns out be unnormalized\n * the configured mismatch reporter and assert functions will\n * be called.\n *\n * @summary Legacy migration helper that replaces the singularize-and-dasherize function `formattedType` and\n * `isEquivType` use to normalize resource types.\n * @param fn - a function which takes a string and returns a string\n * @public\n */\nexport function configureTypeNormalization(fn: (type: string) => string): void {\n NormalizedType = fn;\n}\n\nconst NORMALIZED_TYPES = new Map<string, string>();\n\n/**\n * Converts a potentially unnormalized type into the format expected\n * by our WarpDrive Cache. Currently this is singular-dasherized.\n *\n * you should not rely on this function to give you an exact format\n * for display purposes. Formatting for display should be handled\n * differently if the exact format matters.\n *\n * Asserts invalid types (undefined, null, '') in dev.\n *\n * **Usage**\n *\n * ```js\n * import formattedType from 'soxhub-client/helpers/formatted-type';\n *\n * formattedType('post'); // => 'post'\n * formattedType('posts'); // => 'post'\n * formattedType('Posts'); // => 'post'\n * formattedType('post-comment'); // => 'post-comment'\n * formattedType('post-comments'); // => 'post-comment'\n * formattedType('post_comment'); // => 'post-comment'\n * formattedType('postComment'); // => 'post-comment'\n * formattedType('PostComment'); // => 'post-comment'\n * ```\n *\n * @summary Legacy migration helper that normalizes a resource type to the singular dasherized form the cache\n * expects, such as `'PostComments'` to `'post-comment'`.\n * @param type the potentially un-normalized type\n * @return the normalized type\n * @public\n */\nexport function formattedType<T extends string>(type: T | string): T {\n AssertFn('formattedType: type must not be null', type !== null);\n AssertFn('formattedType: type must not be undefined', type !== undefined);\n AssertFn('formattedType: type must be a string', typeof type === 'string');\n AssertFn('formattedType: type must not be empty', type.length > 0);\n let normalized = NORMALIZED_TYPES.get(type);\n\n if (normalized === undefined) {\n normalized = NormalizedType(type);\n NORMALIZED_TYPES.set(type, normalized);\n }\n\n if (normalized !== type) {\n MismatchReporter('formatted-type', type, normalized);\n }\n\n return normalized as T;\n}\n\n/**\n * Format an id to the format expected by the WarpDrive Cache.\n * Currently this means that id should be `string | null`.\n *\n * Asserts invalid IDs (undefined, '', 0, '0') in dev.\n *\n * **Usage**\n *\n * ```js\n * import formattedId from 'client/utils/formatted-id';\n *\n * formattedId('1'); // => '1'\n * formattedId(1); // => '1'\n * formattedId(null); // => null\n *\t```\n *\n * @summary Legacy migration helper that normalizes a resource id to the `string` or `null` the cache expects,\n * asserting on invalid ids such as `''` or `0`.\n * @param id the potentially un-normalized id\n * @return the normalized id\n * @public\n */\nexport function formattedId(id: string | number): string;\nexport function formattedId(id: null): null;\nexport function formattedId(id: string | number | null): string | null;\nexport function formattedId(id: string | number | null): string | null {\n AssertFn('formattedId: id must not be undefined', id !== undefined);\n AssertFn(\n 'formattedId: id must be a number, string or null',\n typeof id === 'number' || typeof id === 'string' || id === null\n );\n AssertFn(\n 'formattedId: id must not be empty',\n typeof id === 'number' || id === null || (typeof id === 'string' && id.length > 0)\n );\n AssertFn('formattedId: id must not be 0', id !== '0' && id !== 0);\n\n const formatted = id === null ? null : String(id);\n if (formatted !== id) {\n MismatchReporter('formatted-id', id, formatted);\n }\n return id === null ? null : String(id);\n}\n\n/**\n * Like {@link formattedId}, but asserts that `id` is not `null` rather\n * than allowing and passing through `null`.\n *\n * @summary Legacy migration helper that normalizes a resource id to a string like `formattedId`, but asserts that\n * it is not `null`.\n * @public\n */\nexport function expectId(id: string | number): string;\n/**\n * Throws, since `id` is `null`.\n *\n * @public\n */\nexport function expectId(id: null): never;\nexport function expectId(id: string | number | null): string {\n AssertFn('expectId: id must not be null', id !== null);\n\n return formattedId(id);\n}\n\n/**\n * Compares two types for strict equality, converting them to\n * the format expected by the WarpDrive Cache to ensure\n * differences in format are accounted for in the comparison.\n *\n * Asserts when expected or actual are invalid types in dev.\n * Expected may never be null.\n *\n * ```js\n * isEquivType('posts', 'post'); // true\n * isEquivType('post', 'post'); // true\n * isEquivType('posts', 'posts'); // true\n * isEquivType('post-comment', 'postComment'); // true\n * isEquivType('post-comment', 'PostComment'); // true\n * isEquivType('post-comment', 'post_comment'); // true\n * isEquivType('post-comment', 'post-comment'); // true\n * isEquivType('post-comment', 'post'); // false\n * isEquivType('posts', null); // false\n * ```\n *\n * @summary Legacy migration helper that reports whether two resource types match after normalization, so\n * `'posts'` and `'post'` are equivalent.\n * @param expected a potentially unnormalized type to match against\n * @param actual a potentially unnormalized type to match against\n * @return true if the types are equivalent\n * @public\n */\nexport function isEquivType(expected: string, actual: string): boolean {\n AssertFn('isEquivType: Expected type must not be null', expected !== null);\n AssertFn('isEquivType: Expected type must not be undefined', expected !== undefined);\n AssertFn('isEquivType: Expected type must be a string', typeof expected === 'string');\n AssertFn('isEquivType: Expected type must not be empty', expected.length > 0);\n\n AssertFn('isEquivType: Actual type must not be null', actual !== null);\n AssertFn('isEquivType: Actual type must not be undefined', actual !== undefined);\n AssertFn('isEquivType: Actual type must be a string', typeof actual === 'string');\n AssertFn('isEquivType: Actual type must not be empty', actual.length > 0);\n\n return expected === actual || formattedType(expected) === formattedType(actual);\n}\n\n/**\n * Compares two IDs for strict equality, converting them to\n * the format expected by the WarpDrive Cache to ensure\n * differences in format are accounted for in the comparison.\n *\n * Asserts when expected or actual are invalid IDs in dev.\n * Expected may never be null.\n *\n * ```js\n * isEquivId('1', 1); // true\n * isEquivId('2', '2'); // true\n * isEquivId(3, '3'); // true\n * isEquivId(4, '3'); // false\n * isEquivId(1, null); // false\n * ```\n *\n * @summary Legacy migration helper that reports whether two resource ids match after normalization, so `1` and\n * `'1'` are equivalent.\n * @param expected a potentially un-normalized id to match against\n * @param actual a potentially un-normalized id to match against\n * @return true if the ids are equivalent\n * @public\n */\nexport function isEquivId(expected: string | number, actual: string | number | null): boolean {\n AssertFn('isEquivId: Expected id must not be null', expected !== null);\n AssertFn('isEquivId: Expected id must not be undefined', expected !== undefined);\n AssertFn(\n 'isEquivId: Expected id must be a number or string',\n typeof expected === 'number' || typeof expected === 'string'\n );\n AssertFn(\n 'isEquivId: Expected id must not be empty',\n typeof expected === 'number' || (typeof expected === 'string' && expected.length > 0)\n );\n AssertFn('isEquivId: Expected id must not be 0', expected !== '0' && expected !== 0);\n\n AssertFn('isEquivId: Actual id must not be undefined', actual !== undefined);\n AssertFn(\n 'isEquivId: Actual id must be a number, string or null',\n typeof actual === 'number' || typeof actual === 'string' || actual === null\n );\n AssertFn(\n 'isEquivId: Actual id must not be empty',\n actual === null || typeof actual === 'number' || (typeof actual === 'string' && actual.length > 0)\n );\n AssertFn('isEquivId: Actual id must not be 0', actual !== '0' && actual !== 0);\n\n return expected === actual || formattedId(expected) === formatted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