From 1c9dacdf79903b2b1e57c6d55aa149b2439e7379 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Fri, 17 Jan 2025 14:06:03 +0100 Subject: [PATCH 1/2] Add cors headers by default during OpenAPI import (#1649) This is a follow up from #1392 Closes #1593 --- .../cli/test/data/envs/petstore-imported.json | 15 +++++++++++++- .../src/libs/openapi-converter.ts | 6 ++++-- packages/commons/src/libs/schema-builder.ts | 20 ++++++++++++++----- .../app/services/environments.service.ts | 9 ++++++--- .../references/aws-cloudfront-v3.json | 15 +++++++++++++- .../references/aws-server-v3.json | 15 +++++++++++++- .../custom-schema-no-prefix-v2.json | 15 +++++++++++++- .../custom-schema-no-prefix-v3.json | 15 +++++++++++++- .../references/custom-schema-v2.json | 15 +++++++++++++- .../references/custom-schema-v3.json | 15 +++++++++++++- .../import-openapi/references/datagov-v2.json | 15 +++++++++++++- .../import-openapi/references/giphy-v2.json | 15 +++++++++++++- .../import-openapi/references/github-v2.json | 15 +++++++++++++- .../references/petstore-v2.json | 15 +++++++++++++- .../references/petstore-v3.json | 15 +++++++++++++- .../references/shutterstock-v3.json | 15 +++++++++++++- .../import-openapi/references/slack-v2.json | 15 +++++++++++++- .../import-openapi/references/youtube-v3.json | 15 +++++++++++++- 18 files changed, 235 insertions(+), 25 deletions(-) diff --git a/packages/cli/test/data/envs/petstore-imported.json b/packages/cli/test/data/envs/petstore-imported.json index 9e60b93bc..bb81484d3 100644 --- a/packages/cli/test/data/envs/petstore-imported.json +++ b/packages/cli/test/data/envs/petstore-imported.json @@ -180,7 +180,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/commons-server/src/libs/openapi-converter.ts b/packages/commons-server/src/libs/openapi-converter.ts index c84b2148f..c441e4ac3 100644 --- a/packages/commons-server/src/libs/openapi-converter.ts +++ b/packages/commons-server/src/libs/openapi-converter.ts @@ -188,7 +188,8 @@ export class OpenAPIConverter { port?: number ): Environment { const newEnvironment = BuildEnvironment({ - hasDefaultHeader: false, + hasContentTypeHeader: false, + hasCorsHeaders: true, hasDefaultRoute: false, port }); @@ -224,7 +225,8 @@ export class OpenAPIConverter { port?: number ): Environment { const newEnvironment = BuildEnvironment({ - hasDefaultHeader: false, + hasContentTypeHeader: false, + hasCorsHeaders: true, hasDefaultRoute: false, port }); diff --git a/packages/commons/src/libs/schema-builder.ts b/packages/commons/src/libs/schema-builder.ts index d4d57ab96..339f49cd9 100644 --- a/packages/commons/src/libs/schema-builder.ts +++ b/packages/commons/src/libs/schema-builder.ts @@ -212,22 +212,32 @@ export const BuildCallback = (): Callback => ({ ...CallbackDefault }); export const BuildEnvironment = ( params: { hasDefaultRoute: boolean; - hasDefaultHeader: boolean; + hasContentTypeHeader: boolean; + hasCorsHeaders: boolean; port?: number; } = { hasDefaultRoute: true, - hasDefaultHeader: true + hasContentTypeHeader: true, + hasCorsHeaders: true } ): Environment => { const newRoute = BuildHTTPRoute(); + const headers: Header[] = []; + + if (params.hasContentTypeHeader) { + headers.push(BuildHeader('Content-Type', 'application/json')); + } + + if (params.hasCorsHeaders) { + headers.push(...CORSHeaders); + } + return { ...EnvironmentDefault, port: params.port ?? EnvironmentDefault.port, routes: params.hasDefaultRoute ? [newRoute] : [], - headers: params.hasDefaultHeader - ? [BuildHeader('Content-Type', 'application/json'), ...CORSHeaders] - : [], + headers, proxyReqHeaders: [BuildHeader()], proxyResHeaders: [BuildHeader()], rootChildren: params.hasDefaultRoute diff --git a/packages/desktop/src/renderer/app/services/environments.service.ts b/packages/desktop/src/renderer/app/services/environments.service.ts index 075309c03..62862e6ef 100644 --- a/packages/desktop/src/renderer/app/services/environments.service.ts +++ b/packages/desktop/src/renderer/app/services/environments.service.ts @@ -544,7 +544,8 @@ export class EnvironmentsService extends Logger { const newEnvironment = options.environment ? options.environment : BuildEnvironment({ - hasDefaultHeader: true, + hasContentTypeHeader: true, + hasCorsHeaders: true, hasDefaultRoute: true, port: this.dataService.getNewEnvironmentPort() }); @@ -719,7 +720,8 @@ export class EnvironmentsService extends Logger { if (!environment) { environment = { ...BuildEnvironment({ - hasDefaultHeader: true, + hasContentTypeHeader: true, + hasCorsHeaders: true, hasDefaultRoute: true }), // provide a name or the filename (UUID) will be used @@ -1267,7 +1269,8 @@ export class EnvironmentsService extends Logger { setActive: true, environment: { ...BuildEnvironment({ - hasDefaultHeader: true, + hasContentTypeHeader: true, + hasCorsHeaders: true, hasDefaultRoute: true, port: this.dataService.getNewEnvironmentPort() }), diff --git a/packages/desktop/test/data/res/import-openapi/references/aws-cloudfront-v3.json b/packages/desktop/test/data/res/import-openapi/references/aws-cloudfront-v3.json index 341234559..1636d31cd 100644 --- a/packages/desktop/test/data/res/import-openapi/references/aws-cloudfront-v3.json +++ b/packages/desktop/test/data/res/import-openapi/references/aws-cloudfront-v3.json @@ -6736,7 +6736,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/desktop/test/data/res/import-openapi/references/aws-server-v3.json b/packages/desktop/test/data/res/import-openapi/references/aws-server-v3.json index ec6fd97c1..bc93c2ece 100644 --- a/packages/desktop/test/data/res/import-openapi/references/aws-server-v3.json +++ b/packages/desktop/test/data/res/import-openapi/references/aws-server-v3.json @@ -4336,7 +4336,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/desktop/test/data/res/import-openapi/references/custom-schema-no-prefix-v2.json b/packages/desktop/test/data/res/import-openapi/references/custom-schema-no-prefix-v2.json index 44a6557bc..1089ce848 100644 --- a/packages/desktop/test/data/res/import-openapi/references/custom-schema-no-prefix-v2.json +++ b/packages/desktop/test/data/res/import-openapi/references/custom-schema-no-prefix-v2.json @@ -64,7 +64,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/desktop/test/data/res/import-openapi/references/custom-schema-no-prefix-v3.json b/packages/desktop/test/data/res/import-openapi/references/custom-schema-no-prefix-v3.json index 6d6a7eecd..461bc5c7f 100644 --- a/packages/desktop/test/data/res/import-openapi/references/custom-schema-no-prefix-v3.json +++ b/packages/desktop/test/data/res/import-openapi/references/custom-schema-no-prefix-v3.json @@ -144,7 +144,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/desktop/test/data/res/import-openapi/references/custom-schema-v2.json b/packages/desktop/test/data/res/import-openapi/references/custom-schema-v2.json index 402d06762..9368b1a8a 100644 --- a/packages/desktop/test/data/res/import-openapi/references/custom-schema-v2.json +++ b/packages/desktop/test/data/res/import-openapi/references/custom-schema-v2.json @@ -64,7 +64,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/desktop/test/data/res/import-openapi/references/custom-schema-v3.json b/packages/desktop/test/data/res/import-openapi/references/custom-schema-v3.json index bf7aaff9c..d2d38a910 100644 --- a/packages/desktop/test/data/res/import-openapi/references/custom-schema-v3.json +++ b/packages/desktop/test/data/res/import-openapi/references/custom-schema-v3.json @@ -200,7 +200,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/desktop/test/data/res/import-openapi/references/datagov-v2.json b/packages/desktop/test/data/res/import-openapi/references/datagov-v2.json index f961dbcc1..822e9b82a 100644 --- a/packages/desktop/test/data/res/import-openapi/references/datagov-v2.json +++ b/packages/desktop/test/data/res/import-openapi/references/datagov-v2.json @@ -288,7 +288,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/desktop/test/data/res/import-openapi/references/giphy-v2.json b/packages/desktop/test/data/res/import-openapi/references/giphy-v2.json index e46365b91..6422b0394 100644 --- a/packages/desktop/test/data/res/import-openapi/references/giphy-v2.json +++ b/packages/desktop/test/data/res/import-openapi/references/giphy-v2.json @@ -1384,7 +1384,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/desktop/test/data/res/import-openapi/references/github-v2.json b/packages/desktop/test/data/res/import-openapi/references/github-v2.json index d680cac05..dfd6470bf 100644 --- a/packages/desktop/test/data/res/import-openapi/references/github-v2.json +++ b/packages/desktop/test/data/res/import-openapi/references/github-v2.json @@ -25928,7 +25928,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/desktop/test/data/res/import-openapi/references/petstore-v2.json b/packages/desktop/test/data/res/import-openapi/references/petstore-v2.json index 076c30806..9aca5f54d 100644 --- a/packages/desktop/test/data/res/import-openapi/references/petstore-v2.json +++ b/packages/desktop/test/data/res/import-openapi/references/petstore-v2.json @@ -1216,7 +1216,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/desktop/test/data/res/import-openapi/references/petstore-v3.json b/packages/desktop/test/data/res/import-openapi/references/petstore-v3.json index ac3f3a793..f4722e562 100644 --- a/packages/desktop/test/data/res/import-openapi/references/petstore-v3.json +++ b/packages/desktop/test/data/res/import-openapi/references/petstore-v3.json @@ -288,7 +288,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/desktop/test/data/res/import-openapi/references/shutterstock-v3.json b/packages/desktop/test/data/res/import-openapi/references/shutterstock-v3.json index 745d9b38b..1ec240562 100644 --- a/packages/desktop/test/data/res/import-openapi/references/shutterstock-v3.json +++ b/packages/desktop/test/data/res/import-openapi/references/shutterstock-v3.json @@ -10568,7 +10568,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/desktop/test/data/res/import-openapi/references/slack-v2.json b/packages/desktop/test/data/res/import-openapi/references/slack-v2.json index 5d320a686..be79d7d33 100644 --- a/packages/desktop/test/data/res/import-openapi/references/slack-v2.json +++ b/packages/desktop/test/data/res/import-openapi/references/slack-v2.json @@ -12632,7 +12632,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], diff --git a/packages/desktop/test/data/res/import-openapi/references/youtube-v3.json b/packages/desktop/test/data/res/import-openapi/references/youtube-v3.json index 7a74b413e..675cc6212 100644 --- a/packages/desktop/test/data/res/import-openapi/references/youtube-v3.json +++ b/packages/desktop/test/data/res/import-openapi/references/youtube-v3.json @@ -344,7 +344,20 @@ "passphrase": "" }, "cors": true, - "headers": [], + "headers": [ + { + "key": "Access-Control-Allow-Origin", + "value": "*" + }, + { + "key": "Access-Control-Allow-Methods", + "value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS" + }, + { + "key": "Access-Control-Allow-Headers", + "value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With" + } + ], "proxyReqHeaders": [{ "key": "", "value": "" }], "proxyResHeaders": [{ "key": "", "value": "" }], "data": [], From ff9dfca1d3b7f8ca5ed70baedc3826a487b87cbd Mon Sep 17 00:00:00 2001 From: Guillaume Date: Fri, 17 Jan 2025 15:25:48 +0100 Subject: [PATCH 2/2] Add find helper (#1650) Closes #1124 --- .../libs/templating-helpers/helpers/find.ts | 59 +++++++++++++++++++ .../libs/templating-helpers/helpers/index.ts | 2 + .../specs/templating-helpers/helpers.test.ts | 47 +++++++++++++++ .../app/constants/autocomplete.constant.ts | 2 + 4 files changed, 110 insertions(+) create mode 100644 packages/commons-server/src/libs/templating-helpers/helpers/find.ts diff --git a/packages/commons-server/src/libs/templating-helpers/helpers/find.ts b/packages/commons-server/src/libs/templating-helpers/helpers/find.ts new file mode 100644 index 000000000..e0a0d441e --- /dev/null +++ b/packages/commons-server/src/libs/templating-helpers/helpers/find.ts @@ -0,0 +1,59 @@ +import { fromSafeString } from '../../utils'; + +const find = function (...args) { + const parameters = args.slice(0, -1); + + if (parameters.length === 0) { + return ''; + } + + const [arr, ...filters] = parameters; + + if (!(arr instanceof Array)) { + return ''; + } + if (!arr.length || !filters.length) { + return undefined; + } + + const validate = (payload, condition) => { + if ( + condition !== null && + typeof condition === 'object' && + !Array.isArray(condition) + ) { + if (typeof payload === 'object') { + const keys = Object.keys(condition); + + return keys.every((k) => + validate(payload[k], fromSafeString(condition[k])) + ); + } + + return false; + } + + return payload === condition; + }; + + const and = (item, conditions, { or }) => + conditions.every((subConditions) => { + if (Array.isArray(subConditions)) { + return or(item, subConditions); + } + + return validate(item, subConditions); + }); + const or = (item, conditions) => + conditions.some((subConditions) => { + if (Array.isArray(subConditions)) { + return and(item, subConditions, { or }); + } + + return validate(item, subConditions); + }); + + return arr.find((item) => or(item, filters)); +}; + +export default find; diff --git a/packages/commons-server/src/libs/templating-helpers/helpers/index.ts b/packages/commons-server/src/libs/templating-helpers/helpers/index.ts index 3706d570a..d63aebdbd 100644 --- a/packages/commons-server/src/libs/templating-helpers/helpers/index.ts +++ b/packages/commons-server/src/libs/templating-helpers/helpers/index.ts @@ -33,6 +33,7 @@ import domain from './domain'; import email from './email'; import eq from './eq'; import filter from './filter'; +import find from './find'; import firstName from './firstName'; import float from './float'; import floor from './floor'; @@ -117,6 +118,7 @@ export const Helpers = { email, eq, filter, + find, firstName, float, floor, diff --git a/packages/commons-server/test/specs/templating-helpers/helpers.test.ts b/packages/commons-server/test/specs/templating-helpers/helpers.test.ts index 926c0f008..06a22b396 100644 --- a/packages/commons-server/test/specs/templating-helpers/helpers.test.ts +++ b/packages/commons-server/test/specs/templating-helpers/helpers.test.ts @@ -3126,6 +3126,53 @@ describe('Template parser', () => { }); }); + describe('Helper: find', () => { + it('should return the first item matching the condition', () => { + const parseResult = TemplateParser({ + shouldOmitDataHelper: false, + content: + '{{{ stringify (find (array (object b="b1" a="a1") (object b="b2" a="a2") 3) (object b="b1")) }}}', + environment: {} as any, + processedDatabuckets: [], + globalVariables: {}, + request: {} as any, + envVarsPrefix: '' + }); + strictEqual(parseResult, JSON.stringify({ a: 'a1', b: 'b1' }, null, 2)); + }); + + it('should return the first item matching nested values', () => { + const parseResult = TemplateParser({ + shouldOmitDataHelper: false, + content: + '{{{ stringify (find (array (object parent=(object child="child-val") b="b1") (object parent=(object child="child-val2") b="b2") 2 3) (object parent=(object child="child-val"))) }}}', + environment: {} as any, + processedDatabuckets: [], + globalVariables: {}, + request: {} as any, + envVarsPrefix: '' + }); + strictEqual( + parseResult, + JSON.stringify({ b: 'b1', parent: { child: 'child-val' } }, null, 2) + ); + }); + + it('should return undefined when no item matches the condition', () => { + const parseResult = TemplateParser({ + shouldOmitDataHelper: false, + content: + '{{{ stringify (find (array (object parent=(object child="child-val") b="b1") (object parent=(object child="child-val2") b="b2") 2 3) (object parent="parent-val")) }}}', + environment: {} as any, + processedDatabuckets: [], + globalVariables: {}, + request: {} as any, + envVarsPrefix: '' + }); + strictEqual(parseResult, ''); + }); + }); + describe('Helper: sort', () => { it('should return correctly sorted array of numbers in ascending order', () => { const parseResult = TemplateParser({ diff --git a/packages/desktop/src/renderer/app/constants/autocomplete.constant.ts b/packages/desktop/src/renderer/app/constants/autocomplete.constant.ts index 1a2c9e6ea..b0420f8d3 100644 --- a/packages/desktop/src/renderer/app/constants/autocomplete.constant.ts +++ b/packages/desktop/src/renderer/app/constants/autocomplete.constant.ts @@ -83,6 +83,7 @@ export const helpersAutocompletions = [ { caption: 'concat', value: '{{concat value value}}', meta: '' }, { caption: 'jwtPayload', value: "{{jwtPayload token 'key'}}", meta: '' }, { caption: 'jwtHeader', value: "{{jwtHeader token 'key'}}", meta: '' }, + { caption: 'filter', value: "{{filter array 'key'}}", meta: '' }, { caption: 'indexOf', value: '{{indexOf value search startIndex}}', @@ -138,6 +139,7 @@ export const helpersAutocompletions = [ { caption: 'color', value: '{{color}}', meta: '' }, { caption: 'hexColor', value: '{{hexColor}}', meta: '' }, { caption: 'guid', value: '{{guid}}', meta: '' }, + { caption: 'uuid', value: '{{uuid}}', meta: '' }, { caption: 'ipv4', value: '{{ipv4}}', meta: '' }, { caption: 'ipv6', value: '{{ipv6}}', meta: '' }, { caption: 'lorem', value: '{{lorem length}}', meta: '' }