@localness/contract 0.4.0 → 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 +146 -1
- package/dist/index.mjs +95 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -66,6 +66,7 @@ export declare const deliveryMetaSchema: z.ZodObject<{
|
|
|
66
66
|
name: z.ZodString;
|
|
67
67
|
}, z.core.$strip>;
|
|
68
68
|
locales: z.ZodArray<z.ZodString>;
|
|
69
|
+
sourceLocale: z.ZodOptional<z.ZodString>;
|
|
69
70
|
localeFallback: z.ZodString;
|
|
70
71
|
release: z.ZodNullable<z.ZodNumber>;
|
|
71
72
|
releases: z.ZodArray<z.ZodObject<{
|
|
@@ -125,6 +126,60 @@ export declare const deliveryKeysSchema: z.ZodObject<{
|
|
|
125
126
|
generatedAt: z.ZodString;
|
|
126
127
|
}, z.core.$strip>;
|
|
127
128
|
export type DeliveryKeys = z.infer<typeof deliveryKeysSchema>;
|
|
129
|
+
export declare const deliveryLocaleStateNameSchema: z.ZodEnum<{
|
|
130
|
+
draft: "draft";
|
|
131
|
+
published: "published";
|
|
132
|
+
outdated: "outdated";
|
|
133
|
+
unpublished: "unpublished";
|
|
134
|
+
}>;
|
|
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>;
|
|
154
|
+
/**
|
|
155
|
+
* `GET /api/v1/keys/states` — per-key, per-locale state, drafts included.
|
|
156
|
+
* Unlike every other delivery shape this carries draft text: a read token sees
|
|
157
|
+
* what the editor sees.
|
|
158
|
+
*/
|
|
159
|
+
export declare const deliveryKeyStatesSchema: z.ZodObject<{
|
|
160
|
+
sourceLocale: z.ZodString;
|
|
161
|
+
keys: z.ZodArray<z.ZodObject<{
|
|
162
|
+
id: z.ZodNumber;
|
|
163
|
+
key: z.ZodString;
|
|
164
|
+
releaseIds: z.ZodArray<z.ZodNumber>;
|
|
165
|
+
draft: z.ZodBoolean;
|
|
166
|
+
locales: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
167
|
+
draftText: z.ZodNullable<z.ZodString>;
|
|
168
|
+
publishedText: z.ZodNullable<z.ZodString>;
|
|
169
|
+
state: z.ZodEnum<{
|
|
170
|
+
draft: "draft";
|
|
171
|
+
published: "published";
|
|
172
|
+
outdated: "outdated";
|
|
173
|
+
unpublished: "unpublished";
|
|
174
|
+
}>;
|
|
175
|
+
}, z.core.$strip>>;
|
|
176
|
+
}, z.core.$strip>>;
|
|
177
|
+
total: z.ZodNumber;
|
|
178
|
+
offset: z.ZodNumber;
|
|
179
|
+
limit: z.ZodNumber;
|
|
180
|
+
generatedAt: z.ZodString;
|
|
181
|
+
}, z.core.$strip>;
|
|
182
|
+
export type DeliveryKeyStates = z.infer<typeof deliveryKeyStatesSchema>;
|
|
128
183
|
/**
|
|
129
184
|
* Response shapes of the write half of the public `/api/v1` API, plus the
|
|
130
185
|
* capture reads a design tool needs. Same versioning rule as `delivery.ts`:
|
|
@@ -297,4 +352,94 @@ export declare const capturePageSchema: z.ZodObject<{
|
|
|
297
352
|
releaseIds: z.ZodArray<z.ZodNumber>;
|
|
298
353
|
}, z.core.$strip>>;
|
|
299
354
|
}, z.core.$strip>;
|
|
300
|
-
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
|
@@ -65,6 +65,8 @@ const deliveryMetaSchema = z.object({
|
|
|
65
65
|
name: z.string()
|
|
66
66
|
}),
|
|
67
67
|
locales: z.array(z.string()),
|
|
68
|
+
/** The project's source locale. Optional: servers before it omit it. */
|
|
69
|
+
sourceLocale: z.string().optional(),
|
|
68
70
|
localeFallback: z.string(),
|
|
69
71
|
/** The release the response is scoped to, or null for all keys. */
|
|
70
72
|
release: z.number().nullable(),
|
|
@@ -126,6 +128,40 @@ const deliveryKeysSchema = z.object({
|
|
|
126
128
|
/** ISO 8601. */
|
|
127
129
|
generatedAt: z.string()
|
|
128
130
|
});
|
|
131
|
+
const deliveryLocaleStateNameSchema = z.enum([
|
|
132
|
+
"draft",
|
|
133
|
+
"published",
|
|
134
|
+
"outdated",
|
|
135
|
+
"unpublished"
|
|
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
|
+
});
|
|
150
|
+
/**
|
|
151
|
+
* `GET /api/v1/keys/states` — per-key, per-locale state, drafts included.
|
|
152
|
+
* Unlike every other delivery shape this carries draft text: a read token sees
|
|
153
|
+
* what the editor sees.
|
|
154
|
+
*/
|
|
155
|
+
const deliveryKeyStatesSchema = z.object({
|
|
156
|
+
sourceLocale: z.string(),
|
|
157
|
+
keys: z.array(deliveryKeyStateSchema),
|
|
158
|
+
/** Keys in scope, before paging. */
|
|
159
|
+
total: z.number(),
|
|
160
|
+
offset: z.number(),
|
|
161
|
+
limit: z.number(),
|
|
162
|
+
/** ISO 8601. */
|
|
163
|
+
generatedAt: z.string()
|
|
164
|
+
});
|
|
129
165
|
// ../../shared/contract/import.ts
|
|
130
166
|
/**
|
|
131
167
|
* Response shapes of the write half of the public `/api/v1` API, plus the
|
|
@@ -220,4 +256,62 @@ const capturePageSchema = z.object({
|
|
|
220
256
|
releaseIds: z.array(z.number()),
|
|
221
257
|
tags: z.array(captureTagSchema)
|
|
222
258
|
});
|
|
223
|
-
|
|
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