diff --git a/.eslintrc.json b/.eslintrc.json index fa1685ff..84ab4991 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,10 +4,7 @@ "node": true, "mocha": true }, - "plugins": [ - "@typescript-eslint", - "eslint-plugin-tsdoc" - ], + "plugins": ["@typescript-eslint", "eslint-plugin-tsdoc"], "extends": [ "eslint:recommended", "prettier", @@ -19,9 +16,7 @@ "sourceType": "module" }, "rules": { - "no-unused-vars": [ - "off" - ], + "no-unused-vars": ["off"], "tsdoc/syntax": "warn" }, "globals": { diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 58639358..b10f81d6 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,10 +1,9 @@ --- name: Bug report about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - +title: "" +labels: "" +assignees: "" --- **Describe the bug** @@ -12,6 +11,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Simple and straight to the point failing snippet 2. See error @@ -19,9 +19,10 @@ Steps to reproduce the behavior: A clear and concise description of what you expected to happen. **Desktop (please complete the following information):** - - OS: [e.g. Windows] - - Runtime [e.g. node@19, deno@1.33.4] - - Library Version [e.g. 1.0.0] + +- OS: [e.g. Windows] +- Runtime [e.g. node@19, deno@1.33.4] +- Library Version [e.g. 1.0.0] **Additional context** Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7d..2bc5d5f7 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,10 +1,9 @@ --- name: Feature request about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - +title: "" +labels: "" +assignees: "" --- **Is your feature request related to a problem? Please describe.** diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index af595777..8d3ba004 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,7 +1,9 @@ -### Please don't delete this checklist! Before submitting the PR, please make sure you do the following: -- [ ] It's really useful if your PR references an issue where it is discussed ahead of time. -- [ ] This message body should clearly illustrate what problems it solves. -- [ ] Ideally, include a test that fails without this PR but passes with it. - -### Tests -- [ ] Run the tests with `npm run test` and lint the project with `npm run lint` and `npm run prettier` +### Please don't delete this checklist! Before submitting the PR, please make sure you do the following: + +- [ ] It's really useful if your PR references an issue where it is discussed ahead of time. +- [ ] This message body should clearly illustrate what problems it solves. +- [ ] Ideally, include a test that fails without this PR but passes with it. + +### Tests + +- [ ] Run the tests with `npm run test` and lint the project with `npm run lint` and `npm run prettier` diff --git a/.github/renovate.json b/.github/renovate.json index c8dd9000..24217a9d 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,26 +1,24 @@ { - "baseBranches": ["main"], - "dependencyDashboard": true, - "extends": [ - "config:base", - "group:allNonMajor", - "helpers:disableTypesNodeMajor", - "schedule:earlyMondays" - ], - "commitMessageAction": "", - "commitMessageTopic": "{{depName}}", - "commitMessageExtra": "{{#if isMajor}}v{{{newMajor}}}{{else}}{{#if isSingleVersion}}v{{{newVersion}}}{{else}}{{{newValue}}}{{/if}}{{/if}}", - "labels": ["dependencies"], - "prBodyTemplate": "{{{header}}}{{{table}}}{{{notes}}}{{{changelogs}}}{{{controls}}}{{{footer}}}", - "prHeader": "", - "prFooter": "", - "semanticCommits": "enabled", - "packageRules": [ - { - "packageNames": [ - "esbuild" - ], - "versioning": "regex:^(\\d+)\\.(\\d+)\\.(\\d+)$" - } - ] + "baseBranches": ["main"], + "dependencyDashboard": true, + "extends": [ + "config:base", + "group:allNonMajor", + "helpers:disableTypesNodeMajor", + "schedule:earlyMondays" + ], + "commitMessageAction": "", + "commitMessageTopic": "{{depName}}", + "commitMessageExtra": "{{#if isMajor}}v{{{newMajor}}}{{else}}{{#if isSingleVersion}}v{{{newVersion}}}{{else}}{{{newValue}}}{{/if}}{{/if}}", + "labels": ["dependencies"], + "prBodyTemplate": "{{{header}}}{{{table}}}{{{notes}}}{{{changelogs}}}{{{controls}}}{{{footer}}}", + "prHeader": "", + "prFooter": "", + "semanticCommits": "enabled", + "packageRules": [ + { + "packageNames": ["esbuild"], + "versioning": "regex:^(\\d+)\\.(\\d+)\\.(\\d+)$" + } + ] } diff --git a/.github/workflows/alpha-release.yml b/.github/workflows/alpha-release.yml index 1c0a6917..3c38aa45 100644 --- a/.github/workflows/alpha-release.yml +++ b/.github/workflows/alpha-release.yml @@ -1,57 +1,57 @@ name: Deploy alpha release to GitHub on: - workflow_dispatch: - push: - branches: - - main + workflow_dispatch: + push: + branches: + - main jobs: - build: - name: Build from source - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.ref }} - - - uses: actions/setup-node@v3 - with: - node-version: 18 - - - name: Build - run: | - npm ci - npm run build - - - name: Store builds - uses: actions/upload-artifact@v3 - with: - name: build - path: | - package.json - README.md - LICENSE - lib - - alpha-branch: - name: Deploy alpha - runs-on: ubuntu-latest - needs: build - steps: - - uses: actions/checkout@v4 - with: - ref: alpha - - - name: Clear old build - run: find . -not -wholename './.git*' -delete - - - uses: actions/download-artifact@v3 - with: - name: build - - - name: Push to alpha - uses: EndBug/add-and-commit@v9 - with: - default_author: github_actor - message: New alpha release + build: + name: Build from source + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + + - uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Build + run: | + npm ci + npm run build + + - name: Store builds + uses: actions/upload-artifact@v3 + with: + name: build + path: | + package.json + README.md + LICENSE + lib + + alpha-branch: + name: Deploy alpha + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v4 + with: + ref: alpha + + - name: Clear old build + run: find . -not -wholename './.git*' -delete + + - uses: actions/download-artifact@v3 + with: + name: build + + - name: Push to alpha + uses: EndBug/add-and-commit@v9 + with: + default_author: github_actor + message: New alpha release diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index b73a1f95..a5b3f67f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -12,61 +12,60 @@ name: "CodeQL" on: - push: - branches: [ "main" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "main" ] - schedule: - - cron: '45 22 * * 6' + push: + branches: ["main"] + pull_request: + # The branches below must be a subset of the branches above + branches: ["main"] + schedule: + - cron: "45 22 * * 6" jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write - strategy: - fail-fast: false - matrix: - language: [ 'javascript' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + strategy: + fail-fast: false + matrix: + language: ["javascript"] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - steps: - - name: Checkout repository - uses: actions/checkout@v4 + steps: + - name: Checkout repository + uses: actions/checkout@v4 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 5aa70806..b7297bc3 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -4,26 +4,26 @@ name: Preview with Firebase Hosting on: - pull_request: - paths: - - 'src/**' - - 'README.md' - - 'package.json' - - 'docs_statics/*.html' + pull_request: + paths: + - "src/**" + - "README.md" + - "package.json" + - "docs_statics/*.html" jobs: - build_and_preview: - name: Build documentation and preview - if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: | - npm ci --only=dev - npm run document + build_and_preview: + name: Build documentation and preview + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: | + npm ci --only=dev + npm run document - - uses: FirebaseExtended/action-hosting-deploy@v0 - with: - repoToken: '${{ secrets.GITHUB_TOKEN }}' - firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_WHATSAPPAPIJS }}' - projectId: whatsappapijs + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: "${{ secrets.GITHUB_TOKEN }}" + firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_WHATSAPPAPIJS }}" + projectId: whatsappapijs diff --git a/.github/workflows/npm-deploy.yml b/.github/workflows/npm-deploy.yml index 74926bbd..65d5d911 100644 --- a/.github/workflows/npm-deploy.yml +++ b/.github/workflows/npm-deploy.yml @@ -4,115 +4,115 @@ name: Deploy to NPM on: - release: - types: [created] + release: + types: [created] jobs: - build: - name: Build and Document - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - - - name: Setup - run: npm ci - - - name: Build - run: npm run build - - - name: Store builds - uses: actions/upload-artifact@v3 - with: - name: build - path: lib - - test: - name: Test - needs: build - - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x, 20.x] - - steps: - - uses: actions/checkout@v4 - - uses: actions/download-artifact@v3 - with: - name: build - path: lib - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: npm - - - name: Setup - run: npm ci - - - name: Test - run: npm run test - - publish-npm: - name: Public Release - needs: test - - runs-on: ubuntu-latest - if: '!github.event.release.prerelease' - - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 + build: + name: Build and Document + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + + - name: Setup + run: npm ci + + - name: Build + run: npm run build + + - name: Store builds + uses: actions/upload-artifact@v3 + with: + name: build + path: lib + + test: + name: Test + needs: build + + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x, 20.x] + + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v3 + with: + name: build + path: lib + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: npm + + - name: Setup + run: npm ci + + - name: Test + run: npm run test + + publish-npm: + name: Public Release + needs: test + + runs-on: ubuntu-latest + if: ${{ !github.event.release.prerelease }} + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: https://registry.npmjs.org/ + - uses: actions/download-artifact@v3 + with: + name: build + path: lib + + - name: Give me 1 minute to reconsider my life actions + run: sleep 60s + + - name: Ok, now publish it + run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} + + preview-npm: + name: Beta Release + needs: test + + runs-on: ubuntu-latest + if: ${{ github.event.release.prerelease }} + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: https://registry.npmjs.org/ + - uses: actions/download-artifact@v3 + with: + name: build + path: lib + + - name: Set package version to prerelease tag + run: npm version --no-git-tag-version ${GITHUB_REF/refs\/tags\//} + + - name: Beta Release + run: npm publish --tag beta + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} + + web-release: + name: Deploy website + needs: publish-npm + + uses: ./.github/workflows/web-release.yml + secrets: inherit with: - node-version: 18 - registry-url: https://registry.npmjs.org/ - - uses: actions/download-artifact@v3 - with: - name: build - path: lib - - - name: Give me 1 minute to reconsider my life actions - run: sleep 60s - - - name: Ok, now publish it - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} - - preview-npm: - name: Beta Release - needs: test - - runs-on: ubuntu-latest - if: 'github.event.release.prerelease' - - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version: 18 - registry-url: https://registry.npmjs.org/ - - uses: actions/download-artifact@v3 - with: - name: build - path: lib - - - name: Set package version to prerelease tag - run: npm version --no-git-tag-version ${GITHUB_REF/refs\/tags\//} - - - name: Beta Release - run: npm publish --tag beta - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} - - web-release: - name: Deploy website - needs: publish-npm - - uses: ./.github/workflows/web-release.yml - secrets: inherit - with: - tag_name: ${{ github.event.release.tag_name }} + tag_name: ${{ github.event.release.tag_name }} diff --git a/.github/workflows/on-pull-request.yml b/.github/workflows/on-pull-request.yml index a0bf21bd..c6db7a4f 100644 --- a/.github/workflows/on-pull-request.yml +++ b/.github/workflows/on-pull-request.yml @@ -3,41 +3,41 @@ name: Run Pull Request Checks on: [pull_request] jobs: - tests: - name: Run Tests + tests: + name: Run Tests - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x, 20.x] + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x, 20.x] - steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: npm - - name: Install - run: npm ci - - name: Compile - run: npm run build:code - - name: Tests - run: npm run test + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: npm + - name: Install + run: npm ci + - name: Compile + run: npm run build:code + - name: Tests + run: npm run test - lint_and_format: - name: Run Lint and Format - runs-on: ubuntu-latest + lint_and_format: + name: Run Lint and Format + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version: 18.x - cache: npm - - name: Install - run: npm ci - - name: Linted - run: npm run lint - - name: Nice - run: npm run prettier + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 18.x + cache: npm + - name: Install + run: npm ci + - name: Linted + run: npm run lint + - name: Nice + run: npm run prettier diff --git a/.github/workflows/web-release.yml b/.github/workflows/web-release.yml index 1b996f29..1927c4f4 100644 --- a/.github/workflows/web-release.yml +++ b/.github/workflows/web-release.yml @@ -1,92 +1,92 @@ name: Deploy websites update on: - workflow_dispatch: - inputs: - tag_name: - description: 'Tag to deploy' - required: true - workflow_call: - inputs: - tag_name: - description: 'Tag to deploy' - required: true - type: string + workflow_dispatch: + inputs: + tag_name: + description: "Tag to deploy" + required: true + workflow_call: + inputs: + tag_name: + description: "Tag to deploy" + required: true + type: string jobs: - build: - name: Build Documentation - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - - - name: Setup - run: npm ci - - - name: Document - run: npm run document - - - name: Store docs - uses: actions/upload-artifact@v3 - with: - name: docs - path: docs - - firebase: - name: Deploy website to Firebase - needs: build - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Copy docs - uses: actions/download-artifact@v3 - with: - name: docs - - - uses: FirebaseExtended/action-hosting-deploy@v0 - with: - repoToken: '${{ secrets.GITHUB_TOKEN }}' - firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_WHATSAPPAPIJS }}' - channelId: live - projectId: whatsappapijs - - archive: - name: Deploy website to Github Pages - needs: build - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - ref: gh-pages - - - name: Check if tag exists - run: | - if [ $(git tag -l "${{ inputs.tag_name }}") ]; then - echo "Tag doesn't exists" - exit 1 - fi - - - name: Create Endpoint - # The endpoint shouldn't exists - # The code is only executed on releases - run: mkdir ${{ inputs.tag_name }} - - - name: Copy docs into Endpoint - uses: actions/download-artifact@v3 - with: - name: docs - path: ${{ inputs.tag_name }} - - - name: Add Endpoint to the index - run: bash build.sh - - - name: Commit changes - uses: EndBug/add-and-commit@v9 - with: - default_author: github_actor - message: Added ${{ inputs.tag_name }} docs + build: + name: Build Documentation + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + + - name: Setup + run: npm ci + + - name: Document + run: npm run document + + - name: Store docs + uses: actions/upload-artifact@v3 + with: + name: docs + path: docs + + firebase: + name: Deploy website to Firebase + needs: build + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Copy docs + uses: actions/download-artifact@v3 + with: + name: docs + + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: "${{ secrets.GITHUB_TOKEN }}" + firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_WHATSAPPAPIJS }}" + channelId: live + projectId: whatsappapijs + + archive: + name: Deploy website to Github Pages + needs: build + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + ref: gh-pages + + - name: Check if tag exists + run: | + if [ $(git tag -l "${{ inputs.tag_name }}") ]; then + echo "Tag doesn't exists" + exit 1 + fi + + - name: Create Endpoint + # The endpoint shouldn't exists + # The code is only executed on releases + run: mkdir ${{ inputs.tag_name }} + + - name: Copy docs into Endpoint + uses: actions/download-artifact@v3 + with: + name: docs + path: ${{ inputs.tag_name }} + + - name: Add Endpoint to the index + run: bash build.sh + + - name: Commit changes + uses: EndBug/add-and-commit@v9 + with: + default_author: github_actor + message: Added ${{ inputs.tag_name }} docs diff --git a/BREAKING.md b/BREAKING.md index bdce5673..7af73dc8 100644 --- a/BREAKING.md +++ b/BREAKING.md @@ -10,30 +10,32 @@ the original catalog messages. Among the affected classes and files are: -- `interactive.ts` - - `ActionCatalog` -> `ActionProduct`: `ActionCatalog` is now used for the - Catalog messages. The original class was renamed as `ActionProduct`. - - `Product` and `ProductSection`: These classes were moved from the file - `messages/interactive.ts` to `messages/globals.ts`, as they are now also - used in templates. - - `Section`: The class was moved from the file `messages/interactive.ts` to - `types.ts`. - -- `template.ts` - - `ButtonComponent` -> `URLComponent`, `PayloadComponent`, `CatalogComponent`, - `MPMComponent`, `CopyComponent`, `SkipButtonComponent`: As the API now - supports mixing button types, the `ButtonComponent` was splitted into - different classes, each one representing a button types. For example, an URL - component was updated from `new ButtonComponent("url", "example")` to - `new URLComponent("example")`. - - `Template`: The constructor now receives multiple button components instead - of a single one. - - `ButtonComponent`: The class was replaced with an abstract class. - - `ButtonParameter`: The class was replaced with a type. - -- `types.ts` - - `ClientBuildableMessageComponent`: The class was replaced with an interface. - - `PostData`: `PostData.entry[].changes[].value.contacts` may be undefined. +- `interactive.ts` + + - `ActionCatalog` -> `ActionProduct`: `ActionCatalog` is now used for the + Catalog messages. The original class was renamed as `ActionProduct`. + - `Product` and `ProductSection`: These classes were moved from the file + `messages/interactive.ts` to `messages/globals.ts`, as they are now also + used in templates. + - `Section`: The class was moved from the file `messages/interactive.ts` to + `types.ts`. + +- `template.ts` + + - `ButtonComponent` -> `URLComponent`, `PayloadComponent`, `CatalogComponent`, + `MPMComponent`, `CopyComponent`, `SkipButtonComponent`: As the API now + supports mixing button types, the `ButtonComponent` was splitted into + different classes, each one representing a button types. For example, an URL + component was updated from `new ButtonComponent("url", "example")` to + `new URLComponent("example")`. + - `Template`: The constructor now receives multiple button components instead + of a single one. + - `ButtonComponent`: The class was replaced with an abstract class. + - `ButtonParameter`: The class was replaced with a type. + +- `types.ts` + - `ClientBuildableMessageComponent`: The class was replaced with an interface. + - `PostData`: `PostData.entry[].changes[].value.contacts` may be undefined. ### Node min version bumped @@ -72,11 +74,11 @@ Also bumped the default API version to v17.0. import WhatsAppAPI from "whatsapp-api-js"; const Whatsapp = new WhatsAppAPI({ - token: "123", - appSecret: "456", - webhookVerifyToken: "789", - v: "v16.0", - parsed: true, + token: "123", + appSecret: "456", + webhookVerifyToken: "789", + v: "v16.0", + parsed: true }); ``` @@ -90,14 +92,14 @@ the main class. import WhatsAppAPI from "whatsapp-api-js"; const Whatsapp = new WhatsAppAPI({ - token: "123", - appSecret: "456", - webhookVerifyToken: "789", + token: "123", + appSecret: "456", + webhookVerifyToken: "789" }); // Assuming get is called on a GET request to your server function get(e) { - return Whatsapp.get(JSON.parse(e.params)); + return Whatsapp.get(JSON.parse(e.params)); } ``` @@ -111,11 +113,11 @@ const Whatsapp = new WhatsAppAPI({ token: "123", appSecret: "456" }); // Assuming post is called on a POST request to your server function post(e) { - return Whatsapp.post( - JSON.parse(e.data), - e.data, - e.headers["x-hub-signature-256"], - ); + return Whatsapp.post( + JSON.parse(e.data), + e.data, + e.headers["x-hub-signature-256"] + ); } ``` @@ -129,7 +131,7 @@ const Whatsapp = new WhatsAppAPI({ token: "123", secure: false }); // Assuming post is called on a POST request to your server function post(e) { - return Whatsapp.post(JSON.parse(e.data)); + return Whatsapp.post(JSON.parse(e.data)); } ``` @@ -142,24 +144,24 @@ import WhatsAppAPI from "whatsapp-api-js"; const Whatsapp = new WhatsAppAPI({ token: "123", appSecret: "456" }); Whatsapp.on.message = ({ name, from }) => { - console.log(`Got message from ${name} (${from})`); + console.log(`Got message from ${name} (${from})`); }; Whatsapp.on.status = ({ id, status }) => { - console.log(`Message ${id} status changed to ${status}`); + console.log(`Message ${id} status changed to ${status}`); }; Whatsapp.on.sent = ({ id, to }) => { - console.log(`Message ${id} was sent to ${to}`); + console.log(`Message ${id} was sent to ${to}`); }; // Assuming post is called on a POST request to your server function post(e) { - return Whatsapp.post( - JSON.parse(e.data), - e.data, - e.headers["x-hub-signature-256"], - ); + return Whatsapp.post( + JSON.parse(e.data), + e.data, + e.headers["x-hub-signature-256"] + ); } ``` @@ -175,11 +177,11 @@ import WhatsAppAPI from "whatsapp-api-js"; import { fetch } from "undici"; const Whatsapp = new WhatsAppAPI({ - token: "YOUR_TOKEN_HERE", - appSecret: "YOUR_SECRET_HERE", - ponyfill: { - fetch, - }, + token: "YOUR_TOKEN_HERE", + appSecret: "YOUR_SECRET_HERE", + ponyfill: { + fetch + } }); ``` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2834ebb7..6596c81c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,33 +1,34 @@ -# Contributing: - -This project accepts PR! Just keep in mind the following rules: - -1. If you are planning to write a new feature or bug fix, -consider opening an issue to get a confirmation - - Minor changes like typos fixes in documentation can be -created without previous discussion - -2. If deemed necesary, add unit tests that cover the feature or prevents the bug fix - -3. Before committing, remember to run prettier and eslint to fix -syntax and format issues (will setup husky in the future) - -4. Follow the server agnostic "philosophy" of the library, avoid using runtime specific features unless strictly required - -## Setup - -```sh -git clone https://github.com/secreto31126/whatsapp-api-js.git -``` - -```sh -cd whatsapp-api-js -``` - -```sh -npm ci -``` - -```sh -npm run test:build -``` +# Contributing: + +This project accepts PR! Just keep in mind the following rules: + +1. If you are planning to write a new feature or bug fix, + consider opening an issue to get a confirmation + + - Minor changes like typos fixes in documentation can be + created without previous discussion + +2. If deemed necesary, add unit tests that cover the feature or prevents the bug fix + +3. Before committing, remember to run prettier and eslint to fix + syntax and format issues (will setup husky in the future) + +4. Follow the server agnostic "philosophy" of the library, avoid using runtime specific features unless strictly required + +## Setup + +```sh +git clone https://github.com/secreto31126/whatsapp-api-js.git +``` + +```sh +cd whatsapp-api-js +``` + +```sh +npm ci +``` + +```sh +npm run test:build +``` diff --git a/ENVIRONMENTS.md b/ENVIRONMENTS.md index 68e13bdc..14fe699e 100644 --- a/ENVIRONMENTS.md +++ b/ENVIRONMENTS.md @@ -22,7 +22,7 @@ const WhatsAppAPI = require("whatsapp-api-js").default; For each version of Node, you can use the `setup` function to simplify the process. -- Node 19 and above (using Express): +- Node 19 and above (using Express): ```js import WhatsAppAPI from "whatsapp-api-js/middleware/express"; @@ -44,7 +44,7 @@ app.post("/message", async (req, res) => { }); ``` -- Node 18: +- Node 18: ```js import WhatsAppAPI from "whatsapp-api-js"; @@ -58,7 +58,7 @@ const Whatsapp = new WhatsAppAPI( ); ``` -- Node 15 to 17 (deprecated): +- Node 15 to 17 (deprecated): ```js import WhatsAppAPI from "whatsapp-api-js"; @@ -68,10 +68,13 @@ import { Node15 } from "whatsapp-api-js/setup/node"; import fetch from "node-fetch"; // or any other fetch implementation const Whatsapp = new WhatsAppAPI( - Node15({ - token: "123", - appSecret: "123" - }, fetch) + Node15( + { + token: "123", + appSecret: "123" + }, + fetch + ) ); ``` diff --git a/EXAMPLES/contacts.md b/EXAMPLES/contacts.md index f2117374..972dbb3d 100644 --- a/EXAMPLES/contacts.md +++ b/EXAMPLES/contacts.md @@ -7,7 +7,15 @@ import { Contacts, Name, Address, Phone } from "whatsapp-api-js/messages"; const contact_message = new Contacts([ new Name("John Doe", "John", "Doe", undefined, "Mr.", "Jr."), - new Address("United States", "US", "FL", "Miami", "221B Baker Street", "33101", "Mystery"), + new Address( + "United States", + "US", + "FL", + "Miami", + "221B Baker Street", + "33101", + "Mystery" + ), new Phone("+123456789", "Mystery", "123456789") ]); ``` @@ -20,12 +28,28 @@ import { Contacts, Name, Address, Phone } from "whatsapp-api-js/messages"; const multi_contacts_message = new Contacts( [ new Name("John Doe", "John", "Doe", undefined, "Mr.", "Jr."), - new Address("United States", "US", "FL", "Miami", "221A Baker Street", "33101", "Mystery"), + new Address( + "United States", + "US", + "FL", + "Miami", + "221A Baker Street", + "33101", + "Mystery" + ), new Phone("+123456789", "Mystery", "123456789") ], [ new Name("John Another Doe", "John", "Doe", "Another"), - new Address("United Kindom", "UK", "BS", "London", "221B Baker Street", "33101", "Mystery"), + new Address( + "United Kindom", + "UK", + "BS", + "London", + "221B Baker Street", + "33101", + "Mystery" + ), new Phone("+123456789", "Mystery", "123456789") ] ); diff --git a/EXAMPLES/interactive.md b/EXAMPLES/interactive.md index 5bde7795..c25346a6 100644 --- a/EXAMPLES/interactive.md +++ b/EXAMPLES/interactive.md @@ -3,7 +3,12 @@ ## Reply Buttons ```ts -import { Interactive, ActionButtons, Button, Body } from "whatsapp-api-js/messages"; +import { + Interactive, + ActionButtons, + Button, + Body +} from "whatsapp-api-js/messages"; const interactive_button_message = new Interactive( new ActionButtons( @@ -22,7 +27,8 @@ import { Interactive, ActionList, Row, Body } from "whatsapp-api-js/messages"; const interactive_list_message = new Interactive( new ActionList( "Button text", - new ListSection(undefined, + new ListSection( + undefined, new Row("reply_1", "Hello", "Hello description"), new Row("reply_2", "World", "World description") ) @@ -37,17 +43,19 @@ const interactive_list_message = new Interactive( import { Interactive, ActionProduct, Product } from "whatsapp-api-js/messages"; const interactive_single_product_message = new Interactive( - new ActionProduct( - "catalog_id", - new Product("product_id") - ) + new ActionProduct("catalog_id", new Product("product_id")) ); ``` ## Multi Product ```ts -import { Interactive, ActionProduct, ProductSection, Product } from "whatsapp-api-js/messages"; +import { + Interactive, + ActionProduct, + ProductSection, + Product +} from "whatsapp-api-js/messages"; const interactive_multi_product_message = new Interactive( new ActionProduct( @@ -66,12 +74,15 @@ const interactive_multi_product_message = new Interactive( ## Catalog ```ts -import { Interactive, ActionCatalog, Product, Body } from "whatsapp-api-js/messages"; +import { + Interactive, + ActionCatalog, + Product, + Body +} from "whatsapp-api-js/messages"; const interactive_catalog_message = new Interactive( - new ActionCatalog( - new Product("hello") - ), + new ActionCatalog(new Product("hello")), new Body("Hello World") ); ``` diff --git a/EXAMPLES/main.md b/EXAMPLES/main.md index 8f2ece8b..187259cc 100644 --- a/EXAMPLES/main.md +++ b/EXAMPLES/main.md @@ -51,7 +51,11 @@ import { Text } from "whatsapp-api-js/messages"; const text_message = new Text("Hello world!"); -Whatsapp.sendMessage("from (bot phoneID)", "to (phone number/wa_id)", text_message); +Whatsapp.sendMessage( + "from (bot phoneID)", + "to (phone number/wa_id)", + text_message +); ``` ## Documentation diff --git a/EXAMPLES/media.md b/EXAMPLES/media.md index 6f244371..cbe8a11a 100644 --- a/EXAMPLES/media.md +++ b/EXAMPLES/media.md @@ -7,7 +7,11 @@ import { Image } from "whatsapp-api-js/messages"; const image_message = new Image("https://i.imgur.com/4QfKuz1.png"); const image_id_message = new Image("12345678", true); -const image_caption_message = new Image("https://i.imgur.com/4QfKuz1.png", false, "Hello world!"); +const image_caption_message = new Image( + "https://i.imgur.com/4QfKuz1.png", + false, + "Hello world!" +); ``` ## Video @@ -17,7 +21,11 @@ import { Video } from "whatsapp-api-js/messages"; const video_message = new Video("https://www.example.com/video.mp4"); const video_id_message = new Video("12345678", true); -const video_caption_message = new Video("https://www.example.com/video.mp4", false, "Hello world!"); +const video_caption_message = new Video( + "https://www.example.com/video.mp4", + false, + "Hello world!" +); ``` ## Audio @@ -36,8 +44,17 @@ import { Document } from "whatsapp-api-js/messages"; const document_message = new Document("https://www.example.com/document.pdf"); const document_id_message = new Document("12345678", true); -const document_caption_message = new Document("https://www.example.com/document.pdf", false, "Hello world!"); -const document_filename_message = new Document("https://www.example.com/document.pdf", false, undefined, "a weird filename.pdf"); +const document_caption_message = new Document( + "https://www.example.com/document.pdf", + false, + "Hello world!" +); +const document_filename_message = new Document( + "https://www.example.com/document.pdf", + false, + undefined, + "a weird filename.pdf" +); ``` ## Sticker diff --git a/EXAMPLES/template.md b/EXAMPLES/template.md index 0c2abb83..feaa7e0f 100644 --- a/EXAMPLES/template.md +++ b/EXAMPLES/template.md @@ -5,10 +5,7 @@ ```ts import { Template } from "whatsapp-api-js/messages"; -const template_message = new Template( - "template_name", - "en" -); +const template_message = new Template("template_name", "en"); ``` ## Simple template with simple variables in header and body @@ -29,21 +26,13 @@ const template_variables_message = new Template( "en", new HeaderComponent( new HeaderParameter("Hello"), - new HeaderParameter( - new Currency(1.5 * 1000, "USD", "U$1.5"), - ), - new HeaderParameter( - new DateTime("01/01/2023") - ) + new HeaderParameter(new Currency(1.5 * 1000, "USD", "U$1.5")), + new HeaderParameter(new DateTime("01/01/2023")) ), new BodyComponent( new BodyParameter("Hello"), - new BodyParameter( - new Currency(1.5 * 1000, "USD", "U$1.5"), - ), - new BodyParameter( - new DateTime("01/01/2023") - ) + new BodyParameter(new Currency(1.5 * 1000, "USD", "U$1.5")), + new BodyParameter(new DateTime("01/01/2023")) ) ); ``` @@ -66,7 +55,7 @@ const template_media_message = new Template( // Can also be image, document, or location new Video("https://www.w3schools.com/html/mov_bbb.mp4") ) - ), + ) ); ``` @@ -78,12 +67,8 @@ import { Template, PayloadComponent } from "whatsapp-api-js/messages"; const template_reply_buttons_message = new Template( "template_name", "en", - new PayloadComponent( - "reply_1" - ), - new PayloadComponent( - "reply_2" - ) + new PayloadComponent("reply_1"), + new PayloadComponent("reply_2") ); ``` @@ -95,12 +80,8 @@ import { Template, URLComponent } from "whatsapp-api-js/messages"; const template_call_to_action_message = new Template( "template_name", "en", - new URLComponent( - "?user_id=123" - ), - new URLComponent( - "?user_id=456" - ) + new URLComponent("?user_id=123"), + new URLComponent("?user_id=456") ); ``` @@ -112,9 +93,7 @@ import { Template, CopyComponent } from "whatsapp-api-js/messages"; const template_copy_coupon_message = new Template( "template_name", "en", - new CopyComponent( - "PROMO10" - ) + new CopyComponent("PROMO10") ); ``` @@ -131,15 +110,9 @@ import { const template_mixed_buttons_message = new Template( "template_name", "en", - new CopyComponent( - "PROMO10" - ), - new URLComponent( - "?code=PROMO10" - ), - new PayloadComponent( - "send_catalog" - ) + new CopyComponent("PROMO10"), + new URLComponent("?code=PROMO10"), + new PayloadComponent("send_catalog") ); ``` @@ -151,9 +124,7 @@ import { Template, CatalogComponent, Product } from "whatsapp-api-js/messages"; const template_catalog_message = new Template( "template_name", "en", - new CatalogComponent( - new Product("thumbnail") - ) + new CatalogComponent(new Product("thumbnail")) ); ``` @@ -201,9 +172,7 @@ import { const template_multi_product_message = new Template( "template_name", "en", - new BodyComponent( - new BodyParameter("PROMO10") - ), + new BodyComponent(new BodyParameter("PROMO10")), new CarouselComponent( new CarouselCard( new Image(image), @@ -222,11 +191,7 @@ const template_multi_product_message = new Template( ```ts import { Template } from "whatsapp-api-js/messages"; -const template_otp_message = Template.OTP( - "template_name", - "en", - "123456" -); +const template_otp_message = Template.OTP("template_name", "en", "123456"); ``` ## Documentation diff --git a/README.md b/README.md index d8c06cbb..94b75b21 100644 --- a/README.md +++ b/README.md @@ -7,17 +7,17 @@ A TypeScript server agnostic Whatsapp's Official API framework. ## List of contents -- [whatsapp-api-js v2](#whatsapp-api-js-v2) - - [List of contents](#list-of-contents) - - [Set up](#set-up) - - [Examples and Tutorials](#examples-and-tutorials) - - [Types](#types) - - [Changelog](#changelog) - - [Documentation](#documentation) - - [Contributors](#contributors) - - [Contributions](#contributions) - - [Breaking changes](#breaking-changes) - - [Beta releases](#beta-releases) +- [whatsapp-api-js v2](#whatsapp-api-js-v2) + - [List of contents](#list-of-contents) + - [Set up](#set-up) + - [Examples and Tutorials](#examples-and-tutorials) + - [Types](#types) + - [Changelog](#changelog) + - [Documentation](#documentation) + - [Contributors](#contributors) + - [Contributions](#contributions) + - [Breaking changes](#breaking-changes) + - [Beta releases](#beta-releases) ## Set up @@ -48,42 +48,70 @@ const Whatsapp = new WhatsAppAPI({ token: TOKEN, appSecret: APP_SECRET }); function post(e) { // The handlers work with any framework, as long as you pass the correct data // You can also use one of the middlewares provided in the package, keep reading - return Whatsapp.post(JSON.parse(e.data), e.data, e.headers["x-hub-signature-256"]); + return Whatsapp.post( + JSON.parse(e.data), + e.data, + e.headers["x-hub-signature-256"] + ); } Whatsapp.on.message = async ({ phoneID, from, message, name }) => { - console.log(`User ${name} (${from}) sent to bot ${phoneID} ${JSON.stringify(message)}`); + console.log( + `User ${name} (${from}) sent to bot ${phoneID} ${JSON.stringify( + message + )}` + ); let promise; if (message.type === "text") { - promise = Whatsapp.sendMessage(phoneID, from, new Text(`*${name}* said:\n\n${message.text.body}`), message.id); + promise = Whatsapp.sendMessage( + phoneID, + from, + new Text(`*${name}* said:\n\n${message.text.body}`), + message.id + ); } if (message.type === "image") { - promise = Whatsapp.sendMessage(phoneID, from, new Image(message.image.id, true, `Nice photo, ${name}`)); + promise = Whatsapp.sendMessage( + phoneID, + from, + new Image(message.image.id, true, `Nice photo, ${name}`) + ); } if (message.type === "document") { - promise = Whatsapp.sendMessage(phoneID, from, new Document(message.document.id, true, undefined, "Our document")); + promise = Whatsapp.sendMessage( + phoneID, + from, + new Document(message.document.id, true, undefined, "Our document") + ); } if (message.type === "contacts") { - promise = Whatsapp.sendMessage(phoneID, from, new Contacts.Contacts( - [ - new Contacts.Name(name, "First name", "Last name"), - new Contacts.Phone(phone), - new Contacts.Birthday("2022", "04", "25"), - ], - [ - new Contacts.Name("John", "First name", "Last name"), - new Contacts.Organization("Company", "Department", "Title"), - new Contacts.Url("https://www.google.com", "WORK"), - ] - )); + promise = Whatsapp.sendMessage( + phoneID, + from, + new Contacts.Contacts( + [ + new Contacts.Name(name, "First name", "Last name"), + new Contacts.Phone(phone), + new Contacts.Birthday("2022", "04", "25") + ], + [ + new Contacts.Name("John", "First name", "Last name"), + new Contacts.Organization("Company", "Department", "Title"), + new Contacts.Url("https://www.google.com", "WORK") + ] + ) + ); } - console.log(await promise ?? "There are more types of messages, such as locations, templates, interactive, reactions and all the other media types."); + console.log( + (await promise) ?? + "There are more types of messages, such as locations, templates, interactive, reactions and all the other media types." + ); Whatsapp.markAsRead(phoneID, message.id); }; diff --git a/docs_statics/404.html b/docs_statics/404.html index 829eda8f..6558df09 100644 --- a/docs_statics/404.html +++ b/docs_statics/404.html @@ -1,33 +1,96 @@ - + - - - - Page Not Found + + + + Page Not Found - - - -
-

404

-

Page Not Found

-

The specified file was not found on this website. Please check the URL for mistakes and try again.

-

Why am I seeing this?

-

This page was generated by the Firebase Command-Line Interface. To modify it, edit the 404.html file in your project's configured public directory.

-
- + + + +
+

404

+

Page Not Found

+

+ The specified file was not found on this website. Please check + the URL for mistakes and try again. +

+

Why am I seeing this?

+

+ This page was generated by the Firebase Command-Line Interface. + To modify it, edit the 404.html file in your + project's configured public directory. +

+
+ diff --git a/firebase.json b/firebase.json index 6de1d22e..563b7454 100644 --- a/firebase.json +++ b/firebase.json @@ -1,10 +1,6 @@ { - "hosting": { - "public": "docs", - "ignore": [ - "firebase.json", - "**/.*", - "**/node_modules/**" - ] - } + "hosting": { + "public": "docs", + "ignore": ["firebase.json", "**/.*", "**/node_modules/**"] + } } diff --git a/package.json b/package.json index 35825265..001f816d 100644 --- a/package.json +++ b/package.json @@ -1,156 +1,156 @@ { - "name": "whatsapp-api-js", - "version": "2.1.0", - "author": "Secreto31126", - "description": "A TypeScript server agnostic Whatsapp's Official API framework", - "license": "MIT", - "type": "module", - "sideEffects": false, - "engines": { - "node": ">=18" - }, - "files": [ - "lib/**/*" - ], - "types": "lib/types/index.d.ts", - "module": "lib/esm/index.js", - "main": "lib/cjs/index.js", - "exports": { - ".": { - "types": "./lib/types/index.d.ts", - "import": "./lib/esm/index.js", - "require": "./lib/cjs/index.js" + "name": "whatsapp-api-js", + "version": "2.1.0", + "author": "Secreto31126", + "description": "A TypeScript server agnostic Whatsapp's Official API framework", + "license": "MIT", + "type": "module", + "sideEffects": false, + "engines": { + "node": ">=18" }, - "./messages": { - "types": "./lib/types/messages/index.d.ts", - "import": "./lib/esm/messages/index.js", - "require": "./lib/cjs/messages/index.js" + "files": [ + "lib/**/*" + ], + "types": "lib/types/index.d.ts", + "module": "lib/esm/index.js", + "main": "lib/cjs/index.js", + "exports": { + ".": { + "types": "./lib/types/index.d.ts", + "import": "./lib/esm/index.js", + "require": "./lib/cjs/index.js" + }, + "./messages": { + "types": "./lib/types/messages/index.d.ts", + "import": "./lib/esm/messages/index.js", + "require": "./lib/cjs/messages/index.js" + }, + "./messages/*": { + "types": "./lib/types/messages/*.d.ts", + "import": "./lib/esm/messages/*.js", + "require": "./lib/cjs/messages/*.js" + }, + "./setup": null, + "./setup/index": null, + "./setup/*": { + "types": "./lib/types/setup/*.d.ts", + "import": "./lib/esm/setup/*.js", + "require": "./lib/cjs/setup/*.js" + }, + "./middleware": null, + "./middleware/index": null, + "./middleware/*": { + "types": "./lib/types/middleware/*.d.ts", + "import": "./lib/esm/middleware/*.js", + "require": "./lib/cjs/middleware/*.js" + }, + "./emitters": { + "types": "./lib/types/emitters.d.ts" + }, + "./types": { + "types": "./lib/types/types.d.ts", + "import": "./lib/esm/types.js", + "require": "./lib/cjs/types.js" + } }, - "./messages/*": { - "types": "./lib/types/messages/*.d.ts", - "import": "./lib/esm/messages/*.js", - "require": "./lib/cjs/messages/*.js" + "//": [ + "https://github.com/andrewbranch/example-subpath-exports-ts-compat/blob/main/examples/node_modules/types-versions-wildcards/package.json", + "Without this, IntelliSense will throw an error when importing subpaths ONLY on JS files, although it does run fine with Node.", + "Even more stunishing: if included, IntelliSense works even BETTER than with TS." + ], + "typesVersions": { + "*": { + ".": [ + "lib/types/index.d.ts" + ], + "messages": [ + "lib/types/messages/index.d.ts" + ], + "messages/*": [ + "lib/types/messages/*.d.ts" + ], + "setup/index": [], + "setup/*": [ + "lib/types/setup/*.d.ts" + ], + "middleware/index": [], + "middleware/*": [ + "lib/types/middleware/*.d.ts" + ], + "emitters": [ + "lib/types/emitters.d.ts" + ], + "types": [ + "lib/types/types.d.ts" + ] + } }, - "./setup": null, - "./setup/index": null, - "./setup/*": { - "types": "./lib/types/setup/*.d.ts", - "import": "./lib/esm/setup/*.js", - "require": "./lib/cjs/setup/*.js" + "scripts": { + "build": "npm run build:code && npm run build:types", + "build:dev": "npm run build:code:dev && npm run build:types:dev", + "build:code": "node -r dotenv/config build.js", + "build:code:dev": "npm run build:code", + "build:types": "tsc", + "build:types:dev": "tsc --outDir ./lib/esm && tsc --outDir ./lib/cjs", + "test": "mocha", + "test:build": "npm run build && npm run test", + "test:watch": "mocha --reporter min --watch", + "lint": "eslint src", + "lint:fix": "eslint src --fix", + "prettier": "prettier --check .", + "prettier:write": "prettier --write .", + "coverage": "c8 mocha --reporter min", + "document": "typedoc && cp -r docs_statics/* docs/", + "clear": "rm -rf docs/ docs_temp/ lib/ coverage/" }, - "./middleware": null, - "./middleware/index": null, - "./middleware/*": { - "types": "./lib/types/middleware/*.d.ts", - "import": "./lib/esm/middleware/*.js", - "require": "./lib/cjs/middleware/*.js" + "keywords": [ + "whatsapp", + "cloud", + "api", + "framework", + "whatsapp-cloud", + "cloud-api", + "whatsapp-cloud-api", + "whatsapp-business", + "whatsapp-business-api", + "bot", + "whatsapp-bot", + "chatbot", + "bot-framework", + "typescript", + "server-agnostic", + "nodejs", + "deno", + "bun", + "bot-api", + "whatsapp-api", + "business-api" + ], + "repository": { + "type": "git", + "url": "https://github.com/Secreto31126/whatsapp-api-js.git" }, - "./emitters": { - "types": "./lib/types/emitters.d.ts" - }, - "./types": { - "types": "./lib/types/types.d.ts", - "import": "./lib/esm/types.js", - "require": "./lib/cjs/types.js" - } - }, - "//": [ - "https://github.com/andrewbranch/example-subpath-exports-ts-compat/blob/main/examples/node_modules/types-versions-wildcards/package.json", - "Without this, IntelliSense will throw an error when importing subpaths ONLY on JS files, although it does run fine with Node.", - "Even more stunishing: if included, IntelliSense works even BETTER than with TS." - ], - "typesVersions": { - "*": { - ".": [ - "lib/types/index.d.ts" - ], - "messages": [ - "lib/types/messages/index.d.ts" - ], - "messages/*": [ - "lib/types/messages/*.d.ts" - ], - "setup/index": [], - "setup/*": [ - "lib/types/setup/*.d.ts" - ], - "middleware/index": [], - "middleware/*": [ - "lib/types/middleware/*.d.ts" - ], - "emitters": [ - "lib/types/emitters.d.ts" - ], - "types": [ - "lib/types/types.d.ts" - ] + "devDependencies": { + "@adonisjs/http-server": "^5.12.0", + "@types/express": "^4.17.17", + "@types/node": "18.17.15", + "@typescript-eslint/eslint-plugin": "6.6.0", + "@typescript-eslint/parser": "6.6.0", + "@vercel/node": "^3.0.4", + "all-contributors-cli": "^6.26.1", + "c8": "8.0.1", + "dotenv": "16.3.1", + "esbuild": "0.19.0", + "eslint": "8.49.0", + "eslint-config-prettier": "9.0.0", + "eslint-plugin-tsdoc": "0.2.17", + "glob": "10.3.4", + "mocha": "10.2.0", + "prettier": "3.0.3", + "sinon": "16.0.0", + "typedoc": "0.25.1", + "typescript": "5.2.2", + "undici": "5.24.0" } - }, - "scripts": { - "build": "npm run build:code && npm run build:types", - "build:dev": "npm run build:code:dev && npm run build:types:dev", - "build:code": "node -r dotenv/config build.js", - "build:code:dev": "npm run build:code", - "build:types": "tsc", - "build:types:dev": "tsc --outDir ./lib/esm && tsc --outDir ./lib/cjs", - "test": "mocha", - "test:build": "npm run build && npm run test", - "test:watch": "mocha --reporter min --watch", - "lint": "eslint src", - "lint:fix": "eslint src --fix", - "prettier": "prettier --check .", - "prettier:write": "prettier --write .", - "coverage": "c8 mocha --reporter min", - "document": "typedoc && cp -r docs_statics/* docs/", - "clear": "rm -rf docs/ docs_temp/ lib/ coverage/" - }, - "keywords": [ - "whatsapp", - "cloud", - "api", - "framework", - "whatsapp-cloud", - "cloud-api", - "whatsapp-cloud-api", - "whatsapp-business", - "whatsapp-business-api", - "bot", - "whatsapp-bot", - "chatbot", - "bot-framework", - "typescript", - "server-agnostic", - "nodejs", - "deno", - "bun", - "bot-api", - "whatsapp-api", - "business-api" - ], - "repository": { - "type": "git", - "url": "https://github.com/Secreto31126/whatsapp-api-js.git" - }, - "devDependencies": { - "@adonisjs/http-server": "^5.12.0", - "@types/express": "^4.17.17", - "@types/node": "18.17.15", - "@typescript-eslint/eslint-plugin": "6.6.0", - "@typescript-eslint/parser": "6.6.0", - "@vercel/node": "^3.0.4", - "all-contributors-cli": "^6.26.1", - "c8": "8.0.1", - "dotenv": "16.3.1", - "esbuild": "0.19.0", - "eslint": "8.49.0", - "eslint-config-prettier": "9.0.0", - "eslint-plugin-tsdoc": "0.2.17", - "glob": "10.3.4", - "mocha": "10.2.0", - "prettier": "3.0.3", - "sinon": "16.0.0", - "typedoc": "0.25.1", - "typescript": "5.2.2", - "undici": "5.24.0" - } } diff --git a/tsconfig.json b/tsconfig.json index 3cdfb1be..31b93395 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,16 @@ { - "include": ["src/**/*"], - "compilerOptions": { - "lib": ["ESNext"], - "outDir": "lib/types", - "types": ["node", "undici"], - "declaration": true, - "declarationMap": true, - "emitDeclarationOnly": true, - "isolatedModules": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "strict": true, - "skipLibCheck": true - } + "include": ["src/**/*"], + "compilerOptions": { + "lib": ["ESNext"], + "outDir": "lib/types", + "types": ["node", "undici"], + "declaration": true, + "declarationMap": true, + "emitDeclarationOnly": true, + "isolatedModules": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true + } } diff --git a/typedoc.json b/typedoc.json index 6dbbf3ce..13064ee6 100644 --- a/typedoc.json +++ b/typedoc.json @@ -9,9 +9,7 @@ "src/setup/index.ts", "src/middleware/index.ts" ], - "exclude": [ - "**/node_modules/**" - ], + "exclude": ["**/node_modules/**"], "out": "docs", "includeVersion": true, "excludeInternal": true