contiguity 0.0.3 → 0.0.4
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/fetch.d.ts +5 -10
- package/dist/client/fetch.d.ts.map +1 -1
- package/dist/client/fetch.js +13 -45
- package/dist/contiguity.d.ts +1 -1
- package/dist/contiguity.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -185
- package/dist/services/domains/delete.d.ts +0 -4
- package/dist/services/domains/delete.d.ts.map +1 -1
- package/dist/services/domains/delete.js +1 -7
- package/dist/services/domains/get.d.ts +0 -30
- package/dist/services/domains/get.d.ts.map +1 -1
- package/dist/services/domains/get.js +1 -7
- package/dist/services/domains/list.d.ts +0 -32
- package/dist/services/domains/list.d.ts.map +1 -1
- package/dist/services/domains/list.js +1 -11
- package/dist/services/domains/register.d.ts +0 -22
- package/dist/services/domains/register.d.ts.map +1 -1
- package/dist/services/domains/register.js +1 -7
- package/dist/services/email/send.d.ts +0 -3
- package/dist/services/email/send.d.ts.map +1 -1
- package/dist/services/email/send.js +1 -7
- package/dist/services/imessage/send.d.ts +0 -3
- package/dist/services/imessage/send.d.ts.map +1 -1
- package/dist/services/imessage/send.js +1 -7
- package/dist/services/imessage/typing.d.ts +0 -3
- package/dist/services/imessage/typing.d.ts.map +1 -1
- package/dist/services/imessage/typing.js +1 -7
- package/dist/services/lease/available.d.ts +0 -62
- package/dist/services/lease/available.d.ts.map +1 -1
- package/dist/services/lease/available.js +1 -7
- package/dist/services/lease/create.d.ts +0 -31
- package/dist/services/lease/create.d.ts.map +1 -1
- package/dist/services/lease/create.js +1 -7
- package/dist/services/lease/details.d.ts +0 -77
- package/dist/services/lease/details.d.ts.map +1 -1
- package/dist/services/lease/details.js +1 -7
- package/dist/services/lease/get.d.ts +0 -59
- package/dist/services/lease/get.d.ts.map +1 -1
- package/dist/services/lease/get.js +1 -7
- package/dist/services/lease/leased.d.ts +0 -80
- package/dist/services/lease/leased.d.ts.map +1 -1
- package/dist/services/lease/leased.js +1 -7
- package/dist/services/lease/terminate.d.ts +0 -10
- package/dist/services/lease/terminate.d.ts.map +1 -1
- package/dist/services/lease/terminate.js +1 -7
- package/dist/services/otp/index.d.ts +8 -3
- package/dist/services/otp/index.d.ts.map +1 -1
- package/dist/services/otp/index.js +9 -2
- package/dist/services/otp/resend.d.ts +0 -3
- package/dist/services/otp/resend.d.ts.map +1 -1
- package/dist/services/otp/resend.js +1 -7
- package/dist/services/otp/send.d.ts +26 -0
- package/dist/services/otp/send.d.ts.map +1 -0
- package/dist/services/otp/send.js +38 -0
- package/dist/services/otp/verify.d.ts +0 -3
- package/dist/services/otp/verify.d.ts.map +1 -1
- package/dist/services/otp/verify.js +1 -7
- package/dist/services/text/send.d.ts +0 -3
- package/dist/services/text/send.d.ts.map +1 -1
- package/dist/services/text/send.js +1 -7
- package/dist/services/whatsapp/send.d.ts +0 -3
- package/dist/services/whatsapp/send.d.ts.map +1 -1
- package/dist/services/whatsapp/send.js +1 -7
- package/dist/services/whatsapp/typing.d.ts +0 -3
- package/dist/services/whatsapp/typing.d.ts.map +1 -1
- package/dist/services/whatsapp/typing.js +1 -7
- package/dist/types/base.d.ts +2 -23
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/base.js +3 -15
- package/dist/types/response.d.ts +0 -7
- package/dist/types/response.d.ts.map +1 -1
- package/dist/types/response.js +0 -7
- package/package.json +1 -1
package/dist/client/fetch.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export interface ContiguityClientOptions {
|
|
3
|
-
raw?: boolean;
|
|
4
3
|
debug?: boolean;
|
|
5
4
|
}
|
|
6
5
|
/**
|
|
@@ -8,23 +7,19 @@ export interface ContiguityClientOptions {
|
|
|
8
7
|
*/
|
|
9
8
|
export declare class ContiguityClient {
|
|
10
9
|
protected readonly token: string;
|
|
11
|
-
protected readonly raw: boolean;
|
|
12
10
|
constructor(token: string, options?: ContiguityClientOptions);
|
|
13
11
|
/**
|
|
14
12
|
* Make an authenticated request to the Contiguity API
|
|
15
13
|
*/
|
|
16
14
|
request(endpoint: string, options?: RequestInit): Promise<any>;
|
|
17
15
|
/**
|
|
18
|
-
* Parse and normalize API responses to
|
|
19
|
-
* This method handles
|
|
20
|
-
*
|
|
16
|
+
* Parse and normalize API responses to flattened format with metadata
|
|
17
|
+
* This method handles different response formats from the Contiguity API
|
|
18
|
+
* and normalizes them to a consistent flattened format.
|
|
21
19
|
*/
|
|
22
|
-
parse<T extends z.ZodType
|
|
20
|
+
parse<T extends z.ZodType>({ response, schema }: {
|
|
23
21
|
response: any;
|
|
24
|
-
|
|
25
|
-
sdk: T;
|
|
26
|
-
raw: R;
|
|
27
|
-
};
|
|
22
|
+
schema: T;
|
|
28
23
|
}): any;
|
|
29
24
|
}
|
|
30
25
|
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/client/fetch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/client/fetch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,MAAM,WAAW,uBAAuB;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,gBAAgB;IACzB,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAErB,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B;IAYhE;;OAEG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,GAAG,CAAC;IAiDxE;;;;OAIG;IACH,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,EACvB,QAAQ,EACR,MAAM,EACT,EAAE;QACC,QAAQ,EAAE,GAAG,CAAC;QACd,MAAM,EAAE,CAAC,CAAC;KACb,GAAG,GAAG;CAeV"}
|
package/dist/client/fetch.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ContiguityRawResponse } from "@/types/response";
|
|
2
1
|
import { ContiguityAPIError, ContiguityError } from "@/types/error";
|
|
3
2
|
// year | month | version (monthly)
|
|
4
3
|
const LATEST_API_VERSION = "v2025.8.20";
|
|
@@ -8,7 +7,6 @@ const BASE_URL = "https://api.contiguity.com"; // "http://localhost:8080";
|
|
|
8
7
|
*/
|
|
9
8
|
export class ContiguityClient {
|
|
10
9
|
token;
|
|
11
|
-
raw;
|
|
12
10
|
constructor(token, options = {}) {
|
|
13
11
|
if (!token || typeof token !== 'string') {
|
|
14
12
|
throw new Error('API token is required and must be a string');
|
|
@@ -17,7 +15,6 @@ export class ContiguityClient {
|
|
|
17
15
|
throw new Error('API token cannot be empty');
|
|
18
16
|
}
|
|
19
17
|
this.token = token.trim();
|
|
20
|
-
this.raw = options.raw || false; // If true, return raw API responses
|
|
21
18
|
}
|
|
22
19
|
/**
|
|
23
20
|
* Make an authenticated request to the Contiguity API
|
|
@@ -56,19 +53,7 @@ export class ContiguityClient {
|
|
|
56
53
|
});
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
|
-
|
|
60
|
-
const result = ContiguityRawResponse.safeParse(data);
|
|
61
|
-
if (result.success) {
|
|
62
|
-
return result.data;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
throw new ContiguityError({
|
|
66
|
-
data: {
|
|
67
|
-
status: 500,
|
|
68
|
-
error: "Invalid response format from API",
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
56
|
+
return data;
|
|
72
57
|
}
|
|
73
58
|
catch (error) {
|
|
74
59
|
if (error instanceof ContiguityError) {
|
|
@@ -79,38 +64,21 @@ export class ContiguityClient {
|
|
|
79
64
|
}
|
|
80
65
|
}
|
|
81
66
|
/**
|
|
82
|
-
* Parse and normalize API responses to
|
|
83
|
-
* This method handles
|
|
84
|
-
*
|
|
67
|
+
* Parse and normalize API responses to flattened format with metadata
|
|
68
|
+
* This method handles different response formats from the Contiguity API
|
|
69
|
+
* and normalizes them to a consistent flattened format.
|
|
85
70
|
*/
|
|
86
|
-
parse({ response,
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
//
|
|
90
|
-
// 3. Fallback to raw parsing
|
|
91
|
-
const validatedResponse = response.object === "response"
|
|
92
|
-
? raw.parse(response)
|
|
93
|
-
: sdk.safeParse(response).success
|
|
94
|
-
? {
|
|
95
|
-
id: response.id || "unknown",
|
|
96
|
-
timestamp: response.timestamp || Date.now(),
|
|
97
|
-
api_version: response.api_version || "unknown",
|
|
98
|
-
object: response.object || "unknown",
|
|
99
|
-
data: sdk.parse(response),
|
|
100
|
-
}
|
|
101
|
-
: raw.parse(response);
|
|
102
|
-
if (this.raw) {
|
|
103
|
-
return validatedResponse;
|
|
104
|
-
}
|
|
105
|
-
// For flattened responses, we need to handle both formats
|
|
106
|
-
const rawData = raw.parse(validatedResponse);
|
|
71
|
+
parse({ response, schema }) {
|
|
72
|
+
// Parse the response data
|
|
73
|
+
const responseData = schema.parse(response);
|
|
74
|
+
// Return flattened response with metadata
|
|
107
75
|
return {
|
|
108
|
-
...
|
|
76
|
+
...(typeof responseData === 'object' && responseData !== null ? responseData : {}),
|
|
109
77
|
metadata: {
|
|
110
|
-
id:
|
|
111
|
-
timestamp:
|
|
112
|
-
api_version:
|
|
113
|
-
object:
|
|
78
|
+
id: response.id || "unknown",
|
|
79
|
+
timestamp: response.timestamp || Date.now(),
|
|
80
|
+
api_version: response.api_version || "unknown",
|
|
81
|
+
object: response.object || "unknown",
|
|
114
82
|
},
|
|
115
83
|
};
|
|
116
84
|
}
|
package/dist/contiguity.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ import { DomainsService } from "@/services/domains/index";
|
|
|
39
39
|
* });
|
|
40
40
|
*
|
|
41
41
|
* // Send and verify OTP
|
|
42
|
-
* const otpResponse = await contiguity.otp.
|
|
42
|
+
* const otpResponse = await contiguity.otp.send({
|
|
43
43
|
* to: "+1234567890",
|
|
44
44
|
* language: "en",
|
|
45
45
|
* name: "MyApp"
|
package/dist/contiguity.js
CHANGED
|
@@ -40,7 +40,7 @@ import { ContiguitySDKError } from "@/types/error";
|
|
|
40
40
|
* });
|
|
41
41
|
*
|
|
42
42
|
* // Send and verify OTP
|
|
43
|
-
* const otpResponse = await contiguity.otp.
|
|
43
|
+
* const otpResponse = await contiguity.otp.send({
|
|
44
44
|
* to: "+1234567890",
|
|
45
45
|
* language: "en",
|
|
46
46
|
* name: "MyApp"
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Contiguity } from "@/contiguity";
|
|
2
2
|
export { Contiguity };
|
|
3
|
-
export { ContiguityResponse
|
|
3
|
+
export { ContiguityResponse } from "@/types/response";
|
|
4
4
|
export { ContiguityAPIError, ContiguityError, ContiguitySDKError } from "@/types/error";
|
|
5
5
|
export type { ContiguityMetadata, WithMetadata } from "@/types/metadata";
|
|
6
|
-
export { createResponse, BaseResponseBuilder, type BaseResponse, type FlattenedResponse
|
|
6
|
+
export { createResponse, BaseResponseBuilder, type BaseResponse, type FlattenedResponse } from "@/types/base";
|
|
7
7
|
export { E164PhoneNumber, MessageContent, OptionalSenderNumber, AttachmentList, SingleOrMultipleEmails, TypingAction, NumberStatus, LeaseStatus, BillingMethod, Currency, Carrier, MessageChannel, createFallbackSchema } from "@/types/common";
|
|
8
8
|
export { TextSendRequest, TextResponse } from "@/services/text/send";
|
|
9
9
|
export { EmailSendRequest, EmailResponse } from "@/services/email/send";
|
|
@@ -17,7 +17,7 @@ export { LeaseCreateRequest, LeaseCreateResponse, LeaseBillingPrice, LeaseBillin
|
|
|
17
17
|
export { LeaseLeasedResponse, LeasedNumber, LeasedBillingPeriod, LeasedBilling } from "@/services/lease/leased";
|
|
18
18
|
export { LeaseDetailsRequest, LeaseDetailsResponse } from "@/services/lease/details";
|
|
19
19
|
export { LeaseTerminateRequest, LeaseTerminateResponse } from "@/services/lease/terminate";
|
|
20
|
-
export { OTPNewRequest, OTPNewResponse } from "@/services/otp/
|
|
20
|
+
export { OTPSendRequest, OTPSendResponse, OTPSendRequest as OTPNewRequest, OTPSendResponse as OTPNewResponse } from "@/services/otp/send";
|
|
21
21
|
export { OTPVerifyRequest, OTPVerifyResponse } from "@/services/otp/verify";
|
|
22
22
|
export { OTPResendRequest, OTPResendResponse } from "@/services/otp/resend";
|
|
23
23
|
export { DomainsListResponse, DomainInfo } from "@/services/domains/list";
|
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,cAAc,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxF,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC9G,OAAO,EACH,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,YAAY,EACZ,YA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