@warp-drive/legacy 5.10.0-alpha.12 → 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 +7 -0
- 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 +4 -2
- package/dist/adapter/json-api.d.ts.map +1 -1
- package/dist/adapter/json-api.js +7 -0
- 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 +23 -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 +7 -0
- 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 +23 -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 +7 -0
- 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 +23 -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 +7 -0
- 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 +23 -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 +7 -0
- 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 +23 -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 +9 -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":"migration-support.js","names":["recordIdentifierFor","Context","notifyInternalSignal","assertPrivateStore","getOrSetGlobal","Type","Errors","lookupLegacySupport","_destroyRecord","_reload","_save","belongsTo","changedAttributes","createSnapshot","deleteRecord","destroyRecord","hasMany","reload","rollbackAttributes","save","serialize","unloadRecord","RecordState","buildSchema","LegacyFields","LegacySupport","WeakMap","legacySupport","record","options","prop","state","get","set","suppressDeprecation","Boolean","currentState","adapterError","_constructor","isModel","name","type","modelName","recordState","dirtyType","errors","create","__record","isDirty","isDeleted","isEmpty","isError","isLoaded","isLoading","isNew","isSaving","isValid","test","Error","withDefaults","schema","legacy","identity","kind","forEach","field","fields","push","defaultValue","objectExtensions","withRestoredDeprecatedModelRequestBehaviors","registerDerivations","registerDerivation","_registerMode","store","cacheKey","getBelongsTo","value","_join","setDirtyBelongsTo","getHasMany","support","manyArray","getManyArray","splice","length","notify","_manyArrayCache","hasPromise","_relationshipPromisesCache","signal","CAUTION_MEGA_DANGER_ZONE_registerExtension","features","isReloading","console","warn","_isReloading","v","DelegatingSchemaService","_preferred","_secondary","constructor","isDelegated","resource","hasResource","resourceTypes","Array","from","Set","concat","hasTrait","resourceHasTrait","trait","cacheFields","transformation","hashFn","derivation","registerResources","schemas","registerResource","registerTransformation","transform","registerHashFn","CAUTION_MEGA_DANGER_ZONE_hasExtension","ext","extension","CAUTION_MEGA_DANGER_ZONE_resourceExtensions","CAUTION_MEGA_DANGER_ZONE_objectExtensions","resolvedType","CAUTION_MEGA_DANGER_ZONE_arrayExtensions","mode","kinds","_kind","assertPrivate","service","prototype","attributesDefinitionFor","relationshipsDefinitionFor","doesTypeExist"],"sources":["../../../../src/model/migration-support.ts"],"sourcesContent":["/**\n * This module provides support for migrating away from @warp-drive/legacy/model\n * to ReactiveResource from @warp-drive/core/reactive.\n *\n * It includes:\n *\n * - A `withDefaults` function to assist in creating a schema in LegacyMode\n * - A `registerDerivations` function to register the derivations necessary to support LegacyMode\n * - A `DelegatingSchemaService` that can be used to provide a schema service that works with both\n * @warp-drive/legacy/model and @warp-drive/core/reactive simultaneously for migration purposes.\n * - A `WithLegacy` type util that can be used to create a type that includes the legacy\n * properties and methods of a record.\n *\n * Using LegacyMode features on a ReactiveResource *requires* the use of these derivations and schema\n * additions. LegacyMode is not intended to be a long-term solution, but rather a stepping stone\n * to assist in more rapidly adopting modern WarpDrive features.\n *\n * @module\n */\nimport { deprecate } from '@ember/debug';\n\nimport type { Store } from '@warp-drive/core';\nimport { recordIdentifierFor } from '@warp-drive/core';\nimport { ENABLE_LEGACY_SCHEMA_SERVICE } from '@warp-drive/core/build-config/deprecations';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from '@warp-drive/core/reactive';\nimport type { ExtensibleField } from '@warp-drive/core/reactive/-private';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport { notifyInternalSignal } from '@warp-drive/core/signals/-leaked';\nimport type { PrivateReactiveResourceArray } from '@warp-drive/core/store/-private';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { SchemaService } from '@warp-drive/core/types';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { ChangedAttributesHash } from '@warp-drive/core/types/cache';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { ObjectValue } from '@warp-drive/core/types/json/raw';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { Derivation, HashFn, Transformation } from '@warp-drive/core/types/schema/concepts';\nimport type {\n ArrayField,\n CacheableFieldSchema,\n DerivedField,\n FieldSchema,\n GenericField,\n HashField,\n IdentityField,\n LegacyBelongsToField,\n LegacyHasManyField,\n LegacyResourceSchema,\n ObjectField,\n ObjectSchema,\n ResourceSchema,\n} from '@warp-drive/core/types/schema/fields';\nimport { Type } from '@warp-drive/core/types/symbols';\nimport type { WithPartial } from '@warp-drive/core/types/utils';\n\nimport type { Snapshot } from '../compat/-private.ts';\nimport { Errors, lookupLegacySupport } from './-private.ts';\nimport type { MinimalLegacyRecord } from './-private/model-methods.ts';\nimport {\n _destroyRecord,\n _reload,\n _save,\n belongsTo,\n changedAttributes,\n createSnapshot,\n deleteRecord,\n destroyRecord,\n hasMany,\n reload,\n rollbackAttributes,\n save,\n serialize,\n unloadRecord,\n} from './-private/model-methods.ts';\nimport RecordState from './-private/record-state.ts';\nimport type BelongsToReference from './-private/references/belongs-to.ts';\nimport type HasManyReference from './-private/references/has-many.ts';\nimport { buildSchema } from './-private/schema-provider.ts';\nimport type { _MaybeBelongsToFields, MaybeHasManyFields } from './-private/type-utils.ts';\n\n/**\n * Adds the `Model`-style `belongsTo`/`hasMany` reference methods to a\n * {@link TypedRecordInstance}, for use when migrating a resource from\n * `Model` to a schema-based record while preserving these APIs.\n */\nexport type WithLegacyDerivations<T extends TypedRecordInstance> = T &\n MinimalLegacyRecord & {\n /**\n * see {@link belongsTo}\n */\n belongsTo: typeof belongsTo;\n /**\n * see {@link hasMany}\n */\n hasMany: typeof hasMany;\n };\n\ntype AttributesSchema = ReturnType<Exclude<SchemaService['attributesDefinitionFor'], undefined>>;\ntype RelationshipsSchema = ReturnType<Exclude<SchemaService['relationshipsDefinitionFor'], undefined>>;\n\ninterface LegacyModeRecord<T extends TypedRecordInstance> {\n id: string | null;\n\n serialize(options?: Record<string, unknown>): unknown;\n destroyRecord(options?: Record<string, unknown>): Promise<this>;\n unloadRecord(): void;\n changedAttributes(): ChangedAttributesHash;\n rollbackAttributes(): void;\n _createSnapshot(): Snapshot<T>;\n save(options?: Record<string, unknown>): Promise<this>;\n reload(options?: Record<string, unknown>): Promise<T>;\n belongsTo<K extends _MaybeBelongsToFields<T>>(prop: K): BelongsToReference<T, K>;\n hasMany<K extends MaybeHasManyFields<T>>(prop: K): HasManyReference<T, K>;\n deleteRecord(): void;\n\n adapterError: unknown;\n constructor: { modelName: TypeFromInstance<T> };\n currentState: RecordState;\n dirtyType: 'deleted' | 'created' | 'updated' | '';\n errors: unknown;\n hasDirtyAttributes: boolean;\n isDeleted: boolean;\n isEmpty: boolean;\n isError: boolean;\n isLoaded: boolean;\n isLoading: boolean;\n isDestroying: boolean;\n isDestroyed: boolean;\n isNew: boolean;\n isSaving: boolean;\n isValid: boolean;\n}\n\n// 'isDestroying', 'isDestroyed'\nconst LegacyFields = [\n '_createSnapshot',\n 'adapterError',\n 'belongsTo',\n 'changedAttributes',\n 'constructor',\n 'currentState',\n 'deleteRecord',\n 'destroyRecord',\n 'dirtyType',\n 'errors',\n 'hasDirtyAttributes',\n 'hasMany',\n 'isDeleted',\n 'isEmpty',\n 'isError',\n 'isLoaded',\n 'isLoading',\n 'isNew',\n 'isSaving',\n 'isValid',\n 'reload',\n 'rollbackAttributes',\n 'save',\n 'serialize',\n 'unloadRecord',\n] as const;\n\n/**\n * A Type utility that enables quickly adding type information for the fields\n * defined by `import { withDefaults } from '@warp-drive/legacy/model/migration-support'`.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';\n * import { Type } from '@warp-drive/core/types/symbols';\n * import type { HasMany } from '@@warp-drive/legacy/model';\n *\n * export const UserSchema = withDefaults({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * { name: 'age', kind: 'attribute' },\n * { name: 'friends',\n * kind: 'hasMany',\n * type: 'user',\n * options: { inverse: 'friends', async: false }\n * },\n * { name: 'bestFriend',\n * kind: 'belongsTo',\n * type: 'user',\n * options: { inverse: null, async: false }\n * },\n * ],\n * });\n *\n * export type User = WithLegacy<{\n * firstName: string;\n * lastName: string;\n * age: number;\n * friends: HasMany<User>;\n * bestFriend: User | null;\n * [Type]: 'user';\n * }>\n * ```\n *\n */\nexport type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;\n\nconst LegacySupport = getOrSetGlobal('LegacySupport', new WeakMap<MinimalLegacyRecord, Record<string, unknown>>());\n\nfunction legacySupport(record: MinimalLegacyRecord, options: ObjectValue | null, prop: string): unknown {\n let state = LegacySupport.get(record);\n if (!state) {\n state = {};\n LegacySupport.set(record, state);\n }\n const suppressDeprecation = Boolean(options && options.suppressDeprecation);\n\n switch (prop) {\n case '_createSnapshot':\n // FIXME should be deprecated too?\n return createSnapshot;\n case 'adapterError':\n // FIXME should be deprecated too?\n return record.currentState.adapterError;\n case 'belongsTo':\n return belongsTo;\n case 'changedAttributes':\n return changedAttributes;\n case 'constructor':\n return (state._constructor = state._constructor || {\n isModel: true,\n name: `Record<${recordIdentifierFor(record).type}>`,\n modelName: recordIdentifierFor(record).type,\n });\n case 'currentState':\n return (state.recordState = state.recordState || new RecordState(record));\n case 'deleteRecord':\n return deleteRecord;\n case 'destroyRecord':\n return suppressDeprecation ? _destroyRecord : destroyRecord;\n case 'dirtyType':\n return record.currentState.dirtyType;\n case 'errors':\n // FIXME should be deprecated too?\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n return (state.errors = state.errors || Errors.create({ __record: record }));\n case 'hasDirtyAttributes':\n return record.currentState.isDirty;\n case 'hasMany':\n return hasMany;\n case 'isDeleted':\n return record.currentState.isDeleted;\n case 'isEmpty':\n return record.currentState.isEmpty;\n case 'isError':\n return record.currentState.isError;\n case 'isLoaded':\n return record.currentState.isLoaded;\n case 'isLoading':\n return record.currentState.isLoading;\n case 'isNew':\n return record.currentState.isNew;\n case 'isSaving':\n return record.currentState.isSaving;\n case 'isValid':\n return record.currentState.isValid;\n case 'reload':\n return suppressDeprecation ? _reload : reload;\n case 'rollbackAttributes':\n return rollbackAttributes;\n case 'save':\n return suppressDeprecation ? _save : save;\n case 'serialize':\n // FIXME should be deprecated too? (is somewhat deprecated via store.serializeRecord)\n return serialize;\n case 'unloadRecord':\n return unloadRecord;\n default:\n assert(`${prop} is not a supported legacy field`, false);\n }\n}\nlegacySupport[Type] = '@legacy';\n\n/**\n * A function which adds the necessary fields to a schema and marks it as\n * being in LegacyMode. This is used to support the legacy features of\n * @warp-drive/legacy/model while migrating to WarpDrive.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';\n * import { Type } from '@warp-drive/core/types/symbols';\n * import type { HasMany } from '@warp-drive/legacy/model';\n *\n * export const UserSchema = withDefaults({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * { name: 'age', kind: 'attribute' },\n * { name: 'friends',\n * kind: 'hasMany',\n * type: 'user',\n * options: { inverse: 'friends', async: false }\n * },\n * { name: 'bestFriend',\n * kind: 'belongsTo',\n * type: 'user',\n * options: { inverse: null, async: false }\n * },\n * ],\n * });\n *\n * export type User = WithLegacy<{\n * firstName: string;\n * lastName: string;\n * age: number;\n * friends: HasMany<User>;\n * bestFriend: User | null;\n * [Type]: 'user';\n * }>\n * ```\n *\n * Using this function require registering the derivations\n * it requires with the schema service.\n *\n * ```ts\n * import { registerDerivations } from '@warp-drive/legacy/model/migration-support';\n *\n * registerDerivations(schema);\n * ```\n *\n * @param schema The schema to add legacy support to.\n * @return The schema with legacy support added.\n * @public\n */\nexport function withDefaults(schema: WithPartial<LegacyResourceSchema, 'legacy' | 'identity'>): LegacyResourceSchema {\n schema.legacy = true;\n schema.identity = { kind: '@id', name: 'id' };\n\n LegacyFields.forEach((field) => {\n schema.fields.push({\n type: '@legacy',\n name: field,\n kind: 'derived',\n });\n });\n schema.fields.push({\n name: '_isReloading',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroying',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroyed',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.objectExtensions = schema.objectExtensions || [];\n schema.objectExtensions.push('deprecated-model-behaviors');\n return schema as LegacyResourceSchema;\n}\n\n/**\n * Adds the necessasary fields to the schema for supporting\n * the deprecated request methods on LegacyMode schemas.\n *\n * Use this instead of `withDefaults` to add the fields\n * and behaviors necessary to support Model-Like capabilities.\n *\n * ```ts\n * import { withRestoredDeprecatedModelRequestBehaviors } from '@warp-drive/legacy/model/migration-support';\n *\n * export const UserSchema = withRestoredDeprecatedModelRequestBehaviors({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * ]\n * });\n * ```\n */\nexport function withRestoredDeprecatedModelRequestBehaviors(\n schema: WithPartial<LegacyResourceSchema, 'legacy' | 'identity'>\n): LegacyResourceSchema {\n schema.legacy = true;\n schema.identity = { kind: '@id', name: 'id' };\n\n LegacyFields.forEach((field) => {\n schema.fields.push({\n type: '@legacy',\n name: field,\n kind: 'derived',\n options: { suppressDeprecation: true },\n });\n });\n schema.fields.push({\n name: 'isReloading',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroying',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroyed',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n return schema as LegacyResourceSchema;\n}\n\n/**\n * A function which registers the necessary derivations to support\n * the LegacyMode features of @warp-drive/legacy/model while migrating to WarpDrive.\n *\n * This must be called in order to use the fields added by {@link withDefaults} or\n * {@link withRestoredDeprecatedModelRequestBehaviors}.\n *\n * @param schema The schema service to register the derivations with.\n * @public\n */\nexport function registerDerivations(schema: SchemaService): void {\n schema.registerDerivation(legacySupport);\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n schema._registerMode('@legacy', {\n belongsTo: {\n get(store: Store, record: object, cacheKey: ResourceKey, field: LegacyBelongsToField) {\n // FIXME field.name here should likely be field.sourceKey || field.name\n return lookupLegacySupport(record as unknown as MinimalLegacyRecord).getBelongsTo(field.name);\n },\n set(store: Store, record: object, cacheKey: ResourceKey, field: LegacyBelongsToField, value: unknown) {\n assertPrivateStore(store);\n store._join(() => {\n // FIXME field.name here should likely be field.sourceKey || field.name\n lookupLegacySupport(record as unknown as MinimalLegacyRecord).setDirtyBelongsTo(field.name, value);\n });\n },\n },\n hasMany: {\n get(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField) {\n // FIXME field.name here should likely be field.sourceKey || field.name\n return lookupLegacySupport(record as unknown as MinimalLegacyRecord).getHasMany(field.name);\n },\n set(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField, value: unknown[]) {\n assertPrivateStore(store);\n store._join(() => {\n const support = lookupLegacySupport(record as unknown as MinimalLegacyRecord);\n // FIXME field.name here should likely be field.sourceKey || field.name\n const manyArray = support.getManyArray(field.name);\n\n manyArray.splice(0, manyArray.length, ...value);\n });\n },\n notify(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField): boolean {\n const support = lookupLegacySupport(record as unknown as MinimalLegacyRecord);\n // FIXME field.name here should likely be field.sourceKey || field.name\n const manyArray = support && support._manyArrayCache[field.name];\n const hasPromise = support && (support._relationshipPromisesCache[field.name] as Promise<unknown> | undefined);\n\n if (manyArray && hasPromise) {\n // do nothing, we will notify the ManyArray directly\n // once the fetch has completed.\n return false;\n }\n\n if (manyArray) {\n notifyInternalSignal((manyArray as unknown as PrivateReactiveResourceArray)[Context].signal);\n\n return true;\n }\n\n return false;\n },\n },\n });\n\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension!({\n name: 'deprecated-model-behaviors',\n kind: 'object',\n features: {\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n get isReloading() {\n deprecate(\n `record.isReloading is deprecated, please use store.request and either <Request> or getRequuestState to keep track of the request state instead.`,\n false,\n {\n id: 'warp-drive:deprecate-legacy-request-methods',\n until: '6.0',\n for: '@warp-drive/core',\n url: 'https://docs.warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',\n since: {\n enabled: '5.7',\n available: '5.7',\n },\n }\n );\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-return\n return this._isReloading;\n },\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n set isReloading(v) {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n this._isReloading = v;\n },\n },\n });\n}\n\n/**\n * A class which provides a schema service that delegates between\n * a primary schema service and one that supports legacy model\n * classes as its schema source.\n *\n * When the primary schema service has a schema for the given\n * resource, it will be used. Otherwise, the fallback schema\n * service will be used.\n *\n * This can be used when incrementally migrating from Models to\n * ReactiveResources by enabling unmigrated Models to continue to\n * provide their own schema information to the application.\n *\n * ```ts\n * import { DelegatingSchemaService } from '@warp-drive/legacy/model/migration-support';\n * import { SchemaService } from '@warp-drive/core/reactive';\n *\n * class AppStore extends Store {\n * createSchemaService() {\n * const schema = new SchemaService();\n * return new DelegatingSchemaService(this, schema);\n * }\n * }\n * ```\n *\n * All calls to register resources, derivations, transformations, hash functions\n * etc. will be delegated to the primary schema service.\n *\n * @class DelegatingSchemaService\n * @public\n */\nexport interface DelegatingSchemaService {\n /**\n * Delegates to whichever of the primary/fallback schema services has a\n * schema for the resource, preferring the primary. See {@link DelegatingSchemaService.isDelegated | isDelegated}.\n */\n attributesDefinitionFor?(resource: ResourceKey | { type: string }): AttributesSchema;\n /**\n * Delegates to whichever of the primary/fallback schema services has a\n * schema for the resource, preferring the primary. See {@link DelegatingSchemaService.isDelegated | isDelegated}.\n */\n relationshipsDefinitionFor?(resource: ResourceKey | { type: string }): RelationshipsSchema;\n /**\n * Whether either the primary or fallback schema service has a schema\n * for the given type.\n */\n doesTypeExist?(type: string): boolean;\n}\n/**\n * See the {@link DelegatingSchemaService | class documentation above} for usage.\n */\nexport class DelegatingSchemaService implements SchemaService {\n /** @internal */\n _preferred!: SchemaService;\n /** @internal */\n _secondary!: SchemaService;\n\n constructor(store: Store, schema: SchemaService) {\n this._preferred = schema;\n this._secondary = buildSchema(store);\n }\n\n /**\n * Whether the given resource's schema is being served by the fallback\n * (legacy Model-derived) schema service rather than the primary one.\n */\n isDelegated(resource: ResourceKey | { type: string }): boolean {\n return !this._preferred.hasResource(resource) && this._secondary.hasResource(resource);\n }\n\n resourceTypes(): Readonly<string[]> {\n return Array.from(new Set(this._preferred.resourceTypes().concat(this._secondary.resourceTypes())));\n }\n\n hasResource(resource: ResourceKey | { type: string }): boolean {\n return this._preferred.hasResource(resource) || this._secondary.hasResource(resource);\n }\n hasTrait(type: string): boolean {\n if (this._preferred.hasResource({ type })) {\n return this._preferred.hasTrait(type);\n }\n return this._secondary.hasTrait(type);\n }\n resourceHasTrait(resource: ResourceKey | { type: string }, trait: string): boolean {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.resourceHasTrait(resource, trait);\n }\n return this._secondary.resourceHasTrait(resource, trait);\n }\n fields(resource: ResourceKey | { type: string }): Map<string, FieldSchema> {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.fields(resource);\n }\n return this._secondary.fields(resource);\n }\n cacheFields?(resource: { type: string }): Map<string, Exclude<CacheableFieldSchema, IdentityField>> {\n if (this._preferred.hasResource?.(resource)) {\n // @ts-expect-error\n return this._preferred.cacheFields?.(resource);\n }\n\n // @ts-expect-error\n return this._secondary.cacheFields?.(resource);\n }\n transformation(field: GenericField | ObjectField | ArrayField | { type: string }): Transformation {\n return this._preferred.transformation(field);\n }\n hashFn(field: HashField | { type: string }): HashFn {\n return this._preferred.hashFn(field);\n }\n derivation(field: DerivedField | { type: string }): Derivation {\n return this._preferred.derivation(field);\n }\n resource(resource: ResourceKey | { type: string }): ResourceSchema | ObjectSchema {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.resource(resource);\n }\n return this._secondary.resource(resource);\n }\n registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void {\n this._preferred.registerResources(schemas);\n }\n registerResource(schema: ResourceSchema | ObjectSchema): void {\n this._preferred.registerResource(schema);\n }\n registerTransformation(transform: Transformation): void {\n this._preferred.registerTransformation(transform);\n }\n registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void {\n this._preferred.registerDerivation(derivation);\n }\n registerHashFn(hashFn: HashFn): void {\n this._preferred.registerHashFn(hashFn);\n }\n\n CAUTION_MEGA_DANGER_ZONE_hasExtension(ext: { kind: 'object' | 'array'; name: string }): boolean {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_hasExtension!(ext);\n }\n\n CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void {\n this._preferred.CAUTION_MEGA_DANGER_ZONE_registerExtension!(extension);\n }\n\n CAUTION_MEGA_DANGER_ZONE_resourceExtensions(\n resource: ResourceKey | { type: string }\n ): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_resourceExtensions!(resource);\n }\n\n CAUTION_MEGA_DANGER_ZONE_objectExtensions(\n field: ExtensibleField,\n resolvedType: string | null\n ): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_objectExtensions!(field, resolvedType);\n }\n\n CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_arrayExtensions!(field);\n }\n\n /**\n * This is an internal method used to register behaviors for legacy mode.\n * It is not intended for public use.\n *\n * We do think a generalized `kind` registration system would be useful,\n * but we have not yet designed it.\n *\n * See https://github.com/warp-drive-data/warp-drive/issues/9534\n *\n * @internal\n */\n _registerMode(mode: string, kinds: unknown): void {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n this._preferred._registerMode(mode, kinds);\n }\n\n /**\n * This is an internal method used to enable legacy behaviors for legacy mode.\n * It is not intended for public use.\n *\n * We do think a generalized `kind` registration system would be useful,\n * but we have not yet designed it.\n *\n * See https://github.com/warp-drive-data/warp-drive/issues/9534\n *\n * @internal\n */\n _kind(mode: string, kind: 'belongsTo' | 'hasMany'): () => unknown {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n return this._preferred._kind(mode, kind) as () => unknown;\n }\n}\n\n/**\n * @internal\n */\nexport interface PrivateDelegatingSchemaService extends DelegatingSchemaService {\n _preferred: SchemaService;\n _secondary: SchemaService;\n}\nfunction assertPrivate(service: DelegatingSchemaService): asserts service is PrivateDelegatingSchemaService {}\n\nif (ENABLE_LEGACY_SCHEMA_SERVICE) {\n DelegatingSchemaService.prototype.attributesDefinitionFor = function (resource: ResourceKey | { type: string }) {\n assertPrivate(this);\n if (this._preferred.hasResource(resource)) {\n return this._preferred.attributesDefinitionFor!(resource);\n }\n\n return this._secondary.attributesDefinitionFor!(resource);\n };\n DelegatingSchemaService.prototype.relationshipsDefinitionFor = function (resource: ResourceKey | { type: string }) {\n assertPrivate(this);\n if (this._preferred.hasResource(resource)) {\n return this._preferred.relationshipsDefinitionFor!(resource);\n }\n\n return this._secondary.relationshipsDefinitionFor!(resource);\n };\n DelegatingSchemaService.prototype.doesTypeExist = function (type: string) {\n assertPrivate(this);\n return this._preferred.doesTypeExist?.(type) || this._secondary.doesTypeExist?.(type) || false;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuIA,MAAMwB,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8ChB,MAAMC,gBAAgBrB,eAAe,iCAAiB,IAAIsB,QAAsD,CAAC;AAEjH,SAASC,cAAcC,QAA6BC,SAA6BC,MAAuB;CACtG,IAAIC,QAAQN,cAAcO,IAAIJ,MAAM;CACpC,IAAI,CAACG,OAAO;EACVA,QAAQ,CAAC;EACTN,cAAcQ,IAAIL,QAAQG,KAAK;CACjC;CACA,MAAMG,sBAAsBC,QAAQN,WAAWA,QAAQK,mBAAmB;CAE1E,QAAQJ,MAAR;EACE,KAAK,mBAEH,OAAOjB;EACT,KAAK,gBAEH,OAAOe,OAAOQ,aAAaC;EAC7B,KAAK,aACH,OAAO1B;EACT,KAAK,qBACH,OAAOC;EACT,KAAK,eACH,OAAQmB,MAAMO,eAAeP,MAAMO,gBAAgB;GACjDC,SAAS;GACTC,MAAM,UAAUxC,oBAAoB4B,MAAM,CAAC,CAACa,KAAI;GAChDC,WAAW1C,oBAAoB4B,MAAM,CAAC,CAACa;EACzC;EACF,KAAK,gBACH,OAAQV,MAAMY,cAAcZ,MAAMY,eAAe,IAAIrB,YAAYM,MAAM;EACzE,KAAK,gBACH,OAA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MAAMnE,IAAI;CACzC;AACF;AAYEmC,wBAAwBqC,UAAUC,0BAA0B,SAAUjC,UAA0C;CAE9G,IAAI,KAAKJ,WAAWK,YAAYD,QAAQ,GACtC,OAAO,KAAKJ,WAAWqC,wBAAyBjC,QAAQ;CAG1D,OAAO,KAAKH,WAAWoC,wBAAyBjC,QAAQ;AAC1D;AACAL,wBAAwBqC,UAAUE,6BAA6B,SAAUlC,UAA0C;CAEjH,IAAI,KAAKJ,WAAWK,YAAYD,QAAQ,GACtC,OAAO,KAAKJ,WAAWsC,2BAA4BlC,QAAQ;CAG7D,OAAO,KAAKH,WAAWqC,2BAA4BlC,QAAQ;AAC7D;AACAL,wBAAwBqC,UAAUG,gBAAgB,SAAUjG,MAAc;CAExE,OAAO,KAAK0D,WAAWuC,gBAAgBjG,IAAI,KAAK,KAAK2D,WAAWsC,gBAAgBjG,IAAI,KAAK;AAC3F"}
|
|
1
|
+
{"version":3,"file":"migration-support.js","names":["recordIdentifierFor","Context","notifyInternalSignal","assertPrivateStore","getOrSetGlobal","Type","Errors","lookupLegacySupport","_destroyRecord","_reload","_save","belongsTo","changedAttributes","createSnapshot","deleteRecord","destroyRecord","hasMany","reload","rollbackAttributes","save","serialize","unloadRecord","RecordState","buildSchema","LegacyFields","LegacySupport","WeakMap","legacySupport","record","options","prop","state","get","set","suppressDeprecation","Boolean","currentState","adapterError","_constructor","isModel","name","type","modelName","recordState","dirtyType","errors","create","__record","isDirty","isDeleted","isEmpty","isError","isLoaded","isLoading","isNew","isSaving","isValid","test","Error","withDefaults","schema","legacy","identity","kind","forEach","field","fields","push","defaultValue","objectExtensions","withRestoredDeprecatedModelRequestBehaviors","registerDerivations","registerDerivation","_registerMode","store","cacheKey","getBelongsTo","value","_join","setDirtyBelongsTo","getHasMany","support","manyArray","getManyArray","splice","length","notify","_manyArrayCache","hasPromise","_relationshipPromisesCache","signal","CAUTION_MEGA_DANGER_ZONE_registerExtension","features","isReloading","console","warn","_isReloading","v","DelegatingSchemaService","_preferred","_secondary","constructor","isDelegated","resource","hasResource","resourceTypes","Array","from","Set","concat","hasTrait","resourceHasTrait","trait","cacheFields","transformation","hashFn","derivation","registerResources","schemas","registerResource","registerTransformation","transform","registerHashFn","CAUTION_MEGA_DANGER_ZONE_hasExtension","ext","extension","CAUTION_MEGA_DANGER_ZONE_resourceExtensions","CAUTION_MEGA_DANGER_ZONE_objectExtensions","resolvedType","CAUTION_MEGA_DANGER_ZONE_arrayExtensions","mode","kinds","_kind","assertPrivate","service","prototype","attributesDefinitionFor","relationshipsDefinitionFor","doesTypeExist"],"sources":["../../../../src/model/migration-support.ts"],"sourcesContent":["/**\n * This module provides support for migrating away from @warp-drive/legacy/model\n * to ReactiveResource from @warp-drive/core/reactive.\n *\n * It includes:\n *\n * - A `withDefaults` function to assist in creating a schema in LegacyMode\n * - A `registerDerivations` function to register the derivations necessary to support LegacyMode\n * - A `DelegatingSchemaService` that can be used to provide a schema service that works with both\n * @warp-drive/legacy/model and @warp-drive/core/reactive simultaneously for migration purposes.\n * - A `WithLegacy` type util that can be used to create a type that includes the legacy\n * properties and methods of a record.\n *\n * Using LegacyMode features on a ReactiveResource *requires* the use of these derivations and schema\n * additions. LegacyMode is not intended to be a long-term solution, but rather a stepping stone\n * to assist in more rapidly adopting modern WarpDrive features.\n *\n * @summary Legacy helpers for migrating from `Model` to `ReactiveResource`: LegacyMode schema defaults, derivations,\n * types, and a schema service that serves both at once.\n * @module\n */\nimport { deprecate } from '@ember/debug';\n\nimport type { Store } from '@warp-drive/core';\nimport { recordIdentifierFor } from '@warp-drive/core';\nimport { ENABLE_LEGACY_SCHEMA_SERVICE } from '@warp-drive/core/build-config/deprecations';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from '@warp-drive/core/reactive';\nimport type { ExtensibleField } from '@warp-drive/core/reactive/-private';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport { notifyInternalSignal } from '@warp-drive/core/signals/-leaked';\nimport type { PrivateReactiveResourceArray } from '@warp-drive/core/store/-private';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { SchemaService } from '@warp-drive/core/types';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { ChangedAttributesHash } from '@warp-drive/core/types/cache';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { ObjectValue } from '@warp-drive/core/types/json/raw';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { Derivation, HashFn, Transformation } from '@warp-drive/core/types/schema/concepts';\nimport type {\n ArrayField,\n CacheableFieldSchema,\n DerivedField,\n FieldSchema,\n GenericField,\n HashField,\n IdentityField,\n LegacyBelongsToField,\n LegacyHasManyField,\n LegacyResourceSchema,\n ObjectField,\n ObjectSchema,\n ResourceSchema,\n} from '@warp-drive/core/types/schema/fields';\nimport { Type } from '@warp-drive/core/types/symbols';\nimport type { WithPartial } from '@warp-drive/core/types/utils';\n\nimport type { Snapshot } from '../compat/-private.ts';\nimport { Errors, lookupLegacySupport } from './-private.ts';\nimport type { MinimalLegacyRecord } from './-private/model-methods.ts';\nimport {\n _destroyRecord,\n _reload,\n _save,\n belongsTo,\n changedAttributes,\n createSnapshot,\n deleteRecord,\n destroyRecord,\n hasMany,\n reload,\n rollbackAttributes,\n save,\n serialize,\n unloadRecord,\n} from './-private/model-methods.ts';\nimport RecordState from './-private/record-state.ts';\nimport type BelongsToReference from './-private/references/belongs-to.ts';\nimport type HasManyReference from './-private/references/has-many.ts';\nimport { buildSchema } from './-private/schema-provider.ts';\nimport type { _MaybeBelongsToFields, MaybeHasManyFields } from './-private/type-utils.ts';\n\n/**\n * Adds the `Model`-style `belongsTo`/`hasMany` reference methods to a\n * {@link TypedRecordInstance}, for use when migrating a resource from\n * `Model` to a schema-based record while preserving these APIs.\n *\n * @summary Legacy type that adds the `Model`-style `belongsTo` and `hasMany` reference methods to a typed record\n * migrating from `Model` to a schema-based record.\n */\nexport type WithLegacyDerivations<T extends TypedRecordInstance> = T &\n MinimalLegacyRecord & {\n /**\n * see {@link belongsTo}\n */\n belongsTo: typeof belongsTo;\n /**\n * see {@link hasMany}\n */\n hasMany: typeof hasMany;\n };\n\ntype AttributesSchema = ReturnType<Exclude<SchemaService['attributesDefinitionFor'], undefined>>;\ntype RelationshipsSchema = ReturnType<Exclude<SchemaService['relationshipsDefinitionFor'], undefined>>;\n\ninterface LegacyModeRecord<T extends TypedRecordInstance> {\n id: string | null;\n\n serialize(options?: Record<string, unknown>): unknown;\n destroyRecord(options?: Record<string, unknown>): Promise<this>;\n unloadRecord(): void;\n changedAttributes(): ChangedAttributesHash;\n rollbackAttributes(): void;\n _createSnapshot(): Snapshot<T>;\n save(options?: Record<string, unknown>): Promise<this>;\n reload(options?: Record<string, unknown>): Promise<T>;\n belongsTo<K extends _MaybeBelongsToFields<T>>(prop: K): BelongsToReference<T, K>;\n hasMany<K extends MaybeHasManyFields<T>>(prop: K): HasManyReference<T, K>;\n deleteRecord(): void;\n\n adapterError: unknown;\n constructor: { modelName: TypeFromInstance<T> };\n currentState: RecordState;\n dirtyType: 'deleted' | 'created' | 'updated' | '';\n errors: unknown;\n hasDirtyAttributes: boolean;\n isDeleted: boolean;\n isEmpty: boolean;\n isError: boolean;\n isLoaded: boolean;\n isLoading: boolean;\n isDestroying: boolean;\n isDestroyed: boolean;\n isNew: boolean;\n isSaving: boolean;\n isValid: boolean;\n}\n\n// 'isDestroying', 'isDestroyed'\nconst LegacyFields = [\n '_createSnapshot',\n 'adapterError',\n 'belongsTo',\n 'changedAttributes',\n 'constructor',\n 'currentState',\n 'deleteRecord',\n 'destroyRecord',\n 'dirtyType',\n 'errors',\n 'hasDirtyAttributes',\n 'hasMany',\n 'isDeleted',\n 'isEmpty',\n 'isError',\n 'isLoaded',\n 'isLoading',\n 'isNew',\n 'isSaving',\n 'isValid',\n 'reload',\n 'rollbackAttributes',\n 'save',\n 'serialize',\n 'unloadRecord',\n] as const;\n\n/**\n * A Type utility that enables quickly adding type information for the fields\n * defined by `import { withDefaults } from '@warp-drive/legacy/model/migration-support'`.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';\n * import { Type } from '@warp-drive/core/types/symbols';\n * import type { HasMany } from '@@warp-drive/legacy/model';\n *\n * export const UserSchema = withDefaults({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * { name: 'age', kind: 'attribute' },\n * { name: 'friends',\n * kind: 'hasMany',\n * type: 'user',\n * options: { inverse: 'friends', async: false }\n * },\n * { name: 'bestFriend',\n * kind: 'belongsTo',\n * type: 'user',\n * options: { inverse: null, async: false }\n * },\n * ],\n * });\n *\n * export type User = WithLegacy<{\n * firstName: string;\n * lastName: string;\n * age: number;\n * friends: HasMany<User>;\n * bestFriend: User | null;\n * [Type]: 'user';\n * }>\n * ```\n *\n * @summary Legacy type that adds the `Model`-style state flags and methods (`save`, `isNew`, `errors`, etc.) that\n * `withDefaults` provides to a LegacyMode record type.\n */\nexport type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;\n\nconst LegacySupport = getOrSetGlobal('LegacySupport', new WeakMap<MinimalLegacyRecord, Record<string, unknown>>());\n\nfunction legacySupport(record: MinimalLegacyRecord, options: ObjectValue | null, prop: string): unknown {\n let state = LegacySupport.get(record);\n if (!state) {\n state = {};\n LegacySupport.set(record, state);\n }\n const suppressDeprecation = Boolean(options && options.suppressDeprecation);\n\n switch (prop) {\n case '_createSnapshot':\n // FIXME should be deprecated too?\n return createSnapshot;\n case 'adapterError':\n // FIXME should be deprecated too?\n return record.currentState.adapterError;\n case 'belongsTo':\n return belongsTo;\n case 'changedAttributes':\n return changedAttributes;\n case 'constructor':\n return (state._constructor = state._constructor || {\n isModel: true,\n name: `Record<${recordIdentifierFor(record).type}>`,\n modelName: recordIdentifierFor(record).type,\n });\n case 'currentState':\n return (state.recordState = state.recordState || new RecordState(record));\n case 'deleteRecord':\n return deleteRecord;\n case 'destroyRecord':\n return suppressDeprecation ? _destroyRecord : destroyRecord;\n case 'dirtyType':\n return record.currentState.dirtyType;\n case 'errors':\n // FIXME should be deprecated too?\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n return (state.errors = state.errors || Errors.create({ __record: record }));\n case 'hasDirtyAttributes':\n return record.currentState.isDirty;\n case 'hasMany':\n return hasMany;\n case 'isDeleted':\n return record.currentState.isDeleted;\n case 'isEmpty':\n return record.currentState.isEmpty;\n case 'isError':\n return record.currentState.isError;\n case 'isLoaded':\n return record.currentState.isLoaded;\n case 'isLoading':\n return record.currentState.isLoading;\n case 'isNew':\n return record.currentState.isNew;\n case 'isSaving':\n return record.currentState.isSaving;\n case 'isValid':\n return record.currentState.isValid;\n case 'reload':\n return suppressDeprecation ? _reload : reload;\n case 'rollbackAttributes':\n return rollbackAttributes;\n case 'save':\n return suppressDeprecation ? _save : save;\n case 'serialize':\n // FIXME should be deprecated too? (is somewhat deprecated via store.serializeRecord)\n return serialize;\n case 'unloadRecord':\n return unloadRecord;\n default:\n assert(`${prop} is not a supported legacy field`, false);\n }\n}\nlegacySupport[Type] = '@legacy';\n\n/**\n * A function which adds the necessary fields to a schema and marks it as\n * being in LegacyMode. This is used to support the legacy features of\n * @warp-drive/legacy/model while migrating to WarpDrive.\n *\n * Example:\n *\n * ```ts\n * import { withDefaults, WithLegacy } from '@warp-drive/legacy/model/migration-support';\n * import { Type } from '@warp-drive/core/types/symbols';\n * import type { HasMany } from '@warp-drive/legacy/model';\n *\n * export const UserSchema = withDefaults({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * { name: 'age', kind: 'attribute' },\n * { name: 'friends',\n * kind: 'hasMany',\n * type: 'user',\n * options: { inverse: 'friends', async: false }\n * },\n * { name: 'bestFriend',\n * kind: 'belongsTo',\n * type: 'user',\n * options: { inverse: null, async: false }\n * },\n * ],\n * });\n *\n * export type User = WithLegacy<{\n * firstName: string;\n * lastName: string;\n * age: number;\n * friends: HasMany<User>;\n * bestFriend: User | null;\n * [Type]: 'user';\n * }>\n * ```\n *\n * Using this function require registering the derivations\n * it requires with the schema service.\n *\n * ```ts\n * import { registerDerivations } from '@warp-drive/legacy/model/migration-support';\n *\n * registerDerivations(schema);\n * ```\n *\n * @summary Legacy helper that marks a resource schema as LegacyMode and adds the fields that give its records\n * `Model`-like state and methods.\n * @param schema The schema to add legacy support to.\n * @return The schema with legacy support added.\n * @public\n */\nexport function withDefaults(schema: WithPartial<LegacyResourceSchema, 'legacy' | 'identity'>): LegacyResourceSchema {\n schema.legacy = true;\n schema.identity = { kind: '@id', name: 'id' };\n\n LegacyFields.forEach((field) => {\n schema.fields.push({\n type: '@legacy',\n name: field,\n kind: 'derived',\n });\n });\n schema.fields.push({\n name: '_isReloading',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroying',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroyed',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.objectExtensions = schema.objectExtensions || [];\n schema.objectExtensions.push('deprecated-model-behaviors');\n return schema as LegacyResourceSchema;\n}\n\n/**\n * Adds the necessasary fields to the schema for supporting\n * the deprecated request methods on LegacyMode schemas.\n *\n * Use this instead of `withDefaults` to add the fields\n * and behaviors necessary to support Model-Like capabilities.\n *\n * ```ts\n * import { withRestoredDeprecatedModelRequestBehaviors } from '@warp-drive/legacy/model/migration-support';\n *\n * export const UserSchema = withRestoredDeprecatedModelRequestBehaviors({\n * type: 'user',\n * fields: [\n * { name: 'firstName', kind: 'attribute' },\n * { name: 'lastName', kind: 'attribute' },\n * ]\n * });\n * ```\n *\n * @summary Legacy alternative to `withDefaults` that makes a LegacyMode schema whose `save`, `reload`, and\n * `destroyRecord` run without deprecation warnings.\n */\nexport function withRestoredDeprecatedModelRequestBehaviors(\n schema: WithPartial<LegacyResourceSchema, 'legacy' | 'identity'>\n): LegacyResourceSchema {\n schema.legacy = true;\n schema.identity = { kind: '@id', name: 'id' };\n\n LegacyFields.forEach((field) => {\n schema.fields.push({\n type: '@legacy',\n name: field,\n kind: 'derived',\n options: { suppressDeprecation: true },\n });\n });\n schema.fields.push({\n name: 'isReloading',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroying',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n schema.fields.push({\n name: 'isDestroyed',\n kind: '@local',\n type: 'boolean',\n options: { defaultValue: false },\n });\n return schema as LegacyResourceSchema;\n}\n\n/**\n * A function which registers the necessary derivations to support\n * the LegacyMode features of @warp-drive/legacy/model while migrating to WarpDrive.\n *\n * This must be called in order to use the fields added by {@link withDefaults} or\n * {@link withRestoredDeprecatedModelRequestBehaviors}.\n *\n * @summary Legacy setup that registers the derivation, relationship behaviors, and extension a schema service needs to\n * support LegacyMode records.\n * @param schema The schema service to register the derivations with.\n * @public\n */\nexport function registerDerivations(schema: SchemaService): void {\n schema.registerDerivation(legacySupport);\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n schema._registerMode('@legacy', {\n belongsTo: {\n get(store: Store, record: object, cacheKey: ResourceKey, field: LegacyBelongsToField) {\n // FIXME field.name here should likely be field.sourceKey || field.name\n return lookupLegacySupport(record as unknown as MinimalLegacyRecord).getBelongsTo(field.name);\n },\n set(store: Store, record: object, cacheKey: ResourceKey, field: LegacyBelongsToField, value: unknown) {\n assertPrivateStore(store);\n store._join(() => {\n // FIXME field.name here should likely be field.sourceKey || field.name\n lookupLegacySupport(record as unknown as MinimalLegacyRecord).setDirtyBelongsTo(field.name, value);\n });\n },\n },\n hasMany: {\n get(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField) {\n // FIXME field.name here should likely be field.sourceKey || field.name\n return lookupLegacySupport(record as unknown as MinimalLegacyRecord).getHasMany(field.name);\n },\n set(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField, value: unknown[]) {\n assertPrivateStore(store);\n store._join(() => {\n const support = lookupLegacySupport(record as unknown as MinimalLegacyRecord);\n // FIXME field.name here should likely be field.sourceKey || field.name\n const manyArray = support.getManyArray(field.name);\n\n manyArray.splice(0, manyArray.length, ...value);\n });\n },\n notify(store: Store, record: object, cacheKey: ResourceKey, field: LegacyHasManyField): boolean {\n const support = lookupLegacySupport(record as unknown as MinimalLegacyRecord);\n // FIXME field.name here should likely be field.sourceKey || field.name\n const manyArray = support && support._manyArrayCache[field.name];\n const hasPromise = support && (support._relationshipPromisesCache[field.name] as Promise<unknown> | undefined);\n\n if (manyArray && hasPromise) {\n // do nothing, we will notify the ManyArray directly\n // once the fetch has completed.\n return false;\n }\n\n if (manyArray) {\n notifyInternalSignal((manyArray as unknown as PrivateReactiveResourceArray)[Context].signal);\n\n return true;\n }\n\n return false;\n },\n },\n });\n\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension!({\n name: 'deprecated-model-behaviors',\n kind: 'object',\n features: {\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n get isReloading() {\n deprecate(\n `record.isReloading is deprecated, please use store.request and either <Request> or getRequuestState to keep track of the request state instead.`,\n false,\n {\n id: 'warp-drive:deprecate-legacy-request-methods',\n until: '6.0',\n for: '@warp-drive/core',\n url: 'https://warp-drive.io/api/@warp-drive/core/build-config/deprecations/variables/ENABLE_LEGACY_REQUEST_METHODS',\n since: {\n enabled: '5.7',\n available: '5.7',\n },\n }\n );\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-return\n return this._isReloading;\n },\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n set isReloading(v) {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n this._isReloading = v;\n },\n },\n });\n}\n\n/**\n * A class which provides a schema service that delegates between\n * a primary schema service and one that supports legacy model\n * classes as its schema source.\n *\n * When the primary schema service has a schema for the given\n * resource, it will be used. Otherwise, the fallback schema\n * service will be used.\n *\n * This can be used when incrementally migrating from Models to\n * ReactiveResources by enabling unmigrated Models to continue to\n * provide their own schema information to the application.\n *\n * ```ts\n * import { DelegatingSchemaService } from '@warp-drive/legacy/model/migration-support';\n * import { SchemaService } from '@warp-drive/core/reactive';\n *\n * class AppStore extends Store {\n * createSchemaService() {\n * const schema = new SchemaService();\n * return new DelegatingSchemaService(this, schema);\n * }\n * }\n * ```\n *\n * All calls to register resources, derivations, transformations, hash functions\n * etc. will be delegated to the primary schema service.\n *\n * @summary Legacy schema service that serves a resource's schema from the primary service when it has one, and\n * otherwise from its `Model` class, for incremental migration.\n * @class DelegatingSchemaService\n * @public\n */\nexport interface DelegatingSchemaService {\n /**\n * Delegates to whichever of the primary/fallback schema services has a\n * schema for the resource, preferring the primary. See {@link DelegatingSchemaService.isDelegated | isDelegated}.\n */\n attributesDefinitionFor?(resource: ResourceKey | { type: string }): AttributesSchema;\n /**\n * Delegates to whichever of the primary/fallback schema services has a\n * schema for the resource, preferring the primary. See {@link DelegatingSchemaService.isDelegated | isDelegated}.\n */\n relationshipsDefinitionFor?(resource: ResourceKey | { type: string }): RelationshipsSchema;\n /**\n * Whether either the primary or fallback schema service has a schema\n * for the given type.\n */\n doesTypeExist?(type: string): boolean;\n}\n/**\n * See the {@link DelegatingSchemaService | class documentation above} for usage.\n * @summary Legacy schema service that serves a resource's schema from the primary service when it has one, and\n * otherwise from its `Model` class, for incremental migration.\n */\nexport class DelegatingSchemaService implements SchemaService {\n /** @internal */\n _preferred!: SchemaService;\n /** @internal */\n _secondary!: SchemaService;\n\n constructor(store: Store, schema: SchemaService) {\n this._preferred = schema;\n this._secondary = buildSchema(store);\n }\n\n /**\n * Whether the given resource's schema is being served by the fallback\n * (legacy Model-derived) schema service rather than the primary one.\n */\n isDelegated(resource: ResourceKey | { type: string }): boolean {\n return !this._preferred.hasResource(resource) && this._secondary.hasResource(resource);\n }\n\n resourceTypes(): Readonly<string[]> {\n return Array.from(new Set(this._preferred.resourceTypes().concat(this._secondary.resourceTypes())));\n }\n\n hasResource(resource: ResourceKey | { type: string }): boolean {\n return this._preferred.hasResource(resource) || this._secondary.hasResource(resource);\n }\n hasTrait(type: string): boolean {\n if (this._preferred.hasResource({ type })) {\n return this._preferred.hasTrait(type);\n }\n return this._secondary.hasTrait(type);\n }\n resourceHasTrait(resource: ResourceKey | { type: string }, trait: string): boolean {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.resourceHasTrait(resource, trait);\n }\n return this._secondary.resourceHasTrait(resource, trait);\n }\n fields(resource: ResourceKey | { type: string }): Map<string, FieldSchema> {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.fields(resource);\n }\n return this._secondary.fields(resource);\n }\n cacheFields?(resource: { type: string }): Map<string, Exclude<CacheableFieldSchema, IdentityField>> {\n if (this._preferred.hasResource?.(resource)) {\n // @ts-expect-error\n return this._preferred.cacheFields?.(resource);\n }\n\n // @ts-expect-error\n return this._secondary.cacheFields?.(resource);\n }\n transformation(field: GenericField | ObjectField | ArrayField | { type: string }): Transformation {\n return this._preferred.transformation(field);\n }\n hashFn(field: HashField | { type: string }): HashFn {\n return this._preferred.hashFn(field);\n }\n derivation(field: DerivedField | { type: string }): Derivation {\n return this._preferred.derivation(field);\n }\n resource(resource: ResourceKey | { type: string }): ResourceSchema | ObjectSchema {\n if (this._preferred.hasResource(resource)) {\n return this._preferred.resource(resource);\n }\n return this._secondary.resource(resource);\n }\n registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void {\n this._preferred.registerResources(schemas);\n }\n registerResource(schema: ResourceSchema | ObjectSchema): void {\n this._preferred.registerResource(schema);\n }\n registerTransformation(transform: Transformation): void {\n this._preferred.registerTransformation(transform);\n }\n registerDerivation<R, T, FM extends ObjectValue | null>(derivation: Derivation<R, T, FM>): void {\n this._preferred.registerDerivation(derivation);\n }\n registerHashFn(hashFn: HashFn): void {\n this._preferred.registerHashFn(hashFn);\n }\n\n CAUTION_MEGA_DANGER_ZONE_hasExtension(ext: { kind: 'object' | 'array'; name: string }): boolean {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_hasExtension!(ext);\n }\n\n CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void {\n this._preferred.CAUTION_MEGA_DANGER_ZONE_registerExtension!(extension);\n }\n\n CAUTION_MEGA_DANGER_ZONE_resourceExtensions(\n resource: ResourceKey | { type: string }\n ): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_resourceExtensions!(resource);\n }\n\n CAUTION_MEGA_DANGER_ZONE_objectExtensions(\n field: ExtensibleField,\n resolvedType: string | null\n ): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_objectExtensions!(field, resolvedType);\n }\n\n CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension['features'] {\n return this._preferred.CAUTION_MEGA_DANGER_ZONE_arrayExtensions!(field);\n }\n\n /**\n * This is an internal method used to register behaviors for legacy mode.\n * It is not intended for public use.\n *\n * We do think a generalized `kind` registration system would be useful,\n * but we have not yet designed it.\n *\n * See https://github.com/warp-drive-data/warp-drive/issues/9534\n *\n * @internal\n */\n _registerMode(mode: string, kinds: unknown): void {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n this._preferred._registerMode(mode, kinds);\n }\n\n /**\n * This is an internal method used to enable legacy behaviors for legacy mode.\n * It is not intended for public use.\n *\n * We do think a generalized `kind` registration system would be useful,\n * but we have not yet designed it.\n *\n * See https://github.com/warp-drive-data/warp-drive/issues/9534\n *\n * @internal\n */\n _kind(mode: string, kind: 'belongsTo' | 'hasMany'): () => unknown {\n // @ts-expect-error\n // oxlint-disable-next-line typescript/no-unsafe-call\n return this._preferred._kind(mode, kind) as () => unknown;\n }\n}\n\n/**\n * @internal\n */\nexport interface PrivateDelegatingSchemaService extends DelegatingSchemaService {\n _preferred: SchemaService;\n _secondary: SchemaService;\n}\nfunction assertPrivate(service: DelegatingSchemaService): asserts service is PrivateDelegatingSchemaService {}\n\nif (ENABLE_LEGACY_SCHEMA_SERVICE) {\n DelegatingSchemaService.prototype.attributesDefinitionFor = function (resource: ResourceKey | { type: string }) {\n assertPrivate(this);\n if (this._preferred.hasResource(resource)) {\n return this._preferred.attributesDefinitionFor!(resource);\n }\n\n return this._secondary.attributesDefinitionFor!(resource);\n };\n DelegatingSchemaService.prototype.relationshipsDefinitionFor = function (resource: ResourceKey | { type: string }) {\n assertPrivate(this);\n if (this._preferred.hasResource(resource)) {\n return this._preferred.relationshipsDefinitionFor!(resource);\n }\n\n return this._secondary.relationshipsDefinitionFor!(resource);\n };\n DelegatingSchemaService.prototype.doesTypeExist = function (type: string) {\n assertPrivate(this);\n return this._preferred.doesTypeExist?.(type) || this._secondary.doesTypeExist?.(type) || false;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4IA,MAAMwB,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDhB,MAAMC,gBAAgBrB,eAAe,iCAAiB,IAAIsB,QAAsD,CAAC;AAEjH,SAASC,cAAcC,QAA6BC,SAA6BC,MAAuB;CACtG,IAAIC,QAAQN,cAAcO,IAAIJ,MAAM;CACpC,IAAI,CAACG,OAAO;EACVA,QAAQ,CAAC;EACTN,cAAcQ,IAAIL,QAAQG,KAAK;CACjC;CACA,MAAMG,sBAAsBC,QAAQN,WAAWA,QAAQK,mBAAmB;CAE1E,QAAQJ,MAAR;EACE,KAAK,mBAEH,OAAOjB;EACT,KAAK,gBAEH,OAAOe,OAAOQ,aAAaC;EAC7B,KAAK,aACH,OA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ACvC,OAAO,KAAK7B,WAAW4B,0CAA2C9D,OAAO+D,YAAY;CACvF;CAEAC,yCAAyChE,OAA+D;EACtG,OAAO,KAAKkC,WAAW8B,yCAA0ChE,KAAK;CACxE;;;;;;;;;;;;CAaAQ,cAAcyD,MAAcC,OAAsB;EAGhD,KAAKhC,WAAW1B,cAAcyD,MAAMC,KAAK;CAC3C;;;;;;;;;;;;CAaAC,MAAMF,MAAcnE,MAA8C;EAGhE,OAAO,KAAKoC,WAAWiC,MAAMF,MAAMnE,IAAI;CACzC;AACF;AAYEmC,wBAAwBqC,UAAUC,0BAA0B,SAAUjC,UAA0C;CAE9G,IAAI,KAAKJ,WAAWK,YAAYD,QAAQ,GACtC,OAAO,KAAKJ,WAAWqC,wBAAyBjC,QAAQ;CAG1D,OAAO,KAAKH,WAAWoC,wBAAyBjC,QAAQ;AAC1D;AACAL,wBAAwBqC,UAAUE,6BAA6B,SAAUlC,UAA0C;CAEjH,IAAI,KAAKJ,WAAWK,YAAYD,QAAQ,GACtC,OAAO,KAAKJ,WAAWsC,2BAA4BlC,QAAQ;CAG7D,OAAO,KAAKH,WAAWqC,2BAA4BlC,QAAQ;AAC7D;AACAL,wBAAwBqC,UAAUG,gBAAgB,SAAUjG,MAAc;CAExE,OAAO,KAAK0D,WAAWuC,gBAAgBjG,IAAI,KAAK,KAAK2D,WAAWsC,gBAAgBjG,IAAI,KAAK;AAC3F"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as normalizeModelName, t as isElementDescriptor } from "./util-CXA3RNYH.js";
|
|
2
|
-
import { r as lookupLegacySupport } from "./errors-
|
|
3
|
-
import { n as getModelFactory } from "./schema-provider-
|
|
2
|
+
import { r as lookupLegacySupport } from "./errors-CLRhQKym.js";
|
|
3
|
+
import { n as getModelFactory } from "./schema-provider-DHS8XOdK.js";
|
|
4
4
|
import { recordIdentifierFor } from "@warp-drive/core";
|
|
5
5
|
import { getOwner, setOwner } from "@ember/application";
|
|
6
6
|
import { StoreMap, assertPrivateStore, setRecordIdentifier } from "@warp-drive/core/store/-private";
|
|
@@ -161,6 +161,8 @@ return new this();
|
|
|
161
161
|
}
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
+
@summary Legacy `Model` decorator that declares an attribute field, optionally converted by a named transform and
|
|
165
|
+
given a `defaultValue`.
|
|
164
166
|
@public
|
|
165
167
|
@param type the attribute type
|
|
166
168
|
@param options a hash of options
|
|
@@ -365,6 +367,8 @@ Polymorphic to polymorphic relationships are supported. Both sides of the relati
|
|
|
365
367
|
must be declared as polymorphic, and the `as` option must be used to declare the abstract
|
|
366
368
|
type each record satisfies on both sides.
|
|
367
369
|
|
|
370
|
+
@summary Legacy `Model` decorator that declares a to-one relationship to another resource type, configured with
|
|
371
|
+
required `async` and `inverse` options.
|
|
368
372
|
@public
|
|
369
373
|
@param type the name of the related resource
|
|
370
374
|
@param options a hash of options
|
|
@@ -569,6 +573,8 @@ Polymorphic to polymorphic relationships are supported. Both sides of the relati
|
|
|
569
573
|
must be declared as polymorphic, and the `as` option must be used to declare the abstract
|
|
570
574
|
type each record satisfies on both sides.
|
|
571
575
|
|
|
576
|
+
@summary Legacy `Model` decorator that declares a to-many relationship to another resource type, configured with
|
|
577
|
+
required `async` and `inverse` options.
|
|
572
578
|
@public
|
|
573
579
|
@param type the name of the related resource
|
|
574
580
|
@param options a hash of options
|
|
@@ -587,6 +593,8 @@ function hasMany(type, options) {
|
|
|
587
593
|
* this to your store's `instantiateRecord` method when configuring the
|
|
588
594
|
* store to use `Model` for schema/record instantiation.
|
|
589
595
|
*
|
|
596
|
+
* @summary Legacy store hook that creates a `Model` instance for a resource key using the `Model` class registered
|
|
597
|
+
* for its type.
|
|
590
598
|
* @public
|
|
591
599
|
*/
|
|
592
600
|
function instantiateRecord(identifier, createRecordArgs) {
|
|
@@ -611,6 +619,7 @@ function instantiateRecord(identifier, createRecordArgs) {
|
|
|
611
619
|
* to your store's `teardownRecord` method when configuring the store to
|
|
612
620
|
* use `Model` for schema/record instantiation.
|
|
613
621
|
*
|
|
622
|
+
* @summary Legacy store hook that destroys a `Model` instance when the store releases its record.
|
|
614
623
|
* @public
|
|
615
624
|
*/
|
|
616
625
|
function teardownRecord(record) {
|
|
@@ -624,6 +633,8 @@ function teardownRecord(record) {
|
|
|
624
633
|
* as `store.modelFor(type)` when the store is configured to use `Model`.
|
|
625
634
|
* Returns the `Model` subclass registered for the given type, if any.
|
|
626
635
|
*
|
|
636
|
+
* @summary Legacy `store.modelFor` implementation that returns the `Model` class registered for a resource type, if
|
|
637
|
+
* there is one.
|
|
627
638
|
* @public
|
|
628
639
|
*/
|
|
629
640
|
/**
|
|
@@ -657,4 +668,4 @@ function secretInit(record, identifier, store) {
|
|
|
657
668
|
|
|
658
669
|
//#endregion
|
|
659
670
|
export { belongsTo as a, hasMany as i, modelFor as n, attr as o, teardownRecord as r, instantiateRecord as t };
|
|
660
|
-
//# sourceMappingURL=model-
|
|
671
|
+
//# sourceMappingURL=model-DIvuaUiJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-DIvuaUiJ.js","names":["computed","recordIdentifierFor","RecordStore","isElementDescriptor","_attr","type","options","undefined","meta","kind","isAttribute","sourceKey","key","get","includes","Error","constructor","toString","isDestroyed","isDestroying","cache","getAttr","set","value","identifier","test","id","lid","currentState","isDeleted","cacheKey","currentValue","setAttr","isValid","errors","remove","cleanErrorRequests","attr","desc","args","computed","assertPrivateStore","RecordStore","lookupLegacySupport","isElementDescriptor","normalizeModelName","_belongsTo","type","options","test","Error","async","inverse","length","meta","kind","name","sourceKey","get","key","isDestroying","isDestroyed","support","includes","constructor","toString","Object","prototype","hasOwnProperty","call","console","warn","identifier","id","getBelongsTo","set","value","_join","setDirtyBelongsTo","belongsTo","arguments","computed","assertPrivateStore","RecordStore","dasherize","singularize","lookupLegacySupport","isElementDescriptor","normalizeType","type","result","console","warn","_hasMany","options","test","Error","async","meta","kind","name","sourceKey","get","key","includes","constructor","toString","isDestroying","isDestroyed","getHasMany","set","records","support","manyArray","getManyArray","Array","isArray","_join","splice","length","hasMany","arguments","getOwner","setOwner","assertPrivateStore","setRecordIdentifier","StoreMap","getModelFactory","normalizeModelName","recast","context","instantiateRecord","identifier","createRecordArgs","type","createOptions","_createProps","_secretInit","store","cb","secretInit","factory","test","Error","class","create","teardownRecord","record","destroy","modelFor","modelName","isDestroyed","isDestroying","length","maybeFactory","klass","ignoreType","isModel","_forceShim","schema","hasResource","set"],"sources":["../../../src/model/-private/attr.ts","../../../src/model/-private/belongs-to.ts","../../../src/model/-private/has-many.ts","../../../src/model/-private/hooks.ts"],"sourcesContent":["import { computed } from '@ember/object';\n\nimport { recordIdentifierFor } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { ArrayValue, ObjectValue, PrimitiveValue, Value } from '@warp-drive/core/types/json/raw';\nimport { RecordStore, type TransformName } from '@warp-drive/core/types/symbols';\n\n// oxlint-disable-next-line no-unused-vars\nimport type { Transform } from '../../serializer/transform.ts';\nimport type { Model } from './model.ts';\nimport type { DecoratorPropertyDescriptor } from './util.ts';\nimport { isElementDescriptor } from './util.ts';\n/**\n * Options provided to the attr decorator are\n * supplied to the associated transform. Any\n * key-value pair is valid; however, it is highly\n * recommended to only use statically defined values\n * that could be serialized to JSON.\n *\n * If no transform is provided, the only valid\n * option is `defaultValue`.\n *\n * Examples:\n *\n * ```ts\n * class User extends Model {\n * @attr('string', { defaultValue: 'Anonymous' }) name;\n * @attr('date', { defaultValue: () => new Date() }) createdAt;\n * @attr({ defaultValue: () => ({}) }) preferences;\n * @attr('boolean') hasVerifiedEmail;\n * @attr address;\n * }\n *\n * @class NOTATHING\n */\nexport type AttrOptions<DV = PrimitiveValue | object | unknown[]> = {\n /**\n * The default value for this attribute.\n *\n * Default values can be provided as a value or a function that will be\n * executed to generate the default value.\n *\n * Default values *should not* be stateful (object, arrays, etc.) as\n * they will be shared across all instances of the record.\n *\n */\n defaultValue?: DV extends PrimitiveValue ? DV : () => DV;\n\n /**\n * The name of the field as returned by the API and inserted into the\n * cache if it differs from the name of the decorated property.\n *\n * For instance, if the API returns:\n *\n * ```ts\n * {\n * attributes: {\n * 'first-name': 'Chris'\n * }\n * }\n * ```\n *\n * But the app desires to use `record.firstName; // 'Chris'`, then the\n * property should be named `firstName` and `sourceKey` should be set\n * to `'first-name'`.\n *\n * This option is only needed when the value differs from the property name.\n */\n sourceKey?: string;\n};\n\nfunction _attr(type?: string | AttrOptions, options?: AttrOptions) {\n if (typeof type === 'object') {\n options = type;\n type = undefined;\n } else {\n options = options || {};\n }\n\n const meta = {\n type: type,\n kind: 'attribute',\n isAttribute: true,\n options: options,\n sourceKey: options.sourceKey,\n key: null,\n };\n\n return computed({\n get(this: Model, key: string) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`\n );\n }\n }\n if (this.isDestroyed || this.isDestroying) {\n return;\n }\n const cache = this[RecordStore].cache;\n return cache.getAttr(recordIdentifierFor(this), meta.sourceKey ?? key);\n },\n set(this: Model, key: string, value: Value) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`\n );\n }\n }\n const identifier = recordIdentifierFor(this);\n assert(\n `Attempted to set '${key}' on the deleted record ${identifier.type}:${identifier.id} (${identifier.lid})`,\n !this.currentState.isDeleted\n );\n const cache = this[RecordStore].cache;\n const cacheKey = meta.sourceKey ?? key;\n\n const currentValue = cache.getAttr(identifier, cacheKey);\n if (currentValue !== value) {\n cache.setAttr(identifier, cacheKey, value);\n\n if (!this.isValid) {\n const { errors } = this;\n\n if (errors.get(key)) {\n errors.remove(key);\n this.currentState.cleanErrorRequests();\n }\n }\n }\n\n return value;\n },\n }).meta(meta);\n}\n\n// NOTE: Usage of Explicit ANY\n// -------------------------------------------------------------------\n// any is required here because we are the maximal not the minimal\n// subset of options allowed. If we used unknown, object, or\n// Record<string, unknown> we would get type errors when we try to\n// assert against a more specific implementation with precise options.\n// -------------------------------------------------------------------\n\ntype LooseTransformInstance<V, Raw, Name extends string> = {\n /**\n * value type must match the return type of the deserialize method\n *\n */\n // see note on Explicit ANY above\n // oxlint-disable-next-line typescript/no-explicit-any\n serialize: (value: V, options: any) => Raw;\n /**\n * defaultValue type must match the return type of the deserialize method\n *\n */\n // see note on Explicit ANY above\n // oxlint-disable-next-line typescript/no-explicit-any\n deserialize: (value: Raw, options: any) => V;\n\n [TransformName]: Name;\n};\nexport type TransformHasType = { [TransformName]: string };\n\nexport type TypedTransformInstance<V, T extends string> =\n | LooseTransformInstance<V, string, T>\n | LooseTransformInstance<V, number, T>\n | LooseTransformInstance<V, boolean, T>\n | LooseTransformInstance<V, null, T>\n | LooseTransformInstance<V, ObjectValue, T>\n | LooseTransformInstance<V, ArrayValue, T>\n | LooseTransformInstance<V, string | null, T>\n | LooseTransformInstance<V, number | null, T>\n | LooseTransformInstance<V, boolean | null, T>\n | LooseTransformInstance<V, ObjectValue | null, T>\n | LooseTransformInstance<V, ArrayValue | null, T>;\n\n// see note on Explicit ANY above\n// oxlint-disable-next-line typescript/no-explicit-any\nexport type GetMaybeDeserializeValue<T> = T extends { deserialize: (...args: any[]) => unknown }\n ? ReturnType<T['deserialize']>\n : never;\n\nexport type TypeFromInstance<T> = T extends TransformHasType ? T[typeof TransformName] : never;\nexport type ExtractOptions<T extends TypedTransformInstance<GetMaybeDeserializeValue<T>, TypeFromInstance<T>>> =\n Parameters<T['deserialize']>[1] & Parameters<T['serialize']>[1] & AttrOptions<ReturnType<T['deserialize']>>;\nexport type OptionsFromInstance<T> =\n TypeFromInstance<T> extends never\n ? never\n : GetMaybeDeserializeValue<T> extends never\n ? never\n : T extends TypedTransformInstance<GetMaybeDeserializeValue<T>, TypeFromInstance<T>>\n ? Parameters<T['deserialize']>[1] & Parameters<T['serialize']>[1] & AttrOptions<ReturnType<T['deserialize']>>\n : never;\n\n/**\n * The return type of `void` is a lie to appease TypeScript. The actual return type\n * is a descriptor, but typescript incorrectly insists that decorator functions return\n * `void` or `any`.\n *\n */\nexport type DataDecorator = (target: object, key: string, desc?: DecoratorPropertyDescriptor) => void;\n\n/**\n `attr` defines an attribute on a {@link Model}.\n By default, attributes are passed through as-is, however you can specify an\n optional type to have the value automatically transformed.\n WarpDrive ships with four basic transform types: `string`, `number`,\n `boolean` and `date`. You can define your own transforms by subclassing\n {@link Transform}.\n\n Note that you cannot use `attr` to define an attribute of `id`.\n\n `attr` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `defaultValue`: Pass a string or a function to be called to set the attribute\n to a default value if and only if the key is absent from the payload response.\n\n Example\n\n ```js [app/models/user.js]\n import { Model, attr } from '@warp-drive/legacy/model';\n\n export default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n @attr('boolean', { defaultValue: false }) verified;\n }\n ```\n\n Default value can also be a function. This is useful it you want to return\n a new object for each attribute.\n\n ```js [app/models/user.js]\n import { Model, attr } from '@warp-drive/legacy/model';\n\n export default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n\n @attr({\n defaultValue() {\n return {};\n }\n })\n settings;\n }\n ```\n\n The `options` hash is passed as second argument to a transforms'\n `serialize` and `deserialize` method. This allows to configure a\n transformation and adapt the corresponding value, based on the config:\n\n ```js [app/models/post.js]\n import { Model, attr } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @attr('text', {\n uppercase: true\n })\n text;\n }\n ```\n\n ```js [app/transforms/text.js]\n export default class TextTransform {\n serialize(value, options) {\n if (options.uppercase) {\n return value.toUpperCase();\n }\n\n return value;\n }\n\n deserialize(value) {\n return value;\n }\n\n static create() {\n return new this();\n }\n }\n ```\n\n @summary Legacy `Model` decorator that declares an attribute field, optionally converted by a named transform and\n given a `defaultValue`.\n @public\n @param type the attribute type\n @param options a hash of options\n*/\nexport function attr(): DataDecorator;\nexport function attr<T>(type: TypeFromInstance<T>): DataDecorator;\nexport function attr(type: string): DataDecorator;\nexport function attr(options: AttrOptions): DataDecorator;\nexport function attr<T>(type: TypeFromInstance<T>, options?: OptionsFromInstance<T>): DataDecorator;\nexport function attr(type: string, options?: AttrOptions & object): DataDecorator;\nexport function attr(target: object, key: string | symbol, desc?: PropertyDescriptor): void; // see note on DataDecorator for why void\nexport function attr(\n type?: string | AttrOptions | object,\n options?: (AttrOptions & object) | string | symbol,\n desc?: PropertyDescriptor\n): DataDecorator | void {\n const args = [type, options, desc];\n // see note on DataDecorator for why void\n return isElementDescriptor(args) ? (_attr()(...args) as void) : _attr(type, options as object);\n}\n","import { warn } from '@ember/debug';\nimport { computed } from '@ember/object';\n\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport { RecordStore } from '@warp-drive/core/types/symbols';\n\nimport { lookupLegacySupport } from './legacy-relationships-support.ts';\nimport type { MinimalLegacyRecord } from './model-methods.ts';\n// oxlint-disable-next-line no-unused-vars\nimport type { Model } from './model.ts';\nimport { isElementDescriptor, normalizeModelName } from './util.ts';\n\nexport type IsUnknown<T> = unknown extends T ? true : false;\n\nexport type RelationshipOptions<T, Async extends boolean> = {\n async: Async;\n inverse: null | (IsUnknown<T> extends true ? string : keyof NoNull<T> & string);\n polymorphic?: boolean;\n as?: string;\n linksMode?: true;\n resetOnRemoteUpdate?: boolean;\n\n /**\n * The name of the field as returned by the API and inserted into the\n * cache if it differs from the name of the decorated property.\n *\n * For instance, if the API returns:\n *\n * ```ts\n * {\n * relationships: {\n * 'best-friend': { data: { type: 'user', id: '1' } }\n * }\n * }\n * ```\n *\n * But the app desires to use `record.bestFriend`, then the property\n * should be named `bestFriend` and `sourceKey` should be set to\n * `'best-friend'`.\n *\n * This option is only needed when the value differs from the property name.\n */\n sourceKey?: string;\n};\n\nexport type NoNull<T> = Exclude<T, null>;\n// type BelongsToDecoratorObject<getT> = {\n// get: () => getT;\n// // set: (value: Awaited<getT>) => void;\n// set: (value: getT) => void;\n// // init: () => getT;\n// };\n// oxlint-disable-next-line no-unused-vars\nexport type RelationshipDecorator<T> = <This>(target: This, key: string, desc?: PropertyDescriptor) => void; // BelongsToDecoratorObject<getT>;\n\nfunction _belongsTo<T, Async extends boolean>(\n type: string,\n options: RelationshipOptions<T, Async>\n): RelationshipDecorator<T> {\n assert(\n `Expected options.async from @belongsTo('${type}', options) to be a boolean`,\n options && typeof options.async === 'boolean'\n );\n assert(\n `Expected options.inverse from @belongsTo('${type}', options) to be either null or the string type of the related resource.`,\n options.inverse === null || (typeof options.inverse === 'string' && options.inverse.length > 0)\n );\n\n const meta = {\n type: normalizeModelName(type),\n options: options,\n kind: 'belongsTo',\n name: '<Unknown BelongsTo>',\n sourceKey: options.sourceKey,\n };\n\n return computed({\n get<R extends MinimalLegacyRecord>(this: R, key: string) {\n // this is a legacy behavior we may not carry into a new model setup\n // it's better to error on disconnected records so users find errors\n // in their logic.\n if (this.isDestroying || this.isDestroyed) {\n return null;\n }\n const support = lookupLegacySupport(this);\n\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`\n );\n }\n if (Object.prototype.hasOwnProperty.call(options, 'serialize')) {\n warn(\n `You provided a serialize option on the \"${key}\" property in the \"${support.identifier.type}\" class, this belongs in the serializer. See Serializer and it's implementations https://api.emberjs.com/ember-data/release/classes/Serializer`,\n false,\n {\n id: 'ds.model.serialize-option-in-belongs-to',\n }\n );\n }\n\n if (Object.prototype.hasOwnProperty.call(options, 'embedded')) {\n warn(\n `You provided an embedded option on the \"${key}\" property in the \"${support.identifier.type}\" class, this belongs in the serializer. See EmbeddedRecordsMixin https://api.emberjs.com/ember-data/release/classes/EmbeddedRecordsMixin`,\n false,\n {\n id: 'ds.model.embedded-option-in-belongs-to',\n }\n );\n }\n }\n\n return support.getBelongsTo(key);\n },\n set<R extends MinimalLegacyRecord>(this: R, key: string, value: unknown) {\n assert(`Cannot set belongsTo relationship ${key} on a destroyed record`, !this.isDestroying && !this.isDestroyed);\n if (this.isDestroying || this.isDestroyed) {\n return null;\n }\n const support = lookupLegacySupport(this);\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`\n );\n }\n }\n assertPrivateStore(this[RecordStore]);\n this[RecordStore]._join(() => {\n support.setDirtyBelongsTo(key, value);\n });\n\n return support.getBelongsTo(key);\n },\n }).meta(meta);\n}\n\n/**\n `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None\n relationships on a {@link Model}.\n\n `belongsTo` takes a configuration hash as a second parameter, currently\n supported options are:\n\n - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.\n - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.\n - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic\n - `as`: (*optional*) A string used to declare the abstract type \"this\" record satisfies for polymorphism.\n\n ### Examples\n\n To declare a **one-to-many** (or many-to-many) relationship, use\n `belongsTo` in combination with `hasMany`:\n\n ```js\n // app/models/comment.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Comment extends Model {\n @belongsTo('post', { async: false, inverse: 'comments' }) post;\n }\n\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'post' }) comments;\n }\n ```\n\n To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides:\n\n ```js\n // app/models/author.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Author extends Model {\n @belongsTo('address', { async: true, inverse: 'owner' }) address;\n }\n\n // app/models/address.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Address extends Model {\n @belongsTo('author', { async: true, inverse: 'address' }) owner;\n }\n ```\n\n To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides\n with `null` as the inverse:\n\n ```js\n // app/models/author.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Author extends Model {\n @belongsTo('address', { async: true, inverse: null }) address;\n }\n\n // app/models/address.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Address extends Model {\n @belongsTo('author', { async: true, inverse: null }) owner;\n }\n ```\n\n To declare a one-to-none relationship between two models, use\n `belongsTo` with inverse set to `null` on just one side::\n\n ```js\n // app/models/person.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Person extends Model {\n @belongsTo('person', { async: false, inverse: null }) bestFriend;\n }\n ```\n\n #### Sync vs Async Relationships\n\n WarpDrive fulfills relationships using resource data available in\n the cache.\n\n Sync relationships point directly to the known related resources.\n\n When a relationship is declared as async, if any of the known related\n resources have not been loaded, they will be fetched. The property\n on the record when accessed provides a promise that resolves once\n all resources are loaded.\n\n Async relationships may take advantage of links. On access, if the related\n link has not been loaded, or if any known resources are not available in\n the cache, the fresh state will be fetched using the link.\n\n In contrast to async relationship, accessing a sync relationship\n will error on access when any of the known related resources have\n not been loaded.\n\n If you are using `links` with sync relationships, you have to use\n the BelongsTo reference API to fetch or refresh related resources\n that aren't loaded. For instance, for a `bestFriend` relationship:\n\n ```js\n person.belongsTo('bestFriend').reload();\n ```\n\n #### Polymorphic Relationships\n\n To declare a polymorphic relationship, use `hasMany` with the `polymorphic`\n option set to `true`:\n\n ```js\n // app/models/comment.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Comment extends Model {\n @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;\n }\n ```\n\n `'commentable'` here is referred to as the \"abstract type\" for the polymorphic\n relationship.\n\n Polymorphic relationships with `inverse: null` will accept any type of record as their content.\n Polymorphic relationships with `inverse` set to a string will only accept records with a matching\n inverse relationships declaring itself as satisfying the abstract type.\n\n Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'\n for this relationship.\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;\n }\n ```\n\n Note: every Model that declares an inverse to a polymorphic relationship must\n declare itself exactly the same. This is because polymorphism is based on structural\n traits.\n\n Polymorphic to polymorphic relationships are supported. Both sides of the relationship\n must be declared as polymorphic, and the `as` option must be used to declare the abstract\n type each record satisfies on both sides.\n\n @summary Legacy `Model` decorator that declares a to-one relationship to another resource type, configured with\n required `async` and `inverse` options.\n @public\n @param type the name of the related resource\n @param options a hash of options\n*/\n\nexport function belongsTo(): never;\nexport function belongsTo(type: string): never;\nexport function belongsTo<T>(\n type: TypeFromInstance<NoNull<T>>,\n options: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T>;\n// export function belongsTo<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(\n// type: TypeFromInstance<NoNull<T>>,\n// options: RelationshipOptions<T, true>\n// ): RelationshipDecorator<K>;\nexport function belongsTo(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;\nexport function belongsTo<T>(\n type?: TypeFromInstance<NoNull<T>>,\n options?: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T> {\n if (DEBUG) {\n assert(\n `belongsTo must be invoked with a type and options. Did you mean \\`@belongsTo(${type}, { async: false, inverse: null })\\`?`,\n !isElementDescriptor(arguments as unknown as unknown[])\n );\n }\n return _belongsTo(type!, options!);\n}\n","import { deprecate } from '@ember/debug';\nimport { computed } from '@ember/object';\n\nimport { DEPRECATE_NON_STRICT_TYPES } from '@warp-drive/core/build-config/deprecations';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport { RecordStore } from '@warp-drive/core/types/symbols';\nimport { dasherize, singularize } from '@warp-drive/utilities/string';\n\nimport type { NoNull, RelationshipDecorator, RelationshipOptions } from './belongs-to.ts';\nimport { lookupLegacySupport } from './legacy-relationships-support.ts';\nimport type { MinimalLegacyRecord } from './model-methods.ts';\n// oxlint-disable-next-line no-unused-vars\nimport type { Model } from './model.ts';\nimport { isElementDescriptor } from './util.ts';\n\nfunction normalizeType(type: string) {\n if (DEPRECATE_NON_STRICT_TYPES) {\n const result = singularize(dasherize(type));\n\n deprecate(\n `The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`,\n result === type,\n {\n id: 'ember-data:deprecate-non-strict-types',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '4.13',\n enabled: '5.3',\n },\n }\n );\n\n return result;\n }\n\n return type;\n}\n\nfunction _hasMany<T, Async extends boolean>(\n type: string,\n options: RelationshipOptions<T, Async>\n): RelationshipDecorator<T> {\n assert(`Expected hasMany options.async to be a boolean`, options && typeof options.async === 'boolean');\n\n // Metadata about relationships is stored on the meta of\n // the relationship. This is used for introspection and\n // serialization. Note that `key` is populated lazily\n // the first time the CP is called.\n const meta = {\n type: normalizeType(type),\n options,\n kind: 'hasMany',\n name: '<Unknown BelongsTo>',\n sourceKey: options.sourceKey,\n };\n\n return computed({\n get<R extends MinimalLegacyRecord>(this: R, key: string) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`\n );\n }\n }\n if (this.isDestroying || this.isDestroyed) {\n return [];\n }\n return lookupLegacySupport(this).getHasMany(key);\n },\n set<R extends MinimalLegacyRecord>(this: R, key: string, records: T[]) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`\n );\n }\n }\n const support = lookupLegacySupport(this);\n const manyArray = support.getManyArray(key);\n assert(`You must pass an array of records to set a hasMany relationship`, Array.isArray(records));\n\n assertPrivateStore(this[RecordStore]);\n this[RecordStore]._join(() => {\n manyArray.splice(0, manyArray.length, ...records);\n });\n\n return support.getHasMany(key);\n },\n }).meta(meta);\n}\n\n/**\n `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None\n relationships on a {@link Model}.\n\n `hasMany` takes a configuration hash as a second parameter, currently\n supported options are:\n\n - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.\n - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.\n - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic\n - `as`: (*optional*) A string used to declare the abstract type \"this\" record satisfies for polymorphism.\n\n ### Examples\n\n To declare a **many-to-one** (or one-to-many) relationship, use\n `belongsTo` in combination with `hasMany`:\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'post' }) comments;\n }\n\n\n // app/models/comment.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Comment extends Model {\n @belongsTo('post', { async: false, inverse: 'comments' }) post;\n }\n ```\n\n To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides:\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('tag', { async: true, inverse: 'posts' }) tags;\n }\n\n // app/models/tag.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Tag extends Model {\n @hasMany('post', { async: true, inverse: 'tags' }) posts;\n }\n ```\n\n To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides\n with `null` as the inverse:\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('tag', { async: true, inverse: null }) tags;\n }\n\n // app/models/tag.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Tag extends Model {\n @hasMany('post', { async: true, inverse: null }) posts;\n }\n ```\n\n To declare a many-to-none relationship between two models, use\n `hasMany` with inverse set to `null` on just one side::\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('category', { async: true, inverse: null }) categories;\n }\n ```\n\n #### Sync vs Async Relationships\n\n WarpDrive fulfills relationships using resource data available in\n the cache.\n\n Sync relationships point directly to the known related resources.\n\n When a relationship is declared as async, if any of the known related\n resources have not been loaded, they will be fetched. The property\n on the record when accessed provides a promise that resolves once\n all resources are loaded.\n\n Async relationships may take advantage of links. On access, if the related\n link has not been loaded, or if any known resources are not available in\n the cache, the fresh state will be fetched using the link.\n\n In contrast to async relationship, accessing a sync relationship\n will error on access when any of the known related resources have\n not been loaded.\n\n If you are using `links` with sync relationships, you have to use\n the HasMany reference API to fetch or refresh related resources\n that aren't loaded. For instance, for a `comments` relationship:\n\n ```js\n post.hasMany('comments').reload();\n ```\n\n #### Polymorphic Relationships\n\n To declare a polymorphic relationship, use `hasMany` with the `polymorphic`\n option set to `true`:\n\n ```js\n // app/models/comment.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Comment extends Model {\n @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;\n }\n ```\n\n `'commentable'` here is referred to as the \"abstract type\" for the polymorphic\n relationship.\n\n Polymorphic relationships with `inverse: null` will accept any type of record as their content.\n Polymorphic relationships with `inverse` set to a string will only accept records with a matching\n inverse relationships declaring itself as satisfying the abstract type.\n\n Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'\n for this relationship.\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;\n }\n ```\n\n Note: every Model that declares an inverse to a polymorphic relationship must\n declare itself exactly the same. This is because polymorphism is based on structural\n traits.\n\n Polymorphic to polymorphic relationships are supported. Both sides of the relationship\n must be declared as polymorphic, and the `as` option must be used to declare the abstract\n type each record satisfies on both sides.\n\n @summary Legacy `Model` decorator that declares a to-many relationship to another resource type, configured with\n required `async` and `inverse` options.\n @public\n @param type the name of the related resource\n @param options a hash of options\n*/\nexport function hasMany(): never;\nexport function hasMany(type: string): never;\nexport function hasMany<T>(\n type: TypeFromInstance<NoNull<T>>,\n options: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T>;\n// export function hasMany<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(\n// type: TypeFromInstance<NoNull<T>>,\n// options: RelationshipOptions<T, true>\n// ): RelationshipDecorator<K>;\nexport function hasMany(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;\nexport function hasMany<T>(\n type?: TypeFromInstance<NoNull<T>>,\n options?: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T> {\n if (DEBUG) {\n assert(\n `hasMany must be invoked with a type and options. Did you mean \\`@hasMany(${type}, { async: false, inverse: null })\\`?`,\n !isElementDescriptor(arguments as unknown as unknown[])\n );\n }\n return _hasMany(type!, options!);\n}\n","import { getOwner, setOwner } from '@ember/application';\n\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore, setRecordIdentifier, type Store, StoreMap } from '@warp-drive/core/store/-private';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { TypeFromInstance, TypeFromInstanceOrString } from '@warp-drive/core/types/record';\n\nimport type { Model, ModelStore } from './model.ts';\nimport { getModelFactory } from './schema-provider.ts';\nimport { normalizeModelName } from './util.ts';\n\nfunction recast(context: Store): asserts context is ModelStore {}\n\n/**\n * The `instantiateRecord` hook implementation for use with `Model`. Pass\n * this to your store's `instantiateRecord` method when configuring the\n * store to use `Model` for schema/record instantiation.\n *\n * @summary Legacy store hook that creates a `Model` instance for a resource key using the `Model` class registered\n * for its type.\n * @public\n */\nexport function instantiateRecord(\n this: Store,\n identifier: ResourceKey,\n createRecordArgs?: { [key: string]: unknown }\n): Model {\n const type = identifier.type;\n\n recast(this);\n\n // TODO deprecate allowing unknown args setting\n const createOptions = {\n _createProps: createRecordArgs ?? {},\n // TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for\n _secretInit: {\n identifier,\n store: this,\n cb: secretInit,\n },\n };\n\n // ensure that `getOwner(this)` works inside a model instance\n setOwner(createOptions, getOwner(this)!);\n const factory = getModelFactory(this, type);\n\n assert(`No model was found for '${type}'`, factory);\n return factory.class.create(createOptions);\n}\n\n/**\n * The `teardownRecord` hook implementation for use with `Model`. Pass this\n * to your store's `teardownRecord` method when configuring the store to\n * use `Model` for schema/record instantiation.\n *\n * @summary Legacy store hook that destroys a `Model` instance when the store releases its record.\n * @public\n */\nexport function teardownRecord(record: Model): void {\n assert(\n `expected to receive an instance of Model from @warp-drive/legacy/model. If using a custom model make sure you implement teardownRecord`,\n 'destroy' in record\n );\n record.destroy();\n}\n\n/**\n * The `modelFor` implementation for use with `Model`, exposed on the store\n * as `store.modelFor(type)` when the store is configured to use `Model`.\n * Returns the `Model` subclass registered for the given type, if any.\n *\n * @summary Legacy `store.modelFor` implementation that returns the `Model` class registered for a resource type, if\n * there is one.\n * @public\n */\nexport function modelFor<T>(type: TypeFromInstance<T>): typeof Model | void;\n/**\n * Overload accepting a raw type string instead of a typed record instance.\n *\n * @public\n */\nexport function modelFor(type: string): typeof Model | void;\nexport function modelFor<T>(this: Store, modelName: TypeFromInstanceOrString<T>): typeof Model | void {\n assertPrivateStore(this);\n assert(\n `Attempted to call store.modelFor(), but the store instance has already been destroyed.`,\n !this.isDestroyed && !this.isDestroying\n );\n assert(`You need to pass a model name to the store's modelFor method`, modelName);\n assert(\n `Please pass a proper model name to the store's modelFor method`,\n typeof modelName === 'string' && modelName.length\n );\n recast(this);\n\n const type = normalizeModelName(modelName);\n const maybeFactory = getModelFactory(this, type);\n const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;\n\n const ignoreType = !klass || !klass.isModel || this._forceShim;\n if (!ignoreType) {\n return klass;\n }\n assert(`No model was found for '${type}' and no schema handles the type`, this.schema.hasResource({ type }));\n}\n\nfunction secretInit(record: Model, identifier: ResourceKey, store: Store): void {\n setRecordIdentifier(record, identifier);\n StoreMap.set(record, store);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,SAASI,MAAMC,MAA6BC,SAAuB;CACjE,IAAI,OAAOD,SAAS,UAAU;EAC5BC,UAAUD;EACVA,OAAOE;CACT,OACED,UAAUA,WAAW,CAAC;CAGxB,MAAME,OAAO;EACLH;EACNI,MAAM;EACNC,aAAa;EACJJ;EACTK,WAAWL,QAAQK;EACnBC,KAAK;CACP;CAEA,OAAOZ,SAAS;EACda,IAAiBD,KAAa;GAE1B,IAAI,CAAC,cAAc,CAAC,CAACE,SAASF,GAAG,GAC/B,MAAM,IAAIG,MACR,IAAIH,IAAG,kIAAmI,KAAKI,YAAYC,SAAS,GACtK;GAGJ,IAAI,KAAKC,eAAe,KAAKC,cAC3B;GAGF,OADc,KAAKjB,YAAY,CAACkB,MACnBC,QAAQpB,oBAAoB,IAAI,GAAGO,KAAKG,aAAaC,GAAG;EACvE;EACAU,IAAiBV,KAAaW,OAAc;GAExC,IAAI,CAAC,cAAc,CAAC,CAACT,SAASF,GAAG,GAC/B,MAAM,IAAIG,MACR,IAAIH,IAAG,kIAAmI,KAAKI,YAAYC,SAAS,GACtK;GAGJ,MAAMO,aAAavB,oBAAoB,IAAI;GAC3C,EAAAwB,SAAA;IAAA,IAAA,CAAAA,MAAA,MAAA,IAAAV,MACE,qBAAqBH,IAAG,0BAA2BY,WAAWnB,KAAI,GAAImB,WAAWE,GAAE,IAAKF,WAAWG,IAAG,EAAG;GAAA,EAAA,CACzG,CAAC,KAAKC,aAAaC,SAAS;GAE9B,MAAMT,QAAQ,KAAKlB,YAAY,CAACkB;GAChC,MAAMU,WAAWtB,KAAKG,aAAaC;GAGnC,IADqB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AAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,wIAAwI;CAAA,EAAA,CACxI,aAAaI,MAAM;CAErBA,OAAOC,QAAQ;AACjB;;;;;;;;;;;;;;;AAkBA,SAAgBC,SAAyBC,WAA6D;CACpG1B,mBAAmB,IAAI;CACvB,EAAAkB,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,wFAAwF;CAAA,EAAA,CACxF,CAAC,KAAKQ,eAAe,CAAC,KAAKC,YAAY;CAEzC,EAAAV,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,8DAA8D;CAAA,EAAA,CAAEO,SAAS;CAChF,EAAAR,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,gEAAgE;CAAA,EAAA,CAChE,OAAOO,cAAc,YAAYA,UAAUG,MAAM;CAInD,MAAMnB,OAAON,mBAAmBsB,SAAS;CACzC,MAAMI,eAAe3B,gBAAgB,MAAMO,IAAI;CAC/C,MAAMqB,QAAQD,gBAAgBA,aAAaV,QAAQU,aAAaV,QAAQ;CAGxE,IAAI,EADe,CAACW,SAAS,CAACA,MAAME,WAAW,KAAKC,aAElD,OAAOH;CAET,EAAAb,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,2BAA2BT,KAAI,iCAAkC;CAAA,EAAA,CAAE,KAAKyB,OAAOC,YAAY,EAAE1B,KAAK,CAAC,CAAC;AAC7G;AAEA,SAASM,WAAWO,QAAef,YAAyBM,OAAoB;CAC9Eb,oBAAoBsB,QAAQf,UAAU;CACtCN,SAASmC,IAAId,QAAQT,KAAK;AAC5B"}
|
package/dist/{model-fragments-DSqu0ptR.js → unpkg/dev-deprecated/model-fragments-ZM4k_mT3.js}
RENAMED
|
@@ -24,6 +24,8 @@ function withArrayDefaults(arrayName, primitiveType) {
|
|
|
24
24
|
* Used as a helper to setup the relevant parts of a fragment schema
|
|
25
25
|
* and add extensions etc.
|
|
26
26
|
*
|
|
27
|
+
* @summary Legacy ModelFragments migration helper that builds a `schema-object` field for a single `fragment:`
|
|
28
|
+
* type with the `ember-object` and `fragment` extensions.
|
|
27
29
|
* @param fragmentType The type of the fragment
|
|
28
30
|
* @param fragmentName The optional name of the fragment. If not provided, it will default to the fragmentType.
|
|
29
31
|
* @returns The schema for a fragment
|
|
@@ -43,6 +45,8 @@ function withFragmentDefaults(fragmentType, fragmentName) {
|
|
|
43
45
|
* Used as a helper to setup the relevant parts of a fragment-array
|
|
44
46
|
* schema and add extensions etc.
|
|
45
47
|
*
|
|
48
|
+
* @summary Legacy ModelFragments migration helper that builds a `schema-array` field of `fragment:` items,
|
|
49
|
+
* defaulting to an empty array, with Ember and fragment-array extensions.
|
|
46
50
|
* @param fragmentArrayType The type of the fragment-array
|
|
47
51
|
* @param fragmentArrayName The name of the fragment-array
|
|
48
52
|
* @returns The schema for a fragment-array
|
|
@@ -70,6 +74,8 @@ function withFragmentArrayDefaults(fragmentArrayType, fragmentArrayName) {
|
|
|
70
74
|
* migrated from `Model`, applying the `ember-object` and `fragment` object
|
|
71
75
|
* extensions and a default `@id` identity field.
|
|
72
76
|
*
|
|
77
|
+
* @summary Legacy ModelFragments migration helper that completes a legacy resource schema with an `id` identity,
|
|
78
|
+
* `Model` defaults, and the `ember-object` and `fragment` extensions.
|
|
73
79
|
* @param schema the partial legacy resource schema to complete
|
|
74
80
|
* @returns the completed resource schema
|
|
75
81
|
*/
|
|
@@ -89,6 +95,9 @@ function withLegacy(schema) {
|
|
|
89
95
|
/**
|
|
90
96
|
* The features added to an array resource by {@link FragmentArrayExtension}, providing
|
|
91
97
|
* a subset of the legacy `ModelFragments` fragment-array API for migrated resources.
|
|
98
|
+
*
|
|
99
|
+
* @summary Legacy `ModelFragments`-compatible array API, such as `addFragment`, `removeFragment`, and
|
|
100
|
+
* `rollbackAttributes`, for reactive arrays migrated off fragments.
|
|
92
101
|
*/
|
|
93
102
|
var FragmentArray = class {
|
|
94
103
|
static {
|
|
@@ -153,6 +162,9 @@ var FragmentArray = class {
|
|
|
153
162
|
/**
|
|
154
163
|
* A schema extension that adds the {@link FragmentArray} API to migrated
|
|
155
164
|
* `ModelFragments` array resources.
|
|
165
|
+
*
|
|
166
|
+
* @summary Legacy schema extension named `fragment-array` that adds the `FragmentArray` API to reactive arrays
|
|
167
|
+
* migrated from `ModelFragments`.
|
|
156
168
|
*/
|
|
157
169
|
const FragmentArrayExtension = {
|
|
158
170
|
kind: "array",
|
|
@@ -165,6 +177,9 @@ const FragmentArrayExtension = {
|
|
|
165
177
|
/**
|
|
166
178
|
* The features added to an object resource by {@link FragmentExtension}, providing
|
|
167
179
|
* a subset of the legacy `ModelFragments` fragment API for migrated resources.
|
|
180
|
+
*
|
|
181
|
+
* @summary Legacy `ModelFragments`-compatible object API, such as `hasDirtyAttributes`, `isFragment`, and
|
|
182
|
+
* `rollbackAttributes`, for reactive objects migrated off fragments.
|
|
168
183
|
*/
|
|
169
184
|
var Fragment = class {
|
|
170
185
|
static {
|
|
@@ -224,6 +239,9 @@ var Fragment = class {
|
|
|
224
239
|
/**
|
|
225
240
|
* A schema extension that adds the {@link Fragment} API to migrated
|
|
226
241
|
* `ModelFragments` object resources.
|
|
242
|
+
*
|
|
243
|
+
* @summary Legacy schema extension named `fragment` that adds the `Fragment` API to reactive objects migrated from
|
|
244
|
+
* `ModelFragments`.
|
|
227
245
|
*/
|
|
228
246
|
const FragmentExtension = {
|
|
229
247
|
kind: "object",
|
|
@@ -237,6 +255,8 @@ const FragmentExtension = {
|
|
|
237
255
|
* Registers the {@link FragmentExtension}/{@link FragmentArrayExtension} schema
|
|
238
256
|
* extensions on the given `SchemaService`, enabling ModelFragments migration support.
|
|
239
257
|
*
|
|
258
|
+
* @summary Legacy setup function that registers the fragment and fragment-array schema extensions on a
|
|
259
|
+
* `SchemaService` to support migrating off ModelFragments.
|
|
240
260
|
* @public
|
|
241
261
|
*/
|
|
242
262
|
function registerFragmentExtensions(schema) {
|
|
@@ -325,10 +345,12 @@ function fragmentsModelFor(modelName) {
|
|
|
325
345
|
* type when ModelFragments support is enabled and no real `Model` subclass
|
|
326
346
|
* is registered for that type.
|
|
327
347
|
*
|
|
348
|
+
* @summary Legacy `store.modelFor` fallback that returns a schema-backed `ShimModelClass` for a type when
|
|
349
|
+
* ModelFragments support is on and no `Model` class exists.
|
|
328
350
|
* @public
|
|
329
351
|
*/
|
|
330
352
|
const modelFor = fragmentsModelFor;
|
|
331
353
|
|
|
332
354
|
//#endregion
|
|
333
355
|
export { FragmentExtension as a, withLegacy as c, withArrayDefaults as d, Fragment as i, withFragmentArrayDefaults as l, modelFor as n, FragmentArray as o, registerFragmentExtensions as r, FragmentArrayExtension as s, fragmentsModelFor as t, withFragmentDefaults as u };
|
|
334
|
-
//# sourceMappingURL=model-fragments-
|
|
356
|
+
//# sourceMappingURL=model-fragments-ZM4k_mT3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-fragments-ZM4k_mT3.js","names":["cached","tracked","Context","g","i","n","FragmentArray","prototype","isDestroying","isDestroyed","hasDirtyAttributes","array","context","path","resourceKey","store","record","peekRecord","root","at","changedAttributes","addFragment","fragment","addObject","createFragment","pushObject","removeFragment","index","indexOf","splice","rollbackAttributes","FragmentArrayExtension","kind","name","features","i","cached","tracked","Context","g","i","n","Fragment","prototype","isDestroying","isDestroyed","hasDirtyAttributes","path","resourceKey","store","record","peekRecord","root","at","changedAttributes","isFragment","$type","field","type","rollbackAttributes","oldValue","cache","getRemoteAttr","setAttr","FragmentExtension","kind","name","features","i","FragmentArrayExtension","FragmentExtension","registerFragmentExtensions","schema","CAUTION_MEGA_DANGER_ZONE_registerExtension","initialize","application","store","lookup","console","warn","name"],"sources":["../../../src/model-fragments/utilities/with-array-defaults.ts","../../../src/model-fragments/utilities/with-fragment-defaults.ts","../../../src/model-fragments/utilities/with-fragment-array-defaults.ts","../../../src/model-fragments/utilities/with-legacy.ts","../../../src/model-fragments/extensions/fragment-array.ts","../../../src/model-fragments/extensions/fragment.ts","../../../src/model-fragments/instance-initializers/fragment-extensions.ts","../../../src/model-fragments/hooks/model-for.ts"],"sourcesContent":["/**\n * Used as a helper to setup the relevant parts of an array\n * schema and add extensions etc.\n *\n * @summary Legacy ModelFragments migration helper that builds an `array` schema field preconfigured with the\n * `ember-object`, `ember-array-like`, and `fragment-array` extensions.\n * @param arrayName The name of the array\n * @param primitiveType The primitive type of items in the array (optional)\n * @returns The schema for an array\n */\nexport function withArrayDefaults<ArrayName extends string, PrimitiveType extends string>(\n arrayName: ArrayName,\n primitiveType?: PrimitiveType\n): PrimitiveType extends undefined\n ? {\n /**\n * This field is an `'array'` schema field.\n */\n kind: 'array';\n /**\n * The name of the array field.\n */\n name: ArrayName;\n /**\n * The array's item type, `'array'` since no `primitiveType` was given.\n */\n type: 'array';\n /**\n * The schema options for this array field.\n */\n options: {\n /**\n * The registered array-schema extensions to apply to this array.\n */\n arrayExtensions: string[];\n };\n }\n : {\n /**\n * This field is an `'array'` schema field.\n */\n kind: 'array';\n /**\n * The name of the array field.\n */\n name: ArrayName;\n /**\n * The array's item type, derived from `primitiveType`.\n */\n type: `array:${PrimitiveType}`;\n /**\n * The schema options for this array field.\n */\n options: {\n /**\n * The registered array-schema extensions to apply to this array.\n */\n arrayExtensions: string[];\n };\n };\n\nexport function withArrayDefaults<ArrayName extends string, PrimitiveType extends string>(\n arrayName: ArrayName,\n primitiveType?: PrimitiveType\n) {\n const type = primitiveType ? (`array:${primitiveType}` as const) : ('array' as const);\n return {\n kind: 'array' as const,\n name: arrayName,\n type,\n options: {\n arrayExtensions: ['ember-object', 'ember-array-like', 'fragment-array'],\n },\n };\n}\n","/**\n * Used as a helper to setup the relevant parts of a fragment schema\n * and add extensions etc.\n *\n * @summary Legacy ModelFragments migration helper that builds a `schema-object` field for a single `fragment:`\n * type with the `ember-object` and `fragment` extensions.\n * @param fragmentType The type of the fragment\n * @param fragmentName The optional name of the fragment. If not provided, it will default to the fragmentType.\n * @returns The schema for a fragment\n */\nexport function withFragmentDefaults<FragmentType extends string, FragmentName extends string>(\n fragmentType: FragmentType,\n fragmentName?: FragmentName\n): {\n /**\n * This field is a `'schema-object'` field, a single fragment.\n */\n kind: 'schema-object';\n /**\n * The resource type of the fragment.\n */\n type: `fragment:${FragmentType}`;\n /**\n * The name of the fragment field.\n */\n name: FragmentType | FragmentName;\n /**\n * The schema options for this fragment field.\n */\n options: {\n /**\n * The registered object-schema extensions to apply to this fragment.\n */\n objectExtensions: string[];\n };\n} {\n return {\n kind: 'schema-object' as const,\n type: `fragment:${fragmentType}` as const,\n name: fragmentName ?? fragmentType,\n options: {\n objectExtensions: ['ember-object', 'fragment'],\n },\n };\n}\n","import { pluralize, singularize } from '@warp-drive/utilities/string';\n\n/**\n * Used as a helper to setup the relevant parts of a fragment-array\n * schema and add extensions etc.\n *\n * @summary Legacy ModelFragments migration helper that builds a `schema-array` field of `fragment:` items,\n * defaulting to an empty array, with Ember and fragment-array extensions.\n * @param fragmentArrayType The type of the fragment-array\n * @param fragmentArrayName The name of the fragment-array\n * @returns The schema for a fragment-array\n */\nexport function withFragmentArrayDefaults<FragmentArrayType extends string, FragmentArrayName extends string>(\n fragmentArrayType: FragmentArrayType,\n fragmentArrayName?: FragmentArrayName\n): {\n /**\n * This field is a `'schema-array'` field, an array of fragments.\n */\n kind: 'schema-array';\n /**\n * The resource type of the fragments contained in this array.\n */\n type: `fragment:${string}`;\n /**\n * The name of the fragment-array field.\n */\n name: string;\n /**\n * The schema options for this fragment-array field.\n */\n options: {\n /**\n * The registered array-schema extensions to apply to this array.\n */\n arrayExtensions: string[];\n /**\n * Whether the array defaults to a non-null empty array when unset.\n */\n defaultValue: boolean;\n };\n} {\n return {\n kind: 'schema-array' as const,\n type: `fragment:${singularize(fragmentArrayType)}` as const,\n name: fragmentArrayName ?? pluralize(fragmentArrayType),\n options: {\n arrayExtensions: ['ember-object', 'ember-array-like', 'fragment-array'],\n defaultValue: true,\n },\n };\n}\n","import type { LegacyResourceSchema, ResourceSchema } from '@warp-drive/core/types/schema/fields';\nimport type { WithPartial } from '@warp-drive/core/types/utils';\n\nimport { withDefaults } from '../../model/migration-support';\n\n/**\n * Used as a helper to setup the relevant parts of a legacy resource schema\n * migrated from `Model`, applying the `ember-object` and `fragment` object\n * extensions and a default `@id` identity field.\n *\n * @summary Legacy ModelFragments migration helper that completes a legacy resource schema with an `id` identity,\n * `Model` defaults, and the `ember-object` and `fragment` extensions.\n * @param schema the partial legacy resource schema to complete\n * @returns the completed resource schema\n */\nexport function withLegacy(schema: WithPartial<LegacyResourceSchema, 'legacy' | 'identity'>): ResourceSchema {\n return withDefaults({\n ...schema,\n identity: { kind: '@id', name: 'id' },\n objectExtensions: ['ember-object', 'fragment'],\n });\n}\n","import { cached, tracked } from '@glimmer/tracking';\n\nimport type { CAUTION_MEGA_DANGER_ZONE_Extension } from '@warp-drive/core/reactive';\nimport { Context, type ManagedArray } from '@warp-drive/core/reactive/-private';\n\nimport type Model from '../../model.ts';\nimport type { WithFragmentArray } from '../index.ts';\nimport type { Fragment } from './fragment.ts';\n\n/**\n * The features added to an array resource by {@link FragmentArrayExtension}, providing\n * a subset of the legacy `ModelFragments` fragment-array API for migrated resources.\n *\n * @summary Legacy `ModelFragments`-compatible array API, such as `addFragment`, `removeFragment`, and\n * `rollbackAttributes`, for reactive arrays migrated off fragments.\n */\nexport class FragmentArray<T extends Fragment> {\n // We might want to check the parent values once we move this code to warp-drive.\n /**\n * Whether this fragment array is in the process of being destroyed.\n */\n @tracked isDestroying = false;\n /**\n * Whether this fragment array has been destroyed.\n */\n @tracked isDestroyed = false;\n\n /**\n * Whether this fragment array (or any of its members) has uncommitted changes.\n */\n @cached\n get hasDirtyAttributes(): boolean {\n const array = this as unknown as ManagedArray;\n const context = array[Context];\n const { path, resourceKey, store } = context;\n const record = store.peekRecord(resourceKey) as Model;\n\n if (record.hasDirtyAttributes && path) {\n const root = path.at(0) as string;\n return root in record.changedAttributes();\n }\n\n return false;\n }\n\n /**\n * Adds an existing fragment to this array, if one was given.\n */\n addFragment(fragment?: T): Fragment[] | undefined {\n if (!fragment) {\n return;\n }\n\n return (this as unknown as WithFragmentArray<T>).addObject(fragment);\n }\n\n /**\n * Appends a new fragment to the end of this array, if one was given.\n */\n createFragment(fragment?: T): Fragment | undefined {\n if (!fragment) {\n return;\n }\n\n return (this as unknown as WithFragmentArray<T>).pushObject(fragment);\n }\n\n /**\n * Removes the given fragment from this array, if present.\n */\n removeFragment(fragment?: T): void {\n if (!fragment) {\n return;\n }\n\n const index = (this as unknown as WithFragmentArray<T>).indexOf(fragment);\n\n if (index !== -1) {\n (this as unknown as WithFragmentArray<T>).splice(index, 1);\n }\n }\n\n /**\n * Reverts each member fragment's attribute back to its last known remote value.\n */\n rollbackAttributes(): void {\n for (const fragment of this as unknown as WithFragmentArray<T>) {\n // @ts-expect-error TODO: fix these types\n fragment?.rollbackAttributes?.();\n }\n }\n}\n\n/**\n * A schema extension that adds the {@link FragmentArray} API to migrated\n * `ModelFragments` array resources.\n *\n * @summary Legacy schema extension named `fragment-array` that adds the `FragmentArray` API to reactive arrays\n * migrated from `ModelFragments`.\n */\nexport const FragmentArrayExtension: {\n /**\n * This extension applies to `'array'` schemas.\n */\n kind: 'array';\n /**\n * The registered name of this extension.\n */\n name: 'fragment-array';\n /**\n * The features ({@link FragmentArray}) added by this extension.\n */\n features: typeof FragmentArray;\n} = {\n kind: 'array' as const,\n name: 'fragment-array' as const,\n features: FragmentArray,\n} satisfies CAUTION_MEGA_DANGER_ZONE_Extension;\n\nexport default FragmentArrayExtension;\n","import { cached, tracked } from '@glimmer/tracking';\n\nimport type { CAUTION_MEGA_DANGER_ZONE_Extension } from '@warp-drive/core/reactive';\nimport type { PrivateReactiveResource } from '@warp-drive/core/reactive/-private';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport type { Value } from '@warp-drive/core/types/json/raw';\n\nimport type Model from '../../model.ts';\n\n/**\n * The features added to an object resource by {@link FragmentExtension}, providing\n * a subset of the legacy `ModelFragments` fragment API for migrated resources.\n *\n * @summary Legacy `ModelFragments`-compatible object API, such as `hasDirtyAttributes`, `isFragment`, and\n * `rollbackAttributes`, for reactive objects migrated off fragments.\n */\nexport class Fragment {\n // We might want to check the parent values once we move this code to warp-drive.\n /**\n * Whether this fragment is in the process of being destroyed.\n */\n @tracked isDestroying = false;\n /**\n * Whether this fragment has been destroyed.\n */\n @tracked isDestroyed = false;\n\n /**\n * Whether this fragment (or the attribute it is rooted at) has uncommitted changes.\n */\n @cached\n get hasDirtyAttributes(): boolean {\n const { path, resourceKey, store } = (this as unknown as PrivateReactiveResource)[Context];\n const record = store.peekRecord(resourceKey) as Model;\n\n if (record.hasDirtyAttributes && path) {\n const root = path.at(0) as string;\n return root in record.changedAttributes();\n }\n\n return false;\n }\n\n /**\n * Always `true`. Used to distinguish fragments from other resources.\n */\n get isFragment() {\n return true;\n }\n\n /**\n * The resource type of this fragment, if known.\n */\n get $type(): string | null | undefined {\n const { field } = (this as unknown as PrivateReactiveResource)[Context];\n return field?.type;\n }\n\n /**\n * Reverts this fragment's attribute back to its last known remote value.\n */\n rollbackAttributes(this: PrivateReactiveResource): void {\n const { path, resourceKey, store } = this[Context];\n\n if (path) {\n const oldValue = store.cache.getRemoteAttr(resourceKey, path) as Value;\n store.cache.setAttr(resourceKey, path, oldValue);\n }\n }\n}\n\n/**\n * A schema extension that adds the {@link Fragment} API to migrated\n * `ModelFragments` object resources.\n *\n * @summary Legacy schema extension named `fragment` that adds the `Fragment` API to reactive objects migrated from\n * `ModelFragments`.\n */\nexport const FragmentExtension: {\n /**\n * This extension applies to `'object'` schemas.\n */\n kind: 'object';\n /**\n * The registered name of this extension.\n */\n name: 'fragment';\n /**\n * The features ({@link Fragment}) added by this extension.\n */\n features: typeof Fragment;\n} = {\n kind: 'object' as const,\n name: 'fragment' as const,\n features: Fragment,\n} satisfies CAUTION_MEGA_DANGER_ZONE_Extension;\n\nexport default FragmentExtension;\n","import type ApplicationInstance from '@ember/application/instance';\n\nimport type { Store } from '@warp-drive/core';\nimport type { SchemaService } from '@warp-drive/core/types';\n\nimport FragmentArrayExtension from '../extensions/fragment-array.ts';\nimport FragmentExtension from '../extensions/fragment.ts';\n\n/**\n * Registers the {@link FragmentExtension}/{@link FragmentArrayExtension} schema\n * extensions on the given `SchemaService`, enabling ModelFragments migration support.\n *\n * @summary Legacy setup function that registers the fragment and fragment-array schema extensions on a\n * `SchemaService` to support migrating off ModelFragments.\n * @public\n */\nexport function registerFragmentExtensions(schema: SchemaService): void {\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentExtension);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentArrayExtension);\n}\n\nexport function initialize(application: ApplicationInstance): void {\n const store = application.lookup('service:store') as Store | undefined;\n\n if (store) {\n registerFragmentExtensions(store.schema);\n } else {\n // oxlint-disable-next-line no-console\n console.warn(\n 'No store service was found, you will need to call `registerFragmentExtensions` manually in your app.'\n );\n }\n}\n\nexport default {\n name: 'fragment-extensions',\n // the cast is required for isolatedDeclarations to determine this default\n // export's type without inference, even though it's a no-op for `tsc`'s checker\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion\n initialize: initialize as (application: ApplicationInstance) => void,\n};\n","import type { Store } from '@warp-drive/core';\nimport type { ModelSchema } from '@warp-drive/core/types';\nimport type { Value } from '@warp-drive/core/types/json/raw';\nimport type { TypedRecordInstance, TypeFromInstance } from '@warp-drive/core/types/record';\nimport type { LegacyAttributeField, LegacyRelationshipField } from '@warp-drive/core/types/schema/fields';\n\ntype KeyOrString<T> = keyof T & string extends never ? string : keyof T & string;\n\n// if modelFor turns out to be a bottleneck we should replace with a Map\n// and clear it during store teardown.\nconst AvailableShims = new WeakMap<Store, Record<string, ShimModelClass>>();\n\nexport function getShimClass<T>(\n store: Store,\n modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string\n): ShimModelClass<T> {\n let shims = AvailableShims.get(store);\n\n if (!shims) {\n shims = Object.create(null) as Record<string, ShimModelClass>;\n AvailableShims.set(store, shims);\n }\n\n let shim = shims[modelName];\n if (shim === undefined) {\n shim = shims[modelName] = new ShimModelClass<unknown>(store, modelName);\n }\n\n return shim;\n}\n\nconst AttributeKinds = ['field', 'attribute', 'object', 'array', 'schema-object', 'schema-array'] as const;\n\n// Mimics the static apis of @warp-drive/legacy/model\nexport class ShimModelClass<T = unknown> implements ModelSchema<T> {\n declare __store: Store;\n declare modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;\n constructor(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string) {\n this.__store = store;\n this.modelName = modelName;\n }\n\n get fields(): Map<KeyOrString<T>, 'attribute' | 'belongsTo' | 'hasMany'> {\n const fields = new Map<KeyOrString<T>, 'attribute' | 'belongsTo' | 'hasMany'>();\n const fieldSchemas = this.__store.schema.fields({ type: this.modelName });\n\n fieldSchemas.forEach((schema, key) => {\n // @ts-expect-error checking if a string is a valid string\n if (AttributeKinds.includes(schema.kind)) {\n fields.set(key as KeyOrString<T>, 'attribute');\n } else if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {\n fields.set(key as KeyOrString<T>, schema.kind);\n }\n });\n\n return fields;\n }\n\n get attributes(): Map<KeyOrString<T>, LegacyAttributeField> {\n const attrs = new Map<KeyOrString<T>, LegacyAttributeField>();\n const fields = this.__store.schema.fields({ type: this.modelName });\n\n fields.forEach((schema, key) => {\n if (schema.kind === 'attribute') {\n attrs.set(key as KeyOrString<T>, schema);\n // @ts-expect-error checking if a string is a valid string\n } else if (AttributeKinds.includes(schema.kind)) {\n attrs.set(key as KeyOrString<T>, {\n kind: 'attribute',\n name: key,\n type: null,\n options: (schema.options ?? {}) as Record<string, Value>,\n });\n }\n });\n\n return attrs;\n }\n\n get relationshipsByName(): Map<KeyOrString<T>, LegacyRelationshipField> {\n const rels = new Map<KeyOrString<T>, LegacyRelationshipField>();\n const fields = this.__store.schema.fields({ type: this.modelName });\n\n fields.forEach((schema, key) => {\n if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {\n rels.set(key as KeyOrString<T>, schema);\n }\n });\n\n return rels;\n }\n\n eachAttribute<K extends KeyOrString<T>>(\n callback: (key: K, attribute: LegacyAttributeField) => void,\n binding?: T\n ): void {\n this.attributes.forEach((schema, key) => {\n callback.call(binding, key as K, schema);\n });\n }\n\n eachRelationship<K extends KeyOrString<T>>(\n callback: (key: K, relationship: LegacyRelationshipField) => void,\n binding?: T\n ): void {\n this.__store.schema.fields({ type: this.modelName }).forEach((schema, key) => {\n if (schema.kind === 'belongsTo' || schema.kind === 'hasMany') {\n callback.call(binding, key as K, schema);\n }\n });\n }\n\n eachTransformedAttribute<K extends KeyOrString<T>>(\n callback: (key: K, type: string | null) => void,\n binding?: T\n ): void {\n this.__store.schema.fields({ type: this.modelName }).forEach((schema, key) => {\n if (schema.kind === 'attribute') {\n const type = schema.type;\n if (type) callback.call(binding, key as K, type);\n }\n });\n }\n}\n\nexport function fragmentsModelFor<T extends TypedRecordInstance>(\n this: Store,\n modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string\n): ShimModelClass<T> {\n return getShimClass(this, modelName);\n}\n\n/**\n * The `modelFor` fallback used to construct a `ShimModelClass` schema for a\n * type when ModelFragments support is enabled and no real `Model` subclass\n * is registered for that type.\n *\n * @summary Legacy `store.modelFor` fallback that returns a schema-backed `ShimModelClass` for a type when\n * ModelFragments support is on and no `Model` class exists.\n * @public\n */\nexport const modelFor: typeof fragmentsModelFor = fragmentsModelFor;\n"],"mappings":";;;;;;;AA6DA,SAAgB,kBACd,WACA,eACA;CAEA,OAAO;EACL,MAAM;EACN,MAAM;EACN,MAJW,gBAAiB,SAAS,kBAA6B;EAKlE,SAAS,EACP,iBAAiB;GAAC;GAAgB;GAAoB;EAAgB,EACxE;CACF;AACF;;;;;;;;;;;;;;AChEA,SAAgB,qBACd,cACA,cAuBA;CACA,OAAO;EACL,MAAM;EACN,MAAM,YAAY;EAClB,MAAM,gBAAgB;EACtB,SAAS,EACP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ElC,IAAI,eAAe,SAAS,OAAO,IAAI,GAC5C,MAAM,IAAI,KAAuB;IAC/B,MAAM;IACN,MAAM;IACN,MAAM;IACN,SAAU,OAAO,WAAW,CAAC;GAC/B,CAAC;EAEL,CAAC;EAED,OAAO;CACT;CAEA,IAAI,sBAAoE;EACtE,MAAM,uBAAO,IAAI,IAA6C;EAG9D,AAFe,KAAK,QAAQ,OAAO,OAAO,EAAE,MAAM,KAAK,UAAU,CAE5D,CAAC,CAAC,SAAS,QAAQ,QAAQ;GAC9B,IAAI,OAAO,SAAS,eAAe,OAAO,SAAS,WACjD,KAAK,IAAI,KAAuB,MAAM;EAE1C,CAAC;EAED,OAAO;CACT;CAEA,cACE,UACA,SACM;EACN,KAAK,WAAW,SAAS,QAAQ,QAAQ;GACvC,SAAS,KAAK,SAAS,KAAU,MAAM;EACzC,CAAC;CACH;CAEA,iBACE,UACA,SACM;EACN,KAAK,QAAQ,OAAO,OAAO,EAAE,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,QAAQ,QAAQ;GAC5E,IAAI,OAAO,SAAS,eAAe,OAAO,SAAS,WACjD,SAAS,KAAK,SAAS,KAAU,MAAM;EAE3C,CAAC;CACH;CAEA,yBACE,UACA,SACM;EACN,KAAK,QAAQ,OAAO,OAAO,EAAE,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,QAAQ,QAAQ;GAC5E,IAAI,OAAO,SAAS,aAAa;IAC/B,MAAM,OAAO,OAAO;IACpB,IAAI,MAAM,SAAS,KAAK,SAAS,KAAU,IAAI;GACjD;EACF,CAAC;CACH;AACF;AAEA,SAAgB,kBAEd,WACmB;CACnB,OAAO,aAAa,MAAM,SAAS;AACrC;;;;;;;;;;AAWA,MAAa,WAAqC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as FragmentExtension, c as withLegacy, d as withArrayDefaults, i as Fragment, l as withFragmentArrayDefaults, n as modelFor, o as FragmentArray, r as registerFragmentExtensions, s as FragmentArrayExtension, u as withFragmentDefaults } from "./model-fragments-
|
|
1
|
+
import { a as FragmentExtension, c as withLegacy, d as withArrayDefaults, i as Fragment, l as withFragmentArrayDefaults, n as modelFor, o as FragmentArray, r as registerFragmentExtensions, s as FragmentArrayExtension, u as withFragmentDefaults } from "./model-fragments-ZM4k_mT3.js";
|
|
2
2
|
|
|
3
3
|
export { Fragment, FragmentArray, FragmentArrayExtension, FragmentExtension, modelFor, registerFragmentExtensions, withArrayDefaults, withFragmentArrayDefaults, withFragmentDefaults, withLegacy };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as belongsTo, i as hasMany, n as modelFor, o as attr, r as teardownRecord, t as instantiateRecord } from "./model-
|
|
2
|
-
import { i as restoreDeprecatedModelRequestBehaviors, r as Model, t as buildSchema } from "./schema-provider-
|
|
1
|
+
import { a as belongsTo, i as hasMany, n as modelFor, o as attr, r as teardownRecord, t as instantiateRecord } from "./model-DIvuaUiJ.js";
|
|
2
|
+
import { i as restoreDeprecatedModelRequestBehaviors, r as Model, t as buildSchema } from "./schema-provider-DHS8XOdK.js";
|
|
3
3
|
|
|
4
4
|
export { Model, Model as default, attr, belongsTo, buildSchema, hasMany, instantiateRecord, modelFor, restoreDeprecatedModelRequestBehaviors, teardownRecord };
|
package/dist/unpkg/dev-deprecated/{schema-provider-BM9FSxvx.js → schema-provider-DHS8XOdK.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as FetchManager, t as upgradeStore } from "./-private-BWBRzgZO.js";
|
|
2
2
|
import { n as normalizeModelName } from "./util-CXA3RNYH.js";
|
|
3
|
-
import { i as releaseLegacySupport, n as LEGACY_SUPPORT, r as lookupLegacySupport, t as Errors } from "./errors-
|
|
3
|
+
import { i as releaseLegacySupport, n as LEGACY_SUPPORT, r as lookupLegacySupport, t as Errors } from "./errors-CLRhQKym.js";
|
|
4
4
|
import { n as decorateMethodV2 } from "./runtime--fcdnjmJ-DMTJ0Kb3.js";
|
|
5
5
|
import { recordIdentifierFor, storeFor } from "@warp-drive/core";
|
|
6
6
|
import { getOwner } from "@ember/application";
|
|
@@ -518,6 +518,8 @@ function computeOnce(target, propertyName, desc) {
|
|
|
518
518
|
* the class to use as the reactive object for data of resource
|
|
519
519
|
* of that type.
|
|
520
520
|
*
|
|
521
|
+
* @summary Legacy base class whose subclasses both define a resource type's schema with `attr`, `belongsTo` and
|
|
522
|
+
* `hasMany` and serve as its reactive record.
|
|
521
523
|
* @public
|
|
522
524
|
* @noInheritDoc
|
|
523
525
|
* @hideconstructor
|
|
@@ -1587,6 +1589,9 @@ defineGate(Model.prototype, "isReloading", {
|
|
|
1587
1589
|
* `destroyRecord`, and `reload` onto the given `Model` subclass, for
|
|
1588
1590
|
* apps that have not yet migrated off of the deprecated
|
|
1589
1591
|
* `ENABLE_LEGACY_REQUEST_METHODS` behaviors.
|
|
1592
|
+
*
|
|
1593
|
+
* @summary Legacy opt-in that restores the pre-`RequestManager` `save`, `destroyRecord`, `reload`, and `isReloading`
|
|
1594
|
+
* onto a `Model` class without deprecation warnings.
|
|
1590
1595
|
*/
|
|
1591
1596
|
function restoreDeprecatedModelRequestBehaviors(ModelKlass) {
|
|
1592
1597
|
ModelKlass.prototype.save = _save;
|
|
@@ -1804,6 +1809,8 @@ ModelSchemaProvider.prototype.relationshipsDefinitionFor = function(resource) {
|
|
|
1804
1809
|
* the result of this to your store's `createSchemaService` method when
|
|
1805
1810
|
* configuring the store to use `Model` for schema information.
|
|
1806
1811
|
*
|
|
1812
|
+
* @summary Legacy factory for a schema service that reads resource schemas from an app's `Model` classes, returned from
|
|
1813
|
+
* the store's `createSchemaService` hook.
|
|
1807
1814
|
* @public
|
|
1808
1815
|
*/
|
|
1809
1816
|
function buildSchema(store) {
|
|
@@ -1828,4 +1835,4 @@ function getModelFactory(store, type) {
|
|
|
1828
1835
|
|
|
1829
1836
|
//#endregion
|
|
1830
1837
|
export { save as _, RecordState as a, _save as c, createSnapshot as d, deleteRecord as f, rollbackAttributes as g, reload as h, restoreDeprecatedModelRequestBehaviors as i, belongsTo as l, hasMany as m, getModelFactory as n, _destroyRecord as o, destroyRecord as p, Model as r, _reload as s, buildSchema as t, changedAttributes as u, serialize as v, unloadRecord as y };
|
|
1831
|
-
//# sourceMappingURL=schema-provider-
|
|
1838
|
+
//# sourceMappingURL=schema-provider-DHS8XOdK.js.map
|