@tandem-language-exchange/content-store 1.1.2 → 1.2.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.
@@ -1,16 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  config,
4
- fetchBundles
5
- } from "../chunk-JBFJU4JA.js";
4
+ fetchCmsBundles
5
+ } from "../chunk-VRWRAFDK.js";
6
+ import "../chunk-XP3USUQC.js";
6
7
  import {
7
8
  ContentStore
8
- } from "../chunk-UWGOF36L.js";
9
+ } from "../chunk-YZSLCPN6.js";
9
10
 
10
- // src/client/fetch-bundles.ts
11
+ // src/client/fetch-content-bundles.ts
11
12
  import { Command } from "commander";
12
13
  var program = new Command();
13
- program.name("fetch-content-bundles").description("Download latest bundles from S3 to the local filesystem").requiredOption("--cms <provider>", "CMS provider: contentful | sanity").requiredOption("--types <types>", "Comma-separated content types to fetch").option("--output <directory>", "Output directory", "./content-cache").action(async (opts) => {
14
+ program.name("fetch-content-bundles").description("Download latest CMS bundles from S3 to the local filesystem").requiredOption("--cms <provider>", "CMS provider: contentful | sanity").requiredOption("--types <types>", "Comma-separated content types to fetch").option("--output <directory>", "Output directory", "./content-cache").action(async (opts) => {
14
15
  const cms = opts.cms;
15
16
  if (!["contentful", "sanity"].includes(cms)) {
16
17
  console.error(`Invalid CMS provider: ${cms}`);
@@ -19,7 +20,7 @@ program.name("fetch-content-bundles").description("Download latest bundles from
19
20
  const contentTypes = opts.types.split(",").map((s) => s.trim());
20
21
  const store = new ContentStore(config.s3);
21
22
  try {
22
- const files = await fetchBundles(store, opts.output, {
23
+ const files = await fetchCmsBundles(store, opts.output, {
23
24
  cms,
24
25
  contentTypes
25
26
  });
@@ -33,4 +34,4 @@ program.name("fetch-content-bundles").description("Download latest bundles from
33
34
  }
34
35
  });
35
36
  program.parse();
36
- //# sourceMappingURL=fetch-bundles.js.map
37
+ //# sourceMappingURL=fetch-content-bundles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/fetch-content-bundles.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { config, type CMSProvider } from './config';\nimport { ContentStore } from '../shared/s3';\nimport { fetchCmsBundles } from '../shared/bundles';\n\nconst program = new Command();\n\nprogram\n .name('fetch-content-bundles')\n .description('Download latest CMS bundles from S3 to the local filesystem')\n .requiredOption('--cms <provider>', 'CMS provider: contentful | sanity')\n .requiredOption('--types <types>', 'Comma-separated content types to fetch')\n .option('--output <directory>', 'Output directory', './content-cache')\n .action(async (opts: { cms: string; types: string; output: string }) => {\n const cms = opts.cms as CMSProvider;\n\n if (!['contentful', 'sanity'].includes(cms)) {\n console.error(`Invalid CMS provider: ${cms}`);\n process.exit(1);\n }\n\n const contentTypes = opts.types.split(',').map((s) => s.trim());\n const store = new ContentStore(config.s3);\n\n try {\n const files = await fetchCmsBundles(store, opts.output, {\n cms,\n contentTypes,\n });\n\n console.log('Fetched bundles:');\n for (const [type, filePath] of Object.entries(files)) {\n console.log(` ${type} -> ${filePath}`);\n }\n } catch (err) {\n console.error('Fetch failed:', err);\n process.exit(1);\n }\n });\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,eAAe;AAKxB,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,uBAAuB,EAC5B,YAAY,6DAA6D,EACzE,eAAe,oBAAoB,mCAAmC,EACtE,eAAe,mBAAmB,wCAAwC,EAC1E,OAAO,wBAAwB,oBAAoB,iBAAiB,EACpE,OAAO,OAAO,SAAyD;AACtE,QAAM,MAAM,KAAK;AAEjB,MAAI,CAAC,CAAC,cAAc,QAAQ,EAAE,SAAS,GAAG,GAAG;AAC3C,YAAQ,MAAM,yBAAyB,GAAG,EAAE;AAC5C,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,eAAe,KAAK,MAAM,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC;AAC9D,QAAM,QAAQ,IAAI,aAAa,OAAO,EAAE;AAExC,MAAI;AACF,UAAM,QAAQ,MAAM,gBAAgB,OAAO,KAAK,QAAQ;AAAA,MACtD;AAAA,MACA;AAAA,IACF,CAAC;AAED,YAAQ,IAAI,kBAAkB;AAC9B,eAAW,CAAC,MAAM,QAAQ,KAAK,OAAO,QAAQ,KAAK,GAAG;AACpD,cAAQ,IAAI,KAAK,IAAI,OAAO,QAAQ,EAAE;AAAA,IACxC;AAAA,EACF,SAAS,KAAK;AACZ,YAAQ,MAAM,iBAAiB,GAAG;AAClC,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAEH,QAAQ,MAAM;","names":[]}
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ config,
4
+ fetchTranslationBundles
5
+ } from "../chunk-VRWRAFDK.js";
6
+ import "../chunk-XP3USUQC.js";
7
+ import {
8
+ ContentStore
9
+ } from "../chunk-YZSLCPN6.js";
10
+
11
+ // src/client/fetch-translation-bundles.ts
12
+ import { Command } from "commander";
13
+ var program = new Command();
14
+ program.name("fetch-translation-bundles").description("Download latest translation bundles from S3 to the local filesystem").requiredOption("--projects <projects>", "Comma-separated projects to fetch").option("--locales <locales>", "Comma-separated locales to fetch (omit to fetch all)").option("--output <directory>", "Output directory", "./content-cache").action(async (opts) => {
15
+ const projects = opts.projects.split(",").map((s) => s.trim());
16
+ const locales = opts.locales ? opts.locales.split(",").map((s) => s.trim()) : void 0;
17
+ const store = new ContentStore(config.s3);
18
+ try {
19
+ const files = await fetchTranslationBundles(store, opts.output, {
20
+ projects,
21
+ locales
22
+ });
23
+ console.log("Fetched bundles:");
24
+ for (const [project, pathsByKey] of Object.entries(files)) {
25
+ console.log(` ${project}:`);
26
+ for (const [objectKey, filePath] of Object.entries(pathsByKey)) {
27
+ console.log(` ${objectKey} -> ${filePath}`);
28
+ }
29
+ }
30
+ } catch (err) {
31
+ console.error("Fetch failed:", err);
32
+ process.exit(1);
33
+ }
34
+ });
35
+ program.parse();
36
+ //# sourceMappingURL=fetch-translation-bundles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/fetch-translation-bundles.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { config, type CMSProvider } from './config';\nimport { ContentStore } from '../shared/s3';\nimport { fetchTranslationBundles } from '../shared/bundles';\n\nconst program = new Command();\n\nprogram\n .name('fetch-translation-bundles')\n .description('Download latest translation bundles from S3 to the local filesystem')\n .requiredOption('--projects <projects>', 'Comma-separated projects to fetch')\n .option('--locales <locales>', 'Comma-separated locales to fetch (omit to fetch all)')\n .option('--output <directory>', 'Output directory', './content-cache')\n .action(async (opts: { projects: string; locales?: string; output: string }) => {\n\n const projects = opts.projects.split(',').map((s) => s.trim());\n const locales = opts.locales ? opts.locales.split(',').map((s) => s.trim()) : undefined;\n const store = new ContentStore(config.s3);\n\n try {\n const files = await fetchTranslationBundles(store, opts.output, {\n projects,\n locales,\n });\n\n console.log('Fetched bundles:');\n for (const [project, pathsByKey] of Object.entries(files)) {\n console.log(` ${project}:`);\n for (const [objectKey, filePath] of Object.entries(pathsByKey)) {\n console.log(` ${objectKey} -> ${filePath}`);\n }\n }\n } catch (err) {\n console.error('Fetch failed:', err);\n process.exit(1);\n }\n });\n\nprogram.parse();"],"mappings":";;;;;;;;;;;AAAA,SAAS,eAAe;AAKxB,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACK,KAAK,2BAA2B,EAChC,YAAY,qEAAqE,EACjF,eAAe,yBAAyB,mCAAmC,EAC3E,OAAO,uBAAuB,uDAAuD,EACrF,OAAO,wBAAwB,oBAAoB,iBAAiB,EACpE,OAAO,OAAO,SAAiE;AAE5E,QAAM,WAAW,KAAK,SAAS,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC;AAC7D,QAAM,UAAU,KAAK,UAAU,KAAK,QAAQ,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI;AAC9E,QAAM,QAAQ,IAAI,aAAa,OAAO,EAAE;AAExC,MAAI;AACA,UAAM,QAAQ,MAAM,wBAAwB,OAAO,KAAK,QAAQ;AAAA,MAC5D;AAAA,MACA;AAAA,IACJ,CAAC;AAED,YAAQ,IAAI,kBAAkB;AAC9B,eAAW,CAAC,SAAS,UAAU,KAAK,OAAO,QAAQ,KAAK,GAAG;AACvD,cAAQ,IAAI,KAAK,OAAO,GAAG;AAC3B,iBAAW,CAAC,WAAW,QAAQ,KAAK,OAAO,QAAQ,UAAU,GAAG;AAC5D,gBAAQ,IAAI,OAAO,SAAS,OAAO,QAAQ,EAAE;AAAA,MACjD;AAAA,IACJ;AAAA,EACJ,SAAS,KAAK;AACV,YAAQ,MAAM,iBAAiB,GAAG;AAClC,YAAQ,KAAK,CAAC;AAAA,EAClB;AACJ,CAAC;AAEL,QAAQ,MAAM;","names":[]}
@@ -10,28 +10,42 @@ declare class ContentStore {
10
10
  private client;
11
11
  private bucket;
12
12
  constructor(cfg: S3Config);
13
- /** {cms}-{contentType}-{timestamp}.json */
14
- buildVersionedKey(cms: string, contentType: string, timestamp: number): string;
15
- /** {cms}-{contentType}.json (always points at the latest version) */
16
- buildLatestKey(cms: string, contentType: string): string;
17
13
  upload(key: string, data: unknown): Promise<string>;
18
14
  download(key: string): Promise<unknown>;
19
- /**
20
- * Copies a versioned object to the "latest" key so that it always reflects
21
- * the most recent sync while older timestamped versions are retained.
22
- */
23
- copyToLatest(sourceKey: string, cms: string, contentType: string): Promise<string>;
24
15
  }
25
16
 
26
- interface BundleInfo {
17
+ /** Retry/backoff for S3 reads (aligned with CMS `RetryConfig` shape). */
18
+ interface S3RetryConfig {
19
+ maxRetries: number;
20
+ baseDelayMs: number;
21
+ maxDelayMs: number;
22
+ }
23
+ /**
24
+ * Default S3 download retry policy from env.
25
+ * `S3_RETRY_*` overrides `RETRY_*` when set.
26
+ */
27
+ declare function getDefaultS3RetryConfig(): S3RetryConfig;
28
+
29
+ interface CmsBundleInfo {
27
30
  [key: string]: string;
28
31
  }
32
+ interface TranslationBundleInfo {
33
+ [key: string]: Record<string, string>;
34
+ }
29
35
  interface BundleItem {
30
36
  [key: string]: any;
31
37
  }
32
- interface FetchBundlesOptions {
38
+ interface FetchCmsBundlesOptions {
33
39
  cms: CMSProvider;
34
40
  contentTypes: string[];
41
+ /** S3 GET retry; defaults via {@link getDefaultS3RetryConfig}. */
42
+ retry?: S3RetryConfig;
43
+ }
44
+ interface FetchTranslationBundlesOptions {
45
+ projects: string[];
46
+ locales?: string[] | undefined;
47
+ /** S3 GET retry; defaults via {@link getDefaultS3RetryConfig}. */
48
+ retry?: S3RetryConfig;
35
49
  }
36
50
  interface QueryOptions {
37
51
  /**
@@ -64,15 +78,21 @@ interface QueryOptions {
64
78
  include?: number;
65
79
  }
66
80
  /**
67
- * Downloads the latest bundles from S3 and writes them as JSON files to `outputDir`.
81
+ * Downloads the latest CMS bundles from S3 and writes them as JSON files to `outputDir`.
68
82
  *
69
83
  * @returns A map of contentType to absolute file path.
70
84
  */
71
- declare function fetchBundles(store: ContentStore, outputDir: string, options: FetchBundlesOptions): Promise<Record<string, string>>;
85
+ declare function fetchCmsBundles(store: ContentStore, outputDir: string, options: FetchCmsBundlesOptions): Promise<Record<string, string>>;
86
+ /**
87
+ * Downloads the latest translation bundles from S3 and writes them as JSON files to `outputDir`.
88
+ *
89
+ * @returns For each project, a map of S3 object key to absolute file path on disk.
90
+ */
91
+ declare function fetchTranslationBundles(store: ContentStore, outputDir: string, options: FetchTranslationBundlesOptions): Promise<TranslationBundleInfo>;
72
92
  /**
73
93
  * Queries a previously fetched bundle from the local filesystem.
74
94
  */
75
- declare function queryBundle(outputDir: string, cms: CMSProvider, contentType: string, options?: QueryOptions): Promise<unknown[]>;
95
+ declare function queryCmsBundle(outputDir: string, cms: CMSProvider, contentType: string, options?: QueryOptions): Promise<unknown[]>;
76
96
 
77
97
  interface SDKConfig {
78
98
  s3: S3Config;
@@ -80,4 +100,4 @@ interface SDKConfig {
80
100
  outputDir: string;
81
101
  }
82
102
 
83
- export { type BundleInfo as B, type CMSProvider as C, type FetchBundlesOptions as F, type QueryOptions as Q, type SDKConfig as S, type BundleItem as a, ContentStore as b, type S3Config as c, fetchBundles as f, queryBundle as q };
103
+ export { type BundleItem as B, type CMSProvider as C, type FetchCmsBundlesOptions as F, type QueryOptions as Q, type SDKConfig as S, type TranslationBundleInfo as T, type FetchTranslationBundlesOptions as a, type CmsBundleInfo as b, ContentStore as c, type S3Config as d, type S3RetryConfig as e, fetchCmsBundles as f, fetchTranslationBundles as g, getDefaultS3RetryConfig as h, queryCmsBundle as q };
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { B as BundleInfo, a as BundleItem, C as CMSProvider, F as FetchBundlesOptions, Q as QueryOptions, c as S3Config, S as SDKConfig } from './index-DJXkO17k.js';
1
+ export { B as BundleItem, C as CMSProvider, b as CmsBundleInfo, F as FetchCmsBundlesOptions, a as FetchTranslationBundlesOptions, Q as QueryOptions, d as S3Config, e as S3RetryConfig, S as SDKConfig, T as TranslationBundleInfo } from './index-Db97SUTy.js';
@@ -36,10 +36,13 @@ var ContentStoreSDK = class {
36
36
  constructor(_config) {
37
37
  serverOnly();
38
38
  }
39
- fetchBundles() {
39
+ fetchCmsBundles() {
40
40
  return Promise.reject(new Error(SERVER_ONLY));
41
41
  }
42
- queryBundle() {
42
+ queryCmsBundle() {
43
+ return Promise.reject(new Error(SERVER_ONLY));
44
+ }
45
+ fetchTranslationBundles() {
43
46
  return Promise.reject(new Error(SERVER_ONLY));
44
47
  }
45
48
  };
@@ -48,17 +51,21 @@ var ContentStore = class {
48
51
  serverOnly();
49
52
  }
50
53
  };
51
- async function fetchBundles() {
54
+ async function fetchCmsBundles() {
55
+ serverOnly();
56
+ }
57
+ async function queryCmsBundle() {
52
58
  serverOnly();
53
59
  }
54
- async function queryBundle() {
60
+ async function fetchTranslationBundles() {
55
61
  serverOnly();
56
62
  }
57
63
  export {
58
64
  ContentStore,
59
65
  ContentStoreSDK,
60
- fetchBundles,
61
- queryBundle,
66
+ fetchCmsBundles,
67
+ fetchTranslationBundles,
68
+ queryCmsBundle,
62
69
  trimDepth
63
70
  };
64
71
  //# sourceMappingURL=node.browser.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/shared/trimDepth.ts","../src/node.browser.ts"],"sourcesContent":["/**\n * Trims nested object depth.\n *\n * `remaining` represents how many levels the current object is allowed.\n * - Scalar properties are always kept.\n * - Nested objects / arrays-of-objects consume one level. When `remaining`\n * drops to 1 they are replaced with `null` (no budget left for refs).\n */\nexport function trimDepth(value: unknown, remaining: number): unknown {\n if (value === null || value === undefined || typeof value !== 'object') {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => trimDepth(item, remaining));\n }\n\n const obj = value as Record<string, unknown>;\n const result: Record<string, unknown> = {};\n\n for (const [k, v] of Object.entries(obj)) {\n if (v === null || v === undefined || typeof v !== 'object') {\n result[k] = v;\n } else if (remaining <= 1) {\n result[k] = null;\n } else if (Array.isArray(v)) {\n result[k] = v.map((item) => {\n if (item !== null && typeof item === 'object' && !Array.isArray(item)) {\n return trimDepth(item, remaining - 1);\n }\n return item;\n });\n } else {\n result[k] = trimDepth(v, remaining - 1);\n }\n }\n\n return result;\n}\n","/**\n * Browser / client-bundler entry for `@tandem-language-exchange/content-store/node`.\n * Next.js and Turbopack resolve this when the `browser` condition applies, so `fs`\n * is never pulled into client chunks.\n *\n * Server-only APIs throw if called; `trimDepth` is real and safe everywhere.\n */\nexport type {\n SDKConfig,\n FetchBundlesOptions,\n QueryOptions,\n BundleInfo,\n BundleItem,\n} from './sdk/client-types';\nexport type { CMSProvider, S3Config } from './shared/types';\n\nexport { trimDepth } from './shared/trimDepth';\n\nconst SERVER_ONLY =\n '@tandem-language-exchange/content-store/node uses the filesystem and S3 and only runs on the server. ' +\n 'Import it from getServerSideProps, Route Handlers, or \"use server\" modules — not from _app, layouts, or client components. ' +\n 'You can use `import type { ... } from \"@tandem-language-exchange/content-store\"` in shared code.';\n\nfunction serverOnly(): never {\n throw new Error(SERVER_ONLY);\n}\n\nexport class ContentStoreSDK {\n constructor(_config: unknown) {\n serverOnly();\n }\n\n fetchBundles(): Promise<never> {\n return Promise.reject(new Error(SERVER_ONLY));\n }\n\n queryBundle(): Promise<never> {\n return Promise.reject(new Error(SERVER_ONLY));\n }\n}\n\nexport class ContentStore {\n constructor(_cfg: unknown) {\n serverOnly();\n }\n}\n\nexport async function fetchBundles(): Promise<never> {\n serverOnly();\n}\n\nexport async function queryBundle(): Promise<never> {\n serverOnly();\n}\n"],"mappings":";AAQO,SAAS,UAAU,OAAgB,WAA4B;AACpE,MAAI,UAAU,QAAQ,UAAU,UAAa,OAAO,UAAU,UAAU;AACtE,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,IAAI,CAAC,SAAS,UAAU,MAAM,SAAS,CAAC;AAAA,EACvD;AAEA,QAAM,MAAM;AACZ,QAAM,SAAkC,CAAC;AAEzC,aAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,GAAG,GAAG;AACxC,QAAI,MAAM,QAAQ,MAAM,UAAa,OAAO,MAAM,UAAU;AAC1D,aAAO,CAAC,IAAI;AAAA,IACd,WAAW,aAAa,GAAG;AACzB,aAAO,CAAC,IAAI;AAAA,IACd,WAAW,MAAM,QAAQ,CAAC,GAAG;AAC3B,aAAO,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS;AAC1B,YAAI,SAAS,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,GAAG;AACrE,iBAAO,UAAU,MAAM,YAAY,CAAC;AAAA,QACtC;AACA,eAAO;AAAA,MACT,CAAC;AAAA,IACH,OAAO;AACL,aAAO,CAAC,IAAI,UAAU,GAAG,YAAY,CAAC;AAAA,IACxC;AAAA,EACF;AAEA,SAAO;AACT;;;ACpBA,IAAM,cACJ;AAIF,SAAS,aAAoB;AAC3B,QAAM,IAAI,MAAM,WAAW;AAC7B;AAEO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAAY,SAAkB;AAC5B,eAAW;AAAA,EACb;AAAA,EAEA,eAA+B;AAC7B,WAAO,QAAQ,OAAO,IAAI,MAAM,WAAW,CAAC;AAAA,EAC9C;AAAA,EAEA,cAA8B;AAC5B,WAAO,QAAQ,OAAO,IAAI,MAAM,WAAW,CAAC;AAAA,EAC9C;AACF;AAEO,IAAM,eAAN,MAAmB;AAAA,EACxB,YAAY,MAAe;AACzB,eAAW;AAAA,EACb;AACF;AAEA,eAAsB,eAA+B;AACnD,aAAW;AACb;AAEA,eAAsB,cAA8B;AAClD,aAAW;AACb;","names":[]}
1
+ {"version":3,"sources":["../src/shared/trimDepth.ts","../src/node.browser.ts"],"sourcesContent":["/**\n * Trims nested object depth.\n *\n * `remaining` represents how many levels the current object is allowed.\n * - Scalar properties are always kept.\n * - Nested objects / arrays-of-objects consume one level. When `remaining`\n * drops to 1 they are replaced with `null` (no budget left for refs).\n */\nexport function trimDepth(value: unknown, remaining: number): unknown {\n if (value === null || value === undefined || typeof value !== 'object') {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => trimDepth(item, remaining));\n }\n\n const obj = value as Record<string, unknown>;\n const result: Record<string, unknown> = {};\n\n for (const [k, v] of Object.entries(obj)) {\n if (v === null || v === undefined || typeof v !== 'object') {\n result[k] = v;\n } else if (remaining <= 1) {\n result[k] = null;\n } else if (Array.isArray(v)) {\n result[k] = v.map((item) => {\n if (item !== null && typeof item === 'object' && !Array.isArray(item)) {\n return trimDepth(item, remaining - 1);\n }\n return item;\n });\n } else {\n result[k] = trimDepth(v, remaining - 1);\n }\n }\n\n return result;\n}\n","/**\n * Browser / client-bundler entry for `@tandem-language-exchange/content-store/node`.\n * Next.js and Turbopack resolve this when the `browser` condition applies, so `fs`\n * is never pulled into client chunks.\n *\n * Server-only APIs throw if called; `trimDepth` is real and safe everywhere.\n */\nexport type {\n SDKConfig,\n FetchCmsBundlesOptions,\n FetchTranslationBundlesOptions,\n QueryOptions,\n CmsBundleInfo,\n TranslationBundleInfo,\n BundleItem,\n} from './sdk/client-types';\nexport type { CMSProvider, S3Config } from './shared/types';\n\nexport { trimDepth } from './shared/trimDepth';\n\nconst SERVER_ONLY =\n '@tandem-language-exchange/content-store/node uses the filesystem and S3 and only runs on the server. ' +\n 'Import it from getServerSideProps, Route Handlers, or \"use server\" modules — not from _app, layouts, or client components. ' +\n 'You can use `import type { ... } from \"@tandem-language-exchange/content-store\"` in shared code.';\n\nfunction serverOnly(): never {\n throw new Error(SERVER_ONLY);\n}\n\nexport class ContentStoreSDK {\n constructor(_config: unknown) {\n serverOnly();\n }\n\n fetchCmsBundles(): Promise<never> {\n return Promise.reject(new Error(SERVER_ONLY));\n }\n\n queryCmsBundle(): Promise<never> {\n return Promise.reject(new Error(SERVER_ONLY));\n }\n\n fetchTranslationBundles(): Promise<never> {\n return Promise.reject(new Error(SERVER_ONLY));\n }\n}\n\nexport class ContentStore {\n constructor(_cfg: unknown) {\n serverOnly();\n }\n}\n\nexport async function fetchCmsBundles(): Promise<never> {\n serverOnly();\n}\n\nexport async function queryCmsBundle(): Promise<never> {\n serverOnly();\n}\n\nexport async function fetchTranslationBundles(): Promise<never> {\n serverOnly();\n}\n"],"mappings":";AAQO,SAAS,UAAU,OAAgB,WAA4B;AACpE,MAAI,UAAU,QAAQ,UAAU,UAAa,OAAO,UAAU,UAAU;AACtE,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,IAAI,CAAC,SAAS,UAAU,MAAM,SAAS,CAAC;AAAA,EACvD;AAEA,QAAM,MAAM;AACZ,QAAM,SAAkC,CAAC;AAEzC,aAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,GAAG,GAAG;AACxC,QAAI,MAAM,QAAQ,MAAM,UAAa,OAAO,MAAM,UAAU;AAC1D,aAAO,CAAC,IAAI;AAAA,IACd,WAAW,aAAa,GAAG;AACzB,aAAO,CAAC,IAAI;AAAA,IACd,WAAW,MAAM,QAAQ,CAAC,GAAG;AAC3B,aAAO,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS;AAC1B,YAAI,SAAS,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,GAAG;AACrE,iBAAO,UAAU,MAAM,YAAY,CAAC;AAAA,QACtC;AACA,eAAO;AAAA,MACT,CAAC;AAAA,IACH,OAAO;AACL,aAAO,CAAC,IAAI,UAAU,GAAG,YAAY,CAAC;AAAA,IACxC;AAAA,EACF;AAEA,SAAO;AACT;;;AClBA,IAAM,cACJ;AAIF,SAAS,aAAoB;AAC3B,QAAM,IAAI,MAAM,WAAW;AAC7B;AAEO,IAAM,kBAAN,MAAsB;AAAA,EAC3B,YAAY,SAAkB;AAC5B,eAAW;AAAA,EACb;AAAA,EAEA,kBAAkC;AAChC,WAAO,QAAQ,OAAO,IAAI,MAAM,WAAW,CAAC;AAAA,EAC9C;AAAA,EAEA,iBAAiC;AAC/B,WAAO,QAAQ,OAAO,IAAI,MAAM,WAAW,CAAC;AAAA,EAC9C;AAAA,EAEA,0BAA0C;AACxC,WAAO,QAAQ,OAAO,IAAI,MAAM,WAAW,CAAC;AAAA,EAC9C;AACF;AAEO,IAAM,eAAN,MAAmB;AAAA,EACxB,YAAY,MAAe;AACzB,eAAW;AAAA,EACb;AACF;AAEA,eAAsB,kBAAkC;AACtD,aAAW;AACb;AAEA,eAAsB,iBAAiC;AACrD,aAAW;AACb;AAEA,eAAsB,0BAA0C;AAC9D,aAAW;AACb;","names":[]}
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as SDKConfig, F as FetchBundlesOptions, C as CMSProvider, Q as QueryOptions } from './index-DJXkO17k.js';
2
- export { B as BundleInfo, a as BundleItem, b as ContentStore, c as S3Config, f as fetchBundles, q as queryBundle } from './index-DJXkO17k.js';
1
+ import { S as SDKConfig, F as FetchCmsBundlesOptions, a as FetchTranslationBundlesOptions, T as TranslationBundleInfo, C as CMSProvider, Q as QueryOptions } from './index-Db97SUTy.js';
2
+ export { B as BundleItem, b as CmsBundleInfo, c as ContentStore, d as S3Config, e as S3RetryConfig, f as fetchCmsBundles, g as fetchTranslationBundles, h as getDefaultS3RetryConfig, q as queryCmsBundle } from './index-Db97SUTy.js';
3
3
 
4
4
  /**
5
5
  * Trims nested object depth.
@@ -21,11 +21,18 @@ declare class ContentStoreSDK {
21
21
  *
22
22
  * @returns A map of contentType to absolute file path.
23
23
  */
24
- fetchBundles(options: FetchBundlesOptions): Promise<Record<string, string>>;
24
+ fetchCmsBundles(options: FetchCmsBundlesOptions): Promise<Record<string, string>>;
25
+ /**
26
+ * Downloads translation bundles from S3 and writes them as JSON files
27
+ * to `outputDir`.
28
+ *
29
+ * @returns Per project, a map of S3 object key to absolute file path.
30
+ */
31
+ fetchTranslationBundles(options: FetchTranslationBundlesOptions): Promise<TranslationBundleInfo>;
25
32
  /**
26
33
  * Queries a previously fetched bundle from the local filesystem.
27
34
  */
28
- queryBundle(cms: CMSProvider, contentType: string, options?: QueryOptions): Promise<unknown[]>;
35
+ queryCmsBundle(cms: CMSProvider, contentType: string, options?: QueryOptions): Promise<unknown[]>;
29
36
  }
30
37
 
31
- export { CMSProvider, ContentStoreSDK, FetchBundlesOptions, QueryOptions, SDKConfig, trimDepth };
38
+ export { CMSProvider, ContentStoreSDK, FetchCmsBundlesOptions, FetchTranslationBundlesOptions, QueryOptions, SDKConfig, TranslationBundleInfo, trimDepth };