@natyapp/meta 1.0.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.
Files changed (85) hide show
  1. package/README.md +52 -0
  2. package/dist/Entities/Logs.d.ts +16 -0
  3. package/dist/Entities/Logs.js +13 -0
  4. package/dist/Entities/QueueMessages.d.ts +7 -0
  5. package/dist/Entities/QueueMessages.js +13 -0
  6. package/dist/Entities/connection.d.ts +15 -0
  7. package/dist/Entities/connection.js +13 -0
  8. package/dist/Entities/errorLogs.d.ts +9 -0
  9. package/dist/Entities/errorLogs.js +13 -0
  10. package/dist/Entities/message.d.ts +4 -0
  11. package/dist/Entities/message.js +9 -0
  12. package/dist/Entities/webhooks.d.ts +17 -0
  13. package/dist/Entities/webhooks.js +13 -0
  14. package/dist/Errors/Either.d.ts +15 -0
  15. package/dist/Errors/Either.js +37 -0
  16. package/dist/Errors/ErrorHandling.d.ts +10 -0
  17. package/dist/Errors/ErrorHandling.js +15 -0
  18. package/dist/Errors/index.d.ts +2 -0
  19. package/dist/Errors/index.js +18 -0
  20. package/dist/configs/axiosInterceptors.d.ts +7 -0
  21. package/dist/configs/axiosInterceptors.js +10 -0
  22. package/dist/elements/button.d.ts +18 -0
  23. package/dist/elements/button.js +12 -0
  24. package/dist/elements/image.d.ts +9 -0
  25. package/dist/elements/image.js +12 -0
  26. package/dist/elements/list.d.ts +78 -0
  27. package/dist/elements/list.js +55 -0
  28. package/dist/elements/text.d.ts +7 -0
  29. package/dist/elements/text.js +11 -0
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.js +10 -0
  32. package/dist/interfaces/IConnection.d.ts +13 -0
  33. package/dist/interfaces/IConnection.js +2 -0
  34. package/dist/interfaces/ILog.d.ts +10 -0
  35. package/dist/interfaces/ILog.js +2 -0
  36. package/dist/interfaces/IMessage.d.ts +8 -0
  37. package/dist/interfaces/IMessage.js +2 -0
  38. package/dist/interfaces/ISdk.d.ts +13 -0
  39. package/dist/interfaces/ISdk.js +2 -0
  40. package/dist/interfaces/IWebhook.d.ts +14 -0
  41. package/dist/interfaces/IWebhook.js +2 -0
  42. package/dist/interfaces/index.d.ts +5 -0
  43. package/dist/interfaces/index.js +21 -0
  44. package/dist/services/axiosInstances.d.ts +5 -0
  45. package/dist/services/axiosInstances.js +22 -0
  46. package/dist/services/index.d.ts +3 -0
  47. package/dist/services/index.js +19 -0
  48. package/dist/services/middlewares/index.d.ts +1 -0
  49. package/dist/services/middlewares/index.js +5 -0
  50. package/dist/services/middlewares/validations.d.ts +4 -0
  51. package/dist/services/middlewares/validations.js +8 -0
  52. package/dist/services/mutations/connection.d.ts +2 -0
  53. package/dist/services/mutations/connection.js +49 -0
  54. package/dist/services/mutations/index.d.ts +3 -0
  55. package/dist/services/mutations/index.js +19 -0
  56. package/dist/services/mutations/logs.d.ts +2 -0
  57. package/dist/services/mutations/logs.js +25 -0
  58. package/dist/services/mutations/validation.d.ts +5 -0
  59. package/dist/services/mutations/validation.js +15 -0
  60. package/dist/services/mutations/webhooks.d.ts +2 -0
  61. package/dist/services/mutations/webhooks.js +49 -0
  62. package/dist/types/logs.d.ts +5 -0
  63. package/dist/types/logs.js +2 -0
  64. package/dist/types/requestTypes.d.ts +11 -0
  65. package/dist/types/requestTypes.js +2 -0
  66. package/dist/useCases/connection/index.d.ts +15 -0
  67. package/dist/useCases/connection/index.js +16 -0
  68. package/dist/useCases/index.d.ts +6 -0
  69. package/dist/useCases/index.js +16 -0
  70. package/dist/useCases/log/index.d.ts +10 -0
  71. package/dist/useCases/log/index.js +12 -0
  72. package/dist/useCases/message/index.d.ts +9 -0
  73. package/dist/useCases/message/index.js +6 -0
  74. package/dist/useCases/sdk/index.d.ts +15 -0
  75. package/dist/useCases/sdk/index.js +36 -0
  76. package/dist/useCases/webhook/index.d.ts +15 -0
  77. package/dist/useCases/webhook/index.js +16 -0
  78. package/dist/utils/genUuid.d.ts +1 -0
  79. package/dist/utils/genUuid.js +16 -0
  80. package/dist/utils/index.d.ts +1 -0
  81. package/dist/utils/index.js +17 -0
  82. package/dist/utils/tryCatch.d.ts +1 -0
  83. package/dist/utils/tryCatch.js +19 -0
  84. package/index.ts +11 -0
  85. package/package.json +31 -0
