@inizioevoke/veeva-astroclm-core 1.3.8 → 1.4.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.
@@ -18,6 +18,7 @@ export default function ({ veevaEnv = 'client', isTraining = false }: IVeevaConf
18
18
  // language: isEvokeBuild ? undefined : 'English',
19
19
  // crmOrg: isEvokeBuild ? undefined : { crmId: ['CRM_ORG_ID'] },
20
20
  // crmProduct: isEvokeBuild ? undefined : { id: 'VEEVA_ID_FROM_URL' },
21
+ // crmContentGroup: isEvokeBuild ? undefined : { id: 'VEEVA_ID_FROM_URL' },
21
22
  // crmDetailGroup: isEvokeBuild ? undefined : { id: 'VEEVA_ID_FROM_URL' },
22
23
  // detailGroup: undefined
23
24
  };
package/dist/lib/utils.js CHANGED
@@ -2,7 +2,7 @@ export function formatExtId(...ids) {
2
2
  return ids.map((id) => { return id.toUpperCase(); }).join('_');
3
3
  }
4
4
  export function pathToSlideZip(path) {
5
- return `${flattenPath(path, { slashes: false })}.zip`;
5
+ return `${flattenPath(path, { slashes: false }).replace(/\.zip$/i, '')}.zip`;
6
6
  }
