@sixb/core 0.2.4 → 0.2.5
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/dist/actions/index.js +28 -28
- package/dist/agents/execution.d.ts +34 -2
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/ids.d.ts +2 -0
- package/dist/agents/ids.d.ts.map +1 -1
- package/dist/agents/index.d.ts +6 -4
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +51 -33
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/queued-turn.d.ts +16 -0
- package/dist/agents/queued-turn.d.ts.map +1 -0
- package/dist/agents/request.d.ts +79 -1
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/run-after-finish.d.ts +10 -0
- package/dist/agents/run-after-finish.d.ts.map +1 -1
- package/dist/agents/run-artifacts.d.ts +0 -38
- package/dist/agents/run-artifacts.d.ts.map +1 -1
- package/dist/agents/run-events.d.ts +6 -1
- package/dist/agents/run-events.d.ts.map +1 -1
- package/dist/agents/run-session-http.d.ts.map +1 -1
- package/dist/agents/run-session-serve.d.ts.map +1 -1
- package/dist/agents/run-session.d.ts +14 -1
- package/dist/agents/run-session.d.ts.map +1 -1
- package/dist/agents/run-turn.d.ts.map +1 -1
- package/dist/agents/streams/index.d.ts +1 -1
- package/dist/agents/streams/index.d.ts.map +1 -1
- package/dist/agents/streams/index.js +1 -1
- package/dist/agents/streams/internal.js +1 -1
- package/dist/agents/streams/protocol.d.ts +16 -0
- package/dist/agents/streams/protocol.d.ts.map +1 -1
- package/dist/agents/turn-answered.d.ts +7 -0
- package/dist/agents/turn-answered.d.ts.map +1 -0
- package/dist/agents/validation.d.ts +1 -1
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/artifacts/canvas-display.d.ts +3 -5
- package/dist/artifacts/canvas-display.d.ts.map +1 -1
- package/dist/artifacts/comments.d.ts +14 -3
- package/dist/artifacts/comments.d.ts.map +1 -1
- package/dist/artifacts/document-fill.d.ts +18 -0
- package/dist/artifacts/document-fill.d.ts.map +1 -0
- package/dist/artifacts/errors.d.ts +1 -1
- package/dist/artifacts/errors.d.ts.map +1 -1
- package/dist/artifacts/events.d.ts +3 -2
- package/dist/artifacts/events.d.ts.map +1 -1
- package/dist/artifacts/execution.d.ts +40 -4
- package/dist/artifacts/execution.d.ts.map +1 -1
- package/dist/artifacts/frames/assets.d.ts +8 -1
- package/dist/artifacts/frames/assets.d.ts.map +1 -1
- package/dist/artifacts/frames/document-data.d.ts +98 -0
- package/dist/artifacts/frames/document-data.d.ts.map +1 -0
- package/dist/artifacts/frames/entries.d.ts +12 -7
- package/dist/artifacts/frames/entries.d.ts.map +1 -1
- package/dist/artifacts/frames/index.d.ts +2 -1
- package/dist/artifacts/frames/index.d.ts.map +1 -1
- package/dist/artifacts/frames/index.js +22 -13
- package/dist/artifacts/frames/index.js.map +4 -4
- package/dist/artifacts/frames/kit.d.ts +15 -0
- package/dist/artifacts/frames/kit.d.ts.map +1 -1
- package/dist/artifacts/frames/protocol.d.ts +12 -1
- package/dist/artifacts/frames/protocol.d.ts.map +1 -1
- package/dist/artifacts/frames/runtime.d.ts +24 -4
- package/dist/artifacts/frames/runtime.d.ts.map +1 -1
- package/dist/artifacts/index.d.ts +3 -1
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +9 -3
- package/dist/artifacts/index.js.map +3 -3
- package/dist/artifacts/live/blocks.d.ts +62 -0
- package/dist/artifacts/live/blocks.d.ts.map +1 -0
- package/dist/artifacts/live/board.d.ts +6 -0
- package/dist/artifacts/live/board.d.ts.map +1 -1
- package/dist/artifacts/live/document.d.ts +12 -0
- package/dist/artifacts/live/document.d.ts.map +1 -1
- package/dist/artifacts/live/index.d.ts +2 -0
- package/dist/artifacts/live/index.d.ts.map +1 -1
- package/dist/artifacts/live/index.js +148 -44
- package/dist/artifacts/live/index.js.map +3 -3
- package/dist/artifacts/live/page.d.ts +49 -0
- package/dist/artifacts/live/page.d.ts.map +1 -0
- package/dist/artifacts/live/protocol.d.ts +5 -0
- package/dist/artifacts/live/protocol.d.ts.map +1 -1
- package/dist/artifacts/live/server.d.ts +2 -2
- package/dist/artifacts/live/server.d.ts.map +1 -1
- package/dist/artifacts/live/server.js +23 -19
- package/dist/artifacts/live/server.js.map +1 -1
- package/dist/artifacts/live/state.d.ts +4 -1
- package/dist/artifacts/live/state.d.ts.map +1 -1
- package/dist/artifacts/outline.d.ts +16 -0
- package/dist/artifacts/outline.d.ts.map +1 -1
- package/dist/artifacts/paper.d.ts +22 -0
- package/dist/artifacts/paper.d.ts.map +1 -0
- package/dist/artifacts/pdf-job.d.ts +9 -0
- package/dist/artifacts/pdf-job.d.ts.map +1 -0
- package/dist/artifacts/publish/fields.d.ts +25 -0
- package/dist/artifacts/publish/fields.d.ts.map +1 -0
- package/dist/artifacts/publish/index.d.ts +2 -1
- package/dist/artifacts/publish/index.d.ts.map +1 -1
- package/dist/artifacts/publish/index.js +26 -18
- package/dist/artifacts/publish/index.js.map +1 -1
- package/dist/artifacts/publish/merge.d.ts +5 -5
- package/dist/artifacts/publish/merge.d.ts.map +1 -1
- package/dist/artifacts/publish/pdf.d.ts +28 -0
- package/dist/artifacts/publish/pdf.d.ts.map +1 -0
- package/dist/artifacts/publish/previews.d.ts +12 -20
- package/dist/artifacts/publish/previews.d.ts.map +1 -1
- package/dist/artifacts/publish/publish.d.ts.map +1 -1
- package/dist/artifacts/publish/queries.d.ts +6 -1
- package/dist/artifacts/publish/queries.d.ts.map +1 -1
- package/dist/artifacts/publish/query-answers.d.ts +5 -2
- package/dist/artifacts/publish/query-answers.d.ts.map +1 -1
- package/dist/artifacts/publish/validate/document-html.d.ts +24 -0
- package/dist/artifacts/publish/validate/document-html.d.ts.map +1 -0
- package/dist/artifacts/publish/validate/document.d.ts +5 -3
- package/dist/artifacts/publish/validate/document.d.ts.map +1 -1
- package/dist/artifacts/queries.d.ts +16 -2
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/auth/index.js +2 -2
- package/dist/authorization/event-visibility.d.ts.map +1 -1
- package/dist/authorization/index.js +1 -1
- package/dist/blob-storage/index.js +1 -1
- package/dist/bootstrap/index.js +38 -38
- package/dist/{chunk-8bns0y68.js → chunk-0hkdtwqk.js} +5 -5
- package/dist/{chunk-p8pgnq8d.js → chunk-0mvjpgvm.js} +5 -5
- package/dist/{chunk-2bn6813a.js → chunk-1yh6jgtz.js} +1 -1
- package/dist/{chunk-msyevpp3.js → chunk-5t9gm5tt.js} +4 -4
- package/dist/{chunk-a6fjkcne.js → chunk-60662fyv.js} +54 -28
- package/dist/{chunk-a6fjkcne.js.map → chunk-60662fyv.js.map} +7 -6
- package/dist/{chunk-e0hnbb1m.js → chunk-61zptves.js} +1 -1
- package/dist/{chunk-td26wjr5.js → chunk-68hm50qh.js} +3 -3
- package/dist/{chunk-9nsjjd44.js → chunk-8tv3qd65.js} +2 -1
- package/dist/chunk-8tv3qd65.js.map +12 -0
- package/dist/{chunk-fe6r7yhg.js → chunk-92wrka15.js} +1 -1
- package/dist/{chunk-3z1vxzcm.js → chunk-aw1z0gre.js} +4 -4
- package/dist/{chunk-evj5jxz3.js → chunk-b4escq4c.js} +62 -14
- package/dist/{chunk-evj5jxz3.js.map → chunk-b4escq4c.js.map} +7 -7
- package/dist/chunk-bqr703h4.js +1799 -0
- package/dist/chunk-bqr703h4.js.map +13 -0
- package/dist/{chunk-eptrvnby.js → chunk-c29729me.js} +42 -3
- package/dist/chunk-c29729me.js.map +12 -0
- package/dist/{chunk-t24yktqr.js → chunk-dvgc56n2.js} +20 -4
- package/dist/{chunk-t24yktqr.js.map → chunk-dvgc56n2.js.map} +5 -5
- package/dist/{chunk-3014rfjz.js → chunk-ewqn51gr.js} +25 -7
- package/dist/{chunk-3014rfjz.js.map → chunk-ewqn51gr.js.map} +3 -3
- package/dist/{chunk-t0s7b3d1.js → chunk-ey1p8w68.js} +173 -4
- package/dist/chunk-ey1p8w68.js.map +13 -0
- package/dist/{chunk-gxwy4c3s.js → chunk-fpf57gca.js} +316 -57
- package/dist/chunk-fpf57gca.js.map +47 -0
- package/dist/{chunk-r9rtavg9.js → chunk-fzae1jpq.js} +7 -7
- package/dist/{chunk-b9qfh2ya.js → chunk-fzbhybya.js} +29 -2
- package/dist/chunk-fzbhybya.js.map +11 -0
- package/dist/{chunk-w1wq7gfr.js → chunk-gjhrz66x.js} +225 -17
- package/dist/{chunk-w1wq7gfr.js.map → chunk-gjhrz66x.js.map} +5 -5
- package/dist/chunk-hn2r7z41.js.map +1 -1
- package/dist/{chunk-vepea5c3.js → chunk-k29n4176.js} +6 -6
- package/dist/{chunk-48c1z8nj.js → chunk-k3jh8gsg.js} +10 -2
- package/dist/chunk-k3jh8gsg.js.map +10 -0
- package/dist/{chunk-yy914zfr.js → chunk-m3qx2pns.js} +751 -93
- package/dist/chunk-m3qx2pns.js.map +34 -0
- package/dist/{chunk-smnt672s.js → chunk-m9ketb51.js} +20 -4
- package/dist/chunk-m9ketb51.js.map +10 -0
- package/dist/chunk-mbwsgjn7.js +40 -0
- package/dist/chunk-mbwsgjn7.js.map +11 -0
- package/dist/{chunk-sysnvjce.js → chunk-naxjka9v.js} +2 -2
- package/dist/{chunk-n4zzaf6q.js → chunk-nxysqbt0.js} +4 -2
- package/dist/chunk-nxysqbt0.js.map +10 -0
- package/dist/{chunk-vzkxqf8h.js → chunk-paxabbqd.js} +49 -5
- package/dist/chunk-paxabbqd.js.map +23 -0
- package/dist/{chunk-8tqnsx3q.js → chunk-pc7kra3k.js} +5 -3
- package/dist/{chunk-8tqnsx3q.js.map → chunk-pc7kra3k.js.map} +3 -3
- package/dist/{chunk-6ef4esq4.js → chunk-pqvvqc65.js} +4 -4
- package/dist/chunk-pvpq483h.js.map +2 -2
- package/dist/{chunk-mzx71snp.js → chunk-q7g9cqwt.js} +7 -2
- package/dist/{chunk-mzx71snp.js.map → chunk-q7g9cqwt.js.map} +3 -3
- package/dist/{chunk-8t2ynwg0.js → chunk-q8d9p0tb.js} +24 -1
- package/dist/{chunk-8t2ynwg0.js.map → chunk-q8d9p0tb.js.map} +3 -3
- package/dist/{chunk-wa05txmk.js → chunk-qavwr628.js} +49 -5
- package/dist/chunk-qavwr628.js.map +12 -0
- package/dist/{chunk-rsrc7vtw.js → chunk-rg725hry.js} +174 -30
- package/dist/{chunk-rsrc7vtw.js.map → chunk-rg725hry.js.map} +9 -8
- package/dist/{chunk-rsxb14an.js → chunk-s1mqyqmm.js} +3 -3
- package/dist/{chunk-p351afzm.js → chunk-s5pj68fa.js} +2 -2
- package/dist/{chunk-855w9nvw.js → chunk-vehcr9eb.js} +1 -1
- package/dist/{chunk-hvbvq7p4.js → chunk-vs2s3p8n.js} +731 -10
- package/dist/chunk-vs2s3p8n.js.map +20 -0
- package/dist/chunk-vtjzwymr.js.map +2 -2
- package/dist/{chunk-n68vz95m.js → chunk-wqe9shx2.js} +1 -1
- package/dist/{chunk-0k3r5kb3.js → chunk-xcrnrpfh.js} +1 -1
- package/dist/{chunk-cwdzcv37.js → chunk-xrmbhap8.js} +2 -2
- package/dist/{chunk-cwdzcv37.js.map → chunk-xrmbhap8.js.map} +2 -2
- package/dist/{chunk-f6ahf5gf.js → chunk-xxfj0rr2.js} +20 -5
- package/dist/chunk-xxfj0rr2.js.map +13 -0
- package/dist/{chunk-3hzhcfsv.js → chunk-y8fwm3z2.js} +2 -2
- package/dist/{chunk-3hzhcfsv.js.map → chunk-y8fwm3z2.js.map} +3 -3
- package/dist/{chunk-rtm1jq00.js → chunk-z1njfqqs.js} +439 -48
- package/dist/{chunk-rtm1jq00.js.map → chunk-z1njfqqs.js.map} +10 -8
- package/dist/{chunk-yv8hv4wq.js → chunk-z4jqb44a.js} +3 -1
- package/dist/chunk-z4jqb44a.js.map +10 -0
- package/dist/{chunk-s7xqfxs9.js → chunk-zft9bzbc.js} +2 -1
- package/dist/{chunk-s7xqfxs9.js.map → chunk-zft9bzbc.js.map} +3 -3
- package/dist/{chunk-7kpqntgw.js → chunk-zxhym8tr.js} +1 -1
- package/dist/connectors/connection-handles.d.ts +9 -0
- package/dist/connectors/connection-handles.d.ts.map +1 -0
- package/dist/connectors/connections/authorizations.d.ts +9 -0
- package/dist/connectors/connections/authorizations.d.ts.map +1 -1
- package/dist/connectors/connections/events.d.ts +17 -0
- package/dist/connectors/connections/events.d.ts.map +1 -0
- package/dist/connectors/connections/runs.d.ts +3 -0
- package/dist/connectors/connections/runs.d.ts.map +1 -1
- package/dist/connectors/connections/service.d.ts +4 -0
- package/dist/connectors/connections/service.d.ts.map +1 -1
- package/dist/connectors/execution.d.ts +7 -1
- package/dist/connectors/execution.d.ts.map +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/types.d.ts +22 -1
- package/dist/connectors/types.d.ts.map +1 -1
- package/dist/datasets/write.js +1 -1
- package/dist/deploy/index.d.ts +1 -1
- package/dist/deploy/index.d.ts.map +1 -1
- package/dist/deploy/internal.js +3 -2
- package/dist/deploy/internal.js.map +3 -3
- package/dist/deploy/services.d.ts.map +1 -1
- package/dist/deploy/types.d.ts +18 -1
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/events/definitions.d.ts +4 -0
- package/dist/events/definitions.d.ts.map +1 -1
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +3 -3
- package/dist/events/outbox-dispatcher.d.ts +7 -0
- package/dist/events/outbox-dispatcher.d.ts.map +1 -1
- package/dist/events/scope.d.ts +1 -0
- package/dist/events/scope.d.ts.map +1 -1
- package/dist/events/scope.js +1 -1
- package/dist/events/selectors/builder.d.ts +9 -1
- package/dist/events/selectors/builder.d.ts.map +1 -1
- package/dist/events/selectors/index.d.ts +2 -2
- package/dist/events/selectors/index.d.ts.map +1 -1
- package/dist/events/selectors/index.js +2 -2
- package/dist/events/selectors/predicate.d.ts.map +1 -1
- package/dist/events/selectors/types.d.ts +18 -3
- package/dist/events/selectors/types.d.ts.map +1 -1
- package/dist/events/types/artifacts.d.ts +7 -1
- package/dist/events/types/artifacts.d.ts.map +1 -1
- package/dist/events/types/connectors.d.ts +32 -0
- package/dist/events/types/connectors.d.ts.map +1 -0
- package/dist/events/types/index.d.ts +3 -1
- package/dist/events/types/index.d.ts.map +1 -1
- package/dist/execution/agent.js +28 -28
- package/dist/execution/authorization.d.ts +5 -0
- package/dist/execution/authorization.d.ts.map +1 -1
- package/dist/execution/primitive.js +28 -28
- package/dist/execution/request.js +29 -29
- package/dist/execution/scopes.d.ts +8 -0
- package/dist/execution/scopes.d.ts.map +1 -1
- package/dist/execution/script.d.ts +7 -0
- package/dist/execution/script.d.ts.map +1 -0
- package/dist/execution/types.d.ts +16 -1
- package/dist/execution/types.d.ts.map +1 -1
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -44
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/index.js +1 -1
- package/dist/lineage/executors.d.ts +1 -1
- package/dist/lineage/executors.d.ts.map +1 -1
- package/dist/maintenance/index.js +1 -1
- package/dist/materialization/event-envelopes.d.ts +3 -3
- package/dist/materialization/event-envelopes.d.ts.map +1 -1
- package/dist/materialization/events.d.ts +6 -0
- package/dist/materialization/events.d.ts.map +1 -1
- package/dist/materialization/index.js +1 -1
- package/dist/materialization/model.d.ts +6 -0
- package/dist/materialization/model.d.ts.map +1 -1
- package/dist/materializer/index.js +13 -13
- package/dist/materializer/projections/replace.d.ts.map +1 -1
- package/dist/materializer/projections/replacement-plan.d.ts +2 -0
- package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
- package/dist/materializer/shared/normalize.d.ts +1 -0
- package/dist/materializer/shared/normalize.d.ts.map +1 -1
- package/dist/models/execution/index.js +12 -12
- package/dist/objects/index.js +28 -28
- package/dist/objects/query/index.js +12 -12
- package/dist/pipelines/index.js +18 -18
- package/dist/projections/builders.d.ts +7 -1
- package/dist/projections/builders.d.ts.map +1 -1
- package/dist/projections/index.d.ts +1 -1
- package/dist/projections/index.d.ts.map +1 -1
- package/dist/projections/internal.js +13 -13
- package/dist/projections/types.d.ts +10 -0
- package/dist/projections/types.d.ts.map +1 -1
- package/dist/projections/validation.d.ts.map +1 -1
- package/dist/queues/in-memory.d.ts +2 -1
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.d.ts +1 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/types.d.ts +40 -13
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +13 -0
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +1 -0
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +39 -18
- package/dist/runtime/internal.js.map +4 -3
- package/dist/runtime/resolve-definitions.d.ts +1 -1
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/script.d.ts +39 -0
- package/dist/runtime/script.d.ts.map +1 -0
- package/dist/runtime/sixb.d.ts +2 -2
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/schedules/builders.d.ts.map +1 -1
- package/dist/schedules/index.js +3 -3
- package/dist/schedules/runtime.d.ts.map +1 -1
- package/dist/schedules/validation.d.ts +2 -0
- package/dist/schedules/validation.d.ts.map +1 -1
- package/dist/shares/internal.js +12 -12
- package/dist/storage/agents/errors.d.ts +1 -1
- package/dist/storage/agents/errors.d.ts.map +1 -1
- package/dist/storage/agents/in-memory.d.ts +26 -1
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +2 -2
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.d.ts +12 -3
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +25 -5
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +155 -0
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/artifacts/in-memory.d.ts +7 -1
- package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
- package/dist/storage/artifacts/index.d.ts +1 -1
- package/dist/storage/artifacts/index.d.ts.map +1 -1
- package/dist/storage/artifacts/record.d.ts +2 -1
- package/dist/storage/artifacts/record.d.ts.map +1 -1
- package/dist/storage/artifacts/types.d.ts +34 -0
- package/dist/storage/artifacts/types.d.ts.map +1 -1
- package/dist/storage/executions/provider.d.ts +3 -3
- package/dist/storage/executions/provider.d.ts.map +1 -1
- package/dist/storage/executions/provider.js +1 -1
- package/dist/storage/executions/types.d.ts +6 -0
- package/dist/storage/executions/types.d.ts.map +1 -1
- package/dist/storage/executions/validation.d.ts.map +1 -1
- package/dist/storage/file-upload-sessions/provider.js +3 -3
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +18 -14
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +1 -1
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +8 -6
- package/dist/storage/internal.js.map +2 -2
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts +2 -0
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +1 -1
- package/dist/storage/ontology/replacement-plans.d.ts +8 -0
- package/dist/storage/ontology/replacement-plans.d.ts.map +1 -1
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +1 -1
- package/dist/storage/workflow-runs/provider.js +3 -3
- package/dist/syncs/index.js +19 -19
- package/dist/testing/agent-execution.d.ts +3 -0
- package/dist/testing/agent-execution.d.ts.map +1 -1
- package/dist/testing/agent-inbox-storage-contract.d.ts +15 -0
- package/dist/testing/agent-inbox-storage-contract.d.ts.map +1 -0
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
- package/dist/testing/execution-storage-contract.d.ts.map +1 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +5524 -4555
- package/dist/testing/index.js.map +10 -9
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/webhooks/connections.d.ts +3 -4
- package/dist/webhooks/connections.d.ts.map +1 -1
- package/dist/webhooks/index.d.ts +1 -1
- package/dist/webhooks/index.d.ts.map +1 -1
- package/dist/webhooks/internal.js +16 -49
- package/dist/webhooks/internal.js.map +3 -3
- package/dist/webhooks/types.d.ts +2 -11
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/workers/queued-run-dispatch.d.ts.map +1 -1
- package/dist/workflows/index.js +35 -35
- package/package.json +6 -1
- package/src/agents/README.md +6 -2
- package/src/agents/execution.ts +167 -29
- package/src/agents/ids.ts +5 -0
- package/src/agents/index.ts +18 -4
- package/src/agents/queued-turn.ts +46 -0
- package/src/agents/request.ts +517 -2
- package/src/agents/run-after-finish.ts +259 -2
- package/src/agents/run-artifacts.ts +3 -93
- package/src/agents/run-events.ts +26 -1
- package/src/agents/run-session-http.ts +9 -2
- package/src/agents/run-session-serve.ts +2 -8
- package/src/agents/run-session.ts +142 -3
- package/src/agents/run-turn.ts +8 -0
- package/src/agents/streams/index.ts +1 -0
- package/src/agents/streams/protocol.ts +41 -1
- package/src/agents/turn-answered.ts +31 -0
- package/src/agents/validation.ts +2 -0
- package/src/artifacts/canvas-display.ts +4 -6
- package/src/artifacts/comments.ts +70 -17
- package/src/artifacts/document-fill.ts +103 -0
- package/src/artifacts/errors.ts +2 -0
- package/src/artifacts/events.ts +4 -1
- package/src/artifacts/execution.ts +265 -31
- package/src/artifacts/frames/assets.ts +42 -7
- package/src/artifacts/frames/document-data.ts +353 -0
- package/src/artifacts/frames/entries.ts +22 -16
- package/src/artifacts/frames/grants.ts +2 -2
- package/src/artifacts/frames/index.ts +3 -0
- package/src/artifacts/frames/kit.ts +102 -0
- package/src/artifacts/frames/protocol.ts +12 -1
- package/src/artifacts/frames/runtime.ts +413 -6
- package/src/artifacts/index.ts +3 -0
- package/src/artifacts/live/blocks.ts +889 -0
- package/src/artifacts/live/board.ts +195 -42
- package/src/artifacts/live/document.ts +170 -5
- package/src/artifacts/live/index.ts +7 -0
- package/src/artifacts/live/page.ts +807 -0
- package/src/artifacts/live/protocol.ts +5 -0
- package/src/artifacts/live/server.ts +2 -2
- package/src/artifacts/live/state.ts +9 -4
- package/src/artifacts/outline.ts +17 -0
- package/src/artifacts/paper.ts +173 -0
- package/src/artifacts/pdf-job.ts +11 -0
- package/src/artifacts/publish/fields.ts +177 -0
- package/src/artifacts/publish/index.ts +6 -1
- package/src/artifacts/publish/merge.ts +14 -12
- package/src/artifacts/publish/pdf.ts +82 -0
- package/src/artifacts/publish/previews.ts +24 -34
- package/src/artifacts/publish/publish.ts +26 -3
- package/src/artifacts/publish/queries.ts +20 -4
- package/src/artifacts/publish/query-answers.ts +14 -3
- package/src/artifacts/publish/validate/document-html.ts +245 -0
- package/src/artifacts/publish/validate/document.ts +34 -3
- package/src/artifacts/queries.ts +59 -13
- package/src/authorization/event-visibility.ts +13 -0
- package/src/connectors/connection-handles.ts +71 -0
- package/src/connectors/connections/authorizations.ts +50 -2
- package/src/connectors/connections/events.ts +57 -0
- package/src/connectors/connections/runs.ts +5 -0
- package/src/connectors/connections/service.ts +19 -1
- package/src/connectors/execution.ts +30 -2
- package/src/connectors/index.ts +3 -0
- package/src/connectors/types.ts +29 -1
- package/src/deploy/index.ts +1 -0
- package/src/deploy/services.ts +1 -0
- package/src/deploy/types.ts +26 -1
- package/src/events/definitions.ts +14 -0
- package/src/events/execution.ts +9 -2
- package/src/events/index.ts +8 -0
- package/src/events/outbox-dispatcher.ts +12 -2
- package/src/events/scope.ts +3 -0
- package/src/events/selectors/builder.ts +49 -0
- package/src/events/selectors/index.ts +5 -0
- package/src/events/selectors/predicate.ts +2 -0
- package/src/events/selectors/types.ts +30 -1
- package/src/events/types/artifacts.ts +7 -1
- package/src/events/types/connectors.ts +36 -0
- package/src/events/types/index.ts +7 -0
- package/src/execution/authorization.ts +45 -0
- package/src/execution/durable.ts +2 -0
- package/src/execution/scopes.ts +24 -0
- package/src/execution/script.ts +27 -0
- package/src/execution/types.ts +7 -1
- package/src/http/api-routes.ts +25 -0
- package/src/index.ts +21 -2
- package/src/lineage/executors.ts +3 -1
- package/src/materialization/event-envelopes.ts +10 -5
- package/src/materialization/events.ts +2 -0
- package/src/materialization/model.ts +6 -0
- package/src/materializer/README.md +10 -0
- package/src/materializer/projections/replace.ts +42 -1
- package/src/materializer/projections/replacement-plan.ts +44 -4
- package/src/materializer/shared/normalize.ts +4 -0
- package/src/projections/builders.ts +20 -0
- package/src/projections/index.ts +1 -0
- package/src/projections/registry.ts +1 -0
- package/src/projections/revision.ts +2 -0
- package/src/projections/types.ts +11 -0
- package/src/projections/validation.ts +6 -0
- package/src/queues/in-memory.ts +5 -0
- package/src/queues/index.ts +3 -1
- package/src/queues/types.ts +45 -14
- package/src/runtime/host.ts +112 -4
- package/src/runtime/internal.ts +1 -0
- package/src/runtime/resolve-definitions.ts +4 -1
- package/src/runtime/script.ts +62 -0
- package/src/runtime/sixb.ts +3 -3
- package/src/schedules/builders.ts +4 -1
- package/src/schedules/runtime.ts +3 -0
- package/src/schedules/validation.ts +20 -2
- package/src/storage/agents/errors.ts +1 -0
- package/src/storage/agents/in-memory.ts +229 -1
- package/src/storage/agents/index.ts +16 -0
- package/src/storage/agents/provider.ts +284 -2
- package/src/storage/agents/types.ts +167 -0
- package/src/storage/artifacts/in-memory.ts +32 -1
- package/src/storage/artifacts/index.ts +2 -0
- package/src/storage/artifacts/record.ts +25 -2
- package/src/storage/artifacts/types.ts +37 -0
- package/src/storage/executions/provider.ts +22 -2
- package/src/storage/executions/types.ts +2 -0
- package/src/storage/executions/validation.ts +27 -0
- package/src/storage/index.ts +18 -0
- package/src/storage/internal.ts +1 -0
- package/src/storage/ontology/in-memory/replacement-plans.ts +22 -0
- package/src/storage/ontology/replacement-plans.ts +6 -0
- package/src/storage/operation-scope.ts +1 -0
- package/src/testing/agent-execution.ts +45 -2
- package/src/testing/agent-inbox-storage-contract.ts +815 -0
- package/src/testing/agent-storage-contract.ts +103 -0
- package/src/testing/artifact-storage-contract.ts +72 -4
- package/src/testing/execution-storage-contract.ts +31 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/materializer-storage-contract.ts +139 -1
- package/src/testing/queues-contract.ts +22 -0
- package/src/webhooks/connections.ts +9 -50
- package/src/webhooks/index.ts +0 -2
- package/src/webhooks/types.ts +2 -13
- package/src/workers/queued-run-dispatch.ts +8 -1
- package/dist/chunk-48c1z8nj.js.map +0 -10
- package/dist/chunk-58geavnf.js +0 -29
- package/dist/chunk-58geavnf.js.map +0 -10
- package/dist/chunk-9nsjjd44.js.map +0 -12
- package/dist/chunk-b9qfh2ya.js.map +0 -11
- package/dist/chunk-eptrvnby.js.map +0 -12
- package/dist/chunk-f6ahf5gf.js.map +0 -13
- package/dist/chunk-gxwy4c3s.js.map +0 -47
- package/dist/chunk-hvbvq7p4.js.map +0 -18
- package/dist/chunk-m2jerfef.js +0 -474
- package/dist/chunk-m2jerfef.js.map +0 -11
- package/dist/chunk-n4zzaf6q.js.map +0 -10
- package/dist/chunk-smnt672s.js.map +0 -10
- package/dist/chunk-t0s7b3d1.js.map +0 -13
- package/dist/chunk-vzkxqf8h.js.map +0 -23
- package/dist/chunk-wa05txmk.js.map +0 -11
- package/dist/chunk-yv8hv4wq.js.map +0 -10
- package/dist/chunk-yy914zfr.js.map +0 -30
- /package/dist/{chunk-8bns0y68.js.map → chunk-0hkdtwqk.js.map} +0 -0
- /package/dist/{chunk-p8pgnq8d.js.map → chunk-0mvjpgvm.js.map} +0 -0
- /package/dist/{chunk-2bn6813a.js.map → chunk-1yh6jgtz.js.map} +0 -0
- /package/dist/{chunk-msyevpp3.js.map → chunk-5t9gm5tt.js.map} +0 -0
- /package/dist/{chunk-e0hnbb1m.js.map → chunk-61zptves.js.map} +0 -0
- /package/dist/{chunk-td26wjr5.js.map → chunk-68hm50qh.js.map} +0 -0
- /package/dist/{chunk-fe6r7yhg.js.map → chunk-92wrka15.js.map} +0 -0
- /package/dist/{chunk-3z1vxzcm.js.map → chunk-aw1z0gre.js.map} +0 -0
- /package/dist/{chunk-r9rtavg9.js.map → chunk-fzae1jpq.js.map} +0 -0
- /package/dist/{chunk-vepea5c3.js.map → chunk-k29n4176.js.map} +0 -0
- /package/dist/{chunk-sysnvjce.js.map → chunk-naxjka9v.js.map} +0 -0
- /package/dist/{chunk-6ef4esq4.js.map → chunk-pqvvqc65.js.map} +0 -0
- /package/dist/{chunk-rsxb14an.js.map → chunk-s1mqyqmm.js.map} +0 -0
- /package/dist/{chunk-p351afzm.js.map → chunk-s5pj68fa.js.map} +0 -0
- /package/dist/{chunk-855w9nvw.js.map → chunk-vehcr9eb.js.map} +0 -0
- /package/dist/{chunk-n68vz95m.js.map → chunk-wqe9shx2.js.map} +0 -0
- /package/dist/{chunk-0k3r5kb3.js.map → chunk-xcrnrpfh.js.map} +0 -0
- /package/dist/{chunk-7kpqntgw.js.map → chunk-zxhym8tr.js.map} +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultTreeAdapter as adapter,
|
|
3
|
+
type DefaultTreeAdapterTypes,
|
|
4
|
+
parse,
|
|
5
|
+
serialize,
|
|
6
|
+
} from "parse5"
|
|
7
|
+
import {
|
|
8
|
+
type DocumentMark,
|
|
9
|
+
type DocumentSources,
|
|
10
|
+
type DocumentTree,
|
|
11
|
+
documentData,
|
|
12
|
+
} from "./frames/document-data"
|
|
13
|
+
|
|
14
|
+
// A designed document's live data on the server, over parse5: the fields and repeated elements of
|
|
15
|
+
// its `document.html`, and that markup with the values a reader read written in, as a frozen
|
|
16
|
+
// version keeps it or a version prints. The frame shows the same values the same way: both walk
|
|
17
|
+
// the markup with `documentData`.
|
|
18
|
+
|
|
19
|
+
type Element = DefaultTreeAdapterTypes.Element
|
|
20
|
+
type ChildNode = DefaultTreeAdapterTypes.ChildNode
|
|
21
|
+
|
|
22
|
+
const isElement = (node: DefaultTreeAdapterTypes.Node): node is Element => "tagName" in node
|
|
23
|
+
|
|
24
|
+
const tree: DocumentTree<Element> = {
|
|
25
|
+
children: (node) => node.childNodes.filter(isElement),
|
|
26
|
+
attribute: (node, name) => node.attrs.find((each) => each.name === name)?.value ?? null,
|
|
27
|
+
setAttribute(node, name, value) {
|
|
28
|
+
const found = node.attrs.find((each) => each.name === name)
|
|
29
|
+
if (found) found.value = value
|
|
30
|
+
else node.attrs.push({ name, value })
|
|
31
|
+
},
|
|
32
|
+
removeAttribute(node, name) {
|
|
33
|
+
node.attrs = node.attrs.filter((each) => each.name !== name)
|
|
34
|
+
},
|
|
35
|
+
setText(node, text) {
|
|
36
|
+
for (const child of [...node.childNodes]) adapter.detachNode(child)
|
|
37
|
+
adapter.insertText(node, text)
|
|
38
|
+
},
|
|
39
|
+
clone: (node) => copy(node) as Element,
|
|
40
|
+
replace(node, nodes) {
|
|
41
|
+
const parent = node.parentNode
|
|
42
|
+
if (!parent) return
|
|
43
|
+
for (const each of nodes) adapter.insertBefore(parent, each, node)
|
|
44
|
+
adapter.detachNode(node)
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function copy(node: ChildNode): ChildNode {
|
|
49
|
+
if (!isElement(node)) return { ...node, parentNode: null }
|
|
50
|
+
const element = adapter.createElement(
|
|
51
|
+
node.tagName,
|
|
52
|
+
node.namespaceURI,
|
|
53
|
+
node.attrs.map((each) => ({ ...each }))
|
|
54
|
+
)
|
|
55
|
+
for (const child of node.childNodes) adapter.appendChild(element, copy(child))
|
|
56
|
+
return element
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function bodyOf(html: string) {
|
|
60
|
+
const document = parse(html)
|
|
61
|
+
const root = document.childNodes.find(isElement)
|
|
62
|
+
const body = root?.childNodes.find(
|
|
63
|
+
(child): child is Element => isElement(child) && child.tagName === "body"
|
|
64
|
+
)
|
|
65
|
+
return { document, root, body }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The fields and repeated elements of a designed document's markup. */
|
|
69
|
+
export function documentMarks(html: string): DocumentMark[] {
|
|
70
|
+
const { body } = bodyOf(html)
|
|
71
|
+
return body ? documentData().marks(body, tree) : []
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A designed document's markup with the values `sources` hold written in. `plain` leaves no field
|
|
76
|
+
* marked, as a version prints; `keep` leaves every one marked, as a frozen version keeps them.
|
|
77
|
+
* Markup with no field or repeated element is returned as it is.
|
|
78
|
+
*/
|
|
79
|
+
export function fillDocumentHtml(
|
|
80
|
+
html: string,
|
|
81
|
+
sources: DocumentSources,
|
|
82
|
+
options: { readonly plain?: boolean; readonly keep?: boolean } = {}
|
|
83
|
+
): string {
|
|
84
|
+
const { document, root, body } = bodyOf(html)
|
|
85
|
+
if (!body || documentData().marks(body, tree).length === 0) return html
|
|
86
|
+
|
|
87
|
+
const lang = root ? (tree.attribute(root, "lang") ?? undefined) : undefined
|
|
88
|
+
documentData().fill(body, tree, {
|
|
89
|
+
sources,
|
|
90
|
+
...(lang ? { lang } : {}),
|
|
91
|
+
...(options.plain ? { plain: true } : {}),
|
|
92
|
+
...(options.keep ? { keep: true } : {}),
|
|
93
|
+
})
|
|
94
|
+
return serialize(document)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A frozen version's markup as it shows and prints: the values written in when it was frozen, and
|
|
99
|
+
* no field marked, so none is read again.
|
|
100
|
+
*/
|
|
101
|
+
export function frozenDocumentHtml(html: string): string {
|
|
102
|
+
return fillDocumentHtml(html, { queries: {} }, { plain: true })
|
|
103
|
+
}
|
package/src/artifacts/errors.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type ArtifactRequestErrorCode =
|
|
|
6
6
|
| "artifact_moved"
|
|
7
7
|
| "comment_not_found"
|
|
8
8
|
| "comments_full"
|
|
9
|
+
| "holder_not_found"
|
|
9
10
|
| "invalid_artifact"
|
|
10
11
|
| "invalid_comment"
|
|
11
12
|
| "invalid_state"
|
|
@@ -13,6 +14,7 @@ export type ArtifactRequestErrorCode =
|
|
|
13
14
|
| "state_full"
|
|
14
15
|
| "not_allowed"
|
|
15
16
|
| "not_shared"
|
|
17
|
+
| "pdf_unavailable"
|
|
16
18
|
| "query_invalid"
|
|
17
19
|
| "query_not_found"
|
|
18
20
|
| "read_only"
|
package/src/artifacts/events.ts
CHANGED
|
@@ -31,12 +31,14 @@ export async function announceArtifactUpdates(
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* Tells whoever reads the
|
|
34
|
+
* Tells whoever reads the comment's thread that it changed, as `artifact.commented`: the
|
|
35
|
+
* artifact's members, and the guests of `shareGrantId`, the link a guest's thread came through.
|
|
35
36
|
* The change is stored by now, so `emit` never fails it.
|
|
36
37
|
*/
|
|
37
38
|
export async function announceArtifactComment(
|
|
38
39
|
events: Pick<DomainEventLog, "emit">,
|
|
39
40
|
comment: Pick<ArtifactCommentRecord, "artifactId" | "id" | "parentId">,
|
|
41
|
+
shareGrantId: string | undefined,
|
|
40
42
|
action: "created" | "resolved" | "reopened" | "deleted"
|
|
41
43
|
): Promise<void> {
|
|
42
44
|
await events.emit(
|
|
@@ -48,6 +50,7 @@ export async function announceArtifactComment(
|
|
|
48
50
|
artifactId: comment.artifactId,
|
|
49
51
|
commentId: comment.id,
|
|
50
52
|
...(comment.parentId === undefined ? {} : { parentId: comment.parentId }),
|
|
53
|
+
...(shareGrantId === undefined ? {} : { shareGrantId }),
|
|
51
54
|
action,
|
|
52
55
|
},
|
|
53
56
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createAgentThreadAccessRule } from "../agents/thread-access"
|
|
2
2
|
import { type Principal, SYSTEM_PRINCIPAL } from "../auth"
|
|
3
|
-
import { isRuntimeAllowed } from "../authorization"
|
|
4
|
-
import type { BlobStorage } from "../blob-storage/types"
|
|
3
|
+
import { AuthorizationError, isRuntimeAllowed } from "../authorization"
|
|
4
|
+
import type { BlobStorage, FileRef } from "../blob-storage/types"
|
|
5
|
+
import { computeBlobDigest } from "../blob-storage/utils"
|
|
5
6
|
import { resolveRuntimeAuthorizationForProject } from "../execution/authorization"
|
|
6
7
|
import { type AuthorizedObjectReader, objectReadersIn } from "../execution/authorized-object-reader"
|
|
7
8
|
import type { SharedAccessDelegationRef } from "../execution/types"
|
|
@@ -30,14 +31,18 @@ import {
|
|
|
30
31
|
type HolderAccess,
|
|
31
32
|
} from "./access"
|
|
32
33
|
import { type ArtifactCommentsRuntime, createArtifactCommentsRuntime } from "./comments"
|
|
34
|
+
import { documentMarks, fillDocumentHtml, frozenDocumentHtml } from "./document-fill"
|
|
33
35
|
import { ArtifactRequestError } from "./errors"
|
|
34
36
|
import { announceArtifactUpdates } from "./events"
|
|
37
|
+
import { type DocumentQueryResult, documentData } from "./frames/document-data"
|
|
35
38
|
import { type ArtifactHolding, readableHoldings } from "./holders"
|
|
36
39
|
import type { ArtifactKind } from "./kinds"
|
|
37
40
|
import { ARTIFACT_HOLDERS_LIMIT, ARTIFACT_LIMITS, ARTIFACT_STATE_LIMITS } from "./limits"
|
|
38
41
|
import { firstArtifactDocument, keepsDocument } from "./live/state"
|
|
42
|
+
import type { DocumentHolder } from "./outline"
|
|
39
43
|
import { invalidArtifact, readArtifactText } from "./publish/files"
|
|
40
44
|
import { type ArtifactWrite, withDocumentHolding, withMergedWrite } from "./publish/merge"
|
|
45
|
+
import { documentPdfKey, requestDocumentPdf } from "./publish/pdf"
|
|
41
46
|
import {
|
|
42
47
|
type BoardPreviewRequester,
|
|
43
48
|
boardsReadLiveData,
|
|
@@ -53,10 +58,12 @@ import {
|
|
|
53
58
|
storeArtifactVersion,
|
|
54
59
|
} from "./publish/publish"
|
|
55
60
|
import { type ArtifactQueryChecker, createArtifactQueryChecker } from "./publish/queries"
|
|
61
|
+
import { DOCUMENT_HTML_ENTRY } from "./publish/validate/document-html"
|
|
56
62
|
import {
|
|
57
63
|
ARTIFACT_QUERY_KINDS,
|
|
58
64
|
type ArtifactQueryResult,
|
|
59
65
|
artifactQueryPath,
|
|
66
|
+
DOCUMENT_HOLDER_QUERY,
|
|
60
67
|
isArtifactQueryName,
|
|
61
68
|
parseArtifactQuery,
|
|
62
69
|
} from "./queries"
|
|
@@ -101,7 +108,7 @@ export interface UpdateArtifactRuntimeInput extends ArtifactContentInput {
|
|
|
101
108
|
*/
|
|
102
109
|
readonly baseFiles?: readonly ArtifactFile[]
|
|
103
110
|
/**
|
|
104
|
-
* The title of `baseRevision`. A
|
|
111
|
+
* The title of `baseRevision`. A write merged past it keeps a title someone gave it since,
|
|
105
112
|
* unless this write changes the title itself.
|
|
106
113
|
*/
|
|
107
114
|
readonly baseTitle?: string
|
|
@@ -196,6 +203,27 @@ export interface ArtifactsRuntime extends ArtifactCommentsRuntime {
|
|
|
196
203
|
*/
|
|
197
204
|
holders(artifactId: string): Promise<ArtifactHolders | null>
|
|
198
205
|
getVersion(artifactId: string, version: number | "latest"): Promise<ArtifactVersionRecord | null>
|
|
206
|
+
/**
|
|
207
|
+
* A designed document's PDF, printed as its stylesheets' `@page` rule lays it out, with the
|
|
208
|
+
* values its fields read as the caller reads them: `ready` with its file once printed, else
|
|
209
|
+
* `printing`, having asked the render worker to print it, which takes a few seconds; `print:
|
|
210
|
+
* false` reads it without asking. `failed` with why when it could not be printed; `retry` asks
|
|
211
|
+
* again instead. A document that shows live data answers with a `key` naming the values it
|
|
212
|
+
* prints: asked again with it, it reads what that first ask printed, whatever the values are by
|
|
213
|
+
* then, and asks nothing more.
|
|
214
|
+
* Whoever reads the artifact may ask. `null` when the caller cannot read the artifact or it has
|
|
215
|
+
* no such version. Throws `invalid_artifact` for a version that is not a designed document, and
|
|
216
|
+
* `pdf_unavailable` in a project without sandboxes, where nothing prints.
|
|
217
|
+
*/
|
|
218
|
+
pdf(
|
|
219
|
+
artifactId: string,
|
|
220
|
+
options?: {
|
|
221
|
+
readonly version?: number | "latest"
|
|
222
|
+
readonly retry?: boolean
|
|
223
|
+
readonly print?: boolean
|
|
224
|
+
readonly key?: string
|
|
225
|
+
}
|
|
226
|
+
): Promise<ArtifactPdf | null>
|
|
199
227
|
/**
|
|
200
228
|
* Runs the version's query `queries/<name>.json` as the caller, with their rights: a type they
|
|
201
229
|
* cannot view refuses it, and a marked property they are not cleared for is left out of each
|
|
@@ -243,6 +271,21 @@ export interface ArtifactStateRuntime {
|
|
|
243
271
|
clear(): Promise<number>
|
|
244
272
|
}
|
|
245
273
|
|
|
274
|
+
/** A designed document's PDF: its file once printed, being printed, or why it could not be. */
|
|
275
|
+
export type ArtifactPdf = (
|
|
276
|
+
| {
|
|
277
|
+
readonly status: "ready"
|
|
278
|
+
readonly file: FileRef
|
|
279
|
+
/** How many pages it printed on. */
|
|
280
|
+
readonly pages: number
|
|
281
|
+
}
|
|
282
|
+
| { readonly status: "printing" }
|
|
283
|
+
| { readonly status: "failed"; readonly reason: string }
|
|
284
|
+
) & {
|
|
285
|
+
/** The values a document that shows live data prints, to ask for that PDF again with. */
|
|
286
|
+
readonly key?: string
|
|
287
|
+
}
|
|
288
|
+
|
|
246
289
|
/** The objects that hold an artifact, as the caller reads them. */
|
|
247
290
|
export interface ArtifactHolders {
|
|
248
291
|
readonly holders: readonly ArtifactHolderObject[]
|
|
@@ -433,8 +476,11 @@ export function createArtifactsRuntime(
|
|
|
433
476
|
runtime: SixbRuntimeContext,
|
|
434
477
|
blobStorage: BlobStorage,
|
|
435
478
|
options: {
|
|
436
|
-
/**
|
|
437
|
-
|
|
479
|
+
/**
|
|
480
|
+
* The project has sandboxes, where the render worker pictures canvas boards and prints
|
|
481
|
+
* designed documents to PDF.
|
|
482
|
+
*/
|
|
483
|
+
readonly rendersInSandboxes?: boolean
|
|
438
484
|
} = {}
|
|
439
485
|
): ArtifactsRuntime {
|
|
440
486
|
const authority = resolveRuntimeAuthorizationForProject(runtime)
|
|
@@ -476,15 +522,144 @@ export function createArtifactsRuntime(
|
|
|
476
522
|
|
|
477
523
|
const rule = (): ArtifactAccessRule => createRuntimeArtifactAccessRule(runtime)
|
|
478
524
|
const checkQuery = createArtifactQueryChecker(runtime)
|
|
525
|
+
|
|
526
|
+
/** Runs one of a version's queries, or a designed document's holder, as the caller. */
|
|
527
|
+
const runQuery = async (
|
|
528
|
+
read: { readonly artifact: ArtifactRecord; readonly version: ArtifactVersionRecord },
|
|
529
|
+
name: string
|
|
530
|
+
): Promise<ArtifactQueryResult> => {
|
|
531
|
+
// A file artifact is delivered as it is: its one file is never run.
|
|
532
|
+
const { artifact, version } = read
|
|
533
|
+
const holder = version.outline.kind === "document" ? version.outline.holder : undefined
|
|
534
|
+
|
|
535
|
+
// What a designed document's fields read of the object that holds it: that object, with
|
|
536
|
+
// the objects each link they read through reaches.
|
|
537
|
+
if (holder && name === DOCUMENT_HOLDER_QUERY) {
|
|
538
|
+
const refs: ObjectQuery = { kind: "refs", refs: [await requireHolder(artifact.id, holder)] }
|
|
539
|
+
const expansions = holder.links.map((linkId) => ({
|
|
540
|
+
linkId,
|
|
541
|
+
direction: "outgoing" as const,
|
|
542
|
+
}))
|
|
543
|
+
return runArtifactQuery(runtime, name, {
|
|
544
|
+
kind: "objects",
|
|
545
|
+
query: expansions.length > 0 ? { kind: "expand", input: refs, expansions } : refs,
|
|
546
|
+
})
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
const file =
|
|
550
|
+
ARTIFACT_QUERY_KINDS.includes(artifact.kind) && isArtifactQueryName(name)
|
|
551
|
+
? version.files.find((candidate) => candidate.path === artifactQueryPath(name))
|
|
552
|
+
: undefined
|
|
553
|
+
if (!file) {
|
|
554
|
+
throw new ArtifactRequestError(
|
|
555
|
+
"query_not_found",
|
|
556
|
+
`[Sixb] Version ${version.version} of artifact '${artifact.id}' has no query '${name}'.`
|
|
557
|
+
)
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const text = await readArtifactText(blobStorage, file, ARTIFACT_LIMITS.maxQueryBytes)
|
|
561
|
+
const parse = (start?: ObjectQuery) =>
|
|
562
|
+
parseArtifactQuery(file.path, text, start ? { holder: start } : {})
|
|
563
|
+
let parsed = parse(holder ? { kind: "refs", refs: [] } : undefined)
|
|
564
|
+
// A query that starts from the holder is read again from the one the caller reads.
|
|
565
|
+
if (holder && "usesHolder" in parsed && parsed.usesHolder) {
|
|
566
|
+
parsed = parse({ kind: "refs", refs: [await requireHolder(artifact.id, holder)] })
|
|
567
|
+
}
|
|
568
|
+
if ("error" in parsed) {
|
|
569
|
+
throw new ArtifactRequestError("query_invalid", `[Sixb] ${parsed.error}`)
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
return runArtifactQuery(runtime, name, parsed.query)
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* A designed document's markup with the values its fields read written in, as the caller reads
|
|
577
|
+
* them, and no field left marked, or every one with `keep`; null when it shows no live data. What
|
|
578
|
+
* the caller cannot read keeps its written text. A frozen version's are those written in when it
|
|
579
|
+
* was frozen, which are not read again.
|
|
580
|
+
*/
|
|
581
|
+
const writtenIn = async (
|
|
582
|
+
read: {
|
|
583
|
+
readonly artifact: ArtifactRecord
|
|
584
|
+
readonly version: ArtifactVersionRecord
|
|
585
|
+
},
|
|
586
|
+
options: { readonly keep?: boolean } = {}
|
|
587
|
+
): Promise<string | null> => {
|
|
588
|
+
const { version } = read
|
|
589
|
+
const entry = version.files.find((file) => file.path === DOCUMENT_HTML_ENTRY)
|
|
590
|
+
if (version.outline.kind !== "document" || !entry) return null
|
|
591
|
+
|
|
592
|
+
const html = await readArtifactText(blobStorage, entry, ARTIFACT_LIMITS.maxDocumentBytes)
|
|
593
|
+
const reads = documentData().reads(documentMarks(html))
|
|
594
|
+
if (!reads.holder && reads.queries.length === 0) return null
|
|
595
|
+
if (version.frozenAt) return frozenDocumentHtml(html)
|
|
596
|
+
|
|
597
|
+
// What the caller may not read, or no one object holds, keeps its written text; anything
|
|
598
|
+
// else that fails is thrown, never written in as text that stays.
|
|
599
|
+
const answer = (name: string) =>
|
|
600
|
+
runQuery(read, name).then(
|
|
601
|
+
(result) => result as DocumentQueryResult,
|
|
602
|
+
(error: unknown) => {
|
|
603
|
+
if (error instanceof AuthorizationError || error instanceof ArtifactRequestError) {
|
|
604
|
+
return undefined
|
|
605
|
+
}
|
|
606
|
+
throw error
|
|
607
|
+
}
|
|
608
|
+
)
|
|
609
|
+
const [holder, ...results] = await Promise.all([
|
|
610
|
+
reads.holder ? answer(DOCUMENT_HOLDER_QUERY) : undefined,
|
|
611
|
+
...reads.queries.map(answer),
|
|
612
|
+
])
|
|
613
|
+
const queries: Record<string, DocumentQueryResult> = {}
|
|
614
|
+
reads.queries.forEach((name, index) => {
|
|
615
|
+
const result = results[index]
|
|
616
|
+
if (result) queries[name] = result
|
|
617
|
+
})
|
|
618
|
+
const row = holder?.objects?.[0]
|
|
619
|
+
return fillDocumentHtml(
|
|
620
|
+
html,
|
|
621
|
+
{ ...(row ? { holder: row } : {}), queries },
|
|
622
|
+
options.keep ? { keep: true } : { plain: true }
|
|
623
|
+
)
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* The one object of the type a designed document names that holds it, as the caller reads it.
|
|
628
|
+
* Throws `holder_not_found` when none does, or several do: its fields keep their written text.
|
|
629
|
+
*/
|
|
630
|
+
const requireHolder = async (
|
|
631
|
+
artifactId: string,
|
|
632
|
+
holder: DocumentHolder
|
|
633
|
+
): Promise<{ readonly objectTypeId: string; readonly primaryId: string }> => {
|
|
634
|
+
const found = new Set<string>()
|
|
635
|
+
const holdings = readableHoldings({
|
|
636
|
+
runtime,
|
|
637
|
+
reader: runtime.objectReader,
|
|
638
|
+
objects: runtime.storage.objects,
|
|
639
|
+
artifactId,
|
|
640
|
+
})
|
|
641
|
+
for await (const holding of holdings) {
|
|
642
|
+
if (holding.objectTypeId === holder.objectTypeId) found.add(holding.primaryId)
|
|
643
|
+
if (found.size > 1) break
|
|
644
|
+
}
|
|
645
|
+
const [primaryId] = found
|
|
646
|
+
if (found.size !== 1 || primaryId === undefined) {
|
|
647
|
+
throw new ArtifactRequestError(
|
|
648
|
+
"holder_not_found",
|
|
649
|
+
`[Sixb] No one ${holder.objectTypeId} you read holds artifact '${artifactId}', so its fields show what is written in them.`
|
|
650
|
+
)
|
|
651
|
+
}
|
|
652
|
+
return { objectTypeId: holder.objectTypeId, primaryId }
|
|
653
|
+
}
|
|
479
654
|
const requestPreviews: BoardPreviewRequester = async (version, requestOptions) => {
|
|
480
655
|
const storage = runtime.storage.artifacts
|
|
481
|
-
if (!options.
|
|
656
|
+
if (!options.rendersInSandboxes || !storage) return
|
|
482
657
|
|
|
483
658
|
// Its queries are answered as whoever published it, who is this runtime's caller.
|
|
484
659
|
await requestBoardPreviews(
|
|
485
660
|
{
|
|
486
661
|
storage,
|
|
487
|
-
queue: runtime.queues.
|
|
662
|
+
queue: runtime.queues.renders,
|
|
488
663
|
blobStorage,
|
|
489
664
|
query: (name) => artifacts.query(version.artifactId, name, { version: version.version }),
|
|
490
665
|
},
|
|
@@ -604,8 +779,8 @@ export function createArtifactsRuntime(
|
|
|
604
779
|
}
|
|
605
780
|
|
|
606
781
|
/**
|
|
607
|
-
* Stores the latest version, authored by the caller, who may update the artifact.
|
|
608
|
-
* written since the base is merged into, not refused: the merge is
|
|
782
|
+
* Stores the latest version, authored by the caller, who may update the artifact. One that
|
|
783
|
+
* keeps a document, written since the base, is merged into, not refused: the merge is checked.
|
|
609
784
|
*/
|
|
610
785
|
const write = async (
|
|
611
786
|
input: ArtifactWrite & { readonly title: string }
|
|
@@ -637,7 +812,7 @@ export function createArtifactsRuntime(
|
|
|
637
812
|
})
|
|
638
813
|
}
|
|
639
814
|
|
|
640
|
-
/** A live room's write-back: only a canvas
|
|
815
|
+
/** A live room's write-back: only a canvas or a document keeps one to merge it into. */
|
|
641
816
|
const writeLive = async (
|
|
642
817
|
artifactId: string,
|
|
643
818
|
input: LiveArtifactWrite
|
|
@@ -645,7 +820,7 @@ export function createArtifactsRuntime(
|
|
|
645
820
|
const artifact = await requireUpdatable(artifactId)
|
|
646
821
|
if (!keepsDocument(artifact.kind)) {
|
|
647
822
|
throw invalidArtifact(
|
|
648
|
-
`Artifact '${artifactId}' is a ${artifact.kind}
|
|
823
|
+
`Artifact '${artifactId}' is a ${artifact.kind} that is not edited live: publish its files.`
|
|
649
824
|
)
|
|
650
825
|
}
|
|
651
826
|
|
|
@@ -660,6 +835,9 @@ export function createArtifactsRuntime(
|
|
|
660
835
|
author: commentAuthor,
|
|
661
836
|
manager: requireCaller,
|
|
662
837
|
reach,
|
|
838
|
+
...(authority.type === "delegated"
|
|
839
|
+
? { guest: { grantId: authority.delegation?.grantId } }
|
|
840
|
+
: {}),
|
|
663
841
|
}),
|
|
664
842
|
|
|
665
843
|
async create(input) {
|
|
@@ -700,12 +878,37 @@ export function createArtifactsRuntime(
|
|
|
700
878
|
},
|
|
701
879
|
|
|
702
880
|
async freeze(artifactId, input = {}) {
|
|
881
|
+
// A designed document's fields are written in first, as the person freezing reads them, and
|
|
882
|
+
// stay marked: the version it closes shows those values, which are never read again, and
|
|
883
|
+
// the next version, opened from it, reads them anew.
|
|
884
|
+
let baseRevision = input.baseRevision
|
|
885
|
+
const open = await readVersion(artifactId, "latest")
|
|
886
|
+
const filled = open && !open.version.frozenAt ? await writtenIn(open, { keep: true }) : null
|
|
887
|
+
if (open && filled !== null) {
|
|
888
|
+
await requireUpdatable(artifactId)
|
|
889
|
+
const document = await blobStorage.put({
|
|
890
|
+
body: new TextEncoder().encode(filled),
|
|
891
|
+
fileName: DOCUMENT_HTML_ENTRY,
|
|
892
|
+
mediaType: "text/html",
|
|
893
|
+
})
|
|
894
|
+
const written = await write({
|
|
895
|
+
artifactId,
|
|
896
|
+
kind: "document",
|
|
897
|
+
files: open.version.files.map((file) =>
|
|
898
|
+
file.path === DOCUMENT_HTML_ENTRY ? { path: file.path, file: document } : file
|
|
899
|
+
),
|
|
900
|
+
baseRevision: baseRevision ?? open.version.revision,
|
|
901
|
+
title: open.version.title,
|
|
902
|
+
})
|
|
903
|
+
baseRevision = written.version.revision
|
|
904
|
+
}
|
|
905
|
+
|
|
703
906
|
const frozenAt = new Date()
|
|
704
907
|
const frozen = await change(artifactId, (storage, author) =>
|
|
705
908
|
storage.freeze({
|
|
706
909
|
projectId: runtime.projectId,
|
|
707
910
|
artifactId,
|
|
708
|
-
...(
|
|
911
|
+
...(baseRevision === undefined ? {} : { baseRevision }),
|
|
709
912
|
frozenAt,
|
|
710
913
|
frozenBy: author,
|
|
711
914
|
})
|
|
@@ -733,7 +936,7 @@ export function createArtifactsRuntime(
|
|
|
733
936
|
},
|
|
734
937
|
|
|
735
938
|
async restore(artifactId, revision, input = {}) {
|
|
736
|
-
// A
|
|
939
|
+
// A live document takes the restored content as a change, so editors keep theirs.
|
|
737
940
|
const context = { projectId: runtime.projectId, storage: requireStorage(), blobStorage }
|
|
738
941
|
const point = await context.storage.getRestorePoint({
|
|
739
942
|
projectId: runtime.projectId,
|
|
@@ -815,30 +1018,61 @@ export function createArtifactsRuntime(
|
|
|
815
1018
|
return (await readVersion(artifactId, version))?.version ?? null
|
|
816
1019
|
},
|
|
817
1020
|
|
|
818
|
-
async
|
|
819
|
-
const read = await readVersion(artifactId,
|
|
1021
|
+
async pdf(artifactId, pdfOptions = {}) {
|
|
1022
|
+
const read = await readVersion(artifactId, pdfOptions.version ?? "latest")
|
|
820
1023
|
if (!read) return null
|
|
821
1024
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
1025
|
+
const { version } = read
|
|
1026
|
+
if (!documentPdfKey(version)) {
|
|
1027
|
+
throw invalidArtifact(
|
|
1028
|
+
`Version ${version.version} of '${artifactId}' is not a designed document, which alone prints to PDF.`
|
|
1029
|
+
)
|
|
1030
|
+
}
|
|
1031
|
+
// A document that shows live data prints the values the caller reads, written in, and its
|
|
1032
|
+
// key names them; a frozen one prints those written in when it was frozen. Asked with its
|
|
1033
|
+
// key, it is the PDF of those values, and they are not read again.
|
|
1034
|
+
const { key } = pdfOptions
|
|
1035
|
+
const filled = key !== undefined ? null : await writtenIn(read)
|
|
1036
|
+
const printed = filled === null ? null : new TextEncoder().encode(filled)
|
|
1037
|
+
const digest = key ?? (printed ? computeBlobDigest(printed) : undefined)
|
|
1038
|
+
const keyed = digest ? { key: digest } : {}
|
|
1039
|
+
const renderKey = documentPdfKey(version, digest ? { digest } : undefined) as string
|
|
1040
|
+
const storage = requireStorage()
|
|
1041
|
+
const kept = await storage.getPdf({ projectId: runtime.projectId, renderKey })
|
|
1042
|
+
if (kept && !("failure" in kept)) {
|
|
1043
|
+
return { status: "ready", file: kept.file, pages: kept.pages, ...keyed }
|
|
1044
|
+
}
|
|
1045
|
+
if (kept && (!pdfOptions.retry || key !== undefined)) {
|
|
1046
|
+
return { status: "failed", reason: kept.failure, ...keyed }
|
|
1047
|
+
}
|
|
1048
|
+
// The ask that gave the key asked for it to be printed.
|
|
1049
|
+
if (pdfOptions.print === false || key !== undefined) return { status: "printing", ...keyed }
|
|
1050
|
+
if (!options.rendersInSandboxes) {
|
|
829
1051
|
throw new ArtifactRequestError(
|
|
830
|
-
"
|
|
831
|
-
|
|
1052
|
+
"pdf_unavailable",
|
|
1053
|
+
"[Sixb] A document prints to PDF in a sandbox, and this project has no sandbox provider."
|
|
832
1054
|
)
|
|
833
1055
|
}
|
|
834
1056
|
|
|
835
|
-
const
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
1057
|
+
const document = printed
|
|
1058
|
+
? await blobStorage.put({
|
|
1059
|
+
body: printed,
|
|
1060
|
+
fileName: DOCUMENT_HTML_ENTRY,
|
|
1061
|
+
mediaType: "text/html",
|
|
1062
|
+
})
|
|
1063
|
+
: undefined
|
|
1064
|
+
await requestDocumentPdf({ storage, queue: runtime.queues.renders }, version, {
|
|
1065
|
+
...(document ? { document } : {}),
|
|
1066
|
+
retry: pdfOptions.retry === true,
|
|
1067
|
+
})
|
|
1068
|
+
return { status: "printing", ...keyed }
|
|
1069
|
+
},
|
|
1070
|
+
|
|
1071
|
+
async query(artifactId, name, options = {}) {
|
|
1072
|
+
const read = await readVersion(artifactId, options.version ?? "latest")
|
|
1073
|
+
if (!read) return null
|
|
840
1074
|
|
|
841
|
-
return
|
|
1075
|
+
return runQuery(read, name)
|
|
842
1076
|
},
|
|
843
1077
|
|
|
844
1078
|
async listVersions(artifactId, input = {}) {
|
|
@@ -985,7 +1219,7 @@ async function sharedLinkGuest(
|
|
|
985
1219
|
)
|
|
986
1220
|
}
|
|
987
1221
|
|
|
988
|
-
return { type: "guest", id: delegation.sessionId, name }
|
|
1222
|
+
return { type: "guest", id: delegation.sessionId, name, grantId: delegation.grantId }
|
|
989
1223
|
}
|
|
990
1224
|
|
|
991
1225
|
function notFound(artifactId: string): ArtifactRequestError {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { ArtifactFrameTarget } from "../../storage/artifacts/types"
|
|
2
2
|
import { isArtifactAddress, parseArtifactAddress } from "../address"
|
|
3
3
|
import { decodeHtmlEntities } from "../html"
|
|
4
|
+
import type { DocumentHeading } from "../outline"
|
|
5
|
+
import type { DocumentPaper } from "../paper"
|
|
4
6
|
import { FRAME_ASSET_PREFIX } from "../publish/validate/html"
|
|
7
|
+
import { documentData } from "./document-data"
|
|
5
8
|
import type { FrameLayout } from "./entries"
|
|
6
|
-
import { FRAME_DECK_CSS, FRAME_PAGE_CSS } from "./kit"
|
|
9
|
+
import { FRAME_DECK_CSS, FRAME_DOCUMENT_CSS, FRAME_PAGE_CSS } from "./kit"
|
|
7
10
|
import { frameRuntime } from "./runtime"
|
|
8
11
|
|
|
9
12
|
/**
|
|
@@ -29,15 +32,25 @@ export const FRAME_ASSETS: Readonly<
|
|
|
29
32
|
> = {
|
|
30
33
|
[`${FRAME_ASSET_PREFIX}deck.css`]: { body: FRAME_DECK_CSS, type: "text/css; charset=utf-8" },
|
|
31
34
|
[`${FRAME_ASSET_PREFIX}page.css`]: { body: FRAME_PAGE_CSS, type: "text/css; charset=utf-8" },
|
|
35
|
+
[`${FRAME_ASSET_PREFIX}document.css`]: {
|
|
36
|
+
body: FRAME_DOCUMENT_CSS,
|
|
37
|
+
type: "text/css; charset=utf-8",
|
|
38
|
+
},
|
|
32
39
|
[`${FRAME_ASSET_PREFIX}runtime.js`]: {
|
|
33
|
-
body: `(${frameRuntime.toString()})()\n`,
|
|
40
|
+
body: `(${frameRuntime.toString()})(${documentData.toString()})\n`,
|
|
34
41
|
type: "text/javascript; charset=utf-8",
|
|
35
42
|
},
|
|
36
43
|
}
|
|
37
44
|
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
/**
|
|
46
|
+
* The kit for the layout and the runtime, which reads the layout from its own tag, and a designed
|
|
47
|
+
* document's paper: its width, height, and margins, top, right, bottom and left, in pixels.
|
|
48
|
+
*/
|
|
49
|
+
function injected(layout: FrameLayout, base: string, paper?: DocumentPaper): string {
|
|
50
|
+
const sheet = paper
|
|
51
|
+
? ` data-sixb-paper="${[paper.width, paper.height, paper.margin.top, paper.margin.right, paper.margin.bottom, paper.margin.left].join(" ")}"`
|
|
52
|
+
: ""
|
|
53
|
+
return `<link rel="stylesheet" href="${base}${FRAME_ASSET_PREFIX}${layout}.css"><script src="${base}${FRAME_ASSET_PREFIX}runtime.js" data-sixb-layout="${layout}"${sheet}></script>`
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
/**
|
|
@@ -56,8 +69,13 @@ function rootOf(entry: string): string {
|
|
|
56
69
|
* text, so a `<head>` inside a comment or a script's string is not one. `entry` is where the page
|
|
57
70
|
* is in the version, so an entry in a folder, as a canvas's boards are, finds them.
|
|
58
71
|
*/
|
|
59
|
-
export function injectFrameAssets(
|
|
60
|
-
|
|
72
|
+
export function injectFrameAssets(
|
|
73
|
+
html: string,
|
|
74
|
+
layout: FrameLayout,
|
|
75
|
+
entry = "index.html",
|
|
76
|
+
paper?: DocumentPaper
|
|
77
|
+
): string {
|
|
78
|
+
const assets = injected(layout, rootOf(entry), paper)
|
|
61
79
|
for (const selector of ["head", "html"]) {
|
|
62
80
|
let injected = false
|
|
63
81
|
const rewritten = new HTMLRewriter()
|
|
@@ -75,6 +93,23 @@ export function injectFrameAssets(html: string, layout: FrameLayout, entry = "in
|
|
|
75
93
|
return `${doctype}${assets}${html.slice(doctype.length)}`
|
|
76
94
|
}
|
|
77
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Marks each heading of a designed document with the slug publishing named it by, in order,
|
|
98
|
+
* `data-sixb-section`, so the frame opens the document at the section an address names.
|
|
99
|
+
*/
|
|
100
|
+
export function markDocumentSections(html: string, headings: readonly DocumentHeading[]): string {
|
|
101
|
+
let index = 0
|
|
102
|
+
return new HTMLRewriter()
|
|
103
|
+
.on("h1, h2, h3, h4, h5, h6", {
|
|
104
|
+
element(element) {
|
|
105
|
+
const heading = headings[index]
|
|
106
|
+
index += 1
|
|
107
|
+
if (heading?.slug) element.setAttribute("data-sixb-section", heading.slug)
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
.transform(html)
|
|
111
|
+
}
|
|
112
|
+
|
|
78
113
|
/**
|
|
79
114
|
* Where a frame serves a file another artifact lends it, at the version its address pins or the
|
|
80
115
|
* latest: `__sixb/ref/<id>@<version>/<path>` or `__sixb/ref/<id>@latest/<path>`.
|