@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.
Files changed (252) hide show
  1. package/dist/cjs/ai.cjs +267 -0
  2. package/dist/cjs/ai.cjs.map +1 -0
  3. package/dist/cjs/analytics.cjs +175 -0
  4. package/dist/cjs/analytics.cjs.map +1 -0
  5. package/dist/cjs/asset.cjs +88 -0
  6. package/dist/cjs/asset.cjs.map +1 -0
  7. package/dist/cjs/blogComment.cjs +98 -0
  8. package/dist/cjs/blogComment.cjs.map +1 -0
  9. package/dist/cjs/cliSessionToken.cjs +40 -0
  10. package/dist/cjs/cliSessionToken.cjs.map +1 -0
  11. package/dist/cjs/common.cjs +42 -0
  12. package/dist/cjs/common.cjs.map +1 -0
  13. package/dist/cjs/defineRoute.cjs +26 -0
  14. package/dist/cjs/defineRoute.cjs.map +1 -0
  15. package/dist/cjs/demo.cjs +22 -0
  16. package/dist/cjs/demo.cjs.map +1 -0
  17. package/dist/cjs/dictionary.cjs +168 -0
  18. package/dist/cjs/dictionary.cjs.map +1 -0
  19. package/dist/cjs/environment.cjs +91 -0
  20. package/dist/cjs/environment.cjs.map +1 -0
  21. package/dist/cjs/eventListener.cjs +19 -0
  22. package/dist/cjs/eventListener.cjs.map +1 -0
  23. package/dist/cjs/gitProviders.cjs +361 -0
  24. package/dist/cjs/gitProviders.cjs.map +1 -0
  25. package/dist/cjs/newsletter.cjs +50 -0
  26. package/dist/cjs/newsletter.cjs.map +1 -0
  27. package/dist/cjs/oAuth2.cjs +62 -0
  28. package/dist/cjs/oAuth2.cjs.map +1 -0
  29. package/dist/cjs/organization.cjs +226 -0
  30. package/dist/cjs/organization.cjs.map +1 -0
  31. package/dist/cjs/project.cjs +401 -0
  32. package/dist/cjs/project.cjs.map +1 -0
  33. package/dist/cjs/public.cjs +60 -0
  34. package/dist/cjs/public.cjs.map +1 -0
  35. package/dist/cjs/responseData.cjs +33 -0
  36. package/dist/cjs/responseData.cjs.map +1 -0
  37. package/dist/cjs/reviewer.cjs +401 -0
  38. package/dist/cjs/reviewer.cjs.map +1 -0
  39. package/dist/cjs/scan.cjs +235 -0
  40. package/dist/cjs/scan.cjs.map +1 -0
  41. package/dist/cjs/search.cjs +40 -0
  42. package/dist/cjs/search.cjs.map +1 -0
  43. package/dist/cjs/session.cjs +56 -0
  44. package/dist/cjs/session.cjs.map +1 -0
  45. package/dist/cjs/showcaseProject.cjs +185 -0
  46. package/dist/cjs/showcaseProject.cjs.map +1 -0
  47. package/dist/cjs/stripe.cjs +388 -0
  48. package/dist/cjs/stripe.cjs.map +1 -0
  49. package/dist/cjs/tag.cjs +83 -0
  50. package/dist/cjs/tag.cjs.map +1 -0
  51. package/dist/cjs/translation.cjs +54 -0
  52. package/dist/cjs/translation.cjs.map +1 -0
  53. package/dist/cjs/user.cjs +153 -0
  54. package/dist/cjs/user.cjs.map +1 -0
  55. package/dist/esm/ai.mjs +261 -0
  56. package/dist/esm/ai.mjs.map +1 -0
  57. package/dist/esm/analytics.mjs +168 -0
  58. package/dist/esm/analytics.mjs.map +1 -0
  59. package/dist/esm/asset.mjs +86 -0
  60. package/dist/esm/asset.mjs.map +1 -0
  61. package/dist/esm/blogComment.mjs +94 -0
  62. package/dist/esm/blogComment.mjs.map +1 -0
  63. package/dist/esm/cliSessionToken.mjs +39 -0
  64. package/dist/esm/cliSessionToken.mjs.map +1 -0
  65. package/dist/esm/common.mjs +35 -0
  66. package/dist/esm/common.mjs.map +1 -0
  67. package/dist/esm/defineRoute.mjs +23 -0
  68. package/dist/esm/defineRoute.mjs.map +1 -0
  69. package/dist/esm/demo.mjs +21 -0
  70. package/dist/esm/demo.mjs.map +1 -0
  71. package/dist/esm/dictionary.mjs +163 -0
  72. package/dist/esm/dictionary.mjs.map +1 -0
  73. package/dist/esm/environment.mjs +90 -0
  74. package/dist/esm/environment.mjs.map +1 -0
  75. package/dist/esm/eventListener.mjs +18 -0
  76. package/dist/esm/eventListener.mjs.map +1 -0
  77. package/dist/esm/gitProviders.mjs +352 -0
  78. package/dist/esm/gitProviders.mjs.map +1 -0
  79. package/dist/esm/newsletter.mjs +49 -0
  80. package/dist/esm/newsletter.mjs.map +1 -0
  81. package/dist/esm/oAuth2.mjs +60 -0
  82. package/dist/esm/oAuth2.mjs.map +1 -0
  83. package/dist/esm/organization.mjs +219 -0
  84. package/dist/esm/organization.mjs.map +1 -0
  85. package/dist/esm/project.mjs +387 -0
  86. package/dist/esm/project.mjs.map +1 -0
  87. package/dist/esm/public.mjs +58 -0
  88. package/dist/esm/public.mjs.map +1 -0
  89. package/dist/esm/responseData.mjs +30 -0
  90. package/dist/esm/responseData.mjs.map +1 -0
  91. package/dist/esm/reviewer.mjs +390 -0
  92. package/dist/esm/reviewer.mjs.map +1 -0
  93. package/dist/esm/scan.mjs +225 -0
  94. package/dist/esm/scan.mjs.map +1 -0
  95. package/dist/esm/search.mjs +38 -0
  96. package/dist/esm/search.mjs.map +1 -0
  97. package/dist/esm/session.mjs +53 -0
  98. package/dist/esm/session.mjs.map +1 -0
  99. package/dist/esm/showcaseProject.mjs +182 -0
  100. package/dist/esm/showcaseProject.mjs.map +1 -0
  101. package/dist/esm/stripe.mjs +379 -0
  102. package/dist/esm/stripe.mjs.map +1 -0
  103. package/dist/esm/tag.mjs +81 -0
  104. package/dist/esm/tag.mjs.map +1 -0
  105. package/dist/esm/translation.mjs +53 -0
  106. package/dist/esm/translation.mjs.map +1 -0
  107. package/dist/esm/user.mjs +149 -0
  108. package/dist/esm/user.mjs.map +1 -0
  109. package/dist/types/@intlayer/config/dist/types/defaultValues/dictionary.d.ts +1 -0
  110. package/dist/types/@intlayer/config/dist/types/defaultValues/index.d.ts +3 -0
  111. package/dist/types/@intlayer/config/dist/types/defaultValues/internationalization.d.ts +2 -0
  112. package/dist/types/@intlayer/config/dist/types/defaultValues/routing.d.ts +1 -0
  113. package/dist/types/@intlayer/core/dist/types/dictionaryManipulator/plainDynamicLoader.d.ts +2 -0
  114. package/dist/types/@intlayer/core/dist/types/dictionaryManipulator/qualifiedDynamicLoader.d.ts +2 -0
  115. package/dist/types/@intlayer/core/dist/types/formatters/compact.d.ts +1 -0
  116. package/dist/types/@intlayer/core/dist/types/formatters/currency.d.ts +1 -0
  117. package/dist/types/@intlayer/core/dist/types/formatters/date.d.ts +1 -0
  118. package/dist/types/@intlayer/core/dist/types/formatters/index.d.ts +9 -0
  119. package/dist/types/@intlayer/core/dist/types/formatters/list.d.ts +1 -0
  120. package/dist/types/@intlayer/core/dist/types/formatters/number.d.ts +1 -0
  121. package/dist/types/@intlayer/core/dist/types/formatters/percentage.d.ts +1 -0
  122. package/dist/types/@intlayer/core/dist/types/formatters/relativeTime.d.ts +1 -0
  123. package/dist/types/@intlayer/core/dist/types/formatters/units.d.ts +1 -0
  124. package/dist/types/@intlayer/core/dist/types/interpreter/dictionaryTransformCache.d.ts +4 -0
  125. package/dist/types/@intlayer/core/dist/types/interpreter/getCondition.d.ts +2 -0
  126. package/dist/types/@intlayer/core/dist/types/interpreter/getContent/deepTransform.d.ts +1 -0
  127. package/dist/types/@intlayer/core/dist/types/interpreter/getContent/getContent.d.ts +3 -0
  128. package/dist/types/@intlayer/core/dist/types/interpreter/getContent/index.d.ts +3 -0
  129. package/dist/types/@intlayer/core/dist/types/interpreter/getContent/plugins.d.ts +7 -0
  130. package/dist/types/@intlayer/core/dist/types/interpreter/getDictionary.d.ts +4 -0
  131. package/dist/types/@intlayer/core/dist/types/interpreter/getDictionaryAsync.d.ts +6 -0
  132. package/dist/types/@intlayer/core/dist/types/interpreter/getEnumeration.d.ts +2 -0
  133. package/dist/types/@intlayer/core/dist/types/interpreter/getGender.d.ts +2 -0
  134. package/dist/types/@intlayer/core/dist/types/interpreter/getInsertion.d.ts +2 -0
  135. package/dist/types/@intlayer/core/dist/types/interpreter/getIntlayer.d.ts +4 -0
  136. package/dist/types/@intlayer/core/dist/types/interpreter/getIntlayerAsync.d.ts +4 -0
  137. package/dist/types/@intlayer/core/dist/types/interpreter/getNesting.d.ts +6 -0
  138. package/dist/types/@intlayer/core/dist/types/interpreter/getPlural.d.ts +3 -0
  139. package/dist/types/@intlayer/core/dist/types/interpreter/getSelect.d.ts +2 -0
  140. package/dist/types/@intlayer/core/dist/types/interpreter/getTranslation.d.ts +1 -0
  141. package/dist/types/@intlayer/core/dist/types/interpreter/index.d.ts +19 -0
  142. package/dist/types/@intlayer/core/dist/types/interpreter/interpolableNode.d.ts +2 -0
  143. package/dist/types/@intlayer/core/dist/types/interpreter/resolveInterpreterLocale.d.ts +1 -0
  144. package/dist/types/@intlayer/core/dist/types/localization/comparePaths.d.ts +1 -0
  145. package/dist/types/@intlayer/core/dist/types/localization/domainUtils.d.ts +2 -0
  146. package/dist/types/@intlayer/core/dist/types/localization/generateSitemap.d.ts +2 -0
  147. package/dist/types/@intlayer/core/dist/types/localization/getBrowserLocale.d.ts +1 -0
  148. package/dist/types/@intlayer/core/dist/types/localization/getCanonicalPath.d.ts +2 -0
  149. package/dist/types/@intlayer/core/dist/types/localization/getHTMLTextDir.d.ts +1 -0
  150. package/dist/types/@intlayer/core/dist/types/localization/getLocale.d.ts +1 -0
  151. package/dist/types/@intlayer/core/dist/types/localization/getLocaleFromPath.d.ts +2 -0
  152. package/dist/types/@intlayer/core/dist/types/localization/getLocaleFromRequest.d.ts +1 -0
  153. package/dist/types/@intlayer/core/dist/types/localization/getLocaleLang.d.ts +1 -0
  154. package/dist/types/@intlayer/core/dist/types/localization/getLocaleName.d.ts +1 -0
  155. package/dist/types/@intlayer/core/dist/types/localization/getLocalizedPath.d.ts +2 -0
  156. package/dist/types/@intlayer/core/dist/types/localization/getLocalizedUrl.d.ts +2 -0
  157. package/dist/types/@intlayer/core/dist/types/localization/getMultilingualUrls.d.ts +2 -0
  158. package/dist/types/@intlayer/core/dist/types/localization/getPathWithoutLocale.d.ts +1 -0
  159. package/dist/types/@intlayer/core/dist/types/localization/getPrefix.d.ts +2 -0
  160. package/dist/types/@intlayer/core/dist/types/localization/index.d.ts +23 -0
  161. package/dist/types/@intlayer/core/dist/types/localization/localeDetector.d.ts +2 -0
  162. package/dist/types/@intlayer/core/dist/types/localization/localeMapper.d.ts +1 -0
  163. package/dist/types/@intlayer/core/dist/types/localization/localeResolver.d.ts +1 -0
  164. package/dist/types/@intlayer/core/dist/types/localization/resolveBrowserLocale.d.ts +2 -0
  165. package/dist/types/@intlayer/core/dist/types/localization/rewriteMatch.d.ts +1 -0
  166. package/dist/types/@intlayer/core/dist/types/localization/rewriteUtils.d.ts +2 -0
  167. package/dist/types/@intlayer/core/dist/types/localization/validatePrefix.d.ts +2 -0
  168. package/dist/types/@intlayer/core/dist/types/markdown/index.d.ts +2 -0
  169. package/dist/types/@intlayer/core/dist/types/transpiler/condition/condition.d.ts +1 -0
  170. package/dist/types/@intlayer/core/dist/types/transpiler/condition/index.d.ts +1 -0
  171. package/dist/types/@intlayer/core/dist/types/transpiler/enumeration/enumeration.d.ts +1 -0
  172. package/dist/types/@intlayer/core/dist/types/transpiler/enumeration/index.d.ts +1 -0
  173. package/dist/types/@intlayer/core/dist/types/transpiler/file/file.d.ts +1 -0
  174. package/dist/types/@intlayer/core/dist/types/transpiler/file/index.d.ts +1 -0
  175. package/dist/types/@intlayer/core/dist/types/transpiler/gender/gender.d.ts +1 -0
  176. package/dist/types/@intlayer/core/dist/types/transpiler/gender/index.d.ts +1 -0
  177. package/dist/types/@intlayer/core/dist/types/transpiler/html/html.d.ts +1 -0
  178. package/dist/types/@intlayer/core/dist/types/transpiler/html/index.d.ts +1 -0
  179. package/dist/types/@intlayer/core/dist/types/transpiler/index.d.ts +22 -0
  180. package/dist/types/@intlayer/core/dist/types/transpiler/insertion/index.d.ts +1 -0
  181. package/dist/types/@intlayer/core/dist/types/transpiler/insertion/insertion.d.ts +1 -0
  182. package/dist/types/@intlayer/core/dist/types/transpiler/markdown/index.d.ts +1 -0
  183. package/dist/types/@intlayer/core/dist/types/transpiler/markdown/markdown.d.ts +1 -0
  184. package/dist/types/@intlayer/core/dist/types/transpiler/nesting/index.d.ts +1 -0
  185. package/dist/types/@intlayer/core/dist/types/transpiler/nesting/nesting.d.ts +4 -0
  186. package/dist/types/@intlayer/core/dist/types/transpiler/plural/index.d.ts +1 -0
  187. package/dist/types/@intlayer/core/dist/types/transpiler/plural/plural.d.ts +1 -0
  188. package/dist/types/@intlayer/core/dist/types/transpiler/select/index.d.ts +1 -0
  189. package/dist/types/@intlayer/core/dist/types/transpiler/select/select.d.ts +1 -0
  190. package/dist/types/@intlayer/core/dist/types/transpiler/translation/index.d.ts +1 -0
  191. package/dist/types/@intlayer/core/dist/types/transpiler/translation/translation.d.ts +2 -0
  192. package/dist/types/@intlayer/core/dist/types/utils/index.d.ts +3 -0
  193. package/dist/types/@intlayer/core/dist/types/utils/intl.d.ts +1 -0
  194. package/dist/types/@intlayer/core/dist/types/utils/isSameKeyPath.d.ts +1 -0
  195. package/dist/types/@intlayer/core/dist/types/utils/localeStorage.d.ts +2 -0
  196. package/dist/types/ai.d.ts +549 -0
  197. package/dist/types/ai.d.ts.map +1 -0
  198. package/dist/types/analytics.d.ts +378 -0
  199. package/dist/types/analytics.d.ts.map +1 -0
  200. package/dist/types/asset.d.ts +207 -0
  201. package/dist/types/asset.d.ts.map +1 -0
  202. package/dist/types/blogComment.d.ts +241 -0
  203. package/dist/types/blogComment.d.ts.map +1 -0
  204. package/dist/types/cliSessionToken.d.ts +264 -0
  205. package/dist/types/cliSessionToken.d.ts.map +1 -0
  206. package/dist/types/common.d.ts +32 -0
  207. package/dist/types/common.d.ts.map +1 -0
  208. package/dist/types/defineRoute.d.ts +57 -0
  209. package/dist/types/defineRoute.d.ts.map +1 -0
  210. package/dist/types/demo.d.ts +21 -0
  211. package/dist/types/demo.d.ts.map +1 -0
  212. package/dist/types/dictionary.d.ts +360 -0
  213. package/dist/types/dictionary.d.ts.map +1 -0
  214. package/dist/types/environment.d.ts +285 -0
  215. package/dist/types/environment.d.ts.map +1 -0
  216. package/dist/types/eventListener.d.ts +17 -0
  217. package/dist/types/eventListener.d.ts.map +1 -0
  218. package/dist/types/gitProviders.d.ts +807 -0
  219. package/dist/types/gitProviders.d.ts.map +1 -0
  220. package/dist/types/intlayer/dist/types/index.d.ts +13 -0
  221. package/dist/types/newsletter.d.ts +165 -0
  222. package/dist/types/newsletter.d.ts.map +1 -0
  223. package/dist/types/oAuth2.d.ts +482 -0
  224. package/dist/types/oAuth2.d.ts.map +1 -0
  225. package/dist/types/organization.d.ts +1069 -0
  226. package/dist/types/organization.d.ts.map +1 -0
  227. package/dist/types/project.d.ts +1735 -0
  228. package/dist/types/project.d.ts.map +1 -0
  229. package/dist/types/public.d.ts +109 -0
  230. package/dist/types/public.d.ts.map +1 -0
  231. package/dist/types/responseData.d.ts +68 -0
  232. package/dist/types/responseData.d.ts.map +1 -0
  233. package/dist/types/reviewer.d.ts +1239 -0
  234. package/dist/types/reviewer.d.ts.map +1 -0
  235. package/dist/types/scan.d.ts +625 -0
  236. package/dist/types/scan.d.ts.map +1 -0
  237. package/dist/types/search.d.ts +55 -0
  238. package/dist/types/search.d.ts.map +1 -0
  239. package/dist/types/session.d.ts +286 -0
  240. package/dist/types/session.d.ts.map +1 -0
  241. package/dist/types/showcaseProject.d.ts +550 -0
  242. package/dist/types/showcaseProject.d.ts.map +1 -0
  243. package/dist/types/stripe.d.ts +1219 -0
  244. package/dist/types/stripe.d.ts.map +1 -0
  245. package/dist/types/tag.d.ts +193 -0
  246. package/dist/types/tag.d.ts.map +1 -0
  247. package/dist/types/translation.d.ts +162 -0
  248. package/dist/types/translation.d.ts.map +1 -0
  249. package/dist/types/user.d.ts +447 -0
  250. package/dist/types/user.d.ts.map +1 -0
  251. package/package.json +300 -4
  252. package/README.md +0 -3
