├── .vscode ├── extensions.json └── settings.json ├── deps.ts ├── dev_deps.ts ├── .github ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── feature_request.md │ └── bug_report.md └── workflows │ ├── npm-push.yml │ └── ci.yml ├── deno.jsonc ├── tests ├── webhook.test.ts ├── wallet_transaction.test.ts ├── event.test.ts ├── organization.test.ts ├── applied_coupon.test.ts ├── add_on.test.ts ├── coupon.test.ts ├── subscription.test.ts ├── utils.ts ├── billable_metric.test.ts ├── wallet.test.ts ├── plan.test.ts ├── customer.test.ts ├── credit_note.test.ts └── invoice.test.ts ├── LICENSE ├── PULL_REQUEST_TEMPLATE.md ├── mod.ts ├── scripts └── build_npm.ts ├── .gitignore ├── README.md ├── CODE_OF_CONDUCT.md ├── deno.lock └── CONTRIBUTING.md /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["denoland.vscode-deno"] 3 | } 4 | -------------------------------------------------------------------------------- /deps.ts: -------------------------------------------------------------------------------- 1 | export { build, emptyDir } from "https://deno.land/x/dnt@0.38.0/mod.ts"; 2 | -------------------------------------------------------------------------------- /dev_deps.ts: -------------------------------------------------------------------------------- 1 | export { assertEquals } from "https://deno.land/std@0.196.0/assert/mod.ts"; 2 | export * as mf from "https://deno.land/x/mock_fetch@0.3.0/mod.ts"; 3 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "deno.enable": true, 3 | "deno.lint": true, 4 | "editor.formatOnSave": true, 5 | "[typescript]": { 6 | "editor.defaultFormatter": "denoland.vscode-deno" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Lago Questions and Discussions 4 | url: https://lago-community.slack.com 5 | about: Please ask and answer questions on the community forums. 6 | -------------------------------------------------------------------------------- /deno.jsonc: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": { 3 | "build": "deno task generate:openapi && deno task generate:npm-package", 4 | "generate:npm-package": "deno run -A scripts/build_npm.ts", 5 | "generate:openapi": "npx -y swagger-typescript-api@13.0.2 -p https://swagger.getlago.com/openapi.yaml --union-enums -o ./openapi -n client.ts", 6 | "test": "deno test ./tests --parallel" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /.github/workflows/npm-push.yml: -------------------------------------------------------------------------------- 1 | name: Push to NPM 2 | 3 | on: 4 | workflow_dispatch: 5 | release: 6 | types: [published] 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | - uses: actions/setup-node@v3 14 | with: 15 | node-version: 18 16 | registry-url: https://registry.npmjs.org/ 17 | - uses: denoland/setup-deno@v1 18 | with: 19 | deno-version: v1.x 20 | - run: deno task build 21 | - run: npm publish ./npm 22 | env: 23 | NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[FEAT]: " 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Node.js CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - "main" 7 | pull_request: 8 | types: [opened, synchronize, reopened] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | 14 | strategy: 15 | matrix: 16 | node-version: [18.x, 19.x, 20.x, 21.x, 22.x, 23.x] 17 | 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Use Node.js ${{ matrix.node-version }} 21 | uses: actions/setup-node@v3 22 | with: 23 | node-version: ${{ matrix.node-version }} 24 | - name: Use Deno 25 | uses: denoland/setup-deno@v1 26 | with: 27 | deno-version: v1.x 28 | - name: Build project 29 | run: deno task build 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]: " 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Support** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /tests/webhook.test.ts: -------------------------------------------------------------------------------- 1 | import { lagoTest, unauthorizedErrorResponse } from "./utils.ts"; 2 | 3 | Deno.test( 4 | "Successfully sent webhook public key request responds with 2xx", 5 | async (t) => { 6 | await lagoTest({ 7 | t, 8 | testType: "200", 9 | route: "GET@/api/v1/webhooks/public_key", 10 | clientPath: ["webhooks", "fetchPublicKey"], 11 | inputParams: [], 12 | responseObject: "aGVsbG8=", 13 | status: 200, 14 | }); 15 | }, 16 | ); 17 | 18 | Deno.test("Status code is not 2xx", async (t) => { 19 | await lagoTest({ 20 | t, 21 | testType: "error", 22 | route: "GET@/api/v1/webhooks/public_key", 23 | clientPath: ["webhooks", "fetchPublicKey"], 24 | inputParams: [], 25 | responseObject: unauthorizedErrorResponse, 26 | status: 422, 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Lago 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Pull Request template 2 | 3 | Please, go through these steps before you submit a PR. 4 | 5 | 1. Make sure that your PR is not a duplicate. 6 | 2. If not, then make sure that: 7 | 8 | a. You have done your changes in a separate branch. Branches MUST have descriptive names that start with either the `fix/` or `feature/` prefixes. Good examples are: `fix/signin-issue` or `feature/issue-templates`. 9 | 10 | b. You have a descriptive commit message with a short title (first line). 11 | 12 | c. You have only one commit (if not, squash them into one commit). 13 | 14 | d. `npm test` doesn't throw any error. If it does, fix them first and amend your commit (`git commit --amend`). 15 | 16 | 3. **After** these steps, you're ready to open a pull request. 17 | 18 | a. Give a descriptive title to your PR. 19 | 20 | b. Describe your changes. 21 | 22 | c. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such). 23 | 24 | d. Add the corresponding labels to your pull request (ex: feature, improvement, bug...) 25 | 26 | IMPORTANT: Please review the [CONTRIBUTING.md](../CONTRIBUTING.md) file for detailed contributing guidelines. 27 | 28 | **PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING** 29 | -------------------------------------------------------------------------------- /mod.ts: -------------------------------------------------------------------------------- 1 | // deno-lint-ignore-file no-explicit-any 2 | import { Api, ApiConfig, HttpResponse } from "./openapi/client.ts"; 3 | 4 | export const Client = (apiKey: string, apiConfig?: ApiConfig) => { 5 | const api = new Api({ 6 | securityWorker: (apiKey) => 7 | apiKey ? { headers: { Authorization: `Bearer ${apiKey}` } } : {}, 8 | // Cloudflare Workers doesn't support some options like credentials so need to override default 9 | baseApiParams: { 10 | redirect: "follow", 11 | }, 12 | ...apiConfig, 13 | }); 14 | api.setSecurityData(apiKey); 15 | return api; 16 | }; 17 | 18 | type ExtractLagoError = E extends ( 19 | ...args: any 20 | ) => Promise> ? P 21 | : never; 22 | 23 | // https://github.com/remix-run/remix/blob/ef26f7671a9619966a6cfa3c39e196d44fbf32cf/packages/remix-server-runtime/responses.ts#L60 24 | function isResponse(value: any): value is Response { 25 | return ( 26 | value != null && 27 | typeof value.status === "number" && 28 | typeof value.statusText === "string" && 29 | typeof value.headers === "object" && 30 | typeof value.body !== "undefined" 31 | ); 32 | } 33 | 34 | export async function getLagoError(error: any) { 35 | if (isResponse(error)) { 36 | if (!error.bodyUsed) { 37 | const errorJson = await error.json() as ExtractLagoError; 38 | return errorJson; 39 | } 40 | return (error as HttpResponse).error as ExtractLagoError; 41 | } 42 | throw new Error(error); 43 | } 44 | 45 | export * from "./openapi/client.ts"; 46 | -------------------------------------------------------------------------------- /scripts/build_npm.ts: -------------------------------------------------------------------------------- 1 | import { build, emptyDir } from "../deps.ts"; 2 | 3 | await emptyDir("./npm"); 4 | 5 | await build({ 6 | entryPoints: ["./mod.ts"], 7 | outDir: "./npm", 8 | typeCheck: false, 9 | shims: { 10 | // see JS docs for overview and more options 11 | deno: "dev", 12 | custom: [ 13 | { 14 | package: { 15 | name: "urlpattern-polyfill", 16 | version: "^9.0.0", 17 | }, 18 | globalNames: [ 19 | { 20 | name: "URLPattern", 21 | exportName: "URLPattern", 22 | }, 23 | ], 24 | }, 25 | ], 26 | }, 27 | compilerOptions: { 28 | target: "Latest", 29 | lib: ["DOM", "ES2022"], 30 | }, 31 | package: { 32 | // package.json properties 33 | name: "lago-javascript-client", 34 | sideEffects: false, 35 | version: "v1.36.0", 36 | description: "Lago JavaScript API Client", 37 | repository: { 38 | type: "git", 39 | url: "git+https://github.com/getlago/lago-javascript-client.git", 40 | }, 41 | keywords: ["Lago", "Node", "API", "Client"], 42 | contributors: [ 43 | "Lovro Colic", 44 | "Jérémy Denquin", 45 | "Arjun Yelamanchili", 46 | "Vincent Pochet", 47 | "Romain Sempé", 48 | ], 49 | license: "MIT", 50 | bugs: { 51 | url: "https://github.com/getlago/lago-javascript-client/issues", 52 | }, 53 | homepage: "https://github.com/getlago/lago-javascript-client#readme", 54 | }, 55 | }); 56 | 57 | // post build steps 58 | Deno.copyFileSync("LICENSE", "npm/LICENSE"); 59 | Deno.copyFileSync("README.md", "npm/README.md"); 60 | -------------------------------------------------------------------------------- /tests/wallet_transaction.test.ts: -------------------------------------------------------------------------------- 1 | import type { WalletTransaction, WalletTransactionInput } from "../mod.ts"; 2 | import { lagoTest, unprocessableErrorResponse } from "./utils.ts"; 3 | 4 | const walletTransactionInput = { 5 | "wallet_transaction": { 6 | "wallet_id": "985da83c-c007-4fbb-afcd-b00c07c41ffe", 7 | "paid_credits": 100, 8 | "granted_credits": 10, 9 | }, 10 | } as const satisfies WalletTransactionInput; 11 | 12 | Deno.test( 13 | "Successfully sent wallet transaction responds with 2xx", 14 | async (t) => { 15 | await lagoTest({ 16 | t, 17 | testType: "200", 18 | route: "POST@/api/v1/wallet_transactions", 19 | clientPath: ["walletTransactions", "createWalletTransaction"], 20 | inputParams: [walletTransactionInput], 21 | responseObject: { 22 | wallet_transactions: [ 23 | { 24 | lago_id: "183da83c-c007-4fbb-afcd-b00c07c41ffe", 25 | lago_wallet_id: "", 26 | status: "settled", 27 | transaction_type: "inbound", 28 | amount: 500, 29 | credit_amount: 500, 30 | settled_at: "2022-09-14T16:35:31Z", 31 | created_at: "2022-09-14T16:35:31Z", 32 | }, 33 | ], 34 | }, 35 | status: 200, 36 | }); 37 | }, 38 | ); 39 | 40 | Deno.test("Status code is not 2xx", async (t) => { 41 | await lagoTest({ 42 | t, 43 | testType: "error", 44 | route: "POST@/api/v1/wallet_transactions", 45 | clientPath: ["walletTransactions", "createWalletTransaction"], 46 | inputParams: [walletTransactionInput], 47 | responseObject: unprocessableErrorResponse, 48 | status: 422, 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /tests/event.test.ts: -------------------------------------------------------------------------------- 1 | import type { BatchEventInput, EventInput } from "../mod.ts"; 2 | import { 3 | lagoTest, 4 | notFoundErrorResponse, 5 | unprocessableErrorResponse, 6 | } from "./utils.ts"; 7 | 8 | const eventInput = { 9 | event: { 10 | transaction_id: "transactionId", 11 | external_customer_id: "externalCustomerId", 12 | code: "code", 13 | }, 14 | } as const satisfies (EventInput | BatchEventInput); 15 | // const batchEvent = new BatchEvent({ 16 | // transactionId: "transactionId", 17 | // externalSubscriptionIds: ["123", "456"], 18 | // code: "code", 19 | // }); 20 | 21 | Deno.test("Successfully sent event responds with 2xx", async (t) => { 22 | await lagoTest({ 23 | t, 24 | testType: "200", 25 | route: "POST@/api/v1/events", 26 | clientPath: ["events", "createEvent"], 27 | inputParams: [eventInput], 28 | status: 200, 29 | }); 30 | }); 31 | 32 | Deno.test("Status code is not 2xx", async (t) => { 33 | await lagoTest({ 34 | t, 35 | testType: "error", 36 | route: "POST@/api/v1/events", 37 | clientPath: ["events", "createEvent"], 38 | inputParams: [eventInput], 39 | responseObject: unprocessableErrorResponse, 40 | status: 422, 41 | }); 42 | }); 43 | 44 | Deno.test("Successfully sent batch event responds with 2xx", async (t) => { 45 | await lagoTest({ 46 | t, 47 | testType: "200", 48 | route: "POST@/api/v1/events/batch", 49 | clientPath: ["events", "createBatchEvents"], 50 | inputParams: [eventInput], 51 | status: 200, 52 | }); 53 | }); 54 | 55 | Deno.test("Successfully find an event", async (t) => { 56 | await lagoTest({ 57 | t, 58 | testType: "200", 59 | route: "GET@/api/v1/events/transaction_id", 60 | clientPath: ["events", "findEvent"], 61 | inputParams: ["transaction_id"], 62 | status: 200, 63 | }); 64 | }); 65 | 66 | Deno.test("Error when finding an event", async (t) => { 67 | await lagoTest({ 68 | t, 69 | testType: "error", 70 | route: "GET@/api/v1/events/transaction_id", 71 | clientPath: ["events", "findEvent"], 72 | inputParams: ["transaction_id"], 73 | responseObject: notFoundErrorResponse, 74 | status: 404, 75 | }); 76 | }); 77 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # Snowpack dependency directory (https://snowpack.dev/) 45 | web_modules/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # parcel-bundler cache (https://parceljs.org/) 72 | .cache 73 | .parcel-cache 74 | 75 | # Gatsby files 76 | .cache/ 77 | # Comment in the public line in if your project uses Gatsby and not Next.js 78 | # https://nextjs.org/blog/next-9-1#public-directory-support 79 | # public 80 | 81 | # vuepress build output 82 | .vuepress/dist 83 | 84 | # FuseBox cache 85 | .fusebox/ 86 | 87 | # TernJS port file 88 | .tern-port 89 | 90 | # Stores VSCode versions used for testing VSCode extensions 91 | .vscode-test 92 | 93 | # yarn v2 94 | .yarn/cache 95 | .yarn/unplugged 96 | .yarn/build-state.yml 97 | .yarn/install-state.gz 98 | .pnp.* 99 | 100 | .idea/* 101 | *.iml 102 | 103 | npm/ 104 | openapi/ 105 | -------------------------------------------------------------------------------- /tests/organization.test.ts: -------------------------------------------------------------------------------- 1 | import type { Organization, OrganizationInput } from "../mod.ts"; 2 | import { lagoTest, unprocessableErrorResponse } from "./utils.ts"; 3 | 4 | const orgInput = { 5 | "organization": { 6 | "webhook_url": "https://example.com", 7 | "country": "CZ", 8 | "address_line1": "address1", 9 | "address_line2": "address2", 10 | "state": "state1", 11 | "zipcode": "10000", 12 | "email": "example@example.com", 13 | "city": "City", 14 | "legal_name": "name1", 15 | "legal_number": "10000", 16 | "timezone": "Europe/Paris", 17 | "billing_configuration": { 18 | "invoice_footer": "text", 19 | "vat_rate": 25, 20 | "invoice_grace_period": 5, 21 | }, 22 | }, 23 | } satisfies OrganizationInput; 24 | 25 | const orgResponse = { 26 | "organization": { 27 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 28 | "name": "example name", 29 | "created_at": "2022-09-14T16:35:31Z", 30 | "webhook_url": "https://example.com", 31 | "country": "CZ", 32 | "address_line1": "address1", 33 | "address_line2": "address2", 34 | "state": "state1", 35 | "zipcode": "10000", 36 | "email": "example@example.com", 37 | "city": "City", 38 | "legal_name": "name1", 39 | "legal_number": "10000", 40 | "timezone": "UTC", 41 | "billing_configuration": { 42 | "invoice_footer": "text", 43 | "vat_rate": 25, 44 | "invoice_grace_period": 5, 45 | }, 46 | }, 47 | } satisfies Organization; 48 | 49 | Deno.test( 50 | "Successfully sent organization update status responds with 2xx", 51 | async (t) => { 52 | await lagoTest({ 53 | t, 54 | testType: "200", 55 | route: "PUT@/api/v1/organizations", 56 | clientPath: ["organizations", "updateOrganization"], 57 | inputParams: [orgInput], 58 | responseObject: orgResponse, 59 | status: 200, 60 | }); 61 | }, 62 | ); 63 | 64 | Deno.test("Status code is not 2xx", async (t) => { 65 | await lagoTest({ 66 | t, 67 | testType: "error", 68 | route: "PUT@/api/v1/organizations", 69 | clientPath: ["organizations", "updateOrganization"], 70 | inputParams: [orgInput], 71 | responseObject: unprocessableErrorResponse, 72 | status: 422, 73 | }); 74 | }); 75 | -------------------------------------------------------------------------------- /tests/applied_coupon.test.ts: -------------------------------------------------------------------------------- 1 | import type { AppliedCouponInput, AppliedCoupons } from "../mod.ts"; 2 | import { lagoTest, unprocessableErrorResponse } from "./utils.ts"; 3 | 4 | const appliedCoupon = { 5 | applied_coupon: { 6 | external_customer_id: "externalCustomerId", 7 | coupon_code: "coupon-code", 8 | }, 9 | } as const satisfies AppliedCouponInput; 10 | 11 | Deno.test("Successfully sent apply coupon responds with 2xx", async (t) => { 12 | await lagoTest({ 13 | t, 14 | testType: "200", 15 | route: "POST@/api/v1/applied_coupons", 16 | clientPath: ["appliedCoupons", "applyCoupon"], 17 | inputParams: [appliedCoupon], 18 | responseObject: { 19 | applied_coupon: { 20 | lago_id: "b7ab2926-1de8-4428-9bcd-779314ac129b", 21 | lago_coupon_id: "b7ab2926-1de8-4428-9bcd-779314ac129b", 22 | coupon_code: "coupon-code", 23 | external_customer_id: "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba", 24 | lago_customer_id: "99a6094e-199b-4101-896a-54e927ce7bd7", 25 | amount_cents: 123, 26 | amount_currency: "EUR", 27 | frequency: "once", 28 | frequency_duration: undefined, 29 | percentage_rate: undefined, 30 | expiration_at: "2022-04-29", 31 | created_at: "2022-04-29T08:59:51Z", 32 | terminated_at: "2022-04-29T08:59:51Z", 33 | }, 34 | }, 35 | status: 200, 36 | }); 37 | }); 38 | 39 | Deno.test("Status code is not 2xx", async (t) => { 40 | await lagoTest({ 41 | t, 42 | testType: "error", 43 | route: "POST@/api/v1/applied_coupons", 44 | clientPath: ["appliedCoupons", "applyCoupon"], 45 | inputParams: [appliedCoupon], 46 | responseObject: unprocessableErrorResponse, 47 | status: 422, 48 | }); 49 | }); 50 | 51 | Deno.test( 52 | "Successfully sent applied coupon find all request responds with 2xx", 53 | async (t) => { 54 | await lagoTest({ 55 | t, 56 | testType: "200", 57 | route: "GET@/api/v1/applied_coupons", 58 | clientPath: ["appliedCoupons", "findAllAppliedCoupons"], 59 | inputParams: [], 60 | responseObject: { 61 | applied_coupons: [appliedCoupon.applied_coupon], 62 | } satisfies AppliedCoupons, 63 | status: 200, 64 | }); 65 | }, 66 | ); 67 | 68 | Deno.test( 69 | "Successfully sent applied coupon find all request with options responds with 2xx", 70 | async (t) => { 71 | await lagoTest({ 72 | t, 73 | testType: "200", 74 | route: "GET@/api/v1/applied_coupons", 75 | clientPath: ["appliedCoupons", "findAllAppliedCoupons"], 76 | inputParams: [{ 77 | per_page: 2, 78 | page: 3, 79 | }], 80 | responseObject: { 81 | applied_coupons: [appliedCoupon.applied_coupon], 82 | } satisfies AppliedCoupons, 83 | status: 200, 84 | urlParams: { page: "3", per_page: "2" }, 85 | }); 86 | }, 87 | ); 88 | -------------------------------------------------------------------------------- /tests/add_on.test.ts: -------------------------------------------------------------------------------- 1 | import type { AddOn, AddOnCreateInput } from "../mod.ts"; 2 | import { lagoTest, unprocessableErrorResponse } from "./utils.ts"; 3 | 4 | const addOn = { 5 | add_on: { 6 | name: "name1", 7 | code: "code1", 8 | amount_cents: 10000, 9 | amount_currency: "USD", 10 | }, 11 | } as const satisfies AddOnCreateInput; 12 | 13 | const addOnResponse = { 14 | add_on: { 15 | lago_id: "b7ab2926-1de8-4428-9bcd-779314ac129b", 16 | name: "name2", 17 | code: "add_on_code", 18 | amount_cents: 1000, 19 | amount_currency: "EUR", 20 | description: "description", 21 | created_at: "2022-04-29T08:59:51Z", 22 | }, 23 | } as const satisfies AddOn; 24 | 25 | Deno.test("Successfully sent add_on responds with 2xx", async (t) => { 26 | await lagoTest({ 27 | t, 28 | testType: "200", 29 | route: "POST@/api/v1/add_ons", 30 | clientPath: ["addOns", "createAddOn"], 31 | inputParams: [addOn], 32 | responseObject: addOnResponse, 33 | status: 200, 34 | }); 35 | }); 36 | 37 | Deno.test("Status code is not 2xx", async (t) => { 38 | await lagoTest({ 39 | t, 40 | testType: "error", 41 | route: "POST@/api/v1/add_ons", 42 | clientPath: ["addOns", "createAddOn"], 43 | inputParams: [addOnResponse], 44 | responseObject: unprocessableErrorResponse, 45 | status: 422, 46 | }); 47 | }); 48 | 49 | Deno.test( 50 | "Successfully sent add_on update request responds with 2xx", 51 | async (t) => { 52 | await lagoTest({ 53 | t, 54 | testType: "200", 55 | route: "PUT@/api/v1/add_ons/code1", 56 | clientPath: ["addOns", "updateAddOn"], 57 | inputParams: ["code1", { 58 | add_on: { name: "new name", code: "new_code" }, 59 | }], 60 | responseObject: addOnResponse, 61 | status: 200, 62 | }); 63 | }, 64 | ); 65 | 66 | Deno.test( 67 | "Successfully sent add_on find request responds with 2xx", 68 | async (t) => { 69 | await lagoTest({ 70 | t, 71 | testType: "200", 72 | route: "GET@/api/v1/add_ons/code1", 73 | clientPath: ["addOns", "findAddOn"], 74 | inputParams: ["code1"], 75 | responseObject: addOnResponse, 76 | status: 200, 77 | }); 78 | }, 79 | ); 80 | 81 | Deno.test( 82 | "Successfully sent add_on destroy request responds with 2xx", 83 | async (t) => { 84 | await lagoTest({ 85 | t, 86 | testType: "200", 87 | route: "DELETE@/api/v1/add_ons/code1", 88 | clientPath: ["addOns", "destroyAddOn"], 89 | inputParams: ["code1"], 90 | responseObject: addOnResponse, 91 | status: 200, 92 | }); 93 | }, 94 | ); 95 | 96 | Deno.test( 97 | "Successfully sent add_on find all request responds with 2xx", 98 | async (t) => { 99 | await lagoTest({ 100 | t, 101 | testType: "200", 102 | route: "GET@/api/v1/add_ons", 103 | clientPath: ["addOns", "findAllAddOns"], 104 | inputParams: [], 105 | responseObject: { add_ons: [addOn.add_on] }, 106 | status: 200, 107 | }); 108 | }, 109 | ); 110 | 111 | Deno.test( 112 | "Successfully sent add_on find all request with options responds with 2xx", 113 | async (t) => { 114 | await lagoTest({ 115 | t, 116 | testType: "200", 117 | route: "GET@/api/v1/add_ons", 118 | clientPath: ["addOns", "findAllAddOns"], 119 | inputParams: [{ page: 3, per_page: 2 }], 120 | responseObject: { add_ons: [addOn.add_on] }, 121 | status: 200, 122 | urlParams: { page: "3", per_page: "2" }, 123 | }); 124 | }, 125 | ); 126 | -------------------------------------------------------------------------------- /tests/coupon.test.ts: -------------------------------------------------------------------------------- 1 | import type { Coupon, CouponCreateInput } from "../mod.ts"; 2 | import { lagoTest, unprocessableErrorResponse } from "./utils.ts"; 3 | 4 | const coupon = { 5 | coupon: { 6 | name: "name1", 7 | code: "code1", 8 | expiration: "no_expiration", 9 | amount_cents: 10000, 10 | amount_currency: "USD", 11 | }, 12 | } as const satisfies CouponCreateInput; 13 | 14 | const response = { 15 | coupon: { 16 | lago_id: "b7ab2926-1de8-4428-9bcd-779314ac129b", 17 | name: "name2", 18 | code: "coupon_code", 19 | expiration: "no_expiration", 20 | amount_cents: 1000, 21 | amount_currency: "EUR", 22 | expiration_at: undefined, 23 | frequency: "once", 24 | frequency_duration: undefined, 25 | coupon_type: "fixed_amount", 26 | percentage_rate: undefined, 27 | reusable: false, 28 | created_at: "2022-04-29T08:59:51Z", 29 | }, 30 | } as const satisfies Coupon; 31 | 32 | Deno.test("Successfully sent coupon responds with 2xx", async (t) => { 33 | await lagoTest({ 34 | t, 35 | testType: "200", 36 | route: "POST@/api/v1/coupons", 37 | clientPath: ["coupons", "createCoupon"], 38 | inputParams: [coupon], 39 | responseObject: response, 40 | status: 200, 41 | }); 42 | }); 43 | 44 | Deno.test("Status code is not 2xx", async (t) => { 45 | await lagoTest({ 46 | t, 47 | testType: "error", 48 | route: "POST@/api/v1/coupons", 49 | clientPath: ["coupons", "createCoupon"], 50 | inputParams: [coupon], 51 | responseObject: unprocessableErrorResponse, 52 | status: 422, 53 | }); 54 | }); 55 | 56 | Deno.test("Successfully sent coupon update request responds with 2xx", async (t) => { 57 | await lagoTest({ 58 | t, 59 | testType: "200", 60 | route: "PUT@/api/v1/coupons/code1", 61 | clientPath: ["coupons", "updateCoupon"], 62 | inputParams: ["code1", { 63 | coupon: { name: "new name", code: "new_code" }, 64 | }], 65 | responseObject: response, 66 | status: 200, 67 | }); 68 | }); 69 | 70 | Deno.test("Successfully sent coupon find request responds with 2xx", async (t) => { 71 | await lagoTest({ 72 | t, 73 | testType: "200", 74 | route: "GET@/api/v1/coupons/code1", 75 | clientPath: ["coupons", "findCoupon"], 76 | inputParams: ["code1"], 77 | responseObject: response, 78 | status: 200, 79 | }); 80 | }); 81 | 82 | Deno.test("Successfully sent coupon destroy request responds with 2xx", async (t) => { 83 | await lagoTest({ 84 | t, 85 | testType: "200", 86 | route: "DELETE@/api/v1/coupons/code1", 87 | clientPath: ["coupons", "destroyCoupon"], 88 | inputParams: ["code1"], 89 | responseObject: response, 90 | status: 200, 91 | }); 92 | }); 93 | 94 | Deno.test("Successfully sent coupon find all request responds with 2xx", async (t) => { 95 | await lagoTest({ 96 | t, 97 | testType: "200", 98 | route: "GET@/api/v1/coupons", 99 | clientPath: ["coupons", "findAllCoupons"], 100 | inputParams: [], 101 | responseObject: { coupons: [response.coupon] }, 102 | status: 200, 103 | }); 104 | }); 105 | 106 | Deno.test( 107 | "Successfully sent coupon find all request with options responds with 2xx", 108 | async (t) => { 109 | await lagoTest({ 110 | t, 111 | testType: "200", 112 | route: "GET@/api/v1/coupons", 113 | clientPath: ["coupons", "findAllCoupons"], 114 | inputParams: [{ page: 3, per_page: 2 }], 115 | responseObject: { coupons: [response.coupon] }, 116 | status: 200, 117 | urlParams: { page: "3", per_page: "2" }, 118 | }); 119 | }, 120 | ); 121 | -------------------------------------------------------------------------------- /tests/subscription.test.ts: -------------------------------------------------------------------------------- 1 | import type { 2 | Subscription, 3 | SubscriptionCreateInput, 4 | Subscriptions, 5 | } from "../mod.ts"; 6 | import { lagoTest, unprocessableErrorResponse } from "./utils.ts"; 7 | 8 | const subscriptionInput = { 9 | "subscription": { 10 | "external_customer_id": "12345", 11 | "plan_code": "example_code", 12 | "name": "Test name", 13 | "external_id": "54321", 14 | "billing_time": "calendar", 15 | "subscription_at": "2022-08-08T00:00:00Z", 16 | }, 17 | } satisfies SubscriptionCreateInput; 18 | 19 | const subscriptionResponse = { 20 | "subscription": { 21 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 22 | "external_id": "12345", 23 | "lago_customer_id": "995da83c-c007-4fbb-afcd-b00c07c41tre", 24 | "external_customer_id": "54321", 25 | "name": "Test subscription", 26 | "plan_code": "plan_code", 27 | "status": "active", 28 | "billing_time": "calendar", 29 | "subscription_at": "2022-09-14T16:35:31Z", 30 | "started_at": "2022-09-14T16:35:31Z", 31 | "terminated_at": "2022-09-14T16:35:31Z", 32 | "canceled_at": "2022-09-14T16:35:31Z", 33 | "created_at": "2022-09-14T16:35:31Z", 34 | "previous_plan_code": "previous_code", 35 | "next_plan_code": "next_code", 36 | "downgrade_plan_date": "2022-09-14T16:35:31Z", 37 | }, 38 | } satisfies Subscription; 39 | 40 | const subscriptionsResponse = { 41 | subscriptions: [subscriptionResponse.subscription], 42 | } satisfies Subscriptions; 43 | 44 | Deno.test("Successfully sent subscription responds with 2xx", async (t) => { 45 | await lagoTest({ 46 | t, 47 | testType: "200", 48 | route: "POST@/api/v1/subscriptions", 49 | clientPath: ["subscriptions", "createSubscription"], 50 | inputParams: [subscriptionInput], 51 | responseObject: subscriptionResponse, 52 | status: 200, 53 | }); 54 | }); 55 | 56 | Deno.test("Status code is not 2xx", async (t) => { 57 | await lagoTest({ 58 | t, 59 | testType: "error", 60 | route: "POST@/api/v1/subscriptions", 61 | clientPath: ["subscriptions", "createSubscription"], 62 | inputParams: [subscriptionInput], 63 | responseObject: unprocessableErrorResponse, 64 | status: 422, 65 | }); 66 | }); 67 | 68 | Deno.test( 69 | "Successfully sent subscription update request responds with 2xx", 70 | async (t) => { 71 | await lagoTest({ 72 | t, 73 | testType: "200", 74 | route: "PUT@/api/v1/subscriptions/id", 75 | clientPath: ["subscriptions", "updateSubscription"], 76 | inputParams: ["id", subscriptionInput], 77 | responseObject: subscriptionResponse, 78 | status: 200, 79 | }); 80 | }, 81 | ); 82 | 83 | Deno.test( 84 | "Successfully sent subscription destroy request responds with 2xx", 85 | async (t) => { 86 | await lagoTest({ 87 | t, 88 | testType: "200", 89 | route: "DELETE@/api/v1/subscriptions/id", 90 | clientPath: ["subscriptions", "destroySubscription"], 91 | inputParams: ["id"], 92 | responseObject: subscriptionResponse, 93 | status: 200, 94 | }); 95 | }, 96 | ); 97 | 98 | Deno.test( 99 | "Successfully sent subscription find all request with options responds with 2xx", 100 | async (t) => { 101 | await lagoTest({ 102 | t, 103 | testType: "200", 104 | route: "GET@/api/v1/subscriptions", 105 | clientPath: ["subscriptions", "findAllSubscriptions"], 106 | inputParams: [{ external_customer_id: "2" }], 107 | responseObject: subscriptionsResponse, 108 | status: 200, 109 | urlParams: { external_customer_id: "2" }, 110 | }); 111 | }, 112 | ); 113 | -------------------------------------------------------------------------------- /tests/utils.ts: -------------------------------------------------------------------------------- 1 | // deno-lint-ignore-file no-explicit-any ban-types 2 | import { assertEquals } from "../dev_deps.ts"; 3 | import { mf } from "../dev_deps.ts"; 4 | import { Client, getLagoError } from "../mod.ts"; 5 | import type { 6 | Api, 7 | ApiErrorNotFound, 8 | ApiErrorUnauthorized, 9 | ApiErrorUnprocessableEntity, 10 | HttpResponse, 11 | } from "../mod.ts"; 12 | 13 | type ExtractLagoDataOrError = E extends ( 14 | ...args: any 15 | ) => Promise> ? T | P 16 | : never; 17 | 18 | type ExtractLagoInput = I extends ( 19 | ...args: infer P 20 | ) => Promise> ? P 21 | : never; 22 | 23 | type ExtractLagoResponse = E extends ( 24 | ...args: any 25 | ) => Promise ? T 26 | : never; 27 | 28 | const errorMessage = "Lago Error" as const; 29 | 30 | export function setupMockClient(route: string, handler: mf.MatchHandler) { 31 | const { fetch, mock } = mf.sandbox(); 32 | 33 | mock(route, handler); 34 | 35 | return Client("api_key", { customFetch: fetch }); 36 | } 37 | 38 | export async function lagoTest< 39 | T extends keyof Api, 40 | U extends keyof Api[T], 41 | >( 42 | { 43 | t, 44 | route, 45 | clientPath, 46 | inputParams, 47 | responseObject, 48 | status, 49 | testType, 50 | urlParams, 51 | }: { 52 | testType: "error" | "200"; 53 | t: Deno.TestContext; 54 | route: `${"POST" | "GET" | "PUT" | "DELETE"}@/api/v1/${string}`; 55 | clientPath: [T, U]; 56 | inputParams: ExtractLagoInput[T][U]>; 57 | responseObject?: ExtractLagoDataOrError< 58 | Api[T][U] 59 | >; 60 | status: number; 61 | urlParams?: Record; 62 | }, 63 | ) { 64 | const client = setupMockClient( 65 | route, 66 | (_req) => { 67 | if (urlParams) { 68 | const urlSearchParams = new URLSearchParams(new URL(_req.url).search); 69 | Object.entries(urlParams).forEach(([key, value]) => { 70 | assertEquals(urlSearchParams.get(key), value); 71 | }); 72 | } 73 | return new Response( 74 | responseObject ? JSON.stringify(responseObject) : null, 75 | { status }, 76 | ); 77 | }, 78 | ); 79 | 80 | switch (testType) { 81 | case "error": 82 | await t.step("raises an exception", async () => { 83 | try { 84 | await (client[clientPath[0]][clientPath[1]] as (Function))( 85 | ...inputParams, 86 | ) as ExtractLagoResponse[T][U]>; 87 | // Error if there is no Error 88 | assertEquals(0, 1); 89 | } catch (error) { 90 | const lagoError = await getLagoError< 91 | typeof client[typeof clientPath[0]][typeof clientPath[1]] 92 | >( 93 | error, 94 | ); 95 | assertEquals( 96 | (lagoError as ApiErrorUnprocessableEntity).error, 97 | errorMessage, 98 | ); 99 | } 100 | }); 101 | break; 102 | 103 | case "200": 104 | await t.step("returns 200 response", async () => { 105 | const response = 106 | await (client[clientPath[0]][clientPath[1]] as Function)( 107 | ...inputParams, 108 | ) as Response; 109 | 110 | assertEquals(response.status, 200); 111 | }); 112 | break; 113 | 114 | default: 115 | throw new Error("Test type not found!"); 116 | } 117 | } 118 | 119 | export const unprocessableErrorResponse = { 120 | status: 422, 121 | error: errorMessage, 122 | code: "validation_errors", 123 | error_details: {}, 124 | } as const satisfies ApiErrorUnprocessableEntity; 125 | 126 | export const notFoundErrorResponse = { 127 | status: 404, 128 | error: errorMessage, 129 | code: "object_not_found", 130 | } as const satisfies ApiErrorNotFound; 131 | 132 | export const unauthorizedErrorResponse = { 133 | status: 401, 134 | error: errorMessage, 135 | } as const satisfies ApiErrorUnauthorized; 136 | -------------------------------------------------------------------------------- /tests/billable_metric.test.ts: -------------------------------------------------------------------------------- 1 | import type { BillableMetric, BillableMetricInput } from "../mod.ts"; 2 | import { lagoTest, unprocessableErrorResponse } from "./utils.ts"; 3 | 4 | const billableMetric = { 5 | billable_metric: { 6 | name: "name1", 7 | code: "code1", 8 | aggregation_type: "sum_agg", 9 | field_name: "field_name", 10 | group: { 11 | key: "country", 12 | values: ["france", "italy", "spain"], 13 | }, 14 | }, 15 | } satisfies BillableMetricInput; 16 | 17 | const response = { 18 | billable_metric: { 19 | lago_id: "b7ab2926-1de8-4428-9bcd-779314ac129b", 20 | name: "name1", 21 | code: "bm-code", 22 | description: undefined, 23 | aggregation_type: "sum_agg", 24 | field_name: "field_name", 25 | created_at: "2022-04-29T08:59:51Z", 26 | group: { 27 | key: "country", 28 | values: ["france", "italy", "spain"], 29 | }, 30 | }, 31 | } satisfies BillableMetric; 32 | 33 | Deno.test("Successfully sent billable metric responds with 2xx", async (t) => { 34 | await lagoTest({ 35 | t, 36 | testType: "200", 37 | route: "POST@/api/v1/billable_metrics", 38 | clientPath: ["billableMetrics", "createBillableMetric"], 39 | inputParams: [billableMetric], 40 | responseObject: response, 41 | status: 200, 42 | }); 43 | }); 44 | 45 | Deno.test("Status code is not 2xx", async (t) => { 46 | await lagoTest({ 47 | t, 48 | testType: "error", 49 | route: "POST@/api/v1/billable_metrics", 50 | clientPath: ["billableMetrics", "createBillableMetric"], 51 | inputParams: [billableMetric], 52 | responseObject: unprocessableErrorResponse, 53 | status: 422, 54 | }); 55 | }); 56 | 57 | Deno.test( 58 | "Successfully sent billable metric update request responds with 2xx", 59 | async (t) => { 60 | await lagoTest({ 61 | t, 62 | testType: "200", 63 | route: "PUT@/api/v1/billable_metrics/code1", 64 | clientPath: ["billableMetrics", "updateBillableMetric"], 65 | inputParams: [ 66 | "code1", 67 | { 68 | billable_metric: { name: "new name", field_name: "new_field_name" }, 69 | } satisfies BillableMetricInput, 70 | ], 71 | responseObject: response, 72 | status: 200, 73 | }); 74 | }, 75 | ); 76 | 77 | Deno.test( 78 | "Successfully sent billable metric find request responds with 2xx", 79 | async (t) => { 80 | await lagoTest({ 81 | t, 82 | testType: "200", 83 | route: "GET@/api/v1/billable_metrics/code1", 84 | clientPath: ["billableMetrics", "findBillableMetric"], 85 | inputParams: ["code1"], 86 | responseObject: response, 87 | status: 200, 88 | }); 89 | }, 90 | ); 91 | 92 | Deno.test( 93 | "Successfully sent billable metric destroy request responds with 2xx", 94 | async (t) => { 95 | await lagoTest({ 96 | t, 97 | testType: "200", 98 | route: "DELETE@/api/v1/billable_metrics/code1", 99 | clientPath: ["billableMetrics", "destroyBillableMetric"], 100 | inputParams: ["code1"], 101 | responseObject: response, 102 | status: 200, 103 | }); 104 | }, 105 | ); 106 | 107 | Deno.test( 108 | "Successfully sent billable metric find all request responds with 2xx", 109 | async (t) => { 110 | await lagoTest({ 111 | t, 112 | testType: "200", 113 | route: "GET@/api/v1/billable_metrics", 114 | clientPath: ["billableMetrics", "findAllBillableMetrics"], 115 | inputParams: [], 116 | responseObject: { billable_metrics: [response.billable_metric] }, 117 | status: 200, 118 | }); 119 | }, 120 | ); 121 | 122 | Deno.test( 123 | "Successfully sent billable metric find all request with options responds with 2xx", 124 | async (t) => { 125 | await lagoTest({ 126 | t, 127 | testType: "200", 128 | route: "GET@/api/v1/billable_metrics", 129 | clientPath: ["billableMetrics", "findAllBillableMetrics"], 130 | inputParams: [{ 131 | per_page: 2, 132 | page: 3, 133 | }], 134 | responseObject: { billable_metrics: [response.billable_metric] }, 135 | status: 200, 136 | urlParams: { page: "3", per_page: "2" }, 137 | }); 138 | }, 139 | ); 140 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lago JavaScript Client 2 | 3 | This is a JavaScript wrapper for Lago API. Works in Cloudflare Workers, Deno, and Node.js. Generated from [the Lago OpenAPI document](https://swagger.getlago.com/#/). 4 | 5 | [![PyPI version](https://badge.fury.io/js/lago-javascript-client.svg)](https://badge.fury.io/js/lago-javascript-client) 6 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html) 7 | 8 | ## Current Releases 9 | 10 | | Project | Release Badge | 11 | |--------------------|-----------------------------------------------------------------------------------------------------| 12 | | **Lago** | [![Lago Release](https://img.shields.io/github/v/release/getlago/lago)](https://github.com/getlago/lago/releases) | 13 | | **Lago JavaScript Client** | [![Lago JavaScript Client Release](https://img.shields.io/github/v/release/getlago/lago-javascript-client)](https://github.com/getlago/lago-javascript-client/releases) | 14 | 15 | ## Installation 16 | 17 | For npm users: 18 | 19 | ```bash 20 | npm install lago-javascript-client 21 | ``` 22 | 23 | ```typescript 24 | // npm 25 | import { Client, getLagoError } from 'lago-javascript-client'; 26 | 27 | // Deno 28 | import { Client, getLagoError } from 'https://deno.land/x/lago/mod.ts'; 29 | 30 | const lagoClient = Client('__YOUR_API_KEY__'); 31 | 32 | try { 33 | const { data } = await lagoClient.billableMetrics.createBillableMetric(billableMetric); 34 | } catch (error) { 35 | const lagoError = await getLagoError(error); 36 | } 37 | ``` 38 | 39 | ## Compatibility 40 | 41 | This SDK uses the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) and natively supported Node.js version >= 18. For other Node versions: 42 | 43 | 1. Ideally, run Node with the [`--experimental-fetch` flag](https://nodejs.org/docs/latest-v16.x/api/cli.html#--experimental-fetch) 44 | 45 | 1. Otherwise, polyfill the Fetch API by doing both: 46 | 47 | 1. [Patching globalThis](https://github.com/node-fetch/node-fetch#providing-global-access) 48 | 49 | 1. [Pass a Fetch instance](https://github.com/node-fetch/node-fetch#loading-and-configuring-the-module) to the Lago client 50 | 51 | ```typescript 52 | import { Client } from 'lago-javascript-client'; 53 | import fetch from 'node-fetch'; 54 | 55 | const lagoClient = Client("api_key", { customFetch: fetch }); 56 | ``` 57 | 58 | ## Usage 59 | 60 | Check the [Lago API reference](https://doc.getlago.com/docs/api/intro) 61 | 62 | ### Error handling 63 | 64 | Use the get `getLagoError<>()` utility function to extract the error object and TypeScript type: 65 | 66 | ```typescript 67 | try { 68 | const { data } = await lagoClient.billableMetrics.createBillableMetric(billableMetric); 69 | } catch (error) { 70 | const lagoError = await getLagoError(error); 71 | } 72 | ``` 73 | 74 | ## Development 75 | 76 | Uses [dnt](https://github.com/denoland/dnt) to build and test for Deno and Node. 77 | 78 | ### Release new version 79 | 80 | Change the affected fields in `scripts/build_npm.ts` and commit to GitHub. GitHub Actions will build and deploy to npm. 81 | 82 | ### Dependencies 83 | 84 | Requires [Deno](https://deno.land/) and [Node.js >= 18](https://nodejs.org/en/) 85 | 86 | ### Generate client from OpenAPI 87 | 88 | ```bash 89 | deno task generate:openapi 90 | ``` 91 | 92 | ### Run tests 93 | 94 | ```bash 95 | deno task test 96 | ``` 97 | 98 | ### Build 99 | 100 | ```bash 101 | deno task build 102 | ``` 103 | 104 | ### Publish to npm 105 | 106 | ```bash 107 | deno task build 108 | cd npm 109 | npm publish 110 | ``` 111 | 112 | ## Documentation 113 | 114 | The Lago documentation is available at [doc.getlago.com](https://doc.getlago.com/docs/api/intro). 115 | 116 | ## Contributing 117 | 118 | The contribution documentation is available [here](https://github.com/getlago/lago-javascript-client/blob/main/CONTRIBUTING.md) 119 | 120 | ## License 121 | 122 | Lago JavaScript client is distributed under [MIT license](LICENSE). 123 | -------------------------------------------------------------------------------- /tests/wallet.test.ts: -------------------------------------------------------------------------------- 1 | import type { 2 | Wallet, 3 | WalletInput, 4 | Wallets, 5 | WalletUpdateInput, 6 | } from "../mod.ts"; 7 | import { lagoTest, unprocessableErrorResponse } from "./utils.ts"; 8 | 9 | const walletInput = { 10 | "wallet": { 11 | "name": "Wallet name", 12 | "rate_amount": 2, 13 | "currency": "EUR", 14 | "paid_credits": 500, 15 | "granted_credits": 10, 16 | "external_customer_id": "12345", 17 | "expiration_at": "2022-09-14T23:59:59Z", 18 | }, 19 | } as const satisfies WalletInput; 20 | 21 | const walletResponse = { 22 | "wallet": { 23 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 24 | "lago_customer_id": "254da83c-c007-4fbb-afcd-b00c07c41oit", 25 | "external_customer_id": "12345", 26 | "status": "active", 27 | "currency": "EUR", 28 | "name": "Name", 29 | "rate_amount": 2, 30 | "credits_balance": 500, 31 | "balance": 1000, 32 | "consumed_credits": 100, 33 | "created_at": "2022-09-14T16:35:31Z", 34 | "expiration_at": "2022-09-14T23:59:59Z", 35 | "last_balance_sync_at": "2022-09-14T16:35:31Z", 36 | "last_consumed_credit_at": "2022-09-14T16:35:31Z", 37 | "terminated_at": "2022-09-14T16:35:31Z", 38 | }, 39 | } as const satisfies Wallet; 40 | 41 | const walletUpdateInput = { 42 | "wallet": { 43 | "name": "Wallet name", 44 | "expiration_at": "2022-09-14T23:59:59Z", 45 | }, 46 | } as const satisfies WalletUpdateInput; 47 | 48 | const walletsResponse = { 49 | wallets: [walletInput.wallet], 50 | } satisfies Wallets; 51 | 52 | Deno.test("Successfully sent wallet responds with 2xx", async (t) => { 53 | await lagoTest({ 54 | t, 55 | testType: "200", 56 | route: "POST@/api/v1/wallets", 57 | clientPath: ["wallets", "createWallet"], 58 | inputParams: [walletInput], 59 | responseObject: walletResponse, 60 | status: 200, 61 | }); 62 | }); 63 | 64 | Deno.test("Status code is not 2xx", async (t) => { 65 | await lagoTest({ 66 | t, 67 | testType: "error", 68 | route: "POST@/api/v1/wallets", 69 | clientPath: ["wallets", "createWallet"], 70 | inputParams: [walletInput], 71 | responseObject: unprocessableErrorResponse, 72 | status: 422, 73 | }); 74 | }); 75 | 76 | Deno.test("Successfully sent wallet update request responds with 2xx", async (t) => { 77 | await lagoTest({ 78 | t, 79 | testType: "200", 80 | route: "PUT@/api/v1/wallets/id", 81 | clientPath: ["wallets", "updateWallet"], 82 | inputParams: ["id", walletUpdateInput], 83 | responseObject: walletResponse, 84 | status: 200, 85 | }); 86 | }); 87 | 88 | Deno.test("Successfully sent wallet find request responds with 2xx", async (t) => { 89 | await lagoTest({ 90 | t, 91 | testType: "200", 92 | route: "GET@/api/v1/wallets/id", 93 | clientPath: ["wallets", "findWallet"], 94 | inputParams: ["id"], 95 | responseObject: walletResponse, 96 | status: 200, 97 | }); 98 | }); 99 | 100 | Deno.test("Successfully sent wallet destroy request responds with 2xx", async (t) => { 101 | await lagoTest({ 102 | t, 103 | testType: "200", 104 | route: "DELETE@/api/v1/wallets/id", 105 | clientPath: ["wallets", "destroyWallet"], 106 | inputParams: ["id"], 107 | responseObject: walletResponse, 108 | status: 200, 109 | }); 110 | }); 111 | 112 | Deno.test("Successfully sent wallet find all request responds with 2xx", async (t) => { 113 | await lagoTest({ 114 | t, 115 | testType: "200", 116 | route: "GET@/api/v1/wallets", 117 | clientPath: ["wallets", "findAllWallets"], 118 | inputParams: [{ external_customer_id: "external-123" }], 119 | responseObject: walletsResponse, 120 | status: 200, 121 | urlParams: { external_customer_id: "external-123" }, 122 | }); 123 | }); 124 | 125 | Deno.test( 126 | "Successfully sent wallet find all request with options responds with 2xx", 127 | async (t) => { 128 | await lagoTest({ 129 | t, 130 | testType: "200", 131 | route: "GET@/api/v1/wallets", 132 | clientPath: ["wallets", "findAllWallets"], 133 | inputParams: [{ 134 | external_customer_id: "external-123", 135 | per_page: 2, 136 | page: 3, 137 | }], 138 | responseObject: walletsResponse, 139 | status: 200, 140 | urlParams: { 141 | external_customer_id: "external-123", 142 | per_page: "2", 143 | page: "3", 144 | }, 145 | }); 146 | }, 147 | ); 148 | -------------------------------------------------------------------------------- /tests/plan.test.ts: -------------------------------------------------------------------------------- 1 | import type { Plan, PlanInput, Plans } from "../mod.ts"; 2 | import { lagoTest, unprocessableErrorResponse } from "./utils.ts"; 3 | 4 | const planInput = { 5 | "plan": { 6 | "name": "example name", 7 | "code": "example_code", 8 | "interval": "weekly", 9 | "description": "description", 10 | "amount_cents": 1200, 11 | "amount_currency": "EUR", 12 | "trial_period": 2, 13 | "pay_in_advance": true, 14 | "bill_charges_monthly": false, 15 | "charges": [ 16 | { 17 | "id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 18 | "billable_metric_id": "278da83c-c007-4fbb-afcd-b00c07c41utg", 19 | "charge_model": "standard", 20 | "properties": {}, 21 | "group_properties": [ 22 | { 23 | "group_id": "123456", 24 | "values": {}, 25 | }, 26 | ], 27 | }, 28 | ], 29 | }, 30 | } satisfies PlanInput; 31 | 32 | const planResponse = { 33 | "plan": { 34 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 35 | "name": "example name", 36 | "created_at": "2022-09-14T16:35:31Z", 37 | "code": "example_code", 38 | "interval": "weekly", 39 | "description": "description", 40 | "amount_cents": 1200, 41 | "amount_currency": "EUR", 42 | "trial_period": 2, 43 | "pay_in_advance": true, 44 | "bill_charges_monthly": false, 45 | "charges": [ 46 | { 47 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 48 | "lago_billable_metric_id": "278da83c-c007-4fbb-afcd-b00c07c41utg", 49 | "created_at": "2022-09-14T16:35:31Z", 50 | "charge_model": "standard", 51 | "properties": {}, 52 | "group_properties": [ 53 | { 54 | "group_id": "123456", 55 | "values": {}, 56 | }, 57 | ], 58 | }, 59 | ], 60 | }, 61 | } satisfies Plan; 62 | 63 | const plansResponse = { plans: [planResponse.plan] } satisfies Plans; 64 | 65 | Deno.test("Successfully sent plan responds with 2xx", async (t) => { 66 | await lagoTest({ 67 | t, 68 | testType: "200", 69 | route: "POST@/api/v1/plans", 70 | clientPath: ["plans", "createPlan"], 71 | inputParams: [planInput], 72 | responseObject: planResponse, 73 | status: 200, 74 | }); 75 | }); 76 | 77 | Deno.test("Status code is not 2xx", async (t) => { 78 | await lagoTest({ 79 | t, 80 | testType: "error", 81 | route: "POST@/api/v1/plans", 82 | clientPath: ["plans", "createPlan"], 83 | inputParams: [planInput], 84 | responseObject: unprocessableErrorResponse, 85 | status: 422, 86 | }); 87 | }); 88 | 89 | Deno.test("Successfully sent plan update request responds with 2xx", async (t) => { 90 | await lagoTest({ 91 | t, 92 | testType: "200", 93 | route: "PUT@/api/v1/plans/code1", 94 | clientPath: ["plans", "updatePlan"], 95 | inputParams: ["code1", planInput], 96 | responseObject: planResponse, 97 | status: 200, 98 | }); 99 | }); 100 | 101 | Deno.test("Successfully sent plan find request responds with 2xx", async (t) => { 102 | await lagoTest({ 103 | t, 104 | testType: "200", 105 | route: "GET@/api/v1/plans/code1", 106 | clientPath: ["plans", "findPlan"], 107 | inputParams: ["code1"], 108 | responseObject: planResponse, 109 | status: 200, 110 | }); 111 | }); 112 | 113 | Deno.test("Successfully sent plan destroy request responds with 2xx", async (t) => { 114 | await lagoTest({ 115 | t, 116 | testType: "200", 117 | route: "DELETE@/api/v1/plans/code1", 118 | clientPath: ["plans", "destroyPlan"], 119 | inputParams: ["code1"], 120 | responseObject: planResponse, 121 | status: 200, 122 | }); 123 | }); 124 | 125 | Deno.test("Successfully sent plan find all request responds with 2xx", async (t) => { 126 | await lagoTest({ 127 | t, 128 | testType: "200", 129 | route: "GET@/api/v1/plans", 130 | clientPath: ["plans", "findAllPlans"], 131 | inputParams: [], 132 | responseObject: plansResponse, 133 | status: 200, 134 | }); 135 | }); 136 | 137 | Deno.test( 138 | "Successfully sent plan find all request with options responds with 2xx", 139 | async (t) => { 140 | await lagoTest({ 141 | t, 142 | testType: "200", 143 | route: "GET@/api/v1/plans", 144 | clientPath: ["plans", "findAllPlans"], 145 | inputParams: [{ per_page: 2, page: 3 }], 146 | responseObject: plansResponse, 147 | status: 200, 148 | urlParams: { per_page: "2", page: "3" }, 149 | }); 150 | }, 151 | ); 152 | -------------------------------------------------------------------------------- /tests/customer.test.ts: -------------------------------------------------------------------------------- 1 | import type { Customer, CustomerInput, CustomerUsage } from "../mod.ts"; 2 | import { 3 | lagoTest, 4 | notFoundErrorResponse, 5 | unprocessableErrorResponse, 6 | } from "./utils.ts"; 7 | 8 | const customer = { 9 | "customer": { 10 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 11 | "external_id": "886da83c-c007-4fbb-afcd-b00c07c41ffe", 12 | "name": "John Doe", 13 | "sequential_id": 12345, 14 | "slug": "slug", 15 | "created_at": "2022-09-14T16:35:31Z", 16 | "country": "CZ", 17 | "address_line1": "address1", 18 | "address_line2": "address2", 19 | "state": "state1", 20 | "zipcode": "10000", 21 | "email": "example@example.com", 22 | "city": "City", 23 | "url": "https://example.com", 24 | "phone": "3551234567", 25 | "lago_url": "https://lago.url", 26 | "legal_name": "name1", 27 | "legal_number": "10000", 28 | "currency": "EUR", 29 | "timezone": "UTC", 30 | "applicable_timezone": "UTC", 31 | "billing_configuration": { 32 | "invoice_grace_period": 3, 33 | "vat_rate": 25, 34 | "payment_provider": "stripe", 35 | "provider_customer_id": "123456", 36 | "sync_with_provider": true, 37 | "additionalProp1": {}, 38 | }, 39 | }, 40 | } as const satisfies Customer; 41 | 42 | const customerInput = { 43 | "customer": { 44 | "external_id": "886da83c-c007-4fbb-afcd-b00c07c41ffe", 45 | "name": "John Doe", 46 | "country": "CZ", 47 | "address_line1": "address1", 48 | "address_line2": "address2", 49 | "state": "state1", 50 | "zipcode": "10000", 51 | "email": "example@example.com", 52 | "city": "City", 53 | "url": "https://example.com", 54 | "phone": "3551234567", 55 | "lago_url": "https://lago.url", 56 | "legal_name": "name1", 57 | "legal_number": "10000", 58 | "currency": "EUR", 59 | "timezone": "Europe/Paris", 60 | "billing_configuration": { 61 | "invoice_grace_period": 3, 62 | "vat_rate": 25, 63 | "payment_provider": "stripe", 64 | "provider_customer_id": "123456", 65 | "sync_with_provider": true, 66 | "additionalProp1": {}, 67 | }, 68 | }, 69 | } as const satisfies CustomerInput; 70 | 71 | const customerUsage = { 72 | "customer_usage": { 73 | "from_datetime": "2022-09-14T00:00:00Z", 74 | "to_datetime": "2022-09-14T00:00:00Z", 75 | "issuing_date": "2022-09-15T00:00:00Z", 76 | "amount_cents": 1200, 77 | "amount_currency": "EUR", 78 | "total_amount_cents": 1400, 79 | "total_amount_currency": "EUR", 80 | "vat_amount_cents": 200, 81 | "vat_amount_currency": "EUR", 82 | "charges_usage": [ 83 | { 84 | "units": 3, 85 | "amount_cents": 1200, 86 | "amount_currency": "EUR", 87 | "charge": { 88 | "lago_id": "278da83c-c007-4fbb-afcd-b00c07c41utg", 89 | "charge_model": "standard", 90 | }, 91 | "billable_metric": { 92 | "lago_id": "278da83c-c007-4fbb-afcd-b00c07c41utg", 93 | "name": "Example name", 94 | "code": "code", 95 | "aggregation_type": "count_agg", 96 | }, 97 | "groups": [ 98 | { 99 | "lago_id": "278da83c-c007-4fbb-afcd-b00c07c41utg", 100 | "key": "key", 101 | "value": "value", 102 | "units": 3.5, 103 | "amount_cents": 1200, 104 | }, 105 | ], 106 | }, 107 | ], 108 | }, 109 | } satisfies CustomerUsage; 110 | 111 | Deno.test("Successfully sent customer responds with 2xx", async (t) => { 112 | await lagoTest({ 113 | t, 114 | testType: "200", 115 | route: "POST@/api/v1/customers", 116 | clientPath: ["customers", "createCustomer"], 117 | inputParams: [customerInput], 118 | responseObject: customer, 119 | status: 200, 120 | }); 121 | }); 122 | 123 | Deno.test("Status code is not 2xx", async (t) => { 124 | await lagoTest({ 125 | t, 126 | testType: "error", 127 | route: "POST@/api/v1/customers", 128 | clientPath: ["customers", "createCustomer"], 129 | inputParams: [customerInput], 130 | responseObject: unprocessableErrorResponse, 131 | status: 422, 132 | }); 133 | }); 134 | 135 | Deno.test("Current usage responds with a 2xx", async (t) => { 136 | await lagoTest({ 137 | t, 138 | testType: "200", 139 | route: "GET@/api/v1/customers/external_customer_id/current_usage", 140 | clientPath: ["customers", "findCustomerCurrentUsage"], 141 | inputParams: ["external_customer_id", { external_subscription_id: "123" }], 142 | responseObject: customerUsage, 143 | status: 200, 144 | urlParams: { external_subscription_id: "123" }, 145 | }); 146 | }); 147 | 148 | Deno.test("Current usage responds with other than 2xx", async (t) => { 149 | await lagoTest({ 150 | t, 151 | testType: "error", 152 | route: "GET@/api/v1/customers/external_customer_id/current_usage", 153 | clientPath: ["customers", "findCustomerCurrentUsage"], 154 | inputParams: ["external_customer_id", { external_subscription_id: "123" }], 155 | responseObject: notFoundErrorResponse, 156 | status: 404, 157 | urlParams: { external_subscription_id: "123" }, 158 | }); 159 | }); 160 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | - Demonstrating empathy and kindness toward other people 21 | - Being respectful of differing opinions, viewpoints, and experiences 22 | - Giving and gracefully accepting constructive feedback 23 | - Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | - Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | - The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | - Trolling, insulting or derogatory comments, and personal or political attacks 33 | - Public or private harassment 34 | - Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | - Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | dev@getlago.com. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /tests/credit_note.test.ts: -------------------------------------------------------------------------------- 1 | import type { 2 | CreditNote, 3 | CreditNoteInput, 4 | CreditNoteUpdateInput, 5 | } from "../mod.ts"; 6 | import { lagoTest, unprocessableErrorResponse } from "./utils.ts"; 7 | 8 | const creditNote = { 9 | credit_note: { 10 | reason: "other", 11 | invoice_id: "invoice-id", 12 | credit_amount_cents: 10, 13 | items: [ 14 | { 15 | fee_id: "fee-id", 16 | amount_cents: 5, 17 | }, 18 | ], 19 | }, 20 | } satisfies CreditNoteInput; 21 | 22 | const creditNoteUpdate = { 23 | credit_note: { 24 | refund_status: "succeeded", 25 | }, 26 | } satisfies CreditNoteUpdateInput; 27 | 28 | const response = { 29 | "credit_note": { 30 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 31 | "sequential_id": 1234, 32 | "number": "123456789", 33 | "lago_invoice_id": "144da83c-c007-4fbb-afcd-b00c07c41ffe", 34 | "invoice_number": "123456789", 35 | "issuing_date": "2022-09-14T16:35:31Z", 36 | "credit_status": "available", 37 | "refund_status": "pending", 38 | "reason": "duplicated_charge", 39 | "description": "description", 40 | "total_amount_cents": 1220, 41 | "total_amount_currency": "EUR", 42 | "vat_amount_cents": 20, 43 | "vat_amount_currency": "EUR", 44 | "sub_total_vat_excluded_amount_cents": 1000, 45 | "sub_total_vat_excluded_amount_currency": "EUR", 46 | "balance_amount_cents": 20, 47 | "balance_amount_currency": "EUR", 48 | "credit_amount_cents": 20, 49 | "credit_amount_currency": "EUR", 50 | "refund_amount_cents": 20, 51 | "refund_amount_currency": "EUR", 52 | "created_at": "2022-09-14T16:35:31Z", 53 | "updated_at": "2022-09-14T16:35:31Z", 54 | "file_url": "https://example.com", 55 | "customer": { 56 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 57 | "external_id": "886da83c-c007-4fbb-afcd-b00c07c41ffe", 58 | "name": "John Doe", 59 | "sequential_id": 12345, 60 | "slug": "slug", 61 | "created_at": "2022-09-14T16:35:31Z", 62 | "country": "CZ", 63 | "address_line1": "address1", 64 | "address_line2": "address2", 65 | "state": "state1", 66 | "zipcode": "10000", 67 | "email": "example@example.com", 68 | "city": "City", 69 | "url": "https://example.com", 70 | "phone": "3551234567", 71 | "lago_url": "https://lago.url", 72 | "legal_name": "name1", 73 | "legal_number": "10000", 74 | "currency": "EUR", 75 | "timezone": "UTC", 76 | "applicable_timezone": "UTC", 77 | "billing_configuration": { 78 | "invoice_grace_period": 3, 79 | "vat_rate": 25, 80 | "payment_provider": "stripe", 81 | "provider_customer_id": "123456", 82 | "sync_with_provider": true, 83 | "additionalProp1": {}, 84 | }, 85 | }, 86 | "items": [ 87 | { 88 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 89 | "amount_cents": 1220, 90 | "amount_currency": "EUR", 91 | "fee": { 92 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 93 | "lago_group_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 94 | "amount_cents": 1200, 95 | "amount_currency": "EUR", 96 | "vat_amount_cents": 1200, 97 | "vat_amount_currency": "EUR", 98 | "units": 2.5, 99 | "events_count": 5, 100 | "item": { 101 | "type": "charge", 102 | "code": "code", 103 | "name": "name", 104 | }, 105 | }, 106 | }, 107 | ], 108 | }, 109 | } satisfies CreditNote; 110 | 111 | Deno.test("Successfully create a credit note", async (t) => { 112 | await lagoTest({ 113 | t, 114 | testType: "200", 115 | route: "POST@/api/v1/credit_notes", 116 | clientPath: ["creditNotes", "createCreditNote"], 117 | inputParams: [creditNote], 118 | responseObject: response, 119 | status: 200, 120 | }); 121 | }); 122 | 123 | Deno.test("Failled create of credit note", async (t) => { 124 | await lagoTest({ 125 | t, 126 | testType: "error", 127 | route: "POST@/api/v1/credit_notes", 128 | clientPath: ["creditNotes", "createCreditNote"], 129 | inputParams: [creditNote], 130 | responseObject: unprocessableErrorResponse, 131 | status: 422, 132 | }); 133 | }); 134 | 135 | Deno.test("Successfully sent credit note update request", async (t) => { 136 | await lagoTest({ 137 | t, 138 | testType: "200", 139 | route: "PUT@/api/v1/credit_notes/credit-note-id", 140 | clientPath: ["creditNotes", "updateCreditNote"], 141 | inputParams: ["credit-note-id", creditNoteUpdate], 142 | responseObject: response, 143 | status: 200, 144 | }); 145 | }); 146 | 147 | Deno.test("Failed update of credit note", async (t) => { 148 | await lagoTest({ 149 | t, 150 | testType: "error", 151 | route: "PUT@/api/v1/credit_notes/credit-note-id", 152 | clientPath: ["creditNotes", "updateCreditNote"], 153 | inputParams: ["credit-note-id", creditNoteUpdate], 154 | responseObject: unprocessableErrorResponse, 155 | status: 422, 156 | }); 157 | }); 158 | 159 | Deno.test("Successfully find credit note request", async (t) => { 160 | await lagoTest({ 161 | t, 162 | testType: "200", 163 | route: "GET@/api/v1/credit_notes/id", 164 | clientPath: ["creditNotes", "findCreditNote"], 165 | inputParams: ["id"], 166 | responseObject: creditNote, 167 | status: 200, 168 | }); 169 | }); 170 | 171 | Deno.test("Successfully sent find all credit notes request", async (t) => { 172 | await lagoTest({ 173 | t, 174 | testType: "200", 175 | route: "GET@/api/v1/credit_notes", 176 | clientPath: ["creditNotes", "findAllCreditNotes"], 177 | inputParams: [], 178 | responseObject: { credit_notes: [creditNote.credit_note] }, 179 | status: 200, 180 | }); 181 | }); 182 | 183 | Deno.test("Successfully request invoice download", async (t) => { 184 | await lagoTest({ 185 | t, 186 | testType: "200", 187 | route: "POST@/api/v1/credit_notes/lago_id/download", 188 | clientPath: ["creditNotes", "downloadCreditNote"], 189 | inputParams: ["lago_id"], 190 | responseObject: creditNote, 191 | status: 200, 192 | }); 193 | }); 194 | 195 | Deno.test( 196 | "Successfully sent find all credit notes request with options", 197 | async (t) => { 198 | await lagoTest({ 199 | t, 200 | testType: "200", 201 | route: "GET@/api/v1/credit_notes", 202 | clientPath: ["creditNotes", "findAllCreditNotes"], 203 | inputParams: [{ 204 | per_page: 2, 205 | page: 3, 206 | }], 207 | responseObject: { credit_notes: [creditNote.credit_note] }, 208 | status: 200, 209 | urlParams: { page: "3", per_page: "2" }, 210 | }); 211 | }, 212 | ); 213 | -------------------------------------------------------------------------------- /tests/invoice.test.ts: -------------------------------------------------------------------------------- 1 | import type { Invoice, Invoices } from "../mod.ts"; 2 | import { lagoTest, unprocessableErrorResponse } from "./utils.ts"; 3 | 4 | const invoiceResponse = { 5 | "invoice": { 6 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 7 | "sequential_id": 12345, 8 | "number": "222345", 9 | "issuing_date": "2022-09-14T16:35:31Z", 10 | "invoice_type": "subscription", 11 | "status": "finalized", 12 | "payment_status": "pending", 13 | "amount_cents": 1200, 14 | "amount_currency": "EUR", 15 | "vat_amount_cents": 20, 16 | "vat_amount_currency": "EUR", 17 | "credit_amount_cents": 20, 18 | "credit_amount_currency": "EUR", 19 | "total_amount_cents": 1220, 20 | "total_amount_currency": "EUR", 21 | "legacy": true, 22 | "file_url": "https://example.com", 23 | "customer": { 24 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 25 | "external_id": "886da83c-c007-4fbb-afcd-b00c07c41ffe", 26 | "name": "John Doe", 27 | "sequential_id": 12345, 28 | "slug": "slug", 29 | "created_at": "2022-09-14T16:35:31Z", 30 | "country": "CZ", 31 | "address_line1": "address1", 32 | "address_line2": "address2", 33 | "state": "state1", 34 | "zipcode": "10000", 35 | "email": "example@example.com", 36 | "city": "City", 37 | "url": "https://example.com", 38 | "phone": "3551234567", 39 | "lago_url": "https://lago.url", 40 | "legal_name": "name1", 41 | "legal_number": "10000", 42 | "currency": "EUR", 43 | "timezone": "UTC", 44 | "applicable_timezone": "UTC", 45 | "billing_configuration": { 46 | "invoice_grace_period": 3, 47 | "vat_rate": 25, 48 | "payment_provider": "stripe", 49 | "provider_customer_id": "123456", 50 | "sync_with_provider": true, 51 | "additionalProp1": {}, 52 | }, 53 | }, 54 | "subscriptions": [ 55 | { 56 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 57 | "external_id": "12345", 58 | "lago_customer_id": "995da83c-c007-4fbb-afcd-b00c07c41tre", 59 | "external_customer_id": "54321", 60 | "name": "Test subscription", 61 | "plan_code": "plan_code", 62 | "status": "active", 63 | "billing_time": "calendar", 64 | "subscription_at": "2022-09-14T16:35:31Z", 65 | "started_at": "2022-09-14T16:35:31Z", 66 | "terminated_at": "2022-09-14T16:35:31Z", 67 | "canceled_at": "2022-09-14T16:35:31Z", 68 | "created_at": "2022-09-14T16:35:31Z", 69 | "previous_plan_code": "previous_code", 70 | "next_plan_code": "next_code", 71 | "downgrade_plan_date": "2022-09-14T16:35:31Z", 72 | }, 73 | ], 74 | "fees": [ 75 | { 76 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 77 | "lago_group_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 78 | "amount_cents": 1200, 79 | "amount_currency": "EUR", 80 | "vat_amount_cents": 1200, 81 | "vat_amount_currency": "EUR", 82 | "units": 2.5, 83 | "events_count": 5, 84 | "item": { 85 | "type": "charge", 86 | "code": "code", 87 | "name": "name", 88 | }, 89 | }, 90 | ], 91 | "credits": [ 92 | { 93 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 94 | "amount_cents": 1200, 95 | "amount_currency": "EUR", 96 | "item": { 97 | "lago_id": "183da83c-c007-4fbb-afcd-b00c07c41ffe", 98 | "type": "coupon", 99 | "code": "code", 100 | "name": "name", 101 | }, 102 | }, 103 | ], 104 | }, 105 | } satisfies Invoice; 106 | 107 | const invoicesResponse = { 108 | invoices: [invoiceResponse.invoice], 109 | } satisfies Invoices; 110 | 111 | Deno.test( 112 | "Successfully sent invoice update payment status responds with 2xx", 113 | async (t) => { 114 | await lagoTest({ 115 | t, 116 | testType: "200", 117 | route: "PUT@/api/v1/invoices/lago_id", 118 | clientPath: ["invoices", "updateInvoice"], 119 | inputParams: ["lago_id", { 120 | invoice: { 121 | payment_status: "succeeded", 122 | }, 123 | }], 124 | responseObject: invoiceResponse, 125 | status: 200, 126 | }); 127 | }, 128 | ); 129 | 130 | Deno.test("Status code is not 2xx", async (t) => { 131 | await lagoTest({ 132 | t, 133 | testType: "error", 134 | route: "PUT@/api/v1/invoices/lago_id", 135 | clientPath: ["invoices", "updateInvoice"], 136 | inputParams: ["lago_id", { 137 | invoice: { 138 | payment_status: "succeeded", 139 | }, 140 | }], 141 | responseObject: unprocessableErrorResponse, 142 | status: 422, 143 | }); 144 | }); 145 | 146 | Deno.test("Successfully request invoice download responds with 2xx", async (t) => { 147 | await lagoTest({ 148 | t, 149 | testType: "200", 150 | route: "POST@/api/v1/invoices/lago_id/download", 151 | clientPath: ["invoices", "downloadInvoice"], 152 | inputParams: ["lago_id"], 153 | responseObject: invoiceResponse, 154 | status: 200, 155 | }); 156 | }); 157 | 158 | Deno.test("Successfully sent invoice find request responds with 2xx", async (t) => { 159 | await lagoTest({ 160 | t, 161 | testType: "200", 162 | route: "GET@/api/v1/invoices/id", 163 | clientPath: ["invoices", "findInvoice"], 164 | inputParams: ["id"], 165 | responseObject: invoiceResponse, 166 | status: 200, 167 | }); 168 | }); 169 | 170 | Deno.test( 171 | "Successfully sent invoice find all request responds with 2xx", 172 | async (t) => { 173 | await lagoTest({ 174 | t, 175 | testType: "200", 176 | route: "GET@/api/v1/invoices", 177 | clientPath: ["invoices", "findAllInvoices"], 178 | inputParams: [], 179 | responseObject: invoicesResponse, 180 | status: 200, 181 | }); 182 | }, 183 | ); 184 | 185 | Deno.test( 186 | "Successfully sent invoice find all request with options responds with 2xx", 187 | async (t) => { 188 | await lagoTest({ 189 | t, 190 | testType: "200", 191 | route: "GET@/api/v1/invoices", 192 | clientPath: ["invoices", "findAllInvoices"], 193 | inputParams: [{ per_page: 2, page: 3 }], 194 | responseObject: invoicesResponse, 195 | status: 200, 196 | urlParams: { per_page: "2", page: "3" }, 197 | }); 198 | }, 199 | ); 200 | 201 | Deno.test( 202 | "Successfully request invoice refresh responds with 2xx", 203 | async (t) => { 204 | await lagoTest({ 205 | t, 206 | testType: "200", 207 | route: "PUT@/api/v1/invoices/lagoId/refresh", 208 | clientPath: ["invoices", "refreshInvoice"], 209 | inputParams: ["lagoId"], 210 | responseObject: invoiceResponse, 211 | status: 200, 212 | }); 213 | }, 214 | ); 215 | 216 | Deno.test( 217 | "Successfully request invoice finalize responds with 2xx", 218 | async (t) => { 219 | await lagoTest({ 220 | t, 221 | testType: "200", 222 | route: "PUT@/api/v1/invoices/lagoId/finalize", 223 | clientPath: ["invoices", "finalizeInvoice"], 224 | inputParams: ["lagoId"], 225 | responseObject: invoiceResponse, 226 | status: 200, 227 | }); 228 | }, 229 | ); 230 | -------------------------------------------------------------------------------- /deno.lock: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2", 3 | "remote": { 4 | "https://crux.land/api/get/2KNRVU.ts": "6a77d55844aba78d01520c5ff0b2f0af7f24cc1716a0de8b3bb6bd918c47b5ba", 5 | "https://deno.land/std@0.140.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74", 6 | "https://deno.land/std@0.140.0/_util/os.ts": "3b4c6e27febd119d36a416d7a97bd3b0251b77c88942c8f16ee5953ea13e2e49", 7 | "https://deno.land/std@0.140.0/bytes/bytes_list.ts": "67eb118e0b7891d2f389dad4add35856f4ad5faab46318ff99653456c23b025d", 8 | "https://deno.land/std@0.140.0/bytes/equals.ts": "fc16dff2090cced02497f16483de123dfa91e591029f985029193dfaa9d894c9", 9 | "https://deno.land/std@0.140.0/bytes/mod.ts": "763f97d33051cc3f28af1a688dfe2830841192a9fea0cbaa55f927b49d49d0bf", 10 | "https://deno.land/std@0.140.0/fmt/colors.ts": "30455035d6d728394781c10755351742dd731e3db6771b1843f9b9e490104d37", 11 | "https://deno.land/std@0.140.0/fs/_util.ts": "0fb24eb4bfebc2c194fb1afdb42b9c3dda12e368f43e8f2321f84fc77d42cb0f", 12 | "https://deno.land/std@0.140.0/fs/ensure_dir.ts": "9dc109c27df4098b9fc12d949612ae5c9c7169507660dcf9ad90631833209d9d", 13 | "https://deno.land/std@0.140.0/hash/sha256.ts": "803846c7a5a8a5a97f31defeb37d72f519086c880837129934f5d6f72102a8e8", 14 | "https://deno.land/std@0.140.0/io/buffer.ts": "bd0c4bf53db4b4be916ca5963e454bddfd3fcd45039041ea161dbf826817822b", 15 | "https://deno.land/std@0.140.0/path/_constants.ts": "df1db3ffa6dd6d1252cc9617e5d72165cd2483df90e93833e13580687b6083c3", 16 | "https://deno.land/std@0.140.0/path/_interface.ts": "ee3b431a336b80cf445441109d089b70d87d5e248f4f90ff906820889ecf8d09", 17 | "https://deno.land/std@0.140.0/path/_util.ts": "c1e9686d0164e29f7d880b2158971d805b6e0efc3110d0b3e24e4b8af2190d2b", 18 | "https://deno.land/std@0.140.0/path/common.ts": "bee563630abd2d97f99d83c96c2fa0cca7cee103e8cb4e7699ec4d5db7bd2633", 19 | "https://deno.land/std@0.140.0/path/glob.ts": "cb5255638de1048973c3e69e420c77dc04f75755524cb3b2e160fe9277d939ee", 20 | "https://deno.land/std@0.140.0/path/mod.ts": "d3e68d0abb393fb0bf94a6d07c46ec31dc755b544b13144dee931d8d5f06a52d", 21 | "https://deno.land/std@0.140.0/path/posix.ts": "293cdaec3ecccec0a9cc2b534302dfe308adb6f10861fa183275d6695faace44", 22 | "https://deno.land/std@0.140.0/path/separator.ts": "fe1816cb765a8068afb3e8f13ad272351c85cbc739af56dacfc7d93d710fe0f9", 23 | "https://deno.land/std@0.140.0/path/win32.ts": "31811536855e19ba37a999cd8d1b62078235548d67902ece4aa6b814596dd757", 24 | "https://deno.land/std@0.140.0/streams/conversion.ts": "712585bfa0172a97fb68dd46e784ae8ad59d11b88079d6a4ab098ff42e697d21", 25 | "https://deno.land/std@0.181.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462", 26 | "https://deno.land/std@0.181.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3", 27 | "https://deno.land/std@0.181.0/fs/_util.ts": "65381f341af1ff7f40198cee15c20f59951ac26e51ddc651c5293e24f9ce6f32", 28 | "https://deno.land/std@0.181.0/fs/ensure_dir.ts": "dc64c4c75c64721d4e3fb681f1382f803ff3d2868f08563ff923fdd20d071c40", 29 | "https://deno.land/std@0.181.0/fs/expand_glob.ts": "e4f56259a0a70fe23f05215b00de3ac5e6ba46646ab2a06ebbe9b010f81c972a", 30 | "https://deno.land/std@0.181.0/fs/walk.ts": "ea95ffa6500c1eda6b365be488c056edc7c883a1db41ef46ec3bf057b1c0fe32", 31 | "https://deno.land/std@0.181.0/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0", 32 | "https://deno.land/std@0.181.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b", 33 | "https://deno.land/std@0.181.0/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0", 34 | "https://deno.land/std@0.181.0/path/common.ts": "ee7505ab01fd22de3963b64e46cff31f40de34f9f8de1fff6a1bd2fe79380000", 35 | "https://deno.land/std@0.181.0/path/glob.ts": "d479e0a695621c94d3fd7fe7abd4f9499caf32a8de13f25073451c6ef420a4e1", 36 | "https://deno.land/std@0.181.0/path/mod.ts": "bf718f19a4fdd545aee1b06409ca0805bd1b68ecf876605ce632e932fe54510c", 37 | "https://deno.land/std@0.181.0/path/posix.ts": "8b7c67ac338714b30c816079303d0285dd24af6b284f7ad63da5b27372a2c94d", 38 | "https://deno.land/std@0.181.0/path/separator.ts": "0fb679739d0d1d7bf45b68dacfb4ec7563597a902edbaf3c59b50d5bcadd93b1", 39 | "https://deno.land/std@0.181.0/path/win32.ts": "d186344e5583bcbf8b18af416d13d82b35a317116e6460a5a3953508c3de5bba", 40 | "https://deno.land/std@0.182.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462", 41 | "https://deno.land/std@0.182.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3", 42 | "https://deno.land/std@0.182.0/fmt/colors.ts": "d67e3cd9f472535241a8e410d33423980bec45047e343577554d3356e1f0ef4e", 43 | "https://deno.land/std@0.182.0/fs/_util.ts": "65381f341af1ff7f40198cee15c20f59951ac26e51ddc651c5293e24f9ce6f32", 44 | "https://deno.land/std@0.182.0/fs/empty_dir.ts": "c3d2da4c7352fab1cf144a1ecfef58090769e8af633678e0f3fabaef98594688", 45 | "https://deno.land/std@0.182.0/fs/expand_glob.ts": "e4f56259a0a70fe23f05215b00de3ac5e6ba46646ab2a06ebbe9b010f81c972a", 46 | "https://deno.land/std@0.182.0/fs/walk.ts": "920be35a7376db6c0b5b1caf1486fb962925e38c9825f90367f8f26b5e5d0897", 47 | "https://deno.land/std@0.182.0/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0", 48 | "https://deno.land/std@0.182.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b", 49 | "https://deno.land/std@0.182.0/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0", 50 | "https://deno.land/std@0.182.0/path/common.ts": "ee7505ab01fd22de3963b64e46cff31f40de34f9f8de1fff6a1bd2fe79380000", 51 | "https://deno.land/std@0.182.0/path/glob.ts": "d479e0a695621c94d3fd7fe7abd4f9499caf32a8de13f25073451c6ef420a4e1", 52 | "https://deno.land/std@0.182.0/path/mod.ts": "bf718f19a4fdd545aee1b06409ca0805bd1b68ecf876605ce632e932fe54510c", 53 | "https://deno.land/std@0.182.0/path/posix.ts": "8b7c67ac338714b30c816079303d0285dd24af6b284f7ad63da5b27372a2c94d", 54 | "https://deno.land/std@0.182.0/path/separator.ts": "0fb679739d0d1d7bf45b68dacfb4ec7563597a902edbaf3c59b50d5bcadd93b1", 55 | "https://deno.land/std@0.182.0/path/win32.ts": "d186344e5583bcbf8b18af416d13d82b35a317116e6460a5a3953508c3de5bba", 56 | "https://deno.land/std@0.196.0/_util/diff.ts": "1a3c044aedf77647d6cac86b798c6417603361b66b54c53331b312caeb447aea", 57 | "https://deno.land/std@0.196.0/assert/_constants.ts": "8a9da298c26750b28b326b297316cdde860bc237533b07e1337c021379e6b2a9", 58 | "https://deno.land/std@0.196.0/assert/_format.ts": "a69126e8a469009adf4cf2a50af889aca364c349797e63174884a52ff75cf4c7", 59 | "https://deno.land/std@0.196.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", 60 | "https://deno.land/std@0.196.0/assert/assert_almost_equals.ts": "e15ca1f34d0d5e0afae63b3f5d975cbd18335a132e42b0c747d282f62ad2cd6c", 61 | "https://deno.land/std@0.196.0/assert/assert_array_includes.ts": "6856d7f2c3544bc6e62fb4646dfefa3d1df5ff14744d1bca19f0cbaf3b0d66c9", 62 | "https://deno.land/std@0.196.0/assert/assert_equals.ts": "a0ee60574e437bcab2dcb79af9d48dc88845f8fd559468d9c21b15fd638ef943", 63 | "https://deno.land/std@0.196.0/assert/assert_exists.ts": "407cb6b9fb23a835cd8d5ad804e2e2edbbbf3870e322d53f79e1c7a512e2efd7", 64 | "https://deno.land/std@0.196.0/assert/assert_false.ts": "a9962749f4bf5844e3fa494257f1de73d69e4fe0e82c34d0099287552163a2dc", 65 | "https://deno.land/std@0.196.0/assert/assert_instance_of.ts": "09fd297352a5b5bbb16da2b5e1a0d8c6c44da5447772648622dcc7df7af1ddb8", 66 | "https://deno.land/std@0.196.0/assert/assert_is_error.ts": "b4eae4e5d182272efc172bf28e2e30b86bb1650cd88aea059e5d2586d4160fb9", 67 | "https://deno.land/std@0.196.0/assert/assert_match.ts": "c4083f80600bc190309903c95e397a7c9257ff8b5ae5c7ef91e834704e672e9b", 68 | "https://deno.land/std@0.196.0/assert/assert_not_equals.ts": "9f1acab95bd1f5fc9a1b17b8027d894509a745d91bac1718fdab51dc76831754", 69 | "https://deno.land/std@0.196.0/assert/assert_not_instance_of.ts": "0c14d3dfd9ab7a5276ed8ed0b18c703d79a3d106102077ec437bfe7ed912bd22", 70 | "https://deno.land/std@0.196.0/assert/assert_not_match.ts": "3796a5b0c57a1ce6c1c57883dd4286be13a26f715ea662318ab43a8491a13ab0", 71 | "https://deno.land/std@0.196.0/assert/assert_not_strict_equals.ts": "ca6c6d645e95fbc873d25320efeb8c4c6089a9a5e09f92d7c1c4b6e935c2a6ad", 72 | "https://deno.land/std@0.196.0/assert/assert_object_match.ts": "27439c4f41dce099317566144299468ca822f556f1cc697f4dc8ed61fe9fee4c", 73 | "https://deno.land/std@0.196.0/assert/assert_rejects.ts": "45c59724de2701e3b1f67c391d6c71c392363635aad3f68a1b3408f9efca0057", 74 | "https://deno.land/std@0.196.0/assert/assert_strict_equals.ts": "5cf29b38b3f8dece95287325723272aa04e04dbf158d886d662fa594fddc9ed3", 75 | "https://deno.land/std@0.196.0/assert/assert_string_includes.ts": "b821d39ebf5cb0200a348863c86d8c4c4b398e02012ce74ad15666fc4b631b0c", 76 | "https://deno.land/std@0.196.0/assert/assert_throws.ts": "63784e951475cb7bdfd59878cd25a0931e18f6dc32a6077c454b2cd94f4f4bcd", 77 | "https://deno.land/std@0.196.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", 78 | "https://deno.land/std@0.196.0/assert/equal.ts": "9f1a46d5993966d2596c44e5858eec821859b45f783a5ee2f7a695dfc12d8ece", 79 | "https://deno.land/std@0.196.0/assert/fail.ts": "c36353d7ae6e1f7933d45f8ea51e358c8c4b67d7e7502028598fe1fea062e278", 80 | "https://deno.land/std@0.196.0/assert/mod.ts": "08d55a652c22c5da0215054b21085cec25a5da47ce4a6f9de7d9ad36df35bdee", 81 | "https://deno.land/std@0.196.0/assert/unimplemented.ts": "d56fbeecb1f108331a380f72e3e010a1f161baa6956fd0f7cf3e095ae1a4c75a", 82 | "https://deno.land/std@0.196.0/assert/unreachable.ts": "4600dc0baf7d9c15a7f7d234f00c23bca8f3eba8b140286aaca7aa998cf9a536", 83 | "https://deno.land/std@0.196.0/fmt/colors.ts": "a7eecffdf3d1d54db890723b303847b6e0a1ab4b528ba6958b8f2e754cf1b3bc", 84 | "https://deno.land/x/code_block_writer@12.0.0/mod.ts": "2c3448060e47c9d08604c8f40dee34343f553f33edcdfebbf648442be33205e5", 85 | "https://deno.land/x/code_block_writer@12.0.0/utils/string_utils.ts": "60cb4ec8bd335bf241ef785ccec51e809d576ff8e8d29da43d2273b69ce2a6ff", 86 | "https://deno.land/x/deno_cache@0.4.1/auth_tokens.ts": "5fee7e9155e78cedf3f6ff3efacffdb76ac1a76c86978658d9066d4fb0f7326e", 87 | "https://deno.land/x/deno_cache@0.4.1/cache.ts": "51f72f4299411193d780faac8c09d4e8cbee951f541121ef75fcc0e94e64c195", 88 | "https://deno.land/x/deno_cache@0.4.1/deno_dir.ts": "f2a9044ce8c7fe1109004cda6be96bf98b08f478ce77e7a07f866eff1bdd933f", 89 | "https://deno.land/x/deno_cache@0.4.1/deps.ts": "8974097d6c17e65d9a82d39377ae8af7d94d74c25c0cbb5855d2920e063f2343", 90 | "https://deno.land/x/deno_cache@0.4.1/dirs.ts": "d2fa473ef490a74f2dcb5abb4b9ab92a48d2b5b6320875df2dee64851fa64aa9", 91 | "https://deno.land/x/deno_cache@0.4.1/disk_cache.ts": "1f3f5232cba4c56412d93bdb324c624e95d5dd179d0578d2121e3ccdf55539f9", 92 | "https://deno.land/x/deno_cache@0.4.1/file_fetcher.ts": "07a6c5f8fd94bf50a116278cc6012b4921c70d2251d98ce1c9f3c352135c39f7", 93 | "https://deno.land/x/deno_cache@0.4.1/http_cache.ts": "f632e0d6ec4a5d61ae3987737a72caf5fcdb93670d21032ddb78df41131360cd", 94 | "https://deno.land/x/deno_cache@0.4.1/mod.ts": "ef1cda9235a93b89cb175fe648372fc0f785add2a43aa29126567a05e3e36195", 95 | "https://deno.land/x/deno_cache@0.4.1/util.ts": "8cb686526f4be5205b92c819ca2ce82220aa0a8dd3613ef0913f6dc269dbbcfe", 96 | "https://deno.land/x/deno_graph@0.26.0/lib/deno_graph.generated.js": "2f7ca85b2ceb80ec4b3d1b7f3a504956083258610c7b9a1246238c5b7c68f62d", 97 | "https://deno.land/x/deno_graph@0.26.0/lib/loader.ts": "380e37e71d0649eb50176a9786795988fc3c47063a520a54b616d7727b0f8629", 98 | "https://deno.land/x/deno_graph@0.26.0/lib/media_type.ts": "222626d524fa2f9ebcc0ec7c7a7d5dfc74cc401cc46790f7c5e0eab0b0787707", 99 | "https://deno.land/x/deno_graph@0.26.0/lib/snippets/deno_graph-de651bc9c240ed8d/src/deno_apis.js": "41192baaa550a5c6a146280fae358cede917ae16ec4e4315be51bef6631ca892", 100 | "https://deno.land/x/deno_graph@0.26.0/mod.ts": "11131ae166580a1c7fa8506ff553751465a81c263d94443f18f353d0c320bc14", 101 | "https://deno.land/x/dir@1.5.1/data_local_dir/mod.ts": "91eb1c4bfadfbeda30171007bac6d85aadacd43224a5ed721bbe56bc64e9eb66", 102 | "https://deno.land/x/dnt@0.38.0/lib/compiler.ts": "209ad2e1b294f93f87ec02ade9a0821f942d2e524104552d0aa8ff87021050a5", 103 | "https://deno.land/x/dnt@0.38.0/lib/compiler_transforms.ts": "f21aba052f5dcf0b0595c734450842855c7f572e96165d3d34f8fed2fc1f7ba1", 104 | "https://deno.land/x/dnt@0.38.0/lib/mod.deps.ts": "30367fc68bcd2acf3b7020cf5cdd26f817f7ac9ac35c4bfb6c4551475f91bc3e", 105 | "https://deno.land/x/dnt@0.38.0/lib/npm_ignore.ts": "57fbb7e7b935417d225eec586c6aa240288905eb095847d3f6a88e290209df4e", 106 | "https://deno.land/x/dnt@0.38.0/lib/package_json.ts": "61f35b06e374ed39ca776d29d67df4be7ee809d0bca29a8239687556c6d027c2", 107 | "https://deno.land/x/dnt@0.38.0/lib/pkg/dnt_wasm.generated.js": "82aeecfb055af0b2700e1e9b886e4a44fe3bf9cd11a9c4195cb169f53a134b15", 108 | "https://deno.land/x/dnt@0.38.0/lib/pkg/snippets/dnt-wasm-a15ef721fa5290c5/helpers.js": "a6b95adc943a68d513fe8ed9ec7d260ac466b7a4bced4e942f733e494bb9f1be", 109 | "https://deno.land/x/dnt@0.38.0/lib/shims.ts": "df1bd4d9a196dca4b2d512b1564fff64ac6c945189a273d706391f87f210d7e6", 110 | "https://deno.land/x/dnt@0.38.0/lib/test_runner/get_test_runner_code.ts": "4dc7a73a13b027341c0688df2b29a4ef102f287c126f134c33f69f0339b46968", 111 | "https://deno.land/x/dnt@0.38.0/lib/test_runner/test_runner.ts": "4d0da0500ec427d5f390d9a8d42fb882fbeccc92c92d66b6f2e758606dbd40e6", 112 | "https://deno.land/x/dnt@0.38.0/lib/transform.deps.ts": "e42f2bdef46d098453bdba19261a67cf90b583f5d868f7fe83113c1380d9b85c", 113 | "https://deno.land/x/dnt@0.38.0/lib/types.ts": "b8e228b2fac44c2ae902fbb73b1689f6ab889915bd66486c8a85c0c24255f5fb", 114 | "https://deno.land/x/dnt@0.38.0/lib/utils.ts": "878b7ac7003a10c16e6061aa49dbef9b42bd43174853ebffc9b67ea47eeb11d8", 115 | "https://deno.land/x/dnt@0.38.0/mod.ts": "b13349fe77847cf58e26b40bcd58797a8cec5d71b31a1ca567071329c8489de1", 116 | "https://deno.land/x/dnt@0.38.0/transform.ts": "f68743a14cf9bf53bfc9c81073871d69d447a7f9e3453e0447ca2fb78926bb1d", 117 | "https://deno.land/x/mock_fetch@0.3.0/mod.ts": "7e7806c65ab17b2b684c334c4e565812bdaf504a3e9c938d2bb52bb67428bc89", 118 | "https://deno.land/x/ts_morph@18.0.0/bootstrap/mod.ts": "b53aad517f106c4079971fcd4a81ab79fadc40b50061a3ab2b741a09119d51e9", 119 | "https://deno.land/x/ts_morph@18.0.0/bootstrap/ts_morph_bootstrap.js": "6645ac03c5e6687dfa8c78109dc5df0250b811ecb3aea2d97c504c35e8401c06", 120 | "https://deno.land/x/ts_morph@18.0.0/common/DenoRuntime.ts": "6a7180f0c6e90dcf23ccffc86aa8271c20b1c4f34c570588d08a45880b7e172d", 121 | "https://deno.land/x/ts_morph@18.0.0/common/mod.ts": "01985d2ee7da8d1caee318a9d07664774fbee4e31602bc2bb6bb62c3489555ed", 122 | "https://deno.land/x/ts_morph@18.0.0/common/ts_morph_common.js": "845671ca951073400ce142f8acefa2d39ea9a51e29ca80928642f3f8cf2b7700", 123 | "https://deno.land/x/ts_morph@18.0.0/common/typescript.js": "d5c598b6a2db2202d0428fca5fd79fc9a301a71880831a805d778797d2413c59", 124 | "https://deno.land/x/wasmbuild@0.14.1/cache.ts": "89eea5f3ce6035a1164b3e655c95f21300498920575ade23161421f5b01967f4", 125 | "https://deno.land/x/wasmbuild@0.14.1/loader.ts": "d98d195a715f823151cbc8baa3f32127337628379a02d9eb2a3c5902dbccfc02" 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Lago 2 | 3 | If you're reading this, we would first like to thank you for taking the time to contribute. 4 | 5 | The following is a set of guidelines for contributing to Lago and its packages, which are hosted in the [Lago Organization](https://github.com/getlago) on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. 6 | 7 | #### Table Of Contents 8 | 9 | [Code of Conduct](#code-of-conduct) 10 | 11 | [I don't want to read this whole thing, I just have a question!!!](#i-dont-want-to-read-this-whole-thing-i-just-have-a-question) 12 | 13 | [What should I know before I get started?](#what-should-i-know-before-i-get-started) 14 | 15 | - [Lago and Packages](#lago-and-packages) 16 | - [Design Decisions](#design-decisions) 17 | 18 | [How Can I Contribute?](#how-can-i-contribute) 19 | 20 | - [Reporting Bugs](#reporting-bugs) 21 | - [Suggesting Enhancements](#suggesting-enhancements) 22 | - [Your First Code Contribution](#your-first-code-contribution) 23 | - [Pull Requests](#pull-requests) 24 | 25 | [Styleguides](#styleguides) 26 | 27 | - [Git Commit Messages](#git-commit-messages) 28 | - [General style guide](#general-style-guide) 29 | 30 | [Additional Notes](#additional-notes) 31 | 32 | - [Issue and Pull Request Labels](#issue-and-pull-request-labels) 33 | 34 | ## Code of Conduct 35 | 36 | This project and everyone participating in it is governed by the [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [dev@getlago.com](mailto:dev@getlago.com). 37 | 38 | ## I don't want to read this whole thing I just have a question!!! 39 | 40 | - [Lago Discussions](https://lago-community.slack.com) 41 | - [Lago official documentation](https://doc.getlago.com/docs/guide/intro/welcome) 42 | - [Lago feature request](https://getlago.canny.io/) 43 | 44 | ## What should I know before I get started? 45 | 46 | ### Lago and Packages 47 | 48 | Lago is an open source project. When you initially consider contributing to Lago, you might be unsure about which of Lago elements implements the functionality you want to change or report a bug for. This section should help you with that. 49 | 50 | Here's a list of Lago's elements: 51 | 52 | - [lago](https://github.com/getlago/lago) - The entry point of the lago application 53 | - [lago/front](https://github.com/getlago/lago-front) - Lago's UI 54 | - [lago/api](https://github.com/getlago/lago-api) - Lago's API. 55 | - [lago/openAPI](https://github.com/getlago/lago-openapi) - OpenAPI definition for the Lago API 56 | 57 | #### The different clients 58 | 59 | - [lago/client/go](https://github.com/getlago/lago-go-client) - Lago's Go Client 60 | - [lago/client/javascript](https://github.com/getlago/lago-javascript-client) - Lago's Javascript Client (you are here 📍) 61 | - [lago/client/python](https://github.com/getlago/lago-python-client) - Lago's Python Client 62 | - [lago/client/ruby](https://github.com/getlago/lago-ruby-client) - Lago's Ruby Client 63 | 64 | Also, because Lago is extensible, it's possible that a feature you've become accustomed to in Lago or an issue you're encountering isn't coming from a bundled package at all, but rather a community package you've installed. Each community package has its own repository too. 65 | 66 | ### Design Decisions 67 | 68 | If you have a question around how we do things, check to see if it is documented in the wiki of the related repository. If it is _not_ documented there, please open a new topic on [Lago Discussions](https://lago-community.slack.com) and ask your question. 69 | 70 | ## How Can I Contribute? 71 | 72 | ### Reporting Bugs 73 | 74 | This section guides you through submitting a bug report for Lago. Following these guidelines helps maintainers and the community understand your report :pencil:, reproduce the behavior :computer: :computer:, and find related reports :mag_right:. 75 | 76 | Before creating bug reports, please check [this list](#before-submitting-a-bug-report) as you might find out that you don't need to create one. When you are creating a bug report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). Fill out the required [template](https://github.com/getlago/lago-javascript-client/issues/new?assignees=&labels=%F0%9F%90%9E+bug&template=bug_report.md&title=%5BBUG%5D%3A+), the information it asks for helps us resolve issues faster. 77 | 78 | > **Note:** If you find a **Closed** issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one. 79 | 80 | #### Before Submitting A Bug Report 81 | 82 | - **Check [Lago Discussions](https://lago-community.slack.com)** for a list of common questions and problems. 83 | - **Determine [which element the problem should be reported in](#lago-and-packages)**. 84 | - **Perform a [cursory search](https://github.com/search?q=+is%3Aissue+user%3Agetlago)** to see if the problem has already been reported. If it has **and the issue is still open**, add a comment to the existing issue instead of opening a new one. 85 | 86 | #### How Do I Submit A (Good) Bug Report? 87 | 88 | Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). After you've determined [which element](#lago-and-packages) your bug is related to, create an issue and provide the following information by filling in the template. 89 | 90 | Explain the problem and include additional details to help maintainers reproduce the problem: 91 | 92 | - **Use a clear and descriptive title** for the issue to identify the problem. 93 | - **Describe the exact steps which reproduce the problem** in as many details as possible. For example, start by explaining how you started Lago, e.g. which command exactly you used in the terminal, or how you started Lago otherwise. When listing steps, **don't just say what you did, but explain how you did it**. 94 | - **Provide specific examples to demonstrate the steps**. Include links to files or GitHub projects, or copy/pasteable snippets, which you use in those examples. If you're providing snippets in the issue, use [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines). 95 | - **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior. 96 | - **Explain which behavior you expected to see instead and why.** 97 | - **Include screenshots and animated GIFs** which show you following the described steps and clearly demonstrate the problem. If you use the keyboard while following the steps. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. 98 | - **If you're reporting that Lago crashed**, include a crash report with a stack trace from the operating system. Include the crash report in the issue in a [code block](https://help.github.com/articles/markdown-basics/#multiple-lines), a [file attachment](https://help.github.com/articles/file-attachments-on-issues-and-pull-requests/), or put it in a [gist](https://gist.github.com/) and provide link to that gist. 99 | - **If the problem wasn't triggered by a specific action**, describe what you were doing before the problem happened and share more information using the guidelines below. 100 | 101 | Provide more context by answering these questions: 102 | 103 | - **Did the problem start happening recently** (e.g. after updating to a new version of Lago) or was this always a problem? 104 | - If the problem started happening recently, **can you reproduce the problem in an older version of Lago?** What's the most recent version in which the problem doesn't happen? You can download older versions of Lago from [the releases page](https://github.com/getlago/lago/releases). 105 | - **Can you reliably reproduce the issue?** If not, provide details about how often the problem happens and under which conditions it normally happens. 106 | 107 | Include details about your configuration and environment: 108 | 109 | - **Which version of Lago are you using?** 110 | - **What's the name and version of the OS you're using**? 111 | - **Are you running Lago in a virtual machine?** If so, which VM software are you using and which operating systems and versions are used for the host and the guest? 112 | - **Which [packages](#lago-and-packages) do you have installed?**. 113 | 114 | ### Suggesting Enhancements 115 | 116 | This section guides you through submitting an enhancement suggestion for Lago, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion :pencil: and find related suggestions :mag_right:. 117 | 118 | Before creating enhancement suggestions, please check [this list](#before-submitting-an-enhancement-suggestion) as you might find out that you don't need to create one. When you are creating an enhancement suggestion, please [include as many details as possible](#how-do-i-submit-a-good-enhancement-suggestion). Fill in the [template](https://github.com/getlago/lago-node-js/issues/new?assignees=&labels=%F0%9F%9B%A0+feature&template=feature_request.md&title=%5BFEAT%5D%3A+), including the steps that you imagine you would take if the feature you're requesting existed. 119 | 120 | #### Before Submitting An Enhancement Suggestion 121 | 122 | - **Check the [documentation](https://doc.getlago.com/docs/guide/intro)** you might discover that the enhancement is already available. Most importantly, check if you're using [the latest version of Lago](https://github.com/getlago/lago/releases). 123 | - **Determine [which element the enhancement should be suggested in](#lago-and-packages).** 124 | - **Perform a [cursory search](https://github.com/search?q=+is%3Aissue+user%3Agetlago)** to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. 125 | 126 | #### How Do I Submit A (Good) Enhancement Suggestion? 127 | 128 | Enhancement suggestions are tracked as [GitHub issues](https://guides.github.com/features/issues/). After you've determined [which repository](#lago-and-packages) your enhancement suggestion is related to, create an issue and provide the following information: 129 | 130 | - **Use a clear and descriptive title** for the issue to identify the suggestion. 131 | - **Provide a step-by-step description of the suggested enhancement** in as many details as possible. 132 | - **Provide specific examples to demonstrate the steps**. Include copy/pasteable snippets which you use in those examples, as [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines). 133 | - **Describe the current behavior** and **explain which behavior you expected to see instead** and why. 134 | - **Include screenshots and animated GIFs** which help you demonstrate the steps or point out the part of Lago which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. 135 | - **Explain why this enhancement would be useful** to most Lago users and isn't something that can or should be implemented as a [community package](#lago-and-packages). 136 | - **Specify which version of Lago you're using.** 137 | - **Specify the name and version of the OS you're using.** 138 | 139 | ### Your First Code Contribution 140 | 141 | Unsure where to begin contributing to Lago? You can start by looking through these `good first issue` and `help-wanted` labels: 142 | 143 | - Good first issues - issues which should only require a few lines of code, and a test or two. 144 | - Help wanted issues - issues which should be a bit more involved than `good first issue` issues. 145 | 146 | Both issue lists are sorted by total number of comments. While not perfect, number of comments is a reasonable proxy for impact a given change will have. 147 | 148 | #### Local development 149 | 150 | Lago and all packages can be developed locally. For instructions on how to do this, see the dedicated section in the README or in the wiki of the related repository. 151 | 152 | ### Pull Requests 153 | 154 | The process described here has several goals: 155 | 156 | - Maintain Lago's quality 157 | - Fix problems that are important to users 158 | - Engage the community in working toward the best possible Lago 159 | - Enable a sustainable system for Lago's maintainers to review contributions 160 | 161 | Please follow these steps to have your contribution considered by the maintainers: 162 | 163 | 1. Follow all instructions in [the template](PULL_REQUEST_TEMPLATE.md) 164 | 2. Follow the [styleguides](#styleguides) 165 | 3. After you submit your pull request, verify that all [status checks](https://help.github.com/articles/about-status-checks/) are passing
What if the status checks are failing?If a status check is failing, and you believe that the failure is unrelated to your change, please leave a comment on the pull request explaining why you believe the failure is unrelated. A maintainer will re-run the status check for you. If we conclude that the failure was a false positive, then we will open an issue to track that problem with our status check suite.
166 | 167 | While the prerequisites above must be satisfied prior to having your pull request reviewed, the reviewer(s) may ask you to complete additional design work, tests, or other changes before your pull request can be ultimately accepted. 168 | 169 | ## Styleguides 170 | 171 | ### Git Commit Messages 172 | 173 | - Use the present tense ("Add feature" not "Added feature") 174 | - Use the imperative mood ("Move cursor to..." not "Moves cursor to...") 175 | - Limit the first line to 72 characters or less 176 | - Reference issues and pull requests liberally after the first line 177 | - When only changing documentation, include `[ci skip]` in the commit title 178 | - Use the [Convention commits](https://www.conventionalcommits.org/en/v1.0.0/) convention. 179 | 180 | ## Additional Notes 181 | 182 | ### Issue and Pull Request Labels 183 | 184 | This section lists the labels we use to help us track and manage issues and pull requests. 185 | 186 | [GitHub search](https://help.github.com/articles/searching-issues/) makes it easy to use labels for finding groups of issues or pull requests you're interested in. To help you find issues and pull requests, each label is listed with search links for finding open items with that label. We encourage you to read about [other search filters](https://help.github.com/articles/searching-issues/) which will help you write more focused queries. 187 | 188 | The labels are loosely grouped by their purpose, but it's not required that every issue has a label from every group or that an issue can't have more than one label from the same group. 189 | 190 | Please open an issue if you have suggestions for new labels. 191 | 192 | #### Type of Issue and Issue State 193 | 194 | | Label name | :mag_right: | Description | 195 | | --------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | 196 | | `feature` | [Issues](https://github.com/getlago/lago-javascript-client/labels/%F0%9F%9B%A0%20feature) | Feature requests. | 197 | | `improvement` | [Issues](https://github.com/getlago/lago-javascript-client/labels/%F0%9F%8C%88%20improvement) | Improvement requests (of existing features). | 198 | | `documentation` | [Issues](https://github.com/getlago/lago-javascript-client/labels/%F0%9F%93%84%20Documentation) | Feature requests. | 199 | | `bug` | [Issues](https://github.com/getlago/lago-javascript-client/labels/%F0%9F%90%9E%20bug) | Confirmed bugs or reports that are very likely to be bugs. | 200 | | `critical bug` | [Issues](https://github.com/getlago/lago-javascript-client/labels/%F0%9F%99%80%20Critical%20bug) | Confirmed critical bugs or reports that are very likely to be bugs. | 201 | | `chore` | [Issues](https://github.com/getlago/lago-javascript-client/labels/%F0%9F%A5%B7%20chore) | Chore related issues | 202 | | `help wanted` | [Issues](https://github.com/getlago/lago-node-js/labels/help-wanted) | The Lago core team would appreciate help from the community in resolving these issues. | 203 | | `good first issue` | [Issues](https://github.com/getlago/lago-javascript-client/labels/%F0%9F%90%A3%20Beginner) | Less complex issues which would be good first issues to work on for users who want to contribute to Lago. | 204 | | `wontfix` | [Issues](https://github.com/getlago/lago-javascript-client/labels/%E2%9D%8C%20wontfix) | The Lago core team has decided not to fix these issues for now, either because they're working as intended or for some other reason. | 205 | | `dependencies` | [Issues](https://github.com/getlago/lago-javascript-client/labels/%F0%9F%94%97%20dependencies) | Issues reported on the wrong repository | 206 | 207 | #### Pull Request Labels 208 | 209 | | Label name | :mag_right: | Description | 210 | | ------------------ | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- | 211 | | `needs-review` | [PR](https://github.com/getlago/lago-javascript-client/pulls?q=is%3Apr+is%3Aopen+review%3Arequired) | Pull requests which need code review, and approval from maintainers or Lago core team. | 212 | | `requires-changes` | [PR](https://github.com/getlago/lago-javascript-client/pulls?q=is%3Apr+is%3Aopen+review%3Achanges-requested) | Pull requests which need to be updated based on review comments and then reviewed again. | 213 | | `review-approved` | [PR](https://github.com/getlago/lago-javascript-client/pulls?q=is%3Apr+is%3Aopen+review%3Aapproved) | That has been approved | 214 | --------------------------------------------------------------------------------