@flusys/nestjs-entity-builder 9.1.0-rc.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 (115) hide show
  1. package/README.md +103 -0
  2. package/config/entity-builder.constants.d.ts +6 -0
  3. package/config/event-actions.d.ts +8 -0
  4. package/config/index.d.ts +3 -0
  5. package/config/message-keys.d.ts +481 -0
  6. package/controllers/entity-definition.controller.d.ts +40 -0
  7. package/controllers/field-definition.controller.d.ts +22 -0
  8. package/controllers/flow-api-key.controller.d.ts +14 -0
  9. package/controllers/flow-definition.controller.d.ts +45 -0
  10. package/controllers/flow-execution.controller.d.ts +21 -0
  11. package/controllers/flow-runtime.controller.d.ts +16 -0
  12. package/controllers/index.d.ts +6 -0
  13. package/docs/entity-builder-swagger.config.d.ts +3 -0
  14. package/docs/index.d.ts +1 -0
  15. package/dtos/entity-definition.dto.d.ts +58 -0
  16. package/dtos/field-definition.dto.d.ts +42 -0
  17. package/dtos/flow.dto.d.ts +85 -0
  18. package/dtos/index.d.ts +3 -0
  19. package/dtos/schema-change.dto.d.ts +53 -0
  20. package/entities/entity-definition.entity.d.ts +15 -0
  21. package/entities/field-definition.entity.d.ts +23 -0
  22. package/entities/flow-api-key.entity.d.ts +10 -0
  23. package/entities/flow-definition.entity.d.ts +20 -0
  24. package/entities/flow-execution.entity.d.ts +18 -0
  25. package/entities/index.d.ts +14 -0
  26. package/entities/schema-change-log.entity.d.ts +15 -0
  27. package/enums/ddl-operation.enum.d.ts +13 -0
  28. package/enums/entity-status.enum.d.ts +5 -0
  29. package/enums/field-type.enum.d.ts +15 -0
  30. package/enums/index.d.ts +3 -0
  31. package/fesm/21.js +515 -0
  32. package/fesm/362.js +1074 -0
  33. package/fesm/489.js +1238 -0
  34. package/fesm/606.js +1655 -0
  35. package/fesm/719.js +3615 -0
  36. package/fesm/794.js +1050 -0
  37. package/fesm/996.js +6537 -0
  38. package/fesm/config/index.js +126 -0
  39. package/fesm/controllers/index.js +28 -0
  40. package/fesm/docs/index.js +82 -0
  41. package/fesm/dtos/index.js +327 -0
  42. package/fesm/entities/index.js +18 -0
  43. package/fesm/enums/index.js +97 -0
  44. package/fesm/guards/index.js +228 -0
  45. package/fesm/index.js +1125 -0
  46. package/fesm/interfaces/index.js +80 -0
  47. package/fesm/modules/index.js +642 -0
  48. package/fesm/rule-engine/index.js +21 -0
  49. package/fesm/runtime.js +85 -0
  50. package/fesm/services/index.js +495 -0
  51. package/flow-engine/flow-api-key.d.ts +10 -0
  52. package/flow-engine/flow-code-sandbox.d.ts +5 -0
  53. package/flow-engine/flow-engine.d.ts +22 -0
  54. package/flow-engine/flow-graph.validator.d.ts +19 -0
  55. package/flow-engine/flow-http.client.d.ts +15 -0
  56. package/flow-engine/flow-input.validator.d.ts +7 -0
  57. package/flow-engine/flow-node-handlers.d.ts +5 -0
  58. package/flow-engine/flow-rate-limiter.d.ts +8 -0
  59. package/flow-engine/flow-reference.d.ts +7 -0
  60. package/flow-engine/flow-run.types.d.ts +120 -0
  61. package/flow-engine/flow.errors.d.ts +27 -0
  62. package/flow-engine/flow.types.d.ts +217 -0
  63. package/flow-engine/index.d.ts +4 -0
  64. package/flow-engine/redact.d.ts +3 -0
  65. package/flow-engine/ssrf-guard.d.ts +6 -0
  66. package/guards/flow-access.guard.d.ts +11 -0
  67. package/guards/index.d.ts +1 -0
  68. package/index.d.ts +11 -0
  69. package/interfaces/entity-builder-module.interface.d.ts +28 -0
  70. package/interfaces/field-definition.interface.d.ts +33 -0
  71. package/interfaces/flow-definition.interface.d.ts +20 -0
  72. package/interfaces/generic-record.interface.d.ts +15 -0
  73. package/interfaces/index.d.ts +5 -0
  74. package/interfaces/reference-provider.interface.d.ts +8 -0
  75. package/interfaces/schema-dialect-adapter.interface.d.ts +15 -0
  76. package/modules/entity-builder.module.d.ts +10 -0
  77. package/modules/index.d.ts +1 -0
  78. package/package.json +93 -0
  79. package/rule-engine/index.d.ts +3 -0
  80. package/rule-engine/rule-engine.service.d.ts +39 -0
  81. package/rule-engine/rule-evaluation-context.interface.d.ts +28 -0
  82. package/rule-engine/rule-ip.d.ts +3 -0
  83. package/rule-engine/rule-permission.d.ts +10 -0
  84. package/rule-engine/rule-regex.d.ts +4 -0
  85. package/rule-engine/rule-values.d.ts +5 -0
  86. package/rule-engine/rule.interface.d.ts +79 -0
  87. package/services/database-error.mapper.d.ts +2 -0
  88. package/services/definition-cache.service.d.ts +8 -0
  89. package/services/entity-builder-config.service.d.ts +12 -0
  90. package/services/entity-builder-datasource.provider.d.ts +24 -0
  91. package/services/entity-definition.service.d.ts +17 -0
  92. package/services/entity-flow-scaffold.d.ts +26 -0
  93. package/services/entity-permission.service.d.ts +8 -0
  94. package/services/field-definition.service.d.ts +17 -0
  95. package/services/field-type-conversion.d.ts +15 -0
  96. package/services/field-value-validator.d.ts +17 -0
  97. package/services/flow-api-key.service.d.ts +31 -0
  98. package/services/flow-definition.service.d.ts +49 -0
  99. package/services/flow-execution.service.d.ts +37 -0
  100. package/services/flow-executor.service.d.ts +40 -0
  101. package/services/flow-reference.provider.d.ts +13 -0
  102. package/services/flow-runtime.service.d.ts +29 -0
  103. package/services/generic-entity-service.factory.d.ts +12 -0
  104. package/services/generic-entity.service.d.ts +67 -0
  105. package/services/identifier-rules.d.ts +9 -0
  106. package/services/index.d.ts +27 -0
  107. package/services/reference-rewrite.d.ts +7 -0
  108. package/services/reference-scanner.service.d.ts +10 -0
  109. package/services/schema-change-executor.service.d.ts +39 -0
  110. package/services/schema-change.types.d.ts +59 -0
  111. package/services/schema-columns.d.ts +26 -0
  112. package/services/schema-dialect-adapter.service.d.ts +13 -0
  113. package/services/schema-evolution.service.d.ts +67 -0
  114. package/services/schema-registry.service.d.ts +13 -0
  115. package/services/schema-sync.service.d.ts +28 -0
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@flusys/nestjs-entity-builder",
3
+ "version": "9.1.0-rc.1",
4
+ "description": "Dynamic entity builder module - runtime entity/field metadata, driven DDL, and generic CRUD",
5
+ "type": "module",
6
+ "main": "./fesm/index.js",
7
+ "module": "./fesm/index.js",
8
+ "types": "./index.d.ts",
9
+ "sideEffects": false,
10
+ "keywords": [
11
+ "nestjs",
12
+ "@flusys",
13
+ "entity-builder",
14
+ "dynamic-entities",
15
+ "ddl",
16
+ "schema",
17
+ "backendless"
18
+ ],
19
+ "license": "UNLICENSED",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./index.d.ts",
23
+ "import": "./fesm/index.js"
24
+ },
25
+ "./config": {
26
+ "types": "./config/index.d.ts",
27
+ "import": "./fesm/config/index.js"
28
+ },
29
+ "./controllers": {
30
+ "types": "./controllers/index.d.ts",
31
+ "import": "./fesm/controllers/index.js"
32
+ },
33
+ "./docs": {
34
+ "types": "./docs/index.d.ts",
35
+ "import": "./fesm/docs/index.js"
36
+ },
37
+ "./dtos": {
38
+ "types": "./dtos/index.d.ts",
39
+ "import": "./fesm/dtos/index.js"
40
+ },
41
+ "./entities": {
42
+ "types": "./entities/index.d.ts",
43
+ "import": "./fesm/entities/index.js"
44
+ },
45
+ "./enums": {
46
+ "types": "./enums/index.d.ts",
47
+ "import": "./fesm/enums/index.js"
48
+ },
49
+ "./guards": {
50
+ "types": "./guards/index.d.ts",
51
+ "import": "./fesm/guards/index.js"
52
+ },
53
+ "./interfaces": {
54
+ "types": "./interfaces/index.d.ts",
55
+ "import": "./fesm/interfaces/index.js"
56
+ },
57
+ "./modules": {
58
+ "types": "./modules/index.d.ts",
59
+ "import": "./fesm/modules/index.js"
60
+ },
61
+ "./rule-engine": {
62
+ "types": "./rule-engine/index.d.ts",
63
+ "import": "./fesm/rule-engine/index.js"
64
+ },
65
+ "./services": {
66
+ "types": "./services/index.d.ts",
67
+ "import": "./fesm/services/index.js"
68
+ },
69
+ "./*": {
70
+ "types": "./*.d.ts",
71
+ "import": "./fesm/*.js"
72
+ }
73
+ },
74
+ "peerDependencies": {
75
+ "@nestjs/common": "^12.0.0",
76
+ "@nestjs/config": "^12.0.0",
77
+ "@nestjs/core": "^12.0.0",
78
+ "@nestjs/platform-express": "^12.0.0",
79
+ "@nestjs/swagger": "^12.0.0",
80
+ "@nestjs/typeorm": "^12.0.0",
81
+ "class-transformer": "^0.5.1",
82
+ "class-validator": "^0.15.0",
83
+ "typeorm": "^0.3.0",
84
+ "express": "^5.0.0",
85
+ "rxjs": "^7.8.0"
86
+ },
87
+ "dependencies": {
88
+ "@flusys/nestjs-core": "9.1.0-rc.1",
89
+ "@flusys/nestjs-shared": "9.1.0-rc.1",
90
+ "re2js": "^2.8.6",
91
+ "quickjs-emscripten": "^0.32.0"
92
+ }
93
+ }
@@ -0,0 +1,3 @@
1
+ export * from './rule.interface.js';
2
+ export * from './rule-evaluation-context.interface.js';
3
+ export * from './rule-engine.service.js';
@@ -0,0 +1,39 @@
1
+ import { type IPermissionResolver } from '@flusys/nestjs-shared/interfaces';
2
+ import { SharedPermissionCacheService } from '@flusys/nestjs-shared/modules';
3
+ import { type IRulePermissionResolver, type RuleEvaluationContext } from './rule-evaluation-context.interface.js';
4
+ import { type RuleCondition, type RuleExpression, type RuleGroup } from './rule.interface.js';
5
+ interface IEvaluationBudget {
6
+ lookups?: number;
7
+ permissions?: IRulePermissionResolver;
8
+ }
9
+ export declare class RuleEngineService {
10
+ private readonly permissionResolver?;
11
+ private readonly permissionCache?;
12
+ constructor(permissionResolver?: IPermissionResolver | undefined, permissionCache?: SharedPermissionCacheService | undefined);
13
+ createPermissionResolver(user: RuleEvaluationContext['user']): IRulePermissionResolver;
14
+ evaluateGroup(group: RuleGroup, ctx: RuleEvaluationContext, depth?: number, budget?: IEvaluationBudget): Promise<boolean>;
15
+ private every;
16
+ evaluateCondition(condition: RuleCondition, ctx: RuleEvaluationContext, budget?: IEvaluationBudget): Promise<boolean>;
17
+ private resolveConditionLeft;
18
+ private resolveConditionValue;
19
+ resolveExpression(expression: RuleExpression, ctx: RuleEvaluationContext, budget?: IEvaluationBudget): Promise<unknown>;
20
+ private resolveLookup;
21
+ private resolveTemplate;
22
+ private resolveFieldReference;
23
+ private getPath;
24
+ private resolveFunction;
25
+ private hasPermissions;
26
+ private toText;
27
+ private toTime;
28
+ private toDurationUnit;
29
+ private toUtcOffset;
30
+ private ordered;
31
+ private toContainerCheck;
32
+ private isEmptyValue;
33
+ private hasIntersection;
34
+ private toNumber;
35
+ private tryToNumber;
36
+ private applyArithmetic;
37
+ private assertWithinLimits;
38
+ }
39
+ export {};
@@ -0,0 +1,28 @@
1
+ import { type ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
2
+ export interface IRuleLookupQuery {
3
+ filter: Record<string, unknown>;
4
+ sort?: Record<string, 'ASC' | 'DESC'>;
5
+ limit: number;
6
+ }
7
+ export interface IRuleLookupResolver {
8
+ find(entityCode: string, query: IRuleLookupQuery): Promise<{
9
+ rows: Record<string, unknown>[];
10
+ total: number;
11
+ }>;
12
+ }
13
+ export interface IRulePermissionResolver {
14
+ granted(branchId: string | null | undefined): Promise<string[]>;
15
+ }
16
+ export interface RuleEvaluationContext {
17
+ input?: Record<string, unknown> | unknown[];
18
+ context?: Record<string, Record<string, unknown>>;
19
+ vars?: Record<string, unknown>;
20
+ loop?: {
21
+ item: unknown;
22
+ index: number;
23
+ };
24
+ request?: Record<string, unknown>;
25
+ user: ILoggedUserInfo | null;
26
+ lookupResolver?: IRuleLookupResolver;
27
+ permissions?: IRulePermissionResolver;
28
+ }
@@ -0,0 +1,3 @@
1
+ export declare function parseIpRanges(value: unknown): string[];
2
+ export declare function invalidIpRange(value: unknown): string | null;
3
+ export declare function ipInRanges(ip: unknown, ranges: unknown): boolean;
@@ -0,0 +1,10 @@
1
+ import { type ILoggedUserInfo, type IPermissionResolver } from '@flusys/nestjs-shared/interfaces';
2
+ import { type SharedPermissionCacheService } from '@flusys/nestjs-shared/modules';
3
+ import { type IRulePermissionResolver } from './rule-evaluation-context.interface.js';
4
+ export interface IRulePermissionSources {
5
+ resolver?: IPermissionResolver;
6
+ cache?: SharedPermissionCacheService;
7
+ }
8
+ export declare function createRulePermissionResolver(user: ILoggedUserInfo | null, sources: IRulePermissionSources): IRulePermissionResolver;
9
+ export declare function parsePermissionCodes(value: unknown): string[];
10
+ export declare function toBranchArgument(args: unknown[], index: number): string | null | undefined;
@@ -0,0 +1,4 @@
1
+ export type RulePatternProblem = 'too_long' | 'invalid' | 'too_complex';
2
+ export declare function rulePatternProblem(pattern: string): RulePatternProblem | null;
3
+ export declare function matchesPattern(input: unknown, pattern: unknown): boolean;
4
+ export declare function extractPattern(input: unknown, pattern: unknown, group?: unknown): string | null;
@@ -0,0 +1,5 @@
1
+ export declare const ISO_DATE_PREFIX: RegExp;
2
+ export declare function parseDateText(text: string): number;
3
+ export declare function valuesEqual(a: unknown, b: unknown): boolean;
4
+ export declare const includesValue: (list: readonly unknown[], value: unknown) => boolean;
5
+ export declare const equalsOperand: (value: unknown) => unknown;
@@ -0,0 +1,79 @@
1
+ import { type RecordFilterOp } from '../interfaces/generic-record.interface.js';
2
+ export type RuleLogicOperator = 'AND' | 'OR' | 'NOT';
3
+ export declare const RULE_COMPARISON_OPERATORS: readonly ["equals", "not_equals", "greater_than", "less_than", "greater_or_equal", "less_or_equal", "contains", "not_contains", "starts_with", "ends_with", "is_empty", "is_not_empty", "in", "not_in", "is_any_of", "is_none_of", "is_true", "is_false", "matches", "not_matches"];
4
+ export type RuleComparisonOperator = (typeof RULE_COMPARISON_OPERATORS)[number];
5
+ export interface RuleCondition {
6
+ field?: string;
7
+ left?: RuleExpression;
8
+ comparison: RuleComparisonOperator;
9
+ value?: unknown | {
10
+ $field: string;
11
+ } | {
12
+ $expr: RuleExpression;
13
+ };
14
+ }
15
+ export interface RuleGroup {
16
+ operator: RuleLogicOperator;
17
+ conditions: Array<RuleCondition | RuleGroup>;
18
+ }
19
+ export declare function isRuleGroup(node: RuleCondition | RuleGroup): node is RuleGroup;
20
+ export type RuleArithmeticOp = 'sum' | 'subtract' | 'multiply' | 'divide' | 'min' | 'max';
21
+ export declare const RULE_PERMISSION_FUNCTIONS: readonly ["HAS_PERMISSION", "HAS_ANY_PERMISSION", "HAS_ALL_PERMISSIONS"];
22
+ export type RulePermissionFunctionName = (typeof RULE_PERMISSION_FUNCTIONS)[number];
23
+ export declare const RULE_REQUEST_FUNCTIONS: readonly ["HEADER", "QUERY_PARAM", "IP_IN_RANGE"];
24
+ export type RuleRequestFunctionName = (typeof RULE_REQUEST_FUNCTIONS)[number];
25
+ export type RuleTextFunctionName = 'LOWER' | 'UPPER' | 'TRIM' | 'LENGTH' | 'SPLIT_PART' | 'REGEX_EXTRACT' | 'REPLACE' | 'TO_NUMBER';
26
+ export type RuleFunctionName = 'NOW' | 'UUID' | 'CURRENT_USER_ID' | 'COALESCE' | 'ROUND' | 'DATE_DIFF' | 'START_OF_DAY' | 'END_OF_DAY' | 'ADD_DURATION' | RulePermissionFunctionName | RuleRequestFunctionName | RuleTextFunctionName;
27
+ export declare function isPermissionFunction(name: unknown): name is RulePermissionFunctionName;
28
+ export declare const RULE_DURATION_UNITS: readonly ["second", "minute", "hour", "day"];
29
+ export type RuleDurationUnit = (typeof RULE_DURATION_UNITS)[number];
30
+ export type RuleLookupMode = 'exists' | 'count' | 'first';
31
+ export interface RuleLookupFilterCondition {
32
+ op: RecordFilterOp;
33
+ value?: RuleExpression;
34
+ }
35
+ export interface RuleLookupExpression {
36
+ type: 'lookup';
37
+ entity: string;
38
+ filter: Record<string, RuleExpression | RuleLookupFilterCondition>;
39
+ mode: RuleLookupMode;
40
+ field?: string;
41
+ sort?: {
42
+ field: string;
43
+ direction: 'ASC' | 'DESC';
44
+ };
45
+ }
46
+ export type RuleExpression = {
47
+ type: 'literal';
48
+ value: string | number | boolean | null;
49
+ } | {
50
+ type: 'field_ref';
51
+ ref: string;
52
+ } | {
53
+ type: 'arithmetic';
54
+ op: RuleArithmeticOp;
55
+ operands: RuleExpression[];
56
+ } | {
57
+ type: 'concat';
58
+ parts: RuleExpression[];
59
+ } | {
60
+ type: 'function';
61
+ name: RuleFunctionName;
62
+ args: RuleExpression[];
63
+ } | {
64
+ type: 'template';
65
+ template: string;
66
+ } | RuleLookupExpression;
67
+ export declare const RULE_TEMPLATE_MAX_LENGTH = 4000;
68
+ export declare const RULE_ENGINE_LIMITS: {
69
+ readonly MAX_GROUP_DEPTH: 8;
70
+ readonly MAX_CONDITIONS_PER_GROUP: 100;
71
+ readonly MAX_LOOKUPS: 10;
72
+ readonly MAX_REGEX_PATTERN_LENGTH: 500;
73
+ readonly MAX_REGEX_INPUT_LENGTH: 10000;
74
+ readonly MAX_REGEX_REPEAT: 100;
75
+ readonly MAX_REGEX_REPEAT_EXPANSION: 300;
76
+ readonly MAX_UTC_OFFSET_MINUTES: 840;
77
+ readonly MAX_PERMISSION_CODES: 50;
78
+ readonly MAX_IP_RANGES: 100;
79
+ };
@@ -0,0 +1,2 @@
1
+ export declare function mapDatabaseError(error: unknown, knownFields?: string[]): unknown;
2
+ export declare function mapSchemaError(error: unknown): unknown;
@@ -0,0 +1,8 @@
1
+ import { HybridCache } from '@flusys/nestjs-shared/classes';
2
+ import { UtilsService } from '@flusys/nestjs-shared/modules';
3
+ export declare class DefinitionCacheService {
4
+ private readonly cacheManager;
5
+ private readonly utilsService;
6
+ constructor(cacheManager: HybridCache, utilsService: UtilsService);
7
+ clearAll(tenantId?: string): Promise<void>;
8
+ }
@@ -0,0 +1,12 @@
1
+ import { type DatabaseMode, type ITenantDatabaseConfig } from '@flusys/nestjs-core';
2
+ import { type IModuleConfigService } from '@flusys/nestjs-shared/interfaces';
3
+ import { type EntityBuilderModuleOptions } from '../interfaces/entity-builder-module.interface.js';
4
+ export declare class EntityBuilderConfigService implements IModuleConfigService {
5
+ private readonly options;
6
+ constructor(options: EntityBuilderModuleOptions);
7
+ isCompanyFeatureEnabled(tenant?: ITenantDatabaseConfig): boolean;
8
+ getDatabaseMode(): DatabaseMode;
9
+ isMultiTenant(): boolean;
10
+ getOptions(): EntityBuilderModuleOptions;
11
+ getConfig(): import("../index.js").IEntityBuilderConfig | undefined;
12
+ }
@@ -0,0 +1,24 @@
1
+ import { MultiTenantDataSourceService } from '@flusys/nestjs-shared/modules';
2
+ import { type IDatabaseConfig, type ITenantDatabaseConfig } from '@flusys/nestjs-core';
3
+ import { type Request } from 'express';
4
+ import { DataSource, type EntitySchema, type ObjectLiteral, type QueryRunner, type Repository } from 'typeorm';
5
+ import { type SupportedDbDriver } from '../interfaces/schema-dialect-adapter.interface.js';
6
+ import { EntityBuilderConfigService } from './entity-builder-config.service.js';
7
+ export declare class EntityBuilderDataSourceProvider extends MultiTenantDataSourceService {
8
+ protected static readonly tenantConnections: Map<string, DataSource>;
9
+ protected static singleDataSource: DataSource | null;
10
+ protected static readonly tenantsRegistry: Map<string, ITenantDatabaseConfig>;
11
+ protected static initialized: boolean;
12
+ protected static readonly connectionLocks: Map<string, Promise<DataSource>>;
13
+ protected static singleConnectionLock: Promise<DataSource> | null;
14
+ private static readonly registeredSchemas;
15
+ private static readonly rebuildLocks;
16
+ constructor(configService: EntityBuilderConfigService, request?: Request);
17
+ private static buildParentOptions;
18
+ private get statics();
19
+ protected createDataSourceFromConfig(config: IDatabaseConfig): Promise<DataSource>;
20
+ getDriver(): Promise<SupportedDbDriver>;
21
+ registerDynamicSchema(schema: EntitySchema): Promise<void>;
22
+ getDynamicRepository<T extends ObjectLiteral>(schema: EntitySchema<T>): Promise<Repository<T>>;
23
+ getQueryRunner(): Promise<QueryRunner>;
24
+ }
@@ -0,0 +1,17 @@
1
+ import { ApiService, HybridCache } from '@flusys/nestjs-shared/classes';
2
+ import { UtilsService } from '@flusys/nestjs-shared/modules';
3
+ import { type ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
4
+ import { type SelectQueryBuilder } from 'typeorm';
5
+ import { type UpdateEntityDefinitionDto, type CreateEntityDefinitionDto } from '../dtos/entity-definition.dto.js';
6
+ import { EntityDefinition } from '../entities/entity-definition.entity.js';
7
+ import { type IEntityDefinition } from '../interfaces/field-definition.interface.js';
8
+ import { EntityBuilderDataSourceProvider } from './entity-builder-datasource.provider.js';
9
+ export declare class EntityDefinitionService extends ApiService<CreateEntityDefinitionDto, UpdateEntityDefinitionDto, IEntityDefinition, EntityDefinition> {
10
+ protected cacheManager: HybridCache;
11
+ protected utilsService: UtilsService;
12
+ constructor(cacheManager: HybridCache, utilsService: UtilsService, dataSourceProvider: EntityBuilderDataSourceProvider);
13
+ protected getSelectQuery(query: SelectQueryBuilder<EntityDefinition>, user: ILoggedUserInfo | null, select?: string[]): Promise<{
14
+ query: SelectQueryBuilder<EntityDefinition>;
15
+ isRaw: boolean;
16
+ }>;
17
+ }
@@ -0,0 +1,26 @@
1
+ import { type EntityFlowEndpoint } from '../config/entity-builder.constants.js';
2
+ import { FieldType } from '../enums/field-type.enum.js';
3
+ import { type CreateFlowDefinitionDto } from '../dtos/flow.dto.js';
4
+ export interface IEntityFlowField {
5
+ code: string;
6
+ label?: string;
7
+ fieldType: FieldType;
8
+ nullable?: boolean;
9
+ defaultValue?: unknown;
10
+ selectOptions?: unknown[] | null;
11
+ }
12
+ export interface IEntityFlowSource {
13
+ code: string;
14
+ label: string;
15
+ fields: IEntityFlowField[];
16
+ }
17
+ type FlowInputLabel = 'id' | 'ids' | 'search';
18
+ export interface IEntityFlowTexts {
19
+ names?: Partial<Record<EntityFlowEndpoint, string>>;
20
+ inputLabels?: Partial<Record<FlowInputLabel, string>>;
21
+ noMatchMessage?: string;
22
+ }
23
+ export declare const BULK_MAX_ITEMS = 200;
24
+ export declare function entityFlowSlug(entityCode: string, endpoint: EntityFlowEndpoint): string;
25
+ export declare function buildEntityFlow(entity: IEntityFlowSource, endpoint: EntityFlowEndpoint, texts?: IEntityFlowTexts): CreateFlowDefinitionDto;
26
+ export {};
@@ -0,0 +1,8 @@
1
+ import { type IPermissionActionRegistry } from '@flusys/nestjs-shared';
2
+ import { EntityDefinition } from '../entities/entity-definition.entity.js';
3
+ export declare class EntityPermissionService {
4
+ private readonly actionRegistry?;
5
+ constructor(actionRegistry?: IPermissionActionRegistry | undefined);
6
+ provisionForEntity(definition: EntityDefinition): Promise<void>;
7
+ deprovisionForEntity(definition: Pick<EntityDefinition, 'code'>): Promise<void>;
8
+ }
@@ -0,0 +1,17 @@
1
+ import { ApiService, HybridCache } from '@flusys/nestjs-shared/classes';
2
+ import { UtilsService } from '@flusys/nestjs-shared/modules';
3
+ import { type ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
4
+ import { type SelectQueryBuilder } from 'typeorm';
5
+ import { type UpdateFieldDefinitionDto, type CreateFieldDefinitionDto } from '../dtos/field-definition.dto.js';
6
+ import { FieldDefinition } from '../entities/field-definition.entity.js';
7
+ import { type IFieldDefinition } from '../interfaces/field-definition.interface.js';
8
+ import { EntityBuilderDataSourceProvider } from './entity-builder-datasource.provider.js';
9
+ export declare class FieldDefinitionService extends ApiService<CreateFieldDefinitionDto, UpdateFieldDefinitionDto, IFieldDefinition, FieldDefinition> {
10
+ protected cacheManager: HybridCache;
11
+ protected utilsService: UtilsService;
12
+ constructor(cacheManager: HybridCache, utilsService: UtilsService, dataSourceProvider: EntityBuilderDataSourceProvider);
13
+ protected getSelectQuery(query: SelectQueryBuilder<FieldDefinition>, user: ILoggedUserInfo | null, select?: string[]): Promise<{
14
+ query: SelectQueryBuilder<FieldDefinition>;
15
+ isRaw: boolean;
16
+ }>;
17
+ }
@@ -0,0 +1,15 @@
1
+ import { type IMessageRef } from '@flusys/nestjs-shared/interfaces';
2
+ import { FieldType } from '../enums/field-type.enum.js';
3
+ import { type SupportedDbDriver } from '../interfaces/schema-dialect-adapter.interface.js';
4
+ export interface ITypeConversion {
5
+ supported: boolean;
6
+ reason?: IMessageRef;
7
+ noDbChange?: boolean;
8
+ using?: (column: string) => string;
9
+ prechecks: Array<{
10
+ description: IMessageRef;
11
+ badRowsWhere: (column: string, driver: SupportedDbDriver) => string;
12
+ }>;
13
+ lossy?: IMessageRef;
14
+ }
15
+ export declare function planTypeConversion(from: FieldType, to: FieldType, driver: SupportedDbDriver): ITypeConversion;
@@ -0,0 +1,17 @@
1
+ import { type IValidationError } from '@flusys/nestjs-shared/exceptions';
2
+ import { type IMessageRef } from '@flusys/nestjs-shared/interfaces';
3
+ import { FieldType } from '../enums/field-type.enum.js';
4
+ export type IFieldError = IValidationError & IMessageRef;
5
+ export interface IValidatableField {
6
+ code: string;
7
+ label: string;
8
+ fieldType: FieldType;
9
+ nullable: boolean;
10
+ defaultValue: unknown;
11
+ selectOptions: unknown[] | null;
12
+ validationRules: Record<string, unknown> | null;
13
+ }
14
+ export declare function validateRecord(fields: IValidatableField[], values: Record<string, unknown>, mode: 'insert' | 'update'): {
15
+ values: Record<string, unknown>;
16
+ errors: IFieldError[];
17
+ };
@@ -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
+ }
@@ -0,0 +1,49 @@
1
+ import { type IPermissionActionRegistry } from '@flusys/nestjs-shared';
2
+ import { ApiService, HybridCache } from '@flusys/nestjs-shared/classes';
3
+ import { type DeleteDto } from '@flusys/nestjs-shared/dtos';
4
+ import { type ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
5
+ import { SharedPermissionCacheService, UtilsService } from '@flusys/nestjs-shared/modules';
6
+ import { NotFoundException } from '@nestjs/common';
7
+ import { type QueryRunner } from 'typeorm';
8
+ import { type CreateFlowDefinitionDto, type UpdateFlowDefinitionDto } from '../dtos/flow.dto.js';
9
+ import { FlowDefinition } from '../entities/flow-definition.entity.js';
10
+ import { type IFlowValidationResult } from '../flow-engine/flow-graph.validator.js';
11
+ import { type IFlowSettings } from '../flow-engine/flow.types.js';
12
+ import { type IFlowDefinition } from '../interfaces/flow-definition.interface.js';
13
+ import { EntityBuilderDataSourceProvider } from './entity-builder-datasource.provider.js';
14
+ export declare const defaultFlowPermissionCode: (slug: string) => string;
15
+ export declare const flowNotFound: () => NotFoundException;
16
+ export declare function toFlowSettings(dto: Pick<Partial<CreateFlowDefinitionDto>, 'authMode' | 'runAs' | 'isTransactional' | 'bodyType' | 'inputSchema' | 'nodes' | 'edges' | 'timeoutMs'> & {
17
+ slug: string;
18
+ }): IFlowSettings & {
19
+ timeoutMs: number;
20
+ };
21
+ export declare class FlowDefinitionService extends ApiService<CreateFlowDefinitionDto, UpdateFlowDefinitionDto, IFlowDefinition, FlowDefinition> {
22
+ protected cacheManager: HybridCache;
23
+ protected utilsService: UtilsService;
24
+ private readonly provider;
25
+ private readonly permissionCache;
26
+ private readonly actionRegistry?;
27
+ constructor(cacheManager: HybridCache, utilsService: UtilsService, provider: EntityBuilderDataSourceProvider, permissionCache: SharedPermissionCacheService, actionRegistry?: IPermissionActionRegistry | undefined);
28
+ findOrFail(id: string): Promise<FlowDefinition>;
29
+ validate(settings: IFlowSettings): Promise<IFlowValidationResult>;
30
+ private callersOf;
31
+ private assertNotCalled;
32
+ private assertSaveable;
33
+ assertMayAuthor(settings: IFlowSettings, user: ILoggedUserInfo | null): Promise<void>;
34
+ assertMayCreate(user: ILoggedUserInfo | null): Promise<void>;
35
+ assertMayTest(settings: IFlowSettings & {
36
+ permissionCode?: string | null;
37
+ }, user: ILoggedUserInfo | null, run: {
38
+ mode: 'dry_run' | 'live';
39
+ draft: boolean;
40
+ saved: boolean;
41
+ }): Promise<void>;
42
+ private assertHasPermission;
43
+ protected beforeInsertOperation(dto: CreateFlowDefinitionDto | CreateFlowDefinitionDto[], user: ILoggedUserInfo | null, _qr: QueryRunner): Promise<void>;
44
+ protected beforeUpdateOperation(dto: UpdateFlowDefinitionDto | UpdateFlowDefinitionDto[], user: ILoggedUserInfo | null, _qr: QueryRunner): Promise<void>;
45
+ protected beforeDeleteOperation(dto: DeleteDto, user: ILoggedUserInfo | null, _qr: QueryRunner): Promise<void>;
46
+ protected afterInsertOperation(entities: FlowDefinition[]): Promise<void>;
47
+ protected afterUpdateOperation(entities: FlowDefinition[]): Promise<void>;
48
+ private provisionPermissions;
49
+ }
@@ -0,0 +1,37 @@
1
+ import { FlowExecution } from '../entities/flow-execution.entity.js';
2
+ import { type IFlowRunResult, type IFlowSavePoint } from '../flow-engine/flow-run.types.js';
3
+ import { EntityBuilderDataSourceProvider } from './entity-builder-datasource.provider.js';
4
+ export interface IExecutionRecord {
5
+ flowId: string | null;
6
+ flowSlug: string;
7
+ trigger: 'webhook' | 'test';
8
+ mode: 'live' | 'dry_run';
9
+ input: unknown;
10
+ result: Pick<IFlowRunResult, 'status' | 'statusCode' | 'body' | 'error' | 'trace' | 'durationMs'>;
11
+ startedAt: Date;
12
+ actorId: string | null;
13
+ callerIp: string | null;
14
+ retain: number;
15
+ }
16
+ export declare const DRAFT_TEST_RETAIN = 200;
17
+ export declare class FlowExecutionService {
18
+ private readonly provider;
19
+ private readonly logger;
20
+ private static writes;
21
+ constructor(provider: EntityBuilderDataSourceProvider);
22
+ record(entry: IExecutionRecord): Promise<void>;
23
+ prune(flowId: string | null, retain: number): Promise<void>;
24
+ list(query: {
25
+ flowId?: string;
26
+ status?: string;
27
+ page: number;
28
+ pageSize: number;
29
+ }): Promise<{
30
+ rows: FlowExecution[];
31
+ total: number;
32
+ }>;
33
+ get(id: string): Promise<(FlowExecution & {
34
+ savedUpTo: IFlowSavePoint | null;
35
+ }) | null>;
36
+ private repo;
37
+ }
@@ -0,0 +1,40 @@
1
+ import { type ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
2
+ import { SharedPermissionCacheService } from '@flusys/nestjs-shared/modules';
3
+ import { ModuleRef } from '@nestjs/core';
4
+ import { type IFlowRunResult } from '../flow-engine/flow-run.types.js';
5
+ import { type FlowInput, type FlowRunMode, type IFlowSettings } from '../flow-engine/flow.types.js';
6
+ import { RuleEngineService } from '../rule-engine/index.js';
7
+ import { EntityBuilderConfigService } from './entity-builder-config.service.js';
8
+ import { EntityBuilderDataSourceProvider } from './entity-builder-datasource.provider.js';
9
+ export interface IFlowRunOptions {
10
+ mode: FlowRunMode;
11
+ user: ILoggedUserInfo | null;
12
+ input: FlowInput;
13
+ request: Record<string, unknown>;
14
+ exposeDetails: boolean;
15
+ systemAuthorized: boolean;
16
+ }
17
+ export declare const flowTimeout: (timeoutMs: unknown) => number;
18
+ type RunnableFlow = IFlowSettings & {
19
+ timeoutMs: number;
20
+ };
21
+ export declare class FlowExecutorService {
22
+ private readonly provider;
23
+ private readonly ruleEngine;
24
+ private readonly moduleRef;
25
+ private readonly permissionCache;
26
+ private readonly config;
27
+ private readonly logger;
28
+ constructor(provider: EntityBuilderDataSourceProvider, ruleEngine: RuleEngineService, moduleRef: ModuleRef, permissionCache: SharedPermissionCacheService, config: EntityBuilderConfigService);
29
+ run(definition: RunnableFlow, options: IFlowRunOptions): Promise<IFlowRunResult>;
30
+ private execute;
31
+ private limitStatementTime;
32
+ private commitProgress;
33
+ private atomic;
34
+ private callFlow;
35
+ private findCallable;
36
+ private assertMayCall;
37
+ private createEnv;
38
+ private publishPendingEvents;
39
+ }
40
+ export {};
@@ -0,0 +1,13 @@
1
+ import { type EntityManager } from 'typeorm';
2
+ import { type IEntityReferenceProvider } from '../interfaces/reference-provider.interface.js';
3
+ import { EntityBuilderDataSourceProvider } from './entity-builder-datasource.provider.js';
4
+ import { type ISchemaImpact } from './schema-change.types.js';
5
+ export declare class FlowReferenceProvider implements IEntityReferenceProvider {
6
+ private readonly provider;
7
+ constructor(provider: EntityBuilderDataSourceProvider);
8
+ private flows;
9
+ private repo;
10
+ findEntityReferences(entityCode: string): Promise<ISchemaImpact[]>;
11
+ findFieldReferences(entityCode: string, fieldCode: string): Promise<ISchemaImpact[]>;
12
+ rewriteFieldReferences(entityCode: string, from: string, to: string, manager?: EntityManager): Promise<number>;
13
+ }
@@ -0,0 +1,29 @@
1
+ import { type ILoggedUserInfo, type IMessageRef } from '@flusys/nestjs-shared/interfaces';
2
+ import { type TestFlowDto } from '../dtos/flow.dto.js';
3
+ import { FlowDefinition } from '../entities/flow-definition.entity.js';
4
+ import { type IFlowRunResult } from '../flow-engine/flow-run.types.js';
5
+ import { EntityBuilderDataSourceProvider } from './entity-builder-datasource.provider.js';
6
+ import { FlowDefinitionService } from './flow-definition.service.js';
7
+ import { FlowExecutionService } from './flow-execution.service.js';
8
+ import { FlowExecutorService } from './flow-executor.service.js';
9
+ export interface IFlowCaller {
10
+ ip: string | null;
11
+ headers: Record<string, unknown>;
12
+ query?: Record<string, unknown>;
13
+ path?: string | null;
14
+ }
15
+ export declare function requestInfo(caller: IFlowCaller): Record<string, unknown>;
16
+ export declare class FlowRuntimeService {
17
+ private readonly provider;
18
+ private readonly executor;
19
+ private readonly executions;
20
+ private readonly definitions;
21
+ constructor(provider: EntityBuilderDataSourceProvider, executor: FlowExecutorService, executions: FlowExecutionService, definitions: FlowDefinitionService);
22
+ findActive(slug: string): Promise<FlowDefinition | null>;
23
+ handle(flow: FlowDefinition, body: unknown, caller: IFlowCaller, user: ILoggedUserInfo | null): Promise<IFlowRunResult>;
24
+ testRun(dto: TestFlowDto, user: ILoggedUserInfo | null, caller: IFlowCaller): Promise<{
25
+ result: IFlowRunResult;
26
+ warnings: IMessageRef[];
27
+ }>;
28
+ private logWebhook;
29
+ }