Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPLOY 2025-02-25 #2221

Merged
merged 12 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
push:
branches:
- dev
- UXE-6333-real-time-event-improvement-fork
env:
HUSKY: 0

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pre-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
push:
branches:
- dev
- UXE-6333-real-time-event-improvement-fork
workflow_dispatch:

env:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/security-linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ on:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- dev
- UXE-6333-real-time-event-improvement-fork
push:
branches:
- dev
- UXE-6333-real-time-event-improvement-fork
workflow_dispatch:

env:
Expand Down
43 changes: 16 additions & 27 deletions azion.config.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import { defineConfig } from 'azion'
import process from 'node:process'

const { CROSS_EDGE_SECRET, VITE_ENVIRONMENT } = process.env;
const { CROSS_EDGE_SECRET, VITE_ENVIRONMENT } = process.env

const environment = VITE_ENVIRONMENT || 'production'

const addStagePrefix = (origin) => {
if (environment === 'stage') {
return origin?.map((origin) => ({
...origin,
hostHeader: `stage-${origin.hostHeader}`,
addresses: origin.addresses?.map((addr) => `stage-${addr}`)
}))
return origin?.map(({ hostHeader, addresses, ...rest }) => {
const isCitiesDomain = hostHeader === 'cities.azion.com'
const transform = (addr) => `stage-${isCitiesDomain ? addr.replace('.com', '.net') : addr}`

return {
...rest,
hostHeader: transform(hostHeader),
addresses: addresses?.map(transform)
}
})
}
return origin
}
Expand Down Expand Up @@ -313,30 +318,14 @@ const config = {
}
},
{
name: 'Route GraphQL Billing Queries to Manager Origin',
description: 'Routes GraphQL Billing queries to the Manager, updating the URI accordingly',
match: '^/graphql/billing',
name: 'API Version 4 Routing',
description: 'Directs API version 4 requests to the designated API origin for handling.',
match: '^/v4',
behavior: {
forwardCookies: true,
setOrigin: {
name: 'origin-manager',
type: 'single_origin'
},
rewrite: '/billing/graphql'
}
},
{
name: 'Route GraphQL Accounting Queries to Manager Origin',
description:
'Routes GraphQL Accounting queries to the Manager, updating the URI accordingly',
match: '^/graphql/accounting',
behavior: {
forwardCookies: true,
setOrigin: {
name: 'origin-manager',
name: 'origin-api',
type: 'single_origin'
},
rewrite: '/accounting/graphql'
}
}
},
{
Expand Down
18 changes: 6 additions & 12 deletions azion/stage/azion.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "console-kit-2024-08-21-stage",
"bucket": "console-kit-2024-08-21-stage",
"preset": "vue",
"mode": "deliver",
"env": "production",
"prefix": "20240821142547",
"not-first-run": true,
Expand Down Expand Up @@ -123,11 +122,6 @@
"name": "Route GraphQL City Queries to Cities Origin",
"phase": "request"
},
{
"id": 277559,
"name": "Route GraphQL Billing Queries to Manager Origin",
"phase": "request"
},
{
"id": 277563,
"name": "Secure Headers",
Expand All @@ -143,11 +137,6 @@
"name": "Route API Identity Providers",
"phase": "request"
},
{
"id": 317377,
"name": "Route GraphQL Accounting Queries to Manager Origin",
"phase": "request"
},
{
"id": 368013,
"name": "Rewrite azrt Cookie in azion.com",
Expand Down Expand Up @@ -177,6 +166,11 @@
"id": 368018,
"name": "Rewrite azat Cookie in azionedge.net",
"phase": "response"
},
{
"id": 371432,
"name": "API Version 4 Routing",
"phase": "request"
}
]
},
Expand All @@ -190,4 +184,4 @@
"name": "Cities - Cache"
}
]
}
}
2 changes: 1 addition & 1 deletion cypress/e2mock/activity-history.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import selectors from '../support/selectors'
describe('Activity History Spec', { tags: ['@dev2'] }, () => {
beforeEach(() => {
cy.login()
cy.intercept('POST', '/api/v3/events/graphql', { fixture: 'activity-history.json' }).as('activityHistoryApi')
cy.intercept('POST', 'v4/events/graphql', { fixture: 'activity-history.json' }).as('activityHistoryApi')
cy.openProduct('Activity History')
})

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azion-console-kit",
"version": "1.31.7",
"version": "1.32.0",
"private": false,
"type": "module",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions src/helpers/convert-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const convertValueToDate = (value) => {
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: true
}
return date.toLocaleString('en-US', options)
Expand Down
62 changes: 61 additions & 1 deletion src/helpers/convert-gql.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,33 @@ function isValidDate(dateString) {
return !isNaN(Date.parse(dateString))
}

/**
* Builds a GraphQL query based on the provided parameters.
*
* @param {object} options - The options object containing filterParameter, dataset, limit, orderBy, filterQuery, and fields.
* @return {string} The constructed GraphQL query string.
*/
function buildGraphQLQueryTotalRecords({ filterParameter, dataset, limit, filterQuery, fields }) {
const filter = filterQuery.map((field) => `\t\t\t${field}`).join('\n')
return [
`query (`,
filterParameter.join('\n'),
`) {`,
`\t${dataset} (`,
`\t\tlimit: ${limit}`,
`\t\taggregate: {`,
`count: rows`,
`\t\t}`,
`\t\tfilter: {`,
filter,
`\t\t}`,
`\t) {`,
fields,
`\t}`,
`}`
].join('\n')
}

/**
* Builds a GraphQL query based on the provided parameters.
*
Expand Down Expand Up @@ -68,6 +95,39 @@ const formatValueContainOperator = (variable) => {
return variable
}

/**
* Convert filter and table to gql body
*
* @param {Object} filter - Object with the filter to apply
* @param {Object} table - Object with the table to query
* @returns {Object} Returns the body of the gql query with variables
*/
const convertGQLTotalRecords = (filter, table) => {
if (!table) throw new Error('Table parameter is required')

let variables = {}
const fields = filter?.fields || []
const filterQuery = buildFilterQuery(filter, variables)
const fieldsFormat = table.fields.map((field) => `\t\t${field}`).join('\n')
const filterParameter = formatFilterParameter(variables, fields)
variables = formatValueContainOperator(variables)

const queryConfig = {
filterParameter,
dataset: table.dataset,
limit: table.limit,
filterQuery,
fields: fieldsFormat
}

const query = buildGraphQLQueryTotalRecords(queryConfig)

return {
query,
variables
}
}

/**
* Convert filter and table to gql body
*
Expand Down Expand Up @@ -234,4 +294,4 @@ const formatFilterParameter = (variables, fields) => {
})
}

export default convertGQL
export { convertGQL, convertGQLTotalRecords }
8 changes: 4 additions & 4 deletions src/helpers/get-static-urls-by-environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const urls = {
production: 'https://manager.azion.com/billing-subscriptions'
},
playgroundMetrics: {
stage: 'https://stage-manager.azion.com/metrics/graphql',
production: 'https://manager.azion.com/metrics/graphql'
stage: 'https://stage-api.azion.com/v4/metrics/graphql',
production: 'https://api.azion.com/v4/metrics/graphql'
},
playgroundEvents: {
stage: 'https://stage-manager.azion.com/events/graphql',
production: 'https://manager.azion.com/events/graphql'
stage: 'https://stage-api.azion.com/v4/events/graphql',
production: 'https://api.azion.com/v4/events/graphql'
},
helpCenter: {
stage: 'https://storage.googleapis.com/gcs-docs-help-center-stage/console/',
Expand Down
3 changes: 2 additions & 1 deletion src/router/routes/real-time-events-routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export const realTimeEventsRoutes = {
listService: RealTimeEventsService.listActivityHistory,
loadService: RealTimeEventsService.loadActivityHistory
},
loadFieldsData: RealTimeEventsService.loadFieldsEventsData
loadFieldsData: RealTimeEventsService.loadFieldsEventsData,
getTotalRecords: RealTimeEventsService.getTotalRecords
},
meta: {
breadCrumbs: [
Expand Down
5 changes: 3 additions & 2 deletions src/services/axios/AxiosHttpClientAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const parseHttpResponse = (httpResponse) => {

export class AxiosHttpClientAdapter {
static async request(
{ url, method, headers, body, signal },
{ url, method, headers, body, signal, baseURL },
axios = defaultApi(import.meta.env.VITE_PERSONAL_TOKEN)
) {
let axiosResponse
Expand All @@ -50,7 +50,8 @@ export class AxiosHttpClientAdapter {
method: method,
headers: headers,
data: body,
signal
signal,
...(baseURL && { baseURL: baseURL })
})
} catch (error) {
const axiosError = error
Expand Down
5 changes: 3 additions & 2 deletions src/services/axios/AxiosHttpClientSignalDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ export class AxiosHttpClientSignalDecorator {
this.signal = signal
}

async request({ url, method, headers, body }) {
async request({ url, method, headers, body, baseURL }) {
return await AxiosHttpClientAdapter.request({
url,
method,
headers,
body,
signal: this.signal
signal: this.signal,
baseURL
})
}
}
3 changes: 1 addition & 2 deletions src/services/axios/makeEventsApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import axios from 'axios'

const api = (personalToken) => {
delete axios.defaults.headers.common['Authorization']
const version = 'v3'
const baseURL = `api/${version}/events`
const baseURL = `v4/events`

axios.defaults.headers.common['Accept'] = 'application/json'

Expand Down
15 changes: 6 additions & 9 deletions src/services/billing-services/list-payment-history-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { makePaymentBaseUrl } from './make-payment-base-url'
import { makeAccountingBaseUrl } from './make-accounting-base-url'
import { formatDateToUS, getStaticUrlsByEnvironment } from '@/helpers'
import { useAccountStore } from '@/stores/account'
import graphQLApi from '../axios/makeGraphQl'
import { getLastDayMonth } from '@/helpers/payment-history'

const PAGE_SIZE = 200
Expand Down Expand Up @@ -67,14 +66,12 @@ const listPaymentHistoryForRegularAccounts = async () => {
}`
}

let httpResponse = await AxiosHttpClientAdapter.request(
{
url: `${makeAccountingBaseUrl()}`,
method: 'POST',
body: payload
},
graphQLApi
)
let httpResponse = await AxiosHttpClientAdapter.request({
baseURL: '/',
url: `${makeAccountingBaseUrl()}`,
method: 'POST',
body: payload
})

return adaptPaymentHistoryForRegularAccounts(httpResponse)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { formatUnitValue } from '@/helpers'
import { AxiosHttpClientAdapter, parseHttpResponse } from '../axios/AxiosHttpClientAdapter'
import graphQLApi from '../axios/makeGraphQl'
import { makeAccountingBaseUrl } from './make-accounting-base-url'

export const listServiceAndProductsChangesAccountingService = async (billID) => {
Expand All @@ -27,14 +26,12 @@ export const listServiceAndProductsChangesAccountingService = async (billID) =>
query: BILL_DETAIL_QUERY
}

let httpResponse = await AxiosHttpClientAdapter.request(
{
url: `${makeAccountingBaseUrl()}`,
method: 'POST',
body: graphQLPayload
},
graphQLApi
)
let httpResponse = await AxiosHttpClientAdapter.request({
baseURL: '/',
url: `${makeAccountingBaseUrl()}`,
method: 'POST',
body: graphQLPayload
})

httpResponse = adapt(httpResponse)

Expand Down
Loading
Loading