@pilot-status/sdk 0.1.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/README.md +75 -0
- package/dist/client.d.ts +16 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +24 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +55 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +67 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +20 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +116 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/analytics.d.ts +10 -0
- package/dist/resources/analytics.d.ts.map +1 -0
- package/dist/resources/analytics.js +14 -0
- package/dist/resources/analytics.js.map +1 -0
- package/dist/resources/messages.d.ts +9 -0
- package/dist/resources/messages.d.ts.map +1 -0
- package/dist/resources/messages.js +24 -0
- package/dist/resources/messages.js.map +1 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/webhooks/parse.d.ts +4 -0
- package/dist/webhooks/parse.d.ts.map +1 -0
- package/dist/webhooks/parse.js +69 -0
- package/dist/webhooks/parse.js.map +1 -0
- package/dist/webhooks/types.d.ts +57 -0
- package/dist/webhooks/types.d.ts.map +1 -0
- package/dist/webhooks/types.js +2 -0
- package/dist/webhooks/types.js.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @pilot-status/sdk
|
|
2
|
+
|
|
3
|
+
SDK oficial em TypeScript para consumir a API pública do Pilot Status.
|
|
4
|
+
|
|
5
|
+
## Instalação
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @pilot-status/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Uso (Node.js/TypeScript)
|
|
12
|
+
|
|
13
|
+
Crie uma API key no painel e use somente no backend.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { PilotStatusClient } from "@pilot-status/sdk";
|
|
17
|
+
|
|
18
|
+
const client = new PilotStatusClient({
|
|
19
|
+
apiKey: process.env.PILOT_STATUS_API_KEY!,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const accepted = await client.messages.send({
|
|
23
|
+
templateId: "onboarding-test",
|
|
24
|
+
destinationNumber: "+5511999999999",
|
|
25
|
+
variables: { name: "João" },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const message = await client.messages.get(accepted.id);
|
|
29
|
+
console.log(message.status);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Analytics
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const stats = await client.analytics.getDashboardStats({ tz: "America/Sao_Paulo" });
|
|
36
|
+
console.log(stats.totalSent, stats.failureRate);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Webhooks (parse/validação)
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { parseCustomerWebhook } from "@pilot-status/sdk";
|
|
43
|
+
|
|
44
|
+
export async function handler(req: Request) {
|
|
45
|
+
const payload = await req.json();
|
|
46
|
+
const event = parseCustomerWebhook(payload);
|
|
47
|
+
|
|
48
|
+
if (event.event === "message.failed") {
|
|
49
|
+
console.log(event.data.errorMessage);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return new Response("ok");
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Erros
|
|
57
|
+
|
|
58
|
+
Para respostas não-2xx, o SDK lança um erro HTTP com `status` e, quando disponível, `body`.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { PilotStatusHttpError } from "@pilot-status/sdk";
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
await client.messages.send({
|
|
65
|
+
templateId: "x",
|
|
66
|
+
destinationNumber: "+5511999999999",
|
|
67
|
+
variables: {},
|
|
68
|
+
});
|
|
69
|
+
} catch (err) {
|
|
70
|
+
if (err instanceof PilotStatusHttpError) {
|
|
71
|
+
console.log(err.status, err.body);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AnalyticsResource } from "./resources/analytics.js";
|
|
2
|
+
import { MessagesResource } from "./resources/messages.js";
|
|
3
|
+
import { type FetchLike } from "./http.js";
|
|
4
|
+
export type PilotStatusClientOptions = {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
userAgent?: string;
|
|
8
|
+
fetch?: FetchLike;
|
|
9
|
+
getRetries?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare class PilotStatusClient {
|
|
12
|
+
readonly messages: MessagesResource;
|
|
13
|
+
readonly analytics: AnalyticsResource;
|
|
14
|
+
constructor(options: PilotStatusClientOptions);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAE7D,MAAM,MAAM,wBAAwB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,qBAAa,iBAAiB;IAC1B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;gBAE1B,OAAO,EAAE,wBAAwB;CAsBhD"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AnalyticsResource } from "./resources/analytics.js";
|
|
2
|
+
import { MessagesResource } from "./resources/messages.js";
|
|
3
|
+
import { createHttpClient } from "./http.js";
|
|
4
|
+
export class PilotStatusClient {
|
|
5
|
+
messages;
|
|
6
|
+
analytics;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
9
|
+
if (!fetchImpl) {
|
|
10
|
+
throw new Error("fetch is not available in this runtime; pass { fetch } to PilotStatusClient");
|
|
11
|
+
}
|
|
12
|
+
const http = createHttpClient({
|
|
13
|
+
baseUrl: "https://pilotstatus.online",
|
|
14
|
+
apiKey: options.apiKey,
|
|
15
|
+
timeoutMs: options.timeoutMs ?? 30_000,
|
|
16
|
+
userAgent: options.userAgent,
|
|
17
|
+
fetch: fetchImpl,
|
|
18
|
+
getRetries: options.getRetries ?? 2,
|
|
19
|
+
});
|
|
20
|
+
this.messages = new MessagesResource(http);
|
|
21
|
+
this.analytics = new AnalyticsResource(http);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAkB,MAAM,WAAW,CAAC;AAU7D,MAAM,OAAO,iBAAiB;IACjB,QAAQ,CAAmB;IAC3B,SAAS,CAAoB;IAEtC,YAAY,OAAiC;QACzC,MAAM,SAAS,GACX,OAAO,CAAC,KAAK,IAAK,UAAkB,CAAC,KAAK,CAAC;QAE/C,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACX,6EAA6E,CAChF,CAAC;QACN,CAAC;QAED,MAAM,IAAI,GAAG,gBAAgB,CAAC;YAC1B,OAAO,EAAE,4BAA4B;YACrC,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,MAAM;YACtC,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,KAAK,EAAE,SAAS;YAChB,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC;SACtC,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACJ"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type PilotStatusErrorBody = {
|
|
2
|
+
error: string;
|
|
3
|
+
details?: unknown;
|
|
4
|
+
reason?: string;
|
|
5
|
+
code?: string;
|
|
6
|
+
state?: string;
|
|
7
|
+
} | unknown;
|
|
8
|
+
export declare class PilotStatusError extends Error {
|
|
9
|
+
name: string;
|
|
10
|
+
constructor(message: string, options?: {
|
|
11
|
+
cause?: unknown;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export declare class PilotStatusHttpError extends PilotStatusError {
|
|
15
|
+
name: string;
|
|
16
|
+
readonly status: number;
|
|
17
|
+
readonly method: string;
|
|
18
|
+
readonly url: string;
|
|
19
|
+
readonly body: PilotStatusErrorBody | undefined;
|
|
20
|
+
readonly rawBody: string | undefined;
|
|
21
|
+
readonly headers: Record<string, string>;
|
|
22
|
+
constructor(params: {
|
|
23
|
+
message: string;
|
|
24
|
+
status: number;
|
|
25
|
+
method: string;
|
|
26
|
+
url: string;
|
|
27
|
+
body?: PilotStatusErrorBody;
|
|
28
|
+
rawBody?: string;
|
|
29
|
+
headers: Record<string, string>;
|
|
30
|
+
cause?: unknown;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export declare class AuthenticationError extends PilotStatusHttpError {
|
|
34
|
+
name: string;
|
|
35
|
+
}
|
|
36
|
+
export declare class ValidationError extends PilotStatusHttpError {
|
|
37
|
+
name: string;
|
|
38
|
+
}
|
|
39
|
+
export declare class ForbiddenError extends PilotStatusHttpError {
|
|
40
|
+
name: string;
|
|
41
|
+
}
|
|
42
|
+
export declare class NotFoundError extends PilotStatusHttpError {
|
|
43
|
+
name: string;
|
|
44
|
+
}
|
|
45
|
+
export declare class ConflictError extends PilotStatusHttpError {
|
|
46
|
+
name: string;
|
|
47
|
+
}
|
|
48
|
+
export declare class RateLimitError extends PilotStatusHttpError {
|
|
49
|
+
name: string;
|
|
50
|
+
}
|
|
51
|
+
export declare class ServerError extends PilotStatusHttpError {
|
|
52
|
+
name: string;
|
|
53
|
+
}
|
|
54
|
+
export declare function createHttpError(params: ConstructorParameters<typeof PilotStatusHttpError>[0]): PilotStatusHttpError;
|
|
55
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAC1B;IACI,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB,GACD,OAAO,CAAC;AAEd,qBAAa,gBAAiB,SAAQ,KAAK;IAC9B,IAAI,EAAE,MAAM,CAAsB;gBAE/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAM7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AgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,wBAY5F"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export class PilotStatusError extends Error {
|
|
2
|
+
name = "PilotStatusError";
|
|
3
|
+
constructor(message, options) {
|
|
4
|
+
super(message);
|
|
5
|
+
if (options?.cause !== undefined) {
|
|
6
|
+
this.cause = options.cause;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class PilotStatusHttpError extends PilotStatusError {
|
|
11
|
+
name = "PilotStatusHttpError";
|
|
12
|
+
status;
|
|
13
|
+
method;
|
|
14
|
+
url;
|
|
15
|
+
body;
|
|
16
|
+
rawBody;
|
|
17
|
+
headers;
|
|
18
|
+
constructor(params) {
|
|
19
|
+
super(params.message, { cause: params.cause });
|
|
20
|
+
this.status = params.status;
|
|
21
|
+
this.method = params.method;
|
|
22
|
+
this.url = params.url;
|
|
23
|
+
this.body = params.body;
|
|
24
|
+
this.rawBody = params.rawBody;
|
|
25
|
+
this.headers = params.headers;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class AuthenticationError extends PilotStatusHttpError {
|
|
29
|
+
name = "AuthenticationError";
|
|
30
|
+
}
|
|
31
|
+
export class ValidationError extends PilotStatusHttpError {
|
|
32
|
+
name = "ValidationError";
|
|
33
|
+
}
|
|
34
|
+
export class ForbiddenError extends PilotStatusHttpError {
|
|
35
|
+
name = "ForbiddenError";
|
|
36
|
+
}
|
|
37
|
+
export class NotFoundError extends PilotStatusHttpError {
|
|
38
|
+
name = "NotFoundError";
|
|
39
|
+
}
|
|
40
|
+
export class ConflictError extends PilotStatusHttpError {
|
|
41
|
+
name = "ConflictError";
|
|
42
|
+
}
|
|
43
|
+
export class RateLimitError extends PilotStatusHttpError {
|
|
44
|
+
name = "RateLimitError";
|
|
45
|
+
}
|
|
46
|
+
export class ServerError extends PilotStatusHttpError {
|
|
47
|
+
name = "ServerError";
|
|
48
|
+
}
|
|
49
|
+
export function createHttpError(params) {
|
|
50
|
+
const status = params.status;
|
|
51
|
+
if (status === 401)
|
|
52
|
+
return new AuthenticationError(params);
|
|
53
|
+
if (status === 400)
|
|
54
|
+
return new ValidationError(params);
|
|
55
|
+
if (status === 403)
|
|
56
|
+
return new ForbiddenError(params);
|
|
57
|
+
if (status === 404)
|
|
58
|
+
return new NotFoundError(params);
|
|
59
|
+
if (status === 409)
|
|
60
|
+
return new ConflictError(params);
|
|
61
|
+
if (status === 429)
|
|
62
|
+
return new RateLimitError(params);
|
|
63
|
+
if (status >= 500)
|
|
64
|
+
return new ServerError(params);
|
|
65
|
+
return new PilotStatusHttpError(params);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAUA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAC9B,IAAI,GAAW,kBAAkB,CAAC;IAE3C,YAAY,OAAe,EAAE,OAA6B;QACtD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;YAC9B,IAA4B,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QACxD,CAAC;IACL,CAAC;CACJ;AAED,MAAM,OAAO,oBAAqB,SAAQ,gBAAgB;IAC7C,IAAI,GAAW,sBAAsB,CAAC;IAEtC,MAAM,CAAS;IACf,MAAM,CAAS;IACf,GAAG,CAAS;IACZ,IAAI,CAAmC;IACvC,OAAO,CAAqB;IAC5B,OAAO,CAAyB;IAEzC,YAAY,MASX;QACG,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CA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,CAAC,CAAC;IACrD,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;IACtD,IAAI,MAAM,IAAI,GAAG;QAAE,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IAElD,OAAO,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type FetchLike = typeof fetch;
|
|
2
|
+
export type HttpClientOptions = {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
apiKey: string;
|
|
5
|
+
timeoutMs: number;
|
|
6
|
+
userAgent?: string;
|
|
7
|
+
fetch: FetchLike;
|
|
8
|
+
getRetries: number;
|
|
9
|
+
};
|
|
10
|
+
export type HttpRequest = {
|
|
11
|
+
method: "GET" | "POST";
|
|
12
|
+
path: string;
|
|
13
|
+
query?: Record<string, string | number | boolean | undefined | null>;
|
|
14
|
+
body?: unknown;
|
|
15
|
+
};
|
|
16
|
+
export declare function createHttpClient(options: HttpClientOptions): {
|
|
17
|
+
requestJson: <T>(req: HttpRequest) => Promise<T>;
|
|
18
|
+
};
|
|
19
|
+
export type HttpClient = ReturnType<typeof createHttpClient>;
|
|
20
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC;AAErC,MAAM,MAAM,iBAAiB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACtB,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;IACrE,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AA+CF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB;kBAG5B,CAAC,OAAO,WAAW,KAAG,OAAO,CAAC,CAAC,CAAC;EA8E9D;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { createHttpError } from "./errors.js";
|
|
2
|
+
function normalizeBaseUrl(baseUrl) {
|
|
3
|
+
return baseUrl.replace(/\/+$/, "");
|
|
4
|
+
}
|
|
5
|
+
function joinUrl(baseUrl, path) {
|
|
6
|
+
const normalized = normalizeBaseUrl(baseUrl);
|
|
7
|
+
if (!path.startsWith("/"))
|
|
8
|
+
return `${normalized}/${path}`;
|
|
9
|
+
return `${normalized}${path}`;
|
|
10
|
+
}
|
|
11
|
+
function buildUrl(baseUrl, path, query) {
|
|
12
|
+
const url = new URL(joinUrl(baseUrl, path));
|
|
13
|
+
if (query) {
|
|
14
|
+
for (const [key, value] of Object.entries(query)) {
|
|
15
|
+
if (value === undefined || value === null)
|
|
16
|
+
continue;
|
|
17
|
+
url.searchParams.set(key, String(value));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return url.toString();
|
|
21
|
+
}
|
|
22
|
+
function headersToRecord(headers) {
|
|
23
|
+
const out = {};
|
|
24
|
+
headers.forEach((value, key) => {
|
|
25
|
+
out[key] = value;
|
|
26
|
+
});
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
function parseJsonIfPossible(text) {
|
|
30
|
+
const trimmed = text.trim();
|
|
31
|
+
if (!trimmed)
|
|
32
|
+
return undefined;
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(trimmed);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function shouldRetryRequest(method, status) {
|
|
41
|
+
if (method !== "GET")
|
|
42
|
+
return false;
|
|
43
|
+
if (status === undefined)
|
|
44
|
+
return true;
|
|
45
|
+
return status >= 500;
|
|
46
|
+
}
|
|
47
|
+
export function createHttpClient(options) {
|
|
48
|
+
const baseUrl = normalizeBaseUrl(options.baseUrl);
|
|
49
|
+
async function requestJson(req) {
|
|
50
|
+
const url = buildUrl(baseUrl, req.path, req.query);
|
|
51
|
+
const controller = new AbortController();
|
|
52
|
+
const timeout = setTimeout(() => controller.abort(), options.timeoutMs);
|
|
53
|
+
const headers = {
|
|
54
|
+
"x-api-key": options.apiKey,
|
|
55
|
+
Accept: "application/json",
|
|
56
|
+
};
|
|
57
|
+
if (options.userAgent) {
|
|
58
|
+
headers["user-agent"] = options.userAgent;
|
|
59
|
+
}
|
|
60
|
+
let body;
|
|
61
|
+
if (req.body !== undefined) {
|
|
62
|
+
headers["content-type"] = "application/json";
|
|
63
|
+
body = JSON.stringify(req.body);
|
|
64
|
+
}
|
|
65
|
+
const doFetch = async () => {
|
|
66
|
+
const res = await options.fetch(url, {
|
|
67
|
+
method: req.method,
|
|
68
|
+
headers,
|
|
69
|
+
body,
|
|
70
|
+
signal: controller.signal,
|
|
71
|
+
});
|
|
72
|
+
return res;
|
|
73
|
+
};
|
|
74
|
+
let attempt = 0;
|
|
75
|
+
const maxRetries = options.getRetries;
|
|
76
|
+
try {
|
|
77
|
+
while (true) {
|
|
78
|
+
try {
|
|
79
|
+
const res = await doFetch();
|
|
80
|
+
const raw = await res.text();
|
|
81
|
+
const parsed = parseJsonIfPossible(raw);
|
|
82
|
+
if (!res.ok) {
|
|
83
|
+
const message = typeof parsed?.error === "string"
|
|
84
|
+
? String(parsed.error)
|
|
85
|
+
: `HTTP ${res.status}`;
|
|
86
|
+
throw createHttpError({
|
|
87
|
+
message,
|
|
88
|
+
status: res.status,
|
|
89
|
+
method: req.method,
|
|
90
|
+
url,
|
|
91
|
+
body: parsed,
|
|
92
|
+
rawBody: raw || undefined,
|
|
93
|
+
headers: headersToRecord(res.headers),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return parsed;
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
if (attempt >= maxRetries ||
|
|
100
|
+
!(err instanceof Error) ||
|
|
101
|
+
!shouldRetryRequest(req.method, err?.status)) {
|
|
102
|
+
throw err;
|
|
103
|
+
}
|
|
104
|
+
const backoffMs = 250 * Math.pow(2, attempt);
|
|
105
|
+
await new Promise((r) => setTimeout(r, backoffMs));
|
|
106
|
+
attempt += 1;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
clearTimeout(timeout);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return { requestJson };
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAoB9C,SAAS,gBAAgB,CAAC,OAAe;IACrC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,OAAO,CAAC,OAAe,EAAE,IAAY;IAC1C,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC7C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG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,EAAE,SAAS,CAAC,CAAC,CAAC;oBACnD,OAAO,IAAI,CAAC,CAAC;gBACjB,CAAC;YACL,CAAC;QACL,CAAC;gBAAS,CAAC;YACP,YAAY,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;IACL,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,CAAC;AAC3B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { PilotStatusClient } from "./client.js";
|
|
2
|
+
export type { PilotStatusClientOptions } from "./client.js";
|
|
3
|
+
export { PilotStatusError, PilotStatusHttpError, AuthenticationError, ValidationError, ForbiddenError, NotFoundError, ConflictError, RateLimitError, ServerError, } from "./errors.js";
|
|
4
|
+
export type { PilotStatusErrorBody } from "./errors.js";
|
|
5
|
+
export type { Environment, MessageStatus, SendMessageInput, SendMessageAccepted, MessageDetails, DashboardStats, } from "./types.js";
|
|
6
|
+
export type { CustomerWebhookEvent, MessageSentEvent, MessageReadEvent, MessageFailedEvent, MessageReplyEvent, } from "./webhooks/types.js";
|
|
7
|
+
export { parseCustomerWebhook, isCustomerWebhookEvent } from "./webhooks/parse.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EACH,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,YAAY,EACR,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,cAAc,GACjB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACR,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { PilotStatusClient } from "./client.js";
|
|
2
|
+
export { PilotStatusError, PilotStatusHttpError, AuthenticationError, ValidationError, ForbiddenError, NotFoundError, ConflictError, RateLimitError, ServerError, } from "./errors.js";
|
|
3
|
+
export { parseCustomerWebhook, isCustomerWebhookEvent } from "./webhooks/parse.js";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,EACH,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,GACd,MAAM,aAAa,CAAC;AAmBrB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HttpClient } from "../http.js";
|
|
2
|
+
import type { DashboardStats } from "../types.js";
|
|
3
|
+
export declare class AnalyticsResource {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
getDashboardStats(params?: {
|
|
7
|
+
tz?: string;
|
|
8
|
+
}): Promise<DashboardStats>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=analytics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/resources/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,qBAAa,iBAAiB;;gBAGd,IAAI,EAAE,UAAU;IAItB,iBAAiB,CAAC,MAAM,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;CAO7E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class AnalyticsResource {
|
|
2
|
+
#http;
|
|
3
|
+
constructor(http) {
|
|
4
|
+
this.#http = http;
|
|
5
|
+
}
|
|
6
|
+
async getDashboardStats(params) {
|
|
7
|
+
return this.#http.requestJson({
|
|
8
|
+
method: "GET",
|
|
9
|
+
path: "/api/v1/analytics/dashboard",
|
|
10
|
+
query: { tz: params?.tz },
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=analytics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../src/resources/analytics.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,iBAAiB;IACjB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,MAAwB;QAC5C,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAiB;YAC1C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,6BAA6B;YACnC,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;SAC5B,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HttpClient } from "../http.js";
|
|
2
|
+
import type { MessageDetails, SendMessageAccepted, SendMessageInput } from "../types.js";
|
|
3
|
+
export declare class MessagesResource {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
send(input: SendMessageInput): Promise<SendMessageAccepted>;
|
|
7
|
+
get(id: string): Promise<MessageDetails>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/resources/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEzF,qBAAa,gBAAgB;;gBAGb,IAAI,EAAE,UAAU;IAItB,IAAI,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAY3D,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;CAMjD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class MessagesResource {
|
|
2
|
+
#http;
|
|
3
|
+
constructor(http) {
|
|
4
|
+
this.#http = http;
|
|
5
|
+
}
|
|
6
|
+
async send(input) {
|
|
7
|
+
return this.#http.requestJson({
|
|
8
|
+
method: "POST",
|
|
9
|
+
path: "/api/v1/messages/send",
|
|
10
|
+
body: {
|
|
11
|
+
templateId: input.templateId,
|
|
12
|
+
destinationNumber: input.destinationNumber,
|
|
13
|
+
variables: input.variables ?? {},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
async get(id) {
|
|
18
|
+
return this.#http.requestJson({
|
|
19
|
+
method: "GET",
|
|
20
|
+
path: `/api/v1/messages/${encodeURIComponent(id)}`,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/resources/messages.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,gBAAgB;IAChB,KAAK,CAAa;IAE3B,YAAY,IAAgB;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAuB;QAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAsB;YAC/C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,uBAAuB;YAC7B,IAAI,EAAE;gBACF,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;gBAC1C,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,EAAE;aACnC;SACJ,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAiB;YAC1C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,oBAAoB,kBAAkB,CAAC,EAAE,CAAC,EAAE;SACrD,CAAC,CAAC;IACP,CAAC;CACJ"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type Environment = "TEST" | "LIVE";
|
|
2
|
+
export type MessageStatus = "QUEUED" | "SENT" | "FAILED" | "READ";
|
|
3
|
+
export type SendMessageInput = {
|
|
4
|
+
templateId: string;
|
|
5
|
+
destinationNumber: string;
|
|
6
|
+
variables?: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
export type SendMessageAccepted = {
|
|
9
|
+
id: string;
|
|
10
|
+
correlationId: string;
|
|
11
|
+
status: MessageStatus;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
origin: string;
|
|
14
|
+
};
|
|
15
|
+
export type MessageDetails = {
|
|
16
|
+
id: string;
|
|
17
|
+
status: MessageStatus;
|
|
18
|
+
correlationId: string;
|
|
19
|
+
destinationNumber: string;
|
|
20
|
+
template: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
sentAt: string | null;
|
|
23
|
+
readAt: string | null;
|
|
24
|
+
errorMessage: string | null;
|
|
25
|
+
};
|
|
26
|
+
export type DashboardStats = {
|
|
27
|
+
totalSent: number;
|
|
28
|
+
totalFailed: number;
|
|
29
|
+
sentPercentChange: number;
|
|
30
|
+
failedPercentChange: number;
|
|
31
|
+
failureRate: number;
|
|
32
|
+
dailyMessages: Array<{
|
|
33
|
+
date: string;
|
|
34
|
+
count: number;
|
|
35
|
+
}>;
|
|
36
|
+
statusDistribution: {
|
|
37
|
+
queued: number;
|
|
38
|
+
sent: number;
|
|
39
|
+
failed: number;
|
|
40
|
+
read: number;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1C,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,aAAa,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,kBAAkB,EAAE;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KAChB,CAAC;CACL,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CustomerWebhookEvent } from "./types.js";
|
|
2
|
+
export declare function parseCustomerWebhook(payload: unknown): CustomerWebhookEvent;
|
|
3
|
+
export declare function isCustomerWebhookEvent(payload: unknown): payload is CustomerWebhookEvent;
|
|
4
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/webhooks/parse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAqEvD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,oBAAoB,CAE3E;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,oBAAoB,CAExF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const environmentSchema = z.union([z.literal("TEST"), z.literal("LIVE")]);
|
|
3
|
+
const messageSentSchema = z.object({
|
|
4
|
+
event: z.literal("message.sent"),
|
|
5
|
+
data: z.object({
|
|
6
|
+
messageId: z.string(),
|
|
7
|
+
correlationId: z.string(),
|
|
8
|
+
environment: environmentSchema,
|
|
9
|
+
destinationNumber: z.string(),
|
|
10
|
+
projectSlug: z.string(),
|
|
11
|
+
content: z.string(),
|
|
12
|
+
status: z.literal("SENT"),
|
|
13
|
+
sentAt: z.string(),
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
const messageReadSchema = z.object({
|
|
17
|
+
event: z.literal("message.read"),
|
|
18
|
+
data: z.object({
|
|
19
|
+
messageId: z.string(),
|
|
20
|
+
correlationId: z.string(),
|
|
21
|
+
environment: environmentSchema,
|
|
22
|
+
destinationNumber: z.string(),
|
|
23
|
+
projectSlug: z.string(),
|
|
24
|
+
content: z.string(),
|
|
25
|
+
status: z.literal("READ"),
|
|
26
|
+
readAt: z.string(),
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
const messageFailedSchema = z.object({
|
|
30
|
+
event: z.literal("message.failed"),
|
|
31
|
+
data: z.object({
|
|
32
|
+
messageId: z.string(),
|
|
33
|
+
correlationId: z.string(),
|
|
34
|
+
environment: environmentSchema,
|
|
35
|
+
destinationNumber: z.string(),
|
|
36
|
+
projectSlug: z.string(),
|
|
37
|
+
content: z.string(),
|
|
38
|
+
status: z.literal("FAILED"),
|
|
39
|
+
failedAt: z.string(),
|
|
40
|
+
errorMessage: z.string(),
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
const messageReplySchema = z.object({
|
|
44
|
+
event: z.literal("message.reply"),
|
|
45
|
+
data: z.object({
|
|
46
|
+
from: z.string(),
|
|
47
|
+
destinationNumber: z.string(),
|
|
48
|
+
projectSlug: z.string(),
|
|
49
|
+
content: z.string(),
|
|
50
|
+
replyContent: z.string(),
|
|
51
|
+
receivedAt: z.string(),
|
|
52
|
+
lastMessageId: z.string(),
|
|
53
|
+
correlationId: z.string(),
|
|
54
|
+
environment: environmentSchema,
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
const customerWebhookEventSchema = z.discriminatedUnion("event", [
|
|
58
|
+
messageSentSchema,
|
|
59
|
+
messageReadSchema,
|
|
60
|
+
messageFailedSchema,
|
|
61
|
+
messageReplySchema,
|
|
62
|
+
]);
|
|
63
|
+
export function parseCustomerWebhook(payload) {
|
|
64
|
+
return customerWebhookEventSchema.parse(payload);
|
|
65
|
+
}
|
|
66
|
+
export function isCustomerWebhookEvent(payload) {
|
|
67
|
+
return customerWebhookEventSchema.safeParse(payload).success;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/webhooks/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAE1E,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;QACX,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;QACzB,WAAW,EAAE,iBAAiB;QAC9B,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE;QAC7B,WAAW,EAAE,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AAE;KAC3B,CAAC;CACL,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;QACX,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE;QAC7B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;QACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;QACxB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;QACtB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;QACzB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;QACzB,WAAW,EAAE,iBAAiB;KACjC,CAAC;CACL,CAAC,CAAC;AAEH,MAAM,0BAA0B,GAAG,CAAC,CAAC,kBAAkB,CAAC,OAAO,EAAE;IAC7D,iBAAiB;IACjB,iBAAiB;IACjB,mBAAmB;IACnB,kBAAkB;CACrB,CAAC,CAAC;AAEH,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACjD,OAAO,0BAA0B,CAAC,KAAK,CAAC,OAAO,CAAyB,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACnD,OAAO,0BAA0B,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Environment, MessageStatus } from "../types.js";
|
|
2
|
+
export type MessageSentEvent = {
|
|
3
|
+
event: "message.sent";
|
|
4
|
+
data: {
|
|
5
|
+
messageId: string;
|
|
6
|
+
correlationId: string;
|
|
7
|
+
environment: Environment;
|
|
8
|
+
destinationNumber: string;
|
|
9
|
+
projectSlug: string;
|
|
10
|
+
content: string;
|
|
11
|
+
status: Extract<MessageStatus, "SENT">;
|
|
12
|
+
sentAt: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export type MessageReadEvent = {
|
|
16
|
+
event: "message.read";
|
|
17
|
+
data: {
|
|
18
|
+
messageId: string;
|
|
19
|
+
correlationId: string;
|
|
20
|
+
environment: Environment;
|
|
21
|
+
destinationNumber: string;
|
|
22
|
+
projectSlug: string;
|
|
23
|
+
content: string;
|
|
24
|
+
status: Extract<MessageStatus, "READ">;
|
|
25
|
+
readAt: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type MessageFailedEvent = {
|
|
29
|
+
event: "message.failed";
|
|
30
|
+
data: {
|
|
31
|
+
messageId: string;
|
|
32
|
+
correlationId: string;
|
|
33
|
+
environment: Environment;
|
|
34
|
+
destinationNumber: string;
|
|
35
|
+
projectSlug: string;
|
|
36
|
+
content: string;
|
|
37
|
+
status: Extract<MessageStatus, "FAILED">;
|
|
38
|
+
failedAt: string;
|
|
39
|
+
errorMessage: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export type MessageReplyEvent = {
|
|
43
|
+
event: "message.reply";
|
|
44
|
+
data: {
|
|
45
|
+
from: string;
|
|
46
|
+
destinationNumber: string;
|
|
47
|
+
projectSlug: string;
|
|
48
|
+
content: string;
|
|
49
|
+
replyContent: string;
|
|
50
|
+
receivedAt: string;
|
|
51
|
+
lastMessageId: string;
|
|
52
|
+
correlationId: string;
|
|
53
|
+
environment: Environment;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export type CustomerWebhookEvent = MessageSentEvent | MessageReadEvent | MessageFailedEvent | MessageReplyEvent;
|
|
57
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE9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B,IAAI,EAAE;QACF,IAAI,EAAE,MAAM,CAAC;QACb,iBAAiB,EAAE,MAAM,CAAC;QAC1B,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,WAAW,CAAC;KAC5B,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC1B,gBAAgB,GAChB,gBAAgB,GAChB,kBAAkB,GAClB,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pilot-status/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official TypeScript SDK for the Pilot Status public API.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/pilot-status/pilot-status.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://pilotstatus.online",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/pilot-status/pilot-status/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"pilot-status",
|
|
29
|
+
"whatsapp",
|
|
30
|
+
"api",
|
|
31
|
+
"sdk",
|
|
32
|
+
"typescript"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.json",
|
|
36
|
+
"prepublishOnly": "npm run build"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18.0.0"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"zod": "^3.23.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"typescript": "^5.6.0"
|
|
49
|
+
}
|
|
50
|
+
}
|