@warp-drive/legacy 5.9.0-alpha.21 → 5.9.0-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/-private-DQ6Iap2t.js +193 -0
- package/dist/-private-DQ6Iap2t.js.map +1 -0
- package/dist/-private-DccRZQsm.js +904 -0
- package/dist/-private-DccRZQsm.js.map +1 -0
- package/dist/adapter/-private.d.ts +33 -0
- package/dist/adapter/-private.d.ts.map +1 -0
- package/dist/adapter/-private.js +3 -1
- package/dist/adapter/error.d.ts +2 -0
- package/dist/adapter/error.js +422 -453
- package/dist/adapter/error.js.map +1 -0
- package/{declarations → dist}/adapter/json-api.d.ts +30 -29
- package/dist/adapter/json-api.d.ts.map +1 -0
- package/dist/adapter/json-api.js +265 -143
- package/dist/adapter/json-api.js.map +1 -0
- package/dist/adapter/rest.d.ts +2 -0
- package/dist/adapter/rest.js +937 -1136
- package/dist/adapter/rest.js.map +1 -0
- package/dist/adapter-CARrK3-8.d.ts +784 -0
- package/dist/adapter-CARrK3-8.d.ts.map +1 -0
- package/dist/adapter-XgLAkYVs.js +1130 -0
- package/dist/adapter-XgLAkYVs.js.map +1 -0
- package/dist/adapter.d.ts +2 -0
- package/dist/adapter.js +1 -1248
- package/dist/compat/-private.d.ts +2 -0
- package/dist/compat/-private.js +3 -1
- package/dist/compat/builders.d.ts +169 -0
- package/dist/compat/builders.d.ts.map +1 -0
- package/dist/compat/builders.js +205 -245
- package/dist/compat/builders.js.map +1 -0
- package/dist/compat/extensions.d.ts +2 -0
- package/dist/compat/extensions.js +265 -304
- package/dist/compat/extensions.js.map +1 -0
- package/dist/compat/utils.d.ts +151 -0
- package/dist/compat/utils.d.ts.map +1 -0
- package/dist/compat/utils.js +187 -206
- package/dist/compat/utils.js.map +1 -0
- package/dist/compat-BbNNmTM-.d.ts +1386 -0
- package/dist/compat-BbNNmTM-.d.ts.map +1 -0
- package/dist/compat-g__Pfy2S.js +734 -0
- package/dist/compat-g__Pfy2S.js.map +1 -0
- package/dist/compat.d.ts +2 -0
- package/dist/compat.js +1 -1036
- package/dist/error-CzkyXr1Q.d.ts +435 -0
- package/dist/error-CzkyXr1Q.d.ts.map +1 -0
- package/dist/errors-LQhmDVdd.js +2134 -0
- package/dist/errors-LQhmDVdd.js.map +1 -0
- package/dist/extensions-DumNm4dA.d.ts +102 -0
- package/dist/extensions-DumNm4dA.d.ts.map +1 -0
- package/dist/index.d.ts +243 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +267 -339
- package/dist/index.js.map +1 -0
- package/dist/json-BXNPTlcH.js +1106 -0
- package/dist/json-BXNPTlcH.js.map +1 -0
- package/dist/model/-private.d.ts +3 -0
- package/dist/model/-private.js +3 -1
- package/dist/model/migration-support.d.ts +335 -0
- package/dist/model/migration-support.d.ts.map +1 -0
- package/dist/model/migration-support.js +504 -575
- package/dist/model/migration-support.js.map +1 -0
- package/dist/model-62hn5_PD.d.ts +3107 -0
- package/dist/model-62hn5_PD.d.ts.map +1 -0
- package/dist/model-BtIEHqYZ.js +683 -0
- package/dist/model-BtIEHqYZ.js.map +1 -0
- package/dist/model-fragments-Dpn9285r.js +334 -0
- package/dist/model-fragments-Dpn9285r.js.map +1 -0
- package/dist/model-fragments.d.ts +294 -0
- package/dist/model-fragments.d.ts.map +1 -0
- package/dist/model-fragments.js +2 -94
- package/dist/model.d.ts +404 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +3 -670
- package/{declarations/adapter/rest.d.ts → dist/rest-0NhtexIq.d.ts} +183 -173
- package/dist/rest-0NhtexIq.d.ts.map +1 -0
- package/dist/runtime-BPCpkOf1-BgO3Lyjx.js +53 -0
- package/dist/runtime-BPCpkOf1-BgO3Lyjx.js.map +1 -0
- package/dist/schema-provider-DsKuB5Wb.js +1929 -0
- package/dist/schema-provider-DsKuB5Wb.js.map +1 -0
- package/{declarations → dist}/serializer/json-api.d.ts +3 -0
- package/dist/serializer/json-api.d.ts.map +1 -0
- package/dist/serializer/json-api.js +527 -519
- package/dist/serializer/json-api.js.map +1 -0
- package/{declarations → dist}/serializer/json.d.ts +3 -0
- package/dist/serializer/json.d.ts.map +1 -0
- package/dist/serializer/json.js +3 -6
- package/{declarations/serializer/-private/embedded-records-mixin.d.ts → dist/serializer/rest.d.ts} +56 -1
- package/dist/serializer/rest.d.ts.map +1 -0
- package/dist/serializer/rest.js +958 -1199
- package/dist/serializer/rest.js.map +1 -0
- package/dist/serializer/transform.d.ts +313 -0
- package/dist/serializer/transform.d.ts.map +1 -0
- package/dist/serializer/transform.js +283 -308
- package/dist/serializer/transform.js.map +1 -0
- package/dist/serializer.d.ts +151 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/serializer.js +205 -205
- package/dist/serializer.js.map +1 -0
- package/dist/store-C4qYzXei.js +473 -0
- package/dist/store-C4qYzXei.js.map +1 -0
- package/dist/store.d.ts +13 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +1 -641
- package/dist/unpkg/dev/-private-CrEyBE-B.js +189 -0
- package/dist/unpkg/dev/-private-CrEyBE-B.js.map +1 -0
- package/dist/unpkg/dev/-private-vOhxVExH.js +896 -0
- package/dist/unpkg/dev/-private-vOhxVExH.js.map +1 -0
- package/dist/unpkg/dev/adapter/-private.js +3 -1
- package/dist/unpkg/dev/adapter/error.js +421 -452
- package/dist/unpkg/dev/adapter/error.js.map +1 -0
- package/dist/unpkg/dev/adapter/json-api.js +239 -257
- package/dist/unpkg/dev/adapter/json-api.js.map +1 -0
- package/dist/unpkg/dev/adapter/rest.js +935 -1134
- package/dist/unpkg/dev/adapter/rest.js.map +1 -0
- package/dist/unpkg/dev/adapter-Cw0uSl8d.js +1129 -0
- package/dist/unpkg/dev/adapter-Cw0uSl8d.js.map +1 -0
- package/dist/unpkg/dev/adapter.js +1 -1247
- package/dist/unpkg/dev/compat/-private.js +3 -1
- package/dist/unpkg/dev/compat/builders.js +204 -247
- package/dist/unpkg/dev/compat/builders.js.map +1 -0
- package/dist/unpkg/dev/compat/extensions.js +264 -303
- package/dist/unpkg/dev/compat/extensions.js.map +1 -0
- package/dist/unpkg/dev/compat/utils.js +186 -205
- package/dist/unpkg/dev/compat/utils.js.map +1 -0
- package/dist/unpkg/dev/compat-CeyxXB7K.js +825 -0
- package/dist/unpkg/dev/compat-CeyxXB7K.js.map +1 -0
- package/dist/unpkg/dev/compat.js +1 -1178
- package/dist/unpkg/dev/errors-1javxsPo.js +2127 -0
- package/dist/unpkg/dev/errors-1javxsPo.js.map +1 -0
- package/dist/unpkg/dev/index.js +266 -344
- package/dist/unpkg/dev/index.js.map +1 -0
- package/dist/unpkg/dev/json-DDJji3V3.js +1104 -0
- package/dist/unpkg/dev/json-DDJji3V3.js.map +1 -0
- package/dist/unpkg/dev/model/-private.js +3 -1
- package/dist/unpkg/dev/model/migration-support.js +481 -549
- package/dist/unpkg/dev/model/migration-support.js.map +1 -0
- package/dist/unpkg/dev/model-C9Xb1R1x.js +655 -0
- package/dist/unpkg/dev/model-C9Xb1R1x.js.map +1 -0
- package/dist/unpkg/dev/model-fragments-Dpn9285r.js +334 -0
- package/dist/unpkg/dev/model-fragments-Dpn9285r.js.map +1 -0
- package/dist/unpkg/dev/model-fragments.js +2 -94
- package/dist/unpkg/dev/model.js +3 -681
- package/dist/unpkg/dev/runtime-BPCpkOf1-BgO3Lyjx.js +53 -0
- package/dist/unpkg/dev/runtime-BPCpkOf1-BgO3Lyjx.js.map +1 -0
- package/dist/unpkg/dev/schema-provider-Dy6c1J5f.js +1834 -0
- package/dist/unpkg/dev/schema-provider-Dy6c1J5f.js.map +1 -0
- package/dist/unpkg/dev/serializer/json-api.js +514 -634
- package/dist/unpkg/dev/serializer/json-api.js.map +1 -0
- package/dist/unpkg/dev/serializer/json.js +3 -4
- package/dist/unpkg/dev/serializer/rest.js +954 -1196
- package/dist/unpkg/dev/serializer/rest.js.map +1 -0
- package/dist/unpkg/dev/serializer/transform.js +283 -308
- package/dist/unpkg/dev/serializer/transform.js.map +1 -0
- package/dist/unpkg/dev/serializer.js +205 -205
- package/dist/unpkg/dev/serializer.js.map +1 -0
- package/dist/unpkg/dev/store-D_V8-HQl.js +472 -0
- package/dist/unpkg/dev/store-D_V8-HQl.js.map +1 -0
- package/dist/unpkg/dev/store.js +1 -649
- package/dist/unpkg/dev/util-dSKEgQDp.js +12 -0
- package/dist/unpkg/dev/util-dSKEgQDp.js.map +1 -0
- package/dist/unpkg/dev/utils-DYC9utVJ.js +11 -0
- package/dist/unpkg/dev/utils-DYC9utVJ.js.map +1 -0
- package/dist/unpkg/dev-deprecated/-private-CrEyBE-B.js +189 -0
- package/dist/unpkg/dev-deprecated/-private-CrEyBE-B.js.map +1 -0
- package/dist/unpkg/dev-deprecated/-private-vOhxVExH.js +896 -0
- package/dist/unpkg/dev-deprecated/-private-vOhxVExH.js.map +1 -0
- package/dist/unpkg/dev-deprecated/adapter/-private.js +3 -1
- package/dist/unpkg/dev-deprecated/adapter/error.js +421 -452
- package/dist/unpkg/dev-deprecated/adapter/error.js.map +1 -0
- package/dist/unpkg/dev-deprecated/adapter/json-api.js +239 -257
- package/dist/unpkg/dev-deprecated/adapter/json-api.js.map +1 -0
- package/dist/unpkg/dev-deprecated/adapter/rest.js +935 -1134
- package/dist/unpkg/dev-deprecated/adapter/rest.js.map +1 -0
- package/dist/unpkg/dev-deprecated/adapter-Cw0uSl8d.js +1129 -0
- package/dist/unpkg/dev-deprecated/adapter-Cw0uSl8d.js.map +1 -0
- package/dist/unpkg/dev-deprecated/adapter.js +1 -1247
- package/dist/unpkg/dev-deprecated/compat/-private.js +3 -1
- package/dist/unpkg/dev-deprecated/compat/builders.js +204 -247
- package/dist/unpkg/dev-deprecated/compat/builders.js.map +1 -0
- package/dist/unpkg/dev-deprecated/compat/extensions.js +264 -303
- package/dist/unpkg/dev-deprecated/compat/extensions.js.map +1 -0
- package/dist/unpkg/dev-deprecated/compat/utils.js +186 -205
- package/dist/unpkg/dev-deprecated/compat/utils.js.map +1 -0
- package/dist/unpkg/dev-deprecated/compat-DmAgB2NS.js +825 -0
- package/dist/unpkg/dev-deprecated/compat-DmAgB2NS.js.map +1 -0
- package/dist/unpkg/dev-deprecated/compat.js +1 -1178
- package/dist/unpkg/dev-deprecated/errors-C4_aOhY5.js +2128 -0
- package/dist/unpkg/dev-deprecated/errors-C4_aOhY5.js.map +1 -0
- package/dist/unpkg/dev-deprecated/index.js +266 -343
- package/dist/unpkg/dev-deprecated/index.js.map +1 -0
- package/dist/unpkg/dev-deprecated/json-DDJji3V3.js +1104 -0
- package/dist/unpkg/dev-deprecated/json-DDJji3V3.js.map +1 -0
- package/dist/unpkg/dev-deprecated/model/-private.js +3 -1
- package/dist/unpkg/dev-deprecated/model/migration-support.js +492 -566
- package/dist/unpkg/dev-deprecated/model/migration-support.js.map +1 -0
- package/dist/unpkg/dev-deprecated/model-CvSMYkgs.js +660 -0
- package/dist/unpkg/dev-deprecated/model-CvSMYkgs.js.map +1 -0
- package/dist/unpkg/dev-deprecated/model-fragments-Dpn9285r.js +334 -0
- package/dist/unpkg/dev-deprecated/model-fragments-Dpn9285r.js.map +1 -0
- package/dist/unpkg/dev-deprecated/model-fragments.js +2 -94
- package/dist/unpkg/dev-deprecated/model.js +3 -685
- package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-BgO3Lyjx.js +53 -0
- package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-BgO3Lyjx.js.map +1 -0
- package/dist/unpkg/dev-deprecated/schema-provider-Cqttza94.js +1835 -0
- package/dist/unpkg/dev-deprecated/schema-provider-Cqttza94.js.map +1 -0
- package/dist/unpkg/dev-deprecated/serializer/json-api.js +514 -634
- package/dist/unpkg/dev-deprecated/serializer/json-api.js.map +1 -0
- package/dist/unpkg/dev-deprecated/serializer/json.js +3 -4
- package/dist/unpkg/dev-deprecated/serializer/rest.js +954 -1196
- package/dist/unpkg/dev-deprecated/serializer/rest.js.map +1 -0
- package/dist/unpkg/dev-deprecated/serializer/transform.js +283 -308
- package/dist/unpkg/dev-deprecated/serializer/transform.js.map +1 -0
- package/dist/unpkg/dev-deprecated/serializer.js +205 -205
- package/dist/unpkg/dev-deprecated/serializer.js.map +1 -0
- package/dist/unpkg/dev-deprecated/store-BX7GvXC_.js +472 -0
- package/dist/unpkg/dev-deprecated/store-BX7GvXC_.js.map +1 -0
- package/dist/unpkg/dev-deprecated/store.js +1 -649
- package/dist/unpkg/dev-deprecated/util-9mgEBJ3W.js +18 -0
- package/dist/unpkg/dev-deprecated/util-9mgEBJ3W.js.map +1 -0
- package/dist/unpkg/dev-deprecated/utils-Cl86-e7F.js +17 -0
- package/dist/unpkg/dev-deprecated/utils-Cl86-e7F.js.map +1 -0
- package/dist/unpkg/prod/-private-B4bxoTuK.js +160 -0
- package/dist/unpkg/prod/-private-B4bxoTuK.js.map +1 -0
- package/dist/unpkg/prod/-private-SfXkkHKd.js +745 -0
- package/dist/unpkg/prod/-private-SfXkkHKd.js.map +1 -0
- package/dist/unpkg/prod/adapter/-private.js +3 -1
- package/dist/unpkg/prod/adapter/error.js +418 -447
- package/dist/unpkg/prod/adapter/error.js.map +1 -0
- package/dist/unpkg/prod/adapter/json-api.js +236 -252
- package/dist/unpkg/prod/adapter/json-api.js.map +1 -0
- package/dist/unpkg/prod/adapter/rest.js +911 -1097
- package/dist/unpkg/prod/adapter/rest.js.map +1 -0
- package/dist/unpkg/prod/adapter-Wnk7jizX.js +1111 -0
- package/dist/unpkg/prod/adapter-Wnk7jizX.js.map +1 -0
- package/dist/unpkg/prod/adapter.js +1 -1214
- package/dist/unpkg/prod/compat/-private.js +3 -1
- package/dist/unpkg/prod/compat/builders.js +165 -182
- package/dist/unpkg/prod/compat/builders.js.map +1 -0
- package/dist/unpkg/prod/compat/extensions.js +252 -283
- package/dist/unpkg/prod/compat/extensions.js.map +1 -0
- package/dist/unpkg/prod/compat/utils.js +183 -200
- package/dist/unpkg/prod/compat/utils.js.map +1 -0
- package/dist/unpkg/prod/compat-CJ87MzDn.js +547 -0
- package/dist/unpkg/prod/compat-CJ87MzDn.js.map +1 -0
- package/dist/unpkg/prod/compat.js +1 -742
- package/dist/unpkg/prod/errors-Co7YWHoA.js +1977 -0
- package/dist/unpkg/prod/errors-Co7YWHoA.js.map +1 -0
- package/dist/unpkg/prod/index.js +245 -308
- package/dist/unpkg/prod/index.js.map +1 -0
- package/dist/unpkg/prod/json-BD1kRTfB.js +1080 -0
- package/dist/unpkg/prod/json-BD1kRTfB.js.map +1 -0
- package/dist/unpkg/prod/model/-private.js +3 -1
- package/dist/unpkg/prod/model/migration-support.js +477 -542
- package/dist/unpkg/prod/model/migration-support.js.map +1 -0
- package/dist/unpkg/prod/model-BzoOmtka.js +603 -0
- package/dist/unpkg/prod/model-BzoOmtka.js.map +1 -0
- package/dist/unpkg/prod/model-fragments-Dpn9285r.js +334 -0
- package/dist/unpkg/prod/model-fragments-Dpn9285r.js.map +1 -0
- package/dist/unpkg/prod/model-fragments.js +2 -94
- package/dist/unpkg/prod/model.js +3 -596
- package/dist/unpkg/prod/runtime-BPCpkOf1-BgO3Lyjx.js +53 -0
- package/dist/unpkg/prod/runtime-BPCpkOf1-BgO3Lyjx.js.map +1 -0
- package/dist/unpkg/prod/schema-provider-CKZcqWyP.js +1622 -0
- package/dist/unpkg/prod/schema-provider-CKZcqWyP.js.map +1 -0
- package/dist/unpkg/prod/serializer/json-api.js +497 -592
- package/dist/unpkg/prod/serializer/json-api.js.map +1 -0
- package/dist/unpkg/prod/serializer/json.js +3 -4
- package/dist/unpkg/prod/serializer/rest.js +938 -1166
- package/dist/unpkg/prod/serializer/rest.js.map +1 -0
- package/dist/unpkg/prod/serializer/transform.js +283 -308
- package/dist/unpkg/prod/serializer/transform.js.map +1 -0
- package/dist/unpkg/prod/serializer.js +205 -205
- package/dist/unpkg/prod/serializer.js.map +1 -0
- package/dist/unpkg/prod/store-RGGc1ilN.js +392 -0
- package/dist/unpkg/prod/store-RGGc1ilN.js.map +1 -0
- package/dist/unpkg/prod/store.js +1 -517
- package/dist/unpkg/prod/util-dSKEgQDp.js +12 -0
- package/dist/unpkg/prod/util-dSKEgQDp.js.map +1 -0
- package/dist/unpkg/prod/utils-DYC9utVJ.js +11 -0
- package/dist/unpkg/prod/utils-DYC9utVJ.js.map +1 -0
- package/dist/unpkg/prod-deprecated/-private-B4bxoTuK.js +160 -0
- package/dist/unpkg/prod-deprecated/-private-B4bxoTuK.js.map +1 -0
- package/dist/unpkg/prod-deprecated/-private-SfXkkHKd.js +745 -0
- package/dist/unpkg/prod-deprecated/-private-SfXkkHKd.js.map +1 -0
- package/dist/unpkg/prod-deprecated/adapter/-private.js +3 -1
- package/dist/unpkg/prod-deprecated/adapter/error.js +418 -447
- package/dist/unpkg/prod-deprecated/adapter/error.js.map +1 -0
- package/dist/unpkg/prod-deprecated/adapter/json-api.js +236 -252
- package/dist/unpkg/prod-deprecated/adapter/json-api.js.map +1 -0
- package/dist/unpkg/prod-deprecated/adapter/rest.js +911 -1097
- package/dist/unpkg/prod-deprecated/adapter/rest.js.map +1 -0
- package/{declarations/adapter.d.ts → dist/unpkg/prod-deprecated/adapter-Wnk7jizX.js} +445 -110
- package/dist/unpkg/prod-deprecated/adapter-Wnk7jizX.js.map +1 -0
- package/dist/unpkg/prod-deprecated/adapter.js +1 -1214
- package/dist/unpkg/prod-deprecated/compat/-private.js +3 -1
- package/dist/unpkg/prod-deprecated/compat/builders.js +165 -182
- package/dist/unpkg/prod-deprecated/compat/builders.js.map +1 -0
- package/dist/unpkg/prod-deprecated/compat/extensions.js +252 -283
- package/dist/unpkg/prod-deprecated/compat/extensions.js.map +1 -0
- package/dist/unpkg/prod-deprecated/compat/utils.js +183 -200
- package/dist/unpkg/prod-deprecated/compat/utils.js.map +1 -0
- package/dist/unpkg/prod-deprecated/compat-CJ87MzDn.js +547 -0
- package/dist/unpkg/prod-deprecated/compat-CJ87MzDn.js.map +1 -0
- package/dist/unpkg/prod-deprecated/compat.js +1 -742
- package/dist/unpkg/prod-deprecated/errors-C-opde61.js +1978 -0
- package/dist/unpkg/prod-deprecated/errors-C-opde61.js.map +1 -0
- package/dist/unpkg/prod-deprecated/index.js +245 -307
- package/dist/unpkg/prod-deprecated/index.js.map +1 -0
- package/dist/unpkg/prod-deprecated/json-BD1kRTfB.js +1080 -0
- package/dist/unpkg/prod-deprecated/json-BD1kRTfB.js.map +1 -0
- package/dist/unpkg/prod-deprecated/model/-private.js +3 -1
- package/dist/unpkg/prod-deprecated/model/migration-support.js +488 -559
- package/dist/unpkg/prod-deprecated/model/migration-support.js.map +1 -0
- package/dist/unpkg/prod-deprecated/model-C0bTXzGn.js +604 -0
- package/dist/unpkg/prod-deprecated/model-C0bTXzGn.js.map +1 -0
- package/dist/unpkg/prod-deprecated/model-fragments-Dpn9285r.js +334 -0
- package/dist/unpkg/prod-deprecated/model-fragments-Dpn9285r.js.map +1 -0
- package/dist/unpkg/prod-deprecated/model-fragments.js +2 -94
- package/dist/unpkg/prod-deprecated/model.js +3 -599
- package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-BgO3Lyjx.js +53 -0
- package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-BgO3Lyjx.js.map +1 -0
- package/dist/unpkg/prod-deprecated/schema-provider-lH3qP5tw.js +1635 -0
- package/dist/unpkg/prod-deprecated/schema-provider-lH3qP5tw.js.map +1 -0
- package/dist/unpkg/prod-deprecated/serializer/json-api.js +497 -592
- package/dist/unpkg/prod-deprecated/serializer/json-api.js.map +1 -0
- package/dist/unpkg/prod-deprecated/serializer/json.js +3 -4
- package/dist/unpkg/prod-deprecated/serializer/rest.js +938 -1166
- package/dist/unpkg/prod-deprecated/serializer/rest.js.map +1 -0
- package/dist/unpkg/prod-deprecated/serializer/transform.js +283 -308
- package/dist/unpkg/prod-deprecated/serializer/transform.js.map +1 -0
- package/dist/unpkg/prod-deprecated/serializer.js +205 -205
- package/dist/unpkg/prod-deprecated/serializer.js.map +1 -0
- package/dist/unpkg/prod-deprecated/store-0L2CkYzh.js +392 -0
- package/dist/unpkg/prod-deprecated/store-0L2CkYzh.js.map +1 -0
- package/dist/unpkg/prod-deprecated/store.js +1 -517
- package/dist/unpkg/prod-deprecated/util-CQQdHX3n.js +14 -0
- package/dist/unpkg/prod-deprecated/util-CQQdHX3n.js.map +1 -0
- package/dist/unpkg/prod-deprecated/utils-BMI_JwFP.js +13 -0
- package/dist/unpkg/prod-deprecated/utils-BMI_JwFP.js.map +1 -0
- package/dist/util-Bnx8nm-D.js +29 -0
- package/dist/util-Bnx8nm-D.js.map +1 -0
- package/dist/utils-ZAytYep8.js +28 -0
- package/dist/utils-ZAytYep8.js.map +1 -0
- package/package.json +13 -13
- package/declarations/adapter/-private/build-url-mixin.d.ts +0 -189
- package/declarations/adapter/-private/fastboot-interface.d.ts +0 -8
- package/declarations/adapter/-private/utils/continue-on-reject.d.ts +0 -1
- package/declarations/adapter/-private/utils/determine-body-promise.d.ts +0 -4
- package/declarations/adapter/-private/utils/fetch.d.ts +0 -8
- package/declarations/adapter/-private/utils/parse-response-headers.d.ts +0 -1
- package/declarations/adapter/-private/utils/serialize-into-hash.d.ts +0 -6
- package/declarations/adapter/-private/utils/serialize-query-params.d.ts +0 -5
- package/declarations/adapter/-private.d.ts +0 -5
- package/declarations/adapter/error.d.ts +0 -431
- package/declarations/compat/-private.d.ts +0 -13
- package/declarations/compat/builders/find-all.d.ts +0 -34
- package/declarations/compat/builders/find-record.d.ts +0 -56
- package/declarations/compat/builders/query.d.ts +0 -66
- package/declarations/compat/builders/save-record.d.ts +0 -34
- package/declarations/compat/builders/utils.d.ts +0 -3
- package/declarations/compat/builders.d.ts +0 -14
- package/declarations/compat/extensions.d.ts +0 -99
- package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +0 -55
- package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +0 -2
- package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +0 -11
- package/declarations/compat/legacy-network-handler/legacy-data-utils.d.ts +0 -5
- package/declarations/compat/legacy-network-handler/legacy-network-handler.d.ts +0 -9
- package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +0 -528
- package/declarations/compat/legacy-network-handler/minimum-serializer-interface.d.ts +0 -220
- package/declarations/compat/legacy-network-handler/serializer-response.d.ts +0 -6
- package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +0 -110
- package/declarations/compat/legacy-network-handler/snapshot.d.ts +0 -255
- package/declarations/compat/utils.d.ts +0 -148
- package/declarations/compat.d.ts +0 -189
- package/declarations/index.d.ts +0 -244
- package/declarations/model/-private/attr.d.ts +0 -191
- package/declarations/model/-private/belongs-to.d.ts +0 -195
- package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +0 -5
- package/declarations/model/-private/errors.d.ts +0 -289
- package/declarations/model/-private/has-many.d.ts +0 -162
- package/declarations/model/-private/hooks.d.ts +0 -36
- package/declarations/model/-private/legacy-relationships-support.d.ts +0 -47
- package/declarations/model/-private/model-for-mixin.d.ts +0 -3
- package/declarations/model/-private/model-methods.d.ts +0 -39
- package/declarations/model/-private/model.d.ts +0 -1279
- package/declarations/model/-private/notify-changes.d.ts +0 -4
- package/declarations/model/-private/promise-belongs-to.d.ts +0 -40
- package/declarations/model/-private/promise-many-array.d.ts +0 -130
- package/declarations/model/-private/record-state.d.ts +0 -58
- package/declarations/model/-private/references/belongs-to.d.ts +0 -488
- package/declarations/model/-private/references/has-many.d.ts +0 -498
- package/declarations/model/-private/schema-provider.d.ts +0 -66
- package/declarations/model/-private/type-utils.d.ts +0 -57
- package/declarations/model/-private/util.d.ts +0 -5
- package/declarations/model/-private.d.ts +0 -8
- package/declarations/model/migration-support.d.ts +0 -306
- package/declarations/model-fragments/extensions/fragment-array.d.ts +0 -54
- package/declarations/model-fragments/extensions/fragment.d.ts +0 -50
- package/declarations/model-fragments/hooks/model-for.d.ts +0 -27
- package/declarations/model-fragments/index.d.ts +0 -13
- package/declarations/model-fragments/instance-initializers/fragment-extensions.d.ts +0 -15
- package/declarations/model-fragments/utilities/with-array-defaults.d.ts +0 -56
- package/declarations/model-fragments/utilities/with-fragment-array-defaults.d.ts +0 -38
- package/declarations/model-fragments/utilities/with-fragment-defaults.d.ts +0 -34
- package/declarations/model-fragments/utilities/with-legacy.d.ts +0 -11
- package/declarations/model-fragments.d.ts +0 -9
- package/declarations/model.d.ts +0 -49
- package/declarations/serializer/-private/transforms/boolean.d.ts +0 -60
- package/declarations/serializer/-private/transforms/date.d.ts +0 -42
- package/declarations/serializer/-private/transforms/number.d.ts +0 -42
- package/declarations/serializer/-private/transforms/string.d.ts +0 -42
- package/declarations/serializer/-private/transforms/transform.d.ts +0 -118
- package/declarations/serializer/-private/utils.d.ts +0 -27
- package/declarations/serializer/rest.d.ts +0 -51
- package/declarations/serializer/transform.d.ts +0 -5
- package/declarations/serializer.d.ts +0 -252
- package/declarations/store/-private.d.ts +0 -223
- package/declarations/store.d.ts +0 -10
- package/dist/-private-BG3bMiKp.js +0 -1211
- package/dist/errors-DZKA206g.js +0 -2589
- package/dist/hooks-BvOqJBei.js +0 -105
- package/dist/json-DU8m1pGf.js +0 -1336
- package/dist/model-for-CXkJw59V.js +0 -297
- package/dist/runtime-BPCpkOf1-BKOwiRJp.js +0 -65
- package/dist/schema-provider-DtPOp0d7.js +0 -2382
- package/dist/serialize-into-hash-DPZYoF-i.js +0 -261
- package/dist/unpkg/dev/-private-DtjBbEgy.js +0 -1206
- package/dist/unpkg/dev/errors-DngRU-If.js +0 -2585
- package/dist/unpkg/dev/hooks-UuiLxWxS.js +0 -104
- package/dist/unpkg/dev/json-K2Y9z6MN.js +0 -1333
- package/dist/unpkg/dev/model-for-CXkJw59V.js +0 -297
- package/dist/unpkg/dev/runtime-BPCpkOf1-BKOwiRJp.js +0 -65
- package/dist/unpkg/dev/schema-provider-0D7f-QOn.js +0 -2272
- package/dist/unpkg/dev/serialize-into-hash-B2xDbuo5.js +0 -259
- package/dist/unpkg/dev/util-DvanW33H.js +0 -20
- package/dist/unpkg/dev/utils-BhvS1iTS.js +0 -8
- package/dist/unpkg/dev-deprecated/-private-DtjBbEgy.js +0 -1206
- package/dist/unpkg/dev-deprecated/errors-Bzidntpi.js +0 -2588
- package/dist/unpkg/dev-deprecated/hooks-DVXhMW14.js +0 -104
- package/dist/unpkg/dev-deprecated/json-K2Y9z6MN.js +0 -1333
- package/dist/unpkg/dev-deprecated/model-for-CXkJw59V.js +0 -297
- package/dist/unpkg/dev-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +0 -65
- package/dist/unpkg/dev-deprecated/schema-provider-ZwO5_fZw.js +0 -2292
- package/dist/unpkg/dev-deprecated/serialize-into-hash-B2xDbuo5.js +0 -259
- package/dist/unpkg/dev-deprecated/util-CWr5WQOT.js +0 -24
- package/dist/unpkg/dev-deprecated/utils-C9PJehtL.js +0 -12
- package/dist/unpkg/prod/-private-BdyZaGEh.js +0 -971
- package/dist/unpkg/prod/errors-B-PWeYlW.js +0 -2337
- package/dist/unpkg/prod/hooks-Bx-zBziU.js +0 -72
- package/dist/unpkg/prod/json-Qewu-UN9.js +0 -1300
- package/dist/unpkg/prod/model-for-CXkJw59V.js +0 -297
- package/dist/unpkg/prod/runtime-BPCpkOf1-BKOwiRJp.js +0 -65
- package/dist/unpkg/prod/schema-provider-BgRqk8i9.js +0 -1951
- package/dist/unpkg/prod/serialize-into-hash-DGlzQteF.js +0 -215
- package/dist/unpkg/prod/util-DvanW33H.js +0 -20
- package/dist/unpkg/prod/utils-BhvS1iTS.js +0 -8
- package/dist/unpkg/prod-deprecated/-private-BdyZaGEh.js +0 -971
- package/dist/unpkg/prod-deprecated/errors-Dl2J9d1D.js +0 -2340
- package/dist/unpkg/prod-deprecated/hooks-Cm60wWTf.js +0 -72
- package/dist/unpkg/prod-deprecated/json-Qewu-UN9.js +0 -1300
- package/dist/unpkg/prod-deprecated/model-for-CXkJw59V.js +0 -297
- package/dist/unpkg/prod-deprecated/runtime-BPCpkOf1-BKOwiRJp.js +0 -65
- package/dist/unpkg/prod-deprecated/schema-provider-Dh6tRqVI.js +0 -1980
- package/dist/unpkg/prod-deprecated/serialize-into-hash-DGlzQteF.js +0 -215
- package/dist/unpkg/prod-deprecated/util-B6cn-i93.js +0 -23
- package/dist/unpkg/prod-deprecated/utils-BUWwQwCh.js +0 -11
- package/dist/util-Dul6TZts.js +0 -35
- package/dist/utils-Cqw9eRj5.js +0 -23
|
@@ -0,0 +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","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 // eslint-disable-next-line @typescript-eslint/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 // eslint-disable-next-line @typescript-eslint/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 // eslint-disable-next-line @typescript-eslint/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 // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this._isReloading;\n },\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n set isReloading(v) {\n // @ts-expect-error\n // eslint-disable-next-line @typescript-eslint/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 // eslint-disable-next-line @typescript-eslint/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 // eslint-disable-next-line @typescript-eslint/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;AAEj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CkC,WAAqD;EAC9F,KAAK1B,WAAWR,2CAA4CkC,SAAS;CACvE;CAEAC,4CACEvB,UACuC;EACvC,OAAO,KAAKJ,WAAW2B,4CAA6CvB,QAAQ;CAC9E;CAEAwB,0CACE9D,OACA+D,cACuC;EACvC,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,SAAU/F,MAAc;CAExE,OAAO,KAAKwD,WAAWuC,gBAAgB/F,IAAI,KAAK,KAAKyD,WAAWsC,gBAAgB/F,IAAI,KAAK;AAC3F"}
|
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
import { n as normalizeModelName, t as isElementDescriptor } from "./util-CQQdHX3n.js";
|
|
2
|
+
import { r as lookupLegacySupport } from "./errors-C-opde61.js";
|
|
3
|
+
import { n as getModelFactory } from "./schema-provider-lH3qP5tw.js";
|
|
4
|
+
import { recordIdentifierFor } from "@warp-drive/core";
|
|
5
|
+
import { getOwner, setOwner } from "@ember/application";
|
|
6
|
+
import { StoreMap, assertPrivateStore, setRecordIdentifier } from "@warp-drive/core/store/-private";
|
|
7
|
+
import { computed } from "@ember/object";
|
|
8
|
+
import { RecordStore } from "@warp-drive/core/types/symbols";
|
|
9
|
+
import { dasherize, singularize } from "@warp-drive/utilities/string";
|
|
10
|
+
|
|
11
|
+
//#region src/model/-private/attr.ts
|
|
12
|
+
/**
|
|
13
|
+
* Options provided to the attr decorator are
|
|
14
|
+
* supplied to the associated transform. Any
|
|
15
|
+
* key-value pair is valid; however, it is highly
|
|
16
|
+
* recommended to only use statically defined values
|
|
17
|
+
* that could be serialized to JSON.
|
|
18
|
+
*
|
|
19
|
+
* If no transform is provided, the only valid
|
|
20
|
+
* option is `defaultValue`.
|
|
21
|
+
*
|
|
22
|
+
* Examples:
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* class User extends Model {
|
|
26
|
+
* @attr('string', { defaultValue: 'Anonymous' }) name;
|
|
27
|
+
* @attr('date', { defaultValue: () => new Date() }) createdAt;
|
|
28
|
+
* @attr({ defaultValue: () => ({}) }) preferences;
|
|
29
|
+
* @attr('boolean') hasVerifiedEmail;
|
|
30
|
+
* @attr address;
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* @class NOTATHING
|
|
34
|
+
*/
|
|
35
|
+
function _attr(type, options) {
|
|
36
|
+
if (typeof type === "object") {
|
|
37
|
+
options = type;
|
|
38
|
+
type = void 0;
|
|
39
|
+
} else options = options || {};
|
|
40
|
+
const meta = {
|
|
41
|
+
type,
|
|
42
|
+
kind: "attribute",
|
|
43
|
+
isAttribute: true,
|
|
44
|
+
options,
|
|
45
|
+
sourceKey: options.sourceKey,
|
|
46
|
+
key: null
|
|
47
|
+
};
|
|
48
|
+
return computed({
|
|
49
|
+
get(key) {
|
|
50
|
+
if (this.isDestroyed || this.isDestroying) return;
|
|
51
|
+
return this[RecordStore].cache.getAttr(recordIdentifierFor(this), meta.sourceKey ?? key);
|
|
52
|
+
},
|
|
53
|
+
set(key, value) {
|
|
54
|
+
const identifier = recordIdentifierFor(this);
|
|
55
|
+
const cache = this[RecordStore].cache;
|
|
56
|
+
const cacheKey = meta.sourceKey ?? key;
|
|
57
|
+
if (cache.getAttr(identifier, cacheKey) !== value) {
|
|
58
|
+
cache.setAttr(identifier, cacheKey, value);
|
|
59
|
+
if (!this.isValid) {
|
|
60
|
+
const { errors } = this;
|
|
61
|
+
if (errors.get(key)) {
|
|
62
|
+
errors.remove(key);
|
|
63
|
+
this.currentState.cleanErrorRequests();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
}).meta(meta);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The return type of `void` is a lie to appease TypeScript. The actual return type
|
|
73
|
+
* is a descriptor, but typescript incorrectly insists that decorator functions return
|
|
74
|
+
* `void` or `any`.
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
/**
|
|
78
|
+
`attr` defines an attribute on a {@link Model}.
|
|
79
|
+
By default, attributes are passed through as-is, however you can specify an
|
|
80
|
+
optional type to have the value automatically transformed.
|
|
81
|
+
WarpDrive ships with four basic transform types: `string`, `number`,
|
|
82
|
+
`boolean` and `date`. You can define your own transforms by subclassing
|
|
83
|
+
{@link Transform}.
|
|
84
|
+
|
|
85
|
+
Note that you cannot use `attr` to define an attribute of `id`.
|
|
86
|
+
|
|
87
|
+
`attr` takes an optional hash as a second parameter, currently
|
|
88
|
+
supported options are:
|
|
89
|
+
|
|
90
|
+
- `defaultValue`: Pass a string or a function to be called to set the attribute
|
|
91
|
+
to a default value if and only if the key is absent from the payload response.
|
|
92
|
+
|
|
93
|
+
Example
|
|
94
|
+
|
|
95
|
+
```js [app/models/user.js]
|
|
96
|
+
import { Model, attr } from '@warp-drive/legacy/model';
|
|
97
|
+
|
|
98
|
+
export default class UserModel extends Model {
|
|
99
|
+
@attr('string') username;
|
|
100
|
+
@attr('string') email;
|
|
101
|
+
@attr('boolean', { defaultValue: false }) verified;
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Default value can also be a function. This is useful it you want to return
|
|
106
|
+
a new object for each attribute.
|
|
107
|
+
|
|
108
|
+
```js [app/models/user.js]
|
|
109
|
+
import { Model, attr } from '@warp-drive/legacy/model';
|
|
110
|
+
|
|
111
|
+
export default class UserModel extends Model {
|
|
112
|
+
@attr('string') username;
|
|
113
|
+
@attr('string') email;
|
|
114
|
+
|
|
115
|
+
@attr({
|
|
116
|
+
defaultValue() {
|
|
117
|
+
return {};
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
settings;
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The `options` hash is passed as second argument to a transforms'
|
|
125
|
+
`serialize` and `deserialize` method. This allows to configure a
|
|
126
|
+
transformation and adapt the corresponding value, based on the config:
|
|
127
|
+
|
|
128
|
+
```js [app/models/post.js]
|
|
129
|
+
import { Model, attr } from '@warp-drive/legacy/model';
|
|
130
|
+
|
|
131
|
+
export default class PostModel extends Model {
|
|
132
|
+
@attr('text', {
|
|
133
|
+
uppercase: true
|
|
134
|
+
})
|
|
135
|
+
text;
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
```js [app/transforms/text.js]
|
|
140
|
+
export default class TextTransform {
|
|
141
|
+
serialize(value, options) {
|
|
142
|
+
if (options.uppercase) {
|
|
143
|
+
return value.toUpperCase();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return value;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
deserialize(value) {
|
|
150
|
+
return value;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
static create() {
|
|
154
|
+
return new this();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
@public
|
|
160
|
+
@param type the attribute type
|
|
161
|
+
@param options a hash of options
|
|
162
|
+
*/
|
|
163
|
+
function attr(type, options, desc) {
|
|
164
|
+
const args = [
|
|
165
|
+
type,
|
|
166
|
+
options,
|
|
167
|
+
desc
|
|
168
|
+
];
|
|
169
|
+
return isElementDescriptor(args) ? _attr()(...args) : _attr(type, options);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/model/-private/belongs-to.ts
|
|
174
|
+
function _belongsTo(type, options) {
|
|
175
|
+
const meta = {
|
|
176
|
+
type: normalizeModelName(type),
|
|
177
|
+
options,
|
|
178
|
+
kind: "belongsTo",
|
|
179
|
+
name: "<Unknown BelongsTo>",
|
|
180
|
+
sourceKey: options.sourceKey
|
|
181
|
+
};
|
|
182
|
+
return computed({
|
|
183
|
+
get(key) {
|
|
184
|
+
if (this.isDestroying || this.isDestroyed) return null;
|
|
185
|
+
return lookupLegacySupport(this).getBelongsTo(key);
|
|
186
|
+
},
|
|
187
|
+
set(key, value) {
|
|
188
|
+
if (this.isDestroying || this.isDestroyed) return null;
|
|
189
|
+
const support = lookupLegacySupport(this);
|
|
190
|
+
assertPrivateStore(this[RecordStore]);
|
|
191
|
+
this[RecordStore]._join(() => {
|
|
192
|
+
support.setDirtyBelongsTo(key, value);
|
|
193
|
+
});
|
|
194
|
+
return support.getBelongsTo(key);
|
|
195
|
+
}
|
|
196
|
+
}).meta(meta);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
`belongsTo` is used to define One-To-One and One-To-Many, and One-To-None
|
|
200
|
+
relationships on a {@link Model}.
|
|
201
|
+
|
|
202
|
+
`belongsTo` takes a configuration hash as a second parameter, currently
|
|
203
|
+
supported options are:
|
|
204
|
+
|
|
205
|
+
- `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.
|
|
206
|
+
- `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.
|
|
207
|
+
- `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic
|
|
208
|
+
- `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism.
|
|
209
|
+
|
|
210
|
+
### Examples
|
|
211
|
+
|
|
212
|
+
To declare a **one-to-many** (or many-to-many) relationship, use
|
|
213
|
+
`belongsTo` in combination with `hasMany`:
|
|
214
|
+
|
|
215
|
+
```js
|
|
216
|
+
// app/models/comment.js
|
|
217
|
+
import { Model, belongsTo } from '@warp-drive/legacy/model';
|
|
218
|
+
|
|
219
|
+
export default class Comment extends Model {
|
|
220
|
+
@belongsTo('post', { async: false, inverse: 'comments' }) post;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// app/models/post.js
|
|
224
|
+
import { Model, hasMany } from '@warp-drive/legacy/model';
|
|
225
|
+
|
|
226
|
+
export default class Post extends Model {
|
|
227
|
+
@hasMany('comment', { async: false, inverse: 'post' }) comments;
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides:
|
|
232
|
+
|
|
233
|
+
```js
|
|
234
|
+
// app/models/author.js
|
|
235
|
+
import { Model, belongsTo } from '@warp-drive/legacy/model';
|
|
236
|
+
|
|
237
|
+
export default class Author extends Model {
|
|
238
|
+
@belongsTo('address', { async: true, inverse: 'owner' }) address;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// app/models/address.js
|
|
242
|
+
import { Model, belongsTo } from '@warp-drive/legacy/model';
|
|
243
|
+
|
|
244
|
+
export default class Address extends Model {
|
|
245
|
+
@belongsTo('author', { async: true, inverse: 'address' }) owner;
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides
|
|
250
|
+
with `null` as the inverse:
|
|
251
|
+
|
|
252
|
+
```js
|
|
253
|
+
// app/models/author.js
|
|
254
|
+
import { Model, belongsTo } from '@warp-drive/legacy/model';
|
|
255
|
+
|
|
256
|
+
export default class Author extends Model {
|
|
257
|
+
@belongsTo('address', { async: true, inverse: null }) address;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// app/models/address.js
|
|
261
|
+
import { Model, belongsTo } from '@warp-drive/legacy/model';
|
|
262
|
+
|
|
263
|
+
export default class Address extends Model {
|
|
264
|
+
@belongsTo('author', { async: true, inverse: null }) owner;
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
To declare a one-to-none relationship between two models, use
|
|
269
|
+
`belongsTo` with inverse set to `null` on just one side::
|
|
270
|
+
|
|
271
|
+
```js
|
|
272
|
+
// app/models/person.js
|
|
273
|
+
import { Model, belongsTo } from '@warp-drive/legacy/model';
|
|
274
|
+
|
|
275
|
+
export default class Person extends Model {
|
|
276
|
+
@belongsTo('person', { async: false, inverse: null }) bestFriend;
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
#### Sync vs Async Relationships
|
|
281
|
+
|
|
282
|
+
WarpDrive fulfills relationships using resource data available in
|
|
283
|
+
the cache.
|
|
284
|
+
|
|
285
|
+
Sync relationships point directly to the known related resources.
|
|
286
|
+
|
|
287
|
+
When a relationship is declared as async, if any of the known related
|
|
288
|
+
resources have not been loaded, they will be fetched. The property
|
|
289
|
+
on the record when accessed provides a promise that resolves once
|
|
290
|
+
all resources are loaded.
|
|
291
|
+
|
|
292
|
+
Async relationships may take advantage of links. On access, if the related
|
|
293
|
+
link has not been loaded, or if any known resources are not available in
|
|
294
|
+
the cache, the fresh state will be fetched using the link.
|
|
295
|
+
|
|
296
|
+
In contrast to async relationship, accessing a sync relationship
|
|
297
|
+
will error on access when any of the known related resources have
|
|
298
|
+
not been loaded.
|
|
299
|
+
|
|
300
|
+
If you are using `links` with sync relationships, you have to use
|
|
301
|
+
the BelongsTo reference API to fetch or refresh related resources
|
|
302
|
+
that aren't loaded. For instance, for a `bestFriend` relationship:
|
|
303
|
+
|
|
304
|
+
```js
|
|
305
|
+
person.belongsTo('bestFriend').reload();
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
#### Polymorphic Relationships
|
|
309
|
+
|
|
310
|
+
To declare a polymorphic relationship, use `hasMany` with the `polymorphic`
|
|
311
|
+
option set to `true`:
|
|
312
|
+
|
|
313
|
+
```js
|
|
314
|
+
// app/models/comment.js
|
|
315
|
+
import { Model, belongsTo } from '@warp-drive/legacy/model';
|
|
316
|
+
|
|
317
|
+
export default class Comment extends Model {
|
|
318
|
+
@belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
`'commentable'` here is referred to as the "abstract type" for the polymorphic
|
|
323
|
+
relationship.
|
|
324
|
+
|
|
325
|
+
Polymorphic relationships with `inverse: null` will accept any type of record as their content.
|
|
326
|
+
Polymorphic relationships with `inverse` set to a string will only accept records with a matching
|
|
327
|
+
inverse relationships declaring itself as satisfying the abstract type.
|
|
328
|
+
|
|
329
|
+
Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'
|
|
330
|
+
for this relationship.
|
|
331
|
+
|
|
332
|
+
```js
|
|
333
|
+
// app/models/post.js
|
|
334
|
+
import { Model, hasMany } from '@warp-drive/legacy/model';
|
|
335
|
+
|
|
336
|
+
export default class Post extends Model {
|
|
337
|
+
@hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Note: every Model that declares an inverse to a polymorphic relationship must
|
|
342
|
+
declare itself exactly the same. This is because polymorphism is based on structural
|
|
343
|
+
traits.
|
|
344
|
+
|
|
345
|
+
Polymorphic to polymorphic relationships are supported. Both sides of the relationship
|
|
346
|
+
must be declared as polymorphic, and the `as` option must be used to declare the abstract
|
|
347
|
+
type each record satisfies on both sides.
|
|
348
|
+
|
|
349
|
+
@public
|
|
350
|
+
@param type the name of the related resource
|
|
351
|
+
@param options a hash of options
|
|
352
|
+
*/
|
|
353
|
+
function belongsTo(type, options) {
|
|
354
|
+
return _belongsTo(type, options);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/model/-private/has-many.ts
|
|
359
|
+
function normalizeType(type) {
|
|
360
|
+
return singularize(dasherize(type));
|
|
361
|
+
}
|
|
362
|
+
function _hasMany(type, options) {
|
|
363
|
+
const meta = {
|
|
364
|
+
type: normalizeType(type),
|
|
365
|
+
options,
|
|
366
|
+
kind: "hasMany",
|
|
367
|
+
name: "<Unknown BelongsTo>",
|
|
368
|
+
sourceKey: options.sourceKey
|
|
369
|
+
};
|
|
370
|
+
return computed({
|
|
371
|
+
get(key) {
|
|
372
|
+
if (this.isDestroying || this.isDestroyed) return [];
|
|
373
|
+
return lookupLegacySupport(this).getHasMany(key);
|
|
374
|
+
},
|
|
375
|
+
set(key, records) {
|
|
376
|
+
const support = lookupLegacySupport(this);
|
|
377
|
+
const manyArray = support.getManyArray(key);
|
|
378
|
+
assertPrivateStore(this[RecordStore]);
|
|
379
|
+
this[RecordStore]._join(() => {
|
|
380
|
+
manyArray.splice(0, manyArray.length, ...records);
|
|
381
|
+
});
|
|
382
|
+
return support.getHasMany(key);
|
|
383
|
+
}
|
|
384
|
+
}).meta(meta);
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
`hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None
|
|
388
|
+
relationships on a {@link Model}.
|
|
389
|
+
|
|
390
|
+
`hasMany` takes a configuration hash as a second parameter, currently
|
|
391
|
+
supported options are:
|
|
392
|
+
|
|
393
|
+
- `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.
|
|
394
|
+
- `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.
|
|
395
|
+
- `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic
|
|
396
|
+
- `as`: (*optional*) A string used to declare the abstract type "this" record satisfies for polymorphism.
|
|
397
|
+
|
|
398
|
+
### Examples
|
|
399
|
+
|
|
400
|
+
To declare a **many-to-one** (or one-to-many) relationship, use
|
|
401
|
+
`belongsTo` in combination with `hasMany`:
|
|
402
|
+
|
|
403
|
+
```js
|
|
404
|
+
// app/models/post.js
|
|
405
|
+
import { Model, hasMany } from '@warp-drive/legacy/model';
|
|
406
|
+
|
|
407
|
+
export default class Post extends Model {
|
|
408
|
+
@hasMany('comment', { async: false, inverse: 'post' }) comments;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
// app/models/comment.js
|
|
413
|
+
import { Model, belongsTo } from '@warp-drive/legacy/model';
|
|
414
|
+
|
|
415
|
+
export default class Comment extends Model {
|
|
416
|
+
@belongsTo('post', { async: false, inverse: 'comments' }) post;
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides:
|
|
421
|
+
|
|
422
|
+
```js
|
|
423
|
+
// app/models/post.js
|
|
424
|
+
import { Model, hasMany } from '@warp-drive/legacy/model';
|
|
425
|
+
|
|
426
|
+
export default class Post extends Model {
|
|
427
|
+
@hasMany('tag', { async: true, inverse: 'posts' }) tags;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// app/models/tag.js
|
|
431
|
+
import { Model, hasMany } from '@warp-drive/legacy/model';
|
|
432
|
+
|
|
433
|
+
export default class Tag extends Model {
|
|
434
|
+
@hasMany('post', { async: true, inverse: 'tags' }) posts;
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides
|
|
439
|
+
with `null` as the inverse:
|
|
440
|
+
|
|
441
|
+
```js
|
|
442
|
+
// app/models/post.js
|
|
443
|
+
import { Model, hasMany } from '@warp-drive/legacy/model';
|
|
444
|
+
|
|
445
|
+
export default class Post extends Model {
|
|
446
|
+
@hasMany('tag', { async: true, inverse: null }) tags;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// app/models/tag.js
|
|
450
|
+
import { Model, hasMany } from '@warp-drive/legacy/model';
|
|
451
|
+
|
|
452
|
+
export default class Tag extends Model {
|
|
453
|
+
@hasMany('post', { async: true, inverse: null }) posts;
|
|
454
|
+
}
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
To declare a many-to-none relationship between two models, use
|
|
458
|
+
`hasMany` with inverse set to `null` on just one side::
|
|
459
|
+
|
|
460
|
+
```js
|
|
461
|
+
// app/models/post.js
|
|
462
|
+
import { Model, hasMany } from '@warp-drive/legacy/model';
|
|
463
|
+
|
|
464
|
+
export default class Post extends Model {
|
|
465
|
+
@hasMany('category', { async: true, inverse: null }) categories;
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
#### Sync vs Async Relationships
|
|
470
|
+
|
|
471
|
+
WarpDrive fulfills relationships using resource data available in
|
|
472
|
+
the cache.
|
|
473
|
+
|
|
474
|
+
Sync relationships point directly to the known related resources.
|
|
475
|
+
|
|
476
|
+
When a relationship is declared as async, if any of the known related
|
|
477
|
+
resources have not been loaded, they will be fetched. The property
|
|
478
|
+
on the record when accessed provides a promise that resolves once
|
|
479
|
+
all resources are loaded.
|
|
480
|
+
|
|
481
|
+
Async relationships may take advantage of links. On access, if the related
|
|
482
|
+
link has not been loaded, or if any known resources are not available in
|
|
483
|
+
the cache, the fresh state will be fetched using the link.
|
|
484
|
+
|
|
485
|
+
In contrast to async relationship, accessing a sync relationship
|
|
486
|
+
will error on access when any of the known related resources have
|
|
487
|
+
not been loaded.
|
|
488
|
+
|
|
489
|
+
If you are using `links` with sync relationships, you have to use
|
|
490
|
+
the HasMany reference API to fetch or refresh related resources
|
|
491
|
+
that aren't loaded. For instance, for a `comments` relationship:
|
|
492
|
+
|
|
493
|
+
```js
|
|
494
|
+
post.hasMany('comments').reload();
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
#### Polymorphic Relationships
|
|
498
|
+
|
|
499
|
+
To declare a polymorphic relationship, use `hasMany` with the `polymorphic`
|
|
500
|
+
option set to `true`:
|
|
501
|
+
|
|
502
|
+
```js
|
|
503
|
+
// app/models/comment.js
|
|
504
|
+
import { Model, belongsTo } from '@warp-drive/legacy/model';
|
|
505
|
+
|
|
506
|
+
export default class Comment extends Model {
|
|
507
|
+
@belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;
|
|
508
|
+
}
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
`'commentable'` here is referred to as the "abstract type" for the polymorphic
|
|
512
|
+
relationship.
|
|
513
|
+
|
|
514
|
+
Polymorphic relationships with `inverse: null` will accept any type of record as their content.
|
|
515
|
+
Polymorphic relationships with `inverse` set to a string will only accept records with a matching
|
|
516
|
+
inverse relationships declaring itself as satisfying the abstract type.
|
|
517
|
+
|
|
518
|
+
Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'
|
|
519
|
+
for this relationship.
|
|
520
|
+
|
|
521
|
+
```js
|
|
522
|
+
// app/models/post.js
|
|
523
|
+
import { Model, hasMany } from '@warp-drive/legacy/model';
|
|
524
|
+
|
|
525
|
+
export default class Post extends Model {
|
|
526
|
+
@hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;
|
|
527
|
+
}
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
Note: every Model that declares an inverse to a polymorphic relationship must
|
|
531
|
+
declare itself exactly the same. This is because polymorphism is based on structural
|
|
532
|
+
traits.
|
|
533
|
+
|
|
534
|
+
Polymorphic to polymorphic relationships are supported. Both sides of the relationship
|
|
535
|
+
must be declared as polymorphic, and the `as` option must be used to declare the abstract
|
|
536
|
+
type each record satisfies on both sides.
|
|
537
|
+
|
|
538
|
+
@public
|
|
539
|
+
@param type the name of the related resource
|
|
540
|
+
@param options a hash of options
|
|
541
|
+
*/
|
|
542
|
+
function hasMany(type, options) {
|
|
543
|
+
return _hasMany(type, options);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/model/-private/hooks.ts
|
|
548
|
+
/**
|
|
549
|
+
* The `instantiateRecord` hook implementation for use with `Model`. Pass
|
|
550
|
+
* this to your store's `instantiateRecord` method when configuring the
|
|
551
|
+
* store to use `Model` for schema/record instantiation.
|
|
552
|
+
*
|
|
553
|
+
* @public
|
|
554
|
+
*/
|
|
555
|
+
function instantiateRecord(identifier, createRecordArgs) {
|
|
556
|
+
const type = identifier.type;
|
|
557
|
+
const createOptions = {
|
|
558
|
+
_createProps: createRecordArgs ?? {},
|
|
559
|
+
_secretInit: {
|
|
560
|
+
identifier,
|
|
561
|
+
store: this,
|
|
562
|
+
cb: secretInit
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
setOwner(createOptions, getOwner(this));
|
|
566
|
+
return getModelFactory(this, type).class.create(createOptions);
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* The `teardownRecord` hook implementation for use with `Model`. Pass this
|
|
570
|
+
* to your store's `teardownRecord` method when configuring the store to
|
|
571
|
+
* use `Model` for schema/record instantiation.
|
|
572
|
+
*
|
|
573
|
+
* @public
|
|
574
|
+
*/
|
|
575
|
+
function teardownRecord(record) {
|
|
576
|
+
record.destroy();
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* The `modelFor` implementation for use with `Model`, exposed on the store
|
|
580
|
+
* as `store.modelFor(type)` when the store is configured to use `Model`.
|
|
581
|
+
* Returns the `Model` subclass registered for the given type, if any.
|
|
582
|
+
*
|
|
583
|
+
* @public
|
|
584
|
+
*/
|
|
585
|
+
/**
|
|
586
|
+
* Overload accepting a raw type string instead of a typed record instance.
|
|
587
|
+
*
|
|
588
|
+
* @public
|
|
589
|
+
*/
|
|
590
|
+
function modelFor(modelName) {
|
|
591
|
+
assertPrivateStore(this);
|
|
592
|
+
const type = normalizeModelName(modelName);
|
|
593
|
+
const maybeFactory = getModelFactory(this, type);
|
|
594
|
+
const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;
|
|
595
|
+
if (!(!klass || !klass.isModel || this._forceShim)) return klass;
|
|
596
|
+
}
|
|
597
|
+
function secretInit(record, identifier, store) {
|
|
598
|
+
setRecordIdentifier(record, identifier);
|
|
599
|
+
StoreMap.set(record, store);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
//#endregion
|
|
603
|
+
export { belongsTo as a, hasMany as i, modelFor as n, attr as o, teardownRecord as r, instantiateRecord as t };
|
|
604
|
+
//# sourceMappingURL=model-C0bTXzGn.js.map
|