@adonis-agora/durable 1.0.0-rc.2 → 1.0.0-rc.21
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/CHANGELOG.md +204 -0
- package/dist/assets/spa/assets/index-BgoNV3TR.css +1 -0
- package/dist/assets/spa/assets/index-DzXygyDm.js +57 -0
- package/dist/assets/spa/assets/index-DzXygyDm.js.map +1 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-600-normal-BfsvjouI.woff +0 -0
- package/dist/assets/spa/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-400-normal-CRt88UEn.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-400-normal-OW7qkl5a.woff +0 -0
- package/dist/assets/spa/assets/sora-latin-500-normal-01eiPEn0.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-500-normal-w58xtEt9.woff +0 -0
- package/dist/assets/spa/assets/sora-latin-600-normal-1_7fyUAY.woff +0 -0
- package/dist/assets/spa/assets/sora-latin-600-normal-Cdg4DaK0.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-700-normal-9waGdLWo.woff2 +0 -0
- package/dist/assets/spa/assets/sora-latin-700-normal-BKPfQAnC.woff +0 -0
- package/dist/assets/spa/index.html +2 -8
- package/dist/commands/agora_doctor.d.ts +23 -0
- package/dist/commands/agora_doctor.d.ts.map +1 -0
- package/dist/commands/agora_doctor.js +110 -0
- package/dist/commands/agora_doctor.js.map +1 -0
- package/dist/commands/durable_doctor.d.ts +8 -0
- package/dist/commands/durable_doctor.d.ts.map +1 -0
- package/dist/commands/durable_doctor.js +8 -0
- package/dist/commands/durable_doctor.js.map +1 -0
- package/dist/commands/durable_worker.d.ts +3 -3
- package/dist/commands/durable_worker.js +7 -7
- package/dist/commands/durable_worker.js.map +1 -1
- package/dist/commands/health.d.ts +12 -0
- package/dist/commands/health.d.ts.map +1 -0
- package/dist/commands/health.js +34 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/lifecycle_republish.d.ts +8 -9
- package/dist/commands/lifecycle_republish.d.ts.map +1 -1
- package/dist/commands/lifecycle_republish.js +29 -16
- package/dist/commands/lifecycle_republish.js.map +1 -1
- package/dist/commands/main.d.ts +25 -5
- package/dist/commands/main.d.ts.map +1 -1
- package/dist/commands/main.js +54 -7
- package/dist/commands/main.js.map +1 -1
- package/dist/commands/runs.d.ts +9 -16
- package/dist/commands/runs.d.ts.map +1 -1
- package/dist/commands/runs.js +60 -47
- package/dist/commands/runs.js.map +1 -1
- package/dist/commands/runs_bulk.d.ts +17 -0
- package/dist/commands/runs_bulk.d.ts.map +1 -0
- package/dist/commands/runs_bulk.js +76 -0
- package/dist/commands/runs_bulk.js.map +1 -0
- package/dist/commands/runs_cancel.d.ts +15 -0
- package/dist/commands/runs_cancel.d.ts.map +1 -0
- package/dist/commands/runs_cancel.js +39 -0
- package/dist/commands/runs_cancel.js.map +1 -0
- package/dist/commands/runs_continue.d.ts +12 -0
- package/dist/commands/runs_continue.d.ts.map +1 -0
- package/dist/commands/runs_continue.js +28 -0
- package/dist/commands/runs_continue.js.map +1 -0
- package/dist/commands/runs_event.d.ts +13 -0
- package/dist/commands/runs_event.d.ts.map +1 -0
- package/dist/commands/runs_event.js +28 -0
- package/dist/commands/runs_event.js.map +1 -0
- package/dist/commands/runs_fan.d.ts +16 -0
- package/dist/commands/runs_fan.d.ts.map +1 -0
- package/dist/commands/runs_fan.js +58 -0
- package/dist/commands/runs_fan.js.map +1 -0
- package/dist/commands/runs_redispatch.d.ts +14 -0
- package/dist/commands/runs_redispatch.d.ts.map +1 -0
- package/dist/commands/runs_redispatch.js +35 -0
- package/dist/commands/runs_redispatch.js.map +1 -0
- package/dist/commands/runs_replay.d.ts +14 -0
- package/dist/commands/runs_replay.d.ts.map +1 -0
- package/dist/commands/runs_replay.js +38 -0
- package/dist/commands/runs_replay.js.map +1 -0
- package/dist/commands/runs_retry.d.ts +13 -0
- package/dist/commands/runs_retry.d.ts.map +1 -0
- package/dist/commands/runs_retry.js +29 -0
- package/dist/commands/runs_retry.js.map +1 -0
- package/dist/commands/runs_show.d.ts +14 -0
- package/dist/commands/runs_show.d.ts.map +1 -0
- package/dist/commands/runs_show.js +96 -0
- package/dist/commands/runs_show.js.map +1 -0
- package/dist/commands/runs_signal.d.ts +17 -0
- package/dist/commands/runs_signal.d.ts.map +1 -0
- package/dist/commands/runs_signal.js +49 -0
- package/dist/commands/runs_signal.js.map +1 -0
- package/dist/commands/runs_update.d.ts +15 -0
- package/dist/commands/runs_update.d.ts.map +1 -0
- package/dist/commands/runs_update.js +39 -0
- package/dist/commands/runs_update.js.map +1 -0
- package/dist/commands/runs_values.d.ts +15 -0
- package/dist/commands/runs_values.d.ts.map +1 -0
- package/dist/commands/runs_values.js +45 -0
- package/dist/commands/runs_values.js.map +1 -0
- package/dist/commands/schedules.d.ts +18 -0
- package/dist/commands/schedules.d.ts.map +1 -0
- package/dist/commands/schedules.js +70 -0
- package/dist/commands/schedules.js.map +1 -0
- package/dist/commands/schedules_pause.d.ts +16 -0
- package/dist/commands/schedules_pause.d.ts.map +1 -0
- package/dist/commands/schedules_pause.js +40 -0
- package/dist/commands/schedules_pause.js.map +1 -0
- package/dist/commands/schedules_resume.d.ts +8 -0
- package/dist/commands/schedules_resume.d.ts.map +1 -0
- package/dist/commands/schedules_resume.js +8 -0
- package/dist/commands/schedules_resume.js.map +1 -0
- package/dist/commands/schedules_trigger.d.ts +13 -0
- package/dist/commands/schedules_trigger.d.ts.map +1 -0
- package/dist/commands/schedules_trigger.js +32 -0
- package/dist/commands/schedules_trigger.js.map +1 -0
- package/dist/commands/tasks_complete.d.ts +15 -0
- package/dist/commands/tasks_complete.d.ts.map +1 -0
- package/dist/commands/tasks_complete.js +41 -0
- package/dist/commands/tasks_complete.js.map +1 -0
- package/dist/commands/tasks_fail.d.ts +16 -0
- package/dist/commands/tasks_fail.d.ts.map +1 -0
- package/dist/commands/tasks_fail.js +47 -0
- package/dist/commands/tasks_fail.js.map +1 -0
- package/dist/commands/workers.d.ts +11 -0
- package/dist/commands/workers.d.ts.map +1 -0
- package/dist/commands/workers.js +35 -0
- package/dist/commands/workers.js.map +1 -0
- package/dist/commands/workflows_lifecycle.d.ts +12 -0
- package/dist/commands/workflows_lifecycle.d.ts.map +1 -0
- package/dist/commands/workflows_lifecycle.js +37 -0
- package/dist/commands/workflows_lifecycle.js.map +1 -0
- package/dist/configure.d.ts +2 -2
- package/dist/configure.js +2 -2
- package/dist/providers/dashboard_provider.d.ts +57 -54
- package/dist/providers/dashboard_provider.d.ts.map +1 -1
- package/dist/providers/dashboard_provider.js +399 -288
- package/dist/providers/dashboard_provider.js.map +1 -1
- package/dist/providers/durable_provider.d.ts.map +1 -1
- package/dist/providers/durable_provider.js +67 -37
- package/dist/providers/durable_provider.js.map +1 -1
- package/dist/src/commands/console_command.d.ts +82 -0
- package/dist/src/commands/console_command.d.ts.map +1 -0
- package/dist/src/commands/console_command.js +238 -0
- package/dist/src/commands/console_command.js.map +1 -0
- package/dist/src/commands/runs.js +2 -2
- package/dist/src/commands/runs.js.map +1 -1
- package/dist/src/concurrency.d.ts.map +1 -1
- package/dist/src/concurrency.js +1 -0
- package/dist/src/concurrency.js.map +1 -1
- package/dist/src/config_types.d.ts +79 -26
- package/dist/src/config_types.d.ts.map +1 -1
- package/dist/src/dashboard/access_denied_page.d.ts +5 -7
- package/dist/src/dashboard/access_denied_page.d.ts.map +1 -1
- package/dist/src/dashboard/access_denied_page.js +2 -6
- package/dist/src/dashboard/access_denied_page.js.map +1 -1
- package/dist/src/dashboard/audit.d.ts +14 -0
- package/dist/src/dashboard/audit.d.ts.map +1 -0
- package/dist/src/dashboard/audit.js +36 -0
- package/dist/src/dashboard/audit.js.map +1 -0
- package/dist/src/dashboard/console_authorize.d.ts +98 -0
- package/dist/src/dashboard/console_authorize.d.ts.map +1 -0
- package/dist/src/dashboard/console_authorize.js +163 -0
- package/dist/src/dashboard/console_authorize.js.map +1 -0
- package/dist/src/dashboard/console_shell.d.ts +45 -0
- package/dist/src/dashboard/console_shell.d.ts.map +1 -0
- package/dist/src/dashboard/console_shell.js +125 -0
- package/dist/src/dashboard/console_shell.js.map +1 -0
- package/dist/src/dashboard/console_switcher.d.ts +132 -0
- package/dist/src/dashboard/console_switcher.d.ts.map +1 -0
- package/dist/src/dashboard/console_switcher.js +201 -0
- package/dist/src/dashboard/console_switcher.js.map +1 -0
- package/dist/src/dashboard/define_config.d.ts +68 -81
- package/dist/src/dashboard/define_config.d.ts.map +1 -1
- package/dist/src/dashboard/define_config.js +18 -112
- package/dist/src/dashboard/define_config.js.map +1 -1
- package/dist/src/dashboard/dev_tools.d.ts +102 -0
- package/dist/src/dashboard/dev_tools.d.ts.map +1 -0
- package/dist/src/dashboard/dev_tools.js +502 -0
- package/dist/src/dashboard/dev_tools.js.map +1 -0
- package/dist/src/dashboard/diagnostics-recorder.d.ts +1 -1
- package/dist/src/dashboard/diagnostics-recorder.js +1 -1
- package/dist/src/dashboard/gateway-adapter.d.ts +6 -6
- package/dist/src/dashboard/gateway-adapter.d.ts.map +1 -1
- package/dist/src/dashboard/gateway-adapter.js +5 -5
- package/dist/src/dashboard/gateway-adapter.js.map +1 -1
- package/dist/src/dashboard/handlers.d.ts +48 -39
- package/dist/src/dashboard/handlers.d.ts.map +1 -1
- package/dist/src/dashboard/handlers.js +181 -83
- package/dist/src/dashboard/handlers.js.map +1 -1
- package/dist/src/dashboard/index.d.ts +12 -9
- package/dist/src/dashboard/index.d.ts.map +1 -1
- package/dist/src/dashboard/index.js +10 -7
- package/dist/src/dashboard/index.js.map +1 -1
- package/dist/src/dashboard/list-filters.d.ts +27 -0
- package/dist/src/dashboard/list-filters.d.ts.map +1 -0
- package/dist/src/dashboard/list-filters.js +69 -0
- package/dist/src/dashboard/list-filters.js.map +1 -0
- package/dist/src/dashboard/openapi.d.ts.map +1 -1
- package/dist/src/dashboard/openapi.js +127 -52
- package/dist/src/dashboard/openapi.js.map +1 -1
- package/dist/src/dashboard/run-filter.d.ts +18 -15
- package/dist/src/dashboard/run-filter.d.ts.map +1 -1
- package/dist/src/dashboard/run-filter.js +30 -22
- package/dist/src/dashboard/run-filter.js.map +1 -1
- package/dist/src/dashboard/spa.d.ts +26 -1
- package/dist/src/dashboard/spa.d.ts.map +1 -1
- package/dist/src/dashboard/spa.js +9 -2
- package/dist/src/dashboard/spa.js.map +1 -1
- package/dist/src/dashboard/tenant_scope.d.ts +38 -0
- package/dist/src/dashboard/tenant_scope.d.ts.map +1 -0
- package/dist/src/dashboard/tenant_scope.js +166 -0
- package/dist/src/dashboard/tenant_scope.js.map +1 -0
- package/dist/src/define_config.d.ts +27 -12
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js +9 -4
- package/dist/src/define_config.js.map +1 -1
- package/dist/src/diagnostics/index.d.ts +11 -0
- package/dist/src/diagnostics/index.d.ts.map +1 -0
- package/dist/src/diagnostics/index.js +6 -0
- package/dist/src/diagnostics/index.js.map +1 -0
- package/dist/src/diagnostics/transport.d.ts +71 -0
- package/dist/src/diagnostics/transport.d.ts.map +1 -0
- package/dist/src/diagnostics/transport.js +188 -0
- package/dist/src/diagnostics/transport.js.map +1 -0
- package/dist/src/diagnostics-bridge.d.ts +2 -1
- package/dist/src/diagnostics-bridge.d.ts.map +1 -1
- package/dist/src/diagnostics-bridge.js +7 -1
- package/dist/src/diagnostics-bridge.js.map +1 -1
- package/dist/src/doctor/agora_doctor.d.ts +116 -0
- package/dist/src/doctor/agora_doctor.d.ts.map +1 -0
- package/dist/src/doctor/agora_doctor.js +685 -0
- package/dist/src/doctor/agora_doctor.js.map +1 -0
- package/dist/src/doctor/checks.d.ts +28 -0
- package/dist/src/doctor/checks.d.ts.map +1 -0
- package/dist/src/doctor/checks.js +288 -0
- package/dist/src/doctor/checks.js.map +1 -0
- package/dist/src/doctor/index.d.ts +9 -0
- package/dist/src/doctor/index.d.ts.map +1 -0
- package/dist/src/doctor/index.js +16 -0
- package/dist/src/doctor/index.js.map +1 -0
- package/dist/src/engine.d.ts +55 -9
- package/dist/src/engine.d.ts.map +1 -1
- package/dist/src/engine.js +333 -84
- package/dist/src/engine.js.map +1 -1
- package/dist/src/errors.d.ts +9 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +13 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/event-trigger-bridge.d.ts +5 -14
- package/dist/src/event-trigger-bridge.d.ts.map +1 -1
- package/dist/src/event-trigger-bridge.js +11 -99
- package/dist/src/event-trigger-bridge.js.map +1 -1
- package/dist/src/index.d.ts +8 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/interfaces.d.ts +53 -9
- package/dist/src/interfaces.d.ts.map +1 -1
- package/dist/src/interfaces.js +8 -0
- package/dist/src/interfaces.js.map +1 -1
- package/dist/src/origin.js +3 -3
- package/dist/src/role_bindings.d.ts +8 -8
- package/dist/src/role_bindings.js +8 -8
- package/dist/src/run-gateway/interface.d.ts +4 -3
- package/dist/src/run-gateway/interface.d.ts.map +1 -1
- package/dist/src/run-gateway/proxy-run-gateway.d.ts +4 -2
- package/dist/src/run-gateway/proxy-run-gateway.d.ts.map +1 -1
- package/dist/src/run-gateway/proxy-run-gateway.js +21 -6
- package/dist/src/run-gateway/proxy-run-gateway.js.map +1 -1
- package/dist/src/run-gateway/run-request-responder.d.ts +6 -1
- package/dist/src/run-gateway/run-request-responder.d.ts.map +1 -1
- package/dist/src/run-gateway/run-request-responder.js +30 -3
- package/dist/src/run-gateway/run-request-responder.js.map +1 -1
- package/dist/src/run-gateway/store-run-gateway.d.ts +4 -4
- package/dist/src/run-gateway/store-run-gateway.d.ts.map +1 -1
- package/dist/src/run-gateway/store-run-gateway.js +4 -4
- package/dist/src/run-gateway/store-run-gateway.js.map +1 -1
- package/dist/src/run-gateway/tenant-auth.d.ts +19 -1
- package/dist/src/run-gateway/tenant-auth.d.ts.map +1 -1
- package/dist/src/run-gateway/tenant-auth.js +133 -0
- package/dist/src/run-gateway/tenant-auth.js.map +1 -1
- package/dist/src/run-gateway/tenant-scoped-gateway.d.ts +10 -0
- package/dist/src/run-gateway/tenant-scoped-gateway.d.ts.map +1 -0
- package/dist/src/run-gateway/tenant-scoped-gateway.js +107 -0
- package/dist/src/run-gateway/tenant-scoped-gateway.js.map +1 -0
- package/dist/src/run-value-facets.d.ts +1 -1
- package/dist/src/run-value-facets.d.ts.map +1 -1
- package/dist/src/run-value-facets.js +5 -1
- package/dist/src/run-value-facets.js.map +1 -1
- package/dist/src/scheduler.d.ts.map +1 -1
- package/dist/src/scheduler.js +2 -1
- package/dist/src/scheduler.js.map +1 -1
- package/dist/src/schedules.d.ts +16 -1
- package/dist/src/schedules.d.ts.map +1 -1
- package/dist/src/schedules.js +29 -4
- package/dist/src/schedules.js.map +1 -1
- package/dist/src/services/main.d.ts +3 -3
- package/dist/src/services/main.js +6 -6
- package/dist/src/services/main.js.map +1 -1
- package/dist/src/singleton-admission.d.ts.map +1 -1
- package/dist/src/singleton-admission.js +2 -0
- package/dist/src/singleton-admission.js.map +1 -1
- package/dist/src/singleton-gate.d.ts +1 -1
- package/dist/src/singleton-gate.d.ts.map +1 -1
- package/dist/src/singleton-gate.js +4 -3
- package/dist/src/singleton-gate.js.map +1 -1
- package/dist/src/sql-schema.d.ts +54 -0
- package/dist/src/sql-schema.d.ts.map +1 -0
- package/dist/src/sql-schema.js +145 -0
- package/dist/src/sql-schema.js.map +1 -0
- package/dist/src/stores/factory.d.ts +6 -0
- package/dist/src/stores/factory.d.ts.map +1 -1
- package/dist/src/stores/factory.js +3 -0
- package/dist/src/stores/factory.js.map +1 -1
- package/dist/src/stores/lucid-mappers.d.ts +3 -0
- package/dist/src/stores/lucid-mappers.d.ts.map +1 -1
- package/dist/src/stores/lucid-mappers.js +12 -0
- package/dist/src/stores/lucid-mappers.js.map +1 -1
- package/dist/src/stores/lucid-pg-hot-path.d.ts +6 -2
- package/dist/src/stores/lucid-pg-hot-path.d.ts.map +1 -1
- package/dist/src/stores/lucid-pg-hot-path.js +7 -3
- package/dist/src/stores/lucid-pg-hot-path.js.map +1 -1
- package/dist/src/stores/lucid-schema.d.ts +18 -4
- package/dist/src/stores/lucid-schema.d.ts.map +1 -1
- package/dist/src/stores/lucid-schema.js +106 -61
- package/dist/src/stores/lucid-schema.js.map +1 -1
- package/dist/src/stores/lucid.d.ts +42 -2
- package/dist/src/stores/lucid.d.ts.map +1 -1
- package/dist/src/stores/lucid.js +450 -231
- package/dist/src/stores/lucid.js.map +1 -1
- package/dist/src/tenancy.d.ts +104 -0
- package/dist/src/tenancy.d.ts.map +1 -0
- package/dist/src/tenancy.js +91 -0
- package/dist/src/tenancy.js.map +1 -0
- package/dist/src/testing/in-memory-state-store.d.ts.map +1 -1
- package/dist/src/testing/in-memory-state-store.js +9 -3
- package/dist/src/testing/in-memory-state-store.js.map +1 -1
- package/dist/src/testing-kit/state-store-conformance.d.ts.map +1 -1
- package/dist/src/testing-kit/state-store-conformance.js +59 -0
- package/dist/src/testing-kit/state-store-conformance.js.map +1 -1
- package/dist/src/testing-kit/transport-conformance.d.ts.map +1 -1
- package/dist/src/testing-kit/transport-conformance.js +5 -1
- package/dist/src/testing-kit/transport-conformance.js.map +1 -1
- package/dist/src/transports/bullmq/bullmq-transport.d.ts +1 -1
- package/dist/src/transports/bullmq/bullmq-transport.d.ts.map +1 -1
- package/dist/src/transports/bullmq/bullmq-transport.js +14 -3
- package/dist/src/transports/bullmq/bullmq-transport.js.map +1 -1
- package/dist/src/transports/db-schema.d.ts +13 -5
- package/dist/src/transports/db-schema.d.ts.map +1 -1
- package/dist/src/transports/db-schema.js +52 -27
- package/dist/src/transports/db-schema.js.map +1 -1
- package/dist/src/transports/db.d.ts +6 -0
- package/dist/src/transports/db.d.ts.map +1 -1
- package/dist/src/transports/db.js +91 -42
- package/dist/src/transports/db.js.map +1 -1
- package/dist/src/transports/factory.d.ts +16 -0
- package/dist/src/transports/factory.d.ts.map +1 -1
- package/dist/src/transports/factory.js +6 -1
- package/dist/src/transports/factory.js.map +1 -1
- package/dist/src/transports/queue.d.ts +2 -2
- package/dist/src/transports/queue.d.ts.map +1 -1
- package/dist/src/transports/queue.js +49 -8
- package/dist/src/transports/queue.js.map +1 -1
- package/dist/src/transports/worker-keys-db.d.ts +5 -0
- package/dist/src/transports/worker-keys-db.d.ts.map +1 -1
- package/dist/src/transports/worker-keys-db.js +10 -8
- package/dist/src/transports/worker-keys-db.js.map +1 -1
- package/dist/src/workflow-discovery.d.ts +1 -1
- package/dist/src/workflow-discovery.d.ts.map +1 -1
- package/dist/src/workflow-discovery.js +4 -7
- package/dist/src/workflow-discovery.js.map +1 -1
- package/dist/src/workflow-events.d.ts +20 -51
- package/dist/src/workflow-events.d.ts.map +1 -1
- package/dist/src/workflow-events.js +12 -30
- package/dist/src/workflow-events.js.map +1 -1
- package/dist/src/workflow-ref.d.ts +1 -1
- package/dist/stubs/config/durable_dashboard.stub +9 -29
- package/dist/stubs/database/migrations/create_durable_tables.stub +12 -2
- package/dist/stubs/database/migrations/create_durable_transport_messages.stub +34 -5
- package/dist/stubs/database/migrations/create_durable_transport_tables.stub +30 -8
- package/dist/stubs/database/migrations/create_durable_transport_worker_keys.stub +24 -2
- package/package.json +25 -7
- package/skills/durable-cluster/SKILL.md +43 -23
- package/skills/durable-reliability/SKILL.md +13 -7
- package/dist/assets/spa/assets/index-70hGzOnT.css +0 -1
- package/dist/assets/spa/assets/index-CJjMAUau.js +0 -16
- package/dist/assets/spa/assets/index-CJjMAUau.js.map +0 -1
- package/dist/commands/retry.d.ts +0 -16
- package/dist/commands/retry.d.ts.map +0 -1
- package/dist/commands/retry.js +0 -34
- package/dist/commands/retry.js.map +0 -1
- package/dist/src/dashboard/auth.d.ts +0 -134
- package/dist/src/dashboard/auth.d.ts.map +0 -1
- package/dist/src/dashboard/auth.js +0 -156
- package/dist/src/dashboard/auth.js.map +0 -1
- package/dist/src/dashboard/login_page.d.ts +0 -36
- package/dist/src/dashboard/login_page.d.ts.map +0 -1
- package/dist/src/dashboard/login_page.js +0 -158
- package/dist/src/dashboard/login_page.js.map +0 -1
- package/dist/src/dashboard/session_cookie.d.ts +0 -45
- package/dist/src/dashboard/session_cookie.d.ts.map +0 -1
- package/dist/src/dashboard/session_cookie.js +0 -97
- package/dist/src/dashboard/session_cookie.js.map +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { HttpContext } from '@adonisjs/core/http';
|
|
2
|
+
/** The container binding the registry lives at. */
|
|
3
|
+
export declare const AGORA_CONSOLES_BINDING = "agora.consoles";
|
|
4
|
+
/** Bound as a VALUE under `'agora.consoles'`. Data only. */
|
|
5
|
+
export interface AgoraConsoleRegistry {
|
|
6
|
+
readonly version: 1;
|
|
7
|
+
readonly entries: AgoraConsoleEntry[];
|
|
8
|
+
/**
|
|
9
|
+
* Optional, set by an account console (authkit): how a viewer signs out of the app. Every console
|
|
10
|
+
* reads it structurally to offer "Sign out" in its sidebar footer. A string is a POST action path.
|
|
11
|
+
*/
|
|
12
|
+
account?: {
|
|
13
|
+
signOut?: string | {
|
|
14
|
+
action: string;
|
|
15
|
+
} | {
|
|
16
|
+
href: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** The icon a console shows in the switcher. An unknown value renders as `generic`. */
|
|
21
|
+
export type AgoraConsoleIcon = 'workflow' | 'telescope' | 'media' | 'payments' | 'agent' | 'identity' | 'generic';
|
|
22
|
+
/** One hit of a console's global search. */
|
|
23
|
+
export interface AgoraConsoleSearchHit {
|
|
24
|
+
title: string;
|
|
25
|
+
subtitle?: string;
|
|
26
|
+
/** Same-origin absolute path (`/durable#/run/42`). */
|
|
27
|
+
href: string;
|
|
28
|
+
}
|
|
29
|
+
/** One console the switcher can list. */
|
|
30
|
+
export interface AgoraConsoleEntry {
|
|
31
|
+
/** `/^[a-z][a-z0-9-]*$/`: `'durable'`, `'telescope'`, … */
|
|
32
|
+
id: string;
|
|
33
|
+
/** Product title: `'Workflows'`, `'Telescope'`, `'Identity'`. */
|
|
34
|
+
title: string;
|
|
35
|
+
/** The package behind it, shown under the title (`'@adonis-agora/durable'`). */
|
|
36
|
+
package?: string;
|
|
37
|
+
icon: AgoraConsoleIcon;
|
|
38
|
+
/** Same-origin absolute path of the console shell (`/durable`). */
|
|
39
|
+
path: string;
|
|
40
|
+
/** Sort key: durable 10, telescope 20, agent 30, payments 40, media 50, authkit 90. */
|
|
41
|
+
order: number;
|
|
42
|
+
/** The console's RESOLVED gate (the function its own routes call). Never throws. */
|
|
43
|
+
authorize(ctx: HttpContext): Promise<{
|
|
44
|
+
allowed: boolean;
|
|
45
|
+
reason?: string;
|
|
46
|
+
redirectTo?: string;
|
|
47
|
+
}>;
|
|
48
|
+
/** Global search over this console's data, for a viewer this console already allowed. */
|
|
49
|
+
search?(ctx: HttpContext, q: string, limit: number): Promise<AgoraConsoleSearchHit[]>;
|
|
50
|
+
}
|
|
51
|
+
/** One console as the switcher endpoint returns it. */
|
|
52
|
+
export interface VisibleConsole {
|
|
53
|
+
id: string;
|
|
54
|
+
title: string;
|
|
55
|
+
package?: string;
|
|
56
|
+
icon: AgoraConsoleIcon;
|
|
57
|
+
href: string;
|
|
58
|
+
}
|
|
59
|
+
/** The answer of `GET <console api>/consoles`. */
|
|
60
|
+
export interface VisibleConsoles {
|
|
61
|
+
version: 1;
|
|
62
|
+
current: string;
|
|
63
|
+
consoles: VisibleConsole[];
|
|
64
|
+
}
|
|
65
|
+
/** The answer of `GET <console api>/consoles/search?q=`. */
|
|
66
|
+
export interface ConsoleSearchResults {
|
|
67
|
+
version: 1;
|
|
68
|
+
q: string;
|
|
69
|
+
results: Array<{
|
|
70
|
+
id: string;
|
|
71
|
+
title: string;
|
|
72
|
+
icon: AgoraConsoleIcon;
|
|
73
|
+
hits: AgoraConsoleSearchHit[];
|
|
74
|
+
}>;
|
|
75
|
+
}
|
|
76
|
+
/** How long another console's `authorize` (or `search`) may take before it is left out. */
|
|
77
|
+
export declare const PROBE_TIMEOUT_MS = 300;
|
|
78
|
+
/** Hits per console in a global search. */
|
|
79
|
+
export declare const SEARCH_HITS_PER_CONSOLE = 5;
|
|
80
|
+
/** Whether `path` is a same-origin absolute path (`/x`, never `//host` or a URL). */
|
|
81
|
+
export declare function isSameOriginPath(path: unknown): path is string;
|
|
82
|
+
interface ContainerLike {
|
|
83
|
+
hasBinding(binding: string): boolean;
|
|
84
|
+
bindValue(binding: string, value: unknown): void;
|
|
85
|
+
make(binding: string): Promise<unknown>;
|
|
86
|
+
}
|
|
87
|
+
interface LoggerLike {
|
|
88
|
+
warn(message: string): void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Add a console to the app's switcher registry, creating the registry when this is the first
|
|
92
|
+
* console to boot. Consoles call it from their provider's `boot()`; an app can call it too, for a
|
|
93
|
+
* console it mounts itself. A registry of another version is left alone; a duplicate id is skipped
|
|
94
|
+
* with a warning. Returns whether the entry was added.
|
|
95
|
+
*/
|
|
96
|
+
export declare function registerAgoraConsole(container: ContainerLike, entry: AgoraConsoleEntry, logger?: LoggerLike): Promise<boolean>;
|
|
97
|
+
/** The registry, when one is bound with a version this copy reads. */
|
|
98
|
+
export declare function readAgoraConsoles(container: Pick<ContainerLike, 'hasBinding' | 'make'>): Promise<AgoraConsoleRegistry | undefined>;
|
|
99
|
+
/** How many consoles other than `selfId` are registered (no `authorize` runs). */
|
|
100
|
+
export declare function otherConsoles(registry: AgoraConsoleRegistry | undefined, selfId: string): number;
|
|
101
|
+
/**
|
|
102
|
+
* The consoles other than `selfId` the viewer may open: every other entry's `authorize` runs in
|
|
103
|
+
* parallel, each given {@link PROBE_TIMEOUT_MS}; a timeout, a rejection or any denial hides it. No
|
|
104
|
+
* reason is ever returned.
|
|
105
|
+
*/
|
|
106
|
+
export declare function listVisibleConsoles(registry: AgoraConsoleRegistry | undefined, selfId: string, ctx: HttpContext, timeoutMs?: number): Promise<VisibleConsoles>;
|
|
107
|
+
/**
|
|
108
|
+
* Global search: `q` goes to every console the viewer may open that has a `search` (this one
|
|
109
|
+
* included, the viewer is already in it), in parallel, {@link PROBE_TIMEOUT_MS} each, at most
|
|
110
|
+
* {@link SEARCH_HITS_PER_CONSOLE} same-origin hits per console. Consoles with no hit are left out.
|
|
111
|
+
*/
|
|
112
|
+
export declare function searchConsoles(registry: AgoraConsoleRegistry | undefined, selfId: string, ctx: HttpContext, q: string, timeoutMs?: number): Promise<ConsoleSearchResults>;
|
|
113
|
+
/** What {@link durableConsoleSearch} reads: a run by id, and workflow names with their counts. */
|
|
114
|
+
export interface DurableSearchSource {
|
|
115
|
+
getRun(id: string): Promise<{
|
|
116
|
+
id: string;
|
|
117
|
+
workflow: string;
|
|
118
|
+
status: string;
|
|
119
|
+
} | null>;
|
|
120
|
+
/** Workflow names containing `q`, with their run counts. */
|
|
121
|
+
workflows(q: string, limit: number): Promise<Array<{
|
|
122
|
+
value: string | null;
|
|
123
|
+
count: number;
|
|
124
|
+
}>>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The durable console's global search: an exact run id opens that run, and workflow names that
|
|
128
|
+
* contain `q` open the workflow's page. `base` is the console's mount path (`''` at the root).
|
|
129
|
+
*/
|
|
130
|
+
export declare function durableConsoleSearch(source: (ctx: HttpContext) => Promise<DurableSearchSource>, base: string): (ctx: HttpContext, q: string, limit: number) => Promise<AgoraConsoleSearchHit[]>;
|
|
131
|
+
export {};
|
|
132
|
+
//# sourceMappingURL=console_switcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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E,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;CAC9F;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,mBAAmB,CAAC,EAC1D,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAyBlF"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The console switcher registry, version 1, declared here STRUCTURALLY: every `@adonis-agora`
|
|
3
|
+
* console declares the same shapes and binds the same plain value at `'agora.consoles'` when it is
|
|
4
|
+
* the first to boot. No lib imports another; whichever copy creates the registry, the others append
|
|
5
|
+
* to it.
|
|
6
|
+
*/
|
|
7
|
+
/** The container binding the registry lives at. */
|
|
8
|
+
export const AGORA_CONSOLES_BINDING = 'agora.consoles';
|
|
9
|
+
const ID = /^[a-z][a-z0-9-]*$/;
|
|
10
|
+
const ICONS = new Set([
|
|
11
|
+
'workflow',
|
|
12
|
+
'telescope',
|
|
13
|
+
'media',
|
|
14
|
+
'payments',
|
|
15
|
+
'agent',
|
|
16
|
+
'identity',
|
|
17
|
+
'generic',
|
|
18
|
+
]);
|
|
19
|
+
/** How long another console's `authorize` (or `search`) may take before it is left out. */
|
|
20
|
+
export const PROBE_TIMEOUT_MS = 300;
|
|
21
|
+
/** Hits per console in a global search. */
|
|
22
|
+
export const SEARCH_HITS_PER_CONSOLE = 5;
|
|
23
|
+
/** Whether `path` is a same-origin absolute path (`/x`, never `//host` or a URL). */
|
|
24
|
+
export function isSameOriginPath(path) {
|
|
25
|
+
return typeof path === 'string' && path.startsWith('/') && !path.startsWith('//');
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Add a console to the app's switcher registry, creating the registry when this is the first
|
|
29
|
+
* console to boot. Consoles call it from their provider's `boot()`; an app can call it too, for a
|
|
30
|
+
* console it mounts itself. A registry of another version is left alone; a duplicate id is skipped
|
|
31
|
+
* with a warning. Returns whether the entry was added.
|
|
32
|
+
*/
|
|
33
|
+
export async function registerAgoraConsole(container, entry, logger) {
|
|
34
|
+
if (!ID.test(entry.id)) {
|
|
35
|
+
throw new Error(`[@adonis-agora/durable] console id ${JSON.stringify(entry.id)} is invalid`);
|
|
36
|
+
}
|
|
37
|
+
if (!isSameOriginPath(entry.path)) {
|
|
38
|
+
throw new Error(`[@adonis-agora/durable] console path ${JSON.stringify(entry.path)} must start with a single "/"`);
|
|
39
|
+
}
|
|
40
|
+
if (!container.hasBinding(AGORA_CONSOLES_BINDING)) {
|
|
41
|
+
const fresh = { version: 1, entries: [] };
|
|
42
|
+
container.bindValue(AGORA_CONSOLES_BINDING, fresh);
|
|
43
|
+
}
|
|
44
|
+
const registry = (await container.make(AGORA_CONSOLES_BINDING));
|
|
45
|
+
if (registry?.version !== 1 || !Array.isArray(registry.entries))
|
|
46
|
+
return false;
|
|
47
|
+
if (registry.entries.some((existing) => existing.id === entry.id)) {
|
|
48
|
+
logger?.warn(`[@adonis-agora/durable] console id "${entry.id}" already registered`);
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
registry.entries.push(entry);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
/** The registry, when one is bound with a version this copy reads. */
|
|
55
|
+
export async function readAgoraConsoles(container) {
|
|
56
|
+
if (!container.hasBinding(AGORA_CONSOLES_BINDING))
|
|
57
|
+
return undefined;
|
|
58
|
+
const registry = (await container.make(AGORA_CONSOLES_BINDING));
|
|
59
|
+
if (registry?.version !== 1 || !Array.isArray(registry.entries))
|
|
60
|
+
return undefined;
|
|
61
|
+
return registry;
|
|
62
|
+
}
|
|
63
|
+
/** How many consoles other than `selfId` are registered (no `authorize` runs). */
|
|
64
|
+
export function otherConsoles(registry, selfId) {
|
|
65
|
+
return registry ? registry.entries.filter((entry) => entry.id !== selfId).length : 0;
|
|
66
|
+
}
|
|
67
|
+
/** `work`, or `fallback` when it rejects or takes longer than `ms`. */
|
|
68
|
+
async function within(work, ms, fallback) {
|
|
69
|
+
let timer;
|
|
70
|
+
const timeout = new Promise((resolve) => {
|
|
71
|
+
timer = setTimeout(() => resolve(fallback), ms);
|
|
72
|
+
});
|
|
73
|
+
try {
|
|
74
|
+
return await Promise.race([
|
|
75
|
+
Promise.resolve()
|
|
76
|
+
.then(work)
|
|
77
|
+
.catch(() => fallback),
|
|
78
|
+
timeout,
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
finally {
|
|
82
|
+
if (timer !== undefined)
|
|
83
|
+
clearTimeout(timer);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Run `fn` with the probe marker on `ctx`: an `authorize` that writes an audit trail can read
|
|
88
|
+
* `ctx.agoraProbe === true` and skip it, since the switcher only asks, it does not open anything.
|
|
89
|
+
*/
|
|
90
|
+
async function probing(ctx, fn) {
|
|
91
|
+
const marked = ctx;
|
|
92
|
+
const previous = marked.agoraProbe;
|
|
93
|
+
marked.agoraProbe = true;
|
|
94
|
+
try {
|
|
95
|
+
return await fn();
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
if (previous === undefined)
|
|
99
|
+
delete marked.agoraProbe;
|
|
100
|
+
else
|
|
101
|
+
marked.agoraProbe = previous;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function sorted(entries) {
|
|
105
|
+
return [...entries].sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));
|
|
106
|
+
}
|
|
107
|
+
async function allowedEntries(entries, ctx, timeoutMs) {
|
|
108
|
+
const verdicts = await probing(ctx, () => Promise.all(entries.map((entry) => within(async () => (await entry.authorize(ctx)).allowed === true, timeoutMs, false))));
|
|
109
|
+
return entries.filter((_, index) => verdicts[index]);
|
|
110
|
+
}
|
|
111
|
+
function iconOf(icon) {
|
|
112
|
+
return ICONS.has(icon) ? icon : 'generic';
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The consoles other than `selfId` the viewer may open: every other entry's `authorize` runs in
|
|
116
|
+
* parallel, each given {@link PROBE_TIMEOUT_MS}; a timeout, a rejection or any denial hides it. No
|
|
117
|
+
* reason is ever returned.
|
|
118
|
+
*/
|
|
119
|
+
export async function listVisibleConsoles(registry, selfId, ctx, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
120
|
+
const others = registry
|
|
121
|
+
? sorted(registry.entries.filter((entry) => entry.id !== selfId && isSameOriginPath(entry.path)))
|
|
122
|
+
: [];
|
|
123
|
+
const allowed = await allowedEntries(others, ctx, timeoutMs);
|
|
124
|
+
return {
|
|
125
|
+
version: 1,
|
|
126
|
+
current: selfId,
|
|
127
|
+
consoles: allowed.map((entry) => ({
|
|
128
|
+
id: entry.id,
|
|
129
|
+
title: entry.title,
|
|
130
|
+
...(entry.package !== undefined ? { package: entry.package } : {}),
|
|
131
|
+
icon: iconOf(entry.icon),
|
|
132
|
+
href: entry.path,
|
|
133
|
+
})),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Global search: `q` goes to every console the viewer may open that has a `search` (this one
|
|
138
|
+
* included, the viewer is already in it), in parallel, {@link PROBE_TIMEOUT_MS} each, at most
|
|
139
|
+
* {@link SEARCH_HITS_PER_CONSOLE} same-origin hits per console. Consoles with no hit are left out.
|
|
140
|
+
*/
|
|
141
|
+
export async function searchConsoles(registry, selfId, ctx, q, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
142
|
+
const query = q.trim().slice(0, 200);
|
|
143
|
+
if (!registry || query === '')
|
|
144
|
+
return { version: 1, q: query, results: [] };
|
|
145
|
+
const searchable = sorted(registry.entries.filter((entry) => typeof entry.search === 'function' && isSameOriginPath(entry.path)));
|
|
146
|
+
const self = searchable.filter((entry) => entry.id === selfId);
|
|
147
|
+
const others = await allowedEntries(searchable.filter((entry) => entry.id !== selfId), ctx, timeoutMs);
|
|
148
|
+
const targets = sorted([...self, ...others]);
|
|
149
|
+
const hits = await probing(ctx, () => Promise.all(targets.map((entry) => within(async () => (await entry.search?.(ctx, query, SEARCH_HITS_PER_CONSOLE)) ?? [], timeoutMs, []))));
|
|
150
|
+
const results = [];
|
|
151
|
+
targets.forEach((entry, index) => {
|
|
152
|
+
const safe = (hits[index] ?? [])
|
|
153
|
+
.filter((hit) => typeof hit === 'object' &&
|
|
154
|
+
hit !== null &&
|
|
155
|
+
typeof hit.title === 'string' &&
|
|
156
|
+
isSameOriginPath(hit.href))
|
|
157
|
+
.slice(0, SEARCH_HITS_PER_CONSOLE)
|
|
158
|
+
.map((hit) => ({
|
|
159
|
+
title: hit.title,
|
|
160
|
+
...(typeof hit.subtitle === 'string' ? { subtitle: hit.subtitle } : {}),
|
|
161
|
+
href: hit.href,
|
|
162
|
+
}));
|
|
163
|
+
if (safe.length > 0) {
|
|
164
|
+
results.push({ id: entry.id, title: entry.title, icon: iconOf(entry.icon), hits: safe });
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
return { version: 1, q: query, results };
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The durable console's global search: an exact run id opens that run, and workflow names that
|
|
171
|
+
* contain `q` open the workflow's page. `base` is the console's mount path (`''` at the root).
|
|
172
|
+
*/
|
|
173
|
+
export function durableConsoleSearch(source, base) {
|
|
174
|
+
const shell = base === '' ? '/' : base;
|
|
175
|
+
return async (ctx, q, limit) => {
|
|
176
|
+
const reader = await source(ctx);
|
|
177
|
+
const hits = [];
|
|
178
|
+
const run = await reader.getRun(q).catch(() => null);
|
|
179
|
+
if (run) {
|
|
180
|
+
hits.push({
|
|
181
|
+
title: run.id,
|
|
182
|
+
subtitle: `run · ${run.workflow} · ${run.status}`,
|
|
183
|
+
href: `${shell}#/run/${encodeURIComponent(run.id)}`,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
const rows = await reader.workflows(q, limit).catch(() => []);
|
|
187
|
+
for (const row of rows) {
|
|
188
|
+
if (hits.length >= limit)
|
|
189
|
+
break;
|
|
190
|
+
if (row.value === null)
|
|
191
|
+
continue;
|
|
192
|
+
hits.push({
|
|
193
|
+
title: row.value,
|
|
194
|
+
subtitle: `workflow · ${row.count} ${row.count === 1 ? 'run' : 'runs'}`,
|
|
195
|
+
href: `${shell}#/workflow/${encodeURIComponent(row.value)}`,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
return hits.slice(0, limit);
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=console_switcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console_switcher.js","sourceRoot":"","sources":["../../../src/dashboard/console_switcher.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,mDAAmD;AACnD,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AA8EvD,MAAM,EAAE,GAAG,mBAAmB,CAAC;AAC/B,MAAM,KAAK,GAAG,IAAI,GAAG,CAAmB;IACtC,UAAU;IACV,WAAW;IACX,OAAO;IACP,UAAU;IACV,OAAO;IACP,UAAU;IACV,SAAS;CACV,CAAC,CAAC;AACH,2FAA2F;AAC3F,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,2CAA2C;AAC3C,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC,qFAAqF;AACrF,MAAM,UAAU,gBAAgB,CAAC,IAAa;IAC5C,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACpF,CAAC;AAYD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,SAAwB,EACxB,KAAwB,EACxB,MAAmB;IAEnB,IAAI,CA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,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,GAAG,EAAE,CAAC;YACR,IAAI,CAAC,IAAI,CAAC;gBACR,KAAK,EAAE,GAAG,CAAC,EAAE;gBACb,QAAQ,EAAE,SAAS,GAAG,CAAC,QAAQ,MAAM,GAAG,CAAC,MAAM,EAAE;gBACjD,IAAI,EAAE,GAAG,KAAK,SAAS,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;aACpD,CAAC,CAAC;QACL,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9D,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK;gBAAE,MAAM;YAChC,IAAI,GAAG,CAAC,KAAK,KAAK,IAAI;gBAAE,SAAS;YACjC,IAAI,CAAC,IAAI,CAAC;gBACR,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,QAAQ,EAAE,cAAc,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE;gBACvE,IAAI,EAAE,GAAG,KAAK,cAAc,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;aAC5D,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { HttpContext } from '@adonisjs/core/http';
|
|
2
2
|
import type { AccessDeniedOption as GenericAccessDeniedOption, AccessDeniedRenderer as GenericAccessDeniedRenderer } from './access_denied_page.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type ConsoleAuthorize, type ConsoleAuthorizeGate, type ConsoleAuthorizeResult, type ConsoleDecision } from './console_authorize.js';
|
|
4
|
+
import type { ConsoleViewer, SignOutOption, ViewerHook } from './console_shell.js';
|
|
4
5
|
/**
|
|
5
6
|
* The function form of {@link DurableDashboardConfig.accessDenied}: render (or answer) a refused
|
|
6
7
|
* page navigation yourself. Receives the refusal ({@link AccessDeniedInfo}) and the AdonisJS
|
|
@@ -15,41 +16,28 @@ export type AccessDeniedOption = GenericAccessDeniedOption<HttpContext>;
|
|
|
15
16
|
* A structured answer from an {@link AuthorizeHook}: whether the request may proceed and, when it may
|
|
16
17
|
* not, why. The `reason` picks the status: `'unauthenticated'` (nobody is signed in) → `401`,
|
|
17
18
|
* `'forbidden'` (signed in, not allowed) → `403`. No reason → `403` (fail closed).
|
|
18
|
-
*
|
|
19
|
-
* This is the shared Agora dashboard-gate contract — the same shape every `@adonis-agora` console
|
|
20
|
-
* accepts, so one hook (e.g. `@adonis-agora/authz`'s `authorizeByRoles`) can gate them all.
|
|
21
19
|
*/
|
|
22
20
|
export interface AuthorizeDecision {
|
|
23
21
|
allowed: boolean;
|
|
24
22
|
reason?: 'unauthenticated' | 'forbidden';
|
|
25
23
|
}
|
|
26
|
-
/** What an {@link AuthorizeHook} may return: a bare boolean or an {@link AuthorizeDecision}. */
|
|
27
|
-
export type AuthorizeResult = boolean | AuthorizeDecision;
|
|
28
24
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* access-denied page, or `{ error: 'forbidden' }`).
|
|
37
|
-
*
|
|
38
|
-
* A hook that THROWS is a denial (`403`), never a pass. A hook that answers the request itself — a
|
|
39
|
-
* redirect to the host's login page, most commonly — keeps its answer: the provider writes nothing
|
|
40
|
-
* over it.
|
|
41
|
-
*
|
|
42
|
-
* It receives the AdonisJS {@link HttpContext}, so it can read the session,
|
|
43
|
-
* a bearer token, an IP allow-list, etc.
|
|
25
|
+
* What an {@link AuthorizeHook} may return: the shared {@link ConsoleAuthorizeResult} (a boolean,
|
|
26
|
+
* a decision, or `{ redirectTo }`) or an {@link AuthorizeDecision}.
|
|
27
|
+
*/
|
|
28
|
+
export type AuthorizeResult = ConsoleAuthorizeResult | AuthorizeDecision;
|
|
29
|
+
/**
|
|
30
|
+
* The function form of `authorize`. It receives the AdonisJS {@link HttpContext}, so it can read the
|
|
31
|
+
* session, a bearer token, an IP allow-list, etc. May be async.
|
|
44
32
|
*/
|
|
45
33
|
export type AuthorizeHook = (ctx: HttpContext) => AuthorizeResult | Promise<AuthorizeResult>;
|
|
46
34
|
/**
|
|
47
35
|
* Collapse an {@link AuthorizeResult} into a decision. Only `true` or an object with
|
|
48
|
-
* `allowed === true` allows
|
|
49
|
-
*
|
|
50
|
-
*
|
|
36
|
+
* `allowed === true` allows; `{ redirectTo }` is an unauthenticated denial carrying the redirect
|
|
37
|
+
* target; anything else — `false`, `{ allowed: false }`, a truthy non-boolean, a missing value —
|
|
38
|
+
* denies with `403`.
|
|
51
39
|
*/
|
|
52
|
-
export declare function normalizeAuthorizeResult(result: unknown):
|
|
40
|
+
export declare function normalizeAuthorizeResult(result: unknown): ConsoleDecision;
|
|
53
41
|
/** Shape of `config/durable_dashboard.ts`. */
|
|
54
42
|
export interface DurableDashboardConfig {
|
|
55
43
|
/**
|
|
@@ -64,39 +52,17 @@ export interface DurableDashboardConfig {
|
|
|
64
52
|
*/
|
|
65
53
|
path?: string;
|
|
66
54
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* session guard is then the gate) or {@link allowUnauthenticated} explicitly opts out.
|
|
55
|
+
* Who may reach the console. Runs before every dashboard route (API + HTML). Takes the shared
|
|
56
|
+
* {@link ConsoleAuthorize} contract — an inline function, an authorizer class (resolved through the
|
|
57
|
+
* container, so `@inject()` works), or a lazy import of one (`() => import('#policies/console_access')`).
|
|
58
|
+
* It returns a boolean, `{ allowed, reason? }` (`reason: 'unauthenticated'` → `401`, any other
|
|
59
|
+
* denial `403`) or `{ redirectTo }` (`302` for a page, `401` for an API call). A throw is a `403`.
|
|
73
60
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*/
|
|
78
|
-
authorize?: AuthorizeHook;
|
|
79
|
-
/**
|
|
80
|
-
* Explicitly serve the dashboard WITHOUT any authentication. This is the loaded footgun the old
|
|
81
|
-
* "open outside production" default was — now it at least has to be spelled out in config, so a
|
|
82
|
-
* deploy can grep for it. Only for local development / networks you fully trust. Ignored when
|
|
83
|
-
* `authorize` or `dashboardAuth` is configured.
|
|
61
|
+
* Omitted, the console is open when the app is not in production and answers `403` to every
|
|
62
|
+
* request in production (a warning is logged once at boot). For machine access use
|
|
63
|
+
* `authorizeByToken({ token })`.
|
|
84
64
|
*/
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Optional built-in login screen. When set, the provider mounts a
|
|
88
|
-
* server-rendered `GET <path>/login` page plus `POST <path>/login` /
|
|
89
|
-
* `GET <path>/logout`, and stamps a session guard on the dashboard: an
|
|
90
|
-
* unauthenticated page navigation is redirected (`302`) to the login page and
|
|
91
|
-
* an unauthenticated API request gets `401`. The signed session cookie is
|
|
92
|
-
* minted only by the host's {@link DashboardAuthOptions.login} hook.
|
|
93
|
-
*
|
|
94
|
-
* This is ADDITIVE and composes WITH {@link authorize} (both must pass) — it
|
|
95
|
-
* does not replace it. Omit it entirely to keep today's behavior byte-for-byte
|
|
96
|
-
* (no login/logout routes, no session guard). Missing `secret`/`login` fails
|
|
97
|
-
* closed at boot.
|
|
98
|
-
*/
|
|
99
|
-
dashboardAuth?: DashboardAuthOptions;
|
|
65
|
+
authorize?: ConsoleAuthorize | AuthorizeHook;
|
|
100
66
|
/**
|
|
101
67
|
* Audit sink for MUTATING console actions (retry, cancel, bulk, fix-and-replay, signal, update,
|
|
102
68
|
* task completion, schedule control): called once per attempt with who did what, before the
|
|
@@ -117,26 +83,39 @@ export interface DurableDashboardConfig {
|
|
|
117
83
|
};
|
|
118
84
|
/**
|
|
119
85
|
* What a BROWSER sees when the guard refuses a page navigation (the SPA shell, its assets, or —
|
|
120
|
-
*
|
|
86
|
+
* nothing else). API requests are unaffected:
|
|
121
87
|
* they keep getting the JSON the SPA relies on (`403 { error: 'forbidden' }` /
|
|
122
|
-
* `401 { error: '
|
|
88
|
+
* `401 { error: 'unauthenticated' }`).
|
|
123
89
|
*
|
|
124
90
|
* Omit it for the built-in page — a dark card in the console's own visual language, with the
|
|
125
|
-
* status, a sentence explaining the refusal
|
|
126
|
-
* exists, a "Sign in" button. Pass an object to tweak that page (`brand`, `title`, `message`,
|
|
91
|
+
* status, a sentence explaining the refusal and a "Back to app" link. Pass an object to tweak that page (`brand`, `title`, `message`,
|
|
127
92
|
* `homeHref`, `loginHref`, `accent`, …), or a function to render/answer it yourself — see
|
|
128
93
|
* {@link AccessDeniedRenderer}. Either way, an `authorize` hook that already wrote a redirect
|
|
129
94
|
* still wins: the provider never overwrites a `location` header.
|
|
130
95
|
*/
|
|
131
96
|
accessDenied?: AccessDeniedOption;
|
|
97
|
+
/**
|
|
98
|
+
* Who the console's sidebar footer shows as signed in. Omit it to read `ctx.auth.user`
|
|
99
|
+
* structurally (`fullName`/`name`/`email`, first of `role`/`roles`) when the request is already
|
|
100
|
+
* authenticated; return `null` for no user row. A throw is treated as `null`.
|
|
101
|
+
*/
|
|
102
|
+
viewer?: ViewerHook;
|
|
103
|
+
/**
|
|
104
|
+
* The footer's "Sign out": a POST action path (`'/logout'`, sent with the CSRF token), `{ href }`
|
|
105
|
+
* for a plain link, or `false` for none. Omit it to use the sign-out an account console (authkit)
|
|
106
|
+
* announces on the `agora.consoles` registry, when there is one. Same-origin paths only.
|
|
107
|
+
*/
|
|
108
|
+
signOut?: SignOutOption;
|
|
132
109
|
}
|
|
110
|
+
export type { ConsoleViewer, SignOutOption, ViewerHook };
|
|
133
111
|
/** A fully-resolved config — every field present (defaults applied). */
|
|
134
112
|
export interface ResolvedDurableDashboardConfig {
|
|
135
113
|
enabled: boolean;
|
|
136
114
|
path: string;
|
|
137
|
-
authorize:
|
|
138
|
-
|
|
139
|
-
|
|
115
|
+
/** The resolved `authorize` gate (or the default): one call per request, never throws. */
|
|
116
|
+
authorize: ConsoleAuthorizeGate;
|
|
117
|
+
/** Whether the host set `authorize` (`false` means the dev-open / production-deny default). */
|
|
118
|
+
authorizeConfigured: boolean;
|
|
140
119
|
/** The host's `accessDenied` option as given, or `null` for the built-in page with defaults. */
|
|
141
120
|
accessDenied: AccessDeniedOption | null;
|
|
142
121
|
/** The host's audit sink, or `null` for the default logger line. */
|
|
@@ -146,33 +125,41 @@ export interface ResolvedDurableDashboardConfig {
|
|
|
146
125
|
run?: (run: Record<string, unknown>) => Record<string, unknown>;
|
|
147
126
|
checkpoint?: (checkpoint: Record<string, unknown>) => Record<string, unknown>;
|
|
148
127
|
} | null;
|
|
128
|
+
/** The host's `viewer` hook, or `null` for the structural `ctx.auth.user` read. */
|
|
129
|
+
viewer: ViewerHook | null;
|
|
130
|
+
/** The host's `signOut` option, or `null` for the registry's announced one. */
|
|
131
|
+
signOut: SignOutOption | null;
|
|
149
132
|
}
|
|
150
133
|
/** One audited mutating console action — who (actor), what (method + path), when. */
|
|
151
134
|
export interface DashboardAuditEntry {
|
|
152
135
|
at: Date;
|
|
153
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* The signed-in user (`ctx.auth.user`'s `email`, `name` or `id`), `'bearer'` for a caller with an
|
|
138
|
+
* `Authorization` header and no user, else `'anonymous'`. An action run from a developer tool
|
|
139
|
+
* over MCP is `'mcp:<caller>'` (`mcp:token:3f9a1c2b7d10`, `mcp:user:42`); one run from an ace
|
|
140
|
+
* command is `'cli:<os user>'` (or `'cli'`).
|
|
141
|
+
*/
|
|
154
142
|
actor: string;
|
|
143
|
+
/** The HTTP method, `'MCP'` for a developer tool, or `'CLI'` for an ace command. */
|
|
155
144
|
method: string;
|
|
156
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* The request path (no query string), `'<tool> <run id or schedule key>'` for a developer tool, or
|
|
147
|
+
* `'<command> <target>'` for an ace command (`durable:runs:cancel ord-42`).
|
|
148
|
+
*/
|
|
157
149
|
path: string;
|
|
158
150
|
}
|
|
159
|
-
/**
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
* NODE_ENV branch anymore: "not production" is exactly the set of deployments (dev boxes,
|
|
170
|
-
* staging, misspelled envs) that used to ship an open console. Opt out explicitly with
|
|
171
|
-
* `allowUnauthenticated: true`, or configure `dashboardAuth`/your own `authorize`.
|
|
172
|
-
*/
|
|
173
|
-
export declare function defaultAuthorize(ctx: HttpContext): boolean;
|
|
151
|
+
/** The warning logged once at boot when `authorize` is omitted. */
|
|
152
|
+
export declare const NO_AUTHORIZE_WARNING = "[@adonis-agora/durable] console has no `authorize` configured: it is open outside production and denies every request in production. Set `authorize` in config/durable_dashboard.ts.";
|
|
153
|
+
/** Options for {@link resolveConfig}. */
|
|
154
|
+
export interface ResolveConfigOptions {
|
|
155
|
+
/**
|
|
156
|
+
* Whether the app runs in production (`app.inProduction`). Only `false` opens a console without
|
|
157
|
+
* `authorize`; anything else denies it.
|
|
158
|
+
*/
|
|
159
|
+
inProduction?: boolean;
|
|
160
|
+
}
|
|
174
161
|
/** Apply defaults to a partial config, producing a fully-resolved one. */
|
|
175
|
-
export declare function resolveConfig(config?: DurableDashboardConfig): ResolvedDurableDashboardConfig;
|
|
162
|
+
export declare function resolveConfig(config?: DurableDashboardConfig, options?: ResolveConfigOptions): ResolvedDurableDashboardConfig;
|
|
176
163
|
/** Identity helper giving `config/durable_dashboard.ts` full type-checking. */
|
|
177
164
|
export declare function defineConfig(config?: DurableDashboardConfig): DurableDashboardConfig;
|
|
178
165
|
//# sourceMappingURL=define_config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define_config.d.ts","sourceRoot":"","sources":["../../../src/dashboard/define_config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"define_config.d.ts","sourceRoot":"","sources":["../../../src/dashboard/define_config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EACV,kBAAkB,IAAI,yBAAyB,EAC/C,oBAAoB,IAAI,2BAA2B,EACpD,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EAGrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEnF;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,2BAA2B,CAAC,WAAW,CAAC,CAAC;AAE5E,8FAA8F;AAC9F,MAAM,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,WAAW,CAAC,CAAC;AAExE;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,iBAAiB,GAAG,WAAW,CAAC;CAC1C;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,sBAAsB,GAAG,iBAAiB,CAAC;AAEzE;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,WAAW,KAAK,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAE7F;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,eAAe,CAEzE;AAED,8CAA8C;AAC9C,MAAM,WAAW,sBAAsB;IACrC;;;OAGG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