@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.
package/dist/node.js CHANGED
@@ -2,7 +2,6 @@
2
2
  import {
3
3
  S3Client,
4
4
  PutObjectCommand,
5
- CopyObjectCommand,
6
5
  GetObjectCommand
7
6
  } from "@aws-sdk/client-s3";
8
7
  var ContentStore = class {
@@ -18,14 +17,6 @@ var ContentStore = class {
18
17
  });
19
18
  this.bucket = cfg.bucket;
20
19
  }
21
- /** {cms}-{contentType}-{timestamp}.json */
22
- buildVersionedKey(cms, contentType, timestamp) {
23
- return `${cms}-${contentType}-${timestamp}.json`;
24
- }
25
- /** {cms}-{contentType}.json (always points at the latest version) */
26
- buildLatestKey(cms, contentType) {
27
- return `${cms}-${contentType}.json`;
28
- }
29
20
  async upload(key, data) {
30
21
  await this.client.send(
31
22
  new PutObjectCommand({
@@ -45,28 +36,93 @@ var ContentStore = class {
45
36
  if (!body) throw new Error(`Empty response for key: ${key}`);
46
37
  return JSON.parse(body);
47
38
  }
48
- /**
49
- * Copies a versioned object to the "latest" key so that it always reflects
50
- * the most recent sync while older timestamped versions are retained.
51
- */
52
- async copyToLatest(sourceKey, cms, contentType) {
53
- const latestKey = this.buildLatestKey(cms, contentType);
54
- await this.client.send(
55
- new CopyObjectCommand({
56
- Bucket: this.bucket,
57
- CopySource: `${this.bucket}/${sourceKey}`,
58
- Key: latestKey,
59
- ContentType: "application/json"
60
- })
61
- );
62
- return latestKey;
63
- }
39
+ };
40
+ var buildCmsObjectKey = (cms, contentType) => {
41
+ return `${cms}-${contentType}.json`;
42
+ };
43
+ var buildTranslationObjectKey = (project, fileName, locale) => {
44
+ return `lingohub-${project}.${fileName.replaceAll("[locale]", locale)}`;
64
45
  };
65
46
 
66
47
  // src/shared/bundles.ts
67
48
  import fs from "fs/promises";
68
49
  import path from "path";
69
50
 
51
+ // src/shared/s3-retry.ts
52
+ function computeDelay(attempt, baseDelayMs, maxDelayMs) {
53
+ const exponential = baseDelayMs * Math.pow(2, attempt);
54
+ const jitter = Math.random() * baseDelayMs;
55
+ return Math.min(exponential + jitter, maxDelayMs);
56
+ }
57
+ function getDefaultS3RetryConfig() {
58
+ return {
59
+ maxRetries: parseInt(
60
+ process.env.S3_RETRY_MAX_RETRIES ?? process.env.RETRY_MAX_RETRIES ?? "5",
61
+ 10
62
+ ),
63
+ baseDelayMs: parseInt(
64
+ process.env.S3_RETRY_BASE_DELAY_MS ?? process.env.RETRY_BASE_DELAY_MS ?? "1000",
65
+ 10
66
+ ),
67
+ maxDelayMs: parseInt(
68
+ process.env.S3_RETRY_MAX_DELAY_MS ?? process.env.RETRY_MAX_DELAY_MS ?? "60000",
69
+ 10
70
+ )
71
+ };
72
+ }
73
+ function isRetryableS3DownloadError(err) {
74
+ if (err === null || err === void 0) return false;
75
+ if (typeof err === "object") {
76
+ const e = err;
77
+ const status = e.$metadata?.httpStatusCode;
78
+ if (status === 404 || status === 403 || status === 401 || status === 400) {
79
+ return false;
80
+ }
81
+ if (status !== void 0 && (status === 408 || status === 429 || status === 500 || status === 502 || status === 503 || status === 504)) {
82
+ return true;
83
+ }
84
+ const name = e.name ?? "";
85
+ const code = e.Code ?? "";
86
+ if (/SlowDown|Throttl|Timeout|TooManyRequests|ServiceUnavailable|InternalError/i.test(
87
+ name
88
+ ) || /SlowDown|Throttl/i.test(code)) {
89
+ return true;
90
+ }
91
+ }
92
+ if (err instanceof Error) {
93
+ const m = err.message;
94
+ if (/ECONNRESET|ETIMEDOUT|EPIPE|ECONNREFUSED|socket hang up|getaddrinfo/i.test(
95
+ m
96
+ )) {
97
+ return true;
98
+ }
99
+ }
100
+ return false;
101
+ }
102
+ async function withS3Retry(fn, { maxRetries, baseDelayMs, maxDelayMs }) {
103
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
104
+ try {
105
+ return await fn();
106
+ } catch (err) {
107
+ if (!isRetryableS3DownloadError(err)) {
108
+ throw err;
109
+ }
110
+ if (attempt === maxRetries) {
111
+ throw err;
112
+ }
113
+ const delay = computeDelay(attempt, baseDelayMs, maxDelayMs);
114
+ console.warn(
115
+ ` S3 request failed (attempt ${attempt + 1}/${maxRetries + 1}): ${err instanceof Error ? err.message : String(err)}. Retrying in ${Math.round(delay)}ms\u2026`
116
+ );
117
+ await new Promise((resolve) => setTimeout(resolve, delay));
118
+ }
119
+ }
120
+ throw new Error("withS3Retry: unreachable");
121
+ }
122
+ async function downloadWithRetry(store, key, cfg) {
123
+ return withS3Retry(() => store.download(key), cfg);
124
+ }
125
+
70
126
  // src/shared/trimDepth.ts
71
127
  function trimDepth(value, remaining) {
72
128
  if (value === null || value === void 0 || typeof value !== "object") {
@@ -96,6 +152,208 @@ function trimDepth(value, remaining) {
96
152
  return result;
97
153
  }
98
154
 
155
+ // src/shared/lingohub.ts
156
+ var defaultLocales = ["en", "fr", "de", "es", "it", "pt-br", "ru", "zh-hans", "zh-hant", "ko", "ja"];
157
+ var localeMapping = {
158
+ ios: {
159
+ "pt-br": "pt",
160
+ "zh-hans": "zh-Hans",
161
+ "zh-hant": "zh-Hant"
162
+ },
163
+ android: {
164
+ "pt-br": "pt",
165
+ "zh-hans": "zh-Hans-CN",
166
+ "zh-hant": "zh-TW"
167
+ }
168
+ };
169
+ var allProjects = {
170
+ "tandem-(new-website)": [
171
+ {
172
+ fileName: "Website.[locale].json",
173
+ type: "json"
174
+ }
175
+ ],
176
+ "tandem-(website)": [
177
+ {
178
+ fileName: "[locale].json",
179
+ type: "json"
180
+ },
181
+ {
182
+ fileName: "AI.[locale].json",
183
+ type: "json"
184
+ },
185
+ {
186
+ fileName: "languages.[locale].json",
187
+ type: "json"
188
+ }
189
+ ],
190
+ "tandem": [
191
+ {
192
+ fileName: "InfoPlist.[locale].strings",
193
+ type: "strings",
194
+ localeMapping: localeMapping.ios
195
+ },
196
+ {
197
+ fileName: "Localizable.[locale].strings",
198
+ type: "strings",
199
+ localeMapping: localeMapping.ios
200
+ },
201
+ {
202
+ fileName: "MainiPad.[locale].strings",
203
+ type: "strings",
204
+ localeMapping: localeMapping.ios
205
+ },
206
+ {
207
+ fileName: "Main.[locale].strings",
208
+ type: "strings",
209
+ localeMapping: localeMapping.ios
210
+ }
211
+ ],
212
+ "tandem-(android)": [
213
+ {
214
+ fileName: "accessibility_localizable.[locale].xml",
215
+ type: "xml",
216
+ localeMapping: localeMapping.android
217
+ },
218
+ {
219
+ fileName: "call_localizable.[locale].xml",
220
+ type: "xml",
221
+ localeMapping: localeMapping.android
222
+ },
223
+ {
224
+ fileName: "cert_localizable.[locale].xml",
225
+ type: "xml",
226
+ localeMapping: localeMapping.android
227
+ },
228
+ {
229
+ fileName: "chat_localizable.[locale].xml",
230
+ type: "xml",
231
+ localeMapping: localeMapping.android
232
+ },
233
+ {
234
+ fileName: "checklist_localizable.[locale].xml",
235
+ type: "xml",
236
+ localeMapping: localeMapping.android
237
+ },
238
+ {
239
+ fileName: "clubs_localizable.[locale].xml",
240
+ type: "xml",
241
+ localeMapping: localeMapping.android
242
+ },
243
+ {
244
+ fileName: "common_localizable.[locale].xml",
245
+ type: "xml",
246
+ localeMapping: localeMapping.android
247
+ },
248
+ {
249
+ fileName: "community_localizable.[locale].xml",
250
+ type: "xml",
251
+ localeMapping: localeMapping.android
252
+ },
253
+ {
254
+ fileName: "correction_localizable.[locale].xml",
255
+ type: "xml",
256
+ localeMapping: localeMapping.android
257
+ },
258
+ {
259
+ fileName: "country_names.[locale].xml",
260
+ type: "xml",
261
+ localeMapping: localeMapping.android
262
+ },
263
+ {
264
+ fileName: "emoji_localizable.[locale].xml",
265
+ type: "xml",
266
+ localeMapping: localeMapping.android
267
+ },
268
+ {
269
+ fileName: "errors_localizable.[locale].xml",
270
+ type: "xml",
271
+ localeMapping: localeMapping.android
272
+ },
273
+ {
274
+ fileName: "expressions_localizable.[locale].xml",
275
+ type: "xml",
276
+ localeMapping: localeMapping.android
277
+ },
278
+ {
279
+ fileName: "gif_localizable.[locale].xml",
280
+ type: "xml",
281
+ localeMapping: localeMapping.android
282
+ },
283
+ {
284
+ fileName: "guidelines_localizable.[locale].xml",
285
+ type: "xml",
286
+ localeMapping: localeMapping.android
287
+ },
288
+ {
289
+ fileName: "languages_localizable.[locale].xml",
290
+ type: "xml",
291
+ localeMapping: localeMapping.android
292
+ },
293
+ {
294
+ fileName: "localizable.[locale].xml",
295
+ type: "xml",
296
+ localeMapping: localeMapping.android
297
+ },
298
+ {
299
+ fileName: "localizable2.[locale].xml",
300
+ type: "xml",
301
+ localeMapping: localeMapping.android
302
+ },
303
+ {
304
+ fileName: "login_localizable.[locale].xml",
305
+ type: "xml",
306
+ localeMapping: localeMapping.android
307
+ },
308
+ {
309
+ fileName: "myprofile_localizable.[locale].xml",
310
+ type: "xml",
311
+ localeMapping: localeMapping.android
312
+ },
313
+ {
314
+ fileName: "onb_localizable.[locale].xml",
315
+ type: "xml",
316
+ localeMapping: localeMapping.android
317
+ },
318
+ {
319
+ fileName: "parties_localizable.[locale].xml",
320
+ type: "xml",
321
+ localeMapping: localeMapping.android
322
+ },
323
+ {
324
+ fileName: "pro_localizable.[locale].xml",
325
+ type: "xml",
326
+ localeMapping: localeMapping.android
327
+ },
328
+ {
329
+ fileName: "pro_screen_localizable.[locale].xml",
330
+ type: "xml",
331
+ localeMapping: localeMapping.android
332
+ },
333
+ {
334
+ fileName: "push_notification_localizable.[locale].xml",
335
+ type: "xml",
336
+ localeMapping: localeMapping.android
337
+ },
338
+ {
339
+ fileName: "reporting_localizable.[locale].xml",
340
+ type: "xml",
341
+ localeMapping: localeMapping.android
342
+ },
343
+ {
344
+ fileName: "translation_localizable.[locale].xml",
345
+ type: "xml",
346
+ localeMapping: localeMapping.android
347
+ }
348
+ ],
349
+ "tandem-(web-invites)": [
350
+ {
351
+ fileName: "[locale].json",
352
+ type: "json"
353
+ }
354
+ ]
355
+ };
356
+
99
357
  // src/shared/bundles.ts
100
358
  function getAtPath(obj, dottedPath) {
101
359
  const parts = dottedPath.split(".").filter((p) => p.length > 0);
@@ -153,25 +411,62 @@ function setNestedAt(target, dottedPath, value) {
153
411
  }
154
412
  setNestedAt(nested, rest, value);
155
413
  }
156
- async function fetchBundles(store, outputDir, options) {
414
+ async function fetchCmsBundles(store, outputDir, options) {
157
415
  const { cms, contentTypes } = options;
416
+ const retry = options.retry ?? getDefaultS3RetryConfig();
158
417
  await fs.mkdir(outputDir, { recursive: true });
159
418
  const result = {};
160
419
  await Promise.all(
161
420
  contentTypes.map(async (contentType) => {
162
- const key = store.buildLatestKey(cms, contentType);
163
- const data = await store.download(key);
164
- const filePath = path.resolve(
165
- outputDir,
166
- `${cms}-${contentType}.json`
167
- );
421
+ const key = buildCmsObjectKey(cms, contentType);
422
+ const data = await downloadWithRetry(store, key, retry);
423
+ const filePath = path.resolve(outputDir, key);
168
424
  await fs.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
169
425
  result[contentType] = filePath;
170
426
  })
171
427
  );
172
428
  return result;
173
429
  }
174
- async function queryBundle(outputDir, cms, contentType, options = {}) {
430
+ async function fetchTranslationBundles(store, outputDir, options) {
431
+ const { projects, locales } = options;
432
+ const retry = options.retry ?? getDefaultS3RetryConfig();
433
+ await fs.mkdir(outputDir, { recursive: true });
434
+ const result = {};
435
+ const localesToSync = locales && locales.length ? locales : defaultLocales;
436
+ await Promise.all(
437
+ projects.map(async (project) => {
438
+ const resources = allProjects[project];
439
+ if (!resources?.length) {
440
+ return;
441
+ }
442
+ const resourceTasks = [];
443
+ for (const resource of resources) {
444
+ for (const loc of localesToSync) {
445
+ const locale = resource.localeMapping && resource.localeMapping[loc] ? resource.localeMapping[loc] : loc;
446
+ const objectKey = buildTranslationObjectKey(
447
+ project,
448
+ resource.fileName,
449
+ locale
450
+ );
451
+ resourceTasks.push({ objectKey });
452
+ }
453
+ }
454
+ await Promise.all(
455
+ resourceTasks.map(async ({ objectKey }) => {
456
+ const data = await downloadWithRetry(store, objectKey, retry);
457
+ const filePath = path.resolve(outputDir, objectKey);
458
+ await fs.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
459
+ if (!result[project]) {
460
+ result[project] = {};
461
+ }
462
+ result[project][objectKey] = filePath;
463
+ })
464
+ );
465
+ })
466
+ );
467
+ return result;
468
+ }
469
+ async function queryCmsBundle(outputDir, cms, contentType, options = {}) {
175
470
  const filePath = path.resolve(
176
471
  outputDir,
177
472
  `${cms}-${contentType}.json`
@@ -222,21 +517,32 @@ var ContentStoreSDK = class {
222
517
  *
223
518
  * @returns A map of contentType to absolute file path.
224
519
  */
225
- async fetchBundles(options) {
226
- return fetchBundles(this.store, this.outputDir, options);
520
+ async fetchCmsBundles(options) {
521
+ return fetchCmsBundles(this.store, this.outputDir, options);
522
+ }
523
+ /**
524
+ * Downloads translation bundles from S3 and writes them as JSON files
525
+ * to `outputDir`.
526
+ *
527
+ * @returns Per project, a map of S3 object key to absolute file path.
528
+ */
529
+ async fetchTranslationBundles(options) {
530
+ return fetchTranslationBundles(this.store, this.outputDir, options);
227
531
  }
228
532
  /**
229
533
  * Queries a previously fetched bundle from the local filesystem.
230
534
  */
231
- async queryBundle(cms, contentType, options = {}) {
232
- return queryBundle(this.outputDir, cms, contentType, options);
535
+ async queryCmsBundle(cms, contentType, options = {}) {
536
+ return queryCmsBundle(this.outputDir, cms, contentType, options);
233
537
  }
234
538
  };
235
539
  export {
236
540
  ContentStore,
237
541
  ContentStoreSDK,
238
- fetchBundles,
239
- queryBundle,
542
+ fetchCmsBundles,
543
+ fetchTranslationBundles,
544
+ getDefaultS3RetryConfig,
545
+ queryCmsBundle,
240
546
  trimDepth
241
547
  };
242
548
  //# sourceMappingURL=node.js.map
package/dist/node.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/shared/s3.ts","../src/shared/bundles.ts","../src/shared/trimDepth.ts","../src/sdk/client.ts"],"sourcesContent":["import {\n S3Client,\n PutObjectCommand,\n CopyObjectCommand,\n GetObjectCommand,\n} from '@aws-sdk/client-s3';\nimport type { S3Config } from './types';\n\nexport class ContentStore {\n private client: S3Client;\n private bucket: string;\n\n constructor(cfg: S3Config) {\n this.client = new S3Client({\n region: cfg.region,\n credentials: {\n accessKeyId: cfg.accessKeyId,\n secretAccessKey: cfg.secretAccessKey,\n },\n });\n this.bucket = cfg.bucket;\n }\n\n /** {cms}-{contentType}-{timestamp}.json */\n buildVersionedKey(cms: string, contentType: string, timestamp: number): string {\n return `${cms}-${contentType}-${timestamp}.json`;\n }\n\n /** {cms}-{contentType}.json (always points at the latest version) */\n buildLatestKey(cms: string, contentType: string): string {\n return `${cms}-${contentType}.json`;\n }\n\n async upload(key: string, data: unknown): Promise<string> {\n await this.client.send(\n new PutObjectCommand({\n Bucket: this.bucket,\n Key: key,\n Body: JSON.stringify(data, null, 2),\n ContentType: 'application/json',\n }),\n );\n return key;\n }\n\n async download(key: string): Promise<unknown> {\n const response = await this.client.send(\n new GetObjectCommand({ Bucket: this.bucket, Key: key }),\n );\n const body = await response.Body?.transformToString();\n if (!body) throw new Error(`Empty response for key: ${key}`);\n return JSON.parse(body);\n }\n\n /**\n * Copies a versioned object to the \"latest\" key so that it always reflects\n * the most recent sync while older timestamped versions are retained.\n */\n async copyToLatest(\n sourceKey: string,\n cms: string,\n contentType: string,\n ): Promise<string> {\n const latestKey = this.buildLatestKey(cms, contentType);\n await this.client.send(\n new CopyObjectCommand({\n Bucket: this.bucket,\n CopySource: `${this.bucket}/${sourceKey}`,\n Key: latestKey,\n ContentType: 'application/json',\n }),\n );\n return latestKey;\n }\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { CMSProvider } from './types';\nimport { ContentStore } from './s3';\nimport { trimDepth } from './trimDepth';\n\nexport { trimDepth } from './trimDepth';\n\nexport interface BundleInfo {\n [key: string]: string;\n}\n\nexport interface BundleItem {\n [key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n}\n\nexport interface FetchBundlesOptions {\n cms: CMSProvider;\n contentTypes: string[];\n}\n\nexport interface QueryOptions {\n /**\n * Filter items by matching property values (exact equality, or array for IN).\n * Keys may use dot notation for nested paths, e.g. `{ 'meta._id': 'abc' }` matches\n * `item.meta._id`.\n *\n * Contentful-style operators on the path (before `[`):\n * - `{ 'field[exists]': true }` — field is present and non-empty (not null, undefined,\n * `''`, `[]`, or `{}`).\n * - `{ 'field[exists]': false }` — field is missing or empty (same emptiness rules).\n * Nested paths work, e.g. `{ 'blocks.hero[exists]': false }`.\n */\n fields?: Record<string, unknown>;\n /**\n * Properties to include in each result object. Omit to return all properties.\n * Keys may use dot notation; nested segments become nested objects in the result,\n * e.g. `['slug', 'meta._updatedAt']` → `{ slug, meta: { _updatedAt } }`.\n */\n select?: string[];\n /** Maximum number of items to return. */\n limit?: number;\n /**\n * How many levels deep to return.\n * - 1 = the item's own scalar properties only; nested objects/refs are nulled.\n * - 2 = the item including its direct references; refs inside those are nulled.\n * - 3 = three levels deep, and so on.\n * - Omit to return the full depth.\n */\n include?: number;\n}\n\n/** Read a value at a dotted path; returns whether every segment existed. */\nfunction getAtPath(\n obj: unknown,\n dottedPath: string,\n): { found: true; value: unknown } | { found: false } {\n const parts = dottedPath.split('.').filter((p) => p.length > 0);\n if (parts.length === 0) return { found: false };\n\n let cur: unknown = obj;\n for (const p of parts) {\n if (cur === null || typeof cur !== 'object' || Array.isArray(cur)) {\n return { found: false };\n }\n const rec = cur as Record<string, unknown>;\n if (!(p in rec)) return { found: false };\n cur = rec[p];\n }\n return { found: true, value: cur };\n}\n\nconst FIELD_OP_KEY = /^(.+)\\[([^\\]]+)]$/;\n\nfunction parseFieldKey(key: string): { path: string; operator?: string } {\n const m = FIELD_OP_KEY.exec(key);\n if (!m) return { path: key };\n return { path: m[1]!, operator: m[2]! };\n}\n\n/** True when a bundle value counts as “no content” (aligned with typical CMS “empty”). */\nfunction isEmptyValue(value: unknown): boolean {\n if (value === null || value === undefined) return true;\n if (value === '') return true;\n if (Array.isArray(value) && value.length === 0) {\n return true;\n }\n return typeof value === 'object' &&\n !Array.isArray(value) &&\n Object.keys(value).length === 0;\n\n}\n\nfunction matchesFieldFilter(\n item: BundleItem,\n key: string,\n expected: unknown,\n): boolean {\n const { path, operator } = parseFieldKey(key);\n const at = getAtPath(item, path);\n\n if (operator === 'exists') {\n if (expected !== true && expected !== false) return false;\n const empty = !at.found || isEmptyValue(at.value);\n return !expected ? empty : !empty;\n }\n\n const actual = at.found ? at.value : undefined;\n if (Array.isArray(expected)) return expected.includes(actual);\n return actual === expected;\n}\n\n/** Set `value` on `target` at a dotted path, creating plain objects as needed. */\nfunction setNestedAt(\n target: Record<string, unknown>,\n dottedPath: string,\n value: unknown,\n): void {\n const parts = dottedPath.split('.').filter((p) => p.length > 0);\n if (parts.length === 0) return;\n\n if (parts.length === 1) {\n target[parts[0]!] = value;\n return;\n }\n\n const head = parts[0]!;\n const rest = parts.slice(1).join('.');\n let nested = target[head];\n if (\n nested === null ||\n typeof nested !== 'object' ||\n Array.isArray(nested)\n ) {\n nested = {};\n target[head] = nested;\n }\n setNestedAt(nested as Record<string, unknown>, rest, value);\n}\n\n/**\n * Downloads the latest bundles from S3 and writes them as JSON files to `outputDir`.\n *\n * @returns A map of contentType to absolute file path.\n */\nexport async function fetchBundles(\n store: ContentStore,\n outputDir: string,\n options: FetchBundlesOptions,\n): Promise<Record<string, string>> {\n const { cms, contentTypes } = options;\n await fs.mkdir(outputDir, { recursive: true });\n\n const result:BundleInfo = {};\n\n await Promise.all(\n contentTypes.map(async (contentType) => {\n const key = store.buildLatestKey(cms, contentType);\n const data = await store.download(key);\n const filePath = path.resolve(\n outputDir,\n `${cms}-${contentType}.json`,\n );\n await fs.writeFile(filePath, JSON.stringify(data, null, 2), 'utf-8');\n result[contentType] = filePath;\n }),\n );\n\n return result;\n}\n\n/**\n * Queries a previously fetched bundle from the local filesystem.\n */\nexport async function queryBundle(\n outputDir: string,\n cms: CMSProvider,\n contentType: string,\n options: QueryOptions = {},\n): Promise<unknown[]> {\n const filePath = path.resolve(\n outputDir,\n `${cms}-${contentType}.json`,\n );\n const raw = await fs.readFile(filePath, 'utf-8');\n let items:BundleItem[] = JSON.parse(raw) as Record<string, unknown>[];\n\n if (options.fields) {\n const filters = options.fields;\n items = items.filter((item) =>\n Object.entries(filters).every(([key, expected]) =>\n matchesFieldFilter(item, key, expected),\n ),\n );\n }\n\n if (options.limit !== undefined && options.limit > 0) {\n items = items.slice(0, options.limit);\n }\n\n if (options.include !== undefined) {\n items = items.map(\n (item) => trimDepth(item, options.include!) as Record<string, unknown>,\n );\n }\n\n if (options.select?.length) {\n const keys = options.select;\n items = items.map((item) => {\n const picked: Record<string, unknown> = {};\n for (const k of keys) {\n const at = getAtPath(item, k);\n if (at.found) setNestedAt(picked, k, at.value);\n }\n return picked;\n });\n }\n\n return items;\n}\n","/**\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","import type { CMSProvider } from '../shared/types';\nimport { ContentStore } from '../shared/s3';\nimport {\n fetchBundles,\n queryBundle,\n type FetchBundlesOptions,\n type QueryOptions,\n} from '../shared/bundles';\nimport type { SDKConfig } from './client-types';\n\nexport type {\n FetchBundlesOptions,\n QueryOptions,\n BundleInfo,\n BundleItem,\n SDKConfig,\n} from './client-types';\n\nexport class ContentStoreSDK {\n private store: ContentStore;\n private outputDir: string;\n\n constructor(config: SDKConfig) {\n this.store = new ContentStore(config.s3);\n this.outputDir = config.outputDir;\n }\n\n /**\n * Downloads the latest bundles from S3 and writes them as JSON files\n * to `outputDir`.\n *\n * @returns A map of contentType to absolute file path.\n */\n async fetchBundles(\n options: FetchBundlesOptions,\n ): Promise<Record<string, string>> {\n return fetchBundles(this.store, this.outputDir, options);\n }\n\n /**\n * Queries a previously fetched bundle from the local filesystem.\n */\n async queryBundle(\n cms: CMSProvider,\n contentType: string,\n options: QueryOptions = {},\n ): Promise<unknown[]> {\n return queryBundle(this.outputDir, cms, contentType, options);\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,IAAM,eAAN,MAAmB;AAAA,EAChB;AAAA,EACA;AAAA,EAER,YAAY,KAAe;AACzB,SAAK,SAAS,IAAI,SAAS;AAAA,MACzB,QAAQ,IAAI;AAAA,MACZ,aAAa;AAAA,QACX,aAAa,IAAI;AAAA,QACjB,iBAAiB,IAAI;AAAA,MACvB;AAAA,IACF,CAAC;AACD,SAAK,SAAS,IAAI;AAAA,EACpB;AAAA;AAAA,EAGA,kBAAkB,KAAa,aAAqB,WAA2B;AAC7E,WAAO,GAAG,GAAG,IAAI,WAAW,IAAI,SAAS;AAAA,EAC3C;AAAA;AAAA,EAGA,eAAe,KAAa,aAA6B;AACvD,WAAO,GAAG,GAAG,IAAI,WAAW;AAAA,EAC9B;AAAA,EAEA,MAAM,OAAO,KAAa,MAAgC;AACxD,UAAM,KAAK,OAAO;AAAA,MAChB,IAAI,iBAAiB;AAAA,QACnB,QAAQ,KAAK;AAAA,QACb,KAAK;AAAA,QACL,MAAM,KAAK,UAAU,MAAM,MAAM,CAAC;AAAA,QAClC,aAAa;AAAA,MACf,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,SAAS,K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IAAI,aAAa,OAAO,EAAE;AACvC,SAAK,YAAY,OAAO;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,aACJ,SACiC;AACjC,WAAO,aAAa,KAAK,OAAO,KAAK,WAAW,OAAO;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,YACJ,KACA,aACA,UAAwB,CAAC,GACL;AACpB,WAAO,YAAY,KAAK,WAAW,KAAK,aAAa,OAAO;AAAA,EAC9D;AACF;","names":["path"]}
1
+ {"version":3,"sources":["../src/shared/s3.ts","../src/shared/bundles.ts","../src/shared/s3-retry.ts","../src/shared/trimDepth.ts","../src/shared/lingohub.ts","../src/sdk/client.ts"],"sourcesContent":["import {\n S3Client,\n PutObjectCommand,\n GetObjectCommand,\n} from '@aws-sdk/client-s3';\nimport type { S3Config } from './types';\n\nexport class ContentStore {\n private client: S3Client;\n private bucket: string;\n\n constructor(cfg: S3Config) {\n this.client = new S3Client({\n region: cfg.region,\n credentials: {\n accessKeyId: cfg.accessKeyId,\n secretAccessKey: cfg.secretAccessKey,\n },\n });\n this.bucket = cfg.bucket;\n }\n\n async upload(key: string, data: unknown): Promise<string> {\n await this.client.send(\n new PutObjectCommand({\n Bucket: this.bucket,\n Key: key,\n Body: JSON.stringify(data, null, 2),\n ContentType: 'application/json',\n }),\n );\n return key;\n }\n\n async download(key: string): Promise<unknown> {\n const response = await this.client.send(\n new GetObjectCommand({ Bucket: this.bucket, Key: key }),\n );\n const body = await response.Body?.transformToString();\n if (!body) throw new Error(`Empty response for key: ${key}`);\n return JSON.parse(body);\n }\n}\n\n/** {cms}-{contentType}.json (always points at the latest version) */\nexport const buildCmsObjectKey = (cms: string, contentType: string): string => {\n return `${cms}-${contentType}.json`;\n}\n\nexport const buildTranslationObjectKey = (project:string, fileName: string, locale: string): string => {\n return `lingohub-${project}.${fileName.replaceAll('[locale]', locale)}`;\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { CMSProvider } from './types';\nimport { buildCmsObjectKey, buildTranslationObjectKey, ContentStore } from './s3';\nimport {\n downloadWithRetry,\n getDefaultS3RetryConfig,\n type S3RetryConfig,\n} from './s3-retry';\nimport { trimDepth } from './trimDepth';\nimport { allProjects, defaultLocales } from './lingohub';\n\nexport { trimDepth } from './trimDepth';\nexport type { S3RetryConfig } from './s3-retry';\nexport { getDefaultS3RetryConfig } from './s3-retry';\n\nexport interface CmsBundleInfo {\n [key: string]: string;\n}\n\nexport interface TranslationBundleInfo {\n [key: string] : Record<string, string>;\n}\n\nexport interface BundleItem {\n [key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n}\n\nexport interface FetchCmsBundlesOptions {\n cms: CMSProvider;\n contentTypes: string[];\n /** S3 GET retry; defaults via {@link getDefaultS3RetryConfig}. */\n retry?: S3RetryConfig;\n}\n\nexport interface FetchTranslationBundlesOptions {\n projects: string[];\n locales?: string[] | undefined;\n /** S3 GET retry; defaults via {@link getDefaultS3RetryConfig}. */\n retry?: S3RetryConfig;\n}\n\nexport interface QueryOptions {\n /**\n * Filter items by matching property values (exact equality, or array for IN).\n * Keys may use dot notation for nested paths, e.g. `{ 'meta._id': 'abc' }` matches\n * `item.meta._id`.\n *\n * Contentful-style operators on the path (before `[`):\n * - `{ 'field[exists]': true }` — field is present and non-empty (not null, undefined,\n * `''`, `[]`, or `{}`).\n * - `{ 'field[exists]': false }` — field is missing or empty (same emptiness rules).\n * Nested paths work, e.g. `{ 'blocks.hero[exists]': false }`.\n */\n fields?: Record<string, unknown>;\n /**\n * Properties to include in each result object. Omit to return all properties.\n * Keys may use dot notation; nested segments become nested objects in the result,\n * e.g. `['slug', 'meta._updatedAt']` → `{ slug, meta: { _updatedAt } }`.\n */\n select?: string[];\n /** Maximum number of items to return. */\n limit?: number;\n /**\n * How many levels deep to return.\n * - 1 = the item's own scalar properties only; nested objects/refs are nulled.\n * - 2 = the item including its direct references; refs inside those are nulled.\n * - 3 = three levels deep, and so on.\n * - Omit to return the full depth.\n */\n include?: number;\n}\n\n/** Read a value at a dotted path; returns whether every segment existed. */\nfunction getAtPath(\n obj: unknown,\n dottedPath: string,\n): { found: true; value: unknown } | { found: false } {\n const parts = dottedPath.split('.').filter((p) => p.length > 0);\n if (parts.length === 0) return { found: false };\n\n let cur: unknown = obj;\n for (const p of parts) {\n if (cur === null || typeof cur !== 'object' || Array.isArray(cur)) {\n return { found: false };\n }\n const rec = cur as Record<string, unknown>;\n if (!(p in rec)) return { found: false };\n cur = rec[p];\n }\n return { found: true, value: cur };\n}\n\nconst FIELD_OP_KEY = /^(.+)\\[([^\\]]+)]$/;\n\nfunction parseFieldKey(key: string): { path: string; operator?: string } {\n const m = FIELD_OP_KEY.exec(key);\n if (!m) return { path: key };\n return { path: m[1]!, operator: m[2]! };\n}\n\n/** True when a bundle value counts as “no content” (aligned with typical CMS “empty”). */\nfunction isEmptyValue(value: unknown): boolean {\n if (value === null || value === undefined) return true;\n if (value === '') return true;\n if (Array.isArray(value) && value.length === 0) {\n return true;\n }\n return typeof value === 'object' &&\n !Array.isArray(value) &&\n Object.keys(value).length === 0;\n\n}\n\nfunction matchesFieldFilter(\n item: BundleItem,\n key: string,\n expected: unknown,\n): boolean {\n const { path, operator } = parseFieldKey(key);\n const at = getAtPath(item, path);\n\n if (operator === 'exists') {\n if (expected !== true && expected !== false) return false;\n const empty = !at.found || isEmptyValue(at.value);\n return !expected ? empty : !empty;\n }\n\n const actual = at.found ? at.value : undefined;\n if (Array.isArray(expected)) return expected.includes(actual);\n return actual === expected;\n}\n\n/** Set `value` on `target` at a dotted path, creating plain objects as needed. */\nfunction setNestedAt(\n target: Record<string, unknown>,\n dottedPath: string,\n value: unknown,\n): void {\n const parts = dottedPath.split('.').filter((p) => p.length > 0);\n if (parts.length === 0) return;\n\n if (parts.length === 1) {\n target[parts[0]!] = value;\n return;\n }\n\n const head = parts[0]!;\n const rest = parts.slice(1).join('.');\n let nested = target[head];\n if (\n nested === null ||\n typeof nested !== 'object' ||\n Array.isArray(nested)\n ) {\n nested = {};\n target[head] = nested;\n }\n setNestedAt(nested as Record<string, unknown>, rest, value);\n}\n\n/**\n * Downloads the latest CMS bundles from S3 and writes them as JSON files to `outputDir`.\n *\n * @returns A map of contentType to absolute file path.\n */\nexport async function fetchCmsBundles(\n store: ContentStore,\n outputDir: string,\n options: FetchCmsBundlesOptions,\n): Promise<Record<string, string>> {\n const { cms, contentTypes } = options;\n const retry = options.retry ?? getDefaultS3RetryConfig();\n await fs.mkdir(outputDir, { recursive: true });\n\n const result: CmsBundleInfo = {};\n\n await Promise.all(\n contentTypes.map(async (contentType) => {\n const key = buildCmsObjectKey(cms, contentType);\n const data = await downloadWithRetry(store, key, retry);\n const filePath = path.resolve(outputDir, key);\n await fs.writeFile(filePath, JSON.stringify(data, null, 2), 'utf-8');\n result[contentType] = filePath;\n }),\n );\n\n return result;\n}\n\n/**\n * Downloads the latest translation bundles from S3 and writes them as JSON files to `outputDir`.\n *\n * @returns For each project, a map of S3 object key to absolute file path on disk.\n */\nexport async function fetchTranslationBundles(\n store: ContentStore,\n outputDir: string,\n options: FetchTranslationBundlesOptions,\n): Promise<TranslationBundleInfo> {\n const { projects, locales } = options;\n const retry = options.retry ?? getDefaultS3RetryConfig();\n await fs.mkdir(outputDir, { recursive: true });\n\n const result: TranslationBundleInfo = {};\n const localesToSync = locales && locales.length ? locales : defaultLocales;\n\n await Promise.all(\n projects.map(async (project) => {\n const resources = allProjects[project];\n if (!resources?.length) {\n return;\n }\n\n const resourceTasks: { objectKey: string }[] = [];\n for (const resource of resources) {\n for (const loc of localesToSync) {\n const locale =\n resource.localeMapping && resource.localeMapping[loc]\n ? resource.localeMapping[loc]\n : loc;\n const objectKey = buildTranslationObjectKey(\n project,\n resource.fileName,\n locale,\n );\n resourceTasks.push({ objectKey });\n }\n }\n\n await Promise.all(\n resourceTasks.map(async ({ objectKey }) => {\n const data = await downloadWithRetry(store, objectKey, retry);\n const filePath = path.resolve(outputDir, objectKey);\n await fs.writeFile(filePath, JSON.stringify(data, null, 2), 'utf-8');\n if (!result[project]) {\n result[project] = {};\n }\n result[project][objectKey] = filePath;\n }),\n );\n }),\n );\n\n return result;\n}\n\n/**\n * Queries a previously fetched bundle from the local filesystem.\n */\nexport async function queryCmsBundle(\n outputDir: string,\n cms: CMSProvider,\n contentType: string,\n options: QueryOptions = {},\n): Promise<unknown[]> {\n const filePath = path.resolve(\n outputDir,\n `${cms}-${contentType}.json`,\n );\n const raw = await fs.readFile(filePath, 'utf-8');\n let items:BundleItem[] = JSON.parse(raw) as Record<string, unknown>[];\n\n if (options.fields) {\n const filters = options.fields;\n items = items.filter((item) =>\n Object.entries(filters).every(([key, expected]) =>\n matchesFieldFilter(item, key, expected),\n ),\n );\n }\n\n if (options.limit !== undefined && options.limit > 0) {\n items = items.slice(0, options.limit);\n }\n\n if (options.include !== undefined) {\n items = items.map(\n (item) => trimDepth(item, options.include!) as Record<string, unknown>,\n );\n }\n\n if (options.select?.length) {\n const keys = options.select;\n items = items.map((item) => {\n const picked: Record<string, unknown> = {};\n for (const k of keys) {\n const at = getAtPath(item, k);\n if (at.found) setNestedAt(picked, k, at.value);\n }\n return picked;\n });\n }\n\n return items;\n}\n","import type { ContentStore } from './s3';\n\n/** Retry/backoff for S3 reads (aligned with CMS `RetryConfig` shape). */\nexport interface S3RetryConfig {\n maxRetries: number;\n baseDelayMs: number;\n maxDelayMs: number;\n}\n\nfunction computeDelay(\n attempt: number,\n baseDelayMs: number,\n maxDelayMs: number,\n): number {\n const exponential = baseDelayMs * Math.pow(2, attempt);\n const jitter = Math.random() * baseDelayMs;\n return Math.min(exponential + jitter, maxDelayMs);\n}\n\n/**\n * Default S3 download retry policy from env.\n * `S3_RETRY_*` overrides `RETRY_*` when set.\n */\nexport function getDefaultS3RetryConfig(): S3RetryConfig {\n return {\n maxRetries: parseInt(\n process.env.S3_RETRY_MAX_RETRIES ??\n process.env.RETRY_MAX_RETRIES ??\n '5',\n 10,\n ),\n baseDelayMs: parseInt(\n process.env.S3_RETRY_BASE_DELAY_MS ??\n process.env.RETRY_BASE_DELAY_MS ??\n '1000',\n 10,\n ),\n maxDelayMs: parseInt(\n process.env.S3_RETRY_MAX_DELAY_MS ??\n process.env.RETRY_MAX_DELAY_MS ??\n '60000',\n 10,\n ),\n };\n}\n\n/**\n * True when a failed S3 GET may succeed after a short wait (503 Slow Down,\n * transient network, throttling). Never true for definitive client errors (404, etc.).\n */\nexport function isRetryableS3DownloadError(err: unknown): boolean {\n if (err === null || err === undefined) return false;\n\n if (typeof err === 'object') {\n const e = err as {\n name?: string;\n Code?: string;\n $metadata?: { httpStatusCode?: number };\n };\n const status = e.$metadata?.httpStatusCode;\n if (status === 404 || status === 403 || status === 401 || status === 400) {\n return false;\n }\n if (\n status !== undefined &&\n (status === 408 ||\n status === 429 ||\n status === 500 ||\n status === 502 ||\n status === 503 ||\n status === 504)\n ) {\n return true;\n }\n\n const name = e.name ?? '';\n const code = e.Code ?? '';\n if (\n /SlowDown|Throttl|Timeout|TooManyRequests|ServiceUnavailable|InternalError/i.test(\n name,\n ) ||\n /SlowDown|Throttl/i.test(code)\n ) {\n return true;\n }\n }\n\n if (err instanceof Error) {\n const m = err.message;\n if (\n /ECONNRESET|ETIMEDOUT|EPIPE|ECONNREFUSED|socket hang up|getaddrinfo/i.test(\n m,\n )\n ) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Runs `fn` with retries when `isRetryableS3DownloadError` applies; otherwise throws immediately.\n */\nexport async function withS3Retry<T>(\n fn: () => Promise<T>,\n { maxRetries, baseDelayMs, maxDelayMs }: S3RetryConfig,\n): Promise<T> {\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n return await fn();\n } catch (err) {\n if (!isRetryableS3DownloadError(err)) {\n throw err;\n }\n if (attempt === maxRetries) {\n throw err;\n }\n\n const delay = computeDelay(attempt, baseDelayMs, maxDelayMs);\n console.warn(\n ` S3 request failed (attempt ${attempt + 1}/${maxRetries + 1}): ${\n err instanceof Error ? err.message : String(err)\n }. Retrying in ${Math.round(delay)}ms…`,\n );\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n }\n\n throw new Error('withS3Retry: unreachable');\n}\n\nexport async function downloadWithRetry(\n store: ContentStore,\n key: string,\n cfg: S3RetryConfig,\n): Promise<unknown> {\n return withS3Retry(() => store.download(key), cfg);\n}\n","/**\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","export const defaultLocales = ['en', 'fr', 'de', 'es', 'it', 'pt-br', 'ru', 'zh-hans', 'zh-hant', 'ko', 'ja'];\n\nconst localeMapping = {\n ios: {\n 'pt-br': 'pt',\n 'zh-hans': 'zh-Hans',\n 'zh-hant': 'zh-Hant',\n },\n android: {\n 'pt-br': 'pt',\n 'zh-hans': 'zh-Hans-CN',\n 'zh-hant': 'zh-TW',\n },\n};\n\nexport type LingohubResource = {\n fileName: string;\n type: 'json'|'strings'|'xml';\n localeMapping?: Record<string, string>;\n}\n\nexport const allProjects: Record<string, LingohubResource[]> = {\n 'tandem-(new-website)': [\n {\n fileName: 'Website.[locale].json',\n type: 'json'\n }\n ],\n 'tandem-(website)': [\n {\n fileName: '[locale].json',\n type: 'json'\n },\n {\n fileName: 'AI.[locale].json',\n type: 'json'\n },\n {\n fileName: 'languages.[locale].json',\n type: 'json'\n }\n ],\n 'tandem': [\n {\n fileName: 'InfoPlist.[locale].strings',\n type: 'strings',\n localeMapping: localeMapping.ios,\n },\n {\n fileName: 'Localizable.[locale].strings',\n type: 'strings',\n localeMapping: localeMapping.ios,\n },\n {\n fileName: 'MainiPad.[locale].strings',\n type: 'strings',\n localeMapping: localeMapping.ios,\n },\n {\n fileName: 'Main.[locale].strings',\n type: 'strings',\n localeMapping: localeMapping.ios,\n }\n ],\n 'tandem-(android)': [\n {\n fileName: 'accessibility_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'call_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'cert_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'chat_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'checklist_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'clubs_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'common_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'community_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'correction_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'country_names.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'emoji_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'errors_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'expressions_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'gif_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'guidelines_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'languages_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'localizable2.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'login_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'myprofile_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'onb_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'parties_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'pro_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'pro_screen_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'push_notification_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'reporting_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n fileName: 'translation_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n }\n\n ],\n 'tandem-(web-invites)': [\n {\n fileName: '[locale].json',\n type: 'json'\n }\n ]\n};\n","import type { CMSProvider } from '../shared/types';\nimport { ContentStore } from '../shared/s3';\nimport {\n fetchCmsBundles,\n fetchTranslationBundles,\n queryCmsBundle,\n type FetchCmsBundlesOptions,\n type FetchTranslationBundlesOptions,\n type QueryOptions,\n type TranslationBundleInfo,\n} from '../shared/bundles';\nimport type { SDKConfig } from './client-types';\n\nexport type {\n FetchCmsBundlesOptions,\n FetchTranslationBundlesOptions,\n QueryOptions,\n CmsBundleInfo,\n TranslationBundleInfo,\n BundleItem,\n SDKConfig,\n S3RetryConfig,\n} from './client-types';\nexport { getDefaultS3RetryConfig } from './client-types';\n\nexport class ContentStoreSDK {\n private store: ContentStore;\n private outputDir: string;\n\n constructor(config: SDKConfig) {\n this.store = new ContentStore(config.s3);\n this.outputDir = config.outputDir;\n }\n\n /**\n * Downloads the latest bundles from S3 and writes them as JSON files\n * to `outputDir`.\n *\n * @returns A map of contentType to absolute file path.\n */\n async fetchCmsBundles(\n options: FetchCmsBundlesOptions,\n ): Promise<Record<string, string>> {\n return fetchCmsBundles(this.store, this.outputDir, options);\n }\n\n /**\n * Downloads translation bundles from S3 and writes them as JSON files\n * to `outputDir`.\n *\n * @returns Per project, a map of S3 object key to absolute file path.\n */\n async fetchTranslationBundles(\n options: FetchTranslationBundlesOptions,\n ): Promise<TranslationBundleInfo> {\n return fetchTranslationBundles(this.store, this.outputDir, options);\n }\n\n /**\n * Queries a previously fetched bundle from the local filesystem.\n */\n async queryCmsBundle(\n cms: CMSProvider,\n contentType: string,\n options: QueryOptions = {},\n ): Promise<unknown[]> {\n return queryCmsBundle(this.outputDir, cms, contentType, options);\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,IAAM,eAAN,MAAmB;AAAA,EAChB;AAAA,EACA;AAAA,EAER,YAAY,KAAe;AACzB,SAAK,SAAS,IAAI,SAAS;AAAA,MACzB,QAAQ,IAAI;AAAA,MACZ,aAAa;AAAA,QACX,aAAa,IAAI;AAAA,QACjB,iBAAiB,IAAI;AAAA,MACvB;AAAA,IACF,CAAC;AACD,SAAK,SAAS,IAAI;AAAA,EACpB;AAAA,EAEA,MAAM,OAAO,KAAa,MAAgC;AACxD,UAAM,KAAK,OAAO;AAAA,MAChB,IAAI,iBAAiB;AAAA,QACnB,QAAQ,KAAK;AAAA,QACb,KAAK;AAAA,QACL,MAAM,KAAK,UAAU,MAAM,MAAM,CAAC;AAAA,QAClC,aAAa;AAAA,M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B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,gBACJ,SACiC;AACjC,WAAO,gBAAgB,KAAK,OAAO,KAAK,WAAW,OAAO;AAAA,EAC5D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,wBACJ,SACgC;AAChC,WAAO,wBAAwB,KAAK,OAAO,KAAK,WAAW,OAAO;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,eACJ,KACA,aACA,UAAwB,CAAC,GACL;AACpB,WAAO,eAAe,KAAK,WAAW,KAAK,aAAa,OAAO;AAAA,EACjE;AACF;","names":["path"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tandem-language-exchange/content-store",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -33,7 +33,8 @@
33
33
  "dist/chunk-*"
34
34
  ],
35
35
  "bin": {
36
- "fetch-content-bundles": "dist/client/fetch-bundles.js"
36
+ "fetch-content-bundles": "dist/client/fetch-content-bundles.js",
37
+ "fetch-translation-bundles": "dist/client/fetch-translation-bundles.js"
37
38
  },
38
39
  "engines": {
39
40
  "npm": "^11.3.0",
@@ -41,31 +42,42 @@
41
42
  },
42
43
  "scripts": {
43
44
  "build": "tsup",
45
+ "build:docker": "docker build --build-arg LOCAL_BUILD=true -f ./deploy/Dockerfile -t web-content-store .",
44
46
  "dev": "tsx watch src/server/cli.ts serve",
45
47
  "start": "node dist/server/cli.js serve",
46
- "sync": "tsx src/server/cli.ts sync",
47
- "sync-appconfig:staging": "sync-appconfig env=staging project=content-store",
48
- "sync-appconfig:production": "sync-appconfig env=production project=content-store",
49
- "sync-appconfig:local": "sync-appconfig env=local project=content-store",
50
- "sync:contentful": "tsx src/server/cli.ts sync --cms contentful",
51
- "sync:sanity": "tsx src/server/cli.ts sync --cms sanity",
52
- "fetch": "tsx src/server/cli.ts fetch",
53
- "query": "tsx src/server/cli.ts query",
48
+ "sync-appconfig:staging": "sync-appconfig env=staging project=web-content-store",
49
+ "sync-appconfig:production": "sync-appconfig env=production project=web-content-store",
50
+ "sync-appconfig:local": "sync-appconfig env=local project=web-content-store",
51
+ "sync:contentful": "tsx src/server/cli.ts sync-cms-content --cms contentful",
52
+ "sync:sanity": "tsx src/server/cli.ts sync-cms-content --cms sanity",
53
+ "sync:translations": "tsx src/server/cli.ts sync-translations",
54
+ "fetch:cms": "tsx src/client/cli.ts fetch-cms",
55
+ "fetch:translations": "tsx src/client/cli.ts fetch-translations",
56
+ "query:cms": "tsx src/client/cli.ts query-cms",
54
57
  "lint": "eslint .",
55
58
  "lint:fix": "eslint --fix ."
56
59
  },
57
60
  "dependencies": {
58
61
  "@aws-sdk/client-s3": "^3.700.0",
59
62
  "@sanity/client": "^7.20.0",
63
+ "@slack/bolt": "^4.7.0",
60
64
  "commander": "^13.1.0",
61
65
  "contentful": "11.10.3",
62
66
  "dotenv": "16.4.5",
67
+ "eslint": "^10.2.0",
63
68
  "express": "^5.1.0",
64
- "nodemon": "^3.1.14"
69
+ "globals": "^17.4.0",
70
+ "lodash.merge": "^4.6.2",
71
+ "lodash.set": "^4.3.2",
72
+ "nodemon": "^3.1.14",
73
+ "typescript-eslint": "^8.58.1",
74
+ "xml-js": "^1.6.11"
65
75
  },
66
76
  "devDependencies": {
67
77
  "@tandem-web/web-azure-appconfig-sync": "1.0.9",
68
78
  "@types/express": "^5.0.2",
79
+ "@types/lodash.merge": "^4.6.9",
80
+ "@types/lodash.set": "^4.3.9",
69
81
  "@types/node": "22.0.0",
70
82
  "tsup": "^8.5.1",
71
83
  "tsx": "^4.19.0",