@sendly/node 3.18.2 → 3.19.1
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/README.md +3 -3
- package/dist/index.d.mts +21 -3
- package/dist/index.d.ts +21 -3
- package/dist/index.js +12 -2
- package/dist/index.mjs +12 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -621,14 +621,14 @@ const result = await client.enterprise.provision({
|
|
|
621
621
|
name: 'Acme Insurance - Austin',
|
|
622
622
|
sourceWorkspaceId: 'ws_verified',
|
|
623
623
|
creditAmount: 5000,
|
|
624
|
-
creditSourceWorkspaceId: '
|
|
624
|
+
creditSourceWorkspaceId: 'SOURCE_WORKSPACE_ID',
|
|
625
625
|
keyName: 'Production',
|
|
626
626
|
keyType: 'live',
|
|
627
627
|
generateOptInPage: true
|
|
628
628
|
});
|
|
629
629
|
|
|
630
630
|
console.log(result.workspace.id);
|
|
631
|
-
console.log(result.
|
|
631
|
+
console.log(result.key?.key); // shown once
|
|
632
632
|
console.log(result.optInPage?.url); // hosted opt-in page
|
|
633
633
|
```
|
|
634
634
|
|
|
@@ -698,7 +698,7 @@ const key = await client.enterprise.workspaces.createKey('ws_xxx', {
|
|
|
698
698
|
name: 'Production',
|
|
699
699
|
type: 'live'
|
|
700
700
|
});
|
|
701
|
-
console.log(key.
|
|
701
|
+
console.log(key.key); // shown once
|
|
702
702
|
|
|
703
703
|
// Revoke a key
|
|
704
704
|
await client.enterprise.workspaces.revokeKey('ws_xxx', 'key_abc');
|
package/dist/index.d.mts
CHANGED
|
@@ -25,6 +25,7 @@ interface SendlyConfig {
|
|
|
25
25
|
* @default 3
|
|
26
26
|
*/
|
|
27
27
|
maxRetries?: number;
|
|
28
|
+
organizationId?: string;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Message type for compliance classification
|
|
@@ -1613,11 +1614,12 @@ interface ProvisionWorkspaceResult {
|
|
|
1613
1614
|
balance: number;
|
|
1614
1615
|
transferred?: number;
|
|
1615
1616
|
};
|
|
1616
|
-
|
|
1617
|
+
key?: {
|
|
1617
1618
|
id: string;
|
|
1618
1619
|
name: string;
|
|
1619
|
-
|
|
1620
|
-
|
|
1620
|
+
key: string;
|
|
1621
|
+
keyPrefix: string;
|
|
1622
|
+
type: string;
|
|
1621
1623
|
};
|
|
1622
1624
|
optInPage?: {
|
|
1623
1625
|
url: string;
|
|
@@ -1875,6 +1877,7 @@ interface HttpClientConfig {
|
|
|
1875
1877
|
baseUrl: string;
|
|
1876
1878
|
timeout: number;
|
|
1877
1879
|
maxRetries: number;
|
|
1880
|
+
organizationId?: string;
|
|
1878
1881
|
}
|
|
1879
1882
|
/**
|
|
1880
1883
|
* HTTP client for making API requests
|
|
@@ -1882,6 +1885,7 @@ interface HttpClientConfig {
|
|
|
1882
1885
|
declare class HttpClient {
|
|
1883
1886
|
private readonly config;
|
|
1884
1887
|
private rateLimitInfo?;
|
|
1888
|
+
organizationId?: string;
|
|
1885
1889
|
constructor(config: Partial<HttpClientConfig> & {
|
|
1886
1890
|
apiKey: string;
|
|
1887
1891
|
});
|
|
@@ -3418,6 +3422,19 @@ declare class WorkspacesSubResource {
|
|
|
3418
3422
|
workspaces: EnterpriseWorkspace[];
|
|
3419
3423
|
maxWorkspaces: number;
|
|
3420
3424
|
workspacesUsed: number;
|
|
3425
|
+
pagination?: {
|
|
3426
|
+
page: number;
|
|
3427
|
+
limit: number;
|
|
3428
|
+
total: number;
|
|
3429
|
+
totalPages: number;
|
|
3430
|
+
};
|
|
3431
|
+
summary?: {
|
|
3432
|
+
totalCredits: number;
|
|
3433
|
+
totalMessages30d: number;
|
|
3434
|
+
verified: number;
|
|
3435
|
+
pending: number;
|
|
3436
|
+
unverified: number;
|
|
3437
|
+
};
|
|
3421
3438
|
}>;
|
|
3422
3439
|
get(workspaceId: string): Promise<EnterpriseWorkspaceDetail>;
|
|
3423
3440
|
delete(workspaceId: string): Promise<void>;
|
|
@@ -3762,6 +3779,7 @@ declare class Sendly {
|
|
|
3762
3779
|
* Get the configured base URL
|
|
3763
3780
|
*/
|
|
3764
3781
|
getBaseUrl(): string;
|
|
3782
|
+
setOrganizationId(id: string): void;
|
|
3765
3783
|
}
|
|
3766
3784
|
|
|
3767
3785
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ interface SendlyConfig {
|
|
|
25
25
|
* @default 3
|
|
26
26
|
*/
|
|
27
27
|
maxRetries?: number;
|
|
28
|
+
organizationId?: string;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Message type for compliance classification
|
|
@@ -1613,11 +1614,12 @@ interface ProvisionWorkspaceResult {
|
|
|
1613
1614
|
balance: number;
|
|
1614
1615
|
transferred?: number;
|
|
1615
1616
|
};
|
|
1616
|
-
|
|
1617
|
+
key?: {
|
|
1617
1618
|
id: string;
|
|
1618
1619
|
name: string;
|
|
1619
|
-
|
|
1620
|
-
|
|
1620
|
+
key: string;
|
|
1621
|
+
keyPrefix: string;
|
|
1622
|
+
type: string;
|
|
1621
1623
|
};
|
|
1622
1624
|
optInPage?: {
|
|
1623
1625
|
url: string;
|
|
@@ -1875,6 +1877,7 @@ interface HttpClientConfig {
|
|
|
1875
1877
|
baseUrl: string;
|
|
1876
1878
|
timeout: number;
|
|
1877
1879
|
maxRetries: number;
|
|
1880
|
+
organizationId?: string;
|
|
1878
1881
|
}
|
|
1879
1882
|
/**
|
|
1880
1883
|
* HTTP client for making API requests
|
|
@@ -1882,6 +1885,7 @@ interface HttpClientConfig {
|
|
|
1882
1885
|
declare class HttpClient {
|
|
1883
1886
|
private readonly config;
|
|
1884
1887
|
private rateLimitInfo?;
|
|
1888
|
+
organizationId?: string;
|
|
1885
1889
|
constructor(config: Partial<HttpClientConfig> & {
|
|
1886
1890
|
apiKey: string;
|
|
1887
1891
|
});
|
|
@@ -3418,6 +3422,19 @@ declare class WorkspacesSubResource {
|
|
|
3418
3422
|
workspaces: EnterpriseWorkspace[];
|
|
3419
3423
|
maxWorkspaces: number;
|
|
3420
3424
|
workspacesUsed: number;
|
|
3425
|
+
pagination?: {
|
|
3426
|
+
page: number;
|
|
3427
|
+
limit: number;
|
|
3428
|
+
total: number;
|
|
3429
|
+
totalPages: number;
|
|
3430
|
+
};
|
|
3431
|
+
summary?: {
|
|
3432
|
+
totalCredits: number;
|
|
3433
|
+
totalMessages30d: number;
|
|
3434
|
+
verified: number;
|
|
3435
|
+
pending: number;
|
|
3436
|
+
unverified: number;
|
|
3437
|
+
};
|
|
3421
3438
|
}>;
|
|
3422
3439
|
get(workspaceId: string): Promise<EnterpriseWorkspaceDetail>;
|
|
3423
3440
|
delete(workspaceId: string): Promise<void>;
|
|
@@ -3762,6 +3779,7 @@ declare class Sendly {
|
|
|
3762
3779
|
* Get the configured base URL
|
|
3763
3780
|
*/
|
|
3764
3781
|
getBaseUrl(): string;
|
|
3782
|
+
setOrganizationId(id: string): void;
|
|
3765
3783
|
}
|
|
3766
3784
|
|
|
3767
3785
|
/**
|
package/dist/index.js
CHANGED
|
@@ -189,6 +189,7 @@ var DEFAULT_MAX_RETRIES = 3;
|
|
|
189
189
|
var HttpClient = class {
|
|
190
190
|
config;
|
|
191
191
|
rateLimitInfo;
|
|
192
|
+
organizationId;
|
|
192
193
|
constructor(config) {
|
|
193
194
|
this.config = {
|
|
194
195
|
apiKey: config.apiKey,
|
|
@@ -196,6 +197,7 @@ var HttpClient = class {
|
|
|
196
197
|
timeout: config.timeout || DEFAULT_TIMEOUT,
|
|
197
198
|
maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES
|
|
198
199
|
};
|
|
200
|
+
this.organizationId = config.organizationId || process.env.SENDLY_ORG_ID || void 0;
|
|
199
201
|
if (!this.isValidApiKey(this.config.apiKey)) {
|
|
200
202
|
throw new Error(
|
|
201
203
|
"Invalid API key format. Expected sk_test_v1_xxx or sk_live_v1_xxx"
|
|
@@ -374,13 +376,17 @@ var HttpClient = class {
|
|
|
374
376
|
* Build request headers
|
|
375
377
|
*/
|
|
376
378
|
buildHeaders(additionalHeaders) {
|
|
377
|
-
|
|
379
|
+
const headers = {
|
|
378
380
|
Authorization: `Bearer ${this.config.apiKey}`,
|
|
379
381
|
"Content-Type": "application/json",
|
|
380
382
|
Accept: "application/json",
|
|
381
383
|
"User-Agent": "@sendly/node/1.0.5",
|
|
382
384
|
...additionalHeaders
|
|
383
385
|
};
|
|
386
|
+
if (this.organizationId) {
|
|
387
|
+
headers["X-Organization-Id"] = this.organizationId;
|
|
388
|
+
}
|
|
389
|
+
return headers;
|
|
384
390
|
}
|
|
385
391
|
/**
|
|
386
392
|
* Update rate limit info from response headers
|
|
@@ -3511,7 +3517,8 @@ var Sendly = class {
|
|
|
3511
3517
|
apiKey: this.config.apiKey,
|
|
3512
3518
|
baseUrl: this.config.baseUrl,
|
|
3513
3519
|
timeout: this.config.timeout,
|
|
3514
|
-
maxRetries: this.config.maxRetries
|
|
3520
|
+
maxRetries: this.config.maxRetries,
|
|
3521
|
+
organizationId: typeof configOrApiKey === "string" ? void 0 : configOrApiKey.organizationId
|
|
3515
3522
|
});
|
|
3516
3523
|
this.messages = new MessagesResource(this.http);
|
|
3517
3524
|
this.webhooks = new WebhooksResource(this.http);
|
|
@@ -3565,6 +3572,9 @@ var Sendly = class {
|
|
|
3565
3572
|
getBaseUrl() {
|
|
3566
3573
|
return this.config.baseUrl;
|
|
3567
3574
|
}
|
|
3575
|
+
setOrganizationId(id) {
|
|
3576
|
+
this.http.organizationId = id;
|
|
3577
|
+
}
|
|
3568
3578
|
};
|
|
3569
3579
|
|
|
3570
3580
|
// src/utils/webhooks.ts
|
package/dist/index.mjs
CHANGED
|
@@ -129,6 +129,7 @@ var DEFAULT_MAX_RETRIES = 3;
|
|
|
129
129
|
var HttpClient = class {
|
|
130
130
|
config;
|
|
131
131
|
rateLimitInfo;
|
|
132
|
+
organizationId;
|
|
132
133
|
constructor(config) {
|
|
133
134
|
this.config = {
|
|
134
135
|
apiKey: config.apiKey,
|
|
@@ -136,6 +137,7 @@ var HttpClient = class {
|
|
|
136
137
|
timeout: config.timeout || DEFAULT_TIMEOUT,
|
|
137
138
|
maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES
|
|
138
139
|
};
|
|
140
|
+
this.organizationId = config.organizationId || process.env.SENDLY_ORG_ID || void 0;
|
|
139
141
|
if (!this.isValidApiKey(this.config.apiKey)) {
|
|
140
142
|
throw new Error(
|
|
141
143
|
"Invalid API key format. Expected sk_test_v1_xxx or sk_live_v1_xxx"
|
|
@@ -314,13 +316,17 @@ var HttpClient = class {
|
|
|
314
316
|
* Build request headers
|
|
315
317
|
*/
|
|
316
318
|
buildHeaders(additionalHeaders) {
|
|
317
|
-
|
|
319
|
+
const headers = {
|
|
318
320
|
Authorization: `Bearer ${this.config.apiKey}`,
|
|
319
321
|
"Content-Type": "application/json",
|
|
320
322
|
Accept: "application/json",
|
|
321
323
|
"User-Agent": "@sendly/node/1.0.5",
|
|
322
324
|
...additionalHeaders
|
|
323
325
|
};
|
|
326
|
+
if (this.organizationId) {
|
|
327
|
+
headers["X-Organization-Id"] = this.organizationId;
|
|
328
|
+
}
|
|
329
|
+
return headers;
|
|
324
330
|
}
|
|
325
331
|
/**
|
|
326
332
|
* Update rate limit info from response headers
|
|
@@ -3451,7 +3457,8 @@ var Sendly = class {
|
|
|
3451
3457
|
apiKey: this.config.apiKey,
|
|
3452
3458
|
baseUrl: this.config.baseUrl,
|
|
3453
3459
|
timeout: this.config.timeout,
|
|
3454
|
-
maxRetries: this.config.maxRetries
|
|
3460
|
+
maxRetries: this.config.maxRetries,
|
|
3461
|
+
organizationId: typeof configOrApiKey === "string" ? void 0 : configOrApiKey.organizationId
|
|
3455
3462
|
});
|
|
3456
3463
|
this.messages = new MessagesResource(this.http);
|
|
3457
3464
|
this.webhooks = new WebhooksResource(this.http);
|
|
@@ -3505,6 +3512,9 @@ var Sendly = class {
|
|
|
3505
3512
|
getBaseUrl() {
|
|
3506
3513
|
return this.config.baseUrl;
|
|
3507
3514
|
}
|
|
3515
|
+
setOrganizationId(id) {
|
|
3516
|
+
this.http.organizationId = id;
|
|
3517
|
+
}
|
|
3508
3518
|
};
|
|
3509
3519
|
|
|
3510
3520
|
// src/utils/webhooks.ts
|