@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
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
validateObjectQueryWithAdmission,
|
|
5
5
|
SYSTEM_PRINCIPAL2,
|
|
6
6
|
principalsEqual2
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-xcrnrpfh.js";
|
|
8
8
|
import {
|
|
9
9
|
resolveRuntimeAuthorizationForProject,
|
|
10
10
|
AuthorizationError2,
|
|
11
11
|
isRuntimeAllowed2
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-paxabbqd.js";
|
|
13
13
|
import {
|
|
14
14
|
createArtifactId,
|
|
15
15
|
createArtifactCommentId
|
|
@@ -24,21 +24,42 @@ import {
|
|
|
24
24
|
import {
|
|
25
25
|
ArtifactStorageError,
|
|
26
26
|
turnUndoable2
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-ewqn51gr.js";
|
|
28
28
|
import {
|
|
29
29
|
ARTIFACT_LIMITS2,
|
|
30
30
|
ARTIFACT_STATE_LIMITS2,
|
|
31
31
|
ARTIFACT_HOLDERS_LIMIT2,
|
|
32
32
|
ARTIFACT_COMMENT_LIMITS2
|
|
33
33
|
} from "./chunk-9vsc919v.js";
|
|
34
|
+
import {
|
|
35
|
+
computeBlobDigest2
|
|
36
|
+
} from "./chunk-xrmbhap8.js";
|
|
34
37
|
import {
|
|
35
38
|
objectBatchKey2
|
|
36
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-gjhrz66x.js";
|
|
37
40
|
import {
|
|
38
41
|
objectReadersIn,
|
|
39
42
|
getAuthorizedOntologyView,
|
|
40
43
|
readerClearance
|
|
41
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-5t9gm5tt.js";
|
|
45
|
+
import {
|
|
46
|
+
ArtifactRequestError2,
|
|
47
|
+
documentData,
|
|
48
|
+
documentMarks,
|
|
49
|
+
fillDocumentHtml,
|
|
50
|
+
frozenDocumentHtml2,
|
|
51
|
+
checkArtifactFiles,
|
|
52
|
+
readArtifactText,
|
|
53
|
+
invalidArtifact,
|
|
54
|
+
decodeHtmlEntities,
|
|
55
|
+
HTML_ENTRY2,
|
|
56
|
+
refuseFrameAssetPaths,
|
|
57
|
+
readHtmlReferences,
|
|
58
|
+
FRAME_DEFAULT_THEMES2,
|
|
59
|
+
FRAME_CDN_ALLOWLIST2,
|
|
60
|
+
FRAME_ASSETS2,
|
|
61
|
+
serializeArtifactQueryResult2
|
|
62
|
+
} from "./chunk-vs2s3p8n.js";
|
|
42
63
|
import {
|
|
43
64
|
isArtifactAddress2,
|
|
44
65
|
parseArtifactAddress2,
|
|
@@ -49,8 +70,9 @@ import {
|
|
|
49
70
|
isLiveTextPath,
|
|
50
71
|
createArtifactDocument,
|
|
51
72
|
documentFiles2,
|
|
52
|
-
mergeIntoDocument2
|
|
53
|
-
|
|
73
|
+
mergeIntoDocument2,
|
|
74
|
+
holdPage
|
|
75
|
+
} from "./chunk-bqr703h4.js";
|
|
54
76
|
import {
|
|
55
77
|
BOARD_PREVIEW_JOB2,
|
|
56
78
|
BOARD_PREVIEW_WAIT_MS2,
|
|
@@ -59,15 +81,16 @@ import {
|
|
|
59
81
|
canvasEndBox,
|
|
60
82
|
ARTIFACT_QUERIES_DIRECTORY,
|
|
61
83
|
ARTIFACT_QUERY_KINDS,
|
|
84
|
+
DOCUMENT_HOLDER_QUERY2,
|
|
62
85
|
isArtifactQueryName,
|
|
63
86
|
artifactQueryPath,
|
|
64
87
|
artifactQueryName2,
|
|
65
88
|
parseArtifactQuery,
|
|
89
|
+
createHeadingSlugger2,
|
|
66
90
|
ARTIFACT_THEME_FILE2,
|
|
67
91
|
parseArtifactTheme2,
|
|
68
92
|
artifactThemeModes2,
|
|
69
93
|
resolveArtifactAddress2,
|
|
70
|
-
createHeadingSlugger2,
|
|
71
94
|
CsvParseError2,
|
|
72
95
|
parseCsv2,
|
|
73
96
|
WORKBOOK_FILE2,
|
|
@@ -80,20 +103,7 @@ import {
|
|
|
80
103
|
sheetColumnsProblem,
|
|
81
104
|
sheetFormulasProblem,
|
|
82
105
|
sheetChartsProblem
|
|
83
|
-
} from "./chunk-
|
|
84
|
-
import {
|
|
85
|
-
ArtifactRequestError2,
|
|
86
|
-
checkArtifactFiles,
|
|
87
|
-
readArtifactText,
|
|
88
|
-
invalidArtifact,
|
|
89
|
-
decodeHtmlEntities,
|
|
90
|
-
HTML_ENTRY2,
|
|
91
|
-
refuseFrameAssetPaths,
|
|
92
|
-
readHtmlReferences,
|
|
93
|
-
FRAME_DEFAULT_THEMES2,
|
|
94
|
-
FRAME_ASSETS2,
|
|
95
|
-
serializeArtifactQueryResult2
|
|
96
|
-
} from "./chunk-hvbvq7p4.js";
|
|
106
|
+
} from "./chunk-60662fyv.js";
|
|
97
107
|
import {
|
|
98
108
|
ObjectQueryValidationError2,
|
|
99
109
|
ObjectQueryPlanningError2,
|
|
@@ -103,9 +113,6 @@ import {
|
|
|
103
113
|
import {
|
|
104
114
|
AgentRequestError2
|
|
105
115
|
} from "./chunk-9wr3yajk.js";
|
|
106
|
-
import {
|
|
107
|
-
statFileRef2
|
|
108
|
-
} from "./chunk-a3faa34j.js";
|
|
109
116
|
|
|
110
117
|
// src/agents/thread-access.ts
|
|
111
118
|
function createAgentThreadAccessRule(runtime, authority, agents) {
|
|
@@ -251,7 +258,7 @@ async function announceArtifactUpdates(events, latest) {
|
|
|
251
258
|
}))
|
|
252
259
|
}, { source: "Sixb" });
|
|
253
260
|
}
|
|
254
|
-
async function announceArtifactComment(events, comment, action) {
|
|
261
|
+
async function announceArtifactComment(events, comment, shareGrantId, action) {
|
|
255
262
|
await events.emit({
|
|
256
263
|
events: [
|
|
257
264
|
{
|
|
@@ -260,6 +267,7 @@ async function announceArtifactComment(events, comment, action) {
|
|
|
260
267
|
artifactId: comment.artifactId,
|
|
261
268
|
commentId: comment.id,
|
|
262
269
|
...comment.parentId === undefined ? {} : { parentId: comment.parentId },
|
|
270
|
+
...shareGrantId === undefined ? {} : { shareGrantId },
|
|
263
271
|
action
|
|
264
272
|
}
|
|
265
273
|
}
|
|
@@ -271,7 +279,9 @@ async function announceArtifactComment(events, comment, action) {
|
|
|
271
279
|
var ELEMENT_ADDRESS = /^body(>[a-z][a-z0-9-]*:\d+)*$/;
|
|
272
280
|
var MAX_ELEMENT_ADDRESS_LENGTH = 1024;
|
|
273
281
|
function createArtifactCommentsRuntime(input) {
|
|
274
|
-
const { projectId, events } = input;
|
|
282
|
+
const { projectId, events, guest } = input;
|
|
283
|
+
const threadOf = (comment) => comment.parentId === undefined ? Promise.resolve(comment) : input.storage().getComment({ projectId, artifactId: comment.artifactId, id: comment.parentId });
|
|
284
|
+
const reads = (thread) => thread !== null && (!guest || guest.grantId !== undefined && threadLink(thread) === guest.grantId);
|
|
275
285
|
const readable = async (artifactId) => {
|
|
276
286
|
const reached = await input.reach(artifactId);
|
|
277
287
|
if (!reached)
|
|
@@ -283,23 +293,28 @@ function createArtifactCommentsRuntime(input) {
|
|
|
283
293
|
};
|
|
284
294
|
const managed = async (artifactId, commentId) => {
|
|
285
295
|
const { access } = await readable(artifactId);
|
|
286
|
-
const manager = input.manager();
|
|
287
296
|
const comment = await input.storage().getComment({ projectId, artifactId, id: commentId });
|
|
288
|
-
|
|
297
|
+
const thread = comment ? await threadOf(comment) : null;
|
|
298
|
+
if (!comment || !reads(thread))
|
|
289
299
|
throw commentNotFound(artifactId, commentId);
|
|
300
|
+
const manager = input.manager();
|
|
290
301
|
const changes = access === "owner" || access === "update";
|
|
291
302
|
const authored = comment.author.type !== "guest" && principalsEqual2(comment.author, manager);
|
|
292
303
|
if (!changes && !authored) {
|
|
293
304
|
throw new ArtifactRequestError2("not_allowed", "[Sixb] Only a comment's author, or whoever may change the artifact, resolves or deletes it.");
|
|
294
305
|
}
|
|
295
|
-
return comment;
|
|
306
|
+
return { comment, thread };
|
|
296
307
|
};
|
|
297
308
|
return {
|
|
298
309
|
async listComments(artifactId) {
|
|
299
310
|
const reached = await input.reach(artifactId);
|
|
300
311
|
if (!reached || reached.access === "none")
|
|
301
312
|
return null;
|
|
302
|
-
|
|
313
|
+
const comments = await input.storage().listComments({ projectId, id: artifactId });
|
|
314
|
+
if (!guest)
|
|
315
|
+
return comments;
|
|
316
|
+
const threads = new Set(comments.filter((comment) => comment.parentId === undefined && reads(comment)).map((comment) => comment.id));
|
|
317
|
+
return comments.filter((comment) => threads.has(comment.parentId ?? comment.id));
|
|
303
318
|
},
|
|
304
319
|
async addComment(artifactId, comment) {
|
|
305
320
|
const { artifact } = await readable(artifactId);
|
|
@@ -310,9 +325,10 @@ function createArtifactCommentsRuntime(input) {
|
|
|
310
325
|
throw invalid(`A comment holds 1 to ${ARTIFACT_COMMENT_LIMITS2.maxBodyLength} characters of text.`);
|
|
311
326
|
}
|
|
312
327
|
let anchor;
|
|
328
|
+
let parent = null;
|
|
313
329
|
if (comment.parentId !== undefined) {
|
|
314
|
-
|
|
315
|
-
if (!parent)
|
|
330
|
+
parent = await storage.getComment({ projectId, artifactId, id: comment.parentId });
|
|
331
|
+
if (!reads(parent))
|
|
316
332
|
throw commentNotFound(artifactId, comment.parentId);
|
|
317
333
|
anchor = parent.anchor;
|
|
318
334
|
} else {
|
|
@@ -330,14 +346,14 @@ function createArtifactCommentsRuntime(input) {
|
|
|
330
346
|
...comment.origin ? { origin: comment.origin } : {},
|
|
331
347
|
createdAt: new Date
|
|
332
348
|
});
|
|
333
|
-
await announceArtifactComment(events, created, "created");
|
|
349
|
+
await announceArtifactComment(events, created, threadLink(parent ?? created), "created");
|
|
334
350
|
return created;
|
|
335
351
|
} catch (error) {
|
|
336
352
|
throw commentRequestError(error);
|
|
337
353
|
}
|
|
338
354
|
},
|
|
339
355
|
async resolveComment(artifactId, commentId, resolved = true) {
|
|
340
|
-
await managed(artifactId, commentId);
|
|
356
|
+
const { thread } = await managed(artifactId, commentId);
|
|
341
357
|
const changed = await input.storage().resolveComment({
|
|
342
358
|
projectId,
|
|
343
359
|
artifactId,
|
|
@@ -346,18 +362,21 @@ function createArtifactCommentsRuntime(input) {
|
|
|
346
362
|
});
|
|
347
363
|
if (!changed)
|
|
348
364
|
throw commentNotFound(artifactId, commentId);
|
|
349
|
-
await announceArtifactComment(events, changed, resolved ? "resolved" : "reopened");
|
|
365
|
+
await announceArtifactComment(events, changed, threadLink(thread), resolved ? "resolved" : "reopened");
|
|
350
366
|
return changed;
|
|
351
367
|
},
|
|
352
368
|
async deleteComment(artifactId, commentId) {
|
|
353
|
-
const comment = await managed(artifactId, commentId);
|
|
369
|
+
const { comment, thread } = await managed(artifactId, commentId);
|
|
354
370
|
const deleted = await input.storage().deleteComment({ projectId, artifactId, id: commentId });
|
|
355
371
|
if (!deleted)
|
|
356
372
|
throw commentNotFound(artifactId, commentId);
|
|
357
|
-
await announceArtifactComment(events, comment, "deleted");
|
|
373
|
+
await announceArtifactComment(events, comment, threadLink(thread), "deleted");
|
|
358
374
|
}
|
|
359
375
|
};
|
|
360
376
|
}
|
|
377
|
+
function threadLink(thread) {
|
|
378
|
+
return thread.author.type === "guest" ? thread.author.grantId : undefined;
|
|
379
|
+
}
|
|
361
380
|
async function checkAnchor(storage, artifact, anchor) {
|
|
362
381
|
const revision = anchor.revision ?? artifact.revision;
|
|
363
382
|
if (!Number.isSafeInteger(revision) || revision < 1 || revision > artifact.revision) {
|
|
@@ -524,17 +543,18 @@ function sameArtifactFiles2(left, right) {
|
|
|
524
543
|
}
|
|
525
544
|
|
|
526
545
|
// src/artifacts/live/state.ts
|
|
527
|
-
function
|
|
528
|
-
return kind === "canvas";
|
|
546
|
+
function keepsDocument2(kind) {
|
|
547
|
+
return kind === "canvas" || kind === "document";
|
|
529
548
|
}
|
|
530
549
|
async function loadArtifactDocument2(blobStorage, artifact, files) {
|
|
531
550
|
const doc = new Y.Doc;
|
|
532
551
|
const stored = artifact.document;
|
|
552
|
+
const clientID = madeClientId(artifact.id, stored, files);
|
|
533
553
|
if (stored?.revision === artifact.revision) {
|
|
534
554
|
Y.applyUpdate(doc, await readDocumentState2(blobStorage, stored.file));
|
|
555
|
+
holdPage(doc, clientID);
|
|
535
556
|
return doc;
|
|
536
557
|
}
|
|
537
|
-
const clientID = madeClientId(artifact.id, stored, files);
|
|
538
558
|
const live = await readLiveFiles2(blobStorage, files);
|
|
539
559
|
let made;
|
|
540
560
|
if (stored) {
|
|
@@ -547,6 +567,7 @@ async function loadArtifactDocument2(blobStorage, artifact, files) {
|
|
|
547
567
|
}
|
|
548
568
|
Y.applyUpdate(doc, Y.encodeStateAsUpdate(made));
|
|
549
569
|
made.destroy();
|
|
570
|
+
holdPage(doc, clientID);
|
|
550
571
|
return doc;
|
|
551
572
|
}
|
|
552
573
|
async function readDocumentState2(blobStorage, document) {
|
|
@@ -562,7 +583,7 @@ async function storeArtifactDocument(blobStorage, doc) {
|
|
|
562
583
|
});
|
|
563
584
|
}
|
|
564
585
|
async function firstArtifactDocument(blobStorage, kind, files) {
|
|
565
|
-
if (!
|
|
586
|
+
if (!keepsDocument2(kind))
|
|
566
587
|
return;
|
|
567
588
|
const doc = createArtifactDocument(kind, await readLiveFiles2(blobStorage, files));
|
|
568
589
|
try {
|
|
@@ -591,7 +612,7 @@ async function mergeArtifactWrite(context, write) {
|
|
|
591
612
|
...write.baseRevision === undefined ? {} : { baseRevision: write.baseRevision },
|
|
592
613
|
merged: false
|
|
593
614
|
};
|
|
594
|
-
if (!
|
|
615
|
+
if (!keepsDocument2(write.kind))
|
|
595
616
|
return unmerged;
|
|
596
617
|
const { projectId, storage, blobStorage } = context;
|
|
597
618
|
const artifact = await storage.get({ projectId, id: write.artifactId });
|
|
@@ -637,15 +658,16 @@ async function withMergedWrite(context, write, store) {
|
|
|
637
658
|
try {
|
|
638
659
|
return await store(merged);
|
|
639
660
|
} catch (error) {
|
|
640
|
-
if (!isMoved(error) || !
|
|
661
|
+
if (!isMoved(error) || !keepsDocument2(write.kind) || attempt === MERGE_ATTEMPTS) {
|
|
641
662
|
throw error;
|
|
663
|
+
}
|
|
642
664
|
}
|
|
643
665
|
}
|
|
644
666
|
}
|
|
645
667
|
async function documentHolding(context, artifactId, files) {
|
|
646
668
|
const { projectId, storage, blobStorage } = context;
|
|
647
669
|
const artifact = await storage.get({ projectId, id: artifactId });
|
|
648
|
-
if (!artifact || !
|
|
670
|
+
if (!artifact || !keepsDocument2(artifact.kind))
|
|
649
671
|
return null;
|
|
650
672
|
const latest = await storage.getVersion({
|
|
651
673
|
projectId,
|
|
@@ -689,7 +711,7 @@ async function undoneTurnDocuments(context, turnRunId) {
|
|
|
689
711
|
if (write.created)
|
|
690
712
|
continue;
|
|
691
713
|
const artifact = await storage.get({ projectId, id: write.artifactId });
|
|
692
|
-
if (!artifact || !
|
|
714
|
+
if (!artifact || !keepsDocument2(artifact.kind))
|
|
693
715
|
continue;
|
|
694
716
|
const points = await storage.listRestorePoints({ projectId, id: artifact.id });
|
|
695
717
|
const point = points.find((each) => each.turnRunId === turnRunId);
|
|
@@ -700,7 +722,7 @@ async function undoneTurnDocuments(context, turnRunId) {
|
|
|
700
722
|
...point ? { point } : {},
|
|
701
723
|
...target ? { target: { frozen: target.frozenAt !== undefined } } : {}
|
|
702
724
|
});
|
|
703
|
-
if (!point || !undoable)
|
|
725
|
+
if (!point || !undoable || !keepsDocument2(artifact.kind))
|
|
704
726
|
continue;
|
|
705
727
|
const held = await documentHolding(context, artifact.id, point.files);
|
|
706
728
|
if (held?.baseRevision === artifact.revision)
|
|
@@ -719,6 +741,9 @@ async function filesAtRevision(storage, projectId, artifactId, revision) {
|
|
|
719
741
|
return versions.find((version) => version.revision === revision)?.files ?? null;
|
|
720
742
|
}
|
|
721
743
|
|
|
744
|
+
// src/artifacts/publish/pdf.ts
|
|
745
|
+
import { createHash as createHash3 } from "crypto";
|
|
746
|
+
|
|
722
747
|
// src/artifacts/publish/previews.ts
|
|
723
748
|
import { createHash as createHash2 } from "crypto";
|
|
724
749
|
|
|
@@ -742,6 +767,9 @@ async function answerArtifactQueries2(version, read) {
|
|
|
742
767
|
const name = artifactQueryName2(file.path);
|
|
743
768
|
return name === undefined ? [] : [name];
|
|
744
769
|
});
|
|
770
|
+
if (version.outline.kind === "document" && version.outline.holder) {
|
|
771
|
+
names.push(DOCUMENT_HOLDER_QUERY2);
|
|
772
|
+
}
|
|
745
773
|
const answers = await Promise.all(names.map(async (name) => [name, await answerArtifactQuery(() => read(name))]));
|
|
746
774
|
return Object.fromEntries(answers);
|
|
747
775
|
}
|
|
@@ -897,13 +925,13 @@ async function boardPreviewStatuses2(storage, version, input) {
|
|
|
897
925
|
return [board.id, ready ? "ready" : waiting ? "pending" : "none"];
|
|
898
926
|
}));
|
|
899
927
|
}
|
|
900
|
-
async function storeBoardPreviews2(
|
|
928
|
+
async function storeBoardPreviews2(storage, version, previews) {
|
|
901
929
|
if (previews.length === 0)
|
|
902
930
|
return [];
|
|
903
931
|
const { boards, themes } = previewedBoards(version);
|
|
904
932
|
const keys = new Map(boards.map((board) => [board.id, board.renderKey]));
|
|
905
933
|
const createdAt = new Date;
|
|
906
|
-
const checked =
|
|
934
|
+
const checked = previews.map((preview) => {
|
|
907
935
|
const { board, theme, size, file } = preview;
|
|
908
936
|
const refuse = (reason) => ({ refused: { board, theme, size, reason } });
|
|
909
937
|
const renderKey = keys.get(board);
|
|
@@ -917,13 +945,11 @@ async function storeBoardPreviews2(context, version, previews) {
|
|
|
917
945
|
if (file.sizeBytes > MAX_BOARD_PREVIEW_BYTES2) {
|
|
918
946
|
return refuse(`it is ${file.sizeBytes} bytes, past the ${MAX_BOARD_PREVIEW_BYTES2} kept`);
|
|
919
947
|
}
|
|
920
|
-
if (!await statFileRef2(context.blobStorage, file))
|
|
921
|
-
return refuse("it is not stored");
|
|
922
948
|
return { record: { renderKey, theme, size, file: { ...file }, createdAt } };
|
|
923
|
-
})
|
|
949
|
+
});
|
|
924
950
|
const records = checked.flatMap((each) => ("record" in each) ? [each.record] : []);
|
|
925
951
|
if (records.length > 0) {
|
|
926
|
-
await
|
|
952
|
+
await storage.putBoardPreviews({ projectId: version.projectId, previews: records });
|
|
927
953
|
}
|
|
928
954
|
return checked.flatMap((each) => ("refused" in each) ? [each.refused] : []);
|
|
929
955
|
}
|
|
@@ -937,21 +963,20 @@ async function requestBoardPreviews(input, version, options = {}) {
|
|
|
937
963
|
if ((await missingBoardPreviews2(input.storage, version)).length === 0)
|
|
938
964
|
return;
|
|
939
965
|
const queries = boardsReadLiveData2(version) && !options.withoutAnswers ? await storeQueryAnswers(input, version) : undefined;
|
|
940
|
-
const delayMs = options.delayMs ?? BOARD_PREVIEW_JOB2.settleMs;
|
|
941
966
|
await input.queue.enqueue({
|
|
942
967
|
projectId: version.projectId,
|
|
943
968
|
jobs: [
|
|
944
969
|
{
|
|
945
970
|
id: boardPreviewsJobId(version.artifactId),
|
|
946
971
|
replace: true,
|
|
947
|
-
type: "
|
|
972
|
+
type: "artifact.previews.requested",
|
|
948
973
|
payload: {
|
|
949
974
|
artifactId: version.artifactId,
|
|
950
975
|
version: version.version,
|
|
951
976
|
updatedAt: version.updatedAt.toISOString(),
|
|
952
977
|
...queries ? { queries } : {}
|
|
953
978
|
},
|
|
954
|
-
availableAt: new Date(Date.now() +
|
|
979
|
+
availableAt: new Date(Date.now() + BOARD_PREVIEW_JOB2.settleMs).toISOString()
|
|
955
980
|
}
|
|
956
981
|
]
|
|
957
982
|
});
|
|
@@ -975,6 +1000,484 @@ function frameKitDigest() {
|
|
|
975
1000
|
return kitDigest;
|
|
976
1001
|
}
|
|
977
1002
|
|
|
1003
|
+
// src/artifacts/publish/validate/document-html.ts
|
|
1004
|
+
import { posix as posix2 } from "path";
|
|
1005
|
+
|
|
1006
|
+
// src/artifacts/paper.ts
|
|
1007
|
+
var PX_PER_UNIT = {
|
|
1008
|
+
px: 1,
|
|
1009
|
+
in: 96,
|
|
1010
|
+
cm: 96 / 2.54,
|
|
1011
|
+
mm: 96 / 25.4,
|
|
1012
|
+
q: 96 / 101.6,
|
|
1013
|
+
pt: 96 / 72,
|
|
1014
|
+
pc: 16
|
|
1015
|
+
};
|
|
1016
|
+
var PAGE_SIZES = {
|
|
1017
|
+
a5: ["148mm", "210mm"],
|
|
1018
|
+
a4: ["210mm", "297mm"],
|
|
1019
|
+
a3: ["297mm", "420mm"],
|
|
1020
|
+
b5: ["176mm", "250mm"],
|
|
1021
|
+
b4: ["250mm", "353mm"],
|
|
1022
|
+
"jis-b5": ["182mm", "257mm"],
|
|
1023
|
+
"jis-b4": ["257mm", "364mm"],
|
|
1024
|
+
letter: ["8.5in", "11in"],
|
|
1025
|
+
legal: ["8.5in", "14in"],
|
|
1026
|
+
ledger: ["11in", "17in"]
|
|
1027
|
+
};
|
|
1028
|
+
function readDocumentPaper(stylesheets) {
|
|
1029
|
+
let size = null;
|
|
1030
|
+
const margin = [0, 0, 0, 0];
|
|
1031
|
+
for (const css of stylesheets) {
|
|
1032
|
+
for (const declarations of pageRules(css)) {
|
|
1033
|
+
for (const [property, value] of declarations) {
|
|
1034
|
+
if (property === "size") {
|
|
1035
|
+
size = readSize(value) ?? size;
|
|
1036
|
+
} else if (property === "margin") {
|
|
1037
|
+
const sides = readLengths(value);
|
|
1038
|
+
if (sides && sides.length <= 4) {
|
|
1039
|
+
const [top, right = top, bottom = top, left = right] = sides;
|
|
1040
|
+
margin.splice(0, 4, top, right, bottom, left);
|
|
1041
|
+
}
|
|
1042
|
+
} else {
|
|
1043
|
+
const side = ["margin-top", "margin-right", "margin-bottom", "margin-left"].indexOf(property);
|
|
1044
|
+
const length = side === -1 ? null : readLength(value);
|
|
1045
|
+
if (length !== null)
|
|
1046
|
+
margin[side] = length;
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
if (!size)
|
|
1052
|
+
return null;
|
|
1053
|
+
const round = (value) => Math.round(value * 100) / 100;
|
|
1054
|
+
return {
|
|
1055
|
+
width: round(size[0]),
|
|
1056
|
+
height: round(size[1]),
|
|
1057
|
+
margin: {
|
|
1058
|
+
top: round(margin[0]),
|
|
1059
|
+
right: round(margin[1]),
|
|
1060
|
+
bottom: round(margin[2]),
|
|
1061
|
+
left: round(margin[3])
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
function pageRules(css) {
|
|
1066
|
+
const text = css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
1067
|
+
const rules = [];
|
|
1068
|
+
const opening = /@page\b([^{;]*)\{/gi;
|
|
1069
|
+
for (let match = opening.exec(text);match; match = opening.exec(text)) {
|
|
1070
|
+
const body = blockAt(text, opening.lastIndex);
|
|
1071
|
+
opening.lastIndex += body.length;
|
|
1072
|
+
if (match[1]?.trim())
|
|
1073
|
+
continue;
|
|
1074
|
+
let flat = "";
|
|
1075
|
+
let depth = 0;
|
|
1076
|
+
for (const char of body) {
|
|
1077
|
+
if (char === "{")
|
|
1078
|
+
depth += 1;
|
|
1079
|
+
else if (char === "}")
|
|
1080
|
+
depth -= 1;
|
|
1081
|
+
else if (depth === 0)
|
|
1082
|
+
flat += char;
|
|
1083
|
+
}
|
|
1084
|
+
rules.push(flat.split(";").flatMap((declaration) => {
|
|
1085
|
+
const colon = declaration.indexOf(":");
|
|
1086
|
+
if (colon === -1)
|
|
1087
|
+
return [];
|
|
1088
|
+
const property = declaration.slice(0, colon).trim().toLowerCase();
|
|
1089
|
+
const value = declaration.slice(colon + 1).replace(/!important\s*$/i, "").trim().toLowerCase();
|
|
1090
|
+
return property && value ? [[property, value]] : [];
|
|
1091
|
+
}));
|
|
1092
|
+
}
|
|
1093
|
+
return rules;
|
|
1094
|
+
}
|
|
1095
|
+
function blockAt(text, start) {
|
|
1096
|
+
let depth = 1;
|
|
1097
|
+
for (let index = start;index < text.length; index++) {
|
|
1098
|
+
if (text[index] === "{")
|
|
1099
|
+
depth += 1;
|
|
1100
|
+
else if (text[index] === "}")
|
|
1101
|
+
depth -= 1;
|
|
1102
|
+
if (depth === 0)
|
|
1103
|
+
return text.slice(start, index);
|
|
1104
|
+
}
|
|
1105
|
+
return text.slice(start);
|
|
1106
|
+
}
|
|
1107
|
+
function readSize(value) {
|
|
1108
|
+
const words = value.split(/\s+/);
|
|
1109
|
+
const orientation = words.find((word) => word === "portrait" || word === "landscape");
|
|
1110
|
+
const rest = words.filter((word) => word !== orientation);
|
|
1111
|
+
let size = null;
|
|
1112
|
+
if (rest.length === 1 && rest[0] && PAGE_SIZES[rest[0]]) {
|
|
1113
|
+
const [width, height] = PAGE_SIZES[rest[0]];
|
|
1114
|
+
size = [readLength(width), readLength(height)];
|
|
1115
|
+
} else if (rest.length === 0 && orientation) {
|
|
1116
|
+
size = [readLength("8.5in"), readLength("11in")];
|
|
1117
|
+
} else {
|
|
1118
|
+
const lengths = readLengths(rest.join(" "));
|
|
1119
|
+
if (lengths?.length === 1 && lengths[0])
|
|
1120
|
+
size = [lengths[0], lengths[0]];
|
|
1121
|
+
else if (lengths?.length === 2 && lengths[0] && lengths[1])
|
|
1122
|
+
size = [lengths[0], lengths[1]];
|
|
1123
|
+
}
|
|
1124
|
+
if (!size || size[0] <= 0 || size[1] <= 0)
|
|
1125
|
+
return null;
|
|
1126
|
+
const [short, long] = size[0] <= size[1] ? size : [size[1], size[0]];
|
|
1127
|
+
if (orientation === "landscape")
|
|
1128
|
+
return [long, short];
|
|
1129
|
+
if (orientation === "portrait")
|
|
1130
|
+
return [short, long];
|
|
1131
|
+
return size;
|
|
1132
|
+
}
|
|
1133
|
+
function readLengths(value) {
|
|
1134
|
+
const lengths = value.split(/\s+/).map(readLength);
|
|
1135
|
+
return lengths.length > 0 && lengths.every((length) => length !== null) ? lengths : null;
|
|
1136
|
+
}
|
|
1137
|
+
function readLength(value) {
|
|
1138
|
+
if (value === "0")
|
|
1139
|
+
return 0;
|
|
1140
|
+
const match = /^(-?\d*\.?\d+)([a-z]+)$/.exec(value);
|
|
1141
|
+
const perUnit = match?.[2] ? PX_PER_UNIT[match[2]] : undefined;
|
|
1142
|
+
if (!match || perUnit === undefined)
|
|
1143
|
+
return null;
|
|
1144
|
+
const length = Number(match[1]) * perUnit;
|
|
1145
|
+
return Number.isFinite(length) && length >= 0 ? length : null;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
// src/artifacts/publish/validate/document-html.ts
|
|
1149
|
+
var DOCUMENT_HTML_ENTRY = "document.html";
|
|
1150
|
+
var REFUSED_ELEMENTS = [
|
|
1151
|
+
"script",
|
|
1152
|
+
"iframe",
|
|
1153
|
+
"frame",
|
|
1154
|
+
"frameset",
|
|
1155
|
+
"object",
|
|
1156
|
+
"embed",
|
|
1157
|
+
"applet",
|
|
1158
|
+
"form",
|
|
1159
|
+
"base",
|
|
1160
|
+
"portal",
|
|
1161
|
+
"meta[http-equiv]"
|
|
1162
|
+
];
|
|
1163
|
+
var RAW_TEXT_ELEMENTS = ["style", "title", "textarea", "xmp", "noembed", "noframes", "noscript"];
|
|
1164
|
+
var ADDRESS_ATTRIBUTES = ["href", "src", "xlink:href", "poster", "action", "formaction"];
|
|
1165
|
+
async function validateHtmlDocument(blobStorage, files) {
|
|
1166
|
+
const entry = files.find((file) => file.path === DOCUMENT_HTML_ENTRY);
|
|
1167
|
+
if (!entry)
|
|
1168
|
+
throw invalidArtifact(`A designed document needs '${DOCUMENT_HTML_ENTRY}'.`);
|
|
1169
|
+
refuseFrameAssetPaths(files, "the document");
|
|
1170
|
+
const html = await readArtifactText(blobStorage, entry, ARTIFACT_LIMITS2.maxDocumentBytes);
|
|
1171
|
+
const paths = new Set(files.map((file) => file.path));
|
|
1172
|
+
let refused;
|
|
1173
|
+
const refuse = (message) => {
|
|
1174
|
+
refused ??= message;
|
|
1175
|
+
};
|
|
1176
|
+
const headings = [];
|
|
1177
|
+
const slug = createHeadingSlugger2();
|
|
1178
|
+
const slugs = [];
|
|
1179
|
+
let heading = null;
|
|
1180
|
+
const styles = [];
|
|
1181
|
+
let style = null;
|
|
1182
|
+
let objectTypeId;
|
|
1183
|
+
const rewriter = new HTMLRewriter().on(REFUSED_ELEMENTS.join(", "), {
|
|
1184
|
+
element(element) {
|
|
1185
|
+
refuse(`${DOCUMENT_HTML_ENTRY} holds <${element.tagName}>. A designed document is laid out and printed, never run: it may not hold scripts, frames, forms, or <base>.`);
|
|
1186
|
+
}
|
|
1187
|
+
}).on("*", {
|
|
1188
|
+
element(element) {
|
|
1189
|
+
for (const [name, value] of element.attributes) {
|
|
1190
|
+
const attribute = name.toLowerCase();
|
|
1191
|
+
if (attribute.startsWith("on")) {
|
|
1192
|
+
refuse(`${DOCUMENT_HTML_ENTRY} gives <${element.tagName}> the handler '${name}'. A designed document runs no script.`);
|
|
1193
|
+
} else if (ADDRESS_ATTRIBUTES.includes(attribute) && /^\s*javascript:/i.test(decodeHtmlEntities(value).replace(/[\s\u0000-\u001f]/g, ""))) {
|
|
1194
|
+
refuse(`${DOCUMENT_HTML_ENTRY} links <${element.tagName}> to a javascript: address. A designed document runs no script.`);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
}).on(RAW_TEXT_ELEMENTS.map((tag) => `${tag}[data-sixb-field], ${tag}[data-sixb-each]`).join(", "), {
|
|
1199
|
+
element(element) {
|
|
1200
|
+
refuse(`${DOCUMENT_HTML_ENTRY} shows live data in <${element.tagName}>, whose text is not markup. Put the field in an element that shows text, such as <span>.`);
|
|
1201
|
+
}
|
|
1202
|
+
}).on("h1, h2, h3, h4, h5, h6", {
|
|
1203
|
+
element(element) {
|
|
1204
|
+
const current = { depth: Number(element.tagName.slice(1)), text: "" };
|
|
1205
|
+
heading = current;
|
|
1206
|
+
headings.push(current);
|
|
1207
|
+
element.onEndTag(() => {
|
|
1208
|
+
slugs.push(slug(plainText(current.text)));
|
|
1209
|
+
heading = null;
|
|
1210
|
+
});
|
|
1211
|
+
},
|
|
1212
|
+
text(chunk) {
|
|
1213
|
+
if (heading)
|
|
1214
|
+
heading.text += chunk.text;
|
|
1215
|
+
}
|
|
1216
|
+
}).on("img[src]", {
|
|
1217
|
+
element(element) {
|
|
1218
|
+
const source = decodeHtmlEntities(element.getAttribute("src") ?? "").trim();
|
|
1219
|
+
if (isArtifactAddress2(source))
|
|
1220
|
+
return;
|
|
1221
|
+
const problem = localFileProblem(source, paths);
|
|
1222
|
+
if (problem) {
|
|
1223
|
+
refuse(`${DOCUMENT_HTML_ENTRY} shows the image '${source}', ${problem}. Images are files in the artifact, by their relative path, or another artifact's address, such as artifact:art_k3m9q2x7tp/logo.png.`);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
}).on("link[href]", {
|
|
1227
|
+
element(element) {
|
|
1228
|
+
const rel = (element.getAttribute("rel") ?? "").toLowerCase().split(/\s+/);
|
|
1229
|
+
if (!rel.includes("stylesheet"))
|
|
1230
|
+
return;
|
|
1231
|
+
const href = decodeHtmlEntities(element.getAttribute("href") ?? "").trim();
|
|
1232
|
+
if (FRAME_CDN_ALLOWLIST2.some((origin) => href.startsWith(`${origin}/`)))
|
|
1233
|
+
return;
|
|
1234
|
+
const problem = localFileProblem(href, paths);
|
|
1235
|
+
if (problem) {
|
|
1236
|
+
refuse(`${DOCUMENT_HTML_ENTRY} loads the stylesheet '${href}', ${problem}. A stylesheet is a file in the artifact, by its relative path, or on ${FRAME_CDN_ALLOWLIST2.join(", ")}.`);
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
styles.push({ path: posix2.normalize(safeDecodeUri(href.split(/[?#]/)[0] ?? "")) });
|
|
1240
|
+
}
|
|
1241
|
+
}).on('meta[name="sixb:object-type"]', {
|
|
1242
|
+
element(element) {
|
|
1243
|
+
const content = decodeHtmlEntities(element.getAttribute("content") ?? "").trim();
|
|
1244
|
+
if (content)
|
|
1245
|
+
objectTypeId ??= content;
|
|
1246
|
+
}
|
|
1247
|
+
}).on("style", {
|
|
1248
|
+
element(element) {
|
|
1249
|
+
const current = { css: "" };
|
|
1250
|
+
style = current;
|
|
1251
|
+
styles.push(current);
|
|
1252
|
+
element.onEndTag(() => {
|
|
1253
|
+
style = null;
|
|
1254
|
+
});
|
|
1255
|
+
},
|
|
1256
|
+
text(chunk) {
|
|
1257
|
+
if (style)
|
|
1258
|
+
style.css += chunk.text;
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
const { references, refusal } = readHtmlReferences(rewriter, () => slugs.at(-1) ?? "", DOCUMENT_HTML_ENTRY);
|
|
1262
|
+
rewriter.transform(html);
|
|
1263
|
+
const problem = refused ?? refusal();
|
|
1264
|
+
if (problem)
|
|
1265
|
+
throw invalidArtifact(problem);
|
|
1266
|
+
const stylesheets = [];
|
|
1267
|
+
for (const each of styles) {
|
|
1268
|
+
if ("css" in each) {
|
|
1269
|
+
stylesheets.push(each.css);
|
|
1270
|
+
continue;
|
|
1271
|
+
}
|
|
1272
|
+
const file = files.find((candidate) => candidate.path === each.path);
|
|
1273
|
+
if (file) {
|
|
1274
|
+
stylesheets.push(await readArtifactText(blobStorage, file, ARTIFACT_LIMITS2.maxDocumentBytes));
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
const paper = readDocumentPaper(stylesheets);
|
|
1278
|
+
const outlined = headings.map(({ depth, text }, index) => ({
|
|
1279
|
+
depth,
|
|
1280
|
+
text: plainText(text),
|
|
1281
|
+
slug: slugs[index] ?? ""
|
|
1282
|
+
}));
|
|
1283
|
+
return {
|
|
1284
|
+
entry: DOCUMENT_HTML_ENTRY,
|
|
1285
|
+
outline: {
|
|
1286
|
+
kind: "document",
|
|
1287
|
+
format: "html",
|
|
1288
|
+
headings: outlined,
|
|
1289
|
+
...paper ? { paper } : {},
|
|
1290
|
+
...objectTypeId ? { holder: { objectTypeId, links: [] } } : {}
|
|
1291
|
+
},
|
|
1292
|
+
references,
|
|
1293
|
+
marks: documentMarks(html)
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
function plainText(text) {
|
|
1297
|
+
return decodeHtmlEntities(text).replace(/\s+/g, " ").trim();
|
|
1298
|
+
}
|
|
1299
|
+
function localFileProblem(source, paths) {
|
|
1300
|
+
if (source === "" || source.startsWith("//") || /^[a-z][a-z\d+.-]*:/i.test(source)) {
|
|
1301
|
+
return "which is not a file in the artifact";
|
|
1302
|
+
}
|
|
1303
|
+
const path = posix2.normalize(safeDecodeUri(source.split(/[?#]/)[0] ?? ""));
|
|
1304
|
+
return paths.has(path) ? null : "which is not one of the artifact's files";
|
|
1305
|
+
}
|
|
1306
|
+
function safeDecodeUri(value) {
|
|
1307
|
+
try {
|
|
1308
|
+
return decodeURI(value);
|
|
1309
|
+
} catch {
|
|
1310
|
+
return value;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
// src/artifacts/publish/pdf.ts
|
|
1315
|
+
var MAX_DOCUMENT_PDF_BYTES2 = 64 * 1024 * 1024;
|
|
1316
|
+
var RENDER_KEY_FORMAT2 = "sixb-document-pdf/1";
|
|
1317
|
+
function documentPdfKey2(version, document) {
|
|
1318
|
+
if (version.outline.kind !== "document" || version.outline.format !== "html")
|
|
1319
|
+
return null;
|
|
1320
|
+
const files = version.files.map((entry) => [
|
|
1321
|
+
entry.path,
|
|
1322
|
+
document && entry.path === DOCUMENT_HTML_ENTRY ? document.digest : entry.file.digest
|
|
1323
|
+
]).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
|
|
1324
|
+
return createHash3("sha256").update(JSON.stringify([RENDER_KEY_FORMAT2, frameKitDigest(), version.artifactId, files])).digest("hex");
|
|
1325
|
+
}
|
|
1326
|
+
async function requestDocumentPdf(context, version, options = {}) {
|
|
1327
|
+
const renderKey = documentPdfKey2(version, options.document);
|
|
1328
|
+
if (!renderKey)
|
|
1329
|
+
return;
|
|
1330
|
+
if (options.retry) {
|
|
1331
|
+
await context.storage.clearPdfFailure({ projectId: version.projectId, renderKey });
|
|
1332
|
+
}
|
|
1333
|
+
await context.queue.enqueue({
|
|
1334
|
+
projectId: version.projectId,
|
|
1335
|
+
jobs: [
|
|
1336
|
+
{
|
|
1337
|
+
id: `art_pdf_${renderKey}`,
|
|
1338
|
+
...options.retry ? { replace: true } : {},
|
|
1339
|
+
type: "artifact.pdf.requested",
|
|
1340
|
+
payload: {
|
|
1341
|
+
artifactId: version.artifactId,
|
|
1342
|
+
version: version.version,
|
|
1343
|
+
renderKey,
|
|
1344
|
+
...options.document ? { document: options.document } : {}
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
]
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
// src/artifacts/publish/fields.ts
|
|
1352
|
+
async function checkDocumentFields(input) {
|
|
1353
|
+
const data = documentData();
|
|
1354
|
+
const warnings = [];
|
|
1355
|
+
const unknown = (mark, why) => warnings.push({
|
|
1356
|
+
code: "field_unknown",
|
|
1357
|
+
message: `data-sixb-${mark.kind}="${mark.path}" ${why}. It keeps the text written in it.`
|
|
1358
|
+
});
|
|
1359
|
+
const baseOf = (path, within) => {
|
|
1360
|
+
if (path.query !== undefined) {
|
|
1361
|
+
const query = input.queries.get(path.query);
|
|
1362
|
+
return query ? { kind: "rows", query } : { kind: "unknown" };
|
|
1363
|
+
}
|
|
1364
|
+
const each = within.at(-1);
|
|
1365
|
+
if (each === undefined)
|
|
1366
|
+
return { kind: "holder" };
|
|
1367
|
+
const parsed = data.parse(each);
|
|
1368
|
+
if (!parsed)
|
|
1369
|
+
return { kind: "unknown" };
|
|
1370
|
+
if (parsed.query !== undefined && parsed.steps.length === 0)
|
|
1371
|
+
return baseOf(parsed, []);
|
|
1372
|
+
const [step, ...rest] = parsed.steps;
|
|
1373
|
+
const repeatsHolder = baseOf(parsed, within.slice(0, -1)).kind === "holder";
|
|
1374
|
+
return step && rest.length === 0 && step.id === undefined && repeatsHolder ? { kind: "item", key: step.key } : { kind: "unknown" };
|
|
1375
|
+
};
|
|
1376
|
+
const reads = input.marks.flatMap((mark) => {
|
|
1377
|
+
const path = data.parse(mark.path);
|
|
1378
|
+
if (!path) {
|
|
1379
|
+
unknown(mark, "is not a path: name properties with dots, and a list's item by its id in [ ]");
|
|
1380
|
+
return [];
|
|
1381
|
+
}
|
|
1382
|
+
return [{ mark, path, base: baseOf(path, mark.within) }];
|
|
1383
|
+
});
|
|
1384
|
+
let holder;
|
|
1385
|
+
let holderProperties = {};
|
|
1386
|
+
const linkProperties = new Map;
|
|
1387
|
+
const readsHolder = reads.some((read) => read.base.kind === "holder");
|
|
1388
|
+
if (readsHolder && !input.holder) {
|
|
1389
|
+
warnings.push({
|
|
1390
|
+
code: "field_unknown",
|
|
1391
|
+
message: `The document's fields read the object that holds it, but it names no type of object: add <meta name="sixb:object-type" content="..."> to its <head>. They keep the text written in them.`
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
if (input.holder) {
|
|
1395
|
+
if (!input.checker) {
|
|
1396
|
+
throw invalidArtifact("The document shows live data of the object that holds it, and this publish has no way to check that its author reads it.");
|
|
1397
|
+
}
|
|
1398
|
+
const objectTypeId = input.holder;
|
|
1399
|
+
const start = { kind: "start", objectTypeId };
|
|
1400
|
+
try {
|
|
1401
|
+
holderProperties = (await input.checker({ kind: "objects", query: start })).schema.properties;
|
|
1402
|
+
} catch (error) {
|
|
1403
|
+
throw invalidArtifact(`The document names the object type '${objectTypeId}' in <meta name="sixb:object-type">, which you cannot read: ${error instanceof Error ? error.message.replace(/^\[Sixb\]\s*/, "") : String(error)}`);
|
|
1404
|
+
}
|
|
1405
|
+
const candidates = new Set;
|
|
1406
|
+
for (const { base, path } of reads) {
|
|
1407
|
+
const first = path.steps[0]?.key;
|
|
1408
|
+
if (base.kind === "holder" && first && !Object.hasOwn(holderProperties, first)) {
|
|
1409
|
+
candidates.add(first);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
for (const linkId of candidates) {
|
|
1413
|
+
try {
|
|
1414
|
+
const checked = await input.checker({
|
|
1415
|
+
kind: "objects",
|
|
1416
|
+
query: { kind: "expand", input: start, expansions: [{ linkId, direction: "outgoing" }] }
|
|
1417
|
+
});
|
|
1418
|
+
linkProperties.set(linkId, checked.schema.links[linkId]?.properties ?? {});
|
|
1419
|
+
} catch {}
|
|
1420
|
+
}
|
|
1421
|
+
holder = { objectTypeId, links: [...linkProperties.keys()] };
|
|
1422
|
+
}
|
|
1423
|
+
for (const { mark, path, base } of reads) {
|
|
1424
|
+
const [first, second] = path.steps;
|
|
1425
|
+
switch (base.kind) {
|
|
1426
|
+
case "unknown":
|
|
1427
|
+
if (path.query !== undefined)
|
|
1428
|
+
unknown(mark, `names no query: add queries/${path.query}.json`);
|
|
1429
|
+
break;
|
|
1430
|
+
case "rows": {
|
|
1431
|
+
const facets = base.query.kind === "facets";
|
|
1432
|
+
if (path.query !== undefined) {
|
|
1433
|
+
if (mark.kind === "field" && first?.key === "total" && path.steps.length === 1)
|
|
1434
|
+
break;
|
|
1435
|
+
if (first?.key === "facets" && path.steps.length === 2 && facets)
|
|
1436
|
+
break;
|
|
1437
|
+
if (mark.kind === "each" && path.steps.length === 0 && !facets)
|
|
1438
|
+
break;
|
|
1439
|
+
unknown(mark, facets ? `reads facets: repeat over query:${path.query}.facets.<property>, or show query:${path.query}.total` : `reads rows: repeat over query:${path.query}, or show query:${path.query}.total`);
|
|
1440
|
+
break;
|
|
1441
|
+
}
|
|
1442
|
+
if (!first)
|
|
1443
|
+
break;
|
|
1444
|
+
const links = base.query.schema.links;
|
|
1445
|
+
if (Object.hasOwn(base.query.schema.properties, first.key))
|
|
1446
|
+
break;
|
|
1447
|
+
if (Object.hasOwn(links, first.key)) {
|
|
1448
|
+
if (second && !Object.hasOwn(links[first.key]?.properties ?? {}, second.key)) {
|
|
1449
|
+
unknown(mark, `reads '${second.key}', which what '${first.key}' reaches does not hold`);
|
|
1450
|
+
}
|
|
1451
|
+
break;
|
|
1452
|
+
}
|
|
1453
|
+
unknown(mark, `reads '${first.key}', which the rows of its query do not hold`);
|
|
1454
|
+
break;
|
|
1455
|
+
}
|
|
1456
|
+
case "item": {
|
|
1457
|
+
const reached = linkProperties.get(base.key);
|
|
1458
|
+
if (reached && first && !Object.hasOwn(reached, first.key)) {
|
|
1459
|
+
unknown(mark, `reads '${first.key}', which what '${base.key}' reaches does not hold`);
|
|
1460
|
+
}
|
|
1461
|
+
break;
|
|
1462
|
+
}
|
|
1463
|
+
case "holder": {
|
|
1464
|
+
if (!input.holder || !first)
|
|
1465
|
+
break;
|
|
1466
|
+
if (Object.hasOwn(holderProperties, first.key))
|
|
1467
|
+
break;
|
|
1468
|
+
const reached = linkProperties.get(first.key);
|
|
1469
|
+
if (!reached) {
|
|
1470
|
+
unknown(mark, `reads '${first.key}', which a ${input.holder} does not hold`);
|
|
1471
|
+
} else if (second && !Object.hasOwn(reached, second.key)) {
|
|
1472
|
+
unknown(mark, `reads '${second.key}', which what '${first.key}' reaches does not hold`);
|
|
1473
|
+
}
|
|
1474
|
+
break;
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
return { ...holder ? { holder } : {}, warnings };
|
|
1479
|
+
}
|
|
1480
|
+
|
|
978
1481
|
// src/artifacts/run-query.ts
|
|
979
1482
|
var PAGE_SIZE = 1000;
|
|
980
1483
|
async function runArtifactQuery(runtime, name, query) {
|
|
@@ -1207,7 +1710,7 @@ function outermostProject(query, at = "$") {
|
|
|
1207
1710
|
return;
|
|
1208
1711
|
}
|
|
1209
1712
|
}
|
|
1210
|
-
async function checkArtifactQueries(blobStorage, kind, files, checker) {
|
|
1713
|
+
async function checkArtifactQueries(blobStorage, kind, files, checker, options = {}) {
|
|
1211
1714
|
const checked = new Map;
|
|
1212
1715
|
if (kind === "file")
|
|
1213
1716
|
return checked;
|
|
@@ -1215,8 +1718,9 @@ async function checkArtifactQueries(blobStorage, kind, files, checker) {
|
|
|
1215
1718
|
const [first] = queries;
|
|
1216
1719
|
if (!first)
|
|
1217
1720
|
return checked;
|
|
1218
|
-
|
|
1219
|
-
|
|
1721
|
+
const markdown = kind === "document" && !files.some((file) => file.path === DOCUMENT_HTML_ENTRY);
|
|
1722
|
+
if (!ARTIFACT_QUERY_KINDS.includes(kind) || markdown) {
|
|
1723
|
+
throw invalidArtifact(`'${first.path}': a ${markdown ? "Markdown document" : kind} runs no query. A Markdown document shows a live sheet instead; a designed one, document.html, runs queries.`);
|
|
1220
1724
|
}
|
|
1221
1725
|
if (queries.length > ARTIFACT_LIMITS2.maxQueries) {
|
|
1222
1726
|
throw invalidArtifact(`A version holds at most ${ARTIFACT_LIMITS2.maxQueries} queries; this one has ${queries.length}.`);
|
|
@@ -1229,8 +1733,11 @@ async function checkArtifactQueries(blobStorage, kind, files, checker) {
|
|
|
1229
1733
|
if (!name) {
|
|
1230
1734
|
throw invalidArtifact(`'${file.path}' is not a query: name it queries/<name>.json, with lowercase letters, digits and hyphens, at most 64 characters.`);
|
|
1231
1735
|
}
|
|
1736
|
+
if (kind === "document" && name === DOCUMENT_HOLDER_QUERY2) {
|
|
1737
|
+
throw invalidArtifact(`'${file.path}': "${DOCUMENT_HOLDER_QUERY2}" is what a document's fields read of the object that holds it. Name the query otherwise.`);
|
|
1738
|
+
}
|
|
1232
1739
|
const text = await readArtifactText(blobStorage, file, ARTIFACT_LIMITS2.maxQueryBytes);
|
|
1233
|
-
const parsed = parseArtifactQuery(file.path, text);
|
|
1740
|
+
const parsed = parseArtifactQuery(file.path, text, options.holder ? { holder: { kind: "start", objectTypeId: options.holder } } : {});
|
|
1234
1741
|
if ("error" in parsed)
|
|
1235
1742
|
throw invalidArtifact(parsed.error);
|
|
1236
1743
|
try {
|
|
@@ -1345,7 +1852,7 @@ function ownArtifacts(author) {
|
|
|
1345
1852
|
}
|
|
1346
1853
|
|
|
1347
1854
|
// src/artifacts/publish/validate/canvas.ts
|
|
1348
|
-
import { posix as
|
|
1855
|
+
import { posix as posix3 } from "path";
|
|
1349
1856
|
async function validateCanvas(blobStorage, files) {
|
|
1350
1857
|
const byPath = new Map(files.map((file) => [file.path, file]));
|
|
1351
1858
|
const canvasFile = byPath.get(CANVAS_FILE2);
|
|
@@ -1363,7 +1870,7 @@ async function validateCanvas(blobStorage, files) {
|
|
|
1363
1870
|
references.push({ address: item.src, as: "embed", at: item.id });
|
|
1364
1871
|
if (item.type !== "board")
|
|
1365
1872
|
continue;
|
|
1366
|
-
const file = byPath.get(
|
|
1873
|
+
const file = byPath.get(posix3.normalize(item.file));
|
|
1367
1874
|
if (!file) {
|
|
1368
1875
|
throw invalidArtifact(`${CANVAS_FILE2} board '${item.id}' shows '${item.file}', which is not one of the canvas's files.`);
|
|
1369
1876
|
}
|
|
@@ -1384,7 +1891,7 @@ async function validateCanvas(blobStorage, files) {
|
|
|
1384
1891
|
const named = { id: item.id, ...title ? { title } : {} };
|
|
1385
1892
|
if (item.type === "board") {
|
|
1386
1893
|
return [
|
|
1387
|
-
{ ...named, type: "board", file:
|
|
1894
|
+
{ ...named, type: "board", file: posix3.normalize(item.file), w: item.w, h: item.h }
|
|
1388
1895
|
];
|
|
1389
1896
|
}
|
|
1390
1897
|
return item.type === "section" ? [{ ...named, type: "section" }] : [];
|
|
@@ -1523,12 +2030,22 @@ function crosses(start, end, box) {
|
|
|
1523
2030
|
}
|
|
1524
2031
|
|
|
1525
2032
|
// src/artifacts/publish/validate/document.ts
|
|
1526
|
-
import { posix as
|
|
2033
|
+
import { posix as posix4 } from "path";
|
|
1527
2034
|
var DOCUMENT_ENTRY = "document.md";
|
|
1528
2035
|
async function validateDocument(blobStorage, files) {
|
|
1529
|
-
const
|
|
1530
|
-
|
|
1531
|
-
|
|
2036
|
+
const markdown = files.find((file) => file.path === DOCUMENT_ENTRY);
|
|
2037
|
+
const designed = files.some((file) => file.path === DOCUMENT_HTML_ENTRY);
|
|
2038
|
+
if (markdown && designed) {
|
|
2039
|
+
throw invalidArtifact(`A document renders from '${DOCUMENT_ENTRY}' or from '${DOCUMENT_HTML_ENTRY}', not both: keep one.`);
|
|
2040
|
+
}
|
|
2041
|
+
if (designed)
|
|
2042
|
+
return validateHtmlDocument(blobStorage, files);
|
|
2043
|
+
if (!markdown) {
|
|
2044
|
+
throw invalidArtifact(`A document needs its Markdown in '${DOCUMENT_ENTRY}', or its HTML in '${DOCUMENT_HTML_ENTRY}' when it has a design of its own.`);
|
|
2045
|
+
}
|
|
2046
|
+
return validateMarkdownDocument(blobStorage, markdown, files);
|
|
2047
|
+
}
|
|
2048
|
+
async function validateMarkdownDocument(blobStorage, entry, files) {
|
|
1532
2049
|
const markdown = await readArtifactText(blobStorage, entry, ARTIFACT_LIMITS2.maxDocumentBytes);
|
|
1533
2050
|
const html = Bun.markdown.html(markdown, {
|
|
1534
2051
|
tables: true,
|
|
@@ -1591,12 +2108,12 @@ function checkImage(source, paths) {
|
|
|
1591
2108
|
if (source === "" || source.startsWith("//") || /^[a-z][a-z\d+.-]*:/i.test(source)) {
|
|
1592
2109
|
throw invalidArtifact(`${DOCUMENT_ENTRY} shows the image '${source}'. Images must be files in the artifact, by their relative path, or another artifact's address, such as artifact:art_k3m9q2x7tp#chart=revenue.`);
|
|
1593
2110
|
}
|
|
1594
|
-
const path =
|
|
2111
|
+
const path = posix4.normalize(safeDecodeUri2(source.split(/[?#]/)[0] ?? ""));
|
|
1595
2112
|
if (!paths.has(path)) {
|
|
1596
2113
|
throw invalidArtifact(`${DOCUMENT_ENTRY} shows the image '${source}', which is not one of the artifact's files.`);
|
|
1597
2114
|
}
|
|
1598
2115
|
}
|
|
1599
|
-
function
|
|
2116
|
+
function safeDecodeUri2(value) {
|
|
1600
2117
|
try {
|
|
1601
2118
|
return decodeURI(value);
|
|
1602
2119
|
} catch {
|
|
@@ -1661,7 +2178,7 @@ async function validatePage(blobStorage, files) {
|
|
|
1661
2178
|
}
|
|
1662
2179
|
|
|
1663
2180
|
// src/artifacts/publish/validate/sheet.ts
|
|
1664
|
-
import { posix as
|
|
2181
|
+
import { posix as posix5 } from "path";
|
|
1665
2182
|
async function validateSheet(blobStorage, files, queries) {
|
|
1666
2183
|
const byPath = new Map(files.map((file) => [file.path, file]));
|
|
1667
2184
|
const workbookFile = byPath.get(WORKBOOK_FILE2);
|
|
@@ -1821,7 +2338,7 @@ function cellProblem(value, format, byPath) {
|
|
|
1821
2338
|
case "link":
|
|
1822
2339
|
return /^https?:\/\/[^\s]+$/i.test(value.trim()) ? undefined : "is not a link: write a full https:// address, or another artifact's address.";
|
|
1823
2340
|
case "image": {
|
|
1824
|
-
const imagePath =
|
|
2341
|
+
const imagePath = posix5.normalize(value.trim());
|
|
1825
2342
|
return byPath.has(imagePath) ? undefined : "is not one of the artifact's files: add the image to the artifact and give its relative path, or give another artifact's address.";
|
|
1826
2343
|
}
|
|
1827
2344
|
case "boolean":
|
|
@@ -1914,8 +2431,22 @@ async function prepareArtifactVersion2(context, input) {
|
|
|
1914
2431
|
const title = checkTitle(input.title);
|
|
1915
2432
|
await checkArtifactFiles(context.blobStorage, input.files);
|
|
1916
2433
|
const theme = input.kind === "file" ? undefined : await readTheme(context.blobStorage, input.files);
|
|
1917
|
-
const
|
|
1918
|
-
const
|
|
2434
|
+
const document = input.kind === "document" ? await validateDocument(context.blobStorage, input.files) : null;
|
|
2435
|
+
const queries = await checkArtifactQueries(context.blobStorage, input.kind, input.files, input.checkQuery, document?.outline.holder ? { holder: document.outline.holder.objectTypeId } : {});
|
|
2436
|
+
const fields = document?.marks ? await checkDocumentFields({
|
|
2437
|
+
marks: document.marks,
|
|
2438
|
+
...document.outline.holder ? { holder: document.outline.holder.objectTypeId } : {},
|
|
2439
|
+
queries,
|
|
2440
|
+
...input.checkQuery ? { checker: input.checkQuery } : {}
|
|
2441
|
+
}) : null;
|
|
2442
|
+
const validated = document ? {
|
|
2443
|
+
...document,
|
|
2444
|
+
outline: {
|
|
2445
|
+
...document.outline,
|
|
2446
|
+
...fields?.holder ? { holder: fields.holder } : {}
|
|
2447
|
+
},
|
|
2448
|
+
warnings: fields?.warnings ?? []
|
|
2449
|
+
} : await validateKind(context.blobStorage, input.kind, input.files, queries);
|
|
1919
2450
|
const readable = input.readable ?? ownArtifacts(input.author);
|
|
1920
2451
|
const references = await resolveReferences(referenceContext(context, { readable, artifactId: input.artifactId }), validated.references ?? []);
|
|
1921
2452
|
return {
|
|
@@ -2165,13 +2696,92 @@ function createArtifactsRuntime(runtime, blobStorage, options = {}) {
|
|
|
2165
2696
|
};
|
|
2166
2697
|
const rule = () => createRuntimeArtifactAccessRule(runtime);
|
|
2167
2698
|
const checkQuery = createArtifactQueryChecker(runtime);
|
|
2699
|
+
const runQuery = async (read, name) => {
|
|
2700
|
+
const { artifact, version } = read;
|
|
2701
|
+
const holder = version.outline.kind === "document" ? version.outline.holder : undefined;
|
|
2702
|
+
if (holder && name === DOCUMENT_HOLDER_QUERY2) {
|
|
2703
|
+
const refs = { kind: "refs", refs: [await requireHolder(artifact.id, holder)] };
|
|
2704
|
+
const expansions = holder.links.map((linkId) => ({
|
|
2705
|
+
linkId,
|
|
2706
|
+
direction: "outgoing"
|
|
2707
|
+
}));
|
|
2708
|
+
return runArtifactQuery(runtime, name, {
|
|
2709
|
+
kind: "objects",
|
|
2710
|
+
query: expansions.length > 0 ? { kind: "expand", input: refs, expansions } : refs
|
|
2711
|
+
});
|
|
2712
|
+
}
|
|
2713
|
+
const file = ARTIFACT_QUERY_KINDS.includes(artifact.kind) && isArtifactQueryName(name) ? version.files.find((candidate) => candidate.path === artifactQueryPath(name)) : undefined;
|
|
2714
|
+
if (!file) {
|
|
2715
|
+
throw new ArtifactRequestError2("query_not_found", `[Sixb] Version ${version.version} of artifact '${artifact.id}' has no query '${name}'.`);
|
|
2716
|
+
}
|
|
2717
|
+
const text = await readArtifactText(blobStorage, file, ARTIFACT_LIMITS2.maxQueryBytes);
|
|
2718
|
+
const parse = (start) => parseArtifactQuery(file.path, text, start ? { holder: start } : {});
|
|
2719
|
+
let parsed = parse(holder ? { kind: "refs", refs: [] } : undefined);
|
|
2720
|
+
if (holder && "usesHolder" in parsed && parsed.usesHolder) {
|
|
2721
|
+
parsed = parse({ kind: "refs", refs: [await requireHolder(artifact.id, holder)] });
|
|
2722
|
+
}
|
|
2723
|
+
if ("error" in parsed) {
|
|
2724
|
+
throw new ArtifactRequestError2("query_invalid", `[Sixb] ${parsed.error}`);
|
|
2725
|
+
}
|
|
2726
|
+
return runArtifactQuery(runtime, name, parsed.query);
|
|
2727
|
+
};
|
|
2728
|
+
const writtenIn = async (read, options = {}) => {
|
|
2729
|
+
const { version } = read;
|
|
2730
|
+
const entry = version.files.find((file) => file.path === DOCUMENT_HTML_ENTRY);
|
|
2731
|
+
if (version.outline.kind !== "document" || !entry)
|
|
2732
|
+
return null;
|
|
2733
|
+
const html = await readArtifactText(blobStorage, entry, ARTIFACT_LIMITS2.maxDocumentBytes);
|
|
2734
|
+
const reads = documentData().reads(documentMarks(html));
|
|
2735
|
+
if (!reads.holder && reads.queries.length === 0)
|
|
2736
|
+
return null;
|
|
2737
|
+
if (version.frozenAt)
|
|
2738
|
+
return frozenDocumentHtml2(html);
|
|
2739
|
+
const answer = (name) => runQuery(read, name).then((result) => result, (error) => {
|
|
2740
|
+
if (error instanceof AuthorizationError2 || error instanceof ArtifactRequestError2) {
|
|
2741
|
+
return;
|
|
2742
|
+
}
|
|
2743
|
+
throw error;
|
|
2744
|
+
});
|
|
2745
|
+
const [holder, ...results] = await Promise.all([
|
|
2746
|
+
reads.holder ? answer(DOCUMENT_HOLDER_QUERY2) : undefined,
|
|
2747
|
+
...reads.queries.map(answer)
|
|
2748
|
+
]);
|
|
2749
|
+
const queries = {};
|
|
2750
|
+
reads.queries.forEach((name, index) => {
|
|
2751
|
+
const result = results[index];
|
|
2752
|
+
if (result)
|
|
2753
|
+
queries[name] = result;
|
|
2754
|
+
});
|
|
2755
|
+
const row = holder?.objects?.[0];
|
|
2756
|
+
return fillDocumentHtml(html, { ...row ? { holder: row } : {}, queries }, options.keep ? { keep: true } : { plain: true });
|
|
2757
|
+
};
|
|
2758
|
+
const requireHolder = async (artifactId, holder) => {
|
|
2759
|
+
const found = new Set;
|
|
2760
|
+
const holdings = readableHoldings({
|
|
2761
|
+
runtime,
|
|
2762
|
+
reader: runtime.objectReader,
|
|
2763
|
+
objects: runtime.storage.objects,
|
|
2764
|
+
artifactId
|
|
2765
|
+
});
|
|
2766
|
+
for await (const holding of holdings) {
|
|
2767
|
+
if (holding.objectTypeId === holder.objectTypeId)
|
|
2768
|
+
found.add(holding.primaryId);
|
|
2769
|
+
if (found.size > 1)
|
|
2770
|
+
break;
|
|
2771
|
+
}
|
|
2772
|
+
const [primaryId] = found;
|
|
2773
|
+
if (found.size !== 1 || primaryId === undefined) {
|
|
2774
|
+
throw new ArtifactRequestError2("holder_not_found", `[Sixb] No one ${holder.objectTypeId} you read holds artifact '${artifactId}', so its fields show what is written in them.`);
|
|
2775
|
+
}
|
|
2776
|
+
return { objectTypeId: holder.objectTypeId, primaryId };
|
|
2777
|
+
};
|
|
2168
2778
|
const requestPreviews = async (version, requestOptions) => {
|
|
2169
2779
|
const storage = runtime.storage.artifacts;
|
|
2170
|
-
if (!options.
|
|
2780
|
+
if (!options.rendersInSandboxes || !storage)
|
|
2171
2781
|
return;
|
|
2172
2782
|
await requestBoardPreviews({
|
|
2173
2783
|
storage,
|
|
2174
|
-
queue: runtime.queues.
|
|
2784
|
+
queue: runtime.queues.renders,
|
|
2175
2785
|
blobStorage,
|
|
2176
2786
|
query: (name) => artifacts.query(version.artifactId, name, { version: version.version })
|
|
2177
2787
|
}, version, requestOptions);
|
|
@@ -2278,8 +2888,8 @@ function createArtifactsRuntime(runtime, blobStorage, options = {}) {
|
|
|
2278
2888
|
};
|
|
2279
2889
|
const writeLive = async (artifactId, input) => {
|
|
2280
2890
|
const artifact = await requireUpdatable(artifactId);
|
|
2281
|
-
if (!
|
|
2282
|
-
throw invalidArtifact(`Artifact '${artifactId}' is a ${artifact.kind}
|
|
2891
|
+
if (!keepsDocument2(artifact.kind)) {
|
|
2892
|
+
throw invalidArtifact(`Artifact '${artifactId}' is a ${artifact.kind} that is not edited live: publish its files.`);
|
|
2283
2893
|
}
|
|
2284
2894
|
return write({ artifactId, kind: artifact.kind, ...input });
|
|
2285
2895
|
};
|
|
@@ -2290,7 +2900,8 @@ function createArtifactsRuntime(runtime, blobStorage, options = {}) {
|
|
|
2290
2900
|
events: runtime.events,
|
|
2291
2901
|
author: commentAuthor,
|
|
2292
2902
|
manager: requireCaller,
|
|
2293
|
-
reach
|
|
2903
|
+
reach,
|
|
2904
|
+
...authority.type === "delegated" ? { guest: { grantId: authority.delegation?.grantId } } : {}
|
|
2294
2905
|
}),
|
|
2295
2906
|
async create(input) {
|
|
2296
2907
|
const author = requireCaller();
|
|
@@ -2321,11 +2932,30 @@ function createArtifactsRuntime(runtime, blobStorage, options = {}) {
|
|
|
2321
2932
|
});
|
|
2322
2933
|
},
|
|
2323
2934
|
async freeze(artifactId, input = {}) {
|
|
2935
|
+
let baseRevision = input.baseRevision;
|
|
2936
|
+
const open = await readVersion(artifactId, "latest");
|
|
2937
|
+
const filled = open && !open.version.frozenAt ? await writtenIn(open, { keep: true }) : null;
|
|
2938
|
+
if (open && filled !== null) {
|
|
2939
|
+
await requireUpdatable(artifactId);
|
|
2940
|
+
const document = await blobStorage.put({
|
|
2941
|
+
body: new TextEncoder().encode(filled),
|
|
2942
|
+
fileName: DOCUMENT_HTML_ENTRY,
|
|
2943
|
+
mediaType: "text/html"
|
|
2944
|
+
});
|
|
2945
|
+
const written = await write({
|
|
2946
|
+
artifactId,
|
|
2947
|
+
kind: "document",
|
|
2948
|
+
files: open.version.files.map((file) => file.path === DOCUMENT_HTML_ENTRY ? { path: file.path, file: document } : file),
|
|
2949
|
+
baseRevision: baseRevision ?? open.version.revision,
|
|
2950
|
+
title: open.version.title
|
|
2951
|
+
});
|
|
2952
|
+
baseRevision = written.version.revision;
|
|
2953
|
+
}
|
|
2324
2954
|
const frozenAt = new Date;
|
|
2325
2955
|
const frozen = await change(artifactId, (storage, author) => storage.freeze({
|
|
2326
2956
|
projectId: runtime.projectId,
|
|
2327
2957
|
artifactId,
|
|
2328
|
-
...
|
|
2958
|
+
...baseRevision === undefined ? {} : { baseRevision },
|
|
2329
2959
|
frozenAt,
|
|
2330
2960
|
frozenBy: author
|
|
2331
2961
|
}));
|
|
@@ -2405,21 +3035,49 @@ function createArtifactsRuntime(runtime, blobStorage, options = {}) {
|
|
|
2405
3035
|
async getVersion(artifactId, version) {
|
|
2406
3036
|
return (await readVersion(artifactId, version))?.version ?? null;
|
|
2407
3037
|
},
|
|
2408
|
-
async
|
|
2409
|
-
const read = await readVersion(artifactId,
|
|
3038
|
+
async pdf(artifactId, pdfOptions = {}) {
|
|
3039
|
+
const read = await readVersion(artifactId, pdfOptions.version ?? "latest");
|
|
2410
3040
|
if (!read)
|
|
2411
3041
|
return null;
|
|
2412
|
-
const {
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
throw new ArtifactRequestError2("query_not_found", `[Sixb] Version ${version.version} of artifact '${artifactId}' has no query '${name}'.`);
|
|
3042
|
+
const { version } = read;
|
|
3043
|
+
if (!documentPdfKey2(version)) {
|
|
3044
|
+
throw invalidArtifact(`Version ${version.version} of '${artifactId}' is not a designed document, which alone prints to PDF.`);
|
|
2416
3045
|
}
|
|
2417
|
-
const
|
|
2418
|
-
const
|
|
2419
|
-
|
|
2420
|
-
|
|
3046
|
+
const { key } = pdfOptions;
|
|
3047
|
+
const filled = key !== undefined ? null : await writtenIn(read);
|
|
3048
|
+
const printed = filled === null ? null : new TextEncoder().encode(filled);
|
|
3049
|
+
const digest = key ?? (printed ? computeBlobDigest2(printed) : undefined);
|
|
3050
|
+
const keyed = digest ? { key: digest } : {};
|
|
3051
|
+
const renderKey = documentPdfKey2(version, digest ? { digest } : undefined);
|
|
3052
|
+
const storage = requireStorage();
|
|
3053
|
+
const kept = await storage.getPdf({ projectId: runtime.projectId, renderKey });
|
|
3054
|
+
if (kept && !("failure" in kept)) {
|
|
3055
|
+
return { status: "ready", file: kept.file, pages: kept.pages, ...keyed };
|
|
2421
3056
|
}
|
|
2422
|
-
|
|
3057
|
+
if (kept && (!pdfOptions.retry || key !== undefined)) {
|
|
3058
|
+
return { status: "failed", reason: kept.failure, ...keyed };
|
|
3059
|
+
}
|
|
3060
|
+
if (pdfOptions.print === false || key !== undefined)
|
|
3061
|
+
return { status: "printing", ...keyed };
|
|
3062
|
+
if (!options.rendersInSandboxes) {
|
|
3063
|
+
throw new ArtifactRequestError2("pdf_unavailable", "[Sixb] A document prints to PDF in a sandbox, and this project has no sandbox provider.");
|
|
3064
|
+
}
|
|
3065
|
+
const document = printed ? await blobStorage.put({
|
|
3066
|
+
body: printed,
|
|
3067
|
+
fileName: DOCUMENT_HTML_ENTRY,
|
|
3068
|
+
mediaType: "text/html"
|
|
3069
|
+
}) : undefined;
|
|
3070
|
+
await requestDocumentPdf({ storage, queue: runtime.queues.renders }, version, {
|
|
3071
|
+
...document ? { document } : {},
|
|
3072
|
+
retry: pdfOptions.retry === true
|
|
3073
|
+
});
|
|
3074
|
+
return { status: "printing", ...keyed };
|
|
3075
|
+
},
|
|
3076
|
+
async query(artifactId, name, options = {}) {
|
|
3077
|
+
const read = await readVersion(artifactId, options.version ?? "latest");
|
|
3078
|
+
if (!read)
|
|
3079
|
+
return null;
|
|
3080
|
+
return runQuery(read, name);
|
|
2423
3081
|
},
|
|
2424
3082
|
async listVersions(artifactId, input = {}) {
|
|
2425
3083
|
if (!await getReadable(artifactId))
|
|
@@ -2524,12 +3182,12 @@ async function sharedLinkGuest(runtime, delegation) {
|
|
|
2524
3182
|
if (!name) {
|
|
2525
3183
|
throw new ArtifactRequestError2("name_required", "[Sixb] A shared link's guest gives their name before they comment.");
|
|
2526
3184
|
}
|
|
2527
|
-
return { type: "guest", id: delegation.sessionId, name };
|
|
3185
|
+
return { type: "guest", id: delegation.sessionId, name, grantId: delegation.grantId };
|
|
2528
3186
|
}
|
|
2529
3187
|
function notFound3(artifactId) {
|
|
2530
3188
|
return new ArtifactRequestError2("artifact_not_found", `[Sixb] Artifact '${artifactId}' was not found.`);
|
|
2531
3189
|
}
|
|
2532
3190
|
|
|
2533
|
-
export { createAgentThreadAccessRule, assertConversationThread2, conversationThreadId2, agentThreadViews, announceArtifactUpdates, readLiveFiles2, storeLiveFiles2, sameArtifactFiles2, loadArtifactDocument2, readDocumentState2, firstArtifactDocument, withMergedWrite, undoneTurnDocuments, answerArtifactQueries2, parseArtifactQueryAnswers2, BOARD_PREVIEW_MEDIA_TYPES2, MAX_BOARD_PREVIEW_BYTES2, boardRenderKey, boardPreviewsOfCopy, boardsReadLiveData2, boardPreviews2, boardPreview2, missingBoardPreviews2, boardPreviewStatuses2, storeBoardPreviews2, publishArtifact2, prepareArtifactVersion2, storeArtifactVersion2, artifactVersionWarnings2, artifactAccessRule2, artifactTransactionRules, artifactQueryChecker2, artifactPreviewRequester, writeLiveArtifact2, createRuntimeArtifactAccessRule, transactionArtifactAccessRules, updatableArtifactIds, createArtifactsRuntime };
|
|
3191
|
+
export { createAgentThreadAccessRule, assertConversationThread2, conversationThreadId2, agentThreadViews, announceArtifactUpdates, readLiveFiles2, storeLiveFiles2, sameArtifactFiles2, keepsDocument2, loadArtifactDocument2, readDocumentState2, firstArtifactDocument, withMergedWrite, undoneTurnDocuments, answerArtifactQueries2, parseArtifactQueryAnswers2, BOARD_PREVIEW_MEDIA_TYPES2, MAX_BOARD_PREVIEW_BYTES2, boardRenderKey, boardPreviewsOfCopy, boardsReadLiveData2, boardPreviews2, boardPreview2, missingBoardPreviews2, boardPreviewStatuses2, storeBoardPreviews2, MAX_DOCUMENT_PDF_BYTES2, documentPdfKey2, publishArtifact2, prepareArtifactVersion2, storeArtifactVersion2, artifactVersionWarnings2, artifactAccessRule2, artifactTransactionRules, artifactQueryChecker2, artifactPreviewRequester, writeLiveArtifact2, createRuntimeArtifactAccessRule, transactionArtifactAccessRules, updatableArtifactIds, createArtifactsRuntime };
|
|
2534
3192
|
|
|
2535
|
-
//# debugId=
|
|
3193
|
+
//# debugId=9B02BA7B361316AF64756E2164756E21
|