@flusys/nestjs-entity-builder 9.0.1 → 9.1.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.
Files changed (40) hide show
  1. package/README.md +22 -28
  2. package/config/message-keys.d.ts +9 -62
  3. package/controllers/flow-api-key.controller.d.ts +14 -0
  4. package/controllers/flow-definition.controller.d.ts +1 -7
  5. package/controllers/index.d.ts +1 -0
  6. package/dtos/flow.dto.d.ts +20 -10
  7. package/entities/flow-api-key.entity.d.ts +10 -0
  8. package/entities/flow-definition.entity.d.ts +9 -3
  9. package/entities/flow-execution.entity.d.ts +0 -1
  10. package/entities/index.d.ts +3 -3
  11. package/fesm/21.js +11 -64
  12. package/fesm/{582.js → 489.js} +11 -20
  13. package/fesm/{913.js → 606.js} +295 -209
  14. package/fesm/719.js +186 -162
  15. package/fesm/794.js +187 -116
  16. package/fesm/{677.js → 996.js} +616 -1490
  17. package/fesm/controllers/index.js +6 -5
  18. package/fesm/docs/index.js +2 -2
  19. package/fesm/entities/index.js +2 -2
  20. package/fesm/guards/index.js +19 -12
  21. package/fesm/index.js +638 -50
  22. package/fesm/modules/index.js +625 -7
  23. package/fesm/rule-engine/index.js +2 -2
  24. package/fesm/services/index.js +25 -54
  25. package/flow-engine/flow-api-key.d.ts +7 -3
  26. package/flow-engine/flow-graph.validator.d.ts +2 -4
  27. package/flow-engine/flow-run.types.d.ts +4 -14
  28. package/flow-engine/flow.types.d.ts +9 -91
  29. package/interfaces/flow-definition.interface.d.ts +9 -13
  30. package/package.json +5 -5
  31. package/rule-engine/rule-engine.service.d.ts +0 -1
  32. package/services/entity-flow-scaffold.d.ts +1 -1
  33. package/services/flow-api-key.service.d.ts +31 -0
  34. package/services/flow-definition.service.d.ts +12 -24
  35. package/services/flow-execution.service.d.ts +0 -1
  36. package/services/flow-executor.service.d.ts +7 -7
  37. package/services/generic-entity.service.d.ts +1 -1
  38. package/services/index.d.ts +1 -0
  39. package/entities/flow-version.entity.d.ts +0 -10
  40. package/fesm/458.js +0 -649
