@intlayer/api 9.0.0-canary.10 → 9.0.0-canary.11

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 (154) hide show
  1. package/dist/cjs/cms/createAuthManager.cjs +116 -0
  2. package/dist/cjs/cms/createAuthManager.cjs.map +1 -0
  3. package/dist/cjs/cms/createIntlayerCMS.cjs +64 -0
  4. package/dist/cjs/cms/createIntlayerCMS.cjs.map +1 -0
  5. package/dist/cjs/cms/index.cjs +7 -0
  6. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +3 -2
  7. package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
  8. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +3 -2
  9. package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
  10. package/dist/cjs/getIntlayerAPI/ai.cjs +9 -0
  11. package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
  12. package/dist/cjs/getIntlayerAPI/asset.cjs +9 -0
  13. package/dist/cjs/getIntlayerAPI/asset.cjs.map +1 -1
  14. package/dist/cjs/getIntlayerAPI/audit.cjs +9 -0
  15. package/dist/cjs/getIntlayerAPI/audit.cjs.map +1 -1
  16. package/dist/cjs/getIntlayerAPI/bitbucket.cjs +9 -0
  17. package/dist/cjs/getIntlayerAPI/bitbucket.cjs.map +1 -1
  18. package/dist/cjs/getIntlayerAPI/dictionary.cjs +9 -0
  19. package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
  20. package/dist/cjs/getIntlayerAPI/editor.cjs +9 -0
  21. package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
  22. package/dist/cjs/getIntlayerAPI/environment.cjs +9 -0
  23. package/dist/cjs/getIntlayerAPI/environment.cjs.map +1 -1
  24. package/dist/cjs/getIntlayerAPI/github.cjs +9 -0
  25. package/dist/cjs/getIntlayerAPI/github.cjs.map +1 -1
  26. package/dist/cjs/getIntlayerAPI/gitlab.cjs +9 -0
  27. package/dist/cjs/getIntlayerAPI/gitlab.cjs.map +1 -1
  28. package/dist/cjs/getIntlayerAPI/index.cjs +1 -1
  29. package/dist/cjs/getIntlayerAPI/newsletter.cjs +9 -0
  30. package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
  31. package/dist/cjs/getIntlayerAPI/organization.cjs +9 -0
  32. package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
  33. package/dist/cjs/getIntlayerAPI/project.cjs +9 -0
  34. package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
  35. package/dist/cjs/getIntlayerAPI/reviewer.cjs +9 -0
  36. package/dist/cjs/getIntlayerAPI/reviewer.cjs.map +1 -1
  37. package/dist/cjs/getIntlayerAPI/search.cjs +9 -0
  38. package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
  39. package/dist/cjs/getIntlayerAPI/showcaseProject.cjs +9 -0
  40. package/dist/cjs/getIntlayerAPI/showcaseProject.cjs.map +1 -1
  41. package/dist/cjs/getIntlayerAPI/stripe.cjs +9 -0
  42. package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
  43. package/dist/cjs/getIntlayerAPI/tag.cjs +9 -0
  44. package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
  45. package/dist/cjs/getIntlayerAPI/translate.cjs +9 -0
  46. package/dist/cjs/getIntlayerAPI/translate.cjs.map +1 -1
  47. package/dist/cjs/getIntlayerAPI/user.cjs +9 -0
  48. package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
  49. package/dist/cjs/index.cjs +27 -3
  50. package/dist/cjs/proxy.cjs +76 -96
  51. package/dist/cjs/proxy.cjs.map +1 -1
  52. package/dist/esm/cms/createAuthManager.mjs +115 -0
  53. package/dist/esm/cms/createAuthManager.mjs.map +1 -0
  54. package/dist/esm/cms/createIntlayerCMS.mjs +62 -0
  55. package/dist/esm/cms/createIntlayerCMS.mjs.map +1 -0
  56. package/dist/esm/cms/index.mjs +4 -0
  57. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +3 -2
  58. package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
  59. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +3 -2
  60. package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
  61. package/dist/esm/getIntlayerAPI/ai.mjs +9 -1
  62. package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
  63. package/dist/esm/getIntlayerAPI/asset.mjs +9 -1
  64. package/dist/esm/getIntlayerAPI/asset.mjs.map +1 -1
  65. package/dist/esm/getIntlayerAPI/audit.mjs +9 -1
  66. package/dist/esm/getIntlayerAPI/audit.mjs.map +1 -1
  67. package/dist/esm/getIntlayerAPI/bitbucket.mjs +9 -1
  68. package/dist/esm/getIntlayerAPI/bitbucket.mjs.map +1 -1
  69. package/dist/esm/getIntlayerAPI/dictionary.mjs +9 -1
  70. package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
  71. package/dist/esm/getIntlayerAPI/editor.mjs +9 -1
  72. package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
  73. package/dist/esm/getIntlayerAPI/environment.mjs +9 -1
  74. package/dist/esm/getIntlayerAPI/environment.mjs.map +1 -1
  75. package/dist/esm/getIntlayerAPI/github.mjs +9 -1
  76. package/dist/esm/getIntlayerAPI/github.mjs.map +1 -1
  77. package/dist/esm/getIntlayerAPI/gitlab.mjs +9 -1
  78. package/dist/esm/getIntlayerAPI/gitlab.mjs.map +1 -1
  79. package/dist/esm/getIntlayerAPI/index.mjs +1 -1
  80. package/dist/esm/getIntlayerAPI/newsletter.mjs +9 -1
  81. package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
  82. package/dist/esm/getIntlayerAPI/organization.mjs +9 -1
  83. package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
  84. package/dist/esm/getIntlayerAPI/project.mjs +9 -1
  85. package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
  86. package/dist/esm/getIntlayerAPI/reviewer.mjs +9 -1
  87. package/dist/esm/getIntlayerAPI/reviewer.mjs.map +1 -1
  88. package/dist/esm/getIntlayerAPI/search.mjs +9 -1
  89. package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
  90. package/dist/esm/getIntlayerAPI/showcaseProject.mjs +9 -1
  91. package/dist/esm/getIntlayerAPI/showcaseProject.mjs.map +1 -1
  92. package/dist/esm/getIntlayerAPI/stripe.mjs +9 -1
  93. package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
  94. package/dist/esm/getIntlayerAPI/tag.mjs +9 -1
  95. package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
  96. package/dist/esm/getIntlayerAPI/translate.mjs +9 -1
  97. package/dist/esm/getIntlayerAPI/translate.mjs.map +1 -1
  98. package/dist/esm/getIntlayerAPI/user.mjs +9 -1
  99. package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
  100. package/dist/esm/index.mjs +23 -21
  101. package/dist/esm/proxy.mjs +76 -96
  102. package/dist/esm/proxy.mjs.map +1 -1
  103. package/dist/types/cms/createAuthManager.d.ts +103 -0
  104. package/dist/types/cms/createAuthManager.d.ts.map +1 -0
  105. package/dist/types/cms/createIntlayerCMS.d.ts +80 -0
  106. package/dist/types/cms/createIntlayerCMS.d.ts.map +1 -0
  107. package/dist/types/cms/index.d.ts +3 -0
  108. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts +1 -1
  109. package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts.map +1 -1
  110. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +1 -1
  111. package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -1
  112. package/dist/types/getIntlayerAPI/ai.d.ts +22 -2
  113. package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
  114. package/dist/types/getIntlayerAPI/asset.d.ts +19 -1
  115. package/dist/types/getIntlayerAPI/asset.d.ts.map +1 -1
  116. package/dist/types/getIntlayerAPI/audit.d.ts +24 -2
  117. package/dist/types/getIntlayerAPI/audit.d.ts.map +1 -1
  118. package/dist/types/getIntlayerAPI/bitbucket.d.ts +15 -1
  119. package/dist/types/getIntlayerAPI/bitbucket.d.ts.map +1 -1
  120. package/dist/types/getIntlayerAPI/dictionary.d.ts +19 -2
  121. package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
  122. package/dist/types/getIntlayerAPI/editor.d.ts +13 -1
  123. package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
  124. package/dist/types/getIntlayerAPI/environment.d.ts +17 -2
  125. package/dist/types/getIntlayerAPI/environment.d.ts.map +1 -1
  126. package/dist/types/getIntlayerAPI/github.d.ts +16 -1
  127. package/dist/types/getIntlayerAPI/github.d.ts.map +1 -1
  128. package/dist/types/getIntlayerAPI/gitlab.d.ts +15 -1
  129. package/dist/types/getIntlayerAPI/gitlab.d.ts.map +1 -1
  130. package/dist/types/getIntlayerAPI/index.d.ts +1 -1
  131. package/dist/types/getIntlayerAPI/newsletter.d.ts +14 -2
  132. package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
  133. package/dist/types/getIntlayerAPI/organization.d.ts +22 -2
  134. package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
  135. package/dist/types/getIntlayerAPI/project.d.ts +29 -2
  136. package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
  137. package/dist/types/getIntlayerAPI/reviewer.d.ts +46 -2
  138. package/dist/types/getIntlayerAPI/reviewer.d.ts.map +1 -1
  139. package/dist/types/getIntlayerAPI/search.d.ts +12 -2
  140. package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
  141. package/dist/types/getIntlayerAPI/showcaseProject.d.ts +23 -2
  142. package/dist/types/getIntlayerAPI/showcaseProject.d.ts.map +1 -1
  143. package/dist/types/getIntlayerAPI/stripe.d.ts +68 -2
  144. package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
  145. package/dist/types/getIntlayerAPI/tag.d.ts +15 -2
  146. package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
  147. package/dist/types/getIntlayerAPI/translate.d.ts +37 -2
  148. package/dist/types/getIntlayerAPI/translate.d.ts.map +1 -1
  149. package/dist/types/getIntlayerAPI/user.d.ts +20 -2
  150. package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
  151. package/dist/types/index.d.ts +23 -21
  152. package/dist/types/proxy.d.ts +11 -9
  153. package/dist/types/proxy.d.ts.map +1 -1
  154. package/package.json +11 -3
