[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M792Z2Z7ZGZ48TS7JWVCA8BE":3,"skill-same:01M792Z2Z7ZGZ48TS7JWVCA8BE":57},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":37,"repositoryHtmlUrl":38,"repositoryHomepageUrl":6,"ownerHtmlUrl":39,"ownerBlogUrl":40,"ownerDescription":41,"updatedAt":42,"install":43,"resources":56},"01M792Z2Z7ZGZ48TS7JWVCA8BE","lokalise-sdk-patterns",null,"Apply production-ready Lokalise SDK patterns for TypeScript and Node.js.\nUse when implementing Lokalise integrations, refactoring SDK usage,\nor establishing team coding standards for Lokalise.\nTrigger with phrases like \"lokalise SDK patterns\", \"lokalise best practices\",\n\"lokalise code patterns\", \"idiomatic lokalise\".","jukeyman\u002Fjukeyman-skills","jukeyman","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142960420?v=4","01M78FR4Y3DHMMCBCC0GXXNB3F","RICK JEFFERSON","01M78FR4Z8RVQRAD31Y5J7V6EB",1,"MIT","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--lokalise-pack--lokalise-sdk-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: lokalise-sdk-patterns\ndescription: |\n  Apply production-ready Lokalise SDK patterns for TypeScript and Node.js.\n  Use when implementing Lokalise integrations, refactoring SDK usage,\n  or establishing team coding standards for Lokalise.\n  Trigger with phrases like \"lokalise SDK patterns\", \"lokalise best practices\",\n  \"lokalise code patterns\", \"idiomatic lokalise\".\nallowed-tools: Read, Write, Edit\nversion: 1.0.0\nlicense: MIT\nauthor: Jeremy Longshore \u003Cjeremy@intentsolutions.io>\ncompatible-with: claude-code, codex, openclaw\ntags: [saas, lokalise, typescript, nodejs]\n---\n# Lokalise SDK Patterns\n\n## Overview\n\nProduction-grade patterns for `@lokalise\u002Fnode-api`: client singleton, cursor pagination, typed error handling, batch operations, upload monitoring, and retry with rate limiting.\n\n## Prerequisites\n\n- `@lokalise\u002Fnode-api` v12+ installed\n- TypeScript 5+ with `strict` mode\n\n## Instructions\n\n1. Create a client singleton to centralize configuration and support branch-based project IDs.\n\n```typescript\n\u002F\u002F src\u002Flib\u002Flokalise-client.ts\nimport { LokaliseApi } from \"@lokalise\u002Fnode-api\";\n\nlet instance: LokaliseApi | null = null;\n\nexport function getClient(apiKey?: string): LokaliseApi {\n  if (instance) return instance;\n  const key = apiKey ?? process.env.LOKALISE_API_TOKEN;\n  if (!key) throw new Error(\"Set LOKALISE_API_TOKEN or pass apiKey\");\n  instance = new LokaliseApi({ apiKey: key, enableCompression: true });\n  return instance;\n}\n\nexport function resetClient(): void { instance = null; }\n\n\u002F** Lokalise branch syntax: \"projectId:branchName\" *\u002F\nexport function projectId(id: string, branch?: string): string {\n  return branch ? `${id}:${branch}` : id;\n}\n```\n\n2. Build a cursor-based pagination helper that works with any paginated endpoint.\n\n```typescript\n\u002F\u002F src\u002Flib\u002Fpaginate.ts\ninterface PaginatedResult\u003CT> {\n  items: T[];\n  hasNextCursor(): boolean;\n  nextCursor(): string;\n}\n\ntype Fetcher\u003CT> = (params: Record\u003Cstring, unknown>) => Promise\u003CPaginatedResult\u003CT>>;\n\n\u002F** Async generator yielding all items across pages with rate-limit spacing. *\u002F\nexport async function* paginate\u003CT>(\n  fetcher: Fetcher\u003CT>,\n  baseParams: Record\u003Cstring, unknown>,\n  pageSize = 500\n): AsyncGenerator\u003CT, void, undefined> {\n  let cursor: string | undefined;\n  let n = 0;\n  do {\n    const params = { ...baseParams, limit: pageSize, ...(cursor ? { cursor } : {}) };\n    if (n++ > 0) await new Promise((r) => setTimeout(r, 170)); \u002F\u002F 6 req\u002Fsec\n    const page = await fetcher(params);\n    for (const item of page.items) yield item;\n    cursor = page.hasNextCursor() ? page.nextCursor() : undefined;\n  } while (cursor);\n}\n\n\u002F** Collect all pages into an array (use only when dataset fits in memory). *\u002F\nexport async function paginateAll\u003CT>(fetcher: Fetcher\u003CT>, params: Record\u003Cstring, unknown>): Promise\u003CT[]> {\n  const out: T[] = [];\n  for await (const item of paginate(fetcher, params)) out.push(item);\n  return out;\n}\n```\n\nUsage:\n\n```typescript\nconst allKeys = await paginateAll(\n  (p) => client.keys().list(p),\n  { project_id: \"123456.abcdef\", include_translations: 1 }\n);\n```\n\n3. Wrap API calls with structured error handling that classifies retryable errors.\n\n```typescript\n\u002F\u002F src\u002Flib\u002Flokalise-api.ts\nexport class LokaliseError extends Error {\n  constructor(\n    message: string,\n    public readonly statusCode: number,\n    public readonly isRetryable: boolean\n  ) {\n    super(message);\n    this.name = \"LokaliseError\";\n  }\n}\n\nexport async function apiCall\u003CT>(fn: () => Promise\u003CT>): Promise\u003CT> {\n  try {\n    return await fn();\n  } catch (err: unknown) {\n    if (err && typeof err === \"object\" && \"code\" in err) {\n      const e = err as { code: number; message: string };\n      throw new LokaliseError(e.message, e.code, e.code === 429 || e.code >= 500);\n    }\n    throw err;\n  }\n}\n\n\u002F\u002F Usage\ntry {\n  const keys = await apiCall(() => client.keys().list({ project_id: pid, limit: 500 }));\n} catch (err) {\n  if (err instanceof LokaliseError && err.isRetryable) {\n    console.log(\"Transient failure, safe to retry\");\n  }\n}\n```\n\n4. Batch key operations that chunk requests to respect the 500-key-per-request limit.\n\n```typescript\n\u002F\u002F src\u002Flib\u002Fbatch.ts\nfunction chunk\u003CT>(arr: T[], size: number): T[][] {\n  const out: T[][] = [];\n  for (let i = 0; i \u003C arr.length; i += size) out.push(arr.slice(i, i + size));\n  return out;\n}\n\n\u002F** Create keys in batches of 500 with rate-limit spacing. *\u002F\nexport async function batchCreateKeys(\n  client: LokaliseApi, projectId: string,\n  keys: Array\u003C{ key_name: { web: string }; platforms: string[]; tags?: string[];\n    translations?: Array\u003C{ language_iso: string; translation: string }> }>\n): Promise\u003C{ created: number; errors: Error[] }> {\n  const batches = chunk(keys, 500);\n  let created = 0;\n  const errors: Error[] = [];\n  for (let i = 0; i \u003C batches.length; i++) {\n    try {\n      const r = await client.keys().create({ project_id: projectId, keys: batches[i] });\n      created += r.items.length;\n    } catch (err) { errors.push(err as Error); }\n    if (i \u003C batches.length - 1) await new Promise((r) => setTimeout(r, 500));\n  }\n  return { created, errors };\n}\n\n\u002F** Delete keys in batches of 500. *\u002F\nexport async function batchDeleteKeys(\n  client: LokaliseApi, projectId: string, keyIds: number[]\n): Promise\u003Cnumber> {\n  const batches = chunk(keyIds, 500);\n  let deleted = 0;\n  for (let i = 0; i \u003C batches.length; i++) {\n    const r = await client.keys().bulk_delete(batches[i], { project_id: projectId });\n    deleted += r.keys_removed;\n    if (i \u003C batches.length - 1) await new Promise((r) => setTimeout(r, 500));\n  }\n  return deleted;\n}\n```\n\n5. Upload files with async process monitoring and progress callbacks.\n\n```typescript\n\u002F\u002F src\u002Flib\u002Fupload.ts\nimport { readFileSync } from \"node:fs\";\n\nexport async function uploadWithProgress(\n  client: LokaliseApi, projectId: string,\n  opts: { filePath: string; langIso: string; tags?: string[];\n    replaceModified?: boolean; cleanupMode?: boolean },\n  onProgress?: (status: string, elapsedMs: number) => void\n): Promise\u003C{ processId: string; status: string; durationMs: number }> {\n  const data = readFileSync(opts.filePath).toString(\"base64\");\n  const start = Date.now();\n\n  const proc = await client.files().upload(projectId, {\n    data,\n    filename: opts.filePath.split(\"\u002F\").pop()!,\n    lang_iso: opts.langIso,\n    replace_modified: opts.replaceModified ?? true,\n    cleanup_mode: opts.cleanupMode ?? false,\n    detect_icu_plurals: true,\n    tags: opts.tags,\n  });\n  onProgress?.(\"queued\", Date.now() - start);\n\n  \u002F\u002F Poll process status until terminal state\n  const maxWait = 120_000; \u002F\u002F 2 minutes\n  let last = proc.status;\n  while (Date.now() - start \u003C maxWait) {\n    await new Promise((r) => setTimeout(r, 1500));\n    const check = await client.queuedProcesses().get(proc.process_id, { project_id: projectId });\n    if (check.status !== last) { last = check.status; onProgress?.(last, Date.now() - start); }\n    if (check.status === \"finished\") return { processId: proc.process_id, status: \"finished\", durationMs: Date.now() - start };\n    if (check.status === \"cancelled\" || check.status === \"failed\") throw new Error(`Upload ${check.status}: ${JSON.stringify(check.details)}`);\n  }\n  throw new Error(`Upload timed out after ${maxWait}ms`);\n}\n```\n\nUsage:\n\n```typescript\nawait uploadWithProgress(client, \"123456.abcdef\", {\n  filePath: \".\u002Fsrc\u002Flocales\u002Fen.json\",\n  langIso: \"en\",\n  tags: [\"ci\"],\n  replaceModified: true,\n}, (status, ms) => console.log(`[${(ms \u002F 1000).toFixed(1)}s] ${status}`));\n```\n\n6. Add a retry decorator with exponential backoff and a rate limiter for sequential calls.\n\n```typescript\n\u002F\u002F src\u002Flib\u002Fretry.ts\n\u002F** Retry on 429 and 5xx with exponential backoff + jitter. *\u002F\nexport async function withRetry\u003CT>(\n  fn: () => Promise\u003CT>,\n  opts: { maxRetries?: number; baseDelayMs?: number; maxDelayMs?: number;\n    onRetry?: (attempt: number, err: Error, delayMs: number) => void } = {}\n): Promise\u003CT> {\n  const { maxRetries = 3, baseDelayMs = 1000, maxDelayMs = 10_000, onRetry } = opts;\n  let lastErr: Error | undefined;\n  for (let i = 0; i \u003C= maxRetries; i++) {\n    try { return await fn(); }\n    catch (err: unknown) {\n      lastErr = err as Error;\n      const code = (err as { code?: number })?.code;\n      if (!(code === 429 || (code && code >= 500)) || i === maxRetries) throw err;\n      const delay = Math.min(baseDelayMs * 2 ** i + Math.random() * 200, maxDelayMs);\n      onRetry?.(i + 1, lastErr, delay);\n      await new Promise((r) => setTimeout(r, delay));\n    }\n  }\n  throw lastErr;\n}\n\n\u002F** Enforce minimum spacing between calls (default: 170ms = 6 req\u002Fsec). *\u002F\nexport function rateLimited\u003CA extends unknown[], R>(\n  fn: (...args: A) => Promise\u003CR>, minMs = 170\n): (...args: A) => Promise\u003CR> {\n  let last = 0;\n  return async (...args) => {\n    const wait = minMs - (Date.now() - last);\n    if (wait > 0) await new Promise((r) => setTimeout(r, wait));\n    last = Date.now();\n    return fn(...args);\n  };\n}\n```\n\nUsage:\n\n```typescript\n\u002F\u002F Single call with retry\nconst keys = await withRetry(\n  () => client.keys().list({ project_id: pid, limit: 500 }),\n  { onRetry: (n, e, ms) => console.warn(`Retry ${n}: ${e.message} (${ms}ms)`) }\n);\n\n\u002F\u002F Rate-limited sequential calls\nconst listKeys = rateLimited((p: Record\u003Cstring, unknown>) => client.keys().list(p));\nconst p1 = await listKeys({ project_id: pid, page: 1, limit: 100 });\nconst p2 = await listKeys({ project_id: pid, page: 2, limit: 100 });\n```\n\n## Output\n\n- Singleton client with compression and branch support\n- Async generator for memory-efficient cursor pagination\n- Type-safe error wrapper with `isRetryable` classification\n- Batch create\u002Fdelete respecting 500-key API limit\n- File upload with process polling and progress callbacks\n- Retry with exponential backoff + rate limiter at 6 req\u002Fsec\n\n## Error Handling\n\n| Pattern | When to Use | Behavior |\n|---------|------------|----------|\n| `apiCall()` | Every SDK call | Converts to typed `LokaliseError` with `isRetryable` |\n| `withRetry()` | Rate limits or transient failures | Exponential backoff, retries 429 and 5xx only |\n| `rateLimited()` | Sequential bulk calls | Enforces 170ms minimum spacing |\n| `paginate()` | Fetching all keys\u002Ftranslations | Built-in 170ms delay between pages |\n| `batchCreateKeys()` | Creating > 500 keys | 500-key chunks with 500ms spacing |\n| `uploadWithProgress()` | File uploads | Polls process status with 2-minute timeout |\n\n## Examples\n\n### Combining All Patterns\n\n```typescript\nimport { getClient, projectId } from \".\u002Flib\u002Flokalise-client\";\nimport { paginateAll } from \".\u002Flib\u002Fpaginate\";\nimport { withRetry } from \".\u002Flib\u002Fretry\";\nimport { batchCreateKeys } from \".\u002Flib\u002Fbatch\";\nimport { uploadWithProgress } from \".\u002Flib\u002Fupload\";\n\nconst client = getClient();\nconst pid = projectId(\"123456.abcdef\", \"develop\");\n\n\u002F\u002F Upload, paginate, batch create, download — all with rate limiting and retry\nawait uploadWithProgress(client, pid, { filePath: \".\u002Fsrc\u002Flocales\u002Fen.json\", langIso: \"en\" },\n  (s, ms) => console.log(`[${ms}ms] ${s}`));\n\nconst allKeys = await paginateAll((p) => client.keys().list(p), { project_id: pid });\nconsole.log(`${allKeys.length} keys`);\n\nconst result = await batchCreateKeys(client, pid,\n  Array.from({ length: 1200 }, (_, i) => ({\n    key_name: { web: `gen.key_${i}` }, platforms: [\"web\"],\n    translations: [{ language_iso: \"en\", translation: `Val ${i}` }],\n  })));\nconsole.log(`Created ${result.created}, errors: ${result.errors.length}`);\n\nconst bundle = await withRetry(() => client.files().download(pid, {\n  format: \"json\", original_filenames: false, bundle_structure: \"%LANG_ISO%.json\",\n}));\nconsole.log(`Download: ${bundle.bundle_url}`);\n```\n\n## Resources\n\n- [Node SDK Documentation](https:\u002F\u002Flokalise.github.io\u002Fnode-lokalise-api\u002F)\n- [Pagination Guide](https:\u002F\u002Flokalise.github.io\u002Fnode-lokalise-api\u002Fapi\u002Fgetting-started.html)\n- [API Rate Limits](https:\u002F\u002Fdevelopers.lokalise.com\u002Freference\u002Fapi-rate-limits)\n- [API Error Codes](https:\u002F\u002Fdevelopers.lokalise.com\u002Freference\u002Fapi-errors)\n- [Branching](https:\u002F\u002Fdocs.lokalise.com\u002Fen\u002Farticles\u002F3049428-branching)\n\n## Next Steps\n\nApply these patterns in `lokalise-core-workflow-a` and `lokalise-core-workflow-b` for real-world usage.\n","# Lokalise SDK Patterns\n\n## Overview\n\nProduction-grade patterns for `@lokalise\u002Fnode-api`: client singleton, cursor pagination, typed error handling, batch operations, upload monitoring, and retry with rate limiting.\n\n## Prerequisites\n\n- `@lokalise\u002Fnode-api` v12+ installed\n- TypeScript 5+ with `strict` mode\n\n## Instructions\n\n1. Create a client singleton to centralize configuration and support branch-based project IDs.\n\n```typescript\n\u002F\u002F src\u002Flib\u002Flokalise-client.ts\nimport { LokaliseApi } from \"@lokalise\u002Fnode-api\";\n\nlet instance: LokaliseApi | null = null;\n\nexport function getClient(apiKey?: string): LokaliseApi {\n  if (instance) return instance;\n  const key = apiKey ?? process.env.LOKALISE_API_TOKEN;\n  if (!key) throw new Error(\"Set LOKALISE_API_TOKEN or pass apiKey\");\n  instance = new LokaliseApi({ apiKey: key, enableCompression: true });\n  return instance;\n}\n\nexport function resetClient(): void { instance = null; }\n\n\u002F** Lokalise branch syntax: \"projectId:branchName\" *\u002F\nexport function projectId(id: string, branch?: string): string {\n  return branch ? `${id}:${branch}` : id;\n}\n```\n\n2. Build a cursor-based pagination helper that works with any paginated endpoint.\n\n```typescript\n\u002F\u002F src\u002Flib\u002Fpaginate.ts\ninterface PaginatedResult\u003CT> {\n  items: T[];\n  hasNextCursor(): boolean;\n  nextCursor(): string;\n}\n\ntype Fetcher\u003CT> = (params: Record\u003Cstring, unknown>) => Promise\u003CPaginatedResult\u003CT>>;\n\n\u002F** Async generator yielding all items across pages with rate-limit spacing. *\u002F\nexport async function* paginate\u003CT>(\n  fetcher: Fetcher\u003CT>,\n  baseParams: Record\u003Cstring, unknown>,\n  pageSize = 500\n): AsyncGenerator\u003CT, void, undefined> {\n  let cursor: string | undefined;\n  let n = 0;\n  do {\n    const params = { ...baseParams, limit: pageSize, ...(cursor ? { cursor } : {}) };\n    if (n++ > 0) await new Promise((r) => setTimeout(r, 170)); \u002F\u002F 6 req\u002Fsec\n    const page = await fetcher(params);\n    for (const item of page.items) yield item;\n    cursor = page.hasNextCursor() ? page.nextCursor() : undefined;\n  } while (cursor);\n}\n\n\u002F** Collect all pages into an array (use only when dataset fits in memory). *\u002F\nexport async function paginateAll\u003CT>(fetcher: Fetcher\u003CT>, params: Record\u003Cstring, unknown>): Promise\u003CT[]> {\n  const out: T[] = [];\n  for await (const item of paginate(fetcher, params)) out.push(item);\n  return out;\n}\n```\n\nUsage:\n\n```typescript\nconst allKeys = await paginateAll(\n  (p) => client.keys().list(p),\n  { project_id: \"123456.abcdef\", include_translations: 1 }\n);\n```\n\n3. Wrap API calls with structured error handling that classifies retryable errors.\n\n```typescript\n\u002F\u002F src\u002Flib\u002Flokalise-api.ts\nexport class LokaliseError extends Error {\n  constructor(\n    message: string,\n    public readonly statusCode: number,\n    public readonly isRetryable: boolean\n  ) {\n    super(message);\n    this.name = \"LokaliseError\";\n  }\n}\n\nexport async function apiCall\u003CT>(fn: () => Promise\u003CT>): Promise\u003CT> {\n  try {\n    return await fn();\n  } catch (err: unknown) {\n    if (err && typeof err === \"object\" && \"code\" in err) {\n      const e = err as { code: number; message: string };\n      throw new LokaliseError(e.message, e.code, e.code === 429 || e.code >= 500);\n    }\n    throw err;\n  }\n}\n\n\u002F\u002F Usage\ntry {\n  const keys = await apiCall(() => client.keys().list({ project_id: pid, limit: 500 }));\n} catch (err) {\n  if (err instanceof LokaliseError && err.isRetryable) {\n    console.log(\"Transient failure, safe to retry\");\n  }\n}\n```\n\n4. Batch key operations that chunk requests to respect the 500-key-per-request limit.\n\n```typescript\n\u002F\u002F src\u002Flib\u002Fbatch.ts\nfunction chunk\u003CT>(arr: T[], size: number): T[][] {\n  const out: T[][] = [];\n  for (let i = 0; i \u003C arr.length; i += size) out.push(arr.slice(i, i + size));\n  return out;\n}\n\n\u002F** Create keys in batches of 500 with rate-limit spacing. *\u002F\nexport async function batchCreateKeys(\n  client: LokaliseApi, projectId: string,\n  keys: Array\u003C{ key_name: { web: string }; platforms: string[]; tags?: string[];\n    translations?: Array\u003C{ language_iso: string; translation: string }> }>\n): Promise\u003C{ created: number; errors: Error[] }> {\n  const batches = chunk(keys, 500);\n  let created = 0;\n  const errors: Error[] = [];\n  for (let i = 0; i \u003C batches.length; i++) {\n    try {\n      const r = await client.keys().create({ project_id: projectId, keys: batches[i] });\n      created += r.items.length;\n    } catch (err) { errors.push(err as Error); }\n    if (i \u003C batches.length - 1) await new Promise((r) => setTimeout(r, 500));\n  }\n  return { created, errors };\n}\n\n\u002F** Delete keys in batches of 500. *\u002F\nexport async function batchDeleteKeys(\n  client: LokaliseApi, projectId: string, keyIds: number[]\n): Promise\u003Cnumber> {\n  const batches = chunk(keyIds, 500);\n  let deleted = 0;\n  for (let i = 0; i \u003C batches.length; i++) {\n    const r = await client.keys().bulk_delete(batches[i], { project_id: projectId });\n    deleted += r.keys_removed;\n    if (i \u003C batches.length - 1) await new Promise((r) => setTimeout(r, 500));\n  }\n  return deleted;\n}\n```\n\n5. Upload files with async process monitoring and progress callbacks.\n\n```typescript\n\u002F\u002F src\u002Flib\u002Fupload.ts\nimport { readFileSync } from \"node:fs\";\n\nexport async function uploadWithProgress(\n  client: LokaliseApi, projectId: string,\n  opts: { filePath: string; langIso: string; tags?: string[];\n    replaceModified?: boolean; cleanupMode?: boolean },\n  onProgress?: (status: string, elapsedMs: number) => void\n): Promise\u003C{ processId: string; status: string; durationMs: number }> {\n  const data = readFileSync(opts.filePath).toString(\"base64\");\n  const start = Date.now();\n\n  const proc = await client.files().upload(projectId, {\n    data,\n    filename: opts.filePath.split(\"\u002F\").pop()!,\n    lang_iso: opts.langIso,\n    replace_modified: opts.replaceModified ?? true,\n    cleanup_mode: opts.cleanupMode ?? false,\n    detect_icu_plurals: true,\n    tags: opts.tags,\n  });\n  onProgress?.(\"queued\", Date.now() - start);\n\n  \u002F\u002F Poll process status until terminal state\n  const maxWait = 120_000; \u002F\u002F 2 minutes\n  let last = proc.status;\n  while (Date.now() - start \u003C maxWait) {\n    await new Promise((r) => setTimeout(r, 1500));\n    const check = await client.queuedProcesses().get(proc.process_id, { project_id: projectId });\n    if (check.status !== last) { last = check.status; onProgress?.(last, Date.now() - start); }\n    if (check.status === \"finished\") return { processId: proc.process_id, status: \"finished\", durationMs: Date.now() - start };\n    if (check.status === \"cancelled\" || check.status === \"failed\") throw new Error(`Upload ${check.status}: ${JSON.stringify(check.details)}`);\n  }\n  throw new Error(`Upload timed out after ${maxWait}ms`);\n}\n```\n\nUsage:\n\n```typescript\nawait uploadWithProgress(client, \"123456.abcdef\", {\n  filePath: \".\u002Fsrc\u002Flocales\u002Fen.json\",\n  langIso: \"en\",\n  tags: [\"ci\"],\n  replaceModified: true,\n}, (status, ms) => console.log(`[${(ms \u002F 1000).toFixed(1)}s] ${status}`));\n```\n\n6. Add a retry decorator with exponential backoff and a rate limiter for sequential calls.\n\n```typescript\n\u002F\u002F src\u002Flib\u002Fretry.ts\n\u002F** Retry on 429 and 5xx with exponential backoff + jitter. *\u002F\nexport async function withRetry\u003CT>(\n  fn: () => Promise\u003CT>,\n  opts: { maxRetries?: number; baseDelayMs?: number; maxDelayMs?: number;\n    onRetry?: (attempt: number, err: Error, delayMs: number) => void } = {}\n): Promise\u003CT> {\n  const { maxRetries = 3, baseDelayMs = 1000, maxDelayMs = 10_000, onRetry } = opts;\n  let lastErr: Error | undefined;\n  for (let i = 0; i \u003C= maxRetries; i++) {\n    try { return await fn(); }\n    catch (err: unknown) {\n      lastErr = err as Error;\n      const code = (err as { code?: number })?.code;\n      if (!(code === 429 || (code && code >= 500)) || i === maxRetries) throw err;\n      const delay = Math.min(baseDelayMs * 2 ** i + Math.random() * 200, maxDelayMs);\n      onRetry?.(i + 1, lastErr, delay);\n      await new Promise((r) => setTimeout(r, delay));\n    }\n  }\n  throw lastErr;\n}\n\n\u002F** Enforce minimum spacing between calls (default: 170ms = 6 req\u002Fsec). *\u002F\nexport function rateLimited\u003CA extends unknown[], R>(\n  fn: (...args: A) => Promise\u003CR>, minMs = 170\n): (...args: A) => Promise\u003CR> {\n  let last = 0;\n  return async (...args) => {\n    const wait = minMs - (Date.now() - last);\n    if (wait > 0) await new Promise((r) => setTimeout(r, wait));\n    last = Date.now();\n    return fn(...args);\n  };\n}\n```\n\nUsage:\n\n```typescript\n\u002F\u002F Single call with retry\nconst keys = await withRetry(\n  () => client.keys().list({ project_id: pid, limit: 500 }),\n  { onRetry: (n, e, ms) => console.warn(`Retry ${n}: ${e.message} (${ms}ms)`) }\n);\n\n\u002F\u002F Rate-limited sequential calls\nconst listKeys = rateLimited((p: Record\u003Cstring, unknown>) => client.keys().list(p));\nconst p1 = await listKeys({ project_id: pid, page: 1, limit: 100 });\nconst p2 = await listKeys({ project_id: pid, page: 2, limit: 100 });\n```\n\n## Output\n\n- Singleton client with compression and branch support\n- Async generator for memory-efficient cursor pagination\n- Type-safe error wrapper with `isRetryable` classification\n- Batch create\u002Fdelete respecting 500-key API limit\n- File upload with process polling and progress callbacks\n- Retry with exponential backoff + rate limiter at 6 req\u002Fsec\n\n## Error Handling\n\n| Pattern | When to Use | Behavior |\n|---------|------------|----------|\n| `apiCall()` | Every SDK call | Converts to typed `LokaliseError` with `isRetryable` |\n| `withRetry()` | Rate limits or transient failures | Exponential backoff, retries 429 and 5xx only |\n| `rateLimited()` | Sequential bulk calls | Enforces 170ms minimum spacing |\n| `paginate()` | Fetching all keys\u002Ftranslations | Built-in 170ms delay between pages |\n| `batchCreateKeys()` | Creating > 500 keys | 500-key chunks with 500ms spacing |\n| `uploadWithProgress()` | File uploads | Polls process status with 2-minute timeout |\n\n## Examples\n\n### Combining All Patterns\n\n```typescript\nimport { getClient, projectId } from \".\u002Flib\u002Flokalise-client\";\nimport { paginateAll } from \".\u002Flib\u002Fpaginate\";\nimport { withRetry } from \".\u002Flib\u002Fretry\";\nimport { batchCreateKeys } from \".\u002Flib\u002Fbatch\";\nimport { uploadWithProgress } from \".\u002Flib\u002Fupload\";\n\nconst client = getClient();\nconst pid = projectId(\"123456.abcdef\", \"develop\");\n\n\u002F\u002F Upload, paginate, batch create, download — all with rate limiting and retry\nawait uploadWithProgress(client, pid, { filePath: \".\u002Fsrc\u002Flocales\u002Fen.json\", langIso: \"en\" },\n  (s, ms) => console.log(`[${ms}ms] ${s}`));\n\nconst allKeys = await paginateAll((p) => client.keys().list(p), { project_id: pid });\nconsole.log(`${allKeys.length} keys`);\n\nconst result = await batchCreateKeys(client, pid,\n  Array.from({ length: 1200 }, (_, i) => ({\n    key_name: { web: `gen.key_${i}` }, platforms: [\"web\"],\n    translations: [{ language_iso: \"en\", translation: `Val ${i}` }],\n  })));\nconsole.log(`Created ${result.created}, errors: ${result.errors.length}`);\n\nconst bundle = await withRetry(() => client.files().download(pid, {\n  format: \"json\", original_filenames: false, bundle_structure: \"%LANG_ISO%.json\",\n}));\nconsole.log(`Download: ${bundle.bundle_url}`);\n```\n\n## Resources\n\n- [Node SDK Documentation](https:\u002F\u002Flokalise.github.io\u002Fnode-lokalise-api\u002F)\n- [Pagination Guide](https:\u002F\u002Flokalise.github.io\u002Fnode-lokalise-api\u002Fapi\u002Fgetting-started.html)\n- [API Rate Limits](https:\u002F\u002Fdevelopers.lokalise.com\u002Freference\u002Fapi-rate-limits)\n- [API Error Codes](https:\u002F\u002Fdevelopers.lokalise.com\u002Freference\u002Fapi-errors)\n- [Branching](https:\u002F\u002Fdocs.lokalise.com\u002Fen\u002Farticles\u002F3049428-branching)\n\n## Next Steps\n\nApply these patterns in `lokalise-core-workflow-a` and `lokalise-core-workflow-b` for real-world usage.\n",{"name":5,"tags":24,"author":29,"license":15,"version":30,"description":31,"allowed-tools":32,"compatible-with":33},[25,26,27,28],"saas","lokalise","typescript","nodejs","Jeremy Longshore \u003Cjeremy@intentsolutions.io>","1.0.0","Apply production-ready Lokalise SDK patterns for TypeScript and Node.js.\nUse when implementing Lokalise integrations, refactoring SDK usage,\nor establishing team coding standards for Lokalise.\nTrigger with phrases like \"lokalise SDK patterns\", \"lokalise best practices\",\n\"lokalise code patterns\", \"idiomatic lokalise\".\n","Read, Write, Edit","claude-code, codex, openclaw","main","99825ad3f3bcc6597ddcc7294a14e6e922f2b67b","skills\u002Fsaas-packs--lokalise-pack--lokalise-sdk-patterns",0,"https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills","https:\u002F\u002Fgithub.com\u002Fjukeyman","https:\u002F\u002FRJBUSINESSSOLUTIONS.ORG","Credit and Finance Expert | Developer\r\n\r\nI'm Rick Jefferson, a seasoned credit and finance expert with over a decade of experience in financial literacy,","2026-07-13 07:03:29",{"source":8,"skillName":5,"commands":44,"prompt":54,"zipAvailable":55},[45,48,51],{"tool":46,"command":47},"npx","npx skills add jukeyman\u002Fjukeyman-skills --skill lokalise-sdk-patterns",{"tool":49,"command":50},"bunx","bunx skills add jukeyman\u002Fjukeyman-skills --skill lokalise-sdk-patterns",{"tool":52,"command":53},"pnpm","pnpm dlx skills add jukeyman\u002Fjukeyman-skills --skill lokalise-sdk-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--lokalise-pack--lokalise-sdk-patterns\u002FSKILL.md",true,[],[58,65,72,79,86,94],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M79ANS2SM329NEP5ZCX106RR","zustand-store-creator","Create zustand store creator operations. Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like \"zustand store creator\", \"zustand creator\", \"zustand\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M79AMZKP4YDEZ7EHG1Y7PP74","zero-trust-config-helper","Configure with zero trust config helper operations. Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like \"zero trust config helper\", \"zero helper\", \"zero\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M79AMJSBCEJQNBTYNAHYN5HM","zapier-integration-helper","Assist with zapier integration helper operations. Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like \"zapier integration helper\", \"zapier helper\", \"zapier\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M79AHJZGVMARS13VFQYRR1MP","yaml-config-validator","Validate yaml config validator operations. Auto-activating skill for DevOps Basics.\nTriggers on: yaml config validator, yaml config validator\nPart of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like \"yaml config validator\", \"yaml validator\", \"yaml\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyaml-config-validator\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":90,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M79AHGDZRN0020RDQSQDPAM8","xvary-stock-research","Thesis-driven equity analysis from public SEC EDGAR and market data; \u002Fanalyze, \u002Fscore, \u002Fcompare workflows with bundled Python tools (Claude Code, Cursor, Codex).","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M79AHCYJ9FV9RMHQ24HDRN33","xss-vulnerability-scanner","Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals.\nTriggers on: xss vulnerability scanner, xss vulnerability scanner\nPart of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like \"xss vulnerability scanner\", \"xss scanner\", \"xss\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxss-vulnerability-scanner\u002FSKILL.md",[],[]]