dineway 0.1.49 → 0.2.1
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/activity-DUaz_w7p.mjs +79 -0
- package/dist/{activity-events-CwM7yxPW.mjs → activity-events-CJDvE2uc.mjs} +5 -113
- package/dist/actor-0QJ1Gbtf.mjs +37 -0
- package/dist/after-BfniwgIf.mjs +9 -0
- package/dist/{allowed-origins-CyGnbgBd.mjs → allowed-origins--OwHHiY8.mjs} +1 -1
- package/dist/api/route-utils.d.mts +9 -10
- package/dist/api/route-utils.mjs +16 -13
- package/dist/api/schemas/index.d.mts +2 -2
- package/dist/api/schemas/index.mjs +5 -4
- package/dist/{api-BMIxRIEN.mjs → api-B4PHIF4V.mjs} +93 -41
- package/dist/{api-tokens-DtvdtIkm.mjs → api-tokens-tbK_sORH.mjs} +6 -2
- package/dist/{apply-D_RlTYtC.mjs → apply-DjTqq6Ae.mjs} +117 -77
- package/dist/astro/image-endpoint.d.mts +7 -0
- package/dist/astro/image-endpoint.mjs +54 -0
- package/dist/astro/index.d.mts +34 -11
- package/dist/astro/index.mjs +163 -24
- package/dist/astro/integration/shims/use-sync-external-store-with-selector.js +71 -0
- package/dist/astro/integration/shims/use-sync-external-store.js +1 -0
- package/dist/astro/middleware/auth.d.mts +8 -18
- package/dist/astro/middleware/auth.mjs +42 -24
- package/dist/astro/middleware/redirect.mjs +13 -4
- package/dist/astro/middleware/request-context.mjs +8 -5
- package/dist/astro/middleware/seed.d.mts +1 -1
- package/dist/astro/middleware/seed.mjs +2 -2
- package/dist/astro/middleware/setup.mjs +1 -1
- package/dist/astro/middleware.mjs +389 -206
- package/dist/astro/routes/admin.astro +6 -1
- package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +7 -6
- package/dist/astro/routes/api/admin/allowed-domains/index.mjs +7 -6
- package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +4 -4
- package/dist/astro/routes/api/admin/api-tokens/index.mjs +6 -6
- package/dist/astro/routes/api/admin/briefing.mjs +21 -17
- package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +4 -4
- package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +9 -8
- package/dist/astro/routes/api/admin/byline-fields/index.mjs +9 -8
- package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +9 -8
- package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +17 -14
- package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +17 -14
- package/dist/astro/routes/api/admin/bylines/index.mjs +17 -14
- package/dist/astro/routes/api/admin/comments/_id_/status.mjs +14 -12
- package/dist/astro/routes/api/admin/comments/_id_.mjs +6 -5
- package/dist/astro/routes/api/admin/comments/bulk.mjs +11 -9
- package/dist/astro/routes/api/admin/comments/counts.mjs +6 -5
- package/dist/astro/routes/api/admin/comments/index.mjs +11 -9
- package/dist/astro/routes/api/admin/context/_id_/history.mjs +27 -24
- package/dist/astro/routes/api/admin/context/_id_/index.mjs +27 -24
- package/dist/astro/routes/api/admin/context/_id_/review.mjs +32 -28
- package/dist/astro/routes/api/admin/context/_id_/supersede.mjs +32 -28
- package/dist/astro/routes/api/admin/context/diff.mjs +31 -27
- package/dist/astro/routes/api/admin/context/index.mjs +32 -28
- package/dist/astro/routes/api/admin/context/stale.mjs +31 -27
- package/dist/astro/routes/api/admin/hitl-requests/_id_/index.mjs +27 -24
- package/dist/astro/routes/api/admin/hitl-requests/_id_/resolve.mjs +31 -27
- package/dist/astro/routes/api/admin/hitl-requests/index.mjs +31 -27
- package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +28 -25
- package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +3 -3
- package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +6 -6
- package/dist/astro/routes/api/admin/oauth-clients/index.mjs +6 -6
- package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +56 -51
- package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +56 -51
- package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +47 -43
- package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +54 -49
- package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +53 -48
- package/dist/astro/routes/api/admin/plugins/index.mjs +47 -43
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +2 -2
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +46 -42
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +53 -48
- package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +46 -42
- package/dist/astro/routes/api/admin/plugins/updates.mjs +46 -42
- package/dist/astro/routes/api/admin/review-requests/_id_/index.mjs +5 -5
- package/dist/astro/routes/api/admin/review-requests/_id_/resolve.mjs +32 -63
- package/dist/astro/routes/api/admin/review-requests/index.d.mts +2 -1
- package/dist/astro/routes/api/admin/review-requests/index.mjs +58 -10
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +46 -42
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +2 -2
- package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +46 -42
- package/dist/astro/routes/api/admin/users/_id_/disable.mjs +3 -3
- package/dist/astro/routes/api/admin/users/_id_/enable.mjs +2 -2
- package/dist/astro/routes/api/admin/users/_id_/index.mjs +8 -7
- package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +4 -4
- package/dist/astro/routes/api/admin/users/index.mjs +7 -6
- package/dist/astro/routes/api/auth/dev-bypass.mjs +4 -4
- package/dist/astro/routes/api/auth/invite/accept.mjs +2 -2
- package/dist/astro/routes/api/auth/invite/complete.mjs +12 -11
- package/dist/astro/routes/api/auth/invite/index.mjs +9 -8
- package/dist/astro/routes/api/auth/invite/register-options.mjs +11 -10
- package/dist/astro/routes/api/auth/logout.mjs +2 -2
- package/dist/astro/routes/api/auth/magic-link/send.mjs +11 -10
- package/dist/astro/routes/api/auth/magic-link/verify.mjs +3 -3
- package/dist/astro/routes/api/auth/me.mjs +9 -8
- package/dist/astro/routes/api/auth/mode.mjs +1 -1
- package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +3 -3
- package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
- package/dist/astro/routes/api/auth/passkey/_id_.mjs +6 -5
- package/dist/astro/routes/api/auth/passkey/index.mjs +1 -1
- package/dist/astro/routes/api/auth/passkey/options.mjs +12 -11
- package/dist/astro/routes/api/auth/passkey/register/options.mjs +10 -9
- package/dist/astro/routes/api/auth/passkey/register/verify.mjs +11 -10
- package/dist/astro/routes/api/auth/passkey/verify.mjs +11 -10
- package/dist/astro/routes/api/auth/setup-token/index.mjs +5 -5
- package/dist/astro/routes/api/auth/setup-token/verify.mjs +2 -2
- package/dist/astro/routes/api/auth/signup/complete.mjs +12 -11
- package/dist/astro/routes/api/auth/signup/request.mjs +11 -10
- package/dist/astro/routes/api/auth/signup/verify.mjs +2 -2
- package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +15 -13
- package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.d.mts +8 -0
- package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +160 -0
- package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +6 -5
- package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +6 -5
- package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +6 -5
- package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +11 -10
- package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +49 -20
- package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +6 -5
- package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +67 -32
- package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +16 -14
- package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +6 -5
- package/dist/astro/routes/api/content/_collection_/_id_.mjs +11 -9
- package/dist/astro/routes/api/content/_collection_/authors.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/index.mjs +11 -9
- package/dist/astro/routes/api/content/_collection_/trash.mjs +7 -6
- package/dist/astro/routes/api/dashboard.mjs +9 -8
- package/dist/astro/routes/api/dev/emails.mjs +2 -2
- package/dist/astro/routes/api/health.mjs +1 -1
- package/dist/astro/routes/api/import/probe.d.mts +3 -3
- package/dist/astro/routes/api/import/probe.mjs +22 -10
- package/dist/astro/routes/api/import/wordpress/analyze.mjs +9 -6
- package/dist/astro/routes/api/import/wordpress/execute.d.mts +18 -1
- package/dist/astro/routes/api/import/wordpress/execute.mjs +85 -37
- package/dist/astro/routes/api/import/wordpress/media.d.mts +12 -1
- package/dist/astro/routes/api/import/wordpress/media.mjs +20 -14
- package/dist/astro/routes/api/import/wordpress/prepare.mjs +36 -32
- package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +17 -1
- package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +121 -100
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +24 -12
- package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +55 -2
- package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +284 -55
- package/dist/astro/routes/api/manifest.mjs +14 -5
- package/dist/astro/routes/api/mcp.mjs +753 -170
- package/dist/astro/routes/api/media/_id_/confirm.mjs +38 -10
- package/dist/astro/routes/api/media/_id_.mjs +11 -7
- package/dist/astro/routes/api/media/file/_...key_.mjs +1 -1
- package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +2 -2
- package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +2 -2
- package/dist/astro/routes/api/media/providers/index.mjs +2 -2
- package/dist/astro/routes/api/media/upload-url.mjs +11 -10
- package/dist/astro/routes/api/media.mjs +28 -35
- package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +32 -28
- package/dist/astro/routes/api/menus/_name_/items.mjs +32 -28
- package/dist/astro/routes/api/menus/_name_/reorder.mjs +32 -28
- package/dist/astro/routes/api/menus/_name_/translations.mjs +32 -28
- package/dist/astro/routes/api/menus/_name_.mjs +32 -28
- package/dist/astro/routes/api/menus/index.mjs +32 -28
- package/dist/astro/routes/api/oauth/authorize.mjs +7 -7
- package/dist/astro/routes/api/oauth/device/authorize.mjs +6 -6
- package/dist/astro/routes/api/oauth/device/code.mjs +9 -9
- package/dist/astro/routes/api/oauth/device/token.mjs +8 -8
- package/dist/astro/routes/api/oauth/register.mjs +4 -4
- package/dist/astro/routes/api/oauth/token/refresh.mjs +6 -6
- package/dist/astro/routes/api/oauth/token/revoke.mjs +6 -6
- package/dist/astro/routes/api/oauth/token.mjs +6 -6
- package/dist/astro/routes/api/openapi.json.mjs +4 -3
- package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +46 -31
- package/dist/astro/routes/api/redirects/404s/index.mjs +11 -10
- package/dist/astro/routes/api/redirects/404s/summary.mjs +11 -10
- package/dist/astro/routes/api/redirects/_id_.mjs +33 -29
- package/dist/astro/routes/api/redirects/index.mjs +33 -29
- package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +2 -2
- package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +2 -2
- package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +48 -43
- package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +48 -43
- package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +48 -43
- package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +48 -43
- package/dist/astro/routes/api/schema/collections/index.mjs +48 -43
- package/dist/astro/routes/api/schema/index.mjs +14 -15
- package/dist/astro/routes/api/schema/orphans/_slug_.mjs +46 -42
- package/dist/astro/routes/api/schema/orphans/index.mjs +46 -42
- package/dist/astro/routes/api/search/enable.mjs +11 -10
- package/dist/astro/routes/api/search/index.mjs +10 -9
- package/dist/astro/routes/api/search/rebuild.mjs +11 -10
- package/dist/astro/routes/api/search/stats.mjs +6 -6
- package/dist/astro/routes/api/search/suggest.mjs +10 -9
- package/dist/astro/routes/api/sections/_slug_.mjs +32 -28
- package/dist/astro/routes/api/sections/index.mjs +32 -28
- package/dist/astro/routes/api/settings/email.mjs +4 -4
- package/dist/astro/routes/api/settings.mjs +32 -28
- package/dist/astro/routes/api/setup/admin-verify.mjs +14 -13
- package/dist/astro/routes/api/setup/admin.mjs +12 -11
- package/dist/astro/routes/api/setup/dev-bypass.mjs +31 -25
- package/dist/astro/routes/api/setup/dev-reset.mjs +2 -2
- package/dist/astro/routes/api/setup/index.mjs +29 -25
- package/dist/astro/routes/api/setup/status.mjs +3 -3
- package/dist/astro/routes/api/snapshot.mjs +8 -7
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +35 -31
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +35 -31
- package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +35 -31
- package/dist/astro/routes/api/taxonomies/index.mjs +35 -31
- package/dist/astro/routes/api/themes/preview.mjs +5 -5
- package/dist/astro/routes/api/typegen.mjs +4 -4
- package/dist/astro/routes/api/well-known/auth.mjs +3 -3
- package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +3 -3
- package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +3 -3
- package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +31 -27
- package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +32 -28
- package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +32 -28
- package/dist/astro/routes/api/widget-areas/_name_.mjs +29 -26
- package/dist/astro/routes/api/widget-areas/index.mjs +32 -28
- package/dist/astro/routes/api/widget-components.mjs +2 -2
- package/dist/astro/routes/robots.txt.mjs +8 -7
- package/dist/astro/routes/sitemap-_collection_.xml.mjs +23 -14
- package/dist/astro/routes/sitemap.xml.mjs +9 -8
- package/dist/astro/session-driver.d.mts +1 -1
- package/dist/astro/session-driver.mjs +2 -2
- package/dist/astro/types.d.mts +22 -13
- package/dist/{audit-BeNsSyfU.mjs → audit-B2pRxZ20.mjs} +1 -1
- package/dist/auth/providers/github.d.mts +1 -1
- package/dist/auth/providers/google.d.mts +1 -1
- package/dist/{auth-control-guard-Dr14I98m.mjs → auth-control-guard-D71jourk.mjs} +1 -1
- package/dist/{authorize-BLO0m7fW.mjs → authorize-ZXPGPwKn.mjs} +1 -1
- package/dist/{briefing-CkTee1ex.mjs → briefing-0rf-su3-.mjs} +90 -28
- package/dist/{briefing-DJX6irto.mjs → briefing-kRhegBoF.mjs} +2 -1
- package/dist/bundle-CEcdUa1s.mjs +602 -0
- package/dist/{byline-BVC1lV6G.mjs → byline-7xR185Ly.mjs} +30 -62
- package/dist/{byline-fields-Cj39WhXC.mjs → byline-fields-BKzA0fJU.mjs} +1 -1
- package/dist/{byline-fields-uJlygdzM.d.mts → byline-fields-Ckeqd1OY.d.mts} +88 -35
- package/dist/{byline-fields-cNrLJVRs.mjs → byline-fields-WN7RQT4q.mjs} +10 -4
- package/dist/{byline-registry-4v6tXMNX.mjs → byline-registry-Ba54M74c.mjs} +2 -2
- package/dist/{bylines-LN9XISRo.mjs → bylines-C-EL6dh3.mjs} +9 -3
- package/dist/{bylines-DwokOFj6.mjs → bylines-CmZFCMr0.mjs} +5 -5
- package/dist/{cache-Bac05gBd.mjs → cache-DkVCKGio.mjs} +2 -2
- package/dist/{chunks-CuUt7K50.mjs → chunks-ChGNDY8r.mjs} +1 -1
- package/dist/cli/index.d.mts +29 -1
- package/dist/cli/index.mjs +1466 -1763
- package/dist/cli/plugin-kit.d.mts +75 -0
- package/dist/cli/plugin-kit.mjs +4 -0
- package/dist/client/external-auth-headers.d.mts +1 -1
- package/dist/client/index.d.mts +27 -52
- package/dist/client/index.mjs +34 -6
- package/dist/client-factory-BDD9azPJ.mjs +233 -0
- package/dist/{comment-Beue8-15.mjs → comment-DFALgsJD.mjs} +13 -3
- package/dist/comment-reaction-C37bf99u.mjs +58 -0
- package/dist/{comments-DcjFIfqX.mjs → comments-B3NwDBxl.mjs} +1 -1
- package/dist/{content-CBxYGWfL.mjs → content-DJcAYFhz.mjs} +51 -34
- package/dist/content-refresh-B4ZCmxgd.mjs +1576 -0
- package/dist/{context-Df1xVYyr.mjs → context-DnpXcp6Y.mjs} +2 -2
- package/dist/{context-CQVNZaR8.mjs → context-fSCYLL3c.mjs} +125 -53
- package/dist/{context-route-helpers-B9wj8Rmh.mjs → context-route-helpers-CI8XzcsK.mjs} +2 -1
- package/dist/{cron-DxCAU_Sn.mjs → cron-B1SL_lsb.mjs} +7 -3
- package/dist/{dashboard-B7ZUNuyF.mjs → dashboard-D0nj5oWg.mjs} +4 -4
- package/dist/db/index.d.mts +3 -3
- package/dist/db/index.mjs +1 -1
- package/dist/db/libsql.d.mts +1 -1
- package/dist/db/postgres.d.mts +1 -1
- package/dist/db/sqlite.d.mts +1 -1
- package/dist/{device-flow-BZVGftqi.mjs → device-flow-BJe6VEhP.mjs} +5 -5
- package/dist/{placeholder-d54Qr_7n.mjs → enrich-Ck9tfMqe.mjs} +36 -9
- package/dist/{error-DCSuUAZW.mjs → error-CSVaQNZy.mjs} +5 -0
- package/dist/{experimental-workflows-CSMffP6q.mjs → experimental-workflows-GVhUgzEs.mjs} +1 -1
- package/dist/field-defs-cache-DL-T2XVS.mjs +49 -0
- package/dist/forgeway-seo-client-G5ddhVHd.mjs +456 -0
- package/dist/{fts-manager-B5l_qwrA.mjs → fts-manager-ewTGohf4.mjs} +1 -1
- package/dist/{hitl-requests-7NlzVeUA.mjs → hitl-requests-DEFj8e6u.mjs} +2 -2
- package/dist/{hitl-route-helpers-k---_H3-.mjs → hitl-route-helpers-C23JHaWz.mjs} +5 -4
- package/dist/import-CXXL5pip.mjs +1354 -0
- package/dist/index-DcnOCD1e.d.mts +375 -0
- package/dist/index.d.mts +15 -16
- package/dist/index.mjs +85 -70
- package/dist/{jsonld-DZ67souc.d.mts → jsonld-DzKbhRZ4.d.mts} +8 -4
- package/dist/{load-D9OiGr2m.mjs → load-CFtJRT3c.mjs} +1 -1
- package/dist/{loader--GOYux8M.mjs → loader-aWkkc1_o.mjs} +117 -31
- package/dist/{manifest-schema-qh2P7RDX.mjs → manifest-schema-uA6pRFXi.mjs} +38 -1
- package/dist/mcp-reviewed-executor-Dn52L_yY.mjs +558 -0
- package/dist/media/image-endpoint.d.mts +32 -0
- package/dist/media/image-endpoint.mjs +111 -0
- package/dist/media/index.d.mts +27 -2
- package/dist/media/index.mjs +5 -3
- package/dist/media/local-runtime.d.mts +15 -11
- package/dist/media/local-runtime.mjs +9 -7
- package/dist/{media-CbKyYukG.mjs → media-CVMOoywq.mjs} +3 -1
- package/dist/{media-allowlist-BYxJIcTO.mjs → media-allowlist-zDNJmXCo.mjs} +1 -1
- package/dist/media-url-BdoLPvg8.mjs +20 -0
- package/dist/{menus-C7F0sCrC.mjs → menus-CCG2z5um.mjs} +80 -15
- package/dist/{menus-BZbXf-ej.mjs → menus-CmyIkRG5.mjs} +19 -5
- package/dist/{normalize-ByemhhfW.mjs → normalize-Cyt7JdF7.mjs} +8 -1
- package/dist/{oauth-authorization-DF-LCsIA.mjs → oauth-authorization-B9H7X85L.mjs} +5 -5
- package/dist/{oauth-clients-Du-V0fEm.mjs → oauth-clients-Dwl32-Uj.mjs} +2 -2
- package/dist/object-cache/memory.d.mts +14 -0
- package/dist/object-cache/memory.mjs +55 -0
- package/dist/object-cache-D51qOseS.mjs +419 -0
- package/dist/output-DhBe5_Pi.mjs +68 -0
- package/dist/page/index.d.mts +10 -3
- package/dist/page/index.mjs +2 -2
- package/dist/{parse-CneSgl7-.mjs → parse-i15EFSAE.mjs} +1 -1
- package/dist/{parser-DxfsARXL.mjs → parser-06LLLL4E.mjs} +151 -9
- package/dist/{placeholder-CXfoCtCd.d.mts → placeholder-DkWkXfDI.d.mts} +12 -4
- package/dist/plugin-utils.d.mts +8 -9
- package/dist/plugins/adapt-sandbox-entry.d.mts +8 -9
- package/dist/plugins/adapt-sandbox-entry.mjs +13 -2
- package/dist/{plugins-DzfqRREq.mjs → plugins-CPA2PtfY.mjs} +919 -66
- package/dist/{transport-LSdZVXHF.mjs → portable-text-BASHceim.mjs} +1 -134
- package/dist/portable-text-E79LyjGo.d.mts +45 -0
- package/dist/{preview-C-3YTX2U.mjs → preview-BjedZm8G.mjs} +4 -3
- package/dist/process-cache-CCDgti7j.mjs +106 -0
- package/dist/project-env-DKibmuP8.mjs +95 -0
- package/dist/{provider-loader-9it4vd6L.d.mts → provider-loader-DC2JdWeO.d.mts} +1 -1
- package/dist/{public-url-B4xV4rGa.d.mts → public-url-DQJCnYi9.d.mts} +1 -1
- package/dist/publication-authorization-RKiHXKtq.mjs +985 -0
- package/dist/{query-CZ3TH_Uu.mjs → query-C2U5u5_p.mjs} +11 -6
- package/dist/{query-Ds0EnMFX.mjs → query-DEv5x6yB.mjs} +281 -76
- package/dist/{rate-limit-i0G3IAOX.mjs → rate-limit-DglsAJSw.mjs} +2 -2
- package/dist/{redirect-CEACczxo.mjs → redirect-ubhEqQCQ.mjs} +2 -2
- package/dist/{redirects-ocRJmQHP.mjs → redirects-Bhpm8bRe.mjs} +35 -19
- package/dist/{redirects-DYj1yPxs.mjs → redirects-xs2yahLq.mjs} +47 -24
- package/dist/{registry-D7HACema.mjs → registry-BYYyb2tF.mjs} +148 -81
- package/dist/request-context.d.mts +2 -0
- package/dist/{request-meta-DAb6xaP9.mjs → request-meta-CFe1tW2M.mjs} +1 -1
- package/dist/review-payload-BysRWpxS.mjs +111 -0
- package/dist/{review-requests-BW2NxY-l.mjs → review-requests-CTWGnWUt.mjs} +1 -1
- package/dist/review-requests-D42VEP1l.mjs +142 -0
- package/dist/review-route-helpers-C31vO6SI.mjs +41 -0
- package/dist/runner-BgmttQmD.mjs +7444 -0
- package/dist/{runner-09sTqtv0.d.mts → runner-D6hzs8L9.d.mts} +1 -1
- package/dist/runtime.d.mts +9 -10
- package/dist/runtime.mjs +3 -3
- package/dist/schema-DUtnZxjZ.mjs +8 -0
- package/dist/{search-Gdrqj582.mjs → search-DUKgZUlm.mjs} +5 -3
- package/dist/{secrets-CeGpBFV2.mjs → secrets-ZV5rd8yV.mjs} +14 -11
- package/dist/{sections-BOjU13Y-.mjs → sections-DvFgsnda.mjs} +2 -2
- package/dist/seed/index.d.mts +2 -2
- package/dist/seed/index.mjs +21 -18
- package/dist/seo/index.d.mts +1 -1
- package/dist/seo/index.mjs +3 -12
- package/dist/{seo-5lJOtB5J.mjs → seo-BLszyJxd.mjs} +22 -4
- package/dist/{seo-CLj8lS7Q.mjs → seo-BU8MLCS9.mjs} +5 -2
- package/dist/{seo-contributions-CqVvReEj.mjs → seo-contributions-GnCuL1ML.mjs} +11 -3
- package/dist/{service-jGlhrICs.mjs → service-FL3fB0Rx.mjs} +2 -2
- package/dist/session-user-Ct6GBLvn.mjs +22 -0
- package/dist/{settings-CUXOxzsT.mjs → settings-BECcAIRH.mjs} +28 -55
- package/dist/{settings-DlBsT2VS.mjs → settings-EzADu-dd.mjs} +2 -2
- package/dist/{setup-complete-BRrdPYjZ.mjs → setup-complete-Da0axZEE.mjs} +1 -1
- package/dist/{site-activity-DONFrMBJ.mjs → site-activity-h8smOlYI.mjs} +1 -1
- package/dist/{site-context-C8Az_P_I.mjs → site-context-B8T1kpUP.mjs} +337 -530
- package/dist/{site-url-DIMD68go.mjs → site-url-DJEid0ml.mjs} +1 -1
- package/dist/stable-hash-DshcXvRE.mjs +19 -0
- package/dist/status-NqWOSFAD.mjs +21 -0
- package/dist/storage/local.d.mts +1 -1
- package/dist/storage/local.mjs +1 -1
- package/dist/storage/s3.d.mts +1 -1
- package/dist/storage/s3.mjs +1 -1
- package/dist/{taxonomies-D9Sw4wWM.mjs → taxonomies-BiM9NtgW.mjs} +36 -29
- package/dist/taxonomies-DSnY5nOa.mjs +443 -0
- package/dist/{taxonomy-B169Nm6B.mjs → taxonomy-0k_vRVsD.mjs} +44 -9
- package/dist/transport-C46KHLMP.mjs +134 -0
- package/dist/types-A8fPOJnl.mjs +69 -0
- package/dist/types-BLQCz46p.d.mts +118 -0
- package/dist/{types-CwawBUTa.d.mts → types-B_FlxIIl.d.mts} +4 -1
- package/dist/{types-CSgR9nQB.mjs → types-ChxYDRvx.mjs} +1 -1
- package/dist/{types-GaCtZ1k9.d.mts → types-Cw0PeCT_.d.mts} +18 -0
- package/dist/types-DuQn1G7-.d.mts +2973 -0
- package/dist/{runtime-C4-2lSFg.d.mts → types-DwoUifGE.d.mts} +5668 -3000
- package/dist/{types-DRIKLmJI.d.mts → types-opjX_kz6.d.mts} +17 -2
- package/dist/ui/server-runtime.d.mts +13 -15
- package/dist/ui/server-runtime.mjs +24 -20
- package/dist/url-guoXQQcV.mjs +33 -0
- package/dist/{user-DTLoZs16.mjs → user-BH-n01y3.mjs} +2 -2
- package/dist/{utils-B8hBJ9Oz.mjs → utils-D1SrKGtP.mjs} +129 -7
- package/dist/{validate-DzjCdy6v.d.mts → validate-CbVFoJgc.d.mts} +65 -8
- package/dist/{validate-DWmPO6oj.mjs → validate-D1HL-oLR.mjs} +11 -6
- package/dist/version-C3iVRuaF.mjs +6 -0
- package/dist/{widgets-BpJ8EpPd.mjs → widgets-BZrLrNgS.mjs} +46 -43
- package/dist/{wordpress-slugs-DHNR9LpG.mjs → wordpress-slugs-C3PWcowq.mjs} +1 -1
- package/dist/{zod-generator-K91-g665.mjs → zod-generator-C7AsLpSB.mjs} +42 -14
- package/package.json +38 -8
- package/src/components/Block.astro +50 -0
- package/src/components/Comments.astro +143 -1
- package/src/components/DinewayHead.astro +19 -2
- package/src/components/DinewayImage.astro +66 -33
- package/src/components/DinewayMedia.astro +1 -2
- package/src/components/Image.astro +85 -40
- package/src/components/InlinePortableTextEditor.tsx +12 -2
- package/src/components/JsonLdScript.astro +9 -0
- package/src/components/LiveSearch.astro +40 -4
- package/src/components/index.ts +4 -0
- package/src/components/live-search-routing.ts +30 -0
- package/src/components/portable-text-text-align.ts +15 -0
- package/src/ui.ts +2 -0
- package/dist/entity-aliases-4y93Yjuc.mjs +0 -51
- package/dist/import-4YBXbDkI.mjs +0 -684
- package/dist/index-CZiWCQDp.d.mts +0 -227
- package/dist/review-requests-Qum4713s.mjs +0 -79
- package/dist/runner-DzIpHGND.mjs +0 -2836
- package/dist/schema-Bsi-VpYv.mjs +0 -8
- package/dist/taxonomies-CZ-_DitR.mjs +0 -327
- package/dist/types-CuJOqHfM.d.mts +0 -758
- package/dist/types-DSPGWjxO.d.mts +0 -1247
- package/dist/types-nP9vGUFq.d.mts +0 -56
- package/dist/version-C4gfn0PJ.mjs +0 -6
- /package/dist/{adapters-OQCImOL7.d.mts → adapters-BiRymx02.d.mts} +0 -0
- /package/dist/{api-tokens-CYUoFGo7.mjs → api-tokens-Ypaly90d.mjs} +0 -0
- /package/dist/{challenge-store-DFxX0_15.mjs → challenge-store-D5pSY2S1.mjs} +0 -0
- /package/dist/{components--pg6zBvu.mjs → components-DImzlLhb.mjs} +0 -0
- /package/dist/{context-types-r8oFvyOq.mjs → context-types-eBuMDAg-.mjs} +0 -0
- /package/dist/{default-B6iaLvP7.mjs → default-D4Vygcy_.mjs} +0 -0
- /package/dist/{email-console-BOVqIYpB.mjs → email-console-Bp0r68iF.mjs} +0 -0
- /package/dist/{escape-BDgouFFY.mjs → escape-DN4Qmjsl.mjs} +0 -0
- /package/dist/{hash-BPmX6P8I.mjs → hash-mxxx2oPW.mjs} +0 -0
- /package/dist/{mime-CbKsKDCB.mjs → mime-C0vOHFm7.mjs} +0 -0
- /package/dist/{mode-CZqCF9dZ.mjs → mode-C8yZnIlR.mjs} +0 -0
- /package/dist/{oauth-state-store-qncPB_IU.mjs → oauth-state-store-CndT35iw.mjs} +0 -0
- /package/dist/{oauth-user-lookup-BFjWF8wK.mjs → oauth-user-lookup-CMehAaKs.mjs} +0 -0
- /package/dist/{options-LsPjZlqD.mjs → options-DQPTH5n0.mjs} +0 -0
- /package/dist/{passkey-config-DzHQK90v.mjs → passkey-config-NYukYGed.mjs} +0 -0
- /package/dist/{patterns-DKAX6oqN.mjs → patterns-CoqlXUvk.mjs} +0 -0
- /package/dist/{provider-loader-DzUxejk7.mjs → provider-loader-BtfrrzfD.mjs} +0 -0
- /package/dist/{public-url-B_m9IwdV.mjs → public-url-Cp6hyjVR.mjs} +0 -0
- /package/dist/{redirect-BjIBtDWY.mjs → redirect-DrbEmU9a.mjs} +0 -0
- /package/dist/{request-cache-ho99schz.mjs → request-cache-CBFjCwSt.mjs} +0 -0
- /package/dist/{resolve-DTuDyYKs.mjs → resolve-DE71WcL9.mjs} +0 -0
- /package/dist/{setup-nonce-pyGfc9hV.mjs → setup-nonce-BtkKnvxQ.mjs} +0 -0
- /package/dist/{sidecar-client-mJxwayYN.mjs → sidecar-client-Ctzfyyp-.mjs} +0 -0
- /package/dist/{slugify-BqebcqBg.mjs → slugify-KSsVD_D3.mjs} +0 -0
- /package/dist/{ssrf-DiKqWd3N.mjs → ssrf-FJqwQzj4.mjs} +0 -0
- /package/dist/{tokens-SLmgowfd.mjs → tokens-BDQU29Vd.mjs} +0 -0
- /package/dist/{transaction-CFLhEOuH.mjs → transaction-0LEAAy8R.mjs} +0 -0
- /package/dist/{transport-BnsNxh2l.d.mts → transport-D9pKAzFP.d.mts} +0 -0
- /package/dist/{trusted-proxy-BgIIcbsN.mjs → trusted-proxy-Dm7Mxvt6.mjs} +0 -0
- /package/dist/{types-CJ8DkL0q.mjs → types-B7TDDFMG.mjs} +0 -0
- /package/dist/{types-Dryvv7LH.d.mts → types-g0zMtraY.d.mts} +0 -0
- /package/dist/{types-Cg276-3z.mjs → types-mVVgRPaU.mjs} +0 -0
- /package/dist/{types-DZpT-PnG.d.mts → types-wFu80FrO.d.mts} +0 -0
- /package/dist/{url-w7Mp5qAD.mjs → url-EMAguGVk.mjs} +0 -0
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { t as validateIdentifier } from "./validate-VPnKoIzW.mjs";
|
|
2
|
-
import { i as encodeCursor, r as decodeCursor } from "./types-
|
|
3
|
-
import { t as ContentRepository } from "./content-
|
|
4
|
-
import { t as SiteActivityRepository } from "./site-activity-
|
|
5
|
-
import { t as ReviewRequestRepository } from "./review-requests-
|
|
6
|
-
import {
|
|
7
|
-
import { r as isPattern } from "./patterns-
|
|
8
|
-
import { a as ContextRepository, i as parseSiteBriefingScope, l as handlePluginList } from "./briefing-
|
|
9
|
-
import { t as FTSManager } from "./fts-manager-
|
|
10
|
-
import { n as SchemaRegistry } from "./registry-
|
|
11
|
-
import { a as getSiteSettingsWithDb } from "./settings-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
2
|
+
import { i as encodeCursor, r as decodeCursor } from "./types-ChxYDRvx.mjs";
|
|
3
|
+
import { t as ContentRepository } from "./content-DJcAYFhz.mjs";
|
|
4
|
+
import { t as SiteActivityRepository } from "./site-activity-h8smOlYI.mjs";
|
|
5
|
+
import { t as ReviewRequestRepository } from "./review-requests-CTWGnWUt.mjs";
|
|
6
|
+
import { o as HitlRequestRepository } from "./publication-authorization-RKiHXKtq.mjs";
|
|
7
|
+
import { r as isPattern } from "./patterns-CoqlXUvk.mjs";
|
|
8
|
+
import { a as ContextRepository, i as parseSiteBriefingScope, l as handlePluginList } from "./briefing-0rf-su3-.mjs";
|
|
9
|
+
import { t as FTSManager } from "./fts-manager-ewTGohf4.mjs";
|
|
10
|
+
import { n as SchemaRegistry } from "./registry-BYYyb2tF.mjs";
|
|
11
|
+
import { a as getSiteSettingsWithDb } from "./settings-BECcAIRH.mjs";
|
|
12
|
+
import { n as buildStableActionHash, t as ReviewPayloadBuilder } from "./review-payload-BysRWpxS.mjs";
|
|
13
|
+
import { n as assertExperimentalSiteContextWorkflowsEnabled } from "./experimental-workflows-GVhUgzEs.mjs";
|
|
14
|
+
import { m as normalizeUrl } from "./utils-D1SrKGtP.mjs";
|
|
15
|
+
import { t as sanitizeWordPressImportSlug } from "./wordpress-slugs-C3PWcowq.mjs";
|
|
16
|
+
import { s as searchCollection } from "./search-DUKgZUlm.mjs";
|
|
16
17
|
import { sql } from "kysely";
|
|
17
18
|
import { ulid } from "ulidx";
|
|
18
19
|
import { Role } from "@dineway-ai/auth";
|
|
@@ -30,7 +31,8 @@ const ASSIGNMENT_STATUSES = [
|
|
|
30
31
|
"blocked",
|
|
31
32
|
"completed",
|
|
32
33
|
"declined",
|
|
33
|
-
"cancelled"
|
|
34
|
+
"cancelled",
|
|
35
|
+
"overdue"
|
|
34
36
|
];
|
|
35
37
|
const ASSIGNMENT_PRIORITIES = [
|
|
36
38
|
"low",
|
|
@@ -55,7 +57,7 @@ var AssignmentRepository = class {
|
|
|
55
57
|
return row ? rowToAssignment(row) : null;
|
|
56
58
|
}
|
|
57
59
|
async list(query = {}) {
|
|
58
|
-
const limit = clampLimit$
|
|
60
|
+
const limit = clampLimit$2(query.limit);
|
|
59
61
|
const rows = await this.queryRows(query).execute();
|
|
60
62
|
const items = rows.slice(0, limit).map(rowToAssignment);
|
|
61
63
|
const result = { items };
|
|
@@ -73,7 +75,7 @@ var AssignmentRepository = class {
|
|
|
73
75
|
assigned_to_actor_id: input.assignedToActorId ?? null,
|
|
74
76
|
accepted_at: value,
|
|
75
77
|
updated_at: value,
|
|
76
|
-
metadata: jsonString
|
|
78
|
+
metadata: jsonString(input.metadata)
|
|
77
79
|
});
|
|
78
80
|
}
|
|
79
81
|
async start(id, input = {}) {
|
|
@@ -82,7 +84,7 @@ var AssignmentRepository = class {
|
|
|
82
84
|
status: "in_progress",
|
|
83
85
|
started_at: value,
|
|
84
86
|
updated_at: value,
|
|
85
|
-
metadata: jsonString
|
|
87
|
+
metadata: jsonString(input.metadata)
|
|
86
88
|
});
|
|
87
89
|
}
|
|
88
90
|
async block(id, input = {}) {
|
|
@@ -91,7 +93,7 @@ var AssignmentRepository = class {
|
|
|
91
93
|
status: "blocked",
|
|
92
94
|
blocked_at: value,
|
|
93
95
|
updated_at: value,
|
|
94
|
-
metadata: jsonString
|
|
96
|
+
metadata: jsonString(input.metadata)
|
|
95
97
|
});
|
|
96
98
|
}
|
|
97
99
|
async complete(id, input = {}) {
|
|
@@ -104,7 +106,7 @@ var AssignmentRepository = class {
|
|
|
104
106
|
status: "completed",
|
|
105
107
|
completed_at: value,
|
|
106
108
|
updated_at: value,
|
|
107
|
-
metadata: jsonString
|
|
109
|
+
metadata: jsonString(input.metadata)
|
|
108
110
|
});
|
|
109
111
|
}
|
|
110
112
|
async decline(id, input = {}) {
|
|
@@ -113,7 +115,7 @@ var AssignmentRepository = class {
|
|
|
113
115
|
status: "declined",
|
|
114
116
|
declined_at: value,
|
|
115
117
|
updated_at: value,
|
|
116
|
-
metadata: jsonString
|
|
118
|
+
metadata: jsonString(input.metadata)
|
|
117
119
|
});
|
|
118
120
|
}
|
|
119
121
|
async cancel(id, input = {}) {
|
|
@@ -127,9 +129,36 @@ var AssignmentRepository = class {
|
|
|
127
129
|
status: "cancelled",
|
|
128
130
|
cancelled_at: value,
|
|
129
131
|
updated_at: value,
|
|
130
|
-
metadata: jsonString
|
|
132
|
+
metadata: jsonString(input.metadata)
|
|
131
133
|
});
|
|
132
134
|
}
|
|
135
|
+
async markOverdueBefore(input) {
|
|
136
|
+
const limit = clampLimit$2(input.limit);
|
|
137
|
+
let query = this.db.selectFrom("_dineway_assignments").select("id").where("status", "in", [
|
|
138
|
+
"pending",
|
|
139
|
+
"accepted",
|
|
140
|
+
"in_progress",
|
|
141
|
+
"blocked"
|
|
142
|
+
]).where("due_at", "is not", null).where("due_at", "<=", input.before).orderBy("due_at", "asc").orderBy("id", "asc").limit(limit);
|
|
143
|
+
if (input.assignmentType) query = query.where("assignment_type", "=", input.assignmentType);
|
|
144
|
+
const candidates = await query.execute();
|
|
145
|
+
const at = input.at ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
146
|
+
const overdue = [];
|
|
147
|
+
for (const candidate of candidates) {
|
|
148
|
+
const updated = await this.transition(candidate.id, [
|
|
149
|
+
"pending",
|
|
150
|
+
"accepted",
|
|
151
|
+
"in_progress",
|
|
152
|
+
"blocked"
|
|
153
|
+
], {
|
|
154
|
+
status: "overdue",
|
|
155
|
+
overdue_at: at,
|
|
156
|
+
updated_at: at
|
|
157
|
+
});
|
|
158
|
+
if (updated) overdue.push(updated);
|
|
159
|
+
}
|
|
160
|
+
return overdue;
|
|
161
|
+
}
|
|
133
162
|
async linkHitlRequest(id, relatedHitlRequestId, at = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
134
163
|
const result = await this.db.updateTable("_dineway_assignments").set({
|
|
135
164
|
related_hitl_request_id: relatedHitlRequestId,
|
|
@@ -138,8 +167,16 @@ var AssignmentRepository = class {
|
|
|
138
167
|
if (Number(result.numUpdatedRows ?? 0) === 0) return null;
|
|
139
168
|
return this.findById(id);
|
|
140
169
|
}
|
|
170
|
+
async linkHandoffSnapshot(id, relatedHandoffSnapshotId, at = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
171
|
+
const result = await this.db.updateTable("_dineway_assignments").set({
|
|
172
|
+
related_handoff_snapshot_id: relatedHandoffSnapshotId,
|
|
173
|
+
updated_at: at
|
|
174
|
+
}).where("id", "=", id).executeTakeFirst();
|
|
175
|
+
if (Number(result.numUpdatedRows ?? 0) === 0) return null;
|
|
176
|
+
return this.findById(id);
|
|
177
|
+
}
|
|
141
178
|
queryRows(query) {
|
|
142
|
-
const limit = clampLimit$
|
|
179
|
+
const limit = clampLimit$2(query.limit);
|
|
143
180
|
let q = this.db.selectFrom("_dineway_assignments").selectAll().orderBy("created_at", "desc").orderBy("id", "desc").limit(limit + 1);
|
|
144
181
|
if (query.scope) q = q.where("scope", "=", query.scope);
|
|
145
182
|
if (query.scopes && query.scopes.length > 0) q = q.where("scope", "in", query.scopes);
|
|
@@ -176,7 +213,7 @@ function toInsertableAssignment(id, input, now) {
|
|
|
176
213
|
assigned_by_actor_id: input.assignedByActorId,
|
|
177
214
|
assigned_to_actor_type: input.assignedToActorType ?? null,
|
|
178
215
|
assigned_to_actor_id: input.assignedToActorId ?? null,
|
|
179
|
-
metadata: jsonString
|
|
216
|
+
metadata: jsonString(input.metadata),
|
|
180
217
|
related_handoff_snapshot_id: input.relatedHandoffSnapshotId ?? null,
|
|
181
218
|
related_hitl_request_id: input.relatedHitlRequestId ?? null,
|
|
182
219
|
due_at: input.dueAt ?? null,
|
|
@@ -187,7 +224,8 @@ function toInsertableAssignment(id, input, now) {
|
|
|
187
224
|
blocked_at: null,
|
|
188
225
|
completed_at: null,
|
|
189
226
|
declined_at: null,
|
|
190
|
-
cancelled_at: null
|
|
227
|
+
cancelled_at: null,
|
|
228
|
+
overdue_at: null
|
|
191
229
|
};
|
|
192
230
|
}
|
|
193
231
|
function rowToAssignment(row) {
|
|
@@ -204,7 +242,7 @@ function rowToAssignment(row) {
|
|
|
204
242
|
assignedByActorId: row.assigned_by_actor_id,
|
|
205
243
|
assignedToActorType: row.assigned_to_actor_type,
|
|
206
244
|
assignedToActorId: row.assigned_to_actor_id,
|
|
207
|
-
metadata: parseRecord$
|
|
245
|
+
metadata: parseRecord$1(row.metadata),
|
|
208
246
|
relatedHandoffSnapshotId: row.related_handoff_snapshot_id,
|
|
209
247
|
relatedHitlRequestId: row.related_hitl_request_id,
|
|
210
248
|
dueAt: row.due_at,
|
|
@@ -215,187 +253,299 @@ function rowToAssignment(row) {
|
|
|
215
253
|
blockedAt: row.blocked_at,
|
|
216
254
|
completedAt: row.completed_at,
|
|
217
255
|
declinedAt: row.declined_at,
|
|
218
|
-
cancelledAt: row.cancelled_at
|
|
256
|
+
cancelledAt: row.cancelled_at,
|
|
257
|
+
overdueAt: row.overdue_at
|
|
219
258
|
};
|
|
220
259
|
}
|
|
221
|
-
function jsonString
|
|
260
|
+
function jsonString(value) {
|
|
222
261
|
return JSON.stringify(value ?? {});
|
|
223
262
|
}
|
|
224
|
-
function parseRecord$
|
|
263
|
+
function parseRecord$1(value) {
|
|
225
264
|
if (!value) return {};
|
|
226
265
|
try {
|
|
227
266
|
const parsed = JSON.parse(value);
|
|
228
|
-
return isRecord$
|
|
267
|
+
return isRecord$2(parsed) ? parsed : {};
|
|
229
268
|
} catch {
|
|
230
269
|
return {};
|
|
231
270
|
}
|
|
232
271
|
}
|
|
233
|
-
function isRecord$
|
|
272
|
+
function isRecord$2(value) {
|
|
234
273
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
235
274
|
}
|
|
236
|
-
function clampLimit$
|
|
275
|
+
function clampLimit$2(limit) {
|
|
237
276
|
if (!limit || limit < 1) return 50;
|
|
238
277
|
return Math.min(limit, 100);
|
|
239
278
|
}
|
|
240
279
|
|
|
241
280
|
//#endregion
|
|
242
|
-
//#region src/database/repositories/
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
"
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
281
|
+
//#region src/database/repositories/entity-aliases.ts
|
|
282
|
+
const WHITESPACE_PATTERN = /\s+/g;
|
|
283
|
+
function isResolvableEntityType(value) {
|
|
284
|
+
return value === "content" || value === "collection" || value === "plugin" || value === "taxonomy" || value === "menu";
|
|
285
|
+
}
|
|
286
|
+
function mapEntityAlias(row) {
|
|
287
|
+
if (!isResolvableEntityType(row.entity_type)) throw new Error(`Invalid entity alias type: ${row.entity_type}`);
|
|
288
|
+
return {
|
|
289
|
+
id: row.id,
|
|
290
|
+
entityType: row.entity_type,
|
|
291
|
+
collectionSlug: row.collection_slug,
|
|
292
|
+
entityId: row.entity_id,
|
|
293
|
+
alias: row.alias,
|
|
294
|
+
normalizedAlias: row.normalized_alias,
|
|
295
|
+
createdAt: row.created_at
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function normalizeEntityAlias(value) {
|
|
299
|
+
return value.trim().toLowerCase().replace(WHITESPACE_PATTERN, " ");
|
|
300
|
+
}
|
|
301
|
+
var EntityAliasRepository = class {
|
|
255
302
|
constructor(db) {
|
|
256
303
|
this.db = db;
|
|
257
304
|
}
|
|
258
305
|
async create(input) {
|
|
259
306
|
const id = ulid();
|
|
260
|
-
const
|
|
261
|
-
await this.db.insertInto("
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
307
|
+
const normalizedAlias = normalizeEntityAlias(input.alias);
|
|
308
|
+
await this.db.insertInto("_dineway_entity_aliases").values({
|
|
309
|
+
id,
|
|
310
|
+
entity_type: input.entityType,
|
|
311
|
+
collection_slug: input.collectionSlug ?? null,
|
|
312
|
+
entity_id: input.entityId,
|
|
313
|
+
alias: input.alias,
|
|
314
|
+
normalized_alias: normalizedAlias
|
|
315
|
+
}).execute();
|
|
316
|
+
return mapEntityAlias(await this.db.selectFrom("_dineway_entity_aliases").selectAll().where("id", "=", id).executeTakeFirstOrThrow());
|
|
317
|
+
}
|
|
318
|
+
async findByNormalizedAlias(input) {
|
|
319
|
+
const limit = Math.min(Math.max(input.limit ?? 10, 1), 50);
|
|
320
|
+
const collectionSlug = input.collectionSlug;
|
|
321
|
+
let query = this.db.selectFrom("_dineway_entity_aliases").selectAll().where("normalized_alias", "=", input.normalizedAlias);
|
|
322
|
+
if (input.entityTypes && input.entityTypes.length > 0) query = query.where("entity_type", "in", input.entityTypes);
|
|
323
|
+
if (collectionSlug) query = query.where((eb) => eb.or([eb("collection_slug", "is", null), eb("collection_slug", "=", collectionSlug)]));
|
|
324
|
+
return (await query.orderBy("created_at", "desc").limit(limit).execute()).map(mapEntityAlias);
|
|
265
325
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/database/repositories/handoff-snapshots.ts
|
|
330
|
+
var HandoffSnapshotRepository = class {
|
|
331
|
+
constructor(db) {
|
|
332
|
+
this.db = db;
|
|
269
333
|
}
|
|
270
|
-
async
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
result.nextCursor = encodeCursor(last.createdAt, last.id);
|
|
278
|
-
}
|
|
279
|
-
return result;
|
|
334
|
+
async create(input) {
|
|
335
|
+
const id = ulid();
|
|
336
|
+
await this.db.insertInto("_dineway_handoff_snapshots").values(toInsertableHandoffSnapshot(id, input)).execute();
|
|
337
|
+
return this.findById(id).then((snapshot) => {
|
|
338
|
+
if (!snapshot) throw new Error("Failed to create handoff snapshot");
|
|
339
|
+
return snapshot;
|
|
340
|
+
});
|
|
280
341
|
}
|
|
281
|
-
async
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
status: input.decision,
|
|
285
|
-
resolved_by_actor_type: input.resolvedByActorType,
|
|
286
|
-
resolved_by_actor_id: input.resolvedByActorId,
|
|
287
|
-
resolved_auth_metadata: jsonStringOrNull(input.resolvedAuthMetadata),
|
|
288
|
-
review_note: input.reviewNote ?? null,
|
|
289
|
-
resolved_at: resolvedAt,
|
|
290
|
-
updated_at: resolvedAt
|
|
291
|
-
}).where("id", "=", id).where("status", "=", "pending").executeTakeFirst();
|
|
292
|
-
if (Number(result.numUpdatedRows ?? 0) === 0) return null;
|
|
293
|
-
return this.findById(id);
|
|
342
|
+
async findById(id) {
|
|
343
|
+
const row = await this.db.selectFrom("_dineway_handoff_snapshots").selectAll().where("id", "=", id).executeTakeFirst();
|
|
344
|
+
return row ? rowToHandoffSnapshot(row) : null;
|
|
294
345
|
}
|
|
295
|
-
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if (query.scopes && query.scopes.length > 0) q = q.where("scope", "in", query.scopes);
|
|
300
|
-
if (query.statuses && query.statuses.length > 0) q = q.where("status", "in", query.statuses);
|
|
301
|
-
if (query.priority) q = q.where("priority", "=", query.priority);
|
|
302
|
-
if (query.actionType) q = q.where("action_type", "=", query.actionType);
|
|
303
|
-
if (query.targetRefType) q = q.where("target_ref_type", "=", query.targetRefType);
|
|
304
|
-
if (query.targetRefId) q = q.where("target_ref_id", "=", query.targetRefId);
|
|
305
|
-
if (query.relatedAssignmentId) q = q.where("related_assignment_id", "=", query.relatedAssignmentId);
|
|
306
|
-
if (query.requestedByActorType && query.requestedByActorId) q = q.where("requested_by_actor_type", "=", query.requestedByActorType).where("requested_by_actor_id", "=", query.requestedByActorId);
|
|
307
|
-
if (query.participantActor) q = q.where("requested_by_actor_type", "=", query.participantActor.actorType).where("requested_by_actor_id", "=", query.participantActor.actorId);
|
|
308
|
-
if (query.since) q = q.where("updated_at", ">=", query.since);
|
|
309
|
-
if (query.cursor) {
|
|
310
|
-
const decoded = decodeCursor(query.cursor);
|
|
311
|
-
if (decoded) q = q.where((eb) => eb.or([eb("created_at", "<", decoded.orderValue), eb.and([eb("created_at", "=", decoded.orderValue), eb("id", "<", decoded.id)])]));
|
|
312
|
-
}
|
|
313
|
-
return q;
|
|
346
|
+
async markResumed(id, resumedAt) {
|
|
347
|
+
const value = resumedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
348
|
+
await this.db.updateTable("_dineway_handoff_snapshots").set({ resumed_at: value }).where("id", "=", id).execute();
|
|
349
|
+
return this.findById(id);
|
|
314
350
|
}
|
|
315
351
|
};
|
|
316
|
-
function
|
|
352
|
+
function toInsertableHandoffSnapshot(id, input) {
|
|
317
353
|
return {
|
|
318
354
|
id,
|
|
319
355
|
scope: input.scope,
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
review_note: null,
|
|
336
|
-
metadata: jsonString(input.metadata),
|
|
337
|
-
related_assignment_id: input.relatedAssignmentId ?? null,
|
|
338
|
-
related_handoff_snapshot_id: input.relatedHandoffSnapshotId ?? null,
|
|
339
|
-
sla_due_at: input.slaDueAt ?? null,
|
|
340
|
-
created_at: now,
|
|
341
|
-
updated_at: now,
|
|
342
|
-
resolved_at: null
|
|
356
|
+
actor_type: input.actorType,
|
|
357
|
+
actor_id: input.actorId,
|
|
358
|
+
auth_metadata: jsonOrNull(input.authMetadata),
|
|
359
|
+
objective: input.objective,
|
|
360
|
+
reasoning: input.reasoning,
|
|
361
|
+
key_findings: JSON.stringify(input.keyFindings ?? []),
|
|
362
|
+
touched_objects: JSON.stringify(input.touchedObjects ?? []),
|
|
363
|
+
pending_actions: JSON.stringify(input.pendingActions ?? []),
|
|
364
|
+
tool_evidence: JSON.stringify(input.toolEvidence ?? []),
|
|
365
|
+
confidence: input.confidence ?? null,
|
|
366
|
+
handoff_kind: input.handoffKind ?? "pause",
|
|
367
|
+
reference_type: input.referenceType ?? null,
|
|
368
|
+
reference_id: input.referenceId ?? null,
|
|
369
|
+
created_at: input.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
370
|
+
resumed_at: null
|
|
343
371
|
};
|
|
344
372
|
}
|
|
345
|
-
function
|
|
373
|
+
function rowToHandoffSnapshot(row) {
|
|
346
374
|
return {
|
|
347
375
|
id: row.id,
|
|
348
376
|
scope: row.scope,
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
resolvedByActorId: row.resolved_by_actor_id,
|
|
363
|
-
resolvedAuthMetadata: parseNullableRecord(row.resolved_auth_metadata),
|
|
364
|
-
reviewNote: row.review_note,
|
|
365
|
-
metadata: parseRecord$1(row.metadata),
|
|
366
|
-
relatedAssignmentId: row.related_assignment_id,
|
|
367
|
-
relatedHandoffSnapshotId: row.related_handoff_snapshot_id,
|
|
368
|
-
slaDueAt: row.sla_due_at,
|
|
377
|
+
actorType: row.actor_type,
|
|
378
|
+
actorId: row.actor_id,
|
|
379
|
+
authMetadata: parseRecord(row.auth_metadata),
|
|
380
|
+
objective: row.objective,
|
|
381
|
+
reasoning: row.reasoning,
|
|
382
|
+
keyFindings: parseArray(row.key_findings),
|
|
383
|
+
touchedObjects: parseArray(row.touched_objects),
|
|
384
|
+
pendingActions: parseArray(row.pending_actions),
|
|
385
|
+
toolEvidence: parseArray(row.tool_evidence),
|
|
386
|
+
confidence: row.confidence,
|
|
387
|
+
handoffKind: row.handoff_kind,
|
|
388
|
+
referenceType: row.reference_type,
|
|
389
|
+
referenceId: row.reference_id,
|
|
369
390
|
createdAt: row.created_at,
|
|
370
|
-
|
|
371
|
-
resolvedAt: row.resolved_at
|
|
391
|
+
resumedAt: row.resumed_at
|
|
372
392
|
};
|
|
373
393
|
}
|
|
374
|
-
function
|
|
375
|
-
return JSON.stringify(value ?? {});
|
|
376
|
-
}
|
|
377
|
-
function jsonStringOrNull(value) {
|
|
394
|
+
function jsonOrNull(value) {
|
|
378
395
|
return value ? JSON.stringify(value) : null;
|
|
379
396
|
}
|
|
380
|
-
function parseRecord
|
|
381
|
-
if (!value) return
|
|
397
|
+
function parseRecord(value) {
|
|
398
|
+
if (!value) return null;
|
|
382
399
|
try {
|
|
383
400
|
const parsed = JSON.parse(value);
|
|
384
|
-
return isRecord$
|
|
401
|
+
return isRecord$1(parsed) ? parsed : null;
|
|
385
402
|
} catch {
|
|
386
|
-
return
|
|
403
|
+
return null;
|
|
387
404
|
}
|
|
388
405
|
}
|
|
389
|
-
function
|
|
390
|
-
if (!value) return
|
|
391
|
-
|
|
406
|
+
function parseArray(value) {
|
|
407
|
+
if (!value) return [];
|
|
408
|
+
try {
|
|
409
|
+
const parsed = JSON.parse(value);
|
|
410
|
+
return Array.isArray(parsed) ? parsed.filter((_item) => true) : [];
|
|
411
|
+
} catch {
|
|
412
|
+
return [];
|
|
413
|
+
}
|
|
392
414
|
}
|
|
393
|
-
function isRecord$
|
|
415
|
+
function isRecord$1(value) {
|
|
394
416
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
395
417
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
418
|
+
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region src/site-context/hitl.ts
|
|
421
|
+
const HITL_REQUEST_VALID_FROM = { resolve: ["pending"] };
|
|
422
|
+
var HitlRequestService = class {
|
|
423
|
+
repository;
|
|
424
|
+
assignments;
|
|
425
|
+
constructor(db) {
|
|
426
|
+
this.db = db;
|
|
427
|
+
this.repository = new HitlRequestRepository(db);
|
|
428
|
+
this.assignments = new AssignmentRepository(db);
|
|
429
|
+
}
|
|
430
|
+
async create(actor, input) {
|
|
431
|
+
parseSiteBriefingScope(input.scope);
|
|
432
|
+
const assignment = input.relatedAssignmentId ? await this.assignments.findById(input.relatedAssignmentId) : null;
|
|
433
|
+
if (input.relatedAssignmentId && !assignment) throw new Error(`Assignment not found: ${input.relatedAssignmentId}`);
|
|
434
|
+
if (assignment) {
|
|
435
|
+
this.assertRelatedAssignmentReadable(assignment, actor);
|
|
436
|
+
if (assignment.scope !== input.scope) throw new Error("Related assignment scope must match the HITL request scope.");
|
|
437
|
+
if (assignment.relatedHitlRequestId) throw new Error(`Assignment ${assignment.id} is already linked to HITL request ${assignment.relatedHitlRequestId}.`);
|
|
438
|
+
}
|
|
439
|
+
if (input.relatedHandoffSnapshotId) {
|
|
440
|
+
const snapshot = await new HandoffSnapshotRepository(this.db).findById(input.relatedHandoffSnapshotId);
|
|
441
|
+
if (!snapshot) throw new Error(`Handoff snapshot not found: ${input.relatedHandoffSnapshotId}`);
|
|
442
|
+
this.assertRelatedHandoffSnapshotReadable(snapshot, actor);
|
|
443
|
+
if (snapshot.scope !== input.scope) throw new Error("Related handoff snapshot scope must match the HITL request scope.");
|
|
444
|
+
}
|
|
445
|
+
const request = await this.repository.create({
|
|
446
|
+
scope: input.scope,
|
|
447
|
+
actionType: input.actionType,
|
|
448
|
+
title: input.title,
|
|
449
|
+
summary: input.summary,
|
|
450
|
+
riskReason: input.riskReason,
|
|
451
|
+
reviewPayload: input.reviewPayload,
|
|
452
|
+
targetRefType: input.targetRefType,
|
|
453
|
+
targetRefId: input.targetRefId,
|
|
454
|
+
requestedByActorType: actor.actorType,
|
|
455
|
+
requestedByActorId: actor.actorId,
|
|
456
|
+
requestedAuthMetadata: actor.authMetadata,
|
|
457
|
+
priority: input.priority,
|
|
458
|
+
metadata: input.metadata,
|
|
459
|
+
relatedAssignmentId: input.relatedAssignmentId,
|
|
460
|
+
relatedHandoffSnapshotId: input.relatedHandoffSnapshotId,
|
|
461
|
+
slaDueAt: input.slaDueAt,
|
|
462
|
+
createdAt: input.createdAt
|
|
463
|
+
});
|
|
464
|
+
if (assignment) {
|
|
465
|
+
if (!await this.assignments.linkHitlRequest(assignment.id, request.id, request.createdAt)) throw new Error(`Failed to link assignment ${assignment.id} to HITL request ${request.id}.`);
|
|
466
|
+
}
|
|
467
|
+
return request;
|
|
468
|
+
}
|
|
469
|
+
async get(id, actor) {
|
|
470
|
+
const request = await this.repository.findById(id);
|
|
471
|
+
if (!request) return null;
|
|
472
|
+
this.assertReadable(request, actor);
|
|
473
|
+
return request;
|
|
474
|
+
}
|
|
475
|
+
async list(actor, input = {}) {
|
|
476
|
+
return this.repository.list(this.buildListQuery(actor, input));
|
|
477
|
+
}
|
|
478
|
+
async resolve(input) {
|
|
479
|
+
const request = await this.loadExisting(input.id);
|
|
480
|
+
this.assertResolver(input.actor);
|
|
481
|
+
this.assertReadable(request, input.actor);
|
|
482
|
+
this.assertValidAction("resolve", request.status);
|
|
483
|
+
const resolved = await this.repository.resolve(request.id, {
|
|
484
|
+
decision: input.decision,
|
|
485
|
+
resolvedByActorType: input.actor.actorType,
|
|
486
|
+
resolvedByActorId: input.actor.actorId,
|
|
487
|
+
resolvedAuthMetadata: input.actor.authMetadata,
|
|
488
|
+
reviewNote: input.reviewNote,
|
|
489
|
+
resolvedAt: input.at
|
|
490
|
+
});
|
|
491
|
+
if (!resolved) throw new Error(`Failed to resolve HITL request ${request.id}.`);
|
|
492
|
+
return resolved;
|
|
493
|
+
}
|
|
494
|
+
buildListQuery(actor, input) {
|
|
495
|
+
const query = {
|
|
496
|
+
scope: input.scope,
|
|
497
|
+
scopes: input.scopes,
|
|
498
|
+
statuses: input.statuses,
|
|
499
|
+
priority: input.priority,
|
|
500
|
+
actionType: input.actionType,
|
|
501
|
+
targetRefType: input.targetRefType,
|
|
502
|
+
targetRefId: input.targetRefId,
|
|
503
|
+
relatedAssignmentId: input.relatedAssignmentId,
|
|
504
|
+
since: input.since,
|
|
505
|
+
limit: input.limit,
|
|
506
|
+
cursor: input.cursor
|
|
507
|
+
};
|
|
508
|
+
if (isHitlSupervisor(actor.userRole)) return query;
|
|
509
|
+
return {
|
|
510
|
+
...query,
|
|
511
|
+
requestedByActorType: actor.actorType,
|
|
512
|
+
requestedByActorId: actor.actorId
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
async loadExisting(id) {
|
|
516
|
+
const request = await this.repository.findById(id);
|
|
517
|
+
if (!request) throw new Error(`HITL request not found: ${id}`);
|
|
518
|
+
return request;
|
|
519
|
+
}
|
|
520
|
+
assertReadable(request, actor) {
|
|
521
|
+
if (isHitlSupervisor(actor.userRole)) return;
|
|
522
|
+
if (request.requestedByActorType === actor.actorType && request.requestedByActorId === actor.actorId) return;
|
|
523
|
+
throw new Error("Insufficient permissions to read this HITL request.");
|
|
524
|
+
}
|
|
525
|
+
assertResolver(actor) {
|
|
526
|
+
if (isHitlSupervisor(actor.userRole)) return;
|
|
527
|
+
throw new Error("HITL requests may only be resolved by an editor or admin.");
|
|
528
|
+
}
|
|
529
|
+
assertRelatedAssignmentReadable(assignment, actor) {
|
|
530
|
+
if (isHitlSupervisor(actor.userRole)) return;
|
|
531
|
+
if (matchesActor$1(assignment.assignedByActorType, assignment.assignedByActorId, actor) || matchesActor$1(assignment.assignedToActorType, assignment.assignedToActorId, actor)) return;
|
|
532
|
+
throw new Error("Insufficient permissions to link this assignment to a HITL request.");
|
|
533
|
+
}
|
|
534
|
+
assertRelatedHandoffSnapshotReadable(snapshot, actor) {
|
|
535
|
+
if (isHitlSupervisor(actor.userRole)) return;
|
|
536
|
+
if (matchesActor$1(snapshot.actorType, snapshot.actorId, actor)) return;
|
|
537
|
+
throw new Error("Insufficient permissions to link this handoff snapshot to a HITL request.");
|
|
538
|
+
}
|
|
539
|
+
assertValidAction(action, status) {
|
|
540
|
+
const validFrom = HITL_REQUEST_VALID_FROM[action];
|
|
541
|
+
if (!validFrom.includes(status)) throw new Error(`Cannot ${action} a HITL request in status "${status}". Valid statuses: ${validFrom.join(", ")}.`);
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
function isHitlSupervisor(role) {
|
|
545
|
+
return role >= Role.EDITOR;
|
|
546
|
+
}
|
|
547
|
+
function matchesActor$1(actorType, actorId, actor) {
|
|
548
|
+
return actorType === actor.actorType && actorId === actor.actorId;
|
|
399
549
|
}
|
|
400
550
|
|
|
401
551
|
//#endregion
|
|
@@ -436,131 +586,11 @@ function toPublicContextEntryPage(page) {
|
|
|
436
586
|
}
|
|
437
587
|
function toPublicContextDiff(diff) {
|
|
438
588
|
return {
|
|
439
|
-
newEntries: toPublicContextEntries(diff.newEntries),
|
|
440
|
-
supersededEntries: toPublicContextEntries(diff.supersededEntries),
|
|
441
|
-
staleEntries: toPublicContextEntries(diff.staleEntries),
|
|
442
|
-
reviewedEntries: toPublicContextEntries(diff.reviewedEntries)
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
//#endregion
|
|
447
|
-
//#region src/site-context/action-hash.ts
|
|
448
|
-
async function buildStableActionHash(value) {
|
|
449
|
-
return sha256Hex(stableStringify(value));
|
|
450
|
-
}
|
|
451
|
-
function stableStringify(value) {
|
|
452
|
-
if (Array.isArray(value)) return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
453
|
-
if (isRecord$3(value)) return `{${Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).toSorted(([left], [right]) => left.localeCompare(right)).map(([key, entryValue]) => `${JSON.stringify(key)}:${stableStringify(entryValue)}`).join(",")}}`;
|
|
454
|
-
return JSON.stringify(value ?? null);
|
|
455
|
-
}
|
|
456
|
-
function isRecord$3(value) {
|
|
457
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
458
|
-
}
|
|
459
|
-
async function sha256Hex(value) {
|
|
460
|
-
const buffer = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(value));
|
|
461
|
-
return Array.from(new Uint8Array(buffer), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
//#endregion
|
|
465
|
-
//#region src/site-context/review-payload.ts
|
|
466
|
-
var ReviewPayloadBuilder = class {
|
|
467
|
-
constructor(handlers) {
|
|
468
|
-
this.handlers = handlers;
|
|
469
|
-
}
|
|
470
|
-
async buildContentReviewPayload(input) {
|
|
471
|
-
const actionType = input.actionType ?? "content.publish";
|
|
472
|
-
const content = await this.loadContent(input.collection, input.id);
|
|
473
|
-
const compare = await this.loadCompare(input.collection, content.entryId);
|
|
474
|
-
const live = asRecord(compare.live);
|
|
475
|
-
const draft = asRecord(compare.draft) ?? content.data;
|
|
476
|
-
const hasChanges = typeof compare.hasChanges === "boolean" ? compare.hasChanges : stableStringify(live) !== stableStringify(draft);
|
|
477
|
-
const actionHash = await buildStableActionHash({
|
|
478
|
-
actionType,
|
|
479
|
-
collection: input.collection,
|
|
480
|
-
entryId: content.entryId,
|
|
481
|
-
liveRevisionId: content.liveRevisionId,
|
|
482
|
-
draftRevisionId: content.draftRevisionId,
|
|
483
|
-
reviewedRev: content.reviewedRev,
|
|
484
|
-
live,
|
|
485
|
-
draft
|
|
486
|
-
});
|
|
487
|
-
const scope = `content:${input.collection}:${content.entryId}`;
|
|
488
|
-
const summary = input.summary ?? `Review ${actionType} for ${input.collection}/${content.displayTitle ?? content.entryId}`;
|
|
489
|
-
return {
|
|
490
|
-
collection: input.collection,
|
|
491
|
-
entryId: content.entryId,
|
|
492
|
-
scope,
|
|
493
|
-
liveRevisionId: content.liveRevisionId,
|
|
494
|
-
draftRevisionId: content.draftRevisionId,
|
|
495
|
-
reviewedRev: content.reviewedRev,
|
|
496
|
-
actionType,
|
|
497
|
-
actionHash,
|
|
498
|
-
reviewPayload: {
|
|
499
|
-
kind: "content_review",
|
|
500
|
-
actionType,
|
|
501
|
-
summary,
|
|
502
|
-
target: {
|
|
503
|
-
collection: input.collection,
|
|
504
|
-
entryId: content.entryId,
|
|
505
|
-
scope,
|
|
506
|
-
liveRevisionId: content.liveRevisionId,
|
|
507
|
-
draftRevisionId: content.draftRevisionId,
|
|
508
|
-
reviewedRev: content.reviewedRev,
|
|
509
|
-
actionHash
|
|
510
|
-
},
|
|
511
|
-
content: {
|
|
512
|
-
id: content.entryId,
|
|
513
|
-
slug: content.slug,
|
|
514
|
-
status: content.status,
|
|
515
|
-
title: content.displayTitle,
|
|
516
|
-
updatedAt: content.updatedAt
|
|
517
|
-
},
|
|
518
|
-
diff: {
|
|
519
|
-
hasChanges,
|
|
520
|
-
live,
|
|
521
|
-
draft
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
async loadContent(collection, id) {
|
|
527
|
-
const result = await this.handlers.handleContentGet(collection, id);
|
|
528
|
-
if (!result.success) throw new Error(result.error?.message ?? `Content item not found: ${collection}/${id}`);
|
|
529
|
-
const payload = asRecord(result.data);
|
|
530
|
-
const item = asRecord(payload?.item);
|
|
531
|
-
if (!payload || !item) throw new Error("Content get response did not include an item");
|
|
532
|
-
const entryId = stringOrNull(item.id);
|
|
533
|
-
const reviewedRev = stringOrNull(payload._rev);
|
|
534
|
-
if (!entryId) throw new Error("Content item is missing id");
|
|
535
|
-
if (!reviewedRev) throw new Error("Content item is missing _rev for review binding");
|
|
536
|
-
const data = asRecord(item.data) ?? {};
|
|
537
|
-
const title = stringOrNull(data.title) ?? stringOrNull(item.title) ?? stringOrNull(item.slug);
|
|
538
|
-
return {
|
|
539
|
-
entryId,
|
|
540
|
-
reviewedRev,
|
|
541
|
-
liveRevisionId: stringOrNull(item.liveRevisionId),
|
|
542
|
-
draftRevisionId: stringOrNull(item.draftRevisionId),
|
|
543
|
-
slug: stringOrNull(item.slug),
|
|
544
|
-
status: stringOrNull(item.status),
|
|
545
|
-
updatedAt: stringOrNull(item.updatedAt),
|
|
546
|
-
displayTitle: title,
|
|
547
|
-
data
|
|
548
|
-
};
|
|
549
|
-
}
|
|
550
|
-
async loadCompare(collection, id) {
|
|
551
|
-
const result = await this.handlers.handleContentCompare(collection, id);
|
|
552
|
-
if (!result.success) throw new Error(result.error?.message ?? `Failed to compare content: ${collection}/${id}`);
|
|
553
|
-
return asRecord(result.data) ?? {};
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
function asRecord(value) {
|
|
557
|
-
return isRecord$2(value) ? value : null;
|
|
558
|
-
}
|
|
559
|
-
function isRecord$2(value) {
|
|
560
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
561
|
-
}
|
|
562
|
-
function stringOrNull(value) {
|
|
563
|
-
return typeof value === "string" && value.length > 0 ? value : null;
|
|
589
|
+
newEntries: toPublicContextEntries(diff.newEntries),
|
|
590
|
+
supersededEntries: toPublicContextEntries(diff.supersededEntries),
|
|
591
|
+
staleEntries: toPublicContextEntries(diff.staleEntries),
|
|
592
|
+
reviewedEntries: toPublicContextEntries(diff.reviewedEntries)
|
|
593
|
+
};
|
|
564
594
|
}
|
|
565
595
|
|
|
566
596
|
//#endregion
|
|
@@ -2742,12 +2772,12 @@ function parseUnknownRecord(value) {
|
|
|
2742
2772
|
if (!value) return null;
|
|
2743
2773
|
try {
|
|
2744
2774
|
const parsed = JSON.parse(value);
|
|
2745
|
-
return isRecord
|
|
2775
|
+
return isRecord(parsed) ? parsed : null;
|
|
2746
2776
|
} catch {
|
|
2747
2777
|
return null;
|
|
2748
2778
|
}
|
|
2749
2779
|
}
|
|
2750
|
-
function isRecord
|
|
2780
|
+
function isRecord(value) {
|
|
2751
2781
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2752
2782
|
}
|
|
2753
2783
|
|
|
@@ -3135,7 +3165,7 @@ var EntityResolver = class {
|
|
|
3135
3165
|
return this.options.db.selectFrom("_dineway_taxonomy_defs").selectAll().execute();
|
|
3136
3166
|
}
|
|
3137
3167
|
async listPlugins() {
|
|
3138
|
-
const result = await handlePluginList(this.options.db, this.options.handlers.configuredPlugins, this.options.handlers.config.marketplace);
|
|
3168
|
+
const result = await handlePluginList(this.options.db, this.options.handlers.configuredPlugins, this.options.handlers.sandboxedPluginEntries ?? [], this.options.handlers.config.marketplace);
|
|
3139
3169
|
return result.success ? result.data?.items ?? [] : [];
|
|
3140
3170
|
}
|
|
3141
3171
|
contentCandidate(item, context, matchTier, matchReason) {
|
|
@@ -3534,97 +3564,6 @@ function clampLimit$1(value) {
|
|
|
3534
3564
|
return Math.min(Math.max(1, value ?? 10), 100);
|
|
3535
3565
|
}
|
|
3536
3566
|
|
|
3537
|
-
//#endregion
|
|
3538
|
-
//#region src/database/repositories/handoff-snapshots.ts
|
|
3539
|
-
var HandoffSnapshotRepository = class {
|
|
3540
|
-
constructor(db) {
|
|
3541
|
-
this.db = db;
|
|
3542
|
-
}
|
|
3543
|
-
async create(input) {
|
|
3544
|
-
const id = ulid();
|
|
3545
|
-
await this.db.insertInto("_dineway_handoff_snapshots").values(toInsertableHandoffSnapshot(id, input)).execute();
|
|
3546
|
-
return this.findById(id).then((snapshot) => {
|
|
3547
|
-
if (!snapshot) throw new Error("Failed to create handoff snapshot");
|
|
3548
|
-
return snapshot;
|
|
3549
|
-
});
|
|
3550
|
-
}
|
|
3551
|
-
async findById(id) {
|
|
3552
|
-
const row = await this.db.selectFrom("_dineway_handoff_snapshots").selectAll().where("id", "=", id).executeTakeFirst();
|
|
3553
|
-
return row ? rowToHandoffSnapshot(row) : null;
|
|
3554
|
-
}
|
|
3555
|
-
async markResumed(id, resumedAt) {
|
|
3556
|
-
const value = resumedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
3557
|
-
await this.db.updateTable("_dineway_handoff_snapshots").set({ resumed_at: value }).where("id", "=", id).execute();
|
|
3558
|
-
return this.findById(id);
|
|
3559
|
-
}
|
|
3560
|
-
};
|
|
3561
|
-
function toInsertableHandoffSnapshot(id, input) {
|
|
3562
|
-
return {
|
|
3563
|
-
id,
|
|
3564
|
-
scope: input.scope,
|
|
3565
|
-
actor_type: input.actorType,
|
|
3566
|
-
actor_id: input.actorId,
|
|
3567
|
-
auth_metadata: jsonOrNull(input.authMetadata),
|
|
3568
|
-
objective: input.objective,
|
|
3569
|
-
reasoning: input.reasoning,
|
|
3570
|
-
key_findings: JSON.stringify(input.keyFindings ?? []),
|
|
3571
|
-
touched_objects: JSON.stringify(input.touchedObjects ?? []),
|
|
3572
|
-
pending_actions: JSON.stringify(input.pendingActions ?? []),
|
|
3573
|
-
tool_evidence: JSON.stringify(input.toolEvidence ?? []),
|
|
3574
|
-
confidence: input.confidence ?? null,
|
|
3575
|
-
handoff_kind: input.handoffKind ?? "pause",
|
|
3576
|
-
reference_type: input.referenceType ?? null,
|
|
3577
|
-
reference_id: input.referenceId ?? null,
|
|
3578
|
-
created_at: input.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
3579
|
-
resumed_at: null
|
|
3580
|
-
};
|
|
3581
|
-
}
|
|
3582
|
-
function rowToHandoffSnapshot(row) {
|
|
3583
|
-
return {
|
|
3584
|
-
id: row.id,
|
|
3585
|
-
scope: row.scope,
|
|
3586
|
-
actorType: row.actor_type,
|
|
3587
|
-
actorId: row.actor_id,
|
|
3588
|
-
authMetadata: parseRecord(row.auth_metadata),
|
|
3589
|
-
objective: row.objective,
|
|
3590
|
-
reasoning: row.reasoning,
|
|
3591
|
-
keyFindings: parseArray(row.key_findings),
|
|
3592
|
-
touchedObjects: parseArray(row.touched_objects),
|
|
3593
|
-
pendingActions: parseArray(row.pending_actions),
|
|
3594
|
-
toolEvidence: parseArray(row.tool_evidence),
|
|
3595
|
-
confidence: row.confidence,
|
|
3596
|
-
handoffKind: row.handoff_kind,
|
|
3597
|
-
referenceType: row.reference_type,
|
|
3598
|
-
referenceId: row.reference_id,
|
|
3599
|
-
createdAt: row.created_at,
|
|
3600
|
-
resumedAt: row.resumed_at
|
|
3601
|
-
};
|
|
3602
|
-
}
|
|
3603
|
-
function jsonOrNull(value) {
|
|
3604
|
-
return value ? JSON.stringify(value) : null;
|
|
3605
|
-
}
|
|
3606
|
-
function parseRecord(value) {
|
|
3607
|
-
if (!value) return null;
|
|
3608
|
-
try {
|
|
3609
|
-
const parsed = JSON.parse(value);
|
|
3610
|
-
return isRecord(parsed) ? parsed : null;
|
|
3611
|
-
} catch {
|
|
3612
|
-
return null;
|
|
3613
|
-
}
|
|
3614
|
-
}
|
|
3615
|
-
function parseArray(value) {
|
|
3616
|
-
if (!value) return [];
|
|
3617
|
-
try {
|
|
3618
|
-
const parsed = JSON.parse(value);
|
|
3619
|
-
return Array.isArray(parsed) ? parsed.filter((_item) => true) : [];
|
|
3620
|
-
} catch {
|
|
3621
|
-
return [];
|
|
3622
|
-
}
|
|
3623
|
-
}
|
|
3624
|
-
function isRecord(value) {
|
|
3625
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3626
|
-
}
|
|
3627
|
-
|
|
3628
3567
|
//#endregion
|
|
3629
3568
|
//#region src/site-context/handoff.ts
|
|
3630
3569
|
const DEFAULT_ACTIVITY_LIMIT = 25;
|
|
@@ -3638,16 +3577,25 @@ var HandoffSnapshotStore = class {
|
|
|
3638
3577
|
this.now = options.now ?? /* @__PURE__ */ new Date();
|
|
3639
3578
|
}
|
|
3640
3579
|
async capture(input) {
|
|
3641
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
3642
3580
|
parseSiteBriefingScope(input.scope);
|
|
3643
|
-
|
|
3581
|
+
if (Boolean(input.referenceType) !== Boolean(input.referenceId)) throw new Error("Handoff reference type and id must be provided together.");
|
|
3582
|
+
return this.withTransaction(async (transaction) => {
|
|
3583
|
+
if (input.referenceType === "assignment") {
|
|
3584
|
+
const assignment = await new AssignmentRepository(transaction).findById(input.referenceId);
|
|
3585
|
+
if (!assignment) throw new Error(`Assignment not found: ${input.referenceId}`);
|
|
3586
|
+
if (assignment.scope !== input.scope) throw new Error("Referenced Assignment scope must match the Handoff scope.");
|
|
3587
|
+
}
|
|
3588
|
+
const snapshot = await new HandoffSnapshotRepository(transaction).create(input);
|
|
3589
|
+
if (input.referenceType === "assignment") {
|
|
3590
|
+
if (!await new AssignmentRepository(transaction).linkHandoffSnapshot(input.referenceId, snapshot.id, snapshot.createdAt)) throw new Error(`Assignment not found: ${input.referenceId}`);
|
|
3591
|
+
}
|
|
3592
|
+
return snapshot;
|
|
3593
|
+
});
|
|
3644
3594
|
}
|
|
3645
3595
|
async get(id) {
|
|
3646
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
3647
3596
|
return new HandoffSnapshotRepository(this.db).findById(id);
|
|
3648
3597
|
}
|
|
3649
3598
|
async resume(input) {
|
|
3650
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
3651
3599
|
const repository = new HandoffSnapshotRepository(this.db);
|
|
3652
3600
|
const snapshot = await repository.findById(input.id);
|
|
3653
3601
|
if (!snapshot) return null;
|
|
@@ -3717,6 +3665,10 @@ var HandoffSnapshotStore = class {
|
|
|
3717
3665
|
}
|
|
3718
3666
|
};
|
|
3719
3667
|
}
|
|
3668
|
+
async withTransaction(operation) {
|
|
3669
|
+
if (this.db.isTransaction) return operation(this.db);
|
|
3670
|
+
return this.db.transaction().execute(operation);
|
|
3671
|
+
}
|
|
3720
3672
|
};
|
|
3721
3673
|
function summarizeScope(scope) {
|
|
3722
3674
|
return {
|
|
@@ -3772,7 +3724,6 @@ var AssignmentService = class {
|
|
|
3772
3724
|
this.repository = new AssignmentRepository(db);
|
|
3773
3725
|
}
|
|
3774
3726
|
async create(actor, input) {
|
|
3775
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
3776
3727
|
if (input.relatedHandoffSnapshotId) {
|
|
3777
3728
|
const snapshot = await new HandoffSnapshotRepository(this.db).findById(input.relatedHandoffSnapshotId);
|
|
3778
3729
|
if (!snapshot) throw new Error(`Handoff snapshot not found: ${input.relatedHandoffSnapshotId}`);
|
|
@@ -3796,18 +3747,15 @@ var AssignmentService = class {
|
|
|
3796
3747
|
});
|
|
3797
3748
|
}
|
|
3798
3749
|
async get(id, actor) {
|
|
3799
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
3800
3750
|
const assignment = await this.repository.findById(id);
|
|
3801
3751
|
if (!assignment) return null;
|
|
3802
3752
|
this.assertReadable(assignment, actor);
|
|
3803
3753
|
return assignment;
|
|
3804
3754
|
}
|
|
3805
3755
|
async list(actor, input = {}) {
|
|
3806
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
3807
3756
|
return this.repository.list(this.buildListQuery(actor, input));
|
|
3808
3757
|
}
|
|
3809
3758
|
async accept(input) {
|
|
3810
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
3811
3759
|
const assignment = await this.loadExisting(input.id);
|
|
3812
3760
|
this.assertAssigneeAction("accept", assignment, input.actor);
|
|
3813
3761
|
this.assertValidAction("accept", assignment.status);
|
|
@@ -3821,7 +3769,6 @@ var AssignmentService = class {
|
|
|
3821
3769
|
return accepted;
|
|
3822
3770
|
}
|
|
3823
3771
|
async start(input) {
|
|
3824
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
3825
3772
|
const assignment = await this.loadExisting(input.id);
|
|
3826
3773
|
this.assertAssigneeAction("start", assignment, input.actor);
|
|
3827
3774
|
this.assertValidAction("start", assignment.status);
|
|
@@ -3833,7 +3780,6 @@ var AssignmentService = class {
|
|
|
3833
3780
|
return started;
|
|
3834
3781
|
}
|
|
3835
3782
|
async block(input) {
|
|
3836
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
3837
3783
|
const assignment = await this.loadExisting(input.id);
|
|
3838
3784
|
this.assertAssigneeAction("block", assignment, input.actor);
|
|
3839
3785
|
this.assertValidAction("block", assignment.status);
|
|
@@ -3845,7 +3791,6 @@ var AssignmentService = class {
|
|
|
3845
3791
|
return blocked;
|
|
3846
3792
|
}
|
|
3847
3793
|
async complete(input) {
|
|
3848
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
3849
3794
|
const assignment = await this.loadExisting(input.id);
|
|
3850
3795
|
this.assertAssigneeAction("complete", assignment, input.actor);
|
|
3851
3796
|
this.assertValidAction("complete", assignment.status);
|
|
@@ -3857,7 +3802,6 @@ var AssignmentService = class {
|
|
|
3857
3802
|
return completed;
|
|
3858
3803
|
}
|
|
3859
3804
|
async decline(input) {
|
|
3860
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
3861
3805
|
const assignment = await this.loadExisting(input.id);
|
|
3862
3806
|
this.assertAssigneeAction("decline", assignment, input.actor);
|
|
3863
3807
|
this.assertValidAction("decline", assignment.status);
|
|
@@ -3869,7 +3813,6 @@ var AssignmentService = class {
|
|
|
3869
3813
|
return declined;
|
|
3870
3814
|
}
|
|
3871
3815
|
async cancel(input) {
|
|
3872
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
3873
3816
|
const assignment = await this.loadExisting(input.id);
|
|
3874
3817
|
this.assertCanceller(assignment, input.actor);
|
|
3875
3818
|
this.assertValidAction("cancel", assignment.status);
|
|
@@ -3924,7 +3867,7 @@ var AssignmentService = class {
|
|
|
3924
3867
|
}
|
|
3925
3868
|
assertReadable(assignment, actor) {
|
|
3926
3869
|
if (isWorkflowSupervisor(actor.userRole)) return;
|
|
3927
|
-
if (matchesActor
|
|
3870
|
+
if (matchesActor(assignment.assignedByActorType, assignment.assignedByActorId, actor) || matchesActor(assignment.assignedToActorType, assignment.assignedToActorId, actor)) return;
|
|
3928
3871
|
throw new Error("Insufficient permissions to access this assignment.");
|
|
3929
3872
|
}
|
|
3930
3873
|
assertAssigneeAction(action, assignment, actor) {
|
|
@@ -3933,12 +3876,12 @@ var AssignmentService = class {
|
|
|
3933
3876
|
if (action === "accept") return;
|
|
3934
3877
|
throw new Error(`Only an assigned actor can ${action} this assignment.`);
|
|
3935
3878
|
}
|
|
3936
|
-
if (matchesActor
|
|
3879
|
+
if (matchesActor(assignment.assignedToActorType, assignment.assignedToActorId, actor)) return;
|
|
3937
3880
|
throw new Error(`Only the assignee can ${action} this assignment.`);
|
|
3938
3881
|
}
|
|
3939
3882
|
assertCanceller(assignment, actor) {
|
|
3940
3883
|
if (isWorkflowSupervisor(actor.userRole)) return;
|
|
3941
|
-
if (matchesActor
|
|
3884
|
+
if (matchesActor(assignment.assignedByActorType, assignment.assignedByActorId, actor)) return;
|
|
3942
3885
|
throw new Error("Only the assigner or an editor can cancel this assignment.");
|
|
3943
3886
|
}
|
|
3944
3887
|
assertValidAction(action, currentStatus) {
|
|
@@ -3951,7 +3894,7 @@ function validateAssignmentAction(action, currentStatus) {
|
|
|
3951
3894
|
if (validFrom.includes(currentStatus)) return null;
|
|
3952
3895
|
return `Cannot ${action} an assignment that is currently '${currentStatus}'. Must be: ${validFrom.join(" or ")}`;
|
|
3953
3896
|
}
|
|
3954
|
-
function matchesActor
|
|
3897
|
+
function matchesActor(actorType, actorId, actor) {
|
|
3955
3898
|
return actorType === actor.actorType && actorId === actor.actorId;
|
|
3956
3899
|
}
|
|
3957
3900
|
function isWorkflowSupervisor(userRole) {
|
|
@@ -3965,142 +3908,6 @@ function mergeReasonMetadata(metadata, key, reason) {
|
|
|
3965
3908
|
};
|
|
3966
3909
|
}
|
|
3967
3910
|
|
|
3968
|
-
//#endregion
|
|
3969
|
-
//#region src/site-context/hitl.ts
|
|
3970
|
-
const HITL_REQUEST_VALID_FROM = { resolve: ["pending"] };
|
|
3971
|
-
var HitlRequestService = class {
|
|
3972
|
-
repository;
|
|
3973
|
-
assignments;
|
|
3974
|
-
constructor(db) {
|
|
3975
|
-
this.db = db;
|
|
3976
|
-
this.repository = new HitlRequestRepository(db);
|
|
3977
|
-
this.assignments = new AssignmentRepository(db);
|
|
3978
|
-
}
|
|
3979
|
-
async create(actor, input) {
|
|
3980
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
3981
|
-
parseSiteBriefingScope(input.scope);
|
|
3982
|
-
const assignment = input.relatedAssignmentId ? await this.assignments.findById(input.relatedAssignmentId) : null;
|
|
3983
|
-
if (input.relatedAssignmentId && !assignment) throw new Error(`Assignment not found: ${input.relatedAssignmentId}`);
|
|
3984
|
-
if (assignment) {
|
|
3985
|
-
this.assertRelatedAssignmentReadable(assignment, actor);
|
|
3986
|
-
if (assignment.scope !== input.scope) throw new Error("Related assignment scope must match the HITL request scope.");
|
|
3987
|
-
if (assignment.relatedHitlRequestId) throw new Error(`Assignment ${assignment.id} is already linked to HITL request ${assignment.relatedHitlRequestId}.`);
|
|
3988
|
-
}
|
|
3989
|
-
if (input.relatedHandoffSnapshotId) {
|
|
3990
|
-
const snapshot = await new HandoffSnapshotRepository(this.db).findById(input.relatedHandoffSnapshotId);
|
|
3991
|
-
if (!snapshot) throw new Error(`Handoff snapshot not found: ${input.relatedHandoffSnapshotId}`);
|
|
3992
|
-
this.assertRelatedHandoffSnapshotReadable(snapshot, actor);
|
|
3993
|
-
if (snapshot.scope !== input.scope) throw new Error("Related handoff snapshot scope must match the HITL request scope.");
|
|
3994
|
-
}
|
|
3995
|
-
const request = await this.repository.create({
|
|
3996
|
-
scope: input.scope,
|
|
3997
|
-
actionType: input.actionType,
|
|
3998
|
-
title: input.title,
|
|
3999
|
-
summary: input.summary,
|
|
4000
|
-
riskReason: input.riskReason,
|
|
4001
|
-
reviewPayload: input.reviewPayload,
|
|
4002
|
-
targetRefType: input.targetRefType,
|
|
4003
|
-
targetRefId: input.targetRefId,
|
|
4004
|
-
requestedByActorType: actor.actorType,
|
|
4005
|
-
requestedByActorId: actor.actorId,
|
|
4006
|
-
requestedAuthMetadata: actor.authMetadata,
|
|
4007
|
-
priority: input.priority,
|
|
4008
|
-
metadata: input.metadata,
|
|
4009
|
-
relatedAssignmentId: input.relatedAssignmentId,
|
|
4010
|
-
relatedHandoffSnapshotId: input.relatedHandoffSnapshotId,
|
|
4011
|
-
slaDueAt: input.slaDueAt,
|
|
4012
|
-
createdAt: input.createdAt
|
|
4013
|
-
});
|
|
4014
|
-
if (assignment) {
|
|
4015
|
-
if (!await this.assignments.linkHitlRequest(assignment.id, request.id, request.createdAt)) throw new Error(`Failed to link assignment ${assignment.id} to HITL request ${request.id}.`);
|
|
4016
|
-
}
|
|
4017
|
-
return request;
|
|
4018
|
-
}
|
|
4019
|
-
async get(id, actor) {
|
|
4020
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
4021
|
-
const request = await this.repository.findById(id);
|
|
4022
|
-
if (!request) return null;
|
|
4023
|
-
this.assertReadable(request, actor);
|
|
4024
|
-
return request;
|
|
4025
|
-
}
|
|
4026
|
-
async list(actor, input = {}) {
|
|
4027
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
4028
|
-
return this.repository.list(this.buildListQuery(actor, input));
|
|
4029
|
-
}
|
|
4030
|
-
async resolve(input) {
|
|
4031
|
-
assertExperimentalSiteContextWorkflowsEnabled();
|
|
4032
|
-
const request = await this.loadExisting(input.id);
|
|
4033
|
-
this.assertResolver(input.actor);
|
|
4034
|
-
this.assertReadable(request, input.actor);
|
|
4035
|
-
this.assertValidAction("resolve", request.status);
|
|
4036
|
-
const resolved = await this.repository.resolve(request.id, {
|
|
4037
|
-
decision: input.decision,
|
|
4038
|
-
resolvedByActorType: input.actor.actorType,
|
|
4039
|
-
resolvedByActorId: input.actor.actorId,
|
|
4040
|
-
resolvedAuthMetadata: input.actor.authMetadata,
|
|
4041
|
-
reviewNote: input.reviewNote,
|
|
4042
|
-
resolvedAt: input.at
|
|
4043
|
-
});
|
|
4044
|
-
if (!resolved) throw new Error(`Failed to resolve HITL request ${request.id}.`);
|
|
4045
|
-
return resolved;
|
|
4046
|
-
}
|
|
4047
|
-
buildListQuery(actor, input) {
|
|
4048
|
-
const query = {
|
|
4049
|
-
scope: input.scope,
|
|
4050
|
-
scopes: input.scopes,
|
|
4051
|
-
statuses: input.statuses,
|
|
4052
|
-
priority: input.priority,
|
|
4053
|
-
actionType: input.actionType,
|
|
4054
|
-
targetRefType: input.targetRefType,
|
|
4055
|
-
targetRefId: input.targetRefId,
|
|
4056
|
-
relatedAssignmentId: input.relatedAssignmentId,
|
|
4057
|
-
since: input.since,
|
|
4058
|
-
limit: input.limit,
|
|
4059
|
-
cursor: input.cursor
|
|
4060
|
-
};
|
|
4061
|
-
if (isHitlSupervisor(actor.userRole)) return query;
|
|
4062
|
-
return {
|
|
4063
|
-
...query,
|
|
4064
|
-
requestedByActorType: actor.actorType,
|
|
4065
|
-
requestedByActorId: actor.actorId
|
|
4066
|
-
};
|
|
4067
|
-
}
|
|
4068
|
-
async loadExisting(id) {
|
|
4069
|
-
const request = await this.repository.findById(id);
|
|
4070
|
-
if (!request) throw new Error(`HITL request not found: ${id}`);
|
|
4071
|
-
return request;
|
|
4072
|
-
}
|
|
4073
|
-
assertReadable(request, actor) {
|
|
4074
|
-
if (isHitlSupervisor(actor.userRole)) return;
|
|
4075
|
-
if (request.requestedByActorType === actor.actorType && request.requestedByActorId === actor.actorId) return;
|
|
4076
|
-
throw new Error("Insufficient permissions to read this HITL request.");
|
|
4077
|
-
}
|
|
4078
|
-
assertResolver(actor) {
|
|
4079
|
-
if (isHitlSupervisor(actor.userRole)) return;
|
|
4080
|
-
throw new Error("HITL requests may only be resolved by an editor or admin.");
|
|
4081
|
-
}
|
|
4082
|
-
assertRelatedAssignmentReadable(assignment, actor) {
|
|
4083
|
-
if (isHitlSupervisor(actor.userRole)) return;
|
|
4084
|
-
if (matchesActor(assignment.assignedByActorType, assignment.assignedByActorId, actor) || matchesActor(assignment.assignedToActorType, assignment.assignedToActorId, actor)) return;
|
|
4085
|
-
throw new Error("Insufficient permissions to link this assignment to a HITL request.");
|
|
4086
|
-
}
|
|
4087
|
-
assertRelatedHandoffSnapshotReadable(snapshot, actor) {
|
|
4088
|
-
if (isHitlSupervisor(actor.userRole)) return;
|
|
4089
|
-
if (matchesActor(snapshot.actorType, snapshot.actorId, actor)) return;
|
|
4090
|
-
throw new Error("Insufficient permissions to link this handoff snapshot to a HITL request.");
|
|
4091
|
-
}
|
|
4092
|
-
assertValidAction(action, status) {
|
|
4093
|
-
const validFrom = HITL_REQUEST_VALID_FROM[action];
|
|
4094
|
-
if (!validFrom.includes(status)) throw new Error(`Cannot ${action} a HITL request in status "${status}". Valid statuses: ${validFrom.join(", ")}.`);
|
|
4095
|
-
}
|
|
4096
|
-
};
|
|
4097
|
-
function isHitlSupervisor(role) {
|
|
4098
|
-
return role >= Role.EDITOR;
|
|
4099
|
-
}
|
|
4100
|
-
function matchesActor(actorType, actorId, actor) {
|
|
4101
|
-
return actorType === actor.actorType && actorId === actor.actorId;
|
|
4102
|
-
}
|
|
4103
|
-
|
|
4104
3911
|
//#endregion
|
|
4105
3912
|
//#region src/site-context/workflow-hitl.ts
|
|
4106
3913
|
var WorkflowHitlCoordinator = class {
|
|
@@ -4143,4 +3950,4 @@ var WorkflowHitlCoordinator = class {
|
|
|
4143
3950
|
};
|
|
4144
3951
|
|
|
4145
3952
|
//#endregion
|
|
4146
|
-
export {
|
|
3953
|
+
export { ASSIGNMENT_STATUSES as C, ASSIGNMENT_PRIORITIES as S, toPublicContextDiff as _, EntityResolver as a, HitlRequestService as b, TaxonomyHitlPayloadBuilder as c, SettingsHitlPayloadBuilder as d, WordPressImportHitlPayloadBuilder as f, RiskPolicyEvaluator as g, SchemaHitlPayloadBuilder as h, ActorExpertiseService as i, MenuHitlPayloadBuilder as l, PluginHitlPayloadBuilder as m, AssignmentService as n, WidgetHitlPayloadBuilder as o, ExclusiveHookHitlPayloadBuilder as p, HandoffSnapshotStore as r, SectionHitlPayloadBuilder as s, WorkflowHitlCoordinator as t, RedirectHitlPayloadBuilder as u, toPublicContextEntry as v, AssignmentRepository as w, ASSIGNMENT_ACTOR_TYPES as x, toPublicContextEntryPage as y };
|