@warp-drive/legacy 5.10.0-alpha.10 → 5.10.0-alpha.13
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 -1
- package/blueprints/adapter/index.js +8 -4
- package/blueprints/adapter-test/index.js +0 -2
- package/blueprints/adapter-test/qunit-files/__root__/__path__/__test__.js +1 -1
- package/blueprints/model/files/__root__/__path__/__name__.js +1 -1
- package/blueprints/model/index.js +9 -3
- package/blueprints/model-test/index.js +0 -2
- package/blueprints/model-test/qunit-files/__root__/__path__/__test__.js +1 -1
- package/blueprints/serializer/files/__root__/__path__/__name__.js +1 -1
- package/blueprints/serializer/index.js +8 -4
- package/blueprints/serializer-test/index.js +0 -2
- package/blueprints/serializer-test/qunit-files/__root__/__path__/__test__.js +1 -1
- package/blueprints/transform/files/__root__/__path__/__name__.js +1 -1
- package/blueprints/transform/index.js +6 -1
- package/blueprints/transform-test/index.js +0 -2
- package/blueprints/transform-test/qunit-files/__root__/__path__/__test__.js +1 -1
- package/dist/-private-BE7RaJCw.js.map +1 -1
- package/dist/adapter/-private.d.ts +2 -2
- package/dist/adapter/error.d.ts +1 -1
- package/dist/adapter/error.js +53 -0
- package/dist/adapter/error.js.map +1 -1
- package/dist/adapter/json-api.d.ts +5 -3
- package/dist/adapter/json-api.d.ts.map +1 -1
- package/dist/adapter/json-api.js +8 -1
- package/dist/adapter/json-api.js.map +1 -1
- package/dist/adapter/rest.d.ts +1 -1
- package/dist/adapter/rest.js +20 -1
- package/dist/adapter/rest.js.map +1 -1
- package/dist/{adapter-eYo2pIuM.js → adapter-BNC6wlWu.js} +42 -1
- package/dist/adapter-BNC6wlWu.js.map +1 -0
- package/dist/{adapter-CARrK3-8.d.ts → adapter-D3A8ixjz.d.ts} +9 -2
- package/dist/adapter-D3A8ixjz.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/builders.d.ts +10 -0
- package/dist/compat/builders.d.ts.map +1 -1
- package/dist/compat/builders.js +10 -0
- package/dist/compat/builders.js.map +1 -1
- package/dist/compat/extensions.d.ts +1 -1
- package/dist/compat/extensions.js +22 -0
- package/dist/compat/extensions.js.map +1 -1
- package/dist/compat/utils.d.ts +16 -0
- package/dist/compat/utils.d.ts.map +1 -1
- package/dist/compat/utils.js +18 -0
- package/dist/compat/utils.js.map +1 -1
- package/dist/{compat-BbNNmTM-.d.ts → compat-BZlQ-5eI.d.ts} +30 -1
- package/dist/compat-BZlQ-5eI.d.ts.map +1 -0
- package/dist/{compat-DWgmYX8T.js → compat-Da5y9AsM.js} +57 -1
- package/dist/compat-Da5y9AsM.js.map +1 -0
- package/dist/compat.d.ts +1 -1
- package/dist/compat.js +1 -1
- package/dist/{error-CzkyXr1Q.d.ts → error-Ba1cMaWG.d.ts} +49 -1
- package/dist/error-Ba1cMaWG.d.ts.map +1 -0
- package/dist/{errors-BlrR6--x.js → errors-BI0Xugyo.js} +3 -1
- package/dist/errors-BI0Xugyo.js.map +1 -0
- package/dist/{extensions-DumNm4dA.d.ts → extensions-fwdnX9n4.d.ts} +18 -1
- package/dist/extensions-fwdnX9n4.d.ts.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -5
- package/dist/index.js.map +1 -1
- package/dist/{json-BXNPTlcH.js → json-n2XHdV_P.js} +8 -1
- package/dist/json-n2XHdV_P.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 +18 -2
- package/dist/model/migration-support.d.ts.map +1 -1
- package/dist/model/migration-support.js +21 -3
- package/dist/model/migration-support.js.map +1 -1
- package/dist/{model-62hn5_PD.d.ts → model-BPVLf-rp.d.ts} +11 -2
- package/dist/model-BPVLf-rp.d.ts.map +1 -0
- package/dist/{model-C9l1mRs6.js → model-DdlhdL9V.js} +14 -3
- package/dist/model-DdlhdL9V.js.map +1 -0
- package/dist/{unpkg/dev-deprecated/model-fragments-DSqu0ptR.js → model-fragments-ZM4k_mT3.js} +23 -1
- package/dist/model-fragments-ZM4k_mT3.js.map +1 -0
- package/dist/model-fragments.d.ts +31 -1
- package/dist/model-fragments.d.ts.map +1 -1
- package/dist/model-fragments.js +1 -1
- package/dist/model.d.ts +12 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +2 -2
- package/dist/{rest-0NhtexIq.d.ts → rest-ddU-K5eS.d.ts} +18 -4
- package/dist/rest-ddU-K5eS.d.ts.map +1 -0
- package/dist/{schema-provider-waPfuoKq.js → schema-provider-Dyjpau2P.js} +13 -6
- package/dist/schema-provider-Dyjpau2P.js.map +1 -0
- package/dist/serializer/json-api.d.ts +1 -0
- package/dist/serializer/json-api.d.ts.map +1 -1
- package/dist/serializer/json-api.js +6 -1
- package/dist/serializer/json-api.js.map +1 -1
- package/dist/serializer/json.d.ts +2 -0
- package/dist/serializer/json.d.ts.map +1 -1
- package/dist/serializer/json.js +1 -1
- package/dist/serializer/rest.d.ts +4 -0
- package/dist/serializer/rest.d.ts.map +1 -1
- package/dist/serializer/rest.js +10 -1
- package/dist/serializer/rest.js.map +1 -1
- package/dist/serializer/transform.d.ts +9 -0
- package/dist/serializer/transform.d.ts.map +1 -1
- package/dist/serializer/transform.js +9 -0
- package/dist/serializer/transform.js.map +1 -1
- package/dist/serializer.d.ts +2 -0
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +40 -0
- package/dist/serializer.js.map +1 -1
- package/dist/{store-C4qYzXei.js → store-CMUcaXRp.js} +9 -1
- package/dist/store-CMUcaXRp.js.map +1 -0
- package/dist/store.d.ts +3 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +1 -1
- package/dist/unpkg/dev/-private-BWBRzgZO.js.map +1 -1
- package/dist/unpkg/dev/adapter/error.js +53 -0
- package/dist/unpkg/dev/adapter/error.js.map +1 -1
- package/dist/unpkg/dev/adapter/json-api.js +8 -1
- package/dist/unpkg/dev/adapter/json-api.js.map +1 -1
- package/dist/unpkg/dev/adapter/rest.js +20 -1
- package/dist/unpkg/dev/adapter/rest.js.map +1 -1
- package/dist/unpkg/{dev-deprecated/adapter-oLwyr47q.js → dev/adapter-CLkSBRpr.js} +42 -1
- package/dist/unpkg/dev/adapter-CLkSBRpr.js.map +1 -0
- package/dist/unpkg/dev/adapter.js +1 -1
- package/dist/unpkg/dev/compat/builders.js +10 -0
- package/dist/unpkg/dev/compat/builders.js.map +1 -1
- package/dist/unpkg/dev/compat/extensions.js +22 -0
- package/dist/unpkg/dev/compat/extensions.js.map +1 -1
- package/dist/unpkg/dev/compat/utils.js +18 -0
- package/dist/unpkg/dev/compat/utils.js.map +1 -1
- package/dist/unpkg/dev/{compat-BIv7BiG_.js → compat-BEO8cSlC.js} +57 -1
- package/dist/unpkg/dev/compat-BEO8cSlC.js.map +1 -0
- package/dist/unpkg/dev/compat.js +1 -1
- package/dist/unpkg/dev/{errors-Dv8RCLdU.js → errors-TUXPdiG8.js} +3 -1
- package/dist/unpkg/dev/errors-TUXPdiG8.js.map +1 -0
- package/dist/unpkg/dev/index.js +24 -5
- package/dist/unpkg/dev/index.js.map +1 -1
- package/dist/unpkg/dev/{json-DDJji3V3.js → json-CN-WCWwk.js} +8 -1
- package/dist/unpkg/dev/json-CN-WCWwk.js.map +1 -0
- package/dist/unpkg/dev/model/-private.js +1 -1
- package/dist/unpkg/dev/model/migration-support.js +20 -2
- package/dist/unpkg/dev/model/migration-support.js.map +1 -1
- package/dist/unpkg/dev/{model-CRYi4C3z.js → model-OQxvzZu6.js} +14 -3
- package/dist/unpkg/dev/model-OQxvzZu6.js.map +1 -0
- package/dist/unpkg/dev/{model-fragments-DSqu0ptR.js → model-fragments-ZM4k_mT3.js} +23 -1
- package/dist/unpkg/dev/model-fragments-ZM4k_mT3.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/{schema-provider-BYjTpV6C.js → schema-provider-Qxo5AVFM.js} +9 -2
- package/dist/unpkg/dev/schema-provider-Qxo5AVFM.js.map +1 -0
- package/dist/unpkg/dev/serializer/json-api.js +6 -1
- 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 +10 -1
- package/dist/unpkg/dev/serializer/rest.js.map +1 -1
- package/dist/unpkg/dev/serializer/transform.js +9 -0
- package/dist/unpkg/dev/serializer/transform.js.map +1 -1
- package/dist/unpkg/dev/serializer.js +40 -0
- package/dist/unpkg/dev/serializer.js.map +1 -1
- package/dist/unpkg/dev/{store-D_V8-HQl.js → store-DPzaVp5e.js} +9 -1
- package/dist/unpkg/dev/store-DPzaVp5e.js.map +1 -0
- package/dist/unpkg/dev/store.js +1 -1
- package/dist/unpkg/dev-deprecated/-private-BWBRzgZO.js.map +1 -1
- package/dist/unpkg/dev-deprecated/adapter/error.js +53 -0
- package/dist/unpkg/dev-deprecated/adapter/error.js.map +1 -1
- package/dist/unpkg/dev-deprecated/adapter/json-api.js +8 -1
- package/dist/unpkg/dev-deprecated/adapter/json-api.js.map +1 -1
- package/dist/unpkg/dev-deprecated/adapter/rest.js +20 -1
- package/dist/unpkg/dev-deprecated/adapter/rest.js.map +1 -1
- package/dist/unpkg/{dev/adapter-oLwyr47q.js → dev-deprecated/adapter-CLkSBRpr.js} +42 -1
- package/dist/unpkg/dev-deprecated/adapter-CLkSBRpr.js.map +1 -0
- package/dist/unpkg/dev-deprecated/adapter.js +1 -1
- package/dist/unpkg/dev-deprecated/compat/builders.js +10 -0
- package/dist/unpkg/dev-deprecated/compat/builders.js.map +1 -1
- package/dist/unpkg/dev-deprecated/compat/extensions.js +22 -0
- package/dist/unpkg/dev-deprecated/compat/extensions.js.map +1 -1
- package/dist/unpkg/dev-deprecated/compat/utils.js +18 -0
- package/dist/unpkg/dev-deprecated/compat/utils.js.map +1 -1
- package/dist/unpkg/dev-deprecated/{compat-BpJgmr75.js → compat-diBpt972.js} +57 -1
- package/dist/unpkg/dev-deprecated/compat-diBpt972.js.map +1 -0
- package/dist/unpkg/dev-deprecated/compat.js +1 -1
- package/dist/unpkg/dev-deprecated/{errors-__7EyX3m.js → errors-CLRhQKym.js} +3 -1
- package/dist/unpkg/dev-deprecated/errors-CLRhQKym.js.map +1 -0
- package/dist/unpkg/dev-deprecated/index.js +24 -5
- package/dist/unpkg/dev-deprecated/index.js.map +1 -1
- package/dist/unpkg/dev-deprecated/{json-DDJji3V3.js → json-CN-WCWwk.js} +8 -1
- package/dist/unpkg/dev-deprecated/json-CN-WCWwk.js.map +1 -0
- package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/model/migration-support.js +20 -2
- package/dist/unpkg/dev-deprecated/model/migration-support.js.map +1 -1
- package/dist/unpkg/dev-deprecated/{model-BYzXxf9f.js → model-DIvuaUiJ.js} +14 -3
- package/dist/unpkg/dev-deprecated/model-DIvuaUiJ.js.map +1 -0
- package/dist/{model-fragments-DSqu0ptR.js → unpkg/dev-deprecated/model-fragments-ZM4k_mT3.js} +23 -1
- package/dist/unpkg/dev-deprecated/model-fragments-ZM4k_mT3.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/{schema-provider-BM9FSxvx.js → schema-provider-DHS8XOdK.js} +9 -2
- package/dist/unpkg/dev-deprecated/schema-provider-DHS8XOdK.js.map +1 -0
- package/dist/unpkg/dev-deprecated/serializer/json-api.js +6 -1
- 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 +10 -1
- package/dist/unpkg/dev-deprecated/serializer/rest.js.map +1 -1
- package/dist/unpkg/dev-deprecated/serializer/transform.js +9 -0
- package/dist/unpkg/dev-deprecated/serializer/transform.js.map +1 -1
- package/dist/unpkg/dev-deprecated/serializer.js +40 -0
- package/dist/unpkg/dev-deprecated/serializer.js.map +1 -1
- package/dist/unpkg/dev-deprecated/{store-BCOLSC6z.js → store-D4taw4YF.js} +9 -1
- package/dist/unpkg/dev-deprecated/store-D4taw4YF.js.map +1 -0
- package/dist/unpkg/dev-deprecated/store.js +1 -1
- package/dist/unpkg/prod/-private-DG7eJX0Y.js.map +1 -1
- package/dist/unpkg/prod/adapter/error.js +53 -0
- package/dist/unpkg/prod/adapter/error.js.map +1 -1
- package/dist/unpkg/prod/adapter/json-api.js +8 -1
- package/dist/unpkg/prod/adapter/json-api.js.map +1 -1
- package/dist/unpkg/prod/adapter/rest.js +20 -1
- package/dist/unpkg/prod/adapter/rest.js.map +1 -1
- package/dist/unpkg/prod/{adapter-DQ9UA7FC.js → adapter-BCGjVOaE.js} +42 -1
- package/dist/unpkg/prod/adapter-BCGjVOaE.js.map +1 -0
- package/dist/unpkg/prod/adapter.js +1 -1
- package/dist/unpkg/prod/compat/builders.js +10 -0
- package/dist/unpkg/prod/compat/builders.js.map +1 -1
- package/dist/unpkg/prod/compat/extensions.js +22 -0
- package/dist/unpkg/prod/compat/extensions.js.map +1 -1
- package/dist/unpkg/prod/compat/utils.js +18 -0
- package/dist/unpkg/prod/compat/utils.js.map +1 -1
- package/dist/unpkg/prod/{compat-BM3u_d5-.js → compat-DFMtpQGs.js} +57 -1
- package/dist/unpkg/prod/compat-DFMtpQGs.js.map +1 -0
- package/dist/unpkg/prod/compat.js +1 -1
- package/dist/unpkg/prod/{errors-BhnSZApj.js → errors-CImmK4OM.js} +3 -1
- package/dist/unpkg/prod/errors-CImmK4OM.js.map +1 -0
- package/dist/unpkg/prod/index.js +24 -5
- package/dist/unpkg/prod/index.js.map +1 -1
- package/dist/unpkg/{prod-deprecated/json-BD1kRTfB.js → prod/json-CNq5Z0Xq.js} +8 -1
- package/dist/unpkg/prod/json-CNq5Z0Xq.js.map +1 -0
- package/dist/unpkg/prod/model/-private.js +1 -1
- package/dist/unpkg/prod/model/migration-support.js +20 -2
- package/dist/unpkg/prod/model/migration-support.js.map +1 -1
- package/dist/unpkg/prod/{model-CDyejvo3.js → model-_HpfLmtZ.js} +14 -3
- package/dist/unpkg/prod/model-_HpfLmtZ.js.map +1 -0
- package/dist/unpkg/prod/model-fragments-ZM4k_mT3.js +356 -0
- package/dist/unpkg/prod/model-fragments-ZM4k_mT3.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/{schema-provider-Co3gCBMj.js → schema-provider-DEe5vZ8b.js} +9 -2
- package/dist/unpkg/prod/schema-provider-DEe5vZ8b.js.map +1 -0
- package/dist/unpkg/prod/serializer/json-api.js +6 -1
- 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 +10 -1
- package/dist/unpkg/prod/serializer/rest.js.map +1 -1
- package/dist/unpkg/prod/serializer/transform.js +9 -0
- package/dist/unpkg/prod/serializer/transform.js.map +1 -1
- package/dist/unpkg/prod/serializer.js +40 -0
- package/dist/unpkg/prod/serializer.js.map +1 -1
- package/dist/unpkg/prod/{store-RGGc1ilN.js → store-ILh6zPA0.js} +9 -1
- package/dist/unpkg/prod/{store-RGGc1ilN.js.map → store-ILh6zPA0.js.map} +1 -1
- package/dist/unpkg/prod/store.js +1 -1
- package/dist/unpkg/prod-deprecated/-private-DG7eJX0Y.js.map +1 -1
- package/dist/unpkg/prod-deprecated/adapter/error.js +53 -0
- package/dist/unpkg/prod-deprecated/adapter/error.js.map +1 -1
- package/dist/unpkg/prod-deprecated/adapter/json-api.js +8 -1
- package/dist/unpkg/prod-deprecated/adapter/json-api.js.map +1 -1
- package/dist/unpkg/prod-deprecated/adapter/rest.js +20 -1
- package/dist/unpkg/prod-deprecated/adapter/rest.js.map +1 -1
- package/dist/unpkg/prod-deprecated/{adapter-DQ9UA7FC.js → adapter-BCGjVOaE.js} +42 -1
- package/dist/unpkg/prod-deprecated/adapter-BCGjVOaE.js.map +1 -0
- package/dist/unpkg/prod-deprecated/adapter.js +1 -1
- package/dist/unpkg/prod-deprecated/compat/builders.js +10 -0
- package/dist/unpkg/prod-deprecated/compat/builders.js.map +1 -1
- package/dist/unpkg/prod-deprecated/compat/extensions.js +22 -0
- package/dist/unpkg/prod-deprecated/compat/extensions.js.map +1 -1
- package/dist/unpkg/prod-deprecated/compat/utils.js +18 -0
- package/dist/unpkg/prod-deprecated/compat/utils.js.map +1 -1
- package/dist/unpkg/prod-deprecated/{compat-BM3u_d5-.js → compat-DFMtpQGs.js} +57 -1
- package/dist/unpkg/prod-deprecated/compat-DFMtpQGs.js.map +1 -0
- package/dist/unpkg/prod-deprecated/compat.js +1 -1
- package/dist/unpkg/prod-deprecated/{errors-BX8zhQS4.js → errors-DIOUcGAT.js} +3 -1
- package/dist/unpkg/prod-deprecated/errors-DIOUcGAT.js.map +1 -0
- package/dist/unpkg/prod-deprecated/index.js +24 -5
- package/dist/unpkg/prod-deprecated/index.js.map +1 -1
- package/dist/unpkg/{prod/json-BD1kRTfB.js → prod-deprecated/json-CNq5Z0Xq.js} +8 -1
- package/dist/unpkg/prod-deprecated/json-CNq5Z0Xq.js.map +1 -0
- package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/model/migration-support.js +20 -2
- package/dist/unpkg/prod-deprecated/model/migration-support.js.map +1 -1
- package/dist/unpkg/prod-deprecated/{model-fragments-DSqu0ptR.js → model-fragments-ZM4k_mT3.js} +23 -1
- package/dist/unpkg/prod-deprecated/model-fragments-ZM4k_mT3.js.map +1 -0
- package/dist/unpkg/prod-deprecated/model-fragments.js +1 -1
- package/dist/unpkg/prod-deprecated/{model-qeqVBN2l.js → model-wzHTp8Up.js} +14 -3
- package/dist/unpkg/prod-deprecated/model-wzHTp8Up.js.map +1 -0
- package/dist/unpkg/prod-deprecated/model.js +2 -2
- package/dist/unpkg/prod-deprecated/{schema-provider-CTLbab33.js → schema-provider-NWVqBEkW.js} +9 -2
- package/dist/unpkg/prod-deprecated/schema-provider-NWVqBEkW.js.map +1 -0
- package/dist/unpkg/prod-deprecated/serializer/json-api.js +6 -1
- 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 +10 -1
- package/dist/unpkg/prod-deprecated/serializer/rest.js.map +1 -1
- package/dist/unpkg/prod-deprecated/serializer/transform.js +9 -0
- package/dist/unpkg/prod-deprecated/serializer/transform.js.map +1 -1
- package/dist/unpkg/prod-deprecated/serializer.js +40 -0
- package/dist/unpkg/prod-deprecated/serializer.js.map +1 -1
- package/dist/unpkg/prod-deprecated/{store-0L2CkYzh.js → store-CB_rVlXv.js} +9 -1
- package/dist/unpkg/prod-deprecated/{store-0L2CkYzh.js.map → store-CB_rVlXv.js.map} +1 -1
- package/dist/unpkg/prod-deprecated/store.js +1 -1
- package/package.json +12 -9
- 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-DWgmYX8T.js.map +0 -1
- package/dist/error-CzkyXr1Q.d.ts.map +0 -1
- package/dist/errors-BlrR6--x.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-C9l1mRs6.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-waPfuoKq.js.map +0 -1
- package/dist/store-C4qYzXei.js.map +0 -1
- package/dist/unpkg/dev/adapter-oLwyr47q.js.map +0 -1
- package/dist/unpkg/dev/compat-BIv7BiG_.js.map +0 -1
- package/dist/unpkg/dev/errors-Dv8RCLdU.js.map +0 -1
- package/dist/unpkg/dev/json-DDJji3V3.js.map +0 -1
- package/dist/unpkg/dev/model-CRYi4C3z.js.map +0 -1
- package/dist/unpkg/dev/model-fragments-DSqu0ptR.js.map +0 -1
- package/dist/unpkg/dev/schema-provider-BYjTpV6C.js.map +0 -1
- package/dist/unpkg/dev/store-D_V8-HQl.js.map +0 -1
- package/dist/unpkg/dev-deprecated/adapter-oLwyr47q.js.map +0 -1
- package/dist/unpkg/dev-deprecated/compat-BpJgmr75.js.map +0 -1
- package/dist/unpkg/dev-deprecated/errors-__7EyX3m.js.map +0 -1
- package/dist/unpkg/dev-deprecated/json-DDJji3V3.js.map +0 -1
- package/dist/unpkg/dev-deprecated/model-BYzXxf9f.js.map +0 -1
- package/dist/unpkg/dev-deprecated/model-fragments-DSqu0ptR.js.map +0 -1
- package/dist/unpkg/dev-deprecated/schema-provider-BM9FSxvx.js.map +0 -1
- package/dist/unpkg/dev-deprecated/store-BCOLSC6z.js.map +0 -1
- package/dist/unpkg/prod/adapter-DQ9UA7FC.js.map +0 -1
- package/dist/unpkg/prod/compat-BM3u_d5-.js.map +0 -1
- package/dist/unpkg/prod/errors-BhnSZApj.js.map +0 -1
- package/dist/unpkg/prod/json-BD1kRTfB.js.map +0 -1
- package/dist/unpkg/prod/model-CDyejvo3.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/schema-provider-Co3gCBMj.js.map +0 -1
- package/dist/unpkg/prod-deprecated/adapter-DQ9UA7FC.js.map +0 -1
- package/dist/unpkg/prod-deprecated/compat-BM3u_d5-.js.map +0 -1
- package/dist/unpkg/prod-deprecated/errors-BX8zhQS4.js.map +0 -1
- package/dist/unpkg/prod-deprecated/json-BD1kRTfB.js.map +0 -1
- package/dist/unpkg/prod-deprecated/model-fragments-DSqu0ptR.js.map +0 -1
- package/dist/unpkg/prod-deprecated/model-qeqVBN2l.js.map +0 -1
- package/dist/unpkg/prod-deprecated/schema-provider-CTLbab33.js.map +0 -1
|
@@ -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;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,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;EAC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ExB,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"}
|
|
@@ -3,6 +3,11 @@ import { addObserver, removeObserver } from "@ember/object/observers";
|
|
|
3
3
|
import { compare } from "@ember/utils";
|
|
4
4
|
|
|
5
5
|
//#region 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,14 +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
288
|
//#endregion
|
|
267
289
|
export { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension };
|
|
@@ -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,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;CAEAsF,QAAsBtF,KAAawD,OAAsB;EACtD,KAAmDjE,SAASgG,SAASvG,IAAIuG,MAAMvF,KAAKwD,KAAK,CAAC;CAC7F;CAEAgC,OAAwB;EACtB,OAAOC,MAAMC,KAAK,IAAIC,IAAI,IAAI,CAAC;CACjC;CAEAC,OAAqB5F,KAAkB;EACrC,MAAM6F,uBAAO,IAAIF,IAAI;EACrB,MAAMG,SAAc,CAAA;EACpB,KAAKvG,SAASgG,SAAS;GACrB,MAAM/B,QAAQ3E,IAAI0G,MAAMvF,GAAG;GAC3B,IAAI6F,KAAKE,IAAIvC,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;GAC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G,SAASvG,IAAIuG,MAAMvF,KAAKwD,KAAK,CAAC;CAC7F;CAEAgC,OAAwB;EACtB,OAAOC,MAAMC,KAAK,IAAIC,IAAI,IAAI,CAAC;CACjC;CAEAC,OAAqB5F,KAAkB;EACrC,MAAM6F,uBAAO,IAAIF,IAAI;EACrB,MAAMG,SAAc,CAAA;EACpB,KAAKvG,SAASgG,SAAS;GACrB,MAAM/B,QAAQ3E,IAAI0G,MAAMvF,GAAG;GAC3B,IAAI6F,KAAKE,IAAIvC,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;;;;;;;;;AAUA,MAAaE,0BAA8D;CACzEpG,MAAM;CACNC,MAAM;CACNC,UAAUE;AACZ"}
|
|
@@ -5,6 +5,8 @@ import { dasherize, singularize } from "@warp-drive/utilities/string";
|
|
|
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
|
|
@@ -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,SAAg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6CAA6CyB,WAAW,IAAI;CACrEzB,SAAS,kDAAkDyB,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 !==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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"}
|
|
@@ -132,6 +132,9 @@ const PotentialLegacyOperations = /* @__PURE__ */ new Set([
|
|
|
132
132
|
* `deleteRecord` requests using the store's configured {@link MinimumAdapterInterface | adapter}
|
|
133
133
|
* and {@link MinimumSerializerInterface | serializer}, passing any other
|
|
134
134
|
* request through to the next handler unchanged.
|
|
135
|
+
*
|
|
136
|
+
* @summary Legacy `RequestManager` handler that fulfills find, query, create, update, and delete operations through
|
|
137
|
+
* the store's adapters and serializers, passing other requests along.
|
|
135
138
|
*/
|
|
136
139
|
const LegacyNetworkHandler = { request(context, next) {
|
|
137
140
|
if (context.request.url || !context.request.op || !PotentialLegacyOperations.has(context.request.op)) return next(context.request);
|
|
@@ -347,14 +350,55 @@ function queryRecord(context) {
|
|
|
347
350
|
//#endregion
|
|
348
351
|
//#region src/compat.ts
|
|
349
352
|
/**
|
|
353
|
+
* Helps an app migrate incrementally from legacy EmberData patterns to modern ***Warp*Drive**.
|
|
354
|
+
*
|
|
355
|
+
* ## Why it exists
|
|
356
|
+
*
|
|
357
|
+
* While migrating, you may need to:
|
|
358
|
+
*
|
|
359
|
+
* - keep Adapters and Serializers working on a Store whose requests go through the
|
|
360
|
+
* {@link RequestManager}
|
|
361
|
+
* - keep the deprecated request methods such as `store.findRecord` and `store.query`, which
|
|
362
|
+
* Adapters fulfill, working while you move calls to `store.request`
|
|
363
|
+
* - adopt modern patterns one piece at a time rather than all at once
|
|
364
|
+
*
|
|
365
|
+
* ## What it provides
|
|
366
|
+
*
|
|
367
|
+
* - {@link LegacyNetworkHandler}, a request handler that fulfills those legacy requests through
|
|
368
|
+
* the store's Adapters and Serializers and passes every other request along
|
|
369
|
+
* - {@link adapterFor}, {@link serializerFor}, {@link normalize}, {@link pushPayload} and
|
|
370
|
+
* {@link serializeRecord}, the store methods for working with Adapters and Serializers, and
|
|
371
|
+
* {@link LegacyStoreCompat}, the Store type that includes them
|
|
372
|
+
*
|
|
373
|
+
* The Store that [useLegacyStore](/api/@warp-drive/legacy/functions/useLegacyStore) produces
|
|
374
|
+
* adds `LegacyNetworkHandler` to its RequestManager unless `linksMode` is `true`. The hooks
|
|
375
|
+
* that present `Model` instances live in [@warp-drive/legacy/model](/api/@warp-drive/legacy/model/),
|
|
376
|
+
* not here.
|
|
377
|
+
*
|
|
378
|
+
* ## When to use it
|
|
379
|
+
*
|
|
380
|
+
* Only during a migration from legacy EmberData to modern ***Warp*Drive**. It lets you adopt
|
|
381
|
+
* modern patterns incrementally while your existing Adapters and Serializers keep working. For
|
|
382
|
+
* incremental migration strategies, see the [Migration Guide](/upgrading/v5/) and the
|
|
383
|
+
* [Two Store Migration Strategy](/upgrading/v5/two-store-migration).
|
|
384
|
+
*
|
|
385
|
+
* @module
|
|
386
|
+
* @summary Legacy store support for adapters and serializers: the `LegacyNetworkHandler` plus store methods such as
|
|
387
|
+
* `adapterFor`, `serializerFor`, `normalize` and `pushPayload`.
|
|
388
|
+
*/
|
|
389
|
+
/**
|
|
350
390
|
* Extends the signature of {@link Store} with additional
|
|
351
391
|
* methods available when using the legacy network layer.
|
|
352
392
|
*
|
|
393
|
+
* @summary Legacy `Store` type extended with `adapterFor`, `serializerFor`, `normalize`, `pushPayload`, and
|
|
394
|
+
* `serializeRecord` from the adapter and serializer network layer.
|
|
353
395
|
* @public
|
|
354
396
|
* @noInheritDoc
|
|
355
397
|
* @legacy
|
|
356
398
|
*/
|
|
357
399
|
/**
|
|
400
|
+
* @summary Deprecated alias of `LegacyStoreCompat`, the `Store` type extended with legacy adapter and serializer
|
|
401
|
+
* methods.
|
|
358
402
|
* @deprecated - use {@link LegacyStoreCompat} instead
|
|
359
403
|
*/
|
|
360
404
|
/**
|
|
@@ -366,6 +410,8 @@ If no `person` adapter is found, this method will look
|
|
|
366
410
|
for an `application` adapter (the default adapter for
|
|
367
411
|
your entire application).
|
|
368
412
|
|
|
413
|
+
@summary Legacy store method that returns the cached adapter for a model type, falling back to the `application`
|
|
414
|
+
adapter.
|
|
369
415
|
@public
|
|
370
416
|
@param modelName
|
|
371
417
|
*/
|
|
@@ -401,6 +447,8 @@ your entire application).
|
|
|
401
447
|
If a serializer cannot be found on the adapter, it will fall back
|
|
402
448
|
to an instance of `JSONSerializer`.
|
|
403
449
|
|
|
450
|
+
@summary Legacy store method that returns the cached serializer for a model type, falling back to the
|
|
451
|
+
`application` serializer, or `null` if neither exists.
|
|
404
452
|
@public
|
|
405
453
|
@param modelName the record to serialize
|
|
406
454
|
*/
|
|
@@ -444,6 +492,8 @@ store.push(store.normalize(modelName, data));
|
|
|
444
492
|
});
|
|
445
493
|
```
|
|
446
494
|
|
|
495
|
+
@summary Legacy store method that converts a raw payload into the normalized document `store.push` expects, using
|
|
496
|
+
the serializer for the given model type.
|
|
447
497
|
@legacy
|
|
448
498
|
@public
|
|
449
499
|
@param modelName The name of the model type for this payload
|
|
@@ -507,6 +557,8 @@ store.pushPayload(pushData); // Will use the application serializer
|
|
|
507
557
|
store.pushPayload('post', pushData); // Will use the post serializer
|
|
508
558
|
```
|
|
509
559
|
|
|
560
|
+
@summary Legacy store method that pushes a raw payload into the store after the application serializer, or the
|
|
561
|
+
given model type's serializer, normalizes it.
|
|
510
562
|
@public
|
|
511
563
|
@param modelName Optionally, a model type used to determine which serializer will be used
|
|
512
564
|
@param inputPayload
|
|
@@ -520,6 +572,8 @@ function pushPayload(modelName, inputPayload) {
|
|
|
520
572
|
/**
|
|
521
573
|
* Serializes a record using the store's legacy network layer, as with
|
|
522
574
|
* {@link LegacyStoreCompat.serializeRecord | store.serializeRecord}.
|
|
575
|
+
*
|
|
576
|
+
* @summary Legacy store method that serializes a record into a payload using its model type's serializer.
|
|
523
577
|
*/
|
|
524
578
|
function serializeRecord(record, options) {
|
|
525
579
|
/* @__PURE__ */ upgradeStore(this);
|
|
@@ -529,6 +583,8 @@ function serializeRecord(record, options) {
|
|
|
529
583
|
/**
|
|
530
584
|
* Destroys any adapters/serializers the legacy network layer has created
|
|
531
585
|
* for this store, invoked when the store itself is destroyed.
|
|
586
|
+
*
|
|
587
|
+
* @summary Legacy store teardown hook that destroys every adapter and serializer instance the store has cached.
|
|
532
588
|
*/
|
|
533
589
|
function cleanup() {
|
|
534
590
|
/* @__PURE__ */ upgradeStore(this);
|
|
@@ -544,4 +600,4 @@ function cleanup() {
|
|
|
544
600
|
|
|
545
601
|
//#endregion
|
|
546
602
|
export { serializeRecord as a, pushPayload as i, cleanup as n, serializerFor as o, normalize as r, LegacyNetworkHandler as s, adapterFor as t };
|
|
547
|
-
//# sourceMappingURL=compat-
|
|
603
|
+
//# sourceMappingURL=compat-DFMtpQGs.js.map
|