shopeasy-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +383 -0
  2. package/dist/functions/api/config.cjs +81 -0
  3. package/dist/functions/api/config.mjs +71 -0
  4. package/dist/functions/api/index.cjs +35 -0
  5. package/dist/functions/api/index.mjs +33 -0
  6. package/dist/functions/api/services/carts.service.cjs +64 -0
  7. package/dist/functions/api/services/carts.service.mjs +62 -0
  8. package/dist/functions/api/services/catalog.service.cjs +60 -0
  9. package/dist/functions/api/services/catalog.service.mjs +58 -0
  10. package/dist/functions/api/services/configs.service.cjs +46 -0
  11. package/dist/functions/api/services/configs.service.mjs +44 -0
  12. package/dist/functions/api/services/coupons.service.cjs +54 -0
  13. package/dist/functions/api/services/coupons.service.mjs +52 -0
  14. package/dist/functions/api/services/customer.service.cjs +65 -0
  15. package/dist/functions/api/services/customer.service.mjs +63 -0
  16. package/dist/functions/api/services/images.service.cjs +17 -0
  17. package/dist/functions/api/services/images.service.mjs +15 -0
  18. package/dist/functions/api/services/orders.service.cjs +36 -0
  19. package/dist/functions/api/services/orders.service.mjs +34 -0
  20. package/dist/functions/api/services/payment.service.cjs +26 -0
  21. package/dist/functions/api/services/payment.service.mjs +24 -0
  22. package/dist/functions/api/services/plans.service.cjs +67 -0
  23. package/dist/functions/api/services/plans.service.mjs +65 -0
  24. package/dist/functions/api/services/products.service.cjs +104 -0
  25. package/dist/functions/api/services/products.service.mjs +102 -0
  26. package/dist/functions/api/services/sales.service.cjs +29 -0
  27. package/dist/functions/api/services/sales.service.mjs +27 -0
  28. package/dist/functions/api/services/token.service.cjs +17 -0
  29. package/dist/functions/api/services/token.service.mjs +15 -0
  30. package/dist/functions/api/services/users.service.cjs +13 -0
  31. package/dist/functions/api/services/users.service.mjs +11 -0
  32. package/dist/functions/api/services/wallet.service.cjs +33 -0
  33. package/dist/functions/api/services/wallet.service.mjs +31 -0
  34. package/dist/functions/utils/cart.cjs +53 -0
  35. package/dist/functions/utils/cart.mjs +47 -0
  36. package/dist/functions/utils/formarts.cjs +30 -0
  37. package/dist/functions/utils/formarts.mjs +25 -0
  38. package/dist/functions/utils/permission.cjs +31 -0
  39. package/dist/functions/utils/permission.mjs +29 -0
  40. package/dist/index.cjs +45 -0
  41. package/dist/index.d.cts +766 -0
  42. package/dist/index.d.mts +766 -0
  43. package/dist/index.d.ts +766 -0
  44. package/dist/index.mjs +32 -0
  45. package/dist/tools/pix.cjs +108 -0
  46. package/dist/tools/pix.mjs +101 -0
  47. package/package.json +47 -0
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const discord_js = require('discord.js');
4
+
5
+ function hasPermission(member, requiredPerms, configs) {
6
+ if (!configs.staffRoles && !configs.staffUsers) {
7
+ return member.permissions.has(discord_js.PermissionsBitField.Flags.Administrator);
8
+ }
9
+ const userId = member.id;
10
+ if (member.guild.ownerId === userId) {
11
+ return true;
12
+ }
13
+ if (configs.staffUsers && Array.isArray(configs.staffUsers)) {
14
+ if (configs.staffUsers.includes(userId)) {
15
+ return true;
16
+ }
17
+ }
18
+ if (!configs.staffRoles) return false;
19
+ const collectedPerms = /* @__PURE__ */ new Set();
20
+ for (const roleId of member.roles.cache.keys()) {
21
+ const rolePerms = configs.staffRoles[roleId];
22
+ if (!rolePerms) continue;
23
+ for (const perm of rolePerms) {
24
+ collectedPerms.add(perm);
25
+ }
26
+ }
27
+ if (collectedPerms.has("full_access")) return true;
28
+ return requiredPerms.every((perm) => collectedPerms.has(perm));
29
+ }
30
+
31
+ exports.hasPermission = hasPermission;
@@ -0,0 +1,29 @@
1
+ import { PermissionsBitField } from 'discord.js';
2
+
3
+ function hasPermission(member, requiredPerms, configs) {
4
+ if (!configs.staffRoles && !configs.staffUsers) {
5
+ return member.permissions.has(PermissionsBitField.Flags.Administrator);
6
+ }
7
+ const userId = member.id;
8
+ if (member.guild.ownerId === userId) {
9
+ return true;
10
+ }
11
+ if (configs.staffUsers && Array.isArray(configs.staffUsers)) {
12
+ if (configs.staffUsers.includes(userId)) {
13
+ return true;
14
+ }
15
+ }
16
+ if (!configs.staffRoles) return false;
17
+ const collectedPerms = /* @__PURE__ */ new Set();
18
+ for (const roleId of member.roles.cache.keys()) {
19
+ const rolePerms = configs.staffRoles[roleId];
20
+ if (!rolePerms) continue;
21
+ for (const perm of rolePerms) {
22
+ collectedPerms.add(perm);
23
+ }
24
+ }
25
+ if (collectedPerms.has("full_access")) return true;
26
+ return requiredPerms.every((perm) => collectedPerms.has(perm));
27
+ }
28
+
29
+ export { hasPermission };
package/dist/index.cjs ADDED
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ const config = require('./functions/api/config.cjs');
4
+ const index = require('./functions/api/index.cjs');
5
+ const cart = require('./functions/utils/cart.cjs');
6
+ const formarts = require('./functions/utils/formarts.cjs');
7
+ const permission = require('./functions/utils/permission.cjs');
8
+ const pix = require('./tools/pix.cjs');
9
+
10
+ class ShopEasySdk {
11
+ constructor(options) {
12
+ config.configureApi(
13
+ options.baseUrl ?? "https://api.shopeasy.site",
14
+ options.secretKey
15
+ );
16
+ }
17
+ //services crud
18
+ carts = index.db.carts;
19
+ catalogs = index.db.catalogs;
20
+ configs = index.db.configs;
21
+ coupons = index.db.coupon;
22
+ customers = index.db.customers;
23
+ images = index.db.images;
24
+ orders = index.db.orders;
25
+ paymentConfig = index.db.payment;
26
+ plans = index.db.plans;
27
+ products = index.db.products;
28
+ sales = index.db.sales;
29
+ tokens = index.db.tokens;
30
+ users = index.db.users;
31
+ wallet = index.db.wallet;
32
+ }
33
+
34
+ exports.cartAntiFakeVerify = cart.cartAntiFakeVerify;
35
+ exports.cartCalculeTotal = cart.cartCalculeTotal;
36
+ exports.cartVerifyAproved = cart.cartVerifyAproved;
37
+ exports.cartVerifyPermission = cart.cartVerifyPermission;
38
+ exports.cartWillExpire = cart.cartWillExpire;
39
+ exports.formatDecimalToNumber = formarts.formatDecimalToNumber;
40
+ exports.formatNumberToDecimal = formarts.formatNumberToDecimal;
41
+ exports.formatPrice = formarts.formatPrice;
42
+ exports.formatRelativeTime = formarts.formatRelativeTime;
43
+ exports.hasPermission = permission.hasPermission;
44
+ exports.pixUtils = pix.pixUtils;
45
+ exports.ShopEasySdk = ShopEasySdk;