diff --git a/CHANGELOG.md b/CHANGELOG.md index 9691d25..f12eef8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,17 @@ When we make [non-breaking changes](https://developer.paddle.com/api-reference/a This means when upgrading minor versions of the SDK, you may notice type errors. You can safely ignore these or fix by adding additional type guards. +## 2.0.0-rc.1 - 2024-10-08 + +### Added + +- Added `simulationTypes` resources +- Added `simulations` resources +- Added `simulationRuns` resources +- Added `simulationRunEvents` resources + +--- + ## 2.0.0-rc.0 - 2024-09-26 > **Breaking changes:** This version includes major improvements that introduce breaking changes. These are called out below. @@ -40,7 +51,7 @@ This means when upgrading minor versions of the SDK, you may notice type errors. ## 1.6.0 - 2024-09-16 ### Added - + - Added `adjustments.getCreditNotePDF()` to [get a credit note for an adjustment](https://developer.paddle.com/api-reference/adjustments/get-credit-note-pdf?utm_source=dx&utm_medium=paddle-node-sdk) - Added `disposition` query parameter to `adjustments.getCreditNotePDF()` and `transactions.getInvoicePDF()` operations, see [related changelog](https://developer.paddle.com/changelog/2024/invoice-pdf-open-in-browser?utm_source=dx&utm_medium=paddle-node-sdk). - Added pagination support to `notificationSettings.list()` operation, see [related changelog](https://developer.paddle.com/changelog/2024/notification-settings-pagination?utm_source=dx&utm_medium=paddle-node-sdk). @@ -170,7 +181,7 @@ This means when upgrading minor versions of the SDK, you may notice type errors. ### Removed - **Breaking change:** Removed `*Includes` entity in favour of standard entities. - + - Use `Price` instead of `PriceWithIncludes` - Use `Product` instead of `ProductWithIncludes` - Use `Subscription` instead of `SubscriptionIncludes` @@ -230,7 +241,7 @@ This means when upgrading minor versions of the SDK, you may notice type errors. ### Fixed -- Marked `unitPriceOverrides` as optional in Price entity. +- Marked `unitPriceOverrides` as optional in Price entity. --- @@ -290,7 +301,7 @@ This means when upgrading minor versions of the SDK, you may notice type errors. - Added `notificationSettings.get()` to [get a notification settings](https://developer.paddle.com/api-reference/notification-settings/get-notification-setting?utm_source=dx&utm_medium=paddle-node-sdk) - Added `notificationSettings.update()` to [update a notification settings](https://developer.paddle.com/api-reference/notification-settings/update-notification-setting?utm_source=dx&utm_medium=paddle-node-sdk) - Added `notificationSettings.delete()` to [delete a notification settings](https://developer.paddle.com/api-reference/notification-settings/delete-notification-setting?utm_source=dx&utm_medium=paddle-node-sdk) -- Added `notifications.list()` to [list all notifications](https://developer.paddle.com/api-reference/notifications/list-notifications?utm_source=dx&utm_medium=paddle-node-sdk) +- Added `notifications.list()` to [list all notifications](https://developer.paddle.com/api-reference/notifications/list-notifications?utm_source=dx&utm_medium=paddle-node-sdk) - Added `notifications.get()` to [get a notification](https://developer.paddle.com/api-reference/notifications/get-notification?utm_source=dx&utm_medium=paddle-node-sdk) - Added `notifications.replay()` to [replay a notification](https://developer.paddle.com/api-reference/notifications/replay-notification?utm_source=dx&utm_medium=paddle-node-sdk) - Added `notifications.getLogs()` to [get all logs for a notification](https://developer.paddle.com/api-reference/notification-logs/list-notification-logs?utm_source=dx&utm_medium=paddle-node-sdk) @@ -315,7 +326,7 @@ This means when upgrading minor versions of the SDK, you may notice type errors. ### Added - Added helper function to archive supported entities -- Added `pricingPreview.preview()` to [preview calculations for one or more prices](https://developer.paddle.com/api-reference/pricing-preview/preview-prices?utm_source=dx&utm_medium=paddle-node-sdk) +- Added `pricingPreview.preview()` to [preview calculations for one or more prices](https://developer.paddle.com/api-reference/pricing-preview/preview-prices?utm_source=dx&utm_medium=paddle-node-sdk) ### Changed @@ -363,7 +374,7 @@ This means when upgrading minor versions of the SDK, you may notice type errors. - Added changelog. ---- +--- ## 0.1.6 - 2023-11-22 @@ -371,7 +382,7 @@ This means when upgrading minor versions of the SDK, you may notice type errors. - Fixed optional management URL object in subscription entities. ---- +--- ## 0.1.5 - 2023-11-14 diff --git a/package.json b/package.json index 2c75202..d4c27ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paddle/paddle-node-sdk", - "version": "2.0.0-rc.0", + "version": "2.0.0-rc.1", "description": "A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.", "main": "dist/cjs/index.cjs.node.js", "module": "dist/esm/index.esm.node.js", diff --git a/src/__tests__/mocks/resources/simulation-run-events.mock.ts b/src/__tests__/mocks/resources/simulation-run-events.mock.ts new file mode 100644 index 0000000..00f0a2c --- /dev/null +++ b/src/__tests__/mocks/resources/simulation-run-events.mock.ts @@ -0,0 +1,39 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { ISimulationRunEventResponse } from '../../../types/index.js'; +import { Response, ResponsePaginated } from '../../../internal/index.js'; + +export const SimulationRunEventMock: ISimulationRunEventResponse = { + id: 'ntfsimevt_123', + status: 'success', + event_type: 'subscription.created', + payload: {}, + request: null, + response: null, + created_at: '2024-09-18T12:24:47.960617Z', + updated_at: '2024-09-18T12:24:48.309530Z', +}; + +export const SimulationRunEventMockResponse: Response = { + data: SimulationRunEventMock, + meta: { + request_id: '', + }, +}; + +export const ListSimulationRunEventMockResponse: ResponsePaginated = { + data: [SimulationRunEventMock], + meta: { + request_id: '', + pagination: { + estimated_total: 10, + has_more: true, + next: '/simulations/ntfsim_123/runs/ntfsimrun_123/events?after=1', + per_page: 10, + }, + }, +}; diff --git a/src/__tests__/mocks/resources/simulation-runs.mock.ts b/src/__tests__/mocks/resources/simulation-runs.mock.ts new file mode 100644 index 0000000..01a2da2 --- /dev/null +++ b/src/__tests__/mocks/resources/simulation-runs.mock.ts @@ -0,0 +1,36 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { ISimulationRunResponse } from '../../../types/index.js'; +import { Response, ResponsePaginated } from '../../../internal/index.js'; + +export const SimulationRunMock: ISimulationRunResponse = { + id: 'ntfsimrun_01j82gvz2cgw08p7mak3gcd3a3', + status: 'completed', + type: 'subscription_creation', + created_at: '2024-09-18T12:14:15.628606Z', + updated_at: '2024-09-18T12:14:27.244695Z', +}; + +export const SimulationRunMockResponse: Response = { + data: SimulationRunMock, + meta: { + request_id: '', + }, +}; + +export const ListSimulationRunMockResponse: ResponsePaginated = { + data: [SimulationRunMock], + meta: { + request_id: '', + pagination: { + estimated_total: 10, + has_more: true, + next: '/simulations/ntfsim_123/runs?after=1', + per_page: 10, + }, + }, +}; diff --git a/src/__tests__/mocks/resources/simulation-types.mock.ts b/src/__tests__/mocks/resources/simulation-types.mock.ts new file mode 100644 index 0000000..02f556d --- /dev/null +++ b/src/__tests__/mocks/resources/simulation-types.mock.ts @@ -0,0 +1,428 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { ISimulationTypeResponse } from '../../../types/index.js'; +import { Response } from '../../../internal/index.js'; + +export const SimulationTypesMock: ISimulationTypeResponse[] = [ + { + name: 'subscription_creation', + label: 'Subscription created from a checkout', + description: 'Occurs when a subscription is created.', + group: 'Subscription', + type: 'scenario', + events: [ + 'transaction.created', + 'customer.created', + 'address.created', + 'transaction.updated', + 'transaction.ready', + 'transaction.updated', + 'transaction.paid', + 'subscription.created', + 'subscription.activated', + 'transaction.updated', + 'transaction.updated', + 'transaction.completed', + ], + }, + { + name: 'subscription_renewal', + label: 'Subscription renewed successfully', + description: 'Occurs when a subscription is renewed.', + group: 'Subscription', + type: 'scenario', + events: [ + 'subscription.updated', + 'transaction.created', + 'transaction.billed', + 'transaction.updated', + 'transaction.paid', + 'transaction.updated', + 'transaction.completed', + ], + }, + { + name: 'subscription_pause', + label: 'Subscription paused by customer', + description: 'Occurs when a subscription is paused.', + group: 'Subscription', + type: 'scenario', + events: ['subscription.updated', 'subscription.paused'], + }, + { + name: 'subscription_resume', + label: 'Subscription resumed after being paused', + description: 'Occurs when a subscription is resumed after being paused.', + group: 'Subscription', + type: 'scenario', + events: [ + 'subscription.updated', + 'subscription.resumed', + 'transaction.created', + 'transaction.billed', + 'transaction.updated', + 'transaction.paid', + 'transaction.updated', + 'transaction.completed', + ], + }, + { + name: 'subscription_cancellation', + label: 'Subscription canceled by customer', + description: 'Occurs when a subscription is canceled.', + group: 'Subscription', + type: 'scenario', + events: ['subscription.updated', 'subscription.canceled'], + }, + { + name: 'subscription.activated', + label: 'subscription.activated', + description: + 'Occurs when a subscription becomes active. Its status field changes to active. This means any trial period has elapsed and Paddle has successfully billed the customer.', + group: 'Subscription', + type: 'single_event', + events: ['subscription.activated'], + }, + { + name: 'subscription.canceled', + label: 'subscription.canceled', + description: 'Occurs when a subscription is canceled. Its status field changes to canceled.', + group: 'Subscription', + type: 'single_event', + events: ['subscription.canceled'], + }, + { + name: 'subscription.created', + label: 'subscription.created', + description: + 'Occurs when a subscription is created. subscription.trialing or subscription.activated typically follow.', + group: 'Subscription', + type: 'single_event', + events: ['subscription.created'], + }, + { + name: 'subscription.past_due', + label: 'subscription.past_due', + description: 'Occurs when a subscription has an unpaid transaction. Its status changes to past_due.', + group: 'Subscription', + type: 'single_event', + events: ['subscription.past_due'], + }, + { + name: 'subscription.paused', + label: 'subscription.paused', + description: 'Occurs when a subscription is paused. Its status field changes to paused.', + group: 'Subscription', + type: 'single_event', + events: ['subscription.paused'], + }, + { + name: 'subscription.resumed', + label: 'subscription.resumed', + description: 'Occurs when a subscription is resumed after being paused. Its status field changes to active.', + group: 'Subscription', + type: 'single_event', + events: ['subscription.resumed'], + }, + { + name: 'subscription.trialing', + label: 'subscription.trialing', + description: 'Occurs when a subscription enters trial period.', + group: 'Subscription', + type: 'single_event', + events: ['subscription.trialing'], + }, + { + name: 'subscription.updated', + label: 'subscription.updated', + description: 'Occurs when a subscription is updated.', + group: 'Subscription', + type: 'single_event', + events: ['subscription.updated'], + }, + { + name: 'subscription.imported', + label: 'subscription.imported', + description: 'Occurs when a subscription is imported.', + group: 'Subscription', + type: 'single_event', + events: ['subscription.imported'], + }, + { + name: 'address.created', + label: 'address.created', + description: 'Occurs when an address is created.', + group: 'Address', + type: 'single_event', + events: ['address.created'], + }, + { + name: 'address.updated', + label: 'address.updated', + description: 'Occurs when an address is updated.', + group: 'Address', + type: 'single_event', + events: ['address.updated'], + }, + { + name: 'address.imported', + label: 'address.imported', + description: 'Occurs when a address is imported.', + group: 'Address', + type: 'single_event', + events: ['address.imported'], + }, + { + name: 'adjustment.created', + label: 'adjustment.created', + description: 'Occurs when an adjustment is created.', + group: 'Adjustment', + type: 'single_event', + events: ['adjustment.created'], + }, + { + name: 'adjustment.updated', + label: 'adjustment.updated', + description: + 'Occurs when an adjustment is updated, the only time an adjustment will be updated is when the status changes from pending to approved or from pending to rejected.', + group: 'Adjustment', + type: 'single_event', + events: ['adjustment.updated'], + }, + { + name: 'business.created', + label: 'business.created', + description: 'Occurs when a business is created.', + group: 'Business', + type: 'single_event', + events: ['business.created'], + }, + { + name: 'business.updated', + label: 'business.updated', + description: 'Occurs when a business is updated.', + group: 'Business', + type: 'single_event', + events: ['business.updated'], + }, + { + name: 'business.imported', + label: 'business.imported', + description: 'Occurs when a business is imported.', + group: 'Business', + type: 'single_event', + events: ['business.imported'], + }, + { + name: 'customer.created', + label: 'customer.created', + description: 'Occurs when a customer is created.', + group: 'Customer', + type: 'single_event', + events: ['customer.created'], + }, + { + name: 'customer.updated', + label: 'customer.updated', + description: 'Occurs when a customer is updated.', + group: 'Customer', + type: 'single_event', + events: ['customer.updated'], + }, + { + name: 'customer.imported', + label: 'customer.imported', + description: 'Occurs when a customer is imported.', + group: 'Customer', + type: 'single_event', + events: ['customer.imported'], + }, + { + name: 'discount.created', + label: 'discount.created', + description: 'Occurs when a discount is created.', + group: 'Discount', + type: 'single_event', + events: ['discount.created'], + }, + { + name: 'discount.updated', + label: 'discount.updated', + description: 'Occurs when a discount is updated.', + group: 'Discount', + type: 'single_event', + events: ['discount.updated'], + }, + { + name: 'discount.imported', + label: 'discount.imported', + description: 'Occurs when a discount is imported.', + group: 'Discount', + type: 'single_event', + events: ['discount.imported'], + }, + { + name: 'payout.created', + label: 'payout.created', + description: 'Occurs when a payout is created.', + group: 'Payout', + type: 'single_event', + events: ['payout.created'], + }, + { + name: 'payout.paid', + label: 'payout.paid', + description: 'Occurs when a payout is paid.', + group: 'Payout', + type: 'single_event', + events: ['payout.paid'], + }, + { + name: 'price.created', + label: 'price.created', + description: 'Occurs when a price is created.', + group: 'Price', + type: 'single_event', + events: ['price.created'], + }, + { + name: 'price.updated', + label: 'price.updated', + description: 'Occurs when a price is updated.', + group: 'Price', + type: 'single_event', + events: ['price.updated'], + }, + { + name: 'price.imported', + label: 'price.imported', + description: 'Occurs when a price is imported.', + group: 'Price', + type: 'single_event', + events: ['price.imported'], + }, + { + name: 'product.created', + label: 'product.created', + description: 'Occurs when a product is created.', + group: 'Product', + type: 'single_event', + events: ['product.created'], + }, + { + name: 'product.updated', + label: 'product.updated', + description: 'Occurs when a product is updated.', + group: 'Product', + type: 'single_event', + events: ['product.updated'], + }, + { + name: 'product.imported', + label: 'product.imported', + description: 'Occurs when a product is imported.', + group: 'Product', + type: 'single_event', + events: ['product.imported'], + }, + { + name: 'report.created', + label: 'report.created', + description: 'Occurs when a report is created.', + group: 'Report', + type: 'single_event', + events: ['report.created'], + }, + { + name: 'report.updated', + label: 'report.updated', + description: 'Occurs when a report is updated.', + group: 'Report', + type: 'single_event', + events: ['report.updated'], + }, + { + name: 'transaction.billed', + label: 'transaction.billed', + description: 'Occurs when a transaction is billed. Its status field changes to billed and billed_at is populated.', + group: 'Transaction', + type: 'single_event', + events: ['transaction.billed'], + }, + { + name: 'transaction.canceled', + label: 'transaction.canceled', + description: 'Occurs when a transaction is canceled. Its status field changes to canceled.', + group: 'Transaction', + type: 'single_event', + events: ['transaction.canceled'], + }, + { + name: 'transaction.completed', + label: 'transaction.completed', + description: 'Occurs when a transaction is completed. Its status field changes to completed.', + group: 'Transaction', + type: 'single_event', + events: ['transaction.completed'], + }, + { + name: 'transaction.created', + label: 'transaction.created', + description: 'Occurs when a transaction is created.', + group: 'Transaction', + type: 'single_event', + events: ['transaction.created'], + }, + { + name: 'transaction.paid', + label: 'transaction.paid', + description: 'Occurs when a transaction is paid. Its status field changes to paid.', + group: 'Transaction', + type: 'single_event', + events: ['transaction.paid'], + }, + { + name: 'transaction.past_due', + label: 'transaction.past_due', + description: 'Occurs when a transaction becomes past due. Its status field changes to past_due.', + group: 'Transaction', + type: 'single_event', + events: ['transaction.past_due'], + }, + { + name: 'transaction.payment_failed', + label: 'transaction.payment_failed', + description: + 'Occurs when a payment fails for a transaction. The payments array is updated with details of the payment attempt.', + group: 'Transaction', + type: 'single_event', + events: ['transaction.payment_failed'], + }, + { + name: 'transaction.ready', + label: 'transaction.ready', + description: 'Occurs when a transaction is ready to be billed. Its status field changes to ready.', + group: 'Transaction', + type: 'single_event', + events: ['transaction.ready'], + }, + { + name: 'transaction.updated', + label: 'transaction.updated', + description: 'Occurs when a transaction is updated.', + group: 'Transaction', + type: 'single_event', + events: ['transaction.updated'], + }, +]; + +export const ListSimulationTypeMockResponse: Response = { + data: SimulationTypesMock, + meta: { + request_id: '', + }, +}; diff --git a/src/__tests__/mocks/resources/simulations.mock.ts b/src/__tests__/mocks/resources/simulations.mock.ts new file mode 100644 index 0000000..d5c65a3 --- /dev/null +++ b/src/__tests__/mocks/resources/simulations.mock.ts @@ -0,0 +1,51 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { ISimulationResponse } from '../../../types/index.js'; +import { Response, ResponsePaginated } from '../../../internal/index.js'; +import { CreateSimulationRequestBody, UpdateSimulationRequestBody } from '../../../resources/index.js'; + +export const CreateSimulationMock: CreateSimulationRequestBody = { + notificationSettingId: 'ntfset_01gt21c5pdx9q1e4mh1xrsjjn6', + type: 'address.created', + name: 'New address created', +}; + +export const updateSimulationMock: UpdateSimulationRequestBody = { + name: 'New UK address created', +}; + +export const SimulationMock: ISimulationResponse = { + id: 'ntfsim_01ghbkd0frb9k95cnhwd1bxpvk', + status: 'active', + notification_setting_id: 'ntfset_01gt21c5pdx9q1e4mh1xrsjjn6', + name: 'New address created', + type: 'address.created', + payload: null, + last_run_at: '2024-10-12T07:20:50.52Z', + created_at: '2024-10-12T07:20:50.52Z', + updated_at: '2024-10-13T07:20:50.52Z', +}; + +export const SimulationMockResponse: Response = { + data: SimulationMock, + meta: { + request_id: '', + }, +}; + +export const ListSimulationMockResponse: ResponsePaginated = { + data: [SimulationMock], + meta: { + request_id: '', + pagination: { + estimated_total: 10, + has_more: true, + next: '/simulations?after=1', + per_page: 10, + }, + }, +}; diff --git a/src/__tests__/resources/simulation-run-events.test.ts b/src/__tests__/resources/simulation-run-events.test.ts new file mode 100644 index 0000000..bb14710 --- /dev/null +++ b/src/__tests__/resources/simulation-run-events.test.ts @@ -0,0 +1,91 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { SimulationRunEventsResource, type ListSimulationRunEventsQueryParameters } from '../../resources/index.js'; +import { getPaddleTestClient } from '../helpers/test-client.js'; +import { ListSimulationRunEventMockResponse } from '../mocks/resources/simulation-run-events.mock.js'; +import { + SimulationRunEventMock, + SimulationRunEventMockResponse, +} from '../mocks/resources/simulation-run-events.mock.js'; + +const simulationId = 'ntfsim_123'; +const simulationRunId = 'ntfsimrun_123'; + +describe('SimulationRunEventsResource', () => { + test('should return a list of simulationRunEvents', async () => { + const paddleInstance = getPaddleTestClient(); + paddleInstance.get = jest.fn().mockResolvedValue(ListSimulationRunEventMockResponse); + + const simulationRunEventsResource = new SimulationRunEventsResource(paddleInstance); + const simulationRunEventCollection = simulationRunEventsResource.list(simulationId, simulationRunId); + + let simulationRunEvents = await simulationRunEventCollection.next(); + expect(paddleInstance.get).toBeCalledWith(`/simulations/${simulationId}/runs/${simulationRunId}/events?`); + expect(simulationRunEvents.length).toBe(1); + + simulationRunEvents = await simulationRunEventCollection.next(); + expect(paddleInstance.get).toBeCalledWith(`/simulations/${simulationId}/runs/${simulationRunId}/events?after=1`); + expect(simulationRunEvents.length).toBe(1); + }); + + test('should accept query params and return a list of simulationRunEvents', async () => { + const paddleInstance = getPaddleTestClient(); + paddleInstance.get = jest.fn().mockResolvedValue(ListSimulationRunEventMockResponse); + const simulationRunEventsResource = new SimulationRunEventsResource(paddleInstance); + const queryParams: ListSimulationRunEventsQueryParameters = { + after: '2', + id: ['1234'], + }; + + const simulationRunEventCollection = simulationRunEventsResource.list(simulationId, simulationRunId, queryParams); + let simulationRunEvents = await simulationRunEventCollection.next(); + + expect(paddleInstance.get).toBeCalledWith( + `/simulations/${simulationId}/runs/${simulationRunId}/events?after=2&id=1234`, + ); + expect(simulationRunEvents.length).toBe(1); + }); + + test('should return a single simulationRunEvent by ID', async () => { + const simulationRunEventId = SimulationRunEventMock.id; + const paddleInstance = getPaddleTestClient(); + paddleInstance.get = jest.fn().mockResolvedValue(SimulationRunEventMockResponse); + + const simulationRunEventsResource = new SimulationRunEventsResource(paddleInstance); + const simulationRunEvent = await simulationRunEventsResource.get( + simulationId, + simulationRunId, + simulationRunEventId, + ); + + expect(paddleInstance.get).toBeCalledWith( + `/simulations/${simulationId}/runs/${simulationRunId}/events/${simulationRunEventId}`, + ); + expect(simulationRunEvent).toBeDefined(); + expect(simulationRunEvent.id).toBe(simulationRunEventId); + }); + + test('should replay an existing simulationRunEvent', async () => { + const simulationRunEventId = SimulationRunEventMock.id; + + const paddleInstance = getPaddleTestClient(); + paddleInstance.post = jest.fn().mockResolvedValue(SimulationRunEventMockResponse); + + const simulationRunEventsResource = new SimulationRunEventsResource(paddleInstance); + const replayedSimulationRunEvent = await simulationRunEventsResource.replay( + simulationId, + simulationRunId, + simulationRunEventId, + ); + + expect(paddleInstance.post).toBeCalledWith( + `/simulations/${simulationId}/runs/${simulationRunId}/events/${simulationRunEventId}/replay`, + undefined, + ); + expect(replayedSimulationRunEvent).toBeDefined(); + }); +}); diff --git a/src/__tests__/resources/simulation-runs.test.ts b/src/__tests__/resources/simulation-runs.test.ts new file mode 100644 index 0000000..9b1bc12 --- /dev/null +++ b/src/__tests__/resources/simulation-runs.test.ts @@ -0,0 +1,101 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { + SimulationRunsResource, + type ListSimulationRunQueryParameters, + type GetSimulationRunQueryParameters, +} from '../../resources/index.js'; +import { getPaddleTestClient } from '../helpers/test-client.js'; +import { + SimulationRunMockResponse, + SimulationRunMock, + ListSimulationRunMockResponse, +} from '../mocks/resources/simulation-runs.mock.js'; +import { QueryParameters } from '../../internal/base/index.js'; + +const simulationId = 'ntfsim_123'; + +describe('SimulationRunsResource', () => { + test('should return a list of simulationRuns', async () => { + const paddleInstance = getPaddleTestClient(); + paddleInstance.get = jest.fn().mockResolvedValue(ListSimulationRunMockResponse); + + const simulationRunsResource = new SimulationRunsResource(paddleInstance); + const simulationRunCollection = simulationRunsResource.list(simulationId); + + let simulationRuns = await simulationRunCollection.next(); + expect(paddleInstance.get).toBeCalledWith(`/simulations/${simulationId}/runs?`); + expect(simulationRuns.length).toBe(1); + + simulationRuns = await simulationRunCollection.next(); + expect(paddleInstance.get).toBeCalledWith(`/simulations/${simulationId}/runs?after=1`); + expect(simulationRuns.length).toBe(1); + }); + + test('should accept query params and return a list of simulationRuns', async () => { + const paddleInstance = getPaddleTestClient(); + paddleInstance.get = jest.fn().mockResolvedValue(ListSimulationRunMockResponse); + const simulationRunsResource = new SimulationRunsResource(paddleInstance); + const queryParams: ListSimulationRunQueryParameters = { + after: '2', + id: ['1234'], + include: ['price'], + }; + + const simulationRunCollection = simulationRunsResource.list(simulationId, queryParams); + let simulationRuns = await simulationRunCollection.next(); + + expect(paddleInstance.get).toBeCalledWith(`/simulations/${simulationId}/runs?after=2&id=1234&include=price`); + expect(simulationRuns.length).toBe(1); + }); + + test('should return a single simulationRun by ID', async () => { + const simulationRunId = SimulationRunMock.id; + const paddleInstance = getPaddleTestClient(); + paddleInstance.get = jest.fn().mockResolvedValue(SimulationRunMockResponse); + + const simulationRunsResource = new SimulationRunsResource(paddleInstance); + const simulationRun = await simulationRunsResource.get(simulationId, simulationRunId); + + expect(paddleInstance.get).toBeCalledWith(`/simulations/${simulationId}/runs/${simulationRunId}`, { + queryParams: undefined, + }); + expect(simulationRun).toBeDefined(); + expect(simulationRun.id).toBe(simulationRunId); + }); + + test('should accepts query params and return a single simulationRun by ID', async () => { + const simulationRunId = SimulationRunMock.id; + const paddleInstance = getPaddleTestClient(); + + paddleInstance.get = jest.fn().mockResolvedValue(SimulationRunMockResponse); + const simulationRunsResource = new SimulationRunsResource(paddleInstance); + + const queryParams: GetSimulationRunQueryParameters = { + include: ['price'], + }; + const simulationRun = await simulationRunsResource.get(simulationId, simulationRunId, queryParams); + + expect(simulationRun).toBeDefined(); + expect(paddleInstance.get).toBeCalledWith( + `/simulations/${simulationId}/runs/${simulationRunId}`, + new QueryParameters(queryParams), + ); + expect(simulationRun.id).toBe(simulationRunId); + }); + + test('should create a new simulationRun', async () => { + const paddleInstance = getPaddleTestClient(); + + paddleInstance.post = jest.fn().mockResolvedValue(SimulationRunMockResponse); + const simulationRunsResource = new SimulationRunsResource(paddleInstance); + const createdSimulationRun = await simulationRunsResource.create(simulationId); + + expect(createdSimulationRun).toBeDefined(); + expect(createdSimulationRun.id).toBeDefined(); + }); +}); diff --git a/src/__tests__/resources/simulation-types.test.ts b/src/__tests__/resources/simulation-types.test.ts new file mode 100644 index 0000000..ccedf62 --- /dev/null +++ b/src/__tests__/resources/simulation-types.test.ts @@ -0,0 +1,22 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { getPaddleTestClient } from '../helpers/test-client.js'; +import { SimulationTypesResource } from '../../resources/index.js'; +import { ListSimulationTypeMockResponse } from '../mocks/resources/simulation-types.mock.js'; + +describe('simulationTypesResource', () => { + test('should return a list of simulations', async () => { + const paddleInstance = getPaddleTestClient(); + paddleInstance.get = jest.fn().mockResolvedValue(ListSimulationTypeMockResponse); + + const simulationsResource = new SimulationTypesResource(paddleInstance); + const simulationTypes = await simulationsResource.list(); + + expect(paddleInstance.get).toBeCalledWith('/simulation-types'); + expect(simulationTypes.length).toBe(47); + }); +}); diff --git a/src/__tests__/resources/simulations.test.ts b/src/__tests__/resources/simulations.test.ts new file mode 100644 index 0000000..73899c2 --- /dev/null +++ b/src/__tests__/resources/simulations.test.ts @@ -0,0 +1,109 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { + CreateSimulationRequestBody, + UpdateSimulationRequestBody, + SimulationsResource, + ListSimulationQueryParameters, +} from '../../resources/index.js'; +import { getPaddleTestClient } from '../helpers/test-client.js'; +import { + SimulationMockResponse, + SimulationMock, + CreateSimulationMock, + updateSimulationMock, + ListSimulationMockResponse, +} from '../mocks/resources/simulations.mock.js'; + +describe('SimulationsResource', () => { + test('should return a list of simulations', async () => { + const paddleInstance = getPaddleTestClient(); + paddleInstance.get = jest.fn().mockResolvedValue(ListSimulationMockResponse); + + const simulationsResource = new SimulationsResource(paddleInstance); + const simulationCollection = simulationsResource.list(); + + let simulations = await simulationCollection.next(); + expect(paddleInstance.get).toBeCalledWith('/simulations?'); + expect(simulations.length).toBe(1); + + simulations = await simulationCollection.next(); + expect(paddleInstance.get).toBeCalledWith('/simulations?after=1'); + expect(simulations.length).toBe(1); + }); + + test('should accept query params and return a list of simulations', async () => { + const paddleInstance = getPaddleTestClient(); + paddleInstance.get = jest.fn().mockResolvedValue(ListSimulationMockResponse); + const simulationsResource = new SimulationsResource(paddleInstance); + const queryParams: ListSimulationQueryParameters = { + after: '2', + id: ['1234'], + }; + + const simulationCollection = simulationsResource.list(queryParams); + let simulations = await simulationCollection.next(); + + expect(paddleInstance.get).toBeCalledWith('/simulations?after=2&id=1234'); + expect(simulations.length).toBe(1); + }); + + test('should return a single simulation by ID', async () => { + const simulationId = SimulationMock.id; + const paddleInstance = getPaddleTestClient(); + paddleInstance.get = jest.fn().mockResolvedValue(SimulationMockResponse); + + const simulationsResource = new SimulationsResource(paddleInstance); + const simulation = await simulationsResource.get(simulationId); + + expect(paddleInstance.get).toBeCalledWith(`/simulations/${simulationId}`); + expect(simulation).toBeDefined(); + expect(simulation.id).toBe(simulationId); + }); + + test('should accepts query params and return a single simulation by ID', async () => { + const simulationId = SimulationMock.id; + const paddleInstance = getPaddleTestClient(); + + paddleInstance.get = jest.fn().mockResolvedValue(SimulationMockResponse); + const simulationsResource = new SimulationsResource(paddleInstance); + + const simulation = await simulationsResource.get(simulationId); + + expect(simulation).toBeDefined(); + expect(paddleInstance.get).toBeCalledWith(`/simulations/${simulationId}`); + expect(simulation.id).toBe(simulationId); + }); + + test('should create a new simulation', async () => { + const newSimulation: CreateSimulationRequestBody = CreateSimulationMock; + const paddleInstance = getPaddleTestClient(); + + paddleInstance.post = jest.fn().mockResolvedValue(SimulationMockResponse); + const simulationsResource = new SimulationsResource(paddleInstance); + const createdSimulation = await simulationsResource.create(newSimulation); + + expect(paddleInstance.post).toBeCalledWith(`/simulations`, newSimulation); + expect(createdSimulation).toBeDefined(); + expect(createdSimulation.id).toBeDefined(); + expect(createdSimulation.name).toBe(newSimulation.name); + }); + + test('should update an existing simulation', async () => { + const simulationId = SimulationMock.id; + const simulationToBeUpdated: UpdateSimulationRequestBody = updateSimulationMock; + + const paddleInstance = getPaddleTestClient(); + paddleInstance.patch = jest.fn().mockResolvedValue(SimulationMockResponse); + + const simulationsResource = new SimulationsResource(paddleInstance); + const updatedSimulation = await simulationsResource.update(simulationId, simulationToBeUpdated); + + expect(paddleInstance.patch).toBeCalledWith(`/simulations/${simulationId}`, simulationToBeUpdated); + expect(updatedSimulation).toBeDefined(); + }); +}); diff --git a/src/entities/index.ts b/src/entities/index.ts index f2d3c3f..1acaaab 100644 --- a/src/entities/index.ts +++ b/src/entities/index.ts @@ -20,5 +20,9 @@ export * from './event-types/index.js'; export * from './notification-settings/index.js'; export * from './notifications/index.js'; export * from './report/index.js'; +export * from './simulation-types/index.js'; +export * from './simulation/index.js'; +export * from './simulation-run/index.js'; +export * from './simulation-run-event/index.js'; export type CustomData = object; diff --git a/src/entities/shared/index.ts b/src/entities/shared/index.ts index 30542ce..8a47512 100644 --- a/src/entities/shared/index.ts +++ b/src/entities/shared/index.ts @@ -24,3 +24,5 @@ export * from './transaction-checkout.js'; export * from './total-adjustments.js'; export * from './payout-totals-adjustment.js'; export * from './import-meta.js'; +export * from './simulation-event-request.js'; +export * from './simulation-event-response.js'; diff --git a/src/entities/shared/simulation-event-request.ts b/src/entities/shared/simulation-event-request.ts new file mode 100644 index 0000000..1e19e9f --- /dev/null +++ b/src/entities/shared/simulation-event-request.ts @@ -0,0 +1,15 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { type ISimulationEventRequest } from '../../types/index.js'; + +export class SimulationEventRequest { + public readonly body: string; + + constructor(simulationEventRequestResponse: ISimulationEventRequest) { + this.body = simulationEventRequestResponse.body; + } +} diff --git a/src/entities/shared/simulation-event-response.ts b/src/entities/shared/simulation-event-response.ts new file mode 100644 index 0000000..fd433e5 --- /dev/null +++ b/src/entities/shared/simulation-event-response.ts @@ -0,0 +1,17 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { type ISimulationEventResponse } from '../../types/index.js'; + +export class SimulationEventResponse { + public readonly body: string; + public readonly statusCode: number; + + constructor(simulationEventResponse: ISimulationEventResponse) { + this.body = simulationEventResponse.body; + this.statusCode = simulationEventResponse.status_code; + } +} diff --git a/src/entities/simulation-run-event/index.ts b/src/entities/simulation-run-event/index.ts new file mode 100644 index 0000000..520faad --- /dev/null +++ b/src/entities/simulation-run-event/index.ts @@ -0,0 +1,8 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './simulation-run-event.js'; +export * from './simulation-run-event-collection.js'; diff --git a/src/entities/simulation-run-event/simulation-run-event-collection.ts b/src/entities/simulation-run-event/simulation-run-event-collection.ts new file mode 100644 index 0000000..e1cad49 --- /dev/null +++ b/src/entities/simulation-run-event/simulation-run-event-collection.ts @@ -0,0 +1,15 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { SimulationRunEvent } from '../../entities/index.js'; +import { type ISimulationRunEventResponse } from '../../types/index.js'; +import { Collection } from '../../internal/base/index.js'; + +export class SimulationRunEventCollection extends Collection { + override fromJson(data: ISimulationRunEventResponse): SimulationRunEvent { + return new SimulationRunEvent(data); + } +} diff --git a/src/entities/simulation-run-event/simulation-run-event.ts b/src/entities/simulation-run-event/simulation-run-event.ts new file mode 100644 index 0000000..7dd119f --- /dev/null +++ b/src/entities/simulation-run-event/simulation-run-event.ts @@ -0,0 +1,36 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import type { SimulationRunEventStatus, SimulationScenarioType } from '../../enums/index.js'; +import type { IEventName } from '../../notifications/index.js'; +import { type ISimulationRunEventResponse } from '../../types/index.js'; +import { SimulationEventRequest, SimulationEventResponse } from '../shared/index.js'; + +export class SimulationRunEvent { + public readonly id: string; + public readonly status: SimulationRunEventStatus; + public readonly eventType: IEventName | SimulationScenarioType; + public readonly payload: any; + public readonly request: SimulationEventRequest | null; + public readonly response: SimulationEventResponse | null; + public readonly createdAt: string; + public readonly updatedAt: string; + + constructor(simulationRunEventResponse: ISimulationRunEventResponse) { + this.id = simulationRunEventResponse.id; + this.status = simulationRunEventResponse.status; + this.eventType = simulationRunEventResponse.event_type; + this.payload = simulationRunEventResponse.payload; + this.request = simulationRunEventResponse.request + ? new SimulationEventRequest(simulationRunEventResponse.request) + : null; + this.response = simulationRunEventResponse.response + ? new SimulationEventResponse(simulationRunEventResponse.response) + : null; + this.createdAt = simulationRunEventResponse.created_at; + this.updatedAt = simulationRunEventResponse.updated_at; + } +} diff --git a/src/entities/simulation-run/index.ts b/src/entities/simulation-run/index.ts new file mode 100644 index 0000000..c4e5fbd --- /dev/null +++ b/src/entities/simulation-run/index.ts @@ -0,0 +1,8 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './simulation-run.js'; +export * from './simulation-run-collection.js'; diff --git a/src/entities/simulation-run/simulation-run-collection.ts b/src/entities/simulation-run/simulation-run-collection.ts new file mode 100644 index 0000000..2aff44b --- /dev/null +++ b/src/entities/simulation-run/simulation-run-collection.ts @@ -0,0 +1,15 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { SimulationRun } from '../../entities/index.js'; +import { type ISimulationRunResponse } from '../../types/index.js'; +import { Collection } from '../../internal/base/index.js'; + +export class SimulationRunCollection extends Collection { + override fromJson(data: ISimulationRunResponse): SimulationRun { + return new SimulationRun(data); + } +} diff --git a/src/entities/simulation-run/simulation-run.ts b/src/entities/simulation-run/simulation-run.ts new file mode 100644 index 0000000..b11a181 --- /dev/null +++ b/src/entities/simulation-run/simulation-run.ts @@ -0,0 +1,28 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import type { SimulationRunStatus, SimulationScenarioType } from '../../enums/index.js'; +import type { IEventName } from '../../notifications/index.js'; +import type { ISimulationRunResponse } from '../../types/index.js'; +import { SimulationRunEvent } from '../index.js'; + +export class SimulationRun { + public readonly id: string; + public readonly status: SimulationRunStatus; + public readonly createdAt: string; + public readonly updatedAt: string; + public readonly type: IEventName | SimulationScenarioType; + public readonly events: SimulationRunEvent[] | null; + + constructor(simulationRunResponse: ISimulationRunResponse) { + this.id = simulationRunResponse.id; + this.status = simulationRunResponse.status; + this.createdAt = simulationRunResponse.created_at; + this.updatedAt = simulationRunResponse.updated_at; + this.type = simulationRunResponse.type; + this.events = simulationRunResponse.events?.map((event) => new SimulationRunEvent(event)) ?? []; + } +} diff --git a/src/entities/simulation-types/index.ts b/src/entities/simulation-types/index.ts new file mode 100644 index 0000000..cd112aa --- /dev/null +++ b/src/entities/simulation-types/index.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './simulation-type.js'; diff --git a/src/entities/simulation-types/simulation-type.ts b/src/entities/simulation-types/simulation-type.ts new file mode 100644 index 0000000..c7e9e0c --- /dev/null +++ b/src/entities/simulation-types/simulation-type.ts @@ -0,0 +1,27 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { type SimulationKind } from '../../enums/index.js'; +import { type IEventName } from '../../notifications/index.js'; +import { type ISimulationTypeResponse } from '../../types/index.js'; + +export class SimulationType { + public readonly name: string; + public readonly label: string; + public readonly description: string; + public readonly group: string; + public readonly type: SimulationKind; + public readonly events: IEventName[]; + + constructor(simulationTypeResponse: ISimulationTypeResponse) { + this.name = simulationTypeResponse.name; + this.label = simulationTypeResponse.label; + this.description = simulationTypeResponse.description; + this.group = simulationTypeResponse.group; + this.type = simulationTypeResponse.type; + this.events = simulationTypeResponse.events; + } +} diff --git a/src/entities/simulation/index.ts b/src/entities/simulation/index.ts new file mode 100644 index 0000000..aad63a6 --- /dev/null +++ b/src/entities/simulation/index.ts @@ -0,0 +1,8 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './simulation.js'; +export * from './simulation-collection.js'; diff --git a/src/entities/simulation/simulation-collection.ts b/src/entities/simulation/simulation-collection.ts new file mode 100644 index 0000000..3882d2a --- /dev/null +++ b/src/entities/simulation/simulation-collection.ts @@ -0,0 +1,15 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { Simulation } from '../../entities/index.js'; +import { type ISimulationResponse } from '../../types/index.js'; +import { Collection } from '../../internal/base/index.js'; + +export class SimulationCollection extends Collection { + override fromJson(data: ISimulationResponse): Simulation { + return new Simulation(data); + } +} diff --git a/src/entities/simulation/simulation.ts b/src/entities/simulation/simulation.ts new file mode 100644 index 0000000..d49b2ce --- /dev/null +++ b/src/entities/simulation/simulation.ts @@ -0,0 +1,33 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { type ISimulationResponse } from '../../types/index.js'; +import type { SimulationScenarioType, Status } from '../../enums/index.js'; +import type { IEventName } from '../../notifications/index.js'; + +export class Simulation { + public readonly id: string; + public readonly status: Status; + public readonly notificationSettingId: string; + public readonly name: string; + public readonly type: IEventName | SimulationScenarioType; + public readonly payload: any; + public readonly lastRunAt: string | null; + public readonly createdAt: string; + public readonly updatedAt: string; + + constructor(simulationResponse: ISimulationResponse) { + this.id = simulationResponse.id; + this.status = simulationResponse.status; + this.notificationSettingId = simulationResponse.notification_setting_id; + this.name = simulationResponse.name; + this.type = simulationResponse.type; + this.payload = simulationResponse.payload ?? null; + this.lastRunAt = simulationResponse.last_run_at ?? null; + this.createdAt = simulationResponse.created_at; + this.updatedAt = simulationResponse.updated_at; + } +} diff --git a/src/enums/index.ts b/src/enums/index.ts index ca2c132..0dbfcaf 100644 --- a/src/enums/index.ts +++ b/src/enums/index.ts @@ -13,3 +13,7 @@ export * from './payout/index.js'; export * from './notification-settings/index.js'; export * from './notification/index.js'; export * from './report/index.js'; +export * from './simulation-type/index.js'; +export * from './simulation/index.js'; +export * from './simulation-run/index.js'; +export * from './simulation-run-event/index.js'; diff --git a/src/enums/simulation-run-event/index.ts b/src/enums/simulation-run-event/index.ts new file mode 100644 index 0000000..f16a445 --- /dev/null +++ b/src/enums/simulation-run-event/index.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './simulation-run-event-status.js'; diff --git a/src/enums/simulation-run-event/simulation-run-event-status.ts b/src/enums/simulation-run-event/simulation-run-event-status.ts new file mode 100644 index 0000000..3bebc36 --- /dev/null +++ b/src/enums/simulation-run-event/simulation-run-event-status.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export type SimulationRunEventStatus = 'pending' | 'success' | 'failed' | 'aborted'; diff --git a/src/enums/simulation-run/index.ts b/src/enums/simulation-run/index.ts new file mode 100644 index 0000000..cb0caa0 --- /dev/null +++ b/src/enums/simulation-run/index.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './simulation-run-status.js'; diff --git a/src/enums/simulation-run/simulation-run-status.ts b/src/enums/simulation-run/simulation-run-status.ts new file mode 100644 index 0000000..16497fc --- /dev/null +++ b/src/enums/simulation-run/simulation-run-status.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export type SimulationRunStatus = 'pending' | 'completed' | 'canceled'; diff --git a/src/enums/simulation-type/index.ts b/src/enums/simulation-type/index.ts new file mode 100644 index 0000000..14425ee --- /dev/null +++ b/src/enums/simulation-type/index.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './simulation-kind.js'; diff --git a/src/enums/simulation-type/simulation-kind.ts b/src/enums/simulation-type/simulation-kind.ts new file mode 100644 index 0000000..f63a822 --- /dev/null +++ b/src/enums/simulation-type/simulation-kind.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export type SimulationKind = 'single_event' | 'scenario'; diff --git a/src/enums/simulation/index.ts b/src/enums/simulation/index.ts new file mode 100644 index 0000000..93d84eb --- /dev/null +++ b/src/enums/simulation/index.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './simulation-scenario-type.js'; diff --git a/src/enums/simulation/simulation-scenario-type.ts b/src/enums/simulation/simulation-scenario-type.ts new file mode 100644 index 0000000..f99c37b --- /dev/null +++ b/src/enums/simulation/simulation-scenario-type.ts @@ -0,0 +1,12 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export type SimulationScenarioType = + | 'subscription_creation' + | 'subscription_renewal' + | 'subscription_pause' + | 'subscription_resume' + | 'subscription_cancellation'; diff --git a/src/notifications/helpers/types.ts b/src/notifications/helpers/types.ts index 60a7463..4ff7c8f 100644 --- a/src/notifications/helpers/types.ts +++ b/src/notifications/helpers/types.ts @@ -141,10 +141,12 @@ export type IEventName = | 'business.updated' | 'business.imported' | 'customer.created' + | 'customer.imported' | 'customer.updated' | 'discount.created' | 'discount.updated' | 'discount.imported' + | 'payout.created' | 'payout.updated' | 'payout.paid' | 'price.updated' diff --git a/src/paddle.ts b/src/paddle.ts index 61eef14..8d4bc54 100644 --- a/src/paddle.ts +++ b/src/paddle.ts @@ -13,6 +13,10 @@ import { PricingPreviewResource, ProductsResource, ReportsResource, + SimulationTypesResource, + SimulationsResource, + SimulationRunsResource, + SimulationRunEventsResource, SubscriptionsResource, TransactionsResource, } from './resources/index.js'; @@ -42,6 +46,10 @@ export class Paddle { public notificationSettings: NotificationSettingsResource; public notifications: NotificationsResource; public reports: ReportsResource; + public simulationTypes: SimulationTypesResource; + public simulations: SimulationsResource; + public simulationRuns: SimulationRunsResource; + public simulationRunEvents: SimulationRunEventsResource; constructor(apiKey: string, options?: PaddleOptions) { this.client = new Client( @@ -65,5 +73,9 @@ export class Paddle { this.notificationSettings = new NotificationSettingsResource(this.client); this.notifications = new NotificationsResource(this.client); this.reports = new ReportsResource(this.client); + this.simulationTypes = new SimulationTypesResource(this.client); + this.simulations = new SimulationsResource(this.client); + this.simulationRuns = new SimulationRunsResource(this.client); + this.simulationRunEvents = new SimulationRunEventsResource(this.client); } } diff --git a/src/resources/index.ts b/src/resources/index.ts index 4fb5285..436d3a2 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -18,3 +18,7 @@ export * from './event-types/index.js'; export * from './notification-settings/index.js'; export * from './notifications/index.js'; export * from './reports/index.js'; +export * from './simulation-types/index.js'; +export * from './simulations/index.js'; +export * from './simulation-runs/index.js'; +export * from './simulation-run-events/index.js'; diff --git a/src/resources/simulation-run-events/index.ts b/src/resources/simulation-run-events/index.ts new file mode 100644 index 0000000..9b8f3d0 --- /dev/null +++ b/src/resources/simulation-run-events/index.ts @@ -0,0 +1,76 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { SimulationRunEvent, SimulationRunEventCollection } from '../../entities/index.js'; +import { type ISimulationRunEventResponse } from '../../types/index.js'; +import { type ErrorResponse, type Response } from '../../internal/index.js'; +import { BaseResource, PathParameters, QueryParameters } from '../../internal/base/index.js'; +import type { ListSimulationRunEventsQueryParameters } from './operations/index.js'; + +export * from './operations/index.js'; + +const SimulationRunEventPaths = { + list: '/simulations/{simulation_id}/runs/{simulation_run_id}/events', + get: '/simulations/{simulation_id}/runs/{simulation_run_id}/events/{simulation_event_id}', + replay: '/simulations/{simulation_id}/runs/{simulation_run_id}/events/{simulation_event_id}/replay', +} as const; + +export class SimulationRunEventsResource extends BaseResource { + public list( + simulationId: string, + simulationRunId: string, + queryParams?: ListSimulationRunEventsQueryParameters, + ): SimulationRunEventCollection { + const queryParameters = new QueryParameters(queryParams); + const urlWithPathParams = new PathParameters(SimulationRunEventPaths.list, { + simulation_id: simulationId, + simulation_run_id: simulationRunId, + }).deriveUrl(); + + return new SimulationRunEventCollection(this.client, urlWithPathParams + queryParameters.toQueryString()); + } + + public async get( + simulationId: string, + simulationRunId: string, + simulationEventId: string, + ): Promise { + const urlWithPathParams = new PathParameters(SimulationRunEventPaths.get, { + simulation_id: simulationId, + simulation_run_id: simulationRunId, + simulation_event_id: simulationEventId, + }).deriveUrl(); + + const response = await this.client.get | ErrorResponse>( + urlWithPathParams, + ); + + const data = this.handleResponse(response); + + return new SimulationRunEvent(data); + } + + public async replay( + simulationId: string, + simulationRunId: string, + simulationEventId: string, + ): Promise { + const urlWithPathParams = new PathParameters(SimulationRunEventPaths.replay, { + simulation_id: simulationId, + simulation_run_id: simulationRunId, + simulation_event_id: simulationEventId, + }).deriveUrl(); + + const response = await this.client.post | ErrorResponse>( + urlWithPathParams, + undefined, + ); + + const data = this.handleResponse(response); + + return new SimulationRunEvent(data); + } +} diff --git a/src/resources/simulation-run-events/operations/index.ts b/src/resources/simulation-run-events/operations/index.ts new file mode 100644 index 0000000..a2fde23 --- /dev/null +++ b/src/resources/simulation-run-events/operations/index.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './list-simulation-run-events-query-parameters.js'; diff --git a/src/resources/simulation-run-events/operations/list-simulation-run-events-query-parameters.ts b/src/resources/simulation-run-events/operations/list-simulation-run-events-query-parameters.ts new file mode 100644 index 0000000..5b75365 --- /dev/null +++ b/src/resources/simulation-run-events/operations/list-simulation-run-events-query-parameters.ts @@ -0,0 +1,12 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export interface ListSimulationRunEventsQueryParameters { + after?: string; + orderBy?: string; + perPage?: number; + id?: string[]; +} diff --git a/src/resources/simulation-runs/index.ts b/src/resources/simulation-runs/index.ts new file mode 100644 index 0000000..90cba87 --- /dev/null +++ b/src/resources/simulation-runs/index.ts @@ -0,0 +1,67 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { SimulationRun, SimulationRunCollection } from '../../entities/index.js'; +import { type ErrorResponse, type Response } from '../../internal/index.js'; +import { BaseResource, PathParameters, QueryParameters } from '../../internal/base/index.js'; +import type { ISimulationRunResponse } from '../../types/index.js'; +import { type GetSimulationRunQueryParameters, type ListSimulationRunQueryParameters } from './operations/index.js'; + +export * from './operations/index.js'; + +const SimulationRunPaths = { + list: '/simulations/{simulation_id}/runs', + create: '/simulations/{simulation_id}/runs', + get: '/simulations/{simulation_id}/runs/{simulation_run_id}', +} as const; + +export class SimulationRunsResource extends BaseResource { + public list(simulationId: string, queryParams?: ListSimulationRunQueryParameters): SimulationRunCollection { + const queryParameters = new QueryParameters(queryParams); + const urlWithPathParams = new PathParameters(SimulationRunPaths.list, { + simulation_id: simulationId, + }).deriveUrl(); + + return new SimulationRunCollection(this.client, urlWithPathParams + queryParameters.toQueryString()); + } + + public async create(simulationId: string): Promise { + const urlWithPathParams = new PathParameters(SimulationRunPaths.create, { + simulation_id: simulationId, + }).deriveUrl(); + + const response = await this.client.post | ErrorResponse>( + urlWithPathParams, + undefined, + ); + + const data = this.handleResponse(response); + + return new SimulationRun(data); + } + + public async get( + simulationId: string, + simulationRunId: string, + queryParams?: GetSimulationRunQueryParameters, + ): Promise { + const queryParameters = new QueryParameters(queryParams); + + const urlWithPathParams = new PathParameters(SimulationRunPaths.get, { + simulation_id: simulationId, + simulation_run_id: simulationRunId, + }).deriveUrl(); + + const response = await this.client.get< + GetSimulationRunQueryParameters | undefined, + Response | ErrorResponse + >(urlWithPathParams, queryParameters); + + const data = this.handleResponse(response); + + return new SimulationRun(data); + } +} diff --git a/src/resources/simulation-runs/operations/get-simulation-run-query-parameters.ts b/src/resources/simulation-runs/operations/get-simulation-run-query-parameters.ts new file mode 100644 index 0000000..532c803 --- /dev/null +++ b/src/resources/simulation-runs/operations/get-simulation-run-query-parameters.ts @@ -0,0 +1,9 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export interface GetSimulationRunQueryParameters { + include: any[]; +} diff --git a/src/resources/simulation-runs/operations/index.ts b/src/resources/simulation-runs/operations/index.ts new file mode 100644 index 0000000..abca48a --- /dev/null +++ b/src/resources/simulation-runs/operations/index.ts @@ -0,0 +1,8 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './get-simulation-run-query-parameters.js'; +export * from './list-simulation-run-query-parameters.js'; diff --git a/src/resources/simulation-runs/operations/list-simulation-run-query-parameters.ts b/src/resources/simulation-runs/operations/list-simulation-run-query-parameters.ts new file mode 100644 index 0000000..6f59c54 --- /dev/null +++ b/src/resources/simulation-runs/operations/list-simulation-run-query-parameters.ts @@ -0,0 +1,13 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export interface ListSimulationRunQueryParameters { + after?: string; + include?: any[]; + orderBy?: string; + perPage?: number; + id?: string[]; +} diff --git a/src/resources/simulation-types/index.ts b/src/resources/simulation-types/index.ts new file mode 100644 index 0000000..0934838 --- /dev/null +++ b/src/resources/simulation-types/index.ts @@ -0,0 +1,26 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { BaseResource } from '../../internal/base/index.js'; +import { type ErrorResponse, type Response } from '../../internal/index.js'; +import { type ISimulationTypeResponse } from '../../types/index.js'; +import { SimulationType } from '../../entities/index.js'; + +const SimulationTypesPaths = { + list: '/simulation-types', +} as const; + +export class SimulationTypesResource extends BaseResource { + public async list(): Promise { + const response = await this.client.get | ErrorResponse>( + SimulationTypesPaths.list, + ); + + const data = this.handleResponse(response); + + return data.map((simulationType) => new SimulationType(simulationType)); + } +} diff --git a/src/resources/simulations/index.ts b/src/resources/simulations/index.ts new file mode 100644 index 0000000..2297e5b --- /dev/null +++ b/src/resources/simulations/index.ts @@ -0,0 +1,69 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { Simulation, SimulationCollection } from '../../entities/index.js'; +import { type ErrorResponse, type Response } from '../../internal/index.js'; +import { BaseResource, PathParameters, QueryParameters } from '../../internal/base/index.js'; +import { type ISimulationResponse } from '../../types/index.js'; +import { + type CreateSimulationRequestBody, + type ListSimulationQueryParameters, + type UpdateSimulationRequestBody, +} from './operations/index.js'; + +export * from './operations/index.js'; + +const SimulationPaths = { + list: '/simulations', + create: '/simulations', + get: '/simulations/{simulation_id}', + update: '/simulations/{simulation_id}', +} as const; + +export class SimulationsResource extends BaseResource { + public list(queryParams?: ListSimulationQueryParameters): SimulationCollection { + const queryParameters = new QueryParameters(queryParams); + return new SimulationCollection(this.client, SimulationPaths.list + queryParameters.toQueryString()); + } + + public async create(createSimulationParameters: CreateSimulationRequestBody): Promise { + const response = await this.client.post | ErrorResponse>( + SimulationPaths.create, + createSimulationParameters, + ); + + const data = this.handleResponse(response); + + return new Simulation(data); + } + + public async get(simulationId: string): Promise { + const urlWithPathParams = new PathParameters(SimulationPaths.get, { + simulation_id: simulationId, + }).deriveUrl(); + + const response = await this.client.get | ErrorResponse>(urlWithPathParams); + + const data = this.handleResponse(response); + + return new Simulation(data); + } + + public async update(simulationId: string, updateSimulation: UpdateSimulationRequestBody): Promise { + const urlWithPathParams = new PathParameters(SimulationPaths.update, { + simulation_id: simulationId, + }).deriveUrl(); + + const response = await this.client.patch< + UpdateSimulationRequestBody, + Response | ErrorResponse + >(urlWithPathParams, updateSimulation); + + const data = this.handleResponse(response); + + return new Simulation(data); + } +} diff --git a/src/resources/simulations/operations/create-simulation-request-body.ts b/src/resources/simulations/operations/create-simulation-request-body.ts new file mode 100644 index 0000000..3d8736f --- /dev/null +++ b/src/resources/simulations/operations/create-simulation-request-body.ts @@ -0,0 +1,16 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import type { SimulationScenarioType } from '../../../enums/index.js'; +import type { IEventName } from '../../../notifications/index.js'; +import type { DiscriminatedSimulationEventResponse } from '../../../types/index.js'; +interface BaseCreateSimulationRequestBody { + notificationSettingId: string; + name: string; + type: IEventName | SimulationScenarioType; +} + +export type CreateSimulationRequestBody = DiscriminatedSimulationEventResponse; diff --git a/src/resources/simulations/operations/index.ts b/src/resources/simulations/operations/index.ts new file mode 100644 index 0000000..2097e85 --- /dev/null +++ b/src/resources/simulations/operations/index.ts @@ -0,0 +1,9 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './create-simulation-request-body.js'; +export * from './list-simulation-query-parameters.js'; +export * from './update-simulation-request-body.js'; diff --git a/src/resources/simulations/operations/list-simulation-query-parameters.ts b/src/resources/simulations/operations/list-simulation-query-parameters.ts new file mode 100644 index 0000000..fd055d3 --- /dev/null +++ b/src/resources/simulations/operations/list-simulation-query-parameters.ts @@ -0,0 +1,16 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { type Status } from '../../../enums/index.js'; + +export interface ListSimulationQueryParameters { + after?: string; + notificationSettingId?: string[]; + orderBy?: string; + perPage?: number; + id?: string[]; + status?: Status[]; +} diff --git a/src/resources/simulations/operations/update-simulation-request-body.ts b/src/resources/simulations/operations/update-simulation-request-body.ts new file mode 100644 index 0000000..c7dae48 --- /dev/null +++ b/src/resources/simulations/operations/update-simulation-request-body.ts @@ -0,0 +1,15 @@ +import type { DiscriminatedSimulationEventResponse } from '../../../types/index.js'; +import type { Status } from '../../../enums/index.js'; + +interface BaseUpdateSimulationRequestBody { + notificationSettingId?: string; + name?: string; + status?: Status; +} + +type RawUpdateSimulationRequestBody = DiscriminatedSimulationEventResponse; + +// Map all properties to be optional +export type UpdateSimulationRequestBody = { + [Key in keyof RawUpdateSimulationRequestBody]?: RawUpdateSimulationRequestBody[Key]; +}; diff --git a/src/types/index.ts b/src/types/index.ts index e6eed0e..f1583a6 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -21,3 +21,7 @@ export * from './event-types/index.js'; export * from './notification-settings/index.js'; export * from './notifications/index.js'; export * from './report/index.js'; +export * from './simulation-type/index.js'; +export * from './simulation/index.js'; +export * from './simulation-run/index.js'; +export * from './simulation-run-event/index.js'; diff --git a/src/types/shared/index.ts b/src/types/shared/index.ts index 63472eb..e232edf 100644 --- a/src/types/shared/index.ts +++ b/src/types/shared/index.ts @@ -33,3 +33,6 @@ export * from './billing-details-create.js'; export * from './billing-details-update.js'; export * from './custom-data.js'; export * from './import-meta-response.js'; +export * from './simulation-event-request.js'; +export * from './simulation-event-response.js'; +export * from './simulation-payload.js'; diff --git a/src/types/shared/simulation-event-request.ts b/src/types/shared/simulation-event-request.ts new file mode 100644 index 0000000..8c604fc --- /dev/null +++ b/src/types/shared/simulation-event-request.ts @@ -0,0 +1,9 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export interface ISimulationEventRequest { + body: string; +} diff --git a/src/types/shared/simulation-event-response.ts b/src/types/shared/simulation-event-response.ts new file mode 100644 index 0000000..5807b2b --- /dev/null +++ b/src/types/shared/simulation-event-response.ts @@ -0,0 +1,10 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export interface ISimulationEventResponse { + body: string; + status_code: number; +} diff --git a/src/types/shared/simulation-payload.ts b/src/types/shared/simulation-payload.ts new file mode 100644 index 0000000..19ac8d9 --- /dev/null +++ b/src/types/shared/simulation-payload.ts @@ -0,0 +1,102 @@ +import type { IEventName } from '../../notifications/index.js'; +import { + type AddressCreatedEvent, + type AddressImportedEvent, + type AddressUpdatedEvent, + type AdjustmentCreatedEvent, + type AdjustmentUpdatedEvent, + type BusinessCreatedEvent, + type BusinessImportedEvent, + type BusinessUpdatedEvent, + type CustomerCreatedEvent, + type CustomerImportedEvent, + type CustomerUpdatedEvent, + type DiscountCreatedEvent, + type DiscountImportedEvent, + type DiscountUpdatedEvent, + type PayoutCreatedEvent, + type PayoutPaidEvent, + type PriceCreatedEvent, + type PriceImportedEvent, + type PriceUpdatedEvent, + type ProductCreatedEvent, + type ProductImportedEvent, + type ProductUpdatedEvent, + type ReportCreatedEvent, + type ReportUpdatedEvent, + type SubscriptionActivatedEvent, + type SubscriptionCanceledEvent, + type SubscriptionCreatedEvent, + type SubscriptionImportedEvent, + type SubscriptionPastDueEvent, + type SubscriptionPausedEvent, + type SubscriptionResumedEvent, + type SubscriptionTrialingEvent, + type SubscriptionUpdatedEvent, + type TransactionBilledEvent, + type TransactionCanceledEvent, + type TransactionCompletedEvent, + type TransactionCreatedEvent, + type TransactionPaidEvent, + type TransactionPastDueEvent, + type TransactionPaymentFailedEvent, + type TransactionReadyEvent, + type TransactionUpdatedEvent, +} from '../../notifications/events/index.js'; + +interface SimulationEventPayloadMap { + 'address.created': AddressCreatedEvent; + 'address.updated': AddressUpdatedEvent; + 'address.imported': AddressImportedEvent; + 'adjustment.created': AdjustmentCreatedEvent; + 'adjustment.updated': AdjustmentUpdatedEvent; + 'business.created': BusinessCreatedEvent; + 'business.updated': BusinessUpdatedEvent; + 'business.imported': BusinessImportedEvent; + 'customer.created': CustomerCreatedEvent; + 'customer.updated': CustomerUpdatedEvent; + 'customer.imported': CustomerImportedEvent; + 'discount.created': DiscountCreatedEvent; + 'discount.updated': DiscountUpdatedEvent; + 'discount.imported': DiscountImportedEvent; + 'payout.created': PayoutCreatedEvent; + 'payout.paid': PayoutPaidEvent; + 'price.created': PriceCreatedEvent; + 'price.updated': PriceUpdatedEvent; + 'price.imported': PriceImportedEvent; + 'product.created': ProductCreatedEvent; + 'product.updated': ProductUpdatedEvent; + 'product.imported': ProductImportedEvent; + 'subscription.created': SubscriptionCreatedEvent; + 'subscription.past_due': SubscriptionPastDueEvent; + 'subscription.activated': SubscriptionActivatedEvent; + 'subscription.canceled': SubscriptionCanceledEvent; + 'subscription.imported': SubscriptionImportedEvent; + 'subscription.paused': SubscriptionPausedEvent; + 'subscription.resumed': SubscriptionResumedEvent; + 'subscription.trialing': SubscriptionTrialingEvent; + 'subscription.updated': SubscriptionUpdatedEvent; + 'transaction.billed': TransactionBilledEvent; + 'transaction.canceled': TransactionCanceledEvent; + 'transaction.completed': TransactionCompletedEvent; + 'transaction.created': TransactionCreatedEvent; + 'transaction.paid': TransactionPaidEvent; + 'transaction.past_due': TransactionPastDueEvent; + 'transaction.payment_failed': TransactionPaymentFailedEvent; + 'transaction.ready': TransactionReadyEvent; + 'transaction.updated': TransactionUpdatedEvent; + 'report.created': ReportCreatedEvent; + 'report.updated': ReportUpdatedEvent; + subscription_creation: never; + subscription_renewal: never; + subscription_pause: never; + subscription_resume: never; + subscription_cancellation: never; +} + +export type DiscriminatedSimulationEventResponse = { + [K in keyof SimulationEventPayloadMap]: Base & { + type: K; + payload?: K extends IEventName ? Partial | null : null; + }; +}[keyof SimulationEventPayloadMap]; diff --git a/src/types/simulation-run-event/index.ts b/src/types/simulation-run-event/index.ts new file mode 100644 index 0000000..b92576c --- /dev/null +++ b/src/types/simulation-run-event/index.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './simulation-run-event-response.js'; diff --git a/src/types/simulation-run-event/simulation-run-event-response.ts b/src/types/simulation-run-event/simulation-run-event-response.ts new file mode 100644 index 0000000..f3a5614 --- /dev/null +++ b/src/types/simulation-run-event/simulation-run-event-response.ts @@ -0,0 +1,20 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import type { ISimulationEventRequest, ISimulationEventResponse } from '../shared/index.js'; +import type { SimulationRunEventStatus, SimulationScenarioType } from '../../enums/index.js'; +import type { IEventName } from '../../notifications/index.js'; + +export interface ISimulationRunEventResponse { + id: string; + status: SimulationRunEventStatus; + event_type: IEventName | SimulationScenarioType; + payload: any; + request?: ISimulationEventRequest | null; + response?: ISimulationEventResponse | null; + created_at: string; + updated_at: string; +} diff --git a/src/types/simulation-run/index.ts b/src/types/simulation-run/index.ts new file mode 100644 index 0000000..6a45a84 --- /dev/null +++ b/src/types/simulation-run/index.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './simulation-run-response.js'; diff --git a/src/types/simulation-run/simulation-run-event.ts b/src/types/simulation-run/simulation-run-event.ts new file mode 100644 index 0000000..af821a0 --- /dev/null +++ b/src/types/simulation-run/simulation-run-event.ts @@ -0,0 +1,24 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import type { Status, SimulationScenarioType } from '../../enums/index.js'; +import type { IEventName } from '../../notifications/index.js'; + +export interface ISimulationRunEvent { + id: string; + status: Status; + event_type: IEventName | SimulationScenarioType; + payload: any; + request?: { + body: string; + } | null; + response?: { + body: string; + status_code: number; + } | null; + created_at: string; + updated_at: string; +} diff --git a/src/types/simulation-run/simulation-run-response.ts b/src/types/simulation-run/simulation-run-response.ts new file mode 100644 index 0000000..501ea7e --- /dev/null +++ b/src/types/simulation-run/simulation-run-response.ts @@ -0,0 +1,18 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import type { SimulationRunStatus, SimulationScenarioType } from '../../enums/index.js'; +import type { IEventName } from '../../notifications/index.js'; +import type { ISimulationRunEventResponse } from '../index.js'; + +export interface ISimulationRunResponse { + id: string; + status: SimulationRunStatus; + created_at: string; + updated_at: string; + type: IEventName | SimulationScenarioType; + events?: ISimulationRunEventResponse[]; +} diff --git a/src/types/simulation-type/index.ts b/src/types/simulation-type/index.ts new file mode 100644 index 0000000..cd112aa --- /dev/null +++ b/src/types/simulation-type/index.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './simulation-type.js'; diff --git a/src/types/simulation-type/simulation-type.ts b/src/types/simulation-type/simulation-type.ts new file mode 100644 index 0000000..f4d2293 --- /dev/null +++ b/src/types/simulation-type/simulation-type.ts @@ -0,0 +1,17 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { type SimulationKind } from '../../enums/index.js'; +import { type IEventName } from '../../notifications/index.js'; + +export interface ISimulationTypeResponse { + name: string; + label: string; + description: string; + group: string; + type: SimulationKind; + events: IEventName[]; +} diff --git a/src/types/simulation/index.ts b/src/types/simulation/index.ts new file mode 100644 index 0000000..6f51982 --- /dev/null +++ b/src/types/simulation/index.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './simulation-response.js'; diff --git a/src/types/simulation/simulation-response.ts b/src/types/simulation/simulation-response.ts new file mode 100644 index 0000000..2b84a4a --- /dev/null +++ b/src/types/simulation/simulation-response.ts @@ -0,0 +1,14 @@ +import type { Status } from '../../enums/index.js'; +import type { DiscriminatedSimulationEventResponse } from '../shared/simulation-payload.js'; + +export type ISimulationResponse = DiscriminatedSimulationEventResponse; + +interface BaseSimulationResponse { + id: string; + status: Status; + notification_setting_id: string; + name: string; + last_run_at?: string | null; + created_at: string; + updated_at: string; +} diff --git a/src/types/subscription/subscription-update-item.ts b/src/types/subscription/subscription-update-item.ts index a48dd89..9a58fca 100644 --- a/src/types/subscription/subscription-update-item.ts +++ b/src/types/subscription/subscription-update-item.ts @@ -4,7 +4,7 @@ * Changes may be overwritten as part of auto-generation. */ -import { type ISubscriptionUpdateItemCreateWithPriceRequest } from './subscription-update-non-catalog-price-request'; +import { type ISubscriptionUpdateItemCreateWithPriceRequest } from './subscription-update-non-catalog-price-request.js'; interface ISubscriptionUpdateBaseItem { quantity: number;