@flusys/nestjs-entity-builder 9.0.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.
- package/README.md +111 -0
- package/config/entity-builder.constants.d.ts +6 -0
- package/config/event-actions.d.ts +8 -0
- package/config/index.d.ts +3 -0
- package/config/message-keys.d.ts +542 -0
- package/controllers/entity-definition.controller.d.ts +40 -0
- package/controllers/field-definition.controller.d.ts +22 -0
- package/controllers/flow-definition.controller.d.ts +51 -0
- package/controllers/flow-execution.controller.d.ts +21 -0
- package/controllers/flow-runtime.controller.d.ts +24 -0
- package/controllers/index.d.ts +5 -0
- package/docs/entity-builder-swagger.config.d.ts +3 -0
- package/docs/index.d.ts +1 -0
- package/dtos/entity-definition.dto.d.ts +58 -0
- package/dtos/field-definition.dto.d.ts +42 -0
- package/dtos/flow.dto.d.ts +76 -0
- package/dtos/index.d.ts +3 -0
- package/dtos/schema-change.dto.d.ts +53 -0
- package/entities/entity-definition.entity.d.ts +15 -0
- package/entities/field-definition.entity.d.ts +23 -0
- package/entities/flow-definition.entity.d.ts +14 -0
- package/entities/flow-execution.entity.d.ts +19 -0
- package/entities/flow-version.entity.d.ts +10 -0
- package/entities/index.d.ts +14 -0
- package/entities/schema-change-log.entity.d.ts +15 -0
- package/enums/ddl-operation.enum.d.ts +13 -0
- package/enums/entity-status.enum.d.ts +5 -0
- package/enums/field-type.enum.d.ts +15 -0
- package/enums/index.d.ts +3 -0
- package/fesm/21.js +576 -0
- package/fesm/362.js +1074 -0
- package/fesm/458.js +649 -0
- package/fesm/582.js +1247 -0
- package/fesm/677.js +7534 -0
- package/fesm/719.js +3597 -0
- package/fesm/794.js +979 -0
- package/fesm/913.js +1620 -0
- package/fesm/config/index.js +126 -0
- package/fesm/controllers/index.js +27 -0
- package/fesm/docs/index.js +82 -0
- package/fesm/dtos/index.js +327 -0
- package/fesm/entities/index.js +18 -0
- package/fesm/enums/index.js +97 -0
- package/fesm/guards/index.js +226 -0
- package/fesm/index.js +548 -0
- package/fesm/interfaces/index.js +80 -0
- package/fesm/modules/index.js +25 -0
- package/fesm/rule-engine/index.js +21 -0
- package/fesm/runtime.js +85 -0
- package/fesm/services/index.js +526 -0
- package/flow-engine/flow-api-key.d.ts +6 -0
- package/flow-engine/flow-code-sandbox.d.ts +5 -0
- package/flow-engine/flow-engine.d.ts +22 -0
- package/flow-engine/flow-graph.validator.d.ts +20 -0
- package/flow-engine/flow-http.client.d.ts +15 -0
- package/flow-engine/flow-input.validator.d.ts +7 -0
- package/flow-engine/flow-node-handlers.d.ts +5 -0
- package/flow-engine/flow-rate-limiter.d.ts +8 -0
- package/flow-engine/flow-reference.d.ts +7 -0
- package/flow-engine/flow-run.types.d.ts +131 -0
- package/flow-engine/flow.errors.d.ts +27 -0
- package/flow-engine/flow.types.d.ts +315 -0
- package/flow-engine/index.d.ts +4 -0
- package/flow-engine/redact.d.ts +3 -0
- package/flow-engine/ssrf-guard.d.ts +6 -0
- package/guards/flow-access.guard.d.ts +11 -0
- package/guards/index.d.ts +1 -0
- package/index.d.ts +11 -0
- package/interfaces/entity-builder-module.interface.d.ts +28 -0
- package/interfaces/field-definition.interface.d.ts +33 -0
- package/interfaces/flow-definition.interface.d.ts +24 -0
- package/interfaces/generic-record.interface.d.ts +15 -0
- package/interfaces/index.d.ts +5 -0
- package/interfaces/reference-provider.interface.d.ts +8 -0
- package/interfaces/schema-dialect-adapter.interface.d.ts +15 -0
- package/modules/entity-builder.module.d.ts +10 -0
- package/modules/index.d.ts +1 -0
- package/package.json +93 -0
- package/rule-engine/index.d.ts +3 -0
- package/rule-engine/rule-engine.service.d.ts +40 -0
- package/rule-engine/rule-evaluation-context.interface.d.ts +28 -0
- package/rule-engine/rule-ip.d.ts +3 -0
- package/rule-engine/rule-permission.d.ts +10 -0
- package/rule-engine/rule-regex.d.ts +4 -0
- package/rule-engine/rule-values.d.ts +5 -0
- package/rule-engine/rule.interface.d.ts +79 -0
- package/services/database-error.mapper.d.ts +2 -0
- package/services/definition-cache.service.d.ts +8 -0
- package/services/entity-builder-config.service.d.ts +12 -0
- package/services/entity-builder-datasource.provider.d.ts +24 -0
- package/services/entity-definition.service.d.ts +17 -0
- package/services/entity-flow-scaffold.d.ts +27 -0
- package/services/entity-permission.service.d.ts +8 -0
- package/services/field-definition.service.d.ts +17 -0
- package/services/field-type-conversion.d.ts +15 -0
- package/services/field-value-validator.d.ts +17 -0
- package/services/flow-definition.service.d.ts +62 -0
- package/services/flow-execution.service.d.ts +38 -0
- package/services/flow-executor.service.d.ts +41 -0
- package/services/flow-reference.provider.d.ts +13 -0
- package/services/flow-runtime.service.d.ts +30 -0
- package/services/generic-entity-service.factory.d.ts +12 -0
- package/services/generic-entity.service.d.ts +67 -0
- package/services/identifier-rules.d.ts +9 -0
- package/services/index.d.ts +26 -0
- package/services/reference-rewrite.d.ts +7 -0
- package/services/reference-scanner.service.d.ts +10 -0
- package/services/schema-change-executor.service.d.ts +39 -0
- package/services/schema-change.types.d.ts +59 -0
- package/services/schema-columns.d.ts +26 -0
- package/services/schema-dialect-adapter.service.d.ts +13 -0
- package/services/schema-evolution.service.d.ts +67 -0
- package/services/schema-registry.service.d.ts +13 -0
- package/services/schema-sync.service.d.ts +28 -0
package/fesm/913.js
ADDED
|
@@ -0,0 +1,1620 @@
|
|
|
1
|
+
import { lastValueFrom } from "rxjs";
|
|
2
|
+
import * as __rspack_external__flusys_nestjs_shared_guards_3f79ddd1 from "@flusys/nestjs-shared/guards";
|
|
3
|
+
import * as __rspack_external__flusys_nestjs_shared_decorators_c129b601 from "@flusys/nestjs-shared/decorators";
|
|
4
|
+
export const __rspack_esm_id = 913;
|
|
5
|
+
export const __rspack_esm_ids = [913];
|
|
6
|
+
export const __webpack_modules__ = {
|
|
7
|
+
6384(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
8
|
+
|
|
9
|
+
// EXPORTS
|
|
10
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
11
|
+
hv: () => (/* reexport */ EntityDefinitionController),
|
|
12
|
+
GX: () => (/* reexport */ FieldDefinitionController),
|
|
13
|
+
W8: () => (/* reexport */ FlowDefinitionController),
|
|
14
|
+
VU: () => (/* reexport */ FlowExecutionController),
|
|
15
|
+
bw: () => (/* reexport */ FlowRuntimeController)
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared"
|
|
19
|
+
var nestjs_shared_ = __webpack_require__(3422);
|
|
20
|
+
// EXTERNAL MODULE: external "@nestjs/common"
|
|
21
|
+
var common_ = __webpack_require__(6157);
|
|
22
|
+
// EXTERNAL MODULE: external "@nestjs/swagger"
|
|
23
|
+
var swagger_ = __webpack_require__(6176);
|
|
24
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared/guards"
|
|
25
|
+
var guards_ = __webpack_require__(3513);
|
|
26
|
+
;// CONCATENATED MODULE: external "@flusys/nestjs-shared/decorators"
|
|
27
|
+
|
|
28
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared/modules"
|
|
29
|
+
var modules_ = __webpack_require__(1236);
|
|
30
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/config/message-keys.ts
|
|
31
|
+
var message_keys = __webpack_require__(5732);
|
|
32
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/dtos/entity-definition.dto.ts
|
|
33
|
+
var entity_definition_dto = __webpack_require__(680);
|
|
34
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/dtos/schema-change.dto.ts
|
|
35
|
+
var schema_change_dto = __webpack_require__(4945);
|
|
36
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/schema-evolution.service.ts
|
|
37
|
+
var schema_evolution_service = __webpack_require__(3606);
|
|
38
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/entity-definition.service.ts
|
|
39
|
+
var entity_definition_service = __webpack_require__(1296);
|
|
40
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/schema-sync.service.ts
|
|
41
|
+
var schema_sync_service = __webpack_require__(3474);
|
|
42
|
+
;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/controllers/entity-definition.controller.ts
|
|
43
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
44
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
45
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
46
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
47
|
+
} else {
|
|
48
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
49
|
+
if (d = decorators[i]) {
|
|
50
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
55
|
+
}
|
|
56
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
57
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
58
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function _ts_param(paramIndex, decorator) {
|
|
62
|
+
return function(target, key) {
|
|
63
|
+
decorator(target, key, paramIndex);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class EntityDefinitionController extends (0,nestjs_shared_.createApiController)(entity_definition_dto/* .CreateDynamicEntityDto */.Ot, entity_definition_dto/* .UpdateEntityDefinitionDto */.hL, entity_definition_dto/* .EntityDefinitionResponseDto */.d_, {
|
|
79
|
+
entityName: 'entity_builder.entity_definition',
|
|
80
|
+
enabledEndpoints: [
|
|
81
|
+
'getById',
|
|
82
|
+
'getByIds',
|
|
83
|
+
'getAll',
|
|
84
|
+
'getByFilter'
|
|
85
|
+
],
|
|
86
|
+
security: {
|
|
87
|
+
getById: {
|
|
88
|
+
level: 'permission',
|
|
89
|
+
permissions: [
|
|
90
|
+
nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.READ
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
getByIds: {
|
|
94
|
+
level: 'permission',
|
|
95
|
+
permissions: [
|
|
96
|
+
nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.READ
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
getAll: {
|
|
100
|
+
level: 'permission',
|
|
101
|
+
permissions: [
|
|
102
|
+
nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.READ
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
getByFilter: {
|
|
106
|
+
level: 'permission',
|
|
107
|
+
permissions: [
|
|
108
|
+
nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.READ
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}) {
|
|
113
|
+
entityDefinitionService;
|
|
114
|
+
schemaSyncService;
|
|
115
|
+
evolution;
|
|
116
|
+
permissionCache;
|
|
117
|
+
constructor(entityDefinitionService, schemaSyncService, evolution, permissionCache){
|
|
118
|
+
super(entityDefinitionService), this.entityDefinitionService = entityDefinitionService, this.schemaSyncService = schemaSyncService, this.evolution = evolution, this.permissionCache = permissionCache;
|
|
119
|
+
}
|
|
120
|
+
async createEntity(dto, user) {
|
|
121
|
+
const { definition, warnings } = await this.schemaSyncService.createEntity(dto, user);
|
|
122
|
+
return {
|
|
123
|
+
...this.ok(definition, 'Entity created successfully', message_keys/* .ENTITY_DEFINITION_MESSAGES.CREATE_SUCCESS */.pL.CREATE_SUCCESS),
|
|
124
|
+
warnings
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
async planCreateEntity(dto, user) {
|
|
128
|
+
return this.ok(await this.schemaSyncService.planCreateEntity(dto, user), 'Plan generated', message_keys/* .ENTITY_DEFINITION_MESSAGES.PLAN_SUCCESS */.pL.PLAN_SUCCESS);
|
|
129
|
+
}
|
|
130
|
+
async planChange(dto, user) {
|
|
131
|
+
// A plan counts records, so only someone who could apply the change may see it.
|
|
132
|
+
await this.permissionCache.assertPermission(user, (0,schema_evolution_service/* .isDestructiveSchemaAction */.C)(dto.action) ? nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.DELETE : nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.UPDATE);
|
|
133
|
+
return this.ok(await this.evolution.plan(dto, user), 'Plan generated', message_keys/* .ENTITY_DEFINITION_MESSAGES.PLAN_SUCCESS */.pL.PLAN_SUCCESS);
|
|
134
|
+
}
|
|
135
|
+
async applyChange(dto, user) {
|
|
136
|
+
if ((0,schema_evolution_service/* .isDestructiveSchemaAction */.C)(dto.action)) {
|
|
137
|
+
throw new common_.BadRequestException({
|
|
138
|
+
message: `'${dto.action}' deletes data permanently - use apply-destructive-change.`,
|
|
139
|
+
messageKey: message_keys/* .SCHEMA_MESSAGES.USE_DESTRUCTIVE_ENDPOINT */.Hu.USE_DESTRUCTIVE_ENDPOINT,
|
|
140
|
+
messageVariables: {
|
|
141
|
+
action: dto.action
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return this.ok(await this.evolution.apply(dto, user), 'Change applied', message_keys/* .ENTITY_DEFINITION_MESSAGES.APPLY_SUCCESS */.pL.APPLY_SUCCESS);
|
|
146
|
+
}
|
|
147
|
+
async applyDestructiveChange(dto, user) {
|
|
148
|
+
if (!(0,schema_evolution_service/* .isDestructiveSchemaAction */.C)(dto.action)) {
|
|
149
|
+
throw new common_.BadRequestException({
|
|
150
|
+
message: "Only 'drop_entity' and 'purge_field' are applied here - use apply-change for the rest.",
|
|
151
|
+
messageKey: message_keys/* .SCHEMA_MESSAGES.USE_REGULAR_ENDPOINT */.Hu.USE_REGULAR_ENDPOINT
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return this.ok(await this.evolution.apply(dto, user), 'Change applied', message_keys/* .ENTITY_DEFINITION_MESSAGES.APPLY_SUCCESS */.pL.APPLY_SUCCESS);
|
|
155
|
+
}
|
|
156
|
+
async inspect(dto) {
|
|
157
|
+
return this.ok(await this.evolution.inspect(dto.entityDefinitionId), 'Schema checked', message_keys/* .ENTITY_DEFINITION_MESSAGES.INSPECT_SUCCESS */.pL.INSPECT_SUCCESS);
|
|
158
|
+
}
|
|
159
|
+
async history(dto) {
|
|
160
|
+
return this.ok(await this.evolution.history(dto.entityDefinitionId), 'History loaded', message_keys/* .ENTITY_DEFINITION_MESSAGES.HISTORY_SUCCESS */.pL.HISTORY_SUCCESS);
|
|
161
|
+
}
|
|
162
|
+
ok(data, message, messageKey) {
|
|
163
|
+
return {
|
|
164
|
+
success: true,
|
|
165
|
+
message,
|
|
166
|
+
messageKey,
|
|
167
|
+
data
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
_ts_decorate([
|
|
172
|
+
(0,common_.Post)('create-entity'),
|
|
173
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
174
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.CREATE),
|
|
175
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
176
|
+
(0,swagger_.ApiOperation)({
|
|
177
|
+
summary: 'Create a dynamic entity',
|
|
178
|
+
description: 'Creates an EntityDefinition row and its real database table (plus any initial fields) in one DDL transaction.'
|
|
179
|
+
}),
|
|
180
|
+
(0,swagger_.ApiBody)({
|
|
181
|
+
type: entity_definition_dto/* .CreateDynamicEntityDto */.Ot
|
|
182
|
+
}),
|
|
183
|
+
(0,swagger_.ApiResponse)({
|
|
184
|
+
status: 201,
|
|
185
|
+
type: nestjs_shared_.SingleResponseDto,
|
|
186
|
+
description: '`warnings`: follow-up steps that failed after the entity was created (permissions, endpoint flows)'
|
|
187
|
+
}),
|
|
188
|
+
_ts_param(0, (0,common_.Body)()),
|
|
189
|
+
_ts_param(1, (0,nestjs_shared_.CurrentUser)()),
|
|
190
|
+
_ts_metadata("design:type", Function),
|
|
191
|
+
_ts_metadata("design:paramtypes", [
|
|
192
|
+
typeof entity_definition_dto/* .CreateDynamicEntityDto */.Ot === "undefined" ? Object : entity_definition_dto/* .CreateDynamicEntityDto */.Ot,
|
|
193
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
194
|
+
]),
|
|
195
|
+
_ts_metadata("design:returntype", Promise)
|
|
196
|
+
], EntityDefinitionController.prototype, "createEntity", null);
|
|
197
|
+
_ts_decorate([
|
|
198
|
+
(0,common_.Post)('plan-create-entity'),
|
|
199
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
200
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.CREATE),
|
|
201
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
202
|
+
(0,swagger_.ApiOperation)({
|
|
203
|
+
summary: 'Preview creating an entity: the real CREATE TABLE SQL, nothing is created'
|
|
204
|
+
}),
|
|
205
|
+
(0,swagger_.ApiBody)({
|
|
206
|
+
type: entity_definition_dto/* .CreateDynamicEntityDto */.Ot
|
|
207
|
+
}),
|
|
208
|
+
_ts_param(0, (0,common_.Body)()),
|
|
209
|
+
_ts_param(1, (0,nestjs_shared_.CurrentUser)()),
|
|
210
|
+
_ts_metadata("design:type", Function),
|
|
211
|
+
_ts_metadata("design:paramtypes", [
|
|
212
|
+
typeof entity_definition_dto/* .CreateDynamicEntityDto */.Ot === "undefined" ? Object : entity_definition_dto/* .CreateDynamicEntityDto */.Ot,
|
|
213
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
214
|
+
]),
|
|
215
|
+
_ts_metadata("design:returntype", Promise)
|
|
216
|
+
], EntityDefinitionController.prototype, "planCreateEntity", null);
|
|
217
|
+
_ts_decorate([
|
|
218
|
+
(0,common_.Post)('plan-change'),
|
|
219
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
220
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequireAnyPermission)(nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.UPDATE, nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.DELETE),
|
|
221
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
222
|
+
(0,swagger_.ApiOperation)({
|
|
223
|
+
summary: 'Preview a structural change',
|
|
224
|
+
description: 'Dry run: returns the exact SQL (and its reverse), data checks, blockers, warnings and the flows that would be affected. Nothing changes. The plan counts records, so it needs the permission that applies the change: entity_definition.delete for drop_entity / purge_field, entity_definition.update for the rest. It never contains record values.'
|
|
225
|
+
}),
|
|
226
|
+
(0,swagger_.ApiBody)({
|
|
227
|
+
type: schema_change_dto/* .SchemaChangeRequestDto */.ym
|
|
228
|
+
}),
|
|
229
|
+
_ts_param(0, (0,common_.Body)()),
|
|
230
|
+
_ts_param(1, (0,nestjs_shared_.CurrentUser)()),
|
|
231
|
+
_ts_metadata("design:type", Function),
|
|
232
|
+
_ts_metadata("design:paramtypes", [
|
|
233
|
+
typeof schema_change_dto/* .SchemaChangeRequestDto */.ym === "undefined" ? Object : schema_change_dto/* .SchemaChangeRequestDto */.ym,
|
|
234
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
235
|
+
]),
|
|
236
|
+
_ts_metadata("design:returntype", Promise)
|
|
237
|
+
], EntityDefinitionController.prototype, "planChange", null);
|
|
238
|
+
_ts_decorate([
|
|
239
|
+
(0,common_.Post)('apply-change'),
|
|
240
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
241
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.UPDATE),
|
|
242
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
243
|
+
(0,swagger_.ApiOperation)({
|
|
244
|
+
summary: 'Apply a structural change',
|
|
245
|
+
description: 'Add / edit / rename / restore / deprecate a field, change entity settings, or repair drift - in one locked transaction, with the SQL logged. Dropping data uses apply-destructive-change.'
|
|
246
|
+
}),
|
|
247
|
+
(0,swagger_.ApiBody)({
|
|
248
|
+
type: schema_change_dto/* .SchemaChangeRequestDto */.ym
|
|
249
|
+
}),
|
|
250
|
+
_ts_param(0, (0,common_.Body)()),
|
|
251
|
+
_ts_param(1, (0,nestjs_shared_.CurrentUser)()),
|
|
252
|
+
_ts_metadata("design:type", Function),
|
|
253
|
+
_ts_metadata("design:paramtypes", [
|
|
254
|
+
typeof schema_change_dto/* .SchemaChangeRequestDto */.ym === "undefined" ? Object : schema_change_dto/* .SchemaChangeRequestDto */.ym,
|
|
255
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
256
|
+
]),
|
|
257
|
+
_ts_metadata("design:returntype", Promise)
|
|
258
|
+
], EntityDefinitionController.prototype, "applyChange", null);
|
|
259
|
+
_ts_decorate([
|
|
260
|
+
(0,common_.Post)('apply-destructive-change'),
|
|
261
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
262
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.DELETE),
|
|
263
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
264
|
+
(0,swagger_.ApiOperation)({
|
|
265
|
+
summary: 'Permanently delete a field (purge_field) or an entity (drop_entity)'
|
|
266
|
+
}),
|
|
267
|
+
(0,swagger_.ApiBody)({
|
|
268
|
+
type: schema_change_dto/* .SchemaChangeRequestDto */.ym
|
|
269
|
+
}),
|
|
270
|
+
_ts_param(0, (0,common_.Body)()),
|
|
271
|
+
_ts_param(1, (0,nestjs_shared_.CurrentUser)()),
|
|
272
|
+
_ts_metadata("design:type", Function),
|
|
273
|
+
_ts_metadata("design:paramtypes", [
|
|
274
|
+
typeof schema_change_dto/* .SchemaChangeRequestDto */.ym === "undefined" ? Object : schema_change_dto/* .SchemaChangeRequestDto */.ym,
|
|
275
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
276
|
+
]),
|
|
277
|
+
_ts_metadata("design:returntype", Promise)
|
|
278
|
+
], EntityDefinitionController.prototype, "applyDestructiveChange", null);
|
|
279
|
+
_ts_decorate([
|
|
280
|
+
(0,common_.Post)('inspect'),
|
|
281
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
282
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.READ),
|
|
283
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
284
|
+
(0,swagger_.ApiOperation)({
|
|
285
|
+
summary: 'Compare an entity definition with its real table (drift check)'
|
|
286
|
+
}),
|
|
287
|
+
(0,swagger_.ApiBody)({
|
|
288
|
+
type: schema_change_dto/* .SchemaCheckRequestDto */.ct
|
|
289
|
+
}),
|
|
290
|
+
_ts_param(0, (0,common_.Body)()),
|
|
291
|
+
_ts_metadata("design:type", Function),
|
|
292
|
+
_ts_metadata("design:paramtypes", [
|
|
293
|
+
typeof schema_change_dto/* .SchemaCheckRequestDto */.ct === "undefined" ? Object : schema_change_dto/* .SchemaCheckRequestDto */.ct
|
|
294
|
+
]),
|
|
295
|
+
_ts_metadata("design:returntype", Promise)
|
|
296
|
+
], EntityDefinitionController.prototype, "inspect", null);
|
|
297
|
+
_ts_decorate([
|
|
298
|
+
(0,common_.Post)('schema-history'),
|
|
299
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
300
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(nestjs_shared_.ENTITY_DEFINITION_PERMISSIONS.READ),
|
|
301
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
302
|
+
(0,swagger_.ApiOperation)({
|
|
303
|
+
summary: 'Schema change history of an entity (with the SQL of each change)'
|
|
304
|
+
}),
|
|
305
|
+
(0,swagger_.ApiBody)({
|
|
306
|
+
type: schema_change_dto/* .SchemaCheckRequestDto */.ct
|
|
307
|
+
}),
|
|
308
|
+
_ts_param(0, (0,common_.Body)()),
|
|
309
|
+
_ts_metadata("design:type", Function),
|
|
310
|
+
_ts_metadata("design:paramtypes", [
|
|
311
|
+
typeof schema_change_dto/* .SchemaCheckRequestDto */.ct === "undefined" ? Object : schema_change_dto/* .SchemaCheckRequestDto */.ct
|
|
312
|
+
]),
|
|
313
|
+
_ts_metadata("design:returntype", Promise)
|
|
314
|
+
], EntityDefinitionController.prototype, "history", null);
|
|
315
|
+
EntityDefinitionController = _ts_decorate([
|
|
316
|
+
(0,swagger_.ApiTags)('Entity Builder - Entity Definitions'),
|
|
317
|
+
(0,common_.Controller)('entity-builder/entity-definitions'),
|
|
318
|
+
_ts_param(0, (0,common_.Inject)(entity_definition_service/* .EntityDefinitionService */.o)),
|
|
319
|
+
_ts_param(1, (0,common_.Inject)(schema_sync_service/* .SchemaSyncService */.W)),
|
|
320
|
+
_ts_param(2, (0,common_.Inject)(schema_evolution_service/* .SchemaEvolutionService */._)),
|
|
321
|
+
_ts_param(3, (0,common_.Inject)(modules_.SharedPermissionCacheService)),
|
|
322
|
+
_ts_metadata("design:type", Function),
|
|
323
|
+
_ts_metadata("design:paramtypes", [
|
|
324
|
+
typeof entity_definition_service/* .EntityDefinitionService */.o === "undefined" ? Object : entity_definition_service/* .EntityDefinitionService */.o,
|
|
325
|
+
typeof schema_sync_service/* .SchemaSyncService */.W === "undefined" ? Object : schema_sync_service/* .SchemaSyncService */.W,
|
|
326
|
+
typeof schema_evolution_service/* .SchemaEvolutionService */._ === "undefined" ? Object : schema_evolution_service/* .SchemaEvolutionService */._,
|
|
327
|
+
typeof modules_.SharedPermissionCacheService === "undefined" ? Object : modules_.SharedPermissionCacheService
|
|
328
|
+
])
|
|
329
|
+
], EntityDefinitionController);
|
|
330
|
+
|
|
331
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/dtos/field-definition.dto.ts
|
|
332
|
+
var field_definition_dto = __webpack_require__(2003);
|
|
333
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/field-definition.service.ts
|
|
334
|
+
var field_definition_service = __webpack_require__(9487);
|
|
335
|
+
;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/controllers/field-definition.controller.ts
|
|
336
|
+
function field_definition_controller_ts_decorate(decorators, target, key, desc) {
|
|
337
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
338
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
339
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
340
|
+
} else {
|
|
341
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
342
|
+
if (d = decorators[i]) {
|
|
343
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
348
|
+
}
|
|
349
|
+
function field_definition_controller_ts_metadata(metadataKey, metadataValue) {
|
|
350
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
351
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function field_definition_controller_ts_param(paramIndex, decorator) {
|
|
355
|
+
return function(target, key) {
|
|
356
|
+
decorator(target, key, paramIndex);
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
class FieldDefinitionController extends (0,nestjs_shared_.createApiController)(field_definition_dto/* .CreateFieldDefinitionDto */.Vj, field_definition_dto/* .UpdateFieldDefinitionDto */.C3, field_definition_dto/* .FieldDefinitionResponseDto */.C5, {
|
|
365
|
+
entityName: 'entity_builder.field_definition',
|
|
366
|
+
enabledEndpoints: [
|
|
367
|
+
'getById',
|
|
368
|
+
'getByIds',
|
|
369
|
+
'getAll',
|
|
370
|
+
'getByFilter'
|
|
371
|
+
],
|
|
372
|
+
security: {
|
|
373
|
+
getById: {
|
|
374
|
+
level: 'permission',
|
|
375
|
+
permissions: [
|
|
376
|
+
nestjs_shared_.FIELD_DEFINITION_PERMISSIONS.READ
|
|
377
|
+
]
|
|
378
|
+
},
|
|
379
|
+
getByIds: {
|
|
380
|
+
level: 'permission',
|
|
381
|
+
permissions: [
|
|
382
|
+
nestjs_shared_.FIELD_DEFINITION_PERMISSIONS.READ
|
|
383
|
+
]
|
|
384
|
+
},
|
|
385
|
+
getAll: {
|
|
386
|
+
level: 'permission',
|
|
387
|
+
permissions: [
|
|
388
|
+
nestjs_shared_.FIELD_DEFINITION_PERMISSIONS.READ
|
|
389
|
+
]
|
|
390
|
+
},
|
|
391
|
+
getByFilter: {
|
|
392
|
+
level: 'permission',
|
|
393
|
+
permissions: [
|
|
394
|
+
nestjs_shared_.FIELD_DEFINITION_PERMISSIONS.READ
|
|
395
|
+
]
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}) {
|
|
399
|
+
fieldDefinitionService;
|
|
400
|
+
constructor(fieldDefinitionService){
|
|
401
|
+
super(fieldDefinitionService), this.fieldDefinitionService = fieldDefinitionService;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
FieldDefinitionController = field_definition_controller_ts_decorate([
|
|
405
|
+
(0,swagger_.ApiTags)('Entity Builder - Field Definitions'),
|
|
406
|
+
(0,common_.Controller)('entity-builder/field-definitions'),
|
|
407
|
+
field_definition_controller_ts_param(0, (0,common_.Inject)(field_definition_service/* .FieldDefinitionService */.J)),
|
|
408
|
+
field_definition_controller_ts_metadata("design:type", Function),
|
|
409
|
+
field_definition_controller_ts_metadata("design:paramtypes", [
|
|
410
|
+
typeof field_definition_service/* .FieldDefinitionService */.J === "undefined" ? Object : field_definition_service/* .FieldDefinitionService */.J
|
|
411
|
+
])
|
|
412
|
+
], FieldDefinitionController);
|
|
413
|
+
|
|
414
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared/dtos"
|
|
415
|
+
var dtos_ = __webpack_require__(6873);
|
|
416
|
+
// EXTERNAL MODULE: external "class-transformer"
|
|
417
|
+
var external_class_transformer_ = __webpack_require__(5812);
|
|
418
|
+
// EXTERNAL MODULE: external "class-validator"
|
|
419
|
+
var external_class_validator_ = __webpack_require__(5421);
|
|
420
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/flow-engine/flow.types.ts
|
|
421
|
+
var flow_types = __webpack_require__(6256);
|
|
422
|
+
;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/dtos/flow.dto.ts
|
|
423
|
+
function flow_dto_ts_decorate(decorators, target, key, desc) {
|
|
424
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
425
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
426
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
427
|
+
} else {
|
|
428
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
429
|
+
if (d = decorators[i]) {
|
|
430
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
435
|
+
}
|
|
436
|
+
function flow_dto_ts_metadata(metadataKey, metadataValue) {
|
|
437
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
438
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
class CreateFlowDefinitionDto {
|
|
447
|
+
name;
|
|
448
|
+
slug;
|
|
449
|
+
description;
|
|
450
|
+
isActive;
|
|
451
|
+
retainExecutions;
|
|
452
|
+
nodes;
|
|
453
|
+
edges;
|
|
454
|
+
}
|
|
455
|
+
flow_dto_ts_decorate([
|
|
456
|
+
(0,swagger_.ApiProperty)({
|
|
457
|
+
example: 'Create order'
|
|
458
|
+
}),
|
|
459
|
+
(0,external_class_validator_.IsString)(),
|
|
460
|
+
(0,external_class_validator_.IsNotEmpty)(),
|
|
461
|
+
(0,external_class_validator_.MaxLength)(255),
|
|
462
|
+
flow_dto_ts_metadata("design:type", String)
|
|
463
|
+
], CreateFlowDefinitionDto.prototype, "name", void 0);
|
|
464
|
+
flow_dto_ts_decorate([
|
|
465
|
+
(0,swagger_.ApiProperty)({
|
|
466
|
+
description: 'URL name: POST api-flows/<slug> (and api-flows/<slug>/<path> for each Request step with a path)',
|
|
467
|
+
example: 'create-order'
|
|
468
|
+
}),
|
|
469
|
+
(0,external_class_validator_.IsString)(),
|
|
470
|
+
(0,external_class_validator_.Matches)(flow_types/* .FLOW_SLUG_PATTERN */.YD, {
|
|
471
|
+
message: 'slug must be 3-63 characters: lowercase letters, digits and dashes, starting with a letter'
|
|
472
|
+
}),
|
|
473
|
+
flow_dto_ts_metadata("design:type", String)
|
|
474
|
+
], CreateFlowDefinitionDto.prototype, "slug", void 0);
|
|
475
|
+
flow_dto_ts_decorate([
|
|
476
|
+
(0,swagger_.ApiPropertyOptional)(),
|
|
477
|
+
(0,external_class_validator_.IsString)(),
|
|
478
|
+
(0,external_class_validator_.IsOptional)(),
|
|
479
|
+
(0,external_class_validator_.MaxLength)(500),
|
|
480
|
+
flow_dto_ts_metadata("design:type", String)
|
|
481
|
+
], CreateFlowDefinitionDto.prototype, "description", void 0);
|
|
482
|
+
flow_dto_ts_decorate([
|
|
483
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
484
|
+
default: true
|
|
485
|
+
}),
|
|
486
|
+
(0,external_class_validator_.IsBoolean)(),
|
|
487
|
+
(0,external_class_validator_.IsOptional)(),
|
|
488
|
+
flow_dto_ts_metadata("design:type", Boolean)
|
|
489
|
+
], CreateFlowDefinitionDto.prototype, "isActive", void 0);
|
|
490
|
+
flow_dto_ts_decorate([
|
|
491
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
492
|
+
default: 200
|
|
493
|
+
}),
|
|
494
|
+
(0,external_class_validator_.IsInt)(),
|
|
495
|
+
(0,external_class_validator_.Min)(0),
|
|
496
|
+
(0,external_class_validator_.Max)(10000),
|
|
497
|
+
(0,external_class_validator_.IsOptional)(),
|
|
498
|
+
flow_dto_ts_metadata("design:type", Number)
|
|
499
|
+
], CreateFlowDefinitionDto.prototype, "retainExecutions", void 0);
|
|
500
|
+
flow_dto_ts_decorate([
|
|
501
|
+
(0,swagger_.ApiProperty)({
|
|
502
|
+
type: [
|
|
503
|
+
Object
|
|
504
|
+
],
|
|
505
|
+
description: 'Steps; each Request step (trigger) carries its own path, body (bodyType, inputSchema), access (authMode: signed-in by default, permissionCode), runAs (caller by default), isTransactional, timeoutMs and rateLimitPerMinute'
|
|
506
|
+
}),
|
|
507
|
+
(0,external_class_validator_.IsArray)(),
|
|
508
|
+
flow_dto_ts_metadata("design:type", Array)
|
|
509
|
+
], CreateFlowDefinitionDto.prototype, "nodes", void 0);
|
|
510
|
+
flow_dto_ts_decorate([
|
|
511
|
+
(0,swagger_.ApiProperty)({
|
|
512
|
+
type: [
|
|
513
|
+
Object
|
|
514
|
+
]
|
|
515
|
+
}),
|
|
516
|
+
(0,external_class_validator_.IsArray)(),
|
|
517
|
+
flow_dto_ts_metadata("design:type", Array)
|
|
518
|
+
], CreateFlowDefinitionDto.prototype, "edges", void 0);
|
|
519
|
+
class UpdateFlowDefinitionDto extends (0,swagger_.PartialType)(CreateFlowDefinitionDto) {
|
|
520
|
+
id;
|
|
521
|
+
}
|
|
522
|
+
flow_dto_ts_decorate([
|
|
523
|
+
(0,swagger_.ApiProperty)(),
|
|
524
|
+
(0,external_class_validator_.IsUUID)(),
|
|
525
|
+
(0,external_class_validator_.IsNotEmpty)(),
|
|
526
|
+
flow_dto_ts_metadata("design:type", String)
|
|
527
|
+
], UpdateFlowDefinitionDto.prototype, "id", void 0);
|
|
528
|
+
/**
|
|
529
|
+
* A flow as the designer holds it, for a test run or a check: every setting is validated like a
|
|
530
|
+
* saved flow's (the graph, with each Request step's access, run-as and limits, by `validateFlow`),
|
|
531
|
+
* the name may still be empty, and the server-owned fields of a loaded flow are ignored.
|
|
532
|
+
*/ class FlowDraftDto extends (0,swagger_.OmitType)(CreateFlowDefinitionDto, [
|
|
533
|
+
'name'
|
|
534
|
+
]) {
|
|
535
|
+
name;
|
|
536
|
+
id;
|
|
537
|
+
version;
|
|
538
|
+
draft;
|
|
539
|
+
createdAt;
|
|
540
|
+
updatedAt;
|
|
541
|
+
deletedAt;
|
|
542
|
+
createdById;
|
|
543
|
+
updatedById;
|
|
544
|
+
deletedById;
|
|
545
|
+
}
|
|
546
|
+
flow_dto_ts_decorate([
|
|
547
|
+
(0,swagger_.ApiPropertyOptional)(),
|
|
548
|
+
(0,external_class_validator_.IsString)(),
|
|
549
|
+
(0,external_class_validator_.IsOptional)(),
|
|
550
|
+
(0,external_class_validator_.MaxLength)(255),
|
|
551
|
+
flow_dto_ts_metadata("design:type", String)
|
|
552
|
+
], FlowDraftDto.prototype, "name", void 0);
|
|
553
|
+
flow_dto_ts_decorate([
|
|
554
|
+
(0,swagger_.ApiPropertyOptional)(),
|
|
555
|
+
(0,external_class_validator_.IsUUID)(),
|
|
556
|
+
(0,external_class_validator_.IsOptional)(),
|
|
557
|
+
flow_dto_ts_metadata("design:type", String)
|
|
558
|
+
], FlowDraftDto.prototype, "id", void 0);
|
|
559
|
+
flow_dto_ts_decorate([
|
|
560
|
+
(0,external_class_validator_.Allow)(),
|
|
561
|
+
flow_dto_ts_metadata("design:type", Object)
|
|
562
|
+
], FlowDraftDto.prototype, "version", void 0);
|
|
563
|
+
flow_dto_ts_decorate([
|
|
564
|
+
(0,external_class_validator_.Allow)(),
|
|
565
|
+
flow_dto_ts_metadata("design:type", Object)
|
|
566
|
+
], FlowDraftDto.prototype, "draft", void 0);
|
|
567
|
+
flow_dto_ts_decorate([
|
|
568
|
+
(0,external_class_validator_.Allow)(),
|
|
569
|
+
flow_dto_ts_metadata("design:type", Object)
|
|
570
|
+
], FlowDraftDto.prototype, "createdAt", void 0);
|
|
571
|
+
flow_dto_ts_decorate([
|
|
572
|
+
(0,external_class_validator_.Allow)(),
|
|
573
|
+
flow_dto_ts_metadata("design:type", Object)
|
|
574
|
+
], FlowDraftDto.prototype, "updatedAt", void 0);
|
|
575
|
+
flow_dto_ts_decorate([
|
|
576
|
+
(0,external_class_validator_.Allow)(),
|
|
577
|
+
flow_dto_ts_metadata("design:type", Object)
|
|
578
|
+
], FlowDraftDto.prototype, "deletedAt", void 0);
|
|
579
|
+
flow_dto_ts_decorate([
|
|
580
|
+
(0,external_class_validator_.Allow)(),
|
|
581
|
+
flow_dto_ts_metadata("design:type", Object)
|
|
582
|
+
], FlowDraftDto.prototype, "createdById", void 0);
|
|
583
|
+
flow_dto_ts_decorate([
|
|
584
|
+
(0,external_class_validator_.Allow)(),
|
|
585
|
+
flow_dto_ts_metadata("design:type", Object)
|
|
586
|
+
], FlowDraftDto.prototype, "updatedById", void 0);
|
|
587
|
+
flow_dto_ts_decorate([
|
|
588
|
+
(0,external_class_validator_.Allow)(),
|
|
589
|
+
flow_dto_ts_metadata("design:type", Object)
|
|
590
|
+
], FlowDraftDto.prototype, "deletedById", void 0);
|
|
591
|
+
/** What a test run pretends the caller sent. */ class TestFlowRequestDto {
|
|
592
|
+
headers;
|
|
593
|
+
query;
|
|
594
|
+
ip;
|
|
595
|
+
}
|
|
596
|
+
flow_dto_ts_decorate([
|
|
597
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
598
|
+
description: 'Headers to pretend the caller sent (credential headers are still hidden from the flow)'
|
|
599
|
+
}),
|
|
600
|
+
(0,external_class_validator_.IsObject)(),
|
|
601
|
+
(0,external_class_validator_.IsOptional)(),
|
|
602
|
+
flow_dto_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
603
|
+
], TestFlowRequestDto.prototype, "headers", void 0);
|
|
604
|
+
flow_dto_ts_decorate([
|
|
605
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
606
|
+
description: 'Query parameters to pretend the caller sent'
|
|
607
|
+
}),
|
|
608
|
+
(0,external_class_validator_.IsObject)(),
|
|
609
|
+
(0,external_class_validator_.IsOptional)(),
|
|
610
|
+
flow_dto_ts_metadata("design:type", typeof Record === "undefined" ? Object : Record)
|
|
611
|
+
], TestFlowRequestDto.prototype, "query", void 0);
|
|
612
|
+
flow_dto_ts_decorate([
|
|
613
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
614
|
+
description: 'Caller IP address to pretend'
|
|
615
|
+
}),
|
|
616
|
+
(0,external_class_validator_.IsIP)(),
|
|
617
|
+
(0,external_class_validator_.IsOptional)(),
|
|
618
|
+
flow_dto_ts_metadata("design:type", String)
|
|
619
|
+
], TestFlowRequestDto.prototype, "ip", void 0);
|
|
620
|
+
/** Runs a flow from the designer: a saved flow (flowId), an unsaved draft (definition), or both - flowId attributes/scopes the run while definition (the current draft, if sent) is what actually executes. */ class TestFlowDto {
|
|
621
|
+
flowId;
|
|
622
|
+
definition;
|
|
623
|
+
endpoint;
|
|
624
|
+
input;
|
|
625
|
+
mode;
|
|
626
|
+
request;
|
|
627
|
+
}
|
|
628
|
+
flow_dto_ts_decorate([
|
|
629
|
+
(0,swagger_.ApiPropertyOptional)(),
|
|
630
|
+
(0,external_class_validator_.IsUUID)(),
|
|
631
|
+
(0,external_class_validator_.IsOptional)(),
|
|
632
|
+
flow_dto_ts_metadata("design:type", String)
|
|
633
|
+
], TestFlowDto.prototype, "flowId", void 0);
|
|
634
|
+
flow_dto_ts_decorate([
|
|
635
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
636
|
+
type: FlowDraftDto
|
|
637
|
+
}),
|
|
638
|
+
(0,external_class_validator_.IsObject)(),
|
|
639
|
+
(0,external_class_validator_.ValidateNested)(),
|
|
640
|
+
(0,external_class_transformer_.Type)(()=>FlowDraftDto),
|
|
641
|
+
(0,external_class_validator_.IsOptional)(),
|
|
642
|
+
flow_dto_ts_metadata("design:type", typeof FlowDraftDto === "undefined" ? Object : FlowDraftDto)
|
|
643
|
+
], TestFlowDto.prototype, "definition", void 0);
|
|
644
|
+
flow_dto_ts_decorate([
|
|
645
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
646
|
+
description: 'Path of the Request step to start at; left out, the one on the flow\'s own URL',
|
|
647
|
+
example: 'insert-many'
|
|
648
|
+
}),
|
|
649
|
+
(0,external_class_validator_.Matches)(flow_types/* .FLOW_ENDPOINT_PATH_PATTERN */.YO),
|
|
650
|
+
(0,external_class_validator_.IsOptional)(),
|
|
651
|
+
flow_dto_ts_metadata("design:type", String)
|
|
652
|
+
], TestFlowDto.prototype, "endpoint", void 0);
|
|
653
|
+
flow_dto_ts_decorate([
|
|
654
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
655
|
+
description: 'The request body to test with: an object, or a list for a Request step whose body is a list'
|
|
656
|
+
}),
|
|
657
|
+
(0,external_class_validator_.ValidateIf)((dto)=>!Array.isArray(dto.input)),
|
|
658
|
+
(0,external_class_validator_.IsObject)(),
|
|
659
|
+
(0,external_class_validator_.IsOptional)(),
|
|
660
|
+
flow_dto_ts_metadata("design:type", typeof FlowInput === "undefined" ? Object : FlowInput)
|
|
661
|
+
], TestFlowDto.prototype, "input", void 0);
|
|
662
|
+
flow_dto_ts_decorate([
|
|
663
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
664
|
+
enum: [
|
|
665
|
+
'dry_run',
|
|
666
|
+
'live'
|
|
667
|
+
],
|
|
668
|
+
default: 'dry_run',
|
|
669
|
+
description: 'dry_run: entity writes are rolled back, HTTP requests and events are skipped'
|
|
670
|
+
}),
|
|
671
|
+
(0,external_class_validator_.IsEnum)([
|
|
672
|
+
'dry_run',
|
|
673
|
+
'live'
|
|
674
|
+
]),
|
|
675
|
+
(0,external_class_validator_.IsOptional)(),
|
|
676
|
+
flow_dto_ts_metadata("design:type", String)
|
|
677
|
+
], TestFlowDto.prototype, "mode", void 0);
|
|
678
|
+
flow_dto_ts_decorate([
|
|
679
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
680
|
+
type: TestFlowRequestDto,
|
|
681
|
+
description: 'Simulated request details for rules that read headers, query parameters or the IP'
|
|
682
|
+
}),
|
|
683
|
+
(0,external_class_validator_.ValidateNested)(),
|
|
684
|
+
(0,external_class_transformer_.Type)(()=>TestFlowRequestDto),
|
|
685
|
+
(0,external_class_validator_.IsOptional)(),
|
|
686
|
+
flow_dto_ts_metadata("design:type", typeof TestFlowRequestDto === "undefined" ? Object : TestFlowRequestDto)
|
|
687
|
+
], TestFlowDto.prototype, "request", void 0);
|
|
688
|
+
class ValidateFlowDto {
|
|
689
|
+
definition;
|
|
690
|
+
}
|
|
691
|
+
flow_dto_ts_decorate([
|
|
692
|
+
(0,swagger_.ApiProperty)({
|
|
693
|
+
type: FlowDraftDto
|
|
694
|
+
}),
|
|
695
|
+
(0,external_class_validator_.IsObject)(),
|
|
696
|
+
(0,external_class_validator_.ValidateNested)(),
|
|
697
|
+
(0,external_class_transformer_.Type)(()=>FlowDraftDto),
|
|
698
|
+
flow_dto_ts_metadata("design:type", typeof FlowDraftDto === "undefined" ? Object : FlowDraftDto)
|
|
699
|
+
], ValidateFlowDto.prototype, "definition", void 0);
|
|
700
|
+
class FlowIdDto {
|
|
701
|
+
flowId;
|
|
702
|
+
}
|
|
703
|
+
flow_dto_ts_decorate([
|
|
704
|
+
(0,swagger_.ApiProperty)(),
|
|
705
|
+
(0,external_class_validator_.IsUUID)(),
|
|
706
|
+
(0,external_class_validator_.IsNotEmpty)(),
|
|
707
|
+
flow_dto_ts_metadata("design:type", String)
|
|
708
|
+
], FlowIdDto.prototype, "flowId", void 0);
|
|
709
|
+
class PublishFlowDto {
|
|
710
|
+
id;
|
|
711
|
+
note;
|
|
712
|
+
}
|
|
713
|
+
flow_dto_ts_decorate([
|
|
714
|
+
(0,swagger_.ApiProperty)(),
|
|
715
|
+
(0,external_class_validator_.IsUUID)(),
|
|
716
|
+
(0,external_class_validator_.IsNotEmpty)(),
|
|
717
|
+
flow_dto_ts_metadata("design:type", String)
|
|
718
|
+
], PublishFlowDto.prototype, "id", void 0);
|
|
719
|
+
flow_dto_ts_decorate([
|
|
720
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
721
|
+
description: 'What changed in this version',
|
|
722
|
+
example: 'Checks the branch before saving'
|
|
723
|
+
}),
|
|
724
|
+
(0,external_class_validator_.IsString)(),
|
|
725
|
+
(0,external_class_validator_.IsOptional)(),
|
|
726
|
+
(0,external_class_validator_.MaxLength)(500),
|
|
727
|
+
flow_dto_ts_metadata("design:type", String)
|
|
728
|
+
], PublishFlowDto.prototype, "note", void 0);
|
|
729
|
+
class FlowVersionRefDto extends FlowIdDto {
|
|
730
|
+
version;
|
|
731
|
+
}
|
|
732
|
+
flow_dto_ts_decorate([
|
|
733
|
+
(0,swagger_.ApiProperty)({
|
|
734
|
+
example: 3
|
|
735
|
+
}),
|
|
736
|
+
(0,external_class_validator_.IsInt)(),
|
|
737
|
+
(0,external_class_validator_.Min)(1),
|
|
738
|
+
flow_dto_ts_metadata("design:type", Number)
|
|
739
|
+
], FlowVersionRefDto.prototype, "version", void 0);
|
|
740
|
+
/** The id of a flow API key or a flow execution. */ class IdBodyDto {
|
|
741
|
+
id;
|
|
742
|
+
}
|
|
743
|
+
flow_dto_ts_decorate([
|
|
744
|
+
(0,swagger_.ApiProperty)(),
|
|
745
|
+
(0,external_class_validator_.IsUUID)(),
|
|
746
|
+
(0,external_class_validator_.IsNotEmpty)(),
|
|
747
|
+
flow_dto_ts_metadata("design:type", String)
|
|
748
|
+
], IdBodyDto.prototype, "id", void 0);
|
|
749
|
+
class ListFlowExecutionsDto {
|
|
750
|
+
flowId;
|
|
751
|
+
status;
|
|
752
|
+
page;
|
|
753
|
+
pageSize;
|
|
754
|
+
}
|
|
755
|
+
flow_dto_ts_decorate([
|
|
756
|
+
(0,swagger_.ApiPropertyOptional)(),
|
|
757
|
+
(0,external_class_validator_.IsUUID)(),
|
|
758
|
+
(0,external_class_validator_.IsOptional)(),
|
|
759
|
+
flow_dto_ts_metadata("design:type", String)
|
|
760
|
+
], ListFlowExecutionsDto.prototype, "flowId", void 0);
|
|
761
|
+
flow_dto_ts_decorate([
|
|
762
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
763
|
+
enum: [
|
|
764
|
+
'success',
|
|
765
|
+
'failed',
|
|
766
|
+
'rejected'
|
|
767
|
+
]
|
|
768
|
+
}),
|
|
769
|
+
(0,external_class_validator_.IsIn)([
|
|
770
|
+
'success',
|
|
771
|
+
'failed',
|
|
772
|
+
'rejected'
|
|
773
|
+
]),
|
|
774
|
+
(0,external_class_validator_.IsOptional)(),
|
|
775
|
+
flow_dto_ts_metadata("design:type", String)
|
|
776
|
+
], ListFlowExecutionsDto.prototype, "status", void 0);
|
|
777
|
+
flow_dto_ts_decorate([
|
|
778
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
779
|
+
default: 0
|
|
780
|
+
}),
|
|
781
|
+
(0,external_class_validator_.IsInt)(),
|
|
782
|
+
(0,external_class_validator_.Min)(0),
|
|
783
|
+
(0,external_class_validator_.IsOptional)(),
|
|
784
|
+
flow_dto_ts_metadata("design:type", Number)
|
|
785
|
+
], ListFlowExecutionsDto.prototype, "page", void 0);
|
|
786
|
+
flow_dto_ts_decorate([
|
|
787
|
+
(0,swagger_.ApiPropertyOptional)({
|
|
788
|
+
default: 20
|
|
789
|
+
}),
|
|
790
|
+
(0,external_class_validator_.IsInt)(),
|
|
791
|
+
(0,external_class_validator_.Min)(1),
|
|
792
|
+
(0,external_class_validator_.Max)(100),
|
|
793
|
+
(0,external_class_validator_.IsOptional)(),
|
|
794
|
+
flow_dto_ts_metadata("design:type", Number)
|
|
795
|
+
], ListFlowExecutionsDto.prototype, "pageSize", void 0);
|
|
796
|
+
class FlowDefinitionResponseDto extends dtos_.IdentityResponseDto {
|
|
797
|
+
name;
|
|
798
|
+
slug;
|
|
799
|
+
description;
|
|
800
|
+
isActive;
|
|
801
|
+
retainExecutions;
|
|
802
|
+
nodes;
|
|
803
|
+
edges;
|
|
804
|
+
version;
|
|
805
|
+
draft;
|
|
806
|
+
}
|
|
807
|
+
flow_dto_ts_decorate([
|
|
808
|
+
(0,external_class_transformer_.Expose)(),
|
|
809
|
+
(0,swagger_.ApiProperty)(),
|
|
810
|
+
flow_dto_ts_metadata("design:type", String)
|
|
811
|
+
], FlowDefinitionResponseDto.prototype, "name", void 0);
|
|
812
|
+
flow_dto_ts_decorate([
|
|
813
|
+
(0,external_class_transformer_.Expose)(),
|
|
814
|
+
(0,swagger_.ApiProperty)(),
|
|
815
|
+
flow_dto_ts_metadata("design:type", String)
|
|
816
|
+
], FlowDefinitionResponseDto.prototype, "slug", void 0);
|
|
817
|
+
flow_dto_ts_decorate([
|
|
818
|
+
(0,external_class_transformer_.Expose)(),
|
|
819
|
+
(0,swagger_.ApiProperty)(),
|
|
820
|
+
flow_dto_ts_metadata("design:type", Object)
|
|
821
|
+
], FlowDefinitionResponseDto.prototype, "description", void 0);
|
|
822
|
+
flow_dto_ts_decorate([
|
|
823
|
+
(0,external_class_transformer_.Expose)(),
|
|
824
|
+
(0,swagger_.ApiProperty)(),
|
|
825
|
+
flow_dto_ts_metadata("design:type", Boolean)
|
|
826
|
+
], FlowDefinitionResponseDto.prototype, "isActive", void 0);
|
|
827
|
+
flow_dto_ts_decorate([
|
|
828
|
+
(0,external_class_transformer_.Expose)(),
|
|
829
|
+
(0,swagger_.ApiProperty)(),
|
|
830
|
+
flow_dto_ts_metadata("design:type", Number)
|
|
831
|
+
], FlowDefinitionResponseDto.prototype, "retainExecutions", void 0);
|
|
832
|
+
flow_dto_ts_decorate([
|
|
833
|
+
(0,external_class_transformer_.Expose)(),
|
|
834
|
+
(0,swagger_.ApiProperty)(),
|
|
835
|
+
flow_dto_ts_metadata("design:type", Array)
|
|
836
|
+
], FlowDefinitionResponseDto.prototype, "nodes", void 0);
|
|
837
|
+
flow_dto_ts_decorate([
|
|
838
|
+
(0,external_class_transformer_.Expose)(),
|
|
839
|
+
(0,swagger_.ApiProperty)(),
|
|
840
|
+
flow_dto_ts_metadata("design:type", Array)
|
|
841
|
+
], FlowDefinitionResponseDto.prototype, "edges", void 0);
|
|
842
|
+
flow_dto_ts_decorate([
|
|
843
|
+
(0,external_class_transformer_.Expose)(),
|
|
844
|
+
(0,swagger_.ApiProperty)({
|
|
845
|
+
description: 'The published version; 0 until the flow is first published'
|
|
846
|
+
}),
|
|
847
|
+
flow_dto_ts_metadata("design:type", Number)
|
|
848
|
+
], FlowDefinitionResponseDto.prototype, "version", void 0);
|
|
849
|
+
flow_dto_ts_decorate([
|
|
850
|
+
(0,external_class_transformer_.Expose)(),
|
|
851
|
+
(0,swagger_.ApiProperty)({
|
|
852
|
+
description: 'Saved changes not yet published',
|
|
853
|
+
nullable: true
|
|
854
|
+
}),
|
|
855
|
+
flow_dto_ts_metadata("design:type", Object)
|
|
856
|
+
], FlowDefinitionResponseDto.prototype, "draft", void 0);
|
|
857
|
+
|
|
858
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/flow-definition.service.ts + 1 modules
|
|
859
|
+
var flow_definition_service = __webpack_require__(4921);
|
|
860
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/flow-runtime.service.ts
|
|
861
|
+
var flow_runtime_service = __webpack_require__(2300);
|
|
862
|
+
;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/controllers/flow-definition.controller.ts
|
|
863
|
+
function flow_definition_controller_ts_decorate(decorators, target, key, desc) {
|
|
864
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
865
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
866
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
867
|
+
} else {
|
|
868
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
869
|
+
if (d = decorators[i]) {
|
|
870
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
875
|
+
}
|
|
876
|
+
function flow_definition_controller_ts_metadata(metadataKey, metadataValue) {
|
|
877
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
878
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
function flow_definition_controller_ts_param(paramIndex, decorator) {
|
|
882
|
+
return function(target, key) {
|
|
883
|
+
decorator(target, key, paramIndex);
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
const P = nestjs_shared_.FLOW_DEFINITION_PERMISSIONS;
|
|
896
|
+
class FlowDefinitionController extends (0,nestjs_shared_.createApiController)(CreateFlowDefinitionDto, UpdateFlowDefinitionDto, FlowDefinitionResponseDto, {
|
|
897
|
+
entityName: 'entity_builder.flow_definition',
|
|
898
|
+
enabledEndpoints: [
|
|
899
|
+
'insert',
|
|
900
|
+
'getById',
|
|
901
|
+
'getByIds',
|
|
902
|
+
'getAll',
|
|
903
|
+
'getByFilter',
|
|
904
|
+
'update',
|
|
905
|
+
'delete'
|
|
906
|
+
],
|
|
907
|
+
security: {
|
|
908
|
+
insert: {
|
|
909
|
+
level: 'permission',
|
|
910
|
+
permissions: [
|
|
911
|
+
P.CREATE
|
|
912
|
+
]
|
|
913
|
+
},
|
|
914
|
+
getById: {
|
|
915
|
+
level: 'permission',
|
|
916
|
+
permissions: [
|
|
917
|
+
P.READ
|
|
918
|
+
]
|
|
919
|
+
},
|
|
920
|
+
getByIds: {
|
|
921
|
+
level: 'permission',
|
|
922
|
+
permissions: [
|
|
923
|
+
P.READ
|
|
924
|
+
]
|
|
925
|
+
},
|
|
926
|
+
getAll: {
|
|
927
|
+
level: 'permission',
|
|
928
|
+
permissions: [
|
|
929
|
+
P.READ
|
|
930
|
+
]
|
|
931
|
+
},
|
|
932
|
+
getByFilter: {
|
|
933
|
+
level: 'permission',
|
|
934
|
+
permissions: [
|
|
935
|
+
P.READ
|
|
936
|
+
]
|
|
937
|
+
},
|
|
938
|
+
update: {
|
|
939
|
+
level: 'permission',
|
|
940
|
+
permissions: [
|
|
941
|
+
P.UPDATE
|
|
942
|
+
]
|
|
943
|
+
},
|
|
944
|
+
delete: {
|
|
945
|
+
level: 'permission',
|
|
946
|
+
permissions: [
|
|
947
|
+
P.DELETE
|
|
948
|
+
]
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}) {
|
|
952
|
+
flowDefinitionService;
|
|
953
|
+
runtime;
|
|
954
|
+
constructor(flowDefinitionService, runtime){
|
|
955
|
+
super(flowDefinitionService), this.flowDefinitionService = flowDefinitionService, this.runtime = runtime;
|
|
956
|
+
}
|
|
957
|
+
async validate(dto) {
|
|
958
|
+
const result = await this.flowDefinitionService.validate((0,flow_definition_service/* .toFlowSettings */.RK)(dto.definition));
|
|
959
|
+
return {
|
|
960
|
+
success: true,
|
|
961
|
+
message: result.errors.length ? 'The flow has problems' : 'The flow is valid',
|
|
962
|
+
messageKey: result.errors.length ? message_keys/* .FLOW_MESSAGES.VALIDATE_PROBLEMS */.wu.VALIDATE_PROBLEMS : message_keys/* .FLOW_MESSAGES.VALIDATE_OK */.wu.VALIDATE_OK,
|
|
963
|
+
data: result
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
async publish(dto, user) {
|
|
967
|
+
const flow = await this.flowDefinitionService.publish(dto.id, dto.note, user);
|
|
968
|
+
return {
|
|
969
|
+
success: true,
|
|
970
|
+
message: `Version ${flow.version} published`,
|
|
971
|
+
messageKey: message_keys/* .FLOW_MESSAGES.PUBLISH_SUCCESS */.wu.PUBLISH_SUCCESS,
|
|
972
|
+
messageVariables: {
|
|
973
|
+
version: flow.version
|
|
974
|
+
},
|
|
975
|
+
data: flow
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
async versions(dto) {
|
|
979
|
+
return {
|
|
980
|
+
success: true,
|
|
981
|
+
message: 'Versions loaded',
|
|
982
|
+
messageKey: message_keys/* .FLOW_MESSAGES.VERSIONS_SUCCESS */.wu.VERSIONS_SUCCESS,
|
|
983
|
+
data: await this.flowDefinitionService.listVersions(dto.flowId)
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
async version(dto) {
|
|
987
|
+
return {
|
|
988
|
+
success: true,
|
|
989
|
+
message: 'Version loaded',
|
|
990
|
+
messageKey: message_keys/* .FLOW_MESSAGES.VERSION_SUCCESS */.wu.VERSION_SUCCESS,
|
|
991
|
+
data: await this.flowDefinitionService.getVersion(dto.flowId, dto.version)
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
async restoreVersion(dto, user) {
|
|
995
|
+
const flow = await this.flowDefinitionService.restoreVersion(dto.flowId, dto.version, user);
|
|
996
|
+
return {
|
|
997
|
+
success: true,
|
|
998
|
+
message: `Version ${dto.version} restored to the draft`,
|
|
999
|
+
messageKey: message_keys/* .FLOW_MESSAGES.VERSION_RESTORED */.wu.VERSION_RESTORED,
|
|
1000
|
+
messageVariables: {
|
|
1001
|
+
version: dto.version
|
|
1002
|
+
},
|
|
1003
|
+
data: flow
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
1006
|
+
async discardDraft(dto, user) {
|
|
1007
|
+
const flow = await this.flowDefinitionService.discardDraft(dto.flowId, user);
|
|
1008
|
+
return {
|
|
1009
|
+
success: true,
|
|
1010
|
+
message: 'Unpublished changes discarded',
|
|
1011
|
+
messageKey: message_keys/* .FLOW_MESSAGES.DRAFT_DISCARDED */.wu.DRAFT_DISCARDED,
|
|
1012
|
+
data: flow
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
async testRun(dto, user, req) {
|
|
1016
|
+
const { result, warnings } = await this.runtime.testRun(dto, user, {
|
|
1017
|
+
ip: req.ip ?? null,
|
|
1018
|
+
headers: req.headers
|
|
1019
|
+
});
|
|
1020
|
+
return {
|
|
1021
|
+
success: true,
|
|
1022
|
+
message: 'Test run finished',
|
|
1023
|
+
messageKey: message_keys/* .FLOW_MESSAGES.TEST_SUCCESS */.wu.TEST_SUCCESS,
|
|
1024
|
+
data: {
|
|
1025
|
+
...result,
|
|
1026
|
+
warnings
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
flow_definition_controller_ts_decorate([
|
|
1032
|
+
(0,common_.Post)('validate'),
|
|
1033
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
1034
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
1035
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(P.READ),
|
|
1036
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1037
|
+
(0,swagger_.ApiOperation)({
|
|
1038
|
+
summary: 'Check a flow without saving it: errors block saving, warnings do not'
|
|
1039
|
+
}),
|
|
1040
|
+
(0,swagger_.ApiBody)({
|
|
1041
|
+
type: ValidateFlowDto
|
|
1042
|
+
}),
|
|
1043
|
+
flow_definition_controller_ts_param(0, (0,common_.Body)()),
|
|
1044
|
+
flow_definition_controller_ts_metadata("design:type", Function),
|
|
1045
|
+
flow_definition_controller_ts_metadata("design:paramtypes", [
|
|
1046
|
+
typeof ValidateFlowDto === "undefined" ? Object : ValidateFlowDto
|
|
1047
|
+
]),
|
|
1048
|
+
flow_definition_controller_ts_metadata("design:returntype", Promise)
|
|
1049
|
+
], FlowDefinitionController.prototype, "validate", null);
|
|
1050
|
+
flow_definition_controller_ts_decorate([
|
|
1051
|
+
(0,common_.Post)('publish'),
|
|
1052
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
1053
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
1054
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(P.UPDATE),
|
|
1055
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1056
|
+
(0,swagger_.ApiOperation)({
|
|
1057
|
+
summary: 'Make the saved changes live as the next version',
|
|
1058
|
+
description: 'Checked like a save, plus that no other flow calls a URL name or path this version drops.'
|
|
1059
|
+
}),
|
|
1060
|
+
(0,swagger_.ApiBody)({
|
|
1061
|
+
type: PublishFlowDto
|
|
1062
|
+
}),
|
|
1063
|
+
flow_definition_controller_ts_param(0, (0,common_.Body)()),
|
|
1064
|
+
flow_definition_controller_ts_param(1, (0,nestjs_shared_.CurrentUser)()),
|
|
1065
|
+
flow_definition_controller_ts_metadata("design:type", Function),
|
|
1066
|
+
flow_definition_controller_ts_metadata("design:paramtypes", [
|
|
1067
|
+
typeof PublishFlowDto === "undefined" ? Object : PublishFlowDto,
|
|
1068
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1069
|
+
]),
|
|
1070
|
+
flow_definition_controller_ts_metadata("design:returntype", Promise)
|
|
1071
|
+
], FlowDefinitionController.prototype, "publish", null);
|
|
1072
|
+
flow_definition_controller_ts_decorate([
|
|
1073
|
+
(0,common_.Post)('versions'),
|
|
1074
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
1075
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
1076
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(P.READ),
|
|
1077
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1078
|
+
(0,swagger_.ApiOperation)({
|
|
1079
|
+
summary: 'Published versions of a flow, newest first'
|
|
1080
|
+
}),
|
|
1081
|
+
(0,swagger_.ApiBody)({
|
|
1082
|
+
type: FlowIdDto
|
|
1083
|
+
}),
|
|
1084
|
+
flow_definition_controller_ts_param(0, (0,common_.Body)()),
|
|
1085
|
+
flow_definition_controller_ts_metadata("design:type", Function),
|
|
1086
|
+
flow_definition_controller_ts_metadata("design:paramtypes", [
|
|
1087
|
+
typeof FlowIdDto === "undefined" ? Object : FlowIdDto
|
|
1088
|
+
]),
|
|
1089
|
+
flow_definition_controller_ts_metadata("design:returntype", Promise)
|
|
1090
|
+
], FlowDefinitionController.prototype, "versions", null);
|
|
1091
|
+
flow_definition_controller_ts_decorate([
|
|
1092
|
+
(0,common_.Post)('version'),
|
|
1093
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
1094
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
1095
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(P.READ),
|
|
1096
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1097
|
+
(0,swagger_.ApiOperation)({
|
|
1098
|
+
summary: 'One published version in full'
|
|
1099
|
+
}),
|
|
1100
|
+
(0,swagger_.ApiBody)({
|
|
1101
|
+
type: FlowVersionRefDto
|
|
1102
|
+
}),
|
|
1103
|
+
flow_definition_controller_ts_param(0, (0,common_.Body)()),
|
|
1104
|
+
flow_definition_controller_ts_metadata("design:type", Function),
|
|
1105
|
+
flow_definition_controller_ts_metadata("design:paramtypes", [
|
|
1106
|
+
typeof FlowVersionRefDto === "undefined" ? Object : FlowVersionRefDto
|
|
1107
|
+
]),
|
|
1108
|
+
flow_definition_controller_ts_metadata("design:returntype", Promise)
|
|
1109
|
+
], FlowDefinitionController.prototype, "version", null);
|
|
1110
|
+
flow_definition_controller_ts_decorate([
|
|
1111
|
+
(0,common_.Post)('restore-version'),
|
|
1112
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
1113
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
1114
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(P.UPDATE),
|
|
1115
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1116
|
+
(0,swagger_.ApiOperation)({
|
|
1117
|
+
summary: 'Put an old version back into the draft',
|
|
1118
|
+
description: 'Callers keep running the published flow until the draft is published.'
|
|
1119
|
+
}),
|
|
1120
|
+
(0,swagger_.ApiBody)({
|
|
1121
|
+
type: FlowVersionRefDto
|
|
1122
|
+
}),
|
|
1123
|
+
flow_definition_controller_ts_param(0, (0,common_.Body)()),
|
|
1124
|
+
flow_definition_controller_ts_param(1, (0,nestjs_shared_.CurrentUser)()),
|
|
1125
|
+
flow_definition_controller_ts_metadata("design:type", Function),
|
|
1126
|
+
flow_definition_controller_ts_metadata("design:paramtypes", [
|
|
1127
|
+
typeof FlowVersionRefDto === "undefined" ? Object : FlowVersionRefDto,
|
|
1128
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1129
|
+
]),
|
|
1130
|
+
flow_definition_controller_ts_metadata("design:returntype", Promise)
|
|
1131
|
+
], FlowDefinitionController.prototype, "restoreVersion", null);
|
|
1132
|
+
flow_definition_controller_ts_decorate([
|
|
1133
|
+
(0,common_.Post)('discard-draft'),
|
|
1134
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
1135
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
1136
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(P.UPDATE),
|
|
1137
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1138
|
+
(0,swagger_.ApiOperation)({
|
|
1139
|
+
summary: 'Drop the unpublished changes: the flow goes back to what is published'
|
|
1140
|
+
}),
|
|
1141
|
+
(0,swagger_.ApiBody)({
|
|
1142
|
+
type: FlowIdDto
|
|
1143
|
+
}),
|
|
1144
|
+
flow_definition_controller_ts_param(0, (0,common_.Body)()),
|
|
1145
|
+
flow_definition_controller_ts_param(1, (0,nestjs_shared_.CurrentUser)()),
|
|
1146
|
+
flow_definition_controller_ts_metadata("design:type", Function),
|
|
1147
|
+
flow_definition_controller_ts_metadata("design:paramtypes", [
|
|
1148
|
+
typeof FlowIdDto === "undefined" ? Object : FlowIdDto,
|
|
1149
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
|
|
1150
|
+
]),
|
|
1151
|
+
flow_definition_controller_ts_metadata("design:returntype", Promise)
|
|
1152
|
+
], FlowDefinitionController.prototype, "discardDraft", null);
|
|
1153
|
+
flow_definition_controller_ts_decorate([
|
|
1154
|
+
(0,common_.Post)('test-run'),
|
|
1155
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
1156
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
1157
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(P.TEST),
|
|
1158
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1159
|
+
(0,swagger_.ApiOperation)({
|
|
1160
|
+
summary: 'Run a saved flow or an unsaved draft',
|
|
1161
|
+
description: 'dry_run (default): entity writes happen inside a transaction that is rolled back; HTTP requests and events are skipped. live: does everything for real. Returns the answer and a per-node trace.'
|
|
1162
|
+
}),
|
|
1163
|
+
(0,swagger_.ApiBody)({
|
|
1164
|
+
type: TestFlowDto
|
|
1165
|
+
}),
|
|
1166
|
+
flow_definition_controller_ts_param(0, (0,common_.Body)()),
|
|
1167
|
+
flow_definition_controller_ts_param(1, (0,nestjs_shared_.CurrentUser)()),
|
|
1168
|
+
flow_definition_controller_ts_param(2, (0,common_.Req)()),
|
|
1169
|
+
flow_definition_controller_ts_metadata("design:type", Function),
|
|
1170
|
+
flow_definition_controller_ts_metadata("design:paramtypes", [
|
|
1171
|
+
typeof TestFlowDto === "undefined" ? Object : TestFlowDto,
|
|
1172
|
+
typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo,
|
|
1173
|
+
Object
|
|
1174
|
+
]),
|
|
1175
|
+
flow_definition_controller_ts_metadata("design:returntype", Promise)
|
|
1176
|
+
], FlowDefinitionController.prototype, "testRun", null);
|
|
1177
|
+
FlowDefinitionController = flow_definition_controller_ts_decorate([
|
|
1178
|
+
(0,swagger_.ApiTags)('Entity Builder - Flows'),
|
|
1179
|
+
(0,common_.Controller)('entity-builder/flows'),
|
|
1180
|
+
flow_definition_controller_ts_param(0, (0,common_.Inject)(flow_definition_service/* .FlowDefinitionService */.Tk)),
|
|
1181
|
+
flow_definition_controller_ts_param(1, (0,common_.Inject)(flow_runtime_service/* .FlowRuntimeService */.a)),
|
|
1182
|
+
flow_definition_controller_ts_metadata("design:type", Function),
|
|
1183
|
+
flow_definition_controller_ts_metadata("design:paramtypes", [
|
|
1184
|
+
typeof flow_definition_service/* .FlowDefinitionService */.Tk === "undefined" ? Object : flow_definition_service/* .FlowDefinitionService */.Tk,
|
|
1185
|
+
typeof flow_runtime_service/* .FlowRuntimeService */.a === "undefined" ? Object : flow_runtime_service/* .FlowRuntimeService */.a
|
|
1186
|
+
])
|
|
1187
|
+
], FlowDefinitionController);
|
|
1188
|
+
|
|
1189
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/flow-execution.service.ts
|
|
1190
|
+
var flow_execution_service = __webpack_require__(7810);
|
|
1191
|
+
;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/controllers/flow-execution.controller.ts
|
|
1192
|
+
function flow_execution_controller_ts_decorate(decorators, target, key, desc) {
|
|
1193
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1194
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1195
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1196
|
+
} else {
|
|
1197
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
1198
|
+
if (d = decorators[i]) {
|
|
1199
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1204
|
+
}
|
|
1205
|
+
function flow_execution_controller_ts_metadata(metadataKey, metadataValue) {
|
|
1206
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1207
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
function flow_execution_controller_ts_param(paramIndex, decorator) {
|
|
1211
|
+
return function(target, key) {
|
|
1212
|
+
decorator(target, key, paramIndex);
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
|
|
1217
|
+
|
|
1218
|
+
|
|
1219
|
+
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
|
|
1223
|
+
class FlowExecutionController {
|
|
1224
|
+
executions;
|
|
1225
|
+
constructor(executions){
|
|
1226
|
+
this.executions = executions;
|
|
1227
|
+
}
|
|
1228
|
+
async list(dto) {
|
|
1229
|
+
const page = dto.page ?? 0;
|
|
1230
|
+
const pageSize = dto.pageSize ?? 20;
|
|
1231
|
+
const { rows, total } = await this.executions.list({
|
|
1232
|
+
flowId: dto.flowId,
|
|
1233
|
+
status: dto.status,
|
|
1234
|
+
page,
|
|
1235
|
+
pageSize
|
|
1236
|
+
});
|
|
1237
|
+
return {
|
|
1238
|
+
success: true,
|
|
1239
|
+
message: 'Executions loaded',
|
|
1240
|
+
messageKey: message_keys/* .FLOW_MESSAGES.EXECUTIONS_SUCCESS */.wu.EXECUTIONS_SUCCESS,
|
|
1241
|
+
data: rows,
|
|
1242
|
+
meta: {
|
|
1243
|
+
total,
|
|
1244
|
+
page,
|
|
1245
|
+
pageSize,
|
|
1246
|
+
count: rows.length,
|
|
1247
|
+
hasMore: (page + 1) * pageSize < total
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
async get(dto) {
|
|
1252
|
+
const execution = await this.executions.get(dto.id);
|
|
1253
|
+
if (!execution) throw new common_.NotFoundException({
|
|
1254
|
+
message: 'Execution not found.',
|
|
1255
|
+
messageKey: message_keys/* .FLOW_MESSAGES.EXECUTION_NOT_FOUND */.wu.EXECUTION_NOT_FOUND
|
|
1256
|
+
});
|
|
1257
|
+
return {
|
|
1258
|
+
success: true,
|
|
1259
|
+
message: 'Execution loaded',
|
|
1260
|
+
messageKey: message_keys/* .FLOW_MESSAGES.EXECUTION_SUCCESS */.wu.EXECUTION_SUCCESS,
|
|
1261
|
+
data: execution
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
flow_execution_controller_ts_decorate([
|
|
1266
|
+
(0,common_.Post)('list'),
|
|
1267
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
1268
|
+
flow_execution_controller_ts_param(0, (0,common_.Body)()),
|
|
1269
|
+
flow_execution_controller_ts_metadata("design:type", Function),
|
|
1270
|
+
flow_execution_controller_ts_metadata("design:paramtypes", [
|
|
1271
|
+
typeof ListFlowExecutionsDto === "undefined" ? Object : ListFlowExecutionsDto
|
|
1272
|
+
]),
|
|
1273
|
+
flow_execution_controller_ts_metadata("design:returntype", Promise)
|
|
1274
|
+
], FlowExecutionController.prototype, "list", null);
|
|
1275
|
+
flow_execution_controller_ts_decorate([
|
|
1276
|
+
(0,common_.Post)('get'),
|
|
1277
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
1278
|
+
flow_execution_controller_ts_param(0, (0,common_.Body)()),
|
|
1279
|
+
flow_execution_controller_ts_metadata("design:type", Function),
|
|
1280
|
+
flow_execution_controller_ts_metadata("design:paramtypes", [
|
|
1281
|
+
typeof IdBodyDto === "undefined" ? Object : IdBodyDto
|
|
1282
|
+
]),
|
|
1283
|
+
flow_execution_controller_ts_metadata("design:returntype", Promise)
|
|
1284
|
+
], FlowExecutionController.prototype, "get", null);
|
|
1285
|
+
FlowExecutionController = flow_execution_controller_ts_decorate([
|
|
1286
|
+
(0,swagger_.ApiTags)('Entity Builder - Flow executions'),
|
|
1287
|
+
(0,common_.Controller)('entity-builder/flow-executions'),
|
|
1288
|
+
(0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
|
|
1289
|
+
(0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(nestjs_shared_.FLOW_DEFINITION_PERMISSIONS.READ),
|
|
1290
|
+
(0,swagger_.ApiBearerAuth)(),
|
|
1291
|
+
flow_execution_controller_ts_param(0, (0,common_.Inject)(flow_execution_service/* .FlowExecutionService */.A)),
|
|
1292
|
+
flow_execution_controller_ts_metadata("design:type", Function),
|
|
1293
|
+
flow_execution_controller_ts_metadata("design:paramtypes", [
|
|
1294
|
+
typeof flow_execution_service/* .FlowExecutionService */.A === "undefined" ? Object : flow_execution_service/* .FlowExecutionService */.A
|
|
1295
|
+
])
|
|
1296
|
+
], FlowExecutionController);
|
|
1297
|
+
|
|
1298
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/guards/flow-access.guard.ts + 2 modules
|
|
1299
|
+
var flow_access_guard = __webpack_require__(4196);
|
|
1300
|
+
;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/controllers/flow-runtime.controller.ts
|
|
1301
|
+
function flow_runtime_controller_ts_decorate(decorators, target, key, desc) {
|
|
1302
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1303
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1304
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1305
|
+
} else {
|
|
1306
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
1307
|
+
if (d = decorators[i]) {
|
|
1308
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1313
|
+
}
|
|
1314
|
+
function flow_runtime_controller_ts_metadata(metadataKey, metadataValue) {
|
|
1315
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1316
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
function flow_runtime_controller_ts_param(paramIndex, decorator) {
|
|
1320
|
+
return function(target, key) {
|
|
1321
|
+
decorator(target, key, paramIndex);
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
|
|
1326
|
+
|
|
1327
|
+
|
|
1328
|
+
class FlowRuntimeController {
|
|
1329
|
+
runtime;
|
|
1330
|
+
constructor(runtime){
|
|
1331
|
+
this.runtime = runtime;
|
|
1332
|
+
}
|
|
1333
|
+
run(_slug, body, req, res) {
|
|
1334
|
+
return this.answer(body, req, res);
|
|
1335
|
+
}
|
|
1336
|
+
runEndpoint(_slug, _endpoint, body, req, res) {
|
|
1337
|
+
return this.answer(body, req, res);
|
|
1338
|
+
}
|
|
1339
|
+
async answer(body, req, res) {
|
|
1340
|
+
const result = await this.runtime.handle(req.flowDefinition, req.flowEndpoint, body, {
|
|
1341
|
+
ip: req.ip ?? null,
|
|
1342
|
+
headers: req.headers,
|
|
1343
|
+
query: req.query ?? {},
|
|
1344
|
+
path: req.path ?? null
|
|
1345
|
+
}, req.user ?? null);
|
|
1346
|
+
res.status(result.statusCode);
|
|
1347
|
+
return result.body;
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
flow_runtime_controller_ts_decorate([
|
|
1351
|
+
(0,common_.Post)(':slug'),
|
|
1352
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
1353
|
+
(0,common_.UseGuards)(flow_access_guard/* .FlowAccessGuard */.C),
|
|
1354
|
+
(0,swagger_.ApiOperation)({
|
|
1355
|
+
summary: 'Call a flow'
|
|
1356
|
+
}),
|
|
1357
|
+
(0,swagger_.ApiParam)({
|
|
1358
|
+
name: 'slug'
|
|
1359
|
+
}),
|
|
1360
|
+
flow_runtime_controller_ts_param(0, (0,common_.Param)('slug')),
|
|
1361
|
+
flow_runtime_controller_ts_param(1, (0,common_.Body)()),
|
|
1362
|
+
flow_runtime_controller_ts_param(2, (0,common_.Req)()),
|
|
1363
|
+
flow_runtime_controller_ts_param(3, (0,common_.Res)({
|
|
1364
|
+
passthrough: true
|
|
1365
|
+
})),
|
|
1366
|
+
flow_runtime_controller_ts_metadata("design:type", Function),
|
|
1367
|
+
flow_runtime_controller_ts_metadata("design:paramtypes", [
|
|
1368
|
+
String,
|
|
1369
|
+
Object,
|
|
1370
|
+
typeof FlowRequest === "undefined" ? Object : FlowRequest,
|
|
1371
|
+
Object
|
|
1372
|
+
]),
|
|
1373
|
+
flow_runtime_controller_ts_metadata("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
1374
|
+
], FlowRuntimeController.prototype, "run", null);
|
|
1375
|
+
flow_runtime_controller_ts_decorate([
|
|
1376
|
+
(0,common_.Post)(':slug/:endpoint'),
|
|
1377
|
+
(0,common_.HttpCode)(common_.HttpStatus.OK),
|
|
1378
|
+
(0,common_.UseGuards)(flow_access_guard/* .FlowAccessGuard */.C),
|
|
1379
|
+
(0,swagger_.ApiOperation)({
|
|
1380
|
+
summary: 'Call one of the URLs of a flow'
|
|
1381
|
+
}),
|
|
1382
|
+
(0,swagger_.ApiParam)({
|
|
1383
|
+
name: 'slug'
|
|
1384
|
+
}),
|
|
1385
|
+
(0,swagger_.ApiParam)({
|
|
1386
|
+
name: 'endpoint'
|
|
1387
|
+
}),
|
|
1388
|
+
flow_runtime_controller_ts_param(0, (0,common_.Param)('slug')),
|
|
1389
|
+
flow_runtime_controller_ts_param(1, (0,common_.Param)('endpoint')),
|
|
1390
|
+
flow_runtime_controller_ts_param(2, (0,common_.Body)()),
|
|
1391
|
+
flow_runtime_controller_ts_param(3, (0,common_.Req)()),
|
|
1392
|
+
flow_runtime_controller_ts_param(4, (0,common_.Res)({
|
|
1393
|
+
passthrough: true
|
|
1394
|
+
})),
|
|
1395
|
+
flow_runtime_controller_ts_metadata("design:type", Function),
|
|
1396
|
+
flow_runtime_controller_ts_metadata("design:paramtypes", [
|
|
1397
|
+
String,
|
|
1398
|
+
String,
|
|
1399
|
+
Object,
|
|
1400
|
+
typeof FlowRequest === "undefined" ? Object : FlowRequest,
|
|
1401
|
+
Object
|
|
1402
|
+
]),
|
|
1403
|
+
flow_runtime_controller_ts_metadata("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
1404
|
+
], FlowRuntimeController.prototype, "runEndpoint", null);
|
|
1405
|
+
FlowRuntimeController = flow_runtime_controller_ts_decorate([
|
|
1406
|
+
(0,swagger_.ApiTags)('Flows (virtual APIs)'),
|
|
1407
|
+
(0,common_.Controller)('api-flows'),
|
|
1408
|
+
flow_runtime_controller_ts_param(0, (0,common_.Inject)(flow_runtime_service/* .FlowRuntimeService */.a)),
|
|
1409
|
+
flow_runtime_controller_ts_metadata("design:type", Function),
|
|
1410
|
+
flow_runtime_controller_ts_metadata("design:paramtypes", [
|
|
1411
|
+
typeof flow_runtime_service/* .FlowRuntimeService */.a === "undefined" ? Object : flow_runtime_service/* .FlowRuntimeService */.a
|
|
1412
|
+
])
|
|
1413
|
+
], FlowRuntimeController);
|
|
1414
|
+
|
|
1415
|
+
;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/controllers/index.ts
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
|
|
1423
|
+
},
|
|
1424
|
+
4196(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1425
|
+
|
|
1426
|
+
// EXPORTS
|
|
1427
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1428
|
+
C: () => (/* binding */ FlowAccessGuard)
|
|
1429
|
+
});
|
|
1430
|
+
|
|
1431
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared/constants"
|
|
1432
|
+
var constants_ = __webpack_require__(9140);
|
|
1433
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared/guards"
|
|
1434
|
+
var guards_ = __webpack_require__(3513);
|
|
1435
|
+
// EXTERNAL MODULE: external "@flusys/nestjs-shared/modules"
|
|
1436
|
+
var modules_ = __webpack_require__(1236);
|
|
1437
|
+
// EXTERNAL MODULE: external "@nestjs/common"
|
|
1438
|
+
var common_ = __webpack_require__(6157);
|
|
1439
|
+
// EXTERNAL MODULE: external "@nestjs/core"
|
|
1440
|
+
var core_ = __webpack_require__(3075);
|
|
1441
|
+
;// CONCATENATED MODULE: external "rxjs"
|
|
1442
|
+
|
|
1443
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/config/message-keys.ts
|
|
1444
|
+
var message_keys = __webpack_require__(5732);
|
|
1445
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/flow-definition.service.ts + 1 modules
|
|
1446
|
+
var flow_definition_service = __webpack_require__(4921);
|
|
1447
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/services/flow-runtime.service.ts
|
|
1448
|
+
var flow_runtime_service = __webpack_require__(2300);
|
|
1449
|
+
;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/flow-engine/flow-rate-limiter.ts
|
|
1450
|
+
const WINDOW_MS = 60_000;
|
|
1451
|
+
const DEFAULT_MAX_KEYS = 10_000;
|
|
1452
|
+
/**
|
|
1453
|
+
* Fixed-window counter per key (flow + caller IP). In memory, so each server instance counts on
|
|
1454
|
+
* its own - a guard against floods and brute-forcing of API keys, not an exact global quota.
|
|
1455
|
+
* A window is re-inserted when it starts, so the map stays ordered by expiry: expired windows are
|
|
1456
|
+
* dropped from the front in amortized O(1), and at `maxKeys` the oldest window is evicted.
|
|
1457
|
+
*/ class FlowRateLimiter {
|
|
1458
|
+
maxKeys;
|
|
1459
|
+
windows = new Map();
|
|
1460
|
+
constructor(maxKeys = DEFAULT_MAX_KEYS){
|
|
1461
|
+
this.maxKeys = maxKeys;
|
|
1462
|
+
}
|
|
1463
|
+
/** @returns true if the call is allowed. limit 0 = unlimited. */ hit(key, limitPerMinute, now = Date.now()) {
|
|
1464
|
+
if (limitPerMinute <= 0) return true;
|
|
1465
|
+
this.dropExpired(now);
|
|
1466
|
+
const current = this.windows.get(key);
|
|
1467
|
+
if (current && current.resetAt > now) {
|
|
1468
|
+
current.count++;
|
|
1469
|
+
return current.count <= limitPerMinute;
|
|
1470
|
+
}
|
|
1471
|
+
if (current) this.windows.delete(key);
|
|
1472
|
+
if (this.windows.size >= this.maxKeys) this.windows.delete(this.windows.keys().next().value);
|
|
1473
|
+
this.windows.set(key, {
|
|
1474
|
+
count: 1,
|
|
1475
|
+
resetAt: now + WINDOW_MS
|
|
1476
|
+
});
|
|
1477
|
+
return true;
|
|
1478
|
+
}
|
|
1479
|
+
get size() {
|
|
1480
|
+
return this.windows.size;
|
|
1481
|
+
}
|
|
1482
|
+
dropExpired(now) {
|
|
1483
|
+
for (const [key, window] of this.windows){
|
|
1484
|
+
if (window.resetAt > now) return;
|
|
1485
|
+
this.windows.delete(key);
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/flow-engine/flow-api-key.ts
|
|
1491
|
+
var flow_api_key = __webpack_require__(4816);
|
|
1492
|
+
// EXTERNAL MODULE: ./projects/nestjs-entity-builder/src/flow-engine/flow.types.ts
|
|
1493
|
+
var flow_types = __webpack_require__(6256);
|
|
1494
|
+
;// CONCATENATED MODULE: ./projects/nestjs-entity-builder/src/guards/flow-access.guard.ts
|
|
1495
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
1496
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1497
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1498
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1499
|
+
} else {
|
|
1500
|
+
for(var i = decorators.length - 1; i >= 0; i--){
|
|
1501
|
+
if (d = decorators[i]) {
|
|
1502
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1507
|
+
}
|
|
1508
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
1509
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1510
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
function _ts_param(paramIndex, decorator) {
|
|
1514
|
+
return function(target, key) {
|
|
1515
|
+
decorator(target, key, paramIndex);
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
|
|
1520
|
+
|
|
1521
|
+
|
|
1522
|
+
|
|
1523
|
+
|
|
1524
|
+
|
|
1525
|
+
|
|
1526
|
+
|
|
1527
|
+
|
|
1528
|
+
|
|
1529
|
+
|
|
1530
|
+
const limiter = new FlowRateLimiter();
|
|
1531
|
+
class FlowAccessGuard {
|
|
1532
|
+
moduleRef;
|
|
1533
|
+
permissionCache;
|
|
1534
|
+
jwtGuard;
|
|
1535
|
+
constructor(moduleRef, permissionCache){
|
|
1536
|
+
this.moduleRef = moduleRef;
|
|
1537
|
+
this.permissionCache = permissionCache;
|
|
1538
|
+
}
|
|
1539
|
+
async canActivate(context) {
|
|
1540
|
+
const request = context.switchToHttp().getRequest();
|
|
1541
|
+
const slug = request.params?.slug;
|
|
1542
|
+
const contextId = core_.ContextIdFactory.getByRequest(request);
|
|
1543
|
+
const runtime = await this.moduleRef.resolve(flow_runtime_service/* .FlowRuntimeService */.a, contextId, {
|
|
1544
|
+
strict: false
|
|
1545
|
+
});
|
|
1546
|
+
const flow = slug ? await runtime.findActive(slug) : null;
|
|
1547
|
+
const endpoint = flow ? (0,flow_types/* .findEndpoint */.vS)(flow, request.params?.endpoint) : undefined;
|
|
1548
|
+
// A Request step for other flows only has no URL: it looks the same as an unknown one.
|
|
1549
|
+
if (!flow || !endpoint || endpoint.authMode === 'internal') throw new common_.NotFoundException({
|
|
1550
|
+
message: 'Not found',
|
|
1551
|
+
messageKey: message_keys/* .FLOW_MESSAGES.NOT_FOUND */.wu.NOT_FOUND
|
|
1552
|
+
});
|
|
1553
|
+
request.flowDefinition = flow;
|
|
1554
|
+
request.flowEndpoint = endpoint;
|
|
1555
|
+
const ip = request.ip ?? request.socket?.remoteAddress ?? 'unknown';
|
|
1556
|
+
if (!limiter.hit(`${flow.id}|${endpoint.nodeId}|${ip}`, endpoint.rateLimitPerMinute)) {
|
|
1557
|
+
throw new common_.HttpException({
|
|
1558
|
+
message: 'Too many requests. Try again in a minute.',
|
|
1559
|
+
messageKey: message_keys/* .FLOW_MESSAGES.RATE_LIMITED */.wu.RATE_LIMITED
|
|
1560
|
+
}, common_.HttpStatus.TOO_MANY_REQUESTS);
|
|
1561
|
+
}
|
|
1562
|
+
switch(endpoint.authMode){
|
|
1563
|
+
case 'public':
|
|
1564
|
+
return true;
|
|
1565
|
+
case 'api_key':
|
|
1566
|
+
{
|
|
1567
|
+
const header = request.headers?.['x-api-key'];
|
|
1568
|
+
if (!(0,flow_api_key/* .apiKeyOpens */.NT)(endpoint.apiKey, Array.isArray(header) ? header[0] : header)) {
|
|
1569
|
+
throw new common_.UnauthorizedException({
|
|
1570
|
+
message: 'A valid API key is required (x-api-key header).',
|
|
1571
|
+
messageKey: message_keys/* .FLOW_MESSAGES.API_KEY_INVALID */.wu.API_KEY_INVALID
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
return true;
|
|
1575
|
+
}
|
|
1576
|
+
case 'jwt':
|
|
1577
|
+
if (!await this.authenticate(context)) return false;
|
|
1578
|
+
return true;
|
|
1579
|
+
case 'permission':
|
|
1580
|
+
{
|
|
1581
|
+
if (!await this.authenticate(context)) return false;
|
|
1582
|
+
await this.permissionCache.assertPermission(request.user, endpoint.permissionCode || (0,flow_definition_service/* .defaultFlowPermissionCode */.Er)(flow.slug));
|
|
1583
|
+
return true;
|
|
1584
|
+
}
|
|
1585
|
+
default:
|
|
1586
|
+
throw new common_.UnauthorizedException({
|
|
1587
|
+
message: 'Authentication required',
|
|
1588
|
+
messageKey: constants_.ERROR_MESSAGES.UNAUTHORIZED
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
async authenticate(context) {
|
|
1593
|
+
this.jwtGuard ??= await this.moduleRef.create(guards_.JwtAuthGuard);
|
|
1594
|
+
const result = this.jwtGuard.canActivate(context);
|
|
1595
|
+
if (typeof result === 'boolean') return result;
|
|
1596
|
+
if (result instanceof Promise) return result;
|
|
1597
|
+
return lastValueFrom(result);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
FlowAccessGuard = _ts_decorate([
|
|
1601
|
+
(0,common_.Injectable)(),
|
|
1602
|
+
_ts_param(0, (0,common_.Inject)(core_.ModuleRef)),
|
|
1603
|
+
_ts_param(1, (0,common_.Inject)(modules_.SharedPermissionCacheService)),
|
|
1604
|
+
_ts_metadata("design:type", Function),
|
|
1605
|
+
_ts_metadata("design:paramtypes", [
|
|
1606
|
+
typeof core_.ModuleRef === "undefined" ? Object : core_.ModuleRef,
|
|
1607
|
+
typeof modules_.SharedPermissionCacheService === "undefined" ? Object : modules_.SharedPermissionCacheService
|
|
1608
|
+
])
|
|
1609
|
+
], FlowAccessGuard);
|
|
1610
|
+
|
|
1611
|
+
|
|
1612
|
+
},
|
|
1613
|
+
3513(module) {
|
|
1614
|
+
|
|
1615
|
+
module.exports = __rspack_external__flusys_nestjs_shared_guards_3f79ddd1;
|
|
1616
|
+
|
|
1617
|
+
|
|
1618
|
+
},
|
|
1619
|
+
|
|
1620
|
+
};
|