@dudousxd/nestjs-durable-dashboard 0.55.1 → 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.
@@ -1,10 +1,11 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
- // src/server/dashboard.service.ts
5
- import { RunGateway, STATE_STORE_CANONICAL, TERMINAL_RUN_STATUSES, WorkflowEngine, collectMetrics, parseWebhookToken } from "@dudousxd/nestjs-durable-core";
6
- import { Inject, Injectable, Optional } from "@nestjs/common";
7
- import { Observable } from "rxjs";
4
+ // src/server/console-authorize.ts
5
+ import "reflect-metadata";
6
+ import { createHash, timingSafeEqual } from "node:crypto";
7
+ import { Catch, HttpException, Inject, Injectable, Logger, UseFilters, UseGuards, applyDecorators } from "@nestjs/common";
8
+ import { HttpAdapterHost } from "@nestjs/core";
8
9
  function _ts_decorate(decorators, target, key, desc) {
9
10
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
10
11
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
@@ -31,6 +32,315 @@ function _ts_param(paramIndex, decorator) {
31
32
  };
32
33
  }
33
34
  __name(_ts_param, "_ts_param");
35
+ var CONSOLE_GATE = Symbol.for("@dudousxd/aviary:console-gate");
36
+ var PACKAGE = "@dudousxd/nestjs-durable-dashboard";
37
+ var MODULE = "DurableDashboardModule";
38
+ var CONSOLE_AUTHORIZE_MISSING_WARNING = `[${PACKAGE}] console has no \`authorize\` configured: it is open outside production and denies every request in production. Set \`authorize\` in ${MODULE}.forRoot().`;
39
+ var allow = /* @__PURE__ */ __name(() => ({
40
+ allowed: true
41
+ }), "allow");
42
+ var forbidden = /* @__PURE__ */ __name(() => ({
43
+ allowed: false,
44
+ reason: "forbidden"
45
+ }), "forbidden");
46
+ var unauthenticated = /* @__PURE__ */ __name(() => ({
47
+ allowed: false,
48
+ reason: "unauthenticated"
49
+ }), "unauthenticated");
50
+ function isProduction() {
51
+ return (process.env.NODE_ENV ?? "").trim().toLowerCase() === "production";
52
+ }
53
+ __name(isProduction, "isProduction");
54
+ function isAuthorizerClass(value) {
55
+ if (typeof value !== "function") return false;
56
+ if (typeof value.prototype?.authorize === "function") {
57
+ return true;
58
+ }
59
+ return /^class[\s{]/.test(Function.prototype.toString.call(value));
60
+ }
61
+ __name(isAuthorizerClass, "isAuthorizerClass");
62
+ function isPolicyCheck(value) {
63
+ return typeof value === "object" && value !== null && typeof value.policy === "function" && typeof value.ability === "string";
64
+ }
65
+ __name(isPolicyCheck, "isPolicyCheck");
66
+ function isLazyModule(value) {
67
+ return typeof value === "object" && value !== null && isAuthorizerClass(value.default);
68
+ }
69
+ __name(isLazyModule, "isLazyModule");
70
+ function normalizeConsoleResult(result) {
71
+ if (result === true) return allow();
72
+ if (typeof result !== "object" || result === null) return forbidden();
73
+ const shape = result;
74
+ if (typeof shape.redirectTo === "string" && shape.allowed !== true) {
75
+ return {
76
+ allowed: false,
77
+ reason: "unauthenticated",
78
+ redirectTo: shape.redirectTo
79
+ };
80
+ }
81
+ if (shape.allowed === true) return allow();
82
+ return shape.reason === "unauthenticated" ? unauthenticated() : forbidden();
83
+ }
84
+ __name(normalizeConsoleResult, "normalizeConsoleResult");
85
+ function hasUser(user) {
86
+ return user !== null && user !== void 0 && user !== false;
87
+ }
88
+ __name(hasUser, "hasUser");
89
+ async function policyDecider(check, moduleRef) {
90
+ let pkg;
91
+ try {
92
+ pkg = await import("@nestjs/authorization");
93
+ } catch {
94
+ throw new Error(`${MODULE}: \`authorize: { policy, ability }\` needs @nestjs/authorization installed, with AuthorizationModule.forRoot() imported in the app; or pass a function, a class, or a gate name.`);
95
+ }
96
+ const { AuthorizationService, AUTHORIZATION_MODULE_OPTIONS, defaultGetUser } = pkg;
97
+ try {
98
+ moduleRef.get(AuthorizationService, {
99
+ strict: false
100
+ });
101
+ } catch {
102
+ throw new Error(`${MODULE}: \`authorize: { policy, ability }\` needs AuthorizationModule.forRoot() from @nestjs/authorization imported in the app.`);
103
+ }
104
+ let getUser = defaultGetUser;
105
+ try {
106
+ const options = moduleRef.get(AUTHORIZATION_MODULE_OPTIONS, {
107
+ strict: false
108
+ });
109
+ if (typeof options?.getUser === "function") getUser = options.getUser;
110
+ } catch {
111
+ }
112
+ return async (context) => {
113
+ const authorization = moduleRef.get(AuthorizationService, {
114
+ strict: false
115
+ });
116
+ const user = await getUser(context);
117
+ const can = authorization.can;
118
+ if (await can.call(authorization, check.policy, check.ability, hasUser(user) ? user : null)) {
119
+ return allow();
120
+ }
121
+ return hasUser(user) ? forbidden() : unauthenticated();
122
+ };
123
+ }
124
+ __name(policyDecider, "policyDecider");
125
+ function gateDecider(name, moduleRef) {
126
+ try {
127
+ moduleRef.get(CONSOLE_GATE, {
128
+ strict: false
129
+ });
130
+ } catch {
131
+ throw new Error(`\`authorize: '${name}'\` needs @dudousxd/nestjs-authz's AuthzModule (it resolves gate names); or pass a function, a class, or { policy, ability }`);
132
+ }
133
+ return async (context) => {
134
+ const gate = moduleRef.get(CONSOLE_GATE, {
135
+ strict: false
136
+ });
137
+ return normalizeConsoleResult(await gate.allows(name, context));
138
+ };
139
+ }
140
+ __name(gateDecider, "gateDecider");
141
+ function classDecider(moduleRef) {
142
+ const instances = /* @__PURE__ */ new Map();
143
+ const instanceOf = /* @__PURE__ */ __name((Class) => {
144
+ const cached = instances.get(Class);
145
+ if (cached) return cached;
146
+ const pending = (async () => {
147
+ try {
148
+ const registered = moduleRef.get(Class, {
149
+ strict: false
150
+ });
151
+ if (registered) return registered;
152
+ } catch {
153
+ }
154
+ return moduleRef.create(Class);
155
+ })();
156
+ pending.catch(() => instances.delete(Class));
157
+ instances.set(Class, pending);
158
+ return pending;
159
+ }, "instanceOf");
160
+ return (Class) => async (context) => normalizeConsoleResult(await (await instanceOf(Class)).authorize(context));
161
+ }
162
+ __name(classDecider, "classDecider");
163
+ async function resolveConsoleAuthorize(authorize, moduleRef, options = {}) {
164
+ const logger = options.logger ?? new Logger(MODULE);
165
+ if (authorize === void 0) {
166
+ if (options.warnIfMissing !== false) logger.warn(CONSOLE_AUTHORIZE_MISSING_WARNING);
167
+ const production = isProduction();
168
+ return async () => production ? forbidden() : allow();
169
+ }
170
+ let decide;
171
+ if (typeof authorize === "string") {
172
+ decide = gateDecider(authorize, moduleRef);
173
+ } else if (isPolicyCheck(authorize)) {
174
+ decide = await policyDecider(authorize, moduleRef);
175
+ } else if (isAuthorizerClass(authorize)) {
176
+ decide = classDecider(moduleRef)(authorize);
177
+ } else if (typeof authorize === "function") {
178
+ const fromClass = classDecider(moduleRef);
179
+ let lazy;
180
+ const fn = authorize;
181
+ decide = /* @__PURE__ */ __name(async (context) => {
182
+ if (lazy) return lazy(context);
183
+ const result = await fn(context);
184
+ if (!isLazyModule(result)) return normalizeConsoleResult(result);
185
+ lazy = fromClass(result.default);
186
+ return lazy(context);
187
+ }, "decide");
188
+ } else {
189
+ throw new Error(`${MODULE}: \`authorize\` must be a function, a class with authorize(), a lazy import, { policy, ability } or a gate name.`);
190
+ }
191
+ return async (context) => {
192
+ try {
193
+ return await decide(context);
194
+ } catch (error) {
195
+ logger.warn(`console \`authorize\` threw, denying the request: ${error instanceof Error ? error.message : String(error)}`);
196
+ return forbidden();
197
+ }
198
+ };
199
+ }
200
+ __name(resolveConsoleAuthorize, "resolveConsoleAuthorize");
201
+ var sha256 = /* @__PURE__ */ __name((value) => createHash("sha256").update(value).digest(), "sha256");
202
+ function authorizeByToken(options) {
203
+ const token = options.token;
204
+ if (typeof token !== "string" || token.length === 0) {
205
+ throw new Error("authorizeByToken: `token` is empty; set it (e.g. from an env var).");
206
+ }
207
+ const expected = sha256(token);
208
+ return (context) => {
209
+ const header = context.switchToHttp().getRequest()?.headers?.authorization;
210
+ const match = typeof header === "string" ? /^Bearer\s+(.+)$/i.exec(header.trim()) : null;
211
+ if (match?.[1] && timingSafeEqual(sha256(match[1]), expected)) return true;
212
+ return {
213
+ allowed: false,
214
+ reason: "unauthenticated"
215
+ };
216
+ };
217
+ }
218
+ __name(authorizeByToken, "authorizeByToken");
219
+ var CONSOLE_AUTHORIZE_DECIDE = Symbol(`${PACKAGE}:console-authorize`);
220
+ var CONSOLE_PAGE_METADATA = `${PACKAGE}:console-page`;
221
+ var ConsolePage = /* @__PURE__ */ __name(() => (target) => {
222
+ Reflect.defineMetadata(CONSOLE_PAGE_METADATA, true, target);
223
+ }, "ConsolePage");
224
+ var ConsoleAccessDenied = class extends HttpException {
225
+ static {
226
+ __name(this, "ConsoleAccessDenied");
227
+ }
228
+ decision;
229
+ page;
230
+ constructor(decision, page) {
231
+ const unauthenticated2 = decision.reason === "unauthenticated";
232
+ super(unauthenticated2 ? {
233
+ error: "unauthenticated",
234
+ ...decision.redirectTo ? {
235
+ redirectTo: decision.redirectTo
236
+ } : {}
237
+ } : {
238
+ error: "forbidden"
239
+ }, unauthenticated2 ? 401 : 403), this.decision = decision, this.page = page;
240
+ }
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");
246
+ var ConsoleAuthorizeGuard = class {
247
+ static {
248
+ __name(this, "ConsoleAuthorizeGuard");
249
+ }
250
+ decide;
251
+ constructor(decide) {
252
+ this.decide = decide;
253
+ }
254
+ async canActivate(context) {
255
+ if (Reflect.getMetadata(CONSOLE_PUBLIC_METADATA, context.getHandler()) === true) return true;
256
+ const decision = await this.decide(context);
257
+ if (decision.allowed) return true;
258
+ throw new ConsoleAccessDenied(decision, isPageNavigation(context));
259
+ }
260
+ };
261
+ ConsoleAuthorizeGuard = _ts_decorate([
262
+ Injectable(),
263
+ _ts_param(0, Inject(CONSOLE_AUTHORIZE_DECIDE)),
264
+ _ts_metadata("design:type", Function),
265
+ _ts_metadata("design:paramtypes", [
266
+ typeof ConsoleDecide === "undefined" ? Object : ConsoleDecide
267
+ ])
268
+ ], ConsoleAuthorizeGuard);
269
+ function isPageNavigation(context) {
270
+ if (context.getType() !== "http") return false;
271
+ if (Reflect.getMetadata(CONSOLE_PAGE_METADATA, context.getClass()) !== true) return false;
272
+ const request = context.switchToHttp().getRequest();
273
+ const accept = request?.headers?.accept;
274
+ return request?.method === "GET" && typeof accept === "string" && accept.includes("text/html");
275
+ }
276
+ __name(isPageNavigation, "isPageNavigation");
277
+ var consolePage = /* @__PURE__ */ __name((title, message) => `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${title}</title></head><body style="font-family:system-ui,sans-serif;display:grid;place-items:center;min-height:100vh;margin:0"><main style="text-align:center"><h1>${title}</h1><p>${message}</p></main></body></html>`, "consolePage");
278
+ var DENIED_PAGE = consolePage("Access denied", "You do not have access to this console.");
279
+ var SIGN_IN_PAGE = consolePage("Sign in required", "Sign in to open this console.");
280
+ var ConsoleAuthorizeFilter = class {
281
+ static {
282
+ __name(this, "ConsoleAuthorizeFilter");
283
+ }
284
+ adapterHost;
285
+ constructor(adapterHost) {
286
+ this.adapterHost = adapterHost;
287
+ }
288
+ catch(exception, host) {
289
+ const adapter = this.adapterHost.httpAdapter;
290
+ const response = host.switchToHttp().getResponse();
291
+ const { decision, page } = exception;
292
+ if (page && decision.redirectTo) {
293
+ adapter.redirect(response, 302, decision.redirectTo);
294
+ return;
295
+ }
296
+ if (page) {
297
+ const forbiddenPage = decision.reason === "forbidden";
298
+ adapter.setHeader(response, "Content-Type", "text/html; charset=utf-8");
299
+ adapter.reply(response, forbiddenPage ? DENIED_PAGE : SIGN_IN_PAGE, forbiddenPage ? 403 : 401);
300
+ return;
301
+ }
302
+ adapter.reply(response, exception.getResponse(), exception.getStatus());
303
+ }
304
+ };
305
+ ConsoleAuthorizeFilter = _ts_decorate([
306
+ Catch(ConsoleAccessDenied),
307
+ _ts_metadata("design:type", Function),
308
+ _ts_metadata("design:paramtypes", [
309
+ typeof HttpAdapterHost === "undefined" ? Object : HttpAdapterHost
310
+ ])
311
+ ], ConsoleAuthorizeFilter);
312
+ var UseConsoleAuthorize = /* @__PURE__ */ __name(() => applyDecorators(UseGuards(ConsoleAuthorizeGuard), UseFilters(ConsoleAuthorizeFilter)), "UseConsoleAuthorize");
313
+
314
+ // src/server/dashboard.service.ts
315
+ import { RunGateway, STATE_STORE_CANONICAL, TERMINAL_RUN_STATUSES, WorkflowEngine, collectMetrics, parseWebhookToken } from "@dudousxd/nestjs-durable-core";
316
+ import { Inject as Inject2, Injectable as Injectable2, NotImplementedException, Optional } from "@nestjs/common";
317
+ import { Observable } from "rxjs";
318
+ function _ts_decorate2(decorators, target, key, desc) {
319
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
320
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
321
+ r = Reflect.decorate(decorators, target, key, desc);
322
+ } else {
323
+ for (var i = decorators.length - 1; i >= 0; i--) {
324
+ if (d = decorators[i]) {
325
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
326
+ }
327
+ }
328
+ }
329
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
330
+ }
331
+ __name(_ts_decorate2, "_ts_decorate");
332
+ function _ts_metadata2(metadataKey, metadataValue) {
333
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
334
+ return Reflect.metadata(metadataKey, metadataValue);
335
+ }
336
+ }
337
+ __name(_ts_metadata2, "_ts_metadata");
338
+ function _ts_param2(paramIndex, decorator) {
339
+ return function(target, key) {
340
+ decorator(target, key, paramIndex);
341
+ };
342
+ }
343
+ __name(_ts_param2, "_ts_param");
34
344
  var DashboardService = class {
35
345
  static {
36
346
  __name(this, "DashboardService");
@@ -55,7 +365,7 @@ var DashboardService = class {
55
365
  */
56
366
  controlPlane() {
57
367
  if (!this.store || !this.engine) {
58
- 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).");
59
369
  }
60
370
  return {
61
371
  store: this.store,
@@ -304,13 +614,13 @@ var DashboardService = class {
304
614
  });
305
615
  }
306
616
  };
307
- DashboardService = _ts_decorate([
308
- Injectable(),
309
- _ts_param(1, Optional()),
310
- _ts_param(1, Inject(STATE_STORE_CANONICAL)),
311
- _ts_param(2, Optional()),
312
- _ts_metadata("design:type", Function),
313
- _ts_metadata("design:paramtypes", [
617
+ DashboardService = _ts_decorate2([
618
+ Injectable2(),
619
+ _ts_param2(1, Optional()),
620
+ _ts_param2(1, Inject2(STATE_STORE_CANONICAL)),
621
+ _ts_param2(2, Optional()),
622
+ _ts_metadata2("design:type", Function),
623
+ _ts_metadata2("design:paramtypes", [
314
624
  typeof RunGateway === "undefined" ? Object : RunGateway,
315
625
  typeof StateStore === "undefined" ? Object : StateStore,
316
626
  typeof WorkflowEngine === "undefined" ? Object : WorkflowEngine
@@ -319,7 +629,7 @@ DashboardService = _ts_decorate([
319
629
 
320
630
  // src/server/durable-api.controller.ts
321
631
  import { ApplyFilter, ApplyFilterInterceptor, FilterRunner } from "@dudousxd/nestjs-filter";
322
- import { BadRequestException as BadRequestException2, Body, Controller, Get, Header, Headers, NotFoundException, NotImplementedException, Param, Post, Query, Res, Sse, UseFilters, 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";
323
633
 
324
634
  // src/server/durable-run.ts
325
635
  var DurableRun = class {
@@ -395,8 +705,8 @@ function runValueAxisFor(field) {
395
705
  __name(runValueAxisFor, "runValueAxisFor");
396
706
 
397
707
  // src/server/not-modified.ts
398
- import { Catch, HttpException } from "@nestjs/common";
399
- function _ts_decorate2(decorators, target, key, desc) {
708
+ import { Catch as Catch2, HttpException as HttpException2 } from "@nestjs/common";
709
+ function _ts_decorate3(decorators, target, key, desc) {
400
710
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
401
711
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
402
712
  r = Reflect.decorate(decorators, target, key, desc);
@@ -409,7 +719,7 @@ function _ts_decorate2(decorators, target, key, desc) {
409
719
  }
410
720
  return c > 3 && r && Object.defineProperty(target, key, r), r;
411
721
  }
412
- __name(_ts_decorate2, "_ts_decorate");
722
+ __name(_ts_decorate3, "_ts_decorate");
413
723
  function isRawResponse(value) {
414
724
  if (typeof value !== "object" || value === null) return false;
415
725
  const candidate = value;
@@ -435,7 +745,7 @@ function writeNotModifiedRaw(response, etag) {
435
745
  raw.end();
436
746
  }
437
747
  __name(writeNotModifiedRaw, "writeNotModifiedRaw");
438
- var NotModifiedException = class extends HttpException {
748
+ var NotModifiedException = class extends HttpException2 {
439
749
  static {
440
750
  __name(this, "NotModifiedException");
441
751
  }
@@ -452,8 +762,8 @@ var NotModifiedFilter = class {
452
762
  writeNotModifiedRaw(host.switchToHttp().getResponse(), exception.etag);
453
763
  }
454
764
  };
455
- NotModifiedFilter = _ts_decorate2([
456
- Catch(NotModifiedException)
765
+ NotModifiedFilter = _ts_decorate3([
766
+ Catch2(NotModifiedException)
457
767
  ], NotModifiedFilter);
458
768
  function setEtag(response, etag) {
459
769
  setRawHeader(response, "etag", etag);
@@ -470,7 +780,7 @@ __name(toRunListRow, "toRunListRow");
470
780
 
471
781
  // src/server/run.filter.ts
472
782
  import { BaseFilter, FilterFor, Filterable } from "@dudousxd/nestjs-filter";
473
- import { Injectable as Injectable3 } from "@nestjs/common";
783
+ import { Injectable as Injectable4 } from "@nestjs/common";
474
784
 
475
785
  // src/server/attr-filter.ts
476
786
  var SCALAR_OPS = /* @__PURE__ */ new Set([
@@ -521,7 +831,7 @@ __name(parseAttrFilters, "parseAttrFilters");
521
831
 
522
832
  // src/server/run-query.adapter.ts
523
833
  import { RUN_VALUE_FACET_LIMIT, RunGateway as RunGateway2 } from "@dudousxd/nestjs-durable-core";
524
- import { BadRequestException, Injectable as Injectable2 } from "@nestjs/common";
834
+ import { BadRequestException, Injectable as Injectable3 } from "@nestjs/common";
525
835
 
526
836
  // src/server/run-query-draft.ts
527
837
  var RunQueryDraft2 = class {
@@ -551,7 +861,7 @@ var RunQueryDraft2 = class {
551
861
  };
552
862
 
553
863
  // src/server/run-query.adapter.ts
554
- function _ts_decorate3(decorators, target, key, desc) {
864
+ function _ts_decorate4(decorators, target, key, desc) {
555
865
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
556
866
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
557
867
  r = Reflect.decorate(decorators, target, key, desc);
@@ -564,13 +874,13 @@ function _ts_decorate3(decorators, target, key, desc) {
564
874
  }
565
875
  return c > 3 && r && Object.defineProperty(target, key, r), r;
566
876
  }
567
- __name(_ts_decorate3, "_ts_decorate");
568
- function _ts_metadata2(metadataKey, metadataValue) {
877
+ __name(_ts_decorate4, "_ts_decorate");
878
+ function _ts_metadata3(metadataKey, metadataValue) {
569
879
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
570
880
  return Reflect.metadata(metadataKey, metadataValue);
571
881
  }
572
882
  }
573
- __name(_ts_metadata2, "_ts_metadata");
883
+ __name(_ts_metadata3, "_ts_metadata");
574
884
  var RUN_QUERY_ADAPTER = Symbol("DURABLE_RUN_QUERY_ADAPTER");
575
885
  var FIXED_ORDER = {
576
886
  field: "createdAt",
@@ -844,16 +1154,16 @@ var RunQueryAdapter = class {
844
1154
  }
845
1155
  }
846
1156
  };
847
- RunQueryAdapter = _ts_decorate3([
848
- Injectable2(),
849
- _ts_metadata2("design:type", Function),
850
- _ts_metadata2("design:paramtypes", [
1157
+ RunQueryAdapter = _ts_decorate4([
1158
+ Injectable3(),
1159
+ _ts_metadata3("design:type", Function),
1160
+ _ts_metadata3("design:paramtypes", [
851
1161
  typeof RunGateway2 === "undefined" ? Object : RunGateway2
852
1162
  ])
853
1163
  ], RunQueryAdapter);
854
1164
 
855
1165
  // src/server/run.filter.ts
856
- function _ts_decorate4(decorators, target, key, desc) {
1166
+ function _ts_decorate5(decorators, target, key, desc) {
857
1167
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
858
1168
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
859
1169
  r = Reflect.decorate(decorators, target, key, desc);
@@ -866,13 +1176,13 @@ function _ts_decorate4(decorators, target, key, desc) {
866
1176
  }
867
1177
  return c > 3 && r && Object.defineProperty(target, key, r), r;
868
1178
  }
869
- __name(_ts_decorate4, "_ts_decorate");
870
- function _ts_metadata3(metadataKey, metadataValue) {
1179
+ __name(_ts_decorate5, "_ts_decorate");
1180
+ function _ts_metadata4(metadataKey, metadataValue) {
871
1181
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
872
1182
  return Reflect.metadata(metadataKey, metadataValue);
873
1183
  }
874
1184
  }
875
- __name(_ts_metadata3, "_ts_metadata");
1185
+ __name(_ts_metadata4, "_ts_metadata");
876
1186
  function list(value) {
877
1187
  return (Array.isArray(value) ? value : [
878
1188
  value
@@ -992,76 +1302,76 @@ var RunFilter = class extends BaseFilter {
992
1302
  });
993
1303
  }
994
1304
  };
995
- _ts_decorate4([
1305
+ _ts_decorate5([
996
1306
  FilterFor("status"),
997
- _ts_metadata3("design:type", Function),
998
- _ts_metadata3("design:paramtypes", [
1307
+ _ts_metadata4("design:type", Function),
1308
+ _ts_metadata4("design:paramtypes", [
999
1309
  Object
1000
1310
  ]),
1001
- _ts_metadata3("design:returntype", void 0)
1311
+ _ts_metadata4("design:returntype", void 0)
1002
1312
  ], RunFilter.prototype, "applyStatus", null);
1003
- _ts_decorate4([
1313
+ _ts_decorate5([
1004
1314
  FilterFor("workflow"),
1005
- _ts_metadata3("design:type", Function),
1006
- _ts_metadata3("design:paramtypes", [
1315
+ _ts_metadata4("design:type", Function),
1316
+ _ts_metadata4("design:paramtypes", [
1007
1317
  Object
1008
1318
  ]),
1009
- _ts_metadata3("design:returntype", void 0)
1319
+ _ts_metadata4("design:returntype", void 0)
1010
1320
  ], RunFilter.prototype, "applyWorkflow", null);
1011
- _ts_decorate4([
1321
+ _ts_decorate5([
1012
1322
  FilterFor("namespace"),
1013
- _ts_metadata3("design:type", Function),
1014
- _ts_metadata3("design:paramtypes", [
1323
+ _ts_metadata4("design:type", Function),
1324
+ _ts_metadata4("design:paramtypes", [
1015
1325
  Object
1016
1326
  ]),
1017
- _ts_metadata3("design:returntype", void 0)
1327
+ _ts_metadata4("design:returntype", void 0)
1018
1328
  ], RunFilter.prototype, "applyNamespace", null);
1019
- _ts_decorate4([
1329
+ _ts_decorate5([
1020
1330
  FilterFor("tag"),
1021
- _ts_metadata3("design:type", Function),
1022
- _ts_metadata3("design:paramtypes", [
1331
+ _ts_metadata4("design:type", Function),
1332
+ _ts_metadata4("design:paramtypes", [
1023
1333
  Object
1024
1334
  ]),
1025
- _ts_metadata3("design:returntype", void 0)
1335
+ _ts_metadata4("design:returntype", void 0)
1026
1336
  ], RunFilter.prototype, "applyTag", null);
1027
- _ts_decorate4([
1337
+ _ts_decorate5([
1028
1338
  FilterFor("origin"),
1029
- _ts_metadata3("design:type", Function),
1030
- _ts_metadata3("design:paramtypes", []),
1031
- _ts_metadata3("design:returntype", void 0)
1339
+ _ts_metadata4("design:type", Function),
1340
+ _ts_metadata4("design:paramtypes", []),
1341
+ _ts_metadata4("design:returntype", void 0)
1032
1342
  ], RunFilter.prototype, "applyOrigin", null);
1033
- _ts_decorate4([
1343
+ _ts_decorate5([
1034
1344
  FilterFor("unattributed"),
1035
- _ts_metadata3("design:type", Function),
1036
- _ts_metadata3("design:paramtypes", []),
1037
- _ts_metadata3("design:returntype", void 0)
1345
+ _ts_metadata4("design:type", Function),
1346
+ _ts_metadata4("design:paramtypes", []),
1347
+ _ts_metadata4("design:returntype", void 0)
1038
1348
  ], RunFilter.prototype, "applyUnattributed", null);
1039
- _ts_decorate4([
1349
+ _ts_decorate5([
1040
1350
  FilterFor("attr"),
1041
- _ts_metadata3("design:type", Function),
1042
- _ts_metadata3("design:paramtypes", [
1351
+ _ts_metadata4("design:type", Function),
1352
+ _ts_metadata4("design:paramtypes", [
1043
1353
  Object
1044
1354
  ]),
1045
- _ts_metadata3("design:returntype", void 0)
1355
+ _ts_metadata4("design:returntype", void 0)
1046
1356
  ], RunFilter.prototype, "applyAttributes", null);
1047
- _ts_decorate4([
1357
+ _ts_decorate5([
1048
1358
  FilterFor("limit"),
1049
- _ts_metadata3("design:type", Function),
1050
- _ts_metadata3("design:paramtypes", [
1359
+ _ts_metadata4("design:type", Function),
1360
+ _ts_metadata4("design:paramtypes", [
1051
1361
  Object
1052
1362
  ]),
1053
- _ts_metadata3("design:returntype", void 0)
1363
+ _ts_metadata4("design:returntype", void 0)
1054
1364
  ], RunFilter.prototype, "applyLimit", null);
1055
- _ts_decorate4([
1365
+ _ts_decorate5([
1056
1366
  FilterFor("offset"),
1057
- _ts_metadata3("design:type", Function),
1058
- _ts_metadata3("design:paramtypes", [
1367
+ _ts_metadata4("design:type", Function),
1368
+ _ts_metadata4("design:paramtypes", [
1059
1369
  Object
1060
1370
  ]),
1061
- _ts_metadata3("design:returntype", void 0)
1371
+ _ts_metadata4("design:returntype", void 0)
1062
1372
  ], RunFilter.prototype, "applyOffset", null);
1063
- RunFilter = _ts_decorate4([
1064
- Injectable3(),
1373
+ RunFilter = _ts_decorate5([
1374
+ Injectable4(),
1065
1375
  Filterable({
1066
1376
  entity: DurableRun,
1067
1377
  adapter: RUN_QUERY_ADAPTER,
@@ -1070,7 +1380,7 @@ RunFilter = _ts_decorate4([
1070
1380
  ], RunFilter);
1071
1381
 
1072
1382
  // src/server/durable-api.controller.ts
1073
- function _ts_decorate5(decorators, target, key, desc) {
1383
+ function _ts_decorate6(decorators, target, key, desc) {
1074
1384
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1075
1385
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1076
1386
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1083,19 +1393,19 @@ function _ts_decorate5(decorators, target, key, desc) {
1083
1393
  }
1084
1394
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1085
1395
  }
1086
- __name(_ts_decorate5, "_ts_decorate");
1087
- function _ts_metadata4(metadataKey, metadataValue) {
1396
+ __name(_ts_decorate6, "_ts_decorate");
1397
+ function _ts_metadata5(metadataKey, metadataValue) {
1088
1398
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1089
1399
  return Reflect.metadata(metadataKey, metadataValue);
1090
1400
  }
1091
1401
  }
1092
- __name(_ts_metadata4, "_ts_metadata");
1093
- function _ts_param2(paramIndex, decorator) {
1402
+ __name(_ts_metadata5, "_ts_metadata");
1403
+ function _ts_param3(paramIndex, decorator) {
1094
1404
  return function(target, key) {
1095
1405
  decorator(target, key, paramIndex);
1096
1406
  };
1097
1407
  }
1098
- __name(_ts_param2, "_ts_param");
1408
+ __name(_ts_param3, "_ts_param");
1099
1409
  var FAN_INLINE_MAX = 50;
1100
1410
  var DurableApiControllerBase = class {
1101
1411
  static {
@@ -1197,7 +1507,7 @@ var DurableApiControllerBase = class {
1197
1507
  */
1198
1508
  async workflowLifecycle(name) {
1199
1509
  const links = await this.dashboard.workflowLifecycle(name).catch(notSupportedByServer);
1200
- 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");
1201
1511
  return links;
1202
1512
  }
1203
1513
  /** This deployment's durable role (control plane vs tenant) + tenant name — for the header badge. */
@@ -1293,7 +1603,7 @@ var DurableApiControllerBase = class {
1293
1603
  return notSupportedByServer(error);
1294
1604
  }
1295
1605
  if (!result) {
1296
- throw new NotImplementedException("republishing lifecycle events needs the control plane");
1606
+ throw new NotImplementedException2("republishing lifecycle events needs the control plane");
1297
1607
  }
1298
1608
  return result;
1299
1609
  }
@@ -1310,9 +1620,9 @@ var DurableApiControllerBase = class {
1310
1620
  }
1311
1621
  /**
1312
1622
  * Public callback endpoint for `ctx.webhook()`: a third party POSTs here (the url handed to it),
1313
- * and the body resumes the waiting run. NOTE: this is reachable by external systems — protect it
1314
- * by treating the token as a secret (it embeds runId:seq) and/or fronting it with signature
1315
- * 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.
1316
1626
  */
1317
1627
  async webhook(token, body) {
1318
1628
  const result = await this.dashboard.deliverWebhook(token, body);
@@ -1328,135 +1638,135 @@ var DurableApiControllerBase = class {
1328
1638
  return this.dashboard.update(id, name, body);
1329
1639
  }
1330
1640
  };
1331
- _ts_decorate5([
1641
+ _ts_decorate6([
1332
1642
  Get("runs"),
1333
- _ts_param2(0, ApplyFilter(RunFilter)),
1334
- _ts_metadata4("design:type", Function),
1335
- _ts_metadata4("design:paramtypes", [
1643
+ _ts_param3(0, ApplyFilter(RunFilter)),
1644
+ _ts_metadata5("design:type", Function),
1645
+ _ts_metadata5("design:paramtypes", [
1336
1646
  typeof RunQueryDraft === "undefined" ? Object : RunQueryDraft
1337
1647
  ]),
1338
- _ts_metadata4("design:returntype", Promise)
1648
+ _ts_metadata5("design:returntype", Promise)
1339
1649
  ], DurableApiControllerBase.prototype, "runs", null);
1340
- _ts_decorate5([
1650
+ _ts_decorate6([
1341
1651
  Get("runs/facets"),
1342
- _ts_param2(0, ApplyFilter(RunFilter)),
1343
- _ts_metadata4("design:type", Function),
1344
- _ts_metadata4("design:paramtypes", [
1652
+ _ts_param3(0, ApplyFilter(RunFilter)),
1653
+ _ts_metadata5("design:type", Function),
1654
+ _ts_metadata5("design:paramtypes", [
1345
1655
  typeof RunQueryDraft === "undefined" ? Object : RunQueryDraft
1346
1656
  ]),
1347
- _ts_metadata4("design:returntype", void 0)
1657
+ _ts_metadata5("design:returntype", void 0)
1348
1658
  ], DurableApiControllerBase.prototype, "facets", null);
1349
- _ts_decorate5([
1659
+ _ts_decorate6([
1350
1660
  Get("runs/values"),
1351
- _ts_param2(0, Query()),
1352
- _ts_metadata4("design:type", Function),
1353
- _ts_metadata4("design:paramtypes", [
1661
+ _ts_param3(0, Query()),
1662
+ _ts_metadata5("design:type", Function),
1663
+ _ts_metadata5("design:paramtypes", [
1354
1664
  typeof Record === "undefined" ? Object : Record
1355
1665
  ]),
1356
- _ts_metadata4("design:returntype", void 0)
1666
+ _ts_metadata5("design:returntype", void 0)
1357
1667
  ], DurableApiControllerBase.prototype, "values", null);
1358
- _ts_decorate5([
1668
+ _ts_decorate6([
1359
1669
  Get("metrics"),
1360
1670
  Header("Content-Type", "text/plain; version=0.0.4"),
1361
- _ts_metadata4("design:type", Function),
1362
- _ts_metadata4("design:paramtypes", []),
1363
- _ts_metadata4("design:returntype", void 0)
1671
+ _ts_metadata5("design:type", Function),
1672
+ _ts_metadata5("design:paramtypes", []),
1673
+ _ts_metadata5("design:returntype", void 0)
1364
1674
  ], DurableApiControllerBase.prototype, "metrics", null);
1365
- _ts_decorate5([
1675
+ _ts_decorate6([
1366
1676
  Get("workers"),
1367
- _ts_metadata4("design:type", Function),
1368
- _ts_metadata4("design:paramtypes", []),
1369
- _ts_metadata4("design:returntype", void 0)
1677
+ _ts_metadata5("design:type", Function),
1678
+ _ts_metadata5("design:paramtypes", []),
1679
+ _ts_metadata5("design:returntype", void 0)
1370
1680
  ], DurableApiControllerBase.prototype, "workers", null);
1371
- _ts_decorate5([
1681
+ _ts_decorate6([
1372
1682
  Get("schedules"),
1373
- _ts_param2(0, Query("namespace")),
1374
- _ts_param2(1, Query("workflow")),
1375
- _ts_param2(2, Query("tag")),
1376
- _ts_param2(3, Query("paused")),
1377
- _ts_param2(4, Query("limit")),
1378
- _ts_metadata4("design:type", Function),
1379
- _ts_metadata4("design:paramtypes", [
1683
+ _ts_param3(0, Query("namespace")),
1684
+ _ts_param3(1, Query("workflow")),
1685
+ _ts_param3(2, Query("tag")),
1686
+ _ts_param3(3, Query("paused")),
1687
+ _ts_param3(4, Query("limit")),
1688
+ _ts_metadata5("design:type", Function),
1689
+ _ts_metadata5("design:paramtypes", [
1380
1690
  String,
1381
1691
  String,
1382
1692
  String,
1383
1693
  String,
1384
1694
  String
1385
1695
  ]),
1386
- _ts_metadata4("design:returntype", void 0)
1696
+ _ts_metadata5("design:returntype", void 0)
1387
1697
  ], DurableApiControllerBase.prototype, "schedules", null);
1388
- _ts_decorate5([
1698
+ _ts_decorate6([
1389
1699
  Post("schedules/:id/pause"),
1390
- _ts_param2(0, Param("id")),
1391
- _ts_metadata4("design:type", Function),
1392
- _ts_metadata4("design:paramtypes", [
1700
+ _ts_param3(0, Param("id")),
1701
+ _ts_metadata5("design:type", Function),
1702
+ _ts_metadata5("design:paramtypes", [
1393
1703
  String
1394
1704
  ]),
1395
- _ts_metadata4("design:returntype", void 0)
1705
+ _ts_metadata5("design:returntype", void 0)
1396
1706
  ], DurableApiControllerBase.prototype, "pauseSchedule", null);
1397
- _ts_decorate5([
1707
+ _ts_decorate6([
1398
1708
  Post("schedules/:id/resume"),
1399
- _ts_param2(0, Param("id")),
1400
- _ts_metadata4("design:type", Function),
1401
- _ts_metadata4("design:paramtypes", [
1709
+ _ts_param3(0, Param("id")),
1710
+ _ts_metadata5("design:type", Function),
1711
+ _ts_metadata5("design:paramtypes", [
1402
1712
  String
1403
1713
  ]),
1404
- _ts_metadata4("design:returntype", void 0)
1714
+ _ts_metadata5("design:returntype", void 0)
1405
1715
  ], DurableApiControllerBase.prototype, "resumeSchedule", null);
1406
- _ts_decorate5([
1716
+ _ts_decorate6([
1407
1717
  Post("schedules/:id/trigger"),
1408
- _ts_param2(0, Param("id")),
1409
- _ts_metadata4("design:type", Function),
1410
- _ts_metadata4("design:paramtypes", [
1718
+ _ts_param3(0, Param("id")),
1719
+ _ts_metadata5("design:type", Function),
1720
+ _ts_metadata5("design:paramtypes", [
1411
1721
  String
1412
1722
  ]),
1413
- _ts_metadata4("design:returntype", void 0)
1723
+ _ts_metadata5("design:returntype", void 0)
1414
1724
  ], DurableApiControllerBase.prototype, "triggerSchedule", null);
1415
- _ts_decorate5([
1725
+ _ts_decorate6([
1416
1726
  Get("workflows/:name/lifecycle"),
1417
- _ts_param2(0, Param("name")),
1418
- _ts_metadata4("design:type", Function),
1419
- _ts_metadata4("design:paramtypes", [
1727
+ _ts_param3(0, Param("name")),
1728
+ _ts_metadata5("design:type", Function),
1729
+ _ts_metadata5("design:paramtypes", [
1420
1730
  String
1421
1731
  ]),
1422
- _ts_metadata4("design:returntype", Promise)
1732
+ _ts_metadata5("design:returntype", Promise)
1423
1733
  ], DurableApiControllerBase.prototype, "workflowLifecycle", null);
1424
- _ts_decorate5([
1734
+ _ts_decorate6([
1425
1735
  Get("topology"),
1426
- _ts_metadata4("design:type", Function),
1427
- _ts_metadata4("design:paramtypes", []),
1428
- _ts_metadata4("design:returntype", void 0)
1736
+ _ts_metadata5("design:type", Function),
1737
+ _ts_metadata5("design:paramtypes", []),
1738
+ _ts_metadata5("design:returntype", void 0)
1429
1739
  ], DurableApiControllerBase.prototype, "topology", null);
1430
- _ts_decorate5([
1740
+ _ts_decorate6([
1431
1741
  Get("runs/:id"),
1432
- _ts_param2(0, Param("id")),
1433
- _ts_param2(1, Query("full")),
1434
- _ts_param2(2, Headers("if-none-match")),
1435
- _ts_param2(3, Res({
1742
+ _ts_param3(0, Param("id")),
1743
+ _ts_param3(1, Query("full")),
1744
+ _ts_param3(2, Headers("if-none-match")),
1745
+ _ts_param3(3, Res({
1436
1746
  passthrough: true
1437
1747
  })),
1438
- _ts_metadata4("design:type", Function),
1439
- _ts_metadata4("design:paramtypes", [
1748
+ _ts_metadata5("design:type", Function),
1749
+ _ts_metadata5("design:paramtypes", [
1440
1750
  String,
1441
1751
  String,
1442
1752
  String,
1443
1753
  Object
1444
1754
  ]),
1445
- _ts_metadata4("design:returntype", Promise)
1755
+ _ts_metadata5("design:returntype", Promise)
1446
1756
  ], DurableApiControllerBase.prototype, "run", null);
1447
- _ts_decorate5([
1757
+ _ts_decorate6([
1448
1758
  Get("runs/:id/fans/:group"),
1449
- _ts_param2(0, Param("id")),
1450
- _ts_param2(1, Param("group")),
1451
- _ts_param2(2, Query("offset")),
1452
- _ts_param2(3, Query("limit")),
1453
- _ts_param2(4, Query("failed")),
1454
- _ts_param2(5, Headers("if-none-match")),
1455
- _ts_param2(6, Res({
1759
+ _ts_param3(0, Param("id")),
1760
+ _ts_param3(1, Param("group")),
1761
+ _ts_param3(2, Query("offset")),
1762
+ _ts_param3(3, Query("limit")),
1763
+ _ts_param3(4, Query("failed")),
1764
+ _ts_param3(5, Headers("if-none-match")),
1765
+ _ts_param3(6, Res({
1456
1766
  passthrough: true
1457
1767
  })),
1458
- _ts_metadata4("design:type", Function),
1459
- _ts_metadata4("design:paramtypes", [
1768
+ _ts_metadata5("design:type", Function),
1769
+ _ts_metadata5("design:paramtypes", [
1460
1770
  String,
1461
1771
  String,
1462
1772
  String,
@@ -1465,131 +1775,132 @@ _ts_decorate5([
1465
1775
  String,
1466
1776
  Object
1467
1777
  ]),
1468
- _ts_metadata4("design:returntype", Promise)
1778
+ _ts_metadata5("design:returntype", Promise)
1469
1779
  ], DurableApiControllerBase.prototype, "fanMembers", null);
1470
- _ts_decorate5([
1780
+ _ts_decorate6([
1471
1781
  Sse("runs/:id/stream"),
1472
- _ts_param2(0, Param("id")),
1473
- _ts_metadata4("design:type", Function),
1474
- _ts_metadata4("design:paramtypes", [
1782
+ _ts_param3(0, Param("id")),
1783
+ _ts_metadata5("design:type", Function),
1784
+ _ts_metadata5("design:paramtypes", [
1475
1785
  String
1476
1786
  ]),
1477
- _ts_metadata4("design:returntype", void 0)
1787
+ _ts_metadata5("design:returntype", void 0)
1478
1788
  ], DurableApiControllerBase.prototype, "stream", null);
1479
- _ts_decorate5([
1789
+ _ts_decorate6([
1480
1790
  Post("runs/:id/retry"),
1481
- _ts_param2(0, Param("id")),
1482
- _ts_metadata4("design:type", Function),
1483
- _ts_metadata4("design:paramtypes", [
1791
+ _ts_param3(0, Param("id")),
1792
+ _ts_metadata5("design:type", Function),
1793
+ _ts_metadata5("design:paramtypes", [
1484
1794
  String
1485
1795
  ]),
1486
- _ts_metadata4("design:returntype", void 0)
1796
+ _ts_metadata5("design:returntype", void 0)
1487
1797
  ], DurableApiControllerBase.prototype, "retry", null);
1488
- _ts_decorate5([
1798
+ _ts_decorate6([
1489
1799
  Post("runs/:id/retry-with-input"),
1490
- _ts_param2(0, Param("id")),
1491
- _ts_param2(1, Body()),
1492
- _ts_metadata4("design:type", Function),
1493
- _ts_metadata4("design:paramtypes", [
1800
+ _ts_param3(0, Param("id")),
1801
+ _ts_param3(1, Body()),
1802
+ _ts_metadata5("design:type", Function),
1803
+ _ts_metadata5("design:paramtypes", [
1494
1804
  String,
1495
1805
  Object
1496
1806
  ]),
1497
- _ts_metadata4("design:returntype", void 0)
1807
+ _ts_metadata5("design:returntype", void 0)
1498
1808
  ], DurableApiControllerBase.prototype, "retryWithInput", null);
1499
- _ts_decorate5([
1809
+ _ts_decorate6([
1500
1810
  Post("bulk/:action"),
1501
- _ts_param2(0, Param("action")),
1502
- _ts_param2(1, ApplyFilter(RunFilter)),
1503
- _ts_param2(2, Query("compensate")),
1504
- _ts_metadata4("design:type", Function),
1505
- _ts_metadata4("design:paramtypes", [
1811
+ _ts_param3(0, Param("action")),
1812
+ _ts_param3(1, ApplyFilter(RunFilter)),
1813
+ _ts_param3(2, Query("compensate")),
1814
+ _ts_metadata5("design:type", Function),
1815
+ _ts_metadata5("design:paramtypes", [
1506
1816
  String,
1507
1817
  typeof RunQueryDraft === "undefined" ? Object : RunQueryDraft,
1508
1818
  String
1509
1819
  ]),
1510
- _ts_metadata4("design:returntype", void 0)
1820
+ _ts_metadata5("design:returntype", void 0)
1511
1821
  ], DurableApiControllerBase.prototype, "bulk", null);
1512
- _ts_decorate5([
1822
+ _ts_decorate6([
1513
1823
  Post("runs/:id/cancel"),
1514
- _ts_param2(0, Param("id")),
1515
- _ts_param2(1, Query("compensate")),
1516
- _ts_metadata4("design:type", Function),
1517
- _ts_metadata4("design:paramtypes", [
1824
+ _ts_param3(0, Param("id")),
1825
+ _ts_param3(1, Query("compensate")),
1826
+ _ts_metadata5("design:type", Function),
1827
+ _ts_metadata5("design:paramtypes", [
1518
1828
  String,
1519
1829
  String
1520
1830
  ]),
1521
- _ts_metadata4("design:returntype", Promise)
1831
+ _ts_metadata5("design:returntype", Promise)
1522
1832
  ], DurableApiControllerBase.prototype, "cancel", null);
1523
- _ts_decorate5([
1833
+ _ts_decorate6([
1524
1834
  Post("runs/:id/republish-lifecycle"),
1525
- _ts_param2(0, Param("id")),
1526
- _ts_param2(1, Body()),
1527
- _ts_metadata4("design:type", Function),
1528
- _ts_metadata4("design:paramtypes", [
1835
+ _ts_param3(0, Param("id")),
1836
+ _ts_param3(1, Body()),
1837
+ _ts_metadata5("design:type", Function),
1838
+ _ts_metadata5("design:paramtypes", [
1529
1839
  String,
1530
1840
  Object
1531
1841
  ]),
1532
- _ts_metadata4("design:returntype", Promise)
1842
+ _ts_metadata5("design:returntype", Promise)
1533
1843
  ], DurableApiControllerBase.prototype, "republishLifecycle", null);
1534
- _ts_decorate5([
1844
+ _ts_decorate6([
1535
1845
  Post("runs/:id/continue"),
1536
- _ts_param2(0, Param("id")),
1537
- _ts_metadata4("design:type", Function),
1538
- _ts_metadata4("design:paramtypes", [
1846
+ _ts_param3(0, Param("id")),
1847
+ _ts_metadata5("design:type", Function),
1848
+ _ts_metadata5("design:paramtypes", [
1539
1849
  String
1540
1850
  ]),
1541
- _ts_metadata4("design:returntype", Promise)
1851
+ _ts_metadata5("design:returntype", Promise)
1542
1852
  ], DurableApiControllerBase.prototype, "continue", null);
1543
- _ts_decorate5([
1853
+ _ts_decorate6([
1544
1854
  Post("runs/:id/redispatch"),
1545
- _ts_param2(0, Param("id")),
1546
- _ts_metadata4("design:type", Function),
1547
- _ts_metadata4("design:paramtypes", [
1855
+ _ts_param3(0, Param("id")),
1856
+ _ts_metadata5("design:type", Function),
1857
+ _ts_metadata5("design:paramtypes", [
1548
1858
  String
1549
1859
  ]),
1550
- _ts_metadata4("design:returntype", Promise)
1860
+ _ts_metadata5("design:returntype", Promise)
1551
1861
  ], DurableApiControllerBase.prototype, "redispatch", null);
1552
- _ts_decorate5([
1862
+ _ts_decorate6([
1863
+ ConsolePublic(),
1553
1864
  Post("webhooks/:token"),
1554
- _ts_param2(0, Param("token")),
1555
- _ts_param2(1, Body()),
1556
- _ts_metadata4("design:type", Function),
1557
- _ts_metadata4("design:paramtypes", [
1865
+ _ts_param3(0, Param("token")),
1866
+ _ts_param3(1, Body()),
1867
+ _ts_metadata5("design:type", Function),
1868
+ _ts_metadata5("design:paramtypes", [
1558
1869
  String,
1559
1870
  Object
1560
1871
  ]),
1561
- _ts_metadata4("design:returntype", Promise)
1872
+ _ts_metadata5("design:returntype", Promise)
1562
1873
  ], DurableApiControllerBase.prototype, "webhook", null);
1563
- _ts_decorate5([
1874
+ _ts_decorate6([
1564
1875
  Get("runs/:id/events/:key"),
1565
- _ts_param2(0, Param("id")),
1566
- _ts_param2(1, Param("key")),
1567
- _ts_metadata4("design:type", Function),
1568
- _ts_metadata4("design:paramtypes", [
1876
+ _ts_param3(0, Param("id")),
1877
+ _ts_param3(1, Param("key")),
1878
+ _ts_metadata5("design:type", Function),
1879
+ _ts_metadata5("design:paramtypes", [
1569
1880
  String,
1570
1881
  String
1571
1882
  ]),
1572
- _ts_metadata4("design:returntype", void 0)
1883
+ _ts_metadata5("design:returntype", void 0)
1573
1884
  ], DurableApiControllerBase.prototype, "event", null);
1574
- _ts_decorate5([
1885
+ _ts_decorate6([
1575
1886
  Post("runs/:id/updates/:name"),
1576
- _ts_param2(0, Param("id")),
1577
- _ts_param2(1, Param("name")),
1578
- _ts_param2(2, Body()),
1579
- _ts_metadata4("design:type", Function),
1580
- _ts_metadata4("design:paramtypes", [
1887
+ _ts_param3(0, Param("id")),
1888
+ _ts_param3(1, Param("name")),
1889
+ _ts_param3(2, Body()),
1890
+ _ts_metadata5("design:type", Function),
1891
+ _ts_metadata5("design:paramtypes", [
1581
1892
  String,
1582
1893
  String,
1583
1894
  Object
1584
1895
  ]),
1585
- _ts_metadata4("design:returntype", void 0)
1896
+ _ts_metadata5("design:returntype", void 0)
1586
1897
  ], DurableApiControllerBase.prototype, "update", null);
1587
- DurableApiControllerBase = _ts_decorate5([
1898
+ DurableApiControllerBase = _ts_decorate6([
1588
1899
  Controller(),
1589
1900
  UseInterceptors(ApplyFilterInterceptor),
1590
- UseFilters(NotModifiedFilter),
1591
- _ts_metadata4("design:type", Function),
1592
- _ts_metadata4("design:paramtypes", [
1901
+ UseFilters2(NotModifiedFilter),
1902
+ _ts_metadata5("design:type", Function),
1903
+ _ts_metadata5("design:paramtypes", [
1593
1904
  typeof DashboardService === "undefined" ? Object : DashboardService,
1594
1905
  typeof FilterRunner === "undefined" ? Object : FilterRunner
1595
1906
  ])
@@ -1603,7 +1914,7 @@ function notFound(error) {
1603
1914
  __name(notFound, "notFound");
1604
1915
  function notSupportedByServer(error) {
1605
1916
  if (error?.code === "unsupported-request") {
1606
- throw new NotImplementedException(error instanceof Error ? error.message : String(error));
1917
+ throw new NotImplementedException2(error instanceof Error ? error.message : String(error));
1607
1918
  }
1608
1919
  throw error;
1609
1920
  }
@@ -1613,14 +1924,14 @@ var DurableApiController = class extends DurableApiControllerBase {
1613
1924
  __name(this, "DurableApiController");
1614
1925
  }
1615
1926
  };
1616
- DurableApiController = _ts_decorate5([
1927
+ DurableApiController = _ts_decorate6([
1617
1928
  Controller()
1618
1929
  ], DurableApiController);
1619
1930
 
1620
1931
  // src/server/durable-dashboard.module.ts
1621
1932
  import "reflect-metadata";
1622
1933
  import { ApplyFilterInterceptor as ApplyFilterInterceptor2, FilterRunner as FilterRunner2 } from "@dudousxd/nestjs-filter";
1623
- import { Logger, Module } from "@nestjs/common";
1934
+ import { Module } from "@nestjs/common";
1624
1935
  import { ModuleRef, RouterModule } from "@nestjs/core";
1625
1936
 
1626
1937
  // src/server/controller-decorators.ts
@@ -1653,8 +1964,8 @@ __name(controllerFor, "controllerFor");
1653
1964
  import { existsSync, readFileSync } from "node:fs";
1654
1965
  import { basename, extname, join, resolve, sep } from "node:path";
1655
1966
  import { fileURLToPath } from "node:url";
1656
- import { Controller as Controller2, Get as Get2, Header as Header2, Inject as Inject2, NotFoundException as NotFoundException2, Param as Param2, StreamableFile } from "@nestjs/common";
1657
- function _ts_decorate6(decorators, target, key, desc) {
1967
+ import { Controller as Controller2, Get as Get2, Header as Header2, Inject as Inject3, NotFoundException as NotFoundException2, Param as Param2, StreamableFile } from "@nestjs/common";
1968
+ function _ts_decorate7(decorators, target, key, desc) {
1658
1969
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1659
1970
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1660
1971
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1667,19 +1978,19 @@ function _ts_decorate6(decorators, target, key, desc) {
1667
1978
  }
1668
1979
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1669
1980
  }
1670
- __name(_ts_decorate6, "_ts_decorate");
1671
- function _ts_metadata5(metadataKey, metadataValue) {
1981
+ __name(_ts_decorate7, "_ts_decorate");
1982
+ function _ts_metadata6(metadataKey, metadataValue) {
1672
1983
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1673
1984
  return Reflect.metadata(metadataKey, metadataValue);
1674
1985
  }
1675
1986
  }
1676
- __name(_ts_metadata5, "_ts_metadata");
1677
- function _ts_param3(paramIndex, decorator) {
1987
+ __name(_ts_metadata6, "_ts_metadata");
1988
+ function _ts_param4(paramIndex, decorator) {
1678
1989
  return function(target, key) {
1679
1990
  decorator(target, key, paramIndex);
1680
1991
  };
1681
1992
  }
1682
- __name(_ts_param3, "_ts_param");
1993
+ __name(_ts_param4, "_ts_param");
1683
1994
  var DASHBOARD_BASE_PATH = Symbol("DASHBOARD_BASE_PATH");
1684
1995
  var DASHBOARD_API_PATH = Symbol("DASHBOARD_API_PATH");
1685
1996
  var BUILD_BASE = "/durable";
@@ -1732,30 +2043,31 @@ var DurableUiControllerBase = class {
1732
2043
  });
1733
2044
  }
1734
2045
  };
1735
- _ts_decorate6([
2046
+ _ts_decorate7([
1736
2047
  Get2(),
1737
2048
  Header2("Content-Type", "text/html; charset=utf-8"),
1738
2049
  Header2("Cache-Control", "no-store, must-revalidate"),
1739
- _ts_metadata5("design:type", Function),
1740
- _ts_metadata5("design:paramtypes", []),
1741
- _ts_metadata5("design:returntype", String)
2050
+ _ts_metadata6("design:type", Function),
2051
+ _ts_metadata6("design:paramtypes", []),
2052
+ _ts_metadata6("design:returntype", String)
1742
2053
  ], DurableUiControllerBase.prototype, "index", null);
1743
- _ts_decorate6([
2054
+ _ts_decorate7([
1744
2055
  Get2("assets/:file"),
1745
2056
  Header2("Cache-Control", "public, max-age=31536000, immutable"),
1746
- _ts_param3(0, Param2("file")),
1747
- _ts_metadata5("design:type", Function),
1748
- _ts_metadata5("design:paramtypes", [
2057
+ _ts_param4(0, Param2("file")),
2058
+ _ts_metadata6("design:type", Function),
2059
+ _ts_metadata6("design:paramtypes", [
1749
2060
  String
1750
2061
  ]),
1751
- _ts_metadata5("design:returntype", typeof StreamableFile === "undefined" ? Object : StreamableFile)
2062
+ _ts_metadata6("design:returntype", typeof StreamableFile === "undefined" ? Object : StreamableFile)
1752
2063
  ], DurableUiControllerBase.prototype, "asset", null);
1753
- DurableUiControllerBase = _ts_decorate6([
2064
+ DurableUiControllerBase = _ts_decorate7([
1754
2065
  Controller2(),
1755
- _ts_param3(0, Inject2(DASHBOARD_BASE_PATH)),
1756
- _ts_param3(1, Inject2(DASHBOARD_API_PATH)),
1757
- _ts_metadata5("design:type", Function),
1758
- _ts_metadata5("design:paramtypes", [
2066
+ ConsolePage(),
2067
+ _ts_param4(0, Inject3(DASHBOARD_BASE_PATH)),
2068
+ _ts_param4(1, Inject3(DASHBOARD_API_PATH)),
2069
+ _ts_metadata6("design:type", Function),
2070
+ _ts_metadata6("design:paramtypes", [
1759
2071
  String,
1760
2072
  String
1761
2073
  ])
@@ -1765,12 +2077,12 @@ var DurableUiController = class extends DurableUiControllerBase {
1765
2077
  __name(this, "DurableUiController");
1766
2078
  }
1767
2079
  };
1768
- DurableUiController = _ts_decorate6([
2080
+ DurableUiController = _ts_decorate7([
1769
2081
  Controller2()
1770
2082
  ], DurableUiController);
1771
2083
 
1772
2084
  // src/server/durable-dashboard.module.ts
1773
- function _ts_decorate7(decorators, target, key, desc) {
2085
+ function _ts_decorate8(decorators, target, key, desc) {
1774
2086
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1775
2087
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1776
2088
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1783,31 +2095,9 @@ function _ts_decorate7(decorators, target, key, desc) {
1783
2095
  }
1784
2096
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1785
2097
  }
1786
- __name(_ts_decorate7, "_ts_decorate");
2098
+ __name(_ts_decorate8, "_ts_decorate");
1787
2099
  markOpenToAuthorization(DurableApiController);
1788
2100
  markOpenToAuthorization(DurableUiController);
1789
- var DASHBOARD_PROTECTION_CHECK = Symbol("DASHBOARD_PROTECTION_CHECK");
1790
- var UNPROTECTED_CONSOLE_IN_PRODUCTION = [
1791
- "DurableDashboardModule: NODE_ENV=production and the durable console is mounted with no",
1792
- "protection, so the app refuses to boot. Protect it one of two ways:",
1793
- "(1) decorators on the mounted console: DurableDashboardModule.forRoot({ decorators: [UseGuards(AuthenticationGuard), Can(ConsolePolicy, 'view')] });",
1794
- "(2) mount it yourself: DurableDashboardModule.forRoot({ routes: false }) plus @Controller('durable') @UseGuards(AuthenticationGuard) @Can(ConsolePolicy, 'view') class ConsoleUi extends DurableUiControllerBase {} (and the same over DurableApiControllerBase at 'durable/api')."
1795
- ].join(" ");
1796
- function isProduction() {
1797
- return (process.env.NODE_ENV ?? "").trim().toLowerCase() === "production";
1798
- }
1799
- __name(isProduction, "isProduction");
1800
- function protectionCheckProvider() {
1801
- return {
1802
- provide: DASHBOARD_PROTECTION_CHECK,
1803
- useFactory: /* @__PURE__ */ __name(() => {
1804
- if (isProduction()) throw new Error(UNPROTECTED_CONSOLE_IN_PRODUCTION);
1805
- new Logger("DurableDashboard").warn("The durable console is mounted with no `decorators`, so it is served OPEN (retry/cancel included). That is refused when NODE_ENV=production: pass `decorators` (e.g. [UseGuards(AuthenticationGuard), Can(ConsolePolicy, 'view')]) or mount it yourself with `routes: false`.");
1806
- return true;
1807
- }, "useFactory")
1808
- };
1809
- }
1810
- __name(protectionCheckProvider, "protectionCheckProvider");
1811
2101
  function assertNothingToDecorate(options) {
1812
2102
  if (options.decorators === void 0) return;
1813
2103
  throw new Error([
@@ -1818,6 +2108,13 @@ function assertNothingToDecorate(options) {
1818
2108
  ].join(" "));
1819
2109
  }
1820
2110
  __name(assertNothingToDecorate, "assertNothingToDecorate");
2111
+ function consoleController(base, decorators) {
2112
+ return controllerFor(base, [
2113
+ ...decorators ?? [],
2114
+ UseConsoleAuthorize()
2115
+ ]);
2116
+ }
2117
+ __name(consoleController, "consoleController");
1821
2118
  function normalize(path) {
1822
2119
  return `/${path.replace(/^\/+|\/+$/g, "")}`;
1823
2120
  }
@@ -1834,10 +2131,20 @@ var DurableApiModule = class _DurableApiModule {
1834
2131
  ...options.imports ?? []
1835
2132
  ],
1836
2133
  controllers: routes ? [
1837
- controllerFor(DurableApiController, options.decorators)
2134
+ consoleController(DurableApiController, options.decorators)
1838
2135
  ] : [],
1839
2136
  providers: [
1840
2137
  DashboardService,
2138
+ // Resolved at boot: a gate name without nestjs-authz, or a policy without
2139
+ // @nestjs/authorization, fails here rather than on the first request.
2140
+ {
2141
+ provide: CONSOLE_AUTHORIZE_DECIDE,
2142
+ // Also with `routes: false`: `@UseConsoleAuthorize()` still applies the production 403.
2143
+ useFactory: /* @__PURE__ */ __name((moduleRef) => resolveConsoleAuthorize(options.authorize, moduleRef), "useFactory"),
2144
+ inject: [
2145
+ ModuleRef
2146
+ ]
2147
+ },
1841
2148
  // `@dudousxd/nestjs-filter` is wired PRIVATELY here rather than through
1842
2149
  // `FilterModule.forRoot()`, which is a global registration. A library calling that would
1843
2150
  // fight the host app over one set of module options and register a second app-wide
@@ -1875,15 +2182,17 @@ var DurableApiModule = class _DurableApiModule {
1875
2182
  // is only exported then: exporting it from a mounted console would shadow a host's own
1876
2183
  // `FilterModule` runner in whatever module imports the dashboard.
1877
2184
  exports: routes ? [
1878
- DashboardService
2185
+ DashboardService,
2186
+ CONSOLE_AUTHORIZE_DECIDE
1879
2187
  ] : [
1880
2188
  DashboardService,
1881
- FilterRunner2
2189
+ FilterRunner2,
2190
+ CONSOLE_AUTHORIZE_DECIDE
1882
2191
  ]
1883
2192
  };
1884
2193
  }
1885
2194
  };
1886
- DurableApiModule = _ts_decorate7([
2195
+ DurableApiModule = _ts_decorate8([
1887
2196
  Module({})
1888
2197
  ], DurableApiModule);
1889
2198
  var DurableDashboardModule = class _DurableDashboardModule {
@@ -1909,6 +2218,9 @@ var DurableDashboardModule = class _DurableDashboardModule {
1909
2218
  ...options.imports ? {
1910
2219
  imports: options.imports
1911
2220
  } : {},
2221
+ ...options.authorize !== void 0 ? {
2222
+ authorize: options.authorize
2223
+ } : {},
1912
2224
  routes: false
1913
2225
  });
1914
2226
  return {
@@ -1920,7 +2232,8 @@ var DurableDashboardModule = class _DurableDashboardModule {
1920
2232
  controllers: [],
1921
2233
  providers: pathProviders,
1922
2234
  // What a host's subclasses of `DurableUiControllerBase` / `DurableApiControllerBase` inject:
1923
- // the SPA's paths, and the read/action service and the filter runner via the API module.
2235
+ // the SPA's paths, the read/action service, the filter runner and the resolved `authorize`
2236
+ // (for `@UseConsoleAuthorize()`) via the API module.
1924
2237
  exports: [
1925
2238
  DurableApiModule,
1926
2239
  DASHBOARD_BASE_PATH,
@@ -1928,7 +2241,6 @@ var DurableDashboardModule = class _DurableDashboardModule {
1928
2241
  ]
1929
2242
  };
1930
2243
  }
1931
- const decorated = (options.decorators?.length ?? 0) > 0;
1932
2244
  return {
1933
2245
  module: _DurableDashboardModule,
1934
2246
  imports: [
@@ -1942,6 +2254,9 @@ var DurableDashboardModule = class _DurableDashboardModule {
1942
2254
  } : {},
1943
2255
  ...options.decorators ? {
1944
2256
  decorators: options.decorators
2257
+ } : {},
2258
+ ...options.authorize !== void 0 ? {
2259
+ authorize: options.authorize
1945
2260
  } : {}
1946
2261
  }),
1947
2262
  RouterModule.register([
@@ -1956,14 +2271,9 @@ var DurableDashboardModule = class _DurableDashboardModule {
1956
2271
  ])
1957
2272
  ],
1958
2273
  controllers: [
1959
- controllerFor(DurableUiController, options.decorators)
1960
- ],
1961
- providers: [
1962
- ...pathProviders,
1963
- ...decorated ? [] : [
1964
- protectionCheckProvider()
1965
- ]
2274
+ consoleController(DurableUiController, options.decorators)
1966
2275
  ],
2276
+ providers: pathProviders,
1967
2277
  // Re-export the API module so its DashboardService reaches importers (e.g. flip's own controllers).
1968
2278
  exports: [
1969
2279
  DurableApiModule
@@ -1971,13 +2281,22 @@ var DurableDashboardModule = class _DurableDashboardModule {
1971
2281
  };
1972
2282
  }
1973
2283
  };
1974
- DurableDashboardModule = _ts_decorate7([
2284
+ DurableDashboardModule = _ts_decorate8([
1975
2285
  Module({})
1976
2286
  ], DurableDashboardModule);
1977
2287
  export {
2288
+ CONSOLE_AUTHORIZE_DECIDE,
2289
+ CONSOLE_AUTHORIZE_MISSING_WARNING,
2290
+ CONSOLE_GATE,
2291
+ CONSOLE_PAGE_METADATA,
2292
+ CONSOLE_PUBLIC_METADATA,
2293
+ ConsoleAccessDenied,
2294
+ ConsoleAuthorizeFilter,
2295
+ ConsoleAuthorizeGuard,
2296
+ ConsolePage,
2297
+ ConsolePublic,
1978
2298
  DASHBOARD_API_PATH,
1979
2299
  DASHBOARD_BASE_PATH,
1980
- DASHBOARD_PROTECTION_CHECK,
1981
2300
  DashboardService,
1982
2301
  DurableApiController,
1983
2302
  DurableApiControllerBase,
@@ -1985,6 +2304,9 @@ export {
1985
2304
  DurableDashboardModule,
1986
2305
  DurableUiController,
1987
2306
  DurableUiControllerBase,
1988
- UNPROTECTED_CONSOLE_IN_PRODUCTION
2307
+ UseConsoleAuthorize,
2308
+ authorizeByToken,
2309
+ normalizeConsoleResult,
2310
+ resolveConsoleAuthorize
1989
2311
  };
1990
2312
  //# sourceMappingURL=index.js.map