@zennify/sdk-js 1.25.2 → 1.26.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 CHANGED
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GetImageURL = GetImageURL;
4
- const fallbacks = {
4
+ const sources = {
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(fallback, hash) {
11
+ function GetImageURL(source, hash, domain = "zennify.app") {
12
12
  if (!hash)
13
- return fallbacks[fallback];
13
+ return sources[source];
14
14
  else
15
- return `https://cdn.${this.domain}/media/${hash}`;
15
+ return `https://cdn.${domain}/media/${hash}`;
16
16
  }
package/dist/main.js CHANGED
@@ -14,28 +14,14 @@ 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");
19
17
  __exportStar(require("./var"), exports);
20
18
  __exportStar(require("./errors"), exports);
21
19
  __exportStar(require("./utils"), exports);
22
20
  __exportStar(require("./RequestError"), exports);
21
+ __exportStar(require("./images"), exports);
23
22
  __exportStar(require("./interfaces/Panels"), exports);
24
23
  __exportStar(require("./interfaces/Products"), exports);
25
24
  __exportStar(require("./interfaces/Guild"), exports);
26
25
  __exportStar(require("./interfaces/Stores"), exports);
27
26
  __exportStar(require("./interfaces/Transactions"), exports);
28
27
  __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 = { get_url: images_1.GetImageURL };
40
- }
41
- exports.ZennifySDK = ZennifySDK;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zennify/sdk-js",
3
- "version": "1.25.2",
3
+ "version": "1.26.0",
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,20 +1,24 @@
1
- import { ZennifySDK } from "./main";
1
+ interface ImageSources {
2
+ void: void,
3
+ null: null,
4
+ empty: string,
5
+ product_icon: string,
6
+ general: string
7
+ }
2
8
 
3
- const fallbacks = {
9
+ const sources: Record<keyof ImageSources, ImageSources[keyof ImageSources]> = {
4
10
  'product_icon': `https://zennify.app/assets/images/emojis/caixa.png`,
5
11
  'general': `https://zennify.app/assets/images/icon.png`,
6
12
  'void': void 0,
7
13
  'null': null,
8
14
  'empty': ""
9
- } as const;
15
+ }
10
16
 
11
- type Fallbacks = typeof fallbacks;
12
-
13
- export function GetImageURL<Fallback extends keyof Fallbacks>(
14
- this: ZennifySDK,
15
- fallback: Fallback,
16
- hash?: string | null
17
- ): Fallbacks[Fallback] | string {
18
- if (!hash) return fallbacks[fallback];
19
- else return `https://cdn.${this.domain}/media/${hash}`
17
+ export function GetImageURL<Source extends keyof ImageSources>(
18
+ source: Source,
19
+ hash?: string | null,
20
+ domain: string = "zennify.app"
21
+ ): ImageSources[Source] | string {
22
+ if (!hash) return sources[source] as ImageSources[Source];
23
+ else return `https://cdn.${domain}/media/${hash}`;
20
24
  }
package/src/main.ts CHANGED
@@ -1,36 +1,12 @@
1
- import { GetImageURL } from './images';
2
-
3
1
  export * from './var';
4
2
  export * from './errors';
5
3
  export * from './utils';
6
4
  export * from './RequestError';
5
+ export * from './images'
7
6
 
8
7
  export * from './interfaces/Panels';
9
8
  export * from './interfaces/Products';
10
9
  export * from './interfaces/Guild';
11
10
  export * from './interfaces/Stores';
12
11
  export * from './interfaces/Transactions';
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 = { get_url: GetImageURL }
35
-
36
- }
12
+ export * from './interfaces/Statistics';
package/types/images.d.ts CHANGED
@@ -1,11 +1,9 @@
1
- import { ZennifySDK } from "./main";
2
- declare const fallbacks: {
3
- readonly product_icon: "https://zennify.app/assets/images/emojis/caixa.png";
4
- readonly general: "https://zennify.app/assets/images/icon.png";
5
- readonly void: undefined;
6
- readonly null: null;
7
- readonly empty: "";
8
- };
9
- type Fallbacks = typeof fallbacks;
10
- export declare function GetImageURL<Fallback extends keyof Fallbacks>(this: ZennifySDK, fallback: Fallback, hash?: string | null): Fallbacks[Fallback] | string;
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, domain?: string): ImageSources[Source] | string;
11
9
  export {};
package/types/main.d.ts CHANGED
@@ -1,22 +1,11 @@
1
- import { GetImageURL } from './images';
2
1
  export * from './var';
3
2
  export * from './errors';
4
3
  export * from './utils';
5
4
  export * from './RequestError';
5
+ export * from './images';
6
6
  export * from './interfaces/Panels';
7
7
  export * from './interfaces/Products';
8
8
  export * from './interfaces/Guild';
9
9
  export * from './interfaces/Stores';
10
10
  export * from './interfaces/Transactions';
11
11
  export * from './interfaces/Statistics';
12
- type SDKOptions = {
13
- domain?: string;
14
- };
15
- export declare class ZennifySDK {
16
- protected readonly domain: string;
17
- protected readonly token: string | null;
18
- constructor(options?: SDKOptions);
19
- media: {
20
- get_url: typeof GetImageURL;
21
- };
22
- }