@intlayer/api 9.6.0 → 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 (177) hide show
  1. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
  2. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
  3. package/dist/cjs/fetcher.cjs.map +1 -1
  4. package/dist/cjs/getIntlayerAPI/ai.cjs +76 -22
  5. package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
  6. package/dist/cjs/getIntlayerAPI/analytics.cjs +44 -10
  7. package/dist/cjs/getIntlayerAPI/analytics.cjs.map +1 -1
  8. package/dist/cjs/getIntlayerAPI/asset.cjs +38 -8
  9. package/dist/cjs/getIntlayerAPI/asset.cjs.map +1 -1
  10. package/dist/cjs/getIntlayerAPI/audit.cjs +70 -16
  11. package/dist/cjs/getIntlayerAPI/audit.cjs.map +1 -1
  12. package/dist/cjs/getIntlayerAPI/bitbucket.cjs +39 -9
  13. package/dist/cjs/getIntlayerAPI/bitbucket.cjs.map +1 -1
  14. package/dist/cjs/getIntlayerAPI/codeberg.cjs +21 -0
  15. package/dist/cjs/getIntlayerAPI/codeberg.cjs.map +1 -0
  16. package/dist/cjs/getIntlayerAPI/dictionary.cjs +59 -13
  17. package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
  18. package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
  19. package/dist/cjs/getIntlayerAPI/environment.cjs +44 -10
  20. package/dist/cjs/getIntlayerAPI/environment.cjs.map +1 -1
  21. package/dist/cjs/getIntlayerAPI/forge.cjs +64 -0
  22. package/dist/cjs/getIntlayerAPI/forge.cjs.map +1 -0
  23. package/dist/cjs/getIntlayerAPI/gitee.cjs +21 -0
  24. package/dist/cjs/getIntlayerAPI/gitee.cjs.map +1 -0
  25. package/dist/cjs/getIntlayerAPI/github.cjs +44 -10
  26. package/dist/cjs/getIntlayerAPI/github.cjs.map +1 -1
  27. package/dist/cjs/getIntlayerAPI/gitlab.cjs +39 -9
  28. package/dist/cjs/getIntlayerAPI/gitlab.cjs.map +1 -1
  29. package/dist/cjs/getIntlayerAPI/index.cjs +4 -0
  30. package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
  31. package/dist/cjs/getIntlayerAPI/newsletter.cjs +28 -6
  32. package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
  33. package/dist/cjs/getIntlayerAPI/oAuth.cjs +31 -5
  34. package/dist/cjs/getIntlayerAPI/oAuth.cjs.map +1 -1
  35. package/dist/cjs/getIntlayerAPI/organization.cjs +72 -20
  36. package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
  37. package/dist/cjs/getIntlayerAPI/project.cjs +112 -29
  38. package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
  39. package/dist/cjs/getIntlayerAPI/reviewer.cjs +142 -31
  40. package/dist/cjs/getIntlayerAPI/reviewer.cjs.map +1 -1
  41. package/dist/cjs/getIntlayerAPI/search.cjs +15 -3
  42. package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
  43. package/dist/cjs/getIntlayerAPI/showcaseProject.cjs +61 -15
  44. package/dist/cjs/getIntlayerAPI/showcaseProject.cjs.map +1 -1
  45. package/dist/cjs/getIntlayerAPI/status.cjs +16 -3
  46. package/dist/cjs/getIntlayerAPI/status.cjs.map +1 -1
  47. package/dist/cjs/getIntlayerAPI/stripe.cjs +141 -35
  48. package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
  49. package/dist/cjs/getIntlayerAPI/tag.cjs +33 -7
  50. package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
  51. package/dist/cjs/getIntlayerAPI/translate.cjs +46 -8
  52. package/dist/cjs/getIntlayerAPI/translate.cjs.map +1 -1
  53. package/dist/cjs/getIntlayerAPI/user.cjs +58 -14
  54. package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
  55. package/dist/cjs/index.cjs +8 -0
  56. package/dist/cjs/proxy.cjs +4 -0
  57. package/dist/cjs/proxy.cjs.map +1 -1
  58. package/dist/cjs/public/createPublicClient.cjs +25 -5
  59. package/dist/cjs/public/createPublicClient.cjs.map +1 -1
  60. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
  61. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
  62. package/dist/esm/fetcher.mjs.map +1 -1
  63. package/dist/esm/getIntlayerAPI/ai.mjs +76 -22
  64. package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
  65. package/dist/esm/getIntlayerAPI/analytics.mjs +44 -10
  66. package/dist/esm/getIntlayerAPI/analytics.mjs.map +1 -1
  67. package/dist/esm/getIntlayerAPI/asset.mjs +38 -8
  68. package/dist/esm/getIntlayerAPI/asset.mjs.map +1 -1
  69. package/dist/esm/getIntlayerAPI/audit.mjs +70 -16
  70. package/dist/esm/getIntlayerAPI/audit.mjs.map +1 -1
  71. package/dist/esm/getIntlayerAPI/bitbucket.mjs +39 -9
  72. package/dist/esm/getIntlayerAPI/bitbucket.mjs.map +1 -1
  73. package/dist/esm/getIntlayerAPI/codeberg.mjs +19 -0
  74. package/dist/esm/getIntlayerAPI/codeberg.mjs.map +1 -0
  75. package/dist/esm/getIntlayerAPI/dictionary.mjs +59 -13
  76. package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
  77. package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
  78. package/dist/esm/getIntlayerAPI/environment.mjs +44 -10
  79. package/dist/esm/getIntlayerAPI/environment.mjs.map +1 -1
  80. package/dist/esm/getIntlayerAPI/forge.mjs +63 -0
  81. package/dist/esm/getIntlayerAPI/forge.mjs.map +1 -0
  82. package/dist/esm/getIntlayerAPI/gitee.mjs +19 -0
  83. package/dist/esm/getIntlayerAPI/gitee.mjs.map +1 -0
  84. package/dist/esm/getIntlayerAPI/github.mjs +44 -10
  85. package/dist/esm/getIntlayerAPI/github.mjs.map +1 -1
  86. package/dist/esm/getIntlayerAPI/gitlab.mjs +39 -9
  87. package/dist/esm/getIntlayerAPI/gitlab.mjs.map +1 -1
  88. package/dist/esm/getIntlayerAPI/index.mjs +4 -0
  89. package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
  90. package/dist/esm/getIntlayerAPI/newsletter.mjs +28 -6
  91. package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
  92. package/dist/esm/getIntlayerAPI/oAuth.mjs +31 -5
  93. package/dist/esm/getIntlayerAPI/oAuth.mjs.map +1 -1
  94. package/dist/esm/getIntlayerAPI/organization.mjs +72 -20
  95. package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
  96. package/dist/esm/getIntlayerAPI/project.mjs +112 -29
  97. package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
  98. package/dist/esm/getIntlayerAPI/reviewer.mjs +142 -31
  99. package/dist/esm/getIntlayerAPI/reviewer.mjs.map +1 -1
  100. package/dist/esm/getIntlayerAPI/search.mjs +15 -3
  101. package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
  102. package/dist/esm/getIntlayerAPI/showcaseProject.mjs +61 -15
  103. package/dist/esm/getIntlayerAPI/showcaseProject.mjs.map +1 -1
  104. package/dist/esm/getIntlayerAPI/status.mjs +16 -3
  105. package/dist/esm/getIntlayerAPI/status.mjs.map +1 -1
  106. package/dist/esm/getIntlayerAPI/stripe.mjs +141 -35
  107. package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
  108. package/dist/esm/getIntlayerAPI/tag.mjs +33 -7
  109. package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
  110. package/dist/esm/getIntlayerAPI/translate.mjs +46 -8
  111. package/dist/esm/getIntlayerAPI/translate.mjs.map +1 -1
  112. package/dist/esm/getIntlayerAPI/user.mjs +58 -14
  113. package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
  114. package/dist/esm/index.mjs +4 -1
  115. package/dist/esm/proxy.mjs +4 -0
  116. package/dist/esm/proxy.mjs.map +1 -1
  117. package/dist/esm/public/createPublicClient.mjs +25 -5
  118. package/dist/esm/public/createPublicClient.mjs.map +1 -1
  119. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts +1 -1
  120. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +1 -1
  121. package/dist/types/fetcher.d.ts +1 -1
  122. package/dist/types/fetcher.d.ts.map +1 -1
  123. package/dist/types/getIntlayerAPI/ai.d.ts +1 -1
  124. package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
  125. package/dist/types/getIntlayerAPI/analytics.d.ts +1 -1
  126. package/dist/types/getIntlayerAPI/analytics.d.ts.map +1 -1
  127. package/dist/types/getIntlayerAPI/asset.d.ts +1 -0
  128. package/dist/types/getIntlayerAPI/asset.d.ts.map +1 -1
  129. package/dist/types/getIntlayerAPI/audit.d.ts +47 -3
  130. package/dist/types/getIntlayerAPI/audit.d.ts.map +1 -1
  131. package/dist/types/getIntlayerAPI/bitbucket.d.ts.map +1 -1
  132. package/dist/types/getIntlayerAPI/codeberg.d.ts +23 -0
  133. package/dist/types/getIntlayerAPI/codeberg.d.ts.map +1 -0
  134. package/dist/types/getIntlayerAPI/dictionary.d.ts +1 -1
  135. package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
  136. package/dist/types/getIntlayerAPI/editor.d.ts +2 -1
  137. package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
  138. package/dist/types/getIntlayerAPI/environment.d.ts +1 -1
  139. package/dist/types/getIntlayerAPI/environment.d.ts.map +1 -1
  140. package/dist/types/getIntlayerAPI/forge.d.ts +17 -0
  141. package/dist/types/getIntlayerAPI/forge.d.ts.map +1 -0
  142. package/dist/types/getIntlayerAPI/gitee.d.ts +23 -0
  143. package/dist/types/getIntlayerAPI/gitee.d.ts.map +1 -0
  144. package/dist/types/getIntlayerAPI/github.d.ts.map +1 -1
  145. package/dist/types/getIntlayerAPI/gitlab.d.ts.map +1 -1
  146. package/dist/types/getIntlayerAPI/index.d.ts +4 -0
  147. package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
  148. package/dist/types/getIntlayerAPI/newsletter.d.ts +1 -1
  149. package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
  150. package/dist/types/getIntlayerAPI/oAuth.d.ts +2 -0
  151. package/dist/types/getIntlayerAPI/oAuth.d.ts.map +1 -1
  152. package/dist/types/getIntlayerAPI/organization.d.ts +1 -3
  153. package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
  154. package/dist/types/getIntlayerAPI/project.d.ts +2 -1
  155. package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
  156. package/dist/types/getIntlayerAPI/reviewer.d.ts +680 -35
  157. package/dist/types/getIntlayerAPI/reviewer.d.ts.map +1 -1
  158. package/dist/types/getIntlayerAPI/search.d.ts +1 -1
  159. package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
  160. package/dist/types/getIntlayerAPI/showcaseProject.d.ts +1 -1
  161. package/dist/types/getIntlayerAPI/showcaseProject.d.ts.map +1 -1
  162. package/dist/types/getIntlayerAPI/status.d.ts +3 -4
  163. package/dist/types/getIntlayerAPI/status.d.ts.map +1 -1
  164. package/dist/types/getIntlayerAPI/stripe.d.ts +1 -1
  165. package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
  166. package/dist/types/getIntlayerAPI/tag.d.ts +1 -1
  167. package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
  168. package/dist/types/getIntlayerAPI/translate.d.ts +1 -1
  169. package/dist/types/getIntlayerAPI/translate.d.ts.map +1 -1
  170. package/dist/types/getIntlayerAPI/user.d.ts +4 -4
  171. package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
  172. package/dist/types/index.d.ts +7 -4
  173. package/dist/types/proxy.d.ts.map +1 -1
  174. package/dist/types/public/createPublicClient.d.ts +1 -7
  175. package/dist/types/public/createPublicClient.d.ts.map +1 -1
  176. package/dist/types/types.d.ts +5 -2
  177. package/package.json +20 -3
