@zennify/sdk-js 1.0.0-beta.9 → 1.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/.github/workflows/{npm-publish-package.yml → npm-publish-package-ofc.yml} +6 -7
- package/dist/RequestError.js +10 -8
- package/dist/images.js +19 -0
- package/dist/interfaces/Guild.js +2 -0
- package/dist/interfaces/Media.js +2 -0
- package/dist/interfaces/Panels.js +2 -0
- package/dist/interfaces/Products.js +2 -0
- package/dist/interfaces/Statistics.js +2 -0
- package/dist/interfaces/Stores.js +2 -0
- package/dist/main.js +7 -0
- package/dist/utils.js +2 -4
- package/package.json +2 -1
- package/src/RequestError.ts +12 -14
- package/src/errors.ts +144 -84
- package/src/images.ts +27 -0
- package/src/interfaces/Guild.ts +22 -0
- package/src/interfaces/Media.ts +6 -0
- package/src/interfaces/Panels.ts +15 -0
- package/src/interfaces/Products.ts +29 -0
- package/src/interfaces/Statistics.ts +13 -0
- package/src/interfaces/Stores.ts +46 -0
- package/src/main.ts +9 -1
- package/src/utils.ts +6 -23
- package/translations/en_US.json +97 -1
- package/translations/pt_BR.json +108 -12
- package/types/RequestError.d.ts +1 -1
- package/types/errors.d.ts +142 -1
- package/types/images.d.ts +9 -0
- package/types/interfaces/Guild.d.ts +19 -0
- package/types/interfaces/Media.d.ts +6 -0
- package/types/interfaces/Panels.d.ts +14 -0
- package/types/interfaces/Products.d.ts +28 -0
- package/types/interfaces/Statistics.d.ts +12 -0
- package/types/interfaces/Stores.d.ts +29 -0
- package/types/main.d.ts +7 -0
- package/types/utils.d.ts +3 -17
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
name: Publish to npm
|
|
1
|
+
name: Publish to npm (Stable)
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
- main
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
7
6
|
|
|
8
7
|
jobs:
|
|
9
8
|
build:
|
|
@@ -16,7 +15,7 @@ jobs:
|
|
|
16
15
|
- run: npm ci
|
|
17
16
|
- run: npm run build
|
|
18
17
|
|
|
19
|
-
publish-
|
|
18
|
+
publish-npm:
|
|
20
19
|
needs: build
|
|
21
20
|
runs-on: ubuntu-latest
|
|
22
21
|
permissions:
|
|
@@ -30,6 +29,6 @@ jobs:
|
|
|
30
29
|
registry-url: https://registry.npmjs.org/
|
|
31
30
|
- run: npm ci
|
|
32
31
|
- run: npm run build
|
|
33
|
-
- run: npm publish --access public
|
|
32
|
+
- run: npm publish --access public
|
|
34
33
|
env:
|
|
35
|
-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
34
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/dist/RequestError.js
CHANGED
|
@@ -24,20 +24,22 @@ class ZennifyAPIRequestError extends Error {
|
|
|
24
24
|
this.name = "Usuário inválido";
|
|
25
25
|
this.message = "Por favor, se re-autentique";
|
|
26
26
|
}
|
|
27
|
-
if (this.status === 503) {
|
|
27
|
+
else if (this.status === 503) {
|
|
28
28
|
this.name = "API em atualização.";
|
|
29
29
|
this.message = "Por favor, tente novamente em alguns minutos.";
|
|
30
30
|
}
|
|
31
|
-
if (this.status === 429) {
|
|
31
|
+
else if (this.status === 429) {
|
|
32
32
|
this.name = "Calma ai!";
|
|
33
33
|
this.message = "Suas ações estão sendo limitadas!";
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
errors_translations[var_1.ZENNIFY_API_RESPONSE_LANGUAGE][
|
|
37
|
-
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
.
|
|
35
|
+
else {
|
|
36
|
+
const error = errors_translations[var_1.ZENNIFY_API_RESPONSE_LANGUAGE][body.code] ||
|
|
37
|
+
errors_translations[var_1.ZENNIFY_API_RESPONSE_LANGUAGE]["UNKNOWN_TRANSLATION"];
|
|
38
|
+
this.name = error.name
|
|
39
|
+
.replace(match_regex, (value) => replacer(body, value));
|
|
40
|
+
this.message = error.message
|
|
41
|
+
.replace(match_regex, (value) => replacer(body, value));
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
exports.ZennifyAPIRequestError = ZennifyAPIRequestError;
|
package/dist/images.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetImageURL = GetImageURL;
|
|
4
|
+
const template = `https://cdn.zennify.app/media/{store_id}/{id}.png`;
|
|
5
|
+
const sources = {
|
|
6
|
+
'product_icon': `https://zennify.app/assets/images/emojis/caixa.png`,
|
|
7
|
+
'general': `https://zennify.app/assets/images/icon.png`,
|
|
8
|
+
'void': void 0,
|
|
9
|
+
'null': null,
|
|
10
|
+
'empty': ""
|
|
11
|
+
};
|
|
12
|
+
function GetImageURL(source, store_id, id) {
|
|
13
|
+
if (!store_id || !id)
|
|
14
|
+
return sources[source];
|
|
15
|
+
else
|
|
16
|
+
return template
|
|
17
|
+
.replace("{store_id}", store_id.toString())
|
|
18
|
+
.replace("{id}", id.toString());
|
|
19
|
+
}
|
package/dist/main.js
CHANGED
|
@@ -18,3 +18,10 @@ __exportStar(require("./var"), exports);
|
|
|
18
18
|
__exportStar(require("./errors"), exports);
|
|
19
19
|
__exportStar(require("./utils"), exports);
|
|
20
20
|
__exportStar(require("./RequestError"), exports);
|
|
21
|
+
__exportStar(require("./images"), exports);
|
|
22
|
+
__exportStar(require("./interfaces/Media"), exports);
|
|
23
|
+
__exportStar(require("./interfaces/Panels"), exports);
|
|
24
|
+
__exportStar(require("./interfaces/Products"), exports);
|
|
25
|
+
__exportStar(require("./interfaces/Guild"), exports);
|
|
26
|
+
__exportStar(require("./interfaces/Stores"), exports);
|
|
27
|
+
__exportStar(require("./interfaces/Statistics"), exports);
|
package/dist/utils.js
CHANGED
|
@@ -3,11 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GetResponseError = GetResponseError;
|
|
4
4
|
exports.TreatZennifyResponse = TreatZennifyResponse;
|
|
5
5
|
const RequestError_1 = require("./RequestError");
|
|
6
|
-
function GetResponseError(code, additional
|
|
7
|
-
return { code, ...additional };
|
|
8
|
-
}
|
|
6
|
+
function GetResponseError(code, additional) { return { code, ...additional }; }
|
|
9
7
|
async function TreatZennifyResponse(response) {
|
|
10
|
-
const body = await response.json();
|
|
8
|
+
const body = await response.json().catch(() => ({}));
|
|
11
9
|
if (response.ok) {
|
|
12
10
|
return body;
|
|
13
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zennify/sdk-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A simple package to work with https://api.zennify.app",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"types": "./types/main.d.ts",
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@types/node": "^20.12.12",
|
|
18
|
+
"discord.js": "^14.15.3",
|
|
18
19
|
"typescript": "^5.5.3"
|
|
19
20
|
},
|
|
20
21
|
"scripts": {
|
package/src/RequestError.ts
CHANGED
|
@@ -10,7 +10,7 @@ const replacer = (body: any, value: string) => {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
type Body = Record<string, any> & {
|
|
13
|
-
code: APIErrors
|
|
13
|
+
code: keyof APIErrors
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export class ZennifyAPIRequestError extends Error {
|
|
@@ -30,27 +30,25 @@ export class ZennifyAPIRequestError extends Error {
|
|
|
30
30
|
this.name = "Usuário inválido";
|
|
31
31
|
this.message = "Por favor, se re-autentique"
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
if (this.status === 503) {
|
|
33
|
+
else if (this.status === 503) {
|
|
35
34
|
this.name = "API em atualização.";
|
|
36
35
|
this.message = "Por favor, tente novamente em alguns minutos.";
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
if (this.status === 429) {
|
|
37
|
+
else if (this.status === 429) {
|
|
40
38
|
this.name = "Calma ai!";
|
|
41
39
|
this.message = "Suas ações estão sendo limitadas!";
|
|
42
|
-
}
|
|
40
|
+
} else {
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const error: { name: string, message: string } =
|
|
43
|
+
errors_translations[ZENNIFY_API_RESPONSE_LANGUAGE][body.code] ||
|
|
44
|
+
errors_translations[ZENNIFY_API_RESPONSE_LANGUAGE]["UNKNOWN_TRANSLATION"];
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.message = error.message
|
|
52
|
-
.replace(match_regex, (value) => replacer(body, value));
|
|
46
|
+
this.name = error.name
|
|
47
|
+
.replace(match_regex, (value) => replacer(body, value));
|
|
53
48
|
|
|
49
|
+
this.message = error.message
|
|
50
|
+
.replace(match_regex, (value) => replacer(body, value));
|
|
51
|
+
}
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
}
|
package/src/errors.ts
CHANGED
|
@@ -1,101 +1,161 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface APIErrors {
|
|
2
2
|
// = general errors
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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_STRING': ExpectedAdditionalData;
|
|
18
|
+
'EXPECTED_A_NUMBER': ExpectedAdditionalData;
|
|
19
|
+
'EXPECTED_A_VALID_ID': ExpectedAdditionalData;
|
|
20
|
+
'DUPLICATED_VALUES_ISNT_ALLOWED': {};
|
|
15
21
|
// = oAuth errors
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
'GRANT_CODE_MISSING_IN_QUERY': {};
|
|
23
|
+
'INVALID_SCOPE': {};
|
|
24
|
+
'VERIFY_YOUR_EMAIL': {};
|
|
25
|
+
'PLEASE_REVERIFY': {};
|
|
20
26
|
// = user errors
|
|
21
|
-
|
|
27
|
+
'USER_NOT_FOUND': {};
|
|
22
28
|
/// password errors
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
'INVALID_PASSWORD': {};
|
|
30
|
+
'YOU_MUST_INSERT_THE_ACTUAL_PASSWORD': {};
|
|
31
|
+
'THE_PASSWORD_DOES_NOT_MATCH': {};
|
|
32
|
+
'THE_PASSWORD_MUST_HAVE_AT_LEAST_8_CHARACTERS': {};
|
|
33
|
+
'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_NUMBER': {};
|
|
34
|
+
'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_LETTER': {};
|
|
35
|
+
'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_SPECIAL_CHARACTER': {};
|
|
30
36
|
/// pix key errors
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
'THE_EMAIL_SENDED_ISNT_VALID': {};
|
|
38
|
+
'CELLPHONE_NUMBERS_MUST_HAVE_THE_9_DIGIT': {};
|
|
39
|
+
'THE_CELLPHONE_NUMBER_MUST_HAVE_ONLY_DIGITS': {};
|
|
40
|
+
'THE_PIX_KEY_INSERTED_ISNT_VALID': {};
|
|
35
41
|
/// webhook url error
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
'INSERT_A_VALID_URL': {};
|
|
43
|
+
'THE_ONLY_ACCEPTED_PROTOCOL_IS_HTTPS': {};
|
|
44
|
+
'THIS_DOMAIN_IS_BLACKLISTED': {};
|
|
45
|
+
'THE_URL_EXTENSION_ISNT_ACCEPTED_YET': {};
|
|
46
|
+
'THE_URL_IS_INACCESSIBLE_BY_THE_WEBHOOK_SERVER': {};
|
|
47
|
+
'THE_URL_WOULD_NOT_HAVE_REDIRECTS': {};
|
|
48
|
+
'THE_URL_HAS_TIMEOUT_5S': {};
|
|
43
49
|
/// payment errors
|
|
44
|
-
|
|
50
|
+
'INVALID_PAYMENT_METHOD': {};
|
|
45
51
|
// Order Errors
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
'YOU_NEED_TO_INSERT_AT_LEAST_1_ITEM': {};
|
|
53
|
+
'ONE_PROVIDED_PRODUCT_IS_OUT_OF_STOCK': {
|
|
54
|
+
name: string
|
|
55
|
+
};
|
|
56
|
+
'WE_DONT_HAVE_THIS_AMOUNT_IN_STOCK': {
|
|
57
|
+
name: string,
|
|
58
|
+
received: string | number,
|
|
59
|
+
available: string | number
|
|
60
|
+
};
|
|
61
|
+
'THIS_SELLER_WAS_BANNED_FROM_ZENNIFY': {};
|
|
62
|
+
'WE_DO_NOT_YET_SUPPORT_MULTIPLE_USER_PRODUCTS': {
|
|
63
|
+
name: string,
|
|
64
|
+
id: string | number
|
|
65
|
+
};
|
|
66
|
+
'WE_DO_NOT_YET_SUPPORT_MULTIPLE_STORE_PRODUCTS': {
|
|
67
|
+
name: string
|
|
68
|
+
id: string | number
|
|
69
|
+
};
|
|
70
|
+
'YOU_ALREADY_HAVE_ANOTHER_ORDER_WAITING_PAYMENT': {
|
|
71
|
+
id: string | number
|
|
72
|
+
};
|
|
73
|
+
'YOU_INSERTED_AN_INVALID_ADDITIONAL': {
|
|
74
|
+
addon: string
|
|
75
|
+
};
|
|
76
|
+
'UNKNOWN_ORDER': {}
|
|
77
|
+
'INVALID_OPERATION_FOR_CURRENT_TRANSACTION_STATUS': {}
|
|
78
|
+
'INVALID_OPERATION_FOR_PAYMENT_ENTITY': {}
|
|
54
79
|
/// bad preference configuration
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
80
|
+
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX': {};
|
|
81
|
+
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_BOLETO': {};
|
|
82
|
+
'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_CRYPTO': {};
|
|
58
83
|
/// coupons
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
84
|
+
'THIS_COUPON_DOES_NOT_EXISTS': {
|
|
85
|
+
received: string
|
|
86
|
+
};
|
|
87
|
+
'THIS_COUPON_HAS_EXPIRED': {};
|
|
88
|
+
'THIS_COUPON_REACHED_THE_USE_LIMIT': {};
|
|
89
|
+
'SELECT_MORE_ITENS_TO_REACH_MINIMUM_COUPON_VALUE': {
|
|
90
|
+
formated_value: string,
|
|
91
|
+
value: number
|
|
92
|
+
};
|
|
93
|
+
'THIS_COUPON_IS_VALID_ONLY_FOR_THE_FIRST_BUY': {};
|
|
64
94
|
// store errors
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
95
|
+
'UNKNOWN_STORE': {};
|
|
96
|
+
'UNKNOWN_BANK': {
|
|
97
|
+
received: string
|
|
98
|
+
};
|
|
99
|
+
'INVALID_STORE_NAME': {};
|
|
100
|
+
/// AUTOROLE
|
|
101
|
+
'UNKNOWN_AUTOROLE_RULE': {},
|
|
102
|
+
'AUTOROLE_RULE_ALREADY_EXISTS': {};
|
|
103
|
+
'YOU_REACHED_THE_AUTOROLE_RULE_LIMIT': {}
|
|
68
104
|
/// bot errors
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
105
|
+
'WAIT_OR_TRY_AGAIN_WITH_ANOTHER_DISCORD_BOT': {};
|
|
106
|
+
'INVALID_DISCORD_BOT_TOKEN': {};
|
|
107
|
+
'DISABLE_REQUIRE_CODE_GRANT': {};
|
|
108
|
+
'UNKNOWN_DISCORD_CHANNEL': {};
|
|
72
109
|
// product errors
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
110
|
+
'UNKNOWN_PRODUCT': {};
|
|
111
|
+
'INVALID_PRODUCT_NAME': {};
|
|
112
|
+
'INVALID_PRODUCT_VALUE': {};
|
|
113
|
+
'YOU_REACHED_THE_PRODUCT_LIMIT': {};
|
|
114
|
+
'PRODUCT_NAME_ALREADY_EXIST': {};
|
|
78
115
|
/// Description errors
|
|
79
|
-
|
|
116
|
+
'INVALID_PRODUCT_DESCRIPTION_FOR_DISCORD': {};
|
|
80
117
|
/// Stock errors
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
118
|
+
'UNKNOWN_STOCK': {};
|
|
119
|
+
'INVALID_STOCK_CONTENT': {};
|
|
120
|
+
'INVALID_STOCK_COST': {};
|
|
121
|
+
// coupon errors
|
|
122
|
+
'UNKNOWN_COUPON': {},
|
|
123
|
+
'INVALID_COUPON_NAME': {},
|
|
124
|
+
'INVALID_COUPON_TYPE': {},
|
|
125
|
+
'INVALID_COUPON_VALUE': {},
|
|
126
|
+
'INVALID_COUPON_AMOUNT': {},
|
|
127
|
+
'INVALID_COUPON_MIN_VALUE': {},
|
|
128
|
+
'INVALID_COUPON_EXPIRATION': {},
|
|
129
|
+
'INVALID_COUPON_MAX_USES_PER_USER': {}
|
|
130
|
+
'INVALID_COUPON_ONLY_FIRST_BUY': {},
|
|
131
|
+
'YOU_REACHED_THE_COUPON_LIMIT': {},
|
|
132
|
+
'COUPON_NAME_ALREADY_EXIST': {}
|
|
84
133
|
// Media Errors
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
134
|
+
'UNKNOWN_FILE': {};
|
|
135
|
+
'NO_FILES_FOUND': {};
|
|
136
|
+
'INVALID_FILE_TYPE': {};
|
|
137
|
+
'INVALID_FILE_NAME': {};
|
|
138
|
+
'INVALID_FILE_SIZE': {};
|
|
139
|
+
'YOU_REACHED_STORAGE_LIMIT': {};
|
|
140
|
+
'YOU_REACHED_MEDIA_LIMIT': {};
|
|
141
|
+
'YOU_ALREADY_HAVE_THIS_MEDIA': {};
|
|
142
|
+
'MEDIA_NAME_ALREADY_EXIST': {};
|
|
94
143
|
// Discord Panels Errors
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
144
|
+
'UNKNOWN_PANEL': {};
|
|
145
|
+
'INVALID_PANEL_NAME': {};
|
|
146
|
+
'INVALID_PANEL_DESCRIPTION': {};
|
|
147
|
+
'INVALID_PANEL_PLACEHOLDER': {};
|
|
148
|
+
'YOU_REACHED_PANEL_LIMIT': {};
|
|
149
|
+
'PANEL_NAME_ALREADY_EXIST': {};
|
|
150
|
+
'YOU_REACHED_THE_PRODUCT_LIMIT_ON_PANEL': {};
|
|
151
|
+
'STORE_ALREADY_CONFIGURED': {};
|
|
152
|
+
'MP_ACCOUNT_OFFLINE': {};
|
|
153
|
+
'MP_PIX_KEY_NOT_CONFIGURED': {}
|
|
154
|
+
'MP_NOT_ALLOWED_TO_SELL': {}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
type ExpectedAdditionalData = {
|
|
158
|
+
field: string;
|
|
159
|
+
received: any;
|
|
160
|
+
type: string
|
|
161
|
+
}
|
package/src/images.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface ImageSources {
|
|
2
|
+
void: void,
|
|
3
|
+
null: null,
|
|
4
|
+
empty: string,
|
|
5
|
+
product_icon: string,
|
|
6
|
+
general: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const template = `https://cdn.zennify.app/media/{store_id}/{id}.png`
|
|
10
|
+
const sources: Record<keyof ImageSources, ImageSources[keyof ImageSources]> = {
|
|
11
|
+
'product_icon': `https://zennify.app/assets/images/emojis/caixa.png`,
|
|
12
|
+
'general': `https://zennify.app/assets/images/icon.png`,
|
|
13
|
+
'void': void 0,
|
|
14
|
+
'null': null,
|
|
15
|
+
'empty': ""
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function GetImageURL<Source extends keyof ImageSources>(
|
|
19
|
+
source: Source,
|
|
20
|
+
store_id?: number | null,
|
|
21
|
+
id?: number | null
|
|
22
|
+
): ImageSources[Source] | string {
|
|
23
|
+
if (!store_id || !id) return sources[source] as ImageSources[Source];
|
|
24
|
+
else return template
|
|
25
|
+
.replace("{store_id}", store_id.toString())
|
|
26
|
+
.replace("{id}", id.toString());
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ChannelType } from 'discord.js';
|
|
2
|
+
|
|
3
|
+
export interface DiscordGuildChannel {
|
|
4
|
+
id: string,
|
|
5
|
+
name: string,
|
|
6
|
+
type: ChannelType
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface DiscordGuildRole {
|
|
10
|
+
id: string,
|
|
11
|
+
name: string,
|
|
12
|
+
position: number,
|
|
13
|
+
color: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface DiscordGuild {
|
|
17
|
+
id: string,
|
|
18
|
+
name: string,
|
|
19
|
+
icon_url: string,
|
|
20
|
+
owner_id: string,
|
|
21
|
+
channels: DiscordGuildChannel[]
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface PanelProduct {
|
|
2
|
+
id: number,
|
|
3
|
+
position: number,
|
|
4
|
+
emoji: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface Panel {
|
|
8
|
+
id: number,
|
|
9
|
+
name: string,
|
|
10
|
+
placeholder: string,
|
|
11
|
+
description: string | null,
|
|
12
|
+
icon_id: number | null,
|
|
13
|
+
banner_id: number | null,
|
|
14
|
+
products: PanelProduct[]
|
|
15
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface PartialProduct {
|
|
2
|
+
id: number,
|
|
3
|
+
name: string,
|
|
4
|
+
value: number,
|
|
5
|
+
icon_id: number | null,
|
|
6
|
+
banner_id: number | 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: string,
|
|
15
|
+
store_id: number,
|
|
16
|
+
owner_id: number,
|
|
17
|
+
icon_id?: null | number,
|
|
18
|
+
banner_id?: null | number,
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type Statistic = {
|
|
2
|
+
count: number,
|
|
3
|
+
users: number,
|
|
4
|
+
value: number,
|
|
5
|
+
rating: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type Statistics = Record<string, Record<number, Statistic>>
|
|
9
|
+
export type StatisticsResponse = {
|
|
10
|
+
last_update: string,
|
|
11
|
+
created_at: string
|
|
12
|
+
statistics: Statistics
|
|
13
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DiscordGuild } from "./Guild";
|
|
2
|
+
|
|
3
|
+
export type Addons = 'custom_bot' | 'divulgation' | 'antiraid' | 'managed_automod';
|
|
4
|
+
export type Banks = 'Banco Inter S.A.'
|
|
5
|
+
| 'Nu Pagamentos S.A.'
|
|
6
|
+
| 'Picpay Serviços S.A.'
|
|
7
|
+
| 'Mercadopago.com Representações Ltda.'
|
|
8
|
+
| 'Caixa Econômica Federal'
|
|
9
|
+
| 'PagSeguro Internet S.A.'
|
|
10
|
+
| 'Banco do Brasil S.A.'
|
|
11
|
+
| 'Banco Bradesco S.A.'
|
|
12
|
+
| 'Banco Santander (Brasil) S.A.';
|
|
13
|
+
|
|
14
|
+
export interface PartialStore {
|
|
15
|
+
id: number,
|
|
16
|
+
name: string,
|
|
17
|
+
expires_at: string,
|
|
18
|
+
icon_id?: number | null,
|
|
19
|
+
pending_setup?: boolean | null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface FullStore {
|
|
23
|
+
id: number,
|
|
24
|
+
name: string,
|
|
25
|
+
created_at: string,
|
|
26
|
+
expires_at: string,
|
|
27
|
+
owner_id: number,
|
|
28
|
+
icon_id: number | null,
|
|
29
|
+
banner_id: number | null,
|
|
30
|
+
addons: Addons[],
|
|
31
|
+
blocked_banks: Banks[],
|
|
32
|
+
pending_setup?: boolean | null,
|
|
33
|
+
discord_channels: Record<
|
|
34
|
+
string /** guild id */,
|
|
35
|
+
Record<
|
|
36
|
+
'sale' | 'voice' | 'feedback' | 'carts',
|
|
37
|
+
string | null | void /** channel id */
|
|
38
|
+
>
|
|
39
|
+
>,
|
|
40
|
+
discord_bot: {
|
|
41
|
+
id: string,
|
|
42
|
+
app_id: string | null,
|
|
43
|
+
token: string | null
|
|
44
|
+
},
|
|
45
|
+
discord_bot_guilds: Record<string, DiscordGuild>
|
|
46
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export * from './var';
|
|
2
2
|
export * from './errors';
|
|
3
3
|
export * from './utils';
|
|
4
|
-
export * from './RequestError';
|
|
4
|
+
export * from './RequestError';
|
|
5
|
+
export * from './images'
|
|
6
|
+
|
|
7
|
+
export * from './interfaces/Media';
|
|
8
|
+
export * from './interfaces/Panels';
|
|
9
|
+
export * from './interfaces/Products';
|
|
10
|
+
export * from './interfaces/Guild';
|
|
11
|
+
export * from './interfaces/Stores';
|
|
12
|
+
export * from './interfaces/Statistics';
|