@warp-drive-mirror/core 5.10.0-alpha.2 → 5.10.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -6
- package/dist/{-private-ffnwf62T.js → -private-BiuED7nc.js} +5 -4
- package/dist/{-private-ffnwf62T.js.map → -private-BiuED7nc.js.map} +1 -1
- package/dist/{-private-CArItnX4.js → -private-CvZfrDZl.js} +566 -179
- package/dist/-private-CvZfrDZl.js.map +1 -0
- package/dist/{aliases-BWYW5EhX.d.ts → aliases-BG5TxALl.d.ts} +4 -3
- package/dist/aliases-BG5TxALl.d.ts.map +1 -0
- package/dist/{change-C7kqv2kW.d.ts → change-INHMiZ2a.d.ts} +4 -4
- package/dist/change-INHMiZ2a.d.ts.map +1 -0
- package/dist/{concepts-DFldVwEM.d.ts → concepts-vh86nAcd.d.ts} +14 -7
- package/dist/concepts-vh86nAcd.d.ts.map +1 -0
- package/dist/{configure-B_F639tN.d.ts → configure-BfXDuPUb.d.ts} +57 -10
- package/dist/configure-BfXDuPUb.d.ts.map +1 -0
- package/dist/configure.d.ts +2 -2
- package/dist/configure.js +2 -2
- package/dist/{document-Ca4ZZBd9.d.ts → document-B8Fup751.d.ts} +22 -6
- package/dist/document-B8Fup751.d.ts.map +1 -0
- package/dist/{error-0uD6GkNX.d.ts → error-j5n1yL9m.d.ts} +4 -4
- package/dist/error-j5n1yL9m.d.ts.map +1 -0
- package/dist/{fields-FM7peCiM.d.ts → fields-r1rZJB9d.d.ts} +134 -9
- package/dist/fields-r1rZJB9d.d.ts.map +1 -0
- package/dist/graph/-private.d.ts +1 -1
- package/dist/graph/-private.js +25 -40
- package/dist/graph/-private.js.map +1 -1
- package/dist/{graph-DLqYXP2z.d.ts → graph-BqxaFjEb.d.ts} +25 -7
- package/dist/graph-BqxaFjEb.d.ts.map +1 -0
- package/dist/{identifier-DQnqOSJK.d.ts → identifier-DmgDehQK.d.ts} +29 -6
- package/dist/identifier-DmgDehQK.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{internal-BrqYbG_y.d.ts → internal-D_WIXC4r.d.ts} +1524 -1121
- package/dist/internal-D_WIXC4r.d.ts.map +1 -0
- package/dist/{json-api-raw-C5APJHHB.d.ts → json-api-raw-juUdIITO.d.ts} +44 -4
- package/dist/json-api-raw-juUdIITO.d.ts.map +1 -0
- package/dist/{mutations-CqtoGB4t.d.ts → mutations-CA39mior.d.ts} +18 -4
- package/dist/mutations-CA39mior.d.ts.map +1 -0
- package/dist/{operations-D1qA6r0_.d.ts → operations-C1WAEKKq.d.ts} +39 -7
- package/dist/operations-C1WAEKKq.d.ts.map +1 -0
- package/dist/{params-DrEx3bf8.d.ts → params-CNLjCRyH.d.ts} +11 -3
- package/dist/params-CNLjCRyH.d.ts.map +1 -0
- package/dist/{raw-D5hnjiq7.d.ts → raw-adYGuEGM.d.ts} +10 -3
- package/dist/raw-adYGuEGM.d.ts.map +1 -0
- package/dist/reactive/-private.d.ts +1 -1
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.d.ts +2 -2
- package/dist/reactive.js +3 -3
- package/dist/{record-D3QQcaIR.d.ts → record-f5-uOgHt.d.ts} +22 -4
- package/dist/record-f5-uOgHt.d.ts.map +1 -0
- package/dist/{relationship-CmHzMPKf.d.ts → relationship-99pc4CaS.d.ts} +10 -5
- package/dist/relationship-99pc4CaS.d.ts.map +1 -0
- package/dist/{request-o_qGAoFV.js → request-CxtnNIIp.js} +52 -23
- package/dist/request-CxtnNIIp.js.map +1 -0
- package/dist/request.d.ts +1 -1
- package/dist/request.js +1 -1
- package/dist/signals/-leaked.d.ts +86 -18
- package/dist/signals/-leaked.d.ts.map +1 -1
- package/dist/signals/-leaked.js +1 -1
- package/dist/{src-C-xK8l3f.js → src-ccp1WKyt.js} +350 -456
- package/dist/src-ccp1WKyt.js.map +1 -0
- package/dist/store/-private.d.ts +2 -2
- package/dist/store/-private.js +2 -2
- package/dist/{store-DNF9Rgoh.js → store-C8iKKtQK.js} +17 -3
- package/dist/store-C8iKKtQK.js.map +1 -0
- package/dist/store.d.ts +1 -1
- package/dist/store.js +1 -1
- package/dist/{symbols-DjRDCeX0.d.ts → symbols-DVa1PMFG.d.ts} +10 -3
- package/dist/symbols-DVa1PMFG.d.ts.map +1 -0
- package/dist/types/-private.d.ts +1 -2
- package/dist/types/-private.d.ts.map +1 -1
- package/dist/types/-private.js +115 -2
- package/dist/types/-private.js.map +1 -0
- package/dist/types/cache/aliases.d.ts +1 -1
- package/dist/types/cache/change.d.ts +1 -1
- package/dist/types/cache/mutations.d.ts +1 -1
- package/dist/types/cache/operations.d.ts +1 -1
- package/dist/types/cache/relationship.d.ts +1 -1
- package/dist/types/cache.d.ts +1 -1
- package/dist/types/graph.d.ts +1 -1
- package/dist/types/identifier.d.ts +1 -1
- package/dist/types/identifier.js +34 -5
- package/dist/types/identifier.js.map +1 -1
- package/dist/types/json/raw.d.ts +1 -1
- package/dist/types/params.d.ts +1 -1
- package/dist/types/record.d.ts +1 -1
- package/dist/types/record.js +26 -2
- package/dist/types/record.js.map +1 -1
- package/dist/types/request.d.ts +1 -1
- package/dist/types/request.js +82 -3
- package/dist/types/request.js.map +1 -1
- package/dist/types/runtime.d.ts +10 -7
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/runtime.js +9 -6
- package/dist/types/runtime.js.map +1 -1
- package/dist/types/schema/concepts.d.ts +1 -1
- package/dist/types/schema/fields.d.ts +1 -1
- package/dist/types/schema/fields.js +133 -5
- package/dist/types/schema/fields.js.map +1 -1
- package/dist/types/schema/schema-service.d.ts +1 -1
- package/dist/types/spec/document.d.ts +1 -1
- package/dist/types/spec/error.d.ts +1 -1
- package/dist/types/spec/json-api-raw.d.ts +1 -1
- package/dist/types/symbols.d.ts +1 -1
- package/dist/types/symbols.js +16 -3
- package/dist/types/symbols.js.map +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/unpkg/{dev-deprecated/-private-CM5N2rtZ.js → dev/-private-B4pCmkq-.js} +566 -179
- package/dist/unpkg/dev/-private-B4pCmkq-.js.map +1 -0
- package/dist/unpkg/{prod-deprecated/-private-207KndDu.js → dev/-private-BiuED7nc.js} +5 -4
- package/dist/unpkg/{dev-deprecated/-private-BO-nArRb.js.map → dev/-private-BiuED7nc.js.map} +1 -1
- package/dist/unpkg/dev/configure.js +2 -2
- package/dist/unpkg/dev/graph/-private.js +26 -41
- package/dist/unpkg/dev/graph/-private.js.map +1 -1
- package/dist/unpkg/dev/index.js +1 -1
- package/dist/unpkg/dev/reactive/-private.js +1 -1
- package/dist/unpkg/dev/reactive.js +3 -3
- package/dist/unpkg/{dev-deprecated/request-DXPAtRhE.js → dev/request-oWpijCPQ.js} +52 -23
- package/dist/unpkg/dev/request-oWpijCPQ.js.map +1 -0
- package/dist/unpkg/dev/request.js +1 -1
- package/dist/unpkg/dev/{runtime-DW881fpw.js → runtime-RYvEtg99.js} +2 -3
- package/dist/unpkg/dev/{runtime-DW881fpw.js.map → runtime-RYvEtg99.js.map} +1 -1
- package/dist/unpkg/dev/signals/-leaked.js +1 -1
- package/dist/unpkg/dev/{src-kn6qfEPI.js → src-C4ET4R1n.js} +339 -444
- package/dist/unpkg/dev/src-C4ET4R1n.js.map +1 -0
- package/dist/unpkg/dev/store/-private.js +2 -2
- package/dist/unpkg/{dev-deprecated/store-D-z_1Jxe.js → dev/store-dZViNfMK.js} +18 -4
- package/dist/unpkg/dev/store-dZViNfMK.js.map +1 -0
- package/dist/unpkg/dev/store.js +1 -1
- package/dist/unpkg/dev/types/-private.js +106 -2
- package/dist/unpkg/dev/types/-private.js.map +1 -0
- package/dist/unpkg/dev/types/identifier.js +34 -5
- package/dist/unpkg/dev/types/identifier.js.map +1 -1
- package/dist/unpkg/dev/types/record.js +26 -2
- package/dist/unpkg/dev/types/record.js.map +1 -1
- package/dist/unpkg/dev/types/request.js +82 -3
- package/dist/unpkg/dev/types/request.js.map +1 -1
- package/dist/unpkg/dev/types/runtime.js +9 -6
- package/dist/unpkg/dev/types/runtime.js.map +1 -1
- package/dist/unpkg/dev/types/schema/fields.js +133 -5
- package/dist/unpkg/dev/types/schema/fields.js.map +1 -1
- package/dist/unpkg/dev/types/symbols.js +16 -3
- package/dist/unpkg/dev/types/symbols.js.map +1 -1
- package/dist/unpkg/dev/utils/string.js +1 -2
- package/dist/unpkg/{dev/-private-CM5N2rtZ.js → dev-deprecated/-private-B4pCmkq-.js} +566 -179
- package/dist/unpkg/dev-deprecated/-private-B4pCmkq-.js.map +1 -0
- package/dist/unpkg/dev-deprecated/{-private-BO-nArRb.js → -private-BiuED7nc.js} +5 -4
- package/dist/unpkg/{prod/-private-207KndDu.js.map → dev-deprecated/-private-BiuED7nc.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/configure.js +2 -2
- package/dist/unpkg/dev-deprecated/graph/-private.js +26 -41
- package/dist/unpkg/dev-deprecated/graph/-private.js.map +1 -1
- package/dist/unpkg/dev-deprecated/index.js +1 -1
- package/dist/unpkg/dev-deprecated/reactive/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/reactive.js +3 -3
- package/dist/unpkg/{dev/request-DXPAtRhE.js → dev-deprecated/request-oWpijCPQ.js} +52 -23
- package/dist/unpkg/dev-deprecated/request-oWpijCPQ.js.map +1 -0
- package/dist/unpkg/dev-deprecated/request.js +1 -1
- package/dist/unpkg/dev-deprecated/{runtime-BIra6K31.js → runtime-DZVuMuzL.js} +2 -3
- package/dist/unpkg/dev-deprecated/{runtime-BIra6K31.js.map → runtime-DZVuMuzL.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/signals/-leaked.js +1 -1
- package/dist/unpkg/dev-deprecated/{src-DXwW-R57.js → src-jHpowq3S.js} +344 -450
- package/dist/unpkg/dev-deprecated/src-jHpowq3S.js.map +1 -0
- package/dist/unpkg/dev-deprecated/store/-private.js +2 -2
- package/dist/unpkg/{dev/store-C0p6sclI.js → dev-deprecated/store-I7YB0_rC.js} +18 -4
- package/dist/unpkg/dev-deprecated/store-I7YB0_rC.js.map +1 -0
- package/dist/unpkg/dev-deprecated/store.js +1 -1
- package/dist/unpkg/dev-deprecated/types/-private.js +106 -2
- package/dist/unpkg/dev-deprecated/types/-private.js.map +1 -0
- package/dist/unpkg/dev-deprecated/types/identifier.js +34 -5
- package/dist/unpkg/dev-deprecated/types/identifier.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/record.js +26 -2
- package/dist/unpkg/dev-deprecated/types/record.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/request.js +82 -3
- package/dist/unpkg/dev-deprecated/types/request.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/runtime.js +9 -6
- package/dist/unpkg/dev-deprecated/types/runtime.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/schema/fields.js +133 -5
- package/dist/unpkg/dev-deprecated/types/schema/fields.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/symbols.js +16 -3
- package/dist/unpkg/dev-deprecated/types/symbols.js.map +1 -1
- package/dist/unpkg/dev-deprecated/utils/string.js +1 -2
- package/dist/unpkg/prod/-private-BiuED7nc.js +23 -0
- package/dist/unpkg/{prod-deprecated/-private-207KndDu.js.map → prod/-private-BiuED7nc.js.map} +1 -1
- package/dist/unpkg/{prod-deprecated/-private-CdDed4yB.js → prod/-private-CrUi_3E_.js} +539 -173
- package/dist/unpkg/prod/-private-CrUi_3E_.js.map +1 -0
- package/dist/unpkg/prod/configure.js +2 -2
- package/dist/unpkg/prod/graph/-private.js +24 -35
- package/dist/unpkg/prod/graph/-private.js.map +1 -1
- package/dist/unpkg/prod/index.js +1 -1
- package/dist/unpkg/prod/reactive/-private.js +1 -1
- package/dist/unpkg/prod/reactive.js +3 -3
- package/dist/unpkg/prod/{request-C7WZg-zk.js → request-Cgw3j6Dx.js} +51 -21
- package/dist/unpkg/prod/request-Cgw3j6Dx.js.map +1 -0
- package/dist/unpkg/prod/request.js +1 -1
- package/dist/unpkg/prod/signals/-leaked.js +1 -1
- package/dist/unpkg/prod/{src-B-GfFQcx.js → src-DFmPDGQ6.js} +311 -414
- package/dist/unpkg/prod/src-DFmPDGQ6.js.map +1 -0
- package/dist/unpkg/prod/store/-private.js +2 -2
- package/dist/unpkg/prod/{store-BWhmb7Ob.js → store-Bz9R5hGB.js} +17 -3
- package/dist/unpkg/prod/store-Bz9R5hGB.js.map +1 -0
- package/dist/unpkg/prod/store.js +1 -1
- package/dist/unpkg/prod/types/-private.js +94 -2
- package/dist/unpkg/prod/types/-private.js.map +1 -0
- package/dist/unpkg/prod/types/identifier.js +34 -5
- package/dist/unpkg/prod/types/identifier.js.map +1 -1
- package/dist/unpkg/prod/types/record.js +26 -2
- package/dist/unpkg/prod/types/record.js.map +1 -1
- package/dist/unpkg/prod/types/request.js +82 -3
- package/dist/unpkg/prod/types/request.js.map +1 -1
- package/dist/unpkg/prod/types/runtime.js +9 -6
- package/dist/unpkg/prod/types/runtime.js.map +1 -1
- package/dist/unpkg/prod/types/schema/fields.js +133 -5
- package/dist/unpkg/prod/types/schema/fields.js.map +1 -1
- package/dist/unpkg/prod/types/symbols.js +16 -3
- package/dist/unpkg/prod/types/symbols.js.map +1 -1
- package/dist/unpkg/prod/utils/string.js +1 -2
- package/dist/unpkg/{dev/-private-BO-nArRb.js → prod-deprecated/-private-BiuED7nc.js} +5 -4
- package/dist/unpkg/{dev/-private-BO-nArRb.js.map → prod-deprecated/-private-BiuED7nc.js.map} +1 -1
- package/dist/unpkg/{prod/-private-CdDed4yB.js → prod-deprecated/-private-CrUi_3E_.js} +539 -173
- package/dist/unpkg/prod-deprecated/-private-CrUi_3E_.js.map +1 -0
- package/dist/unpkg/prod-deprecated/configure.js +2 -2
- package/dist/unpkg/prod-deprecated/graph/-private.js +24 -35
- package/dist/unpkg/prod-deprecated/graph/-private.js.map +1 -1
- package/dist/unpkg/prod-deprecated/index.js +1 -1
- package/dist/unpkg/prod-deprecated/reactive/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/reactive.js +3 -3
- package/dist/unpkg/prod-deprecated/{request-C7WZg-zk.js → request-Cgw3j6Dx.js} +51 -21
- package/dist/unpkg/prod-deprecated/request-Cgw3j6Dx.js.map +1 -0
- package/dist/unpkg/prod-deprecated/request.js +1 -1
- package/dist/unpkg/prod-deprecated/signals/-leaked.js +1 -1
- package/dist/unpkg/prod-deprecated/{src-Bp8ZJctZ.js → src-BgQLcshl.js} +316 -420
- package/dist/unpkg/prod-deprecated/src-BgQLcshl.js.map +1 -0
- package/dist/unpkg/prod-deprecated/store/-private.js +2 -2
- package/dist/unpkg/prod-deprecated/{store-BWhmb7Ob.js → store-Bz9R5hGB.js} +17 -3
- package/dist/unpkg/prod-deprecated/store-Bz9R5hGB.js.map +1 -0
- package/dist/unpkg/prod-deprecated/store.js +1 -1
- package/dist/unpkg/prod-deprecated/types/-private.js +94 -2
- package/dist/unpkg/prod-deprecated/types/-private.js.map +1 -0
- package/dist/unpkg/prod-deprecated/types/identifier.js +34 -5
- package/dist/unpkg/prod-deprecated/types/identifier.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/record.js +26 -2
- package/dist/unpkg/prod-deprecated/types/record.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/request.js +82 -3
- package/dist/unpkg/prod-deprecated/types/request.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/runtime.js +9 -6
- package/dist/unpkg/prod-deprecated/types/runtime.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/schema/fields.js +133 -5
- package/dist/unpkg/prod-deprecated/types/schema/fields.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/symbols.js +16 -3
- package/dist/unpkg/prod-deprecated/types/symbols.js.map +1 -1
- package/dist/unpkg/prod-deprecated/utils/string.js +1 -2
- package/dist/utils/string.d.ts +0 -2
- package/dist/utils/string.d.ts.map +1 -1
- package/dist/utils/string.js +1 -2
- package/dist/{utils-BtURiy8l.d.ts → utils-BVKvrO6e.d.ts} +8 -3
- package/dist/utils-BVKvrO6e.d.ts.map +1 -0
- package/logos/README.md +1 -1
- package/package.json +9 -9
- package/dist/-private-CArItnX4.js.map +0 -1
- package/dist/-private-CWh7qdp_.js +0 -120
- package/dist/-private-CWh7qdp_.js.map +0 -1
- package/dist/aliases-BWYW5EhX.d.ts.map +0 -1
- package/dist/change-C7kqv2kW.d.ts.map +0 -1
- package/dist/concepts-DFldVwEM.d.ts.map +0 -1
- package/dist/configure-B_F639tN.d.ts.map +0 -1
- package/dist/document-Ca4ZZBd9.d.ts.map +0 -1
- package/dist/error-0uD6GkNX.d.ts.map +0 -1
- package/dist/fields-FM7peCiM.d.ts.map +0 -1
- package/dist/graph-DLqYXP2z.d.ts.map +0 -1
- package/dist/identifier-DQnqOSJK.d.ts.map +0 -1
- package/dist/internal-BrqYbG_y.d.ts.map +0 -1
- package/dist/json-api-raw-C5APJHHB.d.ts.map +0 -1
- package/dist/mutations-CqtoGB4t.d.ts.map +0 -1
- package/dist/operations-D1qA6r0_.d.ts.map +0 -1
- package/dist/params-DrEx3bf8.d.ts.map +0 -1
- package/dist/raw-D5hnjiq7.d.ts.map +0 -1
- package/dist/record-D3QQcaIR.d.ts.map +0 -1
- package/dist/relationship-CmHzMPKf.d.ts.map +0 -1
- package/dist/request-o_qGAoFV.js.map +0 -1
- package/dist/src-C-xK8l3f.js.map +0 -1
- package/dist/store-DNF9Rgoh.js.map +0 -1
- package/dist/symbols-DjRDCeX0.d.ts.map +0 -1
- package/dist/types/schema/fields.type-test.d.ts +0 -1
- package/dist/types/schema/fields.type-test.js +0 -79
- package/dist/types/schema/fields.type-test.js.map +0 -1
- package/dist/unpkg/dev/-private-BP52H-vC.js +0 -111
- package/dist/unpkg/dev/-private-BP52H-vC.js.map +0 -1
- package/dist/unpkg/dev/-private-CM5N2rtZ.js.map +0 -1
- package/dist/unpkg/dev/request-DXPAtRhE.js.map +0 -1
- package/dist/unpkg/dev/src-kn6qfEPI.js.map +0 -1
- package/dist/unpkg/dev/store-C0p6sclI.js.map +0 -1
- package/dist/unpkg/dev/types/schema/fields.type-test.js +0 -79
- package/dist/unpkg/dev/types/schema/fields.type-test.js.map +0 -1
- package/dist/unpkg/dev-deprecated/-private-BP52H-vC.js +0 -111
- package/dist/unpkg/dev-deprecated/-private-BP52H-vC.js.map +0 -1
- package/dist/unpkg/dev-deprecated/-private-CM5N2rtZ.js.map +0 -1
- package/dist/unpkg/dev-deprecated/request-DXPAtRhE.js.map +0 -1
- package/dist/unpkg/dev-deprecated/src-DXwW-R57.js.map +0 -1
- package/dist/unpkg/dev-deprecated/store-D-z_1Jxe.js.map +0 -1
- package/dist/unpkg/dev-deprecated/types/schema/fields.type-test.js +0 -79
- package/dist/unpkg/dev-deprecated/types/schema/fields.type-test.js.map +0 -1
- package/dist/unpkg/prod/-private-207KndDu.js +0 -22
- package/dist/unpkg/prod/-private-CdDed4yB.js.map +0 -1
- package/dist/unpkg/prod/-private-JmhZBKGb.js +0 -99
- package/dist/unpkg/prod/-private-JmhZBKGb.js.map +0 -1
- package/dist/unpkg/prod/request-C7WZg-zk.js.map +0 -1
- package/dist/unpkg/prod/src-B-GfFQcx.js.map +0 -1
- package/dist/unpkg/prod/store-BWhmb7Ob.js.map +0 -1
- package/dist/unpkg/prod/types/schema/fields.type-test.js +0 -79
- package/dist/unpkg/prod/types/schema/fields.type-test.js.map +0 -1
- package/dist/unpkg/prod-deprecated/-private-CdDed4yB.js.map +0 -1
- package/dist/unpkg/prod-deprecated/-private-JmhZBKGb.js +0 -99
- package/dist/unpkg/prod-deprecated/-private-JmhZBKGb.js.map +0 -1
- package/dist/unpkg/prod-deprecated/request-C7WZg-zk.js.map +0 -1
- package/dist/unpkg/prod-deprecated/src-Bp8ZJctZ.js.map +0 -1
- package/dist/unpkg/prod-deprecated/store-BWhmb7Ob.js.map +0 -1
- package/dist/unpkg/prod-deprecated/types/schema/fields.type-test.js +0 -79
- package/dist/unpkg/prod-deprecated/types/schema/fields.type-test.js.map +0 -1
- package/dist/utils-BtURiy8l.d.ts.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as ARRAY_SIGNAL, C as createInternalMemo, D as notifyInternalSignal,
|
|
1
|
+
import { getOrSetGlobal, peekTransient, peekUniversalTransient, setTransient, setUniversalTransient } from "./types/-private.js";
|
|
2
|
+
import { A as ARRAY_SIGNAL, C as createInternalMemo, D as notifyInternalSignal, F as willSyncFlushWatchers, O as peekInternalSignal, S as consumeInternalSignal, T as getOrCreateInternalSignal, _ as entangleSignal, f as createSignalDescriptor, g as entangleInitiallyStaleSignal, h as defineSignal, j as OBJECT_SIGNAL, k as withSignalStore, p as defineGate, w as createInternalSignal, x as Signals } from "./-private-CrUi_3E_.js";
|
|
3
3
|
import { EnableHydration, STRUCTURED, SkipCache } from "./types/request.js";
|
|
4
|
-
import { a as upgradePromise, c as executeNextHandler, d as getRequestResult, f as setPromiseResult, l as clearRequestResult, o as DOMError, p as cloneResponseProperties, s as IS_CACHE_HANDLER, t as withBrand } from "./request-
|
|
5
|
-
import { a as SOURCE, i as Destroy, n as Commit, r as Context, t as Checkout } from "./-private-
|
|
4
|
+
import { a as upgradePromise, c as executeNextHandler, d as getRequestResult, f as setPromiseResult, l as clearRequestResult, o as DOMError, p as cloneResponseProperties, s as IS_CACHE_HANDLER, t as withBrand } from "./request-Cgw3j6Dx.js";
|
|
5
|
+
import { a as SOURCE, i as Destroy, n as Commit, r as Context, t as Checkout } from "./-private-BiuED7nc.js";
|
|
6
6
|
import { CACHE_OWNER } from "./types/identifier.js";
|
|
7
7
|
import { dasherize } from "./utils/string.js";
|
|
8
8
|
import { RecordStore, Type } from "./types/symbols.js";
|
|
9
9
|
import { isResourceSchema } from "./types/schema/fields.js";
|
|
10
|
-
import { t as DefaultCachePolicy } from "./store-
|
|
10
|
+
import { t as DefaultCachePolicy } from "./store-Bz9R5hGB.js";
|
|
11
11
|
import { setIsMaybeMirage } from "./types/runtime.js";
|
|
12
12
|
import * as _importSync20 from "@ember/object";
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// src/reactive/-private/document.ts
|
|
15
15
|
function urlFromLink(link) {
|
|
16
16
|
if (typeof link === "string") return link;
|
|
17
17
|
return link.href;
|
|
@@ -21,10 +21,15 @@ function urlFromLink(link) {
|
|
|
21
21
|
* returned by `Cache.put` or `Cache.peek`, converting ResourceKeys into
|
|
22
22
|
* ReactiveResource instances.
|
|
23
23
|
*
|
|
24
|
+
* The [Using The Response](/guides/the-manual/requests/using-the-response) guide
|
|
25
|
+
* shows when a request's content is a ReactiveDocument.
|
|
26
|
+
*
|
|
24
27
|
* It is not directly instantiated by the user, and its properties should not
|
|
25
28
|
* be directly modified. Whether individual properties are mutable or not is
|
|
26
29
|
* determined by the record instance itself.
|
|
27
30
|
*
|
|
31
|
+
* @summary The reactive wrapper around a request's response document that exposes its data or errors
|
|
32
|
+
* as live records, plus meta, links, and pagination helpers.
|
|
28
33
|
* @public
|
|
29
34
|
*/
|
|
30
35
|
const ReactiveDocumentProto = {
|
|
@@ -124,8 +129,7 @@ function createReactiveDocument(store, cacheKey, localCache) {
|
|
|
124
129
|
return doc;
|
|
125
130
|
}
|
|
126
131
|
|
|
127
|
-
|
|
128
|
-
//#region src/store/-private/managers/cache-capabilities-manager.ts
|
|
132
|
+
// src/store/-private/managers/cache-capabilities-manager.ts
|
|
129
133
|
var CacheCapabilitiesManager = class {
|
|
130
134
|
/** @internal */
|
|
131
135
|
/** @internal */
|
|
@@ -214,8 +218,7 @@ CacheCapabilitiesManager.prototype.getSchemaDefinitionService = function() {
|
|
|
214
218
|
*/
|
|
215
219
|
function assertPrivateCapabilities(manager) {}
|
|
216
220
|
|
|
217
|
-
|
|
218
|
-
//#region src/store/-private/caches/instance-cache.ts
|
|
221
|
+
// src/store/-private/caches/instance-cache.ts
|
|
219
222
|
const RecordCache = getOrSetGlobal("RecordCache", /* @__PURE__ */ new Map());
|
|
220
223
|
function peekResourceKey(record) {
|
|
221
224
|
return RecordCache.get(record);
|
|
@@ -234,6 +237,7 @@ const identifier = recordIdentifierFor(record);
|
|
|
234
237
|
const { id, type, lid } = identifier;
|
|
235
238
|
```
|
|
236
239
|
|
|
240
|
+
@summary Returns the stable `ResourceKey` (type, id, and lid) the store assigned to a record instance.
|
|
237
241
|
@public
|
|
238
242
|
@param record a record instance previously obstained from the store.
|
|
239
243
|
*/
|
|
@@ -450,8 +454,7 @@ function unloadRecord(instances, identifier) {
|
|
|
450
454
|
instances.store._requestCache._clearEntries(identifier);
|
|
451
455
|
}
|
|
452
456
|
|
|
453
|
-
|
|
454
|
-
//#region src/store/-private/caches/resource-utils.ts
|
|
457
|
+
// src/store/-private/caches/resource-utils.ts
|
|
455
458
|
function isResource(resource) {
|
|
456
459
|
return Boolean(resource && typeof resource === "object");
|
|
457
460
|
}
|
|
@@ -468,8 +471,7 @@ function hasType(resource) {
|
|
|
468
471
|
return hasProp(resource, "type");
|
|
469
472
|
}
|
|
470
473
|
|
|
471
|
-
|
|
472
|
-
//#region src/store/-private/utils/coerce-id.ts
|
|
474
|
+
// src/store/-private/utils/coerce-id.ts
|
|
473
475
|
/**
|
|
474
476
|
* Normalizes a resource `id` entering the store to a string (or `null`).
|
|
475
477
|
*
|
|
@@ -504,8 +506,7 @@ function ensureStringId(id) {
|
|
|
504
506
|
return normalized;
|
|
505
507
|
}
|
|
506
508
|
|
|
507
|
-
|
|
508
|
-
//#region src/store/-private/utils/normalize-model-name.ts
|
|
509
|
+
// src/store/-private/utils/normalize-model-name.ts
|
|
509
510
|
/**
|
|
510
511
|
* Normalizes a resource `type` to its dasherized form, e.g. `myClass` to
|
|
511
512
|
* `my-class`. Re-exported elsewhere as `_deprecatingNormalize`.
|
|
@@ -520,8 +521,7 @@ function normalizeModelName(type) {
|
|
|
520
521
|
return dasherize(type);
|
|
521
522
|
}
|
|
522
523
|
|
|
523
|
-
|
|
524
|
-
//#region src/store/-private/managers/cache-key-manager.ts
|
|
524
|
+
// src/store/-private/managers/cache-key-manager.ts
|
|
525
525
|
/**
|
|
526
526
|
* Type-guard that returns `true` if the given value is a stable {@link ResourceKey}
|
|
527
527
|
* (as opposed to a {@link RequestKey} or arbitrary, not-yet-stabilized resource data).
|
|
@@ -536,6 +536,43 @@ function isResourceKey(identifier) {
|
|
|
536
536
|
function isRequestKey(identifier) {
|
|
537
537
|
return identifier.type === "@document" && identifier[CACHE_OWNER] !== void 0;
|
|
538
538
|
}
|
|
539
|
+
/**
|
|
540
|
+
* The identity of a field's value, as returned by {@link fieldValueIdentity}.
|
|
541
|
+
* Today only schema-object values (a `schema-object` field, or one element of
|
|
542
|
+
* a `schema-array`) have one: the concrete schema-object type the value
|
|
543
|
+
* resolves to, and the identity hash that type's `ObjectSchema` declares for
|
|
544
|
+
* it, or `null` when the schema declares `identity: null`.
|
|
545
|
+
*/
|
|
546
|
+
/**
|
|
547
|
+
* The identity of `value` as a value of `field`, when the field kind has one.
|
|
548
|
+
*
|
|
549
|
+
* A `schema-object` value, or one element of a `schema-array`, resolves to its
|
|
550
|
+
* concrete schema-object type and the identity hash that type's `ObjectSchema`
|
|
551
|
+
* declares (`null` when the schema declares `identity: null`). A
|
|
552
|
+
* non-polymorphic field names the type directly; a polymorphic field reads it
|
|
553
|
+
* off the value at `options.type` (default `'type'`), or computes it with the
|
|
554
|
+
* hash function named by `field.type` when `options.type` is `'@hash'`.
|
|
555
|
+
*
|
|
556
|
+
* Every other field kind, and any non-object value, has no identity and
|
|
557
|
+
* returns `null`.
|
|
558
|
+
*/
|
|
559
|
+
function fieldValueIdentity(schema, field, value) {
|
|
560
|
+
if (field.kind !== "schema-object" && field.kind !== "schema-array") return null;
|
|
561
|
+
if (!value || typeof value !== "object") return null;
|
|
562
|
+
const rawValue = value;
|
|
563
|
+
let type;
|
|
564
|
+
if (field.options?.polymorphic) {
|
|
565
|
+
const typePath = field.options.type ?? "type";
|
|
566
|
+
if (typePath === "@hash") type = schema.hashFn({ type: field.type })(rawValue, null, null);
|
|
567
|
+
else type = rawValue[typePath];
|
|
568
|
+
} else type = field.type;
|
|
569
|
+
const hashField = schema.resource({ type }).identity;
|
|
570
|
+
const hash = hashField && hashField.kind === "@hash" ? schema.hashFn(hashField)(rawValue, hashField.options ?? null, hashField.name) : null;
|
|
571
|
+
return {
|
|
572
|
+
type,
|
|
573
|
+
hash
|
|
574
|
+
};
|
|
575
|
+
}
|
|
539
576
|
const _crypto = typeof FastBoot !== "undefined" ? FastBoot.require("crypto") : globalThis.crypto;
|
|
540
577
|
function uuidv4() {
|
|
541
578
|
return _crypto.randomUUID();
|
|
@@ -609,6 +646,8 @@ implement this hook.
|
|
|
609
646
|
|
|
610
647
|
⚠️ Caution: Requests that do not have a `method` assigned are assumed to be `GET`
|
|
611
648
|
|
|
649
|
+
@summary Overrides how the store generates `lid` cache keys for resources and documents; must be set
|
|
650
|
+
before the store is created.
|
|
612
651
|
@public
|
|
613
652
|
*/
|
|
614
653
|
function setIdentifierGenerationMethod(method) {
|
|
@@ -643,6 +682,8 @@ prior to this `UpdateMethod` being called; however, calls to the parent method
|
|
|
643
682
|
`updateRecordIdentifier` that attempt to change the `id` or calling update
|
|
644
683
|
without providing an `id` when one is missing will throw an error.
|
|
645
684
|
|
|
685
|
+
@summary Registers a callback run when an existing resource key receives new data, for updating your
|
|
686
|
+
own secondary lookup tables.
|
|
646
687
|
@public
|
|
647
688
|
*/
|
|
648
689
|
function setIdentifierUpdateMethod(method) {
|
|
@@ -660,6 +701,8 @@ import { setIdentifierForgetMethod } from '@warp-drive-mirror/core';
|
|
|
660
701
|
Takes method which can expect to receive an existing `Identifier` that should be eliminated
|
|
661
702
|
from any secondary lookup tables or caches that the user has populated for it.
|
|
662
703
|
|
|
704
|
+
@summary Registers a callback run when the store releases a resource key, for cleaning up your own
|
|
705
|
+
lookup tables.
|
|
663
706
|
@public
|
|
664
707
|
*/
|
|
665
708
|
function setIdentifierForgetMethod(method) {
|
|
@@ -679,6 +722,8 @@ Takes a method which can expect to be called when the parent application is dest
|
|
|
679
722
|
If you have properly used a WeakMap to encapsulate the state of your customization
|
|
680
723
|
to the application instance, you may not need to implement the `resetMethod`.
|
|
681
724
|
|
|
725
|
+
@summary Registers a callback run when the store's key cache is torn down, for resetting any custom
|
|
726
|
+
key-generation state.
|
|
682
727
|
@public
|
|
683
728
|
*/
|
|
684
729
|
function setIdentifierResetMethod(method) {
|
|
@@ -697,6 +742,8 @@ This configuration MUST occur prior to the store instance being created.
|
|
|
697
742
|
import { setKeyInfoForResource } from '@warp-drive-mirror/core';
|
|
698
743
|
```
|
|
699
744
|
|
|
745
|
+
@summary Overrides how the store derives the `type` and `id` of a new `ResourceKey` from resource data;
|
|
746
|
+
must be set before the store is created.
|
|
700
747
|
@public
|
|
701
748
|
*/
|
|
702
749
|
function setKeyInfoForResource(method) {
|
|
@@ -1041,13 +1088,18 @@ function addResourceToCache(cache, identifier) {
|
|
|
1041
1088
|
if (identifier.id) typeSet.id.set(identifier.id, identifier);
|
|
1042
1089
|
}
|
|
1043
1090
|
|
|
1044
|
-
|
|
1045
|
-
//#region src/store/-private/managers/notification-manager.ts
|
|
1091
|
+
// src/store/-private/managers/notification-manager.ts
|
|
1046
1092
|
/**
|
|
1047
1093
|
* The kinds of change notifications the {@link NotificationManager} can emit for a resource.
|
|
1094
|
+
*
|
|
1095
|
+
* @summary The lifecycle notification kinds sent to resource subscribers: `added`, `removed`, `updated`,
|
|
1096
|
+
* or `state`.
|
|
1048
1097
|
*/
|
|
1049
1098
|
/**
|
|
1050
1099
|
* The kinds of change notifications the {@link NotificationManager} can emit for a request document.
|
|
1100
|
+
*
|
|
1101
|
+
* @summary The notification kinds sent to request document subscribers, such as `updated` or
|
|
1102
|
+
* `invalidated`.
|
|
1051
1103
|
*/
|
|
1052
1104
|
function isCacheOperationValue(value) {
|
|
1053
1105
|
return value === "added" || value === "state" || value === "updated" || value === "removed" || value === "invalidated";
|
|
@@ -1055,6 +1107,9 @@ function isCacheOperationValue(value) {
|
|
|
1055
1107
|
/**
|
|
1056
1108
|
* The full set of notification kinds the {@link NotificationManager} can emit for a resource,
|
|
1057
1109
|
* including both {@link CacheOperation}s and finer-grained field-level change notifications.
|
|
1110
|
+
*
|
|
1111
|
+
* @summary Every notification kind a resource subscriber can receive, from lifecycle operations to
|
|
1112
|
+
* `attributes`, `relationships`, `errors`, `meta`, and `identity` changes.
|
|
1058
1113
|
*/
|
|
1059
1114
|
/**
|
|
1060
1115
|
* The shape accepted by {@link NotificationManager.notify} and
|
|
@@ -1062,6 +1117,8 @@ function isCacheOperationValue(value) {
|
|
|
1062
1117
|
* the `'attributes'` or `'relationships'` namespaces in a single call
|
|
1063
1118
|
* instead of once per key.
|
|
1064
1119
|
*
|
|
1120
|
+
* @summary A set of field names passed to `notify` or `notifyChange` to report many `attributes` or
|
|
1121
|
+
* `relationships` changes in one call.
|
|
1065
1122
|
* @since 5.9.0
|
|
1066
1123
|
* @public
|
|
1067
1124
|
*/
|
|
@@ -1096,6 +1153,8 @@ function isCacheOperationValue(value) {
|
|
|
1096
1153
|
* `DocumentCacheOperation` values) are never filtered by channel since they
|
|
1097
1154
|
* have no local/remote duality.
|
|
1098
1155
|
*
|
|
1156
|
+
* @summary Scopes an `attributes` or `relationships` notification to a resource's local (editable) or
|
|
1157
|
+
* remote (persisted) view so only matching subscribers hear it.
|
|
1099
1158
|
* @public
|
|
1100
1159
|
*/
|
|
1101
1160
|
/**
|
|
@@ -1206,6 +1265,8 @@ function _unsubscribe(token, cache) {
|
|
|
1206
1265
|
* This Feature is what allows WarpDrive to create subscriptions that
|
|
1207
1266
|
* work with any framework or change-notification system.
|
|
1208
1267
|
*
|
|
1268
|
+
* @summary The store service that lets code subscribe to and batch-deliver change notifications for
|
|
1269
|
+
* cached resources and request documents.
|
|
1209
1270
|
* @hideconstructor
|
|
1210
1271
|
* @public
|
|
1211
1272
|
*/
|
|
@@ -1392,8 +1453,7 @@ function hasSubscribers(cache, cacheKey, value) {
|
|
|
1392
1453
|
return Boolean(callbackMap?.length);
|
|
1393
1454
|
}
|
|
1394
1455
|
|
|
1395
|
-
|
|
1396
|
-
//#region src/store/-private/record-arrays/-utils.ts
|
|
1456
|
+
// src/store/-private/record-arrays/-utils.ts
|
|
1397
1457
|
/**
|
|
1398
1458
|
* LegacyArrays have the capability of updating via `array.update()`
|
|
1399
1459
|
* and saving each contained record individually via `array.save()`
|
|
@@ -1469,8 +1529,7 @@ function safeForEach$1(instance, arr, store, callback, target) {
|
|
|
1469
1529
|
return instance;
|
|
1470
1530
|
}
|
|
1471
1531
|
|
|
1472
|
-
|
|
1473
|
-
//#region src/reactive/-private/fields/extension.ts
|
|
1532
|
+
// src/reactive/-private/fields/extension.ts
|
|
1474
1533
|
function expectNever(value) {}
|
|
1475
1534
|
function isExtensionProp(extensions, prop) {
|
|
1476
1535
|
return Boolean(extensions && typeof prop !== "number" && extensions.has(prop));
|
|
@@ -1537,8 +1596,7 @@ function performArrayExtensionGet(receiver, extensions, signals, prop, _SIGNAL,
|
|
|
1537
1596
|
}
|
|
1538
1597
|
}
|
|
1539
1598
|
|
|
1540
|
-
|
|
1541
|
-
//#region src/store/-private/record-arrays/native-proxy-type-fix.ts
|
|
1599
|
+
// src/store/-private/record-arrays/native-proxy-type-fix.ts
|
|
1542
1600
|
/**
|
|
1543
1601
|
* The global `Proxy` constructor, retyped with the corrected
|
|
1544
1602
|
* {@link ProxyConstructor} signature above so that `target` and `receiver`
|
|
@@ -1548,8 +1606,7 @@ function performArrayExtensionGet(receiver, extensions, signals, prop, _SIGNAL,
|
|
|
1548
1606
|
*/
|
|
1549
1607
|
const NativeProxy = Proxy;
|
|
1550
1608
|
|
|
1551
|
-
|
|
1552
|
-
//#region src/store/-private/record-arrays/resource-array.ts
|
|
1609
|
+
// src/store/-private/record-arrays/resource-array.ts
|
|
1553
1610
|
const IS_COLLECTION = getOrSetGlobal("IS_COLLECTION", Symbol.for("Collection"));
|
|
1554
1611
|
function isContextProp(prop) {
|
|
1555
1612
|
return prop === "destroy" || prop === "isDestroying" || prop === "isDestroyed";
|
|
@@ -1576,10 +1633,15 @@ const MUTABLE_PROPS = [
|
|
|
1576
1633
|
* as the base for relationship and legacy record-array types such as
|
|
1577
1634
|
* {@link LegacyLiveArray}, {@link LegacyQueryArray} and {@link LegacyManyArray}.
|
|
1578
1635
|
*
|
|
1636
|
+
* The [Key Terminology](/guides/the-manual/caching/key-terms#resources) guide explains
|
|
1637
|
+
* how it relates to resources.
|
|
1638
|
+
*
|
|
1579
1639
|
* Behaves like a native Array: `Array.isArray(arr)` and `arr instanceof Array`
|
|
1580
1640
|
* both report `true`. The array stays in sync with the cache, updating
|
|
1581
1641
|
* reactively as the underlying {@link ResourceKey}s change.
|
|
1582
1642
|
*
|
|
1643
|
+
* @summary Native-Array-compatible reactive list of records backed by cache keys, returned for collection responses
|
|
1644
|
+
* and underlying relationship and legacy record arrays.
|
|
1583
1645
|
* @public
|
|
1584
1646
|
*/
|
|
1585
1647
|
/**
|
|
@@ -1790,8 +1852,7 @@ function createRequestCollection(config) {
|
|
|
1790
1852
|
});
|
|
1791
1853
|
}
|
|
1792
1854
|
|
|
1793
|
-
|
|
1794
|
-
//#region src/store/-private/record-arrays/legacy-live-array.ts
|
|
1855
|
+
// src/store/-private/record-arrays/legacy-live-array.ts
|
|
1795
1856
|
/**
|
|
1796
1857
|
* LiveArrays contain all the known records for a given `ResourceType`.
|
|
1797
1858
|
*
|
|
@@ -1852,6 +1913,8 @@ function createRequestCollection(config) {
|
|
|
1852
1913
|
* and "bmw" will have populated LiveArrays, but the LiveArray for "car"
|
|
1853
1914
|
* would be empty.
|
|
1854
1915
|
*
|
|
1916
|
+
* @summary Legacy reactive array of every record of one type in the store, returned by `store.peekAll` and
|
|
1917
|
+
* `store.findAll`.
|
|
1855
1918
|
* @legacy we recommend againt using LiveArrays. Use {@link Store.request} instead
|
|
1856
1919
|
*/
|
|
1857
1920
|
/**
|
|
@@ -1891,8 +1954,7 @@ function _updateLiveArray() {
|
|
|
1891
1954
|
return this[Context].store.findAll(this.modelName, { reload: true });
|
|
1892
1955
|
}
|
|
1893
1956
|
|
|
1894
|
-
|
|
1895
|
-
//#region src/store/-private/record-arrays/legacy-query.ts
|
|
1957
|
+
// src/store/-private/record-arrays/legacy-query.ts
|
|
1896
1958
|
/**
|
|
1897
1959
|
* QueryArrays contain the primary records returned when querying
|
|
1898
1960
|
* for records by `ResourceType`.
|
|
@@ -1963,6 +2025,8 @@ function _updateLiveArray() {
|
|
|
1963
2025
|
* from the cache, but it does remove the array as well as the overhead it requires
|
|
1964
2026
|
* from the store for book-keeping.
|
|
1965
2027
|
*
|
|
2028
|
+
* @summary Legacy immutable reactive array of the primary records returned by `store.query`, refreshable with
|
|
2029
|
+
* `update()` and released with `destroy()`.
|
|
1966
2030
|
* @legacy we recommend againt using QueryArrays. Use {@link Store.request} instead
|
|
1967
2031
|
*/
|
|
1968
2032
|
/**
|
|
@@ -2019,8 +2083,7 @@ function destroyCollection(clear) {
|
|
|
2019
2083
|
manager._pending.delete(this);
|
|
2020
2084
|
}
|
|
2021
2085
|
|
|
2022
|
-
|
|
2023
|
-
//#region src/store/-private/managers/record-array-manager.ts
|
|
2086
|
+
// src/store/-private/managers/record-array-manager.ts
|
|
2024
2087
|
const FAKE_ARR = getOrSetGlobal("FAKE_ARR", {});
|
|
2025
2088
|
const SLICE_BATCH_SIZE = 4761;
|
|
2026
2089
|
/**
|
|
@@ -2361,6 +2424,7 @@ var RecordArrayManager = class {
|
|
|
2361
2424
|
this._managed.clear();
|
|
2362
2425
|
this._identifiers.clear();
|
|
2363
2426
|
this._pending.clear();
|
|
2427
|
+
this._staged.clear();
|
|
2364
2428
|
for (const set of this._set.values()) set.clear();
|
|
2365
2429
|
this._visibilitySet.clear();
|
|
2366
2430
|
}
|
|
@@ -2433,8 +2497,7 @@ function isLegacyLiveArray(array) {
|
|
|
2433
2497
|
return context.features !== null && context.features.DEPRECATED_CLASS_NAME === "LiveArray";
|
|
2434
2498
|
}
|
|
2435
2499
|
|
|
2436
|
-
|
|
2437
|
-
//#region src/store/-private/network/request-cache.ts
|
|
2500
|
+
// src/store/-private/network/request-cache.ts
|
|
2438
2501
|
const Touching = getOrSetGlobal("Touching", Symbol("touching"));
|
|
2439
2502
|
const RequestPromise = getOrSetGlobal("RequestPromise", Symbol("promise"));
|
|
2440
2503
|
const EMPTY_ARR = [];
|
|
@@ -2642,8 +2705,7 @@ var RequestStateService = class {
|
|
|
2642
2705
|
*
|
|
2643
2706
|
* @private
|
|
2644
2707
|
*/
|
|
2645
|
-
|
|
2646
|
-
//#region ../../node_modules/.pnpm/@embroider+macros@1.20.7/node_modules/@embroider/macros/src/addon/es-compat2.js
|
|
2708
|
+
// ../../node_modules/.pnpm/@embroider+macros@1.21.4/node_modules/@embroider/macros/src/addon/es-compat2.js
|
|
2647
2709
|
function esCompat(m) {
|
|
2648
2710
|
return m?.__esModule ? m : {
|
|
2649
2711
|
default: m,
|
|
@@ -2651,8 +2713,7 @@ function esCompat(m) {
|
|
|
2651
2713
|
};
|
|
2652
2714
|
}
|
|
2653
2715
|
|
|
2654
|
-
|
|
2655
|
-
//#region src/store/-private/store-service.ts
|
|
2716
|
+
// src/store/-private/store-service.ts
|
|
2656
2717
|
const _BaseClass = esCompat(_importSync20);
|
|
2657
2718
|
const BaseClass = _BaseClass.default ? _BaseClass.default : _BaseClass;
|
|
2658
2719
|
/**
|
|
@@ -2663,6 +2724,10 @@ const BaseClass = _BaseClass.default ? _BaseClass.default : _BaseClass;
|
|
|
2663
2724
|
* The `Store` is the central piece of the ***Warp*Drive** experience. It connects
|
|
2664
2725
|
* requests for data with schemas, caching and reactivity.
|
|
2665
2726
|
*
|
|
2727
|
+
* The [Setup](/guides/configuration/#configure-the-store) guide shows how to configure
|
|
2728
|
+
* one, and [Making Requests](/guides/the-manual/requests/) shows how to request data
|
|
2729
|
+
* through it.
|
|
2730
|
+
*
|
|
2666
2731
|
* While it's easy to use ***just*** ***Warp*Drive**'s request management, most projects will find they
|
|
2667
2732
|
* require far more than basic fetch management. For this reason it's often best to start with a `Store`
|
|
2668
2733
|
* even when you aren't sure yet.
|
|
@@ -2670,6 +2735,7 @@ const BaseClass = _BaseClass.default ? _BaseClass.default : _BaseClass;
|
|
|
2670
2735
|
* Most projects will only have a single `Store`, though using multiple distinct stores
|
|
2671
2736
|
* is possible.
|
|
2672
2737
|
*
|
|
2738
|
+
* @summary Central coordinator that connects requests for data with schemas, the cache and reactivity.
|
|
2673
2739
|
* @public
|
|
2674
2740
|
* @hideconstructor
|
|
2675
2741
|
*/
|
|
@@ -2854,12 +2920,25 @@ var Store = class extends BaseClass {
|
|
|
2854
2920
|
/** @internal */
|
|
2855
2921
|
_getAllPending() {}
|
|
2856
2922
|
/**
|
|
2857
|
-
* ::: tip 💡 For a more complete overview see the [Request Guide](/guides/
|
|
2923
|
+
* ::: tip 💡 For a more complete overview see the [Request Guide](/guides/the-manual/requests/)
|
|
2858
2924
|
* :::
|
|
2859
2925
|
*
|
|
2860
2926
|
* Issue a request via the configured {@link RequestManager},
|
|
2861
2927
|
* inserting the response into the {@link Store.cache | cache} and handing
|
|
2862
|
-
* back a {@link Future} which resolves to a {@link ReactiveDocument | ReactiveDocument}
|
|
2928
|
+
* back a {@link Future} which resolves to a {@link ReactiveDocument | ReactiveDocument}.
|
|
2929
|
+
* Use `store.request` for anything the Store's cache should own, which is nearly all app
|
|
2930
|
+
* code; reach for {@link RequestManager.request | requestManager.request} directly only when
|
|
2931
|
+
* there is no `Store` involved, or you specifically want the unprocessed
|
|
2932
|
+
* {@link StructuredDocument}.
|
|
2933
|
+
*
|
|
2934
|
+
* #### Building Requests
|
|
2935
|
+
*
|
|
2936
|
+
* `requestConfig` can be written by hand, but for anything reused more than once prefer a
|
|
2937
|
+
* request builder — a plain function that returns the right shape for `store.request`. This
|
|
2938
|
+
* repo ships builders for common operations (`findRecord`, `query`, `createRecord`, and more)
|
|
2939
|
+
* for {json:api}, REST, and ActiveRecord-style APIs in `@warp-drive-mirror/utilities`; each builder's
|
|
2940
|
+
* return value also carries its own response type, so `RT` below is inferred automatically
|
|
2941
|
+
* instead of being written by hand. See [Builders](/guides/the-manual/requests/builders.md).
|
|
2863
2942
|
*
|
|
2864
2943
|
* #### Request Cache Keys
|
|
2865
2944
|
*
|
|
@@ -2904,6 +2983,29 @@ var Store = class extends BaseClass {
|
|
|
2904
2983
|
* is that `store.request` will convert the response into a {@link ReactiveDocument}
|
|
2905
2984
|
* containing {@link Store.instantiateRecord | ReactiveResources}.
|
|
2906
2985
|
*
|
|
2986
|
+
* A {@link ReactiveDocument} is either a {@link ReactiveDataDocument} (`content.data` holds
|
|
2987
|
+
* the resource(s)) or a {@link ReactiveErrorDocument} (`content.errors` holds the API's error
|
|
2988
|
+
* objects), depending on whether the `Future` resolves or rejects; both carry the response's
|
|
2989
|
+
* `content.meta`. Read either state reactively with {@link getRequestState} or the
|
|
2990
|
+
* `<Request />` component instead of always `await`-ing the `Future` directly — see
|
|
2991
|
+
* [Using the Response](/guides/the-manual/requests/using-the-response.md).
|
|
2992
|
+
*
|
|
2993
|
+
* #### Typing The Response
|
|
2994
|
+
*
|
|
2995
|
+
* `request<RT>` accepts an explicit type argument, but the more common path is to let it be
|
|
2996
|
+
* inferred: build the request with {@link withResponseType} (or {@link withReactiveResponse}
|
|
2997
|
+
* for the common reactive-document case), or with a builder from `@warp-drive-mirror/utilities` as
|
|
2998
|
+
* described above, and `RT` is inferred from the request object itself. See
|
|
2999
|
+
* [Typing Requests](/guides/the-manual/requests/typing-requests.md) for the full mechanism.
|
|
3000
|
+
*
|
|
3001
|
+
* @example
|
|
3002
|
+
* ```ts
|
|
3003
|
+
* import { findRecord } from '@warp-drive-mirror/utilities/json-api';
|
|
3004
|
+
*
|
|
3005
|
+
* const { content } = await store.request(findRecord('user', '1'));
|
|
3006
|
+
* content.data; // ReactiveResource, typed from the builder's response type
|
|
3007
|
+
* ```
|
|
3008
|
+
*
|
|
2907
3009
|
* @public
|
|
2908
3010
|
*/
|
|
2909
3011
|
request(requestConfig) {
|
|
@@ -3364,8 +3466,7 @@ function extractIdentifierFromRecord$1(recordOrPromiseRecord) {
|
|
|
3364
3466
|
return recordIdentifierFor(recordOrPromiseRecord);
|
|
3365
3467
|
}
|
|
3366
3468
|
|
|
3367
|
-
|
|
3368
|
-
//#region src/store/deprecated/-private.ts
|
|
3469
|
+
// src/store/deprecated/-private.ts
|
|
3369
3470
|
function preloadData(store, identifier, preload) {
|
|
3370
3471
|
const jsonPayload = {};
|
|
3371
3472
|
const fields = store.schema.fields(identifier);
|
|
@@ -3404,6 +3505,8 @@ function _convertPreloadRelationshipToJSON(value, type) {
|
|
|
3404
3505
|
* for @warp-drive-mirror/legacy/model or when wrapping schema for legacy
|
|
3405
3506
|
* Adapters/Serializers.
|
|
3406
3507
|
*
|
|
3508
|
+
* @summary Legacy shape of a Model class's static schema API (fields, attributes, relationships, iterators) used
|
|
3509
|
+
* by the legacy schema service and Adapters/Serializers.
|
|
3407
3510
|
*/
|
|
3408
3511
|
function _resourceIsFullDeleted(identifier, cache) {
|
|
3409
3512
|
return cache.isDeletionCommitted(identifier) || cache.isNew(identifier) && cache.isDeleted(identifier);
|
|
@@ -3628,8 +3731,7 @@ var ShimModelClass = class {
|
|
|
3628
3731
|
}
|
|
3629
3732
|
};
|
|
3630
3733
|
|
|
3631
|
-
|
|
3632
|
-
//#region src/store/deprecated/store.ts
|
|
3734
|
+
// src/store/deprecated/store.ts
|
|
3633
3735
|
Store.prototype.findRecord = function(resource, id, options) {
|
|
3634
3736
|
if (isMaybeIdentifier(resource)) options = id;
|
|
3635
3737
|
else {
|
|
@@ -3734,8 +3836,7 @@ function upgradeInstanceCaches(cache) {
|
|
|
3734
3836
|
return withReferences;
|
|
3735
3837
|
}
|
|
3736
3838
|
|
|
3737
|
-
|
|
3738
|
-
//#region src/store/-private/cache-handler/utils.ts
|
|
3839
|
+
// src/store/-private/cache-handler/utils.ts
|
|
3739
3840
|
const MUTATION_OPS$1 = /* @__PURE__ */ new Set([
|
|
3740
3841
|
"createRecord",
|
|
3741
3842
|
"updateRecord",
|
|
@@ -3775,15 +3876,23 @@ function getPriority(identifier, deduped, priority) {
|
|
|
3775
3876
|
return priority;
|
|
3776
3877
|
}
|
|
3777
3878
|
|
|
3778
|
-
|
|
3779
|
-
//#region src/store/-private/cache-handler/handler.ts
|
|
3879
|
+
// src/store/-private/cache-handler/handler.ts
|
|
3780
3880
|
/**
|
|
3781
3881
|
* The request shape accepted by {@link Store.request}, either a fully-formed
|
|
3782
3882
|
* {@link ImmutableRequestInfo} or the looser {@link LooseStoreRequestInfo}.
|
|
3883
|
+
*
|
|
3884
|
+
* Only the looser form accepts `controller`, so a request carrying one, including a builder's
|
|
3885
|
+
* output spread together with a `controller`, resolves to {@link LooseStoreRequestInfo}.
|
|
3886
|
+
*
|
|
3887
|
+
* @summary The request object `store.request` accepts, either a full immutable request info or a looser
|
|
3888
|
+
* form with plain `records` and `headers`.
|
|
3783
3889
|
*/
|
|
3784
3890
|
/**
|
|
3785
3891
|
* A CacheHandler that adds support for using an WarpDrive Cache with a RequestManager.
|
|
3786
3892
|
*
|
|
3893
|
+
* The [Caching](/guides/the-manual/caching/) guide explains how it decides whether a
|
|
3894
|
+
* request can use the cache.
|
|
3895
|
+
*
|
|
3787
3896
|
* This handler will only run when a request has supplied a `store` instance. Requests
|
|
3788
3897
|
* issued by the store via `store.request()` will automatically have the `store` instance
|
|
3789
3898
|
* attached to the request.
|
|
@@ -3819,7 +3928,10 @@ function getPriority(identifier, deduped, priority) {
|
|
|
3819
3928
|
* method: 'GET',
|
|
3820
3929
|
* [EnableHydration]: true
|
|
3821
3930
|
* });
|
|
3931
|
+
* ```
|
|
3822
3932
|
*
|
|
3933
|
+
* @summary The RequestManager cache handler that serves, dedupes, and caches store requests and returns
|
|
3934
|
+
* reactive documents when hydration is enabled.
|
|
3823
3935
|
*/
|
|
3824
3936
|
const CacheHandler = { request(context, next) {
|
|
3825
3937
|
if (!context.request.store || context.request.cacheOptions?.[SkipCache]) return next(context.request);
|
|
@@ -3974,14 +4086,12 @@ function fetchContentAndHydrate(next, context, identifier, priority) {
|
|
|
3974
4086
|
}] });
|
|
3975
4087
|
}
|
|
3976
4088
|
|
|
3977
|
-
|
|
3978
|
-
//#region src/store/-private/utils/is-non-empty-string.ts
|
|
4089
|
+
// src/store/-private/utils/is-non-empty-string.ts
|
|
3979
4090
|
function isNonEmptyString(str) {
|
|
3980
4091
|
return Boolean(str && typeof str === "string");
|
|
3981
4092
|
}
|
|
3982
4093
|
|
|
3983
|
-
|
|
3984
|
-
//#region src/store/-private/utils/construct-resource.ts
|
|
4094
|
+
// src/store/-private/utils/construct-resource.ts
|
|
3985
4095
|
/**
|
|
3986
4096
|
* Given an existing resource identifier object (or a {@link ResourceKey}),
|
|
3987
4097
|
* returns it unchanged aside from coercing its `id`, if present, to a string.
|
|
@@ -4044,8 +4154,7 @@ function constructResource(type, id, lid) {
|
|
|
4044
4154
|
}
|
|
4045
4155
|
}
|
|
4046
4156
|
|
|
4047
|
-
|
|
4048
|
-
//#region src/store/-private/record-arrays/legacy-many-array.ts
|
|
4157
|
+
// src/store/-private/record-arrays/legacy-many-array.ts
|
|
4049
4158
|
/**
|
|
4050
4159
|
A `ManyArray` is a `MutableArray` that represents the contents of a has-many
|
|
4051
4160
|
relationship.
|
|
@@ -4086,6 +4195,7 @@ the has-many.
|
|
|
4086
4195
|
We call the record to which a relationship belongs-to the
|
|
4087
4196
|
relationship's _owner_.
|
|
4088
4197
|
|
|
4198
|
+
@summary Legacy mutable reactive array holding the related records of a legacy or linksMode has-many relationship.
|
|
4089
4199
|
@public
|
|
4090
4200
|
*/
|
|
4091
4201
|
/**
|
|
@@ -4117,7 +4227,7 @@ function createLegacyManyArray(options) {
|
|
|
4117
4227
|
isAsync: options.isAsync,
|
|
4118
4228
|
isPolymorphic: options.isPolymorphic,
|
|
4119
4229
|
identifier: options.identifier,
|
|
4120
|
-
key: options.field.name,
|
|
4230
|
+
key: options.field.sourceKey ?? options.field.name,
|
|
4121
4231
|
reload,
|
|
4122
4232
|
createRecord,
|
|
4123
4233
|
notify
|
|
@@ -4335,8 +4445,7 @@ function mutate(collection, mutation, _SIGNAL) {
|
|
|
4335
4445
|
notifyInternalSignal(_SIGNAL);
|
|
4336
4446
|
}
|
|
4337
4447
|
|
|
4338
|
-
|
|
4339
|
-
//#region src/store/-private/debug/utils.ts
|
|
4448
|
+
// src/store/-private/debug/utils.ts
|
|
4340
4449
|
const TEXT_COLORS = {
|
|
4341
4450
|
TEXT: "inherit",
|
|
4342
4451
|
notify: [
|
|
@@ -4565,15 +4674,13 @@ function _log(scope, prefix, subScop1, subScop2, subScop3, subScop4) {
|
|
|
4565
4674
|
return [];
|
|
4566
4675
|
}
|
|
4567
4676
|
|
|
4568
|
-
|
|
4569
|
-
//#region src/reactive/-private/kind/alias-field.ts
|
|
4677
|
+
// src/reactive/-private/kind/alias-field.ts
|
|
4570
4678
|
function getAliasField(context) {}
|
|
4571
4679
|
function setAliasField(context) {
|
|
4572
4680
|
return false;
|
|
4573
4681
|
}
|
|
4574
4682
|
|
|
4575
|
-
|
|
4576
|
-
//#region src/reactive/-private/fields/managed-array.ts
|
|
4683
|
+
// src/reactive/-private/fields/managed-array.ts
|
|
4577
4684
|
const ARRAY_GETTER_METHODS = /* @__PURE__ */ new Set([
|
|
4578
4685
|
Symbol.iterator,
|
|
4579
4686
|
"concat",
|
|
@@ -4670,17 +4777,7 @@ var ManagedArray = class {
|
|
|
4670
4777
|
if (field.type) return schema.transformation(field).hydrate(rawValue, field.options ?? null, self.owner);
|
|
4671
4778
|
return rawValue;
|
|
4672
4779
|
}
|
|
4673
|
-
|
|
4674
|
-
* When the array is polymorphic, we need to determine the real type
|
|
4675
|
-
* in order to apply the correct identity as schema-object identity
|
|
4676
|
-
* is only required to be unique by type
|
|
4677
|
-
*/
|
|
4678
|
-
let objectType;
|
|
4679
|
-
if (field.options?.polymorphic) {
|
|
4680
|
-
const typePath = field.options.type ?? "type";
|
|
4681
|
-
if (typePath === "@hash") objectType = schema.hashFn({ type: field.type })(rawValue, null, null);
|
|
4682
|
-
else objectType = rawValue[typePath];
|
|
4683
|
-
} else objectType = field.type;
|
|
4780
|
+
const { type: objectType, hash } = fieldValueIdentity(schema, field, rawValue);
|
|
4684
4781
|
/**
|
|
4685
4782
|
* When KeyMode=@hash the ReactiveResource is keyed into
|
|
4686
4783
|
* ManagedRecordRefs by the return value of @hash on the rawValue.
|
|
@@ -4689,10 +4786,8 @@ var ManagedArray = class {
|
|
|
4689
4786
|
* when ARRAY_SIGNAL is dirty if hash performance becomes a bottleneck.
|
|
4690
4787
|
*/
|
|
4691
4788
|
let schemaObjectKeyValue;
|
|
4692
|
-
if (KeyMode === "@hash")
|
|
4693
|
-
|
|
4694
|
-
schemaObjectKeyValue = schema.hashFn(hashField)(rawValue, hashField.options ?? null, hashField.name);
|
|
4695
|
-
} else schemaObjectKeyValue = KeyMode === "@identity" ? rawValue : KeyMode === "@index" ? index : rawValue[KeyMode];
|
|
4789
|
+
if (KeyMode === "@hash") schemaObjectKeyValue = hash;
|
|
4790
|
+
else schemaObjectKeyValue = KeyMode === "@identity" ? rawValue : KeyMode === "@index" ? index : rawValue[KeyMode];
|
|
4696
4791
|
if (!schemaObjectKeyValue && schemaObjectKeyValue !== 0) return;
|
|
4697
4792
|
const recordRef = ManagedRecordRefs.get(schemaObjectKeyValue);
|
|
4698
4793
|
const record = recordRef?.value.deref();
|
|
@@ -4816,8 +4911,7 @@ Object.defineProperty(ManagedArray.prototype, "[]", {
|
|
|
4816
4911
|
}
|
|
4817
4912
|
});
|
|
4818
4913
|
|
|
4819
|
-
|
|
4820
|
-
//#region src/reactive/-private/kind/array-field.ts
|
|
4914
|
+
// src/reactive/-private/kind/array-field.ts
|
|
4821
4915
|
function getArrayField(context) {
|
|
4822
4916
|
const signal = entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4823
4917
|
const { record } = context;
|
|
@@ -4860,8 +4954,7 @@ function setArrayField(context) {
|
|
|
4860
4954
|
return true;
|
|
4861
4955
|
}
|
|
4862
4956
|
|
|
4863
|
-
|
|
4864
|
-
//#region src/reactive/-private/kind/attribute-field.ts
|
|
4957
|
+
// src/reactive/-private/kind/attribute-field.ts
|
|
4865
4958
|
function getAttributeField(context) {
|
|
4866
4959
|
entangleInitiallyStaleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4867
4960
|
const { cache } = context.store;
|
|
@@ -4872,8 +4965,7 @@ function setAttributeField(context) {
|
|
|
4872
4965
|
return true;
|
|
4873
4966
|
}
|
|
4874
4967
|
|
|
4875
|
-
|
|
4876
|
-
//#region src/reactive/-private/fields/get-field-key.ts
|
|
4968
|
+
// src/reactive/-private/fields/get-field-key.ts
|
|
4877
4969
|
const InvalidKinds = [
|
|
4878
4970
|
"alias",
|
|
4879
4971
|
"derived",
|
|
@@ -4892,8 +4984,7 @@ function getFieldCacheKey(field) {
|
|
|
4892
4984
|
return "sourceKey" in field && field.sourceKey ? field.sourceKey : field.name;
|
|
4893
4985
|
}
|
|
4894
4986
|
|
|
4895
|
-
|
|
4896
|
-
//#region src/reactive/-private/kind/belongs-to-field.ts
|
|
4987
|
+
// src/reactive/-private/kind/belongs-to-field.ts
|
|
4897
4988
|
function getBelongsToField(context) {
|
|
4898
4989
|
entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4899
4990
|
const { field, resourceKey, store } = context;
|
|
@@ -4930,8 +5021,7 @@ function getResourceKey(record) {
|
|
|
4930
5021
|
return recordIdentifierFor(record);
|
|
4931
5022
|
}
|
|
4932
5023
|
|
|
4933
|
-
|
|
4934
|
-
//#region src/reactive/-private/kind/collection-field.ts
|
|
5024
|
+
// src/reactive/-private/kind/collection-field.ts
|
|
4935
5025
|
function getCollectionField(context) {
|
|
4936
5026
|
entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4937
5027
|
}
|
|
@@ -4939,8 +5029,7 @@ function setCollectionField(context) {
|
|
|
4939
5029
|
return false;
|
|
4940
5030
|
}
|
|
4941
5031
|
|
|
4942
|
-
|
|
4943
|
-
//#region src/reactive/-private/kind/derived-field.ts
|
|
5032
|
+
// src/reactive/-private/kind/derived-field.ts
|
|
4944
5033
|
function getDerivedField(context) {
|
|
4945
5034
|
const { schema } = context.store;
|
|
4946
5035
|
return schema.derivation(context.field)(context.record, context.field.options ?? null, context.field.name);
|
|
@@ -4949,8 +5038,7 @@ function setDerivedField(context) {
|
|
|
4949
5038
|
return false;
|
|
4950
5039
|
}
|
|
4951
5040
|
|
|
4952
|
-
|
|
4953
|
-
//#region src/reactive/-private/kind/generic-field.ts
|
|
5041
|
+
// src/reactive/-private/kind/generic-field.ts
|
|
4954
5042
|
function getGenericField(context) {
|
|
4955
5043
|
const signal = entangleInitiallyStaleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4956
5044
|
signal.isStale = false;
|
|
@@ -4972,8 +5060,7 @@ function setGenericField(context) {
|
|
|
4972
5060
|
return true;
|
|
4973
5061
|
}
|
|
4974
5062
|
|
|
4975
|
-
|
|
4976
|
-
//#region src/reactive/-private/fields/many-array-manager.ts
|
|
5063
|
+
// src/reactive/-private/fields/many-array-manager.ts
|
|
4977
5064
|
var ManyArrayManager = class {
|
|
4978
5065
|
constructor(record, editable) {
|
|
4979
5066
|
const context = record[Context];
|
|
@@ -5029,8 +5116,7 @@ function extractCacheOptions(options) {
|
|
|
5029
5116
|
return cacheOptions;
|
|
5030
5117
|
}
|
|
5031
5118
|
|
|
5032
|
-
|
|
5033
|
-
//#region src/reactive/-private/kind/has-many-field.ts
|
|
5119
|
+
// src/reactive/-private/kind/has-many-field.ts
|
|
5034
5120
|
function getHasManyField(context) {
|
|
5035
5121
|
const signal = entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
5036
5122
|
const { store, field } = context;
|
|
@@ -5067,8 +5153,7 @@ function setHasManyField(context) {
|
|
|
5067
5153
|
return true;
|
|
5068
5154
|
}
|
|
5069
5155
|
|
|
5070
|
-
|
|
5071
|
-
//#region src/reactive/-private/kind/hash-field.ts
|
|
5156
|
+
// src/reactive/-private/kind/hash-field.ts
|
|
5072
5157
|
function getHashField(context) {
|
|
5073
5158
|
const { field, path, resourceKey } = context;
|
|
5074
5159
|
const { schema, cache } = context.store;
|
|
@@ -5080,8 +5165,7 @@ function setHashField(context) {
|
|
|
5080
5165
|
return false;
|
|
5081
5166
|
}
|
|
5082
5167
|
|
|
5083
|
-
|
|
5084
|
-
//#region src/reactive/-private/kind/identity-field.ts
|
|
5168
|
+
// src/reactive/-private/kind/identity-field.ts
|
|
5085
5169
|
function getIdentityField(context) {
|
|
5086
5170
|
entangleSignal(context.signals, context.record, "@identity", null);
|
|
5087
5171
|
return context.resourceKey.id;
|
|
@@ -5097,8 +5181,7 @@ function setIdentityField(context) {
|
|
|
5097
5181
|
return true;
|
|
5098
5182
|
}
|
|
5099
5183
|
|
|
5100
|
-
|
|
5101
|
-
//#region src/reactive/-private/kind/local-field.ts
|
|
5184
|
+
// src/reactive/-private/kind/local-field.ts
|
|
5102
5185
|
function getLocalField(context) {
|
|
5103
5186
|
const { field } = context;
|
|
5104
5187
|
const signal = getOrCreateInternalSignal(context.signals, context.record, field.name, field.options?.defaultValue ?? null);
|
|
@@ -5115,8 +5198,7 @@ function setLocalField(context) {
|
|
|
5115
5198
|
return true;
|
|
5116
5199
|
}
|
|
5117
5200
|
|
|
5118
|
-
|
|
5119
|
-
//#region src/reactive/-private/fields/managed-object.ts
|
|
5201
|
+
// src/reactive/-private/fields/managed-object.ts
|
|
5120
5202
|
const ObjectSymbols = /* @__PURE__ */ new Set([
|
|
5121
5203
|
OBJECT_SIGNAL,
|
|
5122
5204
|
Context,
|
|
@@ -5197,8 +5279,7 @@ function peekManagedObject(record, field) {
|
|
|
5197
5279
|
if (managedObjectMapForRecord) return managedObjectMapForRecord.get(field.name);
|
|
5198
5280
|
}
|
|
5199
5281
|
|
|
5200
|
-
|
|
5201
|
-
//#region src/reactive/-private/kind/object-field.ts
|
|
5282
|
+
// src/reactive/-private/kind/object-field.ts
|
|
5202
5283
|
function getObjectField(context) {
|
|
5203
5284
|
entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
5204
5285
|
const { record, field } = context;
|
|
@@ -5254,8 +5335,7 @@ function setObjectField(context) {
|
|
|
5254
5335
|
return true;
|
|
5255
5336
|
}
|
|
5256
5337
|
|
|
5257
|
-
|
|
5258
|
-
//#region src/reactive/-private/kind/resource-field.ts
|
|
5338
|
+
// src/reactive/-private/kind/resource-field.ts
|
|
5259
5339
|
var ResourceRelationship = class {
|
|
5260
5340
|
constructor(context) {
|
|
5261
5341
|
const { store, resourceKey } = context;
|
|
@@ -5295,8 +5375,7 @@ function setResourceField(context) {
|
|
|
5295
5375
|
return false;
|
|
5296
5376
|
}
|
|
5297
5377
|
|
|
5298
|
-
|
|
5299
|
-
//#region src/reactive/-private/kind/schema-array-field.ts
|
|
5378
|
+
// src/reactive/-private/kind/schema-array-field.ts
|
|
5300
5379
|
function setSchemaArrayField(context) {
|
|
5301
5380
|
const arrayValue = context.value === null ? null : context.value?.slice();
|
|
5302
5381
|
const fieldSignal = peekInternalSignal(context.signals, context.path.at(-1));
|
|
@@ -5310,8 +5389,7 @@ function setSchemaArrayField(context) {
|
|
|
5310
5389
|
return true;
|
|
5311
5390
|
}
|
|
5312
5391
|
|
|
5313
|
-
|
|
5314
|
-
//#region src/reactive/-private/kind/schema-object-field.ts
|
|
5392
|
+
// src/reactive/-private/kind/schema-object-field.ts
|
|
5315
5393
|
function getSchemaObjectField(context) {
|
|
5316
5394
|
const signal = entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
5317
5395
|
const { store, resourceKey, path, field } = context;
|
|
@@ -5328,15 +5406,8 @@ function getSchemaObjectField(context) {
|
|
|
5328
5406
|
}
|
|
5329
5407
|
return null;
|
|
5330
5408
|
}
|
|
5331
|
-
const {
|
|
5332
|
-
|
|
5333
|
-
if (field.options?.polymorphic) {
|
|
5334
|
-
const typePath = field.options.type ?? "type";
|
|
5335
|
-
if (typePath === "@hash") objectType = schema.hashFn({ type: field.type })(rawValue, null, null);
|
|
5336
|
-
else objectType = rawValue[typePath];
|
|
5337
|
-
} else objectType = field.type;
|
|
5338
|
-
const hashField = schema.resource({ type: objectType }).identity;
|
|
5339
|
-
const identity = hashField ? schema.hashFn(hashField)(rawValue, hashField.options ?? null, hashField.name) : field.name;
|
|
5409
|
+
const { type: objectType, hash } = fieldValueIdentity(store.schema, field, rawValue);
|
|
5410
|
+
const identity = hash ?? field.name;
|
|
5340
5411
|
const cachedSchemaObject = signal.value;
|
|
5341
5412
|
if (cachedSchemaObject) {
|
|
5342
5413
|
if (cachedSchemaObject.type === objectType && cachedSchemaObject.identity === identity) return cachedSchemaObject.value;
|
|
@@ -5373,8 +5444,7 @@ function setSchemaObjectField(context) {
|
|
|
5373
5444
|
return true;
|
|
5374
5445
|
}
|
|
5375
5446
|
|
|
5376
|
-
|
|
5377
|
-
//#region src/reactive/-private/default-mode.ts
|
|
5447
|
+
// src/reactive/-private/default-mode.ts
|
|
5378
5448
|
/**
|
|
5379
5449
|
* A ReactiveResource context object passed to
|
|
5380
5450
|
* the get/set functions of a field kind implementation.
|
|
@@ -5490,14 +5560,15 @@ const DefaultMode = {
|
|
|
5490
5560
|
}
|
|
5491
5561
|
};
|
|
5492
5562
|
|
|
5493
|
-
|
|
5494
|
-
//#region src/reactive/-private/record.ts
|
|
5563
|
+
// src/reactive/-private/record.ts
|
|
5495
5564
|
const IgnoredGlobalFields = /* @__PURE__ */ new Set([
|
|
5496
5565
|
"length",
|
|
5497
5566
|
"nodeType",
|
|
5498
5567
|
"then",
|
|
5499
5568
|
"setInterval",
|
|
5500
5569
|
"document",
|
|
5570
|
+
"unknownProperty",
|
|
5571
|
+
"size",
|
|
5501
5572
|
STRUCTURED
|
|
5502
5573
|
]);
|
|
5503
5574
|
const RecordSymbols = /* @__PURE__ */ new Set([
|
|
@@ -5522,10 +5593,14 @@ const Editables = /* @__PURE__ */ new Map();
|
|
|
5522
5593
|
* and a ResourceKey to transform data from the cache into a rich, reactive
|
|
5523
5594
|
* object.
|
|
5524
5595
|
*
|
|
5596
|
+
* The [ResourceSchemas](/guides/the-manual/schemas/resources/) guide shows how to
|
|
5597
|
+
* define the schema it reads.
|
|
5598
|
+
*
|
|
5525
5599
|
* This class is not directly instantiable. To use it, you should
|
|
5526
5600
|
* configure the store's `instantiateRecord` and `teardownRecord` hooks
|
|
5527
5601
|
* with the matching hooks provided by this package.
|
|
5528
5602
|
*
|
|
5603
|
+
* @summary The rich, reactive record object that presents a resource's cached data through its `ResourceSchema`.
|
|
5529
5604
|
* @hideconstructor
|
|
5530
5605
|
* @public
|
|
5531
5606
|
*/
|
|
@@ -5921,6 +5996,8 @@ function assertNeverField(identifier, field, path) {
|
|
|
5921
5996
|
* Edits to editable resources will be automatically committed if a new
|
|
5922
5997
|
* payload from the cache matches their existing value.
|
|
5923
5998
|
*
|
|
5999
|
+
* @summary Resolves with an editable copy of an immutable `ReactiveResource` so its fields can be
|
|
6000
|
+
* changed locally.
|
|
5924
6001
|
* @public
|
|
5925
6002
|
*
|
|
5926
6003
|
* @returns a promise that resolves to the editable resource
|
|
@@ -5937,14 +6014,15 @@ function checkout(resource) {
|
|
|
5937
6014
|
* approach is for either the API or a Handler to reflect saved
|
|
5938
6015
|
* changes back to update the cache.
|
|
5939
6016
|
*
|
|
6017
|
+
* @summary Forcibly makes an editable resource's local changes its new remote (immutable) state,
|
|
6018
|
+
* bypassing a save round-trip.
|
|
5940
6019
|
* @public
|
|
5941
6020
|
*/
|
|
5942
6021
|
function commit(record) {
|
|
5943
6022
|
return record[Commit]();
|
|
5944
6023
|
}
|
|
5945
6024
|
|
|
5946
|
-
|
|
5947
|
-
//#region src/reactive/-private/hooks.ts
|
|
6025
|
+
// src/reactive/-private/hooks.ts
|
|
5948
6026
|
/**
|
|
5949
6027
|
* The store's default `instantiateRecord` hook implementation, which
|
|
5950
6028
|
* produces a {@link ReactiveResource} for `identifier` using the resource
|
|
@@ -5954,6 +6032,8 @@ function commit(record) {
|
|
|
5954
6032
|
* schema is `legacy`, matching the historical behavior of assigning initial
|
|
5955
6033
|
* properties when creating a new legacy record.
|
|
5956
6034
|
*
|
|
6035
|
+
* @summary Default store `instantiateRecord` hook that creates a `ReactiveResource` for a resource key
|
|
6036
|
+
* from its registered schema.
|
|
5957
6037
|
* @public
|
|
5958
6038
|
*/
|
|
5959
6039
|
function instantiateRecord(store, identifier, createArgs) {
|
|
@@ -5977,14 +6057,15 @@ function instantiateRecord(store, identifier, createArgs) {
|
|
|
5977
6057
|
* that `record` is a {@link ReactiveResource} and invokes its `Destroy`
|
|
5978
6058
|
* behavior.
|
|
5979
6059
|
*
|
|
6060
|
+
* @summary Default store `teardownRecord` hook that destroys a `ReactiveResource` when the store
|
|
6061
|
+
* releases it.
|
|
5980
6062
|
* @public
|
|
5981
6063
|
*/
|
|
5982
6064
|
function teardownRecord(record) {
|
|
5983
6065
|
record[Destroy]();
|
|
5984
6066
|
}
|
|
5985
6067
|
|
|
5986
|
-
|
|
5987
|
-
//#region src/reactive/-private/schema.ts
|
|
6068
|
+
// src/reactive/-private/schema.ts
|
|
5988
6069
|
const Support = getOrSetGlobal("Support", /* @__PURE__ */ new WeakMap());
|
|
5989
6070
|
const ConstructorField = {
|
|
5990
6071
|
type: "@constructor",
|
|
@@ -6026,16 +6107,25 @@ _constructor[Type] = "@constructor";
|
|
|
6026
6107
|
* This should only be used for temporary migration purposes
|
|
6027
6108
|
* to the new schema system when migrating from either Model
|
|
6028
6109
|
* or ModelFragments.
|
|
6110
|
+
*
|
|
6111
|
+
* @summary Registers named methods, getters, and values to add to ReactiveResources, ReactiveObjects,
|
|
6112
|
+
* or ReactiveArrays; meant only as a temporary aid when migrating from Model or ModelFragments.
|
|
6029
6113
|
*/
|
|
6030
6114
|
/**
|
|
6031
6115
|
* Describes one feature added to a resource by a schema extension, as
|
|
6032
6116
|
* classified by {@link processExtension} from the property descriptor it
|
|
6033
6117
|
* was declared with (a method, a plain value, or a getter/setter pair).
|
|
6118
|
+
*
|
|
6119
|
+
* @summary One normalized feature of a schema extension, tagged by kind as a method, a readonly or
|
|
6120
|
+
* mutable value, or a getter/setter accessor.
|
|
6034
6121
|
*/
|
|
6035
6122
|
/**
|
|
6036
6123
|
* The result of {@link processExtension} normalizing a
|
|
6037
6124
|
* {@link CAUTION_MEGA_DANGER_ZONE_Extension} into a lookup of its features
|
|
6038
6125
|
* by name.
|
|
6126
|
+
*
|
|
6127
|
+
* @summary A registered schema extension normalized into its kind, name, and a map of its features
|
|
6128
|
+
* keyed by property name.
|
|
6039
6129
|
*/
|
|
6040
6130
|
const BannedKeys = ["constructor", "__proto__"];
|
|
6041
6131
|
function processExtension(extension) {
|
|
@@ -6125,14 +6215,19 @@ function processExtensions(schema, field, scenario, resolvedType) {
|
|
|
6125
6215
|
* Utility for constructing a ResourceSchema with the recommended
|
|
6126
6216
|
* fields for the PolarisMode experience.
|
|
6127
6217
|
*
|
|
6218
|
+
* The [ResourceSchemas](/guides/the-manual/schemas/resources/) guide shows how to
|
|
6219
|
+
* create a schema with it.
|
|
6220
|
+
*
|
|
6128
6221
|
* Using this requires registering the PolarisMode derivations
|
|
6129
6222
|
*
|
|
6130
6223
|
* ```ts
|
|
6131
|
-
* import { registerDerivations } from '@warp-drive-mirror/
|
|
6224
|
+
* import { registerDerivations } from '@warp-drive-mirror/core/reactive';
|
|
6132
6225
|
*
|
|
6133
6226
|
* registerDerivations(schema);
|
|
6134
6227
|
* ```
|
|
6135
6228
|
*
|
|
6229
|
+
* @summary Adds the default `id` identity plus `$key`, `$type`, and `constructor` derived fields to a
|
|
6230
|
+
* PolarisMode resource schema.
|
|
6136
6231
|
* @public
|
|
6137
6232
|
* @param schema
|
|
6138
6233
|
* @return {PolarisResourceSchema}
|
|
@@ -6163,6 +6258,8 @@ function withDefaults(schema) {
|
|
|
6163
6258
|
*
|
|
6164
6259
|
* `^` returns the entire identifier object.
|
|
6165
6260
|
*
|
|
6261
|
+
* @summary The `@identity` derivation, which reads a record's `id`, `lid`, `type`, or whole resource key
|
|
6262
|
+
* for use in derived fields.
|
|
6166
6263
|
* @public
|
|
6167
6264
|
*/
|
|
6168
6265
|
const fromIdentity = (record, options, key) => {
|
|
@@ -6175,9 +6272,14 @@ fromIdentity[Type] = "@identity";
|
|
|
6175
6272
|
* to use the PolarisMode defaults provided by
|
|
6176
6273
|
*
|
|
6177
6274
|
* ```ts
|
|
6178
|
-
* import { withDefaults } from '@warp-drive-mirror/
|
|
6275
|
+
* import { withDefaults } from '@warp-drive-mirror/core/reactive';
|
|
6179
6276
|
* ```
|
|
6180
6277
|
*
|
|
6278
|
+
* The [Derivations](/guides/the-manual/schemas/derivations#about-built-in-derivations)
|
|
6279
|
+
* guide explains when you need to call it.
|
|
6280
|
+
*
|
|
6281
|
+
* @summary Registers the `@identity` and `@constructor` derivations that schemas built with
|
|
6282
|
+
* `withDefaults` depend on.
|
|
6181
6283
|
* @public
|
|
6182
6284
|
*/
|
|
6183
6285
|
function registerDerivations(schema) {
|
|
@@ -6188,6 +6290,9 @@ function registerDerivations(schema) {
|
|
|
6188
6290
|
* Defines how to convert a `GenericField`, `ObjectField`, or `ArrayField`
|
|
6189
6291
|
* between the raw value `T` stored in the cache and the presentation value
|
|
6190
6292
|
* `PT` exposed on the record.
|
|
6293
|
+
*
|
|
6294
|
+
* @summary A registered converter between a field's raw cache value and the value exposed on the
|
|
6295
|
+
* record, with optional default.
|
|
6191
6296
|
*/
|
|
6192
6297
|
/**
|
|
6193
6298
|
* Wraps a derivation in a new function with Derivation signature but that looks
|
|
@@ -6210,6 +6315,12 @@ function makeCachedDerivation(derivation) {
|
|
|
6210
6315
|
/**
|
|
6211
6316
|
* A SchemaService designed to work with dynamically registered schemas.
|
|
6212
6317
|
*
|
|
6318
|
+
* The [Schemas](/guides/the-manual/schemas/) guide shows how to register schemas
|
|
6319
|
+
* with it, and [Advanced Store Configuration](/guides/configuration/advanced#add-a-source-for-schema-for-your-data)
|
|
6320
|
+
* shows how to give a store one.
|
|
6321
|
+
*
|
|
6322
|
+
* @summary The default schema service, which stores resource and object schemas, traits, derivations,
|
|
6323
|
+
* transformations, hash functions and extensions registered at runtime.
|
|
6213
6324
|
* @public
|
|
6214
6325
|
*/
|
|
6215
6326
|
var SchemaService = class {
|
|
@@ -6528,284 +6639,7 @@ function mergeMap(base, toApply) {
|
|
|
6528
6639
|
for (const [key, value] of toApply) base.set(key, value);
|
|
6529
6640
|
}
|
|
6530
6641
|
|
|
6531
|
-
|
|
6532
|
-
//#region src/reactive.ts
|
|
6533
|
-
/**
|
|
6534
|
-
* # About
|
|
6535
|
-
*
|
|
6536
|
-
* This module provides an implementation of reactive objects that a Store may use for creating
|
|
6537
|
-
* reactive representations of the raw data for requests, resources and their relationships
|
|
6538
|
-
* stored in the cache.
|
|
6539
|
-
*
|
|
6540
|
-
* - For configuring the store to use these reactive objects, see [The Setup Guide](/guides/configuration/)
|
|
6541
|
-
* - For defining resource schemas, see [The Schema Guide](/guides/the-manual/schemas/)
|
|
6542
|
-
*
|
|
6543
|
-
* Any method that returns a record instance will use the `instantiateRecord`
|
|
6544
|
-
* hook configured above to instantiate a ReactiveResource once this is in place.
|
|
6545
|
-
* After that, its up to you what ReactiveResource can do.
|
|
6546
|
-
*
|
|
6547
|
-
* ## Modes
|
|
6548
|
-
*
|
|
6549
|
-
* ReactiveResource has two modes: `legacy` and `polaris`.
|
|
6550
|
-
*
|
|
6551
|
-
* **LegacyMode** can be used to emulate the behaviors and capabilities of WarpDrive's `Model` class,
|
|
6552
|
-
* and because there is little distinction between Model and a ReactiveResource in LegacyMode we refer
|
|
6553
|
-
* to both of these approaches as LegacyMode. This mode is the default experience in V5.
|
|
6554
|
-
*
|
|
6555
|
-
* In LegacyMode:
|
|
6556
|
-
*
|
|
6557
|
-
* - records are mutable
|
|
6558
|
-
* - local changes immediately reflect app wide
|
|
6559
|
-
* - records have all the APIs of Model (references, state props, currentState, methods etc)
|
|
6560
|
-
* - the continued use of `@warp-drive-mirror/legacy` is required (though most imports from it can be removed)
|
|
6561
|
-
* - `async: true` relationships are supported (but not recommended outside of [LinksMode](/guides/the-manual/misc/links-mode.md))
|
|
6562
|
-
*
|
|
6563
|
-
* ---
|
|
6564
|
-
*
|
|
6565
|
-
* **PolarisMode** is an upcoming suite of features that will become the default experience in V6.
|
|
6566
|
-
*
|
|
6567
|
-
* In PolarisMode:
|
|
6568
|
-
*
|
|
6569
|
-
* - records are immutable, unless creating a new resource or explicitly checking out a record for editing
|
|
6570
|
-
* - local changes are isolated until committed, displaying only via the editable version of the record
|
|
6571
|
-
* - records have a more limited API, focused on only what is in their schema.
|
|
6572
|
-
* - some common operations may have more friction to perform because intended utilities are not yet available
|
|
6573
|
-
* - `async: true` relationships are not supported (see [LinksMode](/guides/the-manual/misc/links-mode.md))
|
|
6574
|
-
* - The `@warp-drive-mirror/legacy` package is not required
|
|
6575
|
-
*
|
|
6576
|
-
* These modes are interopable. The reactive object (record) for a resource in PolarisMode can relate to
|
|
6577
|
-
* a record in LegacyMode and vice-versa. This interopability is true whether the record in LegacyMode is
|
|
6578
|
-
* a ReactiveResource or a Model.
|
|
6579
|
-
*
|
|
6580
|
-
* ---
|
|
6581
|
-
*
|
|
6582
|
-
* ## Basic Usage
|
|
6583
|
-
*
|
|
6584
|
-
* ReactiveResource is a reactive object that transforms raw data from an associated
|
|
6585
|
-
* cache into reactive data backed by Signals.
|
|
6586
|
-
*
|
|
6587
|
-
* The shape of the object and the transformation of raw cache data into its
|
|
6588
|
-
* reactive form is controlled by a resource schema.
|
|
6589
|
-
*
|
|
6590
|
-
* For instance, lets say your API is a [{json:api}](https://jsonapi.org) and your store is using
|
|
6591
|
-
* the Cache provided by {@link @warp-drive-mirror/json-api! | @warp-drive-mirror/json-api}, and a request
|
|
6592
|
-
* returns the following raw data:
|
|
6593
|
-
*
|
|
6594
|
-
* ```ts
|
|
6595
|
-
* {
|
|
6596
|
-
* data: {
|
|
6597
|
-
* type: 'user',
|
|
6598
|
-
* id: '1',
|
|
6599
|
-
* attributes: { firstName: 'Chris', lastName: 'Thoburn' },
|
|
6600
|
-
* relationships: { pets: { data: [{ type: 'dog', id: '1' }] }}
|
|
6601
|
-
* },
|
|
6602
|
-
* included: [
|
|
6603
|
-
* {
|
|
6604
|
-
* type: 'dog',
|
|
6605
|
-
* id: '1',
|
|
6606
|
-
* attributes: { name: 'Rey' },
|
|
6607
|
-
* relationships: { owner: { data: { type: 'user', id: '1' }}}
|
|
6608
|
-
* }
|
|
6609
|
-
* ]
|
|
6610
|
-
* }
|
|
6611
|
-
* ```
|
|
6612
|
-
*
|
|
6613
|
-
* We could describe the `'user'` and `'dog'` resources in the above payload
|
|
6614
|
-
* with the following schemas:
|
|
6615
|
-
*
|
|
6616
|
-
* ```ts
|
|
6617
|
-
* store.schema.registerResources([
|
|
6618
|
-
* {
|
|
6619
|
-
* type: 'user',
|
|
6620
|
-
* identity: { type: '@id', name: 'id' },
|
|
6621
|
-
* fields: [
|
|
6622
|
-
* {
|
|
6623
|
-
* type: '@identity',
|
|
6624
|
-
* name: '$type',
|
|
6625
|
-
* kind: 'derived',
|
|
6626
|
-
* options: { key: 'type' },
|
|
6627
|
-
* },
|
|
6628
|
-
* { kind: 'field', name: 'firstName' },
|
|
6629
|
-
* { kind: 'field', name: 'lastName' },
|
|
6630
|
-
* {
|
|
6631
|
-
* kind: 'derived',
|
|
6632
|
-
* name: 'name',
|
|
6633
|
-
* type: 'concat',
|
|
6634
|
-
* options: { fields: ['firstName', 'lastName'], separator: ' ' }
|
|
6635
|
-
* },
|
|
6636
|
-
* {
|
|
6637
|
-
* kind: 'hasMany',
|
|
6638
|
-
* name: 'pets',
|
|
6639
|
-
* type: 'pet',
|
|
6640
|
-
* options: {
|
|
6641
|
-
* async: false,
|
|
6642
|
-
* inverse: 'owner',
|
|
6643
|
-
* polymorphic: true,
|
|
6644
|
-
* linksMode: true,
|
|
6645
|
-
* }
|
|
6646
|
-
* }
|
|
6647
|
-
* ]
|
|
6648
|
-
* },
|
|
6649
|
-
* {
|
|
6650
|
-
* type: 'dog',
|
|
6651
|
-
* identity: { type: '@id', name: 'id' },
|
|
6652
|
-
* fields: [
|
|
6653
|
-
* {
|
|
6654
|
-
* type: '@identity',
|
|
6655
|
-
* name: '$type',
|
|
6656
|
-
* kind: 'derived',
|
|
6657
|
-
* options: { key: 'type' },
|
|
6658
|
-
* },
|
|
6659
|
-
* { kind: 'field', name: 'name' },
|
|
6660
|
-
* {
|
|
6661
|
-
* kind: 'belongsTo',
|
|
6662
|
-
* name: 'owner',
|
|
6663
|
-
* type: 'user',
|
|
6664
|
-
* options: {
|
|
6665
|
-
* async: false,
|
|
6666
|
-
* inverse: 'pets',
|
|
6667
|
-
* as: 'pet',
|
|
6668
|
-
* linksMode: true,
|
|
6669
|
-
* }
|
|
6670
|
-
* }
|
|
6671
|
-
* ]
|
|
6672
|
-
* }
|
|
6673
|
-
* ]);
|
|
6674
|
-
* ```
|
|
6675
|
-
*
|
|
6676
|
-
* With these schemas in place, the reactive objects that the store would
|
|
6677
|
-
* provide us whenever we encountered a `'user'` or a `'dog'` would be:
|
|
6678
|
-
*
|
|
6679
|
-
* ```ts
|
|
6680
|
-
* interface Pet {
|
|
6681
|
-
* readonly id: string;
|
|
6682
|
-
* readonly owner: User;
|
|
6683
|
-
* }
|
|
6684
|
-
*
|
|
6685
|
-
* interface Dog extends Pet {
|
|
6686
|
-
* readonly $type: 'dog';
|
|
6687
|
-
* readonly name: string;
|
|
6688
|
-
* }
|
|
6689
|
-
*
|
|
6690
|
-
* interface EditableUser {
|
|
6691
|
-
* readonly $type: 'user';
|
|
6692
|
-
* readonly id: string;
|
|
6693
|
-
* firstName: string;
|
|
6694
|
-
* lastName: string;
|
|
6695
|
-
* readonly name: string;
|
|
6696
|
-
* pets: Array<Dog | Pet>;
|
|
6697
|
-
* }
|
|
6698
|
-
*
|
|
6699
|
-
* interface User {
|
|
6700
|
-
* readonly $type: 'user';
|
|
6701
|
-
* readonly id: string;
|
|
6702
|
-
* readonly firstName: string;
|
|
6703
|
-
* readonly lastName: string;
|
|
6704
|
-
* readonly name: string;
|
|
6705
|
-
* readonly pets: Readonly<Array<Dog | Pet>>;
|
|
6706
|
-
* [Checkout](): Promise<EditableUser>
|
|
6707
|
-
* }>
|
|
6708
|
-
* ```
|
|
6709
|
-
*
|
|
6710
|
-
* Note how based on the schema the reactive object we receive is able to produce
|
|
6711
|
-
* `name` on user (despite no name field being in the cache), provide `$type`
|
|
6712
|
-
* pulled from the identity of the resource, and flatten the individual attributes
|
|
6713
|
-
* and relationships onto the record for easier use.
|
|
6714
|
-
*
|
|
6715
|
-
* Notice also how we typed this object with `readonly`. This is because while
|
|
6716
|
-
* ReactiveResource instances are ***deeply reactive***, they are also ***immutable***.
|
|
6717
|
-
*
|
|
6718
|
-
* We can mutate a ReactiveResource only be explicitly asking permission to do so, and
|
|
6719
|
-
* in the process gaining access to an editable copy. The immutable version will
|
|
6720
|
-
* not show any in-process edits made to this editable copy.
|
|
6721
|
-
*
|
|
6722
|
-
* ```ts
|
|
6723
|
-
* import { Checkout } from '@warp-drive-mirror/schema-record';
|
|
6724
|
-
*
|
|
6725
|
-
* const editable = await user[Checkout]();
|
|
6726
|
-
* ```
|
|
6727
|
-
*
|
|
6728
|
-
* ## Utilities
|
|
6729
|
-
*
|
|
6730
|
-
* ReactiveResource provides a schema builder that simplifies setting up a couple of
|
|
6731
|
-
* conventional fields like identity and `$type`. We can rewrite the schema
|
|
6732
|
-
* definition above using this utility like so:
|
|
6733
|
-
*
|
|
6734
|
-
* ```ts
|
|
6735
|
-
* import { withDefaults } from '@warp-drive-mirror/core/reactive';
|
|
6736
|
-
*
|
|
6737
|
-
* store.schema.registerResources([
|
|
6738
|
-
* withDefaults({
|
|
6739
|
-
* type: 'user',
|
|
6740
|
-
* fields: [
|
|
6741
|
-
* { kind: 'field', name: 'firstName' },
|
|
6742
|
-
* { kind: 'field', name: 'lastName' },
|
|
6743
|
-
* {
|
|
6744
|
-
* kind: 'derived',
|
|
6745
|
-
* name: 'name',
|
|
6746
|
-
* type: 'concat',
|
|
6747
|
-
* options: { fields: ['firstName', 'lastName'], separator: ' ' }
|
|
6748
|
-
* },
|
|
6749
|
-
* {
|
|
6750
|
-
* kind: 'hasMany',
|
|
6751
|
-
* name: 'pets',
|
|
6752
|
-
* type: 'pet',
|
|
6753
|
-
* options: {
|
|
6754
|
-
* async: false,
|
|
6755
|
-
* inverse: 'owner',
|
|
6756
|
-
* polymorphic: true,
|
|
6757
|
-
* linksMode: true,
|
|
6758
|
-
* resetOnRemoteUpdate: false,
|
|
6759
|
-
* }
|
|
6760
|
-
* }
|
|
6761
|
-
* ]
|
|
6762
|
-
* }),
|
|
6763
|
-
* withDefaults({
|
|
6764
|
-
* type: 'dog',
|
|
6765
|
-
* fields: [
|
|
6766
|
-
* { kind: 'field', name: 'name' },
|
|
6767
|
-
* {
|
|
6768
|
-
* kind: 'belongsTo',
|
|
6769
|
-
* name: 'owner',
|
|
6770
|
-
* type: 'user',
|
|
6771
|
-
* options: {
|
|
6772
|
-
* async: false,
|
|
6773
|
-
* inverse: 'pets',
|
|
6774
|
-
* as: 'pet',
|
|
6775
|
-
* linksMode: true,
|
|
6776
|
-
* resetOnRemoteUpdate: false,
|
|
6777
|
-
* }
|
|
6778
|
-
* }
|
|
6779
|
-
* ]
|
|
6780
|
-
* })
|
|
6781
|
-
* ]);
|
|
6782
|
-
* ```
|
|
6783
|
-
*
|
|
6784
|
-
* ## Type Support
|
|
6785
|
-
*
|
|
6786
|
-
* ### Resource Schemas
|
|
6787
|
-
*
|
|
6788
|
-
* - {@link PolarisResourceSchema}
|
|
6789
|
-
* - {@link LegacyResourceSchema}
|
|
6790
|
-
* - {@link ObjectSchema}
|
|
6791
|
-
*
|
|
6792
|
-
* ### Resource Schema Type Utils
|
|
6793
|
-
*
|
|
6794
|
-
* - {@link resourceSchema}
|
|
6795
|
-
* - {@link objectSchema}
|
|
6796
|
-
* - {@link isResourceSchema}
|
|
6797
|
-
* - {@link isLegacyResourceSchema}
|
|
6798
|
-
*
|
|
6799
|
-
* ### Field Schemas
|
|
6800
|
-
*
|
|
6801
|
-
* - {@link LegacyModeFieldSchema}
|
|
6802
|
-
* - {@link PolarisModeFieldSchema}
|
|
6803
|
-
*
|
|
6804
|
-
* @module
|
|
6805
|
-
*/
|
|
6806
|
-
|
|
6807
|
-
//#endregion
|
|
6808
|
-
//#region src/request/-private/fetch.ts
|
|
6642
|
+
// src/request/-private/fetch.ts
|
|
6809
6643
|
const _fetch = typeof fetch !== "undefined" ? (...args) => fetch(...args) : typeof FastBoot !== "undefined" ? (...args) => FastBoot.require("node-fetch")(...args) : () => {
|
|
6810
6644
|
throw new Error("No Fetch Implementation Found");
|
|
6811
6645
|
};
|
|
@@ -6878,6 +6712,9 @@ const ERROR_STATUS_CODE_FOR = /* @__PURE__ */ new Map([
|
|
|
6878
6712
|
* A basic Fetch Handler which converts a request into a
|
|
6879
6713
|
* `fetch` call presuming the response to be `json`.
|
|
6880
6714
|
*
|
|
6715
|
+
* The [Making Requests](/guides/the-manual/requests/#requests-do-not-need-to-use-fetch)
|
|
6716
|
+
* guide shows where it sits in the handler chain.
|
|
6717
|
+
*
|
|
6881
6718
|
* ```ts
|
|
6882
6719
|
* import { RequestManager, Fetch } from '@warp-drive-mirror/core';
|
|
6883
6720
|
*
|
|
@@ -6885,6 +6722,8 @@ const ERROR_STATUS_CODE_FOR = /* @__PURE__ */ new Map([
|
|
|
6885
6722
|
* .use([Fetch]);
|
|
6886
6723
|
* ```
|
|
6887
6724
|
*
|
|
6725
|
+
* @summary Terminal request handler that sends the request with native `fetch` and resolves with the
|
|
6726
|
+
* parsed JSON body, turning HTTP failures into errors.
|
|
6888
6727
|
* @public
|
|
6889
6728
|
* @badge Handler
|
|
6890
6729
|
*/
|
|
@@ -7002,8 +6841,7 @@ function isDict(v) {
|
|
|
7002
6841
|
return v !== null && typeof v === "object";
|
|
7003
6842
|
}
|
|
7004
6843
|
|
|
7005
|
-
|
|
7006
|
-
//#region src/request/-private/manager.ts
|
|
6844
|
+
// src/request/-private/manager.ts
|
|
7007
6845
|
/**
|
|
7008
6846
|
* ## Import
|
|
7009
6847
|
*
|
|
@@ -7011,7 +6849,8 @@ function isDict(v) {
|
|
|
7011
6849
|
* import { RequestManager } from '@warp-drive-mirror/core';
|
|
7012
6850
|
* ```
|
|
7013
6851
|
*
|
|
7014
|
-
* For complete usage guide see
|
|
6852
|
+
* For a complete usage guide see [Making Requests](/guides/the-manual/requests/), and
|
|
6853
|
+
* [Handlers](/guides/the-manual/requests/handlers) for writing the handlers it runs.
|
|
7015
6854
|
*
|
|
7016
6855
|
* ## How It Works
|
|
7017
6856
|
*
|
|
@@ -7034,11 +6873,28 @@ function isDict(v) {
|
|
|
7034
6873
|
* ```ts [Setup.ts]
|
|
7035
6874
|
* import { RequestManager, Fetch } from '@warp-drive-mirror/core';
|
|
7036
6875
|
* import { AutoCompress } from '@warp-drive-mirror/utilities/handlers';
|
|
7037
|
-
* import
|
|
6876
|
+
* import { AuthHandler } from './auth-handler';
|
|
7038
6877
|
*
|
|
7039
6878
|
* // ... create manager
|
|
7040
6879
|
* const manager = new RequestManager()
|
|
7041
|
-
* .use([
|
|
6880
|
+
* .use([AuthHandler, new AutoCompress(), Fetch]); // [!code focus]
|
|
6881
|
+
* ```
|
|
6882
|
+
*
|
|
6883
|
+
* ```ts [auth-handler.ts]
|
|
6884
|
+
* import type { Handler, NextFn } from '@warp-drive-mirror/core/request';
|
|
6885
|
+
* import type { RequestContext } from '@warp-drive-mirror/core/types/request';
|
|
6886
|
+
*
|
|
6887
|
+
* const token = '<token>';
|
|
6888
|
+
*
|
|
6889
|
+
* // adds a bearer token to every request, then passes it along
|
|
6890
|
+
* export const AuthHandler: Handler = {
|
|
6891
|
+
* request<T>(context: RequestContext, next: NextFn<T>) {
|
|
6892
|
+
* const headers = new Headers(context.request.headers);
|
|
6893
|
+
* headers.append('Authorization', `Bearer ${token}`);
|
|
6894
|
+
*
|
|
6895
|
+
* return next(Object.assign({}, context.request, { headers }));
|
|
6896
|
+
* },
|
|
6897
|
+
* };
|
|
7042
6898
|
* ```
|
|
7043
6899
|
*
|
|
7044
6900
|
* ```ts [Usage.ts]
|
|
@@ -7054,6 +6910,20 @@ function isDict(v) {
|
|
|
7054
6910
|
*
|
|
7055
6911
|
* :::
|
|
7056
6912
|
*
|
|
6913
|
+
* ### RequestManager vs {@link Store.request}
|
|
6914
|
+
*
|
|
6915
|
+
* A bare `RequestManager` is the low-level primitive: it runs a request through the configured
|
|
6916
|
+
* {@link Handler | handler chain} and settles with the raw {@link StructuredDocument}. It has no
|
|
6917
|
+
* cache and does not hydrate {@link ReactiveDocument | ReactiveDocuments} unless you register a
|
|
6918
|
+
* cache handler yourself via {@link RequestManager.useCache} and the request opts in.
|
|
6919
|
+
*
|
|
6920
|
+
* {@link Store.request} issues requests through this same `RequestManager`, but with the Store's
|
|
6921
|
+
* cache handler and hydration already wired up — inserting the response into the Store's cache
|
|
6922
|
+
* and resolving with a `ReactiveDocument` instead. Use `store.request` for anything the Store's
|
|
6923
|
+
* cache should own, which is nearly all app code. Reach for `requestManager.request` directly
|
|
6924
|
+
* only when there is no {@link Store} involved, or you specifically want the unprocessed
|
|
6925
|
+
* `StructuredDocument`.
|
|
6926
|
+
*
|
|
7057
6927
|
* ### Futures
|
|
7058
6928
|
*
|
|
7059
6929
|
* The return value of `manager.request` is a `Future`, which allows
|
|
@@ -7092,6 +6962,7 @@ function isDict(v) {
|
|
|
7092
6962
|
* type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument;
|
|
7093
6963
|
* ```
|
|
7094
6964
|
*
|
|
6965
|
+
* @summary Runs each request through a chain of handlers that can fulfill, modify, or pass it along, and returns a `Future` for the response.
|
|
7095
6966
|
* @public
|
|
7096
6967
|
*/
|
|
7097
6968
|
var RequestManager = class {
|
|
@@ -7142,7 +7013,23 @@ var RequestManager = class {
|
|
|
7142
7013
|
/**
|
|
7143
7014
|
* Issue a Request.
|
|
7144
7015
|
*
|
|
7145
|
-
*
|
|
7016
|
+
* Runs `request` through the configured {@link Handler | handler chain} and settles with the
|
|
7017
|
+
* {@link StructuredDocument} the chain produces — a plain `{ request, response, content }`
|
|
7018
|
+
* object, not a {@link ReactiveDocument}. Caching and hydration only happen if a cache handler
|
|
7019
|
+
* has been registered via {@link RequestManager.useCache} and the request opts in; a
|
|
7020
|
+
* `RequestManager` created on its own has neither.
|
|
7021
|
+
*
|
|
7022
|
+
* Most app code should use {@link Store.request} instead, which calls this same method with
|
|
7023
|
+
* the Store's cache handler and hydration already configured. Reach for `requestManager.request`
|
|
7024
|
+
* directly when there is no {@link Store} involved, or when you want the unprocessed
|
|
7025
|
+
* `StructuredDocument`. The `<RT>` generic can be set explicitly or inferred from a request
|
|
7026
|
+
* built with {@link withResponseType} or {@link withReactiveResponse} — see
|
|
7027
|
+
* [Typing Requests](/guides/the-manual/requests/typing-requests.md).
|
|
7028
|
+
*
|
|
7029
|
+
* @example
|
|
7030
|
+
* ```ts
|
|
7031
|
+
* const { content } = await requestManager.request({ url: '/users' });
|
|
7032
|
+
* ```
|
|
7146
7033
|
*
|
|
7147
7034
|
* @public
|
|
7148
7035
|
*/
|
|
@@ -7201,20 +7088,27 @@ var RequestManager = class {
|
|
|
7201
7088
|
*
|
|
7202
7089
|
* @private
|
|
7203
7090
|
*/
|
|
7204
|
-
|
|
7205
|
-
//#region src/index.ts
|
|
7091
|
+
// src/index.ts
|
|
7206
7092
|
/**
|
|
7093
|
+
* @summary Main entry point for WarpDrive: the `Store`, `RequestManager`, `Fetch` handler, `CacheHandler`, and
|
|
7094
|
+
* `useRecommendedStore` for building a configured store.
|
|
7207
7095
|
* @module
|
|
7208
7096
|
* @mergeModuleWith <project>
|
|
7209
7097
|
*/
|
|
7210
7098
|
globalThis.setWarpDriveIsMaybeMirage = setIsMaybeMirage;
|
|
7211
7099
|
/**
|
|
7212
7100
|
* Options for setting up a Store instance with `useRecommendedStore`.
|
|
7101
|
+
*
|
|
7102
|
+
* @summary Configures the cache, cache policy, request handlers, schemas, and schema extensions that
|
|
7103
|
+
* `useRecommendedStore` wires into a Store class.
|
|
7213
7104
|
*/
|
|
7214
7105
|
/**
|
|
7215
7106
|
* Creates a configured Store class with recommended defaults
|
|
7216
7107
|
* for schema handling, reactivity, caching, and request management.
|
|
7217
7108
|
*
|
|
7109
|
+
* The [Setup](/guides/configuration/#configure-the-store) guide walks through
|
|
7110
|
+
* configuring the store with it.
|
|
7111
|
+
*
|
|
7218
7112
|
* ```ts
|
|
7219
7113
|
* import { useRecommendedStore } from '@warp-drive-mirror/core';
|
|
7220
7114
|
* import { JSONAPICache } from '@warp-drive-mirror/json-api';
|
|
@@ -7317,6 +7211,9 @@ globalThis.setWarpDriveIsMaybeMirage = setIsMaybeMirage;
|
|
|
7317
7211
|
* {@link RequestManager} won't have it set unless the caller supplies it
|
|
7318
7212
|
* explicitly, so a handler relying on it should treat it as optional (as
|
|
7319
7213
|
* `LoggingHandler` does above).
|
|
7214
|
+
*
|
|
7215
|
+
* @summary Builds a Store subclass preconfigured with the given cache, schemas, and handlers, plus
|
|
7216
|
+
* `Fetch`, `CacheHandler`, and a default cache policy.
|
|
7320
7217
|
*/
|
|
7321
7218
|
function useRecommendedStore(options, StoreKlass = Store) {
|
|
7322
7219
|
return class AppStore extends StoreKlass {
|
|
@@ -7370,6 +7267,5 @@ function useRecommendedStore(options, StoreKlass = Store) {
|
|
|
7370
7267
|
};
|
|
7371
7268
|
}
|
|
7372
7269
|
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
//# sourceMappingURL=src-Bp8ZJctZ.js.map
|
|
7270
|
+
export { normalizeModelName as A, isRequestKey as C, setIdentifierResetMethod as D, setIdentifierGenerationMethod as E, recordIdentifierFor as F, setRecordIdentifier as I, storeFor as L, ensureStringId as M, StoreMap as N, setIdentifierUpdateMethod as O, _clearCaches as P, assertPrivateCapabilities as R, fieldValueIdentity as S, setIdentifierForgetMethod as T, Store as _, fromIdentity as a, RecordArrayManager as b, instantiateRecord as c, commit as d, log as f, CacheHandler as g, constructResource as h, SchemaService as i, coerceId as j, setKeyInfoForResource as k, teardownRecord as l, createLegacyManyArray as m, RequestManager as n, registerDerivations as o, logGroup as p, Fetch as r, withDefaults as s, useRecommendedStore as t, checkout as u, assertPrivateStore as v, isResourceKey as w, fastPush as x, isPrivateStore as y };
|
|
7271
|
+
//# sourceMappingURL=src-BgQLcshl.js.map
|