@zennify/sdk-js 1.0.0-beta.21 → 1.0.0-beta.22
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/package.json +1 -1
- package/src/images.ts +14 -4
- package/types/images.d.ts +8 -2
package/package.json
CHANGED
package/src/images.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
interface ImageSources {
|
|
2
|
+
void: void,
|
|
3
|
+
null: null,
|
|
4
|
+
empty: string,
|
|
5
|
+
product_icon: string,
|
|
6
|
+
general: string
|
|
7
|
+
}
|
|
2
8
|
|
|
3
9
|
const template = `https://cdn.zennify.app/media/{store_id}/{id}.png`
|
|
4
|
-
const sources: Record<ImageSources,
|
|
10
|
+
const sources: Record<keyof ImageSources, ImageSources[keyof ImageSources]> = {
|
|
5
11
|
'product_icon': `https://zennify.app/assets/images/emojis/caixa.png`,
|
|
6
12
|
'general': `https://zennify.app/assets/images/icon.png`,
|
|
7
13
|
'void': void 0,
|
|
@@ -9,8 +15,12 @@ const sources: Record<ImageSources, string | void | null> = {
|
|
|
9
15
|
'empty': ""
|
|
10
16
|
}
|
|
11
17
|
|
|
12
|
-
export function GetImageURL
|
|
13
|
-
|
|
18
|
+
export function GetImageURL<Source extends keyof ImageSources>(
|
|
19
|
+
source: Source,
|
|
20
|
+
store_id?: number | null,
|
|
21
|
+
id?: number | null
|
|
22
|
+
) {
|
|
23
|
+
if (!store_id || !id) return sources[source] as ImageSources[Source];
|
|
14
24
|
else return template
|
|
15
25
|
.replace("{store_id}", store_id.toString())
|
|
16
26
|
.replace("{id}", id.toString());
|
package/types/images.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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, store_id?: number | null, id?: number | null): string | ImageSources[Source];
|
|
3
9
|
export {};
|