contiguity 0.0.8 → 0.0.9
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/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/resources/agreements.d.ts +14 -0
- package/dist/resources/agreements.d.ts.map +1 -0
- package/dist/resources/agreements.js +10 -0
- package/dist/resources/entitlements.d.ts +38 -0
- package/dist/resources/entitlements.d.ts.map +1 -0
- package/dist/resources/entitlements.js +19 -0
- package/dist/resources/imessage.d.ts +12 -0
- package/dist/resources/imessage.d.ts.map +1 -1
- package/dist/resources/imessage.js +8 -0
- package/dist/resources/text.d.ts +12 -0
- package/dist/resources/text.d.ts.map +1 -1
- package/dist/resources/text.js +8 -0
- package/dist/resources/whatsapp.d.ts +12 -0
- package/dist/resources/whatsapp.d.ts.map +1 -1
- package/dist/resources/whatsapp.js +8 -0
- package/dist/schemas/conversations.d.ts.map +1 -1
- package/dist/schemas/imessage.d.ts +1 -0
- package/dist/schemas/imessage.d.ts.map +1 -1
- package/dist/schemas/imessage.js +1 -0
- package/dist/schemas/text.d.ts +1 -0
- package/dist/schemas/text.d.ts.map +1 -1
- package/dist/schemas/text.js +1 -0
- package/dist/schemas/whatsapp.d.ts +1 -0
- package/dist/schemas/whatsapp.d.ts.map +1 -1
- package/dist/schemas/whatsapp.js +1 -0
- package/dist/types/webhooks.d.ts +38 -0
- package/dist/types/webhooks.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +5 -1
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +3 -1
- package/dist/utils/normalize.d.ts +13 -0
- package/dist/utils/normalize.d.ts.map +1 -0
- package/dist/utils/normalize.js +25 -0
- package/dist/utils/request.d.ts +1 -0
- package/dist/utils/request.d.ts.map +1 -1
- package/dist/utils/request.js +5 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { EmailResource } from "./resources/email.js";
|
|
|
3
3
|
import { OtpResource } from "./resources/otp.js";
|
|
4
4
|
import { DomainsResource } from "./resources/domains.js";
|
|
5
5
|
import { LeaseResource } from "./resources/lease.js";
|
|
6
|
+
import { EntitlementsResource } from "./resources/entitlements.js";
|
|
7
|
+
import { AgreementsResource } from "./resources/agreements.js";
|
|
6
8
|
import { ImessageResource } from "./resources/imessage.js";
|
|
7
9
|
import { WhatsappResource } from "./resources/whatsapp.js";
|
|
8
10
|
import { WebhookResource } from "./resources/webhook.js";
|
|
@@ -15,6 +17,8 @@ export declare class Contiguity {
|
|
|
15
17
|
readonly otp: OtpResource;
|
|
16
18
|
readonly domains: DomainsResource;
|
|
17
19
|
readonly lease: LeaseResource;
|
|
20
|
+
readonly entitlements: EntitlementsResource;
|
|
21
|
+
readonly agreements: AgreementsResource;
|
|
18
22
|
readonly imessage: ImessageResource;
|
|
19
23
|
readonly whatsapp: WhatsappResource;
|
|
20
24
|
readonly webhook: WebhookResource;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,MAAM,WAAW,gBAAgB;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,UAAU;IACnB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IAEpC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;gBAEtB,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,GAAE,gBAAqB;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,MAAM,WAAW,gBAAgB;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,UAAU;IACnB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAC5C,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IAEpC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;gBAEtB,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,GAAE,gBAAqB;CA4B5D"}
|
package/dist/client.js
CHANGED
|
@@ -3,6 +3,8 @@ import { EmailResource } from "./resources/email.js";
|
|
|
3
3
|
import { OtpResource } from "./resources/otp.js";
|
|
4
4
|
import { DomainsResource } from "./resources/domains.js";
|
|
5
5
|
import { LeaseResource } from "./resources/lease.js";
|
|
6
|
+
import { EntitlementsResource } from "./resources/entitlements.js";
|
|
7
|
+
import { AgreementsResource } from "./resources/agreements.js";
|
|
6
8
|
import { ImessageResource } from "./resources/imessage.js";
|
|
7
9
|
import { WhatsappResource } from "./resources/whatsapp.js";
|
|
8
10
|
// import { VoiceResource } from "./resources/voice.js";
|
|
@@ -13,6 +15,8 @@ export class Contiguity {
|
|
|
13
15
|
otp;
|
|
14
16
|
domains;
|
|
15
17
|
lease;
|
|
18
|
+
entitlements;
|
|
19
|
+
agreements;
|
|
16
20
|
imessage;
|
|
17
21
|
whatsapp;
|
|
18
22
|
// readonly voice: VoiceResource;
|
|
@@ -36,6 +40,8 @@ export class Contiguity {
|
|
|
36
40
|
this.otp = new OtpResource({ ...request_config, base: "otp" });
|
|
37
41
|
this.domains = new DomainsResource({ ...request_config, base: "domains" });
|
|
38
42
|
this.lease = new LeaseResource({ ...request_config, base: "numbers" });
|
|
43
|
+
this.entitlements = new EntitlementsResource({ ...request_config, base: "entitlements" });
|
|
44
|
+
this.agreements = new AgreementsResource(this.entitlements);
|
|
39
45
|
this.imessage = new ImessageResource(request_config);
|
|
40
46
|
this.whatsapp = new WhatsappResource(request_config);
|
|
41
47
|
// this.voice = new VoiceResource({ ...request_config, base: "voice" });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { Contiguity } from "./client.js";
|
|
2
2
|
export type { ContiguityConfig } from "./client.js";
|
|
3
3
|
export { ContiguityError } from "./utils/errors.js";
|
|
4
|
+
export type { ContiguityErrorData } from "./utils/errors.js";
|
|
4
5
|
export { verifyWebhookSignature } from "./webhook/verify.js";
|
|
5
6
|
export { parseWebhookPayload } from "./webhook/parse.js";
|
|
6
7
|
export type { ResponseMetadata } from "./types/responses.js";
|
|
7
|
-
export type { WebhookEventBase, WebhookEventType } from "./types/webhooks.js";
|
|
8
|
+
export type { WebhookEventBase, WebhookEventType, IncomingMessageData, TextIncomingData, ImessageIncomingData, TextDeliveryData, } from "./types/webhooks.js";
|
|
8
9
|
export type { TextSendParams, TextReactParams } from "./schemas/text.js";
|
|
9
10
|
export type { EmailSendParams } from "./schemas/email.js";
|
|
10
11
|
export type { OtpNewParams, OtpVerifyParams, OtpResendParams, OtpReverseInitiateParams } from "./schemas/otp.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AACjH,YAAY,EACR,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC3G,YAAY,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EntitlementsResource } from "./entitlements.js";
|
|
2
|
+
export declare class AgreementsResource {
|
|
3
|
+
private readonly entitlements;
|
|
4
|
+
constructor(entitlements: EntitlementsResource);
|
|
5
|
+
accept(agreement_url: string): Promise<Record<string, unknown> & {
|
|
6
|
+
metadata: {
|
|
7
|
+
id: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
api_version: string;
|
|
10
|
+
object: string;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=agreements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agreements.d.ts","sourceRoot":"","sources":["../../src/resources/agreements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,qBAAa,kBAAkB;IACf,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAAZ,YAAY,EAAE,oBAAoB;IAE/D,MAAM,CAAC,aAAa,EAAE,MAAM;;;;;;;;CAI/B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class AgreementsResource {
|
|
2
|
+
entitlements;
|
|
3
|
+
constructor(entitlements) {
|
|
4
|
+
this.entitlements = entitlements;
|
|
5
|
+
}
|
|
6
|
+
accept(agreement_url) {
|
|
7
|
+
const name = agreement_url.replace("https://api.contiguity.com/entitlements/", "");
|
|
8
|
+
return this.entitlements.apply(name);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { RequestConfig } from "../utils/request.js";
|
|
2
|
+
export declare class EntitlementsResource {
|
|
3
|
+
private readonly config;
|
|
4
|
+
constructor(config: RequestConfig);
|
|
5
|
+
list(): Promise<Record<string, unknown> & {
|
|
6
|
+
metadata: {
|
|
7
|
+
id: string;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
api_version: string;
|
|
10
|
+
object: string;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
get(name: string): Promise<Record<string, unknown> & {
|
|
14
|
+
metadata: {
|
|
15
|
+
id: string;
|
|
16
|
+
timestamp: string;
|
|
17
|
+
api_version: string;
|
|
18
|
+
object: string;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
apply(name: string): Promise<Record<string, unknown> & {
|
|
22
|
+
metadata: {
|
|
23
|
+
id: string;
|
|
24
|
+
timestamp: string;
|
|
25
|
+
api_version: string;
|
|
26
|
+
object: string;
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
29
|
+
revoke(name: string): Promise<Record<string, unknown> & {
|
|
30
|
+
metadata: {
|
|
31
|
+
id: string;
|
|
32
|
+
timestamp: string;
|
|
33
|
+
api_version: string;
|
|
34
|
+
object: string;
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=entitlements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlements.d.ts","sourceRoot":"","sources":["../../src/resources/entitlements.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,qBAAa,oBAAoB;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,IAAI;;;;;;;;IAIJ,GAAG,CAAC,IAAI,EAAE,MAAM;;;;;;;;IAIhB,KAAK,CAAC,IAAI,EAAE,MAAM;;;;;;;;IAIlB,MAAM,CAAC,IAAI,EAAE,MAAM;;;;;;;;CAGtB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { request } from "../utils/request.js";
|
|
2
|
+
export class EntitlementsResource {
|
|
3
|
+
config;
|
|
4
|
+
constructor(config) {
|
|
5
|
+
this.config = config;
|
|
6
|
+
}
|
|
7
|
+
list() {
|
|
8
|
+
return request(this.config, "/");
|
|
9
|
+
}
|
|
10
|
+
get(name) {
|
|
11
|
+
return request(this.config, `/${encodeURIComponent(name)}`, { method: "GET" });
|
|
12
|
+
}
|
|
13
|
+
apply(name) {
|
|
14
|
+
return request(this.config, `/${encodeURIComponent(name)}`, { method: "POST" });
|
|
15
|
+
}
|
|
16
|
+
revoke(name) {
|
|
17
|
+
return request(this.config, `/${encodeURIComponent(name)}`, { method: "DELETE" });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { type ImessageSendParams, type ImessageTypingParams, type ImessageReactParams, type ImessageReadParams } from "../schemas/imessage.js";
|
|
2
2
|
import { type ConversationHistoryParams } from "../schemas/conversations.js";
|
|
3
3
|
import type { RequestConfig } from "../utils/request.js";
|
|
4
|
+
import type { WebhookEventBase } from "../types/webhooks.js";
|
|
4
5
|
export declare class ImessageResource {
|
|
5
6
|
private readonly config;
|
|
6
7
|
constructor(config: RequestConfig);
|
|
8
|
+
/** Reply to an incoming imessage webhook. Prefills to/from from event.data. */
|
|
9
|
+
reply(event: WebhookEventBase, params: Omit<ImessageSendParams, "to" | "from">): Promise<{
|
|
10
|
+
message_id: string;
|
|
11
|
+
} & {
|
|
12
|
+
metadata: {
|
|
13
|
+
id: string;
|
|
14
|
+
timestamp: string;
|
|
15
|
+
api_version: string;
|
|
16
|
+
object: string;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
7
19
|
send(params: ImessageSendParams): Promise<{
|
|
8
20
|
message_id: string;
|
|
9
21
|
} & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imessage.d.ts","sourceRoot":"","sources":["../../src/resources/imessage.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"imessage.d.ts","sourceRoot":"","sources":["../../src/resources/imessage.ts"],"names":[],"mappings":"AAEA,OAAO,EAKH,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEH,KAAK,yBAAyB,EACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,qBAAa,gBAAgB;IACb,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,+EAA+E;IACzE,KAAK,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,GAAG,MAAM,CAAC;oBAUnD,MAAM;;;;;;;;;IAFjC,IAAI,CAAC,MAAM,EAAE,kBAAkB;oBAEJ,MAAM;;;;;;;;;IAMjC,MAAM,CAAC,MAAM,EAAE,oBAAoB;;;;;;;;IAQnC,GAAG,CAAC,EAAE,EAAE,MAAM;;;;;;;;IAQd,OAAO,CAAC,MAAM,EAAE,yBAAyB;;;;;;;;IAUzC,KAAK,CAAC,MAAM,EAAE,KAAK,GAAG,QAAQ,EAAE,MAAM,EAAE,mBAAmB;;;;;;;;IAS3D,IAAI,CAAC,MAAM,EAAE,kBAAkB;;;;;;;;CAOxC"}
|
|
@@ -7,6 +7,14 @@ export class ImessageResource {
|
|
|
7
7
|
constructor(config) {
|
|
8
8
|
this.config = config;
|
|
9
9
|
}
|
|
10
|
+
/** Reply to an incoming imessage webhook. Prefills to/from from event.data. */
|
|
11
|
+
async reply(event, params) {
|
|
12
|
+
const data = event.data;
|
|
13
|
+
if (typeof data.to !== "string" || typeof data.from !== "string") {
|
|
14
|
+
throw new Error("Webhook event data must have to and from for reply");
|
|
15
|
+
}
|
|
16
|
+
return this.send({ ...params, to: data.from, from: data.to });
|
|
17
|
+
}
|
|
10
18
|
async send(params) {
|
|
11
19
|
const parsed = imessageSendSchema.parse(params);
|
|
12
20
|
return request(this.config, "/imessage", {
|
package/dist/resources/text.d.ts
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { type TextSendParams, type TextReactParams } from "../schemas/text.js";
|
|
2
2
|
import { type ConversationHistoryParams } from "../schemas/conversations.js";
|
|
3
3
|
import type { RequestConfig } from "../utils/request.js";
|
|
4
|
+
import type { WebhookEventBase } from "../types/webhooks.js";
|
|
4
5
|
export declare class TextResource {
|
|
5
6
|
private readonly config;
|
|
6
7
|
constructor(config: RequestConfig);
|
|
8
|
+
/** Reply to an incoming text webhook. Prefills to/from from event.data. */
|
|
9
|
+
reply(event: WebhookEventBase, params: Omit<TextSendParams, "to" | "from">): Promise<{
|
|
10
|
+
message_id: string;
|
|
11
|
+
} & {
|
|
12
|
+
metadata: {
|
|
13
|
+
id: string;
|
|
14
|
+
timestamp: string;
|
|
15
|
+
api_version: string;
|
|
16
|
+
object: string;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
7
19
|
send(params: TextSendParams): Promise<{
|
|
8
20
|
message_id: string;
|
|
9
21
|
} & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/resources/text.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/resources/text.ts"],"names":[],"mappings":"AAEA,OAAO,EAGH,KAAK,cAAc,EACnB,KAAK,eAAe,EACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEH,KAAK,yBAAyB,EACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,qBAAa,YAAY;IACT,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,2EAA2E;IACrE,KAAK,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,GAAG,MAAM,CAAC;oBAU/C,MAAM;;;;;;;;;IAFjC,IAAI,CAAC,MAAM,EAAE,cAAc;oBAEA,MAAM;;;;;;;;;IAMjC,GAAG,CAAC,EAAE,EAAE,MAAM;;;;;;;;IAQd,OAAO,CAAC,MAAM,EAAE,yBAAyB;;;;;;;;IAUzC,KAAK,CAAC,MAAM,EAAE,KAAK,GAAG,QAAQ,EAAE,MAAM,EAAE,eAAe;oBAG5B,MAAM;;;;;;;;;CAK1C"}
|
package/dist/resources/text.js
CHANGED
|
@@ -7,6 +7,14 @@ export class TextResource {
|
|
|
7
7
|
constructor(config) {
|
|
8
8
|
this.config = config;
|
|
9
9
|
}
|
|
10
|
+
/** Reply to an incoming text webhook. Prefills to/from from event.data. */
|
|
11
|
+
async reply(event, params) {
|
|
12
|
+
const data = event.data;
|
|
13
|
+
if (typeof data.to !== "string" || typeof data.from !== "string") {
|
|
14
|
+
throw new Error("Webhook event data must have to and from for reply");
|
|
15
|
+
}
|
|
16
|
+
return this.send({ ...params, to: data.from, from: data.to });
|
|
17
|
+
}
|
|
10
18
|
async send(params) {
|
|
11
19
|
const parsed = textSendSchema.parse(params);
|
|
12
20
|
return request(this.config, "/text", {
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import { type WhatsappSendParams, type WhatsappTypingParams, type WhatsappReactParams } from "../schemas/whatsapp.js";
|
|
2
2
|
import type { RequestConfig } from "../utils/request.js";
|
|
3
|
+
import type { WebhookEventBase } from "../types/webhooks.js";
|
|
3
4
|
export declare class WhatsappResource {
|
|
4
5
|
private readonly config;
|
|
5
6
|
constructor(config: RequestConfig);
|
|
7
|
+
/** Reply to an incoming whatsapp webhook. Prefills to/from from event.data. */
|
|
8
|
+
reply(event: WebhookEventBase, params: Omit<WhatsappSendParams, "to" | "from">): Promise<{
|
|
9
|
+
message_id: string;
|
|
10
|
+
} & {
|
|
11
|
+
metadata: {
|
|
12
|
+
id: string;
|
|
13
|
+
timestamp: string;
|
|
14
|
+
api_version: string;
|
|
15
|
+
object: string;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
6
18
|
send(params: WhatsappSendParams): Promise<{
|
|
7
19
|
message_id: string;
|
|
8
20
|
} & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whatsapp.d.ts","sourceRoot":"","sources":["../../src/resources/whatsapp.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"whatsapp.d.ts","sourceRoot":"","sources":["../../src/resources/whatsapp.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,+EAA+E;IACzE,KAAK,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,GAAG,MAAM,CAAC;oBAUrD,MAAM;;;;;;;;;IAF/B,IAAI,CAAC,MAAM,EAAE,kBAAkB;oBAEN,MAAM;;;;;;;;;IAM/B,MAAM,CAAC,MAAM,EAAE,oBAAoB;;;;;;;;IAQnC,KAAK,CAAC,MAAM,EAAE,KAAK,GAAG,QAAQ,EAAE,MAAM,EAAE,mBAAmB;;;;;;;;CAQlE"}
|
|
@@ -6,6 +6,14 @@ export class WhatsappResource {
|
|
|
6
6
|
constructor(config) {
|
|
7
7
|
this.config = config;
|
|
8
8
|
}
|
|
9
|
+
/** Reply to an incoming whatsapp webhook. Prefills to/from from event.data. */
|
|
10
|
+
async reply(event, params) {
|
|
11
|
+
const data = event.data;
|
|
12
|
+
if (typeof data.to !== "string" || typeof data.from !== "string") {
|
|
13
|
+
throw new Error("Webhook event data must have to and from for reply");
|
|
14
|
+
}
|
|
15
|
+
return this.send({ ...params, to: data.from, from: data.to });
|
|
16
|
+
}
|
|
9
17
|
async send(params) {
|
|
10
18
|
const parsed = whatsappSendSchema.parse(params);
|
|
11
19
|
return request(this.config, "/whatsapp", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../src/schemas/conversations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,yBAAyB;;;;
|
|
1
|
+
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../src/schemas/conversations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,yBAAyB;;;;iBAM1B,CAAC;AAEb,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
|
|
@@ -11,6 +11,7 @@ export declare const imessageSendSchema: z.ZodObject<{
|
|
|
11
11
|
from: z.ZodOptional<z.ZodString>;
|
|
12
12
|
}, z.core.$strip>>;
|
|
13
13
|
attachments: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
|
+
fast_track: z.ZodOptional<z.ZodBoolean>;
|
|
14
15
|
}, z.core.$loose>;
|
|
15
16
|
export declare const imessageTypingSchema: z.ZodObject<{
|
|
16
17
|
to: z.ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imessage.d.ts","sourceRoot":"","sources":["../../src/schemas/imessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"imessage.d.ts","sourceRoot":"","sources":["../../src/schemas/imessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;iBAcnB,CAAC;AAEb,eAAO,MAAM,oBAAoB;;;;;;;iBAMrB,CAAC;AAEb,eAAO,MAAM,mBAAmB;;;;;;;;;;;;iBAOpB,CAAC;AAEb,eAAO,MAAM,kBAAkB;;;iBAKnB,CAAC;AAEb,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACxE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
package/dist/schemas/imessage.js
CHANGED
package/dist/schemas/text.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const textSendSchema: z.ZodObject<{
|
|
|
4
4
|
message: z.ZodString;
|
|
5
5
|
from: z.ZodOptional<z.ZodString>;
|
|
6
6
|
attachments: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7
|
+
fast_track: z.ZodOptional<z.ZodBoolean>;
|
|
7
8
|
}, z.core.$loose>;
|
|
8
9
|
export declare const textReactSchema: z.ZodObject<{
|
|
9
10
|
message_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/schemas/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/schemas/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;;;;;;iBAQf,CAAC;AAEb,eAAO,MAAM,eAAe;;;;;;;;;;;;;iBAQhB,CAAC;AAEb,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAC5D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
package/dist/schemas/text.js
CHANGED
|
@@ -11,6 +11,7 @@ export declare const whatsappSendSchema: z.ZodObject<{
|
|
|
11
11
|
from: z.ZodOptional<z.ZodString>;
|
|
12
12
|
}, z.core.$strip>>;
|
|
13
13
|
attachments: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
|
+
fast_track: z.ZodOptional<z.ZodBoolean>;
|
|
14
15
|
}, z.core.$loose>;
|
|
15
16
|
export declare const whatsappTypingSchema: z.ZodObject<{
|
|
16
17
|
to: z.ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whatsapp.d.ts","sourceRoot":"","sources":["../../src/schemas/whatsapp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"whatsapp.d.ts","sourceRoot":"","sources":["../../src/schemas/whatsapp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;iBAcnB,CAAC;AAEb,eAAO,MAAM,oBAAoB;;;;;;;iBAMrB,CAAC;AAEb,eAAO,MAAM,mBAAmB;;;;iBAMpB,CAAC;AAEb,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACpE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACxE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
package/dist/schemas/whatsapp.js
CHANGED
package/dist/types/webhooks.d.ts
CHANGED
|
@@ -7,4 +7,42 @@ export interface WebhookEventBase {
|
|
|
7
7
|
api_version: string;
|
|
8
8
|
data: Record<string, unknown>;
|
|
9
9
|
}
|
|
10
|
+
/** text.incoming.sms / text.incoming.mms */
|
|
11
|
+
export interface TextIncomingData {
|
|
12
|
+
from: string;
|
|
13
|
+
to: string;
|
|
14
|
+
body: string;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
attachments?: Array<{
|
|
17
|
+
url: string;
|
|
18
|
+
mime: string;
|
|
19
|
+
filename: string;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
/** imessage.incoming */
|
|
23
|
+
export interface ImessageIncomingData {
|
|
24
|
+
from: string;
|
|
25
|
+
to: string;
|
|
26
|
+
body: string;
|
|
27
|
+
timestamp: number;
|
|
28
|
+
attachments?: Array<{
|
|
29
|
+
url?: string;
|
|
30
|
+
mime?: string;
|
|
31
|
+
filename?: string;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
/** text.delivery.confirmed / text.delivery.failed */
|
|
35
|
+
export interface TextDeliveryData {
|
|
36
|
+
from: string;
|
|
37
|
+
to: string;
|
|
38
|
+
message_id: string;
|
|
39
|
+
timestamp: number;
|
|
40
|
+
error?: string;
|
|
41
|
+
}
|
|
42
|
+
/** Minimal data for reply() - has to/from. Used by text, imessage, whatsapp. */
|
|
43
|
+
export interface IncomingMessageData {
|
|
44
|
+
to: string;
|
|
45
|
+
from: string;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
10
48
|
//# sourceMappingURL=webhooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/types/webhooks.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/types/webhooks.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,MAAM,gBAAgB,GACtB,mBAAmB,GACnB,mBAAmB,GACnB,yBAAyB,GACzB,sBAAsB,GACtB,mBAAmB,GACnB,sBAAsB,GACtB,sBAAsB,GACtB,gBAAgB,GAChB,uCAAuC,GACvC,0CAA0C,GAC1C,wCAAwC,GACxC,sCAAsC,GACtC,8CAA8C,GAC9C,iDAAiD,GACjD,+CAA+C,GAC/C,wCAAwC,CAAC;AAE/C,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,gBAAgB,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxE;AAED,wBAAwB;AACxB,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3E;AAED,qDAAqD;AACrD,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,gFAAgF;AAChF,MAAM,WAAW,mBAAmB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B"}
|
package/dist/utils/errors.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
export interface ContiguityErrorData {
|
|
2
|
+
agreement_url?: string;
|
|
3
|
+
}
|
|
1
4
|
export declare class ContiguityError extends Error {
|
|
2
5
|
readonly status?: number | undefined;
|
|
3
6
|
readonly code?: string | undefined;
|
|
4
|
-
|
|
7
|
+
readonly data?: ContiguityErrorData | undefined;
|
|
8
|
+
constructor(message: string, status?: number | undefined, code?: string | undefined, data?: ContiguityErrorData | undefined);
|
|
5
9
|
}
|
|
6
10
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAgB,SAAQ,KAAK;aAGlB,MAAM,CAAC,EAAE,MAAM;aACf,IAAI,CAAC,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,eAAgB,SAAQ,KAAK;aAGlB,MAAM,CAAC,EAAE,MAAM;aACf,IAAI,CAAC,EAAE,MAAM;aACb,IAAI,CAAC,EAAE,mBAAmB;gBAH1C,OAAO,EAAE,MAAM,EACC,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,IAAI,CAAC,EAAE,MAAM,YAAA,EACb,IAAI,CAAC,EAAE,mBAAmB,YAAA;CAMjD"}
|
package/dist/utils/errors.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export class ContiguityError extends Error {
|
|
2
2
|
status;
|
|
3
3
|
code;
|
|
4
|
-
|
|
4
|
+
data;
|
|
5
|
+
constructor(message, status, code, data) {
|
|
5
6
|
super(message);
|
|
6
7
|
this.status = status;
|
|
7
8
|
this.code = code;
|
|
9
|
+
this.data = data;
|
|
8
10
|
this.name = "ContiguityError";
|
|
9
11
|
Object.setPrototypeOf(this, ContiguityError.prototype);
|
|
10
12
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strip formatting. Only add leading + for 11-digit US (1 + 10 digits).
|
|
3
|
+
* e.g. "14155552671" -> "+14155552671", "+1 (415)-555 2671" -> "+14155552671"
|
|
4
|
+
* "442081234567" -> "442081234567" (no plus)
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizePhone(value: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Fix common "from" address issues: missing ">", trim.
|
|
9
|
+
* e.g. "Support <hello@example.com" -> "Support <hello@example.com>"
|
|
10
|
+
* Bare "hello@example.com" left as-is.
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeEmailFrom(value: string): string;
|
|
13
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/utils/normalize.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKpD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMxD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strip formatting. Only add leading + for 11-digit US (1 + 10 digits).
|
|
3
|
+
* e.g. "14155552671" -> "+14155552671", "+1 (415)-555 2671" -> "+14155552671"
|
|
4
|
+
* "442081234567" -> "442081234567" (no plus)
|
|
5
|
+
*/
|
|
6
|
+
export function normalizePhone(value) {
|
|
7
|
+
const digits_only = value.replace(/\D/g, "");
|
|
8
|
+
if (!digits_only)
|
|
9
|
+
return value;
|
|
10
|
+
const is_us_11 = digits_only.length === 11 && digits_only.startsWith("1");
|
|
11
|
+
return is_us_11 ? `+${digits_only}` : digits_only;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Fix common "from" address issues: missing ">", trim.
|
|
15
|
+
* e.g. "Support <hello@example.com" -> "Support <hello@example.com>"
|
|
16
|
+
* Bare "hello@example.com" left as-is.
|
|
17
|
+
*/
|
|
18
|
+
export function normalizeEmailFrom(value) {
|
|
19
|
+
const trimmed = value.trim();
|
|
20
|
+
const has_angle_open = trimmed.includes("<");
|
|
21
|
+
const has_angle_close = trimmed.includes(">");
|
|
22
|
+
if (has_angle_open && !has_angle_close)
|
|
23
|
+
return `${trimmed}>`;
|
|
24
|
+
return trimmed;
|
|
25
|
+
}
|
package/dist/utils/request.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare const BASE_URLS: {
|
|
|
5
5
|
readonly numbers: "https://api.contiguity.com/numbers";
|
|
6
6
|
readonly conversations: "https://api.contiguity.com/conversations";
|
|
7
7
|
readonly voice: "https://api.contiguity.com/voice";
|
|
8
|
+
readonly entitlements: "https://api.contiguity.com/entitlements";
|
|
8
9
|
};
|
|
9
10
|
export type ApiBase = keyof typeof BASE_URLS;
|
|
10
11
|
export interface RequestConfig {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/utils/request.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/utils/request.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,SAAS;;;;;;;;CAQL,CAAC;AAEX,MAAM,MAAM,OAAO,GAAG,MAAM,OAAO,SAAS,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrD,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IACL,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7B,GACP,OAAO,CAAC,CAAC,GAAG;IAAE,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC,CAqCnG"}
|
package/dist/utils/request.js
CHANGED
|
@@ -7,6 +7,7 @@ const BASE_URLS = {
|
|
|
7
7
|
numbers: "https://api.contiguity.com/numbers",
|
|
8
8
|
conversations: "https://api.contiguity.com/conversations",
|
|
9
9
|
voice: "https://api.contiguity.com/voice",
|
|
10
|
+
entitlements: "https://api.contiguity.com/entitlements",
|
|
10
11
|
};
|
|
11
12
|
export async function request(config, path, options = {}) {
|
|
12
13
|
const { token, base, debug } = config;
|
|
@@ -31,7 +32,10 @@ export async function request(config, path, options = {}) {
|
|
|
31
32
|
json.object ??
|
|
32
33
|
"Unknown error";
|
|
33
34
|
const status = json.data?.status ?? json.status ?? res.status;
|
|
34
|
-
|
|
35
|
+
const data = json.data?.agreement_url != null
|
|
36
|
+
? { agreement_url: String(json.data.agreement_url) }
|
|
37
|
+
: undefined;
|
|
38
|
+
throw new ContiguityError(errMsg, status, undefined, data);
|
|
35
39
|
}
|
|
36
40
|
return transformResponse(json);
|
|
37
41
|
}
|