@lokalise/tm-sdk 5.0.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/sdk/TranslationMemoryClient.d.ts +2 -2
- package/dist/sdk/TranslationMemoryClient.js +13 -17
- package/dist/sdk/TranslationMemoryClient.js.map +1 -1
- package/dist/sdk/types/apiResponses.d.ts +57 -12
- package/dist/sdk/types/apiResponses.js +13 -1
- package/dist/sdk/types/apiResponses.js.map +1 -1
- package/dist/sdk/types/models.d.ts +43 -19
- package/dist/sdk/types/models.js +38 -1
- package/dist/sdk/types/models.js.map +1 -1
- package/package.json +15 -14
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export * from './sdk/TranslationMemoryClient.js';
|
|
|
2
2
|
export * from './sdk/errors/TranslationMemoryClientError.js';
|
|
3
3
|
export * from './sdk/types/requests.js';
|
|
4
4
|
export * from './sdk/types/models.js';
|
|
5
|
+
export * from './sdk/types/apiResponses.js';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA;AAChD,cAAc,8CAA8C,CAAA;AAC5D,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA;AAChD,cAAc,8CAA8C,CAAA;AAC5D,cAAc,yBAAyB,CAAA;AACvC,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA"}
|
|
@@ -2,7 +2,7 @@ import type { MandatoryPaginationParams } from '@lokalise/api-common';
|
|
|
2
2
|
import type { RequestContext } from '@lokalise/fastify-extras';
|
|
3
3
|
import { type ErrorReporter } from '@lokalise/node-core';
|
|
4
4
|
import type { RetryConfig } from 'undici-retry';
|
|
5
|
-
import type { BulkTranslationMemoryMatches, TranslationMemoryRecord, TranslationMemoryRecordsResponse,
|
|
5
|
+
import type { BulkTranslationMemoryMatches, TranslationMemoryRecord, TranslationMemoryRecordsResponse, UpsertTranslationMemoryRecordDto } from './types/models.js';
|
|
6
6
|
import type { BulkFindMatchesRequest, FindMatchesRequest } from './types/requests.js';
|
|
7
7
|
export type TranslationMemoryClientConfig = {
|
|
8
8
|
baseUrl: string;
|
|
@@ -27,7 +27,7 @@ export declare class TranslationMemoryClient {
|
|
|
27
27
|
bulkFindMatches(groupId: string, { filters, options }: BulkFindMatchesRequest, context?: TranslationMemoryClientContext): Promise<BulkTranslationMemoryMatches[]>;
|
|
28
28
|
bulkFindMatchesIterative(groupId: string, { filters, options }: BulkFindMatchesRequest, context?: TranslationMemoryClientContext): AsyncGenerator<BulkTranslationMemoryMatches[]>;
|
|
29
29
|
getRecords(groupId: string, pagination?: MandatoryPaginationParams, context?: TranslationMemoryClientContext): Promise<TranslationMemoryRecordsResponse>;
|
|
30
|
-
upsertRecords(groupId: string, records:
|
|
30
|
+
upsertRecords(groupId: string, records: UpsertTranslationMemoryRecordDto[], context?: TranslationMemoryClientContext): Promise<void>;
|
|
31
31
|
private internalBulkFindMatches;
|
|
32
32
|
private handleError;
|
|
33
33
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { buildClient, isResponseStatusError, sendGet, sendPost, sendPut, } from '@lokalise/backend-http-client';
|
|
2
2
|
import { InternalError } from '@lokalise/node-core';
|
|
3
3
|
import { chunk, transformToKebabCase } from '@lokalise/universal-ts-utils/node';
|
|
4
|
-
import { z } from 'zod';
|
|
4
|
+
import { z } from 'zod/v4';
|
|
5
5
|
import { TranslationMemoryClientError } from './errors/TranslationMemoryClientError.js';
|
|
6
|
-
|
|
6
|
+
import { GET_FIND_MATCHES_RESPONSE_SCHEMA, GET_TRANSLATION_MEMORY_RECORDS_RESPONSE_SCHEMA, POST_BULK_FIND_MATCHES_RESPONSE_SCHEMA, } from './types/apiResponses.js';
|
|
7
7
|
export class TranslationMemoryClient {
|
|
8
8
|
maxFindMatchesRequestSize = 20;
|
|
9
9
|
isEnabled;
|
|
@@ -35,15 +35,14 @@ export class TranslationMemoryClient {
|
|
|
35
35
|
this.errorReporter = config.errorReporter;
|
|
36
36
|
}
|
|
37
37
|
async findMatches(groupId, request, context = {}) {
|
|
38
|
-
if (!this.isEnabled)
|
|
38
|
+
if (!this.isEnabled)
|
|
39
39
|
return [];
|
|
40
|
-
}
|
|
41
40
|
try {
|
|
42
41
|
const response = await sendGet(this.httpClient, `/v1/groups/${groupId}/actions/find-matches`, {
|
|
43
42
|
reqContext: context.reqContext,
|
|
44
43
|
headers: this.headers,
|
|
45
|
-
responseSchema:
|
|
46
|
-
validateResponse:
|
|
44
|
+
responseSchema: GET_FIND_MATCHES_RESPONSE_SCHEMA,
|
|
45
|
+
validateResponse: true,
|
|
47
46
|
retryConfig: this.retryConfig,
|
|
48
47
|
requestLabel: '(tm-sdk) Find matches',
|
|
49
48
|
query: transformToKebabCase(request),
|
|
@@ -81,8 +80,8 @@ export class TranslationMemoryClient {
|
|
|
81
80
|
const response = await sendGet(this.httpClient, `/v1/groups/${groupId}/records`, {
|
|
82
81
|
reqContext: context.reqContext,
|
|
83
82
|
headers: this.headers,
|
|
84
|
-
validateResponse:
|
|
85
|
-
responseSchema:
|
|
83
|
+
validateResponse: true,
|
|
84
|
+
responseSchema: GET_TRANSLATION_MEMORY_RECORDS_RESPONSE_SCHEMA,
|
|
86
85
|
retryConfig: this.retryConfig,
|
|
87
86
|
requestLabel: '(tm-sdk) Get records',
|
|
88
87
|
query: pagination,
|
|
@@ -94,19 +93,17 @@ export class TranslationMemoryClient {
|
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
async upsertRecords(groupId, records, context = {}) {
|
|
97
|
-
if (!this.isEnabled)
|
|
96
|
+
if (!this.isEnabled)
|
|
98
97
|
return;
|
|
99
|
-
}
|
|
100
98
|
// Avoiding sending empty records
|
|
101
99
|
const recordsToInsert = records.filter((record) => record.sourceText.trim().length > 0 && record.targetText.trim().length > 0);
|
|
102
|
-
if (recordsToInsert.length === 0)
|
|
100
|
+
if (recordsToInsert.length === 0)
|
|
103
101
|
return;
|
|
104
|
-
}
|
|
105
102
|
try {
|
|
106
103
|
await sendPut(this.httpClient, `/v1/groups/${groupId}/records`, recordsToInsert, {
|
|
107
104
|
reqContext: context.reqContext,
|
|
108
105
|
headers: this.headers,
|
|
109
|
-
responseSchema:
|
|
106
|
+
responseSchema: z.any(),
|
|
110
107
|
validateResponse: false,
|
|
111
108
|
retryConfig: this.retryConfig,
|
|
112
109
|
requestLabel: '(tm-sdk) Create or update records',
|
|
@@ -118,9 +115,8 @@ export class TranslationMemoryClient {
|
|
|
118
115
|
}
|
|
119
116
|
async internalBulkFindMatches(groupId, request, context) {
|
|
120
117
|
const result = [];
|
|
121
|
-
if (!this.isEnabled)
|
|
118
|
+
if (!this.isEnabled)
|
|
122
119
|
return result;
|
|
123
|
-
}
|
|
124
120
|
if (request.options?.ignoreEmptyFilters) {
|
|
125
121
|
const { emptyFilters, nonEmptyFilters } = request.filters.reduce((acc, filter) => {
|
|
126
122
|
const list = filter.sourceText.trim().length === 0 ? acc.emptyFilters : acc.nonEmptyFilters;
|
|
@@ -140,8 +136,8 @@ export class TranslationMemoryClient {
|
|
|
140
136
|
const response = await sendPost(this.httpClient, `/v1/groups/${groupId}/actions/bulk-find-matches`, request, {
|
|
141
137
|
reqContext: context.reqContext,
|
|
142
138
|
headers: this.headers,
|
|
143
|
-
responseSchema:
|
|
144
|
-
validateResponse:
|
|
139
|
+
responseSchema: POST_BULK_FIND_MATCHES_RESPONSE_SCHEMA,
|
|
140
|
+
validateResponse: true,
|
|
145
141
|
retryConfig: this.retryConfig,
|
|
146
142
|
requestLabel: '(tm-sdk) Bulk find matches',
|
|
147
143
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranslationMemoryClient.js","sourceRoot":"","sources":["../../src/sdk/TranslationMemoryClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,OAAO,EACP,QAAQ,EACR,OAAO,GACR,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAsB,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACvE,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"TranslationMemoryClient.js","sourceRoot":"","sources":["../../src/sdk/TranslationMemoryClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,qBAAqB,EACrB,OAAO,EACP,QAAQ,EACR,OAAO,GACR,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAsB,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACvE,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AAI/E,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC1B,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAA;AACvF,OAAO,EACL,gCAAgC,EAChC,8CAA8C,EAC9C,sCAAsC,GACvC,MAAM,yBAAyB,CAAA;AA0BhC,MAAM,OAAO,uBAAuB;IACjB,yBAAyB,GAAG,EAAE,CAAA;IAE9B,SAAS,CAAS;IAClB,UAAU,CAAQ;IAClB,OAAO,CAAyB;IAChC,WAAW,CAAa;IAExB,aAAa,CAAgB;IAE9C,YAAY,MAAqC;QAC/C,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,IAAI,CAAA;QACzC,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QAC7C,IAAI,CAAC,OAAO,GAAG;YACb,cAAc,EAA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5
|
+
groupId: z.ZodString;
|
|
6
|
+
ownerId: z.ZodGUID;
|
|
7
|
+
sourceLocale: z.ZodString;
|
|
8
|
+
targetLocale: z.ZodString;
|
|
9
|
+
sourceText: z.ZodString;
|
|
10
|
+
targetText: z.ZodString;
|
|
11
|
+
sourcePrevContent: z.ZodOptional<z.ZodString>;
|
|
12
|
+
sourceNextContent: z.ZodOptional<z.ZodString>;
|
|
13
|
+
createdAt: z.ZodISODateTime;
|
|
14
|
+
updatedAt: z.ZodISODateTime;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type GetFindMatchesResponse = z.infer<typeof GET_FIND_MATCHES_RESPONSE_SCHEMA>;
|
|
18
|
+
export declare const GET_TRANSLATION_MEMORY_RECORDS_RESPONSE_SCHEMA: z.ZodObject<{
|
|
19
|
+
data: z.ZodArray<z.ZodObject<{
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
groupId: z.ZodString;
|
|
22
|
+
ownerId: z.ZodGUID;
|
|
23
|
+
sourceLocale: z.ZodString;
|
|
24
|
+
targetLocale: z.ZodString;
|
|
25
|
+
sourceText: z.ZodString;
|
|
26
|
+
targetText: z.ZodString;
|
|
27
|
+
sourcePrevContent: z.ZodOptional<z.ZodString>;
|
|
28
|
+
sourceNextContent: z.ZodOptional<z.ZodString>;
|
|
29
|
+
createdAt: z.ZodISODateTime;
|
|
30
|
+
updatedAt: z.ZodISODateTime;
|
|
31
|
+
}, z.core.$strip>>;
|
|
32
|
+
meta: z.ZodObject<{
|
|
33
|
+
count: z.ZodNumber;
|
|
34
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
35
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type GetTranslationMemoryRecordsResponse = z.infer<typeof GET_TRANSLATION_MEMORY_RECORDS_RESPONSE_SCHEMA>;
|
|
39
|
+
export declare const POST_BULK_FIND_MATCHES_RESPONSE_SCHEMA: z.ZodObject<{
|
|
40
|
+
data: z.ZodArray<z.ZodObject<{
|
|
41
|
+
filterId: z.ZodOptional<z.ZodString>;
|
|
42
|
+
matches: z.ZodArray<z.ZodObject<{
|
|
43
|
+
id: z.ZodString;
|
|
44
|
+
groupId: z.ZodString;
|
|
45
|
+
ownerId: z.ZodGUID;
|
|
46
|
+
sourceLocale: z.ZodString;
|
|
47
|
+
targetLocale: z.ZodString;
|
|
48
|
+
sourceText: z.ZodString;
|
|
49
|
+
targetText: z.ZodString;
|
|
50
|
+
sourcePrevContent: z.ZodOptional<z.ZodString>;
|
|
51
|
+
sourceNextContent: z.ZodOptional<z.ZodString>;
|
|
52
|
+
createdAt: z.ZodISODateTime;
|
|
53
|
+
updatedAt: z.ZodISODateTime;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
}, z.core.$strip>>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
export type PostBulkFindMatchesResponse = z.infer<typeof POST_BULK_FIND_MATCHES_RESPONSE_SCHEMA>;
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { zMeta } from '@lokalise/api-common';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
import { BULK_TRANSLATION_MEMORY_MATCHES_SCHEMA, TRANSLATION_MEMORY_RECORD_SCHEMA, } from './models.js';
|
|
4
|
+
export const GET_FIND_MATCHES_RESPONSE_SCHEMA = z.object({
|
|
5
|
+
data: z.array(TRANSLATION_MEMORY_RECORD_SCHEMA),
|
|
6
|
+
});
|
|
7
|
+
export const GET_TRANSLATION_MEMORY_RECORDS_RESPONSE_SCHEMA = z.object({
|
|
8
|
+
data: z.array(TRANSLATION_MEMORY_RECORD_SCHEMA),
|
|
9
|
+
meta: zMeta,
|
|
10
|
+
});
|
|
11
|
+
export const POST_BULK_FIND_MATCHES_RESPONSE_SCHEMA = z.object({
|
|
12
|
+
data: z.array(BULK_TRANSLATION_MEMORY_MATCHES_SCHEMA),
|
|
13
|
+
});
|
|
2
14
|
//# sourceMappingURL=apiResponses.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiResponses.js","sourceRoot":"","sources":["../../../src/sdk/types/apiResponses.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"apiResponses.js","sourceRoot":"","sources":["../../../src/sdk/types/apiResponses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC1B,OAAO,EACL,sCAAsC,EACtC,gCAAgC,GACjC,MAAM,aAAa,CAAA;AAEpB,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,gCAAgC,CAAC;CAChD,CAAC,CAAA;AAGF,MAAM,CAAC,MAAM,8CAA8C,GAAG,CAAC,CAAC,MAAM,CAAC;IACrE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,gCAAgC,CAAC;IAC/C,IAAI,EAAE,KAAK;CACZ,CAAC,CAAA;AAKF,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7D,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,sCAAsC,CAAC;CACtD,CAAC,CAAA"}
|
|
@@ -1,23 +1,47 @@
|
|
|
1
1
|
import type { PaginationMeta } from '@lokalise/api-common';
|
|
2
|
-
import
|
|
3
|
-
export
|
|
4
|
-
id:
|
|
5
|
-
groupId:
|
|
6
|
-
ownerId:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
sourcePrevContent
|
|
12
|
-
sourceNextContent
|
|
13
|
-
createdAt:
|
|
14
|
-
updatedAt:
|
|
15
|
-
}
|
|
16
|
-
export type
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
export declare const TRANSLATION_MEMORY_RECORD_SCHEMA: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
groupId: z.ZodString;
|
|
6
|
+
ownerId: z.ZodGUID;
|
|
7
|
+
sourceLocale: z.ZodString;
|
|
8
|
+
targetLocale: z.ZodString;
|
|
9
|
+
sourceText: z.ZodString;
|
|
10
|
+
targetText: z.ZodString;
|
|
11
|
+
sourcePrevContent: z.ZodOptional<z.ZodString>;
|
|
12
|
+
sourceNextContent: z.ZodOptional<z.ZodString>;
|
|
13
|
+
createdAt: z.ZodISODateTime;
|
|
14
|
+
updatedAt: z.ZodISODateTime;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type TranslationMemoryRecord = z.infer<typeof TRANSLATION_MEMORY_RECORD_SCHEMA>;
|
|
17
|
+
export declare const UPSERT_TRANSLATION_MEMORY_RECORD_DTO_SCHEMA: z.ZodObject<{
|
|
18
|
+
id: z.ZodOptional<z.ZodString>;
|
|
19
|
+
ownerId: z.ZodGUID;
|
|
20
|
+
sourceLocale: z.ZodString;
|
|
21
|
+
targetLocale: z.ZodString;
|
|
22
|
+
sourceText: z.ZodString;
|
|
23
|
+
targetText: z.ZodString;
|
|
24
|
+
sourcePrevContent: z.ZodOptional<z.ZodString>;
|
|
25
|
+
sourceNextContent: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type UpsertTranslationMemoryRecordDto = z.infer<typeof UPSERT_TRANSLATION_MEMORY_RECORD_DTO_SCHEMA>;
|
|
28
|
+
export declare const BULK_TRANSLATION_MEMORY_MATCHES_SCHEMA: z.ZodObject<{
|
|
29
|
+
filterId: z.ZodOptional<z.ZodString>;
|
|
30
|
+
matches: z.ZodArray<z.ZodObject<{
|
|
31
|
+
id: z.ZodString;
|
|
32
|
+
groupId: z.ZodString;
|
|
33
|
+
ownerId: z.ZodGUID;
|
|
34
|
+
sourceLocale: z.ZodString;
|
|
35
|
+
targetLocale: z.ZodString;
|
|
36
|
+
sourceText: z.ZodString;
|
|
37
|
+
targetText: z.ZodString;
|
|
38
|
+
sourcePrevContent: z.ZodOptional<z.ZodString>;
|
|
39
|
+
sourceNextContent: z.ZodOptional<z.ZodString>;
|
|
40
|
+
createdAt: z.ZodISODateTime;
|
|
41
|
+
updatedAt: z.ZodISODateTime;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type BulkTranslationMemoryMatches = z.infer<typeof BULK_TRANSLATION_MEMORY_MATCHES_SCHEMA>;
|
|
21
45
|
export type TranslationMemoryRecordsResponse = {
|
|
22
46
|
records: TranslationMemoryRecord[];
|
|
23
47
|
meta: PaginationMeta;
|
package/dist/sdk/types/models.js
CHANGED
|
@@ -1,2 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import { isSupportedLocale } from '@lokalise/supported-languages';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
const LOCALE_SCHEMA = z.string().min(1).refine(isSupportedLocale, {
|
|
4
|
+
message: 'Unsupported locale',
|
|
5
|
+
});
|
|
6
|
+
export const TRANSLATION_MEMORY_RECORD_SCHEMA = z.object({
|
|
7
|
+
id: z.string().nonempty().describe('Unique record ID, generated by TM service'),
|
|
8
|
+
groupId: z
|
|
9
|
+
.string()
|
|
10
|
+
.min(1)
|
|
11
|
+
.describe('Identifier of an isolated group of records (e.g. can be used to separate searches per different projects). Can be any non-empty string'),
|
|
12
|
+
ownerId: z
|
|
13
|
+
.guid()
|
|
14
|
+
.describe('Unique identifier of a record owner - only owner can UPDATE or DELETE such record'),
|
|
15
|
+
sourceLocale: LOCALE_SCHEMA.describe('Source language tag (locale), e.g. "de" or "en-CA"'),
|
|
16
|
+
targetLocale: LOCALE_SCHEMA.describe('Target language tag (locale), e.g. "de" or "en-CA"'),
|
|
17
|
+
sourceText: z.string().min(1).describe('Translation text in source language'),
|
|
18
|
+
targetText: z.string().min(1).describe('Translation text in target language'),
|
|
19
|
+
sourcePrevContent: z
|
|
20
|
+
.string()
|
|
21
|
+
.min(1)
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('Text that appears right before the seeked translation'),
|
|
24
|
+
sourceNextContent: z
|
|
25
|
+
.string()
|
|
26
|
+
.min(1)
|
|
27
|
+
.optional()
|
|
28
|
+
.describe('Text that appears right after the seeked translation'),
|
|
29
|
+
createdAt: z.iso.datetime().describe('Timestamp of record creation, generated by TM service'),
|
|
30
|
+
updatedAt: z.iso.datetime().describe('Timestamp of record creation, generated by TM service'),
|
|
31
|
+
});
|
|
32
|
+
export const UPSERT_TRANSLATION_MEMORY_RECORD_DTO_SCHEMA = TRANSLATION_MEMORY_RECORD_SCHEMA.partial({ id: true }).omit({ groupId: true, createdAt: true, updatedAt: true });
|
|
33
|
+
export const BULK_TRANSLATION_MEMORY_MATCHES_SCHEMA = z.object({
|
|
34
|
+
filterId: z.string().min(1).optional().describe('Individual results ID'),
|
|
35
|
+
matches: z
|
|
36
|
+
.array(TRANSLATION_MEMORY_RECORD_SCHEMA)
|
|
37
|
+
.describe('Array of translation memory records'),
|
|
38
|
+
});
|
|
2
39
|
//# sourceMappingURL=models.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/sdk/types/models.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/sdk/types/models.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,EAAE;IAChE,OAAO,EAAE,oBAAoB;CAC9B,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,g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,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;AAK3D,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7D,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IACxE,OAAO,EAAE,CAAC;SACP,KAAK,CAAC,gCAAgC,CAAC;SACvC,QAAQ,CAAC,qCAAqC,CAAC;CACnD,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lokalise/tm-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Lokalise",
|
|
@@ -34,29 +34,30 @@
|
|
|
34
34
|
"postversion": "biome check --write package.json"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@lokalise/api-common": "^
|
|
38
|
-
"@lokalise/backend-http-client": "^
|
|
39
|
-
"@lokalise/id-utils": "^3.0.
|
|
40
|
-
"@lokalise/node-core": "^14.
|
|
41
|
-
"@lokalise/
|
|
42
|
-
"
|
|
37
|
+
"@lokalise/api-common": "^6.0.0",
|
|
38
|
+
"@lokalise/backend-http-client": "^7.0.0",
|
|
39
|
+
"@lokalise/id-utils": "^3.0.1",
|
|
40
|
+
"@lokalise/node-core": "^14.1.0",
|
|
41
|
+
"@lokalise/supported-languages": "^3.1.0",
|
|
42
|
+
"@lokalise/universal-ts-utils": "^4.5.0",
|
|
43
|
+
"undici": "^7.10.0",
|
|
43
44
|
"undici-retry": "^6.0.0"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
46
|
-
"zod": "
|
|
47
|
+
"zod": ">=3.25.76 <5.0.0"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@biomejs/biome": "^1.9.4",
|
|
50
51
|
"@lokalise/biome-config": "^2.0.0",
|
|
51
|
-
"@lokalise/
|
|
52
|
-
"@lokalise/
|
|
53
|
-
"@types/node": "
|
|
54
|
-
"@vitest/coverage-v8": "^3.
|
|
52
|
+
"@lokalise/fastify-extras": "^29.0.0",
|
|
53
|
+
"@lokalise/tsconfig": "^2.0.0",
|
|
54
|
+
"@types/node": "24.0.3",
|
|
55
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
55
56
|
"mockttp": "^3.17.1",
|
|
56
57
|
"rimraf": "^6.0.1",
|
|
57
|
-
"shx": "^0.
|
|
58
|
+
"shx": "^0.4.0",
|
|
58
59
|
"typescript": "5.8.3",
|
|
59
60
|
"vitest": "^3.0.2",
|
|
60
|
-
"zod": "^3.
|
|
61
|
+
"zod": "^3.25.76"
|
|
61
62
|
}
|
|
62
63
|
}
|