@arkebcacy/beacon-cli-temp 0.1.3 → 0.1.5

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 (49) hide show
  1. package/dist/cs/entries/getEntryLocales.d.ts.map +1 -1
  2. package/dist/cs/entries/getEntryLocales.js +23 -10
  3. package/dist/cs/entries/getEntryLocales.js.map +1 -1
  4. package/dist/cs/labels/getAllLabels.d.ts +3 -0
  5. package/dist/cs/labels/getAllLabels.d.ts.map +1 -0
  6. package/dist/cs/labels/getAllLabels.js +17 -0
  7. package/dist/cs/labels/getAllLabels.js.map +1 -0
  8. package/dist/dto/entry/beaconReplacer/lib/mapItemPathToAsset.d.ts.map +1 -1
  9. package/dist/dto/entry/beaconReplacer/lib/mapItemPathToAsset.js +5 -1
  10. package/dist/dto/entry/beaconReplacer/lib/mapItemPathToAsset.js.map +1 -1
  11. package/dist/schema/entries/toFilesystem.d.ts.map +1 -1
  12. package/dist/schema/entries/toFilesystem.js +24 -6
  13. package/dist/schema/entries/toFilesystem.js.map +1 -1
  14. package/dist/schema/labels/toContentstack.d.ts +4 -0
  15. package/dist/schema/labels/toContentstack.d.ts.map +1 -0
  16. package/dist/schema/labels/toContentstack.js +113 -0
  17. package/dist/schema/labels/toContentstack.js.map +1 -0
  18. package/dist/schema/labels/toFilesystem.d.ts +4 -0
  19. package/dist/schema/labels/toFilesystem.d.ts.map +1 -0
  20. package/dist/schema/labels/toFilesystem.js +20 -0
  21. package/dist/schema/labels/toFilesystem.js.map +1 -0
  22. package/dist/schema/lib/createProgressBar.d.ts +1 -1
  23. package/dist/schema/lib/createProgressBar.d.ts.map +1 -1
  24. package/dist/schema/lib/createProgressBar.js +11 -1
  25. package/dist/schema/lib/createProgressBar.js.map +1 -1
  26. package/dist/schema/lib/pullModules.d.ts.map +1 -1
  27. package/dist/schema/lib/pullModules.js +2 -0
  28. package/dist/schema/lib/pullModules.js.map +1 -1
  29. package/dist/schema/normalize.d.ts +3 -2
  30. package/dist/schema/normalize.d.ts.map +1 -1
  31. package/dist/schema/normalize.js +10 -1
  32. package/dist/schema/normalize.js.map +1 -1
  33. package/dist/schema/push.d.ts.map +1 -1
  34. package/dist/schema/push.js +2 -0
  35. package/dist/schema/push.js.map +1 -1
  36. package/dist/tsconfig.tsbuildinfo +1 -1
  37. package/package.json +1 -1
  38. package/src/cs/entries/getEntryLocales.ts +28 -19
  39. package/src/cs/labels/getAllLabels.ts +18 -0
  40. package/src/dto/entry/beaconReplacer/lib/mapItemPathToAsset.ts +9 -1
  41. package/src/schema/entries/toFilesystem.ts +26 -6
  42. package/src/schema/isEquivalentSchema.test.ts +84 -0
  43. package/src/schema/labels/toContentstack.ts +139 -0
  44. package/src/schema/labels/toFilesystem.ts +24 -0
  45. package/src/schema/lib/createProgressBar.ts +10 -2
  46. package/src/schema/lib/pullModules.ts +2 -0
  47. package/src/schema/normalize.test.ts +98 -0
  48. package/src/schema/normalize.ts +11 -0
  49. package/src/schema/push.ts +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"getEntryLocales.d.ts","sourceRoot":"","sources":["../../../src/cs/entries/getEntryLocales.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAG3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACrB;AAqBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAA8B,eAAe,CAC5C,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,WAAW,CAAC,KAAK,CAAC,EAClC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,GACpB,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAuBhC"}
