From e7af4c5d82a8494d7908cd68563a6b803806b14b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Narciso?= Date: Wed, 28 May 2025 16:28:35 -0300 Subject: [PATCH 1/4] feat: purge api v4 --- .../src/configProcessor/helpers/schema.ts | 22 ++++++++----------- .../purgeProcessConfigStrategy.ts | 18 +++++++-------- packages/config/src/types.ts | 10 ++++----- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/packages/config/src/configProcessor/helpers/schema.ts b/packages/config/src/configProcessor/helpers/schema.ts index 1cbe00d6..4a33d013 100644 --- a/packages/config/src/configProcessor/helpers/schema.ts +++ b/packages/config/src/configProcessor/helpers/schema.ts @@ -1011,33 +1011,29 @@ const azionConfigSchema = { enum: ['url', 'cachekey', 'wildcard'], errorMessage: "The 'type' field must be either 'url', 'cachekey' or 'wildcard'.", }, - urls: { + items: { type: 'array', + minItems: 1, items: { type: 'string', - errorMessage: "Each item in 'urls' must be a string.", + errorMessage: "Each item in 'items' must be a string.", }, errorMessage: { - type: "The 'urls' field must be an array of strings.", + type: "The 'items' field must be an array of strings.", + minItems: 'The purge items array cannot be empty. At least one item must be specified.', }, }, - method: { - type: 'string', - enum: ['delete'], - errorMessage: "The 'method' field must be either 'delete'. Default is 'delete'.", - }, layer: { type: 'string', - enum: ['edge_caching', 'l2_caching'], - errorMessage: - "The 'layer' field must be either 'edge_caching' or 'l2_caching'. Default is 'edge_caching'.", + enum: ['edge_cache', 'tiered_cache'], + errorMessage: "The 'layer' field must be either 'edge_cache' or 'tiered_cache'.", }, }, - required: ['type', 'urls'], + required: ['type', 'items'], additionalProperties: false, errorMessage: { additionalProperties: 'No additional properties are allowed in purge items.', - required: "The 'type and urls' fields are required in each purge item.", + required: "The 'type and items' fields are required in each purge item.", }, }, }, diff --git a/packages/config/src/configProcessor/processStrategy/implementations/purgeProcessConfigStrategy.ts b/packages/config/src/configProcessor/processStrategy/implementations/purgeProcessConfigStrategy.ts index f27e52da..159d2e7c 100644 --- a/packages/config/src/configProcessor/processStrategy/implementations/purgeProcessConfigStrategy.ts +++ b/packages/config/src/configProcessor/processStrategy/implementations/purgeProcessConfigStrategy.ts @@ -14,7 +14,7 @@ class PurgeProcessConfigStrategy extends ProcessConfigStrategy { return; } config?.purge.forEach((purge) => { - purge?.urls.forEach((value) => { + purge?.items.forEach((value) => { if (!value.includes('http://') && !value.includes('https://')) { throw new Error('The URL must contain the protocol (http:// or https://).'); } @@ -27,12 +27,11 @@ class PurgeProcessConfigStrategy extends ProcessConfigStrategy { // eslint-disable-next-line @typescript-eslint/no-explicit-any const purgeSetting: any = { type: purge.type, - urls: purge.urls || [], - method: purge.method || 'delete', + items: purge.items || [], }; - if (purge?.type === 'cachekey') { - purgeSetting.layer = purge.layer || 'edge_caching'; + if (purge?.layer) { + purgeSetting.layer = purge.layer; } payload.push(purgeSetting); @@ -48,7 +47,7 @@ class PurgeProcessConfigStrategy extends ProcessConfigStrategy { } transformedPayload.purge = []; purgeConfig.forEach((purge) => { - purge.urls.forEach((value: string) => { + purge.items.forEach((value: string) => { if (!value.includes('http://') && !value.includes('https://')) { throw new Error('The URL must contain the protocol (http:// or https://).'); } @@ -59,12 +58,11 @@ class PurgeProcessConfigStrategy extends ProcessConfigStrategy { }); const purgeSetting: AzionPurge = { type: purge.type, - urls: purge.urls || [], - method: purge.method || 'delete', + items: purge.items || [], }; - if (purge?.type === 'cachekey') { - purgeSetting.layer = purge.layer || 'edge_caching'; + if (purge?.layer) { + purgeSetting.layer = purge.layer; } transformedPayload.purge!.push(purgeSetting); diff --git a/packages/config/src/types.ts b/packages/config/src/types.ts index dde7cd81..118c82cd 100644 --- a/packages/config/src/types.ts +++ b/packages/config/src/types.ts @@ -261,14 +261,12 @@ export type AzionRules = { * Purge configuration for Azion. */ export type AzionPurge = { + /** Items to be purged */ + items: string[]; + /** Cache layer to be purged */ + layer?: 'edge_cache' | 'tiered_cache'; /** Purge type */ type: 'url' | 'cachekey' | 'wildcard'; - /** URLs to be purged */ - urls: string[]; - /** HTTP method for purge request */ - method?: 'delete'; - /** Cache layer to be purged */ - layer?: 'edge_caching' | 'l2_caching'; }; export type PresetInput = string | AzionBuildPreset; From 6019d855d103b39731c7c299b04f6215a5988179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Narciso?= Date: Mon, 2 Jun 2025 14:40:21 -0300 Subject: [PATCH 2/4] refactor: input_value -> argument --- .../src/rules-engine/services/types.ts | 4 +- packages/config/README.md | 6 +- .../converterJsonConfig/index.test.ts | 126 +++++++++--------- .../helpers/azion.config.example.ts | 10 +- .../src/configProcessor/helpers/schema.ts | 8 +- .../configProcessor/helpers/schemaManifest.ts | 12 +- .../processConfig/index.test.ts | 26 ++-- .../application/rulesProcessConfigStrategy.ts | 28 ++-- .../firewallProcessConfigStrategy.test.ts | 8 +- .../secure/firewallProcessConfigStrategy.ts | 14 +- packages/config/src/types.ts | 4 +- 11 files changed, 123 insertions(+), 123 deletions(-) diff --git a/packages/applications/src/rules-engine/services/types.ts b/packages/applications/src/rules-engine/services/types.ts index 99ce5d54..c5c78b60 100644 --- a/packages/applications/src/rules-engine/services/types.ts +++ b/packages/applications/src/rules-engine/services/types.ts @@ -43,7 +43,7 @@ export interface Criterion { variable: string; operator: string; conditional: 'if' | 'and' | 'or'; - input_value: string; + argument: string; } export interface ApiCreateRulePayload { @@ -107,7 +107,7 @@ export interface Criterion { variable: string; operator: string; conditional: 'if' | 'and' | 'or'; - input_value: string; + argument: string; } export interface ApiCreateRulePayload { diff --git a/packages/config/README.md b/packages/config/README.md index 49213a8b..60e88df5 100644 --- a/packages/config/README.md +++ b/packages/config/README.md @@ -129,7 +129,7 @@ const config = defineConfig({ variable: 'remote_addr', operator: 'in', conditional: 'if', - inputValue: 'suspicious_ips', + argument: 'suspicious_ips', }, ], behavior: { @@ -145,7 +145,7 @@ const config = defineConfig({ variable: 'uri', operator: 'starts_with', conditional: 'if', - inputValue: '/api/', + argument: '/api/', }, ], behavior: { @@ -597,7 +597,7 @@ Type definition for the response rule configuration. - `variable: RuleVariable` - Variable to be evaluated. - `conditional: RuleConditional` - Conditional type. - `operator: RuleOperatorWithValue | RuleOperatorWithoutValue` - Comparison operator. - - `inputValue?: string` - Input value for comparison (required for operators with value). + - `argument?: string` - Input value for comparison (required for operators with value). ### `AzionWaf` diff --git a/packages/config/src/configProcessor/converterJsonConfig/index.test.ts b/packages/config/src/configProcessor/converterJsonConfig/index.test.ts index b3687906..70d02d23 100644 --- a/packages/config/src/configProcessor/converterJsonConfig/index.test.ts +++ b/packages/config/src/configProcessor/converterJsonConfig/index.test.ts @@ -201,7 +201,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -227,7 +227,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], behavior: { @@ -250,7 +250,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -282,7 +282,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule responds with a file from the origin storage.', @@ -309,7 +309,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -333,7 +333,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule rewrites the request path.', @@ -357,7 +357,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -380,7 +380,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule delivers the request.', @@ -404,7 +404,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -428,7 +428,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule sets a cookie.', @@ -452,7 +452,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -484,7 +484,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule sets multiple headers.', @@ -508,7 +508,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -538,7 +538,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule sets the cache.', @@ -562,7 +562,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -596,7 +596,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule sets the cache.', @@ -624,7 +624,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -648,7 +648,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule forwards the cookie.', @@ -679,7 +679,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -703,7 +703,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule runs a function.', @@ -729,7 +729,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -752,7 +752,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule enables GZIP compression.', @@ -778,7 +778,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -801,7 +801,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule bypasses the cache.', @@ -827,7 +827,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${scheme}`, operator: 'matches', conditional: 'if', - input_value: 'http', + argument: 'http', }, ], ], @@ -852,7 +852,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${scheme}`, operator: 'matches', conditional: 'if', - inputValue: 'http', + argument: 'http', }, ], description: 'This rule redirects HTTP to HTTPS.', @@ -877,7 +877,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -905,7 +905,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule captures the request.', @@ -935,7 +935,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -963,7 +963,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule captures the request.', @@ -990,7 +990,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -1014,7 +1014,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule the request.', @@ -1040,7 +1040,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/images', + argument: '/images', }, ], ], @@ -1064,7 +1064,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/images', + argument: '/images', }, ], description: 'This rule the request.', @@ -1089,7 +1089,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -1121,7 +1121,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule sets multiple headers.', @@ -1146,7 +1146,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/login', + argument: '/login', }, ], ], @@ -1170,7 +1170,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/login', + argument: '/login', }, ], description: 'This rule the request.', @@ -1198,7 +1198,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -1223,7 +1223,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], active: false, @@ -1248,7 +1248,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -1274,7 +1274,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], behavior: { @@ -1298,7 +1298,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${status}`, operator: 'equals', conditional: 'if', - input_value: '200', + argument: '200', }, ], ], @@ -1322,7 +1322,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${status}`, operator: 'equals', conditional: 'if', - inputValue: '200', + argument: '200', }, ], active: false, @@ -1347,7 +1347,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${status}`, operator: 'equals', conditional: 'if', - input_value: '200', + argument: '200', }, ], ], @@ -1371,7 +1371,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${status}`, operator: 'equals', conditional: 'if', - inputValue: '200', + argument: '200', }, ], description: 'This rule sets a header.', @@ -1395,7 +1395,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${status}`, operator: 'equals', conditional: 'if', - input_value: '200', + argument: '200', }, ], ], @@ -1418,7 +1418,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${status}`, operator: 'equals', conditional: 'if', - inputValue: '200', + argument: '200', }, ], description: 'This rule enables GZIP compression.', @@ -1443,7 +1443,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -1468,7 +1468,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule filters the cookie.', @@ -1493,7 +1493,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${status}`, operator: 'equals', conditional: 'if', - input_value: '200', + argument: '200', }, ], ], @@ -1518,7 +1518,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${status}`, operator: 'equals', conditional: 'if', - inputValue: '200', + argument: '200', }, ], description: 'This rule filters the header.', @@ -1549,7 +1549,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -1573,7 +1573,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'matches', conditional: 'if', - inputValue: '/test', + argument: '/test', }, ], description: 'This rule runs a function.', @@ -1599,7 +1599,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'equals', conditional: 'if', - input_value: '/', + argument: '/', }, ], ], @@ -1624,7 +1624,7 @@ describe('convertJsonConfigToObject', () => { variable: `\${uri}`, operator: 'equals', conditional: 'if', - inputValue: '/', + argument: '/', }, ], description: 'This rule delivers the response.', @@ -1909,7 +1909,7 @@ describe('convertJsonConfigToObject', () => { variable: 'invalid_variable', operator: 'is_equal', conditional: 'if', - input_value: 'test', + argument: 'test', }, }, ], @@ -1935,7 +1935,7 @@ describe('convertJsonConfigToObject', () => { variable: 'request_uri', operator: 'is_equal', conditional: 'if', - input_value: '/test', + argument: '/test', }, behavior: { name: 'invalid_behavior', @@ -1965,7 +1965,7 @@ describe('convertJsonConfigToObject', () => { variable: 'request_uri', operator: 'is_equal', conditional: 'if', - input_value: '/test', + argument: '/test', }, behavior: { name: 'set_rate_limit', @@ -2132,7 +2132,7 @@ describe('convertJsonConfigToObject', () => { variable: 'invalid_variable', operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -2169,7 +2169,7 @@ describe('convertJsonConfigToObject', () => { variable: 'request_uri', operator: 'matches', conditional: 'if', - input_value: '/test', + argument: '/test', }, ], ], @@ -2190,7 +2190,7 @@ describe('convertJsonConfigToObject', () => { ); }); - it('should throw an error when input_value is missing for operator that requires it', () => { + it('should throw an error when argument is missing for operator that requires it', () => { const jsonConfig = { application: [ { @@ -2222,7 +2222,7 @@ describe('convertJsonConfigToObject', () => { }; expect(() => convertJsonConfigToObject(JSON.stringify(jsonConfig))).toThrow( - "The operator 'matches' requires an input_value.", + "The operator 'matches' requires an argument.", ); }); }); diff --git a/packages/config/src/configProcessor/helpers/azion.config.example.ts b/packages/config/src/configProcessor/helpers/azion.config.example.ts index 2f890e76..25a0bc5f 100644 --- a/packages/config/src/configProcessor/helpers/azion.config.example.ts +++ b/packages/config/src/configProcessor/helpers/azion.config.example.ts @@ -241,7 +241,7 @@ export default { variable: '${uri}', operator: 'matches', conditional: 'if', - inputValue: '^/', + argument: '^/', }, ], behavior: { @@ -258,7 +258,7 @@ export default { variable: '${uri}', operator: 'matches', conditional: 'if', - inputValue: '^/', + argument: '^/', }, ], behavior: { @@ -274,7 +274,7 @@ export default { variable: '${uri}', operator: 'matches', conditional: 'if', - inputValue: '^/login', + argument: '^/login', }, ], behavior: { @@ -356,7 +356,7 @@ export default { variable: '${uri}', operator: 'matches', conditional: 'if', - inputValue: '^/', + argument: '^/', }, ], behavior: { @@ -372,7 +372,7 @@ export default { variable: '${uri}', operator: 'matches', conditional: 'if', - inputValue: '^/', + argument: '^/', }, ], behavior: { diff --git a/packages/config/src/configProcessor/helpers/schema.ts b/packages/config/src/configProcessor/helpers/schema.ts index 4a33d013..90d7e5b8 100644 --- a/packages/config/src/configProcessor/helpers/schema.ts +++ b/packages/config/src/configProcessor/helpers/schema.ts @@ -64,11 +64,11 @@ const criteriaBaseSchema = { }, }, then: { - required: ['inputValue'], + required: ['argument'], properties: { - inputValue: { + argument: { type: 'string', - errorMessage: "The 'inputValue' field must be a string", + errorMessage: "The 'argument' field must be a string", }, }, }, @@ -81,7 +81,7 @@ const criteriaBaseSchema = { }, then: { not: { - required: ['inputValue'], + required: ['argument'], }, }, }, diff --git a/packages/config/src/configProcessor/helpers/schemaManifest.ts b/packages/config/src/configProcessor/helpers/schemaManifest.ts index abe84d3b..af8fa0ed 100644 --- a/packages/config/src/configProcessor/helpers/schemaManifest.ts +++ b/packages/config/src/configProcessor/helpers/schemaManifest.ts @@ -212,9 +212,9 @@ const schemaFirewallRuleCriteria = { enum: FIREWALL_RULE_CONDITIONALS, errorMessage: "The 'conditional' field must be one of: if, and, or", }, - input_value: { + argument: { type: 'string', - errorMessage: "The 'input_value' field must be a string.", + errorMessage: "The 'argument' field must be a string.", }, }, required: ['variable', 'operator', 'conditional'], @@ -625,9 +625,9 @@ const schemaApplicationRules = { enum: RULE_CONDITIONALS, errorMessage: "The 'conditional' field must be one of: if, and, or.", }, - input_value: { + argument: { type: 'string', - errorMessage: "The 'input_value' field must be a string.", + errorMessage: "The 'argument' field must be a string.", }, }, required: ['variable', 'operator', 'conditional'], @@ -638,8 +638,8 @@ const schemaApplicationRules = { properties: { operator: { enum: RULE_OPERATORS_WITH_VALUE }, }, - required: ['input_value'], - errorMessage: "The operator 'matches' requires an input_value.", + required: ['argument'], + errorMessage: "The operator 'matches' requires an argument.", }, ], }, diff --git a/packages/config/src/configProcessor/processConfig/index.test.ts b/packages/config/src/configProcessor/processConfig/index.test.ts index baa195c9..89f9156c 100644 --- a/packages/config/src/configProcessor/processConfig/index.test.ts +++ b/packages/config/src/configProcessor/processConfig/index.test.ts @@ -171,7 +171,7 @@ describe('processConfig', () => { criteria: expect.arrayContaining([ expect.arrayContaining([ expect.objectContaining({ - input_value: '/api', + argument: '/api', }), ]), ]), @@ -1747,7 +1747,7 @@ describe('processConfig', () => { variable: '${uri}', operator: 'matches', conditional: 'if', - inputValue: '^/', + argument: '^/', }, ], behavior: { @@ -1765,7 +1765,7 @@ describe('processConfig', () => { variable: '${uri}', operator: 'matches', conditional: 'if', - input_value: '^/', + argument: '^/', }, ], ]); @@ -1783,7 +1783,7 @@ describe('processConfig', () => { variable: '${uri}', operator: 'matches', conditional: 'if', - input_value: '^/', + argument: '^/', }, ], behavior: { @@ -1816,13 +1816,13 @@ describe('processConfig', () => { variable: '${uri}', operator: 'matches', conditional: 'if', - inputValue: '^/', + argument: '^/', }, { variable: '${device_group}', operator: 'is_equal', conditional: 'and', - inputValue: 'mobile', + argument: 'mobile', }, ], behavior: { @@ -1840,13 +1840,13 @@ describe('processConfig', () => { variable: '${uri}', operator: 'matches', conditional: 'if', - input_value: '^/', + argument: '^/', }, { variable: '${device_group}', operator: 'is_equal', conditional: 'and', - input_value: 'mobile', + argument: 'mobile', }, ], ]); @@ -1904,7 +1904,7 @@ describe('processConfig', () => { variable: '${uri}', operator: 'matches', conditional: 'if', - inputValue: '^/', + argument: '^/', }, ], behavior: { @@ -1944,7 +1944,7 @@ describe('processConfig', () => { variable: '${uri}', operator: 'matches', conditional: 'if', - inputValue: '^/', + argument: '^/', }, ], behavior: { @@ -1979,7 +1979,7 @@ describe('processConfig', () => { variable: '${uri}', operator: 'matches', conditional: 'if', - inputValue: '^/', + argument: '^/', }, ], behavior: { @@ -2014,7 +2014,7 @@ describe('processConfig', () => { variable: '${uri}', operator: 'matches', conditional: 'if', - inputValue: '^/images', + argument: '^/images', }, ], behavior: { @@ -2049,7 +2049,7 @@ describe('processConfig', () => { variable: '${uri}', operator: 'matches', conditional: 'if', - inputValue: '^/login', + argument: '^/login', }, ], behavior: { diff --git a/packages/config/src/configProcessor/processStrategy/implementations/application/rulesProcessConfigStrategy.ts b/packages/config/src/configProcessor/processStrategy/implementations/application/rulesProcessConfigStrategy.ts index 0b51d77b..f85595f8 100644 --- a/packages/config/src/configProcessor/processStrategy/implementations/application/rulesProcessConfigStrategy.ts +++ b/packages/config/src/configProcessor/processStrategy/implementations/application/rulesProcessConfigStrategy.ts @@ -90,12 +90,12 @@ class RulesProcessConfigStrategy extends ProcessConfigStrategy { criteria: rule.criteria ? [ rule.criteria.map((criterion) => { - const isWithValue = 'inputValue' in criterion; - const { inputValue, ...rest } = criterion as AzionEdgeFirewallCriteriaWithValue; + const isWithValue = 'argument' in criterion; + const { argument, ...rest } = criterion as AzionEdgeFirewallCriteriaWithValue; return { ...rest, variable: criterion.variable.startsWith('${') ? criterion.variable : `\${${criterion.variable}}`, - ...(isWithValue && { input_value: inputValue }), + ...(isWithValue && { argument: argument }), }; }), ] @@ -105,7 +105,7 @@ class RulesProcessConfigStrategy extends ProcessConfigStrategy { variable: rule.variable?.startsWith('${') ? rule.variable : `\${${rule.variable ?? 'uri'}}`, operator: 'matches', conditional: 'if', - input_value: rule.match, + argument: rule.match, }, ], ], @@ -127,12 +127,12 @@ class RulesProcessConfigStrategy extends ProcessConfigStrategy { criteria: rule.criteria ? [ rule.criteria.map((criterion) => { - const isWithValue = 'inputValue' in criterion; - const { inputValue, ...rest } = criterion as AzionEdgeFirewallCriteriaWithValue; + const isWithValue = 'argument' in criterion; + const { argument, ...rest } = criterion as AzionEdgeFirewallCriteriaWithValue; return { ...rest, variable: criterion.variable.startsWith('${') ? criterion.variable : `\${${criterion.variable}}`, - ...(isWithValue && { input_value: inputValue }), + ...(isWithValue && { argument: argument }), }; }), ] @@ -142,7 +142,7 @@ class RulesProcessConfigStrategy extends ProcessConfigStrategy { variable: rule.variable?.startsWith('${') ? rule.variable : `\${${rule.variable ?? 'uri'}}`, operator: 'matches', conditional: 'if', - input_value: rule.match, + argument: rule.match, }, ], ], @@ -208,11 +208,11 @@ class RulesProcessConfigStrategy extends ProcessConfigStrategy { Array.isArray(rule.criteria) && Array.isArray(rule.criteria[0]) ? // eslint-disable-next-line @typescript-eslint/no-explicit-any rule.criteria[0].map((criterion: any) => { - const isWithValue = 'input_value' in criterion; - const { input_value, ...rest } = criterion; + const isWithValue = 'argument' in criterion; + const { argument, ...rest } = criterion; return { ...rest, - ...(isWithValue && { inputValue: input_value }), + ...(isWithValue && { argument: argument }), }; }) : [], @@ -227,11 +227,11 @@ class RulesProcessConfigStrategy extends ProcessConfigStrategy { Array.isArray(rule.criteria) && Array.isArray(rule.criteria[0]) ? // eslint-disable-next-line @typescript-eslint/no-explicit-any rule.criteria[0].map((criterion: any) => { - const isWithValue = 'input_value' in criterion; - const { input_value, ...rest } = criterion; + const isWithValue = 'argument' in criterion; + const { argument, ...rest } = criterion; return { ...rest, - ...(isWithValue && { inputValue: input_value }), + ...(isWithValue && { argument: argument }), }; }) : [], diff --git a/packages/config/src/configProcessor/processStrategy/implementations/secure/firewallProcessConfigStrategy.test.ts b/packages/config/src/configProcessor/processStrategy/implementations/secure/firewallProcessConfigStrategy.test.ts index 9f9c50e9..a39280f1 100644 --- a/packages/config/src/configProcessor/processStrategy/implementations/secure/firewallProcessConfigStrategy.test.ts +++ b/packages/config/src/configProcessor/processStrategy/implementations/secure/firewallProcessConfigStrategy.test.ts @@ -32,7 +32,7 @@ describe('FirewallProcessConfigStrategy', () => { variable: 'uri', conditional: 'if', operator: 'matches', - inputValue: '/test', + argument: '/test', }, ], behavior: { @@ -68,7 +68,7 @@ describe('FirewallProcessConfigStrategy', () => { variable: 'uri', conditional: 'if', operator: 'matches', - input_value: '/test', + argument: '/test', }, ], ], @@ -136,7 +136,7 @@ describe('FirewallProcessConfigStrategy', () => { variable: '${uri}', conditional: 'if', operator: 'matches', - input_value: '/test', + argument: '/test', }, ], ], @@ -168,7 +168,7 @@ describe('FirewallProcessConfigStrategy', () => { variable: '${uri}', conditional: 'if', operator: 'matches', - inputValue: '/test', + argument: '/test', }, ], behavior: { diff --git a/packages/config/src/configProcessor/processStrategy/implementations/secure/firewallProcessConfigStrategy.ts b/packages/config/src/configProcessor/processStrategy/implementations/secure/firewallProcessConfigStrategy.ts index c8a839ca..ae3a48bb 100644 --- a/packages/config/src/configProcessor/processStrategy/implementations/secure/firewallProcessConfigStrategy.ts +++ b/packages/config/src/configProcessor/processStrategy/implementations/secure/firewallProcessConfigStrategy.ts @@ -40,12 +40,12 @@ class FirewallProcessConfigStrategy extends ProcessConfigStrategy { criteria: rule.criteria ? [ rule.criteria.map((criterion) => { - const isWithValue = 'inputValue' in criterion; - const { inputValue, ...rest } = criterion as AzionEdgeFirewallCriteriaWithValue; + const isWithValue = 'argument' in criterion; + const { argument, ...rest } = criterion as AzionEdgeFirewallCriteriaWithValue; return { ...rest, variable: criterion.variable, - ...(isWithValue && { input_value: inputValue }), + ...(isWithValue && { argument: argument }), }; }), ] @@ -55,7 +55,7 @@ class FirewallProcessConfigStrategy extends ProcessConfigStrategy { variable: rule.variable, operator: 'matches', conditional: 'if', - input_value: rule.match, + argument: rule.match, }, ], ], @@ -156,11 +156,11 @@ class FirewallProcessConfigStrategy extends ProcessConfigStrategy { criteria: // eslint-disable-next-line @typescript-eslint/no-explicit-any rule.criteria?.[0].map((criterion: any) => { - const isWithValue = 'input_value' in criterion; - const { input_value, ...rest } = criterion; + const isWithValue = 'argument' in criterion; + const { argument, ...rest } = criterion; return { ...rest, - ...(isWithValue && { inputValue: input_value }), + ...(isWithValue && { argument: argument }), }; }) || [], }; diff --git a/packages/config/src/types.ts b/packages/config/src/types.ts index 118c82cd..97337b6d 100644 --- a/packages/config/src/types.ts +++ b/packages/config/src/types.ts @@ -109,7 +109,7 @@ export type AzionRuleCriteriaWithValue = AzionRuleCriteriaBase & { /** Operator for comparison that requires input value */ operator: RuleOperatorWithValue; /** Input value for comparison */ - inputValue: string; + argument: string; }; export type AzionRuleCriteriaWithoutValue = AzionRuleCriteriaBase & { @@ -443,7 +443,7 @@ export type AzionEdgeFirewallCriteriaWithValue = AzionEdgeFirewallCriteriaBase & /** Operator for comparison that requires input value */ operator: RuleOperatorWithValue; /** Input value for comparison */ - inputValue: string; + argument: string; }; export type AzionEdgeFirewallCriteriaWithoutValue = AzionEdgeFirewallCriteriaBase & { From d6eb4b1366ad8bf91910f005044e3706a891e6cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Narciso?= Date: Mon, 2 Jun 2025 14:43:24 -0300 Subject: [PATCH 3/4] refactor: behavior: target -> argument --- packages/client/src/types.ts | 2 +- .../src/configProcessor/helpers/behaviors.ts | 60 ++++++++--------- .../configProcessor/helpers/schemaManifest.ts | 8 +-- .../processConfig/index.test.ts | 66 +++++++++---------- .../functionsProcessConfigStrategy.ts | 4 +- packages/config/src/types.ts | 2 +- 6 files changed, 71 insertions(+), 71 deletions(-) diff --git a/packages/client/src/types.ts b/packages/client/src/types.ts index d085dae4..1491285b 100644 --- a/packages/client/src/types.ts +++ b/packages/client/src/types.ts @@ -172,7 +172,7 @@ export interface AzionClient { * const { data: newRule } = await app.rules.request.createRule({ * data: { * name: 'My Rule', - * behaviors: [{ name: 'set_origin', target: newOrigin.id }], + * behaviors: [{ name: 'set_origin', argument: newOrigin.id }], * criteria: [{ condition: 'starts_with', variable: '${uri}', input: '/api' }] * } * }); diff --git a/packages/config/src/configProcessor/helpers/behaviors.ts b/packages/config/src/configProcessor/helpers/behaviors.ts index 8138ee5c..d7ef4125 100644 --- a/packages/config/src/configProcessor/helpers/behaviors.ts +++ b/packages/config/src/configProcessor/helpers/behaviors.ts @@ -10,7 +10,7 @@ export const requestBehaviors = { return { name: 'set_edge_connector', - target: connector.name, + argument: connector.name, }; }, }, @@ -19,7 +19,7 @@ export const requestBehaviors = { const behaviors = []; behaviors.push({ name: 'rewrite_request', - target: value, + argument: value, }); return behaviors; }, @@ -27,20 +27,20 @@ export const requestBehaviors = { deliver: { transform: () => ({ name: 'deliver', - target: null, + argument: null, }), }, setCookie: { transform: (value: any) => ({ name: 'add_request_cookie', - target: value, + argument: value, }), }, setHeaders: { transform: (value: any) => value.map((header: any) => ({ name: 'add_request_header', - target: header, + argument: header, })), }, setCache: { @@ -48,7 +48,7 @@ export const requestBehaviors = { if (typeof value === 'string') { return { name: 'set_cache_policy', - target: value, + argument: value, }; } if (typeof value === 'object') { @@ -60,7 +60,7 @@ export const requestBehaviors = { payloadCDN.cache.push(cacheSetting); return { name: 'set_cache_policy', - target: value.name, + argument: value.name, }; } return undefined; @@ -71,7 +71,7 @@ export const requestBehaviors = { if (value) { return { name: 'forward_cookies', - target: null, + argument: null, }; } return undefined; @@ -80,7 +80,7 @@ export const requestBehaviors = { runFunction: { transform: (value: string) => ({ name: 'run_function', - target: value, + argument: value, }), }, enableGZIP: { @@ -88,7 +88,7 @@ export const requestBehaviors = { if (value) { return { name: 'enable_gzip', - target: '', + argument: '', }; } return undefined; @@ -99,7 +99,7 @@ export const requestBehaviors = { if (value) { return { name: 'bypass_cache_phase', - target: null, + argument: null, }; } return undefined; @@ -110,7 +110,7 @@ export const requestBehaviors = { if (value) { return { name: 'redirect_http_to_https', - target: null, + argument: null, }; } return undefined; @@ -119,19 +119,19 @@ export const requestBehaviors = { redirectTo301: { transform: (value: any) => ({ name: 'redirect_to_301', - target: value, + argument: value, }), }, redirectTo302: { transform: (value: any) => ({ name: 'redirect_to_302', - target: value, + argument: value, }), }, capture: { transform: (value: any) => ({ name: 'capture_match_groups', - target: { + argument: { regex: value.match, captured_array: value.captured, subject: `\${${value.subject ?? 'uri'}}`, @@ -141,13 +141,13 @@ export const requestBehaviors = { filterCookie: { transform: (value: any) => ({ name: 'filter_request_cookie', - target: value, + argument: value, }), }, filterHeader: { transform: (value: any) => ({ name: 'filter_request_header', - target: value, + argument: value, }), }, noContent: { @@ -155,7 +155,7 @@ export const requestBehaviors = { if (value) { return { name: 'no_content', - target: null, + argument: null, }; } return undefined; @@ -166,7 +166,7 @@ export const requestBehaviors = { if (value) { return { name: 'optimize_images', - target: null, + argument: null, }; } return undefined; @@ -177,7 +177,7 @@ export const requestBehaviors = { if (value) { return { name: 'deny', - target: null, + argument: null, }; } return undefined; @@ -188,14 +188,14 @@ export const responseBehaviors = { setCookie: { transform: (value: any) => ({ name: 'set_cookie', - target: value, + argument: value, }), }, setHeaders: { transform: (value: any) => value.map((header: any) => ({ name: 'add_response_header', - target: header, + argument: header, })), }, enableGZIP: { @@ -203,7 +203,7 @@ export const responseBehaviors = { if (value) { return { name: 'enable_gzip', - target: '', + argument: '', }; } return undefined; @@ -212,37 +212,37 @@ export const responseBehaviors = { filterCookie: { transform: (value: any) => ({ name: 'filter_response_cookie', - target: value, + argument: value, }), }, filterHeader: { transform: (value: any) => ({ name: 'filter_response_header', - target: value, + argument: value, }), }, runFunction: { transform: (value: string) => ({ name: 'run_function', - target: value, + argument: value, }), }, redirectTo301: { transform: (value: any) => ({ name: 'redirect_to_301', - target: value, + argument: value, }), }, redirectTo302: { transform: (value: any) => ({ name: 'redirect_to_302', - target: value, + argument: value, }), }, capture: { transform: (value: any) => ({ name: 'capture_match_groups', - target: { + argument: { regex: value.match, captured_array: value.captured, subject: `\${${value.subject ?? 'uri'}}`, @@ -254,7 +254,7 @@ export const responseBehaviors = { if (value) { return { name: 'deliver', - target: null, + argument: null, }; } return undefined; diff --git a/packages/config/src/configProcessor/helpers/schemaManifest.ts b/packages/config/src/configProcessor/helpers/schemaManifest.ts index af8fa0ed..481c97cc 100644 --- a/packages/config/src/configProcessor/helpers/schemaManifest.ts +++ b/packages/config/src/configProcessor/helpers/schemaManifest.ts @@ -418,9 +418,9 @@ const schemaFunctionManifest = { type: 'string', errorMessage: "The 'name' field must be a string", }, - target: { + arguemnt: { type: 'string', - errorMessage: "The 'target' field must be a string", + errorMessage: "The 'argument' field must be a string", }, args: { type: 'object', @@ -594,9 +594,9 @@ const schemaApplicationRules = { enum: RULE_BEHAVIOR_NAMES, errorMessage: "The 'name' field must be a valid behavior name.", }, - target: { + argument: { oneOf: [{ type: 'string' }, { type: 'null' }], - errorMessage: "The 'target' must be a string or null.", + errorMessage: "The 'argument' must be a string or null.", }, }, required: ['name'], diff --git a/packages/config/src/configProcessor/processConfig/index.test.ts b/packages/config/src/configProcessor/processConfig/index.test.ts index 89f9156c..9512a509 100644 --- a/packages/config/src/configProcessor/processConfig/index.test.ts +++ b/packages/config/src/configProcessor/processConfig/index.test.ts @@ -84,7 +84,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'rewrite_request', - target: '/new-path', + argument: '/new-path', }), ]), ); @@ -178,7 +178,7 @@ describe('processConfig', () => { behaviors: expect.arrayContaining([ expect.objectContaining({ name: 'set_origin', - target: 'my origin storage', + argument: 'my origin storage', }), ]), }), @@ -246,7 +246,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'forward_cookies', - target: null, // Updated from 'params' to 'target' + argument: null, // Updated from 'params' to 'argument' }), ]), ); @@ -323,7 +323,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'set_origin', - target: 'my origin storage', + argument: 'my origin storage', }), ]), ); @@ -393,7 +393,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'run_function', - target: 'handler', + argument: 'handler', }), ]), ); @@ -547,7 +547,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'add_request_cookie', - target: 'sessionId=abc123', + argument: 'sessionId=abc123', }), ]), ); @@ -573,7 +573,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'add_request_header', - target: 'Authorization: Bearer abc123', + argument: 'Authorization: Bearer abc123', }), ]), ); @@ -962,7 +962,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'set_origin', - target: 'my single origin', + argument: 'my single origin', }), ]), ); @@ -1003,7 +1003,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'bypass_cache_phase', - target: null, + argument: null, }), ]), ); @@ -1029,7 +1029,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'redirect_to_301', - target: 'https://example.com', + argument: 'https://example.com', }), ]), ); @@ -1055,7 +1055,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'redirect_to_302', - target: 'https://example.com', + argument: 'https://example.com', }), ]), ); @@ -1085,7 +1085,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'capture_match_groups', - target: { + argument: { regex: '^/user/(.*)', captured_array: 'userId', // eslint-disable-next-line no-template-curly-in-string @@ -1116,7 +1116,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'filter_response_cookie', - target: '_cookie', + argument: '_cookie', }), ]), ); @@ -1142,7 +1142,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'add_response_header', - target: 'X-Test-Header: value', + argument: 'X-Test-Header: value', }), ]), ); @@ -1168,11 +1168,11 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'add_response_header', - target: 'X-Frame-Options: DENY', + argument: 'X-Frame-Options: DENY', }), expect.objectContaining({ name: 'add_response_header', - target: "Content-Security-Policy: default-src 'self'", + argument: "Content-Security-Policy: default-src 'self'", }), ]), ); @@ -1198,7 +1198,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'enable_gzip', - target: '', + argument: '', }), ]), ); @@ -1326,14 +1326,14 @@ describe('processConfig', () => { expect(result.rules[0].behaviors).toEqual([ expect.objectContaining({ name: 'add_request_header', - target: 'Authorization: Bearer abc123', + argument: 'Authorization: Bearer abc123', }), expect.objectContaining({ name: 'deliver', }), expect.objectContaining({ name: 'set_origin', - target: 'my origin storage', + argument: 'my origin storage', }), ]); }); @@ -1387,11 +1387,11 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'set_origin', - target: 'legacy origin', + argument: 'legacy origin', }), expect.objectContaining({ name: 'add_request_header', - target: 'Authorization: Bearer legacy', + argument: 'Authorization: Bearer legacy', }), ]), ); @@ -1416,11 +1416,11 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'add_response_header', - target: 'X-Legacy-Header: legacy', + argument: 'X-Legacy-Header: legacy', }), expect.objectContaining({ name: 'enable_gzip', - target: '', + argument: '', }), ]), ); @@ -1456,11 +1456,11 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'set_origin', - target: 'mixed origin', + argument: 'mixed origin', }), expect.objectContaining({ name: 'add_request_header', - target: 'Authorization: Bearer mixed', + argument: 'Authorization: Bearer mixed', }), ]), ); @@ -1487,11 +1487,11 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'add_response_header', - target: 'X-Mixed-Header: mixed', + argument: 'X-Mixed-Header: mixed', }), expect.objectContaining({ name: 'enable_gzip', - target: '', + argument: '', }), ]), ); @@ -1921,11 +1921,11 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'filter_request_header', - target: 'X-Test-Header', + argument: 'X-Test-Header', }), expect.objectContaining({ name: 'filter_request_cookie', - target: '_cookie', + argument: '_cookie', }), ]), ); @@ -1960,7 +1960,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'no_content', - target: null, + argument: null, }), ]), ); @@ -1995,7 +1995,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'deliver', - target: null, + argument: null, }), ]), ); @@ -2030,7 +2030,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'optimize_images', - target: null, + argument: null, }), ]), ); @@ -2065,7 +2065,7 @@ describe('processConfig', () => { expect.arrayContaining([ expect.objectContaining({ name: 'deny', - target: null, + argument: null, }), ]), ); diff --git a/packages/config/src/configProcessor/processStrategy/implementations/functionsProcessConfigStrategy.ts b/packages/config/src/configProcessor/processStrategy/implementations/functionsProcessConfigStrategy.ts index 9a075dc4..f1520672 100644 --- a/packages/config/src/configProcessor/processStrategy/implementations/functionsProcessConfigStrategy.ts +++ b/packages/config/src/configProcessor/processStrategy/implementations/functionsProcessConfigStrategy.ts @@ -28,7 +28,7 @@ class FunctionsProcessConfigStrategy extends ProcessConfigStrategy { return { name: func.name, - target: func.path, + argument: func.path, args: func.args || {}, bindings: func.bindings ? { @@ -54,7 +54,7 @@ class FunctionsProcessConfigStrategy extends ProcessConfigStrategy { transformedPayload.edgeFunctions = payload.functions.map((func: any) => { const config = { name: func.name, - path: func.target, + path: func.argument, args: func.args || {}, bindings: func.bindings ? { diff --git a/packages/config/src/types.ts b/packages/config/src/types.ts index 97337b6d..6ffd53e1 100644 --- a/packages/config/src/types.ts +++ b/packages/config/src/types.ts @@ -443,7 +443,7 @@ export type AzionEdgeFirewallCriteriaWithValue = AzionEdgeFirewallCriteriaBase & /** Operator for comparison that requires input value */ operator: RuleOperatorWithValue; /** Input value for comparison */ - argument: string; + inputValue: string; }; export type AzionEdgeFirewallCriteriaWithoutValue = AzionEdgeFirewallCriteriaBase & { From a99fe1157e2a4d2d4175cad4842ce2660314389f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Narciso?= Date: Tue, 3 Jun 2025 10:36:53 -0300 Subject: [PATCH 4/4] fix: return empty array instead of object when no edgeFunctions are present --- .../implementations/functionsProcessConfigStrategy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config/src/configProcessor/processStrategy/implementations/functionsProcessConfigStrategy.ts b/packages/config/src/configProcessor/processStrategy/implementations/functionsProcessConfigStrategy.ts index f1520672..1659329e 100644 --- a/packages/config/src/configProcessor/processStrategy/implementations/functionsProcessConfigStrategy.ts +++ b/packages/config/src/configProcessor/processStrategy/implementations/functionsProcessConfigStrategy.ts @@ -17,7 +17,7 @@ class FunctionsProcessConfigStrategy extends ProcessConfigStrategy { transformToManifest(config: AzionConfig) { if (!Array.isArray(config?.edgeFunctions) || config?.edgeFunctions.length === 0) { - return {}; + return []; } return config.edgeFunctions.map((func) => {