@dudousxd/nestjs-durable-dashboard 0.55.1 → 0.56.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,310 @@ 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 ConsoleAuthorizeGuard = class {
243
+ static {
244
+ __name(this, "ConsoleAuthorizeGuard");
245
+ }
246
+ decide;
247
+ constructor(decide) {
248
+ this.decide = decide;
249
+ }
250
+ async canActivate(context) {
251
+ const decision = await this.decide(context);
252
+ if (decision.allowed) return true;
253
+ throw new ConsoleAccessDenied(decision, isPageNavigation(context));
254
+ }
255
+ };
256
+ ConsoleAuthorizeGuard = _ts_decorate([
257
+ Injectable(),
258
+ _ts_param(0, Inject(CONSOLE_AUTHORIZE_DECIDE)),
259
+ _ts_metadata("design:type", Function),
260
+ _ts_metadata("design:paramtypes", [
261
+ typeof ConsoleDecide === "undefined" ? Object : ConsoleDecide
262
+ ])
263
+ ], ConsoleAuthorizeGuard);
264
+ function isPageNavigation(context) {
265
+ if (context.getType() !== "http") return false;
266
+ if (Reflect.getMetadata(CONSOLE_PAGE_METADATA, context.getClass()) !== true) return false;
267
+ const request = context.switchToHttp().getRequest();
268
+ const accept = request?.headers?.accept;
269
+ return request?.method === "GET" && typeof accept === "string" && accept.includes("text/html");
270
+ }
271
+ __name(isPageNavigation, "isPageNavigation");
272
+ 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");
273
+ var DENIED_PAGE = consolePage("Access denied", "You do not have access to this console.");
274
+ var SIGN_IN_PAGE = consolePage("Sign in required", "Sign in to open this console.");
275
+ var ConsoleAuthorizeFilter = class {
276
+ static {
277
+ __name(this, "ConsoleAuthorizeFilter");
278
+ }
279
+ adapterHost;
280
+ constructor(adapterHost) {
281
+ this.adapterHost = adapterHost;
282
+ }
283
+ catch(exception, host) {
284
+ const adapter = this.adapterHost.httpAdapter;
285
+ const response = host.switchToHttp().getResponse();
286
+ const { decision, page } = exception;
287
+ if (page && decision.redirectTo) {
288
+ adapter.redirect(response, 302, decision.redirectTo);
289
+ return;
290
+ }
291
+ if (page) {
292
+ const forbiddenPage = decision.reason === "forbidden";
293
+ adapter.setHeader(response, "Content-Type", "text/html; charset=utf-8");
294
+ adapter.reply(response, forbiddenPage ? DENIED_PAGE : SIGN_IN_PAGE, forbiddenPage ? 403 : 401);
295
+ return;
296
+ }
297
+ adapter.reply(response, exception.getResponse(), exception.getStatus());
298
+ }
299
+ };
300
+ ConsoleAuthorizeFilter = _ts_decorate([
301
+ Catch(ConsoleAccessDenied),
302
+ _ts_metadata("design:type", Function),
303
+ _ts_metadata("design:paramtypes", [
304
+ typeof HttpAdapterHost === "undefined" ? Object : HttpAdapterHost
305
+ ])
306
+ ], ConsoleAuthorizeFilter);
307
+ var UseConsoleAuthorize = /* @__PURE__ */ __name(() => applyDecorators(UseGuards(ConsoleAuthorizeGuard), UseFilters(ConsoleAuthorizeFilter)), "UseConsoleAuthorize");
308
+
309
+ // src/server/dashboard.service.ts
310
+ 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";
312
+ import { Observable } from "rxjs";
313
+ function _ts_decorate2(decorators, target, key, desc) {
314
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
315
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
316
+ r = Reflect.decorate(decorators, target, key, desc);
317
+ } else {
318
+ for (var i = decorators.length - 1; i >= 0; i--) {
319
+ if (d = decorators[i]) {
320
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
321
+ }
322
+ }
323
+ }
324
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
325
+ }
326
+ __name(_ts_decorate2, "_ts_decorate");
327
+ function _ts_metadata2(metadataKey, metadataValue) {
328
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
329
+ return Reflect.metadata(metadataKey, metadataValue);
330
+ }
331
+ }
332
+ __name(_ts_metadata2, "_ts_metadata");
333
+ function _ts_param2(paramIndex, decorator) {
334
+ return function(target, key) {
335
+ decorator(target, key, paramIndex);
336
+ };
337
+ }
338
+ __name(_ts_param2, "_ts_param");
34
339
  var DashboardService = class {
35
340
  static {
36
341
  __name(this, "DashboardService");
@@ -304,13 +609,13 @@ var DashboardService = class {
304
609
  });
305
610
  }