@@ -0,0 +1,235 @@
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/scan.ts
8
+ /**
9
+ * Locale routing strategies detected on a website. Mirrors
10
+ * `@intlayer/engine/scan` (asserted equal there: engine depends on the
11
+ * contract, not the reverse).
12
+ */
13
+ const routingStrategySchema = zod_mini.z.enum([
14
+ "prefix-all",
15
+ "prefix-no-default",
16
+ "search-params",
17
+ "subdomain",
18
+ "domain",
19
+ "no-prefix",
20
+ "unknown"
21
+ ]);
22
+ /** Technology categories of the scan signatures (mirrors engine). */
23
+ const technologyCategorySchema = zod_mini.z.enum([
24
+ "framework",
25
+ "i18n-library",
26
+ "tms",
27
+ "translation-proxy",
28
+ "cms"
29
+ ]);
30
+ /** Where a host scan came from. */
31
+ const hostScanSourceSchema = zod_mini.z.enum([
32
+ "scan",
33
+ "recursive",
34
+ "extension",
35
+ "background"
36
+ ]);
37
+ /** Technology detected on a host. */
38
+ const hostTechnologySchema = zod_mini.z.object({
39
+ id: zod_mini.z.string(),
40
+ name: zod_mini.z.string(),
41
+ category: technologyCategorySchema,
42
+ version: zod_mini.z.optional(zod_mini.z.string())
43
+ });
44
+ /** One scan of a host. */
45
+ const hostScanSchema = zod_mini.z.object({
46
+ url: zod_mini.z.string(),
47
+ source: hostScanSourceSchema,
48
+ score: zod_mini.z.optional(zod_mini.z.number()),
49
+ title: zod_mini.z.optional(zod_mini.z.string()),
50
+ technologies: zod_mini.z.array(hostTechnologySchema),
51
+ routingStrategy: zod_mini.z.optional(routingStrategySchema),
52
+ locales: zod_mini.z.optional(zod_mini.z.array(zod_mini.z.string())),
53
+ scannedAt: require_common.dateTimeSchema
54
+ });
55
+ const scannedHostSummarySchema = zod_mini.z.object({
56
+ id: zod_mini.z.string(),
57
+ host: zod_mini.z.string(),
58
+ title: zod_mini.z.optional(zod_mini.z.string()),
59
+ technologies: zod_mini.z.array(hostTechnologySchema),
60
+ routingStrategy: zod_mini.z.optional(routingStrategySchema),
61
+ locales: zod_mini.z.optional(zod_mini.z.array(zod_mini.z.string())),
62
+ lastScore: zod_mini.z.optional(zod_mini.z.number()),
63
+ lastScannedAt: require_common.dateTimeSchema,
64
+ scanCount: zod_mini.z.number()
65
+ });
66
+ const scannedHostDetailSchema = zod_mini.z.object({
67
+ ...scannedHostSummarySchema.shape,
68
+ scans: zod_mini.z.array(hostScanSchema)
69
+ });
70
+ /** Usage of a technology across scanned hosts. */
71
+ const technologyUsageSchema = zod_mini.z.object({
72
+ ...hostTechnologySchema.shape,
73
+ hostCount: zod_mini.z.number(),
74
+ lastSeenAt: require_common.dateTimeSchema
75
+ });
76
+ const recursiveAuditJobSchema = zod_mini.z.looseObject({
77
+ _id: zod_mini.z.string(),
78
+ targetUrl: zod_mini.z.string(),
79
+ userId: zod_mini.z.optional(zod_mini.z.string()),
80
+ status: zod_mini.z.enum([
81
+ "pending",
82
+ "running",
83
+ "paused",
84
+ "cancelled",
85
+ "completed",
86
+ "failed"
87
+ ]),
88
+ progress: zod_mini.z.number(),
89
+ totalPageCount: zod_mini.z.number(),
90
+ completedPageCount: zod_mini.z.number(),
91
+ createdAt: require_common.dateTimeSchema,
92
+ updatedAt: require_common.dateTimeSchema
93
+ });
94
+ const recursiveAuditPageSchema = zod_mini.z.looseObject({
95
+ _id: zod_mini.z.string(),
96
+ url: zod_mini.z.string(),
97
+ status: zod_mini.z.enum([
98
+ "pending",
99
+ "running",
100
+ "completed",
101
+ "failed"
102
+ ]),
103
+ score: zod_mini.z.optional(zod_mini.z.number()),
104
+ error: zod_mini.z.optional(zod_mini.z.string()),
105
+ results: zod_mini.z.optional(zod_mini.z.array(zod_mini.z.unknown()))
106
+ });
107
+ const recursiveAuditStatusSchema = zod_mini.z.object({
108
+ job: recursiveAuditJobSchema,
109
+ pages: zod_mini.z.array(recursiveAuditPageSchema)
110
+ });
111
+ const urlQuerySchema = zod_mini.z.object({ url: zod_mini.z.string().check(zod_mini.z.minLength(1)) });
112
+ const jobIdParamsSchema = zod_mini.z.object({ jobId: zod_mini.z.string().check(zod_mini.z.minLength(1)) });
113
+ const successSchema = zod_mini.z.object({ success: zod_mini.z.boolean() });
114
+ /** Recursive audit job control routes share the same shape. */
115
+ const jobControlRoute = (path, summary) => require_defineRoute.defineRoute({
116
+ method: "POST",
117
+ path,
118
+ summary,
119
+ schemas: {
120
+ params: jobIdParamsSchema,
121
+ response: { 200: successSchema }
122
+ }
123
+ });
124
+ /** REST contract of the `/api/scan` routes (i18n website scanner). */
125
+ const scanContract = require_defineRoute.defineRouteGroup({
126
+ prefix: "/api/scan",
127
+ tag: "Scan",
128
+ routes: {
129
+ scan: require_defineRoute.defineRoute({
130
+ method: "GET",
131
+ path: "/",
132
+ summary: "Audit the i18n of a page (server-sent events stream)",
133
+ schemas: { querystring: zod_mini.z.object({
134
+ url: zod_mini.z.string().check(zod_mini.z.minLength(1)),
135
+ /** `true` to bypass the one-hour audit cache. */
136
+ refresh: zod_mini.z.optional(zod_mini.z.string())
137
+ }) }
138
+ }),
139
+ getTechnologyUsage: require_defineRoute.defineRoute({
140
+ method: "GET",
141
+ path: "/technologies",
142
+ summary: "Technologies seen across scanned hosts",
143
+ schemas: {
144
+ querystring: zod_mini.z.object({ category: zod_mini.z.optional(zod_mini.z.string()) }),
145
+ response: { 200: require_responseData.responseDataSchema(zod_mini.z.array(technologyUsageSchema)) }
146
+ }
147
+ }),
148
+ getScannedHosts: require_defineRoute.defineRoute({
149
+ method: "GET",
150
+ path: "/hosts",
151
+ summary: "List scanned hosts",
152
+ schemas: {
153
+ querystring: zod_mini.z.object({
154
+ ...require_common.paginationQueryShape,
155
+ technologyId: zod_mini.z.optional(zod_mini.z.string()),
156
+ category: zod_mini.z.optional(zod_mini.z.string()),
157
+ search: zod_mini.z.optional(zod_mini.z.string())
158
+ }),
159
+ response: { 200: require_responseData.paginatedResponseSchema(scannedHostSummarySchema) }
160
+ }
161
+ }),
162
+ getScannedHost: require_defineRoute.defineRoute({
163
+ method: "GET",
164
+ path: "/hosts/:host",
165
+ summary: "Scan history of a host",
166
+ schemas: {
167
+ params: zod_mini.z.object({ host: zod_mini.z.string().check(zod_mini.z.maxLength(253), zod_mini.z.regex(/^[a-zA-Z0-9.-]+$/)) }),
168
+ response: { 200: require_responseData.responseDataSchema(scannedHostDetailSchema) }
169
+ }
170
+ }),
171
+ reportHostDetection: require_defineRoute.defineRoute({
172
+ method: "POST",
173
+ path: "/hosts/detections",
174
+ summary: "Public detection report of the Chrome extension (rate limited)",
175
+ schemas: {
176
+ /** Every field bounded: names and categories are resolved server-side. */
177
+ body: zod_mini.z.strictObject({
178
+ url: zod_mini.z.string().check(zod_mini.z.maxLength(2048), zod_mini.z.regex(/^https?:\/\//)),
179
+ technologies: zod_mini.z.array(zod_mini.z.strictObject({
180
+ id: zod_mini.z.string().check(zod_mini.z.maxLength(64), zod_mini.z.regex(/^[a-z0-9-]+$/)),
181
+ version: zod_mini.z.optional(zod_mini.z.string().check(zod_mini.z.maxLength(64)))
182
+ })).check(zod_mini.z.maxLength(50)),
183
+ routingStrategy: zod_mini.z.optional(routingStrategySchema),
184
+ locales: zod_mini.z.optional(zod_mini.z.array(zod_mini.z.string().check(zod_mini.z.maxLength(35), zod_mini.z.regex(/^[a-zA-Z]{2,3}([_-][a-zA-Z0-9]{2,8})*$/))).check(zod_mini.z.maxLength(100))),
185
+ title: zod_mini.z.optional(zod_mini.z.string().check(zod_mini.z.maxLength(300)))
186
+ }),
187
+ response: { 200: require_responseData.responseDataSchema(zod_mini.z.object({ isBackgroundScanQueued: zod_mini.z.boolean() })) }
188
+ }
189
+ }),
190
+ discoverUrls: require_defineRoute.defineRoute({
191
+ method: "GET",
192
+ path: "/recursive/discover",
193
+ summary: "Discover the crawlable URLs of a website",
194
+ schemas: {
195
+ querystring: urlQuerySchema,
196
+ response: { 200: zod_mini.z.object({ urls: zod_mini.z.array(zod_mini.z.string()) }) }
197
+ }
198
+ }),
199
+ startRecursive: require_defineRoute.defineRoute({
200
+ method: "POST",
201
+ path: "/recursive/start",
202
+ summary: "Start a recursive audit of a website",
203
+ schemas: {
204
+ querystring: urlQuerySchema,
205
+ body: zod_mini.z.optional(zod_mini.z.object({ urls: zod_mini.z.optional(zod_mini.z.array(zod_mini.z.string())) })),
206
+ response: { 200: zod_mini.z.object({ jobId: zod_mini.z.string() }) }
207
+ }
208
+ }),
209
+ getRecursiveStatus: require_defineRoute.defineRoute({
210
+ method: "GET",
211
+ path: "/recursive/:jobId",
212
+ summary: "Progress and page results of a recursive audit",
213
+ schemas: {
214
+ params: jobIdParamsSchema,
215
+ response: { 200: recursiveAuditStatusSchema }
216
+ }
217
+ }),
218
+ cancelRecursive: jobControlRoute("/recursive/:jobId/cancel", "Cancel a recursive audit"),
219
+ pauseRecursive: jobControlRoute("/recursive/:jobId/pause", "Pause a recursive audit"),
220
+ resumeRecursive: jobControlRoute("/recursive/:jobId/resume", "Resume a recursive audit")
221
+ }
222
+ });
223
+
224
+ //#endregion
225
+ exports.hostScanSchema = hostScanSchema;
226
+ exports.hostScanSourceSchema = hostScanSourceSchema;
227
+ exports.hostTechnologySchema = hostTechnologySchema;
228
+ exports.recursiveAuditStatusSchema = recursiveAuditStatusSchema;
229
+ exports.routingStrategySchema = routingStrategySchema;
230
+ exports.scanContract = scanContract;
231
+ exports.scannedHostDetailSchema = scannedHostDetailSchema;
232
+ exports.scannedHostSummarySchema = scannedHostSummarySchema;
233
+ exports.technologyCategorySchema = technologyCategorySchema;
234
+ exports.technologyUsageSchema = technologyUsageSchema;
235
+ //# sourceMappingURL=scan.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan.cjs","names":["z","dateTimeSchema","defineRoute","defineRouteGroup","responseDataSchema","paginationQueryShape","paginatedResponseSchema"],"sources":["../../src/scan.ts"],"sourcesContent":["import { z } from 'zod/mini';\nimport { dateTimeSchema, paginationQueryShape } 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/**\n * Locale routing strategies detected on a website. Mirrors\n * `@intlayer/engine/scan` (asserted equal there: engine depends on the\n * contract, not the reverse).\n */\nexport const routingStrategySchema = z.enum([\n 'prefix-all',\n 'prefix-no-default',\n 'search-params',\n 'subdomain',\n 'domain',\n 'no-prefix',\n 'unknown',\n]);\n\n/** Technology categories of the scan signatures (mirrors engine). */\nexport const technologyCategorySchema = z.enum([\n 'framework',\n 'i18n-library',\n 'tms',\n 'translation-proxy',\n 'cms',\n]);\n\n/** Where a host scan came from. */\nexport const hostScanSourceSchema = z.enum([\n 'scan',\n 'recursive',\n 'extension',\n 'background',\n]);\n\n/** Technology detected on a host. */\nexport const hostTechnologySchema = z.object({\n id: z.string(),\n name: z.string(),\n category: technologyCategorySchema,\n version: z.optional(z.string()),\n});\n\n/** One scan of a host. */\nexport const hostScanSchema = z.object({\n url: z.string(),\n source: hostScanSourceSchema,\n score: z.optional(z.number()),\n title: z.optional(z.string()),\n technologies: z.array(hostTechnologySchema),\n routingStrategy: z.optional(routingStrategySchema),\n locales: z.optional(z.array(z.string())),\n scannedAt: dateTimeSchema,\n});\n\nexport const scannedHostSummarySchema = z.object({\n id: z.string(),\n host: z.string(),\n title: z.optional(z.string()),\n technologies: z.array(hostTechnologySchema),\n routingStrategy: z.optional(routingStrategySchema),\n locales: z.optional(z.array(z.string())),\n lastScore: z.optional(z.number()),\n lastScannedAt: dateTimeSchema,\n scanCount: z.number(),\n});\n\nexport const scannedHostDetailSchema = z.object({\n ...scannedHostSummarySchema.shape,\n scans: z.array(hostScanSchema),\n});\n\n/** Usage of a technology across scanned hosts. */\nexport const technologyUsageSchema = z.object({\n ...hostTechnologySchema.shape,\n hostCount: z.number(),\n lastSeenAt: dateTimeSchema,\n});\n\nconst recursiveAuditJobSchema = z.looseObject({\n _id: z.string(),\n targetUrl: z.string(),\n userId: z.optional(z.string()),\n status: z.enum([\n 'pending',\n 'running',\n 'paused',\n 'cancelled',\n 'completed',\n 'failed',\n ]),\n progress: z.number(),\n totalPageCount: z.number(),\n completedPageCount: z.number(),\n createdAt: dateTimeSchema,\n updatedAt: dateTimeSchema,\n});\n\nconst recursiveAuditPageSchema = z.looseObject({\n _id: z.string(),\n url: z.string(),\n status: z.enum(['pending', 'running', 'completed', 'failed']),\n score: z.optional(z.number()),\n error: z.optional(z.string()),\n results: z.optional(z.array(z.unknown())),\n});\n\nexport const recursiveAuditStatusSchema = z.object({\n job: recursiveAuditJobSchema,\n pages: z.array(recursiveAuditPageSchema),\n});\n\nconst urlQuerySchema = z.object({ url: z.string().check(z.minLength(1)) });\nconst jobIdParamsSchema = z.object({ jobId: z.string().check(z.minLength(1)) });\nconst successSchema = z.object({ success: z.boolean() });\n\n/** Recursive audit job control routes share the same shape. */\nconst jobControlRoute = (\n path: `/recursive/:jobId/${string}`,\n summary: string\n) =>\n defineRoute({\n method: 'POST',\n path,\n summary,\n schemas: {\n params: jobIdParamsSchema,\n response: { 200: successSchema },\n },\n });\n\n/** REST contract of the `/api/scan` routes (i18n website scanner). */\nexport const scanContract = defineRouteGroup({\n prefix: '/api/scan',\n tag: 'Scan',\n routes: {\n scan: defineRoute({\n method: 'GET',\n path: '/',\n summary: 'Audit the i18n of a page (server-sent events stream)',\n schemas: {\n querystring: z.object({\n url: z.string().check(z.minLength(1)),\n /** `true` to bypass the one-hour audit cache. */\n refresh: z.optional(z.string()),\n }),\n },\n }),\n getTechnologyUsage: defineRoute({\n method: 'GET',\n path: '/technologies',\n summary: 'Technologies seen across scanned hosts',\n schemas: {\n querystring: z.object({ category: z.optional(z.string()) }),\n response: { 200: responseDataSchema(z.array(technologyUsageSchema)) },\n },\n }),\n getScannedHosts: defineRoute({\n method: 'GET',\n path: '/hosts',\n summary: 'List scanned hosts',\n schemas: {\n querystring: z.object({\n ...paginationQueryShape,\n technologyId: z.optional(z.string()),\n category: z.optional(z.string()),\n search: z.optional(z.string()),\n }),\n response: { 200: paginatedResponseSchema(scannedHostSummarySchema) },\n },\n }),\n getScannedHost: defineRoute({\n method: 'GET',\n path: '/hosts/:host',\n summary: 'Scan history of a host',\n schemas: {\n params: z.object({\n host: z.string().check(z.maxLength(253), z.regex(/^[a-zA-Z0-9.-]+$/)),\n }),\n response: { 200: responseDataSchema(scannedHostDetailSchema) },\n },\n }),\n reportHostDetection: defineRoute({\n method: 'POST',\n path: '/hosts/detections',\n summary: 'Public detection report of the Chrome extension (rate limited)',\n schemas: {\n /** Every field bounded: names and categories are resolved server-side. */\n body: z.strictObject({\n url: z.string().check(z.maxLength(2048), z.regex(/^https?:\\/\\//)),\n technologies: z\n .array(\n z.strictObject({\n id: z.string().check(z.maxLength(64), z.regex(/^[a-z0-9-]+$/)),\n version: z.optional(z.string().check(z.maxLength(64))),\n })\n )\n .check(z.maxLength(50)),\n routingStrategy: z.optional(routingStrategySchema),\n locales: z.optional(\n z\n .array(\n z\n .string()\n .check(\n z.maxLength(35),\n z.regex(/^[a-zA-Z]{2,3}([_-][a-zA-Z0-9]{2,8})*$/)\n )\n )\n .check(z.maxLength(100))\n ),\n title: z.optional(z.string().check(z.maxLength(300))),\n }),\n response: {\n 200: responseDataSchema(\n z.object({ isBackgroundScanQueued: z.boolean() })\n ),\n },\n },\n }),\n discoverUrls: defineRoute({\n method: 'GET',\n path: '/recursive/discover',\n summary: 'Discover the crawlable URLs of a website',\n schemas: {\n querystring: urlQuerySchema,\n response: { 200: z.object({ urls: z.array(z.string()) }) },\n },\n }),\n startRecursive: defineRoute({\n method: 'POST',\n path: '/recursive/start',\n summary: 'Start a recursive audit of a website',\n schemas: {\n querystring: urlQuerySchema,\n body: z.optional(z.object({ urls: z.optional(z.array(z.string())) })),\n response: { 200: z.object({ jobId: z.string() }) },\n },\n }),\n getRecursiveStatus: defineRoute({\n method: 'GET',\n path: '/recursive/:jobId',\n summary: 'Progress and page results of a recursive audit',\n schemas: {\n params: jobIdParamsSchema,\n response: { 200: recursiveAuditStatusSchema },\n },\n }),\n cancelRecursive: jobControlRoute(\n '/recursive/:jobId/cancel',\n 'Cancel a recursive audit'\n ),\n pauseRecursive: jobControlRoute(\n '/recursive/:jobId/pause',\n 'Pause a recursive audit'\n ),\n resumeRecursive: jobControlRoute(\n '/recursive/:jobId/resume',\n 'Resume a recursive audit'\n ),\n },\n});\n\n/** Route definitions of the `/api/scan` group, by name. */\nexport type ScanRoutes = (typeof scanContract)['routes'];\n\nexport type RoutingStrategy = z.output<typeof routingStrategySchema>;\nexport type TechnologyCategory = z.output<typeof technologyCategorySchema>;\nexport type HostScanSource = z.output<typeof hostScanSourceSchema>;\nexport type HostTechnology = z.output<typeof hostTechnologySchema>;\nexport type HostScan = z.output<typeof hostScanSchema>;\nexport type ScannedHostSummary = z.output<typeof scannedHostSummarySchema>;\nexport type ScannedHostDetail = z.output<typeof scannedHostDetailSchema>;\nexport type TechnologyUsage = z.output<typeof technologyUsageSchema>;\n\nexport type ReportHostDetectionBody = RouteBodyInput<\n ScanRoutes['reportHostDetection']\n>;\nexport type ReportHostDetectionResult = ResponseData<{\n isBackgroundScanQueued: boolean;\n}>;\nexport type GetTechnologyUsageQuery = RouteQuerystring<\n ScanRoutes['getTechnologyUsage']\n>;\nexport type GetTechnologyUsageResult = ResponseData<TechnologyUsage[]>;\nexport type GetScannedHostsQuery = RouteQuerystring<\n ScanRoutes['getScannedHosts']\n>;\nexport type GetScannedHostsResult = PaginatedResponse<ScannedHostSummary>;\nexport type GetScannedHostParams = RouteParams<ScanRoutes['getScannedHost']>;\nexport type GetScannedHostResult = ResponseData<ScannedHostDetail>;\nexport type DiscoverUrlsResult = { urls: string[] };\nexport type StartRecursiveAuditResult = { jobId: string };\nexport type GetRecursiveAuditStatusResult = z.output<\n typeof recursiveAuditStatusSchema\n>;\n\n// Scan stream (`GET /api/scan`): one message per audit step\ntype AuditDetails =\n | null\n | undefined\n | string\n | number\n | boolean\n | AuditDetails[]\n | { [key: string]: AuditDetails };\n\ntype UrlAuditCheck =\n | 'url_hasCanonical'\n | 'url_hasLocalizedLinks'\n | 'url_currentLocale'\n | 'url_htmlLang'\n | 'url_htmlDir'\n | 'url_ogLocale'\n | 'url_hreflang'\n | 'url_hreflangReciprocal'\n | 'url_hasXDefault'\n | 'url_allAnchorsLocalized'\n | 'url_hasLangSelector'\n | 'url_unusedBundleContent';\n\n/** Audit check identifier (`url_*` checks are suffixed with the URL). */\nexport type AuditDataList<Url extends string = string> =\n | `${UrlAuditCheck}${Url}`\n | 'robots_robotsPresent'\n | 'robots_noLocalizedUrlsForgotten'\n | 'sitemap_sitemapPresent'\n | 'sitemap_noLocalizedUrlsForgotten'\n | 'sitemap_hasXDefault'\n | 'sitemap_hasAlternates';\n\nexport type AuditData = {\n successDetails?: AuditDetails;\n warningsDetails?: AuditDetails;\n errorsDetails?: AuditDetails;\n};\n\n/** Locale routing detected on a page (mirrors engine `RoutingDetection`). */\nexport type RoutingDetection = {\n strategy: RoutingStrategy;\n confidence: 'high' | 'low';\n locales: string[];\n defaultLocale?: string;\n searchParamName?: string;\n hostLocales?: Record<string, string>;\n urlLocale?: string;\n evidence: string;\n};\n\n/** Technology detected on a page (mirrors engine `DetectedTechnology`). */\nexport type DetectedTechnology = HostTechnology & { evidence: string };\n\nexport type DomainData = {\n discoveredUrls: Record<string, string[]>;\n discoveredLocales: string[];\n defaultLocale: string;\n image: string;\n title: string;\n description: string;\n routing: RoutingDetection;\n technologies: DetectedTechnology[];\n};\n\nexport type AuditEvent = {\n type?: AuditDataList;\n status?: 'started' | 'success' | 'warning' | 'error';\n data?: AuditData;\n score?: number;\n progress?: number;\n message?: string;\n globalError?: string;\n domainData?: Partial<DomainData>;\n /** ISO date, sent first when the result is replayed from the cache. */\n cachedAt?: string;\n};\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAa,wBAAwBA,WAAE,KAAK;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAa,2BAA2BA,WAAE,KAAK;CAC7C;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAa,uBAAuBA,WAAE,KAAK;C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 Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_defineRoute = require('./defineRoute.cjs');
3
+ const require_responseData = require('./responseData.cjs');
4
+ let zod_mini = require("zod/mini");
5
+
6
+ //#region src/search.ts
7
+ /** One documentation chunk matching a search. */
8
+ const searchDocResultSchema = zod_mini.z.object({
9
+ fileKey: zod_mini.z.string(),
10
+ chunkNumber: zod_mini.z.number(),
11
+ content: zod_mini.z.optional(zod_mini.z.string()),
12
+ docUrl: zod_mini.z.string(),
13
+ docName: zod_mini.z.string(),
14
+ /** Front matter `priority` of the source file, from 1 to 10. */
15
+ priority: zod_mini.z.optional(zod_mini.z.number())
16
+ });
17
+ /** REST contract of the `/api/search` routes. */
18
+ const searchContract = require_defineRoute.defineRouteGroup({
19
+ prefix: "/api/search",
20
+ tag: "Search",
21
+ routes: { doc: require_defineRoute.defineRoute({
22
+ method: "GET",
23
+ path: "/doc",
24
+ summary: "Semantic search in the Intlayer documentation",
25
+ schemas: {
26
+ querystring: zod_mini.z.object({
27
+ input: zod_mini.z.string(),
28
+ limit: zod_mini.z.optional(zod_mini.z.string()),
29
+ /** `true` to return the chunks content instead of their URLs. */
30
+ returnContent: zod_mini.z.optional(zod_mini.z.string())
31
+ }),
32
+ response: { 200: require_responseData.responseDataSchema(zod_mini.z.union([zod_mini.z.array(zod_mini.z.string()), zod_mini.z.array(searchDocResultSchema)])) }
33
+ }
34
+ }) }
35
+ });
36
+
37
+ //#endregion
38
+ exports.searchContract = searchContract;
39
+ exports.searchDocResultSchema = searchDocResultSchema;
40
+ //# sourceMappingURL=search.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.cjs","names":["z","defineRouteGroup","defineRoute","responseDataSchema"],"sources":["../../src/search.ts"],"sourcesContent":["import { z } from 'zod/mini';\nimport {\n defineRoute,\n defineRouteGroup,\n type RouteQuerystring,\n} from './defineRoute';\nimport { type ResponseData, responseDataSchema } from './responseData';\n\n/** One documentation chunk matching a search. */\nexport const searchDocResultSchema = z.object({\n fileKey: z.string(),\n chunkNumber: z.number(),\n content: z.optional(z.string()),\n docUrl: z.string(),\n docName: z.string(),\n /** Front matter `priority` of the source file, from 1 to 10. */\n priority: z.optional(z.number()),\n});\n\n/** REST contract of the `/api/search` routes. */\nexport const searchContract = defineRouteGroup({\n prefix: '/api/search',\n tag: 'Search',\n routes: {\n doc: defineRoute({\n method: 'GET',\n path: '/doc',\n summary: 'Semantic search in the Intlayer documentation',\n schemas: {\n querystring: z.object({\n input: z.string(),\n limit: z.optional(z.string()),\n /** `true` to return the chunks content instead of their URLs. */\n returnContent: z.optional(z.string()),\n }),\n response: {\n 200: responseDataSchema(\n z.union([z.array(z.string()), z.array(searchDocResultSchema)])\n ),\n },\n },\n }),\n },\n});\n\n/** Route definitions of the `/api/search` group, by name. */\nexport type SearchRoutes = (typeof searchContract)['routes'];\n\nexport type SearchDocResult = z.output<typeof searchDocResultSchema>;\nexport type SearchDocUtilParams = RouteQuerystring<SearchRoutes['doc']>;\nexport type SearchDocUtilResult = ResponseData<string[] | SearchDocResult[]>;\n"],"mappings":";;;;;;;AASA,MAAa,wBAAwBA,WAAE,OAAO;CAC5C,SAASA,WAAE,OAAO;CAClB,aAAaA,WAAE,OAAO;CACtB,SAASA,WAAE,SAASA,WAAE,OAAO,CAAC;CAC9B,QAAQA,WAAE,OAAO;CACjB,SAASA,WAAE,OAAO;;CAElB,UAAUA,WAAE,SAASA,WAAE,OAAO,CAAC;AACjC,CAAC;;AAGD,MAAa,iBAAiBC,qCAAiB;CAC7C,QAAQ;CACR,KAAK;CACL,QAAQ,EACN,KAAKC,gCAAY;EACf,QAAQ;EACR,MAAM;EACN,SAAS;EACT,SAAS;GACP,aAAaF,WAAE,OAAO;IACpB,OAAOA,WAAE,OAAO;IAChB,OAAOA,WAAE,SAASA,WAAE,OAAO,CAAC;;IAE5B,eAAeA,WAAE,SAASA,WAAE,OAAO,CAAC;GACtC,CAAC;GACD,UAAU,EACR,KAAKG,wCACHH,WAAE,MAAM,CAACA,WAAE,MAAMA,WAAE,OAAO,CAAC,GAAGA,WAAE,MAAM,qBAAqB,CAAC,CAAC,CAC/D,EACF;EACF;CACF,CAAC,EACH;AACF,CAAC"}
@@ -0,0 +1,56 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_common = require('./common.cjs');
3
+ const require_project = require('./project.cjs');
4
+ const require_organization = require('./organization.cjs');
5
+ const require_user = require('./user.cjs');
6
+ let zod_mini = require("zod/mini");
7
+
8
+ //#region src/session.ts
9
+ /** Named groupings of privileges granted to a user. */
10
+ const rolesSchema = zod_mini.z.enum([
11
+ "user",
12
+ "admin",
13
+ "org_admin",
14
+ "org_user",
15
+ "project_admin",
16
+ "project_user",
17
+ "project_reviewer"
18
+ ]);
19
+ const allowedEnvironmentIdsSchema = zod_mini.z.nullable(zod_mini.z.array(zod_mini.z.nullable(zod_mini.z.string())));
20
+ /** better-auth session record (token excluded from the API shape). */
21
+ const sessionDataSchema = zod_mini.z.looseObject({
22
+ id: zod_mini.z.string(),
23
+ userId: zod_mini.z.string(),
24
+ expiresAt: require_common.dateTimeSchema,
25
+ createdAt: require_common.dateTimeSchema,
26
+ updatedAt: require_common.dateTimeSchema,
27
+ ipAddress: zod_mini.z.optional(zod_mini.z.nullable(zod_mini.z.string())),
28
+ userAgent: zod_mini.z.optional(zod_mini.z.nullable(zod_mini.z.string())),
29
+ activeOrganizationId: zod_mini.z.optional(zod_mini.z.nullable(zod_mini.z.string())),
30
+ activeProjectId: zod_mini.z.optional(zod_mini.z.nullable(zod_mini.z.string())),
31
+ activeEnvironmentId: zod_mini.z.optional(zod_mini.z.nullable(zod_mini.z.string())),
32
+ locale: zod_mini.z.optional(require_common.typedStringSchema())
33
+ });
34
+ /** Session as returned to the dashboard (`get-session`). */
35
+ const sessionSchema = zod_mini.z.looseObject({
36
+ session: sessionDataSchema,
37
+ user: require_user.userSchema,
38
+ organization: zod_mini.z.optional(zod_mini.z.nullable(require_organization.organizationSchema)),
39
+ project: zod_mini.z.optional(zod_mini.z.nullable(require_project.projectSchema)),
40
+ environment: zod_mini.z.optional(zod_mini.z.nullable(require_project.environmentSchema)),
41
+ id: zod_mini.z.optional(zod_mini.z.string()),
42
+ permissions: zod_mini.z.array(require_common.typedStringSchema()),
43
+ roles: zod_mini.z.array(rolesSchema),
44
+ authType: zod_mini.z.nullable(zod_mini.z.enum(["session", "oauth2"])),
45
+ locale: zod_mini.z.optional(require_common.typedStringSchema()),
46
+ /** null = unrestricted; [] = none; array = allowed ids (null item = production). */
47
+ allowedEnvironmentIds: zod_mini.z.optional(allowedEnvironmentIdsSchema),
48
+ /** null = unrestricted; [] = none; array = allowed locales. */
49
+ allowedLocales: zod_mini.z.optional(zod_mini.z.nullable(zod_mini.z.array(require_common.typedStringSchema())))
50
+ });
51
+
52
+ //#endregion
53
+ exports.rolesSchema = rolesSchema;
54
+ exports.sessionDataSchema = sessionDataSchema;
55
+ exports.sessionSchema = sessionSchema;
56
+ //# sourceMappingURL=session.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.cjs","names":["z","dateTimeSchema","typedStringSchema","userSchema","organizationSchema","projectSchema","environmentSchema"],"sources":["../../src/session.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport { z } from 'zod/mini';\nimport { dateTimeSchema, typedStringSchema } from './common';\nimport { organizationSchema } from './organization';\nimport { environmentSchema, projectSchema } from './project';\nimport { userSchema } from './user';\n\n/** Named groupings of privileges granted to a user. */\nexport const rolesSchema = z.enum([\n 'user',\n 'admin',\n 'org_admin',\n 'org_user',\n 'project_admin',\n 'project_user',\n 'project_reviewer',\n]);\n\n/** Protected resources and the actions performed on them. */\ntype Resource = 'organization' | 'project' | 'dictionary' | 'tag' | 'user';\ntype Action = 'read' | 'write' | 'admin';\n\n/** `resource:action` unit checked at runtime (ex: `project:write`). */\nexport type Permission = `${Resource}:${Action}`;\n\nconst allowedEnvironmentIdsSchema = z.nullable(z.array(z.nullable(z.string())));\n\n/** better-auth session record (token excluded from the API shape). */\nexport const sessionDataSchema = z.looseObject({\n id: z.string(),\n userId: z.string(),\n expiresAt: dateTimeSchema,\n createdAt: dateTimeSchema,\n updatedAt: dateTimeSchema,\n ipAddress: z.optional(z.nullable(z.string())),\n userAgent: z.optional(z.nullable(z.string())),\n activeOrganizationId: z.optional(z.nullable(z.string())),\n activeProjectId: z.optional(z.nullable(z.string())),\n activeEnvironmentId: z.optional(z.nullable(z.string())),\n locale: z.optional(typedStringSchema<Locale>()),\n});\n\n/** Session as returned to the dashboard (`get-session`). */\nexport const sessionSchema = z.looseObject({\n session: sessionDataSchema,\n user: userSchema,\n organization: z.optional(z.nullable(organizationSchema)),\n project: z.optional(z.nullable(projectSchema)),\n environment: z.optional(z.nullable(environmentSchema)),\n id: z.optional(z.string()),\n permissions: z.array(typedStringSchema<Permission>()),\n roles: z.array(rolesSchema),\n authType: z.nullable(z.enum(['session', 'oauth2'])),\n locale: z.optional(typedStringSchema<Locale>()),\n /** null = unrestricted; [] = none; array = allowed ids (null item = production). */\n allowedEnvironmentIds: z.optional(allowedEnvironmentIdsSchema),\n /** null = unrestricted; [] = none; array = allowed locales. */\n allowedLocales: z.optional(z.nullable(z.array(typedStringSchema<Locale>()))),\n});\n\nexport type Roles = z.output<typeof rolesSchema>;\nexport type SessionDataAPI = z.output<typeof sessionDataSchema>;\nexport type SessionAPI = z.output<typeof sessionSchema>;\n"],"mappings":";;;;;;;;;AAQA,MAAa,cAAcA,WAAE,KAAK;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AASD,MAAM,8BAA8BA,WAAE,SAASA,WAAE,MAAMA,WAAE,SAASA,WAAE,OAAO,CAAC,CAAC,CAAC;;AAG9E,MAAa,oBAAoBA,WAAE,YAAY;CAC7C,IAAIA,WAAE,OAAO;CACb,QAAQA,WAAE,OAAO;CACjB,WAAWC;CACX,WAAWA;CACX,WAAWA;CACX,WAAWD,WAAE,SAASA,WAAE,SAASA,WAAE,OAAO,CAAC,CAAC;CAC5C,WAAWA,WAAE,SAASA,WAAE,SAASA,WAAE,OAAO,CAAC,CAAC;CAC5C,sBAAsBA,WAAE,SAASA,WAAE,SAASA,WAAE,OAAO,CAAC,CAAC;CACvD,iBAAiBA,WAAE,SAASA,WAAE,SAASA,WAAE,OAAO,CAAC,CAAC;CAClD,qBAAqBA,WAAE,SAASA,WAAE,SAASA,WAAE,OAAO,CAAC,CAAC;CACtD,QAAQA,WAAE,SAASE,iCAA0B,CAAC;AAChD,CAAC;;AAGD,MAAa,gBAAgBF,WAAE,YAAY;CACzC,SAAS;CACT,MAAMG;CACN,cAAcH,WAAE,SAASA,WAAE,SAASI,uCAAkB,CAAC;CACvD,SAASJ,WAAE,SAASA,WAAE,SAASK,6BAAa,CAAC;CAC7C,aAAaL,WAAE,SAASA,WAAE,SAASM,iCAAiB,CAAC;CACrD,IAAIN,WAAE,SAASA,WAAE,OAAO,CAAC;CACzB,aAAaA,WAAE,MAAME,iCAA8B,CAAC;CACpD,OAAOF,WAAE,MAAM,WAAW;CAC1B,UAAUA,WAAE,SAASA,WAAE,KAAK,CAAC,WAAW,QAAQ,CAAC,CAAC;CAClD,QAAQA,WAAE,SAASE,iCAA0B,CAAC;;CAE9C,uBAAuBF,WAAE,SAAS,2BAA2B;;CAE7D,gBAAgBA,WAAE,SAASA,WAAE,SAASA,WAAE,MAAME,iCAA0B,CAAC,CAAC,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,185 @@
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/showcaseProject.ts
8
+ /** Rejects repository URLs, which belong in the `githubUrl` field. */
9
+ const isNotRepositoryURL = zod_mini.z.refine((value) => !/github\.com|gitlab\.com|bitbucket\.org|codeberg\.org|gitee\.com/.test(value), { message: "Repository URLs should be placed in the GitHub URL field" });
10
+ /** Optional URL where an empty string means "not provided". */
11
+ const optionalURLSchema = zod_mini.z.pipe(zod_mini.z.union([zod_mini.z.optional(zod_mini.z.url()), zod_mini.z.literal("")]), zod_mini.z.transform((value) => value === "" ? void 0 : value));
12
+ /** Up to three use cases describing the project. */
13
+ const useCasesSchema = zod_mini.z.optional(zod_mini.z.array(zod_mini.z.string()).check(zod_mini.z.maxLength(3)));
14
+ /** Votes of a showcase project, with the session's own vote. */
15
+ const votesSchema = zod_mini.z.object({
16
+ upvotes: zod_mini.z.number(),
17
+ isUpVoted: zod_mini.z.boolean(),
18
+ downvotes: zod_mini.z.number(),
19
+ isDownVoted: zod_mini.z.boolean()
20
+ });
21
+ /** i18n SEO checks run on the showcased website. */
22
+ const showcaseScanDetailsSchema = zod_mini.z.object({
23
+ score: zod_mini.z.number(),
24
+ langTag: zod_mini.z.string(),
25
+ htmlDir: zod_mini.z.string(),
26
+ hreflangs: zod_mini.z.array(zod_mini.z.string()),
27
+ hasXDefault: zod_mini.z.boolean(),
28
+ hasCanonical: zod_mini.z.boolean(),
29
+ hasLocalizedLinks: zod_mini.z.boolean(),
30
+ allAnchorsLocalized: zod_mini.z.boolean(),
31
+ robotsTxt: zod_mini.z.object({
32
+ accessible: zod_mini.z.boolean(),
33
+ disallowWithoutLocaleAlternates: zod_mini.z.boolean()
34
+ }),
35
+ sitemapXml: zod_mini.z.object({
36
+ urlsDiscoveredCount: zod_mini.z.number(),
37
+ alternatesPresent: zod_mini.z.boolean(),
38
+ xDefaultPresent: zod_mini.z.boolean()
39
+ })
40
+ });
41
+ /** Showcase project as returned by the API. */
42
+ const showcaseProjectSchema = zod_mini.z.looseObject({
43
+ id: zod_mini.z.string(),
44
+ title: zod_mini.z.string(),
45
+ description: zod_mini.z.string(),
46
+ imageUrl: zod_mini.z.string(),
47
+ logoUrl: zod_mini.z.optional(zod_mini.z.string()),
48
+ websiteUrl: zod_mini.z.string(),
49
+ githubUrl: zod_mini.z.optional(zod_mini.z.nullable(zod_mini.z.string())),
50
+ tags: zod_mini.z.array(zod_mini.z.string()),
51
+ isOpenSource: zod_mini.z.boolean(),
52
+ intlayerVersion: zod_mini.z.optional(zod_mini.z.string()),
53
+ libsUsed: zod_mini.z.array(zod_mini.z.string()),
54
+ packageDetails: zod_mini.z.optional(zod_mini.z.record(zod_mini.z.string(), zod_mini.z.string())),
55
+ lastScanDate: zod_mini.z.optional(require_common.dateTimeSchema),
56
+ scanDetails: zod_mini.z.optional(showcaseScanDetailsSchema),
57
+ owner: zod_mini.z.optional(zod_mini.z.string()),
58
+ status: zod_mini.z.optional(zod_mini.z.enum([
59
+ "pending_scan",
60
+ "active",
61
+ "scan_failed"
62
+ ])),
63
+ createdAt: require_common.dateTimeSchema,
64
+ isOwner: zod_mini.z.optional(zod_mini.z.boolean()),
65
+ ...votesSchema.shape
66
+ });
67
+ const projectIdParamsSchema = zod_mini.z.object({ projectId: require_common.objectIdSchema });
68
+ const projectIdBodySchema = zod_mini.z.object({ projectId: require_common.objectIdSchema });
69
+ /** REST contract of the `/api/showcase-project` routes. */
70
+ const showcaseProjectContract = require_defineRoute.defineRouteGroup({
71
+ prefix: "/api/showcase-project",
72
+ tag: "Showcase project",
73
+ routes: {
74
+ getShowcaseProjects: require_defineRoute.defineRoute({
75
+ method: "GET",
76
+ path: "/",
77
+ summary: "List the projects showcased on intlayer.org",
78
+ schemas: {
79
+ querystring: zod_mini.z.object({
80
+ ...require_common.paginationQueryShape,
81
+ search: zod_mini.z.optional(zod_mini.z.string()),
82
+ selectedUseCases: zod_mini.z.optional(require_common.repeatableQueryValueSchema),
83
+ isOpenSource: zod_mini.z.optional(zod_mini.z.string())
84
+ }),
85
+ response: { 200: require_responseData.paginatedResponseSchema(showcaseProjectSchema) }
86
+ }
87
+ }),
88
+ submitShowcaseProject: require_defineRoute.defineRoute({
89
+ method: "POST",
90
+ path: "/submit",
91
+ summary: "Submit a project to the showcase (scanned before listing)",
92
+ schemas: {
93
+ body: zod_mini.z.object({
94
+ name: zod_mini.z.string().check(zod_mini.z.minLength(1)),
95
+ url: zod_mini.z.url().check(isNotRepositoryURL),
96
+ githubUrl: optionalURLSchema,
97
+ useCases: useCasesSchema
98
+ }),
99
+ response: { 200: require_responseData.responseDataSchema(showcaseProjectSchema) }
100
+ }
101
+ }),
102
+ getOtherShowcaseProjects: require_defineRoute.defineRoute({
103
+ method: "GET",
104
+ path: "/others",
105
+ summary: "Other showcase projects, for \"see also\" sections",
106
+ schemas: {
107
+ querystring: zod_mini.z.object({
108
+ excludeId: zod_mini.z.string(),
109
+ limit: zod_mini.z.optional(zod_mini.z.string())
110
+ }),
111
+ response: { 200: require_responseData.responseDataSchema(zod_mini.z.array(showcaseProjectSchema)) }
112
+ }
113
+ }),
114
+ toggleShowcaseUpvote: require_defineRoute.defineRoute({
115
+ method: "POST",
116
+ path: "/upvote",
117
+ summary: "Toggle the upvote of the signed-in user",
118
+ schemas: {
119
+ body: projectIdBodySchema,
120
+ response: { 200: require_responseData.responseDataSchema(votesSchema) }
121
+ }
122
+ }),
123
+ toggleShowcaseDownvote: require_defineRoute.defineRoute({
124
+ method: "POST",
125
+ path: "/downvote",
126
+ summary: "Toggle the downvote of the signed-in user",
127
+ schemas: {
128
+ body: projectIdBodySchema,
129
+ response: { 200: require_responseData.responseDataSchema(votesSchema) }
130
+ }
131
+ }),
132
+ getShowcaseProjectById: require_defineRoute.defineRoute({
133
+ method: "GET",
134
+ path: "/:projectId",
135
+ summary: "Get a showcase project",
136
+ schemas: {
137
+ params: projectIdParamsSchema,
138
+ response: { 200: require_responseData.responseDataSchema(showcaseProjectSchema) }
139
+ }
140
+ }),
141
+ scanShowcaseProject: require_defineRoute.defineRoute({
142
+ method: "GET",
143
+ path: "/:projectId/scan",
144
+ summary: "Owner only: re-scan the project (server-sent events stream)",
145
+ schemas: { params: projectIdParamsSchema }
146
+ }),
147
+ deleteShowcaseProject: require_defineRoute.defineRoute({
148
+ method: "DELETE",
149
+ path: "/:projectId",
150
+ summary: "Owner only: delete a showcase project",
151
+ schemas: {
152
+ params: projectIdParamsSchema,
153
+ response: { 200: require_responseData.responseDataSchema(zod_mini.z.object({ success: zod_mini.z.boolean() })) }
154
+ }
155
+ }),
156
+ updateShowcaseProject: require_defineRoute.defineRoute({
157
+ method: "PATCH",
158
+ path: "/:projectId",
159
+ summary: "Owner only: update a showcase project",
160
+ schemas: {
161
+ params: projectIdParamsSchema,
162
+ body: zod_mini.z.object({
163
+ name: zod_mini.z.optional(zod_mini.z.string().check(zod_mini.z.minLength(1), zod_mini.z.maxLength(255))),
164
+ url: zod_mini.z.optional(zod_mini.z.url().check(isNotRepositoryURL)),
165
+ /** Normalized to an `https://` URL; empty clears it (`null`). */
166
+ githubUrl: zod_mini.z.pipe(zod_mini.z.optional(zod_mini.z.string()), zod_mini.z.transform((value) => {
167
+ if (!value) return null;
168
+ if (value.startsWith("http://") || value.startsWith("https://")) return value;
169
+ return `https://${value}`;
170
+ })),
171
+ tagline: zod_mini.z.optional(zod_mini.z.string().check(zod_mini.z.minLength(1), zod_mini.z.maxLength(500))),
172
+ description: zod_mini.z.optional(zod_mini.z.string()),
173
+ useCases: useCasesSchema
174
+ }),
175
+ response: { 200: require_responseData.responseDataSchema(showcaseProjectSchema) }
176
+ }
177
+ })
178
+ }
179
+ });
180
+
181
+ //#endregion
182
+ exports.showcaseProjectContract = showcaseProjectContract;
183
+ exports.showcaseProjectSchema = showcaseProjectSchema;
184
+ exports.showcaseScanDetailsSchema = showcaseScanDetailsSchema;
185
+ //# sourceMappingURL=showcaseProject.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"showcaseProject.cjs","names":["z","dateTimeSchema","objectIdSchema","defineRouteGroup","defineRoute","paginationQueryShape","repeatableQueryValueSchema","paginatedResponseSchema","responseDataSchema"],"sources":["../../src/showcaseProject.ts"],"sourcesContent":["import { z } from 'zod/mini';\nimport {\n dateTimeSchema,\n objectIdSchema,\n paginationQueryShape,\n repeatableQueryValueSchema,\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/** Rejects repository URLs, which belong in the `githubUrl` field. */\nconst isNotRepositoryURL = z.refine<string>(\n (value: string) =>\n !/github\\.com|gitlab\\.com|bitbucket\\.org|codeberg\\.org|gitee\\.com/.test(\n value\n ),\n { message: 'Repository URLs should be placed in the GitHub URL field' }\n);\n\n/** Optional URL where an empty string means \"not provided\". */\nconst optionalURLSchema = z.pipe(\n z.union([z.optional(z.url()), z.literal('')]),\n z.transform((value) => (value === '' ? undefined : value))\n);\n\n/** Up to three use cases describing the project. */\nconst useCasesSchema = z.optional(z.array(z.string()).check(z.maxLength(3)));\n\n/** Votes of a showcase project, with the session's own vote. */\nconst votesSchema = z.object({\n upvotes: z.number(),\n isUpVoted: z.boolean(),\n downvotes: z.number(),\n isDownVoted: z.boolean(),\n});\n\n/** i18n SEO checks run on the showcased website. */\nexport const showcaseScanDetailsSchema = z.object({\n score: z.number(),\n langTag: z.string(),\n htmlDir: z.string(),\n hreflangs: z.array(z.string()),\n hasXDefault: z.boolean(),\n hasCanonical: z.boolean(),\n hasLocalizedLinks: z.boolean(),\n allAnchorsLocalized: z.boolean(),\n robotsTxt: z.object({\n accessible: z.boolean(),\n disallowWithoutLocaleAlternates: z.boolean(),\n }),\n sitemapXml: z.object({\n urlsDiscoveredCount: z.number(),\n alternatesPresent: z.boolean(),\n xDefaultPresent: z.boolean(),\n }),\n});\n\n/** Showcase project as returned by the API. */\nexport const showcaseProjectSchema = z.looseObject({\n id: z.string(),\n title: z.string(),\n description: z.string(),\n imageUrl: z.string(),\n logoUrl: z.optional(z.string()),\n websiteUrl: z.string(),\n githubUrl: z.optional(z.nullable(z.string())),\n tags: z.array(z.string()),\n isOpenSource: z.boolean(),\n intlayerVersion: z.optional(z.string()),\n libsUsed: z.array(z.string()),\n packageDetails: z.optional(z.record(z.string(), z.string())),\n lastScanDate: z.optional(dateTimeSchema),\n scanDetails: z.optional(showcaseScanDetailsSchema),\n owner: z.optional(z.string()),\n status: z.optional(z.enum(['pending_scan', 'active', 'scan_failed'])),\n createdAt: dateTimeSchema,\n isOwner: z.optional(z.boolean()),\n ...votesSchema.shape,\n});\n\nconst projectIdParamsSchema = z.object({ projectId: objectIdSchema });\nconst projectIdBodySchema = z.object({ projectId: objectIdSchema });\n\n/** REST contract of the `/api/showcase-project` routes. */\nexport const showcaseProjectContract = defineRouteGroup({\n prefix: '/api/showcase-project',\n tag: 'Showcase project',\n routes: {\n getShowcaseProjects: defineRoute({\n method: 'GET',\n path: '/',\n summary: 'List the projects showcased on intlayer.org',\n schemas: {\n querystring: z.object({\n ...paginationQueryShape,\n search: z.optional(z.string()),\n selectedUseCases: z.optional(repeatableQueryValueSchema),\n isOpenSource: z.optional(z.string()),\n }),\n response: { 200: paginatedResponseSchema(showcaseProjectSchema) },\n },\n }),\n submitShowcaseProject: defineRoute({\n method: 'POST',\n path: '/submit',\n summary: 'Submit a project to the showcase (scanned before listing)',\n schemas: {\n body: z.object({\n name: z.string().check(z.minLength(1)),\n url: z.url().check(isNotRepositoryURL),\n githubUrl: optionalURLSchema,\n useCases: useCasesSchema,\n }),\n response: { 200: responseDataSchema(showcaseProjectSchema) },\n },\n }),\n getOtherShowcaseProjects: defineRoute({\n method: 'GET',\n path: '/others',\n summary: 'Other showcase projects, for \"see also\" sections',\n schemas: {\n querystring: z.object({\n excludeId: z.string(),\n limit: z.optional(z.string()),\n }),\n response: {\n 200: responseDataSchema(z.array(showcaseProjectSchema)),\n },\n },\n }),\n toggleShowcaseUpvote: defineRoute({\n method: 'POST',\n path: '/upvote',\n summary: 'Toggle the upvote of the signed-in user',\n schemas: {\n body: projectIdBodySchema,\n response: { 200: responseDataSchema(votesSchema) },\n },\n }),\n toggleShowcaseDownvote: defineRoute({\n method: 'POST',\n path: '/downvote',\n summary: 'Toggle the downvote of the signed-in user',\n schemas: {\n body: projectIdBodySchema,\n response: { 200: responseDataSchema(votesSchema) },\n },\n }),\n getShowcaseProjectById: defineRoute({\n method: 'GET',\n path: '/:projectId',\n summary: 'Get a showcase project',\n schemas: {\n params: projectIdParamsSchema,\n response: { 200: responseDataSchema(showcaseProjectSchema) },\n },\n }),\n scanShowcaseProject: defineRoute({\n method: 'GET',\n path: '/:projectId/scan',\n summary: 'Owner only: re-scan the project (server-sent events stream)',\n schemas: {\n params: projectIdParamsSchema,\n },\n }),\n deleteShowcaseProject: defineRoute({\n method: 'DELETE',\n path: '/:projectId',\n summary: 'Owner only: delete a showcase project',\n schemas: {\n params: projectIdParamsSchema,\n response: {\n 200: responseDataSchema(z.object({ success: z.boolean() })),\n },\n },\n }),\n updateShowcaseProject: defineRoute({\n method: 'PATCH',\n path: '/:projectId',\n summary: 'Owner only: update a showcase project',\n schemas: {\n params: projectIdParamsSchema,\n body: z.object({\n name: z.optional(z.string().check(z.minLength(1), z.maxLength(255))),\n url: z.optional(z.url().check(isNotRepositoryURL)),\n /** Normalized to an `https://` URL; empty clears it (`null`). */\n githubUrl: z.pipe(\n z.optional(z.string()),\n z.transform((value) => {\n if (!value) return null;\n if (value.startsWith('http://') || value.startsWith('https://'))\n return value;\n return `https://${value}`;\n })\n ),\n tagline: z.optional(\n z.string().check(z.minLength(1), z.maxLength(500))\n ),\n description: z.optional(z.string()),\n useCases: useCasesSchema,\n }),\n response: { 200: responseDataSchema(showcaseProjectSchema) },\n },\n }),\n },\n});\n\n/** Route definitions of the `/api/showcase-project` group, by name. */\nexport type ShowcaseProjectRoutes = (typeof showcaseProjectContract)['routes'];\n\ntype ShowcaseVotes = z.output<typeof votesSchema>;\n\nexport type ShowcaseScanDetails = z.output<typeof showcaseScanDetailsSchema>;\nexport type ShowcaseProjectAPI = z.output<typeof showcaseProjectSchema>;\nexport type GetShowcaseProjectsQuery = RouteQuerystring<\n ShowcaseProjectRoutes['getShowcaseProjects']\n>;\nexport type GetShowcaseProjectsResult = PaginatedResponse<ShowcaseProjectAPI>;\nexport type SubmitShowcaseProjectBody = RouteBodyInput<\n ShowcaseProjectRoutes['submitShowcaseProject']\n>;\nexport type SubmitShowcaseProjectResult = ResponseData<ShowcaseProjectAPI>;\nexport type GetOtherShowcaseProjectsQuery = RouteQuerystring<\n ShowcaseProjectRoutes['getOtherShowcaseProjects']\n>;\nexport type GetOtherShowcaseProjectsResult = ResponseData<ShowcaseProjectAPI[]>;\nexport type ToggleShowcaseUpvoteBody = RouteBodyInput<\n ShowcaseProjectRoutes['toggleShowcaseUpvote']\n>;\nexport type ToggleShowcaseUpvoteResult = ResponseData<ShowcaseVotes>;\nexport type ToggleShowcaseDownvoteBody = RouteBodyInput<\n ShowcaseProjectRoutes['toggleShowcaseDownvote']\n>;\nexport type ToggleShowcaseDownvoteResult = ResponseData<ShowcaseVotes>;\nexport type GetShowcaseProjectByIdParams = RouteParams<\n ShowcaseProjectRoutes['getShowcaseProjectById']\n>;\nexport type GetShowcaseProjectByIdResult = ResponseData<ShowcaseProjectAPI>;\nexport type UpdateShowcaseProjectParams = RouteParams<\n ShowcaseProjectRoutes['updateShowcaseProject']\n>;\nexport type UpdateShowcaseProjectBody = RouteBodyInput<\n ShowcaseProjectRoutes['updateShowcaseProject']\n>;\nexport type UpdateShowcaseProjectResult = ResponseData<ShowcaseProjectAPI>;\nexport type DeleteShowcaseProjectParams = RouteParams<\n ShowcaseProjectRoutes['deleteShowcaseProject']\n>;\n"],"mappings":";;;;;;;;AAsBA,MAAM,qBAAqBA,WAAE,QAC1B,UACC,CAAC,kEAAkE,KACjE,KACF,GACF,EAAE,SAAS,2DAA2D,CACxE;;AAGA,MAAM,oBAAoBA,WAAE,KAC1BA,WAAE,MAAM,CAACA,WAAE,SAASA,WAAE,IAAI,CAAC,GAAGA,WAAE,QAAQ,EAAE,CAAC,CAAC,GAC5CA,WAAE,WAAW,UAAW,UAAU,KAAK,SAAY,KAAM,CAC3D;;AAGA,MAAM,i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