@@ -0,0 +1,5 @@
1
+ export * from "./IConnection";
2
+ export * from "./IWebhook";
3
+ export * from "./IMessage";
4
+ export * from "./ILog";
5
+ export * from "./ISdk";
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./IConnection"), exports);
18
+ __exportStar(require("./IWebhook"), exports);
19
+ __exportStar(require("./IMessage"), exports);
20
+ __exportStar(require("./ILog"), exports);
21
+ __exportStar(require("./ISdk"), exports);
@@ -0,0 +1,5 @@
1
+ declare const api: import("axios").AxiosInstance;
2
+ export { api };
3
+ export declare const updateInterceptor: (interceptors: {
4
+ [key: string]: string;
5
+ }, callback?: ((bool: boolean) => void) | undefined) => Promise<number>;
@@ -0,0 +1,22 @@
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.updateInterceptor = exports.api = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const axiosInterceptors_1 = require("../configs/axiosInterceptors");
9
+ const api = axios_1.default.create({
10
+ baseURL: "https://whatsapi.secretarianaty.com/v1",
11
+ headers: axiosInterceptors_1.configInterceptors,
12
+ });
13
+ exports.api = api;
14
+ const updateInterceptor = async (interceptors, callback) => {
15
+ return api.interceptors.request.use((config) => {
16
+ // if (!config.headers) config.headers = configInterceptors;
17
+ config.headers = Object.assign(Object.assign(Object.assign({}, config.headers), axiosInterceptors_1.configInterceptors), interceptors);
18
+ callback && callback(true);
19
+ return config;
20
+ });
21
+ };
22
+ exports.updateInterceptor = updateInterceptor;
@@ -0,0 +1,3 @@
1
+ export * from "./mutations";
2
+ export * from "./axiosInstances";
3
+ export * from "./middlewares";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./mutations"), exports);
18
+ __exportStar(require("./axiosInstances"), exports);
19
+ __exportStar(require("./middlewares"), exports);
@@ -0,0 +1 @@
1
+ export { middlewares } from "./validations";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.middlewares = void 0;
4
+ var validations_1 = require("./validations");
5
+ Object.defineProperty(exports, "middlewares", { enumerable: true, get: function () { return validations_1.middlewares; } });
@@ -0,0 +1,4 @@
1
+ import { Response } from "../../Errors/ErrorHandling";
2
+ export declare const middlewares: {
3
+ confirmAppToken: (appToken: string) => Promise<Response<void, boolean>>;
4
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.middlewares = void 0;
4
+ const validation_1 = require("../mutations/validation");
5
+ const tryCatch_1 = require("../../utils/tryCatch");
6
+ exports.middlewares = {
7
+ confirmAppToken: async (appToken) => await (0, tryCatch_1.Try)(validation_1.validateMutations.confirmAppToken, appToken),
8
+ };
@@ -0,0 +1,2 @@
1
+ import { IConnection } from "../../interfaces";
2
+ export declare const connectionMutations: IConnection;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.connectionMutations = void 0;
4
+ const Either_1 = require("../../Errors/Either");
5
+ const axiosInstances_1 = require("../axiosInstances");
6
+ exports.connectionMutations = {
7
+ insert: async (connection) => {
8
+ const call = await axiosInstances_1.api.post(`/connections`, connection);
9
+ if (!call.data)
10
+ return (0, Either_1.throwError)("");
11
+ return (0, Either_1.throwSuccess)(call.data);
12
+ },
13
+ getSingle: async (id) => {
14
+ const call = await axiosInstances_1.api.get(`/connections/${id}`);
15
+ if (!call.data)
16
+ return (0, Either_1.throwError)("");
17
+ return (0, Either_1.throwSuccess)(call.data);
18
+ },
19
+ SearchOne: async (key, value) => {
20
+ const call = await axiosInstances_1.api.get(`/connections`, { params: { key, value } });
21
+ if (!call.data)
22
+ return (0, Either_1.throwError)("");
23
+ return (0, Either_1.throwSuccess)(call.data);
24
+ },
25
+ getAll: async (props) => {
26
+ const call = await axiosInstances_1.api.get(`/connections`, { params: props });
27
+ if (!call.data)
28
+ return (0, Either_1.throwError)("");
29
+ return (0, Either_1.throwSuccess)(call.data);
30
+ },
31
+ update: async (id, connection) => {
32
+ const call = await axiosInstances_1.api.patch(`/connections/${id}`, connection);
33
+ if (!call.data)
34
+ return (0, Either_1.throwError)("");
35
+ return (0, Either_1.throwSuccess)(call.data);
36
+ },
37
+ updateMany: async (connection) => {
38
+ const call = await axiosInstances_1.api.patch(`/connections`, connection);
39
+ if (!call.data)
40
+ return (0, Either_1.throwError)("");
41
+ return (0, Either_1.throwSuccess)(call.data);
42
+ },
43
+ deleteOne: async (id) => {
44
+ const call = await axiosInstances_1.api.delete(`/connections/${id}`);
45
+ if (!call.data)
46
+ return (0, Either_1.throwError)("");
47
+ return (0, Either_1.throwSuccess)(call.data);
48
+ },
49
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./connection";
2
+ export * from "./logs";
3
+ export * from "./webhooks";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./connection"), exports);
18
+ __exportStar(require("./logs"), exports);
19
+ __exportStar(require("./webhooks"), exports);
@@ -0,0 +1,2 @@
1
+ import { ILog } from "../../interfaces";
2
+ export declare const logsMutations: ILog;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logsMutations = void 0;
4
+ const Either_1 = require("../../Errors/Either");
5
+ const axiosInstances_1 = require("../axiosInstances");
6
+ exports.logsMutations = {
7
+ getSingle: async (id) => {
8
+ const call = await axiosInstances_1.api.get(`/logs/${id}`);
9
+ if (!call.data)
10
+ return (0, Either_1.throwError)("");
11
+ return (0, Either_1.throwSuccess)(call.data);
12
+ },
13
+ searchOne: async (key, value) => {
14
+ const call = await axiosInstances_1.api.get(`/logs`, { params: { key, value } });
15
+ if (!call.data)
16
+ return (0, Either_1.throwError)("");
17
+ return (0, Either_1.throwSuccess)(call.data);
18
+ },
19
+ getAll: async (props) => {
20
+ const call = await axiosInstances_1.api.get(`/logs`, { params: props });
21
+ if (!call.data)
22
+ return (0, Either_1.throwError)("");
23
+ return (0, Either_1.throwSuccess)(call.data);
24
+ },
25
+ };
@@ -0,0 +1,5 @@
1
+ import { Either } from "../../Errors/Either";
2
+ export declare const validateMutations: {
3
+ confirmAppToken: (appToken: string) => Promise<Either<ConfirmAppTokenErrors, boolean>>;
4
+ };
5
+ export type ConfirmAppTokenErrors = "Não foi possível validar";
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateMutations = void 0;
4
+ const axiosInstances_1 = require("../axiosInstances");
5
+ const Either_1 = require("../../Errors/Either");
6
+ exports.validateMutations = {
7
+ confirmAppToken: async (appToken) => {
8
+ const confirmation = await axiosInstances_1.api.post("/validate/validateAppToken", {
9
+ appToken,
10
+ });
11
+ if (confirmation.data)
12
+ return (0, Either_1.throwSuccess)(confirmation.data);
13
+ return (0, Either_1.throwError)("Não foi possível validar");
14
+ },
15
+ };
@@ -0,0 +1,2 @@
1
+ import { IWebhook } from "../../interfaces";
2
+ export declare const webhooksMutations: IWebhook;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webhooksMutations = void 0;
4
+ const Either_1 = require("../../Errors/Either");
5
+ const axiosInstances_1 = require("../axiosInstances");
6
+ exports.webhooksMutations = {
7
+ insert: async (connection) => {
8
+ const call = await axiosInstances_1.api.post(`/webhooks`, connection);
9
+ if (!call.data)
10
+ return (0, Either_1.throwError)("");
11
+ return (0, Either_1.throwSuccess)(call.data);
12
+ },
13
+ getSingle: async (id) => {
14
+ const call = await axiosInstances_1.api.get(`/webhooks/${id}`);
15
+ if (!call.data)
16
+ return (0, Either_1.throwError)("");
17
+ return (0, Either_1.throwSuccess)(call.data);
18
+ },
19
+ searchOne: async (key, value) => {
20
+ const call = await axiosInstances_1.api.get(`/webhooks`, { params: { key, value } });
21
+ if (!call.data)
22
+ return (0, Either_1.throwError)("");
23
+ return (0, Either_1.throwSuccess)(call.data);
24
+ },
25
+ getAll: async (props) => {
26
+ const call = await axiosInstances_1.api.get(`/webhooks`, { params: props });
27
+ if (!call.data)
28
+ return (0, Either_1.throwError)("");
29
+ return (0, Either_1.throwSuccess)(call.data);
30
+ },
31
+ update: async (id, connection) => {
32
+ const call = await axiosInstances_1.api.patch(`/webhooks/${id}`, connection);
33
+ if (!call.data)
34
+ return (0, Either_1.throwError)("");
35
+ return (0, Either_1.throwSuccess)(call.data);
36
+ },
37
+ updateMany: async (connection) => {
38
+ const call = await axiosInstances_1.api.patch(`/webhooks`, connection);
39
+ if (!call.data)
40
+ return (0, Either_1.throwError)("");
41
+ return (0, Either_1.throwSuccess)(call.data);
42
+ },
43
+ deleteOne: async (id) => {
44
+ const call = await axiosInstances_1.api.delete(`/webhooks/${id}`);
45
+ if (!call.data)
46
+ return (0, Either_1.throwError)("");
47
+ return (0, Either_1.throwSuccess)(call.data);
48
+ },
49
+ };
@@ -0,0 +1,5 @@
1
+ import { LogsEntity } from "../Entities/Logs";
2
+ export type typeLog = "Error" | "Access" | "Update" | "Observer" | "Middleware";
3
+ export type dataLogs = Partial<LogsEntity> & {
4
+ type: typeLog;
5
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ export type getAllProps = {
2
+ page?: number;
3
+ size?: number;
4
+ filter?: filterProps;
5
+ };
6
+ export type filterProps = {
7
+ key?: string;
8
+ value?: any;
9
+ fields?: string;
10
+ };
11
+ export type getAllReturn<t> = t[];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import { ConnectionEntity } from "../../Entities/connection";
2
+ import { Either } from "../../Errors";
3
+ import { IConnection } from "../../interfaces";
4
+ import { getAllProps, getAllReturn } from "../../types/requestTypes";
5
+ declare class Connections implements IConnection {
6
+ getSingle: (id: string) => Promise<Either<"", ConnectionEntity>>;
7
+ getAll: (props: getAllProps) => Promise<Either<"", getAllReturn<ConnectionEntity>>>;
8
+ SearchOne: (key: string, value: string) => Promise<Either<"", ConnectionEntity>>;
9
+ insert: (connection: Partial<ConnectionEntity>) => Promise<Either<"", ConnectionEntity>>;
10
+ update: (id: string, connection: Partial<ConnectionEntity>) => Promise<Either<"", ConnectionEntity>>;
11
+ updateMany: (connection: Partial<ConnectionEntity>[]) => Promise<Either<"", ConnectionEntity[]>>;
12
+ deleteOne: (id: string) => Promise<Either<"", ConnectionEntity>>;
13
+ }
14
+ declare const _default: Connections;
15
+ export default _default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const services_1 = require("../../services");
4
+ const utils_1 = require("../../utils");
5
+ class Connections {
6
+ constructor() {
7
+ this.getSingle = (id) => (0, utils_1.Try)(services_1.connectionMutations.getSingle, id);
8
+ this.getAll = (props) => (0, utils_1.Try)(services_1.connectionMutations.getAll, props);
9
+ this.SearchOne = (key, value) => (0, utils_1.Try)(services_1.connectionMutations.SearchOne, key, value);
10
+ this.insert = (connection) => (0, utils_1.Try)(services_1.connectionMutations.insert, connection);
11
+ this.update = (id, connection) => (0, utils_1.Try)(services_1.connectionMutations.update, id, connection);
12
+ this.updateMany = (connection) => (0, utils_1.Try)(services_1.connectionMutations.updateMany, connection);
13
+ this.deleteOne = (id) => (0, utils_1.Try)(services_1.connectionMutations.deleteOne, id);
14
+ }
15
+ }
16
+ exports.default = new Connections();
@@ -0,0 +1,6 @@
1
+ import { NatyMeta } from "./sdk";
2
+ import Connection from "./connection";
3
+ import Message from "./message";
4
+ import Webhook from "./webhook";
5
+ import Log from "./log";
6
+ export { NatyMeta, Connection, Message, Webhook, Log };
@@ -0,0 +1,16 @@
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.Log = exports.Webhook = exports.Message = exports.Connection = exports.NatyMeta = void 0;
7
+ const sdk_1 = require("./sdk");
8
+ Object.defineProperty(exports, "NatyMeta", { enumerable: true, get: function () { return sdk_1.NatyMeta; } });
9
+ const connection_1 = __importDefault(require("./connection"));
10
+ exports.Connection = connection_1.default;
11
+ const message_1 = __importDefault(require("./message"));
12
+ exports.Message = message_1.default;
13
+ const webhook_1 = __importDefault(require("./webhook"));
14
+ exports.Webhook = webhook_1.default;
15
+ const log_1 = __importDefault(require("./log"));
16
+ exports.Log = log_1.default;
@@ -0,0 +1,10 @@
1
+ import { LogsEntity } from "../../Entities/Logs";
2
+ import { Response } from "../../Errors";
3
+ import { getAllProps, getAllReturn } from "../../types/requestTypes";
4
+ declare class Logs {
5
+ getSingle: (id: string) => Promise<Response<"", LogsEntity>>;
6
+ getAll: (props: getAllProps) => Promise<Response<"", getAllReturn<LogsEntity>>>;
7
+ searchOne: (key: string, value: string) => Promise<Response<"", LogsEntity>>;
8
+ }
9
+ declare const _default: Logs;
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const services_1 = require("../../services");
4
+ const utils_1 = require("../../utils");
5
+ class Logs {
6
+ constructor() {
7
+ this.getSingle = (id) => (0, utils_1.Try)(services_1.logsMutations.getSingle, id);
8
+ this.getAll = (props) => (0, utils_1.Try)(services_1.logsMutations.getAll, props);
9
+ this.searchOne = (key, value) => (0, utils_1.Try)(services_1.logsMutations.searchOne, key, value);
10
+ }
11
+ }
12
+ exports.default = new Logs();
@@ -0,0 +1,9 @@
1
+ import { Button } from "../../elements/button";
2
+ import { List } from "../../elements/list";
3
+ import { Text } from "../../elements/text";
4
+ declare const _default: {
5
+ Button: typeof Button;
6
+ List: typeof List;
7
+ Text: typeof Text;
8
+ };
9
+ export default _default;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const button_1 = require("../../elements/button");
4
+ const list_1 = require("../../elements/list");
5
+ const text_1 = require("../../elements/text");
6
+ exports.default = { Button: button_1.Button, List: list_1.List, Text: text_1.Text };
@@ -0,0 +1,15 @@
1
+ import { Response } from "../../Errors/ErrorHandling";
2
+ import { ConnectErrors, ConnectProps, ISdk } from "../../interfaces/ISdk";
3
+ import Connection from "../connection";
4
+ import Message from "../message";
5
+ import Webhook from "../webhook";
6
+ import Log from "../log";
7
+ export declare class NatyMeta implements ISdk {
8
+ connected: boolean;
9
+ Connection: typeof Connection;
10
+ Message: typeof Message;
11
+ Webhook: typeof Webhook;
12
+ Log: typeof Log;
13
+ constructor(appToken?: string);
14
+ connect({ appToken, }: ConnectProps): Promise<Response<ConnectErrors, boolean>>;
15
+ }
@@ -0,0 +1,36 @@
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.NatyMeta = void 0;
7
+ const axiosInstances_1 = require("../../services/axiosInstances");
8
+ const validations_1 = require("../../services/middlewares/validations");
9
+ const tryCatch_1 = require("../../utils/tryCatch");
10
+ const connection_1 = __importDefault(require("../connection"));
11
+ const message_1 = __importDefault(require("../message"));
12
+ const webhook_1 = __importDefault(require("../webhook"));
13
+ const log_1 = __importDefault(require("../log"));
14
+ class NatyMeta {
15
+ constructor(appToken) {
16
+ this.connected = false;
17
+ if (appToken)
18
+ this.connect({ appToken });
19
+ (0, axiosInstances_1.updateInterceptor)({ ["x-access-token"]: `${appToken}` }, (bool) => ((this.connected = bool), console.log(bool)));
20
+ }
21
+ async connect({ appToken, }) {
22
+ const confirmAppToken = await (0, tryCatch_1.Try)(validations_1.middlewares.confirmAppToken, `${appToken}`);
23
+ if (confirmAppToken.isSuccess) {
24
+ await (0, axiosInstances_1.updateInterceptor)({ ["x-access-token"]: `${appToken}` }, (bool) => (this.connected = bool));
25
+ this.Connection = connection_1.default;
26
+ this.Message = message_1.default;
27
+ this.Webhook = webhook_1.default;
28
+ this.Log = log_1.default;
29
+ }
30
+ else {
31
+ this.connected = false;
32
+ }
33
+ return confirmAppToken;
34
+ }
35
+ }
36
+ exports.NatyMeta = NatyMeta;
@@ -0,0 +1,15 @@
1
+ import { WebhooksEntity } from "../../Entities/webhooks";
2
+ import { Either } from "../../Errors";
3
+ import { IWebhook } from "../../interfaces";
4
+ import { getAllProps, getAllReturn } from "../../types/requestTypes";
5
+ declare class Webhooks implements IWebhook {
6
+ getSingle: (id: string) => Promise<Either<"", WebhooksEntity>>;
7
+ getAll: (props: getAllProps) => Promise<Either<"", getAllReturn<WebhooksEntity>>>;
8
+ searchOne: (key: string, value: string) => Promise<Either<"", WebhooksEntity>>;
9
+ insert: (connection: Partial<WebhooksEntity>) => Promise<Either<"", WebhooksEntity>>;
10
+ update: (id: string, connection: Partial<WebhooksEntity>) => Promise<Either<"", WebhooksEntity>>;
11
+ updateMany: (webhooks: Partial<WebhooksEntity>[]) => Promise<Either<"", WebhooksEntity[]>>;
12
+ deleteOne: (id: string) => Promise<Either<"", WebhooksEntity>>;
13
+ }
14
+ declare const _default: Webhooks;
15
+ export default _default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const services_1 = require("../../services");
4
+ const utils_1 = require("../../utils");
5
+ class Webhooks {
6
+ constructor() {
7
+ this.getSingle = (id) => (0, utils_1.Try)(services_1.webhooksMutations.getSingle, id);
8
+ this.getAll = (props) => (0, utils_1.Try)(services_1.webhooksMutations.getAll, props);
9
+ this.searchOne = (key, value) => (0, utils_1.Try)(services_1.webhooksMutations.searchOne, key, value);
10
+ this.insert = (connection) => (0, utils_1.Try)(services_1.webhooksMutations.insert, connection);
11
+ this.update = (id, connection) => (0, utils_1.Try)(services_1.webhooksMutations.update, id, connection);
12
+ this.updateMany = (webhooks) => (0, utils_1.Try)(services_1.webhooksMutations.updateMany, webhooks);
13
+ this.deleteOne = (id) => (0, utils_1.Try)(services_1.webhooksMutations.deleteOne, id);
14
+ }
15
+ }
16
+ exports.default = new Webhooks();
@@ -0,0 +1 @@
1
+ export declare const genId: (str?: string) => string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.genId = void 0;
4
+ const genId = (str = "ID") => {
5
+ var characters = "abcdefghijklmnopqrstuvwxyz0123456789";
6
+ var result = "";
7
+ var charactersLength = characters.length;
8
+ for (var i = 0; i < 4; i++) {
9
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
10
+ }
11
+ const randomNumber = Math.floor(Math.random() * Date.now())
12
+ .toString()
13
+ .substring(2, 7);
14
+ return `${str.toUpperCase()}_${result}-${randomNumber}`;
15
+ };
16
+ exports.genId = genId;
@@ -0,0 +1 @@
1
+ export * from "./tryCatch";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./tryCatch"), exports);
@@ -0,0 +1 @@
1
+ export declare const Try: (fn: any, ...args: any) => Promise<any>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Try = void 0;
4
+ const Either_1 = require("../Errors/Either");
5
+ const ErrorHandling_1 = require("../Errors/ErrorHandling");
6
+ const Try = async (fn, ...args) => {
7
+ var _a;
8
+ try {
9
+ const resolver = await fn.apply(null, args);
10
+ if ((0, Either_1.isSuccess)(resolver))
11
+ (0, Either_1.unwrapEither)(resolver);
12
+ return resolver;
13
+ }
14
+ catch (err) {
15
+ const axiosError = { isError: (_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.data };
16
+ return (0, ErrorHandling_1.ErrorHandling)(axiosError);
17
+ }
18
+ };
19
+ exports.Try = Try;
package/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { NatyMeta } from "./src";
2
+
3
+ const teste = async () => {
4
+ const Meta = new NatyMeta();
5
+
6
+ await Meta.connect({ appToken: "OFP@OH26657FEUfsjfw9efh123F@YWFB*@" });
7
+
8
+ console.log(Meta.connected);
9
+ };
10
+
11
+ teste();
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@natyapp/meta",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "scripts": {
8
+ "test": "jest --watchAll",
9
+ "dev": "nodemon --quiet .",
10
+ "build": "rm -rf ./dist && npx tsc --declaration -p tsconfig.json"
11
+ },
12
+ "keywords": [
13
+ "naty"
14
+ ],
15
+ "author": "IkiraDev",
16
+ "license": "ISC",
17
+ "dependencies": {
18
+ "axios": "^0.26.1"
19
+ },
20
+ "devDependencies": {
21
+ "@types/axios": "^0.14.0",
22
+ "@types/jest": "^29.2.4",
23
+ "@types/node": "^18.11.18",
24
+ "dotenv": "^16.0.3",
25
+ "jest": "^29.3.1",
26
+ "nodemon": "^2.0.18",
27
+ "ts-jest": "^29.0.3",
28
+ "ts-node": "^10.9.1",
29
+ "typescript": "^4.9.4"
30
+ }
31
+ }