@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,1386 @@
|
|
|
1
|
+
import { Store } from "@warp-drive/core";
|
|
2
|
+
import { LegacyLiveArray, LegacyQueryArray, Request } from "@warp-drive/core/store/-private";
|
|
3
|
+
import { Handler, createDeferred } from "@warp-drive/core/request";
|
|
4
|
+
import { ImmutableRequestInfo } from "@warp-drive/core/types/request";
|
|
5
|
+
import { FindAllOptions, FindRecordOptions, ModelSchema } from "@warp-drive/core/types";
|
|
6
|
+
import { ObjectValue } from "@warp-drive/core/types/json/raw";
|
|
7
|
+
import { JsonApiDocument, SingleResourceDocument } from "@warp-drive/core/types/spec/json-api-raw";
|
|
8
|
+
import { ChangedAttributesHash } from "@warp-drive/core/types/cache";
|
|
9
|
+
import { PersistedResourceKey, ResourceKey as ResourceKey$1 } from "@warp-drive/core/types/identifier";
|
|
10
|
+
import { TypeFromInstance, TypedRecordInstance } from "@warp-drive/core/types/record";
|
|
11
|
+
import { LegacyAttributeField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
|
|
12
|
+
//#region src/compat/legacy-network-handler/minimum-adapter-interface.d.ts
|
|
13
|
+
type Group = Snapshot[];
|
|
14
|
+
/**
|
|
15
|
+
* The raw payload shape returned by a legacy adapter's request methods,
|
|
16
|
+
* prior to being normalized by a {@link MinimumSerializerInterface}.
|
|
17
|
+
*/
|
|
18
|
+
type AdapterPayload = Record<string, unknown> | unknown[];
|
|
19
|
+
/**
|
|
20
|
+
* :::danger
|
|
21
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
22
|
+
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
23
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
24
|
+
:::
|
|
25
|
+
|
|
26
|
+
The following documentation describes the methods an
|
|
27
|
+
adapter should implement with descriptions around when an
|
|
28
|
+
application might expect these methods to be called.
|
|
29
|
+
|
|
30
|
+
Methods that are not required are marked as **optional**.
|
|
31
|
+
|
|
32
|
+
@class (Interface) Adapter
|
|
33
|
+
@public
|
|
34
|
+
*/
|
|
35
|
+
interface MinimumAdapterInterface {
|
|
36
|
+
/**
|
|
37
|
+
* `adapter.findRecord` takes a request for a resource of a given `type` and `id` combination
|
|
38
|
+
* and should return a `Promise` which fulfills with data for a single resource matching that
|
|
39
|
+
* `type` and `id`.
|
|
40
|
+
*
|
|
41
|
+
* The response will be fed to the associated serializer's `normalizeResponse` method with the
|
|
42
|
+
* `requestType` set to `findRecord`, which should return a `JSON:API` document.
|
|
43
|
+
*
|
|
44
|
+
* The final result after normalization to `JSON:API` will be added to store via `store.push` where
|
|
45
|
+
* it will merge with any existing data for the record.
|
|
46
|
+
*
|
|
47
|
+
* ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
|
|
48
|
+
* call will NOT be made. In this scenario you may need to do at least a minimum amount of response
|
|
49
|
+
* processing within the adapter.
|
|
50
|
+
*
|
|
51
|
+
* `adapter.findRecord` is called whenever the `store` needs to load, reload, or backgroundReload
|
|
52
|
+
* the resource data for a given `type` and `id`.
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
56
|
+
* @param {ModelSchema} schema An object with methods for accessing information about
|
|
57
|
+
* the type, attributes and relationships of the primary type associated with the request.
|
|
58
|
+
* @param {String} id
|
|
59
|
+
* @param {Snapshot} snapshot
|
|
60
|
+
* @return {Promise} a promise resolving with resource data to feed to the associated serializer
|
|
61
|
+
*/
|
|
62
|
+
findRecord(store: Store, schema: ModelSchema, id: string, snapshot: Snapshot): Promise<AdapterPayload>;
|
|
63
|
+
/**
|
|
64
|
+
* `adapter.findAll` takes a request for resources of a given `type` and should return
|
|
65
|
+
* a `Promise` which fulfills with a collection of resource data matching that `type`.
|
|
66
|
+
*
|
|
67
|
+
* The response will be fed to the associated serializer's `normalizeResponse` method
|
|
68
|
+
* with the `requestType` set to `findAll`, which should return a `JSON:API` document.
|
|
69
|
+
*
|
|
70
|
+
* The final result after normalization to `JSON:API` will be added to store via `store.push` where
|
|
71
|
+
* it will merge with any existing records for `type`. Existing records for the `type` will not be removed.
|
|
72
|
+
*
|
|
73
|
+
* ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
|
|
74
|
+
* call will NOT be made. In this scenario you may need to do at least a minimum amount of response
|
|
75
|
+
* processing within the adapter.
|
|
76
|
+
*
|
|
77
|
+
* `adapter.findAll` is called whenever `store.findAll` is asked to reload or backgroundReload.
|
|
78
|
+
* The records in the response are merged with the contents of the store. Existing records for
|
|
79
|
+
* the `type` will not be removed.
|
|
80
|
+
*
|
|
81
|
+
* See also `shouldReloadAll` and `shouldBackgroundReloadAll`
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
85
|
+
* @param {ModelSchema} schema An object with methods for accessing information about
|
|
86
|
+
* the type, attributes and relationships of the primary type associated with the request.
|
|
87
|
+
* @param {null} sinceToken This parameter is no longer used and will always be null.
|
|
88
|
+
* @param {SnapshotRecordArray} snapshotRecordArray an object containing any passed in options,
|
|
89
|
+
* adapterOptions, and the ability to access a snapshot for each existing record of the type.
|
|
90
|
+
* @return {Promise} a promise resolving with resource data to feed to the associated serializer
|
|
91
|
+
*/
|
|
92
|
+
findAll(store: Store, schema: ModelSchema, sinceToken: null, snapshotRecordArray: SnapshotRecordArray): Promise<AdapterPayload>;
|
|
93
|
+
/**
|
|
94
|
+
* `adapter.query` takes a request for resources of a given `type` and should return
|
|
95
|
+
* a `Promise` which fulfills with a collection of resource data matching that `type`.
|
|
96
|
+
*
|
|
97
|
+
* The response will be fed to the associated serializer's `normalizeResponse` method
|
|
98
|
+
* with the `requestType` set to `query`, which should return a `JSON:API` document.
|
|
99
|
+
*
|
|
100
|
+
* As with `findAll`, the final result after normalization to `JSON:API` will be added to
|
|
101
|
+
* store via `store.push` where it will merge with any existing records for `type`.
|
|
102
|
+
*
|
|
103
|
+
* ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
|
|
104
|
+
* call will NOT be made. In this scenario you may need to do at least a minimum amount of response
|
|
105
|
+
* processing within the adapter.
|
|
106
|
+
*
|
|
107
|
+
* `adapter.query` is called whenever `store.query` is called or a previous query result is
|
|
108
|
+
* asked to reload.
|
|
109
|
+
*
|
|
110
|
+
* Existing records for the `type` will not be removed. The key difference is in the result
|
|
111
|
+
* returned by the `store`. For `findAll` the result is all known records of the `type`,
|
|
112
|
+
* while for `query` it will only be the records returned from `adapter.query`.
|
|
113
|
+
*
|
|
114
|
+
* @public
|
|
115
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
116
|
+
* @param {ModelSchema} schema An object with methods for accessing information about
|
|
117
|
+
* the type, attributes and relationships of the primary type associated with the request.
|
|
118
|
+
* @param {Object} query
|
|
119
|
+
* @param {LegacyQueryArray} recordArray
|
|
120
|
+
* @param {Object} options
|
|
121
|
+
* @return {Promise} a promise resolving with resource data to feed to the associated serializer
|
|
122
|
+
*/
|
|
123
|
+
query(store: Store, schema: ModelSchema, query: Record<string, unknown>, recordArray: LegacyQueryArray, options: {
|
|
124
|
+
adapterOptions?: unknown;
|
|
125
|
+
}): Promise<AdapterPayload>;
|
|
126
|
+
/**
|
|
127
|
+
* `adapter.queryRecord` takes a request for resource of a given `type` and should return
|
|
128
|
+
* a `Promise` which fulfills with data for a single resource matching that `type`.
|
|
129
|
+
*
|
|
130
|
+
* The response will be fed to the associated serializer's `normalizeResponse` method
|
|
131
|
+
* with the `requestType` set to `queryRecord`, which should return a `JSON:API` document.
|
|
132
|
+
*
|
|
133
|
+
* The final result after normalization to `JSON:API` will be added to store via `store.push` where
|
|
134
|
+
* it will merge with any existing data for the returned record.
|
|
135
|
+
*
|
|
136
|
+
* ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
|
|
137
|
+
* call will NOT be made. In this scenario you may need to do at least a minimum amount of response
|
|
138
|
+
* processing within the adapter.
|
|
139
|
+
*
|
|
140
|
+
* @public
|
|
141
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
142
|
+
* @param {ModelSchema} schema An object with methods for accessing information about
|
|
143
|
+
* the type, attributes and relationships of the primary type associated with the request.
|
|
144
|
+
* @param query
|
|
145
|
+
* @param options
|
|
146
|
+
* @return {Promise} a promise resolving with resource data to feed to the associated serializer
|
|
147
|
+
*/
|
|
148
|
+
queryRecord(store: Store, schema: ModelSchema, query: Record<string, unknown>, options: {
|
|
149
|
+
adapterOptions?: unknown;
|
|
150
|
+
}): Promise<AdapterPayload>;
|
|
151
|
+
/**
|
|
152
|
+
* `adapter.createRecord` takes a request to create a resource of a given `type` and should
|
|
153
|
+
* return a `Promise` which fulfills with data for the newly created resource.
|
|
154
|
+
*
|
|
155
|
+
* The response will be fed to the associated serializer's `normalizeResponse` method
|
|
156
|
+
* with the `requestType` set to `createRecord`, which should return a `JSON:API` document.
|
|
157
|
+
*
|
|
158
|
+
* The final result after normalization to `JSON:API` will be added to store via `store.push` where
|
|
159
|
+
* it will merge with any existing data for the record.
|
|
160
|
+
*
|
|
161
|
+
* ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
|
|
162
|
+
* call will NOT be made. In this scenario you may need to do at least a minimum amount of response
|
|
163
|
+
* processing within the adapter.
|
|
164
|
+
*
|
|
165
|
+
* If the adapter rejects or throws an error the record will enter an error state and the attributes
|
|
166
|
+
* that had attempted to be saved will still be considered dirty.
|
|
167
|
+
*
|
|
168
|
+
* ### InvalidErrors
|
|
169
|
+
*
|
|
170
|
+
* When rejecting a `createRecord` request due to validation issues during save (typically a 422 status code),
|
|
171
|
+
* you may throw an `InvalidError`.
|
|
172
|
+
*
|
|
173
|
+
* Throwing an `InvalidError` makes per-attribute errors available for records to use in the UI as needed.
|
|
174
|
+
* Records can also use this information to mark themselves as being in an `invalid` state.
|
|
175
|
+
* For more reading [see the RecordData Errors RFC](https://emberjs.github.io/rfcs/0465-record-data-errors.html)
|
|
176
|
+
*
|
|
177
|
+
* ```js
|
|
178
|
+
* let error = new Error(errorMessage);
|
|
179
|
+
*
|
|
180
|
+
* // these two properties combined
|
|
181
|
+
* // alert WarpDrive to this error being for
|
|
182
|
+
* // invalid properties on the record during
|
|
183
|
+
* // the request
|
|
184
|
+
* error.isAdapterError = true;
|
|
185
|
+
* error.code = 'InvalidError';
|
|
186
|
+
*
|
|
187
|
+
* // A JSON:API formatted array of errors
|
|
188
|
+
* // See https://jsonapi.org/format/#errors
|
|
189
|
+
* error.errors = [];
|
|
190
|
+
*
|
|
191
|
+
* throw error;
|
|
192
|
+
* ```
|
|
193
|
+
*
|
|
194
|
+
* @public
|
|
195
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
196
|
+
* @param {ModelSchema} schema An object with methods for accessing information about
|
|
197
|
+
* the type, attributes and relationships of the primary type associated with the request.
|
|
198
|
+
* @param {Snapshot} snapshot
|
|
199
|
+
* @return {Promise} a promise resolving with resource data to feed to the associated serializer
|
|
200
|
+
*/
|
|
201
|
+
createRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
|
|
202
|
+
/**
|
|
203
|
+
* `adapter.updateRecord` takes a request to update a resource of a given `type` and should
|
|
204
|
+
* return a `Promise` which fulfills with the updated data for the resource.
|
|
205
|
+
*
|
|
206
|
+
* The response will be fed to the associated serializer's `normalizeResponse` method
|
|
207
|
+
* with the `requestType` set to `updateRecord`, which should return a `JSON:API` document.
|
|
208
|
+
*
|
|
209
|
+
* The final result after normalization to `JSON:API` will be added to store via `store.push` where
|
|
210
|
+
* it will merge with any existing data for the record.
|
|
211
|
+
*
|
|
212
|
+
* ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
|
|
213
|
+
* call will NOT be made. In this scenario you may need to do at least a minimum amount of response
|
|
214
|
+
* processing within the adapter.
|
|
215
|
+
*
|
|
216
|
+
* If the adapter rejects or throws an error the record will enter an error state and the attributes
|
|
217
|
+
* that had attempted to be saved will still be considered dirty.
|
|
218
|
+
*
|
|
219
|
+
* ### InvalidErrors
|
|
220
|
+
*
|
|
221
|
+
* When rejecting a `createRecord` request due to validation issues during save (typically a 422 status code),
|
|
222
|
+
* you may throw an `InvalidError`.
|
|
223
|
+
*
|
|
224
|
+
* Throwing an `InvalidError` makes per-attribute errors available for records to use in the UI as needed.
|
|
225
|
+
* Records can also use this information to mark themselves as being in an `invalid` state.
|
|
226
|
+
* For more reading [see the RecordData Errors RFC](https://emberjs.github.io/rfcs/0465-record-data-errors.html)
|
|
227
|
+
*
|
|
228
|
+
* ```js
|
|
229
|
+
* let error = new Error(errorMessage);
|
|
230
|
+
*
|
|
231
|
+
* // these two properties combined
|
|
232
|
+
* // alert WarpDrive to this error being for
|
|
233
|
+
* // invalid properties on the record during
|
|
234
|
+
* // the request
|
|
235
|
+
* error.isAdapterError = true;
|
|
236
|
+
* error.code = 'InvalidError';
|
|
237
|
+
*
|
|
238
|
+
* // A JSON:API formatted array of errors
|
|
239
|
+
* // See https://jsonapi.org/format/#errors
|
|
240
|
+
* error.errors = [];
|
|
241
|
+
*
|
|
242
|
+
* throw error;
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @public
|
|
246
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
247
|
+
* @param {ModelSchema} schema An object with methods for accessing information about
|
|
248
|
+
* the type, attributes and relationships of the primary type associated with the request.
|
|
249
|
+
* @param {Snapshot} snapshot
|
|
250
|
+
*/
|
|
251
|
+
updateRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
|
|
252
|
+
/**
|
|
253
|
+
* `adapter.deleteRecord` takes a request to delete a resource of a given `type` and
|
|
254
|
+
* should return a `Promise` which resolves when that deletion is complete.
|
|
255
|
+
*
|
|
256
|
+
* Usually the response will be empty, but you may include additional updates in the
|
|
257
|
+
* response. The response will be fed to the associated serializer's `normalizeResponse` method
|
|
258
|
+
* with the `requestType` set to `deleteRecord`, which should return a `JSON:API` document.
|
|
259
|
+
*
|
|
260
|
+
* The final result after normalization to `JSON:API` will be added to store via `store.push` where
|
|
261
|
+
* it will merge with any existing data.
|
|
262
|
+
*
|
|
263
|
+
* ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
|
|
264
|
+
* call will NOT be made. In this scenario you may need to do at least a minimum amount of response
|
|
265
|
+
* processing within the adapter.
|
|
266
|
+
*
|
|
267
|
+
* If the adapter rejects or errors the record will need to be saved again once the reason
|
|
268
|
+
* for the error is addressed in order to persist the deleted state.
|
|
269
|
+
*
|
|
270
|
+
* @public
|
|
271
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
272
|
+
* @param {ModelSchema} schema An object with methods for accessing information about
|
|
273
|
+
* the type, attributes and relationships of the primary type associated with the request.
|
|
274
|
+
* @param {Snapshot} snapshot A Snapshot containing the record's current data
|
|
275
|
+
* @return
|
|
276
|
+
*/
|
|
277
|
+
deleteRecord(store: Store, schema: ModelSchema, snapshot: Snapshot): Promise<AdapterPayload>;
|
|
278
|
+
/**
|
|
279
|
+
* `adapter.findBelongsTo` takes a request to fetch a related resource located at a
|
|
280
|
+
* `relatedLink` and should return a `Promise` which fulfills with data for a single
|
|
281
|
+
* resource.
|
|
282
|
+
*
|
|
283
|
+
* ⚠️ This method is only called if the store previously received relationship information for a resource
|
|
284
|
+
* containing a [related link](https://jsonapi.org/format/#document-resource-object-related-resource-links).
|
|
285
|
+
*
|
|
286
|
+
* If the cache does not have a `link` for the relationship then `findRecord` will be used if a `type` and `id`
|
|
287
|
+
* for the related resource is known.
|
|
288
|
+
*
|
|
289
|
+
* The response will be fed to the associated serializer's `normalizeResponse` method
|
|
290
|
+
* with the `requestType` set to `findBelongsTo`, which should return a `JSON:API` document.
|
|
291
|
+
*
|
|
292
|
+
* The final result after normalization to `JSON:API` will be added to store via `store.push` where
|
|
293
|
+
* it will merge with any existing data.
|
|
294
|
+
*
|
|
295
|
+
* ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
|
|
296
|
+
* call will NOT be made. In this scenario you may need to do at least a minimum amount of response
|
|
297
|
+
* processing within the adapter.
|
|
298
|
+
*
|
|
299
|
+
* @public
|
|
300
|
+
* @optional
|
|
301
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
302
|
+
* @param {Snapshot} snapshot A Snapshot containing the parent record's current data
|
|
303
|
+
* @param {String} relatedLink The link at which the associated resource might be found
|
|
304
|
+
* @param {RelationshipSchema} relationship
|
|
305
|
+
* @return {Promise} a promise resolving with resource data to feed to the associated serializer
|
|
306
|
+
*/
|
|
307
|
+
findBelongsTo?(store: Store, snapshot: Snapshot, relatedLink: string, relationship: LegacyRelationshipField): Promise<AdapterPayload>;
|
|
308
|
+
/**
|
|
309
|
+
* `adapter.findHasMany` takes a request to fetch a related resource collection located
|
|
310
|
+
* at a `relatedLink` and should return a `Promise` which fulfills with data for that
|
|
311
|
+
* collection.
|
|
312
|
+
*
|
|
313
|
+
* ⚠️ This method is only called if the store previously received relationship information for a resource
|
|
314
|
+
* containing a [related link](https://jsonapi.org/format/#document-resource-object-related-resource-links).
|
|
315
|
+
*
|
|
316
|
+
* If the cache does not have a `link` for the relationship but the `type` and `id` of
|
|
317
|
+
* related resources are known then `findRecord` will be used for each individual related
|
|
318
|
+
* resource.
|
|
319
|
+
*
|
|
320
|
+
* The response will be fed to the associated serializer's `normalizeResponse` method
|
|
321
|
+
* with the `requestType` set to `findHasMany`, which should return a `JSON:API` document.
|
|
322
|
+
*
|
|
323
|
+
* The final result after normalization to `JSON:API` will be added to store via `store.push` where
|
|
324
|
+
* it will merge with any existing data.
|
|
325
|
+
*
|
|
326
|
+
* ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
|
|
327
|
+
* call will NOT be made. In this scenario you may need to do at least a minimum amount of response
|
|
328
|
+
* processing within the adapter.
|
|
329
|
+
*
|
|
330
|
+
* @public
|
|
331
|
+
* @optional
|
|
332
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
333
|
+
* @param {Snapshot} snapshot A Snapshot containing the parent record's current data
|
|
334
|
+
* @param {String} relatedLink The link at which the associated resource collection might be found
|
|
335
|
+
* @param {RelationshipSchema} relationship
|
|
336
|
+
* @return {Promise} a promise resolving with resource data to feed to the associated serializer
|
|
337
|
+
*/
|
|
338
|
+
findHasMany?(store: Store, snapshot: Snapshot, relatedLink: string, relationship: LegacyRelationshipField): Promise<AdapterPayload>;
|
|
339
|
+
/**
|
|
340
|
+
* ⚠️ This Method is only called if `coalesceFindRequests` is `true`. The array passed to it is determined
|
|
341
|
+
* by the adapter's `groupRecordsForFindMany` method, and will be called once per group returned.
|
|
342
|
+
*
|
|
343
|
+
* `adapter.findMany` takes a request to fetch a collection of resources and should return a
|
|
344
|
+
* `Promise` which fulfills with data for that collection.
|
|
345
|
+
*
|
|
346
|
+
* The response will be fed to the associated serializer's `normalizeResponse` method
|
|
347
|
+
* with the `requestType` set to `findMany`, which should return a `JSON:API` document.
|
|
348
|
+
*
|
|
349
|
+
* The final result after normalization to `JSON:API` will be added to store via `store.push` where
|
|
350
|
+
* it will merge with any existing data.
|
|
351
|
+
*
|
|
352
|
+
* ⚠️ If the adapter's response resolves to a false-y value, the associated `serializer.normalizeResponse`
|
|
353
|
+
* call will NOT be made. In this scenario you may need to do at least a minimum amount of response
|
|
354
|
+
* processing within the adapter.
|
|
355
|
+
*
|
|
356
|
+
* See also `groupRecordsForFindMany` and `coalesceFindRequests`
|
|
357
|
+
*
|
|
358
|
+
* @public
|
|
359
|
+
* @optional
|
|
360
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
361
|
+
* @param {ModelSchema} schema An object with methods for accessing information about
|
|
362
|
+
* the type, attributes and relationships of the primary type associated with the request.
|
|
363
|
+
* @param {Array<string>} ids An array of the ids of the resources to fetch
|
|
364
|
+
* @param {Array<Snapshot>} snapshots An array of snapshots of the available data for the resources to fetch
|
|
365
|
+
* @return {Promise} a promise resolving with resource data to feed to the associated serializer
|
|
366
|
+
*/
|
|
367
|
+
findMany?(store: Store, schema: ModelSchema, ids: string[], snapshots: Snapshot[]): Promise<AdapterPayload>;
|
|
368
|
+
/**
|
|
369
|
+
* This method provides the ability to generate an ID to assign to a new record whenever `store.createRecord`
|
|
370
|
+
* is called if no `id` was provided.
|
|
371
|
+
*
|
|
372
|
+
* Alternatively you can pass an id into the call to `store.createRecord` directly.
|
|
373
|
+
*
|
|
374
|
+
* ```js
|
|
375
|
+
* let id = generateNewId(type);
|
|
376
|
+
* let newRecord = store.createRecord(type, { id });
|
|
377
|
+
* ```
|
|
378
|
+
*
|
|
379
|
+
* @public
|
|
380
|
+
* @optional
|
|
381
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
382
|
+
* @param {String} type The type (or modelName) of record being created
|
|
383
|
+
* @param properties the properties passed as the second arg to `store.createRecord`
|
|
384
|
+
* @return {String} a string ID that should be unique (no other models of `type` in the cache should have this `id`)
|
|
385
|
+
*/
|
|
386
|
+
generateIdForRecord?(store: Store, type: string, properties: unknown): string;
|
|
387
|
+
/**
|
|
388
|
+
* If your adapter implements `findMany`, setting this to `true` will cause `findRecord`
|
|
389
|
+
* requests triggered within the same `runloop` to be coalesced into one or more calls
|
|
390
|
+
* to `adapter.findMany`. The number of calls made and the records contained in each call
|
|
391
|
+
* can be tuned by your adapter's `groupRecordsForHasMany` method.
|
|
392
|
+
*
|
|
393
|
+
* Implementing coalescing using this flag and the associated methods does not always offer
|
|
394
|
+
* the right level of correctness, timing control or granularity. If your application would
|
|
395
|
+
* be better suited coalescing across multiple types, coalescing for longer than a single runloop,
|
|
396
|
+
* or with a more custom request structure, coalescing within your application adapter may prove
|
|
397
|
+
* more effective.
|
|
398
|
+
*
|
|
399
|
+
* @property coalesceFindRequests [OPTIONAL]
|
|
400
|
+
* @public
|
|
401
|
+
* @optional
|
|
402
|
+
* @type {Boolean} true if the requests to find individual records should be coalesced, false otherwise
|
|
403
|
+
*/
|
|
404
|
+
coalesceFindRequests?: boolean;
|
|
405
|
+
/**
|
|
406
|
+
* ⚠️ This Method is only called if `coalesceFindRequests` is `true`.
|
|
407
|
+
*
|
|
408
|
+
* This method allows for you to split pending requests for records into multiple `findMany`
|
|
409
|
+
* requests. It receives an array of snapshots where each snapshot represents a unique record
|
|
410
|
+
* requested via `store.findRecord` during the most recent `runloop` that was not found in the
|
|
411
|
+
* cache or needs to be reloaded. It should return an array of groups.
|
|
412
|
+
*
|
|
413
|
+
* A group is an array of snapshots meant to be fetched together by a single `findMany` request.
|
|
414
|
+
*
|
|
415
|
+
* By default if this method is not implemented WarpDrive will call `findMany` once with all
|
|
416
|
+
* requested records as a single group when `coalesceFindRequests` is `true`.
|
|
417
|
+
*
|
|
418
|
+
* See also `findMany` and `coalesceFindRequests`
|
|
419
|
+
*
|
|
420
|
+
* @public
|
|
421
|
+
* @optional
|
|
422
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
423
|
+
* @param {Array<Snapshot>} snapshots An array of snapshots
|
|
424
|
+
* @return {Array<Array<Snapshot>>} An array of Snapshot arrays
|
|
425
|
+
*/
|
|
426
|
+
groupRecordsForFindMany?(store: Store, snapshots: Snapshot[]): Group[];
|
|
427
|
+
/**
|
|
428
|
+
* When a record is already available in the store and is requested again via `store.findRecord`,
|
|
429
|
+
* and `reload` is not specified as an option in the request, this method is called to determine
|
|
430
|
+
* whether the record should be reloaded prior to returning the result.
|
|
431
|
+
*
|
|
432
|
+
* If `reload` is specified as an option in the request (`true` or `false`) this method will not
|
|
433
|
+
* be called.
|
|
434
|
+
*
|
|
435
|
+
* ```js
|
|
436
|
+
* store.findRecord('user', '1', { reload: false })
|
|
437
|
+
* ```
|
|
438
|
+
*
|
|
439
|
+
* The default behavior if this method is not implemented and the option is not specified is to
|
|
440
|
+
* not reload, the same as a return of `false`.
|
|
441
|
+
*
|
|
442
|
+
* See also the documentation for `shouldBackgroundReloadRecord` which defaults to `true`.
|
|
443
|
+
*
|
|
444
|
+
* @public
|
|
445
|
+
* @optional
|
|
446
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
447
|
+
* @param {Snapshot} snapshot A Snapshot containing the record's current data
|
|
448
|
+
* @return {Boolean} true if the record should be reloaded immediately, false otherwise
|
|
449
|
+
*/
|
|
450
|
+
shouldReloadRecord?(store: Store, snapshot: Snapshot): boolean;
|
|
451
|
+
/**
|
|
452
|
+
* When `store.findAll(<type>)` is called without a `reload` option, the adapter
|
|
453
|
+
* is presented the opportunity to trigger a new request for records of that type.
|
|
454
|
+
*
|
|
455
|
+
* If `reload` is specified as an option in the request (`true` or `false`) this method will not
|
|
456
|
+
* be called.
|
|
457
|
+
*
|
|
458
|
+
* ```js
|
|
459
|
+
* store.findAll('user', { reload: false })
|
|
460
|
+
* ```
|
|
461
|
+
*
|
|
462
|
+
* The default behavior if this method is not implemented and the option is not specified is to
|
|
463
|
+
* not reload, the same as a return of `false`.
|
|
464
|
+
*
|
|
465
|
+
* Note: the Promise returned by `store.findAll` resolves to the same LiveArray instance
|
|
466
|
+
* returned by `store.peekAll` for that type, and will include all records in the store for
|
|
467
|
+
* the given type, including any previously existing records not returned by the reload request.
|
|
468
|
+
*
|
|
469
|
+
* @public
|
|
470
|
+
* @optional
|
|
471
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
472
|
+
* @param {SnapshotRecordArray} snapshotArray
|
|
473
|
+
* @return {Boolean} true if the a new request for all records of the type in SnapshotRecordArray should be made immediately, false otherwise
|
|
474
|
+
*/
|
|
475
|
+
shouldReloadAll?(store: Store, snapshotArray: SnapshotRecordArray): boolean;
|
|
476
|
+
/**
|
|
477
|
+
* When a record is already available in the store and is requested again via `store.findRecord`,
|
|
478
|
+
* and the record does not need to be reloaded prior to return, this method provides the ability
|
|
479
|
+
* to specify whether a refresh of the data for the reload should be scheduled to occur in the background.
|
|
480
|
+
*
|
|
481
|
+
* Users may explicitly declare a record should/should not be background reloaded by passing
|
|
482
|
+
* `backgroundReload: true` or `backgroundReload: false` as an option to the request respectively.
|
|
483
|
+
*
|
|
484
|
+
* ```js
|
|
485
|
+
* store.findRecord('user', '1', { backgroundReload: false })
|
|
486
|
+
* ```
|
|
487
|
+
*
|
|
488
|
+
* If the `backgroundReload` option is not present, this method will be called to determine whether
|
|
489
|
+
* a backgroundReload should be performed.
|
|
490
|
+
*
|
|
491
|
+
* The default behavior if this method is not implemented and the option was not specified is to
|
|
492
|
+
* background reload, the same as a return of `true`.
|
|
493
|
+
*
|
|
494
|
+
* @public
|
|
495
|
+
* @optional
|
|
496
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
497
|
+
* @param {Snapshot} snapshot A Snapshot containing the record's current data
|
|
498
|
+
* @return {Boolean} true if the record should be reloaded in the background, false otherwise
|
|
499
|
+
*/
|
|
500
|
+
shouldBackgroundReloadRecord?(store: Store, snapshot: Snapshot): boolean;
|
|
501
|
+
/**
|
|
502
|
+
* When `store.findAll(<type>)` is called and a `reload` is not initiated, the adapter
|
|
503
|
+
* is presented the opportunity to trigger a new non-blocking (background) request for
|
|
504
|
+
* records of that type
|
|
505
|
+
*
|
|
506
|
+
* Users may explicitly declare that this background request should/should not occur by passing
|
|
507
|
+
* `backgroundReload: true` or `backgroundReload: false` as an option to the request respectively.
|
|
508
|
+
*
|
|
509
|
+
* ```js
|
|
510
|
+
* store.findAll('user', { backgroundReload: false })
|
|
511
|
+
* ```
|
|
512
|
+
*
|
|
513
|
+
* The default behavior if this method is not implemented and the option is not specified is to
|
|
514
|
+
* perform a reload, the same as a return of `true`.
|
|
515
|
+
*
|
|
516
|
+
* @public
|
|
517
|
+
* @optional
|
|
518
|
+
* @param {Store} store The store service that initiated the request being normalized
|
|
519
|
+
* @param {SnapshotRecordArray} snapshotArray
|
|
520
|
+
* @return {Boolean} true if the a new request for all records of the type in SnapshotRecordArray should be made in the background, false otherwise
|
|
521
|
+
*/
|
|
522
|
+
shouldBackgroundReloadAll?(store: Store, snapshotArray: SnapshotRecordArray): boolean;
|
|
523
|
+
/**
|
|
524
|
+
* In some situations the adapter may need to perform cleanup when destroyed,
|
|
525
|
+
* that cleanup can be done in `destroy`.
|
|
526
|
+
*
|
|
527
|
+
* If not implemented, the store does not inform the adapter of destruction.
|
|
528
|
+
*
|
|
529
|
+
* @public
|
|
530
|
+
* @optional
|
|
531
|
+
*/
|
|
532
|
+
destroy?(): void;
|
|
533
|
+
}
|
|
534
|
+
//#endregion
|
|
535
|
+
//#region src/compat/legacy-network-handler/minimum-serializer-interface.d.ts
|
|
536
|
+
/**
|
|
537
|
+
* Options accepted by {@link MinimumSerializerInterface.serialize | serialize}
|
|
538
|
+
* and related legacy serializer methods.
|
|
539
|
+
*/
|
|
540
|
+
type SerializerOptions = {
|
|
541
|
+
/**
|
|
542
|
+
* whether the resource's id should be included in the serialized output
|
|
543
|
+
*/
|
|
544
|
+
includeId?: boolean;
|
|
545
|
+
};
|
|
546
|
+
/**
|
|
547
|
+
* :::danger
|
|
548
|
+
⚠️ **This is LEGACY documentation** for a feature that is no longer encouraged to be used.
|
|
549
|
+
If starting a new app or thinking of implementing a new adapter, consider writing a
|
|
550
|
+
{@link Handler} instead to be used with the {@link RequestManager}
|
|
551
|
+
:::
|
|
552
|
+
|
|
553
|
+
The following documentation describes the methods an application
|
|
554
|
+
serializer should implement with descriptions around when an
|
|
555
|
+
application might expect these methods to be called.
|
|
556
|
+
|
|
557
|
+
Methods that are not required are marked as **optional**.
|
|
558
|
+
|
|
559
|
+
@public
|
|
560
|
+
*/
|
|
561
|
+
interface MinimumSerializerInterface {
|
|
562
|
+
/**
|
|
563
|
+
* This method is responsible for normalizing the value resolved from the promise returned
|
|
564
|
+
* by an Adapter request into the format expected by the `Store`.
|
|
565
|
+
*
|
|
566
|
+
* The output should be a [JSON:API Document](https://jsonapi.org/format/#document-structure)
|
|
567
|
+
* with the following additional restrictions:
|
|
568
|
+
*
|
|
569
|
+
* - `type` should be formatted in the `singular` `dasherized` `lowercase` form
|
|
570
|
+
* - `members` (the property names of attributes and relationships) should be formatted
|
|
571
|
+
* to match their definition in the corresponding `Model` definition. Typically this
|
|
572
|
+
* will be `camelCase`.
|
|
573
|
+
* - [`lid`](https://github.com/emberjs/rfcs/blob/main/text/0403-ember-data-identifiers.md) is
|
|
574
|
+
* a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects)
|
|
575
|
+
* and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects)
|
|
576
|
+
*
|
|
577
|
+
* @public
|
|
578
|
+
* @param store The store service that initiated the request being normalized
|
|
579
|
+
* @param schema An object with methods for accessing information about
|
|
580
|
+
* the type, attributes and relationships of the primary type associated with the request.
|
|
581
|
+
* @param rawPayload The raw JSON response data returned from an API request.
|
|
582
|
+
* This correlates to the value the promise returned by the adapter method that performed
|
|
583
|
+
* the request resolved to.
|
|
584
|
+
* @param id For a findRecord request, this is the id initially provided
|
|
585
|
+
* in the call to store.findRecord. Else this value is null.
|
|
586
|
+
* @param requestType The type of request the Adapter had been asked to perform.
|
|
587
|
+
*
|
|
588
|
+
* @return a document following the structure of a [{json:api} Document](https://jsonapi.org/format/#document-structure).
|
|
589
|
+
*/
|
|
590
|
+
normalizeResponse(store: Store, schema: ModelSchema, rawPayload: AdapterPayload, id: string | null, requestType: "findRecord" | "queryRecord" | "findAll" | "findBelongsTo" | "findHasMany" | "findMany" | "query" | "createRecord" | "deleteRecord" | "updateRecord"): JsonApiDocument;
|
|
591
|
+
/**
|
|
592
|
+
* This method is responsible for serializing an individual record
|
|
593
|
+
* via a {@link Snapshot} into the format expected by the API.
|
|
594
|
+
*
|
|
595
|
+
* This method is called by `snapshot.serialize()`.
|
|
596
|
+
*
|
|
597
|
+
* When using `Model`, this method is called by `record.serialize()`.
|
|
598
|
+
*
|
|
599
|
+
* When using `JSONAPIAdapter` or `RESTAdapter` this method is called
|
|
600
|
+
* by `updateRecord` and `createRecord` if `Serializer.serializeIntoHash`
|
|
601
|
+
* is not implemented.
|
|
602
|
+
*
|
|
603
|
+
* @public
|
|
604
|
+
* @param snapshot A Snapshot for the record to serialize
|
|
605
|
+
*/
|
|
606
|
+
serialize(snapshot: Snapshot, options?: SerializerOptions): ObjectValue;
|
|
607
|
+
/**
|
|
608
|
+
* This method is intended to normalize data into a [JSON:API Document](https://jsonapi.org/format/#document-structure)
|
|
609
|
+
* with a data member containing a single [Resource](https://jsonapi.org/format/#document-resource-objects).
|
|
610
|
+
*
|
|
611
|
+
* - `type` should be formatted in the singular, dasherized and lowercase form
|
|
612
|
+
* - `members` (the property names of attributes and relationships) should be formatted
|
|
613
|
+
* to match their definition in the corresponding `Model` definition. Typically this
|
|
614
|
+
* will be `camelCase`.
|
|
615
|
+
* - [`lid`](https://github.com/emberjs/rfcs/blob/main/text/0403-ember-data-identifiers.md) is
|
|
616
|
+
* a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects)
|
|
617
|
+
* and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects)
|
|
618
|
+
*
|
|
619
|
+
* This method is called by the `Store` when `store.normalize(modelName, payload)` is
|
|
620
|
+
* called. It is recommended to use `store.serializerFor(modelName).normalizeResponse`
|
|
621
|
+
* over `store.normalize`.
|
|
622
|
+
*
|
|
623
|
+
* This method may be called when also using the `RESTSerializer`
|
|
624
|
+
* when `serializer.pushPayload` is called by `store.pushPayload`.
|
|
625
|
+
* However, it is recommended to use `store.push` over `store.pushPayload` after normalizing
|
|
626
|
+
* the payload directly.
|
|
627
|
+
*
|
|
628
|
+
* Example:
|
|
629
|
+
* ```js
|
|
630
|
+
* function pushPayload(store, modelName, rawPayload) {
|
|
631
|
+
* const ModelClass = store.modelFor(modelName);
|
|
632
|
+
* const serializer = store.serializerFor(modelName);
|
|
633
|
+
* const jsonApiPayload = serializer.normalizeResponse(store, ModelClass, rawPayload, null, 'query');
|
|
634
|
+
*
|
|
635
|
+
* return store.push(jsonApiPayload);
|
|
636
|
+
* }
|
|
637
|
+
* ```
|
|
638
|
+
*
|
|
639
|
+
* This method may be called when also using the `JSONAPISerializer`
|
|
640
|
+
* when normalizing included records. If mixing serializer usage in this way
|
|
641
|
+
* we recommend implementing this method, but caution that it may lead
|
|
642
|
+
* to unexpected mixing of formats.
|
|
643
|
+
*
|
|
644
|
+
* This method may also be called when normalizing embedded relationships when
|
|
645
|
+
* using the `EmbeddedRecordsMixin`. If using this mixin in a serializer in
|
|
646
|
+
* your application we recommend implementing this method, but caution that
|
|
647
|
+
* it may lead to unexpected mixing of formats.
|
|
648
|
+
*
|
|
649
|
+
* @public
|
|
650
|
+
* @optional
|
|
651
|
+
* @param schema An object with methods for accessing information about
|
|
652
|
+
* the type, attributes and relationships of the primary type associated with the request.
|
|
653
|
+
* @param rawPayload Some raw JSON data to be normalized into a JSON:API Resource.
|
|
654
|
+
* @param prop When called by the EmbeddedRecordsMixin this param will be the
|
|
655
|
+
* property at which the object provided as rawPayload was found.
|
|
656
|
+
* @return A JSON:API Document containing a single JSON:API Resource as its primary data.
|
|
657
|
+
*/
|
|
658
|
+
normalize?(schema: ModelSchema, rawPayload: ObjectValue, prop?: string): SingleResourceDocument;
|
|
659
|
+
/**
|
|
660
|
+
* When using `JSONAPIAdapter` or `RESTAdapter` this method is called
|
|
661
|
+
* by `adapter.updateRecord` and `adapter.createRecord` if `serializer.serializeIntoHash`
|
|
662
|
+
* is implemented. If this method is not implemented, `serializer.serialize`
|
|
663
|
+
* will be called in this case.
|
|
664
|
+
*
|
|
665
|
+
* You can use this method to customize the root keys serialized into the payload.
|
|
666
|
+
* The hash property should be modified by reference.
|
|
667
|
+
*
|
|
668
|
+
* For instance, your API may expect resources to be keyed by underscored type in the payload:
|
|
669
|
+
*
|
|
670
|
+
* ```js
|
|
671
|
+
* {
|
|
672
|
+
* _user: {
|
|
673
|
+
* type: 'user',
|
|
674
|
+
* id: '1'
|
|
675
|
+
* }
|
|
676
|
+
* }
|
|
677
|
+
* ```
|
|
678
|
+
*
|
|
679
|
+
* Which when using these adapters can be achieved by implementing this method similar
|
|
680
|
+
* to the following:
|
|
681
|
+
*
|
|
682
|
+
* ```js
|
|
683
|
+
* serializeIntoHash(hash, ModelClass, snapshot, options) {
|
|
684
|
+
* hash[`_${snapshot.modelName}`] = this.serialize(snapshot, options).data;
|
|
685
|
+
* }
|
|
686
|
+
* ```
|
|
687
|
+
*
|
|
688
|
+
* @public
|
|
689
|
+
* @optional
|
|
690
|
+
* @param hash A top most object of the request payload onto
|
|
691
|
+
* which to append the serialized record
|
|
692
|
+
* @param schema An object with methods for accessing information about
|
|
693
|
+
* the type, attributes and relationships of the primary type associated with the request.
|
|
694
|
+
* @param snapshot A Snapshot for the record to serialize
|
|
695
|
+
*/
|
|
696
|
+
serializeIntoHash?(hash: object, schema: ModelSchema, snapshot: Snapshot, options?: SerializerOptions): void;
|
|
697
|
+
/**
|
|
698
|
+
* This method allows for normalization of data when `store.pushPayload` is called
|
|
699
|
+
* and should be implemented if you want to use that method.
|
|
700
|
+
*
|
|
701
|
+
* The method is responsible for pushing new data to the store using `store.push`
|
|
702
|
+
* once any necessary normalization has occurred, and no data in the store will be
|
|
703
|
+
* updated unless it does so.
|
|
704
|
+
*
|
|
705
|
+
* The normalized form pushed to the store should be a [JSON:API Document](https://jsonapi.org/format/#document-structure)
|
|
706
|
+
* with the following additional restrictions:
|
|
707
|
+
*
|
|
708
|
+
* - `type` should be formatted in the singular, dasherized and lowercase form
|
|
709
|
+
* - `members` (the property names of attributes and relationships) should be formatted
|
|
710
|
+
* to match their definition in the corresponding `Model` definition. Typically this
|
|
711
|
+
* will be `camelCase`.
|
|
712
|
+
* - [`lid`](https://github.com/emberjs/rfcs/blob/main/text/0403-ember-data-identifiers.md) is
|
|
713
|
+
* a valid optional sibling to `id` and `type` in both [Resources](https://jsonapi.org/format/#document-resource-objects)
|
|
714
|
+
* and [Resource Identifier Objects](https://jsonapi.org/format/#document-resource-identifier-objects)
|
|
715
|
+
*
|
|
716
|
+
* If you need better control over normalization or want access to the records being added or updated
|
|
717
|
+
* in the store, we recommended using `store.push` over `store.pushPayload` after normalizing
|
|
718
|
+
* the payload directly. This can even take advantage of an existing serializer for the format
|
|
719
|
+
* the data is in, for example:
|
|
720
|
+
*
|
|
721
|
+
* ```js
|
|
722
|
+
* function pushPayload(store, modelName, rawPayload) {
|
|
723
|
+
* const ModelClass = store.modelFor(modelName);
|
|
724
|
+
* const serializer = store.serializerFor(modelName);
|
|
725
|
+
* const jsonApiPayload = serializer.normalizeResponse(store, ModelClass, rawPayload, null, 'query');
|
|
726
|
+
*
|
|
727
|
+
* return store.push(jsonApiPayload);
|
|
728
|
+
* }
|
|
729
|
+
* ```
|
|
730
|
+
*
|
|
731
|
+
* @public
|
|
732
|
+
* @optional
|
|
733
|
+
* @param store The store service that initiated the request being normalized
|
|
734
|
+
* @param rawPayload The raw JSON response data returned from an API request.
|
|
735
|
+
* This JSON should be in the API format expected by the serializer.
|
|
736
|
+
*/
|
|
737
|
+
pushPayload?(store: Store, rawPayload: ObjectValue): void;
|
|
738
|
+
/**
|
|
739
|
+
* In some situations the serializer may need to perform cleanup when destroyed,
|
|
740
|
+
* that cleanup can be done in `destroy`.
|
|
741
|
+
*
|
|
742
|
+
* If not implemented, the store does not inform the serializer of destruction.
|
|
743
|
+
*
|
|
744
|
+
* @public
|
|
745
|
+
* @optional
|
|
746
|
+
*/
|
|
747
|
+
destroy?(): void;
|
|
748
|
+
}
|
|
749
|
+
//#endregion
|
|
750
|
+
//#region src/compat/legacy-network-handler/snapshot.d.ts
|
|
751
|
+
type RecordId = string | null;
|
|
752
|
+
/**
|
|
753
|
+
Snapshot is not directly instantiable.
|
|
754
|
+
Instances are provided to a consuming application's
|
|
755
|
+
adapters and serializers for certain requests.
|
|
756
|
+
|
|
757
|
+
Snapshots are only available when using `@ember-data/legacy-compat`
|
|
758
|
+
for legacy compatibility with adapters and serializers.
|
|
759
|
+
|
|
760
|
+
For serialization of records in modern paradigms, request data from
|
|
761
|
+
the cache or off the record directly.
|
|
762
|
+
|
|
763
|
+
@hideconstructor
|
|
764
|
+
@public
|
|
765
|
+
*/
|
|
766
|
+
declare class Snapshot<R = unknown> {
|
|
767
|
+
/** @internal */
|
|
768
|
+
private __attributes;
|
|
769
|
+
/** @internal */
|
|
770
|
+
private _belongsToRelationships;
|
|
771
|
+
/** @internal */
|
|
772
|
+
private _belongsToIds;
|
|
773
|
+
/** @internal */
|
|
774
|
+
private _hasManyRelationships;
|
|
775
|
+
/** @internal */
|
|
776
|
+
private _hasManyIds;
|
|
777
|
+
/** @internal */
|
|
778
|
+
private _changedAttributes;
|
|
779
|
+
/** @internal */
|
|
780
|
+
private _store;
|
|
781
|
+
/**
|
|
782
|
+
The unique ResourceKey associated with this Snapshot.
|
|
783
|
+
|
|
784
|
+
@public
|
|
785
|
+
*/
|
|
786
|
+
identifier: ResourceKey$1<R extends TypedRecordInstance ? TypeFromInstance<R> : string>;
|
|
787
|
+
/**
|
|
788
|
+
The ResourceType of the underlying record for this Snapshot, as a string.
|
|
789
|
+
|
|
790
|
+
@public
|
|
791
|
+
*/
|
|
792
|
+
modelName: R extends TypedRecordInstance ? TypeFromInstance<R> : string;
|
|
793
|
+
/**
|
|
794
|
+
The id of the snapshot's underlying record
|
|
795
|
+
|
|
796
|
+
Example
|
|
797
|
+
|
|
798
|
+
```js
|
|
799
|
+
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
800
|
+
postSnapshot.id; // => '1'
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
@public
|
|
804
|
+
*/
|
|
805
|
+
id: string | null;
|
|
806
|
+
/**
|
|
807
|
+
If `include` was passed to the options for the request, the value
|
|
808
|
+
would be available here.
|
|
809
|
+
|
|
810
|
+
@public
|
|
811
|
+
*/
|
|
812
|
+
include?: string | string[];
|
|
813
|
+
/**
|
|
814
|
+
The adapterOptions passed to the request which generated this Snapshot, if any
|
|
815
|
+
|
|
816
|
+
@public
|
|
817
|
+
*/
|
|
818
|
+
adapterOptions?: Record<string, unknown>;
|
|
819
|
+
constructor(options: FindRecordOptions, identifier: ResourceKey$1<R extends TypedRecordInstance ? TypeFromInstance<R> : string>, store: Store);
|
|
820
|
+
/**
|
|
821
|
+
The underlying record for this snapshot. Can be used to access methods and
|
|
822
|
+
properties defined on the record.
|
|
823
|
+
|
|
824
|
+
```js
|
|
825
|
+
const someValue = snapshot.record.someProp;
|
|
826
|
+
```
|
|
827
|
+
|
|
828
|
+
@property record
|
|
829
|
+
@public
|
|
830
|
+
*/
|
|
831
|
+
get record(): R | null;
|
|
832
|
+
/** @internal */
|
|
833
|
+
private get _attributes();
|
|
834
|
+
get isNew(): boolean;
|
|
835
|
+
/**
|
|
836
|
+
Returns the value of an attribute.
|
|
837
|
+
|
|
838
|
+
Example
|
|
839
|
+
|
|
840
|
+
```javascript
|
|
841
|
+
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
842
|
+
postSnapshot.attr('author'); // => 'Tomster'
|
|
843
|
+
postSnapshot.attr('title'); // => 'Ember.js rocks'
|
|
844
|
+
```
|
|
845
|
+
|
|
846
|
+
Note: Values are loaded eagerly and cached when the snapshot is created.
|
|
847
|
+
|
|
848
|
+
@return The attribute value or undefined
|
|
849
|
+
@public
|
|
850
|
+
*/
|
|
851
|
+
attr(keyName: keyof R & string): unknown;
|
|
852
|
+
/**
|
|
853
|
+
Returns all attributes and their corresponding values.
|
|
854
|
+
|
|
855
|
+
::: warning ⚠️ WARNING
|
|
856
|
+
Attributes are SHALLOW copied from the cache.
|
|
857
|
+
Because they are NOT deep copied from the cache, mutating
|
|
858
|
+
any object or array fields will cause unintended side-effects
|
|
859
|
+
and bugs.
|
|
860
|
+
:::
|
|
861
|
+
|
|
862
|
+
Example
|
|
863
|
+
|
|
864
|
+
```js
|
|
865
|
+
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
866
|
+
postSnapshot.attributes(); // => { author: 'Tomster', title: 'Ember.js rocks' }
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
@return All attributes of the current snapshot
|
|
870
|
+
@public
|
|
871
|
+
*/
|
|
872
|
+
attributes(): Record<keyof R & string, unknown>;
|
|
873
|
+
/**
|
|
874
|
+
Returns all changed attributes and their old and new values.
|
|
875
|
+
|
|
876
|
+
Example
|
|
877
|
+
|
|
878
|
+
```js
|
|
879
|
+
// store.push('post', { id: 1, author: 'Tomster', title: 'Ember.js rocks' });
|
|
880
|
+
postModel.set('title', 'Ember.js rocks!');
|
|
881
|
+
postSnapshot.changedAttributes(); // => { title: ['Ember.js rocks', 'Ember.js rocks!'] }
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
@return All changed attributes of the current snapshot
|
|
885
|
+
@public
|
|
886
|
+
*/
|
|
887
|
+
changedAttributes(): ChangedAttributesHash;
|
|
888
|
+
/**
|
|
889
|
+
Returns the current value of a belongsTo relationship.
|
|
890
|
+
|
|
891
|
+
`belongsTo` takes an optional hash of options as a second parameter,
|
|
892
|
+
currently supported options are:
|
|
893
|
+
|
|
894
|
+
- `id`: set to `true` if you only want the ID of the related record to be
|
|
895
|
+
returned.
|
|
896
|
+
|
|
897
|
+
Example
|
|
898
|
+
|
|
899
|
+
```js
|
|
900
|
+
// store.push('post', { id: 1, title: 'Hello World' });
|
|
901
|
+
// store.createRecord('comment', { body: 'Lorem ipsum', post: post });
|
|
902
|
+
commentSnapshot.belongsTo('post'); // => Snapshot
|
|
903
|
+
commentSnapshot.belongsTo('post', { id: true }); // => '1'
|
|
904
|
+
|
|
905
|
+
// store.push('comment', { id: 1, body: 'Lorem ipsum' });
|
|
906
|
+
commentSnapshot.belongsTo('post'); // => undefined
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
Calling `belongsTo` will return a new Snapshot as long as there's any known
|
|
910
|
+
data for the relationship available, such as an ID. If the relationship is
|
|
911
|
+
known but unset, `belongsTo` will return `null`. If the contents of the
|
|
912
|
+
relationship is unknown `belongsTo` will return `undefined`.
|
|
913
|
+
|
|
914
|
+
Note: Relationships are loaded lazily and cached upon first access.
|
|
915
|
+
|
|
916
|
+
@public
|
|
917
|
+
@return A snapshot or ID of a known relationship or null if the
|
|
918
|
+
relationship is known but unset. undefined will be returned if the
|
|
919
|
+
contents of the relationship are unknown.
|
|
920
|
+
*/
|
|
921
|
+
belongsTo(keyName: string, options?: {
|
|
922
|
+
id?: boolean;
|
|
923
|
+
}): Snapshot | RecordId | undefined;
|
|
924
|
+
/**
|
|
925
|
+
Returns the current value of a hasMany relationship.
|
|
926
|
+
|
|
927
|
+
`hasMany` takes an optional hash of options as a second parameter,
|
|
928
|
+
currently supported options are:
|
|
929
|
+
|
|
930
|
+
- `ids`: set to `true` if you only want the IDs of the related records to be
|
|
931
|
+
returned.
|
|
932
|
+
|
|
933
|
+
Example
|
|
934
|
+
|
|
935
|
+
```javascript
|
|
936
|
+
// store.push('post', { id: 1, title: 'Hello World', comments: [2, 3] });
|
|
937
|
+
postSnapshot.hasMany('comments'); // => [Snapshot, Snapshot]
|
|
938
|
+
postSnapshot.hasMany('comments', { ids: true }); // => ['2', '3']
|
|
939
|
+
|
|
940
|
+
// store.push('post', { id: 1, title: 'Hello World' });
|
|
941
|
+
postSnapshot.hasMany('comments'); // => undefined
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
Note: Relationships are loaded lazily and cached upon first access.
|
|
945
|
+
|
|
946
|
+
@public
|
|
947
|
+
@return An array of snapshots or IDs of a known
|
|
948
|
+
relationship or an empty array if the relationship is known but unset.
|
|
949
|
+
undefined will be returned if the contents of the relationship is unknown.
|
|
950
|
+
*/
|
|
951
|
+
hasMany(keyName: string, options?: {
|
|
952
|
+
ids?: boolean;
|
|
953
|
+
}): RecordId[] | Snapshot[] | undefined;
|
|
954
|
+
/**
|
|
955
|
+
Iterates through all the attributes of the model, calling the passed
|
|
956
|
+
function on each attribute.
|
|
957
|
+
|
|
958
|
+
Example
|
|
959
|
+
|
|
960
|
+
```javascript
|
|
961
|
+
snapshot.eachAttribute(function(name, meta) {
|
|
962
|
+
// ...
|
|
963
|
+
});
|
|
964
|
+
```
|
|
965
|
+
|
|
966
|
+
@param callback the callback to execute
|
|
967
|
+
@param binding the optional value to which the callback's `this` should be bound
|
|
968
|
+
@public
|
|
969
|
+
*/
|
|
970
|
+
eachAttribute(callback: (key: string, meta: LegacyAttributeField) => void, binding?: unknown): void;
|
|
971
|
+
/**
|
|
972
|
+
Iterates through all the relationships of the model, calling the passed
|
|
973
|
+
function on each relationship.
|
|
974
|
+
|
|
975
|
+
Example
|
|
976
|
+
|
|
977
|
+
```javascript
|
|
978
|
+
snapshot.eachRelationship(function(name, relationship) {
|
|
979
|
+
// ...
|
|
980
|
+
});
|
|
981
|
+
```
|
|
982
|
+
|
|
983
|
+
@param callback the callback to execute
|
|
984
|
+
@param binding the optional value to which the callback's `this` should be bound
|
|
985
|
+
@public
|
|
986
|
+
*/
|
|
987
|
+
eachRelationship(callback: (key: string, meta: LegacyRelationshipField) => void, binding?: unknown): void;
|
|
988
|
+
/**
|
|
989
|
+
Serializes the snapshot using the serializer for the model.
|
|
990
|
+
|
|
991
|
+
Example
|
|
992
|
+
|
|
993
|
+
```js [app/adapters/application.js]
|
|
994
|
+
import Adapter from '@ember-data/adapter';
|
|
995
|
+
|
|
996
|
+
export default Adapter.extend({
|
|
997
|
+
createRecord(store, type, snapshot) {
|
|
998
|
+
let data = snapshot.serialize({ includeId: true });
|
|
999
|
+
let url = `/${type.modelName}`;
|
|
1000
|
+
|
|
1001
|
+
return fetch(url, {
|
|
1002
|
+
method: 'POST',
|
|
1003
|
+
body: data,
|
|
1004
|
+
}).then((response) => response.json())
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
```
|
|
1008
|
+
|
|
1009
|
+
@return an object whose values are primitive JSON values only
|
|
1010
|
+
@public
|
|
1011
|
+
*/
|
|
1012
|
+
serialize(options?: SerializerOptions): unknown;
|
|
1013
|
+
}
|
|
1014
|
+
//#endregion
|
|
1015
|
+
//#region src/compat/legacy-network-handler/snapshot-record-array.d.ts
|
|
1016
|
+
/**
|
|
1017
|
+
SnapshotRecordArray is not directly instantiable.
|
|
1018
|
+
Instances are provided to consuming application's
|
|
1019
|
+
adapters for certain `findAll` requests.
|
|
1020
|
+
|
|
1021
|
+
@hideconstructor
|
|
1022
|
+
@public
|
|
1023
|
+
*/
|
|
1024
|
+
declare class SnapshotRecordArray {
|
|
1025
|
+
/**
|
|
1026
|
+
* An array of snapshots
|
|
1027
|
+
*
|
|
1028
|
+
* @internal
|
|
1029
|
+
*/
|
|
1030
|
+
private _snapshots;
|
|
1031
|
+
/** @internal */
|
|
1032
|
+
private _type;
|
|
1033
|
+
/**
|
|
1034
|
+
* The ResourceType of the underlying records for the {@link Snapshot | Snapshots} in the array
|
|
1035
|
+
*/
|
|
1036
|
+
modelName: string;
|
|
1037
|
+
/** @internal */
|
|
1038
|
+
private __store;
|
|
1039
|
+
/**
|
|
1040
|
+
* A hash of adapter options passed into the store method for this request.
|
|
1041
|
+
|
|
1042
|
+
Example
|
|
1043
|
+
|
|
1044
|
+
```js [app/adapters/post.js]
|
|
1045
|
+
import MyCustomAdapter from './custom-adapter';
|
|
1046
|
+
|
|
1047
|
+
export default class PostAdapter extends MyCustomAdapter {
|
|
1048
|
+
findAll(store, type, sinceToken, snapshotRecordArray) {
|
|
1049
|
+
if (snapshotRecordArray.adapterOptions.subscribe) {
|
|
1050
|
+
// ...
|
|
1051
|
+
}
|
|
1052
|
+
// ...
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
```
|
|
1056
|
+
*/
|
|
1057
|
+
adapterOptions?: Record<string, unknown>;
|
|
1058
|
+
/**
|
|
1059
|
+
* The relationships to include for this request.
|
|
1060
|
+
|
|
1061
|
+
Example
|
|
1062
|
+
|
|
1063
|
+
```js [app/adapters/application.js]
|
|
1064
|
+
import Adapter from '@ember-data/adapter';
|
|
1065
|
+
|
|
1066
|
+
export default class ApplicationAdapter extends Adapter {
|
|
1067
|
+
findAll(store, type, snapshotRecordArray) {
|
|
1068
|
+
let url = `/${type.modelName}?include=${encodeURIComponent(snapshotRecordArray.include)}`;
|
|
1069
|
+
|
|
1070
|
+
return fetch(url).then((response) => response.json())
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
```
|
|
1074
|
+
*/
|
|
1075
|
+
include?: string | string[];
|
|
1076
|
+
/**
|
|
1077
|
+
SnapshotRecordArray is not directly instantiable.
|
|
1078
|
+
Instances are provided to consuming application's
|
|
1079
|
+
adapters and serializers for certain requests.
|
|
1080
|
+
|
|
1081
|
+
@private
|
|
1082
|
+
@constructor
|
|
1083
|
+
@param {Store} store
|
|
1084
|
+
@param {String} type
|
|
1085
|
+
@param options
|
|
1086
|
+
*/
|
|
1087
|
+
constructor(store: Store, type: string, options?: FindAllOptions);
|
|
1088
|
+
/**
|
|
1089
|
+
An array of records
|
|
1090
|
+
|
|
1091
|
+
@internal
|
|
1092
|
+
*/
|
|
1093
|
+
get _recordArray(): LegacyLiveArray;
|
|
1094
|
+
/**
|
|
1095
|
+
Number of records in the array
|
|
1096
|
+
|
|
1097
|
+
Example
|
|
1098
|
+
|
|
1099
|
+
```js [app/adapters/post.js]
|
|
1100
|
+
import JSONAPIAdapter from '@ember-data/adapter/json-api';
|
|
1101
|
+
|
|
1102
|
+
export default class PostAdapter extends JSONAPIAdapter {
|
|
1103
|
+
shouldReloadAll(store, snapshotRecordArray) {
|
|
1104
|
+
return !snapshotRecordArray.length;
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
```
|
|
1108
|
+
*/
|
|
1109
|
+
get length(): number;
|
|
1110
|
+
/**
|
|
1111
|
+
Get snapshots of the underlying record array
|
|
1112
|
+
|
|
1113
|
+
Example
|
|
1114
|
+
|
|
1115
|
+
```js [app/adapters/post.js]
|
|
1116
|
+
import JSONAPIAdapter from '@ember-data/adapter/json-api';
|
|
1117
|
+
|
|
1118
|
+
export default class PostAdapter extends JSONAPIAdapter {
|
|
1119
|
+
shouldReloadAll(store, snapshotArray) {
|
|
1120
|
+
let snapshots = snapshotArray.snapshots();
|
|
1121
|
+
|
|
1122
|
+
return snapshots.any(function(ticketSnapshot) {
|
|
1123
|
+
let timeDiff = moment().diff(ticketSnapshot.attr('lastAccessedAt'), 'minutes');
|
|
1124
|
+
if (timeDiff > 20) {
|
|
1125
|
+
return true;
|
|
1126
|
+
} else {
|
|
1127
|
+
return false;
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
```
|
|
1133
|
+
|
|
1134
|
+
@public
|
|
1135
|
+
@return Array of snapshots
|
|
1136
|
+
*/
|
|
1137
|
+
snapshots(): Snapshot[];
|
|
1138
|
+
}
|
|
1139
|
+
//#endregion
|
|
1140
|
+
//#region src/compat/legacy-network-handler/fetch-manager.d.ts
|
|
1141
|
+
type Deferred<T> = ReturnType<typeof createDeferred<T>>;
|
|
1142
|
+
declare const SaveOp: "___(unique) Symbol(SaveOp)";
|
|
1143
|
+
type FetchMutationOptions = FindRecordOptions & {
|
|
1144
|
+
[SaveOp]: "createRecord" | "deleteRecord" | "updateRecord";
|
|
1145
|
+
};
|
|
1146
|
+
interface PendingFetchItem {
|
|
1147
|
+
identifier: PersistedResourceKey;
|
|
1148
|
+
queryRequest: Request;
|
|
1149
|
+
resolver: Deferred<any>;
|
|
1150
|
+
options: FindRecordOptions;
|
|
1151
|
+
trace?: unknown;
|
|
1152
|
+
promise: Promise<PersistedResourceKey>;
|
|
1153
|
+
}
|
|
1154
|
+
/**
|
|
1155
|
+
* @private
|
|
1156
|
+
*/
|
|
1157
|
+
declare class FetchManager {
|
|
1158
|
+
/**
|
|
1159
|
+
* @internal
|
|
1160
|
+
*/
|
|
1161
|
+
isDestroyed: boolean;
|
|
1162
|
+
/** @internal */
|
|
1163
|
+
private requestCache;
|
|
1164
|
+
/**
|
|
1165
|
+
* @internal
|
|
1166
|
+
*/
|
|
1167
|
+
_pendingFetch: Map<string, Map<PersistedResourceKey, PendingFetchItem[]>>;
|
|
1168
|
+
/** @internal */
|
|
1169
|
+
private _store;
|
|
1170
|
+
constructor(store: Store);
|
|
1171
|
+
createSnapshot<T>(identifier: ResourceKey$1<TypeFromInstance<T>>, options?: FindRecordOptions): Snapshot<T>;
|
|
1172
|
+
createSnapshot(identifier: ResourceKey$1, options?: FindRecordOptions): Snapshot;
|
|
1173
|
+
/**
|
|
1174
|
+
This method is called by `record.save`, and gets passed a
|
|
1175
|
+
resolver for the promise that `record.save` returns.
|
|
1176
|
+
|
|
1177
|
+
It schedules saving to happen at the end of the run loop.
|
|
1178
|
+
|
|
1179
|
+
@private
|
|
1180
|
+
*/
|
|
1181
|
+
scheduleSave(identifier: ResourceKey$1, options: FetchMutationOptions): Promise<null | SingleResourceDocument>;
|
|
1182
|
+
scheduleFetch(identifier: PersistedResourceKey, options: FindRecordOptions, request: ImmutableRequestInfo): Promise<PersistedResourceKey>;
|
|
1183
|
+
getPendingFetch(identifier: PersistedResourceKey, options: FindRecordOptions): Promise<PersistedResourceKey> | undefined;
|
|
1184
|
+
flushAllPendingFetches(): void;
|
|
1185
|
+
fetchDataIfNeededForIdentifier(identifier: PersistedResourceKey, options: FindRecordOptions | undefined, request: ImmutableRequestInfo): Promise<PersistedResourceKey>;
|
|
1186
|
+
destroy(): void;
|
|
1187
|
+
}
|
|
1188
|
+
//#endregion
|
|
1189
|
+
//#region src/compat/-private.d.ts
|
|
1190
|
+
declare function upgradeStore(store: Store): asserts store is CompatStore;
|
|
1191
|
+
//#endregion
|
|
1192
|
+
//#region src/compat/legacy-network-handler/legacy-network-handler.d.ts
|
|
1193
|
+
/**
|
|
1194
|
+
* A {@link Handler} that fulfills legacy `findRecord`/`findAll`/`query`/
|
|
1195
|
+
* `queryRecord`/`findBelongsTo`/`findHasMany`/`createRecord`/`updateRecord`/
|
|
1196
|
+
* `deleteRecord` requests using the store's configured {@link MinimumAdapterInterface | adapter}
|
|
1197
|
+
* and {@link MinimumSerializerInterface | serializer}, passing any other
|
|
1198
|
+
* request through to the next handler unchanged.
|
|
1199
|
+
*/
|
|
1200
|
+
declare const LegacyNetworkHandler: Handler;
|
|
1201
|
+
//#endregion
|
|
1202
|
+
//#region src/compat.d.ts
|
|
1203
|
+
/**
|
|
1204
|
+
* Extends the signature of {@link Store} with additional
|
|
1205
|
+
* methods available when using the legacy network layer.
|
|
1206
|
+
*
|
|
1207
|
+
* @public
|
|
1208
|
+
* @noInheritDoc
|
|
1209
|
+
* @legacy
|
|
1210
|
+
*/
|
|
1211
|
+
interface LegacyStoreCompat extends Store {
|
|
1212
|
+
/**
|
|
1213
|
+
* @private
|
|
1214
|
+
*/
|
|
1215
|
+
_fetchManager: FetchManager;
|
|
1216
|
+
/**
|
|
1217
|
+
* Returns the adapter instance for the given model type, instantiating
|
|
1218
|
+
* it (and caching the instance) if necessary. See {@link adapterFor}.
|
|
1219
|
+
*/
|
|
1220
|
+
adapterFor(this: Store, modelName: string): MinimumAdapterInterface;
|
|
1221
|
+
/**
|
|
1222
|
+
* Same as the single-argument overload, but returns `undefined` instead
|
|
1223
|
+
* of throwing/asserting when `_allowMissing` is `true` and no adapter
|
|
1224
|
+
* is found.
|
|
1225
|
+
*/
|
|
1226
|
+
adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;
|
|
1227
|
+
/**
|
|
1228
|
+
* Returns the serializer instance for the given model type, instantiating
|
|
1229
|
+
* it (and caching the instance) if necessary. See {@link serializerFor}.
|
|
1230
|
+
*/
|
|
1231
|
+
serializerFor<K extends string>(modelName: K, _allowMissing?: boolean): MinimumSerializerInterface | null;
|
|
1232
|
+
/**
|
|
1233
|
+
* Normalizes a payload for the given model type using its serializer.
|
|
1234
|
+
* See {@link normalize}.
|
|
1235
|
+
*/
|
|
1236
|
+
normalize(modelName: string, payload: ObjectValue): ObjectValue;
|
|
1237
|
+
/**
|
|
1238
|
+
* Pushes a payload into the store using the appropriate serializer to
|
|
1239
|
+
* normalize it first. See {@link pushPayload}.
|
|
1240
|
+
*/
|
|
1241
|
+
pushPayload(modelName: string, payload: ObjectValue): void;
|
|
1242
|
+
/**
|
|
1243
|
+
* Serializes a record using its serializer. See {@link serializeRecord}.
|
|
1244
|
+
*/
|
|
1245
|
+
serializeRecord(record: unknown, options?: SerializerOptions): unknown;
|
|
1246
|
+
/**
|
|
1247
|
+
* @private
|
|
1248
|
+
*/
|
|
1249
|
+
_adapterCache: Record<string, MinimumAdapterInterface & {
|
|
1250
|
+
store: Store;
|
|
1251
|
+
}>;
|
|
1252
|
+
/**
|
|
1253
|
+
* @private
|
|
1254
|
+
*/
|
|
1255
|
+
_serializerCache: Record<string, MinimumSerializerInterface & {
|
|
1256
|
+
store: Store;
|
|
1257
|
+
}>;
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* @deprecated - use {@link LegacyStoreCompat} instead
|
|
1261
|
+
*/
|
|
1262
|
+
type CompatStore = LegacyStoreCompat;
|
|
1263
|
+
/**
|
|
1264
|
+
Returns an instance of the adapter for a given type. For
|
|
1265
|
+
example, `adapterFor('person')` will return an instance of
|
|
1266
|
+
the adapter located at `app/adapters/person.js`
|
|
1267
|
+
|
|
1268
|
+
If no `person` adapter is found, this method will look
|
|
1269
|
+
for an `application` adapter (the default adapter for
|
|
1270
|
+
your entire application).
|
|
1271
|
+
|
|
1272
|
+
@public
|
|
1273
|
+
@param modelName
|
|
1274
|
+
*/
|
|
1275
|
+
declare function adapterFor(this: Store, modelName: string): MinimumAdapterInterface;
|
|
1276
|
+
declare function adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;
|
|
1277
|
+
/**
|
|
1278
|
+
Returns an instance of the serializer for a given type. For
|
|
1279
|
+
example, `serializerFor('person')` will return an instance of
|
|
1280
|
+
`App.PersonSerializer`.
|
|
1281
|
+
|
|
1282
|
+
If no `App.PersonSerializer` is found, this method will look
|
|
1283
|
+
for an `App.ApplicationSerializer` (the default serializer for
|
|
1284
|
+
your entire application).
|
|
1285
|
+
|
|
1286
|
+
If a serializer cannot be found on the adapter, it will fall back
|
|
1287
|
+
to an instance of `JSONSerializer`.
|
|
1288
|
+
|
|
1289
|
+
@public
|
|
1290
|
+
@param modelName the record to serialize
|
|
1291
|
+
*/
|
|
1292
|
+
declare function serializerFor(this: Store, modelName: string): MinimumSerializerInterface | null;
|
|
1293
|
+
/**
|
|
1294
|
+
`normalize` converts a json payload into the normalized form expected by
|
|
1295
|
+
{@link Store.push | push} using the serializer specified by `modelName`
|
|
1296
|
+
|
|
1297
|
+
:::warning
|
|
1298
|
+
Generally it would be better to invoke the serializer yourself directly,
|
|
1299
|
+
or write a more specialized normalization utility.
|
|
1300
|
+
:::
|
|
1301
|
+
|
|
1302
|
+
Example
|
|
1303
|
+
|
|
1304
|
+
```js
|
|
1305
|
+
socket.on('message', function(message) {
|
|
1306
|
+
let modelName = message.model;
|
|
1307
|
+
let data = message.data;
|
|
1308
|
+
store.push(store.normalize(modelName, data));
|
|
1309
|
+
});
|
|
1310
|
+
```
|
|
1311
|
+
|
|
1312
|
+
@legacy
|
|
1313
|
+
@public
|
|
1314
|
+
@param modelName The name of the model type for this payload
|
|
1315
|
+
@return The normalized payload
|
|
1316
|
+
*/
|
|
1317
|
+
declare function normalize(this: Store, modelName: string, payload: ObjectValue): SingleResourceDocument;
|
|
1318
|
+
/**
|
|
1319
|
+
Push some raw data into the store.
|
|
1320
|
+
|
|
1321
|
+
This method can be used both to push in brand new
|
|
1322
|
+
records, as well as to update existing records. You
|
|
1323
|
+
can push in more than one type of object at once.
|
|
1324
|
+
All objects should be in the format expected by the
|
|
1325
|
+
serializer.
|
|
1326
|
+
|
|
1327
|
+
```js [app/serializers/application.js]
|
|
1328
|
+
import RESTSerializer from '@warp-drive/legacy/serializer/rest';
|
|
1329
|
+
|
|
1330
|
+
export default class ApplicationSerializer extends RESTSerializer;
|
|
1331
|
+
```
|
|
1332
|
+
|
|
1333
|
+
```js
|
|
1334
|
+
let pushData = {
|
|
1335
|
+
posts: [
|
|
1336
|
+
{ id: 1, postTitle: "Great post", commentIds: [2] }
|
|
1337
|
+
],
|
|
1338
|
+
comments: [
|
|
1339
|
+
{ id: 2, commentBody: "Insightful comment" }
|
|
1340
|
+
]
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
store.pushPayload(pushData);
|
|
1344
|
+
```
|
|
1345
|
+
|
|
1346
|
+
By default, the data will be deserialized using a default
|
|
1347
|
+
serializer (the application serializer if it exists).
|
|
1348
|
+
|
|
1349
|
+
Alternatively, `pushPayload` will accept a model type which
|
|
1350
|
+
will determine which serializer will process the payload.
|
|
1351
|
+
|
|
1352
|
+
```js [app/serializers/application.js]
|
|
1353
|
+
import RESTSerializer from '@warp-drive/legacy/serializer/rest';
|
|
1354
|
+
|
|
1355
|
+
export default class ApplicationSerializer extends RESTSerializer;
|
|
1356
|
+
```
|
|
1357
|
+
|
|
1358
|
+
```js [app/serializers/post.js]
|
|
1359
|
+
import JSONSerializer from '@warp-drive/legacy/serializer/json';
|
|
1360
|
+
|
|
1361
|
+
export default JSONSerializer;
|
|
1362
|
+
```
|
|
1363
|
+
|
|
1364
|
+
```js
|
|
1365
|
+
store.pushPayload(pushData); // Will use the application serializer
|
|
1366
|
+
store.pushPayload('post', pushData); // Will use the post serializer
|
|
1367
|
+
```
|
|
1368
|
+
|
|
1369
|
+
@public
|
|
1370
|
+
@param modelName Optionally, a model type used to determine which serializer will be used
|
|
1371
|
+
@param inputPayload
|
|
1372
|
+
*/
|
|
1373
|
+
declare function pushPayload(this: Store, modelName: string, inputPayload: ObjectValue): void;
|
|
1374
|
+
/**
|
|
1375
|
+
* Serializes a record using the store's legacy network layer, as with
|
|
1376
|
+
* {@link LegacyStoreCompat.serializeRecord | store.serializeRecord}.
|
|
1377
|
+
*/
|
|
1378
|
+
declare function serializeRecord(this: Store, record: unknown, options?: SerializerOptions): unknown;
|
|
1379
|
+
/**
|
|
1380
|
+
* Destroys any adapters/serializers the legacy network layer has created
|
|
1381
|
+
* for this store, invoked when the store itself is destroyed.
|
|
1382
|
+
*/
|
|
1383
|
+
declare function cleanup(this: Store): void;
|
|
1384
|
+
//#endregion
|
|
1385
|
+
export { AdapterPayload as _, normalize as a, serializerFor as c, FetchManager as d, SaveOp as f, SerializerOptions as g, MinimumSerializerInterface as h, cleanup as i, LegacyNetworkHandler as l, Snapshot as m, LegacyStoreCompat as n, pushPayload as o, SnapshotRecordArray as p, adapterFor as r, serializeRecord as s, CompatStore as t, upgradeStore as u, MinimumAdapterInterface as v };
|
|
1386
|
+
//# sourceMappingURL=compat-BbNNmTM-.d.ts.map
|