shopeasy-sdk 1.0.2 → 1.0.4
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/functions/api/services/wallet.service.cjs +5 -1
- package/dist/functions/api/services/wallet.service.mjs +5 -1
- package/dist/index.d.cts +250 -11
- package/dist/index.d.mts +250 -11
- package/dist/index.d.ts +250 -11
- package/package.json +1 -1
|
@@ -13,7 +13,11 @@ class WalletService {
|
|
|
13
13
|
}
|
|
14
14
|
async getByApiKey(apiKey) {
|
|
15
15
|
const { data } = await config.api.get(`/wallet/by-api/${apiKey}`);
|
|
16
|
-
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
async withdrawAtos(args) {
|
|
19
|
+
const { walletKey, apiKey, pixKey, pixKeyType } = args;
|
|
20
|
+
const { data } = await config.api.post(`/atos/wallet/${walletKey}`, { apiKey, pixKey, pixKeyType });
|
|
17
21
|
return data;
|
|
18
22
|
}
|
|
19
23
|
async update(args) {
|
|
@@ -11,7 +11,11 @@ class WalletService {
|
|
|
11
11
|
}
|
|
12
12
|
async getByApiKey(apiKey) {
|
|
13
13
|
const { data } = await api.get(`/wallet/by-api/${apiKey}`);
|
|
14
|
-
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
async withdrawAtos(args) {
|
|
17
|
+
const { walletKey, apiKey, pixKey, pixKeyType } = args;
|
|
18
|
+
const { data } = await api.post(`/atos/wallet/${walletKey}`, { apiKey, pixKey, pixKeyType });
|
|
15
19
|
return data;
|
|
16
20
|
}
|
|
17
21
|
async update(args) {
|
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,197 @@ import { Decimal as Decimal$1 } from 'decimal.js';
|
|
|
2
2
|
import { Guild as Guild$1, GuildMember } from 'discord.js';
|
|
3
3
|
import { createStaticPix, PixStaticObject } from 'pix-utils';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Tipos de chave PIX aceitos pela A-TOS
|
|
7
|
+
*/
|
|
8
|
+
type AtosPixKeyType = "phone" | "email" | "random" | "cpf" | "cnpj";
|
|
9
|
+
/**
|
|
10
|
+
* Recipient types:
|
|
11
|
+
* 0 → divide lucro (não altera valor)
|
|
12
|
+
* 1 → comissão percentual (antes dos sócios)
|
|
13
|
+
* 2 → soma no valor cobrado (taxas / upsell)
|
|
14
|
+
*/
|
|
15
|
+
type AtosRecipientType = 0 | 1 | 2;
|
|
16
|
+
/**
|
|
17
|
+
* Type 2 → valor fixo que SOMA ao valor cobrado
|
|
18
|
+
*/
|
|
19
|
+
interface AtosRecipientType2 {
|
|
20
|
+
id: string;
|
|
21
|
+
type: 2;
|
|
22
|
+
amount: number;
|
|
23
|
+
percentage?: never;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Type 1 → comissão percentual (antes dos sócios)
|
|
27
|
+
*/
|
|
28
|
+
interface AtosRecipientType1 {
|
|
29
|
+
id: string;
|
|
30
|
+
type: 1;
|
|
31
|
+
percentage: number;
|
|
32
|
+
amount?: never;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Type 0 → divisão de lucro entre sócios / owner
|
|
36
|
+
*/
|
|
37
|
+
interface AtosRecipientType0 {
|
|
38
|
+
id: string;
|
|
39
|
+
type: 0;
|
|
40
|
+
percentage: number;
|
|
41
|
+
amount?: never;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Union final de recipients (INPUT)
|
|
45
|
+
*/
|
|
46
|
+
type AtosRecipient = AtosRecipientType0 | AtosRecipientType1 | AtosRecipientType2;
|
|
47
|
+
interface AtosCreatePixPaymentInput {
|
|
48
|
+
amount: number;
|
|
49
|
+
fee_to_customer?: boolean;
|
|
50
|
+
shop: {
|
|
51
|
+
/** ID lógico do servidor / loja */
|
|
52
|
+
id: string;
|
|
53
|
+
/** Nome do servidor / loja */
|
|
54
|
+
name: string;
|
|
55
|
+
/** Wallet / owner que receberá o saldo */
|
|
56
|
+
owner_id: string;
|
|
57
|
+
};
|
|
58
|
+
items: {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
quantity: number;
|
|
62
|
+
}[];
|
|
63
|
+
customer: {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
};
|
|
67
|
+
seller: {
|
|
68
|
+
/** CPF ou CNPJ do titular da API Key */
|
|
69
|
+
national_registration: string;
|
|
70
|
+
national_registration_name: string;
|
|
71
|
+
};
|
|
72
|
+
recipients?: AtosRecipient[];
|
|
73
|
+
overwrite_webhook_url?: string;
|
|
74
|
+
}
|
|
75
|
+
interface AtosCreatePixPaymentResponse {
|
|
76
|
+
id: string;
|
|
77
|
+
amount: number;
|
|
78
|
+
status: string;
|
|
79
|
+
qr_code?: string;
|
|
80
|
+
qr_code_image_url?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Recipient retornado pelo gateway
|
|
84
|
+
*/
|
|
85
|
+
interface AtosRecipientResponse {
|
|
86
|
+
id: string;
|
|
87
|
+
type: AtosRecipientType;
|
|
88
|
+
percentage: number | null;
|
|
89
|
+
amount: number;
|
|
90
|
+
available_at: string | null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Shop retornado
|
|
94
|
+
*/
|
|
95
|
+
interface AtosShopResponse {
|
|
96
|
+
id: string;
|
|
97
|
+
name: string;
|
|
98
|
+
owner_id: string;
|
|
99
|
+
created_at: string | null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Item retornado
|
|
103
|
+
*/
|
|
104
|
+
interface AtosItemResponse {
|
|
105
|
+
id: string;
|
|
106
|
+
name: string;
|
|
107
|
+
quantity: number;
|
|
108
|
+
}
|
|
109
|
+
type AtosPaymentStatus = "pending" | "paid" | "expired" | "refunded" | "canceled" | "failed";
|
|
110
|
+
interface AtosGetPaymentResponse {
|
|
111
|
+
id: string;
|
|
112
|
+
shop: AtosShopResponse;
|
|
113
|
+
status: AtosPaymentStatus;
|
|
114
|
+
amount: number;
|
|
115
|
+
recipients: AtosRecipientResponse[];
|
|
116
|
+
items: AtosItemResponse[];
|
|
117
|
+
customer: AtosCustomerResponse;
|
|
118
|
+
/** Código PIX copia e cola (só existe se for PIX) */
|
|
119
|
+
data: string | null;
|
|
120
|
+
payer: unknown | null;
|
|
121
|
+
expire_at: string | null;
|
|
122
|
+
created_at: string;
|
|
123
|
+
infraction: unknown | null;
|
|
124
|
+
end2end_id: string | null;
|
|
125
|
+
receipt_file_url: string | null;
|
|
126
|
+
custom_message: string | null;
|
|
127
|
+
withdrawn: boolean;
|
|
128
|
+
withdraw_id: string | null;
|
|
129
|
+
kyc_validated: boolean;
|
|
130
|
+
identifier: string | null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Customer retornado
|
|
134
|
+
*/
|
|
135
|
+
interface AtosCustomerResponse {
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
cpf: string | null;
|
|
139
|
+
email: string | null;
|
|
140
|
+
ip: string | null;
|
|
141
|
+
}
|
|
142
|
+
interface AtosCreatePixPaymentFullResponse {
|
|
143
|
+
id: string;
|
|
144
|
+
shop: AtosShopResponse;
|
|
145
|
+
status: "pending" | "paid" | "expired" | "refunded";
|
|
146
|
+
amount: number;
|
|
147
|
+
recipients: AtosRecipientResponse[];
|
|
148
|
+
items: AtosItemResponse[];
|
|
149
|
+
customer: AtosCustomerResponse;
|
|
150
|
+
/** Código PIX (copia e cola) */
|
|
151
|
+
data: string;
|
|
152
|
+
payer: unknown | null;
|
|
153
|
+
/** Data de expiração do PIX */
|
|
154
|
+
expire_at: string;
|
|
155
|
+
created_at: string;
|
|
156
|
+
infraction: unknown | null;
|
|
157
|
+
end2end_id: string | null;
|
|
158
|
+
receipt_file_url: string | null;
|
|
159
|
+
custom_message: string | null;
|
|
160
|
+
withdrawn: boolean;
|
|
161
|
+
withdraw_id: string | null;
|
|
162
|
+
kyc_validated: boolean;
|
|
163
|
+
/** Identificador interno do gateway */
|
|
164
|
+
identifier: string;
|
|
165
|
+
}
|
|
166
|
+
interface AtosRefundResponse {
|
|
167
|
+
success?: boolean;
|
|
168
|
+
status?: string;
|
|
169
|
+
}
|
|
170
|
+
interface AtosWithdrawArgs {
|
|
171
|
+
apiKey: string;
|
|
172
|
+
pixKey: string;
|
|
173
|
+
pixKeyType: "cpf" | "cnpj" | "email" | "phone" | "random";
|
|
174
|
+
walletKey: string;
|
|
175
|
+
}
|
|
176
|
+
interface atosWithdrawResponse {
|
|
177
|
+
sucess?: boolean;
|
|
178
|
+
}
|
|
179
|
+
interface AtosWithdrawInput {
|
|
180
|
+
/** Wallet / owner que está sacando */
|
|
181
|
+
withdraw_user_id: string;
|
|
182
|
+
pixKey: string;
|
|
183
|
+
pixKeyType: AtosPixKeyType;
|
|
184
|
+
baasPostbackUrl: string;
|
|
185
|
+
}
|
|
186
|
+
interface AtosWithdrawResponse {
|
|
187
|
+
id: string;
|
|
188
|
+
status: string;
|
|
189
|
+
}
|
|
190
|
+
interface AtosBalanceResponse {
|
|
191
|
+
pending: number;
|
|
192
|
+
available: number;
|
|
193
|
+
locked: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
5
196
|
type GatewayProvider = "atos" | "fluxopay";
|
|
6
197
|
interface WalletBalance {
|
|
7
198
|
pending: number;
|
|
@@ -19,6 +210,13 @@ interface Wallet {
|
|
|
19
210
|
createdAt: Date;
|
|
20
211
|
updatedAt: Date;
|
|
21
212
|
}
|
|
213
|
+
interface CreateWalletArgs {
|
|
214
|
+
userId: string;
|
|
215
|
+
apiKey?: string;
|
|
216
|
+
gatewayProvider?: GatewayProvider;
|
|
217
|
+
gatewayConfig?: Record<string, unknown>;
|
|
218
|
+
isActive?: boolean;
|
|
219
|
+
}
|
|
22
220
|
interface UpdateWalletArgs {
|
|
23
221
|
userId: string;
|
|
24
222
|
data: {
|
|
@@ -59,6 +257,7 @@ interface ConfigDraftSetArgs {
|
|
|
59
257
|
guildId: string;
|
|
60
258
|
data: ConfigUpdateArgs["data"];
|
|
61
259
|
}
|
|
260
|
+
type paymentProvider = "mercadoPago" | "pixManual";
|
|
62
261
|
type ActionPermission = "manage_products" | "manage_carts" | "manage_config" | "view_orders" | "process_payments" | "manager_payments" | "manage_roles" | "manager_bot" | "full_access";
|
|
63
262
|
type RolePermissionsMap = Record<string, ActionPermission[]>;
|
|
64
263
|
interface Config {
|
|
@@ -88,6 +287,7 @@ interface Config {
|
|
|
88
287
|
updatedAt: Date;
|
|
89
288
|
guild?: Guild$1;
|
|
90
289
|
}
|
|
290
|
+
type ConfigDraft = Partial<Omit<Config, "id">> | null;
|
|
91
291
|
interface ConfigUpdateArgs {
|
|
92
292
|
guildId: string;
|
|
93
293
|
data: Omit<Partial<Config>, "id" | "guildId">;
|
|
@@ -154,6 +354,9 @@ interface PlanStatus {
|
|
|
154
354
|
expireAt?: Date;
|
|
155
355
|
daysUntilExpire?: number;
|
|
156
356
|
}
|
|
357
|
+
interface MarkAlertBody {
|
|
358
|
+
daysUntilExpire: number;
|
|
359
|
+
}
|
|
157
360
|
interface MarkAlertResponse {
|
|
158
361
|
success: boolean;
|
|
159
362
|
message: string;
|
|
@@ -173,15 +376,6 @@ interface ProductGetByReference {
|
|
|
173
376
|
reference: string;
|
|
174
377
|
guildId: string;
|
|
175
378
|
}
|
|
176
|
-
interface SaleProduct$1 {
|
|
177
|
-
id: string;
|
|
178
|
-
saleId: string;
|
|
179
|
-
productid: string;
|
|
180
|
-
guildId: string;
|
|
181
|
-
valueTotal: number;
|
|
182
|
-
quantiy: number;
|
|
183
|
-
product?: Product;
|
|
184
|
-
}
|
|
185
379
|
interface GenerateProductArgs {
|
|
186
380
|
guildId: string;
|
|
187
381
|
productId: string;
|
|
@@ -220,7 +414,7 @@ interface Product {
|
|
|
220
414
|
coupon?: boolean;
|
|
221
415
|
colorHex?: string | null;
|
|
222
416
|
guild?: Guild | null;
|
|
223
|
-
sales?: SaleProduct
|
|
417
|
+
sales?: SaleProduct[];
|
|
224
418
|
catalogs?: string[];
|
|
225
419
|
}
|
|
226
420
|
interface ProduductDraftSetArgs {
|
|
@@ -243,6 +437,7 @@ interface ProductUpdateArgs {
|
|
|
243
437
|
id: string;
|
|
244
438
|
data: Omit<Partial<Product>, "id" | "reference">;
|
|
245
439
|
}
|
|
440
|
+
type ProductDraft = Partial<Omit<Product, "id" | "reference">> | null;
|
|
246
441
|
|
|
247
442
|
interface Guild {
|
|
248
443
|
id: string;
|
|
@@ -283,6 +478,7 @@ interface CustomerUpdateArgs {
|
|
|
283
478
|
id: string;
|
|
284
479
|
data: Omit<Partial<Customer>, "id" | "userId" | "guildId">;
|
|
285
480
|
}
|
|
481
|
+
type CustomerDraft = Partial<Omit<Customer, "id" | "userId" | "guildId">> | null;
|
|
286
482
|
|
|
287
483
|
interface SaleCreateArgs {
|
|
288
484
|
userId: string;
|
|
@@ -361,6 +557,17 @@ interface PaymentConfig {
|
|
|
361
557
|
walletApiKey?: string;
|
|
362
558
|
chavePixchavePixStaticQrCode: boolean;
|
|
363
559
|
}
|
|
560
|
+
interface CreatePaymentConfigArgs {
|
|
561
|
+
guildId: string;
|
|
562
|
+
provider?: PaymentProvider;
|
|
563
|
+
mercadoPagoToken?: string;
|
|
564
|
+
efiBankToken?: string;
|
|
565
|
+
chavePix?: string;
|
|
566
|
+
chavePixType?: "CPF" | "EMAIL" | "ALEATORIA" | "NUMERO";
|
|
567
|
+
chavePixName?: string;
|
|
568
|
+
chavePixCity?: string;
|
|
569
|
+
chavePixchavePixStaticQrCode: boolean;
|
|
570
|
+
}
|
|
364
571
|
interface UpdatePaymentConfigArgs {
|
|
365
572
|
guildId: string;
|
|
366
573
|
data: {
|
|
@@ -424,6 +631,7 @@ interface Image {
|
|
|
424
631
|
expiresIn: number;
|
|
425
632
|
}
|
|
426
633
|
type imageCreate = Omit<Image, "id">;
|
|
634
|
+
type ImageUpdate = Omit<Image, "id" | "guildId">;
|
|
427
635
|
|
|
428
636
|
type CouponStatus = "ACTIVED" | "DEACTIVATED" | "EXPIRED";
|
|
429
637
|
interface Coupon {
|
|
@@ -463,6 +671,7 @@ interface CouponUpdateArgs {
|
|
|
463
671
|
id: string;
|
|
464
672
|
data: Omit<Partial<Coupon>, "id" | "reference">;
|
|
465
673
|
}
|
|
674
|
+
type CouponDraft = Partial<Omit<Coupon, "id" | "reference">> | null;
|
|
466
675
|
|
|
467
676
|
type CatalogStatus = "ACTIVED" | "DEACTIVATED" | "BANNED";
|
|
468
677
|
interface CatalogProduct {
|
|
@@ -503,6 +712,7 @@ interface CatalogUpdateArgs {
|
|
|
503
712
|
id: string;
|
|
504
713
|
data: Omit<Partial<Catalog>, "id" | "reference" | "guild" | "products">;
|
|
505
714
|
}
|
|
715
|
+
type CatalogDraft = Partial<Omit<Catalog, "id" | "reference" | "guild" | "products">> | null;
|
|
506
716
|
interface CatalogDraftSetArgs {
|
|
507
717
|
id: string;
|
|
508
718
|
userId: string;
|
|
@@ -591,6 +801,33 @@ interface CartGetArgs {
|
|
|
591
801
|
guildId: string;
|
|
592
802
|
}
|
|
593
803
|
|
|
804
|
+
interface Bot {
|
|
805
|
+
id: string;
|
|
806
|
+
hostingId: string | null;
|
|
807
|
+
status: "AVAILABLE" | "IN_USE" | "GRACE";
|
|
808
|
+
currentPlanId: string | null;
|
|
809
|
+
deployedAt: string | null;
|
|
810
|
+
lastUsedAt: string | null;
|
|
811
|
+
createdAt: string;
|
|
812
|
+
updatedAt: string;
|
|
813
|
+
}
|
|
814
|
+
interface BotStatus {
|
|
815
|
+
running: boolean;
|
|
816
|
+
restarted?: boolean;
|
|
817
|
+
status: string;
|
|
818
|
+
usage: {
|
|
819
|
+
cpu: string;
|
|
820
|
+
ram: string;
|
|
821
|
+
network: string;
|
|
822
|
+
storage: string;
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
interface BotDeploy {
|
|
826
|
+
message: string;
|
|
827
|
+
bot: Bot;
|
|
828
|
+
hostingId: string;
|
|
829
|
+
}
|
|
830
|
+
|
|
594
831
|
declare function cartWillExpire(cart: Cart): Promise<void>;
|
|
595
832
|
declare function cartAntiFakeVerify(configs: Config, member: GuildMember): boolean;
|
|
596
833
|
declare function cartVerifyPermission(cart: Cart, member: GuildMember, configs: Config): boolean;
|
|
@@ -751,7 +988,7 @@ declare class ShopEasySdk {
|
|
|
751
988
|
create(args: SaleCreateArgs): Promise<Sale>;
|
|
752
989
|
getById(id: string): Promise<Sale | null>;
|
|
753
990
|
getAllByGuild(guildId: string): Promise<Sale[]>;
|
|
754
|
-
saleProductGet(id: string): Promise<SaleProduct
|
|
991
|
+
saleProductGet(id: string): Promise<SaleProduct | null>;
|
|
755
992
|
delete(id: string): Promise<void>;
|
|
756
993
|
};
|
|
757
994
|
tokens: {
|
|
@@ -765,9 +1002,11 @@ declare class ShopEasySdk {
|
|
|
765
1002
|
getOrCreate(userId: string): Promise<Wallet>;
|
|
766
1003
|
getByUserId(userId: string): Promise<Wallet>;
|
|
767
1004
|
getByApiKey(apiKey: string): Promise<Wallet>;
|
|
1005
|
+
withdrawAtos(args: AtosWithdrawArgs): Promise<atosWithdrawResponse>;
|
|
768
1006
|
update(args: UpdateWalletArgs): Promise<Wallet>;
|
|
769
1007
|
getByCaching(userId: string): Promise<Wallet | null>;
|
|
770
1008
|
};
|
|
771
1009
|
}
|
|
772
1010
|
|
|
773
1011
|
export { ShopEasySdk, cartAntiFakeVerify, cartCalculeTotal, cartVerifyAproved, cartVerifyPermission, cartWillExpire, formatDecimalToNumber, formatNumberToDecimal, formatPrice, formatRelativeTime, hasPermission, pixUtils };
|
|
1012
|
+
export type { ActionPermission, AtosBalanceResponse, AtosCreatePixPaymentFullResponse, AtosCreatePixPaymentInput, AtosCreatePixPaymentResponse, AtosCustomerResponse, AtosGetPaymentResponse, AtosItemResponse, AtosPaymentStatus, AtosPixKeyType, AtosRecipient, AtosRecipientResponse, AtosRecipientType, AtosRecipientType0, AtosRecipientType1, AtosRecipientType2, AtosRefundResponse, AtosShopResponse, AtosWithdrawArgs, AtosWithdrawInput, AtosWithdrawResponse, Bot, BotDeploy, BotStatus, Cart, CartDraft, CartDraftProduct, CartGetArgs, CartProduct, CartStatus, CartUpdateArgs, Catalog, CatalogCreateArgs, CatalogDraft, CatalogDraftGetArgs, CatalogDraftSetArgs, CatalogProduct, CatalogStatus, CatalogUpdateArgs, CheckExpirationsResponse, Config, ConfigDraft, ConfigDraftGetArgs, ConfigDraftSetArgs, ConfigUpdateArgs, Coupon, CouponCreateArgs, CouponDraft, CouponDraftGetArgs, CouponDraftSetArgs, CouponStatus, CouponUpdateArgs, CreateCartArgs, CreateCartProduct, CreatePaymentConfigArgs, CreateWalletArgs, Customer, CustomerCreateArgs, CustomerDraft, CustomerDraftGetArgs, CustomerDraftSetArgs, CustomerUpdateArgs, EfiPixCreateResponse, ExpiredPlansResponse, ExpiringPlan, GatewayProvider, GenerateProductArgs, Image, ImageUpdate, MarkAlertBody, MarkAlertResponse, Order, OrderCreate, OrderCustomer, OrderPayment, OrderProduct, PaymentConfig, PaymentProvider, Plan, PlanNeedingAlert, PlanStatus, PlanSubscriptionCreateArgs, PlanType, PlansNeedingAlertResponse, Product, ProductCreateArgs, ProductDraft, ProductGetByReference, ProductId, ProductMode, ProductStatus, ProductStockPushArgs, ProductUpdateArgs, ProduductDraftGetArgs, ProduductDraftSetArgs, RolePermissionsMap, Sale, SaleCreateArgs, SaleProduct, SaleProductCreateArgs, StockMode, Token, TokenUpdateArgs, UpdateCartData, UpdatePaymentConfigArgs, UpdateWalletArgs, Wallet, atosWithdrawResponse, imageCreate, paymentProvider };
|
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,197 @@ import { Decimal as Decimal$1 } from 'decimal.js';
|
|
|
2
2
|
import { Guild as Guild$1, GuildMember } from 'discord.js';
|
|
3
3
|
import { createStaticPix, PixStaticObject } from 'pix-utils';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Tipos de chave PIX aceitos pela A-TOS
|
|
7
|
+
*/
|
|
8
|
+
type AtosPixKeyType = "phone" | "email" | "random" | "cpf" | "cnpj";
|
|
9
|
+
/**
|
|
10
|
+
* Recipient types:
|
|
11
|
+
* 0 → divide lucro (não altera valor)
|
|
12
|
+
* 1 → comissão percentual (antes dos sócios)
|
|
13
|
+
* 2 → soma no valor cobrado (taxas / upsell)
|
|
14
|
+
*/
|
|
15
|
+
type AtosRecipientType = 0 | 1 | 2;
|
|
16
|
+
/**
|
|
17
|
+
* Type 2 → valor fixo que SOMA ao valor cobrado
|
|
18
|
+
*/
|
|
19
|
+
interface AtosRecipientType2 {
|
|
20
|
+
id: string;
|
|
21
|
+
type: 2;
|
|
22
|
+
amount: number;
|
|
23
|
+
percentage?: never;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Type 1 → comissão percentual (antes dos sócios)
|
|
27
|
+
*/
|
|
28
|
+
interface AtosRecipientType1 {
|
|
29
|
+
id: string;
|
|
30
|
+
type: 1;
|
|
31
|
+
percentage: number;
|
|
32
|
+
amount?: never;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Type 0 → divisão de lucro entre sócios / owner
|
|
36
|
+
*/
|
|
37
|
+
interface AtosRecipientType0 {
|
|
38
|
+
id: string;
|
|
39
|
+
type: 0;
|
|
40
|
+
percentage: number;
|
|
41
|
+
amount?: never;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Union final de recipients (INPUT)
|
|
45
|
+
*/
|
|
46
|
+
type AtosRecipient = AtosRecipientType0 | AtosRecipientType1 | AtosRecipientType2;
|
|
47
|
+
interface AtosCreatePixPaymentInput {
|
|
48
|
+
amount: number;
|
|
49
|
+
fee_to_customer?: boolean;
|
|
50
|
+
shop: {
|
|
51
|
+
/** ID lógico do servidor / loja */
|
|
52
|
+
id: string;
|
|
53
|
+
/** Nome do servidor / loja */
|
|
54
|
+
name: string;
|
|
55
|
+
/** Wallet / owner que receberá o saldo */
|
|
56
|
+
owner_id: string;
|
|
57
|
+
};
|
|
58
|
+
items: {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
quantity: number;
|
|
62
|
+
}[];
|
|
63
|
+
customer: {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
};
|
|
67
|
+
seller: {
|
|
68
|
+
/** CPF ou CNPJ do titular da API Key */
|
|
69
|
+
national_registration: string;
|
|
70
|
+
national_registration_name: string;
|
|
71
|
+
};
|
|
72
|
+
recipients?: AtosRecipient[];
|
|
73
|
+
overwrite_webhook_url?: string;
|
|
74
|
+
}
|
|
75
|
+
interface AtosCreatePixPaymentResponse {
|
|
76
|
+
id: string;
|
|
77
|
+
amount: number;
|
|
78
|
+
status: string;
|
|
79
|
+
qr_code?: string;
|
|
80
|
+
qr_code_image_url?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Recipient retornado pelo gateway
|
|
84
|
+
*/
|
|
85
|
+
interface AtosRecipientResponse {
|
|
86
|
+
id: string;
|
|
87
|
+
type: AtosRecipientType;
|
|
88
|
+
percentage: number | null;
|
|
89
|
+
amount: number;
|
|
90
|
+
available_at: string | null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Shop retornado
|
|
94
|
+
*/
|
|
95
|
+
interface AtosShopResponse {
|
|
96
|
+
id: string;
|
|
97
|
+
name: string;
|
|
98
|
+
owner_id: string;
|
|
99
|
+
created_at: string | null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Item retornado
|
|
103
|
+
*/
|
|
104
|
+
interface AtosItemResponse {
|
|
105
|
+
id: string;
|
|
106
|
+
name: string;
|
|
107
|
+
quantity: number;
|
|
108
|
+
}
|
|
109
|
+
type AtosPaymentStatus = "pending" | "paid" | "expired" | "refunded" | "canceled" | "failed";
|
|
110
|
+
interface AtosGetPaymentResponse {
|
|
111
|
+
id: string;
|
|
112
|
+
shop: AtosShopResponse;
|
|
113
|
+
status: AtosPaymentStatus;
|
|
114
|
+
amount: number;
|
|
115
|
+
recipients: AtosRecipientResponse[];
|
|
116
|
+
items: AtosItemResponse[];
|
|
117
|
+
customer: AtosCustomerResponse;
|
|
118
|
+
/** Código PIX copia e cola (só existe se for PIX) */
|
|
119
|
+
data: string | null;
|
|
120
|
+
payer: unknown | null;
|
|
121
|
+
expire_at: string | null;
|
|
122
|
+
created_at: string;
|
|
123
|
+
infraction: unknown | null;
|
|
124
|
+
end2end_id: string | null;
|
|
125
|
+
receipt_file_url: string | null;
|
|
126
|
+
custom_message: string | null;
|
|
127
|
+
withdrawn: boolean;
|
|
128
|
+
withdraw_id: string | null;
|
|
129
|
+
kyc_validated: boolean;
|
|
130
|
+
identifier: string | null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Customer retornado
|
|
134
|
+
*/
|
|
135
|
+
interface AtosCustomerResponse {
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
cpf: string | null;
|
|
139
|
+
email: string | null;
|
|
140
|
+
ip: string | null;
|
|
141
|
+
}
|
|
142
|
+
interface AtosCreatePixPaymentFullResponse {
|
|
143
|
+
id: string;
|
|
144
|
+
shop: AtosShopResponse;
|
|
145
|
+
status: "pending" | "paid" | "expired" | "refunded";
|
|
146
|
+
amount: number;
|
|
147
|
+
recipients: AtosRecipientResponse[];
|
|
148
|
+
items: AtosItemResponse[];
|
|
149
|
+
customer: AtosCustomerResponse;
|
|
150
|
+
/** Código PIX (copia e cola) */
|
|
151
|
+
data: string;
|
|
152
|
+
payer: unknown | null;
|
|
153
|
+
/** Data de expiração do PIX */
|
|
154
|
+
expire_at: string;
|
|
155
|
+
created_at: string;
|
|
156
|
+
infraction: unknown | null;
|
|
157
|
+
end2end_id: string | null;
|
|
158
|
+
receipt_file_url: string | null;
|
|
159
|
+
custom_message: string | null;
|
|
160
|
+
withdrawn: boolean;
|
|
161
|
+
withdraw_id: string | null;
|
|
162
|
+
kyc_validated: boolean;
|
|
163
|
+
/** Identificador interno do gateway */
|
|
164
|
+
identifier: string;
|
|
165
|
+
}
|
|
166
|
+
interface AtosRefundResponse {
|
|
167
|
+
success?: boolean;
|
|
168
|
+
status?: string;
|
|
169
|
+
}
|
|
170
|
+
interface AtosWithdrawArgs {
|
|
171
|
+
apiKey: string;
|
|
172
|
+
pixKey: string;
|
|
173
|
+
pixKeyType: "cpf" | "cnpj" | "email" | "phone" | "random";
|
|
174
|
+
walletKey: string;
|
|
175
|
+
}
|
|
176
|
+
interface atosWithdrawResponse {
|
|
177
|
+
sucess?: boolean;
|
|
178
|
+
}
|
|
179
|
+
interface AtosWithdrawInput {
|
|
180
|
+
/** Wallet / owner que está sacando */
|
|
181
|
+
withdraw_user_id: string;
|
|
182
|
+
pixKey: string;
|
|
183
|
+
pixKeyType: AtosPixKeyType;
|
|
184
|
+
baasPostbackUrl: string;
|
|
185
|
+
}
|
|
186
|
+
interface AtosWithdrawResponse {
|
|
187
|
+
id: string;
|
|
188
|
+
status: string;
|
|
189
|
+
}
|
|
190
|
+
interface AtosBalanceResponse {
|
|
191
|
+
pending: number;
|
|
192
|
+
available: number;
|
|
193
|
+
locked: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
5
196
|
type GatewayProvider = "atos" | "fluxopay";
|
|
6
197
|
interface WalletBalance {
|
|
7
198
|
pending: number;
|
|
@@ -19,6 +210,13 @@ interface Wallet {
|
|
|
19
210
|
createdAt: Date;
|
|
20
211
|
updatedAt: Date;
|
|
21
212
|
}
|
|
213
|
+
interface CreateWalletArgs {
|
|
214
|
+
userId: string;
|
|
215
|
+
apiKey?: string;
|
|
216
|
+
gatewayProvider?: GatewayProvider;
|
|
217
|
+
gatewayConfig?: Record<string, unknown>;
|
|
218
|
+
isActive?: boolean;
|
|
219
|
+
}
|
|
22
220
|
interface UpdateWalletArgs {
|
|
23
221
|
userId: string;
|
|
24
222
|
data: {
|
|
@@ -59,6 +257,7 @@ interface ConfigDraftSetArgs {
|
|
|
59
257
|
guildId: string;
|
|
60
258
|
data: ConfigUpdateArgs["data"];
|
|
61
259
|
}
|
|
260
|
+
type paymentProvider = "mercadoPago" | "pixManual";
|
|
62
261
|
type ActionPermission = "manage_products" | "manage_carts" | "manage_config" | "view_orders" | "process_payments" | "manager_payments" | "manage_roles" | "manager_bot" | "full_access";
|
|
63
262
|
type RolePermissionsMap = Record<string, ActionPermission[]>;
|
|
64
263
|
interface Config {
|
|
@@ -88,6 +287,7 @@ interface Config {
|
|
|
88
287
|
updatedAt: Date;
|
|
89
288
|
guild?: Guild$1;
|
|
90
289
|
}
|
|
290
|
+
type ConfigDraft = Partial<Omit<Config, "id">> | null;
|
|
91
291
|
interface ConfigUpdateArgs {
|
|
92
292
|
guildId: string;
|
|
93
293
|
data: Omit<Partial<Config>, "id" | "guildId">;
|
|
@@ -154,6 +354,9 @@ interface PlanStatus {
|
|
|
154
354
|
expireAt?: Date;
|
|
155
355
|
daysUntilExpire?: number;
|
|
156
356
|
}
|
|
357
|
+
interface MarkAlertBody {
|
|
358
|
+
daysUntilExpire: number;
|
|
359
|
+
}
|
|
157
360
|
interface MarkAlertResponse {
|
|
158
361
|
success: boolean;
|
|
159
362
|
message: string;
|
|
@@ -173,15 +376,6 @@ interface ProductGetByReference {
|
|
|
173
376
|
reference: string;
|
|
174
377
|
guildId: string;
|
|
175
378
|
}
|
|
176
|
-
interface SaleProduct$1 {
|
|
177
|
-
id: string;
|
|
178
|
-
saleId: string;
|
|
179
|
-
productid: string;
|
|
180
|
-
guildId: string;
|
|
181
|
-
valueTotal: number;
|
|
182
|
-
quantiy: number;
|
|
183
|
-
product?: Product;
|
|
184
|
-
}
|
|
185
379
|
interface GenerateProductArgs {
|
|
186
380
|
guildId: string;
|
|
187
381
|
productId: string;
|
|
@@ -220,7 +414,7 @@ interface Product {
|
|
|
220
414
|
coupon?: boolean;
|
|
221
415
|
colorHex?: string | null;
|
|
222
416
|
guild?: Guild | null;
|
|
223
|
-
sales?: SaleProduct
|
|
417
|
+
sales?: SaleProduct[];
|
|
224
418
|
catalogs?: string[];
|
|
225
419
|
}
|
|
226
420
|
interface ProduductDraftSetArgs {
|
|
@@ -243,6 +437,7 @@ interface ProductUpdateArgs {
|
|
|
243
437
|
id: string;
|
|
244
438
|
data: Omit<Partial<Product>, "id" | "reference">;
|
|
245
439
|
}
|
|
440
|
+
type ProductDraft = Partial<Omit<Product, "id" | "reference">> | null;
|
|
246
441
|
|
|
247
442
|
interface Guild {
|
|
248
443
|
id: string;
|
|
@@ -283,6 +478,7 @@ interface CustomerUpdateArgs {
|
|
|
283
478
|
id: string;
|
|
284
479
|
data: Omit<Partial<Customer>, "id" | "userId" | "guildId">;
|
|
285
480
|
}
|
|
481
|
+
type CustomerDraft = Partial<Omit<Customer, "id" | "userId" | "guildId">> | null;
|
|
286
482
|
|
|
287
483
|
interface SaleCreateArgs {
|
|
288
484
|
userId: string;
|
|
@@ -361,6 +557,17 @@ interface PaymentConfig {
|
|
|
361
557
|
walletApiKey?: string;
|
|
362
558
|
chavePixchavePixStaticQrCode: boolean;
|
|
363
559
|
}
|
|
560
|
+
interface CreatePaymentConfigArgs {
|
|
561
|
+
guildId: string;
|
|
562
|
+
provider?: PaymentProvider;
|
|
563
|
+
mercadoPagoToken?: string;
|
|
564
|
+
efiBankToken?: string;
|
|
565
|
+
chavePix?: string;
|
|
566
|
+
chavePixType?: "CPF" | "EMAIL" | "ALEATORIA" | "NUMERO";
|
|
567
|
+
chavePixName?: string;
|
|
568
|
+
chavePixCity?: string;
|
|
569
|
+
chavePixchavePixStaticQrCode: boolean;
|
|
570
|
+
}
|
|
364
571
|
interface UpdatePaymentConfigArgs {
|
|
365
572
|
guildId: string;
|
|
366
573
|
data: {
|
|
@@ -424,6 +631,7 @@ interface Image {
|
|
|
424
631
|
expiresIn: number;
|
|
425
632
|
}
|
|
426
633
|
type imageCreate = Omit<Image, "id">;
|
|
634
|
+
type ImageUpdate = Omit<Image, "id" | "guildId">;
|
|
427
635
|
|
|
428
636
|
type CouponStatus = "ACTIVED" | "DEACTIVATED" | "EXPIRED";
|
|
429
637
|
interface Coupon {
|
|
@@ -463,6 +671,7 @@ interface CouponUpdateArgs {
|
|
|
463
671
|
id: string;
|
|
464
672
|
data: Omit<Partial<Coupon>, "id" | "reference">;
|
|
465
673
|
}
|
|
674
|
+
type CouponDraft = Partial<Omit<Coupon, "id" | "reference">> | null;
|
|
466
675
|
|
|
467
676
|
type CatalogStatus = "ACTIVED" | "DEACTIVATED" | "BANNED";
|
|
468
677
|
interface CatalogProduct {
|
|
@@ -503,6 +712,7 @@ interface CatalogUpdateArgs {
|
|
|
503
712
|
id: string;
|
|
504
713
|
data: Omit<Partial<Catalog>, "id" | "reference" | "guild" | "products">;
|
|
505
714
|
}
|
|
715
|
+
type CatalogDraft = Partial<Omit<Catalog, "id" | "reference" | "guild" | "products">> | null;
|
|
506
716
|
interface CatalogDraftSetArgs {
|
|
507
717
|
id: string;
|
|
508
718
|
userId: string;
|
|
@@ -591,6 +801,33 @@ interface CartGetArgs {
|
|
|
591
801
|
guildId: string;
|
|
592
802
|
}
|
|
593
803
|
|
|
804
|
+
interface Bot {
|
|
805
|
+
id: string;
|
|
806
|
+
hostingId: string | null;
|
|
807
|
+
status: "AVAILABLE" | "IN_USE" | "GRACE";
|
|
808
|
+
currentPlanId: string | null;
|
|
809
|
+
deployedAt: string | null;
|
|
810
|
+
lastUsedAt: string | null;
|
|
811
|
+
createdAt: string;
|
|
812
|
+
updatedAt: string;
|
|
813
|
+
}
|
|
814
|
+
interface BotStatus {
|
|
815
|
+
running: boolean;
|
|
816
|
+
restarted?: boolean;
|
|
817
|
+
status: string;
|
|
818
|
+
usage: {
|
|
819
|
+
cpu: string;
|
|
820
|
+
ram: string;
|
|
821
|
+
network: string;
|
|
822
|
+
storage: string;
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
interface BotDeploy {
|
|
826
|
+
message: string;
|
|
827
|
+
bot: Bot;
|
|
828
|
+
hostingId: string;
|
|
829
|
+
}
|
|
830
|
+
|
|
594
831
|
declare function cartWillExpire(cart: Cart): Promise<void>;
|
|
595
832
|
declare function cartAntiFakeVerify(configs: Config, member: GuildMember): boolean;
|
|
596
833
|
declare function cartVerifyPermission(cart: Cart, member: GuildMember, configs: Config): boolean;
|
|
@@ -751,7 +988,7 @@ declare class ShopEasySdk {
|
|
|
751
988
|
create(args: SaleCreateArgs): Promise<Sale>;
|
|
752
989
|
getById(id: string): Promise<Sale | null>;
|
|
753
990
|
getAllByGuild(guildId: string): Promise<Sale[]>;
|
|
754
|
-
saleProductGet(id: string): Promise<SaleProduct
|
|
991
|
+
saleProductGet(id: string): Promise<SaleProduct | null>;
|
|
755
992
|
delete(id: string): Promise<void>;
|
|
756
993
|
};
|
|
757
994
|
tokens: {
|
|
@@ -765,9 +1002,11 @@ declare class ShopEasySdk {
|
|
|
765
1002
|
getOrCreate(userId: string): Promise<Wallet>;
|
|
766
1003
|
getByUserId(userId: string): Promise<Wallet>;
|
|
767
1004
|
getByApiKey(apiKey: string): Promise<Wallet>;
|
|
1005
|
+
withdrawAtos(args: AtosWithdrawArgs): Promise<atosWithdrawResponse>;
|
|
768
1006
|
update(args: UpdateWalletArgs): Promise<Wallet>;
|
|
769
1007
|
getByCaching(userId: string): Promise<Wallet | null>;
|
|
770
1008
|
};
|
|
771
1009
|
}
|
|
772
1010
|
|
|
773
1011
|
export { ShopEasySdk, cartAntiFakeVerify, cartCalculeTotal, cartVerifyAproved, cartVerifyPermission, cartWillExpire, formatDecimalToNumber, formatNumberToDecimal, formatPrice, formatRelativeTime, hasPermission, pixUtils };
|
|
1012
|
+
export type { ActionPermission, AtosBalanceResponse, AtosCreatePixPaymentFullResponse, AtosCreatePixPaymentInput, AtosCreatePixPaymentResponse, AtosCustomerResponse, AtosGetPaymentResponse, AtosItemResponse, AtosPaymentStatus, AtosPixKeyType, AtosRecipient, AtosRecipientResponse, AtosRecipientType, AtosRecipientType0, AtosRecipientType1, AtosRecipientType2, AtosRefundResponse, AtosShopResponse, AtosWithdrawArgs, AtosWithdrawInput, AtosWithdrawResponse, Bot, BotDeploy, BotStatus, Cart, CartDraft, CartDraftProduct, CartGetArgs, CartProduct, CartStatus, CartUpdateArgs, Catalog, CatalogCreateArgs, CatalogDraft, CatalogDraftGetArgs, CatalogDraftSetArgs, CatalogProduct, CatalogStatus, CatalogUpdateArgs, CheckExpirationsResponse, Config, ConfigDraft, ConfigDraftGetArgs, ConfigDraftSetArgs, ConfigUpdateArgs, Coupon, CouponCreateArgs, CouponDraft, CouponDraftGetArgs, CouponDraftSetArgs, CouponStatus, CouponUpdateArgs, CreateCartArgs, CreateCartProduct, CreatePaymentConfigArgs, CreateWalletArgs, Customer, CustomerCreateArgs, CustomerDraft, CustomerDraftGetArgs, CustomerDraftSetArgs, CustomerUpdateArgs, EfiPixCreateResponse, ExpiredPlansResponse, ExpiringPlan, GatewayProvider, GenerateProductArgs, Image, ImageUpdate, MarkAlertBody, MarkAlertResponse, Order, OrderCreate, OrderCustomer, OrderPayment, OrderProduct, PaymentConfig, PaymentProvider, Plan, PlanNeedingAlert, PlanStatus, PlanSubscriptionCreateArgs, PlanType, PlansNeedingAlertResponse, Product, ProductCreateArgs, ProductDraft, ProductGetByReference, ProductId, ProductMode, ProductStatus, ProductStockPushArgs, ProductUpdateArgs, ProduductDraftGetArgs, ProduductDraftSetArgs, RolePermissionsMap, Sale, SaleCreateArgs, SaleProduct, SaleProductCreateArgs, StockMode, Token, TokenUpdateArgs, UpdateCartData, UpdatePaymentConfigArgs, UpdateWalletArgs, Wallet, atosWithdrawResponse, imageCreate, paymentProvider };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,197 @@ import { Decimal as Decimal$1 } from 'decimal.js';
|
|
|
2
2
|
import { Guild as Guild$1, GuildMember } from 'discord.js';
|
|
3
3
|
import { createStaticPix, PixStaticObject } from 'pix-utils';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Tipos de chave PIX aceitos pela A-TOS
|
|
7
|
+
*/
|
|
8
|
+
type AtosPixKeyType = "phone" | "email" | "random" | "cpf" | "cnpj";
|
|
9
|
+
/**
|
|
10
|
+
* Recipient types:
|
|
11
|
+
* 0 → divide lucro (não altera valor)
|
|
12
|
+
* 1 → comissão percentual (antes dos sócios)
|
|
13
|
+
* 2 → soma no valor cobrado (taxas / upsell)
|
|
14
|
+
*/
|
|
15
|
+
type AtosRecipientType = 0 | 1 | 2;
|
|
16
|
+
/**
|
|
17
|
+
* Type 2 → valor fixo que SOMA ao valor cobrado
|
|
18
|
+
*/
|
|
19
|
+
interface AtosRecipientType2 {
|
|
20
|
+
id: string;
|
|
21
|
+
type: 2;
|
|
22
|
+
amount: number;
|
|
23
|
+
percentage?: never;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Type 1 → comissão percentual (antes dos sócios)
|
|
27
|
+
*/
|
|
28
|
+
interface AtosRecipientType1 {
|
|
29
|
+
id: string;
|
|
30
|
+
type: 1;
|
|
31
|
+
percentage: number;
|
|
32
|
+
amount?: never;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Type 0 → divisão de lucro entre sócios / owner
|
|
36
|
+
*/
|
|
37
|
+
interface AtosRecipientType0 {
|
|
38
|
+
id: string;
|
|
39
|
+
type: 0;
|
|
40
|
+
percentage: number;
|
|
41
|
+
amount?: never;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Union final de recipients (INPUT)
|
|
45
|
+
*/
|
|
46
|
+
type AtosRecipient = AtosRecipientType0 | AtosRecipientType1 | AtosRecipientType2;
|
|
47
|
+
interface AtosCreatePixPaymentInput {
|
|
48
|
+
amount: number;
|
|
49
|
+
fee_to_customer?: boolean;
|
|
50
|
+
shop: {
|
|
51
|
+
/** ID lógico do servidor / loja */
|
|
52
|
+
id: string;
|
|
53
|
+
/** Nome do servidor / loja */
|
|
54
|
+
name: string;
|
|
55
|
+
/** Wallet / owner que receberá o saldo */
|
|
56
|
+
owner_id: string;
|
|
57
|
+
};
|
|
58
|
+
items: {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
quantity: number;
|
|
62
|
+
}[];
|
|
63
|
+
customer: {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
};
|
|
67
|
+
seller: {
|
|
68
|
+
/** CPF ou CNPJ do titular da API Key */
|
|
69
|
+
national_registration: string;
|
|
70
|
+
national_registration_name: string;
|
|
71
|
+
};
|
|
72
|
+
recipients?: AtosRecipient[];
|
|
73
|
+
overwrite_webhook_url?: string;
|
|
74
|
+
}
|
|
75
|
+
interface AtosCreatePixPaymentResponse {
|
|
76
|
+
id: string;
|
|
77
|
+
amount: number;
|
|
78
|
+
status: string;
|
|
79
|
+
qr_code?: string;
|
|
80
|
+
qr_code_image_url?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Recipient retornado pelo gateway
|
|
84
|
+
*/
|
|
85
|
+
interface AtosRecipientResponse {
|
|
86
|
+
id: string;
|
|
87
|
+
type: AtosRecipientType;
|
|
88
|
+
percentage: number | null;
|
|
89
|
+
amount: number;
|
|
90
|
+
available_at: string | null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Shop retornado
|
|
94
|
+
*/
|
|
95
|
+
interface AtosShopResponse {
|
|
96
|
+
id: string;
|
|
97
|
+
name: string;
|
|
98
|
+
owner_id: string;
|
|
99
|
+
created_at: string | null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Item retornado
|
|
103
|
+
*/
|
|
104
|
+
interface AtosItemResponse {
|
|
105
|
+
id: string;
|
|
106
|
+
name: string;
|
|
107
|
+
quantity: number;
|
|
108
|
+
}
|
|
109
|
+
type AtosPaymentStatus = "pending" | "paid" | "expired" | "refunded" | "canceled" | "failed";
|
|
110
|
+
interface AtosGetPaymentResponse {
|
|
111
|
+
id: string;
|
|
112
|
+
shop: AtosShopResponse;
|
|
113
|
+
status: AtosPaymentStatus;
|
|
114
|
+
amount: number;
|
|
115
|
+
recipients: AtosRecipientResponse[];
|
|
116
|
+
items: AtosItemResponse[];
|
|
117
|
+
customer: AtosCustomerResponse;
|
|
118
|
+
/** Código PIX copia e cola (só existe se for PIX) */
|
|
119
|
+
data: string | null;
|
|
120
|
+
payer: unknown | null;
|
|
121
|
+
expire_at: string | null;
|
|
122
|
+
created_at: string;
|
|
123
|
+
infraction: unknown | null;
|
|
124
|
+
end2end_id: string | null;
|
|
125
|
+
receipt_file_url: string | null;
|
|
126
|
+
custom_message: string | null;
|
|
127
|
+
withdrawn: boolean;
|
|
128
|
+
withdraw_id: string | null;
|
|
129
|
+
kyc_validated: boolean;
|
|
130
|
+
identifier: string | null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Customer retornado
|
|
134
|
+
*/
|
|
135
|
+
interface AtosCustomerResponse {
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
cpf: string | null;
|
|
139
|
+
email: string | null;
|
|
140
|
+
ip: string | null;
|
|
141
|
+
}
|
|
142
|
+
interface AtosCreatePixPaymentFullResponse {
|
|
143
|
+
id: string;
|
|
144
|
+
shop: AtosShopResponse;
|
|
145
|
+
status: "pending" | "paid" | "expired" | "refunded";
|
|
146
|
+
amount: number;
|
|
147
|
+
recipients: AtosRecipientResponse[];
|
|
148
|
+
items: AtosItemResponse[];
|
|
149
|
+
customer: AtosCustomerResponse;
|
|
150
|
+
/** Código PIX (copia e cola) */
|
|
151
|
+
data: string;
|
|
152
|
+
payer: unknown | null;
|
|
153
|
+
/** Data de expiração do PIX */
|
|
154
|
+
expire_at: string;
|
|
155
|
+
created_at: string;
|
|
156
|
+
infraction: unknown | null;
|
|
157
|
+
end2end_id: string | null;
|
|
158
|
+
receipt_file_url: string | null;
|
|
159
|
+
custom_message: string | null;
|
|
160
|
+
withdrawn: boolean;
|
|
161
|
+
withdraw_id: string | null;
|
|
162
|
+
kyc_validated: boolean;
|
|
163
|
+
/** Identificador interno do gateway */
|
|
164
|
+
identifier: string;
|
|
165
|
+
}
|
|
166
|
+
interface AtosRefundResponse {
|
|
167
|
+
success?: boolean;
|
|
168
|
+
status?: string;
|
|
169
|
+
}
|
|
170
|
+
interface AtosWithdrawArgs {
|
|
171
|
+
apiKey: string;
|
|
172
|
+
pixKey: string;
|
|
173
|
+
pixKeyType: "cpf" | "cnpj" | "email" | "phone" | "random";
|
|
174
|
+
walletKey: string;
|
|
175
|
+
}
|
|
176
|
+
interface atosWithdrawResponse {
|
|
177
|
+
sucess?: boolean;
|
|
178
|
+
}
|
|
179
|
+
interface AtosWithdrawInput {
|
|
180
|
+
/** Wallet / owner que está sacando */
|
|
181
|
+
withdraw_user_id: string;
|
|
182
|
+
pixKey: string;
|
|
183
|
+
pixKeyType: AtosPixKeyType;
|
|
184
|
+
baasPostbackUrl: string;
|
|
185
|
+
}
|
|
186
|
+
interface AtosWithdrawResponse {
|
|
187
|
+
id: string;
|
|
188
|
+
status: string;
|
|
189
|
+
}
|
|
190
|
+
interface AtosBalanceResponse {
|
|
191
|
+
pending: number;
|
|
192
|
+
available: number;
|
|
193
|
+
locked: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
5
196
|
type GatewayProvider = "atos" | "fluxopay";
|
|
6
197
|
interface WalletBalance {
|
|
7
198
|
pending: number;
|
|
@@ -19,6 +210,13 @@ interface Wallet {
|
|
|
19
210
|
createdAt: Date;
|
|
20
211
|
updatedAt: Date;
|
|
21
212
|
}
|
|
213
|
+
interface CreateWalletArgs {
|
|
214
|
+
userId: string;
|
|
215
|
+
apiKey?: string;
|
|
216
|
+
gatewayProvider?: GatewayProvider;
|
|
217
|
+
gatewayConfig?: Record<string, unknown>;
|
|
218
|
+
isActive?: boolean;
|
|
219
|
+
}
|
|
22
220
|
interface UpdateWalletArgs {
|
|
23
221
|
userId: string;
|
|
24
222
|
data: {
|
|
@@ -59,6 +257,7 @@ interface ConfigDraftSetArgs {
|
|
|
59
257
|
guildId: string;
|
|
60
258
|
data: ConfigUpdateArgs["data"];
|
|
61
259
|
}
|
|
260
|
+
type paymentProvider = "mercadoPago" | "pixManual";
|
|
62
261
|
type ActionPermission = "manage_products" | "manage_carts" | "manage_config" | "view_orders" | "process_payments" | "manager_payments" | "manage_roles" | "manager_bot" | "full_access";
|
|
63
262
|
type RolePermissionsMap = Record<string, ActionPermission[]>;
|
|
64
263
|
interface Config {
|
|
@@ -88,6 +287,7 @@ interface Config {
|
|
|
88
287
|
updatedAt: Date;
|
|
89
288
|
guild?: Guild$1;
|
|
90
289
|
}
|
|
290
|
+
type ConfigDraft = Partial<Omit<Config, "id">> | null;
|
|
91
291
|
interface ConfigUpdateArgs {
|
|
92
292
|
guildId: string;
|
|
93
293
|
data: Omit<Partial<Config>, "id" | "guildId">;
|
|
@@ -154,6 +354,9 @@ interface PlanStatus {
|
|
|
154
354
|
expireAt?: Date;
|
|
155
355
|
daysUntilExpire?: number;
|
|
156
356
|
}
|
|
357
|
+
interface MarkAlertBody {
|
|
358
|
+
daysUntilExpire: number;
|
|
359
|
+
}
|
|
157
360
|
interface MarkAlertResponse {
|
|
158
361
|
success: boolean;
|
|
159
362
|
message: string;
|
|
@@ -173,15 +376,6 @@ interface ProductGetByReference {
|
|
|
173
376
|
reference: string;
|
|
174
377
|
guildId: string;
|
|
175
378
|
}
|
|
176
|
-
interface SaleProduct$1 {
|
|
177
|
-
id: string;
|
|
178
|
-
saleId: string;
|
|
179
|
-
productid: string;
|
|
180
|
-
guildId: string;
|
|
181
|
-
valueTotal: number;
|
|
182
|
-
quantiy: number;
|
|
183
|
-
product?: Product;
|
|
184
|
-
}
|
|
185
379
|
interface GenerateProductArgs {
|
|
186
380
|
guildId: string;
|
|
187
381
|
productId: string;
|
|
@@ -220,7 +414,7 @@ interface Product {
|
|
|
220
414
|
coupon?: boolean;
|
|
221
415
|
colorHex?: string | null;
|
|
222
416
|
guild?: Guild | null;
|
|
223
|
-
sales?: SaleProduct
|
|
417
|
+
sales?: SaleProduct[];
|
|
224
418
|
catalogs?: string[];
|
|
225
419
|
}
|
|
226
420
|
interface ProduductDraftSetArgs {
|
|
@@ -243,6 +437,7 @@ interface ProductUpdateArgs {
|
|
|
243
437
|
id: string;
|
|
244
438
|
data: Omit<Partial<Product>, "id" | "reference">;
|
|
245
439
|
}
|
|
440
|
+
type ProductDraft = Partial<Omit<Product, "id" | "reference">> | null;
|
|
246
441
|
|
|
247
442
|
interface Guild {
|
|
248
443
|
id: string;
|
|
@@ -283,6 +478,7 @@ interface CustomerUpdateArgs {
|
|
|
283
478
|
id: string;
|
|
284
479
|
data: Omit<Partial<Customer>, "id" | "userId" | "guildId">;
|
|
285
480
|
}
|
|
481
|
+
type CustomerDraft = Partial<Omit<Customer, "id" | "userId" | "guildId">> | null;
|
|
286
482
|
|
|
287
483
|
interface SaleCreateArgs {
|
|
288
484
|
userId: string;
|
|
@@ -361,6 +557,17 @@ interface PaymentConfig {
|
|
|
361
557
|
walletApiKey?: string;
|
|
362
558
|
chavePixchavePixStaticQrCode: boolean;
|
|
363
559
|
}
|
|
560
|
+
interface CreatePaymentConfigArgs {
|
|
561
|
+
guildId: string;
|
|
562
|
+
provider?: PaymentProvider;
|
|
563
|
+
mercadoPagoToken?: string;
|
|
564
|
+
efiBankToken?: string;
|
|
565
|
+
chavePix?: string;
|
|
566
|
+
chavePixType?: "CPF" | "EMAIL" | "ALEATORIA" | "NUMERO";
|
|
567
|
+
chavePixName?: string;
|
|
568
|
+
chavePixCity?: string;
|
|
569
|
+
chavePixchavePixStaticQrCode: boolean;
|
|
570
|
+
}
|
|
364
571
|
interface UpdatePaymentConfigArgs {
|
|
365
572
|
guildId: string;
|
|
366
573
|
data: {
|
|
@@ -424,6 +631,7 @@ interface Image {
|
|
|
424
631
|
expiresIn: number;
|
|
425
632
|
}
|
|
426
633
|
type imageCreate = Omit<Image, "id">;
|
|
634
|
+
type ImageUpdate = Omit<Image, "id" | "guildId">;
|
|
427
635
|
|
|
428
636
|
type CouponStatus = "ACTIVED" | "DEACTIVATED" | "EXPIRED";
|
|
429
637
|
interface Coupon {
|
|
@@ -463,6 +671,7 @@ interface CouponUpdateArgs {
|
|
|
463
671
|
id: string;
|
|
464
672
|
data: Omit<Partial<Coupon>, "id" | "reference">;
|
|
465
673
|
}
|
|
674
|
+
type CouponDraft = Partial<Omit<Coupon, "id" | "reference">> | null;
|
|
466
675
|
|
|
467
676
|
type CatalogStatus = "ACTIVED" | "DEACTIVATED" | "BANNED";
|
|
468
677
|
interface CatalogProduct {
|
|
@@ -503,6 +712,7 @@ interface CatalogUpdateArgs {
|
|
|
503
712
|
id: string;
|
|
504
713
|
data: Omit<Partial<Catalog>, "id" | "reference" | "guild" | "products">;
|
|
505
714
|
}
|
|
715
|
+
type CatalogDraft = Partial<Omit<Catalog, "id" | "reference" | "guild" | "products">> | null;
|
|
506
716
|
interface CatalogDraftSetArgs {
|
|
507
717
|
id: string;
|
|
508
718
|
userId: string;
|
|
@@ -591,6 +801,33 @@ interface CartGetArgs {
|
|
|
591
801
|
guildId: string;
|
|
592
802
|
}
|
|
593
803
|
|
|
804
|
+
interface Bot {
|
|
805
|
+
id: string;
|
|
806
|
+
hostingId: string | null;
|
|
807
|
+
status: "AVAILABLE" | "IN_USE" | "GRACE";
|
|
808
|
+
currentPlanId: string | null;
|
|
809
|
+
deployedAt: string | null;
|
|
810
|
+
lastUsedAt: string | null;
|
|
811
|
+
createdAt: string;
|
|
812
|
+
updatedAt: string;
|
|
813
|
+
}
|
|
814
|
+
interface BotStatus {
|
|
815
|
+
running: boolean;
|
|
816
|
+
restarted?: boolean;
|
|
817
|
+
status: string;
|
|
818
|
+
usage: {
|
|
819
|
+
cpu: string;
|
|
820
|
+
ram: string;
|
|
821
|
+
network: string;
|
|
822
|
+
storage: string;
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
interface BotDeploy {
|
|
826
|
+
message: string;
|
|
827
|
+
bot: Bot;
|
|
828
|
+
hostingId: string;
|
|
829
|
+
}
|
|
830
|
+
|
|
594
831
|
declare function cartWillExpire(cart: Cart): Promise<void>;
|
|
595
832
|
declare function cartAntiFakeVerify(configs: Config, member: GuildMember): boolean;
|
|
596
833
|
declare function cartVerifyPermission(cart: Cart, member: GuildMember, configs: Config): boolean;
|
|
@@ -751,7 +988,7 @@ declare class ShopEasySdk {
|
|
|
751
988
|
create(args: SaleCreateArgs): Promise<Sale>;
|
|
752
989
|
getById(id: string): Promise<Sale | null>;
|
|
753
990
|
getAllByGuild(guildId: string): Promise<Sale[]>;
|
|
754
|
-
saleProductGet(id: string): Promise<SaleProduct
|
|
991
|
+
saleProductGet(id: string): Promise<SaleProduct | null>;
|
|
755
992
|
delete(id: string): Promise<void>;
|
|
756
993
|
};
|
|
757
994
|
tokens: {
|
|
@@ -765,9 +1002,11 @@ declare class ShopEasySdk {
|
|
|
765
1002
|
getOrCreate(userId: string): Promise<Wallet>;
|
|
766
1003
|
getByUserId(userId: string): Promise<Wallet>;
|
|
767
1004
|
getByApiKey(apiKey: string): Promise<Wallet>;
|
|
1005
|
+
withdrawAtos(args: AtosWithdrawArgs): Promise<atosWithdrawResponse>;
|
|
768
1006
|
update(args: UpdateWalletArgs): Promise<Wallet>;
|
|
769
1007
|
getByCaching(userId: string): Promise<Wallet | null>;
|
|
770
1008
|
};
|
|
771
1009
|
}
|
|
772
1010
|
|
|
773
1011
|
export { ShopEasySdk, cartAntiFakeVerify, cartCalculeTotal, cartVerifyAproved, cartVerifyPermission, cartWillExpire, formatDecimalToNumber, formatNumberToDecimal, formatPrice, formatRelativeTime, hasPermission, pixUtils };
|
|
1012
|
+
export type { ActionPermission, AtosBalanceResponse, AtosCreatePixPaymentFullResponse, AtosCreatePixPaymentInput, AtosCreatePixPaymentResponse, AtosCustomerResponse, AtosGetPaymentResponse, AtosItemResponse, AtosPaymentStatus, AtosPixKeyType, AtosRecipient, AtosRecipientResponse, AtosRecipientType, AtosRecipientType0, AtosRecipientType1, AtosRecipientType2, AtosRefundResponse, AtosShopResponse, AtosWithdrawArgs, AtosWithdrawInput, AtosWithdrawResponse, Bot, BotDeploy, BotStatus, Cart, CartDraft, CartDraftProduct, CartGetArgs, CartProduct, CartStatus, CartUpdateArgs, Catalog, CatalogCreateArgs, CatalogDraft, CatalogDraftGetArgs, CatalogDraftSetArgs, CatalogProduct, CatalogStatus, CatalogUpdateArgs, CheckExpirationsResponse, Config, ConfigDraft, ConfigDraftGetArgs, ConfigDraftSetArgs, ConfigUpdateArgs, Coupon, CouponCreateArgs, CouponDraft, CouponDraftGetArgs, CouponDraftSetArgs, CouponStatus, CouponUpdateArgs, CreateCartArgs, CreateCartProduct, CreatePaymentConfigArgs, CreateWalletArgs, Customer, CustomerCreateArgs, CustomerDraft, CustomerDraftGetArgs, CustomerDraftSetArgs, CustomerUpdateArgs, EfiPixCreateResponse, ExpiredPlansResponse, ExpiringPlan, GatewayProvider, GenerateProductArgs, Image, ImageUpdate, MarkAlertBody, MarkAlertResponse, Order, OrderCreate, OrderCustomer, OrderPayment, OrderProduct, PaymentConfig, PaymentProvider, Plan, PlanNeedingAlert, PlanStatus, PlanSubscriptionCreateArgs, PlanType, PlansNeedingAlertResponse, Product, ProductCreateArgs, ProductDraft, ProductGetByReference, ProductId, ProductMode, ProductStatus, ProductStockPushArgs, ProductUpdateArgs, ProduductDraftGetArgs, ProduductDraftSetArgs, RolePermissionsMap, Sale, SaleCreateArgs, SaleProduct, SaleProductCreateArgs, StockMode, Token, TokenUpdateArgs, UpdateCartData, UpdatePaymentConfigArgs, UpdateWalletArgs, Wallet, atosWithdrawResponse, imageCreate, paymentProvider };
|