@inizioevoke/veeva-astroclm-core 1.4.6 → 1.4.8

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.
@@ -15,6 +15,7 @@ interface Params {
15
15
  buildName: string;
16
16
  fieldsOnly?: boolean;
17
17
  additionalFields?: AdditionalFields;
18
+ replaceHeaders?: Record<string, string>;
18
19
  }
19
- export default function ({ config, deployDir, buildName, fieldsOnly, additionalFields }: Params): Promise<void>;
20
+ export default function ({ config, deployDir, buildName, fieldsOnly, additionalFields, replaceHeaders }: Params): Promise<void>;
20
21
  export {};
@@ -2,7 +2,7 @@ import { writeFile } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import logger from '../lib/logger.js';
4
4
  import { pathToSlideZip } from '../lib/utils.js';
5
- export default async function ({ config, deployDir, buildName, fieldsOnly = false, additionalFields }) {
5
+ export default async function ({ config, deployDir, buildName, fieldsOnly = false, additionalFields, replaceHeaders }) {
6
6
  logger.info('Creating multichannel loader CSV');
7
7
  const headers = [...(fieldsOnly ? CSV_HEADERS_FIELDS_ONLY : CSV_HEADERS)];
8
8
  const additional = filterAdditionalFields(config, additionalFields);
@@ -44,11 +44,20 @@ export default async function ({ config, deployDir, buildName, fieldsOnly = fals
44
44
  }
45
45
  const rows = [headers];
46
46
  rows.push(createPresentationRow(headers, config, additional?.presentation));
47
+ const shared = createSharedRow(headers, config, additional?.shared);
48
+ shared && rows.push(shared);
47
49
  for (let i = 0; i < config.presentation.slides.length; i++) {
48
50
  rows.push(createSlideRow(headers, config, config.presentation.slides[i], additional?.slides));
49
51
  }
50
- const shared = createSharedRow(headers, config, additional?.shared);
51
- shared && rows.push(shared);
52
+ if (replaceHeaders) {
53
+ const keys = Object.keys(replaceHeaders);
54
+ for (const key of keys) {
55
+ const i = headers.findIndex(h => h === key);
56
+ if (i > -1) {
57
+ headers[i] = replaceHeaders[key];
58
+ }
59
+ }
60
+ }
52
61
  await writeFile(join(deployDir, `_${config.presentation.presentationId}_${buildName}.csv`), rows.map((r) => { return r.join(','); }).join('\n'), { encoding: 'utf8' });
53
62
  }
54
63
  function filterAdditionalFields(config, additionalFields) {
@@ -7,6 +7,7 @@ interface Opts {
7
7
  csvOnly?: boolean;
8
8
  serverPort?: number;
9
9
  additionalCsvFields?: AdditionalFields;
10
+ replaceHeaders?: Record<string, string>;
10
11
  }
11
- export default function ({ root, config, env, csvOnly, serverPort, additionalCsvFields }: Opts): Promise<void>;
12
+ export default function ({ root, config, env, csvOnly, serverPort, additionalCsvFields, replaceHeaders }: Opts): Promise<void>;
12
13
  export {};
@@ -14,7 +14,7 @@ const argv = parseArgv({
14
14
  mode: 'string',
15
15
  fieldsOnly: 'boolean'
16
16
  });
17
- export default async function ({ root, config, env, csvOnly = false, serverPort = 4320, additionalCsvFields }) {
17
+ export default async function ({ root, config, env, csvOnly = false, serverPort = 4320, additionalCsvFields, replaceHeaders }) {
18
18
  const rootDir = root ?? process.cwd();
19
19
  // we could import the astro config and see if the outDir was set but right now it's not necessary
20
20
  const astroConfig = await getAstroConfig(root);
@@ -50,7 +50,7 @@ export default async function ({ root, config, env, csvOnly = false, serverPort
50
50
  await server.stop();
51
51
  await createZips({ config, deployDir });
52
52
  }
53
- await createCsv({ config, deployDir, buildName, fieldsOnly: csvOnly, additionalFields: additionalCsvFields });
53
+ await createCsv({ config, deployDir, buildName, fieldsOnly: csvOnly, additionalFields: additionalCsvFields, replaceHeaders });
54
54
  }
55
55
  async function getAstroConfig(root) {
56
56
  let config = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inizioevoke/veeva-astroclm-core",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -3,6 +3,7 @@ import { join } from 'node:path';
3
3
  import type { IVeevaConfig, IVeevaConfigSlide, Actions, IVeevaClmBinderFields } from '../types';
4
4
  import logger from '../lib/logger.js';
5
5
  import { pathToSlideZip } from '../lib/utils.js';
6
+ import console from 'node:console';
6
7
 
7
8
  export interface AdditionalField {
8
9
  header: string;
@@ -22,8 +23,9 @@ interface Params {
22
23
  buildName: string;
23
24
  fieldsOnly?: boolean;
24
25
  additionalFields?: AdditionalFields;
26
+ replaceHeaders?: Record<string, string>;
25
27
  }
26
- export default async function({ config, deployDir, buildName, fieldsOnly = false, additionalFields }: Params) {
28
+ export default async function({ config, deployDir, buildName, fieldsOnly = false, additionalFields, replaceHeaders }: Params) {
27
29
  logger.info('Creating multichannel loader CSV');
28
30
  const headers: string[] = [...(fieldsOnly ? CSV_HEADERS_FIELDS_ONLY : CSV_HEADERS)];
29
31
 
@@ -53,6 +55,7 @@ export default async function({ config, deployDir, buildName, fieldsOnly = false
53
55
  headers.push(a.header);
54
56
  }
55
57
  });
58
+
56
59
  const presentation = config.presentation;
57
60
 
58
61
  for (const [key, header] of Object.entries(BINDER_PRES_HEADERS)) {
@@ -68,11 +71,23 @@ export default async function({ config, deployDir, buildName, fieldsOnly = false
68
71
 
69
72
  const rows: string[][] = [headers];
70
73
  rows.push(createPresentationRow(headers, config, additional?.presentation));
74
+
75
+ const shared = createSharedRow(headers, config, additional?.shared);
76
+ shared && rows.push(shared);
77
+
71
78
  for (let i=0; i<config.presentation.slides.length; i++) {
72
79
  rows.push(createSlideRow(headers, config, config.presentation.slides[i], additional?.slides));
73
80
  }
74
- const shared = createSharedRow(headers, config, additional?.shared);
75
- shared && rows.push(shared);
81
+
82
+ if (replaceHeaders) {
83
+ const keys = Object.keys(replaceHeaders) as (keyof typeof replaceHeaders)[];
84
+ for (const key of keys) {
85
+ const i = headers.findIndex(h => h === key);
86
+ if (i > -1) {
87
+ headers[i] = replaceHeaders[key];
88
+ }
89
+ }
90
+ }
76
91
 
77
92
  await writeFile(join(deployDir, `_${config.presentation.presentationId}_${buildName}.csv`), rows.map((r)=>{return r.join(',');}).join('\n'), { encoding: 'utf8' });
78
93
  }
@@ -28,8 +28,9 @@ interface Opts {
28
28
  csvOnly?: boolean;
29
29
  serverPort?: number;
30
30
  additionalCsvFields?: AdditionalFields;
31
+ replaceHeaders?: Record<string, string>;
31
32
  }
32
- export default async function({ root, config, env, csvOnly = false, serverPort = 4320, additionalCsvFields }: Opts) {
33
+ export default async function({ root, config, env, csvOnly = false, serverPort = 4320, additionalCsvFields, replaceHeaders }: Opts) {
33
34
  const rootDir = root ?? process.cwd();
34
35
  // we could import the astro config and see if the outDir was set but right now it's not necessary
35
36
  const astroConfig = await getAstroConfig(root);
@@ -71,7 +72,7 @@ export default async function({ root, config, env, csvOnly = false, serverPort =
71
72
  await createZips({ config, deployDir });
72
73
  }
73
74
 
74
- await createCsv({ config, deployDir, buildName, fieldsOnly: csvOnly, additionalFields: additionalCsvFields })
75
+ await createCsv({ config, deployDir, buildName, fieldsOnly: csvOnly, additionalFields: additionalCsvFields, replaceHeaders })
75
76
  }
76
77
 
77
78