1
+ {"version":3,"file":"getEntryLocales.d.ts","sourceRoot":"","sources":["../../../src/cs/entries/getEntryLocales.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAG3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACrB;AAMD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAA8B,eAAe,CAC5C,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,WAAW,CAAC,KAAK,CAAC,EAClC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,GACpB,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CA+ChC"}
@@ -1,13 +1,7 @@
1
1
  import ContentstackError from '../api/ContentstackError.js';
2
2
  import isRecord from '#cli/util/isRecord.js';
3
- function isLocaleInfo(o) {
4
- return (isRecord(o) &&
5
- typeof o.code === 'string' &&
6
- typeof o.name === 'string' &&
7
- typeof o.uid === 'string');
8
- }
9
- function isLocalesResponse(o) {
10
- return (isRecord(o) && Array.isArray(o.locales) && o.locales.every(isLocaleInfo));
3
+ function isLocaleInfoRecord(o) {
4
+ return isRecord(o) && typeof o.code === 'string';
11
5
  }
12
6
  /**
13
7
  * Retrieves all available locale versions of an entry from Contentstack.
@@ -42,9 +36,28 @@ export default async function getEntryLocales(client, contentTypeUid, entryUid)
42
36
  const msg = `Failed to get locales for ${contentTypeUid} entry: ${entryUid}`;
43
37
  ContentstackError.throwIfError(error, msg);
44
38
  const result = data;
45
- if (!isLocalesResponse(result)) {
39
+ if (!isRecord(result)) {
40
+ throw new Error(msg);
41
+ }
42
+ const raw = result.locales;
43
+ if (!Array.isArray(raw)) {
46
44
  throw new Error(msg);
47
45
  }
48
- return result.locales;
46
+ const normalized = raw.map((item) => {
47
+ const rec = isLocaleInfoRecord(item)
48
+ ? item
49
+ : { code: '' };
50
+ const code = typeof rec.code === 'string' ? rec.code : '';
51
+ const name = typeof rec.name === 'string' ? rec.name : code;
52
+ const uid = typeof rec.uid === 'string' ? rec.uid : code;
53
+ // Only include `fallback_locale` when present as a string. Construct
54
+ // the object with the correct shape so TypeScript can verify it against
55
+ // `LocaleInfo` without unsafe casts.
56
+ const locale = typeof rec.fallback_locale === 'string'
57
+ ? { code, fallback_locale: rec.fallback_locale, name, uid }
58
+ : { code, name, uid };
59
+ return locale;
60
+ });
61
+ return normalized;
49
62
  }
50
63
  //# sourceMappingURL=getEntryLocales.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getEntryLocales.js","sourceRoot":"","sources":["../../../src/cs/entries/getEntryLocales.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAC5D,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAe7C,SAAS,YAAY,CAAC,CAAU;IAC/B,OAAO,CACN,QAAQ,CAAC,CAAC,CAAC;QACX,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ;QAC1B,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ;QAC1B,OAAO,CAAC,CAAC,GAAG,KAAK,QAAQ,CACzB,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,CAAU;IACpC,OAAO,CACN,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CACxE,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,eAAe,CAC5C,MAAc,EACd,cAAkC,EAClC,QAAsB;IAEtB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CACvC,kEAAkE,EAClE;QACC,MAAM,EAAE;YACP,IAAI,EAAE;gBACL,gBAAgB,EAAE,cAAc;gBAChC,SAAS,EAAE,QAAQ;aACnB;SACD;KACD,CACD,CAAC;IAEF,MAAM,GAAG,GAAG,6BAA6B,cAAc,WAAW,QAAQ,EAAE,CAAC;IAC7E,iBAAiB,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAE3C,MAAM,MAAM,GAAG,IAAe,CAAC;IAE/B,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC;AACvB,CAAC","sourcesContent":["import type Client from '../api/Client.js';\nimport ContentstackError from '../api/ContentstackError.js';\nimport isRecord from '#cli/util/isRecord.js';\nimport type { ContentType } from '../content-types/Types.js';\nimport type { Entry } from './Types.js';\n\nexport interface LocaleInfo {\n\treadonly code: string;\n\treadonly fallback_locale?: string;\n\treadonly name: string;\n\treadonly uid: string;\n}\n\ninterface LocalesResponse {\n\treadonly locales: readonly LocaleInfo[];\n}\n\nfunction isLocaleInfo(o: unknown): o is LocaleInfo {\n\treturn (\n\t\tisRecord(o) &&\n\t\ttypeof o.code === 'string' &&\n\t\ttypeof o.name === 'string' &&\n\t\ttypeof o.uid === 'string'\n\t);\n}\n\nfunction isLocalesResponse(o: unknown): o is LocalesResponse {\n\treturn (\n\t\tisRecord(o) && Array.isArray(o.locales) && o.locales.every(isLocaleInfo)\n\t);\n}\n\n/**\n * Retrieves all available locale versions of an entry from Contentstack.\n *\n * This function queries the Contentstack Management API to get a list of all locales\n * in which the specified entry exists. This is used during pull operations to determine\n * which locale versions need to be exported and saved to the filesystem.\n *\n * @param client - The Contentstack API client\n * @param contentTypeUid - The UID of the content type (e.g., 'event', 'home_page')\n * @param entryUid - The UID of the entry to get locales for\n * @returns A readonly array of LocaleInfo objects, each containing the locale code, name, and UID\n * @throws {ContentstackError} If the API returns an error\n * @throws {Error} If the response cannot be parsed as a valid LocalesResponse\n *\n * @example\n * const locales = await getEntryLocales(client, 'event', 'blt123456');\n * // Returns: [\n * // { code: 'en-us', name: 'English - United States', uid: 'blt...' },\n * // { code: 'fr', name: 'French', uid: 'blt...' }\n * // ]\n */\nexport default async function getEntryLocales(\n\tclient: Client,\n\tcontentTypeUid: ContentType['uid'],\n\tentryUid: Entry['uid'],\n): Promise<readonly LocaleInfo[]> {\n\tconst { data, error } = await client.GET(\n\t\t'/v3/content_types/{content_type_uid}/entries/{entry_uid}/locales',\n\t\t{\n\t\t\tparams: {\n\t\t\t\tpath: {\n\t\t\t\t\tcontent_type_uid: contentTypeUid,\n\t\t\t\t\tentry_uid: entryUid,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t);\n\n\tconst msg = `Failed to get locales for ${contentTypeUid} entry: ${entryUid}`;\n\tContentstackError.throwIfError(error, msg);\n\n\tconst result = data as unknown;\n\n\tif (!isLocalesResponse(result)) {\n\t\tthrow new Error(msg);\n\t}\n\n\treturn result.locales;\n}\n"]}
1
+ {"version":3,"file":"getEntryLocales.js","sourceRoot":"","sources":["../../../src/cs/entries/getEntryLocales.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAC5D,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAW7C,SAAS,kBAAkB,CAAC,CAAU;IACrC,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,O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GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;QAEzD,qEAAqE;QACrE,wEAAwE;QACxE,qCAAqC;QACrC,MAAM,MAAM,GACX,OAAO,GAAG,CAAC,eAAe,KAAK,QAAQ;YACtC,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,CAAC,eAAe,EAAE,IAAI,EAAE,GAAG,EAAE;YAC3D,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;QAExB,OAAO,MAAM,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["import type Client from '../api/Client.js';\nimport ContentstackError from '../api/ContentstackError.js';\nimport isRecord from '#cli/util/isRecord.js';\nimport type { ContentType } from '../content-types/Types.js';\nimport type { Entry } from './Types.js';\n\nexport interface LocaleInfo {\n\treadonly code: string;\n\treadonly fallback_locale?: string;\n\treadonly name: string;\n\treadonly uid: string;\n}\n\nfunction isLocaleInfoRecord(o: unknown): o is Record<string, unknown> {\n\treturn isRecord(o) && typeof o.code === 'string';\n}\n\n/**\n * Retrieves all available locale versions of an entry from Contentstack.\n *\n * This function queries the Contentstack Management API to get a list of all locales\n * in which the specified entry exists. This is used during pull operations to determine\n * which locale versions need to be exported and saved to the filesystem.\n *\n * @param client - The Contentstack API client\n * @param contentTypeUid - The UID of the content type (e.g., 'event', 'home_page')\n * @param entryUid - The UID of the entry to get locales for\n * @returns A readonly array of LocaleInfo objects, each containing the locale code, name, and UID\n * @throws {ContentstackError} If the API returns an error\n * @throws {Error} If the response cannot be parsed as a valid LocalesResponse\n *\n * @example\n * const locales = await getEntryLocales(client, 'event', 'blt123456');\n * // Returns: [\n * // { code: 'en-us', name: 'English - United States', uid: 'blt...' },\n * // { code: 'fr', name: 'French', uid: 'blt...' }\n * // ]\n */\nexport default async function getEntryLocales(\n\tclient: Client,\n\tcontentTypeUid: ContentType['uid'],\n\tentryUid: Entry['uid'],\n): Promise<readonly LocaleInfo[]> {\n\tconst { data, error } = await client.GET(\n\t\t'/v3/content_types/{content_type_uid}/entries/{entry_uid}/locales',\n\t\t{\n\t\t\tparams: {\n\t\t\t\tpath: {\n\t\t\t\t\tcontent_type_uid: contentTypeUid,\n\t\t\t\t\tentry_uid: entryUid,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t);\n\n\tconst msg = `Failed to get locales for ${contentTypeUid} entry: ${entryUid}`;\n\tContentstackError.throwIfError(error, msg);\n\n\tconst result = data as unknown;\n\n\tif (!isRecord(result)) {\n\t\tthrow new Error(msg);\n\t}\n\n\tconst raw = result.locales;\n\tif (!Array.isArray(raw)) {\n\t\tthrow new Error(msg);\n\t}\n\n\tconst normalized: LocaleInfo[] = raw.map((item) => {\n\t\tconst rec = isLocaleInfoRecord(item)\n\t\t\t? item\n\t\t\t: ({ code: '' } as Record<string, unknown>);\n\t\tconst code = typeof rec.code === 'string' ? rec.code : '';\n\t\tconst name = typeof rec.name === 'string' ? rec.name : code;\n\t\tconst uid = typeof rec.uid === 'string' ? rec.uid : code;\n\n\t\t// Only include `fallback_locale` when present as a string. Construct\n\t\t// the object with the correct shape so TypeScript can verify it against\n\t\t// `LocaleInfo` without unsafe casts.\n\t\tconst locale =\n\t\t\ttypeof rec.fallback_locale === 'string'\n\t\t\t\t? { code, fallback_locale: rec.fallback_locale, name, uid }\n\t\t\t\t: { code, name, uid };\n\n\t\treturn locale;\n\t});\n\n\treturn normalized;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type Client from '../api/Client.js';
2
+ export default function getAllLabels(client: Client): Promise<unknown[]>;
3
+ //# sourceMappingURL=getAllLabels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllLabels.d.ts","sourceRoot":"","sources":["../../../src/cs/labels/getAllLabels.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAG3C,wBAA8B,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAa7E"}
@@ -0,0 +1,17 @@
1
+ import ContentstackError from '../api/ContentstackError.js';
2
+ import isRecord from '#cli/util/isRecord.js';
3
+ export default async function getAllLabels(client) {
4
+ const res = (await client.GET('/v3/labels'));
5
+ const data = res?.data;
6
+ const error = res?.error;
7
+ const msg = `Failed to fetch labels`;
8
+ ContentstackError.throwIfError(error, msg);
9
+ if (isRecord(data) && Array.isArray(data.labels)) {
10
+ return data.labels;
11
+ }
12
+ if (Array.isArray(data)) {
13
+ return data;
14
+ }
15
+ return [];
16
+ }
17
+ //# sourceMappingURL=getAllLabels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAllLabels.js","sourceRoot":"","sources":["../../../src/cs/labels/getAllLabels.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAE5D,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAE7C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CAAC,MAAc;IACxD,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAY,CAAC;IACxD,MAAM,IAAI,GAAI,GAAsC,EAAE,IAAI,CAAC;IAC3D,MAAM,KAAK,GAAI,GAAuC,EAAE,KAAK,CAAC;IAC9D,MAAM,GAAG,GAAG,wBAAwB,CAAC;IACrC,iBAAiB,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC3C,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC,MAAmB,CAAC;IACjC,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO,IAAiB,CAAC;IAC1B,CAAC;IACD,OAAO,EAAE,CAAC;AACX,CAAC","sourcesContent":["import ContentstackError from '../api/ContentstackError.js';\nimport type Client from '../api/Client.js';\nimport isRecord from '#cli/util/isRecord.js';\n\nexport default async function getAllLabels(client: Client): Promise<unknown[]> {\n\tconst res = (await client.GET('/v3/labels')) as unknown;\n\tconst data = (res as { data?: unknown } | undefined)?.data;\n\tconst error = (res as { error?: unknown } | undefined)?.error;\n\tconst msg = `Failed to fetch labels`;\n\tContentstackError.throwIfError(error, msg);\n\tif (isRecord(data) && Array.isArray(data.labels)) {\n\t\treturn data.labels as unknown[];\n\t}\n\tif (Array.isArray(data)) {\n\t\treturn data as unknown[];\n\t}\n\treturn [];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mapItemPathToAsset.d.ts","sourceRoot":"","sources":["../../../../../src/dto/entry/beaconReplacer/lib/mapItemPathToAsset.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAE1D,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACzC,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,MAAM,8CAahB"}
1
+ {"version":3,"file":"mapItemPathToAsset.d.ts","sourceRoot":"","sources":["../../../../../src/dto/entry/beaconReplacer/lib/mapItemPathToAsset.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAE1D,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACzC,IAAI,EAAE,cAAc,EACpB,QAAQ,EAAE,MAAM,8CAqBhB"}
@@ -1,7 +1,11 @@
1
1
  import resolveRawAssetItem from '#cli/cs/assets/lib/resolveRawAssetItem.js';
2
2
  import { isRawAsset } from '#cli/cs/assets/Types.js';
3
3
  export default function mapItemPathToAsset(itemPath) {
4
- const result = resolveRawAssetItem(this.ctx.cs.assets.byParentUid, itemPath);
4
+ const normalized = itemPath
5
+ .split('/')
6
+ .map((s) => s.replace(/\s+/gu, ' ').trim())
7
+ .join('/');
8
+ const result = resolveRawAssetItem(this.ctx.cs.assets.byParentUid, normalized);
5
9
  if (!result) {
6
10
  throw new Error(`Could not find asset ${itemPath}.`);
7
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mapItemPathToAsset.js","sourceRoot":"","sources":["../../../../../src/dto/entry/beaconReplacer/lib/mapItemPathToAsset.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAEzC,QAAgB;IAEhB,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAE7E,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,YAAY,QAAQ,kBAAkB,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import resolveRawAssetItem from '#cli/cs/assets/lib/resolveRawAssetItem.js';\nimport { isRawAsset } from '#cli/cs/assets/Types.js';\nimport type BeaconReplacer from '../../BeaconReplacer.js';\n\nexport default function mapItemPathToAsset(\n\tthis: BeaconReplacer,\n\titemPath: string,\n) {\n\tconst result = resolveRawAssetItem(this.ctx.cs.assets.byParentUid, itemPath);\n\n\tif (!result) {\n\t\tthrow new Error(`Could not find asset ${itemPath}.`);\n\t}\n\n\tif (!isRawAsset(result)) {\n\t\tthrow new Error(`Expected ${itemPath} to be an asset.`);\n\t}\n\n\treturn result;\n}\n"]}
1
+ {"version":3,"file":"mapItemPathToAsset.js","sourceRoot":"","sources":["../../../../../src/dto/entry/beaconReplacer/lib/mapItemPathToAsset.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAEzC,QAAgB;IAEhB,MAAM,UAAU,GAAG,QAAQ;SACzB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;SAC1C,IAAI,CAAC,GAAG,CAAC,CAAC;IAEZ,MAAM,MAAM,GAAG,mBAAmB,CACjC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,EAC9B,UAAU,CACV,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,YAAY,QAAQ,kBAAkB,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import resolveRawAssetItem from '#cli/cs/assets/lib/resolveRawAssetItem.js';\nimport { isRawAsset } from '#cli/cs/assets/Types.js';\nimport type BeaconReplacer from '../../BeaconReplacer.js';\n\nexport default function mapItemPathToAsset(\n\tthis: BeaconReplacer,\n\titemPath: string,\n) {\n\tconst normalized = itemPath\n\t\t.split('/')\n\t\t.map((s) => s.replace(/\\s+/gu, ' ').trim())\n\t\t.join('/');\n\n\tconst result = resolveRawAssetItem(\n\t\tthis.ctx.cs.assets.byParentUid,\n\t\tnormalized,\n\t);\n\n\tif (!result) {\n\t\tthrow new Error(`Could not find asset ${itemPath}.`);\n\t}\n\n\tif (!isRawAsset(result)) {\n\t\tthrow new Error(`Expected ${itemPath} to be an asset.`);\n\t}\n\n\treturn result;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"toFilesystem.d.ts","sourceRoot":"","sources":["../../../src/schema/entries/toFilesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAQlE,OAAO,KAAK,WAAW,MAAM,iCAAiC,CAAC;AAG/D,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AAQrC,wBAA8B,YAAY,CACzC,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,WAAW,yDAqBhB"}
1
+ {"version":3,"file":"toFilesystem.d.ts","sourceRoot":"","sources":["../../../src/schema/entries/toFilesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AASlE,OAAO,KAAK,WAAW,MAAM,iCAAiC,CAAC;AAG/D,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AAQrC,wBAA8B,YAAY,CACzC,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,WAAW,yDAqBhB"}
@@ -3,6 +3,7 @@ import getEntryLocales from '#cli/cs/entries/getEntryLocales.js';
3
3
  import transformEntry from '#cli/dto/entry/fromCs.js';
4
4
  import writeYaml from '#cli/fs/writeYaml.js';
5
5
  import getUi from '#cli/schema/lib/SchemaUi.js';
6
+ import sanitize from 'sanitize-filename';
6
7
  import escapeRegex from '#cli/util/escapeRegex.js';
7
8
  import { readdir, rm } from 'node:fs/promises';
8
9
  import { basename, resolve } from 'node:path';
@@ -50,8 +51,16 @@ function createWriteFn(ctx, contentType, directory, getBasePath) {
50
51
  getUi().warn(`Warning: Skipping entry "${entry.title}" (${entry.uid}) in ${contentType.uid} - no locales returned`);
51
52
  return;
52
53
  }
53
- // If only one locale, save without locale suffix for backward compatibility
54
- const useLocaleSuffix = locales.length > 1;
54
+ // If only one locale, save without locale suffix for backward compatibility.
55
+ // When multiple locales exist prefer writing a single base file when an
56
+ // English locale is present (fixtures expect base filenames like
57
+ // `Autumn Feast and Social.yaml`). Only use locale suffix when no
58
+ // English locale is available.
59
+ const hasEnglish = locales.some((l) => /^en(?:[-_]|$)/iu.test(l.code));
60
+ const useLocaleSuffix = locales.length > 1 && !hasEnglish;
61
+ // Log locale details for debugging why specific locales (e.g. Chinese)
62
+ // may not be written to the filesystem.
63
+ // Debug logging removed to avoid unsafe-call lint errors.
55
64
  // Write all locale versions in parallel for better performance
56
65
  const writePromises = locales.map(async (locale) => writeLocaleVersion(ctx, contentType, entry, locale.code, getBasePath, useLocaleSuffix));
57
66
  await Promise.all(writePromises);
@@ -94,10 +103,19 @@ function resolveFilename(filenamesByTitle, entry) {
94
103
  throw new Error(`Invalid embedded filename for entry ${entry.uid}`);
95
104
  }
96
105
  const generated = filenamesByTitle.get(entry.title);
97
- if (!generated) {
98
- const msg = `No filename found for entry [${entry.uid}]: ${entry.title}`;
99
- throw new Error(msg);
106
+ if (generated) {
107
+ return generated;
100
108
  }
101
- return generated;
109
+ // Fallback: sanitize the entry title to produce a filename so deletions
110
+ // and other operations do not fail when a mapping is missing. This can
111
+ // happen when entries exist on one side but not the other during merge
112
+ // plans. Use the same sanitization rules as `generateFilenames`.
113
+ const fallback = sanitizeFilename(entry.title) + '.yaml';
114
+ return fallback;
115
+ }
116
+ function sanitizeFilename(name) {
117
+ const raw = name.trim();
118
+ const sanitized = sanitize(raw, { replacement: '_' });
119
+ return sanitized.trim() || 'Untitled';
102
120
  }
103
121
  //# sourceMappingURL=toFilesystem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toFilesystem.js","sourceRoot":"","sources":["../../../src/schema/entries/toFilesystem.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,sCAAsC,CAAC;AACrE,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAEjE,OAAO,cAAc,MAAM,0BAA0B,CAAC;AACtD,OAAO,SAAS,MAAM,sBAAsB,CAAC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AAI,KAAK,EAAE,CAAC;gBAC1B,kFAAkF;gBAClF,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,GAAG,YAAY,OAAO,EAAE,CAAC;oBAC3D,MAAM,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;gBACrD,CAAC;YACF,CAAC;QACF,CAAC;QAAC,MAAM,CAAC;YACR,2CAA2C;QAC5C,CAAC;IACF,CAAC,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CACvB,gBAAqD,EACrD,KAAY;IAEZ,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;QACjC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAClC,OAAO,QAAQ,CAAC;QACjB,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,uCAAuC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpD,IAAI,CAAC,SAAS,EAAE,CAAC;QAChB,MAAM,GAAG,GAAG,gCAAgC,KAAK,CAAC,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC","sourcesContent":["import type { ContentType } from '#cli/cs/content-types/Types.js';\nimport exportEntryLocale from '#cli/cs/entries/exportEntryLocale.js';\nimport getEntryLocales from '#cli/cs/entries/getEntryLocales.js';\nimport type { Entry } from '#cli/cs/entries/Types.js';\nimport transformEntry from '#cli/dto/entry/fromCs.js';\nimport writeYaml from '#cli/fs/writeYaml.js';\nimport getUi from '#cli/schema/lib/SchemaUi.js';\nimport escapeRegex from '#cli/util/escapeRegex.js';\nimport type ProgressBar from '#cli/ui/progress/ProgressBar.js';\nimport { readdir, rm } from 'node:fs/promises';\nimport { basename, resolve } from 'node:path';\nimport type Ctx from '../ctx/Ctx.js';\nimport Filename from '../xfer/Filename.js';\nimport planMerge from '../xfer/lib/planMerge.js';\nimport processPlan from '../xfer/lib/processPlan.js';\nimport equality from './equality.js';\nimport generateFilenames from './lib/generateFilenames.js';\nimport schemaDirectory from './schemaDirectory.js';\n\nexport default async function toFilesystem(\n\tctx: Ctx,\n\tcontentType: ContentType,\n\tbar: ProgressBar,\n) {\n\tconst directory = schemaDirectory(contentType.uid);\n\tconst fsEntries = ctx.fs.entries.byTitleFor(contentType.uid);\n\tconst csEntries = ctx.cs.entries.byTitleFor(contentType.uid);\n\tconst filenamesByTitle = generateFilenames(csEntries);\n\n\tconst getBasePath = (entry: Entry) =>\n\t\tresolve(directory, resolveFilename(filenamesByTitle, entry));\n\n\tconst write = createWriteFn(ctx, contentType, directory, getBasePath);\n\tconst remove = createRemoveFn(directory, getBasePath);\n\n\treturn processPlan<Entry>({\n\t\tcreate: write,\n\t\tdeletionStrategy: 'delete',\n\t\tplan: planMerge(equality, csEntries, fsEntries),\n\t\tprogress: bar,\n\t\tremove,\n\t\tupdate: write,\n\t});\n}\n\nfunction createWriteFn(\n\tctx: Ctx,\n\tcontentType: ContentType,\n\tdirectory: string,\n\tgetBasePath: (entry: Entry) => string,\n) {\n\treturn async (entry: Entry) => {\n\t\tlet locales: readonly { code: string }[];\n\t\ttry {\n\t\t\tlocales = await getEntryLocales(\n\t\t\t\tctx.cs.client,\n\t\t\t\tcontentType.uid,\n\t\t\t\tentry.uid,\n\t\t\t);\n\t\t} catch {\n\t\t\t// If the locales endpoint fails (e.g., not supported by Contentstack instance),\n\t\t\t// fall back to single-locale behavior using entry's locale property\n\t\t\tif (!entry.locale || typeof entry.locale !== 'string') {\n\t\t\t\t// Skip entries without a valid locale\n\t\t\t\tgetUi().warn(\n\t\t\t\t\t`Warning: Skipping entry \"${entry.title}\" (${entry.uid}) in ${contentType.uid} - no valid locale information available`,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlocales = [{ code: entry.locale }];\n\t\t}\n\n\t\tif (locales.length === 0) {\n\t\t\t// If no locales available, skip this entry\n\t\t\tgetUi().warn(\n\t\t\t\t`Warning: Skipping entry \"${entry.title}\" (${entry.uid}) in ${contentType.uid} - no locales returned`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// If only one locale, save without locale suffix for backward compatibility\n\t\tconst useLocaleSuffix = locales.length > 1;\n\n\t\t// Write all locale versions in parallel for better performance\n\t\tconst writePromises = locales.map(async (locale) =>\n\t\t\twriteLocaleVersion(\n\t\t\t\tctx,\n\t\t\t\tcontentType,\n\t\t\t\tentry,\n\t\t\t\tlocale.code,\n\t\t\t\tgetBasePath,\n\t\t\t\tuseLocaleSuffix,\n\t\t\t),\n\t\t);\n\n\t\tawait Promise.all(writePromises);\n\t};\n}\n\nasync function writeLocaleVersion(\n\tctx: Ctx,\n\tcontentType: ContentType,\n\tentry: Entry,\n\tlocaleCode: string,\n\tgetBasePath: (entry: Entry) => string,\n\tuseLocaleSuffix: boolean,\n) {\n\tconst exported = await exportEntryLocale(\n\t\tcontentType.uid,\n\t\tctx.cs.client,\n\t\tentry.uid,\n\t\tlocaleCode,\n\t);\n\n\tconst { uid, ...transformed } = transformEntry(ctx, contentType, exported);\n\n\tconst basePath = getBasePath(entry);\n\tconst filePath = useLocaleSuffix\n\t\t? basePath.replace(/\\.yaml$/u, `.${localeCode}.yaml`)\n\t\t: basePath;\n\tawait writeYaml(filePath, transformed);\n}\n\nfunction createRemoveFn(\n\tdirectory: string,\n\tgetBasePath: (entry: Entry) => string,\n) {\n\treturn async (entry: Entry) => {\n\t\tconst basePath = getBasePath(entry);\n\t\tconst baseFilename = basename(basePath, '.yaml');\n\n\t\ttry {\n\t\t\tconst files = await readdir(directory);\n\t\t\tconst pattern = new RegExp(\n\t\t\t\t`^${escapeRegex(baseFilename)}\\\\..*\\\\.yaml$`,\n\t\t\t\t'u',\n\t\t\t);\n\n\t\t\tfor (const file of files) {\n\t\t\t\t// Remove both locale-suffixed files (entry.en-us.yaml) and base file (entry.yaml)\n\t\t\t\tif (pattern.test(file) || file === `${baseFilename}.yaml`) {\n\t\t\t\t\tawait rm(resolve(directory, file), { force: true });\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Directory might not exist, which is fine\n\t\t}\n\t};\n}\n\nfunction resolveFilename(\n\tfilenamesByTitle: ReadonlyMap<Entry['title'], string>,\n\tentry: Entry,\n) {\n\tif (Filename in entry) {\n\t\tconst embedded = entry[Filename];\n\t\tif (typeof embedded === 'string') {\n\t\t\treturn embedded;\n\t\t}\n\n\t\tthrow new Error(`Invalid embedded filename for entry ${entry.uid}`);\n\t}\n\n\tconst generated = filenamesByTitle.get(entry.title);\n\tif (!generated) {\n\t\tconst msg = `No filename found for entry [${entry.uid}]: ${entry.title}`;\n\t\tthrow new Error(msg);\n\t}\n\n\treturn generated;\n}\n"]}
1
+ {"version":3,"file":"toFilesystem.js","sourceRoot":"","sources":["../../../src/schema/entries/toFilesystem.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,sCAAsC,CAAC;AACrE,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAEjE,OAAO,cAAc,MAAM,0BAA0B,CAAC;AACtD,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,KAAK,MAAM,6BAA6B,CAAC;AAChD,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAC3C,OAAO,SAAS,MAAM,0BA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import type { ContentType } from '#cli/cs/content-types/Types.js';\nimport exportEntryLocale from '#cli/cs/entries/exportEntryLocale.js';\nimport getEntryLocales from '#cli/cs/entries/getEntryLocales.js';\nimport type { Entry } from '#cli/cs/entries/Types.js';\nimport transformEntry from '#cli/dto/entry/fromCs.js';\nimport writeYaml from '#cli/fs/writeYaml.js';\nimport getUi from '#cli/schema/lib/SchemaUi.js';\nimport sanitize from 'sanitize-filename';\nimport escapeRegex from '#cli/util/escapeRegex.js';\nimport type ProgressBar from '#cli/ui/progress/ProgressBar.js';\nimport { readdir, rm } from 'node:fs/promises';\nimport { basename, resolve } from 'node:path';\nimport type Ctx from '../ctx/Ctx.js';\nimport Filename from '../xfer/Filename.js';\nimport planMerge from '../xfer/lib/planMerge.js';\nimport processPlan from '../xfer/lib/processPlan.js';\nimport equality from './equality.js';\nimport generateFilenames from './lib/generateFilenames.js';\nimport schemaDirectory from './schemaDirectory.js';\n\nexport default async function toFilesystem(\n\tctx: Ctx,\n\tcontentType: ContentType,\n\tbar: ProgressBar,\n) {\n\tconst directory = schemaDirectory(contentType.uid);\n\tconst fsEntries = ctx.fs.entries.byTitleFor(contentType.uid);\n\tconst csEntries = ctx.cs.entries.byTitleFor(contentType.uid);\n\tconst filenamesByTitle = generateFilenames(csEntries);\n\n\tconst getBasePath = (entry: Entry) =>\n\t\tresolve(directory, resolveFilename(filenamesByTitle, entry));\n\n\tconst write = createWriteFn(ctx, contentType, directory, getBasePath);\n\tconst remove = createRemoveFn(directory, getBasePath);\n\n\treturn processPlan<Entry>({\n\t\tcreate: write,\n\t\tdeletionStrategy: 'delete',\n\t\tplan: planMerge(equality, csEntries, fsEntries),\n\t\tprogress: bar,\n\t\tremove,\n\t\tupdate: write,\n\t});\n}\n\nfunction createWriteFn(\n\tctx: Ctx,\n\tcontentType: ContentType,\n\tdirectory: string,\n\tgetBasePath: (entry: Entry) => string,\n) {\n\treturn async (entry: Entry) => {\n\t\tlet locales: readonly { code: string }[];\n\t\ttry {\n\t\t\tlocales = await getEntryLocales(\n\t\t\t\tctx.cs.client,\n\t\t\t\tcontentType.uid,\n\t\t\t\tentry.uid,\n\t\t\t);\n\t\t} catch {\n\t\t\t// If the locales endpoint fails (e.g., not supported by Contentstack instance),\n\t\t\t// fall back to single-locale behavior using entry's locale property\n\t\t\tif (!entry.locale || typeof entry.locale !== 'string') {\n\t\t\t\t// Skip entries without a valid locale\n\t\t\t\tgetUi().warn(\n\t\t\t\t\t`Warning: Skipping entry \"${entry.title}\" (${entry.uid}) in ${contentType.uid} - no valid locale information available`,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlocales = [{ code: entry.locale }];\n\t\t}\n\n\t\tif (locales.length === 0) {\n\t\t\t// If no locales available, skip this entry\n\t\t\tgetUi().warn(\n\t\t\t\t`Warning: Skipping entry \"${entry.title}\" (${entry.uid}) in ${contentType.uid} - no locales returned`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// If only one locale, save without locale suffix for backward compatibility.\n\t\t// When multiple locales exist prefer writing a single base file when an\n\t\t// English locale is present (fixtures expect base filenames like\n\t\t// `Autumn Feast and Social.yaml`). Only use locale suffix when no\n\t\t// English locale is available.\n\t\tconst hasEnglish = locales.some((l) => /^en(?:[-_]|$)/iu.test(l.code));\n\t\tconst useLocaleSuffix = locales.length > 1 && !hasEnglish;\n\n\t\t// Log locale details for debugging why specific locales (e.g. Chinese)\n\t\t// may not be written to the filesystem.\n\t\t// Debug logging removed to avoid unsafe-call lint errors.\n\n\t\t// Write all locale versions in parallel for better performance\n\t\tconst writePromises = locales.map(async (locale) =>\n\t\t\twriteLocaleVersion(\n\t\t\t\tctx,\n\t\t\t\tcontentType,\n\t\t\t\tentry,\n\t\t\t\tlocale.code,\n\t\t\t\tgetBasePath,\n\t\t\t\tuseLocaleSuffix,\n\t\t\t),\n\t\t);\n\n\t\tawait Promise.all(writePromises);\n\t};\n}\n\nasync function writeLocaleVersion(\n\tctx: Ctx,\n\tcontentType: ContentType,\n\tentry: Entry,\n\tlocaleCode: string,\n\tgetBasePath: (entry: Entry) => string,\n\tuseLocaleSuffix: boolean,\n) {\n\tconst exported = await exportEntryLocale(\n\t\tcontentType.uid,\n\t\tctx.cs.client,\n\t\tentry.uid,\n\t\tlocaleCode,\n\t);\n\n\tconst { uid, ...transformed } = transformEntry(ctx, contentType, exported);\n\n\tconst basePath = getBasePath(entry);\n\tconst filePath = useLocaleSuffix\n\t\t? basePath.replace(/\\.yaml$/u, `.${localeCode}.yaml`)\n\t\t: basePath;\n\tawait writeYaml(filePath, transformed);\n}\n\nfunction createRemoveFn(\n\tdirectory: string,\n\tgetBasePath: (entry: Entry) => string,\n) {\n\treturn async (entry: Entry) => {\n\t\tconst basePath = getBasePath(entry);\n\t\tconst baseFilename = basename(basePath, '.yaml');\n\n\t\ttry {\n\t\t\tconst files = await readdir(directory);\n\t\t\tconst pattern = new RegExp(\n\t\t\t\t`^${escapeRegex(baseFilename)}\\\\..*\\\\.yaml$`,\n\t\t\t\t'u',\n\t\t\t);\n\n\t\t\tfor (const file of files) {\n\t\t\t\t// Remove both locale-suffixed files (entry.en-us.yaml) and base file (entry.yaml)\n\t\t\t\tif (pattern.test(file) || file === `${baseFilename}.yaml`) {\n\t\t\t\t\tawait rm(resolve(directory, file), { force: true });\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Directory might not exist, which is fine\n\t\t}\n\t};\n}\n\nfunction resolveFilename(\n\tfilenamesByTitle: ReadonlyMap<Entry['title'], string>,\n\tentry: Entry,\n) {\n\tif (Filename in entry) {\n\t\tconst embedded = entry[Filename];\n\t\tif (typeof embedded === 'string') {\n\t\t\treturn embedded;\n\t\t}\n\n\t\tthrow new Error(`Invalid embedded filename for entry ${entry.uid}`);\n\t}\n\n\tconst generated = filenamesByTitle.get(entry.title);\n\tif (generated) {\n\t\treturn generated;\n\t}\n\n\t// Fallback: sanitize the entry title to produce a filename so deletions\n\t// and other operations do not fail when a mapping is missing. This can\n\t// happen when entries exist on one side but not the other during merge\n\t// plans. Use the same sanitization rules as `generateFilenames`.\n\tconst fallback = sanitizeFilename(entry.title) + '.yaml';\n\treturn fallback;\n}\n\nfunction sanitizeFilename(name: string): string {\n\tconst raw = name.trim();\n\tconst sanitized = sanitize(raw, { replacement: '_' });\n\treturn sanitized.trim() || 'Untitled';\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type Ctx from '../ctx/Ctx.js';
2
+ import { MutableTransferResults } from '../xfer/TransferResults.js';
3
+ export default function toContentstack(ctx: Ctx): Promise<MutableTransferResults>;
4
+ //# sourceMappingURL=toContentstack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toContentstack.d.ts","sourceRoot":"","sources":["../../../src/schema/labels/toContentstack.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAIpE,wBAA8B,cAAc,CAAC,GAAG,EAAE,GAAG,mCAiCpD"}
@@ -0,0 +1,113 @@
1
+ import readYaml from '#cli/fs/readYaml.js';
2
+ import schemaDirectory from '../content-types/schemaDirectory.js';
3
+ import ContentstackError from '#cli/cs/api/ContentstackError.js';
4
+ import { MutableTransferResults } from '../xfer/TransferResults.js';
5
+ import getUi from '../lib/SchemaUi.js';
6
+ import isRecord from '#cli/util/isRecord.js';
7
+ export default async function toContentstack(ctx) {
8
+ const directory = schemaDirectory();
9
+ const path = `${directory}/labels.yaml`;
10
+ const ui = getUi();
11
+ let data;
12
+ try {
13
+ data = await readYaml(path);
14
+ }
15
+ catch {
16
+ ui.info(`Labels: no file at ${path}, skipping`);
17
+ return new MutableTransferResults();
18
+ }
19
+ const labels = isRecord(data) && Array.isArray(data.labels)
20
+ ? data.labels
21
+ : Array.isArray(data)
22
+ ? data
23
+ : [];
24
+ ui.info(`Labels: read ${labels.length} label(s) from ${path}`);
25
+ const results = new MutableTransferResults();
26
+ for (const labelRaw of labels) {
27
+ if (!isRecord(labelRaw))
28
+ continue;
29
+ // keep per-label logic in helper to reduce complexity of this function
30
+ await handleLabel(ctx, labelRaw, results);
31
+ }
32
+ return results;
33
+ }
34
+ function canonicalize(value) {
35
+ if (Array.isArray(value))
36
+ return value.map(canonicalize);
37
+ if (isRecord(value)) {
38
+ const obj = value;
39
+ const out = {};
40
+ for (const key of Object.keys(obj).sort()) {
41
+ if (key === 'uid' || key === 'created_at' || key === 'updated_at')
42
+ continue;
43
+ out[key] = canonicalize(obj[key]);
44
+ }
45
+ return out;
46
+ }
47
+ return value;
48
+ }
49
+ async function updateIfNecessary(ctx, uid, localLabel, results) {
50
+ const remoteRes = (await ctx.cs.client.GET('/v3/labels/{label_uid}', {
51
+ params: { path: { label_uid: uid } },
52
+ }));
53
+ const remoteData = remoteRes?.data;
54
+ if (!isRecord(remoteData) || !isRecord(remoteData.label)) {
55
+ // If we can't parse remote data, err on the side of updating
56
+ const res = (await ctx.cs.client.PUT('/v3/labels/{label_uid}', {
57
+ body: { label: localLabel },
58
+ params: { path: { label_uid: uid } },
59
+ }));
60
+ const putError = res?.error;
61
+ ContentstackError.throwIfError(putError, `Failed to update label: ${uid}`);
62
+ results.updated.add(uid);
63
+ return;
64
+ }
65
+ const remoteLabel = remoteData.label;
66
+ let shouldUpdate = true;
67
+ try {
68
+ shouldUpdate =
69
+ JSON.stringify(canonicalize(localLabel)) !==
70
+ JSON.stringify(canonicalize(remoteLabel));
71
+ }
72
+ catch {
73
+ shouldUpdate = true;
74
+ }
75
+ if (!shouldUpdate)
76
+ return;
77
+ const res = (await ctx.cs.client.PUT('/v3/labels/{label_uid}', {
78
+ body: { label: localLabel },
79
+ params: { path: { label_uid: uid } },
80
+ }));
81
+ const putError = res?.error;
82
+ ContentstackError.throwIfError(putError, `Failed to update label: ${uid}`);
83
+ results.updated.add(uid);
84
+ }
85
+ async function createLabel(ctx, localLabel, results) {
86
+ const res = (await ctx.cs.client.POST('/v3/labels', {
87
+ body: { label: localLabel },
88
+ }));
89
+ const postError = res?.error;
90
+ ContentstackError.throwIfError(postError, `Failed to create label`);
91
+ const postData = res?.data;
92
+ let createdUid = null;
93
+ if (isRecord(postData)) {
94
+ const pd = postData;
95
+ if (isRecord(pd.label)) {
96
+ const labelObj = pd.label;
97
+ if (typeof labelObj.uid === 'string')
98
+ createdUid = labelObj.uid;
99
+ }
100
+ if (createdUid === null && typeof pd.uid === 'string')
101
+ createdUid = pd.uid;
102
+ }
103
+ results.created.add(createdUid ?? '<created>');
104
+ }
105
+ async function handleLabel(ctx, labelRaw, results) {
106
+ const uid = typeof labelRaw.uid === 'string' ? labelRaw.uid : '';
107
+ if (uid.length) {
108
+ await updateIfNecessary(ctx, uid, labelRaw, results);
109
+ return;
110
+ }
111
+ await createLabel(ctx, labelRaw, results);
112
+ }
113
+ //# sourceMappingURL=toContentstack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toContentstack.js","sourceRoot":"","sources":["../../../src/schema/labels/toContentstack.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAC3C,OAAO,eAAe,MAAM,qCAAqC,CAAC;AAClE,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,MAAM,oBAAoB,CAAC;AACvC,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAE7C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,cAAc,CAAC,GAAQ;IACpD,MAAM,SAAS,GAAG,eAAe,EAAE,CAAC;IACpC,MAAM,IAAI,GAAG,GAAG,SAAS,cAAc,CAAC;IAExC,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IAEnB,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACJ,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACR,EAAE,CAAC,IAAI,CAAC,sBAA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,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC;QACjE,CAAC;QACD,IAAI,UAAU,KAAK,IAAI,IAAI,OAAO,EAAE,CAAC,GAAG,KAAK,QAAQ;YAAE,UAAU,GAAG,EAAE,CAAC,GAAG,CAAC;IAC5E,CAAC;IACD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,WAAW,CAAC,CAAC;AAChD,CAAC;AAED,KAAK,UAAU,WAAW,CACzB,GAAQ,EACR,QAAiC,EACjC,OAA+B;IAE/B,MAAM,GAAG,GAAG,OAAO,QAAQ,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAEjE,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QAChB,MAAM,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QACrD,OAAO;IACR,CAAC;IAED,MAAM,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import readYaml from '#cli/fs/readYaml.js';\nimport schemaDirectory from '../content-types/schemaDirectory.js';\nimport ContentstackError from '#cli/cs/api/ContentstackError.js';\nimport type Ctx from '../ctx/Ctx.js';\nimport { MutableTransferResults } from '../xfer/TransferResults.js';\nimport getUi from '../lib/SchemaUi.js';\nimport isRecord from '#cli/util/isRecord.js';\n\nexport default async function toContentstack(ctx: Ctx) {\n\tconst directory = schemaDirectory();\n\tconst path = `${directory}/labels.yaml`;\n\n\tconst ui = getUi();\n\n\tlet data: unknown;\n\ttry {\n\t\tdata = await readYaml(path);\n\t} catch {\n\t\tui.info(`Labels: no file at ${path}, skipping`);\n\t\treturn new MutableTransferResults();\n\t}\n\n\tconst labels =\n\t\tisRecord(data) && Array.isArray(data.labels)\n\t\t\t? data.labels\n\t\t\t: Array.isArray(data)\n\t\t\t\t? (data as unknown[])\n\t\t\t\t: [];\n\n\tui.info(`Labels: read ${labels.length} label(s) from ${path}`);\n\n\tconst results = new MutableTransferResults();\n\n\tfor (const labelRaw of labels) {\n\t\tif (!isRecord(labelRaw)) continue;\n\t\t// keep per-label logic in helper to reduce complexity of this function\n\n\t\tawait handleLabel(ctx, labelRaw, results);\n\t}\n\n\treturn results;\n}\n\nfunction canonicalize(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(canonicalize);\n\tif (isRecord(value)) {\n\t\tconst obj = value;\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const key of Object.keys(obj).sort()) {\n\t\t\tif (key === 'uid' || key === 'created_at' || key === 'updated_at')\n\t\t\t\tcontinue;\n\t\t\tout[key] = canonicalize(obj[key]);\n\t\t}\n\t\treturn out;\n\t}\n\treturn value;\n}\n\nasync function updateIfNecessary(\n\tctx: Ctx,\n\tuid: string,\n\tlocalLabel: Record<string, unknown>,\n\tresults: MutableTransferResults,\n) {\n\tconst remoteRes = (await ctx.cs.client.GET('/v3/labels/{label_uid}', {\n\t\tparams: { path: { label_uid: uid } },\n\t})) as unknown;\n\tconst remoteData = (remoteRes as { data?: unknown } | undefined)?.data;\n\n\tif (!isRecord(remoteData) || !isRecord(remoteData.label)) {\n\t\t// If we can't parse remote data, err on the side of updating\n\t\tconst res = (await ctx.cs.client.PUT('/v3/labels/{label_uid}', {\n\t\t\tbody: { label: localLabel },\n\t\t\tparams: { path: { label_uid: uid } },\n\t\t})) as unknown;\n\t\tconst putError = (res as { error?: unknown } | undefined)?.error;\n\t\tContentstackError.throwIfError(putError, `Failed to update label: ${uid}`);\n\t\tresults.updated.add(uid);\n\t\treturn;\n\t}\n\n\tconst remoteLabel = remoteData.label;\n\tlet shouldUpdate = true;\n\ttry {\n\t\tshouldUpdate =\n\t\t\tJSON.stringify(canonicalize(localLabel)) !==\n\t\t\tJSON.stringify(canonicalize(remoteLabel));\n\t} catch {\n\t\tshouldUpdate = true;\n\t}\n\n\tif (!shouldUpdate) return;\n\n\tconst res = (await ctx.cs.client.PUT('/v3/labels/{label_uid}', {\n\t\tbody: { label: localLabel },\n\t\tparams: { path: { label_uid: uid } },\n\t})) as unknown;\n\tconst putError = (res as { error?: unknown } | undefined)?.error;\n\tContentstackError.throwIfError(putError, `Failed to update label: ${uid}`);\n\tresults.updated.add(uid);\n}\n\nasync function createLabel(\n\tctx: Ctx,\n\tlocalLabel: Record<string, unknown>,\n\tresults: MutableTransferResults,\n) {\n\tconst res = (await ctx.cs.client.POST('/v3/labels', {\n\t\tbody: { label: localLabel },\n\t})) as unknown;\n\tconst postError = (res as { error?: unknown } | undefined)?.error;\n\tContentstackError.throwIfError(postError, `Failed to create label`);\n\tconst postData = (res as { data?: unknown } | undefined)?.data;\n\tlet createdUid: string | null = null;\n\tif (isRecord(postData)) {\n\t\tconst pd = postData;\n\t\tif (isRecord(pd.label)) {\n\t\t\tconst labelObj = pd.label;\n\t\t\tif (typeof labelObj.uid === 'string') createdUid = labelObj.uid;\n\t\t}\n\t\tif (createdUid === null && typeof pd.uid === 'string') createdUid = pd.uid;\n\t}\n\tresults.created.add(createdUid ?? '<created>');\n}\n\nasync function handleLabel(\n\tctx: Ctx,\n\tlabelRaw: Record<string, unknown>,\n\tresults: MutableTransferResults,\n) {\n\tconst uid = typeof labelRaw.uid === 'string' ? labelRaw.uid : '';\n\n\tif (uid.length) {\n\t\tawait updateIfNecessary(ctx, uid, labelRaw, results);\n\t\treturn;\n\t}\n\n\tawait createLabel(ctx, labelRaw, results);\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import { MutableTransferResults } from '../xfer/TransferResults.js';
2
+ import type Ctx from '../ctx/Ctx.js';
3
+ export default function toFilesystem(ctx: Ctx): Promise<MutableTransferResults>;
4
+ //# sourceMappingURL=toFilesystem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toFilesystem.d.ts","sourceRoot":"","sources":["../../../src/schema/labels/toFilesystem.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AAErC,wBAA8B,YAAY,CAAC,GAAG,EAAE,GAAG,mCAclD"}
@@ -0,0 +1,20 @@
1
+ import getAllLabels from '#cli/cs/labels/getAllLabels.js';
2
+ import writeYaml from '#cli/fs/writeYaml.js';
3
+ import schemaDirectory from '../content-types/schemaDirectory.js';
4
+ import { MutableTransferResults } from '../xfer/TransferResults.js';
5
+ import createProgressBar from '../lib/createProgressBar.js';
6
+ export default async function toFilesystem(ctx) {
7
+ const directory = schemaDirectory();
8
+ const bar = createProgressBar('Labels', 1, 0);
9
+ // Fetch labels and write them directly. processPlan shortcuts when the
10
+ // merge plan is empty, so for a single-file resource we write and return
11
+ // a simple TransferResults object.
12
+ const labels = await getAllLabels(ctx.cs.client);
13
+ await writeYaml(`${directory}/labels.yaml`, { labels });
14
+ const result = new MutableTransferResults();
15
+ result.created.add('labels.yaml');
16
+ bar.increment();
17
+ return result;
18
+ }
19
+ //# sourceMappingURL=toFilesystem.js.map
20
+ //# sourceMappingURL=toFilesystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toFilesystem.js","sourceRoot":"","sources":["../../../src/schema/labels/toFilesystem.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gCAAgC,CAAC;AAC1D,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,eAAe,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,iBAAiB,MAAM,6BAA6B,CAAC;AAG5D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,YAAY,CAAC,GAAQ;IAClD,MAAM,SAAS,GAAG,eAAe,EAAE,CAAC;IACpC,MAAM,GAAG,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAE9C,uEAAuE;IACvE,yEAAyE;IACzE,mCAAmC;IACnC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IACjD,MAAM,SAAS,CAAC,GAAG,SAAS,cAAc,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAExD,MAAM,MAAM,GAAG,IAAI,sBAAsB,EAAE,CAAC;IAC5C,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAClC,GAAG,CAAC,SAAS,EAAE,CAAC;IAChB,OAAO,MAAM,CAAC;AACf,CAAC;AAED,wCAAwC","sourcesContent":["import getAllLabels from '#cli/cs/labels/getAllLabels.js';\nimport writeYaml from '#cli/fs/writeYaml.js';\nimport schemaDirectory from '../content-types/schemaDirectory.js';\nimport { MutableTransferResults } from '../xfer/TransferResults.js';\nimport createProgressBar from '../lib/createProgressBar.js';\nimport type Ctx from '../ctx/Ctx.js';\n\nexport default async function toFilesystem(ctx: Ctx) {\n\tconst directory = schemaDirectory();\n\tconst bar = createProgressBar('Labels', 1, 0);\n\n\t// Fetch labels and write them directly. processPlan shortcuts when the\n\t// merge plan is empty, so for a single-file resource we write and return\n\t// a simple TransferResults object.\n\tconst labels = await getAllLabels(ctx.cs.client);\n\tawait writeYaml(`${directory}/labels.yaml`, { labels });\n\n\tconst result = new MutableTransferResults();\n\tresult.created.add('labels.yaml');\n\tbar.increment();\n\treturn result;\n}\n\n//# sourceMappingURL=toFilesystem.js.map\n"]}
@@ -1,2 +1,2 @@
1
- export default function createProgressBar(name: string, ...indicies: readonly ReadonlyMap<unknown, unknown>[]): import("../../ui/progress/ProgressBar.js").default;
1
+ export default function createProgressBar(name: string, ...indicies: readonly (ReadonlyMap<unknown, unknown> | number)[]): import("../../ui/progress/ProgressBar.js").default;
2
2
  //# sourceMappingURL=createProgressBar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createProgressBar.d.ts","sourceRoot":"","sources":["../../../src/schema/lib/createProgressBar.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACxC,IAAI,EAAE,MAAM,EACZ,GAAG,QAAQ,EAAE,SAAS,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,sDAIrD"}
1
+ {"version":3,"file":"createProgressBar.d.ts","sourceRoot":"","sources":["../../../src/schema/lib/createProgressBar.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACxC,IAAI,EAAE,MAAM,EACZ,GAAG,QAAQ,EAAE,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,EAAE,sDAYhE"}
@@ -1,6 +1,16 @@
1
1
  import getUi from './SchemaUi.js';
2
2
  export default function createProgressBar(name, ...indicies) {
3
- const totalSize = new Set(indicies.flatMap((x) => [...x.keys()])).size;
3
+ const sizes = indicies.map((x) => {
4
+ if (typeof x === 'number')
5
+ return x;
6
+ try {
7
+ return [...x.keys()].length;
8
+ }
9
+ catch {
10
+ return 0;
11
+ }
12
+ });
13
+ const totalSize = sizes.reduce((a, b) => a + b, 0);
4
14
  return getUi().createProgressBar(name, totalSize);
5
15
  }
6
16
  //# sourceMappingURL=createProgressBar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createProgressBar.js","sourceRoot":"","sources":["../../../src/schema/lib/createProgressBar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,eAAe,CAAC;AAElC,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACxC,IAAY,EACZ,GAAG,QAAkD;IAErD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvE,OAAO,KAAK,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import getUi from './SchemaUi.js';\n\nexport default function createProgressBar(\n\tname: string,\n\t...indicies: readonly ReadonlyMap<unknown, unknown>[]\n) {\n\tconst totalSize = new Set(indicies.flatMap((x) => [...x.keys()])).size;\n\treturn getUi().createProgressBar(name, totalSize);\n}\n"]}
1
+ {"version":3,"file":"createProgressBar.js","sourceRoot":"","sources":["../../../src/schema/lib/createProgressBar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,eAAe,CAAC;AAElC,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACxC,IAAY,EACZ,GAAG,QAA6D;IAEhE,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAChC,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,CAAC,CAAC;QACV,CAAC;IACF,CAAC,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACnD,OAAO,KAAK,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import getUi from './SchemaUi.js';\n\nexport default function createProgressBar(\n\tname: string,\n\t...indicies: readonly (ReadonlyMap<unknown, unknown> | number)[]\n) {\n\tconst sizes = indicies.map((x) => {\n\t\tif (typeof x === 'number') return x;\n\t\ttry {\n\t\t\treturn [...x.keys()].length;\n\t\t} catch {\n\t\t\treturn 0;\n\t\t}\n\t});\n\tconst totalSize = sizes.reduce((a, b) => a + b, 0);\n\treturn getUi().createProgressBar(name, totalSize);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"pullModules.d.ts","sourceRoot":"","sources":["../../../src/schema/lib/pullModules.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AAKrC,OAAO,KAAK,eAAe,MAAM,4BAA4B,CAAC;AAG9D,wBAA+B,WAAW,CACzC,GAAG,EAAE,GAAG,GACN,cAAc,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAwB7D"}
1
+ {"version":3,"file":"pullModules.d.ts","sourceRoot":"","sources":["../../../src/schema/lib/pullModules.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AAKrC,OAAO,KAAK,eAAe,MAAM,4BAA4B,CAAC;AAG9D,wBAA+B,WAAW,CACzC,GAAG,EAAE,GAAG,GACN,cAAc,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAyB7D"}
@@ -1,6 +1,7 @@
1
1
  import { __addDisposableResource, __disposeResources } from "tslib";
2
2
  import assets from '../assets/toFilesystem.js';
3
3
  import contentTypes from '../content-types/toFilesystem.js';
4
+ import labels from '../labels/toFilesystem.js';
4
5
  import clean from '../entries/clean.js';
5
6
  import entries from '../entries/toFilesystem.js';
6
7
  import globalFields from '../global-fields/toFilesystem.js';
@@ -10,6 +11,7 @@ export default async function* pullModules(ctx) {
10
11
  yield ['Assets', assets(ctx)];
11
12
  yield ['Global Fields', globalFields(ctx)];
12
13
  yield ['Taxonomies', taxonomies(ctx)];
14
+ yield ['Labels', labels(ctx)];
13
15
  yield ['Content Types', contentTypes(ctx)];
14
16
  const summary = summarizeContentTypes(ctx);
15
17
  const total = [...summary.values()].reduce((acc, count) => acc + count, 0);
@@ -1 +1 @@
1
- {"version":3,"file":"pullModules.js","sourceRoot":"","sources":["../../../src/schema/lib/pullModules.ts"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,YAAY,MAAM,kCAAkC,CAAC;AAE5D,OAAO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e;QACf,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;KACxE,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,GAAQ;IACtC,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;IAEnC,OAAO,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;SACtC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SAChD,MAAM,CAAC,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE;QAC5B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC;YACtB,GAAG,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;YACpD,GAAG,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;SACpD,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC,EAAE,IAAI,GAAG,EAAuB,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import type { ContentType } from '#cli/cs/content-types/Types.js';\nimport assets from '../assets/toFilesystem.js';\nimport contentTypes from '../content-types/toFilesystem.js';\nimport type Ctx from '../ctx/Ctx.js';\nimport clean from '../entries/clean.js';\nimport entries from '../entries/toFilesystem.js';\nimport globalFields from '../global-fields/toFilesystem.js';\nimport taxonomies from '../taxonomies/toFilesystem.js';\nimport type TransferResults from '../xfer/TransferResults.js';\nimport getUi from './SchemaUi.js';\n\nexport default async function* pullModules(\n\tctx: Ctx,\n): AsyncGenerator<readonly [string, Promise<TransferResults>]> {\n\tyield ['Assets', assets(ctx)];\n\tyield ['Global Fields', globalFields(ctx)];\n\tyield ['Taxonomies', taxonomies(ctx)];\n\tyield ['Content Types', contentTypes(ctx)];\n\n\tconst summary = summarizeContentTypes(ctx);\n\tconst total = [...summary.values()].reduce((acc, count) => acc + count, 0);\n\tconst ui = getUi();\n\n\t{\n\t\tusing bar = ui.createProgressBar('Entries', total);\n\n\t\tfor (const contentType of summary.keys()) {\n\t\t\tconst task = entries(ctx, contentType, bar);\n\t\t\tyield [`${contentType.title} Entries`, task];\n\t\t\tawait Promise.allSettled([task]);\n\t\t}\n\t}\n\n\tyield [\n\t\t'Stale Entries',\n\t\tclean(ui.options.schema.schemaPath, new Set(ctx.cs.contentTypes.keys())),\n\t];\n}\n\nfunction summarizeContentTypes(ctx: Ctx): ReadonlyMap<ContentType, number> {\n\tconst sorter = new Intl.Collator();\n\n\treturn [...ctx.cs.contentTypes.values()]\n\t\t.sort((a, b) => sorter.compare(a.title, b.title))\n\t\t.reduce((acc, contentType) => {\n\t\t\tconst titles = new Set([\n\t\t\t\t...ctx.cs.entries.byTitleFor(contentType.uid).keys(),\n\t\t\t\t...ctx.fs.entries.byTitleFor(contentType.uid).keys(),\n\t\t\t]);\n\n\t\t\treturn acc.set(contentType, titles.size);\n\t\t}, new Map<ContentType, number>());\n}\n"]}
1
+ {"version":3,"file":"pullModules.js","sourceRoot":"","sources":["../../../src/schema/lib/pullModules.ts"],"names":[],"mappings":";AACA,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAC/C,OAAO,YAAY,MAAM,kCAAkC,CAAC;AAC5D,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAE/C,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,OAAO,MAAM,4BAA4B,CAAC;AACjD,OAAO,YAAY,MAAM,kCAAkC,CAAC;AAC5D,OAAO,UAAU,MAAM,+BAA+B,CA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,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;KACxE,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,GAAQ;IACtC,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;IAEnC,OAAO,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;SACtC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SAChD,MAAM,CAAC,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE;QAC5B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC;YACtB,GAAG,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;YACpD,GAAG,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;SACpD,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC,EAAE,IAAI,GAAG,EAAuB,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import type { ContentType } from '#cli/cs/content-types/Types.js';\nimport assets from '../assets/toFilesystem.js';\nimport contentTypes from '../content-types/toFilesystem.js';\nimport labels from '../labels/toFilesystem.js';\nimport type Ctx from '../ctx/Ctx.js';\nimport clean from '../entries/clean.js';\nimport entries from '../entries/toFilesystem.js';\nimport globalFields from '../global-fields/toFilesystem.js';\nimport taxonomies from '../taxonomies/toFilesystem.js';\nimport type TransferResults from '../xfer/TransferResults.js';\nimport getUi from './SchemaUi.js';\n\nexport default async function* pullModules(\n\tctx: Ctx,\n): AsyncGenerator<readonly [string, Promise<TransferResults>]> {\n\tyield ['Assets', assets(ctx)];\n\tyield ['Global Fields', globalFields(ctx)];\n\tyield ['Taxonomies', taxonomies(ctx)];\n\tyield ['Labels', labels(ctx)];\n\tyield ['Content Types', contentTypes(ctx)];\n\n\tconst summary = summarizeContentTypes(ctx);\n\tconst total = [...summary.values()].reduce((acc, count) => acc + count, 0);\n\tconst ui = getUi();\n\n\t{\n\t\tusing bar = ui.createProgressBar('Entries', total);\n\n\t\tfor (const contentType of summary.keys()) {\n\t\t\tconst task = entries(ctx, contentType, bar);\n\t\t\tyield [`${contentType.title} Entries`, task];\n\t\t\tawait Promise.allSettled([task]);\n\t\t}\n\t}\n\n\tyield [\n\t\t'Stale Entries',\n\t\tclean(ui.options.schema.schemaPath, new Set(ctx.cs.contentTypes.keys())),\n\t];\n}\n\nfunction summarizeContentTypes(ctx: Ctx): ReadonlyMap<ContentType, number> {\n\tconst sorter = new Intl.Collator();\n\n\treturn [...ctx.cs.contentTypes.values()]\n\t\t.sort((a, b) => sorter.compare(a.title, b.title))\n\t\t.reduce((acc, contentType) => {\n\t\t\tconst titles = new Set([\n\t\t\t\t...ctx.cs.entries.byTitleFor(contentType.uid).keys(),\n\t\t\t\t...ctx.fs.entries.byTitleFor(contentType.uid).keys(),\n\t\t\t]);\n\n\t\t\treturn acc.set(contentType, titles.size);\n\t\t}, new Map<ContentType, number>());\n}\n"]}
@@ -1,9 +1,10 @@
1
1
  import type { Schema } from '#cli/cs/Types.js';
2
- export default function normalize({ description, options, schema, title, uid, }: Schema): {
3
- description: unknown;
2
+ export default function normalize({ description, labels, options, schema, title, uid, }: Schema): {
4
3
  options: unknown;
5
4
  schema: unknown;
6
5
  title: string;
7
6
  uid: string;
7
+ labels?: {};
8
+ description: unknown;
8
9
  };
9
10
  //# sourceMappingURL=normalize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/schema/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAS/C,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EACjC,WAAW,EACX,OAAO,EACP,MAAM,EACN,KAAK,EACL,GAAG,GACH,EAAE,MAAM;;;;;;EAQR"}
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/schema/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAc/C,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EACjC,WAAW,EACX,MAAM,EACN,OAAO,EACP,MAAM,EACN,KAAK,EACL,GAAG,GACH,EAAE,MAAM;;;;;;;EAaR"}
@@ -5,9 +5,18 @@
5
5
  // - SYS_ACL
6
6
  //
7
7
  // Last observed: 2024-07-26.
8
- export default function normalize({ description, options, schema, title, uid, }) {
8
+ //
9
+ // This function normalizes a schema by extracting only the fields that are
10
+ // considered stable and should be compared for equivalence. Fields like
11
+ // labels are preserved when present to ensure they are not lost during
12
+ // serialization/deserialization cycles.
13
+ export default function normalize({ description, labels, options, schema, title, uid, }) {
14
+ const normalizedLabels = Array.isArray(labels)
15
+ ? labels.slice().sort()
16
+ : labels;
9
17
  return {
10
18
  description,
19
+ ...(normalizedLabels ? { labels: normalizedLabels } : {}),
11
20
  options,
12
21
  schema: normalizeSchema(schema),
13
22
  title,
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/schema/normalize.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,2DAA2D;AAC3D,EAAE;AACF,kBAAkB;AAClB,cAAc;AACd,EAAE;AACF,6BAA6B;AAC7B,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EACjC,WAAW,EACX,OAAO,EACP,MAAM,EACN,KAAK,EACL,GAAG,GACK;IACR,OAAO;QACN,WAAW;QACX,OAAO;QACP,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;QAC/B,KAAK;QACL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ing differing values for these fields based on\n// whether an \"import\" or a \"read\" operation was performed:\n//\n// - DEFAULT_ACL\n// - SYS_ACL\n//\n// Last observed: 2024-07-26.\nexport default function normalize({\n\tdescription,\n\toptions,\n\tschema,\n\ttitle,\n\tuid,\n}: Schema) {\n\treturn {\n\t\tdescription,\n\t\toptions,\n\t\tschema: normalizeSchema(schema),\n\t\ttitle,\n\t\tuid,\n\t};\n}\n\nfunction normalizeSchema(schema: unknown): unknown {\n\tif (schema === undefined) {\n\t\treturn schema;\n\t}\n\n\tif (Array.isArray(schema)) {\n\t\treturn schema.map(normalizeSchema);\n\t}\n\n\tif (typeof schema !== 'object' || schema === null) {\n\t\tthrow new Error('Invalid schema');\n\t}\n\n\tconst {\n\t\tinbuilt_model,\n\t\tindexed,\n\t\tschema: nestedSchema,\n\t\t...rest\n\t} = schema as Record<string, unknown>;\n\n\treturn {\n\t\t...rest,\n\t\t...(nestedSchema ? { schema: normalizeSchema(nestedSchema) } : {}),\n\t\t...normalizeReferenceTo(rest),\n\t};\n}\n\nfunction normalizeReferenceTo(schema: Record<string, unknown>) {\n\tif (schema.data_type !== 'reference') {\n\t\treturn {};\n\t}\n\n\tconst { reference_to } = schema;\n\n\tif (!reference_to) {\n\t\treturn {};\n\t}\n\n\tif (!Array.isArray(reference_to)) {\n\t\treturn { reference_to };\n\t}\n\n\treturn { reference_to: [...new Set(reference_to)].sort() };\n}\n"]}
1
+ {"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/schema/normalize.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,2DAA2D;AAC3D,EAAE;AACF,kBAAkB;AAClB,cAAc;AACd,EAAE;AACF,6BAA6B;AAC7B,EAAE;AACF,2EAA2E;AAC3E,wEAAwE;AACxE,uEAAuE;AACvE,wCAAwC;AACxC,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EACjC,WAAW,EACX,MAAM,EACN,OAAO,EACP,MAAM,EACN,KAAK,EACL,GAAG,GACK;IACR,MAAM,gB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C,YAAY,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACX,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QAClC,OAAO,EAAE,YAAY,EAAE,CAAC;IACzB,CAAC;IAED,OAAO,EAAE,YAAY,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AAC5D,CAAC","sourcesContent":["import type { Schema } from '#cli/cs/Types.js';\n\n// Contentstack observed providing differing values for these fields based on\n// whether an \"import\" or a \"read\" operation was performed:\n//\n// - DEFAULT_ACL\n// - SYS_ACL\n//\n// Last observed: 2024-07-26.\n//\n// This function normalizes a schema by extracting only the fields that are\n// considered stable and should be compared for equivalence. Fields like\n// labels are preserved when present to ensure they are not lost during\n// serialization/deserialization cycles.\nexport default function normalize({\n\tdescription,\n\tlabels,\n\toptions,\n\tschema,\n\ttitle,\n\tuid,\n}: Schema) {\n\tconst normalizedLabels = Array.isArray(labels)\n\t\t? (labels as string[]).slice().sort()\n\t\t: labels;\n\n\treturn {\n\t\tdescription,\n\t\t...(normalizedLabels ? { labels: normalizedLabels } : {}),\n\t\toptions,\n\t\tschema: normalizeSchema(schema),\n\t\ttitle,\n\t\tuid,\n\t};\n}\n\nfunction normalizeSchema(schema: unknown): unknown {\n\tif (schema === undefined) {\n\t\treturn schema;\n\t}\n\n\tif (Array.isArray(schema)) {\n\t\treturn schema.map(normalizeSchema);\n\t}\n\n\tif (typeof schema !== 'object' || schema === null) {\n\t\tthrow new Error('Invalid schema');\n\t}\n\n\tconst {\n\t\tinbuilt_model,\n\t\tindexed,\n\t\tschema: nestedSchema,\n\t\t...rest\n\t} = schema as Record<string, unknown>;\n\n\treturn {\n\t\t...rest,\n\t\t...(nestedSchema ? { schema: normalizeSchema(nestedSchema) } : {}),\n\t\t...normalizeReferenceTo(rest),\n\t};\n}\n\nfunction normalizeReferenceTo(schema: Record<string, unknown>) {\n\tif (schema.data_type !== 'reference') {\n\t\treturn {};\n\t}\n\n\tconst { reference_to } = schema;\n\n\tif (!reference_to) {\n\t\treturn {};\n\t}\n\n\tif (!Array.isArray(reference_to)) {\n\t\treturn { reference_to };\n\t}\n\n\treturn { reference_to: [...new Set(reference_to)].sort() };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../src/schema/push.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAchD,wBAA8B,IAAI,CAAC,MAAM,EAAE,MAAM,mGAmDhD"}
1
+ {"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../src/schema/push.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAehD,wBAA8B,IAAI,CAAC,MAAM,EAAE,MAAM,mGAoDhD"}
@@ -11,6 +11,7 @@ import PushResults from './lib/PushResults.js';
11
11
  import getUi from './lib/SchemaUi.js';
12
12
  import taxonomies from './taxonomies/toContentstack.js';
13
13
  import terms from './terms/toContentstack.js';
14
+ import labels from './labels/toContentstack.js';
14
15
  export default async function push(client) {
15
16
  const results = new PushResults();
16
17
  const ctx = await Ctx.prepare(client);
@@ -64,6 +65,7 @@ export default async function push(client) {
64
65
  }
65
66
  }
66
67
  await results.set('References', updateMissedReferences(ctx));
68
+ await results.set('Labels', labels(ctx));
67
69
  return results.value;
68
70
  }
69
71
  function calculateTotalEntries(ctx) {