@warp-drive-mirror/core 5.10.0-alpha.2 → 5.10.0-alpha.20
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-BE5B0ZXl.d.ts} +1526 -1133
- package/dist/internal-BE5B0ZXl.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-BTF6QRQ3.js} +346 -456
- package/dist/src-BTF6QRQ3.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-Dt1O1Pw1.js} +335 -444
- package/dist/unpkg/dev/src-Dt1O1Pw1.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-B5QlMjHe.js} +340 -450
- package/dist/unpkg/dev-deprecated/src-B5QlMjHe.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-evv7LXnE.js} +307 -414
- package/dist/unpkg/prod/src-evv7LXnE.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-D6BqG5K8.js} +312 -420
- package/dist/unpkg/prod-deprecated/src-D6BqG5K8.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
|
/**
|
|
@@ -2428,8 +2491,7 @@ function isLegacyLiveArray(array) {
|
|
|
2428
2491
|
return context.features !== null && context.features.DEPRECATED_CLASS_NAME === "LiveArray";
|
|
2429
2492
|
}
|
|
2430
2493
|
|
|
2431
|
-
|
|
2432
|
-
//#region src/store/-private/network/request-cache.ts
|
|
2494
|
+
// src/store/-private/network/request-cache.ts
|
|
2433
2495
|
const Touching = getOrSetGlobal("Touching", Symbol("touching"));
|
|
2434
2496
|
const RequestPromise = getOrSetGlobal("RequestPromise", Symbol("promise"));
|
|
2435
2497
|
const EMPTY_ARR = [];
|
|
@@ -2637,8 +2699,7 @@ var RequestStateService = class {
|
|
|
2637
2699
|
*
|
|
2638
2700
|
* @private
|
|
2639
2701
|
*/
|
|
2640
|
-
|
|
2641
|
-
//#region src/store/-private/store-service.ts
|
|
2702
|
+
// src/store/-private/store-service.ts
|
|
2642
2703
|
/**
|
|
2643
2704
|
* Currently only records that extend object can be created via
|
|
2644
2705
|
* store.createRecord. This is a limitation of the current API,
|
|
@@ -2668,6 +2729,10 @@ const BaseClass = _BaseClass.default ? _BaseClass.default : _BaseClass;
|
|
|
2668
2729
|
* The `Store` is the central piece of the ***Warp*Drive** experience. It connects
|
|
2669
2730
|
* requests for data with schemas, caching and reactivity.
|
|
2670
2731
|
*
|
|
2732
|
+
* The [Setup](/guides/configuration/#configure-the-store) guide shows how to configure
|
|
2733
|
+
* one, and [Making Requests](/guides/the-manual/requests/) shows how to request data
|
|
2734
|
+
* through it.
|
|
2735
|
+
*
|
|
2671
2736
|
* While it's easy to use ***just*** ***Warp*Drive**'s request management, most projects will find they
|
|
2672
2737
|
* require far more than basic fetch management. For this reason it's often best to start with a `Store`
|
|
2673
2738
|
* even when you aren't sure yet.
|
|
@@ -2675,6 +2740,7 @@ const BaseClass = _BaseClass.default ? _BaseClass.default : _BaseClass;
|
|
|
2675
2740
|
* Most projects will only have a single `Store`, though using multiple distinct stores
|
|
2676
2741
|
* is possible.
|
|
2677
2742
|
*
|
|
2743
|
+
* @summary Central coordinator that connects requests for data with schemas, the cache and reactivity.
|
|
2678
2744
|
* @public
|
|
2679
2745
|
* @hideconstructor
|
|
2680
2746
|
*/
|
|
@@ -2859,12 +2925,25 @@ var Store = class extends BaseClass {
|
|
|
2859
2925
|
/** @internal */
|
|
2860
2926
|
_getAllPending() {}
|
|
2861
2927
|
/**
|
|
2862
|
-
* ::: tip 💡 For a more complete overview see the [Request Guide](/guides/
|
|
2928
|
+
* ::: tip 💡 For a more complete overview see the [Request Guide](/guides/the-manual/requests/)
|
|
2863
2929
|
* :::
|
|
2864
2930
|
*
|
|
2865
2931
|
* Issue a request via the configured {@link RequestManager},
|
|
2866
2932
|
* inserting the response into the {@link Store.cache | cache} and handing
|
|
2867
|
-
* back a {@link Future} which resolves to a {@link ReactiveDocument | ReactiveDocument}
|
|
2933
|
+
* back a {@link Future} which resolves to a {@link ReactiveDocument | ReactiveDocument}.
|
|
2934
|
+
* Use `store.request` for anything the Store's cache should own, which is nearly all app
|
|
2935
|
+
* code; reach for {@link RequestManager.request | requestManager.request} directly only when
|
|
2936
|
+
* there is no `Store` involved, or you specifically want the unprocessed
|
|
2937
|
+
* {@link StructuredDocument}.
|
|
2938
|
+
*
|
|
2939
|
+
* #### Building Requests
|
|
2940
|
+
*
|
|
2941
|
+
* `requestConfig` can be written by hand, but for anything reused more than once prefer a
|
|
2942
|
+
* request builder — a plain function that returns the right shape for `store.request`. This
|
|
2943
|
+
* repo ships builders for common operations (`findRecord`, `query`, `createRecord`, and more)
|
|
2944
|
+
* for {json:api}, REST, and ActiveRecord-style APIs in `@warp-drive-mirror/utilities`; each builder's
|
|
2945
|
+
* return value also carries its own response type, so `RT` below is inferred automatically
|
|
2946
|
+
* instead of being written by hand. See [Builders](/guides/the-manual/requests/builders.md).
|
|
2868
2947
|
*
|
|
2869
2948
|
* #### Request Cache Keys
|
|
2870
2949
|
*
|
|
@@ -2909,6 +2988,29 @@ var Store = class extends BaseClass {
|
|
|
2909
2988
|
* is that `store.request` will convert the response into a {@link ReactiveDocument}
|
|
2910
2989
|
* containing {@link Store.instantiateRecord | ReactiveResources}.
|
|
2911
2990
|
*
|
|
2991
|
+
* A {@link ReactiveDocument} is either a {@link ReactiveDataDocument} (`content.data` holds
|
|
2992
|
+
* the resource(s)) or a {@link ReactiveErrorDocument} (`content.errors` holds the API's error
|
|
2993
|
+
* objects), depending on whether the `Future` resolves or rejects; both carry the response's
|
|
2994
|
+
* `content.meta`. Read either state reactively with {@link getRequestState} or the
|
|
2995
|
+
* `<Request />` component instead of always `await`-ing the `Future` directly — see
|
|
2996
|
+
* [Using the Response](/guides/the-manual/requests/using-the-response.md).
|
|
2997
|
+
*
|
|
2998
|
+
* #### Typing The Response
|
|
2999
|
+
*
|
|
3000
|
+
* `request<RT>` accepts an explicit type argument, but the more common path is to let it be
|
|
3001
|
+
* inferred: build the request with {@link withResponseType} (or {@link withReactiveResponse}
|
|
3002
|
+
* for the common reactive-document case), or with a builder from `@warp-drive-mirror/utilities` as
|
|
3003
|
+
* described above, and `RT` is inferred from the request object itself. See
|
|
3004
|
+
* [Typing Requests](/guides/the-manual/requests/typing-requests.md) for the full mechanism.
|
|
3005
|
+
*
|
|
3006
|
+
* @example
|
|
3007
|
+
* ```ts
|
|
3008
|
+
* import { findRecord } from '@warp-drive-mirror/utilities/json-api';
|
|
3009
|
+
*
|
|
3010
|
+
* const { content } = await store.request(findRecord('user', '1'));
|
|
3011
|
+
* content.data; // ReactiveResource, typed from the builder's response type
|
|
3012
|
+
* ```
|
|
3013
|
+
*
|
|
2912
3014
|
* @public
|
|
2913
3015
|
*/
|
|
2914
3016
|
request(requestConfig) {
|
|
@@ -3360,8 +3462,7 @@ function extractIdentifierFromRecord$1(recordOrPromiseRecord) {
|
|
|
3360
3462
|
return recordIdentifierFor(recordOrPromiseRecord);
|
|
3361
3463
|
}
|
|
3362
3464
|
|
|
3363
|
-
|
|
3364
|
-
//#region src/store/-private/cache-handler/utils.ts
|
|
3465
|
+
// src/store/-private/cache-handler/utils.ts
|
|
3365
3466
|
const MUTATION_OPS$1 = /* @__PURE__ */ new Set([
|
|
3366
3467
|
"createRecord",
|
|
3367
3468
|
"updateRecord",
|
|
@@ -3401,15 +3502,20 @@ function getPriority(identifier, deduped, priority) {
|
|
|
3401
3502
|
return priority;
|
|
3402
3503
|
}
|
|
3403
3504
|
|
|
3404
|
-
|
|
3405
|
-
//#region src/store/-private/cache-handler/handler.ts
|
|
3505
|
+
// src/store/-private/cache-handler/handler.ts
|
|
3406
3506
|
/**
|
|
3407
3507
|
* The request shape accepted by {@link Store.request}, either a fully-formed
|
|
3408
3508
|
* {@link ImmutableRequestInfo} or the looser {@link LooseStoreRequestInfo}.
|
|
3509
|
+
*
|
|
3510
|
+
* @summary The request object `store.request` accepts, either a full immutable request info or a looser
|
|
3511
|
+
* form with plain `records` and `headers`.
|
|
3409
3512
|
*/
|
|
3410
3513
|
/**
|
|
3411
3514
|
* A CacheHandler that adds support for using an WarpDrive Cache with a RequestManager.
|
|
3412
3515
|
*
|
|
3516
|
+
* The [Caching](/guides/the-manual/caching/) guide explains how it decides whether a
|
|
3517
|
+
* request can use the cache.
|
|
3518
|
+
*
|
|
3413
3519
|
* This handler will only run when a request has supplied a `store` instance. Requests
|
|
3414
3520
|
* issued by the store via `store.request()` will automatically have the `store` instance
|
|
3415
3521
|
* attached to the request.
|
|
@@ -3445,7 +3551,10 @@ function getPriority(identifier, deduped, priority) {
|
|
|
3445
3551
|
* method: 'GET',
|
|
3446
3552
|
* [EnableHydration]: true
|
|
3447
3553
|
* });
|
|
3554
|
+
* ```
|
|
3448
3555
|
*
|
|
3556
|
+
* @summary The RequestManager cache handler that serves, dedupes, and caches store requests and returns
|
|
3557
|
+
* reactive documents when hydration is enabled.
|
|
3449
3558
|
*/
|
|
3450
3559
|
const CacheHandler = { request(context, next) {
|
|
3451
3560
|
if (!context.request.store || context.request.cacheOptions?.[SkipCache]) return next(context.request);
|
|
@@ -3600,14 +3709,12 @@ function fetchContentAndHydrate(next, context, identifier, priority) {
|
|
|
3600
3709
|
}] });
|
|
3601
3710
|
}
|
|
3602
3711
|
|
|
3603
|
-
|
|
3604
|
-
//#region src/store/-private/utils/is-non-empty-string.ts
|
|
3712
|
+
// src/store/-private/utils/is-non-empty-string.ts
|
|
3605
3713
|
function isNonEmptyString(str) {
|
|
3606
3714
|
return Boolean(str && typeof str === "string");
|
|
3607
3715
|
}
|
|
3608
3716
|
|
|
3609
|
-
|
|
3610
|
-
//#region src/store/-private/utils/construct-resource.ts
|
|
3717
|
+
// src/store/-private/utils/construct-resource.ts
|
|
3611
3718
|
/**
|
|
3612
3719
|
* Given an existing resource identifier object (or a {@link ResourceKey}),
|
|
3613
3720
|
* returns it unchanged aside from coercing its `id`, if present, to a string.
|
|
@@ -3670,8 +3777,7 @@ function constructResource(type, id, lid) {
|
|
|
3670
3777
|
}
|
|
3671
3778
|
}
|
|
3672
3779
|
|
|
3673
|
-
|
|
3674
|
-
//#region src/store/-private/record-arrays/legacy-many-array.ts
|
|
3780
|
+
// src/store/-private/record-arrays/legacy-many-array.ts
|
|
3675
3781
|
/**
|
|
3676
3782
|
A `ManyArray` is a `MutableArray` that represents the contents of a has-many
|
|
3677
3783
|
relationship.
|
|
@@ -3712,6 +3818,7 @@ the has-many.
|
|
|
3712
3818
|
We call the record to which a relationship belongs-to the
|
|
3713
3819
|
relationship's _owner_.
|
|
3714
3820
|
|
|
3821
|
+
@summary Legacy mutable reactive array holding the related records of a legacy or linksMode has-many relationship.
|
|
3715
3822
|
@public
|
|
3716
3823
|
*/
|
|
3717
3824
|
/**
|
|
@@ -3743,7 +3850,7 @@ function createLegacyManyArray(options) {
|
|
|
3743
3850
|
isAsync: options.isAsync,
|
|
3744
3851
|
isPolymorphic: options.isPolymorphic,
|
|
3745
3852
|
identifier: options.identifier,
|
|
3746
|
-
key: options.field.name,
|
|
3853
|
+
key: options.field.sourceKey ?? options.field.name,
|
|
3747
3854
|
reload,
|
|
3748
3855
|
createRecord,
|
|
3749
3856
|
notify
|
|
@@ -3917,8 +4024,7 @@ function mutate(collection, mutation, _SIGNAL) {
|
|
|
3917
4024
|
notifyInternalSignal(_SIGNAL);
|
|
3918
4025
|
}
|
|
3919
4026
|
|
|
3920
|
-
|
|
3921
|
-
//#region src/store/-private/debug/utils.ts
|
|
4027
|
+
// src/store/-private/debug/utils.ts
|
|
3922
4028
|
const TEXT_COLORS = {
|
|
3923
4029
|
TEXT: "inherit",
|
|
3924
4030
|
notify: [
|
|
@@ -4147,15 +4253,13 @@ function _log(scope, prefix, subScop1, subScop2, subScop3, subScop4) {
|
|
|
4147
4253
|
return [];
|
|
4148
4254
|
}
|
|
4149
4255
|
|
|
4150
|
-
|
|
4151
|
-
//#region src/reactive/-private/kind/alias-field.ts
|
|
4256
|
+
// src/reactive/-private/kind/alias-field.ts
|
|
4152
4257
|
function getAliasField(context) {}
|
|
4153
4258
|
function setAliasField(context) {
|
|
4154
4259
|
return false;
|
|
4155
4260
|
}
|
|
4156
4261
|
|
|
4157
|
-
|
|
4158
|
-
//#region src/reactive/-private/fields/managed-array.ts
|
|
4262
|
+
// src/reactive/-private/fields/managed-array.ts
|
|
4159
4263
|
const ARRAY_GETTER_METHODS = /* @__PURE__ */ new Set([
|
|
4160
4264
|
Symbol.iterator,
|
|
4161
4265
|
"concat",
|
|
@@ -4252,17 +4356,7 @@ var ManagedArray = class {
|
|
|
4252
4356
|
if (field.type) return schema.transformation(field).hydrate(rawValue, field.options ?? null, self.owner);
|
|
4253
4357
|
return rawValue;
|
|
4254
4358
|
}
|
|
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;
|
|
4359
|
+
const { type: objectType, hash } = fieldValueIdentity(schema, field, rawValue);
|
|
4266
4360
|
/**
|
|
4267
4361
|
* When KeyMode=@hash the ReactiveResource is keyed into
|
|
4268
4362
|
* ManagedRecordRefs by the return value of @hash on the rawValue.
|
|
@@ -4271,10 +4365,8 @@ var ManagedArray = class {
|
|
|
4271
4365
|
* when ARRAY_SIGNAL is dirty if hash performance becomes a bottleneck.
|
|
4272
4366
|
*/
|
|
4273
4367
|
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];
|
|
4368
|
+
if (KeyMode === "@hash") schemaObjectKeyValue = hash;
|
|
4369
|
+
else schemaObjectKeyValue = KeyMode === "@identity" ? rawValue : KeyMode === "@index" ? index : rawValue[KeyMode];
|
|
4278
4370
|
if (!schemaObjectKeyValue && schemaObjectKeyValue !== 0) return;
|
|
4279
4371
|
const recordRef = ManagedRecordRefs.get(schemaObjectKeyValue);
|
|
4280
4372
|
const record = recordRef?.value.deref();
|
|
@@ -4396,8 +4488,7 @@ Object.defineProperty(ManagedArray.prototype, "[]", {
|
|
|
4396
4488
|
get: function() {}
|
|
4397
4489
|
});
|
|
4398
4490
|
|
|
4399
|
-
|
|
4400
|
-
//#region src/reactive/-private/kind/array-field.ts
|
|
4491
|
+
// src/reactive/-private/kind/array-field.ts
|
|
4401
4492
|
function getArrayField(context) {
|
|
4402
4493
|
const signal = entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4403
4494
|
const { record } = context;
|
|
@@ -4440,8 +4531,7 @@ function setArrayField(context) {
|
|
|
4440
4531
|
return true;
|
|
4441
4532
|
}
|
|
4442
4533
|
|
|
4443
|
-
|
|
4444
|
-
//#region src/reactive/-private/kind/attribute-field.ts
|
|
4534
|
+
// src/reactive/-private/kind/attribute-field.ts
|
|
4445
4535
|
function getAttributeField(context) {
|
|
4446
4536
|
entangleInitiallyStaleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4447
4537
|
const { cache } = context.store;
|
|
@@ -4452,8 +4542,7 @@ function setAttributeField(context) {
|
|
|
4452
4542
|
return true;
|
|
4453
4543
|
}
|
|
4454
4544
|
|
|
4455
|
-
|
|
4456
|
-
//#region src/reactive/-private/fields/get-field-key.ts
|
|
4545
|
+
// src/reactive/-private/fields/get-field-key.ts
|
|
4457
4546
|
const InvalidKinds = [
|
|
4458
4547
|
"alias",
|
|
4459
4548
|
"derived",
|
|
@@ -4472,8 +4561,7 @@ function getFieldCacheKey(field) {
|
|
|
4472
4561
|
return "sourceKey" in field && field.sourceKey ? field.sourceKey : field.name;
|
|
4473
4562
|
}
|
|
4474
4563
|
|
|
4475
|
-
|
|
4476
|
-
//#region src/reactive/-private/kind/belongs-to-field.ts
|
|
4564
|
+
// src/reactive/-private/kind/belongs-to-field.ts
|
|
4477
4565
|
function getBelongsToField(context) {
|
|
4478
4566
|
entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4479
4567
|
const { field, resourceKey, store } = context;
|
|
@@ -4510,8 +4598,7 @@ function getResourceKey(record) {
|
|
|
4510
4598
|
return recordIdentifierFor(record);
|
|
4511
4599
|
}
|
|
4512
4600
|
|
|
4513
|
-
|
|
4514
|
-
//#region src/reactive/-private/kind/collection-field.ts
|
|
4601
|
+
// src/reactive/-private/kind/collection-field.ts
|
|
4515
4602
|
function getCollectionField(context) {
|
|
4516
4603
|
entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4517
4604
|
}
|
|
@@ -4519,8 +4606,7 @@ function setCollectionField(context) {
|
|
|
4519
4606
|
return false;
|
|
4520
4607
|
}
|
|
4521
4608
|
|
|
4522
|
-
|
|
4523
|
-
//#region src/reactive/-private/kind/derived-field.ts
|
|
4609
|
+
// src/reactive/-private/kind/derived-field.ts
|
|
4524
4610
|
function getDerivedField(context) {
|
|
4525
4611
|
const { schema } = context.store;
|
|
4526
4612
|
return schema.derivation(context.field)(context.record, context.field.options ?? null, context.field.name);
|
|
@@ -4529,8 +4615,7 @@ function setDerivedField(context) {
|
|
|
4529
4615
|
return false;
|
|
4530
4616
|
}
|
|
4531
4617
|
|
|
4532
|
-
|
|
4533
|
-
//#region src/reactive/-private/kind/generic-field.ts
|
|
4618
|
+
// src/reactive/-private/kind/generic-field.ts
|
|
4534
4619
|
function getGenericField(context) {
|
|
4535
4620
|
const signal = entangleInitiallyStaleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4536
4621
|
signal.isStale = false;
|
|
@@ -4552,8 +4637,7 @@ function setGenericField(context) {
|
|
|
4552
4637
|
return true;
|
|
4553
4638
|
}
|
|
4554
4639
|
|
|
4555
|
-
|
|
4556
|
-
//#region src/reactive/-private/fields/many-array-manager.ts
|
|
4640
|
+
// src/reactive/-private/fields/many-array-manager.ts
|
|
4557
4641
|
var ManyArrayManager = class {
|
|
4558
4642
|
constructor(record, editable) {
|
|
4559
4643
|
const context = record[Context];
|
|
@@ -4609,8 +4693,7 @@ function extractCacheOptions(options) {
|
|
|
4609
4693
|
return cacheOptions;
|
|
4610
4694
|
}
|
|
4611
4695
|
|
|
4612
|
-
|
|
4613
|
-
//#region src/reactive/-private/kind/has-many-field.ts
|
|
4696
|
+
// src/reactive/-private/kind/has-many-field.ts
|
|
4614
4697
|
function getHasManyField(context) {
|
|
4615
4698
|
const signal = entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4616
4699
|
const { store, field } = context;
|
|
@@ -4647,8 +4730,7 @@ function setHasManyField(context) {
|
|
|
4647
4730
|
return true;
|
|
4648
4731
|
}
|
|
4649
4732
|
|
|
4650
|
-
|
|
4651
|
-
//#region src/reactive/-private/kind/hash-field.ts
|
|
4733
|
+
// src/reactive/-private/kind/hash-field.ts
|
|
4652
4734
|
function getHashField(context) {
|
|
4653
4735
|
const { field, path, resourceKey } = context;
|
|
4654
4736
|
const { schema, cache } = context.store;
|
|
@@ -4660,8 +4742,7 @@ function setHashField(context) {
|
|
|
4660
4742
|
return false;
|
|
4661
4743
|
}
|
|
4662
4744
|
|
|
4663
|
-
|
|
4664
|
-
//#region src/reactive/-private/kind/identity-field.ts
|
|
4745
|
+
// src/reactive/-private/kind/identity-field.ts
|
|
4665
4746
|
function getIdentityField(context) {
|
|
4666
4747
|
entangleSignal(context.signals, context.record, "@identity", null);
|
|
4667
4748
|
return context.resourceKey.id;
|
|
@@ -4677,8 +4758,7 @@ function setIdentityField(context) {
|
|
|
4677
4758
|
return true;
|
|
4678
4759
|
}
|
|
4679
4760
|
|
|
4680
|
-
|
|
4681
|
-
//#region src/reactive/-private/kind/local-field.ts
|
|
4761
|
+
// src/reactive/-private/kind/local-field.ts
|
|
4682
4762
|
function getLocalField(context) {
|
|
4683
4763
|
const { field } = context;
|
|
4684
4764
|
const signal = getOrCreateInternalSignal(context.signals, context.record, field.name, field.options?.defaultValue ?? null);
|
|
@@ -4695,8 +4775,7 @@ function setLocalField(context) {
|
|
|
4695
4775
|
return true;
|
|
4696
4776
|
}
|
|
4697
4777
|
|
|
4698
|
-
|
|
4699
|
-
//#region src/reactive/-private/fields/managed-object.ts
|
|
4778
|
+
// src/reactive/-private/fields/managed-object.ts
|
|
4700
4779
|
const ObjectSymbols = /* @__PURE__ */ new Set([
|
|
4701
4780
|
OBJECT_SIGNAL,
|
|
4702
4781
|
Context,
|
|
@@ -4777,8 +4856,7 @@ function peekManagedObject(record, field) {
|
|
|
4777
4856
|
if (managedObjectMapForRecord) return managedObjectMapForRecord.get(field.name);
|
|
4778
4857
|
}
|
|
4779
4858
|
|
|
4780
|
-
|
|
4781
|
-
//#region src/reactive/-private/kind/object-field.ts
|
|
4859
|
+
// src/reactive/-private/kind/object-field.ts
|
|
4782
4860
|
function getObjectField(context) {
|
|
4783
4861
|
entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4784
4862
|
const { record, field } = context;
|
|
@@ -4834,8 +4912,7 @@ function setObjectField(context) {
|
|
|
4834
4912
|
return true;
|
|
4835
4913
|
}
|
|
4836
4914
|
|
|
4837
|
-
|
|
4838
|
-
//#region src/reactive/-private/kind/resource-field.ts
|
|
4915
|
+
// src/reactive/-private/kind/resource-field.ts
|
|
4839
4916
|
var ResourceRelationship = class {
|
|
4840
4917
|
constructor(context) {
|
|
4841
4918
|
const { store, resourceKey } = context;
|
|
@@ -4875,8 +4952,7 @@ function setResourceField(context) {
|
|
|
4875
4952
|
return false;
|
|
4876
4953
|
}
|
|
4877
4954
|
|
|
4878
|
-
|
|
4879
|
-
//#region src/reactive/-private/kind/schema-array-field.ts
|
|
4955
|
+
// src/reactive/-private/kind/schema-array-field.ts
|
|
4880
4956
|
function setSchemaArrayField(context) {
|
|
4881
4957
|
const arrayValue = context.value === null ? null : context.value?.slice();
|
|
4882
4958
|
const fieldSignal = peekInternalSignal(context.signals, context.path.at(-1));
|
|
@@ -4890,8 +4966,7 @@ function setSchemaArrayField(context) {
|
|
|
4890
4966
|
return true;
|
|
4891
4967
|
}
|
|
4892
4968
|
|
|
4893
|
-
|
|
4894
|
-
//#region src/reactive/-private/kind/schema-object-field.ts
|
|
4969
|
+
// src/reactive/-private/kind/schema-object-field.ts
|
|
4895
4970
|
function getSchemaObjectField(context) {
|
|
4896
4971
|
const signal = entangleSignal(context.signals, context.record, context.path.at(-1), null);
|
|
4897
4972
|
const { store, resourceKey, path, field } = context;
|
|
@@ -4908,15 +4983,8 @@ function getSchemaObjectField(context) {
|
|
|
4908
4983
|
}
|
|
4909
4984
|
return null;
|
|
4910
4985
|
}
|
|
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;
|
|
4986
|
+
const { type: objectType, hash } = fieldValueIdentity(store.schema, field, rawValue);
|
|
4987
|
+
const identity = hash ?? field.name;
|
|
4920
4988
|
const cachedSchemaObject = signal.value;
|
|
4921
4989
|
if (cachedSchemaObject) {
|
|
4922
4990
|
if (cachedSchemaObject.type === objectType && cachedSchemaObject.identity === identity) return cachedSchemaObject.value;
|
|
@@ -4953,8 +5021,7 @@ function setSchemaObjectField(context) {
|
|
|
4953
5021
|
return true;
|
|
4954
5022
|
}
|
|
4955
5023
|
|
|
4956
|
-
|
|
4957
|
-
//#region src/reactive/-private/default-mode.ts
|
|
5024
|
+
// src/reactive/-private/default-mode.ts
|
|
4958
5025
|
/**
|
|
4959
5026
|
* A ReactiveResource context object passed to
|
|
4960
5027
|
* the get/set functions of a field kind implementation.
|
|
@@ -5070,14 +5137,15 @@ const DefaultMode = {
|
|
|
5070
5137
|
}
|
|
5071
5138
|
};
|
|
5072
5139
|
|
|
5073
|
-
|
|
5074
|
-
//#region src/reactive/-private/record.ts
|
|
5140
|
+
// src/reactive/-private/record.ts
|
|
5075
5141
|
const IgnoredGlobalFields = /* @__PURE__ */ new Set([
|
|
5076
5142
|
"length",
|
|
5077
5143
|
"nodeType",
|
|
5078
5144
|
"then",
|
|
5079
5145
|
"setInterval",
|
|
5080
5146
|
"document",
|
|
5147
|
+
"unknownProperty",
|
|
5148
|
+
"size",
|
|
5081
5149
|
STRUCTURED
|
|
5082
5150
|
]);
|
|
5083
5151
|
const RecordSymbols = /* @__PURE__ */ new Set([
|
|
@@ -5102,10 +5170,14 @@ const Editables = /* @__PURE__ */ new Map();
|
|
|
5102
5170
|
* and a ResourceKey to transform data from the cache into a rich, reactive
|
|
5103
5171
|
* object.
|
|
5104
5172
|
*
|
|
5173
|
+
* The [ResourceSchemas](/guides/the-manual/schemas/resources/) guide shows how to
|
|
5174
|
+
* define the schema it reads.
|
|
5175
|
+
*
|
|
5105
5176
|
* This class is not directly instantiable. To use it, you should
|
|
5106
5177
|
* configure the store's `instantiateRecord` and `teardownRecord` hooks
|
|
5107
5178
|
* with the matching hooks provided by this package.
|
|
5108
5179
|
*
|
|
5180
|
+
* @summary The rich, reactive record object that presents a resource's cached data through its `ResourceSchema`.
|
|
5109
5181
|
* @hideconstructor
|
|
5110
5182
|
* @public
|
|
5111
5183
|
*/
|
|
@@ -5501,6 +5573,8 @@ function assertNeverField(identifier, field, path) {
|
|
|
5501
5573
|
* Edits to editable resources will be automatically committed if a new
|
|
5502
5574
|
* payload from the cache matches their existing value.
|
|
5503
5575
|
*
|
|
5576
|
+
* @summary Resolves with an editable copy of an immutable `ReactiveResource` so its fields can be
|
|
5577
|
+
* changed locally.
|
|
5504
5578
|
* @public
|
|
5505
5579
|
*
|
|
5506
5580
|
* @returns a promise that resolves to the editable resource
|
|
@@ -5517,14 +5591,15 @@ function checkout(resource) {
|
|
|
5517
5591
|
* approach is for either the API or a Handler to reflect saved
|
|
5518
5592
|
* changes back to update the cache.
|
|
5519
5593
|
*
|
|
5594
|
+
* @summary Forcibly makes an editable resource's local changes its new remote (immutable) state,
|
|
5595
|
+
* bypassing a save round-trip.
|
|
5520
5596
|
* @public
|
|
5521
5597
|
*/
|
|
5522
5598
|
function commit(record) {
|
|
5523
5599
|
return record[Commit]();
|
|
5524
5600
|
}
|
|
5525
5601
|
|
|
5526
|
-
|
|
5527
|
-
//#region src/reactive/-private/hooks.ts
|
|
5602
|
+
// src/reactive/-private/hooks.ts
|
|
5528
5603
|
/**
|
|
5529
5604
|
* The store's default `instantiateRecord` hook implementation, which
|
|
5530
5605
|
* produces a {@link ReactiveResource} for `identifier` using the resource
|
|
@@ -5534,6 +5609,8 @@ function commit(record) {
|
|
|
5534
5609
|
* schema is `legacy`, matching the historical behavior of assigning initial
|
|
5535
5610
|
* properties when creating a new legacy record.
|
|
5536
5611
|
*
|
|
5612
|
+
* @summary Default store `instantiateRecord` hook that creates a `ReactiveResource` for a resource key
|
|
5613
|
+
* from its registered schema.
|
|
5537
5614
|
* @public
|
|
5538
5615
|
*/
|
|
5539
5616
|
function instantiateRecord(store, identifier, createArgs) {
|
|
@@ -5557,14 +5634,15 @@ function instantiateRecord(store, identifier, createArgs) {
|
|
|
5557
5634
|
* that `record` is a {@link ReactiveResource} and invokes its `Destroy`
|
|
5558
5635
|
* behavior.
|
|
5559
5636
|
*
|
|
5637
|
+
* @summary Default store `teardownRecord` hook that destroys a `ReactiveResource` when the store
|
|
5638
|
+
* releases it.
|
|
5560
5639
|
* @public
|
|
5561
5640
|
*/
|
|
5562
5641
|
function teardownRecord(record) {
|
|
5563
5642
|
record[Destroy]();
|
|
5564
5643
|
}
|
|
5565
5644
|
|
|
5566
|
-
|
|
5567
|
-
//#region src/reactive/-private/schema.ts
|
|
5645
|
+
// src/reactive/-private/schema.ts
|
|
5568
5646
|
const Support = getOrSetGlobal("Support", /* @__PURE__ */ new WeakMap());
|
|
5569
5647
|
const ConstructorField = {
|
|
5570
5648
|
type: "@constructor",
|
|
@@ -5606,16 +5684,25 @@ _constructor[Type] = "@constructor";
|
|
|
5606
5684
|
* This should only be used for temporary migration purposes
|
|
5607
5685
|
* to the new schema system when migrating from either Model
|
|
5608
5686
|
* or ModelFragments.
|
|
5687
|
+
*
|
|
5688
|
+
* @summary Registers named methods, getters, and values to add to ReactiveResources, ReactiveObjects,
|
|
5689
|
+
* or ReactiveArrays; meant only as a temporary aid when migrating from Model or ModelFragments.
|
|
5609
5690
|
*/
|
|
5610
5691
|
/**
|
|
5611
5692
|
* Describes one feature added to a resource by a schema extension, as
|
|
5612
5693
|
* classified by {@link processExtension} from the property descriptor it
|
|
5613
5694
|
* was declared with (a method, a plain value, or a getter/setter pair).
|
|
5695
|
+
*
|
|
5696
|
+
* @summary One normalized feature of a schema extension, tagged by kind as a method, a readonly or
|
|
5697
|
+
* mutable value, or a getter/setter accessor.
|
|
5614
5698
|
*/
|
|
5615
5699
|
/**
|
|
5616
5700
|
* The result of {@link processExtension} normalizing a
|
|
5617
5701
|
* {@link CAUTION_MEGA_DANGER_ZONE_Extension} into a lookup of its features
|
|
5618
5702
|
* by name.
|
|
5703
|
+
*
|
|
5704
|
+
* @summary A registered schema extension normalized into its kind, name, and a map of its features
|
|
5705
|
+
* keyed by property name.
|
|
5619
5706
|
*/
|
|
5620
5707
|
const BannedKeys = ["constructor", "__proto__"];
|
|
5621
5708
|
function processExtension(extension) {
|
|
@@ -5705,14 +5792,19 @@ function processExtensions(schema, field, scenario, resolvedType) {
|
|
|
5705
5792
|
* Utility for constructing a ResourceSchema with the recommended
|
|
5706
5793
|
* fields for the PolarisMode experience.
|
|
5707
5794
|
*
|
|
5795
|
+
* The [ResourceSchemas](/guides/the-manual/schemas/resources/) guide shows how to
|
|
5796
|
+
* create a schema with it.
|
|
5797
|
+
*
|
|
5708
5798
|
* Using this requires registering the PolarisMode derivations
|
|
5709
5799
|
*
|
|
5710
5800
|
* ```ts
|
|
5711
|
-
* import { registerDerivations } from '@warp-drive-mirror/
|
|
5801
|
+
* import { registerDerivations } from '@warp-drive-mirror/core/reactive';
|
|
5712
5802
|
*
|
|
5713
5803
|
* registerDerivations(schema);
|
|
5714
5804
|
* ```
|
|
5715
5805
|
*
|
|
5806
|
+
* @summary Adds the default `id` identity plus `$key`, `$type`, and `constructor` derived fields to a
|
|
5807
|
+
* PolarisMode resource schema.
|
|
5716
5808
|
* @public
|
|
5717
5809
|
* @param schema
|
|
5718
5810
|
* @return {PolarisResourceSchema}
|
|
@@ -5743,6 +5835,8 @@ function withDefaults(schema) {
|
|
|
5743
5835
|
*
|
|
5744
5836
|
* `^` returns the entire identifier object.
|
|
5745
5837
|
*
|
|
5838
|
+
* @summary The `@identity` derivation, which reads a record's `id`, `lid`, `type`, or whole resource key
|
|
5839
|
+
* for use in derived fields.
|
|
5746
5840
|
* @public
|
|
5747
5841
|
*/
|
|
5748
5842
|
const fromIdentity = (record, options, key) => {
|
|
@@ -5755,9 +5849,14 @@ fromIdentity[Type] = "@identity";
|
|
|
5755
5849
|
* to use the PolarisMode defaults provided by
|
|
5756
5850
|
*
|
|
5757
5851
|
* ```ts
|
|
5758
|
-
* import { withDefaults } from '@warp-drive-mirror/
|
|
5852
|
+
* import { withDefaults } from '@warp-drive-mirror/core/reactive';
|
|
5759
5853
|
* ```
|
|
5760
5854
|
*
|
|
5855
|
+
* The [Derivations](/guides/the-manual/schemas/derivations#about-built-in-derivations)
|
|
5856
|
+
* guide explains when you need to call it.
|
|
5857
|
+
*
|
|
5858
|
+
* @summary Registers the `@identity` and `@constructor` derivations that schemas built with
|
|
5859
|
+
* `withDefaults` depend on.
|
|
5761
5860
|
* @public
|
|
5762
5861
|
*/
|
|
5763
5862
|
function registerDerivations(schema) {
|
|
@@ -5768,6 +5867,9 @@ function registerDerivations(schema) {
|
|
|
5768
5867
|
* Defines how to convert a `GenericField`, `ObjectField`, or `ArrayField`
|
|
5769
5868
|
* between the raw value `T` stored in the cache and the presentation value
|
|
5770
5869
|
* `PT` exposed on the record.
|
|
5870
|
+
*
|
|
5871
|
+
* @summary A registered converter between a field's raw cache value and the value exposed on the
|
|
5872
|
+
* record, with optional default.
|
|
5771
5873
|
*/
|
|
5772
5874
|
/**
|
|
5773
5875
|
* Wraps a derivation in a new function with Derivation signature but that looks
|
|
@@ -5790,6 +5892,12 @@ function makeCachedDerivation(derivation) {
|
|
|
5790
5892
|
/**
|
|
5791
5893
|
* A SchemaService designed to work with dynamically registered schemas.
|
|
5792
5894
|
*
|
|
5895
|
+
* The [Schemas](/guides/the-manual/schemas/) guide shows how to register schemas
|
|
5896
|
+
* with it, and [Advanced Store Configuration](/guides/configuration/advanced#add-a-source-for-schema-for-your-data)
|
|
5897
|
+
* shows how to give a store one.
|
|
5898
|
+
*
|
|
5899
|
+
* @summary The default schema service, which stores resource and object schemas, traits, derivations,
|
|
5900
|
+
* transformations, hash functions and extensions registered at runtime.
|
|
5793
5901
|
* @public
|
|
5794
5902
|
*/
|
|
5795
5903
|
var SchemaService = class {
|
|
@@ -6095,284 +6203,7 @@ function mergeMap(base, toApply) {
|
|
|
6095
6203
|
for (const [key, value] of toApply) base.set(key, value);
|
|
6096
6204
|
}
|
|
6097
6205
|
|
|
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
|
|
6206
|
+
// src/request/-private/fetch.ts
|
|
6376
6207
|
const _fetch = typeof fetch !== "undefined" ? (...args) => fetch(...args) : typeof FastBoot !== "undefined" ? (...args) => FastBoot.require("node-fetch")(...args) : () => {
|
|
6377
6208
|
throw new Error("No Fetch Implementation Found");
|
|
6378
6209
|
};
|
|
@@ -6445,6 +6276,9 @@ const ERROR_STATUS_CODE_FOR = /* @__PURE__ */ new Map([
|
|
|
6445
6276
|
* A basic Fetch Handler which converts a request into a
|
|
6446
6277
|
* `fetch` call presuming the response to be `json`.
|
|
6447
6278
|
*
|
|
6279
|
+
* The [Making Requests](/guides/the-manual/requests/#requests-do-not-need-to-use-fetch)
|
|
6280
|
+
* guide shows where it sits in the handler chain.
|
|
6281
|
+
*
|
|
6448
6282
|
* ```ts
|
|
6449
6283
|
* import { RequestManager, Fetch } from '@warp-drive-mirror/core';
|
|
6450
6284
|
*
|
|
@@ -6452,6 +6286,8 @@ const ERROR_STATUS_CODE_FOR = /* @__PURE__ */ new Map([
|
|
|
6452
6286
|
* .use([Fetch]);
|
|
6453
6287
|
* ```
|
|
6454
6288
|
*
|
|
6289
|
+
* @summary Terminal request handler that sends the request with native `fetch` and resolves with the
|
|
6290
|
+
* parsed JSON body, turning HTTP failures into errors.
|
|
6455
6291
|
* @public
|
|
6456
6292
|
* @badge Handler
|
|
6457
6293
|
*/
|
|
@@ -6569,8 +6405,7 @@ function isDict(v) {
|
|
|
6569
6405
|
return v !== null && typeof v === "object";
|
|
6570
6406
|
}
|
|
6571
6407
|
|
|
6572
|
-
|
|
6573
|
-
//#region src/request/-private/manager.ts
|
|
6408
|
+
// src/request/-private/manager.ts
|
|
6574
6409
|
/**
|
|
6575
6410
|
* ## Import
|
|
6576
6411
|
*
|
|
@@ -6578,7 +6413,8 @@ function isDict(v) {
|
|
|
6578
6413
|
* import { RequestManager } from '@warp-drive-mirror/core';
|
|
6579
6414
|
* ```
|
|
6580
6415
|
*
|
|
6581
|
-
* For complete usage guide see
|
|
6416
|
+
* For a complete usage guide see [Making Requests](/guides/the-manual/requests/), and
|
|
6417
|
+
* [Handlers](/guides/the-manual/requests/handlers) for writing the handlers it runs.
|
|
6582
6418
|
*
|
|
6583
6419
|
* ## How It Works
|
|
6584
6420
|
*
|
|
@@ -6601,11 +6437,28 @@ function isDict(v) {
|
|
|
6601
6437
|
* ```ts [Setup.ts]
|
|
6602
6438
|
* import { RequestManager, Fetch } from '@warp-drive-mirror/core';
|
|
6603
6439
|
* import { AutoCompress } from '@warp-drive-mirror/utilities/handlers';
|
|
6604
|
-
* import
|
|
6440
|
+
* import { AuthHandler } from './auth-handler';
|
|
6605
6441
|
*
|
|
6606
6442
|
* // ... create manager
|
|
6607
6443
|
* const manager = new RequestManager()
|
|
6608
|
-
* .use([
|
|
6444
|
+
* .use([AuthHandler, new AutoCompress(), Fetch]); // [!code focus]
|
|
6445
|
+
* ```
|
|
6446
|
+
*
|
|
6447
|
+
* ```ts [auth-handler.ts]
|
|
6448
|
+
* import type { Handler, NextFn } from '@warp-drive-mirror/core/request';
|
|
6449
|
+
* import type { RequestContext } from '@warp-drive-mirror/core/types/request';
|
|
6450
|
+
*
|
|
6451
|
+
* const token = '<token>';
|
|
6452
|
+
*
|
|
6453
|
+
* // adds a bearer token to every request, then passes it along
|
|
6454
|
+
* export const AuthHandler: Handler = {
|
|
6455
|
+
* request<T>(context: RequestContext, next: NextFn<T>) {
|
|
6456
|
+
* const headers = new Headers(context.request.headers);
|
|
6457
|
+
* headers.append('Authorization', `Bearer ${token}`);
|
|
6458
|
+
*
|
|
6459
|
+
* return next(Object.assign({}, context.request, { headers }));
|
|
6460
|
+
* },
|
|
6461
|
+
* };
|
|
6609
6462
|
* ```
|
|
6610
6463
|
*
|
|
6611
6464
|
* ```ts [Usage.ts]
|
|
@@ -6621,6 +6474,20 @@ function isDict(v) {
|
|
|
6621
6474
|
*
|
|
6622
6475
|
* :::
|
|
6623
6476
|
*
|
|
6477
|
+
* ### RequestManager vs {@link Store.request}
|
|
6478
|
+
*
|
|
6479
|
+
* A bare `RequestManager` is the low-level primitive: it runs a request through the configured
|
|
6480
|
+
* {@link Handler | handler chain} and settles with the raw {@link StructuredDocument}. It has no
|
|
6481
|
+
* cache and does not hydrate {@link ReactiveDocument | ReactiveDocuments} unless you register a
|
|
6482
|
+
* cache handler yourself via {@link RequestManager.useCache} and the request opts in.
|
|
6483
|
+
*
|
|
6484
|
+
* {@link Store.request} issues requests through this same `RequestManager`, but with the Store's
|
|
6485
|
+
* cache handler and hydration already wired up — inserting the response into the Store's cache
|
|
6486
|
+
* and resolving with a `ReactiveDocument` instead. Use `store.request` for anything the Store's
|
|
6487
|
+
* cache should own, which is nearly all app code. Reach for `requestManager.request` directly
|
|
6488
|
+
* only when there is no {@link Store} involved, or you specifically want the unprocessed
|
|
6489
|
+
* `StructuredDocument`.
|
|
6490
|
+
*
|
|
6624
6491
|
* ### Futures
|
|
6625
6492
|
*
|
|
6626
6493
|
* The return value of `manager.request` is a `Future`, which allows
|
|
@@ -6659,6 +6526,7 @@ function isDict(v) {
|
|
|
6659
6526
|
* type StructuredDocument<T> = StructuredDataDocument<T> | StructuredErrorDocument;
|
|
6660
6527
|
* ```
|
|
6661
6528
|
*
|
|
6529
|
+
* @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
6530
|
* @public
|
|
6663
6531
|
*/
|
|
6664
6532
|
var RequestManager = class {
|
|
@@ -6709,7 +6577,23 @@ var RequestManager = class {
|
|
|
6709
6577
|
/**
|
|
6710
6578
|
* Issue a Request.
|
|
6711
6579
|
*
|
|
6712
|
-
*
|
|
6580
|
+
* Runs `request` through the configured {@link Handler | handler chain} and settles with the
|
|
6581
|
+
* {@link StructuredDocument} the chain produces — a plain `{ request, response, content }`
|
|
6582
|
+
* object, not a {@link ReactiveDocument}. Caching and hydration only happen if a cache handler
|
|
6583
|
+
* has been registered via {@link RequestManager.useCache} and the request opts in; a
|
|
6584
|
+
* `RequestManager` created on its own has neither.
|
|
6585
|
+
*
|
|
6586
|
+
* Most app code should use {@link Store.request} instead, which calls this same method with
|
|
6587
|
+
* the Store's cache handler and hydration already configured. Reach for `requestManager.request`
|
|
6588
|
+
* directly when there is no {@link Store} involved, or when you want the unprocessed
|
|
6589
|
+
* `StructuredDocument`. The `<RT>` generic can be set explicitly or inferred from a request
|
|
6590
|
+
* built with {@link withResponseType} or {@link withReactiveResponse} — see
|
|
6591
|
+
* [Typing Requests](/guides/the-manual/requests/typing-requests.md).
|
|
6592
|
+
*
|
|
6593
|
+
* @example
|
|
6594
|
+
* ```ts
|
|
6595
|
+
* const { content } = await requestManager.request({ url: '/users' });
|
|
6596
|
+
* ```
|
|
6713
6597
|
*
|
|
6714
6598
|
* @public
|
|
6715
6599
|
*/
|
|
@@ -6768,20 +6652,27 @@ var RequestManager = class {
|
|
|
6768
6652
|
*
|
|
6769
6653
|
* @private
|
|
6770
6654
|
*/
|
|
6771
|
-
|
|
6772
|
-
//#region src/index.ts
|
|
6655
|
+
// src/index.ts
|
|
6773
6656
|
/**
|
|
6657
|
+
* @summary Main entry point for WarpDrive: the `Store`, `RequestManager`, `Fetch` handler, `CacheHandler`, and
|
|
6658
|
+
* `useRecommendedStore` for building a configured store.
|
|
6774
6659
|
* @module
|
|
6775
6660
|
* @mergeModuleWith <project>
|
|
6776
6661
|
*/
|
|
6777
6662
|
globalThis.setWarpDriveIsMaybeMirage = setIsMaybeMirage;
|
|
6778
6663
|
/**
|
|
6779
6664
|
* Options for setting up a Store instance with `useRecommendedStore`.
|
|
6665
|
+
*
|
|
6666
|
+
* @summary Configures the cache, cache policy, request handlers, schemas, and schema extensions that
|
|
6667
|
+
* `useRecommendedStore` wires into a Store class.
|
|
6780
6668
|
*/
|
|
6781
6669
|
/**
|
|
6782
6670
|
* Creates a configured Store class with recommended defaults
|
|
6783
6671
|
* for schema handling, reactivity, caching, and request management.
|
|
6784
6672
|
*
|
|
6673
|
+
* The [Setup](/guides/configuration/#configure-the-store) guide walks through
|
|
6674
|
+
* configuring the store with it.
|
|
6675
|
+
*
|
|
6785
6676
|
* ```ts
|
|
6786
6677
|
* import { useRecommendedStore } from '@warp-drive-mirror/core';
|
|
6787
6678
|
* import { JSONAPICache } from '@warp-drive-mirror/json-api';
|
|
@@ -6884,6 +6775,9 @@ globalThis.setWarpDriveIsMaybeMirage = setIsMaybeMirage;
|
|
|
6884
6775
|
* {@link RequestManager} won't have it set unless the caller supplies it
|
|
6885
6776
|
* explicitly, so a handler relying on it should treat it as optional (as
|
|
6886
6777
|
* `LoggingHandler` does above).
|
|
6778
|
+
*
|
|
6779
|
+
* @summary Builds a Store subclass preconfigured with the given cache, schemas, and handlers, plus
|
|
6780
|
+
* `Fetch`, `CacheHandler`, and a default cache policy.
|
|
6887
6781
|
*/
|
|
6888
6782
|
function useRecommendedStore(options, StoreKlass = Store) {
|
|
6889
6783
|
return class AppStore extends StoreKlass {
|
|
@@ -6937,6 +6831,5 @@ function useRecommendedStore(options, StoreKlass = Store) {
|
|
|
6937
6831
|
};
|
|
6938
6832
|
}
|
|
6939
6833
|
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
//# sourceMappingURL=src-B-GfFQcx.js.map
|
|
6834
|
+
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 };
|
|
6835
|
+
//# sourceMappingURL=src-evv7LXnE.js.map
|