@@ -1,4 +1,5 @@
1
1
  import { fetcher } from "../fetcher.mjs";
2
+ import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
2
3
  import { editor } from "@intlayer/config/built";
3
4
 
4
5
  //#region src/getIntlayerAPI/stripe.ts
@@ -169,7 +170,14 @@ const getStripeAPI = (authAPIOptions = {}, intlayerConfig) => {
169
170
  getAffiliatePromoCode
170
171
  };
171
172
  };
173
+ /**
174
+ * Authenticated `stripe` endpoint bound to an Intlayer CMS authenticator.
175
+ *
176
+ * Pass an authenticator created with `createIntlayerCMS`, or omit it to use
177
+ * the build-time configuration (`@intlayer/config/built`).
178
+ */
179
+ const stripeEndpoint = createEndpoint(getStripeAPI);
172
180
 
173
181
  //#endregion
174
- export { getStripeAPI };
182
+ export { getStripeAPI, stripeEndpoint };
175
183
  //# sourceMappingURL=stripe.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"stripe.mjs","names":[],"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 { 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"],"mappings":"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"}
1
+ {"version":3,"file":"stripe.mjs","names":[],"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":"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"}
@@ -1,4 +1,5 @@
1
1
  import { fetcher } from "../fetcher.mjs";
2
+ import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
2
3
  import { editor } from "@intlayer/config/built";
3
4
 
4
5
  //#region src/getIntlayerAPI/tag.ts
@@ -40,7 +41,14 @@ const getTagAPI = (authAPIOptions = {}, intlayerConfig) => {
40
41
  deleteTag
41
42
  };
42
43
  };
44
+ /**
45
+ * Authenticated `tag` endpoint bound to an Intlayer CMS authenticator.
46
+ *
47
+ * Pass an authenticator created with `createIntlayerCMS`, or omit it to use
48
+ * the build-time configuration (`@intlayer/config/built`).
49
+ */
50
+ const tagEndpoint = createEndpoint(getTagAPI);
43
51
 
44
52
  //#endregion
45
- export { getTagAPI };
53
+ export { getTagAPI, tagEndpoint };
46
54
  //# sourceMappingURL=tag.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tag.mjs","names":[],"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 { 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"],"mappings":";;;;AAeA,MAAa,aACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,oBAAoB,GAFP,gBAAgB,QAAQ,cAAc,OAAO,WAExB;;;;;CAMxC,MAAM,UAAU,OACd,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;CAMH,MAAM,SAAS,OAAO,KAAiB,eAA+B,EAAE,KACtE,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,YAAY,OAChB,OACA,KACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,YAAY,OAChB,OAEA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA,EACE,QAAQ,UACT,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"tag.mjs","names":[],"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,EAAE,EACnC,mBACG;CAGH,MAAM,oBAAoB,GAFP,gBAAgB,QAAQ,cAAc,OAAO,WAExB;;;;;CAMxC,MAAM,UAAU,OACd,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,mBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;CAMH,MAAM,SAAS,OAAO,KAAiB,eAA+B,EAAE,KACtE,MAAM,QACJ,GAAG,qBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,YAAY,OAChB,OACA,KACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;CAMH,MAAM,YAAY,OAChB,OAEA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBAAkB,GAAG,SACxB,gBACA,cACA,EACE,QAAQ,UACT,CACF;AAEH,QAAO;EACL;EACA;EACA;EACA;EACD;;;;;;;;AASH,MAAa,cAAc,eAAe,UAAU"}
@@ -1,4 +1,5 @@
1
1
  import { fetcher } from "../fetcher.mjs";
2
+ import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
2
3
  import { editor } from "@intlayer/config/built";
3
4
 
4
5
  //#region src/getIntlayerAPI/translate.ts
@@ -22,7 +23,14 @@ const getTranslateAPI = (authAPIOptions = {}, intlayerConfig) => {
22
23
  restartTranslationJob
23
24
  };
24
25
  };
26
+ /**
27
+ * Authenticated `translate` endpoint bound to an Intlayer CMS authenticator.
28
+ *
29
+ * Pass an authenticator created with `createIntlayerCMS`, or omit it to use
30
+ * the build-time configuration (`@intlayer/config/built`).
31
+ */
32
+ const translateEndpoint = createEndpoint(getTranslateAPI);
25
33
 
26
34
  //#endregion
27
- export { getTranslateAPI };
35
+ export { getTranslateAPI, translateEndpoint };
28
36
  //# sourceMappingURL=translate.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"translate.mjs","names":[],"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 { 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"],"mappings":";;;;AAUA,MAAa,mBACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,sBAAsB,GAFT,gBAAgB,QAAQ,cAAc,OAAO,WAEtB;CAE1C,MAAM,wBAAwB,OAC5B,MACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,gBACvB,gBACA,cACA;EAAE,QAAQ;EAAQ;EAAM,CACzB;CAEH,MAAM,sBAAsB,OAC1B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,uBAAuB,OAC3B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,UAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,qBAAqB,OACzB,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,QAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,sBAAsB,OAC1B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,wBAAwB,OAC5B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,WAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"translate.mjs","names":[],"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,EAAE,EACnC,mBACG;CAGH,MAAM,sBAAsB,GAFT,gBAAgB,QAAQ,cAAc,OAAO,WAEtB;CAE1C,MAAM,wBAAwB,OAC5B,MACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,gBACvB,gBACA,cACA;EAAE,QAAQ;EAAQ;EAAM,CACzB;CAEH,MAAM,sBAAsB,OAC1B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,uBAAuB,OAC3B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,UAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,qBAAqB,OACzB,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,QAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,sBAAsB,OAC1B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,SAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;CAEH,MAAM,wBAAwB,OAC5B,OACA,eAA+B,EAAE,KAEjC,QACE,GAAG,oBAAoB,GAAG,MAAM,WAChC,gBACA,cACA,EAAE,QAAQ,QAAQ,CACnB;AAEH,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACD;;;;;;;;AASH,MAAa,oBAAoB,eAAe,gBAAgB"}
