@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,15 +1,15 @@
|
|
|
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 { RecordStore, Type } from "./types/symbols.js";
|
|
8
8
|
import { isResourceSchema } from "./types/schema/fields.js";
|
|
9
|
-
import { t as DefaultCachePolicy } from "./store-
|
|
9
|
+
import { t as DefaultCachePolicy } from "./store-Bz9R5hGB.js";
|
|
10
10
|
import { setIsMaybeMirage } from "./types/runtime.js";
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
// src/reactive/-private/document.ts
|
|
13
13
|
function urlFromLink(link) {
|
|
14
14
|
if (typeof link === "string") return link;
|
|
15
15
|
return link.href;
|
|
@@ -19,10 +19,15 @@ function urlFromLink(link) {
|
|
|
19
19
|
* returned by `Cache.put` or `Cache.peek`, converting ResourceKeys into
|
|
20
20
|
* ReactiveResource instances.
|
|
21
21
|
*
|
|
22
|
+
* The [Using The Response](/guides/the-manual/requests/using-the-response) guide
|
|
23
|
+
* shows when a request's content is a ReactiveDocument.
|
|
24
|
+
*
|
|
22
25
|
* It is not directly instantiated by the user, and its properties should not
|
|
23
26
|
* be directly modified. Whether individual properties are mutable or not is
|
|
24
27
|
* determined by the record instance itself.
|
|
25
28
|
*
|
|
29
|
+
* @summary The reactive wrapper around a request's response document that exposes its data or errors
|
|
30
|
+
* as live records, plus meta, links, and pagination helpers.
|
|
26
31
|
* @public
|
|
27
32
|
*/
|
|
28
33
|
const ReactiveDocumentProto = {
|
|
@@ -122,8 +127,7 @@ function createReactiveDocument(store, cacheKey, localCache) {
|
|
|
122
127
|
return doc;
|
|
123
128
|
}
|
|
124
129
|
|
|
125
|
-
|
|
126
|
-
//#region src/store/-private/managers/cache-capabilities-manager.ts
|
|
130
|
+
// src/store/-private/managers/cache-capabilities-manager.ts
|
|
127
131
|
var CacheCapabilitiesManager = class {
|
|
128
132
|
/** @internal */
|
|
129
133
|
/** @internal */
|
|
@@ -216,8 +220,7 @@ var CacheCapabilitiesManager = class {
|
|
|
216
220
|
*/
|
|
217
221
|
function assertPrivateCapabilities(manager) {}
|
|
218
222
|
|
|
219
|
-
|
|
220
|
-
//#region src/store/-private/caches/instance-cache.ts
|
|
223
|
+
// src/store/-private/caches/instance-cache.ts
|
|
221
224
|
const RecordCache = getOrSetGlobal("RecordCache", /* @__PURE__ */ new Map());
|
|
222
225
|
function peekResourceKey(record) {
|
|
223
226
|
return RecordCache.get(record);
|
|
@@ -236,6 +239,7 @@ const identifier = recordIdentifierFor(record);
|
|
|
236
239
|
const { id, type, lid } = identifier;
|
|
237
240
|
```
|
|
238
241
|
|
|
242
|
+
@summary Returns the stable `ResourceKey` (type, id, and lid) the store assigned to a record instance.
|
|
239
243
|
@public
|
|
240
244
|
@param record a record instance previously obstained from the store.
|
|
241
245
|
*/
|
|
@@ -452,8 +456,7 @@ function unloadRecord(instances, identifier) {
|
|
|
452
456
|
instances.store._requestCache._clearEntries(identifier);
|
|
453
457
|
}
|
|
454
458
|
|
|
455
|
-
|
|
456
|
-
//#region src/store/-private/caches/resource-utils.ts
|
|
459
|
+
// src/store/-private/caches/resource-utils.ts
|
|
457
460
|
function isResource(resource) {
|
|
458
461
|
return Boolean(resource && typeof resource === "object");
|
|
459
462
|
}
|
|
@@ -470,8 +473,7 @@ function hasType(resource) {
|
|
|
470
473
|
return hasProp(resource, "type");
|
|
471
474
|
}
|
|
472
475
|
|
|
473
|
-
|
|
474
|
-
//#region src/store/-private/utils/coerce-id.ts
|
|
476
|
+
// src/store/-private/utils/coerce-id.ts
|
|
475
477
|
/**
|
|
476
478
|
* Normalizes a resource `id` entering the store to a string (or `null`).
|
|
477
479
|
*
|
|
@@ -501,8 +503,7 @@ function ensureStringId(id) {
|
|
|
501
503
|
return normalized;
|
|
502
504
|
}
|
|
503
505
|
|
|
504
|
-
|
|
505
|
-
//#region src/store/-private/utils/normalize-model-name.ts
|
|
506
|
+
// src/store/-private/utils/normalize-model-name.ts
|
|
506
507
|
/**
|
|
507
508
|
* Normalizes a resource `type` to its dasherized form, e.g. `myClass` to
|
|
508
509
|
* `my-class`. Re-exported elsewhere as `_deprecatingNormalize`.
|
|
@@ -517,8 +518,7 @@ function normalizeModelName(type) {
|
|
|
517
518
|
return type;
|
|
518
519
|
}
|
|
519
520
|
|
|
520
|
-
|
|
521
|
-
//#region src/store/-private/managers/cache-key-manager.ts
|
|
521
|
+
// src/store/-private/managers/cache-key-manager.ts
|
|
522
522
|
/**
|
|
523
523
|
* Type-guard that returns `true` if the given value is a stable {@link ResourceKey}
|
|
524
524
|
* (as opposed to a {@link RequestKey} or arbitrary, not-yet-stabilized resource data).
|
|
@@ -533,6 +533,43 @@ function isResourceKey(identifier) {
|
|
|
533
533
|
function isRequestKey(identifier) {
|
|
534
534
|
return identifier.type === "@document" && identifier[CACHE_OWNER] !== void 0;
|
|
535
535
|
}
|
|
536
|
+
/**
|
|
537
|
+
* The identity of a field's value, as returned by {@link fieldValueIdentity}.
|
|
538
|
+
* Today only schema-object values (a `schema-object` field, or one element of
|
|
539
|
+
* a `schema-array`) have one: the concrete schema-object type the value
|
|
540
|
+
* resolves to, and the identity hash that type's `ObjectSchema` declares for
|
|
541
|
+
* it, or `null` when the schema declares `identity: null`.
|
|
542
|
+
*/
|
|
543
|
+
/**
|
|
544
|
+
* The identity of `value` as a value of `field`, when the field kind has one.
|
|
545
|
+
*
|
|
546
|
+
* A `schema-object` value, or one element of a `schema-array`, resolves to its
|
|
547
|
+
* concrete schema-object type and the identity hash that type's `ObjectSchema`
|
|
548
|
+
* declares (`null` when the schema declares `identity: null`). A
|
|
549
|
+
* non-polymorphic field names the type directly; a polymorphic field reads it
|
|
550
|
+
* off the value at `options.type` (default `'type'`), or computes it with the
|
|
551
|
+
* hash function named by `field.type` when `options.type` is `'@hash'`.
|
|
552
|
+
*
|
|
553
|
+
* Every other field kind, and any non-object value, has no identity and
|
|
554
|
+
* returns `null`.
|
|
555
|
+
*/
|
|
556
|
+
function fieldValueIdentity(schema, field, value) {
|
|
557
|
+
if (field.kind !== "schema-object" && field.kind !== "schema-array") return null;
|
|
558
|
+
if (!value || typeof value !== "object") return null;
|
|
559
|
+
const rawValue = value;
|
|
560
|
+
let type;
|
|
561
|
+
if (field.options?.polymorphic) {
|
|
562
|
+
const typePath = field.options.type ?? "type";
|
|
563
|
+
if (typePath === "@hash") type = schema.hashFn({ type: field.type })(rawValue, null, null);
|
|
564
|
+
else type = rawValue[typePath];
|
|
565
|
+
} else type = field.type;
|
|
566
|
+
const hashField = schema.resource({ type }).identity;
|
|
567
|
+
const hash = hashField && hashField.kind === "@hash" ? schema.hashFn(hashField)(rawValue, hashField.options ?? null, hashField.name) : null;
|
|
568
|
+
return {
|
|
569
|
+
type,
|
|
570
|
+
hash
|
|
571
|
+
};
|
|
572
|
+
}
|
|
536
573
|
const _crypto = typeof FastBoot !== "undefined" ? FastBoot.require("crypto") : globalThis.crypto;
|
|
537
574
|
function uuidv4() {
|
|
538
575
|
return _crypto.randomUUID();
|
|
@@ -606,6 +643,8 @@ implement this hook.
|
|
|
606
643
|
|
|
607
644
|
⚠️ Caution: Requests that do not have a `method` assigned are assumed to be `GET`
|
|
608
645
|
|
|
646
|
+
@summary Overrides how the store generates `lid` cache keys for resources and documents; must be set
|
|
647
|
+
before the store is created.
|
|
609
648
|
@public
|
|
610
649
|
*/
|
|
611
650
|
function setIdentifierGenerationMethod(method) {
|
|
@@ -640,6 +679,8 @@ prior to this `UpdateMethod` being called; however, calls to the parent method
|
|
|
640
679
|
`updateRecordIdentifier` that attempt to change the `id` or calling update
|
|
641
680
|
without providing an `id` when one is missing will throw an error.
|
|
642
681
|
|
|
682
|
+
@summary Registers a callback run when an existing resource key receives new data, for updating your
|
|
683
|
+
own secondary lookup tables.
|
|
643
684
|
@public
|
|
644
685
|
*/
|
|
645
686
|
function setIdentifierUpdateMethod(method) {
|
|
@@ -657,6 +698,8 @@ import { setIdentifierForgetMethod } from '@warp-drive-mirror/core';
|
|
|
657
698
|
Takes method which can expect to receive an existing `Identifier` that should be eliminated
|
|
658
699
|
from any secondary lookup tables or caches that the user has populated for it.
|
|
659
700
|
|
|
701
|
+
@summary Registers a callback run when the store releases a resource key, for cleaning up your own
|
|
702
|
+
lookup tables.
|
|
660
703
|
@public
|
|
661
704
|
*/
|
|
662
705
|
function setIdentifierForgetMethod(method) {
|
|
@@ -676,6 +719,8 @@ Takes a method which can expect to be called when the parent application is dest
|
|
|
676
719
|
If you have properly used a WeakMap to encapsulate the state of your customization
|
|
677
720
|
to the application instance, you may not need to implement the `resetMethod`.
|
|
678
721
|
|
|
722
|
+
@summary Registers a callback run when the store's key cache is torn down, for resetting any custom
|
|
723
|
+
key-generation state.
|
|
679
724
|
@public
|
|
680
725
|
*/
|
|
681
726
|
function setIdentifierResetMethod(method) {
|
|
@@ -694,6 +739,8 @@ This configuration MUST occur prior to the store instance being created.
|
|
|
694
739
|
import { setKeyInfoForResource } from '@warp-drive-mirror/core';
|
|
695
740
|
```
|
|
696
741
|
|
|
742
|
+
@summary Overrides how the store derives the `type` and `id` of a new `ResourceKey` from resource data;
|
|
743
|
+
must be set before the store is created.
|
|
697
744
|
@public
|
|
698
745
|
*/
|
|
699
746
|
function setKeyInfoForResource(method) {
|
|
@@ -1038,13 +1085,18 @@ function addResourceToCache(cache, identifier) {
|
|
|
1038
1085
|
if (identifier.id) typeSet.id.set(identifier.id, identifier);
|
|
1039
1086
|
}
|
|
1040
1087
|
|
|
1041
|
-
|
|
1042
|
-
//#region src/store/-private/managers/notification-manager.ts
|
|
1088
|
+
// src/store/-private/managers/notification-manager.ts
|
|
1043
1089
|
/**
|
|
1044
1090
|
* The kinds of change notifications the {@link NotificationManager} can emit for a resource.
|
|
1091
|
+
*
|
|
1092
|
+
* @summary The lifecycle notification kinds sent to resource subscribers: `added`, `removed`, `updated`,
|
|
1093
|
+
* or `state`.
|
|
1045
1094
|
*/
|
|
1046
1095
|
/**
|
|
1047
1096
|
* The kinds of change notifications the {@link NotificationManager} can emit for a request document.
|
|
1097
|
+
*
|
|
1098
|
+
* @summary The notification kinds sent to request document subscribers, such as `updated` or
|
|
1099
|
+
* `invalidated`.
|
|
1048
1100
|
*/
|
|
1049
1101
|
function isCacheOperationValue(value) {
|
|
1050
1102
|
return value === "added" || value === "state" || value === "updated" || value === "removed" || value === "invalidated";
|
|
@@ -1052,6 +1104,9 @@ function isCacheOperationValue(value) {
|
|
|
1052
1104
|
/**
|
|
1053
1105
|
* The full set of notification kinds the {@link NotificationManager} can emit for a resource,
|
|
1054
1106
|
* including both {@link CacheOperation}s and finer-grained field-level change notifications.
|
|
1107
|
+
*
|
|
1108
|
+
* @summary Every notification kind a resource subscriber can receive, from lifecycle operations to
|
|
1109
|
+
* `attributes`, `relationships`, `errors`, `meta`, and `identity` changes.
|
|
1055
1110
|
*/
|
|
1056
1111
|
/**
|
|
1057
1112
|
* The shape accepted by {@link NotificationManager.notify} and
|
|
@@ -1059,6 +1114,8 @@ function isCacheOperationValue(value) {
|
|
|
1059
1114
|
* the `'attributes'` or `'relationships'` namespaces in a single call
|
|
1060
1115
|
* instead of once per key.
|
|
1061
1116
|
*
|
|
1117
|
+
* @summary A set of field names passed to `notify` or `notifyChange` to report many `attributes` or
|
|
1118
|
+
* `relationships` changes in one call.
|
|
1062
1119
|
* @since 5.9.0
|
|
1063
1120
|
* @public
|
|
1064
1121
|
*/
|
|
@@ -1093,6 +1150,8 @@ function isCacheOperationValue(value) {
|
|
|
1093
1150
|
* `DocumentCacheOperation` values) are never filtered by channel since they
|
|
1094
1151
|
* have no local/remote duality.
|
|
1095
1152
|
*
|
|
1153
|
+
* @summary Scopes an `attributes` or `relationships` notification to a resource's local (editable) or
|
|
1154
|
+
* remote (persisted) view so only matching subscribers hear it.
|
|
1096
1155
|
* @public
|
|
1097
1156
|
*/
|
|
1098
1157
|
/**
|
|
@@ -1203,6 +1262,8 @@ function _unsubscribe(token, cache) {
|
|
|
1203
1262
|
* This Feature is what allows WarpDrive to create subscriptions that
|
|
1204
1263
|
* work with any framework or change-notification system.
|
|
1205
1264
|
*
|
|
1265
|
+
* @summary The store service that lets code subscribe to and batch-deliver change notifications for
|
|
1266
|
+
* cached resources and request documents.
|
|
1206
1267
|
* @hideconstructor
|
|
1207
1268
|
* @public
|
|
1208
1269
|
*/
|
|
@@ -1389,8 +1450,7 @@ function hasSubscribers(cache, cacheKey, value) {
|
|
|
1389
1450
|
return Boolean(callbackMap?.length);
|
|
1390
1451
|
}
|
|
1391
1452
|
|
|
1392
|
-
|
|
1393
|
-
//#region src/store/-private/record-arrays/-utils.ts
|
|
1453
|
+
// src/store/-private/record-arrays/-utils.ts
|
|
1394
1454
|
/**
|
|
1395
1455
|
* LegacyArrays have the capability of updating via `array.update()`
|
|
1396
1456
|
* and saving each contained record individually via `array.save()`
|
|
@@ -1466,8 +1526,7 @@ function safeForEach$1(instance, arr, store, callback, target) {
|
|
|
1466
1526
|
return instance;
|
|
1467
1527
|
}
|
|
1468
1528
|
|
|
1469
|
-
|
|
1470
|
-
//#region src/reactive/-private/fields/extension.ts
|
|
1529
|
+
// src/reactive/-private/fields/extension.ts
|
|
1471
1530
|
function expectNever(value) {}
|
|
1472
1531
|
function isExtensionProp(extensions, prop) {
|
|
1473
1532
|
return Boolean(extensions && typeof prop !== "number" && extensions.has(prop));
|
|
@@ -1534,8 +1593,7 @@ function performArrayExtensionGet(receiver, extensions, signals, prop, _SIGNAL,
|
|
|
1534
1593
|
}
|
|
1535
1594
|
}
|
|
1536
1595
|
|
|
1537
|
-
|
|
1538
|
-
//#region src/store/-private/record-arrays/native-proxy-type-fix.ts
|
|
1596
|
+
// src/store/-private/record-arrays/native-proxy-type-fix.ts
|
|
1539
1597
|
/**
|
|
1540
1598
|
* The global `Proxy` constructor, retyped with the corrected
|
|
1541
1599
|
* {@link ProxyConstructor} signature above so that `target` and `receiver`
|
|
@@ -1545,8 +1603,7 @@ function performArrayExtensionGet(receiver, extensions, signals, prop, _SIGNAL,
|
|
|
1545
1603
|
*/
|
|
1546
1604
|
const NativeProxy = Proxy;
|
|
1547
1605
|
|
|
1548
|
-
|
|
1549
|
-
//#region src/store/-private/record-arrays/resource-array.ts
|
|
1606
|
+
// src/store/-private/record-arrays/resource-array.ts
|
|
1550
1607
|
const IS_COLLECTION = getOrSetGlobal("IS_COLLECTION", Symbol.for("Collection"));
|
|
1551
1608
|
function isContextProp(prop) {
|
|
1552
1609
|
return prop === "destroy" || prop === "isDestroying" || prop === "isDestroyed";
|
|
@@ -1573,10 +1630,15 @@ const MUTABLE_PROPS = [
|
|
|
1573
1630
|
* as the base for relationship and legacy record-array types such as
|
|
1574
1631
|
* {@link LegacyLiveArray}, {@link LegacyQueryArray} and {@link LegacyManyArray}.
|
|
1575
1632
|
*
|
|
1633
|
+
* The [Key Terminology](/guides/the-manual/caching/key-terms#resources) guide explains
|
|
1634
|
+
* how it relates to resources.
|
|
1635
|
+
*
|
|
1576
1636
|
* Behaves like a native Array: `Array.isArray(arr)` and `arr instanceof Array`
|
|
1577
1637
|
* both report `true`. The array stays in sync with the cache, updating
|
|
1578
1638
|
* reactively as the underlying {@link ResourceKey}s change.
|
|
1579
1639
|
*
|
|
1640
|
+
* @summary Native-Array-compatible reactive list of records backed by cache keys, returned for collection responses
|
|
1641
|
+
* and underlying relationship and legacy record arrays.
|
|
1580
1642
|
* @public
|
|
1581
1643
|
*/
|
|
1582
1644
|
/**
|
|
@@ -1785,8 +1847,7 @@ function createRequestCollection(config) {
|
|
|
1785
1847
|
});
|
|
1786
1848
|
}
|
|
1787
1849
|
|
|
1788
|
-
|
|
1789
|
-
//#region src/store/-private/record-arrays/legacy-live-array.ts
|
|
1850
|
+
// src/store/-private/record-arrays/legacy-live-array.ts
|
|
1790
1851
|
/**
|
|
1791
1852
|
* LiveArrays contain all the known records for a given `ResourceType`.
|
|
1792
1853
|
*
|
|
@@ -1847,6 +1908,8 @@ function createRequestCollection(config) {
|
|
|
1847
1908
|
* and "bmw" will have populated LiveArrays, but the LiveArray for "car"
|
|
1848
1909
|
* would be empty.
|
|
1849
1910
|
*
|
|
1911
|
+
* @summary Legacy reactive array of every record of one type in the store, returned by `store.peekAll` and
|
|
1912
|
+
* `store.findAll`.
|
|
1850
1913
|
* @legacy we recommend againt using LiveArrays. Use {@link Store.request} instead
|
|
1851
1914
|
*/
|
|
1852
1915
|
/**
|
|
@@ -1886,8 +1949,7 @@ function _updateLiveArray() {
|
|
|
1886
1949
|
return this[Context].store.findAll(this.modelName, { reload: true });
|
|
1887
1950
|
}
|
|
1888
1951
|
|
|
1889
|
-
|
|
1890
|
-
//#region src/store/-private/record-arrays/legacy-query.ts
|
|
1952
|
+
// src/store/-private/record-arrays/legacy-query.ts
|
|
1891
1953
|
/**
|
|
1892
1954
|
* QueryArrays contain the primary records returned when querying
|
|
1893
1955
|
* for records by `ResourceType`.
|
|
@@ -1958,6 +2020,8 @@ function _updateLiveArray() {
|
|
|
1958
2020
|
* from the cache, but it does remove the array as well as the overhead it requires
|
|
1959
2021
|
* from the store for book-keeping.
|
|
1960
2022
|
*
|
|
2023
|
+
* @summary Legacy immutable reactive array of the primary records returned by `store.query`, refreshable with
|
|
2024
|
+
* `update()` and released with `destroy()`.
|
|
1961
2025
|
* @legacy we recommend againt using QueryArrays. Use {@link Store.request} instead
|
|
1962
2026
|
*/
|
|
1963
2027
|
/**
|
|
@@ -2014,8 +2078,7 @@ function destroyCollection(clear) {
|
|
|
2014
2078
|
manager._pending.delete(this);
|
|
2015
2079
|
}
|
|
2016
2080
|
|
|
2017
|
-
|
|
2018
|
-
//#region src/store/-private/managers/record-array-manager.ts
|
|
2081
|
+
// src/store/-private/managers/record-array-manager.ts
|
|
2019
2082
|
const FAKE_ARR = getOrSetGlobal("FAKE_ARR", {});
|
|
2020
2083
|
const SLICE_BATCH_SIZE = 4761;
|
|
2021
2084
|
/**
|
|
@@ -2356,6 +2419,7 @@ var RecordArrayManager = class {
|
|
|
2356
2419
|
this._managed.clear();
|
|
2357
2420
|
this._identifiers.clear();
|
|
2358
2421
|
this._pending.clear();
|
|
2422
|
+
this._staged.clear();
|
|
2359
2423
|
for (const set of this._set.values()) set.clear();
|
|
2360
2424
|
this._visibilitySet.clear();
|
|
2361
2425
|
}
|
|
@@ -2428,8 +2492,7 @@ function isLegacyLiveArray(array) {
|
|
|
2428
2492
|
return context.features !== null && context.features.DEPRECATED_CLASS_NAME === "LiveArray";
|
|
2429
2493
|
}
|
|
2430
2494
|
|
|
2431
|
-
|
|
2432
|
-
//#region src/store/-private/network/request-cache.ts
|
|
2495
|
+
// src/store/-private/network/request-cache.ts
|
|
2433
2496
|
const Touching = getOrSetGlobal("Touching", Symbol("touching"));
|
|
2434
2497
|
const RequestPromise = getOrSetGlobal("RequestPromise", Symbol("promise"));
|
|
2435
2498
|
const EMPTY_ARR = [];
|
|
@@ -2637,8 +2700,7 @@ var RequestStateService = class {
|
|
|
2637
2700
|
*
|
|
2638
2701
|
* @private
|
|
2639
2702
|
*/
|
|
2640
|
-
|
|
2641
|
-
//#region src/store/-private/store-service.ts
|
|
2703
|
+
// src/store/-private/store-service.ts
|
|
2642
2704
|
/**
|
|
2643
2705
|
* Currently only records that extend object can be created via
|
|
2644
2706
|
* store.createRecord. This is a limitation of the current API,
|
|
@@ -2668,6 +2730,10 @@ const BaseClass = _BaseClass.default ? _BaseClass.default : _BaseClass;
|
|
|
2668
2730
|
* The `Store` is the central piece of the ***Warp*Drive** experience. It connects
|
|
2669
2731
|
* requests for data with schemas, caching and reactivity.
|
|
2670
2732
|
*
|
|
2733
|
+
* The [Setup](/guides/configuration/#configure-the-store) guide shows how to configure
|
|
2734
|
+
* one, and [Making Requests](/guides/the-manual/requests/) shows how to request data
|
|
2735
|
+
* through it.
|
|
2736
|
+
*
|
|
2671
2737
|
* While it's easy to use ***just*** ***Warp*Drive**'s request management, most projects will find they
|
|
2672
2738
|
* require far more than basic fetch management. For this reason it's often best to start with a `Store`
|
|
2673
2739
|
* even when you aren't sure yet.
|
|
@@ -2675,6 +2741,7 @@ const BaseClass = _BaseClass.default ? _BaseClass.default : _BaseClass;
|
|
|
2675
2741
|
* Most projects will only have a single `Store`, though using multiple distinct stores
|
|
2676
2742
|
* is possible.
|
|
2677
2743
|
*
|
|
2744
|
+
* @summary Central coordinator that connects requests for data with schemas, the cache and reactivity.
|
|
2678
2745
|
* @public
|
|
2679
2746
|
* @hideconstructor
|
|
2680
2747
|
*/
|
|
@@ -2859,12 +2926,25 @@ var Store = class extends BaseClass {
|
|
|
2859
2926
|
/** @internal */
|
|
2860
2927
|
_getAllPending() {}
|
|
2861
2928
|
/**
|
|
2862
|
-
* ::: tip 💡 For a more complete overview see the [Request Guide](/guides/
|
|
2929
|
+
* ::: tip 💡 For a more complete overview see the [Request Guide](/guides/the-manual/requests/)
|
|
2863
2930
|
* :::
|
|
2864
2931
|
*
|
|
2865
2932
|
* Issue a request via the configured {@link RequestManager},
|
|
2866
2933
|
* inserting the response into the {@link Store.cache | cache} and handing
|
|
2867
|
-
* back a {@link Future} which resolves to a {@link ReactiveDocument | ReactiveDocument}
|
|
2934
|
+
* back a {@link Future} which resolves to a {@link ReactiveDocument | ReactiveDocument}.
|
|
2935
|
+
* Use `store.request` for anything the Store's cache should own, which is nearly all app
|
|
2936
|
+
* code; reach for {@link RequestManager.request | requestManager.request} directly only when
|
|
2937
|
+
* there is no `Store` involved, or you specifically want the unprocessed
|
|
2938
|
+
* {@link StructuredDocument}.
|
|
2939
|
+
*
|
|
2940
|
+
* #### Building Requests
|
|
2941
|
+
*
|
|
2942
|
+
* `requestConfig` can be written by hand, but for anything reused more than once prefer a
|
|
2943
|
+
* request builder — a plain function that returns the right shape for `store.request`. This
|
|
2944
|
+
* repo ships builders for common operations (`findRecord`, `query`, `createRecord`, and more)
|
|
2945
|
+
* for {json:api}, REST, and ActiveRecord-style APIs in `@warp-drive-mirror/utilities`; each builder's
|
|
2946
|
+
* return value also carries its own response type, so `RT` below is inferred automatically
|
|
2947
|
+
* instead of being written by hand. See [Builders](/guides/the-manual/requests/builders.md).
|
|
2868
2948
|
*
|
|
2869
2949
|
* #### Request Cache Keys
|
|
2870
2950
|
*
|
|
@@ -2909,6 +2989,29 @@ var Store = class extends BaseClass {
|
|
|
2909
2989
|
* is that `store.request` will convert the response into a {@link ReactiveDocument}
|
|
2910
2990
|
* containing {@link Store.instantiateRecord | ReactiveResources}.
|
|
2911
2991
|
*
|
|
2992
|
+
* A {@link ReactiveDocument} is either a {@link ReactiveDataDocument} (`content.data` holds
|
|
2993
|
+
* the resource(s)) or a {@link ReactiveErrorDocument} (`content.errors` holds the API's error
|
|
2994
|
+
* objects), depending on whether the `Future` resolves or rejects; both carry the response's
|
|
2995
|
+
* `content.meta`. Read either state reactively with {@link getRequestState} or the
|
|
2996
|
+
* `<Request />` component instead of always `await`-ing the `Future` directly — see
|
|
2997
|
+
* [Using the Response](/guides/the-manual/requests/using-the-response.md).
|
|
2998
|
+
*
|
|
2999
|
+
* #### Typing The Response
|
|
3000
|
+
*
|
|
3001
|
+
* `request<RT>` accepts an explicit type argument, but the more common path is to let it be
|
|
3002
|
+
* inferred: build the request with {@link withResponseType} (or {@link withReactiveResponse}
|
|
3003
|
+
* for the common reactive-document case), or with a builder from `@warp-drive-mirror/utilities` as
|
|
3004
|
+
* described above, and `RT` is inferred from the request object itself. See
|
|
3005
|
+
* [Typing Requests](/guides/the-manual/requests/typing-requests.md) for the full mechanism.
|
|
3006
|
+
*
|
|
3007
|
+
* @example
|
|
3008
|
+
* ```ts
|
|
3009
|
+
* import { findRecord } from '@warp-drive-mirror/utilities/json-api';
|
|
3010
|
+
*
|
|
3011
|
+
* const { content } = await store.request(findRecord('user', '1'));
|
|
3012
|
+
* content.data; // ReactiveResource, typed from the builder's response type
|
|
3013
|
+
* ```
|
|
3014
|
+
*
|
|
2912
3015
|
* @public
|
|
2913
3016
|
*/
|
|
2914
3017
|
request(requestConfig) {
|
|
@@ -3360,8 +3463,7 @@ function extractIdentifierFromRecord$1(recordOrPromiseRecord) {
|
|
|
3360
3463
|
return recordIdentifierFor(recordOrPromiseRecord);
|
|
3361
3464
|
}
|
|
3362
3465
|
|
|
3363
|
-
|
|
3364
|
-
//#region src/store/-private/cache-handler/utils.ts
|
|
3466
|
+
// src/store/-private/cache-handler/utils.ts
|
|
3365
3467
|
const MUTATION_OPS$1 = /* @__PURE__ */ new Set([
|
|
3366
3468
|
"createRecord",
|
|
3367
3469
|
"updateRecord",
|
|
@@ -3401,15 +3503,23 @@ function getPriority(identifier, deduped, priority) {
|
|
|
3401
3503
|
return priority;
|
|
3402
3504
|
}
|
|
3403
3505
|
|
|
3404
|
-
|
|
3405
|
-
//#region src/store/-private/cache-handler/handler.ts
|
|
3506
|
+
// src/store/-private/cache-handler/handler.ts
|
|
3406
3507
|
/**
|
|
3407
3508
|
* The request shape accepted by {@link Store.request}, either a fully-formed
|
|
3408
3509
|
* {@link ImmutableRequestInfo} or the looser {@link LooseStoreRequestInfo}.
|
|
3510
|
+
*
|
|
3511
|
+
* Only the looser form accepts `controller`, so a request carrying one, including a builder's
|
|
3512
|
+
* output spread together with a `controller`, resolves to {@link LooseStoreRequestInfo}.
|
|
3513
|
+
*
|
|
3514
|
+
* @summary The request object `store.request` accepts, either a full immutable request info or a looser
|
|
3515
|
+
* form with plain `records` and `headers`.
|
|
3409
3516
|
*/
|
|
3410
3517
|
/**
|
|
3411
3518
|
* A CacheHandler that adds support for using an WarpDrive Cache with a RequestManager.
|
|
3412
3519
|
*
|
|
3520
|
+
* The [Caching](/guides/the-manual/caching/) guide explains how it decides whether a
|
|
3521
|
+
* request can use the cache.
|
|
3522
|
+
*
|
|
3413
3523
|
* This handler will only run when a request has supplied a `store` instance. Requests
|
|
3414
3524
|
* issued by the store via `store.request()` will automatically have the `store` instance
|
|
3415
3525
|
* attached to the request.
|
|
@@ -3445,7 +3555,10 @@ function getPriority(identifier, deduped, priority) {
|
|
|
3445
3555
|
* method: 'GET',
|
|
3446
3556
|
* [EnableHydration]: true
|
|
3447
3557
|
* });
|
|
3558
|
+
* ```
|
|
3448
3559
|
*
|
|
3560
|
+
* @summary The RequestManager cache handler that serves, dedupes, and caches store requests and returns
|
|
3561
|
+
* reactive documents when hydration is enabled.
|
|
3449
3562
|
*/
|
|
3450
3563
|
const CacheHandler = { request(context, next) {
|
|
3451
3564
|
if (!context.request.store || context.request.cacheOptions?.[SkipCache]) return next(context.request);
|
|
@@ -3600,14 +3713,12 @@ function fetchContentAndHydrate(next, context, identifier, priority) {
|
|
|
3600
3713
|
}] });
|
|
3601
3714
|
}
|
|
3602
3715
|
|
|
3603
|
-
|
|
3604
|
-
//#region src/store/-private/utils/is-non-empty-string.ts
|
|
3716
|
+
// src/store/-private/utils/is-non-empty-string.ts
|
|
3605
3717
|
function isNonEmptyString(str) {
|
|
3606
3718
|
return Boolean(str && typeof str === "string");
|
|
3607
3719
|
}
|
|
3608
3720
|
|
|
3609
|
-
|
|
3610
|
-
//#region src/store/-private/utils/construct-resource.ts
|
|
3721
|
+
// src/store/-private/utils/construct-resource.ts
|
|
3611
3722
|
/**
|
|
3612
3723
|
* Given an existing resource identifier object (or a {@link ResourceKey}),
|
|
3613
3724
|
* returns it unchanged aside from coercing its `id`, if present, to a string.
|
|
@@ -3670,8 +3781,7 @@ function constructResource(type, id, lid) {
|
|
|
3670
3781
|
}
|
|
3671
3782
|
}
|
|
3672
3783
|
|
|
3673
|
-
|
|
3674
|
-
//#region src/store/-private/record-arrays/legacy-many-array.ts
|
|
3784
|
+
// src/store/-private/record-arrays/legacy-many-array.ts
|
|
3675
3785
|
/**
|
|
3676
3786
|
A `ManyArray` is a `MutableArray` that represents the contents of a has-many
|
|
3677
3787
|
relationship.
|
|
@@ -3712,6 +3822,7 @@ the has-many.
|
|
|
3712
3822
|
We call the record to which a relationship belongs-to the
|
|
3713
3823
|
relationship's _owner_.
|
|
3714
3824
|
|
|
3825
|
+
@summary Legacy mutable reactive array holding the related records of a legacy or linksMode has-many relationship.
|
|
3715
3826
|
@public
|
|
3716
3827
|
*/
|
|
3717
3828
|
/**
|
|
@@ -3743,7 +3854,7 @@ function createLegacyManyArray(options) {
|
|
|
3743
3854
|
isAsync: options.isAsync,
|
|
3744
3855
|
isPolymorphic: options.isPolymorphic,
|
|
3745
3856
|
identifier: options.identifier,
|
|
3746
|
-
key: options.field.name,
|
|
3857
|
+
key: options.field.sourceKey ?? options.field.name,
|
|
3747
3858
|
reload,
|
|
3748
3859
|
createRecord,
|
|
3749
3860
|
notify
|
|
@@ -3917,8 +4028,7 @@ function mutate(collection, mutation, _SIGNAL) {
|
|
|
3917
4028
|
notifyInternalSignal(_SIGNAL);
|
|
3918
4029
|
}
|
|
3919
4030
|
|
|
3920
|
-
|
|
3921
|
-
//#region src/store/-private/debug/utils.ts
|
|
4031
|
+
// src/store/-private/debug/utils.ts
|
|
3922
4032
|
const TEXT_COLORS = {
|
|
3923
4033
|
TEXT: "inherit",
|
|
3924
4034
|
notify: [
|
|
@@ -4147,15 +4257,13 @@ function _log(scope, prefix, subScop1, subScop2, subScop3, subScop4) {
|
|
|
4147
4257
|
return [];
|
|
4148
4258
|
}
|
|
4149
4259
|
|
|
4150
|
-
|
|
4151
|
-
//#region src/reactive/-private/kind/alias-field.ts
|
|
4260
|
+
// src/reactive/-private/kind/alias-field.ts
|
|
4152
4261
|
function getAliasField(context) {}
|
|
4153
4262
|
function setAliasField(context) {
|
|
4154
4263
|
return false;
|
|
4155
4264
|
}
|
|
4156
4265
|
|
|
4157
|
-
|
|
4158
|
-
//#region src/reactive/-private/fields/managed-array.ts
|
|
4266
|
+
// src/reactive/-private/fields/managed-array.ts
|
|
4159
4267
|
const ARRAY_GETTER_METHODS = /* @__PURE__ */ new Set([
|
|
4160
4268
|
Symbol.iterator,
|
|
4161
4269
|
"concat",
|
|
@@ -4252,17 +4360,7 @@ var ManagedArray = class {
|
|
|
4252
4360
|
if (field.type) return schema.transformation(field).hydrate(rawValue, field.options ?? null, self.owner);
|
|
4253
4361
|
return rawValue;
|
|
4254
4362
|
}
|
|
4255
|
-
|
|
4256
|
-
* When the array is polymorphic, we need to determine the real type
|
|
4257
|
-
* in order to apply the correct identity as schema-object identity
|
|
4258
|
-
* is only required to be unique by type
|
|
4259
|
-
*/
|
|
4260
|
-
let objectType;
|
|
4261
|
-
if (field.options?.polymorphic) {
|
|
4262
|
-
const typePath = field.options.type ?? "type";
|
|
4263
|
-
if (typePath === "@hash") objectType = schema.hashFn({ type: field.type })(rawValue, null, null);
|
|
4264
|
-
else objectType = rawValue[typePath];
|
|
4265
|
-
} else objectType = field.type;
|
|
4363
|
+
const { type: objectType, hash } = fieldValueIdentity(schema, field, rawValue);
|
|
4266
4364
|
/**
|
|
4267
4365
|
* When KeyMode=@hash the ReactiveResource is keyed into
|
|
4268
4366
|
* ManagedRecordRefs by the return value of @hash on the rawValue.
|
|
@@ -4271,10 +4369,8 @@ var ManagedArray = class {
|
|
|
4271
4369
|
* when ARRAY_SIGNAL is dirty if hash performance becomes a bottleneck.
|
|
4272
4370
|
*/
|
|
4273
4371
|
let schemaObjectKeyValue;
|
|
4274
|
-
if (KeyMode === "@hash")
|
|
4275
|
-
|
|
4276
|
-
schemaObjectKeyValue = schema.hashFn(hashField)(rawValue, hashField.options ?? null, hashField.name);
|
|
4277
|
-
} else schemaObjectKeyValue = KeyMode === "@identity" ? rawValue : KeyMode === "@index" ? index : rawValue[KeyMode];
|
|
4372
|
+
if (KeyMode === "@hash") schemaObjectKeyValue = hash;
|
|
4373
|
+
else schemaObjectKeyValue = KeyMode === "@identity" ? rawValue : KeyMode === "@index" ? index : rawValue[KeyMode];
|
|
4278
4374
|
if (!schemaObjectKeyValue && schemaObjectKeyValue !== 0) return;
|
|
4279
4375
|
const recordRef = ManagedRecordRefs.get(schemaObjectKeyValue);
|
|
4280
4376
|
const record = recordRef?.value.deref();
|
|
@@ -4396,8 +4492,7 @@ Object.defineProperty(ManagedArray.prototype, "[]", {
|
|
|
4396
4492
|
get: function() {}
|
|
4397
4493
|
});
|
|
4398
4494
|
|
|
4399
|
-
|
|
4400
|
-
//#region src/reactive/-private/kind/array-field.ts
|
|
4495
|
+
// src/reactive/-private/kind/array-field.ts
|
|
4401
4496
|
function getArrayField(context) {
|
|
4402
4497
|
const signal = entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4403
4498
|
const { record } = context;
|
|
@@ -4440,8 +4535,7 @@ function setArrayField(context) {
|
|
|
4440
4535
|
return true;
|
|
4441
4536
|
}
|
|
4442
4537
|
|
|
4443
|
-
|
|
4444
|
-
//#region src/reactive/-private/kind/attribute-field.ts
|
|
4538
|
+
// src/reactive/-private/kind/attribute-field.ts
|
|
4445
4539
|
function getAttributeField(context) {
|
|
4446
4540
|
entangleInitiallyStaleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4447
4541
|
const { cache } = context.store;
|
|
@@ -4452,8 +4546,7 @@ function setAttributeField(context) {
|
|
|
4452
4546
|
return true;
|
|
4453
4547
|
}
|
|
4454
4548
|
|
|
4455
|
-
|
|
4456
|
-
//#region src/reactive/-private/fields/get-field-key.ts
|
|
4549
|
+
// src/reactive/-private/fields/get-field-key.ts
|
|
4457
4550
|
const InvalidKinds = [
|
|
4458
4551
|
"alias",
|
|
4459
4552
|
"derived",
|
|
@@ -4472,8 +4565,7 @@ function getFieldCacheKey(field) {
|
|
|
4472
4565
|
return "sourceKey" in field && field.sourceKey ? field.sourceKey : field.name;
|
|
4473
4566
|
}
|
|
4474
4567
|
|
|
4475
|
-
|
|
4476
|
-
//#region src/reactive/-private/kind/belongs-to-field.ts
|
|
4568
|
+
// src/reactive/-private/kind/belongs-to-field.ts
|
|
4477
4569
|
function getBelongsToField(context) {
|
|
4478
4570
|
entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4479
4571
|
const { field, resourceKey, store } = context;
|
|
@@ -4510,8 +4602,7 @@ function getResourceKey(record) {
|
|
|
4510
4602
|
return recordIdentifierFor(record);
|
|
4511
4603
|
}
|
|
4512
4604
|
|
|
4513
|
-
|
|
4514
|
-
//#region src/reactive/-private/kind/collection-field.ts
|
|
4605
|
+
// src/reactive/-private/kind/collection-field.ts
|
|
4515
4606
|
function getCollectionField(context) {
|
|
4516
4607
|
entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4517
4608
|
}
|
|
@@ -4519,8 +4610,7 @@ function setCollectionField(context) {
|
|
|
4519
4610
|
return false;
|
|
4520
4611
|
}
|
|
4521
4612
|
|
|
4522
|
-
|
|
4523
|
-
//#region src/reactive/-private/kind/derived-field.ts
|
|
4613
|
+
// src/reactive/-private/kind/derived-field.ts
|
|
4524
4614
|
function getDerivedField(context) {
|
|
4525
4615
|
const { schema } = context.store;
|
|
4526
4616
|
return schema.derivation(context.field)(context.record, context.field.options ?? null, context.field.name);
|
|
@@ -4529,8 +4619,7 @@ function setDerivedField(context) {
|
|
|
4529
4619
|
return false;
|
|
4530
4620
|
}
|
|
4531
4621
|
|
|
4532
|
-
|
|
4533
|
-
//#region src/reactive/-private/kind/generic-field.ts
|
|
4622
|
+
// src/reactive/-private/kind/generic-field.ts
|
|
4534
4623
|
function getGenericField(context) {
|
|
4535
4624
|
const signal = entangleInitiallyStaleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4536
4625
|
signal.isStale = false;
|
|
@@ -4552,8 +4641,7 @@ function setGenericField(context) {
|
|
|
4552
4641
|
return true;
|
|
4553
4642
|
}
|
|
4554
4643
|
|
|
4555
|
-
|
|
4556
|
-
//#region src/reactive/-private/fields/many-array-manager.ts
|
|
4644
|
+
// src/reactive/-private/fields/many-array-manager.ts
|
|
4557
4645
|
var ManyArrayManager = class {
|
|
4558
4646
|
constructor(record, editable) {
|
|
4559
4647
|
const context = record[Context];
|
|
@@ -4609,8 +4697,7 @@ function extractCacheOptions(options) {
|
|
|
4609
4697
|
return cacheOptions;
|
|
4610
4698
|
}
|
|
4611
4699
|
|
|
4612
|
-
|
|
4613
|
-
//#region src/reactive/-private/kind/has-many-field.ts
|
|
4700
|
+
// src/reactive/-private/kind/has-many-field.ts
|
|
4614
4701
|
function getHasManyField(context) {
|
|
4615
4702
|
const signal = entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4616
4703
|
const { store, field } = context;
|
|
@@ -4647,8 +4734,7 @@ function setHasManyField(context) {
|
|
|
4647
4734
|
return true;
|
|
4648
4735
|
}
|
|
4649
4736
|
|
|
4650
|
-
|
|
4651
|
-
//#region src/reactive/-private/kind/hash-field.ts
|
|
4737
|
+
// src/reactive/-private/kind/hash-field.ts
|
|
4652
4738
|
function getHashField(context) {
|
|
4653
4739
|
const { field, path, resourceKey } = context;
|
|
4654
4740
|
const { schema, cache } = context.store;
|
|
@@ -4660,8 +4746,7 @@ function setHashField(context) {
|
|
|
4660
4746
|
return false;
|
|
4661
4747
|
}
|
|
4662
4748
|
|
|
4663
|
-
|
|
4664
|
-
//#region src/reactive/-private/kind/identity-field.ts
|
|
4749
|
+
// src/reactive/-private/kind/identity-field.ts
|
|
4665
4750
|
function getIdentityField(context) {
|
|
4666
4751
|
entangleSignal(context.signals, context.record, "@identity", null);
|
|
4667
4752
|
return context.resourceKey.id;
|
|
@@ -4677,8 +4762,7 @@ function setIdentityField(context) {
|
|
|
4677
4762
|
return true;
|
|
4678
4763
|
}
|
|
4679
4764
|
|
|
4680
|
-
|
|
4681
|
-
//#region src/reactive/-private/kind/local-field.ts
|
|
4765
|
+
// src/reactive/-private/kind/local-field.ts
|
|
4682
4766
|
function getLocalField(context) {
|
|
4683
4767
|
const { field } = context;
|
|
4684
4768
|
const signal = getOrCreateInternalSignal(context.signals, context.record, field.name, field.options?.defaultValue ?? null);
|
|
@@ -4695,8 +4779,7 @@ function setLocalField(context) {
|
|
|
4695
4779
|
return true;
|
|
4696
4780
|
}
|
|
4697
4781
|
|
|
4698
|
-
|
|
4699
|
-
//#region src/reactive/-private/fields/managed-object.ts
|
|
4782
|
+
// src/reactive/-private/fields/managed-object.ts
|
|
4700
4783
|
const ObjectSymbols = /* @__PURE__ */ new Set([
|
|
4701
4784
|
OBJECT_SIGNAL,
|
|
4702
4785
|
Context,
|
|
@@ -4777,8 +4860,7 @@ function peekManagedObject(record, field) {
|
|
|
4777
4860
|
if (managedObjectMapForRecord) return managedObjectMapForRecord.get(field.name);
|
|
4778
4861
|
}
|
|
4779
4862
|
|
|
4780
|
-
|
|
4781
|
-
//#region src/reactive/-private/kind/object-field.ts
|
|
4863
|
+
// src/reactive/-private/kind/object-field.ts
|
|
4782
4864
|
function getObjectField(context) {
|
|
4783
4865
|
entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4784
4866
|
const { record, field } = context;
|
|
@@ -4834,8 +4916,7 @@ function setObjectField(context) {
|
|
|
4834
4916
|
return true;
|
|
4835
4917
|
}
|
|
4836
4918
|
|
|
4837
|
-
|
|
4838
|
-
//#region src/reactive/-private/kind/resource-field.ts
|
|
4919
|
+
// src/reactive/-private/kind/resource-field.ts
|
|
4839
4920
|
var ResourceRelationship = class {
|
|
4840
4921
|
constructor(context) {
|
|
4841
4922
|
const { store, resourceKey } = context;
|
|
@@ -4875,8 +4956,7 @@ function setResourceField(context) {
|
|
|
4875
4956
|
return false;
|
|
4876
4957
|
}
|
|
4877
4958
|
|
|
4878
|
-
|
|
4879
|
-
//#region src/reactive/-private/kind/schema-array-field.ts
|
|
4959
|
+
// src/reactive/-private/kind/schema-array-field.ts
|
|
4880
4960
|
function setSchemaArrayField(context) {
|
|
4881
4961
|
const arrayValue = context.value === null ? null : context.value?.slice();
|
|
4882
4962
|
const fieldSignal = peekInternalSignal(context.signals, context.path.at(-1));
|
|
@@ -4890,8 +4970,7 @@ function setSchemaArrayField(context) {
|
|
|
4890
4970
|
return true;
|
|
4891
4971
|
}
|
|
4892
4972
|
|
|
4893
|
-
|
|
4894
|
-
//#region src/reactive/-private/kind/schema-object-field.ts
|
|
4973
|
+
// src/reactive/-private/kind/schema-object-field.ts
|
|
4895
4974
|
function getSchemaObjectField(context) {
|
|
4896
4975
|
const signal = entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4897
4976
|
const { store, resourceKey, path, field } = context;
|
|
@@ -4908,15 +4987,8 @@ function getSchemaObjectField(context) {
|
|
|
4908
4987
|
}
|
|
4909
4988
|
return null;
|
|
4910
4989
|
}
|
|
4911
|
-
const {
|
|
4912
|
-
|
|
4913
|
-
if (field.options?.polymorphic) {
|
|
4914
|
-
const typePath = field.options.type ?? "type";
|
|
4915
|
-
if (typePath === "@hash") objectType = schema.hashFn({ type: field.type })(rawValue, null, null);
|
|
4916
|
-
else objectType = rawValue[typePath];
|
|
4917
|
-
} else objectType = field.type;
|
|
4918
|
-
const hashField = schema.resource({ type: objectType }).identity;
|
|
4919
|
-
const identity = hashField ? schema.hashFn(hashField)(rawValue, hashField.options ?? null, hashField.name) : field.name;
|
|
4990
|
+
const { type: objectType, hash } = fieldValueIdentity(store.schema, field, rawValue);
|
|
4991
|
+
const identity = hash ?? field.name;
|
|
4920
4992
|
const cachedSchemaObject = signal.value;
|
|
4921
4993
|
if (cachedSchemaObject) {
|
|
4922
4994
|
if (cachedSchemaObject.type === objectType && cachedSchemaObject.identity === identity) return cachedSchemaObject.value;
|
|
@@ -4953,8 +5025,7 @@ function setSchemaObjectField(context) {
|
|
|
4953
5025
|
return true;
|
|
4954
5026
|
}
|
|
4955
5027
|
|
|
4956
|
-
|
|
4957
|
-
//#region src/reactive/-private/default-mode.ts
|
|
5028
|
+
// src/reactive/-private/default-mode.ts
|
|
4958
5029
|
/**
|
|
4959
5030
|
* A ReactiveResource context object passed to
|
|
4960
5031
|
* the get/set functions of a field kind implementation.
|
|
@@ -5070,14 +5141,15 @@ const DefaultMode = {
|
|
|
5070
5141
|
}
|
|
5071
5142
|
};
|
|
5072
5143
|
|
|
5073
|
-
|
|
5074
|
-
//#region src/reactive/-private/record.ts
|
|
5144
|
+
// src/reactive/-private/record.ts
|
|
5075
5145
|
const IgnoredGlobalFields = /* @__PURE__ */ new Set([
|
|
5076
5146
|
"length",
|
|
5077
5147
|
"nodeType",
|
|
5078
5148
|
"then",
|
|
5079
5149
|
"setInterval",
|
|
5080
5150
|
"document",
|
|
5151
|
+
"unknownProperty",
|
|
5152
|
+
"size",
|
|
5081
5153
|
STRUCTURED
|
|
5082
5154
|
]);
|
|
5083
5155
|
const RecordSymbols = /* @__PURE__ */ new Set([
|
|
@@ -5102,10 +5174,14 @@ const Editables = /* @__PURE__ */ new Map();
|
|
|
5102
5174
|
* and a ResourceKey to transform data from the cache into a rich, reactive
|
|
5103
5175
|
* object.
|
|
5104
5176
|
*
|
|
5177
|
+
* The [ResourceSchemas](/guides/the-manual/schemas/resources/) guide shows how to
|
|
5178
|
+
* define the schema it reads.
|
|
5179
|
+
*
|
|
5105
5180
|
* This class is not directly instantiable. To use it, you should
|
|
5106
5181
|
* configure the store's `instantiateRecord` and `teardownRecord` hooks
|
|
5107
5182
|
* with the matching hooks provided by this package.
|
|
5108
5183
|
*
|
|
5184
|
+
* @summary The rich, reactive record object that presents a resource's cached data through its `ResourceSchema`.
|
|
5109
5185
|
* @hideconstructor
|
|
5110
5186
|
* @public
|
|
5111
5187
|
*/
|
|
@@ -5501,6 +5577,8 @@ function assertNeverField(identifier, field, path) {
|
|
|
5501
5577
|
* Edits to editable resources will be automatically committed if a new
|
|
5502
5578
|
* payload from the cache matches their existing value.
|
|
5503
5579
|
*
|
|
5580
|
+
* @summary Resolves with an editable copy of an immutable `ReactiveResource` so its fields can be
|
|
5581
|
+
* changed locally.
|
|
5504
5582
|
* @public
|
|
5505
5583
|
*
|
|
5506
5584
|
* @returns a promise that resolves to the editable resource
|
|
@@ -5517,14 +5595,15 @@ function checkout(resource) {
|
|
|
5517
5595
|
* approach is for either the API or a Handler to reflect saved
|
|
5518
5596
|
* changes back to update the cache.
|
|
5519
5597
|
*
|
|
5598
|
+
* @summary Forcibly makes an editable resource's local changes its new remote (immutable) state,
|
|
5599
|
+
* bypassing a save round-trip.
|
|
5520
5600
|
* @public
|
|
5521
5601
|
*/
|
|
5522
5602
|
function commit(record) {
|
|
5523
5603
|
return record[Commit]();
|
|
5524
5604
|
}
|
|
5525
5605
|
|
|
5526
|
-
|
|
5527
|
-
//#region src/reactive/-private/hooks.ts
|
|
5606
|
+
// src/reactive/-private/hooks.ts
|
|
5528
5607
|
/**
|
|
5529
5608
|
* The store's default `instantiateRecord` hook implementation, which
|
|
5530
5609
|
* produces a {@link ReactiveResource} for `identifier` using the resource
|
|
@@ -5534,6 +5613,8 @@ function commit(record) {
|
|
|
5534
5613
|
* schema is `legacy`, matching the historical behavior of assigning initial
|
|
5535
5614
|
* properties when creating a new legacy record.
|
|
5536
5615
|
*
|
|
5616
|
+
* @summary Default store `instantiateRecord` hook that creates a `ReactiveResource` for a resource key
|
|
5617
|
+
* from its registered schema.
|
|
5537
5618
|
* @public
|
|
5538
5619
|
*/
|
|
5539
5620
|
function instantiateRecord(store, identifier, createArgs) {
|
|
@@ -5557,14 +5638,15 @@ function instantiateRecord(store, identifier, createArgs) {
|
|
|
5557
5638
|
* that `record` is a {@link ReactiveResource} and invokes its `Destroy`
|
|
5558
5639
|
* behavior.
|
|
5559
5640
|
*
|
|
5641
|
+
* @summary Default store `teardownRecord` hook that destroys a `ReactiveResource` when the store
|
|
5642
|
+
* releases it.
|
|
5560
5643
|
* @public
|
|
5561
5644
|
*/
|
|
5562
5645
|
function teardownRecord(record) {
|
|
5563
5646
|
record[Destroy]();
|
|
5564
5647
|
}
|
|
5565
5648
|
|
|
5566
|
-
|
|
5567
|
-
//#region src/reactive/-private/schema.ts
|
|
5649
|
+
// src/reactive/-private/schema.ts
|
|
5568
5650
|
const Support = getOrSetGlobal("Support", /* @__PURE__ */ new WeakMap());
|
|
5569
5651
|
const ConstructorField = {
|
|
5570
5652
|
type: "@constructor",
|
|
@@ -5606,16 +5688,25 @@ _constructor[Type] = "@constructor";
|
|
|
5606
5688
|
* This should only be used for temporary migration purposes
|
|
5607
5689
|
* to the new schema system when migrating from either Model
|
|
5608
5690
|
* or ModelFragments.
|
|
5691
|
+
*
|
|
5692
|
+
* @summary Registers named methods, getters, and values to add to ReactiveResources, ReactiveObjects,
|
|
5693
|
+
* or ReactiveArrays; meant only as a temporary aid when migrating from Model or ModelFragments.
|
|
5609
5694
|
*/
|
|
5610
5695
|
/**
|
|
5611
5696
|
* Describes one feature added to a resource by a schema extension, as
|
|
5612
5697
|
* classified by {@link processExtension} from the property descriptor it
|
|
5613
5698
|
* was declared with (a method, a plain value, or a getter/setter pair).
|
|
5699
|
+
*
|
|
5700
|
+
* @summary One normalized feature of a schema extension, tagged by kind as a method, a readonly or
|
|
5701
|
+
* mutable value, or a getter/setter accessor.
|
|
5614
5702
|
*/
|
|
5615
5703
|
/**
|
|
5616
5704
|
* The result of {@link processExtension} normalizing a
|
|
5617
5705
|
* {@link CAUTION_MEGA_DANGER_ZONE_Extension} into a lookup of its features
|
|
5618
5706
|
* by name.
|
|
5707
|
+
*
|
|
5708
|
+
* @summary A registered schema extension normalized into its kind, name, and a map of its features
|
|
5709
|
+
* keyed by property name.
|
|
5619
5710
|
*/
|
|
5620
5711
|
const BannedKeys = ["constructor", "__proto__"];
|
|
5621
5712
|
function processExtension(extension) {
|
|
@@ -5705,14 +5796,19 @@ function processExtensions(schema, field, scenario, resolvedType) {
|
|
|
5705
5796
|
* Utility for constructing a ResourceSchema with the recommended
|
|
5706
5797
|
* fields for the PolarisMode experience.
|
|
5707
5798
|
*
|
|
5799
|
+
* The [ResourceSchemas](/guides/the-manual/schemas/resources/) guide shows how to
|
|
5800
|
+
* create a schema with it.
|
|
5801
|
+
*
|
|
5708
5802
|
* Using this requires registering the PolarisMode derivations
|
|
5709
5803
|
*
|
|
5710
5804
|
* ```ts
|
|
5711
|
-
* import { registerDerivations } from '@warp-drive-mirror/
|
|
5805
|
+
* import { registerDerivations } from '@warp-drive-mirror/core/reactive';
|
|
5712
5806
|
*
|
|
5713
5807
|
* registerDerivations(schema);
|
|
5714
5808
|
* ```
|
|
5715
5809
|
*
|
|
5810
|
+
* @summary Adds the default `id` identity plus `$key`, `$type`, and `constructor` derived fields to a
|
|
5811
|
+
* PolarisMode resource schema.
|
|
5716
5812
|
* @public
|
|
5717
5813
|
* @param schema
|
|
5718
5814
|
* @return {PolarisResourceSchema}
|
|
@@ -5743,6 +5839,8 @@ function withDefaults(schema) {
|
|
|
5743
5839
|
*
|
|
5744
5840
|
* `^` returns the entire identifier object.
|
|
5745
5841
|
*
|
|
5842
|
+
* @summary The `@identity` derivation, which reads a record's `id`, `lid`, `type`, or whole resource key
|
|
5843
|
+
* for use in derived fields.
|
|
5746
5844
|
* @public
|
|
5747
5845
|
*/
|
|
5748
5846
|
const fromIdentity = (record, options, key) => {
|
|
@@ -5755,9 +5853,14 @@ fromIdentity[Type] = "@identity";
|
|
|
5755
5853
|
* to use the PolarisMode defaults provided by
|
|
5756
5854
|
*
|
|
5757
5855
|
* ```ts
|
|
5758
|
-
* import { withDefaults } from '@warp-drive-mirror/
|
|
5856
|
+
* import { withDefaults } from '@warp-drive-mirror/core/reactive';
|
|
5759
5857
|
* ```
|
|
5760
5858
|
*
|
|
5859
|
+
* The [Derivations](/guides/the-manual/schemas/derivations#about-built-in-derivations)
|
|
5860
|
+
* guide explains when you need to call it.
|
|
5861
|
+
*
|
|
5862
|
+
* @summary Registers the `@identity` and `@constructor` derivations that schemas built with
|
|
5863
|
+
* `withDefaults` depend on.
|
|
5761
5864
|
* @public
|
|
5762
5865
|
*/
|
|
5763
5866
|
function registerDerivations(schema) {
|
|
@@ -5768,6 +5871,9 @@ function registerDerivations(schema) {
|
|
|
5768
5871
|
* Defines how to convert a `GenericField`, `ObjectField`, or `ArrayField`
|
|
5769
5872
|
* between the raw value `T` stored in the cache and the presentation value
|
|
5770
5873
|
* `PT` exposed on the record.
|
|
5874
|
+
*
|
|
5875
|
+
* @summary A registered converter between a field's raw cache value and the value exposed on the
|
|
5876
|
+
* record, with optional default.
|
|
5771
5877
|
*/
|
|
5772
5878
|
/**
|
|
5773
5879
|
* Wraps a derivation in a new function with Derivation signature but that looks
|
|
@@ -5790,6 +5896,12 @@ function makeCachedDerivation(derivation) {
|
|
|
5790
5896
|
/**
|
|
5791
5897
|
* A SchemaService designed to work with dynamically registered schemas.
|
|
5792
5898
|
*
|
|
5899
|
+
* The [Schemas](/guides/the-manual/schemas/) guide shows how to register schemas
|
|
5900
|
+
* with it, and [Advanced Store Configuration](/guides/configuration/advanced#add-a-source-for-schema-for-your-data)
|
|
5901
|
+
* shows how to give a store one.
|
|
5902
|
+
*
|
|
5903
|
+
* @summary The default schema service, which stores resource and object schemas, traits, derivations,
|
|
5904
|
+
* transformations, hash functions and extensions registered at runtime.
|
|
5793
5905
|
* @public
|
|
5794
5906
|
*/
|
|
5795
5907
|
var SchemaService = class {
|
|
@@ -6095,284 +6207,7 @@ function mergeMap(base, toApply) {
|
|
|
6095
6207
|
for (const [key, value] of toApply) base.set(key, value);
|
|
6096
6208
|
}
|
|
6097
6209
|
|
|
6098
|
-
|
|
6099
|
-
//#region src/reactive.ts
|
|
6100
|
-
/**
|
|
6101
|
-
* # About
|
|
6102
|
-
*
|
|
6103
|
-
* This module provides an implementation of reactive objects that a Store may use for creating
|
|
6104
|
-
* reactive representations of the raw data for requests, resources and their relationships
|
|
6105
|
-
* stored in the cache.
|
|
6106
|
-
*
|
|
6107
|
-
* - For configuring the store to use these reactive objects, see [The Setup Guide](/guides/configuration/)
|
|
6108
|
-
* - For defining resource schemas, see [The Schema Guide](/guides/the-manual/schemas/)
|
|
6109
|
-
*
|
|
6110
|
-
* Any method that returns a record instance will use the `instantiateRecord`
|
|
6111
|
-
* hook configured above to instantiate a ReactiveResource once this is in place.
|
|
6112
|
-
* After that, its up to you what ReactiveResource can do.
|
|
6113
|
-
*
|
|
6114
|
-
* ## Modes
|
|
6115
|
-
*
|
|
6116
|
-
* ReactiveResource has two modes: `legacy` and `polaris`.
|
|
6117
|
-
*
|
|
6118
|
-
* **LegacyMode** can be used to emulate the behaviors and capabilities of WarpDrive's `Model` class,
|
|
6119
|
-
* and because there is little distinction between Model and a ReactiveResource in LegacyMode we refer
|
|
6120
|
-
* to both of these approaches as LegacyMode. This mode is the default experience in V5.
|
|
6121
|
-
*
|
|
6122
|
-
* In LegacyMode:
|
|
6123
|
-
*
|
|
6124
|
-
* - records are mutable
|
|
6125
|
-
* - local changes immediately reflect app wide
|
|
6126
|
-
* - records have all the APIs of Model (references, state props, currentState, methods etc)
|
|
6127
|
-
* - the continued use of `@warp-drive-mirror/legacy` is required (though most imports from it can be removed)
|
|
6128
|
-
* - `async: true` relationships are supported (but not recommended outside of [LinksMode](/guides/the-manual/misc/links-mode.md))
|
|
6129
|
-
*
|
|
6130
|
-
* ---
|
|
6131
|
-
*
|
|
6132
|
-
* **PolarisMode** is an upcoming suite of features that will become the default experience in V6.
|
|
6133
|
-
*
|
|
6134
|
-
* In PolarisMode:
|
|
6135
|
-
*
|
|
6136
|
-
* - records are immutable, unless creating a new resource or explicitly checking out a record for editing
|
|
6137
|
-
* - local changes are isolated until committed, displaying only via the editable version of the record
|
|
6138
|
-
* - records have a more limited API, focused on only what is in their schema.
|
|
6139
|
-
* - some common operations may have more friction to perform because intended utilities are not yet available
|
|
6140
|
-
* - `async: true` relationships are not supported (see [LinksMode](/guides/the-manual/misc/links-mode.md))
|
|
6141
|
-
* - The `@warp-drive-mirror/legacy` package is not required
|
|
6142
|
-
*
|
|
6143
|
-
* These modes are interopable. The reactive object (record) for a resource in PolarisMode can relate to
|
|
6144
|
-
* a record in LegacyMode and vice-versa. This interopability is true whether the record in LegacyMode is
|
|
6145
|
-
* a ReactiveResource or a Model.
|
|
6146
|
-
*
|
|
6147
|
-
* ---
|
|
6148
|
-
*
|
|
6149
|
-
* ## Basic Usage
|
|
6150
|
-
*
|
|
6151
|
-
* ReactiveResource is a reactive object that transforms raw data from an associated
|
|
6152
|
-
* cache into reactive data backed by Signals.
|
|
6153
|
-
*
|
|
6154
|
-
* The shape of the object and the transformation of raw cache data into its
|
|
6155
|
-
* reactive form is controlled by a resource schema.
|
|
6156
|
-
*
|
|
6157
|
-
* For instance, lets say your API is a [{json:api}](https://jsonapi.org) and your store is using
|
|
6158
|
-
* the Cache provided by {@link @warp-drive-mirror/json-api! | @warp-drive-mirror/json-api}, and a request
|
|
6159
|
-
* returns the following raw data:
|
|
6160
|
-
*
|
|
6161
|
-
* ```ts
|
|
6162
|
-
* {
|
|
6163
|
-
* data: {
|
|
6164
|
-
* type: 'user',
|
|
6165
|
-
* id: '1',
|
|
6166
|
-
* attributes: { firstName: 'Chris', lastName: 'Thoburn' },
|
|
6167
|
-
* relationships: { pets: { data: [{ type: 'dog', id: '1' }] }}
|
|
6168
|
-
* },
|
|
6169
|
-
* included: [
|
|
6170
|
-
* {
|
|
6171
|
-
* type: 'dog',
|
|
6172
|
-
* id: '1',
|
|
6173
|
-
* attributes: { name: 'Rey' },
|
|
6174
|
-
* relationships: { owner: { data: { type: 'user', id: '1' }}}
|
|
6175
|
-
* }
|
|
6176
|
-
* ]
|
|
6177
|
-
* }
|
|
6178
|
-
* ```
|
|
6179
|
-
*
|
|
6180
|
-
* We could describe the `'user'` and `'dog'` resources in the above payload
|
|
6181
|
-
* with the following schemas:
|
|
6182
|
-
*
|
|
6183
|
-
* ```ts
|
|
6184
|
-
* store.schema.registerResources([
|
|
6185
|
-
* {
|
|
6186
|
-
* type: 'user',
|
|
6187
|
-
* identity: { type: '@id', name: 'id' },
|
|
6188
|
-
* fields: [
|
|
6189
|
-
* {
|
|
6190
|
-
* type: '@identity',
|
|
6191
|
-
* name: '$type',
|
|
6192
|
-
* kind: 'derived',
|
|
6193
|
-
* options: { key: 'type' },
|
|
6194
|
-
* },
|
|
6195
|
-
* { kind: 'field', name: 'firstName' },
|
|
6196
|
-
* { kind: 'field', name: 'lastName' },
|
|
6197
|
-
* {
|
|
6198
|
-
* kind: 'derived',
|
|
6199
|
-
* name: 'name',
|
|
6200
|
-
* type: 'concat',
|
|
6201
|
-
* options: { fields: ['firstName', 'lastName'], separator: ' ' }
|
|
6202
|
-
* },
|
|
6203
|
-
* {
|
|
6204
|
-
* kind: 'hasMany',
|
|
6205
|
-
* name: 'pets',
|
|
6206
|
-
* type: 'pet',
|
|
6207
|
-
* options: {
|
|
6208
|
-
* async: false,
|
|
6209
|
-
* inverse: 'owner',
|
|
6210
|
-
* polymorphic: true,
|
|
6211
|
-
* linksMode: true,
|
|
6212
|
-
* }
|
|
6213
|
-
* }
|
|
6214
|
-
* ]
|
|
6215
|
-
* },
|
|
6216
|
-
* {
|
|
6217
|
-
* type: 'dog',
|
|
6218
|
-
* identity: { type: '@id', name: 'id' },
|
|
6219
|
-
* fields: [
|
|
6220
|
-
* {
|
|
6221
|
-
* type: '@identity',
|
|
6222
|
-
* name: '$type',
|
|
6223
|
-
* kind: 'derived',
|
|
6224
|
-
* options: { key: 'type' },
|
|
6225
|
-
* },
|
|
6226
|
-
* { kind: 'field', name: 'name' },
|
|
6227
|
-
* {
|
|
6228
|
-
* kind: 'belongsTo',
|
|
6229
|
-
* name: 'owner',
|
|
6230
|
-
* type: 'user',
|
|
6231
|
-
* options: {
|
|
6232
|
-
* async: false,
|
|
6233
|
-
* inverse: 'pets',
|
|
6234
|
-
* as: 'pet',
|
|
6235
|
-
* linksMode: true,
|
|
6236
|
-
* }
|
|
6237
|
-
* }
|
|
6238
|
-
* ]
|
|
6239
|
-
* }
|
|
6240
|
-
* ]);
|
|
6241
|
-
* ```
|
|
6242
|
-
*
|
|
6243
|
-
* With these schemas in place, the reactive objects that the store would
|
|
6244
|
-
* provide us whenever we encountered a `'user'` or a `'dog'` would be:
|
|
6245
|
-
*
|
|
6246
|
-
* ```ts
|
|
6247
|
-
* interface Pet {
|
|
6248
|
-
* readonly id: string;
|
|
6249
|
-
* readonly owner: User;
|
|
6250
|
-
* }
|
|
6251
|
-
*
|
|
6252
|
-
* interface Dog extends Pet {
|
|
6253
|
-
* readonly $type: 'dog';
|
|
6254
|
-
* readonly name: string;
|
|
6255
|
-
* }
|
|
6256
|
-
*
|
|
6257
|
-
* interface EditableUser {
|
|
6258
|
-
* readonly $type: 'user';
|
|
6259
|
-
* readonly id: string;
|
|
6260
|
-
* firstName: string;
|
|
6261
|
-
* lastName: string;
|
|
6262
|
-
* readonly name: string;
|
|
6263
|
-
* pets: Array<Dog | Pet>;
|
|
6264
|
-
* }
|
|
6265
|
-
*
|
|
6266
|
-
* interface User {
|
|
6267
|
-
* readonly $type: 'user';
|
|
6268
|
-
* readonly id: string;
|
|
6269
|
-
* readonly firstName: string;
|
|
6270
|
-
* readonly lastName: string;
|
|
6271
|
-
* readonly name: string;
|
|
6272
|
-
* readonly pets: Readonly<Array<Dog | Pet>>;
|
|
6273
|
-
* [Checkout](): Promise<EditableUser>
|
|
6274
|
-
* }>
|
|
6275
|
-
* ```
|
|
6276
|
-
*
|
|
6277
|
-
* Note how based on the schema the reactive object we receive is able to produce
|
|
6278
|
-
* `name` on user (despite no name field being in the cache), provide `$type`
|
|
6279
|
-
* pulled from the identity of the resource, and flatten the individual attributes
|
|
6280
|
-
* and relationships onto the record for easier use.
|
|
6281
|
-
*
|
|
6282
|
-
* Notice also how we typed this object with `readonly`. This is because while
|
|
6283
|
-
* ReactiveResource instances are ***deeply reactive***, they are also ***immutable***.
|
|
6284
|
-
*
|
|
6285
|
-
* We can mutate a ReactiveResource only be explicitly asking permission to do so, and
|
|
6286
|
-
* in the process gaining access to an editable copy. The immutable version will
|
|
6287
|
-
* not show any in-process edits made to this editable copy.
|
|
6288
|
-
*
|
|
6289
|
-
* ```ts
|
|
6290
|
-
* import { Checkout } from '@warp-drive-mirror/schema-record';
|
|
6291
|
-
*
|
|
6292
|
-
* const editable = await user[Checkout]();
|
|
6293
|
-
* ```
|
|
6294
|
-
*
|
|
6295
|
-
* ## Utilities
|
|
6296
|
-
*
|
|
6297
|
-
* ReactiveResource provides a schema builder that simplifies setting up a couple of
|
|
6298
|
-
* conventional fields like identity and `$type`. We can rewrite the schema
|
|
6299
|
-
* definition above using this utility like so:
|
|
6300
|
-
*
|
|
6301
|
-
* ```ts
|
|
6302
|
-
* import { withDefaults } from '@warp-drive-mirror/core/reactive';
|
|
6303
|
-
*
|
|
6304
|
-
* store.schema.registerResources([
|
|
6305
|
-
* withDefaults({
|
|
6306
|
-
* type: 'user',
|
|
6307
|
-
* fields: [
|
|
6308
|
-
* { kind: 'field', name: 'firstName' },
|
|
6309
|
-
* { kind: 'field', name: 'lastName' },
|
|
6310
|
-
* {
|
|
6311
|
-
* kind: 'derived',
|
|
6312
|
-
* name: 'name',
|
|
6313
|
-
* type: 'concat',
|
|
6314
|
-
* options: { fields: ['firstName', 'lastName'], separator: ' ' }
|
|
6315
|
-
* },
|
|
6316
|
-
* {
|
|
6317
|
-
* kind: 'hasMany',
|
|
6318
|
-
* name: 'pets',
|
|
6319
|
-
* type: 'pet',
|
|
6320
|
-
* options: {
|
|
6321
|
-
* async: false,
|
|
6322
|
-
* inverse: 'owner',
|
|
6323
|
-
* polymorphic: true,
|
|
6324
|
-
* linksMode: true,
|
|
6325
|
-
* resetOnRemoteUpdate: false,
|
|
6326
|
-
* }
|
|
6327
|
-
* }
|
|
6328
|
-
* ]
|
|
6329
|
-
* }),
|
|
6330
|
-
* withDefaults({
|
|
6331
|
-
* type: 'dog',
|
|
6332
|
-
* fields: [
|
|
6333
|
-
* { kind: 'field', name: 'name' },
|
|
6334
|
-
* {
|
|
6335
|
-
* kind: 'belongsTo',
|
|
6336
|
-
* name: 'owner',
|
|
6337
|
-
* type: 'user',
|
|
6338
|
-
* options: {
|
|
6339
|
-
* async: false,
|
|
6340
|
-
* inverse: 'pets',
|
|
6341
|
-
* as: 'pet',
|
|
6342
|
-
* linksMode: true,
|
|
6343
|
-
* resetOnRemoteUpdate: false,
|
|
6344
|
-
* }
|
|
6345
|
-
* }
|
|
6346
|
-
* ]
|
|
6347
|
-
* })
|
|
6348
|
-
* ]);
|
|
6349
|
-
* ```
|
|
6350
|
-
*
|
|
6351
|
-
* ## Type Support
|
|
6352
|
-
*
|
|
6353
|
-
* ### Resource Schemas
|
|
6354
|
-
*
|
|
6355
|
-
* - {@link PolarisResourceSchema}
|
|
6356
|
-
* - {@link LegacyResourceSchema}
|
|
6357
|
-
* - {@link ObjectSchema}
|
|
6358
|
-
*
|
|
6359
|
-
* ### Resource Schema Type Utils
|
|
6360
|
-
*
|
|
6361
|
-
* - {@link resourceSchema}
|
|
6362
|
-
* - {@link objectSchema}
|
|
6363
|
-
* - {@link isResourceSchema}
|
|
6364
|
-
* - {@link isLegacyResourceSchema}
|
|
6365
|
-
*
|
|
6366
|
-
* ### Field Schemas
|
|
6367
|
-
*
|
|
6368
|
-
* - {@link LegacyModeFieldSchema}
|
|
6369
|
-
* - {@link PolarisModeFieldSchema}
|
|
6370
|
-
*
|
|
6371
|
-
* @module
|
|
6372
|
-
*/
|
|
6373
|
-
|
|
6374
|
-
//#endregion
|
|
6375
|
-
//#region src/request/-private/fetch.ts
|
|
6210
|
+
// src/request/-private/fetch.ts
|
|
6376
6211
|
const _fetch = typeof fetch !== "undefined" ? (...args) => fetch(...args) : typeof FastBoot !== "undefined" ? (...args) => FastBoot.require("node-fetch")(...args) : () => {
|
|
6377
6212
|
throw new Error("No Fetch Implementation Found");
|
|
6378
6213
|
};
|
|
@@ -6445,6 +6280,9 @@ const ERROR_STATUS_CODE_FOR = /* @__PURE__ */ new Map([
|
|
|
6445
6280
|
* A basic Fetch Handler which converts a request into a
|
|
6446
6281
|
* `fetch` call presuming the response to be `json`.
|
|
6447
6282
|
*
|
|
6283
|
+
* The [Making Requests](/guides/the-manual/requests/#requests-do-not-need-to-use-fetch)
|
|
6284
|
+
* guide shows where it sits in the handler chain.
|
|
6285
|
+
*
|
|
6448
6286
|
* ```ts
|
|
6449
6287
|
* import { RequestManager, Fetch } from '@warp-drive-mirror/core';
|
|
6450
6288
|
*
|
|
@@ -6452,6 +6290,8 @@ const ERROR_STATUS_CODE_FOR = /* @__PURE__ */ new Map([
|
|
|
6452
6290
|
* .use([Fetch]);
|
|
6453
6291
|
* ```
|
|
6454
6292
|
*
|
|
6293
|
+
* @summary Terminal request handler that sends the request with native `fetch` and resolves with the
|
|
6294
|
+
* parsed JSON body, turning HTTP failures into errors.
|
|
6455
6295
|
* @public
|
|
6456
6296
|
* @badge Handler
|
|
6457
6297
|
*/
|
|
@@ -6569,8 +6409,7 @@ function isDict(v) {
|
|
|
6569
6409
|
return v !== null && typeof v === "object";
|
|
6570
6410
|
}
|
|
6571
6411
|
|
|
6572
|
-
|
|
6573
|
-
//#region src/request/-private/manager.ts
|
|
6412
|
+
// src/request/-private/manager.ts
|
|
6574
6413
|
/**
|
|
6575
6414
|
* ## Import
|
|
6576
6415
|
*
|
|
@@ -6578,7 +6417,8 @@ function isDict(v) {
|
|
|
6578
6417
|
* import { RequestManager } from '@warp-drive-mirror/core';
|
|
6579
6418
|
* ```
|
|
6580
6419
|
*
|
|
6581
|
-
* For complete usage guide see
|
|
6420
|
+
* For a complete usage guide see [Making Requests](/guides/the-manual/requests/), and
|
|
6421
|
+
* [Handlers](/guides/the-manual/requests/handlers) for writing the handlers it runs.
|
|
6582
6422
|
*
|
|
6583
6423
|
* ## How It Works
|
|
6584
6424
|
*
|
|
@@ -6601,11 +6441,28 @@ function isDict(v) {
|
|
|
6601
6441
|
* ```ts [Setup.ts]
|
|
6602
6442
|
* import { RequestManager, Fetch } from '@warp-drive-mirror/core';
|
|
6603
6443
|
* import { AutoCompress } from '@warp-drive-mirror/utilities/handlers';
|
|
6604
|
-
* import
|
|
6444
|
+
* import { AuthHandler } from './auth-handler';
|
|
6605
6445
|
*
|
|
6606
6446
|
* // ... create manager
|
|
6607
6447
|
* const manager = new RequestManager()
|
|
6608
|
-
* .use([
|
|
6448
|
+
* .use([AuthHandler, new AutoCompress(), Fetch]); // [!code focus]
|
|
6449
|
+
* ```
|
|
6450
|
+
*
|
|
6451
|
+
* ```ts [auth-handler.ts]
|
|
6452
|
+
* import type { Handler, NextFn } from '@warp-drive-mirror/core/request';
|
|
6453
|
+
* import type { RequestContext } from '@warp-drive-mirror/core/types/request';
|
|
6454
|
+
*
|
|
6455
|
+
* const token = '<token>';
|
|
6456
|
+
*
|
|
6457
|
+
* // adds a bearer token to every request, then passes it along
|
|
6458
|
+
* export const AuthHandler: Handler = {
|
|
6459
|
+
* request<T>(context: RequestContext, next: NextFn<T>) {
|
|
6460
|
+
* const headers = new Headers(context.request.headers);
|
|
6461
|
+
* headers.append('Authorization', `Bearer ${token}`);
|
|
6462
|
+
*
|
|
6463
|
+
* return next(Object.assign({}, context.request, { headers }));
|
|
6464
|
+
* },
|
|
6465
|
+
* };
|
|
6609
6466
|
* ```
|
|
6610
6467
|
*
|
|
6611
6468
|
* ```ts [Usage.ts]
|
|
@@ -6621,6 +6478,20 @@ function isDict(v) {
|
|
|
6621
6478
|
*
|
|
6622
6479
|
* :::
|
|
6623
6480
|
*
|
|
6481
|
+
* ### RequestManager vs {@link Store.request}
|
|
6482
|
+
*
|
|
6483
|
+
* A bare `RequestManager` is the low-level primitive: it runs a request through the configured
|
|
6484
|
+
* {@link Handler | handler chain} and settles with the raw {@link StructuredDocument}. It has no
|
|
6485
|
+
* cache and does not hydrate {@link ReactiveDocument | ReactiveDocuments} unless you register a
|
|
6486
|
+
* cache handler yourself via {@link RequestManager.useCache} and the request opts in.
|
|
6487
|
+
*
|
|
6488
|
+
* {@link Store.request} issues requests through this same `RequestManager`, but with the Store's
|
|
6489
|
+
* cache handler and hydration already wired up — inserting the response into the Store's cache
|
|
6490
|
+
* and resolving with a `ReactiveDocument` instead. Use `store.request` for anything the Store's
|
|
6491
|
+
* cache should own, which is nearly all app code. Reach for `requestManager.request` directly
|
|
6492
|
+
* only when there is no {@link Store} involved, or you specifically want the unprocessed
|
|
6493
|
+
* `StructuredDocument`.
|
|
6494
|
+
*
|
|
6624
6495
|
* ### Futures
|
|
6625
6496
|
*
|
|
6626
6497
|
* The return value of `manager.request` is a `Future`, which allows
|
|
@@ -6659,6 +6530,7 @@ function isDict(v) {
|
|
|
6659
6530
|
* type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument;
|
|
6660
6531
|
* ```
|
|
6661
6532
|
*
|
|
6533
|
+
* @summary Runs each request through a chain of handlers that can fulfill, modify, or pass it along, and returns a `Future` for the response.
|
|
6662
6534
|
* @public
|
|
6663
6535
|
*/
|
|
6664
6536
|
var RequestManager = class {
|
|
@@ -6709,7 +6581,23 @@ var RequestManager = class {
|
|
|
6709
6581
|
/**
|
|
6710
6582
|
* Issue a Request.
|
|
6711
6583
|
*
|
|
6712
|
-
*
|
|
6584
|
+
* Runs `request` through the configured {@link Handler | handler chain} and settles with the
|
|
6585
|
+
* {@link StructuredDocument} the chain produces — a plain `{ request, response, content }`
|
|
6586
|
+
* object, not a {@link ReactiveDocument}. Caching and hydration only happen if a cache handler
|
|
6587
|
+
* has been registered via {@link RequestManager.useCache} and the request opts in; a
|
|
6588
|
+
* `RequestManager` created on its own has neither.
|
|
6589
|
+
*
|
|
6590
|
+
* Most app code should use {@link Store.request} instead, which calls this same method with
|
|
6591
|
+
* the Store's cache handler and hydration already configured. Reach for `requestManager.request`
|
|
6592
|
+
* directly when there is no {@link Store} involved, or when you want the unprocessed
|
|
6593
|
+
* `StructuredDocument`. The `<RT>` generic can be set explicitly or inferred from a request
|
|
6594
|
+
* built with {@link withResponseType} or {@link withReactiveResponse} — see
|
|
6595
|
+
* [Typing Requests](/guides/the-manual/requests/typing-requests.md).
|
|
6596
|
+
*
|
|
6597
|
+
* @example
|
|
6598
|
+
* ```ts
|
|
6599
|
+
* const { content } = await requestManager.request({ url: '/users' });
|
|
6600
|
+
* ```
|
|
6713
6601
|
*
|
|
6714
6602
|
* @public
|
|
6715
6603
|
*/
|
|
@@ -6768,20 +6656,27 @@ var RequestManager = class {
|
|
|
6768
6656
|
*
|
|
6769
6657
|
* @private
|
|
6770
6658
|
*/
|
|
6771
|
-
|
|
6772
|
-
//#region src/index.ts
|
|
6659
|
+
// src/index.ts
|
|
6773
6660
|
/**
|
|
6661
|
+
* @summary Main entry point for WarpDrive: the `Store`, `RequestManager`, `Fetch` handler, `CacheHandler`, and
|
|
6662
|
+
* `useRecommendedStore` for building a configured store.
|
|
6774
6663
|
* @module
|
|
6775
6664
|
* @mergeModuleWith <project>
|
|
6776
6665
|
*/
|
|
6777
6666
|
globalThis.setWarpDriveIsMaybeMirage = setIsMaybeMirage;
|
|
6778
6667
|
/**
|
|
6779
6668
|
* Options for setting up a Store instance with `useRecommendedStore`.
|
|
6669
|
+
*
|
|
6670
|
+
* @summary Configures the cache, cache policy, request handlers, schemas, and schema extensions that
|
|
6671
|
+
* `useRecommendedStore` wires into a Store class.
|
|
6780
6672
|
*/
|
|
6781
6673
|
/**
|
|
6782
6674
|
* Creates a configured Store class with recommended defaults
|
|
6783
6675
|
* for schema handling, reactivity, caching, and request management.
|
|
6784
6676
|
*
|
|
6677
|
+
* The [Setup](/guides/configuration/#configure-the-store) guide walks through
|
|
6678
|
+
* configuring the store with it.
|
|
6679
|
+
*
|
|
6785
6680
|
* ```ts
|
|
6786
6681
|
* import { useRecommendedStore } from '@warp-drive-mirror/core';
|
|
6787
6682
|
* import { JSONAPICache } from '@warp-drive-mirror/json-api';
|
|
@@ -6884,6 +6779,9 @@ globalThis.setWarpDriveIsMaybeMirage = setIsMaybeMirage;
|
|
|
6884
6779
|
* {@link RequestManager} won't have it set unless the caller supplies it
|
|
6885
6780
|
* explicitly, so a handler relying on it should treat it as optional (as
|
|
6886
6781
|
* `LoggingHandler` does above).
|
|
6782
|
+
*
|
|
6783
|
+
* @summary Builds a Store subclass preconfigured with the given cache, schemas, and handlers, plus
|
|
6784
|
+
* `Fetch`, `CacheHandler`, and a default cache policy.
|
|
6887
6785
|
*/
|
|
6888
6786
|
function useRecommendedStore(options, StoreKlass = Store) {
|
|
6889
6787
|
return class AppStore extends StoreKlass {
|
|
@@ -6937,6 +6835,5 @@ function useRecommendedStore(options, StoreKlass = Store) {
|
|
|
6937
6835
|
};
|
|
6938
6836
|
}
|
|
6939
6837
|
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
//# sourceMappingURL=src-B-GfFQcx.js.map
|
|
6838
|
+
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 };
|
|
6839
|
+
//# sourceMappingURL=src-DFmPDGQ6.js.map
|