@iota-uz/sdk 0.45.0 → 0.47.0
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 +5 -0
- package/dist/client-host/identity.d.ts +4 -4
- package/dist/client-host/identity.js +2 -2
- package/dist/lens/{CascadePanel-bXr7ekeZ.js → CascadePanel-BlYJd18G.js} +1 -1
- package/dist/lens/{ChartDataEquivalent-ZsncHfTF.js → ChartDataEquivalent-B6xSOdzC.js} +1 -1
- package/dist/lens/{ChartPanel-Cku9c87t.js → ChartPanel-BIJjrs5D.js} +159 -159
- package/dist/lens/{CoveragePanel-DE3fi5c7.js → CoveragePanel-CHtXDMtt.js} +1 -1
- package/dist/lens/{GaugePanel-DwR4zylR.js → GaugePanel-By0TOJPa.js} +1 -1
- package/dist/lens/LensDashboard.d.ts +13 -0
- package/dist/lens/LensDashboard.d.ts.map +1 -1
- package/dist/lens/{MapPanel-DJSiLZSz.js → MapPanel-Cw4ELCiM.js} +3 -3
- package/dist/lens/{MetricFlowPanel-Dsp_ntas.js → MetricFlowPanel-Gr5wi3nI.js} +2 -2
- package/dist/lens/{MetricHierarchyPanel-BYcy4FNw.js → MetricHierarchyPanel-VLA_5LXX.js} +2 -2
- package/dist/lens/{MetricRelationshipPanel-Gh5RKIu1.js → MetricRelationshipPanel-DFP566_c.js} +2 -2
- package/dist/lens/{PrintReport-RnKpLle9.js → PrintReport-C0OV1iHP.js} +5 -5
- package/dist/lens/{QualityChip-BxAn3wh6.js → QualityChip-DTi-0jdh.js} +1 -1
- package/dist/lens/SaveInvestigation-CX1Abyl8.js +309 -0
- package/dist/lens/TablePanel-BusKU7cU.js +994 -0
- package/dist/lens/{adapter-CZZIKpwb.js → adapter-CQg4-M7p.js} +7 -7
- package/dist/lens/contract/schemas.d.ts +2 -0
- package/dist/lens/contract/schemas.d.ts.map +1 -1
- package/dist/lens/contract/types.d.ts +14 -0
- package/dist/lens/contract/types.d.ts.map +1 -1
- package/dist/lens/{dashboardEdit-BLzL02OH.js → dashboardEdit-CJgCVfi_.js} +1 -1
- package/dist/lens/explore/DrillOverlay.d.ts +38 -0
- package/dist/lens/explore/DrillOverlay.d.ts.map +1 -1
- package/dist/lens/explore/ExplorePanel.d.ts.map +1 -1
- package/dist/lens/explore/SaveInvestigation.d.ts +21 -0
- package/dist/lens/explore/SaveInvestigation.d.ts.map +1 -0
- package/dist/lens/explore/drillHost.d.ts +25 -0
- package/dist/lens/explore/drillHost.d.ts.map +1 -0
- package/dist/lens/explore/investigation.d.ts +174 -0
- package/dist/lens/explore/investigation.d.ts.map +1 -0
- package/dist/lens/explore/provenanceLabels.d.ts +10 -0
- package/dist/lens/explore/provenanceLabels.d.ts.map +1 -0
- package/dist/lens/formula/FormulaTip.d.ts +5 -0
- package/dist/lens/formula/FormulaTip.d.ts.map +1 -1
- package/dist/lens/formula/FormulaView.d.ts.map +1 -1
- package/dist/lens/formula/PanelFormula.d.ts +2 -0
- package/dist/lens/formula/PanelFormula.d.ts.map +1 -1
- package/dist/lens/formula/element.d.ts.map +1 -1
- package/dist/lens/formula/values.d.ts +10 -1
- package/dist/lens/formula/values.d.ts.map +1 -1
- package/dist/lens/index-DR7Hf8Km.js +19805 -0
- package/dist/lens/{index-Dm3Y4NDq.js → index-DZFw4cqF.js} +1 -1
- package/dist/lens/index.d.ts +7 -1
- package/dist/lens/index.d.ts.map +1 -1
- package/dist/lens/index.js +67 -53
- package/dist/lens/{install-DCaRpfvv.js → install-B2lTK6uo.js} +1 -1
- package/dist/lens/{install-pvJpTP1f.js → install-BXr4Mnc0.js} +1 -1
- package/dist/lens/{install-C48hgC9S.js → install-CicNQ_ks.js} +1 -1
- package/dist/lens/{install-DB0eod1K.js → install-d8A0WPiw.js} +1 -1
- package/dist/lens/{keys-BAkGzg_y.js → keys-C-Akc9lZ.js} +2 -2
- package/dist/lens/panels/ChartPanel.d.ts.map +1 -1
- package/dist/lens/panels/TablePanel.d.ts.map +1 -1
- package/dist/lens/panels/actions.d.ts.map +1 -1
- package/dist/lens/panels/panelFailure.d.ts.map +1 -1
- package/dist/lens/{prefetch-j8VKR0tY.js → prefetch-C9kxuIs8.js} +2 -2
- package/dist/lens/{prefetchPanels-vwQqxrs4.js → prefetchPanels-gbY9RIqL.js} +1 -1
- package/dist/lens/{print-CuBcYmVF.js → print-CllsAP3d.js} +1 -1
- package/dist/lens/reports/ReportCompositionEditor.d.ts +8 -2
- package/dist/lens/reports/ReportCompositionEditor.d.ts.map +1 -1
- package/dist/lens/reports/ReportDefinitionEditor.d.ts +54 -0
- package/dist/lens/reports/ReportDefinitionEditor.d.ts.map +1 -0
- package/dist/lens/reports/ReportPicker.d.ts +6 -0
- package/dist/lens/reports/ReportPicker.d.ts.map +1 -1
- package/dist/lens/reports/dashboardEdit.d.ts +3 -0
- package/dist/lens/reports/dashboardEdit.d.ts.map +1 -1
- package/dist/lens/reports/editing.d.ts +35 -0
- package/dist/lens/reports/editing.d.ts.map +1 -1
- package/dist/lens/reports/picker.d.ts +4 -1
- package/dist/lens/reports/picker.d.ts.map +1 -1
- package/dist/lens/runtime/index.d.ts +0 -1
- package/dist/lens/runtime/index.d.ts.map +1 -1
- package/dist/lens/runtime/messages.d.ts +2 -2
- package/dist/lens/runtime/messages.d.ts.map +1 -1
- package/dist/lens/runtime/provider.d.ts +5 -1
- package/dist/lens/runtime/provider.d.ts.map +1 -1
- package/dist/lens/runtime/returnContext.d.ts +62 -0
- package/dist/lens/runtime/returnContext.d.ts.map +1 -0
- package/dist/lens/runtime/tableSummary.d.ts +9 -0
- package/dist/lens/runtime/tableSummary.d.ts.map +1 -0
- package/dist/lens/{scales-BSDq-uby.js → scales-CO6Q9RtG.js} +1 -1
- package/dist/lens/style.css +1 -1
- package/dist/runtime/README.md +24 -0
- package/dist/runtime/assert.d.ts +51 -0
- package/dist/runtime/assert.js +172 -0
- package/dist/runtime/build/README.txt +1 -0
- package/dist/runtime/build/extract.mjs +342 -0
- package/dist/runtime/build/shared-exports.json +388 -0
- package/dist/runtime/build/test-child.mjs +136 -0
- package/dist/runtime/build/theme/tailwind.config.js +121 -0
- package/dist/runtime/build/theme/theme.css +462 -0
- package/dist/runtime/build/theme/utilities.css +1 -0
- package/dist/runtime/build/vendor/lib/lib.d.ts +22 -0
- package/dist/runtime/build/vendor/lib/lib.decorators.d.ts +384 -0
- package/dist/runtime/build/vendor/lib/lib.decorators.legacy.d.ts +22 -0
- package/dist/runtime/build/vendor/lib/lib.dom.asynciterable.d.ts +41 -0
- package/dist/runtime/build/vendor/lib/lib.dom.d.ts +28983 -0
- package/dist/runtime/build/vendor/lib/lib.dom.iterable.d.ts +491 -0
- package/dist/runtime/build/vendor/lib/lib.es2015.collection.d.ts +147 -0
- package/dist/runtime/build/vendor/lib/lib.es2015.core.d.ts +597 -0
- package/dist/runtime/build/vendor/lib/lib.es2015.d.ts +28 -0
- package/dist/runtime/build/vendor/lib/lib.es2015.generator.d.ts +77 -0
- package/dist/runtime/build/vendor/lib/lib.es2015.iterable.d.ts +590 -0
- package/dist/runtime/build/vendor/lib/lib.es2015.promise.d.ts +81 -0
- package/dist/runtime/build/vendor/lib/lib.es2015.proxy.d.ts +128 -0
- package/dist/runtime/build/vendor/lib/lib.es2015.reflect.d.ts +144 -0
- package/dist/runtime/build/vendor/lib/lib.es2015.symbol.d.ts +46 -0
- package/dist/runtime/build/vendor/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
- package/dist/runtime/build/vendor/lib/lib.es2016.array.include.d.ts +116 -0
- package/dist/runtime/build/vendor/lib/lib.es2016.d.ts +21 -0
- package/dist/runtime/build/vendor/lib/lib.es2016.full.d.ts +23 -0
- package/dist/runtime/build/vendor/lib/lib.es2016.intl.d.ts +31 -0
- package/dist/runtime/build/vendor/lib/lib.es2017.arraybuffer.d.ts +21 -0
- package/dist/runtime/build/vendor/lib/lib.es2017.d.ts +26 -0
- package/dist/runtime/build/vendor/lib/lib.es2017.date.d.ts +31 -0
- package/dist/runtime/build/vendor/lib/lib.es2017.full.d.ts +23 -0
- package/dist/runtime/build/vendor/lib/lib.es2017.intl.d.ts +44 -0
- package/dist/runtime/build/vendor/lib/lib.es2017.object.d.ts +49 -0
- package/dist/runtime/build/vendor/lib/lib.es2017.sharedmemory.d.ts +135 -0
- package/dist/runtime/build/vendor/lib/lib.es2017.string.d.ts +45 -0
- package/dist/runtime/build/vendor/lib/lib.es2017.typedarrays.d.ts +53 -0
- package/dist/runtime/build/vendor/lib/lib.es2018.asyncgenerator.d.ts +77 -0
- package/dist/runtime/build/vendor/lib/lib.es2018.asynciterable.d.ts +53 -0
- package/dist/runtime/build/vendor/lib/lib.es2018.d.ts +24 -0
- package/dist/runtime/build/vendor/lib/lib.es2018.full.d.ts +24 -0
- package/dist/runtime/build/vendor/lib/lib.es2018.intl.d.ts +83 -0
- package/dist/runtime/build/vendor/lib/lib.es2018.promise.d.ts +30 -0
- package/dist/runtime/build/vendor/lib/lib.es2018.regexp.d.ts +37 -0
- package/dist/runtime/build/vendor/lib/lib.es2019.array.d.ts +79 -0
- package/dist/runtime/build/vendor/lib/lib.es2019.d.ts +24 -0
- package/dist/runtime/build/vendor/lib/lib.es2019.full.d.ts +24 -0
- package/dist/runtime/build/vendor/lib/lib.es2019.intl.d.ts +23 -0
- package/dist/runtime/build/vendor/lib/lib.es2019.object.d.ts +33 -0
- package/dist/runtime/build/vendor/lib/lib.es2019.string.d.ts +37 -0
- package/dist/runtime/build/vendor/lib/lib.es2019.symbol.d.ts +24 -0
- package/dist/runtime/build/vendor/lib/lib.es2020.bigint.d.ts +731 -0
- package/dist/runtime/build/vendor/lib/lib.es2020.d.ts +27 -0
- package/dist/runtime/build/vendor/lib/lib.es2020.date.d.ts +42 -0
- package/dist/runtime/build/vendor/lib/lib.es2020.full.d.ts +24 -0
- package/dist/runtime/build/vendor/lib/lib.es2020.intl.d.ts +474 -0
- package/dist/runtime/build/vendor/lib/lib.es2020.number.d.ts +28 -0
- package/dist/runtime/build/vendor/lib/lib.es2020.promise.d.ts +47 -0
- package/dist/runtime/build/vendor/lib/lib.es2020.sharedmemory.d.ts +99 -0
- package/dist/runtime/build/vendor/lib/lib.es2020.string.d.ts +44 -0
- package/dist/runtime/build/vendor/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
- package/dist/runtime/build/vendor/lib/lib.es2021.d.ts +23 -0
- package/dist/runtime/build/vendor/lib/lib.es2021.full.d.ts +24 -0
- package/dist/runtime/build/vendor/lib/lib.es2021.intl.d.ts +166 -0
- package/dist/runtime/build/vendor/lib/lib.es2021.promise.d.ts +48 -0
- package/dist/runtime/build/vendor/lib/lib.es2021.string.d.ts +33 -0
- package/dist/runtime/build/vendor/lib/lib.es2021.weakref.d.ts +78 -0
- package/dist/runtime/build/vendor/lib/lib.es2022.array.d.ts +121 -0
- package/dist/runtime/build/vendor/lib/lib.es2022.d.ts +25 -0
- package/dist/runtime/build/vendor/lib/lib.es2022.error.d.ts +75 -0
- package/dist/runtime/build/vendor/lib/lib.es2022.full.d.ts +24 -0
- package/dist/runtime/build/vendor/lib/lib.es2022.intl.d.ts +121 -0
- package/dist/runtime/build/vendor/lib/lib.es2022.object.d.ts +26 -0
- package/dist/runtime/build/vendor/lib/lib.es2022.regexp.d.ts +39 -0
- package/dist/runtime/build/vendor/lib/lib.es2022.string.d.ts +25 -0
- package/dist/runtime/build/vendor/lib/lib.es2023.array.d.ts +924 -0
- package/dist/runtime/build/vendor/lib/lib.es2023.collection.d.ts +21 -0
- package/dist/runtime/build/vendor/lib/lib.es2023.d.ts +22 -0
- package/dist/runtime/build/vendor/lib/lib.es2023.full.d.ts +24 -0
- package/dist/runtime/build/vendor/lib/lib.es2023.intl.d.ts +56 -0
- package/dist/runtime/build/vendor/lib/lib.es2024.arraybuffer.d.ts +65 -0
- package/dist/runtime/build/vendor/lib/lib.es2024.collection.d.ts +29 -0
- package/dist/runtime/build/vendor/lib/lib.es2024.d.ts +26 -0
- package/dist/runtime/build/vendor/lib/lib.es2024.full.d.ts +24 -0
- package/dist/runtime/build/vendor/lib/lib.es2024.object.d.ts +29 -0
- package/dist/runtime/build/vendor/lib/lib.es2024.promise.d.ts +35 -0
- package/dist/runtime/build/vendor/lib/lib.es2024.regexp.d.ts +25 -0
- package/dist/runtime/build/vendor/lib/lib.es2024.sharedmemory.d.ts +68 -0
- package/dist/runtime/build/vendor/lib/lib.es2024.string.d.ts +29 -0
- package/dist/runtime/build/vendor/lib/lib.es5.d.ts +4585 -0
- package/dist/runtime/build/vendor/lib/lib.es6.d.ts +23 -0
- package/dist/runtime/build/vendor/lib/lib.esnext.array.d.ts +35 -0
- package/dist/runtime/build/vendor/lib/lib.esnext.collection.d.ts +96 -0
- package/dist/runtime/build/vendor/lib/lib.esnext.d.ts +25 -0
- package/dist/runtime/build/vendor/lib/lib.esnext.decorators.d.ts +28 -0
- package/dist/runtime/build/vendor/lib/lib.esnext.disposable.d.ts +193 -0
- package/dist/runtime/build/vendor/lib/lib.esnext.full.d.ts +24 -0
- package/dist/runtime/build/vendor/lib/lib.esnext.intl.d.ts +21 -0
- package/dist/runtime/build/vendor/lib/lib.esnext.iterator.d.ts +148 -0
- package/dist/runtime/build/vendor/node-types/assert/strict.d.ts +111 -0
- package/dist/runtime/build/vendor/node-types/assert.d.ts +1115 -0
- package/dist/runtime/build/vendor/node-types/async_hooks.d.ts +619 -0
- package/dist/runtime/build/vendor/node-types/buffer.buffer.d.ts +477 -0
- package/dist/runtime/build/vendor/node-types/buffer.d.ts +1941 -0
- package/dist/runtime/build/vendor/node-types/child_process.d.ts +1480 -0
- package/dist/runtime/build/vendor/node-types/cluster.d.ts +578 -0
- package/dist/runtime/build/vendor/node-types/compatibility/iterators.d.ts +21 -0
- package/dist/runtime/build/vendor/node-types/console.d.ts +453 -0
- package/dist/runtime/build/vendor/node-types/constants.d.ts +21 -0
- package/dist/runtime/build/vendor/node-types/crypto.d.ts +5484 -0
- package/dist/runtime/build/vendor/node-types/dgram.d.ts +715 -0
- package/dist/runtime/build/vendor/node-types/diagnostics_channel.d.ts +576 -0
- package/dist/runtime/build/vendor/node-types/dns/promises.d.ts +503 -0
- package/dist/runtime/build/vendor/node-types/dns.d.ts +923 -0
- package/dist/runtime/build/vendor/node-types/domain.d.ts +166 -0
- package/dist/runtime/build/vendor/node-types/events.d.ts +967 -0
- package/dist/runtime/build/vendor/node-types/fs/promises.d.ts +1354 -0
- package/dist/runtime/build/vendor/node-types/fs.d.ts +4777 -0
- package/dist/runtime/build/vendor/node-types/globals.d.ts +170 -0
- package/dist/runtime/build/vendor/node-types/globals.typedarray.d.ts +41 -0
- package/dist/runtime/build/vendor/node-types/http.d.ts +2246 -0
- package/dist/runtime/build/vendor/node-types/http2.d.ts +2882 -0
- package/dist/runtime/build/vendor/node-types/https.d.ts +585 -0
- package/dist/runtime/build/vendor/node-types/index.d.ts +101 -0
- package/dist/runtime/build/vendor/node-types/inspector.d.ts +323 -0
- package/dist/runtime/build/vendor/node-types/inspector.generated.d.ts +4406 -0
- package/dist/runtime/build/vendor/node-types/module.d.ts +844 -0
- package/dist/runtime/build/vendor/node-types/net.d.ts +1197 -0
- package/dist/runtime/build/vendor/node-types/os.d.ts +507 -0
- package/dist/runtime/build/vendor/node-types/package.json +140 -0
- package/dist/runtime/build/vendor/node-types/path.d.ts +200 -0
- package/dist/runtime/build/vendor/node-types/perf_hooks.d.ts +1054 -0
- package/dist/runtime/build/vendor/node-types/process.d.ts +2101 -0
- package/dist/runtime/build/vendor/node-types/punycode.d.ts +117 -0
- package/dist/runtime/build/vendor/node-types/querystring.d.ts +152 -0
- package/dist/runtime/build/vendor/node-types/readline/promises.d.ts +161 -0
- package/dist/runtime/build/vendor/node-types/readline.d.ts +600 -0
- package/dist/runtime/build/vendor/node-types/repl.d.ts +438 -0
- package/dist/runtime/build/vendor/node-types/sea.d.ts +162 -0
- package/dist/runtime/build/vendor/node-types/sqlite.d.ts +1182 -0
- package/dist/runtime/build/vendor/node-types/stream/consumers.d.ts +45 -0
- package/dist/runtime/build/vendor/node-types/stream/promises.d.ts +90 -0
- package/dist/runtime/build/vendor/node-types/stream/web.d.ts +596 -0
- package/dist/runtime/build/vendor/node-types/stream.d.ts +1707 -0
- package/dist/runtime/build/vendor/node-types/string_decoder.d.ts +67 -0
- package/dist/runtime/build/vendor/node-types/test.d.ts +2656 -0
- package/dist/runtime/build/vendor/node-types/timers/promises.d.ts +108 -0
- package/dist/runtime/build/vendor/node-types/timers.d.ts +285 -0
- package/dist/runtime/build/vendor/node-types/tls.d.ts +1314 -0
- package/dist/runtime/build/vendor/node-types/trace_events.d.ts +197 -0
- package/dist/runtime/build/vendor/node-types/ts5.6/buffer.buffer.d.ts +473 -0
- package/dist/runtime/build/vendor/node-types/ts5.6/compatibility/float16array.d.ts +71 -0
- package/dist/runtime/build/vendor/node-types/ts5.6/globals.typedarray.d.ts +36 -0
- package/dist/runtime/build/vendor/node-types/ts5.6/index.d.ts +103 -0
- package/dist/runtime/build/vendor/node-types/ts5.7/compatibility/float16array.d.ts +72 -0
- package/dist/runtime/build/vendor/node-types/ts5.7/index.d.ts +103 -0
- package/dist/runtime/build/vendor/node-types/tty.d.ts +209 -0
- package/dist/runtime/build/vendor/node-types/url.d.ts +1103 -0
- package/dist/runtime/build/vendor/node-types/util.d.ts +2379 -0
- package/dist/runtime/build/vendor/node-types/v8.d.ts +1010 -0
- package/dist/runtime/build/vendor/node-types/vm.d.ts +1160 -0
- package/dist/runtime/build/vendor/node-types/wasi.d.ts +202 -0
- package/dist/runtime/build/vendor/node-types/web-globals/abortcontroller.d.ts +34 -0
- package/dist/runtime/build/vendor/node-types/web-globals/crypto.d.ts +32 -0
- package/dist/runtime/build/vendor/node-types/web-globals/domexception.d.ts +68 -0
- package/dist/runtime/build/vendor/node-types/web-globals/events.d.ts +97 -0
- package/dist/runtime/build/vendor/node-types/web-globals/fetch.d.ts +62 -0
- package/dist/runtime/build/vendor/node-types/web-globals/navigator.d.ts +25 -0
- package/dist/runtime/build/vendor/node-types/web-globals/storage.d.ts +24 -0
- package/dist/runtime/build/vendor/node-types/web-globals/streams.d.ts +22 -0
- package/dist/runtime/build/vendor/node-types/worker_threads.d.ts +894 -0
- package/dist/runtime/build/vendor/node-types/zlib.d.ts +768 -0
- package/dist/runtime/build/vendor/node_modules/csstype/LICENSE +19 -0
- package/dist/runtime/build/vendor/node_modules/csstype/index.d.ts +22569 -0
- package/dist/runtime/build/vendor/node_modules/csstype/index.js.flow +6863 -0
- package/dist/runtime/build/vendor/node_modules/csstype/package.json +70 -0
- package/dist/runtime/build/vendor/node_modules/seroval/LICENSE +7 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/cjs/development/index.cjs +4232 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/cjs/production/index.cjs +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/esm/development/index.mjs +4209 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/esm/production/index.mjs +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/Serializer.d.ts +28 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/base-primitives.d.ts +28 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/compat.d.ts +15 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/constants.d.ts +105 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/constructors.d.ts +50 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/context/async-parser.d.ts +20 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/context/deserializer.d.ts +52 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/context/parser.d.ts +62 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/context/serializer.d.ts +103 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/context/sync-parser.d.ts +61 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/cross/index.d.ts +24 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/errors.d.ts +47 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/function-string.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/keys.d.ts +4 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/literals.d.ts +10 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/node.d.ts +8 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/opaque-reference.d.ts +9 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/plugin.d.ts +52 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/reference.d.ts +6 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/sequence.d.ts +11 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/special-reference.d.ts +16 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/stream.d.ts +17 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/string.d.ts +4 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/symbols.d.ts +14 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/tree/index.d.ts +21 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/types.d.ts +233 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/error.d.ts +6 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/get-identifier.d.ts +2 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/get-object-flag.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/is-valid-identifier.d.ts +2 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/promise-to-result.d.ts +2 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/typed-array.d.ts +6 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/core/utils/valid-properties.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval/dist/types/index.d.ts +18 -0
- package/dist/runtime/build/vendor/node_modules/seroval/package.json +67 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/Serializer.ts +119 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/base-primitives.ts +537 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/compat.ts +23 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/constants.ts +202 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/constructors.ts +265 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/context/async-parser.ts +666 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/context/deserializer.ts +832 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/context/parser.ts +335 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/context/serializer.ts +1524 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/context/sync-parser.ts +943 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/cross/index.ts +190 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/errors.ts +196 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/function-string.ts +31 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/keys.ts +17 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/literals.ts +43 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/node.ts +40 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/opaque-reference.ts +9 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/plugin.ts +105 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/reference.ts +66 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/sequence.ts +59 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/special-reference.ts +42 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/stream.ts +71 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/string.ts +86 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/symbols.ts +20 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/tree/index.ts +134 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/types.ts +377 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/error.ts +73 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/get-identifier.ts +18 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/get-object-flag.ts +14 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/is-valid-identifier.ts +12 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/promise-to-result.ts +9 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/typed-array.ts +56 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/core/utils/valid-properties.ts +34 -0
- package/dist/runtime/build/vendor/node_modules/seroval/src/index.ts +36 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/LICENSE +7 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/cjs/development/web.cjs +826 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/cjs/production/web.cjs +1 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/esm/development/web.mjs +803 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/esm/production/web.mjs +1 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/abort-signal.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/blob.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/custom-event.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/dom-exception.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/event.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/file.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/form-data.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/headers.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/image-data.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/index.d.ts +15 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/readable-stream.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/request.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/response.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/url-search-params.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/dist/types/web/url.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/package.json +70 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/abort-signal.ts +131 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/blob.ts +41 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/custom-event.ts +66 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/dom-exception.ts +57 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/event.ts +62 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/file.ts +50 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/form-data.ts +105 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/headers.ts +49 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/image-data.ts +74 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/index.ts +14 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/readable-stream.ts +148 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/request.ts +82 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/response.ts +65 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/url-search-params.ts +40 -0
- package/dist/runtime/build/vendor/node_modules/seroval-plugins/web/url.ts +37 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/dist/server.cjs +824 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/dist/server.js +770 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/dist/solid.cjs +1808 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/dist/solid.js +1753 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/jsx-runtime.d.ts +1 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/package.json +243 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/store/dist/server.cjs +133 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/store/dist/server.js +121 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/store/dist/store.cjs +463 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/store/dist/store.js +454 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/store/package.json +46 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/store/types/index.d.ts +12 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/store/types/modifiers.d.ts +6 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/store/types/mutable.d.ts +5 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/store/types/server.d.ts +17 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/store/types/store.d.ts +108 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/index.d.ts +23 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/jsx.d.ts +4253 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/reactive/array.d.ts +44 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/reactive/observable.d.ts +36 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/reactive/scheduler.d.ts +10 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/reactive/signal.d.ts +581 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/render/Suspense.d.ts +26 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/render/component.d.ts +111 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/render/flow.d.ts +118 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/render/hydration.d.ts +24 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/render/index.d.ts +4 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/server/index.d.ts +3 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/server/reactive.d.ts +98 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/types/server/rendering.d.ts +160 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/dist/server.cjs +900 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/dist/server.js +786 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/dist/web.cjs +884 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/dist/web.js +772 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/package.json +46 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/storage/dist/storage.cjs +12 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/storage/dist/storage.js +10 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/storage/package.json +15 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/storage/types/index.d.ts +2 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/types/client.d.ts +93 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/types/core.d.ts +2 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/types/index.d.ts +50 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/types/jsx.d.ts +1 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/types/server-mock.d.ts +65 -0
- package/dist/runtime/build/vendor/node_modules/solid-js/web/types/server.d.ts +187 -0
- package/dist/runtime/build/worker.mjs +293415 -0
- package/dist/runtime/catalog/sdk-natives.json +655 -0
- package/dist/runtime/cli/iota-ext.mjs +1028 -0
- package/dist/runtime/client-host/entry.d.ts +10 -0
- package/dist/runtime/client-host/entry.js +124 -0
- package/dist/runtime/client-host/hooks.d.ts +43 -0
- package/dist/runtime/client-host/hooks.js +94 -0
- package/dist/runtime/client-host/index.d.ts +9 -0
- package/dist/runtime/client-host/index.js +9 -0
- package/dist/runtime/client-host/islands.d.ts +44 -0
- package/dist/runtime/client-host/islands.js +165 -0
- package/dist/runtime/client-host/kit.d.ts +10 -0
- package/dist/runtime/client-host/kit.js +37 -0
- package/dist/runtime/client-host/page.d.ts +53 -0
- package/dist/runtime/client-host/page.js +217 -0
- package/dist/runtime/client-host/params.d.ts +8 -0
- package/dist/runtime/client-host/params.js +36 -0
- package/dist/runtime/client-host/protocol.d.ts +78 -0
- package/dist/runtime/client-host/protocol.js +26 -0
- package/dist/runtime/client-host/shared.d.ts +12 -0
- package/dist/runtime/client-host/shared.js +49 -0
- package/dist/runtime/client-host/shell.d.ts +88 -0
- package/dist/runtime/client-host/shell.js +195 -0
- package/dist/runtime/client-host/slots.d.ts +54 -0
- package/dist/runtime/client-host/slots.js +90 -0
- package/dist/runtime/client-host/styles.d.ts +7 -0
- package/dist/runtime/client-host/styles.js +61 -0
- package/dist/runtime/client-host/transport.d.ts +45 -0
- package/dist/runtime/client-host/transport.js +115 -0
- package/dist/runtime/client.d.ts +226 -0
- package/dist/runtime/client.js +121 -0
- package/dist/runtime/contracts.d.ts +204 -0
- package/dist/runtime/contracts.js +195 -0
- package/dist/runtime/docs/authoring.md +1609 -0
- package/dist/runtime/docs/example/docs/en/admin/limits.md +10 -0
- package/dist/runtime/docs/example/docs/en/getting-started.md +13 -0
- package/dist/runtime/docs/example/docs/en/points.md +9 -0
- package/dist/runtime/docs/example/docs/ru/getting-started.md +12 -0
- package/dist/runtime/docs/example/package.json +27 -0
- package/dist/runtime/docs/example/src/ClientScreen.tsx +10 -0
- package/dist/runtime/docs/example/src/RedemptionScreen.tsx +7 -0
- package/dist/runtime/docs/example/src/RewardsScreen.module.css +13 -0
- package/dist/runtime/docs/example/src/RewardsScreen.tsx +51 -0
- package/dist/runtime/docs/example/src/client.tsx +40 -0
- package/dist/runtime/docs/example/src/contracts.ts +132 -0
- package/dist/runtime/docs/example/src/css-modules.d.ts +5 -0
- package/dist/runtime/docs/example/src/server.test.ts +156 -0
- package/dist/runtime/docs/example/src/server.ts +188 -0
- package/dist/runtime/docs/example/tsconfig.json +16 -0
- package/dist/runtime/entity.d.ts +237 -0
- package/dist/runtime/entity.js +201 -0
- package/dist/runtime/fakes.d.ts +80 -0
- package/dist/runtime/fakes.js +88 -0
- package/dist/runtime/fixtures.d.ts +34 -0
- package/dist/runtime/fixtures.js +60 -0
- package/dist/runtime/help.d.ts +22 -0
- package/dist/runtime/help.js +51 -0
- package/dist/runtime/host/context.mjs +392 -0
- package/dist/runtime/host/errors.mjs +64 -0
- package/dist/runtime/host/loader.mjs +28 -0
- package/dist/runtime/host/protocol.mjs +4 -0
- package/dist/runtime/host/register.mjs +8 -0
- package/dist/runtime/host/sdk/assert.mjs +153 -0
- package/dist/runtime/host/sdk/client-host/hooks.mjs +86 -0
- package/dist/runtime/host/sdk/client-host/protocol.mjs +30 -0
- package/dist/runtime/host/sdk/client-host/slots.mjs +82 -0
- package/dist/runtime/host/sdk/client-host/styles.mjs +45 -0
- package/dist/runtime/host/sdk/client-host/transport.mjs +102 -0
- package/dist/runtime/host/sdk/client.mjs +115 -0
- package/dist/runtime/host/sdk/contracts.mjs +185 -0
- package/dist/runtime/host/sdk/entity.mjs +183 -0
- package/dist/runtime/host/sdk/fakes.mjs +88 -0
- package/dist/runtime/host/sdk/fixtures.mjs +56 -0
- package/dist/runtime/host/sdk/help.mjs +37 -0
- package/dist/runtime/host/sdk/index.mjs +83 -0
- package/dist/runtime/host/sdk/kit.mjs +11 -0
- package/dist/runtime/host/sdk/manifest.mjs +276 -0
- package/dist/runtime/host/sdk/model.mjs +4 -0
- package/dist/runtime/host/sdk/resource.mjs +34 -0
- package/dist/runtime/host/sdk/schema.mjs +75 -0
- package/dist/runtime/host/sdk/server.mjs +43 -0
- package/dist/runtime/host/sdk/testhost.mjs +992 -0
- package/dist/runtime/host/sdk/testing.mjs +21 -0
- package/dist/runtime/host/sdk/wire.mjs +207 -0
- package/dist/runtime/host/worker.mjs +252 -0
- package/dist/runtime/index.d.ts +10 -0
- package/dist/runtime/index.js +5 -0
- package/dist/runtime/kit.d.ts +5 -0
- package/dist/runtime/kit.js +14 -0
- package/dist/runtime/manifest.d.ts +17 -0
- package/dist/runtime/manifest.js +323 -0
- package/dist/runtime/model.d.ts +224 -0
- package/dist/runtime/model.js +3 -0
- package/dist/runtime/resource.d.ts +31 -0
- package/dist/runtime/resource.js +35 -0
- package/dist/runtime/schema.d.ts +97 -0
- package/dist/runtime/schema.js +73 -0
- package/dist/runtime/server.d.ts +445 -0
- package/dist/runtime/server.js +41 -0
- package/dist/runtime/testhost.d.ts +216 -0
- package/dist/runtime/testhost.js +1146 -0
- package/dist/runtime/testing.d.ts +10 -0
- package/dist/runtime/testing.js +7 -0
- package/dist/runtime/wire.d.ts +26 -0
- package/dist/runtime/wire.js +236 -0
- package/dist/sdk-identity.cjs +3 -3
- package/dist/sdk-identity.js +3 -3
- package/dist/sdk-identity.json +2 -2
- package/dist/solid-ui/embedded-css.d.ts +2 -0
- package/dist/solid-ui/embedded-css.js +1 -0
- package/dist/solid-ui/embedded.css +2 -0
- package/dist/testing/components.d.ts +73 -0
- package/dist/testing/components.js +96 -0
- package/dist/testing/htmx.d.ts +44 -0
- package/dist/testing/htmx.js +284 -0
- package/dist/testing/index.d.ts +4 -41
- package/dist/testing/index.js +3 -206
- package/dist/testing/scenarios.d.ts +83 -0
- package/dist/testing/scenarios.js +74 -0
- package/dist/testing/wait.d.ts +7 -0
- package/dist/testing/wait.js +19 -0
- package/package.json +33 -2
- package/dist/lens/TablePanel-DU_ydQ1x.js +0 -980
- package/dist/lens/index-BJIuggdQ.js +0 -18403
- package/dist/lens/runtime/recovery.d.ts +0 -26
- package/dist/lens/runtime/recovery.d.ts.map +0 -1
|
@@ -0,0 +1,992 @@
|
|
|
1
|
+
import { compileFilter } from "./entity.mjs";
|
|
2
|
+
import { fakeEffects } from "./fakes.mjs";
|
|
3
|
+
import { EPOCH, OVERLAY_OF } from "./fixtures.mjs";
|
|
4
|
+
import { decode, encode, validate } from "./wire.mjs";
|
|
5
|
+
class TestHostError extends Error {
|
|
6
|
+
kind;
|
|
7
|
+
code;
|
|
8
|
+
constructor(code, message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "TestHostError";
|
|
11
|
+
this.kind = "internal";
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const fail = (code, message) => {
|
|
16
|
+
throw new TestHostError(code, message);
|
|
17
|
+
};
|
|
18
|
+
const assigneeOf = (assignee) => {
|
|
19
|
+
const permission = assignee?.permission;
|
|
20
|
+
return typeof permission === "object" && permission !== null && typeof permission.id === "string" ? { permission: permission.id } : assignee;
|
|
21
|
+
};
|
|
22
|
+
const permissionOf = (assignee) => {
|
|
23
|
+
const permission = assignee?.permission;
|
|
24
|
+
return typeof permission === "string" ? permission : void 0;
|
|
25
|
+
};
|
|
26
|
+
function state() {
|
|
27
|
+
const g = globalThis;
|
|
28
|
+
return g[Symbol.for("iota.testing.state")] ??= { cases: [], http: null };
|
|
29
|
+
}
|
|
30
|
+
let prefix = "";
|
|
31
|
+
function test(name, fn, options = {}) {
|
|
32
|
+
state().cases.push({ name: prefix + name, fn, ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs } });
|
|
33
|
+
}
|
|
34
|
+
function describe(name, body) {
|
|
35
|
+
const before = prefix;
|
|
36
|
+
prefix = `${before}${name} > `;
|
|
37
|
+
try {
|
|
38
|
+
body();
|
|
39
|
+
} finally {
|
|
40
|
+
prefix = before;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const POLICY_REASON = /^[a-z0-9_.-]{1,64}$/;
|
|
44
|
+
const VERSION_SEGMENT = /^v[1-9][0-9]*$/;
|
|
45
|
+
function noticeKey(id) {
|
|
46
|
+
const snake = (s) => s.replace(/(?<=[^A-Z_])([A-Z])/g, "_$1").toLowerCase();
|
|
47
|
+
const segments = id.split(".").map(snake);
|
|
48
|
+
const last = segments[segments.length - 1] ?? "";
|
|
49
|
+
if (!VERSION_SEGMENT.test(last)) segments.push("v1");
|
|
50
|
+
return { key: segments.join("."), version: Number((segments[segments.length - 1] ?? "v1").slice(1)) };
|
|
51
|
+
}
|
|
52
|
+
const DURATION = /^(\d+)(ms|s|m|h|d)$/;
|
|
53
|
+
const UNIT_MS = { ms: 1, s: 1e3, m: 6e4, h: 36e5, d: 864e5 };
|
|
54
|
+
function durationMs(d) {
|
|
55
|
+
const m = DURATION.exec(d);
|
|
56
|
+
if (m === null) return fail("runtime.invalidDuration", `invalid duration "${d}"`);
|
|
57
|
+
return Number(m[1]) * UNIT_MS[m[2]];
|
|
58
|
+
}
|
|
59
|
+
const json = (value) => value === void 0 ? value : JSON.parse(JSON.stringify(value));
|
|
60
|
+
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
61
|
+
function cmpDecimal(a, b) {
|
|
62
|
+
const parse = (s) => {
|
|
63
|
+
const neg = s.startsWith("-");
|
|
64
|
+
const [i = "0", f = ""] = (neg ? s.slice(1) : s).split(".");
|
|
65
|
+
return [neg, i.replace(/^0+(?=\d)/, ""), f];
|
|
66
|
+
};
|
|
67
|
+
const [an, ai, af] = parse(a);
|
|
68
|
+
const [bn, bi, bf] = parse(b);
|
|
69
|
+
const scale = Math.max(af.length, bf.length);
|
|
70
|
+
const x = BigInt(ai + af.padEnd(scale, "0")) * (an ? -1n : 1n);
|
|
71
|
+
const y = BigInt(bi + bf.padEnd(scale, "0")) * (bn ? -1n : 1n);
|
|
72
|
+
return x < y ? -1 : x > y ? 1 : 0;
|
|
73
|
+
}
|
|
74
|
+
const order = (x, y) => x < y ? -1 : x > y ? 1 : 0;
|
|
75
|
+
function compare(type, a, b) {
|
|
76
|
+
const key = (v) => isRecord(v) ? String(v.key) : String(v);
|
|
77
|
+
switch (type?.kind) {
|
|
78
|
+
case "int":
|
|
79
|
+
return order(Number(a), Number(b));
|
|
80
|
+
case "int64":
|
|
81
|
+
return order(BigInt(String(a)), BigInt(String(b)));
|
|
82
|
+
case "decimal":
|
|
83
|
+
return cmpDecimal(String(a), String(b));
|
|
84
|
+
case "datetime":
|
|
85
|
+
return order(Date.parse(String(a)), Date.parse(String(b)));
|
|
86
|
+
case "bool":
|
|
87
|
+
return order(Boolean(a), Boolean(b));
|
|
88
|
+
case "ref":
|
|
89
|
+
return order(key(a), key(b));
|
|
90
|
+
case "json":
|
|
91
|
+
case "object":
|
|
92
|
+
case "array":
|
|
93
|
+
return JSON.stringify(a) === JSON.stringify(b) ? 0 : 1;
|
|
94
|
+
case void 0:
|
|
95
|
+
return typeof a === "number" && typeof b === "number" ? order(a, b) : order(key(a), key(b));
|
|
96
|
+
default:
|
|
97
|
+
return order(String(a), String(b));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const ORDERABLE = /* @__PURE__ */ new Set(["string", "int", "int64", "decimal", "date", "datetime", "uuid", "enum"]);
|
|
101
|
+
const MAX_PATH = 4;
|
|
102
|
+
const MAX_IN = 1e3;
|
|
103
|
+
const DEFAULT_LIMIT = 100;
|
|
104
|
+
const MAX_LIMIT = 1e3;
|
|
105
|
+
function likeToRegExp(pattern) {
|
|
106
|
+
let out = "";
|
|
107
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
108
|
+
const ch = pattern[i] ?? "";
|
|
109
|
+
if (ch === "\\" && i + 1 < pattern.length) out += (pattern[++i] ?? "").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
110
|
+
else if (ch === "%") out += "[\\s\\S]*";
|
|
111
|
+
else if (ch === "_") out += "[\\s\\S]";
|
|
112
|
+
else out += ch.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
113
|
+
}
|
|
114
|
+
return new RegExp(`^${out}$`);
|
|
115
|
+
}
|
|
116
|
+
class Store {
|
|
117
|
+
tables = /* @__PURE__ */ new Map();
|
|
118
|
+
overlays = /* @__PURE__ */ new Map();
|
|
119
|
+
clone() {
|
|
120
|
+
const c = new Store();
|
|
121
|
+
for (const [id, rows] of this.tables) c.tables.set(id, new Map([...rows].map(([k, r]) => [k, structuredClone(r)])));
|
|
122
|
+
for (const [id, rows] of this.overlays) c.overlays.set(id, new Map([...rows].map(([k, r]) => [k, structuredClone(r)])));
|
|
123
|
+
return c;
|
|
124
|
+
}
|
|
125
|
+
table(id) {
|
|
126
|
+
let t = this.tables.get(id);
|
|
127
|
+
if (t === void 0) this.tables.set(id, t = /* @__PURE__ */ new Map());
|
|
128
|
+
return t;
|
|
129
|
+
}
|
|
130
|
+
overlay(id) {
|
|
131
|
+
let t = this.overlays.get(id);
|
|
132
|
+
if (t === void 0) this.overlays.set(id, t = /* @__PURE__ */ new Map());
|
|
133
|
+
return t;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const isOverlay = (d) => d.kind === "overlay";
|
|
137
|
+
function createTestHost(options = {}) {
|
|
138
|
+
const fakes = options.fakes ?? fakeEffects();
|
|
139
|
+
state().http = fakes.http;
|
|
140
|
+
const permissions = new Set(options.user?.permissions ?? []);
|
|
141
|
+
const user = {
|
|
142
|
+
tenantId: "tenant-test",
|
|
143
|
+
userId: options.user?.id ?? "1",
|
|
144
|
+
kind: options.user?.kind ?? "initiator",
|
|
145
|
+
...options.user?.locale === void 0 ? {} : { locale: options.user.locale },
|
|
146
|
+
has: (p) => {
|
|
147
|
+
const id = typeof p === "string" ? p : p.id;
|
|
148
|
+
return id === "" || permissions.has(id);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const holds = (userId, permission) => userId === user.userId ? permissions.has(permission) : options.users?.[userId]?.includes(permission) ?? false;
|
|
152
|
+
let store = new Store();
|
|
153
|
+
const defs = /* @__PURE__ */ new Map();
|
|
154
|
+
const committed = { emitted: [], notices: [], started: [], signals: [] };
|
|
155
|
+
const deliveries = [];
|
|
156
|
+
const logs = [];
|
|
157
|
+
const impls = /* @__PURE__ */ new Map();
|
|
158
|
+
const writeRules = /* @__PURE__ */ new Map();
|
|
159
|
+
const opGuards = /* @__PURE__ */ new Map();
|
|
160
|
+
const prechecks = /* @__PURE__ */ new Map();
|
|
161
|
+
const workflowDefs = /* @__PURE__ */ new Map();
|
|
162
|
+
const runs = /* @__PURE__ */ new Map();
|
|
163
|
+
const inboxes = /* @__PURE__ */ new Map();
|
|
164
|
+
let clockMs = Date.parse(options.now ?? EPOCH);
|
|
165
|
+
let counter = 0;
|
|
166
|
+
const nextId = (p) => `${p}-${++counter}`;
|
|
167
|
+
const nextKey = () => `00000000-0000-4000-8000-${(++counter).toString(16).padStart(12, "0")}`;
|
|
168
|
+
const nowIso = () => new Date(clockMs).toISOString();
|
|
169
|
+
const register = (def) => {
|
|
170
|
+
if (!defs.has(def.id)) defs.set(def.id, def);
|
|
171
|
+
};
|
|
172
|
+
for (const d of options.entities ?? []) register(d);
|
|
173
|
+
const templateSets = /* @__PURE__ */ new Map();
|
|
174
|
+
for (const item of options.implementations ?? []) {
|
|
175
|
+
if (item.serverKind === "templates") templateSets.set(item.notice.id, item);
|
|
176
|
+
else impls.set(item.contract.id, item);
|
|
177
|
+
}
|
|
178
|
+
for (const set of options.templates ?? []) templateSets.set(set.notice.id, set);
|
|
179
|
+
const push = (map, id, value) => void map.set(id, [...map.get(id) ?? [], value]);
|
|
180
|
+
for (const g of options.guards ?? []) {
|
|
181
|
+
if (g.phase === "write") push(writeRules, g.target.id, g);
|
|
182
|
+
else if (g.phase === "operation") push(opGuards, g.target.id, g);
|
|
183
|
+
else push(prechecks, g.target.id, g);
|
|
184
|
+
if (g.phase === "write") register(g.target);
|
|
185
|
+
}
|
|
186
|
+
for (const f of options.fixtures ?? []) {
|
|
187
|
+
const overlayId = f[OVERLAY_OF];
|
|
188
|
+
if (typeof overlayId === "string") {
|
|
189
|
+
const row = f;
|
|
190
|
+
store.overlay(overlayId).set(String(row.baseKey), structuredClone({ ...row }));
|
|
191
|
+
} else {
|
|
192
|
+
const fx = f;
|
|
193
|
+
const record = structuredClone({ ...fx.record });
|
|
194
|
+
delete record.ref;
|
|
195
|
+
store.table(fx.ref.entity).set(fx.ref.key, record);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const SYSTEM_TYPES = { key: { kind: "string" }, createdAt: { kind: "datetime" }, updatedAt: { kind: "datetime" } };
|
|
199
|
+
const typeAt = (def, key) => def?.fields[key]?.type ?? (def !== void 0 && def.resource.kind === "entity" ? SYSTEM_TYPES[key] : void 0);
|
|
200
|
+
const hiddenField = (def, key) => {
|
|
201
|
+
const required = (def?.resource.access?.fields ?? {})[key] ?? [];
|
|
202
|
+
return required.some((p) => !user.has(p));
|
|
203
|
+
};
|
|
204
|
+
const subjectRef = () => ({ entity: "core.user", key: user.userId });
|
|
205
|
+
const matches = (s, def, row, filter, trusted) => {
|
|
206
|
+
for (const [path, cond] of Object.entries(filter.fields ?? {}).sort(([a], [b]) => a < b ? -1 : 1)) {
|
|
207
|
+
const [value, type] = resolvePath(s, def, row, path, trusted);
|
|
208
|
+
if (!condition(cond, value, type, path)) return false;
|
|
209
|
+
}
|
|
210
|
+
const alternatives = filter.or ?? [];
|
|
211
|
+
return alternatives.length === 0 || alternatives.some((alt) => matches(s, def, row, alt, trusted));
|
|
212
|
+
};
|
|
213
|
+
const resolvePath = (s, def, row, path, trusted) => {
|
|
214
|
+
const segments = path.split(".");
|
|
215
|
+
if (segments.length > MAX_PATH) fail("data.invalidQuery", `path "${path}" is deeper than ${MAX_PATH}`);
|
|
216
|
+
let current = row;
|
|
217
|
+
let currentDef = def;
|
|
218
|
+
for (const seg of segments.slice(0, -1)) {
|
|
219
|
+
const type2 = typeAt(currentDef, seg);
|
|
220
|
+
if (currentDef !== void 0 && type2 === void 0) fail("data.unknownField", `"${seg}" on ${currentDef.id}`);
|
|
221
|
+
if (!trusted && hiddenField(currentDef, seg)) fail("data.fieldNotAccessible", `"${seg}" on ${currentDef?.id ?? "?"}`);
|
|
222
|
+
if (type2 !== void 0 && type2.kind !== "ref") fail("data.invalidQuery", `"${seg}" is not a ref, cannot continue path "${path}"`);
|
|
223
|
+
const target = current === void 0 ? void 0 : current[seg];
|
|
224
|
+
const targetDef = type2?.entity === void 0 ? void 0 : defs.get(type2.entity);
|
|
225
|
+
const next = target?.entity === void 0 || target.key === void 0 ? void 0 : s.table(target.entity).get(target.key);
|
|
226
|
+
current = next !== void 0 && targetDef !== void 0 && !trusted && !visible(s, targetDef, next) ? void 0 : next;
|
|
227
|
+
currentDef = targetDef;
|
|
228
|
+
}
|
|
229
|
+
const last = segments[segments.length - 1] ?? "";
|
|
230
|
+
const type = typeAt(currentDef, last);
|
|
231
|
+
if (currentDef !== void 0 && type === void 0) fail("data.unknownField", `"${last}" on ${currentDef.id}`);
|
|
232
|
+
if (!trusted && hiddenField(currentDef, last)) fail("data.fieldNotAccessible", `"${last}" on ${currentDef?.id ?? "?"}`);
|
|
233
|
+
return [current === void 0 ? null : current[last] ?? null, type];
|
|
234
|
+
};
|
|
235
|
+
const resolveValue = (raw) => {
|
|
236
|
+
if (isRecord(raw) && Object.keys(raw).length === 1 && "$" in raw) {
|
|
237
|
+
if (raw.$ !== "user") fail("data.invalidQuery", `unknown placeholder ${JSON.stringify(raw)}`);
|
|
238
|
+
return subjectRef();
|
|
239
|
+
}
|
|
240
|
+
return raw;
|
|
241
|
+
};
|
|
242
|
+
const condition = (c, value, type, field) => {
|
|
243
|
+
const present = value !== null && value !== void 0;
|
|
244
|
+
const checked = (raw) => {
|
|
245
|
+
const v = resolveValue(raw);
|
|
246
|
+
if (v !== null && type !== void 0) {
|
|
247
|
+
try {
|
|
248
|
+
validate({ ...type, optional: void 0, nullable: void 0 }, v);
|
|
249
|
+
} catch (e) {
|
|
250
|
+
fail("data.invalidQuery", `value for "${field}": ${e.message}`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return v;
|
|
254
|
+
};
|
|
255
|
+
const eq = (raw) => {
|
|
256
|
+
const v = checked(raw);
|
|
257
|
+
return present && v !== null && compare(type, value, v) === 0;
|
|
258
|
+
};
|
|
259
|
+
const parts = [];
|
|
260
|
+
if (c.eq !== void 0) parts.push(c.eq === null ? !present : eq(c.eq));
|
|
261
|
+
if (c.ne !== void 0) parts.push(c.ne === null ? present : !present || !eq(c.ne));
|
|
262
|
+
if (c.in !== void 0) {
|
|
263
|
+
if (c.in.length > MAX_IN) fail("data.invalidQuery", `"${field}": in-list longer than ${MAX_IN}`);
|
|
264
|
+
parts.push(c.in.length === 0 ? false : c.in.map(checked).some((v) => present && v !== null && compare(type, value, v) === 0));
|
|
265
|
+
}
|
|
266
|
+
for (const [op, raw] of [["lt", c.lt], ["lte", c.lte], ["gt", c.gt], ["gte", c.gte]]) {
|
|
267
|
+
if (raw === void 0) continue;
|
|
268
|
+
if (type !== void 0 && !ORDERABLE.has(type.kind)) fail("data.invalidQuery", `"${field}" (${type.kind}) cannot be compared with ${op}`);
|
|
269
|
+
const v = checked(raw);
|
|
270
|
+
const d = present && v !== null ? compare(type, value, v) : void 0;
|
|
271
|
+
parts.push(d !== void 0 && (op === "lt" ? d < 0 : op === "lte" ? d <= 0 : op === "gt" ? d > 0 : d >= 0));
|
|
272
|
+
}
|
|
273
|
+
if (c.isNull !== void 0) parts.push(c.isNull ? !present : present);
|
|
274
|
+
if (c.like !== void 0) {
|
|
275
|
+
if (type !== void 0 && type.kind !== "string" && type.kind !== "enum") fail("data.invalidQuery", `"${field}" (${type.kind}) does not support like`);
|
|
276
|
+
parts.push(present && likeToRegExp(c.like).test(String(value)));
|
|
277
|
+
}
|
|
278
|
+
if (parts.length === 0) fail("data.invalidQuery", `empty condition for "${field}"`);
|
|
279
|
+
return parts.every(Boolean);
|
|
280
|
+
};
|
|
281
|
+
const visible = (s, def, row) => {
|
|
282
|
+
const rules = def.resource.access?.read ?? [];
|
|
283
|
+
if (rules.length === 0) return true;
|
|
284
|
+
for (const rule of rules) {
|
|
285
|
+
if (!user.has(rule.permission ?? "")) continue;
|
|
286
|
+
if (rule.all === true) return true;
|
|
287
|
+
if (rule.rows !== void 0 && matches(s, def, row, rule.rows, true)) return true;
|
|
288
|
+
}
|
|
289
|
+
return false;
|
|
290
|
+
};
|
|
291
|
+
const withRef = (def, row) => isOverlay(def) ? row : { ...row, ref: { entity: def.id, key: String(row.key) } };
|
|
292
|
+
const project = (def, row) => {
|
|
293
|
+
const out = {};
|
|
294
|
+
for (const [k, v] of Object.entries(row)) if (!(k in def.fields) || !hiddenField(def, k)) out[k] = structuredClone(v);
|
|
295
|
+
return withRef(def, out);
|
|
296
|
+
};
|
|
297
|
+
const makeReader = (s) => {
|
|
298
|
+
const matching = (entity, where) => {
|
|
299
|
+
register(entity);
|
|
300
|
+
const st = s();
|
|
301
|
+
const filter = where === void 0 ? {} : compileFilter(where);
|
|
302
|
+
return [...st.table(entity.id).values()].filter((r) => visible(st, entity, r)).filter((r) => matches(st, entity, r, filter, false));
|
|
303
|
+
};
|
|
304
|
+
const find = (entity, q = {}) => {
|
|
305
|
+
const st = s();
|
|
306
|
+
const limit = q.limit ?? 0;
|
|
307
|
+
const offset = q.offset ?? 0;
|
|
308
|
+
if (limit < 0 || offset < 0) fail("data.invalidQuery", "limit and offset must not be negative");
|
|
309
|
+
let rows = matching(entity, q.where);
|
|
310
|
+
const orders = (q.orderBy ?? []).map((o) => ({ field: o.field, desc: o.desc === true }));
|
|
311
|
+
for (const o of orders) {
|
|
312
|
+
const sample = rows[0];
|
|
313
|
+
const [, type] = sample === void 0 ? [null, typeAt(entity, o.field.split(".")[0] ?? "")] : resolvePath(st, entity, sample, o.field, false);
|
|
314
|
+
if (type !== void 0 && !ORDERABLE.has(type.kind) && type.kind !== "ref" && type.kind !== "bool") fail("data.invalidQuery", `"${o.field}" (${type.kind}) cannot be ordered`);
|
|
315
|
+
}
|
|
316
|
+
const keyed = rows.map((r) => ({ r, vals: orders.map((o) => resolvePath(st, entity, r, o.field, false)) }));
|
|
317
|
+
keyed.sort((a, b) => {
|
|
318
|
+
for (const [i, o] of orders.entries()) {
|
|
319
|
+
const [av, type] = a.vals[i] ?? [null, void 0];
|
|
320
|
+
const [bv] = b.vals[i] ?? [null, void 0];
|
|
321
|
+
const an = av === null || av === void 0;
|
|
322
|
+
const bn = bv === null || bv === void 0;
|
|
323
|
+
const d = an && bn ? 0 : an ? 1 : bn ? -1 : compare(type, av, bv);
|
|
324
|
+
if (d !== 0) return o.desc ? -d : d;
|
|
325
|
+
}
|
|
326
|
+
return order(String(a.r.key), String(b.r.key));
|
|
327
|
+
});
|
|
328
|
+
rows = keyed.map((k) => k.r);
|
|
329
|
+
return rows.slice(offset, offset + Math.min(limit === 0 ? DEFAULT_LIMIT : limit, MAX_LIMIT)).map((r) => project(entity, r));
|
|
330
|
+
};
|
|
331
|
+
const get = (def, ref) => {
|
|
332
|
+
register(def);
|
|
333
|
+
const st = s();
|
|
334
|
+
if (isOverlay(def)) {
|
|
335
|
+
const row2 = st.overlay(def.id).get(ref.key);
|
|
336
|
+
const base = st.tables.get(def.base.id)?.get(ref.key);
|
|
337
|
+
if (row2 === void 0 || base !== void 0 && !visible(st, defs.get(def.base.id) ?? def.base, base)) return null;
|
|
338
|
+
return project(def, row2);
|
|
339
|
+
}
|
|
340
|
+
if (ref.entity !== def.id) fail("data.invalidRef", `ref to "${ref.entity}" used with entity "${def.id}"`);
|
|
341
|
+
const row = st.table(def.id).get(ref.key);
|
|
342
|
+
return row === void 0 || !visible(st, def, row) ? null : project(def, row);
|
|
343
|
+
};
|
|
344
|
+
const count = (entity, where) => matching(entity, where).length;
|
|
345
|
+
return {
|
|
346
|
+
get: (async (def, ref) => get(def, ref)),
|
|
347
|
+
find: (async (entity, q) => {
|
|
348
|
+
return find(entity, q);
|
|
349
|
+
}),
|
|
350
|
+
count: (async (entity, where) => count(entity, where))
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
const logger = () => {
|
|
354
|
+
const at = (level) => (message, fields) => void logs.push({ level, message: fields === void 0 ? message : `${message} ${JSON.stringify(fields)}` });
|
|
355
|
+
return { debug: at("debug"), info: at("info"), warn: at("warn"), error: at("error") };
|
|
356
|
+
};
|
|
357
|
+
const invocation = (parentId) => ({
|
|
358
|
+
id: nextId("inv"),
|
|
359
|
+
trigger: options.trigger ?? "ui",
|
|
360
|
+
...parentId === void 0 ? {} : { parentId }
|
|
361
|
+
});
|
|
362
|
+
const secrets = {
|
|
363
|
+
get: async (name) => options.secrets?.[name] ?? fail("runtime.secretUndeclared", `secret "${name}" is not provided to this test host`)
|
|
364
|
+
};
|
|
365
|
+
const readContext = (s, info, open = () => void 0) => {
|
|
366
|
+
const reader = makeReader(s);
|
|
367
|
+
return {
|
|
368
|
+
user,
|
|
369
|
+
invocation: info,
|
|
370
|
+
log: logger(),
|
|
371
|
+
get: (async (...a) => (open(), reader.get(...a))),
|
|
372
|
+
find: (async (...a) => (open(), reader.find(...a))),
|
|
373
|
+
count: (async (...a) => (open(), reader.count(...a))),
|
|
374
|
+
query: (async (q, input) => {
|
|
375
|
+
open();
|
|
376
|
+
return runQuery(s(), q, input, info.id);
|
|
377
|
+
})
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
const guardContext = (ctx) => Object.freeze({ user: ctx.user, invocation: ctx.invocation, log: ctx.log, get: ctx.get, find: ctx.find, count: ctx.count, query: ctx.query });
|
|
381
|
+
const runQuery = async (snapshot, q, input, parent) => {
|
|
382
|
+
if (q.kind !== "query") return fail("runtime.invalidInput", `"${q.id}" is a ${q.kind}, not a query`);
|
|
383
|
+
const valid = validateInput(q, input);
|
|
384
|
+
const handler = implementationOf(q.id).handler;
|
|
385
|
+
const out = await handler(readContext(() => snapshot, invocation(parent)), valid);
|
|
386
|
+
return decode(q.output, encode(q.output, out));
|
|
387
|
+
};
|
|
388
|
+
const checkSignal = (target, name, payload, starting) => {
|
|
389
|
+
const run = runs.get(target.instance);
|
|
390
|
+
const workflowId = run?.workflow.id ?? [...committed.started, ...starting].find((x) => x.instance === target.instance)?.workflow;
|
|
391
|
+
if (workflowId === void 0 || workflowId !== target.workflow) {
|
|
392
|
+
return fail("workflow.unknownInstance", `no started instance "${target.instance}" of workflow "${target.workflow}"`);
|
|
393
|
+
}
|
|
394
|
+
const schema = (run?.workflow ?? workflowDefs.get(workflowId))?.signals[name]?.schema;
|
|
395
|
+
if (schema === void 0) return fail("workflow.unknownSignal", `workflow "${workflowId}" declares no signal "${name}"`);
|
|
396
|
+
try {
|
|
397
|
+
return { workflow: workflowId, instance: target.instance, name, payload: json(encode(schema, payload)) };
|
|
398
|
+
} catch (e) {
|
|
399
|
+
return fail("workflow.invalidSignal", `signal "${name}" of "${workflowId}": ${e.message}`);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
const deliverSignal = (signal) => {
|
|
403
|
+
committed.signals.push(signal);
|
|
404
|
+
const run = runs.get(signal.instance);
|
|
405
|
+
if (run !== void 0) run.push(signal.name, signal.payload);
|
|
406
|
+
else inboxes.set(signal.instance, [...inboxes.get(signal.instance) ?? [], { name: signal.name, payload: signal.payload }]);
|
|
407
|
+
};
|
|
408
|
+
const validateInput = (c, input) => {
|
|
409
|
+
try {
|
|
410
|
+
return decode(c.input, encode(c.input, input));
|
|
411
|
+
} catch (e) {
|
|
412
|
+
return fail("runtime.invalidInput", `${c.id}: ${e.message}`);
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
const implementationOf = (id) => {
|
|
416
|
+
const impl = impls.get(id);
|
|
417
|
+
if (impl === void 0) return fail("test.noImplementation", `no implementation of "${id}" is bound in this test host; pass it in createTestHost({ implementations })`);
|
|
418
|
+
return impl;
|
|
419
|
+
};
|
|
420
|
+
const writeRuleHooks = async (tx, def, op, existing, proposed) => {
|
|
421
|
+
const rules = writeRules.get(def.id) ?? [];
|
|
422
|
+
if (rules.length === 0) return;
|
|
423
|
+
const changed = Object.keys(def.fields).filter((k) => JSON.stringify(existing?.[k] ?? null) !== JSON.stringify(proposed?.[k] ?? null));
|
|
424
|
+
const change = {
|
|
425
|
+
op,
|
|
426
|
+
existing: existing === null ? null : withRef(def, structuredClone(existing)),
|
|
427
|
+
proposed: proposed === null ? null : withRef(def, structuredClone(proposed)),
|
|
428
|
+
changed
|
|
429
|
+
};
|
|
430
|
+
for (const rule of rules) await rule.handler(guardContext(tx), change);
|
|
431
|
+
};
|
|
432
|
+
const callCallable = async (tx, callable, input) => {
|
|
433
|
+
const valid = validateInput(callable, input);
|
|
434
|
+
for (const g of opGuards.get(callable.id) ?? []) await g.handler(guardContext(tx), valid);
|
|
435
|
+
const out = await implementationOf(callable.id).handler(tx, valid);
|
|
436
|
+
return callable.output === void 0 ? void 0 : decode(callable.output, encode(callable.output, out));
|
|
437
|
+
};
|
|
438
|
+
const makeTx = (scope) => {
|
|
439
|
+
const guard = () => {
|
|
440
|
+
if (!scope.open) fail("runtime.txClosed", "transaction is closed");
|
|
441
|
+
};
|
|
442
|
+
const reads = readContext(() => scope.store, scope.info, guard);
|
|
443
|
+
const own = (def, op) => {
|
|
444
|
+
register(def);
|
|
445
|
+
if (def.entityKind === "native") fail("data.nativeWrite", `${op} on native entity "${def.id}": native entities are read-only through generic data calls`);
|
|
446
|
+
};
|
|
447
|
+
const writable = (def, values) => {
|
|
448
|
+
for (const k of Object.keys(values)) {
|
|
449
|
+
if (values[k] !== void 0 && hiddenField(def, k)) fail("data.fieldNotAccessible", `"${k}" on ${def.id}`);
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
const checkUnique = (def, row, exceptKey) => {
|
|
453
|
+
for (const [k, f] of Object.entries(def.fields)) {
|
|
454
|
+
if (f.spec.unique !== true || row[k] === null || row[k] === void 0) continue;
|
|
455
|
+
for (const other of scope.store.table(def.id).values()) {
|
|
456
|
+
if (other.key !== exceptKey && JSON.stringify(other[k]) === JSON.stringify(row[k])) fail("data.unique", `field "${k}" already holds this value`);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
const shapeOf = (def, keys) => {
|
|
461
|
+
const properties = keys.map((k) => {
|
|
462
|
+
const f = def.fields[k];
|
|
463
|
+
if (f === void 0) return fail("data.unknownField", `"${k}" on ${def.id}`);
|
|
464
|
+
return { name: k, type: f.type };
|
|
465
|
+
});
|
|
466
|
+
return { type: { kind: "object", properties } };
|
|
467
|
+
};
|
|
468
|
+
const tx = {
|
|
469
|
+
...reads,
|
|
470
|
+
insert: async (def, values) => {
|
|
471
|
+
guard();
|
|
472
|
+
own(def, "insert");
|
|
473
|
+
writable(def, values);
|
|
474
|
+
const row = {};
|
|
475
|
+
for (const [k, f] of Object.entries(def.fields)) row[k] = values[k] !== void 0 ? values[k] : f.spec.default ?? null;
|
|
476
|
+
for (const k of Object.keys(values)) if (!(k in def.fields)) fail("data.unknownField", `"${k}" on ${def.id}`);
|
|
477
|
+
try {
|
|
478
|
+
encode(shapeOf(def, Object.keys(def.fields)), row);
|
|
479
|
+
} catch (e) {
|
|
480
|
+
fail("data.invalidValue", e.message);
|
|
481
|
+
}
|
|
482
|
+
checkUnique(def, row, void 0);
|
|
483
|
+
const full = { key: nextKey(), createdAt: nowIso(), updatedAt: nowIso(), rowVersion: 1, ...structuredClone(row) };
|
|
484
|
+
await writeRuleHooks(tx, def, "insert", null, full);
|
|
485
|
+
scope.store.table(def.id).set(String(full.key), full);
|
|
486
|
+
return project(def, full);
|
|
487
|
+
},
|
|
488
|
+
update: async (def, ref, patch, opts) => {
|
|
489
|
+
guard();
|
|
490
|
+
own(def, "update");
|
|
491
|
+
writable(def, patch);
|
|
492
|
+
const existing = scope.store.table(def.id).get(ref.key);
|
|
493
|
+
if (existing === void 0 || !visible(scope.store, def, existing)) return fail("data.notFound", `${def.id} ${ref.key}`);
|
|
494
|
+
if (opts?.rowVersion !== void 0 && opts.rowVersion !== existing.rowVersion) {
|
|
495
|
+
fail("data.versionConflict", `${def.id} ${ref.key} is at version ${String(existing.rowVersion)}, expected ${opts.rowVersion}`);
|
|
496
|
+
}
|
|
497
|
+
const keys = Object.keys(patch).filter((k) => patch[k] !== void 0);
|
|
498
|
+
try {
|
|
499
|
+
encode(shapeOf(def, keys), Object.fromEntries(keys.map((k) => [k, patch[k]])));
|
|
500
|
+
} catch (e) {
|
|
501
|
+
fail("data.invalidValue", e.message);
|
|
502
|
+
}
|
|
503
|
+
const next = { ...structuredClone(existing), ...structuredClone(Object.fromEntries(keys.map((k) => [k, patch[k]]))) };
|
|
504
|
+
checkUnique(def, next, ref.key);
|
|
505
|
+
next.updatedAt = nowIso();
|
|
506
|
+
next.rowVersion = Number(existing.rowVersion) + 1;
|
|
507
|
+
await writeRuleHooks(tx, def, "update", existing, next);
|
|
508
|
+
scope.store.table(def.id).set(ref.key, next);
|
|
509
|
+
return project(def, next);
|
|
510
|
+
},
|
|
511
|
+
delete: async (def, ref) => {
|
|
512
|
+
guard();
|
|
513
|
+
own(def, "delete");
|
|
514
|
+
const existing = scope.store.table(def.id).get(ref.key);
|
|
515
|
+
if (existing === void 0 || !visible(scope.store, def, existing)) return fail("data.notFound", `${def.id} ${ref.key}`);
|
|
516
|
+
await writeRuleHooks(tx, def, "delete", existing, null);
|
|
517
|
+
scope.store.table(def.id).delete(ref.key);
|
|
518
|
+
},
|
|
519
|
+
put: async (overlay, base, values) => {
|
|
520
|
+
guard();
|
|
521
|
+
register(overlay);
|
|
522
|
+
writable(overlay, values);
|
|
523
|
+
const baseTable = scope.store.tables.get(overlay.base.id);
|
|
524
|
+
if (baseTable !== void 0 && !baseTable.has(base.key)) fail("data.notFound", `${overlay.base.id} ${base.key}`);
|
|
525
|
+
const keys = Object.keys(values).filter((k) => values[k] !== void 0);
|
|
526
|
+
try {
|
|
527
|
+
encode(shapeOf(overlay, keys), Object.fromEntries(keys.map((k) => [k, values[k]])));
|
|
528
|
+
} catch (e) {
|
|
529
|
+
fail("data.invalidValue", e.message);
|
|
530
|
+
}
|
|
531
|
+
const existing = scope.store.overlay(overlay.id).get(base.key);
|
|
532
|
+
const row = existing === void 0 ? { baseKey: base.key } : structuredClone(existing);
|
|
533
|
+
for (const [k, f] of Object.entries(overlay.fields)) {
|
|
534
|
+
if (values[k] !== void 0) row[k] = structuredClone(values[k]);
|
|
535
|
+
else if (!(k in row)) row[k] = f.spec.default ?? null;
|
|
536
|
+
}
|
|
537
|
+
scope.store.overlay(overlay.id).set(base.key, row);
|
|
538
|
+
return project(overlay, row);
|
|
539
|
+
},
|
|
540
|
+
call: async (callable, input) => {
|
|
541
|
+
guard();
|
|
542
|
+
const c = callable;
|
|
543
|
+
if (!(c.kind === "operation" || c.kind === "command" && c.atomic === true)) {
|
|
544
|
+
fail("runtime.ordinaryCommandInTx", `tx.call accepts only operations and atomic commands, not ${c.kind === "command" ? "ordinary command " : c.kind + " "}"${c.id}"`);
|
|
545
|
+
}
|
|
546
|
+
return callCallable(tx, callable, input);
|
|
547
|
+
},
|
|
548
|
+
emit: async (event, args) => {
|
|
549
|
+
guard();
|
|
550
|
+
if (event.subject !== void 0 && args.subject?.entity !== event.subject.id) fail("runtime.invalidInput", `event "${event.id}" needs a subject of "${event.subject.id}"`);
|
|
551
|
+
scope.pending.emitted.push({ event: event.id, subject: args.subject, payload: encode(event.payload, args.payload), initiator: user.userId });
|
|
552
|
+
},
|
|
553
|
+
notify: async (notice, args) => {
|
|
554
|
+
guard();
|
|
555
|
+
if (notice.subject !== void 0 && args.subject?.entity !== notice.subject.id) fail("runtime.invalidInput", `notice "${notice.id}" needs a subject of "${notice.subject.id}"`);
|
|
556
|
+
if (args.to.length === 0 || args.channels.length === 0) fail("runtime.invalidInput", `notice "${notice.id}" needs recipients and channels`);
|
|
557
|
+
if (templateSets.size > 0 && !templateSets.has(notice.id)) {
|
|
558
|
+
fail("notify.noTemplates", `no templates(...) for notice "${notice.id}" are bound in this test host; pass them in createTestHost({ templates })`);
|
|
559
|
+
}
|
|
560
|
+
const sent = { notice: notice.id, subject: args.subject, payload: encode(notice.payload, args.payload), to: json(args.to), channels: [...args.channels] };
|
|
561
|
+
scope.pending.notices.push({ sent, schema: notice.payload, seq: nextId("ntc") });
|
|
562
|
+
},
|
|
563
|
+
start: async (wf, input, opts) => {
|
|
564
|
+
guard();
|
|
565
|
+
if (!scope.derived && opts?.key === void 0) fail("runtime.startKeyRequired", `tx.start("${wf.id}") needs { key } outside subscriptions and workflows`);
|
|
566
|
+
const known = opts?.key === void 0 ? void 0 : [...committed.started, ...scope.pending.started].find((x) => x.workflow === wf.id && x.key === opts.key);
|
|
567
|
+
if (known !== void 0) return { workflow: wf.id, instance: known.instance };
|
|
568
|
+
const instance = nextId("wf");
|
|
569
|
+
scope.pending.started.push({ workflow: wf.id, instance, key: opts?.key, input: encode(wf.input, validateInput(wf, input)) });
|
|
570
|
+
workflowDefs.set(wf.id, wf);
|
|
571
|
+
return { workflow: wf.id, instance };
|
|
572
|
+
},
|
|
573
|
+
signal: async (target, name, payload) => {
|
|
574
|
+
guard();
|
|
575
|
+
scope.pending.signals.push(checkSignal(target, name, payload, scope.pending.started));
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
return tx;
|
|
579
|
+
};
|
|
580
|
+
const channelTargets = async (recipient, channel, locale) => {
|
|
581
|
+
if (recipient.kind === "address") {
|
|
582
|
+
const address = recipient.address[channel];
|
|
583
|
+
return address === void 0 || address === "" ? { targets: [], reason: `the address has no ${channel} entry` } : { targets: [address] };
|
|
584
|
+
}
|
|
585
|
+
if (recipient.kind === "user") {
|
|
586
|
+
const key = recipient.user.key;
|
|
587
|
+
const row = store.table("core.user").get(key);
|
|
588
|
+
if (row === void 0) {
|
|
589
|
+
return { targets: [], reason: `no core.user fixture with key "${key}": add fixture(core.User, { ... }, { key: "${key}" }) to createTestHost({ fixtures })` };
|
|
590
|
+
}
|
|
591
|
+
if (typeof row.uiLanguage === "string" && row.uiLanguage !== "") locale.value = row.uiLanguage;
|
|
592
|
+
const value = channel === "sms" ? row.phone : channel === "email" ? row.email : key;
|
|
593
|
+
return typeof value === "string" && value !== "" ? { targets: [value] } : { targets: [], reason: `the core.user fixture "${key}" has no ${channel === "sms" ? "phone" : "email"}` };
|
|
594
|
+
}
|
|
595
|
+
if (channel === "inApp") return { targets: [], reason: "inApp notifications address ERP users, not records" };
|
|
596
|
+
const record = recipient.record;
|
|
597
|
+
let found = options.contacts === void 0 ? void 0 : await options.contacts(record);
|
|
598
|
+
if (found === void 0) {
|
|
599
|
+
const resolver = [...impls.values()].find((i) => i.contract.kind === "contactResolver" && i.contract.entity.id === record.entity);
|
|
600
|
+
if (resolver === void 0) {
|
|
601
|
+
return { targets: [], reason: `no contact data for ${record.entity}: pass createTestHost({ contacts }) or bind its contactResolver in implementations` };
|
|
602
|
+
}
|
|
603
|
+
found = await resolver.handler(queryContext(), record);
|
|
604
|
+
}
|
|
605
|
+
const list = found[channel] ?? [];
|
|
606
|
+
return list.length > 0 ? { targets: [...list] } : { targets: [], reason: `the contact data of ${record.entity} "${record.key}" has no ${channel} target` };
|
|
607
|
+
};
|
|
608
|
+
const evaluatePolicies = async (sent, recipient, channel, address) => {
|
|
609
|
+
if (recipient.kind !== "record") return { allow: true };
|
|
610
|
+
const bound = [...impls.values()].filter((i) => i.contract.kind === "deliveryPolicy" && i.contract.entity.id === recipient.record.entity).sort((a, b) => a.contract.id < b.contract.id ? -1 : a.contract.id > b.contract.id ? 1 : 0);
|
|
611
|
+
if (bound.length === 0) return { allow: true };
|
|
612
|
+
const { key, version } = noticeKey(sent.notice);
|
|
613
|
+
const owner = sent.notice.split(".").slice(0, 2).join(".");
|
|
614
|
+
const request = {
|
|
615
|
+
notice: { key, version, snapshot: options.snapshot ?? `${owner}@0.0.0` },
|
|
616
|
+
subject: sent.subject === void 0 ? null : { entity: sent.subject.entity, key: sent.subject.key },
|
|
617
|
+
recipient: { kind: "record", ref: recipient.record, address: null },
|
|
618
|
+
channel,
|
|
619
|
+
target: { address, deviceId: null }
|
|
620
|
+
};
|
|
621
|
+
for (const impl of bound) {
|
|
622
|
+
let decision;
|
|
623
|
+
try {
|
|
624
|
+
decision = await impl.handler(queryContext(), json(request));
|
|
625
|
+
} catch (e) {
|
|
626
|
+
return { allow: false, failed: true, reason: `delivery policy ${impl.contract.id} failed: ${e instanceof Error ? e.message : String(e)}` };
|
|
627
|
+
}
|
|
628
|
+
const verdict = decision;
|
|
629
|
+
if (typeof verdict !== "object" || verdict === null || typeof verdict.allow !== "boolean") {
|
|
630
|
+
return { allow: false, failed: true, reason: `delivery policy ${impl.contract.id} must return {allow: boolean, reason?: string}` };
|
|
631
|
+
}
|
|
632
|
+
if (!verdict.allow) {
|
|
633
|
+
const reason = typeof verdict.reason === "string" && POLICY_REASON.test(verdict.reason) ? verdict.reason : "";
|
|
634
|
+
return { allow: false, failed: false, reason: reason === "" ? "policy_denied" : `policy_denied:${reason}` };
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return { allow: true };
|
|
638
|
+
};
|
|
639
|
+
const deliverNotice = async ({ sent, schema, seq }) => {
|
|
640
|
+
const set = templateSets.get(sent.notice);
|
|
641
|
+
const renderers = set?.renderers ?? {};
|
|
642
|
+
for (const raw of sent.to) {
|
|
643
|
+
const recipient = raw;
|
|
644
|
+
for (const channel of sent.channels) {
|
|
645
|
+
const record = (partial) => void deliveries.push({ notice: sent.notice, channel, recipient, ...partial });
|
|
646
|
+
const locale = { value: user.locale ?? "en" };
|
|
647
|
+
const resolved = await channelTargets(recipient, channel, locale);
|
|
648
|
+
if (resolved.targets.length === 0) {
|
|
649
|
+
record({ target: void 0, status: "skipped", reason: resolved.reason ?? "no target" });
|
|
650
|
+
continue;
|
|
651
|
+
}
|
|
652
|
+
const render = renderers[channel];
|
|
653
|
+
for (const target of resolved.targets) {
|
|
654
|
+
if (render === void 0) {
|
|
655
|
+
record({ target, status: "skipped", reason: `the templates of ${sent.notice} have no ${channel} renderer` });
|
|
656
|
+
continue;
|
|
657
|
+
}
|
|
658
|
+
if (channel !== "inApp") {
|
|
659
|
+
const verdict = await evaluatePolicies(sent, recipient, channel, target);
|
|
660
|
+
if (!verdict.allow) {
|
|
661
|
+
record({ target, status: verdict.failed ? "failed" : "skipped", reason: verdict.reason });
|
|
662
|
+
continue;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
let content;
|
|
666
|
+
const idempotencyKey = `${seq}:${channel}:${target}`;
|
|
667
|
+
try {
|
|
668
|
+
const rendered = await render({ payload: decode(schema, sent.payload), subject: sent.subject, locale: locale.value });
|
|
669
|
+
content = json(rendered);
|
|
670
|
+
if (channel === "sms") await fakes.sms.send({ to: target, text: String(rendered), idempotencyKey });
|
|
671
|
+
else if (channel === "email") await fakes.email.send({ to: target, ...rendered, idempotencyKey });
|
|
672
|
+
else if (channel === "push") await fakes.push.send({ to: target, ...rendered, idempotencyKey });
|
|
673
|
+
else await fakes.inApp.send({ to: target, ...rendered, idempotencyKey });
|
|
674
|
+
} catch (e) {
|
|
675
|
+
record({ target, status: "failed", reason: e instanceof Error ? e.message : String(e) });
|
|
676
|
+
continue;
|
|
677
|
+
}
|
|
678
|
+
record({ target, status: "delivered", content });
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
const flush = async (pending) => {
|
|
684
|
+
committed.emitted.push(...pending.emitted);
|
|
685
|
+
committed.notices.push(...pending.notices.map((n) => n.sent));
|
|
686
|
+
committed.started.push(...pending.started);
|
|
687
|
+
for (const signal of pending.signals) deliverSignal(signal);
|
|
688
|
+
if (templateSets.size > 0) for (const n of pending.notices) await deliverNotice(n);
|
|
689
|
+
};
|
|
690
|
+
const inTransaction = async (body, derived, info = invocation()) => {
|
|
691
|
+
const scope = { store: store.clone(), pending: { emitted: [], notices: [], started: [], signals: [] }, open: true, derived, info };
|
|
692
|
+
const tx = makeTx(scope);
|
|
693
|
+
try {
|
|
694
|
+
const result = await body(tx);
|
|
695
|
+
scope.open = false;
|
|
696
|
+
store = scope.store;
|
|
697
|
+
await flush(scope.pending);
|
|
698
|
+
return result;
|
|
699
|
+
} catch (e) {
|
|
700
|
+
scope.open = false;
|
|
701
|
+
throw e;
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
const queryContext = (info = invocation()) => readContext(() => store, info);
|
|
705
|
+
const commandContext = (info = invocation()) => {
|
|
706
|
+
let inTx = false;
|
|
707
|
+
const snapshot = queryContext(info);
|
|
708
|
+
const ctx = {
|
|
709
|
+
user,
|
|
710
|
+
invocation: info,
|
|
711
|
+
log: logger(),
|
|
712
|
+
secrets,
|
|
713
|
+
// Callable like the worker's `ctx.query`: it is the read-only snapshot context and runs a query.
|
|
714
|
+
query: Object.assign((q, input) => snapshot.query(q, input), snapshot),
|
|
715
|
+
async transaction(callback) {
|
|
716
|
+
if (inTx) fail("runtime.nestedTransaction", "ctx.transaction cannot be nested");
|
|
717
|
+
inTx = true;
|
|
718
|
+
try {
|
|
719
|
+
return await inTransaction((tx) => callback(tx), false, info);
|
|
720
|
+
} finally {
|
|
721
|
+
inTx = false;
|
|
722
|
+
}
|
|
723
|
+
},
|
|
724
|
+
call: (async (command, input) => {
|
|
725
|
+
if (inTx) fail("runtime.intentInTransaction", "ctx.call is not allowed while a transaction is open; finish the transaction first");
|
|
726
|
+
return invokeCommand(command, input, info.id);
|
|
727
|
+
}),
|
|
728
|
+
signal: (async (target, name, payload) => deliverSignal(checkSignal(target, name, payload, [])))
|
|
729
|
+
};
|
|
730
|
+
return ctx;
|
|
731
|
+
};
|
|
732
|
+
const invokeCommand = async (command, input, parent) => {
|
|
733
|
+
const valid = validateInput(command, input);
|
|
734
|
+
const info = invocation(parent);
|
|
735
|
+
const finish = (out) => command.output === void 0 ? void 0 : decode(command.output, encode(command.output, out));
|
|
736
|
+
if (command.atomic) {
|
|
737
|
+
return finish(await inTransaction((tx) => callCallable(tx, command, valid), false, info));
|
|
738
|
+
}
|
|
739
|
+
for (const g of prechecks.get(command.id) ?? []) await g.handler(guardContext(queryContext(info)), valid);
|
|
740
|
+
return finish(await implementationOf(command.id).handler(commandContext(info), valid));
|
|
741
|
+
};
|
|
742
|
+
class Suspend extends Error {
|
|
743
|
+
on;
|
|
744
|
+
constructor(on) {
|
|
745
|
+
super(`workflow suspended on ${on.kind} "${on.name}"`);
|
|
746
|
+
this.name = "Suspend";
|
|
747
|
+
this.on = on;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
const createWorkflow = (impl, input, instanceId) => {
|
|
751
|
+
const instance = instanceId ?? nextId("wf");
|
|
752
|
+
const workflow = impl.contract;
|
|
753
|
+
const validInput = validateInput(workflow, input);
|
|
754
|
+
const startedAs = committed.started.find((x) => x.instance === instance);
|
|
755
|
+
if (startedAs !== void 0 && startedAs.workflow !== workflow.id) {
|
|
756
|
+
fail("workflow.unknownInstance", `instance "${instance}" was started as "${startedAs.workflow}", not "${workflow.id}"`);
|
|
757
|
+
}
|
|
758
|
+
if (runs.has(instance)) fail("test.duplicateRun", `instance "${instance}" already has a run in this test host`);
|
|
759
|
+
const journal = /* @__PURE__ */ new Map();
|
|
760
|
+
const tasks = [];
|
|
761
|
+
const signals = (inboxes.get(instance) ?? []).map((x) => ({ ...x, consumed: false }));
|
|
762
|
+
inboxes.delete(instance);
|
|
763
|
+
workflowDefs.set(workflow.id, workflow);
|
|
764
|
+
runs.set(instance, { workflow, push: (name, payload) => void signals.push({ name, payload, consumed: false }) });
|
|
765
|
+
const run = async () => {
|
|
766
|
+
const counters = /* @__PURE__ */ new Map();
|
|
767
|
+
const occurrence = (name, kind) => {
|
|
768
|
+
const n = counters.get(name) ?? 0;
|
|
769
|
+
counters.set(name, n + 1);
|
|
770
|
+
const key = `${name}#${n}`;
|
|
771
|
+
const occ = journal.get(key);
|
|
772
|
+
if (occ !== void 0 && occ.kind !== kind) fail("workflow.nondeterminism", `occurrence ${key} was ${occ.kind}, now ${kind}`);
|
|
773
|
+
return { key, n, occ };
|
|
774
|
+
};
|
|
775
|
+
const done = (key, kind, result, prior) => void journal.set(key, { kind, status: "completed", result: result === void 0 ? null : json(result), attempts: (prior?.attempts ?? 0) + 1 });
|
|
776
|
+
const wf = {
|
|
777
|
+
user,
|
|
778
|
+
instance: { id: instance },
|
|
779
|
+
log: logger(),
|
|
780
|
+
secrets,
|
|
781
|
+
transaction: (async (name, body, txInput) => {
|
|
782
|
+
const { key, occ } = occurrence(name, "transaction");
|
|
783
|
+
if (occ?.status === "completed") return occ.result;
|
|
784
|
+
const callback = typeof body === "function" ? body : typeof txInput === "function" ? txInput : void 0;
|
|
785
|
+
const schema = callback !== void 0 && isRecord(body) ? body.output : void 0;
|
|
786
|
+
const result = callback !== void 0 ? await inTransaction(async (tx) => callback(tx), true) : await inTransaction((tx) => callCallable(tx, body, txInput), true);
|
|
787
|
+
if (schema !== void 0) encode(schema, result);
|
|
788
|
+
done(key, "transaction", result);
|
|
789
|
+
return result;
|
|
790
|
+
}),
|
|
791
|
+
step: (async (name, a, b) => {
|
|
792
|
+
const effect = typeof a === "function" ? a : b;
|
|
793
|
+
const schema = isRecord(a) ? a.output : void 0;
|
|
794
|
+
const { key, n, occ } = occurrence(name, "step");
|
|
795
|
+
if (occ?.status === "completed") return occ.result;
|
|
796
|
+
const attempt = occ ?? { kind: "step", status: "waiting", attempts: 0 };
|
|
797
|
+
journal.set(key, { ...attempt, attempts: attempt.attempts + 1 });
|
|
798
|
+
const value = await effect({ idempotencyKey: `${instance}:${name}:${n}` });
|
|
799
|
+
if (schema !== void 0) encode(schema, value);
|
|
800
|
+
done(key, "step", value, journal.get(key));
|
|
801
|
+
return value;
|
|
802
|
+
}),
|
|
803
|
+
sleep: async (name, duration) => {
|
|
804
|
+
const { key, n, occ } = occurrence(name, "sleep");
|
|
805
|
+
if (occ?.status === "completed") return;
|
|
806
|
+
const wakeAt = occ?.wakeAt ?? clockMs + durationMs(duration);
|
|
807
|
+
if (clockMs >= wakeAt) return done(key, "sleep", null);
|
|
808
|
+
journal.set(key, { kind: "sleep", status: "waiting", wakeAt, attempts: 1 });
|
|
809
|
+
throw new Suspend({ kind: "sleep", name, n, wakeAt: new Date(wakeAt).toISOString() });
|
|
810
|
+
},
|
|
811
|
+
waitFor: (async (name, signal, opts) => {
|
|
812
|
+
const { key, n, occ } = occurrence(name, "waitFor");
|
|
813
|
+
const reply = (result) => opts === void 0 ? result.payload : result;
|
|
814
|
+
if (occ?.status === "completed") return reply(occ.result);
|
|
815
|
+
const queued = signals.find((s) => !s.consumed && s.name === signal.name);
|
|
816
|
+
if (queued !== void 0) {
|
|
817
|
+
queued.consumed = true;
|
|
818
|
+
const result = { outcome: "received", payload: queued.payload };
|
|
819
|
+
done(key, "waitFor", result);
|
|
820
|
+
return reply(result);
|
|
821
|
+
}
|
|
822
|
+
const wakeAt = opts === void 0 ? void 0 : occ?.wakeAt ?? clockMs + durationMs(opts.timeout);
|
|
823
|
+
if (wakeAt !== void 0 && clockMs >= wakeAt) {
|
|
824
|
+
done(key, "waitFor", { outcome: "timeout" });
|
|
825
|
+
return reply({ outcome: "timeout" });
|
|
826
|
+
}
|
|
827
|
+
journal.set(key, { kind: "waitFor", status: "waiting", ...wakeAt === void 0 ? {} : { wakeAt }, attempts: 1 });
|
|
828
|
+
throw new Suspend({ kind: "signal", name, n });
|
|
829
|
+
}),
|
|
830
|
+
task: (async (name, spec) => {
|
|
831
|
+
const { key, n, occ } = occurrence(name, "task");
|
|
832
|
+
if (occ?.status === "completed") return occ.result;
|
|
833
|
+
let task = tasks.find((t) => t.name === name && t.n === n);
|
|
834
|
+
if (task === void 0) {
|
|
835
|
+
task = {
|
|
836
|
+
name,
|
|
837
|
+
n,
|
|
838
|
+
subject: spec.subject,
|
|
839
|
+
assignee: assigneeOf(spec.assignee),
|
|
840
|
+
status: "open",
|
|
841
|
+
mutableStatus: "open",
|
|
842
|
+
schema: spec.decision,
|
|
843
|
+
...spec.timeout === void 0 ? {} : { due: clockMs + durationMs(spec.timeout) }
|
|
844
|
+
};
|
|
845
|
+
tasks.push(task);
|
|
846
|
+
}
|
|
847
|
+
if (task.mutableStatus === "decided") {
|
|
848
|
+
const result = { outcome: "decided", decision: task.decision, by: task.by ?? user.userId };
|
|
849
|
+
done(key, "task", result);
|
|
850
|
+
return result;
|
|
851
|
+
}
|
|
852
|
+
if (task.due !== void 0 && clockMs >= task.due) {
|
|
853
|
+
task.mutableStatus = "expired";
|
|
854
|
+
done(key, "task", { outcome: "timeout" });
|
|
855
|
+
return { outcome: "timeout" };
|
|
856
|
+
}
|
|
857
|
+
journal.set(key, { kind: "task", status: "waiting", attempts: 1 });
|
|
858
|
+
throw new Suspend({ kind: "task", name, n });
|
|
859
|
+
}),
|
|
860
|
+
call: (async (name, command, callInput) => {
|
|
861
|
+
const { key, occ } = occurrence(name, "call");
|
|
862
|
+
if (occ?.status === "completed") return occ.result;
|
|
863
|
+
const result = await invokeCommand(command, callInput, instance);
|
|
864
|
+
done(key, "call", result);
|
|
865
|
+
return result;
|
|
866
|
+
}),
|
|
867
|
+
start: (async (name, child, childInput) => {
|
|
868
|
+
const { key, n, occ } = occurrence(name, "start");
|
|
869
|
+
if (occ?.status === "completed") return occ.result;
|
|
870
|
+
const childInstance = nextId("wf");
|
|
871
|
+
workflowDefs.set(child.id, child);
|
|
872
|
+
committed.started.push({ workflow: child.id, instance: childInstance, key: `${instance}:${name}:${n}`, input: encode(child.input, validateInput(child, childInput)) });
|
|
873
|
+
const handle = { workflow: child.id, instance: childInstance };
|
|
874
|
+
done(key, "start", handle);
|
|
875
|
+
return handle;
|
|
876
|
+
}),
|
|
877
|
+
now: async (name) => {
|
|
878
|
+
const { key, occ } = occurrence(name, "now");
|
|
879
|
+
if (occ?.status === "completed") return occ.result;
|
|
880
|
+
const at = nowIso();
|
|
881
|
+
done(key, "now", at);
|
|
882
|
+
return at;
|
|
883
|
+
},
|
|
884
|
+
uuid: async (name) => {
|
|
885
|
+
const { key, occ } = occurrence(name, "uuid");
|
|
886
|
+
if (occ?.status === "completed") return occ.result;
|
|
887
|
+
const id = nextKey();
|
|
888
|
+
done(key, "uuid", id);
|
|
889
|
+
return id;
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
try {
|
|
893
|
+
const value = await impl.handler(wf, validInput);
|
|
894
|
+
return { status: "completed", value };
|
|
895
|
+
} catch (e) {
|
|
896
|
+
if (e instanceof Suspend) return { status: "suspended", on: e.on };
|
|
897
|
+
return { status: "failed", error: e };
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
const driver = {
|
|
901
|
+
instance,
|
|
902
|
+
run,
|
|
903
|
+
decide(name, decision, opts = {}) {
|
|
904
|
+
const task = tasks.find((t) => t.name === name && t.mutableStatus === "open" && (opts.n === void 0 || t.n === opts.n));
|
|
905
|
+
if (task === void 0) return fail("workflow.noOpenTask", `no open task "${name}" in ${instance}`);
|
|
906
|
+
const required = permissionOf(task.assignee);
|
|
907
|
+
if (required !== void 0 && !holds(opts.by ?? user.userId, required)) {
|
|
908
|
+
return fail("workflow.forbidden", `user ${opts.by ?? user.userId} does not hold permission ${required}, which task "${name}" is assigned to`);
|
|
909
|
+
}
|
|
910
|
+
try {
|
|
911
|
+
encode(task.schema, decision);
|
|
912
|
+
} catch (e) {
|
|
913
|
+
return fail("workflow.invalidDecision", e.message);
|
|
914
|
+
}
|
|
915
|
+
task.decision = json(decision);
|
|
916
|
+
task.by = opts.by ?? user.userId;
|
|
917
|
+
task.mutableStatus = "decided";
|
|
918
|
+
},
|
|
919
|
+
signal(signal, payload) {
|
|
920
|
+
const name = typeof signal === "string" ? signal : signal.name;
|
|
921
|
+
deliverSignal(checkSignal({ workflow: workflow.id, instance }, name, payload, []));
|
|
922
|
+
},
|
|
923
|
+
get tasks() {
|
|
924
|
+
return tasks.map((t) => ({ name: t.name, n: t.n, subject: t.subject, assignee: t.assignee, status: t.mutableStatus }));
|
|
925
|
+
},
|
|
926
|
+
get journal() {
|
|
927
|
+
return [...journal].filter(([, o]) => o.status === "completed").map(([k]) => k);
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
return driver;
|
|
931
|
+
};
|
|
932
|
+
const host = {
|
|
933
|
+
fakes,
|
|
934
|
+
user,
|
|
935
|
+
clock: {
|
|
936
|
+
now: nowIso,
|
|
937
|
+
advance: (d) => void (clockMs += durationMs(d))
|
|
938
|
+
},
|
|
939
|
+
get emitted() {
|
|
940
|
+
return committed.emitted;
|
|
941
|
+
},
|
|
942
|
+
get notices() {
|
|
943
|
+
return committed.notices;
|
|
944
|
+
},
|
|
945
|
+
get deliveries() {
|
|
946
|
+
return deliveries;
|
|
947
|
+
},
|
|
948
|
+
get started() {
|
|
949
|
+
return committed.started;
|
|
950
|
+
},
|
|
951
|
+
get signals() {
|
|
952
|
+
return committed.signals;
|
|
953
|
+
},
|
|
954
|
+
get logs() {
|
|
955
|
+
return logs;
|
|
956
|
+
},
|
|
957
|
+
query: () => queryContext(),
|
|
958
|
+
command: () => commandContext(),
|
|
959
|
+
transaction: (callback) => inTransaction(async (tx) => callback(tx), false),
|
|
960
|
+
deliver: (async (subscription, event) => {
|
|
961
|
+
const payload = decode(subscription.event.payload, event.payload);
|
|
962
|
+
const delivered = {
|
|
963
|
+
id: nextId("evt"),
|
|
964
|
+
event: subscription.event.id,
|
|
965
|
+
occurredAt: nowIso(),
|
|
966
|
+
subject: event.subject,
|
|
967
|
+
payload,
|
|
968
|
+
initiator: event.initiator ?? user.userId
|
|
969
|
+
};
|
|
970
|
+
await inTransaction(async (tx) => {
|
|
971
|
+
await subscription.handler(tx, delivered);
|
|
972
|
+
}, true);
|
|
973
|
+
}),
|
|
974
|
+
workflow: ((impl, input, opts) => createWorkflow(impl, input, opts?.instance)),
|
|
975
|
+
table: ((entity) => {
|
|
976
|
+
register(entity);
|
|
977
|
+
return [...store.table(entity.id).values()].map((r) => project(entity, r));
|
|
978
|
+
}),
|
|
979
|
+
overlayRow: ((overlay, base) => {
|
|
980
|
+
register(overlay);
|
|
981
|
+
const row = store.overlay(overlay.id).get(base.key);
|
|
982
|
+
return row === void 0 ? null : project(overlay, row);
|
|
983
|
+
})
|
|
984
|
+
};
|
|
985
|
+
return host;
|
|
986
|
+
}
|
|
987
|
+
export {
|
|
988
|
+
TestHostError,
|
|
989
|
+
createTestHost,
|
|
990
|
+
describe,
|
|
991
|
+
test
|
|
992
|
+
};
|