@@ -2,81 +2,187 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_fetcher = require('../fetcher.cjs');
3
3
  const require_cms_createIntlayerCMS = require('../cms/createIntlayerCMS.cjs');
4
4
  let _intlayer_config_built = require("@intlayer/config/built");
5
+ let _intlayer_backend_contract_defineRoute = require("@intlayer/backend-contract/defineRoute");
6
+ let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
5
7
 
6
8
  //#region src/getIntlayerAPI/stripe.ts
9
+ /** Prefix of the routes, checked against the backend contract. */
10
+ const stripeGroup = { prefix: "/api/stripe" };
11
+ /**
12
+ * Method and path of every route, checked against the backend contract at
13
+ * compile time (the contract's zod schemas are never loaded).
14
+ */
15
+ const stripeEndpoints = {
16
+ getPricing: {
17
+ method: "POST",
18
+ path: "/pricing"
19
+ },
20
+ createSubscription: {
21
+ method: "POST",
22
+ path: "/create-subscription"
23
+ },
24
+ cancelSubscription: {
25
+ method: "POST",
26
+ path: "/cancel-subscription"
27
+ },
28
+ getInvoices: {
29
+ method: "GET",
30
+ path: "/invoices"
31
+ },
32
+ getPaymentMethod: {
33
+ method: "GET",
34
+ path: "/payment-method"
35
+ },
36
+ createPortalSession: {
37
+ method: "POST",
38
+ path: "/portal-session"
39
+ },
40
+ grantAffiliateAccess: {
41
+ method: "POST",
42
+ path: "/affiliate/grant"
43
+ },
44
+ getAffiliates: {
45
+ method: "GET",
46
+ path: "/affiliates"
47
+ },
48
+ getAffiliateById: {
49
+ method: "GET",
50
+ path: "/affiliates/:id"
51
+ },
52
+ getAffiliate: {
53
+ method: "GET",
54
+ path: "/affiliate"
55
+ },
56
+ getAffiliateAccountSession: {
57
+ method: "POST",
58
+ path: "/affiliate/account-session"
59
+ },
60
+ getAffiliateOnboardingLink: {
61
+ method: "GET",
62
+ path: "/affiliate/onboarding-link"
63
+ },
64
+ getAffiliateStats: {
65
+ method: "GET",
66
+ path: "/affiliate/stats"
67
+ },
68
+ getAffiliateInvitations: {
69
+ method: "GET",
70
+ path: "/affiliate/invitations"
71
+ },
72
+ sendAffiliateInvitation: {
73
+ method: "POST",
74
+ path: "/affiliate/invite"
75
+ },
76
+ getAffiliateInvitation: {
77
+ method: "GET",
78
+ path: "/affiliate/invitation/:token"
79
+ },
80
+ acceptAffiliateInvitation: {
81
+ method: "POST",
82
+ path: "/affiliate/invitation/:token/accept"
83
+ },
84
+ updateAffiliateStatus: {
85
+ method: "PATCH",
86
+ path: "/affiliates/:id/status"
87
+ },
88
+ getPromoCodes: {
89
+ method: "GET",
90
+ path: "/promo-codes"
91
+ },
92
+ getPromoCodeById: {
93
+ method: "GET",
94
+ path: "/promo-codes/:id"
95
+ },
96
+ createPromoCode: {
97
+ method: "POST",
98
+ path: "/promo-codes"
99
+ },
100
+ updatePromoCode: {
101
+ method: "PATCH",
102
+ path: "/promo-codes/:id"
103
+ },
104
+ deletePromoCode: {
105
+ method: "DELETE",
106
+ path: "/promo-codes/:id"
107
+ },
108
+ getAffiliatePromoCode: {
109
+ method: "GET",
110
+ path: "/affiliate-promo-code/:referralCode"
111
+ }
112
+ };
7
113
  const getStripeAPI = (authAPIOptions = {}, intlayerConfig) => {
8
- const STRIPE_API_ROUTE = `${intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL}/api/stripe`;
114
+ const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL ?? _intlayer_config_defaultValues.BACKEND_URL;
9
115
  /**
10
116
  * Get a pricing plan calculated for a given promotion code.
11
117
  * @param body - Pricing plan body.
12
118
  */
13
- const getPricing = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/pricing`, authAPIOptions, otherOptions, {
14
- method: "POST",
119
+ const getPricing = async (body, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getPricing), authAPIOptions, otherOptions, {
120
+ method: stripeEndpoints.getPricing.method,
15
121
  body
16
122
  });
17
123
  /**
18
124
  * Retrieves a checkout session.
19
125
  * @param body - Checkout session body.
20
126
  */
21
- const getSubscription = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/create-subscription`, authAPIOptions, otherOptions, {
22
- method: "POST",
127
+ const getSubscription = async (body, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.createSubscription), authAPIOptions, otherOptions, {
128
+ method: stripeEndpoints.createSubscription.method,
23
129
  body
24
130
  });
25
131
  /**
26
132
  * Cancels a subscription.
27
133
  * @param body - Checkout session body.
28
134
  */
29
- const cancelSubscription = async (otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/cancel-subscription`, authAPIOptions, otherOptions, { method: "POST" });
135
+ const cancelSubscription = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.cancelSubscription), authAPIOptions, otherOptions, { method: stripeEndpoints.cancelSubscription.method });
30
136
  /**
31
137
  * Lists invoices for the authenticated organization's Stripe customer.
32
138
  */
33
- const getInvoices = async (otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/invoices`, authAPIOptions, otherOptions, { method: "GET" });
139
+ const getInvoices = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getInvoices), authAPIOptions, otherOptions, { method: stripeEndpoints.getInvoices.method });
34
140
  /**
35
141
  * Returns the first card payment method for the authenticated organization's
36
142
  * Stripe customer (or null if none).
37
143
  */
38
- const getPaymentMethod = async (otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/payment-method`, authAPIOptions, otherOptions, { method: "GET" });
144
+ const getPaymentMethod = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getPaymentMethod), authAPIOptions, otherOptions, { method: stripeEndpoints.getPaymentMethod.method });
39
145
  /**
40
146
  * Creates a Stripe Billing Portal session for the authenticated organization.
41
147
  */
42
- const createPortalSession = async (otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/portal-session`, authAPIOptions, otherOptions, { method: "POST" });
148
+ const createPortalSession = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.createPortalSession), authAPIOptions, otherOptions, { method: stripeEndpoints.createPortalSession.method });
43
149
  /**
44
150
  * Admin-only: grants affiliate access to a user by creating their Stripe Connect account.
45
151
  */
46
- const grantAffiliateAccess = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/affiliate/grant`, authAPIOptions, otherOptions, {
47
- method: "POST",
152
+ const grantAffiliateAccess = async (body, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.grantAffiliateAccess), authAPIOptions, otherOptions, {
153
+ method: stripeEndpoints.grantAffiliateAccess.method,
48
154
  body
49
155
  });
50
156
  /**
51
157
  * Admin-only: returns a paginated list of all affiliates.
52
158
  */
53
- const getAffiliates = async (params, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/affiliates`, authAPIOptions, otherOptions, {
54
- method: "GET",
159
+ const getAffiliates = async (params, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getAffiliates), authAPIOptions, otherOptions, {
160
+ method: stripeEndpoints.getAffiliates.method,
55
161
  params
56
162
  });