@@ -1,4 +1,5 @@
1
1
  import { fetcher } from "../fetcher.mjs";
2
+ import { createEndpoint } from "../cms/createIntlayerCMS.mjs";
2
3
  import { editor } from "@intlayer/config/built";
3
4
 
4
5
  //#region src/getIntlayerAPI/user.ts
@@ -98,7 +99,14 @@ const getUserAPI = (authAPIOptions = {}, intlayerConfig) => {
98
99
  getVerifyEmailStatusURL
99
100
  };
100
101
  };
102
+ /**
103
+ * Authenticated `user` endpoint bound to an Intlayer CMS authenticator.
104
+ *
105
+ * Pass an authenticator created with `createIntlayerCMS`, or omit it to use
106
+ * the build-time configuration (`@intlayer/config/built`).
107
+ */
108
+ const userEndpoint = createEndpoint(getUserAPI);
101
109
 
102
110
  //#endregion
103
- export { getUserAPI };
111
+ export { getUserAPI, userEndpoint };
104
112
  //# sourceMappingURL=user.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.mjs","names":[],"sources":["../../../src/getIntlayerAPI/user.ts"],"sourcesContent":["import type {\n CreateUserBody,\n CreateUserResult,\n GetUserByEmailParams,\n GetUserByEmailResult,\n GetUserByIdParams,\n GetUserByIdResult,\n GetUsersParams,\n GetUsersResult,\n UpdateUserBody,\n UpdateUserResult,\n UploadUserAvatarResult,\n UserAPI,\n} from '@intlayer/backend';\nimport { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type FetcherOptions, fetcher } from '../fetcher';\n\ntype GetUserByAccountParams = { providerAccountId: string; provider: string };\ntype GetUserByAccountResult = import('@intlayer/backend').ResponseData<UserAPI>;\n\nexport const getUserAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const USER_API_ROUTE = `${backendURL}/api/user`;\n\n /**\n * Retrieves a list of users based on filters and pagination.\n * @param filters - Filters and pagination options.\n * @returns List of users.\n */\n const getUsers = async (\n filters?: GetUsersParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUsersResult>(\n USER_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 * Retrieves a user by ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const getUserById = async (\n userId: GetUserByIdParams['userId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByIdResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by email.\n * @param email - User email.\n * @returns User object.\n */\n const getUserByEmail = async (\n email: GetUserByEmailParams['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByEmailResult>(\n `${USER_API_ROUTE}/email/${email}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by account.\n * @param providerAccountId - The provider account ID.\n * @param provider - The provider of the account.\n */\n const getUserByAccount = async (\n providerAccountId: GetUserByAccountParams['providerAccountId'],\n provider: GetUserByAccountParams['provider'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByAccountResult>(\n `${USER_API_ROUTE}/account/${provider}/${providerAccountId}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Creates a new user.\n * @param user - User credentials.\n * @returns User object.\n */\n const createUser = async (\n user: CreateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateUserResult>(\n `${USER_API_ROUTE}/`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Updates the user with the provided data.\n * @param user - Updated user data.\n * @returns User object.\n */\n const updateUser = async (\n user: UpdateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: user,\n }\n );\n\n /**\n * Deletes a user with the provided ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const deleteUser = async (\n userId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Uploads a new avatar for the authenticated user.\n * @param file - The image File object to upload.\n * @returns Updated user object.\n */\n const uploadAvatar = async (\n file: File,\n otherOptions: FetcherOptions = {}\n ) => {\n const buffer = await file.arrayBuffer();\n\n const baseHeaders: Record<string, string> = {\n 'Content-Type': file.type || 'image/jpeg',\n };\n\n // Forward auth cookies / credentials from authAPIOptions headers\n const authHeaders =\n (authAPIOptions.headers as Record<string, string> | undefined) ?? {};\n\n const response = await fetch(`${USER_API_ROUTE}/avatar`, {\n method: 'POST',\n credentials: 'include',\n headers: { ...authHeaders, ...baseHeaders },\n body: buffer,\n signal: otherOptions.signal as AbortSignal | undefined,\n });\n\n if (!response.ok) {\n const result = await response.json();\n throw new Error(JSON.stringify(result.error) ?? 'Avatar upload failed');\n }\n\n return (await response.json()) as UploadUserAvatarResult;\n };\n\n /**\n * Gets the verify email status URL to use in the SSE.\n * @param userId - User ID.\n * @returns The verify email status URL.\n */\n const getVerifyEmailStatusURL = (userId: string | UserAPI['id']) =>\n `${USER_API_ROUTE}/verify-email-status/${String(userId)}`;\n\n return {\n createUser,\n getUsers,\n getUserById,\n getUserByAccount,\n getUserByEmail,\n updateUser,\n deleteUser,\n uploadAvatar,\n getVerifyEmailStatusURL,\n };\n};\n"],"mappings":";;;;AAqBA,MAAa,cACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,iBAAiB,GAFJ,gBAAgB,QAAQ,cAAc,OAAO,WAE3B;;;;;;CAOrC,MAAM,WAAW,OACf,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,gBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;;CAOH,MAAM,cAAc,OAClB,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,GAAG,UACrB,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,iBAAiB,OACrB,OACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,SAAS,SAC3B,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,mBAAmB,OACvB,mBACA,UACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,WAAW,SAAS,GAAG,qBACzC,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,IAClB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,GAAG,UACrB,gBACA,cACA,EACE,QAAQ,UACT,CACF;;;;;;CAOH,MAAM,eAAe,OACnB,MACA,eAA+B,EAAE,KAC9B;EACH,MAAM,SAAS,MAAM,KAAK,aAAa;EAEvC,MAAM,cAAsC,EAC1C,gBAAgB,KAAK,QAAQ,cAC9B;EAGD,MAAM,cACH,eAAe,WAAkD,EAAE;EAEtE,MAAM,WAAW,MAAM,MAAM,GAAG,eAAe,UAAU;GACvD,QAAQ;GACR,aAAa;GACb,SAAS;IAAE,GAAG;IAAa,GAAG;IAAa;GAC3C,MAAM;GACN,QAAQ,aAAa;GACtB,CAAC;AAEF,MAAI,CAAC,SAAS,IAAI;GAChB,MAAM,SAAS,MAAM,SAAS,MAAM;AACpC,SAAM,IAAI,MAAM,KAAK,UAAU,OAAO,MAAM,IAAI,uBAAuB;;AAGzE,SAAQ,MAAM,SAAS,MAAM;;;;;;;CAQ/B,MAAM,2BAA2B,WAC/B,GAAG,eAAe,uBAAuB,OAAO,OAAO;AAEzD,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"user.mjs","names":[],"sources":["../../../src/getIntlayerAPI/user.ts"],"sourcesContent":["import type {\n CreateUserBody,\n CreateUserResult,\n GetUserByEmailParams,\n GetUserByEmailResult,\n GetUserByIdParams,\n GetUserByIdResult,\n GetUsersParams,\n GetUsersResult,\n UpdateUserBody,\n UpdateUserResult,\n UploadUserAvatarResult,\n UserAPI,\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\ntype GetUserByAccountParams = { providerAccountId: string; provider: string };\ntype GetUserByAccountResult = import('@intlayer/backend').ResponseData<UserAPI>;\n\nexport const getUserAPI = (\n authAPIOptions: FetcherOptions = {},\n intlayerConfig?: IntlayerConfig\n) => {\n const backendURL = intlayerConfig?.editor?.backendURL ?? editor.backendURL;\n\n const USER_API_ROUTE = `${backendURL}/api/user`;\n\n /**\n * Retrieves a list of users based on filters and pagination.\n * @param filters - Filters and pagination options.\n * @returns List of users.\n */\n const getUsers = async (\n filters?: GetUsersParams,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUsersResult>(\n USER_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 * Retrieves a user by ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const getUserById = async (\n userId: GetUserByIdParams['userId'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByIdResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by email.\n * @param email - User email.\n * @returns User object.\n */\n const getUserByEmail = async (\n email: GetUserByEmailParams['email'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByEmailResult>(\n `${USER_API_ROUTE}/email/${email}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Retrieves a user by account.\n * @param providerAccountId - The provider account ID.\n * @param provider - The provider of the account.\n */\n const getUserByAccount = async (\n providerAccountId: GetUserByAccountParams['providerAccountId'],\n provider: GetUserByAccountParams['provider'],\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<GetUserByAccountResult>(\n `${USER_API_ROUTE}/account/${provider}/${providerAccountId}`,\n authAPIOptions,\n otherOptions,\n {\n cache: 'no-store',\n }\n );\n\n /**\n * Creates a new user.\n * @param user - User credentials.\n * @returns User object.\n */\n const createUser = async (\n user: CreateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<CreateUserResult>(\n `${USER_API_ROUTE}/`,\n authAPIOptions,\n otherOptions,\n {\n method: 'POST',\n body: user,\n }\n );\n\n /**\n * Updates the user with the provided data.\n * @param user - Updated user data.\n * @returns User object.\n */\n const updateUser = async (\n user: UpdateUserBody,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'PUT',\n body: user,\n }\n );\n\n /**\n * Deletes a user with the provided ID.\n * @param userId - User ID.\n * @returns User object.\n */\n const deleteUser = async (\n userId: string,\n otherOptions: FetcherOptions = {}\n ) =>\n await fetcher<UpdateUserResult>(\n `${USER_API_ROUTE}/${userId}`,\n authAPIOptions,\n otherOptions,\n {\n method: 'DELETE',\n }\n );\n\n /**\n * Uploads a new avatar for the authenticated user.\n * @param file - The image File object to upload.\n * @returns Updated user object.\n */\n const uploadAvatar = async (\n file: File,\n otherOptions: FetcherOptions = {}\n ) => {\n const buffer = await file.arrayBuffer();\n\n const baseHeaders: Record<string, string> = {\n 'Content-Type': file.type || 'image/jpeg',\n };\n\n // Forward auth cookies / credentials from authAPIOptions headers\n const authHeaders =\n (authAPIOptions.headers as Record<string, string> | undefined) ?? {};\n\n const response = await fetch(`${USER_API_ROUTE}/avatar`, {\n method: 'POST',\n credentials: 'include',\n headers: { ...authHeaders, ...baseHeaders },\n body: buffer,\n signal: otherOptions.signal as AbortSignal | undefined,\n });\n\n if (!response.ok) {\n const result = await response.json();\n throw new Error(JSON.stringify(result.error) ?? 'Avatar upload failed');\n }\n\n return (await response.json()) as UploadUserAvatarResult;\n };\n\n /**\n * Gets the verify email status URL to use in the SSE.\n * @param userId - User ID.\n * @returns The verify email status URL.\n */\n const getVerifyEmailStatusURL = (userId: string | UserAPI['id']) =>\n `${USER_API_ROUTE}/verify-email-status/${String(userId)}`;\n\n return {\n createUser,\n getUsers,\n getUserById,\n getUserByAccount,\n getUserByEmail,\n updateUser,\n deleteUser,\n uploadAvatar,\n getVerifyEmailStatusURL,\n };\n};\n\n/**\n * Authenticated `user` 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 userEndpoint = createEndpoint(getUserAPI);\n"],"mappings":";;;;;AAsBA,MAAa,cACX,iBAAiC,EAAE,EACnC,mBACG;CAGH,MAAM,iBAAiB,GAFJ,gBAAgB,QAAQ,cAAc,OAAO,WAE3B;;;;;;CAOrC,MAAM,WAAW,OACf,SACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,gBACA,gBACA,cACA;EACE,OAAO;EAEP,QAAQ;EACT,CACF;;;;;;CAOH,MAAM,cAAc,OAClB,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,GAAG,UACrB,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,iBAAiB,OACrB,OACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,SAAS,SAC3B,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,mBAAmB,OACvB,mBACA,UACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,WAAW,SAAS,GAAG,qBACzC,gBACA,cACA,EACE,OAAO,YACR,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,IAClB,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,MACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,kBACH,gBACA,cACA;EACE,QAAQ;EACR,MAAM;EACP,CACF;;;;;;CAOH,MAAM,aAAa,OACjB,QACA,eAA+B,EAAE,KAEjC,MAAM,QACJ,GAAG,eAAe,GAAG,UACrB,gBACA,cACA,EACE,QAAQ,UACT,CACF;;;;;;CAOH,MAAM,eAAe,OACnB,MACA,eAA+B,EAAE,KAC9B;EACH,MAAM,SAAS,MAAM,KAAK,aAAa;EAEvC,MAAM,cAAsC,EAC1C,gBAAgB,KAAK,QAAQ,cAC9B;EAGD,MAAM,cACH,eAAe,WAAkD,EAAE;EAEtE,MAAM,WAAW,MAAM,MAAM,GAAG,eAAe,UAAU;GACvD,QAAQ;GACR,aAAa;GACb,SAAS;IAAE,GAAG;IAAa,GAAG;IAAa;GAC3C,MAAM;GACN,QAAQ,aAAa;GACtB,CAAC;AAEF,MAAI,CAAC,SAAS,IAAI;GAChB,MAAM,SAAS,MAAM,SAAS,MAAM;AACpC,SAAM,IAAI,MAAM,KAAK,UAAU,OAAO,MAAM,IAAI,uBAAuB;;AAGzE,SAAQ,MAAM,SAAS,MAAM;;;;;;;CAQ/B,MAAM,2BAA2B,WAC/B,GAAG,eAAe,uBAAuB,OAAO,OAAO;AAEzD,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;;;;;;;;AASH,MAAa,eAAe,eAAe,WAAW"}