7
7
  export function flattenPath(path, { slashes = true } = {}) {
8
8
  return `${slashes ? '/' : ''}${path.toLowerCase().split('/').filter(s => s !== '').join('-')}${slashes ? '/' : ''}`;
@@ -152,7 +152,7 @@ function createSlideRow(headers, config, slide, additional) {
152
152
  addColumn(headers, row, HEADER_SLIDE_REACTIONS, disable.has('Reactions') ? ',a,b,c' : '');
153
153
  disable.delete('Reactions');
154
154
  addColumn(headers, row, HEADER_SLIDE_DISABLE_ACTIONS, [...disable].join(','));
155
- addColumn(headers, row, HEADER_SLIDE_FILE_NAME, pathToSlideZip(slide.path));
155
+ addColumn(headers, row, HEADER_SLIDE_FILE_NAME, pathToSlideZip(slide.zipFileName ?? slide.path));
156
156
  addColumn(headers, row, HEADER_SLIDE_RELATED_SHARED, config.presentation.shared?.externalId ?? '');
157
157
  addColumn(headers, row, HEADER_SLIDE_CLM_CONTENT, VEEVA_YES);
158
158
  addColumn(headers, row, HEADER_PRESENTATION, config.presentation.externalId);
@@ -180,7 +180,7 @@ function createSharedRow(headers, config, additional) {
180
180
  addColumn(headers, row, HEADER_SLIDE_PRODUCT, config.presentation.product);
181
181
  addColumn(headers, row, HEADER_SLIDE_COUNTRY, config.presentation.country);
182
182
  addColumn(headers, row, HEADER_SLIDE_MEDIA_TYPE, shared.mediaType ?? VEEVA_MEDIATYPE_HTML);
183
- addColumn(headers, row, HEADER_SLIDE_FILE_NAME, pathToSlideZip(shared.path ?? 'shared'));
183
+ addColumn(headers, row, HEADER_SLIDE_FILE_NAME, pathToSlideZip(shared.zipFileName ?? shared.path ?? 'shared'));
184
184
  addColumn(headers, row, HEADER_SLIDE_CLM_CONTENT, VEEVA_YES);
185
185
  addColumn(headers, row, HEADER_SLIDE_CRM_SHARED, VEEVA_YES);
186
186
  addColumn(headers, row, HEADER_LIFECYCLE, VEEVA_LIFECYCLE_CRM_CONTENT);
@@ -1,5 +1,5 @@
1
1
  import { writeFile } from "node:fs/promises";
2
- import { join } from "node:path";
2
+ import { extname, join } from "node:path";
3
3
  import puppeteer from "puppeteer";
4
4
  import sharp from 'sharp';
5
5
  import logger from '../lib/logger.js';
@@ -18,9 +18,13 @@ export default async function ({ config, root, deployDir, server }) {
18
18
  });
19
19
  try {
20
20
  for (const slide of config.presentation.slides) {
21
+ if (!slide.thumbnails || !slide.thumbnails.settings)
22
+ continue;
21
23
  for (const settings of slide.thumbnails.settings) {
22
- logger.info(`Generating /${settings.path ?? slide.path}/`);
23
- const url = `${server.protocol ?? 'http'}://${server.host}:${server.port}/${settings.path ?? slide.path}/${settings.queryStringParams ? `?${objToQS(settings.queryStringParams)}` : ''}`;
24
+ const settingsPath = settings.path ?? slide.path;
25
+ const urlPath = `${settingsPath.startsWith('/') ? '' : '/'}${settingsPath}${extname(settingsPath) !== '' ? '' : '/'}`;
26
+ logger.info(`Generating ${urlPath}`);
27
+ const url = `${server.protocol ?? 'http'}://${server.host}:${server.port}${urlPath}${settings.queryStringParams ? `?${objToQS(settings.queryStringParams)}` : ''}`;
24
28
  await page.goto(url, {
25
29
  waitUntil: 'networkidle0'
26
30
  });
@@ -165,6 +169,8 @@ function initThumbSettings(config) {
165
169
  // }
166
170
  // }
167
171
  for (const slide of config.presentation.slides) {
172
+ if (slide.thumbnails === false)
173
+ continue;
168
174
  if (!slide.thumbnails) {
169
175
  slide.thumbnails = {};
170
176
  }
@@ -1,4 +1,5 @@
1
1
  import { readdir, readFile, writeFile } from 'node:fs/promises';
2
+ import { existsSync } from 'node:fs';
2
3
  import { join, extname } from 'node:path';
3
4
  import logger from '../lib/logger.js';
4
5
  export default async function ({ deployDir }) {
@@ -29,13 +30,19 @@ async function handleShared(deployDir, dir) {
29
30
  }
30
31
  }
31
32
  async function handleHTML(deployDir, dir) {
32
- await updateSharedPath(join(deployDir, dir, 'index.html'));
33
+ const index = join(deployDir, dir, 'index.html');
34
+ if (!existsSync(index))
35
+ return;
36
+ await updateSharedPath(index);
33
37
  }
34
38
  async function updateSharedPath(filepath) {
35
39
  const str = await readFile(filepath, 'utf8');
36
40
  let shared = './shared/';
37
- if (extname(filepath) === '.css') { // relative paths inside a css
38
- shared = './';
41
+ switch (extname(filepath)) {
42
+ case '.css':
43
+ case '.js':
44
+ shared = './';
45
+ break;
39
46
  }
40
47
  await writeFile(filepath, str.replace(/(?:\.*\/)*shared\//g, shared));
41
48
  }
@@ -37,12 +37,14 @@ export interface ISlideThumbnailSettings {
37
37
  export interface IVeevaConfigSlide extends IVeevaClmSlide {
38
38
  path: string;
39
39
  enableActions?: Actions[];
40
- thumbnails?: ISlideThumbnailSettings;
40
+ thumbnails?: false | ISlideThumbnailSettings;
41
+ zipFileName?: string;
41
42
  }
42
43
 
43
44
  export interface IVeevaConfigPresentation extends IVeevaClmPresentation {
44
45
  shared?: IVeevaClmSharedResource & {
45
46
  path?: string;
47
+ zipFileName?: string;
46
48
  },
47
49
  slides: IVeevaConfigSlide[]
48
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inizioevoke/veeva-astroclm-core",
3
- "version": "1.3.8",
3
+ "version": "1.4.0",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -18,6 +18,7 @@ export default function ({ veevaEnv = 'client', isTraining = false }: IVeevaConf
18
18
  // language: isEvokeBuild ? undefined : 'English',
19
19
  // crmOrg: isEvokeBuild ? undefined : { crmId: ['CRM_ORG_ID'] },
20
20
  // crmProduct: isEvokeBuild ? undefined : { id: 'VEEVA_ID_FROM_URL' },
21
+ // crmContentGroup: isEvokeBuild ? undefined : { id: 'VEEVA_ID_FROM_URL' },
21
22
  // crmDetailGroup: isEvokeBuild ? undefined : { id: 'VEEVA_ID_FROM_URL' },
22
23
  // detailGroup: undefined
23
24
  };
package/src/lib/utils.ts CHANGED
@@ -5,7 +5,7 @@ export function formatExtId(...ids: string[]) {
5
5
  }
6
6
 
7
7
  export function pathToSlideZip(path: string) {
8
- return `${flattenPath(path, { slashes: false })}.zip`;
8
+ return `${flattenPath(path, { slashes: false }).replace(/\.zip$/i,'')}.zip`;
9
9
  }
10
10
 
11
11
  export function flattenPath(path: string, { slashes = true }: { slashes?: boolean } = {}) {
@@ -229,7 +229,7 @@ function createSlideRow(headers: string[], config: IVeevaConfig, slide: IVeevaCo
229
229
  disable.delete('Reactions');
230
230
  addColumn(headers, row, HEADER_SLIDE_DISABLE_ACTIONS, [...disable].join(','));
231
231
 
232
- addColumn(headers, row, HEADER_SLIDE_FILE_NAME, pathToSlideZip(slide.path));
232
+ addColumn(headers, row, HEADER_SLIDE_FILE_NAME, pathToSlideZip(slide.zipFileName ?? slide.path));
233
233
  addColumn(headers, row, HEADER_SLIDE_RELATED_SHARED, config.presentation.shared?.externalId ?? '');
234
234
  addColumn(headers, row, HEADER_SLIDE_CLM_CONTENT, VEEVA_YES);
235
235
  addColumn(headers, row, HEADER_PRESENTATION, config.presentation.externalId);
@@ -260,7 +260,7 @@ function createSharedRow(headers: string[], config: IVeevaConfig, additional?: A
260
260
  addColumn(headers, row, HEADER_SLIDE_PRODUCT, config.presentation.product);
261
261
  addColumn(headers, row, HEADER_SLIDE_COUNTRY, config.presentation.country);
262
262
  addColumn(headers, row, HEADER_SLIDE_MEDIA_TYPE, shared.mediaType ?? VEEVA_MEDIATYPE_HTML);
263
- addColumn(headers, row, HEADER_SLIDE_FILE_NAME, pathToSlideZip(shared.path ?? 'shared'));
263
+ addColumn(headers, row, HEADER_SLIDE_FILE_NAME, pathToSlideZip(shared.zipFileName ?? shared.path ?? 'shared'));
264
264
  addColumn(headers, row, HEADER_SLIDE_CLM_CONTENT, VEEVA_YES);
265
265
  addColumn(headers, row, HEADER_SLIDE_CRM_SHARED, VEEVA_YES);
266
266
  addColumn(headers, row, HEADER_LIFECYCLE, VEEVA_LIFECYCLE_CRM_CONTENT);
@@ -1,5 +1,5 @@
1
1
  import { writeFile } from "node:fs/promises";
2
- import { join } from "node:path";
2
+ import { extname, join } from "node:path";
3
3
  import puppeteer, { type Viewport } from "puppeteer";
4
4
  import sharp from 'sharp';
5
5
 
@@ -34,9 +34,13 @@ export default async function({ config, root, deployDir, server }: Params) {
34
34
 
35
35
  try {
36
36
  for (const slide of config.presentation.slides) {
37
- for (const settings of slide.thumbnails!.settings!) {
38
- logger.info(`Generating /${settings.path ?? slide.path}/`);
39
- const url = `${server.protocol ?? 'http'}://${server.host}:${server.port}/${settings.path ?? slide.path}/${settings.queryStringParams ? `?${objToQS(settings.queryStringParams)}` : ''}`
37
+ if (!slide.thumbnails || !slide.thumbnails.settings) continue;
38
+
39
+ for (const settings of slide.thumbnails.settings) {
40
+ const settingsPath = settings.path ?? slide.path;
41
+ const urlPath = `${settingsPath.startsWith('/') ? '' : '/'}${settingsPath}${extname(settingsPath) !== '' ? '' : '/'}`;
42
+ logger.info(`Generating ${urlPath}`);
43
+ const url = `${server.protocol ?? 'http'}://${server.host}:${server.port}${urlPath}${settings.queryStringParams ? `?${objToQS(settings.queryStringParams)}` : ''}`
40
44
 
41
45
  await page.goto(url, {
42
46
  waitUntil: 'networkidle0'
@@ -189,6 +193,8 @@ function initThumbSettings(config: IVeevaConfig) {
189
193
  // }
190
194
 
191
195
  for (const slide of config.presentation.slides) {
196
+ if (slide.thumbnails === false) continue;
197
+
192
198
  if (!slide.thumbnails) {
193
199
  slide.thumbnails = {};
194
200
  }
@@ -1,4 +1,5 @@
1
1
  import { readdir, readFile, writeFile } from 'node:fs/promises';
2
+ import { existsSync } from 'node:fs';
2
3
  import { join, extname } from 'node:path';
3
4
 
4
5
  import logger from '../lib/logger.js';
@@ -36,14 +37,19 @@ async function handleShared(deployDir: string, dir: string) {
36
37
  }
37
38
 
38
39
  async function handleHTML(deployDir: string, dir: string) {
39
- await updateSharedPath(join(deployDir, dir, 'index.html'));
40
+ const index = join(deployDir, dir, 'index.html');
41
+ if (!existsSync(index)) return;
42
+ await updateSharedPath(index);
40
43
  }
41
44
 
42
45
  async function updateSharedPath(filepath: string) {
43
46
  const str = await readFile(filepath, 'utf8');
44
47
  let shared = './shared/';
45
- if (extname(filepath) === '.css') { // relative paths inside a css
46
- shared = './';
48
+ switch (extname(filepath)) {
49
+ case '.css':
50
+ case '.js':
51
+ shared = './';
52
+ break;
47
53
  }
48
54
  await writeFile(filepath, str.replace(/(?:\.*\/)*shared\//g, shared));
49
55
  }
@@ -37,12 +37,14 @@ export interface ISlideThumbnailSettings {
37
37
  export interface IVeevaConfigSlide extends IVeevaClmSlide {
38
38
  path: string;
39
39
  enableActions?: Actions[];
40
- thumbnails?: ISlideThumbnailSettings;
40
+ thumbnails?: false | ISlideThumbnailSettings;
41
+ zipFileName?: string;
41
42
  }
42
43
 
43
44
  export interface IVeevaConfigPresentation extends IVeevaClmPresentation {
44
45
  shared?: IVeevaClmSharedResource & {
45
46
  path?: string;
47
+ zipFileName?: string;
46
48
  },
47
49
  slides: IVeevaConfigSlide[]
48
50
  }