@localness/contract 0.4.1 → 0.4.2
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.mts +111 -3
- package/dist/index.mjs +73 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -127,12 +127,30 @@ export declare const deliveryKeysSchema: z.ZodObject<{
|
|
|
127
127
|
}, z.core.$strip>;
|
|
128
128
|
export type DeliveryKeys = z.infer<typeof deliveryKeysSchema>;
|
|
129
129
|
export declare const deliveryLocaleStateNameSchema: z.ZodEnum<{
|
|
130
|
-
outdated: "outdated";
|
|
131
130
|
draft: "draft";
|
|
132
131
|
published: "published";
|
|
132
|
+
outdated: "outdated";
|
|
133
133
|
unpublished: "unpublished";
|
|
134
134
|
}>;
|
|
135
135
|
export type DeliveryLocaleStateName = z.infer<typeof deliveryLocaleStateNameSchema>;
|
|
136
|
+
/** One key as `/keys/states` lists it; the key write routes answer with it too. */
|
|
137
|
+
export declare const deliveryKeyStateSchema: z.ZodObject<{
|
|
138
|
+
id: z.ZodNumber;
|
|
139
|
+
key: z.ZodString;
|
|
140
|
+
releaseIds: z.ZodArray<z.ZodNumber>;
|
|
141
|
+
draft: z.ZodBoolean;
|
|
142
|
+
locales: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
143
|
+
draftText: z.ZodNullable<z.ZodString>;
|
|
144
|
+
publishedText: z.ZodNullable<z.ZodString>;
|
|
145
|
+
state: z.ZodEnum<{
|
|
146
|
+
draft: "draft";
|
|
147
|
+
published: "published";
|
|
148
|
+
outdated: "outdated";
|
|
149
|
+
unpublished: "unpublished";
|
|
150
|
+
}>;
|
|
151
|
+
}, z.core.$strip>>;
|
|
152
|
+
}, z.core.$strip>;
|
|
153
|
+
export type DeliveryKeyState = z.infer<typeof deliveryKeyStateSchema>;
|
|
136
154
|
/**
|
|
137
155
|
* `GET /api/v1/keys/states` — per-key, per-locale state, drafts included.
|
|
138
156
|
* Unlike every other delivery shape this carries draft text: a read token sees
|
|
@@ -149,9 +167,9 @@ export declare const deliveryKeyStatesSchema: z.ZodObject<{
|
|
|
149
167
|
draftText: z.ZodNullable<z.ZodString>;
|
|
150
168
|
publishedText: z.ZodNullable<z.ZodString>;
|
|
151
169
|
state: z.ZodEnum<{
|
|
152
|
-
outdated: "outdated";
|
|
153
170
|
draft: "draft";
|
|
154
171
|
published: "published";
|
|
172
|
+
outdated: "outdated";
|
|
155
173
|
unpublished: "unpublished";
|
|
156
174
|
}>;
|
|
157
175
|
}, z.core.$strip>>;
|
|
@@ -334,4 +352,94 @@ export declare const capturePageSchema: z.ZodObject<{
|
|
|
334
352
|
releaseIds: z.ZodArray<z.ZodNumber>;
|
|
335
353
|
}, z.core.$strip>>;
|
|
336
354
|
}, z.core.$strip>;
|
|
337
|
-
export type CapturePage = z.infer<typeof capturePageSchema>;
|
|
355
|
+
export type CapturePage = z.infer<typeof capturePageSchema>;
|
|
356
|
+
/**
|
|
357
|
+
* Response shapes of the key write routes an IDE plugin uses: create a key from
|
|
358
|
+
* text in code, name it, and edit its drafts. Same versioning rule as
|
|
359
|
+
* `delivery.ts`. A key created with a name publishes its source text; every
|
|
360
|
+
* other write lands in drafts, and publishing stays in the web app.
|
|
361
|
+
*/
|
|
362
|
+
/**
|
|
363
|
+
* `POST /api/v1/keys` and `PATCH /api/v1/keys`. The key comes back in the
|
|
364
|
+
* `/keys/states` shape, so a plugin can drop it straight into that cache.
|
|
365
|
+
*/
|
|
366
|
+
export declare const keyWriteResultSchema: z.ZodObject<{
|
|
367
|
+
sourceLocale: z.ZodString;
|
|
368
|
+
created: z.ZodBoolean;
|
|
369
|
+
key: z.ZodObject<{
|
|
370
|
+
id: z.ZodNumber;
|
|
371
|
+
key: z.ZodString;
|
|
372
|
+
releaseIds: z.ZodArray<z.ZodNumber>;
|
|
373
|
+
draft: z.ZodBoolean;
|
|
374
|
+
locales: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
375
|
+
draftText: z.ZodNullable<z.ZodString>;
|
|
376
|
+
publishedText: z.ZodNullable<z.ZodString>;
|
|
377
|
+
state: z.ZodEnum<{
|
|
378
|
+
draft: "draft";
|
|
379
|
+
published: "published";
|
|
380
|
+
outdated: "outdated";
|
|
381
|
+
unpublished: "unpublished";
|
|
382
|
+
}>;
|
|
383
|
+
}, z.core.$strip>>;
|
|
384
|
+
}, z.core.$strip>;
|
|
385
|
+
}, z.core.$strip>;
|
|
386
|
+
export type KeyWriteResult = z.infer<typeof keyWriteResultSchema>;
|
|
387
|
+
/**
|
|
388
|
+
* The `data` of a `PATCH /api/v1/keys` 409: a locale's draft no longer matches
|
|
389
|
+
* the `expected` the client sent. Nothing was written; `key` is the current
|
|
390
|
+
* state to diff against before retrying.
|
|
391
|
+
*/
|
|
392
|
+
export declare const keyDraftConflictSchema: z.ZodObject<{
|
|
393
|
+
locales: z.ZodArray<z.ZodString>;
|
|
394
|
+
key: z.ZodObject<{
|
|
395
|
+
id: z.ZodNumber;
|
|
396
|
+
key: z.ZodString;
|
|
397
|
+
releaseIds: z.ZodArray<z.ZodNumber>;
|
|
398
|
+
draft: z.ZodBoolean;
|
|
399
|
+
locales: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
400
|
+
draftText: z.ZodNullable<z.ZodString>;
|
|
401
|
+
publishedText: z.ZodNullable<z.ZodString>;
|
|
402
|
+
state: z.ZodEnum<{
|
|
403
|
+
draft: "draft";
|
|
404
|
+
published: "published";
|
|
405
|
+
outdated: "outdated";
|
|
406
|
+
unpublished: "unpublished";
|
|
407
|
+
}>;
|
|
408
|
+
}, z.core.$strip>>;
|
|
409
|
+
}, z.core.$strip>;
|
|
410
|
+
}, z.core.$strip>;
|
|
411
|
+
export type KeyDraftConflict = z.infer<typeof keyDraftConflictSchema>;
|
|
412
|
+
export declare const keyViolationSchema: z.ZodEnum<{
|
|
413
|
+
prefix: "prefix";
|
|
414
|
+
charset: "charset";
|
|
415
|
+
segment: "segment";
|
|
416
|
+
case: "case";
|
|
417
|
+
depth: "depth";
|
|
418
|
+
}>;
|
|
419
|
+
/**
|
|
420
|
+
* `POST /api/v1/keys/suggest-name` — the web app's AI key naming, under the
|
|
421
|
+
* project's key convention. `key` is empty when the text has nothing nameable.
|
|
422
|
+
*/
|
|
423
|
+
export declare const keyNameSuggestionSchema: z.ZodObject<{
|
|
424
|
+
source: z.ZodString;
|
|
425
|
+
key: z.ZodString;
|
|
426
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
427
|
+
alternatives: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
428
|
+
key: z.ZodString;
|
|
429
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
430
|
+
}, z.core.$strip>>>;
|
|
431
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
432
|
+
violations: z.ZodArray<z.ZodEnum<{
|
|
433
|
+
prefix: "prefix";
|
|
434
|
+
charset: "charset";
|
|
435
|
+
segment: "segment";
|
|
436
|
+
case: "case";
|
|
437
|
+
depth: "depth";
|
|
438
|
+
}>>;
|
|
439
|
+
duplicates: z.ZodArray<z.ZodObject<{
|
|
440
|
+
key: z.ZodString;
|
|
441
|
+
sourceText: z.ZodString;
|
|
442
|
+
sameSourceText: z.ZodBoolean;
|
|
443
|
+
}, z.core.$strip>>;
|
|
444
|
+
}, z.core.$strip>;
|
|
445
|
+
export type KeyNameSuggestion = z.infer<typeof keyNameSuggestionSchema>;
|
package/dist/index.mjs
CHANGED
|
@@ -134,6 +134,19 @@ const deliveryLocaleStateNameSchema = z.enum([
|
|
|
134
134
|
"outdated",
|
|
135
135
|
"unpublished"
|
|
136
136
|
]);
|
|
137
|
+
/** One key as `/keys/states` lists it; the key write routes answer with it too. */
|
|
138
|
+
const deliveryKeyStateSchema = z.object({
|
|
139
|
+
id: z.number(),
|
|
140
|
+
key: z.string(),
|
|
141
|
+
releaseIds: z.array(z.number()),
|
|
142
|
+
/** True while the key still has unpublished edits or was never published. */
|
|
143
|
+
draft: z.boolean(),
|
|
144
|
+
locales: z.record(z.string(), z.object({
|
|
145
|
+
draftText: z.string().nullable(),
|
|
146
|
+
publishedText: z.string().nullable(),
|
|
147
|
+
state: deliveryLocaleStateNameSchema
|
|
148
|
+
}))
|
|
149
|
+
});
|
|
137
150
|
/**
|
|
138
151
|
* `GET /api/v1/keys/states` — per-key, per-locale state, drafts included.
|
|
139
152
|
* Unlike every other delivery shape this carries draft text: a read token sees
|
|
@@ -141,18 +154,7 @@ const deliveryLocaleStateNameSchema = z.enum([
|
|
|
141
154
|
*/
|
|
142
155
|
const deliveryKeyStatesSchema = z.object({
|
|
143
156
|
sourceLocale: z.string(),
|
|
144
|
-
keys: z.array(
|
|
145
|
-
id: z.number(),
|
|
146
|
-
key: z.string(),
|
|
147
|
-
releaseIds: z.array(z.number()),
|
|
148
|
-
/** True while the key still has unpublished edits or was never published. */
|
|
149
|
-
draft: z.boolean(),
|
|
150
|
-
locales: z.record(z.string(), z.object({
|
|
151
|
-
draftText: z.string().nullable(),
|
|
152
|
-
publishedText: z.string().nullable(),
|
|
153
|
-
state: deliveryLocaleStateNameSchema
|
|
154
|
-
}))
|
|
155
|
-
})),
|
|
157
|
+
keys: z.array(deliveryKeyStateSchema),
|
|
156
158
|
/** Keys in scope, before paging. */
|
|
157
159
|
total: z.number(),
|
|
158
160
|
offset: z.number(),
|
|
@@ -254,4 +256,62 @@ const capturePageSchema = z.object({
|
|
|
254
256
|
releaseIds: z.array(z.number()),
|
|
255
257
|
tags: z.array(captureTagSchema)
|
|
256
258
|
});
|
|
257
|
-
|
|
259
|
+
// ../../shared/contract/keys.ts
|
|
260
|
+
/**
|
|
261
|
+
* Response shapes of the key write routes an IDE plugin uses: create a key from
|
|
262
|
+
* text in code, name it, and edit its drafts. Same versioning rule as
|
|
263
|
+
* `delivery.ts`. A key created with a name publishes its source text; every
|
|
264
|
+
* other write lands in drafts, and publishing stays in the web app.
|
|
265
|
+
*/
|
|
266
|
+
/**
|
|
267
|
+
* `POST /api/v1/keys` and `PATCH /api/v1/keys`. The key comes back in the
|
|
268
|
+
* `/keys/states` shape, so a plugin can drop it straight into that cache.
|
|
269
|
+
*/
|
|
270
|
+
const keyWriteResultSchema = z.object({
|
|
271
|
+
sourceLocale: z.string(),
|
|
272
|
+
/**
|
|
273
|
+
* False when the request named no key and the text already has its
|
|
274
|
+
* `__unnamed_` key — the same text maps to the same placeholder. Always false
|
|
275
|
+
* for `PATCH`.
|
|
276
|
+
*/
|
|
277
|
+
created: z.boolean(),
|
|
278
|
+
key: deliveryKeyStateSchema
|
|
279
|
+
});
|
|
280
|
+
/**
|
|
281
|
+
* The `data` of a `PATCH /api/v1/keys` 409: a locale's draft no longer matches
|
|
282
|
+
* the `expected` the client sent. Nothing was written; `key` is the current
|
|
283
|
+
* state to diff against before retrying.
|
|
284
|
+
*/
|
|
285
|
+
const keyDraftConflictSchema = z.object({
|
|
286
|
+
locales: z.array(z.string()),
|
|
287
|
+
key: deliveryKeyStateSchema
|
|
288
|
+
});
|
|
289
|
+
const keyViolationSchema = z.enum([
|
|
290
|
+
"prefix",
|
|
291
|
+
"charset",
|
|
292
|
+
"segment",
|
|
293
|
+
"case",
|
|
294
|
+
"depth"
|
|
295
|
+
]);
|
|
296
|
+
/**
|
|
297
|
+
* `POST /api/v1/keys/suggest-name` — the web app's AI key naming, under the
|
|
298
|
+
* project's key convention. `key` is empty when the text has nothing nameable.
|
|
299
|
+
*/
|
|
300
|
+
const keyNameSuggestionSchema = z.object({
|
|
301
|
+
source: z.string(),
|
|
302
|
+
key: z.string(),
|
|
303
|
+
confidence: z.number().optional(),
|
|
304
|
+
alternatives: z.array(z.object({
|
|
305
|
+
key: z.string(),
|
|
306
|
+
confidence: z.number().optional()
|
|
307
|
+
})).optional(),
|
|
308
|
+
reason: z.string().optional(),
|
|
309
|
+
violations: z.array(keyViolationSchema),
|
|
310
|
+
/** Candidates the project already has; `sameSourceText` means reuse, not clash. */
|
|
311
|
+
duplicates: z.array(z.object({
|
|
312
|
+
key: z.string(),
|
|
313
|
+
sourceText: z.string(),
|
|
314
|
+
sameSourceText: z.boolean()
|
|
315
|
+
}))
|
|
316
|
+
});
|
|
317
|
+
export { captureKeyHitSchema, captureKeySearchSchema, captureMatchSchema, capturePageSchema, captureTagSchema, createPageResultSchema, deleteTagsResultSchema, deliveryBundleSchema, deliveryKeyStateSchema, deliveryKeyStatesSchema, deliveryKeysSchema, deliveryLocaleSchema, deliveryLocaleStateNameSchema, deliveryMetaSchema, deliveryOutdatedSchema, deliveryProjectRefSchema, deliveryProjectsSchema, i18nKeyNamespaceCountsSchema, idSchema, importPageResultSchema, importPageTagsSchema, importedTagSchema, keyDraftConflictSchema, keyNameSuggestionSchema, keyNamespaceSchema, keyViolationSchema, keyWriteResultSchema, projectReleaseSchema, releaseMembershipResultSchema, uploadResultSchema };
|
package/package.json
CHANGED