@dudousxd/nestjs-durable-dashboard 0.56.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -88,6 +88,12 @@ declare class ConsoleAccessDenied extends HttpException {
88
88
  allowed: false;
89
89
  }>, page: boolean);
90
90
  }
91
+ /**
92
+ * Marks a console route that is not part of the console: `authorize` does not apply to it. Used on
93
+ * the `ctx.webhook()` callback, which third parties call with the token as the secret.
94
+ */
95
+ declare const CONSOLE_PUBLIC_METADATA = "@dudousxd/nestjs-durable-dashboard:console-public";
96
+ declare const ConsolePublic: () => MethodDecorator;
91
97
  declare class ConsoleAuthorizeGuard implements CanActivate {
92
98
  private readonly decide;
93
99
  constructor(decide: ConsoleDecide);
@@ -422,9 +428,9 @@ declare class DurableApiControllerBase {
422
428
  }>;
423
429
  /**
424
430
  * Public callback endpoint for `ctx.webhook()`: a third party POSTs here (the url handed to it),
425
- * and the body resumes the waiting run. NOTE: this is reachable by external systems — protect it
426
- * by treating the token as a secret (it embeds runId:seq) and/or fronting it with signature
427
- * verification in your own middleware.
431
+ * and the body resumes the waiting run. Not a console route: the console's `authorize` does not
432
+ * apply, the token is the secret. The app's `decorators` still do. Treat the token as a secret
433
+ * and/or front it with signature verification in your own middleware.
428
434
  */
429
435
  webhook(token: string, body: unknown): Promise<_dudousxd_nestjs_durable_core.RunResult>;
430
436
  /** Live query: the latest value a run published for `key` via `ctx.setEvent` (no side effect). */
@@ -443,7 +449,9 @@ declare class DurableApiController extends DurableApiControllerBase {
443
449
 
444
450
  interface DurableDashboardOptions {
445
451
  /**
446
- * Who may use the console (the SPA, its JSON API, the run stream and the webhook route). One of:
452
+ * Who may use the console (the SPA, its JSON API and the run stream). Not the `ctx.webhook()`
453
+ * callback (`POST <apiBasePath>/webhooks/:token`), which third parties call with the token as the
454
+ * secret; {@link decorators} still apply to it. One of:
447
455
  *
448
456
  * - a function `(context) => boolean | { allowed } | { redirectTo }` (may be async);
449
457
  * - an `@Injectable()` class implementing {@link ConsoleAuthorizer} (constructor injection works;
@@ -588,4 +596,4 @@ declare class DurableUiControllerBase {
588
596
  declare class DurableUiController extends DurableUiControllerBase {
589
597
  }
590
598
 
591
- export { CONSOLE_AUTHORIZE_DECIDE, CONSOLE_AUTHORIZE_MISSING_WARNING, CONSOLE_GATE, CONSOLE_PAGE_METADATA, ConsoleAccessDenied, type ConsoleAuthorize, ConsoleAuthorizeFilter, ConsoleAuthorizeGuard, type ConsoleAuthorizeResult, type ConsoleAuthorizer, type ConsoleAuthorizerClass, type ConsoleDecide, type ConsoleDecision, type ConsoleGate, ConsolePage, type ConsolePolicyCheck, DASHBOARD_API_PATH, DASHBOARD_BASE_PATH, DashboardService, DurableApiController, DurableApiControllerBase, DurableApiModule, DurableDashboardModule, type DurableDashboardOptions, DurableUiController, DurableUiControllerBase, UseConsoleAuthorize, type WorkflowLifecyclePage, authorizeByToken, normalizeConsoleResult, resolveConsoleAuthorize };
599
+ export { CONSOLE_AUTHORIZE_DECIDE, CONSOLE_AUTHORIZE_MISSING_WARNING, CONSOLE_GATE, CONSOLE_PAGE_METADATA, CONSOLE_PUBLIC_METADATA, ConsoleAccessDenied, type ConsoleAuthorize, ConsoleAuthorizeFilter, ConsoleAuthorizeGuard, type ConsoleAuthorizeResult, type ConsoleAuthorizer, type ConsoleAuthorizerClass, type ConsoleDecide, type ConsoleDecision, type ConsoleGate, ConsolePage, type ConsolePolicyCheck, ConsolePublic, DASHBOARD_API_PATH, DASHBOARD_BASE_PATH, DashboardService, DurableApiController, DurableApiControllerBase, DurableApiModule, DurableDashboardModule, type DurableDashboardOptions, DurableUiController, DurableUiControllerBase, UseConsoleAuthorize, type WorkflowLifecyclePage, authorizeByToken, normalizeConsoleResult, resolveConsoleAuthorize };
@@ -88,6 +88,12 @@ declare class ConsoleAccessDenied extends HttpException {
88
88
  allowed: false;
89
89
  }>, page: boolean);
90
90
  }
91
+ /**
92
+ * Marks a console route that is not part of the console: `authorize` does not apply to it. Used on
93
+ * the `ctx.webhook()` callback, which third parties call with the token as the secret.
94
+ */
95
+ declare const CONSOLE_PUBLIC_METADATA = "@dudousxd/nestjs-durable-dashboard:console-public";
96
+ declare const ConsolePublic: () => MethodDecorator;
91
97
  declare class ConsoleAuthorizeGuard implements CanActivate {
92
98
  private readonly decide;
93
99
  constructor(decide: ConsoleDecide);
@@ -422,9 +428,9 @@ declare class DurableApiControllerBase {
422
428
  }>;
423
429
  /**
424
430
  * Public callback endpoint for `ctx.webhook()`: a third party POSTs here (the url handed to it),
425
- * and the body resumes the waiting run. NOTE: this is reachable by external systems — protect it
426
- * by treating the token as a secret (it embeds runId:seq) and/or fronting it with signature
427
- * verification in your own middleware.
431
+ * and the body resumes the waiting run. Not a console route: the console's `authorize` does not
432
+ * apply, the token is the secret. The app's `decorators` still do. Treat the token as a secret
433
+ * and/or front it with signature verification in your own middleware.
428
434
  */
429
435
  webhook(token: string, body: unknown): Promise<_dudousxd_nestjs_durable_core.RunResult>;
430
436
  /** Live query: the latest value a run published for `key` via `ctx.setEvent` (no side effect). */
@@ -443,7 +449,9 @@ declare class DurableApiController extends DurableApiControllerBase {
443
449
 
444
450
  interface DurableDashboardOptions {
445
451
  /**
446
- * Who may use the console (the SPA, its JSON API, the run stream and the webhook route). One of:
452
+ * Who may use the console (the SPA, its JSON API and the run stream). Not the `ctx.webhook()`
453
+ * callback (`POST <apiBasePath>/webhooks/:token`), which third parties call with the token as the
454
+ * secret; {@link decorators} still apply to it. One of:
447
455
  *
448
456
  * - a function `(context) => boolean | { allowed } | { redirectTo }` (may be async);
449
457
  * - an `@Injectable()` class implementing {@link ConsoleAuthorizer} (constructor injection works;
@@ -588,4 +596,4 @@ declare class DurableUiControllerBase {
588
596
  declare class DurableUiController extends DurableUiControllerBase {
589
597
  }
590
598
 
591
- export { CONSOLE_AUTHORIZE_DECIDE, CONSOLE_AUTHORIZE_MISSING_WARNING, CONSOLE_GATE, CONSOLE_PAGE_METADATA, ConsoleAccessDenied, type ConsoleAuthorize, ConsoleAuthorizeFilter, ConsoleAuthorizeGuard, type ConsoleAuthorizeResult, type ConsoleAuthorizer, type ConsoleAuthorizerClass, type ConsoleDecide, type ConsoleDecision, type ConsoleGate, ConsolePage, type ConsolePolicyCheck, DASHBOARD_API_PATH, DASHBOARD_BASE_PATH, DashboardService, DurableApiController, DurableApiControllerBase, DurableApiModule, DurableDashboardModule, type DurableDashboardOptions, DurableUiController, DurableUiControllerBase, UseConsoleAuthorize, type WorkflowLifecyclePage, authorizeByToken, normalizeConsoleResult, resolveConsoleAuthorize };
599
+ export { CONSOLE_AUTHORIZE_DECIDE, CONSOLE_AUTHORIZE_MISSING_WARNING, CONSOLE_GATE, CONSOLE_PAGE_METADATA, CONSOLE_PUBLIC_METADATA, ConsoleAccessDenied, type ConsoleAuthorize, ConsoleAuthorizeFilter, ConsoleAuthorizeGuard, type ConsoleAuthorizeResult, type ConsoleAuthorizer, type ConsoleAuthorizerClass, type ConsoleDecide, type ConsoleDecision, type ConsoleGate, ConsolePage, type ConsolePolicyCheck, ConsolePublic, DASHBOARD_API_PATH, DASHBOARD_BASE_PATH, DashboardService, DurableApiController, DurableApiControllerBase, DurableApiModule, DurableDashboardModule, type DurableDashboardOptions, DurableUiController, DurableUiControllerBase, UseConsoleAuthorize, type WorkflowLifecyclePage, authorizeByToken, normalizeConsoleResult, resolveConsoleAuthorize };
@@ -239,6 +239,10 @@ var ConsoleAccessDenied = class extends HttpException {
239
239
  }, unauthenticated2 ? 401 : 403), this.decision = decision, this.page = page;
240
240
  }
241
241
  };
242
+ var CONSOLE_PUBLIC_METADATA = `${PACKAGE}:console-public`;
243
+ var ConsolePublic = /* @__PURE__ */ __name(() => (_target, _key, descriptor) => {
244
+ Reflect.defineMetadata(CONSOLE_PUBLIC_METADATA, true, descriptor.value);
245
+ }, "ConsolePublic");
242
246
  var ConsoleAuthorizeGuard = class {
243
247
  static {
244
248
  __name(this, "ConsoleAuthorizeGuard");
@@ -248,6 +252,7 @@ var ConsoleAuthorizeGuard = class {
248
252
  this.decide = decide;
249
253
  }
250
254
  async canActivate(context) {
255
+ if (Reflect.getMetadata(CONSOLE_PUBLIC_METADATA, context.getHandler()) === true) return true;
251
256
  const decision = await this.decide(context);
252
257
  if (decision.allowed) return true;
253
258
  throw new ConsoleAccessDenied(decision, isPageNavigation(context));
@@ -308,7 +313,7 @@ var UseConsoleAuthorize = /* @__PURE__ */ __name(() => applyDecorators(UseGuards
308
313
 
309
314
  // src/server/dashboard.service.ts
310
315
  import { RunGateway, STATE_STORE_CANONICAL, TERMINAL_RUN_STATUSES, WorkflowEngine, collectMetrics, parseWebhookToken } from "@dudousxd/nestjs-durable-core";
311
- import { Inject as Inject2, Injectable as Injectable2, Optional } from "@nestjs/common";
316
+ import { Inject as Inject2, Injectable as Injectable2, NotImplementedException, Optional } from "@nestjs/common";
312
317
  import { Observable } from "rxjs";
313
318
  function _ts_decorate2(decorators, target, key, desc) {
314
319
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -360,7 +365,7 @@ var DashboardService = class {
360
365
  */
361
366
  controlPlane() {
362
367
  if (!this.store || !this.engine) {
363
- throw new Error("This durable dashboard operation requires the control plane (not available on a tenant deployment).");
368
+ throw new NotImplementedException("This durable dashboard operation requires the control plane (not available on a tenant deployment).");
364
369
  }
365
370
  return {
366
371
  store: this.store,
@@ -624,7 +629,7 @@ DashboardService = _ts_decorate2([
624
629
 
625
630
  // src/server/durable-api.controller.ts
626
631
  import { ApplyFilter, ApplyFilterInterceptor, FilterRunner } from "@dudousxd/nestjs-filter";
627
- import { BadRequestException as BadRequestException2, Body, Controller, Get, Header, Headers, NotFoundException, NotImplementedException, Param, Post, Query, Res, Sse, UseFilters as UseFilters2, UseInterceptors } from "@nestjs/common";
632
+ import { BadRequestException as BadRequestException2, Body, Controller, Get, Header, Headers, NotFoundException, NotImplementedException as NotImplementedException2, Param, Post, Query, Res, Sse, UseFilters as UseFilters2, UseInterceptors } from "@nestjs/common";
628
633
 
629
634
  // src/server/durable-run.ts
630
635
  var DurableRun = class {
@@ -1502,7 +1507,7 @@ var DurableApiControllerBase = class {
1502
1507
  */
1503
1508
  async workflowLifecycle(name) {
1504
1509
  const links = await this.dashboard.workflowLifecycle(name).catch(notSupportedByServer);
1505
- if (!links) throw new NotImplementedException("workflow lifecycle links need the control plane");
1510
+ if (!links) throw new NotImplementedException2("workflow lifecycle links need the control plane");
1506
1511
  return links;
1507
1512
  }
1508
1513
  /** This deployment's durable role (control plane vs tenant) + tenant name — for the header badge. */
@@ -1598,7 +1603,7 @@ var DurableApiControllerBase = class {
1598
1603
  return notSupportedByServer(error);
1599
1604
  }
1600
1605
  if (!result) {
1601
- throw new NotImplementedException("republishing lifecycle events needs the control plane");
1606
+ throw new NotImplementedException2("republishing lifecycle events needs the control plane");
1602
1607
  }
1603
1608
  return result;
1604
1609
  }
@@ -1615,9 +1620,9 @@ var DurableApiControllerBase = class {
1615
1620
  }
1616
1621
  /**
1617
1622
  * Public callback endpoint for `ctx.webhook()`: a third party POSTs here (the url handed to it),
1618
- * and the body resumes the waiting run. NOTE: this is reachable by external systems — protect it
1619
- * by treating the token as a secret (it embeds runId:seq) and/or fronting it with signature
1620
- * verification in your own middleware.
1623
+ * and the body resumes the waiting run. Not a console route: the console's `authorize` does not
1624
+ * apply, the token is the secret. The app's `decorators` still do. Treat the token as a secret
1625
+ * and/or front it with signature verification in your own middleware.
1621
1626
  */
1622
1627
  async webhook(token, body) {
1623
1628
  const result = await this.dashboard.deliverWebhook(token, body);
@@ -1855,6 +1860,7 @@ _ts_decorate6([
1855
1860
  _ts_metadata5("design:returntype", Promise)
1856
1861
  ], DurableApiControllerBase.prototype, "redispatch", null);
1857
1862
  _ts_decorate6([
1863
+ ConsolePublic(),
1858
1864
  Post("webhooks/:token"),
1859
1865
  _ts_param3(0, Param("token")),
1860
1866
  _ts_param3(1, Body()),
@@ -1908,7 +1914,7 @@ function notFound(error) {
1908
1914
  __name(notFound, "notFound");
1909
1915
  function notSupportedByServer(error) {
1910
1916
  if (error?.code === "unsupported-request") {
1911
- throw new NotImplementedException(error instanceof Error ? error.message : String(error));
1917
+ throw new NotImplementedException2(error instanceof Error ? error.message : String(error));
1912
1918
  }
1913
1919
  throw error;
1914
1920
  }
@@ -2283,10 +2289,12 @@ export {
2283
2289
  CONSOLE_AUTHORIZE_MISSING_WARNING,
2284
2290
  CONSOLE_GATE,
2285
2291
  CONSOLE_PAGE_METADATA,
2292
+ CONSOLE_PUBLIC_METADATA,
2286
2293
  ConsoleAccessDenied,
2287
2294
  ConsoleAuthorizeFilter,
2288
2295
  ConsoleAuthorizeGuard,
2289
2296
  ConsolePage,
2297
+ ConsolePublic,
2290
2298
  DASHBOARD_API_PATH,
2291
2299
  DASHBOARD_BASE_PATH,
2292
2300
  DashboardService,