@flusys/nestjs-entity-builder 9.1.2 → 9.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +49 -25
  2. package/config/entity-builder.constants.d.ts +1 -0
  3. package/config/message-keys.d.ts +37 -2
  4. package/controllers/definition-bundle.controller.d.ts +2 -2
  5. package/controllers/entity-definition.controller.d.ts +1 -1
  6. package/controllers/field-definition.controller.d.ts +1 -1
  7. package/controllers/flow-definition.controller.d.ts +3 -1
  8. package/controllers/flow-runtime.controller.d.ts +4 -3
  9. package/dtos/definition-bundle.dto.d.ts +1 -0
  10. package/dtos/entity-definition.dto.d.ts +1 -2
  11. package/fesm/21.js +39 -5
  12. package/fesm/{458.js → 28.js} +110 -63
  13. package/fesm/677.js +1543 -513
  14. package/fesm/794.js +1 -1
  15. package/fesm/857.js +3 -3
  16. package/fesm/870.js +974 -558
  17. package/fesm/897.js +187 -51
  18. package/fesm/946.js +72 -43
  19. package/fesm/config/index.js +10 -14
  20. package/fesm/docs/index.js +1 -1
  21. package/fesm/dtos/index.js +11 -0
  22. package/fesm/guards/index.js +16 -10
  23. package/fesm/index.js +44 -26
  24. package/fesm/modules/index.js +4 -3
  25. package/fesm/services/index.js +40 -59
  26. package/flow-engine/flow-code-runner.d.ts +16 -0
  27. package/flow-engine/flow-graph.validator.d.ts +1 -0
  28. package/flow-engine/flow-input.validator.d.ts +16 -1
  29. package/flow-engine/flow-run.types.d.ts +16 -0
  30. package/flow-engine/flow.types.d.ts +18 -1
  31. package/guards/designer-writable.interceptor.d.ts +1 -0
  32. package/interfaces/definition-bundle.interface.d.ts +4 -1
  33. package/interfaces/entity-builder-module.interface.d.ts +9 -0
  34. package/modules/entity-builder.module.d.ts +1 -0
  35. package/modules/index.d.ts +1 -0
  36. package/modules/tenant-context-id.strategy.d.ts +16 -0
  37. package/package.json +3 -4
  38. package/services/definition-bundle.diff.d.ts +6 -2
  39. package/services/definition-bundle.file.d.ts +2 -1
  40. package/services/definition-bundle.service.d.ts +10 -3
  41. package/services/entity-builder-config.service.d.ts +3 -0
  42. package/services/entity-builder-datasource.provider.d.ts +1 -0
  43. package/services/entity-flow-scaffold.d.ts +2 -1
  44. package/services/entity-permission.service.d.ts +1 -0
  45. package/services/field-value-validator.d.ts +7 -0
  46. package/services/flow-definition.service.d.ts +11 -3
  47. package/services/flow-executor.service.d.ts +3 -0
  48. package/services/flow-runtime.service.d.ts +7 -1
  49. package/services/generic-entity-service.factory.d.ts +5 -1
  50. package/services/generic-entity.service.d.ts +25 -2
  51. package/services/identifier-rules.d.ts +0 -1
  52. package/services/save-loaded.d.ts +2 -0
  53. package/services/schema-change-executor.service.d.ts +1 -0
  54. package/services/schema-columns.d.ts +7 -2
  55. package/services/schema-dialect-adapter.service.d.ts +2 -0
  56. package/services/schema-evolution.service.d.ts +8 -2
  57. package/services/schema-registry.service.d.ts +12 -0
  58. package/services/schema-sync.service.d.ts +3 -1
  59. package/flow-engine/flow-code-sandbox.d.ts +0 -5
