contiguity 0.0.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.
Files changed (111) hide show
  1. package/LICENSE.md +8 -0
  2. package/README.md +1 -0
  3. package/dist/client/fetch.d.ts +30 -0
  4. package/dist/client/fetch.d.ts.map +1 -0
  5. package/dist/client/fetch.js +117 -0
  6. package/dist/contiguity.d.ts +81 -0
  7. package/dist/contiguity.d.ts.map +1 -0
  8. package/dist/contiguity.js +106 -0
  9. package/dist/index.d.ts +28 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +12542 -0
  12. package/dist/services/domains/delete.d.ts +32 -0
  13. package/dist/services/domains/delete.d.ts.map +1 -0
  14. package/dist/services/domains/delete.js +43 -0
  15. package/dist/services/domains/get.d.ts +128 -0
  16. package/dist/services/domains/get.d.ts.map +1 -0
  17. package/dist/services/domains/get.js +95 -0
  18. package/dist/services/domains/index.d.ts +34 -0
  19. package/dist/services/domains/index.d.ts.map +1 -0
  20. package/dist/services/domains/index.js +37 -0
  21. package/dist/services/domains/list.d.ts +68 -0
  22. package/dist/services/domains/list.d.ts.map +1 -0
  23. package/dist/services/domains/list.js +52 -0
  24. package/dist/services/domains/register.d.ts +89 -0
  25. package/dist/services/domains/register.d.ts.map +1 -0
  26. package/dist/services/domains/register.js +73 -0
  27. package/dist/services/email/index.d.ts +17 -0
  28. package/dist/services/email/index.d.ts.map +1 -0
  29. package/dist/services/email/index.js +16 -0
  30. package/dist/services/email/send.d.ts +69 -0
  31. package/dist/services/email/send.d.ts.map +1 -0
  32. package/dist/services/email/send.js +84 -0
  33. package/dist/services/imessage/index.d.ts +24 -0
  34. package/dist/services/imessage/index.d.ts.map +1 -0
  35. package/dist/services/imessage/index.js +23 -0
  36. package/dist/services/imessage/send.d.ts +60 -0
  37. package/dist/services/imessage/send.d.ts.map +1 -0
  38. package/dist/services/imessage/send.js +66 -0
  39. package/dist/services/imessage/typing.d.ts +43 -0
  40. package/dist/services/imessage/typing.d.ts.map +1 -0
  41. package/dist/services/imessage/typing.js +55 -0
  42. package/dist/services/lease/available.d.ts +255 -0
  43. package/dist/services/lease/available.d.ts.map +1 -0
  44. package/dist/services/lease/available.js +109 -0
  45. package/dist/services/lease/create.d.ts +139 -0
  46. package/dist/services/lease/create.d.ts.map +1 -0
  47. package/dist/services/lease/create.js +84 -0
  48. package/dist/services/lease/details.d.ts +210 -0
  49. package/dist/services/lease/details.d.ts.map +1 -0
  50. package/dist/services/lease/details.js +71 -0
  51. package/dist/services/lease/get.d.ts +155 -0
  52. package/dist/services/lease/get.d.ts.map +1 -0
  53. package/dist/services/lease/get.js +74 -0
  54. package/dist/services/lease/index.d.ts +50 -0
  55. package/dist/services/lease/index.d.ts.map +1 -0
  56. package/dist/services/lease/index.js +51 -0
  57. package/dist/services/lease/leased.d.ts +308 -0
  58. package/dist/services/lease/leased.d.ts.map +1 -0
  59. package/dist/services/lease/leased.js +114 -0
  60. package/dist/services/lease/terminate.d.ts +81 -0
  61. package/dist/services/lease/terminate.d.ts.map +1 -0
  62. package/dist/services/lease/terminate.js +84 -0
  63. package/dist/services/otp/index.d.ts +28 -0
  64. package/dist/services/otp/index.d.ts.map +1 -0
  65. package/dist/services/otp/index.js +30 -0
  66. package/dist/services/otp/new.d.ts +29 -0
  67. package/dist/services/otp/new.d.ts.map +1 -0
  68. package/dist/services/otp/new.js +44 -0
  69. package/dist/services/otp/resend.d.ts +25 -0
  70. package/dist/services/otp/resend.d.ts.map +1 -0
  71. package/dist/services/otp/resend.js +37 -0
  72. package/dist/services/otp/verify.d.ts +27 -0
  73. package/dist/services/otp/verify.d.ts.map +1 -0
  74. package/dist/services/otp/verify.js +40 -0
  75. package/dist/services/text/index.d.ts +17 -0
  76. package/dist/services/text/index.d.ts.map +1 -0
  77. package/dist/services/text/index.js +16 -0
  78. package/dist/services/text/send.d.ts +28 -0
  79. package/dist/services/text/send.d.ts.map +1 -0
  80. package/dist/services/text/send.js +43 -0
  81. package/dist/services/whatsapp/index.d.ts +24 -0
  82. package/dist/services/whatsapp/index.d.ts.map +1 -0
  83. package/dist/services/whatsapp/index.js +23 -0
  84. package/dist/services/whatsapp/send.d.ts +60 -0
  85. package/dist/services/whatsapp/send.d.ts.map +1 -0
  86. package/dist/services/whatsapp/send.js +66 -0
  87. package/dist/services/whatsapp/typing.d.ts +43 -0
  88. package/dist/services/whatsapp/typing.d.ts.map +1 -0
  89. package/dist/services/whatsapp/typing.js +55 -0
  90. package/dist/types/base.d.ts +38 -0
  91. package/dist/types/base.d.ts.map +1 -0
  92. package/dist/types/base.js +32 -0
  93. package/dist/types/common.d.ts +56 -0
  94. package/dist/types/common.d.ts.map +1 -0
  95. package/dist/types/common.js +48 -0
  96. package/dist/types/error.d.ts +37 -0
  97. package/dist/types/error.d.ts.map +1 -0
  98. package/dist/types/error.js +54 -0
  99. package/dist/types/metadata.d.ts +10 -0
  100. package/dist/types/metadata.d.ts.map +1 -0
  101. package/dist/types/metadata.js +1 -0
  102. package/dist/types/response.d.ts +17 -0
  103. package/dist/types/response.d.ts.map +1 -0
  104. package/dist/types/response.js +17 -0
  105. package/dist/utils/parse.d.ts +8 -0
  106. package/dist/utils/parse.d.ts.map +1 -0
  107. package/dist/utils/parse.js +36 -0
  108. package/dist/utils/request.d.ts +6 -0
  109. package/dist/utils/request.d.ts.map +1 -0
  110. package/dist/utils/request.js +47 -0
  111. package/package.json +46 -0