57
163
  /**
58
164
  * Admin-only: returns a single affiliate by ID.
59
165
  */
60
- const getAffiliateById = async ({ id }, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/affiliates/${id}`, authAPIOptions, otherOptions, { method: "GET" });
166
+ const getAffiliateById = async ({ id }, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getAffiliateById, { id }), authAPIOptions, otherOptions, { method: stripeEndpoints.getAffiliateById.method });
61
167
  /**
62
168
  * Returns the affiliate record for the authenticated user (null if not an affiliate).
63
169
  */
64
- const getAffiliate = async (otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/affiliate`, authAPIOptions, otherOptions, { method: "GET" });
170
+ const getAffiliate = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getAffiliate), authAPIOptions, otherOptions, { method: stripeEndpoints.getAffiliate.method });
65
171
  /**
66
172
  * Creates a Stripe Connect account session for the authenticated affiliate (embedded onboarding).
67
173
  */
68
- const getAffiliateAccountSession = async (otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/affiliate/account-session`, authAPIOptions, otherOptions, { method: "POST" });
174
+ const getAffiliateAccountSession = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getAffiliateAccountSession), authAPIOptions, otherOptions, { method: stripeEndpoints.getAffiliateAccountSession.method });
69
175
  /**
70
176
  * Returns a Stripe-hosted onboarding URL for the authenticated affiliate.
71
177
  */
72
- const getAffiliateOnboardingLink = async (params, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/affiliate/onboarding-link`, authAPIOptions, otherOptions, {
73
- method: "GET",
178
+ const getAffiliateOnboardingLink = async (params, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getAffiliateOnboardingLink), authAPIOptions, otherOptions, {
179
+ method: stripeEndpoints.getAffiliateOnboardingLink.method,
74
180
  params
75
181
  });
76
182
  /**
77
183
  * Returns referral stats for the authenticated affiliate.
78
184
  */
79
- const getAffiliateStats = async (otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/affiliate/stats`, authAPIOptions, otherOptions, { method: "GET" });
185
+ const getAffiliateStats = async (otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getAffiliateStats), authAPIOptions, otherOptions, { method: stripeEndpoints.getAffiliateStats.method });
80
186
  /**
81
187
  * Admin-only: returns a paginated list of all affiliate invitations.
82
188
  */
@@ -86,31 +192,31 @@ const getStripeAPI = (authAPIOptions = {}, intlayerConfig) => {
86
192
  if (params.pageSize) qs.set("pageSize", String(params.pageSize));
87
193
  if (params.search) qs.set("search", params.search);
88
194
  const query = qs.toString() ? `?${qs.toString()}` : "";
89
- return await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/affiliate/invitations${query}`, authAPIOptions, otherOptions, { method: "GET" });
195
+ return await require_fetcher.fetcher(`${(0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getAffiliateInvitations)}${query}`, authAPIOptions, otherOptions, { method: "GET" });
90
196
  };
91
197
  /**
92
198
  * Sends an affiliate invitation email to the given address (admin only).
93
199
  */
94
- const sendAffiliateInvitation = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/affiliate/invite`, authAPIOptions, otherOptions, {
95
- method: "POST",
200
+ const sendAffiliateInvitation = async (body, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.sendAffiliateInvitation), authAPIOptions, otherOptions, {
201
+ method: stripeEndpoints.sendAffiliateInvitation.method,
96
202
  body
97
203
  });
98
204
  /**
99
205
  * Retrieves an affiliate invitation by token (public — no auth required).
100
206
  */
101
- const getAffiliateInvitation = async ({ token }, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/affiliate/invitation/${token}`, authAPIOptions, otherOptions, { method: "GET" });
207
+ const getAffiliateInvitation = async ({ token }, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getAffiliateInvitation, { token }), authAPIOptions, otherOptions, { method: stripeEndpoints.getAffiliateInvitation.method });
102
208
  /**
103
209
  * Admin-only: updates an affiliate's status and/or category.
104
210
  */
