@tandem-language-exchange/content-store 1.3.6 → 1.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  allProjects,
13
13
  defaultLocales
14
- } from "./chunk-TMR6VJBQ.js";
14
+ } from "./chunk-GGZIMFPD.js";
15
15
 
16
16
  // src/server/adapters/azure/types.ts
17
17
  var AZURE_DEVOPS_PROJECT_KEYS = [
@@ -396,8 +396,9 @@ var config2 = {
396
396
  spaceId: process.env.CONTENTFUL_SPACE_ID ?? "",
397
397
  accessToken: process.env.CONTENTFUL_WEBSITE_TOKEN ?? "",
398
398
  host: process.env.CONTENTFUL_HOST ?? "preview.contentful.com",
399
- batchSize: 1e3,
399
+ batchSize: parseInt(process.env.CONTENTFUL_BATCH_SIZE ?? "200", 10),
400
400
  maxDepth: 4,
401
+ includeLevels: parseInt(process.env.CONTENTFUL_INCLUDE_LEVELS ?? "4", 10),
401
402
  contentTypes: [
402
403
  "asset",
403
404
  "page",
@@ -701,6 +702,7 @@ var ContentfulAdapter = class {
701
702
  client;
702
703
  batchSize;
703
704
  maxDepth;
705
+ includeLevels;
704
706
  allowedTypes;
705
707
  retryConfig;
706
708
  apiUsage;
@@ -712,6 +714,7 @@ var ContentfulAdapter = class {
712
714
  });
713
715
  this.batchSize = cfg2.batchSize;
714
716
  this.maxDepth = cfg2.maxDepth;
717
+ this.includeLevels = cfg2.includeLevels;
715
718
  this.allowedTypes = cfg2.contentTypes;
716
719
  this.retryConfig = retryConfig;
717
720
  this.apiUsage = new ContentfulApiUsageTracker(cfg2.host);
@@ -740,7 +743,7 @@ var ContentfulAdapter = class {
740
743
  *
741
744
  * The reserved content type `"asset"` fetches from `getAssets()` instead.
742
745
  */
743
- async fetchAll(contentType, includeLevels = 4) {
746
+ async fetchAll(contentType, includeLevels = this.includeLevels) {
744
747
  if (contentType === "asset") {
745
748
  return this.fetchAllAssets();
746
749
  }
@@ -944,9 +947,7 @@ async function syncTranslations(projects, locales) {
944
947
  const entries = [];
945
948
  const errors = [];
946
949
  const timestamp = Math.floor(Date.now() / 1e3);
947
- if (!locales) {
948
- locales = defaultLocales;
949
- }
950
+ const requestedLocales = locales && locales.length ? locales : null;
950
951
  if (!projects) {
951
952
  projects = Object.keys(allProjects);
952
953
  }
@@ -957,7 +958,7 @@ async function syncTranslations(projects, locales) {
957
958
  continue;
958
959
  }
959
960
  for (const resource of resources) {
960
- const resourceLocales = resource.locales ? locales.filter((l) => resource.locales.includes(l)) : locales;
961
+ const resourceLocales = resource.locales ? requestedLocales ? requestedLocales.filter((l) => resource.locales.includes(l)) : resource.locales : requestedLocales ?? defaultLocales;
961
962
  for (const loc of resourceLocales) {
962
963
  const locale = resource.localeMapping && resource.localeMapping[loc] ? resource.localeMapping[loc] : loc;
963
964
  try {
@@ -1013,4 +1014,4 @@ export {
1013
1014
  syncCmsContent,
1014
1015
  syncTranslations
1015
1016
  };
1016
- //# sourceMappingURL=chunk-WJDMWZOX.js.map
1017
+ //# sourceMappingURL=chunk-CAC2DUWN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/adapters/azure/types.ts","../src/server/adapters/azure/client.ts","../src/server/adapters/azure/pipelines.ts","../src/server/adapters/azure/environment.ts","../src/server/config.ts","../src/server/restrictedCron.ts","../src/shared/content-refresh.ts","../src/server/content-refresh-notify.ts","../src/server/adapters/contentful-api-usage.ts","../src/server/adapters/contentful.ts","../src/server/sync/retry.ts","../src/server/adapters/sanity.ts","../src/server/adapters/index.ts","../src/server/adapters/lingohub.ts","../src/server/sync/engine.ts"],"sourcesContent":["import type { AzurePipelineEnvironment } from './environment';\n\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\n\n/** Azure DevOps project name (e.g. `web-site`, `web-app`). */\nexport type AzureDevOpsProjectKey = 'web-site' | 'web-app' | 'web-invites';\n\nexport const AZURE_DEVOPS_PROJECT_KEYS: AzureDevOpsProjectKey[] = [\n 'web-site',\n 'web-app',\n 'web-invites',\n];\n\nexport interface AzurePipelineDefinition {\n id: number;\n refName: string;\n}\n\n/** Pipeline for this content-store instance (one id/ref per ADO project). */\nexport interface AzureProjectConfig {\n pipeline: AzurePipelineDefinition;\n}\n\n/** Credentials and per-project pipeline map for this deployment. */\nexport interface AzureDevOpsConfig {\n organization: string;\n /** Personal access token with pipeline run permissions. */\n pat: string;\n apiVersion: string;\n /** Default when Slack command omits the project argument. */\n defaultProject: AzureDevOpsProjectKey;\n /** Raw `ENVIRONMENT` on this instance (e.g. beta, live). */\n instanceEnvironment: string;\n /** Normalized for Azure (staging | production). */\n pipelineEnvironment: AzurePipelineEnvironment;\n projects: Record<AzureDevOpsProjectKey, AzureProjectConfig>;\n}\n\n/** Connection settings for a single ADO project (used by the HTTP client). */\nexport interface AzureDevOpsClientConfig {\n organization: string;\n project: string;\n pat: string;\n apiVersion: string;\n}\n\nexport interface AzureRequestOptions {\n method?: HttpMethod;\n /**\n * Path under the project, e.g. `/_apis/pipelines/281/runs`.\n * If it starts with `http://` or `https://`, it is used as the full URL.\n */\n path: string;\n query?: Record<string, string | number | boolean | undefined>;\n body?: unknown;\n /** Overrides the default api-version query parameter. */\n apiVersion?: string;\n headers?: Record<string, string>;\n}\n\nexport interface AzureApiErrorBody {\n message?: string;\n typeKey?: string;\n}\n\n/** Subset of the Azure Pipelines run object returned by the Runs API. */\nexport interface PipelineRunResponse {\n id: number;\n name?: string;\n state?: string;\n url?: string;\n createdDate?: string;\n _links?: {\n web?: { href?: string };\n pipeline?: { href?: string };\n };\n}\n\nexport interface TriggerPipelineRunResult {\n project: AzureDevOpsProjectKey;\n instanceEnvironment: string;\n pipelineEnvironment: AzurePipelineEnvironment;\n pipelineId: number;\n refName: string;\n run: PipelineRunResponse;\n}\n","import type {\n AzureApiErrorBody,\n AzureDevOpsClientConfig,\n AzureRequestOptions,\n HttpMethod,\n} from './types';\n\nexport class AzureDevOpsClient {\n private readonly baseUrl: string;\n\n constructor(private readonly config: AzureDevOpsClientConfig) {\n const org = config.organization.replace(/^\\/+|\\/+$/g, '');\n const project = encodeURIComponent(config.project);\n this.baseUrl = `https://dev.azure.com/${org}/${project}`;\n }\n\n /**\n * Call any Azure DevOps REST endpoint under the configured organization and project.\n */\n async request<T>(options: AzureRequestOptions): Promise<T> {\n const {\n method = 'GET',\n path,\n query = {},\n body,\n apiVersion = this.config.apiVersion,\n headers: extraHeaders = {},\n } = options;\n\n if (!this.config.pat) {\n throw new Error(\n 'Azure DevOps is not configured (set AZURE_DEVOPS_ACCESS_TOKEN)',\n );\n }\n\n const url = this.buildUrl(path, { ...query, 'api-version': apiVersion });\n const headers: Record<string, string> = {\n Authorization: this.basicAuthHeader(),\n Accept: 'application/json',\n ...extraHeaders,\n };\n\n const init: RequestInit = { method, headers };\n if (body !== undefined) {\n headers['Content-Type'] = 'application/json';\n init.body = JSON.stringify(body);\n }\n\n const response = await fetch(url, init);\n const text = await response.text();\n let parsed: unknown;\n if (text) {\n try {\n parsed = JSON.parse(text) as unknown;\n } catch {\n parsed = text;\n }\n }\n\n if (!response.ok) {\n const errBody = parsed as AzureApiErrorBody | undefined;\n const detail =\n errBody?.message ??\n (typeof parsed === 'string' ? parsed : JSON.stringify(parsed));\n throw new Error(\n `Azure DevOps ${method} ${path} failed (${response.status}): ${detail}`,\n );\n }\n\n return parsed as T;\n }\n\n private buildUrl(\n path: string,\n query: Record<string, string | number | boolean | undefined>,\n ): string {\n const base = /^https?:\\/\\//i.test(path) ? path : `${this.baseUrl}${path}`;\n const url = new URL(base);\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) {\n url.searchParams.set(key, String(value));\n }\n }\n return url.toString();\n }\n\n private basicAuthHeader(): string {\n const encoded = Buffer.from(`:${this.config.pat}`).toString('base64');\n return `Basic ${encoded}`;\n }\n}\n\nexport function createAzureDevOpsClient(\n config: AzureDevOpsClientConfig,\n): AzureDevOpsClient {\n return new AzureDevOpsClient(config);\n}\n\nexport type { HttpMethod };\n","import { createAzureDevOpsClient } from './client';\nimport type {\n AzureDevOpsConfig,\n AzureDevOpsProjectKey,\n PipelineRunResponse,\n TriggerPipelineRunResult,\n} from './types';\nimport { AZURE_DEVOPS_PROJECT_KEYS } from './types';\n\nexport function isAzureDevOpsProjectKey(value: string): value is AzureDevOpsProjectKey {\n return (AZURE_DEVOPS_PROJECT_KEYS as string[]).includes(value);\n}\n\nfunction resolveProjectConfig(\n azureConfig: AzureDevOpsConfig,\n project: AzureDevOpsProjectKey,\n) {\n const projectConfig = azureConfig.projects[project];\n if (!projectConfig) {\n throw new Error(`Unknown Azure DevOps project \"${project}\"`);\n }\n return projectConfig;\n}\n\n/**\n * Queue a pipeline run for the given ADO project using this instance's configured pipeline id/ref.\n */\nexport async function triggerPipelineBuild(\n azureConfig: AzureDevOpsConfig,\n project: AzureDevOpsProjectKey,\n variables: Record<string, string> = {},\n): Promise<TriggerPipelineRunResult> {\n const { pipeline } = resolveProjectConfig(azureConfig, project);\n if (!pipeline?.id) {\n throw new Error(\n `No pipeline id configured for project \"${project}\" ` +\n `(instance ENVIRONMENT=${azureConfig.instanceEnvironment}, ` +\n `Azure=${azureConfig.pipelineEnvironment})`,\n );\n }\n\n const client = createAzureDevOpsClient({\n organization: azureConfig.organization,\n project,\n pat: azureConfig.pat,\n apiVersion: azureConfig.apiVersion,\n });\n\n const run = await client.request<PipelineRunResponse>({\n method: 'POST',\n path: `/_apis/pipelines/${pipeline.id}/runs`,\n body: {\n resources: {\n repositories: {\n self: {\n refName: pipeline.refName,\n },\n },\n },\n variables,\n },\n });\n\n return {\n project,\n instanceEnvironment: azureConfig.instanceEnvironment,\n pipelineEnvironment: azureConfig.pipelineEnvironment,\n pipelineId: pipeline.id,\n refName: pipeline.refName,\n run,\n };\n}\n\nexport function formatPipelineRunSummary(result: TriggerPipelineRunResult): string {\n const {\n run,\n project,\n instanceEnvironment,\n pipelineEnvironment,\n pipelineId,\n refName,\n } = result;\n const webUrl = run._links?.web?.href ?? run.url;\n const envLabel =\n instanceEnvironment === pipelineEnvironment\n ? `\\`${pipelineEnvironment}\\``\n : `\\`${instanceEnvironment}\\` → Azure \\`${pipelineEnvironment}\\``;\n const lines = [\n `Environment ${envLabel} — project \\`${project}\\`, pipeline id \\`${pipelineId}\\`, ref \\`${refName}\\``,\n `Run #${run.id}${run.state ? ` — state: \\`${run.state}\\`` : ''}`,\n ];\n if (webUrl) {\n lines.push(`<${webUrl}|Open run in Azure DevOps>`);\n }\n return lines.join('\\n');\n}\n","/**\n * Azure Pipelines only use staging / production naming.\n * Map AWS / shared `ENVIRONMENT` values (beta, live, …) at the adapter boundary.\n */\nexport type AzurePipelineEnvironment = 'staging' | 'production';\n\nconst PRODUCTION_ALIASES = new Set(['production', 'live', 'prod']);\nconst STAGING_ALIASES = new Set(['staging', 'beta', 'development', 'dev', 'local']);\n\n/**\n * Normalize any instance `ENVIRONMENT` value to Azure's staging | production.\n * Unknown values default to staging and log a warning (avoids queuing production by mistake).\n */\nexport function normalizeToAzureEnvironment(\n instanceEnvironment: string,\n): AzurePipelineEnvironment {\n const key = instanceEnvironment.trim().toLowerCase();\n if (!key) {\n console.warn(\n '[azure] Empty ENVIRONMENT; defaulting Azure pipeline environment to staging',\n );\n return 'staging';\n }\n if (PRODUCTION_ALIASES.has(key)) {\n return 'production';\n }\n if (STAGING_ALIASES.has(key)) {\n return 'staging';\n }\n console.warn(\n `[azure] Unrecognized ENVIRONMENT=\"${instanceEnvironment}\"; defaulting Azure pipeline environment to staging`,\n );\n return 'staging';\n}\n\n/** Git ref queued for the pipeline run (always derived from the Azure environment). */\nexport function pipelineRefForAzure(\n pipelineEnvironment: AzurePipelineEnvironment,\n): string {\n return `refs/heads/${pipelineEnvironment}`;\n}\n","import dotenv from 'dotenv';\nimport type { S3Config, CMSProvider } from '../shared/types';\nimport { SharedConfig, config as sharedConfig } from '../shared/config';\nimport type { AzureDevOpsConfig, AzureDevOpsProjectKey } from './adapters/azure';\nimport {\n AZURE_DEVOPS_PROJECT_KEYS,\n normalizeToAzureEnvironment,\n pipelineRefForAzure,\n} from './adapters/azure';\nimport type { AzurePipelineEnvironment } from './adapters/azure';\nimport type { ContentRefreshNotifyConfig } from './content-refresh-notify';\nimport { isContentRefreshEnabledForInstance } from './content-refresh-notify';\nimport { validateScheduleCronExpression } from './restrictedCron';\n\ndotenv.config({ path: '.env.local' });\ndotenv.config();\n\nexport type { CMSProvider, S3Config };\n\nexport interface ContentfulConfig {\n spaceId: string;\n accessToken: string;\n host: string;\n /** Number of entries fetched per API page. Keep low when includeLevels > 0 to avoid the 7 MB response cap. */\n batchSize: number;\n /** Content types to sync. When empty, all content types in the space are synced. */\n contentTypes: string[];\n /** Max nesting depth when unwrapping resolved entries. Deeper references are dropped. */\n maxDepth: number;\n /** Contentful `include` depth — how many levels of linked entries are pre-resolved per page (0–10). Higher values increase response size significantly. */\n includeLevels: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;\n}\n\nexport interface SanityConfig {\n projectId: string;\n dataset: string;\n token: string;\n apiVersion: string;\n}\n\nexport interface LingohubConfig {\n authToken: string;\n workspace: string;\n}\n\nexport interface RetryConfig {\n maxRetries: number;\n baseDelayMs: number;\n maxDelayMs: number;\n}\n\nexport interface RestApiConfig {\n port: number;\n apiToken: string;\n}\n\n/** Background schedule (same behaviour as `content-store sync` in the CLI). */\nexport interface ScheduledCmsJobConfig {\n enabled: boolean;\n /** Two-field cron: minute then hour only. Example: `30 3` or a minute step with star in the hour field. Empty when disabled. */\n cronExpression: string;\n /** When true, run once when the server starts, then on the cron wall clock. */\n runOnStart: boolean;\n syncCms?: CMSProvider;\n syncTypes?: string[];\n}\n\nexport interface ScheduledTranslationJobConfig {\n enabled: boolean;\n cronExpression: string;\n runOnStart: boolean;\n syncProjects?: string[];\n}\n\nfunction readScheduleCronEnv(): {\n scheduleCron: string;\n cmsCronRaw: string;\n translationCronRaw: string;\n} {\n return {\n scheduleCron: (process.env.SCHEDULE_CRON ?? '').trim(),\n cmsCronRaw: (process.env.SCHEDULE_CMS_CRON ?? '').trim(),\n translationCronRaw: (process.env.SCHEDULE_TRANSLATION_CRON ?? '').trim(),\n };\n}\n\nfunction resolveScheduleCron(\n jobSpecific: string,\n globalCron: string,\n jobLabel: string,\n): string | null {\n const raw = jobSpecific || globalCron;\n if (!raw) return null;\n try {\n return validateScheduleCronExpression(raw);\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n console.error(`[config] Invalid ${jobLabel} schedule cron: ${msg}`);\n return null;\n }\n}\n\nfunction parseScheduledCmsJobConfig(): ScheduledCmsJobConfig {\n const { scheduleCron, cmsCronRaw } = readScheduleCronEnv();\n const runOnStart =\n (process.env.SCHEDULE_RUN_ON_START ?? 'true').toLowerCase() !== 'false';\n const syncCms = (process.env.SCHEDULE_SYNC_CMS ?? '').trim() as CMSProvider;\n const rawTypes = process.env.SCHEDULE_SYNC_CONTENT_TYPES?.trim();\n const syncTypes = rawTypes\n ? rawTypes.split(',').map((s) => s.trim()).filter(Boolean)\n : undefined;\n\n const resolved = resolveScheduleCron(cmsCronRaw, scheduleCron, 'CMS');\n const cmsOk =\n !!syncCms && (syncCms === 'contentful' || syncCms === 'sanity');\n if (resolved !== null && !cmsOk) {\n console.warn(\n '[config] CMS schedule cron is set but SCHEDULE_SYNC_CMS is missing or not \"contentful\"|\"sanity\"; scheduled CMS sync is disabled.',\n );\n }\n const enabled = resolved !== null && cmsOk;\n\n return {\n enabled,\n cronExpression: resolved ?? '',\n runOnStart,\n syncCms: syncCms || undefined,\n syncTypes,\n };\n}\n\nfunction parseScheduledTranslationJobConfig(): ScheduledTranslationJobConfig {\n const { scheduleCron, translationCronRaw } = readScheduleCronEnv();\n const runOnStart =\n (process.env.SCHEDULE_RUN_ON_START ?? 'true').toLowerCase() !== 'false';\n const rawProjects = process.env.SCHEDULE_SYNC_TRANSLATION_PROJECTS?.trim();\n const syncProjects = rawProjects\n ? rawProjects.split(',').map((s) => s.trim()).filter(Boolean)\n : undefined;\n\n const resolved = resolveScheduleCron(\n translationCronRaw,\n scheduleCron,\n 'translation',\n );\n const enabled = resolved !== null;\n\n return {\n enabled,\n cronExpression: resolved ?? '',\n runOnStart,\n syncProjects,\n };\n}\n\nexport interface SlackConfig {\n enabled: boolean;\n botToken: string;\n signingSecret: string;\n /** Socket Mode app-level token (xapp-…). Required when enabled. */\n appToken: string;\n /** Channel ID or name for async notifications (e.g. sync results). */\n notifyChannel: string;\n /** Slash command name for CMS sync (default `/sync-content`). */\n cmdSyncContent: string;\n /** Slash command name for translation sync (default `/sync-translations`). */\n cmdSyncTranslations: string;\n /** Slash command to queue an Azure Pipelines run (default `/trigger-pipeline`). */\n cmdTriggerBuild: string;\n}\n\nfunction projectEnvSlug(project: AzureDevOpsProjectKey): string {\n return project.toUpperCase().replace(/-/g, '_');\n}\n\nfunction readProjectPipeline(\n project: AzureDevOpsProjectKey,\n pipelineEnvironment: AzurePipelineEnvironment,\n): { id: number; refName: string } {\n const slug = projectEnvSlug(project);\n const id = parseInt(process.env[`AZURE_${slug}_PIPELINE_ID`]?.trim() ?? '0', 10);\n return { id, refName: pipelineRefForAzure(pipelineEnvironment) };\n}\n\nfunction parseAzureDevOpsConfig(\n instanceEnvironment: string,\n): AzureDevOpsConfig & { enabled: boolean } {\n const pipelineEnvironment = normalizeToAzureEnvironment(instanceEnvironment);\n const pat = process.env.AZURE_DEVOPS_ACCESS_TOKEN?.trim() ?? '';\n\n const defaultProjectRaw = (\n process.env.AZURE_DEVOPS_DEFAULT_PROJECT ?? 'web-site'\n ).trim() as AzureDevOpsProjectKey;\n\n const defaultProject = (AZURE_DEVOPS_PROJECT_KEYS as string[]).includes(\n defaultProjectRaw,\n )\n ? defaultProjectRaw\n : 'web-site';\n\n const projects = Object.fromEntries(\n AZURE_DEVOPS_PROJECT_KEYS.map((project) => [\n project,\n { pipeline: readProjectPipeline(project, pipelineEnvironment) },\n ]),\n ) as AzureDevOpsConfig['projects'];\n\n return {\n enabled: pat.length > 0,\n organization: process.env.AZURE_DEVOPS_ORGANIZATION?.trim() || 'tripod-technology',\n pat,\n apiVersion: process.env.AZURE_DEVOPS_API_VERSION?.trim() || '7.1',\n defaultProject,\n instanceEnvironment,\n pipelineEnvironment,\n projects,\n };\n}\n\nfunction readContentRefreshUrl(project: AzureDevOpsProjectKey): string | undefined {\n const slug = projectEnvSlug(project);\n return process.env[`CONTENT_REFRESH_${slug}_URL`]?.trim() || undefined;\n}\n\nfunction parseContentRefreshConfig(\n instanceEnvironment: string,\n): ContentRefreshNotifyConfig {\n const targets = Object.fromEntries(\n AZURE_DEVOPS_PROJECT_KEYS.map((project) => [\n project,\n { url: readContentRefreshUrl(project) },\n ]),\n ) as ContentRefreshNotifyConfig['targets'];\n\n return {\n enabled: isContentRefreshEnabledForInstance(instanceEnvironment),\n basicAuth: process.env.CONTENT_REFRESH_BASIC_AUTH?.trim() ?? '',\n targets,\n };\n}\n\nexport interface ServerConfig {\n contentful: ContentfulConfig;\n sanity: SanityConfig;\n lingohub: LingohubConfig;\n retry: RetryConfig;\n api: RestApiConfig;\n scheduledCmsJob: ScheduledCmsJobConfig;\n scheduledTranslationJob: ScheduledTranslationJobConfig;\n azure: AzureDevOpsConfig & { enabled: boolean };\n contentRefresh: ContentRefreshNotifyConfig;\n slack: SlackConfig;\n}\n\nexport const config: ServerConfig & SharedConfig = {\n ...sharedConfig,\n contentful: {\n spaceId: process.env.CONTENTFUL_SPACE_ID ?? '',\n accessToken: process.env.CONTENTFUL_WEBSITE_TOKEN ?? '',\n host: process.env.CONTENTFUL_HOST ?? 'preview.contentful.com',\n batchSize: parseInt(process.env.CONTENTFUL_BATCH_SIZE ?? '200', 10),\n maxDepth: 4,\n includeLevels: (parseInt(process.env.CONTENTFUL_INCLUDE_LEVELS ?? '4', 10) as ContentfulConfig['includeLevels']),\n contentTypes: [\n 'asset','page','longtailPage','customJson','banner','cookieBanner','downloadPage'\n // Add Contentful content type IDs here to limit sync scope.\n ],\n },\n\n sanity: {\n projectId: process.env.SANITY_PROJECT_ID ?? '',\n dataset: process.env.SANITY_DATASET ?? 'main',\n token: process.env.SANITY_API_TOKEN ?? '',\n apiVersion: '2024-01-01',\n },\n\n lingohub: {\n authToken : process.env.LINGOHUB_AUTH_TOKEN ?? '',\n workspace: process.env.LINGOHUB_WORKSPACE ?? '',\n },\n\n retry: {\n maxRetries: parseInt(process.env.RETRY_MAX_RETRIES ?? '5', 10),\n baseDelayMs: parseInt(process.env.RETRY_BASE_DELAY_MS ?? '1000', 10),\n maxDelayMs: parseInt(process.env.RETRY_MAX_DELAY_MS ?? '60000', 10),\n },\n\n api: {\n port: parseInt(process.env.PORT ?? '3030', 10),\n apiToken: process.env.CONTENT_STORE_API_TOKEN ?? '',\n },\n\n scheduledCmsJob: parseScheduledCmsJobConfig(),\n scheduledTranslationJob: parseScheduledTranslationJobConfig(),\n\n azure: parseAzureDevOpsConfig(sharedConfig.environment),\n\n contentRefresh: parseContentRefreshConfig(sharedConfig.environment),\n\n slack: {\n enabled: (process.env.SLACK_BOT_TOKEN ?? '').length > 0,\n botToken: process.env.SLACK_BOT_TOKEN ?? '',\n signingSecret: process.env.SLACK_SIGNING_SECRET ?? '',\n appToken: process.env.SLACK_APP_TOKEN ?? '',\n notifyChannel: process.env.SLACK_NOTIFY_CHANNEL ?? '',\n cmdSyncContent: process.env.SLACK_CMD_SYNC_CONTENT ?? '/sync-content',\n cmdSyncTranslations: process.env.SLACK_CMD_SYNC_TRANSLATIONS ?? '/sync-translations',\n cmdTriggerBuild:\n process.env.SLACK_CMD_TRIGGER_BUILD ?? '/trigger-build',\n },\n};\n","/**\n * Schedule expressions: exactly **two** whitespace-separated fields: minute, then hour\n * (same meaning as the first two fields of standard cron). No day-of-month, month, or\n * day-of-week — those are not accepted.\n *\n * Supported per field: `*`, `n`, `a-b`, steps (asterisk + slash + step), and comma lists.\n * Step must be >= 1.\n */\n\nconst MAX_SEARCH_MINUTES = 366 * 24 * 60;\n\nfunction tokenize(expr: string): string[] {\n return expr\n .trim()\n .split(/\\s+/)\n .map((s) => s.trim())\n .filter(Boolean);\n}\n\n/**\n * Validates that `expr` is exactly two cron fields (minute hour) and returns them\n * as a single normalized string `\"<minute> <hour>\"` for storage and logging.\n */\nexport function validateScheduleCronExpression(expr: string): string {\n const parts = tokenize(expr);\n if (parts.length !== 2) {\n throw new Error(\n `Schedule cron must be exactly two fields (minute hour), whitespace-separated; got ${parts.length} field(s): \"${expr}\"`,\n );\n }\n const minuteSpec = parts[0]!;\n const hourSpec = parts[1]!;\n parseField(minuteSpec, 0, 59, 'minute');\n parseField(hourSpec, 0, 23, 'hour');\n return `${minuteSpec} ${hourSpec}`;\n}\n\nfunction parseField(\n spec: string,\n lo: number,\n hi: number,\n fieldName: string,\n): (n: number) => boolean {\n const subs = spec.split(',').map((s) => s.trim()).filter(Boolean);\n if (subs.length === 0) {\n throw new Error(`Empty ${fieldName} field in cron`);\n }\n const preds = subs.map((sub) => parseSubfield(sub, lo, hi, fieldName));\n return (n: number) => preds.some((p) => p(n));\n}\n\nfunction parseSubfield(\n sub: string,\n lo: number,\n hi: number,\n fieldName: string,\n): (n: number) => boolean {\n if (sub === '*') {\n return () => true;\n }\n if (sub.startsWith('*/')) {\n const step = parseInt(sub.slice(2), 10);\n if (!Number.isFinite(step) || step < 1) {\n throw new Error(`Invalid step in ${fieldName} field: \"${sub}\"`);\n }\n return (n: number) => n >= lo && n <= hi && n % step === 0;\n }\n if (sub.includes('-')) {\n const [a, b] = sub.split('-').map((x) => parseInt(x.trim(), 10));\n if (!Number.isFinite(a) || !Number.isFinite(b)) {\n throw new Error(`Invalid range in ${fieldName} field: \"${sub}\"`);\n }\n if (a < lo || b > hi || a > b) {\n throw new Error(`Range out of bounds in ${fieldName} field: \"${sub}\"`);\n }\n return (n: number) => n >= a && n <= b;\n }\n const v = parseInt(sub, 10);\n if (!Number.isFinite(v) || v < lo || v > hi) {\n throw new Error(`Invalid value in ${fieldName} field: \"${sub}\"`);\n }\n return (n: number) => n === v;\n}\n\nfunction floorToMinuteStart(d: Date): Date {\n const t = new Date(d.getTime());\n t.setSeconds(0, 0);\n return t;\n}\n\nfunction addOneMinute(d: Date): Date {\n const t = new Date(d.getTime());\n t.setMinutes(t.getMinutes() + 1, 0, 0);\n return t;\n}\n\nfunction matchesAtMinuteStart(\n minutePred: (m: number) => boolean,\n hourPred: (h: number) => boolean,\n d: Date,\n): boolean {\n return minutePred(d.getMinutes()) && hourPred(d.getHours());\n}\n\n/**\n * Earliest minute boundary strictly after `after` that satisfies the two-field expression.\n */\nexport function nextCronFireAfter(expr: string, after: Date): Date {\n const parts = tokenize(expr);\n if (parts.length !== 2) {\n throw new Error(\n `nextCronFireAfter expects exactly two fields (minute hour); got ${parts.length}: \"${expr}\"`,\n );\n }\n const minutePred = parseField(parts[0]!, 0, 59, 'minute');\n const hourPred = parseField(parts[1]!, 0, 23, 'hour');\n\n let d = floorToMinuteStart(after);\n if (d.getTime() <= after.getTime()) {\n d = addOneMinute(d);\n }\n\n for (let i = 0; i < MAX_SEARCH_MINUTES; i++) {\n if (matchesAtMinuteStart(minutePred, hourPred, d)) {\n return d;\n }\n d = addOneMinute(d);\n }\n\n throw new Error(`No cron match within ${MAX_SEARCH_MINUTES} minutes for \"${expr}\"`);\n}\n","import { timingSafeEqual } from 'node:crypto';\nimport type { CMSProvider } from './types';\nimport type {\n FetchCmsBundlesOptions,\n FetchTranslationBundlesOptions,\n TranslationBundleInfo,\n} from './bundles';\n\nexport type ContentRefreshScope = 'cms' | 'translations' | 'all';\n\nexport interface ContentRefreshRequest {\n scope?: ContentRefreshScope;\n cms?: CMSProvider;\n content_types?: string[];\n projects?: string[];\n locales?: string[];\n}\n\n/** Defaults applied when the request omits fields (set by the host application). */\nexport interface ContentRefreshDefaults {\n scope?: ContentRefreshScope;\n cms?: CMSProvider;\n contentTypes?: string[];\n translationProjects?: string[];\n locales?: string[];\n}\n\nexport interface ContentRefreshError {\n step: string;\n message: string;\n}\n\nexport interface ContentRefreshResult {\n ok: boolean;\n scope: ContentRefreshScope;\n cmsFiles?: Record<string, string>;\n translationFiles?: TranslationBundleInfo;\n errors: ContentRefreshError[];\n durationMs: number;\n}\n\nexport interface ContentRefreshFetchers {\n fetchCmsBundles: (\n options: FetchCmsBundlesOptions,\n ) => Promise<Record<string, string>>;\n fetchTranslationBundles: (\n options: FetchTranslationBundlesOptions,\n ) => Promise<TranslationBundleInfo>;\n}\n\nexport function resolveContentRefreshScope(\n request: ContentRefreshRequest,\n defaults: ContentRefreshDefaults,\n): ContentRefreshScope {\n return request.scope ?? defaults.scope ?? 'cms';\n}\n\n/** Base64 of `username:password` (value only — prefix with `Basic ` in the header). */\nexport function encodeBasicAuthCredentials(\n username: string,\n password: string,\n): string {\n return Buffer.from(`${username}:${password}`, 'utf8').toString('base64');\n}\n\n/**\n * Validates `Authorization: Basic <base64>` against the expected credentials\n * (base64 of `user:pass`, same as staging site basic auth).\n */\nexport function assertContentRefreshBasicAuth(\n authorizationHeader: string | undefined,\n expectedCredentialsBase64: string,\n): void {\n if (!expectedCredentialsBase64) {\n throw new ContentRefreshAuthError(\n 'Content refresh basic auth is not configured (set CONTENT_REFRESH_BASIC_AUTH)',\n 500,\n );\n }\n if (!authorizationHeader?.startsWith('Basic ')) {\n throw new ContentRefreshAuthError(\n 'Missing or malformed Authorization header (expected Basic)',\n 401,\n );\n }\n const provided = authorizationHeader.slice(6).trim();\n const bufA = new TextEncoder().encode(provided);\n const bufB = new TextEncoder().encode(expectedCredentialsBase64);\n if (bufA.byteLength !== bufB.byteLength || !timingSafeEqual(bufA, bufB)) {\n throw new ContentRefreshAuthError('Invalid basic auth credentials', 403);\n }\n}\n\nexport class ContentRefreshAuthError extends Error {\n constructor(\n message: string,\n readonly statusCode: number,\n ) {\n super(message);\n this.name = 'ContentRefreshAuthError';\n }\n}\n\n/**\n * Pull the latest bundles from S3 into the host app's configured output directory.\n */\nexport async function executeContentRefresh(\n fetchers: ContentRefreshFetchers,\n request: ContentRefreshRequest,\n defaults: ContentRefreshDefaults = {},\n): Promise<ContentRefreshResult> {\n const started = Date.now();\n const scope = resolveContentRefreshScope(request, defaults);\n const errors: ContentRefreshError[] = [];\n let cmsFiles: Record<string, string> | undefined;\n let translationFiles: TranslationBundleInfo | undefined;\n\n if (scope === 'cms' || scope === 'all') {\n const cms = request.cms ?? defaults.cms ?? 'contentful';\n const contentTypes = request.content_types ?? defaults.contentTypes;\n if (!contentTypes?.length) {\n errors.push({\n step: 'cms',\n message: 'content_types (or handler defaults.contentTypes) is required for CMS refresh',\n });\n } else {\n try {\n cmsFiles = await fetchers.fetchCmsBundles({ cms, contentTypes });\n } catch (err) {\n errors.push({\n step: 'cms',\n message: err instanceof Error ? err.message : String(err),\n });\n }\n }\n }\n\n if (scope === 'translations' || scope === 'all') {\n const projects = request.projects ?? defaults.translationProjects;\n if (!projects?.length) {\n errors.push({\n step: 'translations',\n message:\n 'projects (or handler defaults.translationProjects) is required for translation refresh',\n });\n } else {\n const locales = request.locales ?? defaults.locales;\n try {\n const projectMap = Object.fromEntries(\n projects.map((p) => [p, [] as string[]]),\n );\n translationFiles = await fetchers.fetchTranslationBundles({\n projects: projectMap,\n locales,\n });\n } catch (err) {\n errors.push({\n step: 'translations',\n message: err instanceof Error ? err.message : String(err),\n });\n }\n }\n }\n\n return {\n ok: errors.length === 0,\n scope,\n cmsFiles,\n translationFiles,\n errors,\n durationMs: Date.now() - started,\n };\n}\n\nexport interface PostContentRefreshResponse {\n target: string;\n ok: boolean;\n status: number;\n body?: unknown;\n error?: string;\n}\n\n/**\n * Ask a remote application (web-site, web-app, …) to refresh its local content cache.\n */\nexport async function postContentRefresh(\n target: string,\n url: string,\n basicAuth: string,\n request: ContentRefreshRequest,\n): Promise<PostContentRefreshResponse> {\n try {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Authorization: `Basic ${basicAuth}`,\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n },\n body: JSON.stringify(request),\n });\n\n const text = await response.text();\n let body: unknown;\n if (text) {\n try {\n body = JSON.parse(text) as unknown;\n } catch {\n body = text;\n }\n }\n\n return {\n target,\n ok: response.ok,\n status: response.status,\n body,\n error: response.ok\n ? undefined\n : typeof body === 'object' && body !== null && 'error' in body\n ? String((body as { error: unknown }).error)\n : `HTTP ${response.status}`,\n };\n } catch (err) {\n return {\n target,\n ok: false,\n status: 0,\n error: err instanceof Error ? err.message : String(err),\n };\n }\n}\n","import type { AzureDevOpsProjectKey } from './adapters/azure';\nimport { AZURE_DEVOPS_PROJECT_KEYS } from './adapters/azure';\nimport { normalizeToAzureEnvironment } from './adapters/azure';\nimport { config, type CMSProvider } from './config';\nimport type { CmsSyncResult } from './sync/engine';\nimport {\n postContentRefresh,\n type ContentRefreshRequest,\n type PostContentRefreshResponse,\n} from '../shared/content-refresh';\n\nexport interface ContentRefreshTargetConfig {\n url?: string;\n}\n\nexport interface ContentRefreshNotifyConfig {\n /** When false, never call client refresh URLs (e.g. production uses pipeline builds). */\n enabled: boolean;\n /** Base64 of `username:password` (no `Basic ` prefix). */\n basicAuth: string;\n targets: Record<AzureDevOpsProjectKey, ContentRefreshTargetConfig>;\n}\n\nexport function isContentRefreshEnabledForInstance(\n instanceEnvironment: string,\n): boolean {\n return normalizeToAzureEnvironment(instanceEnvironment) === 'staging';\n}\n\nexport async function notifyContentRefreshTargets(\n notifyConfig: ContentRefreshNotifyConfig,\n request: ContentRefreshRequest,\n projects?: AzureDevOpsProjectKey[],\n): Promise<PostContentRefreshResponse[]> {\n if (!notifyConfig.enabled || !notifyConfig.basicAuth) {\n return [];\n }\n\n const keys =\n projects ??\n (AZURE_DEVOPS_PROJECT_KEYS.filter(\n (p) => notifyConfig.targets[p]?.url,\n ) as AzureDevOpsProjectKey[]);\n\n const results: PostContentRefreshResponse[] = [];\n\n for (const project of keys) {\n const url = notifyConfig.targets[project]?.url;\n if (!url) {\n continue;\n }\n const result = await postContentRefresh(\n project,\n url,\n notifyConfig.basicAuth,\n request,\n );\n results.push(result);\n if (result.ok) {\n console.log(\n `[content-refresh] Notified ${project} (${result.status})`,\n );\n } else {\n console.error(\n `[content-refresh] Failed to notify ${project}: ${result.error ?? result.status}`,\n );\n }\n }\n\n return results;\n}\n\n/**\n * After a successful CMS sync (Slack, HTTP API, or cron), POST to configured client refresh URLs.\n */\nexport async function notifyClientsAfterCmsSync(\n result: CmsSyncResult,\n requestedContentTypes?: string[],\n projects?: AzureDevOpsProjectKey[],\n): Promise<PostContentRefreshResponse[]> {\n const { contentRefresh } = config;\n\n if (!contentRefresh.enabled) {\n console.log(\n '[content-refresh] Skipped after CMS sync (disabled on this instance; staging/beta only)',\n );\n return [];\n }\n if (!contentRefresh.basicAuth) {\n console.warn(\n '[content-refresh] Skipped after CMS sync (set CONTENT_REFRESH_BASIC_AUTH)',\n );\n return [];\n }\n if (result.errors.length > 0) {\n console.log('[content-refresh] Skipped after CMS sync (sync had errors)');\n return [];\n }\n\n const types = requestedContentTypes?.length\n ? requestedContentTypes\n : result.entries.map((e) => e.contentType);\n if (types.length === 0) {\n console.warn('[content-refresh] Skipped after CMS sync (no content types)');\n return [];\n }\n\n const targets = (\n projects ??\n (AZURE_DEVOPS_PROJECT_KEYS.filter(\n (p) => contentRefresh.targets[p]?.url,\n ) as AzureDevOpsProjectKey[])\n );\n\n if (targets.length === 0) {\n console.warn(\n '[content-refresh] Skipped after CMS sync (no CONTENT_REFRESH_*_URL configured)',\n );\n return [];\n }\n\n console.log(\n `[content-refresh] Notifying after CMS sync (${result.cms}): ${targets.join(', ')}`,\n );\n\n return notifyContentRefreshTargets(\n contentRefresh,\n {\n scope: 'cms',\n cms: result.cms as CMSProvider,\n content_types: types,\n },\n projects,\n );\n}\n","/** Per-API request counts for a single Contentful sync run. */\nexport interface ContentfulApiUsage {\n cda: number;\n cma: number;\n cpa: number;\n}\n\nexport type ContentfulApiKind = keyof ContentfulApiUsage;\n\nexport function emptyContentfulApiUsage(): ContentfulApiUsage {\n return { cda: 0, cma: 0, cpa: 0 };\n}\n\n/** Map Contentful client `host` to CDA / CPA / CMA (one kind per adapter instance). */\nexport function contentfulApiKindFromHost(host: string): ContentfulApiKind {\n const h = host.toLowerCase();\n if (h.includes('preview')) {\n return 'cpa';\n }\n if (h.includes('api.contentful') || h === 'api.contentful.com') {\n return 'cma';\n }\n return 'cda';\n}\n\nexport function totalContentfulApiCalls(usage: ContentfulApiUsage): number {\n return usage.cda + usage.cma + usage.cpa;\n}\n\n/** Slack / log lines for Contentful API usage (omits zero counts except total). */\nexport function summariseContentfulApiUsage(usage: ContentfulApiUsage): string[] {\n const lines: string[] = [];\n if (usage.cda > 0) {\n lines.push(`CDA requests: ${usage.cda}`);\n }\n if (usage.cpa > 0) {\n lines.push(`CPA requests: ${usage.cpa}`);\n }\n if (usage.cma > 0) {\n lines.push(`CMA requests: ${usage.cma}`);\n }\n lines.push(`Total contentful API calls: ${totalContentfulApiCalls(usage)}`);\n return lines;\n}\n\nexport class ContentfulApiUsageTracker {\n private readonly kind: ContentfulApiKind;\n private readonly counts = emptyContentfulApiUsage();\n\n constructor(host: string) {\n this.kind = contentfulApiKindFromHost(host);\n }\n\n recordCall(): void {\n this.counts[this.kind] += 1;\n }\n\n snapshot(): ContentfulApiUsage {\n return { ...this.counts };\n }\n}\n","import {\n createClient,\n type ContentfulClientApi,\n type ContentTypeCollection,\n type AssetCollection,\n} from 'contentful';\nimport type { ContentfulConfig, RetryConfig } from '../config';\nimport type { CMSAdapter, FetchResult } from './types';\nimport {\n type ContentfulApiUsage,\n ContentfulApiUsageTracker,\n} from './contentful-api-usage';\nimport { withRetry } from '../sync/retry';\n\ntype CfCollection = {\n items: CfItem[],\n total: number\n}\n\ntype CfItem = {\n metadata:{\n tags: string[],\n concepts: string[]\n }\n sys:{\n type: string,\n id: string\n space: {\n sys: {\n type: string\n linkType: string\n id: string\n }\n },\n environment: {\n sys: {\n id: string\n type: 'Link',\n linkType: 'Environment'\n }\n },\n contentType: {\n sys: {\n type: 'Link',\n linkType: 'ContentType',\n id: string\n }\n },\n createdBy: {\n sys: {\n type: 'Link',\n linkType: 'User',\n id: string,\n }\n },\n updatedBy: {\n sys: {\n type: 'Link',\n linkType: 'User',\n id: string\n }\n },\n 'revision': number,\n 'createdAt': string,\n 'updatedAt': string,\n 'publishedVersion': string\n },\n fields:{\n [key:string]: unknown\n }\n}\n\n\n/**\n * Recursively unwraps Contentful's { metadata, sys, fields } envelope.\n * `depth` tracks how many entry/asset envelopes deep we are — anything\n * beyond `maxDepth` is dropped to avoid blowing the call stack on\n * circular or extremely deep reference chains.\n *\n * `path` holds objects on the current recursion branch only. That way a\n * shared reference (e.g. the same asset on `image` and `mobileImage`) is\n * unwrapped for each sibling; only true cycles (an object recurring as a\n * descendant of itself) yield `undefined`.\n */\nfunction stripEnvelope(\n value: unknown,\n maxDepth: number,\n depth = 0,\n path = new WeakSet<object>(),\n): unknown {\n if (value === null || typeof value !== 'object') return value;\n\n const obj = value as CfItem;\n\n if (path.has(obj)) return undefined;\n path.add(obj);\n\n try {\n if (Array.isArray(value)) {\n return value.map((item) => stripEnvelope(item, maxDepth, depth, path));\n }\n\n const isEnvelope = 'sys' in obj && 'fields' in obj && typeof obj.fields === 'object';\n\n if (isEnvelope) {\n if (depth >= maxDepth) return undefined;\n\n const fields = obj.fields as Record<string, unknown>;\n const result: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(fields)) {\n result[k] = stripEnvelope(v, maxDepth, depth + 1, path);\n }\n\n const sys = obj.sys;\n if (sys) {\n const existingMeta = result.meta;\n const metaBase =\n typeof existingMeta === 'object' &&\n existingMeta !== null &&\n !Array.isArray(existingMeta)\n ? (existingMeta as Record<string, unknown>)\n : {};\n const _contentType = sys.contentType ? sys.contentType.sys.id : 'Asset'\n result.meta = { ...metaBase, _id: sys.id, _contentType, _updatedAt: sys.updatedAt };\n }\n\n return result;\n }\n\n const result: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(obj)) {\n result[k] = stripEnvelope(v, maxDepth, depth, path);\n }\n return result;\n } finally {\n path.delete(obj);\n }\n}\n\nexport class ContentfulAdapter implements CMSAdapter {\n readonly name = 'contentful';\n private client: ContentfulClientApi<undefined>;\n private batchSize: number;\n private maxDepth: number;\n private includeLevels: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;\n private allowedTypes: string[];\n private retryConfig: RetryConfig;\n private readonly apiUsage: ContentfulApiUsageTracker;\n\n constructor(cfg: ContentfulConfig, retryConfig: RetryConfig) {\n this.client = createClient({\n space: cfg.spaceId,\n accessToken: cfg.accessToken,\n host: cfg.host,\n });\n this.batchSize = cfg.batchSize;\n this.maxDepth = cfg.maxDepth;\n this.includeLevels = cfg.includeLevels;\n this.allowedTypes = cfg.contentTypes;\n this.retryConfig = retryConfig;\n this.apiUsage = new ContentfulApiUsageTracker(cfg.host);\n }\n\n getContentfulApiUsage(): ContentfulApiUsage {\n return this.apiUsage.snapshot();\n }\n\n async getContentTypes(): Promise<string[]> {\n const response = await withRetry<ContentTypeCollection>(\n () => {\n this.apiUsage.recordCall();\n return this.client.getContentTypes();\n },\n this.retryConfig,\n );\n\n const allTypes = response.items.map((ct) => ct.sys.id);\n\n if (this.allowedTypes.length > 0) {\n return allTypes.filter((t) => this.allowedTypes.includes(t));\n }\n return allTypes;\n }\n\n /**\n * Fetches every entry for a content type using batched pagination.\n * Contentful caps `getEntries` at 1 000 items per call, so we page through\n * with `skip` until all items are collected.\n *\n * The reserved content type `\"asset\"` fetches from `getAssets()` instead.\n */\n async fetchAll(contentType: string, includeLevels: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 = this.includeLevels): Promise<FetchResult> {\n if (contentType === 'asset') {\n return this.fetchAllAssets();\n }\n\n const allItems: unknown[] = [];\n let skip = 0;\n let total = 0;\n\n do {\n const payload = {\n content_type: contentType,\n limit: this.batchSize,\n skip,\n include: includeLevels,\n };\n this.apiUsage.recordCall();\n const response = await this.client.getEntries(payload) as unknown as CfCollection;\n total = response.total;\n allItems.push(...response.items);\n skip += response.items.length;\n\n if (total > this.batchSize) {\n console.log(\n ` [contentful] ${contentType}: fetched ${allItems.length}/${total}`,\n );\n }\n } while (skip < total);\n\n return {\n contentType,\n items: allItems.map((item) => stripEnvelope(item, this.maxDepth)),\n total,\n };\n }\n\n private async fetchAllAssets(): Promise<FetchResult> {\n const allItems: unknown[] = [];\n let skip = 0;\n let total = 0;\n\n do {\n const response = await withRetry<AssetCollection>(\n () => {\n this.apiUsage.recordCall();\n return this.client.getAssets({ limit: this.batchSize, skip });\n },\n this.retryConfig,\n );\n total = response.total;\n allItems.push(...response.items);\n skip += response.items.length;\n\n if (total > this.batchSize) {\n console.log(\n ` [contentful] asset: fetched ${allItems.length}/${total}`,\n );\n }\n } while (skip < total);\n\n return {\n contentType: 'asset',\n items: allItems.map((item) => stripEnvelope(item, this.maxDepth)),\n total,\n };\n }\n}\n","import type { RetryConfig } from '../config';\n\n/**\n * Inspects an error to determine if it represents an API rate-limit (HTTP 429).\n * Returns the suggested wait time in ms when available, otherwise `0` to signal\n * that the caller should fall back to computed backoff. Returns `null` when the\n * error is *not* a rate-limit error.\n */\nfunction rateLimitDelayMs(err: unknown): number | null {\n const e = err as Record<string, unknown>;\n\n if (e?.status === 429 || e?.statusCode === 429) {\n const reset = (e?.headers as Record<string, string> | undefined)?.[\n 'x-contentful-ratelimit-reset'\n ];\n return reset ? parseFloat(reset) * 1000 : 0;\n }\n\n const resp = e?.response as Record<string, unknown> | undefined;\n if (resp?.status === 429) {\n const headers = resp?.headers as Record<string, string> | undefined;\n const reset = headers?.['x-contentful-ratelimit-reset'];\n return reset ? parseFloat(reset) * 1000 : 0;\n }\n\n return null;\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 * Executes `fn` with automatic retry + exponential backoff.\n * Rate-limit (429) responses are handled specially: if the API provides a\n * Retry-After / reset header, that value is respected instead of computed backoff.\n */\nexport async function withRetry<T>(\n fn: () => Promise<T>,\n { maxRetries, baseDelayMs, maxDelayMs }: RetryConfig,\n): Promise<T> {\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n return await fn();\n } catch (err) {\n if (attempt === maxRetries) throw err;\n\n const rlDelay = rateLimitDelayMs(err);\n let delay: number;\n\n if (rlDelay !== null) {\n delay =\n rlDelay > 0 ? rlDelay : computeDelay(attempt, baseDelayMs, maxDelayMs);\n console.warn(\n ` Rate limited (attempt ${attempt + 1}/${maxRetries}). ` +\n `Waiting ${Math.round(delay)}ms…`,\n );\n } else {\n delay = computeDelay(attempt, baseDelayMs, maxDelayMs);\n console.warn(\n ` Request failed (attempt ${attempt + 1}/${maxRetries}): ` +\n `${(err as Error).message}. Retrying in ${Math.round(delay)}ms…`,\n );\n }\n\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n }\n\n throw new Error('withRetry: unreachable');\n}\n","import { createClient, type SanityClient } from '@sanity/client';\nimport type { SanityConfig, RetryConfig } from '../config';\nimport type { CMSAdapter, FetchResult } from './types';\nimport { withRetry } from '../sync/retry';\n\nexport class SanityAdapter implements CMSAdapter {\n readonly name = 'sanity';\n private client: SanityClient;\n private retryConfig: RetryConfig;\n\n constructor(cfg: SanityConfig, retryConfig: RetryConfig) {\n this.client = createClient({\n projectId: cfg.projectId,\n dataset: cfg.dataset,\n token: cfg.token,\n apiVersion: cfg.apiVersion,\n useCdn: false,\n });\n this.retryConfig = retryConfig;\n }\n\n async getContentTypes(): Promise<string[]> {\n const types: string[] = await withRetry(\n () => this.client.fetch('array::unique(*[]._type)'),\n this.retryConfig,\n );\n return types.filter(\n (t) => !t.startsWith('system.') && !t.startsWith('sanity.'),\n );\n }\n\n async fetchAll(contentType: string): Promise<FetchResult> {\n const items: unknown[] = await withRetry(\n () => this.client.fetch('*[_type == $type]', { type: contentType }),\n this.retryConfig,\n );\n\n console.log(` [sanity] ${contentType}: fetched ${items.length} items`);\n return { contentType, items, total: items.length };\n }\n}\n","import { config, type CMSProvider } from '../config';\nimport type { CMSAdapter } from './types';\nimport { ContentfulAdapter } from './contentful';\nimport { SanityAdapter } from './sanity';\n\nexport function createAdapter(cms: CMSProvider): CMSAdapter {\n switch (cms) {\n case 'contentful':\n return new ContentfulAdapter(config.contentful, config.retry);\n case 'sanity':\n return new SanityAdapter(config.sanity, config.retry);\n default:\n throw new Error(`Unknown CMS provider: ${cms as string}`);\n }\n}\n\nexport type { CMSAdapter, FetchResult } from './types';\n","import { config } from '../config';\nimport type { LingohubResource } from '../../shared/lingohub';\n\nconst cfg = config.lingohub;\nconst apiUrl = 'https://api.lingohub.com/v1/' + cfg.workspace + '/projects/';\n\n/**\n * Downloads the raw Lingohub resource body (exact bytes as UTF-8 text).\n * Sync uploads this unmodified to S3; conversion happens at fetch time.\n */\nexport async function fetchLingohubResourceRaw(\n project: string,\n resource: LingohubResource,\n locale: string,\n): Promise<string> {\n const urlForResourceLocalised =\n `${apiUrl}${project}/resources/${resource.fileName}?auth_token=${cfg.authToken}`.replace(\n '[locale]',\n locale,\n );\n const res = await fetch(urlForResourceLocalised, { method: 'GET' });\n if (!res.ok) {\n throw new Error(`Failed to fetch resource \\`${resource.fileName}\\` (${locale}): ${res.status} - ${res.statusText}`);\n }\n return await res.text();\n}\n","import type { ContentfulApiUsage } from '../adapters/contentful-api-usage';\nimport { summariseContentfulApiUsage } from '../adapters/contentful-api-usage';\nimport type { CMSProvider } from '../config';\nimport { config } from '../config';\nimport { createAdapter } from '../adapters';\nimport {buildCmsObjectKey, buildTranslationObjectKey, ContentStore} from '../../shared/s3';\nimport { allProjects, defaultLocales } from '../../shared/lingohub';\nimport { fetchLingohubResourceRaw } from '../adapters/lingohub';\nimport { contentTypeForTranslationKey } from '../../shared/translationResource';\nimport { withRetry } from './retry';\n\nexport interface CmsSyncResultEntry {\n contentType: string;\n itemCount: number;\n objectKey: string;\n}\n\nexport interface CmsSyncResult {\n cms: CMSProvider;\n timestamp: number;\n entries: CmsSyncResultEntry[];\n errors: Array<{ contentType: string; error: string }>;\n /** Present when `cms` is `contentful`; counts each Contentful SDK HTTP request in this run. */\n contentfulApiUsage?: ContentfulApiUsage;\n}\n\nexport interface TranslationSyncResultEntry {\n project: string;\n resource: string;\n locale: string;\n /** UTF-8 byte size of the raw Lingohub file uploaded to S3. */\n itemCount: number;\n objectKey: string;\n}\n\nexport interface TranslationSyncResult {\n timestamp: number;\n entries: TranslationSyncResultEntry[];\n errors: Array<{ locale: string; project: string, error: string }>;\n}\n\nexport function summariseCmsEntries(result: CmsSyncResult): string[] {\n return result.entries.map(\n (e) => `• \\`${e.contentType}\\` — ${e.itemCount} items`,\n );\n}\n\nexport function summariseCmsErrors(result: CmsSyncResult): string[] {\n return result.errors.map(\n (e) => `• \\`${e.contentType}\\` — ${e.error}`,\n );\n}\n\n/** Slack-style lines for Contentful CDA/CPA/CMA request totals (empty when not Contentful). */\nexport function summariseCmsContentfulApiUsage(result: CmsSyncResult): string[] {\n if (!result.contentfulApiUsage) {\n return [];\n }\n return summariseContentfulApiUsage(result.contentfulApiUsage);\n}\n\n/** Group translation sync entries into one summary line per project/resource. */\nexport function summariseTranslationEntries(entries: TranslationSyncResultEntry[]): string[] {\n const grouped = new Map<string, { locales: number; bytes: number }>();\n for (const e of entries) {\n const key = `${e.project} / ${e.resource}`;\n const existing = grouped.get(key);\n if (existing) {\n existing.locales += 1;\n existing.bytes += e.itemCount;\n } else {\n grouped.set(key, { locales: 1, bytes: e.itemCount });\n }\n }\n return [...grouped.entries()].map(\n ([key, { locales, bytes }]) => `• \\`${key}\\` / [${locales} locale${locales === 1 ? '' : 's'}] — ${bytes} bytes`,\n );\n}\n\nexport async function runSync(cms: CMSProvider, contentTypes?: string[], includeLevels?: number){\n await syncCmsContent(cms, contentTypes, includeLevels )\n}\n\nexport async function syncCmsContent(\n cms: CMSProvider,\n contentTypes?: string[],\n includeLevels?: number\n): Promise<CmsSyncResult> {\n const adapter = createAdapter(cms);\n const store = new ContentStore(config.s3);\n const timestamp = Math.floor(Date.now() / 1000);\n\n console.log(`\\nStarting sync from ${cms} at ${new Date(timestamp * 1000).toISOString()}`);\n\n const typesToSync =\n contentTypes && contentTypes.length > 0\n ? contentTypes\n : await adapter.getContentTypes();\n\n console.log(`Content types to sync: ${typesToSync.join(', ')}\\n`);\n\n const entries: CmsSyncResultEntry[] = [];\n const errors: Array<{ contentType: string; error: string }> = [];\n\n for (const contentType of typesToSync) {\n try {\n const result = await adapter.fetchAll(contentType, includeLevels);\n const objectKey = buildCmsObjectKey(cms, contentType);\n await store.upload(objectKey, result.items);\n\n entries.push({\n contentType,\n itemCount: result.total,\n objectKey,\n });\n\n console.log(\n ` + ${contentType}: ${result.total} items -> ${objectKey}`,\n );\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n errors.push({ contentType, error: message });\n console.error(` x ${contentType}: ${message}`);\n }\n }\n\n const contentfulApiUsage = adapter.getContentfulApiUsage?.();\n\n if (contentfulApiUsage) {\n console.log(\n `\\nContentful API calls: ${summariseContentfulApiUsage(contentfulApiUsage).join(', ')}`,\n );\n }\n\n console.log(\n `\\nSync complete: ${entries.length} succeeded, ${errors.length} failed\\n`,\n );\n\n return { cms, timestamp, entries, errors, contentfulApiUsage };\n}\n\nexport async function syncTranslations(projects?: string[], locales?:string[]):Promise<TranslationSyncResult> {\n\n const store = new ContentStore(config.s3);\n const entries: TranslationSyncResultEntry[] = [];\n const errors: Array<{ project: string; locale: string, error: string }> = [];\n const timestamp = Math.floor(Date.now() / 1000);\n const requestedLocales = locales && locales.length ? locales : null;\n if(!projects){\n projects = Object.keys(allProjects);\n }\n\n for(const project of projects) {\n const resources = allProjects[project];\n if(!resources){\n console.error(`No resources found for ${project}`);\n continue;\n }\n for(const resource of resources) {\n const resourceLocales = resource.locales\n ? (requestedLocales ? requestedLocales.filter((l) => resource.locales!.includes(l)) : resource.locales)\n : (requestedLocales ?? defaultLocales);\n for(const loc of resourceLocales){\n const locale = (resource.localeMapping && resource.localeMapping[loc]) ? resource.localeMapping[loc] : loc;\n try {\n const raw = await withRetry(\n () => fetchLingohubResourceRaw(project, resource, locale),\n config.retry,\n );\n const objectKey = buildTranslationObjectKey(\n project,\n resource.fileName,\n locale,\n );\n await store.uploadRaw(\n objectKey,\n raw,\n contentTypeForTranslationKey(objectKey),\n );\n const byteLength = Buffer.byteLength(raw, 'utf8');\n entries.push({\n project,\n resource: resource.resource,\n locale,\n itemCount: byteLength,\n objectKey,\n });\n\n console.log(\n ` + ${project} - ${locale}: ${byteLength} bytes -> ${objectKey}`,\n );\n }catch(err){\n const message = err instanceof Error ? err.message : String(err);\n errors.push({ project,locale, error: message });\n console.error(` x ${project} - ${locale}: ${message}`);\n }\n }\n }\n }\n\n return { timestamp, entries, errors };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAOO,IAAM,4BAAqD;AAAA,EAChE;AAAA,EACA;AAAA,EACA;AACF;;;ACJO,IAAM,oBAAN,MAAwB;AAAA,EAG7B,YAA6BA,SAAiC;AAAjC,kBAAAA;AAC3B,UAAM,MAAMA,QAAO,aAAa,QAAQ,cAAc,EAAE;AACxD,UAAM,UAAU,mBAAmBA,QAAO,OAAO;AACjD,SAAK,UAAU,yBAAyB,GAAG,IAAI,OAAO;AAAA,EACxD;AAAA,EANiB;AAAA;AAAA;AAAA;AAAA,EAWjB,MAAM,QAAW,SAA0C;AACzD,UAAM;AAAA,MACJ,SAAS;AAAA,MACT;AAAA,MACA,QAAQ,CAAC;AAAA,MACT;AAAA,MACA,aAAa,KAAK,OAAO;AAAA,MACzB,SAAS,eAAe,CAAC;AAAA,IAC3B,IAAI;AAEJ,QAAI,CAAC,KAAK,OAAO,KAAK;AACpB,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,MAAM,KAAK,SAAS,MAAM,EAAE,GAAG,OAAO,eAAe,WAAW,CAAC;AACvE,UAAM,UAAkC;AAAA,MACtC,eAAe,KAAK,gBAAgB;AA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AO,CAAC,MAAM,SAAS,QAAS,SAAS,CAAC,CAAC,IAAI,SAAS,UAC5F,oBAAoB;AACzB,iBAAU,OAAO,iBAAgB;AAC/B,cAAM,SAAU,SAAS,iBAAiB,SAAS,cAAc,GAAG,IAAK,SAAS,cAAc,GAAG,IAAI;AACvG,YAAI;AACF,gBAAM,MAAM,MAAM;AAAA,YAChB,MAAM,yBAAyB,SAAS,UAAU,MAAM;AAAA,YACxDA,QAAO;AAAA,UACT;AACA,gBAAM,YAAY;AAAA,YAChB;AAAA,YACA,SAAS;AAAA,YACT;AAAA,UACF;AACA,gBAAM,MAAM;AAAA,YACV;AAAA,YACA;AAAA,YACA,6BAA6B,SAAS;AAAA,UACxC;AACA,gBAAM,aAAa,OAAO,WAAW,KAAK,MAAM;AAChD,kBAAQ,KAAK;AAAA,YACX;AAAA,YACA,UAAU,SAAS;AAAA,YACnB;AAAA,YACA,WAAW;AAAA,YACX;AAAA,UACF,CAAC;AAED,kBAAQ;AAAA,YACN,OAAO,OAAO,MAAM,MAAM,KAAK,UAAU,aAAa,SAAS;AAAA,UACjE;AAAA,QACF,SAAO,KAAI;AACT,gBAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC/D,iBAAO,KAAK,EAAE,SAAQ,QAAQ,OAAO,QAAQ,CAAC;AAC9C,kBAAQ,MAAM,OAAO,OAAO,MAAM,MAAM,KAAK,OAAO,EAAE;AAAA,QACxD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,WAAW,SAAS,OAAO;AACtC;","names":["config","config","config","result","cfg","createClient","cfg","createClient","config","config","config"]}
@@ -15,6 +15,9 @@ var localeMapping = {
15
15
  },
16
16
  invites: {
17
17
  "prs": "fa"
18
+ },
19
+ website: {
20
+ "prs": "fa"
18
21
  }
19
22
  };
20
23
  var allProjects = {
@@ -30,7 +33,9 @@ var allProjects = {
30
33
  {
31
34
  resource: "main",
32
35
  fileName: "[locale].json",
33
- type: "json"
36
+ type: "json",
37
+ locales: ["ar", "de", "en", "es", "fr", "it", "ja", "ko", "pt-br", "prs", "ps", "ru", "th", "uk", "vi", "zh-hans", "zh-hant"],
38
+ localeMapping: localeMapping.website
34
39
  },
35
40
  {
36
41
  resource: "ai",
@@ -248,4 +253,4 @@ export {
248
253
  defaultLocales,
249
254
  allProjects
250
255
  };
251
- //# sourceMappingURL=chunk-TMR6VJBQ.js.map
256
+ //# sourceMappingURL=chunk-GGZIMFPD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shared/lingohub.ts"],"sourcesContent":["export const defaultLocales = ['de', 'en', 'es', 'fr', 'it', 'ja', 'ko', 'pt-br', 'ru', 'th', 'uk', 'vi', 'zh-hans', 'zh-hant'];\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 invites: {\n 'prs': 'fa',\n },\n website: {\n 'prs': 'fa',\n },\n};\n\nexport type LingohubResource = {\n resource: string,\n fileName: string;\n type: 'json'|'strings'|'xml';\n localeMapping?: Record<string, string>;\n locales?: string[]\n}\n\nexport const allProjects: Record<string, LingohubResource[]> = {\n 'tandem-(new-website)': [\n {\n resource: 'main',\n fileName: 'Website.[locale].json',\n type: 'json',\n locales: ['de', 'en', 'es', 'fr', 'it', 'ja', 'ko', 'pt-br', 'ru', 'zh-hans', 'zh-hant']\n }\n ],\n 'tandem-(website)': [\n {\n resource: 'main',\n fileName: '[locale].json',\n type: 'json',\n locales: ['ar', 'de', 'en', 'es', 'fr', 'it', 'ja', 'ko', 'pt-br', 'prs', 'ps', 'ru', 'th', 'uk', 'vi', 'zh-hans', 'zh-hant'],\n localeMapping: localeMapping.website,\n },\n {\n resource: 'ai',\n fileName: 'AI.[locale].json',\n type: 'json'\n },\n {\n resource: 'languages',\n fileName: 'languages.[locale].json',\n type: 'json'\n }\n ],\n 'tandem': [\n {\n resource: 'infoplist',\n fileName: 'InfoPlist.[locale].strings',\n type: 'strings',\n localeMapping: localeMapping.ios,\n },\n {\n resource: 'localizable',\n fileName: 'Localizable.[locale].strings',\n type: 'strings',\n localeMapping: localeMapping.ios,\n },\n {\n resource: 'ipad',\n fileName: 'Main_iPad.[locale].strings',\n type: 'strings',\n localeMapping: localeMapping.ios,\n },\n {\n resource: 'main',\n fileName: 'Main.[locale].strings',\n type: 'strings',\n localeMapping: localeMapping.ios,\n }\n ],\n 'tandem-(android)': [\n {\n resource: 'accessibility',\n fileName: 'accessibility_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'call',\n fileName: 'call_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'cert',\n fileName: 'cert_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'chat',\n fileName: 'chat_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'checklist',\n fileName: 'checklist_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'clubs',\n fileName: 'clubs_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'common',\n fileName: 'common_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'community',\n fileName: 'community_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'correction',\n fileName: 'correction_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'country_names',\n fileName: 'country_names.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'emoji',\n fileName: 'emoji_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'errors',\n fileName: 'errors.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'expressions',\n fileName: 'expressions_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'gif',\n fileName: 'gif_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'guidelines',\n fileName: 'guidelines_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'lanuguages',\n fileName: 'languages_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'localizable',\n fileName: 'localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'localizable2',\n fileName: 'localizable2.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'login',\n fileName: 'login_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'myprofile',\n fileName: 'myprofile_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'onb',\n fileName: 'onb_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'parties',\n fileName: 'parties_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'pro',\n fileName: 'pro_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'pro_screen',\n fileName: 'pro_screen_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'push_notification',\n fileName: 'push_notification_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'reporting',\n fileName: 'reporting_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n },\n {\n resource: 'translation',\n fileName: 'translation_localizable.[locale].xml',\n type: 'xml',\n localeMapping: localeMapping.android,\n }\n\n ],\n 'tandem-(web-invites)': [\n {\n resource: 'main',\n fileName: '[locale].json',\n type: 'json',\n locales: ['ar', 'de', 'en', 'es', 'fr', 'it', 'ja', 'ko', 'prs', 'ps', 'pt-br', 'ru', 'uk', 'zh-hans', 'zh-hant'],\n localeMapping: localeMapping.invites,\n }\n ]\n};\n"],"mappings":";;;AAAO,IAAM,iBAAkB,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,SAAS,MAAM,MAAM,MAAM,MAAM,WAAW,SAAS;AAE/H,IAAM,gBAAgB;AAAA,EAClB,KAAK;AAAA,IACD,SAAS;AAAA,IACT,WAAW;AAAA,IACX,WAAW;AAAA,EACf;AAAA,EACA,SAAS;AAAA,IACL,SAAS;AAAA,IACT,WAAW;AAAA,IACX,WAAW;AAAA,EACf;AAAA,EACA,SAAS;AAAA,IACL,OAAO;AAAA,EACX;AAAA,EACA,SAAS;AAAA,IACL,OAAO;AAAA,EACX;AACJ;AAUO,IAAM,cAAkD;AAAA,EAC3D,wBAAwB;AAAA,IACpB;AAAA,MACI,UAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,SAAS,MAAM,WAAW,SAAS;AAAA,IAC3F;AAAA,EACJ;AAAA,EACA,oBAAoB;AAAA,IAChB;AAAA,MACI,UAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAS,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,SAAS,OAAO,MAAM,MAAM,MAAM,MAAM,MAAM,WAAW,SAAS;AAAA,MAC5H,eAAe,cAAc;AAAA,IACjC;AAAA,IACA;AAAA,MACI,UAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAM;AAAA,IACV;AAAA,IACA;AAAA,MACI,UAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAM;AAAA,IACV;AAAA,EACJ;AAAA,EACA,UAAU;AAAA,IACN;AAAA,MACI,UAAU;AAAA,MACV,UAAU;A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,eAAe,cAAc;AAAA,IACjC;AAAA,IACA;AAAA,MACI,UAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAM;AAAA,MACN,eAAe,cAAc;AAAA,IACjC;AAAA,IACA;AAAA,MACI,UAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAM;AAAA,MACN,eAAe,cAAc;AAAA,IACjC;AAAA,IACA;AAAA,MACI,UAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAM;AAAA,MACN,eAAe,cAAc;AAAA,IACjC;AAAA,IACA;AAAA,MACI,UAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAM;AAAA,MACN,eAAe,cAAc;AAAA,IACjC;AAAA,IACA;AAAA,MACI,UAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAM;AAAA,MACN,eAAe,cAAc;AAAA,IACjC;AAAA,EAEJ;AAAA,EACA,wBAAwB;AAAA,IACpB;AAAA,MACI,UAAU;AAAA,MACV,UAAU;AAAA,MACV,MAAM;AAAA,MACN,SAAU,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,OAAO,MAAM,SAAS,MAAM,MAAM,WAAW,SAAS;AAAA,MACjH,eAAe,cAAc;AAAA,IACjC;AAAA,EACJ;AACJ;","names":[]}
@@ -12,10 +12,10 @@ import {
12
12
  syncCmsContent,
13
13
  syncTranslations,
14
14
  triggerPipelineBuild
15
- } from "./chunk-WJDMWZOX.js";
15
+ } from "./chunk-CAC2DUWN.js";
16
16
  import {
17
17
  allProjects
18
- } from "./chunk-TMR6VJBQ.js";
18
+ } from "./chunk-GGZIMFPD.js";
19
19
 
20
20
  // src/server/slack.ts
21
21
  import { App } from "@slack/bolt";
@@ -251,4 +251,4 @@ export {
251
251
  notifySlack,
252
252
  startSlackBot
253
253
  };
254
- //# sourceMappingURL=chunk-FMP35RL2.js.map
254
+ //# sourceMappingURL=chunk-LLNHAWCQ.js.map
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  allProjects,
16
16
  defaultLocales
17
- } from "./chunk-TMR6VJBQ.js";
17
+ } from "./chunk-GGZIMFPD.js";
18
18
 
19
19
  // src/shared/bundles.ts
20
20
  import fs from "fs/promises";
@@ -50,6 +50,12 @@ function trimDepth(value, remaining) {
50
50
  }
51
51
 
52
52
  // src/shared/bundles.ts
53
+ function resolveResourceLocales(resource, requestedLocales) {
54
+ if (resource.locales) {
55
+ return requestedLocales ? requestedLocales.filter((l) => resource.locales.includes(l)) : resource.locales;
56
+ }
57
+ return requestedLocales ?? defaultLocales;
58
+ }
53
59
  function nestKeys(flat) {
54
60
  if (typeof flat !== "object" || flat === null || Array.isArray(flat)) return flat;
55
61
  const src = flat;
@@ -150,7 +156,7 @@ async function fetchTranslationBundles(store, outputDir, options) {
150
156
  const retry = options.retry ?? getDefaultS3RetryConfig();
151
157
  await fs.mkdir(outputDir, { recursive: true });
152
158
  const result = {};
153
- const localesToSync = locales && locales.length ? locales : defaultLocales;
159
+ const requestedLocales = locales && locales.length ? locales : null;
154
160
  await Promise.all(
155
161
  Object.entries(projects).map(async ([project, resourceFilter]) => {
156
162
  const allResources = allProjects[project];
@@ -159,7 +165,7 @@ async function fetchTranslationBundles(store, outputDir, options) {
159
165
  if (!resources.length) return;
160
166
  const resourceTasks = [];
161
167
  for (const resource of resources) {
162
- const resourceLocales = resource.locales ? localesToSync.filter((l) => resource.locales.includes(l)) : localesToSync;
168
+ const resourceLocales = resolveResourceLocales(resource, requestedLocales);
163
169
  for (const loc of resourceLocales) {
164
170
  const locale = resource.localeMapping && resource.localeMapping[loc] ? resource.localeMapping[loc] : loc;
165
171
  const objectKey = buildTranslationObjectKey(
@@ -197,7 +203,7 @@ async function fetchMergedTranslationBundles(store, outputDir, options) {
197
203
  const nested = structure === "nested";
198
204
  const retry = options.retry ?? getDefaultS3RetryConfig();
199
205
  await fs.mkdir(outputDir, { recursive: true });
200
- const localesToSync = locales && locales.length ? locales : defaultLocales;
206
+ const requestedLocales = locales && locales.length ? locales : null;
201
207
  const tasks = [];
202
208
  const allLocales = /* @__PURE__ */ new Set();
203
209
  for (const [project, resourceFilter] of Object.entries(projects)) {
@@ -206,7 +212,7 @@ async function fetchMergedTranslationBundles(store, outputDir, options) {
206
212
  const resources = filterResources(allResources, resourceFilter);
207
213
  if (!resources.length) continue;
208
214
  for (const resource of resources) {
209
- const resourceLocales = resource.locales ? localesToSync.filter((l) => resource.locales.includes(l)) : localesToSync;
215
+ const resourceLocales = resolveResourceLocales(resource, requestedLocales);
210
216
  for (const loc of resourceLocales) {
211
217
  allLocales.add(loc);
212
218
  const mappedLocale = resource.localeMapping && resource.localeMapping[loc] ? resource.localeMapping[loc] : loc;
@@ -290,4 +296,4 @@ export {
290
296
  fetchMergedTranslationBundles,
291
297
  queryCmsBundle
292
298
  };
293
- //# sourceMappingURL=chunk-ZXSGKKXJ.js.map
299
+ //# sourceMappingURL=chunk-ZLSV6OOO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shared/bundles.ts","../src/shared/trimDepth.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { CMSProvider } from './types';\nimport { buildCmsObjectKey, buildTranslationObjectKey, ContentStore } from './s3';\nimport {\n downloadRawWithRetry,\n downloadWithRetry,\n getDefaultS3RetryConfig,\n type S3RetryConfig,\n} from './s3-retry';\nimport { trimDepth } from './trimDepth';\nimport {\n allProjects,\n defaultLocales,\n type LingohubResource,\n} from './lingohub';\n\n/**\n * Resolves the effective locale list for a single resource.\n *\n * - No explicit request + resource has own locales → resource.locales (full)\n * - Explicit request + resource has own locales → intersection (skip unsupported)\n * - No explicit request + no resource locales → defaultLocales\n * - Explicit request + no resource locales → requested locales\n */\nfunction resolveResourceLocales(\n resource: LingohubResource,\n requestedLocales: string[] | null,\n): string[] {\n if (resource.locales) {\n return requestedLocales\n ? requestedLocales.filter((l) => resource.locales!.includes(l))\n : resource.locales;\n }\n return requestedLocales ?? defaultLocales;\n}\nimport {\n parseTranslationResourceRaw,\n toFlatStringMap,\n translationJsonOutputPath,\n} from './translationResource';\n\nexport { trimDepth } from './trimDepth';\nexport type { S3RetryConfig } from './s3-retry';\nexport { getDefaultS3RetryConfig } from './s3-retry';\n\n/**\n * Expand dotted keys into a nested object structure.\n * e.g. `{ \"General.tryAgain\": \"Try Again\" }` → `{ \"General\": { \"tryAgain\": \"Try Again\" } }`\n */\nexport function nestKeys(flat: unknown): unknown {\n if (typeof flat !== 'object' || flat === null || Array.isArray(flat)) return flat;\n const src = flat as Record<string, unknown>;\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(src)) {\n const parts = key.split('.');\n let cur = result;\n for (let i = 0; i < parts.length - 1; i++) {\n const seg = parts[i]!;\n if (!(seg in cur) || typeof cur[seg] !== 'object' || cur[seg] === null) {\n cur[seg] = {};\n }\n cur = cur[seg] as Record<string, unknown>;\n }\n cur[parts[parts.length - 1]!] = value;\n }\n return result;\n}\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\n/**\n * Config-file-friendly shape used by `fetchTranslationBundles` and the CLI.\n *\n * ```json\n * {\n * \"projects\": {\n * \"tandem\": [],\n * \"tandem-(website)\": [\"main\", \"ai\"]\n * },\n * \"locales\": [\"en\", \"de\", \"it\"]\n * }\n * ```\n *\n * `projects` maps each Lingohub project id to an array of resource keys.\n * An empty array means **all** resources for that project.\n * `locales` is optional — omit (or pass `[]`) to fetch the default locale set.\n */\nexport interface TranslationFilterConfig {\n projects: Record<string, string[]>;\n locales?: string[];\n /** Output key structure. `\"flat\"` (default) keeps dotted keys as-is; `\"nested\"` expands dots into nested objects. */\n structure?: 'flat' | 'nested';\n}\n\nexport interface FetchTranslationBundlesOptions extends TranslationFilterConfig {\n /** S3 GET retry; defaults via {@link getDefaultS3RetryConfig}. */\n retry?: S3RetryConfig;\n}\n\n/** One merged JSON file per catalog locale (`en.json`, …). Same options as {@link FetchTranslationBundlesOptions}. */\nexport type FetchMergedTranslationBundlesOptions = FetchTranslationBundlesOptions;\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 */\n/** Filter a project's full resource list by the resource keys specified in the config. */\nfunction filterResources(\n projectResources: LingohubResource[],\n resourceFilter: string[],\n): LingohubResource[] {\n if (resourceFilter.length === 0) return projectResources;\n return projectResources.filter((r) => resourceFilter.includes(r.resource));\n}\n\nexport async function fetchTranslationBundles(\n store: ContentStore,\n outputDir: string,\n options: FetchTranslationBundlesOptions,\n): Promise<TranslationBundleInfo> {\n const { projects, locales, structure } = options;\n const nested = structure === 'nested';\n const retry = options.retry ?? getDefaultS3RetryConfig();\n await fs.mkdir(outputDir, { recursive: true });\n\n const result: TranslationBundleInfo = {};\n const requestedLocales = locales && locales.length ? locales : null;\n\n await Promise.all(\n Object.entries(projects).map(async ([project, resourceFilter]) => {\n const allResources = allProjects[project];\n if (!allResources?.length) return;\n\n const resources = filterResources(allResources, resourceFilter);\n if (!resources.length) return;\n\n const resourceTasks: { objectKey: string; resource: LingohubResource }[] =\n [];\n for (const resource of resources) {\n const resourceLocales = resolveResourceLocales(resource, requestedLocales);\n for (const loc of resourceLocales) {\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, resource });\n }\n }\n\n await Promise.all(\n resourceTasks.map(async ({ objectKey, resource }) => {\n const raw = await downloadRawWithRetry(store, objectKey, retry);\n const parsed = parseTranslationResourceRaw(raw, resource);\n const output = nested ? nestKeys(parsed) : parsed;\n const filePath = translationJsonOutputPath(outputDir, objectKey);\n await fs.mkdir(path.dirname(filePath), { recursive: true });\n await fs.writeFile(\n filePath,\n JSON.stringify(output, null, 2),\n 'utf-8',\n );\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 * Downloads translation bundles from S3, parses each raw Lingohub file, and merges all\n * key/value pairs per **catalog** locale into a single JSON file (e.g. `en.json`).\n * Duplicate keys across resources or projects: **last write wins** (iteration order:\n * projects → resources → locales).\n *\n * @returns Map of locale code to absolute path of the merged `{locale}.json` file.\n */\nexport async function fetchMergedTranslationBundles(\n store: ContentStore,\n outputDir: string,\n options: FetchMergedTranslationBundlesOptions,\n): Promise<Record<string, string>> {\n const { projects, locales, structure } = options;\n const nested = structure === 'nested';\n const retry = options.retry ?? getDefaultS3RetryConfig();\n await fs.mkdir(outputDir, { recursive: true });\n\n const requestedLocales = locales && locales.length ? locales : null;\n\n type Task = {\n catalogLocale: string;\n objectKey: string;\n resource: LingohubResource;\n };\n const tasks: Task[] = [];\n const allLocales = new Set<string>();\n\n for (const [project, resourceFilter] of Object.entries(projects)) {\n const allResources = allProjects[project];\n if (!allResources?.length) continue;\n\n const resources = filterResources(allResources, resourceFilter);\n if (!resources.length) continue;\n\n for (const resource of resources) {\n const resourceLocales = resolveResourceLocales(resource, requestedLocales);\n for (const loc of resourceLocales) {\n allLocales.add(loc);\n const mappedLocale =\n resource.localeMapping && resource.localeMapping[loc]\n ? resource.localeMapping[loc]\n : loc;\n const objectKey = buildTranslationObjectKey(\n project,\n resource.fileName,\n mappedLocale,\n );\n tasks.push({ catalogLocale: loc, objectKey, resource });\n }\n }\n }\n\n const results = await Promise.all(\n tasks.map(async ({ catalogLocale, objectKey, resource }) => {\n const raw = await downloadRawWithRetry(store, objectKey, retry);\n const parsed = parseTranslationResourceRaw(raw, resource);\n const stringMap = toFlatStringMap(parsed);\n return { catalogLocale, stringMap };\n }),\n );\n\n const merged: Record<string, Record<string, string>> = {};\n for (const loc of allLocales) {\n merged[loc] = {};\n }\n for (const { catalogLocale, stringMap } of results) {\n Object.assign(merged[catalogLocale]!, stringMap);\n }\n\n const out: Record<string, string> = {};\n for (const loc of allLocales) {\n const filePath = path.resolve(outputDir, `${loc}.json`);\n const output = nested ? nestKeys(merged[loc]) : merged[loc];\n await fs.writeFile(\n filePath,\n JSON.stringify(output, null, 2),\n 'utf-8',\n );\n out[loc] = filePath;\n }\n\n return out;\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","/**\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"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;;;ACOV,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;;;ADbA,SAAS,uBACP,UACA,kBACU;AACV,MAAI,SAAS,SAAS;AACpB,WAAO,mBACH,iBAAiB,OAAO,CAAC,MAAM,SAAS,QAAS,SAAS,CAAC,CAAC,IAC5D,SAAS;AAAA,EACf;AACA,SAAO,oBAAoB;AAC7B;AAeO,SAAS,SAAS,MAAwB;AA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IQZW.js";
10
10
  import {
11
11
  ContentStore
12
12
  } from "../chunk-K4RASQFK.js";
13
- import "../chunk-TMR6VJBQ.js";
13
+ import "../chunk-GGZIMFPD.js";
14
14
 
15
15
  // src/client/fetch-content-bundles.ts
16
16
  import { Command } from "commander";
@@ -4,7 +4,7 @@ import {
4
4
  } from "../chunk-SDEERVPV.js";
5
5
  import {
6
6
  fetchMergedTranslationBundles
7
- } from "../chunk-ZXSGKKXJ.js";
7
+ } from "../chunk-ZLSV6OOO.js";
8
8
  import "../chunk-EQ3DSPTJ.js";
9
9
  import "../chunk-OCAIIQZW.js";
10
10
  import {
@@ -12,7 +12,7 @@ import {
12
12
  } from "../chunk-K4RASQFK.js";
13
13
  import {
14
14
  allProjects
15
- } from "../chunk-TMR6VJBQ.js";
15
+ } from "../chunk-GGZIMFPD.js";
16
16
 
17
17
  // src/client/fetch-merged-translation-bundles.ts
18
18
  import fs from "fs";
@@ -4,7 +4,7 @@ import {
4
4
  } from "../chunk-SDEERVPV.js";
5
5
  import {
6
6
  fetchTranslationBundles
7
- } from "../chunk-ZXSGKKXJ.js";
7
+ } from "../chunk-ZLSV6OOO.js";
8
8
  import "../chunk-EQ3DSPTJ.js";
9
9
  import "../chunk-OCAIIQZW.js";
10
10
  import {
@@ -12,7 +12,7 @@ import {
12
12
  } from "../chunk-K4RASQFK.js";
13
13
  import {
14
14
  allProjects
15
- } from "../chunk-TMR6VJBQ.js";
15
+ } from "../chunk-GGZIMFPD.js";
16
16
 
17
17
  // src/client/fetch-translation-bundles.ts
18
18
  import fs from "fs";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  allProjects
4
- } from "../chunk-TMR6VJBQ.js";
4
+ } from "../chunk-GGZIMFPD.js";
5
5
 
6
6
  // src/client/list-projects.ts
7
7
  import { Command } from "commander";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  allProjects
4
- } from "../chunk-TMR6VJBQ.js";
4
+ } from "../chunk-GGZIMFPD.js";
5
5
 
6
6
  // src/client/list-resources.ts
7
7
  import { createInterface } from "readline/promises";
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  queryCmsBundle
4
- } from "../chunk-ZXSGKKXJ.js";
4
+ } from "../chunk-ZLSV6OOO.js";
5
5
  import "../chunk-EQ3DSPTJ.js";
6
6
  import "../chunk-K4RASQFK.js";
7
- import "../chunk-TMR6VJBQ.js";
7
+ import "../chunk-GGZIMFPD.js";
8
8
 
9
9
  // src/client/query-cms.ts
10
10
  import { Command } from "commander";
package/dist/node.js CHANGED
@@ -191,6 +191,9 @@ var localeMapping = {
191
191
  },
192
192
  invites: {
193
193
  "prs": "fa"
194
+ },
195
+ website: {
196
+ "prs": "fa"
194
197
  }
195
198
  };
196
199
  var allProjects = {
@@ -206,7 +209,9 @@ var allProjects = {
206
209
  {
207
210
  resource: "main",
208
211
  fileName: "[locale].json",
209
- type: "json"
212
+ type: "json",
213
+ locales: ["ar", "de", "en", "es", "fr", "it", "ja", "ko", "pt-br", "prs", "ps", "ru", "th", "uk", "vi", "zh-hans", "zh-hant"],
214
+ localeMapping: localeMapping.website
210
215
  },
211
216
  {
212
217
  resource: "ai",
@@ -517,6 +522,12 @@ function translationJsonOutputPath(outputDir, objectKey) {
517
522
  }
518
523
 
519
524
  // src/shared/bundles.ts
525
+ function resolveResourceLocales(resource, requestedLocales) {
526
+ if (resource.locales) {
527
+ return requestedLocales ? requestedLocales.filter((l) => resource.locales.includes(l)) : resource.locales;
528
+ }
529
+ return requestedLocales ?? defaultLocales;
530
+ }
520
531
  function nestKeys(flat) {
521
532
  if (typeof flat !== "object" || flat === null || Array.isArray(flat)) return flat;
522
533
  const src = flat;
@@ -617,7 +628,7 @@ async function fetchTranslationBundles(store, outputDir, options) {
617
628
  const retry = options.retry ?? getDefaultS3RetryConfig();
618
629
  await fs.mkdir(outputDir, { recursive: true });
619
630
  const result = {};
620
- const localesToSync = locales && locales.length ? locales : defaultLocales;
631
+ const requestedLocales = locales && locales.length ? locales : null;
621
632
  await Promise.all(
622
633
  Object.entries(projects).map(async ([project, resourceFilter]) => {
623
634
  const allResources = allProjects[project];
@@ -626,7 +637,7 @@ async function fetchTranslationBundles(store, outputDir, options) {
626
637
  if (!resources.length) return;
627
638
  const resourceTasks = [];
628
639
  for (const resource of resources) {
629
- const resourceLocales = resource.locales ? localesToSync.filter((l) => resource.locales.includes(l)) : localesToSync;
640
+ const resourceLocales = resolveResourceLocales(resource, requestedLocales);
630
641
  for (const loc of resourceLocales) {
631
642
  const locale = resource.localeMapping && resource.localeMapping[loc] ? resource.localeMapping[loc] : loc;
632
643
  const objectKey = buildTranslationObjectKey(
@@ -664,7 +675,7 @@ async function fetchMergedTranslationBundles(store, outputDir, options) {
664
675
  const nested = structure === "nested";
665
676
  const retry = options.retry ?? getDefaultS3RetryConfig();
666
677
  await fs.mkdir(outputDir, { recursive: true });
667
- const localesToSync = locales && locales.length ? locales : defaultLocales;
678
+ const requestedLocales = locales && locales.length ? locales : null;
668
679
  const tasks = [];
669
680
  const allLocales = /* @__PURE__ */ new Set();
670
681
  for (const [project, resourceFilter] of Object.entries(projects)) {
@@ -673,7 +684,7 @@ async function fetchMergedTranslationBundles(store, outputDir, options) {
673
684
  const resources = filterResources(allResources, resourceFilter);
674
685
  if (!resources.length) continue;
675
686
  for (const resource of resources) {
676
- const resourceLocales = resource.locales ? localesToSync.filter((l) => resource.locales.includes(l)) : localesToSync;
687
+ const resourceLocales = resolveResourceLocales(resource, requestedLocales);
677
688
  for (const loc of resourceLocales) {
678
689
  allLocales.add(loc);
679
690
  const mappedLocale = resource.localeMapping && resource.localeMapping[loc] ? resource.localeMapping[loc] : loc;