@zennify/sdk-js 1.0.0-beta.8 → 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.
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
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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/dist/var.js CHANGED
@@ -1,4 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ZENNIFY_API_RESPONSE_LANGUAGE = void 0;
4
+ exports.SetAPIResponseLanguage = SetAPIResponseLanguage;
4
5
  exports.ZENNIFY_API_RESPONSE_LANGUAGE = 'en_US';
6
+ function SetAPIResponseLanguage(lang) {
7
+ return exports.ZENNIFY_API_RESPONSE_LANGUAGE = lang;
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zennify/sdk-js",
3
- "version": "1.0.0-beta.8",
3
+ "version": "1.0.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": {
@@ -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 {
package/src/errors.ts CHANGED
@@ -1,101 +1,160 @@
1
- export type APIErrors =
1
+ export interface APIErrors {
2
2
  // = general errors
3
- | 'UNKNOWN_ERROR'
4
- | 'UNKNOWN_TRANSLATION'
5
- | 'METHOD_NOT_ALLOWED'
6
- | 'EXPECTED_AN_OBJECT_ARRAY'
7
- | 'EXPECTED_A_STRING_ARRAY'
8
- | 'EXPECTED_A_NUMBER_ARRAY'
9
- | 'EXPECTED_AN_OBJECT'
10
- | 'EXPECTED_A_NON_EMPTY_OBJECT'
11
- | 'EXPECTED_A_STRING'
12
- | 'EXPECTED_A_NUMBER'
13
- | 'EXPECTED_A_VALID_ID'
14
- | 'DUPLICATED_VALUES_ISNT_ALLOWED'
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
- | 'GRANT_CODE_MISSING_IN_QUERY'
17
- | 'INVALID_SCOPE'
18
- | 'VERIFY_YOUR_EMAIL'
19
- | 'PLEASE_REVERIFY'
22
+ 'GRANT_CODE_MISSING_IN_QUERY': {};
23
+ 'INVALID_SCOPE': {};
24
+ 'VERIFY_YOUR_EMAIL': {};
25
+ 'PLEASE_REVERIFY': {};
20
26
  // = user errors
21
- | 'USER_NOT_FOUND'
27
+ 'USER_NOT_FOUND': {};
22
28
  /// password errors
23
- | 'INVALID_PASSWORD'
24
- | 'YOU_MUST_INSERT_THE_ACTUAL_PASSWORD'
25
- | 'THE_PASSWORD_DOES_NOT_MATCH'
26
- | 'THE_PASSWORD_MUST_HAVE_AT_LEAST_8_CHARACTERS'
27
- | 'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_NUMBER'
28
- | 'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_LETTER'
29
- | 'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_SPECIAL_CHARACTER'
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
- | 'THE_EMAIL_SENDED_ISNT_VALID'
32
- | 'CELLPHONE_NUMBERS_MUST_HAVE_THE_9_DIGIT'
33
- | 'THE_CELLPHONE_NUMBER_MUST_HAVE_ONLY_DIGITS'
34
- | 'THE_PIX_KEY_INSERTED_ISNT_VALID'
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
- | 'INSERT_A_VALID_URL'
37
- | 'THE_ONLY_ACCEPTED_PROTOCOL_IS_HTTPS'
38
- | 'THIS_DOMAIN_IS_BLACKLISTED'
39
- | 'THE_URL_EXTENSION_ISNT_ACCEPTED_YET'
40
- | 'THE_URL_IS_INACCESSIBLE_BY_THE_WEBHOOK_SERVER'
41
- | 'THE_URL_WOULD_NOT_HAVE_REDIRECTS'
42
- | 'THE_URL_HAS_TIMEOUT_5S'
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
- | 'INVALID_PAYMENT_METHOD'
50
+ 'INVALID_PAYMENT_METHOD': {};
45
51
  // Order Errors
46
- | 'YOU_NEED_TO_INSERT_AT_LEAST_1_ITEM'
47
- | 'ONE_PROVIDED_PRODUCT_IS_OUT_OF_STOCK'
48
- | 'WE_DONT_HAVE_THIS_AMOUNT_IN_STOCK'
49
- | 'THIS_SELLER_WAS_BANNED_FROM_ZENNIFY'
50
- | 'WE_DO_NOT_YET_SUPPORT_MULTIPLE_USER_PRODUCTS'
51
- | 'WE_DO_NOT_YET_SUPPORT_MULTIPLE_STORE_PRODUCTS'
52
- | 'YOU_ALREADY_HAVE_ANOTHER_ORDER_WAITING_PAYMENT'
53
- | 'YOU_INSERTED_AN_INVALID_ADDITIONAL'
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
- | 'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX'
56
- | 'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_BOLETO'
57
- | 'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_CRYPTO'
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
- | 'THIS_COUPON_DOES_NOT_EXISTS'
60
- | 'THIS_COUPON_HAS_EXPIRED'
61
- | 'THIS_COUPON_REACHED_THE_USE_LIMIT'
62
- | 'SELECT_MORE_ITENS_TO_REACH_MINIMUM_COUPON_VALUE'
63
- | 'THIS_COUPON_IS_VALID_ONLY_FOR_THE_FIRST_BUY'
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
- | 'UNKNOWN_STORE'
66
- | 'UNKNOWN_BANK'
67
- | 'INVALID_STORE_NAME'
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
- | 'WAIT_OR_TRY_AGAIN_WITH_ANOTHER_DISCORD_BOT'
70
- | 'INVALID_DISCORD_BOT_TOKEN'
71
- | 'DISABLE_REQUIRE_CODE_GRANT'
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
- | 'UNKNOWN_PRODUCT'
74
- | 'INVALID_PRODUCT_NAME'
75
- | 'INVALID_PRODUCT_VALUE'
76
- | 'YOU_REACHED_THE_PRODUCT_LIMIT'
77
- | 'PRODUCT_NAME_ALREADY_EXIST'
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
- | 'INVALID_PRODUCT_DESCRIPTION_FOR_DISCORD'
116
+ 'INVALID_PRODUCT_DESCRIPTION_FOR_DISCORD': {};
80
117
  /// Stock errors
81
- | 'UNKNOWN_STOCK'
82
- | 'INVALID_STOCK_CONTENT'
83
- | 'INVALID_STOCK_COST'
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
- | 'UNKNOWN_FILE'
86
- | 'NO_FILES_FOUND'
87
- | 'INVALID_FILE_TYPE'
88
- | 'INVALID_FILE_NAME'
89
- | 'INVALID_FILE_SIZE'
90
- | 'YOU_REACHED_STORAGE_LIMIT'
91
- | 'YOU_REACHED_MEDIA_LIMIT'
92
- | 'YOU_ALREADY_HAVE_THIS_MEDIA'
93
- | 'MEDIA_NAME_ALREADY_EXIST'
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
- | 'UNKNOWN_PANEL'
96
- | 'INVALID_PANEL_NAME'
97
- | 'INVALID_PANEL_DESCRIPTION'
98
- | 'INVALID_PANEL_PLACEHOLDER'
99
- | 'YOU_REACHED_PANEL_LIMIT'
100
- | 'PANEL_NAME_ALREADY_EXIST'
101
- | 'YOU_REACHED_THE_PRODUCT_LIMIT_ON_PANEL'
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
+ }
155
+
156
+ type ExpectedAdditionalData = {
157
+ field: string;
158
+ received: any;
159
+ type: string
160
+ }
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,6 @@
1
+ export interface Medium {
2
+ id: number,
3
+ name: string,
4
+ size: number,
5
+ mime_type: string,
6
+ }
@@ -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';
package/src/utils.ts CHANGED
@@ -1,31 +1,14 @@
1
1
  import { ZennifyAPIRequestError } from './RequestError';
2
2
  import { APIErrors } from './errors';
3
3
 
4
- type ExpectedErrorAdditional = { field: string; received: any; type: string }
5
- type ExpectedError = Extract<
6
- APIErrors,
7
- | 'EXPECTED_AN_OBJECT_ARRAY'
8
- | 'EXPECTED_A_STRING_ARRAY'
9
- | 'EXPECTED_A_NUMBER_ARRAY'
10
- | 'EXPECTED_AN_OBJECT'
11
- | 'EXPECTED_A_NON_EMPTY_OBJECT'
12
- | 'EXPECTED_A_STRING'
13
- | 'EXPECTED_A_NUMBER'
14
- | 'EXPECTED_A_VALID_ID'
15
- >;
16
-
17
- type CommonError = Exclude<APIErrors, ExpectedError>;
18
-
19
- export function GetResponseError(code: CommonError): { code: CommonError };
20
- export function GetResponseError(code: ExpectedError, additional: ExpectedErrorAdditional): { code: ExpectedError } & ExpectedErrorAdditional;
21
- export function GetResponseError<T extends object>(code: CommonError, additional?: T): { code: CommonError } & T;
22
- export function GetResponseError(code: APIErrors, additional: any = {}) {
23
- return { code, ...additional };
24
- }
4
+ export function GetResponseError<Code extends keyof APIErrors>(
5
+ code: Code,
6
+ additional: APIErrors[Code]
7
+ ) { return { code, ...additional }; }
25
8
 
26
9
  export async function TreatZennifyResponse<T extends any>(response: Response): Promise<T> {
27
10
 
28
- const body = await response.json();
11
+ const body = await response.json().catch(() => ({}));
29
12
 
30
13
  if (response.ok) {
31
14
  return body as T;
@@ -33,4 +16,4 @@ export async function TreatZennifyResponse<T extends any>(response: Response): P
33
16
 
34
17
  throw new ZennifyAPIRequestError(response, body);
35
18
 
36
- }
19
+ }
package/src/var.ts CHANGED
@@ -1,3 +1,5 @@
1
- type Languages = 'pt_BR' | 'en_US';
2
-
3
- export let ZENNIFY_API_RESPONSE_LANGUAGE: Languages = 'en_US';
1
+ export type SupportedLanguages = 'pt_BR' | 'en_US';
2
+ export let ZENNIFY_API_RESPONSE_LANGUAGE: SupportedLanguages = 'en_US';
3
+ export function SetAPIResponseLanguage(lang: SupportedLanguages) {
4
+ return ZENNIFY_API_RESPONSE_LANGUAGE = lang;
5
+ }
@@ -3,6 +3,10 @@
3
3
  "name": "An unknown error occurred.",
4
4
  "message": "Contact support with ID {id}"
5
5
  },
6
+ "MISSING_PERMISSIONS": {
7
+ "name": "You don't have permission to do this operation",
8
+ "message": "Verify your permissions"
9
+ },
6
10
  "UNKNOWN_TRANSLATION": {
7
11
  "name": "{code} not yet translated",
8
12
  "message": "Contact support."
@@ -43,6 +47,10 @@
43
47
  "name": "Expected a valid ID",
44
48
  "message": "IDs must be integers between 0 and 2.147.483.647"
45
49
  },
50
+ "STORE_ALREADY_CONFIGURED": {
51
+ "name": "This store is already configured",
52
+ "message": "Go back to dashboard and access the store again"
53
+ },
46
54
  "DUPLICATED_VALUES_ISNT_ALLOWED": {
47
55
  "name": "Duplicated values aren't allowed",
48
56
  "message": "Received \"{received}\", Check \"{field}\" field"
@@ -175,6 +183,26 @@
175
183
  "name": "You inserted an invalid additional",
176
184
  "message": "Remove the additional \"{addon}\"."
177
185
  },
186
+ "UNKNOWN_ORDER": {
187
+ "name": "Order not found.",
188
+ "message": "Check if the ID is correct."
189
+ },
190
+ "MP_ACCOUNT_OFFLINE": {
191
+ "name": "Unable to generate an order",
192
+ "message": "It appears that this Mercado Pago account is offline."
193
+ },
194
+ "MP_PIX_KEY_NOT_CONFIGURED": {
195
+ "name": "PIX key not configured",
196
+ "message": "The seller must configure a PIX key in Mercado Pago."
197
+ },
198
+ "INVALID_OPERATION_FOR_CURRENT_TRANSACTION_STATUS": {
199
+ "name": "Invalid operation for this transaction.",
200
+ "message": "The current status doesn't allow this operation."
201
+ },
202
+ "INVALID_OPERATION_FOR_PAYMENT_ENTITY": {
203
+ "name": "This payment entity doesn't support this operation",
204
+ "message": "Try using another payment entity or check the request"
205
+ },
178
206
  "THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX": {
179
207
  "name": "This seller has not yet configured receipt via PIX",
180
208
  "message": "Choose another method or wait for seller configuration."
@@ -197,7 +225,7 @@
197
225
  },
198
226
  "THIS_COUPON_HAS_EXPIRED": {
199
227
  "name": "This coupon has expired",
200
- "message": "Use a valid coupon."
228
+ "message": "Try using another coupon."
201
229
  },
202
230
  "THIS_COUPON_REACHED_THE_USE_LIMIT": {
203
231
  "name": "This coupon reached the use limit",
@@ -223,6 +251,18 @@
223
251
  "name": "Invalid store name",
224
252
  "message": "The name must be up to 50 characters"
225
253
  },
254
+ "UNKNOWN_AUTOROLE_RULE": {
255
+ "name": "Unknown Discord autorole rule",
256
+ "message": "Try to create a new rule"
257
+ },
258
+ "AUTOROLE_RULE_ALREADY_EXISTS": {
259
+ "name": "An automatic role rule already exists for this role!",
260
+ "message": "Use the update route."
261
+ },
262
+ "YOU_REACHED_THE_AUTOROLE_RULE_LIMIT": {
263
+ "name": "You have reached the limit of automatic roles!",
264
+ "message": "Try deleting the ones you no longer use."
265
+ },
226
266
  "WAIT_OR_TRY_AGAIN_WITH_ANOTHER_DISCORD_BOT": {
227
267
  "name": "Wait or try again with another BOT",
228
268
  "message": "Your actions are being limited"
@@ -235,6 +275,14 @@
235
275
  "name": "Disable \"Require code grant\"",
236
276
  "message": "With it enabled, you won't be able to invite the bot."
237
277
  },
278
+ "UNKNOWN_DISCORD_CHANNEL": {
279
+ "name": "Unknown Discord channel",
280
+ "message": "Perhaps this channel no longer exists."
281
+ },
282
+ "INVALID_DISCORD_CHANNEL_FOR_MESSAGE": {
283
+ "name": "Invalid channel for messages",
284
+ "message": "The selected channel doesn't support messages"
285
+ },
238
286
  "UNKNOWN_PRODUCT": {
239
287
  "name": "Unknown product",
240
288
  "message": "Perhaps this product no longer exists."
@@ -271,6 +319,50 @@
271
319
  "name": "Invalid item cost",
272
320
  "message": "It must be between R$ 0.00 and R$ 999,999.00"
273
321
  },
322
+ "UNKNOWN_COUPON": {
323
+ "name": "Unknown coupon",
324
+ "message": "Perhaps this coupon no longer exists."
325
+ },
326
+ "INVALID_COUPON_NAME": {
327
+ "name": "Invalid coupon name",
328
+ "message": "Must consist only of letters and numbers"
329
+ },
330
+ "INVALID_COUPON_TYPE": {
331
+ "name": "Invalid coupon type",
332
+ "message": "Must be either 'value' or 'percentage'"
333
+ },
334
+ "INVALID_COUPON_VALUE": {
335
+ "name": "Invalid coupon value",
336
+ "message": "Must be between 0% and 100% for percentage and R$ 0.00 and R$ 999,999 for value"
337
+ },
338
+ "INVALID_COUPON_AMOUNT": {
339
+ "name": "Invalid coupon amount",
340
+ "message": "Must be a number between 0 and 32,768"
341
+ },
342
+ "INVALID_COUPON_MIN_VALUE": {
343
+ "name": "Invalid minimum coupon value",
344
+ "message": "Must be between R$ 0.00 and R$ 999,999.00"
345
+ },
346
+ "INVALID_COUPON_EXPIRATION": {
347
+ "name": "Invalid coupon expiration",
348
+ "message": "Must be a future date or 0 (Never expires)"
349
+ },
350
+ "INVALID_COUPON_MAX_USES_PER_USER": {
351
+ "name": "Invalid maximum uses per coupon",
352
+ "message": "Must be a number between 0 and 32,768"
353
+ },
354
+ "INVALID_COUPON_ONLY_FIRST_BUY": {
355
+ "name": "Invalid first purchase coupon setting",
356
+ "message": "Must be a boolean type (true or false)"
357
+ },
358
+ "YOU_REACHED_THE_COUPON_LIMIT": {
359
+ "name": "You have reached the coupon limit for this store",
360
+ "message": "Try deleting coupons you no longer use"
361
+ },
362
+ "COUPON_NAME_ALREADY_EXIST": {
363
+ "name": "You already have a coupon with this name",
364
+ "message": "Try setting a different name"
365
+ },
274
366
  "UNKNOWN_FILE": {
275
367
  "name": "Unknown file",
276
368
  "message": "Perhaps it has already been deleted"
@@ -3,6 +3,10 @@
3
3
  "name": "Um erro deconhecido ocorreu.",
4
4
  "message": "Contate o suporte com o ID {id}"
5
5
  },
6
+ "MISSING_PERMISSIONS": {
7
+ "name": "Você não tem permissão para realizar essa operação.",
8
+ "message": "Verifique as suas permissões."
9
+ },
6
10
  "UNKNOWN_TRANSLATION": {
7
11
  "name": "{code} não traduzido ainda",
8
12
  "message": "Entre em contato com o suporte."
@@ -175,41 +179,65 @@
175
179
  "name": "Adicional inválido",
176
180
  "message": "Remova o adicional \"{addon}\"."
177
181
  },
182
+ "UNKNOWN_ORDER": {
183
+ "name": "Pedido não encontrado.",
184
+ "message": "Verifique o ID enviado."
185
+ },
186
+ "MP_ACCOUNT_OFFLINE": {
187
+ "name": "Não foi possível gerar um pedido",
188
+ "message": "Aparentemente essa conta do Mercado Pago está inoperante."
189
+ },
190
+ "MP_PIX_KEY_NOT_CONFIGURED": {
191
+ "name": "Chave PIX não configurada",
192
+ "message": "O vendedor deve configurar uma chave pix no Mercado Pago."
193
+ },
194
+ "INVALID_OPERATION_FOR_CURRENT_TRANSACTION_STATUS": {
195
+ "name": "Operação inválida para essa transação.",
196
+ "message": "O estado atual não permite que a operação seja realizada."
197
+ },
198
+ "INVALID_OPERATION_FOR_PAYMENT_ENTITY": {
199
+ "name": "Essa entidade de pagamento não suporta essa operação",
200
+ "message": "Tente usando uma outra entidade de pagamento"
201
+ },
178
202
  "THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX": {
179
- "name": "Pix não configurado",
203
+ "name": "O vendedor não configurou o recebimento via Pix",
180
204
  "message": "Escolha outro método ou aguarde a configuração do vendedor."
181
205
  },
182
206
  "THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_BOLETO": {
183
- "name": "Boleto não configurado",
207
+ "name": "O vendedor não configurou o recebimento via Boleto",
184
208
  "message": "Escolha outro método ou aguarde a configuração do vendedor."
185
209
  },
186
210
  "THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_CRYPTO": {
187
- "name": "Cripto não configurado",
211
+ "name": "O vendedor não configurou o recebimento via Cripto",
188
212
  "message": "Escolha outro método ou aguarde a configuração do vendedor."
189
213
  },
190
214
  "THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_VISA": {
191
- "name": "Visa não configurado",
215
+ "name": "O vendedor não configurou o recebimento via Visa",
192
216
  "message": "Escolha outro método ou aguarde a configuração do vendedor."
193
217
  },
194
218
  "THIS_COUPON_DOES_NOT_EXISTS": {
195
- "name": "O cupom \"{name}\" não existe",
219
+ "name": "O cupom \"{received}\" não existe",
196
220
  "message": "Verifique o código do cupom."
197
221
  },
198
222
  "THIS_COUPON_HAS_EXPIRED": {
199
- "name": "Cupom expirado",
200
- "message": "Use um cupom válido."
223
+ "name": "O cupom inserido está expirado",
224
+ "message": "Tente usar outro cupom."
225
+ },
226
+ "STORE_ALREADY_CONFIGURED": {
227
+ "name": "Essa loja já foi configurada",
228
+ "message": "Volte para a dashboard e acesse a loja normalmente"
201
229
  },
202
230
  "THIS_COUPON_REACHED_THE_USE_LIMIT": {
203
231
  "name": "O cupom atingiu o limite de usos",
204
- "message": "Tente novamente depois."
232
+ "message": "Tente usar um cupom diferente."
205
233
  },
206
234
  "SELECT_MORE_ITENS_TO_REACH_MINIMUM_COUPON_VALUE": {
207
235
  "name": "Adicione mais itens pra atingir o valor mínimo do cupom",
208
- "message": "O valor mínimo para usar esse cupom é de {value}."
236
+ "message": "O valor mínimo para usar esse cupom é de {formated_value}."
209
237
  },
210
238
  "THIS_COUPON_IS_VALID_ONLY_FOR_THE_FIRST_BUY": {
211
239
  "name": "Cupom válido apenas para a primeira compra",
212
- "message": "Cupom válido apenas na primeira compra."
240
+ "message": "Tente usar um cupom diferente desse."
213
241
  },
214
242
  "UNKNOWN_STORE": {
215
243
  "name": "Loja desconhecida",
@@ -217,12 +245,24 @@
217
245
  },
218
246
  "UNKNOWN_BANK": {
219
247
  "name": "Banco não suportado",
220
- "message": "Ainda não suportamos o banco \"{bank}\""
248
+ "message": "Ainda não suportamos o banco \"{received}\""
221
249
  },
222
250
  "INVALID_STORE_NAME": {
223
251
  "name": "Nome de loja inválido",
224
252
  "message": "O nome deve ter até 50 caracteres"
225
253
  },
254
+ "UNKNOWN_AUTOROLE_RULE": {
255
+ "name": "Regra de cargo automático desconhecida",
256
+ "message": "Tente criar uma nova regra"
257
+ },
258
+ "AUTOROLE_RULE_ALREADY_EXISTS": {
259
+ "name": "Já existe uma regra de cargo automático pra esse cargo!",
260
+ "message": "Use a rota de alteração."
261
+ },
262
+ "YOU_REACHED_THE_AUTOROLE_RULE_LIMIT": {
263
+ "name": "Você já atingiu o limite de cargos automáticos!",
264
+ "message": "Tente apagar os que você não usa mais"
265
+ },
226
266
  "WAIT_OR_TRY_AGAIN_WITH_ANOTHER_DISCORD_BOT": {
227
267
  "name": "Aguarde ou tente novamente com outro BOT",
228
268
  "message": "Sua ações estão sendo limitadas"
@@ -235,6 +275,14 @@
235
275
  "name": "Desabilite o \"Require code grant\"",
236
276
  "message": "Com ele ativado você não conseguirá convidar o bot"
237
277
  },
278
+ "UNKNOWN_DISCORD_CHANNEL": {
279
+ "name": "Canal do Discord desconhecido",
280
+ "message": "Talvez esse canal não exista mais."
281
+ },
282
+ "INVALID_DISCORD_CHANNEL_FOR_MESSAGE": {
283
+ "name": "Canal inválido para envio",
284
+ "message": "O canal selecionado não suporta mensagens"
285
+ },
238
286
  "UNKNOWN_PRODUCT": {
239
287
  "name": "Produto desconhecido",
240
288
  "message": "Talvez esse produto não exista mais."
@@ -271,6 +319,50 @@
271
319
  "name": "O custo do item é inválido",
272
320
  "message": "Deve ser entre R$ 0.00 e R$ 999.999,00"
273
321
  },
322
+ "UNKNOWN_COUPON": {
323
+ "name": "Cupom desconhecido",
324
+ "message": "Talvez esse cupom não exista mais."
325
+ },
326
+ "INVALID_COUPON_NAME": {
327
+ "name": "Nome do cupom inválido",
328
+ "message": "Deve ser composto apenas de letras e números"
329
+ },
330
+ "INVALID_COUPON_TYPE": {
331
+ "name": "Tipo do cupom inválido",
332
+ "message": "Deve ser valor ou porcentagem"
333
+ },
334
+ "INVALID_COUPON_VALUE": {
335
+ "name": "Valor do cupom inválido",
336
+ "message": "Deve ser entre 0% e 100% pra porcentagem e R$ 0.00 e R$ 999.999 pra valor"
337
+ },
338
+ "INVALID_COUPON_AMOUNT": {
339
+ "name": "Quantidade de cupons inválida",
340
+ "message": "Deve ser um número entre 0 e 32768"
341
+ },
342
+ "INVALID_COUPON_MIN_VALUE": {
343
+ "name": "Valor mínimo do cupom inválido",
344
+ "message": "Deve ser entre R$ 0.00 e R$ 999.999,00"
345
+ },
346
+ "INVALID_COUPON_EXPIRATION": {
347
+ "name": "Expiração do cupom inválido",
348
+ "message": "Deve ser uma data futura ou 0 (Nunca expira)"
349
+ },
350
+ "INVALID_COUPON_MAX_USES_PER_USER": {
351
+ "name": "Uso máximo por cupom inválido",
352
+ "message": "Deve ser um número entre 0 e 32768"
353
+ },
354
+ "INVALID_COUPON_ONLY_FIRST_BUY": {
355
+ "name": "Configuração de primeira compra cupom inválida",
356
+ "message": "Deve ser um tipo booleano (verdadeiro ou falso)"
357
+ },
358
+ "YOU_REACHED_THE_COUPON_LIMIT": {
359
+ "name": "Você atingiu o limite de cupons nessa loja",
360
+ "message": "Tente apagar cupons que você não usa mais"
361
+ },
362
+ "COUPON_NAME_ALREADY_EXIST": {
363
+ "name": "Você já tem um cupom com esse nome",
364
+ "message": "Tente configurar um nome diferente"
365
+ },
274
366
  "UNKNOWN_FILE": {
275
367
  "name": "Imagem desconhecida",
276
368
  "message": "Talvez ela já tenha sido apagada"
@@ -329,7 +421,7 @@
329
421
  },
330
422
  "PANEL_NAME_ALREADY_EXIST": {
331
423
  "name": "Você já possui outro painel com este nome",
332
- "message": "Tente alterar o nome"
424
+ "message": "Tente alterar o nome do painel"
333
425
  },
334
426
  "YOU_REACHED_THE_PRODUCT_LIMIT_ON_PANEL": {
335
427
  "name": "Você atingiu o limite de produtos no painel",
@@ -1,6 +1,6 @@
1
1
  import { APIErrors } from './errors';
2
2
  type Body = Record<string, any> & {
3
- code: APIErrors;
3
+ code: keyof APIErrors;
4
4
  };
5
5
  export declare class ZennifyAPIRequestError extends Error {
6
6
  status: number;
package/types/errors.d.ts CHANGED
@@ -1 +1,141 @@
1
- export type APIErrors = 'UNKNOWN_ERROR' | 'UNKNOWN_TRANSLATION' | 'METHOD_NOT_ALLOWED' | 'EXPECTED_AN_OBJECT_ARRAY' | 'EXPECTED_A_STRING_ARRAY' | 'EXPECTED_A_NUMBER_ARRAY' | 'EXPECTED_AN_OBJECT' | 'EXPECTED_A_NON_EMPTY_OBJECT' | 'EXPECTED_A_STRING' | 'EXPECTED_A_NUMBER' | 'EXPECTED_A_VALID_ID' | 'DUPLICATED_VALUES_ISNT_ALLOWED' | 'GRANT_CODE_MISSING_IN_QUERY' | 'INVALID_SCOPE' | 'VERIFY_YOUR_EMAIL' | 'PLEASE_REVERIFY' | 'USER_NOT_FOUND' | 'INVALID_PASSWORD' | 'YOU_MUST_INSERT_THE_ACTUAL_PASSWORD' | 'THE_PASSWORD_DOES_NOT_MATCH' | 'THE_PASSWORD_MUST_HAVE_AT_LEAST_8_CHARACTERS' | 'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_NUMBER' | 'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_LETTER' | 'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_SPECIAL_CHARACTER' | 'THE_EMAIL_SENDED_ISNT_VALID' | 'CELLPHONE_NUMBERS_MUST_HAVE_THE_9_DIGIT' | 'THE_CELLPHONE_NUMBER_MUST_HAVE_ONLY_DIGITS' | 'THE_PIX_KEY_INSERTED_ISNT_VALID' | 'INSERT_A_VALID_URL' | 'THE_ONLY_ACCEPTED_PROTOCOL_IS_HTTPS' | 'THIS_DOMAIN_IS_BLACKLISTED' | 'THE_URL_EXTENSION_ISNT_ACCEPTED_YET' | 'THE_URL_IS_INACCESSIBLE_BY_THE_WEBHOOK_SERVER' | 'THE_URL_WOULD_NOT_HAVE_REDIRECTS' | 'THE_URL_HAS_TIMEOUT_5S' | 'INVALID_PAYMENT_METHOD' | 'YOU_NEED_TO_INSERT_AT_LEAST_1_ITEM' | 'ONE_PROVIDED_PRODUCT_IS_OUT_OF_STOCK' | 'WE_DONT_HAVE_THIS_AMOUNT_IN_STOCK' | 'THIS_SELLER_WAS_BANNED_FROM_ZENNIFY' | 'WE_DO_NOT_YET_SUPPORT_MULTIPLE_USER_PRODUCTS' | 'WE_DO_NOT_YET_SUPPORT_MULTIPLE_STORE_PRODUCTS' | 'YOU_ALREADY_HAVE_ANOTHER_ORDER_WAITING_PAYMENT' | 'YOU_INSERTED_AN_INVALID_ADDITIONAL' | 'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX' | 'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_BOLETO' | 'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_CRYPTO' | 'THIS_COUPON_DOES_NOT_EXISTS' | 'THIS_COUPON_HAS_EXPIRED' | 'THIS_COUPON_REACHED_THE_USE_LIMIT' | 'SELECT_MORE_ITENS_TO_REACH_MINIMUM_COUPON_VALUE' | 'THIS_COUPON_IS_VALID_ONLY_FOR_THE_FIRST_BUY' | 'UNKNOWN_STORE' | 'UNKNOWN_BANK' | 'INVALID_STORE_NAME' | 'WAIT_OR_TRY_AGAIN_WITH_ANOTHER_DISCORD_BOT' | 'INVALID_DISCORD_BOT_TOKEN' | 'DISABLE_REQUIRE_CODE_GRANT' | 'UNKNOWN_PRODUCT' | 'INVALID_PRODUCT_NAME' | 'INVALID_PRODUCT_VALUE' | 'YOU_REACHED_THE_PRODUCT_LIMIT' | 'PRODUCT_NAME_ALREADY_EXIST' | 'INVALID_PRODUCT_DESCRIPTION_FOR_DISCORD' | 'UNKNOWN_STOCK' | 'INVALID_STOCK_CONTENT' | 'INVALID_STOCK_COST' | 'UNKNOWN_FILE' | 'NO_FILES_FOUND' | 'INVALID_FILE_TYPE' | 'INVALID_FILE_NAME' | 'INVALID_FILE_SIZE' | 'YOU_REACHED_STORAGE_LIMIT' | 'YOU_REACHED_MEDIA_LIMIT' | 'YOU_ALREADY_HAVE_THIS_MEDIA' | 'MEDIA_NAME_ALREADY_EXIST' | 'UNKNOWN_PANEL' | 'INVALID_PANEL_NAME' | 'INVALID_PANEL_DESCRIPTION' | 'INVALID_PANEL_PLACEHOLDER' | 'YOU_REACHED_PANEL_LIMIT' | 'PANEL_NAME_ALREADY_EXIST' | 'YOU_REACHED_THE_PRODUCT_LIMIT_ON_PANEL';
1
+ export interface APIErrors {
2
+ 'UNKNOWN_ERROR': {
3
+ id: string | number;
4
+ };
5
+ 'UNKNOWN_TRANSLATION': {
6
+ code: keyof APIErrors | string;
7
+ };
8
+ 'INVALID_DISCORD_CHANNEL_FOR_MESSAGE': {};
9
+ 'MISSING_PERMISSIONS': {};
10
+ 'METHOD_NOT_ALLOWED': {};
11
+ 'EXPECTED_AN_OBJECT_ARRAY': ExpectedAdditionalData;
12
+ 'EXPECTED_A_STRING_ARRAY': ExpectedAdditionalData;
13
+ 'EXPECTED_A_NUMBER_ARRAY': ExpectedAdditionalData;
14
+ 'EXPECTED_AN_OBJECT': ExpectedAdditionalData;
15
+ 'EXPECTED_A_NON_EMPTY_OBJECT': ExpectedAdditionalData;
16
+ 'EXPECTED_A_STRING': ExpectedAdditionalData;
17
+ 'EXPECTED_A_NUMBER': ExpectedAdditionalData;
18
+ 'EXPECTED_A_VALID_ID': ExpectedAdditionalData;
19
+ 'DUPLICATED_VALUES_ISNT_ALLOWED': {};
20
+ 'GRANT_CODE_MISSING_IN_QUERY': {};
21
+ 'INVALID_SCOPE': {};
22
+ 'VERIFY_YOUR_EMAIL': {};
23
+ 'PLEASE_REVERIFY': {};
24
+ 'USER_NOT_FOUND': {};
25
+ 'INVALID_PASSWORD': {};
26
+ 'YOU_MUST_INSERT_THE_ACTUAL_PASSWORD': {};
27
+ 'THE_PASSWORD_DOES_NOT_MATCH': {};
28
+ 'THE_PASSWORD_MUST_HAVE_AT_LEAST_8_CHARACTERS': {};
29
+ 'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_NUMBER': {};
30
+ 'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_LETTER': {};
31
+ 'THE_PASSWORD_MUST_HAVE_AT_LEAST_ONE_SPECIAL_CHARACTER': {};
32
+ 'THE_EMAIL_SENDED_ISNT_VALID': {};
33
+ 'CELLPHONE_NUMBERS_MUST_HAVE_THE_9_DIGIT': {};
34
+ 'THE_CELLPHONE_NUMBER_MUST_HAVE_ONLY_DIGITS': {};
35
+ 'THE_PIX_KEY_INSERTED_ISNT_VALID': {};
36
+ 'INSERT_A_VALID_URL': {};
37
+ 'THE_ONLY_ACCEPTED_PROTOCOL_IS_HTTPS': {};
38
+ 'THIS_DOMAIN_IS_BLACKLISTED': {};
39
+ 'THE_URL_EXTENSION_ISNT_ACCEPTED_YET': {};
40
+ 'THE_URL_IS_INACCESSIBLE_BY_THE_WEBHOOK_SERVER': {};
41
+ 'THE_URL_WOULD_NOT_HAVE_REDIRECTS': {};
42
+ 'THE_URL_HAS_TIMEOUT_5S': {};
43
+ 'INVALID_PAYMENT_METHOD': {};
44
+ 'YOU_NEED_TO_INSERT_AT_LEAST_1_ITEM': {};
45
+ 'ONE_PROVIDED_PRODUCT_IS_OUT_OF_STOCK': {
46
+ name: string;
47
+ };
48
+ 'WE_DONT_HAVE_THIS_AMOUNT_IN_STOCK': {
49
+ name: string;
50
+ received: string | number;
51
+ available: string | number;
52
+ };
53
+ 'THIS_SELLER_WAS_BANNED_FROM_ZENNIFY': {};
54
+ 'WE_DO_NOT_YET_SUPPORT_MULTIPLE_USER_PRODUCTS': {
55
+ name: string;
56
+ id: string | number;
57
+ };
58
+ 'WE_DO_NOT_YET_SUPPORT_MULTIPLE_STORE_PRODUCTS': {
59
+ name: string;
60
+ id: string | number;
61
+ };
62
+ 'YOU_ALREADY_HAVE_ANOTHER_ORDER_WAITING_PAYMENT': {
63
+ id: string | number;
64
+ };
65
+ 'YOU_INSERTED_AN_INVALID_ADDITIONAL': {
66
+ addon: string;
67
+ };
68
+ 'UNKNOWN_ORDER': {};
69
+ 'INVALID_OPERATION_FOR_CURRENT_TRANSACTION_STATUS': {};
70
+ 'INVALID_OPERATION_FOR_PAYMENT_ENTITY': {};
71
+ 'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_PIX': {};
72
+ 'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_BOLETO': {};
73
+ 'THIS_SELLER_HAS_NOT_YET_CONFIGURED_RECEIPT_VIA_CRYPTO': {};
74
+ 'THIS_COUPON_DOES_NOT_EXISTS': {
75
+ received: string;
76
+ };
77
+ 'THIS_COUPON_HAS_EXPIRED': {};
78
+ 'THIS_COUPON_REACHED_THE_USE_LIMIT': {};
79
+ 'SELECT_MORE_ITENS_TO_REACH_MINIMUM_COUPON_VALUE': {
80
+ formated_value: string;
81
+ value: number;
82
+ };
83
+ 'THIS_COUPON_IS_VALID_ONLY_FOR_THE_FIRST_BUY': {};
84
+ 'UNKNOWN_STORE': {};
85
+ 'UNKNOWN_BANK': {
86
+ received: string;
87
+ };
88
+ 'INVALID_STORE_NAME': {};
89
+ 'UNKNOWN_AUTOROLE_RULE': {};
90
+ 'AUTOROLE_RULE_ALREADY_EXISTS': {};
91
+ 'YOU_REACHED_THE_AUTOROLE_RULE_LIMIT': {};
92
+ 'WAIT_OR_TRY_AGAIN_WITH_ANOTHER_DISCORD_BOT': {};
93
+ 'INVALID_DISCORD_BOT_TOKEN': {};
94
+ 'DISABLE_REQUIRE_CODE_GRANT': {};
95
+ 'UNKNOWN_DISCORD_CHANNEL': {};
96
+ 'UNKNOWN_PRODUCT': {};
97
+ 'INVALID_PRODUCT_NAME': {};
98
+ 'INVALID_PRODUCT_VALUE': {};
99
+ 'YOU_REACHED_THE_PRODUCT_LIMIT': {};
100
+ 'PRODUCT_NAME_ALREADY_EXIST': {};
101
+ 'INVALID_PRODUCT_DESCRIPTION_FOR_DISCORD': {};
102
+ 'UNKNOWN_STOCK': {};
103
+ 'INVALID_STOCK_CONTENT': {};
104
+ 'INVALID_STOCK_COST': {};
105
+ 'UNKNOWN_COUPON': {};
106
+ 'INVALID_COUPON_NAME': {};
107
+ 'INVALID_COUPON_TYPE': {};
108
+ 'INVALID_COUPON_VALUE': {};
109
+ 'INVALID_COUPON_AMOUNT': {};
110
+ 'INVALID_COUPON_MIN_VALUE': {};
111
+ 'INVALID_COUPON_EXPIRATION': {};
112
+ 'INVALID_COUPON_MAX_USES_PER_USER': {};
113
+ 'INVALID_COUPON_ONLY_FIRST_BUY': {};
114
+ 'YOU_REACHED_THE_COUPON_LIMIT': {};
115
+ 'COUPON_NAME_ALREADY_EXIST': {};
116
+ 'UNKNOWN_FILE': {};
117
+ 'NO_FILES_FOUND': {};
118
+ 'INVALID_FILE_TYPE': {};
119
+ 'INVALID_FILE_NAME': {};
120
+ 'INVALID_FILE_SIZE': {};
121
+ 'YOU_REACHED_STORAGE_LIMIT': {};
122
+ 'YOU_REACHED_MEDIA_LIMIT': {};
123
+ 'YOU_ALREADY_HAVE_THIS_MEDIA': {};
124
+ 'MEDIA_NAME_ALREADY_EXIST': {};
125
+ 'UNKNOWN_PANEL': {};
126
+ 'INVALID_PANEL_NAME': {};
127
+ 'INVALID_PANEL_DESCRIPTION': {};
128
+ 'INVALID_PANEL_PLACEHOLDER': {};
129
+ 'YOU_REACHED_PANEL_LIMIT': {};
130
+ 'PANEL_NAME_ALREADY_EXIST': {};
131
+ 'YOU_REACHED_THE_PRODUCT_LIMIT_ON_PANEL': {};
132
+ 'STORE_ALREADY_CONFIGURED': {};
133
+ 'MP_ACCOUNT_OFFLINE': {};
134
+ 'MP_PIX_KEY_NOT_CONFIGURED': {};
135
+ }
136
+ type ExpectedAdditionalData = {
137
+ field: string;
138
+ received: any;
139
+ type: string;
140
+ };
141
+ export {};
@@ -0,0 +1,9 @@
1
+ interface ImageSources {
2
+ void: void;
3
+ null: null;
4
+ empty: string;
5
+ product_icon: string;
6
+ general: string;
7
+ }
8
+ export declare function GetImageURL<Source extends keyof ImageSources>(source: Source, store_id?: number | null, id?: number | null): ImageSources[Source] | string;
9
+ export {};
@@ -0,0 +1,19 @@
1
+ import { type ChannelType } from 'discord.js';
2
+ export interface DiscordGuildChannel {
3
+ id: string;
4
+ name: string;
5
+ type: ChannelType;
6
+ }
7
+ export interface DiscordGuildRole {
8
+ id: string;
9
+ name: string;
10
+ position: number;
11
+ color: number;
12
+ }
13
+ export interface DiscordGuild {
14
+ id: string;
15
+ name: string;
16
+ icon_url: string;
17
+ owner_id: string;
18
+ channels: DiscordGuildChannel[];
19
+ }
@@ -0,0 +1,6 @@
1
+ export interface Medium {
2
+ id: number;
3
+ name: string;
4
+ size: number;
5
+ mime_type: string;
6
+ }
@@ -0,0 +1,14 @@
1
+ export interface PanelProduct {
2
+ id: number;
3
+ position: number;
4
+ emoji: string;
5
+ }
6
+ export interface Panel {
7
+ id: number;
8
+ name: string;
9
+ placeholder: string;
10
+ description: string | null;
11
+ icon_id: number | null;
12
+ banner_id: number | null;
13
+ products: PanelProduct[];
14
+ }
@@ -0,0 +1,28 @@
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
+ export interface Product {
11
+ id: number;
12
+ name: string;
13
+ created_at: string;
14
+ store_id: number;
15
+ owner_id: number;
16
+ icon_id?: null | number;
17
+ banner_id?: null | number;
18
+ value: number;
19
+ description: {
20
+ short: null | string;
21
+ discord: null | string;
22
+ website: null | string;
23
+ };
24
+ stock: {
25
+ size: number;
26
+ locked: boolean;
27
+ };
28
+ }
@@ -0,0 +1,12 @@
1
+ export type Statistic = {
2
+ count: number;
3
+ users: number;
4
+ value: number;
5
+ rating: number;
6
+ };
7
+ export type Statistics = Record<string, Record<number, Statistic>>;
8
+ export type StatisticsResponse = {
9
+ last_update: string;
10
+ created_at: string;
11
+ statistics: Statistics;
12
+ };
@@ -0,0 +1,29 @@
1
+ import { DiscordGuild } from "./Guild";
2
+ export type Addons = 'custom_bot' | 'divulgation' | 'antiraid' | 'managed_automod';
3
+ export type Banks = 'Banco Inter S.A.' | 'Nu Pagamentos S.A.' | 'Picpay Serviços S.A.' | 'Mercadopago.com Representações Ltda.' | 'Caixa Econômica Federal' | 'PagSeguro Internet S.A.' | 'Banco do Brasil S.A.' | 'Banco Bradesco S.A.' | 'Banco Santander (Brasil) S.A.';
4
+ export interface PartialStore {
5
+ id: number;
6
+ name: string;
7
+ expires_at: string;
8
+ icon_id?: number | null;
9
+ pending_setup?: boolean | null;
10
+ }
11
+ export interface FullStore {
12
+ id: number;
13
+ name: string;
14
+ created_at: string;
15
+ expires_at: string;
16
+ owner_id: number;
17
+ icon_id: number | null;
18
+ banner_id: number | null;
19
+ addons: Addons[];
20
+ blocked_banks: Banks[];
21
+ pending_setup?: boolean | null;
22
+ discord_channels: Record<string /** guild id */, Record<'sale' | 'voice' | 'feedback' | 'carts', string | null | void /** channel id */>>;
23
+ discord_bot: {
24
+ id: string;
25
+ app_id: string | null;
26
+ token: string | null;
27
+ };
28
+ discord_bot_guilds: Record<string, DiscordGuild>;
29
+ }
package/types/main.d.ts CHANGED
@@ -2,3 +2,10 @@ export * from './var';
2
2
  export * from './errors';
3
3
  export * from './utils';
4
4
  export * from './RequestError';
5
+ export * from './images';
6
+ export * from './interfaces/Media';
7
+ export * from './interfaces/Panels';
8
+ export * from './interfaces/Products';
9
+ export * from './interfaces/Guild';
10
+ export * from './interfaces/Stores';
11
+ export * from './interfaces/Statistics';
package/types/utils.d.ts CHANGED
@@ -1,19 +1,5 @@
1
1
  import { APIErrors } from './errors';
2
- type ExpectedErrorAdditional = {
3
- field: string;
4
- received: any;
5
- type: string;
6
- };
7
- type ExpectedError = Extract<APIErrors, 'EXPECTED_AN_OBJECT_ARRAY' | 'EXPECTED_A_STRING_ARRAY' | 'EXPECTED_A_NUMBER_ARRAY' | 'EXPECTED_AN_OBJECT' | 'EXPECTED_A_NON_EMPTY_OBJECT' | 'EXPECTED_A_STRING' | 'EXPECTED_A_NUMBER' | 'EXPECTED_A_VALID_ID'>;
8
- type CommonError = Exclude<APIErrors, ExpectedError>;
9
- export declare function GetResponseError(code: CommonError): {
10
- code: CommonError;
11
- };
12
- export declare function GetResponseError(code: ExpectedError, additional: ExpectedErrorAdditional): {
13
- code: ExpectedError;
14
- } & ExpectedErrorAdditional;
15
- export declare function GetResponseError<T extends object>(code: CommonError, additional?: T): {
16
- code: CommonError;
17
- } & T;
2
+ export declare function GetResponseError<Code extends keyof APIErrors>(code: Code, additional: APIErrors[Code]): {
3
+ code: Code;
4
+ } & APIErrors[Code];
18
5
  export declare function TreatZennifyResponse<T extends any>(response: Response): Promise<T>;
19
- export {};
package/types/var.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- type Languages = 'pt_BR' | 'en_US';
2
- export declare let ZENNIFY_API_RESPONSE_LANGUAGE: Languages;
3
- export {};
1
+ export type SupportedLanguages = 'pt_BR' | 'en_US';
2
+ export declare let ZENNIFY_API_RESPONSE_LANGUAGE: SupportedLanguages;
3
+ export declare function SetAPIResponseLanguage(lang: SupportedLanguages): SupportedLanguages;