@zennify/sdk-js 1.47.1 → 2.0.1
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/.github/workflows/npm-publish-package-ofc.yml +4 -7
- package/dist/lib/api/client/client.gen.js +221 -0
- package/dist/lib/api/client/index.js +17 -0
- package/dist/{interfaces/Products.js → lib/api/client/types.gen.js} +1 -0
- package/dist/lib/api/client/utils.gen.js +242 -0
- package/dist/lib/api/client.gen.js +6 -0
- package/dist/lib/api/core/auth.gen.js +18 -0
- package/dist/lib/api/core/bodySerializer.gen.js +60 -0
- package/dist/lib/api/core/params.gen.js +107 -0
- package/dist/lib/api/core/pathSerializer.gen.js +123 -0
- package/dist/lib/api/core/queryKeySerializer.gen.js +105 -0
- package/dist/lib/api/core/serverSentEvents.gen.js +139 -0
- package/dist/{errors.js → lib/api/core/types.gen.js} +1 -0
- package/dist/lib/api/core/utils.gen.js +93 -0
- package/dist/lib/api/index.js +61 -0
- package/dist/lib/api/sdk.gen.js +610 -0
- package/dist/{interfaces/Media.js → lib/api/types.gen.js} +1 -0
- package/dist/main.js +1 -10
- package/package.json +1 -1
- package/src/lib/api/client/client.gen.ts +303 -0
- package/src/lib/api/client/index.ts +25 -0
- package/src/lib/api/client/types.gen.ts +247 -0
- package/src/lib/api/client/utils.gen.ts +337 -0
- package/src/lib/api/client.gen.ts +25 -0
- package/src/lib/api/core/auth.gen.ts +42 -0
- package/src/lib/api/core/bodySerializer.gen.ts +96 -0
- package/src/lib/api/core/params.gen.ts +181 -0
- package/src/lib/api/core/pathSerializer.gen.ts +180 -0
- package/src/lib/api/core/queryKeySerializer.gen.ts +136 -0
- package/src/lib/api/core/serverSentEvents.gen.ts +265 -0
- package/src/lib/api/core/types.gen.ts +118 -0
- package/src/lib/api/core/utils.gen.ts +143 -0
- package/src/lib/api/index.ts +325 -0
- package/src/lib/api/sdk.gen.ts +1188 -0
- package/src/lib/api/types.gen.ts +3328 -0
- package/src/main.ts +42 -13
- package/types/lib/api/client/client.gen.d.ts +2 -0
- package/types/lib/api/client/index.d.ts +8 -0
- package/types/lib/api/client/types.gen.d.ts +120 -0
- package/types/lib/api/client/utils.gen.d.ts +37 -0
- package/types/lib/api/client.gen.d.ts +12 -0
- package/types/lib/api/core/auth.gen.d.ts +18 -0
- package/types/lib/api/core/bodySerializer.gen.d.ts +25 -0
- package/types/lib/api/core/params.gen.d.ts +43 -0
- package/types/lib/api/core/pathSerializer.gen.d.ts +33 -0
- package/types/lib/api/core/queryKeySerializer.gen.d.ts +18 -0
- package/types/lib/api/core/serverSentEvents.gen.d.ts +71 -0
- package/types/lib/api/core/types.gen.d.ts +78 -0
- package/types/lib/api/core/utils.gen.d.ts +19 -0
- package/types/lib/api/index.d.ts +2 -0
- package/types/lib/api/sdk.gen.d.ts +235 -0
- package/types/lib/api/types.gen.d.ts +2910 -0
- package/types/main.d.ts +19 -12
- package/dist/RequestError.js +0 -55
- package/dist/interfaces/Panels.js +0 -2
- package/dist/interfaces/Statistics.js +0 -2
- package/dist/interfaces/Stores.js +0 -2
- package/dist/interfaces/Transactions.js +0 -2
- package/dist/utils.js +0 -13
- package/dist/var.js +0 -8
- package/src/RequestError.ts +0 -66
- package/src/errors.ts +0 -224
- package/src/interfaces/Media.ts +0 -5
- package/src/interfaces/Panels.ts +0 -18
- package/src/interfaces/Products.ts +0 -29
- package/src/interfaces/Statistics.ts +0 -21
- package/src/interfaces/Stores.ts +0 -58
- package/src/interfaces/Transactions.ts +0 -80
- package/src/utils.ts +0 -19
- package/src/var.ts +0 -5
- package/types/RequestError.d.ts +0 -11
- package/types/errors.d.ts +0 -214
- package/types/interfaces/Media.d.ts +0 -5
- package/types/interfaces/Panels.d.ts +0 -17
- package/types/interfaces/Products.d.ts +0 -28
- package/types/interfaces/Statistics.d.ts +0 -19
- package/types/interfaces/Stores.d.ts +0 -47
- package/types/interfaces/Transactions.d.ts +0 -78
- package/types/utils.d.ts +0 -5
- package/types/var.d.ts +0 -3
package/types/main.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
1
|
+
import { GetStoreDiscordPanelsResponse, GetStoreProductResponse, GetStoreResponse, GetStoresResponse, GetTransactionResponse, GetUserResponse, ListStoreProductsResponse, ListTransactionsResponse, UploadStoreMediaData } from "./lib/api";
|
|
2
|
+
export * from "./images";
|
|
3
|
+
export * from "./lib/api/index";
|
|
4
|
+
export * from "./interfaces/Guild";
|
|
5
|
+
export type ZennifyUser = GetUserResponse;
|
|
6
|
+
export type MediaUpdatePayload = UploadStoreMediaData;
|
|
7
|
+
export type PartialStore = GetStoresResponse[number];
|
|
8
|
+
export type FullStore = GetStoreResponse;
|
|
9
|
+
export type StoreModerator = FullStore["moderators"][number];
|
|
10
|
+
export type StoreModeratorPermissions = StoreModerator["permissions"][number];
|
|
11
|
+
export type PartialProduct = ListStoreProductsResponse[number];
|
|
12
|
+
export type Product = GetStoreProductResponse;
|
|
13
|
+
export type TransactionStatus = FullTransaction["status"];
|
|
14
|
+
export type PartialTransaction = ListTransactionsResponse[number];
|
|
15
|
+
export type FullTransaction<T = never> = GetTransactionResponse & {
|
|
16
|
+
metadata: T;
|
|
17
|
+
};
|
|
18
|
+
export type Panel = GetStoreDiscordPanelsResponse[number];
|
|
19
|
+
export type PanelProduct = Panel["products"][number];
|
package/dist/RequestError.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
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.ZennifyAPIRequestError = void 0;
|
|
7
|
-
const pt_BR_json_1 = __importDefault(require("../translations/pt_BR.json"));
|
|
8
|
-
const en_US_json_1 = __importDefault(require("../translations/en_US.json"));
|
|
9
|
-
const var_1 = require("./var");
|
|
10
|
-
const errors_translations = { pt_BR: pt_BR_json_1.default, en_US: en_US_json_1.default };
|
|
11
|
-
const match_regex = /{[\w.]+}/g;
|
|
12
|
-
const replacer = (body, value) => {
|
|
13
|
-
return body[value.slice(1, -1)];
|
|
14
|
-
};
|
|
15
|
-
class ZennifyAPIRequestError extends Error {
|
|
16
|
-
code = "UNKNOWN_ERROR";
|
|
17
|
-
body;
|
|
18
|
-
status = 0;
|
|
19
|
-
constructor(response, body) {
|
|
20
|
-
super();
|
|
21
|
-
this.body = body;
|
|
22
|
-
this.status = response.status;
|
|
23
|
-
this.code = body.code || 'UNKNOWN_ERROR';
|
|
24
|
-
if (this.status === 401) {
|
|
25
|
-
this.name = "Usuário inválido";
|
|
26
|
-
this.message = "Por favor, se re-autentique";
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
else if (this.status === 503) {
|
|
30
|
-
this.name = "API em atualização.";
|
|
31
|
-
this.message = "Por favor, tente novamente em alguns minutos.";
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
else if (this.status === 429) {
|
|
35
|
-
this.name = "Calma ai!";
|
|
36
|
-
this.message = "Suas ações estão sendo limitadas!";
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
else if (this.code) {
|
|
40
|
-
const error = errors_translations[var_1.ZENNIFY_API_RESPONSE_LANGUAGE][this.code] ||
|
|
41
|
-
errors_translations[var_1.ZENNIFY_API_RESPONSE_LANGUAGE]["UNKNOWN_TRANSLATION"];
|
|
42
|
-
this.name = error.name
|
|
43
|
-
.replace(match_regex, (value) => replacer(body, value));
|
|
44
|
-
this.message = error.message
|
|
45
|
-
.replace(match_regex, (value) => replacer(body, value));
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
else if (this.status === 401) {
|
|
49
|
-
this.name = "Sem permissões";
|
|
50
|
-
this.message = "Por favor, se re-autentique";
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.ZennifyAPIRequestError = ZennifyAPIRequestError;
|
package/dist/utils.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GetResponseError = GetResponseError;
|
|
4
|
-
exports.TreatZennifyResponse = TreatZennifyResponse;
|
|
5
|
-
const RequestError_1 = require("./RequestError");
|
|
6
|
-
function GetResponseError(code, additional) { return { code, ...additional }; }
|
|
7
|
-
async function TreatZennifyResponse(response) {
|
|
8
|
-
const body = await response.json().catch(() => ({}));
|
|
9
|
-
if (response.ok) {
|
|
10
|
-
return body;
|
|
11
|
-
}
|
|
12
|
-
throw new RequestError_1.ZennifyAPIRequestError(response, body);
|
|
13
|
-
}
|
package/dist/var.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZENNIFY_API_RESPONSE_LANGUAGE = void 0;
|
|
4
|
-
exports.SetAPIResponseLanguage = SetAPIResponseLanguage;
|
|
5
|
-
exports.ZENNIFY_API_RESPONSE_LANGUAGE = 'en_US';
|
|
6
|
-
function SetAPIResponseLanguage(lang) {
|
|
7
|
-
return exports.ZENNIFY_API_RESPONSE_LANGUAGE = lang;
|
|
8
|
-
}
|
package/src/RequestError.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import pt_BR from '../translations/pt_BR.json';
|
|
2
|
-
import en_US from '../translations/en_US.json';
|
|
3
|
-
import { ZENNIFY_API_RESPONSE_LANGUAGE } from './var';
|
|
4
|
-
import { APIErrors } from './errors';
|
|
5
|
-
|
|
6
|
-
const errors_translations = { pt_BR, en_US };
|
|
7
|
-
const match_regex = /{[\w.]+}/g;
|
|
8
|
-
const replacer = (body: any, value: string) => {
|
|
9
|
-
return body[value.slice(1, -1)]
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type Body = Record<string, any> & {
|
|
13
|
-
code: keyof APIErrors
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class ZennifyAPIRequestError extends Error {
|
|
17
|
-
|
|
18
|
-
code: keyof APIErrors = "UNKNOWN_ERROR";
|
|
19
|
-
body: Body
|
|
20
|
-
status: number = 0;
|
|
21
|
-
|
|
22
|
-
constructor(response: Response, body: Body) {
|
|
23
|
-
|
|
24
|
-
super();
|
|
25
|
-
|
|
26
|
-
this.body = body;
|
|
27
|
-
this.status = response.status;
|
|
28
|
-
this.code = body.code || 'UNKNOWN_ERROR'
|
|
29
|
-
|
|
30
|
-
if (this.status === 401) {
|
|
31
|
-
this.name = "Usuário inválido";
|
|
32
|
-
this.message = "Por favor, se re-autentique";
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
else if (this.status === 503) {
|
|
36
|
-
this.name = "API em atualização.";
|
|
37
|
-
this.message = "Por favor, tente novamente em alguns minutos.";
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
else if (this.status === 429) {
|
|
41
|
-
this.name = "Calma ai!";
|
|
42
|
-
this.message = "Suas ações estão sendo limitadas!";
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
else if (this.code) {
|
|
46
|
-
|
|
47
|
-
const error: { name: string, message: string } =
|
|
48
|
-
errors_translations[ZENNIFY_API_RESPONSE_LANGUAGE][this.code] ||
|
|
49
|
-
errors_translations[ZENNIFY_API_RESPONSE_LANGUAGE]["UNKNOWN_TRANSLATION"];
|
|
50
|
-
|
|
51
|
-
this.name = error.name
|
|
52
|
-
.replace(match_regex, (value) => replacer(body, value));
|
|
53
|
-
|
|
54
|
-
this.message = error.message
|
|
55
|
-
.replace(match_regex, (value) => replacer(body, value));
|
|
56
|
-
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
else if (this.status === 401) {
|
|
60
|
-
this.name = "Sem permissões";
|
|
61
|
-
this.message = "Por favor, se re-autentique"
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
}
|
package/src/errors.ts
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
export interface APIErrors {
|
|
2
|
-
// = general errors
|
|
3
|
-
'UNKNOWN_ERROR': {
|
|
4
|
-
id: string | number
|
|
5
|
-
};
|
|
6
|
-
'UNKNOWN_TRANSLATION': {
|
|
7
|
-
code: keyof APIErrors | string
|
|
8
|
-
};
|
|
9
|
-
'INVALID_DISCORD_CHANNEL_FOR_MESSAGE': {}
|
|
10
|
-
'MISSING_PERMISSIONS': {};
|
|
11
|
-
'METHOD_NOT_ALLOWED': {};
|
|
12
|
-
'EXPECTED_AN_OBJECT_ARRAY': ExpectedAdditionalData;
|
|
13
|
-
'EXPECTED_A_STRING_ARRAY': ExpectedAdditionalData;
|
|
14
|
-
'EXPECTED_A_NUMBER_ARRAY': ExpectedAdditionalData;
|
|
15
|
-
'EXPECTED_AN_OBJECT': ExpectedAdditionalData;
|
|
16
|
-
'EXPECTED_A_NON_EMPTY_OBJECT': ExpectedAdditionalData;
|
|
17
|
-
'EXPECTED_A_BOOLEAN': ExpectedAdditionalData;
|
|
18
|
-
'EXPECTED_A_STRING': ExpectedAdditionalData;
|
|
19
|
-
'EXPECTED_A_NUMBER': ExpectedAdditionalData;
|
|
20
|
-
'EXPECTED_A_VALID_ID': ExpectedAdditionalData;
|
|
21
|
-
'EXPECTED_A_VALID_SNOWFLAKE_ID': {};
|
|
22
|
-
'DUPLICATED_VALUES_ISNT_ALLOWED': {};
|
|
23
|
-
// = oAuth errors
|
|
24
|
-
'GRANT_CODE_MISSING_IN_QUERY': {};
|
|
25
|
-
'INVALID_SCOPE': {};
|
|
26
|
-
'VERIFY_YOUR_EMAIL': {};
|
|
27
|
-
'PLEASE_REVERIFY': {};
|
|
28
|
-
// Wallet errors
|
|
29
|
-
'WITHDRAW_INSUFFICIENT_BALANCE': { available: number };
|
|
30
|
-
'WITHDRAW_LIMIT_EXCEEDED': { limit: number };
|
|
31
|
-
'WALLET_SETUP_HAS_BLOCKED_PRODUCTS': {};
|
|
32
|
-
// = user errors
|
|
33
|
-
'USER_NOT_FOUND': {};
|
|
34
|
-
'USER_INVALID_NAME': {};
|
|
35
|
-
/// legal errors
|
|
36
|
-
'USER_LEGAL_DATA_REQUIRED': {};
|
|
37
|
-
'USER_LEGAL_DATA_ALREADY_EXISTS': {};
|
|
38
|
-
'USER_LEGAL_RESPONSIBLE_INVALID': {};
|
|
39
|
-
|
|
40
|
-
'USER_LEGAL_DOCUMENTS_REQUIRED': {};
|
|
41
|
-
'USER_LEGAL_DOCUMENT_INVALID': {};
|
|
42
|
-
'USER_LEGAL_NAME_INVALID': {};
|
|
43
|
-
'USER_LEGAL_BORN_INVALID': {};
|
|
44
|
-
'USER_LEGAL_PHONE_INVALID': {};
|
|
45
|
-
'USER_LEGAL_ADDRESS_INVALID': { prop: InvalidAddressProps };
|
|
46
|
-
|
|
47
|
-
'USER_LEGAL_RESPONSIBLE_DOCUMENTS_REQUIRED': {};
|
|
48
|
-
'USER_LEGAL_RESPONSIBLE_DOCUMENT_INVALID': {};
|
|
49
|
-
'USER_LEGAL_RESPONSIBLE_NAME_INVALID': {};
|
|
50
|
-
'USER_LEGAL_RESPONSIBLE_BORN_INVALID': {};
|
|
51
|
-
'USER_LEGAL_RESPONSIBLE_PHONE_INVALID': {};
|
|
52
|
-
'USER_LEGAL_RESPONSIBLE_ADDRESS_INVALID': { prop: InvalidAddressProps };
|
|
53
|
-
/// token errors
|
|
54
|
-
'INVALID_TOKEN_NAME': {};
|
|
55
|
-
'INVALID_TOKEN_EXPIRATION': {};
|
|
56
|
-
'INVALID_TOKEN_PERMISSIONS': {};
|
|
57
|
-
'YOU_REACHED_TOKEN_LIMIT': {};
|
|
58
|
-
/// password errors
|
|
59
|
-
'INVALID_PASSWORD': {};
|
|
60
|
-
'YOU_MUST_INSERT_THE_ACTUAL_PASSWORD': {};
|
|
61
|
-
'THE_PASSWORD_DOES_NOT_MATCH': {};
|
|
62
|
-
'THE_PASSWORD_MUST_HAVE_AT_LEAST_8_CHARACTERS': {};
|
|
63
|
-
'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_NUMBER': {};
|
|
64
|
-
'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_LETTER': {};
|
|
65
|
-
'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_SPECIAL_CHARACTER': {};
|
|
66
|
-
/// pix key errors
|
|
67
|
-
'THE_EMAIL_SENDED_ISNT_VALID': {};
|
|
68
|
-
'CELLPHONE_NUMBERS_MUST_HAVE_THE_9_DIGIT': {};
|
|
69
|
-
'THE_CELLPHONE_NUMBER_MUST_HAVE_ONLY_DIGITS': {};
|
|
70
|
-
'THE_PIX_KEY_INSERTED_ISNT_VALID': {};
|
|
71
|
-
/// webhook url error
|
|
72
|
-
'INSERT_A_VALID_URL': {};
|
|
73
|
-
'THE_ONLY_ACCEPTED_PROTOCOL_IS_HTTPS': {};
|
|
74
|
-
'THIS_DOMAIN_IS_BLACKLISTED': {};
|
|
75
|
-
'THE_URL_EXTENSION_ISNT_ACCEPTED_YET': {};
|
|
76
|
-
'THE_URL_IS_INACCESSIBLE_BY_THE_WEBHOOK_SERVER': {};
|
|
77
|
-
'THE_URL_WOULD_NOT_HAVE_REDIRECTS': {};
|
|
78
|
-
'THE_URL_HAS_TIMEOUT_5S': {};
|
|
79
|
-
'WEBHOOK_RECEIVED_INVALID_DATA': { status: number };
|
|
80
|
-
/// payment errors
|
|
81
|
-
'INVALID_PAYMENT_METHOD': {};
|
|
82
|
-
'BANK_INTERNAL_ERROR': {};
|
|
83
|
-
// Order Errors
|
|
84
|
-
'YOU_NEED_TO_INSERT_AT_LEAST_1_ITEM': {};
|
|
85
|
-
'ONE_PROVIDED_PRODUCT_IS_OUT_OF_STOCK': {
|
|
86
|
-
name: string
|
|
87
|
-
};
|
|
88
|
-
'WE_DONT_HAVE_THIS_AMOUNT_IN_STOCK': {
|
|
89
|
-
name: string,
|
|
90
|
-
received: string | number,
|
|
91
|
-
available: string | number
|
|
92
|
-
};
|
|
93
|
-
'THIS_SELLER_WAS_BANNED_FROM_ZENNIFY': {};
|
|
94
|
-
'WE_DO_NOT_YET_SUPPORT_MULTIPLE_USER_PRODUCTS': {
|
|
95
|
-
name: string,
|
|
96
|
-
id: string | number
|
|
97
|
-
};
|
|
98
|
-
'WE_DO_NOT_YET_SUPPORT_MULTIPLE_STORE_PRODUCTS': {
|
|
99
|
-
name: string
|
|
100
|
-
id: string | number
|
|
101
|
-
};
|
|
102
|
-
'YOU_ALREADY_HAVE_ANOTHER_ORDER_WAITING_PAYMENT': {
|
|
103
|
-
id: string | number
|
|
104
|
-
};
|
|
105
|
-
'YOU_INSERTED_AN_INVALID_ADDITIONAL': {
|
|
106
|
-
addon: string
|
|
107
|
-
};
|
|
108
|
-
'UNKNOWN_TRANSACTION': {}
|
|
109
|
-
/// for update
|
|
110
|
-
'INVALID_OPERATION_FOR_CURRENT_TRANSACTION_STATUS': {};
|
|
111
|
-
'INVALID_OPERATION_FOR_PAYMENT_ENTITY': {};
|
|
112
|
-
'INVALID_STATUS_FOR_TRANSACTION_UPDATE': {};
|
|
113
|
-
'INVALID_REFUND_VALUE_EXCEEDS_ORDER_VALUE': {};
|
|
114
|
-
'ORDER_TRANSACTION_ALREADY_REFUNDED': {};
|
|
115
|
-
'FAILED_REFUND': {};
|
|
116
|
-
'INVALID_METADATA': { details: string };
|
|
117
|
-
// MP errors
|
|
118
|
-
'MP_INVALID_TOKEN': {};
|
|
119
|
-
'MP_ACCOUNT_OFFLINE': {};
|
|
120
|
-
'MP_PIX_KEY_NOT_CONFIGURED': {};
|
|
121
|
-
'MP_NOT_ALLOWED_TO_SELL': {};
|
|
122
|
-
'MP_RATE_LIMIT': {};
|
|
123
|
-
// Efi Errors
|
|
124
|
-
'EFIBANK_INVALID_PIX_KEY': {};
|
|
125
|
-
'EFIBANK_INVALID_CREDENTIALS': {};
|
|
126
|
-
'EFIBANK_INVALID_SCOPES': {};
|
|
127
|
-
'EFIBANK_INVALID_CERTIFICATE': {};
|
|
128
|
-
'EFIBANK_INVALID_CLIENT_ID': {};
|
|
129
|
-
'EFIBANK_INVALID_CLIENT_SECRET': {};
|
|
130
|
-
'EFIBANK_BLOCKED_ACCOUNT': {};
|
|
131
|
-
'EFIBANK_UNKNOWN_TRANSACTION': {};
|
|
132
|
-
'EFIBANK_RATE_LIMIT': {};
|
|
133
|
-
/// bad preference configuration
|
|
134
|
-
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX': {};
|
|
135
|
-
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_BOLETO': {};
|
|
136
|
-
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_CRYPTO': {};
|
|
137
|
-
/// coupons
|
|
138
|
-
'THIS_COUPON_DOES_NOT_EXISTS': {
|
|
139
|
-
received: string
|
|
140
|
-
};
|
|
141
|
-
'THIS_COUPON_HAS_EXPIRED': {};
|
|
142
|
-
'THIS_COUPON_REACHED_THE_USE_LIMIT': {};
|
|
143
|
-
'SELECT_MORE_ITENS_TO_REACH_MINIMUM_COUPON_VALUE': {
|
|
144
|
-
formated_value: string,
|
|
145
|
-
value: number
|
|
146
|
-
};
|
|
147
|
-
'THIS_COUPON_IS_VALID_ONLY_FOR_THE_FIRST_BUY': {};
|
|
148
|
-
'COUPON_EXCLUSIVE_FOR_SOME_PRODUCTS': { allowed: number[] };
|
|
149
|
-
// store errors
|
|
150
|
-
'UNKNOWN_STORE': {};
|
|
151
|
-
'EXPIRED_STORE': {},
|
|
152
|
-
'UNKNOWN_BANK': { received: string };
|
|
153
|
-
'INVALID_STORE_NAME': {};
|
|
154
|
-
'YOU_HAVE_ALREADY_MIGRATED': {};
|
|
155
|
-
/// moderators errors
|
|
156
|
-
'YOU_REACHED_MODERATOR_LIMIT': {};
|
|
157
|
-
'INVALID_PERMISSIONS': {};
|
|
158
|
-
'UNKNOWN_PERMISSION': { index: number };
|
|
159
|
-
'MAX_MODERATOR_REQUESTS_REACHED': {};
|
|
160
|
-
'INVALID_CODE': {};
|
|
161
|
-
'UNKNOWN_CODE': {};
|
|
162
|
-
'UNKNOWN_MODERATOR': {};
|
|
163
|
-
/// AUTOROLE
|
|
164
|
-
'UNKNOWN_AUTOROLE_RULE': {},
|
|
165
|
-
'AUTOROLE_RULE_ALREADY_EXISTS': {};
|
|
166
|
-
'YOU_REACHED_THE_AUTOROLE_RULE_LIMIT': {}
|
|
167
|
-
/// bot errors
|
|
168
|
-
'WAIT_OR_TRY_AGAIN_WITH_ANOTHER_DISCORD_BOT': {};
|
|
169
|
-
'INVALID_DISCORD_BOT_TOKEN': {};
|
|
170
|
-
'DISABLE_REQUIRE_CODE_GRANT': {};
|
|
171
|
-
'UNKNOWN_DISCORD_CHANNEL': {};
|
|
172
|
-
'ANOTHER_STORE_HAS_THIS_BOT': {}
|
|
173
|
-
'UNKNOWN_APPLICATION': {}
|
|
174
|
-
'WAIT_APPLICATION_UPLOAD': {}
|
|
175
|
-
// product errors
|
|
176
|
-
'UNKNOWN_PRODUCT': {};
|
|
177
|
-
'INVALID_PRODUCT_NAME': {};
|
|
178
|
-
'INVALID_PRODUCT_VALUE': {};
|
|
179
|
-
'YOU_REACHED_THE_PRODUCT_LIMIT': {};
|
|
180
|
-
'PRODUCT_NAME_ALREADY_EXIST': {};
|
|
181
|
-
/// Description errors
|
|
182
|
-
'INVALID_PRODUCT_DESCRIPTION_FOR_DISCORD': {};
|
|
183
|
-
/// Stock errors
|
|
184
|
-
'UNKNOWN_STOCK': {};
|
|
185
|
-
'INVALID_STOCK_CONTENT': {};
|
|
186
|
-
'INVALID_STOCK_COST': {};
|
|
187
|
-
// coupon errors
|
|
188
|
-
'UNKNOWN_COUPON': {},
|
|
189
|
-
'INVALID_COUPON_NAME': {},
|
|
190
|
-
'INVALID_COUPON_TYPE': {},
|
|
191
|
-
'INVALID_COUPON_VALUE': {},
|
|
192
|
-
'INVALID_COUPON_AMOUNT': {},
|
|
193
|
-
'INVALID_COUPON_MIN_VALUE': {},
|
|
194
|
-
'INVALID_COUPON_EXPIRATION': {},
|
|
195
|
-
'INVALID_COUPON_MAX_USES_PER_USER': {}
|
|
196
|
-
'INVALID_COUPON_ONLY_FIRST_BUY': {},
|
|
197
|
-
'YOU_REACHED_THE_COUPON_LIMIT': {},
|
|
198
|
-
'COUPON_NAME_ALREADY_EXIST': {}
|
|
199
|
-
// Media Errors
|
|
200
|
-
'NO_FILES_FOUND': {};
|
|
201
|
-
'INVALID_FILE_TYPE': {};
|
|
202
|
-
'INVALID_FILE_SIZE': {};
|
|
203
|
-
'MEDIA_INVALID_SET': {};
|
|
204
|
-
'MEDIA_INVALID_SET_STORE': {};
|
|
205
|
-
'MEDIA_INVALID_SET_PRODUCTS': {};
|
|
206
|
-
'MEDIA_INVALID_SET_DISCORD_SALE_PANELS': {};
|
|
207
|
-
// Discord Panels Errors
|
|
208
|
-
'UNKNOWN_PANEL': {};
|
|
209
|
-
'INVALID_PANEL_NAME': {};
|
|
210
|
-
'INVALID_PANEL_DESCRIPTION': {};
|
|
211
|
-
'INVALID_PANEL_PLACEHOLDER': {};
|
|
212
|
-
'YOU_REACHED_PANEL_LIMIT': {};
|
|
213
|
-
'PANEL_NAME_ALREADY_EXIST': {};
|
|
214
|
-
'YOU_REACHED_THE_PRODUCT_LIMIT_ON_PANEL': {};
|
|
215
|
-
'STORE_ALREADY_CONFIGURED': {};
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
type InvalidAddressProps = "cep" | "state" | "city" | "neighborhood" | "line1" | "line2" | "number";
|
|
219
|
-
type ExpectedAdditionalData = {
|
|
220
|
-
field: string;
|
|
221
|
-
received: any;
|
|
222
|
-
type: string,
|
|
223
|
-
max_length?: string
|
|
224
|
-
}
|
package/src/interfaces/Media.ts
DELETED
package/src/interfaces/Panels.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface PanelProduct {
|
|
2
|
-
id: number,
|
|
3
|
-
emoji?: string | null,
|
|
4
|
-
label?: string | null
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface Panel {
|
|
8
|
-
id: number,
|
|
9
|
-
name: string,
|
|
10
|
-
created_at: number,
|
|
11
|
-
placeholder: string | null,
|
|
12
|
-
description: string | null,
|
|
13
|
-
icon_id: string | null,
|
|
14
|
-
banner_id: string | null,
|
|
15
|
-
owner_id: number,
|
|
16
|
-
store_id: number,
|
|
17
|
-
products: PanelProduct[]
|
|
18
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export interface PartialProduct {
|
|
2
|
-
id: number,
|
|
3
|
-
name: string,
|
|
4
|
-
value: number,
|
|
5
|
-
icon_id: string | null,
|
|
6
|
-
banner_id: string | null,
|
|
7
|
-
stock_locked: boolean | null,
|
|
8
|
-
stock_count: number
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface Product {
|
|
12
|
-
id: number,
|
|
13
|
-
name: string,
|
|
14
|
-
created_at: number,
|
|
15
|
-
store_id: number,
|
|
16
|
-
owner_id: number,
|
|
17
|
-
icon_id?: string | null,
|
|
18
|
-
banner_id?: string | null,
|
|
19
|
-
value: number,
|
|
20
|
-
description: {
|
|
21
|
-
short: null | string,
|
|
22
|
-
discord: null | string,
|
|
23
|
-
website: null | string
|
|
24
|
-
},
|
|
25
|
-
stock: {
|
|
26
|
-
size: number,
|
|
27
|
-
locked: boolean
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export type ProductStatisticsCustomer = {
|
|
2
|
-
id: number,
|
|
3
|
-
discord_user_id: string,
|
|
4
|
-
value: number,
|
|
5
|
-
sales: number
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type ProductStatistics = {
|
|
9
|
-
count: number,
|
|
10
|
-
users: number,
|
|
11
|
-
value: number,
|
|
12
|
-
rating: number,
|
|
13
|
-
customers: ProductStatisticsCustomer[]
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type Statistics = Record<string, Record<number, ProductStatistics>>
|
|
17
|
-
export type StatisticsResponse = {
|
|
18
|
-
last_update: number,
|
|
19
|
-
created_at: number
|
|
20
|
-
statistics: Statistics
|
|
21
|
-
};
|
package/src/interfaces/Stores.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export type Addons = 'custom_bot' | 'divulgation' | 'antiraid' | 'managed_automod';
|
|
2
|
-
|
|
3
|
-
export interface PartialStore {
|
|
4
|
-
id: number,
|
|
5
|
-
name: string,
|
|
6
|
-
created_at: number,
|
|
7
|
-
expires_at: number,
|
|
8
|
-
icon_id?: string | null,
|
|
9
|
-
banner_id?: string | null,
|
|
10
|
-
is_owner: boolean
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type StoreModeratorPermissions =
|
|
14
|
-
| 'MANAGE_DISCORD_PANELS' // Gerenciar painéis do Discord
|
|
15
|
-
| 'MANAGE_PRODUCTS' // Gerenciar produtos
|
|
16
|
-
| 'MANAGE_COUPONS' // Gerenciar cupons
|
|
17
|
-
| 'MANAGE_STORE' // Gerenciar a loja (Editar bot, nome, imagem, bancos bloqueados) e comandos /customize, /mod, /autorole, /temprole
|
|
18
|
-
| 'MANAGE_SALES' // Gerenciar vendas (Aprovar, cancelar e reembolsar)
|
|
19
|
-
| 'VIEW_STATISTICS' // Ver estatísticas (Acessar a home da dashboard, usar o comando /ranking e ver estatisticas de produtos)
|
|
20
|
-
|
|
21
|
-
export type StoreModerator = {
|
|
22
|
-
username: string,
|
|
23
|
-
discord_user_id: string | null,
|
|
24
|
-
created_at: number,
|
|
25
|
-
permissions: StoreModeratorPermissions[]
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface FullStore {
|
|
29
|
-
id: number,
|
|
30
|
-
name: string,
|
|
31
|
-
created_at: number,
|
|
32
|
-
expires_at: number,
|
|
33
|
-
owner_id: number,
|
|
34
|
-
icon_id: string | null,
|
|
35
|
-
banner_id: string | null,
|
|
36
|
-
banner_sale_approved_id: string | null,
|
|
37
|
-
background_ranking_id: string | null,
|
|
38
|
-
addons: Addons[],
|
|
39
|
-
blocked_banks: string[],
|
|
40
|
-
limit_product: number,
|
|
41
|
-
limit_discord_server: number,
|
|
42
|
-
discord_bot: {
|
|
43
|
-
id: string
|
|
44
|
-
cluster: string | null
|
|
45
|
-
},
|
|
46
|
-
moderators: Record<string, StoreModerator>
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export type StoreInvite = {
|
|
50
|
-
permissions: StoreModeratorPermissions[],
|
|
51
|
-
expires: number
|
|
52
|
-
store: {
|
|
53
|
-
name: string,
|
|
54
|
-
created_at: number
|
|
55
|
-
icon_id?: string | null,
|
|
56
|
-
banner_id?: string | null,
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
export type TransactionStatus = 'approved' | 'cancelled' | 'expired' | 'pending' | 'refused' | 'analysis' | 'refunded' | 'invalid-pix-key';
|
|
2
|
-
export type BaseTransaction<TransactionMetadata = any> = {
|
|
3
|
-
id: string,
|
|
4
|
-
created_at: number,
|
|
5
|
-
expires_at: number,
|
|
6
|
-
entity: 'semiauto' | 'mercadopago' | 'efi' | 'wallet-efi',
|
|
7
|
-
method: 'pix',
|
|
8
|
-
managed?: boolean | null,
|
|
9
|
-
status: TransactionStatus,
|
|
10
|
-
value: number,
|
|
11
|
-
base_value: number,
|
|
12
|
-
refunded_value: number,
|
|
13
|
-
refund_reason?: string | null,
|
|
14
|
-
refund_comment?: string | null,
|
|
15
|
-
refund_requested_by?: string | null,
|
|
16
|
-
pix_e2eid?: string | null,
|
|
17
|
-
pix_qrcode?: string | null,
|
|
18
|
-
payer_bank?: string | null,
|
|
19
|
-
metadata?: TransactionMetadata | null
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
type DiscordOrder = {
|
|
23
|
-
platform: 'discord',
|
|
24
|
-
discord_guild_id: string,
|
|
25
|
-
discord_channel_id: string,
|
|
26
|
-
discord_channel_message_id: string
|
|
27
|
-
discord_sale_message?: string | null,
|
|
28
|
-
discord_feedback_message?: string | null,
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type SaleTransaction = {
|
|
32
|
-
type: 'sale',
|
|
33
|
-
order: DiscordOrder & {
|
|
34
|
-
id: string,
|
|
35
|
-
created_at: number,
|
|
36
|
-
discount: number,
|
|
37
|
-
subtotal: number,
|
|
38
|
-
total_value: number,
|
|
39
|
-
rating?: number | null,
|
|
40
|
-
rating_message?: string | null,
|
|
41
|
-
payer: {
|
|
42
|
-
id: number,
|
|
43
|
-
username: string,
|
|
44
|
-
discord_user_id: string
|
|
45
|
-
},
|
|
46
|
-
seller: {
|
|
47
|
-
id: number,
|
|
48
|
-
username: string,
|
|
49
|
-
discord_user_id: string
|
|
50
|
-
},
|
|
51
|
-
store: {
|
|
52
|
-
id: number,
|
|
53
|
-
name: string,
|
|
54
|
-
icon_id?: string | null,
|
|
55
|
-
banner_id?: string | null
|
|
56
|
-
},
|
|
57
|
-
products: [
|
|
58
|
-
{
|
|
59
|
-
id: number,
|
|
60
|
-
name: string,
|
|
61
|
-
value: number,
|
|
62
|
-
icon_id?: string | null,
|
|
63
|
-
banner_id?: string | null,
|
|
64
|
-
discord_description?: string | null,
|
|
65
|
-
short_description?: string | null,
|
|
66
|
-
website_description?: string | null,
|
|
67
|
-
amount: number,
|
|
68
|
-
delivered: string[]
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export type FullTransaction<TransactionMetadata = any> = BaseTransaction<TransactionMetadata> & SaleTransaction;
|
|
75
|
-
export type PartialTransaction = {
|
|
76
|
-
id: string,
|
|
77
|
-
base_value: number,
|
|
78
|
-
created_at: number,
|
|
79
|
-
status: TransactionStatus
|
|
80
|
-
}
|
package/src/utils.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ZennifyAPIRequestError } from './RequestError';
|
|
2
|
-
import { APIErrors } from './errors';
|
|
3
|
-
|
|
4
|
-
export function GetResponseError<Code extends keyof APIErrors>(
|
|
5
|
-
code: Code,
|
|
6
|
-
additional: APIErrors[Code]
|
|
7
|
-
) { return { code, ...additional }; }
|
|
8
|
-
|
|
9
|
-
export async function TreatZennifyResponse<T extends any>(response: Response): Promise<T> {
|
|
10
|
-
|
|
11
|
-
const body = await response.json().catch(() => ({}));
|
|
12
|
-
|
|
13
|
-
if (response.ok) {
|
|
14
|
-
return body as T;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
throw new ZennifyAPIRequestError(response, body);
|
|
18
|
-
|
|
19
|
-
}
|
package/src/var.ts
DELETED
package/types/RequestError.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { APIErrors } from './errors';
|
|
2
|
-
type Body = Record<string, any> & {
|
|
3
|
-
code: keyof APIErrors;
|
|
4
|
-
};
|
|
5
|
-
export declare class ZennifyAPIRequestError extends Error {
|
|
6
|
-
code: keyof APIErrors;
|
|
7
|
-
body: Body;
|
|
8
|
-
status: number;
|
|
9
|
-
constructor(response: Response, body: Body);
|
|
10
|
-
}
|
|
11
|
-
export {};
|