diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dd571ceeab..751d015852 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,5 @@ -name: CI/CD Pipeline +name: 🚀 Publish to NPM + on: push: tags: @@ -58,6 +59,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: write + outputs: + version: ${{ steps.version.outputs.version }} steps: - name: 🔄 Checkout repository uses: actions/checkout@v4 diff --git a/.npmignore b/.npmignore index f3e42a2920..10b3f984c4 100644 --- a/.npmignore +++ b/.npmignore @@ -6,7 +6,7 @@ coverage .idea examples -eslint.config.js +eslint.config.ts .editorconfig .DS_Store pnpm-lock.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 09ab8052cd..178c6fe848 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Jira.js changelog +## 5.2.0 + +### Build & Distribution Improvements +- Added `rollup-plugin-node-externals` to transform `ESNext` `import`/`export` syntax to `NodeNext` format +- Restructured `dist` files to preserve modules + +### Documentation Updates +- Updated tree shaking description in `README.md` +- Redesigned `README.md` with a new "Getting Started" section + ## 5.1.1 - Fixing CommonJS requiring. Thanks to solshark ([solshark](https://github.com/solshark)) for reporting this issue ([#381](https://github.com/MrRefactoring/jira.js/issues/381)) diff --git a/README.md b/README.md index d994d69828..a7784fb5c8 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,59 @@
Jira.js logo - NPM version - NPM downloads per month - build status - license + NPM version + NPM downloads per month + build status + license - JavaScript / TypeScript library for Node.JS and browsers to easily interact with Atlassian Jira API + JavaScript / TypeScript library for Node.js and browsers to interact with Atlassian Jira APIs
## About -Jira.js is a powerful [Node.JS](https://nodejs.org/) / Browser module that allows you to interact with the [Jira Cloud API](https://developer.atlassian.com/cloud/jira/platform/rest/), [Jira Agile Cloud API](https://developer.atlassian.com/cloud/jira/software/rest/intro/), [Jira ServiceDesk Cloud API](https://developer.atlassian.com/cloud/jira/service-desk/rest/intro/) very easily. +Jira.js is a powerful [Node.js](https://nodejs.org/) and browser-compatible module that provides seamless interaction with: +- [Jira Cloud API](https://developer.atlassian.com/cloud/jira/platform/rest/) +- [Jira Agile Cloud API](https://developer.atlassian.com/cloud/jira/software/rest/intro/) +- [Jira ServiceDesk Cloud API](https://developer.atlassian.com/cloud/jira/service-desk/rest/intro/) -Usability, consistency, and performance are key focuses of jira.js, and it also has nearly 100% coverage of the Jira API. It receives new Jira features shortly after they arrive in the API. +Designed for usability, consistency, and performance, it covers nearly 100% of Jira APIs and stays updated with new features. ## Table of Contents -- [Installation](#installation) +- [Getting Started](#getting-started) + - [Installation](#installation) + - [Quick Example](#quick-example) - [Documentation](#documentation) - [Usage](#usage) - [Authentication](#authentication) - - [Email and ApiToken](#email-and-api-token) + - [Email and API Token](#email-and-api-token) - [OAuth 2.0](#oauth-20) - - [Error handling](#error-handling) - - [Example and using algorithm](#example-and-using-algorithm) -- [Decreasing Webpack bundle size](#decreasing-webpack-bundle-size) -- [Take a look at our other products](#take-a-look-at-our-other-products) + - [Error Handling](#error-handling) + - [API Structure](#api-structure) +- [Tree Shaking](#tree-shaking) +- [Other Products](#other-products) - [License](#license) -## Installation +## Getting Started -**Node.js 20.0.0 or newer is required.** +### Installation -Install with the npm: +**Requires Node.js 20.0.0 or newer.** ```bash +# Using npm npm install jira.js -``` - -Install with the yarn: -```bash +# Using yarn yarn add jira.js -``` - -## Documentation - -You can find the documentation [here](https://mrrefactoring.github.io/jira.js/). - -## Usage - -#### Authentication -There are several types of authentication to gain access to the Jira API. Let's take a look at a few of them below: - -##### Email and API Token +# Using pnpm +pnpm add jira.js +``` -To create an API Token, use this link: [https://id.atlassian.com/manage-profile/security/api-tokens](https://id.atlassian.com/manage-profile/security/api-tokens) +### Quick Example -Example of usage +Create your first Jira issue in under 5 minutes: ```typescript import { Version3Client } from 'jira.js'; @@ -68,132 +62,103 @@ const client = new Version3Client({ host: 'https://your-domain.atlassian.net', authentication: { basic: { - email: 'YOUR@EMAIL.ORG', - apiToken: 'YOUR_API_TOKEN', + email: 'your@email.com', + apiToken: 'YOUR_API_TOKEN', // Create one: https://id.atlassian.com/manage-profile/security/api-tokens }, }, }); -``` - -##### [OAuth 2.0](https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/) -Only the authorization token is currently supported. To release it, you need to read the [documentation](https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/) and write your own code to get the token. +async function createIssue() { + const project = await client.projects.getProject({ projectIdOrKey: 'Your project id or key' }); -Example of usage + const newIssue = await client.issues.createIssue({ + fields: { + summary: 'Hello Jira.js!', + issuetype: { name: 'Task' }, + project: { key: project.key }, + }, + }); -```typescript -import { Version3Client } from 'jira.js'; + console.log(`Issue created: ${newIssue.id}`); +} -const client = new Version3Client({ - host: 'https://your-domain.atlassian.net', - authentication: { - oauth2: { - accessToken: 'YOUR_ACCESS_TOKEN', - }, - }, -}); +createIssue(); ``` +## Documentation -#### Error handling -Starting from version 4.0.0, the library has a new error handling system. -Now, all errors are instances of - - the `HttpException` class in case the Axios has response from the server; - - the `AxiosError` class in case something went wrong before sending the request. +Full API reference and guides available at: +[https://mrrefactoring.github.io/jira.js/](https://mrrefactoring.github.io/jira.js/) -The `HttpException` class tries to parse different sorts of responses from the server to provide a unified error class. +## Usage -If the original error is required, you can get it from the `cause` property of the `HttpException` class. +### Authentication -```typescript -try { - const users = await this.client.userSearch.findUsers({ query: email }); - // ... -} catch (error: unknown) { - if (error instanceof HttpException) { - console.log(error.message); - console.log(error.cause); // original error (AxiosError | Error) - console.log(error.cause.response?.headers); // headers from the server - } else if (error instanceof AxiosError) { - console.log(error.message); - console.log(error.code); // error code, for instance AxiosError.ETIMEDOUT - } else { - console.log(error); - } -} -``` +#### Email and API Token -#### Example and using algorithm +1. Create an API token: [https://id.atlassian.com/manage-profile/security/api-tokens](https://id.atlassian.com/manage-profile/security/api-tokens) +2. Configure the client: -1. Example +```typescript +const client = new Version3Client({ + host: 'https://your-domain.atlassian.net', + authentication: { + basic: { email: 'YOUR@EMAIL.ORG', apiToken: 'YOUR_API_TOKEN' }, + }, +}); +``` -You can find out [examples project here](https://github.com/MrRefactoring/jira.js/tree/master/examples) or perform the following actions: +#### OAuth 2.0 - - Change the `host`, `email` and `apiToken` to your data - - Run script +Only authorization code grants are supported. Implement your own token acquisition flow using Atlassian's [OAuth 2.0 documentation](https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/). ```typescript -import { Version3Client } from 'jira.js'; - const client = new Version3Client({ - host, + host: 'https://your-domain.atlassian.net', authentication: { - basic: { - email, - apiToken, - }, + oauth2: { accessToken: 'YOUR_ACCESS_TOKEN' }, }, }); +``` -async function main() { - const { values: projects } = await client.projects.searchProjects(); - - if (projects.length) { - const project = projects[0]; +### Error Handling - const { id } = await client.issues.createIssue({ - fields: { - summary: 'My first issue', - issuetype: { - name: 'Task' - }, - project: { - key: project.key, - }, - } - }); +Errors are categorized as: +- `HttpException`: Server responded with an error (includes parsed error details) +- `AxiosError`: Network/configuration issues (e.g., timeouts) - const issue = await client.issues.getIssue({ issueIdOrKey: id }); +**Example handling:** - console.log(`Issue '${issue.fields.summary}' was successfully added to '${project.name}' project.`); +```typescript +try { + await client.issues.getIssue({ issueIdOrKey: 'INVALID-123' }); +} catch (error) { + if (error instanceof HttpException) { + console.error('Server error:', error.message); + console.debug('Response headers:', error.cause.response?.headers); + } else if (error instanceof AxiosError) { + console.error('Network error:', error.code); } else { - const myself = await client.myself.getCurrentUser(); - - const { id } = await client.projects.createProject({ - key: 'PROJECT', - name: "My Project", - leadAccountId: myself.accountId, - projectTypeKey: 'software', - }); - - const project = await client.projects.getProject({ projectIdOrKey: id.toString() }); - - console.log(`Project '${project.name}' was successfully created.`); + console.error('Unexpected error:', error); } } - -main(); ``` -2. The algorithm for using the library: +### API Structure + +Access endpoints using the `client..` pattern: ```typescript -client..(parametersObject); +// Get all projects +const projects = await client.projects.searchProjects(); + +// Create a sprint +const sprint = await client.sprint.createSprint({ name: 'Q4 Sprint' }); ``` -Available groups: -
- Agile Cloud API group +**Available API groups:** +
+ 🔽 Agile Cloud API - [backlog](https://developer.atlassian.com/cloud/jira/software/rest/api-group-backlog/#api-group-backlog) - [board](https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-group-board) @@ -208,108 +173,10 @@ Available groups: - [remoteLinks](https://developer.atlassian.com/cloud/jira/software/rest/api-group-remote-links/#api-group-remote-links) - [securityInformation](https://developer.atlassian.com/cloud/jira/software/rest/api-group-security-information/#api-group-security-information) - [sprint](https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-group-sprint) -
-
- Version 2 Cloud REST API group - - - [announcementBanner](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-announcement-banner/#api-group-announcement-banner) - - [appDataPolicies](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-app-data-policies/#api-group-app-data-policies) - - [applicationRoles](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-application-roles/#api-group-application-roles) - - [appMigration](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-app-migration/#api-group-app-migration) - - [auditRecords](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-audit-records/#api-group-audit-records) - - [avatars](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-avatars/#api-group-avatars) - - [classificationLevels](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-classification-levels/#api-group-classification-levels) - - [dashboards](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-dashboards/#api-group-dashboards) - - [filters](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-filters/#api-group-filters) - - [filterSharing](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-filter-sharing/#api-group-filter-sharing) - - [groupAndUserPicker](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-group-and-user-picker/#api-group-group-and-user-picker) - - [groups](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-groups/#api-group-groups) - - [issues](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/#api-group-issues) - - [issueAttachments](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-attachments/#api-group-issue-attachments) - - [issueComments](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-comments/#api-group-issue-comments) - - [issueCustomFieldAssociations](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-custom-field-associations/#api-group-issue-custom-field-associations) - - [issueCustomFieldConfigurationApps](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-custom-field-configuration--apps-/#api-group-issue-custom-field-configuration--apps-) - - [issueCommentProperties](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-comment-properties/#api-group-issue-comment-properties) - - [issueFields](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-fields/#api-group-issue-fields) - - [issueFieldConfigurations](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-field-configurations/#api-group-issue-field-configurations) - - [issueCustomFieldContexts](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-custom-field-contexts/#api-group-issue-custom-field-contexts) - - [issueCustomFieldOptions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-custom-field-options/#api-group-issue-custom-field-options) - - [issueCustomFieldOptionsApps](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-custom-field-options--apps-/#api-group-issue-custom-field-options--apps-) - - [issueCustomFieldValuesApps](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-custom-field-values--apps-/#api-group-issue-custom-field-values--apps-) - - [issueLinks](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-links/#api-group-issue-links) - - [issueLinkTypes](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-link-types/#api-group-issue-link-types) - - [issueNavigatorSettings](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-navigator-settings/#api-group-issue-navigator-settings) - - [issueNotificationSchemes](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-notification-schemes/#api-group-issue-notification-schemes) - - [issuePriorities](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-priorities/#api-group-issue-priorities) - - [issueProperties](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-properties/#api-group-issue-properties) - - [issueRemoteLinks](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-remote-links/#api-group-issue-remote-links) - - [issueResolutions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-resolutions/#api-group-issue-resolutions) - - [issueSearch](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-search/#api-group-issue-search) - - [issueSecurityLevel](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-security-level/#api-group-issue-security-level) - - [issueSecuritySchemes](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-security-schemes/#api-group-issue-security-schemes) - - [issueTypes](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-types/#api-group-issue-types) - - [issueTypeSchemes](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-type-schemes/#api-group-issue-type-schemes) - - [issueTypeScreenSchemes](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-type-screen-schemes/#api-group-issue-type-screen-schemes) - - [issueTypeProperties](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-type-properties/#api-group-issue-type-properties) - - [issueVotes](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-votes/#api-group-issue-votes) - - [issueWatchers](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-watchers/#api-group-issue-watchers) - - [issueWorklogs](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-worklogs/#api-group-issue-worklogs) - - [issueWorklogProperties](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-worklog-properties/#api-group-issue-worklog-properties) - - [jiraExpressions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-jira-expressions/#api-group-jira-expressions) - - [jiraSettings](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-jira-settings/#api-group-jira-settings) - - [jql](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-jql/#api-group-jql) - - [jqlFunctionsApps](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-jql-functions--apps-/#api-group-jql-functions--apps-) - - [labels](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-labels/#api-group-labels) - - [licenseMetrics](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-license-metrics/#api-group-license-metrics) - - [myself](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-myself/#api-group-myself) - - [permissions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-permissions/#api-group-permissions) - - [permissionSchemes](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-permission-schemes/#api-group-permission-schemes) - - [plans](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-plans/#api-group-plans) - - [prioritySchemes](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-priority-schemes/#api-group-priority-schemes) - - [projects](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-projects/#api-group-projects) - - [projectTemplates](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-templates/#api-group-project-templates) - - [projectAvatars](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-avatars/#api-group-project-avatars) - - [projectCategories](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-categories/#api-group-project-categories) - - [projectClassificationLevels](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-classification-levels/#api-group-project-classification-levels) - - [projectComponents](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-components/#api-group-project-components) - - [projectEmail](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-email/#api-group-project-email) - - [projectFeatures](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-features/#api-group-project-features) - - [projectKeyAndNameValidation](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-key-and-name-validation/#api-group-project-key-and-name-validation) - - [projectPermissionSchemes](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-permission-schemes/#api-group-project-permission-schemes) - - [projectProperties](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-properties/#api-group-project-properties) - - [projectRoles](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-roles/#api-group-project-roles) - - [projectRoleActors](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-role-actors/#api-group-project-role-actors) - - [projectTypes](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-types/#api-group-project-types) - - [projectVersions](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-project-versions/#api-group-project-versions) - - [screens](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-screens/#api-group-screens) - - [screenTabs](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-screen-tabs/#api-group-screen-tabs) - - [screenTabFields](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-screen-tab-fields/#api-group-screen-tab-fields) - - [screenSchemes](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-screen-schemes/#api-group-screen-schemes) - - [serverInfo](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-server-info/#api-group-server-info) - - [serviceRegistry](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-service-registry/#api-group-service-registry) - - [status](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-status/#api-group-status) - - [tasks](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-tasks/#api-group-tasks) - - [teamsInPlan](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-teams-in-plan/#api-group-teams-in-plan) - - [timeTracking](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-time-tracking/#api-group-time-tracking) - - [uiModificationsApps](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-ui-modifications--apps-/#api-group-ui-modifications--apps-) - - [userNavProperties](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-other-operations/#api-group-other-operations) - - [users](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-users/#api-group-users) - - [userProperties](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-user-properties/#api-group-user-properties) - - [userSearch](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-user-search/#api-group-user-search) - - [webhooks](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-webhooks/#api-group-webhooks) - - [workflows](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-workflows/#api-group-workflows) - - [workflowTransitionRules](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-workflow-transition-rules/#api-group-workflow-transition-rules) - - [workflowSchemes](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-workflow-schemes/#api-group-workflow-schemes) - - [workflowSchemeProjectAssociations](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-workflow-scheme-project-associations/#api-group-workflow-scheme-project-associations) - - [workflowSchemeDrafts](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-workflow-scheme-drafts/#api-group-workflow-scheme-drafts) - - [workflowStatuses](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-workflow-statuses/#api-group-workflow-statuses) - - [workflowStatusCategories](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-workflow-status-categories/#api-group-workflow-status-categories) - - [workflowTransitionProperties](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-workflow-transition-properties/#api-group-workflow-transition-properties) - - [appProperties](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-app-properties/#api-group-app-properties) - - [dynamicModules](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-dynamic-modules/#api-group-dynamic-modules) -
-
- Version 3 Cloud REST API group +
+ +
+ 🔽 Core REST API (v2/v3) - [announcementBanner](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-announcement-banner/#api-group-announcement-banner) - [appDataPolicy](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-app-data-policies/#api-group-app-data-policies) @@ -408,9 +275,10 @@ Available groups: - [workflowTransitionProperties](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-workflow-transition-properties/#api-group-workflow-transition-properties) - [appProperties](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-app-properties/#api-group-app-properties) - [dynamicModules](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-dynamic-modules/#api-group-dynamic-modules) -
-
- Service Desk Cloud API group +
+ +
+ 🔽 Service Desk API - [customer](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-customer/) - [info](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-info/#api-group-info) @@ -420,34 +288,37 @@ Available groups: - [request](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-group-request) - [requestType](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-requesttype/#api-group-requesttype) - [serviceDesk](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-servicedesk/#api-group-servicedesk) -
+
-The name of the methods is the name of the endpoint in the group without spaces and in `camelCase`. +See full group list in [original documentation](#usage). -The parameters depend on the specific endpoint. For more information, [see here](https://mrrefactoring.github.io/jira.js/). +## Tree Shaking -## Decreasing Webpack bundle size - -If you use Webpack and need to reduce the size of the assembly, you can create your client with only the groups you use. +Optimize bundle size by importing only needed modules: ```typescript +// custom-client.ts import { BaseClient } from 'jira.js'; -import { Board } from 'jira.js/out/agile'; -import { Groups } from 'jira.js/out/version2'; -import { Issues } from 'jira.js/out/version3'; +import { Issues } from 'jira.js/version3'; +import { Board } from 'jira.js/agile'; -export class CustomJiraClient extends BaseClient { - board = new Board(this); - groups = new Groups(this); +export class CustomClient extends BaseClient { issues = new Issues(this); + board = new Board(this); } + +// Usage +const client = new CustomClient({ /* config */ }); +await client.issues.getIssue({ issueIdOrKey: 'KEY-1' }); ``` -## Take a look at our other products +## Other Products -* [Confluence.js](https://github.com/MrRefactoring/confluence.js) - confluence.js is a powerful Node.JS / Browser module that allows you to interact with the Confluence API very easily -* [Trello.js](https://github.com/MrRefactoring/trello.js) - JavaScript / TypeScript library for Node.JS and browsers to easily interact with Atlassian Trello API +Explore our other Atlassian integration libraries: +- [Confluence.js](https://github.com/MrRefactoring/confluence.js) - Interact with Confluence API +- [Trello.js](https://github.com/MrRefactoring/trello.js) - Trello API integration ## License -Distributed under the MIT License. See `LICENSE` for more information. +MIT License © MrRefactoring +See [LICENSE](https://github.com/mrrefactoring/jira.js/blob/develop/LICENSE) for details. diff --git a/eslint.config.js b/eslint.config.ts similarity index 97% rename from eslint.config.js rename to eslint.config.ts index fe1e14acae..2954ddc6ec 100644 --- a/eslint.config.js +++ b/eslint.config.ts @@ -12,7 +12,6 @@ export default defineConfig([ { languageOptions: { parserOptions: { - project: './tsconfig.lint.json', projectService: true, tsconfigRootDir: import.meta.dirname, }, @@ -57,6 +56,7 @@ export default defineConfig([ '@typescript-eslint/no-unsafe-call': 'off', // todo fix it '@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/prefer-optional-chain': 'error', + '@stylistic/ts/object-curly-spacing': ["error", "always"] }, }, ]); diff --git a/package.json b/package.json index e2fedbc455..8308243cd9 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,48 @@ { "name": "jira.js", - "version": "5.1.1", + "version": "5.2.0", "description": "A comprehensive JavaScript/TypeScript library designed for both Node.JS and browsers, facilitating seamless interaction with the Atlassian Jira API.", "repository": "https://github.com/MrRefactoring/jira.js.git", "homepage": "https://mrrefactoring.github.io/jira.js", "author": "Vladislav Tupikin ", "license": "MIT", "type": "module", + "types": "./dist/esm/types/index.d.ts", + "module": "./dist/esm/index.mjs", + "main": "./dist/cjs/index.cjs", + "exports": { + ".": { + "types": "./dist/esm/types/index.d.ts", + "import": "./dist/esm/index.mjs", + "require": "./dist/cjs/index.cjs" + }, + "./*": { + "types": "./dist/esm/types/*.d.ts", + "import": "./dist/esm/*.mjs", + "require": "./dist/cjs/*.cjs" + }, + "./agile": { + "types": "./dist/esm/types/agile/index.d.ts", + "import": "./dist/esm/agile/index.mjs", + "require": "./dist/cjs/agile/index.cjs" + }, + "./version2": { + "types": "./dist/esm/types/version2/index.d.ts", + "import": "./dist/esm/version2/index.mjs", + "require": "./dist/cjs/version2/index.cjs" + }, + "./version3": { + "types": "./dist/esm/types/version3/index.d.ts", + "import": "./dist/esm/version3/index.mjs", + "require": "./dist/cjs/version3/index.cjs" + }, + "./serviceDesk": { + "types": "./dist/esm/types/serviceDesk/index.d.ts", + "import": "./dist/esm/serviceDesk/index.mjs", + "require": "./dist/cjs/serviceDesk/index.cjs" + }, + "./package.json": "./package.json" + }, "keywords": [ "jira", "javascript", @@ -31,21 +67,11 @@ "axios" ], "engines": { - "node": ">=20.0.0" - }, - "types": "./dist/index.d.ts", - "module": "./dist/index.mjs", - "main": "./dist/index.cjs", - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.cjs" - } + "node": ">=20" }, "scripts": { "build": "pnpm run build:src && pnpm run build:tests", - "build:src": "rollup -c rollup.config.ts --configPlugin typescript && ts-add-js-extension --dir=dist --showchanges=false", + "build:src": "rollup -c rollup.config.ts --configPlugin typescript", "build:tests": "tsc --project tests/tsconfig.json", "prettier": "prettier --write src", "lint": "pnpm run lint:tests && pnpm run lint:src:agile && pnpm run lint:src:clients && pnpm run lint:src:services && pnpm run lint:src:version2 && pnpm run lint:src:version3 && pnpm run lint:src:files", @@ -102,20 +128,22 @@ "@rollup/plugin-typescript": "^12.1.2", "@stylistic/eslint-plugin-js": "^4.2.0", "@stylistic/eslint-plugin-ts": "^4.2.0", - "@types/node": "^20.17.41", + "@types/node": "^20.17.47", "@types/sinon": "^17.0.4", "dotenv": "^16.5.0", "eslint": "^9.26.0", - "globals": "^16.0.0", + "globals": "^16.1.0", + "jiti": "^2.4.2", "prettier": "^3.5.3", "prettier-plugin-jsdoc": "^1.3.2", "rollup": "^4.40.2", + "rollup-plugin-esnext-to-nodenext": "^1.0.0", + "rollup-plugin-node-externals": "^8.0.0", "sinon": "^20.0.0", - "ts-add-js-extension": "^1.6.5", "tslib": "^2.8.1", "typedoc": "^0.28.4", "typescript": "^5.8.3", - "typescript-eslint": "^8.32.0", + "typescript-eslint": "^8.32.1", "vitest": "^3.1.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 38e455c38a..9477f317a0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,13 +35,13 @@ importers: version: 12.1.2(rollup@4.40.2)(tslib@2.8.1)(typescript@5.8.3) '@stylistic/eslint-plugin-js': specifier: ^4.2.0 - version: 4.2.0(eslint@9.26.0) + version: 4.2.0(eslint@9.26.0(jiti@2.4.2)) '@stylistic/eslint-plugin-ts': specifier: ^4.2.0 - version: 4.2.0(eslint@9.26.0)(typescript@5.8.3) + version: 4.2.0(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3) '@types/node': - specifier: ^20.17.41 - version: 20.17.43 + specifier: ^20.17.47 + version: 20.17.47 '@types/sinon': specifier: ^17.0.4 version: 17.0.4 @@ -50,10 +50,13 @@ importers: version: 16.5.0 eslint: specifier: ^9.26.0 - version: 9.26.0 + version: 9.26.0(jiti@2.4.2) globals: - specifier: ^16.0.0 - version: 16.0.0 + specifier: ^16.1.0 + version: 16.1.0 + jiti: + specifier: ^2.4.2 + version: 2.4.2 prettier: specifier: ^3.5.3 version: 3.5.3 @@ -63,12 +66,15 @@ importers: rollup: specifier: ^4.40.2 version: 4.40.2 + rollup-plugin-esnext-to-nodenext: + specifier: ^1.0.0 + version: 1.0.0(rollup@4.40.2) + rollup-plugin-node-externals: + specifier: ^8.0.0 + version: 8.0.0(rollup@4.40.2) sinon: specifier: ^20.0.0 version: 20.0.0 - ts-add-js-extension: - specifier: ^1.6.5 - version: 1.6.5 tslib: specifier: ^2.8.1 version: 2.8.1 @@ -79,11 +85,11 @@ importers: specifier: ^5.8.3 version: 5.8.3 typescript-eslint: - specifier: ^8.32.0 - version: 8.32.0(eslint@9.26.0)(typescript@5.8.3) + specifier: ^8.32.1 + version: 8.32.1(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3) vitest: specifier: ^3.1.3 - version: 3.1.3(@types/debug@4.1.12)(@types/node@20.17.43)(yaml@2.7.1) + version: 3.1.3(@types/debug@4.1.12)(@types/node@20.17.47)(jiti@2.4.2)(yaml@2.7.1) packages: @@ -520,8 +526,8 @@ packages: '@types/ms@2.1.0': resolution: {integrity: sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==} - '@types/node@20.17.43': - resolution: {integrity: sha512-DnDEcDUnVAUYSa7U03QvrXbj1MZj00xoyi/a3lRGkR/c7BFUnqv+OY9EUphMqXUKdZJEOmuzu2mm+LmCisnPow==} + '@types/node@20.17.47': + resolution: {integrity: sha512-3dLX0Upo1v7RvUimvxLeXqwrfyKxUINk0EAM83swP2mlSUcwV73sZy8XhNz8bcZ3VbsfQyC/y6jRdL5tgCNpDQ==} '@types/resolve@1.20.2': resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} @@ -535,16 +541,16 @@ packages: '@types/unist@3.0.3': resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==} - '@typescript-eslint/eslint-plugin@8.32.0': - resolution: {integrity: sha512-/jU9ettcntkBFmWUzzGgsClEi2ZFiikMX5eEQsmxIAWMOn4H3D4rvHssstmAHGVvrYnaMqdWWWg0b5M6IN/MTQ==} + '@typescript-eslint/eslint-plugin@8.32.1': + resolution: {integrity: sha512-6u6Plg9nP/J1GRpe/vcjjabo6Uc5YQPAMxsgQyGC/I0RuukiG1wIe3+Vtg3IrSCVJDmqK3j8adrtzXSENRtFgg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: '@typescript-eslint/parser': ^8.0.0 || ^8.0.0-alpha.0 eslint: ^8.57.0 || ^9.0.0 typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/parser@8.32.0': - resolution: {integrity: sha512-B2MdzyWxCE2+SqiZHAjPphft+/2x2FlO9YBx7eKE1BCb+rqBlQdhtAEhzIEdozHd55DXPmxBdpMygFJjfjjA9A==} + '@typescript-eslint/parser@8.32.1': + resolution: {integrity: sha512-LKMrmwCPoLhM45Z00O1ulb6jwyVr2kr3XJp+G+tSEZcbauNnScewcQwtJqXDhXeYPDEjZ8C1SjXm015CirEmGg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -554,8 +560,12 @@ packages: resolution: {integrity: sha512-jc/4IxGNedXkmG4mx4nJTILb6TMjL66D41vyeaPWvDUmeYQzF3lKtN15WsAeTr65ce4mPxwopPSo1yUUAWw0hQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/type-utils@8.32.0': - resolution: {integrity: sha512-t2vouuYQKEKSLtJaa5bB4jHeha2HJczQ6E5IXPDPgIty9EqcJxpr1QHQ86YyIPwDwxvUmLfP2YADQ5ZY4qddZg==} + '@typescript-eslint/scope-manager@8.32.1': + resolution: {integrity: sha512-7IsIaIDeZn7kffk7qXC3o6Z4UblZJKV3UBpkvRNpr5NSyLji7tvTcvmnMNYuYLyh26mN8W723xpo3i4MlD33vA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@typescript-eslint/type-utils@8.32.1': + resolution: {integrity: sha512-mv9YpQGA8iIsl5KyUPi+FGLm7+bA4fgXaeRcFKRDRwDMu4iwrSHeDPipwueNXhdIIZltwCJv+NkxftECbIZWfA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -565,12 +575,22 @@ packages: resolution: {integrity: sha512-O5Id6tGadAZEMThM6L9HmVf5hQUXNSxLVKeGJYWNhhVseps/0LddMkp7//VDkzwJ69lPL0UmZdcZwggj9akJaA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@typescript-eslint/types@8.32.1': + resolution: {integrity: sha512-YmybwXUJcgGqgAp6bEsgpPXEg6dcCyPyCSr0CAAueacR/CCBi25G3V8gGQ2kRzQRBNol7VQknxMs9HvVa9Rvfg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@typescript-eslint/typescript-estree@8.32.0': resolution: {integrity: sha512-pU9VD7anSCOIoBFnhTGfOzlVFQIA1XXiQpH/CezqOBaDppRwTglJzCC6fUQGpfwey4T183NKhF1/mfatYmjRqQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '>=4.8.4 <5.9.0' + '@typescript-eslint/typescript-estree@8.32.1': + resolution: {integrity: sha512-Y3AP9EIfYwBb4kWGb+simvPaqQoT5oJuzzj9m0i6FCY6SPvlomY2Ei4UEMm7+FXtlNJbor80ximyslzaQF6xhg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <5.9.0' + '@typescript-eslint/utils@8.32.0': resolution: {integrity: sha512-8S9hXau6nQ/sYVtC3D6ISIDoJzS1NsCK+gluVhLN2YkBPX+/1wkwyUiDKnxRh15579WoOIyVWnoyIf3yGI9REw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -578,10 +598,21 @@ packages: eslint: ^8.57.0 || ^9.0.0 typescript: '>=4.8.4 <5.9.0' + '@typescript-eslint/utils@8.32.1': + resolution: {integrity: sha512-DsSFNIgLSrc89gpq1LJB7Hm1YpuhK086DRDJSNrewcGvYloWW1vZLHBTIvarKZDcAORIy/uWNx8Gad+4oMpkSA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: '>=4.8.4 <5.9.0' + '@typescript-eslint/visitor-keys@8.32.0': resolution: {integrity: sha512-1rYQTCLFFzOI5Nl0c8LUpJT8HxpwVRn9E4CkMsYfuN6ctmQqExjSTzzSk0Tz2apmXy7WU6/6fyaZVVA/thPN+w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@typescript-eslint/visitor-keys@8.32.1': + resolution: {integrity: sha512-ar0tjQfObzhSaW3C3QNmTc5ofj0hDoNQ5XWrCy6zDyabdr0TWhCkClp+rywGNj/odAFBVzzJrK4tEq5M4Hmu4w==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@vitest/expect@3.1.3': resolution: {integrity: sha512-7FTQQuuLKmN1Ig/h+h/GO+44Q1IlglPlR2es4ab7Yvfx+Uk5xsv+Ykk+MEt/M2Yn/xGmzaLKxGw2lgy2bwuYqg==} @@ -1007,8 +1038,8 @@ packages: resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} engines: {node: '>=18'} - globals@16.0.0: - resolution: {integrity: sha512-iInW14XItCXET01CQFqudPOWP2jYMl7T+QRQT+UNcR/iQncN/F0UNpgd76iFkBPgNQb4+X3LV9tLJYzwh+Gl3A==} + globals@16.1.0: + resolution: {integrity: sha512-aibexHNbb/jiUSObBgpHLj+sIuUmJnYcgXBlrfsiDZ9rt4aF2TFRbyLgZ2iFQuVZ1K5Mx3FVkbKRSgKrbK3K2g==} engines: {node: '>=18'} gopd@1.2.0: @@ -1046,6 +1077,10 @@ packages: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} + ignore@7.0.4: + resolution: {integrity: sha512-gJzzk+PQNznz8ysRrC0aOkBNVRBDtE1n53IqyqEf3PXrYwomFs5q4pGMizBMJF+ykh03insJ27hB8gSrD2Hn8A==} + engines: {node: '>= 4'} + import-fresh@3.3.1: resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==} engines: {node: '>=6'} @@ -1089,6 +1124,10 @@ packages: isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + jiti@2.4.2: + resolution: {integrity: sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==} + hasBin: true + js-yaml@4.1.0: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} hasBin: true @@ -1405,6 +1444,18 @@ packages: resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + rollup-plugin-esnext-to-nodenext@1.0.0: + resolution: {integrity: sha512-3rPZyEspYJMR78W6UB61GQrsO1yYz8P52pZwEJh48Ub4UuQ2bnLYPsOBAUnPDmu7A/AiA3sJmc+d/gWb0LoHoQ==} + engines: {node: '>=20'} + peerDependencies: + rollup: ^4 + + rollup-plugin-node-externals@8.0.0: + resolution: {integrity: sha512-2HIOpWsWn5DqBoYl6iCAmB4kd5GoGbF68PR4xKR1YBPvywiqjtYvDEjHFodyqRL51iAMDITP074Zxs0OKs6F+g==} + engines: {node: '>= 21 || ^20.6.0 || ^18.19.0'} + peerDependencies: + rollup: ^4.0.0 + rollup@4.40.2: resolution: {integrity: sha512-tfUOg6DTP4rhQ3VjOO6B4wyrJnGOX85requAXvqYTHsOgb2TFJdZ3aWpT8W2kPoypSGP7dZUyzxJ9ee4buM5Fg==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -1561,8 +1612,8 @@ packages: peerDependencies: typescript: 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x || 5.7.x || 5.8.x - typescript-eslint@8.32.0: - resolution: {integrity: sha512-UMq2kxdXCzinFFPsXc9o2ozIpYCCOiEC46MG3yEh5Vipq6BO27otTtEBZA1fQ66DulEUgE97ucQ/3YY66CPg0A==} + typescript-eslint@8.32.1: + resolution: {integrity: sha512-D7el+eaDHAmXvrZBy1zpzSNIRqnCOrkwTgZxTu3MUqRWk8k0q9m9Ho4+vPf7iHtgUfrK/o8IZaEApsxPlHTFCg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -1777,9 +1828,9 @@ snapshots: '@esbuild/win32-x64@0.25.3': optional: true - '@eslint-community/eslint-utils@4.7.0(eslint@9.26.0)': + '@eslint-community/eslint-utils@4.7.0(eslint@9.26.0(jiti@2.4.2))': dependencies: - eslint: 9.26.0 + eslint: 9.26.0(jiti@2.4.2) eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.1': {} @@ -2008,16 +2059,16 @@ snapshots: lodash.get: 4.4.2 type-detect: 4.1.0 - '@stylistic/eslint-plugin-js@4.2.0(eslint@9.26.0)': + '@stylistic/eslint-plugin-js@4.2.0(eslint@9.26.0(jiti@2.4.2))': dependencies: - eslint: 9.26.0 + eslint: 9.26.0(jiti@2.4.2) eslint-visitor-keys: 4.2.0 espree: 10.3.0 - '@stylistic/eslint-plugin-ts@4.2.0(eslint@9.26.0)(typescript@5.8.3)': + '@stylistic/eslint-plugin-ts@4.2.0(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3)': dependencies: - '@typescript-eslint/utils': 8.32.0(eslint@9.26.0)(typescript@5.8.3) - eslint: 9.26.0 + '@typescript-eslint/utils': 8.32.0(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3) + eslint: 9.26.0(jiti@2.4.2) eslint-visitor-keys: 4.2.0 espree: 10.3.0 transitivePeerDependencies: @@ -2042,7 +2093,7 @@ snapshots: '@types/ms@2.1.0': {} - '@types/node@20.17.43': + '@types/node@20.17.47': dependencies: undici-types: 6.19.8 @@ -2056,31 +2107,31 @@ snapshots: '@types/unist@3.0.3': {} - '@typescript-eslint/eslint-plugin@8.32.0(@typescript-eslint/parser@8.32.0(eslint@9.26.0)(typescript@5.8.3))(eslint@9.26.0)(typescript@5.8.3)': + '@typescript-eslint/eslint-plugin@8.32.1(@typescript-eslint/parser@8.32.1(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3)': dependencies: '@eslint-community/regexpp': 4.12.1 - '@typescript-eslint/parser': 8.32.0(eslint@9.26.0)(typescript@5.8.3) - '@typescript-eslint/scope-manager': 8.32.0 - '@typescript-eslint/type-utils': 8.32.0(eslint@9.26.0)(typescript@5.8.3) - '@typescript-eslint/utils': 8.32.0(eslint@9.26.0)(typescript@5.8.3) - '@typescript-eslint/visitor-keys': 8.32.0 - eslint: 9.26.0 + '@typescript-eslint/parser': 8.32.1(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/scope-manager': 8.32.1 + '@typescript-eslint/type-utils': 8.32.1(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/utils': 8.32.1(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/visitor-keys': 8.32.1 + eslint: 9.26.0(jiti@2.4.2) graphemer: 1.4.0 - ignore: 5.3.2 + ignore: 7.0.4 natural-compare: 1.4.0 ts-api-utils: 2.1.0(typescript@5.8.3) typescript: 5.8.3 transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.32.0(eslint@9.26.0)(typescript@5.8.3)': + '@typescript-eslint/parser@8.32.1(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3)': dependencies: - '@typescript-eslint/scope-manager': 8.32.0 - '@typescript-eslint/types': 8.32.0 - '@typescript-eslint/typescript-estree': 8.32.0(typescript@5.8.3) - '@typescript-eslint/visitor-keys': 8.32.0 + '@typescript-eslint/scope-manager': 8.32.1 + '@typescript-eslint/types': 8.32.1 + '@typescript-eslint/typescript-estree': 8.32.1(typescript@5.8.3) + '@typescript-eslint/visitor-keys': 8.32.1 debug: 4.4.0 - eslint: 9.26.0 + eslint: 9.26.0(jiti@2.4.2) typescript: 5.8.3 transitivePeerDependencies: - supports-color @@ -2090,12 +2141,17 @@ snapshots: '@typescript-eslint/types': 8.32.0 '@typescript-eslint/visitor-keys': 8.32.0 - '@typescript-eslint/type-utils@8.32.0(eslint@9.26.0)(typescript@5.8.3)': + '@typescript-eslint/scope-manager@8.32.1': dependencies: - '@typescript-eslint/typescript-estree': 8.32.0(typescript@5.8.3) - '@typescript-eslint/utils': 8.32.0(eslint@9.26.0)(typescript@5.8.3) + '@typescript-eslint/types': 8.32.1 + '@typescript-eslint/visitor-keys': 8.32.1 + + '@typescript-eslint/type-utils@8.32.1(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3)': + dependencies: + '@typescript-eslint/typescript-estree': 8.32.1(typescript@5.8.3) + '@typescript-eslint/utils': 8.32.1(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3) debug: 4.4.0 - eslint: 9.26.0 + eslint: 9.26.0(jiti@2.4.2) ts-api-utils: 2.1.0(typescript@5.8.3) typescript: 5.8.3 transitivePeerDependencies: @@ -2103,6 +2159,8 @@ snapshots: '@typescript-eslint/types@8.32.0': {} + '@typescript-eslint/types@8.32.1': {} + '@typescript-eslint/typescript-estree@8.32.0(typescript@5.8.3)': dependencies: '@typescript-eslint/types': 8.32.0 @@ -2117,13 +2175,38 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@8.32.0(eslint@9.26.0)(typescript@5.8.3)': + '@typescript-eslint/typescript-estree@8.32.1(typescript@5.8.3)': + dependencies: + '@typescript-eslint/types': 8.32.1 + '@typescript-eslint/visitor-keys': 8.32.1 + debug: 4.4.0 + fast-glob: 3.3.3 + is-glob: 4.0.3 + minimatch: 9.0.5 + semver: 7.7.1 + ts-api-utils: 2.1.0(typescript@5.8.3) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/utils@8.32.0(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3)': dependencies: - '@eslint-community/eslint-utils': 4.7.0(eslint@9.26.0) + '@eslint-community/eslint-utils': 4.7.0(eslint@9.26.0(jiti@2.4.2)) '@typescript-eslint/scope-manager': 8.32.0 '@typescript-eslint/types': 8.32.0 '@typescript-eslint/typescript-estree': 8.32.0(typescript@5.8.3) - eslint: 9.26.0 + eslint: 9.26.0(jiti@2.4.2) + typescript: 5.8.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/utils@8.32.1(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3)': + dependencies: + '@eslint-community/eslint-utils': 4.7.0(eslint@9.26.0(jiti@2.4.2)) + '@typescript-eslint/scope-manager': 8.32.1 + '@typescript-eslint/types': 8.32.1 + '@typescript-eslint/typescript-estree': 8.32.1(typescript@5.8.3) + eslint: 9.26.0(jiti@2.4.2) typescript: 5.8.3 transitivePeerDependencies: - supports-color @@ -2133,6 +2216,11 @@ snapshots: '@typescript-eslint/types': 8.32.0 eslint-visitor-keys: 4.2.0 + '@typescript-eslint/visitor-keys@8.32.1': + dependencies: + '@typescript-eslint/types': 8.32.1 + eslint-visitor-keys: 4.2.0 + '@vitest/expect@3.1.3': dependencies: '@vitest/spy': 3.1.3 @@ -2140,13 +2228,13 @@ snapshots: chai: 5.2.0 tinyrainbow: 2.0.0 - '@vitest/mocker@3.1.3(vite@6.3.5(@types/node@20.17.43)(yaml@2.7.1))': + '@vitest/mocker@3.1.3(vite@6.3.5(@types/node@20.17.47)(jiti@2.4.2)(yaml@2.7.1))': dependencies: '@vitest/spy': 3.1.3 estree-walker: 3.0.3 magic-string: 0.30.17 optionalDependencies: - vite: 6.3.5(@types/node@20.17.43)(yaml@2.7.1) + vite: 6.3.5(@types/node@20.17.47)(jiti@2.4.2)(yaml@2.7.1) '@vitest/pretty-format@3.1.3': dependencies: @@ -2408,9 +2496,9 @@ snapshots: eslint-visitor-keys@4.2.0: {} - eslint@9.26.0: + eslint@9.26.0(jiti@2.4.2): dependencies: - '@eslint-community/eslint-utils': 4.7.0(eslint@9.26.0) + '@eslint-community/eslint-utils': 4.7.0(eslint@9.26.0(jiti@2.4.2)) '@eslint-community/regexpp': 4.12.1 '@eslint/config-array': 0.20.0 '@eslint/config-helpers': 0.2.2 @@ -2447,6 +2535,8 @@ snapshots: natural-compare: 1.4.0 optionator: 0.9.4 zod: 3.24.4 + optionalDependencies: + jiti: 2.4.2 transitivePeerDependencies: - supports-color @@ -2619,7 +2709,7 @@ snapshots: globals@14.0.0: {} - globals@16.0.0: {} + globals@16.1.0: {} gopd@1.2.0: {} @@ -2651,6 +2741,8 @@ snapshots: ignore@5.3.2: {} + ignore@7.0.4: {} + import-fresh@3.3.1: dependencies: parent-module: 1.0.1 @@ -2684,6 +2776,8 @@ snapshots: isexe@2.0.0: {} + jiti@2.4.2: {} + js-yaml@4.1.0: dependencies: argparse: 2.0.1 @@ -3041,6 +3135,15 @@ snapshots: reusify@1.1.0: {} + rollup-plugin-esnext-to-nodenext@1.0.0(rollup@4.40.2): + dependencies: + rollup: 4.40.2 + ts-add-js-extension: 1.6.5 + + rollup-plugin-node-externals@8.0.0(rollup@4.40.2): + dependencies: + rollup: 4.40.2 + rollup@4.40.2: dependencies: '@types/estree': 1.0.7 @@ -3228,12 +3331,12 @@ snapshots: typescript: 5.8.3 yaml: 2.7.1 - typescript-eslint@8.32.0(eslint@9.26.0)(typescript@5.8.3): + typescript-eslint@8.32.1(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3): dependencies: - '@typescript-eslint/eslint-plugin': 8.32.0(@typescript-eslint/parser@8.32.0(eslint@9.26.0)(typescript@5.8.3))(eslint@9.26.0)(typescript@5.8.3) - '@typescript-eslint/parser': 8.32.0(eslint@9.26.0)(typescript@5.8.3) - '@typescript-eslint/utils': 8.32.0(eslint@9.26.0)(typescript@5.8.3) - eslint: 9.26.0 + '@typescript-eslint/eslint-plugin': 8.32.1(@typescript-eslint/parser@8.32.1(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3))(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/parser': 8.32.1(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3) + '@typescript-eslint/utils': 8.32.1(eslint@9.26.0(jiti@2.4.2))(typescript@5.8.3) + eslint: 9.26.0(jiti@2.4.2) typescript: 5.8.3 transitivePeerDependencies: - supports-color @@ -3256,13 +3359,13 @@ snapshots: vary@1.1.2: {} - vite-node@3.1.3(@types/node@20.17.43)(yaml@2.7.1): + vite-node@3.1.3(@types/node@20.17.47)(jiti@2.4.2)(yaml@2.7.1): dependencies: cac: 6.7.14 debug: 4.4.0 es-module-lexer: 1.7.0 pathe: 2.0.3 - vite: 6.3.5(@types/node@20.17.43)(yaml@2.7.1) + vite: 6.3.5(@types/node@20.17.47)(jiti@2.4.2)(yaml@2.7.1) transitivePeerDependencies: - '@types/node' - jiti @@ -3277,7 +3380,7 @@ snapshots: - tsx - yaml - vite@6.3.5(@types/node@20.17.43)(yaml@2.7.1): + vite@6.3.5(@types/node@20.17.47)(jiti@2.4.2)(yaml@2.7.1): dependencies: esbuild: 0.25.3 fdir: 6.4.4(picomatch@4.0.2) @@ -3286,14 +3389,15 @@ snapshots: rollup: 4.40.2 tinyglobby: 0.2.13 optionalDependencies: - '@types/node': 20.17.43 + '@types/node': 20.17.47 fsevents: 2.3.3 + jiti: 2.4.2 yaml: 2.7.1 - vitest@3.1.3(@types/debug@4.1.12)(@types/node@20.17.43)(yaml@2.7.1): + vitest@3.1.3(@types/debug@4.1.12)(@types/node@20.17.47)(jiti@2.4.2)(yaml@2.7.1): dependencies: '@vitest/expect': 3.1.3 - '@vitest/mocker': 3.1.3(vite@6.3.5(@types/node@20.17.43)(yaml@2.7.1)) + '@vitest/mocker': 3.1.3(vite@6.3.5(@types/node@20.17.47)(jiti@2.4.2)(yaml@2.7.1)) '@vitest/pretty-format': 3.1.3 '@vitest/runner': 3.1.3 '@vitest/snapshot': 3.1.3 @@ -3310,12 +3414,12 @@ snapshots: tinyglobby: 0.2.13 tinypool: 1.0.2 tinyrainbow: 2.0.0 - vite: 6.3.5(@types/node@20.17.43)(yaml@2.7.1) - vite-node: 3.1.3(@types/node@20.17.43)(yaml@2.7.1) + vite: 6.3.5(@types/node@20.17.47)(jiti@2.4.2)(yaml@2.7.1) + vite-node: 3.1.3(@types/node@20.17.47)(jiti@2.4.2)(yaml@2.7.1) why-is-node-running: 2.3.0 optionalDependencies: '@types/debug': 4.1.12 - '@types/node': 20.17.43 + '@types/node': 20.17.47 transitivePeerDependencies: - jiti - less diff --git a/rollup.config.ts b/rollup.config.ts index 71c043df06..8076618b46 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -3,43 +3,70 @@ import typescript from '@rollup/plugin-typescript'; import resolve from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; import alias from '@rollup/plugin-alias'; +import esnextToNodeNext from 'rollup-plugin-esnext-to-nodenext'; +import nodeExternals from 'rollup-plugin-node-externals'; import { fileURLToPath } from 'node:url'; import { dirname } from 'node:path'; -import { readFileSync } from 'node:fs'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -const packageJsonPath = `${__dirname}/package.json`; -const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')); - -const dependencies = Object.keys(packageJson.dependencies || {}); -const peerDependencies = Object.keys(packageJson.peerDependencies || {}); -const external = [...dependencies, ...peerDependencies]; - -export default defineConfig({ - input: 'src/index.ts', - output: [ - { - file: 'dist/index.cjs', - format: 'cjs', +export default defineConfig([ + { + input: 'src/index.ts', + output: { + dir: 'dist/esm', + format: 'esm', + preserveModules: true, + preserveModulesRoot: 'src', sourcemap: true, + entryFileNames: '[name].mjs', }, - { - file: 'dist/index.mjs', - format: 'esm', + plugins: [ + nodeExternals(), + alias({ + entries: [ + { find: '~', replacement: `${__dirname}/src` } + ] + }), + resolve(), + commonjs(), + typescript({ + outDir: 'dist/esm', + rootDir: 'src', + declaration: true, + declarationDir: 'dist/esm/types', + tsconfig: './tsconfig.json', + }), + esnextToNodeNext() + ] + }, + { + input: 'src/index.ts', + output: { + dir: 'dist/cjs', + format: 'cjs', + preserveModules: true, + preserveModulesRoot: 'src', sourcemap: true, + exports: 'auto', + entryFileNames: '[name].cjs', }, - ], - plugins: [ - alias({ - entries: [ - { find: '~', replacement: `${__dirname}/src` } - ] - }), - resolve(), - commonjs(), - typescript({ tsconfig: './tsconfig.json' }), - ], - external, -}); + plugins: [ + nodeExternals(), + alias({ + entries: [ + { find: '~', replacement: `${__dirname}/src` } + ] + }), + resolve(), + commonjs(), + typescript({ + outDir: 'dist/cjs', + rootDir: 'src', + declaration: false, + tsconfig: './tsconfig.json', + }), + ] + } +]); diff --git a/tests/tsconfig.json b/tests/tsconfig.json index 058af71175..e2fc13172f 100644 --- a/tests/tsconfig.json +++ b/tests/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../tsconfig.json", "compilerOptions": { "baseUrl": ".", - "outDir": "./out", + "outDir": "./dist", "noEmit": true, "paths": { "~/*": ["../src/*"], diff --git a/tsconfig.json b/tsconfig.json index a5cf405ec8..4ef7bef424 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "target": "ES2022", "outDir": "dist", - "module": "ES2022", + "module": "ESNext", "moduleResolution": "bundler", "strict": true, "declaration": true, @@ -24,7 +24,7 @@ "node_modules", "coverage", "docs", - "out", + "dist", "examples" ] } diff --git a/tsconfig.lint.json b/tsconfig.lint.json deleted file mode 100644 index 30dc9ba3dc..0000000000 --- a/tsconfig.lint.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": [ - "examples", - "src", - "tests", - "vitest.config.mts", - "eslint.config.js" - ] -}