@intlayer/backend-contract 0.0.0-stage → 9.7.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/cjs/ai.cjs +267 -0
- package/dist/cjs/ai.cjs.map +1 -0
- package/dist/cjs/analytics.cjs +175 -0
- package/dist/cjs/analytics.cjs.map +1 -0
- package/dist/cjs/asset.cjs +88 -0
- package/dist/cjs/asset.cjs.map +1 -0
- package/dist/cjs/blogComment.cjs +98 -0
- package/dist/cjs/blogComment.cjs.map +1 -0
- package/dist/cjs/cliSessionToken.cjs +40 -0
- package/dist/cjs/cliSessionToken.cjs.map +1 -0
- package/dist/cjs/common.cjs +42 -0
- package/dist/cjs/common.cjs.map +1 -0
- package/dist/cjs/defineRoute.cjs +26 -0
- package/dist/cjs/defineRoute.cjs.map +1 -0
- package/dist/cjs/demo.cjs +22 -0
- package/dist/cjs/demo.cjs.map +1 -0
- package/dist/cjs/dictionary.cjs +168 -0
- package/dist/cjs/dictionary.cjs.map +1 -0
- package/dist/cjs/environment.cjs +91 -0
- package/dist/cjs/environment.cjs.map +1 -0
- package/dist/cjs/eventListener.cjs +19 -0
- package/dist/cjs/eventListener.cjs.map +1 -0
- package/dist/cjs/gitProviders.cjs +361 -0
- package/dist/cjs/gitProviders.cjs.map +1 -0
- package/dist/cjs/newsletter.cjs +50 -0
- package/dist/cjs/newsletter.cjs.map +1 -0
- package/dist/cjs/oAuth2.cjs +62 -0
- package/dist/cjs/oAuth2.cjs.map +1 -0
- package/dist/cjs/organization.cjs +226 -0
- package/dist/cjs/organization.cjs.map +1 -0
- package/dist/cjs/project.cjs +401 -0
- package/dist/cjs/project.cjs.map +1 -0
- package/dist/cjs/public.cjs +60 -0
- package/dist/cjs/public.cjs.map +1 -0
- package/dist/cjs/responseData.cjs +33 -0
- package/dist/cjs/responseData.cjs.map +1 -0
- package/dist/cjs/reviewer.cjs +401 -0
- package/dist/cjs/reviewer.cjs.map +1 -0
- package/dist/cjs/scan.cjs +235 -0
- package/dist/cjs/scan.cjs.map +1 -0
- package/dist/cjs/search.cjs +40 -0
- package/dist/cjs/search.cjs.map +1 -0
- package/dist/cjs/session.cjs +56 -0
- package/dist/cjs/session.cjs.map +1 -0
- package/dist/cjs/showcaseProject.cjs +185 -0
- package/dist/cjs/showcaseProject.cjs.map +1 -0
- package/dist/cjs/stripe.cjs +388 -0
- package/dist/cjs/stripe.cjs.map +1 -0
- package/dist/cjs/tag.cjs +83 -0
- package/dist/cjs/tag.cjs.map +1 -0
- package/dist/cjs/translation.cjs +54 -0
- package/dist/cjs/translation.cjs.map +1 -0
- package/dist/cjs/user.cjs +153 -0
- package/dist/cjs/user.cjs.map +1 -0
- package/dist/esm/ai.mjs +261 -0
- package/dist/esm/ai.mjs.map +1 -0
- package/dist/esm/analytics.mjs +168 -0
- package/dist/esm/analytics.mjs.map +1 -0
- package/dist/esm/asset.mjs +86 -0
- package/dist/esm/asset.mjs.map +1 -0
- package/dist/esm/blogComment.mjs +94 -0
- package/dist/esm/blogComment.mjs.map +1 -0
- package/dist/esm/cliSessionToken.mjs +39 -0
- package/dist/esm/cliSessionToken.mjs.map +1 -0
- package/dist/esm/common.mjs +35 -0
- package/dist/esm/common.mjs.map +1 -0
- package/dist/esm/defineRoute.mjs +23 -0
- package/dist/esm/defineRoute.mjs.map +1 -0
- package/dist/esm/demo.mjs +21 -0
- package/dist/esm/demo.mjs.map +1 -0
- package/dist/esm/dictionary.mjs +163 -0
- package/dist/esm/dictionary.mjs.map +1 -0
- package/dist/esm/environment.mjs +90 -0
- package/dist/esm/environment.mjs.map +1 -0
- package/dist/esm/eventListener.mjs +18 -0
- package/dist/esm/eventListener.mjs.map +1 -0
- package/dist/esm/gitProviders.mjs +352 -0
- package/dist/esm/gitProviders.mjs.map +1 -0
- package/dist/esm/newsletter.mjs +49 -0
- package/dist/esm/newsletter.mjs.map +1 -0
- package/dist/esm/oAuth2.mjs +60 -0
- package/dist/esm/oAuth2.mjs.map +1 -0
- package/dist/esm/organization.mjs +219 -0
- package/dist/esm/organization.mjs.map +1 -0
- package/dist/esm/project.mjs +387 -0
- package/dist/esm/project.mjs.map +1 -0
- package/dist/esm/public.mjs +58 -0
- package/dist/esm/public.mjs.map +1 -0
- package/dist/esm/responseData.mjs +30 -0
- package/dist/esm/responseData.mjs.map +1 -0
- package/dist/esm/reviewer.mjs +390 -0
- package/dist/esm/reviewer.mjs.map +1 -0
- package/dist/esm/scan.mjs +225 -0
- package/dist/esm/scan.mjs.map +1 -0
- package/dist/esm/search.mjs +38 -0
- package/dist/esm/search.mjs.map +1 -0
- package/dist/esm/session.mjs +53 -0
- package/dist/esm/session.mjs.map +1 -0
- package/dist/esm/showcaseProject.mjs +182 -0
- package/dist/esm/showcaseProject.mjs.map +1 -0
- package/dist/esm/stripe.mjs +379 -0
- package/dist/esm/stripe.mjs.map +1 -0
- package/dist/esm/tag.mjs +81 -0
- package/dist/esm/tag.mjs.map +1 -0
- package/dist/esm/translation.mjs +53 -0
- package/dist/esm/translation.mjs.map +1 -0
- package/dist/esm/user.mjs +149 -0
- package/dist/esm/user.mjs.map +1 -0
- package/dist/types/@intlayer/config/dist/types/defaultValues/dictionary.d.ts +1 -0
- package/dist/types/@intlayer/config/dist/types/defaultValues/index.d.ts +3 -0
- package/dist/types/@intlayer/config/dist/types/defaultValues/internationalization.d.ts +2 -0
- package/dist/types/@intlayer/config/dist/types/defaultValues/routing.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/dictionaryManipulator/plainDynamicLoader.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/dictionaryManipulator/qualifiedDynamicLoader.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/formatters/compact.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/formatters/currency.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/formatters/date.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/formatters/index.d.ts +9 -0
- package/dist/types/@intlayer/core/dist/types/formatters/list.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/formatters/number.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/formatters/percentage.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/formatters/relativeTime.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/formatters/units.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/dictionaryTransformCache.d.ts +4 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getCondition.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getContent/deepTransform.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getContent/getContent.d.ts +3 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getContent/index.d.ts +3 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getContent/plugins.d.ts +7 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getDictionary.d.ts +4 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getDictionaryAsync.d.ts +6 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getEnumeration.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getGender.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getInsertion.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getIntlayer.d.ts +4 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getIntlayerAsync.d.ts +4 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getNesting.d.ts +6 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getPlural.d.ts +3 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getSelect.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/getTranslation.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/index.d.ts +19 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/interpolableNode.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/interpreter/resolveInterpreterLocale.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/localization/comparePaths.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/localization/domainUtils.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/localization/generateSitemap.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/localization/getBrowserLocale.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/localization/getCanonicalPath.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/localization/getHTMLTextDir.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/localization/getLocale.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/localization/getLocaleFromPath.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/localization/getLocaleFromRequest.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/localization/getLocaleLang.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/localization/getLocaleName.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/localization/getLocalizedPath.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/localization/getLocalizedUrl.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/localization/getMultilingualUrls.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/localization/getPathWithoutLocale.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/localization/getPrefix.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/localization/index.d.ts +23 -0
- package/dist/types/@intlayer/core/dist/types/localization/localeDetector.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/localization/localeMapper.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/localization/localeResolver.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/localization/resolveBrowserLocale.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/localization/rewriteMatch.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/localization/rewriteUtils.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/localization/validatePrefix.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/markdown/index.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/condition/condition.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/condition/index.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/enumeration/enumeration.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/enumeration/index.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/file/file.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/file/index.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/gender/gender.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/gender/index.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/html/html.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/html/index.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/index.d.ts +22 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/insertion/index.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/insertion/insertion.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/markdown/index.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/markdown/markdown.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/nesting/index.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/nesting/nesting.d.ts +4 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/plural/index.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/plural/plural.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/select/index.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/select/select.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/translation/index.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/transpiler/translation/translation.d.ts +2 -0
- package/dist/types/@intlayer/core/dist/types/utils/index.d.ts +3 -0
- package/dist/types/@intlayer/core/dist/types/utils/intl.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/utils/isSameKeyPath.d.ts +1 -0
- package/dist/types/@intlayer/core/dist/types/utils/localeStorage.d.ts +2 -0
- package/dist/types/ai.d.ts +549 -0
- package/dist/types/ai.d.ts.map +1 -0
- package/dist/types/analytics.d.ts +378 -0
- package/dist/types/analytics.d.ts.map +1 -0
- package/dist/types/asset.d.ts +207 -0
- package/dist/types/asset.d.ts.map +1 -0
- package/dist/types/blogComment.d.ts +241 -0
- package/dist/types/blogComment.d.ts.map +1 -0
- package/dist/types/cliSessionToken.d.ts +264 -0
- package/dist/types/cliSessionToken.d.ts.map +1 -0
- package/dist/types/common.d.ts +32 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/defineRoute.d.ts +57 -0
- package/dist/types/defineRoute.d.ts.map +1 -0
- package/dist/types/demo.d.ts +21 -0
- package/dist/types/demo.d.ts.map +1 -0
- package/dist/types/dictionary.d.ts +360 -0
- package/dist/types/dictionary.d.ts.map +1 -0
- package/dist/types/environment.d.ts +285 -0
- package/dist/types/environment.d.ts.map +1 -0
- package/dist/types/eventListener.d.ts +17 -0
- package/dist/types/eventListener.d.ts.map +1 -0
- package/dist/types/gitProviders.d.ts +807 -0
- package/dist/types/gitProviders.d.ts.map +1 -0
- package/dist/types/intlayer/dist/types/index.d.ts +13 -0
- package/dist/types/newsletter.d.ts +165 -0
- package/dist/types/newsletter.d.ts.map +1 -0
- package/dist/types/oAuth2.d.ts +482 -0
- package/dist/types/oAuth2.d.ts.map +1 -0
- package/dist/types/organization.d.ts +1069 -0
- package/dist/types/organization.d.ts.map +1 -0
- package/dist/types/project.d.ts +1735 -0
- package/dist/types/project.d.ts.map +1 -0
- package/dist/types/public.d.ts +109 -0
- package/dist/types/public.d.ts.map +1 -0
- package/dist/types/responseData.d.ts +68 -0
- package/dist/types/responseData.d.ts.map +1 -0
- package/dist/types/reviewer.d.ts +1239 -0
- package/dist/types/reviewer.d.ts.map +1 -0
- package/dist/types/scan.d.ts +625 -0
- package/dist/types/scan.d.ts.map +1 -0
- package/dist/types/search.d.ts +55 -0
- package/dist/types/search.d.ts.map +1 -0
- package/dist/types/session.d.ts +286 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/showcaseProject.d.ts +550 -0
- package/dist/types/showcaseProject.d.ts.map +1 -0
- package/dist/types/stripe.d.ts +1219 -0
- package/dist/types/stripe.d.ts.map +1 -0
- package/dist/types/tag.d.ts +193 -0
- package/dist/types/tag.d.ts.map +1 -0
- package/dist/types/translation.d.ts +162 -0
- package/dist/types/translation.d.ts.map +1 -0
- package/dist/types/user.d.ts +447 -0
- package/dist/types/user.d.ts.map +1 -0
- package/package.json +300 -4
- package/README.md +0 -3
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_common = require('./common.cjs');
|
|
3
|
+
const require_defineRoute = require('./defineRoute.cjs');
|
|
4
|
+
const require_responseData = require('./responseData.cjs');
|
|
5
|
+
let zod_mini = require("zod/mini");
|
|
6
|
+
|
|
7
|
+
//#region src/blogComment.ts
|
|
8
|
+
/** Moderation status of a blog comment. */
|
|
9
|
+
const blogCommentStatusSchema = zod_mini.z.enum([
|
|
10
|
+
"pending",
|
|
11
|
+
"approved",
|
|
12
|
+
"rejected"
|
|
13
|
+
]);
|
|
14
|
+
/** Comment as shown publicly (author email stripped). */
|
|
15
|
+
const blogCommentPublicSchema = zod_mini.z.looseObject({
|
|
16
|
+
id: zod_mini.z.string(),
|
|
17
|
+
blogSlug: zod_mini.z.string(),
|
|
18
|
+
authorName: zod_mini.z.string(),
|
|
19
|
+
content: zod_mini.z.string(),
|
|
20
|
+
status: blogCommentStatusSchema,
|
|
21
|
+
createdAt: zod_mini.z.string(),
|
|
22
|
+
updatedAt: zod_mini.z.string()
|
|
23
|
+
});
|
|
24
|
+
/** Comment as shown to admins. */
|
|
25
|
+
const blogCommentSchema = zod_mini.z.looseObject({
|
|
26
|
+
...blogCommentPublicSchema.shape,
|
|
27
|
+
authorEmail: zod_mini.z.string()
|
|
28
|
+
});
|
|
29
|
+
const commentIdParamsSchema = zod_mini.z.object({ commentId: require_common.objectIdSchema });
|
|
30
|
+
/** REST contract of the `/api/blog-comments` routes. */
|
|
31
|
+
const blogCommentContract = require_defineRoute.defineRouteGroup({
|
|
32
|
+
prefix: "/api/blog-comments",
|
|
33
|
+
tag: "Blog comment",
|
|
34
|
+
routes: {
|
|
35
|
+
submitBlogComment: require_defineRoute.defineRoute({
|
|
36
|
+
method: "POST",
|
|
37
|
+
path: "/",
|
|
38
|
+
summary: "Submit a comment on a blog post (moderated)",
|
|
39
|
+
schemas: {
|
|
40
|
+
body: zod_mini.z.object({
|
|
41
|
+
blogSlug: zod_mini.z.string().check(zod_mini.z.minLength(1)),
|
|
42
|
+
authorName: zod_mini.z.string().check(zod_mini.z.minLength(1)),
|
|
43
|
+
authorEmail: zod_mini.z.string().check(zod_mini.z.minLength(1)),
|
|
44
|
+
content: zod_mini.z.string().check(zod_mini.z.minLength(1))
|
|
45
|
+
}),
|
|
46
|
+
response: { 201: require_responseData.responseDataSchema(blogCommentPublicSchema) }
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
getAdminBlogComments: require_defineRoute.defineRoute({
|
|
50
|
+
method: "GET",
|
|
51
|
+
path: "/admin",
|
|
52
|
+
summary: "Admin only: list comments by status or post",
|
|
53
|
+
schemas: {
|
|
54
|
+
querystring: zod_mini.z.object({
|
|
55
|
+
...require_common.paginationQueryShape,
|
|
56
|
+
blogSlug: zod_mini.z.optional(zod_mini.z.string()),
|
|
57
|
+
status: zod_mini.z.optional(blogCommentStatusSchema)
|
|
58
|
+
}),
|
|
59
|
+
response: { 200: require_responseData.paginatedResponseSchema(blogCommentSchema) }
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
getApprovedBlogComments: require_defineRoute.defineRoute({
|
|
63
|
+
method: "GET",
|
|
64
|
+
path: "/:blogSlug",
|
|
65
|
+
summary: "Approved comments of a blog post",
|
|
66
|
+
schemas: {
|
|
67
|
+
params: zod_mini.z.object({ blogSlug: zod_mini.z.string() }),
|
|
68
|
+
response: { 200: require_responseData.responseDataSchema(zod_mini.z.array(blogCommentPublicSchema)) }
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
updateBlogCommentStatus: require_defineRoute.defineRoute({
|
|
72
|
+
method: "PATCH",
|
|
73
|
+
path: "/:commentId/status",
|
|
74
|
+
summary: "Admin only: approve or reject a comment",
|
|
75
|
+
schemas: {
|
|
76
|
+
params: commentIdParamsSchema,
|
|
77
|
+
body: zod_mini.z.object({ status: blogCommentStatusSchema }),
|
|
78
|
+
response: { 200: require_responseData.responseDataSchema(blogCommentSchema) }
|
|
79
|
+
}
|
|
80
|
+
}),
|
|
81
|
+
deleteBlogComment: require_defineRoute.defineRoute({
|
|
82
|
+
method: "DELETE",
|
|
83
|
+
path: "/:commentId",
|
|
84
|
+
summary: "Admin only: delete a comment",
|
|
85
|
+
schemas: {
|
|
86
|
+
params: commentIdParamsSchema,
|
|
87
|
+
response: { 200: require_responseData.responseDataSchema(zod_mini.z.null()) }
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
exports.blogCommentContract = blogCommentContract;
|
|
95
|
+
exports.blogCommentPublicSchema = blogCommentPublicSchema;
|
|
96
|
+
exports.blogCommentSchema = blogCommentSchema;
|
|
97
|
+
exports.blogCommentStatusSchema = blogCommentStatusSchema;
|
|
98
|
+
//# sourceMappingURL=blogComment.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blogComment.cjs","names":["z","objectIdSchema","defineRouteGroup","defineRoute","responseDataSchema","paginationQueryShape","paginatedResponseSchema"],"sources":["../../src/blogComment.ts"],"sourcesContent":["import { z } from 'zod/mini';\nimport { objectIdSchema, paginationQueryShape } from './common';\nimport {\n defineRoute,\n defineRouteGroup,\n type RouteBodyInput,\n} from './defineRoute';\nimport {\n type PaginatedResponse,\n paginatedResponseSchema,\n type ResponseData,\n responseDataSchema,\n} from './responseData';\n\n/** Moderation status of a blog comment. */\nexport const blogCommentStatusSchema = z.enum([\n 'pending',\n 'approved',\n 'rejected',\n]);\n\n/** Comment as shown publicly (author email stripped). */\nexport const blogCommentPublicSchema = z.looseObject({\n id: z.string(),\n blogSlug: z.string(),\n authorName: z.string(),\n content: z.string(),\n status: blogCommentStatusSchema,\n createdAt: z.string(),\n updatedAt: z.string(),\n});\n\n/** Comment as shown to admins. */\nexport const blogCommentSchema = z.looseObject({\n ...blogCommentPublicSchema.shape,\n authorEmail: z.string(),\n});\n\nconst commentIdParamsSchema = z.object({ commentId: objectIdSchema });\n\n/** REST contract of the `/api/blog-comments` routes. */\nexport const blogCommentContract = defineRouteGroup({\n prefix: '/api/blog-comments',\n tag: 'Blog comment',\n routes: {\n submitBlogComment: defineRoute({\n method: 'POST',\n path: '/',\n summary: 'Submit a comment on a blog post (moderated)',\n schemas: {\n body: z.object({\n blogSlug: z.string().check(z.minLength(1)),\n authorName: z.string().check(z.minLength(1)),\n authorEmail: z.string().check(z.minLength(1)),\n content: z.string().check(z.minLength(1)),\n }),\n response: { 201: responseDataSchema(blogCommentPublicSchema) },\n },\n }),\n getAdminBlogComments: defineRoute({\n method: 'GET',\n path: '/admin',\n summary: 'Admin only: list comments by status or post',\n schemas: {\n querystring: z.object({\n ...paginationQueryShape,\n blogSlug: z.optional(z.string()),\n status: z.optional(blogCommentStatusSchema),\n }),\n response: { 200: paginatedResponseSchema(blogCommentSchema) },\n },\n }),\n getApprovedBlogComments: defineRoute({\n method: 'GET',\n path: '/:blogSlug',\n summary: 'Approved comments of a blog post',\n schemas: {\n params: z.object({ blogSlug: z.string() }),\n response: {\n 200: responseDataSchema(z.array(blogCommentPublicSchema)),\n },\n },\n }),\n updateBlogCommentStatus: defineRoute({\n method: 'PATCH',\n path: '/:commentId/status',\n summary: 'Admin only: approve or reject a comment',\n schemas: {\n params: commentIdParamsSchema,\n body: z.object({ status: blogCommentStatusSchema }),\n response: { 200: responseDataSchema(blogCommentSchema) },\n },\n }),\n deleteBlogComment: defineRoute({\n method: 'DELETE',\n path: '/:commentId',\n summary: 'Admin only: delete a comment',\n schemas: {\n params: commentIdParamsSchema,\n response: { 200: responseDataSchema(z.null()) },\n },\n }),\n },\n});\n\n/** Route definitions of the `/api/blog-comments` group, by name. */\nexport type BlogCommentRoutes = (typeof blogCommentContract)['routes'];\n\nexport type BlogCommentStatus = z.output<typeof blogCommentStatusSchema>;\nexport type BlogCommentPublicAPI = z.output<typeof blogCommentPublicSchema>;\nexport type BlogCommentAPI = z.output<typeof blogCommentSchema>;\nexport type SubmitBlogCommentBody = RouteBodyInput<\n BlogCommentRoutes['submitBlogComment']\n>;\nexport type SubmitBlogCommentResult = ResponseData<BlogCommentPublicAPI>;\nexport type GetBlogCommentsResult = ResponseData<BlogCommentPublicAPI[]>;\nexport type GetAdminBlogCommentsResult = PaginatedResponse<BlogCommentAPI>;\nexport type UpdateBlogCommentStatusBody = RouteBodyInput<\n BlogCommentRoutes['updateBlogCommentStatus']\n>;\nexport type UpdateBlogCommentStatusResult = ResponseData<BlogCommentAPI>;\n"],"mappings":";;;;;;;;AAeA,MAAa,0BAA0BA,WAAE,KAAK;CAC5C;CACA;CACA;AACF,CAAC;;AAGD,MAAa,0BAA0BA,WAAE,YAAY;CACnD,IAAIA,WAAE,OAAO;CACb,UAAUA,WAAE,OAAO;CACnB,YAAYA,WAAE,OAAO;CACrB,SAASA,WAAE,OAAO;CAClB,QAAQ;CACR,WAAWA,WAAE,OAAO;CACpB,WAAWA,WAAE,OAAO;AACtB,CAAC;;AAGD,MAAa,oBAAoBA,WAAE,YAAY;CAC7C,GAAG,wBAAwB;CAC3B,aAAaA,WAAE,OAAO;AACxB,CAAC;AAED,MAAM,wBAAwBA,WAAE,OAAO,EAAE,WAAWC,8BAAe,CAAC;;AAGpE,MAAa,sBAAsBC,qCAAiB;CAClD,QAAQ;CACR,KAAK;CACL,QAAQ;EACN,mBAAmBC,gCAAY;GAC7B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,MAAMH,WAAE,OAAO;KACb,UAAUA,WAAE,OAAO,CAAC,CAAC,MAAMA,WAAE,UAAU,CAAC,CAAC;KACzC,YAAYA,WAAE,OAAO,CAAC,CAAC,MAAMA,WAAE,UAAU,CAAC,CAAC;KAC3C,aAAaA,WAAE,OAAO,CAAC,CAAC,MAAMA,WAAE,UAAU,CAAC,CAAC;KAC5C,SAASA,WAAE,OAAO,CAAC,CAAC,MAAMA,WAAE,UAAU,CAAC,CAAC;IAC1C,CAAC;IACD,UAAU,EAAE,KAAKI,wCAAmB,uBAAuB,EAAE;GAC/D;EACF,CAAC;EACD,sBAAsBD,gCAAY;GAChC,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,aAAaH,WAAE,OAAO;KACpB,GAAGK;KACH,UAAUL,WAAE,SAASA,WAAE,OAAO,CAAC;KAC/B,QAAQA,WAAE,SAAS,uBAAuB;IAC5C,CAAC;IACD,UAAU,EAAE,KAAKM,6CAAwB,iBAAiB,EAAE;GAC9D;EACF,CAAC;EACD,yBAAyBH,gCAAY;GACnC,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,QAAQH,WAAE,OAAO,EAAE,UAAUA,WAAE,OAAO,EAAE,CAAC;IACzC,UAAU,EACR,KAAKI,wCAAmBJ,WAAE,MAAM,uBAAuB,CAAC,EAC1D;GACF;EACF,CAAC;EACD,yBAAyBG,gCAAY;GACnC,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,QAAQ;IACR,MAAMH,WAAE,OAAO,EAAE,QAAQ,wBAAwB,CAAC;IAClD,UAAU,EAAE,KAAKI,wCAAmB,iBAAiB,EAAE;GACzD;EACF,CAAC;EACD,mBAAmBD,gCAAY;GAC7B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,QAAQ;IACR,UAAU,EAAE,KAAKC,wCAAmBJ,WAAE,KAAK,CAAC,EAAE;GAChD;EACF,CAAC;CACH;AACF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_common = require('./common.cjs');
|
|
3
|
+
const require_defineRoute = require('./defineRoute.cjs');
|
|
4
|
+
const require_responseData = require('./responseData.cjs');
|
|
5
|
+
const require_project = require('./project.cjs');
|
|
6
|
+
const require_organization = require('./organization.cjs');
|
|
7
|
+
const require_user = require('./user.cjs');
|
|
8
|
+
let zod_mini = require("zod/mini");
|
|
9
|
+
|
|
10
|
+
//#region src/cliSessionToken.ts
|
|
11
|
+
/** REST contract of the CLI session routes (`intlayer login`). */
|
|
12
|
+
const cliSessionTokenContract = require_defineRoute.defineRouteGroup({
|
|
13
|
+
prefix: "/api/cli-session",
|
|
14
|
+
tag: "CLI session",
|
|
15
|
+
routes: {
|
|
16
|
+
createCliSessionToken: require_defineRoute.defineRoute({
|
|
17
|
+
method: "POST",
|
|
18
|
+
path: "/",
|
|
19
|
+
summary: "Issue a short-lived token for the CLI login handoff",
|
|
20
|
+
schemas: { response: { 200: require_responseData.responseDataSchema(zod_mini.z.object({
|
|
21
|
+
token: zod_mini.z.string(),
|
|
22
|
+
expiresAt: require_common.dateTimeSchema
|
|
23
|
+
})) } }
|
|
24
|
+
}),
|
|
25
|
+
getCliSessionMe: require_defineRoute.defineRoute({
|
|
26
|
+
method: "GET",
|
|
27
|
+
path: "/me",
|
|
28
|
+
summary: "User, organization and project bound to the CLI session token",
|
|
29
|
+
schemas: { response: { 200: require_responseData.responseDataSchema(zod_mini.z.object({
|
|
30
|
+
project: require_project.projectSchema,
|
|
31
|
+
user: zod_mini.z.optional(zod_mini.z.nullable(require_user.userSchema)),
|
|
32
|
+
organization: zod_mini.z.optional(zod_mini.z.nullable(require_organization.organizationSchema))
|
|
33
|
+
})) } }
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.cliSessionTokenContract = cliSessionTokenContract;
|
|
40
|
+
//# sourceMappingURL=cliSessionToken.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliSessionToken.cjs","names":["defineRouteGroup","defineRoute","responseDataSchema","z","dateTimeSchema","projectSchema","userSchema","organizationSchema"],"sources":["../../src/cliSessionToken.ts"],"sourcesContent":["import { z } from 'zod/mini';\nimport { dateTimeSchema } from './common';\nimport { defineRoute, defineRouteGroup } from './defineRoute';\nimport { type OrganizationAPI, organizationSchema } from './organization';\nimport { type ProjectAPI, projectSchema } from './project';\nimport { type ResponseData, responseDataSchema } from './responseData';\nimport { type UserAPI, userSchema } from './user';\n\n/** REST contract of the CLI session routes (`intlayer login`). */\nexport const cliSessionTokenContract = defineRouteGroup({\n prefix: '/api/cli-session',\n tag: 'CLI session',\n routes: {\n createCliSessionToken: defineRoute({\n method: 'POST',\n path: '/',\n summary: 'Issue a short-lived token for the CLI login handoff',\n schemas: {\n response: {\n 200: responseDataSchema(\n z.object({ token: z.string(), expiresAt: dateTimeSchema })\n ),\n },\n },\n }),\n getCliSessionMe: defineRoute({\n method: 'GET',\n path: '/me',\n summary: 'User, organization and project bound to the CLI session token',\n schemas: {\n response: {\n 200: responseDataSchema(\n z.object({\n project: projectSchema,\n // Optional: backends before 9.6 only return the project\n user: z.optional(z.nullable(userSchema)),\n organization: z.optional(z.nullable(organizationSchema)),\n })\n ),\n },\n },\n }),\n },\n});\n\n/** Route definitions of the CLI session group, by name. */\nexport type CliSessionTokenRoutes = (typeof cliSessionTokenContract)['routes'];\n\nexport type CreateCliSessionTokenResult = ResponseData<{\n token: string;\n expiresAt: string;\n}>;\nexport type GetCliSessionMeResult = ResponseData<{\n project: ProjectAPI;\n user?: UserAPI | null;\n organization?: OrganizationAPI | null;\n}>;\n"],"mappings":";;;;;;;;;;;AASA,MAAa,0BAA0BA,qCAAiB;CACtD,QAAQ;CACR,KAAK;CACL,QAAQ;EACN,uBAAuBC,gCAAY;GACjC,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS,EACP,UAAU,EACR,KAAKC,wCACHC,WAAE,OAAO;IAAE,OAAOA,WAAE,OAAO;IAAG,WAAWC;GAAe,CAAC,CAC3D,EACF,EACF;EACF,CAAC;EACD,iBAAiBH,gCAAY;GAC3B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS,EACP,UAAU,EACR,KAAKC,wCACHC,WAAE,OAAO;IACP,SAASE;IAET,MAAMF,WAAE,SAASA,WAAE,SAASG,uBAAU,CAAC;IACvC,cAAcH,WAAE,SAASA,WAAE,SAASI,uCAAkB,CAAC;GACzD,CAAC,CACH,EACF,EACF;EACF,CAAC;CACH;AACF,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let zod_mini = require("zod/mini");
|
|
3
|
+
|
|
4
|
+
//#region src/common.ts
|
|
5
|
+
/** 24-character hexadecimal MongoDB ObjectId, serialized as a string. */
|
|
6
|
+
const objectIdSchema = zod_mini.z.string().check(zod_mini.z.regex(/^[a-fA-F0-9]{24}$/));
|
|
7
|
+
/**
|
|
8
|
+
* Query string value that may be repeated (`?id=a&id=b`): Fastify parses it
|
|
9
|
+
* as a single string or as an array of strings.
|
|
10
|
+
*/
|
|
11
|
+
const repeatableQueryValueSchema = zod_mini.z.union([zod_mini.z.string(), zod_mini.z.array(zod_mini.z.string())]);
|
|
12
|
+
/** Pagination fields shared by every paginated list endpoint. */
|
|
13
|
+
const paginationQueryShape = {
|
|
14
|
+
page: zod_mini.z.optional(zod_mini.z.union([zod_mini.z.string(), zod_mini.z.number()])),
|
|
15
|
+
pageSize: zod_mini.z.optional(zod_mini.z.union([zod_mini.z.string(), zod_mini.z.number()]))
|
|
16
|
+
};
|
|
17
|
+
/** Date serialized by `JSON.stringify` (ISO 8601). */
|
|
18
|
+
const dateTimeSchema = zod_mini.z.string();
|
|
19
|
+
/**
|
|
20
|
+
* String narrowed to a type owned by another package (ex: `Locale` from
|
|
21
|
+
* `@intlayer/types`), without duplicating its values. Validated and
|
|
22
|
+
* documented as a plain string.
|
|
23
|
+
*/
|
|
24
|
+
const typedStringSchema = () => zod_mini.z.custom((value) => typeof value === "string");
|
|
25
|
+
/**
|
|
26
|
+
* Value whose type is owned by another package (ex: AI configuration or
|
|
27
|
+
* dictionaries from `@intlayer/types`), documented as any JSON value.
|
|
28
|
+
* @param isValid - Optional shallow runtime check (defaults to accept all).
|
|
29
|
+
*/
|
|
30
|
+
const typedValueSchema = (isValid = () => true) => zod_mini.z.custom(isValid);
|
|
31
|
+
/** Whether a value is a plain JSON object (not null, not an array). */
|
|
32
|
+
const isJSONObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.dateTimeSchema = dateTimeSchema;
|
|
36
|
+
exports.isJSONObject = isJSONObject;
|
|
37
|
+
exports.objectIdSchema = objectIdSchema;
|
|
38
|
+
exports.paginationQueryShape = paginationQueryShape;
|
|
39
|
+
exports.repeatableQueryValueSchema = repeatableQueryValueSchema;
|
|
40
|
+
exports.typedStringSchema = typedStringSchema;
|
|
41
|
+
exports.typedValueSchema = typedValueSchema;
|
|
42
|
+
//# sourceMappingURL=common.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.cjs","names":["z"],"sources":["../../src/common.ts"],"sourcesContent":["import { z } from 'zod/mini';\n\n/** 24-character hexadecimal MongoDB ObjectId, serialized as a string. */\nexport const objectIdSchema = z.string().check(z.regex(/^[a-fA-F0-9]{24}$/));\n\n/**\n * Query string value that may be repeated (`?id=a&id=b`): Fastify parses it\n * as a single string or as an array of strings.\n */\nexport const repeatableQueryValueSchema = z.union([\n z.string(),\n z.array(z.string()),\n]);\n\n/** Pagination fields shared by every paginated list endpoint. */\nexport const paginationQueryShape = {\n page: z.optional(z.union([z.string(), z.number()])),\n pageSize: z.optional(z.union([z.string(), z.number()])),\n};\n\n/** Date serialized by `JSON.stringify` (ISO 8601). */\nexport const dateTimeSchema = z.string();\n\n/**\n * String narrowed to a type owned by another package (ex: `Locale` from\n * `@intlayer/types`), without duplicating its values. Validated and\n * documented as a plain string.\n */\nexport const typedStringSchema = <Value extends string>() =>\n z.custom<Value>((value) => typeof value === 'string');\n\n/**\n * Value whose type is owned by another package (ex: AI configuration or\n * dictionaries from `@intlayer/types`), documented as any JSON value.\n * @param isValid - Optional shallow runtime check (defaults to accept all).\n */\nexport const typedValueSchema = <Value>(\n isValid: (value: unknown) => boolean = () => true\n) => z.custom<Value>(isValid);\n\n/** Whether a value is a plain JSON object (not null, not an array). */\nexport const isJSONObject = (\n value: unknown\n): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n"],"mappings":";;;;;AAGA,MAAa,iBAAiBA,WAAE,OAAO,CAAC,CAAC,MAAMA,WAAE,MAAM,mBAAmB,CAAC;;;;;AAM3E,MAAa,6BAA6BA,WAAE,MAAM,CAChDA,WAAE,OAAO,GACTA,WAAE,MAAMA,WAAE,OAAO,CAAC,CACpB,CAAC;;AAGD,MAAa,uBAAuB;CAClC,MAAMA,WAAE,SAASA,WAAE,MAAM,CAACA,WAAE,OAAO,GAAGA,WAAE,OAAO,CAAC,CAAC,CAAC;CAClD,UAAUA,WAAE,SAASA,WAAE,MAAM,CAACA,WAAE,OAAO,GAAGA,WAAE,OAAO,CAAC,CAAC,CAAC;AACxD;;AAGA,MAAa,iBAAiBA,WAAE,OAAO;;;;;;AAOvC,MAAa,0BACXA,WAAE,QAAe,UAAU,OAAO,UAAU,QAAQ;;;;;;AAOtD,MAAa,oBACX,gBAA6C,SAC1CA,WAAE,OAAc,OAAO;;AAG5B,MAAa,gBACX,UAEA,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
//#region src/defineRoute.ts
|
|
3
|
+
/** Identity helper preserving literal types of a route definition. */
|
|
4
|
+
const defineRoute = (route) => route;
|
|
5
|
+
/** Identity helper preserving literal types of a route group. */
|
|
6
|
+
const defineRouteGroup = (group) => group;
|
|
7
|
+
/** Untyped implementation of {@link buildRouteURL}. */
|
|
8
|
+
const joinRouteURL = (backendURL, prefix, path, params) => {
|
|
9
|
+
const resolvedPath = path.replace(/:([A-Za-z0-9_]+)/g, (_match, name) => {
|
|
10
|
+
const value = params?.[name];
|
|
11
|
+
if (value === void 0) throw new Error(`Missing route param "${name}" for ${path}`);
|
|
12
|
+
return encodeURIComponent(value);
|
|
13
|
+
});
|
|
14
|
+
return `${backendURL}${prefix}${resolvedPath === "/" ? "" : resolvedPath}`;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Builds the absolute URL of a route by joining the backend URL, the group
|
|
18
|
+
* prefix and the path, with `:param` segments replaced and URI-encoded.
|
|
19
|
+
*/
|
|
20
|
+
const buildRouteURL = (backendURL, group, route, ...[params]) => joinRouteURL(backendURL, group.prefix, route.path, params);
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.buildRouteURL = buildRouteURL;
|
|
24
|
+
exports.defineRoute = defineRoute;
|
|
25
|
+
exports.defineRouteGroup = defineRouteGroup;
|
|
26
|
+
//# sourceMappingURL=defineRoute.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineRoute.cjs","names":[],"sources":["../../src/defineRoute.ts"],"sourcesContent":["import type { $ZodType, input, output } from 'zod/v4/core';\n\n/** HTTP methods exposed by the Intlayer backend. */\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\n\n/** Zod schemas describing one route's input and output. */\nexport type RouteSchemas = {\n params?: $ZodType;\n querystring?: $ZodType;\n body?: $ZodType;\n /** Response schemas keyed by HTTP status code. */\n response?: Partial<Record<number, $ZodType>>;\n};\n\n/** One REST route: method, path relative to its group prefix, and schemas. */\nexport type RouteDefinition<\n Method extends HttpMethod = HttpMethod,\n Path extends string = string,\n Schemas extends RouteSchemas = RouteSchemas,\n> = {\n method: Method;\n /** Fastify-style path, relative to the group prefix (ex: `/:projectId`). */\n path: Path;\n /** One-line summary shown in the OpenAPI documentation. */\n summary: string;\n description?: string;\n schemas: Schemas;\n};\n\n/** A set of routes sharing a URL prefix and an OpenAPI tag. */\nexport type RouteGroup<\n Prefix extends string = string,\n Routes extends Record<string, RouteDefinition> = Record<\n string,\n RouteDefinition\n >,\n> = {\n /** Absolute prefix mounted on the backend (ex: `/api/project`). */\n prefix: Prefix;\n /** OpenAPI tag grouping the routes in the documentation. */\n tag: string;\n routes: Routes;\n};\n\n/** Identity helper preserving literal types of a route definition. */\nexport const defineRoute = <\n const Method extends HttpMethod,\n const Path extends string,\n const Schemas extends RouteSchemas,\n>(\n route: RouteDefinition<Method, Path, Schemas>\n): RouteDefinition<Method, Path, Schemas> => route;\n\n/** Identity helper preserving literal types of a route group. */\nexport const defineRouteGroup = <\n const Prefix extends string,\n const Routes extends Record<string, RouteDefinition>,\n>(\n group: RouteGroup<Prefix, Routes>\n): RouteGroup<Prefix, Routes> => group;\n\ntype SchemaOutput<Schema> = Schema extends $ZodType ? output<Schema> : never;\ntype SchemaInput<Schema> = Schema extends $ZodType ? input<Schema> : never;\n\n/** Request body as parsed by the backend (after validation). */\nexport type RouteBody<Route extends RouteDefinition> = SchemaOutput<\n Route['schemas']['body']\n>;\n/** Request body as sent by a client (before validation). */\nexport type RouteBodyInput<Route extends RouteDefinition> = SchemaInput<\n Route['schemas']['body']\n>;\n/** URL params as parsed by the backend. */\nexport type RouteParams<Route extends RouteDefinition> = SchemaOutput<\n Route['schemas']['params']\n>;\n/** Query string as parsed by the backend. */\nexport type RouteQuerystring<Route extends RouteDefinition> = SchemaOutput<\n Route['schemas']['querystring']\n>;\n/** Successful (200) response payload. */\nexport type RouteResponse<Route extends RouteDefinition> =\n Route['schemas']['response'] extends Record<200, infer Schema>\n ? SchemaOutput<Schema>\n : unknown;\n\n/** Method and path of every route, for clients that must not load the schemas. */\nexport type RouteEndpoints<Routes extends Record<string, RouteDefinition>> = {\n [Name in keyof Routes]: Pick<Routes[Name], 'method' | 'path'>;\n};\n\n/** Extracts `{ name: string }` from a `/:name` path pattern. */\nexport type PathParams<Path extends string> =\n Path extends `${string}:${infer Name}/${infer Rest}`\n ? { [Key in Name]: string } & PathParams<`/${Rest}`>\n : Path extends `${string}:${infer Name}`\n ? { [Key in Name]: string }\n : Record<never, never>;\n\n/** Untyped implementation of {@link buildRouteURL}. */\nconst joinRouteURL = (\n backendURL: string,\n prefix: string,\n path: string,\n params?: Record<string, string>\n): string => {\n const resolvedPath = path.replace(\n /:([A-Za-z0-9_]+)/g,\n (_match, name: string) => {\n const value = params?.[name];\n\n if (value === undefined) {\n throw new Error(`Missing route param \"${name}\" for ${path}`);\n }\n\n return encodeURIComponent(value);\n }\n );\n const normalizedPath = resolvedPath === '/' ? '' : resolvedPath;\n\n return `${backendURL}${prefix}${normalizedPath}`;\n};\n\n/**\n * Builds the absolute URL of a route by joining the backend URL, the group\n * prefix and the path, with `:param` segments replaced and URI-encoded.\n */\nexport const buildRouteURL = <Prefix extends string, Path extends string>(\n backendURL: string,\n group: Pick<RouteGroup<Prefix>, 'prefix'>,\n route: Pick<RouteDefinition<HttpMethod, Path>, 'path'>,\n ...[params]: keyof PathParams<Path> extends never\n ? []\n : [params: PathParams<Path>]\n): string =>\n joinRouteURL(\n backendURL,\n group.prefix,\n route.path,\n params as Record<string, string> | undefined\n );\n"],"mappings":";;;AA6CA,MAAa,eAKX,UAC2C;;AAG7C,MAAa,oBAIX,UAC+B;;AAyCjC,MAAM,gBACJ,YACA,QACA,MACA,WACW;CACX,MAAM,eAAe,KAAK,QACxB,sBACC,QAAQ,SAAiB;EACxB,MAAM,QAAQ,SAAS;EAEvB,IAAI,UAAU,QACZ,MAAM,IAAI,MAAM,wBAAwB,KAAK,QAAQ,MAAM;EAG7D,OAAO,mBAAmB,KAAK;CACjC,CACF;CAGA,OAAO,GAAG,aAAa,SAFA,iBAAiB,MAAM,KAAK;AAGrD;;;;;AAMA,MAAa,iBACX,YACA,OACA,OACA,GAAG,CAAC,YAIJ,aACE,YACA,MAAM,QACN,MAAM,MACN,MACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_defineRoute = require('./defineRoute.cjs');
|
|
3
|
+
let zod_mini = require("zod/mini");
|
|
4
|
+
|
|
5
|
+
//#region src/demo.ts
|
|
6
|
+
/** REST contract of the `/api/demo` routes (cloud only). */
|
|
7
|
+
const demoContract = require_defineRoute.defineRouteGroup({
|
|
8
|
+
prefix: "/api/demo",
|
|
9
|
+
tag: "Demo",
|
|
10
|
+
routes: { getDemoSession: require_defineRoute.defineRoute({
|
|
11
|
+
method: "GET",
|
|
12
|
+
path: "/session",
|
|
13
|
+
summary: "Sign the browser into the shared read-only demo account",
|
|
14
|
+
schemas: {
|
|
15
|
+
/** Sets the demo session cookie. */
|
|
16
|
+
response: { 200: zod_mini.z.object({ ok: zod_mini.z.boolean() }) } }
|
|
17
|
+
}) }
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.demoContract = demoContract;
|
|
22
|
+
//# sourceMappingURL=demo.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.cjs","names":["defineRouteGroup","defineRoute","z"],"sources":["../../src/demo.ts"],"sourcesContent":["import { z } from 'zod/mini';\nimport { defineRoute, defineRouteGroup } from './defineRoute';\n\n/** REST contract of the `/api/demo` routes (cloud only). */\nexport const demoContract = defineRouteGroup({\n prefix: '/api/demo',\n tag: 'Demo',\n routes: {\n getDemoSession: defineRoute({\n method: 'GET',\n path: '/session',\n summary: 'Sign the browser into the shared read-only demo account',\n schemas: {\n /** Sets the demo session cookie. */\n response: { 200: z.object({ ok: z.boolean() }) },\n },\n }),\n },\n});\n\n/** Route definitions of the `/api/demo` group, by name. */\nexport type DemoRoutes = (typeof demoContract)['routes'];\n\nexport type GetDemoSessionResult = { ok: boolean };\n"],"mappings":";;;;;;AAIA,MAAa,eAAeA,qCAAiB;CAC3C,QAAQ;CACR,KAAK;CACL,QAAQ,EACN,gBAAgBC,gCAAY;EAC1B,QAAQ;EACR,MAAM;EACN,SAAS;EACT,SAAS;;AAEP,UAAU,EAAE,KAAKC,WAAE,OAAO,EAAE,IAAIA,WAAE,QAAQ,EAAE,CAAC,EAAE,EACjD;CACF,CAAC,EACH;AACF,CAAC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_common = require('./common.cjs');
|
|
3
|
+
const require_defineRoute = require('./defineRoute.cjs');
|
|
4
|
+
const require_responseData = require('./responseData.cjs');
|
|
5
|
+
let zod_mini = require("zod/mini");
|
|
6
|
+
|
|
7
|
+
//#region src/dictionary.ts
|
|
8
|
+
/** Whether a value looks like a dictionary (object with a string `key`). */
|
|
9
|
+
const isDictionaryLike = (value) => require_common.isJSONObject(value) && typeof value.key === "string";
|
|
10
|
+
/** Dictionary as returned by the API (content documented as any JSON). */
|
|
11
|
+
const dictionarySchema = require_common.typedValueSchema(isDictionaryLike);
|
|
12
|
+
/** Dictionary pushed by the CLI / editor (`@intlayer/types` shape). */
|
|
13
|
+
const localDictionarySchema = require_common.typedValueSchema(isDictionaryLike);
|
|
14
|
+
/** Content node of a dictionary (`@intlayer/types`). */
|
|
15
|
+
const contentNodeSchema = require_common.typedValueSchema();
|
|
16
|
+
/** Result of a push, per dictionary. */
|
|
17
|
+
const pushedDictionarySchema = zod_mini.z.object({
|
|
18
|
+
key: zod_mini.z.string(),
|
|
19
|
+
localId: zod_mini.z.string(),
|
|
20
|
+
id: zod_mini.z.optional(zod_mini.z.string())
|
|
21
|
+
});
|
|
22
|
+
const pushDictionariesResultSchema = zod_mini.z.object({
|
|
23
|
+
newDictionaries: zod_mini.z.array(pushedDictionarySchema),
|
|
24
|
+
updatedDictionaries: zod_mini.z.array(pushedDictionarySchema),
|
|
25
|
+
upToDateDictionaries: zod_mini.z.array(pushedDictionarySchema),
|
|
26
|
+
error: zod_mini.z.array(zod_mini.z.object({
|
|
27
|
+
id: zod_mini.z.optional(zod_mini.z.string()),
|
|
28
|
+
key: zod_mini.z.string(),
|
|
29
|
+
localId: zod_mini.z.optional(zod_mini.z.string()),
|
|
30
|
+
message: zod_mini.z.string()
|
|
31
|
+
}))
|
|
32
|
+
});
|
|
33
|
+
const dictionaryIdParamsSchema = zod_mini.z.object({ dictionaryId: require_common.objectIdSchema });
|
|
34
|
+
/** REST contract of the `/api/dictionary` routes. */
|
|
35
|
+
const dictionaryContract = require_defineRoute.defineRouteGroup({
|
|
36
|
+
prefix: "/api/dictionary",
|
|
37
|
+
tag: "Dictionary",
|
|
38
|
+
routes: {
|
|
39
|
+
getDictionaries: require_defineRoute.defineRoute({
|
|
40
|
+
method: "GET",
|
|
41
|
+
path: "/",
|
|
42
|
+
summary: "List the dictionaries of the selected project",
|
|
43
|
+
schemas: {
|
|
44
|
+
querystring: zod_mini.z.looseObject({
|
|
45
|
+
...require_common.paginationQueryShape,
|
|
46
|
+
ids: zod_mini.z.optional(require_common.repeatableQueryValueSchema),
|
|
47
|
+
projectId: zod_mini.z.optional(zod_mini.z.string()),
|
|
48
|
+
projectIds: zod_mini.z.optional(require_common.repeatableQueryValueSchema),
|
|
49
|
+
organizationId: zod_mini.z.optional(zod_mini.z.string()),
|
|
50
|
+
organizationIds: zod_mini.z.optional(require_common.repeatableQueryValueSchema),
|
|
51
|
+
userId: zod_mini.z.optional(zod_mini.z.string()),
|
|
52
|
+
userIds: zod_mini.z.optional(require_common.repeatableQueryValueSchema),
|
|
53
|
+
creatorId: zod_mini.z.optional(zod_mini.z.string()),
|
|
54
|
+
creatorIds: zod_mini.z.optional(require_common.repeatableQueryValueSchema),
|
|
55
|
+
title: zod_mini.z.optional(zod_mini.z.string()),
|
|
56
|
+
description: zod_mini.z.optional(zod_mini.z.string()),
|
|
57
|
+
key: zod_mini.z.optional(zod_mini.z.string()),
|
|
58
|
+
keys: zod_mini.z.optional(require_common.repeatableQueryValueSchema),
|
|
59
|
+
tags: zod_mini.z.optional(require_common.repeatableQueryValueSchema),
|
|
60
|
+
location: zod_mini.z.optional(zod_mini.z.enum([
|
|
61
|
+
"remote",
|
|
62
|
+
"local",
|
|
63
|
+
"both",
|
|
64
|
+
"none"
|
|
65
|
+
]))
|
|
66
|
+
}),
|
|
67
|
+
response: { 200: require_responseData.paginatedResponseSchema(dictionarySchema) }
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
getDictionariesKeys: require_defineRoute.defineRoute({
|
|
71
|
+
method: "GET",
|
|
72
|
+
path: "/keys",
|
|
73
|
+
summary: "Keys of every dictionary of the selected project",
|
|
74
|
+
schemas: { response: { 200: require_responseData.responseDataSchema(zod_mini.z.array(zod_mini.z.string())) } }
|
|
75
|
+
}),
|
|
76
|
+
getDictionariesUpdateTimestamp: require_defineRoute.defineRoute({
|
|
77
|
+
method: "GET",
|
|
78
|
+
path: "/update",
|
|
79
|
+
summary: "Last update time (epoch ms) of each dictionary, by id",
|
|
80
|
+
schemas: { response: { 200: require_responseData.responseDataSchema(zod_mini.z.record(zod_mini.z.string(), zod_mini.z.object({
|
|
81
|
+
key: zod_mini.z.string(),
|
|
82
|
+
updatedAt: zod_mini.z.number()
|
|
83
|
+
}))) } }
|
|
84
|
+
}),
|
|
85
|
+
getDictionariesByKeys: require_defineRoute.defineRoute({
|
|
86
|
+
method: "GET",
|
|
87
|
+
path: "/by-keys",
|
|
88
|
+
summary: "Get several dictionaries by key",
|
|
89
|
+
schemas: {
|
|
90
|
+
querystring: zod_mini.z.object({
|
|
91
|
+
/** Comma-separated string or repeated parameter. */
|
|
92
|
+
keys: require_common.repeatableQueryValueSchema,
|
|
93
|
+
version: zod_mini.z.optional(zod_mini.z.string())
|
|
94
|
+
}),
|
|
95
|
+
response: { 200: require_responseData.responseDataSchema(zod_mini.z.array(dictionarySchema)) }
|
|
96
|
+
}
|
|
97
|
+
}),
|
|
98
|
+
getDictionary: require_defineRoute.defineRoute({
|
|
99
|
+
method: "GET",
|
|
100
|
+
path: "/:dictionaryKey",
|
|
101
|
+
summary: "Get a dictionary by key",
|
|
102
|
+
schemas: {
|
|
103
|
+
params: zod_mini.z.object({ dictionaryKey: zod_mini.z.string().check(zod_mini.z.minLength(1), zod_mini.z.maxLength(255)) }),
|
|
104
|
+
querystring: zod_mini.z.object({ version: zod_mini.z.optional(zod_mini.z.string()) }),
|
|
105
|
+
response: { 200: require_responseData.responseDataSchema(dictionarySchema) }
|
|
106
|
+
}
|
|
107
|
+
}),
|
|
108
|
+
addDictionary: require_defineRoute.defineRoute({
|
|
109
|
+
method: "POST",
|
|
110
|
+
path: "/",
|
|
111
|
+
summary: "Create a dictionary in the selected project",
|
|
112
|
+
schemas: {
|
|
113
|
+
body: zod_mini.z.object({ dictionary: zod_mini.z.looseObject({
|
|
114
|
+
key: zod_mini.z.string().check(zod_mini.z.minLength(1)),
|
|
115
|
+
projectIds: zod_mini.z.array(zod_mini.z.string()),
|
|
116
|
+
content: zod_mini.z.optional(contentNodeSchema),
|
|
117
|
+
title: zod_mini.z.optional(zod_mini.z.string()),
|
|
118
|
+
description: zod_mini.z.optional(zod_mini.z.string()),
|
|
119
|
+
priority: zod_mini.z.optional(zod_mini.z.number()),
|
|
120
|
+
importMode: zod_mini.z.optional(zod_mini.z.enum([
|
|
121
|
+
"static",
|
|
122
|
+
"dynamic",
|
|
123
|
+
"fetch"
|
|
124
|
+
])),
|
|
125
|
+
tags: zod_mini.z.optional(zod_mini.z.array(zod_mini.z.string())),
|
|
126
|
+
environmentId: zod_mini.z.optional(zod_mini.z.string())
|
|
127
|
+
}) }),
|
|
128
|
+
response: { 200: require_responseData.responseDataSchema(dictionarySchema) }
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
pushDictionaries: require_defineRoute.defineRoute({
|
|
132
|
+
method: "PATCH",
|
|
133
|
+
path: "/",
|
|
134
|
+
summary: "Push local dictionaries (CLI): create or version them",
|
|
135
|
+
schemas: {
|
|
136
|
+
body: zod_mini.z.object({ dictionaries: zod_mini.z.array(localDictionarySchema) }),
|
|
137
|
+
response: { 200: require_responseData.responseDataSchema(pushDictionariesResultSchema) }
|
|
138
|
+
}
|
|
139
|
+
}),
|
|
140
|
+
updateDictionary: require_defineRoute.defineRoute({
|
|
141
|
+
method: "PUT",
|
|
142
|
+
path: "/:dictionaryId",
|
|
143
|
+
summary: "Update a dictionary of the selected project",
|
|
144
|
+
schemas: {
|
|
145
|
+
params: dictionaryIdParamsSchema,
|
|
146
|
+
body: require_common.typedValueSchema(require_common.isJSONObject),
|
|
147
|
+
response: { 200: require_responseData.responseDataSchema(dictionarySchema) }
|
|
148
|
+
}
|
|
149
|
+
}),
|
|
150
|
+
deleteDictionary: require_defineRoute.defineRoute({
|
|
151
|
+
method: "DELETE",
|
|
152
|
+
path: "/:dictionaryId",
|
|
153
|
+
summary: "Delete a dictionary of the selected project",
|
|
154
|
+
schemas: {
|
|
155
|
+
params: dictionaryIdParamsSchema,
|
|
156
|
+
response: { 200: require_responseData.responseDataSchema(dictionarySchema) }
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
//#endregion
|
|
163
|
+
exports.contentNodeSchema = contentNodeSchema;
|
|
164
|
+
exports.dictionaryContract = dictionaryContract;
|
|
165
|
+
exports.dictionarySchema = dictionarySchema;
|
|
166
|
+
exports.localDictionarySchema = localDictionarySchema;
|
|
167
|
+
exports.pushDictionariesResultSchema = pushDictionariesResultSchema;
|
|
168
|
+
//# sourceMappingURL=dictionary.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dictionary.cjs","names":["isJSONObject","typedValueSchema","z","objectIdSchema","defineRouteGroup","defineRoute","paginationQueryShape","repeatableQueryValueSchema","paginatedResponseSchema","responseDataSchema"],"sources":["../../src/dictionary.ts"],"sourcesContent":["import type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport { z } from 'zod/mini';\nimport {\n isJSONObject,\n objectIdSchema,\n paginationQueryShape,\n repeatableQueryValueSchema,\n typedValueSchema,\n} from './common';\nimport {\n defineRoute,\n defineRouteGroup,\n type RouteBodyInput,\n type RouteParams,\n type RouteQuerystring,\n} from './defineRoute';\nimport {\n type PaginatedResponse,\n paginatedResponseSchema,\n type ResponseData,\n responseDataSchema,\n} from './responseData';\n\n/** Outcome of the last commit of a CMS edit to the source `.content` file. */\nexport type DictionarySourceSync = {\n status:\n | 'committed'\n | 'pull-request'\n | 'up-to-date'\n | 'file-not-found'\n | 'unsupported'\n | 'error';\n /** Commit (or pull request) link on the git provider. */\n url?: string;\n commitSha?: string;\n message?: string;\n syncedAt: string;\n};\n\n/** Fields the server adds to a stored dictionary. */\ntype DictionaryServerFields = {\n id: string;\n projectIds: string[];\n creatorId: string;\n /** Content versions, oldest first. */\n versionList: string[];\n /** Environment the dictionary belongs to; null = shared by all. */\n environmentId?: string | null;\n sourceSync?: DictionarySourceSync;\n createdAt: string;\n updatedAt: string;\n};\n\n/**\n * Dictionary as returned by the API: the `@intlayer/types` dictionary (the\n * framework-wide source of truth for content) plus the server fields.\n */\nexport type DictionaryAPI = Omit<Dictionary, keyof DictionaryServerFields> &\n DictionaryServerFields;\n\n/** Whether a value looks like a dictionary (object with a string `key`). */\nconst isDictionaryLike = (value: unknown): boolean =>\n isJSONObject(value) && typeof value.key === 'string';\n\n/** Dictionary as returned by the API (content documented as any JSON). */\nexport const dictionarySchema =\n typedValueSchema<DictionaryAPI>(isDictionaryLike);\n\n/** Dictionary pushed by the CLI / editor (`@intlayer/types` shape). */\nexport const localDictionarySchema =\n typedValueSchema<Dictionary>(isDictionaryLike);\n\n/** Content node of a dictionary (`@intlayer/types`). */\nexport const contentNodeSchema = typedValueSchema<ContentNode>();\n\n/** Result of a push, per dictionary. */\nconst pushedDictionarySchema = z.object({\n key: z.string(),\n localId: z.string(),\n id: z.optional(z.string()),\n});\n\nexport const pushDictionariesResultSchema = z.object({\n newDictionaries: z.array(pushedDictionarySchema),\n updatedDictionaries: z.array(pushedDictionarySchema),\n upToDateDictionaries: z.array(pushedDictionarySchema),\n error: z.array(\n z.object({\n id: z.optional(z.string()),\n key: z.string(),\n localId: z.optional(z.string()),\n message: z.string(),\n })\n ),\n});\n\nconst dictionaryIdParamsSchema = z.object({ dictionaryId: objectIdSchema });\n\n/** REST contract of the `/api/dictionary` routes. */\nexport const dictionaryContract = defineRouteGroup({\n prefix: '/api/dictionary',\n tag: 'Dictionary',\n routes: {\n getDictionaries: defineRoute({\n method: 'GET',\n path: '/',\n summary: 'List the dictionaries of the selected project',\n schemas: {\n querystring: z.looseObject({\n ...paginationQueryShape,\n ids: z.optional(repeatableQueryValueSchema),\n projectId: z.optional(z.string()),\n projectIds: z.optional(repeatableQueryValueSchema),\n organizationId: z.optional(z.string()),\n organizationIds: z.optional(repeatableQueryValueSchema),\n userId: z.optional(z.string()),\n userIds: z.optional(repeatableQueryValueSchema),\n creatorId: z.optional(z.string()),\n creatorIds: z.optional(repeatableQueryValueSchema),\n title: z.optional(z.string()),\n description: z.optional(z.string()),\n key: z.optional(z.string()),\n keys: z.optional(repeatableQueryValueSchema),\n tags: z.optional(repeatableQueryValueSchema),\n location: z.optional(z.enum(['remote', 'local', 'both', 'none'])),\n }),\n response: { 200: paginatedResponseSchema(dictionarySchema) },\n },\n }),\n getDictionariesKeys: defineRoute({\n method: 'GET',\n path: '/keys',\n summary: 'Keys of every dictionary of the selected project',\n schemas: {\n response: { 200: responseDataSchema(z.array(z.string())) },\n },\n }),\n getDictionariesUpdateTimestamp: defineRoute({\n method: 'GET',\n path: '/update',\n summary: 'Last update time (epoch ms) of each dictionary, by id',\n schemas: {\n response: {\n 200: responseDataSchema(\n z.record(\n z.string(),\n z.object({ key: z.string(), updatedAt: z.number() })\n )\n ),\n },\n },\n }),\n getDictionariesByKeys: defineRoute({\n method: 'GET',\n path: '/by-keys',\n summary: 'Get several dictionaries by key',\n schemas: {\n querystring: z.object({\n /** Comma-separated string or repeated parameter. */\n keys: repeatableQueryValueSchema,\n version: z.optional(z.string()),\n }),\n response: { 200: responseDataSchema(z.array(dictionarySchema)) },\n },\n }),\n getDictionary: defineRoute({\n method: 'GET',\n path: '/:dictionaryKey',\n summary: 'Get a dictionary by key',\n schemas: {\n params: z.object({\n dictionaryKey: z.string().check(z.minLength(1), z.maxLength(255)),\n }),\n querystring: z.object({ version: z.optional(z.string()) }),\n response: { 200: responseDataSchema(dictionarySchema) },\n },\n }),\n addDictionary: defineRoute({\n method: 'POST',\n path: '/',\n summary: 'Create a dictionary in the selected project',\n schemas: {\n body: z.object({\n dictionary: z.looseObject({\n key: z.string().check(z.minLength(1)),\n projectIds: z.array(z.string()),\n content: z.optional(contentNodeSchema),\n title: z.optional(z.string()),\n description: z.optional(z.string()),\n priority: z.optional(z.number()),\n importMode: z.optional(z.enum(['static', 'dynamic', 'fetch'])),\n tags: z.optional(z.array(z.string())),\n environmentId: z.optional(z.string()),\n }),\n }),\n response: { 200: responseDataSchema(dictionarySchema) },\n },\n }),\n pushDictionaries: defineRoute({\n method: 'PATCH',\n path: '/',\n summary: 'Push local dictionaries (CLI): create or version them',\n schemas: {\n body: z.object({ dictionaries: z.array(localDictionarySchema) }),\n response: { 200: responseDataSchema(pushDictionariesResultSchema) },\n },\n }),\n updateDictionary: defineRoute({\n method: 'PUT',\n path: '/:dictionaryId',\n summary: 'Update a dictionary of the selected project',\n schemas: {\n params: dictionaryIdParamsSchema,\n body: typedValueSchema<Partial<DictionaryAPI>>(isJSONObject),\n response: { 200: responseDataSchema(dictionarySchema) },\n },\n }),\n deleteDictionary: defineRoute({\n method: 'DELETE',\n path: '/:dictionaryId',\n summary: 'Delete a dictionary of the selected project',\n schemas: {\n params: dictionaryIdParamsSchema,\n response: { 200: responseDataSchema(dictionarySchema) },\n },\n }),\n },\n});\n\n/** Route definitions of the `/api/dictionary` group, by name. */\nexport type DictionaryRoutes = (typeof dictionaryContract)['routes'];\n\nexport type PushDictionariesResultData = z.output<\n typeof pushDictionariesResultSchema\n>;\nexport type GetDictionariesParams = RouteQuerystring<\n DictionaryRoutes['getDictionaries']\n>;\nexport type GetDictionariesResult = PaginatedResponse<DictionaryAPI>;\nexport type GetDictionariesKeysResult = ResponseData<string[]>;\nexport type GetDictionariesUpdateTimestampResult = ResponseData<\n Record<string, { key: string; updatedAt: number }>\n>;\nexport type GetDictionaryParams = RouteParams<\n DictionaryRoutes['getDictionary']\n>;\nexport type GetDictionaryQuery = RouteQuerystring<\n DictionaryRoutes['getDictionary']\n>;\nexport type GetDictionaryResult = ResponseData<DictionaryAPI>;\nexport type GetDictionariesByKeysQuery = RouteQuerystring<\n DictionaryRoutes['getDictionariesByKeys']\n>;\nexport type GetDictionariesByKeysResult = ResponseData<DictionaryAPI[]>;\nexport type AddDictionaryBody = RouteBodyInput<\n DictionaryRoutes['addDictionary']\n>;\nexport type AddDictionaryResult = ResponseData<DictionaryAPI>;\nexport type PushDictionariesBody = RouteBodyInput<\n DictionaryRoutes['pushDictionaries']\n>;\nexport type PushDictionariesResult = ResponseData<PushDictionariesResultData>;\nexport type UpdateDictionaryParam = RouteParams<\n DictionaryRoutes['updateDictionary']\n>;\nexport type UpdateDictionaryBody = RouteBodyInput<\n DictionaryRoutes['updateDictionary']\n>;\nexport type UpdateDictionaryResult = ResponseData<DictionaryAPI>;\nexport type DeleteDictionaryParam = RouteParams<\n DictionaryRoutes['deleteDictionary']\n>;\nexport type DeleteDictionaryResult = ResponseData<DictionaryAPI>;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_common = require('./common.cjs');
|
|
3
|
+
const require_defineRoute = require('./defineRoute.cjs');
|
|
4
|
+
const require_responseData = require('./responseData.cjs');
|
|
5
|
+
const require_project = require('./project.cjs');
|
|
6
|
+
let zod_mini = require("zod/mini");
|
|
7
|
+
|
|
8
|
+
//#region src/environment.ts
|
|
9
|
+
const environmentIdParamsSchema = zod_mini.z.object({ environmentId: require_common.objectIdSchema });
|
|
10
|
+
/** Every environment of the project, production first when virtual. */
|
|
11
|
+
const environmentsResponseSchema = require_responseData.responseDataSchema(zod_mini.z.array(require_project.environmentSchema));
|
|
12
|
+
/** REST contract of the `/api/project/environment` routes. */
|
|
13
|
+
const environmentContract = require_defineRoute.defineRouteGroup({
|
|
14
|
+
prefix: "/api/project/environment",
|
|
15
|
+
tag: "Environment",
|
|
16
|
+
routes: {
|
|
17
|
+
addEnvironment: require_defineRoute.defineRoute({
|
|
18
|
+
method: "POST",
|
|
19
|
+
path: "/",
|
|
20
|
+
summary: "Create an environment in the selected project",
|
|
21
|
+
schemas: {
|
|
22
|
+
body: zod_mini.z.object({
|
|
23
|
+
name: zod_mini.z.string(),
|
|
24
|
+
configuration: zod_mini.z.optional(require_project.projectConfigurationSchema)
|
|
25
|
+
}),
|
|
26
|
+
response: { 200: environmentsResponseSchema }
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
updateEnvironment: require_defineRoute.defineRoute({
|
|
30
|
+
method: "PUT",
|
|
31
|
+
path: "/:environmentId",
|
|
32
|
+
summary: "Rename or reconfigure an environment",
|
|
33
|
+
schemas: {
|
|
34
|
+
params: environmentIdParamsSchema,
|
|
35
|
+
body: zod_mini.z.object({
|
|
36
|
+
name: zod_mini.z.optional(zod_mini.z.string()),
|
|
37
|
+
configuration: zod_mini.z.optional(require_project.projectConfigurationSchema)
|
|
38
|
+
}),
|
|
39
|
+
response: { 200: environmentsResponseSchema }
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
42
|
+
deleteEnvironment: require_defineRoute.defineRoute({
|
|
43
|
+
method: "DELETE",
|
|
44
|
+
path: "/:environmentId",
|
|
45
|
+
summary: "Delete an environment",
|
|
46
|
+
schemas: {
|
|
47
|
+
params: environmentIdParamsSchema,
|
|
48
|
+
response: { 200: environmentsResponseSchema }
|
|
49
|
+
}
|
|
50
|
+
}),
|
|
51
|
+
resetToProductionEnvironment: require_defineRoute.defineRoute({
|
|
52
|
+
method: "PUT",
|
|
53
|
+
path: "/production/select",
|
|
54
|
+
summary: "Select the production environment for the session",
|
|
55
|
+
schemas: { response: { 200: require_responseData.responseDataSchema(zod_mini.z.nullable(require_project.environmentSchema)) } }
|
|
56
|
+
}),
|
|
57
|
+
selectEnvironment: require_defineRoute.defineRoute({
|
|
58
|
+
method: "PUT",
|
|
59
|
+
path: "/:environmentId/select",
|
|
60
|
+
summary: "Select an environment for the session",
|
|
61
|
+
schemas: {
|
|
62
|
+
params: environmentIdParamsSchema,
|
|
63
|
+
response: { 200: require_responseData.responseDataSchema(require_project.environmentSchema) }
|
|
64
|
+
}
|
|
65
|
+
}),
|
|
66
|
+
migrateEnvironment: require_defineRoute.defineRoute({
|
|
67
|
+
method: "POST",
|
|
68
|
+
path: "/migrate",
|
|
69
|
+
summary: "Copy dictionaries and configuration between environments",
|
|
70
|
+
schemas: {
|
|
71
|
+
body: zod_mini.z.object({
|
|
72
|
+
/** Environment id, or `production` for the default environment. */
|
|
73
|
+
sourceEnvironmentId: zod_mini.z.string(),
|
|
74
|
+
targetEnvironmentId: zod_mini.z.string(),
|
|
75
|
+
strategy: zod_mini.z.enum(["overwrite", "fill-missing"]),
|
|
76
|
+
migrateContent: zod_mini.z.optional(zod_mini.z.boolean()),
|
|
77
|
+
migrateConfiguration: zod_mini.z.optional(zod_mini.z.boolean())
|
|
78
|
+
}),
|
|
79
|
+
response: { 200: require_responseData.responseDataSchema(zod_mini.z.object({
|
|
80
|
+
migratedDictionaries: zod_mini.z.number(),
|
|
81
|
+
skippedDictionaries: zod_mini.z.number(),
|
|
82
|
+
configurationMigrated: zod_mini.z.boolean()
|
|
83
|
+
})) }
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
exports.environmentContract = environmentContract;
|
|
91
|
+
//# sourceMappingURL=environment.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.cjs","names":["z","objectIdSchema","responseDataSchema","environmentSchema","defineRouteGroup","defineRoute","projectConfigurationSchema"],"sources":["../../src/environment.ts"],"sourcesContent":["import { z } from 'zod/mini';\nimport { objectIdSchema } from './common';\nimport {\n defineRoute,\n defineRouteGroup,\n type RouteBodyInput,\n type RouteParams,\n} from './defineRoute';\nimport {\n type EnvironmentAPI,\n environmentSchema,\n projectConfigurationSchema,\n} from './project';\nimport { type ResponseData, responseDataSchema } from './responseData';\n\nconst environmentIdParamsSchema = z.object({ environmentId: objectIdSchema });\n\n/** Every environment of the project, production first when virtual. */\nconst environmentsResponseSchema = responseDataSchema(\n z.array(environmentSchema)\n);\n\n/** REST contract of the `/api/project/environment` routes. */\nexport const environmentContract = defineRouteGroup({\n prefix: '/api/project/environment',\n tag: 'Environment',\n routes: {\n addEnvironment: defineRoute({\n method: 'POST',\n path: '/',\n summary: 'Create an environment in the selected project',\n schemas: {\n body: z.object({\n name: z.string(),\n configuration: z.optional(projectConfigurationSchema),\n }),\n response: { 200: environmentsResponseSchema },\n },\n }),\n updateEnvironment: defineRoute({\n method: 'PUT',\n path: '/:environmentId',\n summary: 'Rename or reconfigure an environment',\n schemas: {\n params: environmentIdParamsSchema,\n body: z.object({\n name: z.optional(z.string()),\n configuration: z.optional(projectConfigurationSchema),\n }),\n response: { 200: environmentsResponseSchema },\n },\n }),\n deleteEnvironment: defineRoute({\n method: 'DELETE',\n path: '/:environmentId',\n summary: 'Delete an environment',\n schemas: {\n params: environmentIdParamsSchema,\n response: { 200: environmentsResponseSchema },\n },\n }),\n resetToProductionEnvironment: defineRoute({\n method: 'PUT',\n path: '/production/select',\n summary: 'Select the production environment for the session',\n schemas: {\n response: { 200: responseDataSchema(z.nullable(environmentSchema)) },\n },\n }),\n selectEnvironment: defineRoute({\n method: 'PUT',\n path: '/:environmentId/select',\n summary: 'Select an environment for the session',\n schemas: {\n params: environmentIdParamsSchema,\n response: { 200: responseDataSchema(environmentSchema) },\n },\n }),\n migrateEnvironment: defineRoute({\n method: 'POST',\n path: '/migrate',\n summary: 'Copy dictionaries and configuration between environments',\n schemas: {\n body: z.object({\n /** Environment id, or `production` for the default environment. */\n sourceEnvironmentId: z.string(),\n targetEnvironmentId: z.string(),\n strategy: z.enum(['overwrite', 'fill-missing']),\n migrateContent: z.optional(z.boolean()),\n migrateConfiguration: z.optional(z.boolean()),\n }),\n response: {\n 200: responseDataSchema(\n z.object({\n migratedDictionaries: z.number(),\n skippedDictionaries: z.number(),\n configurationMigrated: z.boolean(),\n })\n ),\n },\n },\n }),\n },\n});\n\n/** Route definitions of the `/api/project/environment` group, by name. */\nexport type EnvironmentRoutes = (typeof environmentContract)['routes'];\n\nexport type AddEnvironmentBody = RouteBodyInput<\n EnvironmentRoutes['addEnvironment']\n>;\nexport type AddEnvironmentResult = ResponseData<EnvironmentAPI[]>;\nexport type UpdateEnvironmentParams = RouteParams<\n EnvironmentRoutes['updateEnvironment']\n>;\nexport type UpdateEnvironmentBody = RouteBodyInput<\n EnvironmentRoutes['updateEnvironment']\n>;\nexport type UpdateEnvironmentResult = ResponseData<EnvironmentAPI[]>;\nexport type DeleteEnvironmentParams = RouteParams<\n EnvironmentRoutes['deleteEnvironment']\n>;\nexport type DeleteEnvironmentResult = ResponseData<EnvironmentAPI[]>;\nexport type SelectEnvironmentParams = RouteParams<\n EnvironmentRoutes['selectEnvironment']\n>;\nexport type SelectEnvironmentResult = ResponseData<EnvironmentAPI>;\nexport type ResetToProductionEnvironmentResult =\n ResponseData<EnvironmentAPI | null>;\nexport type MigrateEnvironmentBody = RouteBodyInput<\n EnvironmentRoutes['migrateEnvironment']\n>;\nexport type MigrateEnvironmentResult = ResponseData<{\n migratedDictionaries: number;\n skippedDictionaries: number;\n configurationMigrated: boolean;\n}>;\n"],"mappings":";;;;;;;;AAeA,MAAM,4BAA4BA,WAAE,OAAO,EAAE,eAAeC,8BAAe,CAAC;;AAG5E,MAAM,6BAA6BC,wCACjCF,WAAE,MAAMG,iCAAiB,CAC3B;;AAGA,MAAa,sBAAsBC,qCAAiB;CAClD,QAAQ;CACR,KAAK;CACL,QAAQ;EACN,gBAAgBC,gCAAY;GAC1B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,MAAML,WAAE,OAAO;KACb,MAAMA,WAAE,OAAO;KACf,eAAeA,WAAE,SAASM,0CAA0B;IACtD,CAAC;IACD,UAAU,EAAE,KAAK,2BAA2B;GAC9C;EACF,CAAC;EACD,mBAAmBD,gCAAY;GAC7B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,QAAQ;IACR,MAAML,WAAE,OAAO;KACb,MAAMA,WAAE,SAASA,WAAE,OAAO,CAAC;KAC3B,eAAeA,WAAE,SAASM,0CAA0B;IACtD,CAAC;IACD,UAAU,EAAE,KAAK,2BAA2B;GAC9C;EACF,CAAC;EACD,mBAAmBD,gCAAY;GAC7B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,QAAQ;IACR,UAAU,EAAE,KAAK,2BAA2B;GAC9C;EACF,CAAC;EACD,8BAA8BA,gCAAY;GACxC,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS,EACP,UAAU,EAAE,KAAKH,wCAAmBF,WAAE,SAASG,iCAAiB,CAAC,EAAE,EACrE;EACF,CAAC;EACD,mBAAmBE,gCAAY;GAC7B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,QAAQ;IACR,UAAU,EAAE,KAAKH,wCAAmBC,iCAAiB,EAAE;GACzD;EACF,CAAC;EACD,oBAAoBE,gCAAY;GAC9B,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,MAAML,WAAE,OAAO;;KAEb,qBAAqBA,WAAE,OAAO;KAC9B,qBAAqBA,WAAE,OAAO;KAC9B,UAAUA,WAAE,KAAK,CAAC,aAAa,cAAc,CAAC;KAC9C,gBAAgBA,WAAE,SAASA,WAAE,QAAQ,CAAC;KACtC,sBAAsBA,WAAE,SAASA,WAAE,QAAQ,CAAC;IAC9C,CAAC;IACD,UAAU,EACR,KAAKE,wCACHF,WAAE,OAAO;KACP,sBAAsBA,WAAE,OAAO;KAC/B,qBAAqBA,WAAE,OAAO;KAC9B,uBAAuBA,WAAE,QAAQ;IACnC,CAAC,CACH,EACF;GACF;EACF,CAAC;CACH;AACF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_defineRoute = require('./defineRoute.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/eventListener.ts
|
|
5
|
+
/** Live dictionary change stream (server-sent events). */
|
|
6
|
+
const eventListenerContract = require_defineRoute.defineRouteGroup({
|
|
7
|
+
prefix: "/api/event-listener",
|
|
8
|
+
tag: "Event listener",
|
|
9
|
+
routes: { checkDictionaryChangeSSE: require_defineRoute.defineRoute({
|
|
10
|
+
method: "GET",
|
|
11
|
+
path: "/",
|
|
12
|
+
summary: "Stream dictionary changes of the project (server-sent events)",
|
|
13
|
+
schemas: {}
|
|
14
|
+
}) }
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.eventListenerContract = eventListenerContract;
|
|
19
|
+
//# sourceMappingURL=eventListener.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventListener.cjs","names":["defineRouteGroup","defineRoute"],"sources":["../../src/eventListener.ts"],"sourcesContent":["import { defineRoute, defineRouteGroup } from './defineRoute';\nimport type { DictionaryAPI } from './dictionary';\n\n/** Live dictionary change stream (server-sent events). */\nexport const eventListenerContract = defineRouteGroup({\n prefix: '/api/event-listener',\n tag: 'Event listener',\n routes: {\n checkDictionaryChangeSSE: defineRoute({\n method: 'GET',\n path: '/',\n summary: 'Stream dictionary changes of the project (server-sent events)',\n schemas: {},\n }),\n },\n});\n\n/** Route definitions of the event listener group, by name. */\nexport type EventListenerRoutes = (typeof eventListenerContract)['routes'];\n\n/** Message pushed on the dictionary change stream. */\nexport type MessageEventData = {\n object: 'DICTIONARY';\n status: 'ADDED' | 'UPDATED' | 'DELETED' | 'CREATED';\n data: DictionaryAPI;\n};\n"],"mappings":";;;;;AAIA,MAAa,wBAAwBA,qCAAiB;CACpD,QAAQ;CACR,KAAK;CACL,QAAQ,EACN,0BAA0BC,gCAAY;EACpC,QAAQ;EACR,MAAM;EACN,SAAS;EACT,SAAS,CAAC;CACZ,CAAC,EACH;AACF,CAAC"}
|