@ductape/sdk 0.0.4-v3 → 0.0.4-v31
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/dist/api/services/appApi.service.d.ts +2 -2
- package/dist/api/services/appApi.service.js +1 -2
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/pricingApi.service.d.ts +10 -0
- package/dist/api/services/pricingApi.service.js +34 -0
- package/dist/api/services/pricingApi.service.js.map +1 -0
- package/dist/api/services/processorApi.service.d.ts +12 -2
- package/dist/api/services/processorApi.service.js +12 -2
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +5 -1
- package/dist/api/services/productsApi.service.js +22 -0
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/services/userApi.service.js +1 -0
- package/dist/api/services/userApi.service.js.map +1 -1
- package/dist/api/services/workspaceApi.service.js +1 -0
- package/dist/api/services/workspaceApi.service.js.map +1 -1
- package/dist/api/urls.d.ts +6 -1
- package/dist/api/urls.js +12 -2
- package/dist/api/urls.js.map +1 -1
- package/dist/api/utils/strings.utils.d.ts +2 -0
- package/dist/api/utils/strings.utils.js +14 -0
- package/dist/api/utils/strings.utils.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +9 -1
- package/dist/apps/services/app.service.js +346 -88
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/apps/validators/joi-validators/create.appAction.validator.d.ts +1 -2
- package/dist/apps/validators/joi-validators/create.appAction.validator.js +21 -2
- package/dist/apps/validators/joi-validators/create.appAction.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appAction.validator.js +11 -1
- package/dist/apps/validators/joi-validators/update.appAction.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.d.ts +1 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js +34 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js.map +1 -1
- package/dist/clients/apps.client.js +1 -1
- package/dist/clients/apps.client.js.map +1 -1
- package/dist/clients/pricing.client.d.ts +3 -0
- package/dist/clients/pricing.client.js +33 -0
- package/dist/clients/pricing.client.js.map +1 -0
- package/dist/imports/imports.service.d.ts +3 -3
- package/dist/imports/imports.service.js +7 -7
- package/dist/imports/imports.service.js.map +1 -1
- package/dist/imports/imports.types.d.ts +8 -0
- package/dist/imports/repos/openApi.repo.d.ts +1 -2
- package/dist/imports/repos/openApi.repo.js +43 -71
- package/dist/imports/repos/openApi.repo.js.map +1 -1
- package/dist/imports/repos/postmanV21.repo.d.ts +1 -1
- package/dist/imports/repos/postmanV21.repo.js +29 -2
- package/dist/imports/repos/postmanV21.repo.js.map +1 -1
- package/dist/index.d.ts +965 -47
- package/dist/index.js +924 -81
- package/dist/index.js.map +1 -1
- package/dist/inputs/inputs.service.js +2 -2
- package/dist/inputs/inputs.service.js.map +1 -1
- package/dist/inputs/utils/inputs.utils.create.js +1 -1
- package/dist/inputs/utils/inputs.utils.create.js.map +1 -1
- package/dist/logs/logs.service.js +1 -0
- package/dist/logs/logs.service.js.map +1 -1
- package/dist/logs/logs.types.d.ts +5 -0
- package/dist/logs/logs.types.js.map +1 -1
- package/dist/parsers/index.d.ts +3 -0
- package/dist/parsers/index.js +27 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/pipelines/postman.pipelines.d.ts +15 -0
- package/dist/parsers/pipelines/postman.pipelines.js +103 -0
- package/dist/parsers/pipelines/postman.pipelines.js.map +1 -0
- package/dist/parsers/types/postman.types.d.ts +200 -0
- package/dist/parsers/types/postman.types.js +3 -0
- package/dist/parsers/types/postman.types.js.map +1 -0
- package/dist/parsers/utils/postman.utils.d.ts +12 -0
- package/dist/parsers/utils/postman.utils.js +116 -0
- package/dist/parsers/utils/postman.utils.js.map +1 -0
- package/dist/parsers/validators/postman-auth.validators.d.ts +10 -0
- package/dist/parsers/validators/postman-auth.validators.js +127 -0
- package/dist/parsers/validators/postman-auth.validators.js.map +1 -0
- package/dist/parsers/validators/postman-request.validators.d.ts +13 -0
- package/dist/parsers/validators/postman-request.validators.js +139 -0
- package/dist/parsers/validators/postman-request.validators.js.map +1 -0
- package/dist/parsers/validators/postman-response.validators.d.ts +13 -0
- package/dist/parsers/validators/postman-response.validators.js +150 -0
- package/dist/parsers/validators/postman-response.validators.js.map +1 -0
- package/dist/parsers/validators/postman-variable.validators.d.ts +14 -0
- package/dist/parsers/validators/postman-variable.validators.js +163 -0
- package/dist/parsers/validators/postman-variable.validators.js.map +1 -0
- package/dist/pricing/pricing.repo.d.ts +0 -0
- package/dist/pricing/pricing.repo.js +1 -0
- package/dist/pricing/pricing.repo.js.map +1 -0
- package/dist/pricing/pricing.service.d.ts +24 -0
- package/dist/pricing/pricing.service.js +51 -0
- package/dist/pricing/pricing.service.js.map +1 -0
- package/dist/pricing/pricing.types.d.ts +76 -0
- package/dist/pricing/pricing.types.js +21 -0
- package/dist/pricing/pricing.types.js.map +1 -0
- package/dist/pricing/utils/string.utils.d.ts +1 -0
- package/dist/pricing/utils/string.utils.js +9 -0
- package/dist/pricing/utils/string.utils.js.map +1 -0
- package/dist/processor/repos/sms.repo.d.ts +4 -4
- package/dist/processor/repos/sms.repo.js +23 -10
- package/dist/processor/repos/sms.repo.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +36 -5
- package/dist/processor/services/processor.service.js +568 -201
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/services/request.service.d.ts +36 -0
- package/dist/processor/services/request.service.js +304 -0
- package/dist/processor/services/request.service.js.map +1 -0
- package/dist/processor/types/request.types.d.ts +14 -0
- package/dist/processor/types/request.types.js +3 -0
- package/dist/processor/types/request.types.js.map +1 -0
- package/dist/processor/utils/processor.utils.d.ts +3 -0
- package/dist/processor/utils/processor.utils.js +88 -5
- package/dist/processor/utils/processor.utils.js.map +1 -1
- package/dist/processor/utils/request.utils.d.ts +20 -0
- package/dist/processor/utils/request.utils.js +113 -0
- package/dist/processor/utils/request.utils.js.map +1 -0
- package/dist/processor/utils/storage.util.js +54 -40
- package/dist/processor/utils/storage.util.js.map +1 -1
- package/dist/products/services/products.service.d.ts +20 -7
- package/dist/products/services/products.service.js +269 -43
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/utils/string.utils.d.ts +1 -1
- package/dist/products/utils/string.utils.js +14 -2
- package/dist/products/utils/string.utils.js.map +1 -1
- package/dist/products/validators/index.d.ts +2 -1
- package/dist/products/validators/index.js +3 -1
- package/dist/products/validators/index.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productEnv.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.productEnv.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.d.ts +4 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js +58 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.userAuth.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.userAuth.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.dataValue.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.dataValue.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productEnv.validator.js +3 -0
- package/dist/products/validators/joi-validators/update.productEnv.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.userAuth.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.userAuth.validator.js.map +1 -1
- package/dist/test/test.health.d.ts +1 -0
- package/dist/test/test.health.js +49 -0
- package/dist/test/test.health.js.map +1 -0
- package/dist/test/test.import.js +51 -4
- package/dist/test/test.import.js.map +1 -1
- package/dist/test/test.imports.js +22 -7
- package/dist/test/test.imports.js.map +1 -1
- package/dist/test/test.processor.js +32 -115
- package/dist/test/test.processor.js.map +1 -1
- package/dist/test/test.products.d.ts +1 -0
- package/dist/test/test.products.js +49 -0
- package/dist/test/test.products.js.map +1 -0
- package/dist/types/appBuilder.types.d.ts +4 -11
- package/dist/types/enums.d.ts +3 -1
- package/dist/types/enums.js +2 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/index.types.d.ts +4 -0
- package/dist/types/pricing.types.d.ts +4 -0
- package/dist/types/pricing.types.js +3 -0
- package/dist/types/pricing.types.js.map +1 -0
- package/dist/types/processor.types.d.ts +66 -9
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +52 -5
- package/dist/types/productsBuilder.types.js +9 -1
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/dist/types/request-tracker.interface.d.ts +0 -0
- package/dist/types/request-tracker.interface.js +1 -0
- package/dist/types/request-tracker.interface.js.map +1 -0
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +5 -0
- package/dist/utils/constants.js.map +1 -0
- package/package.json +14 -3
|
@@ -179,33 +179,221 @@ class AppBuilderService {
|
|
|
179
179
|
},
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
|
+
// Helper function to merge metadata into parsed schema data
|
|
183
|
+
mergeMetadataIntoSchema(parsedData, metadataMap) {
|
|
184
|
+
if (!metadataMap || Object.keys(metadataMap).length === 0) {
|
|
185
|
+
return parsedData;
|
|
186
|
+
}
|
|
187
|
+
return parsedData.map(item => {
|
|
188
|
+
const metadata = metadataMap[item.key || ''];
|
|
189
|
+
if (metadata) {
|
|
190
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, item), (metadata.minLength !== undefined ? { minLength: metadata.minLength } : {})), (metadata.maxLength !== undefined ? { maxLength: metadata.maxLength } : {})), (metadata.required !== undefined ? { required: metadata.required } : {})), (metadata.type !== undefined ? { type: metadata.type } : {}));
|
|
191
|
+
}
|
|
192
|
+
return item;
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
// Helper function to merge nested metadata for body fields
|
|
196
|
+
mergeNestedBodyMetadata(parsedData, fieldsMetadata) {
|
|
197
|
+
if (!fieldsMetadata || Object.keys(fieldsMetadata).length === 0) {
|
|
198
|
+
return parsedData;
|
|
199
|
+
}
|
|
200
|
+
const applyMetadataRecursively = (data, pathPrefix = '') => {
|
|
201
|
+
return data.map((item) => {
|
|
202
|
+
const fullPath = pathPrefix ? `${pathPrefix}.${item.key}` : item.key;
|
|
203
|
+
const metadata = fieldsMetadata[fullPath];
|
|
204
|
+
let updatedItem = Object.assign({}, item);
|
|
205
|
+
if (metadata) {
|
|
206
|
+
updatedItem = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, updatedItem), (metadata.minLength !== undefined ? { minLength: metadata.minLength } : {})), (metadata.maxLength !== undefined ? { maxLength: metadata.maxLength } : {})), (metadata.required !== undefined ? { required: metadata.required } : {})), (metadata.type !== undefined ? { type: metadata.type } : {}));
|
|
207
|
+
}
|
|
208
|
+
// Recursively apply to nested data (if the parsed item has nested structure)
|
|
209
|
+
if (updatedItem.data && Array.isArray(updatedItem.data) && updatedItem.data.length > 0) {
|
|
210
|
+
updatedItem.data = applyMetadataRecursively(updatedItem.data, fullPath);
|
|
211
|
+
}
|
|
212
|
+
return updatedItem;
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
return applyMetadataRecursively(parsedData);
|
|
216
|
+
}
|
|
182
217
|
async createAction(data, throwErrorIfExists = false) {
|
|
218
|
+
// Validate schema
|
|
219
|
+
await validators_1.CreateAppActionSchema.validateAsync(data);
|
|
220
|
+
data.tag = (0, string_utils_1.tagify)(data.tag);
|
|
221
|
+
const { tag } = data;
|
|
222
|
+
// Check if action already exists
|
|
223
|
+
let exists;
|
|
183
224
|
try {
|
|
184
|
-
|
|
185
|
-
if (!data.resource)
|
|
186
|
-
throw new Error('resource is required');
|
|
187
|
-
data.resource = (0, strings_utils_1.extractURLPath)(url);
|
|
188
|
-
await validators_1.CreateAppActionSchema.validateAsync(data);
|
|
189
|
-
data.tag = (0, string_utils_1.tagify)(data.tag);
|
|
190
|
-
const { tag } = data;
|
|
191
|
-
let exists;
|
|
192
|
-
try {
|
|
193
|
-
exists = this.fetchAction(tag);
|
|
194
|
-
}
|
|
195
|
-
catch (e) {
|
|
196
|
-
exists = false;
|
|
197
|
-
}
|
|
198
|
-
if (!exists) {
|
|
199
|
-
data.resource = url;
|
|
200
|
-
//await this.updateActionProcess(tag, { ...data }, RequestAction.CREATE);
|
|
201
|
-
}
|
|
202
|
-
if (exists && throwErrorIfExists) {
|
|
203
|
-
throw new Error(`App action ${tag} already exists`);
|
|
204
|
-
}
|
|
225
|
+
exists = this.fetchAction(tag);
|
|
205
226
|
}
|
|
206
227
|
catch (e) {
|
|
207
|
-
|
|
228
|
+
exists = false;
|
|
229
|
+
}
|
|
230
|
+
if (exists && throwErrorIfExists) {
|
|
231
|
+
throw new Error(`App action ${tag} already exists`);
|
|
232
|
+
}
|
|
233
|
+
if (exists) {
|
|
234
|
+
return; // Silently skip if already exists and not throwing error
|
|
235
|
+
}
|
|
236
|
+
// Build the action body (similar to updateAction but without fetching existing action)
|
|
237
|
+
const body = {
|
|
238
|
+
tag: data.tag,
|
|
239
|
+
name: data.name,
|
|
240
|
+
method: data.method,
|
|
241
|
+
request_type: data.request_type || types_1.DataFormats.JSON,
|
|
242
|
+
description: data.description || '',
|
|
243
|
+
responses: []
|
|
244
|
+
};
|
|
245
|
+
// Batch all parsing operations for parallel execution
|
|
246
|
+
const parseOperations = [];
|
|
247
|
+
const parseKeys = [];
|
|
248
|
+
// Prepare params parsing
|
|
249
|
+
if (data.params) {
|
|
250
|
+
parseKeys.push('params');
|
|
251
|
+
parseOperations.push(this.inputsService.parseJson({
|
|
252
|
+
data: data.params,
|
|
253
|
+
expected: types_1.ExpectedValues.PARSESAMPLE,
|
|
254
|
+
category: types_1.Categories.PARAMS
|
|
255
|
+
}).then(parsedData => ({
|
|
256
|
+
key: 'params',
|
|
257
|
+
parsedData: parsedData,
|
|
258
|
+
metadata: this.extractMetadata(data.params)
|
|
259
|
+
})));
|
|
260
|
+
}
|
|
261
|
+
// Prepare query parsing
|
|
262
|
+
if (data.query) {
|
|
263
|
+
parseKeys.push('query');
|
|
264
|
+
parseOperations.push(this.inputsService.parseJson({
|
|
265
|
+
data: data.query,
|
|
266
|
+
expected: types_1.ExpectedValues.PARSESAMPLE,
|
|
267
|
+
category: types_1.Categories.QUERY
|
|
268
|
+
}).then(parsedData => ({
|
|
269
|
+
key: 'query',
|
|
270
|
+
parsedData: parsedData,
|
|
271
|
+
metadata: this.extractMetadata(data.query)
|
|
272
|
+
})));
|
|
273
|
+
}
|
|
274
|
+
// Prepare body parsing
|
|
275
|
+
if (data.body) {
|
|
276
|
+
const fieldsMetadata = data.body.fieldsMetadata;
|
|
277
|
+
const bodySample = data.body.sample || data.body;
|
|
278
|
+
parseKeys.push('body');
|
|
279
|
+
parseOperations.push(this.inputsService.parseJson({
|
|
280
|
+
data: bodySample,
|
|
281
|
+
expected: types_1.ExpectedValues.PARSESAMPLE,
|
|
282
|
+
category: types_1.Categories.BODY
|
|
283
|
+
}).then(parsedData => ({
|
|
284
|
+
key: 'body',
|
|
285
|
+
parsedData: parsedData,
|
|
286
|
+
fieldsMetadata,
|
|
287
|
+
bodySample,
|
|
288
|
+
metadata: fieldsMetadata ? null : this.extractMetadata(data.body)
|
|
289
|
+
})));
|
|
290
|
+
}
|
|
291
|
+
// Prepare headers parsing
|
|
292
|
+
if (data.headers) {
|
|
293
|
+
parseKeys.push('headers');
|
|
294
|
+
parseOperations.push(this.inputsService.parseJson({
|
|
295
|
+
data: data.headers,
|
|
296
|
+
expected: types_1.ExpectedValues.PARSESAMPLE,
|
|
297
|
+
category: types_1.Categories.HEADER
|
|
298
|
+
}).then(parsedData => ({
|
|
299
|
+
key: 'headers',
|
|
300
|
+
parsedData: parsedData,
|
|
301
|
+
metadata: this.extractMetadata(data.headers)
|
|
302
|
+
})));
|
|
303
|
+
}
|
|
304
|
+
// Prepare response parsing
|
|
305
|
+
if (data.response) {
|
|
306
|
+
parseKeys.push('response');
|
|
307
|
+
parseOperations.push(this.inputsService.parseJson({
|
|
308
|
+
data: data.response.body,
|
|
309
|
+
expected: types_1.ExpectedValues.PARSESAMPLE
|
|
310
|
+
}).then(parsedData => ({
|
|
311
|
+
key: 'response',
|
|
312
|
+
parsedData: parsedData
|
|
313
|
+
})));
|
|
314
|
+
}
|
|
315
|
+
// Execute all parsing operations in parallel
|
|
316
|
+
const parseResults = await Promise.all(parseOperations);
|
|
317
|
+
// Process parsed results
|
|
318
|
+
for (const result of parseResults) {
|
|
319
|
+
switch (result.key) {
|
|
320
|
+
case 'params':
|
|
321
|
+
body.params = {
|
|
322
|
+
type: types_1.InputsTypes.JSON,
|
|
323
|
+
sample: JSON.stringify(data.params),
|
|
324
|
+
data: this.mergeMetadataIntoSchema(result.parsedData, result.metadata)
|
|
325
|
+
};
|
|
326
|
+
break;
|
|
327
|
+
case 'query':
|
|
328
|
+
body.query = {
|
|
329
|
+
type: types_1.InputsTypes.JSON,
|
|
330
|
+
sample: JSON.stringify(data.query),
|
|
331
|
+
data: this.mergeMetadataIntoSchema(result.parsedData, result.metadata)
|
|
332
|
+
};
|
|
333
|
+
break;
|
|
334
|
+
case 'body':
|
|
335
|
+
let finalData = result.parsedData;
|
|
336
|
+
if (result.fieldsMetadata) {
|
|
337
|
+
finalData = this.mergeNestedBodyMetadata(result.parsedData, result.fieldsMetadata);
|
|
338
|
+
}
|
|
339
|
+
else if (result.metadata && Object.keys(result.metadata).length > 0) {
|
|
340
|
+
finalData = this.mergeMetadataIntoSchema(result.parsedData, result.metadata);
|
|
341
|
+
}
|
|
342
|
+
body.body = {
|
|
343
|
+
type: types_1.InputsTypes.JSON,
|
|
344
|
+
sample: JSON.stringify(result.bodySample),
|
|
345
|
+
data: finalData
|
|
346
|
+
};
|
|
347
|
+
break;
|
|
348
|
+
case 'headers':
|
|
349
|
+
body.headers = {
|
|
350
|
+
type: types_1.InputsTypes.JSON,
|
|
351
|
+
sample: JSON.stringify(data.headers),
|
|
352
|
+
data: this.mergeMetadataIntoSchema(result.parsedData, result.metadata)
|
|
353
|
+
};
|
|
354
|
+
break;
|
|
355
|
+
case 'response':
|
|
356
|
+
const response = {
|
|
357
|
+
name: data.response.name || `Response - ${data.response.status_code}`,
|
|
358
|
+
tag: data.tag,
|
|
359
|
+
response_format: data.response.response_format,
|
|
360
|
+
status_code: data.response.status_code,
|
|
361
|
+
success: data.response.success,
|
|
362
|
+
body: {
|
|
363
|
+
sample: JSON.stringify(data.response.body),
|
|
364
|
+
type: types_1.InputsTypes.JSON,
|
|
365
|
+
data: result.parsedData,
|
|
366
|
+
status_code: data.response.status_code,
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
body.responses = [response];
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
208
372
|
}
|
|
373
|
+
// Handle resource URL parsing (only if not already provided params/query)
|
|
374
|
+
if (data.resource) {
|
|
375
|
+
const { params, query: queryData } = await this.extractResourceData(data.resource);
|
|
376
|
+
body.resource = (0, strings_utils_1.extractURLPath)(data.resource);
|
|
377
|
+
// Merge resource-extracted params/query with existing ones
|
|
378
|
+
body.params = Object.assign(Object.assign({}, body.params), params);
|
|
379
|
+
body.query = Object.assign(Object.assign({}, body.query), queryData);
|
|
380
|
+
}
|
|
381
|
+
// Create action via API
|
|
382
|
+
await this.updateActionProcess(tag, body, types_1.RequestAction.CREATE);
|
|
383
|
+
// Update local cache instead of full app refetch
|
|
384
|
+
this.appVersion.actions.push(body);
|
|
385
|
+
}
|
|
386
|
+
// Helper method to extract metadata from data object
|
|
387
|
+
extractMetadata(data) {
|
|
388
|
+
const metadataMap = {};
|
|
389
|
+
if (data && data.data && Array.isArray(data.data)) {
|
|
390
|
+
data.data.forEach((item) => {
|
|
391
|
+
if (item.metadata) {
|
|
392
|
+
metadataMap[item.key] = item.metadata;
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
return metadataMap;
|
|
209
397
|
}
|
|
210
398
|
fetchActions() {
|
|
211
399
|
return this.appVersion.actions;
|
|
@@ -217,99 +405,167 @@ class AppBuilderService {
|
|
|
217
405
|
return action;
|
|
218
406
|
}
|
|
219
407
|
async updateAction(tag, data) {
|
|
408
|
+
// Validate schema
|
|
220
409
|
await validators_1.UpdateAppActionSchema.validateAsync(data);
|
|
221
410
|
const action = this.fetchAction(tag);
|
|
222
411
|
const body = action;
|
|
223
412
|
if (!action) {
|
|
224
413
|
throw new Error(`Action ${tag} not found`);
|
|
225
414
|
}
|
|
415
|
+
// Batch all parsing operations for parallel execution
|
|
416
|
+
const parseOperations = [];
|
|
417
|
+
// Prepare params parsing
|
|
226
418
|
if (data.params) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
419
|
+
parseOperations.push(this.inputsService.parseJson({
|
|
420
|
+
data: data.params,
|
|
421
|
+
expected: types_1.ExpectedValues.PARSESAMPLE,
|
|
422
|
+
category: types_1.Categories.PARAMS
|
|
423
|
+
}).then(parsedData => ({
|
|
424
|
+
key: 'params',
|
|
425
|
+
parsedData: parsedData
|
|
426
|
+
})));
|
|
232
427
|
}
|
|
428
|
+
// Prepare query parsing
|
|
233
429
|
if (data.query) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
430
|
+
parseOperations.push(this.inputsService.parseJson({
|
|
431
|
+
data: data.query,
|
|
432
|
+
expected: types_1.ExpectedValues.PARSESAMPLE,
|
|
433
|
+
category: types_1.Categories.QUERY
|
|
434
|
+
}).then(parsedData => ({
|
|
435
|
+
key: 'query',
|
|
436
|
+
parsedData: parsedData
|
|
437
|
+
})));
|
|
239
438
|
}
|
|
439
|
+
// Prepare body parsing
|
|
240
440
|
if (data.body) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
441
|
+
parseOperations.push(this.inputsService.parseJson({
|
|
442
|
+
data: data.body,
|
|
443
|
+
expected: types_1.ExpectedValues.PARSESAMPLE,
|
|
444
|
+
category: types_1.Categories.BODY
|
|
445
|
+
}).then(parsedData => ({
|
|
446
|
+
key: 'body',
|
|
447
|
+
parsedData: parsedData
|
|
448
|
+
})));
|
|
246
449
|
}
|
|
450
|
+
// Prepare headers parsing
|
|
247
451
|
if (data.headers) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
452
|
+
parseOperations.push(this.inputsService.parseJson({
|
|
453
|
+
data: data.headers,
|
|
454
|
+
expected: types_1.ExpectedValues.PARSESAMPLE,
|
|
455
|
+
category: types_1.Categories.HEADER
|
|
456
|
+
}).then(parsedData => ({
|
|
457
|
+
key: 'headers',
|
|
458
|
+
parsedData: parsedData
|
|
459
|
+
})));
|
|
253
460
|
}
|
|
461
|
+
// Prepare response parsing
|
|
462
|
+
if (data.response) {
|
|
463
|
+
parseOperations.push(this.inputsService.parseJson({
|
|
464
|
+
data: data.response.body,
|
|
465
|
+
expected: types_1.ExpectedValues.PARSESAMPLE
|
|
466
|
+
}).then(parsedData => ({
|
|
467
|
+
key: 'response',
|
|
468
|
+
parsedData: parsedData
|
|
469
|
+
})));
|
|
470
|
+
}
|
|
471
|
+
// Execute all parsing operations in parallel
|
|
472
|
+
const parseResults = await Promise.all(parseOperations);
|
|
473
|
+
// Process parsed results
|
|
474
|
+
for (const result of parseResults) {
|
|
475
|
+
switch (result.key) {
|
|
476
|
+
case 'params':
|
|
477
|
+
body.params = {
|
|
478
|
+
type: types_1.InputsTypes.JSON,
|
|
479
|
+
sample: JSON.stringify(data.params),
|
|
480
|
+
data: result.parsedData
|
|
481
|
+
};
|
|
482
|
+
break;
|
|
483
|
+
case 'query':
|
|
484
|
+
body.query = {
|
|
485
|
+
type: types_1.InputsTypes.JSON,
|
|
486
|
+
sample: JSON.stringify(data.query),
|
|
487
|
+
data: result.parsedData
|
|
488
|
+
};
|
|
489
|
+
break;
|
|
490
|
+
case 'body':
|
|
491
|
+
body.body = {
|
|
492
|
+
type: types_1.InputsTypes.JSON,
|
|
493
|
+
sample: JSON.stringify(data.body),
|
|
494
|
+
data: result.parsedData
|
|
495
|
+
};
|
|
496
|
+
break;
|
|
497
|
+
case 'headers':
|
|
498
|
+
body.headers = {
|
|
499
|
+
type: types_1.InputsTypes.JSON,
|
|
500
|
+
sample: JSON.stringify(data.headers),
|
|
501
|
+
data: result.parsedData
|
|
502
|
+
};
|
|
503
|
+
break;
|
|
504
|
+
case 'response':
|
|
505
|
+
body.responses = action.responses;
|
|
506
|
+
const response = {
|
|
507
|
+
name: `Response - ${data.response.status_code}`,
|
|
508
|
+
response_format: data.response.response_format,
|
|
509
|
+
status_code: data.response.status_code,
|
|
510
|
+
success: data.response.success,
|
|
511
|
+
body: {
|
|
512
|
+
sample: JSON.stringify(data.response.body),
|
|
513
|
+
type: types_1.InputsTypes.JSON,
|
|
514
|
+
data: result.parsedData,
|
|
515
|
+
status_code: data.response.status_code,
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
const statusIndex = body.responses.findIndex((resp) => resp.status_code === data.response.status_code);
|
|
519
|
+
if (data.response.success === true) {
|
|
520
|
+
const index = action.responses.findIndex((resp) => resp.success === true);
|
|
521
|
+
if (index > -1) {
|
|
522
|
+
body.responses[index] = response;
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
if (statusIndex > -1) {
|
|
526
|
+
body.responses.splice(statusIndex, 1);
|
|
527
|
+
}
|
|
528
|
+
body.responses.push(response);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
if (statusIndex > -1) {
|
|
533
|
+
body.responses.splice(statusIndex, 1);
|
|
534
|
+
}
|
|
535
|
+
body.responses.push(response);
|
|
536
|
+
}
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
// Handle resource URL parsing
|
|
254
541
|
if (data.resource) {
|
|
255
542
|
const { params, query: queryData } = await this.extractResourceData(data.resource);
|
|
256
543
|
body.resource = (0, strings_utils_1.extractURLPath)(data.resource);
|
|
544
|
+
// Merge resource-extracted params/query with existing ones
|
|
257
545
|
body.params = Object.assign(Object.assign({}, body.params), params);
|
|
258
546
|
body.query = Object.assign(Object.assign({}, body.query), queryData);
|
|
259
547
|
}
|
|
548
|
+
// Update simple fields
|
|
260
549
|
if (data.description) {
|
|
261
550
|
body.description = data.description;
|
|
262
551
|
}
|
|
263
|
-
/*if(body.description === ''){
|
|
264
|
-
body.description = undefined
|
|
265
|
-
}*/
|
|
266
552
|
if (data.method) {
|
|
267
553
|
body.method = data.method;
|
|
268
554
|
}
|
|
269
555
|
if (data.request_type) {
|
|
270
556
|
body.request_type = data.request_type;
|
|
271
557
|
}
|
|
272
|
-
|
|
273
|
-
body.responses = action.responses;
|
|
274
|
-
const response = {
|
|
275
|
-
name: `Response - ${data.response.status_code}`,
|
|
276
|
-
response_format: data.response.response_format,
|
|
277
|
-
status_code: data.response.status_code,
|
|
278
|
-
success: data.response.success,
|
|
279
|
-
body: {
|
|
280
|
-
sample: JSON.stringify(data.response.body),
|
|
281
|
-
type: types_1.InputsTypes.JSON,
|
|
282
|
-
data: await this.inputsService.parseJson({
|
|
283
|
-
data: data.response.body,
|
|
284
|
-
expected: types_1.ExpectedValues.PARSESAMPLE
|
|
285
|
-
}),
|
|
286
|
-
status_code: data.response.status_code,
|
|
287
|
-
}
|
|
288
|
-
};
|
|
289
|
-
const statusIndex = body.responses.findIndex((resp) => resp.status_code === data.response.status_code);
|
|
290
|
-
if (data.response.success === true) {
|
|
291
|
-
const index = action.responses.findIndex((resp) => resp.success === true);
|
|
292
|
-
if (index > -1) {
|
|
293
|
-
body.responses[index] = response;
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
if (statusIndex > -1) {
|
|
297
|
-
body.responses.splice(statusIndex, 1);
|
|
298
|
-
}
|
|
299
|
-
body.responses.push(response);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
if (statusIndex > -1) {
|
|
304
|
-
body.responses.splice(statusIndex, 1);
|
|
305
|
-
}
|
|
306
|
-
body.responses.push(response);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
558
|
+
// Update action via API
|
|
309
559
|
await this.updateActionProcess(tag, body, types_1.RequestAction.UPDATE);
|
|
560
|
+
// Update local cache instead of full app refetch
|
|
561
|
+
const actionIndex = this.appVersion.actions.findIndex(a => a.tag === tag || a._id === action._id);
|
|
562
|
+
if (actionIndex > -1) {
|
|
563
|
+
this.appVersion.actions[actionIndex] = body;
|
|
564
|
+
}
|
|
310
565
|
}
|
|
311
566
|
async updateActionProcess(tag, data, action) {
|
|
312
|
-
const query = Object.assign({ component: types_1.AppComponents.ACTION, action
|
|
567
|
+
const query = Object.assign({ component: types_1.AppComponents.ACTION, action,
|
|
568
|
+
tag }, data);
|
|
313
569
|
await this.appApi.updateApp(this.app_id, query, this.getUserAccess());
|
|
314
570
|
}
|
|
315
571
|
async createActionRequestData(category, tag, payload, throwErrorIfExists = false) {
|
|
@@ -747,17 +1003,19 @@ class AppBuilderService {
|
|
|
747
1003
|
if (stages.length === 0) {
|
|
748
1004
|
throw new Error(`Missing locators in ${locator}`);
|
|
749
1005
|
}
|
|
1006
|
+
// Convert stages to string[] for functions expecting string[]
|
|
1007
|
+
const stringStages = stages.map(stage => String(stage));
|
|
750
1008
|
if (locator.startsWith('$Body{')) {
|
|
751
|
-
await this.updateValidation(types_1.AppCategories.BODY,
|
|
1009
|
+
await this.updateValidation(types_1.AppCategories.BODY, stringStages, update);
|
|
752
1010
|
}
|
|
753
1011
|
else if (locator.startsWith('$Query{')) {
|
|
754
|
-
await this.updateValidation(types_1.AppCategories.QUERY,
|
|
1012
|
+
await this.updateValidation(types_1.AppCategories.QUERY, stringStages, update);
|
|
755
1013
|
}
|
|
756
1014
|
else if (locator.startsWith('$Params{')) {
|
|
757
|
-
await this.updateValidation(types_1.AppCategories.PARAMS,
|
|
1015
|
+
await this.updateValidation(types_1.AppCategories.PARAMS, stringStages, update);
|
|
758
1016
|
}
|
|
759
1017
|
else if (locator.startsWith('$Header{')) {
|
|
760
|
-
await this.updateValidation(types_1.AppCategories.HEADER,
|
|
1018
|
+
await this.updateValidation(types_1.AppCategories.HEADER, stringStages, update);
|
|
761
1019
|
}
|
|
762
1020
|
else {
|
|
763
1021
|
throw new Error(`Invalid input ${locator}`);
|
|
@@ -805,7 +1063,7 @@ class AppBuilderService {
|
|
|
805
1063
|
'responses',
|
|
806
1064
|
...exclude,
|
|
807
1065
|
]);
|
|
808
|
-
await this.appApi.updateApp(this.app_id, Object.assign(Object.assign({ tag: action_tag },
|
|
1066
|
+
await this.appApi.updateApp(this.app_id, Object.assign(Object.assign({ tag: action_tag }, action), { component: types_1.AppComponents.VALIDATION, action: types_1.RequestAction.UPDATE }), this.getUserAccess());
|
|
809
1067
|
await this.initializeApp(this.app_id);
|
|
810
1068
|
}
|
|
811
1069
|
catch (e) {
|