@aemforms/af-core 0.22.161 → 0.22.162
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/esm/afb-runtime.js
CHANGED
|
@@ -2935,6 +2935,9 @@ const request = async (context, uri, httpVerb, payload, success, error, headers)
|
|
|
2935
2935
|
if (payload.body && payload.headers) {
|
|
2936
2936
|
encryptOutput = { ...payload };
|
|
2937
2937
|
headers = { ...payload.headers };
|
|
2938
|
+
if (payload.options && typeof payload.options === 'object') {
|
|
2939
|
+
Object.assign(requestOptions, payload.options);
|
|
2940
|
+
}
|
|
2938
2941
|
payload = payload.body;
|
|
2939
2942
|
cryptoMetadata = payload.cryptoMetadata;
|
|
2940
2943
|
inputPayload = payload;
|
|
@@ -3227,6 +3230,47 @@ class FunctionRuntimeImpl {
|
|
|
3227
3230
|
filesMap[qualifiedName] = field.serialize();
|
|
3228
3231
|
}
|
|
3229
3232
|
return filesMap;
|
|
3233
|
+
},
|
|
3234
|
+
setVariable: (variableName, variableValue, target) => {
|
|
3235
|
+
const args = [variableName, variableValue, target];
|
|
3236
|
+
return FunctionRuntimeImpl.getInstance().getFunctions().setVariable._func.call(undefined, args, data, interpreter);
|
|
3237
|
+
},
|
|
3238
|
+
getVariable: (variableName, target) => {
|
|
3239
|
+
const args = [variableName, target];
|
|
3240
|
+
return FunctionRuntimeImpl.getInstance().getFunctions().getVariable._func.call(undefined, args, data, interpreter);
|
|
3241
|
+
},
|
|
3242
|
+
request: async (options) => {
|
|
3243
|
+
const { url, method = 'GET', body: requestBody = {}, headers = { 'Content-Type': 'application/json' }, options: fetchOptions } = options;
|
|
3244
|
+
const funcs = FunctionRuntimeImpl.getInstance().getFunctions();
|
|
3245
|
+
const externalizedUrl = funcs.externalize._func.call(undefined, [url], data, interpreter);
|
|
3246
|
+
const random = Math.floor(Math.random() * 1000000);
|
|
3247
|
+
const now = Date.now();
|
|
3248
|
+
const internalSuccess = `custom:__internalSuccess_${random}_${now}`;
|
|
3249
|
+
const internalError = `custom:__internalError_${random}_${now}`;
|
|
3250
|
+
const encryptPayload = { body: requestBody, headers };
|
|
3251
|
+
if (fetchOptions) {
|
|
3252
|
+
encryptPayload.options = fetchOptions;
|
|
3253
|
+
}
|
|
3254
|
+
const payload = await funcs.encrypt._func.call(undefined, [encryptPayload], data, interpreter);
|
|
3255
|
+
const requestArgs = [externalizedUrl, method, payload, internalSuccess, internalError];
|
|
3256
|
+
const requestFn = funcs.requestWithRetry._func.call(undefined, requestArgs, data, interpreter);
|
|
3257
|
+
const response = await funcs.retryHandler._func.call(undefined, [requestFn], data, interpreter);
|
|
3258
|
+
const isSuccess = response?.status >= 200 && response?.status <= 299;
|
|
3259
|
+
if (isSuccess && response?.body) {
|
|
3260
|
+
const decryptedBody = await funcs.decrypt._func.call(undefined, [response.body, response.originalRequest], data, interpreter);
|
|
3261
|
+
return {
|
|
3262
|
+
ok: true,
|
|
3263
|
+
status: response.status,
|
|
3264
|
+
body: decryptedBody,
|
|
3265
|
+
headers: response.headers
|
|
3266
|
+
};
|
|
3267
|
+
}
|
|
3268
|
+
return {
|
|
3269
|
+
ok: isSuccess,
|
|
3270
|
+
status: response?.status,
|
|
3271
|
+
body: response?.body,
|
|
3272
|
+
headers: response?.headers
|
|
3273
|
+
};
|
|
3230
3274
|
}
|
|
3231
3275
|
}
|
|
3232
3276
|
};
|
|
@@ -3550,6 +3594,13 @@ class FunctionRuntimeImpl {
|
|
|
3550
3594
|
},
|
|
3551
3595
|
_signature: []
|
|
3552
3596
|
},
|
|
3597
|
+
externalize: {
|
|
3598
|
+
_func: (args, data, interpreter) => {
|
|
3599
|
+
const url = toString(args[0]);
|
|
3600
|
+
return url;
|
|
3601
|
+
},
|
|
3602
|
+
_signature: []
|
|
3603
|
+
},
|
|
3553
3604
|
awaitFn: {
|
|
3554
3605
|
_func: async (args, data, interpreter) => {
|
|
3555
3606
|
const success = args[1];
|
|
@@ -67,6 +67,10 @@ declare class FunctionRuntimeImpl {
|
|
|
67
67
|
_func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
|
|
68
68
|
_signature: never[];
|
|
69
69
|
};
|
|
70
|
+
externalize: {
|
|
71
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => string;
|
|
72
|
+
_signature: never[];
|
|
73
|
+
};
|
|
70
74
|
awaitFn: {
|
|
71
75
|
_func: (args: Array<unknown>, data: unknown, interpreter: any) => Promise<{}>;
|
|
72
76
|
_signature: never[];
|
|
@@ -67,6 +67,10 @@ declare class FunctionRuntimeImpl {
|
|
|
67
67
|
_func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
|
|
68
68
|
_signature: never[];
|
|
69
69
|
};
|
|
70
|
+
externalize: {
|
|
71
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => string;
|
|
72
|
+
_signature: never[];
|
|
73
|
+
};
|
|
70
74
|
awaitFn: {
|
|
71
75
|
_func: (args: Array<unknown>, data: unknown, interpreter: any) => Promise<{}>;
|
|
72
76
|
_signature: never[];
|
|
@@ -50,6 +50,9 @@ const request = (context, uri, httpVerb, payload, success, error, headers) => __
|
|
|
50
50
|
if (payload.body && payload.headers) {
|
|
51
51
|
encryptOutput = Object.assign({}, payload);
|
|
52
52
|
headers = Object.assign({}, payload.headers);
|
|
53
|
+
if (payload.options && typeof payload.options === 'object') {
|
|
54
|
+
Object.assign(requestOptions, payload.options);
|
|
55
|
+
}
|
|
53
56
|
payload = payload.body;
|
|
54
57
|
cryptoMetadata = payload.cryptoMetadata;
|
|
55
58
|
inputPayload = payload;
|
|
@@ -329,7 +332,48 @@ class FunctionRuntimeImpl {
|
|
|
329
332
|
filesMap[qualifiedName] = field.serialize();
|
|
330
333
|
}
|
|
331
334
|
return filesMap;
|
|
332
|
-
}
|
|
335
|
+
},
|
|
336
|
+
setVariable: (variableName, variableValue, target) => {
|
|
337
|
+
const args = [variableName, variableValue, target];
|
|
338
|
+
return FunctionRuntimeImpl.getInstance().getFunctions().setVariable._func.call(undefined, args, data, interpreter);
|
|
339
|
+
},
|
|
340
|
+
getVariable: (variableName, target) => {
|
|
341
|
+
const args = [variableName, target];
|
|
342
|
+
return FunctionRuntimeImpl.getInstance().getFunctions().getVariable._func.call(undefined, args, data, interpreter);
|
|
343
|
+
},
|
|
344
|
+
request: (options) => __awaiter(this, void 0, void 0, function* () {
|
|
345
|
+
const { url, method = 'GET', body: requestBody = {}, headers = { 'Content-Type': 'application/json' }, options: fetchOptions } = options;
|
|
346
|
+
const funcs = FunctionRuntimeImpl.getInstance().getFunctions();
|
|
347
|
+
const externalizedUrl = funcs.externalize._func.call(undefined, [url], data, interpreter);
|
|
348
|
+
const random = Math.floor(Math.random() * 1000000);
|
|
349
|
+
const now = Date.now();
|
|
350
|
+
const internalSuccess = `custom:__internalSuccess_${random}_${now}`;
|
|
351
|
+
const internalError = `custom:__internalError_${random}_${now}`;
|
|
352
|
+
const encryptPayload = { body: requestBody, headers };
|
|
353
|
+
if (fetchOptions) {
|
|
354
|
+
encryptPayload.options = fetchOptions;
|
|
355
|
+
}
|
|
356
|
+
const payload = yield funcs.encrypt._func.call(undefined, [encryptPayload], data, interpreter);
|
|
357
|
+
const requestArgs = [externalizedUrl, method, payload, internalSuccess, internalError];
|
|
358
|
+
const requestFn = funcs.requestWithRetry._func.call(undefined, requestArgs, data, interpreter);
|
|
359
|
+
const response = yield funcs.retryHandler._func.call(undefined, [requestFn], data, interpreter);
|
|
360
|
+
const isSuccess = (response === null || response === void 0 ? void 0 : response.status) >= 200 && (response === null || response === void 0 ? void 0 : response.status) <= 299;
|
|
361
|
+
if (isSuccess && (response === null || response === void 0 ? void 0 : response.body)) {
|
|
362
|
+
const decryptedBody = yield funcs.decrypt._func.call(undefined, [response.body, response.originalRequest], data, interpreter);
|
|
363
|
+
return {
|
|
364
|
+
ok: true,
|
|
365
|
+
status: response.status,
|
|
366
|
+
body: decryptedBody,
|
|
367
|
+
headers: response.headers
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
return {
|
|
371
|
+
ok: isSuccess,
|
|
372
|
+
status: response === null || response === void 0 ? void 0 : response.status,
|
|
373
|
+
body: response === null || response === void 0 ? void 0 : response.body,
|
|
374
|
+
headers: response === null || response === void 0 ? void 0 : response.headers
|
|
375
|
+
};
|
|
376
|
+
})
|
|
333
377
|
}
|
|
334
378
|
};
|
|
335
379
|
return funcDef(...args, globals);
|
|
@@ -647,6 +691,13 @@ class FunctionRuntimeImpl {
|
|
|
647
691
|
},
|
|
648
692
|
_signature: []
|
|
649
693
|
},
|
|
694
|
+
externalize: {
|
|
695
|
+
_func: (args, data, interpreter) => {
|
|
696
|
+
const url = toString(args[0]);
|
|
697
|
+
return url;
|
|
698
|
+
},
|
|
699
|
+
_signature: []
|
|
700
|
+
},
|
|
650
701
|
awaitFn: {
|
|
651
702
|
_func: (args, data, interpreter) => __awaiter(this, void 0, void 0, function* () {
|
|
652
703
|
const success = args[1];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.162",
|
|
4
4
|
"description": "Core Module for Forms Runtime",
|
|
5
5
|
"author": "Adobe Systems",
|
|
6
6
|
"license": "Adobe Proprietary",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@adobe/json-formula": "0.1.50",
|
|
40
|
-
"@aemforms/af-formatters": "^0.22.
|
|
40
|
+
"@aemforms/af-formatters": "^0.22.162"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|