@intlayer/backend-contract 0.0.0-stage → 9.6.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 (164) hide show
  1. package/README.md +330 -2
  2. package/dist/cjs/ai.cjs +267 -0
  3. package/dist/cjs/ai.cjs.map +1 -0
  4. package/dist/cjs/analytics.cjs +175 -0
  5. package/dist/cjs/analytics.cjs.map +1 -0
  6. package/dist/cjs/asset.cjs +88 -0
  7. package/dist/cjs/asset.cjs.map +1 -0
  8. package/dist/cjs/blogComment.cjs +98 -0
  9. package/dist/cjs/blogComment.cjs.map +1 -0
  10. package/dist/cjs/cliSessionToken.cjs +40 -0
  11. package/dist/cjs/cliSessionToken.cjs.map +1 -0
  12. package/dist/cjs/common.cjs +42 -0
  13. package/dist/cjs/common.cjs.map +1 -0
  14. package/dist/cjs/defineRoute.cjs +26 -0
  15. package/dist/cjs/defineRoute.cjs.map +1 -0
  16. package/dist/cjs/demo.cjs +22 -0
  17. package/dist/cjs/demo.cjs.map +1 -0
  18. package/dist/cjs/dictionary.cjs +168 -0
  19. package/dist/cjs/dictionary.cjs.map +1 -0
  20. package/dist/cjs/environment.cjs +91 -0
  21. package/dist/cjs/environment.cjs.map +1 -0
  22. package/dist/cjs/eventListener.cjs +19 -0
  23. package/dist/cjs/eventListener.cjs.map +1 -0
  24. package/dist/cjs/gitProviders.cjs +361 -0
  25. package/dist/cjs/gitProviders.cjs.map +1 -0
  26. package/dist/cjs/newsletter.cjs +50 -0
  27. package/dist/cjs/newsletter.cjs.map +1 -0
  28. package/dist/cjs/oAuth2.cjs +62 -0
  29. package/dist/cjs/oAuth2.cjs.map +1 -0
  30. package/dist/cjs/organization.cjs +226 -0
  31. package/dist/cjs/organization.cjs.map +1 -0
  32. package/dist/cjs/project.cjs +401 -0
  33. package/dist/cjs/project.cjs.map +1 -0
  34. package/dist/cjs/public.cjs +60 -0
  35. package/dist/cjs/public.cjs.map +1 -0
  36. package/dist/cjs/responseData.cjs +33 -0
  37. package/dist/cjs/responseData.cjs.map +1 -0
  38. package/dist/cjs/reviewer.cjs +401 -0
  39. package/dist/cjs/reviewer.cjs.map +1 -0
  40. package/dist/cjs/scan.cjs +235 -0
  41. package/dist/cjs/scan.cjs.map +1 -0
  42. package/dist/cjs/search.cjs +40 -0
  43. package/dist/cjs/search.cjs.map +1 -0
  44. package/dist/cjs/session.cjs +56 -0
  45. package/dist/cjs/session.cjs.map +1 -0
  46. package/dist/cjs/showcaseProject.cjs +185 -0
  47. package/dist/cjs/showcaseProject.cjs.map +1 -0
  48. package/dist/cjs/stripe.cjs +388 -0
  49. package/dist/cjs/stripe.cjs.map +1 -0
  50. package/dist/cjs/tag.cjs +83 -0
  51. package/dist/cjs/tag.cjs.map +1 -0
  52. package/dist/cjs/translation.cjs +54 -0
  53. package/dist/cjs/translation.cjs.map +1 -0
  54. package/dist/cjs/user.cjs +153 -0
  55. package/dist/cjs/user.cjs.map +1 -0
  56. package/dist/esm/ai.mjs +261 -0
  57. package/dist/esm/ai.mjs.map +1 -0
  58. package/dist/esm/analytics.mjs +168 -0
  59. package/dist/esm/analytics.mjs.map +1 -0
  60. package/dist/esm/asset.mjs +86 -0
  61. package/dist/esm/asset.mjs.map +1 -0
  62. package/dist/esm/blogComment.mjs +94 -0
  63. package/dist/esm/blogComment.mjs.map +1 -0
  64. package/dist/esm/cliSessionToken.mjs +39 -0
  65. package/dist/esm/cliSessionToken.mjs.map +1 -0
  66. package/dist/esm/common.mjs +35 -0
  67. package/dist/esm/common.mjs.map +1 -0
  68. package/dist/esm/defineRoute.mjs +23 -0
  69. package/dist/esm/defineRoute.mjs.map +1 -0
  70. package/dist/esm/demo.mjs +21 -0
  71. package/dist/esm/demo.mjs.map +1 -0
  72. package/dist/esm/dictionary.mjs +163 -0
  73. package/dist/esm/dictionary.mjs.map +1 -0
  74. package/dist/esm/environment.mjs +90 -0
  75. package/dist/esm/environment.mjs.map +1 -0
  76. package/dist/esm/eventListener.mjs +18 -0
  77. package/dist/esm/eventListener.mjs.map +1 -0
  78. package/dist/esm/gitProviders.mjs +352 -0
  79. package/dist/esm/gitProviders.mjs.map +1 -0
  80. package/dist/esm/newsletter.mjs +49 -0
  81. package/dist/esm/newsletter.mjs.map +1 -0
  82. package/dist/esm/oAuth2.mjs +60 -0
  83. package/dist/esm/oAuth2.mjs.map +1 -0
  84. package/dist/esm/organization.mjs +219 -0
  85. package/dist/esm/organization.mjs.map +1 -0
  86. package/dist/esm/project.mjs +387 -0
  87. package/dist/esm/project.mjs.map +1 -0
  88. package/dist/esm/public.mjs +58 -0
  89. package/dist/esm/public.mjs.map +1 -0
  90. package/dist/esm/responseData.mjs +30 -0
  91. package/dist/esm/responseData.mjs.map +1 -0
  92. package/dist/esm/reviewer.mjs +390 -0
  93. package/dist/esm/reviewer.mjs.map +1 -0
  94. package/dist/esm/scan.mjs +225 -0
  95. package/dist/esm/scan.mjs.map +1 -0
  96. package/dist/esm/search.mjs +38 -0
  97. package/dist/esm/search.mjs.map +1 -0
  98. package/dist/esm/session.mjs +53 -0
  99. package/dist/esm/session.mjs.map +1 -0
  100. package/dist/esm/showcaseProject.mjs +182 -0
  101. package/dist/esm/showcaseProject.mjs.map +1 -0
  102. package/dist/esm/stripe.mjs +379 -0
  103. package/dist/esm/stripe.mjs.map +1 -0
  104. package/dist/esm/tag.mjs +81 -0
  105. package/dist/esm/tag.mjs.map +1 -0
  106. package/dist/esm/translation.mjs +53 -0
  107. package/dist/esm/translation.mjs.map +1 -0
  108. package/dist/esm/user.mjs +149 -0
  109. package/dist/esm/user.mjs.map +1 -0
  110. package/dist/types/ai.d.ts +549 -0
  111. package/dist/types/ai.d.ts.map +1 -0
  112. package/dist/types/analytics.d.ts +378 -0
  113. package/dist/types/analytics.d.ts.map +1 -0
  114. package/dist/types/asset.d.ts +207 -0
  115. package/dist/types/asset.d.ts.map +1 -0
  116. package/dist/types/blogComment.d.ts +241 -0
  117. package/dist/types/blogComment.d.ts.map +1 -0
  118. package/dist/types/cliSessionToken.d.ts +263 -0
  119. package/dist/types/cliSessionToken.d.ts.map +1 -0
  120. package/dist/types/common.d.ts +32 -0
  121. package/dist/types/common.d.ts.map +1 -0
  122. package/dist/types/defineRoute.d.ts +57 -0
  123. package/dist/types/defineRoute.d.ts.map +1 -0
  124. package/dist/types/demo.d.ts +21 -0
  125. package/dist/types/demo.d.ts.map +1 -0
  126. package/dist/types/dictionary.d.ts +360 -0
  127. package/dist/types/dictionary.d.ts.map +1 -0
  128. package/dist/types/environment.d.ts +284 -0
  129. package/dist/types/environment.d.ts.map +1 -0
  130. package/dist/types/eventListener.d.ts +17 -0
  131. package/dist/types/eventListener.d.ts.map +1 -0
  132. package/dist/types/gitProviders.d.ts +807 -0
  133. package/dist/types/gitProviders.d.ts.map +1 -0
  134. package/dist/types/newsletter.d.ts +165 -0
  135. package/dist/types/newsletter.d.ts.map +1 -0
  136. package/dist/types/oAuth2.d.ts +481 -0
  137. package/dist/types/oAuth2.d.ts.map +1 -0
  138. package/dist/types/organization.d.ts +1069 -0
  139. package/dist/types/organization.d.ts.map +1 -0
  140. package/dist/types/project.d.ts +1735 -0
  141. package/dist/types/project.d.ts.map +1 -0
  142. package/dist/types/public.d.ts +109 -0
  143. package/dist/types/public.d.ts.map +1 -0
  144. package/dist/types/responseData.d.ts +68 -0
  145. package/dist/types/responseData.d.ts.map +1 -0
  146. package/dist/types/reviewer.d.ts +1239 -0
  147. package/dist/types/reviewer.d.ts.map +1 -0
  148. package/dist/types/scan.d.ts +625 -0
  149. package/dist/types/scan.d.ts.map +1 -0
  150. package/dist/types/search.d.ts +55 -0
  151. package/dist/types/search.d.ts.map +1 -0
  152. package/dist/types/session.d.ts +286 -0
  153. package/dist/types/session.d.ts.map +1 -0
  154. package/dist/types/showcaseProject.d.ts +550 -0
  155. package/dist/types/showcaseProject.d.ts.map +1 -0
  156. package/dist/types/stripe.d.ts +1219 -0
  157. package/dist/types/stripe.d.ts.map +1 -0
  158. package/dist/types/tag.d.ts +193 -0
  159. package/dist/types/tag.d.ts.map +1 -0
  160. package/dist/types/translation.d.ts +162 -0
  161. package/dist/types/translation.d.ts.map +1 -0
  162. package/dist/types/user.d.ts +447 -0
  163. package/dist/types/user.d.ts.map +1 -0
  164. package/package.json +300 -4