306
611
  };
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", [
612
+ DashboardService = _ts_decorate2([
613
+ Injectable2(),
614
+ _ts_param2(1, Optional()),
615
+ _ts_param2(1, Inject2(STATE_STORE_CANONICAL)),
616
+ _ts_param2(2, Optional()),
617
+ _ts_metadata2("design:type", Function),
618
+ _ts_metadata2("design:paramtypes", [
314
619
  typeof RunGateway === "undefined" ? Object : RunGateway,
315
620
  typeof StateStore === "undefined" ? Object : StateStore,
316
621
  typeof WorkflowEngine === "undefined" ? Object : WorkflowEngine
@@ -319,7 +624,7 @@ DashboardService = _ts_decorate([
319
624
 
320
625
  // src/server/durable-api.controller.ts
321
626
  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";
627
+ import { BadRequestException as BadRequestException2, Body, Controller, Get, Header, Headers, NotFoundException, NotImplementedException, Param, Post, Query, Res, Sse, UseFilters as UseFilters2, UseInterceptors } from "@nestjs/common";
323
628
 
324
629
  // src/server/durable-run.ts
325
630
  var DurableRun = class {
@@ -395,8 +700,8 @@ function runValueAxisFor(field) {
395
700
  __name(runValueAxisFor, "runValueAxisFor");
396
701
 
397
702
  // src/server/not-modified.ts
398
- import { Catch, HttpException } from "@nestjs/common";
399
- function _ts_decorate2(decorators, target, key, desc) {
703
+ import { Catch as Catch2, HttpException as HttpException2 } from "@nestjs/common";
704
+ function _ts_decorate3(decorators, target, key, desc) {
400
705
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
401
706
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
402
707
  r = Reflect.decorate(decorators, target, key, desc);
@@ -409,7 +714,7 @@ function _ts_decorate2(decorators, target, key, desc) {
409
714
  }
410
715
  return c > 3 && r && Object.defineProperty(target, key, r), r;
411
716
  }
412
- __name(_ts_decorate2, "_ts_decorate");
717
+ __name(_ts_decorate3, "_ts_decorate");
413
718
  function isRawResponse(value) {
414
719
  if (typeof value !== "object" || value === null) return false;
415
720
  const candidate = value;
@@ -435,7 +740,7 @@ function writeNotModifiedRaw(response, etag) {
435
740
  raw.end();
436
741
  }
437
742
  __name(writeNotModifiedRaw, "writeNotModifiedRaw");
438
- var NotModifiedException = class extends HttpException {
743
+ var NotModifiedException = class extends HttpException2 {
439
744
  static {
440
745
  __name(this, "NotModifiedException");
441
746
  }
@@ -452,8 +757,8 @@ var NotModifiedFilter = class {
452
757
  writeNotModifiedRaw(host.switchToHttp().getResponse(), exception.etag);
453
758
  }
454
759
  };
455
- NotModifiedFilter = _ts_decorate2([
456
- Catch(NotModifiedException)
760
+ NotModifiedFilter = _ts_decorate3([
761
+ Catch2(NotModifiedException)
457
762
  ], NotModifiedFilter);
458
763
  function setEtag(response, etag) {
459
764
  setRawHeader(response, "etag", etag);
@@ -470,7 +775,7 @@ __name(toRunListRow, "toRunListRow");
470
775
 
471
776
  // src/server/run.filter.ts
472
777
  import { BaseFilter, FilterFor, Filterable } from "@dudousxd/nestjs-filter";
473
- import { Injectable as Injectable3 } from "@nestjs/common";
778
+ import { Injectable as Injectable4 } from "@nestjs/common";
474
779
 
475
780
  // src/server/attr-filter.ts
476
781
  var SCALAR_OPS = /* @__PURE__ */ new Set([
@@ -521,7 +826,7 @@ __name(parseAttrFilters, "parseAttrFilters");
521
826
 
522
827
  // src/server/run-query.adapter.ts
523
828
  import { RUN_VALUE_FACET_LIMIT, RunGateway as RunGateway2 } from "@dudousxd/nestjs-durable-core";
524
- import { BadRequestException, Injectable as Injectable2 } from "@nestjs/common";
829
+ import { BadRequestException, Injectable as Injectable3 } from "@nestjs/common";
525
830
 
526
831
  // src/server/run-query-draft.ts
527
832
  var RunQueryDraft2 = class {
@@ -551,7 +856,7 @@ var RunQueryDraft2 = class {
551
856
  };
552
857
 
553
858
  // src/server/run-query.adapter.ts
554
- function _ts_decorate3(decorators, target, key, desc) {
859
+ function _ts_decorate4(decorators, target, key, desc) {
555
860
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
556
861
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
557
862
  r = Reflect.decorate(decorators, target, key, desc);
@@ -564,13 +869,13 @@ function _ts_decorate3(decorators, target, key, desc) {
564
869
  }
565
870
  return c > 3 && r && Object.defineProperty(target, key, r), r;
566
871
  }
567
- __name(_ts_decorate3, "_ts_decorate");
568
- function _ts_metadata2(metadataKey, metadataValue) {
872
+ __name(_ts_decorate4, "_ts_decorate");
873
+ function _ts_metadata3(metadataKey, metadataValue) {
569
874
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
570
875
  return Reflect.metadata(metadataKey, metadataValue);
571
876
  }
572
877
  }
573
- __name(_ts_metadata2, "_ts_metadata");
878
+ __name(_ts_metadata3, "_ts_metadata");
574
879
  var RUN_QUERY_ADAPTER = Symbol("DURABLE_RUN_QUERY_ADAPTER");
575
880
  var FIXED_ORDER = {
576
881
  field: "createdAt",
@@ -844,16 +1149,16 @@ var RunQueryAdapter = class {
844
1149
  }
845
1150
  }
846
1151
  };
847
- RunQueryAdapter = _ts_decorate3([
848
- Injectable2(),
849
- _ts_metadata2("design:type", Function),
850
- _ts_metadata2("design:paramtypes", [
1152
+ RunQueryAdapter = _ts_decorate4([
1153
+ Injectable3(),
1154
+ _ts_metadata3("design:type", Function),
1155
+ _ts_metadata3("design:paramtypes", [
851
1156
  typeof RunGateway2 === "undefined" ? Object : RunGateway2
852
1157
  ])
853
1158
  ], RunQueryAdapter);
854
1159
 
855
1160
  // src/server/run.filter.ts
856
- function _ts_decorate4(decorators, target, key, desc) {
1161
+ function _ts_decorate5(decorators, target, key, desc) {
857
1162
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
858
1163
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
859
1164
  r = Reflect.decorate(decorators, target, key, desc);
@@ -866,13 +1171,13 @@ function _ts_decorate4(decorators, target, key, desc) {
866
1171
  }
867
1172
  return c > 3 && r && Object.defineProperty(target, key, r), r;
868
1173
  }
869
- __name(_ts_decorate4, "_ts_decorate");
870
- function _ts_metadata3(metadataKey, metadataValue) {
1174
+ __name(_ts_decorate5, "_ts_decorate");
1175
+ function _ts_metadata4(metadataKey, metadataValue) {
871
1176
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
872
1177
  return Reflect.metadata(metadataKey, metadataValue);
873
1178
  }
874
1179
  }
875
- __name(_ts_metadata3, "_ts_metadata");
1180
+ __name(_ts_metadata4, "_ts_metadata");
876
1181
  function list(value) {
877
1182
  return (Array.isArray(value) ? value : [
878
1183
  value
@@ -992,76 +1297,76 @@ var RunFilter = class extends BaseFilter {
992
1297
  });
993
1298
  }
994
1299
  };
995
- _ts_decorate4([
1300
+ _ts_decorate5([
996
1301
  FilterFor("status"),
997
- _ts_metadata3("design:type", Function),
998
- _ts_metadata3("design:paramtypes", [
1302
+ _ts_metadata4("design:type", Function),
1303
+ _ts_metadata4("design:paramtypes", [
999
1304
  Object
1000
1305
  ]),
1001
- _ts_metadata3("design:returntype", void 0)
1306
+ _ts_metadata4("design:returntype", void 0)
1002
1307
  ], RunFilter.prototype, "applyStatus", null);
1003
- _ts_decorate4([
1308
+ _ts_decorate5([
1004
1309
  FilterFor("workflow"),
1005
- _ts_metadata3("design:type", Function),
1006
- _ts_metadata3("design:paramtypes", [
1310
+ _ts_metadata4("design:type", Function),
1311
+ _ts_metadata4("design:paramtypes", [
1007
1312
  Object
1008
1313
  ]),
1009
- _ts_metadata3("design:returntype", void 0)
1314
+ _ts_metadata4("design:returntype", void 0)
1010
1315
  ], RunFilter.prototype, "applyWorkflow", null);
1011
- _ts_decorate4([
1316
+ _ts_decorate5([
1012
1317
  FilterFor("namespace"),
1013
- _ts_metadata3("design:type", Function),
1014
- _ts_metadata3("design:paramtypes", [
1318
+ _ts_metadata4("design:type", Function),
1319
+ _ts_metadata4("design:paramtypes", [
1015
1320
  Object
1016
1321
  ]),
1017
- _ts_metadata3("design:returntype", void 0)
1322
+ _ts_metadata4("design:returntype", void 0)
1018
1323
  ], RunFilter.prototype, "applyNamespace", null);
1019
- _ts_decorate4([
1324
+ _ts_decorate5([
1020
1325
  FilterFor("tag"),
1021
- _ts_metadata3("design:type", Function),
1022
- _ts_metadata3("design:paramtypes", [
1326
+ _ts_metadata4("design:type", Function),
1327
+ _ts_metadata4("design:paramtypes", [
1023
1328
  Object
1024
1329
  ]),
1025
- _ts_metadata3("design:returntype", void 0)
1330
+ _ts_metadata4("design:returntype", void 0)
1026
1331
  ], RunFilter.prototype, "applyTag", null);
1027
- _ts_decorate4([
1332
+ _ts_decorate5([
1028
1333
  FilterFor("origin"),
1029
- _ts_metadata3("design:type", Function),
1030
- _ts_metadata3("design:paramtypes", []),
1031
- _ts_metadata3("design:returntype", void 0)
1334
+ _ts_metadata4("design:type", Function),
1335
+ _ts_metadata4("design:paramtypes", []),
1336
+ _ts_metadata4("design:returntype", void 0)
1032
1337
  ], RunFilter.prototype, "applyOrigin", null);
1033
- _ts_decorate4([
1338
+ _ts_decorate5([
1034
1339
  FilterFor("unattributed"),
1035
- _ts_metadata3("design:type", Function),
1036
- _ts_metadata3("design:paramtypes", []),
1037
- _ts_metadata3("design:returntype", void 0)
1340
+ _ts_metadata4("design:type", Function),
1341
+ _ts_metadata4("design:paramtypes", []),
1342
+ _ts_metadata4("design:returntype", void 0)
1038
1343
  ], RunFilter.prototype, "applyUnattributed", null);
1039
- _ts_decorate4([
1344
+ _ts_decorate5([
1040
1345
  FilterFor("attr"),
1041
- _ts_metadata3("design:type", Function),
1042
- _ts_metadata3("design:paramtypes", [
1346
+ _ts_metadata4("design:type", Function),
1347
+ _ts_metadata4("design:paramtypes", [
1043
1348
  Object
1044
1349
  ]),
1045
- _ts_metadata3("design:returntype", void 0)
1350
+ _ts_metadata4("design:returntype", void 0)
1046
1351
  ], RunFilter.prototype, "applyAttributes", null);
1047
- _ts_decorate4([
1352
+ _ts_decorate5([
1048
1353
  FilterFor("limit"),
1049
- _ts_metadata3("design:type", Function),
1050
- _ts_metadata3("design:paramtypes", [
1354
+ _ts_metadata4("design:type", Function),
1355
+ _ts_metadata4("design:paramtypes", [
1051
1356
  Object
1052
1357
  ]),
1053
- _ts_metadata3("design:returntype", void 0)
1358
+ _ts_metadata4("design:returntype", void 0)
1054
1359
  ], RunFilter.prototype, "applyLimit", null);
1055
- _ts_decorate4([
1360
+ _ts_decorate5([
1056
1361
  FilterFor("offset"),
1057
- _ts_metadata3("design:type", Function),
1058
- _ts_metadata3("design:paramtypes", [
1362
+ _ts_metadata4("design:type", Function),
1363
+ _ts_metadata4("design:paramtypes", [
1059
1364
  Object
1060
1365
  ]),
1061
- _ts_metadata3("design:returntype", void 0)
1366
+ _ts_metadata4("design:returntype", void 0)
1062
1367
  ], RunFilter.prototype, "applyOffset", null);
1063
- RunFilter = _ts_decorate4([
1064
- Injectable3(),
1368
+ RunFilter = _ts_decorate5([
1369
+ Injectable4(),
1065
1370
  Filterable({
1066
1371
  entity: DurableRun,
1067
1372
  adapter: RUN_QUERY_ADAPTER,
@@ -1070,7 +1375,7 @@ RunFilter = _ts_decorate4([
1070
1375
  ], RunFilter);
1071
1376
 
1072
1377
  // src/server/durable-api.controller.ts
1073
- function _ts_decorate5(decorators, target, key, desc) {
1378
+ function _ts_decorate6(decorators, target, key, desc) {
1074
1379
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1075
1380
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1076
1381
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1083,19 +1388,19 @@ function _ts_decorate5(decorators, target, key, desc) {
1083
1388
  }
1084
1389
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1085
1390
  }
1086
- __name(_ts_decorate5, "_ts_decorate");
1087
- function _ts_metadata4(metadataKey, metadataValue) {
1391
+ __name(_ts_decorate6, "_ts_decorate");
1392
+ function _ts_metadata5(metadataKey, metadataValue) {
1088
1393
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1089
1394
  return Reflect.metadata(metadataKey, metadataValue);
1090
1395
  }
1091
1396
  }
1092
- __name(_ts_metadata4, "_ts_metadata");
1093
- function _ts_param2(paramIndex, decorator) {
1397
+ __name(_ts_metadata5, "_ts_metadata");
1398
+ function _ts_param3(paramIndex, decorator) {
1094
1399
  return function(target, key) {
1095
1400
  decorator(target, key, paramIndex);
1096
1401
  };
1097
1402
  }
1098
- __name(_ts_param2, "_ts_param");
1403
+ __name(_ts_param3, "_ts_param");
1099
1404
  var FAN_INLINE_MAX = 50;
1100
1405
  var DurableApiControllerBase = class {
1101
1406
  static {
@@ -1328,135 +1633,135 @@ var DurableApiControllerBase = class {
1328
1633
  return this.dashboard.update(id, name, body);
1329
1634
  }
1330
1635
  };
1331
- _ts_decorate5([
1636
+ _ts_decorate6([
1332
1637
  Get("runs"),
1333
- _ts_param2(0, ApplyFilter(RunFilter)),
1334
- _ts_metadata4("design:type", Function),
1335
- _ts_metadata4("design:paramtypes", [
1638
+ _ts_param3(0, ApplyFilter(RunFilter)),
1639
+ _ts_metadata5("design:type", Function),
1640
+ _ts_metadata5("design:paramtypes", [
1336
1641
  typeof RunQueryDraft === "undefined" ? Object : RunQueryDraft
1337
1642
  ]),
1338
- _ts_metadata4("design:returntype", Promise)
1643
+ _ts_metadata5("design:returntype", Promise)
1339
1644
  ], DurableApiControllerBase.prototype, "runs", null);
1340
- _ts_decorate5([
1645
+ _ts_decorate6([
1341
1646
  Get("runs/facets"),
1342
- _ts_param2(0, ApplyFilter(RunFilter)),
1343
- _ts_metadata4("design:type", Function),
1344
- _ts_metadata4("design:paramtypes", [
1647
+ _ts_param3(0, ApplyFilter(RunFilter)),
1648
+ _ts_metadata5("design:type", Function),
1649
+ _ts_metadata5("design:paramtypes", [
1345
1650
  typeof RunQueryDraft === "undefined" ? Object : RunQueryDraft
1346
1651
  ]),
1347
- _ts_metadata4("design:returntype", void 0)
1652
+ _ts_metadata5("design:returntype", void 0)
1348
1653
  ], DurableApiControllerBase.prototype, "facets", null);
1349
- _ts_decorate5([
1654
+ _ts_decorate6([
1350
1655
  Get("runs/values"),
1351
- _ts_param2(0, Query()),
1352
- _ts_metadata4("design:type", Function),
1353
- _ts_metadata4("design:paramtypes", [
1656
+ _ts_param3(0, Query()),
1657
+ _ts_metadata5("design:type", Function),
1658
+ _ts_metadata5("design:paramtypes", [
1354
1659
  typeof Record === "undefined" ? Object : Record
1355
1660
  ]),
1356
- _ts_metadata4("design:returntype", void 0)
1661
+ _ts_metadata5("design:returntype", void 0)
1357
1662
  ], DurableApiControllerBase.prototype, "values", null);
1358
- _ts_decorate5([
1663
+ _ts_decorate6([
1359
1664
  Get("metrics"),
1360
1665
  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)
1666
+ _ts_metadata5("design:type", Function),
1667
+ _ts_metadata5("design:paramtypes", []),
1668
+ _ts_metadata5("design:returntype", void 0)
1364
1669
  ], DurableApiControllerBase.prototype, "metrics", null);
1365
- _ts_decorate5([
1670
+ _ts_decorate6([
1366
1671
  Get("workers"),
1367
- _ts_metadata4("design:type", Function),
1368
- _ts_metadata4("design:paramtypes", []),
1369
- _ts_metadata4("design:returntype", void 0)
1672
+ _ts_metadata5("design:type", Function),
1673
+ _ts_metadata5("design:paramtypes", []),
1674
+ _ts_metadata5("design:returntype", void 0)
1370
1675
  ], DurableApiControllerBase.prototype, "workers", null);
1371
- _ts_decorate5([
1676
+ _ts_decorate6([
1372
1677
  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", [
1678
+ _ts_param3(0, Query("namespace")),
1679
+ _ts_param3(1, Query("workflow")),
1680
+ _ts_param3(2, Query("tag")),
1681
+ _ts_param3(3, Query("paused")),
1682
+ _ts_param3(4, Query("limit")),
1683
+ _ts_metadata5("design:type", Function),
1684
+ _ts_metadata5("design:paramtypes", [
1380
1685
  String,
1381
1686
  String,
1382
1687
  String,
1383
1688
  String,
1384
1689
  String
1385
1690
  ]),
1386
- _ts_metadata4("design:returntype", void 0)
1691
+ _ts_metadata5("design:returntype", void 0)
1387
1692
  ], DurableApiControllerBase.prototype, "schedules", null);
1388
- _ts_decorate5([
1693
+ _ts_decorate6([
1389
1694
  Post("schedules/:id/pause"),
1390
- _ts_param2(0, Param("id")),
1391
- _ts_metadata4("design:type", Function),
1392
- _ts_metadata4("design:paramtypes", [
1695
+ _ts_param3(0, Param("id")),
1696
+ _ts_metadata5("design:type", Function),
1697
+ _ts_metadata5("design:paramtypes", [
1393
1698
  String
1394
1699
  ]),
1395
- _ts_metadata4("design:returntype", void 0)
1700
+ _ts_metadata5("design:returntype", void 0)
1396
1701
  ], DurableApiControllerBase.prototype, "pauseSchedule", null);
1397
- _ts_decorate5([
1702
+ _ts_decorate6([
1398
1703
  Post("schedules/:id/resume"),
1399
- _ts_param2(0, Param("id")),
1400
- _ts_metadata4("design:type", Function),
1401
- _ts_metadata4("design:paramtypes", [
1704
+ _ts_param3(0, Param("id")),
1705
+ _ts_metadata5("design:type", Function),
1706
+ _ts_metadata5("design:paramtypes", [
1402
1707
  String
1403
1708
  ]),
1404
- _ts_metadata4("design:returntype", void 0)
1709
+ _ts_metadata5("design:returntype", void 0)
1405
1710
  ], DurableApiControllerBase.prototype, "resumeSchedule", null);
1406
- _ts_decorate5([
1711
+ _ts_decorate6([
1407
1712
  Post("schedules/:id/trigger"),
1408
- _ts_param2(0, Param("id")),
1409
- _ts_metadata4("design:type", Function),
1410
- _ts_metadata4("design:paramtypes", [
1713
+ _ts_param3(0, Param("id")),
1714
+ _ts_metadata5("design:type", Function),
1715
+ _ts_metadata5("design:paramtypes", [
1411
1716
  String
1412
1717
  ]),
1413
- _ts_metadata4("design:returntype", void 0)
1718
+ _ts_metadata5("design:returntype", void 0)
1414
1719
  ], DurableApiControllerBase.prototype, "triggerSchedule", null);
1415
- _ts_decorate5([
1720
+ _ts_decorate6([
1416
1721
  Get("workflows/:name/lifecycle"),
1417
- _ts_param2(0, Param("name")),
1418
- _ts_metadata4("design:type", Function),
1419
- _ts_metadata4("design:paramtypes", [
1722
+ _ts_param3(0, Param("name")),
1723
+ _ts_metadata5("design:type", Function),
1724
+ _ts_metadata5("design:paramtypes", [
1420
1725
  String
1421
1726
  ]),
1422
- _ts_metadata4("design:returntype", Promise)
1727
+ _ts_metadata5("design:returntype", Promise)
1423
1728
  ], DurableApiControllerBase.prototype, "workflowLifecycle", null);
1424
- _ts_decorate5([
1729
+ _ts_decorate6([
1425
1730
  Get("topology"),
1426
- _ts_metadata4("design:type", Function),
1427
- _ts_metadata4("design:paramtypes", []),
1428
- _ts_metadata4("design:returntype", void 0)
1731
+ _ts_metadata5("design:type", Function),
1732
+ _ts_metadata5("design:paramtypes", []),
1733
+ _ts_metadata5("design:returntype", void 0)
1429
1734
  ], DurableApiControllerBase.prototype, "topology", null);
1430
- _ts_decorate5([
1735
+ _ts_decorate6([
1431
1736
  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({
1737
+ _ts_param3(0, Param("id")),
1738
+ _ts_param3(1, Query("full")),
1739
+ _ts_param3(2, Headers("if-none-match")),
1740
+ _ts_param3(3, Res({
1436
1741
  passthrough: true
1437
1742
  })),
1438
- _ts_metadata4("design:type", Function),
1439
- _ts_metadata4("design:paramtypes", [
1743
+ _ts_metadata5("design:type", Function),
1744
+ _ts_metadata5("design:paramtypes", [
1440
1745
  String,
1441
1746
  String,
1442
1747
  String,
1443
1748
  Object
1444
1749
  ]),
1445
- _ts_metadata4("design:returntype", Promise)
1750
+ _ts_metadata5("design:returntype", Promise)
1446
1751
  ], DurableApiControllerBase.prototype, "run", null);
1447
- _ts_decorate5([
1752
+ _ts_decorate6([
1448
1753
  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({
1754
+ _ts_param3(0, Param("id")),
1755
+ _ts_param3(1, Param("group")),
1756
+ _ts_param3(2, Query("offset")),
1757
+ _ts_param3(3, Query("limit")),
1758
+ _ts_param3(4, Query("failed")),
1759
+ _ts_param3(5, Headers("if-none-match")),
1760
+ _ts_param3(6, Res({
1456
1761
  passthrough: true
1457
1762
  })),
1458
- _ts_metadata4("design:type", Function),
1459
- _ts_metadata4("design:paramtypes", [
1763
+ _ts_metadata5("design:type", Function),
1764
+ _ts_metadata5("design:paramtypes", [
1460
1765
  String,
1461
1766
  String,
1462
1767
  String,
@@ -1465,131 +1770,131 @@ _ts_decorate5([
1465
1770
  String,
1466
1771
  Object
1467
1772
  ]),
1468
- _ts_metadata4("design:returntype", Promise)
1773
+ _ts_metadata5("design:returntype", Promise)
1469
1774
  ], DurableApiControllerBase.prototype, "fanMembers", null);
1470
- _ts_decorate5([
1775
+ _ts_decorate6([
1471
1776
  Sse("runs/:id/stream"),
1472
- _ts_param2(0, Param("id")),
1473
- _ts_metadata4("design:type", Function),
1474
- _ts_metadata4("design:paramtypes", [
1777
+ _ts_param3(0, Param("id")),
1778
+ _ts_metadata5("design:type", Function),
1779
+ _ts_metadata5("design:paramtypes", [
1475
1780
  String
1476
1781
  ]),
1477
- _ts_metadata4("design:returntype", void 0)
1782
+ _ts_metadata5("design:returntype", void 0)
1478
1783
  ], DurableApiControllerBase.prototype, "stream", null);
1479
- _ts_decorate5([
1784
+ _ts_decorate6([
1480
1785
  Post("runs/:id/retry"),
1481
- _ts_param2(0, Param("id")),
1482
- _ts_metadata4("design:type", Function),
1483
- _ts_metadata4("design:paramtypes", [
1786
+ _ts_param3(0, Param("id")),
1787
+ _ts_metadata5("design:type", Function),
1788
+ _ts_metadata5("design:paramtypes", [
1484
1789
  String
1485
1790
  ]),
1486
- _ts_metadata4("design:returntype", void 0)
1791
+ _ts_metadata5("design:returntype", void 0)
1487
1792
  ], DurableApiControllerBase.prototype, "retry", null);
1488
- _ts_decorate5([
1793
+ _ts_decorate6([
1489
1794
  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", [
1795
+ _ts_param3(0, Param("id")),
1796
+ _ts_param3(1, Body()),
1797
+ _ts_metadata5("design:type", Function),
1798
+ _ts_metadata5("design:paramtypes", [
1494
1799
  String,
1495
1800
  Object
1496
1801
  ]),
1497
- _ts_metadata4("design:returntype", void 0)
1802
+ _ts_metadata5("design:returntype", void 0)
1498
1803
  ], DurableApiControllerBase.prototype, "retryWithInput", null);
1499
- _ts_decorate5([
1804
+ _ts_decorate6([
1500
1805
  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", [
1806
+ _ts_param3(0, Param("action")),
1807
+ _ts_param3(1, ApplyFilter(RunFilter)),
1808
+ _ts_param3(2, Query("compensate")),
1809
+ _ts_metadata5("design:type", Function),
1810
+ _ts_metadata5("design:paramtypes", [
1506
1811
  String,
1507
1812
  typeof RunQueryDraft === "undefined" ? Object : RunQueryDraft,
1508
1813
  String
1509
1814
  ]),
1510
- _ts_metadata4("design:returntype", void 0)
1815
+ _ts_metadata5("design:returntype", void 0)
1511
1816
  ], DurableApiControllerBase.prototype, "bulk", null);
1512
- _ts_decorate5([
1817
+ _ts_decorate6([
1513
1818
  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", [
1819
+ _ts_param3(0, Param("id")),
1820
+ _ts_param3(1, Query("compensate")),
1821
+ _ts_metadata5("design:type", Function),
1822
+ _ts_metadata5("design:paramtypes", [
1518
1823
  String,
1519
1824
  String
1520
1825
  ]),
1521
- _ts_metadata4("design:returntype", Promise)
1826
+ _ts_metadata5("design:returntype", Promise)
1522
1827
  ], DurableApiControllerBase.prototype, "cancel", null);
1523
- _ts_decorate5([
1828
+ _ts_decorate6([
1524
1829
  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", [
1830
+ _ts_param3(0, Param("id")),
1831
+ _ts_param3(1, Body()),
1832
+ _ts_metadata5("design:type", Function),
1833
+ _ts_metadata5("design:paramtypes", [
1529
1834
  String,
1530
1835
  Object
1531
1836
  ]),
1532
- _ts_metadata4("design:returntype", Promise)
1837
+ _ts_metadata5("design:returntype", Promise)
1533
1838
  ], DurableApiControllerBase.prototype, "republishLifecycle", null);
1534
- _ts_decorate5([
1839
+ _ts_decorate6([
1535
1840
  Post("runs/:id/continue"),
1536
- _ts_param2(0, Param("id")),
1537
- _ts_metadata4("design:type", Function),
1538
- _ts_metadata4("design:paramtypes", [
1841
+ _ts_param3(0, Param("id")),
1842
+ _ts_metadata5("design:type", Function),
1843
+ _ts_metadata5("design:paramtypes", [
1539
1844
  String
1540
1845
  ]),
1541
- _ts_metadata4("design:returntype", Promise)
1846
+ _ts_metadata5("design:returntype", Promise)
1542
1847
  ], DurableApiControllerBase.prototype, "continue", null);
1543
- _ts_decorate5([
1848
+ _ts_decorate6([
1544
1849
  Post("runs/:id/redispatch"),
1545
- _ts_param2(0, Param("id")),
1546
- _ts_metadata4("design:type", Function),
1547
- _ts_metadata4("design:paramtypes", [
1850
+ _ts_param3(0, Param("id")),
1851
+ _ts_metadata5("design:type", Function),
1852
+ _ts_metadata5("design:paramtypes", [
1548
1853
  String
1549
1854
  ]),
1550
- _ts_metadata4("design:returntype", Promise)
1855
+ _ts_metadata5("design:returntype", Promise)
1551
1856
  ], DurableApiControllerBase.prototype, "redispatch", null);
1552
- _ts_decorate5([
1857
+ _ts_decorate6([
1553
1858
  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", [
1859
+ _ts_param3(0, Param("token")),
1860
+ _ts_param3(1, Body()),
1861
+ _ts_metadata5("design:type", Function),
1862
+ _ts_metadata5("design:paramtypes", [
1558
1863
  String,
1559
1864
  Object
1560
1865
  ]),
1561
- _ts_metadata4("design:returntype", Promise)
1866
+ _ts_metadata5("design:returntype", Promise)
1562
1867
  ], DurableApiControllerBase.prototype, "webhook", null);
1563
- _ts_decorate5([
1868
+ _ts_decorate6([
1564
1869
  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", [
1870
+ _ts_param3(0, Param("id")),
1871
+ _ts_param3(1, Param("key")),
1872
+ _ts_metadata5("design:type", Function),
1873
+ _ts_metadata5("design:paramtypes", [
1569
1874
  String,
1570
1875
  String
1571
1876
  ]),
1572
- _ts_metadata4("design:returntype", void 0)
1877
+ _ts_metadata5("design:returntype", void 0)
1573
1878
  ], DurableApiControllerBase.prototype, "event", null);
1574
- _ts_decorate5([
1879
+ _ts_decorate6([
1575
1880
  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", [
1881
+ _ts_param3(0, Param("id")),
1882
+ _ts_param3(1, Param("name")),
1883
+ _ts_param3(2, Body()),
1884
+ _ts_metadata5("design:type", Function),
1885
+ _ts_metadata5("design:paramtypes", [
1581
1886
  String,
1582
1887
  String,
1583
1888
  Object
1584
1889
  ]),
1585
- _ts_metadata4("design:returntype", void 0)
1890
+ _ts_metadata5("design:returntype", void 0)
1586
1891
  ], DurableApiControllerBase.prototype, "update", null);
1587
- DurableApiControllerBase = _ts_decorate5([
1892
+ DurableApiControllerBase = _ts_decorate6([
1588
1893
  Controller(),
1589
1894
  UseInterceptors(ApplyFilterInterceptor),
1590
- UseFilters(NotModifiedFilter),
1591
- _ts_metadata4("design:type", Function),
1592
- _ts_metadata4("design:paramtypes", [
1895
+ UseFilters2(NotModifiedFilter),
1896
+ _ts_metadata5("design:type", Function),
1897
+ _ts_metadata5("design:paramtypes", [
1593
1898
  typeof DashboardService === "undefined" ? Object : DashboardService,
1594
1899
  typeof FilterRunner === "undefined" ? Object : FilterRunner
1595
1900
  ])
@@ -1613,14 +1918,14 @@ var DurableApiController = class extends DurableApiControllerBase {
1613
1918
  __name(this, "DurableApiController");
1614
1919
  }
1615
1920
  };
1616
- DurableApiController = _ts_decorate5([
1921
+ DurableApiController = _ts_decorate6([
1617
1922
  Controller()
1618
1923
  ], DurableApiController);
1619
1924
 
1620
1925
  // src/server/durable-dashboard.module.ts
1621
1926
  import "reflect-metadata";
1622
1927
  import { ApplyFilterInterceptor as ApplyFilterInterceptor2, FilterRunner as FilterRunner2 } from "@dudousxd/nestjs-filter";
1623
- import { Logger, Module } from "@nestjs/common";
1928
+ import { Module } from "@nestjs/common";
1624
1929
  import { ModuleRef, RouterModule } from "@nestjs/core";
1625
1930
 
1626
1931
  // src/server/controller-decorators.ts
@@ -1653,8 +1958,8 @@ __name(controllerFor, "controllerFor");
1653
1958
  import { existsSync, readFileSync } from "node:fs";
1654
1959
  import { basename, extname, join, resolve, sep } from "node:path";
1655
1960
  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) {
1961
+ import { Controller as Controller2, Get as Get2, Header as Header2, Inject as Inject3, NotFoundException as NotFoundException2, Param as Param2, StreamableFile } from "@nestjs/common";
1962
+ function _ts_decorate7(decorators, target, key, desc) {
1658
1963
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1659
1964
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1660
1965
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1667,19 +1972,19 @@ function _ts_decorate6(decorators, target, key, desc) {
1667
1972
  }
1668
1973
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1669
1974
  }
1670
- __name(_ts_decorate6, "_ts_decorate");
1671
- function _ts_metadata5(metadataKey, metadataValue) {
1975
+ __name(_ts_decorate7, "_ts_decorate");
1976
+ function _ts_metadata6(metadataKey, metadataValue) {
1672
1977
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1673
1978
  return Reflect.metadata(metadataKey, metadataValue);
1674
1979
  }
1675
1980
  }
1676
- __name(_ts_metadata5, "_ts_metadata");
1677
- function _ts_param3(paramIndex, decorator) {
1981
+ __name(_ts_metadata6, "_ts_metadata");
1982
+ function _ts_param4(paramIndex, decorator) {
1678
1983
  return function(target, key) {
1679
1984
  decorator(target, key, paramIndex);
1680
1985
  };
1681
1986
  }
1682
- __name(_ts_param3, "_ts_param");
1987
+ __name(_ts_param4, "_ts_param");
1683
1988
  var DASHBOARD_BASE_PATH = Symbol("DASHBOARD_BASE_PATH");
1684
1989
  var DASHBOARD_API_PATH = Symbol("DASHBOARD_API_PATH");
1685
1990
  var BUILD_BASE = "/durable";
@@ -1732,30 +2037,31 @@ var DurableUiControllerBase = class {
1732
2037
  });
1733
2038
  }
1734
2039
  };
1735
- _ts_decorate6([
2040
+ _ts_decorate7([
1736
2041
  Get2(),
1737
2042
  Header2("Content-Type", "text/html; charset=utf-8"),
1738
2043
  Header2("Cache-Control", "no-store, must-revalidate"),
1739
- _ts_metadata5("design:type", Function),
1740
- _ts_metadata5("design:paramtypes", []),
1741
- _ts_metadata5("design:returntype", String)
2044
+ _ts_metadata6("design:type", Function),
2045
+ _ts_metadata6("design:paramtypes", []),
2046
+ _ts_metadata6("design:returntype", String)
1742
2047
  ], DurableUiControllerBase.prototype, "index", null);
1743
- _ts_decorate6([
2048
+ _ts_decorate7([
1744
2049
  Get2("assets/:file"),
1745
2050
  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", [
2051
+ _ts_param4(0, Param2("file")),
2052
+ _ts_metadata6("design:type", Function),
2053
+ _ts_metadata6("design:paramtypes", [
1749
2054
  String
1750
2055
  ]),
1751
- _ts_metadata5("design:returntype", typeof StreamableFile === "undefined" ? Object : StreamableFile)
2056
+ _ts_metadata6("design:returntype", typeof StreamableFile === "undefined" ? Object : StreamableFile)
1752
2057
  ], DurableUiControllerBase.prototype, "asset", null);
1753
- DurableUiControllerBase = _ts_decorate6([
2058
+ DurableUiControllerBase = _ts_decorate7([
1754
2059
  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", [
2060
+ ConsolePage(),
2061
+ _ts_param4(0, Inject3(DASHBOARD_BASE_PATH)),
2062
+ _ts_param4(1, Inject3(DASHBOARD_API_PATH)),
2063
+ _ts_metadata6("design:type", Function),
2064
+ _ts_metadata6("design:paramtypes", [
1759
2065
  String,
1760
2066
  String
1761
2067
  ])
@@ -1765,12 +2071,12 @@ var DurableUiController = class extends DurableUiControllerBase {
1765
2071
  __name(this, "DurableUiController");
1766
2072
  }
1767
2073
  };
1768
- DurableUiController = _ts_decorate6([
2074
+ DurableUiController = _ts_decorate7([
1769
2075
  Controller2()
1770
2076
  ], DurableUiController);
1771
2077
 
1772
2078
  // src/server/durable-dashboard.module.ts
1773
- function _ts_decorate7(decorators, target, key, desc) {
2079
+ function _ts_decorate8(decorators, target, key, desc) {
1774
2080
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1775
2081
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1776
2082
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1783,31 +2089,9 @@ function _ts_decorate7(decorators, target, key, desc) {
1783
2089
  }
1784
2090
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1785
2091
  }
1786
- __name(_ts_decorate7, "_ts_decorate");
2092
+ __name(_ts_decorate8, "_ts_decorate");
1787
2093
  markOpenToAuthorization(DurableApiController);
1788
2094
  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
2095
  function assertNothingToDecorate(options) {
1812
2096
  if (options.decorators === void 0) return;
1813
2097
  throw new Error([
@@ -1818,6 +2102,13 @@ function assertNothingToDecorate(options) {
1818
2102
  ].join(" "));
1819
2103
  }
1820
2104
  __name(assertNothingToDecorate, "assertNothingToDecorate");
2105
+ function consoleController(base, decorators) {
2106
+ return controllerFor(base, [
2107
+ ...decorators ?? [],
2108
+ UseConsoleAuthorize()
2109
+ ]);
2110
+ }
2111
+ __name(consoleController, "consoleController");
1821
2112
  function normalize(path) {
1822
2113
  return `/${path.replace(/^\/+|\/+$/g, "")}`;
1823
2114
  }
@@ -1834,10 +2125,20 @@ var DurableApiModule = class _DurableApiModule {
1834
2125
  ...options.imports ?? []
1835
2126
  ],
1836
2127
  controllers: routes ? [
1837
- controllerFor(DurableApiController, options.decorators)
2128
+ consoleController(DurableApiController, options.decorators)
1838
2129
  ] : [],
1839
2130
  providers: [
1840
2131
  DashboardService,
2132
+ // Resolved at boot: a gate name without nestjs-authz, or a policy without
2133
+ // @nestjs/authorization, fails here rather than on the first request.
2134
+ {
2135
+ provide: CONSOLE_AUTHORIZE_DECIDE,
2136
+ // Also with `routes: false`: `@UseConsoleAuthorize()` still applies the production 403.
2137
+ useFactory: /* @__PURE__ */ __name((moduleRef) => resolveConsoleAuthorize(options.authorize, moduleRef), "useFactory"),
2138
+ inject: [
2139
+ ModuleRef
2140
+ ]
2141
+ },
1841
2142
  // `@dudousxd/nestjs-filter` is wired PRIVATELY here rather than through
1842
2143
  // `FilterModule.forRoot()`, which is a global registration. A library calling that would
1843
2144
  // fight the host app over one set of module options and register a second app-wide
@@ -1875,15 +2176,17 @@ var DurableApiModule = class _DurableApiModule {
1875
2176
  // is only exported then: exporting it from a mounted console would shadow a host's own
1876
2177
  // `FilterModule` runner in whatever module imports the dashboard.
1877
2178
  exports: routes ? [
1878
- DashboardService
2179
+ DashboardService,
2180
+ CONSOLE_AUTHORIZE_DECIDE
1879
2181
  ] : [
1880
2182
  DashboardService,
1881
- FilterRunner2
2183
+ FilterRunner2,
2184
+ CONSOLE_AUTHORIZE_DECIDE
1882
2185
  ]
1883
2186
  };
1884
2187
  }
1885
2188
  };
1886
- DurableApiModule = _ts_decorate7([
2189
+ DurableApiModule = _ts_decorate8([
1887
2190
  Module({})
1888
2191
  ], DurableApiModule);
1889
2192
  var DurableDashboardModule = class _DurableDashboardModule {
@@ -1909,6 +2212,9 @@ var DurableDashboardModule = class _DurableDashboardModule {
1909
2212
  ...options.imports ? {
1910
2213
  imports: options.imports
1911
2214
  } : {},
2215
+ ...options.authorize !== void 0 ? {
2216
+ authorize: options.authorize
2217
+ } : {},
1912
2218
  routes: false
1913
2219
  });
1914
2220
  return {
@@ -1920,7 +2226,8 @@ var DurableDashboardModule = class _DurableDashboardModule {
1920
2226
  controllers: [],
1921
2227
  providers: pathProviders,
1922
2228
  // 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.
2229
+ // the SPA's paths, the read/action service, the filter runner and the resolved `authorize`
2230
+ // (for `@UseConsoleAuthorize()`) via the API module.
1924
2231
  exports: [
1925
2232
  DurableApiModule,
1926
2233
  DASHBOARD_BASE_PATH,
@@ -1928,7 +2235,6 @@ var DurableDashboardModule = class _DurableDashboardModule {
1928
2235
  ]
1929
2236
  };
1930
2237
  }
1931
- const decorated = (options.decorators?.length ?? 0) > 0;
1932
2238
  return {
1933
2239
  module: _DurableDashboardModule,
1934
2240
  imports: [
@@ -1942,6 +2248,9 @@ var DurableDashboardModule = class _DurableDashboardModule {
1942
2248
  } : {},
1943
2249
  ...options.decorators ? {
1944
2250
  decorators: options.decorators
2251
+ } : {},
2252
+ ...options.authorize !== void 0 ? {
2253
+ authorize: options.authorize
1945
2254
  } : {}
1946
2255
  }),
1947
2256
  RouterModule.register([
@@ -1956,14 +2265,9 @@ var DurableDashboardModule = class _DurableDashboardModule {
1956
2265
  ])
1957
2266
  ],
1958
2267
  controllers: [
1959
- controllerFor(DurableUiController, options.decorators)
1960
- ],
1961
- providers: [
1962
- ...pathProviders,
1963
- ...decorated ? [] : [
1964
- protectionCheckProvider()
1965
- ]
2268
+ consoleController(DurableUiController, options.decorators)
1966
2269
  ],
2270
+ providers: pathProviders,
1967
2271
  // Re-export the API module so its DashboardService reaches importers (e.g. flip's own controllers).
1968
2272
  exports: [
1969
2273
  DurableApiModule
@@ -1971,13 +2275,20 @@ var DurableDashboardModule = class _DurableDashboardModule {
1971
2275
  };
1972
2276
  }
1973
2277
  };
1974
- DurableDashboardModule = _ts_decorate7([
2278
+ DurableDashboardModule = _ts_decorate8([
1975
2279
  Module({})
1976
2280
  ], DurableDashboardModule);
1977
2281
  export {
2282
+ CONSOLE_AUTHORIZE_DECIDE,
2283
+ CONSOLE_AUTHORIZE_MISSING_WARNING,
2284
+ CONSOLE_GATE,
2285
+ CONSOLE_PAGE_METADATA,
2286
+ ConsoleAccessDenied,
2287
+ ConsoleAuthorizeFilter,
2288
+ ConsoleAuthorizeGuard,
2289
+ ConsolePage,
1978
2290
  DASHBOARD_API_PATH,
1979
2291
  DASHBOARD_BASE_PATH,
1980
- DASHBOARD_PROTECTION_CHECK,
1981
2292
  DashboardService,
1982
2293
  DurableApiController,
1983
2294
  DurableApiControllerBase,
@@ -1985,6 +2296,9 @@ export {
1985
2296
  DurableDashboardModule,
1986
2297
  DurableUiController,
1987
2298
  DurableUiControllerBase,
1988
- UNPROTECTED_CONSOLE_IN_PRODUCTION
2299
+ UseConsoleAuthorize,
2300
+ authorizeByToken,
2301
+ normalizeConsoleResult,
2302
+ resolveConsoleAuthorize
1989
2303
  };
1990
2304
  //# sourceMappingURL=index.js.map