@trycourier/courier 7.3.0 → 7.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +136 -0
- package/LICENSE +1 -1
- package/README.md +34 -345
- package/client.d.mts +53 -8
- package/client.d.mts.map +1 -1
- package/client.d.ts +53 -8
- package/client.d.ts.map +1 -1
- package/client.js +26 -9
- package/client.js.map +1 -1
- package/client.mjs +27 -10
- package/client.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/utils/query.d.mts +2 -0
- package/internal/utils/query.d.mts.map +1 -0
- package/internal/utils/query.d.ts +2 -0
- package/internal/utils/query.d.ts.map +1 -0
- package/internal/utils/query.js +10 -0
- package/internal/utils/query.js.map +1 -0
- package/internal/utils/query.mjs +6 -0
- package/internal/utils/query.mjs.map +1 -0
- package/internal/utils.d.mts +1 -0
- package/internal/utils.d.ts +1 -0
- package/internal/utils.js +1 -0
- package/internal/utils.js.map +1 -1
- package/internal/utils.mjs +1 -0
- package/package.json +12 -1
- package/resources/audiences.d.mts +11 -33
- package/resources/audiences.d.mts.map +1 -1
- package/resources/audiences.d.ts +11 -33
- package/resources/audiences.d.ts.map +1 -1
- package/resources/automations/automations.d.mts +54 -1
- package/resources/automations/automations.d.mts.map +1 -1
- package/resources/automations/automations.d.ts +54 -1
- package/resources/automations/automations.d.ts.map +1 -1
- package/resources/automations/automations.js +12 -0
- package/resources/automations/automations.js.map +1 -1
- package/resources/automations/automations.mjs +12 -0
- package/resources/automations/automations.mjs.map +1 -1
- package/resources/automations/index.d.mts +1 -1
- package/resources/automations/index.d.mts.map +1 -1
- package/resources/automations/index.d.ts +1 -1
- package/resources/automations/index.d.ts.map +1 -1
- package/resources/automations/index.js.map +1 -1
- package/resources/automations/index.mjs +1 -1
- package/resources/automations/index.mjs.map +1 -1
- package/resources/bulk.d.mts +80 -39
- package/resources/bulk.d.mts.map +1 -1
- package/resources/bulk.d.ts +80 -39
- package/resources/bulk.d.ts.map +1 -1
- package/resources/bulk.js +12 -2
- package/resources/bulk.js.map +1 -1
- package/resources/bulk.mjs +12 -2
- package/resources/bulk.mjs.map +1 -1
- package/resources/inbound.d.mts +1 -1
- package/resources/inbound.d.ts +1 -1
- package/resources/index.d.mts +4 -3
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +4 -3
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -1
- package/resources/index.mjs.map +1 -1
- package/resources/journeys.d.mts +143 -0
- package/resources/journeys.d.mts.map +1 -0
- package/resources/journeys.d.ts +143 -0
- package/resources/journeys.d.ts.map +1 -0
- package/resources/journeys.js +38 -0
- package/resources/journeys.js.map +1 -0
- package/resources/journeys.mjs +34 -0
- package/resources/journeys.mjs.map +1 -0
- package/resources/lists/subscriptions.d.mts +1 -1
- package/resources/lists/subscriptions.d.ts +1 -1
- package/resources/messages.d.mts +20 -20
- package/resources/messages.d.mts.map +1 -1
- package/resources/messages.d.ts +20 -20
- package/resources/messages.d.ts.map +1 -1
- package/resources/notifications/checks.d.mts +2 -2
- package/resources/notifications/checks.d.ts +2 -2
- package/resources/send.d.mts +8 -2
- package/resources/send.d.mts.map +1 -1
- package/resources/send.d.ts +8 -2
- package/resources/send.d.ts.map +1 -1
- package/resources/send.js +1 -1
- package/resources/send.mjs +1 -1
- package/resources/shared.d.mts +290 -52
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +290 -52
- package/resources/shared.d.ts.map +1 -1
- package/resources/tenants/index.d.mts +2 -2
- package/resources/tenants/index.d.mts.map +1 -1
- package/resources/tenants/index.d.ts +2 -2
- package/resources/tenants/index.d.ts.map +1 -1
- package/resources/tenants/index.js +2 -2
- package/resources/tenants/index.js.map +1 -1
- package/resources/tenants/index.mjs +1 -1
- package/resources/tenants/index.mjs.map +1 -1
- package/resources/tenants/preferences/items.d.mts +2 -2
- package/resources/tenants/preferences/items.d.ts +2 -2
- package/resources/tenants/templates/index.d.mts +3 -0
- package/resources/tenants/templates/index.d.mts.map +1 -0
- package/resources/tenants/templates/index.d.ts +3 -0
- package/resources/tenants/templates/index.d.ts.map +1 -0
- package/resources/tenants/templates/index.js +9 -0
- package/resources/tenants/templates/index.js.map +1 -0
- package/resources/tenants/templates/index.mjs +4 -0
- package/resources/tenants/templates/index.mjs.map +1 -0
- package/resources/tenants/templates/templates.d.mts +159 -0
- package/resources/tenants/templates/templates.d.mts.map +1 -0
- package/resources/tenants/templates/templates.d.ts +159 -0
- package/resources/tenants/templates/templates.d.ts.map +1 -0
- package/resources/tenants/templates/templates.js +91 -0
- package/resources/tenants/templates/templates.js.map +1 -0
- package/resources/tenants/templates/templates.mjs +86 -0
- package/resources/tenants/templates/templates.mjs.map +1 -0
- package/resources/tenants/templates/versions.d.mts +39 -0
- package/resources/tenants/templates/versions.d.mts.map +1 -0
- package/resources/tenants/templates/versions.d.ts +39 -0
- package/resources/tenants/templates/versions.d.ts.map +1 -0
- package/resources/tenants/templates/versions.js +32 -0
- package/resources/tenants/templates/versions.js.map +1 -0
- package/resources/tenants/templates/versions.mjs +28 -0
- package/resources/tenants/templates/versions.mjs.map +1 -0
- package/resources/tenants/templates.d.mts +1 -90
- package/resources/tenants/templates.d.mts.map +1 -1
- package/resources/tenants/templates.d.ts +1 -90
- package/resources/tenants/templates.d.ts.map +1 -1
- package/resources/tenants/templates.js +2 -34
- package/resources/tenants/templates.js.map +1 -1
- package/resources/tenants/templates.mjs +1 -32
- package/resources/tenants/templates.mjs.map +1 -1
- package/resources/tenants/tenants.d.mts +147 -5
- package/resources/tenants/tenants.d.mts.map +1 -1
- package/resources/tenants/tenants.d.ts +147 -5
- package/resources/tenants/tenants.d.ts.map +1 -1
- package/resources/tenants/tenants.js +2 -2
- package/resources/tenants/tenants.js.map +1 -1
- package/resources/tenants/tenants.mjs +2 -2
- package/resources/tenants/tenants.mjs.map +1 -1
- package/resources/translations.d.mts +1 -1
- package/resources/translations.d.ts +1 -1
- package/resources/users/preferences.d.mts +1 -1
- package/resources/users/preferences.d.ts +1 -1
- package/resources/users/tenants.d.mts +1 -1
- package/resources/users/tenants.d.ts +1 -1
- package/resources/users/tokens.d.mts +3 -8
- package/resources/users/tokens.d.mts.map +1 -1
- package/resources/users/tokens.d.ts +3 -8
- package/resources/users/tokens.d.ts.map +1 -1
- package/resources/users/tokens.js +2 -3
- package/resources/users/tokens.js.map +1 -1
- package/resources/users/tokens.mjs +2 -3
- package/resources/users/tokens.mjs.map +1 -1
- package/src/client.ts +115 -19
- package/src/internal/parse.ts +6 -0
- package/src/internal/utils/query.ts +7 -0
- package/src/internal/utils.ts +1 -0
- package/src/resources/audiences.ts +11 -69
- package/src/resources/automations/automations.ts +74 -1
- package/src/resources/automations/index.ts +7 -1
- package/src/resources/bulk.ts +71 -32
- package/src/resources/inbound.ts +1 -1
- package/src/resources/index.ts +21 -3
- package/src/resources/journeys.ts +174 -0
- package/src/resources/lists/subscriptions.ts +1 -1
- package/src/resources/messages.ts +24 -24
- package/src/resources/notifications/checks.ts +2 -2
- package/src/resources/send.ts +28 -2
- package/src/resources/shared.ts +391 -49
- package/src/resources/tenants/index.ts +8 -1
- package/src/resources/tenants/preferences/items.ts +2 -2
- package/src/resources/tenants/templates/index.ts +11 -0
- package/src/resources/tenants/templates/templates.ts +222 -0
- package/src/resources/tenants/templates/versions.ts +55 -0
- package/src/resources/tenants/templates.ts +1 -122
- package/src/resources/tenants/tenants.ts +179 -3
- package/src/resources/translations.ts +1 -1
- package/src/resources/users/preferences.ts +1 -1
- package/src/resources/users/tenants.ts +1 -1
- package/src/resources/users/tokens.ts +4 -10
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/client.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { APIResponseProps } from './internal/parse';
|
|
|
11
11
|
import { getPlatformHeaders } from './internal/detect-platform';
|
|
12
12
|
import * as Shims from './internal/shims';
|
|
13
13
|
import * as Opts from './internal/request-options';
|
|
14
|
-
import
|
|
14
|
+
import { stringifyQuery } from './internal/utils/query';
|
|
15
15
|
import { VERSION } from './version';
|
|
16
16
|
import * as Errors from './core/error';
|
|
17
17
|
import * as Uploads from './core/uploads';
|
|
@@ -26,8 +26,6 @@ import {
|
|
|
26
26
|
AudienceUpdateParams,
|
|
27
27
|
AudienceUpdateResponse,
|
|
28
28
|
Audiences,
|
|
29
|
-
Filter,
|
|
30
|
-
FilterConfig,
|
|
31
29
|
} from './resources/audiences';
|
|
32
30
|
import {
|
|
33
31
|
AuditEvent,
|
|
@@ -69,6 +67,15 @@ import {
|
|
|
69
67
|
InboundBulkMessageUser,
|
|
70
68
|
} from './resources/bulk';
|
|
71
69
|
import { Inbound, InboundTrackEventParams, InboundTrackEventResponse } from './resources/inbound';
|
|
70
|
+
import {
|
|
71
|
+
Journey,
|
|
72
|
+
JourneyInvokeParams,
|
|
73
|
+
JourneyListParams,
|
|
74
|
+
Journeys,
|
|
75
|
+
JourneysInvokeRequest,
|
|
76
|
+
JourneysInvokeResponse,
|
|
77
|
+
JourneysListResponse,
|
|
78
|
+
} from './resources/journeys';
|
|
72
79
|
import {
|
|
73
80
|
MessageContentResponse,
|
|
74
81
|
MessageDetails,
|
|
@@ -87,7 +94,13 @@ import {
|
|
|
87
94
|
TranslationUpdateParams,
|
|
88
95
|
Translations,
|
|
89
96
|
} from './resources/translations';
|
|
90
|
-
import {
|
|
97
|
+
import {
|
|
98
|
+
AutomationInvokeResponse,
|
|
99
|
+
AutomationListParams,
|
|
100
|
+
AutomationTemplate,
|
|
101
|
+
AutomationTemplateListResponse,
|
|
102
|
+
Automations,
|
|
103
|
+
} from './resources/automations/automations';
|
|
91
104
|
import {
|
|
92
105
|
ListListParams,
|
|
93
106
|
ListListResponse,
|
|
@@ -118,6 +131,10 @@ import {
|
|
|
118
131
|
import {
|
|
119
132
|
BaseTemplateTenantAssociation,
|
|
120
133
|
DefaultPreferences,
|
|
134
|
+
PostTenantTemplatePublishRequest,
|
|
135
|
+
PostTenantTemplatePublishResponse,
|
|
136
|
+
PutTenantTemplateRequest,
|
|
137
|
+
PutTenantTemplateResponse,
|
|
121
138
|
SubscriptionTopicNew,
|
|
122
139
|
Tenant,
|
|
123
140
|
TenantAssociation,
|
|
@@ -125,6 +142,7 @@ import {
|
|
|
125
142
|
TenantListResponse,
|
|
126
143
|
TenantListUsersParams,
|
|
127
144
|
TenantListUsersResponse,
|
|
145
|
+
TenantTemplateInput,
|
|
128
146
|
TenantUpdateParams,
|
|
129
147
|
Tenants,
|
|
130
148
|
} from './resources/tenants/tenants';
|
|
@@ -322,8 +340,8 @@ export class Courier {
|
|
|
322
340
|
return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
|
|
323
341
|
}
|
|
324
342
|
|
|
325
|
-
protected stringifyQuery(query: Record<string, unknown>): string {
|
|
326
|
-
return
|
|
343
|
+
protected stringifyQuery(query: object | Record<string, unknown>): string {
|
|
344
|
+
return stringifyQuery(query);
|
|
327
345
|
}
|
|
328
346
|
|
|
329
347
|
private getUserAgent(): string {
|
|
@@ -355,12 +373,13 @@ export class Courier {
|
|
|
355
373
|
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
356
374
|
|
|
357
375
|
const defaultQuery = this.defaultQuery();
|
|
358
|
-
|
|
359
|
-
|
|
376
|
+
const pathQuery = Object.fromEntries(url.searchParams);
|
|
377
|
+
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
|
|
378
|
+
query = { ...pathQuery, ...defaultQuery, ...query };
|
|
360
379
|
}
|
|
361
380
|
|
|
362
381
|
if (typeof query === 'object' && query && !Array.isArray(query)) {
|
|
363
|
-
url.search = this.stringifyQuery(query
|
|
382
|
+
url.search = this.stringifyQuery(query);
|
|
364
383
|
}
|
|
365
384
|
|
|
366
385
|
return url.toString();
|
|
@@ -544,7 +563,7 @@ export class Courier {
|
|
|
544
563
|
loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
|
|
545
564
|
|
|
546
565
|
const errText = await response.text().catch((err: any) => castToError(err).message);
|
|
547
|
-
const errJSON = safeJSON(errText);
|
|
566
|
+
const errJSON = safeJSON(errText) as any;
|
|
548
567
|
const errMessage = errJSON ? undefined : errText;
|
|
549
568
|
|
|
550
569
|
loggerFor(this).debug(
|
|
@@ -585,9 +604,10 @@ export class Courier {
|
|
|
585
604
|
controller: AbortController,
|
|
586
605
|
): Promise<Response> {
|
|
587
606
|
const { signal, method, ...options } = init || {};
|
|
588
|
-
|
|
607
|
+
const abort = this._makeAbort(controller);
|
|
608
|
+
if (signal) signal.addEventListener('abort', abort, { once: true });
|
|
589
609
|
|
|
590
|
-
const timeout = setTimeout(
|
|
610
|
+
const timeout = setTimeout(abort, ms);
|
|
591
611
|
|
|
592
612
|
const isReadableBody =
|
|
593
613
|
((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
|
|
@@ -664,9 +684,9 @@ export class Courier {
|
|
|
664
684
|
}
|
|
665
685
|
}
|
|
666
686
|
|
|
667
|
-
// If the API asks us to wait a certain amount of time
|
|
668
|
-
//
|
|
669
|
-
if (
|
|
687
|
+
// If the API asks us to wait a certain amount of time, just do what it
|
|
688
|
+
// says, but otherwise calculate a default
|
|
689
|
+
if (timeoutMillis === undefined) {
|
|
670
690
|
const maxRetries = options.maxRetries ?? this.maxRetries;
|
|
671
691
|
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
|
|
672
692
|
}
|
|
@@ -754,6 +774,12 @@ export class Courier {
|
|
|
754
774
|
return headers.values;
|
|
755
775
|
}
|
|
756
776
|
|
|
777
|
+
private _makeAbort(controller: AbortController) {
|
|
778
|
+
// note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
|
|
779
|
+
// would capture all request options, and cause a memory leak.
|
|
780
|
+
return () => controller.abort();
|
|
781
|
+
}
|
|
782
|
+
|
|
757
783
|
private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
|
|
758
784
|
bodyHeaders: HeadersLike;
|
|
759
785
|
body: BodyInit | undefined;
|
|
@@ -786,6 +812,14 @@ export class Courier {
|
|
|
786
812
|
(Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))
|
|
787
813
|
) {
|
|
788
814
|
return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable<Uint8Array>) };
|
|
815
|
+
} else if (
|
|
816
|
+
typeof body === 'object' &&
|
|
817
|
+
headers.values.get('content-type') === 'application/x-www-form-urlencoded'
|
|
818
|
+
) {
|
|
819
|
+
return {
|
|
820
|
+
bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
821
|
+
body: this.stringifyQuery(body),
|
|
822
|
+
};
|
|
789
823
|
} else {
|
|
790
824
|
return this.#encoder({ body, headers });
|
|
791
825
|
}
|
|
@@ -815,6 +849,7 @@ export class Courier {
|
|
|
815
849
|
auditEvents: API.AuditEvents = new API.AuditEvents(this);
|
|
816
850
|
auth: API.Auth = new API.Auth(this);
|
|
817
851
|
automations: API.Automations = new API.Automations(this);
|
|
852
|
+
journeys: API.Journeys = new API.Journeys(this);
|
|
818
853
|
brands: API.Brands = new API.Brands(this);
|
|
819
854
|
bulk: API.Bulk = new API.Bulk(this);
|
|
820
855
|
inbound: API.Inbound = new API.Inbound(this);
|
|
@@ -833,6 +868,7 @@ Courier.Audiences = Audiences;
|
|
|
833
868
|
Courier.AuditEvents = AuditEvents;
|
|
834
869
|
Courier.Auth = Auth;
|
|
835
870
|
Courier.Automations = Automations;
|
|
871
|
+
Courier.Journeys = Journeys;
|
|
836
872
|
Courier.Brands = Brands;
|
|
837
873
|
Courier.Bulk = Bulk;
|
|
838
874
|
Courier.Inbound = Inbound;
|
|
@@ -857,8 +893,6 @@ export declare namespace Courier {
|
|
|
857
893
|
export {
|
|
858
894
|
Audiences as Audiences,
|
|
859
895
|
type Audience as Audience,
|
|
860
|
-
type Filter as Filter,
|
|
861
|
-
type FilterConfig as FilterConfig,
|
|
862
896
|
type AudienceUpdateResponse as AudienceUpdateResponse,
|
|
863
897
|
type AudienceListResponse as AudienceListResponse,
|
|
864
898
|
type AudienceListMembersResponse as AudienceListMembersResponse,
|
|
@@ -880,7 +914,23 @@ export declare namespace Courier {
|
|
|
880
914
|
type AuthIssueTokenParams as AuthIssueTokenParams,
|
|
881
915
|
};
|
|
882
916
|
|
|
883
|
-
export {
|
|
917
|
+
export {
|
|
918
|
+
Automations as Automations,
|
|
919
|
+
type AutomationInvokeResponse as AutomationInvokeResponse,
|
|
920
|
+
type AutomationTemplate as AutomationTemplate,
|
|
921
|
+
type AutomationTemplateListResponse as AutomationTemplateListResponse,
|
|
922
|
+
type AutomationListParams as AutomationListParams,
|
|
923
|
+
};
|
|
924
|
+
|
|
925
|
+
export {
|
|
926
|
+
Journeys as Journeys,
|
|
927
|
+
type Journey as Journey,
|
|
928
|
+
type JourneysInvokeRequest as JourneysInvokeRequest,
|
|
929
|
+
type JourneysInvokeResponse as JourneysInvokeResponse,
|
|
930
|
+
type JourneysListResponse as JourneysListResponse,
|
|
931
|
+
type JourneyListParams as JourneyListParams,
|
|
932
|
+
type JourneyInvokeParams as JourneyInvokeParams,
|
|
933
|
+
};
|
|
884
934
|
|
|
885
935
|
export {
|
|
886
936
|
Brands as Brands,
|
|
@@ -969,9 +1019,14 @@ export declare namespace Courier {
|
|
|
969
1019
|
Tenants as Tenants,
|
|
970
1020
|
type BaseTemplateTenantAssociation as BaseTemplateTenantAssociation,
|
|
971
1021
|
type DefaultPreferences as DefaultPreferences,
|
|
1022
|
+
type PostTenantTemplatePublishRequest as PostTenantTemplatePublishRequest,
|
|
1023
|
+
type PostTenantTemplatePublishResponse as PostTenantTemplatePublishResponse,
|
|
1024
|
+
type PutTenantTemplateRequest as PutTenantTemplateRequest,
|
|
1025
|
+
type PutTenantTemplateResponse as PutTenantTemplateResponse,
|
|
972
1026
|
type SubscriptionTopicNew as SubscriptionTopicNew,
|
|
973
1027
|
type Tenant as Tenant,
|
|
974
1028
|
type TenantAssociation as TenantAssociation,
|
|
1029
|
+
type TenantTemplateInput as TenantTemplateInput,
|
|
975
1030
|
type TenantListResponse as TenantListResponse,
|
|
976
1031
|
type TenantListUsersResponse as TenantListUsersResponse,
|
|
977
1032
|
type TenantUpdateParams as TenantUpdateParams,
|
|
@@ -988,9 +1043,16 @@ export declare namespace Courier {
|
|
|
988
1043
|
|
|
989
1044
|
export { Users as Users };
|
|
990
1045
|
|
|
1046
|
+
export type AirshipProfile = API.AirshipProfile;
|
|
1047
|
+
export type AirshipProfileAudience = API.AirshipProfileAudience;
|
|
991
1048
|
export type Alignment = API.Alignment;
|
|
1049
|
+
export type AudienceFilter = API.AudienceFilter;
|
|
1050
|
+
export type AudienceFilterConfig = API.AudienceFilterConfig;
|
|
1051
|
+
export type AudienceRecipient = API.AudienceRecipient;
|
|
992
1052
|
export type ChannelClassification = API.ChannelClassification;
|
|
993
1053
|
export type ChannelPreference = API.ChannelPreference;
|
|
1054
|
+
export type DeviceType = API.DeviceType;
|
|
1055
|
+
export type Discord = API.Discord;
|
|
994
1056
|
export type ElementalActionNodeWithType = API.ElementalActionNodeWithType;
|
|
995
1057
|
export type ElementalBaseNode = API.ElementalBaseNode;
|
|
996
1058
|
export type ElementalChannelNode = API.ElementalChannelNode;
|
|
@@ -1003,17 +1065,51 @@ export declare namespace Courier {
|
|
|
1003
1065
|
export type ElementalNode = API.ElementalNode;
|
|
1004
1066
|
export type ElementalQuoteNodeWithType = API.ElementalQuoteNodeWithType;
|
|
1005
1067
|
export type ElementalTextNodeWithType = API.ElementalTextNodeWithType;
|
|
1068
|
+
export type Expo = API.Expo;
|
|
1069
|
+
export type FilterConfig = API.FilterConfig;
|
|
1070
|
+
export type Intercom = API.Intercom;
|
|
1071
|
+
export type IntercomRecipient = API.IntercomRecipient;
|
|
1072
|
+
export type ListFilter = API.ListFilter;
|
|
1073
|
+
export type ListPatternRecipient = API.ListPatternRecipient;
|
|
1074
|
+
export type ListRecipient = API.ListRecipient;
|
|
1006
1075
|
export type MessageContext = API.MessageContext;
|
|
1007
1076
|
export type MessageRouting = API.MessageRouting;
|
|
1008
1077
|
export type MessageRoutingChannel = API.MessageRoutingChannel;
|
|
1078
|
+
export type MsTeams = API.MsTeams;
|
|
1079
|
+
export type MsTeamsBaseProperties = API.MsTeamsBaseProperties;
|
|
1080
|
+
export type MsTeamsRecipient = API.MsTeamsRecipient;
|
|
1081
|
+
export type MultipleTokens = API.MultipleTokens;
|
|
1009
1082
|
export type NotificationPreferenceDetails = API.NotificationPreferenceDetails;
|
|
1083
|
+
export type Pagerduty = API.Pagerduty;
|
|
1084
|
+
export type PagerdutyRecipient = API.PagerdutyRecipient;
|
|
1010
1085
|
export type Paging = API.Paging;
|
|
1011
1086
|
export type Preference = API.Preference;
|
|
1012
1087
|
export type PreferenceStatus = API.PreferenceStatus;
|
|
1013
|
-
export type Recipient = API.Recipient;
|
|
1014
1088
|
export type RecipientPreferences = API.RecipientPreferences;
|
|
1015
1089
|
export type Rule = API.Rule;
|
|
1090
|
+
export type SendDirectMessage = API.SendDirectMessage;
|
|
1091
|
+
export type SendToChannel = API.SendToChannel;
|
|
1092
|
+
export type SendToMsTeamsChannelID = API.SendToMsTeamsChannelID;
|
|
1093
|
+
export type SendToMsTeamsChannelName = API.SendToMsTeamsChannelName;
|
|
1094
|
+
export type SendToMsTeamsConversationID = API.SendToMsTeamsConversationID;
|
|
1095
|
+
export type SendToMsTeamsEmail = API.SendToMsTeamsEmail;
|
|
1096
|
+
export type SendToMsTeamsUserID = API.SendToMsTeamsUserID;
|
|
1097
|
+
export type SendToSlackChannel = API.SendToSlackChannel;
|
|
1098
|
+
export type SendToSlackEmail = API.SendToSlackEmail;
|
|
1099
|
+
export type SendToSlackUserID = API.SendToSlackUserID;
|
|
1100
|
+
export type Slack = API.Slack;
|
|
1101
|
+
export type SlackBaseProperties = API.SlackBaseProperties;
|
|
1102
|
+
export type SlackRecipient = API.SlackRecipient;
|
|
1016
1103
|
export type TextStyle = API.TextStyle;
|
|
1104
|
+
export type Token = API.Token;
|
|
1105
|
+
export type UserProfile = API.UserProfile;
|
|
1106
|
+
export type UserProfileFirebaseToken = API.UserProfileFirebaseToken;
|
|
1017
1107
|
export type UserRecipient = API.UserRecipient;
|
|
1018
1108
|
export type Utm = API.Utm;
|
|
1109
|
+
export type WebhookAuthMode = API.WebhookAuthMode;
|
|
1110
|
+
export type WebhookAuthentication = API.WebhookAuthentication;
|
|
1111
|
+
export type WebhookMethod = API.WebhookMethod;
|
|
1112
|
+
export type WebhookProfile = API.WebhookProfile;
|
|
1113
|
+
export type WebhookProfileType = API.WebhookProfileType;
|
|
1114
|
+
export type WebhookRecipient = API.WebhookRecipient;
|
|
1019
1115
|
}
|
package/src/internal/parse.ts
CHANGED
|
@@ -29,6 +29,12 @@ export async function defaultParseResponse<T>(client: Courier, props: APIRespons
|
|
|
29
29
|
const mediaType = contentType?.split(';')[0]?.trim();
|
|
30
30
|
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
31
31
|
if (isJSON) {
|
|
32
|
+
const contentLength = response.headers.get('content-length');
|
|
33
|
+
if (contentLength === '0') {
|
|
34
|
+
// if there is no content we can't do anything
|
|
35
|
+
return undefined as T;
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
const json = await response.json();
|
|
33
39
|
return json as T;
|
|
34
40
|
}
|
package/src/internal/utils.ts
CHANGED
|
@@ -71,83 +71,22 @@ export interface Audience {
|
|
|
71
71
|
*/
|
|
72
72
|
description: string;
|
|
73
73
|
|
|
74
|
-
/**
|
|
75
|
-
* A single filter to use for filtering
|
|
76
|
-
*/
|
|
77
|
-
filter: Filter;
|
|
78
|
-
|
|
79
74
|
/**
|
|
80
75
|
* The name of the audience
|
|
81
76
|
*/
|
|
82
77
|
name: string;
|
|
83
78
|
|
|
84
79
|
updated_at: string;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface Filter {
|
|
88
|
-
/**
|
|
89
|
-
* The operator to use for filtering
|
|
90
|
-
*/
|
|
91
|
-
operator:
|
|
92
|
-
| 'ENDS_WITH'
|
|
93
|
-
| 'EQ'
|
|
94
|
-
| 'EXISTS'
|
|
95
|
-
| 'GT'
|
|
96
|
-
| 'GTE'
|
|
97
|
-
| 'INCLUDES'
|
|
98
|
-
| 'IS_AFTER'
|
|
99
|
-
| 'IS_BEFORE'
|
|
100
|
-
| 'LT'
|
|
101
|
-
| 'LTE'
|
|
102
|
-
| 'NEQ'
|
|
103
|
-
| 'OMIT'
|
|
104
|
-
| 'STARTS_WITH'
|
|
105
|
-
| 'AND'
|
|
106
|
-
| 'OR';
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* The attribe name from profile whose value will be operated against the filter
|
|
110
|
-
* value
|
|
111
|
-
*/
|
|
112
|
-
path: string;
|
|
113
80
|
|
|
114
81
|
/**
|
|
115
|
-
*
|
|
82
|
+
* Filter configuration for audience membership containing an array of filter rules
|
|
116
83
|
*/
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export interface FilterConfig {
|
|
121
|
-
/**
|
|
122
|
-
* The operator to use for filtering
|
|
123
|
-
*/
|
|
124
|
-
operator:
|
|
125
|
-
| 'ENDS_WITH'
|
|
126
|
-
| 'EQ'
|
|
127
|
-
| 'EXISTS'
|
|
128
|
-
| 'GT'
|
|
129
|
-
| 'GTE'
|
|
130
|
-
| 'INCLUDES'
|
|
131
|
-
| 'IS_AFTER'
|
|
132
|
-
| 'IS_BEFORE'
|
|
133
|
-
| 'LT'
|
|
134
|
-
| 'LTE'
|
|
135
|
-
| 'NEQ'
|
|
136
|
-
| 'OMIT'
|
|
137
|
-
| 'STARTS_WITH'
|
|
138
|
-
| 'AND'
|
|
139
|
-
| 'OR';
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* The attribe name from profile whose value will be operated against the filter
|
|
143
|
-
* value
|
|
144
|
-
*/
|
|
145
|
-
path: string;
|
|
84
|
+
filter?: Shared.AudienceFilterConfig | null;
|
|
146
85
|
|
|
147
86
|
/**
|
|
148
|
-
* The
|
|
87
|
+
* The logical operator (AND/OR) for the top-level filter
|
|
149
88
|
*/
|
|
150
|
-
|
|
89
|
+
operator?: 'AND' | 'OR';
|
|
151
90
|
}
|
|
152
91
|
|
|
153
92
|
export interface AudienceUpdateResponse {
|
|
@@ -187,14 +126,19 @@ export interface AudienceUpdateParams {
|
|
|
187
126
|
description?: string | null;
|
|
188
127
|
|
|
189
128
|
/**
|
|
190
|
-
*
|
|
129
|
+
* Filter configuration for audience membership containing an array of filter rules
|
|
191
130
|
*/
|
|
192
|
-
filter?:
|
|
131
|
+
filter?: Shared.AudienceFilterConfig | null;
|
|
193
132
|
|
|
194
133
|
/**
|
|
195
134
|
* The name of the audience
|
|
196
135
|
*/
|
|
197
136
|
name?: string | null;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The logical operator (AND/OR) for the top-level filter
|
|
140
|
+
*/
|
|
141
|
+
operator?: 'AND' | 'OR' | null;
|
|
198
142
|
}
|
|
199
143
|
|
|
200
144
|
export interface AudienceListParams {
|
|
@@ -214,8 +158,6 @@ export interface AudienceListMembersParams {
|
|
|
214
158
|
export declare namespace Audiences {
|
|
215
159
|
export {
|
|
216
160
|
type Audience as Audience,
|
|
217
|
-
type Filter as Filter,
|
|
218
|
-
type FilterConfig as FilterConfig,
|
|
219
161
|
type AudienceUpdateResponse as AudienceUpdateResponse,
|
|
220
162
|
type AudienceListResponse as AudienceListResponse,
|
|
221
163
|
type AudienceListMembersResponse as AudienceListMembersResponse,
|
|
@@ -3,19 +3,92 @@
|
|
|
3
3
|
import { APIResource } from '../../core/resource';
|
|
4
4
|
import * as InvokeAPI from './invoke';
|
|
5
5
|
import { Invoke, InvokeInvokeAdHocParams, InvokeInvokeByTemplateParams } from './invoke';
|
|
6
|
+
import { APIPromise } from '../../core/api-promise';
|
|
7
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
6
8
|
|
|
7
9
|
export class Automations extends APIResource {
|
|
8
10
|
invoke: InvokeAPI.Invoke = new InvokeAPI.Invoke(this._client);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Get the list of automations.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const automationTemplateListResponse =
|
|
18
|
+
* await client.automations.list();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
list(
|
|
22
|
+
query: AutomationListParams | null | undefined = {},
|
|
23
|
+
options?: RequestOptions,
|
|
24
|
+
): APIPromise<AutomationTemplateListResponse> {
|
|
25
|
+
return this._client.get('/automations', { query, ...options });
|
|
26
|
+
}
|
|
9
27
|
}
|
|
10
28
|
|
|
11
29
|
export interface AutomationInvokeResponse {
|
|
12
30
|
runId: string;
|
|
13
31
|
}
|
|
14
32
|
|
|
33
|
+
export interface AutomationTemplate {
|
|
34
|
+
/**
|
|
35
|
+
* The unique identifier of the automation template.
|
|
36
|
+
*/
|
|
37
|
+
id: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The name of the automation template.
|
|
41
|
+
*/
|
|
42
|
+
name: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The version of the template published or drafted.
|
|
46
|
+
*/
|
|
47
|
+
version: 'published' | 'draft';
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* ISO 8601 timestamp when the template was created.
|
|
51
|
+
*/
|
|
52
|
+
createdAt?: string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* ISO 8601 timestamp when the template was last updated.
|
|
56
|
+
*/
|
|
57
|
+
updatedAt?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface AutomationTemplateListResponse {
|
|
61
|
+
/**
|
|
62
|
+
* A cursor token for pagination. Present when there are more results available.
|
|
63
|
+
*/
|
|
64
|
+
cursor?: string;
|
|
65
|
+
|
|
66
|
+
templates?: Array<AutomationTemplate>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface AutomationListParams {
|
|
70
|
+
/**
|
|
71
|
+
* A cursor token for pagination. Use the cursor from the previous response to
|
|
72
|
+
* fetch the next page of results.
|
|
73
|
+
*/
|
|
74
|
+
cursor?: string;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The version of templates to retrieve. Accepted values are published (for
|
|
78
|
+
* published templates) or draft (for draft templates). Defaults to published.
|
|
79
|
+
*/
|
|
80
|
+
version?: 'published' | 'draft';
|
|
81
|
+
}
|
|
82
|
+
|
|
15
83
|
Automations.Invoke = Invoke;
|
|
16
84
|
|
|
17
85
|
export declare namespace Automations {
|
|
18
|
-
export {
|
|
86
|
+
export {
|
|
87
|
+
type AutomationInvokeResponse as AutomationInvokeResponse,
|
|
88
|
+
type AutomationTemplate as AutomationTemplate,
|
|
89
|
+
type AutomationTemplateListResponse as AutomationTemplateListResponse,
|
|
90
|
+
type AutomationListParams as AutomationListParams,
|
|
91
|
+
};
|
|
19
92
|
|
|
20
93
|
export {
|
|
21
94
|
Invoke as Invoke,
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export {
|
|
4
|
+
Automations,
|
|
5
|
+
type AutomationInvokeResponse,
|
|
6
|
+
type AutomationTemplate,
|
|
7
|
+
type AutomationTemplateListResponse,
|
|
8
|
+
type AutomationListParams,
|
|
9
|
+
} from './automations';
|
|
4
10
|
export { Invoke, type InvokeInvokeAdHocParams, type InvokeInvokeByTemplateParams } from './invoke';
|