Skip to content

Commit

Permalink
Merge pull request #694 from aziontech/dev
Browse files Browse the repository at this point in the history
DEPLOY 2024.02.07
  • Loading branch information
csfeijo authored Feb 7, 2024
2 parents 7f7d524 + 234f7b6 commit 223663c
Show file tree
Hide file tree
Showing 114 changed files with 3,469 additions and 766 deletions.
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo "checking build integrity"
yarn build
rm -rf dist
rm -rf coverage
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.16.0
20.11.0
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azion-platform-kit",
"version": "1.8.3",
"version": "1.8.4",
"private": true,
"type": "module",
"repository": {
Expand Down Expand Up @@ -46,6 +46,7 @@
"@commitlint/config-conventional": "^17.7.0",
"@rushstack/eslint-patch": "^1.3.2",
"@tailwindcss/typography": "^0.5.10",
"caniuse-lite": "^1.0.30001584",
"@types/c3": "^0.7.11",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.0.1",
Expand Down
1 change: 1 addition & 0 deletions src/helpers/azion-documentation-catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const documentationCatalog = {
dataStreaming: () => openSearchResult('data streaming'),
edgeFunctions: () => openSearchResult('edge functions'),
edgeFirewall: () => openSearchResult('edge firewall'),
edgeFirewallRulesEngine: () => openSearchResult('edge firewall rules engine'),
edgeApplication: () => openSearchResult('edge application'),
edgeApplicationOrigins: () => openSearchResult('edge application origins'),
edgeApplicationCacheSettings: () => openSearchResult('cache settings'),
Expand Down
7 changes: 6 additions & 1 deletion src/helpers/metrics-playground-opener.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { getEnvironmentFromUrl } from './get-environment-from-url'

export const metricsPlaygroundOpener = () => {
window.open('https://azion.com', '_blank')
const environment = getEnvironmentFromUrl(window.location.href)
const subdomain = environment === 'prod' ? 'manager' : 'stage-manager'

window.open(`https://${subdomain}.azion.com/metrics/graphql`, '_blank')
}
49 changes: 34 additions & 15 deletions src/router/routes/edge-firewall-routes/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as Helpers from '@/helpers'
import * as DomainServices from '@/services/domains-services'
import * as EdgeFirewall from '@/services/edge-firewall-services'
import * as EdgeFirewallFunctions from '@/services/edge-firewall-functions-services'
import * as EdgeFirewallServices from '@/services/edge-firewall-services'
import * as EdgeFirewallFunctionsServices from '@/services/edge-firewall-functions-services'
import * as EdgeFirewallRulesEngineServices from '@/services/edge-firewall-rules-engine-services'
import * as WafRulesServices from '@/services/waf-rules-services'

/** @type {import('vue-router').RouteRecordRaw} */
export const edgeFirewallRoutes = {
Expand All @@ -13,8 +15,8 @@ export const edgeFirewallRoutes = {
name: 'list-edge-firewall',
component: () => import('@views/EdgeFirewall/ListView.vue'),
props: {
listEdgeFirewallService: EdgeFirewall.listEdgeFirewallService,
deleteEdgeFirewallService: EdgeFirewall.deleteEdgeFirewallService,
listEdgeFirewallService: EdgeFirewallServices.listEdgeFirewallService,
deleteEdgeFirewallService: EdgeFirewallServices.deleteEdgeFirewallService,
documentationService: Helpers.documentationCatalog.edgeFirewall
},
meta: {
Expand All @@ -32,7 +34,7 @@ export const edgeFirewallRoutes = {
component: () => import('@views/EdgeFirewall/CreateView.vue'),
props: {
listDomainsService: DomainServices.listDomainsService,
createEdgeFirewallService: EdgeFirewall.createEdgeFirewallService
createEdgeFirewallService: EdgeFirewallServices.createEdgeFirewallService
},
meta: {
breadCrumbs: [
Expand All @@ -52,21 +54,38 @@ export const edgeFirewallRoutes = {
name: 'edit-edge-firewall',
component: () => import('@/views/EdgeFirewall/TabsView.vue'),
props: {
listDomainsService: DomainServices.listDomainsService,
edgeFirewallServices: {
createEdgeFirewallService: EdgeFirewall.createEdgeFirewallService,
loadEdgeFirewallService: EdgeFirewall.loadEdgeFirewallService,
editEdgeFirewallService: EdgeFirewall.editEdgeFirewallService,
createEdgeFirewallService: EdgeFirewallServices.createEdgeFirewallService,
loadEdgeFirewallService: EdgeFirewallServices.loadEdgeFirewallService,
editEdgeFirewallService: EdgeFirewallServices.editEdgeFirewallService,

listEdgeFunctionsService: EdgeFirewallFunctions.listEdgeFunctionsService,
listEdgeFirewallFunctionService: EdgeFirewallFunctions.listEdgeFirewallFunctionsService,
createFunctionService: EdgeFirewallFunctions.createFunctionService,
editFunctionService: EdgeFirewallFunctions.editFunctionService,
deleteFunctionService: EdgeFirewallFunctions.deleteFunctionService,
loadFunctionService: EdgeFirewallFunctions.loadFunctionService,
listEdgeFunctionsService: EdgeFirewallFunctionsServices.listEdgeFunctionsService,
listEdgeFirewallFunctionService:
EdgeFirewallFunctionsServices.listEdgeFirewallFunctionsService,
createFunctionService: EdgeFirewallFunctionsServices.createFunctionService,
editFunctionService: EdgeFirewallFunctionsServices.editFunctionService,
deleteFunctionService: EdgeFirewallFunctionsServices.deleteFunctionService,
loadFunctionService: EdgeFirewallFunctionsServices.loadFunctionService,
documentationService: Helpers.documentationCatalog.edgeFirewall,
updatedRedirect: 'list-edge-firewall'
},
listDomainsService: DomainServices.listDomainsService
rulesEngineServices: {
listEdgeFirewallRulesEngineService:
EdgeFirewallRulesEngineServices.listEdgeFirewallRulesEngineService,
deleteEdgeFirewallRulesEngineService:
EdgeFirewallRulesEngineServices.deleteEdgeFirewallRulesEngineService,
createEdgeFirewallRulesEngineService:
EdgeFirewallRulesEngineServices.createEdgeFirewallRulesEngineService,
loadEdgeFirewallRulesEngineService:
EdgeFirewallRulesEngineServices.loadEdgeFirewallRulesEngineService,
editEdgeFirewallRulesEngineService:
EdgeFirewallRulesEngineServices.editEdgeFirewallRulesEngineService,

listFunctionsService: EdgeFirewallFunctionsServices.listFunctionsService,
listWafRulesService: WafRulesServices.listWafRulesService,
documentationService: Helpers.documentationCatalog.edgeFirewallRulesEngine
}
},
meta: {
breadCrumbs: [
Expand Down
5 changes: 3 additions & 2 deletions src/router/routes/metrics-routes/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { metricsPlaygroundOpener } from '@/helpers'
import { clipboardWrite, metricsPlaygroundOpener } from '@/helpers'

/** @type {import('vue-router').RouteRecordRaw} */
export const metricsRoutes = {
path: '/real-time-metrics/:pageId?/:dashboardId?',
name: 'real-time-metrics',
component: () => import('@views/Metrics/MetricsView.vue'),
props: {
playgroundOpener: metricsPlaygroundOpener
playgroundOpener: metricsPlaygroundOpener,
clipboardWrite
},
meta: {
breadCrumbs: [
Expand Down
4 changes: 2 additions & 2 deletions src/router/routes/waf-rules-routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const wafRulesRoutes = {
to: '/waf'
},
{
label: 'New WAF Rules',
label: 'Create WAF Rule',
to: '/waf/create'
}
]
Expand Down Expand Up @@ -80,7 +80,7 @@ export const wafRulesRoutes = {
to: '/waf'
},
{
label: 'Edit Waf Rules'
label: 'Edit WAF Rule'
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const getAccountSettingsService = async () => {
const adapt = (response) => {
return {
accountName: response.name,
clientId: response.id,
clientId: response.client_id,
companyName: response.company_name,
uniqueIdentifier: response.unique_identifier,
billingEmails: response.billing_emails,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ const getHeaders = (listHeaders) => {
const headers = {}
if (listHeaders.length > 0) {
listHeaders.forEach((element) => {
const [key, ...rest] = element.value.includes(':')
? element.value.split(':')
: [element.value]
const headerKey = key.trim()
headers[headerKey] = rest.length > 0 ? rest.join(':').trim() : headerKey
if (element.value.trim().length > 0) {
const [key, ...rest] = element.value.includes(':')
? element.value.split(':')
: [element.value]
const headerKey = key.trim()
headers[headerKey] = rest.length > 0 ? rest.join(':').trim() : headerKey
}
})
}
return headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ const getHeaders = (listHeaders) => {
const headers = {}
if (listHeaders.length > 0) {
listHeaders.forEach((element) => {
const [key, ...rest] = element.value.includes(':')
? element.value.split(':')
: [element.value]
const headerKey = key.trim()
headers[headerKey] = rest.length > 0 ? rest.join(':').trim() : headerKey
if (element.value.trim().length > 0) {
const [key, ...rest] = element.value.includes(':')
? element.value.split(':')
: [element.value]
const headerKey = key.trim()
headers[headerKey] = rest.length > 0 ? rest.join(':').trim() : headerKey
}
})
}
return headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,17 @@ const adapt = (payload) => {
/**
* @param {Object} errorSchema - The error schema.
* @param {string} key - The error key of error schema.
* @returns {string|undefined} The result message based on the status code.
* @returns {Object} An object containing the most specific error key and its message.
*/
const extractErrorKey = (errorSchema, key) => {
if (Array.isArray(errorSchema[key])) {
if (typeof errorSchema[key][0] === 'object') {
const newError = errorSchema[key][0]
const errorKey = Object.keys(errorSchema[key][0])
return newError[errorKey]?.[0]
const errorValue = errorSchema[key]
if (Array.isArray(errorValue)) {
if (errorValue.length > 0 && typeof errorValue[0] === 'object') {
return extractErrorKey(errorValue[0], Object.keys(errorValue[0])[0])
}
return errorSchema[key]?.[0]
return { key, message: errorValue[0] }
}
return errorSchema[key]
return { key, message: errorValue }
}

/**
Expand All @@ -59,9 +58,12 @@ const extractErrorKey = (errorSchema, key) => {
* @returns {string} The result message based on the status code.
*/
const extractApiError = (httpResponse) => {
const errorKey = Object.keys(httpResponse.body)[0]
const apiError = extractErrorKey(httpResponse.body, errorKey)
return `${errorKey}: ${apiError}`
for (const key of Object.keys(httpResponse.body)) {
const { key: innerKey, message } = extractErrorKey(httpResponse.body, key)
if (message) {
return `${innerKey}: ${message}`
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ export const editOriginService = async (payload) => {
}

const adapt = (payload) => {
const payloadAdapted = {
let payloadAdapted = {
name: payload.name,
host_header: payload.hostHeader,
origin_type: payload.originType,
method: payload.method,
is_origin_redirection_enabled: payload.isOriginRedirectionEnabled,
addresses: payload.addresses?.map((addressItem) => ({
address: addressItem.address,
weight: addressItem.weight,
server_role: addressItem.serverRole,
is_active: addressItem.isActive
})),
addresses: payload.addresses?.map((addressItem) => {
const address = {
address: addressItem.address,
server_role: addressItem.serverRole,
is_active: addressItem.isActive
}
if (addressItem.weight) {
address.weight = addressItem.weight
}
return address
}),
origin_path: payload.originPath,
origin_protocol_policy: payload.originProtocolPolicy,
hmac_authentication: payload.hmacAuthentication,
Expand All @@ -36,19 +40,27 @@ const adapt = (payload) => {
timeout_between_bytes: payload.timeoutBetweenBytes
}

if (payload.method) {
payloadAdapted.method = payload.method
}

return payloadAdapted
}

/**
* @param {Object} errorSchema - The error schema.
* @param {string} key - The error key of error schema.
* @returns {string|undefined} The result message based on the status code.
* @returns {Object} An object containing the most specific error key and its message.
*/
const extractErrorKey = (errorSchema, key) => {
if (Array.isArray(errorSchema[key])) {
return errorSchema[key]?.[0]
const errorValue = errorSchema[key]
if (Array.isArray(errorValue)) {
if (errorValue.length > 0 && typeof errorValue[0] === 'object') {
return extractErrorKey(errorValue[0], Object.keys(errorValue[0])[0])
}
return { key, message: errorValue[0] }
}
return errorSchema[key]
return { key, message: errorValue }
}

/**
Expand All @@ -57,9 +69,12 @@ const extractErrorKey = (errorSchema, key) => {
* @returns {string} The result message based on the status code.
*/
const extractApiError = (httpResponse) => {
const errorKey = Object.keys(httpResponse.body)[0]
const apiError = extractErrorKey(httpResponse.body, errorKey)
return `${errorKey}: ${apiError}`
for (const key of Object.keys(httpResponse.body)) {
const { key: innerKey, message } = extractErrorKey(httpResponse.body, key)
if (message) {
return `${innerKey}: ${message}`
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ export const editRulesEngineService = async ({ id, payload, reorder = false }) =
* @returns {string}
*/
const generateRulePhase = (payload) => {
const DEFAULT_RULE_PHASE = 'Default'
return payload.phase.content === DEFAULT_RULE_PHASE
? 'request'
: payload.phase.content?.toLowerCase()
let rulePhase = payload.phase
if (payload.phase?.content) {
rulePhase = payload.phase?.content
}

const DEFAULT_RULE_PHASE = 'default'
return rulePhase === DEFAULT_RULE_PHASE ? 'request' : rulePhase.toLowerCase()
}

const adapt = (payload, reorder) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const adapt = (payload) => {
: 0,
cdn_cache_settings: payload.cdnCacheSettings,
cdn_cache_settings_maximum_ttl: payload.cdnCacheSettingsMaximumTtl,
active: payload.active
debug_rules: payload.debugRules
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ const adapt = (httpResponse) => {
id: edgeApplication.id,
name: edgeApplication.name,
origins: originNames,
status: edgeApplication.active
? {
content: 'Active',
severity: 'success'
}
: {
content: 'Inactive',
severity: 'danger'
},
lastEditor: edgeApplication.last_editor,
lastModify: dateFormat(edgeApplication.last_modified),
lastModifyDate: edgeApplication.last_modified
Expand Down
4 changes: 3 additions & 1 deletion src/services/edge-firewall-functions-services/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { createFunctionService } from './create-function-service'
import { editFunctionService } from './edit-function-service'
import { deleteFunctionService } from './delete-function-service'
import { loadFunctionService } from './loader-function-service'
import { listFunctionsService } from './list-functions-service'

export {
listEdgeFirewallFunctionsService,
createFunctionService,
editFunctionService,
deleteFunctionService,
listEdgeFunctionsService,
loadFunctionService
loadFunctionService,
listFunctionsService
}
Loading

0 comments on commit 223663c

Please sign in to comment.