@agenus-io/webhook-centralizer 1.0.3 → 1.0.5
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/index.d.ts +4 -3
- package/dist/Class/index.js +41 -4
- package/dist/Class/interface.d.ts +41 -6
- package/dist/Schema/index.d.ts +59 -13
- package/dist/Utils/zod.d.ts +10 -10
- package/package.json +5 -3
package/dist/Class/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICreatePlatformDTO, IDeletePlatformDTO, IGetPlatformDTO, IGetPlatformWebhooksDTO, IUpdatePlatformDTO, IWebhookCentralizeSDK } from './interface';
|
|
1
|
+
import { ICreatePlatformDTO, IDeletePlatformDTO, IGetPlatformByTitleDTO, IGetPlatformDTO, IGetPlatformWebhooksDTO, IUpdatePlatformDTO, IWebhookCentralizeSDK } from './interface';
|
|
2
2
|
/**
|
|
3
3
|
* Classe responsável pela centralização de webhooks de plataformas de pagamento e envio de webhooks para o microserviço de webhooks
|
|
4
4
|
*/
|
|
@@ -13,8 +13,9 @@ export declare class WebhookCentralizerSDK implements IWebhookCentralizeSDK {
|
|
|
13
13
|
*/
|
|
14
14
|
constructor(appId: string, appToken: string, environment?: "production" | "develop");
|
|
15
15
|
Create({ workSpaceId, ...data }: ICreatePlatformDTO.Params): Promise<ICreatePlatformDTO.Result>;
|
|
16
|
-
Update({ id, workSpaceId, ...data }: IUpdatePlatformDTO.Params): Promise<
|
|
17
|
-
Delete({ id, workSpaceId }: IDeletePlatformDTO.Params): Promise<
|
|
16
|
+
Update({ id, workSpaceId, ...data }: IUpdatePlatformDTO.Params): Promise<IUpdatePlatformDTO.Result>;
|
|
17
|
+
Delete({ id, workSpaceId }: IDeletePlatformDTO.Params): Promise<IDeletePlatformDTO.Result>;
|
|
18
18
|
Get({ page, pageSize, filter, workSpaceId }: IGetPlatformDTO.Params): Promise<IGetPlatformDTO.Result>;
|
|
19
|
+
GetByTitle({ title, workSpaceId }: IGetPlatformByTitleDTO.Params): Promise<IGetPlatformByTitleDTO.Result>;
|
|
19
20
|
GetWebhooks({ id, page, pageSize, filter, workSpaceId }: IGetPlatformWebhooksDTO.Params): Promise<IGetPlatformWebhooksDTO.Result>;
|
|
20
21
|
}
|
package/dist/Class/index.js
CHANGED
|
@@ -66,7 +66,10 @@ class WebhookCentralizerSDK {
|
|
|
66
66
|
else {
|
|
67
67
|
console.log(error);
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
return {
|
|
70
|
+
isError: true,
|
|
71
|
+
error: error,
|
|
72
|
+
};
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
async Update({ id, workSpaceId, ...data }) {
|
|
@@ -76,7 +79,9 @@ class WebhookCentralizerSDK {
|
|
|
76
79
|
secretToken: this.appToken,
|
|
77
80
|
workSpaceId,
|
|
78
81
|
};
|
|
79
|
-
await axios_1.default.put(`${this.apiUrl}/platform/${id}`, { token, ...data });
|
|
82
|
+
const res = await axios_1.default.put(`${this.apiUrl}/platform/${id}`, { token, ...data });
|
|
83
|
+
const result = res.data;
|
|
84
|
+
return result;
|
|
80
85
|
}
|
|
81
86
|
catch (error) {
|
|
82
87
|
if (error instanceof axios_1.AxiosError) {
|
|
@@ -85,7 +90,10 @@ class WebhookCentralizerSDK {
|
|
|
85
90
|
else {
|
|
86
91
|
console.log(error);
|
|
87
92
|
}
|
|
88
|
-
|
|
93
|
+
return {
|
|
94
|
+
isError: true,
|
|
95
|
+
error: error,
|
|
96
|
+
};
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
99
|
async Delete({ id, workSpaceId }) {
|
|
@@ -98,6 +106,9 @@ class WebhookCentralizerSDK {
|
|
|
98
106
|
await axios_1.default.delete(`${this.apiUrl}/platform/${id}`, {
|
|
99
107
|
headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
|
|
100
108
|
});
|
|
109
|
+
return {
|
|
110
|
+
isError: false,
|
|
111
|
+
};
|
|
101
112
|
}
|
|
102
113
|
catch (error) {
|
|
103
114
|
if (error instanceof axios_1.AxiosError) {
|
|
@@ -106,7 +117,10 @@ class WebhookCentralizerSDK {
|
|
|
106
117
|
else {
|
|
107
118
|
console.log(error);
|
|
108
119
|
}
|
|
109
|
-
|
|
120
|
+
return {
|
|
121
|
+
isError: true,
|
|
122
|
+
error: error,
|
|
123
|
+
};
|
|
110
124
|
}
|
|
111
125
|
}
|
|
112
126
|
async Get({ page, pageSize, filter, workSpaceId }) {
|
|
@@ -132,6 +146,29 @@ class WebhookCentralizerSDK {
|
|
|
132
146
|
throw "Erro ao listar pixel";
|
|
133
147
|
}
|
|
134
148
|
}
|
|
149
|
+
async GetByTitle({ title, workSpaceId }) {
|
|
150
|
+
try {
|
|
151
|
+
const token = {
|
|
152
|
+
appId: this.appId,
|
|
153
|
+
secretToken: this.appToken,
|
|
154
|
+
workSpaceId,
|
|
155
|
+
};
|
|
156
|
+
const response = await axios_1.default.get(`${this.apiUrl}/platform/title`, {
|
|
157
|
+
headers: { "app-id": token.appId, "app-secret-token": token.secretToken, "work-space-id": token.workSpaceId },
|
|
158
|
+
params: { title },
|
|
159
|
+
});
|
|
160
|
+
return response.data;
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (error instanceof axios_1.AxiosError) {
|
|
164
|
+
console.log(error.response?.data);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
console.log(error);
|
|
168
|
+
}
|
|
169
|
+
throw "Erro ao buscar plataforma por título";
|
|
170
|
+
}
|
|
171
|
+
}
|
|
135
172
|
async GetWebhooks({ id, page, pageSize, filter, workSpaceId }) {
|
|
136
173
|
try {
|
|
137
174
|
const token = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { webhookCentralizerOrderStatus, webhookCentralizerPlatform } from './../types';
|
|
2
2
|
import { webhookCentralizerDispatchType } from '../types';
|
|
3
|
+
import { JsonValue } from 'aws-sdk/clients/appmesh';
|
|
3
4
|
interface ICreatePlatformDTO {
|
|
4
5
|
title: string;
|
|
5
6
|
platformToken: string;
|
|
@@ -13,7 +14,9 @@ interface ICreatePlatformDTO {
|
|
|
13
14
|
export declare namespace ICreatePlatformDTO {
|
|
14
15
|
type Params = ICreatePlatformDTO;
|
|
15
16
|
type Result = {
|
|
16
|
-
id
|
|
17
|
+
id?: string;
|
|
18
|
+
error?: any;
|
|
19
|
+
isError?: boolean;
|
|
17
20
|
};
|
|
18
21
|
}
|
|
19
22
|
export declare namespace IUpdatePlatformDTO {
|
|
@@ -21,12 +24,20 @@ export declare namespace IUpdatePlatformDTO {
|
|
|
21
24
|
id: string;
|
|
22
25
|
workSpaceId: string;
|
|
23
26
|
} & Partial<ICreatePlatformDTO>;
|
|
27
|
+
type Result = {
|
|
28
|
+
isError?: boolean;
|
|
29
|
+
error?: any;
|
|
30
|
+
};
|
|
24
31
|
}
|
|
25
32
|
export declare namespace IDeletePlatformDTO {
|
|
26
33
|
type Params = {
|
|
27
34
|
id: string;
|
|
28
35
|
workSpaceId: string;
|
|
29
36
|
};
|
|
37
|
+
type Result = {
|
|
38
|
+
isError?: boolean;
|
|
39
|
+
error?: any;
|
|
40
|
+
};
|
|
30
41
|
}
|
|
31
42
|
export declare namespace IGetPlatformDTO {
|
|
32
43
|
type Params = {
|
|
@@ -90,11 +101,35 @@ export declare namespace IGetPlatformWebhooksDTO {
|
|
|
90
101
|
};
|
|
91
102
|
};
|
|
92
103
|
}
|
|
104
|
+
export declare namespace IGetPlatformByTitleDTO {
|
|
105
|
+
type Params = {
|
|
106
|
+
title: string;
|
|
107
|
+
workSpaceId: string;
|
|
108
|
+
};
|
|
109
|
+
type Result = {
|
|
110
|
+
id: string;
|
|
111
|
+
title: string;
|
|
112
|
+
status: boolean;
|
|
113
|
+
dispatchType: webhookCentralizerDispatchType;
|
|
114
|
+
type: webhookCentralizerPlatform;
|
|
115
|
+
apiToken: string | null;
|
|
116
|
+
slug: string | null;
|
|
117
|
+
url: string;
|
|
118
|
+
platformSettingId: string;
|
|
119
|
+
appId: string;
|
|
120
|
+
workSpaceId: string;
|
|
121
|
+
meta: JsonValue | null;
|
|
122
|
+
createdAt: Date;
|
|
123
|
+
updatedAt: Date;
|
|
124
|
+
isDeleted: boolean;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
93
127
|
export interface IWebhookCentralizeSDK {
|
|
94
|
-
Create
|
|
95
|
-
Update
|
|
96
|
-
Delete
|
|
97
|
-
Get
|
|
98
|
-
GetWebhooks
|
|
128
|
+
Create(data: ICreatePlatformDTO.Params): Promise<ICreatePlatformDTO.Result>;
|
|
129
|
+
Update(data: IUpdatePlatformDTO.Params): Promise<IUpdatePlatformDTO.Result>;
|
|
130
|
+
Delete(data: IDeletePlatformDTO.Params): Promise<IDeletePlatformDTO.Result>;
|
|
131
|
+
Get(data: IGetPlatformDTO.Params): Promise<IGetPlatformDTO.Result>;
|
|
132
|
+
GetWebhooks(data: IGetPlatformWebhooksDTO.Params): Promise<IGetPlatformWebhooksDTO.Result>;
|
|
133
|
+
GetByTitle(data: IGetPlatformByTitleDTO.Params): Promise<IGetPlatformByTitleDTO.Result>;
|
|
99
134
|
}
|
|
100
135
|
export {};
|
package/dist/Schema/index.d.ts
CHANGED
|
@@ -1,27 +1,73 @@
|
|
|
1
1
|
export declare const WebhookCentralizerCreatePlatformSchema: import("zod").ZodObject<{
|
|
2
2
|
title: import("zod").ZodString;
|
|
3
3
|
platformToken: import("zod").ZodOptional<import("zod").ZodString>;
|
|
4
|
-
dispatchType: import("zod").ZodDefault<import("zod").
|
|
5
|
-
type: import("zod").
|
|
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
6
|
apiToken: import("zod").ZodOptional<import("zod").ZodString>;
|
|
7
7
|
slug: import("zod").ZodOptional<import("zod").ZodString>;
|
|
8
|
-
}, import("zod
|
|
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
|
+
}>;
|
|
9
23
|
export declare const WebhookCentralizerUpdatePlatformSchema: import("zod").ZodObject<{
|
|
10
24
|
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
11
25
|
platformToken: import("zod").ZodOptional<import("zod").ZodString>;
|
|
12
|
-
dispatchType: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").
|
|
13
|
-
type: import("zod").ZodOptional<import("zod").
|
|
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>>>;
|
|
14
28
|
apiToken: import("zod").ZodOptional<import("zod").ZodString>;
|
|
15
29
|
slug: import("zod").ZodOptional<import("zod").ZodOptional<import("zod").ZodString>>;
|
|
16
|
-
}, import("zod
|
|
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
|
+
}>;
|
|
17
45
|
export declare const WebhookCentralizerGetPlatformsSchema: import("zod").ZodObject<{
|
|
18
|
-
page: import("zod").ZodDefault<import("zod").
|
|
19
|
-
pageSize: import("zod").ZodDefault<import("zod").
|
|
46
|
+
page: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
47
|
+
pageSize: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
20
48
|
filter: import("zod").ZodOptional<import("zod").ZodString>;
|
|
21
|
-
}, import("zod
|
|
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
|
+
}>;
|
|
22
58
|
export declare const WebhookCentralizerGetPlatformWebhooksSchema: import("zod").ZodObject<{
|
|
23
|
-
page: import("zod").ZodDefault<import("zod").
|
|
24
|
-
status: import("zod").ZodOptional<import("zod").
|
|
25
|
-
pageSize: import("zod").ZodDefault<import("zod").
|
|
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>;
|
|
26
62
|
filter: import("zod").ZodOptional<import("zod").ZodString>;
|
|
27
|
-
}, import("zod
|
|
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
|
+
}>;
|
package/dist/Utils/zod.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ZodRawShape, ZodTypeAny, z } from "zod";
|
|
2
2
|
export declare const stringField: () => z.ZodString;
|
|
3
|
-
export declare const booleanField: () => z.
|
|
4
|
-
export declare const numberField: () => z.
|
|
5
|
-
export declare const dateField: () => z.
|
|
6
|
-
export declare const objectField: <T extends ZodRawShape>(schema: T) => z.
|
|
7
|
-
export declare const startDateField: () => z.
|
|
8
|
-
export declare const endDateField: () => z.
|
|
9
|
-
export declare const nativeEnumField: <T extends
|
|
10
|
-
export declare const enumField: <U extends string, T extends Readonly<[U, ...U[]]>>(values: T) => z.ZodEnum<
|
|
11
|
-
export declare const arrayField: <T extends ZodTypeAny>(schema: T) => z.
|
|
12
|
-
export declare const formDataField: <T extends ZodTypeAny>(schema: T) => z.
|
|
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>;
|
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.5",
|
|
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,11 +18,13 @@
|
|
|
18
18
|
"email": "davidpimanta@gmail.com",
|
|
19
19
|
"license": "ISC",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@asteasolutions/zod-to-openapi": "^
|
|
21
|
+
"@asteasolutions/zod-to-openapi": "^7.3.0",
|
|
22
22
|
"aws-sdk": "^2.1692.0",
|
|
23
23
|
"axios": "^1.13.2",
|
|
24
24
|
"dayjs": "^1.11.19",
|
|
25
|
-
"zod": "^
|
|
25
|
+
"zod": "^3.23.8",
|
|
26
|
+
"zod-openapi": "^4.2.3",
|
|
27
|
+
"ts-to-zod": "^3.15.0"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
30
|
"@types/node": "^24.5.2",
|