@@ -0,0 +1,44 @@
1
+ import { z } from "zod";
2
+ import { createResponse } from "@/types/base";
3
+ import { E164PhoneNumber } from "@/types/common";
4
+ export const OTPNewRequest = z.object({
5
+ /** Recipient's phone number. Must be in E.164 format */
6
+ to: E164PhoneNumber,
7
+ /** Language of the OTP message */
8
+ language: z.string().min(1, "Language cannot be empty"),
9
+ /** Your app's name (customizes message to 'Your [name] code is...') */
10
+ name: z.string().min(1, "App name cannot be empty"),
11
+ });
12
+ export const OTPNewResponse = z.object({
13
+ /** The OTP's ID. Use it to refer to this verification in the future, such as when verifying the OTP or resending it. */
14
+ otp_id: z.string(),
15
+ });
16
+ // Using the new base response builder - this replaces the manual Flattened/Raw definitions
17
+ export const OTPNewResponseBuilder = createResponse(OTPNewResponse);
18
+ /**
19
+ * Sends a new OTP to the specified phone number
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const response = await contiguity.otp.new({
24
+ * to: "+1234567890",
25
+ * language: "en",
26
+ * name: "My App"
27
+ * });
28
+ * console.log(`OTP ID: ${response.otp_id}`);
29
+ * ```
30
+ */
31
+ export async function _otpNew(params) {
32
+ const validatedParams = OTPNewRequest.parse(params);
33
+ const response = await this.request("/otp/new", {
34
+ method: "POST",
35
+ body: JSON.stringify(validatedParams),
36
+ });
37
+ return this.parse({
38
+ response,
39
+ schemas: {
40
+ sdk: OTPNewResponse,
41
+ raw: OTPNewResponseBuilder.raw
42
+ }
43
+ });
44
+ }
@@ -0,0 +1,25 @@
1
+ import { z } from "zod";
2
+ export declare const OTPResendRequest: z.ZodObject<{
3
+ otp_id: z.ZodString;
4
+ }, z.core.$strip>;
5
+ export declare const OTPResendResponse: z.ZodObject<{
6
+ resent: z.ZodBoolean;
7
+ }, z.core.$strip>;
8
+ export declare const OTPResendResponseBuilder: import("@/types/base").BaseResponseBuilder<z.ZodObject<{
9
+ resent: z.ZodBoolean;
10
+ }, z.core.$strip>>;
11
+ export type OTPResendParams = z.infer<typeof OTPResendRequest>;
12
+ export type OTPResendResponse = z.infer<typeof OTPResendResponse>;
13
+ /**
14
+ * Resends an OTP to the same phone number
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const response = await contiguity.otp.resend({
19
+ * otp_id: "otp_1234567890"
20
+ * });
21
+ * console.log(`Resent: ${response.resent}`);
22
+ * ```
23
+ */
24
+ export declare function _otpResend(this: any, params: OTPResendParams): Promise<any>;
25
+ //# sourceMappingURL=resend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resend.d.ts","sourceRoot":"","sources":["../../../src/services/otp/resend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,gBAAgB;;iBAG3B,CAAA;AAEF,eAAO,MAAM,iBAAiB;;iBAG5B,CAAA;AAGF,eAAO,MAAM,wBAAwB;;kBAAoC,CAAA;AAEzE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC/D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE;;;;;;;;;;GAUG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,CAcjF"}
@@ -0,0 +1,37 @@
1
+ import { z } from "zod";
2
+ import { createResponse } from "@/types/base";
3
+ export const OTPResendRequest = z.object({
4
+ /** The OTP ID you received when sending the OTP */
5
+ otp_id: z.string().min(1, "OTP ID cannot be empty"),
6
+ });
7
+ export const OTPResendResponse = z.object({
8
+ /** Whether the OTP was resent */
9
+ resent: z.boolean(),
10
+ });
11
+ // Using the new base response builder
12
+ export const OTPResendResponseBuilder = createResponse(OTPResendResponse);
13
+ /**
14
+ * Resends an OTP to the same phone number
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const response = await contiguity.otp.resend({
19
+ * otp_id: "otp_1234567890"
20
+ * });
21
+ * console.log(`Resent: ${response.resent}`);
22
+ * ```
23
+ */
24
+ export async function _otpResend(params) {
25
+ const validatedParams = OTPResendRequest.parse(params);
26
+ const response = await this.request("/otp/resend", {
27
+ method: "POST",
28
+ body: JSON.stringify(validatedParams),
29
+ });
30
+ return this.parse({
31
+ response,
32
+ schemas: {
33
+ sdk: OTPResendResponse,
34
+ raw: OTPResendResponseBuilder.raw
35
+ }
36
+ });
37
+ }
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ export declare const OTPVerifyRequest: z.ZodObject<{
3
+ otp_id: z.ZodString;
4
+ otp: z.ZodString;
5
+ }, z.core.$strip>;
6
+ export declare const OTPVerifyResponse: z.ZodObject<{
7
+ verified: z.ZodBoolean;
8
+ }, z.core.$strip>;
9
+ export declare const OTPVerifyResponseBuilder: import("@/types/base").BaseResponseBuilder<z.ZodObject<{
10
+ verified: z.ZodBoolean;
11
+ }, z.core.$strip>>;
12
+ export type OTPVerifyParams = z.infer<typeof OTPVerifyRequest>;
13
+ export type OTPVerifyResponse = z.infer<typeof OTPVerifyResponse>;
14
+ /**
15
+ * Verifies an OTP code
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const response = await contiguity.otp.verify({
20
+ * otp_id: "otp_1234567890",
21
+ * otp: "123456"
22
+ * });
23
+ * console.log(`Verified: ${response.verified}`);
24
+ * ```
25
+ */
26
+ export declare function _otpVerify(this: any, params: OTPVerifyParams): Promise<any>;
27
+ //# sourceMappingURL=verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../src/services/otp/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,gBAAgB;;;iBAK3B,CAAA;AAEF,eAAO,MAAM,iBAAiB;;iBAG5B,CAAA;AAGF,eAAO,MAAM,wBAAwB;;kBAAoC,CAAA;AAEzE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC/D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE;;;;;;;;;;;GAWG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,CAcjF"}
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ import { createResponse } from "@/types/base";
3
+ export const OTPVerifyRequest = z.object({
4
+ /** The OTP ID you received when sending the OTP */
5
+ otp_id: z.string().min(1, "OTP ID cannot be empty"),
6
+ /** The OTP inputted by the user */
7
+ otp: z.string().min(1, "OTP cannot be empty"),
8
+ });
9
+ export const OTPVerifyResponse = z.object({
10
+ /** Whether the OTP was verified or not */
11
+ verified: z.boolean(),
12
+ });
13
+ // Using the new base response builder
14
+ export const OTPVerifyResponseBuilder = createResponse(OTPVerifyResponse);
15
+ /**
16
+ * Verifies an OTP code
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const response = await contiguity.otp.verify({
21
+ * otp_id: "otp_1234567890",
22
+ * otp: "123456"
23
+ * });
24
+ * console.log(`Verified: ${response.verified}`);
25
+ * ```
26
+ */
27
+ export async function _otpVerify(params) {
28
+ const validatedParams = OTPVerifyRequest.parse(params);
29
+ const response = await this.request("/otp/verify", {
30
+ method: "POST",
31
+ body: JSON.stringify(validatedParams),
32
+ });
33
+ return this.parse({
34
+ response,
35
+ schemas: {
36
+ sdk: OTPVerifyResponse,
37
+ raw: OTPVerifyResponseBuilder.raw
38
+ }
39
+ });
40
+ }
@@ -0,0 +1,17 @@
1
+ import { ContiguityClient } from "@/client/fetch";
2
+ import { z } from "zod";
3
+ import { TextSendRequest, TextResponse } from "@/services/text/send";
4
+ import type { WithMetadata } from "@/types/metadata";
5
+ export type TextSendParams = z.infer<typeof TextSendRequest>;
6
+ export type TextSendResponse = z.infer<typeof TextResponse>;
7
+ /**
8
+ * Text service for sending messages
9
+ */
10
+ export declare class TextService extends ContiguityClient {
11
+ constructor(token: string);
12
+ /**
13
+ * Send a text message
14
+ */
15
+ send(params: TextSendParams): Promise<WithMetadata<TextSendResponse>>;
16
+ }
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAC7D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAE5D;;GAEG;AACH,qBAAa,WAAY,SAAQ,gBAAgB;gBACjC,KAAK,EAAE,MAAM;IAIzB;;OAEG;IACG,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;CAG9E"}
@@ -0,0 +1,16 @@
1
+ import { ContiguityClient } from "@/client/fetch";
2
+ import { _textSend } from "@/services/text/send";
3
+ /**
4
+ * Text service for sending messages
5
+ */
6
+ export class TextService extends ContiguityClient {
7
+ constructor(token) {
8
+ super(token);
9
+ }
10
+ /**
11
+ * Send a text message
12
+ */
13
+ async send(params) {
14
+ return _textSend.call(this, params);
15
+ }
16
+ }
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ export declare const TextSendRequest: z.ZodObject<{
3
+ to: z.ZodString;
4
+ from: z.ZodOptional<z.ZodString>;
5
+ message: z.ZodString;
6
+ }, z.core.$strip>;
7
+ export declare const TextResponse: z.ZodObject<{
8
+ message_id: z.ZodString;
9
+ }, z.core.$strip>;
10
+ export declare const TextSendResponse: import("@/types/base").BaseResponseBuilder<z.ZodObject<{
11
+ message_id: z.ZodString;
12
+ }, z.core.$strip>>;
13
+ export type TextSendParams = z.infer<typeof TextSendRequest>;
14
+ export type TextSendResponse = z.infer<typeof TextResponse>;
15
+ /**
16
+ * Sends a text message
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const response = await contiguity.text.send({
21
+ * to: "+1234567890",
22
+ * message: "Hello from Contiguity!"
23
+ * });
24
+ * console.log(`Message ID: ${response.message_id}`);
25
+ * ```
26
+ */
27
+ export declare function _textSend(this: any, params: TextSendParams): Promise<any>;
28
+ //# sourceMappingURL=send.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../../src/services/text/send.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,eAAe;;;;iBAO1B,CAAA;AAEF,eAAO,MAAM,YAAY;;iBAGvB,CAAA;AAGF,eAAO,MAAM,gBAAgB;;kBAA+B,CAAA;AAE5D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAC7D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAE5D;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,CAc/E"}
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+ import { createResponse } from "@/types/base";
3
+ import { E164PhoneNumber, OptionalSenderNumber, MessageContent } from "@/types/common";
4
+ export const TextSendRequest = z.object({
5
+ /** Recipient's phone number. Must be in E.164 format */
6
+ to: E164PhoneNumber,
7
+ /** If you lease a phone number from Contiguity, you can use a specific one by providing it here */
8
+ from: OptionalSenderNumber,
9
+ /** The text message to send */
10
+ message: MessageContent,
11
+ });
12
+ export const TextResponse = z.object({
13
+ /** The message's ID. Use it to refer to this message in the future */
14
+ message_id: z.string(),
15
+ });
16
+ // Using the new base response builder - this replaces the manual Flattened/Raw definitions
17
+ export const TextSendResponse = createResponse(TextResponse);
18
+ /**
19
+ * Sends a text message
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const response = await contiguity.text.send({
24
+ * to: "+1234567890",
25
+ * message: "Hello from Contiguity!"
26
+ * });
27
+ * console.log(`Message ID: ${response.message_id}`);
28
+ * ```
29
+ */
30
+ export async function _textSend(params) {
31
+ const validatedParams = TextSendRequest.parse(params);
32
+ const response = await this.request("/send/text", {
33
+ method: "POST",
34
+ body: JSON.stringify(validatedParams),
35
+ });
36
+ return this.parse({
37
+ response,
38
+ schemas: {
39
+ sdk: TextResponse,
40
+ raw: TextSendResponse.raw
41
+ }
42
+ });
43
+ }
@@ -0,0 +1,24 @@
1
+ import { ContiguityClient } from "@/client/fetch";
2
+ import { z } from "zod";
3
+ import { WhatsAppSendRequest, WhatsAppResponse } from "@/services/whatsapp/send";
4
+ import { WhatsAppTypingRequest, WhatsAppTypingResponse } from "@/services/whatsapp/typing";
5
+ import type { WithMetadata } from "@/types/metadata";
6
+ export type WhatsAppSendParams = z.infer<typeof WhatsAppSendRequest>;
7
+ export type WhatsAppSendResponse = z.infer<typeof WhatsAppResponse>;
8
+ export type WhatsAppTypingParams = z.infer<typeof WhatsAppTypingRequest>;
9
+ export type WhatsAppTypingResponseType = z.infer<typeof WhatsAppTypingResponse>;
10
+ /**
11
+ * WhatsApp service for sending WhatsApp messages and managing typing indicators
12
+ */
13
+ export declare class WhatsAppService extends ContiguityClient {
14
+ constructor(token: string);
15
+ /**
16
+ * Send a WhatsApp message
17
+ */
18
+ send(params: WhatsAppSendParams): Promise<WithMetadata<WhatsAppSendResponse>>;
19
+ /**
20
+ * Start or stop sending typing indicators over WhatsApp
21
+ */
22
+ typing(params: WhatsAppTypingParams): Promise<WithMetadata<WhatsAppTypingResponseType>>;
23
+ }
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/whatsapp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACH,mBAAmB,EACnB,gBAAgB,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACrE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AACpE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACzE,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEhF;;GAEG;AACH,qBAAa,eAAgB,SAAQ,gBAAgB;gBACrC,KAAK,EAAE,MAAM;IAIzB;;OAEG;IACG,IAAI,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC;IAInF;;OAEG;IACG,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAAC;CAGhG"}
@@ -0,0 +1,23 @@
1
+ import { ContiguityClient } from "@/client/fetch";
2
+ import { _whatsAppSend } from "@/services/whatsapp/send";
3
+ import { _whatsAppTyping } from "@/services/whatsapp/typing";
4
+ /**
5
+ * WhatsApp service for sending WhatsApp messages and managing typing indicators
6
+ */
7
+ export class WhatsAppService extends ContiguityClient {
8
+ constructor(token) {
9
+ super(token);
10
+ }
11
+ /**
12
+ * Send a WhatsApp message
13
+ */
14
+ async send(params) {
15
+ return _whatsAppSend.call(this, params);
16
+ }
17
+ /**
18
+ * Start or stop sending typing indicators over WhatsApp
19
+ */
20
+ async typing(params) {
21
+ return _whatsAppTyping.call(this, params);
22
+ }
23
+ }
@@ -0,0 +1,60 @@
1
+ import { z } from "zod";
2
+ export declare const WhatsAppSendRequest: z.ZodObject<{
3
+ to: z.ZodString;
4
+ from: z.ZodOptional<z.ZodString>;
5
+ message: z.ZodString;
6
+ fallback: z.ZodOptional<z.ZodObject<{
7
+ when: z.ZodArray<z.ZodEnum<{
8
+ whatsapp: "whatsapp";
9
+ whatsapp_unsupported: "whatsapp_unsupported";
10
+ whatsapp_fails: "whatsapp_fails";
11
+ }>>;
12
+ from: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strip>>;
14
+ attachments: z.ZodOptional<z.ZodArray<z.ZodString>>;
15
+ }, z.core.$strip>;
16
+ export declare const WhatsAppResponse: z.ZodObject<{
17
+ message_id: z.ZodString;
18
+ }, z.core.$strip>;
19
+ export declare const WhatsAppSendResponse: import("@/types/base").BaseResponseBuilder<z.ZodObject<{
20
+ message_id: z.ZodString;
21
+ }, z.core.$strip>>;
22
+ export type WhatsAppFallbackParams = {
23
+ when: ("whatsapp_unsupported" | "whatsapp_fails")[];
24
+ from?: string;
25
+ };
26
+ export type WhatsAppSendParams = z.infer<typeof WhatsAppSendRequest>;
27
+ export type WhatsAppSendResponse = z.infer<typeof WhatsAppResponse>;
28
+ /**
29
+ * Sends a WhatsApp message
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const response = await contiguity.whatsapp.send({
34
+ * to: "+1234567890",
35
+ * message: "Hello from Contiguity!"
36
+ * });
37
+ * console.log(`Message ID: ${response.message_id}`);
38
+ * ```
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * // Send with fallback to SMS and attachments
43
+ * const response = await contiguity.whatsapp.send({
44
+ * to: "+1234567890",
45
+ * from: "+15555555555",
46
+ * message: "Check out this image!",
47
+ * fallback: {
48
+ * when: ["whatsapp_unsupported", "whatsapp_fails"],
49
+ * from: "+15555555555"
50
+ * },
51
+ * attachments: [
52
+ * "https://example.com/image.png",
53
+ * "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34..."
54
+ * ]
55
+ * });
56
+ * console.log(`Message ID: ${response.message_id}`);
57
+ * ```
58
+ */
59
+ export declare function _whatsAppSend(this: any, params: WhatsAppSendParams): Promise<any>;
60
+ //# sourceMappingURL=send.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../../src/services/whatsapp/send.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;iBAW9B,CAAA;AAEF,eAAO,MAAM,gBAAgB;;iBAG3B,CAAA;AAGF,eAAO,MAAM,oBAAoB;;kBAAmC,CAAA;AAEpE,MAAM,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,CAAC,sBAAsB,GAAG,gBAAgB,CAAC,EAAE,CAAC;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACrE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,CAcvF"}
@@ -0,0 +1,66 @@
1
+ import { z } from "zod";
2
+ import { createResponse } from "@/types/base";
3
+ import { E164PhoneNumber, OptionalSenderNumber, MessageContent, AttachmentList, createFallbackSchema } from "@/types/common";
4
+ export const WhatsAppSendRequest = z.object({
5
+ /** Recipient's WhatsApp number. Must be in E.164 format */
6
+ to: E164PhoneNumber,
7
+ /** Your leased WhatsApp number. If none is provided, we will use a random WhatsApp number of yours */
8
+ from: OptionalSenderNumber,
9
+ /** The WhatsApp message to send */
10
+ message: MessageContent,
11
+ /** Should Contiguity fallback to SMS/RCS if the recipient does not have WhatsApp, or if WhatsApp fails to send? */
12
+ fallback: createFallbackSchema("whatsapp", ["whatsapp_unsupported", "whatsapp_fails"]),
13
+ /** Attachments to send. Can be a URL to your attachment (e.g. example.com/image.png) or a base64 string. Max 10 attachments, with a cumulative size of 50MB */
14
+ attachments: AttachmentList
15
+ });
16
+ export const WhatsAppResponse = z.object({
17
+ /** The message's ID. Use it to refer to this message in the future, when checking the status of the message or finding it in the Console */
18
+ message_id: z.string(),
19
+ });
20
+ // Using the new base response builder - this replaces the manual Flattened/Raw definitions
21
+ export const WhatsAppSendResponse = createResponse(WhatsAppResponse);
22
+ /**
23
+ * Sends a WhatsApp message
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const response = await contiguity.whatsapp.send({
28
+ * to: "+1234567890",
29
+ * message: "Hello from Contiguity!"
30
+ * });
31
+ * console.log(`Message ID: ${response.message_id}`);
32
+ * ```
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * // Send with fallback to SMS and attachments
37
+ * const response = await contiguity.whatsapp.send({
38
+ * to: "+1234567890",
39
+ * from: "+15555555555",
40
+ * message: "Check out this image!",
41
+ * fallback: {
42
+ * when: ["whatsapp_unsupported", "whatsapp_fails"],
43
+ * from: "+15555555555"
44
+ * },
45
+ * attachments: [
46
+ * "https://example.com/image.png",
47
+ * "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34..."
48
+ * ]
49
+ * });
50
+ * console.log(`Message ID: ${response.message_id}`);
51
+ * ```
52
+ */
53
+ export async function _whatsAppSend(params) {
54
+ const validatedParams = WhatsAppSendRequest.parse(params);
55
+ const response = await this.request("/send/whatsapp", {
56
+ method: "POST",
57
+ body: JSON.stringify(validatedParams),
58
+ });
59
+ return this.parse({
60
+ response,
61
+ schemas: {
62
+ sdk: WhatsAppResponse,
63
+ raw: WhatsAppSendResponse.raw
64
+ }
65
+ });
66
+ }
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+ export declare const WhatsAppTypingRequest: z.ZodObject<{
3
+ to: z.ZodString;
4
+ from: z.ZodOptional<z.ZodString>;
5
+ action: z.ZodEnum<{
6
+ start: "start";
7
+ stop: "stop";
8
+ }>;
9
+ }, z.core.$strip>;
10
+ export declare const WhatsAppTypingResponse: z.ZodObject<{
11
+ status: z.ZodString;
12
+ }, z.core.$strip>;
13
+ export declare const WhatsAppTypingResponseBuilder: import("@/types/base").BaseResponseBuilder<z.ZodObject<{
14
+ status: z.ZodString;
15
+ }, z.core.$strip>>;
16
+ export type WhatsAppTypingParams = z.infer<typeof WhatsAppTypingRequest>;
17
+ export type WhatsAppTypingResponseType = z.infer<typeof WhatsAppTypingResponse>;
18
+ /**
19
+ * Start or stop sending typing indicators over WhatsApp
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // Start typing indicator
24
+ * const response = await contiguity.whatsapp.typing({
25
+ * to: "+1234567890",
26
+ * action: "start"
27
+ * });
28
+ * console.log(`Typing status: ${response.status}`);
29
+ * ```
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * // Stop typing indicator with specific sender number
34
+ * const response = await contiguity.whatsapp.typing({
35
+ * to: "+1234567890",
36
+ * from: "+15555555555",
37
+ * action: "stop"
38
+ * });
39
+ * console.log(`Typing status: ${response.status}`);
40
+ * ```
41
+ */
42
+ export declare function _whatsAppTyping(this: any, params: WhatsAppTypingParams): Promise<any>;
43
+ //# sourceMappingURL=typing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typing.d.ts","sourceRoot":"","sources":["../../../src/services/whatsapp/typing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,qBAAqB;;;;;;;iBAOhC,CAAA;AAEF,eAAO,MAAM,sBAAsB;;iBAGjC,CAAA;AAGF,eAAO,MAAM,6BAA6B;;kBAAyC,CAAA;AAEnF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACzE,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,GAAG,CAAC,CAc3F"}
@@ -0,0 +1,55 @@
1
+ import { z } from "zod";
2
+ import { createResponse } from "@/types/base";
3
+ import { E164PhoneNumber, OptionalSenderNumber, TypingAction } from "@/types/common";
4
+ export const WhatsAppTypingRequest = z.object({
5
+ /** Recipient's WhatsApp number. Must be in E.164 format */
6
+ to: E164PhoneNumber,
7
+ /** Your leased WhatsApp number. If none is provided, we will use a random WhatsApp number of yours */
8
+ from: OptionalSenderNumber,
9
+ /** Whether to start or stop sending typing indicators */
10
+ action: TypingAction
11
+ });
12
+ export const WhatsAppTypingResponse = z.object({
13
+ /** Status of the typing indicator */
14
+ status: z.string(),
15
+ });
16
+ // Using the new base response builder
17
+ export const WhatsAppTypingResponseBuilder = createResponse(WhatsAppTypingResponse);
18
+ /**
19
+ * Start or stop sending typing indicators over WhatsApp
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // Start typing indicator
24
+ * const response = await contiguity.whatsapp.typing({
25
+ * to: "+1234567890",
26
+ * action: "start"
27
+ * });
28
+ * console.log(`Typing status: ${response.status}`);
29
+ * ```
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * // Stop typing indicator with specific sender number
34
+ * const response = await contiguity.whatsapp.typing({
35
+ * to: "+1234567890",
36
+ * from: "+15555555555",
37
+ * action: "stop"
38
+ * });
39
+ * console.log(`Typing status: ${response.status}`);
40
+ * ```
41
+ */
42
+ export async function _whatsAppTyping(params) {
43
+ const validatedParams = WhatsAppTypingRequest.parse(params);
44
+ const response = await this.request("/send/whatsapp/typing", {
45
+ method: "POST",
46
+ body: JSON.stringify(validatedParams),
47
+ });
48
+ return this.parse({
49
+ response,
50
+ schemas: {
51
+ sdk: WhatsAppTypingResponse,
52
+ raw: WhatsAppTypingResponseBuilder.raw
53
+ }
54
+ });
55
+ }
@@ -0,0 +1,38 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Base response builder that automatically creates flattened and raw response types
4
+ * This eliminates the need to manually define *ResponseFlattened and *ResponseRaw for each service
5
+ */
6
+ export declare class BaseResponseBuilder<T extends z.ZodObject<any>> {
7
+ readonly schema: T;
8
+ constructor(schema: T);
9
+ get response(): T;
10
+ get flattened(): z.ZodObject<{
11
+ [x: string]: any;
12
+ }, z.core.$strip>;
13
+ get raw(): z.ZodObject<{
14
+ id: z.ZodString;
15
+ timestamp: z.ZodNumber;
16
+ api_version: z.ZodString;
17
+ object: z.ZodString;
18
+ data: T;
19
+ }, z.core.$strip>;
20
+ get all(): {
21
+ response: T;
22
+ flattened: z.ZodObject<{
23
+ [x: string]: any;
24
+ }, z.core.$strip>;
25
+ raw: z.ZodObject<{
26
+ id: z.ZodString;
27
+ timestamp: z.ZodNumber;
28
+ api_version: z.ZodString;
29
+ object: z.ZodString;
30
+ data: T;
31
+ }, z.core.$strip>;
32
+ };
33
+ }
34
+ export declare function createResponse<T extends z.ZodObject<any>>(schema: T): BaseResponseBuilder<T>;
35
+ export type BaseResponse<T extends BaseResponseBuilder<any>> = z.infer<T['response']>;
36
+ export type FlattenedResponse<T extends BaseResponseBuilder<any>> = z.infer<T['flattened']>;
37
+ export type RawResponse<T extends BaseResponseBuilder<any>> = z.infer<T['raw']>;
38
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/types/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;GAGG;AACH,qBAAa,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC;aAC3B,MAAM,EAAE,CAAC;gBAAT,MAAM,EAAE,CAAC;IAErC,IAAI,QAAQ,MAEX;IAED,IAAI,SAAS;;sBAEZ;IAED,IAAI,GAAG;;;;;;sBAIN;IAED,IAAI,GAAG;;;;;;;;;;;;MAMN;CACJ;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,0BAEnE;AAED,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;AACtF,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;AAC5F,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC"}