-
Notifications
You must be signed in to change notification settings - Fork 1
Initialize vue project + Reports Overview component #1053
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
base: develop
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| pnpm-debug.log* | ||
|
|
||
| node_modules | ||
| .DS_Store | ||
| dist | ||
| coverage | ||
| *.local | ||
|
|
||
| # Editor directories and files | ||
| .vscode/* | ||
| !.vscode/extensions.json | ||
| .idea | ||
| *.suo | ||
| *.ntvs* | ||
| *.njsproj | ||
| *.sln | ||
| *.sw? | ||
|
|
||
| *.tsbuildinfo | ||
|
|
||
| .eslintcache | ||
|
|
||
| # Vitest | ||
| __screenshots__/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "translationSourcePaths": [ | ||
| "src/assets/translations/en-US.json" | ||
| ], | ||
| "locales": [ | ||
| "da-DK", | ||
| "de-DE", | ||
| "es-ES", | ||
| "fi-FI", | ||
| "fr-FR", | ||
| "it-IT", | ||
| "nl-NL", | ||
| "no-NO", | ||
| "pt-BR", | ||
| "sv-SE" | ||
| ], | ||
| "placeholderFormat": "YAML" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { spawnSync } from 'child_process'; | ||
| import { resolve, dirname } from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
| import { existsSync, readFileSync } from 'fs'; | ||
| import dotenv from 'dotenv'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
| const rootDir = resolve(__dirname, '..'); | ||
| const monorepoRoot = resolve(rootDir, '..'); | ||
|
|
||
| // Load .env from this project's envs/ or fall back to monorepo envs/env.default | ||
| const envPath = existsSync(resolve(rootDir, 'envs/.env')) | ||
| ? resolve(rootDir, 'envs/.env') | ||
| : existsSync(resolve(monorepoRoot, 'envs/.env')) | ||
| ? resolve(monorepoRoot, 'envs/.env') | ||
| : resolve(monorepoRoot, 'envs/env.default'); | ||
|
|
||
| const envContent = readFileSync(envPath, 'utf8'); | ||
| const parsed = dotenv.parse(envContent); | ||
| const port = process.env.PLAYGROUND_PORT || parsed.PLAYGROUND_PORT || '6007'; | ||
|
|
||
| const result = spawnSync('npx', ['storybook', 'dev', '-p', port, '--no-open'], { | ||
| cwd: rootDir, | ||
| stdio: 'inherit', | ||
| shell: true, | ||
| env: { | ||
| ...process.env, | ||
| STORYBOOK: 'true', | ||
| STORYBOOK_PORT: port, | ||
| }, | ||
| }); | ||
|
|
||
| process.exit(result.status); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,67 @@ | ||||||
| import { StorybookConfig } from '@storybook/vue3-vite'; | ||||||
| import { fileURLToPath, URL } from 'node:url'; | ||||||
| import { getEnvironment } from '../envs/getEnvs.ts'; | ||||||
| import { realApiProxies } from '../../endpoints/realApiProxies'; | ||||||
|
|
||||||
| const config: StorybookConfig = { | ||||||
| stories: ['../stories/**/*.stories.*'], | ||||||
| staticDirs: ['../../static'], | ||||||
| framework: { | ||||||
| name: '@storybook/vue3-vite', | ||||||
| options: {}, | ||||||
| }, | ||||||
| async viteFinal(config) { | ||||||
| const mode = process.env.VITE_MODE ?? 'development'; | ||||||
| const { api, app } = getEnvironment(mode); | ||||||
|
|
||||||
| const removeInspect = (plugins: any[]): any[] => | ||||||
| plugins.flat(Infinity).filter((p: any) => !(p && typeof p === 'object' && p.name === 'vite-plugin-inspect')); | ||||||
| config.plugins = removeInspect(config.plugins ?? []); | ||||||
|
|
||||||
| config.resolve = { | ||||||
| ...config.resolve, | ||||||
| alias: { | ||||||
| ...(config.resolve?.alias as Record<string, string>), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| '@': fileURLToPath(new URL('../src', import.meta.url)), | ||||||
| }, | ||||||
| }; | ||||||
|
|
||||||
| config.server = { | ||||||
| ...config.server, | ||||||
| proxy: { ...config.server?.proxy, ...realApiProxies(api, mode) }, | ||||||
| }; | ||||||
|
|
||||||
| config.define = { | ||||||
| ...config.define, | ||||||
| 'process.env.VITE_APP_PORT': JSON.stringify(app.port || null), | ||||||
| 'process.env.VITE_APP_URL': JSON.stringify(app.url || null), | ||||||
| 'process.env.VITE_APP_LOADING_CONTEXT': JSON.stringify(app.loadingContext || null), | ||||||
| 'process.env.VITE_LOCAL_ASSETS': JSON.stringify(process.env.USE_CDN === 'true' ? null : true), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic |
||||||
| 'process.env.VITE_VERSION': JSON.stringify('1.0.0'), | ||||||
| 'process.env.SESSION_ACCOUNT_HOLDER': JSON.stringify(api.session.accountHolder || null), | ||||||
| 'process.env.SESSION_AUTO_REFRESH': JSON.stringify(api.session.autoRefresh === 'true' || null), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the |
||||||
| 'process.env.SESSION_MAX_AGE_MS': JSON.stringify(api.session.maxAgeMs || null), | ||||||
| 'process.env.SESSION_PERMISSIONS': JSON.stringify(api.session.permissions || null), | ||||||
| 'process.env.USE_CDN': JSON.stringify(app.useCdn ?? null), | ||||||
| 'process.env.VITE_TEST_CDN_ASSETS': JSON.stringify(app.useTestCdn ? true : null), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current check for
Suggested change
|
||||||
| 'process.env.NODE_ENV': JSON.stringify(mode), | ||||||
| }; | ||||||
|
|
||||||
| config.build = { | ||||||
| ...config.build, | ||||||
| target: 'esnext', | ||||||
| chunkSizeWarningLimit: 800, | ||||||
| rollupOptions: { | ||||||
| ...config.build?.rollupOptions, | ||||||
| output: { | ||||||
| ...(config.build?.rollupOptions?.output as object), | ||||||
| experimentalMinChunkSize: 10_000, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| }, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| }, | ||||||
| }; | ||||||
|
|
||||||
| return config; | ||||||
| }, | ||||||
| }; | ||||||
|
|
||||||
| export default config; | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { addons } from 'storybook/manager-api'; | ||
|
|
||
| addons.setConfig({ | ||
| isFullscreen: false, | ||
| showPanel: true, | ||
| panelPosition: 'bottom', | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import type { Preview } from '@storybook/vue3'; | ||
| import { setup } from '@storybook/vue3'; | ||
| import { createI18n } from 'vue-i18n'; | ||
| import BentoPlugin from '@adyen/bento-vue3'; | ||
| import '@adyen/bento-vue3/fonts.css'; | ||
| import '@adyen/bento-vue3/styles/bento-light'; | ||
| import '../stories/utils/styles.scss'; | ||
|
|
||
| const i18n = createI18n({ | ||
| locale: 'en-US', | ||
| fallbackLocale: 'en-US', | ||
| fallbackRoot: false, | ||
| allowComposition: true, | ||
| legacy: false, | ||
| messages: { | ||
| 'en-US': {}, | ||
| }, | ||
| }); | ||
|
|
||
| setup(app => { | ||
| app.use(i18n); | ||
| app.use(BentoPlugin, { withToast: true, withDesignTokensCSSInjection: false }); | ||
| }); | ||
|
|
||
| const preview: Preview = { | ||
| parameters: { | ||
| controls: { | ||
| hideNoControlsWarning: true, | ||
| }, | ||
| }, | ||
| argTypes: { | ||
| locale: { | ||
| control: 'select', | ||
| options: ['da-DK', 'de-DE', 'en-US', 'es-ES', 'fi-FI', 'fr-FR', 'it-IT', 'nl-NL', 'no-NO', 'pt-BR', 'sv-SE'], | ||
| }, | ||
| }, | ||
| args: { | ||
| locale: 'en-US', | ||
| }, | ||
| }; | ||
|
|
||
| export default preview; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "extends": "../tsconfig.json", | ||
| "compilerOptions": { | ||
| "moduleResolution": "bundler", | ||
| "allowImportingTsExtensions": true | ||
| }, | ||
| "include": ["./**/*.ts", "../stories/**/*.ts", "../stories/**/*.vue", "../src/**/*.ts", "../src/**/*.vue"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| const baseUrl = 'https://platform-components-external-test.adyen.com/platform-components-external/api/v([0-9]+)'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| const datasetBaseUrl = '/datasets'; | ||
|
|
||
| export const endpoints = () => | ||
| ({ | ||
| balanceAccounts: `${baseUrl}/balanceAccounts`, | ||
| balances: `${baseUrl}/balanceAccounts/:id/balances`, | ||
| payouts: `${baseUrl}/payouts`, | ||
| payout: `${baseUrl}/payouts/breakdown`, | ||
| transactions: `${baseUrl}/transactions`, | ||
| transaction: `${baseUrl}/transactions/:id`, | ||
| initiateRefund: `${baseUrl}/transactions/:id/refund`, | ||
| transactionsTotals: `${baseUrl}/transactions/totals`, | ||
| downloadTransactions: `${baseUrl}/transactions/download`, | ||
| sessions: '/api/authe/api/v1/sessions', | ||
| setup: `${baseUrl}/setup`, | ||
| sendEngageEvent: `${baseUrl}/uxdsclient/engage`, | ||
| sendTrackEvent: `${baseUrl}/uxdsclient/track`, | ||
| reports: `${baseUrl}/reports`, | ||
| downloadReport: `${baseUrl}/reports/download`, | ||
| stores: `${baseUrl}/stores`, | ||
| capital: { | ||
| anaCredit: `${baseUrl}/capital/grants/missingActions/anaCredit`, | ||
| createOffer: `${baseUrl}/capital/grantOffers/create`, | ||
| dynamicOfferConfig: `${baseUrl}/capital/grantOffers/dynamic/configuration`, | ||
| dynamicOffer: `${baseUrl}/capital/grantOffers/dynamic`, | ||
| grants: `${baseUrl}/capital/grants`, | ||
| requestFunds: `${baseUrl}/capital/grants/:id`, | ||
| signToS: `${baseUrl}/capital/grants/missingActions/signToS`, | ||
| }, | ||
| disputes: { | ||
| accept: `${baseUrl}/disputes/:id/accept`, | ||
| defend: `${baseUrl}/disputes/:id/defend`, | ||
| details: `${baseUrl}/disputes/:id`, | ||
| documents: `${baseUrl}/disputes/:id/documents`, | ||
| download: `${baseUrl}/disputes/:id/documents/download`, | ||
| list: `${baseUrl}/disputes`, | ||
| }, | ||
| payByLink: { | ||
| configuration: `${baseUrl}/paybylink/paymentLinks/:storeId/configuration`, | ||
| countries: `${baseUrl}/paybylink/countries`, | ||
| currencies: `${baseUrl}/paybylink/currencies`, | ||
| details: `${baseUrl}/paybylink/paymentLinks/:id`, | ||
| expire: `${baseUrl}/paybylink/paymentLinks/:id/expire`, | ||
| filters: `${baseUrl}/paybylink/filters`, | ||
| installments: `${baseUrl}/paybylink/installments`, | ||
| list: `${baseUrl}/paybylink/paymentLinks`, | ||
| settings: `${baseUrl}/paybylink/settings/:storeId`, | ||
| themes: `${baseUrl}/paybylink/themes/:id`, | ||
| }, | ||
| datasets: { | ||
| countries: `${datasetBaseUrl}/countries/:locale.json?import`, | ||
| }, | ||
| }) as const; | ||
|
Comment on lines
+4
to
+54
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The export const endpoints = {
balanceAccounts: `${baseUrl}/balanceAccounts`,
balances: `${baseUrl}/balanceAccounts/:id/balances`,
payouts: `${baseUrl}/payouts`,
payout: `${baseUrl}/payouts/breakdown`,
transactions: `${baseUrl}/transactions`,
transaction: `${baseUrl}/transactions/:id`,
initiateRefund: `${baseUrl}/transactions/:id/refund`,
transactionsTotals: `${baseUrl}/transactions/totals`,
downloadTransactions: `${baseUrl}/transactions/download`,
sessions: '/api/authe/api/v1/sessions',
setup: `${baseUrl}/setup`,
sendEngageEvent: `${baseUrl}/uxdsclient/engage`,
sendTrackEvent: `${baseUrl}/uxdsclient/track`,
reports: `${baseUrl}/reports`,
downloadReport: `${baseUrl}/reports/download`,
stores: `${baseUrl}/stores`,
capital: {
anaCredit: `${baseUrl}/capital/grants/missingActions/anaCredit`,
createOffer: `${baseUrl}/capital/grantOffers/create`,
dynamicOfferConfig: `${baseUrl}/capital/grantOffers/dynamic/configuration`,
dynamicOffer: `${baseUrl}/capital/grantOffers/dynamic`,
grants: `${baseUrl}/capital/grants`,
requestFunds: `${baseUrl}/capital/grants/:id`,
signToS: `${baseUrl}/capital/grants/missingActions/signToS`,
},
disputes: {
accept: `${baseUrl}/disputes/:id/accept`,
defend: `${baseUrl}/disputes/:id/defend`,
details: `${baseUrl}/disputes/:id`,
documents: `${baseUrl}/disputes/:id/documents`,
download: `${baseUrl}/disputes/:id/documents/download`,
list: `${baseUrl}/disputes`,
},
payByLink: {
configuration: `${baseUrl}/paybylink/paymentLinks/:storeId/configuration`,
countries: `${baseUrl}/paybylink/countries`,
currencies: `${baseUrl}/paybylink/currencies`,
details: `${baseUrl}/paybylink/paymentLinks/:id`,
expire: `${baseUrl}/paybylink/paymentLinks/:id/expire`,
filters: `${baseUrl}/paybylink/filters`,
installments: `${baseUrl}/paybylink/installments`,
list: `${baseUrl}/paybylink/paymentLinks`,
settings: `${baseUrl}/paybylink/settings/:storeId`,
themes: `${baseUrl}/paybylink/themes/:id`,
},
datasets: {
countries: `${datasetBaseUrl}/countries/:locale.json?import`,
},
} as const; |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { dirname, resolve } from 'path'; | ||
| import { loadEnv } from 'vite'; | ||
| import { fileURLToPath } from 'url'; | ||
|
|
||
| const filename = fileURLToPath(import.meta.url); | ||
|
|
||
| // Point to project root (parent of envs/ directory) | ||
| const envDir = resolve(dirname(filename), '..'); | ||
|
|
||
| const parseEnv = (env: Record<string, string | undefined>) => { | ||
| // Interpolate shell-style variables like $PLAYGROUND_HOST:$PLAYGROUND_PORT | ||
| const interpolate = (value: string | undefined): string | undefined => { | ||
| if (!value) return value; | ||
| return value.replace(/\$PLAYGROUND_HOST/g, env.PLAYGROUND_HOST ?? 'localhost').replace(/\$PLAYGROUND_PORT/g, env.PLAYGROUND_PORT ?? '5173'); | ||
| }; | ||
|
|
||
| return { | ||
| api: { | ||
| session: { | ||
| accountHolder: env.SESSION_ACCOUNT_HOLDER, | ||
| apiKey: env.API_KEY, | ||
| autoRefresh: env.SESSION_AUTO_REFRESH, | ||
| maxAgeMs: env.SESSION_MAX_AGE_MS, | ||
| permissions: env.SESSION_PERMISSIONS, | ||
| url: env.SESSION_API_URL ?? '', | ||
| }, | ||
| }, | ||
| app: { | ||
| host: env.PLAYGROUND_HOST ?? 'localhost', | ||
| port: parseInt(env.PLAYGROUND_PORT ?? '5173'), | ||
| loadingContext: env.LOADING_CONTEXT, | ||
| url: interpolate(env.PLAYGROUND_URL) ?? `http://${env.PLAYGROUND_HOST ?? 'localhost'}:${env.PLAYGROUND_PORT ?? '5173'}/`, | ||
| useCdn: env.USE_CDN, | ||
| useTestCdn: env.USE_TEST_CDN, | ||
| }, | ||
| }; | ||
| }; | ||
|
|
||
| export type Environment = ReturnType<typeof parseEnv>; | ||
|
|
||
| export const getEnvironment = (mode: string): Environment => { | ||
| const envVars = { ...process.env, ...loadEnv(mode, envDir, '') }; | ||
| return parseEnv(envVars); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "paths": { | ||
| "@/*": ["./src/*"] | ||
| } | ||
| }, | ||
| "exclude": ["node_modules", "dist"] | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,54 @@ | ||||||
| { | ||||||
| "name": "@adyen/adyen-platform-experience-web-vue", | ||||||
| "version": "0.0.0", | ||||||
| "private": false, | ||||||
| "type": "module", | ||||||
| "main": "./dist/es/index.js", | ||||||
| "module": "./dist/es/index.js", | ||||||
| "types": "./dist/index.d.ts", | ||||||
| "exports": { | ||||||
| ".": { | ||||||
| "types": "./dist/index.d.ts", | ||||||
| "import": "./dist/es/index.js" | ||||||
| }, | ||||||
| "./style.css": "./dist/adyen-platform-experience-web-vue.css" | ||||||
| }, | ||||||
| "sideEffects": [ | ||||||
| "**/*.css" | ||||||
| ], | ||||||
| "files": [ | ||||||
| "dist" | ||||||
| ], | ||||||
| "scripts": { | ||||||
| "start": "pnpm run storybook", | ||||||
| "build": "vite build && vue-tsc -p tsconfig.build.json", | ||||||
| "preview": "vite preview", | ||||||
| "storybook": "node .storybook/dev.js", | ||||||
| "storybook:build": "storybook build", | ||||||
| "test": "cross-env TEST_ENV=1 vitest --config vite.config.ts" | ||||||
| }, | ||||||
| "dependencies": { | ||||||
| "@adyen/bento-vue3": "^1.86.0", | ||||||
| "vue-i18n": "^11" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||
| }, | ||||||
| "peerDependencies": { | ||||||
| "vue": "^3.3.0" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||
| }, | ||||||
| "devDependencies": { | ||||||
| "@storybook/vue3": "^10.1.10", | ||||||
|
Comment on lines
+40
to
+42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Storybook dependencies ( |
||||||
| "@storybook/vue3-vite": "^10.1.10", | ||||||
| "@types/node": "^24.10.13", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| "@vitejs/plugin-vue": "^6.0.3", | ||||||
| "cross-env": "^10.1.0", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| "dotenv": "^16.4.7", | ||||||
| "sass": "^1.77.6", | ||||||
| "storybook": "^10.1.10", | ||||||
| "terser": "^5.46.0", | ||||||
| "typescript": "^5.8.3", | ||||||
| "vite": "^7.3.0", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| "vite-plugin-vue-devtools": "^8.0.5", | ||||||
| "vitest": "^4.0.18", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| "vue": "^3.5.26", | ||||||
| "vue-tsc": "^2.2.4" | ||||||
| } | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
any[]for plugin types bypasses TypeScript's type checking, which can lead to unexpected runtime errors. Consider defining a more specific type forpluginsand the individualpelements to leverage TypeScript's benefits fully.