@aicats/sdk 1.1.0 → 1.2.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/index.d.mts +51 -23
- package/dist/index.d.ts +51 -23
- package/dist/index.js +20 -10
- package/dist/index.mjs +20 -10
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Available media types for AI cat media
|
|
3
|
+
*/
|
|
4
|
+
declare enum Type {
|
|
5
|
+
/** All media types */
|
|
6
|
+
All = "All",
|
|
7
|
+
/** Image media type (Default) */
|
|
8
|
+
Image = "Image",
|
|
9
|
+
/** Video media type */
|
|
10
|
+
Video = "Video"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A search result containing a cat media ID and URL
|
|
3
15
|
*/
|
|
4
16
|
interface SearchResult {
|
|
5
|
-
/** Unique identifier for the cat
|
|
17
|
+
/** Unique identifier for the cat media */
|
|
6
18
|
id: string;
|
|
7
|
-
/** Direct URL to the cat
|
|
19
|
+
/** Direct URL to the cat media */
|
|
8
20
|
url: string;
|
|
21
|
+
/** The type of media */
|
|
22
|
+
type: Type;
|
|
9
23
|
}
|
|
10
24
|
|
|
11
25
|
/**
|
|
12
|
-
* Available themes for AI cat
|
|
26
|
+
* Available themes for AI cat media
|
|
13
27
|
*/
|
|
14
28
|
declare enum Theme {
|
|
15
|
-
/** Standard cat images */
|
|
29
|
+
/** Standard cat images/videos */
|
|
16
30
|
Default = "Default",
|
|
17
31
|
/** Spring-themed cats with flowers and nature */
|
|
18
32
|
Spring = "Spring",
|
|
@@ -33,23 +47,25 @@ declare enum Theme {
|
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
/**
|
|
36
|
-
* Detailed information about a cat
|
|
50
|
+
* Detailed information about a cat media
|
|
37
51
|
*/
|
|
38
52
|
interface CatInfo {
|
|
39
|
-
/** Unique identifier for the cat
|
|
53
|
+
/** Unique identifier for the cat media */
|
|
40
54
|
id: string;
|
|
41
|
-
/** URL to access the cat
|
|
55
|
+
/** URL to access the cat media */
|
|
42
56
|
url: string;
|
|
43
|
-
/** Unix timestamp when the
|
|
57
|
+
/** Unix timestamp when the media was created */
|
|
44
58
|
dateCreated: number;
|
|
45
|
-
/** The AI prompt used to generate this cat
|
|
59
|
+
/** The AI prompt used to generate this cat media */
|
|
46
60
|
prompt: string;
|
|
47
|
-
/** The theme of the cat
|
|
61
|
+
/** The theme of the cat media */
|
|
48
62
|
theme: Theme;
|
|
63
|
+
/** The type of media */
|
|
64
|
+
type: Type;
|
|
49
65
|
}
|
|
50
66
|
|
|
51
67
|
/**
|
|
52
|
-
* Available
|
|
68
|
+
* Available media sizes for AI cat media
|
|
53
69
|
*/
|
|
54
70
|
declare enum Size {
|
|
55
71
|
/** 1024x1024 pixels (default, highest quality) */
|
|
@@ -68,16 +84,18 @@ declare enum Size {
|
|
|
68
84
|
Micro = "16"
|
|
69
85
|
}
|
|
70
86
|
|
|
71
|
-
/** Response type for
|
|
87
|
+
/** Response type for media requests */
|
|
72
88
|
type ResponseType = 'blob' | 'arrayBuffer' | 'base64' | 'dataUrl';
|
|
73
|
-
/**
|
|
74
|
-
type
|
|
89
|
+
/** Media response based on responseType */
|
|
90
|
+
type MediaResponse<T extends ResponseType = 'blob'> = T extends 'blob' ? Blob : T extends 'arrayBuffer' ? ArrayBuffer : T extends 'base64' ? string : T extends 'dataUrl' ? string : Blob;
|
|
75
91
|
/** Options for getting a random cat */
|
|
76
92
|
interface RandomCatOptions<T extends ResponseType = 'blob'> {
|
|
77
|
-
/**
|
|
93
|
+
/** Media size (default: Large) */
|
|
78
94
|
size?: Size;
|
|
79
|
-
/** Theme of the cat
|
|
95
|
+
/** Theme of the cat media */
|
|
80
96
|
theme?: Theme;
|
|
97
|
+
/** Filter by media type */
|
|
98
|
+
type?: Type;
|
|
81
99
|
/** Response format (default: blob) */
|
|
82
100
|
responseType?: T;
|
|
83
101
|
}
|
|
@@ -93,33 +111,43 @@ interface SearchOptions {
|
|
|
93
111
|
descending?: boolean;
|
|
94
112
|
/** Filter by theme */
|
|
95
113
|
theme?: Theme;
|
|
96
|
-
/**
|
|
114
|
+
/** Media size in results */
|
|
97
115
|
size?: Size;
|
|
116
|
+
/** Filter by media type */
|
|
117
|
+
type?: Type;
|
|
98
118
|
}
|
|
99
119
|
/** Options for similar cats */
|
|
100
120
|
interface SimilarOptions {
|
|
101
121
|
/** Maximum number of results (1-100, default: 10) */
|
|
102
122
|
limit?: number;
|
|
103
|
-
/**
|
|
123
|
+
/** Media size in results */
|
|
104
124
|
size?: Size;
|
|
105
125
|
}
|
|
106
126
|
/** Options for getting a cat by ID */
|
|
107
127
|
interface GetByIdOptions<T extends ResponseType = 'blob'> {
|
|
108
|
-
/**
|
|
128
|
+
/** Media size (default: Large) */
|
|
109
129
|
size?: Size;
|
|
130
|
+
/** media type */
|
|
131
|
+
type?: Type;
|
|
110
132
|
/** Response format (default: blob) */
|
|
111
133
|
responseType?: T;
|
|
112
134
|
}
|
|
135
|
+
interface CountOptions {
|
|
136
|
+
/** Filter by theme */
|
|
137
|
+
theme?: Theme;
|
|
138
|
+
/** Filter by media type */
|
|
139
|
+
type?: Type;
|
|
140
|
+
}
|
|
113
141
|
|
|
114
142
|
declare const AiCats: {
|
|
115
|
-
random: <T extends ResponseType = "blob">(options?: RandomCatOptions<T>) => Promise<
|
|
116
|
-
getById: <T extends ResponseType = "blob">(id: string, options?: GetByIdOptions<T>) => Promise<
|
|
143
|
+
random: <T extends ResponseType = "blob">(options?: RandomCatOptions<T>) => Promise<MediaResponse<T>>;
|
|
144
|
+
getById: <T extends ResponseType = "blob">(id: string, options?: GetByIdOptions<T>) => Promise<MediaResponse<T>>;
|
|
117
145
|
getInfo: (id: string) => Promise<CatInfo>;
|
|
118
146
|
search: (options?: SearchOptions) => Promise<SearchResult[]>;
|
|
119
147
|
getSimilar: (id: string, options?: SimilarOptions) => Promise<SearchResult[]>;
|
|
120
148
|
getSearchCompletion: (options?: SearchOptions) => Promise<string>;
|
|
121
149
|
getThemes: () => Promise<Theme[]>;
|
|
122
|
-
getCount: (
|
|
150
|
+
getCount: (options?: CountOptions) => Promise<number>;
|
|
123
151
|
};
|
|
124
152
|
|
|
125
153
|
export { AiCats, type CatInfo, type RandomCatOptions, type SearchOptions, type SearchResult, type SimilarOptions, Size, Theme };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Available media types for AI cat media
|
|
3
|
+
*/
|
|
4
|
+
declare enum Type {
|
|
5
|
+
/** All media types */
|
|
6
|
+
All = "All",
|
|
7
|
+
/** Image media type (Default) */
|
|
8
|
+
Image = "Image",
|
|
9
|
+
/** Video media type */
|
|
10
|
+
Video = "Video"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A search result containing a cat media ID and URL
|
|
3
15
|
*/
|
|
4
16
|
interface SearchResult {
|
|
5
|
-
/** Unique identifier for the cat
|
|
17
|
+
/** Unique identifier for the cat media */
|
|
6
18
|
id: string;
|
|
7
|
-
/** Direct URL to the cat
|
|
19
|
+
/** Direct URL to the cat media */
|
|
8
20
|
url: string;
|
|
21
|
+
/** The type of media */
|
|
22
|
+
type: Type;
|
|
9
23
|
}
|
|
10
24
|
|
|
11
25
|
/**
|
|
12
|
-
* Available themes for AI cat
|
|
26
|
+
* Available themes for AI cat media
|
|
13
27
|
*/
|
|
14
28
|
declare enum Theme {
|
|
15
|
-
/** Standard cat images */
|
|
29
|
+
/** Standard cat images/videos */
|
|
16
30
|
Default = "Default",
|
|
17
31
|
/** Spring-themed cats with flowers and nature */
|
|
18
32
|
Spring = "Spring",
|
|
@@ -33,23 +47,25 @@ declare enum Theme {
|
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
/**
|
|
36
|
-
* Detailed information about a cat
|
|
50
|
+
* Detailed information about a cat media
|
|
37
51
|
*/
|
|
38
52
|
interface CatInfo {
|
|
39
|
-
/** Unique identifier for the cat
|
|
53
|
+
/** Unique identifier for the cat media */
|
|
40
54
|
id: string;
|
|
41
|
-
/** URL to access the cat
|
|
55
|
+
/** URL to access the cat media */
|
|
42
56
|
url: string;
|
|
43
|
-
/** Unix timestamp when the
|
|
57
|
+
/** Unix timestamp when the media was created */
|
|
44
58
|
dateCreated: number;
|
|
45
|
-
/** The AI prompt used to generate this cat
|
|
59
|
+
/** The AI prompt used to generate this cat media */
|
|
46
60
|
prompt: string;
|
|
47
|
-
/** The theme of the cat
|
|
61
|
+
/** The theme of the cat media */
|
|
48
62
|
theme: Theme;
|
|
63
|
+
/** The type of media */
|
|
64
|
+
type: Type;
|
|
49
65
|
}
|
|
50
66
|
|
|
51
67
|
/**
|
|
52
|
-
* Available
|
|
68
|
+
* Available media sizes for AI cat media
|
|
53
69
|
*/
|
|
54
70
|
declare enum Size {
|
|
55
71
|
/** 1024x1024 pixels (default, highest quality) */
|
|
@@ -68,16 +84,18 @@ declare enum Size {
|
|
|
68
84
|
Micro = "16"
|
|
69
85
|
}
|
|
70
86
|
|
|
71
|
-
/** Response type for
|
|
87
|
+
/** Response type for media requests */
|
|
72
88
|
type ResponseType = 'blob' | 'arrayBuffer' | 'base64' | 'dataUrl';
|
|
73
|
-
/**
|
|
74
|
-
type
|
|
89
|
+
/** Media response based on responseType */
|
|
90
|
+
type MediaResponse<T extends ResponseType = 'blob'> = T extends 'blob' ? Blob : T extends 'arrayBuffer' ? ArrayBuffer : T extends 'base64' ? string : T extends 'dataUrl' ? string : Blob;
|
|
75
91
|
/** Options for getting a random cat */
|
|
76
92
|
interface RandomCatOptions<T extends ResponseType = 'blob'> {
|
|
77
|
-
/**
|
|
93
|
+
/** Media size (default: Large) */
|
|
78
94
|
size?: Size;
|
|
79
|
-
/** Theme of the cat
|
|
95
|
+
/** Theme of the cat media */
|
|
80
96
|
theme?: Theme;
|
|
97
|
+
/** Filter by media type */
|
|
98
|
+
type?: Type;
|
|
81
99
|
/** Response format (default: blob) */
|
|
82
100
|
responseType?: T;
|
|
83
101
|
}
|
|
@@ -93,33 +111,43 @@ interface SearchOptions {
|
|
|
93
111
|
descending?: boolean;
|
|
94
112
|
/** Filter by theme */
|
|
95
113
|
theme?: Theme;
|
|
96
|
-
/**
|
|
114
|
+
/** Media size in results */
|
|
97
115
|
size?: Size;
|
|
116
|
+
/** Filter by media type */
|
|
117
|
+
type?: Type;
|
|
98
118
|
}
|
|
99
119
|
/** Options for similar cats */
|
|
100
120
|
interface SimilarOptions {
|
|
101
121
|
/** Maximum number of results (1-100, default: 10) */
|
|
102
122
|
limit?: number;
|
|
103
|
-
/**
|
|
123
|
+
/** Media size in results */
|
|
104
124
|
size?: Size;
|
|
105
125
|
}
|
|
106
126
|
/** Options for getting a cat by ID */
|
|
107
127
|
interface GetByIdOptions<T extends ResponseType = 'blob'> {
|
|
108
|
-
/**
|
|
128
|
+
/** Media size (default: Large) */
|
|
109
129
|
size?: Size;
|
|
130
|
+
/** media type */
|
|
131
|
+
type?: Type;
|
|
110
132
|
/** Response format (default: blob) */
|
|
111
133
|
responseType?: T;
|
|
112
134
|
}
|
|
135
|
+
interface CountOptions {
|
|
136
|
+
/** Filter by theme */
|
|
137
|
+
theme?: Theme;
|
|
138
|
+
/** Filter by media type */
|
|
139
|
+
type?: Type;
|
|
140
|
+
}
|
|
113
141
|
|
|
114
142
|
declare const AiCats: {
|
|
115
|
-
random: <T extends ResponseType = "blob">(options?: RandomCatOptions<T>) => Promise<
|
|
116
|
-
getById: <T extends ResponseType = "blob">(id: string, options?: GetByIdOptions<T>) => Promise<
|
|
143
|
+
random: <T extends ResponseType = "blob">(options?: RandomCatOptions<T>) => Promise<MediaResponse<T>>;
|
|
144
|
+
getById: <T extends ResponseType = "blob">(id: string, options?: GetByIdOptions<T>) => Promise<MediaResponse<T>>;
|
|
117
145
|
getInfo: (id: string) => Promise<CatInfo>;
|
|
118
146
|
search: (options?: SearchOptions) => Promise<SearchResult[]>;
|
|
119
147
|
getSimilar: (id: string, options?: SimilarOptions) => Promise<SearchResult[]>;
|
|
120
148
|
getSearchCompletion: (options?: SearchOptions) => Promise<string>;
|
|
121
149
|
getThemes: () => Promise<Theme[]>;
|
|
122
|
-
getCount: (
|
|
150
|
+
getCount: (options?: CountOptions) => Promise<number>;
|
|
123
151
|
};
|
|
124
152
|
|
|
125
153
|
export { AiCats, type CatInfo, type RandomCatOptions, type SearchOptions, type SearchResult, type SimilarOptions, Size, Theme };
|
package/dist/index.js
CHANGED
|
@@ -54,7 +54,7 @@ var Theme = /* @__PURE__ */ ((Theme2) => {
|
|
|
54
54
|
|
|
55
55
|
// src/api/ai-cats-api.ts
|
|
56
56
|
var ApiUrl = "https://api.ai-cats.net/v1";
|
|
57
|
-
async function toResponseType(buffer, type = "blob") {
|
|
57
|
+
async function toResponseType(buffer, mediaType = "Image" /* Image */, type = "blob") {
|
|
58
58
|
switch (type) {
|
|
59
59
|
case "arrayBuffer":
|
|
60
60
|
return buffer;
|
|
@@ -72,34 +72,38 @@ async function toResponseType(buffer, type = "blob") {
|
|
|
72
72
|
for (let i = 0; i < bytes.length; i++) {
|
|
73
73
|
binary += String.fromCharCode(bytes[i]);
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
const mimeType2 = mediaType === "Video" /* Video */ ? "video/mp4" : "image/jpeg";
|
|
76
|
+
return `data:${mimeType2};base64,${btoa(binary)}`;
|
|
76
77
|
}
|
|
77
78
|
case "blob":
|
|
78
79
|
default:
|
|
79
|
-
|
|
80
|
+
const mimeType = mediaType === "Video" /* Video */ ? "video/mp4" : "image/jpeg";
|
|
81
|
+
return new Blob([buffer], { type: mimeType });
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
async function random(options) {
|
|
83
85
|
const params = new URLSearchParams();
|
|
84
86
|
if (options?.size) params.set("size", options.size);
|
|
85
87
|
if (options?.theme) params.set("theme", options.theme);
|
|
88
|
+
if (options?.type) params.set("type", options.type);
|
|
86
89
|
params.set("rnd", Math.random().toString());
|
|
87
90
|
const query = params.toString() ? `?${params}` : "";
|
|
88
91
|
const response = await fetch(`${ApiUrl}/cat${query}`);
|
|
89
92
|
if (!response.ok) {
|
|
90
|
-
throw new Error(`Error fetching cat
|
|
93
|
+
throw new Error(`Error fetching cat media: ${response.statusText}`);
|
|
91
94
|
}
|
|
92
95
|
const buffer = await response.arrayBuffer();
|
|
93
|
-
return toResponseType(buffer, options?.responseType ?? "blob");
|
|
96
|
+
return toResponseType(buffer, options?.type, options?.responseType ?? "blob");
|
|
94
97
|
}
|
|
95
98
|
async function getById(id, options) {
|
|
96
99
|
const size = options?.size ?? "1024" /* Large */;
|
|
97
|
-
const
|
|
100
|
+
const suffix = options?.type === "Video" /* Video */ ? ".mp4" : ".jpg";
|
|
101
|
+
const response = await fetch(`${ApiUrl}/cat/${id}${suffix}?size=${size}`);
|
|
98
102
|
if (!response.ok) {
|
|
99
|
-
throw new Error(`Error fetching cat
|
|
103
|
+
throw new Error(`Error fetching cat media: ${response.statusText}`);
|
|
100
104
|
}
|
|
101
105
|
const buffer = await response.arrayBuffer();
|
|
102
|
-
return toResponseType(buffer, options?.responseType ?? "blob");
|
|
106
|
+
return toResponseType(buffer, options?.type, options?.responseType ?? "blob");
|
|
103
107
|
}
|
|
104
108
|
async function getInfo(id) {
|
|
105
109
|
const response = await fetch(`${ApiUrl}/cat/info/${id}`);
|
|
@@ -116,6 +120,7 @@ async function search(options = {}) {
|
|
|
116
120
|
if (options.descending) params.set("descending", "true");
|
|
117
121
|
if (options.theme) params.set("theme", options.theme);
|
|
118
122
|
if (options.size) params.set("size", options.size);
|
|
123
|
+
if (options.type) params.set("type", options.type);
|
|
119
124
|
const query = params.toString() ? `?${params}` : "";
|
|
120
125
|
const response = await fetch(`${ApiUrl}/cat/search${query}`);
|
|
121
126
|
if (!response.ok) {
|
|
@@ -142,6 +147,7 @@ async function getSearchCompletion(options = {}) {
|
|
|
142
147
|
if (options.descending) params.set("descending", "true");
|
|
143
148
|
if (options.theme) params.set("theme", options.theme);
|
|
144
149
|
if (options.size) params.set("size", options.size);
|
|
150
|
+
if (options.type) params.set("type", options.type);
|
|
145
151
|
const query = params.toString() ? `?${params}` : "";
|
|
146
152
|
const response = await fetch(`${ApiUrl}/cat/search-completion${query}`);
|
|
147
153
|
if (!response.ok) {
|
|
@@ -158,8 +164,12 @@ async function getThemes() {
|
|
|
158
164
|
const data = await response.json();
|
|
159
165
|
return data.themes;
|
|
160
166
|
}
|
|
161
|
-
async function getCount(
|
|
162
|
-
const
|
|
167
|
+
async function getCount(options = {}) {
|
|
168
|
+
const params = new URLSearchParams();
|
|
169
|
+
if (options.theme) params.set("theme", options.theme);
|
|
170
|
+
if (options.type) params.set("type", options.type);
|
|
171
|
+
const query = params.toString() ? `?${params}` : "";
|
|
172
|
+
const response = await fetch(`${ApiUrl}/cat/count${query}`);
|
|
163
173
|
if (!response.ok) {
|
|
164
174
|
throw new Error(`Error fetching count: ${response.statusText}`);
|
|
165
175
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -26,7 +26,7 @@ var Theme = /* @__PURE__ */ ((Theme2) => {
|
|
|
26
26
|
|
|
27
27
|
// src/api/ai-cats-api.ts
|
|
28
28
|
var ApiUrl = "https://api.ai-cats.net/v1";
|
|
29
|
-
async function toResponseType(buffer, type = "blob") {
|
|
29
|
+
async function toResponseType(buffer, mediaType = "Image" /* Image */, type = "blob") {
|
|
30
30
|
switch (type) {
|
|
31
31
|
case "arrayBuffer":
|
|
32
32
|
return buffer;
|
|
@@ -44,34 +44,38 @@ async function toResponseType(buffer, type = "blob") {
|
|
|
44
44
|
for (let i = 0; i < bytes.length; i++) {
|
|
45
45
|
binary += String.fromCharCode(bytes[i]);
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
const mimeType2 = mediaType === "Video" /* Video */ ? "video/mp4" : "image/jpeg";
|
|
48
|
+
return `data:${mimeType2};base64,${btoa(binary)}`;
|
|
48
49
|
}
|
|
49
50
|
case "blob":
|
|
50
51
|
default:
|
|
51
|
-
|
|
52
|
+
const mimeType = mediaType === "Video" /* Video */ ? "video/mp4" : "image/jpeg";
|
|
53
|
+
return new Blob([buffer], { type: mimeType });
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
async function random(options) {
|
|
55
57
|
const params = new URLSearchParams();
|
|
56
58
|
if (options?.size) params.set("size", options.size);
|
|
57
59
|
if (options?.theme) params.set("theme", options.theme);
|
|
60
|
+
if (options?.type) params.set("type", options.type);
|
|
58
61
|
params.set("rnd", Math.random().toString());
|
|
59
62
|
const query = params.toString() ? `?${params}` : "";
|
|
60
63
|
const response = await fetch(`${ApiUrl}/cat${query}`);
|
|
61
64
|
if (!response.ok) {
|
|
62
|
-
throw new Error(`Error fetching cat
|
|
65
|
+
throw new Error(`Error fetching cat media: ${response.statusText}`);
|
|
63
66
|
}
|
|
64
67
|
const buffer = await response.arrayBuffer();
|
|
65
|
-
return toResponseType(buffer, options?.responseType ?? "blob");
|
|
68
|
+
return toResponseType(buffer, options?.type, options?.responseType ?? "blob");
|
|
66
69
|
}
|
|
67
70
|
async function getById(id, options) {
|
|
68
71
|
const size = options?.size ?? "1024" /* Large */;
|
|
69
|
-
const
|
|
72
|
+
const suffix = options?.type === "Video" /* Video */ ? ".mp4" : ".jpg";
|
|
73
|
+
const response = await fetch(`${ApiUrl}/cat/${id}${suffix}?size=${size}`);
|
|
70
74
|
if (!response.ok) {
|
|
71
|
-
throw new Error(`Error fetching cat
|
|
75
|
+
throw new Error(`Error fetching cat media: ${response.statusText}`);
|
|
72
76
|
}
|
|
73
77
|
const buffer = await response.arrayBuffer();
|
|
74
|
-
return toResponseType(buffer, options?.responseType ?? "blob");
|
|
78
|
+
return toResponseType(buffer, options?.type, options?.responseType ?? "blob");
|
|
75
79
|
}
|
|
76
80
|
async function getInfo(id) {
|
|
77
81
|
const response = await fetch(`${ApiUrl}/cat/info/${id}`);
|
|
@@ -88,6 +92,7 @@ async function search(options = {}) {
|
|
|
88
92
|
if (options.descending) params.set("descending", "true");
|
|
89
93
|
if (options.theme) params.set("theme", options.theme);
|
|
90
94
|
if (options.size) params.set("size", options.size);
|
|
95
|
+
if (options.type) params.set("type", options.type);
|
|
91
96
|
const query = params.toString() ? `?${params}` : "";
|
|
92
97
|
const response = await fetch(`${ApiUrl}/cat/search${query}`);
|
|
93
98
|
if (!response.ok) {
|
|
@@ -114,6 +119,7 @@ async function getSearchCompletion(options = {}) {
|
|
|
114
119
|
if (options.descending) params.set("descending", "true");
|
|
115
120
|
if (options.theme) params.set("theme", options.theme);
|
|
116
121
|
if (options.size) params.set("size", options.size);
|
|
122
|
+
if (options.type) params.set("type", options.type);
|
|
117
123
|
const query = params.toString() ? `?${params}` : "";
|
|
118
124
|
const response = await fetch(`${ApiUrl}/cat/search-completion${query}`);
|
|
119
125
|
if (!response.ok) {
|
|
@@ -130,8 +136,12 @@ async function getThemes() {
|
|
|
130
136
|
const data = await response.json();
|
|
131
137
|
return data.themes;
|
|
132
138
|
}
|
|
133
|
-
async function getCount(
|
|
134
|
-
const
|
|
139
|
+
async function getCount(options = {}) {
|
|
140
|
+
const params = new URLSearchParams();
|
|
141
|
+
if (options.theme) params.set("theme", options.theme);
|
|
142
|
+
if (options.type) params.set("type", options.type);
|
|
143
|
+
const query = params.toString() ? `?${params}` : "";
|
|
144
|
+
const response = await fetch(`${ApiUrl}/cat/count${query}`);
|
|
135
145
|
if (!response.ok) {
|
|
136
146
|
throw new Error(`Error fetching count: ${response.statusText}`);
|
|
137
147
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aicats/sdk",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Official JavaScript SDK for the ai-cats.net API",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"api",
|
|
34
34
|
"sdk",
|
|
35
35
|
"ai-cats",
|
|
36
|
-
"images"
|
|
36
|
+
"images",
|
|
37
|
+
"videos"
|
|
37
38
|
],
|
|
38
39
|
"author": {
|
|
39
40
|
"name": "Mario Bertsch",
|