@intlayer/api 9.0.0-canary.10 → 9.0.0-canary.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cms/createAuthManager.cjs +116 -0
- package/dist/cjs/cms/createAuthManager.cjs.map +1 -0
- package/dist/cjs/cms/createIntlayerCMS.cjs +64 -0
- package/dist/cjs/cms/createIntlayerCMS.cjs.map +1 -0
- package/dist/cjs/cms/index.cjs +7 -0
- package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs +3 -2
- package/dist/cjs/distantDictionary/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +3 -2
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/ai.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/ai.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/asset.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/asset.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/audit.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/audit.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/bitbucket.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/bitbucket.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/dictionary.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/dictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/editor.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/editor.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/environment.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/environment.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/github.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/github.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/gitlab.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/gitlab.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/index.cjs +4 -2
- package/dist/cjs/getIntlayerAPI/index.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/newsletter.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/newsletter.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/organization.cjs +19 -0
- package/dist/cjs/getIntlayerAPI/organization.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/project.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/project.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/reviewer.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/reviewer.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/search.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/search.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/showcaseProject.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/showcaseProject.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/status.cjs +48 -0
- package/dist/cjs/getIntlayerAPI/status.cjs.map +1 -0
- package/dist/cjs/getIntlayerAPI/stripe.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/stripe.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/tag.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/tag.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/translate.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/translate.cjs.map +1 -1
- package/dist/cjs/getIntlayerAPI/user.cjs +9 -0
- package/dist/cjs/getIntlayerAPI/user.cjs.map +1 -1
- package/dist/cjs/index.cjs +30 -3
- package/dist/cjs/proxy.cjs +78 -96
- package/dist/cjs/proxy.cjs.map +1 -1
- package/dist/esm/cms/createAuthManager.mjs +115 -0
- package/dist/esm/cms/createAuthManager.mjs.map +1 -0
- package/dist/esm/cms/createIntlayerCMS.mjs +62 -0
- package/dist/esm/cms/createIntlayerCMS.mjs.map +1 -0
- package/dist/esm/cms/index.mjs +4 -0
- package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs +3 -2
- package/dist/esm/distantDictionary/fetchDistantDictionaries.mjs.map +1 -1
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +3 -2
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/ai.mjs +9 -1
- package/dist/esm/getIntlayerAPI/ai.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/asset.mjs +9 -1
- package/dist/esm/getIntlayerAPI/asset.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/audit.mjs +9 -1
- package/dist/esm/getIntlayerAPI/audit.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/bitbucket.mjs +9 -1
- package/dist/esm/getIntlayerAPI/bitbucket.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/dictionary.mjs +9 -1
- package/dist/esm/getIntlayerAPI/dictionary.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/editor.mjs +9 -1
- package/dist/esm/getIntlayerAPI/editor.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/environment.mjs +9 -1
- package/dist/esm/getIntlayerAPI/environment.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/github.mjs +9 -1
- package/dist/esm/getIntlayerAPI/github.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/gitlab.mjs +9 -1
- package/dist/esm/getIntlayerAPI/gitlab.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/index.mjs +4 -2
- package/dist/esm/getIntlayerAPI/index.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/newsletter.mjs +9 -1
- package/dist/esm/getIntlayerAPI/newsletter.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/organization.mjs +19 -1
- package/dist/esm/getIntlayerAPI/organization.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/project.mjs +9 -1
- package/dist/esm/getIntlayerAPI/project.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/reviewer.mjs +9 -1
- package/dist/esm/getIntlayerAPI/reviewer.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/search.mjs +9 -1
- package/dist/esm/getIntlayerAPI/search.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/showcaseProject.mjs +9 -1
- package/dist/esm/getIntlayerAPI/showcaseProject.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/status.mjs +46 -0
- package/dist/esm/getIntlayerAPI/status.mjs.map +1 -0
- package/dist/esm/getIntlayerAPI/stripe.mjs +9 -1
- package/dist/esm/getIntlayerAPI/stripe.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/tag.mjs +9 -1
- package/dist/esm/getIntlayerAPI/tag.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/translate.mjs +9 -1
- package/dist/esm/getIntlayerAPI/translate.mjs.map +1 -1
- package/dist/esm/getIntlayerAPI/user.mjs +9 -1
- package/dist/esm/getIntlayerAPI/user.mjs.map +1 -1
- package/dist/esm/index.mjs +24 -21
- package/dist/esm/proxy.mjs +78 -96
- package/dist/esm/proxy.mjs.map +1 -1
- package/dist/types/apps/backend/dist/types/controllers/ai.controller.d.ts +94 -0
- package/dist/types/apps/backend/dist/types/controllers/ai.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/asset.controller.d.ts +15 -0
- package/dist/types/apps/backend/dist/types/controllers/asset.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/audit.controller.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/controllers/bitbucket.controller.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/controllers/cliSessionToken.controller.d.ts +18 -0
- package/dist/types/apps/backend/dist/types/controllers/cliSessionToken.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/dictionary.controller.d.ts +85 -0
- package/dist/types/apps/backend/dist/types/controllers/dictionary.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/environment.controller.d.ts +30 -0
- package/dist/types/apps/backend/dist/types/controllers/environment.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/eventListener.controller.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/controllers/github.controller.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/controllers/gitlab.controller.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/controllers/newsletter.controller.d.ts +25 -0
- package/dist/types/apps/backend/dist/types/controllers/newsletter.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/oAuth2.controller.d.ts +7 -0
- package/dist/types/apps/backend/dist/types/controllers/oAuth2.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/organization.controller.d.ts +71 -0
- package/dist/types/apps/backend/dist/types/controllers/organization.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/project.controller.d.ts +81 -0
- package/dist/types/apps/backend/dist/types/controllers/project.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/projectAccessKey.controller.d.ts +26 -0
- package/dist/types/apps/backend/dist/types/controllers/projectAccessKey.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/projectMemberAccess.controller.d.ts +15 -0
- package/dist/types/apps/backend/dist/types/controllers/projectMemberAccess.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/recursiveAudit.controller.d.ts +31 -0
- package/dist/types/apps/backend/dist/types/controllers/recursiveAudit.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/reviewer.controller.d.ts +69 -0
- package/dist/types/apps/backend/dist/types/controllers/reviewer.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/searchDoc.controller.d.ts +19 -0
- package/dist/types/apps/backend/dist/types/controllers/searchDoc.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/showcaseProject.controller.d.ts +76 -0
- package/dist/types/apps/backend/dist/types/controllers/showcaseProject.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/stripe.controller.d.ts +148 -0
- package/dist/types/apps/backend/dist/types/controllers/stripe.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/tag.controller.d.ts +34 -0
- package/dist/types/apps/backend/dist/types/controllers/tag.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/translation.controller.d.ts +15 -0
- package/dist/types/apps/backend/dist/types/controllers/translation.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/controllers/user.controller.d.ts +51 -0
- package/dist/types/apps/backend/dist/types/controllers/user.controller.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/export.d.ts +37 -0
- package/dist/types/apps/backend/dist/types/routes/ai.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/asset.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/audit.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/bitbucket.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/dictionary.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/environment.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/github.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/gitlab.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/newsletter.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/organization.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/project.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/reviewer.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/showcaseProject.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/stripe.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/translate.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/routes/user.routes.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/services/audit/types.d.ts +34 -0
- package/dist/types/apps/backend/dist/types/services/audit/types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/services/ci.service.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/services/github.service.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/services/subscription.service.d.ts +13 -0
- package/dist/types/apps/backend/dist/types/services/subscription.service.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/affiliate.types.d.ts +39 -0
- package/dist/types/apps/backend/dist/types/types/affiliate.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/affiliateInvitation.types.d.ts +26 -0
- package/dist/types/apps/backend/dist/types/types/affiliateInvitation.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/aiStats.types.d.ts +23 -0
- package/dist/types/apps/backend/dist/types/types/aiStats.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/asset.types.d.ts +31 -0
- package/dist/types/apps/backend/dist/types/types/asset.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/dictionary.types.d.ts +65 -0
- package/dist/types/apps/backend/dist/types/types/dictionary.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/discussion.types.d.ts +42 -0
- package/dist/types/apps/backend/dist/types/types/discussion.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/oAuth2.types.d.ts +16 -0
- package/dist/types/apps/backend/dist/types/types/oAuth2.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/organization.types.d.ts +98 -0
- package/dist/types/apps/backend/dist/types/types/organization.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/plan.types.d.ts +23 -0
- package/dist/types/apps/backend/dist/types/types/plan.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/project.types.d.ts +122 -0
- package/dist/types/apps/backend/dist/types/types/project.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/projectInsights.types.d.ts +52 -0
- package/dist/types/apps/backend/dist/types/types/projectInsights.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/promoCode.types.d.ts +26 -0
- package/dist/types/apps/backend/dist/types/types/promoCode.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/reviewer.types.d.ts +49 -0
- package/dist/types/apps/backend/dist/types/types/reviewer.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/session.types.d.ts +2 -0
- package/dist/types/apps/backend/dist/types/types/showcaseProject.types.d.ts +59 -0
- package/dist/types/apps/backend/dist/types/types/showcaseProject.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/tag.types.d.ts +31 -0
- package/dist/types/apps/backend/dist/types/types/tag.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/types/user.types.d.ts +32 -0
- package/dist/types/apps/backend/dist/types/types/user.types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/AI/askDocQuestion/askDocQuestion.d.ts +10 -0
- package/dist/types/apps/backend/dist/types/utils/AI/askDocQuestion/askDocQuestion.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/AI/auditDictionary/index.d.ts +15 -0
- package/dist/types/apps/backend/dist/types/utils/AI/auditDictionary/index.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/AI/auditDictionaryField/index.d.ts +12 -0
- package/dist/types/apps/backend/dist/types/utils/AI/auditDictionaryField/index.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/AI/auditDictionaryMetadata/index.d.ts +2 -0
- package/dist/types/apps/backend/dist/types/utils/AI/auditTag/index.d.ts +10 -0
- package/dist/types/apps/backend/dist/types/utils/AI/auditTag/index.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/AI/chat/index.d.ts +16 -0
- package/dist/types/apps/backend/dist/types/utils/AI/chat/index.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/AI/customQuery/index.d.ts +11 -0
- package/dist/types/apps/backend/dist/types/utils/AI/customQuery/index.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/AI/translateJSON/index.d.ts +20 -0
- package/dist/types/apps/backend/dist/types/utils/AI/translateJSON/index.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/auth/getAuth.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getDictionaryFiltersAndPagination.d.ts +41 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getDictionaryFiltersAndPagination.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getDiscussionFiltersAndPagination.d.ts +19 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getDiscussionFiltersAndPagination.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getFiltersAndPaginationFromBody.d.ts +11 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getFiltersAndPaginationFromBody.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getOrganizationFiltersAndPagination.d.ts +25 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getOrganizationFiltersAndPagination.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getProjectFiltersAndPagination.d.ts +18 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getProjectFiltersAndPagination.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getTagFiltersAndPagination.d.ts +16 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getTagFiltersAndPagination.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getUserFiltersAndPagination.d.ts +20 -0
- package/dist/types/apps/backend/dist/types/utils/filtersAndPagination/getUserFiltersAndPagination.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/httpStatusCodes.d.ts +408 -0
- package/dist/types/apps/backend/dist/types/utils/httpStatusCodes.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/mongoDB/types.d.ts +10 -0
- package/dist/types/apps/backend/dist/types/utils/mongoDB/types.d.ts.map +1 -0
- package/dist/types/apps/backend/dist/types/utils/permissions.d.ts +1 -0
- package/dist/types/apps/backend/dist/types/utils/responseData.d.ts +27 -0
- package/dist/types/apps/backend/dist/types/utils/responseData.d.ts.map +1 -0
- package/dist/types/cms/createAuthManager.d.ts +103 -0
- package/dist/types/cms/createAuthManager.d.ts.map +1 -0
- package/dist/types/cms/createIntlayerCMS.d.ts +80 -0
- package/dist/types/cms/createIntlayerCMS.d.ts.map +1 -0
- package/dist/types/cms/index.d.ts +3 -0
- package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts +1 -1
- package/dist/types/distantDictionary/fetchDistantDictionaries.d.ts.map +1 -1
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +1 -1
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/ai.d.ts +22 -2
- package/dist/types/getIntlayerAPI/ai.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/asset.d.ts +20 -1
- package/dist/types/getIntlayerAPI/asset.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/audit.d.ts +25 -2
- package/dist/types/getIntlayerAPI/audit.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/bitbucket.d.ts +15 -1
- package/dist/types/getIntlayerAPI/bitbucket.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/dictionary.d.ts +19 -2
- package/dist/types/getIntlayerAPI/dictionary.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/editor.d.ts +13 -1
- package/dist/types/getIntlayerAPI/editor.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/environment.d.ts +17 -2
- package/dist/types/getIntlayerAPI/environment.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/github.d.ts +16 -1
- package/dist/types/getIntlayerAPI/github.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/gitlab.d.ts +15 -1
- package/dist/types/getIntlayerAPI/gitlab.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/index.d.ts +3 -1
- package/dist/types/getIntlayerAPI/index.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/newsletter.d.ts +14 -2
- package/dist/types/getIntlayerAPI/newsletter.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/oAuth.d.ts +2 -0
- package/dist/types/getIntlayerAPI/oAuth.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/organization.d.ts +24 -2
- package/dist/types/getIntlayerAPI/organization.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/project.d.ts +32 -2
- package/dist/types/getIntlayerAPI/project.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/reviewer.d.ts +651 -17
- package/dist/types/getIntlayerAPI/reviewer.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/search.d.ts +12 -2
- package/dist/types/getIntlayerAPI/search.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/showcaseProject.d.ts +23 -2
- package/dist/types/getIntlayerAPI/showcaseProject.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/status.d.ts +36 -0
- package/dist/types/getIntlayerAPI/status.d.ts.map +1 -0
- package/dist/types/getIntlayerAPI/stripe.d.ts +68 -2
- package/dist/types/getIntlayerAPI/stripe.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/tag.d.ts +15 -2
- package/dist/types/getIntlayerAPI/tag.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/translate.d.ts +37 -2
- package/dist/types/getIntlayerAPI/translate.d.ts.map +1 -1
- package/dist/types/getIntlayerAPI/user.d.ts +24 -3
- package/dist/types/getIntlayerAPI/user.d.ts.map +1 -1
- package/dist/types/index.d.ts +28 -22
- package/dist/types/packages/@intlayer/ai/dist/types/aiSdk.d.ts +115 -0
- package/dist/types/packages/@intlayer/ai/dist/types/aiSdk.d.ts.map +1 -0
- package/dist/types/packages/@intlayer/ai/dist/types/auditDictionaryMetadata/index.d.ts +12 -0
- package/dist/types/packages/@intlayer/ai/dist/types/auditDictionaryMetadata/index.d.ts.map +1 -0
- package/dist/types/packages/@intlayer/ai/dist/types/customQuery.d.ts +8 -0
- package/dist/types/packages/@intlayer/ai/dist/types/customQuery.d.ts.map +1 -0
- package/dist/types/packages/@intlayer/ai/dist/types/index.d.ts +27 -0
- package/dist/types/packages/@intlayer/ai/dist/types/index.d.ts.map +1 -0
- package/dist/types/packages/@intlayer/ai/dist/types/translateJSON/index.d.ts +10 -0
- package/dist/types/packages/@intlayer/ai/dist/types/translateJSON/index.d.ts.map +1 -0
- package/dist/types/packages/@intlayer/core/dist/types/messageFormat/ICU.d.ts +1 -0
- package/dist/types/packages/@intlayer/core/dist/types/messageFormat/i18next.d.ts +1 -0
- package/dist/types/packages/@intlayer/core/dist/types/messageFormat/index.d.ts +1 -0
- package/dist/types/packages/@intlayer/core/dist/types/messageFormat/po.d.ts +1 -0
- package/dist/types/packages/@intlayer/core/dist/types/messageFormat/resolveMessage.d.ts +1 -0
- package/dist/types/packages/@intlayer/core/dist/types/messageFormat/vue-i18n.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/build.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts +2 -0
- package/dist/types/packages/@intlayer/engine/dist/types/buildIntlayerDictionary/processContentDeclaration.d.ts +2 -0
- package/dist/types/packages/@intlayer/engine/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -0
- package/dist/types/packages/@intlayer/engine/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -0
- package/dist/types/packages/@intlayer/engine/dist/types/buildIntlayerDictionary/writeUnmergedDictionary.d.ts +2 -0
- package/dist/types/packages/@intlayer/engine/dist/types/cleanOutputDir.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/createDictionaryEntryPoint/getBuiltDictionariesPath.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/createType/createModuleAugmentation.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/createType/createType.d.ts +2 -0
- package/dist/types/packages/@intlayer/engine/dist/types/formatDictionary.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/loadDictionaries/loadContentDeclaration.d.ts +2 -0
- package/dist/types/packages/@intlayer/engine/dist/types/loadDictionaries/loadDictionaries.d.ts +2 -0
- package/dist/types/packages/@intlayer/engine/dist/types/loadDictionaries/loadLocalDictionaries.d.ts +2 -0
- package/dist/types/packages/@intlayer/engine/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/prepareIntlayer.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/writeConfiguration/index.d.ts +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/writeContentDeclaration/dictionaryStatus.d.ts +6 -0
- package/dist/types/packages/@intlayer/engine/dist/types/writeContentDeclaration/dictionaryStatus.d.ts.map +1 -0
- package/dist/types/packages/@intlayer/engine/dist/types/writeContentDeclaration/transformJSFile.d.ts +2 -0
- package/dist/types/packages/@intlayer/engine/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +3 -0
- package/dist/types/packages/@intlayer/engine/dist/types/writeContentDeclaration/writeJSFile.d.ts +2 -0
- package/dist/types/packages/intlayer-editor/server/dist/controllers/dictionary.controller.d.ts +1 -1
- package/dist/types/proxy.d.ts +11 -9
- package/dist/types/proxy.d.ts.map +1 -1
- package/dist/types/types.d.ts +1 -1
- package/package.json +19 -3
package/dist/cjs/proxy.cjs
CHANGED
|
@@ -1,111 +1,93 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_getIntlayerAPI_oAuth = require('./getIntlayerAPI/oAuth.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_cms_createIntlayerCMS = require('./cms/createIntlayerCMS.cjs');
|
|
4
|
+
const require_getIntlayerAPI_ai = require('./getIntlayerAPI/ai.cjs');
|
|
5
|
+
const require_getIntlayerAPI_asset = require('./getIntlayerAPI/asset.cjs');
|
|
6
|
+
const require_getIntlayerAPI_audit = require('./getIntlayerAPI/audit.cjs');
|
|
7
|
+
const require_getIntlayerAPI_bitbucket = require('./getIntlayerAPI/bitbucket.cjs');
|
|
8
|
+
const require_getIntlayerAPI_dictionary = require('./getIntlayerAPI/dictionary.cjs');
|
|
9
|
+
const require_getIntlayerAPI_editor = require('./getIntlayerAPI/editor.cjs');
|
|
10
|
+
const require_getIntlayerAPI_environment = require('./getIntlayerAPI/environment.cjs');
|
|
11
|
+
const require_getIntlayerAPI_github = require('./getIntlayerAPI/github.cjs');
|
|
12
|
+
const require_getIntlayerAPI_gitlab = require('./getIntlayerAPI/gitlab.cjs');
|
|
13
|
+
const require_getIntlayerAPI_newsletter = require('./getIntlayerAPI/newsletter.cjs');
|
|
14
|
+
const require_getIntlayerAPI_organization = require('./getIntlayerAPI/organization.cjs');
|
|
15
|
+
const require_getIntlayerAPI_project = require('./getIntlayerAPI/project.cjs');
|
|
16
|
+
const require_getIntlayerAPI_reviewer = require('./getIntlayerAPI/reviewer.cjs');
|
|
17
|
+
const require_getIntlayerAPI_search = require('./getIntlayerAPI/search.cjs');
|
|
18
|
+
const require_getIntlayerAPI_showcaseProject = require('./getIntlayerAPI/showcaseProject.cjs');
|
|
19
|
+
const require_getIntlayerAPI_status = require('./getIntlayerAPI/status.cjs');
|
|
20
|
+
const require_getIntlayerAPI_stripe = require('./getIntlayerAPI/stripe.cjs');
|
|
21
|
+
const require_getIntlayerAPI_tag = require('./getIntlayerAPI/tag.cjs');
|
|
22
|
+
const require_getIntlayerAPI_translate = require('./getIntlayerAPI/translate.cjs');
|
|
23
|
+
const require_getIntlayerAPI_user = require('./getIntlayerAPI/user.cjs');
|
|
4
24
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
5
25
|
|
|
6
26
|
//#region src/proxy.ts
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
const sectionFactories = {
|
|
28
|
+
asset: require_getIntlayerAPI_asset.getAssetAPI,
|
|
29
|
+
organization: require_getIntlayerAPI_organization.getOrganizationAPI,
|
|
30
|
+
project: require_getIntlayerAPI_project.getProjectAPI,
|
|
31
|
+
environment: require_getIntlayerAPI_environment.getEnvironmentAPI,
|
|
32
|
+
user: require_getIntlayerAPI_user.getUserAPI,
|
|
33
|
+
oAuth: require_getIntlayerAPI_oAuth.getOAuthAPI,
|
|
34
|
+
dictionary: require_getIntlayerAPI_dictionary.getDictionaryAPI,
|
|
35
|
+
stripe: require_getIntlayerAPI_stripe.getStripeAPI,
|
|
36
|
+
ai: require_getIntlayerAPI_ai.getAiAPI,
|
|
37
|
+
audit: require_getIntlayerAPI_audit.getAuditAPI,
|
|
38
|
+
tag: require_getIntlayerAPI_tag.getTagAPI,
|
|
39
|
+
search: require_getIntlayerAPI_search.getSearchAPI,
|
|
40
|
+
editor: require_getIntlayerAPI_editor.getEditorAPI,
|
|
41
|
+
newsletter: require_getIntlayerAPI_newsletter.getNewsletterAPI,
|
|
42
|
+
github: require_getIntlayerAPI_github.getGithubAPI,
|
|
43
|
+
gitlab: require_getIntlayerAPI_gitlab.getGitlabAPI,
|
|
44
|
+
bitbucket: require_getIntlayerAPI_bitbucket.getBitbucketAPI,
|
|
45
|
+
showcaseProject: require_getIntlayerAPI_showcaseProject.getShowcaseProjectAPI,
|
|
46
|
+
translate: require_getIntlayerAPI_translate.getTranslateAPI,
|
|
47
|
+
reviewer: require_getIntlayerAPI_reviewer.getReviewerAPI,
|
|
48
|
+
status: require_getIntlayerAPI_status.getStatusAPI
|
|
20
49
|
};
|
|
21
|
-
|
|
22
|
-
let currentExpiryTs;
|
|
23
|
-
let pendingRefresh;
|
|
50
|
+
const AUTH_FREE_SECTIONS = new Set(["oAuth"]);
|
|
24
51
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* - Refreshes token proactively when near expiry
|
|
29
|
-
*
|
|
30
|
-
* When `sessionToken` is provided (a CLI session token starting with
|
|
31
|
-
* "clisession_"), it is used directly as the Bearer token without any OAuth2
|
|
32
|
-
* exchange — the backend validates it against the CliSessionToken collection.
|
|
52
|
+
* Builds the **complete** auto-authenticated Intlayer API as a single lazy
|
|
53
|
+
* object. Every domain is reachable through it, so it pulls every domain client
|
|
54
|
+
* into the bundle.
|
|
33
55
|
*
|
|
34
|
-
*
|
|
56
|
+
* Prefer {@link createIntlayerCMS} together with the per-domain endpoint binders
|
|
57
|
+
* (e.g. `dictionaryEndpoint`) in bundle-sensitive code — they include only the
|
|
58
|
+
* domains you use. This helper is a convenience for Node tools (such as the CLI)
|
|
59
|
+
* where bundle size is not a concern.
|
|
35
60
|
*/
|
|
36
61
|
const getIntlayerAPIProxy = (baseAuthOptions = {}, intlayerConfig = { editor: _intlayer_config_built.editor }, sessionToken) => {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
const baseApi = require_getIntlayerAPI_index.getIntlayerAPI(authOptionsRef, intlayerConfig);
|
|
47
|
-
const needsRefresh = () => {
|
|
48
|
-
if (!currentAccessToken) return true;
|
|
49
|
-
if (!currentExpiryTs) return false;
|
|
50
|
-
return Date.now() + ONE_MINUTE_MS >= currentExpiryTs;
|
|
62
|
+
const cms = require_cms_createIntlayerCMS.createIntlayerCMS(intlayerConfig, {
|
|
63
|
+
baseFetcherOptions: baseAuthOptions,
|
|
64
|
+
sessionToken
|
|
65
|
+
});
|
|
66
|
+
const sectionCache = /* @__PURE__ */ new Map();
|
|
67
|
+
const buildSection = (key) => {
|
|
68
|
+
const factory = sectionFactories[key];
|
|
69
|
+
return cms.bindSection(factory, { skipAuth: AUTH_FREE_SECTIONS.has(key) ? true : void 0 });
|
|
51
70
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
...authOptionsRef.headers ?? {},
|
|
70
|
-
Authorization: `Bearer ${currentAccessToken}`
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
const wrapSection = (section, skipAuth = !hasCMSAuth) => {
|
|
74
|
-
return new Proxy(section, { get(target, prop, receiver) {
|
|
75
|
-
const value = Reflect.get(target, prop, receiver);
|
|
76
|
-
if (typeof value === "function") return async (...args) => {
|
|
77
|
-
if (!skipAuth) if (sessionToken) {} else {
|
|
78
|
-
await ensureValidToken();
|
|
79
|
-
applyAuthHeaderToRef();
|
|
80
|
-
}
|
|
81
|
-
try {
|
|
82
|
-
return await value.apply(target, args);
|
|
83
|
-
} catch (err) {
|
|
84
|
-
if (!skipAuth && !sessionToken) {
|
|
85
|
-
await refreshToken();
|
|
86
|
-
applyAuthHeaderToRef();
|
|
87
|
-
return await value.apply(target, args);
|
|
88
|
-
}
|
|
89
|
-
throw err;
|
|
90
|
-
}
|
|
71
|
+
return new Proxy({}, {
|
|
72
|
+
get(_target, property) {
|
|
73
|
+
const key = property;
|
|
74
|
+
if (!(key in sectionFactories)) return void 0;
|
|
75
|
+
if (!sectionCache.has(key)) sectionCache.set(key, buildSection(key));
|
|
76
|
+
return sectionCache.get(key);
|
|
77
|
+
},
|
|
78
|
+
has(_target, property) {
|
|
79
|
+
return property in sectionFactories;
|
|
80
|
+
},
|
|
81
|
+
ownKeys() {
|
|
82
|
+
return Reflect.ownKeys(sectionFactories);
|
|
83
|
+
},
|
|
84
|
+
getOwnPropertyDescriptor() {
|
|
85
|
+
return {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
configurable: true
|
|
91
88
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
95
|
-
return {
|
|
96
|
-
organization: wrapSection(baseApi.organization),
|
|
97
|
-
project: wrapSection(baseApi.project),
|
|
98
|
-
user: wrapSection(baseApi.user),
|
|
99
|
-
oAuth: wrapSection(baseApi.oAuth, true),
|
|
100
|
-
dictionary: wrapSection(baseApi.dictionary),
|
|
101
|
-
stripe: wrapSection(baseApi.stripe),
|
|
102
|
-
ai: wrapSection(baseApi.ai),
|
|
103
|
-
tag: wrapSection(baseApi.tag),
|
|
104
|
-
search: wrapSection(baseApi.search),
|
|
105
|
-
editor: wrapSection(baseApi.editor),
|
|
106
|
-
newsletter: wrapSection(baseApi.newsletter),
|
|
107
|
-
github: wrapSection(baseApi.github)
|
|
108
|
-
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
109
91
|
};
|
|
110
92
|
|
|
111
93
|
//#endregion
|
package/dist/cjs/proxy.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.cjs","names":["
|
|
1
|
+
{"version":3,"file":"proxy.cjs","names":["getAssetAPI","getOrganizationAPI","getProjectAPI","getEnvironmentAPI","getUserAPI","getOAuthAPI","getDictionaryAPI","getStripeAPI","getAiAPI","getAuditAPI","getTagAPI","getSearchAPI","getEditorAPI","getNewsletterAPI","getGithubAPI","getGitlabAPI","getBitbucketAPI","getShowcaseProjectAPI","getTranslateAPI","getReviewerAPI","getStatusAPI","createIntlayerCMS"],"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 { getStatusAPI } from './getIntlayerAPI/status';\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 status: getStatusAPI,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,mBAAqC;CACzC,OAAOA;CACP,cAAcC;CACd,SAASC;CACT,aAAaC;CACb,MAAMC;CACN,OAAOC;CACP,YAAYC;CACZ,QAAQC;CACR,IAAIC;CACJ,OAAOC;CACP,KAAKC;CACL,QAAQC;CACR,QAAQC;CACR,YAAYC;CACZ,QAAQC;CACR,QAAQC;CACR,WAAWC;CACX,iBAAiBC;CACjB,WAAWC;CACX,UAAUC;CACV,QAAQC;CACT;AAID,MAAM,qBAA8C,IAAI,IAAgB,CACtE,QACD,CAAC;;;;;;;;;;;AAYF,MAAa,uBACX,kBAAkC,EAAE,EACpC,iBAAiD,EAAE,uCAAQ,EAC3D,iBACgB;CAChB,MAAM,MAAmBC,gDAAkB,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"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { getOAuthAPI } from "../getIntlayerAPI/oAuth.mjs";
|
|
2
|
+
import { editor } from "@intlayer/config/built";
|
|
3
|
+
import { defu } from "defu";
|
|
4
|
+
|
|
5
|
+
//#region src/cms/createAuthManager.ts
|
|
6
|
+
const ONE_MINUTE_MS = 6e4;
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the expiration timestamp (in ms since epoch) from an OAuth2
|
|
9
|
+
* token-like payload, supporting both absolute dates and relative durations.
|
|
10
|
+
*/
|
|
11
|
+
const getExpiryTimestamp = (token) => {
|
|
12
|
+
if (!token) return void 0;
|
|
13
|
+
const dateLike = token.accessTokenExpiresAt ?? token.expiresAt;
|
|
14
|
+
if (dateLike) {
|
|
15
|
+
const timestamp = typeof dateLike === "string" ? Date.parse(dateLike) : dateLike.getTime?.();
|
|
16
|
+
if (typeof timestamp === "number" && Number.isFinite(timestamp)) return timestamp;
|
|
17
|
+
}
|
|
18
|
+
const seconds = token.expires_in ?? token.expiresIn;
|
|
19
|
+
if (typeof seconds === "number" && Number.isFinite(seconds)) return Date.now() + seconds * 1e3;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Creates an instance-scoped {@link AuthManager} handling the OAuth2
|
|
23
|
+
* `client_credentials` flow (or a pre-issued CLI session token).
|
|
24
|
+
*
|
|
25
|
+
* Unlike a global token cache, each manager keeps its own token state, so
|
|
26
|
+
* independent SDK instances never interfere with one another.
|
|
27
|
+
*
|
|
28
|
+
* @param intlayerConfig - Intlayer configuration carrying the `editor`
|
|
29
|
+
* credentials. Defaults to the build-time configuration.
|
|
30
|
+
* @param options - Optional session token and base fetcher options.
|
|
31
|
+
*/
|
|
32
|
+
const createAuthManager = (intlayerConfig = { editor }, options = {}) => {
|
|
33
|
+
const { baseFetcherOptions = {}, sessionToken } = options;
|
|
34
|
+
const resolvedConfig = defu(intlayerConfig ?? {}, { editor });
|
|
35
|
+
const fetcherOptions = {
|
|
36
|
+
...baseFetcherOptions,
|
|
37
|
+
credentials: "omit"
|
|
38
|
+
};
|
|
39
|
+
const hasCredentials = Boolean(sessionToken) || Boolean(resolvedConfig?.editor?.clientId && resolvedConfig?.editor?.clientSecret);
|
|
40
|
+
if (sessionToken) fetcherOptions.headers = {
|
|
41
|
+
...fetcherOptions.headers ?? {},
|
|
42
|
+
Authorization: `Bearer ${sessionToken}`
|
|
43
|
+
};
|
|
44
|
+
let accessToken;
|
|
45
|
+
let expiryTimestamp;
|
|
46
|
+
let pendingRefresh;
|
|
47
|
+
const needsRefresh = () => {
|
|
48
|
+
if (!accessToken) return true;
|
|
49
|
+
if (!expiryTimestamp) return false;
|
|
50
|
+
return Date.now() + ONE_MINUTE_MS >= expiryTimestamp;
|
|
51
|
+
};
|
|
52
|
+
const refreshToken = async () => {
|
|
53
|
+
const doRefresh = async () => {
|
|
54
|
+
const tokenData = (await getOAuthAPI({}, resolvedConfig).getOAuth2AccessToken())?.data;
|
|
55
|
+
accessToken = tokenData?.accessToken;
|
|
56
|
+
expiryTimestamp = getExpiryTimestamp(tokenData);
|
|
57
|
+
};
|
|
58
|
+
pendingRefresh ??= doRefresh().finally(() => {
|
|
59
|
+
pendingRefresh = void 0;
|
|
60
|
+
});
|
|
61
|
+
await pendingRefresh;
|
|
62
|
+
};
|
|
63
|
+
const applyAuthHeader = () => {
|
|
64
|
+
if (!accessToken) return;
|
|
65
|
+
fetcherOptions.headers = {
|
|
66
|
+
...fetcherOptions.headers ?? {},
|
|
67
|
+
Authorization: `Bearer ${accessToken}`
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
const ensureAuth = async () => {
|
|
71
|
+
if (sessionToken) return;
|
|
72
|
+
if (needsRefresh()) await refreshToken();
|
|
73
|
+
applyAuthHeader();
|
|
74
|
+
};
|
|
75
|
+
const reset = () => {
|
|
76
|
+
accessToken = void 0;
|
|
77
|
+
expiryTimestamp = void 0;
|
|
78
|
+
};
|
|
79
|
+
const withAuth = (method, skipAuth = !hasCredentials) => {
|
|
80
|
+
if (skipAuth) return method;
|
|
81
|
+
return async (...args) => {
|
|
82
|
+
await ensureAuth();
|
|
83
|
+
try {
|
|
84
|
+
return await method(...args);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
if (sessionToken) throw error;
|
|
87
|
+
await refreshToken();
|
|
88
|
+
applyAuthHeader();
|
|
89
|
+
return await method(...args);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
const bindSection = (factory, bindOptions = {}) => {
|
|
94
|
+
const section = factory(fetcherOptions, resolvedConfig);
|
|
95
|
+
const skipAuth = bindOptions.skipAuth ?? !hasCredentials;
|
|
96
|
+
return new Proxy(section, { get(target, property, receiver) {
|
|
97
|
+
const value = Reflect.get(target, property, receiver);
|
|
98
|
+
if (typeof value !== "function") return value;
|
|
99
|
+
return withAuth(value.bind(target), skipAuth);
|
|
100
|
+
} });
|
|
101
|
+
};
|
|
102
|
+
return {
|
|
103
|
+
fetcherOptions,
|
|
104
|
+
intlayerConfig: resolvedConfig,
|
|
105
|
+
hasCredentials,
|
|
106
|
+
ensureAuth,
|
|
107
|
+
reset,
|
|
108
|
+
withAuth,
|
|
109
|
+
bindSection
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
export { createAuthManager };
|
|
115
|
+
//# sourceMappingURL=createAuthManager.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAuthManager.mjs","names":[],"sources":["../../../src/cms/createAuthManager.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { defu } from 'defu';\nimport type { FetcherOptions } from '../fetcher';\nimport { getOAuthAPI } from '../getIntlayerAPI/oAuth';\n\n/**\n * Shape of the various OAuth2 token payloads the backend may return. Only the\n * fields used to derive the expiration timestamp are described here.\n */\ntype OAuthTokenLike = {\n accessToken?: string;\n accessTokenExpiresAt?: string | Date;\n expires_in?: number;\n expiresIn?: number;\n expiresAt?: string | Date;\n};\n\n/**\n * Any asynchronous API method exposed by a domain section\n * (e.g. `getDictionaries`, `pushDictionaries`).\n */\ntype AsyncMethod<Arguments extends unknown[], Result> = (\n ...args: Arguments\n) => Promise<Result>;\n\n/**\n * A domain section factory: builds a plain object of async methods from shared\n * fetcher options and the Intlayer configuration.\n */\ntype SectionFactory<Section extends Record<string, unknown>> = (\n fetcherOptions: FetcherOptions,\n intlayerConfig: IntlayerConfig\n) => Section;\n\nconst ONE_MINUTE_MS = 60_000;\n\n/**\n * Resolves the expiration timestamp (in ms since epoch) from an OAuth2\n * token-like payload, supporting both absolute dates and relative durations.\n */\nconst getExpiryTimestamp = (\n token: OAuthTokenLike | undefined\n): number | undefined => {\n if (!token) return undefined;\n\n const dateLike = (token.accessTokenExpiresAt ?? token.expiresAt) as\n | string\n | Date\n | undefined;\n\n if (dateLike) {\n const timestamp =\n typeof dateLike === 'string'\n ? Date.parse(dateLike)\n : dateLike.getTime?.();\n if (typeof timestamp === 'number' && Number.isFinite(timestamp)) {\n return timestamp;\n }\n }\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\n return undefined;\n};\n\n/**\n * Options accepted when creating an {@link AuthManager}.\n */\nexport type AuthManagerOptions = {\n /**\n * Base fetcher options merged into every request (e.g. custom headers).\n */\n baseFetcherOptions?: FetcherOptions;\n /**\n * A pre-issued CLI session token (prefixed with `clisession_`). When provided,\n * it is used directly as the Bearer token and the OAuth2 `client_credentials`\n * exchange is skipped entirely.\n */\n sessionToken?: string;\n};\n\n/**\n * Options accepted when binding a domain section to an {@link AuthManager}.\n */\nexport type BindSectionOptions = {\n /**\n * Forces auth injection on (`false`) or off (`true`). Defaults to enabled\n * whenever credentials are available.\n */\n skipAuth?: boolean;\n};\n\n/**\n * Manages CMS authentication for a set of API calls.\n *\n * The manager owns a single mutable {@link FetcherOptions} object\n * (`fetcherOptions`). Domain factories bound through it share the same\n * reference, so refreshing the token in place transparently authenticates every\n * call — without rebuilding the API clients.\n */\nexport type AuthManager = {\n /**\n * Mutable fetcher options carrying the `Authorization` header. Bound sections\n * share this reference so the injected token is reused everywhere.\n */\n fetcherOptions: FetcherOptions;\n /**\n * The resolved Intlayer configuration (merged with the build-time defaults).\n */\n intlayerConfig: IntlayerConfig;\n /**\n * `true` when credentials are available — either a session token or a\n * `clientId`/`clientSecret` pair in the configuration.\n */\n hasCredentials: boolean;\n /**\n * Ensures a valid access token is available and applies it to\n * `fetcherOptions`. Called automatically by {@link withAuth}.\n */\n ensureAuth: () => Promise<void>;\n /**\n * Forces a token refresh on the next call by clearing the cached token.\n */\n reset: () => void;\n /**\n * Wraps a single API method so it injects (and, on failure, refreshes) the\n * access token on every invocation while preserving the method's signature.\n */\n withAuth: <Arguments extends unknown[], Result>(\n method: AsyncMethod<Arguments, Result>,\n skipAuth?: boolean\n ) => AsyncMethod<Arguments, Result>;\n /**\n * Instantiates a domain factory with the managed fetcher options and config,\n * returning a section whose every method authenticates automatically.\n *\n * @example\n * ```ts\n * const dictionary = authManager.bindSection(getDictionaryAPI);\n * await dictionary.pushDictionaries(dictionaries);\n * ```\n */\n bindSection: <Section extends Record<string, unknown>>(\n factory: SectionFactory<Section>,\n options?: BindSectionOptions\n ) => Section;\n};\n\n/**\n * Creates an instance-scoped {@link AuthManager} handling the OAuth2\n * `client_credentials` flow (or a pre-issued CLI session token).\n *\n * Unlike a global token cache, each manager keeps its own token state, so\n * independent SDK instances never interfere with one another.\n *\n * @param intlayerConfig - Intlayer configuration carrying the `editor`\n * credentials. Defaults to the build-time configuration.\n * @param options - Optional session token and base fetcher options.\n */\nexport const createAuthManager = (\n intlayerConfig: Pick<IntlayerConfig, 'editor'> = { editor },\n options: AuthManagerOptions = {}\n): AuthManager => {\n const { baseFetcherOptions = {}, sessionToken } = options;\n\n const resolvedConfig = defu(intlayerConfig ?? {}, {\n editor,\n }) as IntlayerConfig;\n\n // `credentials: 'omit'` prevents the browser from attaching session cookies;\n // authentication is handled exclusively through the injected Bearer token.\n // This is required because the backend only allows credentialed requests for\n // whitelisted first-party origins.\n const fetcherOptions: FetcherOptions = {\n ...baseFetcherOptions,\n credentials: 'omit',\n };\n\n const hasCredentials =\n Boolean(sessionToken) ||\n Boolean(\n resolvedConfig?.editor?.clientId && resolvedConfig?.editor?.clientSecret\n );\n\n // A session token is used as-is and never expires within the SDK's concern,\n // so inject it once up-front and skip the OAuth2 exchange.\n if (sessionToken) {\n fetcherOptions.headers = {\n ...(fetcherOptions.headers ?? {}),\n Authorization: `Bearer ${sessionToken}`,\n } as HeadersInit;\n }\n\n let accessToken: string | undefined;\n let expiryTimestamp: number | undefined;\n let pendingRefresh: Promise<void> | undefined;\n\n const needsRefresh = (): boolean => {\n if (!accessToken) return true;\n if (!expiryTimestamp) return false; // Unknown expiry: assume usable until failure.\n\n // Refresh one minute before the actual expiry to avoid edge-of-expiry races.\n return Date.now() + ONE_MINUTE_MS >= expiryTimestamp;\n };\n\n const refreshToken = async (): Promise<void> => {\n const doRefresh = async (): Promise<void> => {\n const oAuthAPI = getOAuthAPI({}, resolvedConfig);\n const response = await oAuthAPI.getOAuth2AccessToken();\n const tokenData = response?.data as OAuthTokenLike | undefined;\n\n accessToken = tokenData?.accessToken;\n expiryTimestamp = getExpiryTimestamp(tokenData);\n };\n\n // De-duplicate concurrent refreshes so a burst of calls triggers one fetch.\n pendingRefresh ??= doRefresh().finally(() => {\n pendingRefresh = undefined;\n });\n\n await pendingRefresh;\n };\n\n const applyAuthHeader = (): void => {\n if (!accessToken) return;\n fetcherOptions.headers = {\n ...(fetcherOptions.headers ?? {}),\n Authorization: `Bearer ${accessToken}`,\n } as HeadersInit;\n };\n\n const ensureAuth = async (): Promise<void> => {\n if (sessionToken) return; // Already injected; nothing to refresh.\n if (needsRefresh()) {\n await refreshToken();\n }\n applyAuthHeader();\n };\n\n const reset = (): void => {\n accessToken = undefined;\n expiryTimestamp = undefined;\n };\n\n const withAuth = <Arguments extends unknown[], Result>(\n method: AsyncMethod<Arguments, Result>,\n skipAuth = !hasCredentials\n ): AsyncMethod<Arguments, Result> => {\n if (skipAuth) return method;\n\n return async (...args: Arguments): Promise<Result> => {\n await ensureAuth();\n\n try {\n return await method(...args);\n } catch (error) {\n // The token may have been revoked or expired early: refresh once and\n // retry before surfacing the error. A session token cannot be\n // refreshed, so re-throw immediately in that case.\n if (sessionToken) throw error;\n\n await refreshToken();\n applyAuthHeader();\n return await method(...args);\n }\n };\n };\n\n const bindSection = <Section extends Record<string, unknown>>(\n factory: SectionFactory<Section>,\n bindOptions: BindSectionOptions = {}\n ): Section => {\n const section = factory(fetcherOptions, resolvedConfig);\n const skipAuth = bindOptions.skipAuth ?? !hasCredentials;\n\n return new Proxy(section, {\n get(target, property, receiver) {\n const value = Reflect.get(target, property, receiver);\n\n if (typeof value !== 'function') return value;\n\n return withAuth(\n (value as AsyncMethod<unknown[], unknown>).bind(target),\n skipAuth\n );\n },\n });\n };\n\n return {\n fetcherOptions,\n intlayerConfig: resolvedConfig,\n hasCredentials,\n ensureAuth,\n reset,\n withAuth,\n bindSection,\n };\n};\n"],"mappings":";;;;;AAmCA,MAAM,gBAAgB;;;;;AAMtB,MAAM,sBACJ,UACuB;AACvB,KAAI,CAAC,MAAO,QAAO;CAEnB,MAAM,WAAY,MAAM,wBAAwB,MAAM;AAKtD,KAAI,UAAU;EACZ,MAAM,YACJ,OAAO,aAAa,WAChB,KAAK,MAAM,SAAS,GACpB,SAAS,WAAW;AAC1B,MAAI,OAAO,cAAc,YAAY,OAAO,SAAS,UAAU,CAC7D,QAAO;;CAIX,MAAM,UAAU,MAAM,cAAc,MAAM;AAC1C,KAAI,OAAO,YAAY,YAAY,OAAO,SAAS,QAAQ,CACzD,QAAO,KAAK,KAAK,GAAG,UAAU;;;;;;;;;;;;;AAoGlC,MAAa,qBACX,iBAAiD,EAAE,QAAQ,EAC3D,UAA8B,EAAE,KAChB;CAChB,MAAM,EAAE,qBAAqB,EAAE,EAAE,iBAAiB;CAElD,MAAM,iBAAiB,KAAK,kBAAkB,EAAE,EAAE,EAChD,QACD,CAAC;CAMF,MAAM,iBAAiC;EACrC,GAAG;EACH,aAAa;EACd;CAED,MAAM,iBACJ,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,IAAI;CACJ,IAAI;CACJ,IAAI;CAEJ,MAAM,qBAA8B;AAClC,MAAI,CAAC,YAAa,QAAO;AACzB,MAAI,CAAC,gBAAiB,QAAO;AAG7B,SAAO,KAAK,KAAK,GAAG,iBAAiB;;CAGvC,MAAM,eAAe,YAA2B;EAC9C,MAAM,YAAY,YAA2B;GAG3C,MAAM,aAAY,MAFD,YAAY,EAAE,EAAE,eACF,CAAC,sBAAsB,GAC1B;AAE5B,iBAAc,WAAW;AACzB,qBAAkB,mBAAmB,UAAU;;AAIjD,qBAAmB,WAAW,CAAC,cAAc;AAC3C,oBAAiB;IACjB;AAEF,QAAM;;CAGR,MAAM,wBAA8B;AAClC,MAAI,CAAC,YAAa;AAClB,iBAAe,UAAU;GACvB,GAAI,eAAe,WAAW,EAAE;GAChC,eAAe,UAAU;GAC1B;;CAGH,MAAM,aAAa,YAA2B;AAC5C,MAAI,aAAc;AAClB,MAAI,cAAc,CAChB,OAAM,cAAc;AAEtB,mBAAiB;;CAGnB,MAAM,cAAoB;AACxB,gBAAc;AACd,oBAAkB;;CAGpB,MAAM,YACJ,QACA,WAAW,CAAC,mBACuB;AACnC,MAAI,SAAU,QAAO;AAErB,SAAO,OAAO,GAAG,SAAqC;AACpD,SAAM,YAAY;AAElB,OAAI;AACF,WAAO,MAAM,OAAO,GAAG,KAAK;YACrB,OAAO;AAId,QAAI,aAAc,OAAM;AAExB,UAAM,cAAc;AACpB,qBAAiB;AACjB,WAAO,MAAM,OAAO,GAAG,KAAK;;;;CAKlC,MAAM,eACJ,SACA,cAAkC,EAAE,KACxB;EACZ,MAAM,UAAU,QAAQ,gBAAgB,eAAe;EACvD,MAAM,WAAW,YAAY,YAAY,CAAC;AAE1C,SAAO,IAAI,MAAM,SAAS,EACxB,IAAI,QAAQ,UAAU,UAAU;GAC9B,MAAM,QAAQ,QAAQ,IAAI,QAAQ,UAAU,SAAS;AAErD,OAAI,OAAO,UAAU,WAAY,QAAO;AAExC,UAAO,SACJ,MAA0C,KAAK,OAAO,EACvD,SACD;KAEJ,CAAC;;AAGJ,QAAO;EACL;EACA,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createAuthManager } from "./createAuthManager.mjs";
|
|
2
|
+
import { editor } from "@intlayer/config/built";
|
|
3
|
+
|
|
4
|
+
//#region src/cms/createIntlayerCMS.ts
|
|
5
|
+
/**
|
|
6
|
+
* Creates an Intlayer CMS authenticator handling authentication automatically
|
|
7
|
+
* (OAuth2 `client_credentials`, or a CLI session token).
|
|
8
|
+
*
|
|
9
|
+
* This factory is intentionally lightweight: it does **not** bundle any domain
|
|
10
|
+
* client. Combine it with the per-domain endpoint binders — imported separately
|
|
11
|
+
* so only the domains you use are included in your bundle.
|
|
12
|
+
*
|
|
13
|
+
* The configuration is optional: when omitted, the credentials are read from the
|
|
14
|
+
* build-time configuration (`@intlayer/config/built`), which resolves the
|
|
15
|
+
* `INTLAYER_CLIENT_ID` / `INTLAYER_CLIENT_SECRET` environment variables.
|
|
16
|
+
*
|
|
17
|
+
* > Security: the CMS credentials grant write access to your content. Only ever
|
|
18
|
+
* > create the authenticator on the server side — never ship `clientId` /
|
|
19
|
+
* > `clientSecret` to the browser.
|
|
20
|
+
*
|
|
21
|
+
* @param intlayerConfig - Intlayer configuration carrying the `editor`
|
|
22
|
+
* credentials. Defaults to the build-time configuration.
|
|
23
|
+
* @param options - Optional CLI session token and base fetcher options.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { createIntlayerCMS } from '@intlayer/api';
|
|
28
|
+
* import { dictionaryEndpoint } from '@intlayer/api/dictionary';
|
|
29
|
+
*
|
|
30
|
+
* // Optional: reads INTLAYER_CLIENT_ID / INTLAYER_CLIENT_SECRET when omitted
|
|
31
|
+
* const cms = createIntlayerCMS();
|
|
32
|
+
*
|
|
33
|
+
* // Read
|
|
34
|
+
* const { data: dictionaries } = await dictionaryEndpoint(cms).getDictionaries();
|
|
35
|
+
*
|
|
36
|
+
* // Write
|
|
37
|
+
* await dictionaryEndpoint(cms).pushDictionaries([myDictionary]);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
const createIntlayerCMS = (intlayerConfig = { editor }, options = {}) => createAuthManager(intlayerConfig, options);
|
|
41
|
+
/**
|
|
42
|
+
* Turns a domain factory into a tree-shakeable endpoint binder.
|
|
43
|
+
*
|
|
44
|
+
* Each endpoint pulls in only its own domain client plus the auth machinery, so
|
|
45
|
+
* importing `dictionaryEndpoint` never bundles the project, AI, or any other
|
|
46
|
+
* domain.
|
|
47
|
+
*
|
|
48
|
+
* @param factory - The domain factory (e.g. `getDictionaryAPI`).
|
|
49
|
+
* @param options - Binding options, e.g. `{ skipAuth: true }` for the token
|
|
50
|
+
* endpoint itself.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* // inside @intlayer/api/dictionary
|
|
55
|
+
* export const dictionaryEndpoint = createEndpoint(getDictionaryAPI);
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
const createEndpoint = (factory, options) => (cms = createIntlayerCMS()) => cms.bindSection(factory, options);
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { createEndpoint, createIntlayerCMS };
|
|
62
|
+
//# sourceMappingURL=createIntlayerCMS.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createIntlayerCMS.mjs","names":[],"sources":["../../../src/cms/createIntlayerCMS.ts"],"sourcesContent":["import { editor } from '@intlayer/config/built';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { FetcherOptions } from '../fetcher';\nimport {\n type AuthManager,\n type AuthManagerOptions,\n type BindSectionOptions,\n createAuthManager,\n} from './createAuthManager';\n\n/**\n * Options accepted when creating the Intlayer CMS authenticator.\n */\nexport type IntlayerCMSOptions = AuthManagerOptions;\n\n/**\n * The Intlayer CMS authenticator returned by {@link createIntlayerCMS}.\n *\n * It is a lightweight object that holds the credentials and the managed token,\n * but knows nothing about individual domains. Pair it with a domain endpoint\n * (e.g. `dictionaryEndpoint`) to issue authenticated requests.\n */\nexport type IntlayerCMS = AuthManager;\n\n/**\n * Creates an Intlayer CMS authenticator handling authentication automatically\n * (OAuth2 `client_credentials`, or a CLI session token).\n *\n * This factory is intentionally lightweight: it does **not** bundle any domain\n * client. Combine it with the per-domain endpoint binders — imported separately\n * so only the domains you use are included in your bundle.\n *\n * The configuration is optional: when omitted, the credentials are read from the\n * build-time configuration (`@intlayer/config/built`), which resolves the\n * `INTLAYER_CLIENT_ID` / `INTLAYER_CLIENT_SECRET` environment variables.\n *\n * > Security: the CMS credentials grant write access to your content. Only ever\n * > create the authenticator on the server side — never ship `clientId` /\n * > `clientSecret` to the browser.\n *\n * @param intlayerConfig - Intlayer configuration carrying the `editor`\n * credentials. Defaults to the build-time configuration.\n * @param options - Optional CLI session token and base fetcher options.\n *\n * @example\n * ```ts\n * import { createIntlayerCMS } from '@intlayer/api';\n * import { dictionaryEndpoint } from '@intlayer/api/dictionary';\n *\n * // Optional: reads INTLAYER_CLIENT_ID / INTLAYER_CLIENT_SECRET when omitted\n * const cms = createIntlayerCMS();\n *\n * // Read\n * const { data: dictionaries } = await dictionaryEndpoint(cms).getDictionaries();\n *\n * // Write\n * await dictionaryEndpoint(cms).pushDictionaries([myDictionary]);\n * ```\n */\nexport const createIntlayerCMS = (\n intlayerConfig: Pick<IntlayerConfig, 'editor'> = { editor },\n options: IntlayerCMSOptions = {}\n): IntlayerCMS => createAuthManager(intlayerConfig, options);\n\n/**\n * A domain endpoint binder: given an authenticator (or none, in which case a\n * default one is created from the build-time configuration), returns the\n * authenticated domain section.\n */\nexport type CMSEndpoint<Section extends Record<string, unknown>> = (\n cms?: IntlayerCMS\n) => Section;\n\n/**\n * Turns a domain factory into a tree-shakeable endpoint binder.\n *\n * Each endpoint pulls in only its own domain client plus the auth machinery, so\n * importing `dictionaryEndpoint` never bundles the project, AI, or any other\n * domain.\n *\n * @param factory - The domain factory (e.g. `getDictionaryAPI`).\n * @param options - Binding options, e.g. `{ skipAuth: true }` for the token\n * endpoint itself.\n *\n * @example\n * ```ts\n * // inside @intlayer/api/dictionary\n * export const dictionaryEndpoint = createEndpoint(getDictionaryAPI);\n * ```\n */\nexport const createEndpoint =\n <Section extends Record<string, unknown>>(\n factory: (\n fetcherOptions: FetcherOptions,\n intlayerConfig: IntlayerConfig\n ) => Section,\n options?: BindSectionOptions\n ): CMSEndpoint<Section> =>\n (cms: IntlayerCMS = createIntlayerCMS()): Section =>\n cms.bindSection(factory, options);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAa,qBACX,iBAAiD,EAAE,QAAQ,EAC3D,UAA8B,EAAE,KAChB,kBAAkB,gBAAgB,QAAQ;;;;;;;;;;;;;;;;;;AA4B5D,MAAa,kBAET,SAIA,aAED,MAAmB,mBAAmB,KACrC,IAAI,YAAY,SAAS,QAAQ"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createIntlayerCMS } from "../cms/createIntlayerCMS.mjs";
|
|
2
|
+
import { dictionaryEndpoint } from "../getIntlayerAPI/dictionary.mjs";
|
|
2
3
|
|
|
3
4
|
//#region src/distantDictionary/fetchDistantDictionaries.ts
|
|
4
5
|
/**
|
|
@@ -8,7 +9,7 @@ const fetchDistantDictionaries = async (intlayerConfig) => {
|
|
|
8
9
|
try {
|
|
9
10
|
const { clientId, clientSecret } = intlayerConfig.editor;
|
|
10
11
|
if (!clientId || !clientSecret) throw new Error("Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.");
|
|
11
|
-
return (await
|
|
12
|
+
return (await dictionaryEndpoint(createIntlayerCMS(intlayerConfig)).getDictionaries()).data;
|
|
12
13
|
} catch (error) {
|
|
13
14
|
console.error(error);
|
|
14
15
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchDistantDictionaries.mjs","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"sourcesContent":["import type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport {
|
|
1
|
+
{"version":3,"file":"fetchDistantDictionaries.mjs","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionaries.ts"],"sourcesContent":["import type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createIntlayerCMS } from '../cms/createIntlayerCMS';\nimport { dictionaryEndpoint } from '../getIntlayerAPI/dictionary';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionaries = async (\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI[] | null | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const dictionary = dictionaryEndpoint(createIntlayerCMS(intlayerConfig));\n\n // Fetch the dictionary list\n const getDictionaryResult = await dictionary.getDictionaries();\n\n const distantDictionaries = getDictionaryResult.data;\n\n return distantDictionaries;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;;AAQA,MAAa,2BAA2B,OACtC,mBACgD;AAChD,KAAI;EACF,MAAM,EAAE,UAAU,iBAAiB,eAAe;AAElD,MAAI,CAAC,YAAY,CAAC,aAChB,OAAM,IAAI,MACR,yGACD;AAUH,UAF4B,MALT,mBAAmB,kBAAkB,eAAe,CAG3B,CAAC,iBAAiB,EAEd;UAGzC,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createIntlayerCMS } from "../cms/createIntlayerCMS.mjs";
|
|
2
|
+
import { dictionaryEndpoint } from "../getIntlayerAPI/dictionary.mjs";
|
|
2
3
|
|
|
3
4
|
//#region src/distantDictionary/fetchDistantDictionary.ts
|
|
4
5
|
/**
|
|
@@ -8,7 +9,7 @@ const fetchDistantDictionary = async (dictionaryKey, intlayerConfig) => {
|
|
|
8
9
|
try {
|
|
9
10
|
const { clientId, clientSecret } = intlayerConfig.editor;
|
|
10
11
|
if (!clientId || !clientSecret) throw new Error("Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.");
|
|
11
|
-
const distantDictionary = (await
|
|
12
|
+
const distantDictionary = (await dictionaryEndpoint(createIntlayerCMS(intlayerConfig)).getDictionary(dictionaryKey)).data;
|
|
12
13
|
if (!distantDictionary) throw new Error(`Dictionary ${dictionaryKey} not found on remote`);
|
|
13
14
|
return distantDictionary;
|
|
14
15
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchDistantDictionary.mjs","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["import type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport {
|
|
1
|
+
{"version":3,"file":"fetchDistantDictionary.mjs","names":[],"sources":["../../../src/distantDictionary/fetchDistantDictionary.ts"],"sourcesContent":["import type { DictionaryAPI } from '@intlayer/backend';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { createIntlayerCMS } from '../cms/createIntlayerCMS';\nimport { dictionaryEndpoint } from '../getIntlayerAPI/dictionary';\n\n/**\n * Fetch distant dictionary\n */\nexport const fetchDistantDictionary = async (\n dictionaryKey: string,\n intlayerConfig: IntlayerConfig\n): Promise<DictionaryAPI | undefined> => {\n try {\n const { clientId, clientSecret } = intlayerConfig.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://app.intlayer.org/project.'\n );\n }\n\n const dictionary = dictionaryEndpoint(createIntlayerCMS(intlayerConfig));\n\n // Fetch the dictionary\n const getDictionaryResult = await dictionary.getDictionary(dictionaryKey);\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n return distantDictionary;\n } catch (error) {\n console.error(error);\n return undefined;\n }\n};\n"],"mappings":";;;;;;;AAQA,MAAa,yBAAyB,OACpC,eACA,mBACuC;AACvC,KAAI;EACF,MAAM,EAAE,UAAU,iBAAiB,eAAe;AAElD,MAAI,CAAC,YAAY,CAAC,aAChB,OAAM,IAAI,MACR,yGACD;EAQH,MAAM,qBAAoB,MALP,mBAAmB,kBAAkB,eAAe,CAG3B,CAAC,cAAc,cAAc,EAE3B;AAE9C,MAAI,CAAC,kBACH,OAAM,IAAI,MAAM,cAAc,cAAc,sBAAsB;AAGpE,SAAO;UACA,OAAO;AACd,UAAQ,MAAM,MAAM;AACpB"}
|
|
@@ -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/ai.ts
|
|
@@ -222,7 +223,14 @@ const getAiAPI = (authAPIOptions = {}, intlayerConfig) => {
|
|
|
222
223
|
getAIStats
|
|
223
224
|
};
|
|
224
225
|
};
|
|
226
|
+
/**
|
|
227
|
+
* Authenticated `ai` endpoint bound to an Intlayer CMS authenticator.
|
|
228
|
+
*
|
|
229
|
+
* Pass an authenticator created with `createIntlayerCMS`, or omit it to use
|
|
230
|
+
* the build-time configuration (`@intlayer/config/built`).
|
|
231
|
+
*/
|
|
232
|
+
const aiEndpoint = createEndpoint(getAiAPI);
|
|
225
233
|
|
|
226
234
|
//#endregion
|
|
227
|
-
export { getAiAPI };
|
|
235
|
+
export { aiEndpoint, getAiAPI };
|
|
228
236
|
//# sourceMappingURL=ai.mjs.map
|