@mostra/protocol 0.0.0-placeholder → 0.1.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/LICENSE +202 -0
- package/README.md +37 -1
- package/dist/actions.d.ts +273 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +154 -0
- package/dist/actions.js.map +1 -0
- package/dist/artifact.d.ts +113 -0
- package/dist/artifact.d.ts.map +1 -0
- package/dist/artifact.js +79 -0
- package/dist/artifact.js.map +1 -0
- package/dist/bridge.d.ts +295 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +343 -0
- package/dist/bridge.js.map +1 -0
- package/dist/browser.d.ts +195 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +156 -0
- package/dist/browser.js.map +1 -0
- package/dist/bundle.d.ts +155 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +130 -0
- package/dist/bundle.js.map +1 -0
- package/dist/canonical.d.ts +23 -0
- package/dist/canonical.d.ts.map +1 -0
- package/dist/canonical.js +45 -0
- package/dist/canonical.js.map +1 -0
- package/dist/capability.d.ts +38 -0
- package/dist/capability.d.ts.map +1 -0
- package/dist/capability.js +61 -0
- package/dist/capability.js.map +1 -0
- package/dist/diagnostics/codes/a11y.d.ts +8 -0
- package/dist/diagnostics/codes/a11y.d.ts.map +1 -0
- package/dist/diagnostics/codes/a11y.js +30 -0
- package/dist/diagnostics/codes/a11y.js.map +1 -0
- package/dist/diagnostics/codes/action.d.ts +8 -0
- package/dist/diagnostics/codes/action.d.ts.map +1 -0
- package/dist/diagnostics/codes/action.js +110 -0
- package/dist/diagnostics/codes/action.js.map +1 -0
- package/dist/diagnostics/codes/artifact.d.ts +8 -0
- package/dist/diagnostics/codes/artifact.d.ts.map +1 -0
- package/dist/diagnostics/codes/artifact.js +121 -0
- package/dist/diagnostics/codes/artifact.js.map +1 -0
- package/dist/diagnostics/codes/build.d.ts +8 -0
- package/dist/diagnostics/codes/build.d.ts.map +1 -0
- package/dist/diagnostics/codes/build.js +55 -0
- package/dist/diagnostics/codes/build.js.map +1 -0
- package/dist/diagnostics/codes/cli.d.ts +8 -0
- package/dist/diagnostics/codes/cli.d.ts.map +1 -0
- package/dist/diagnostics/codes/cli.js +44 -0
- package/dist/diagnostics/codes/cli.js.map +1 -0
- package/dist/diagnostics/codes/console.d.ts +8 -0
- package/dist/diagnostics/codes/console.d.ts.map +1 -0
- package/dist/diagnostics/codes/console.js +30 -0
- package/dist/diagnostics/codes/console.js.map +1 -0
- package/dist/diagnostics/codes/dep.d.ts +8 -0
- package/dist/diagnostics/codes/dep.d.ts.map +1 -0
- package/dist/diagnostics/codes/dep.js +88 -0
- package/dist/diagnostics/codes/dep.js.map +1 -0
- package/dist/diagnostics/codes/env.d.ts +8 -0
- package/dist/diagnostics/codes/env.d.ts.map +1 -0
- package/dist/diagnostics/codes/env.js +132 -0
- package/dist/diagnostics/codes/env.js.map +1 -0
- package/dist/diagnostics/codes/field.d.ts +8 -0
- package/dist/diagnostics/codes/field.d.ts.map +1 -0
- package/dist/diagnostics/codes/field.js +99 -0
- package/dist/diagnostics/codes/field.js.map +1 -0
- package/dist/diagnostics/codes/home.d.ts +8 -0
- package/dist/diagnostics/codes/home.d.ts.map +1 -0
- package/dist/diagnostics/codes/home.js +132 -0
- package/dist/diagnostics/codes/home.js.map +1 -0
- package/dist/diagnostics/codes/host.d.ts +8 -0
- package/dist/diagnostics/codes/host.d.ts.map +1 -0
- package/dist/diagnostics/codes/host.js +176 -0
- package/dist/diagnostics/codes/host.js.map +1 -0
- package/dist/diagnostics/codes/hygiene.d.ts +8 -0
- package/dist/diagnostics/codes/hygiene.d.ts.map +1 -0
- package/dist/diagnostics/codes/hygiene.js +154 -0
- package/dist/diagnostics/codes/hygiene.js.map +1 -0
- package/dist/diagnostics/codes/index.d.ts +51 -0
- package/dist/diagnostics/codes/index.d.ts.map +1 -0
- package/dist/diagnostics/codes/index.js +72 -0
- package/dist/diagnostics/codes/index.js.map +1 -0
- package/dist/diagnostics/codes/live.d.ts +8 -0
- package/dist/diagnostics/codes/live.d.ts.map +1 -0
- package/dist/diagnostics/codes/live.js +30 -0
- package/dist/diagnostics/codes/live.js.map +1 -0
- package/dist/diagnostics/codes/manifest.d.ts +8 -0
- package/dist/diagnostics/codes/manifest.d.ts.map +1 -0
- package/dist/diagnostics/codes/manifest.js +44 -0
- package/dist/diagnostics/codes/manifest.js.map +1 -0
- package/dist/diagnostics/codes/network.d.ts +8 -0
- package/dist/diagnostics/codes/network.d.ts.map +1 -0
- package/dist/diagnostics/codes/network.js +30 -0
- package/dist/diagnostics/codes/network.js.map +1 -0
- package/dist/diagnostics/codes/platform.d.ts +8 -0
- package/dist/diagnostics/codes/platform.d.ts.map +1 -0
- package/dist/diagnostics/codes/platform.js +18 -0
- package/dist/diagnostics/codes/platform.js.map +1 -0
- package/dist/diagnostics/codes/publish.d.ts +8 -0
- package/dist/diagnostics/codes/publish.d.ts.map +1 -0
- package/dist/diagnostics/codes/publish.js +44 -0
- package/dist/diagnostics/codes/publish.js.map +1 -0
- package/dist/diagnostics/codes/regression.d.ts +8 -0
- package/dist/diagnostics/codes/regression.d.ts.map +1 -0
- package/dist/diagnostics/codes/regression.js +77 -0
- package/dist/diagnostics/codes/regression.js.map +1 -0
- package/dist/diagnostics/codes/runtime.d.ts +8 -0
- package/dist/diagnostics/codes/runtime.d.ts.map +1 -0
- package/dist/diagnostics/codes/runtime.js +66 -0
- package/dist/diagnostics/codes/runtime.js.map +1 -0
- package/dist/diagnostics/codes/secret.d.ts +8 -0
- package/dist/diagnostics/codes/secret.d.ts.map +1 -0
- package/dist/diagnostics/codes/secret.js +18 -0
- package/dist/diagnostics/codes/secret.js.map +1 -0
- package/dist/diagnostics/codes/smoke.d.ts +8 -0
- package/dist/diagnostics/codes/smoke.d.ts.map +1 -0
- package/dist/diagnostics/codes/smoke.js +30 -0
- package/dist/diagnostics/codes/smoke.js.map +1 -0
- package/dist/diagnostics/codes/submit.d.ts +8 -0
- package/dist/diagnostics/codes/submit.d.ts.map +1 -0
- package/dist/diagnostics/codes/submit.js +99 -0
- package/dist/diagnostics/codes/submit.js.map +1 -0
- package/dist/diagnostics/codes/target.d.ts +8 -0
- package/dist/diagnostics/codes/target.d.ts.map +1 -0
- package/dist/diagnostics/codes/target.js +18 -0
- package/dist/diagnostics/codes/target.js.map +1 -0
- package/dist/diagnostics/codes/type.d.ts +8 -0
- package/dist/diagnostics/codes/type.d.ts.map +1 -0
- package/dist/diagnostics/codes/type.js +30 -0
- package/dist/diagnostics/codes/type.js.map +1 -0
- package/dist/diagnostics/codes/verify.d.ts +8 -0
- package/dist/diagnostics/codes/verify.d.ts.map +1 -0
- package/dist/diagnostics/codes/verify.js +99 -0
- package/dist/diagnostics/codes/verify.js.map +1 -0
- package/dist/diagnostics/diagnostic.d.ts +79 -0
- package/dist/diagnostics/diagnostic.d.ts.map +1 -0
- package/dist/diagnostics/diagnostic.js +131 -0
- package/dist/diagnostics/diagnostic.js.map +1 -0
- package/dist/diagnostics/spec.d.ts +49 -0
- package/dist/diagnostics/spec.d.ts.map +1 -0
- package/dist/diagnostics/spec.js +31 -0
- package/dist/diagnostics/spec.js.map +1 -0
- package/dist/hygiene.d.ts +66 -0
- package/dist/hygiene.d.ts.map +1 -0
- package/dist/hygiene.js +134 -0
- package/dist/hygiene.js.map +1 -0
- package/dist/ids.d.ts +119 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +135 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +86 -0
- package/dist/interaction.d.ts +391 -0
- package/dist/interaction.d.ts.map +1 -0
- package/dist/interaction.js +306 -0
- package/dist/interaction.js.map +1 -0
- package/dist/manifest.d.ts +97 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +101 -0
- package/dist/manifest.js.map +1 -0
- package/dist/method.d.ts +26 -0
- package/dist/method.d.ts.map +1 -0
- package/dist/method.js +10 -0
- package/dist/method.js.map +1 -0
- package/dist/methods/artifact/create.d.ts +29 -0
- package/dist/methods/artifact/create.d.ts.map +1 -0
- package/dist/methods/artifact/create.js +31 -0
- package/dist/methods/artifact/create.js.map +1 -0
- package/dist/methods/artifact/get.d.ts +17 -0
- package/dist/methods/artifact/get.d.ts.map +1 -0
- package/dist/methods/artifact/get.js +21 -0
- package/dist/methods/artifact/get.js.map +1 -0
- package/dist/methods/artifact/list.d.ts +22 -0
- package/dist/methods/artifact/list.d.ts.map +1 -0
- package/dist/methods/artifact/list.js +19 -0
- package/dist/methods/artifact/list.js.map +1 -0
- package/dist/methods/artifact/publish.d.ts +28 -0
- package/dist/methods/artifact/publish.d.ts.map +1 -0
- package/dist/methods/artifact/publish.js +28 -0
- package/dist/methods/artifact/publish.js.map +1 -0
- package/dist/methods/artifact/verify.d.ts +29 -0
- package/dist/methods/artifact/verify.d.ts.map +1 -0
- package/dist/methods/artifact/verify.js +27 -0
- package/dist/methods/artifact/verify.js.map +1 -0
- package/dist/methods/deps/add.d.ts +43 -0
- package/dist/methods/deps/add.d.ts.map +1 -0
- package/dist/methods/deps/add.js +40 -0
- package/dist/methods/deps/add.js.map +1 -0
- package/dist/methods/dev/start.d.ts +52 -0
- package/dist/methods/dev/start.d.ts.map +1 -0
- package/dist/methods/dev/start.js +56 -0
- package/dist/methods/dev/start.js.map +1 -0
- package/dist/methods/dev/stop.d.ts +16 -0
- package/dist/methods/dev/stop.d.ts.map +1 -0
- package/dist/methods/dev/stop.js +21 -0
- package/dist/methods/dev/stop.js.map +1 -0
- package/dist/methods/events/ack.d.ts +20 -0
- package/dist/methods/events/ack.d.ts.map +1 -0
- package/dist/methods/events/ack.js +26 -0
- package/dist/methods/events/ack.js.map +1 -0
- package/dist/methods/events/read.d.ts +40 -0
- package/dist/methods/events/read.d.ts.map +1 -0
- package/dist/methods/events/read.js +35 -0
- package/dist/methods/events/read.js.map +1 -0
- package/dist/methods/events/subscribe.d.ts +54 -0
- package/dist/methods/events/subscribe.d.ts.map +1 -0
- package/dist/methods/events/subscribe.js +44 -0
- package/dist/methods/events/subscribe.js.map +1 -0
- package/dist/methods/events/unsubscribe.d.ts +16 -0
- package/dist/methods/events/unsubscribe.d.ts.map +1 -0
- package/dist/methods/events/unsubscribe.js +21 -0
- package/dist/methods/events/unsubscribe.js.map +1 -0
- package/dist/methods/gc/run.d.ts +76 -0
- package/dist/methods/gc/run.d.ts.map +1 -0
- package/dist/methods/gc/run.js +56 -0
- package/dist/methods/gc/run.js.map +1 -0
- package/dist/methods/index.d.ts +6 -0
- package/dist/methods/index.d.ts.map +1 -0
- package/dist/methods/index.js +78 -0
- package/dist/methods/index.js.map +1 -0
- package/dist/methods/instance/check.d.ts +30 -0
- package/dist/methods/instance/check.d.ts.map +1 -0
- package/dist/methods/instance/check.js +34 -0
- package/dist/methods/instance/check.js.map +1 -0
- package/dist/methods/instance/status.d.ts +102 -0
- package/dist/methods/instance/status.d.ts.map +1 -0
- package/dist/methods/instance/status.js +83 -0
- package/dist/methods/instance/status.js.map +1 -0
- package/dist/methods/live/push.d.ts +28 -0
- package/dist/methods/live/push.d.ts.map +1 -0
- package/dist/methods/live/push.js +35 -0
- package/dist/methods/live/push.js.map +1 -0
- package/dist/methods/mostra/initialize.d.ts +143 -0
- package/dist/methods/mostra/initialize.d.ts.map +1 -0
- package/dist/methods/mostra/initialize.js +97 -0
- package/dist/methods/mostra/initialize.js.map +1 -0
- package/dist/methods/mostra/shutdown.d.ts +14 -0
- package/dist/methods/mostra/shutdown.d.ts.map +1 -0
- package/dist/methods/mostra/shutdown.js +22 -0
- package/dist/methods/mostra/shutdown.js.map +1 -0
- package/dist/methods/port/drafts-mirror.d.ts +30 -0
- package/dist/methods/port/drafts-mirror.d.ts.map +1 -0
- package/dist/methods/port/drafts-mirror.js +33 -0
- package/dist/methods/port/drafts-mirror.js.map +1 -0
- package/dist/methods/port/secrets-get.d.ts +19 -0
- package/dist/methods/port/secrets-get.d.ts.map +1 -0
- package/dist/methods/port/secrets-get.js +31 -0
- package/dist/methods/port/secrets-get.js.map +1 -0
- package/dist/methods/port/submissions-deliver.d.ts +38 -0
- package/dist/methods/port/submissions-deliver.d.ts.map +1 -0
- package/dist/methods/port/submissions-deliver.js +38 -0
- package/dist/methods/port/submissions-deliver.js.map +1 -0
- package/dist/methods/port/trusted-controls-activated.d.ts +27 -0
- package/dist/methods/port/trusted-controls-activated.d.ts.map +1 -0
- package/dist/methods/port/trusted-controls-activated.js +33 -0
- package/dist/methods/port/trusted-controls-activated.js.map +1 -0
- package/dist/methods/port/trusted-controls-policy.d.ts +21 -0
- package/dist/methods/port/trusted-controls-policy.d.ts.map +1 -0
- package/dist/methods/port/trusted-controls-policy.js +27 -0
- package/dist/methods/port/trusted-controls-policy.js.map +1 -0
- package/dist/methods/results/get.d.ts +32 -0
- package/dist/methods/results/get.d.ts.map +1 -0
- package/dist/methods/results/get.js +36 -0
- package/dist/methods/results/get.js.map +1 -0
- package/dist/methods/secret/delete.d.ts +22 -0
- package/dist/methods/secret/delete.d.ts.map +1 -0
- package/dist/methods/secret/delete.js +32 -0
- package/dist/methods/secret/delete.js.map +1 -0
- package/dist/methods/secret/list.d.ts +21 -0
- package/dist/methods/secret/list.d.ts.map +1 -0
- package/dist/methods/secret/list.js +29 -0
- package/dist/methods/secret/list.js.map +1 -0
- package/dist/methods/secret/set.d.ts +37 -0
- package/dist/methods/secret/set.d.ts.map +1 -0
- package/dist/methods/secret/set.js +41 -0
- package/dist/methods/secret/set.js.map +1 -0
- package/dist/methods/state/get.d.ts +25 -0
- package/dist/methods/state/get.d.ts.map +1 -0
- package/dist/methods/state/get.js +29 -0
- package/dist/methods/state/get.js.map +1 -0
- package/dist/methods/state/patch.d.ts +32 -0
- package/dist/methods/state/patch.d.ts.map +1 -0
- package/dist/methods/state/patch.js +29 -0
- package/dist/methods/state/patch.js.map +1 -0
- package/dist/methods/view/default.d.ts +19 -0
- package/dist/methods/view/default.d.ts.map +1 -0
- package/dist/methods/view/default.js +23 -0
- package/dist/methods/view/default.js.map +1 -0
- package/dist/methods/view/launch.d.ts +27 -0
- package/dist/methods/view/launch.d.ts.map +1 -0
- package/dist/methods/view/launch.js +30 -0
- package/dist/methods/view/launch.js.map +1 -0
- package/dist/methods/view/revoke.d.ts +19 -0
- package/dist/methods/view/revoke.d.ts.map +1 -0
- package/dist/methods/view/revoke.js +26 -0
- package/dist/methods/view/revoke.js.map +1 -0
- package/dist/methods/view/rotate.d.ts +21 -0
- package/dist/methods/view/rotate.d.ts.map +1 -0
- package/dist/methods/view/rotate.js +27 -0
- package/dist/methods/view/rotate.js.map +1 -0
- package/dist/methods/view/url.d.ts +52 -0
- package/dist/methods/view/url.d.ts.map +1 -0
- package/dist/methods/view/url.js +43 -0
- package/dist/methods/view/url.js.map +1 -0
- package/dist/methods/wait/wait.d.ts +37 -0
- package/dist/methods/wait/wait.d.ts.map +1 -0
- package/dist/methods/wait/wait.js +39 -0
- package/dist/methods/wait/wait.js.map +1 -0
- package/dist/revision.d.ts +43 -0
- package/dist/revision.d.ts.map +1 -0
- package/dist/revision.js +69 -0
- package/dist/revision.js.map +1 -0
- package/dist/rpc/error.d.ts +47 -0
- package/dist/rpc/error.d.ts.map +1 -0
- package/dist/rpc/error.js +77 -0
- package/dist/rpc/error.js.map +1 -0
- package/dist/rpc/lines.d.ts +30 -0
- package/dist/rpc/lines.d.ts.map +1 -0
- package/dist/rpc/lines.js +63 -0
- package/dist/rpc/lines.js.map +1 -0
- package/dist/rpc/messages.d.ts +92 -0
- package/dist/rpc/messages.d.ts.map +1 -0
- package/dist/rpc/messages.js +133 -0
- package/dist/rpc/messages.js.map +1 -0
- package/dist/rpc/peer.d.ts +81 -0
- package/dist/rpc/peer.d.ts.map +1 -0
- package/dist/rpc/peer.js +208 -0
- package/dist/rpc/peer.js.map +1 -0
- package/dist/serializer.d.ts +178 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/serializer.js +929 -0
- package/dist/serializer.js.map +1 -0
- package/dist/verify.d.ts +254 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +243 -0
- package/dist/verify.js.map +1 -0
- package/dist/view.d.ts +103 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +110 -0
- package/dist/view.js.map +1 -0
- package/dist/wire-registry.js +11 -0
- package/dist/wire-registry.js.map +1 -0
- package/dist/worker.d.ts +249 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +158 -0
- package/dist/worker.js.map +1 -0
- package/package.json +114 -4
- package/schemas/protocol.draft-07.json +5120 -0
- package/schemas/protocol.schema.json +4964 -0
- package/src/actions.ts +418 -0
- package/src/artifact.ts +187 -0
- package/src/bridge.ts +618 -0
- package/src/browser.ts +374 -0
- package/src/bundle.ts +264 -0
- package/src/canonical.ts +49 -0
- package/src/capability.ts +92 -0
- package/src/diagnostics/codes/a11y.ts +41 -0
- package/src/diagnostics/codes/action.ts +125 -0
- package/src/diagnostics/codes/artifact.ts +137 -0
- package/src/diagnostics/codes/build.ts +65 -0
- package/src/diagnostics/codes/cli.ts +53 -0
- package/src/diagnostics/codes/console.ts +41 -0
- package/src/diagnostics/codes/dep.ts +101 -0
- package/src/diagnostics/codes/env.ts +149 -0
- package/src/diagnostics/codes/field.ts +113 -0
- package/src/diagnostics/codes/home.ts +150 -0
- package/src/diagnostics/codes/host.ts +197 -0
- package/src/diagnostics/codes/hygiene.ts +175 -0
- package/src/diagnostics/codes/index.ts +142 -0
- package/src/diagnostics/codes/live.ts +41 -0
- package/src/diagnostics/codes/manifest.ts +53 -0
- package/src/diagnostics/codes/network.ts +41 -0
- package/src/diagnostics/codes/platform.ts +30 -0
- package/src/diagnostics/codes/publish.ts +53 -0
- package/src/diagnostics/codes/regression.ts +89 -0
- package/src/diagnostics/codes/runtime.ts +77 -0
- package/src/diagnostics/codes/secret.ts +29 -0
- package/src/diagnostics/codes/smoke.ts +41 -0
- package/src/diagnostics/codes/submit.ts +113 -0
- package/src/diagnostics/codes/target.ts +29 -0
- package/src/diagnostics/codes/type.ts +41 -0
- package/src/diagnostics/codes/verify.ts +113 -0
- package/src/diagnostics/diagnostic.ts +240 -0
- package/src/diagnostics/spec.ts +90 -0
- package/src/hygiene.ts +224 -0
- package/src/ids.ts +279 -0
- package/src/index.ts +576 -0
- package/src/interaction.ts +728 -0
- package/src/manifest.ts +206 -0
- package/src/method.ts +42 -0
- package/src/methods/artifact/create.ts +56 -0
- package/src/methods/artifact/get.ts +30 -0
- package/src/methods/artifact/list.ts +42 -0
- package/src/methods/artifact/publish.ts +46 -0
- package/src/methods/artifact/verify.ts +46 -0
- package/src/methods/deps/add.ts +72 -0
- package/src/methods/dev/start.ts +84 -0
- package/src/methods/dev/stop.ts +32 -0
- package/src/methods/events/ack.ts +41 -0
- package/src/methods/events/read.ts +67 -0
- package/src/methods/events/subscribe.ts +91 -0
- package/src/methods/events/unsubscribe.ts +35 -0
- package/src/methods/gc/run.ts +125 -0
- package/src/methods/index.ts +81 -0
- package/src/methods/instance/check.ts +61 -0
- package/src/methods/instance/status.ts +172 -0
- package/src/methods/live/push.ts +54 -0
- package/src/methods/mostra/initialize.ts +249 -0
- package/src/methods/mostra/shutdown.ts +31 -0
- package/src/methods/port/drafts-mirror.ts +52 -0
- package/src/methods/port/secrets-get.ts +40 -0
- package/src/methods/port/submissions-deliver.ts +70 -0
- package/src/methods/port/trusted-controls-activated.ts +51 -0
- package/src/methods/port/trusted-controls-policy.ts +38 -0
- package/src/methods/results/get.ts +59 -0
- package/src/methods/secret/delete.ts +43 -0
- package/src/methods/secret/list.ts +40 -0
- package/src/methods/secret/set.ts +69 -0
- package/src/methods/state/get.ts +44 -0
- package/src/methods/state/patch.ts +51 -0
- package/src/methods/view/default.ts +32 -0
- package/src/methods/view/launch.ts +47 -0
- package/src/methods/view/revoke.ts +39 -0
- package/src/methods/view/rotate.ts +37 -0
- package/src/methods/view/url.ts +84 -0
- package/src/methods/wait/wait.ts +58 -0
- package/src/revision.ts +101 -0
- package/src/rpc/error.ts +107 -0
- package/src/rpc/lines.ts +70 -0
- package/src/rpc/messages.ts +188 -0
- package/src/rpc/peer.ts +341 -0
- package/src/serializer.ts +1217 -0
- package/src/timers.d.ts +8 -0
- package/src/verify.ts +458 -0
- package/src/view.ts +200 -0
- package/src/web-crypto.d.ts +9 -0
- package/src/web-platform.d.ts +35 -0
- package/src/wire-registry.ts +14 -0
- package/src/worker.ts +374 -0
package/src/actions.ts
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actions, live data and secrets (INTERFACES §2.4, §4, §6; D24, D44, D54, D56): the shapes the
|
|
3
|
+
* browser protocol, the host protocol and the worker channel share. Server-function arguments and
|
|
4
|
+
* results travel as the serializer's batches (`Batches`).
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* const run: RunState = await post("runs", { viewId, fnId: "actions.ts#sendReply", args, clientKey });
|
|
8
|
+
* if (run.status === "succeeded") show(await deserializeAll(run.batches));
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
import * as z from "zod";
|
|
12
|
+
import { ViewId } from "./ids.ts";
|
|
13
|
+
import type { Frame, WireError } from "./serializer.ts";
|
|
14
|
+
import { wireRegistry } from "./wire-registry.ts";
|
|
15
|
+
|
|
16
|
+
/** A value written by the serializer: its batches, in order (`serializeAll`). */
|
|
17
|
+
export type Batches = readonly (readonly Frame[])[];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The Zod schema of the `Batches` type: a list of batches, each a list of frames. The frames
|
|
21
|
+
* themselves are checked by the reader (`ValueReader`), which refuses anything malformed.
|
|
22
|
+
*/
|
|
23
|
+
export const Batches: z.ZodType<Batches> = z
|
|
24
|
+
.array(z.array(z.record(z.string(), z.unknown())).readonly())
|
|
25
|
+
.readonly()
|
|
26
|
+
.register(wireRegistry, {
|
|
27
|
+
id: "Batches",
|
|
28
|
+
description: "A serialized server-function value: its batches of frames, in order.",
|
|
29
|
+
}) as unknown as z.ZodType<Batches>;
|
|
30
|
+
|
|
31
|
+
/** An error as runs, calls and live sources report it. */
|
|
32
|
+
export interface ActionError extends WireError {
|
|
33
|
+
/** The stack of the thrown error, kept in the run log and never sent to a page. */
|
|
34
|
+
readonly stack?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The Zod schema of the `ActionError` type. */
|
|
38
|
+
export const ActionError: z.ZodType<ActionError> = z
|
|
39
|
+
.object({
|
|
40
|
+
message: z.string(),
|
|
41
|
+
code: z.string().exactOptional(),
|
|
42
|
+
stack: z.string().exactOptional(),
|
|
43
|
+
})
|
|
44
|
+
.register(wireRegistry, {
|
|
45
|
+
id: "ActionError",
|
|
46
|
+
description: "An error from server code: its message and diagnostic code.",
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/** The largest serialized arguments a call or run takes, in characters of JSON. */
|
|
50
|
+
export const ACTION_ARGS_MAX: number = 16 * 1024 * 1024;
|
|
51
|
+
|
|
52
|
+
/** The largest serialized result a run keeps, in characters of JSON (larger fails the run). */
|
|
53
|
+
export const ACTION_RESULT_MAX: number = 16 * 1024 * 1024;
|
|
54
|
+
|
|
55
|
+
/** The cap of a run's log, in UTF-16 code units of its lines (D47's 1 MB). */
|
|
56
|
+
export const RUN_LOG_MAX: number = 1024 * 1024;
|
|
57
|
+
|
|
58
|
+
/** The line a capped log ends with. */
|
|
59
|
+
export const RUN_LOG_TRUNCATED = "[log truncated at 1 MB]";
|
|
60
|
+
|
|
61
|
+
/** The longest run key, in characters. */
|
|
62
|
+
export const RUN_KEY_MAX = 256;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A run's state (D24, ARCHITECTURE §7). `queued`: recorded, not yet started in a worker.
|
|
66
|
+
* `running`: started. `waiting` is reserved for a remote server's run that waits for its owner's
|
|
67
|
+
* instance (WP-28, D117); a page that doesn't know it treats it like `queued`. The others are
|
|
68
|
+
* final.
|
|
69
|
+
*/
|
|
70
|
+
export type RunStatus = "queued" | "running" | "waiting" | "succeeded" | "failed" | "cancelled";
|
|
71
|
+
|
|
72
|
+
/** Every run status. */
|
|
73
|
+
export const RUN_STATUSES: readonly RunStatus[] = [
|
|
74
|
+
"queued",
|
|
75
|
+
"running",
|
|
76
|
+
"waiting",
|
|
77
|
+
"succeeded",
|
|
78
|
+
"failed",
|
|
79
|
+
"cancelled",
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
/** Whether a run in `status` has ended. */
|
|
83
|
+
export function isFinalRunStatus(status: RunStatus): boolean {
|
|
84
|
+
return status === "succeeded" || status === "failed" || status === "cancelled";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Why a run ended the way it did, beside its status: `interrupted` (its worker or the instance
|
|
89
|
+
* stopped while it ran, D24), `threw` (the action threw), `unserializable` (its result is outside
|
|
90
|
+
* the type set), `too-large`, `parked` (its artifact's worker keeps crashing), `cancelled` (by a
|
|
91
|
+
* viewer), `unknown-function`. Later releases add reasons.
|
|
92
|
+
*/
|
|
93
|
+
export type RunReason = string;
|
|
94
|
+
|
|
95
|
+
/** A run's progress, as the action last reported it. */
|
|
96
|
+
export interface RunProgress {
|
|
97
|
+
/** From 0 to 1. */
|
|
98
|
+
readonly fraction?: number;
|
|
99
|
+
/** One short line for people. */
|
|
100
|
+
readonly message?: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The Zod schema of the `RunProgress` type. */
|
|
104
|
+
export const RunProgress: z.ZodType<RunProgress> = z
|
|
105
|
+
.object({
|
|
106
|
+
fraction: z.number().min(0).max(1).exactOptional(),
|
|
107
|
+
message: z.string().max(1000).exactOptional(),
|
|
108
|
+
})
|
|
109
|
+
.register(wireRegistry, {
|
|
110
|
+
id: "RunProgress",
|
|
111
|
+
description: "A run's progress: fraction and message.",
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* One action run as a page reads it (D54): its state, progress, log and the result written so far.
|
|
116
|
+
* A result that is an async iterable grows item by item while the run is `running`.
|
|
117
|
+
*/
|
|
118
|
+
export interface RunState {
|
|
119
|
+
/** The run's `run_` ID. */
|
|
120
|
+
readonly runId: string;
|
|
121
|
+
/** The server function it runs: `<module path>#<export>`. */
|
|
122
|
+
readonly fnId: string;
|
|
123
|
+
/** The idempotency key it was started with, if any. */
|
|
124
|
+
readonly key?: string;
|
|
125
|
+
/** The run's state. */
|
|
126
|
+
readonly status: RunStatus;
|
|
127
|
+
/** Why it ended, for `failed` and `cancelled`. */
|
|
128
|
+
readonly reason?: RunReason;
|
|
129
|
+
/** Its latest progress. */
|
|
130
|
+
readonly progress?: RunProgress;
|
|
131
|
+
/** The log lines, capped at 1 MB with a marker line. */
|
|
132
|
+
readonly log: readonly string[];
|
|
133
|
+
/** The result's batches so far. */
|
|
134
|
+
readonly batches: Batches;
|
|
135
|
+
/** For `failed`: what went wrong, without the stack. */
|
|
136
|
+
readonly error?: WireError;
|
|
137
|
+
/** When it was recorded. */
|
|
138
|
+
readonly startedAt: string;
|
|
139
|
+
/** When it ended. */
|
|
140
|
+
readonly finishedAt?: string;
|
|
141
|
+
/** Whether this request joined a run that already existed (a key or a retried `clientKey`). */
|
|
142
|
+
readonly joined?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* The index of the first line in `log`, when the request said which lines the page holds
|
|
145
|
+
* (`RunAttachRequest.held`); absent: 0, the whole log.
|
|
146
|
+
*/
|
|
147
|
+
readonly logFrom?: number;
|
|
148
|
+
/** The index of the first batch in `batches`, as `logFrom`; absent: 0. */
|
|
149
|
+
readonly batchFrom?: number;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** The Zod schema of the `RunState` type. */
|
|
153
|
+
export const RunState: z.ZodType<RunState> = z
|
|
154
|
+
.object({
|
|
155
|
+
runId: z.string(),
|
|
156
|
+
fnId: z.string(),
|
|
157
|
+
key: z.string().exactOptional(),
|
|
158
|
+
status: z.enum(RUN_STATUSES as [RunStatus, ...RunStatus[]]),
|
|
159
|
+
reason: z.string().exactOptional(),
|
|
160
|
+
progress: RunProgress.exactOptional(),
|
|
161
|
+
log: z.array(z.string()).readonly(),
|
|
162
|
+
batches: Batches,
|
|
163
|
+
error: z.object({ message: z.string(), code: z.string().exactOptional() }).exactOptional(),
|
|
164
|
+
startedAt: z.string(),
|
|
165
|
+
finishedAt: z.string().exactOptional(),
|
|
166
|
+
joined: z.boolean().exactOptional(),
|
|
167
|
+
logFrom: z.number().int().nonnegative().exactOptional(),
|
|
168
|
+
batchFrom: z.number().int().nonnegative().exactOptional(),
|
|
169
|
+
})
|
|
170
|
+
.register(wireRegistry, {
|
|
171
|
+
id: "RunState",
|
|
172
|
+
description: "An action run: status, progress, log and the result written so far.",
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* What changed in a run since a page last heard: a lossy notification on the event stream. Lines
|
|
177
|
+
* start at `logFrom` and batches at `batchFrom`; a page that holds fewer reads the run again
|
|
178
|
+
* (`runs/attach`).
|
|
179
|
+
*/
|
|
180
|
+
export interface RunDelta {
|
|
181
|
+
/** The run's `run_` ID. */
|
|
182
|
+
readonly runId: string;
|
|
183
|
+
/** The run's state. */
|
|
184
|
+
readonly status: RunStatus;
|
|
185
|
+
/** Why it ended so, for `failed` and `cancelled`. */
|
|
186
|
+
readonly reason?: RunReason;
|
|
187
|
+
/** Its latest progress. */
|
|
188
|
+
readonly progress?: RunProgress;
|
|
189
|
+
/** The index of the first line in `log`. */
|
|
190
|
+
readonly logFrom: number;
|
|
191
|
+
/** Log lines, starting at `logFrom`. */
|
|
192
|
+
readonly log: readonly string[];
|
|
193
|
+
/** The index of the first batch in `batches`. */
|
|
194
|
+
readonly batchFrom: number;
|
|
195
|
+
/** Result batches, starting at `batchFrom`. */
|
|
196
|
+
readonly batches: Batches;
|
|
197
|
+
/** What went wrong. */
|
|
198
|
+
readonly error?: WireError;
|
|
199
|
+
/** When it ended. */
|
|
200
|
+
readonly finishedAt?: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** A live source's value as a page reads it (D56). */
|
|
204
|
+
export interface LiveState {
|
|
205
|
+
/** The idempotency key it was started with, if any. */
|
|
206
|
+
readonly key: string;
|
|
207
|
+
/** The value's revision, a decimal string that only grows; absent before any value. */
|
|
208
|
+
readonly revision?: string;
|
|
209
|
+
/** When the value was produced. */
|
|
210
|
+
readonly at?: string;
|
|
211
|
+
/** The latest value, serialized. */
|
|
212
|
+
readonly value?: Batches;
|
|
213
|
+
/**
|
|
214
|
+
* Append mode (`useLive(key, { mode: "append" })`): the values kept in the source's ring, oldest
|
|
215
|
+
* first, at most the window the page asked for.
|
|
216
|
+
*/
|
|
217
|
+
readonly ring?: readonly {
|
|
218
|
+
readonly revision: string;
|
|
219
|
+
readonly at: string;
|
|
220
|
+
readonly value: Batches;
|
|
221
|
+
}[];
|
|
222
|
+
/** The producer's last failure, while the last good value stays (FAILURE_MODEL §6). */
|
|
223
|
+
readonly error?: WireError;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** One live update on the event stream: never stored as an event (D63, LL-04). */
|
|
227
|
+
export interface LiveUpdate {
|
|
228
|
+
/** The live source's key. */
|
|
229
|
+
readonly key: string;
|
|
230
|
+
/** The value's revision. */
|
|
231
|
+
readonly revision?: string;
|
|
232
|
+
/** When the value was produced. */
|
|
233
|
+
readonly at?: string;
|
|
234
|
+
/** The value, serialized. */
|
|
235
|
+
readonly value?: Batches;
|
|
236
|
+
/** What went wrong. */
|
|
237
|
+
readonly error?: WireError;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* An ephemeral message on a page's event stream (SSE `event: run` or `event: live`, without an
|
|
242
|
+
* `id`, so a reconnect's cursor is untouched) or in a poll's `ephemeral`: lossy, coalesced, and
|
|
243
|
+
* never stored as an event.
|
|
244
|
+
*/
|
|
245
|
+
export type EphemeralMessage =
|
|
246
|
+
| { readonly kind: "run"; readonly run: RunDelta }
|
|
247
|
+
| { readonly kind: "live"; readonly live: LiveUpdate };
|
|
248
|
+
|
|
249
|
+
/** `POST …/call/{fnId}`: a plain server-function call, no durable record (D54). */
|
|
250
|
+
export interface CallRequest {
|
|
251
|
+
/** The view the page was opened as (D104). */
|
|
252
|
+
readonly viewId: string;
|
|
253
|
+
/** The arguments, serialized as one array value. */
|
|
254
|
+
readonly args: Batches;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** The Zod schema of the `CallRequest` type. */
|
|
258
|
+
export const CallRequest: z.ZodType<CallRequest> = z
|
|
259
|
+
.object({ viewId: ViewId.schema, args: Batches })
|
|
260
|
+
.register(wireRegistry, {
|
|
261
|
+
id: "CallRequest",
|
|
262
|
+
description: "A plain server-function call: the view and the serialized arguments.",
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* One line of a plain call's answer (`application/x-ndjson`): a batch of the result, then the end.
|
|
267
|
+
*/
|
|
268
|
+
export type CallLine =
|
|
269
|
+
| { readonly batch: readonly Frame[] }
|
|
270
|
+
| { readonly end: { readonly status: "succeeded" } }
|
|
271
|
+
| { readonly end: { readonly status: "failed"; readonly error: WireError } };
|
|
272
|
+
|
|
273
|
+
/** `POST …/runs`: start a durable action run, or join one (D54, AC-02, AC-03). */
|
|
274
|
+
export interface RunRequest {
|
|
275
|
+
/** The view the page was opened as (D104). */
|
|
276
|
+
readonly viewId: string;
|
|
277
|
+
/** `<module path>#<export>`. */
|
|
278
|
+
readonly fnId: string;
|
|
279
|
+
/** The arguments, serialized as one array value. */
|
|
280
|
+
readonly args: Batches;
|
|
281
|
+
/** The author's idempotency key: one run per artifact, function and key, ever. */
|
|
282
|
+
readonly key?: string;
|
|
283
|
+
/** A fresh ID per invocation, so a retried request joins the run it already started. */
|
|
284
|
+
readonly clientKey: string;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** The Zod schema of the `RunRequest` type. */
|
|
288
|
+
export const RunRequest: z.ZodType<RunRequest> = z
|
|
289
|
+
.object({
|
|
290
|
+
viewId: ViewId.schema,
|
|
291
|
+
fnId: z.string().min(3).max(1024),
|
|
292
|
+
args: Batches,
|
|
293
|
+
key: z.string().min(1).max(RUN_KEY_MAX).exactOptional(),
|
|
294
|
+
clientKey: z.string().min(8).max(64),
|
|
295
|
+
})
|
|
296
|
+
.register(wireRegistry, {
|
|
297
|
+
id: "RunRequest",
|
|
298
|
+
description: "Start or join an action run: the function, its arguments and keys.",
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* `POST …/runs/attach`: read runs and hear their changes on the event stream for the next minute
|
|
303
|
+
* (re-attach after a reload, AC-02). By ID, or by function and key.
|
|
304
|
+
*/
|
|
305
|
+
export interface RunAttachRequest {
|
|
306
|
+
/** The view the page was opened as (D104). */
|
|
307
|
+
readonly viewId: string;
|
|
308
|
+
/** Runs by ID. */
|
|
309
|
+
readonly runIds?: readonly string[];
|
|
310
|
+
/** Runs by function and key. */
|
|
311
|
+
readonly keyed?: readonly { readonly fnId: string; readonly key: string }[];
|
|
312
|
+
/**
|
|
313
|
+
* What the page already holds of runs it names by ID: so many log lines and batches. Each such
|
|
314
|
+
* run's answer starts there (`RunState.logFrom`, `batchFrom`), so a page renewing its interest
|
|
315
|
+
* doesn't read the whole run again (Opus review 14).
|
|
316
|
+
*/
|
|
317
|
+
readonly held?: readonly {
|
|
318
|
+
readonly runId: string;
|
|
319
|
+
readonly log: number;
|
|
320
|
+
readonly batches: number;
|
|
321
|
+
}[];
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** The Zod schema of the `RunAttachRequest` type. */
|
|
325
|
+
export const RunAttachRequest: z.ZodType<RunAttachRequest> = z
|
|
326
|
+
.object({
|
|
327
|
+
viewId: ViewId.schema,
|
|
328
|
+
runIds: z.array(z.string().max(64)).max(100).readonly().exactOptional(),
|
|
329
|
+
keyed: z
|
|
330
|
+
.array(
|
|
331
|
+
z.object({ fnId: z.string().min(3).max(1024), key: z.string().min(1).max(RUN_KEY_MAX) }),
|
|
332
|
+
)
|
|
333
|
+
.max(100)
|
|
334
|
+
.readonly()
|
|
335
|
+
.exactOptional(),
|
|
336
|
+
held: z
|
|
337
|
+
.array(
|
|
338
|
+
z.object({
|
|
339
|
+
runId: z.string().max(64),
|
|
340
|
+
log: z.number().int().nonnegative(),
|
|
341
|
+
batches: z.number().int().nonnegative(),
|
|
342
|
+
}),
|
|
343
|
+
)
|
|
344
|
+
.max(100)
|
|
345
|
+
.readonly()
|
|
346
|
+
.exactOptional(),
|
|
347
|
+
})
|
|
348
|
+
.register(wireRegistry, {
|
|
349
|
+
id: "RunAttachRequest",
|
|
350
|
+
description: "Runs a page reads and follows: by ID, or by function and key.",
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
/** `POST …/runs/{id}/cancel`. */
|
|
354
|
+
export interface RunCancelRequest {
|
|
355
|
+
/** The view the page was opened as (D104). */
|
|
356
|
+
readonly viewId: string;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** The Zod schema of the `RunCancelRequest` type. */
|
|
360
|
+
export const RunCancelRequest: z.ZodType<RunCancelRequest> = z
|
|
361
|
+
.object({ viewId: ViewId.schema })
|
|
362
|
+
.register(wireRegistry, { id: "RunCancelRequest", description: "Cancel a run, from a view." });
|
|
363
|
+
|
|
364
|
+
/** The keys of live sources: like JavaScript export names, which is what `live.ts` declares. */
|
|
365
|
+
export const LIVE_KEY_PATTERN: RegExp = /^[A-Za-z_$][A-Za-z0-9_$]{0,127}$/;
|
|
366
|
+
|
|
367
|
+
/** The largest live value, in characters of serialized JSON (DATA_MODEL §5's 4 MiB). */
|
|
368
|
+
export const LIVE_VALUE_MAX: number = 4 * 1024 * 1024;
|
|
369
|
+
|
|
370
|
+
/** The ring size of a pushed source in append mode that no `defineLive` sized. */
|
|
371
|
+
export const LIVE_RING_DEFAULT = 1024;
|
|
372
|
+
|
|
373
|
+
/** The largest ring a source may keep. */
|
|
374
|
+
export const LIVE_RING_MAX = 100_000;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* `POST …/live`: read live sources and keep their producers running for this view for the next
|
|
378
|
+
* minute (D56, LL-04); a page asks again while it shows them.
|
|
379
|
+
*/
|
|
380
|
+
export interface LiveRequest {
|
|
381
|
+
/** The view the page was opened as (D104). */
|
|
382
|
+
readonly viewId: string;
|
|
383
|
+
/**
|
|
384
|
+
* The sources, each with its append window; `refresh` asks the source's producer to load again
|
|
385
|
+
* now (`useLive`'s `refresh()`).
|
|
386
|
+
*/
|
|
387
|
+
readonly keys: readonly {
|
|
388
|
+
readonly key: string;
|
|
389
|
+
readonly window?: number;
|
|
390
|
+
readonly refresh?: boolean;
|
|
391
|
+
}[];
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** The Zod schema of the `LiveRequest` type. */
|
|
395
|
+
export const LiveRequest: z.ZodType<LiveRequest> = z
|
|
396
|
+
.object({
|
|
397
|
+
viewId: ViewId.schema,
|
|
398
|
+
keys: z
|
|
399
|
+
.array(
|
|
400
|
+
z.object({
|
|
401
|
+
key: z.string().regex(LIVE_KEY_PATTERN),
|
|
402
|
+
window: z.int().min(1).max(LIVE_RING_MAX).exactOptional(),
|
|
403
|
+
refresh: z.boolean().exactOptional(),
|
|
404
|
+
}),
|
|
405
|
+
)
|
|
406
|
+
.max(256)
|
|
407
|
+
.readonly(),
|
|
408
|
+
})
|
|
409
|
+
.register(wireRegistry, {
|
|
410
|
+
id: "LiveRequest",
|
|
411
|
+
description: "Live sources a page reads and keeps running: keys and append windows.",
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
/** Secret names: letters, digits, `_`, `.` and `-`, starting with a letter or `_` (D44). */
|
|
415
|
+
export const SECRET_NAME_PATTERN: RegExp = /^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/;
|
|
416
|
+
|
|
417
|
+
/** The largest secret value, in UTF-8 bytes. */
|
|
418
|
+
export const SECRET_VALUE_MAX: number = 64 * 1024;
|
package/src/artifact.ts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifacts and versions as clients see them (INTERFACES §6): how a client names an artifact or its
|
|
3
|
+
* source, and the summaries `artifact/list`, `artifact/get` and `artifact/publish` return.
|
|
4
|
+
*/
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { ArtifactId, Cursor, TokenId, VersionId } from "./ids.ts";
|
|
7
|
+
import { ArtifactLink, ArtifactManifest, SubmissionPolicy } from "./manifest.ts";
|
|
8
|
+
import { wireRegistry } from "./wire-registry.ts";
|
|
9
|
+
|
|
10
|
+
/** An absolute file system path: the client resolves relative paths against its own directory. */
|
|
11
|
+
const AbsolutePath = z.string().regex(/^\//);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Where to build an artifact from: a source path (a `.tsx`, `.jsx` or `.mdx` file, or a directory
|
|
15
|
+
* with an `index` entry), or an artifact ID, meaning the path it was last published from.
|
|
16
|
+
*/
|
|
17
|
+
export type SourceRef = { readonly path: string } | { readonly artifactId: string };
|
|
18
|
+
|
|
19
|
+
/** Names an artifact: by its ID, or by a source path bound to it. */
|
|
20
|
+
export type ArtifactRef = { readonly artifactId: string } | { readonly path: string };
|
|
21
|
+
|
|
22
|
+
/** The Zod schema of the `SourceRef` type. */
|
|
23
|
+
export const SourceRef: z.ZodType<SourceRef> = z
|
|
24
|
+
.union([z.object({ path: AbsolutePath }), z.object({ artifactId: ArtifactId.schema })])
|
|
25
|
+
.register(wireRegistry, {
|
|
26
|
+
id: "SourceRef",
|
|
27
|
+
description:
|
|
28
|
+
"Where to build an artifact from: an absolute source path, or an artifact ID (its last published source path).",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/** The Zod schema of the `ArtifactRef` type. */
|
|
32
|
+
export const ArtifactRef: z.ZodType<ArtifactRef> = z
|
|
33
|
+
.union([z.object({ artifactId: ArtifactId.schema }), z.object({ path: AbsolutePath })])
|
|
34
|
+
.register(wireRegistry, {
|
|
35
|
+
id: "ArtifactRef",
|
|
36
|
+
description: "Names an artifact by its ID or by an absolute source path bound to it.",
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/** One published version. */
|
|
40
|
+
export interface VersionSummary {
|
|
41
|
+
/** The content-addressed version ID (D89). */
|
|
42
|
+
readonly id: string;
|
|
43
|
+
/** The per-artifact version number, for people: 1, 2, 3 … */
|
|
44
|
+
readonly number: number;
|
|
45
|
+
/** When it was published (RFC 3339, UTC). */
|
|
46
|
+
readonly publishedAt: string;
|
|
47
|
+
/** SHA-256 of the source tree's canonical listing, lowercase hex (DATA_MODEL §2). */
|
|
48
|
+
readonly sourceDigest: string;
|
|
49
|
+
/** SHA-256 of the build environment's canonical JSON, lowercase hex (DATA_MODEL §2). */
|
|
50
|
+
readonly envDigest: string;
|
|
51
|
+
/** SHA-256 of the build output's canonical listing: recorded, never identity (VR-01). */
|
|
52
|
+
readonly outputDigest: string;
|
|
53
|
+
/** Diagnostic codes a forced publish recorded (D41); absent when none. */
|
|
54
|
+
readonly forcedDiagnostics?: readonly string[];
|
|
55
|
+
/**
|
|
56
|
+
* When `mostra gc` removed the version's files (D140): its ID and number stay, but it can't be
|
|
57
|
+
* opened until its exact source is published again. Absent for a version whose files exist.
|
|
58
|
+
*/
|
|
59
|
+
readonly collected?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** One artifact, as `artifact/list` returns it. Metadata comes from the latest version's manifest. */
|
|
63
|
+
export interface ArtifactSummary {
|
|
64
|
+
/** The artifact ID. */
|
|
65
|
+
readonly id: string;
|
|
66
|
+
/** The title people see. */
|
|
67
|
+
readonly title: string;
|
|
68
|
+
/** What the artifact is for. */
|
|
69
|
+
readonly description?: string;
|
|
70
|
+
/** What kind of artifact it is. */
|
|
71
|
+
readonly family?: string;
|
|
72
|
+
/** Related artifacts. */
|
|
73
|
+
readonly links: readonly ArtifactLink[];
|
|
74
|
+
/** The render mode of the latest version. */
|
|
75
|
+
readonly mode: "spa";
|
|
76
|
+
/** The submission policy requested at publish or in the manifest; the host decides (D39). */
|
|
77
|
+
readonly policy?: SubmissionPolicy;
|
|
78
|
+
/** The source path the artifact was last published from. */
|
|
79
|
+
readonly source?: string;
|
|
80
|
+
/** When the artifact was first published (RFC 3339, UTC). */
|
|
81
|
+
readonly createdAt: string;
|
|
82
|
+
/** The version viewers are offered. */
|
|
83
|
+
readonly latestVersion?: VersionSummary;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** One artifact in full, as `artifact/get` returns it. */
|
|
87
|
+
export interface ArtifactDetail extends ArtifactSummary {
|
|
88
|
+
/** The latest version's manifest. */
|
|
89
|
+
readonly manifest: ArtifactManifest;
|
|
90
|
+
/** Every version, newest number first. */
|
|
91
|
+
readonly versions: readonly VersionSummary[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The receipt of `artifact/publish` (INTERFACES §6, H-07). Everything it names is durable before the
|
|
96
|
+
* response is sent.
|
|
97
|
+
*/
|
|
98
|
+
export interface PublishReceipt {
|
|
99
|
+
/** The artifact the version belongs to. */
|
|
100
|
+
readonly artifactId: string;
|
|
101
|
+
/** The content-addressed version ID (D89). */
|
|
102
|
+
readonly versionId: string;
|
|
103
|
+
/** The version number. */
|
|
104
|
+
readonly version: number;
|
|
105
|
+
/**
|
|
106
|
+
* The capability URL: the artifact's default link (D97), the same for every publish until it is
|
|
107
|
+
* rotated or revoked. Instances with the gateway (WP-05 on) always set it; optional on
|
|
108
|
+
* the wire so instances without it can publish (D90).
|
|
109
|
+
*/
|
|
110
|
+
readonly url?: string;
|
|
111
|
+
/**
|
|
112
|
+
* The ID of the token behind `url`, the artifact's default link (D97), for `view/rotate` and
|
|
113
|
+
* `view/revoke`. Present whenever `url` is.
|
|
114
|
+
*/
|
|
115
|
+
readonly tokenId?: string;
|
|
116
|
+
/** The event cursor of the version's `version.published` event; `wait` and events read after it. */
|
|
117
|
+
readonly cursor: string;
|
|
118
|
+
/** `true` when this artifact already had this exact source and environment as a version. */
|
|
119
|
+
readonly reused: boolean;
|
|
120
|
+
/** The error codes a forced publish recorded (D41). */
|
|
121
|
+
readonly forcedDiagnostics?: readonly string[];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** The Zod schema of the `VersionSummary` type. */
|
|
125
|
+
export const VersionSummary: z.ZodType<VersionSummary> = z
|
|
126
|
+
.object({
|
|
127
|
+
id: VersionId.schema,
|
|
128
|
+
number: z.int().min(1),
|
|
129
|
+
publishedAt: z.iso.datetime(),
|
|
130
|
+
sourceDigest: z.string().regex(/^[0-9a-f]{64}$/),
|
|
131
|
+
envDigest: z.string().regex(/^[0-9a-f]{64}$/),
|
|
132
|
+
outputDigest: z.string().regex(/^[0-9a-f]{64}$/),
|
|
133
|
+
forcedDiagnostics: z.array(z.string()).readonly().exactOptional(),
|
|
134
|
+
collected: z.iso.datetime().exactOptional(),
|
|
135
|
+
})
|
|
136
|
+
.register(wireRegistry, { id: "VersionSummary", description: "One published version." });
|
|
137
|
+
|
|
138
|
+
const summaryShape = {
|
|
139
|
+
id: ArtifactId.schema,
|
|
140
|
+
title: z.string(),
|
|
141
|
+
description: z.string().exactOptional(),
|
|
142
|
+
family: z.string().exactOptional(),
|
|
143
|
+
links: z.array(ArtifactLink).readonly(),
|
|
144
|
+
mode: z.literal("spa"),
|
|
145
|
+
policy: SubmissionPolicy.exactOptional(),
|
|
146
|
+
source: z.string().exactOptional(),
|
|
147
|
+
createdAt: z.iso.datetime(),
|
|
148
|
+
latestVersion: VersionSummary.exactOptional(),
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/** The Zod schema of the `ArtifactSummary` type. */
|
|
152
|
+
export const ArtifactSummary: z.ZodType<ArtifactSummary> = z
|
|
153
|
+
.object(summaryShape)
|
|
154
|
+
.register(wireRegistry, {
|
|
155
|
+
id: "ArtifactSummary",
|
|
156
|
+
description: "One artifact: metadata from its latest version, its source and latest version.",
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
/** The Zod schema of the `ArtifactDetail` type. */
|
|
160
|
+
export const ArtifactDetail: z.ZodType<ArtifactDetail> = z
|
|
161
|
+
.object({
|
|
162
|
+
...summaryShape,
|
|
163
|
+
manifest: ArtifactManifest,
|
|
164
|
+
versions: z.array(VersionSummary).readonly(),
|
|
165
|
+
})
|
|
166
|
+
.register(wireRegistry, {
|
|
167
|
+
id: "ArtifactDetail",
|
|
168
|
+
description: "One artifact in full: its summary, the latest manifest and every version.",
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
/** The Zod schema of the `PublishReceipt` type. */
|
|
172
|
+
export const PublishReceipt: z.ZodType<PublishReceipt> = z
|
|
173
|
+
.object({
|
|
174
|
+
artifactId: ArtifactId.schema,
|
|
175
|
+
versionId: VersionId.schema,
|
|
176
|
+
version: z.int().min(1),
|
|
177
|
+
url: z.string().exactOptional(),
|
|
178
|
+
tokenId: TokenId.schema.exactOptional(),
|
|
179
|
+
cursor: Cursor.schema,
|
|
180
|
+
reused: z.boolean(),
|
|
181
|
+
forcedDiagnostics: z.array(z.string()).readonly().exactOptional(),
|
|
182
|
+
})
|
|
183
|
+
.register(wireRegistry, {
|
|
184
|
+
id: "PublishReceipt",
|
|
185
|
+
description:
|
|
186
|
+
"The receipt of artifact/publish: artifact, version, number, capability URL when served, event cursor, reuse.",
|
|
187
|
+
});
|