@@ -6,6 +6,7 @@ export const __webpack_modules__ = {
6
6
  // EXPORTS
7
7
  __webpack_require__.d(__webpack_exports__, {
8
8
  zb: () => (/* reexport */ generic_entity_service/* .ACTOR_BRANCH_METADATA_KEY */.zb),
9
+ Ty: () => (/* reexport */ (/* inlined export .BULK_MAX_ITEMS */200)),
9
10
  Fz: () => (/* reexport */ (/* inlined export .DRAFT_TEST_RETAIN */200)),
10
11
  Vo: () => (/* reexport */ definition_cache_service/* .DefinitionCacheService */.V),
11
12
  IP: () => (/* reexport */ entity_flow_scaffold/* .ENTITY_FLOW_PATHS */.IP),
@@ -14,6 +15,7 @@ __webpack_require__.d(__webpack_exports__, {
14
15
  oc: () => (/* reexport */ entity_definition_service/* .EntityDefinitionService */.o),
15
16
  u4: () => (/* reexport */ entity_permission_service/* .EntityPermissionService */.u),
16
17
  J: () => (/* reexport */ field_definition_service/* .FieldDefinitionService */.J),
18
+ Td: () => (/* reexport */ flow_api_key_service/* .FlowApiKeyService */.T),
17
19
  Tk: () => (/* reexport */ flow_definition_service/* .FlowDefinitionService */.Tk),
18
20
  AJ: () => (/* reexport */ flow_execution_service/* .FlowExecutionService */.A),
19
21
  FT: () => (/* reexport */ flow_executor_service/* .FlowExecutorService */.F),
@@ -47,7 +49,6 @@ __webpack_require__.d(__webpack_exports__, {
47
49
  mo: () => (/* reexport */ schema_columns/* .indexName */.mo),
48
50
  C5: () => (/* reexport */ schema_evolution_service/* .isDestructiveSchemaAction */.C),
49
51
  d4: () => (/* reexport */ schema_columns/* .isIndexableFieldType */.d4),
50
- HF: () => (/* reexport */ flow_definition_service/* .isPublished */.HF),
51
52
  Eq: () => (/* reexport */ database_error_mapper/* .mapDatabaseError */.E),
52
53
  iw: () => (/* reexport */ database_error_mapper/* .mapSchemaError */.i),
53
54
  v7: () => (/* reexport */ schema_columns/* .plainIndex */.v7),
@@ -55,14 +56,12 @@ __webpack_require__.d(__webpack_exports__, {
55
56
  e1: () => (/* reexport */ schema_change_executor_service/* .relationTargetCodes */.e),
56
57
  Sd: () => (/* reexport */ flow_runtime_service/* .requestInfo */.S),
57
58
  G7: () => (/* reexport */ schema_columns/* .sameColumns */.G7),
58
- eY: () => (/* reexport */ flow_definition_service/* .snapshotOf */.eY),
59
59
  OG: () => (/* reexport */ schema_columns/* .softDeleteColumn */.OG),
60
60
  cg: () => (/* reexport */ schema_columns/* .sqlTypeFor */.cg),
61
61
  uy: () => (/* reexport */ schema_columns/* .tableUnique */.uy),
62
62
  RK: () => (/* reexport */ flow_definition_service/* .toFlowSettings */.RK),
63
63
  jp: () => (/* reexport */ schema_columns/* .typeFamily */.jp),
64
- eV: () => (/* reexport */ field_value_validator/* .validateRecord */.e),
65
- lw: () => (/* reexport */ flow_definition_service/* .workingCopy */.lw)
64
+ eV: () => (/* reexport */ field_value_validator/* .validateRecord */.e)
66
65
  });
67
66
 
68
67
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/entity-builder-config.service.ts
@@ -105,8 +104,10 @@ var reference_scanner_service = __webpack_require__(921);
105
104
  var field_value_validator = __webpack_require__(3525);
106
105
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/database-error.mapper.ts
107
106
  var database_error_mapper = __webpack_require__(8323);
108
- // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/flow-definition.service.ts + 1 modules
109
- var flow_definition_service = __webpack_require__(4921);
107
+ // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/flow-definition.service.ts
108
+ var flow_definition_service = __webpack_require__(5229);
109
+ // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/flow-api-key.service.ts + 1 modules
110
+ var flow_api_key_service = __webpack_require__(8888);
110
111
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/flow-execution.service.ts
111
112
  var flow_execution_service = __webpack_require__(7810);
112
113
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/flow-executor.service.ts + 5 modules
@@ -123,8 +124,6 @@ var external_typeorm_ = __webpack_require__(7158);
123
124
  var message_keys = __webpack_require__(5732);
124
125
  // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/entities/flow-definition.entity.ts
125
126
  var flow_definition_entity = __webpack_require__(3770);
126
- // EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/entities/flow-version.entity.ts
127
- var flow_version_entity = __webpack_require__(2399);
128
127
  ;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/services/reference-rewrite.ts
129
128
  /** Pure JSON string helpers for finding and rewriting `<prefix>.<field>` references inside definitions. */ function mapStrings(value, fn) {
130
129
  if (typeof value === 'string') return fn(value);
@@ -326,24 +325,23 @@ function _ts_param(paramIndex, decorator) {
326
325
 
327
326
 
328
327
 
329
-
330
328
  class FlowReferenceProvider {
331
329
  provider;
332
330
  constructor(provider){
333
331
  this.provider = provider;
334
332
  }
335
- async flows() {
336
- return (await this.repo(flow_definition_entity/* .FlowDefinition */.G)).find({
333
+ async flows(manager) {
334
+ return (await this.repo(manager)).find({
337
335
  where: {
338
336
  deletedAt: (0,external_typeorm_.IsNull)()
339
337
  }
340
338
  });
341
339
  }
342
- async repo(entity, manager) {
343
- return manager ? manager.getRepository(entity) : this.provider.getRepository(entity);
340
+ async repo(manager) {
341
+ return manager ? manager.getRepository(flow_definition_entity/* .FlowDefinition */.G) : this.provider.getRepository(flow_definition_entity/* .FlowDefinition */.G);
344
342
  }
345
343
  async findEntityReferences(entityCode) {
346
- return (await this.flows()).filter((f)=>flowUsesEntity(f.nodes, entityCode) || !!f.draft && flowUsesEntity(f.draft.nodes, entityCode)).map((f)=>({
344
+ return (await this.flows()).filter((f)=>flowUsesEntity(f.nodes, entityCode)).map((f)=>({
347
345
  kind: 'flow',
348
346
  id: f.id,
349
347
  name: f.name,
@@ -353,7 +351,7 @@ class FlowReferenceProvider {
353
351
  }));
354
352
  }
355
353
  async findFieldReferences(entityCode, fieldCode) {
356
- return (await this.flows()).filter((f)=>flowRefersToField(f.nodes, entityCode, fieldCode) || !!f.draft && flowRefersToField(f.draft.nodes, entityCode, fieldCode)).map((f)=>({
354
+ return (await this.flows()).filter((f)=>flowRefersToField(f.nodes, entityCode, fieldCode)).map((f)=>({
357
355
  kind: 'flow',
358
356
  id: f.id,
359
357
  name: f.name,
@@ -365,42 +363,15 @@ class FlowReferenceProvider {
365
363
  }
366
364
  async rewriteFieldReferences(entityCode, from, to, manager) {
367
365
  let count = 0;
368
- const flows = await this.repo(flow_definition_entity/* .FlowDefinition */.G, manager);
369
- // Deleted flows too: one restored later must not bring the old field name back.
370
- for (const flow of (await flows.find({
371
- withDeleted: true
372
- }))){
373
- // The published flow and its unpublished draft both keep working after the rename.
374
- const live = rewriteFlowField(flow.nodes, entityCode, from, to);
375
- const draft = flow.draft ? rewriteFlowField(flow.draft.nodes, entityCode, from, to) : null;
376
- if (!live.changed && !draft?.changed) continue;
377
- await flows.update(flow.id, {
378
- nodes: live.nodes,
379
- ...draft?.changed ? {
380
- draft: {
381
- ...flow.draft,
382
- nodes: draft.nodes
383
- }
384
- } : {}
366
+ for (const flow of (await this.flows(manager))){
367
+ const { nodes, changed } = rewriteFlowField(flow.nodes, entityCode, from, to);
368
+ if (!changed) continue;
369
+ await (await this.repo(manager)).update(flow.id, {
370
+ nodes,
371
+ version: flow.version + 1
385
372
  });
386
373
  count++;
387
374
  }
388
- // A version restored later must not bring the old field name back.
389
- const versions = await this.repo(flow_version_entity/* .FlowVersion */.p, manager);
390
- for (const version of (await versions.find({
391
- select: {
392
- id: true,
393
- definition: true
394
- }
395
- }))){
396
- const { nodes, changed } = rewriteFlowField(version.definition.nodes, entityCode, from, to);
397
- if (changed) await versions.update(version.id, {
398
- definition: {
399
- ...version.definition,
400
- nodes
401
- }
402
- });
403
- }
404
375
  return count;
405
376
  }
406
377
  }
@@ -444,6 +415,7 @@ var entity_flow_scaffold = __webpack_require__(8271);
444
415
 
445
416
 
446
417
 
418
+
447
419
 
448
420
 
449
421
  },
@@ -453,11 +425,11 @@ import { __webpack_require__ } from '../runtime.js';
453
425
  var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
454
426
  import * as __rspack_chunk_1 from '../21.js';
455
427
  __webpack_require__.C(__rspack_chunk_1);
456
- import * as __rspack_chunk_2 from '../582.js';
428
+ import * as __rspack_chunk_2 from '../489.js';
457
429
  __webpack_require__.C(__rspack_chunk_2);
458
430
  import * as __rspack_chunk_3 from '../794.js';
459
431
  __webpack_require__.C(__rspack_chunk_3);
460
- import * as __rspack_chunk_4 from '../677.js';
432
+ import * as __rspack_chunk_4 from '../996.js';
461
433
  __webpack_require__.C(__rspack_chunk_4);
462
434
  import * as __rspack_chunk_5 from '../362.js';
463
435
  __webpack_require__.C(__rspack_chunk_5);
@@ -466,6 +438,7 @@ __webpack_require__.C(__rspack_chunk_6);
466
438
  import * as __rspack_chunk_7 from './index.js';
467
439
  __webpack_require__.C(__rspack_chunk_7);
468
440
  var __webpack_exports__ = __webpack_exec__(8752);var __webpack_exports__ACTOR_BRANCH_METADATA_KEY = __webpack_exports__.zb;
441
+ var __webpack_exports__BULK_MAX_ITEMS = __webpack_exports__.Ty;
469
442
  var __webpack_exports__DRAFT_TEST_RETAIN = __webpack_exports__.Fz;
470
443
  var __webpack_exports__DefinitionCacheService = __webpack_exports__.Vo;
471
444
  var __webpack_exports__ENTITY_FLOW_PATHS = __webpack_exports__.IP;
@@ -474,6 +447,7 @@ var __webpack_exports__EntityBuilderDataSourceProvider = __webpack_exports__.DR;
474
447
  var __webpack_exports__EntityDefinitionService = __webpack_exports__.oc;
475
448
  var __webpack_exports__EntityPermissionService = __webpack_exports__.u4;
476
449
  var __webpack_exports__FieldDefinitionService = __webpack_exports__.J;
450
+ var __webpack_exports__FlowApiKeyService = __webpack_exports__.Td;
477
451
  var __webpack_exports__FlowDefinitionService = __webpack_exports__.Tk;
478
452
  var __webpack_exports__FlowExecutionService = __webpack_exports__.AJ;
479
453
  var __webpack_exports__FlowExecutorService = __webpack_exports__.FT;
@@ -507,7 +481,6 @@ var __webpack_exports__flowTimeout = __webpack_exports__.gl;
507
481
  var __webpack_exports__indexName = __webpack_exports__.mo;
508
482
  var __webpack_exports__isDestructiveSchemaAction = __webpack_exports__.C5;
509
483
  var __webpack_exports__isIndexableFieldType = __webpack_exports__.d4;
510
- var __webpack_exports__isPublished = __webpack_exports__.HF;
511
484
  var __webpack_exports__mapDatabaseError = __webpack_exports__.Eq;
512
485
  var __webpack_exports__mapSchemaError = __webpack_exports__.iw;
513
486
  var __webpack_exports__plainIndex = __webpack_exports__.v7;
@@ -515,12 +488,10 @@ var __webpack_exports__planTypeConversion = __webpack_exports__.IM;
515
488
  var __webpack_exports__relationTargetCodes = __webpack_exports__.e1;
516
489
  var __webpack_exports__requestInfo = __webpack_exports__.Sd;
517
490
  var __webpack_exports__sameColumns = __webpack_exports__.G7;
518
- var __webpack_exports__snapshotOf = __webpack_exports__.eY;
519
491
  var __webpack_exports__softDeleteColumn = __webpack_exports__.OG;
520
492
  var __webpack_exports__sqlTypeFor = __webpack_exports__.cg;
521
493
  var __webpack_exports__tableUnique = __webpack_exports__.uy;
522
494
  var __webpack_exports__toFlowSettings = __webpack_exports__.RK;
523
495
  var __webpack_exports__typeFamily = __webpack_exports__.jp;
524
496
  var __webpack_exports__validateRecord = __webpack_exports__.eV;
525
- var __webpack_exports__workingCopy = __webpack_exports__.lw;
526
- export { __webpack_exports__ACTOR_BRANCH_METADATA_KEY as ACTOR_BRANCH_METADATA_KEY, __webpack_exports__DRAFT_TEST_RETAIN as DRAFT_TEST_RETAIN, __webpack_exports__DefinitionCacheService as DefinitionCacheService, __webpack_exports__ENTITY_FLOW_PATHS as ENTITY_FLOW_PATHS, __webpack_exports__EntityBuilderConfigService as EntityBuilderConfigService, __webpack_exports__EntityBuilderDataSourceProvider as EntityBuilderDataSourceProvider, __webpack_exports__EntityDefinitionService as EntityDefinitionService, __webpack_exports__EntityPermissionService as EntityPermissionService, __webpack_exports__FieldDefinitionService as FieldDefinitionService, __webpack_exports__FlowDefinitionService as FlowDefinitionService, __webpack_exports__FlowExecutionService as FlowExecutionService, __webpack_exports__FlowExecutorService as FlowExecutorService, __webpack_exports__FlowReferenceProvider as FlowReferenceProvider, __webpack_exports__FlowRuntimeService as FlowRuntimeService, __webpack_exports__GenericEntityService as GenericEntityService, __webpack_exports__GenericEntityServiceFactory as GenericEntityServiceFactory, __webpack_exports__NON_INDEXABLE_FIELD_TYPES as NON_INDEXABLE_FIELD_TYPES, __webpack_exports__RESERVED_WORDS as RESERVED_WORDS, __webpack_exports__ReferenceScannerService as ReferenceScannerService, __webpack_exports__SYSTEM_COLUMN_NAMES as SYSTEM_COLUMN_NAMES, __webpack_exports__SchemaChangeExecutor as SchemaChangeExecutor, __webpack_exports__SchemaDialectAdapterService as SchemaDialectAdapterService, __webpack_exports__SchemaEvolutionService as SchemaEvolutionService, __webpack_exports__SchemaRegistryService as SchemaRegistryService, __webpack_exports__SchemaSyncService as SchemaSyncService, __webpack_exports__actorMetadata as actorMetadata, __webpack_exports__addUnique as addUnique, __webpack_exports__assertIndexableField as assertIndexableField, __webpack_exports__assertValidIdentifier as assertValidIdentifier, __webpack_exports__auditColumns as auditColumns, __webpack_exports__buildEntityFlow as buildEntityFlow, __webpack_exports__buildFieldColumn as buildFieldColumn, __webpack_exports__buildSystemColumns as buildSystemColumns, __webpack_exports__defaultFlowPermissionCode as defaultFlowPermissionCode, __webpack_exports__describeImpact as describeImpact, __webpack_exports__entityFlowSlug as entityFlowSlug, __webpack_exports__fitIdentifier as fitIdentifier, __webpack_exports__flowNotFound as flowNotFound, __webpack_exports__flowTimeout as flowTimeout, __webpack_exports__indexName as indexName, __webpack_exports__isDestructiveSchemaAction as isDestructiveSchemaAction, __webpack_exports__isIndexableFieldType as isIndexableFieldType, __webpack_exports__isPublished as isPublished, __webpack_exports__mapDatabaseError as mapDatabaseError, __webpack_exports__mapSchemaError as mapSchemaError, __webpack_exports__plainIndex as plainIndex, __webpack_exports__planTypeConversion as planTypeConversion, __webpack_exports__relationTargetCodes as relationTargetCodes, __webpack_exports__requestInfo as requestInfo, __webpack_exports__sameColumns as sameColumns, __webpack_exports__snapshotOf as snapshotOf, __webpack_exports__softDeleteColumn as softDeleteColumn, __webpack_exports__sqlTypeFor as sqlTypeFor, __webpack_exports__tableUnique as tableUnique, __webpack_exports__toFlowSettings as toFlowSettings, __webpack_exports__typeFamily as typeFamily, __webpack_exports__validateRecord as validateRecord, __webpack_exports__workingCopy as workingCopy };
497
+ export { __webpack_exports__ACTOR_BRANCH_METADATA_KEY as ACTOR_BRANCH_METADATA_KEY, __webpack_exports__BULK_MAX_ITEMS as BULK_MAX_ITEMS, __webpack_exports__DRAFT_TEST_RETAIN as DRAFT_TEST_RETAIN, __webpack_exports__DefinitionCacheService as DefinitionCacheService, __webpack_exports__ENTITY_FLOW_PATHS as ENTITY_FLOW_PATHS, __webpack_exports__EntityBuilderConfigService as EntityBuilderConfigService, __webpack_exports__EntityBuilderDataSourceProvider as EntityBuilderDataSourceProvider, __webpack_exports__EntityDefinitionService as EntityDefinitionService, __webpack_exports__EntityPermissionService as EntityPermissionService, __webpack_exports__FieldDefinitionService as FieldDefinitionService, __webpack_exports__FlowApiKeyService as FlowApiKeyService, __webpack_exports__FlowDefinitionService as FlowDefinitionService, __webpack_exports__FlowExecutionService as FlowExecutionService, __webpack_exports__FlowExecutorService as FlowExecutorService, __webpack_exports__FlowReferenceProvider as FlowReferenceProvider, __webpack_exports__FlowRuntimeService as FlowRuntimeService, __webpack_exports__GenericEntityService as GenericEntityService, __webpack_exports__GenericEntityServiceFactory as GenericEntityServiceFactory, __webpack_exports__NON_INDEXABLE_FIELD_TYPES as NON_INDEXABLE_FIELD_TYPES, __webpack_exports__RESERVED_WORDS as RESERVED_WORDS, __webpack_exports__ReferenceScannerService as ReferenceScannerService, __webpack_exports__SYSTEM_COLUMN_NAMES as SYSTEM_COLUMN_NAMES, __webpack_exports__SchemaChangeExecutor as SchemaChangeExecutor, __webpack_exports__SchemaDialectAdapterService as SchemaDialectAdapterService, __webpack_exports__SchemaEvolutionService as SchemaEvolutionService, __webpack_exports__SchemaRegistryService as SchemaRegistryService, __webpack_exports__SchemaSyncService as SchemaSyncService, __webpack_exports__actorMetadata as actorMetadata, __webpack_exports__addUnique as addUnique, __webpack_exports__assertIndexableField as assertIndexableField, __webpack_exports__assertValidIdentifier as assertValidIdentifier, __webpack_exports__auditColumns as auditColumns, __webpack_exports__buildEntityFlow as buildEntityFlow, __webpack_exports__buildFieldColumn as buildFieldColumn, __webpack_exports__buildSystemColumns as buildSystemColumns, __webpack_exports__defaultFlowPermissionCode as defaultFlowPermissionCode, __webpack_exports__describeImpact as describeImpact, __webpack_exports__entityFlowSlug as entityFlowSlug, __webpack_exports__fitIdentifier as fitIdentifier, __webpack_exports__flowNotFound as flowNotFound, __webpack_exports__flowTimeout as flowTimeout, __webpack_exports__indexName as indexName, __webpack_exports__isDestructiveSchemaAction as isDestructiveSchemaAction, __webpack_exports__isIndexableFieldType as isIndexableFieldType, __webpack_exports__mapDatabaseError as mapDatabaseError, __webpack_exports__mapSchemaError as mapSchemaError, __webpack_exports__plainIndex as plainIndex, __webpack_exports__planTypeConversion as planTypeConversion, __webpack_exports__relationTargetCodes as relationTargetCodes, __webpack_exports__requestInfo as requestInfo, __webpack_exports__sameColumns as sameColumns, __webpack_exports__softDeleteColumn as softDeleteColumn, __webpack_exports__sqlTypeFor as sqlTypeFor, __webpack_exports__tableUnique as tableUnique, __webpack_exports__toFlowSettings as toFlowSettings, __webpack_exports__typeFamily as typeFamily, __webpack_exports__validateRecord as validateRecord };
@@ -1,6 +1,10 @@
1
- import { type IFlowNode, type IStoredApiKey } from './flow.types.js';
1
+ export declare const API_KEY_PREFIX_LENGTH = 11;
2
+ export declare function generateApiKey(): {
3
+ key: string;
4
+ prefix: string;
5
+ hash: string;
6
+ };
2
7
  export declare const hashApiKey: (key: string) => string;
3
8
  export declare const apiKeyPrefix: (key: string) => string;
4
9
  export declare function looksLikeApiKey(key: unknown): key is string;
5
- export declare const apiKeyOpens: (stored: IStoredApiKey | null, presented: unknown) => boolean;
6
- export declare function sealApiKeys(nodes: IFlowNode[]): IFlowNode[];
10
+ export declare function apiKeyMatches(presented: string, storedHash: string): boolean;
@@ -1,20 +1,18 @@
1
1
  import { type IMessageRef } from '@flusys/nestjs-shared/interfaces';
2
- import { type FlowMessageService, type IFlowEndpoint, type IFlowSettings } from './flow.types.js';
2
+ import { type FlowAuthMode, type IFlowEndpoint, type IFlowSettings } from './flow.types.js';
3
3
  export interface IFlowValidationResult {
4
4
  errors: IMessageRef[];
5
5
  warnings: IMessageRef[];
6
6
  }
7
7
  export interface ICallableFlow {
8
8
  isActive: boolean;
9
+ authMode: FlowAuthMode;
9
10
  endpoints: Array<Omit<IFlowEndpoint, 'nodeId'>>;
10
11
  calls: string[];
11
12
  }
12
13
  export interface IFlowValidationContext {
13
14
  knownEntityCodes?: Set<string>;
14
15
  knownFlows?: Map<string, ICallableFlow>;
15
- messageServices?: Partial<Record<FlowMessageService, boolean>>;
16
- companyMembers?: boolean;
17
16
  }
18
17
  export declare function usesPermissionFunction(value: unknown, depth?: number): boolean;
19
18
  export declare function validateFlow(flow: IFlowSettings, context?: IFlowValidationContext): IFlowValidationResult;
20
- export declare function callProblems(caller: IFlowSettings, slug: string, known: Map<string, ICallableFlow>): IMessageRef[];
@@ -1,4 +1,4 @@
1
- import { type IEmailAdapter, type ILoggedUserInfo, type IMessageRef, type INotificationAdapter, type IUserCompanyAccess } from '@flusys/nestjs-shared/interfaces';
1
+ import { type ILoggedUserInfo, type IMessageRef } from '@flusys/nestjs-shared/interfaces';
2
2
  import { type QueryRunner } from 'typeorm';
3
3
  import { type IGenericRecord } from '../interfaces/generic-record.interface.js';
4
4
  import { type IRulePermissionResolver, type RuleEngineService, type RuleExpression } from '../rule-engine/index.js';
@@ -17,18 +17,14 @@ export interface IFlowTraceEntry {
17
17
  }
18
18
  export interface IPendingRecordEvent {
19
19
  entityCode: string;
20
- action: 'created' | 'updated' | 'deleted' | 'purged';
20
+ action: 'created' | 'updated' | 'deleted';
21
21
  row: IGenericRecord;
22
22
  }
23
23
  export interface IPendingFlowEvent {
24
24
  eventName: string;
25
25
  payload: Record<string, unknown>;
26
26
  }
27
- export interface IPendingDelivery {
28
- delivery: string;
29
- send: () => Promise<void>;
30
- }
31
- export type IPendingEvent = IPendingRecordEvent | IPendingFlowEvent | IPendingDelivery;
27
+ export type IPendingEvent = IPendingRecordEvent | IPendingFlowEvent;
32
28
  export interface IFlowLoopScope {
33
29
  item: unknown;
34
30
  index: number;
@@ -47,14 +43,12 @@ export interface IFlowRunState {
47
43
  loop?: IFlowLoopScope;
48
44
  request: Record<string, unknown>;
49
45
  user: ILoggedUserInfo | null;
50
- authorization?: string;
51
46
  permissions?: IRulePermissionResolver;
52
47
  mode: FlowRunMode;
53
48
  runAs: FlowRunAs;
54
49
  systemAuthorized?: boolean;
55
50
  steps: number;
56
51
  httpCalls: number;
57
- messages: number;
58
52
  writes: number;
59
53
  deadline: number;
60
54
  qr?: QueryRunner;
@@ -76,19 +70,15 @@ export interface IFlowEnv {
76
70
  publish(eventName: string, payload: Record<string, unknown>, user: ILoggedUserInfo | null): Promise<void>;
77
71
  atomic<T>(state: IFlowRunState, work: () => Promise<T>): Promise<T>;
78
72
  commit(state: IFlowRunState): Promise<void>;
79
- companyAccess(userId: string): Promise<IUserCompanyAccess>;
80
- companyMembers?(companyId: string, branchIds?: string[]): Promise<string[]>;
81
73
  assertPermission(code: string, user: ILoggedUserInfo | null): Promise<void>;
82
74
  allowPrivateHttp: boolean;
83
- notifications?: INotificationAdapter;
84
- email?: IEmailAdapter;
85
75
  }
86
76
  export interface IFlowEntityAccess {
87
77
  insert(dto: Record<string, unknown>, user: ILoggedUserInfo | null, options?: IFlowWriteOptions): Promise<IGenericRecord>;
88
78
  update(dto: Record<string, unknown> & {
89
79
  id: string;
90
80
  }, user: ILoggedUserInfo | null, options?: IFlowWriteOptions): Promise<IGenericRecord>;
91
- delete(id: string, user: ILoggedUserInfo | null, options?: IFlowWriteOptions): Promise<'deleted' | 'purged'>;
81
+ delete(id: string, user: ILoggedUserInfo | null, options?: IFlowWriteOptions): Promise<unknown>;
92
82
  findById(id: string, options?: IFlowReadOptions): Promise<IGenericRecord>;
93
83
  getAll(search: string | undefined, dto: {
94
84
  filter?: Record<string, unknown>;
@@ -1,12 +1,10 @@
1
1
  import { type RecordFilterOp } from '../interfaces/generic-record.interface.js';
2
2
  import { type RuleExpression, type RuleGroup } from '../rule-engine/index.js';
3
- export declare const FLOW_NODE_TYPES: readonly ["trigger", "validate", "permission_check", "company_branch_check", "set", "condition", "switch", "foreach", "entity_insert", "entity_update", "entity_delete", "entity_get", "entity_query", "commit", "call_flow", "http_request", "publish_event", "send_notification", "send_email", "respond", "code"];
3
+ export declare const FLOW_NODE_TYPES: readonly ["trigger", "validate", "permission_check", "set", "condition", "switch", "foreach", "entity_insert", "entity_update", "entity_delete", "entity_get", "entity_query", "commit", "call_flow", "http_request", "publish_event", "respond", "code"];
4
4
  export type FlowNodeType = (typeof FLOW_NODE_TYPES)[number];
5
5
  export declare const NON_CONTINUABLE_NODE_TYPES: ReadonlySet<FlowNodeType>;
6
6
  export declare const FLOW_AUTH_MODES: readonly ["public", "api_key", "jwt", "permission", "internal"];
7
7
  export type FlowAuthMode = (typeof FLOW_AUTH_MODES)[number];
8
- export declare const DEFAULT_AUTH_MODE: FlowAuthMode;
9
- export declare const KEYLESS_AUTH_MODES: ReadonlySet<FlowAuthMode>;
10
8
  export declare const FLOW_RUN_AS: readonly ["caller", "system"];
11
9
  export type FlowRunAs = (typeof FLOW_RUN_AS)[number];
12
10
  export type FlowRunMode = 'live' | 'dry_run';
@@ -54,6 +52,11 @@ export interface IFlowGraph {
54
52
  }
55
53
  export interface IFlowSettings extends IFlowGraph {
56
54
  slug: string;
55
+ authMode: FlowAuthMode;
56
+ runAs: FlowRunAs;
57
+ isTransactional: boolean;
58
+ bodyType: FlowBodyType;
59
+ inputSchema: IFlowInputField[];
57
60
  }
58
61
  export type ExpressionMap = Record<string, RuleExpression>;
59
62
  export interface IValidateCheck {
@@ -72,13 +75,7 @@ export type PermissionDeniedMode = 'reject' | 'branch';
72
75
  export interface IPermissionCheckConfig {
73
76
  codes: string[] | string;
74
77
  match?: 'any' | 'all';
75
- onDenied?: PermissionDeniedMode;
76
- statusCode?: number;
77
- message?: string;
78
- }
79
- export interface ICompanyBranchCheckConfig {
80
- companyIds?: RuleExpression;
81
- branchIds?: RuleExpression;
78
+ branch?: RuleExpression | null;
82
79
  onDenied?: PermissionDeniedMode;
83
80
  statusCode?: number;
84
81
  message?: string;
@@ -161,19 +158,7 @@ export interface ITriggerConfig {
161
158
  path?: string;
162
159
  bodyType?: FlowBodyType;
163
160
  inputSchema?: IFlowInputField[];
164
- authMode?: FlowAuthMode;
165
- permissionCode?: string;
166
- runAs?: FlowRunAs;
167
- isTransactional?: boolean;
168
- timeoutMs?: number;
169
- rateLimitPerMinute?: number;
170
- apiKey?: string | IStoredApiKey;
171
161
  }
172
- export interface IStoredApiKey {
173
- prefix: string;
174
- hash: string;
175
- }
176
- export declare function isStoredApiKey(value: unknown): value is IStoredApiKey;
177
162
  export interface ICallFlowConfig {
178
163
  flowSlug: string;
179
164
  endpoint?: string;
@@ -186,57 +171,11 @@ export interface IHttpRequestConfig {
186
171
  headers?: ExpressionMap;
187
172
  body?: ExpressionMap;
188
173
  timeoutMs?: number;
189
- forwardAuth?: boolean;
190
174
  }
191
175
  export interface IPublishEventConfig {
192
176
  eventName: string;
193
177
  payload: ExpressionMap;
194
178
  }
195
- export declare const FLOW_MESSAGE_SERVICES: {
196
- readonly send_notification: "notification";
197
- readonly send_email: "email";
198
- };
199
- export type FlowMessageNodeType = keyof typeof FLOW_MESSAGE_SERVICES;
200
- export type FlowMessageService = (typeof FLOW_MESSAGE_SERVICES)[FlowMessageNodeType];
201
- export declare const isMessageNode: (type: string) => type is FlowMessageNodeType;
202
- export declare const FLOW_NOTIFICATION_TYPES: readonly ["info", "success", "warning", "error"];
203
- export type FlowNotificationType = (typeof FLOW_NOTIFICATION_TYPES)[number];
204
- export declare const FLOW_NOTIFICATION_TARGETS: readonly ["one", "many", "company"];
205
- export type FlowNotificationTarget = (typeof FLOW_NOTIFICATION_TARGETS)[number];
206
- export declare const FLOW_EMAIL_TARGETS: readonly ["one", "many"];
207
- export type FlowEmailTarget = (typeof FLOW_EMAIL_TARGETS)[number];
208
- export interface ISendNotificationConfig {
209
- target?: FlowNotificationTarget;
210
- items?: RuleExpression;
211
- userIds?: RuleExpression;
212
- companyIds?: RuleExpression;
213
- branchIds?: RuleExpression;
214
- title: RuleExpression;
215
- message?: RuleExpression;
216
- type?: FlowNotificationType;
217
- data?: ExpressionMap;
218
- companyId?: RuleExpression;
219
- realtime?: boolean;
220
- }
221
- export declare const FLOW_EMAIL_MODES: readonly ["content", "template"];
222
- export type FlowEmailMode = (typeof FLOW_EMAIL_MODES)[number];
223
- export declare const FLOW_EMAIL_FORMATS: readonly ["text", "html"];
224
- export type FlowEmailFormat = (typeof FLOW_EMAIL_FORMATS)[number];
225
- export interface ISendEmailConfig {
226
- target?: FlowEmailTarget;
227
- items?: RuleExpression;
228
- to: RuleExpression;
229
- cc?: RuleExpression;
230
- bcc?: RuleExpression;
231
- replyTo?: RuleExpression;
232
- mode?: FlowEmailMode;
233
- subject?: RuleExpression;
234
- body?: RuleExpression;
235
- format?: FlowEmailFormat;
236
- templateSlug?: string;
237
- variables?: ExpressionMap;
238
- emailConfigId?: string;
239
- }
240
179
  export interface IRespondConfig {
241
180
  statusCode: number;
242
181
  body?: ExpressionMap;
@@ -254,13 +193,6 @@ export declare const FLOW_LIMITS: {
254
193
  readonly MAX_LOOP_DEPTH: 3;
255
194
  readonly MAX_CALL_DEPTH: 5;
256
195
  readonly MAX_HTTP_CALLS: 10;
257
- readonly MAX_MESSAGES_PER_RUN: 100;
258
- readonly MAX_NOTIFICATION_RECIPIENTS: 500;
259
- readonly MAX_COMPANY_NOTIFICATION_RECIPIENTS: 5000;
260
- readonly MAX_EMAIL_RECIPIENTS: 50;
261
- readonly MAX_NOTIFICATION_TITLE_LENGTH: 255;
262
- readonly MAX_EMAIL_SUBJECT_LENGTH: 255;
263
- readonly MAX_EMAIL_TEMPLATE_SLUG_LENGTH: 255;
264
196
  readonly MAX_HTTP_TIMEOUT_MS: 15000;
265
197
  readonly MAX_HTTP_RESPONSE_BYTES: 1000000;
266
198
  readonly MAX_QUERY_LIMIT: 200;
@@ -271,8 +203,6 @@ export declare const FLOW_LIMITS: {
271
203
  readonly DEFAULT_TIMEOUT_MS: 30000;
272
204
  readonly MIN_TIMEOUT_MS: 1000;
273
205
  readonly MAX_TIMEOUT_MS: 120000;
274
- readonly DEFAULT_RATE_LIMIT_PER_MINUTE: 60;
275
- readonly MAX_RATE_LIMIT_PER_MINUTE: 100000;
276
206
  readonly TRACE_PREVIEW_CHARS: 2000;
277
207
  readonly MAX_INPUT_FIELDS: 50;
278
208
  readonly MAX_INPUT_DEPTH: 4;
@@ -291,25 +221,13 @@ export declare const FLOW_NODE_ID_PATTERN: RegExp;
291
221
  export declare const FLOW_SLUG_PATTERN: RegExp;
292
222
  export declare const FLOW_INPUT_NAME_PATTERN: RegExp;
293
223
  export declare const FLOW_ENDPOINT_PATH_PATTERN: RegExp;
294
- export declare const FLOW_ID_PATTERN: RegExp;
295
224
  export interface IFlowEndpoint {
296
225
  nodeId: string;
297
226
  path: string | null;
298
227
  bodyType: FlowBodyType;
299
228
  inputSchema: IFlowInputField[];
300
- authMode: FlowAuthMode;
301
- permissionCode: string | null;
302
- runAs: FlowRunAs;
303
- isTransactional: boolean;
304
- timeoutMs: number;
305
- rateLimitPerMinute: number;
306
- apiKey: IStoredApiKey | null;
307
229
  }
308
- type EndpointSource = Pick<IFlowSettings, 'nodes'>;
309
- export declare const isFunctionFlow: (flow: EndpointSource) => boolean;
310
230
  export declare function triggerPath(node: Pick<IFlowNode, 'config'>): string | null;
311
- export declare function flowEndpoints(flow: EndpointSource): IFlowEndpoint[];
312
- export declare function findEndpoint(flow: EndpointSource, path?: string | null): IFlowEndpoint | undefined;
313
- export declare function startEndpoint(flow: EndpointSource, nodeId?: string): IFlowEndpoint | undefined;
231
+ export declare function flowEndpoints(flow: Pick<IFlowSettings, 'nodes' | 'bodyType' | 'inputSchema'>): IFlowEndpoint[];
232
+ export declare function findEndpoint(flow: Pick<IFlowSettings, 'nodes' | 'bodyType' | 'inputSchema'>, path?: string | null): IFlowEndpoint | undefined;
314
233
  export declare function portsOf(node: Pick<IFlowNode, 'type' | 'config'>): string[];
315
- export {};
@@ -1,24 +1,20 @@
1
1
  import { type IIdentity } from '@flusys/nestjs-shared/interfaces';
2
- import { type IFlowEdge, type IFlowNode } from '../flow-engine/flow.types.js';
2
+ import { type FlowAuthMode, type FlowBodyType, type FlowRunAs, type IFlowEdge, type IFlowInputField, type IFlowNode } from '../flow-engine/flow.types.js';
3
3
  export interface IFlowDefinition extends IIdentity {
4
4
  name: string;
5
5
  slug: string;
6
6
  description: string | null;
7
7
  isActive: boolean;
8
+ authMode: FlowAuthMode;
9
+ permissionCode: string | null;
10
+ runAs: FlowRunAs;
11
+ isTransactional: boolean;
12
+ timeoutMs: number;
13
+ rateLimitPerMinute: number;
8
14
  retainExecutions: number;
15
+ bodyType: FlowBodyType;
16
+ inputSchema: IFlowInputField[];
9
17
  nodes: IFlowNode[];
10
18
  edges: IFlowEdge[];
11
19
  version: number;
12
- draft: IFlowSnapshot | null;
13
- }
14
- export declare const FLOW_VERSIONED_FIELDS: readonly ["name", "slug", "description", "isActive", "retainExecutions", "nodes", "edges"];
15
- export type IFlowSnapshot = Pick<IFlowDefinition, (typeof FLOW_VERSIONED_FIELDS)[number]>;
16
- export interface IFlowVersion {
17
- id: string;
18
- flowId: string;
19
- version: number;
20
- note: string | null;
21
- publishedAt: Date | null;
22
- publishedById: string | null;
23
- definition?: IFlowSnapshot;
24
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flusys/nestjs-entity-builder",
3
- "version": "9.0.1",
3
+ "version": "9.1.0",
4
4
  "description": "Dynamic entity builder module - runtime entity/field metadata, driven DDL, and generic CRUD",
5
5
  "type": "module",
6
6
  "main": "./fesm/index.js",
@@ -75,18 +75,18 @@
75
75
  "@nestjs/common": "^12.0.0",
76
76
  "@nestjs/config": "^12.0.0",
77
77
  "@nestjs/core": "^12.0.0",
78
- "@nestjs/platform-express": "^12.1.2",
78
+ "@nestjs/platform-express": "^12.0.0",
79
79
  "@nestjs/swagger": "^12.0.0",
80
80
  "@nestjs/typeorm": "^12.0.0",
81
81
  "class-transformer": "^0.5.1",
82
82
  "class-validator": "^0.15.0",
83
- "typeorm": "^0.3.31",
83
+ "typeorm": "^0.3.0",
84
84
  "express": "^5.0.0",
85
85
  "rxjs": "^7.8.0"
86
86
  },
87
87
  "dependencies": {
88
- "@flusys/nestjs-core": "9.0.1",
89
- "@flusys/nestjs-shared": "9.0.1",
88
+ "@flusys/nestjs-core": "9.1.0",
89
+ "@flusys/nestjs-shared": "9.1.0",
90
90
  "re2js": "^2.8.6",
91
91
  "quickjs-emscripten": "^0.32.0"
92
92
  }
@@ -17,7 +17,6 @@ export declare class RuleEngineService {
17
17
  private resolveConditionLeft;
18
18
  private resolveConditionValue;
19
19
  resolveExpression(expression: RuleExpression, ctx: RuleEvaluationContext, budget?: IEvaluationBudget): Promise<unknown>;
20
- resolveHtml(expression: RuleExpression, ctx: RuleEvaluationContext): Promise<unknown>;
21
20
  private resolveLookup;
22
21
  private resolveTemplate;
23
22
  private resolveFieldReference;
@@ -8,7 +8,6 @@ export interface IEntityFlowField {
8
8
  nullable?: boolean;
9
9
  defaultValue?: unknown;
10
10
  selectOptions?: unknown[] | null;
11
- validationRules?: Record<string, unknown> | null;
12
11
  }
13
12
  export interface IEntityFlowSource {
14
13
  code: string;
@@ -22,6 +21,7 @@ export interface IEntityFlowTexts {
22
21
  noMatchMessage?: string;
23
22
  }
24
23
  export declare const ENTITY_FLOW_PATHS: Record<EntityFlowEndpoint, string>;
24
+ export declare const BULK_MAX_ITEMS = 200;
25
25
  export declare const entityFlowSlug: (entityCode: string) => string;
26
26
  export declare function buildEntityFlow(entity: IEntityFlowSource, endpoints: readonly EntityFlowEndpoint[], texts?: IEntityFlowTexts): CreateFlowDefinitionDto;
27
27
  export {};
@@ -0,0 +1,31 @@
1
+ import { type ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
2
+ import { EntityBuilderDataSourceProvider } from './entity-builder-datasource.provider.js';
3
+ export type FlowApiKeyStatus = 'active' | 'revoked' | 'expired';
4
+ export type FlowApiKeyCheck = 'valid' | 'invalid' | 'expired';
5
+ export interface IFlowApiKeyInfo {
6
+ id: string;
7
+ flowId: string;
8
+ name: string;
9
+ keyPrefix: string;
10
+ isActive: boolean;
11
+ status: FlowApiKeyStatus;
12
+ expiresAt: Date | null;
13
+ lastUsedAt: Date | null;
14
+ createdAt: Date;
15
+ }
16
+ export declare class FlowApiKeyService {
17
+ private readonly provider;
18
+ constructor(provider: EntityBuilderDataSourceProvider);
19
+ private repo;
20
+ private assertFlowExists;
21
+ private findKey;
22
+ create(flowId: string, name: string, expiresAt: string | undefined, user: ILoggedUserInfo | null): Promise<{
23
+ key: string;
24
+ info: IFlowApiKeyInfo;
25
+ }>;
26
+ list(flowId: string): Promise<IFlowApiKeyInfo[]>;
27
+ revoke(id: string): Promise<void>;
28
+ remove(id: string): Promise<void>;
29
+ verify(flowId: string, presented: unknown): Promise<FlowApiKeyCheck>;
30
+ private info;
31
+ }