@lokalise/connector-api-contracts 1.9.2 → 1.10.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/contracts/cacheContracts.d.ts +20 -0
- package/dist/contracts/cacheContracts.js +20 -6
- package/dist/contracts/cacheContracts.js.map +1 -1
- package/dist/contracts/itemListContracts.js +5 -3
- package/dist/contracts/itemListContracts.js.map +1 -1
- package/dist/contracts/paginationSchemas.d.ts +36 -0
- package/dist/contracts/paginationSchemas.js +50 -0
- package/dist/contracts/paginationSchemas.js.map +1 -0
- package/dist/contracts/translateContracts.d.ts +10 -0
- package/dist/contracts/translateContracts.js +9 -4
- package/dist/contracts/translateContracts.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -28,6 +28,8 @@ export declare const PARTIAL_CACHE_ITEM_SCHEMA: z.ZodObject<{
|
|
|
28
28
|
*/
|
|
29
29
|
export declare const listCacheRequestQueryString: z.ZodObject<{
|
|
30
30
|
next: z.ZodOptional<z.ZodString>;
|
|
31
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
31
33
|
}, z.core.$strip>;
|
|
32
34
|
/**
|
|
33
35
|
* @deprecated Use `getItemList` API instead
|
|
@@ -39,6 +41,8 @@ export declare const listCacheResponseBody: z.ZodObject<{
|
|
|
39
41
|
metadata: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
40
42
|
}, z.core.$strip>>;
|
|
41
43
|
next: z.ZodOptional<z.ZodString>;
|
|
44
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
42
46
|
}, z.core.$strip>;
|
|
43
47
|
/**
|
|
44
48
|
* @deprecated Use `getItemList` API instead
|
|
@@ -52,6 +56,8 @@ export declare const cacheResponseBody: z.ZodObject<{
|
|
|
52
56
|
title: z.ZodString;
|
|
53
57
|
groupTitle: z.ZodString;
|
|
54
58
|
}, z.core.$strip>>;
|
|
59
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
60
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
55
61
|
}, z.core.$strip>;
|
|
56
62
|
/**
|
|
57
63
|
* @deprecated Use `getItemList` API instead
|
|
@@ -62,6 +68,8 @@ export declare const cacheRequestBody: z.ZodObject<{
|
|
|
62
68
|
groupId: z.ZodString;
|
|
63
69
|
metadata: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
64
70
|
}, z.core.$strip>>;
|
|
71
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
65
73
|
}, z.core.$strip>;
|
|
66
74
|
/**
|
|
67
75
|
* @deprecated Use `getItemList` API instead
|
|
@@ -104,8 +112,12 @@ export declare const getCacheContract: import("@lokalise/api-contracts").GetRout
|
|
|
104
112
|
groupId: z.ZodString;
|
|
105
113
|
metadata: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
106
114
|
}, z.core.$strip>>;
|
|
115
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
116
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
107
117
|
}, z.core.$strip>, undefined, z.ZodObject<{
|
|
108
118
|
next: z.ZodOptional<z.ZodString>;
|
|
119
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
120
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
109
121
|
}, z.core.$strip>, z.ZodObject<{
|
|
110
122
|
'ce-config': z.ZodString;
|
|
111
123
|
'ce-auth': z.ZodString;
|
|
@@ -118,6 +130,8 @@ export declare const getCacheContract: import("@lokalise/api-contracts").GetRout
|
|
|
118
130
|
metadata: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
119
131
|
}, z.core.$strip>>;
|
|
120
132
|
next: z.ZodOptional<z.ZodString>;
|
|
133
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
134
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
121
135
|
}, z.core.$strip>;
|
|
122
136
|
}>;
|
|
123
137
|
export declare const postCacheItemsContract: import("@lokalise/api-contracts").PayloadRouteDefinition<z.ZodObject<{
|
|
@@ -126,6 +140,8 @@ export declare const postCacheItemsContract: import("@lokalise/api-contracts").P
|
|
|
126
140
|
groupId: z.ZodString;
|
|
127
141
|
metadata: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
128
142
|
}, z.core.$strip>>;
|
|
143
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
144
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
129
145
|
}, z.core.$strip>, z.ZodObject<{
|
|
130
146
|
items: z.ZodArray<z.ZodObject<{
|
|
131
147
|
uniqueId: z.ZodString;
|
|
@@ -135,6 +151,8 @@ export declare const postCacheItemsContract: import("@lokalise/api-contracts").P
|
|
|
135
151
|
title: z.ZodString;
|
|
136
152
|
groupTitle: z.ZodString;
|
|
137
153
|
}, z.core.$strip>>;
|
|
154
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
155
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
138
156
|
}, z.core.$strip>, undefined, undefined, z.ZodObject<{
|
|
139
157
|
'ce-config': z.ZodString;
|
|
140
158
|
'ce-auth': z.ZodString;
|
|
@@ -149,5 +167,7 @@ export declare const postCacheItemsContract: import("@lokalise/api-contracts").P
|
|
|
149
167
|
title: z.ZodString;
|
|
150
168
|
groupTitle: z.ZodString;
|
|
151
169
|
}, z.core.$strip>>;
|
|
170
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
171
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
152
172
|
}, z.core.$strip>;
|
|
153
173
|
}>;
|
|
@@ -2,6 +2,7 @@ import { buildGetRoute, buildPayloadRoute } from '@lokalise/api-contracts';
|
|
|
2
2
|
import { z } from 'zod/v4';
|
|
3
3
|
import { isValidNextParam } from "../utils/nextParamUtils.js";
|
|
4
4
|
import { CONNECTOR_REQUEST_HEADERS_SCHEMA, ITEM_IDENTIFIER_SCHEMA } from "./commonSchemas.js";
|
|
5
|
+
import { PAGINATION_REQUEST_PARAMS_SCHEMA, PAGINATION_RESPONSE_METADATA_SCHEMA, } from "./paginationSchemas.js";
|
|
5
6
|
export const MAX_TITLE_LENGTH = 256;
|
|
6
7
|
/**
|
|
7
8
|
* @deprecated Use `getItemList` API instead
|
|
@@ -22,6 +23,9 @@ export const PARTIAL_CACHE_ITEM_SCHEMA = CACHE_ITEM_SCHEMA.extend({
|
|
|
22
23
|
*/
|
|
23
24
|
export const listCacheRequestQueryString = z
|
|
24
25
|
.object({
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use `cursor` instead
|
|
28
|
+
*/
|
|
25
29
|
next: z
|
|
26
30
|
.string()
|
|
27
31
|
.includes(':', {
|
|
@@ -29,28 +33,38 @@ export const listCacheRequestQueryString = z
|
|
|
29
33
|
})
|
|
30
34
|
.optional(),
|
|
31
35
|
})
|
|
36
|
+
.extend(PAGINATION_REQUEST_PARAMS_SCHEMA.shape)
|
|
32
37
|
.refine(({ next }) => !next || isValidNextParam(next), {
|
|
33
38
|
message: 'Must contain skip and limit numeric values divided by colon',
|
|
34
39
|
});
|
|
35
40
|
/**
|
|
36
41
|
* @deprecated Use `getItemList` API instead
|
|
37
42
|
*/
|
|
38
|
-
export const listCacheResponseBody = z
|
|
43
|
+
export const listCacheResponseBody = z
|
|
44
|
+
.object({
|
|
39
45
|
items: z.array(ITEM_IDENTIFIER_SCHEMA),
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Use `nextCursor` instead
|
|
48
|
+
*/
|
|
40
49
|
next: z.string().optional(),
|
|
41
|
-
})
|
|
50
|
+
})
|
|
51
|
+
.extend(PAGINATION_RESPONSE_METADATA_SCHEMA.shape);
|
|
42
52
|
/**
|
|
43
53
|
* @deprecated Use `getItemList` API instead
|
|
44
54
|
*/
|
|
45
|
-
export const cacheResponseBody = z
|
|
55
|
+
export const cacheResponseBody = z
|
|
56
|
+
.object({
|
|
46
57
|
items: z.array(CACHE_ITEM_SCHEMA),
|
|
47
|
-
})
|
|
58
|
+
})
|
|
59
|
+
.extend(PAGINATION_RESPONSE_METADATA_SCHEMA.shape);
|
|
48
60
|
/**
|
|
49
61
|
* @deprecated Use `getItemList` API instead
|
|
50
62
|
*/
|
|
51
|
-
export const cacheRequestBody = z
|
|
63
|
+
export const cacheRequestBody = z
|
|
64
|
+
.object({
|
|
52
65
|
items: z.array(ITEM_IDENTIFIER_SCHEMA),
|
|
53
|
-
})
|
|
66
|
+
})
|
|
67
|
+
.extend(PAGINATION_REQUEST_PARAMS_SCHEMA.shape);
|
|
54
68
|
/**
|
|
55
69
|
* @deprecated Use `getItemList` API instead
|
|
56
70
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheContracts.js","sourceRoot":"","sources":["../../src/contracts/cacheContracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC1E,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,gCAAgC,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"cacheContracts.js","sourceRoot":"","sources":["../../src/contracts/cacheContracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC1E,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,gCAAgC,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;A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EAAE,gBAAgB;IACnC,yBAAyB,EAAE,iBAAiB;IAC5C,2BAA2B,EAAE;QAC3B,GAAG,EAAE,iBAAiB;KACvB;IACD,mBAAmB,EAAE,gCAAgC;CACtD,CAAC,CAAA"}
|
|
@@ -6,10 +6,12 @@ import { MAX_TITLE_LENGTH } from "./cacheContracts.js";
|
|
|
6
6
|
import { COMMON_ERROR_RESPONSE_SCHEMA, CONNECTOR_REQUEST_HEADERS_SCHEMA, ITEM_IDENTIFIER_SCHEMA, } from "./commonSchemas.js";
|
|
7
7
|
export const itemListRequestQueryString = z.object({
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* If specified
|
|
9
|
+
* Maximum number of items to return in this response.
|
|
10
|
+
* If not specified, connector-specific default will be used.
|
|
11
|
+
* If specified value exceeds connector-specific default, the default value will be used instead.
|
|
12
|
+
* Connector should return min(limit, connector_default_limit).
|
|
11
13
|
*/
|
|
12
|
-
limit: z.coerce.number().optional(),
|
|
14
|
+
limit: z.coerce.number().int().positive().optional(),
|
|
13
15
|
/**
|
|
14
16
|
* Opaque connector-specific string that can be used to retrieve the next page of items.
|
|
15
17
|
* If not specified, the first page of items will be returned.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"itemListContracts.js","sourceRoot":"","sources":["../../src/contracts/itemListContracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EACL,4BAA4B,EAC5B,gCAAgC,EAChC,sBAAsB,GACvB,MAAM,oBAAoB,CAAA;AAE3B,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,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CAAA;AAE1E,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAC;IAC/C,YAAY,EAAE,GAAG,EAAE,CAAC,WAAW;IAC/B,WAAW,EAAE,6BAA6B;IAC1C,kBAAkB,EAAE,0BAA0B;IAC9C,yBAAyB,EAAE,oBAAoB;IAC/C,2BAA2B,EAAE;QAC3B,GAAG,EAAE,oBAAoB;QACzB,GAAG,EAAE,4BAA4B;KAClC;IACD,mBAAmB,EAAE,gCAAgC;CACtD,CAAC,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
/**
|
|
3
|
+
* Default maximum items to request from connectors per batch.
|
|
4
|
+
* Connectors may return fewer items based on their own constraints.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_MAX_ITEMS: 100;
|
|
7
|
+
/**
|
|
8
|
+
* Absolute maximum items limit to prevent excessive memory usage.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MAX_ITEMS_LIMIT: 1000;
|
|
11
|
+
/**
|
|
12
|
+
* Common pagination metadata included in connector responses.
|
|
13
|
+
* Used to indicate if more data is available and how to fetch it.
|
|
14
|
+
*/
|
|
15
|
+
export declare const PAGINATION_RESPONSE_METADATA_SCHEMA: z.ZodObject<{
|
|
16
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type PaginationResponseMetadata = z.infer<typeof PAGINATION_RESPONSE_METADATA_SCHEMA>;
|
|
20
|
+
/**
|
|
21
|
+
* Common request parameters for pagination.
|
|
22
|
+
* Connectors should return min(maxItems, connector_default_limit).
|
|
23
|
+
*/
|
|
24
|
+
export declare const PAGINATION_REQUEST_PARAMS_SCHEMA: z.ZodObject<{
|
|
25
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export type PaginationRequestParams = z.infer<typeof PAGINATION_REQUEST_PARAMS_SCHEMA>;
|
|
29
|
+
/**
|
|
30
|
+
* Helper to extend a response schema with pagination metadata
|
|
31
|
+
*/
|
|
32
|
+
export declare const withPaginationMetadata: <T extends z.ZodObject<z.ZodRawShape>>(schema: T) => z.ZodObject<{
|
|
33
|
+
readonly [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
34
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
/**
|
|
3
|
+
* Default maximum items to request from connectors per batch.
|
|
4
|
+
* Connectors may return fewer items based on their own constraints.
|
|
5
|
+
*/
|
|
6
|
+
export const DEFAULT_MAX_ITEMS = 100;
|
|
7
|
+
/**
|
|
8
|
+
* Absolute maximum items limit to prevent excessive memory usage.
|
|
9
|
+
*/
|
|
10
|
+
export const MAX_ITEMS_LIMIT = 1000;
|
|
11
|
+
/**
|
|
12
|
+
* Common pagination metadata included in connector responses.
|
|
13
|
+
* Used to indicate if more data is available and how to fetch it.
|
|
14
|
+
*/
|
|
15
|
+
export const PAGINATION_RESPONSE_METADATA_SCHEMA = z.object({
|
|
16
|
+
/**
|
|
17
|
+
* Indicates whether more items are available beyond this response
|
|
18
|
+
*/
|
|
19
|
+
hasMore: z.boolean().optional(),
|
|
20
|
+
/**
|
|
21
|
+
* Opaque cursor string to retrieve the next page of results.
|
|
22
|
+
* Format is connector-specific.
|
|
23
|
+
*/
|
|
24
|
+
nextCursor: z.string().optional(),
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Common request parameters for pagination.
|
|
28
|
+
* Connectors should return min(maxItems, connector_default_limit).
|
|
29
|
+
*/
|
|
30
|
+
export const PAGINATION_REQUEST_PARAMS_SCHEMA = z.object({
|
|
31
|
+
/**
|
|
32
|
+
* Maximum number of items to return in this response.
|
|
33
|
+
* If not specified, connector-specific default will be used.
|
|
34
|
+
* If specified value exceeds connector-specific default, the default value will be used instead.
|
|
35
|
+
*/
|
|
36
|
+
maxItems: z.number().int().positive().max(MAX_ITEMS_LIMIT).optional(),
|
|
37
|
+
/**
|
|
38
|
+
* Opaque cursor string to continue from a previous request.
|
|
39
|
+
* Should be the value of `nextCursor` from the previous response.
|
|
40
|
+
* If not specified, processing starts from the beginning.
|
|
41
|
+
*/
|
|
42
|
+
cursor: z.string().optional(),
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Helper to extend a response schema with pagination metadata
|
|
46
|
+
*/
|
|
47
|
+
export const withPaginationMetadata = (schema) => {
|
|
48
|
+
return schema.extend(PAGINATION_RESPONSE_METADATA_SCHEMA.shape);
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=paginationSchemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginationSchemas.js","sourceRoot":"","sources":["../../src/contracts/paginationSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAY,CAAA;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAa,CAAA;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1D;;OAEG;IACH,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC/B;;;OAGG;IACH,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAClC,CAAC,CAAA;AAIF;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD;;;;OAIG;IACH,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE;IACrE;;;;OAIG;IACH,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAA;AAIF;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAuC,MAAS,EAAE,EAAE;IACxF,OAAO,MAAM,CAAC,MAAM,CAAC,mCAAmC,CAAC,KAAK,CAAC,CAAA;AACjE,CAAC,CAAA"}
|
|
@@ -7,6 +7,8 @@ export declare const translateRequestBody: z.ZodObject<{
|
|
|
7
7
|
metadata: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
8
8
|
}, z.core.$strip>>;
|
|
9
9
|
defaultLocale: z.ZodString;
|
|
10
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
10
12
|
}, z.core.$strip>;
|
|
11
13
|
export declare const translateResponseBody: z.ZodObject<{
|
|
12
14
|
items: z.ZodArray<z.ZodObject<{
|
|
@@ -22,6 +24,8 @@ export declare const translateResponseBody: z.ZodObject<{
|
|
|
22
24
|
errors: z.ZodArray<z.ZodObject<{}, z.core.$loose>>;
|
|
23
25
|
}, z.core.$strip>;
|
|
24
26
|
}, z.core.$strip>>;
|
|
27
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
25
29
|
}, z.core.$strip>;
|
|
26
30
|
export type ReferenceProcessingMode = 'no-references-export' | 'export-all-references' | 'export-without-slugs';
|
|
27
31
|
export type TranslateRequestBody = z.infer<typeof translateRequestBody>;
|
|
@@ -34,6 +38,8 @@ export declare const postTranslateContract: import("@lokalise/api-contracts").Pa
|
|
|
34
38
|
metadata: z.ZodRecord<z.ZodAny, z.ZodAny>;
|
|
35
39
|
}, z.core.$strip>>;
|
|
36
40
|
defaultLocale: z.ZodString;
|
|
41
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
37
43
|
}, z.core.$strip>, z.ZodObject<{
|
|
38
44
|
items: z.ZodArray<z.ZodObject<{
|
|
39
45
|
uniqueId: z.ZodString;
|
|
@@ -48,6 +54,8 @@ export declare const postTranslateContract: import("@lokalise/api-contracts").Pa
|
|
|
48
54
|
errors: z.ZodArray<z.ZodObject<{}, z.core.$loose>>;
|
|
49
55
|
}, z.core.$strip>;
|
|
50
56
|
}, z.core.$strip>>;
|
|
57
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
51
59
|
}, z.core.$strip>, undefined, undefined, z.ZodObject<{
|
|
52
60
|
'ce-config': z.ZodString;
|
|
53
61
|
'ce-auth': z.ZodString;
|
|
@@ -67,6 +75,8 @@ export declare const postTranslateContract: import("@lokalise/api-contracts").Pa
|
|
|
67
75
|
errors: z.ZodArray<z.ZodObject<{}, z.core.$loose>>;
|
|
68
76
|
}, z.core.$strip>;
|
|
69
77
|
}, z.core.$strip>>;
|
|
78
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
70
80
|
}, z.core.$strip>;
|
|
71
81
|
403: z.ZodObject<{
|
|
72
82
|
statusCode: z.ZodNumber;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { buildPayloadRoute } from '@lokalise/api-contracts';
|
|
2
2
|
import { z } from 'zod/v4';
|
|
3
3
|
import { COMMON_ERROR_RESPONSE_SCHEMA, CONNECTOR_REQUEST_HEADERS_SCHEMA, CONTENT_ITEM_SCHEMA, ITEM_IDENTIFIER_SCHEMA, } from "./commonSchemas.js";
|
|
4
|
-
|
|
4
|
+
import { PAGINATION_REQUEST_PARAMS_SCHEMA, PAGINATION_RESPONSE_METADATA_SCHEMA, } from "./paginationSchemas.js";
|
|
5
|
+
export const translateRequestBody = z
|
|
6
|
+
.object({
|
|
5
7
|
locales: z.array(z.string()),
|
|
6
8
|
items: z.array(ITEM_IDENTIFIER_SCHEMA),
|
|
7
9
|
defaultLocale: z.string(),
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
+
})
|
|
11
|
+
.extend(PAGINATION_REQUEST_PARAMS_SCHEMA.shape);
|
|
12
|
+
export const translateResponseBody = z
|
|
13
|
+
.object({
|
|
10
14
|
items: z.array(CONTENT_ITEM_SCHEMA),
|
|
11
15
|
payload: z
|
|
12
16
|
.object({
|
|
@@ -17,7 +21,8 @@ export const translateResponseBody = z.object({
|
|
|
17
21
|
}),
|
|
18
22
|
})
|
|
19
23
|
.optional(),
|
|
20
|
-
})
|
|
24
|
+
})
|
|
25
|
+
.extend(PAGINATION_RESPONSE_METADATA_SCHEMA.shape);
|
|
21
26
|
export const postTranslateContract = buildPayloadRoute({
|
|
22
27
|
pathResolver: () => `/translate`,
|
|
23
28
|
method: 'post',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translateContracts.js","sourceRoot":"","sources":["../../src/contracts/translateContracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC1B,OAAO,EACL,4BAA4B,EAC5B,gCAAgC,EAChC,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"translateContracts.js","sourceRoot":"","sources":["../../src/contracts/translateContracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAC1B,OAAO,EACL,4BAA4B,EAC5B,gCAAgC,EAChC,mBAAmB,EACnB,sBAAsB,GACv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 @@ export * from './contracts/commonSchemas.ts';
|
|
|
4
4
|
export * from './contracts/connectorApiConstants.ts';
|
|
5
5
|
export * from './contracts/envContracts.ts';
|
|
6
6
|
export * from './contracts/itemListContracts.ts';
|
|
7
|
+
export * from './contracts/paginationSchemas.ts';
|
|
7
8
|
export * from './contracts/publishContracts.ts';
|
|
8
9
|
export * from './contracts/translateContracts.ts';
|
|
9
10
|
export * from './utils/nextParamUtils.ts';
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./contracts/commonSchemas.js";
|
|
|
4
4
|
export * from "./contracts/connectorApiConstants.js";
|
|
5
5
|
export * from "./contracts/envContracts.js";
|
|
6
6
|
export * from "./contracts/itemListContracts.js";
|
|
7
|
+
export * from "./contracts/paginationSchemas.js";
|
|
7
8
|
export * from "./contracts/publishContracts.js";
|
|
8
9
|
export * from "./contracts/translateContracts.js";
|
|
9
10
|
export * from "./utils/nextParamUtils.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,sCAAsC,CAAA;AACpD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kCAAkC,CAAA;AAChD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,mCAAmC,CAAA;AACjD,cAAc,2BAA2B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,sCAAsC,CAAA;AACpD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kCAAkC,CAAA;AAChD,cAAc,kCAAkC,CAAA;AAChD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,mCAAmC,CAAA;AACjD,cAAc,2BAA2B,CAAA"}
|