@@ -1,10 +1,11 @@
1
+ import { type ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
1
2
  import { type FlowDefinition } from '../entities/flow-definition.entity.js';
2
3
  import { type IFlowEndpoint } from '../flow-engine/flow.types.js';
3
4
  import { FlowRuntimeService } from '../services/flow-runtime.service.js';
4
5
  type FlowRequest = {
5
6
  flowDefinition: FlowDefinition;
6
7
  flowEndpoint: IFlowEndpoint;
7
- user?: never;
8
+ user?: ILoggedUserInfo;
8
9
  ip?: string;
9
10
  headers: Record<string, unknown>;
10
11
  query?: Record<string, unknown>;
@@ -13,10 +14,10 @@ type FlowRequest = {
13
14
  export declare class FlowRuntimeController {
14
15
  private readonly runtime;
15
16
  constructor(runtime: FlowRuntimeService);
16
- run(_slug: string, body: unknown, req: FlowRequest, res: {
17
+ run(body: unknown, req: FlowRequest, res: {
17
18
  status(code: number): unknown;
18
19
  }): Promise<unknown>;
19
- runEndpoint(_slug: string, _endpoint: string, body: unknown, req: FlowRequest, res: {
20
+ runEndpoint(body: unknown, req: FlowRequest, res: {
20
21
  status(code: number): unknown;
21
22
  }): Promise<unknown>;
22
23
  private answer;
@@ -51,6 +51,7 @@ export declare class ExportBundleDto {
51
51
  }
52
52
  export declare class ImportBundleOptionsDto {
53
53
  deprecateMissingFields?: boolean;
54
+ deactivateMissingFlows?: boolean;
54
55
  confirm?: boolean;
55
56
  expectedChecksum?: string;
56
57
  expectedPlanChecksum?: string;
@@ -31,13 +31,12 @@ export declare class EntityFlowNamesDto {
31
31
  }
32
32
  export declare class EntityFlowInputLabelsDto {
33
33
  id?: string;
34
- ids?: string;
35
- search?: string;
36
34
  }
37
35
  export declare class EntityFlowTextsDto {
38
36
  names?: EntityFlowNamesDto;
39
37
  inputLabels?: EntityFlowInputLabelsDto;
40
38
  noMatchMessage?: string;
39
+ deleteOnlyMessage?: string;
41
40
  }
42
41
  export declare class CreateDynamicEntityDto extends CreateEntityDefinitionDto {
43
42
  fields?: EntityFieldSpecDto[];
package/fesm/21.js CHANGED
@@ -2,7 +2,6 @@ export const __rspack_esm_id = 21;
2
2
  export const __rspack_esm_ids = [21];
3
3
  export const __webpack_modules__ = {
4
4
  5732(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
5
- // ==================== ENTITY BUILDER MODULE MESSAGE KEYS ====================
6
5
  // The CRUD `*_SUCCESS` keys are the ones createApiController emits for `entityName: 'entity_builder.<resource>'`.
7
6
  const ENTITY_DEFINITION_MESSAGES = {
8
7
  NOT_FOUND: 'entity_builder.entity_definition.not.found',
@@ -35,7 +34,6 @@ const FLOW_DEFINITION_MESSAGES = {
35
34
  CREATE_SUCCESS: 'entity_builder.flow_definition.create.success',
36
35
  UPDATE_SUCCESS: 'entity_builder.flow_definition.update.success',
37
36
  DELETE_SUCCESS: 'entity_builder.flow_definition.delete.success',
38
- RESTORE_SUCCESS: 'entity_builder.flow_definition.restore.success',
39
37
  GET_SUCCESS: 'entity_builder.flow_definition.get.success',
40
38
  GET_BY_IDS_SUCCESS: 'entity_builder.flow_definition.get.by.ids.success',
41
39
  GET_BY_FILTER_SUCCESS: 'entity_builder.flow_definition.get.by.filter.success',
@@ -280,17 +278,23 @@ const FLOW_MESSAGES = {
280
278
  TEST_SUCCESS: 'entity_builder.flow.test.success',
281
279
  INPUT_INVALID: 'entity_builder.flow.input.invalid',
282
280
  INPUT_BODY_NOT_LIST: 'entity_builder.flow.input.body.not.list',
281
+ INPUT_SORT_INVALID: 'entity_builder.flow.input.sort.invalid',
282
+ INPUT_SELECT_INVALID: 'entity_builder.flow.input.select.invalid',
283
+ INPUT_PAGE_INVALID: 'entity_builder.flow.input.page.invalid',
284
+ INPUT_PAGE_SIZE_INVALID: 'entity_builder.flow.input.page.size.invalid',
283
285
  INPUT_BODY_ITEM_NOT_OBJECT: 'entity_builder.flow.input.body.item.not.object',
284
286
  CHECKS_FAILED: 'entity_builder.flow.checks.failed',
285
287
  PERMISSION_DENIED: 'entity_builder.flow.permission.denied',
286
288
  PUBLISH_SUCCESS: 'entity_builder.flow.publish.success',
287
289
  NOTHING_TO_PUBLISH: 'entity_builder.flow.nothing.to.publish',
288
290
  VERSIONS_SUCCESS: 'entity_builder.flow.versions.success',
291
+ CODE_PACKAGES_SUCCESS: 'entity_builder.flow.code.packages.success',
289
292
  VERSION_SUCCESS: 'entity_builder.flow.version.success',
290
293
  VERSION_NOT_FOUND: 'entity_builder.flow.version.not.found',
291
294
  VERSION_RESTORED: 'entity_builder.flow.version.restored',
292
295
  DRAFT_DISCARDED: 'entity_builder.flow.draft.discarded',
293
- NO_DRAFT: 'entity_builder.flow.no.draft'
296
+ NO_DRAFT: 'entity_builder.flow.no.draft',
297
+ RESTORE_UNSUPPORTED: 'entity_builder.flow.restore.unsupported'
294
298
  };
295
299
  /** Why a run was stopped or a node failed (`trace[].error`, `body.messageKey`). */ const FLOW_ERROR_MESSAGES = {
296
300
  NO_TRIGGER: 'entity_builder.flow.error.no.trigger',
@@ -301,6 +305,8 @@ const FLOW_MESSAGES = {
301
305
  UNKNOWN_NODE_TYPE: 'entity_builder.flow.error.unknown.node.type',
302
306
  RECORD_ID_MISSING: 'entity_builder.flow.error.record.id.missing',
303
307
  LIST_NOT_A_LIST: 'entity_builder.flow.error.list.not.a.list',
308
+ RESPOND_DATA_NOT_LIST: 'entity_builder.flow.error.respond.data.not.list',
309
+ RESPOND_META_INVALID: 'entity_builder.flow.error.respond.meta.invalid',
304
310
  TOO_MANY_WRITES: 'entity_builder.flow.error.too.many.writes',
305
311
  WRITE_FILTER_EMPTY: 'entity_builder.flow.error.write.filter.empty',
306
312
  TOO_MANY_MATCHES: 'entity_builder.flow.error.too.many.matches',
@@ -363,6 +369,7 @@ const FLOW_MESSAGES = {
363
369
  TRIGGER_MISSING: 'entity_builder.flow.validation.trigger.missing',
364
370
  TRIGGER_MAIN_DUPLICATE: 'entity_builder.flow.validation.trigger.main.duplicate',
365
371
  TRIGGER_PATH_INVALID: 'entity_builder.flow.validation.trigger.path.invalid',
372
+ TRIGGER_CONTRACT_INVALID: 'entity_builder.flow.validation.trigger.contract.invalid',
366
373
  TRIGGER_PATH_DUPLICATE: 'entity_builder.flow.validation.trigger.path.duplicate',
367
374
  EDGE_ID_DUPLICATE: 'entity_builder.flow.validation.edge.id.duplicate',
368
375
  EDGE_DANGLING: 'entity_builder.flow.validation.edge.dangling',
@@ -375,6 +382,7 @@ const FLOW_MESSAGES = {
375
382
  TRANSACTIONAL_HTTP: 'entity_builder.flow.validation.transactional.http',
376
383
  WRITES_NOT_TRANSACTIONAL: 'entity_builder.flow.validation.writes.not.transactional',
377
384
  NODE_COMMIT_CONTINUE: 'entity_builder.flow.validation.node.commit.continue',
385
+ NODE_CONTINUE_UNSUPPORTED: 'entity_builder.flow.validation.node.continue.unsupported',
378
386
  COMMIT_NOT_TRANSACTIONAL: 'entity_builder.flow.validation.commit.not.transactional',
379
387
  COMMIT_IN_LOOP: 'entity_builder.flow.validation.commit.in.loop',
380
388
  COMMIT_IN_CALLED_FLOW: 'entity_builder.flow.validation.commit.in.called.flow',
@@ -392,6 +400,7 @@ const FLOW_MESSAGES = {
392
400
  INPUT_TOO_MANY: 'entity_builder.flow.validation.input.too.many',
393
401
  INPUT_NAME_INVALID: 'entity_builder.flow.validation.input.name.invalid',
394
402
  INPUT_NAME_DUPLICATE: 'entity_builder.flow.validation.input.name.duplicate',
403
+ INPUT_NAME_RESERVED: 'entity_builder.flow.validation.input.name.reserved',
395
404
  INPUT_TYPE_UNKNOWN: 'entity_builder.flow.validation.input.type.unknown',
396
405
  INPUT_CHOICE_NO_OPTIONS: 'entity_builder.flow.validation.input.choice.no.options',
397
406
  INPUT_ITEM_TYPE_UNKNOWN: 'entity_builder.flow.validation.input.item.type.unknown',
@@ -410,6 +419,9 @@ const FLOW_MESSAGES = {
410
419
  NODE_CASE_DUPLICATE: 'entity_builder.flow.validation.node.case.duplicate',
411
420
  NODE_MAX_ITEMS_RANGE: 'entity_builder.flow.validation.node.max.items.range',
412
421
  NODE_LIMIT_RANGE: 'entity_builder.flow.validation.node.limit.range',
422
+ NODE_QUERY_FROM_REQUEST_INVALID: 'entity_builder.flow.validation.node.query.from.request.invalid',
423
+ NODE_QUERY_NOT_GET_ALL: 'entity_builder.flow.validation.node.query.not.get.all',
424
+ NODE_GET_NOT_GET_BY_ID: 'entity_builder.flow.validation.node.get.not.get.by.id',
413
425
  NODE_SORT_INVALID: 'entity_builder.flow.validation.node.sort.invalid',
414
426
  NODE_WRITE_TARGET_INVALID: 'entity_builder.flow.validation.node.write.target.invalid',
415
427
  NODE_NOT_FOUND_INVALID: 'entity_builder.flow.validation.node.not.found.invalid',
@@ -445,6 +457,9 @@ const FLOW_MESSAGES = {
445
457
  MESSAGE_AFTER_COMMIT: 'entity_builder.flow.validation.message.after.commit',
446
458
  PUBLIC_MESSAGE: 'entity_builder.flow.validation.public.message',
447
459
  NODE_STATUS_2XX_5XX: 'entity_builder.flow.validation.node.status.2xx.5xx',
460
+ NODE_RESPOND_FORMAT_INVALID: 'entity_builder.flow.validation.node.respond.format.invalid',
461
+ NODE_RESPOND_MESSAGE_REQUIRED: 'entity_builder.flow.validation.node.respond.message.required',
462
+ NODE_RESPOND_LIST_VALUE_REQUIRED: 'entity_builder.flow.validation.node.respond.list.value.required',
448
463
  REF_BAD_SCOPE: 'entity_builder.flow.validation.ref.bad.scope',
449
464
  REF_NODE_MISSING: 'entity_builder.flow.validation.ref.node.missing',
450
465
  REF_SELF: 'entity_builder.flow.validation.ref.self',
@@ -465,7 +480,8 @@ const FLOW_MESSAGES = {
465
480
  NODE_PERMISSION_OPTION_INVALID: 'entity_builder.flow.validation.node.permission.option.invalid',
466
481
  NODE_CODE_REQUIRED: 'entity_builder.flow.validation.node.code.required',
467
482
  NODE_CODE_TOO_LONG: 'entity_builder.flow.validation.node.code.too.long',
468
- NODE_CODE_TIMEOUT_RANGE: 'entity_builder.flow.validation.node.code.timeout.range'
483
+ NODE_CODE_TIMEOUT_RANGE: 'entity_builder.flow.validation.node.code.timeout.range',
484
+ NODE_CODE_PACKAGE_NOT_ALLOWED: 'entity_builder.flow.validation.node.code.package.not.allowed'
469
485
  };
470
486
  /** Why an expression or rule inside a flow node is malformed (`node.expression.problem` variable). */ const FLOW_SHAPE_MESSAGES = {
471
487
  NOT_AN_EXPRESSION: 'entity_builder.flow.shape.not.an.expression',
@@ -512,6 +528,12 @@ const FLOW_MESSAGES = {
512
528
  THE_URL: 'entity_builder.flow.subject.the.url',
513
529
  THE_INPUT_LIST: 'entity_builder.flow.subject.the.input.list',
514
530
  THE_RESPONSE: 'entity_builder.flow.subject.the.response',
531
+ THE_DATA: 'entity_builder.flow.subject.the.data',
532
+ THE_TOTAL: 'entity_builder.flow.subject.the.total',
533
+ THE_PAGE: 'entity_builder.flow.subject.the.page',
534
+ THE_PAGE_SIZE: 'entity_builder.flow.subject.the.page.size',
535
+ MESSAGE_VARIABLES: 'entity_builder.flow.subject.message.variables',
536
+ MESSAGE_VARIABLE: 'entity_builder.flow.subject.message.variable',
515
537
  THE_RECIPIENTS: 'entity_builder.flow.subject.the.recipients',
516
538
  THE_TITLE: 'entity_builder.flow.subject.the.title',
517
539
  THE_MESSAGE: 'entity_builder.flow.subject.the.message',
@@ -562,6 +584,11 @@ const FLOW_MESSAGES = {
562
584
  RENAME_VIA_TEMPORARY: 'entity_builder.bundle.rename.via.temporary',
563
585
  FILE_REQUIRED: 'entity_builder.bundle.file.required',
564
586
  FILE_INVALID: 'entity_builder.bundle.file.invalid',
587
+ FILE_NOT_JSON: 'entity_builder.bundle.file.not.json',
588
+ FILE_NOT_OBJECT: 'entity_builder.bundle.file.not.object',
589
+ FILE_EMPTY: 'entity_builder.bundle.file.empty',
590
+ FILE_VALUE_INVALID: 'entity_builder.bundle.file.value.invalid',
591
+ FILES_TOO_LARGE: 'entity_builder.bundle.files.too.large',
565
592
  CONFIRM_REQUIRED: 'entity_builder.bundle.confirm.required',
566
593
  DUPLICATE_ENTITY: 'entity_builder.bundle.duplicate.entity',
567
594
  DUPLICATE_FIELD: 'entity_builder.bundle.duplicate.field',
@@ -569,10 +596,17 @@ const FLOW_MESSAGES = {
569
596
  RELATION_TARGET_UNKNOWN: 'entity_builder.bundle.relation.target.unknown',
570
597
  ENTITY_CODE_CHANGED: 'entity_builder.bundle.entity.code.changed',
571
598
  VARIABLE_MISSING: 'entity_builder.bundle.variable.missing',
572
- FLOW_SLUG_DELETED: 'entity_builder.bundle.flow.slug.deleted',
573
599
  FLOW_UNPUBLISHED_SKIPPED: 'entity_builder.bundle.flow.unpublished.skipped',
574
600
  FLOW_DRAFT_REPLACED: 'entity_builder.bundle.flow.draft.replaced',
575
601
  FLOW_API_KEY_GENERATED: 'entity_builder.bundle.flow.api.key.generated',
602
+ FLOW_FIXED_IDS: 'entity_builder.bundle.flow.fixed.ids',
603
+ FLOW_DEACTIVATE_CALLED: 'entity_builder.bundle.flow.deactivate.called',
604
+ FLOW_SECRET_WRITTEN: 'entity_builder.bundle.flow.secret.written',
605
+ FLOW_PERMISSION_UNKNOWN: 'entity_builder.bundle.flow.permission.unknown',
606
+ PERMISSIONS_TO_GRANT: 'entity_builder.bundle.permissions.to.grant',
607
+ EXPORT_RELATION_LEFT_OUT: 'entity_builder.bundle.export.relation.left.out',
608
+ EXPORT_CALLED_FLOW_LEFT_OUT: 'entity_builder.bundle.export.called.flow.left.out',
609
+ IMPORT_IN_PROGRESS: 'entity_builder.bundle.import.in.progress',
576
610
  STEP_AFTER_EARLIER: 'entity_builder.bundle.step.after.earlier',
577
611
  FLOWS_CHECKED_ON_APPLY: 'entity_builder.bundle.flows.checked.on.apply',
578
612
  DESIGNER_READ_ONLY: 'entity_builder.designer.read.only'
@@ -1,5 +1,7 @@
1
- export const __rspack_esm_id = 458;
2
- export const __rspack_esm_ids = [458];
1
+ import { SCOPE_OPTIONS_METADATA } from "@nestjs/common/constants.js";
2
+ import { DEFAULT_TENANT_HEADER } from "@flusys/nestjs-core";
3
+ export const __rspack_esm_id = 28;
4
+ export const __rspack_esm_ids = [28];
3
5
  export const __webpack_modules__ = {
4
6
  5460(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
5
7
  /* import */ var _flow_access_guard_js__rspack_import_0 = __webpack_require__(4196);
@@ -9,23 +11,27 @@ export const __webpack_modules__ = {
9
11
 
10
12
  __webpack_require__.d(__webpack_exports__, {
11
13
  CA: () => (/* reexport safe */ _flow_access_guard_js__rspack_import_0.C),
12
- Wq: () => (/* reexport safe */ _designer_writable_interceptor_js__rspack_import_1.W),
13
- Xg: () => (/* reexport safe */ _designer_writable_interceptor_js__rspack_import_1.X)
14
+ H6: () => (/* reexport safe */ _designer_writable_interceptor_js__rspack_import_1.H6),
15
+ Wq: () => (/* reexport safe */ _designer_writable_interceptor_js__rspack_import_1.Wq),
16
+ Xg: () => (/* reexport safe */ _designer_writable_interceptor_js__rspack_import_1.Xg)
14
17
  });
15
18
 
16
19
 
17
20
  },
18
- 4249(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
21
+ 4735(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
19
22
 
20
23
  // EXPORTS
21
24
  __webpack_require__.d(__webpack_exports__, {
22
- l: () => (/* reexport */ EntityBuilderModule)
25
+ l: () => (/* reexport */ EntityBuilderModule),
26
+ o: () => (/* reexport */ TenantContextIdStrategy)
23
27
  });
24
28
 
25
29
  // EXTERNAL MODULE: external "@flusys/nestjs-shared/modules"
26
30
  var modules_ = __webpack_require__(1236);
27
31
  // EXTERNAL MODULE: external "@nestjs/common"
28
32
  var common_ = __webpack_require__(6157);
33
+ ;// CONCATENATED MODULE: external "@nestjs/common/constants.js"
34
+
29
35
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/config/entity-builder.constants.ts
30
36
  var entity_builder_constants = __webpack_require__(6576);
31
37
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/config/event-actions.ts
@@ -36,8 +42,8 @@ var controllers = __webpack_require__(729);
36
42
  var reference_provider_interface = __webpack_require__(2492);
37
43
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/rule-engine/index.ts + 2 modules
38
44
  var rule_engine = __webpack_require__(8552);
39
- // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/index.ts + 3 modules
40
- var services = __webpack_require__(8752);
45
+ // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/index.ts + 2 modules
46
+ var services = __webpack_require__(712);
41
47
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/guards/index.ts
42
48
  var guards = __webpack_require__(5460);
43
49
  ;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/modules/entity-builder.module.ts
@@ -63,6 +69,7 @@ function _ts_decorate(decorators, target, key, desc) {
63
69
 
64
70
 
65
71
 
72
+
66
73
  class EntityBuilderModule {
67
74
  static CONTROLLERS = [
68
75
  controllers/* .EntityDefinitionController */.hv,
@@ -102,7 +109,7 @@ class EntityBuilderModule {
102
109
  ],
103
110
  controllers: options.includeController !== false ? this.CONTROLLERS : [],
104
111
  providers: [
105
- ...this.buildProviders(options),
112
+ ...this.tenantScoped(this.buildProviders(options), options.tenantScopedServices),
106
113
  ...options.providers ?? []
107
114
  ],
108
115
  exports: this.EXPORTS
@@ -120,12 +127,24 @@ class EntityBuilderModule {
120
127
  controllers: options.includeController !== false ? this.CONTROLLERS : [],
121
128
  providers: [
122
129
  ...this.buildAsyncProviders(options),
123
- ...this.buildProviders(),
130
+ ...this.tenantScoped(this.buildProviders(), options.tenantScopedServices),
124
131
  ...options.providers ?? []
125
132
  ],
126
133
  exports: this.EXPORTS
127
134
  };
128
135
  }
136
+ /**
137
+ * `tenantScopedServices`: every request-scoped class becomes durable - one instance per tenant (TenantContextIdStrategy).
138
+ * Classes that are request-scoped only through a dependency follow it, so nothing else needs marking.
139
+ */ static tenantScoped(providers, enabled = false) {
140
+ if (!enabled) return providers;
141
+ return providers.map((provider)=>typeof provider === 'function' && Reflect.getMetadata(SCOPE_OPTIONS_METADATA, provider)?.scope === common_.Scope.REQUEST ? {
142
+ provide: provider,
143
+ useClass: provider,
144
+ scope: common_.Scope.REQUEST,
145
+ durable: true
146
+ } : provider);
147
+ }
129
148
  static buildProviders(options) {
130
149
  const providers = [
131
150
  services/* .EntityBuilderConfigService */.E,
@@ -215,12 +234,66 @@ EntityBuilderModule = _ts_decorate([
215
234
  (0,common_.Module)({})
216
235
  ], EntityBuilderModule);
217
236
 
237
+ ;// CONCATENATED MODULE: external "@flusys/nestjs-core"
238
+
239
+ // EXTERNAL MODULE: external "@flusys/nestjs-shared/constants"
240
+ var constants_ = __webpack_require__(9140);
241
+ // EXTERNAL MODULE: external "@nestjs/core"
242
+ var core_ = __webpack_require__(3075);
243
+ ;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/modules/tenant-context-id.strategy.ts
244
+
245
+
246
+
247
+ /**
248
+ * Builds the services registered as durable (EntityBuilderModule `tenantScopedServices: true`) once per tenant and
249
+ * reuses them for every request of that tenant, instead of once per request; all other request-scoped providers stay
250
+ * per request. Enable it once, in `main.ts`: `ContextIdFactory.apply(new TenantContextIdStrategy({ tenants }))`.
251
+ *
252
+ * The tenant is read from `x-tenant-id` exactly as the datasource provider and the request context read it, so a
253
+ * shared set never serves another tenant's database. A shared service's `REQUEST` is `{ headers: { 'x-tenant-id' } }`:
254
+ * the tenant and nothing of any caller.
255
+ */ class TenantContextIdStrategy {
256
+ tenantContexts = new Map();
257
+ isTenant;
258
+ maxTenants;
259
+ constructor(options = {}){
260
+ const { tenants } = options;
261
+ if (typeof tenants === 'function') this.isTenant = tenants;
262
+ else if (tenants) {
263
+ const known = new Set(tenants);
264
+ this.isTenant = (tenantId)=>known.has(tenantId);
265
+ } else this.isTenant = ()=>true;
266
+ this.maxTenants = options.maxTenants ?? 1000;
267
+ }
268
+ attach(contextId, request) {
269
+ const raw = request?.headers?.[DEFAULT_TENANT_HEADER];
270
+ if (raw !== undefined && (typeof raw !== 'string' || !constants_.TENANT_ID_PATTERN.test(raw) || !this.isTenant(raw))) return undefined;
271
+ const tenantId = raw ?? '';
272
+ let tenantContext = this.tenantContexts.get(tenantId);
273
+ if (!tenantContext) {
274
+ if (this.tenantContexts.size >= this.maxTenants) return undefined;
275
+ tenantContext = core_.ContextIdFactory.create();
276
+ this.tenantContexts.set(tenantId, tenantContext);
277
+ }
278
+ const shared = tenantContext;
279
+ return {
280
+ resolve: (info)=>info.isTreeDurable ? shared : contextId,
281
+ payload: {
282
+ headers: tenantId ? {
283
+ [DEFAULT_TENANT_HEADER]: tenantId
284
+ } : {}
285
+ }
286
+ };
287
+ }
288
+ }
289
+
218
290
  ;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/modules/index.ts
219
291
 
220
292
 
221
293
 
294
+
222
295
  },
223
- 8752(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
296
+ 712(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
224
297
 
225
298
  // EXPORTS
226
299
  __webpack_require__.d(__webpack_exports__, {
@@ -228,13 +301,11 @@ __webpack_require__.d(__webpack_exports__, {
228
301
  Fz: () => (/* reexport */ (/* inlined export .DRAFT_TEST_RETAIN */200)),
229
302
  P0: () => (/* reexport */ definition_bundle_service/* .DefinitionBundleService */.P),
230
303
  Vo: () => (/* reexport */ definition_cache_service/* .DefinitionCacheService */.V),
231
- $I: () => (/* reexport */ definition_bundle_diff/* .ENTITY_COMPARED_KEYS */.$I),
232
304
  IP: () => (/* reexport */ entity_flow_scaffold/* .ENTITY_FLOW_PATHS */.IP),
233
305
  E: () => (/* reexport */ entity_builder_config_service/* .EntityBuilderConfigService */.E),
234
306
  DR: () => (/* reexport */ entity_builder_datasource_provider/* .EntityBuilderDataSourceProvider */.D),
235
307
  oc: () => (/* reexport */ entity_definition_service/* .EntityDefinitionService */.o),
236
308
  u4: () => (/* reexport */ entity_permission_service/* .EntityPermissionService */.u),
237
- mT: () => (/* reexport */ definition_bundle_diff/* .FIELD_COMPARED_KEYS */.mT),
238
309
  J: () => (/* reexport */ field_definition_service/* .FieldDefinitionService */.J),
239
310
  Tk: () => (/* reexport */ flow_definition_service/* .FlowDefinitionService */.Tk),
240
311
  AJ: () => (/* reexport */ flow_execution_service/* .FlowExecutionService */.A),
@@ -243,8 +314,7 @@ __webpack_require__.d(__webpack_exports__, {
243
314
  a$: () => (/* reexport */ flow_runtime_service/* .FlowRuntimeService */.a),
244
315
  GK: () => (/* reexport */ generic_entity_service/* .GenericEntityService */.GK),
245
316
  GR: () => (/* reexport */ generic_entity_service_factory/* .GenericEntityServiceFactory */.G),
246
- gW: () => (/* reexport */ schema_columns/* .NON_INDEXABLE_FIELD_TYPES */.gW),
247
- xJ: () => (/* reexport */ identifier_rules/* .RESERVED_WORDS */.xJ),
317
+ vx: () => (/* reexport */ schema_columns/* .LIVE_ROWS_WHERE */.vx),
248
318
  tH: () => (/* reexport */ reference_scanner_service/* .ReferenceScannerService */.t),
249
319
  mq: () => (/* reexport */ schema_columns/* .SYSTEM_COLUMN_NAMES */.mq),
250
320
  TQ: () => (/* reexport */ schema_change_executor_service/* .SchemaChangeExecutor */.T),
@@ -255,8 +325,9 @@ __webpack_require__.d(__webpack_exports__, {
255
325
  DG: () => (/* reexport */ generic_entity_service/* .actorMetadata */.DG),
256
326
  $6: () => (/* reexport */ schema_columns/* .addUnique */.$6),
257
327
  gT: () => (/* reexport */ definition_bundle_diff/* .applyVariables */.gT),
258
- fY: () => (/* reexport */ identifier_rules/* .assertIndexableField */.fY),
259
- kV: () => (/* reexport */ identifier_rules/* .assertValidIdentifier */.kV),
328
+ b$: () => (/* reexport */ flow_definition_service/* .asksExecutePermission */.b$),
329
+ fY: () => (/* reexport */ identifier_rules/* .assertIndexableField */.f),
330
+ kV: () => (/* reexport */ identifier_rules/* .assertValidIdentifier */.k),
260
331
  HK: () => (/* reexport */ schema_columns/* .auditColumns */.HK),
261
332
  CO: () => (/* reexport */ entity_flow_scaffold/* .buildEntityFlow */.CO),
262
333
  fu: () => (/* reexport */ schema_columns/* .buildFieldColumn */.fu),
@@ -270,34 +341,43 @@ __webpack_require__.d(__webpack_exports__, {
270
341
  an: () => (/* reexport */ schema_change_types/* .describeImpact */.a),
271
342
  Sy: () => (/* reexport */ definition_bundle_diff/* .diffEntities */.zb),
272
343
  x2: () => (/* reexport */ entity_flow_scaffold/* .entityFlowSlug */.x2),
344
+ ZM: () => (/* reexport */ entity_permission_service/* .entityPermissionCodes */.Z),
273
345
  lj: () => (/* reexport */ definition_bundle_diff/* .extractVariables */.lj),
274
346
  HQ: () => (/* reexport */ schema_dialect_adapter_service/* .fitIdentifier */.H),
347
+ f7: () => (/* reexport */ definition_bundle_diff/* .fixedIds */.f7),
275
348
  YW: () => (/* reexport */ flow_definition_service/* .flowNotFound */.YW),
276
349
  j4: () => (/* reexport */ flow_definition_service/* .flowPermissions */.j4),
277
350
  gl: () => (/* reexport */ flow_executor_service/* .flowTimeout */.g),
278
351
  mo: () => (/* reexport */ schema_columns/* .indexName */.mo),
352
+ w5: () => (/* reexport */ schema_columns/* .indexedByDefault */.w5),
279
353
  C5: () => (/* reexport */ schema_evolution_service/* .isDestructiveSchemaAction */.C),
280
354
  d4: () => (/* reexport */ schema_columns/* .isIndexableFieldType */.d4),
355
+ YS: () => (/* reexport */ schema_columns/* .isLiveRowsIndex */.YS),
281
356
  HF: () => (/* reexport */ flow_definition_service/* .isPublished */.HF),
282
357
  Eq: () => (/* reexport */ database_error_mapper/* .mapDatabaseError */.E),
283
358
  iw: () => (/* reexport */ database_error_mapper/* .mapSchemaError */.i),
284
359
  Og: () => (/* reexport */ definition_bundle_diff/* .matchDefinitions */.Og),
285
360
  qG: () => (/* reexport */ definition_bundle_diff/* .orderFlows */.qG),
361
+ QJ: () => (/* reexport */ definition_bundle_diff/* .permissionCodes */.QJ),
286
362
  v7: () => (/* reexport */ schema_columns/* .plainIndex */.v7),
287
363
  IM: () => (/* reexport */ field_type_conversion/* .planTypeConversion */.I),
288
364
  zi: () => (/* reexport */ definition_bundle_file/* .readBundleFile */.z),
365
+ KA: () => (/* reexport */ definition_bundle_file/* .readBundleFiles */.K),
289
366
  e1: () => (/* reexport */ schema_change_executor_service/* .relationTargetCodes */.e),
290
367
  Sd: () => (/* reexport */ flow_runtime_service/* .requestInfo */.S),
291
368
  G7: () => (/* reexport */ schema_columns/* .sameColumns */.G7),
292
369
  eY: () => (/* reexport */ flow_definition_service/* .snapshotOf */.eY),
293
370
  OG: () => (/* reexport */ schema_columns/* .softDeleteColumn */.OG),
294
371
  cg: () => (/* reexport */ schema_columns/* .sqlTypeFor */.cg),
372
+ xV: () => (/* reexport */ generic_entity_service/* .statementTimeoutSql */.xV),
295
373
  dX: () => (/* reexport */ definition_bundle_diff/* .stripApiKeys */.dX),
296
374
  uy: () => (/* reexport */ schema_columns/* .tableUnique */.uy),
297
375
  RK: () => (/* reexport */ flow_definition_service/* .toFlowSettings */.RK),
298
376
  jp: () => (/* reexport */ schema_columns/* .typeFamily */.jp),
299
377
  eV: () => (/* reexport */ field_value_validator/* .validateRecord */.e),
300
- lw: () => (/* reexport */ flow_definition_service/* .workingCopy */.lw)
378
+ CM: () => (/* reexport */ field_value_validator/* .valueRulesOf */.C),
379
+ lw: () => (/* reexport */ flow_definition_service/* .workingCopy */.lw),
380
+ l6: () => (/* reexport */ definition_bundle_diff/* .writtenSecrets */.l6)
301
381
  });
302
382
 
303
383
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/entity-builder-config.service.ts
@@ -314,8 +394,8 @@ var schema_sync_service = __webpack_require__(3474);
314
394
  var entity_definition_service = __webpack_require__(1296);
315
395
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/field-definition.service.ts
316
396
  var field_definition_service = __webpack_require__(9487);
317
- // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/generic-entity.service.ts
318
- var generic_entity_service = __webpack_require__(3998);
397
+ // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/generic-entity.service.ts + 3 modules
398
+ var generic_entity_service = __webpack_require__(3052);
319
399
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/generic-entity-service.factory.ts
320
400
  var generic_entity_service_factory = __webpack_require__(7705);
321
401
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/entity-permission.service.ts
@@ -352,39 +432,14 @@ var flow_runtime_service = __webpack_require__(2300);
352
432
  var utils_ = __webpack_require__(9216);
353
433
  // EXTERNAL MODULE: external "@nestjs/common"
354
434
  var common_ = __webpack_require__(6157);
355
- // EXTERNAL MODULE: external "typeorm"
356
- var external_typeorm_ = __webpack_require__(7158);
357
435
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/config/message-keys.ts
358
436
  var message_keys = __webpack_require__(5732);
359
437
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/entities/flow-definition.entity.ts
360
438
  var flow_definition_entity = __webpack_require__(3770);
361
439
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/entities/flow-version.entity.ts
362
440
  var flow_version_entity = __webpack_require__(2399);
363
- ;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/services/reference-rewrite.ts
364
- /** Pure JSON string helpers for finding and rewriting `<prefix>.<field>` references inside definitions. */ function mapStrings(value, fn) {
365
- if (typeof value === 'string') return fn(value);
366
- if (Array.isArray(value)) return value.map((v)=>mapStrings(v, fn));
367
- if (value && typeof value === 'object') {
368
- return Object.fromEntries(Object.entries(value).map(([k, v])=>[
369
- k,
370
- mapStrings(v, fn)
371
- ]));
372
- }
373
- return value;
374
- }
375
- function anyString(value, test) {
376
- if (typeof value === 'string') return test(value);
377
- if (Array.isArray(value)) return value.some((v)=>anyString(v, test));
378
- if (value && typeof value === 'object') return Object.values(value).some((v)=>anyString(v, test));
379
- return false;
380
- }
381
- const escapeRe = (s)=>s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
382
- /**
383
- * `<prefix>.<field>`, `<prefix>.<field>.x` or `{{ <prefix>.<field> }}` inside a template - but not
384
- * `<prefix>.<field>_2`. The prefix is a regex source (e.g. `context\.find\.items\.\d+`), captured so a rewrite keeps it.
385
- */ const referencePatternSource = (prefixSource, field, flags = '')=>new RegExp(`(^|\\{\\{\\s*)(${prefixSource})\\.${escapeRe(field)}(?!\\w)`, flags);
386
- const replaceReferenceSource = (s, prefixSource, from, to)=>s.replace(referencePatternSource(prefixSource, from, 'g'), (_match, lead, prefix)=>`${lead}${prefix}.${to}`);
387
-
441
+ // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/reference-rewrite.ts
442
+ var reference_rewrite = __webpack_require__(3086);
388
443
  ;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/flow-engine/flow-reference.ts
389
444
 
390
445
  const entityOf = (node)=>node.config?.entityCode;
@@ -418,20 +473,20 @@ const ITEM = '\\.items\\.\\d+';
418
473
  /** Regex sources of every output path that holds a record of the entity. */ function recordPrefixes(nodes, entityCode) {
419
474
  const out = [];
420
475
  for (const node of nodes){
421
- const base = `context\\.${escapeRe(node.id)}`;
476
+ const base = `context\\.${(0,reference_rewrite/* .escapeRe */.NF)(node.id)}`;
422
477
  if (entityOf(node) === entityCode) {
423
478
  if (node.type === 'entity_get') out.push(base);
424
479
  else if (node.type === 'entity_insert' || node.type === 'entity_update') out.push(`${base}(?:${ITEM})?`);
425
480
  else if (node.type === 'entity_query') out.push(`${base}${ITEM}`);
426
481
  }
427
482
  for (const child of childrenOf(node)){
428
- if (child.entityCode === entityCode && typeof child.as === 'string' && child.as) out.push(`${base}(?:${ITEM})?\\.${escapeRe(child.as)}\\.\\d+`);
483
+ if (child.entityCode === entityCode && typeof child.as === 'string' && child.as) out.push(`${base}(?:${ITEM})?\\.${(0,reference_rewrite/* .escapeRe */.NF)(child.as)}\\.\\d+`);
429
484
  }
430
485
  }
431
486
  return out;
432
487
  }
433
488
  function flowRefersToField(nodes, entityCode, field) {
434
- const patterns = recordPrefixes(nodes, entityCode).map((prefix)=>referencePatternSource(prefix, field));
489
+ const patterns = recordPrefixes(nodes, entityCode).map((prefix)=>(0,reference_rewrite/* .referencePatternSource */.LV)(prefix, field));
435
490
  return nodes.some((node)=>{
436
491
  if (entityOf(node) === entityCode) {
437
492
  const c = node.config;
@@ -441,7 +496,7 @@ function flowRefersToField(nodes, entityCode, field) {
441
496
  }
442
497
  if (childrenOf(node).some((child)=>child.entityCode === entityCode && childUsesField(child, field))) return true;
443
498
  if (anyLookup(node.config, entityCode, (lookup)=>lookupUsesField(lookup, field))) return true;
444
- return patterns.length > 0 && anyString(node.config, (s)=>patterns.some((p)=>p.test(s)));
499
+ return patterns.length > 0 && (0,reference_rewrite/* .anyString */.gp)(node.config, (s)=>patterns.some((p)=>p.test(s)));
445
500
  });
446
501
  }
447
502
  function rewriteFlowField(nodes, entityCode, from, to) {
@@ -513,8 +568,8 @@ function rewriteFlowField(nodes, entityCode, from, to) {
513
568
  };
514
569
  });
515
570
  if (prefixes.length) {
516
- config = mapStrings(config, (s)=>{
517
- const out = prefixes.reduce((acc, prefix)=>replaceReferenceSource(acc, prefix, from, to), s);
571
+ config = (0,reference_rewrite/* .mapStrings */.to)(config, (s)=>{
572
+ const out = prefixes.reduce((acc, prefix)=>(0,reference_rewrite/* .replaceReferenceSource */.Ni)(acc, prefix, from, to), s);
518
573
  if (out !== s) changed = true;
519
574
  return out;
520
575
  });
@@ -561,18 +616,13 @@ function _ts_param(paramIndex, decorator) {
561
616
 
562
617
 
563
618
 
564
-
565
619
  class FlowReferenceProvider {
566
620
  provider;
567
621
  constructor(provider){
568
622
  this.provider = provider;
569
623
  }
570
624
  async flows() {
571
- return (await this.repo(flow_definition_entity/* .FlowDefinition */.G)).find({
572
- where: {
573
- deletedAt: (0,external_typeorm_.IsNull)()
574
- }
575
- });
625
+ return (await this.repo(flow_definition_entity/* .FlowDefinition */.G)).find();
576
626
  }
577
627
  async repo(entity, manager) {
578
628
  return manager ? manager.getRepository(entity) : this.provider.getRepository(entity);
@@ -601,10 +651,7 @@ class FlowReferenceProvider {
601
651
  async rewriteFieldReferences(entityCode, from, to, manager) {
602
652
  let count = 0;
603
653
  const flows = await this.repo(flow_definition_entity/* .FlowDefinition */.G, manager);
604
- // Deleted flows too: one restored later must not bring the old field name back.
605
- for (const flow of (await flows.find({
606
- withDeleted: true
607
- }))){
654
+ for (const flow of (await flows.find())){
608
655
  // The published flow and its unpublished draft both keep working after the rename.
609
656
  const live = rewriteFlowField(flow.nodes, entityCode, from, to);
610
657
  const draft = flow.draft ? rewriteFlowField(flow.draft.nodes, entityCode, from, to) : null;