@agenus-io/webhook-centralizer 1.0.2 → 1.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/Class/interface.d.ts +1 -0
- package/dist/Schema/index.d.ts +73 -0
- package/dist/Schema/index.js +33 -0
- package/dist/Utils/zod.d.ts +12 -0
- package/dist/Utils/zod.js +59 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +6 -34
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -1
- package/package.json +7 -2
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export declare const WebhookCentralizerCreatePlatformSchema: import("zod").ZodObject<{
|
|
2
|
+
title: import("zod").ZodString;
|
|
3
|
+
platformToken: import("zod").ZodOptional<import("zod").ZodString>;
|
|
4
|
+
dispatchType: import("zod").ZodDefault<import("zod").ZodNativeEnum<Record<import("../types").webhookCentralizerDispatchType, import("../types").webhookCentralizerDispatchType>>>;
|
|
5
|
+
type: import("zod").ZodNativeEnum<Record<import("../types").webhookCentralizerPlatform, import("../types").webhookCentralizerPlatform>>;
|
|
6
|
+
apiToken: import("zod").ZodOptional<import("zod").ZodString>;
|
|
7
|
+
slug: import("zod").ZodOptional<import("zod").ZodString>;
|
|
8
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
9
|
+
title: string;
|
|
10
|
+
dispatchType: import("../types").webhookCentralizerDispatchType;
|
|
11
|
+
type: import("../types").webhookCentralizerPlatform;
|
|
12
|
+
platformToken?: string | undefined;
|
|
13
|
+
apiToken?: string | undefined;
|
|
14
|
+
slug?: string | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
title: string;
|
|
17
|
+
type: import("../types").webhookCentralizerPlatform;
|
|
18
|
+
platformToken?: string | undefined;
|
|
19
|
+
dispatchType?: import("../types").webhookCentralizerDispatchType | undefined;
|
|
20
|
+
apiToken?: string | undefined;
|
|
21
|
+
slug?: string | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const WebhookCentralizerUpdatePlatformSchema: import("zod").ZodObject<{
|
|
24
|
+
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
25
|
+
platformToken: import("zod").ZodOptional<import("zod").ZodString>;
|
|
26
|
+
dispatchType: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNativeEnum<Record<import("../types").webhookCentralizerDispatchType, import("../types").webhookCentralizerDispatchType>>>>;
|
|
27
|
+
type: import("zod").ZodOptional<import("zod").ZodNativeEnum<Record<import("../types").webhookCentralizerPlatform, import("../types").webhookCentralizerPlatform>>>;
|
|
28
|
+
apiToken: import("zod").ZodOptional<import("zod").ZodString>;
|
|
29
|
+
slug: import("zod").ZodOptional<import("zod").ZodOptional<import("zod").ZodString>>;
|
|
30
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
31
|
+
title?: string | undefined;
|
|
32
|
+
platformToken?: string | undefined;
|
|
33
|
+
dispatchType?: import("../types").webhookCentralizerDispatchType | undefined;
|
|
34
|
+
type?: import("../types").webhookCentralizerPlatform | undefined;
|
|
35
|
+
apiToken?: string | undefined;
|
|
36
|
+
slug?: string | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
title?: string | undefined;
|
|
39
|
+
platformToken?: string | undefined;
|
|
40
|
+
dispatchType?: import("../types").webhookCentralizerDispatchType | undefined;
|
|
41
|
+
type?: import("../types").webhookCentralizerPlatform | undefined;
|
|
42
|
+
apiToken?: string | undefined;
|
|
43
|
+
slug?: string | undefined;
|
|
44
|
+
}>;
|
|
45
|
+
export declare const WebhookCentralizerGetPlatformsSchema: import("zod").ZodObject<{
|
|
46
|
+
page: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
47
|
+
pageSize: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
48
|
+
filter: import("zod").ZodOptional<import("zod").ZodString>;
|
|
49
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
50
|
+
page: number;
|
|
51
|
+
pageSize: number;
|
|
52
|
+
filter?: string | undefined;
|
|
53
|
+
}, {
|
|
54
|
+
page?: number | undefined;
|
|
55
|
+
pageSize?: number | undefined;
|
|
56
|
+
filter?: string | undefined;
|
|
57
|
+
}>;
|
|
58
|
+
export declare const WebhookCentralizerGetPlatformWebhooksSchema: import("zod").ZodObject<{
|
|
59
|
+
page: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
60
|
+
status: import("zod").ZodOptional<import("zod").ZodNativeEnum<Record<import("../types").webhookCentralizerOrderStatus, import("../types").webhookCentralizerOrderStatus>>>;
|
|
61
|
+
pageSize: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
62
|
+
filter: import("zod").ZodOptional<import("zod").ZodString>;
|
|
63
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
64
|
+
page: number;
|
|
65
|
+
pageSize: number;
|
|
66
|
+
filter?: string | undefined;
|
|
67
|
+
status?: import("../types").webhookCentralizerOrderStatus | undefined;
|
|
68
|
+
}, {
|
|
69
|
+
page?: number | undefined;
|
|
70
|
+
pageSize?: number | undefined;
|
|
71
|
+
filter?: string | undefined;
|
|
72
|
+
status?: import("../types").webhookCentralizerOrderStatus | undefined;
|
|
73
|
+
}>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebhookCentralizerGetPlatformWebhooksSchema = exports.WebhookCentralizerGetPlatformsSchema = exports.WebhookCentralizerUpdatePlatformSchema = exports.WebhookCentralizerCreatePlatformSchema = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const zod_1 = require("../Utils/zod");
|
|
7
|
+
exports.WebhookCentralizerCreatePlatformSchema = config_1.zod.object({
|
|
8
|
+
title: (0, zod_1.stringField)().min(3),
|
|
9
|
+
platformToken: (0, zod_1.stringField)().optional(),
|
|
10
|
+
dispatchType: (0, zod_1.nativeEnumField)(types_1.WebhookCentralizerDispatchTypeEnum).default("WEBHOOK"),
|
|
11
|
+
type: (0, zod_1.nativeEnumField)(types_1.WebhookCentralizerPlatformEnum),
|
|
12
|
+
apiToken: (0, zod_1.stringField)().optional(),
|
|
13
|
+
slug: (0, zod_1.stringField)().optional(),
|
|
14
|
+
});
|
|
15
|
+
exports.WebhookCentralizerUpdatePlatformSchema = config_1.zod.object({
|
|
16
|
+
title: (0, zod_1.stringField)().min(3).optional(),
|
|
17
|
+
platformToken: (0, zod_1.stringField)().optional(),
|
|
18
|
+
dispatchType: (0, zod_1.nativeEnumField)(types_1.WebhookCentralizerDispatchTypeEnum).default("WEBHOOK").optional(),
|
|
19
|
+
type: (0, zod_1.nativeEnumField)(types_1.WebhookCentralizerPlatformEnum).optional(),
|
|
20
|
+
apiToken: (0, zod_1.stringField)().optional(),
|
|
21
|
+
slug: (0, zod_1.stringField)().optional().optional(),
|
|
22
|
+
});
|
|
23
|
+
exports.WebhookCentralizerGetPlatformsSchema = config_1.zod.object({
|
|
24
|
+
page: (0, zod_1.numberField)().default(1),
|
|
25
|
+
pageSize: (0, zod_1.numberField)().default(10),
|
|
26
|
+
filter: (0, zod_1.stringField)().optional(),
|
|
27
|
+
});
|
|
28
|
+
exports.WebhookCentralizerGetPlatformWebhooksSchema = config_1.zod.object({
|
|
29
|
+
page: (0, zod_1.numberField)().default(1),
|
|
30
|
+
status: (0, zod_1.nativeEnumField)(types_1.WebhookCentralizerStatusEnum).optional(),
|
|
31
|
+
pageSize: (0, zod_1.numberField)().default(10),
|
|
32
|
+
filter: (0, zod_1.stringField)().optional(),
|
|
33
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ZodRawShape, ZodTypeAny, z } from "zod";
|
|
2
|
+
export declare const stringField: () => z.ZodString;
|
|
3
|
+
export declare const booleanField: () => z.ZodEffects<z.ZodBoolean, boolean, unknown>;
|
|
4
|
+
export declare const numberField: () => z.ZodNumber;
|
|
5
|
+
export declare const dateField: () => z.ZodDate;
|
|
6
|
+
export declare const objectField: <T extends ZodRawShape>(schema: T) => z.ZodEffects<z.ZodObject<T, "strip", ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_3 ? { [k in keyof T_3]: T_3[k]; } : never, unknown>;
|
|
7
|
+
export declare const startDateField: () => z.ZodEffects<z.ZodDate, Date, Date>;
|
|
8
|
+
export declare const endDateField: () => z.ZodEffects<z.ZodDate, Date, Date>;
|
|
9
|
+
export declare const nativeEnumField: <T extends z.EnumLike>(values: T) => z.ZodNativeEnum<T>;
|
|
10
|
+
export declare const enumField: <U extends string, T extends Readonly<[U, ...U[]]>>(values: T) => z.ZodEnum<z.Writeable<T>>;
|
|
11
|
+
export declare const arrayField: <T extends ZodTypeAny>(schema: T) => z.ZodEffects<z.ZodArray<T, "many">, T["_output"][], unknown>;
|
|
12
|
+
export declare const formDataField: <T extends ZodTypeAny>(schema: T) => z.ZodEffects<T, T["_output"], unknown>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.formDataField = exports.arrayField = exports.enumField = exports.nativeEnumField = exports.endDateField = exports.startDateField = exports.objectField = exports.dateField = exports.numberField = exports.booleanField = exports.stringField = void 0;
|
|
7
|
+
const config_1 = require("../config");
|
|
8
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
9
|
+
// funcionam tanto em um body/json, multipart-formdata, query params
|
|
10
|
+
const stringField = () => config_1.zod.string().trim();
|
|
11
|
+
exports.stringField = stringField;
|
|
12
|
+
const booleanField = () => config_1.zod.preprocess((value) => {
|
|
13
|
+
if (value === "true")
|
|
14
|
+
return true;
|
|
15
|
+
if (value === "false")
|
|
16
|
+
return false;
|
|
17
|
+
return value;
|
|
18
|
+
}, config_1.zod.boolean());
|
|
19
|
+
exports.booleanField = booleanField;
|
|
20
|
+
const numberField = () => config_1.zod.coerce.number();
|
|
21
|
+
exports.numberField = numberField;
|
|
22
|
+
const dateField = () => config_1.zod.coerce.date();
|
|
23
|
+
exports.dateField = dateField;
|
|
24
|
+
const objectField = (schema) => config_1.zod.preprocess((value) => {
|
|
25
|
+
if (typeof value === "string") {
|
|
26
|
+
try {
|
|
27
|
+
return JSON.parse(value.replace(/([a-zA-Z0-9_]+):/g, '"$1":'));
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
throw new Error("Formato de objeto inválido");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}, config_1.zod.object(schema));
|
|
35
|
+
exports.objectField = objectField;
|
|
36
|
+
const startDateField = () => config_1.zod.coerce.date().transform((date) => (0, dayjs_1.default)(date).startOf("day").add(1, "day").toDate());
|
|
37
|
+
exports.startDateField = startDateField;
|
|
38
|
+
const endDateField = () => config_1.zod.coerce.date().transform((date) => (0, dayjs_1.default)(date).endOf("day").add(1, "day").toDate());
|
|
39
|
+
exports.endDateField = endDateField;
|
|
40
|
+
const nativeEnumField = (values) => config_1.zod.nativeEnum(values);
|
|
41
|
+
exports.nativeEnumField = nativeEnumField;
|
|
42
|
+
const enumField = (values) => config_1.zod.enum(values);
|
|
43
|
+
exports.enumField = enumField;
|
|
44
|
+
const arrayField = (schema) => config_1.zod.preprocess((value) => {
|
|
45
|
+
if (typeof value === "string") {
|
|
46
|
+
return value.split(",");
|
|
47
|
+
}
|
|
48
|
+
return value;
|
|
49
|
+
}, config_1.zod.array(schema));
|
|
50
|
+
exports.arrayField = arrayField;
|
|
51
|
+
const formDataField = (schema) => config_1.zod
|
|
52
|
+
.preprocess((value) => {
|
|
53
|
+
if (typeof value === "string") {
|
|
54
|
+
return JSON.parse(value);
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
}, schema)
|
|
58
|
+
.describe("Enviar como JSON");
|
|
59
|
+
exports.formDataField = formDataField;
|
package/dist/config.d.ts
CHANGED
package/dist/config.js
CHANGED
|
@@ -1,35 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// * Região AWS onde a fila SQS está localizada
|
|
9
|
-
// * Exemplo: "us-east-1", "sa-east-1"
|
|
10
|
-
// */
|
|
11
|
-
// region: string;
|
|
12
|
-
// /**
|
|
13
|
-
// * Access Key ID da AWS
|
|
14
|
-
// */
|
|
15
|
-
// accessKeyId: string;
|
|
16
|
-
// /**
|
|
17
|
-
// * Secret Access Key da AWS
|
|
18
|
-
// */
|
|
19
|
-
// secretAccessKey: string;
|
|
20
|
-
// /**
|
|
21
|
-
// * URL da fila SQS
|
|
22
|
-
// * Exemplo: "https://sqs.us-east-1.amazonaws.com/123456789012/my-queue"
|
|
23
|
-
// */
|
|
24
|
-
// queueUrl: string;
|
|
25
|
-
// }
|
|
26
|
-
// /**
|
|
27
|
-
// * Parâmetros para processamento de webhook de pagamento
|
|
28
|
-
// */
|
|
29
|
-
// export interface SendSaleParams {
|
|
30
|
-
// /**
|
|
31
|
-
// * Dados do webhook de pagamento a serem processados
|
|
32
|
-
// */
|
|
33
|
-
// workspaceId: string;
|
|
34
|
-
// order: Order;
|
|
35
|
-
// }
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zod = void 0;
|
|
4
|
+
const zod_to_openapi_1 = require("@asteasolutions/zod-to-openapi");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
(0, zod_to_openapi_1.extendZodWithOpenApi)(zod_1.z);
|
|
7
|
+
exports.zod = zod_1.z;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,3 +6,4 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { WebhookCentralizerSDK } from "./Class";
|
|
8
8
|
export type { webhookCentralizerDispatchType, webhookCentralizerPlatform, webhookCentralizerOrderStatus, WebhookCentralizerDispatchTypeEnum, WebhookCentralizerPlatformEnum, WebhookCentralizerStatusEnum, } from "./types";
|
|
9
|
+
export { WebhookCentralizerGetPlatformWebhooksSchema, WebhookCentralizerCreatePlatformSchema, WebhookCentralizerUpdatePlatformSchema, WebhookCentralizerGetPlatformsSchema, } from "./Schema";
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
* webhooks de plataformas de pagamento através de uma fila AWS SQS.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.WebhookCentralizerSDK = void 0;
|
|
9
|
+
exports.WebhookCentralizerGetPlatformsSchema = exports.WebhookCentralizerUpdatePlatformSchema = exports.WebhookCentralizerCreatePlatformSchema = exports.WebhookCentralizerGetPlatformWebhooksSchema = exports.WebhookCentralizerSDK = void 0;
|
|
10
10
|
var Class_1 = require("./Class");
|
|
11
11
|
Object.defineProperty(exports, "WebhookCentralizerSDK", { enumerable: true, get: function () { return Class_1.WebhookCentralizerSDK; } });
|
|
12
|
+
var Schema_1 = require("./Schema");
|
|
13
|
+
Object.defineProperty(exports, "WebhookCentralizerGetPlatformWebhooksSchema", { enumerable: true, get: function () { return Schema_1.WebhookCentralizerGetPlatformWebhooksSchema; } });
|
|
14
|
+
Object.defineProperty(exports, "WebhookCentralizerCreatePlatformSchema", { enumerable: true, get: function () { return Schema_1.WebhookCentralizerCreatePlatformSchema; } });
|
|
15
|
+
Object.defineProperty(exports, "WebhookCentralizerUpdatePlatformSchema", { enumerable: true, get: function () { return Schema_1.WebhookCentralizerUpdatePlatformSchema; } });
|
|
16
|
+
Object.defineProperty(exports, "WebhookCentralizerGetPlatformsSchema", { enumerable: true, get: function () { return Schema_1.WebhookCentralizerGetPlatformsSchema; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agenus-io/webhook-centralizer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "SDK para centralização de webhooks focado atualmente em plataformas de pagamentos",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,8 +18,13 @@
|
|
|
18
18
|
"email": "davidpimanta@gmail.com",
|
|
19
19
|
"license": "ISC",
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"@asteasolutions/zod-to-openapi": "^7.3.0",
|
|
21
22
|
"aws-sdk": "^2.1692.0",
|
|
22
|
-
"axios": "^1.13.2"
|
|
23
|
+
"axios": "^1.13.2",
|
|
24
|
+
"dayjs": "^1.11.19",
|
|
25
|
+
"zod": "^3.23.8",
|
|
26
|
+
"zod-openapi": "^4.2.3",
|
|
27
|
+
"ts-to-zod": "^3.15.0"
|
|
23
28
|
},
|
|
24
29
|
"devDependencies": {
|
|
25
30
|
"@types/node": "^24.5.2",
|