diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f16e9b1a..9a3ece4d 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.32.0" + ".": "1.33.0" } diff --git a/.stats.yml b/.stats.yml index 1fbd43d5..c2b62580 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 94 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/knock%2Fknock-4b8499dddbc5ac767491c492be1629f4f10a17442cf84e13e10fe38b7dcb713c.yml openapi_spec_hash: 98edfca809c07521259de151d3fc5684 -config_hash: 2008af3064bfaa2ba7828708de5d97a8 +config_hash: 625db64572b7ee0ee1dd00546e53fc5f diff --git a/CHANGELOG.md b/CHANGELOG.md index 66073bac..6cfdacf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## 1.33.0 (2026-05-27) + +Full Changelog: [v1.32.0...v1.33.0](https://github.com/knocklabs/knock-node/compare/v1.32.0...v1.33.0) + +### Features + +* **api:** api update ([9dbfff2](https://github.com/knocklabs/knock-node/commit/9dbfff222da87c9398415efcf3c0387dc112f35d)) +* **api:** api update ([54c0d88](https://github.com/knocklabs/knock-node/commit/54c0d88e8238333ff5145177a722894baa3ee186)) + + +### Chores + +* **formatter:** run prettier and eslint separately ([462a571](https://github.com/knocklabs/knock-node/commit/462a5715f67fa2b60c08699d4f11c3638d2e1e89)) +* **formatter:** run prettier and eslint separately ([ec2ce1a](https://github.com/knocklabs/knock-node/commit/ec2ce1a53fe1b5b08ef6aedce33d3d80de4b27a4)) +* **formatter:** run prettier and eslint separately ([a4a2c96](https://github.com/knocklabs/knock-node/commit/a4a2c9668233333a46fd75dbc2f4f82af2492df5)) + ## 1.32.0 (2026-04-22) Full Changelog: [v1.31.1...v1.32.0](https://github.com/knocklabs/knock-node/compare/v1.31.1...v1.32.0) diff --git a/eslint.config.mjs b/eslint.config.mjs index eabb2ff4..f3427c78 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,7 +1,6 @@ // @ts-check import tseslint from 'typescript-eslint'; import unusedImports from 'eslint-plugin-unused-imports'; -import prettier from 'eslint-plugin-prettier'; export default tseslint.config( { @@ -14,11 +13,9 @@ export default tseslint.config( plugins: { '@typescript-eslint': tseslint.plugin, 'unused-imports': unusedImports, - prettier, }, rules: { 'no-unused-vars': 'off', - 'prettier/prettier': 'error', 'unused-imports/no-unused-imports': 'error', 'no-restricted-imports': [ 'error', diff --git a/package.json b/package.json index 02205374..71ed7d5c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@knocklabs/node", - "version": "1.32.0", + "version": "1.33.0", "description": "The official TypeScript library for the Knock API", "author": "Knock ", "types": "dist/index.d.ts", @@ -38,7 +38,6 @@ "@typescript-eslint/eslint-plugin": "8.31.1", "@typescript-eslint/parser": "8.31.1", "eslint": "^9.39.1", - "eslint-plugin-prettier": "^5.4.1", "eslint-plugin-unused-imports": "^4.1.4", "iconv-lite": "^0.6.3", "jest": "^29.4.0", diff --git a/scripts/fast-format b/scripts/fast-format index 53721ac0..e1723136 100755 --- a/scripts/fast-format +++ b/scripts/fast-format @@ -31,10 +31,8 @@ if ! [ -z "$ESLINT_FILES" ]; then fi echo "==> Running prettier --write" -# format things eslint didn't -PRETTIER_FILES="$(grep '\.\(js\|json\)$' "$FILE_LIST" || true)" +PRETTIER_FILES="$(grep '\.\([mc]?tsx?\|[mc]?jsx?\|json\)$' "$FILE_LIST" || true)" if ! [ -z "$PRETTIER_FILES" ]; then echo "$PRETTIER_FILES" | xargs ./node_modules/.bin/prettier \ - --write --cache --cache-strategy metadata --no-error-on-unmatched-pattern \ - '!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs' + --write --cache --cache-strategy metadata --no-error-on-unmatched-pattern fi diff --git a/scripts/format b/scripts/format index 7a756401..b1b2c17a 100755 --- a/scripts/format +++ b/scripts/format @@ -8,5 +8,4 @@ echo "==> Running eslint --fix" ./node_modules/.bin/eslint --fix . echo "==> Running prettier --write" -# format things eslint didn't -./node_modules/.bin/prettier --write --cache --cache-strategy metadata . '!**/dist' '!**/*.ts' '!**/*.mts' '!**/*.cts' '!**/*.js' '!**/*.mjs' '!**/*.cjs' +./node_modules/.bin/prettier --write --cache --cache-strategy metadata . diff --git a/scripts/lint b/scripts/lint index 3ffb78a6..1f532548 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,6 +4,9 @@ set -e cd "$(dirname "$0")/.." +echo "==> Running prettier --check" +./node_modules/.bin/prettier --check . + echo "==> Running eslint" ./node_modules/.bin/eslint . diff --git a/src/api-promise.ts b/src/api-promise.ts index 8c775ee6..4e701286 100644 --- a/src/api-promise.ts +++ b/src/api-promise.ts @@ -1,2 +1,2 @@ /** @deprecated Import from ./core/api-promise instead */ -export * from './core/api-promise'; +export * from "./core/api-promise" \ No newline at end of file diff --git a/src/client.ts b/src/client.ts index 4b364ac5..a7e8e540 100644 --- a/src/client.ts +++ b/src/client.ts @@ -15,137 +15,28 @@ import { stringifyQuery } from './internal/utils/query'; import { VERSION } from './version'; import * as Errors from './core/error'; import * as Pagination from './core/pagination'; -import { - AbstractPage, - type EntriesCursorParams, - EntriesCursorResponse, - type ItemsCursorParams, - ItemsCursorResponse, - type MsTeamsPaginationParams, - MsTeamsPaginationResponse, - type SlackChannelsCursorParams, - SlackChannelsCursorResponse, -} from './core/pagination'; +import { AbstractPage, type EntriesCursorParams, EntriesCursorResponse, type ItemsCursorParams, ItemsCursorResponse, type MsTeamsPaginationParams, MsTeamsPaginationResponse, type SlackChannelsCursorParams, SlackChannelsCursorResponse } from './core/pagination'; import * as Uploads from './core/uploads'; import * as API from './resources/index'; import { APIPromise } from './core/api-promise'; -import { - AudienceAddMembersParams, - AudienceListMembersResponse, - AudienceMember, - AudienceRemoveMembersParams, - Audiences, -} from './resources/audiences'; +import { AudienceAddMembersParams, AudienceListMembersResponse, AudienceMember, AudienceRemoveMembersParams, Audiences } from './resources/audiences'; import { BulkOperation, BulkOperations } from './resources/bulk-operations'; -import { - WorkflowRecipientRun, - WorkflowRecipientRunDetail, - WorkflowRecipientRunEvent, - WorkflowRecipientRunListParams, - WorkflowRecipientRuns, - WorkflowRecipientRunsItemsCursor, -} from './resources/workflow-recipient-runs'; -import { - WorkflowCancelParams, - WorkflowTriggerParams, - WorkflowTriggerResponse, - Workflows, -} from './resources/workflows'; +import { WorkflowRecipientRun, WorkflowRecipientRunDetail, WorkflowRecipientRunEvent, WorkflowRecipientRunListParams, WorkflowRecipientRuns, WorkflowRecipientRunsItemsCursor } from './resources/workflow-recipient-runs'; +import { WorkflowCancelParams, WorkflowTriggerParams, WorkflowTriggerResponse, Workflows } from './resources/workflows'; import { Channels } from './resources/channels/channels'; import { Integrations } from './resources/integrations/integrations'; -import { - ActivitiesItemsCursor, - Activity, - Message, - MessageDeliveryLog, - MessageDeliveryLogsItemsCursor, - MessageEvent, - MessageEventsItemsCursor, - MessageGetContentResponse, - MessageListActivitiesParams, - MessageListDeliveryLogsParams, - MessageListEventsParams, - MessageListParams, - MessageMarkAsInteractedParams, - Messages, - MessagesItemsCursor, -} from './resources/messages/messages'; -import { - InlineObjectRequest, - Object, - ObjectAddSubscriptionsParams, - ObjectAddSubscriptionsResponse, - ObjectDeleteSubscriptionsParams, - ObjectDeleteSubscriptionsResponse, - ObjectListMessagesParams, - ObjectListParams, - ObjectListPreferencesResponse, - ObjectListSchedulesParams, - ObjectListSubscriptionsParams, - ObjectSetChannelDataParams, - ObjectSetParams, - ObjectSetPreferencesParams, - Objects, - ObjectsEntriesCursor, -} from './resources/objects/objects'; +import { ActivitiesItemsCursor, Activity, Message, MessageDeliveryLog, MessageDeliveryLogsItemsCursor, MessageEvent, MessageEventsItemsCursor, MessageGetContentResponse, MessageListActivitiesParams, MessageListDeliveryLogsParams, MessageListEventsParams, MessageListParams, MessageMarkAsInteractedParams, Messages, MessagesItemsCursor } from './resources/messages/messages'; +import { InlineObjectRequest, Object, ObjectAddSubscriptionsParams, ObjectAddSubscriptionsResponse, ObjectDeleteSubscriptionsParams, ObjectDeleteSubscriptionsResponse, ObjectListMessagesParams, ObjectListParams, ObjectListPreferencesResponse, ObjectListSchedulesParams, ObjectListSubscriptionsParams, ObjectSetChannelDataParams, ObjectSetParams, ObjectSetPreferencesParams, Objects, ObjectsEntriesCursor } from './resources/objects/objects'; import { Providers } from './resources/providers/providers'; -import { - Recipient, - RecipientReference, - RecipientRequest, - Recipients, -} from './resources/recipients/recipients'; -import { - Schedule, - ScheduleCreateParams, - ScheduleCreateResponse, - ScheduleDeleteParams, - ScheduleDeleteResponse, - ScheduleListParams, - ScheduleRepeatRule, - ScheduleUpdateParams, - ScheduleUpdateResponse, - Schedules, - SchedulesEntriesCursor, -} from './resources/schedules/schedules'; -import { - InlineTenantRequest, - Tenant, - TenantGetParams, - TenantListParams, - TenantRequest, - TenantSetParams, - Tenants, - TenantsEntriesCursor, -} from './resources/tenants/tenants'; -import { - IdentifyUserRequest, - InlineIdentifyUserRequest, - User, - UserGetPreferencesParams, - UserListMessagesParams, - UserListParams, - UserListPreferencesResponse, - UserListSchedulesParams, - UserListSubscriptionsParams, - UserMergeParams, - UserSetChannelDataParams, - UserSetPreferencesParams, - UserUpdateParams, - Users, - UsersEntriesCursor, -} from './resources/users/users'; +import { Recipient, RecipientReference, RecipientRequest, Recipients } from './resources/recipients/recipients'; +import { Schedule, ScheduleCreateParams, ScheduleCreateResponse, ScheduleDeleteParams, ScheduleDeleteResponse, ScheduleListParams, ScheduleRepeatRule, ScheduleUpdateParams, ScheduleUpdateResponse, Schedules, SchedulesEntriesCursor } from './resources/schedules/schedules'; +import { InlineTenantRequest, Tenant, TenantGetParams, TenantListParams, TenantRequest, TenantSetParams, Tenants, TenantsEntriesCursor } from './resources/tenants/tenants'; +import { IdentifyUserRequest, InlineIdentifyUserRequest, User, UserGetPreferencesParams, UserListMessagesParams, UserListParams, UserListPreferencesResponse, UserListSchedulesParams, UserListSubscriptionsParams, UserMergeParams, UserSetChannelDataParams, UserSetPreferencesParams, UserUpdateParams, Users, UsersEntriesCursor } from './resources/users/users'; import { type Fetch } from './internal/builtin-types'; import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers'; import { FinalRequestOptions, RequestOptions } from './internal/request-options'; import { readEnv } from './internal/utils/env'; -import { - type LogLevel, - type Logger, - formatRequestDetails, - loggerFor, - parseLogLevel, -} from './internal/utils/log'; +import { type LogLevel, type Logger, formatRequestDetails, loggerFor, parseLogLevel } from './internal/utils/log'; import { isEmptyObj } from './internal/utils/values'; export interface ClientOptions { @@ -229,7 +120,7 @@ export interface ClientOptions { } /** - * API Client for interfacing with the Knock API. + * API Client for interfacing with the Knock API. */ export class Knock { apiKey: string; @@ -268,7 +159,7 @@ export class Knock { }: ClientOptions = {}) { if (apiKey === undefined) { throw new Errors.KnockError( - "The KNOCK_API_KEY environment variable is missing or empty; either provide it, or instantiate the Knock client with an apiKey option, like new Knock({ apiKey: 'My API Key' }).", + 'The KNOCK_API_KEY environment variable is missing or empty; either provide it, or instantiate the Knock client with an apiKey option, like new Knock({ apiKey: \'My API Key\' }).' ); } @@ -285,17 +176,14 @@ export class Knock { const defaultLogLevel = 'warn'; // Set default logLevel early so that we can log a warning in parseLogLevel. this.logLevel = defaultLogLevel; - this.logLevel = - parseLogLevel(options.logLevel, 'ClientOptions.logLevel', this) ?? - parseLogLevel(readEnv('KNOCK_LOG'), "process.env['KNOCK_LOG']", this) ?? - defaultLogLevel; + this.logLevel = parseLogLevel(options.logLevel, 'ClientOptions.logLevel', this) ?? parseLogLevel(readEnv('KNOCK_LOG'), 'process.env[\'KNOCK_LOG\']', this) ?? defaultLogLevel; this.fetchOptions = options.fetchOptions; this.maxRetries = options.maxRetries ?? 2; this.fetch = options.fetch ?? Shims.getDefaultFetch(); this.#encoder = Opts.FallbackEncoder; this._options = options; - this.idempotencyHeader = 'Idempotency-Key'; + this.idempotencyHeader = 'Idempotency-Key' this.apiKey = apiKey; this.branch = branch; @@ -316,7 +204,7 @@ export class Knock { fetchOptions: this.fetchOptions, apiKey: this.apiKey, branch: this.branch, - ...options, + ...options }); return client; } @@ -329,7 +217,7 @@ export class Knock { } protected defaultQuery(): Record | undefined { - return this._options.defaultQuery; + return this._options.defaultQuery } protected validateHeaders({ values, nulls }: NullableHeaders) { @@ -361,11 +249,7 @@ export class Knock { return Errors.APIError.generate(status, error, message, headers); } - buildURL( - path: string, - query: Record | null | undefined, - defaultBaseURL?: string | undefined, - ): string { + buildURL(path: string, query: Record | null | undefined, defaultBaseURL?: string | undefined): string { const baseURL = (!this.#baseURLOverridden() && defaultBaseURL) || this.baseURL; const url = isAbsoluteURL(path) ? @@ -456,9 +340,7 @@ export class Knock { await this.prepareOptions(options); - const { req, url, timeout } = await this.buildRequest(options, { - retryCount: maxRetries - retriesRemaining, - }); + const { req, url, timeout } = await this.buildRequest(options, { retryCount: maxRetries - retriesRemaining }); await this.prepareRequest(req, { url, options }); @@ -467,16 +349,7 @@ export class Knock { const retryLogStr = retryOfRequestLogID === undefined ? '' : `, retryOf: ${retryOfRequestLogID}`; const startTime = Date.now(); - loggerFor(this).debug( - `[${requestLogID}] sending request`, - formatRequestDetails({ - retryOfRequestLogID, - method: options.method, - url, - options, - headers: req.headers, - }), - ); + loggerFor(this).debug(`[${requestLogID}] sending request`, formatRequestDetails({ retryOfRequestLogID, method: options.method, url, options, headers: req.headers })); if (options.signal?.aborted) { throw new Errors.APIUserAbortError(); @@ -495,45 +368,21 @@ export class Knock { // deno throws "TypeError: error sending request for url (https://example/): client error (Connect): tcp connect error: Operation timed out (os error 60): Operation timed out (os error 60)" // undici throws "TypeError: fetch failed" with cause "ConnectTimeoutError: Connect Timeout Error (attempted address: example:443, timeout: 1ms)" // others do not provide enough information to distinguish timeouts from other connection errors - const isTimeout = - isAbortError(response) || - /timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : '')); + const isTimeout = isAbortError(response) || /timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : '')) if (retriesRemaining) { - loggerFor(this).info( - `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`, - ); - loggerFor(this).debug( - `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${retryMessage})`, - formatRequestDetails({ - retryOfRequestLogID, - url, - durationMs: headersTime - startTime, - message: response.message, - }), - ); + loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`) + loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${retryMessage})`, formatRequestDetails({ retryOfRequestLogID, url, durationMs: headersTime - startTime, message: response.message })); return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID); } - loggerFor(this).info( - `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - error; no more retries left`, - ); - loggerFor(this).debug( - `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (error; no more retries left)`, - formatRequestDetails({ - retryOfRequestLogID, - url, - durationMs: headersTime - startTime, - message: response.message, - }), - ); + loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - error; no more retries left`) + loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (error; no more retries left)`, formatRequestDetails({ retryOfRequestLogID, url, durationMs: headersTime - startTime, message: response.message })); if (isTimeout) { throw new Errors.APIConnectionTimeoutError(); } throw new Errors.APIConnectionError({ cause: response }); } - const responseInfo = `[${requestLogID}${retryLogStr}] ${req.method} ${url} ${ - response.ok ? 'succeeded' : 'failed' - } with status ${response.status} in ${headersTime - startTime}ms`; + const responseInfo = `[${requestLogID}${retryLogStr}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`; if (!response.ok) { const shouldRetry = await this.shouldRetry(response); @@ -542,60 +391,27 @@ export class Knock { // We don't need the body of this response. await Shims.CancelReadableStream(response.body); - loggerFor(this).info(`${responseInfo} - ${retryMessage}`); - loggerFor(this).debug( - `[${requestLogID}] response error (${retryMessage})`, - formatRequestDetails({ - retryOfRequestLogID, - url: response.url, - status: response.status, - headers: response.headers, - durationMs: headersTime - startTime, - }), - ); - return this.retryRequest( - options, - retriesRemaining, - retryOfRequestLogID ?? requestLogID, - response.headers, - ); + loggerFor(this).info(`${responseInfo} - ${retryMessage}`) + loggerFor(this).debug(`[${requestLogID}] response error (${retryMessage})`, formatRequestDetails({ retryOfRequestLogID, url: response.url, status: response.status, headers: response.headers, durationMs: headersTime - startTime })); + return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID, response.headers); } const retryMessage = shouldRetry ? `error; no more retries left` : `error; not retryable`; - loggerFor(this).info(`${responseInfo} - ${retryMessage}`); + loggerFor(this).info(`${responseInfo} - ${retryMessage}`) const errText = await response.text().catch((err: any) => castToError(err).message); const errJSON = safeJSON(errText) as any; const errMessage = errJSON ? undefined : errText; - loggerFor(this).debug( - `[${requestLogID}] response error (${retryMessage})`, - formatRequestDetails({ - retryOfRequestLogID, - url: response.url, - status: response.status, - headers: response.headers, - message: errMessage, - durationMs: Date.now() - startTime, - }), - ); + loggerFor(this).debug(`[${requestLogID}] response error (${retryMessage})`, formatRequestDetails({ retryOfRequestLogID, url: response.url, status: response.status, headers: response.headers, message: errMessage, durationMs: Date.now() - startTime })); const err = this.makeStatusError(response.status, errJSON, errMessage, response.headers); throw err; } - loggerFor(this).info(responseInfo); - loggerFor(this).debug( - `[${requestLogID}] response start`, - formatRequestDetails({ - retryOfRequestLogID, - url: response.url, - status: response.status, - headers: response.headers, - durationMs: headersTime - startTime, - }), - ); + loggerFor(this).info(responseInfo) + loggerFor(this).debug(`[${requestLogID}] response start`, formatRequestDetails({ retryOfRequestLogID, url: response.url, status: response.status, headers: response.headers, durationMs: headersTime - startTime })); return { response, options, controller, requestLogID, retryOfRequestLogID, startTime }; } @@ -613,10 +429,7 @@ export class Knock { ); } - requestAPIList< - Item = unknown, - PageClass extends Pagination.AbstractPage = Pagination.AbstractPage, - >( + requestAPIList = Pagination.AbstractPage>( Page: new (...args: ConstructorParameters) => PageClass, options: PromiseOrValue, ): Pagination.PagePromise { @@ -636,9 +449,7 @@ export class Knock { const timeout = setTimeout(abort, ms); - const isReadableBody = - ((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) || - (typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body); + const isReadableBody = ((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) || (typeof options.body === "object" && options.body !== null && Symbol.asyncIterator in options.body); const fetchOptions: RequestInit = { signal: controller.signal as any, @@ -653,6 +464,7 @@ export class Knock { } try { + // use undefined this binding; fetch errors if bound to something else in browser/cloudflare return await this.fetch.call(undefined, url, fetchOptions); } finally { @@ -753,12 +565,11 @@ export class Knock { const req: FinalizedRequestInit = { method, headers: reqHeaders, - ...(options.signal && { signal: options.signal }), - ...((globalThis as any).ReadableStream && - body instanceof (globalThis as any).ReadableStream && { duplex: 'half' }), + ...(options.signal && { signal: options.signal}), + ...((globalThis as any).ReadableStream && body instanceof (globalThis as any).ReadableStream && { duplex: "half" }), ...(body && { body }), - ...((this.fetchOptions as any) ?? {}), - ...((options.fetchOptions as any) ?? {}), + ...(this.fetchOptions as any ?? {}), + ...(options.fetchOptions as any ?? {}), }; return { req, url, timeout: options.timeout }; @@ -783,18 +594,16 @@ export class Knock { const headers = buildHeaders([ idempotencyHeaders, - { - Accept: 'application/json', - 'User-Agent': this.getUserAgent(), - 'X-Stainless-Retry-Count': String(retryCount), - ...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}), - ...getPlatformHeaders(), - 'X-Knock-Branch': this.branch, - }, + {Accept: 'application/json', + 'User-Agent': this.getUserAgent(), + 'X-Stainless-Retry-Count': String(retryCount), + ...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}), + ...getPlatformHeaders(), + 'X-Knock-Branch': this.branch}, await this.authHeaders(options), this._options.defaultHeaders, bodyHeaders, - options.headers, + options.headers ]); this.validateHeaders(headers); @@ -821,9 +630,11 @@ export class Knock { ArrayBuffer.isView(body) || body instanceof ArrayBuffer || body instanceof DataView || - (typeof body === 'string' && + ( + typeof body === 'string' && // Preserve legacy string encoding behavior for now - headers.values.has('content-type')) || + headers.values.has('content-type') + ) || // `Blob` is superset of `File` ((globalThis as any).Blob && body instanceof (globalThis as any).Blob) || // `FormData` -> `multipart/form-data` @@ -854,7 +665,7 @@ export class Knock { } static Knock = this; - static DEFAULT_TIMEOUT = 60000; // 1 minute + static DEFAULT_TIMEOUT = 60000 // 1 minute static KnockError = Errors.KnockError; static APIError = Errors.APIError; @@ -929,148 +740,160 @@ Knock.Channels = Channels; Knock.Audiences = Audiences; export declare namespace Knock { - export type RequestOptions = Opts.RequestOptions; - - export import EntriesCursor = Pagination.EntriesCursor; - export { - type EntriesCursorParams as EntriesCursorParams, - type EntriesCursorResponse as EntriesCursorResponse, - }; - - export import ItemsCursor = Pagination.ItemsCursor; - export { type ItemsCursorParams as ItemsCursorParams, type ItemsCursorResponse as ItemsCursorResponse }; - - export import SlackChannelsCursor = Pagination.SlackChannelsCursor; - export { - type SlackChannelsCursorParams as SlackChannelsCursorParams, - type SlackChannelsCursorResponse as SlackChannelsCursorResponse, - }; - - export import MsTeamsPagination = Pagination.MsTeamsPagination; - export { - type MsTeamsPaginationParams as MsTeamsPaginationParams, - type MsTeamsPaginationResponse as MsTeamsPaginationResponse, - }; - - export { - Recipients as Recipients, - type Recipient as Recipient, - type RecipientReference as RecipientReference, - type RecipientRequest as RecipientRequest, - }; - - export { - Users as Users, - type IdentifyUserRequest as IdentifyUserRequest, - type InlineIdentifyUserRequest as InlineIdentifyUserRequest, - type User as User, - type UserListPreferencesResponse as UserListPreferencesResponse, - type UsersEntriesCursor as UsersEntriesCursor, - type UserUpdateParams as UserUpdateParams, - type UserListParams as UserListParams, - type UserGetPreferencesParams as UserGetPreferencesParams, - type UserListMessagesParams as UserListMessagesParams, - type UserListSchedulesParams as UserListSchedulesParams, - type UserListSubscriptionsParams as UserListSubscriptionsParams, - type UserMergeParams as UserMergeParams, - type UserSetChannelDataParams as UserSetChannelDataParams, - type UserSetPreferencesParams as UserSetPreferencesParams, - }; - - export { - Objects as Objects, - type InlineObjectRequest as InlineObjectRequest, - type Object as Object, - type ObjectAddSubscriptionsResponse as ObjectAddSubscriptionsResponse, - type ObjectDeleteSubscriptionsResponse as ObjectDeleteSubscriptionsResponse, - type ObjectListPreferencesResponse as ObjectListPreferencesResponse, - type ObjectsEntriesCursor as ObjectsEntriesCursor, - type ObjectListParams as ObjectListParams, - type ObjectAddSubscriptionsParams as ObjectAddSubscriptionsParams, - type ObjectDeleteSubscriptionsParams as ObjectDeleteSubscriptionsParams, - type ObjectListMessagesParams as ObjectListMessagesParams, - type ObjectListSchedulesParams as ObjectListSchedulesParams, - type ObjectListSubscriptionsParams as ObjectListSubscriptionsParams, - type ObjectSetParams as ObjectSetParams, - type ObjectSetChannelDataParams as ObjectSetChannelDataParams, - type ObjectSetPreferencesParams as ObjectSetPreferencesParams, - }; - - export { - Tenants as Tenants, - type InlineTenantRequest as InlineTenantRequest, - type Tenant as Tenant, - type TenantRequest as TenantRequest, - type TenantsEntriesCursor as TenantsEntriesCursor, - type TenantListParams as TenantListParams, - type TenantGetParams as TenantGetParams, - type TenantSetParams as TenantSetParams, - }; - - export { BulkOperations as BulkOperations, type BulkOperation as BulkOperation }; - - export { - Messages as Messages, - type Activity as Activity, - type Message as Message, - type MessageDeliveryLog as MessageDeliveryLog, - type MessageEvent as MessageEvent, - type MessageGetContentResponse as MessageGetContentResponse, - type MessagesItemsCursor as MessagesItemsCursor, - type ActivitiesItemsCursor as ActivitiesItemsCursor, - type MessageDeliveryLogsItemsCursor as MessageDeliveryLogsItemsCursor, - type MessageEventsItemsCursor as MessageEventsItemsCursor, - type MessageListParams as MessageListParams, - type MessageListActivitiesParams as MessageListActivitiesParams, - type MessageListDeliveryLogsParams as MessageListDeliveryLogsParams, - type MessageListEventsParams as MessageListEventsParams, - type MessageMarkAsInteractedParams as MessageMarkAsInteractedParams, - }; - - export { Providers as Providers }; - - export { Integrations as Integrations }; - - export { - Workflows as Workflows, - type WorkflowTriggerResponse as WorkflowTriggerResponse, - type WorkflowCancelParams as WorkflowCancelParams, - type WorkflowTriggerParams as WorkflowTriggerParams, - }; - - export { - WorkflowRecipientRuns as WorkflowRecipientRuns, - type WorkflowRecipientRun as WorkflowRecipientRun, - type WorkflowRecipientRunDetail as WorkflowRecipientRunDetail, - type WorkflowRecipientRunEvent as WorkflowRecipientRunEvent, - type WorkflowRecipientRunsItemsCursor as WorkflowRecipientRunsItemsCursor, - type WorkflowRecipientRunListParams as WorkflowRecipientRunListParams, - }; - - export { - Schedules as Schedules, - type Schedule as Schedule, - type ScheduleRepeatRule as ScheduleRepeatRule, - type ScheduleCreateResponse as ScheduleCreateResponse, - type ScheduleUpdateResponse as ScheduleUpdateResponse, - type ScheduleDeleteResponse as ScheduleDeleteResponse, - type SchedulesEntriesCursor as SchedulesEntriesCursor, - type ScheduleCreateParams as ScheduleCreateParams, - type ScheduleUpdateParams as ScheduleUpdateParams, - type ScheduleListParams as ScheduleListParams, - type ScheduleDeleteParams as ScheduleDeleteParams, - }; - - export { Channels as Channels }; - - export { - Audiences as Audiences, - type AudienceMember as AudienceMember, - type AudienceListMembersResponse as AudienceListMembersResponse, - type AudienceAddMembersParams as AudienceAddMembersParams, - type AudienceRemoveMembersParams as AudienceRemoveMembersParams, - }; - - export type Condition = API.Condition; - export type PageInfo = API.PageInfo; -} + export type RequestOptions = Opts.RequestOptions; + + export import EntriesCursor = Pagination.EntriesCursor; +export { + type EntriesCursorParams as EntriesCursorParams, + type EntriesCursorResponse as EntriesCursorResponse +}; + +export import ItemsCursor = Pagination.ItemsCursor; +export { + type ItemsCursorParams as ItemsCursorParams, + type ItemsCursorResponse as ItemsCursorResponse +}; + +export import SlackChannelsCursor = Pagination.SlackChannelsCursor; +export { + type SlackChannelsCursorParams as SlackChannelsCursorParams, + type SlackChannelsCursorResponse as SlackChannelsCursorResponse +}; + +export import MsTeamsPagination = Pagination.MsTeamsPagination; +export { + type MsTeamsPaginationParams as MsTeamsPaginationParams, + type MsTeamsPaginationResponse as MsTeamsPaginationResponse +}; + +export { + Recipients as Recipients, + type Recipient as Recipient, + type RecipientReference as RecipientReference, + type RecipientRequest as RecipientRequest +}; + +export { + Users as Users, + type IdentifyUserRequest as IdentifyUserRequest, + type InlineIdentifyUserRequest as InlineIdentifyUserRequest, + type User as User, + type UserListPreferencesResponse as UserListPreferencesResponse, + type UsersEntriesCursor as UsersEntriesCursor, + type UserUpdateParams as UserUpdateParams, + type UserListParams as UserListParams, + type UserGetPreferencesParams as UserGetPreferencesParams, + type UserListMessagesParams as UserListMessagesParams, + type UserListSchedulesParams as UserListSchedulesParams, + type UserListSubscriptionsParams as UserListSubscriptionsParams, + type UserMergeParams as UserMergeParams, + type UserSetChannelDataParams as UserSetChannelDataParams, + type UserSetPreferencesParams as UserSetPreferencesParams +}; + +export { + Objects as Objects, + type InlineObjectRequest as InlineObjectRequest, + type Object as Object, + type ObjectAddSubscriptionsResponse as ObjectAddSubscriptionsResponse, + type ObjectDeleteSubscriptionsResponse as ObjectDeleteSubscriptionsResponse, + type ObjectListPreferencesResponse as ObjectListPreferencesResponse, + type ObjectsEntriesCursor as ObjectsEntriesCursor, + type ObjectListParams as ObjectListParams, + type ObjectAddSubscriptionsParams as ObjectAddSubscriptionsParams, + type ObjectDeleteSubscriptionsParams as ObjectDeleteSubscriptionsParams, + type ObjectListMessagesParams as ObjectListMessagesParams, + type ObjectListSchedulesParams as ObjectListSchedulesParams, + type ObjectListSubscriptionsParams as ObjectListSubscriptionsParams, + type ObjectSetParams as ObjectSetParams, + type ObjectSetChannelDataParams as ObjectSetChannelDataParams, + type ObjectSetPreferencesParams as ObjectSetPreferencesParams +}; + +export { + Tenants as Tenants, + type InlineTenantRequest as InlineTenantRequest, + type Tenant as Tenant, + type TenantRequest as TenantRequest, + type TenantsEntriesCursor as TenantsEntriesCursor, + type TenantListParams as TenantListParams, + type TenantGetParams as TenantGetParams, + type TenantSetParams as TenantSetParams +}; + +export { + BulkOperations as BulkOperations, + type BulkOperation as BulkOperation +}; + +export { + Messages as Messages, + type Activity as Activity, + type Message as Message, + type MessageDeliveryLog as MessageDeliveryLog, + type MessageEvent as MessageEvent, + type MessageGetContentResponse as MessageGetContentResponse, + type MessagesItemsCursor as MessagesItemsCursor, + type ActivitiesItemsCursor as ActivitiesItemsCursor, + type MessageDeliveryLogsItemsCursor as MessageDeliveryLogsItemsCursor, + type MessageEventsItemsCursor as MessageEventsItemsCursor, + type MessageListParams as MessageListParams, + type MessageListActivitiesParams as MessageListActivitiesParams, + type MessageListDeliveryLogsParams as MessageListDeliveryLogsParams, + type MessageListEventsParams as MessageListEventsParams, + type MessageMarkAsInteractedParams as MessageMarkAsInteractedParams +}; + +export { + Providers as Providers +}; + +export { + Integrations as Integrations +}; + +export { + Workflows as Workflows, + type WorkflowTriggerResponse as WorkflowTriggerResponse, + type WorkflowCancelParams as WorkflowCancelParams, + type WorkflowTriggerParams as WorkflowTriggerParams +}; + +export { + WorkflowRecipientRuns as WorkflowRecipientRuns, + type WorkflowRecipientRun as WorkflowRecipientRun, + type WorkflowRecipientRunDetail as WorkflowRecipientRunDetail, + type WorkflowRecipientRunEvent as WorkflowRecipientRunEvent, + type WorkflowRecipientRunsItemsCursor as WorkflowRecipientRunsItemsCursor, + type WorkflowRecipientRunListParams as WorkflowRecipientRunListParams +}; + +export { + Schedules as Schedules, + type Schedule as Schedule, + type ScheduleRepeatRule as ScheduleRepeatRule, + type ScheduleCreateResponse as ScheduleCreateResponse, + type ScheduleUpdateResponse as ScheduleUpdateResponse, + type ScheduleDeleteResponse as ScheduleDeleteResponse, + type SchedulesEntriesCursor as SchedulesEntriesCursor, + type ScheduleCreateParams as ScheduleCreateParams, + type ScheduleUpdateParams as ScheduleUpdateParams, + type ScheduleListParams as ScheduleListParams, + type ScheduleDeleteParams as ScheduleDeleteParams +}; + +export { + Channels as Channels +}; + +export { + Audiences as Audiences, + type AudienceMember as AudienceMember, + type AudienceListMembersResponse as AudienceListMembersResponse, + type AudienceAddMembersParams as AudienceAddMembersParams, + type AudienceRemoveMembersParams as AudienceRemoveMembersParams +}; + +export type Condition = API.Condition; +export type PageInfo = API.PageInfo; + } diff --git a/src/core/api-promise.ts b/src/core/api-promise.ts index 012a786c..72633e22 100644 --- a/src/core/api-promise.ts +++ b/src/core/api-promise.ts @@ -16,10 +16,7 @@ export class APIPromise extends Promise { constructor( client: Knock, private responsePromise: Promise, - private parseResponse: ( - client: Knock, - props: APIResponseProps, - ) => PromiseOrValue = defaultParseResponse, + private parseResponse: (client: Knock, props: APIResponseProps) => PromiseOrValue = defaultParseResponse, ) { super((resolve) => { // this is maybe a bit weird but this has to be a no-op to not implicitly @@ -31,9 +28,7 @@ export class APIPromise extends Promise { } _thenUnwrap(transform: (data: T, props: APIResponseProps) => U): APIPromise { - return new APIPromise(this.#client, this.responsePromise, async (client, props) => - transform(await this.parseResponse(client, props), props), - ); + return new APIPromise(this.#client, this.responsePromise, async (client, props) => transform(await this.parseResponse(client, props), props)); } /** diff --git a/src/core/error.ts b/src/core/error.ts index cb4f8e0b..7ddc8028 100644 --- a/src/core/error.ts +++ b/src/core/error.ts @@ -2,13 +2,10 @@ import { castToError } from '../internal/errors'; -export class KnockError extends Error {} +export class KnockError extends Error { +} -export class APIError< - TStatus extends number | undefined = number | undefined, - THeaders extends Headers | undefined = Headers | undefined, - TError extends Object | undefined = Object | undefined, -> extends KnockError { +export class APIError extends KnockError { /** HTTP status for the response that caused the error */ readonly status: TStatus; /** HTTP headers for the response that caused the error */ @@ -16,6 +13,9 @@ export class APIError< /** JSON body of the response that caused the error */ readonly error: TError; + + ; + constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) { super(`${APIError.makeMessage(status, error, message)}`); this.status = status; @@ -26,8 +26,7 @@ export class APIError< private static makeMessage(status: number | undefined, error: any, message: string | undefined) { const msg = error?.message ? - typeof error.message === 'string' ? - error.message + typeof error.message === 'string' ? error.message : JSON.stringify(error.message) : error ? JSON.stringify(error) : message; @@ -44,12 +43,7 @@ export class APIError< return '(no status code or body)'; } - static generate( - status: number | undefined, - errorResponse: Object | undefined, - message: string | undefined, - headers: Headers | undefined, - ): APIError { + static generate(status: number | undefined, errorResponse: Object | undefined, message: string | undefined, headers: Headers | undefined): APIError { if (!status || !headers) { return new APIConnectionError({ message, cause: castToError(errorResponse) }); } @@ -113,18 +107,26 @@ export class APIConnectionTimeoutError extends APIConnectionError { } } -export class BadRequestError extends APIError<400, Headers> {} +export class BadRequestError extends APIError<400, Headers> { +} -export class AuthenticationError extends APIError<401, Headers> {} +export class AuthenticationError extends APIError<401, Headers> { +} -export class PermissionDeniedError extends APIError<403, Headers> {} +export class PermissionDeniedError extends APIError<403, Headers> { +} -export class NotFoundError extends APIError<404, Headers> {} +export class NotFoundError extends APIError<404, Headers> { +} -export class ConflictError extends APIError<409, Headers> {} +export class ConflictError extends APIError<409, Headers> { +} -export class UnprocessableEntityError extends APIError<422, Headers> {} +export class UnprocessableEntityError extends APIError<422, Headers> { +} -export class RateLimitError extends APIError<429, Headers> {} +export class RateLimitError extends APIError<429, Headers> { +} -export class InternalServerError extends APIError {} +export class InternalServerError extends APIError { +} diff --git a/src/core/pagination.ts b/src/core/pagination.ts index b4d1cfde..7d0da5e2 100644 --- a/src/core/pagination.ts +++ b/src/core/pagination.ts @@ -87,8 +87,7 @@ export class PagePromise< super( client, request, - async (client, props) => - new Page(client, props.response, await defaultParseResponse(client, props), props.options), + async (client, props) => new Page(client, props.response, await defaultParseResponse(client, props), props.options) ); } @@ -132,12 +131,7 @@ export class EntriesCursor extends AbstractPage implements EntriesCu page_info: EntriesCursorResponse.PageInfo; - constructor( - client: Knock, - response: Response, - body: EntriesCursorResponse, - options: FinalRequestOptions, - ) { + constructor(client: Knock, response: Response, body: EntriesCursorResponse, options: FinalRequestOptions) { super(client, response, body, options); this.entries = body.entries || []; @@ -149,7 +143,7 @@ export class EntriesCursor extends AbstractPage implements EntriesCu } nextPageRequestOptions(): PageRequestOptions | null { - const cursor = this.page_info?.after; + const cursor = this.page_info?.after if (!cursor) { return null; } @@ -189,12 +183,7 @@ export class ItemsCursor extends AbstractPage implements ItemsCursor page_info: ItemsCursorResponse.PageInfo; - constructor( - client: Knock, - response: Response, - body: ItemsCursorResponse, - options: FinalRequestOptions, - ) { + constructor(client: Knock, response: Response, body: ItemsCursorResponse, options: FinalRequestOptions) { super(client, response, body, options); this.items = body.items || []; @@ -206,7 +195,7 @@ export class ItemsCursor extends AbstractPage implements ItemsCursor } nextPageRequestOptions(): PageRequestOptions | null { - const cursor = this.page_info?.after; + const cursor = this.page_info?.after if (!cursor) { return null; } @@ -233,20 +222,12 @@ export interface SlackChannelsCursorParams { 'query_options.limit'?: number; } -export class SlackChannelsCursor - extends AbstractPage - implements SlackChannelsCursorResponse -{ +export class SlackChannelsCursor extends AbstractPage implements SlackChannelsCursorResponse { next_cursor: string; slack_channels: Array; - constructor( - client: Knock, - response: Response, - body: SlackChannelsCursorResponse, - options: FinalRequestOptions, - ) { + constructor(client: Knock, response: Response, body: SlackChannelsCursorResponse, options: FinalRequestOptions) { super(client, response, body, options); this.next_cursor = body.next_cursor || ''; @@ -258,7 +239,7 @@ export class SlackChannelsCursor } nextPageRequestOptions(): PageRequestOptions | null { - const cursor = this.next_cursor; + const cursor = this.next_cursor if (!cursor) { return null; } @@ -290,12 +271,7 @@ export class MsTeamsPagination extends AbstractPage implements MsTea ms_teams_teams: Array; - constructor( - client: Knock, - response: Response, - body: MsTeamsPaginationResponse, - options: FinalRequestOptions, - ) { + constructor(client: Knock, response: Response, body: MsTeamsPaginationResponse, options: FinalRequestOptions) { super(client, response, body, options); this.skip_token = body.skip_token || ''; @@ -307,7 +283,7 @@ export class MsTeamsPagination extends AbstractPage implements MsTea } nextPageRequestOptions(): PageRequestOptions | null { - const cursor = this.skip_token; + const cursor = this.skip_token if (!cursor) { return null; } diff --git a/src/error.ts b/src/error.ts index fc55f46c..d0832d34 100644 --- a/src/error.ts +++ b/src/error.ts @@ -1,2 +1,2 @@ /** @deprecated Import from ./core/error instead */ -export * from './core/error'; +export * from "./core/error" \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index ae4e92dc..ef9fda64 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,21 +6,7 @@ export { type Uploadable, toFile } from './core/uploads'; export { APIPromise } from './core/api-promise'; export { Knock, type ClientOptions } from './client'; export { PagePromise } from './core/pagination'; -export { - KnockError, - APIError, - APIConnectionError, - APIConnectionTimeoutError, - APIUserAbortError, - NotFoundError, - ConflictError, - RateLimitError, - BadRequestError, - AuthenticationError, - InternalServerError, - PermissionDeniedError, - UnprocessableEntityError, -} from './core/error'; +export { KnockError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError } from './core/error'; // Explicitly exported to follow pre-stainless implementation of this package. export { diff --git a/src/internal/builtin-types.ts b/src/internal/builtin-types.ts index c23d3bde..6059d5db 100644 --- a/src/internal/builtin-types.ts +++ b/src/internal/builtin-types.ts @@ -1,20 +1,23 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export type Fetch = (input: string | URL | Request, init?: RequestInit) => Promise; +export type Fetch = ( + input: string | URL | Request, + init?: RequestInit, +) => Promise /** * An alias to the builtin `RequestInit` type so we can * easily alias it in import statements if there are name clashes. - * - * https://developer.mozilla.org/docs/Web/API/RequestInit + * + * https://developer.mozilla.org/docs/Web/API/RequestInit */ type _RequestInit = RequestInit; /** * An alias to the builtin `Response` type so we can * easily alias it in import statements if there are name clashes. - * - * https://developer.mozilla.org/docs/Web/API/Response + * + * https://developer.mozilla.org/docs/Web/API/Response */ type _Response = Response; @@ -51,15 +54,7 @@ type _Array = Array; */ type _Record = Record; -export type { - _Array as Array, - _BodyInit as BodyInit, - _HeadersInit as HeadersInit, - _Record as Record, - _RequestInfo as RequestInfo, - _RequestInit as RequestInit, - _Response as Response, -}; +export type { _Array as Array, _BodyInit as BodyInit, _HeadersInit as HeadersInit, _Record as Record, _RequestInfo as RequestInfo, _RequestInit as RequestInit, _Response as Response }; /** * A copy of the builtin `EndingType` type as it isn't fully supported in certain diff --git a/src/internal/detect-platform.ts b/src/internal/detect-platform.ts index e82d95c9..394ede88 100644 --- a/src/internal/detect-platform.ts +++ b/src/internal/detect-platform.ts @@ -25,11 +25,7 @@ function getDetectedPlatform(): DetectedPlatform { if (typeof EdgeRuntime !== 'undefined') { return 'edge'; } - if ( - Object.prototype.toString.call( - typeof (globalThis as any).process !== 'undefined' ? (globalThis as any).process : 0, - ) === '[object process]' - ) { + if (Object.prototype.toString.call(typeof (globalThis as any).process !== 'undefined' ? (globalThis as any).process : 0) === '[object process]') { return 'node'; } return 'unknown'; diff --git a/src/internal/errors.ts b/src/internal/errors.ts index 82c7b14d..c14a742b 100644 --- a/src/internal/errors.ts +++ b/src/internal/errors.ts @@ -2,12 +2,12 @@ export function isAbortError(err: unknown) { return ( - typeof err === 'object' && - err !== null && - // Spec-compliant fetch implementations - (('name' in err && (err as any).name === 'AbortError') || + typeof err === 'object' && err !== null && ( + // Spec-compliant fetch implementations + ('name' in err && (err as any).name === 'AbortError') || // Expo fetch - ('message' in err && String((err as any).message).includes('FetchRequestCanceledException'))) + ('message' in err && String((err as any).message).includes('FetchRequestCanceledException')) + ) ); } @@ -24,10 +24,10 @@ export const castToError = (err: any): Error => { if (err.name) error.name = err.name; return error; } - } catch {} + } catch { } try { return new Error(JSON.stringify(err)); - } catch {} + } catch { } } return new Error(err); }; diff --git a/src/internal/headers.ts b/src/internal/headers.ts index c724a9d2..fa2ea2b9 100644 --- a/src/internal/headers.ts +++ b/src/internal/headers.ts @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import { isReadonlyArray } from './utils/values'; +import { isReadonlyArray } from "./utils/values"; type HeaderValue = string | undefined | null; export type HeadersLike = @@ -51,7 +51,7 @@ function* iterateHeaders(headers: HeadersLike): IterableIterator(client: Knock, props: APIResponseProps): Promise { const { response, requestLogID, retryOfRequestLogID, startTime } = props; const body = await (async () => { + // fetch refuses to read the body when the status code is 204. if (response.status === 204) { return null as T; @@ -42,15 +43,6 @@ export async function defaultParseResponse(client: Knock, props: APIResponseP const text = await response.text(); return text as unknown as T; })(); - loggerFor(client).debug( - `[${requestLogID}] response parsed`, - formatRequestDetails({ - retryOfRequestLogID, - url: response.url, - status: response.status, - body, - durationMs: Date.now() - startTime, - }), - ); + loggerFor(client).debug(`[${requestLogID}] response parsed`, formatRequestDetails({ retryOfRequestLogID, url: response.url, status: response.status, body, durationMs: Date.now() - startTime })); return body; } diff --git a/src/internal/qs/utils.ts b/src/internal/qs/utils.ts index 4cd56579..f21d955b 100644 --- a/src/internal/qs/utils.ts +++ b/src/internal/qs/utils.ts @@ -62,7 +62,10 @@ export function merge( if (isArray(target)) { target.push(source); } else if (target && typeof target === 'object') { - if ((options && (options.plainObjects || options.allowPrototypes)) || !has(Object.prototype, source)) { + if ( + (options && (options.plainObjects || options.allowPrototypes)) || + !has(Object.prototype, source) + ) { target[source] = true; } } else { diff --git a/src/internal/request-options.ts b/src/internal/request-options.ts index 2aabf9aa..a8558b20 100644 --- a/src/internal/request-options.ts +++ b/src/internal/request-options.ts @@ -76,10 +76,14 @@ export type RequestOptions = { defaultBaseURL?: string | undefined; __binaryResponse?: boolean | undefined; + }; export type EncodedContent = { bodyHeaders: HeadersLike; body: BodyInit }; -export type RequestEncoder = (request: { headers: NullableHeaders; body: unknown }) => EncodedContent; +export type RequestEncoder = (request: { + headers: NullableHeaders; + body: unknown; +}) => EncodedContent; export const FallbackEncoder: RequestEncoder = ({ headers, body }) => { return { diff --git a/src/internal/shim-types.ts b/src/internal/shim-types.ts index 8ddf7b0a..accbf576 100644 --- a/src/internal/shim-types.ts +++ b/src/internal/shim-types.ts @@ -19,8 +19,8 @@ type _ConditionalNodeReadableStream = typeof globalThis extends { ReadableStream: any } ? never : _NodeReadableStream; type _ReadableStream = NeverToAny< - | ([0] extends [1 & _DOMReadableStream] ? never : _DOMReadableStream) - | ([0] extends [1 & _ConditionalNodeReadableStream] ? never : _ConditionalNodeReadableStream) + ([0] extends [1 & _DOMReadableStream] ? never : _DOMReadableStream) | + ([0] extends [1 & _ConditionalNodeReadableStream] ? never : _ConditionalNodeReadableStream) >; export type { _ReadableStream as ReadableStream }; diff --git a/src/internal/shims.ts b/src/internal/shims.ts index a1594527..58e10ff6 100644 --- a/src/internal/shims.ts +++ b/src/internal/shims.ts @@ -27,9 +27,7 @@ export function makeReadableStream(...args: ReadableStreamArgs): ReadableStream if (typeof ReadableStream === 'undefined') { // Note: All of the platforms / runtimes we officially support already define // `ReadableStream` as a global, so this should only ever be hit on unsupported runtimes. - throw new Error( - '`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`', - ); + throw new Error('`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`'); } return new ReadableStream(...args); diff --git a/src/internal/to-file.ts b/src/internal/to-file.ts index 30eada32..c72a2b41 100644 --- a/src/internal/to-file.ts +++ b/src/internal/to-file.ts @@ -1,4 +1,4 @@ -import { BlobPart, getName, makeFile, isAsyncIterable } from './uploads'; +import { BlobPart, getName, makeFile, isAsyncIterable } from "./uploads"; import type { FilePropertyBag } from './builtin-types'; import { checkFileSupport } from './uploads'; @@ -65,11 +65,8 @@ const isResponseLike = (value: any): value is ResponseLike => typeof value.url === 'string' && typeof value.blob === 'function'; -export type ToFileInput = - | FileLike - | ResponseLike - | Exclude - | AsyncIterable; +export type ToFileInput = FileLike | ResponseLike | Exclude | AsyncIterable; + /** * Helper for creating a {@link File} to pass to an SDK upload method from a variety of different data formats @@ -119,7 +116,9 @@ export async function toFile( return makeFile(parts, name, options); } -async function getBytes(value: BlobLikePart | AsyncIterable): Promise> { +async function getBytes( + value: BlobLikePart | AsyncIterable, +): Promise> { let parts: Array = []; if ( typeof value === 'string' || @@ -152,3 +151,4 @@ function propsForError(value: unknown): string { const props = Object.getOwnPropertyNames(value); return `; props: [${props.map((p) => `"${p}"`).join(', ')}]`; } + diff --git a/src/internal/types.ts b/src/internal/types.ts index b668dfc0..c45fee32 100644 --- a/src/internal/types.ts +++ b/src/internal/types.ts @@ -7,40 +7,34 @@ export type KeysEnum = { [P in keyof Required]: true }; export type FinalizedRequestInit = RequestInit & { headers: Headers }; -type NotAny = [0] extends [1 & T] ? never : T; +type NotAny = [0] extends [(1 & T)] ? never : T; /** * Some environments overload the global fetch function, and Parameters only gets the last signature. */ -type OverloadedParameters = - T extends ( - { +type OverloadedParameters = T extends { + (...args: infer A): unknown; + (...args: infer B): unknown; + (...args: infer C): unknown; + (...args: infer D): unknown; +} + ? A | B | C | D + : T extends { (...args: infer A): unknown; (...args: infer B): unknown; (...args: infer C): unknown; - (...args: infer D): unknown; } - ) ? - A | B | C | D - : T extends ( - { - (...args: infer A): unknown; - (...args: infer B): unknown; - (...args: infer C): unknown; - } - ) ? - A | B | C - : T extends ( - { + ? A | B | C + : T extends { (...args: infer A): unknown; (...args: infer B): unknown; } - ) ? - A | B - : T extends (...args: infer A) => unknown ? A + ? A | B + : T extends (...args: infer A) => unknown + ? A : never; -/* eslint-disable */ + /** * These imports attempt to get types from a parent package's dependencies. * Unresolved bare specifiers can trigger [automatic type acquisition][1] in some projects, which @@ -63,19 +57,19 @@ type OverloadedParameters = * * [1]: https://www.typescriptlang.org/tsconfig/#typeAcquisition */ -/** @ts-ignore For users with \@types/node */ +/** @ts-ignore For users with \@types/node */ /* prettier-ignore */ type UndiciTypesRequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users with undici */ +/** @ts-ignore For users with undici */ /* prettier-ignore */ type UndiciRequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users with \@types/bun */ +/** @ts-ignore For users with \@types/bun */ /* prettier-ignore */ type BunRequestInit = globalThis.FetchRequestInit; -/** @ts-ignore For users with node-fetch@2 */ +/** @ts-ignore For users with node-fetch@2 */ /* prettier-ignore */ type NodeFetch2RequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */ +/** @ts-ignore For users with node-fetch@3, doesn't need file extension because types are at ./@types/index.d.ts */ /* prettier-ignore */ type NodeFetch3RequestInit = NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny | NotAny; -/** @ts-ignore For users who use Deno */ +/** @ts-ignore For users who use Deno */ /* prettier-ignore */ type FetchRequestInit = NonNullable[1]>; -/* eslint-enable */ + type RequestInits = | NotAny diff --git a/src/internal/utils/log.ts b/src/internal/utils/log.ts index a7e59d3a..630d7fd4 100644 --- a/src/internal/utils/log.ts +++ b/src/internal/utils/log.ts @@ -4,7 +4,7 @@ import { hasOwn } from './values'; import { type Knock } from '../../client'; import { RequestOptions } from '../request-options'; -type LogFn = (message: string, ...rest: unknown[]) => void; +type LogFn = (message: string, ...rest: unknown[]) => void export type Logger = { error: LogFn; warn: LogFn; @@ -21,22 +21,14 @@ const levelNumbers = { debug: 500, }; -export const parseLogLevel = ( - maybeLevel: string | undefined, - sourceName: string, - client: Knock, -): LogLevel | undefined => { +export const parseLogLevel = (maybeLevel: string | undefined, sourceName: string, client: Knock): LogLevel | undefined => { if (!maybeLevel) { return undefined; } if (hasOwn(levelNumbers, maybeLevel)) { return maybeLevel; - } - loggerFor(client).warn( - `${sourceName} was set to ${JSON.stringify(maybeLevel)}, expected one of ${JSON.stringify( - Object.keys(levelNumbers), - )}`, - ); + }; + loggerFor(client).warn(`${sourceName} was set to ${JSON.stringify(maybeLevel)}, expected one of ${JSON.stringify(Object.keys(levelNumbers))}`); return undefined; }; @@ -97,24 +89,11 @@ export const formatRequestDetails = (details: { body?: unknown; }) => { if (details.options) { - details.options = { ...details.options }; + details.options = {...details.options}; delete details.options['headers']; // redundant + leaks internals } if (details.headers) { - details.headers = Object.fromEntries( - (details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map( - ([name, value]) => [ - name, - ( - name.toLowerCase() === 'authorization' || - name.toLowerCase() === 'cookie' || - name.toLowerCase() === 'set-cookie' - ) ? - '***' - : value, - ], - ), - ); + details.headers = Object.fromEntries((details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map(([name, value]) => [name, name.toLowerCase() === 'authorization' || name.toLowerCase() === 'cookie' || name.toLowerCase() === 'set-cookie' ? '***' : value])) } if ('retryOfRequestLogID' in details) { if (details.retryOfRequestLogID) { @@ -122,5 +101,5 @@ export const formatRequestDetails = (details: { } delete details.retryOfRequestLogID; } - return details; -}; + return details +} diff --git a/src/internal/utils/uuid.ts b/src/internal/utils/uuid.ts index b0e53aaf..53708ba6 100644 --- a/src/internal/utils/uuid.ts +++ b/src/internal/utils/uuid.ts @@ -10,8 +10,10 @@ export let uuid4 = function () { return crypto.randomUUID(); } const u8 = new Uint8Array(1); - const randomByte = crypto ? () => crypto.getRandomValues(u8)[0]! : () => (Math.random() * 0xff) & 0xff; - return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => + const randomByte = crypto + ? () => crypto.getRandomValues(u8)[0]! + : () => (Math.random() * 0xff) & 0xff; + return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) => (+c ^ (randomByte() & (15 >> (+c / 4)))).toString(16), ); -}; +} diff --git a/src/pagination.ts b/src/pagination.ts index 90bf015e..e1e5d091 100644 --- a/src/pagination.ts +++ b/src/pagination.ts @@ -1,2 +1,2 @@ /** @deprecated Import from ./core/pagination instead */ -export * from './core/pagination'; +export * from "./core/pagination" \ No newline at end of file diff --git a/src/resource.ts b/src/resource.ts index 363e3516..57a27a94 100644 --- a/src/resource.ts +++ b/src/resource.ts @@ -1,2 +1,2 @@ /** @deprecated Import from ./core/resource instead */ -export * from './core/resource'; +export * from "./core/resource" \ No newline at end of file diff --git a/src/resources/audiences.ts b/src/resources/audiences.ts index d71ba579..c0dd8699 100644 --- a/src/resources/audiences.ts +++ b/src/resources/audiences.ts @@ -32,13 +32,8 @@ export class Audiences extends APIResource { * ``` */ addMembers(key: string, params: AudienceAddMembersParams, options?: RequestOptions): APIPromise { - const { create_audience, ...body } = params; - return this._client.post(path`/v1/audiences/${key}/members`, { - query: { create_audience }, - body, - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + const { create_audience, ...body } = params + return this._client.post(path`/v1/audiences/${key}/members`, { query: { create_audience }, body, ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } /** @@ -64,11 +59,7 @@ export class Audiences extends APIResource { * ``` */ removeMembers(key: string, body: AudienceRemoveMembersParams, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/audiences/${key}/members`, { - body, - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + return this._client.delete(path`/v1/audiences/${key}/members`, { body, ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } } @@ -185,6 +176,6 @@ export declare namespace Audiences { type AudienceMember as AudienceMember, type AudienceListMembersResponse as AudienceListMembersResponse, type AudienceAddMembersParams as AudienceAddMembersParams, - type AudienceRemoveMembersParams as AudienceRemoveMembersParams, + type AudienceRemoveMembersParams as AudienceRemoveMembersParams }; } diff --git a/src/resources/bulk-operations.ts b/src/resources/bulk-operations.ts index 1c0b583b..ad1184ad 100644 --- a/src/resources/bulk-operations.ts +++ b/src/resources/bulk-operations.ts @@ -119,5 +119,7 @@ export namespace BulkOperation { } export declare namespace BulkOperations { - export { type BulkOperation as BulkOperation }; + export { + type BulkOperation as BulkOperation + }; } diff --git a/src/resources/channels/bulk.ts b/src/resources/channels/bulk.ts index fca735b5..b241a5f2 100644 --- a/src/resources/channels/bulk.ts +++ b/src/resources/channels/bulk.ts @@ -37,22 +37,7 @@ export class Bulk extends APIResource { * ); * ``` */ - updateMessageStatus( - channelID: string, - action: - | 'seen' - | 'unseen' - | 'read' - | 'unread' - | 'archived' - | 'unarchived' - | 'interacted' - | 'archive' - | 'unarchive' - | 'delete', - body: BulkUpdateMessageStatusParams, - options?: RequestOptions, - ): APIPromise { + updateMessageStatus(channelID: string, action: 'seen' | 'unseen' | 'read' | 'unread' | 'archived' | 'unarchived' | 'interacted' | 'archive' | 'unarchive' | 'delete', body: BulkUpdateMessageStatusParams, options?: RequestOptions): APIPromise { return this._client.post(path`/v1/channels/${channelID}/messages/bulk/${action}`, { body, ...options }); } } @@ -66,27 +51,12 @@ export interface BulkUpdateMessageStatusParams { /** * Limits the results to messages with the given delivery status. */ - delivery_status?: - | 'queued' - | 'sent' - | 'delivered' - | 'delivery_attempted' - | 'undelivered' - | 'not_sent' - | 'bounced'; + delivery_status?: 'queued' | 'sent' | 'delivered' | 'delivery_attempted' | 'undelivered' | 'not_sent' | 'bounced'; /** * Limits the results to messages with the given engagement status. */ - engagement_status?: - | 'seen' - | 'unseen' - | 'read' - | 'unread' - | 'archived' - | 'unarchived' - | 'link_clicked' - | 'interacted'; + engagement_status?: 'seen' | 'unseen' | 'read' | 'unread' | 'archived' | 'unarchived' | 'link_clicked' | 'interacted'; /** * Limits the results to messages that have a tenant or not. @@ -127,5 +97,7 @@ export interface BulkUpdateMessageStatusParams { } export declare namespace Bulk { - export { type BulkUpdateMessageStatusParams as BulkUpdateMessageStatusParams }; + export { + type BulkUpdateMessageStatusParams as BulkUpdateMessageStatusParams + }; } diff --git a/src/resources/channels/channels.ts b/src/resources/channels/channels.ts index 83c63b9a..a8e27ead 100644 --- a/src/resources/channels/channels.ts +++ b/src/resources/channels/channels.ts @@ -11,5 +11,8 @@ export class Channels extends APIResource { Channels.Bulk = Bulk; export declare namespace Channels { - export { Bulk as Bulk, type BulkUpdateMessageStatusParams as BulkUpdateMessageStatusParams }; + export { + Bulk as Bulk, + type BulkUpdateMessageStatusParams as BulkUpdateMessageStatusParams + }; } diff --git a/src/resources/channels/index.ts b/src/resources/channels/index.ts index e8be38eb..cfcf1604 100644 --- a/src/resources/channels/index.ts +++ b/src/resources/channels/index.ts @@ -1,4 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Bulk, type BulkUpdateMessageStatusParams } from './bulk'; -export { Channels } from './channels'; +export { Bulk, type BulkUpdateMessageStatusParams } from './bulk';; +export { Channels } from './channels';; diff --git a/src/resources/index.ts b/src/resources/index.ts index baa8c0b8..6d4d32b2 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,109 +1,16 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export * from './shared'; -export { - Audiences, - type AudienceMember, - type AudienceListMembersResponse, - type AudienceAddMembersParams, - type AudienceRemoveMembersParams, -} from './audiences'; -export { BulkOperations, type BulkOperation } from './bulk-operations'; -export { Channels } from './channels/channels'; -export { Integrations } from './integrations/integrations'; -export { - Messages, - type Activity, - type Message, - type MessageDeliveryLog, - type MessageEvent, - type MessageGetContentResponse, - type MessageListParams, - type MessageListActivitiesParams, - type MessageListDeliveryLogsParams, - type MessageListEventsParams, - type MessageMarkAsInteractedParams, - type MessagesItemsCursor, - type ActivitiesItemsCursor, - type MessageDeliveryLogsItemsCursor, - type MessageEventsItemsCursor, -} from './messages/messages'; -export { - Objects, - type InlineObjectRequest, - type Object, - type ObjectAddSubscriptionsResponse, - type ObjectDeleteSubscriptionsResponse, - type ObjectListPreferencesResponse, - type ObjectListParams, - type ObjectAddSubscriptionsParams, - type ObjectDeleteSubscriptionsParams, - type ObjectListMessagesParams, - type ObjectListSchedulesParams, - type ObjectListSubscriptionsParams, - type ObjectSetParams, - type ObjectSetChannelDataParams, - type ObjectSetPreferencesParams, - type ObjectsEntriesCursor, -} from './objects/objects'; -export { Providers } from './providers/providers'; -export { - Recipients, - type Recipient, - type RecipientReference, - type RecipientRequest, -} from './recipients/recipients'; -export { - Schedules, - type Schedule, - type ScheduleRepeatRule, - type ScheduleCreateResponse, - type ScheduleUpdateResponse, - type ScheduleDeleteResponse, - type ScheduleCreateParams, - type ScheduleUpdateParams, - type ScheduleListParams, - type ScheduleDeleteParams, - type SchedulesEntriesCursor, -} from './schedules/schedules'; -export { - Tenants, - type InlineTenantRequest, - type Tenant, - type TenantRequest, - type TenantListParams, - type TenantGetParams, - type TenantSetParams, - type TenantsEntriesCursor, -} from './tenants/tenants'; -export { - Users, - type IdentifyUserRequest, - type InlineIdentifyUserRequest, - type User, - type UserListPreferencesResponse, - type UserUpdateParams, - type UserListParams, - type UserGetPreferencesParams, - type UserListMessagesParams, - type UserListSchedulesParams, - type UserListSubscriptionsParams, - type UserMergeParams, - type UserSetChannelDataParams, - type UserSetPreferencesParams, - type UsersEntriesCursor, -} from './users/users'; -export { - WorkflowRecipientRuns, - type WorkflowRecipientRun, - type WorkflowRecipientRunDetail, - type WorkflowRecipientRunEvent, - type WorkflowRecipientRunListParams, - type WorkflowRecipientRunsItemsCursor, -} from './workflow-recipient-runs'; -export { - Workflows, - type WorkflowTriggerResponse, - type WorkflowCancelParams, - type WorkflowTriggerParams, -} from './workflows'; +export * from './shared';; +export { Audiences, type AudienceMember, type AudienceListMembersResponse, type AudienceAddMembersParams, type AudienceRemoveMembersParams } from './audiences';; +export { BulkOperations, type BulkOperation } from './bulk-operations';; +export { Channels } from './channels/channels';; +export { Integrations } from './integrations/integrations';; +export { Messages, type Activity, type Message, type MessageDeliveryLog, type MessageEvent, type MessageGetContentResponse, type MessageListParams, type MessageListActivitiesParams, type MessageListDeliveryLogsParams, type MessageListEventsParams, type MessageMarkAsInteractedParams, type MessagesItemsCursor, type ActivitiesItemsCursor, type MessageDeliveryLogsItemsCursor, type MessageEventsItemsCursor } from './messages/messages';; +export { Objects, type InlineObjectRequest, type Object, type ObjectAddSubscriptionsResponse, type ObjectDeleteSubscriptionsResponse, type ObjectListPreferencesResponse, type ObjectListParams, type ObjectAddSubscriptionsParams, type ObjectDeleteSubscriptionsParams, type ObjectListMessagesParams, type ObjectListSchedulesParams, type ObjectListSubscriptionsParams, type ObjectSetParams, type ObjectSetChannelDataParams, type ObjectSetPreferencesParams, type ObjectsEntriesCursor } from './objects/objects';; +export { Providers } from './providers/providers';; +export { Recipients, type Recipient, type RecipientReference, type RecipientRequest } from './recipients/recipients';; +export { Schedules, type Schedule, type ScheduleRepeatRule, type ScheduleCreateResponse, type ScheduleUpdateResponse, type ScheduleDeleteResponse, type ScheduleCreateParams, type ScheduleUpdateParams, type ScheduleListParams, type ScheduleDeleteParams, type SchedulesEntriesCursor } from './schedules/schedules';; +export { Tenants, type InlineTenantRequest, type Tenant, type TenantRequest, type TenantListParams, type TenantGetParams, type TenantSetParams, type TenantsEntriesCursor } from './tenants/tenants';; +export { Users, type IdentifyUserRequest, type InlineIdentifyUserRequest, type User, type UserListPreferencesResponse, type UserUpdateParams, type UserListParams, type UserGetPreferencesParams, type UserListMessagesParams, type UserListSchedulesParams, type UserListSubscriptionsParams, type UserMergeParams, type UserSetChannelDataParams, type UserSetPreferencesParams, type UsersEntriesCursor } from './users/users';; +export { WorkflowRecipientRuns, type WorkflowRecipientRun, type WorkflowRecipientRunDetail, type WorkflowRecipientRunEvent, type WorkflowRecipientRunListParams, type WorkflowRecipientRunsItemsCursor } from './workflow-recipient-runs';; +export { Workflows, type WorkflowTriggerResponse, type WorkflowCancelParams, type WorkflowTriggerParams } from './workflows';; diff --git a/src/resources/integrations/census.ts b/src/resources/integrations/census.ts index 5ffe3d09..4c85e3c5 100644 --- a/src/resources/integrations/census.ts +++ b/src/resources/integrations/census.ts @@ -8,10 +8,7 @@ export class Census extends APIResource { /** * Processes a Census custom destination RPC request. */ - customDestination( - body: CensusCustomDestinationParams, - options?: RequestOptions, - ): APIPromise { + customDestination(body: CensusCustomDestinationParams, options?: RequestOptions): APIPromise { return this._client.post('/v1/integrations/census/custom-destination', { body, ...options }); } } @@ -53,6 +50,6 @@ export interface CensusCustomDestinationParams { export declare namespace Census { export { type CensusCustomDestinationResponse as CensusCustomDestinationResponse, - type CensusCustomDestinationParams as CensusCustomDestinationParams, + type CensusCustomDestinationParams as CensusCustomDestinationParams }; } diff --git a/src/resources/integrations/hightouch.ts b/src/resources/integrations/hightouch.ts index d32bafa0..d425a562 100644 --- a/src/resources/integrations/hightouch.ts +++ b/src/resources/integrations/hightouch.ts @@ -8,10 +8,7 @@ export class Hightouch extends APIResource { /** * Processes a Hightouch embedded destination RPC request. */ - embeddedDestination( - body: HightouchEmbeddedDestinationParams, - options?: RequestOptions, - ): APIPromise { + embeddedDestination(body: HightouchEmbeddedDestinationParams, options?: RequestOptions): APIPromise { return this._client.post('/v1/integrations/hightouch/embedded-destination', { body, ...options }); } } @@ -53,6 +50,6 @@ export interface HightouchEmbeddedDestinationParams { export declare namespace Hightouch { export { type HightouchEmbeddedDestinationResponse as HightouchEmbeddedDestinationResponse, - type HightouchEmbeddedDestinationParams as HightouchEmbeddedDestinationParams, + type HightouchEmbeddedDestinationParams as HightouchEmbeddedDestinationParams }; } diff --git a/src/resources/integrations/index.ts b/src/resources/integrations/index.ts index 9231ec9c..7464a8cf 100644 --- a/src/resources/integrations/index.ts +++ b/src/resources/integrations/index.ts @@ -1,9 +1,5 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Census, type CensusCustomDestinationResponse, type CensusCustomDestinationParams } from './census'; -export { - Hightouch, - type HightouchEmbeddedDestinationResponse, - type HightouchEmbeddedDestinationParams, -} from './hightouch'; -export { Integrations } from './integrations'; +export { Census, type CensusCustomDestinationResponse, type CensusCustomDestinationParams } from './census';; +export { Hightouch, type HightouchEmbeddedDestinationResponse, type HightouchEmbeddedDestinationParams } from './hightouch';; +export { Integrations } from './integrations';; diff --git a/src/resources/integrations/integrations.ts b/src/resources/integrations/integrations.ts index 9e88a215..4b1a7259 100644 --- a/src/resources/integrations/integrations.ts +++ b/src/resources/integrations/integrations.ts @@ -4,11 +4,7 @@ import { APIResource } from '../../core/resource'; import * as CensusAPI from './census'; import { Census, CensusCustomDestinationParams, CensusCustomDestinationResponse } from './census'; import * as HightouchAPI from './hightouch'; -import { - Hightouch, - HightouchEmbeddedDestinationParams, - HightouchEmbeddedDestinationResponse, -} from './hightouch'; +import { Hightouch, HightouchEmbeddedDestinationParams, HightouchEmbeddedDestinationResponse } from './hightouch'; export class Integrations extends APIResource { census: CensusAPI.Census = new CensusAPI.Census(this._client); @@ -22,12 +18,12 @@ export declare namespace Integrations { export { Census as Census, type CensusCustomDestinationResponse as CensusCustomDestinationResponse, - type CensusCustomDestinationParams as CensusCustomDestinationParams, + type CensusCustomDestinationParams as CensusCustomDestinationParams }; export { Hightouch as Hightouch, type HightouchEmbeddedDestinationResponse as HightouchEmbeddedDestinationResponse, - type HightouchEmbeddedDestinationParams as HightouchEmbeddedDestinationParams, + type HightouchEmbeddedDestinationParams as HightouchEmbeddedDestinationParams }; } diff --git a/src/resources/messages/batch.ts b/src/resources/messages/batch.ts index a07e5c2c..0af45136 100644 --- a/src/resources/messages/batch.ts +++ b/src/resources/messages/batch.ts @@ -57,10 +57,7 @@ export class Batch extends APIResource { * }); * ``` */ - markAsInteracted( - body: BatchMarkAsInteractedParams, - options?: RequestOptions, - ): APIPromise { + markAsInteracted(body: BatchMarkAsInteractedParams, options?: RequestOptions): APIPromise { return this._client.post('/v1/messages/batch/interacted', { body, ...options }); } @@ -116,10 +113,7 @@ export class Batch extends APIResource { * }); * ``` */ - markAsUnread( - body: BatchMarkAsUnreadParams, - options?: RequestOptions, - ): APIPromise { + markAsUnread(body: BatchMarkAsUnreadParams, options?: RequestOptions): APIPromise { return this._client.post('/v1/messages/batch/unread', { body, ...options }); } @@ -138,10 +132,7 @@ export class Batch extends APIResource { * }); * ``` */ - markAsUnseen( - body: BatchMarkAsUnseenParams, - options?: RequestOptions, - ): APIPromise { + markAsUnseen(body: BatchMarkAsUnseenParams, options?: RequestOptions): APIPromise { return this._client.post('/v1/messages/batch/unseen', { body, ...options }); } @@ -168,12 +159,12 @@ export class Batch extends APIResource { /** * The list of messages that were updated. */ -export type BatchArchiveResponse = Array; +export type BatchArchiveResponse = Array /** * A list of `MessageContents` */ -export type BatchGetContentResponse = Array; +export type BatchGetContentResponse = Array export namespace BatchGetContentResponse { /** @@ -188,12 +179,7 @@ export namespace BatchGetContentResponse { /** * Content data specific to the channel type. */ - data: - | BatchGetContentResponseItem.MessageEmailContent - | BatchGetContentResponseItem.MessageSMSContent - | BatchGetContentResponseItem.MessagePushContent - | BatchGetContentResponseItem.MessageChatContent - | BatchGetContentResponseItem.MessageInAppFeedContent; + data: BatchGetContentResponseItem.MessageEmailContent | BatchGetContentResponseItem.MessageSMSContent | BatchGetContentResponseItem.MessagePushContent | BatchGetContentResponseItem.MessageChatContent | BatchGetContentResponseItem.MessageInAppFeedContent; /** * Timestamp when the message content was created. @@ -388,10 +374,7 @@ export namespace BatchGetContentResponse { /** * The blocks of the message in an app feed. */ - blocks: Array< - | MessageInAppFeedContent.MessageInAppFeedContentBlock - | MessageInAppFeedContent.MessageInAppFeedButtonSetBlock - >; + blocks: Array; } export namespace MessageInAppFeedContent { @@ -468,32 +451,32 @@ export namespace BatchGetContentResponse { /** * The list of messages that were updated. */ -export type BatchMarkAsInteractedResponse = Array; +export type BatchMarkAsInteractedResponse = Array /** * The list of messages that were updated. */ -export type BatchMarkAsReadResponse = Array; +export type BatchMarkAsReadResponse = Array /** * The list of messages that were updated. */ -export type BatchMarkAsSeenResponse = Array; +export type BatchMarkAsSeenResponse = Array /** * The list of messages that were updated. */ -export type BatchMarkAsUnreadResponse = Array; +export type BatchMarkAsUnreadResponse = Array /** * The list of messages that were updated. */ -export type BatchMarkAsUnseenResponse = Array; +export type BatchMarkAsUnseenResponse = Array /** * The list of messages that were updated. */ -export type BatchUnarchiveResponse = Array; +export type BatchUnarchiveResponse = Array export interface BatchArchiveParams { /** @@ -573,6 +556,6 @@ export declare namespace Batch { type BatchMarkAsSeenParams as BatchMarkAsSeenParams, type BatchMarkAsUnreadParams as BatchMarkAsUnreadParams, type BatchMarkAsUnseenParams as BatchMarkAsUnseenParams, - type BatchUnarchiveParams as BatchUnarchiveParams, + type BatchUnarchiveParams as BatchUnarchiveParams }; } diff --git a/src/resources/messages/index.ts b/src/resources/messages/index.ts index a7019813..1bf66d98 100644 --- a/src/resources/messages/index.ts +++ b/src/resources/messages/index.ts @@ -1,38 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { - Batch, - type BatchArchiveResponse, - type BatchGetContentResponse, - type BatchMarkAsInteractedResponse, - type BatchMarkAsReadResponse, - type BatchMarkAsSeenResponse, - type BatchMarkAsUnreadResponse, - type BatchMarkAsUnseenResponse, - type BatchUnarchiveResponse, - type BatchArchiveParams, - type BatchGetContentParams, - type BatchMarkAsInteractedParams, - type BatchMarkAsReadParams, - type BatchMarkAsSeenParams, - type BatchMarkAsUnreadParams, - type BatchMarkAsUnseenParams, - type BatchUnarchiveParams, -} from './batch'; -export { - Messages, - type Activity, - type Message, - type MessageDeliveryLog, - type MessageEvent, - type MessageGetContentResponse, - type MessageListParams, - type MessageListActivitiesParams, - type MessageListDeliveryLogsParams, - type MessageListEventsParams, - type MessageMarkAsInteractedParams, - type MessagesItemsCursor, - type ActivitiesItemsCursor, - type MessageDeliveryLogsItemsCursor, - type MessageEventsItemsCursor, -} from './messages'; +export { Batch, type BatchArchiveResponse, type BatchGetContentResponse, type BatchMarkAsInteractedResponse, type BatchMarkAsReadResponse, type BatchMarkAsSeenResponse, type BatchMarkAsUnreadResponse, type BatchMarkAsUnseenResponse, type BatchUnarchiveResponse, type BatchArchiveParams, type BatchGetContentParams, type BatchMarkAsInteractedParams, type BatchMarkAsReadParams, type BatchMarkAsSeenParams, type BatchMarkAsUnreadParams, type BatchMarkAsUnseenParams, type BatchUnarchiveParams } from './batch';; +export { Messages, type Activity, type Message, type MessageDeliveryLog, type MessageEvent, type MessageGetContentResponse, type MessageListParams, type MessageListActivitiesParams, type MessageListDeliveryLogsParams, type MessageListEventsParams, type MessageMarkAsInteractedParams, type MessagesItemsCursor, type ActivitiesItemsCursor, type MessageDeliveryLogsItemsCursor, type MessageEventsItemsCursor } from './messages';; diff --git a/src/resources/messages/messages.ts b/src/resources/messages/messages.ts index 2358a81a..7018ec38 100644 --- a/src/resources/messages/messages.ts +++ b/src/resources/messages/messages.ts @@ -2,25 +2,7 @@ import { APIResource } from '../../core/resource'; import * as BatchAPI from './batch'; -import { - Batch, - BatchArchiveParams, - BatchArchiveResponse, - BatchGetContentParams, - BatchGetContentResponse, - BatchMarkAsInteractedParams, - BatchMarkAsInteractedResponse, - BatchMarkAsReadParams, - BatchMarkAsReadResponse, - BatchMarkAsSeenParams, - BatchMarkAsSeenResponse, - BatchMarkAsUnreadParams, - BatchMarkAsUnreadResponse, - BatchMarkAsUnseenParams, - BatchMarkAsUnseenResponse, - BatchUnarchiveParams, - BatchUnarchiveResponse, -} from './batch'; +import { Batch, BatchArchiveParams, BatchArchiveResponse, BatchGetContentParams, BatchGetContentResponse, BatchMarkAsInteractedParams, BatchMarkAsInteractedResponse, BatchMarkAsReadParams, BatchMarkAsReadResponse, BatchMarkAsSeenParams, BatchMarkAsSeenResponse, BatchMarkAsUnreadParams, BatchMarkAsUnreadResponse, BatchMarkAsUnseenParams, BatchMarkAsUnseenResponse, BatchUnarchiveParams, BatchUnarchiveResponse } from './batch'; import * as RecipientsAPI from '../recipients/recipients'; import { APIPromise } from '../../core/api-promise'; import { ItemsCursor, type ItemsCursorParams, PagePromise } from '../../core/pagination'; @@ -44,10 +26,7 @@ export class Messages extends APIResource { * } * ``` */ - list( - query: MessageListParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { + list(query: MessageListParams | null | undefined = {}, options?: RequestOptions): PagePromise { return this._client.getAPIList('/v1/messages', ItemsCursor, { query, ...options }); } @@ -108,15 +87,8 @@ export class Messages extends APIResource { * } * ``` */ - listActivities( - messageID: string, - query: MessageListActivitiesParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList(path`/v1/messages/${messageID}/activities`, ItemsCursor, { - query, - ...options, - }); + listActivities(messageID: string, query: MessageListActivitiesParams | null | undefined = {}, options?: RequestOptions): PagePromise { + return this._client.getAPIList(path`/v1/messages/${messageID}/activities`, ItemsCursor, { query, ...options }); } /** @@ -132,16 +104,8 @@ export class Messages extends APIResource { * } * ``` */ - listDeliveryLogs( - messageID: string, - query: MessageListDeliveryLogsParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList( - path`/v1/messages/${messageID}/delivery_logs`, - ItemsCursor, - { query, ...options }, - ); + listDeliveryLogs(messageID: string, query: MessageListDeliveryLogsParams | null | undefined = {}, options?: RequestOptions): PagePromise { + return this._client.getAPIList(path`/v1/messages/${messageID}/delivery_logs`, ItemsCursor, { query, ...options }); } /** @@ -157,15 +121,8 @@ export class Messages extends APIResource { * } * ``` */ - listEvents( - messageID: string, - query: MessageListEventsParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList(path`/v1/messages/${messageID}/events`, ItemsCursor, { - query, - ...options, - }); + listEvents(messageID: string, query: MessageListEventsParams | null | undefined = {}, options?: RequestOptions): PagePromise { + return this._client.getAPIList(path`/v1/messages/${messageID}/events`, ItemsCursor, { query, ...options }); } /** @@ -182,11 +139,7 @@ export class Messages extends APIResource { * ); * ``` */ - markAsInteracted( - messageID: string, - body: MessageMarkAsInteractedParams | null | undefined = {}, - options?: RequestOptions, - ): APIPromise { + markAsInteracted(messageID: string, body: MessageMarkAsInteractedParams | null | undefined = {}, options?: RequestOptions): APIPromise { return this._client.put(path`/v1/messages/${messageID}/interacted`, { body, ...options }); } @@ -270,13 +223,13 @@ export class Messages extends APIResource { } } -export type MessagesItemsCursor = ItemsCursor; +export type MessagesItemsCursor = ItemsCursor -export type ActivitiesItemsCursor = ItemsCursor; +export type ActivitiesItemsCursor = ItemsCursor -export type MessageDeliveryLogsItemsCursor = ItemsCursor; +export type MessageDeliveryLogsItemsCursor = ItemsCursor -export type MessageEventsItemsCursor = ItemsCursor; +export type MessageEventsItemsCursor = ItemsCursor /** * An activity associated with a workflow trigger request. Messages produced after @@ -658,23 +611,7 @@ export interface MessageEvent { /** * The type of event that occurred. */ - type: - | 'message.archived' - | 'message.bounced' - | 'message.created' - | 'message.delivered' - | 'message.delivery_attempted' - | 'message.interacted' - | 'message.link_clicked' - | 'message.not_sent' - | 'message.queued' - | 'message.read' - | 'message.seen' - | 'message.sent' - | 'message.unarchived' - | 'message.undelivered' - | 'message.unread' - | 'message.unseen'; + type: 'message.archived' | 'message.bounced' | 'message.created' | 'message.delivered' | 'message.delivery_attempted' | 'message.interacted' | 'message.link_clicked' | 'message.not_sent' | 'message.queued' | 'message.read' | 'message.seen' | 'message.sent' | 'message.unarchived' | 'message.undelivered' | 'message.unread' | 'message.unseen'; /** * The data associated with the message event. Only present for some event types. @@ -694,12 +631,7 @@ export interface MessageGetContentResponse { /** * Content data specific to the channel type. */ - data: - | MessageGetContentResponse.MessageEmailContent - | MessageGetContentResponse.MessageSMSContent - | MessageGetContentResponse.MessagePushContent - | MessageGetContentResponse.MessageChatContent - | MessageGetContentResponse.MessageInAppFeedContent; + data: MessageGetContentResponse.MessageEmailContent | MessageGetContentResponse.MessageSMSContent | MessageGetContentResponse.MessagePushContent | MessageGetContentResponse.MessageChatContent | MessageGetContentResponse.MessageInAppFeedContent; /** * Timestamp when the message content was created. @@ -894,10 +826,7 @@ export namespace MessageGetContentResponse { /** * The blocks of the message in an app feed. */ - blocks: Array< - | MessageInAppFeedContent.MessageInAppFeedContentBlock - | MessageInAppFeedContent.MessageInAppFeedButtonSetBlock - >; + blocks: Array; } export namespace MessageInAppFeedContent { @@ -979,9 +908,7 @@ export interface MessageListParams extends ItemsCursorParams { /** * Limits the results to messages with the given engagement status. */ - engagement_status?: Array< - 'seen' | 'unseen' | 'read' | 'unread' | 'archived' | 'unarchived' | 'link_clicked' | 'interacted' - >; + engagement_status?: Array<'seen' | 'unseen' | 'read' | 'unread' | 'archived' | 'unarchived' | 'link_clicked' | 'interacted'>; inserted_at?: MessageListParams.InsertedAt; @@ -999,9 +926,7 @@ export interface MessageListParams extends ItemsCursorParams { /** * Limits the results to messages with the given delivery status. */ - status?: Array< - 'queued' | 'sent' | 'delivered' | 'delivery_attempted' | 'undelivered' | 'not_sent' | 'bounced' - >; + status?: Array<'queued' | 'sent' | 'delivered' | 'delivery_attempted' | 'undelivered' | 'not_sent' | 'bounced'>; /** * Limits the results to items with the corresponding tenant. @@ -1063,9 +988,11 @@ export interface MessageListActivitiesParams extends ItemsCursorParams { trigger_data?: string; } -export interface MessageListDeliveryLogsParams extends ItemsCursorParams {} +export interface MessageListDeliveryLogsParams extends ItemsCursorParams { +} -export interface MessageListEventsParams extends ItemsCursorParams {} +export interface MessageListEventsParams extends ItemsCursorParams { +} export interface MessageMarkAsInteractedParams { /** @@ -1091,7 +1018,7 @@ export declare namespace Messages { type MessageListActivitiesParams as MessageListActivitiesParams, type MessageListDeliveryLogsParams as MessageListDeliveryLogsParams, type MessageListEventsParams as MessageListEventsParams, - type MessageMarkAsInteractedParams as MessageMarkAsInteractedParams, + type MessageMarkAsInteractedParams as MessageMarkAsInteractedParams }; export { @@ -1111,6 +1038,6 @@ export declare namespace Messages { type BatchMarkAsSeenParams as BatchMarkAsSeenParams, type BatchMarkAsUnreadParams as BatchMarkAsUnreadParams, type BatchMarkAsUnseenParams as BatchMarkAsUnseenParams, - type BatchUnarchiveParams as BatchUnarchiveParams, + type BatchUnarchiveParams as BatchUnarchiveParams }; } diff --git a/src/resources/objects/bulk.ts b/src/resources/objects/bulk.ts index 36db4c04..3f780237 100644 --- a/src/resources/objects/bulk.ts +++ b/src/resources/objects/bulk.ts @@ -24,11 +24,7 @@ export class Bulk extends APIResource { * ); * ``` */ - delete( - collection: string, - body: BulkDeleteParams, - options?: RequestOptions, - ): APIPromise { + delete(collection: string, body: BulkDeleteParams, options?: RequestOptions): APIPromise { return this._client.post(path`/v1/objects/${collection}/bulk/delete`, { body, ...options }); } @@ -53,11 +49,7 @@ export class Bulk extends APIResource { * }); * ``` */ - addSubscriptions( - collection: string, - body: BulkAddSubscriptionsParams, - options?: RequestOptions, - ): APIPromise { + addSubscriptions(collection: string, body: BulkAddSubscriptionsParams, options?: RequestOptions): APIPromise { return this._client.post(path`/v1/objects/${collection}/bulk/subscriptions/add`, { body, ...options }); } @@ -91,11 +83,7 @@ export class Bulk extends APIResource { * ); * ``` */ - deleteSubscriptions( - collection: string, - body: BulkDeleteSubscriptionsParams, - options?: RequestOptions, - ): APIPromise { + deleteSubscriptions(collection: string, body: BulkDeleteSubscriptionsParams, options?: RequestOptions): APIPromise { return this._client.post(path`/v1/objects/${collection}/bulk/subscriptions/delete`, { body, ...options }); } @@ -110,11 +98,7 @@ export class Bulk extends APIResource { * ); * ``` */ - set( - collection: string, - body: BulkSetParams, - options?: RequestOptions, - ): APIPromise { + set(collection: string, body: BulkSetParams, options?: RequestOptions): APIPromise { return this._client.post(path`/v1/objects/${collection}/bulk/set`, { body, ...options }); } } @@ -220,7 +204,7 @@ export namespace BulkSetParams { */ preferences?: PreferencesAPI.InlinePreferenceSetRequest | null; - [k: string]: unknown; + [k: string]: unknown } } @@ -229,6 +213,6 @@ export declare namespace Bulk { type BulkDeleteParams as BulkDeleteParams, type BulkAddSubscriptionsParams as BulkAddSubscriptionsParams, type BulkDeleteSubscriptionsParams as BulkDeleteSubscriptionsParams, - type BulkSetParams as BulkSetParams, + type BulkSetParams as BulkSetParams }; } diff --git a/src/resources/objects/index.ts b/src/resources/objects/index.ts index 4a183921..0f329362 100644 --- a/src/resources/objects/index.ts +++ b/src/resources/objects/index.ts @@ -1,27 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { - Bulk, - type BulkDeleteParams, - type BulkAddSubscriptionsParams, - type BulkDeleteSubscriptionsParams, - type BulkSetParams, -} from './bulk'; -export { - Objects, - type InlineObjectRequest, - type Object, - type ObjectAddSubscriptionsResponse, - type ObjectDeleteSubscriptionsResponse, - type ObjectListPreferencesResponse, - type ObjectListParams, - type ObjectAddSubscriptionsParams, - type ObjectDeleteSubscriptionsParams, - type ObjectListMessagesParams, - type ObjectListSchedulesParams, - type ObjectListSubscriptionsParams, - type ObjectSetParams, - type ObjectSetChannelDataParams, - type ObjectSetPreferencesParams, - type ObjectsEntriesCursor, -} from './objects'; +export { Bulk, type BulkDeleteParams, type BulkAddSubscriptionsParams, type BulkDeleteSubscriptionsParams, type BulkSetParams } from './bulk';; +export { Objects, type InlineObjectRequest, type Object, type ObjectAddSubscriptionsResponse, type ObjectDeleteSubscriptionsResponse, type ObjectListPreferencesResponse, type ObjectListParams, type ObjectAddSubscriptionsParams, type ObjectDeleteSubscriptionsParams, type ObjectListMessagesParams, type ObjectListSchedulesParams, type ObjectListSubscriptionsParams, type ObjectSetParams, type ObjectSetChannelDataParams, type ObjectSetPreferencesParams, type ObjectsEntriesCursor } from './objects';; diff --git a/src/resources/objects/objects.ts b/src/resources/objects/objects.ts index 2862a4de..7903126a 100644 --- a/src/resources/objects/objects.ts +++ b/src/resources/objects/objects.ts @@ -5,13 +5,7 @@ import * as Shared from '../shared'; import * as MessagesAPI from '../messages/messages'; import { MessagesItemsCursor } from '../messages/messages'; import * as BulkAPI from './bulk'; -import { - Bulk, - BulkAddSubscriptionsParams, - BulkDeleteParams, - BulkDeleteSubscriptionsParams, - BulkSetParams, -} from './bulk'; +import { Bulk, BulkAddSubscriptionsParams, BulkDeleteParams, BulkDeleteSubscriptionsParams, BulkSetParams } from './bulk'; import * as ChannelDataAPI from '../recipients/channel-data'; import * as PreferencesAPI from '../recipients/preferences'; import * as RecipientsAPI from '../recipients/recipients'; @@ -20,13 +14,7 @@ import { SubscriptionsEntriesCursor } from '../recipients/subscriptions'; import * as SchedulesAPI from '../schedules/schedules'; import { SchedulesEntriesCursor } from '../schedules/schedules'; import { APIPromise } from '../../core/api-promise'; -import { - EntriesCursor, - type EntriesCursorParams, - ItemsCursor, - type ItemsCursorParams, - PagePromise, -} from '../../core/pagination'; +import { EntriesCursor, type EntriesCursorParams, ItemsCursor, type ItemsCursorParams, PagePromise } from '../../core/pagination'; import { buildHeaders } from '../../internal/headers'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; @@ -51,15 +39,8 @@ export class Objects extends APIResource { * } * ``` */ - list( - collection: string, - query: ObjectListParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList(path`/v1/objects/${collection}`, EntriesCursor, { - query, - ...options, - }); + list(collection: string, query: ObjectListParams | null | undefined = {}, options?: RequestOptions): PagePromise { + return this._client.getAPIList(path`/v1/objects/${collection}`, EntriesCursor, { query, ...options }); } /** @@ -72,10 +53,7 @@ export class Objects extends APIResource { * ``` */ delete(collection: string, id: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/objects/${collection}/${id}`, { - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + return this._client.delete(path`/v1/objects/${collection}/${id}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } /** @@ -96,12 +74,7 @@ export class Objects extends APIResource { * ); * ``` */ - addSubscriptions( - collection: string, - objectID: string, - body: ObjectAddSubscriptionsParams, - options?: RequestOptions, - ): APIPromise { + addSubscriptions(collection: string, objectID: string, body: ObjectAddSubscriptionsParams, options?: RequestOptions): APIPromise { return this._client.post(path`/v1/objects/${collection}/${objectID}/subscriptions`, { body, ...options }); } @@ -119,16 +92,8 @@ export class Objects extends APIResource { * ); * ``` */ - deleteSubscriptions( - collection: string, - objectID: string, - body: ObjectDeleteSubscriptionsParams, - options?: RequestOptions, - ): APIPromise { - return this._client.delete(path`/v1/objects/${collection}/${objectID}/subscriptions`, { - body, - ...options, - }); + deleteSubscriptions(collection: string, objectID: string, body: ObjectDeleteSubscriptionsParams, options?: RequestOptions): APIPromise { + return this._client.delete(path`/v1/objects/${collection}/${objectID}/subscriptions`, { body, ...options }); } /** @@ -156,12 +121,7 @@ export class Objects extends APIResource { * ); * ``` */ - getChannelData( - collection: string, - objectID: string, - channelID: string, - options?: RequestOptions, - ): APIPromise { + getChannelData(collection: string, objectID: string, channelID: string, options?: RequestOptions): APIPromise { return this._client.get(path`/v1/objects/${collection}/${objectID}/channel_data/${channelID}`, options); } @@ -177,12 +137,7 @@ export class Objects extends APIResource { * ); * ``` */ - getPreferences( - collection: string, - objectID: string, - id: string, - options?: RequestOptions, - ): APIPromise { + getPreferences(collection: string, objectID: string, id: string, options?: RequestOptions): APIPromise { return this._client.get(path`/v1/objects/${collection}/${objectID}/preferences/${id}`, options); } @@ -202,17 +157,8 @@ export class Objects extends APIResource { * } * ``` */ - listMessages( - collection: string, - id: string, - query: ObjectListMessagesParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList( - path`/v1/objects/${collection}/${id}/messages`, - ItemsCursor, - { query, ...options }, - ); + listMessages(collection: string, id: string, query: ObjectListMessagesParams | null | undefined = {}, options?: RequestOptions): PagePromise { + return this._client.getAPIList(path`/v1/objects/${collection}/${id}/messages`, ItemsCursor, { query, ...options }); } /** @@ -226,11 +172,7 @@ export class Objects extends APIResource { * ); * ``` */ - listPreferences( - collection: string, - objectID: string, - options?: RequestOptions, - ): APIPromise { + listPreferences(collection: string, objectID: string, options?: RequestOptions): APIPromise { return this._client.get(path`/v1/objects/${collection}/${objectID}/preferences`, options); } @@ -248,17 +190,8 @@ export class Objects extends APIResource { * } * ``` */ - listSchedules( - collection: string, - id: string, - query: ObjectListSchedulesParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList( - path`/v1/objects/${collection}/${id}/schedules`, - EntriesCursor, - { query, ...options }, - ); + listSchedules(collection: string, id: string, query: ObjectListSchedulesParams | null | undefined = {}, options?: RequestOptions): PagePromise { + return this._client.getAPIList(path`/v1/objects/${collection}/${id}/schedules`, EntriesCursor, { query, ...options }); } /** @@ -277,17 +210,8 @@ export class Objects extends APIResource { * } * ``` */ - listSubscriptions( - collection: string, - objectID: string, - query: ObjectListSubscriptionsParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList( - path`/v1/objects/${collection}/${objectID}/subscriptions`, - EntriesCursor, - { query, ...options }, - ); + listSubscriptions(collection: string, objectID: string, query: ObjectListSubscriptionsParams | null | undefined = {}, options?: RequestOptions): PagePromise { + return this._client.getAPIList(path`/v1/objects/${collection}/${objectID}/subscriptions`, EntriesCursor, { query, ...options }); } /** @@ -342,17 +266,8 @@ export class Objects extends APIResource { * ); * ``` */ - setChannelData( - collection: string, - objectID: string, - channelID: string, - body: ObjectSetChannelDataParams, - options?: RequestOptions, - ): APIPromise { - return this._client.put(path`/v1/objects/${collection}/${objectID}/channel_data/${channelID}`, { - body, - ...options, - }); + setChannelData(collection: string, objectID: string, channelID: string, body: ObjectSetChannelDataParams, options?: RequestOptions): APIPromise { + return this._client.put(path`/v1/objects/${collection}/${objectID}/channel_data/${channelID}`, { body, ...options }); } /** @@ -390,17 +305,8 @@ export class Objects extends APIResource { * ); * ``` */ - setPreferences( - collection: string, - objectID: string, - id: string, - body: ObjectSetPreferencesParams, - options?: RequestOptions, - ): APIPromise { - return this._client.put(path`/v1/objects/${collection}/${objectID}/preferences/${id}`, { - body, - ...options, - }); + setPreferences(collection: string, objectID: string, id: string, body: ObjectSetPreferencesParams, options?: RequestOptions): APIPromise { + return this._client.put(path`/v1/objects/${collection}/${objectID}/preferences/${id}`, { body, ...options }); } /** @@ -415,16 +321,8 @@ export class Objects extends APIResource { * ); * ``` */ - unsetChannelData( - collection: string, - objectID: string, - channelID: string, - options?: RequestOptions, - ): APIPromise { - return this._client.delete(path`/v1/objects/${collection}/${objectID}/channel_data/${channelID}`, { - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + unsetChannelData(collection: string, objectID: string, channelID: string, options?: RequestOptions): APIPromise { + return this._client.delete(path`/v1/objects/${collection}/${objectID}/channel_data/${channelID}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } /** @@ -439,20 +337,12 @@ export class Objects extends APIResource { * ); * ``` */ - unsetPreferences( - collection: string, - objectID: string, - id: string, - options?: RequestOptions, - ): APIPromise { - return this._client.delete(path`/v1/objects/${collection}/${objectID}/preferences/${id}`, { - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + unsetPreferences(collection: string, objectID: string, id: string, options?: RequestOptions): APIPromise { + return this._client.delete(path`/v1/objects/${collection}/${objectID}/preferences/${id}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } } -export type ObjectsEntriesCursor = EntriesCursor; +export type ObjectsEntriesCursor = EntriesCursor /** * A custom [Object](/concepts/objects) entity which belongs to a collection. @@ -490,7 +380,7 @@ export interface InlineObjectRequest { */ preferences?: PreferencesAPI.InlinePreferenceSetRequest | null; - [k: string]: unknown; +[k: string]: unknown } /** @@ -531,17 +421,17 @@ export interface Object { /** * A response containing a list of subscriptions. */ -export type ObjectAddSubscriptionsResponse = Array; +export type ObjectAddSubscriptionsResponse = Array /** * A response containing a list of subscriptions. */ -export type ObjectDeleteSubscriptionsResponse = Array; +export type ObjectDeleteSubscriptionsResponse = Array /** * A list of preference sets for the object */ -export type ObjectListPreferencesResponse = Array; +export type ObjectListPreferencesResponse = Array export interface ObjectListParams extends EntriesCursorParams { /** @@ -580,9 +470,7 @@ export interface ObjectListMessagesParams extends ItemsCursorParams { /** * Limits the results to messages with the given engagement status. */ - engagement_status?: Array< - 'seen' | 'unseen' | 'read' | 'unread' | 'archived' | 'unarchived' | 'link_clicked' | 'interacted' - >; + engagement_status?: Array<'seen' | 'unseen' | 'read' | 'unread' | 'archived' | 'unarchived' | 'link_clicked' | 'interacted'>; inserted_at?: ObjectListMessagesParams.InsertedAt; @@ -600,9 +488,7 @@ export interface ObjectListMessagesParams extends ItemsCursorParams { /** * Limits the results to messages with the given delivery status. */ - status?: Array< - 'queued' | 'sent' | 'delivered' | 'delivery_attempted' | 'undelivered' | 'not_sent' | 'bounced' - >; + status?: Array<'queued' | 'sent' | 'delivered' | 'delivery_attempted' | 'undelivered' | 'not_sent' | 'bounced'>; /** * Limits the results to items with the corresponding tenant. @@ -742,22 +628,14 @@ export interface ObjectSetParams { */ timezone?: string | null; - [k: string]: unknown; +[k: string]: unknown } export interface ObjectSetChannelDataParams { /** * Channel data for a given channel type. */ - data: - | ChannelDataAPI.PushChannelDataTokensOnly - | ChannelDataAPI.PushChannelDataDevicesOnly - | ChannelDataAPI.AwsSnsPushChannelDataTargetArnsOnly - | ChannelDataAPI.AwsSnsPushChannelDataDevicesOnly - | ChannelDataAPI.OneSignalChannelDataPlayerIDsOnly - | ChannelDataAPI.SlackChannelData - | ChannelDataAPI.MsTeamsChannelData - | ChannelDataAPI.DiscordChannelData; + data: ChannelDataAPI.PushChannelDataTokensOnly | ChannelDataAPI.PushChannelDataDevicesOnly | ChannelDataAPI.AwsSnsPushChannelDataTargetArnsOnly | ChannelDataAPI.AwsSnsPushChannelDataDevicesOnly | ChannelDataAPI.OneSignalChannelDataPlayerIDsOnly | ChannelDataAPI.SlackChannelData | ChannelDataAPI.MsTeamsChannelData | ChannelDataAPI.DiscordChannelData; } export interface ObjectSetPreferencesParams { @@ -771,9 +649,7 @@ export interface ObjectSetPreferencesParams { * An object where the key is the category and the values are the preference * settings for that category. */ - categories?: { - [key: string]: boolean | ObjectSetPreferencesParams.PreferenceSetWorkflowCategorySettingObject; - } | null; + categories?: { [key: string]: boolean | ObjectSetPreferencesParams.PreferenceSetWorkflowCategorySettingObject } | null; /** * Channel type preferences. @@ -795,9 +671,7 @@ export interface ObjectSetPreferencesParams { * An object where the key is the workflow key and the values are the preference * settings for that workflow. */ - workflows?: { - [key: string]: boolean | ObjectSetPreferencesParams.PreferenceSetWorkflowCategorySettingObject; - } | null; + workflows?: { [key: string]: boolean | ObjectSetPreferencesParams.PreferenceSetWorkflowCategorySettingObject } | null; } export namespace ObjectSetPreferencesParams { @@ -862,7 +736,7 @@ export declare namespace Objects { type ObjectListSubscriptionsParams as ObjectListSubscriptionsParams, type ObjectSetParams as ObjectSetParams, type ObjectSetChannelDataParams as ObjectSetChannelDataParams, - type ObjectSetPreferencesParams as ObjectSetPreferencesParams, + type ObjectSetPreferencesParams as ObjectSetPreferencesParams }; export { @@ -870,8 +744,8 @@ export declare namespace Objects { type BulkDeleteParams as BulkDeleteParams, type BulkAddSubscriptionsParams as BulkAddSubscriptionsParams, type BulkDeleteSubscriptionsParams as BulkDeleteSubscriptionsParams, - type BulkSetParams as BulkSetParams, + type BulkSetParams as BulkSetParams }; } -export { type MessagesItemsCursor, type SchedulesEntriesCursor, type SubscriptionsEntriesCursor }; +export { type MessagesItemsCursor, type SchedulesEntriesCursor, type SubscriptionsEntriesCursor } diff --git a/src/resources/providers/index.ts b/src/resources/providers/index.ts index 71820371..ea84dcbc 100644 --- a/src/resources/providers/index.ts +++ b/src/resources/providers/index.ts @@ -1,25 +1,5 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { - MsTeams, - type MsTeamCheckAuthResponse, - type MsTeamListChannelsResponse, - type MsTeamListTeamsResponse, - type MsTeamRevokeAccessResponse, - type MsTeamCheckAuthParams, - type MsTeamListChannelsParams, - type MsTeamListTeamsParams, - type MsTeamRevokeAccessParams, - type MsTeamListTeamsResponsesMsTeamsPagination, -} from './ms-teams'; -export { Providers } from './providers'; -export { - Slack, - type SlackCheckAuthResponse, - type SlackListChannelsResponse, - type SlackRevokeAccessResponse, - type SlackCheckAuthParams, - type SlackListChannelsParams, - type SlackRevokeAccessParams, - type SlackListChannelsResponsesSlackChannelsCursor, -} from './slack'; +export { MsTeams, type MsTeamCheckAuthResponse, type MsTeamListChannelsResponse, type MsTeamListTeamsResponse, type MsTeamRevokeAccessResponse, type MsTeamCheckAuthParams, type MsTeamListChannelsParams, type MsTeamListTeamsParams, type MsTeamRevokeAccessParams, type MsTeamListTeamsResponsesMsTeamsPagination } from './ms-teams';; +export { Providers } from './providers';; +export { Slack, type SlackCheckAuthResponse, type SlackListChannelsResponse, type SlackRevokeAccessResponse, type SlackCheckAuthParams, type SlackListChannelsParams, type SlackRevokeAccessParams, type SlackListChannelsResponsesSlackChannelsCursor } from './slack';; diff --git a/src/resources/providers/ms-teams.ts b/src/resources/providers/ms-teams.ts index da81b6f4..a0ffda27 100644 --- a/src/resources/providers/ms-teams.ts +++ b/src/resources/providers/ms-teams.ts @@ -22,11 +22,7 @@ export class MsTeams extends APIResource { * ); * ``` */ - checkAuth( - channelID: string, - query: MsTeamCheckAuthParams, - options?: RequestOptions, - ): APIPromise { + checkAuth(channelID: string, query: MsTeamCheckAuthParams, options?: RequestOptions): APIPromise { return this._client.get(path`/v1/providers/ms-teams/${channelID}/auth_check`, { query, ...options }); } @@ -46,11 +42,7 @@ export class MsTeams extends APIResource { * ); * ``` */ - listChannels( - channelID: string, - query: MsTeamListChannelsParams, - options?: RequestOptions, - ): APIPromise { + listChannels(channelID: string, query: MsTeamListChannelsParams, options?: RequestOptions): APIPromise { return this._client.get(path`/v1/providers/ms-teams/${channelID}/channels`, { query, ...options }); } @@ -69,16 +61,8 @@ export class MsTeams extends APIResource { * } * ``` */ - listTeams( - channelID: string, - query: MsTeamListTeamsParams, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList( - path`/v1/providers/ms-teams/${channelID}/teams`, - MsTeamsPagination, - { query, ...options }, - ); + listTeams(channelID: string, query: MsTeamListTeamsParams, options?: RequestOptions): PagePromise { + return this._client.getAPIList(path`/v1/providers/ms-teams/${channelID}/teams`, MsTeamsPagination, { query, ...options }); } /** @@ -93,20 +77,13 @@ export class MsTeams extends APIResource { * ); * ``` */ - revokeAccess( - channelID: string, - params: MsTeamRevokeAccessParams, - options?: RequestOptions, - ): APIPromise { - const { ms_teams_tenant_object } = params; - return this._client.put(path`/v1/providers/ms-teams/${channelID}/revoke_access`, { - query: { ms_teams_tenant_object }, - ...options, - }); + revokeAccess(channelID: string, params: MsTeamRevokeAccessParams, options?: RequestOptions): APIPromise { + const { ms_teams_tenant_object } = params + return this._client.put(path`/v1/providers/ms-teams/${channelID}/revoke_access`, { query: { ms_teams_tenant_object }, ...options }); } } -export type MsTeamListTeamsResponsesMsTeamsPagination = MsTeamsPagination; +export type MsTeamListTeamsResponsesMsTeamsPagination = MsTeamsPagination /** * The response from a Microsoft Teams auth check request. @@ -298,6 +275,6 @@ export declare namespace MsTeams { type MsTeamCheckAuthParams as MsTeamCheckAuthParams, type MsTeamListChannelsParams as MsTeamListChannelsParams, type MsTeamListTeamsParams as MsTeamListTeamsParams, - type MsTeamRevokeAccessParams as MsTeamRevokeAccessParams, + type MsTeamRevokeAccessParams as MsTeamRevokeAccessParams }; } diff --git a/src/resources/providers/providers.ts b/src/resources/providers/providers.ts index 1603dc77..f9fbc1b9 100644 --- a/src/resources/providers/providers.ts +++ b/src/resources/providers/providers.ts @@ -2,29 +2,9 @@ import { APIResource } from '../../core/resource'; import * as MsTeamsAPI from './ms-teams'; -import { - MsTeamCheckAuthParams, - MsTeamCheckAuthResponse, - MsTeamListChannelsParams, - MsTeamListChannelsResponse, - MsTeamListTeamsParams, - MsTeamListTeamsResponse, - MsTeamListTeamsResponsesMsTeamsPagination, - MsTeamRevokeAccessParams, - MsTeamRevokeAccessResponse, - MsTeams, -} from './ms-teams'; +import { MsTeamCheckAuthParams, MsTeamCheckAuthResponse, MsTeamListChannelsParams, MsTeamListChannelsResponse, MsTeamListTeamsParams, MsTeamListTeamsResponse, MsTeamListTeamsResponsesMsTeamsPagination, MsTeamRevokeAccessParams, MsTeamRevokeAccessResponse, MsTeams } from './ms-teams'; import * as SlackAPI from './slack'; -import { - Slack, - SlackCheckAuthParams, - SlackCheckAuthResponse, - SlackListChannelsParams, - SlackListChannelsResponse, - SlackListChannelsResponsesSlackChannelsCursor, - SlackRevokeAccessParams, - SlackRevokeAccessResponse, -} from './slack'; +import { Slack, SlackCheckAuthParams, SlackCheckAuthResponse, SlackListChannelsParams, SlackListChannelsResponse, SlackListChannelsResponsesSlackChannelsCursor, SlackRevokeAccessParams, SlackRevokeAccessResponse } from './slack'; export class Providers extends APIResource { slack: SlackAPI.Slack = new SlackAPI.Slack(this._client); @@ -43,7 +23,7 @@ export declare namespace Providers { type SlackListChannelsResponsesSlackChannelsCursor as SlackListChannelsResponsesSlackChannelsCursor, type SlackCheckAuthParams as SlackCheckAuthParams, type SlackListChannelsParams as SlackListChannelsParams, - type SlackRevokeAccessParams as SlackRevokeAccessParams, + type SlackRevokeAccessParams as SlackRevokeAccessParams }; export { @@ -56,6 +36,6 @@ export declare namespace Providers { type MsTeamCheckAuthParams as MsTeamCheckAuthParams, type MsTeamListChannelsParams as MsTeamListChannelsParams, type MsTeamListTeamsParams as MsTeamListTeamsParams, - type MsTeamRevokeAccessParams as MsTeamRevokeAccessParams, + type MsTeamRevokeAccessParams as MsTeamRevokeAccessParams }; } diff --git a/src/resources/providers/slack.ts b/src/resources/providers/slack.ts index 6ac3b60b..a9ed255e 100644 --- a/src/resources/providers/slack.ts +++ b/src/resources/providers/slack.ts @@ -21,11 +21,7 @@ export class Slack extends APIResource { * ); * ``` */ - checkAuth( - channelID: string, - query: SlackCheckAuthParams, - options?: RequestOptions, - ): APIPromise { + checkAuth(channelID: string, query: SlackCheckAuthParams, options?: RequestOptions): APIPromise { return this._client.get(path`/v1/providers/slack/${channelID}/auth_check`, { query, ...options }); } @@ -43,16 +39,8 @@ export class Slack extends APIResource { * } * ``` */ - listChannels( - channelID: string, - query: SlackListChannelsParams, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList( - path`/v1/providers/slack/${channelID}/channels`, - SlackChannelsCursor, - { query, ...options }, - ); + listChannels(channelID: string, query: SlackListChannelsParams, options?: RequestOptions): PagePromise { + return this._client.getAPIList(path`/v1/providers/slack/${channelID}/channels`, SlackChannelsCursor, { query, ...options }); } /** @@ -66,20 +54,13 @@ export class Slack extends APIResource { * ); * ``` */ - revokeAccess( - channelID: string, - params: SlackRevokeAccessParams, - options?: RequestOptions, - ): APIPromise { - const { access_token_object } = params; - return this._client.put(path`/v1/providers/slack/${channelID}/revoke_access`, { - query: { access_token_object }, - ...options, - }); + revokeAccess(channelID: string, params: SlackRevokeAccessParams, options?: RequestOptions): APIPromise { + const { access_token_object } = params + return this._client.put(path`/v1/providers/slack/${channelID}/revoke_access`, { query: { access_token_object }, ...options }); } } -export type SlackListChannelsResponsesSlackChannelsCursor = SlackChannelsCursor; +export type SlackListChannelsResponsesSlackChannelsCursor = SlackChannelsCursor /** * The response from a Slack auth check request. @@ -214,6 +195,6 @@ export declare namespace Slack { type SlackListChannelsResponsesSlackChannelsCursor as SlackListChannelsResponsesSlackChannelsCursor, type SlackCheckAuthParams as SlackCheckAuthParams, type SlackListChannelsParams as SlackListChannelsParams, - type SlackRevokeAccessParams as SlackRevokeAccessParams, + type SlackRevokeAccessParams as SlackRevokeAccessParams }; } diff --git a/src/resources/recipients/channel-data.ts b/src/resources/recipients/channel-data.ts index 340601d5..1f8bc321 100644 --- a/src/resources/recipients/channel-data.ts +++ b/src/resources/recipients/channel-data.ts @@ -2,7 +2,9 @@ import { APIResource } from '../../core/resource'; -export class ChannelData extends APIResource {} +export class ChannelData extends APIResource { + +} /** * AWS SNS push channel data. @@ -68,27 +70,12 @@ export interface ChannelData { /** * Channel data for a given channel type. */ - data: - | ChannelData.PushChannelDataFull - | ChannelData.AwssnsPushChannelDataFull - | OneSignalChannelDataPlayerIDsOnly - | SlackChannelData - | MsTeamsChannelData - | DiscordChannelData; + data: ChannelData.PushChannelDataFull | ChannelData.AwssnsPushChannelDataFull | OneSignalChannelDataPlayerIDsOnly | SlackChannelData | MsTeamsChannelData | DiscordChannelData; /** * The type of provider. */ - provider?: - | 'push_fcm' - | 'push_apns' - | 'push_aws_sns' - | 'push_expo' - | 'push_one_signal' - | 'chat_slack' - | 'chat_ms_teams' - | 'chat_discord' - | 'http_knock_webhook'; + provider?: 'push_fcm' | 'push_apns' | 'push_aws_sns' | 'push_expo' | 'push_one_signal' | 'chat_slack' | 'chat_ms_teams' | 'chat_discord' | 'http_knock_webhook'; } export namespace ChannelData { @@ -181,15 +168,7 @@ export interface ChannelDataRequest { /** * Channel data for a given channel type. */ - data: - | PushChannelDataTokensOnly - | PushChannelDataDevicesOnly - | AwsSnsPushChannelDataTargetArnsOnly - | AwsSnsPushChannelDataDevicesOnly - | OneSignalChannelDataPlayerIDsOnly - | SlackChannelData - | MsTeamsChannelData - | DiscordChannelData; + data: PushChannelDataTokensOnly | PushChannelDataDevicesOnly | AwsSnsPushChannelDataTargetArnsOnly | AwsSnsPushChannelDataDevicesOnly | OneSignalChannelDataPlayerIDsOnly | SlackChannelData | MsTeamsChannelData | DiscordChannelData; } /** @@ -199,9 +178,7 @@ export interface DiscordChannelData { /** * List of Discord channel connections. */ - connections: Array< - DiscordChannelData.DiscordChannelConnection | DiscordChannelData.DiscordIncomingWebhookConnection - >; + connections: Array; } export namespace DiscordChannelData { @@ -241,17 +218,7 @@ export namespace DiscordChannelData { /** * A request to set channel data for a type of channel inline. */ -export type InlineChannelDataRequest = { - [key: string]: - | PushChannelDataTokensOnly - | PushChannelDataDevicesOnly - | AwsSnsPushChannelDataTargetArnsOnly - | AwsSnsPushChannelDataDevicesOnly - | OneSignalChannelDataPlayerIDsOnly - | SlackChannelData - | MsTeamsChannelData - | DiscordChannelData; -}; +export type InlineChannelDataRequest = { [key: string]: PushChannelDataTokensOnly | PushChannelDataDevicesOnly | AwsSnsPushChannelDataTargetArnsOnly | AwsSnsPushChannelDataDevicesOnly | OneSignalChannelDataPlayerIDsOnly | SlackChannelData | MsTeamsChannelData | DiscordChannelData } /** * Microsoft Teams channel data. @@ -260,9 +227,7 @@ export interface MsTeamsChannelData { /** * List of Microsoft Teams connections. */ - connections: Array< - MsTeamsChannelData.MsTeamsTokenConnection | MsTeamsChannelData.MsTeamsIncomingWebhookConnection - >; + connections: Array; /** * Microsoft Teams tenant ID. @@ -442,6 +407,6 @@ export declare namespace ChannelData { type OneSignalChannelDataPlayerIDsOnly as OneSignalChannelDataPlayerIDsOnly, type PushChannelDataDevicesOnly as PushChannelDataDevicesOnly, type PushChannelDataTokensOnly as PushChannelDataTokensOnly, - type SlackChannelData as SlackChannelData, + type SlackChannelData as SlackChannelData }; } diff --git a/src/resources/recipients/index.ts b/src/resources/recipients/index.ts index 2cfc89b2..acbb2b03 100644 --- a/src/resources/recipients/index.ts +++ b/src/resources/recipients/index.ts @@ -1,26 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { - ChannelData, - type AwsSnsPushChannelDataDevicesOnly, - type AwsSnsPushChannelDataTargetArnsOnly, - type ChannelDataRequest, - type DiscordChannelData, - type InlineChannelDataRequest, - type MsTeamsChannelData, - type OneSignalChannelDataPlayerIDsOnly, - type PushChannelDataDevicesOnly, - type PushChannelDataTokensOnly, - type SlackChannelData, -} from './channel-data'; -export { - Preferences, - type InlinePreferenceSetRequest, - type PreferenceSet, - type PreferenceSetChannelSetting, - type PreferenceSetChannelTypeSetting, - type PreferenceSetChannelTypes, - type PreferenceSetRequest, -} from './preferences'; -export { Recipients, type Recipient, type RecipientReference, type RecipientRequest } from './recipients'; -export { Subscriptions, type Subscription, type SubscriptionsEntriesCursor } from './subscriptions'; +export { ChannelData, type AwsSnsPushChannelDataDevicesOnly, type AwsSnsPushChannelDataTargetArnsOnly, type ChannelDataRequest, type DiscordChannelData, type InlineChannelDataRequest, type MsTeamsChannelData, type OneSignalChannelDataPlayerIDsOnly, type PushChannelDataDevicesOnly, type PushChannelDataTokensOnly, type SlackChannelData } from './channel-data';; +export { Preferences, type InlinePreferenceSetRequest, type PreferenceSet, type PreferenceSetChannelSetting, type PreferenceSetChannelTypeSetting, type PreferenceSetChannelTypes, type PreferenceSetRequest } from './preferences';; +export { Recipients, type Recipient, type RecipientReference, type RecipientRequest } from './recipients';; +export { Subscriptions, type Subscription, type SubscriptionsEntriesCursor } from './subscriptions';; diff --git a/src/resources/recipients/preferences.ts b/src/resources/recipients/preferences.ts index 2f2b0325..ec102fa9 100644 --- a/src/resources/recipients/preferences.ts +++ b/src/resources/recipients/preferences.ts @@ -4,14 +4,16 @@ import { APIResource } from '../../core/resource'; import * as PreferencesAPI from './preferences'; import * as Shared from '../shared'; -export class Preferences extends APIResource {} +export class Preferences extends APIResource { + +} /** * Inline set preferences for a recipient, where the key is the preference set id. * Preferences that are set inline will be merged into any existing preferences * rather than replacing them. */ -export type InlinePreferenceSetRequest = { [key: string]: PreferenceSetRequest }; +export type InlinePreferenceSetRequest = { [key: string]: PreferenceSetRequest } /** * A preference set represents a specific set of notification preferences for a @@ -167,9 +169,7 @@ export interface PreferenceSetRequest { * An object where the key is the category and the values are the preference * settings for that category. */ - categories?: { - [key: string]: boolean | PreferenceSetRequest.PreferenceSetWorkflowCategorySettingObject; - } | null; + categories?: { [key: string]: boolean | PreferenceSetRequest.PreferenceSetWorkflowCategorySettingObject } | null; /** * Channel type preferences. @@ -191,9 +191,7 @@ export interface PreferenceSetRequest { * An object where the key is the workflow key and the values are the preference * settings for that workflow. */ - workflows?: { - [key: string]: boolean | PreferenceSetRequest.PreferenceSetWorkflowCategorySettingObject; - } | null; + workflows?: { [key: string]: boolean | PreferenceSetRequest.PreferenceSetWorkflowCategorySettingObject } | null; } export namespace PreferenceSetRequest { @@ -247,6 +245,6 @@ export declare namespace Preferences { type PreferenceSetChannelSetting as PreferenceSetChannelSetting, type PreferenceSetChannelTypeSetting as PreferenceSetChannelTypeSetting, type PreferenceSetChannelTypes as PreferenceSetChannelTypes, - type PreferenceSetRequest as PreferenceSetRequest, + type PreferenceSetRequest as PreferenceSetRequest }; } diff --git a/src/resources/recipients/recipients.ts b/src/resources/recipients/recipients.ts index d2f1c8bb..72b77f46 100644 --- a/src/resources/recipients/recipients.ts +++ b/src/resources/recipients/recipients.ts @@ -3,29 +3,9 @@ import { APIResource } from '../../core/resource'; import * as ObjectsAPI from '../objects/objects'; import * as ChannelDataAPI from './channel-data'; -import { - AwsSnsPushChannelDataDevicesOnly, - AwsSnsPushChannelDataTargetArnsOnly, - ChannelData, - ChannelDataRequest, - DiscordChannelData, - InlineChannelDataRequest, - MsTeamsChannelData, - OneSignalChannelDataPlayerIDsOnly, - PushChannelDataDevicesOnly, - PushChannelDataTokensOnly, - SlackChannelData, -} from './channel-data'; +import { AwsSnsPushChannelDataDevicesOnly, AwsSnsPushChannelDataTargetArnsOnly, ChannelData, ChannelDataRequest, DiscordChannelData, InlineChannelDataRequest, MsTeamsChannelData, OneSignalChannelDataPlayerIDsOnly, PushChannelDataDevicesOnly, PushChannelDataTokensOnly, SlackChannelData } from './channel-data'; import * as PreferencesAPI from './preferences'; -import { - InlinePreferenceSetRequest, - PreferenceSet, - PreferenceSetChannelSetting, - PreferenceSetChannelTypeSetting, - PreferenceSetChannelTypes, - PreferenceSetRequest, - Preferences, -} from './preferences'; +import { InlinePreferenceSetRequest, PreferenceSet, PreferenceSetChannelSetting, PreferenceSetChannelTypeSetting, PreferenceSetChannelTypes, PreferenceSetRequest, Preferences } from './preferences'; import * as SubscriptionsAPI from './subscriptions'; import { Subscription, Subscriptions } from './subscriptions'; import * as UsersAPI from '../users/users'; @@ -39,13 +19,13 @@ export class Recipients extends APIResource { /** * A recipient of a notification, which is either a user or an object. */ -export type Recipient = UsersAPI.User | ObjectsAPI.Object; +export type Recipient = UsersAPI.User | ObjectsAPI.Object /** * A reference to a recipient, either a user identifier (string) or an object * reference (ID, collection). */ -export type RecipientReference = string | RecipientReference.ObjectReference; +export type RecipientReference = string | RecipientReference.ObjectReference export namespace RecipientReference { /** @@ -69,7 +49,7 @@ export namespace RecipientReference { * (string), an inline user request (object), or an inline object request, which is * determined by the presence of a `collection` property. */ -export type RecipientRequest = string | UsersAPI.InlineIdentifyUserRequest | ObjectsAPI.InlineObjectRequest; +export type RecipientRequest = string | UsersAPI.InlineIdentifyUserRequest | ObjectsAPI.InlineObjectRequest Recipients.Subscriptions = Subscriptions; Recipients.Preferences = Preferences; @@ -78,10 +58,13 @@ export declare namespace Recipients { export { type Recipient as Recipient, type RecipientReference as RecipientReference, - type RecipientRequest as RecipientRequest, + type RecipientRequest as RecipientRequest }; - export { Subscriptions as Subscriptions, type Subscription as Subscription }; + export { + Subscriptions as Subscriptions, + type Subscription as Subscription + }; export { Preferences as Preferences, @@ -90,7 +73,7 @@ export declare namespace Recipients { type PreferenceSetChannelSetting as PreferenceSetChannelSetting, type PreferenceSetChannelTypeSetting as PreferenceSetChannelTypeSetting, type PreferenceSetChannelTypes as PreferenceSetChannelTypes, - type PreferenceSetRequest as PreferenceSetRequest, + type PreferenceSetRequest as PreferenceSetRequest }; export { @@ -104,6 +87,6 @@ export declare namespace Recipients { type OneSignalChannelDataPlayerIDsOnly as OneSignalChannelDataPlayerIDsOnly, type PushChannelDataDevicesOnly as PushChannelDataDevicesOnly, type PushChannelDataTokensOnly as PushChannelDataTokensOnly, - type SlackChannelData as SlackChannelData, + type SlackChannelData as SlackChannelData }; } diff --git a/src/resources/recipients/subscriptions.ts b/src/resources/recipients/subscriptions.ts index 89ce7a6f..7ef32e67 100644 --- a/src/resources/recipients/subscriptions.ts +++ b/src/resources/recipients/subscriptions.ts @@ -5,9 +5,11 @@ import * as ObjectsAPI from '../objects/objects'; import * as RecipientsAPI from './recipients'; import { EntriesCursor } from '../../core/pagination'; -export class Subscriptions extends APIResource {} +export class Subscriptions extends APIResource { -export type SubscriptionsEntriesCursor = EntriesCursor; +} + +export type SubscriptionsEntriesCursor = EntriesCursor /** * A subscription object. @@ -45,5 +47,7 @@ export interface Subscription { } export declare namespace Subscriptions { - export { type Subscription as Subscription }; + export { + type Subscription as Subscription + }; } diff --git a/src/resources/schedules/bulk.ts b/src/resources/schedules/bulk.ts index b7fd6ee3..910af654 100644 --- a/src/resources/schedules/bulk.ts +++ b/src/resources/schedules/bulk.ts @@ -114,5 +114,7 @@ export namespace BulkCreateParams { } export declare namespace Bulk { - export { type BulkCreateParams as BulkCreateParams }; + export { + type BulkCreateParams as BulkCreateParams + }; } diff --git a/src/resources/schedules/index.ts b/src/resources/schedules/index.ts index 5519b439..3dd8d7dd 100644 --- a/src/resources/schedules/index.ts +++ b/src/resources/schedules/index.ts @@ -1,16 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Bulk, type BulkCreateParams } from './bulk'; -export { - Schedules, - type Schedule, - type ScheduleRepeatRule, - type ScheduleCreateResponse, - type ScheduleUpdateResponse, - type ScheduleDeleteResponse, - type ScheduleCreateParams, - type ScheduleUpdateParams, - type ScheduleListParams, - type ScheduleDeleteParams, - type SchedulesEntriesCursor, -} from './schedules'; +export { Bulk, type BulkCreateParams } from './bulk';; +export { Schedules, type Schedule, type ScheduleRepeatRule, type ScheduleCreateResponse, type ScheduleUpdateResponse, type ScheduleDeleteResponse, type ScheduleCreateParams, type ScheduleUpdateParams, type ScheduleListParams, type ScheduleDeleteParams, type SchedulesEntriesCursor } from './schedules';; diff --git a/src/resources/schedules/schedules.ts b/src/resources/schedules/schedules.ts index 711dc129..32004424 100644 --- a/src/resources/schedules/schedules.ts +++ b/src/resources/schedules/schedules.ts @@ -128,7 +128,7 @@ export class Schedules extends APIResource { } } -export type SchedulesEntriesCursor = EntriesCursor; +export type SchedulesEntriesCursor = EntriesCursor /** * A schedule represents a recurring workflow execution. @@ -243,17 +243,17 @@ export interface ScheduleRepeatRule { /** * A list of schedules. */ -export type ScheduleCreateResponse = Array; +export type ScheduleCreateResponse = Array /** * A list of schedules. */ -export type ScheduleUpdateResponse = Array; +export type ScheduleUpdateResponse = Array /** * A list of schedules. */ -export type ScheduleDeleteResponse = Array; +export type ScheduleDeleteResponse = Array export interface ScheduleCreateParams { /** @@ -380,8 +380,11 @@ export declare namespace Schedules { type ScheduleCreateParams as ScheduleCreateParams, type ScheduleUpdateParams as ScheduleUpdateParams, type ScheduleListParams as ScheduleListParams, - type ScheduleDeleteParams as ScheduleDeleteParams, + type ScheduleDeleteParams as ScheduleDeleteParams }; - export { Bulk as Bulk, type BulkCreateParams as BulkCreateParams }; + export { + Bulk as Bulk, + type BulkCreateParams as BulkCreateParams + }; } diff --git a/src/resources/shared.ts b/src/resources/shared.ts index f8e032df..8c83b2ef 100644 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -1,5 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + /** * A condition to be evaluated. */ @@ -12,30 +13,7 @@ export interface Condition { /** * The operator to use in the condition evaluation. */ - operator: - | 'equal_to' - | 'not_equal_to' - | 'greater_than' - | 'less_than' - | 'greater_than_or_equal_to' - | 'less_than_or_equal_to' - | 'contains' - | 'not_contains' - | 'empty' - | 'not_empty' - | 'exists' - | 'not_exists' - | 'contains_all' - | 'is_timestamp' - | 'is_not_timestamp' - | 'is_timestamp_on_or_after' - | 'is_timestamp_before' - | 'is_timestamp_on_or_after_date' - | 'is_timestamp_before_date' - | 'is_timestamp_between' - | 'is_between' - | 'is_audience_member' - | 'is_not_audience_member'; + operator: 'equal_to' | 'not_equal_to' | 'greater_than' | 'less_than' | 'greater_than_or_equal_to' | 'less_than_or_equal_to' | 'contains' | 'not_contains' | 'empty' | 'not_empty' | 'exists' | 'not_exists' | 'contains_all' | 'is_timestamp' | 'is_not_timestamp' | 'is_timestamp_on_or_after' | 'is_timestamp_before' | 'is_timestamp_on_or_after_date' | 'is_timestamp_before_date' | 'is_timestamp_between' | 'is_between' | 'is_audience_member' | 'is_not_audience_member'; /** * The variable to be evaluated in the condition. diff --git a/src/resources/tenants/bulk.ts b/src/resources/tenants/bulk.ts index 687c3198..65d19ff5 100644 --- a/src/resources/tenants/bulk.ts +++ b/src/resources/tenants/bulk.ts @@ -22,7 +22,7 @@ export class Bulk extends APIResource { * ``` */ delete(params: BulkDeleteParams, options?: RequestOptions): APIPromise { - const { tenant_ids } = params; + const { tenant_ids } = params return this._client.post('/v1/tenants/bulk/delete', { query: { tenant_ids }, ...options }); } @@ -56,5 +56,8 @@ export interface BulkSetParams { } export declare namespace Bulk { - export { type BulkDeleteParams as BulkDeleteParams, type BulkSetParams as BulkSetParams }; + export { + type BulkDeleteParams as BulkDeleteParams, + type BulkSetParams as BulkSetParams + }; } diff --git a/src/resources/tenants/index.ts b/src/resources/tenants/index.ts index af403c7c..87092969 100644 --- a/src/resources/tenants/index.ts +++ b/src/resources/tenants/index.ts @@ -1,13 +1,4 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Bulk, type BulkDeleteParams, type BulkSetParams } from './bulk'; -export { - Tenants, - type InlineTenantRequest, - type Tenant, - type TenantRequest, - type TenantListParams, - type TenantGetParams, - type TenantSetParams, - type TenantsEntriesCursor, -} from './tenants'; +export { Bulk, type BulkDeleteParams, type BulkSetParams } from './bulk';; +export { Tenants, type InlineTenantRequest, type Tenant, type TenantRequest, type TenantListParams, type TenantGetParams, type TenantSetParams, type TenantsEntriesCursor } from './tenants';; diff --git a/src/resources/tenants/tenants.ts b/src/resources/tenants/tenants.ts index 6b3ff14d..831170d9 100644 --- a/src/resources/tenants/tenants.ts +++ b/src/resources/tenants/tenants.ts @@ -28,10 +28,7 @@ export class Tenants extends APIResource { * } * ``` */ - list( - query: TenantListParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { + list(query: TenantListParams | null | undefined = {}, options?: RequestOptions): PagePromise { return this._client.getAPIList('/v1/tenants', EntriesCursor, { query, ...options }); } @@ -44,10 +41,7 @@ export class Tenants extends APIResource { * ``` */ delete(id: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/tenants/${id}`, { - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + return this._client.delete(path`/v1/tenants/${id}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } /** @@ -58,11 +52,7 @@ export class Tenants extends APIResource { * const tenant = await client.tenants.get('id'); * ``` */ - get( - id: string, - query: TenantGetParams | null | undefined = {}, - options?: RequestOptions, - ): APIPromise { + get(id: string, query: TenantGetParams | null | undefined = {}, options?: RequestOptions): APIPromise { return this._client.get(path`/v1/tenants/${id}`, { query, ...options }); } @@ -87,21 +77,17 @@ export class Tenants extends APIResource { * ``` */ set(id: string, params: TenantSetParams, options?: RequestOptions): APIPromise { - const { resolve_full_preference_settings, ...body } = params; - return this._client.put(path`/v1/tenants/${id}`, { - query: { resolve_full_preference_settings }, - body, - ...options, - }); + const { resolve_full_preference_settings, ...body } = params + return this._client.put(path`/v1/tenants/${id}`, { query: { resolve_full_preference_settings }, body, ...options }); } } -export type TenantsEntriesCursor = EntriesCursor; +export type TenantsEntriesCursor = EntriesCursor /** * An request to set a tenant inline. */ -export type InlineTenantRequest = string | TenantRequest; +export type InlineTenantRequest = string | TenantRequest /** * A tenant entity. @@ -127,7 +113,7 @@ export interface Tenant { */ settings?: Tenant.Settings | null; - [k: string]: unknown; +[k: string]: unknown } export namespace Tenant { @@ -209,7 +195,7 @@ export interface TenantRequest { */ settings?: TenantRequest.Settings; - [k: string]: unknown; +[k: string]: unknown } export namespace TenantRequest { @@ -302,7 +288,7 @@ export interface TenantSetParams { */ settings?: TenantSetParams.Settings; - [k: string]: unknown; +[k: string]: unknown } export namespace TenantSetParams { @@ -361,8 +347,12 @@ export declare namespace Tenants { type TenantsEntriesCursor as TenantsEntriesCursor, type TenantListParams as TenantListParams, type TenantGetParams as TenantGetParams, - type TenantSetParams as TenantSetParams, + type TenantSetParams as TenantSetParams }; - export { Bulk as Bulk, type BulkDeleteParams as BulkDeleteParams, type BulkSetParams as BulkSetParams }; + export { + Bulk as Bulk, + type BulkDeleteParams as BulkDeleteParams, + type BulkSetParams as BulkSetParams + }; } diff --git a/src/resources/users/bulk.ts b/src/resources/users/bulk.ts index 87cd8a76..2e64a64a 100644 --- a/src/resources/users/bulk.ts +++ b/src/resources/users/bulk.ts @@ -89,10 +89,7 @@ export class Bulk extends APIResource { * }); * ``` */ - setPreferences( - body: BulkSetPreferencesParams, - options?: RequestOptions, - ): APIPromise { + setPreferences(body: BulkSetPreferencesParams, options?: RequestOptions): APIPromise { return this._client.post('/v1/users/bulk/preferences', { body, ...options }); } } @@ -127,6 +124,6 @@ export declare namespace Bulk { export { type BulkDeleteParams as BulkDeleteParams, type BulkIdentifyParams as BulkIdentifyParams, - type BulkSetPreferencesParams as BulkSetPreferencesParams, + type BulkSetPreferencesParams as BulkSetPreferencesParams }; } diff --git a/src/resources/users/feeds.ts b/src/resources/users/feeds.ts index f56ffa56..f68900fd 100644 --- a/src/resources/users/feeds.ts +++ b/src/resources/users/feeds.ts @@ -57,21 +57,12 @@ export class Feeds extends APIResource { * } * ``` */ - listItems( - userID: string, - id: string, - query: FeedListItemsParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList( - path`/v1/users/${userID}/feeds/${id}`, - EntriesCursor, - { query, ...options }, - ); + listItems(userID: string, id: string, query: FeedListItemsParams | null | undefined = {}, options?: RequestOptions): PagePromise { + return this._client.getAPIList(path`/v1/users/${userID}/feeds/${id}`, EntriesCursor, { query, ...options }); } } -export type FeedListItemsResponsesEntriesCursor = EntriesCursor; +export type FeedListItemsResponsesEntriesCursor = EntriesCursor /** * The response for the user's feed settings. @@ -122,9 +113,7 @@ export interface FeedListItemsResponse { /** * Content blocks that make up the feed item. */ - blocks: Array< - FeedListItemsResponse.MessageInAppFeedContentBlock | FeedListItemsResponse.MessageInAppFeedButtonSetBlock - >; + blocks: Array; /** * Additional data associated with the feed item. @@ -377,6 +366,6 @@ export declare namespace Feeds { type FeedGetSettingsResponse as FeedGetSettingsResponse, type FeedListItemsResponse as FeedListItemsResponse, type FeedListItemsResponsesEntriesCursor as FeedListItemsResponsesEntriesCursor, - type FeedListItemsParams as FeedListItemsParams, + type FeedListItemsParams as FeedListItemsParams }; } diff --git a/src/resources/users/guides.ts b/src/resources/users/guides.ts index a2f16489..b054d8ac 100644 --- a/src/resources/users/guides.ts +++ b/src/resources/users/guides.ts @@ -20,12 +20,7 @@ export class Guides extends APIResource { * ); * ``` */ - getChannel( - userID: string, - channelID: string, - query: GuideGetChannelParams | null | undefined = {}, - options?: RequestOptions, - ): APIPromise { + getChannel(userID: string, channelID: string, query: GuideGetChannelParams | null | undefined = {}, options?: RequestOptions): APIPromise { return this._client.get(path`/v1/users/${userID}/guides/${channelID}`, { query, ...options }); } @@ -48,16 +43,8 @@ export class Guides extends APIResource { * ); * ``` */ - markMessageAsArchived( - userID: string, - messageID: string, - body: GuideMarkMessageAsArchivedParams, - options?: RequestOptions, - ): APIPromise { - return this._client.put(path`/v1/users/${userID}/guides/messages/${messageID}/archived`, { - body, - ...options, - }); + markMessageAsArchived(userID: string, messageID: string, body: GuideMarkMessageAsArchivedParams, options?: RequestOptions): APIPromise { + return this._client.put(path`/v1/users/${userID}/guides/messages/${messageID}/archived`, { body, ...options }); } /** @@ -79,16 +66,8 @@ export class Guides extends APIResource { * ); * ``` */ - markMessageAsInteracted( - userID: string, - messageID: string, - body: GuideMarkMessageAsInteractedParams, - options?: RequestOptions, - ): APIPromise { - return this._client.put(path`/v1/users/${userID}/guides/messages/${messageID}/interacted`, { - body, - ...options, - }); + markMessageAsInteracted(userID: string, messageID: string, body: GuideMarkMessageAsInteractedParams, options?: RequestOptions): APIPromise { + return this._client.put(path`/v1/users/${userID}/guides/messages/${messageID}/interacted`, { body, ...options }); } /** @@ -125,16 +104,8 @@ export class Guides extends APIResource { * ); * ``` */ - markMessageAsSeen( - userID: string, - messageID: string, - body: GuideMarkMessageAsSeenParams, - options?: RequestOptions, - ): APIPromise { - return this._client.put(path`/v1/users/${userID}/guides/messages/${messageID}/seen`, { - body, - ...options, - }); + markMessageAsSeen(userID: string, messageID: string, body: GuideMarkMessageAsSeenParams, options?: RequestOptions): APIPromise { + return this._client.put(path`/v1/users/${userID}/guides/messages/${messageID}/seen`, { body, ...options }); } } @@ -319,11 +290,7 @@ export namespace GuideGetChannelResponse { /** * Reason code for ineligibility */ - reason: - | 'guide_not_active' - | 'marked_as_archived' - | 'target_conditions_not_met' - | 'not_in_target_audience'; + reason: 'guide_not_active' | 'marked_as_archived' | 'target_conditions_not_met' | 'not_in_target_audience'; } } @@ -524,6 +491,6 @@ export declare namespace Guides { type GuideGetChannelParams as GuideGetChannelParams, type GuideMarkMessageAsArchivedParams as GuideMarkMessageAsArchivedParams, type GuideMarkMessageAsInteractedParams as GuideMarkMessageAsInteractedParams, - type GuideMarkMessageAsSeenParams as GuideMarkMessageAsSeenParams, + type GuideMarkMessageAsSeenParams as GuideMarkMessageAsSeenParams }; } diff --git a/src/resources/users/index.ts b/src/resources/users/index.ts index 0d3685b1..5b081609 100644 --- a/src/resources/users/index.ts +++ b/src/resources/users/index.ts @@ -1,38 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Bulk, type BulkDeleteParams, type BulkIdentifyParams, type BulkSetPreferencesParams } from './bulk'; -export { - Feeds, - type FeedGetSettingsResponse, - type FeedListItemsResponse, - type FeedListItemsParams, - type FeedListItemsResponsesEntriesCursor, -} from './feeds'; -export { - Guides, - type GuideGetChannelResponse, - type GuideMarkMessageAsArchivedResponse, - type GuideMarkMessageAsInteractedResponse, - type GuideMarkMessageAsSeenResponse, - type GuideGetChannelParams, - type GuideMarkMessageAsArchivedParams, - type GuideMarkMessageAsInteractedParams, - type GuideMarkMessageAsSeenParams, -} from './guides'; -export { - Users, - type IdentifyUserRequest, - type InlineIdentifyUserRequest, - type User, - type UserListPreferencesResponse, - type UserUpdateParams, - type UserListParams, - type UserGetPreferencesParams, - type UserListMessagesParams, - type UserListSchedulesParams, - type UserListSubscriptionsParams, - type UserMergeParams, - type UserSetChannelDataParams, - type UserSetPreferencesParams, - type UsersEntriesCursor, -} from './users'; +export { Bulk, type BulkDeleteParams, type BulkIdentifyParams, type BulkSetPreferencesParams } from './bulk';; +export { Feeds, type FeedGetSettingsResponse, type FeedListItemsResponse, type FeedListItemsParams, type FeedListItemsResponsesEntriesCursor } from './feeds';; +export { Guides, type GuideGetChannelResponse, type GuideMarkMessageAsArchivedResponse, type GuideMarkMessageAsInteractedResponse, type GuideMarkMessageAsSeenResponse, type GuideGetChannelParams, type GuideMarkMessageAsArchivedParams, type GuideMarkMessageAsInteractedParams, type GuideMarkMessageAsSeenParams } from './guides';; +export { Users, type IdentifyUserRequest, type InlineIdentifyUserRequest, type User, type UserListPreferencesResponse, type UserUpdateParams, type UserListParams, type UserGetPreferencesParams, type UserListMessagesParams, type UserListSchedulesParams, type UserListSubscriptionsParams, type UserMergeParams, type UserSetChannelDataParams, type UserSetPreferencesParams, type UsersEntriesCursor } from './users';; diff --git a/src/resources/users/users.ts b/src/resources/users/users.ts index c63eed47..66305df6 100644 --- a/src/resources/users/users.ts +++ b/src/resources/users/users.ts @@ -14,33 +14,11 @@ import { SchedulesEntriesCursor } from '../schedules/schedules'; import * as BulkAPI from './bulk'; import { Bulk, BulkDeleteParams, BulkIdentifyParams, BulkSetPreferencesParams } from './bulk'; import * as FeedsAPI from './feeds'; -import { - FeedGetSettingsResponse, - FeedListItemsParams, - FeedListItemsResponse, - FeedListItemsResponsesEntriesCursor, - Feeds, -} from './feeds'; +import { FeedGetSettingsResponse, FeedListItemsParams, FeedListItemsResponse, FeedListItemsResponsesEntriesCursor, Feeds } from './feeds'; import * as GuidesAPI from './guides'; -import { - GuideGetChannelParams, - GuideGetChannelResponse, - GuideMarkMessageAsArchivedParams, - GuideMarkMessageAsArchivedResponse, - GuideMarkMessageAsInteractedParams, - GuideMarkMessageAsInteractedResponse, - GuideMarkMessageAsSeenParams, - GuideMarkMessageAsSeenResponse, - Guides, -} from './guides'; +import { GuideGetChannelParams, GuideGetChannelResponse, GuideMarkMessageAsArchivedParams, GuideMarkMessageAsArchivedResponse, GuideMarkMessageAsInteractedParams, GuideMarkMessageAsInteractedResponse, GuideMarkMessageAsSeenParams, GuideMarkMessageAsSeenResponse, Guides } from './guides'; import { APIPromise } from '../../core/api-promise'; -import { - EntriesCursor, - type EntriesCursorParams, - ItemsCursor, - type ItemsCursorParams, - PagePromise, -} from '../../core/pagination'; +import { EntriesCursor, type EntriesCursorParams, ItemsCursor, type ItemsCursorParams, PagePromise } from '../../core/pagination'; import { buildHeaders } from '../../internal/headers'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; @@ -98,10 +76,7 @@ export class Users extends APIResource { * } * ``` */ - list( - query: UserListParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { + list(query: UserListParams | null | undefined = {}, options?: RequestOptions): PagePromise { return this._client.getAPIList('/v1/users', EntriesCursor, { query, ...options }); } @@ -114,10 +89,7 @@ export class Users extends APIResource { * ``` */ delete(userID: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/users/${userID}`, { - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + return this._client.delete(path`/v1/users/${userID}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } /** @@ -143,11 +115,7 @@ export class Users extends APIResource { * ); * ``` */ - getChannelData( - userID: string, - channelID: string, - options?: RequestOptions, - ): APIPromise { + getChannelData(userID: string, channelID: string, options?: RequestOptions): APIPromise { return this._client.get(path`/v1/users/${userID}/channel_data/${channelID}`, options); } @@ -163,12 +131,7 @@ export class Users extends APIResource { * ); * ``` */ - getPreferences( - userID: string, - id: string, - query: UserGetPreferencesParams | null | undefined = {}, - options?: RequestOptions, - ): APIPromise { + getPreferences(userID: string, id: string, query: UserGetPreferencesParams | null | undefined = {}, options?: RequestOptions): APIPromise { return this._client.get(path`/v1/users/${userID}/preferences/${id}`, { query, ...options }); } @@ -187,15 +150,8 @@ export class Users extends APIResource { * } * ``` */ - listMessages( - userID: string, - query: UserListMessagesParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList(path`/v1/users/${userID}/messages`, ItemsCursor, { - query, - ...options, - }); + listMessages(userID: string, query: UserListMessagesParams | null | undefined = {}, options?: RequestOptions): PagePromise { + return this._client.getAPIList(path`/v1/users/${userID}/messages`, ItemsCursor, { query, ...options }); } /** @@ -225,16 +181,8 @@ export class Users extends APIResource { * } * ``` */ - listSchedules( - userID: string, - query: UserListSchedulesParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList( - path`/v1/users/${userID}/schedules`, - EntriesCursor, - { query, ...options }, - ); + listSchedules(userID: string, query: UserListSchedulesParams | null | undefined = {}, options?: RequestOptions): PagePromise { + return this._client.getAPIList(path`/v1/users/${userID}/schedules`, EntriesCursor, { query, ...options }); } /** @@ -251,16 +199,8 @@ export class Users extends APIResource { * } * ``` */ - listSubscriptions( - userID: string, - query: UserListSubscriptionsParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList( - path`/v1/users/${userID}/subscriptions`, - EntriesCursor, - { query, ...options }, - ); + listSubscriptions(userID: string, query: UserListSubscriptionsParams | null | undefined = {}, options?: RequestOptions): PagePromise { + return this._client.getAPIList(path`/v1/users/${userID}/subscriptions`, EntriesCursor, { query, ...options }); } /** @@ -292,12 +232,7 @@ export class Users extends APIResource { * ); * ``` */ - setChannelData( - userID: string, - channelID: string, - body: UserSetChannelDataParams, - options?: RequestOptions, - ): APIPromise { + setChannelData(userID: string, channelID: string, body: UserSetChannelDataParams, options?: RequestOptions): APIPromise { return this._client.put(path`/v1/users/${userID}/channel_data/${channelID}`, { body, ...options }); } @@ -341,12 +276,7 @@ export class Users extends APIResource { * ); * ``` */ - setPreferences( - userID: string, - id: string, - body: UserSetPreferencesParams, - options?: RequestOptions, - ): APIPromise { + setPreferences(userID: string, id: string, body: UserSetPreferencesParams, options?: RequestOptions): APIPromise { return this._client.put(path`/v1/users/${userID}/preferences/${id}`, { body, ...options }); } @@ -362,10 +292,7 @@ export class Users extends APIResource { * ``` */ unsetChannelData(userID: string, channelID: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/users/${userID}/channel_data/${channelID}`, { - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + return this._client.delete(path`/v1/users/${userID}/channel_data/${channelID}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } /** @@ -377,14 +304,11 @@ export class Users extends APIResource { * ``` */ unsetPreferences(userID: string, id: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/v1/users/${userID}/preferences/${id}`, { - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + return this._client.delete(path`/v1/users/${userID}/preferences/${id}`, { ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } } -export type UsersEntriesCursor = EntriesCursor; +export type UsersEntriesCursor = EntriesCursor /** * A set of parameters to identify a user with. Does not include the user ID, as @@ -443,7 +367,7 @@ export interface IdentifyUserRequest { */ timezone?: string | null; - [k: string]: unknown; +[k: string]: unknown } /** @@ -509,7 +433,7 @@ export interface InlineIdentifyUserRequest { */ timezone?: string | null; - [k: string]: unknown; +[k: string]: unknown } /** @@ -567,13 +491,13 @@ export interface User { */ timezone?: string | null; - [k: string]: unknown; +[k: string]: unknown } /** * A list of preference sets for the user. */ -export type UserListPreferencesResponse = Array; +export type UserListPreferencesResponse = Array export interface UserUpdateParams { /** @@ -627,7 +551,7 @@ export interface UserUpdateParams { */ timezone?: string | null; - [k: string]: unknown; +[k: string]: unknown } export interface UserListParams extends EntriesCursorParams { @@ -653,9 +577,7 @@ export interface UserListMessagesParams extends ItemsCursorParams { /** * Limits the results to messages with the given engagement status. */ - engagement_status?: Array< - 'seen' | 'unseen' | 'read' | 'unread' | 'archived' | 'unarchived' | 'link_clicked' | 'interacted' - >; + engagement_status?: Array<'seen' | 'unseen' | 'read' | 'unread' | 'archived' | 'unarchived' | 'link_clicked' | 'interacted'>; inserted_at?: UserListMessagesParams.InsertedAt; @@ -673,9 +595,7 @@ export interface UserListMessagesParams extends ItemsCursorParams { /** * Limits the results to messages with the given delivery status. */ - status?: Array< - 'queued' | 'sent' | 'delivered' | 'delivery_attempted' | 'undelivered' | 'not_sent' | 'bounced' - >; + status?: Array<'queued' | 'sent' | 'delivered' | 'delivery_attempted' | 'undelivered' | 'not_sent' | 'bounced'>; /** * Limits the results to items with the corresponding tenant. @@ -765,15 +685,7 @@ export interface UserSetChannelDataParams { /** * Channel data for a given channel type. */ - data: - | ChannelDataAPI.PushChannelDataTokensOnly - | ChannelDataAPI.PushChannelDataDevicesOnly - | ChannelDataAPI.AwsSnsPushChannelDataTargetArnsOnly - | ChannelDataAPI.AwsSnsPushChannelDataDevicesOnly - | ChannelDataAPI.OneSignalChannelDataPlayerIDsOnly - | ChannelDataAPI.SlackChannelData - | ChannelDataAPI.MsTeamsChannelData - | ChannelDataAPI.DiscordChannelData; + data: ChannelDataAPI.PushChannelDataTokensOnly | ChannelDataAPI.PushChannelDataDevicesOnly | ChannelDataAPI.AwsSnsPushChannelDataTargetArnsOnly | ChannelDataAPI.AwsSnsPushChannelDataDevicesOnly | ChannelDataAPI.OneSignalChannelDataPlayerIDsOnly | ChannelDataAPI.SlackChannelData | ChannelDataAPI.MsTeamsChannelData | ChannelDataAPI.DiscordChannelData; } export interface UserSetPreferencesParams { @@ -787,9 +699,7 @@ export interface UserSetPreferencesParams { * An object where the key is the category and the values are the preference * settings for that category. */ - categories?: { - [key: string]: boolean | UserSetPreferencesParams.PreferenceSetWorkflowCategorySettingObject; - } | null; + categories?: { [key: string]: boolean | UserSetPreferencesParams.PreferenceSetWorkflowCategorySettingObject } | null; /** * Channel type preferences. @@ -811,9 +721,7 @@ export interface UserSetPreferencesParams { * An object where the key is the workflow key and the values are the preference * settings for that workflow. */ - workflows?: { - [key: string]: boolean | UserSetPreferencesParams.PreferenceSetWorkflowCategorySettingObject; - } | null; + workflows?: { [key: string]: boolean | UserSetPreferencesParams.PreferenceSetWorkflowCategorySettingObject } | null; } export namespace UserSetPreferencesParams { @@ -879,7 +787,7 @@ export declare namespace Users { type UserListSubscriptionsParams as UserListSubscriptionsParams, type UserMergeParams as UserMergeParams, type UserSetChannelDataParams as UserSetChannelDataParams, - type UserSetPreferencesParams as UserSetPreferencesParams, + type UserSetPreferencesParams as UserSetPreferencesParams }; export { @@ -887,7 +795,7 @@ export declare namespace Users { type FeedGetSettingsResponse as FeedGetSettingsResponse, type FeedListItemsResponse as FeedListItemsResponse, type FeedListItemsResponsesEntriesCursor as FeedListItemsResponsesEntriesCursor, - type FeedListItemsParams as FeedListItemsParams, + type FeedListItemsParams as FeedListItemsParams }; export { @@ -899,15 +807,15 @@ export declare namespace Users { type GuideGetChannelParams as GuideGetChannelParams, type GuideMarkMessageAsArchivedParams as GuideMarkMessageAsArchivedParams, type GuideMarkMessageAsInteractedParams as GuideMarkMessageAsInteractedParams, - type GuideMarkMessageAsSeenParams as GuideMarkMessageAsSeenParams, + type GuideMarkMessageAsSeenParams as GuideMarkMessageAsSeenParams }; export { Bulk as Bulk, type BulkDeleteParams as BulkDeleteParams, type BulkIdentifyParams as BulkIdentifyParams, - type BulkSetPreferencesParams as BulkSetPreferencesParams, + type BulkSetPreferencesParams as BulkSetPreferencesParams }; } -export { type MessagesItemsCursor, type SchedulesEntriesCursor, type SubscriptionsEntriesCursor }; +export { type MessagesItemsCursor, type SchedulesEntriesCursor, type SubscriptionsEntriesCursor } diff --git a/src/resources/workflow-recipient-runs.ts b/src/resources/workflow-recipient-runs.ts index 795e627d..cae1bcff 100644 --- a/src/resources/workflow-recipient-runs.ts +++ b/src/resources/workflow-recipient-runs.ts @@ -22,14 +22,8 @@ export class WorkflowRecipientRuns extends APIResource { * } * ``` */ - list( - query: WorkflowRecipientRunListParams | null | undefined = {}, - options?: RequestOptions, - ): PagePromise { - return this._client.getAPIList('/v1/workflow_recipient_runs', ItemsCursor, { - query, - ...options, - }); + list(query: WorkflowRecipientRunListParams | null | undefined = {}, options?: RequestOptions): PagePromise { + return this._client.getAPIList('/v1/workflow_recipient_runs', ItemsCursor, { query, ...options }); } /** @@ -46,7 +40,7 @@ export class WorkflowRecipientRuns extends APIResource { } } -export type WorkflowRecipientRunsItemsCursor = ItemsCursor; +export type WorkflowRecipientRunsItemsCursor = ItemsCursor /** * A workflow recipient run represents an individual execution of a workflow for a @@ -251,6 +245,6 @@ export declare namespace WorkflowRecipientRuns { type WorkflowRecipientRunDetail as WorkflowRecipientRunDetail, type WorkflowRecipientRunEvent as WorkflowRecipientRunEvent, type WorkflowRecipientRunsItemsCursor as WorkflowRecipientRunsItemsCursor, - type WorkflowRecipientRunListParams as WorkflowRecipientRunListParams, + type WorkflowRecipientRunListParams as WorkflowRecipientRunListParams }; } diff --git a/src/resources/workflows.ts b/src/resources/workflows.ts index ad04e9da..99fbe744 100644 --- a/src/resources/workflows.ts +++ b/src/resources/workflows.ts @@ -26,11 +26,7 @@ export class Workflows extends APIResource { * ``` */ cancel(key: string, body: WorkflowCancelParams, options?: RequestOptions): APIPromise { - return this._client.post(path`/v1/workflows/${key}/cancel`, { - body, - ...options, - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), - }); + return this._client.post(path`/v1/workflows/${key}/cancel`, { body, ...options, headers: buildHeaders([{Accept: '*/*'}, options?.headers]) }); } /** @@ -62,11 +58,7 @@ export class Workflows extends APIResource { * }); * ``` */ - trigger( - key: string, - body: WorkflowTriggerParams, - options?: RequestOptions, - ): APIPromise { + trigger(key: string, body: WorkflowTriggerParams, options?: RequestOptions): APIPromise { return this._client.post(path`/v1/workflows/${key}/trigger`, { body, ...options }); } } @@ -140,6 +132,6 @@ export declare namespace Workflows { export { type WorkflowTriggerResponse as WorkflowTriggerResponse, type WorkflowCancelParams as WorkflowCancelParams, - type WorkflowTriggerParams as WorkflowTriggerParams, + type WorkflowTriggerParams as WorkflowTriggerParams }; } diff --git a/src/uploads.ts b/src/uploads.ts index b2ef6471..d5437085 100644 --- a/src/uploads.ts +++ b/src/uploads.ts @@ -1,2 +1,2 @@ /** @deprecated Import from ./core/uploads instead */ -export * from './core/uploads'; +export * from "./core/uploads" \ No newline at end of file diff --git a/src/version.ts b/src/version.ts index 49bad0d4..e6295542 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '1.32.0'; // x-release-please-version +export const VERSION = '1.33.0';// x-release-please-version diff --git a/tests/api-resources/audiences.test.ts b/tests/api-resources/audiences.test.ts index c719a089..2cb340eb 100644 --- a/tests/api-resources/audiences.test.ts +++ b/tests/api-resources/audiences.test.ts @@ -2,10 +2,7 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource audiences', () => { test('addMembers: only required params', async () => { @@ -20,212 +17,135 @@ describe('resource audiences', () => { }); test('addMembers: required and optional params', async () => { - const response = await client.audiences.addMembers('key', { - members: [ - { - user: { - id: 'dr_sattler', - avatar: 'avatar', - channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, - created_at: '2019-12-27T18:11:19.117Z', - email: 'ellie@ingen.net', - locale: 'locale', - name: 'Dr. Ellie Sattler', - phone_number: 'phone_number', - preferences: { - default: { - __persistence_strategy__: 'merge', - categories: { - marketing: false, - transactional: { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { - '2f641633-95d3-4555-9222-9f1eb7888a80': { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, - }, - commercial_subscribed: true, - workflows: { - 'dinosaurs-loose': { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - }, - }, - timezone: 'America/New_York', - }, - tenant: 'ingen_isla_nublar', - }, - ], - create_audience: true, - }); + const response = await client.audiences.addMembers('key', { members: [{ + user: { + id: 'dr_sattler', + avatar: 'avatar', + channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, + created_at: '2019-12-27T18:11:19.117Z', + email: 'ellie@ingen.net', + locale: 'locale', + name: 'Dr. Ellie Sattler', + phone_number: 'phone_number', + preferences: { default: { + __persistence_strategy__: 'merge', + categories: { + marketing: false, + transactional: { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + }, + }, + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { + '2f641633-95d3-4555-9222-9f1eb7888a80': { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, + }, + commercial_subscribed: true, + workflows: { 'dinosaurs-loose': { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + } }, + } }, + timezone: 'America/New_York', + }, + tenant: 'ingen_isla_nublar', + }], create_audience: true }); }); test('listMembers', async () => { @@ -240,9 +160,7 @@ describe('resource audiences', () => { }); test('removeMembers: only required params', async () => { - const responsePromise = client.audiences.removeMembers('key', { - members: [{ user: { id: 'dr_sattler' } }], - }); + const responsePromise = client.audiences.removeMembers('key', { members: [{ user: { id: 'dr_sattler' } }] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -253,210 +171,134 @@ describe('resource audiences', () => { }); test('removeMembers: required and optional params', async () => { - const response = await client.audiences.removeMembers('key', { - members: [ - { - user: { - id: 'dr_sattler', - avatar: 'avatar', - channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, - created_at: '2019-12-27T18:11:19.117Z', - email: 'ellie@ingen.net', - locale: 'locale', - name: 'Dr. Ellie Sattler', - phone_number: 'phone_number', - preferences: { - default: { - __persistence_strategy__: 'merge', - categories: { - marketing: false, - transactional: { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { - '2f641633-95d3-4555-9222-9f1eb7888a80': { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, - }, - commercial_subscribed: true, - workflows: { - 'dinosaurs-loose': { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - }, - }, - timezone: 'America/New_York', - }, - tenant: 'ingen_isla_nublar', - }, - ], - }); + const response = await client.audiences.removeMembers('key', { members: [{ + user: { + id: 'dr_sattler', + avatar: 'avatar', + channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, + created_at: '2019-12-27T18:11:19.117Z', + email: 'ellie@ingen.net', + locale: 'locale', + name: 'Dr. Ellie Sattler', + phone_number: 'phone_number', + preferences: { default: { + __persistence_strategy__: 'merge', + categories: { + marketing: false, + transactional: { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + }, + }, + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { + '2f641633-95d3-4555-9222-9f1eb7888a80': { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, + }, + commercial_subscribed: true, + workflows: { 'dinosaurs-loose': { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + } }, + } }, + timezone: 'America/New_York', + }, + tenant: 'ingen_isla_nublar', + }] }); }); }); diff --git a/tests/api-resources/bulk-operations.test.ts b/tests/api-resources/bulk-operations.test.ts index a80019c5..be33c1f0 100644 --- a/tests/api-resources/bulk-operations.test.ts +++ b/tests/api-resources/bulk-operations.test.ts @@ -2,10 +2,7 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource bulkOperations', () => { test('get', async () => { diff --git a/tests/api-resources/channels/bulk.test.ts b/tests/api-resources/channels/bulk.test.ts index 09e8f2f4..e637d7db 100644 --- a/tests/api-resources/channels/bulk.test.ts +++ b/tests/api-resources/channels/bulk.test.ts @@ -2,18 +2,11 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource bulk', () => { test('updateMessageStatus', async () => { - const responsePromise = client.channels.bulk.updateMessageStatus( - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - 'seen', - {}, - ); + const responsePromise = client.channels.bulk.updateMessageStatus('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', 'seen', {}); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; diff --git a/tests/api-resources/integrations/census.test.ts b/tests/api-resources/integrations/census.test.ts index 109c3910..a4838721 100644 --- a/tests/api-resources/integrations/census.test.ts +++ b/tests/api-resources/integrations/census.test.ts @@ -2,18 +2,15 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource census', () => { test('customDestination: only required params', async () => { const responsePromise = client.integrations.census.customDestination({ - id: 'id', - jsonrpc: 'jsonrpc', - method: 'method', - }); + id: 'id', + jsonrpc: 'jsonrpc', + method: 'method', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -25,10 +22,10 @@ describe('resource census', () => { test('customDestination: required and optional params', async () => { const response = await client.integrations.census.customDestination({ - id: 'id', - jsonrpc: 'jsonrpc', - method: 'method', - params: { foo: 'bar' }, - }); + id: 'id', + jsonrpc: 'jsonrpc', + method: 'method', + params: { foo: 'bar' }, + }); }); }); diff --git a/tests/api-resources/integrations/hightouch.test.ts b/tests/api-resources/integrations/hightouch.test.ts index 21a1fe26..d843c788 100644 --- a/tests/api-resources/integrations/hightouch.test.ts +++ b/tests/api-resources/integrations/hightouch.test.ts @@ -2,18 +2,15 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource hightouch', () => { test('embeddedDestination: only required params', async () => { const responsePromise = client.integrations.hightouch.embeddedDestination({ - id: 'id', - jsonrpc: 'jsonrpc', - method: 'method', - }); + id: 'id', + jsonrpc: 'jsonrpc', + method: 'method', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -25,10 +22,10 @@ describe('resource hightouch', () => { test('embeddedDestination: required and optional params', async () => { const response = await client.integrations.hightouch.embeddedDestination({ - id: 'id', - jsonrpc: 'jsonrpc', - method: 'method', - params: { foo: 'bar' }, - }); + id: 'id', + jsonrpc: 'jsonrpc', + method: 'method', + params: { foo: 'bar' }, + }); }); }); diff --git a/tests/api-resources/messages/batch.test.ts b/tests/api-resources/messages/batch.test.ts index d3c9c56d..c699d819 100644 --- a/tests/api-resources/messages/batch.test.ts +++ b/tests/api-resources/messages/batch.test.ts @@ -2,16 +2,11 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource batch', () => { test('archive: only required params', async () => { - const responsePromise = client.messages.batch.archive({ - message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'], - }); + const responsePromise = client.messages.batch.archive({ message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,9 +17,7 @@ describe('resource batch', () => { }); test('archive: required and optional params', async () => { - const response = await client.messages.batch.archive({ - message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'], - }); + const response = await client.messages.batch.archive({ message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'] }); }); // Mock server doesn't support array query params for this endpoint yet @@ -45,9 +38,7 @@ describe('resource batch', () => { }); test('markAsInteracted: only required params', async () => { - const responsePromise = client.messages.batch.markAsInteracted({ - message_ids: ['1jNaXzB2RZX3LY8wVQnfCKyPnv7'], - }); + const responsePromise = client.messages.batch.markAsInteracted({ message_ids: ['1jNaXzB2RZX3LY8wVQnfCKyPnv7'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -59,15 +50,13 @@ describe('resource batch', () => { test('markAsInteracted: required and optional params', async () => { const response = await client.messages.batch.markAsInteracted({ - message_ids: ['1jNaXzB2RZX3LY8wVQnfCKyPnv7'], - metadata: { key: 'bar' }, - }); + message_ids: ['1jNaXzB2RZX3LY8wVQnfCKyPnv7'], + metadata: { key: 'bar' }, + }); }); test('markAsRead: only required params', async () => { - const responsePromise = client.messages.batch.markAsRead({ - message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'], - }); + const responsePromise = client.messages.batch.markAsRead({ message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -78,15 +67,11 @@ describe('resource batch', () => { }); test('markAsRead: required and optional params', async () => { - const response = await client.messages.batch.markAsRead({ - message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'], - }); + const response = await client.messages.batch.markAsRead({ message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'] }); }); test('markAsSeen: only required params', async () => { - const responsePromise = client.messages.batch.markAsSeen({ - message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'], - }); + const responsePromise = client.messages.batch.markAsSeen({ message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -97,15 +82,11 @@ describe('resource batch', () => { }); test('markAsSeen: required and optional params', async () => { - const response = await client.messages.batch.markAsSeen({ - message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'], - }); + const response = await client.messages.batch.markAsSeen({ message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'] }); }); test('markAsUnread: only required params', async () => { - const responsePromise = client.messages.batch.markAsUnread({ - message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'], - }); + const responsePromise = client.messages.batch.markAsUnread({ message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -116,15 +97,11 @@ describe('resource batch', () => { }); test('markAsUnread: required and optional params', async () => { - const response = await client.messages.batch.markAsUnread({ - message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'], - }); + const response = await client.messages.batch.markAsUnread({ message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'] }); }); test('markAsUnseen: only required params', async () => { - const responsePromise = client.messages.batch.markAsUnseen({ - message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'], - }); + const responsePromise = client.messages.batch.markAsUnseen({ message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -135,15 +112,11 @@ describe('resource batch', () => { }); test('markAsUnseen: required and optional params', async () => { - const response = await client.messages.batch.markAsUnseen({ - message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'], - }); + const response = await client.messages.batch.markAsUnseen({ message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'] }); }); test('unarchive: only required params', async () => { - const responsePromise = client.messages.batch.unarchive({ - message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'], - }); + const responsePromise = client.messages.batch.unarchive({ message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -154,8 +127,6 @@ describe('resource batch', () => { }); test('unarchive: required and optional params', async () => { - const response = await client.messages.batch.unarchive({ - message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'], - }); + const response = await client.messages.batch.unarchive({ message_ids: ['2w3YUpTTOxuDvZFji8OMsKrG176', '2w3YVRbPXMIh8Zq6oBFcVDA5xes'] }); }); }); diff --git a/tests/api-resources/messages/messages.test.ts b/tests/api-resources/messages/messages.test.ts index 17829107..eeea9a6f 100644 --- a/tests/api-resources/messages/messages.test.ts +++ b/tests/api-resources/messages/messages.test.ts @@ -2,10 +2,7 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource messages', () => { test('list', async () => { @@ -21,32 +18,29 @@ describe('resource messages', () => { test('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.messages.list( - { - after: 'after', - before: 'before', - channel_id: 'channel_id', - engagement_status: ['seen'], - inserted_at: { - gt: 'gt', - gte: 'gte', - lt: 'lt', - lte: 'lte', - }, - message_ids: ['string'], - page_size: 0, - source: 'source', - status: ['queued'], - tenant: 'tenant', - trigger_data: 'trigger_data', - workflow_categories: ['string'], - workflow_recipient_run_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - workflow_run_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.messages.list({ + after: 'after', + before: 'before', + channel_id: 'channel_id', + engagement_status: ['seen'], + inserted_at: { + gt: 'gt', + gte: 'gte', + lt: 'lt', + lte: 'lte', + }, + message_ids: ['string'], + page_size: 0, + source: 'source', + status: ['queued'], + tenant: 'tenant', + trigger_data: 'trigger_data', + workflow_categories: ['string'], + workflow_recipient_run_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + workflow_run_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('archive', async () => { @@ -95,18 +89,14 @@ describe('resource messages', () => { test('listActivities: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.messages.listActivities( - 'message_id', - { - after: 'after', - before: 'before', - page_size: 0, - trigger_data: 'trigger_data', - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.messages.listActivities('message_id', { + after: 'after', + before: 'before', + page_size: 0, + trigger_data: 'trigger_data', + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('listDeliveryLogs', async () => { @@ -122,17 +112,13 @@ describe('resource messages', () => { test('listDeliveryLogs: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.messages.listDeliveryLogs( - 'message_id', - { - after: 'after', - before: 'before', - page_size: 0, - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.messages.listDeliveryLogs('message_id', { + after: 'after', + before: 'before', + page_size: 0, + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('listEvents', async () => { @@ -148,17 +134,13 @@ describe('resource messages', () => { test('listEvents: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.messages.listEvents( - 'message_id', - { - after: 'after', - before: 'before', - page_size: 0, - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.messages.listEvents('message_id', { + after: 'after', + before: 'before', + page_size: 0, + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('markAsInteracted', async () => { @@ -174,13 +156,9 @@ describe('resource messages', () => { test('markAsInteracted: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.messages.markAsInteracted( - '1jNaXzB2RZX3LY8wVQnfCKyPnv7', - { metadata: { key: 'bar' } }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.messages.markAsInteracted('1jNaXzB2RZX3LY8wVQnfCKyPnv7', { metadata: { key: 'bar' } }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('markAsRead', async () => { diff --git a/tests/api-resources/objects/bulk.test.ts b/tests/api-resources/objects/bulk.test.ts index 3d648f8b..079b6995 100644 --- a/tests/api-resources/objects/bulk.test.ts +++ b/tests/api-resources/objects/bulk.test.ts @@ -2,16 +2,11 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource bulk', () => { test('delete: only required params', async () => { - const responsePromise = client.objects.bulk.delete('collection', { - object_ids: ['obj_123', 'obj_456', 'obj_789'], - }); + const responsePromise = client.objects.bulk.delete('collection', { object_ids: ['obj_123', 'obj_456', 'obj_789'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,15 +17,11 @@ describe('resource bulk', () => { }); test('delete: required and optional params', async () => { - const response = await client.objects.bulk.delete('collection', { - object_ids: ['obj_123', 'obj_456', 'obj_789'], - }); + const response = await client.objects.bulk.delete('collection', { object_ids: ['obj_123', 'obj_456', 'obj_789'] }); }); test('addSubscriptions: only required params', async () => { - const responsePromise = client.objects.bulk.addSubscriptions('projects', { - subscriptions: [{ id: 'project-1', recipients: [{ id: 'user_1' }] }], - }); + const responsePromise = client.objects.bulk.addSubscriptions('projects', { subscriptions: [{ id: 'project-1', recipients: [{ id: 'user_1' }] }] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -41,223 +32,140 @@ describe('resource bulk', () => { }); test('addSubscriptions: required and optional params', async () => { - const response = await client.objects.bulk.addSubscriptions('projects', { - subscriptions: [ - { - id: 'project-1', - recipients: [ - { - id: 'user_1', - avatar: 'avatar', - channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, - created_at: '2019-12-27T18:11:19.117Z', - email: 'jane@ingen.net', - locale: 'locale', - name: 'Jane Doe', - phone_number: 'phone_number', - preferences: { - default: { - __persistence_strategy__: 'merge', - categories: { - marketing: false, - transactional: { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { - '2f641633-95d3-4555-9222-9f1eb7888a80': { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, - }, - commercial_subscribed: true, - workflows: { - 'dinosaurs-loose': { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - }, - }, - timezone: 'America/New_York', - }, - ], - properties: { foo: 'bar' }, - }, - ], - }); + const response = await client.objects.bulk.addSubscriptions('projects', { subscriptions: [{ + id: 'project-1', + recipients: [{ + id: 'user_1', + avatar: 'avatar', + channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, + created_at: '2019-12-27T18:11:19.117Z', + email: 'jane@ingen.net', + locale: 'locale', + name: 'Jane Doe', + phone_number: 'phone_number', + preferences: { default: { + __persistence_strategy__: 'merge', + categories: { + marketing: false, + transactional: { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + }, + }, + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { + '2f641633-95d3-4555-9222-9f1eb7888a80': { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, + }, + commercial_subscribed: true, + workflows: { 'dinosaurs-loose': { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + } }, + } }, + timezone: 'America/New_York', + }], + properties: { foo: 'bar' }, + }] }); }); test('deleteSubscriptions: only required params', async () => { - const responsePromise = client.objects.bulk.deleteSubscriptions('projects', { - subscriptions: [ - { id: 'subscribed-to-object-1', recipients: [{}, 'subscriber-user-1'] }, - { id: 'subscribed-to-object-2', recipients: ['subscriber-user-2'] }, - ], - }); + const responsePromise = client.objects.bulk.deleteSubscriptions('projects', { subscriptions: [{ id: 'subscribed-to-object-1', recipients: [{}, 'subscriber-user-1'] }, { id: 'subscribed-to-object-2', recipients: ['subscriber-user-2'] }] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -268,15 +176,7 @@ describe('resource bulk', () => { }); test('deleteSubscriptions: required and optional params', async () => { - const response = await client.objects.bulk.deleteSubscriptions('projects', { - subscriptions: [ - { - id: 'subscribed-to-object-1', - recipients: [{ id: 'subscriber-project-1', collection: 'projects' }, 'subscriber-user-1'], - }, - { id: 'subscribed-to-object-2', recipients: ['subscriber-user-2'] }, - ], - }); + const response = await client.objects.bulk.deleteSubscriptions('projects', { subscriptions: [{ id: 'subscribed-to-object-1', recipients: [{ id: 'subscriber-project-1', collection: 'projects' }, 'subscriber-user-1'] }, { id: 'subscribed-to-object-2', recipients: ['subscriber-user-2'] }] }); }); test('set: only required params', async () => { @@ -291,201 +191,123 @@ describe('resource bulk', () => { }); test('set: required and optional params', async () => { - const response = await client.objects.bulk.set('collection', { - objects: [ - { - id: 'project_1', - channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_xxx'] } }, - created_at: '2019-12-27T18:11:19.117Z', - name: 'My project', - preferences: { - default: { - __persistence_strategy__: 'merge', - categories: { - transactional: { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { - '2f641633-95d3-4555-9222-9f1eb7888a80': { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, - }, - commercial_subscribed: true, - workflows: { - 'dinosaurs-loose': { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - }, - }, - }, - ], - }); + const response = await client.objects.bulk.set('collection', { objects: [{ + id: 'project_1', + channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_xxx'] } }, + created_at: '2019-12-27T18:11:19.117Z', + name: 'My project', + preferences: { default: { + __persistence_strategy__: 'merge', + categories: { transactional: { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + } }, + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { + '2f641633-95d3-4555-9222-9f1eb7888a80': { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, + }, + commercial_subscribed: true, + workflows: { 'dinosaurs-loose': { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + } }, + } }, + }] }); }); }); diff --git a/tests/api-resources/objects/objects.test.ts b/tests/api-resources/objects/objects.test.ts index b3bb38f4..f33b6d9b 100644 --- a/tests/api-resources/objects/objects.test.ts +++ b/tests/api-resources/objects/objects.test.ts @@ -2,10 +2,7 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource objects', () => { test('list', async () => { @@ -21,18 +18,14 @@ describe('resource objects', () => { test('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.objects.list( - 'collection', - { - after: 'after', - before: 'before', - include: ['preferences'], - page_size: 0, - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.objects.list('collection', { + after: 'after', + before: 'before', + include: ['preferences'], + page_size: 0, + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('delete', async () => { @@ -47,9 +40,7 @@ describe('resource objects', () => { }); test('addSubscriptions: only required params', async () => { - const responsePromise = client.objects.addSubscriptions('collection', 'object_id', { - recipients: ['user_1', 'user_2'], - }); + const responsePromise = client.objects.addSubscriptions('collection', 'object_id', { recipients: ['user_1', 'user_2'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -61,15 +52,13 @@ describe('resource objects', () => { test('addSubscriptions: required and optional params', async () => { const response = await client.objects.addSubscriptions('collection', 'object_id', { - recipients: ['user_1', 'user_2'], - properties: { key: 'bar' }, - }); + recipients: ['user_1', 'user_2'], + properties: { key: 'bar' }, + }); }); test('deleteSubscriptions: only required params', async () => { - const responsePromise = client.objects.deleteSubscriptions('collection', 'object_id', { - recipients: ['user_123'], - }); + const responsePromise = client.objects.deleteSubscriptions('collection', 'object_id', { recipients: ['user_123'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -80,9 +69,7 @@ describe('resource objects', () => { }); test('deleteSubscriptions: required and optional params', async () => { - const response = await client.objects.deleteSubscriptions('collection', 'object_id', { - recipients: ['user_123'], - }); + const response = await client.objects.deleteSubscriptions('collection', 'object_id', { recipients: ['user_123'] }); }); test('get', async () => { @@ -97,11 +84,7 @@ describe('resource objects', () => { }); test('getChannelData', async () => { - const responsePromise = client.objects.getChannelData( - 'collection', - 'object_id', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - ); + const responsePromise = client.objects.getChannelData('collection', 'object_id', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -135,34 +118,29 @@ describe('resource objects', () => { test('listMessages: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.objects.listMessages( - 'projects', - 'project-123', - { - after: 'after', - before: 'before', - channel_id: 'channel_id', - engagement_status: ['seen'], - inserted_at: { - gt: 'gt', - gte: 'gte', - lt: 'lt', - lte: 'lte', - }, - message_ids: ['string'], - page_size: 0, - source: 'source', - status: ['queued'], - tenant: 'tenant', - trigger_data: 'trigger_data', - workflow_categories: ['string'], - workflow_recipient_run_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - workflow_run_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.objects.listMessages('projects', 'project-123', { + after: 'after', + before: 'before', + channel_id: 'channel_id', + engagement_status: ['seen'], + inserted_at: { + gt: 'gt', + gte: 'gte', + lt: 'lt', + lte: 'lte', + }, + message_ids: ['string'], + page_size: 0, + source: 'source', + status: ['queued'], + tenant: 'tenant', + trigger_data: 'trigger_data', + workflow_categories: ['string'], + workflow_recipient_run_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + workflow_run_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('listPreferences', async () => { @@ -189,20 +167,15 @@ describe('resource objects', () => { test('listSchedules: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.objects.listSchedules( - 'collection', - 'id', - { - after: 'after', - before: 'before', - page_size: 0, - tenant: 'tenant', - workflow: 'workflow', - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.objects.listSchedules('collection', 'id', { + after: 'after', + before: 'before', + page_size: 0, + tenant: 'tenant', + workflow: 'workflow', + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('listSubscriptions', async () => { @@ -218,22 +191,17 @@ describe('resource objects', () => { test('listSubscriptions: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.objects.listSubscriptions( - 'collection', - 'object_id', - { - after: 'after', - before: 'before', - include: ['preferences'], - mode: 'recipient', - objects: [{ id: 'project_123', collection: 'projects' }], - page_size: 0, - recipients: ['user_123'], - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.objects.listSubscriptions('collection', 'object_id', { + after: 'after', + before: 'before', + include: ['preferences'], + mode: 'recipient', + objects: [{ id: 'project_123', collection: 'projects' }], + page_size: 0, + recipients: ['user_123'], + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('set', async () => { @@ -248,12 +216,7 @@ describe('resource objects', () => { }); test('setChannelData: only required params', async () => { - const responsePromise = client.objects.setChannelData( - 'collection', - 'object_id', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { data: { tokens: ['push_token_1'] } }, - ); + const responsePromise = client.objects.setChannelData('collection', 'object_id', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { data: { tokens: ['push_token_1'] } }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -264,12 +227,7 @@ describe('resource objects', () => { }); test('setChannelData: required and optional params', async () => { - const response = await client.objects.setChannelData( - 'collection', - 'object_id', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { data: { tokens: ['push_token_1'] } }, - ); + const response = await client.objects.setChannelData('collection', 'object_id', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { data: { tokens: ['push_token_1'] } }); }); test('setPreferences', async () => { @@ -284,11 +242,7 @@ describe('resource objects', () => { }); test('unsetChannelData', async () => { - const responsePromise = client.objects.unsetChannelData( - 'collection', - 'object_id', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - ); + const responsePromise = client.objects.unsetChannelData('collection', 'object_id', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; diff --git a/tests/api-resources/providers/ms-teams.test.ts b/tests/api-resources/providers/ms-teams.test.ts index 5682c7b4..be7f38e6 100644 --- a/tests/api-resources/providers/ms-teams.test.ts +++ b/tests/api-resources/providers/ms-teams.test.ts @@ -2,16 +2,11 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource msTeams', () => { test('checkAuth: only required params', async () => { - const responsePromise = client.providers.msTeams.checkAuth('channel_id', { - ms_teams_tenant_object: 'ms_teams_tenant_object', - }); + const responsePromise = client.providers.msTeams.checkAuth('channel_id', { ms_teams_tenant_object: 'ms_teams_tenant_object' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,16 +17,11 @@ describe('resource msTeams', () => { }); test('checkAuth: required and optional params', async () => { - const response = await client.providers.msTeams.checkAuth('channel_id', { - ms_teams_tenant_object: 'ms_teams_tenant_object', - }); + const response = await client.providers.msTeams.checkAuth('channel_id', { ms_teams_tenant_object: 'ms_teams_tenant_object' }); }); test('listChannels: only required params', async () => { - const responsePromise = client.providers.msTeams.listChannels('channel_id', { - ms_teams_tenant_object: 'ms_teams_tenant_object', - team_id: 'team_id', - }); + const responsePromise = client.providers.msTeams.listChannels('channel_id', { ms_teams_tenant_object: 'ms_teams_tenant_object', team_id: 'team_id' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -43,16 +33,14 @@ describe('resource msTeams', () => { test('listChannels: required and optional params', async () => { const response = await client.providers.msTeams.listChannels('channel_id', { - ms_teams_tenant_object: 'ms_teams_tenant_object', - team_id: 'team_id', - query_options: { $filter: '$filter', $select: '$select' }, - }); + ms_teams_tenant_object: 'ms_teams_tenant_object', + team_id: 'team_id', + query_options: { $filter: '$filter', $select: '$select' }, + }); }); test('listTeams: only required params', async () => { - const responsePromise = client.providers.msTeams.listTeams('channel_id', { - ms_teams_tenant_object: 'ms_teams_tenant_object', - }); + const responsePromise = client.providers.msTeams.listTeams('channel_id', { ms_teams_tenant_object: 'ms_teams_tenant_object' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -64,20 +52,18 @@ describe('resource msTeams', () => { test('listTeams: required and optional params', async () => { const response = await client.providers.msTeams.listTeams('channel_id', { - ms_teams_tenant_object: 'ms_teams_tenant_object', - query_options: { - $filter: '$filter', - $select: '$select', - $skiptoken: '$skiptoken', - $top: 0, - }, - }); + ms_teams_tenant_object: 'ms_teams_tenant_object', + query_options: { + $filter: '$filter', + $select: '$select', + $skiptoken: '$skiptoken', + $top: 0, + }, + }); }); test('revokeAccess: only required params', async () => { - const responsePromise = client.providers.msTeams.revokeAccess('channel_id', { - ms_teams_tenant_object: 'ms_teams_tenant_object', - }); + const responsePromise = client.providers.msTeams.revokeAccess('channel_id', { ms_teams_tenant_object: 'ms_teams_tenant_object' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -88,8 +74,6 @@ describe('resource msTeams', () => { }); test('revokeAccess: required and optional params', async () => { - const response = await client.providers.msTeams.revokeAccess('channel_id', { - ms_teams_tenant_object: 'ms_teams_tenant_object', - }); + const response = await client.providers.msTeams.revokeAccess('channel_id', { ms_teams_tenant_object: 'ms_teams_tenant_object' }); }); }); diff --git a/tests/api-resources/providers/slack.test.ts b/tests/api-resources/providers/slack.test.ts index 49ccf740..a1e3ec83 100644 --- a/tests/api-resources/providers/slack.test.ts +++ b/tests/api-resources/providers/slack.test.ts @@ -2,16 +2,11 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource slack', () => { test('checkAuth: only required params', async () => { - const responsePromise = client.providers.slack.checkAuth('channel_id', { - access_token_object: 'access_token_object', - }); + const responsePromise = client.providers.slack.checkAuth('channel_id', { access_token_object: 'access_token_object' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,15 +17,11 @@ describe('resource slack', () => { }); test('checkAuth: required and optional params', async () => { - const response = await client.providers.slack.checkAuth('channel_id', { - access_token_object: 'access_token_object', - }); + const response = await client.providers.slack.checkAuth('channel_id', { access_token_object: 'access_token_object' }); }); test('listChannels: only required params', async () => { - const responsePromise = client.providers.slack.listChannels('channel_id', { - access_token_object: 'access_token_object', - }); + const responsePromise = client.providers.slack.listChannels('channel_id', { access_token_object: 'access_token_object' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -42,21 +33,19 @@ describe('resource slack', () => { test('listChannels: required and optional params', async () => { const response = await client.providers.slack.listChannels('channel_id', { - access_token_object: 'access_token_object', - query_options: { - cursor: 'cursor', - exclude_archived: true, - limit: 0, - team_id: 'team_id', - types: 'types', - }, - }); + access_token_object: 'access_token_object', + query_options: { + cursor: 'cursor', + exclude_archived: true, + limit: 0, + team_id: 'team_id', + types: 'types', + }, + }); }); test('revokeAccess: only required params', async () => { - const responsePromise = client.providers.slack.revokeAccess('channel_id', { - access_token_object: 'access_token_object', - }); + const responsePromise = client.providers.slack.revokeAccess('channel_id', { access_token_object: 'access_token_object' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -67,8 +56,6 @@ describe('resource slack', () => { }); test('revokeAccess: required and optional params', async () => { - const response = await client.providers.slack.revokeAccess('channel_id', { - access_token_object: 'access_token_object', - }); + const response = await client.providers.slack.revokeAccess('channel_id', { access_token_object: 'access_token_object' }); }); }); diff --git a/tests/api-resources/schedules/bulk.test.ts b/tests/api-resources/schedules/bulk.test.ts index a3890fa0..a14bcf21 100644 --- a/tests/api-resources/schedules/bulk.test.ts +++ b/tests/api-resources/schedules/bulk.test.ts @@ -2,16 +2,11 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource bulk', () => { test('create: only required params', async () => { - const responsePromise = client.schedules.bulk.create({ - schedules: [{ workflow: 'comment-created' }, { workflow: 'comment-created' }], - }); + const responsePromise = client.schedules.bulk.create({ schedules: [{ workflow: 'comment-created' }, { workflow: 'comment-created' }] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -22,443 +17,290 @@ describe('resource bulk', () => { }); test('create: required and optional params', async () => { - const response = await client.schedules.bulk.create({ - schedules: [ - { - workflow: 'comment-created', - actor: { - id: 'user_1', - avatar: 'avatar', - channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, - created_at: '2019-12-27T18:11:19.117Z', - email: 'jane@ingen.net', - locale: 'locale', - name: 'Jane Doe', - phone_number: 'phone_number', - preferences: { - default: { - __persistence_strategy__: 'merge', - categories: { - marketing: false, - transactional: { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { - '2f641633-95d3-4555-9222-9f1eb7888a80': { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, - }, - commercial_subscribed: true, - workflows: { - 'dinosaurs-loose': { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - }, - }, - timezone: 'America/New_York', - }, - data: { key: 'bar' }, - ending_at: null, - recipient: 'dnedry', - repeats: [ - { - frequency: 'daily', - __typename: 'ScheduleRepeat', - day_of_month: null, - days: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'], - hours: null, - interval: 1, - minutes: null, - }, - ], - scheduled_at: null, - tenant: 'acme_corp', - }, - { - workflow: 'comment-created', - actor: { - id: 'user_1', - avatar: 'avatar', - channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, - created_at: '2019-12-27T18:11:19.117Z', - email: 'jane@ingen.net', - locale: 'locale', - name: 'Jane Doe', - phone_number: 'phone_number', - preferences: { - default: { - __persistence_strategy__: 'merge', - categories: { - marketing: false, - transactional: { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { - '2f641633-95d3-4555-9222-9f1eb7888a80': { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, - }, - commercial_subscribed: true, - workflows: { - 'dinosaurs-loose': { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - }, - }, - timezone: 'America/New_York', - }, - data: { key: 'bar' }, - ending_at: null, - recipient: 'esattler', - repeats: [ - { - frequency: 'daily', - __typename: 'ScheduleRepeat', - day_of_month: null, - days: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'], - hours: null, - interval: 1, - minutes: null, - }, - ], - scheduled_at: null, - tenant: 'acme_corp', - }, - ], - }); + const response = await client.schedules.bulk.create({ schedules: [{ + workflow: 'comment-created', + actor: { + id: 'user_1', + avatar: 'avatar', + channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, + created_at: '2019-12-27T18:11:19.117Z', + email: 'jane@ingen.net', + locale: 'locale', + name: 'Jane Doe', + phone_number: 'phone_number', + preferences: { default: { + __persistence_strategy__: 'merge', + categories: { + marketing: false, + transactional: { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + }, + }, + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { + '2f641633-95d3-4555-9222-9f1eb7888a80': { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, + }, + commercial_subscribed: true, + workflows: { 'dinosaurs-loose': { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + } }, + } }, + timezone: 'America/New_York', + }, + data: { key: 'bar' }, + ending_at: null, + recipient: 'dnedry', + repeats: [{ + frequency: 'daily', + __typename: 'ScheduleRepeat', + day_of_month: null, + days: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'], + hours: null, + interval: 1, + minutes: null, + }], + scheduled_at: null, + tenant: 'acme_corp', + }, { + workflow: 'comment-created', + actor: { + id: 'user_1', + avatar: 'avatar', + channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, + created_at: '2019-12-27T18:11:19.117Z', + email: 'jane@ingen.net', + locale: 'locale', + name: 'Jane Doe', + phone_number: 'phone_number', + preferences: { default: { + __persistence_strategy__: 'merge', + categories: { + marketing: false, + transactional: { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + }, + }, + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { + '2f641633-95d3-4555-9222-9f1eb7888a80': { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, + }, + commercial_subscribed: true, + workflows: { 'dinosaurs-loose': { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + } }, + } }, + timezone: 'America/New_York', + }, + data: { key: 'bar' }, + ending_at: null, + recipient: 'esattler', + repeats: [{ + frequency: 'daily', + __typename: 'ScheduleRepeat', + day_of_month: null, + days: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'], + hours: null, + interval: 1, + minutes: null, + }], + scheduled_at: null, + tenant: 'acme_corp', + }] }); }); }); diff --git a/tests/api-resources/schedules/schedules.test.ts b/tests/api-resources/schedules/schedules.test.ts index 8b94f8c6..be47f72b 100644 --- a/tests/api-resources/schedules/schedules.test.ts +++ b/tests/api-resources/schedules/schedules.test.ts @@ -2,17 +2,11 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource schedules', () => { test('create: only required params', async () => { - const responsePromise = client.schedules.create({ - recipients: ['user_123'], - workflow: 'comment-created', - }); + const responsePromise = client.schedules.create({ recipients: ['user_123'], workflow: 'comment-created' }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -24,228 +18,152 @@ describe('resource schedules', () => { test('create: required and optional params', async () => { const response = await client.schedules.create({ - recipients: ['user_123'], - workflow: 'comment-created', - actor: { - id: 'user_1', - avatar: 'avatar', - channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, - created_at: '2019-12-27T18:11:19.117Z', - email: 'jane@ingen.net', - locale: 'locale', - name: 'Jane Doe', - phone_number: 'phone_number', - preferences: { - default: { - __persistence_strategy__: 'merge', - categories: { - marketing: false, - transactional: { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { - '2f641633-95d3-4555-9222-9f1eb7888a80': { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, - }, - commercial_subscribed: true, - workflows: { - 'dinosaurs-loose': { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - }, - }, - timezone: 'America/New_York', - }, - data: { key: 'bar' }, - ending_at: null, - repeats: [ - { - frequency: 'daily', - __typename: 'ScheduleRepeat', - day_of_month: null, - days: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'], - hours: null, - interval: 1, - minutes: null, - }, - ], - scheduled_at: null, - tenant: 'acme_corp', - }); + recipients: ['user_123'], + workflow: 'comment-created', + actor: { + id: 'user_1', + avatar: 'avatar', + channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, + created_at: '2019-12-27T18:11:19.117Z', + email: 'jane@ingen.net', + locale: 'locale', + name: 'Jane Doe', + phone_number: 'phone_number', + preferences: { default: { + __persistence_strategy__: 'merge', + categories: { + marketing: false, + transactional: { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + }, + }, + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { + '2f641633-95d3-4555-9222-9f1eb7888a80': { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, + }, + commercial_subscribed: true, + workflows: { 'dinosaurs-loose': { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + } }, + } }, + timezone: 'America/New_York', + }, + data: { key: 'bar' }, + ending_at: null, + repeats: [{ + frequency: 'daily', + __typename: 'ScheduleRepeat', + day_of_month: null, + days: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'], + hours: null, + interval: 1, + minutes: null, + }], + scheduled_at: null, + tenant: 'acme_corp', + }); }); test('update: only required params', async () => { - const responsePromise = client.schedules.update({ - schedule_ids: ['123e4567-e89b-12d3-a456-426614174000'], - }); + const responsePromise = client.schedules.update({ schedule_ids: ['123e4567-e89b-12d3-a456-426614174000'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -257,24 +175,22 @@ describe('resource schedules', () => { test('update: required and optional params', async () => { const response = await client.schedules.update({ - schedule_ids: ['123e4567-e89b-12d3-a456-426614174000'], - actor: 'string', - data: { key: 'bar' }, - ending_at: null, - repeats: [ - { - frequency: 'daily', - __typename: 'ScheduleRepeat', - day_of_month: null, - days: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'], - hours: null, - interval: 1, - minutes: null, - }, - ], - scheduled_at: null, - tenant: 'acme_corp', - }); + schedule_ids: ['123e4567-e89b-12d3-a456-426614174000'], + actor: 'string', + data: { key: 'bar' }, + ending_at: null, + repeats: [{ + frequency: 'daily', + __typename: 'ScheduleRepeat', + day_of_month: null, + days: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'], + hours: null, + interval: 1, + minutes: null, + }], + scheduled_at: null, + tenant: 'acme_corp', + }); }); test('list: only required params', async () => { @@ -290,19 +206,17 @@ describe('resource schedules', () => { test('list: required and optional params', async () => { const response = await client.schedules.list({ - workflow: 'workflow', - after: 'after', - before: 'before', - page_size: 0, - recipients: ['user_123'], - tenant: 'tenant', - }); + workflow: 'workflow', + after: 'after', + before: 'before', + page_size: 0, + recipients: ['user_123'], + tenant: 'tenant', + }); }); test('delete: only required params', async () => { - const responsePromise = client.schedules.delete({ - schedule_ids: ['123e4567-e89b-12d3-a456-426614174000'], - }); + const responsePromise = client.schedules.delete({ schedule_ids: ['123e4567-e89b-12d3-a456-426614174000'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -313,8 +227,6 @@ describe('resource schedules', () => { }); test('delete: required and optional params', async () => { - const response = await client.schedules.delete({ - schedule_ids: ['123e4567-e89b-12d3-a456-426614174000'], - }); + const response = await client.schedules.delete({ schedule_ids: ['123e4567-e89b-12d3-a456-426614174000'] }); }); }); diff --git a/tests/api-resources/tenants/bulk.test.ts b/tests/api-resources/tenants/bulk.test.ts index 72f4d4ee..e3d7f799 100644 --- a/tests/api-resources/tenants/bulk.test.ts +++ b/tests/api-resources/tenants/bulk.test.ts @@ -2,10 +2,7 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource bulk', () => { // Mock server doesn't support array query params for this endpoint yet @@ -37,393 +34,245 @@ describe('resource bulk', () => { }); test('set: required and optional params', async () => { - const response = await client.tenants.bulk.set({ - tenants: [ - { - id: 'tenant_1', - channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_xxx'] } }, - name: 'Acme Corp, Inc.', - preferences: { - default: { - __persistence_strategy__: 'merge', - categories: { - transactional: { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { - '2f641633-95d3-4555-9222-9f1eb7888a80': { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, - }, - commercial_subscribed: true, - workflows: { - 'dinosaurs-loose': { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - }, - }, - settings: { - branding: { - icon_url: 'https://example.com/icon.png', - logo_url: 'https://example.com/logo.png', - primary_color: '#000000', - primary_color_contrast: '#FFFFFF', - }, - preference_set: { - __persistence_strategy__: 'merge', - categories: { - marketing: false, - transactional: { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { - '2f641633-95d3-4555-9222-9f1eb7888a80': { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, - }, - commercial_subscribed: true, - workflows: { - 'dinosaurs-loose': { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - }, - }, - }, - ], - }); + const response = await client.tenants.bulk.set({ tenants: [{ + id: 'tenant_1', + channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_xxx'] } }, + name: 'Acme Corp, Inc.', + preferences: { default: { + __persistence_strategy__: 'merge', + categories: { transactional: { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + } }, + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { + '2f641633-95d3-4555-9222-9f1eb7888a80': { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, + }, + commercial_subscribed: true, + workflows: { 'dinosaurs-loose': { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + } }, + } }, + settings: { + branding: { + icon_url: 'https://example.com/icon.png', + logo_url: 'https://example.com/logo.png', + primary_color: '#000000', + primary_color_contrast: '#FFFFFF', + }, + preference_set: { + __persistence_strategy__: 'merge', + categories: { + marketing: false, + transactional: { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + }, + }, + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { + '2f641633-95d3-4555-9222-9f1eb7888a80': { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, + }, + commercial_subscribed: true, + workflows: { 'dinosaurs-loose': { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + } }, + }, + }, + }] }); }); }); diff --git a/tests/api-resources/tenants/tenants.test.ts b/tests/api-resources/tenants/tenants.test.ts index 2f20cb40..ade0b582 100644 --- a/tests/api-resources/tenants/tenants.test.ts +++ b/tests/api-resources/tenants/tenants.test.ts @@ -2,10 +2,7 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource tenants', () => { test('list', async () => { @@ -21,18 +18,15 @@ describe('resource tenants', () => { test('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.tenants.list( - { - after: 'after', - before: 'before', - name: 'name', - page_size: 0, - tenant_id: 'tenant_id', - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.tenants.list({ + after: 'after', + before: 'before', + name: 'name', + page_size: 0, + tenant_id: 'tenant_id', + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('delete', async () => { @@ -59,13 +53,9 @@ describe('resource tenants', () => { test('get: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.tenants.get( - 'id', - { resolve_full_preference_settings: true }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.tenants.get('id', { resolve_full_preference_settings: true }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('set', async () => { diff --git a/tests/api-resources/users/bulk.test.ts b/tests/api-resources/users/bulk.test.ts index 4522879d..15219fa3 100644 --- a/tests/api-resources/users/bulk.test.ts +++ b/tests/api-resources/users/bulk.test.ts @@ -2,10 +2,7 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource bulk', () => { test('delete: only required params', async () => { @@ -35,215 +32,139 @@ describe('resource bulk', () => { }); test('identify: required and optional params', async () => { - const response = await client.users.bulk.identify({ - users: [ - { - id: 'user_1', - avatar: 'avatar', - channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, - created_at: '2019-12-27T18:11:19.117Z', - email: 'jane@ingen.net', - locale: 'locale', - name: 'Jane Doe', - phone_number: 'phone_number', - preferences: { - default: { - __persistence_strategy__: 'merge', - categories: { - marketing: false, - transactional: { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { - '2f641633-95d3-4555-9222-9f1eb7888a80': { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, - }, - commercial_subscribed: true, - workflows: { - 'dinosaurs-loose': { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - }, - }, - timezone: 'America/New_York', - }, - ], - }); + const response = await client.users.bulk.identify({ users: [{ + id: 'user_1', + avatar: 'avatar', + channel_data: { '97c5837d-c65c-4d54-aa39-080eeb81c69d': { tokens: ['push_token_123'] } }, + created_at: '2019-12-27T18:11:19.117Z', + email: 'jane@ingen.net', + locale: 'locale', + name: 'Jane Doe', + phone_number: 'phone_number', + preferences: { default: { + __persistence_strategy__: 'merge', + categories: { + marketing: false, + transactional: { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + }, + }, + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { + '2f641633-95d3-4555-9222-9f1eb7888a80': { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, + }, + commercial_subscribed: true, + workflows: { 'dinosaurs-loose': { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + } }, + } }, + timezone: 'America/New_York', + }] }); }); test('setPreferences: only required params', async () => { const responsePromise = client.users.bulk.setPreferences({ - preferences: {}, - user_ids: ['user_1', 'user_2'], - }); + preferences: {}, + user_ids: ['user_1', 'user_2'], + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -255,192 +176,122 @@ describe('resource bulk', () => { test('setPreferences: required and optional params', async () => { const response = await client.users.bulk.setPreferences({ - preferences: { - __persistence_strategy__: 'merge', - categories: { - marketing: false, - transactional: { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: true, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { - '2f641633-95d3-4555-9222-9f1eb7888a80': { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, - }, - commercial_subscribed: true, - workflows: { - 'dinosaurs-loose': { - channel_types: { - chat: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - email: false, - http: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - in_app_feed: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - push: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - sms: { - conditions: [ - { - argument: 'US', - operator: 'equal_to', - variable: 'recipient.country_code', - }, - ], - }, - }, - channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, - conditions: [ - { - argument: 'frog_genome', - operator: 'contains', - variable: 'specimen.dna_sequence', - }, - ], - }, - }, - }, - user_ids: ['user_1', 'user_2'], - }); + preferences: { + __persistence_strategy__: 'merge', + categories: { + marketing: false, + transactional: { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + }, + }, + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: true, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { + '2f641633-95d3-4555-9222-9f1eb7888a80': { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true, + }, + commercial_subscribed: true, + workflows: { 'dinosaurs-loose': { + channel_types: { + chat: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + email: false, + http: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + in_app_feed: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + push: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + sms: { conditions: [{ + argument: 'US', + operator: 'equal_to', + variable: 'recipient.country_code', + }] }, + }, + channels: { 'aef6e715-df82-4ab6-b61e-b743e249f7b6': true }, + conditions: [{ + argument: 'frog_genome', + operator: 'contains', + variable: 'specimen.dna_sequence', + }], + } }, + }, + user_ids: ['user_1', 'user_2'], + }); }); }); diff --git a/tests/api-resources/users/feeds.test.ts b/tests/api-resources/users/feeds.test.ts index b4ac6490..4fcd28d9 100644 --- a/tests/api-resources/users/feeds.test.ts +++ b/tests/api-resources/users/feeds.test.ts @@ -2,10 +2,7 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource feeds', () => { test('getSettings', async () => { @@ -32,33 +29,28 @@ describe('resource feeds', () => { test('listItems: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.users.feeds.listItems( - 'user_id', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { - after: 'after', - archived: 'exclude', - before: 'before', - exclude: 'exclude', - has_tenant: true, - inserted_at: { - gt: 'gt', - gte: 'gte', - lt: 'lt', - lte: 'lte', - }, - locale: 'locale', - mode: 'compact', - page_size: 0, - source: 'source', - status: 'unread', - tenant: 'tenant', - trigger_data: 'trigger_data', - workflow_categories: ['string'], - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.users.feeds.listItems('user_id', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + after: 'after', + archived: 'exclude', + before: 'before', + exclude: 'exclude', + has_tenant: true, + inserted_at: { + gt: 'gt', + gte: 'gte', + lt: 'lt', + lte: 'lte', + }, + locale: 'locale', + mode: 'compact', + page_size: 0, + source: 'source', + status: 'unread', + tenant: 'tenant', + trigger_data: 'trigger_data', + workflow_categories: ['string'], + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); }); diff --git a/tests/api-resources/users/guides.test.ts b/tests/api-resources/users/guides.test.ts index 8b3ff0d1..e8893cca 100644 --- a/tests/api-resources/users/guides.test.ts +++ b/tests/api-resources/users/guides.test.ts @@ -2,10 +2,7 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource guides', () => { test('getChannel', async () => { @@ -21,27 +18,22 @@ describe('resource guides', () => { test('getChannel: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.users.guides.getChannel( - 'user_id', - '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - { - data: 'data', - tenant: 'tenant', - type: 'type', - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.users.guides.getChannel('user_id', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { + data: 'data', + tenant: 'tenant', + type: 'type', + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('markMessageAsArchived: only required params', async () => { const responsePromise = client.users.guides.markMessageAsArchived('user_id', 'message_id', { - channel_id: '123e4567-e89b-12d3-a456-426614174000', - guide_id: '7e9dc78c-b3b1-4127-a54e-71f1899b831a', - guide_key: 'tour_notification', - guide_step_ref: 'lab_tours', - }); + channel_id: '123e4567-e89b-12d3-a456-426614174000', + guide_id: '7e9dc78c-b3b1-4127-a54e-71f1899b831a', + guide_key: 'tour_notification', + guide_step_ref: 'lab_tours', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -53,33 +45,33 @@ describe('resource guides', () => { test('markMessageAsArchived: required and optional params', async () => { const response = await client.users.guides.markMessageAsArchived('user_id', 'message_id', { - channel_id: '123e4567-e89b-12d3-a456-426614174000', - guide_id: '7e9dc78c-b3b1-4127-a54e-71f1899b831a', - guide_key: 'tour_notification', - guide_step_ref: 'lab_tours', - content: { body: 'bar', title: 'bar' }, - data: { - next_time: 'bar', - spots_left: 'bar', - tour_id: 'bar', - }, - is_final: false, - metadata: { - cta: 'bar', - theme: 'bar', - type: 'bar', - }, - tenant: 'ingen_isla_nublar', - }); + channel_id: '123e4567-e89b-12d3-a456-426614174000', + guide_id: '7e9dc78c-b3b1-4127-a54e-71f1899b831a', + guide_key: 'tour_notification', + guide_step_ref: 'lab_tours', + content: { body: 'bar', title: 'bar' }, + data: { + next_time: 'bar', + spots_left: 'bar', + tour_id: 'bar', + }, + is_final: false, + metadata: { + cta: 'bar', + theme: 'bar', + type: 'bar', + }, + tenant: 'ingen_isla_nublar', + }); }); test('markMessageAsInteracted: only required params', async () => { const responsePromise = client.users.guides.markMessageAsInteracted('user_id', 'message_id', { - channel_id: '123e4567-e89b-12d3-a456-426614174000', - guide_id: '7e9dc78c-b3b1-4127-a54e-71f1899b831a', - guide_key: 'tour_notification', - guide_step_ref: 'lab_tours', - }); + channel_id: '123e4567-e89b-12d3-a456-426614174000', + guide_id: '7e9dc78c-b3b1-4127-a54e-71f1899b831a', + guide_key: 'tour_notification', + guide_step_ref: 'lab_tours', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -91,33 +83,33 @@ describe('resource guides', () => { test('markMessageAsInteracted: required and optional params', async () => { const response = await client.users.guides.markMessageAsInteracted('user_id', 'message_id', { - channel_id: '123e4567-e89b-12d3-a456-426614174000', - guide_id: '7e9dc78c-b3b1-4127-a54e-71f1899b831a', - guide_key: 'tour_notification', - guide_step_ref: 'lab_tours', - content: { body: 'bar', title: 'bar' }, - data: { - next_time: 'bar', - spots_left: 'bar', - tour_id: 'bar', - }, - is_final: false, - metadata: { - cta: 'bar', - theme: 'bar', - type: 'bar', - }, - tenant: 'ingen_isla_nublar', - }); + channel_id: '123e4567-e89b-12d3-a456-426614174000', + guide_id: '7e9dc78c-b3b1-4127-a54e-71f1899b831a', + guide_key: 'tour_notification', + guide_step_ref: 'lab_tours', + content: { body: 'bar', title: 'bar' }, + data: { + next_time: 'bar', + spots_left: 'bar', + tour_id: 'bar', + }, + is_final: false, + metadata: { + cta: 'bar', + theme: 'bar', + type: 'bar', + }, + tenant: 'ingen_isla_nublar', + }); }); test('markMessageAsSeen: only required params', async () => { const responsePromise = client.users.guides.markMessageAsSeen('user_id', 'message_id', { - channel_id: '123e4567-e89b-12d3-a456-426614174000', - guide_id: '7e9dc78c-b3b1-4127-a54e-71f1899b831a', - guide_key: 'tour_notification', - guide_step_ref: 'lab_tours', - }); + channel_id: '123e4567-e89b-12d3-a456-426614174000', + guide_id: '7e9dc78c-b3b1-4127-a54e-71f1899b831a', + guide_key: 'tour_notification', + guide_step_ref: 'lab_tours', + }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -129,23 +121,23 @@ describe('resource guides', () => { test('markMessageAsSeen: required and optional params', async () => { const response = await client.users.guides.markMessageAsSeen('user_id', 'message_id', { - channel_id: '123e4567-e89b-12d3-a456-426614174000', - guide_id: '7e9dc78c-b3b1-4127-a54e-71f1899b831a', - guide_key: 'tour_notification', - guide_step_ref: 'lab_tours', - content: { body: 'bar', title: 'bar' }, - data: { - next_time: 'bar', - spots_left: 'bar', - tour_id: 'bar', - }, - is_final: false, - metadata: { - cta: 'bar', - theme: 'bar', - type: 'bar', - }, - tenant: 'ingen_isla_nublar', - }); + channel_id: '123e4567-e89b-12d3-a456-426614174000', + guide_id: '7e9dc78c-b3b1-4127-a54e-71f1899b831a', + guide_key: 'tour_notification', + guide_step_ref: 'lab_tours', + content: { body: 'bar', title: 'bar' }, + data: { + next_time: 'bar', + spots_left: 'bar', + tour_id: 'bar', + }, + is_final: false, + metadata: { + cta: 'bar', + theme: 'bar', + type: 'bar', + }, + tenant: 'ingen_isla_nublar', + }); }); }); diff --git a/tests/api-resources/users/users.test.ts b/tests/api-resources/users/users.test.ts index 817b3803..e8576f18 100644 --- a/tests/api-resources/users/users.test.ts +++ b/tests/api-resources/users/users.test.ts @@ -2,10 +2,7 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource users', () => { test('update', async () => { @@ -32,17 +29,14 @@ describe('resource users', () => { test('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.users.list( - { - after: 'after', - before: 'before', - include: ['preferences'], - page_size: 0, - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.users.list({ + after: 'after', + before: 'before', + include: ['preferences'], + page_size: 0, + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('delete', async () => { @@ -91,14 +85,9 @@ describe('resource users', () => { test('getPreferences: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.users.getPreferences( - 'user_id', - 'default', - { tenant: 'tenant' }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.users.getPreferences('user_id', 'default', { tenant: 'tenant' }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('listMessages', async () => { @@ -114,33 +103,29 @@ describe('resource users', () => { test('listMessages: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.users.listMessages( - 'user-123', - { - after: 'after', - before: 'before', - channel_id: 'channel_id', - engagement_status: ['seen'], - inserted_at: { - gt: 'gt', - gte: 'gte', - lt: 'lt', - lte: 'lte', - }, - message_ids: ['string'], - page_size: 0, - source: 'source', - status: ['queued'], - tenant: 'tenant', - trigger_data: 'trigger_data', - workflow_categories: ['string'], - workflow_recipient_run_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - workflow_run_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.users.listMessages('user-123', { + after: 'after', + before: 'before', + channel_id: 'channel_id', + engagement_status: ['seen'], + inserted_at: { + gt: 'gt', + gte: 'gte', + lt: 'lt', + lte: 'lte', + }, + message_ids: ['string'], + page_size: 0, + source: 'source', + status: ['queued'], + tenant: 'tenant', + trigger_data: 'trigger_data', + workflow_categories: ['string'], + workflow_recipient_run_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + workflow_run_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('listPreferences', async () => { @@ -167,19 +152,15 @@ describe('resource users', () => { test('listSchedules: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.users.listSchedules( - 'user_id', - { - after: 'after', - before: 'before', - page_size: 0, - tenant: 'tenant', - workflow: 'workflow', - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.users.listSchedules('user_id', { + after: 'after', + before: 'before', + page_size: 0, + tenant: 'tenant', + workflow: 'workflow', + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('listSubscriptions', async () => { @@ -195,19 +176,15 @@ describe('resource users', () => { test('listSubscriptions: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.users.listSubscriptions( - 'user_id', - { - after: 'after', - before: 'before', - include: ['preferences'], - objects: ['user_123'], - page_size: 0, - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.users.listSubscriptions('user_id', { + after: 'after', + before: 'before', + include: ['preferences'], + objects: ['user_123'], + page_size: 0, + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('merge: only required params', async () => { @@ -226,9 +203,7 @@ describe('resource users', () => { }); test('setChannelData: only required params', async () => { - const responsePromise = client.users.setChannelData('user_id', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - data: { tokens: ['push_token_1'] }, - }); + const responsePromise = client.users.setChannelData('user_id', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { data: { tokens: ['push_token_1'] } }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -239,9 +214,7 @@ describe('resource users', () => { }); test('setChannelData: required and optional params', async () => { - const response = await client.users.setChannelData('user_id', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { - data: { tokens: ['push_token_1'] }, - }); + const response = await client.users.setChannelData('user_id', '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { data: { tokens: ['push_token_1'] } }); }); test('setPreferences', async () => { diff --git a/tests/api-resources/workflow-recipient-runs.test.ts b/tests/api-resources/workflow-recipient-runs.test.ts index 130d2b5b..875d137a 100644 --- a/tests/api-resources/workflow-recipient-runs.test.ts +++ b/tests/api-resources/workflow-recipient-runs.test.ts @@ -2,10 +2,7 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource workflowRecipientRuns', () => { test('list', async () => { @@ -21,23 +18,20 @@ describe('resource workflowRecipientRuns', () => { test('list: request options and params are passed correctly', async () => { // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error - await expect( - client.workflowRecipientRuns.list( - { - after: 'after', - before: 'before', - ending_at: '2019-12-27T18:11:19.117Z', - has_errors: true, - page_size: 0, - recipient: 'user_123', - starting_at: '2019-12-27T18:11:19.117Z', - status: ['queued'], - tenant: 'tenant', - workflow: 'workflow', - }, - { path: '/_stainless_unknown_path' }, - ), - ).rejects.toThrow(Knock.NotFoundError); + await expect(client.workflowRecipientRuns.list({ + after: 'after', + before: 'before', + ending_at: '2019-12-27T18:11:19.117Z', + has_errors: true, + page_size: 0, + recipient: 'user_123', + starting_at: '2019-12-27T18:11:19.117Z', + status: ['queued'], + tenant: 'tenant', + workflow: 'workflow', + }, { path: '/_stainless_unknown_path' })) + .rejects + .toThrow(Knock.NotFoundError); }); test('get', async () => { diff --git a/tests/api-resources/workflows.test.ts b/tests/api-resources/workflows.test.ts index 8aac34b5..b2f0af01 100644 --- a/tests/api-resources/workflows.test.ts +++ b/tests/api-resources/workflows.test.ts @@ -2,10 +2,7 @@ import Knock from '@knocklabs/node'; -const client = new Knock({ - apiKey: 'My API Key', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); +const client = new Knock({ apiKey: 'My API Key', baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010' }); describe('resource workflows', () => { test('cancel: only required params', async () => { @@ -20,16 +17,11 @@ describe('resource workflows', () => { }); test('cancel: required and optional params', async () => { - const response = await client.workflows.cancel('key', { - cancellation_key: 'cancel-workflow-123', - recipients: ['jhammond'], - }); + const response = await client.workflows.cancel('key', { cancellation_key: 'cancel-workflow-123', recipients: ['jhammond'] }); }); test('trigger: only required params', async () => { - const responsePromise = client.workflows.trigger('key', { - recipients: ['dr_grant', 'dr_sattler', 'dr_malcolm'], - }); + const responsePromise = client.workflows.trigger('key', { recipients: ['dr_grant', 'dr_sattler', 'dr_malcolm'] }); const rawResponse = await responsePromise.asResponse(); expect(rawResponse).toBeInstanceOf(Response); const response = await responsePromise; @@ -41,18 +33,18 @@ describe('resource workflows', () => { test('trigger: required and optional params', async () => { const response = await client.workflows.trigger('key', { - recipients: ['dr_grant', 'dr_sattler', 'dr_malcolm'], - actor: 'mr_dna', - cancellation_key: 'isla_nublar_incident_1993', - data: { - affected_areas: 'bar', - attraction_id: 'bar', - evacuation_protocol: 'bar', - message: 'bar', - severity: 'bar', - system_status: 'bar', - }, - tenant: 'ingen_isla_nublar', - }); + recipients: ['dr_grant', 'dr_sattler', 'dr_malcolm'], + actor: 'mr_dna', + cancellation_key: 'isla_nublar_incident_1993', + data: { + affected_areas: 'bar', + attraction_id: 'bar', + evacuation_protocol: 'bar', + message: 'bar', + severity: 'bar', + system_status: 'bar', + }, + tenant: 'ingen_isla_nublar', + }); }); }); diff --git a/tests/index.test.ts b/tests/index.test.ts index 39c93713..d719bf58 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -21,10 +21,10 @@ describe('instantiate client', () => { describe('defaultHeaders', () => { const client = new Knock({ - baseURL: 'http://localhost:5000/', - defaultHeaders: { 'X-My-Default-Header': '2' }, - apiKey: 'My API Key', - }); + baseURL: 'http://localhost:5000/', + defaultHeaders: { 'X-My-Default-Header': '2' }, + apiKey: 'My API Key', +}) test('they are used in the request', async () => { const { req } = await client.buildRequest({ path: '/foo', method: 'post' }); @@ -49,193 +49,191 @@ describe('instantiate client', () => { expect(req.headers.has('x-my-default-header')).toBe(false); }); }); - describe('logging', () => { - const env = process.env; +describe('logging', () => { + const env = process.env; - beforeEach(() => { - process.env = { ...env }; - process.env['KNOCK_LOG'] = undefined; - }); + beforeEach(() => { + process.env = { ...env }; + process.env['KNOCK_LOG'] = undefined; + }); - afterEach(() => { - process.env = env; - }); + afterEach(() => { + process.env = env; + }); - const forceAPIResponseForClient = async (client: Knock) => { - await new APIPromise( - client, - Promise.resolve({ - response: new Response(), - controller: new AbortController(), - requestLogID: 'log_000000', - retryOfRequestLogID: undefined, - startTime: Date.now(), - options: { - method: 'get', - path: '/', - }, - }), - ); + const forceAPIResponseForClient = async (client: Knock) => { + await new APIPromise( + client, + Promise.resolve({ + response: new Response(), + controller: new AbortController(), + requestLogID: 'log_000000', + retryOfRequestLogID: undefined, + startTime: Date.now(), + options: { + method: 'get', + path: '/', + }, + }), + ); + }; + + test('debug logs when log level is debug', async () => { + const debugMock = jest.fn(); + const logger = { + debug: debugMock, + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), }; - test('debug logs when log level is debug', async () => { - const debugMock = jest.fn(); - const logger = { - debug: debugMock, - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - }; - - const client = new Knock({ - logger: logger, - logLevel: 'debug', - apiKey: 'My API Key', - }); + const client = new Knock({ + logger: logger, + logLevel: 'debug', + apiKey: 'My API Key', +}); - await forceAPIResponseForClient(client); - expect(debugMock).toHaveBeenCalled(); - }); + await forceAPIResponseForClient(client); + expect(debugMock).toHaveBeenCalled(); + }); - test('default logLevel is warn', async () => { - const client = new Knock({ apiKey: 'My API Key' }); - expect(client.logLevel).toBe('warn'); - }); + test('default logLevel is warn', async () => { + const client = new Knock({ apiKey: 'My API Key' }); + expect(client.logLevel).toBe('warn'); + }); - test('debug logs are skipped when log level is info', async () => { - const debugMock = jest.fn(); - const logger = { - debug: debugMock, - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - }; + test('debug logs are skipped when log level is info', async () => { + const debugMock = jest.fn(); + const logger = { + debug: debugMock, + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), + }; - const client = new Knock({ - logger: logger, - logLevel: 'info', - apiKey: 'My API Key', - }); + const client = new Knock({ + logger: logger, + logLevel: 'info', + apiKey: 'My API Key', +}); - await forceAPIResponseForClient(client); - expect(debugMock).not.toHaveBeenCalled(); - }); + await forceAPIResponseForClient(client); + expect(debugMock).not.toHaveBeenCalled(); + }); - test('debug logs happen with debug env var', async () => { - const debugMock = jest.fn(); - const logger = { - debug: debugMock, - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - }; + test('debug logs happen with debug env var', async () => { + const debugMock = jest.fn(); + const logger = { + debug: debugMock, + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), + }; - process.env['KNOCK_LOG'] = 'debug'; - const client = new Knock({ logger: logger, apiKey: 'My API Key' }); - expect(client.logLevel).toBe('debug'); + process.env['KNOCK_LOG'] = 'debug'; + const client = new Knock({ logger: logger, apiKey: 'My API Key' }); + expect(client.logLevel).toBe('debug'); - await forceAPIResponseForClient(client); - expect(debugMock).toHaveBeenCalled(); - }); + await forceAPIResponseForClient(client); + expect(debugMock).toHaveBeenCalled(); + }); - test('warn when env var level is invalid', async () => { - const warnMock = jest.fn(); - const logger = { - debug: jest.fn(), - info: jest.fn(), - warn: warnMock, - error: jest.fn(), - }; + test('warn when env var level is invalid', async () => { + const warnMock = jest.fn(); + const logger = { + debug: jest.fn(), + info: jest.fn(), + warn: warnMock, + error: jest.fn(), + }; - process.env['KNOCK_LOG'] = 'not a log level'; - const client = new Knock({ logger: logger, apiKey: 'My API Key' }); - expect(client.logLevel).toBe('warn'); - expect(warnMock).toHaveBeenCalledWith( - 'process.env[\'KNOCK_LOG\'] was set to "not a log level", expected one of ["off","error","warn","info","debug"]', - ); - }); + process.env['KNOCK_LOG'] = 'not a log level'; + const client = new Knock({ logger: logger, apiKey: 'My API Key' }); + expect(client.logLevel).toBe('warn'); + expect(warnMock).toHaveBeenCalledWith('process.env[\'KNOCK_LOG\'] was set to "not a log level", expected one of ["off","error","warn","info","debug"]'); + }); - test('client log level overrides env var', async () => { - const debugMock = jest.fn(); - const logger = { - debug: debugMock, - info: jest.fn(), - warn: jest.fn(), - error: jest.fn(), - }; + test('client log level overrides env var', async () => { + const debugMock = jest.fn(); + const logger = { + debug: debugMock, + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), + }; - process.env['KNOCK_LOG'] = 'debug'; - const client = new Knock({ - logger: logger, - logLevel: 'off', - apiKey: 'My API Key', - }); + process.env['KNOCK_LOG'] = 'debug'; + const client = new Knock({ + logger: logger, + logLevel: 'off', + apiKey: 'My API Key', +}); - await forceAPIResponseForClient(client); - expect(debugMock).not.toHaveBeenCalled(); - }); + await forceAPIResponseForClient(client); + expect(debugMock).not.toHaveBeenCalled(); + }); - test('no warning logged for invalid env var level + valid client level', async () => { - const warnMock = jest.fn(); - const logger = { - debug: jest.fn(), - info: jest.fn(), - warn: warnMock, - error: jest.fn(), - }; + test('no warning logged for invalid env var level + valid client level', async () => { + const warnMock = jest.fn(); + const logger = { + debug: jest.fn(), + info: jest.fn(), + warn: warnMock, + error: jest.fn(), + }; - process.env['KNOCK_LOG'] = 'not a log level'; - const client = new Knock({ - logger: logger, - logLevel: 'debug', - apiKey: 'My API Key', - }); - expect(client.logLevel).toBe('debug'); - expect(warnMock).not.toHaveBeenCalled(); - }); + process.env['KNOCK_LOG'] = 'not a log level'; + const client = new Knock({ + logger: logger, + logLevel: 'debug', + apiKey: 'My API Key', +}); + expect(client.logLevel).toBe('debug'); + expect(warnMock).not.toHaveBeenCalled(); }); +}); describe('defaultQuery', () => { test('with null query params given', () => { const client = new Knock({ - baseURL: 'http://localhost:5000/', - defaultQuery: { apiVersion: 'foo' }, - apiKey: 'My API Key', - }); + baseURL: 'http://localhost:5000/', + defaultQuery: { apiVersion: 'foo' }, + apiKey: 'My API Key', +}); expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/foo?apiVersion=foo'); }); test('multiple default query params', () => { const client = new Knock({ - baseURL: 'http://localhost:5000/', - defaultQuery: { apiVersion: 'foo', hello: 'world' }, - apiKey: 'My API Key', - }); + baseURL: 'http://localhost:5000/', + defaultQuery: { apiVersion: 'foo', hello: 'world' }, + apiKey: 'My API Key', +}); expect(client.buildURL('/foo', null)).toEqual('http://localhost:5000/foo?apiVersion=foo&hello=world'); }); test('overriding with `undefined`', () => { const client = new Knock({ - baseURL: 'http://localhost:5000/', - defaultQuery: { hello: 'world' }, - apiKey: 'My API Key', - }); + baseURL: 'http://localhost:5000/', + defaultQuery: { hello: 'world' }, + apiKey: 'My API Key', +}) expect(client.buildURL('/foo', { hello: undefined })).toEqual('http://localhost:5000/foo'); }); }); test('custom fetch', async () => { const client = new Knock({ - baseURL: 'http://localhost:5000/', - apiKey: 'My API Key', - fetch: (url) => { - return Promise.resolve( - new Response(JSON.stringify({ url, custom: true }), { - headers: { 'Content-Type': 'application/json' }, - }), - ); - }, - }); + baseURL: 'http://localhost:5000/', + apiKey: 'My API Key', + fetch: (url) => { + return Promise.resolve( + new Response(JSON.stringify({ url, custom: true }), { + headers: { 'Content-Type': 'application/json' }, + }), + ); +}, +}); const response = await client.get('/foo'); expect(response).toEqual({ url: 'http://localhost:5000/foo', custom: true }); @@ -244,35 +242,37 @@ describe('instantiate client', () => { test('explicit global fetch', async () => { // make sure the global fetch type is assignable to our Fetch type const client = new Knock({ - baseURL: 'http://localhost:5000/', - apiKey: 'My API Key', - fetch: defaultFetch, - }); + baseURL: 'http://localhost:5000/', + apiKey: 'My API Key', + fetch: defaultFetch, +}); }); test('custom signal', async () => { const client = new Knock({ - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', - apiKey: 'My API Key', - fetch: (...args) => { - return new Promise((resolve, reject) => - setTimeout( - () => - defaultFetch(...args) - .then(resolve) - .catch(reject), - 300, - ), - ); - }, - }); + baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', + apiKey: 'My API Key', + fetch: (...args) => { + return new Promise((resolve, reject) => + setTimeout( + () => + defaultFetch(...args) + .then(resolve) + .catch(reject), + 300, + ), + ); +}, +}); const controller = new AbortController(); setTimeout(() => controller.abort(), 200); const spy = jest.spyOn(client, 'request'); - await expect(client.get('/foo', { signal: controller.signal })).rejects.toThrowError(APIUserAbortError); + await expect(client.get('/foo', { signal: controller.signal })).rejects.toThrowError( + APIUserAbortError, + ); expect(spy).toHaveBeenCalledTimes(1); }); @@ -284,10 +284,10 @@ describe('instantiate client', () => { }; const client = new Knock({ - baseURL: 'http://localhost:5000/', - apiKey: 'My API Key', - fetch: testFetch, - }); + baseURL: 'http://localhost:5000/', + apiKey: 'My API Key', + fetch: testFetch, +}); await client.patch('/foo'); expect(capturedRequest?.method).toEqual('PATCH'); @@ -322,35 +322,29 @@ describe('instantiate client', () => { test('empty env variable', () => { process.env['KNOCK_BASE_URL'] = ''; // empty const client = new Knock({ apiKey: 'My API Key' }); - expect(client.baseURL).toEqual('https://api.knock.app'); + expect(client.baseURL).toEqual('https://api.knock.app') }); test('blank env variable', () => { process.env['KNOCK_BASE_URL'] = ' '; // blank const client = new Knock({ apiKey: 'My API Key' }); - expect(client.baseURL).toEqual('https://api.knock.app'); + expect(client.baseURL).toEqual('https://api.knock.app') }); test('in request options', () => { const client = new Knock({ apiKey: 'My API Key' }); - expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( - 'http://localhost:5000/option/foo', - ); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual('http://localhost:5000/option/foo'); }); test('in request options overridden by client options', () => { const client = new Knock({ apiKey: 'My API Key', baseURL: 'http://localhost:5000/client' }); - expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( - 'http://localhost:5000/client/foo', - ); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual('http://localhost:5000/client/foo'); }); test('in request options overridden by env variable', () => { process.env['KNOCK_BASE_URL'] = 'http://localhost:5000/env'; const client = new Knock({ apiKey: 'My API Key' }); - expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual( - 'http://localhost:5000/env/foo', - ); + expect(client.buildURL('/foo', null, 'http://localhost:5000/option')).toEqual('http://localhost:5000/env/foo'); }); }); @@ -366,10 +360,10 @@ describe('instantiate client', () => { describe('withOptions', () => { test('creates a new client with overridden options', async () => { const client = new Knock({ - baseURL: 'http://localhost:5000/', - maxRetries: 3, - apiKey: 'My API Key', - }); + baseURL: 'http://localhost:5000/', + maxRetries: 3, + apiKey: 'My API Key', + }); const newClient = client.withOptions({ maxRetries: 5, @@ -391,11 +385,11 @@ describe('instantiate client', () => { test('inherits options from the parent client', async () => { const client = new Knock({ - baseURL: 'http://localhost:5000/', - defaultHeaders: { 'X-Test-Header': 'test-value' }, - defaultQuery: { 'test-param': 'test-value' }, - apiKey: 'My API Key', - }); + baseURL: 'http://localhost:5000/', + defaultHeaders: { 'X-Test-Header': 'test-value' }, + defaultQuery: { 'test-param': 'test-value' }, + apiKey: 'My API Key', + }); const newClient = client.withOptions({ baseURL: 'http://localhost:5001/', @@ -410,10 +404,10 @@ describe('instantiate client', () => { test('respects runtime property changes when creating new client', () => { const client = new Knock({ - baseURL: 'http://localhost:5000/', - timeout: 1000, - apiKey: 'My API Key', - }); + baseURL: 'http://localhost:5000/', + timeout: 1000, + apiKey: 'My API Key', + }); // Modify the client properties directly after creation client.baseURL = 'http://localhost:6000/'; @@ -456,31 +450,23 @@ describe('instantiate client', () => { describe('idempotency', () => { test('key can be set per-request', async () => { - const client = new Knock({ - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', - apiKey: 'My API Key', - }); - await client.users.merge('user_id', { from_user_id: 'user_1' }, { idempotencyKey: 'my-idempotency-key' }); - }); -}); + const client = new Knock({ baseURL: process.env["TEST_API_BASE_URL"] ?? 'http://127.0.0.1:4010', apiKey: 'My API Key' }); + await client.users.merge('user_id', { from_user_id: 'user_1' }, { idempotencyKey: 'my-idempotency-key' }) + }) +}) describe('request building', () => { const client = new Knock({ apiKey: 'My API Key' }); describe('custom headers', () => { test('handles undefined', async () => { - const { req } = await client.buildRequest({ - path: '/foo', - method: 'post', - body: { value: 'hello' }, - headers: { 'X-Foo': 'baz', 'x-foo': 'bar', 'x-Foo': undefined, 'x-baz': 'bam', 'X-Baz': null }, - }); + const { req } = await client.buildRequest({ path: '/foo', method: 'post', body: { value: 'hello' }, headers: { 'X-Foo': 'baz', 'x-foo': 'bar', 'x-Foo': undefined, 'x-baz': 'bam', 'X-Baz': null } }); expect(req.headers.get('x-foo')).toEqual('bar'); expect(req.headers.get('x-Foo')).toEqual('bar'); expect(req.headers.get('X-Foo')).toEqual('bar'); expect(req.headers.get('x-baz')).toEqual(null); }); - }); + }) }); describe('default encoder', () => { @@ -557,40 +543,37 @@ describe('default encoder', () => { describe('retries', () => { test('retry on timeout', async () => { let count = 0; - const testFetch = async ( - url: string | URL | Request, - { signal }: RequestInit = {}, - ): Promise => { - if (count++ === 0) { - return new Promise( - (resolve, reject) => signal?.addEventListener('abort', () => reject(new Error('timed out'))), - ); - } - return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); - }; - - const client = new Knock({ - apiKey: 'My API Key', - timeout: 10, - fetch: testFetch, - }); + const testFetch = async (url: string | URL | Request, { signal }: RequestInit = {}): Promise => { + if (count++ === 0) { + return new Promise((resolve, reject) => + signal?.addEventListener('abort', () => reject(new Error('timed out'))), + ); + } + return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); + }; - expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); - expect(count).toEqual(2); - expect( - await client - .request({ path: '/foo', method: 'get' }) - .asResponse() - .then((r) => r.text()), - ).toEqual(JSON.stringify({ a: 1 })); - expect(count).toEqual(3); + const client = new Knock({ + apiKey: 'My API Key', + timeout: 10, + fetch: testFetch, }); + expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); + expect(count).toEqual(2); + expect( + await client + .request({ path: '/foo', method: 'get' }) + .asResponse() + .then((r) => r.text()), + ).toEqual(JSON.stringify({ a: 1 })); + expect(count).toEqual(3); + }); + test('retry count header', async () => { let count = 0; let capturedRequest: RequestInit | undefined; const testFetch = async (url: string | URL | Request, init: RequestInit = {}): Promise => { - count++; + count++ if (count <= 2) { return new Response(undefined, { status: 429, @@ -604,10 +587,10 @@ describe('retries', () => { }; const client = new Knock({ - apiKey: 'My API Key', - fetch: testFetch, - maxRetries: 4, - }); + apiKey: 'My API Key', + fetch: testFetch, + maxRetries: 4, + }); expect(await client.request({ path: '/foo', method: 'get' })).toEqual({ a: 1 }); @@ -619,7 +602,7 @@ describe('retries', () => { let count = 0; let capturedRequest: RequestInit | undefined; const testFetch = async (url: string | URL | Request, init: RequestInit = {}): Promise => { - count++; + count++ if (count <= 2) { return new Response(undefined, { status: 429, @@ -632,10 +615,10 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; const client = new Knock({ - apiKey: 'My API Key', - fetch: testFetch, - maxRetries: 4, - }); + apiKey: 'My API Key', + fetch: testFetch, + maxRetries: 4, + }); expect( await client.request({ @@ -652,7 +635,7 @@ describe('retries', () => { let count = 0; let capturedRequest: RequestInit | undefined; const testFetch = async (url: string | URL | Request, init: RequestInit = {}): Promise => { - count++; + count++ if (count <= 2) { return new Response(undefined, { status: 429, @@ -665,11 +648,11 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; const client = new Knock({ - apiKey: 'My API Key', - fetch: testFetch, - maxRetries: 4, - defaultHeaders: { 'X-Stainless-Retry-Count': null }, - }); + apiKey: 'My API Key', + fetch: testFetch, + maxRetries: 4, + defaultHeaders: { 'X-Stainless-Retry-Count': null }, + }); expect( await client.request({ @@ -685,7 +668,7 @@ describe('retries', () => { let count = 0; let capturedRequest: RequestInit | undefined; const testFetch = async (url: string | URL | Request, init: RequestInit = {}): Promise => { - count++; + count++ if (count <= 2) { return new Response(undefined, { status: 429, @@ -698,10 +681,10 @@ describe('retries', () => { return new Response(JSON.stringify({ a: 1 }), { headers: { 'Content-Type': 'application/json' } }); }; const client = new Knock({ - apiKey: 'My API Key', - fetch: testFetch, - maxRetries: 4, - }); + apiKey: 'My API Key', + fetch: testFetch, + maxRetries: 4, + }); expect( await client.request({ @@ -716,10 +699,7 @@ describe('retries', () => { test('retry on 429 with retry-after', async () => { let count = 0; - const testFetch = async ( - url: string | URL | Request, - { signal }: RequestInit = {}, - ): Promise => { + const testFetch = async (url: string | URL | Request, { signal }: RequestInit = {}): Promise => { if (count++ === 0) { return new Response(undefined, { status: 429, @@ -746,10 +726,7 @@ describe('retries', () => { test('retry on 429 with retry-after-ms', async () => { let count = 0; - const testFetch = async ( - url: string | URL | Request, - { signal }: RequestInit = {}, - ): Promise => { + const testFetch = async (url: string | URL | Request, { signal }: RequestInit = {}): Promise => { if (count++ === 0) { return new Response(undefined, { status: 429, diff --git a/tests/qs/utils.test.ts b/tests/qs/utils.test.ts index 948bc07a..27531110 100644 --- a/tests/qs/utils.test.ts +++ b/tests/qs/utils.test.ts @@ -66,7 +66,7 @@ describe('merge()', function () { // st.equal(getCount, 1); expect(setCount).toEqual(0); expect(getCount).toEqual(1); - observed[0] = observed[0]; + observed[0] = observed[0]; // st.equal(setCount, 1); // st.equal(getCount, 2); expect(setCount).toEqual(1); diff --git a/tests/stringifyQuery.test.ts b/tests/stringifyQuery.test.ts index 696e231f..7dd6fa6a 100644 --- a/tests/stringifyQuery.test.ts +++ b/tests/stringifyQuery.test.ts @@ -2,53 +2,51 @@ import { stringifyQuery } from '@knocklabs/node/internal/utils/query'; -describe(stringifyQuery, () => { - for (const [input, expected] of [ - [{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'], - [{ a: null, b: false, c: undefined }, 'a=&b=false'], - [{ 'a/b': 1.28341 }, `${encodeURIComponent('a/b')}=1.28341`], - [ - { 'a/b': 'c/d', 'e=f': 'g&h' }, - `${encodeURIComponent('a/b')}=${encodeURIComponent('c/d')}&${encodeURIComponent( - 'e=f', - )}=${encodeURIComponent('g&h')}`, - ], - // Test arrays of objects - should use indices format (brackets are URL encoded) - [ - { objects: [{ id: '1', collection: 'teams' }] }, - 'objects%5B0%5D%5Bid%5D=1&objects%5B0%5D%5Bcollection%5D=teams', - ], - [ - { - objects: [ - { id: '1', collection: 'teams' }, - { id: '2', collection: 'projects' }, - ], - }, - 'objects%5B0%5D%5Bid%5D=1&objects%5B0%5D%5Bcollection%5D=teams&objects%5B1%5D%5Bid%5D=2&objects%5B1%5D%5Bcollection%5D=projects', - ], - // Test simple arrays - should use brackets format (brackets are URL encoded) - [{ tags: ['tag1', 'tag2'] }, 'tags%5B%5D=tag1&tags%5B%5D=tag2'], - [{ ids: [1, 2, 3] }, 'ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=3'], - // Test mixed: normal params + arrays of objects - [ - { userId: 'user-123', objects: [{ id: '1', collection: 'teams' }], limit: 10 }, - 'userId=user-123&limit=10&objects%5B0%5D%5Bid%5D=1&objects%5B0%5D%5Bcollection%5D=teams', - ], - // Test mixed: normal params + simple arrays + arrays of objects - // Simple arrays should use brackets format, object arrays should use indices format - [ - { status: 'active', tags: ['tag1', 'tag2'], objects: [{ id: '1', collection: 'teams' }] }, - 'status=active&tags%5B%5D=tag1&tags%5B%5D=tag2&objects%5B0%5D%5Bid%5D=1&objects%5B0%5D%5Bcollection%5D=teams', - ], - // Test user subscriptions scenario: include array with objects array - [ - { include: ['preferences'], objects: [{ id: 'test-123', collection: 'new' }] }, - 'include%5B%5D=preferences&objects%5B0%5D%5Bid%5D=test-123&objects%5B0%5D%5Bcollection%5D=new', - ], - ] as const) { - it(`${JSON.stringify(input)} -> ${expected}`, () => { - expect(stringifyQuery(input)).toEqual(expected); - }); - } -}); +describe(stringifyQuery, () => { for (const [input, expected] of [ + [{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'], + [{ a: null, b: false, c: undefined }, 'a=&b=false'], + [{ 'a/b': 1.28341 }, `${encodeURIComponent('a/b')}=1.28341`], + [ + { 'a/b': 'c/d', 'e=f': 'g&h' }, + `${encodeURIComponent('a/b')}=${encodeURIComponent('c/d')}&${encodeURIComponent( + 'e=f', + )}=${encodeURIComponent('g&h')}`, + ], + // Test arrays of objects - should use indices format (brackets are URL encoded) + [ + { objects: [{ id: '1', collection: 'teams' }] }, + 'objects%5B0%5D%5Bid%5D=1&objects%5B0%5D%5Bcollection%5D=teams', + ], + [ + { + objects: [ + { id: '1', collection: 'teams' }, + { id: '2', collection: 'projects' }, + ], + }, + 'objects%5B0%5D%5Bid%5D=1&objects%5B0%5D%5Bcollection%5D=teams&objects%5B1%5D%5Bid%5D=2&objects%5B1%5D%5Bcollection%5D=projects', + ], + // Test simple arrays - should use brackets format (brackets are URL encoded) + [{ tags: ['tag1', 'tag2'] }, 'tags%5B%5D=tag1&tags%5B%5D=tag2'], + [{ ids: [1, 2, 3] }, 'ids%5B%5D=1&ids%5B%5D=2&ids%5B%5D=3'], + // Test mixed: normal params + arrays of objects + [ + { userId: 'user-123', objects: [{ id: '1', collection: 'teams' }], limit: 10 }, + 'userId=user-123&limit=10&objects%5B0%5D%5Bid%5D=1&objects%5B0%5D%5Bcollection%5D=teams', + ], + // Test mixed: normal params + simple arrays + arrays of objects + // Simple arrays should use brackets format, object arrays should use indices format + [ + { status: 'active', tags: ['tag1', 'tag2'], objects: [{ id: '1', collection: 'teams' }] }, + 'status=active&tags%5B%5D=tag1&tags%5B%5D=tag2&objects%5B0%5D%5Bid%5D=1&objects%5B0%5D%5Bcollection%5D=teams', + ], + // Test user subscriptions scenario: include array with objects array + [ + { include: ['preferences'], objects: [{ id: 'test-123', collection: 'new' }] }, + 'include%5B%5D=preferences&objects%5B0%5D%5Bid%5D=test-123&objects%5B0%5D%5Bcollection%5D=new', + ], +] as const) { + it(`${JSON.stringify(input)} -> ${expected}`, () => { + expect(stringifyQuery(input)).toEqual(expected); + }); +} }) diff --git a/yarn.lock b/yarn.lock index 88e67ac3..799b588b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -709,11 +709,6 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@pkgr/core@^0.2.4": - version "0.2.4" - resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.2.4.tgz#d897170a2b0ba51f78a099edccd968f7b103387c" - integrity sha512-ROFF39F6ZrnzSUEmQQZUar0Jt4xVoP9WnDRdWwF4NNcXs3xBTLgBUDoOwW141y1jP+S8nahIbdxbFC7IShw9Iw== - "@sinclair/typebox@^0.27.8": version "0.27.8" resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" @@ -1515,14 +1510,6 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -eslint-plugin-prettier@^5.4.1: - version "5.4.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.4.1.tgz#99b55d7dd70047886b2222fdd853665f180b36af" - integrity sha512-9dF+KuU/Ilkq27A8idRP7N2DH8iUR6qXcjF3FR2wETY21PZdBrIjwCau8oboyGj9b7etWmTGEeM8e7oOed6ZWg== - dependencies: - prettier-linter-helpers "^1.0.0" - synckit "^0.11.7" - eslint-plugin-unused-imports@^4.1.4: version "4.1.4" resolved "https://registry.yarnpkg.com/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-4.1.4.tgz#62ddc7446ccbf9aa7b6f1f0b00a980423cda2738" @@ -1674,11 +1661,6 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-diff@^1.1.2: - version "1.3.0" - resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0" - integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw== - fast-glob@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" @@ -2846,13 +2828,6 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -prettier-linter-helpers@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" - integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== - dependencies: - fast-diff "^1.1.2" - prettier@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.1.tgz#6ba9f23165d690b6cbdaa88cb0807278f7019848" @@ -3149,13 +3124,6 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== -synckit@^0.11.7: - version "0.11.8" - resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.11.8.tgz#b2aaae998a4ef47ded60773ad06e7cb821f55457" - integrity sha512-+XZ+r1XGIJGeQk3VvXhT6xx/VpbHsRzsTkGgF6E5RX9TTXD0118l87puaEBZ566FhqblC6U0d4XnubznJDm30A== - dependencies: - "@pkgr/core" "^0.2.4" - test-exclude@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e"