@inizioevoke/veeva-astroclm-core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/.editorconfig +12 -0
  2. package/build.ts +38 -0
  3. package/dist/apps/index.d.ts +2 -0
  4. package/dist/apps/index.js +2 -0
  5. package/dist/apps/page-manager/bulk-create.d.ts +1 -0
  6. package/dist/apps/page-manager/bulk-create.js +120 -0
  7. package/dist/apps/page-manager/index.d.ts +5 -0
  8. package/dist/apps/page-manager/index.js +24 -0
  9. package/dist/apps/page-manager/single-create.d.ts +1 -0
  10. package/dist/apps/page-manager/single-create.js +78 -0
  11. package/dist/apps/page-manager/templates/contents.astro.txt +12 -0
  12. package/dist/apps/page-manager/templates/page.astro.txt +4 -0
  13. package/dist/apps/page-manager/utils.d.ts +10 -0
  14. package/dist/apps/page-manager/utils.js +57 -0
  15. package/dist/apps/utils.d.ts +5 -0
  16. package/dist/apps/utils.js +43 -0
  17. package/dist/apps/veeva-config-manager/create.d.ts +1 -0
  18. package/dist/apps/veeva-config-manager/create.js +136 -0
  19. package/dist/apps/veeva-config-manager/index.d.ts +3 -0
  20. package/dist/apps/veeva-config-manager/index.js +16 -0
  21. package/dist/apps/veeva-config-manager/templates/config.ts.txt +60 -0
  22. package/dist/env/schema.d.ts +15 -0
  23. package/dist/env/schema.js +28 -0
  24. package/dist/lib/const.d.ts +15 -0
  25. package/dist/lib/const.js +14 -0
  26. package/dist/lib/env.d.ts +8 -0
  27. package/dist/lib/env.js +17 -0
  28. package/dist/lib/index.d.ts +5 -0
  29. package/dist/lib/index.js +5 -0
  30. package/dist/lib/logger.d.ts +9 -0
  31. package/dist/lib/logger.js +72 -0
  32. package/dist/lib/parse-argv.d.ts +31 -0
  33. package/dist/lib/parse-argv.js +109 -0
  34. package/dist/lib/parse-env.d.ts +45 -0
  35. package/dist/lib/parse-env.js +124 -0
  36. package/dist/lib/utils.d.ts +8 -0
  37. package/dist/lib/utils.js +37 -0
  38. package/dist/tasks/copy-files.d.ts +9 -0
  39. package/dist/tasks/copy-files.js +15 -0
  40. package/dist/tasks/create-csv.d.ts +15 -0
  41. package/dist/tasks/create-csv.js +186 -0
  42. package/dist/tasks/create-zips.d.ts +5 -0
  43. package/dist/tasks/create-zips.js +16 -0
  44. package/dist/tasks/deploy.d.ts +10 -0
  45. package/dist/tasks/deploy.js +49 -0
  46. package/dist/tasks/generate-thumbs.d.ts +12 -0
  47. package/dist/tasks/generate-thumbs.js +152 -0
  48. package/dist/tasks/index.d.ts +1 -0
  49. package/dist/tasks/index.js +1 -0
  50. package/dist/tasks/update-shared.d.ts +5 -0
  51. package/dist/tasks/update-shared.js +41 -0
  52. package/dist/types/config.d.ts +52 -0
  53. package/dist/types/env.d.ts +7 -0
  54. package/dist/types/index.d.ts +9 -0
  55. package/dist/types/veeva.d.ts +58 -0
  56. package/dist/veeva/slideManager.d.ts +33 -0
  57. package/dist/veeva/slideManager.js +120 -0
  58. package/package.json +39 -0
  59. package/src/apps/index.ts +2 -0
  60. package/src/apps/page-manager/bulk-create.ts +131 -0
  61. package/src/apps/page-manager/index.ts +31 -0
  62. package/src/apps/page-manager/single-create.ts +97 -0
  63. package/src/apps/page-manager/templates/contents.astro.txt +12 -0
  64. package/src/apps/page-manager/templates/page.astro.txt +4 -0
  65. package/src/apps/page-manager/utils.ts +70 -0
  66. package/src/apps/utils.ts +47 -0
  67. package/src/apps/veeva-config-manager/create.ts +153 -0
  68. package/src/apps/veeva-config-manager/index.ts +20 -0
  69. package/src/apps/veeva-config-manager/templates/config.ts.txt +60 -0
  70. package/src/env/schema.ts +43 -0
  71. package/src/lib/const.ts +17 -0
  72. package/src/lib/env.ts +27 -0
  73. package/src/lib/index.ts +5 -0
  74. package/src/lib/logger.ts +84 -0
  75. package/src/lib/parse-argv.ts +125 -0
  76. package/src/lib/parse-env.ts +147 -0
  77. package/src/lib/utils.ts +37 -0
  78. package/src/tasks/copy-files.ts +29 -0
  79. package/src/tasks/create-csv.ts +259 -0
  80. package/src/tasks/create-zips.ts +21 -0
  81. package/src/tasks/deploy.ts +72 -0
  82. package/src/tasks/generate-thumbs.ts +179 -0
  83. package/src/tasks/index.ts +1 -0
  84. package/src/tasks/update-shared.ts +49 -0
  85. package/src/types/config.d.ts +52 -0
  86. package/src/types/env.d.ts +7 -0
  87. package/src/types/index.d.ts +9 -0
  88. package/src/types/veeva.d.ts +58 -0
  89. package/src/veeva/readme.md +77 -0
  90. package/src/veeva/slideManager.ts +139 -0
  91. package/tsconfig.json +27 -0