@@ -1,27 +1,29 @@
1
1
  import { fetcher, fetcherOptions } from "./fetcher.mjs";
2
- import { getAiAPI } from "./getIntlayerAPI/ai.mjs";
3
- import { getAssetAPI } from "./getIntlayerAPI/asset.mjs";
4
- import { getAuditAPI } from "./getIntlayerAPI/audit.mjs";
5
- import { getBitbucketAPI } from "./getIntlayerAPI/bitbucket.mjs";
6
- import { getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
7
- import { getEditorAPI } from "./getIntlayerAPI/editor.mjs";
8
- import { getEnvironmentAPI } from "./getIntlayerAPI/environment.mjs";
9
- import { getGithubAPI } from "./getIntlayerAPI/github.mjs";
10
- import { getGitlabAPI } from "./getIntlayerAPI/gitlab.mjs";
11
- import { getNewsletterAPI } from "./getIntlayerAPI/newsletter.mjs";
12
2
  import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
13
- import { getOrganizationAPI } from "./getIntlayerAPI/organization.mjs";
14
- import { getProjectAPI } from "./getIntlayerAPI/project.mjs";
15
- import { getReviewerAPI } from "./getIntlayerAPI/reviewer.mjs";
16
- import { getSearchAPI } from "./getIntlayerAPI/search.mjs";
17
- import { getShowcaseProjectAPI } from "./getIntlayerAPI/showcaseProject.mjs";
18
- import { getStripeAPI } from "./getIntlayerAPI/stripe.mjs";
19
- import { getTagAPI } from "./getIntlayerAPI/tag.mjs";
20
- import { getTranslateAPI } from "./getIntlayerAPI/translate.mjs";
21
- import { getUserAPI } from "./getIntlayerAPI/user.mjs";
22
- import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
3
+ import { createAuthManager } from "./cms/createAuthManager.mjs";
4
+ import { createEndpoint, createIntlayerCMS } from "./cms/createIntlayerCMS.mjs";
5
+ import { aiEndpoint, getAiAPI } from "./getIntlayerAPI/ai.mjs";
6
+ import { assetEndpoint, getAssetAPI } from "./getIntlayerAPI/asset.mjs";
7
+ import { auditEndpoint, getAuditAPI } from "./getIntlayerAPI/audit.mjs";
8
+ import { bitbucketEndpoint, getBitbucketAPI } from "./getIntlayerAPI/bitbucket.mjs";
9
+ import { dictionaryEndpoint, getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
10
+ import { editorEndpoint, getEditorAPI } from "./getIntlayerAPI/editor.mjs";
11
+ import { environmentEndpoint, getEnvironmentAPI } from "./getIntlayerAPI/environment.mjs";
12
+ import { getGithubAPI, githubEndpoint } from "./getIntlayerAPI/github.mjs";
13
+ import { getGitlabAPI, gitlabEndpoint } from "./getIntlayerAPI/gitlab.mjs";
14
+ import { getNewsletterAPI, newsletterEndpoint } from "./getIntlayerAPI/newsletter.mjs";
15
+ import { getOrganizationAPI, organizationEndpoint } from "./getIntlayerAPI/organization.mjs";
16
+ import { getProjectAPI, projectEndpoint } from "./getIntlayerAPI/project.mjs";
17
+ import { getReviewerAPI, reviewerEndpoint } from "./getIntlayerAPI/reviewer.mjs";
18
+ import { getSearchAPI, searchEndpoint } from "./getIntlayerAPI/search.mjs";
19
+ import { getShowcaseProjectAPI, showcaseProjectEndpoint } from "./getIntlayerAPI/showcaseProject.mjs";
20
+ import { getStripeAPI, stripeEndpoint } from "./getIntlayerAPI/stripe.mjs";
21
+ import { getTagAPI, tagEndpoint } from "./getIntlayerAPI/tag.mjs";
22
+ import { getTranslateAPI, translateEndpoint } from "./getIntlayerAPI/translate.mjs";
23
+ import { getUserAPI, userEndpoint } from "./getIntlayerAPI/user.mjs";
23
24
  import { getIntlayerAPIProxy } from "./proxy.mjs";
24
25
  import { fetchDistantDictionaries } from "./distantDictionary/fetchDistantDictionaries.mjs";
25
26
  import { fetchDistantDictionary } from "./distantDictionary/fetchDistantDictionary.mjs";
27
+ import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
26
28
 
27
- export { fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAssetAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getEnvironmentAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getReviewerAPI, getSearchAPI, getShowcaseProjectAPI, getStripeAPI, getTagAPI, getTranslateAPI, getUserAPI };
29
+ export { aiEndpoint, assetEndpoint, auditEndpoint, bitbucketEndpoint, createAuthManager, createEndpoint, createIntlayerCMS, dictionaryEndpoint, editorEndpoint, environmentEndpoint, fetchDistantDictionaries, fetchDistantDictionary, fetcher, fetcherOptions, getAiAPI, getAssetAPI, getAuditAPI, getBitbucketAPI, getDictionaryAPI, getEditorAPI, getEnvironmentAPI, getGithubAPI, getGitlabAPI, getIntlayerAPI, getIntlayerAPIProxy, getNewsletterAPI, getOAuthAPI, getOrganizationAPI, getProjectAPI, getReviewerAPI, getSearchAPI, getShowcaseProjectAPI, getStripeAPI, getTagAPI, getTranslateAPI, getUserAPI, githubEndpoint, gitlabEndpoint, newsletterEndpoint, organizationEndpoint, projectEndpoint, reviewerEndpoint, searchEndpoint, showcaseProjectEndpoint, stripeEndpoint, tagEndpoint, translateEndpoint, userEndpoint };
@@ -1,110 +1,90 @@
1
1
  import { getOAuthAPI } from "./getIntlayerAPI/oAuth.mjs";
2
- import { getIntlayerAPI } from "./getIntlayerAPI/index.mjs";
2
+ import { createIntlayerCMS } from "./cms/createIntlayerCMS.mjs";
3
+ import { getAiAPI } from "./getIntlayerAPI/ai.mjs";
4
+ import { getAssetAPI } from "./getIntlayerAPI/asset.mjs";
5
+ import { getAuditAPI } from "./getIntlayerAPI/audit.mjs";
6
+ import { getBitbucketAPI } from "./getIntlayerAPI/bitbucket.mjs";
7
+ import { getDictionaryAPI } from "./getIntlayerAPI/dictionary.mjs";
8
+ import { getEditorAPI } from "./getIntlayerAPI/editor.mjs";
9
+ import { getEnvironmentAPI } from "./getIntlayerAPI/environment.mjs";
10
+ import { getGithubAPI } from "./getIntlayerAPI/github.mjs";
11
+ import { getGitlabAPI } from "./getIntlayerAPI/gitlab.mjs";
12
+ import { getNewsletterAPI } from "./getIntlayerAPI/newsletter.mjs";
13
+ import { getOrganizationAPI } from "./getIntlayerAPI/organization.mjs";
14
+ import { getProjectAPI } from "./getIntlayerAPI/project.mjs";
15
+ import { getReviewerAPI } from "./getIntlayerAPI/reviewer.mjs";
16
+ import { getSearchAPI } from "./getIntlayerAPI/search.mjs";
17
+ import { getShowcaseProjectAPI } from "./getIntlayerAPI/showcaseProject.mjs";
18
+ import { getStripeAPI } from "./getIntlayerAPI/stripe.mjs";
19
+ import { getTagAPI } from "./getIntlayerAPI/tag.mjs";
20
+ import { getTranslateAPI } from "./getIntlayerAPI/translate.mjs";
21
+ import { getUserAPI } from "./getIntlayerAPI/user.mjs";
3
22
  import { editor } from "@intlayer/config/built";
4
23
 
5
24
  //#region src/proxy.ts
6
- const ONE_MINUTE_MS = 6e4;
7
- /**
8
- * Returns the expiration timestamp in ms from an OAuth token-like object.
9
- */
10
- const getExpiryTimestamp = (token) => {
11
- if (!token) return void 0;
12
- const dateLike = token.accessTokenExpiresAt ?? token.expiresAt;
13
- if (dateLike) {
14
- const ts = typeof dateLike === "string" ? Date.parse(dateLike) : dateLike.getTime?.();
15
- if (typeof ts === "number" && Number.isFinite(ts)) return ts;
16
- }
17
- const seconds = token.expires_in ?? token.expiresIn;
18
- if (typeof seconds === "number" && Number.isFinite(seconds)) return Date.now() + seconds * 1e3;
25
+ const sectionFactories = {
26
+ asset: getAssetAPI,
27
+ organization: getOrganizationAPI,
28
+ project: getProjectAPI,
29
+ environment: getEnvironmentAPI,
30
+ user: getUserAPI,
31
+ oAuth: getOAuthAPI,
32
+ dictionary: getDictionaryAPI,
33
+ stripe: getStripeAPI,
34
+ ai: getAiAPI,
35
+ audit: getAuditAPI,
36
+ tag: getTagAPI,
37
+ search: getSearchAPI,
38
+ editor: getEditorAPI,
39
+ newsletter: getNewsletterAPI,
40
+ github: getGithubAPI,
41
+ gitlab: getGitlabAPI,
42
+ bitbucket: getBitbucketAPI,
43
+ showcaseProject: getShowcaseProjectAPI,
44
+ translate: getTranslateAPI,
45
+ reviewer: getReviewerAPI
19
46
  };
20
- let currentAccessToken;
21
- let currentExpiryTs;
22
- let pendingRefresh;
47
+ const AUTH_FREE_SECTIONS = new Set(["oAuth"]);
23
48
  /**
24
- * Build an auto-auth proxy around getIntlayerAPI that:
25
- * - Fetches an OAuth2 token when needed
26
- * - Injects Authorization header for each request
27
- * - Refreshes token proactively when near expiry
28
- *
29
- * When `sessionToken` is provided (a CLI session token starting with
30
- * "clisession_"), it is used directly as the Bearer token without any OAuth2
31
- * exchange — the backend validates it against the CliSessionToken collection.
49
+ * Builds the **complete** auto-authenticated Intlayer API as a single lazy
50
+ * object. Every domain is reachable through it, so it pulls every domain client
51
+ * into the bundle.
32
52
  *
33
- * The returned API matches the shape of getIntlayerAPI.
53
+ * Prefer {@link createIntlayerCMS} together with the per-domain endpoint binders
54
+ * (e.g. `dictionaryEndpoint`) in bundle-sensitive code — they include only the
55
+ * domains you use. This helper is a convenience for Node tools (such as the CLI)
56
+ * where bundle size is not a concern.
34
57
  */
35
58
  const getIntlayerAPIProxy = (baseAuthOptions = {}, intlayerConfig = { editor }, sessionToken) => {
36
- const authOptionsRef = {
37
- ...baseAuthOptions,
38
- credentials: "omit"
39
- };
40
- const hasCMSAuth = Boolean(sessionToken) || Boolean(intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret);
41
- if (sessionToken) authOptionsRef.headers = {
42
- ...authOptionsRef.headers ?? {},
43
- Authorization: `Bearer ${sessionToken}`
44
- };
45
- const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);
46
- const needsRefresh = () => {
47
- if (!currentAccessToken) return true;
48
- if (!currentExpiryTs) return false;
49
- return Date.now() + ONE_MINUTE_MS >= currentExpiryTs;
59
+ const cms = createIntlayerCMS(intlayerConfig, {
60
+ baseFetcherOptions: baseAuthOptions,
61
+ sessionToken
62
+ });
63
+ const sectionCache = /* @__PURE__ */ new Map();
64
+ const buildSection = (key) => {
65
+ const factory = sectionFactories[key];
66
+ return cms.bindSection(factory, { skipAuth: AUTH_FREE_SECTIONS.has(key) ? true : void 0 });
50
67
  };
51
- const refreshToken = async () => {
52
- const doRefresh = async () => {
53
- const tokenData = (await getOAuthAPI({}, intlayerConfig).getOAuth2AccessToken())?.data;
54
- currentAccessToken = tokenData?.accessToken;
55
- currentExpiryTs = getExpiryTimestamp(tokenData);
56
- };
57
- if (!pendingRefresh) pendingRefresh = doRefresh().finally(() => {
58
- pendingRefresh = void 0;
59
- });
60
- await pendingRefresh;
61
- };
62
- const ensureValidToken = async () => {
63
- if (needsRefresh()) await refreshToken();
64
- };
65
- const applyAuthHeaderToRef = () => {
66
- if (!currentAccessToken) return;
67
- authOptionsRef.headers = {
68
- ...authOptionsRef.headers ?? {},
69
- Authorization: `Bearer ${currentAccessToken}`
70
- };
71
- };
72
- const wrapSection = (section, skipAuth = !hasCMSAuth) => {
73
- return new Proxy(section, { get(target, prop, receiver) {
74
- const value = Reflect.get(target, prop, receiver);
75
- if (typeof value === "function") return async (...args) => {
76
- if (!skipAuth) if (sessionToken) {} else {
77
- await ensureValidToken();
78
- applyAuthHeaderToRef();
79
- }
80
- try {
81
- return await value.apply(target, args);
82
- } catch (err) {
83
- if (!skipAuth && !sessionToken) {
84
- await refreshToken();
85
- applyAuthHeaderToRef();
86
- return await value.apply(target, args);
87
- }
88
- throw err;
89
- }
68
+ return new Proxy({}, {
69
+ get(_target, property) {
70
+ const key = property;
71
+ if (!(key in sectionFactories)) return void 0;
72
+ if (!sectionCache.has(key)) sectionCache.set(key, buildSection(key));
73
+ return sectionCache.get(key);
74
+ },
75
+ has(_target, property) {
76
+ return property in sectionFactories;
77
+ },
78
+ ownKeys() {
79
+ return Reflect.ownKeys(sectionFactories);
80
+ },
81
+ getOwnPropertyDescriptor() {
82
+ return {
83
+ enumerable: true,
84
+ configurable: true
90
85
  };
91
- return value;
92
- } });
93
- };
94
- return {
95
- organization: wrapSection(baseApi.organization),
96
- project: wrapSection(baseApi.project),
97
- user: wrapSection(baseApi.user),
98
- oAuth: wrapSection(baseApi.oAuth, true),
99
- dictionary: wrapSection(baseApi.dictionary),
100
- stripe: wrapSection(baseApi.stripe),
101
- ai: wrapSection(baseApi.ai),
102
- tag: wrapSection(baseApi.tag),
103
- search: wrapSection(baseApi.search),
104
- editor: wrapSection(baseApi.editor),
105
- newsletter: wrapSection(baseApi.newsletter),
106
- github: wrapSection(baseApi.github)
107
- };
86
+ }
87
+ });
108
88
  };
109
89
 
110
90
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.mjs","names":[],"sources":["../../src/proxy.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { FetcherOptions } from './fetcher';\nimport { getIntlayerAPI } from './getIntlayerAPI';\nimport type { IntlayerAPI } from './getIntlayerAPI/index';\nimport { getOAuthAPI } from './getIntlayerAPI/oAuth';\n\ntype OAuthTokenLike = {\n accessToken?: string;\n accessTokenExpiresAt?: string | Date;\n expires_in?: number;\n expiresIn?: number;\n expiresAt?: string | Date;\n};\n\nconst ONE_MINUTE_MS = 60_000;\n\n/**\n * Returns the expiration timestamp in ms from an OAuth token-like object.\n */\nconst getExpiryTimestamp = (\n token: OAuthTokenLike | undefined\n): number | undefined => {\n if (!token) return undefined;\n const dateLike = (token.accessTokenExpiresAt ?? token.expiresAt) as\n | string\n | Date\n | undefined;\n if (dateLike) {\n const ts =\n typeof dateLike === 'string'\n ? Date.parse(dateLike)\n : dateLike.getTime?.();\n if (typeof ts === 'number' && Number.isFinite(ts)) return ts;\n }\n const seconds = token.expires_in ?? token.expiresIn;\n if (typeof seconds === 'number' && Number.isFinite(seconds)) {\n return Date.now() + seconds * 1000;\n }\n return undefined;\n};\n\nlet currentAccessToken: string | undefined;\nlet currentExpiryTs: number | undefined;\nlet pendingRefresh: Promise<void> | undefined;\n\n/**\n * Build an auto-auth proxy around getIntlayerAPI that:\n * - Fetches an OAuth2 token when needed\n * - Injects Authorization header for each request\n * - Refreshes token proactively when near expiry\n *\n * When `sessionToken` is provided (a CLI session token starting with\n * \"clisession_\"), it is used directly as the Bearer token without any OAuth2\n * exchange the backend validates it against the CliSessionToken collection.\n *\n * The returned API matches the shape of getIntlayerAPI.\n */\nexport const getIntlayerAPIProxy = (\n baseAuthOptions: FetcherOptions = {},\n intlayerConfig: Pick<IntlayerConfig, 'editor'> = { editor },\n sessionToken?: string\n): IntlayerAPI => {\n // Use a shared mutable auth options object captured by the API closures.\n // credentials: 'omit' prevents the browser from attaching session cookies to\n // these requests; authentication is handled exclusively via the Bearer token\n // injected below. This is required because the backend only sets\n // Access-Control-Allow-Credentials: true for whitelisted first-party origins.\n const authOptionsRef: FetcherOptions = {\n ...baseAuthOptions,\n credentials: 'omit',\n };\n const hasCMSAuth =\n Boolean(sessionToken) ||\n Boolean(\n intlayerConfig?.editor?.clientId && intlayerConfig?.editor?.clientSecret\n );\n\n // When a CLI session token is provided, inject it immediately and skip the\n // OAuth2 client_credentials exchange entirely.\n if (sessionToken) {\n authOptionsRef.headers = {\n ...(authOptionsRef.headers ?? {}),\n Authorization: `Bearer ${sessionToken}`,\n } as HeadersInit;\n }\n\n const baseApi = getIntlayerAPI(authOptionsRef, intlayerConfig);\n\n const needsRefresh = (): boolean => {\n if (!currentAccessToken) return true;\n if (!currentExpiryTs) return false; // If unknown, assume usable until failure\n\n return Date.now() + ONE_MINUTE_MS >= currentExpiryTs; // refresh 1 min before expiry\n };\n\n const refreshToken = async (): Promise<void> => {\n const doRefresh = async () => {\n const authApi = getOAuthAPI({}, intlayerConfig);\n const res = await authApi.getOAuth2AccessToken();\n const tokenData = res?.data as OAuthTokenLike | undefined;\n\n currentAccessToken = tokenData?.accessToken;\n currentExpiryTs = getExpiryTimestamp(tokenData);\n };\n\n if (!pendingRefresh) {\n pendingRefresh = doRefresh().finally(() => {\n pendingRefresh = undefined;\n });\n }\n await pendingRefresh;\n };\n\n const ensureValidToken = async () => {\n if (needsRefresh()) {\n await refreshToken();\n }\n };\n\n const applyAuthHeaderToRef = () => {\n if (!currentAccessToken) return;\n authOptionsRef.headers = {\n ...(authOptionsRef.headers ?? {}),\n Authorization: `Bearer ${currentAccessToken}`,\n } as HeadersInit;\n };\n\n const wrapSection = <T extends Record<string, unknown>>(\n section: T,\n skipAuth = !hasCMSAuth\n ): T => {\n return new Proxy(section, {\n get(target, prop, receiver) {\n const value = Reflect.get(target, prop, receiver);\n\n if (typeof value === 'function') {\n // Wrap section method to inject token and headers\n return async (...args: unknown[]) => {\n if (!skipAuth) {\n if (sessionToken) {\n // Session token is pre-injected in authOptionsRef; no OAuth2 exchange needed\n } else {\n await ensureValidToken();\n applyAuthHeaderToRef();\n }\n }\n\n try {\n return await value.apply(target, args);\n } catch (err) {\n // Best-effort retry: if token might be stale, refresh once and retry\n if (!skipAuth && !sessionToken) {\n await refreshToken();\n applyAuthHeaderToRef();\n return await value.apply(target, args);\n }\n throw err;\n }\n };\n }\n\n return value;\n },\n });\n };\n\n return {\n organization: wrapSection(baseApi.organization),\n project: wrapSection(baseApi.project),\n user: wrapSection(baseApi.user),\n oAuth: wrapSection(baseApi.oAuth, true), // do NOT inject auth for token endpoint\n dictionary: wrapSection(baseApi.dictionary),\n stripe: wrapSection(baseApi.stripe),\n ai: wrapSection(baseApi.ai),\n tag: wrapSection(baseApi.tag),\n search: wrapSection(baseApi.search),\n editor: wrapSection(baseApi.editor),\n newsletter: wrapSection(baseApi.newsletter),\n github: wrapSection(baseApi.github),\n } as IntlayerAPI;\n};\n\nexport type IntlayerAPIProxy = ReturnType<typeof getIntlayerAPIProxy>;\n"],"mappings":";;;;;AAeA,MAAM,gBAAgB;;;;AAKtB,MAAM,sBACJ,UACuB;AACvB,KAAI,CAAC,MAAO,QAAO;CACnB,MAAM,WAAY,MAAM,wBAAwB,MAAM;AAItD,KAAI,UAAU;EACZ,MAAM,KACJ,OAAO,aAAa,WAChB,KAAK,MAAM,SAAS,GACpB,SAAS,WAAW;AAC1B,MAAI,OAAO,OAAO,YAAY,OAAO,SAAS,GAAG,CAAE,QAAO;;CAE5D,MAAM,UAAU,MAAM,cAAc,MAAM;AAC1C,KAAI,OAAO,YAAY,YAAY,OAAO,SAAS,QAAQ,CACzD,QAAO,KAAK,KAAK,GAAG,UAAU;;AAKlC,IAAI;AACJ,IAAI;AACJ,IAAI;;;;;;;;;;;;;AAcJ,MAAa,uBACX,kBAAkC,EAAE,EACpC,iBAAiD,EAAE,QAAQ,EAC3D,iBACgB;CAMhB,MAAM,iBAAiC;EACrC,GAAG;EACH,aAAa;EACd;CACD,MAAM,aACJ,QAAQ,aAAa,IACrB,QACE,gBAAgB,QAAQ,YAAY,gBAAgB,QAAQ,aAC7D;AAIH,KAAI,aACF,gBAAe,UAAU;EACvB,GAAI,eAAe,WAAW,EAAE;EAChC,eAAe,UAAU;EAC1B;CAGH,MAAM,UAAU,eAAe,gBAAgB,eAAe;CAE9D,MAAM,qBAA8B;AAClC,MAAI,CAAC,mBAAoB,QAAO;AAChC,MAAI,CAAC,gBAAiB,QAAO;AAE7B,SAAO,KAAK,KAAK,GAAG,iBAAiB;;CAGvC,MAAM,eAAe,YAA2B;EAC9C,MAAM,YAAY,YAAY;GAG5B,MAAM,aAAY,MAFF,YAAY,EAAE,EAAE,eACP,CAAC,sBAAsB,GACzB;AAEvB,wBAAqB,WAAW;AAChC,qBAAkB,mBAAmB,UAAU;;AAGjD,MAAI,CAAC,eACH,kBAAiB,WAAW,CAAC,cAAc;AACzC,oBAAiB;IACjB;AAEJ,QAAM;;CAGR,MAAM,mBAAmB,YAAY;AACnC,MAAI,cAAc,CAChB,OAAM,cAAc;;CAIxB,MAAM,6BAA6B;AACjC,MAAI,CAAC,mBAAoB;AACzB,iBAAe,UAAU;GACvB,GAAI,eAAe,WAAW,EAAE;GAChC,eAAe,UAAU;GAC1B;;CAGH,MAAM,eACJ,SACA,WAAW,CAAC,eACN;AACN,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,MAAM,UAAU;GAC1B,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM,SAAS;AAEjD,OAAI,OAAO,UAAU,WAEnB,QAAO,OAAO,GAAG,SAAoB;AACnC,QAAI,CAAC,SACH,KAAI,cAAc,QAEX;AACL,WAAM,kBAAkB;AACxB,2BAAsB;;AAI1B,QAAI;AACF,YAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;aAC/B,KAAK;AAEZ,SAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,cAAc;AACpB,4BAAsB;AACtB,aAAO,MAAM,MAAM,MAAM,QAAQ,KAAK;;AAExC,WAAM;;;AAKZ,UAAO;KAEV,CAAC;;AAGJ,QAAO;EACL,cAAc,YAAY,QAAQ,aAAa;EAC/C,SAAS,YAAY,QAAQ,QAAQ;EACrC,MAAM,YAAY,QAAQ,KAAK;EAC/B,OAAO,YAAY,QAAQ,OAAO,KAAK;EACvC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACnC,IAAI,YAAY,QAAQ,GAAG;EAC3B,KAAK,YAAY,QAAQ,IAAI;EAC7B,QAAQ,YAAY,QAAQ,OAAO;EACnC,QAAQ,YAAY,QAAQ,OAAO;EACnC,YAAY,YAAY,QAAQ,WAAW;EAC3C,QAAQ,YAAY,QAAQ,OAAO;EACpC"}
1
+ {"version":3,"file":"proxy.mjs","names":[],"sources":["../../src/proxy.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createIntlayerCMS, type IntlayerCMS } from './cms/createIntlayerCMS';\nimport type { FetcherOptions } from './fetcher';\nimport { getAiAPI } from './getIntlayerAPI/ai';\nimport { getAssetAPI } from './getIntlayerAPI/asset';\nimport { getAuditAPI } from './getIntlayerAPI/audit';\nimport { getBitbucketAPI } from './getIntlayerAPI/bitbucket';\nimport { getDictionaryAPI } from './getIntlayerAPI/dictionary';\nimport { getEditorAPI } from './getIntlayerAPI/editor';\nimport { getEnvironmentAPI } from './getIntlayerAPI/environment';\nimport { getGithubAPI } from './getIntlayerAPI/github';\nimport { getGitlabAPI } from './getIntlayerAPI/gitlab';\nimport type { IntlayerAPI } from './getIntlayerAPI/index';\nimport { getNewsletterAPI } from './getIntlayerAPI/newsletter';\nimport { getOAuthAPI } from './getIntlayerAPI/oAuth';\nimport { getOrganizationAPI } from './getIntlayerAPI/organization';\nimport { getProjectAPI } from './getIntlayerAPI/project';\nimport { getReviewerAPI } from './getIntlayerAPI/reviewer';\nimport { getSearchAPI } from './getIntlayerAPI/search';\nimport { getShowcaseProjectAPI } from './getIntlayerAPI/showcaseProject';\nimport { getStripeAPI } from './getIntlayerAPI/stripe';\nimport { getTagAPI } from './getIntlayerAPI/tag';\nimport { getTranslateAPI } from './getIntlayerAPI/translate';\nimport { getUserAPI } from './getIntlayerAPI/user';\n\ntype SectionKey = keyof IntlayerAPI;\n\n/**\n * Homogeneous factory map: every domain factory normalized to the same\n * `(fetcherOptions, config) => section` signature, keyed by section name.\n * Declaring it as a single mapped type lets a generic lookup stay callable\n * (a union of factory signatures would not be).\n */\ntype SectionFactories = {\n [Key in SectionKey]: (\n fetcherOptions: FetcherOptions,\n intlayerConfig: IntlayerConfig\n ) => IntlayerAPI[Key];\n};\n\nconst sectionFactories: SectionFactories = {\n asset: getAssetAPI,\n organization: getOrganizationAPI,\n project: getProjectAPI,\n environment: getEnvironmentAPI,\n user: getUserAPI,\n oAuth: getOAuthAPI,\n dictionary: getDictionaryAPI,\n stripe: getStripeAPI,\n ai: getAiAPI,\n audit: getAuditAPI,\n tag: getTagAPI,\n search: getSearchAPI,\n editor: getEditorAPI,\n newsletter: getNewsletterAPI,\n github: getGithubAPI,\n gitlab: getGitlabAPI,\n bitbucket: getBitbucketAPI,\n showcaseProject: getShowcaseProjectAPI,\n translate: getTranslateAPI,\n reviewer: getReviewerAPI,\n};\n\n// The OAuth2 token endpoint must never receive an injected Bearer token —\n// it is the call that issues one.\nconst AUTH_FREE_SECTIONS: ReadonlySet<SectionKey> = new Set<SectionKey>([\n 'oAuth',\n]);\n\n/**\n * Builds the **complete** auto-authenticated Intlayer API as a single lazy\n * object. Every domain is reachable through it, so it pulls every domain client\n * into the bundle.\n *\n * Prefer {@link createIntlayerCMS} together with the per-domain endpoint binders\n * (e.g. `dictionaryEndpoint`) in bundle-sensitive code they include only the\n * domains you use. This helper is a convenience for Node tools (such as the CLI)\n * where bundle size is not a concern.\n */\nexport const getIntlayerAPIProxy = (\n baseAuthOptions: FetcherOptions = {},\n intlayerConfig: Pick<IntlayerConfig, 'editor'> = { editor },\n sessionToken?: string\n): IntlayerAPI => {\n const cms: IntlayerCMS = createIntlayerCMS(intlayerConfig, {\n baseFetcherOptions: baseAuthOptions,\n sessionToken,\n });\n\n const sectionCache = new Map<SectionKey, unknown>();\n\n // Generic over `Key` so `sectionFactories[key]` resolves to a single\n // `(opts, config) => IntlayerAPI[Key]` signature rather than the union of all\n // factory signatures (which would not be callable).\n const buildSection = <Key extends SectionKey>(key: Key): IntlayerAPI[Key] => {\n const factory = sectionFactories[key] as (\n fetcherOptions: FetcherOptions,\n intlayerConfig: IntlayerConfig\n ) => Record<string, unknown>;\n\n return cms.bindSection(factory, {\n skipAuth: AUTH_FREE_SECTIONS.has(key) ? true : undefined,\n }) as IntlayerAPI[Key];\n };\n\n return new Proxy({} as IntlayerAPI, {\n get(_target, property) {\n const key = property as SectionKey;\n if (!(key in sectionFactories)) return undefined;\n\n if (!sectionCache.has(key)) {\n sectionCache.set(key, buildSection(key));\n }\n\n return sectionCache.get(key);\n },\n has(_target, property) {\n return (property as SectionKey) in sectionFactories;\n },\n ownKeys() {\n return Reflect.ownKeys(sectionFactories);\n },\n getOwnPropertyDescriptor() {\n return { enumerable: true, configurable: true };\n },\n });\n};\n\n/**\n * The complete auto-authenticated Intlayer API returned by\n * {@link getIntlayerAPIProxy}. Equivalent in shape to `IntlayerAPI`.\n */\nexport type IntlayerAPIProxy = ReturnType<typeof getIntlayerAPIProxy>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,mBAAqC;CACzC,OAAO;CACP,cAAc;CACd,SAAS;CACT,aAAa;CACb,MAAM;CACN,OAAO;CACP,YAAY;CACZ,QAAQ;CACR,IAAI;CACJ,OAAO;CACP,KAAK;CACL,QAAQ;CACR,QAAQ;CACR,YAAY;CACZ,QAAQ;CACR,QAAQ;CACR,WAAW;CACX,iBAAiB;CACjB,WAAW;CACX,UAAU;CACX;AAID,MAAM,qBAA8C,IAAI,IAAgB,CACtE,QACD,CAAC;;;;;;;;;;;AAYF,MAAa,uBACX,kBAAkC,EAAE,EACpC,iBAAiD,EAAE,QAAQ,EAC3D,iBACgB;CAChB,MAAM,MAAmB,kBAAkB,gBAAgB;EACzD,oBAAoB;EACpB;EACD,CAAC;CAEF,MAAM,+BAAe,IAAI,KAA0B;CAKnD,MAAM,gBAAwC,QAA+B;EAC3E,MAAM,UAAU,iBAAiB;AAKjC,SAAO,IAAI,YAAY,SAAS,EAC9B,UAAU,mBAAmB,IAAI,IAAI,GAAG,OAAO,QAChD,CAAC;;AAGJ,QAAO,IAAI,MAAM,EAAE,EAAiB;EAClC,IAAI,SAAS,UAAU;GACrB,MAAM,MAAM;AACZ,OAAI,EAAE,OAAO,kBAAmB,QAAO;AAEvC,OAAI,CAAC,aAAa,IAAI,IAAI,CACxB,cAAa,IAAI,KAAK,aAAa,IAAI,CAAC;AAG1C,UAAO,aAAa,IAAI,IAAI;;EAE9B,IAAI,SAAS,UAAU;AACrB,UAAQ,YAA2B;;EAErC,UAAU;AACR,UAAO,QAAQ,QAAQ,iBAAiB;;EAE1C,2BAA2B;AACzB,UAAO;IAAE,YAAY;IAAM,cAAc;IAAM;;EAElD,CAAC"}