105
- const updateAffiliateStatus = async ({ id }, body, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/affiliates/${id}/status`, authAPIOptions, otherOptions, {
106
- method: "PATCH",
211
+ const updateAffiliateStatus = async ({ id }, body, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.updateAffiliateStatus, { id }), authAPIOptions, otherOptions, {
212
+ method: stripeEndpoints.updateAffiliateStatus.method,
107
213
  body
108
214
  });
109
215
  /**
110
216
  * Accepts an affiliate invitation and creates the affiliate account.
111
217
  */
112
- const acceptAffiliateInvitation = async ({ token, country, stripeAccountType }, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/affiliate/invitation/${token}/accept`, authAPIOptions, otherOptions, {
113
- method: "POST",
218
+ const acceptAffiliateInvitation = async ({ token, country, stripeAccountType }, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.acceptAffiliateInvitation, { token }), authAPIOptions, otherOptions, {
219
+ method: stripeEndpoints.acceptAffiliateInvitation.method,
114
220
  body: {
115
221
  country,
116
222
  stripeAccountType
@@ -119,33 +225,33 @@ const getStripeAPI = (authAPIOptions = {}, intlayerConfig) => {
119
225
  /**
120
226
  * Admin-only: returns a paginated list of all promo codes.
121
227
  */
122
- const getPromoCodeById = async (id, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/promo-codes/${id}`, authAPIOptions, otherOptions, { method: "GET" });
228
+ const getPromoCodeById = async (id, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getPromoCodeById, { id }), authAPIOptions, otherOptions, { method: stripeEndpoints.getPromoCodeById.method });
123
229
  const getPromoCodes = async (params = {}, otherOptions = {}) => {
124
230
  const qs = params.affiliateId ? `?affiliateId=${encodeURIComponent(params.affiliateId)}` : "";
125
- return await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/promo-codes${qs}`, authAPIOptions, otherOptions, { method: "GET" });
231
+ return await require_fetcher.fetcher(`${(0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getPromoCodes)}${qs}`, authAPIOptions, otherOptions, { method: "GET" });
126
232
  };
127
233
  /**
128
234
  * Admin-only: creates a new promo code (Stripe coupon + promotion code).
129
235
  */
130
- const createPromoCode = async (body, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/promo-codes`, authAPIOptions, otherOptions, {
131
- method: "POST",
236
+ const createPromoCode = async (body, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.createPromoCode), authAPIOptions, otherOptions, {
237
+ method: stripeEndpoints.createPromoCode.method,
132
238
  body
133
239
  });
134
240
  /**
135
241
  * Admin-only: updates a promo code.
136
242
  */
137
- const updatePromoCode = async ({ id, ...body }, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/promo-codes/${id}`, authAPIOptions, otherOptions, {
138
- method: "PATCH",
243
+ const updatePromoCode = async ({ id, ...body }, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.updatePromoCode, { id }), authAPIOptions, otherOptions, {
244
+ method: stripeEndpoints.updatePromoCode.method,
139
245
  body
140
246
  });
141
247
  /**
142
248
  * Admin-only: deactivates a promo code (sets active=false, disables Stripe promotion code).
143
249
  */
144
- const deletePromoCode = async ({ id }, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/promo-codes/${id}`, authAPIOptions, otherOptions, { method: "DELETE" });
250
+ const deletePromoCode = async ({ id }, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.deletePromoCode, { id }), authAPIOptions, otherOptions, { method: stripeEndpoints.deletePromoCode.method });
145
251
  /**
146
252
  * Retrieves the active promo code associated with a given affiliate referral code.
147
253
  */
148
- const getAffiliatePromoCode = async (referralCode, otherOptions = {}) => await require_fetcher.fetcher(`${STRIPE_API_ROUTE}/affiliate-promo-code/${referralCode}`, authAPIOptions, otherOptions, { method: "GET" });
254
+ const getAffiliatePromoCode = async (referralCode, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, stripeGroup, stripeEndpoints.getAffiliatePromoCode, { referralCode }), authAPIOptions, otherOptions, { method: stripeEndpoints.getAffiliatePromoCode.method });
149
255
  return {
150
256
  getPricing,
151
257
  getSubscription,
@@ -1 +1 @@
1
- {"version":3,"file":"stripe.cjs","names":["editor","fetcher","createEndpoint"],"sources":["../../../src/getIntlayerAPI/stripe.ts"],"sourcesContent":["import type {\n AcceptAffiliateInvitationResult,\n CreatePortalSessionResult,\n CreatePromoCodeBody,\n CreatePromoCodeResult,\n DeletePromoCodeResult,\n GetAffiliateAccountSessionResult,\n GetAffiliateByIdResult,\n GetAffiliateInvitationResult,\n GetAffiliateInvitationsResult,\n GetAffiliateOnboardingLinkResult,\n GetAffiliateResult,\n GetAffiliateStatsResult,\n GetAffiliatesParams,\n GetAffiliatesResult,\n GetCheckoutSessionBody,\n GetCheckoutSessionResult,\n GetInvoicesResult,\n GetPaymentMethodResult,\n GetPricingBody,\n GetPricingResult,\n GetPromoCodeByIdResult,\n GetPromoCodesResult,\n GrantAffiliateAccessBody,\n GrantAffiliateAccessResult,\n SendAffiliateInvitationBody,\n SendAffiliateInvitationResult,\n UpdateAffiliateStatusBody,\n UpdateAffiliateStatusResult,\n UpdatePromoCodeBody,\n UpdatePromoCodeResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getStripeAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const STRIPE_API_ROUTE = `${backendURL}/api/stripe`;\n\n /**\n * Get a pricing plan calculated for a given promotion code.\n * @param body - Pricing plan body.\n */\n const getPricing = async (\n body?: GetPricingBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetPricingResult>(\n `${STRIPE_API_ROUTE}/pricing`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Retrieves a checkout session.\n * @param body - Checkout session body.\n */\n const getSubscription = async (\n body?: GetCheckoutSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/create-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body,\n }\n );\n\n /**\n * Cancels a subscription.\n * @param body - Checkout session body.\n */\n const cancelSubscription = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetCheckoutSessionResult>(\n `${STRIPE_API_ROUTE}/cancel-subscription`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n }\n );\n\n /**\n * Lists invoices for the authenticated organization's Stripe customer.\n */\n const getInvoices = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetInvoicesResult>(\n `${STRIPE_API_ROUTE}/invoices`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Returns the first card payment method for the authenticated organization's\n * Stripe customer (or null if none).\n */\n const getPaymentMethod = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetPaymentMethodResult>(\n `${STRIPE_API_ROUTE}/payment-method`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Creates a Stripe Billing Portal session for the authenticated organization.\n */\n const createPortalSession = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<CreatePortalSessionResult>(\n `${STRIPE_API_ROUTE}/portal-session`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n /**\n * Admin-only: grants affiliate access to a user by creating their Stripe Connect account.\n */\n const grantAffiliateAccess = async (\n body: GrantAffiliateAccessBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GrantAffiliateAccessResult>(\n `${STRIPE_API_ROUTE}/affiliate/grant`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n /**\n * Admin-only: returns a paginated list of all affiliates.\n */\n const getAffiliates = async (\n params?: GetAffiliatesParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliatesResult>(\n `${STRIPE_API_ROUTE}/affiliates`,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params: params as Record<string, string> }\n );\n\n /**\n * Admin-only: returns a single affiliate by ID.\n */\n const getAffiliateById = async (\n { id }: { id: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateByIdResult>(\n `${STRIPE_API_ROUTE}/affiliates/${id}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Returns the affiliate record for the authenticated user (null if not an affiliate).\n */\n const getAffiliate = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetAffiliateResult>(\n `${STRIPE_API_ROUTE}/affiliate`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Creates a Stripe Connect account session for the authenticated affiliate (embedded onboarding).\n */\n const getAffiliateAccountSession = async (\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateAccountSessionResult>(\n `${STRIPE_API_ROUTE}/affiliate/account-session`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n /**\n * Returns a Stripe-hosted onboarding URL for the authenticated affiliate.\n */\n const getAffiliateOnboardingLink = async (\n params?: { returnUrl?: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateOnboardingLinkResult>(\n `${STRIPE_API_ROUTE}/affiliate/onboarding-link`,\n authAPIOptions,\n otherOptions,\n { method: 'GET', params }\n );\n\n /**\n * Returns referral stats for the authenticated affiliate.\n */\n const getAffiliateStats = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetAffiliateStatsResult>(\n `${STRIPE_API_ROUTE}/affiliate/stats`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Admin-only: returns a paginated list of all affiliate invitations.\n */\n const getAffiliateInvitations = async (\n params: GetAffiliatesParams = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const qs = new URLSearchParams();\n if (params.page) qs.set('page', String(params.page));\n if (params.pageSize) qs.set('pageSize', String(params.pageSize));\n if (params.search) qs.set('search', params.search);\n const query = qs.toString() ? `?${qs.toString()}` : '';\n return await fetcher<GetAffiliateInvitationsResult>(\n `${STRIPE_API_ROUTE}/affiliate/invitations${query}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n /**\n * Sends an affiliate invitation email to the given address (admin only).\n */\n const sendAffiliateInvitation = async (\n body: SendAffiliateInvitationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SendAffiliateInvitationResult>(\n `${STRIPE_API_ROUTE}/affiliate/invite`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n /**\n * Retrieves an affiliate invitation by token (public — no auth required).\n */\n const getAffiliateInvitation = async (\n { token }: { token: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateInvitationResult>(\n `${STRIPE_API_ROUTE}/affiliate/invitation/${token}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n /**\n * Admin-only: updates an affiliate's status and/or category.\n */\n const updateAffiliateStatus = async (\n { id }: { id: string },\n body: UpdateAffiliateStatusBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateAffiliateStatusResult>(\n `${STRIPE_API_ROUTE}/affiliates/${id}/status`,\n authAPIOptions,\n otherOptions,\n { method: 'PATCH', body }\n );\n\n /**\n * Accepts an affiliate invitation and creates the affiliate account.\n */\n const acceptAffiliateInvitation = async (\n {\n token,\n country,\n stripeAccountType,\n }: {\n token: string;\n country?: string;\n stripeAccountType?: 'express' | 'standard';\n },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AcceptAffiliateInvitationResult>(\n `${STRIPE_API_ROUTE}/affiliate/invitation/${token}/accept`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body: { country, stripeAccountType } }\n );\n\n /**\n * Admin-only: returns a paginated list of all promo codes.\n */\n const getPromoCodeById = async (\n id: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetPromoCodeByIdResult>(\n `${STRIPE_API_ROUTE}/promo-codes/${id}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n const getPromoCodes = async (\n params: { affiliateId?: string } = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const qs = params.affiliateId\n ? `?affiliateId=${encodeURIComponent(params.affiliateId)}`\n : '';\n return await fetcher<GetPromoCodesResult>(\n `${STRIPE_API_ROUTE}/promo-codes${qs}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n /**\n * Admin-only: creates a new promo code (Stripe coupon + promotion code).\n */\n const createPromoCode = async (\n body: CreatePromoCodeBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreatePromoCodeResult>(\n `${STRIPE_API_ROUTE}/promo-codes`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n /**\n * Admin-only: updates a promo code.\n */\n const updatePromoCode = async (\n { id, ...body }: { id: string } & UpdatePromoCodeBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdatePromoCodeResult>(\n `${STRIPE_API_ROUTE}/promo-codes/${id}`,\n authAPIOptions,\n otherOptions,\n { method: 'PATCH', body }\n );\n\n /**\n * Admin-only: deactivates a promo code (sets active=false, disables Stripe promotion code).\n */\n const deletePromoCode = async (\n { id }: { id: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeletePromoCodeResult>(\n `${STRIPE_API_ROUTE}/promo-codes/${id}`,\n authAPIOptions,\n otherOptions,\n { method: 'DELETE' }\n );\n\n /**\n * Retrieves the active promo code associated with a given affiliate referral code.\n */\n const getAffiliatePromoCode = async (\n referralCode: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<any>(\n `${STRIPE_API_ROUTE}/affiliate-promo-code/${referralCode}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n\n return {\n getPricing,\n getSubscription,\n cancelSubscription,\n getInvoices,\n getPaymentMethod,\n createPortalSession,\n grantAffiliateAccess,\n getAffiliates,\n getAffiliateById,\n getAffiliate,\n getAffiliateAccountSession,\n getAffiliateOnboardingLink,\n getAffiliateStats,\n getAffiliateInvitations,\n sendAffiliateInvitation,\n getAffiliateInvitation,\n acceptAffiliateInvitation,\n updateAffiliateStatus,\n getPromoCodeById,\n getPromoCodes,\n createPromoCode,\n updatePromoCode,\n deletePromoCode,\n getAffiliatePromoCode,\n };\n};\n\n/**\n * Authenticated `stripe` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const stripeEndpoint = createEndpoint(getStripeAPI);\n"],"mappings":";;;;;;AAqCA,MAAa,gBACX,iBAAiC,CAAC,GAClC,mBACG;C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AQ,MAAM,CAClB;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,iBAAiBC,6CAAe,YAAY"}
1
+ {"version":3,"file":"stripe.cjs","names":["editor","BACKEND_URL","fetcher","buildRouteURL","createEndpoint"],"sources":["../../../src/getIntlayerAPI/stripe.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n AcceptAffiliateInvitationResult,\n CreatePortalSessionResult,\n CreatePromoCodeBody,\n CreatePromoCodeResult,\n DeletePromoCodeResult,\n GetAffiliateAccountSessionResult,\n GetAffiliateByIdResult,\n GetAffiliateInvitationResult,\n GetAffiliateInvitationsResult,\n GetAffiliateOnboardingLinkResult,\n GetAffiliateResult,\n GetAffiliateStatsResult,\n GetAffiliatesParams,\n GetAffiliatesResult,\n GetCheckoutSessionBody,\n GetCheckoutSessionResult,\n GetInvoicesResult,\n GetPaymentMethodResult,\n GetPricingBody,\n GetPricingResult,\n GetPromoCodeByIdResult,\n GetPromoCodesResult,\n GrantAffiliateAccessBody,\n GrantAffiliateAccessResult,\n SendAffiliateInvitationBody,\n SendAffiliateInvitationResult,\n StripeRoutes,\n stripeContract,\n UpdateAffiliateStatusBody,\n UpdateAffiliateStatusResult,\n UpdatePromoCodeBody,\n UpdatePromoCodeResult,\n} from '@intlayer/backend-contract/stripe';\nimport { editor } from '@intlayer/config/built';\nimport { BACKEND_URL } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\n/** Prefix of the routes, checked against the backend contract. */\nconst stripeGroup = {\n prefix: '/api/stripe',\n} as const satisfies Pick<typeof stripeContract, 'prefix'>;\n\n/**\n * Method and path of every route, checked against the backend contract at\n * compile time (the contract's zod schemas are never loaded).\n */\nconst stripeEndpoints = {\n getPricing: { method: 'POST', path: '/pricing' },\n createSubscription: { method: 'POST', path: '/create-subscription' },\n cancelSubscription: { method: 'POST', path: '/cancel-subscription' },\n getInvoices: { method: 'GET', path: '/invoices' },\n getPaymentMethod: { method: 'GET', path: '/payment-method' },\n createPortalSession: { method: 'POST', path: '/portal-session' },\n grantAffiliateAccess: { method: 'POST', path: '/affiliate/grant' },\n getAffiliates: { method: 'GET', path: '/affiliates' },\n getAffiliateById: { method: 'GET', path: '/affiliates/:id' },\n getAffiliate: { method: 'GET', path: '/affiliate' },\n getAffiliateAccountSession: {\n method: 'POST',\n path: '/affiliate/account-session',\n },\n getAffiliateOnboardingLink: {\n method: 'GET',\n path: '/affiliate/onboarding-link',\n },\n getAffiliateStats: { method: 'GET', path: '/affiliate/stats' },\n getAffiliateInvitations: { method: 'GET', path: '/affiliate/invitations' },\n sendAffiliateInvitation: { method: 'POST', path: '/affiliate/invite' },\n getAffiliateInvitation: {\n method: 'GET',\n path: '/affiliate/invitation/:token',\n },\n acceptAffiliateInvitation: {\n method: 'POST',\n path: '/affiliate/invitation/:token/accept',\n },\n updateAffiliateStatus: { method: 'PATCH', path: '/affiliates/:id/status' },\n getPromoCodes: { method: 'GET', path: '/promo-codes' },\n getPromoCodeById: { method: 'GET', path: '/promo-codes/:id' },\n createPromoCode: { method: 'POST', path: '/promo-codes' },\n updatePromoCode: { method: 'PATCH', path: '/promo-codes/:id' },\n deletePromoCode: { method: 'DELETE', path: '/promo-codes/:id' },\n getAffiliatePromoCode: {\n method: 'GET',\n path: '/affiliate-promo-code/:referralCode',\n },\n} as const satisfies RouteEndpoints<StripeRoutes>;\n\nexport const getStripeAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n /**\n * Get a pricing plan calculated for a given promotion code.\n * @param body - Pricing plan body.\n */\n const getPricing = async (\n body?: GetPricingBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetPricingResult>(\n buildRouteURL(backendURL, stripeGroup, stripeEndpoints.getPricing),\n authAPIOptions,\n otherOptions,\n {\n method: stripeEndpoints.getPricing.method,\n body,\n }\n );\n\n /**\n * Retrieves a checkout session.\n * @param body - Checkout session body.\n */\n const getSubscription = async (\n body?: GetCheckoutSessionBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetCheckoutSessionResult>(\n buildRouteURL(\n backendURL,\n stripeGroup,\n stripeEndpoints.createSubscription\n ),\n authAPIOptions,\n otherOptions,\n {\n method: stripeEndpoints.createSubscription.method,\n body,\n }\n );\n\n /**\n * Cancels a subscription.\n * @param body - Checkout session body.\n */\n const cancelSubscription = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetCheckoutSessionResult>(\n buildRouteURL(\n backendURL,\n stripeGroup,\n stripeEndpoints.cancelSubscription\n ),\n authAPIOptions,\n otherOptions,\n {\n method: stripeEndpoints.cancelSubscription.method,\n }\n );\n\n /**\n * Lists invoices for the authenticated organization's Stripe customer.\n */\n const getInvoices = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetInvoicesResult>(\n buildRouteURL(backendURL, stripeGroup, stripeEndpoints.getInvoices),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.getInvoices.method }\n );\n\n /**\n * Returns the first card payment method for the authenticated organization's\n * Stripe customer (or null if none).\n */\n const getPaymentMethod = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetPaymentMethodResult>(\n buildRouteURL(backendURL, stripeGroup, stripeEndpoints.getPaymentMethod),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.getPaymentMethod.method }\n );\n\n /**\n * Creates a Stripe Billing Portal session for the authenticated organization.\n */\n const createPortalSession = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<CreatePortalSessionResult>(\n buildRouteURL(\n backendURL,\n stripeGroup,\n stripeEndpoints.createPortalSession\n ),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.createPortalSession.method }\n );\n\n /**\n * Admin-only: grants affiliate access to a user by creating their Stripe Connect account.\n */\n const grantAffiliateAccess = async (\n body: GrantAffiliateAccessBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GrantAffiliateAccessResult>(\n buildRouteURL(\n backendURL,\n stripeGroup,\n stripeEndpoints.grantAffiliateAccess\n ),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.grantAffiliateAccess.method, body }\n );\n\n /**\n * Admin-only: returns a paginated list of all affiliates.\n */\n const getAffiliates = async (\n params?: GetAffiliatesParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliatesResult>(\n buildRouteURL(backendURL, stripeGroup, stripeEndpoints.getAffiliates),\n authAPIOptions,\n otherOptions,\n {\n method: stripeEndpoints.getAffiliates.method,\n params: params as Record<string, string>,\n }\n );\n\n /**\n * Admin-only: returns a single affiliate by ID.\n */\n const getAffiliateById = async (\n { id }: { id: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateByIdResult>(\n buildRouteURL(backendURL, stripeGroup, stripeEndpoints.getAffiliateById, {\n id,\n }),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.getAffiliateById.method }\n );\n\n /**\n * Returns the affiliate record for the authenticated user (null if not an affiliate).\n */\n const getAffiliate = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetAffiliateResult>(\n buildRouteURL(backendURL, stripeGroup, stripeEndpoints.getAffiliate),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.getAffiliate.method }\n );\n\n /**\n * Creates a Stripe Connect account session for the authenticated affiliate (embedded onboarding).\n */\n const getAffiliateAccountSession = async (\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateAccountSessionResult>(\n buildRouteURL(\n backendURL,\n stripeGroup,\n stripeEndpoints.getAffiliateAccountSession\n ),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.getAffiliateAccountSession.method }\n );\n\n /**\n * Returns a Stripe-hosted onboarding URL for the authenticated affiliate.\n */\n const getAffiliateOnboardingLink = async (\n params?: { returnUrl?: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateOnboardingLinkResult>(\n buildRouteURL(\n backendURL,\n stripeGroup,\n stripeEndpoints.getAffiliateOnboardingLink\n ),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.getAffiliateOnboardingLink.method, params }\n );\n\n /**\n * Returns referral stats for the authenticated affiliate.\n */\n const getAffiliateStats = async (otherOptions: FetcherOptions = {}) =>\n await fetcher<GetAffiliateStatsResult>(\n buildRouteURL(backendURL, stripeGroup, stripeEndpoints.getAffiliateStats),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.getAffiliateStats.method }\n );\n\n /**\n * Admin-only: returns a paginated list of all affiliate invitations.\n */\n const getAffiliateInvitations = async (\n params: GetAffiliatesParams = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const qs = new URLSearchParams();\n if (params.page) qs.set('page', String(params.page));\n if (params.pageSize) qs.set('pageSize', String(params.pageSize));\n if (params.search) qs.set('search', params.search);\n const query = qs.toString() ? `?${qs.toString()}` : '';\n return await fetcher<GetAffiliateInvitationsResult>(\n `${buildRouteURL(backendURL, stripeGroup, stripeEndpoints.getAffiliateInvitations)}${query}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n /**\n * Sends an affiliate invitation email to the given address (admin only).\n */\n const sendAffiliateInvitation = async (\n body: SendAffiliateInvitationBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<SendAffiliateInvitationResult>(\n buildRouteURL(\n backendURL,\n stripeGroup,\n stripeEndpoints.sendAffiliateInvitation\n ),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.sendAffiliateInvitation.method, body }\n );\n\n /**\n * Retrieves an affiliate invitation by token (public — no auth required).\n */\n const getAffiliateInvitation = async (\n { token }: { token: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetAffiliateInvitationResult>(\n buildRouteURL(\n backendURL,\n stripeGroup,\n stripeEndpoints.getAffiliateInvitation,\n { token }\n ),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.getAffiliateInvitation.method }\n );\n\n /**\n * Admin-only: updates an affiliate's status and/or category.\n */\n const updateAffiliateStatus = async (\n { id }: { id: string },\n body: UpdateAffiliateStatusBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateAffiliateStatusResult>(\n buildRouteURL(\n backendURL,\n stripeGroup,\n stripeEndpoints.updateAffiliateStatus,\n { id }\n ),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.updateAffiliateStatus.method, body }\n );\n\n /**\n * Accepts an affiliate invitation and creates the affiliate account.\n */\n const acceptAffiliateInvitation = async (\n {\n token,\n country,\n stripeAccountType,\n }: {\n token: string;\n country?: string;\n stripeAccountType?: 'express' | 'standard';\n },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<AcceptAffiliateInvitationResult>(\n buildRouteURL(\n backendURL,\n stripeGroup,\n stripeEndpoints.acceptAffiliateInvitation,\n { token }\n ),\n authAPIOptions,\n otherOptions,\n {\n method: stripeEndpoints.acceptAffiliateInvitation.method,\n body: { country, stripeAccountType },\n }\n );\n\n /**\n * Admin-only: returns a paginated list of all promo codes.\n */\n const getPromoCodeById = async (\n id: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetPromoCodeByIdResult>(\n buildRouteURL(backendURL, stripeGroup, stripeEndpoints.getPromoCodeById, {\n id,\n }),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.getPromoCodeById.method }\n );\n\n const getPromoCodes = async (\n params: { affiliateId?: string } = {},\n otherOptions: FetcherOptions = {}\n ) => {\n const qs = params.affiliateId\n ? `?affiliateId=${encodeURIComponent(params.affiliateId)}`\n : '';\n return await fetcher<GetPromoCodesResult>(\n `${buildRouteURL(backendURL, stripeGroup, stripeEndpoints.getPromoCodes)}${qs}`,\n authAPIOptions,\n otherOptions,\n { method: 'GET' }\n );\n };\n\n /**\n * Admin-only: creates a new promo code (Stripe coupon + promotion code).\n */\n const createPromoCode = async (\n body: CreatePromoCodeBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreatePromoCodeResult>(\n buildRouteURL(backendURL, stripeGroup, stripeEndpoints.createPromoCode),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.createPromoCode.method, body }\n );\n\n /**\n * Admin-only: updates a promo code.\n */\n const updatePromoCode = async (\n { id, ...body }: { id: string } & UpdatePromoCodeBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdatePromoCodeResult>(\n buildRouteURL(backendURL, stripeGroup, stripeEndpoints.updatePromoCode, {\n id,\n }),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.updatePromoCode.method, body }\n );\n\n /**\n * Admin-only: deactivates a promo code (sets active=false, disables Stripe promotion code).\n */\n const deletePromoCode = async (\n { id }: { id: string },\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeletePromoCodeResult>(\n buildRouteURL(backendURL, stripeGroup, stripeEndpoints.deletePromoCode, {\n id,\n }),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.deletePromoCode.method }\n );\n\n /**\n * Retrieves the active promo code associated with a given affiliate referral code.\n */\n const getAffiliatePromoCode = async (\n referralCode: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<any>(\n buildRouteURL(\n backendURL,\n stripeGroup,\n stripeEndpoints.getAffiliatePromoCode,\n { referralCode }\n ),\n authAPIOptions,\n otherOptions,\n { method: stripeEndpoints.getAffiliatePromoCode.method }\n );\n\n return {\n getPricing,\n getSubscription,\n cancelSubscription,\n getInvoices,\n getPaymentMethod,\n createPortalSession,\n grantAffiliateAccess,\n getAffiliates,\n getAffiliateById,\n getAffiliate,\n getAffiliateAccountSession,\n getAffiliateOnboardingLink,\n getAffiliateStats,\n getAffiliateInvitations,\n sendAffiliateInvitation,\n getAffiliateInvitation,\n acceptAffiliateInvitation,\n updateAffiliateStatus,\n getPromoCodeById,\n getPromoCodes,\n createPromoCode,\n updatePromoCode,\n deletePromoCode,\n getAffiliatePromoCode,\n };\n};\n\n/**\n * Authenticated `stripe` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const stripeEndpoint = createEndpoint(getStripeAPI);\n"],"mappings":";;;;;;;;;AA2CA,MAAM,cAAc,EAClB,QAAQ,cACV;;;;;AAMA,MAAM,kBAAkB;CACtB,YAAY;EAAE,QAAQ;EAAQ,MAAM;CAAW;CAC/C,oBAAoB;EAAE,QAAQ;EAAQ,MAAM;CAAuB;CACnE,oBAAoB;EAAE,QAAQ;EAAQ,MAAM;CAAuB;CACnE,aAAa;EAAE,QAAQ;EAAO,MAAM;CAAY;CAChD,kBAAkB;EAAE,QAAQ;EAAO,MAAM;CAAkB;CAC3D,qBAAqB;EAAE,QAAQ;EAAQ,MAAM;CAAkB;CAC/D,sBAAsB;EAAE,QAAQ;EAAQ,MAAM;CAAmB;CACjE,eAAe;EAAE,QAAQ;EAAO,MAAM;CAAc;CACpD,kBAAkB;EAAE,QAAQ;EAAO,MAAM;CAAkB;CAC3D,cAAc;EAAE,QAAQ;EAAO,MAAM;CAAa;CAClD,4BAA4B;EAC1B,QAAQ;EACR,MAAM;CACR;CACA,4BAA4B;EAC1B,QAAQ;EACR,MAAM;CACR;CACA,mBAAmB;EAAE,QAAQ;EAAO,MAAM;CAAmB;CAC7D,yBAAyB;EAAE,QAAQ;EAAO,MAAM;CAAyB;CACzE,yBAAyB;EAAE,QAAQ;EAAQ,MAAM;CAAoB;CACrE,wBAAwB;EACtB,QAAQ;EACR,MAAM;CACR;CACA,2BAA2B;EACzB,QAAQ;EACR,MAAM;CACR;CACA,u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O,CACzD;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,iBAAiBC,6CAAe,YAAY"}
@@ -2,15 +2,41 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_fetcher = require('../fetcher.cjs');
3
3
  const require_cms_createIntlayerCMS = require('../cms/createIntlayerCMS.cjs');
4
4
  let _intlayer_config_built = require("@intlayer/config/built");
5
+ let _intlayer_backend_contract_defineRoute = require("@intlayer/backend-contract/defineRoute");
6
+ let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
5
7
 
6
8
  //#region src/getIntlayerAPI/tag.ts
9
+ /** Prefix of the routes, checked against the backend contract. */
10
+ const tagGroup = { prefix: "/api/tag" };
11
+ /**
12
+ * Method and path of every route, checked against the backend contract at
13
+ * compile time (the contract's zod schemas are never loaded).
14
+ */
15
+ const tagEndpoints = {
16
+ getTags: {
17
+ method: "GET",
18
+ path: "/"
19
+ },
20
+ addTag: {
21
+ method: "POST",
22
+ path: "/"
23
+ },
24
+ updateTag: {
25
+ method: "PUT",
26
+ path: "/:tagId"
27
+ },
28
+ deleteTag: {
29
+ method: "DELETE",
30
+ path: "/:tagId"
31
+ }
32
+ };
7
33
  const getTagAPI = (authAPIOptions = {}, intlayerConfig) => {
8
- const PROJECT_API_ROUTE = `${intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL}/api/tag`;
34
+ const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL ?? _intlayer_config_defaultValues.BACKEND_URL;
9
35
  /**
10
36
  * Retrieves a list of tags based on filters and pagination.
11
37
  * @param filters - Filters and pagination options.
12
38
  */
13
- const getTags = async (filters, otherOptions = {}) => await require_fetcher.fetcher(PROJECT_API_ROUTE, authAPIOptions, otherOptions, {
39
+ const getTags = async (filters, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, tagGroup, tagEndpoints.getTags), authAPIOptions, otherOptions, {
14
40
  cache: "no-store",
15
41
  params: filters
16
42
  });
@@ -18,23 +44,23 @@ const getTagAPI = (authAPIOptions = {}, intlayerConfig) => {
18
44
  * Adds a new tag to the database.
19
45
  * @param tag - Tag data.
20
46
  */
21
- const addTag = async (tag, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}`, authAPIOptions, otherOptions, {
22
- method: "POST",
47
+ const addTag = async (tag, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, tagGroup, tagEndpoints.addTag), authAPIOptions, otherOptions, {
48
+ method: tagEndpoints.addTag.method,
23
49
  body: tag
24
50
  });
25
51
  /**
26
52
  * Updates an existing tag in the database.
27
53
  * @param tag - Updated tag data.
28
54
  */
29
- const updateTag = async (tagId, tag, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/${tagId}`, authAPIOptions, otherOptions, {
30
- method: "PUT",
55
+ const updateTag = async (tagId, tag, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, tagGroup, tagEndpoints.updateTag, { tagId: String(tagId) }), authAPIOptions, otherOptions, {
56
+ method: tagEndpoints.updateTag.method,
31
57
  body: tag
32
58
  });
33
59
  /**
34
60
  * Deletes a tag from the database by its ID.
35
61
  * @param tagId - Tag ID.
36
62
  */
37
- const deleteTag = async (tagId, otherOptions = {}) => await require_fetcher.fetcher(`${PROJECT_API_ROUTE}/${tagId}`, authAPIOptions, otherOptions, { method: "DELETE" });
63
+ const deleteTag = async (tagId, otherOptions = {}) => await require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, tagGroup, tagEndpoints.deleteTag, { tagId: String(tagId) }), authAPIOptions, otherOptions, { method: tagEndpoints.deleteTag.method });
38
64
  return {
39
65
  getTags,
40
66
  addTag,
@@ -1 +1 @@
1
- {"version":3,"file":"tag.cjs","names":["editor","fetcher","createEndpoint"],"sources":["../../../src/getIntlayerAPI/tag.ts"],"sourcesContent":["import type {\n AddTagBody,\n AddTagResult,\n DeleteTagParams,\n DeleteTagResult,\n GetTagsParams,\n GetTagsResult,\n UpdateTagBody,\n UpdateTagParams,\n UpdateTagResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport const getTagAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const PROJECT_API_ROUTE = `${backendURL}/api/tag`;\n\n /**\n * Retrieves a list of tags based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getTags = async (\n filters?: GetTagsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetTagsResult>(\n PROJECT_API_ROUTE,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Adds a new tag to the database.\n * @param tag - Tag data.\n */\n const addTag = async (tag: AddTagBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<AddTagResult>(\n `${PROJECT_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: tag,\n }\n );\n\n /**\n * Updates an existing tag in the database.\n * @param tag - Updated tag data.\n */\n const updateTag = async (\n tagId: UpdateTagParams['tagId'],\n tag: UpdateTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: tag,\n }\n );\n\n /**\n * Deletes a tag from the database by its ID.\n * @param tagId - Tag ID.\n */\n const deleteTag = async (\n tagId: DeleteTagParams['tagId'],\n\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteTagResult>(\n `${PROJECT_API_ROUTE}/${tagId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n return {\n getTags,\n addTag,\n updateTag,\n deleteTag,\n };\n};\n\n/**\n * Authenticated `tag` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const tagEndpoint = createEndpoint(getTagAPI);\n"],"mappings":";;;;;;AAgBA,MAAa,aACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,oBAAoB,GAFP,gBAAgB,QAAQ,cAAcA,8BAAO,WAExB;;;;;CAMxC,MAAM,UAAU,OACd,SACA,eAA+B,CAAC,MAEhC,MAAMC,wBACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;CACV,CACF;;;;;CAMF,MAAM,SAAS,OAAO,KAAiB,eAA+B,CAAC,MACrE,MAAMA,wBACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,YAAY,OAChB,OACA,KACA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;CACR,CACF;;;;;CAMF,MAAM,YAAY,OAChB,OAEA,eAA+B,CAAC,MAEhC,MAAMA,wBACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA,EACE,QAAQ,SACV,CACF;CAEF,OAAO;EACL;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,cAAcC,6CAAe,SAAS"}
1
+ {"version":3,"file":"tag.cjs","names":["editor","BACKEND_URL","fetcher","buildRouteURL","createEndpoint"],"sources":["../../../src/getIntlayerAPI/tag.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n AddTagBody,\n AddTagResult,\n DeleteTagParams,\n DeleteTagResult,\n GetTagsParams,\n GetTagsResult,\n TagRoutes,\n tagContract,\n UpdateTagBody,\n UpdateTagParams,\n UpdateTagResult,\n} from '@intlayer/backend-contract/tag';\nimport { editor } from '@intlayer/config/built';\nimport { BACKEND_URL } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\n/** Prefix of the routes, checked against the backend contract. */\nconst tagGroup = {\n prefix: '/api/tag',\n} as const satisfies Pick<typeof tagContract, 'prefix'>;\n\n/**\n * Method and path of every route, checked against the backend contract at\n * compile time (the contract's zod schemas are never loaded).\n */\nconst tagEndpoints = {\n getTags: { method: 'GET', path: '/' },\n addTag: { method: 'POST', path: '/' },\n updateTag: { method: 'PUT', path: '/:tagId' },\n deleteTag: { method: 'DELETE', path: '/:tagId' },\n} as const satisfies RouteEndpoints<TagRoutes>;\n\nexport const getTagAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n /**\n * Retrieves a list of tags based on filters and pagination.\n * @param filters - Filters and pagination options.\n */\n const getTags = async (\n filters?: GetTagsParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetTagsResult>(\n buildRouteURL(backendURL, tagGroup, tagEndpoints.getTags),\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n // @ts-ignore Number of parameter will be stringified by the fetcher\n params: filters,\n }\n );\n\n /**\n * Adds a new tag to the database.\n * @param tag - Tag data.\n */\n const addTag = async (tag: AddTagBody, otherOptions: FetcherOptions = {}) =>\n await fetcher<AddTagResult>(\n buildRouteURL(backendURL, tagGroup, tagEndpoints.addTag),\n authAPIOptions,\n otherOptions,\n {\n method: tagEndpoints.addTag.method,\n body: tag,\n }\n );\n\n /**\n * Updates an existing tag in the database.\n * @param tag - Updated tag data.\n */\n const updateTag = async (\n tagId: UpdateTagParams['tagId'],\n tag: UpdateTagBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateTagResult>(\n buildRouteURL(backendURL, tagGroup, tagEndpoints.updateTag, {\n tagId: String(tagId),\n }),\n authAPIOptions,\n otherOptions,\n {\n method: tagEndpoints.updateTag.method,\n body: tag,\n }\n );\n\n /**\n * Deletes a tag from the database by its ID.\n * @param tagId - Tag ID.\n */\n const deleteTag = async (\n tagId: DeleteTagParams['tagId'],\n\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<DeleteTagResult>(\n buildRouteURL(backendURL, tagGroup, tagEndpoints.deleteTag, {\n tagId: String(tagId),\n }),\n authAPIOptions,\n otherOptions,\n {\n method: tagEndpoints.deleteTag.method,\n }\n );\n\n return {\n getTags,\n addTag,\n updateTag,\n deleteTag,\n };\n};\n\n/**\n * Authenticated `tag` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const tagEndpoint = createEndpoint(getTagAPI);\n"],"mappings":";;;;;;;;;AAsBA,MAAM,WAAW,EACf,QAAQ,WACV;;;;;AAMA,MAAM,eAAe;CACnB,SAAS;EAAE,QAAQ;EAAO,MAAM;CAAI;CACpC,QAAQ;EAAE,QAAQ;EAAQ,MAAM;CAAI;CACpC,WAAW;EAAE,QAAQ;EAAO,MAAM;CAAU;CAC5C,WAAW;EAAE,QAAQ;EAAU,MAAM;CAAU;AACjD;AAEA,MAAa,aACX,iBAAiC,CAAC,GAClC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,8BAAO,cAAcC;;;;;CAM7D,MAAM,UAAU,OACd,SACA,eAA+B,CAAC,MAEhC,MAAMC,4BACJC,sDAAc,YAAY,UAAU,aAAa,OAAO,GACxD,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;CACV,CACF;;;;;CAMF,MAAM,SAAS,OAAO,KAAiB,eAA+B,CAAC,MACrE,MAAMD,4BACJC,sDAAc,YAAY,UAAU,aAAa,MAAM,GACvD,gBACA,cACA;EACE,QAAQ,aAAa,OAAO;EAC5B,MAAM;CACR,CACF;;;;;CAMF,MAAM,YAAY,OAChB,OACA,KACA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDAAc,YAAY,UAAU,aAAa,WAAW,EAC1D,OAAO,OAAO,KAAK,EACrB,CAAC,GACD,gBACA,cACA;EACE,QAAQ,aAAa,UAAU;EAC/B,MAAM;CACR,CACF;;;;;CAMF,MAAM,YAAY,OAChB,OAEA,eAA+B,CAAC,MAEhC,MAAMD,4BACJC,sDAAc,YAAY,UAAU,aAAa,WAAW,EAC1D,OAAO,OAAO,KAAK,EACrB,CAAC,GACD,gBACA,cACA,EACE,QAAQ,aAAa,UAAU,OACjC,CACF;CAEF,OAAO;EACL;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,cAAcC,6CAAe,SAAS"}
@@ -2,19 +2,57 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_fetcher = require('../fetcher.cjs');
3
3
  const require_cms_createIntlayerCMS = require('../cms/createIntlayerCMS.cjs');
4
4
  let _intlayer_config_built = require("@intlayer/config/built");
5
+ let _intlayer_backend_contract_defineRoute = require("@intlayer/backend-contract/defineRoute");
6
+ let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
5
7
 
6
8
  //#region src/getIntlayerAPI/translate.ts
7
- const getTranslateAPI = (authAPIOptions = {}, intlayerConfig) => {
8
- const TRANSLATE_API_ROUTE = `${intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL}/api/translate`;
9
- const translateDictionaries = async (body, otherOptions = {}) => require_fetcher.fetcher(`${TRANSLATE_API_ROUTE}/dictionaries`, authAPIOptions, otherOptions, {
9
+ /** Prefix of the routes, checked against the backend contract. */
10
+ const translationGroup = { prefix: "/api/translate" };
11
+ /**
12
+ * Method and path of every route, checked against the backend contract at
13
+ * compile time (the contract's zod schemas are never loaded).
14
+ */
15
+ const translationEndpoints = {
16
+ translateDictionaries: {
17
+ method: "POST",
18
+ path: "/dictionaries"
19
+ },
20
+ getTranslationStatus: {
21
+ method: "GET",
22
+ path: "/status"
23
+ },
24
+ pauseTranslationJob: {
25
+ method: "POST",
26
+ path: "/:jobId/pause"
27
+ },
28
+ resumeTranslationJob: {
10
29
  method: "POST",
30
+ path: "/:jobId/resume"
31
+ },
32
+ stopTranslationJob: {
33
+ method: "POST",
34
+ path: "/:jobId/stop"
35
+ },
36
+ retryTranslationJob: {
37
+ method: "POST",
38
+ path: "/:jobId/retry"
39
+ },
40
+ restartTranslationJob: {
41
+ method: "POST",
42
+ path: "/:jobId/restart"
43
+ }
44
+ };
45
+ const getTranslateAPI = (authAPIOptions = {}, intlayerConfig) => {
46
+ const backendURL = intlayerConfig?.editor?.backendURL ?? _intlayer_config_built.editor.backendURL ?? _intlayer_config_defaultValues.BACKEND_URL;
47
+ const translateDictionaries = async (body, otherOptions = {}) => require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, translationGroup, translationEndpoints.translateDictionaries), authAPIOptions, otherOptions, {
48
+ method: translationEndpoints.translateDictionaries.method,
11
49
  body
12
50
  });
13
- const pauseTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/pause`, authAPIOptions, otherOptions, { method: "POST" });
14
- const resumeTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/resume`, authAPIOptions, otherOptions, { method: "POST" });
15
- const stopTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/stop`, authAPIOptions, otherOptions, { method: "POST" });
16
- const retryTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/retry`, authAPIOptions, otherOptions, { method: "POST" });
17
- const restartTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher(`${TRANSLATE_API_ROUTE}/${jobId}/restart`, authAPIOptions, otherOptions, { method: "POST" });
51
+ const pauseTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, translationGroup, translationEndpoints.pauseTranslationJob, { jobId }), authAPIOptions, otherOptions, { method: translationEndpoints.pauseTranslationJob.method });
52
+ const resumeTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, translationGroup, translationEndpoints.resumeTranslationJob, { jobId }), authAPIOptions, otherOptions, { method: translationEndpoints.resumeTranslationJob.method });
53
+ const stopTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, translationGroup, translationEndpoints.stopTranslationJob, { jobId }), authAPIOptions, otherOptions, { method: translationEndpoints.stopTranslationJob.method });
54
+ const retryTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, translationGroup, translationEndpoints.retryTranslationJob, { jobId }), authAPIOptions, otherOptions, { method: translationEndpoints.retryTranslationJob.method });
55
+ const restartTranslationJob = async (jobId, otherOptions = {}) => require_fetcher.fetcher((0, _intlayer_backend_contract_defineRoute.buildRouteURL)(backendURL, translationGroup, translationEndpoints.restartTranslationJob, { jobId }), authAPIOptions, otherOptions, { method: translationEndpoints.restartTranslationJob.method });
18
56
  return {
19
57
  translateDictionaries,
20
58
  pauseTranslationJob,
@@ -1 +1 @@
1
- {"version":3,"file":"translate.cjs","names":["editor","fetcher","createEndpoint"],"sources":["../../../src/getIntlayerAPI/translate.ts"],"sourcesContent":["import type {\n TranslateDictionariesBody,\n TranslateDictionariesResult,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type { TranslateDictionariesBody, TranslateDictionariesResult };\n\nexport const getTranslateAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const TRANSLATE_API_ROUTE = `${backendURL}/api/translate`;\n\n const translateDictionaries = async (\n body: TranslateDictionariesBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<TranslateDictionariesResult>(\n `${TRANSLATE_API_ROUTE}/dictionaries`,\n authAPIOptions,\n otherOptions,\n { method: 'POST', body }\n );\n\n const pauseTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/pause`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const resumeTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/resume`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const stopTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/stop`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const retryTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/retry`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n const restartTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n `${TRANSLATE_API_ROUTE}/${jobId}/restart`,\n authAPIOptions,\n otherOptions,\n { method: 'POST' }\n );\n\n return {\n translateDictionaries,\n pauseTranslationJob,\n resumeTranslationJob,\n stopTranslationJob,\n retryTranslationJob,\n restartTranslationJob,\n };\n};\n\n/**\n * Authenticated `translate` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const translateEndpoint = createEndpoint(getTranslateAPI);\n"],"mappings":";;;;;;AAWA,MAAa,mBACX,iBAAiC,CAAC,GAClC,mBACG;CAGH,MAAM,sBAAsB,GAFT,gBAAgB,QAAQ,cAAcA,8BAAO,WAEtB;CAE1C,MAAM,wBAAwB,OAC5B,MACA,eAA+B,CAAC,MAEhCC,wBACE,GAAG,oBAAoB,gBACvB,gBACA,cACA;EAAE,QAAQ;EAAQ;CAAK,CACzB;CAEF,MAAM,sBAAsB,OAC1B,OACA,eAA+B,CAAC,MAEhCA,wBACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,OAAO,CACnB;CAEF,MAAM,uBAAuB,OAC3B,OACA,eAA+B,CAAC,MAEhCA,wBACE,GAAG,oBAAoB,GAAG,MAAM,UAChC,gBACA,cACA,EAAE,QAAQ,OAAO,CACnB;CAEF,MAAM,qBAAqB,OACzB,OACA,eAA+B,CAAC,MAEhCA,wBACE,GAAG,oBAAoB,GAAG,MAAM,QAChC,gBACA,cACA,EAAE,QAAQ,OAAO,CACnB;CAEF,MAAM,sBAAsB,OAC1B,OACA,eAA+B,CAAC,MAEhCA,wBACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,OAAO,CACnB;CAEF,MAAM,wBAAwB,OAC5B,OACA,eAA+B,CAAC,MAEhCA,wBACE,GAAG,oBAAoB,GAAG,MAAM,WAChC,gBACA,cACA,EAAE,QAAQ,OAAO,CACnB;CAEF,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF;;;;;;;AAQA,MAAa,oBAAoBC,6CAAe,eAAe"}
1
+ {"version":3,"file":"translate.cjs","names":["editor","BACKEND_URL","fetcher","buildRouteURL","createEndpoint"],"sources":["../../../src/getIntlayerAPI/translate.ts"],"sourcesContent":["import type { RouteEndpoints } from '@intlayer/backend-contract/defineRoute';\nimport { buildRouteURL } from '@intlayer/backend-contract/defineRoute';\nimport type {\n TranslateDictionariesBody,\n TranslateDictionariesResult,\n TranslationRoutes,\n translationContract,\n} from '@intlayer/backend-contract/translation';\nimport { editor } from '@intlayer/config/built';\nimport { BACKEND_URL } from '@intlayer/config/defaultValues';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createEndpoint } from '../cms/createIntlayerCMS';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\nexport type { TranslateDictionariesBody, TranslateDictionariesResult };\n\n/** Prefix of the routes, checked against the backend contract. */\nconst translationGroup = {\n prefix: '/api/translate',\n} as const satisfies Pick<typeof translationContract, 'prefix'>;\n\n/**\n * Method and path of every route, checked against the backend contract at\n * compile time (the contract's zod schemas are never loaded).\n */\nconst translationEndpoints = {\n translateDictionaries: { method: 'POST', path: '/dictionaries' },\n getTranslationStatus: { method: 'GET', path: '/status' },\n pauseTranslationJob: { method: 'POST', path: '/:jobId/pause' },\n resumeTranslationJob: { method: 'POST', path: '/:jobId/resume' },\n stopTranslationJob: { method: 'POST', path: '/:jobId/stop' },\n retryTranslationJob: { method: 'POST', path: '/:jobId/retry' },\n restartTranslationJob: { method: 'POST', path: '/:jobId/restart' },\n} as const satisfies RouteEndpoints<TranslationRoutes>;\n\nexport const getTranslateAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL =\n intlayerConfig?.editor?.backendURL ?? editor.backendURL ?? BACKEND_URL;\n\n const translateDictionaries = async (\n body: TranslateDictionariesBody,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<TranslateDictionariesResult>(\n buildRouteURL(\n backendURL,\n translationGroup,\n translationEndpoints.translateDictionaries\n ),\n authAPIOptions,\n otherOptions,\n { method: translationEndpoints.translateDictionaries.method, body }\n );\n\n const pauseTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n buildRouteURL(\n backendURL,\n translationGroup,\n translationEndpoints.pauseTranslationJob,\n { jobId }\n ),\n authAPIOptions,\n otherOptions,\n { method: translationEndpoints.pauseTranslationJob.method }\n );\n\n const resumeTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n buildRouteURL(\n backendURL,\n translationGroup,\n translationEndpoints.resumeTranslationJob,\n { jobId }\n ),\n authAPIOptions,\n otherOptions,\n { method: translationEndpoints.resumeTranslationJob.method }\n );\n\n const stopTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n buildRouteURL(\n backendURL,\n translationGroup,\n translationEndpoints.stopTranslationJob,\n { jobId }\n ),\n authAPIOptions,\n otherOptions,\n { method: translationEndpoints.stopTranslationJob.method }\n );\n\n const retryTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n buildRouteURL(\n backendURL,\n translationGroup,\n translationEndpoints.retryTranslationJob,\n { jobId }\n ),\n authAPIOptions,\n otherOptions,\n { method: translationEndpoints.retryTranslationJob.method }\n );\n\n const restartTranslationJob = async (\n jobId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n fetcher<{ data: { jobId: string } }>(\n buildRouteURL(\n backendURL,\n translationGroup,\n translationEndpoints.restartTranslationJob,\n { jobId }\n ),\n authAPIOptions,\n otherOptions,\n { method: translationEndpoints.restartTranslationJob.method }\n );\n\n return {\n translateDictionaries,\n pauseTranslationJob,\n resumeTranslationJob,\n stopTranslationJob,\n retryTranslationJob,\n restartTranslationJob,\n };\n};\n\n/**\n * Authenticated `translate` endpoint bound to an Intlayer CMS authenticator.\n *\n * Pass an authenticator created with `createIntlayerCMS`, or omit it to use\n * the build-time configuration (`@intlayer/config/built`).\n */\nexport const translateEndpoint = createEndpoint(getTranslateAPI);\n"],"mappings":";;;;;;;;;AAiBA,MAAM,mBAAmB,EACvB,QAAQ,iBACV;;;;;AAMA,MAAM,uBAAuB;CAC3B,uBAAuB;EAAE,QAAQ;EAAQ,MAAM;CAAgB;CAC/D,sBAAsB;EAAE,QAAQ;EAAO,MAAM;CAAU;CACvD,qBAAqB;EAAE,QAAQ;EAAQ,MAAM;CAAgB;CAC7D,sBAAsB;EAAE,QAAQ;EAAQ,MAAM;CAAiB;CAC/D,oBAAoB;EAAE,QAAQ;EAAQ,MAAM;CAAe;CAC3D,qBAAqB;EAAE,QAAQ;EAAQ,MAAM;CAAgB;CAC7D,uBAAuB;EAAE,QAAQ;EAAQ,MAAM;CAAkB;AACnE;AAEA,MAAa,mBACX,iBAAiC,CAAC,GAClC,mBACG;CACH,MAAM,aACJ,gBAAgB,QAAQ,cAAcA,8BAAO,cAAcC;CAE7D,MAAM,wBAAwB,OAC5B,MACA,eAA+B,CAAC,MAEhCC,4BACEC,sDACE,YACA,kBACA,qBAAqB,qBACvB,GACA,gBACA,cACA;EAAE,QAAQ,qBAAqB,sBAAsB;EAAQ;CAAK,CACpE;CAEF,MAAM,sBAAsB,OAC1B,OACA,eAA+B,CAAC,MAEhCD,4BACEC,sDACE,YACA,kBACA,qBAAqB,qBACrB,EAAE,MAAM,CACV,GACA,gBACA,cACA,EAAE,QAAQ,qBAAqB,oBAAoB,OAAO,CAC5D;CAEF,MAAM,uBAAuB,OAC3B,OACA,eAA+B,CAAC,MAEhCD,4BACEC,sDACE,YACA,kBACA,qBAAqB,sBACrB,EAAE,MAAM,CACV,GACA,gBACA,cACA,EAAE,QAAQ,qBAAq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