@@ -0,0 +1,15 @@
1
+ import { envField } from 'astro/config';
2
+ type BooleanField = ReturnType<typeof envField.boolean>;
3
+ type EnumField = ReturnType<typeof envField.enum>;
4
+ export type EnvFieldName = 'BUILD_TARGET' | 'WEB_ENV' | 'WEB_SCALING' | 'VEEVA_TRAINING' | 'VEEVA_ENV' | 'VEEVA_PLATFORM' | 'LOG_LEVEL' | 'LOG_TIME' | 'LOG_OUTPUT';
5
+ export declare const BUILD_TARGET: EnumField;
6
+ export declare const WEB_ENV: EnumField;
7
+ export declare const WEB_SCALING: BooleanField;
8
+ export declare const VEEVA_TRAINING: BooleanField;
9
+ export declare const VEEVA_ENV: EnumField;
10
+ export declare const VEEVA_PLATFORM: EnumField;
11
+ export declare const LOG_LEVEL: EnumField;
12
+ export declare const LOG_TIME: EnumField;
13
+ export declare const LOG_OUTPUT: EnumField;
14
+ declare const schema: Record<EnvFieldName, BooleanField | EnumField>;
15
+ export default schema;
@@ -0,0 +1,28 @@
1
+ import { envField } from 'astro/config';
2
+ import { BUILD_TARGETS, WEB_ENVS, VEEVA_ENVS, VEEVA_PLATFORMS, LOG_LEVELS, LOG_TIMES, LOG_OUTPUTS, DEFAULT_BUILD_TARGET, DEFAULT_WEB_ENV, DEFAULT_VEEVA_ENV, DEFAULT_VEEVA_PLATFORM, DEFAULT_LOG_LEVEL, DEFAULT_LOG_TIME, DEFAULT_LOG_OUTPUT, } from '../lib/const.js';
3
+ const envPublicOptional = {
4
+ context: 'client',
5
+ access: 'public',
6
+ optional: true
7
+ };
8
+ export const BUILD_TARGET = envField.enum({ ...envPublicOptional, values: BUILD_TARGETS, default: DEFAULT_BUILD_TARGET });
9
+ export const WEB_ENV = envField.enum({ ...envPublicOptional, values: WEB_ENVS, default: DEFAULT_WEB_ENV });
10
+ export const WEB_SCALING = envField.boolean({ ...envPublicOptional, default: false });
11
+ export const VEEVA_TRAINING = envField.boolean({ ...envPublicOptional, default: false });
12
+ export const VEEVA_ENV = envField.enum({ ...envPublicOptional, values: VEEVA_ENVS, default: DEFAULT_VEEVA_ENV });
13
+ export const VEEVA_PLATFORM = envField.enum({ ...envPublicOptional, values: VEEVA_PLATFORMS, default: DEFAULT_VEEVA_PLATFORM });
14
+ export const LOG_LEVEL = envField.enum({ ...envPublicOptional, values: LOG_LEVELS, default: DEFAULT_LOG_LEVEL });
15
+ export const LOG_TIME = envField.enum({ ...envPublicOptional, values: LOG_TIMES, default: DEFAULT_LOG_TIME });
16
+ export const LOG_OUTPUT = envField.enum({ ...envPublicOptional, values: LOG_OUTPUTS, default: DEFAULT_LOG_OUTPUT });
17
+ const schema = {
18
+ BUILD_TARGET,
19
+ WEB_ENV,
20
+ WEB_SCALING,
21
+ VEEVA_TRAINING,
22
+ VEEVA_ENV,
23
+ VEEVA_PLATFORM,
24
+ LOG_LEVEL,
25
+ LOG_TIME,
26
+ LOG_OUTPUT
27
+ };
28
+ export default schema;
@@ -0,0 +1,15 @@
1
+ import type { BuildTarget, WebEnv, VeevaEnv, VeevaPlatform, LogLevel, LogTime, LogOutput } from '../types';
2
+ export declare const BUILD_TARGETS: BuildTarget[];
3
+ export declare const WEB_ENVS: WebEnv[];
4
+ export declare const VEEVA_ENVS: VeevaEnv[];
5
+ export declare const VEEVA_PLATFORMS: VeevaPlatform[];
6
+ export declare const LOG_LEVELS: LogLevel[];
7
+ export declare const LOG_TIMES: LogTime[];
8
+ export declare const LOG_OUTPUTS: LogOutput[];
9
+ export declare const DEFAULT_BUILD_TARGET: BuildTarget;
10
+ export declare const DEFAULT_WEB_ENV: WebEnv;
11
+ export declare const DEFAULT_VEEVA_ENV: VeevaEnv;
12
+ export declare const DEFAULT_VEEVA_PLATFORM: VeevaPlatform;
13
+ export declare const DEFAULT_LOG_LEVEL: LogLevel;
14
+ export declare const DEFAULT_LOG_TIME: LogTime;
15
+ export declare const DEFAULT_LOG_OUTPUT: LogOutput;
@@ -0,0 +1,14 @@
1
+ export const BUILD_TARGETS = ['veeva', 'web'];
2
+ export const WEB_ENVS = ['development', 'production'];
3
+ export const VEEVA_ENVS = ['client', 'evoke'];
4
+ export const VEEVA_PLATFORMS = ['salesforce', 'vault'];
5
+ export const LOG_LEVELS = ['disabled', 'error', 'debug'];
6
+ export const LOG_TIMES = ['none', 'date', 'time', 'datetime', 'performance'];
7
+ export const LOG_OUTPUTS = ['console', 'screen'];
8
+ export const DEFAULT_BUILD_TARGET = 'web';
9
+ export const DEFAULT_WEB_ENV = 'development';
10
+ export const DEFAULT_VEEVA_ENV = 'client';
11
+ export const DEFAULT_VEEVA_PLATFORM = 'salesforce';
12
+ export const DEFAULT_LOG_LEVEL = 'disabled';
13
+ export const DEFAULT_LOG_TIME = 'time';
14
+ export const DEFAULT_LOG_OUTPUT = 'console';
@@ -0,0 +1,8 @@
1
+ import type { BuildTarget, VeevaEnv, VeevaPlatform } from '../types';
2
+ export interface Env {
3
+ BUILD_TARGET: BuildTarget;
4
+ VEEVA_ENV: VeevaEnv;
5
+ VEEVA_PLATFORM: VeevaPlatform;
6
+ VEEVA_TRAINING: boolean;
7
+ }
8
+ export default function loadEnv(mode?: string): Promise<Env>;
@@ -0,0 +1,17 @@
1
+ import * as Constants from './const.js';
2
+ import parseEnv from "./parse-env.js";
3
+ export default async function loadEnv(mode) {
4
+ const env = await parseEnv({
5
+ BUILD_TARGET: Constants.BUILD_TARGETS,
6
+ VEEVA_ENV: Constants.VEEVA_ENVS,
7
+ VEEVA_PLATFORM: Constants.VEEVA_PLATFORMS,
8
+ VEEVA_TRAINING: 'boolean'
9
+ }, {
10
+ mode
11
+ });
12
+ env.BUILD_TARGET = env.BUILD_TARGET ?? Constants.DEFAULT_BUILD_TARGET,
13
+ env.VEEVA_ENV = env.VEEVA_ENV ?? Constants.DEFAULT_VEEVA_ENV,
14
+ env.VEEVA_PLATFORM = env.VEEVA_PLATFORM ?? Constants.DEFAULT_VEEVA_PLATFORM,
15
+ env.VEEVA_TRAINING = env.VEEVA_TRAINING ?? false;
16
+ return env;
17
+ }
@@ -0,0 +1,5 @@
1
+ export * from './const.js';
2
+ export { default as loadEnv } from './env.js';
3
+ export { default as parseArgv } from './parse-argv.js';
4
+ export { default as parseEnv } from './parse-env.js';
5
+ export * from './utils.js';
@@ -0,0 +1,5 @@
1
+ export * from './const.js';
2
+ export { default as loadEnv } from './env.js';
3
+ export { default as parseArgv } from './parse-argv.js';
4
+ export { default as parseEnv } from './parse-env.js';
5
+ export * from './utils.js';
@@ -0,0 +1,9 @@
1
+ export declare function info(message: string): void;
2
+ export declare function warn(message: string): void;
3
+ export declare function error(message: string): void;
4
+ declare const _default: {
5
+ info: typeof info;
6
+ warn: typeof warn;
7
+ error: typeof error;
8
+ };
9
+ export default _default;
@@ -0,0 +1,72 @@
1
+ const Style = Object.freeze({
2
+ Background: {
3
+ Black: '\x1b[40m',
4
+ Red: '\x1b[41m',
5
+ Green: '\x1b[42m',
6
+ Yellow: '\x1b[43m',
7
+ Blue: '\x1b[44m',
8
+ Magenta: '\x1b[45m',
9
+ Cyan: '\x1b[46m',
10
+ White: '\x1b[47m',
11
+ Gray: '\x1b[100m',
12
+ BrightRed: '\x1b[101m',
13
+ BrightGreen: '\x1b[102m',
14
+ BrightYellow: '\x1b[103m',
15
+ BrightBlue: '\x1b[104m',
16
+ BrightMagenta: '\x1b[105m',
17
+ BrightCyan: '\x1b[106m',
18
+ BrightWhite: '\x1b[107m'
19
+ },
20
+ Foreground: {
21
+ Black: '\x1b[30m',
22
+ Red: '\x1b[31m',
23
+ Green: '\x1b[32m',
24
+ Yellow: '\x1b[33m',
25
+ Blue: '\x1b[34m',
26
+ Magenta: '\x1b[35m',
27
+ Cyan: '\x1b[36m',
28
+ White: '\x1b[37m',
29
+ Gray: '\x1b[90m',
30
+ BrightRed: '\x1b[91m',
31
+ BrightGreen: '\x1b[92m',
32
+ BrightYellow: '\x1b[93m',
33
+ BrightBlue: '\x1b[94m',
34
+ BrightMagenta: '\x1b[95m',
35
+ BrightCyan: '\x1b[96m',
36
+ BrightWhite: '\x1b[97m'
37
+ },
38
+ Bold: '\x1b[1m',
39
+ Inverse: '\x1b[7m',
40
+ Reset: '\x1b[0m',
41
+ Underscore: '\x1b[4m'
42
+ });
43
+ function _log({ task, message, data, style }) {
44
+ const now = new Date();
45
+ const ts = `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}`;
46
+ const msg = [`${Style.Foreground.Gray}${ts}${Style.Reset}`];
47
+ if (task) {
48
+ msg.push(`${Style.Foreground.Cyan}[${task}]${Style.Reset}`);
49
+ }
50
+ msg.push(`${style ?? Style.Reset}${message}${Style.Reset}`);
51
+ if (data) {
52
+ msg.push(`${Style.Foreground.Yellow}${data}${Style.Reset}`);
53
+ }
54
+ console.log(msg.join(' '));
55
+ }
56
+ export function info(message) {
57
+ _log({ message, style: Style.Foreground.White });
58
+ // _log({ task, message, data, style: Style.Foreground.White });
59
+ }
60
+ export function warn(message) {
61
+ _log({ message, style: Style.Foreground.Yellow });
62
+ // _log({ task, message, data, style: Style.Foreground.Yellow });
63
+ }
64
+ export function error(message) {
65
+ _log({ message, style: Style.Foreground.Red });
66
+ // _log({ task, message, data, style: Style.Foreground.Red });
67
+ }
68
+ export default {
69
+ info,
70
+ warn,
71
+ error
72
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Parses process.argv or any string[] into an object with the given schema
3
+ * Properties should be prefixed with `--`
4
+ * Values should come immediately after the property and be separated by a space or `=`
5
+ * Type `array` can only be a array of `boolean`, `number`, or `string` types
6
+ * Type `boolean` will be `true` if present and not followed by `=[VALUE]`
7
+ * Type `object` property values can only by of `boolean`, `number`, or `string` types
8
+ * Schema entries may also be string‑literal arrays, which are treated as enum
9
+ * definitions; the resulting value will be typed as the union of the literals.
10
+ *
11
+ * @example
12
+ * const argv = parseArgv({
13
+ * a: 'array',
14
+ * b: 'boolean',
15
+ * b2: 'boolean',
16
+ * f: 'float',
17
+ * n: 'number',
18
+ * o: 'object',
19
+ * s: 'string',
20
+ * mode: ['dev','prod'] as const // enum-style union
21
+ * })
22
+ *
23
+ * > npm run build -- --a [one,2,false] --b --b2=false --f 3.14 --n 123 --o {one:1,nope:false,hello:world} --s mystring --mode dev
24
+ *
25
+ */
26
+ type Type = 'array' | 'boolean' | 'float' | 'number' | 'object' | 'string';
27
+ type Schema<S extends Record<string, Type | readonly string[]>> = {
28
+ [K in keyof S]: S[K] extends readonly (infer U)[] ? U | undefined : S[K] extends 'array' ? any[] | undefined : S[K] extends 'boolean' ? boolean | undefined : S[K] extends 'float' ? number | undefined : S[K] extends 'number' ? number | undefined : S[K] extends 'object' ? Record<string, any> | undefined : S[K] extends 'string' ? string | undefined : string | undefined;
29
+ };
30
+ export default function <S extends Record<string, Type | readonly string[]>>(schema: S, argv?: string[]): Schema<S>;
31
+ export {};
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Parses process.argv or any string[] into an object with the given schema
3
+ * Properties should be prefixed with `--`
4
+ * Values should come immediately after the property and be separated by a space or `=`
5
+ * Type `array` can only be a array of `boolean`, `number`, or `string` types
6
+ * Type `boolean` will be `true` if present and not followed by `=[VALUE]`
7
+ * Type `object` property values can only by of `boolean`, `number`, or `string` types
8
+ * Schema entries may also be string‑literal arrays, which are treated as enum
9
+ * definitions; the resulting value will be typed as the union of the literals.
10
+ *
11
+ * @example
12
+ * const argv = parseArgv({
13
+ * a: 'array',
14
+ * b: 'boolean',
15
+ * b2: 'boolean',
16
+ * f: 'float',
17
+ * n: 'number',
18
+ * o: 'object',
19
+ * s: 'string',
20
+ * mode: ['dev','prod'] as const // enum-style union
21
+ * })
22
+ *
23
+ * > npm run build -- --a [one,2,false] --b --b2=false --f 3.14 --n 123 --o {one:1,nope:false,hello:world} --s mystring --mode dev
24
+ *
25
+ */
26
+ export default function (schema, argv = process.argv.slice(2)) {
27
+ const data = {};
28
+ const args = argv.slice()
29
+ .map((arg) => { return arg?.trim(); })
30
+ .filter(arg => typeof arg == 'string' && arg !== '');
31
+ for (let i = 0; i < args.length; i++) {
32
+ if (args[i].startsWith('--')) {
33
+ const arg = args[i].slice(2);
34
+ if (arg.indexOf('=') !== -1) {
35
+ let [key, value] = arg.split('=');
36
+ if (schema[key]) {
37
+ value = parseValue(schema[key], value);
38
+ data[key] = value;
39
+ }
40
+ }
41
+ else if (schema[arg] === 'boolean') {
42
+ data[arg] = true;
43
+ }
44
+ else if (schema[arg]) {
45
+ let value = true;
46
+ if (i + 1 < args.length && !args[i + 1].startsWith('--')) {
47
+ value = parseValue(schema[arg], args[++i]);
48
+ }
49
+ data[arg] = value;
50
+ }
51
+ }
52
+ }
53
+ return data;
54
+ }
55
+ function parseValue(type, value) {
56
+ if (typeof value != 'string') {
57
+ return undefined;
58
+ }
59
+ if (Array.isArray(type)) {
60
+ return (type.includes(value) ? value : value);
61
+ }
62
+ switch (type) {
63
+ case 'array': {
64
+ if (value.startsWith('[')) {
65
+ value = value.substring(1);
66
+ }
67
+ if (value.endsWith(']')) {
68
+ value = value.slice(0, -1);
69
+ }
70
+ const items = value.split(',')
71
+ .map((v) => {
72
+ v = v.trim();
73
+ if (/(true|false|\d+(?:\.\d+)?)/i.test(v)) {
74
+ return JSON.parse(v);
75
+ }
76
+ else {
77
+ return v;
78
+ }
79
+ });
80
+ return items;
81
+ }
82
+ case 'boolean':
83
+ return value.toLowerCase() === 'true' || value === '1';
84
+ case 'float':
85
+ return parseFloat(value);
86
+ case 'number':
87
+ return parseInt(value, 10);
88
+ case 'object':
89
+ if (value.startsWith('{') && value.endsWith('}')) {
90
+ const obj = value.substring(1, value.length - 1)
91
+ .split(',')
92
+ .filter(p => p.trim() !== '')
93
+ .map((pair) => {
94
+ let [key, val] = pair.split(':').map(s => s.trim());
95
+ if (/(true|false|\d+(?:\.\d+)?)/i.test(val)) {
96
+ val = JSON.parse(val);
97
+ }
98
+ return [key, val];
99
+ });
100
+ return Object.fromEntries(obj);
101
+ }
102
+ else {
103
+ return {};
104
+ }
105
+ case 'string':
106
+ default:
107
+ return value;
108
+ }
109
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Parses a .env file into an object with the given schema
3
+ * Values should come immediately after the property and be separated by `=`
4
+ * Values can be quoted or unquoted
5
+ * Type `array` can only be a array of `boolean`, `number`, or `string` types
6
+ * Type `object` property values can only by of `boolean`, `number`, or `string` types
7
+ * Schema entries may also be string‑literal arrays, which are treated as enum
8
+ * definitions; the resulting value will be typed as the union of the literals.
9
+ *
10
+ * @example
11
+ * import parseEnv from './parse-env';
12
+ *
13
+ * const env = parseEnv({
14
+ * a: 'array',
15
+ * b: 'boolean',
16
+ * b2: 'boolean',
17
+ * f: 'float',
18
+ * n: 'number',
19
+ * o: 'object',
20
+ * s: 'string',
21
+ * mode: ['dev','prod'] as const // enum-style union
22
+ * })
23
+ *
24
+ *
25
+ * // .env
26
+ * a="[1,2,3]"
27
+ * b=false
28
+ * b2="true"
29
+ * f="1.23"
30
+ * n=234
31
+ * o={"test":1}
32
+ * s="testing 1 2 3"
33
+ * mode=prod
34
+ */
35
+ export type EnvPropertyType = 'array' | 'boolean' | 'float' | 'number' | 'object' | 'string';
36
+ export type EnvSchema<S extends Record<string, EnvPropertyType | readonly string[]> = Record<string, any>> = {
37
+ [K in keyof S]: S[K] extends readonly (infer U)[] ? U | undefined : S[K] extends 'array' ? any[] | undefined : S[K] extends 'boolean' ? boolean | undefined : S[K] extends 'float' ? number | undefined : S[K] extends 'number' ? number | undefined : S[K] extends 'object' ? Record<string, any> | undefined : S[K] extends 'string' ? string | undefined : string | undefined;
38
+ };
39
+ declare function parseEnv<S extends Record<string, EnvPropertyType | readonly string[]>>(schema: S, { mode, cwd, filePath, all }?: {
40
+ mode?: string;
41
+ cwd?: string;
42
+ filePath?: string;
43
+ all?: boolean;
44
+ }): Promise<EnvSchema<S>>;
45
+ export default parseEnv;
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Parses a .env file into an object with the given schema
3
+ * Values should come immediately after the property and be separated by `=`
4
+ * Values can be quoted or unquoted
5
+ * Type `array` can only be a array of `boolean`, `number`, or `string` types
6
+ * Type `object` property values can only by of `boolean`, `number`, or `string` types
7
+ * Schema entries may also be string‑literal arrays, which are treated as enum
8
+ * definitions; the resulting value will be typed as the union of the literals.
9
+ *
10
+ * @example
11
+ * import parseEnv from './parse-env';
12
+ *
13
+ * const env = parseEnv({
14
+ * a: 'array',
15
+ * b: 'boolean',
16
+ * b2: 'boolean',
17
+ * f: 'float',
18
+ * n: 'number',
19
+ * o: 'object',
20
+ * s: 'string',
21
+ * mode: ['dev','prod'] as const // enum-style union
22
+ * })
23
+ *
24
+ *
25
+ * // .env
26
+ * a="[1,2,3]"
27
+ * b=false
28
+ * b2="true"
29
+ * f="1.23"
30
+ * n=234
31
+ * o={"test":1}
32
+ * s="testing 1 2 3"
33
+ * mode=prod
34
+ */
35
+ import { existsSync } from "node:fs";
36
+ import { readFile } from "node:fs/promises";
37
+ import { join } from 'node:path';
38
+ // parse reads a .env file according to the given schema. In addition to
39
+ // the primitive types listed above the schema may use a string-literal
40
+ // array to describe an enum; the returned object will then have the property
41
+ // typed as the union of those literals.
42
+ async function parseEnv(schema, { mode, cwd, filePath, all = false } = {}) {
43
+ const env = {};
44
+ const fp = filePath ? cwd ? join(cwd, filePath) : filePath : join(cwd ?? process.cwd(), `.env${mode ? `.${mode}` : ''}`);
45
+ if (existsSync(fp)) {
46
+ const data = {};
47
+ const content = await readFile(fp, 'utf8');
48
+ const lines = content.split(/\r?\n/).filter(l => l.trim() !== '');
49
+ for (const line of lines) {
50
+ const [key, value] = line.split('=');
51
+ data[key.trim()] = value.trim().match(/['"']?([^'"]*)['"]?/)?.[1].trim() ?? '';
52
+ }
53
+ for (const [key, value] of Object.entries(data)) {
54
+ if (schema[key]) {
55
+ env[key] = parseValue(schema[key], value);
56
+ }
57
+ else if (all) {
58
+ env[key] = value;
59
+ }
60
+ }
61
+ }
62
+ return env;
63
+ }
64
+ ;
65
+ function parseValue(type, value) {
66
+ if (typeof value != 'string') {
67
+ return undefined;
68
+ }
69
+ // enums are defined as string literal arrays in the schema
70
+ if (Array.isArray(type)) {
71
+ // return the value directly; optionally we could validate, but at runtime
72
+ // we simply cast back to one of the allowed values (union type ensures
73
+ // callers only use valid strings at compile time if schema is const).
74
+ return (type.includes(value) ? value : value);
75
+ }
76
+ switch (type) {
77
+ case 'array': {
78
+ if (value.startsWith('[')) {
79
+ value = value.substring(1);
80
+ }
81
+ if (value.endsWith(']')) {
82
+ value = value.slice(0, -1);
83
+ }
84
+ const items = value.split(',')
85
+ .map((v) => {
86
+ v = v.trim();
87
+ if (/(true|false|\d+(?:\.\d+)?)/i.test(v)) {
88
+ return JSON.parse(v);
89
+ }
90
+ else {
91
+ return v;
92
+ }
93
+ });
94
+ return items;
95
+ }
96
+ case 'boolean':
97
+ return value.toLowerCase() === 'true' || value === '1';
98
+ case 'float':
99
+ return parseFloat(value);
100
+ case 'number':
101
+ return parseInt(value, 10);
102
+ case 'object':
103
+ if (value.startsWith('{') && value.endsWith('}')) {
104
+ const obj = value.substring(1, value.length - 1)
105
+ .split(',')
106
+ .filter(p => p.trim() !== '')
107
+ .map((pair) => {
108
+ let [key, val] = pair.split(':').map(s => s.trim());
109
+ if (/(true|false|\d+(?:\.\d+)?)/i.test(val)) {
110
+ val = JSON.parse(val);
111
+ }
112
+ return [key, val];
113
+ });
114
+ return Object.fromEntries(obj);
115
+ }
116
+ else {
117
+ return {};
118
+ }
119
+ case 'string':
120
+ default:
121
+ return value;
122
+ }
123
+ }
124
+ export default parseEnv;
@@ -0,0 +1,8 @@
1
+ import { DataEvotrk } from '../types';
2
+ export declare function formatExtId(...ids: string[]): string;
3
+ export declare function pathToSlideZip(path: string): string;
4
+ export declare function flattenPath(path: string, { slashes }?: {
5
+ slashes?: boolean;
6
+ }): string;
7
+ export declare function urlToId(url: string | URL, separator?: string): string;
8
+ export declare function dataEvotrkToString(data: DataEvotrk): string;
@@ -0,0 +1,37 @@
1
+ export function formatExtId(...ids) {
2
+ return ids.map((id) => { return id.toUpperCase(); }).join('_');
3
+ }
4
+ export function pathToSlideZip(path) {
5
+ return `${flattenPath(path, { slashes: false })}.zip`;
6
+ }
7
+ export function flattenPath(path, { slashes = true } = {}) {
8
+ return `${slashes ? '/' : ''}${path.toLowerCase().split('/').filter(s => s !== '').join('-')}${slashes ? '/' : ''}`;
9
+ }
10
+ export function urlToId(url, separator = '_') {
11
+ return (url instanceof URL ? url.pathname : url).split('/').filter(s => s !== '').map((s) => { return s.toLowerCase().replace(/[^0-9a-z_]/g, separator); }).join(separator);
12
+ }
13
+ export function dataEvotrkToString(data) {
14
+ data.slide = data.slide ?? '';
15
+ data.type = data.type ?? '';
16
+ data.name = data.name ?? '';
17
+ return Object.entries((data))
18
+ .sort(([key1], [key2]) => {
19
+ if (key1 === 'slide')
20
+ return -1;
21
+ if (key2 === 'slide')
22
+ return 1;
23
+ if (key1 === 'type')
24
+ return -1;
25
+ if (key2 === 'type')
26
+ return 1;
27
+ if (key1 === 'name')
28
+ return -1;
29
+ if (key2 === 'name')
30
+ return 1;
31
+ return 0;
32
+ })
33
+ .map(([key, value]) => {
34
+ return value;
35
+ })
36
+ .join('|');
37
+ }
@@ -0,0 +1,9 @@
1
+ import type { IVeevaConfig } from '../types';
2
+ interface Params {
3
+ config: IVeevaConfig;
4
+ rootDir: string;
5
+ astroDistDir: string;
6
+ deployDir: string;
7
+ }
8
+ export default function ({ config, rootDir, astroDistDir, deployDir }: Params): Promise<void>;
9
+ export {};
@@ -0,0 +1,15 @@
1
+ import { cp, readdir, writeFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import logger from '../lib/logger.js';
4
+ export default async function ({ config, rootDir, astroDistDir, deployDir }) {
5
+ logger.info(`Copying files to ${deployDir.replace(rootDir, '')}`);
6
+ const dirContent = await readdir(astroDistDir, { withFileTypes: true });
7
+ for (const c of dirContent) {
8
+ if (c.isDirectory() && (c.name === 'shared' || config.presentation.slides.find(s => s.path === c.name))) {
9
+ await cp(join(c.parentPath, c.name), join(deployDir, c.name), { recursive: true });
10
+ if (c.name === 'shared') {
11
+ writeFile(join(deployDir, c.name, 'index.html'), `<html><head><meta charset="UTF-8"><title>${config.presentation.name} - Shared Resource</title></head><body><h1>${config.presentation.name} - Shared Resource</h1></body></html>`);
12
+ }
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ import type { IVeevaConfig } from '../types';
2
+ interface Params {
3
+ config: IVeevaConfig;
4
+ deployDir: string;
5
+ buildName: string;
6
+ fieldsOnly?: boolean;
7
+ additional?: {
8
+ headers: string[];
9
+ presentation: string[];
10
+ slides: string[][];
11
+ shared: string[];
12
+ };
13
+ }
14
+ export default function ({ config, deployDir, buildName, fieldsOnly, additional }: Params): Promise<void>;
15
+ export {};