@garchicms/garchi-node-sdk 0.0.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/LICENSE.md +21 -0
- package/README.md +269 -0
- package/dist/index.cjs +448 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +384 -0
- package/dist/index.d.ts +384 -0
- package/dist/index.js +415 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
interface PaginationLinks {
|
|
2
|
+
first: string;
|
|
3
|
+
last: string;
|
|
4
|
+
prev: string | null;
|
|
5
|
+
next: string | null;
|
|
6
|
+
}
|
|
7
|
+
interface PaginationMeta {
|
|
8
|
+
current_page: number;
|
|
9
|
+
from: number;
|
|
10
|
+
last_page: number;
|
|
11
|
+
links: Array<{
|
|
12
|
+
url: string | null;
|
|
13
|
+
label: string;
|
|
14
|
+
active: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
path: string;
|
|
17
|
+
per_page: number;
|
|
18
|
+
to: number;
|
|
19
|
+
total: number;
|
|
20
|
+
}
|
|
21
|
+
interface PaginatedResponse<T> {
|
|
22
|
+
data: T[];
|
|
23
|
+
links: PaginationLinks;
|
|
24
|
+
meta: PaginationMeta;
|
|
25
|
+
}
|
|
26
|
+
interface GetPageParams {
|
|
27
|
+
space_uid: string;
|
|
28
|
+
slug: string;
|
|
29
|
+
lang?: string;
|
|
30
|
+
mode?: "draft" | "live";
|
|
31
|
+
}
|
|
32
|
+
type GarchiPage = {
|
|
33
|
+
id: string;
|
|
34
|
+
title: string;
|
|
35
|
+
slug: string;
|
|
36
|
+
description: string;
|
|
37
|
+
sections: GarchiSection[];
|
|
38
|
+
};
|
|
39
|
+
type SectionPropType = "text" | "longtext" | "media" | "richtext" | "select";
|
|
40
|
+
interface SectionTemplateProp {
|
|
41
|
+
key: string;
|
|
42
|
+
type: SectionPropType;
|
|
43
|
+
allowed_values?: string;
|
|
44
|
+
}
|
|
45
|
+
interface SectionTemplate {
|
|
46
|
+
name: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
prev_name?: string;
|
|
49
|
+
props?: SectionTemplateProp[];
|
|
50
|
+
}
|
|
51
|
+
interface CreateOrUpdateSectionTemplateParams {
|
|
52
|
+
space_uid: string;
|
|
53
|
+
section_templates: SectionTemplate[];
|
|
54
|
+
}
|
|
55
|
+
type GarchiSection = {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
props: {
|
|
60
|
+
[key: string]: unknown;
|
|
61
|
+
};
|
|
62
|
+
children: GarchiSection[];
|
|
63
|
+
order: number;
|
|
64
|
+
};
|
|
65
|
+
type GarchiReviewCreate = {
|
|
66
|
+
item_id: number;
|
|
67
|
+
rating: number;
|
|
68
|
+
review_body: string;
|
|
69
|
+
user_email?: string;
|
|
70
|
+
user_name?: string;
|
|
71
|
+
parent_id?: number;
|
|
72
|
+
};
|
|
73
|
+
type GarchiReviewUpdate = {
|
|
74
|
+
review_id: number;
|
|
75
|
+
review_body?: string;
|
|
76
|
+
rating: number;
|
|
77
|
+
};
|
|
78
|
+
type GarchiReactionCreate = {
|
|
79
|
+
reaction: string;
|
|
80
|
+
user_identifier: string;
|
|
81
|
+
review_id?: number;
|
|
82
|
+
item_id?: number;
|
|
83
|
+
reaction_for: "review" | "item";
|
|
84
|
+
};
|
|
85
|
+
type GarchiReaction = {
|
|
86
|
+
reaction_id: string;
|
|
87
|
+
reaction: string;
|
|
88
|
+
user_identifier: string;
|
|
89
|
+
created_at: string;
|
|
90
|
+
updated_at: string;
|
|
91
|
+
};
|
|
92
|
+
type GarchiReview = {
|
|
93
|
+
review_id: number;
|
|
94
|
+
review_body: string;
|
|
95
|
+
rating: number;
|
|
96
|
+
guest: null;
|
|
97
|
+
user: {
|
|
98
|
+
fname: string;
|
|
99
|
+
lname: string;
|
|
100
|
+
};
|
|
101
|
+
item_id: number;
|
|
102
|
+
reviewed_at: string;
|
|
103
|
+
replies?: GarchiReview[];
|
|
104
|
+
reactions?: GarchiReaction[];
|
|
105
|
+
};
|
|
106
|
+
type GarchiCategory = {
|
|
107
|
+
id: number;
|
|
108
|
+
name: string;
|
|
109
|
+
};
|
|
110
|
+
type GarchiAttributeOption = {
|
|
111
|
+
id: number;
|
|
112
|
+
name: string;
|
|
113
|
+
price: number;
|
|
114
|
+
};
|
|
115
|
+
type GarchiAttribute = {
|
|
116
|
+
id: number;
|
|
117
|
+
name: string;
|
|
118
|
+
min: string;
|
|
119
|
+
options: GarchiAttributeOption[];
|
|
120
|
+
};
|
|
121
|
+
type GarchiSpace = {
|
|
122
|
+
uid: string;
|
|
123
|
+
name: string;
|
|
124
|
+
logo_url?: string;
|
|
125
|
+
number_of_items: number;
|
|
126
|
+
};
|
|
127
|
+
type GarchiSpaceCreate = {
|
|
128
|
+
name: string;
|
|
129
|
+
logo?: File;
|
|
130
|
+
};
|
|
131
|
+
type GarchiSpaceAPIResponse = PaginatedResponse<GarchiSpace>;
|
|
132
|
+
type GarchiItemMeta = {
|
|
133
|
+
id?: number;
|
|
134
|
+
key: string;
|
|
135
|
+
value: string;
|
|
136
|
+
type: string;
|
|
137
|
+
};
|
|
138
|
+
type GarchiItem = {
|
|
139
|
+
item_id: number;
|
|
140
|
+
slug: string;
|
|
141
|
+
sku?: string;
|
|
142
|
+
name: string;
|
|
143
|
+
stock?: number;
|
|
144
|
+
categories: GarchiCategory[];
|
|
145
|
+
price?: number;
|
|
146
|
+
external_link?: string;
|
|
147
|
+
scratched_price?: number | null;
|
|
148
|
+
one_liner?: string;
|
|
149
|
+
description?: string;
|
|
150
|
+
delivery_type?: string;
|
|
151
|
+
main_image?: string;
|
|
152
|
+
other_images?: string[];
|
|
153
|
+
attributes?: GarchiAttribute[];
|
|
154
|
+
space?: GarchiSpace;
|
|
155
|
+
avg_rating?: number | null;
|
|
156
|
+
scheduled_for?: string | null;
|
|
157
|
+
item_meta?: GarchiItemMeta[];
|
|
158
|
+
reactions?: GarchiReaction[];
|
|
159
|
+
created?: string;
|
|
160
|
+
updated?: string;
|
|
161
|
+
};
|
|
162
|
+
type GarchiItemAPIResponse = PaginatedResponse<GarchiItem>;
|
|
163
|
+
type GarchiCategoryAPIResponse = PaginatedResponse<GarchiCategory>;
|
|
164
|
+
type GarchiAsset = {
|
|
165
|
+
id: string;
|
|
166
|
+
path: string;
|
|
167
|
+
size: string;
|
|
168
|
+
type: string;
|
|
169
|
+
};
|
|
170
|
+
type GarchiCMSInitOptions = {
|
|
171
|
+
api_key?: string;
|
|
172
|
+
headers?: Record<string, string | number | boolean>;
|
|
173
|
+
};
|
|
174
|
+
interface CreateDataItemParams {
|
|
175
|
+
space_uid: string;
|
|
176
|
+
name: string;
|
|
177
|
+
categories: number[];
|
|
178
|
+
sku?: string;
|
|
179
|
+
stock?: number;
|
|
180
|
+
price?: number;
|
|
181
|
+
scratched_price?: number;
|
|
182
|
+
detail_description?: string;
|
|
183
|
+
external_url?: string;
|
|
184
|
+
slug?: string;
|
|
185
|
+
}
|
|
186
|
+
interface DeleteDataItemParams {
|
|
187
|
+
item_id: number;
|
|
188
|
+
space_uid: string;
|
|
189
|
+
}
|
|
190
|
+
interface UpdateDataItemParams {
|
|
191
|
+
item_id: number;
|
|
192
|
+
space_uid: string;
|
|
193
|
+
name?: string;
|
|
194
|
+
sku?: string;
|
|
195
|
+
stock?: number;
|
|
196
|
+
categories?: number[];
|
|
197
|
+
price?: number;
|
|
198
|
+
scratched_price?: number;
|
|
199
|
+
detail_description?: string;
|
|
200
|
+
external_url?: string;
|
|
201
|
+
make_public?: boolean;
|
|
202
|
+
slug?: string;
|
|
203
|
+
}
|
|
204
|
+
type MetaType = "string" | "array" | "url" | "object" | "numeric" | "email" | "date";
|
|
205
|
+
interface MetaInfo {
|
|
206
|
+
key: string;
|
|
207
|
+
type: MetaType;
|
|
208
|
+
value: string;
|
|
209
|
+
}
|
|
210
|
+
interface CreateMetaInfoParams {
|
|
211
|
+
item_id: number;
|
|
212
|
+
meta: MetaInfo[];
|
|
213
|
+
}
|
|
214
|
+
interface DeleteMetaInfoParams {
|
|
215
|
+
meta_id: number;
|
|
216
|
+
item_id: number;
|
|
217
|
+
space_uid: string;
|
|
218
|
+
}
|
|
219
|
+
interface UpdateMetaInfoParams {
|
|
220
|
+
meta_id: number;
|
|
221
|
+
item_id: number;
|
|
222
|
+
key?: string;
|
|
223
|
+
type?: MetaType;
|
|
224
|
+
value?: string;
|
|
225
|
+
}
|
|
226
|
+
interface PaginateQueryParams {
|
|
227
|
+
size?: number;
|
|
228
|
+
page?: number;
|
|
229
|
+
}
|
|
230
|
+
interface ItemsQueryParams extends PaginateQueryParams {
|
|
231
|
+
order_key?: "name" | "price" | "created" | `meta.${string}`;
|
|
232
|
+
order_by?: "asc" | "desc";
|
|
233
|
+
reactions?: "include" | "exclude";
|
|
234
|
+
description?: "include" | "exclude";
|
|
235
|
+
}
|
|
236
|
+
interface GetItemsBySpaceParams extends ItemsQueryParams {
|
|
237
|
+
uid: string;
|
|
238
|
+
}
|
|
239
|
+
interface SemanticSearchParams {
|
|
240
|
+
q: string;
|
|
241
|
+
threshold?: number;
|
|
242
|
+
reactions?: "include" | "exclude";
|
|
243
|
+
description?: "include" | "exclude";
|
|
244
|
+
}
|
|
245
|
+
interface GetFeaturedItemsParams {
|
|
246
|
+
reactions?: "include" | "exclude";
|
|
247
|
+
description?: "include" | "exclude";
|
|
248
|
+
}
|
|
249
|
+
interface GetItemParams {
|
|
250
|
+
item: string | number;
|
|
251
|
+
reactions?: "include" | "exclude";
|
|
252
|
+
}
|
|
253
|
+
interface GetAllItemsParams extends ItemsQueryParams {
|
|
254
|
+
search_keyword?: string;
|
|
255
|
+
}
|
|
256
|
+
interface FilterItemsBodyParams {
|
|
257
|
+
spaces?: string[];
|
|
258
|
+
categories?: number[];
|
|
259
|
+
priceOrder?: "low-high" | "high-low";
|
|
260
|
+
size?: number;
|
|
261
|
+
}
|
|
262
|
+
interface FilterItemsParams {
|
|
263
|
+
query?: ItemsQueryParams;
|
|
264
|
+
body: FilterItemsBodyParams;
|
|
265
|
+
}
|
|
266
|
+
type MetaFilterOperator = "equals" | "in" | "like" | "gte" | "lte";
|
|
267
|
+
interface MetaFilter {
|
|
268
|
+
key: string;
|
|
269
|
+
value: string | number | (string | number)[];
|
|
270
|
+
operator: MetaFilterOperator;
|
|
271
|
+
}
|
|
272
|
+
interface FilterItemsByMetaBodyParams {
|
|
273
|
+
meta_filters: MetaFilter[];
|
|
274
|
+
}
|
|
275
|
+
interface FilterItemsByMetaParams {
|
|
276
|
+
query?: ItemsQueryParams;
|
|
277
|
+
body: FilterItemsByMetaBodyParams;
|
|
278
|
+
}
|
|
279
|
+
interface GetItemsByIdsBodyParams {
|
|
280
|
+
item_ids: (number | string)[];
|
|
281
|
+
}
|
|
282
|
+
interface GetItemsByIdsParams {
|
|
283
|
+
query?: ItemsQueryParams;
|
|
284
|
+
body: GetItemsByIdsBodyParams;
|
|
285
|
+
}
|
|
286
|
+
interface CreateCategoryParams {
|
|
287
|
+
category: string;
|
|
288
|
+
space_uid: string;
|
|
289
|
+
}
|
|
290
|
+
interface DeleteCategoryParams {
|
|
291
|
+
category_id: number;
|
|
292
|
+
space_uid: string;
|
|
293
|
+
}
|
|
294
|
+
interface UpdateCategoryParams extends CreateCategoryParams {
|
|
295
|
+
category_id: number;
|
|
296
|
+
}
|
|
297
|
+
type DatasetType = "items" | "categories" | "reviews";
|
|
298
|
+
type ItemFields = "item_id" | "name" | "slug" | "description" | "categories" | "ratings" | "price" | "created";
|
|
299
|
+
type CategoryFields = "category_id" | "category_name";
|
|
300
|
+
type ReviewFields = "review_id" | "item_id" | "rating" | "review" | "created";
|
|
301
|
+
type ConditionType = "eq" | "gte" | "lte" | "gt" | "lt" | "like" | "in" | "not_eq" | "not_in";
|
|
302
|
+
type LogicType = "and" | "or";
|
|
303
|
+
interface CompoundQueryBody {
|
|
304
|
+
dataset: DatasetType;
|
|
305
|
+
fields: string[];
|
|
306
|
+
conditions: ConditionType[];
|
|
307
|
+
values: (string | number)[];
|
|
308
|
+
logic?: LogicType[];
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
declare class APIClient {
|
|
312
|
+
client: Axios.AxiosInstance;
|
|
313
|
+
constructor(options: GarchiCMSInitOptions | null);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
declare class Category extends APIClient {
|
|
317
|
+
create(params: CreateCategoryParams): Promise<GarchiCategory>;
|
|
318
|
+
delete(params: DeleteCategoryParams): Promise<string>;
|
|
319
|
+
update(params: UpdateCategoryParams): Promise<string>;
|
|
320
|
+
getAll(): Promise<GarchiCategory[]>;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare class CompoundQuery extends APIClient {
|
|
324
|
+
query(body: CompoundQueryBody, params: ItemsQueryParams): Promise<GarchiItemAPIResponse | GarchiCategoryAPIResponse | PaginatedResponse<GarchiReview>>;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
declare class DataItem extends APIClient {
|
|
328
|
+
create(params: CreateDataItemParams): Promise<GarchiItem>;
|
|
329
|
+
delete(params: DeleteDataItemParams): Promise<string>;
|
|
330
|
+
update(params: UpdateDataItemParams): Promise<string>;
|
|
331
|
+
createMetaInfo(params: CreateMetaInfoParams): Promise<GarchiItemMeta[]>;
|
|
332
|
+
deleteMetaInfo(params: DeleteMetaInfoParams): Promise<string>;
|
|
333
|
+
updateMetaInfo(params: UpdateMetaInfoParams): Promise<string>;
|
|
334
|
+
getBySpace(params: GetItemsBySpaceParams): Promise<GarchiItemAPIResponse>;
|
|
335
|
+
semanticSearch(params: SemanticSearchParams): Promise<GarchiItem[]>;
|
|
336
|
+
featured(params: GetFeaturedItemsParams): Promise<GarchiItemAPIResponse>;
|
|
337
|
+
get(params: GetItemParams): Promise<GarchiItem>;
|
|
338
|
+
getAll(params: GetAllItemsParams): Promise<GarchiItemAPIResponse>;
|
|
339
|
+
filter(params: FilterItemsParams): Promise<GarchiItem[]>;
|
|
340
|
+
filterByMeta(params: FilterItemsByMetaParams): Promise<GarchiItem[]>;
|
|
341
|
+
getByIds(params: GetItemsByIdsParams): Promise<GarchiItemAPIResponse>;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
declare class Headless extends APIClient {
|
|
345
|
+
getAsset(file_name: string, space_uid: string): Promise<GarchiAsset>;
|
|
346
|
+
getPage(params: GetPageParams): Promise<GarchiPage>;
|
|
347
|
+
createOrUpdateSectionTemplates(params: CreateOrUpdateSectionTemplateParams): Promise<string>;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
declare class Reaction extends APIClient {
|
|
351
|
+
manage(params: GarchiReactionCreate): Promise<GarchiReaction>;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
declare class Review extends APIClient {
|
|
355
|
+
create(params: GarchiReviewCreate): Promise<GarchiReview>;
|
|
356
|
+
update(params: GarchiReviewUpdate): Promise<string>;
|
|
357
|
+
delete(review_id: number): Promise<string>;
|
|
358
|
+
getByItem(item_id: number | string, queryParams: PaginateQueryParams): Promise<PaginatedResponse<GarchiReview>>;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
declare class Space extends APIClient {
|
|
362
|
+
categories(space_uid: string): Promise<GarchiCategory[]>;
|
|
363
|
+
getAll(params: PaginateQueryParams): Promise<GarchiSpaceAPIResponse>;
|
|
364
|
+
get(space_uid: string): Promise<GarchiSpace>;
|
|
365
|
+
create(params: GarchiSpaceCreate): Promise<GarchiSpace>;
|
|
366
|
+
update(space_uid: string, params: {
|
|
367
|
+
name?: string;
|
|
368
|
+
logo?: File;
|
|
369
|
+
}): Promise<string>;
|
|
370
|
+
delete(space_uid: string): Promise<string>;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
declare class GarchiCMS {
|
|
374
|
+
dataItem: DataItem;
|
|
375
|
+
category: Category;
|
|
376
|
+
space: Space;
|
|
377
|
+
review: Review;
|
|
378
|
+
headless: Headless;
|
|
379
|
+
reaction: Reaction;
|
|
380
|
+
compoundQuery: CompoundQuery;
|
|
381
|
+
constructor(options: GarchiCMSInitOptions);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export { type CategoryFields, type CompoundQueryBody, type ConditionType, type CreateCategoryParams, type CreateDataItemParams, type CreateMetaInfoParams, type CreateOrUpdateSectionTemplateParams, type DatasetType, type DeleteCategoryParams, type DeleteDataItemParams, type DeleteMetaInfoParams, type FilterItemsBodyParams, type FilterItemsByMetaBodyParams, type FilterItemsByMetaParams, type FilterItemsParams, type GarchiAsset, type GarchiAttribute, type GarchiAttributeOption, type GarchiCMSInitOptions, type GarchiCategory, type GarchiCategoryAPIResponse, type GarchiItem, type GarchiItemAPIResponse, type GarchiItemMeta, type GarchiPage, type GarchiReaction, type GarchiReactionCreate, type GarchiReview, type GarchiReviewCreate, type GarchiReviewUpdate, type GarchiSection, type GarchiSpace, type GarchiSpaceAPIResponse, type GarchiSpaceCreate, type GetAllItemsParams, type GetFeaturedItemsParams, type GetItemParams, type GetItemsByIdsBodyParams, type GetItemsByIdsParams, type GetItemsBySpaceParams, type GetPageParams, type ItemFields, type ItemsQueryParams, type LogicType, type MetaFilter, type MetaFilterOperator, type MetaInfo, type MetaType, type PaginateQueryParams, type PaginatedResponse, type PaginationLinks, type PaginationMeta, type ReviewFields, type SectionPropType, type SectionTemplate, type SectionTemplateProp, type SemanticSearchParams, type UpdateCategoryParams, type UpdateDataItemParams, type UpdateMetaInfoParams, GarchiCMS as default };
|