@@ -0,0 +1,379 @@
1
+ import { defineRoute, defineRouteGroup } from "./defineRoute.mjs";
2
+ import { paginatedResponseSchema, responseDataSchema } from "./responseData.mjs";
3
+ import { dateTimeSchema, objectIdSchema, paginationQueryShape } from "./common.mjs";
4
+ import { planSchema } from "./organization.mjs";
5
+ import { z } from "zod/mini";
6
+
7
+ //#region src/stripe.ts
8
+ /** Stripe invoice. */
9
+ const stripeInvoiceSchema = z.looseObject({
10
+ id: z.optional(z.string()),
11
+ status: z.nullable(z.string()),
12
+ total: z.number(),
13
+ subtotal: z.number(),
14
+ currency: z.string(),
15
+ /** Epoch seconds. */
16
+ created: z.number(),
17
+ hosted_invoice_url: z.optional(z.nullable(z.string()))
18
+ });
19
+ /** Stripe payment method. */
20
+ const stripePaymentMethodSchema = z.looseObject({
21
+ id: z.string(),
22
+ type: z.string(),
23
+ card: z.optional(z.nullable(z.looseObject({
24
+ brand: z.string(),
25
+ last4: z.string(),
26
+ exp_month: z.optional(z.number()),
27
+ exp_year: z.optional(z.number())
28
+ })))
29
+ });
30
+ /** Price of each Stripe price id, after the promo code. */
31
+ const pricingResultSchema = z.record(z.string(), z.object({
32
+ originalTotal: z.number(),
33
+ discountApplied: z.number(),
34
+ discountType: z.nullable(z.enum(["amount", "percentage"])),
35
+ finalTotal: z.number(),
36
+ currency: z.string(),
37
+ planType: z.enum([
38
+ "premium",
39
+ "enterprise",
40
+ "one_time",
41
+ "unknown"
42
+ ]),
43
+ period: z.enum([
44
+ "monthly",
45
+ "yearly",
46
+ "one_time",
47
+ "unknown"
48
+ ])
49
+ }));
50
+ const commissionTypeSchema = z.enum(["recurring", "one_time"]);
51
+ /** Affiliate program member. The Stripe account id is admin information. */
52
+ const affiliateSchema = z.looseObject({
53
+ id: z.string(),
54
+ userId: z.string(),
55
+ stripeAccountId: z.optional(z.string()),
56
+ stripeAccountType: z.optional(z.enum(["express", "standard"])),
57
+ referralCode: z.string(),
58
+ status: z.enum([
59
+ "pending",
60
+ "onboarding",
61
+ "active",
62
+ "suspended"
63
+ ]),
64
+ /** Percentage (20 = 20%). */
65
+ commissionRate: z.number(),
66
+ commissionType: commissionTypeSchema,
67
+ chargesEnabled: z.optional(z.boolean()),
68
+ payoutsEnabled: z.optional(z.boolean()),
69
+ activatedAt: z.optional(dateTimeSchema),
70
+ stripeOnboardingInitiated: z.optional(z.boolean()),
71
+ createdAt: dateTimeSchema,
72
+ updatedAt: dateTimeSchema
73
+ });
74
+ const affiliateStatsSchema = z.object({
75
+ affiliate: affiliateSchema,
76
+ totalReferrals: z.number(),
77
+ convertedReferrals: z.number(),
78
+ pendingReferrals: z.number(),
79
+ /** In cents. */
80
+ totalCommissionEarned: z.number(),
81
+ /** In cents. */
82
+ pendingCommission: z.number(),
83
+ referralLink: z.string()
84
+ });
85
+ const affiliateInvitationSchema = z.looseObject({
86
+ id: z.string(),
87
+ email: z.string(),
88
+ token: z.string(),
89
+ status: z.enum([
90
+ "pending",
91
+ "accepted",
92
+ "expired"
93
+ ]),
94
+ invitedBy: z.string(),
95
+ commissionRate: z.number(),
96
+ commissionType: commissionTypeSchema,
97
+ country: z.optional(z.string()),
98
+ expiresAt: dateTimeSchema,
99
+ createdAt: dateTimeSchema,
100
+ updatedAt: dateTimeSchema
101
+ });
102
+ const promoCodeSchema = z.looseObject({
103
+ id: z.string(),
104
+ code: z.string(),
105
+ stripeCouponId: z.string(),
106
+ stripePromotionCodeId: z.optional(z.string()),
107
+ affiliateId: z.optional(z.string()),
108
+ discountType: z.enum(["percentage", "amount"]),
109
+ discountValue: z.number(),
110
+ currency: z.optional(z.string()),
111
+ maxRedemptions: z.optional(z.number()),
112
+ timesRedeemed: z.number(),
113
+ active: z.boolean(),
114
+ expiresAt: z.optional(dateTimeSchema),
115
+ createdAt: dateTimeSchema,
116
+ updatedAt: dateTimeSchema
117
+ });
118
+ const idParamsSchema = z.object({ id: objectIdSchema });
119
+ const tokenParamsSchema = z.object({ token: z.string().check(z.minLength(1)) });
120
+ const searchQuerySchema = z.looseObject({
121
+ ...paginationQueryShape,
122
+ search: z.optional(z.string())
123
+ });
124
+ const affiliateTermsShape = {
125
+ commissionRate: z.optional(z.number()),
126
+ commissionType: z.optional(commissionTypeSchema),
127
+ country: z.optional(z.string())
128
+ };
129
+ const affiliateResponseSchema = responseDataSchema(affiliateSchema);
130
+ const promoCodeResponseSchema = responseDataSchema(promoCodeSchema);
131
+ const urlResponseSchema = responseDataSchema(z.object({ url: z.string() }));
132
+ /** REST contract of the `/api/stripe` routes (billing, affiliates, promo codes). */
133
+ const stripeContract = defineRouteGroup({
134
+ prefix: "/api/stripe",
135
+ tag: "Billing",
136
+ routes: {
137
+ getPricing: defineRoute({
138
+ method: "POST",
139
+ path: "/pricing",
140
+ summary: "Prices of the plans, with an optional promo code",
141
+ schemas: {
142
+ body: z.object({
143
+ priceIds: z.optional(z.array(z.string())),
144
+ promoCode: z.optional(z.string())
145
+ }),
146
+ response: { 200: responseDataSchema(pricingResultSchema) }
147
+ }
148
+ }),
149
+ createSubscription: defineRoute({
150
+ method: "POST",
151
+ path: "/create-subscription",
152
+ summary: "Start a subscription checkout for the selected organization",
153
+ schemas: {
154
+ body: z.object({
155
+ priceId: z.string(),
156
+ promoCode: z.optional(z.string()),
157
+ referralCode: z.optional(z.string())
158
+ }),
159
+ response: { 200: responseDataSchema(z.looseObject({
160
+ /** Stripe subscription (one-time prices return a payment intent). */
161
+ subscription: z.optional(z.looseObject({ id: z.string() })),
162
+ paymentIntent: z.optional(z.looseObject({ id: z.string() })),
163
+ clientSecret: z.string()
164
+ })) }
165
+ }
166
+ }),
167
+ cancelSubscription: defineRoute({
168
+ method: "POST",
169
+ path: "/cancel-subscription",
170
+ summary: "Cancel the subscription of the selected organization",
171
+ schemas: { response: { 200: responseDataSchema(z.optional(planSchema)) } }
172
+ }),
173
+ getInvoices: defineRoute({
174
+ method: "GET",
175
+ path: "/invoices",
176
+ summary: "Invoices of the selected organization",
177
+ schemas: { response: { 200: responseDataSchema(z.array(stripeInvoiceSchema)) } }
178
+ }),
179
+ getPaymentMethod: defineRoute({
180
+ method: "GET",
181
+ path: "/payment-method",
182
+ summary: "Default payment method of the selected organization",
183
+ schemas: { response: { 200: responseDataSchema(z.nullable(stripePaymentMethodSchema)) } }
184
+ }),
185
+ createPortalSession: defineRoute({
186
+ method: "POST",
187
+ path: "/portal-session",
188
+ summary: "Stripe customer portal URL",
189
+ schemas: { response: { 200: urlResponseSchema } }
190
+ }),
191
+ grantAffiliateAccess: defineRoute({
192
+ method: "POST",
193
+ path: "/affiliate/grant",
194
+ summary: "Admin only: make a user an affiliate",
195
+ schemas: {
196
+ body: z.object({
197
+ userId: objectIdSchema,
198
+ ...affiliateTermsShape
199
+ }),
200
+ response: { 200: affiliateResponseSchema }
201
+ }
202
+ }),
203
+ getAffiliates: defineRoute({
204
+ method: "GET",
205
+ path: "/affiliates",
206
+ summary: "Admin only: list affiliates",
207
+ schemas: {
208
+ querystring: searchQuerySchema,
209
+ response: { 200: paginatedResponseSchema(affiliateSchema) }
210
+ }
211
+ }),
212
+ getAffiliateById: defineRoute({
213
+ method: "GET",
214
+ path: "/affiliates/:id",
215
+ summary: "Admin only: get an affiliate",
216
+ schemas: {
217
+ params: idParamsSchema,
218
+ response: { 200: responseDataSchema(z.nullable(affiliateSchema)) }
219
+ }
220
+ }),
221
+ getAffiliate: defineRoute({
222
+ method: "GET",
223
+ path: "/affiliate",
224
+ summary: "Affiliate account of the signed-in user",
225
+ schemas: { response: { 200: responseDataSchema(z.nullable(affiliateSchema)) } }
226
+ }),
227
+ getAffiliateAccountSession: defineRoute({
228
+ method: "POST",
229
+ path: "/affiliate/account-session",
230
+ summary: "Stripe Connect embedded component session",
231
+ schemas: { response: { 200: responseDataSchema(z.object({ clientSecret: z.string() })) } }
232
+ }),
233
+ getAffiliateOnboardingLink: defineRoute({
234
+ method: "GET",
235
+ path: "/affiliate/onboarding-link",
236
+ summary: "Stripe Connect onboarding link",
237
+ schemas: {
238
+ querystring: z.object({ returnUrl: z.optional(z.string()) }),
239
+ response: { 200: urlResponseSchema }
240
+ }
241
+ }),
242
+ getAffiliateStats: defineRoute({
243
+ method: "GET",
244
+ path: "/affiliate/stats",
245
+ summary: "Referral and commission stats of the signed-in affiliate",
246
+ schemas: { response: { 200: responseDataSchema(z.nullable(affiliateStatsSchema)) } }
247
+ }),
248
+ getAffiliateInvitations: defineRoute({
249
+ method: "GET",
250
+ path: "/affiliate/invitations",
251
+ summary: "Admin only: list affiliate invitations",
252
+ schemas: {
253
+ querystring: searchQuerySchema,
254
+ response: { 200: paginatedResponseSchema(affiliateInvitationSchema) }
255
+ }
256
+ }),
257
+ sendAffiliateInvitation: defineRoute({
258
+ method: "POST",
259
+ path: "/affiliate/invite",
260
+ summary: "Admin only: invite someone to the affiliate program",
261
+ schemas: {
262
+ body: z.object({
263
+ email: z.string(),
264
+ ...affiliateTermsShape
265
+ }),
266
+ response: { 200: responseDataSchema(z.object({ sent: z.boolean() })) }
267
+ }
268
+ }),
269
+ getAffiliateInvitation: defineRoute({
270
+ method: "GET",
271
+ path: "/affiliate/invitation/:token",
272
+ summary: "Invitation details (landing page of the invitation link)",
273
+ schemas: {
274
+ params: tokenParamsSchema,
275
+ response: { 200: responseDataSchema(z.nullable(affiliateInvitationSchema)) }
276
+ }
277
+ }),
278
+ acceptAffiliateInvitation: defineRoute({
279
+ method: "POST",
280
+ path: "/affiliate/invitation/:token/accept",
281
+ summary: "Accept an affiliate invitation",
282
+ schemas: {
283
+ params: tokenParamsSchema,
284
+ body: z.optional(z.object({
285
+ country: z.optional(z.string()),
286
+ stripeAccountType: z.optional(z.enum(["express", "standard"]))
287
+ })),
288
+ response: { 200: affiliateResponseSchema }
289
+ }
290
+ }),
291
+ updateAffiliateStatus: defineRoute({
292
+ method: "PATCH",
293
+ path: "/affiliates/:id/status",
294
+ summary: "Admin only: activate or suspend an affiliate",
295
+ schemas: {
296
+ params: idParamsSchema,
297
+ body: z.object({ status: z.optional(z.enum(["active", "suspended"])) }),
298
+ response: { 200: affiliateResponseSchema }
299
+ }
300
+ }),
301
+ getPromoCodes: defineRoute({
302
+ method: "GET",
303
+ path: "/promo-codes",
304
+ summary: "Admin only: list promo codes",
305
+ schemas: {
306
+ querystring: z.looseObject({
307
+ ...searchQuerySchema.shape,
308
+ affiliateId: z.optional(z.string())
309
+ }),
310
+ response: { 200: paginatedResponseSchema(promoCodeSchema) }
311
+ }
312
+ }),
313
+ getPromoCodeById: defineRoute({
314
+ method: "GET",
315
+ path: "/promo-codes/:id",
316
+ summary: "Admin only: get a promo code",
317
+ schemas: {
318
+ params: idParamsSchema,
319
+ response: { 200: promoCodeResponseSchema }
320
+ }
321
+ }),
322
+ createPromoCode: defineRoute({
323
+ method: "POST",
324
+ path: "/promo-codes",
325
+ summary: "Admin only: create a promo code (and its Stripe coupon)",
326
+ schemas: {
327
+ body: z.object({
328
+ code: z.string().check(z.minLength(1)),
329
+ discountType: z.enum(["percentage", "amount"]),
330
+ discountValue: z.number(),
331
+ currency: z.optional(z.string()),
332
+ affiliateId: z.optional(z.string()),
333
+ maxRedemptions: z.optional(z.number()),
334
+ /** ISO date. */
335
+ expiresAt: z.optional(z.string())
336
+ }),
337
+ response: { 200: promoCodeResponseSchema }
338
+ }
339
+ }),
340
+ updatePromoCode: defineRoute({
341
+ method: "PATCH",
342
+ path: "/promo-codes/:id",
343
+ summary: "Admin only: update a promo code",
344
+ schemas: {
345
+ params: idParamsSchema,
346
+ body: z.object({
347
+ affiliateId: z.optional(z.nullable(z.string())),
348
+ active: z.optional(z.boolean()),
349
+ maxRedemptions: z.optional(z.number()),
350
+ /** ISO date. */
351
+ expiresAt: z.optional(z.string())
352
+ }),
353
+ response: { 200: promoCodeResponseSchema }
354
+ }
355
+ }),
356
+ deletePromoCode: defineRoute({
357
+ method: "DELETE",
358
+ path: "/promo-codes/:id",
359
+ summary: "Admin only: delete a promo code",
360
+ schemas: {
361
+ params: idParamsSchema,
362
+ response: { 200: responseDataSchema(z.object({ deleted: z.boolean() })) }
363
+ }
364
+ }),
365
+ getAffiliatePromoCode: defineRoute({
366
+ method: "GET",
367
+ path: "/affiliate-promo-code/:referralCode",
368
+ summary: "Promo code attached to a referral code (checkout)",
369
+ schemas: {
370
+ params: z.object({ referralCode: z.string().check(z.minLength(1)) }),
371
+ response: { 200: responseDataSchema(z.nullable(promoCodeSchema)) }
372
+ }
373
+ })
374
+ }
375
+ });
376
+
377
+ //#endregion
378
+ export { affiliateInvitationSchema, affiliateSchema, affiliateStatsSchema, commissionTypeSchema, pricingResultSchema, promoCodeSchema, stripeContract, stripeInvoiceSchema, stripePaymentMethodSchema };
379
+ //# sourceMappingURL=stripe.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripe.mjs","names":[],"sources":["../../src/stripe.ts"],"sourcesContent":["import { z } from 'zod/mini';\nimport { dateTimeSchema, objectIdSchema, paginationQueryShape } from './common';\nimport {\n defineRoute,\n defineRouteGroup,\n type RouteBodyInput,\n type RouteQuerystring,\n} from './defineRoute';\nimport { type PlanAPI, planSchema } from './organization';\nimport {\n type PaginatedResponse,\n paginatedResponseSchema,\n type ResponseData,\n responseDataSchema,\n} from './responseData';\n\n// ── Stripe objects (subset of the Stripe API the dashboard reads) ───────────\n\n/** Stripe invoice. */\nexport const stripeInvoiceSchema = z.looseObject({\n id: z.optional(z.string()),\n status: z.nullable(z.string()),\n total: z.number(),\n subtotal: z.number(),\n currency: z.string(),\n /** Epoch seconds. */\n created: z.number(),\n hosted_invoice_url: z.optional(z.nullable(z.string())),\n});\n\n/** Stripe payment method. */\nexport const stripePaymentMethodSchema = z.looseObject({\n id: z.string(),\n type: z.string(),\n card: z.optional(\n z.nullable(\n z.looseObject({\n brand: z.string(),\n last4: z.string(),\n exp_month: z.optional(z.number()),\n exp_year: z.optional(z.number()),\n })\n )\n ),\n});\n\n/** Price of each Stripe price id, after the promo code. */\nexport const pricingResultSchema = z.record(\n z.string(),\n z.object({\n originalTotal: z.number(),\n discountApplied: z.number(),\n discountType: z.nullable(z.enum(['amount', 'percentage'])),\n finalTotal: z.number(),\n currency: z.string(),\n planType: z.enum(['premium', 'enterprise', 'one_time', 'unknown']),\n period: z.enum(['monthly', 'yearly', 'one_time', 'unknown']),\n })\n);\n\n// ── Affiliates ──────────────────────────────────────────────────────────────\n\nexport const commissionTypeSchema = z.enum(['recurring', 'one_time']);\n\n/** Affiliate program member. The Stripe account id is admin information. */\nexport const affiliateSchema = z.looseObject({\n id: z.string(),\n userId: z.string(),\n stripeAccountId: z.optional(z.string()),\n stripeAccountType: z.optional(z.enum(['express', 'standard'])),\n referralCode: z.string(),\n status: z.enum(['pending', 'onboarding', 'active', 'suspended']),\n /** Percentage (20 = 20%). */\n commissionRate: z.number(),\n commissionType: commissionTypeSchema,\n chargesEnabled: z.optional(z.boolean()),\n payoutsEnabled: z.optional(z.boolean()),\n activatedAt: z.optional(dateTimeSchema),\n stripeOnboardingInitiated: z.optional(z.boolean()),\n createdAt: dateTimeSchema,\n updatedAt: dateTimeSchema,\n});\n\nexport const affiliateStatsSchema = z.object({\n affiliate: affiliateSchema,\n totalReferrals: z.number(),\n convertedReferrals: z.number(),\n pendingReferrals: z.number(),\n /** In cents. */\n totalCommissionEarned: z.number(),\n /** In cents. */\n pendingCommission: z.number(),\n referralLink: z.string(),\n});\n\nexport const affiliateInvitationSchema = z.looseObject({\n id: z.string(),\n email: z.string(),\n token: z.string(),\n status: z.enum(['pending', 'accepted', 'expired']),\n invitedBy: z.string(),\n commissionRate: z.number(),\n commissionType: commissionTypeSchema,\n country: z.optional(z.string()),\n expiresAt: dateTimeSchema,\n createdAt: dateTimeSchema,\n updatedAt: dateTimeSchema,\n});\n\n// ── Promo codes ─────────────────────────────────────────────────────────────\n\nexport const promoCodeSchema = z.looseObject({\n id: z.string(),\n code: z.string(),\n stripeCouponId: z.string(),\n stripePromotionCodeId: z.optional(z.string()),\n affiliateId: z.optional(z.string()),\n discountType: z.enum(['percentage', 'amount']),\n discountValue: z.number(),\n currency: z.optional(z.string()),\n maxRedemptions: z.optional(z.number()),\n timesRedeemed: z.number(),\n active: z.boolean(),\n expiresAt: z.optional(dateTimeSchema),\n createdAt: dateTimeSchema,\n updatedAt: dateTimeSchema,\n});\n\nconst idParamsSchema = z.object({ id: objectIdSchema });\nconst tokenParamsSchema = z.object({ token: z.string().check(z.minLength(1)) });\nconst searchQuerySchema = z.looseObject({\n ...paginationQueryShape,\n search: z.optional(z.string()),\n});\nconst affiliateTermsShape = {\n commissionRate: z.optional(z.number()),\n commissionType: z.optional(commissionTypeSchema),\n country: z.optional(z.string()),\n};\nconst affiliateResponseSchema = responseDataSchema(affiliateSchema);\nconst promoCodeResponseSchema = responseDataSchema(promoCodeSchema);\nconst urlResponseSchema = responseDataSchema(z.object({ url: z.string() }));\n\n/** REST contract of the `/api/stripe` routes (billing, affiliates, promo codes). */\nexport const stripeContract = defineRouteGroup({\n prefix: '/api/stripe',\n tag: 'Billing',\n routes: {\n getPricing: defineRoute({\n method: 'POST',\n path: '/pricing',\n summary: 'Prices of the plans, with an optional promo code',\n schemas: {\n body: z.object({\n priceIds: z.optional(z.array(z.string())),\n promoCode: z.optional(z.string()),\n }),\n response: { 200: responseDataSchema(pricingResultSchema) },\n },\n }),\n createSubscription: defineRoute({\n method: 'POST',\n path: '/create-subscription',\n summary: 'Start a subscription checkout for the selected organization',\n schemas: {\n body: z.object({\n priceId: z.string(),\n promoCode: z.optional(z.string()),\n referralCode: z.optional(z.string()),\n }),\n response: {\n 200: responseDataSchema(\n z.looseObject({\n /** Stripe subscription (one-time prices return a payment intent). */\n subscription: z.optional(z.looseObject({ id: z.string() })),\n paymentIntent: z.optional(z.looseObject({ id: z.string() })),\n clientSecret: z.string(),\n })\n ),\n },\n },\n }),\n cancelSubscription: defineRoute({\n method: 'POST',\n path: '/cancel-subscription',\n summary: 'Cancel the subscription of the selected organization',\n schemas: {\n response: { 200: responseDataSchema(z.optional(planSchema)) },\n },\n }),\n getInvoices: defineRoute({\n method: 'GET',\n path: '/invoices',\n summary: 'Invoices of the selected organization',\n schemas: {\n response: { 200: responseDataSchema(z.array(stripeInvoiceSchema)) },\n },\n }),\n getPaymentMethod: defineRoute({\n method: 'GET',\n path: '/payment-method',\n summary: 'Default payment method of the selected organization',\n schemas: {\n response: {\n 200: responseDataSchema(z.nullable(stripePaymentMethodSchema)),\n },\n },\n }),\n createPortalSession: defineRoute({\n method: 'POST',\n path: '/portal-session',\n summary: 'Stripe customer portal URL',\n schemas: { response: { 200: urlResponseSchema } },\n }),\n grantAffiliateAccess: defineRoute({\n method: 'POST',\n path: '/affiliate/grant',\n summary: 'Admin only: make a user an affiliate',\n schemas: {\n body: z.object({ userId: objectIdSchema, ...affiliateTermsShape }),\n response: { 200: affiliateResponseSchema },\n },\n }),\n getAffiliates: defineRoute({\n method: 'GET',\n path: '/affiliates',\n summary: 'Admin only: list affiliates',\n schemas: {\n querystring: searchQuerySchema,\n response: { 200: paginatedResponseSchema(affiliateSchema) },\n },\n }),\n getAffiliateById: defineRoute({\n method: 'GET',\n path: '/affiliates/:id',\n summary: 'Admin only: get an affiliate',\n schemas: {\n params: idParamsSchema,\n response: { 200: responseDataSchema(z.nullable(affiliateSchema)) },\n },\n }),\n getAffiliate: defineRoute({\n method: 'GET',\n path: '/affiliate',\n summary: 'Affiliate account of the signed-in user',\n schemas: {\n response: { 200: responseDataSchema(z.nullable(affiliateSchema)) },\n },\n }),\n getAffiliateAccountSession: defineRoute({\n method: 'POST',\n path: '/affiliate/account-session',\n summary: 'Stripe Connect embedded component session',\n schemas: {\n response: {\n 200: responseDataSchema(z.object({ clientSecret: z.string() })),\n },\n },\n }),\n getAffiliateOnboardingLink: defineRoute({\n method: 'GET',\n path: '/affiliate/onboarding-link',\n summary: 'Stripe Connect onboarding link',\n schemas: {\n querystring: z.object({ returnUrl: z.optional(z.string()) }),\n response: { 200: urlResponseSchema },\n },\n }),\n getAffiliateStats: defineRoute({\n method: 'GET',\n path: '/affiliate/stats',\n summary: 'Referral and commission stats of the signed-in affiliate',\n schemas: {\n response: { 200: responseDataSchema(z.nullable(affiliateStatsSchema)) },\n },\n }),\n getAffiliateInvitations: defineRoute({\n method: 'GET',\n path: '/affiliate/invitations',\n summary: 'Admin only: list affiliate invitations',\n schemas: {\n querystring: searchQuerySchema,\n response: { 200: paginatedResponseSchema(affiliateInvitationSchema) },\n },\n }),\n sendAffiliateInvitation: defineRoute({\n method: 'POST',\n path: '/affiliate/invite',\n summary: 'Admin only: invite someone to the affiliate program',\n schemas: {\n body: z.object({ email: z.string(), ...affiliateTermsShape }),\n response: {\n 200: responseDataSchema(z.object({ sent: z.boolean() })),\n },\n },\n }),\n getAffiliateInvitation: defineRoute({\n method: 'GET',\n path: '/affiliate/invitation/:token',\n summary: 'Invitation details (landing page of the invitation link)',\n schemas: {\n params: tokenParamsSchema,\n response: {\n 200: responseDataSchema(z.nullable(affiliateInvitationSchema)),\n },\n },\n }),\n acceptAffiliateInvitation: defineRoute({\n method: 'POST',\n path: '/affiliate/invitation/:token/accept',\n summary: 'Accept an affiliate invitation',\n schemas: {\n params: tokenParamsSchema,\n body: z.optional(\n z.object({\n country: z.optional(z.string()),\n stripeAccountType: z.optional(z.enum(['express', 'standard'])),\n })\n ),\n response: { 200: affiliateResponseSchema },\n },\n }),\n updateAffiliateStatus: defineRoute({\n method: 'PATCH',\n path: '/affiliates/:id/status',\n summary: 'Admin only: activate or suspend an affiliate',\n schemas: {\n params: idParamsSchema,\n body: z.object({\n status: z.optional(z.enum(['active', 'suspended'])),\n }),\n response: { 200: affiliateResponseSchema },\n },\n }),\n getPromoCodes: defineRoute({\n method: 'GET',\n path: '/promo-codes',\n summary: 'Admin only: list promo codes',\n schemas: {\n querystring: z.looseObject({\n ...searchQuerySchema.shape,\n affiliateId: z.optional(z.string()),\n }),\n response: { 200: paginatedResponseSchema(promoCodeSchema) },\n },\n }),\n getPromoCodeById: defineRoute({\n method: 'GET',\n path: '/promo-codes/:id',\n summary: 'Admin only: get a promo code',\n schemas: {\n params: idParamsSchema,\n response: { 200: promoCodeResponseSchema },\n },\n }),\n createPromoCode: defineRoute({\n method: 'POST',\n path: '/promo-codes',\n summary: 'Admin only: create a promo code (and its Stripe coupon)',\n schemas: {\n body: z.object({\n code: z.string().check(z.minLength(1)),\n discountType: z.enum(['percentage', 'amount']),\n discountValue: z.number(),\n currency: z.optional(z.string()),\n affiliateId: z.optional(z.string()),\n maxRedemptions: z.optional(z.number()),\n /** ISO date. */\n expiresAt: z.optional(z.string()),\n }),\n response: { 200: promoCodeResponseSchema },\n },\n }),\n updatePromoCode: defineRoute({\n method: 'PATCH',\n path: '/promo-codes/:id',\n summary: 'Admin only: update a promo code',\n schemas: {\n params: idParamsSchema,\n body: z.object({\n affiliateId: z.optional(z.nullable(z.string())),\n active: z.optional(z.boolean()),\n maxRedemptions: z.optional(z.number()),\n /** ISO date. */\n expiresAt: z.optional(z.string()),\n }),\n response: { 200: promoCodeResponseSchema },\n },\n }),\n deletePromoCode: defineRoute({\n method: 'DELETE',\n path: '/promo-codes/:id',\n summary: 'Admin only: delete a promo code',\n schemas: {\n params: idParamsSchema,\n response: {\n 200: responseDataSchema(z.object({ deleted: z.boolean() })),\n },\n },\n }),\n getAffiliatePromoCode: defineRoute({\n method: 'GET',\n path: '/affiliate-promo-code/:referralCode',\n summary: 'Promo code attached to a referral code (checkout)',\n schemas: {\n params: z.object({ referralCode: z.string().check(z.minLength(1)) }),\n response: { 200: responseDataSchema(z.nullable(promoCodeSchema)) },\n },\n }),\n },\n});\n\n/** Route definitions of the `/api/stripe` group, by name. */\nexport type StripeRoutes = (typeof stripeContract)['routes'];\n\nexport type StripeInvoice = z.output<typeof stripeInvoiceSchema>;\nexport type StripePaymentMethod = z.output<typeof stripePaymentMethodSchema>;\nexport type PricingResult = z.output<typeof pricingResultSchema>;\nexport type CommissionType = z.output<typeof commissionTypeSchema>;\nexport type AffiliateAPI = z.output<typeof affiliateSchema>;\nexport type AffiliateStats = z.output<typeof affiliateStatsSchema>;\nexport type AffiliateInvitationAPI = z.output<typeof affiliateInvitationSchema>;\nexport type PromoCodeAPI = z.output<typeof promoCodeSchema>;\n\nexport type GetPricingBody = RouteBodyInput<StripeRoutes['getPricing']>;\nexport type GetPricingResult = ResponseData<PricingResult>;\nexport type GetCheckoutSessionBody = RouteBodyInput<\n StripeRoutes['createSubscription']\n>;\nexport type GetCheckoutSessionResult = ResponseData<{\n subscription?: { id: string; [key: string]: unknown };\n paymentIntent?: { id: string; [key: string]: unknown };\n clientSecret: string;\n}>;\nexport type CancelSubscriptionResult = ResponseData<PlanAPI | undefined>;\nexport type GetInvoicesResult = ResponseData<StripeInvoice[]>;\nexport type GetPaymentMethodResult = ResponseData<StripePaymentMethod | null>;\nexport type CreatePortalSessionResult = ResponseData<{ url: string }>;\nexport type GrantAffiliateAccessBody = RouteBodyInput<\n StripeRoutes['grantAffiliateAccess']\n>;\nexport type GrantAffiliateAccessResult = ResponseData<AffiliateAPI>;\nexport type GetAffiliatesParams = RouteQuerystring<\n StripeRoutes['getAffiliates']\n>;\nexport type GetAffiliatesResult = PaginatedResponse<AffiliateAPI>;\nexport type GetAffiliateByIdResult = ResponseData<AffiliateAPI | null>;\nexport type GetAffiliateResult = ResponseData<AffiliateAPI | null>;\nexport type GetAffiliateAccountSessionResult = ResponseData<{\n clientSecret: string;\n}>;\nexport type GetAffiliateOnboardingLinkResult = ResponseData<{ url: string }>;\nexport type GetAffiliateStatsResult = ResponseData<AffiliateStats | null>;\nexport type GetAffiliateInvitationsResult =\n PaginatedResponse<AffiliateInvitationAPI>;\nexport type SendAffiliateInvitationBody = RouteBodyInput<\n StripeRoutes['sendAffiliateInvitation']\n>;\nexport type SendAffiliateInvitationResult = ResponseData<{ sent: boolean }>;\nexport type GetAffiliateInvitationResult =\n ResponseData<AffiliateInvitationAPI | null>;\nexport type UpdateAffiliateStatusBody = RouteBodyInput<\n StripeRoutes['updateAffiliateStatus']\n>;\nexport type UpdateAffiliateStatusResult = ResponseData<AffiliateAPI>;\nexport type AcceptAffiliateInvitationBody = NonNullable<\n RouteBodyInput<StripeRoutes['acceptAffiliateInvitation']>\n>;\nexport type AcceptAffiliateInvitationResult = ResponseData<AffiliateAPI>;\nexport type GetPromoCodesQuerystring = RouteQuerystring<\n StripeRoutes['getPromoCodes']\n>;\nexport type GetPromoCodesResult = PaginatedResponse<PromoCodeAPI>;\nexport type GetPromoCodeByIdResult = ResponseData<PromoCodeAPI>;\nexport type CreatePromoCodeBody = RouteBodyInput<\n StripeRoutes['createPromoCode']\n>;\nexport type CreatePromoCodeResult = ResponseData<PromoCodeAPI>;\nexport type UpdatePromoCodeBody = RouteBodyInput<\n StripeRoutes['updatePromoCode']\n>;\nexport type UpdatePromoCodeResult = ResponseData<PromoCodeAPI>;\nexport type DeletePromoCodeResult = ResponseData<{ deleted: boolean }>;\n"],"mappings":";;;;;;;;AAmBA,MAAa,sBAAsB,EAAE,YAAY;CAC/C,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC;CACzB,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;CAC7B,OAAO,EAAE,OAAO;CAChB,UAAU,EAAE,OAAO;CACnB,UAAU,EAAE,OAAO;;CAEnB,SAAS,EAAE,OAAO;CAClB,oBAAoB,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;;AAGD,MAAa,4BAA4B,EAAE,YAAY;CACrD,IAAI,EAAE,OAAO;CACb,MAAM,EAAE,OAAO;CACf,MAAM,EAAE,SACN,EAAE,SACA,EAAE,YAAY;EACZ,OAAO,EAAE,OAAO;EAChB,OAAO,EAAE,OAAO;EAChB,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC;EAChC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;CACjC,CAAC,CACH,CACF;AACF,CAAC;;A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F,CAAC;EACD,uBAAuB,YAAY;GACjC,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;IACnE,UAAU,EAAE,KAAK,mBAAmB,EAAE,SAAS,eAAe,CAAC,EAAE;GACnE;EACF,CAAC;CACH;AACF,CAAC"}
@@ -0,0 +1,81 @@
1
+ import { defineRoute, defineRouteGroup } from "./defineRoute.mjs";
2
+ import { paginatedResponseSchema, responseDataSchema } from "./responseData.mjs";
3
+ import { dateTimeSchema, objectIdSchema, paginationQueryShape, repeatableQueryValueSchema } from "./common.mjs";
4
+ import { z } from "zod/mini";
5
+
6
+ //#region src/tag.ts
7
+ /** Tag editable fields: ownership (project, organization, creator) is set by the server. */
8
+ const tagFieldsShape = {
9
+ key: z.string().check(z.minLength(1)),
10
+ name: z.optional(z.string()),
11
+ description: z.optional(z.string()),
12
+ instructions: z.optional(z.string())
13
+ };
14
+ /** Tag as returned by the API. */
15
+ const tagSchema = z.looseObject({
16
+ id: z.string(),
17
+ ...tagFieldsShape,
18
+ creatorId: z.string(),
19
+ projectId: z.string(),
20
+ organizationId: z.string(),
21
+ createdAt: dateTimeSchema,
22
+ updatedAt: dateTimeSchema
23
+ });
24
+ const tagIdParamsSchema = z.object({ tagId: objectIdSchema });
25
+ /** REST contract of the `/api/tag` routes. */
26
+ const tagContract = defineRouteGroup({
27
+ prefix: "/api/tag",
28
+ tag: "Tag",
29
+ routes: {
30
+ getTags: defineRoute({
31
+ method: "GET",
32
+ path: "/",
33
+ summary: "List the tags of the selected project",
34
+ schemas: {
35
+ querystring: z.looseObject({
36
+ ...paginationQueryShape,
37
+ ids: z.optional(repeatableQueryValueSchema),
38
+ keys: z.optional(repeatableQueryValueSchema),
39
+ name: z.optional(z.string()),
40
+ search: z.optional(z.string()),
41
+ organizationId: z.optional(z.string()),
42
+ /** Admin only: list tags of every organization. */
43
+ fetchAll: z.optional(z.enum(["true", "false"]))
44
+ }),
45
+ response: { 200: paginatedResponseSchema(tagSchema) }
46
+ }
47
+ }),
48
+ addTag: defineRoute({
49
+ method: "POST",
50
+ path: "/",
51
+ summary: "Create a tag in the selected project",
52
+ schemas: {
53
+ body: z.object(tagFieldsShape),
54
+ response: { 200: responseDataSchema(tagSchema) }
55
+ }
56
+ }),
57
+ updateTag: defineRoute({
58
+ method: "PUT",
59
+ path: "/:tagId",
60
+ summary: "Update a tag",
61
+ schemas: {
62
+ params: tagIdParamsSchema,
63
+ body: z.partial(z.object(tagFieldsShape)),
64
+ response: { 200: responseDataSchema(tagSchema) }
65
+ }
66
+ }),
67
+ deleteTag: defineRoute({
68
+ method: "DELETE",
69
+ path: "/:tagId",
70
+ summary: "Delete a tag",
71
+ schemas: {
72
+ params: tagIdParamsSchema,
73
+ response: { 200: responseDataSchema(tagSchema) }
74
+ }
75
+ })
76
+ }
77
+ });
78
+
79
+ //#endregion
80
+ export { tagContract, tagSchema };
81
+ //# sourceMappingURL=tag.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tag.mjs","names":[],"sources":["../../src/tag.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/** Tag editable fields: ownership (project, organization, creator) is set by the server. */\nconst tagFieldsShape = {\n key: z.string().check(z.minLength(1)),\n name: z.optional(z.string()),\n description: z.optional(z.string()),\n instructions: z.optional(z.string()),\n};\n\n/** Tag as returned by the API. */\nexport const tagSchema = z.looseObject({\n id: z.string(),\n ...tagFieldsShape,\n creatorId: z.string(),\n projectId: z.string(),\n organizationId: z.string(),\n createdAt: dateTimeSchema,\n updatedAt: dateTimeSchema,\n});\n\nconst tagIdParamsSchema = z.object({ tagId: objectIdSchema });\n\n/** REST contract of the `/api/tag` routes. */\nexport const tagContract = defineRouteGroup({\n prefix: '/api/tag',\n tag: 'Tag',\n routes: {\n getTags: defineRoute({\n method: 'GET',\n path: '/',\n summary: 'List the tags of the selected project',\n schemas: {\n querystring: z.looseObject({\n ...paginationQueryShape,\n ids: z.optional(repeatableQueryValueSchema),\n keys: z.optional(repeatableQueryValueSchema),\n name: z.optional(z.string()),\n search: z.optional(z.string()),\n organizationId: z.optional(z.string()),\n /** Admin only: list tags of every organization. */\n fetchAll: z.optional(z.enum(['true', 'false'])),\n }),\n response: { 200: paginatedResponseSchema(tagSchema) },\n },\n }),\n addTag: defineRoute({\n method: 'POST',\n path: '/',\n summary: 'Create a tag in the selected project',\n schemas: {\n body: z.object(tagFieldsShape),\n response: { 200: responseDataSchema(tagSchema) },\n },\n }),\n updateTag: defineRoute({\n method: 'PUT',\n path: '/:tagId',\n summary: 'Update a tag',\n schemas: {\n params: tagIdParamsSchema,\n body: z.partial(z.object(tagFieldsShape)),\n response: { 200: responseDataSchema(tagSchema) },\n },\n }),\n deleteTag: defineRoute({\n method: 'DELETE',\n path: '/:tagId',\n summary: 'Delete a tag',\n schemas: {\n params: tagIdParamsSchema,\n response: { 200: responseDataSchema(tagSchema) },\n },\n }),\n },\n});\n\n/** Route definitions of the `/api/tag` group, by name. */\nexport type TagRoutes = (typeof tagContract)['routes'];\n\nexport type TagAPI = z.output<typeof tagSchema>;\nexport type GetTagsParams = RouteQuerystring<TagRoutes['getTags']>;\nexport type GetTagsResult = PaginatedResponse<TagAPI>;\nexport type AddTagBody = RouteBodyInput<TagRoutes['addTag']>;\nexport type AddTagResult = ResponseData<TagAPI>;\nexport type UpdateTagParams = RouteParams<TagRoutes['updateTag']>;\nexport type UpdateTagBody = RouteBodyInput<TagRoutes['updateTag']>;\nexport type UpdateTagResult = ResponseData<TagAPI>;\nexport type D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AM;GACN,SAAS;GACT,SAAS;IACP,QAAQ;IACR,MAAM,EAAE,QAAQ,EAAE,OAAO,cAAc,CAAC;IACxC,UAAU,EAAE,KAAK,mBAAmB,SAAS,EAAE;GACjD;EACF,CAAC;EACD,WAAW,YAAY;GACrB,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,QAAQ;IACR,UAAU,EAAE,KAAK,mBAAmB,SAAS,EAAE;GACjD;EACF,CAAC;CACH;AACF,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { defineRoute, defineRouteGroup } from "./defineRoute.mjs";
2
+ import { responseDataSchema } from "./responseData.mjs";
3
+ import { typedStringSchema } from "./common.mjs";
4
+ import { z } from "zod/mini";
5
+
6
+ //#region src/translation.ts
7
+ const jobIdParamsSchema = z.object({ jobId: z.string().check(z.minLength(1)) });
8
+ const jobResponseSchema = responseDataSchema(z.unknown());
9
+ /** Job control routes share the same shape. */
10
+ const jobRoute = (path, summary) => defineRoute({
11
+ method: "POST",
12
+ path,
13
+ summary,
14
+ schemas: {
15
+ params: jobIdParamsSchema,
16
+ response: { 200: jobResponseSchema }
17
+ }
18
+ });
19
+ /** REST contract of the live translation routes (Redis-backed queue). */
20
+ const translationContract = defineRouteGroup({
21
+ prefix: "/api/translate",
22
+ tag: "Translation",
23
+ routes: {
24
+ translateDictionaries: defineRoute({
25
+ method: "POST",
26
+ path: "/dictionaries",
27
+ summary: "Queue the translation of dictionaries into locales",
28
+ schemas: {
29
+ body: z.object({
30
+ dictionaryIds: z.array(z.string()),
31
+ targetLocales: z.array(typedStringSchema()),
32
+ mode: z.optional(z.enum(["complete", "review"]))
33
+ }),
34
+ response: { 200: responseDataSchema(z.object({ jobId: z.string() })) }
35
+ }
36
+ }),
37
+ getTranslationStatus: defineRoute({
38
+ method: "GET",
39
+ path: "/status",
40
+ summary: "Translation job progress (server-sent events stream)",
41
+ schemas: {}
42
+ }),
43
+ pauseTranslationJob: jobRoute("/:jobId/pause", "Pause a translation job"),
44
+ resumeTranslationJob: jobRoute("/:jobId/resume", "Resume a paused translation job"),
45
+ stopTranslationJob: jobRoute("/:jobId/stop", "Stop a translation job"),
46
+ retryTranslationJob: jobRoute("/:jobId/retry", "Retry the failed items of a job"),
47
+ restartTranslationJob: jobRoute("/:jobId/restart", "Restart a translation job")
48
+ }
49
+ });
50
+
51
+ //#endregion
52
+ export { translationContract };
53
+ //# sourceMappingURL=translation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation.mjs","names":[],"sources":["../../src/translation.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport { z } from 'zod/mini';\nimport { typedStringSchema } from './common';\nimport {\n defineRoute,\n defineRouteGroup,\n type RouteBodyInput,\n} from './defineRoute';\nimport { type ResponseData, responseDataSchema } from './responseData';\n\nconst jobIdParamsSchema = z.object({ jobId: z.string().check(z.minLength(1)) });\nconst jobResponseSchema = responseDataSchema(z.unknown());\n\n/** Job control routes share the same shape. */\nconst jobRoute = (path: `/:jobId/${string}`, summary: string) =>\n defineRoute({\n method: 'POST',\n path,\n summary,\n schemas: {\n params: jobIdParamsSchema,\n response: { 200: jobResponseSchema },\n },\n });\n\n/** REST contract of the live translation routes (Redis-backed queue). */\nexport const translationContract = defineRouteGroup({\n prefix: '/api/translate',\n tag: 'Translation',\n routes: {\n translateDictionaries: defineRoute({\n method: 'POST',\n path: '/dictionaries',\n summary: 'Queue the translation of dictionaries into locales',\n schemas: {\n body: z.object({\n dictionaryIds: z.array(z.string()),\n targetLocales: z.array(typedStringSchema<Locale>()),\n mode: z.optional(z.enum(['complete', 'review'])),\n }),\n response: {\n 200: responseDataSchema(z.object({ jobId: z.string() })),\n },\n },\n }),\n getTranslationStatus: defineRoute({\n method: 'GET',\n path: '/status',\n summary: 'Translation job progress (server-sent events stream)',\n schemas: {},\n }),\n pauseTranslationJob: jobRoute('/:jobId/pause', 'Pause a translation job'),\n resumeTranslationJob: jobRoute(\n '/:jobId/resume',\n 'Resume a paused translation job'\n ),\n stopTranslationJob: jobRoute('/:jobId/stop', 'Stop a translation job'),\n retryTranslationJob: jobRoute(\n '/:jobId/retry',\n 'Retry the failed items of a job'\n ),\n restartTranslationJob: jobRoute(\n '/:jobId/restart',\n 'Restart a translation job'\n ),\n },\n});\n\n/** Route definitions of the translation group, by name. */\nexport type TranslationRoutes = (typeof translationContract)['routes'];\n\nexport type TranslateDictionariesBody = RouteBodyInput<\n TranslationRoutes['translateDictionaries']\n>;\nexport type TranslateDictionariesResult = ResponseData<{ jobId: string }>;\n"],"mappings":";;;;;;AAUA,MAAM,oBAAoB,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;AAC9E,MAAM,oBAAoB,mBAAmB,EAAE,QAAQ,CAAC;;AAGxD,MAAM,YAAY,MAA2B,YAC3C,YAAY;CACV,QAAQ;CACR;CACA;CACA,SAAS;EACP,QAAQ;EACR,UAAU,EAAE,KAAK,kBAAkB;CACrC;AACF,CAAC;;AAGH,MAAa,sBAAsB,iBAAiB;CAClD,QAAQ;CACR,KAAK;CACL,QAAQ;EACN,uBAAuB,YAAY;GACjC,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS;IACP,MAAM,EAAE,OAAO;KACb,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC;KACjC,eAAe,EAAE,MAAM,kBAA0B,CAAC;KAClD,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,YAAY,QAAQ,CAAC,CAAC;IACjD,CAAC;IACD,UAAU,EACR,KAAK,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,EACzD;GACF;EACF,CAAC;EACD,sBAAsB,YAAY;GAChC,QAAQ;GACR,MAAM;GACN,SAAS;GACT,SAAS,CAAC;EACZ,CAAC;EACD,qBAAqB,SAAS,iBAAiB,yBAAyB;EACxE,sBAAsB,SACpB,kBACA,iCACF;EACA,oBAAoB,SAAS,gBAAgB,wBAAwB;EACrE,qBAAqB,SACnB,iBACA,iCACF;EACA,uBAAuB,SACrB,mBACA,2BACF;CACF;AACF,CAAC"}