diff --git a/javascript/src/api/application.ts b/javascript/src/api/application.ts index ac4fe24a3..548bc2041 100644 --- a/javascript/src/api/application.ts +++ b/javascript/src/api/application.ts @@ -1,9 +1,10 @@ +// this file is @generated (with the exception of getOrCreate) import { + Configuration, ApplicationApi, ApplicationIn, ApplicationOut, ApplicationPatch, - Configuration, ListResponseApplicationOut, Ordering, } from "../openapi"; @@ -25,18 +26,26 @@ export class Application { this.api = new ApplicationApi(config); } + /// List of all the organization's applications. public list(options?: ApplicationListOptions): Promise { - const iterator = options?.iterator ?? undefined; - return this.api.v1ApplicationList({ ...options, iterator }); + return this.api.v1ApplicationList({ + ...options, + iterator: options?.iterator ?? undefined, + }); } + /// Create a new application. public create( applicationIn: ApplicationIn, options?: PostOptions ): Promise { - return this.api.v1ApplicationCreate({ applicationIn, ...options }); + return this.api.v1ApplicationCreate({ + applicationIn, + ...options, + }); } + /// Get the application with the UID from `applicationIn`, or create it if it doesn't exist yet. public getOrCreate( applicationIn: ApplicationIn, options?: PostOptions @@ -48,22 +57,36 @@ export class Application { }); } + /// Get an application. public get(appId: string): Promise { - return this.api.v1ApplicationGet({ appId }); + return this.api.v1ApplicationGet({ + appId, + }); } + /// Update an application. public update(appId: string, applicationIn: ApplicationIn): Promise { - return this.api.v1ApplicationUpdate({ appId, applicationIn }); + return this.api.v1ApplicationUpdate({ + appId, + applicationIn, + }); + } + + /// Delete an application. + public delete(appId: string): Promise { + return this.api.v1ApplicationDelete({ + appId, + }); } + /// Partially update an application. public patch( appId: string, applicationPatch: ApplicationPatch ): Promise { - return this.api.v1ApplicationPatch({ appId, applicationPatch }); - } - - public delete(appId: string): Promise { - return this.api.v1ApplicationDelete({ appId }); + return this.api.v1ApplicationPatch({ + appId, + applicationPatch, + }); } } diff --git a/javascript/src/api/authentication.ts b/javascript/src/api/authentication.ts index 3335aa209..cedc04485 100644 --- a/javascript/src/api/authentication.ts +++ b/javascript/src/api/authentication.ts @@ -1,9 +1,11 @@ +// this file is @generated (with minor manual changes) import { Configuration, AuthenticationApi, - DashboardAccessOut, - AppPortalAccessOut, AppPortalAccessIn, + AppPortalAccessOut, + ApplicationTokenExpireIn, + DashboardAccessOut, } from "../openapi"; import { PostOptions } from "../util"; @@ -14,6 +16,7 @@ export class Authentication { this.api = new AuthenticationApi(config); } + /// Use this function to get magic links (and authentication codes) for connecting your users to the Consumer Application Portal. public appPortalAccess( appId: string, appPortalAccessIn: AppPortalAccessIn, @@ -36,7 +39,25 @@ export class Authentication { }); } + /// Expire all of the tokens associated with a specific Application + public expireAll( + appId: string, + applicationTokenExpireIn: ApplicationTokenExpireIn, + options?: PostOptions + ): Promise { + return this.api.v1AuthenticationExpireAll({ + appId, + applicationTokenExpireIn, + ...options, + }); + } + + /// Logout an app token. + /// + /// Trying to log out other tokens will fail. public logout(options?: PostOptions): Promise { - return this.api.v1AuthenticationLogout({ ...options }); + return this.api.v1AuthenticationLogout({ + ...options, + }); } } diff --git a/javascript/src/api/endpoint.ts b/javascript/src/api/endpoint.ts index fff07700a..74ef27c7c 100644 --- a/javascript/src/api/endpoint.ts +++ b/javascript/src/api/endpoint.ts @@ -1,25 +1,28 @@ +// this file is @generated (with manual changes) import { Configuration, EndpointApi, - ListResponseEndpointOut, - EndpointOut, + EndpointHeadersIn, + EndpointHeadersOut, + EndpointHeadersPatchIn, EndpointIn, - EndpointUpdate, + EndpointOauthConfigIn, + EndpointOut, + EndpointPatch, EndpointSecretOut, EndpointSecretRotateIn, + EndpointStats, EndpointTransformationIn, EndpointTransformationOut, - EndpointHeadersIn, - EndpointHeadersPatchIn, - EndpointHeadersOut, - EndpointStats, + EndpointUpdate, EventExampleIn, - RecoverIn, - ReplayIn, + ListResponseEndpointOut, MessageOut, Ordering, - EndpointPatch, - EndpointOauthConfigIn, + RecoverIn, + RecoverOut, + ReplayIn, + ReplayOut, } from "../openapi"; import { PostOptions } from "../util"; @@ -33,7 +36,9 @@ export interface EndpointListOptions { } export interface EndpointStatsOptions { + /// Filter the range to data starting from this date since?: Date | null; + /// Filter the range to data ending by this date until?: Date | null; } @@ -44,14 +49,21 @@ export class Endpoint { this.api = new EndpointApi(config); } + /// List the application's endpoints. public list( appId: string, options?: EndpointListOptions ): Promise { - const iterator = options?.iterator ?? undefined; - return this.api.v1EndpointList({ appId, ...options, iterator }); + return this.api.v1EndpointList({ + appId, + ...options, + iterator: options?.iterator ?? undefined, + }); } + /// Create a new endpoint for the application. + /// + /// When `secret` is `null` the secret is automatically generated (recommended) public create( appId: string, endpointIn: EndpointIn, @@ -64,10 +76,15 @@ export class Endpoint { }); } + /// Get an endpoint. public get(appId: string, endpointId: string): Promise { - return this.api.v1EndpointGet({ endpointId, appId }); + return this.api.v1EndpointGet({ + appId, + endpointId, + }); } + /// Update an endpoint. public update( appId: string, endpointId: string, @@ -80,78 +97,28 @@ export class Endpoint { }); } - public patch( - appId: string, - endpointId: string, - endpointPatch: EndpointPatch - ): Promise { - return this.api.v1EndpointPatch({ - appId, - endpointId, - endpointPatch, - }); - } - + /// Delete an endpoint. public delete(appId: string, endpointId: string): Promise { return this.api.v1EndpointDelete({ - endpointId, appId, - }); - } - - public getSecret(appId: string, endpointId: string): Promise { - return this.api.v1EndpointGetSecret({ endpointId, - appId, }); } - public rotateSecret( + /// Partially update an endpoint. + public patch( appId: string, endpointId: string, - endpointSecretRotateIn: EndpointSecretRotateIn, - options?: PostOptions - ): Promise { - return this.api.v1EndpointRotateSecret({ - endpointId, + endpointPatch: EndpointPatch + ): Promise { + return this.api.v1EndpointPatch({ appId, - endpointSecretRotateIn, - ...options, + endpointId, + endpointPatch, }); } - public recover( - appId: string, - endpointId: string, - recoverIn: RecoverIn, - options?: PostOptions - ): Promise { - return this.api - .v1EndpointRecover({ - appId, - endpointId, - recoverIn, - ...options, - }) - .then(() => Promise.resolve()); - } - - public replayMissing( - appId: string, - endpointId: string, - replayIn: ReplayIn, - options?: PostOptions - ): Promise { - return this.api - .v1EndpointReplayMissing({ - appId, - endpointId, - replayIn, - ...options, - }) - .then(() => Promise.resolve()); - } - + /// Get the additional headers to be sent with the webhook public getHeaders(appId: string, endpointId: string): Promise { return this.api.v1EndpointGetHeaders({ appId, @@ -213,39 +180,70 @@ export class Endpoint { }); } - public getStats( + /// Resend all failed messages since a given time. + /// + /// Messages that were sent successfully, even if failed initially, are not resent. + public recover( appId: string, endpointId: string, - options?: EndpointStatsOptions - ): Promise { - return this.api.v1EndpointGetStats({ + recoverIn: RecoverIn, + options?: PostOptions + ): Promise { + return this.api.v1EndpointRecover({ appId, endpointId, + recoverIn, ...options, - since: options?.since ?? undefined, - until: options?.until ?? undefined, }); } - public transformationGet( + /// Replays messages to the endpoint. + /// + /// Only messages that were created after `since` will be sent. + /// Messages that were previously sent to the endpoint are not resent. + public replayMissing( appId: string, - endpointId: string - ): Promise { - return this.api.v1EndpointTransformationGet({ endpointId, appId }); + endpointId: string, + replayIn: ReplayIn, + options?: PostOptions + ): Promise { + return this.api.v1EndpointReplayMissing({ + appId, + endpointId, + replayIn, + ...options, + }); } - public transformationPartialUpdate( + /// Get the endpoint's signing secret. + /// + /// This is used to verify the authenticity of the webhook. + /// For more information please refer to [the consuming webhooks docs](https://docs.svix.com/consuming-webhooks/). + public getSecret(appId: string, endpointId: string): Promise { + return this.api.v1EndpointGetSecret({ + appId, + endpointId, + }); + } + + /// Rotates the endpoint's signing secret. + /// + /// The previous secret will remain valid for the next 24 hours. + public rotateSecret( appId: string, endpointId: string, - endpointTransformationIn: EndpointTransformationIn + endpointSecretRotateIn: EndpointSecretRotateIn, + options?: PostOptions ): Promise { - return this.api.v1EndpointTransformationPartialUpdate({ + return this.api.v1EndpointRotateSecret({ appId, endpointId, - endpointTransformationIn, + endpointSecretRotateIn, + ...options, }); } + /// Send an example message for an event public sendExample( appId: string, endpointId: string, @@ -260,6 +258,45 @@ export class Endpoint { }); } + /// Get basic statistics for the endpoint. + public getStats( + appId: string, + endpointId: string, + options?: EndpointStatsOptions + ): Promise { + return this.api.v1EndpointGetStats({ + appId, + endpointId, + ...options, + since: options?.since ?? undefined, + until: options?.until ?? undefined, + }); + } + + /// Get the transformation code associated with this endpoint + public transformationGet( + appId: string, + endpointId: string + ): Promise { + return this.api.v1EndpointTransformationGet({ + appId, + endpointId, + }); + } + + /// Set or unset the transformation code associated with this endpoint + public transformationPartialUpdate( + appId: string, + endpointId: string, + endpointTransformationIn: EndpointTransformationIn + ): Promise { + return this.api.v1EndpointTransformationPartialUpdate({ + appId, + endpointId, + endpointTransformationIn, + }); + } + public oauthUpdate( appId: string, endpointId: string, diff --git a/javascript/src/api/event_type.ts b/javascript/src/api/event_type.ts index a8bf4c193..e2ac7d072 100644 --- a/javascript/src/api/event_type.ts +++ b/javascript/src/api/event_type.ts @@ -1,13 +1,14 @@ +// this file is @generated (with minor manual changes) import { Configuration, EventTypeApi, - ListResponseEventTypeOut, + EventTypeImportOpenApiIn, + EventTypeImportOpenApiOut, EventTypeIn, EventTypeOut, - EventTypeUpdate, EventTypePatch, - EventTypeImportOpenApiIn, - EventTypeImportOpenApiOut, + EventTypeUpdate, + ListResponseEventTypeOut, Ordering, } from "../openapi"; import { PostOptions } from "../util"; @@ -32,19 +33,49 @@ export class EventType { this.api = new EventTypeApi(config); } + /// Return the list of event types. public list(options?: EventTypeListOptions): Promise { - const iterator = options?.iterator ?? undefined; - return this.api.v1EventTypeList({ ...options, iterator }); + return this.api.v1EventTypeList({ + ...options, + iterator: options?.iterator ?? undefined, + }); } - public get(eventTypeName: string): Promise { - return this.api.v1EventTypeGet({ eventTypeName }); + /// Create new or unarchive existing event type. + /// + /// Unarchiving an event type will allow endpoints to filter on it and messages to be sent with it. + /// Endpoints filtering on the event type before archival will continue to filter on it. + /// This operation does not preserve the description and schemas. + public create(eventTypeIn: EventTypeIn, options?: PostOptions): Promise { + return this.api.v1EventTypeCreate({ + eventTypeIn, + ...options, + }); } - public create(eventTypeIn: EventTypeIn, options?: PostOptions): Promise { - return this.api.v1EventTypeCreate({ eventTypeIn, ...options }); + /// Given an OpenAPI spec, create new or update existing event types. + /// If an existing `archived` event type is updated, it will be unarchived. + /// + /// The importer will convert all webhooks found in the either the `webhooks` or `x-webhooks` + /// top-level. + public importOpenapi( + eventTypeImportOpenApiIn: EventTypeImportOpenApiIn, + options?: PostOptions + ): Promise { + return this.api.v1EventTypeImportOpenapi({ + eventTypeImportOpenApiIn, + ...options, + }); } + /// Get an event type. + public get(eventTypeName: string): Promise { + return this.api.v1EventTypeGet({ + eventTypeName, + }); + } + + /// Update an event type. public update( eventTypeName: string, eventTypeUpdate: EventTypeUpdate @@ -55,6 +86,19 @@ export class EventType { }); } + /// Archive an event type. + /// + /// Endpoints already configured to filter on an event type will continue to do so after archival. + /// However, new messages can not be sent with it and endpoints can not filter on it. + /// An event type can be unarchived with the + /// [create operation](#operation/create_event_type_api_v1_event_type__post). + public delete(eventTypeName: string): Promise { + return this.api.v1EventTypeDelete({ + eventTypeName, + }); + } + + /// Partially update an event type. public patch( eventTypeName: string, eventTypePatch: EventTypePatch @@ -64,18 +108,4 @@ export class EventType { eventTypePatch, }); } - - public delete(eventTypeName: string): Promise { - return this.api.v1EventTypeDelete({ eventTypeName }); - } - - public importOpenApi( - eventTypeImportOpenApiIn: EventTypeImportOpenApiIn, - options?: PostOptions - ): Promise { - return this.api.v1EventTypeImportOpenapi({ - eventTypeImportOpenApiIn, - ...options, - }); - } } diff --git a/javascript/src/api/integration.ts b/javascript/src/api/integration.ts index 12743b1ef..ba5764d81 100644 --- a/javascript/src/api/integration.ts +++ b/javascript/src/api/integration.ts @@ -1,11 +1,12 @@ +// this file is @generated (with minor manual changes) import { Configuration, IntegrationApi, - ListResponseIntegrationOut, - IntegrationOut, IntegrationIn, - IntegrationUpdate, IntegrationKeyOut, + IntegrationOut, + IntegrationUpdate, + ListResponseIntegrationOut, Ordering, } from "../openapi"; import { PostOptions } from "../util"; @@ -26,14 +27,19 @@ export class Integration { this.api = new IntegrationApi(config); } + /// List the application's integrations. public list( appId: string, options?: IntegrationListOptions ): Promise { - const iterator = options?.iterator ?? undefined; - return this.api.v1IntegrationList({ appId, ...options, iterator }); + return this.api.v1IntegrationList({ + appId, + ...options, + iterator: options?.iterator ?? undefined, + }); } + /// Create an integration. public create( appId: string, integrationIn: IntegrationIn, @@ -46,10 +52,15 @@ export class Integration { }); } + /// Get an integration. public get(appId: string, integId: string): Promise { - return this.api.v1IntegrationGet({ integId, appId }); + return this.api.v1IntegrationGet({ + appId, + integId, + }); } + /// Update an integration. public update( appId: string, integId: string, @@ -62,10 +73,11 @@ export class Integration { }); } + /// Delete an integration. public delete(appId: string, integId: string): Promise { return this.api.v1IntegrationDelete({ - integId, appId, + integId, }); } @@ -76,14 +88,15 @@ export class Integration { }); } + /// Rotate the integration's key. The previous key will be immediately revoked. public rotateKey( appId: string, integId: string, options?: PostOptions ): Promise { return this.api.v1IntegrationRotateKey({ - integId, appId, + integId, ...options, }); } diff --git a/javascript/src/api/message.ts b/javascript/src/api/message.ts index 6c6383b3d..a36ee5f48 100644 --- a/javascript/src/api/message.ts +++ b/javascript/src/api/message.ts @@ -1,9 +1,10 @@ +// this file is @generated (with minor manual changes) import { Configuration, MessageApi, - MessageOut, - MessageIn, ListResponseMessageOut, + MessageIn, + MessageOut, } from "../openapi"; import { PostOptions } from "../util"; @@ -33,6 +34,15 @@ export class Message { this.api = new MessageApi(config); } + /// List all of the application's messages. + /// + /// The `before` and `after` parameters let you filter all items created before or after a certain date. These can be used alongside an iterator to paginate over results + /// within a certain window. + /// + /// Note that by default this endpoint is limited to retrieving 90 days' worth of data + /// relative to now or, if an iterator is provided, 90 days before/after the time indicated + /// by the iterator ID. If you require data beyond those time ranges, you will need to explicitly + /// set the `before` or `after` parameter as appropriate. public list( appId: string, options?: MessageListOptions @@ -46,20 +56,43 @@ export class Message { }); } + /// Creates a new message and dispatches it to all of the application's endpoints. + /// + /// The `eventId` is an optional custom unique ID. It's verified to be unique only up to a day, after that no verification will be made. + /// If a message with the same `eventId` already exists for the application, a 409 conflict error will be returned. + /// + /// The `eventType` indicates the type and schema of the event. All messages of a certain `eventType` are expected to have the same schema. Endpoints can choose to only listen to specific event types. + /// Messages can also have `channels`, which similar to event types let endpoints filter by them. Unlike event types, messages can have multiple channels, and channels don't imply a specific message content or schema. + /// + /// The `payload` property is the webhook's body (the actual webhook message). Svix supports payload sizes of up to ~350kb, though it's generally a good idea to keep webhook payloads small, probably no larger than 40kb. public create( appId: string, messageIn: MessageIn, options?: PostOptions ): Promise { - return this.api.v1MessageCreate({ appId, messageIn, ...options }); + return this.api.v1MessageCreate({ + appId, + messageIn, + ...options, + }); } + /// Get a message by its ID or eventID. public get(appId: string, msgId: string): Promise { - return this.api.v1MessageGet({ msgId, appId }); + return this.api.v1MessageGet({ + appId, + msgId, + }); } + /// Delete the given message's payload. Useful in cases when a message was accidentally sent with sensitive content. + /// + /// The message can't be replayed or resent once its payload has been deleted or expired. public expungeContent(appId: string, msgId: string): Promise { - return this.api.v1MessageExpungeContent({ appId, msgId }); + return this.api.v1MessageExpungeContent({ + appId, + msgId, + }); } } diff --git a/javascript/src/api/message_attempt.ts b/javascript/src/api/message_attempt.ts index 5a48ed040..fb3c7ab15 100644 --- a/javascript/src/api/message_attempt.ts +++ b/javascript/src/api/message_attempt.ts @@ -1,10 +1,10 @@ +// this file is @generated (with minor manual changes) import { Configuration, MessageAttemptApi, ListResponseEndpointMessageOut, - ListResponseMessageEndpointOut, - ListResponseMessageAttemptEndpointOut, ListResponseMessageAttemptOut, + ListResponseMessageEndpointOut, MessageAttemptOut, MessageStatus, StatusCodeClass, @@ -119,6 +119,33 @@ export class MessageAttempt { return this.listByMsg(appId, msgId, options); } + /// List attempts by endpoint id + /// + /// Note that by default this endpoint is limited to retrieving 90 days' worth of data + /// relative to now or, if an iterator is provided, 90 days before/after the time indicated + /// by the iterator ID. If you require data beyond those time ranges, you will need to explicitly + /// set the `before` or `after` parameter as appropriate. + public listByEndpoint( + appId: string, + endpointId: string, + options?: MessageAttemptListByEndpointOptions + ): Promise { + return this.api.v1MessageAttemptListByEndpoint({ + appId, + endpointId, + ...options, + iterator: options?.iterator ?? undefined, + before: options?.before ?? undefined, + after: options?.after ?? undefined, + }); + } + + /// List attempts by message id + /// + /// Note that by default this endpoint is limited to retrieving 90 days' worth of data + /// relative to now or, if an iterator is provided, 90 days before/after the time indicated + /// by the iterator ID. If you require data beyond those time ranges, you will need to explicitly + /// set the `before` or `after` parameter as appropriate. public listByMsg( appId: string, msgId: string, @@ -134,12 +161,20 @@ export class MessageAttempt { }); } - public listByEndpoint( + /// List messages for a particular endpoint. Additionally includes metadata about the latest message attempt. + /// + /// The `before` parameter lets you filter all items created before a certain date and is ignored if an iterator is passed. + /// + /// Note that by default this endpoint is limited to retrieving 90 days' worth of data + /// relative to now or, if an iterator is provided, 90 days before/after the time indicated + /// by the iterator ID. If you require data beyond those time ranges, you will need to explicitly + /// set the `before` or `after` parameter as appropriate. + public listAttemptedMessages( appId: string, endpointId: string, - options?: MessageAttemptListByEndpointOptions - ): Promise { - return this.api.v1MessageAttemptListByEndpoint({ + options?: MessageAttemptListAttemptedMessagesOptions + ): Promise { + return this.api.v1MessageAttemptListAttemptedMessages({ appId, endpointId, ...options, @@ -149,47 +184,30 @@ export class MessageAttempt { }); } + /// `msg_id`: Use a message id or a message `eventId` public get( appId: string, msgId: string, attemptId: string ): Promise { return this.api.v1MessageAttemptGet({ - attemptId, - msgId, appId, - }); - } - - public resend( - appId: string, - msgId: string, - endpointId: string, - options?: PostOptions - ): Promise { - return this.api.v1MessageAttemptResend({ - endpointId, msgId, - appId, - ...options, + attemptId, }); } - public listAttemptedMessages( - appId: string, - endpointId: string, - options?: MessageAttemptListAttemptedMessagesOptions - ): Promise { - return this.api.v1MessageAttemptListAttemptedMessages({ + /// Deletes the given attempt's response body. Useful when an endpoint accidentally returned sensitive content. + public expungeContent(appId: string, msgId: string, attemptId: string): Promise { + return this.api.v1MessageAttemptExpungeContent({ appId, - endpointId, - ...options, - iterator: options?.iterator ?? undefined, - before: options?.before ?? undefined, - after: options?.after ?? undefined, + msgId, + attemptId, }); } + /// List endpoints attempted by a given message. Additionally includes metadata about the latest message attempt. + /// By default, endpoints are listed in ascending order by ID. public listAttemptedDestinations( appId: string, msgId: string, @@ -203,28 +221,18 @@ export class MessageAttempt { }); } - public listAttemptsForEndpoint( + /// Resend a message to the specified endpoint. + public resend( appId: string, msgId: string, endpointId: string, - options?: MessageAttemptListOptions - ): Promise { - return this.api.v1MessageAttemptListByEndpointDeprecated({ + options?: PostOptions + ): Promise { + return this.api.v1MessageAttemptResend({ appId, msgId, endpointId, ...options, - iterator: options?.iterator ?? undefined, - before: options?.before ?? undefined, - after: options?.after ?? undefined, - }); - } - - public expungeContent(appId: string, msgId: string, attemptId: string): Promise { - return this.api.v1MessageAttemptExpungeContent({ - appId, - msgId, - attemptId, }); } } diff --git a/javascript/src/api/statistics.ts b/javascript/src/api/statistics.ts index eeb32b591..f7cc65015 100644 --- a/javascript/src/api/statistics.ts +++ b/javascript/src/api/statistics.ts @@ -1,9 +1,10 @@ +// this file is @generated import { Configuration, StatisticsApi, + AggregateEventTypesOut, AppUsageStatsIn, AppUsageStatsOut, - AggregateEventTypesOut, } from "../openapi"; import { PostOptions } from "../util"; @@ -14,10 +15,10 @@ export class Statistics { this.api = new StatisticsApi(config); } - public aggregateEventTypes(): Promise { - return this.api.v1StatisticsAggregateEventTypes({}); - } - + /// Creates a background task to calculate the message destinations for all applications in the environment. + /// + /// Note that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to + /// retrieve the results of the operation. public aggregateAppStats( appUsageStatsIn: AppUsageStatsIn, options?: PostOptions @@ -27,4 +28,12 @@ export class Statistics { ...options, }); } + + /// Creates a background task to calculate the listed event types for all apps in the organization. + /// + /// Note that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to + /// retrieve the results of the operation. + public aggregateEventTypes(): Promise { + return this.api.v1StatisticsAggregateEventTypes({}); + } }