@lingo.dev/_sdk 0.10.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.cjs CHANGED
@@ -10,11 +10,13 @@ var engineParamsSchema = _zod2.default.object({
10
10
  }).passthrough();
11
11
  var payloadSchema = _zod2.default.record(_zod2.default.string(), _zod2.default.any());
12
12
  var referenceSchema = _zod2.default.record(__spec.localeCodeSchema, payloadSchema);
13
+ var hintsSchema = _zod2.default.record(_zod2.default.string(), _zod2.default.array(_zod2.default.string()));
13
14
  var localizationParamsSchema = _zod2.default.object({
14
15
  sourceLocale: _zod2.default.union([__spec.localeCodeSchema, _zod2.default.null()]),
15
16
  targetLocale: __spec.localeCodeSchema,
16
17
  fast: _zod2.default.boolean().optional(),
17
- reference: referenceSchema.optional()
18
+ reference: referenceSchema.optional(),
19
+ hints: hintsSchema.optional()
18
20
  });
19
21
  var LingoDotDevEngine = class {
20
22
 
@@ -48,7 +50,7 @@ var LingoDotDevEngine = class {
48
50
  const processedPayloadChunk = await this.localizeChunk(
49
51
  finalParams.sourceLocale,
50
52
  finalParams.targetLocale,
51
- { data: chunk, reference: params.reference },
53
+ { data: chunk, reference: params.reference, hints: params.hints },
52
54
  workflowId,
53
55
  params.fast || false,
54
56
  signal
@@ -85,7 +87,8 @@ var LingoDotDevEngine = class {
85
87
  target: targetLocale
86
88
  },
87
89
  data: payload.data,
88
- reference: payload.reference
90
+ reference: payload.reference,
91
+ hints: payload.hints
89
92
  },
90
93
  null,
91
94
  2
@@ -217,6 +220,26 @@ var LingoDotDevEngine = class {
217
220
  );
218
221
  return responses;
219
222
  }
223
+ /**
224
+ * Localize an array of strings
225
+ * @param strings - An array of strings to be localized
226
+ * @param params - Localization parameters:
227
+ * - sourceLocale: The source language code (e.g., 'en')
228
+ * - targetLocale: The target language code (e.g., 'es')
229
+ * - fast: Optional boolean to enable fast mode (faster for bigger batches)
230
+ * @returns An array of localized strings in the same order
231
+ */
232
+ async localizeStringArray(strings, params) {
233
+ const mapped = strings.reduce(
234
+ (acc, str, i) => {
235
+ acc[`item_${i}`] = str;
236
+ return acc;
237
+ },
238
+ {}
239
+ );
240
+ const result = await this.localizeObject(mapped, params);
241
+ return Object.values(result);
242
+ }
220
243
  /**
221
244
  * Localize a chat sequence while preserving speaker names
222
245
  * @param chat - Array of chat messages, each with 'name' and 'text' properties
package/build/index.d.cts CHANGED
@@ -23,16 +23,19 @@ declare const localizationParamsSchema: Z.ZodObject<{
23
23
  targetLocale: Z.ZodEffects<Z.ZodString, string, string>;
24
24
  fast: Z.ZodOptional<Z.ZodBoolean>;
25
25
  reference: Z.ZodOptional<Z.ZodRecord<Z.ZodEffects<Z.ZodString, string, string>, Z.ZodRecord<Z.ZodString, Z.ZodAny>>>;
26
+ hints: Z.ZodOptional<Z.ZodRecord<Z.ZodString, Z.ZodArray<Z.ZodString, "many">>>;
26
27
  }, "strip", Z.ZodTypeAny, {
27
28
  sourceLocale: string | null;
28
29
  targetLocale: string;
29
30
  fast?: boolean | undefined;
30
31
  reference?: Record<string, Record<string, any>> | undefined;
32
+ hints?: Record<string, string[]> | undefined;
31
33
  }, {
32
34
  sourceLocale: string | null;
33
35
  targetLocale: string;
34
36
  fast?: boolean | undefined;
35
37
  reference?: Record<string, Record<string, any>> | undefined;
38
+ hints?: Record<string, string[]> | undefined;
36
39
  }>;
37
40
  /**
38
41
  * LingoDotDevEngine class for interacting with the LingoDotDev API
@@ -118,6 +121,16 @@ declare class LingoDotDevEngine {
118
121
  targetLocales: LocaleCode[];
119
122
  fast?: boolean;
120
123
  }, signal?: AbortSignal): Promise<string[]>;
124
+ /**
125
+ * Localize an array of strings
126
+ * @param strings - An array of strings to be localized
127
+ * @param params - Localization parameters:
128
+ * - sourceLocale: The source language code (e.g., 'en')
129
+ * - targetLocale: The target language code (e.g., 'es')
130
+ * - fast: Optional boolean to enable fast mode (faster for bigger batches)
131
+ * @returns An array of localized strings in the same order
132
+ */
133
+ localizeStringArray(strings: string[], params: Z.infer<typeof localizationParamsSchema>): Promise<string[]>;
121
134
  /**
122
135
  * Localize a chat sequence while preserving speaker names
123
136
  * @param chat - Array of chat messages, each with 'name' and 'text' properties
package/build/index.d.ts CHANGED
@@ -23,16 +23,19 @@ declare const localizationParamsSchema: Z.ZodObject<{
23
23
  targetLocale: Z.ZodEffects<Z.ZodString, string, string>;
24
24
  fast: Z.ZodOptional<Z.ZodBoolean>;
25
25
  reference: Z.ZodOptional<Z.ZodRecord<Z.ZodEffects<Z.ZodString, string, string>, Z.ZodRecord<Z.ZodString, Z.ZodAny>>>;
26
+ hints: Z.ZodOptional<Z.ZodRecord<Z.ZodString, Z.ZodArray<Z.ZodString, "many">>>;
26
27
  }, "strip", Z.ZodTypeAny, {
27
28
  sourceLocale: string | null;
28
29
  targetLocale: string;
29
30
  fast?: boolean | undefined;
30
31
  reference?: Record<string, Record<string, any>> | undefined;
32
+ hints?: Record<string, string[]> | undefined;
31
33
  }, {
32
34
  sourceLocale: string | null;
33
35
  targetLocale: string;
34
36
  fast?: boolean | undefined;
35
37
  reference?: Record<string, Record<string, any>> | undefined;
38
+ hints?: Record<string, string[]> | undefined;
36
39
  }>;
37
40
  /**
38
41
  * LingoDotDevEngine class for interacting with the LingoDotDev API
@@ -118,6 +121,16 @@ declare class LingoDotDevEngine {
118
121
  targetLocales: LocaleCode[];
119
122
  fast?: boolean;
120
123
  }, signal?: AbortSignal): Promise<string[]>;
124
+ /**
125
+ * Localize an array of strings
126
+ * @param strings - An array of strings to be localized
127
+ * @param params - Localization parameters:
128
+ * - sourceLocale: The source language code (e.g., 'en')
129
+ * - targetLocale: The target language code (e.g., 'es')
130
+ * - fast: Optional boolean to enable fast mode (faster for bigger batches)
131
+ * @returns An array of localized strings in the same order
132
+ */
133
+ localizeStringArray(strings: string[], params: Z.infer<typeof localizationParamsSchema>): Promise<string[]>;
121
134
  /**
122
135
  * Localize a chat sequence while preserving speaker names
123
136
  * @param chat - Array of chat messages, each with 'name' and 'text' properties
package/build/index.mjs CHANGED
@@ -10,11 +10,13 @@ var engineParamsSchema = Z.object({
10
10
  }).passthrough();
11
11
  var payloadSchema = Z.record(Z.string(), Z.any());
12
12
  var referenceSchema = Z.record(localeCodeSchema, payloadSchema);
13
+ var hintsSchema = Z.record(Z.string(), Z.array(Z.string()));
13
14
  var localizationParamsSchema = Z.object({
14
15
  sourceLocale: Z.union([localeCodeSchema, Z.null()]),
15
16
  targetLocale: localeCodeSchema,
16
17
  fast: Z.boolean().optional(),
17
- reference: referenceSchema.optional()
18
+ reference: referenceSchema.optional(),
19
+ hints: hintsSchema.optional()
18
20
  });
19
21
  var LingoDotDevEngine = class {
20
22
  config;
@@ -48,7 +50,7 @@ var LingoDotDevEngine = class {
48
50
  const processedPayloadChunk = await this.localizeChunk(
49
51
  finalParams.sourceLocale,
50
52
  finalParams.targetLocale,
51
- { data: chunk, reference: params.reference },
53
+ { data: chunk, reference: params.reference, hints: params.hints },
52
54
  workflowId,
53
55
  params.fast || false,
54
56
  signal
@@ -85,7 +87,8 @@ var LingoDotDevEngine = class {
85
87
  target: targetLocale
86
88
  },
87
89
  data: payload.data,
88
- reference: payload.reference
90
+ reference: payload.reference,
91
+ hints: payload.hints
89
92
  },
90
93
  null,
91
94
  2
@@ -217,6 +220,26 @@ var LingoDotDevEngine = class {
217
220
  );
218
221
  return responses;
219
222
  }
223
+ /**
224
+ * Localize an array of strings
225
+ * @param strings - An array of strings to be localized
226
+ * @param params - Localization parameters:
227
+ * - sourceLocale: The source language code (e.g., 'en')
228
+ * - targetLocale: The target language code (e.g., 'es')
229
+ * - fast: Optional boolean to enable fast mode (faster for bigger batches)
230
+ * @returns An array of localized strings in the same order
231
+ */
232
+ async localizeStringArray(strings, params) {
233
+ const mapped = strings.reduce(
234
+ (acc, str, i) => {
235
+ acc[`item_${i}`] = str;
236
+ return acc;
237
+ },
238
+ {}
239
+ );
240
+ const result = await this.localizeObject(mapped, params);
241
+ return Object.values(result);
242
+ }
220
243
  /**
221
244
  * Localize a chat sequence while preserving speaker names
222
245
  * @param chat - Array of chat messages, each with 'name' and 'text' properties
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingo.dev/_sdk",
3
- "version": "0.10.2",
3
+ "version": "0.12.0",
4
4
  "description": "Lingo.dev JS SDK",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -21,7 +21,7 @@
21
21
  "@paralleldrive/cuid2": "^2.2.2",
22
22
  "jsdom": "^25.0.1",
23
23
  "zod": "^3.25.76",
24
- "@lingo.dev/_spec": "0.39.3"
24
+ "@lingo.dev/_spec": "0.40.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/jsdom": "^21.1.7",
@@ -31,7 +31,8 @@
31
31
  },
32
32
  "scripts": {
33
33
  "dev": "tsup --watch",
34
- "build": "tsc --noEmit && tsup",
34
+ "build": "pnpm typecheck && tsup",
35
+ "typecheck": "tsc --noEmit",
35
36
  "test": "vitest run"
36
37
  }
37
38
  }