@lingo.dev/_sdk 0.15.2 → 0.16.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 +16 -39
- package/build/index.d.cts +1 -2
- package/build/index.d.ts +1 -2
- package/build/index.mjs +16 -39
- package/package.json +2 -2
package/build/index.cjs
CHANGED
|
@@ -63,10 +63,10 @@ async function getDistinctId(apiKey, apiUrl) {
|
|
|
63
63
|
const cached = identityCache.get(apiKey);
|
|
64
64
|
if (cached) return cached;
|
|
65
65
|
try {
|
|
66
|
-
const res = await fetch(`${apiUrl}/
|
|
67
|
-
method: "
|
|
66
|
+
const res = await fetch(`${apiUrl}/users/me`, {
|
|
67
|
+
method: "GET",
|
|
68
68
|
headers: {
|
|
69
|
-
|
|
69
|
+
"X-API-Key": apiKey,
|
|
70
70
|
"Content-Type": "application/json"
|
|
71
71
|
}
|
|
72
72
|
});
|
|
@@ -95,7 +95,7 @@ async function getDistinctId(apiKey, apiUrl) {
|
|
|
95
95
|
// src/index.ts
|
|
96
96
|
var engineParamsSchema = _zod2.default.object({
|
|
97
97
|
apiKey: _zod2.default.string(),
|
|
98
|
-
apiUrl: _zod2.default.string().url().default("https://
|
|
98
|
+
apiUrl: _zod2.default.string().url().default("https://api.lingo.dev"),
|
|
99
99
|
batchSize: _zod2.default.number().int().gt(0).lte(250).default(25),
|
|
100
100
|
idealBatchItemSize: _zod2.default.number().int().gt(0).lte(2500).default(250),
|
|
101
101
|
engineId: _zod2.default.string().optional()
|
|
@@ -115,16 +115,10 @@ var localizationParamsSchema = _zod2.default.object({
|
|
|
115
115
|
var LingoDotDevEngine = (_class = class {
|
|
116
116
|
|
|
117
117
|
__init() {this.sessionId = _cuid2.createId.call(void 0, )}
|
|
118
|
-
get isVNext() {
|
|
119
|
-
return !!this.config.engineId;
|
|
120
|
-
}
|
|
121
118
|
get headers() {
|
|
122
|
-
return
|
|
119
|
+
return {
|
|
123
120
|
"Content-Type": "application/json; charset=utf-8",
|
|
124
121
|
"X-API-Key": this.config.apiKey
|
|
125
|
-
} : {
|
|
126
|
-
"Content-Type": "application/json; charset=utf-8",
|
|
127
|
-
Authorization: `Bearer ${this.config.apiKey}`
|
|
128
122
|
};
|
|
129
123
|
}
|
|
130
124
|
/**
|
|
@@ -132,11 +126,7 @@ var LingoDotDevEngine = (_class = class {
|
|
|
132
126
|
* @param config - Configuration options for the Engine
|
|
133
127
|
*/
|
|
134
128
|
constructor(config) {;_class.prototype.__init.call(this);
|
|
135
|
-
|
|
136
|
-
if (!config.apiUrl && parsed.engineId) {
|
|
137
|
-
parsed.apiUrl = "https://api.lingo.dev";
|
|
138
|
-
}
|
|
139
|
-
this.config = parsed;
|
|
129
|
+
this.config = engineParamsSchema.parse(config);
|
|
140
130
|
}
|
|
141
131
|
/**
|
|
142
132
|
* Localize content using the Lingo.dev API
|
|
@@ -183,13 +173,13 @@ var LingoDotDevEngine = (_class = class {
|
|
|
183
173
|
* @param workflowId - Workflow ID for tracking
|
|
184
174
|
* @param fast - Whether to use fast mode
|
|
185
175
|
* @param filePath - Optional file path for metadata
|
|
186
|
-
* @param triggerType - Optional trigger type
|
|
176
|
+
* @param triggerType - Optional trigger type
|
|
187
177
|
* @param signal - Optional AbortSignal to cancel the operation
|
|
188
178
|
* @returns Localized chunk
|
|
189
179
|
*/
|
|
190
180
|
async localizeChunk(sourceLocale, targetLocale, payload, workflowId, fast, filePath, triggerType, signal) {
|
|
191
|
-
const url =
|
|
192
|
-
const body =
|
|
181
|
+
const url = `${this.config.apiUrl}/process/localize`;
|
|
182
|
+
const body = {
|
|
193
183
|
params: { fast },
|
|
194
184
|
sourceLocale,
|
|
195
185
|
targetLocale,
|
|
@@ -198,16 +188,8 @@ var LingoDotDevEngine = (_class = class {
|
|
|
198
188
|
hints: payload.hints,
|
|
199
189
|
sessionId: this.sessionId,
|
|
200
190
|
triggerType,
|
|
201
|
-
metadata: filePath ? { filePath } : void 0
|
|
202
|
-
|
|
203
|
-
params: { workflowId, fast },
|
|
204
|
-
locale: {
|
|
205
|
-
source: sourceLocale,
|
|
206
|
-
target: targetLocale
|
|
207
|
-
},
|
|
208
|
-
data: payload.data,
|
|
209
|
-
reference: payload.reference,
|
|
210
|
-
hints: payload.hints
|
|
191
|
+
metadata: filePath ? { filePath } : void 0,
|
|
192
|
+
...this.config.engineId && { engineId: this.config.engineId }
|
|
211
193
|
};
|
|
212
194
|
const res = await fetch(url, {
|
|
213
195
|
method: "POST",
|
|
@@ -677,7 +659,7 @@ var LingoDotDevEngine = (_class = class {
|
|
|
677
659
|
trackProps
|
|
678
660
|
);
|
|
679
661
|
try {
|
|
680
|
-
const url =
|
|
662
|
+
const url = `${this.config.apiUrl}/process/recognize`;
|
|
681
663
|
const response = await fetch(url, {
|
|
682
664
|
method: "POST",
|
|
683
665
|
headers: this.headers,
|
|
@@ -714,16 +696,11 @@ var LingoDotDevEngine = (_class = class {
|
|
|
714
696
|
}
|
|
715
697
|
}
|
|
716
698
|
async whoami(signal) {
|
|
717
|
-
|
|
718
|
-
return { email: "vnext-user", id: this.config.engineId };
|
|
719
|
-
}
|
|
699
|
+
const url = `${this.config.apiUrl}/users/me`;
|
|
720
700
|
try {
|
|
721
|
-
const res = await fetch(
|
|
722
|
-
method: "
|
|
723
|
-
headers:
|
|
724
|
-
Authorization: `Bearer ${this.config.apiKey}`,
|
|
725
|
-
"Content-Type": "application/json"
|
|
726
|
-
},
|
|
701
|
+
const res = await fetch(url, {
|
|
702
|
+
method: "GET",
|
|
703
|
+
headers: this.headers,
|
|
727
704
|
signal
|
|
728
705
|
});
|
|
729
706
|
if (res.ok) {
|
package/build/index.d.cts
CHANGED
|
@@ -29,7 +29,6 @@ declare const localizationParamsSchema: Z.ZodObject<{
|
|
|
29
29
|
declare class LingoDotDevEngine {
|
|
30
30
|
protected config: Z.infer<typeof engineParamsSchema>;
|
|
31
31
|
private readonly sessionId;
|
|
32
|
-
private get isVNext();
|
|
33
32
|
private get headers();
|
|
34
33
|
/**
|
|
35
34
|
* Create a new LingoDotDevEngine instance
|
|
@@ -54,7 +53,7 @@ declare class LingoDotDevEngine {
|
|
|
54
53
|
* @param workflowId - Workflow ID for tracking
|
|
55
54
|
* @param fast - Whether to use fast mode
|
|
56
55
|
* @param filePath - Optional file path for metadata
|
|
57
|
-
* @param triggerType - Optional trigger type
|
|
56
|
+
* @param triggerType - Optional trigger type
|
|
58
57
|
* @param signal - Optional AbortSignal to cancel the operation
|
|
59
58
|
* @returns Localized chunk
|
|
60
59
|
*/
|
package/build/index.d.ts
CHANGED
|
@@ -29,7 +29,6 @@ declare const localizationParamsSchema: Z.ZodObject<{
|
|
|
29
29
|
declare class LingoDotDevEngine {
|
|
30
30
|
protected config: Z.infer<typeof engineParamsSchema>;
|
|
31
31
|
private readonly sessionId;
|
|
32
|
-
private get isVNext();
|
|
33
32
|
private get headers();
|
|
34
33
|
/**
|
|
35
34
|
* Create a new LingoDotDevEngine instance
|
|
@@ -54,7 +53,7 @@ declare class LingoDotDevEngine {
|
|
|
54
53
|
* @param workflowId - Workflow ID for tracking
|
|
55
54
|
* @param fast - Whether to use fast mode
|
|
56
55
|
* @param filePath - Optional file path for metadata
|
|
57
|
-
* @param triggerType - Optional trigger type
|
|
56
|
+
* @param triggerType - Optional trigger type
|
|
58
57
|
* @param signal - Optional AbortSignal to cancel the operation
|
|
59
58
|
* @returns Localized chunk
|
|
60
59
|
*/
|
package/build/index.mjs
CHANGED
|
@@ -63,10 +63,10 @@ async function getDistinctId(apiKey, apiUrl) {
|
|
|
63
63
|
const cached = identityCache.get(apiKey);
|
|
64
64
|
if (cached) return cached;
|
|
65
65
|
try {
|
|
66
|
-
const res = await fetch(`${apiUrl}/
|
|
67
|
-
method: "
|
|
66
|
+
const res = await fetch(`${apiUrl}/users/me`, {
|
|
67
|
+
method: "GET",
|
|
68
68
|
headers: {
|
|
69
|
-
|
|
69
|
+
"X-API-Key": apiKey,
|
|
70
70
|
"Content-Type": "application/json"
|
|
71
71
|
}
|
|
72
72
|
});
|
|
@@ -95,7 +95,7 @@ async function getDistinctId(apiKey, apiUrl) {
|
|
|
95
95
|
// src/index.ts
|
|
96
96
|
var engineParamsSchema = Z.object({
|
|
97
97
|
apiKey: Z.string(),
|
|
98
|
-
apiUrl: Z.string().url().default("https://
|
|
98
|
+
apiUrl: Z.string().url().default("https://api.lingo.dev"),
|
|
99
99
|
batchSize: Z.number().int().gt(0).lte(250).default(25),
|
|
100
100
|
idealBatchItemSize: Z.number().int().gt(0).lte(2500).default(250),
|
|
101
101
|
engineId: Z.string().optional()
|
|
@@ -115,16 +115,10 @@ var localizationParamsSchema = Z.object({
|
|
|
115
115
|
var LingoDotDevEngine = class {
|
|
116
116
|
config;
|
|
117
117
|
sessionId = createId();
|
|
118
|
-
get isVNext() {
|
|
119
|
-
return !!this.config.engineId;
|
|
120
|
-
}
|
|
121
118
|
get headers() {
|
|
122
|
-
return
|
|
119
|
+
return {
|
|
123
120
|
"Content-Type": "application/json; charset=utf-8",
|
|
124
121
|
"X-API-Key": this.config.apiKey
|
|
125
|
-
} : {
|
|
126
|
-
"Content-Type": "application/json; charset=utf-8",
|
|
127
|
-
Authorization: `Bearer ${this.config.apiKey}`
|
|
128
122
|
};
|
|
129
123
|
}
|
|
130
124
|
/**
|
|
@@ -132,11 +126,7 @@ var LingoDotDevEngine = class {
|
|
|
132
126
|
* @param config - Configuration options for the Engine
|
|
133
127
|
*/
|
|
134
128
|
constructor(config) {
|
|
135
|
-
|
|
136
|
-
if (!config.apiUrl && parsed.engineId) {
|
|
137
|
-
parsed.apiUrl = "https://api.lingo.dev";
|
|
138
|
-
}
|
|
139
|
-
this.config = parsed;
|
|
129
|
+
this.config = engineParamsSchema.parse(config);
|
|
140
130
|
}
|
|
141
131
|
/**
|
|
142
132
|
* Localize content using the Lingo.dev API
|
|
@@ -183,13 +173,13 @@ var LingoDotDevEngine = class {
|
|
|
183
173
|
* @param workflowId - Workflow ID for tracking
|
|
184
174
|
* @param fast - Whether to use fast mode
|
|
185
175
|
* @param filePath - Optional file path for metadata
|
|
186
|
-
* @param triggerType - Optional trigger type
|
|
176
|
+
* @param triggerType - Optional trigger type
|
|
187
177
|
* @param signal - Optional AbortSignal to cancel the operation
|
|
188
178
|
* @returns Localized chunk
|
|
189
179
|
*/
|
|
190
180
|
async localizeChunk(sourceLocale, targetLocale, payload, workflowId, fast, filePath, triggerType, signal) {
|
|
191
|
-
const url =
|
|
192
|
-
const body =
|
|
181
|
+
const url = `${this.config.apiUrl}/process/localize`;
|
|
182
|
+
const body = {
|
|
193
183
|
params: { fast },
|
|
194
184
|
sourceLocale,
|
|
195
185
|
targetLocale,
|
|
@@ -198,16 +188,8 @@ var LingoDotDevEngine = class {
|
|
|
198
188
|
hints: payload.hints,
|
|
199
189
|
sessionId: this.sessionId,
|
|
200
190
|
triggerType,
|
|
201
|
-
metadata: filePath ? { filePath } : void 0
|
|
202
|
-
|
|
203
|
-
params: { workflowId, fast },
|
|
204
|
-
locale: {
|
|
205
|
-
source: sourceLocale,
|
|
206
|
-
target: targetLocale
|
|
207
|
-
},
|
|
208
|
-
data: payload.data,
|
|
209
|
-
reference: payload.reference,
|
|
210
|
-
hints: payload.hints
|
|
191
|
+
metadata: filePath ? { filePath } : void 0,
|
|
192
|
+
...this.config.engineId && { engineId: this.config.engineId }
|
|
211
193
|
};
|
|
212
194
|
const res = await fetch(url, {
|
|
213
195
|
method: "POST",
|
|
@@ -677,7 +659,7 @@ var LingoDotDevEngine = class {
|
|
|
677
659
|
trackProps
|
|
678
660
|
);
|
|
679
661
|
try {
|
|
680
|
-
const url =
|
|
662
|
+
const url = `${this.config.apiUrl}/process/recognize`;
|
|
681
663
|
const response = await fetch(url, {
|
|
682
664
|
method: "POST",
|
|
683
665
|
headers: this.headers,
|
|
@@ -714,16 +696,11 @@ var LingoDotDevEngine = class {
|
|
|
714
696
|
}
|
|
715
697
|
}
|
|
716
698
|
async whoami(signal) {
|
|
717
|
-
|
|
718
|
-
return { email: "vnext-user", id: this.config.engineId };
|
|
719
|
-
}
|
|
699
|
+
const url = `${this.config.apiUrl}/users/me`;
|
|
720
700
|
try {
|
|
721
|
-
const res = await fetch(
|
|
722
|
-
method: "
|
|
723
|
-
headers:
|
|
724
|
-
Authorization: `Bearer ${this.config.apiKey}`,
|
|
725
|
-
"Content-Type": "application/json"
|
|
726
|
-
},
|
|
701
|
+
const res = await fetch(url, {
|
|
702
|
+
method: "GET",
|
|
703
|
+
headers: this.headers,
|
|
727
704
|
signal
|
|
728
705
|
});
|
|
729
706
|
if (res.ok) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingo.dev/_sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Lingo.dev JS SDK",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"jsdom": "25.0.1",
|
|
29
29
|
"posthog-node": "5.14.0",
|
|
30
30
|
"zod": "4.1.12",
|
|
31
|
-
"@lingo.dev/_spec": "0.
|
|
31
|
+
"@lingo.dev/_spec": "0.49.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/jsdom": "21.1.7",
|