@zennify/sdk-js 1.24.2 → 1.25.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 +3 -3
- package/dist/main.js +19 -1
- package/package.json +1 -1
- package/src/images.ts +8 -14
- package/src/interfaces/Products.ts +2 -2
- package/src/interfaces/Transactions.ts +4 -4
- package/src/main.ts +29 -2
- package/types/images.d.ts +9 -8
- package/types/interfaces/Products.d.ts +2 -2
- package/types/interfaces/Transactions.d.ts +4 -4
- package/types/main.d.ts +11 -1
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
|
|
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(
|
|
11
|
+
function GetImageURL(fallback, hash) {
|
|
12
12
|
if (!hash)
|
|
13
|
-
return
|
|
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: async (...options) => {
|
|
41
|
+
return (0, images_1.GetImageURL)(...options)?.replace("zennify.app", this.domain);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
exports.ZennifySDK = ZennifySDK;
|
package/package.json
CHANGED
package/src/images.ts
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
|
|
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<
|
|
18
|
-
|
|
11
|
+
export function GetImageURL<Fallback extends keyof Fallbacks>(
|
|
12
|
+
fallback: Fallback,
|
|
19
13
|
hash?: string | null
|
|
20
|
-
):
|
|
21
|
-
if (!hash) return
|
|
14
|
+
): Fallbacks[Fallback] | string {
|
|
15
|
+
if (!hash) return fallbacks[fallback];
|
|
22
16
|
else return "https://cdn.zennify.app/media/" + hash
|
|
23
17
|
}
|
|
@@ -14,8 +14,8 @@ export interface Product {
|
|
|
14
14
|
created_at: string,
|
|
15
15
|
store_id: number,
|
|
16
16
|
owner_id: number,
|
|
17
|
-
icon_id?:
|
|
18
|
-
banner_id?:
|
|
17
|
+
icon_id?: string | null,
|
|
18
|
+
banner_id?: string | null,
|
|
19
19
|
value: number,
|
|
20
20
|
description: {
|
|
21
21
|
short: null | string,
|
|
@@ -47,16 +47,16 @@ type SaleTransaction = {
|
|
|
47
47
|
store: {
|
|
48
48
|
id: number,
|
|
49
49
|
name: string,
|
|
50
|
-
icon_id?:
|
|
51
|
-
banner_id?:
|
|
50
|
+
icon_id?: string | null,
|
|
51
|
+
banner_id?: string | null
|
|
52
52
|
},
|
|
53
53
|
products: [
|
|
54
54
|
{
|
|
55
55
|
id: number,
|
|
56
56
|
name: string,
|
|
57
57
|
value: number,
|
|
58
|
-
icon_id?:
|
|
59
|
-
banner_id?:
|
|
58
|
+
icon_id?: string | null,
|
|
59
|
+
banner_id?: string | null
|
|
60
60
|
amount: number,
|
|
61
61
|
delivered: string[]
|
|
62
62
|
}
|
package/src/main.ts
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
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
|
+
media = {
|
|
34
|
+
get_url: async (...options: Parameters<typeof GetImageURL>) => {
|
|
35
|
+
return GetImageURL(...options)?.replace("zennify.app", this.domain)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
package/types/images.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
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 {};
|
|
@@ -13,8 +13,8 @@ export interface Product {
|
|
|
13
13
|
created_at: string;
|
|
14
14
|
store_id: number;
|
|
15
15
|
owner_id: number;
|
|
16
|
-
icon_id?:
|
|
17
|
-
banner_id?:
|
|
16
|
+
icon_id?: string | null;
|
|
17
|
+
banner_id?: string | null;
|
|
18
18
|
value: number;
|
|
19
19
|
description: {
|
|
20
20
|
short: null | string;
|
|
@@ -45,16 +45,16 @@ type SaleTransaction = {
|
|
|
45
45
|
store: {
|
|
46
46
|
id: number;
|
|
47
47
|
name: string;
|
|
48
|
-
icon_id?:
|
|
49
|
-
banner_id?:
|
|
48
|
+
icon_id?: string | null;
|
|
49
|
+
banner_id?: string | null;
|
|
50
50
|
};
|
|
51
51
|
products: [
|
|
52
52
|
{
|
|
53
53
|
id: number;
|
|
54
54
|
name: string;
|
|
55
55
|
value: number;
|
|
56
|
-
icon_id?:
|
|
57
|
-
banner_id?:
|
|
56
|
+
icon_id?: string | null;
|
|
57
|
+
banner_id?: string | null;
|
|
58
58
|
amount: number;
|
|
59
59
|
delivered: string[];
|
|
60
60
|
}
|
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) => Promise<string | undefined>;
|
|
20
|
+
};
|
|
21
|
+
}
|