@zennify/sdk-js 1.24.3 → 1.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/images.js CHANGED
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GetImageURL = GetImageURL;
4
- const sources = {
4
+ const fallbacks = {
5
5
  'product_icon': `https://zennify.app/assets/images/emojis/caixa.png`,
6
6
  'general': `https://zennify.app/assets/images/icon.png`,
7
7
  'void': void 0,
8
8
  'null': null,
9
9
  'empty': ""
10
10
  };
11
- function GetImageURL(source, hash) {
11
+ function GetImageURL(fallback, hash) {
12
12
  if (!hash)
13
- return sources[source];
13
+ return fallbacks[fallback];
14
14
  else
15
15
  return "https://cdn.zennify.app/media/" + hash;
16
16
  }
package/dist/main.js CHANGED
@@ -14,14 +14,32 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ZennifySDK = void 0;
18
+ const images_1 = require("./images");
17
19
  __exportStar(require("./var"), exports);
18
20
  __exportStar(require("./errors"), exports);
19
21
  __exportStar(require("./utils"), exports);
20
22
  __exportStar(require("./RequestError"), exports);
21
- __exportStar(require("./images"), exports);
22
23
  __exportStar(require("./interfaces/Panels"), exports);
23
24
  __exportStar(require("./interfaces/Products"), exports);
24
25
  __exportStar(require("./interfaces/Guild"), exports);
25
26
  __exportStar(require("./interfaces/Stores"), exports);
26
27
  __exportStar(require("./interfaces/Transactions"), exports);
27
28
  __exportStar(require("./interfaces/Statistics"), exports);
29
+ class ZennifySDK {
30
+ domain;
31
+ token = null;
32
+ // protected readonly language: SupportedLanguages;
33
+ // private readonly user_agent: string = "Zennify-sdk";
34
+ constructor(options) {
35
+ this.domain = options?.domain ?? "zennify.app";
36
+ // this.language = options?.language ?? "en_US";
37
+ // this.token = options?.token ?? null;
38
+ }
39
+ media = {
40
+ get_url: (...options) => {
41
+ return (0, images_1.GetImageURL)(...options)?.replace("zennify.app", this.domain);
42
+ }
43
+ };
44
+ }
45
+ exports.ZennifySDK = ZennifySDK;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zennify/sdk-js",
3
- "version": "1.24.3",
3
+ "version": "1.25.1",
4
4
  "description": "A simple package to work with https://api.zennify.app",
5
5
  "main": "dist/main.js",
6
6
  "keywords": [],
package/src/images.ts CHANGED
@@ -1,23 +1,17 @@
1
- interface ImageSources {
2
- void: void,
3
- null: null,
4
- empty: string,
5
- product_icon: string,
6
- general: string
7
- }
8
-
9
- const sources: Record<keyof ImageSources, ImageSources[keyof ImageSources]> = {
1
+ const fallbacks = {
10
2
  'product_icon': `https://zennify.app/assets/images/emojis/caixa.png`,
11
3
  'general': `https://zennify.app/assets/images/icon.png`,
12
4
  'void': void 0,
13
5
  'null': null,
14
6
  'empty': ""
15
- }
7
+ } as const;
8
+
9
+ type Fallbacks = typeof fallbacks;
16
10
 
17
- export function GetImageURL<Source extends keyof ImageSources>(
18
- source: Source,
11
+ export function GetImageURL<Fallback extends keyof Fallbacks>(
12
+ fallback: Fallback,
19
13
  hash?: string | null
20
- ): ImageSources[Source] | string {
21
- if (!hash) return sources[source] as ImageSources[Source];
14
+ ): Fallbacks[Fallback] | string {
15
+ if (!hash) return fallbacks[fallback];
22
16
  else return "https://cdn.zennify.app/media/" + hash
23
17
  }
package/src/main.ts CHANGED
@@ -1,12 +1,40 @@
1
+ import { GetImageURL } from './images';
2
+
1
3
  export * from './var';
2
4
  export * from './errors';
3
5
  export * from './utils';
4
6
  export * from './RequestError';
5
- export * from './images'
6
7
 
7
8
  export * from './interfaces/Panels';
8
9
  export * from './interfaces/Products';
9
10
  export * from './interfaces/Guild';
10
11
  export * from './interfaces/Stores';
11
12
  export * from './interfaces/Transactions';
12
- export * from './interfaces/Statistics';
13
+ export * from './interfaces/Statistics';
14
+
15
+ type SDKOptions = {
16
+ domain?: string,
17
+ // language?: SupportedLanguages
18
+ // token?: string
19
+ }
20
+
21
+ export class ZennifySDK {
22
+
23
+ protected readonly domain: string;
24
+ protected readonly token: string | null = null;
25
+ // protected readonly language: SupportedLanguages;
26
+ // private readonly user_agent: string = "Zennify-sdk";
27
+
28
+ constructor(options?: SDKOptions) {
29
+ this.domain = options?.domain ?? "zennify.app";
30
+ // this.language = options?.language ?? "en_US";
31
+ // this.token = options?.token ?? null;
32
+ }
33
+
34
+ media = {
35
+ get_url: (...options: Parameters<typeof GetImageURL>) => {
36
+ return GetImageURL(...options)?.replace("zennify.app", this.domain)
37
+ }
38
+ }
39
+
40
+ }
package/types/images.d.ts CHANGED
@@ -1,9 +1,10 @@
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, hash?: string | null): ImageSources[Source] | string;
1
+ declare const fallbacks: {
2
+ readonly product_icon: "https://zennify.app/assets/images/emojis/caixa.png";
3
+ readonly general: "https://zennify.app/assets/images/icon.png";
4
+ readonly void: undefined;
5
+ readonly null: null;
6
+ readonly empty: "";
7
+ };
8
+ type Fallbacks = typeof fallbacks;
9
+ export declare function GetImageURL<Fallback extends keyof Fallbacks>(fallback: Fallback, hash?: string | null): Fallbacks[Fallback] | string;
9
10
  export {};
package/types/main.d.ts CHANGED
@@ -2,10 +2,20 @@ export * from './var';
2
2
  export * from './errors';
3
3
  export * from './utils';
4
4
  export * from './RequestError';
5
- export * from './images';
6
5
  export * from './interfaces/Panels';
7
6
  export * from './interfaces/Products';
8
7
  export * from './interfaces/Guild';
9
8
  export * from './interfaces/Stores';
10
9
  export * from './interfaces/Transactions';
11
10
  export * from './interfaces/Statistics';
11
+ type SDKOptions = {
12
+ domain?: string;
13
+ };
14
+ export declare class ZennifySDK {
15
+ protected readonly domain: string;
16
+ protected readonly token: string | null;
17
+ constructor(options?: SDKOptions);
18
+ media: {
19
+ get_url: (fallback: "product_icon" | "general" | "void" | "null" | "empty", hash?: string | null | undefined) => string | undefined;
20
+ };
21
+ }