@better-i18n/schemas 0.2.2 → 0.2.3
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/package.json +1 -1
- package/src/content.ts +10 -1
- package/src/projects/project.input.ts +52 -0
package/package.json
CHANGED
package/src/content.ts
CHANGED
|
@@ -197,10 +197,18 @@ export const listContentEntriesSchema = z.object({
|
|
|
197
197
|
projectId: z.string().uuid(),
|
|
198
198
|
modelSlug: z.string().optional(),
|
|
199
199
|
status: contentEntryStatusEnum.optional(),
|
|
200
|
-
search: z.string().optional(),
|
|
200
|
+
search: z.union([z.string(), z.array(z.string())]).optional(),
|
|
201
|
+
/** Which languages to search content IN (default: all). Separate from languageCodes which filters BY having translations. */
|
|
202
|
+
searchLanguageCodes: z.array(z.string().transform(v => v.toLowerCase())).optional(),
|
|
203
|
+
/** Opt-in body search (default: false, can be slow on large bodies) */
|
|
204
|
+
searchInBody: z.boolean().default(false).optional(),
|
|
201
205
|
languageCodes: z.array(z.string().transform(v => v.toLowerCase())).optional(),
|
|
206
|
+
/** Filter entries that do NOT have a translation for this language code */
|
|
207
|
+
missingLanguageCode: z.string().transform(v => v.toLowerCase()).optional(),
|
|
202
208
|
/** Filter by custom field values. Key = field name, value = exact match. */
|
|
203
209
|
fieldFilters: z.record(z.string(), z.string()).optional(),
|
|
210
|
+
/** Filter entries by specific IDs */
|
|
211
|
+
ids: z.array(z.string().uuid()).optional(),
|
|
204
212
|
sort: contentEntrySortFieldEnum.optional(),
|
|
205
213
|
order: z.enum(["asc", "desc"]).optional(),
|
|
206
214
|
page: z.number().int().min(1).default(1),
|
|
@@ -245,6 +253,7 @@ export const updateContentEntrySchema = z.object({
|
|
|
245
253
|
.regex(/^[a-z0-9-]+$/, "Slug must contain only lowercase letters, numbers, and hyphens")
|
|
246
254
|
.optional(),
|
|
247
255
|
publishedAt: z.string().datetime({ offset: true }).nullable().optional(),
|
|
256
|
+
translationStatus: z.enum(["draft", "published"]).optional(),
|
|
248
257
|
});
|
|
249
258
|
|
|
250
259
|
/** Delete a content entry */
|
|
@@ -74,6 +74,36 @@ export const addTargetLanguageSchema = z.object({
|
|
|
74
74
|
status: z.enum(["active", "draft"]).default("active").optional(),
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Schema for batch adding multiple target languages to a project.
|
|
79
|
+
* Replaces sequential addTargetLanguage calls for better performance.
|
|
80
|
+
*/
|
|
81
|
+
export const batchAddTargetLanguagesSchema = z.object({
|
|
82
|
+
projectId: z.string().uuid("Invalid project ID"),
|
|
83
|
+
languageCodes: z
|
|
84
|
+
.array(z.string().min(2).max(10))
|
|
85
|
+
.min(1, "At least one language code required")
|
|
86
|
+
.max(50, "Maximum 50 languages at once"),
|
|
87
|
+
status: z.enum(["active", "draft"]).default("active").optional(),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Schema for batch updating target language statuses.
|
|
92
|
+
* Replaces sequential updateTargetLanguageStatus calls.
|
|
93
|
+
*/
|
|
94
|
+
export const batchUpdateTargetLanguageStatusSchema = z.object({
|
|
95
|
+
projectId: z.string().uuid("Invalid project ID"),
|
|
96
|
+
updates: z
|
|
97
|
+
.array(
|
|
98
|
+
z.object({
|
|
99
|
+
languageCode: z.string().min(2).max(10),
|
|
100
|
+
status: z.enum(["active", "draft", "archived"]),
|
|
101
|
+
}),
|
|
102
|
+
)
|
|
103
|
+
.min(1, "At least one update required")
|
|
104
|
+
.max(50, "Maximum 50 updates at once"),
|
|
105
|
+
});
|
|
106
|
+
|
|
77
107
|
/**
|
|
78
108
|
* Schema for removing a target language from a project.
|
|
79
109
|
*/
|
|
@@ -152,6 +182,26 @@ export const getTargetLanguagesSchema = z.object({
|
|
|
152
182
|
projectId: z.string().uuid("Invalid project ID"),
|
|
153
183
|
});
|
|
154
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Schema for managing languages in a single operation.
|
|
187
|
+
* Combines batch add + batch status updates into one mutation
|
|
188
|
+
* so that a single activity record is created.
|
|
189
|
+
*/
|
|
190
|
+
export const manageLanguagesSchema = z.object({
|
|
191
|
+
projectId: z.string().uuid("Invalid project ID"),
|
|
192
|
+
add: z.array(z.string().min(2).max(10)).default([]),
|
|
193
|
+
statusUpdates: z
|
|
194
|
+
.array(
|
|
195
|
+
z.object({
|
|
196
|
+
languageCode: z.string().min(2).max(10),
|
|
197
|
+
status: z.enum(["active", "draft"]),
|
|
198
|
+
}),
|
|
199
|
+
)
|
|
200
|
+
.default([]),
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
export type ManageLanguagesInput = z.infer<typeof manageLanguagesSchema>;
|
|
204
|
+
|
|
155
205
|
// Type exports
|
|
156
206
|
export type CreateProjectInput = z.infer<typeof createProjectSchema>;
|
|
157
207
|
export type UpdateProjectInput = z.infer<typeof updateProjectSchema>;
|
|
@@ -165,5 +215,7 @@ export type ToggleTargetLanguageInput = z.infer<typeof toggleTargetLanguageSchem
|
|
|
165
215
|
export type UpdateTargetLanguageStatusInput = z.infer<typeof updateTargetLanguageStatusSchema>;
|
|
166
216
|
export type LanguageStatus = z.infer<typeof languageStatusEnum>;
|
|
167
217
|
export type GetTargetLanguagesInput = z.infer<typeof getTargetLanguagesSchema>;
|
|
218
|
+
export type BatchAddTargetLanguagesInput = z.infer<typeof batchAddTargetLanguagesSchema>;
|
|
219
|
+
export type BatchUpdateTargetLanguageStatusInput = z.infer<typeof batchUpdateTargetLanguageStatusSchema>;
|
|
168
220
|
|
|
169
221
|
|