@magiclabs.ai/magicbook-client 0.4.8 → 0.5.0-dev
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/config.d.ts +2 -1
- package/data/design-request.d.ts +1 -1
- package/magicbook-client.js +638 -637
- package/magicbook-client.umd.cjs +3 -3
- package/models/book.d.ts +19 -15
- package/models/design-request/image.d.ts +2 -1
- package/models/design-request/index.d.ts +8 -5
- package/package.json +10 -10
- package/utils/engine-api/axios.d.ts +5 -5
- package/utils/engine-api/books.d.ts +4 -4
- package/utils/engine-api/design-options.d.ts +1 -1
- package/utils/engine-api/images.d.ts +1 -1
package/models/book.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BookSize, CoverType, EmbellishmentLevel, ImageDensity,
|
|
1
|
+
import { BookSize, CoverType, EmbellishmentLevel, ImageDensity, ImageFilteringLevel, Occasion, PageType, State, TextStickerLevel } from './design-request';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export type BookDesignRequestProps = {
|
|
4
4
|
occasion: Occasion;
|
|
@@ -7,7 +7,7 @@ export type BookDesignRequestProps = {
|
|
|
7
7
|
cover_type: CoverType;
|
|
8
8
|
page_type: PageType;
|
|
9
9
|
image_density: ImageDensity;
|
|
10
|
-
|
|
10
|
+
image_filtering_level: ImageFilteringLevel;
|
|
11
11
|
embellishment_level: EmbellishmentLevel;
|
|
12
12
|
text_sticker_level: TextStickerLevel;
|
|
13
13
|
};
|
|
@@ -18,7 +18,7 @@ export declare class BookDesignRequest {
|
|
|
18
18
|
cover_type: CoverType;
|
|
19
19
|
page_type: PageType;
|
|
20
20
|
image_density: ImageDensity;
|
|
21
|
-
|
|
21
|
+
image_filtering_level: ImageFilteringLevel;
|
|
22
22
|
embellishment_level: EmbellishmentLevel;
|
|
23
23
|
text_sticker_level: TextStickerLevel;
|
|
24
24
|
constructor(props: BookDesignRequestProps);
|
|
@@ -30,7 +30,7 @@ export declare const bookDesignRequestSchema: z.ZodObject<{
|
|
|
30
30
|
cover_type: z.ZodEnum<["sc", "hc", "pl"]>;
|
|
31
31
|
page_type: z.ZodEnum<["sp", "sl", "dl"]>;
|
|
32
32
|
image_density: z.ZodEnum<["low", "medium", "high"]>;
|
|
33
|
-
|
|
33
|
+
image_filtering_level: z.ZodEnum<["best", "most", "all"]>;
|
|
34
34
|
embellishment_level: z.ZodEnum<["none", "few", "lots"]>;
|
|
35
35
|
text_sticker_level: z.ZodEnum<["none", "few", "lots"]>;
|
|
36
36
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -40,7 +40,7 @@ export declare const bookDesignRequestSchema: z.ZodObject<{
|
|
|
40
40
|
cover_type: "sc" | "hc" | "pl";
|
|
41
41
|
page_type: "sp" | "sl" | "dl";
|
|
42
42
|
image_density: "low" | "medium" | "high";
|
|
43
|
-
|
|
43
|
+
image_filtering_level: "best" | "most" | "all";
|
|
44
44
|
embellishment_level: "none" | "few" | "lots";
|
|
45
45
|
text_sticker_level: "none" | "few" | "lots";
|
|
46
46
|
}, {
|
|
@@ -50,13 +50,12 @@ export declare const bookDesignRequestSchema: z.ZodObject<{
|
|
|
50
50
|
cover_type: "sc" | "hc" | "pl";
|
|
51
51
|
page_type: "sp" | "sl" | "dl";
|
|
52
52
|
image_density: "low" | "medium" | "high";
|
|
53
|
-
|
|
53
|
+
image_filtering_level: "best" | "most" | "all";
|
|
54
54
|
embellishment_level: "none" | "few" | "lots";
|
|
55
55
|
text_sticker_level: "none" | "few" | "lots";
|
|
56
56
|
}>;
|
|
57
57
|
export declare const BookPropsSchema: z.ZodObject<{
|
|
58
58
|
id: z.ZodString;
|
|
59
|
-
state: z.ZodEnum<["new", "ingesting", "submitted", "storyboarding", "storyboarding succeeded", "designing", "designing succeeded", "layouting", "layouting succeeded", "embellishing", "embellishing succeeded", "polishing", "polishing succeeded", "ready", "error"]>;
|
|
60
59
|
title: z.ZodString;
|
|
61
60
|
design_request: z.ZodObject<{
|
|
62
61
|
occasion: z.ZodEnum<["baby", "birthday", "default", "everyday", "family", "kids", "life-stories", "portfolio", "school-memories", "seasonal-holidays", "special-celebrations", "sports-and-hobbies", "travel", "wedding", "year-in-review"]>;
|
|
@@ -65,7 +64,7 @@ export declare const BookPropsSchema: z.ZodObject<{
|
|
|
65
64
|
cover_type: z.ZodEnum<["sc", "hc", "pl"]>;
|
|
66
65
|
page_type: z.ZodEnum<["sp", "sl", "dl"]>;
|
|
67
66
|
image_density: z.ZodEnum<["low", "medium", "high"]>;
|
|
68
|
-
|
|
67
|
+
image_filtering_level: z.ZodEnum<["best", "most", "all"]>;
|
|
69
68
|
embellishment_level: z.ZodEnum<["none", "few", "lots"]>;
|
|
70
69
|
text_sticker_level: z.ZodEnum<["none", "few", "lots"]>;
|
|
71
70
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -75,7 +74,7 @@ export declare const BookPropsSchema: z.ZodObject<{
|
|
|
75
74
|
cover_type: "sc" | "hc" | "pl";
|
|
76
75
|
page_type: "sp" | "sl" | "dl";
|
|
77
76
|
image_density: "low" | "medium" | "high";
|
|
78
|
-
|
|
77
|
+
image_filtering_level: "best" | "most" | "all";
|
|
79
78
|
embellishment_level: "none" | "few" | "lots";
|
|
80
79
|
text_sticker_level: "none" | "few" | "lots";
|
|
81
80
|
}, {
|
|
@@ -85,13 +84,14 @@ export declare const BookPropsSchema: z.ZodObject<{
|
|
|
85
84
|
cover_type: "sc" | "hc" | "pl";
|
|
86
85
|
page_type: "sp" | "sl" | "dl";
|
|
87
86
|
image_density: "low" | "medium" | "high";
|
|
88
|
-
|
|
87
|
+
image_filtering_level: "best" | "most" | "all";
|
|
89
88
|
embellishment_level: "none" | "few" | "lots";
|
|
90
89
|
text_sticker_level: "none" | "few" | "lots";
|
|
91
90
|
}>;
|
|
91
|
+
state: z.ZodOptional<z.ZodEnum<["new", "ingesting", "submitted", "storyboarding", "storyboarding succeeded", "designing", "designing succeeded", "layouting", "layouting succeeded", "embellishing", "embellishing succeeded", "polishing", "polishing succeeded", "ready", "error"]>>;
|
|
92
|
+
guid: z.ZodOptional<z.ZodString>;
|
|
92
93
|
}, "strip", z.ZodTypeAny, {
|
|
93
94
|
id: string;
|
|
94
|
-
state: "new" | "ingesting" | "submitted" | "storyboarding" | "storyboarding succeeded" | "designing" | "designing succeeded" | "layouting" | "layouting succeeded" | "embellishing" | "embellishing succeeded" | "polishing" | "polishing succeeded" | "ready" | "error";
|
|
95
95
|
title: string;
|
|
96
96
|
design_request: {
|
|
97
97
|
occasion: "baby" | "birthday" | "default" | "everyday" | "family" | "kids" | "life-stories" | "portfolio" | "school-memories" | "seasonal-holidays" | "special-celebrations" | "sports-and-hobbies" | "travel" | "wedding" | "year-in-review";
|
|
@@ -100,13 +100,14 @@ export declare const BookPropsSchema: z.ZodObject<{
|
|
|
100
100
|
cover_type: "sc" | "hc" | "pl";
|
|
101
101
|
page_type: "sp" | "sl" | "dl";
|
|
102
102
|
image_density: "low" | "medium" | "high";
|
|
103
|
-
|
|
103
|
+
image_filtering_level: "best" | "most" | "all";
|
|
104
104
|
embellishment_level: "none" | "few" | "lots";
|
|
105
105
|
text_sticker_level: "none" | "few" | "lots";
|
|
106
106
|
};
|
|
107
|
+
state?: "new" | "ingesting" | "submitted" | "storyboarding" | "storyboarding succeeded" | "designing" | "designing succeeded" | "layouting" | "layouting succeeded" | "embellishing" | "embellishing succeeded" | "polishing" | "polishing succeeded" | "ready" | "error" | undefined;
|
|
108
|
+
guid?: string | undefined;
|
|
107
109
|
}, {
|
|
108
110
|
id: string;
|
|
109
|
-
state: "new" | "ingesting" | "submitted" | "storyboarding" | "storyboarding succeeded" | "designing" | "designing succeeded" | "layouting" | "layouting succeeded" | "embellishing" | "embellishing succeeded" | "polishing" | "polishing succeeded" | "ready" | "error";
|
|
110
111
|
title: string;
|
|
111
112
|
design_request: {
|
|
112
113
|
occasion: "baby" | "birthday" | "default" | "everyday" | "family" | "kids" | "life-stories" | "portfolio" | "school-memories" | "seasonal-holidays" | "special-celebrations" | "sports-and-hobbies" | "travel" | "wedding" | "year-in-review";
|
|
@@ -115,16 +116,19 @@ export declare const BookPropsSchema: z.ZodObject<{
|
|
|
115
116
|
cover_type: "sc" | "hc" | "pl";
|
|
116
117
|
page_type: "sp" | "sl" | "dl";
|
|
117
118
|
image_density: "low" | "medium" | "high";
|
|
118
|
-
|
|
119
|
+
image_filtering_level: "best" | "most" | "all";
|
|
119
120
|
embellishment_level: "none" | "few" | "lots";
|
|
120
121
|
text_sticker_level: "none" | "few" | "lots";
|
|
121
122
|
};
|
|
123
|
+
state?: "new" | "ingesting" | "submitted" | "storyboarding" | "storyboarding succeeded" | "designing" | "designing succeeded" | "layouting" | "layouting succeeded" | "embellishing" | "embellishing succeeded" | "polishing" | "polishing succeeded" | "ready" | "error" | undefined;
|
|
124
|
+
guid?: string | undefined;
|
|
122
125
|
}>;
|
|
123
126
|
export type BookProps = z.infer<typeof BookPropsSchema>;
|
|
124
127
|
export declare class Book {
|
|
125
128
|
id: string;
|
|
126
|
-
state: State;
|
|
127
129
|
title: string;
|
|
128
130
|
design_request: BookDesignRequest;
|
|
131
|
+
state?: State;
|
|
132
|
+
guid?: string;
|
|
129
133
|
constructor(props: BookProps);
|
|
130
134
|
}
|
|
@@ -11,10 +11,11 @@ export type Image = {
|
|
|
11
11
|
filename: string;
|
|
12
12
|
};
|
|
13
13
|
export declare class Images {
|
|
14
|
+
private apiKey;
|
|
14
15
|
private parentId;
|
|
15
16
|
private images;
|
|
16
17
|
length: number;
|
|
17
|
-
constructor(parentId: string);
|
|
18
|
+
constructor(parentId: string, apiKey: string);
|
|
18
19
|
add(image: Image): Promise<number>;
|
|
19
20
|
}
|
|
20
21
|
export declare const imageServerSchema: z.ZodObject<{
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Images } from './image';
|
|
2
|
-
import { bookSizes, coverTypes, embellishmentLevels, imageDensities,
|
|
2
|
+
import { bookSizes, coverTypes, embellishmentLevels, imageDensities, imageFilteringLevels, occasions, pageTypes, states, styles, textStickerLevels } from '../../data/design-request';
|
|
3
3
|
export type Occasion = typeof occasions[number];
|
|
4
4
|
export type Style = keyof typeof styles;
|
|
5
5
|
export type BookSize = typeof bookSizes[number];
|
|
6
6
|
export type CoverType = typeof coverTypes[number];
|
|
7
7
|
export type PageType = typeof pageTypes[number];
|
|
8
8
|
export type ImageDensity = typeof imageDensities[number];
|
|
9
|
-
export type
|
|
9
|
+
export type ImageFilteringLevel = typeof imageFilteringLevels[number];
|
|
10
10
|
export type EmbellishmentLevel = typeof embellishmentLevels[number];
|
|
11
11
|
export type TextStickerLevel = typeof textStickerLevels[number];
|
|
12
12
|
export type DesignRequestProps = {
|
|
@@ -17,7 +17,7 @@ export type DesignRequestProps = {
|
|
|
17
17
|
coverType?: CoverType;
|
|
18
18
|
pageType?: PageType;
|
|
19
19
|
imageDensity?: ImageDensity;
|
|
20
|
-
|
|
20
|
+
imageFilteringLevel?: ImageFilteringLevel;
|
|
21
21
|
embellishmentLevel?: EmbellishmentLevel;
|
|
22
22
|
textStickerLevel?: TextStickerLevel;
|
|
23
23
|
};
|
|
@@ -27,6 +27,7 @@ export type DesignRequestEventDetail = {
|
|
|
27
27
|
};
|
|
28
28
|
export type DesignRequestEvent = CustomEvent<DesignRequestEventDetail>;
|
|
29
29
|
export declare class DesignRequest {
|
|
30
|
+
private apiKey;
|
|
30
31
|
parentId: string;
|
|
31
32
|
title: string;
|
|
32
33
|
occasion: Occasion;
|
|
@@ -35,11 +36,12 @@ export declare class DesignRequest {
|
|
|
35
36
|
coverType: CoverType;
|
|
36
37
|
pageType: PageType;
|
|
37
38
|
imageDensity: ImageDensity;
|
|
38
|
-
|
|
39
|
+
imageFilteringLevel: ImageFilteringLevel;
|
|
39
40
|
embellishmentLevel: EmbellishmentLevel;
|
|
40
41
|
textStickerLevel: TextStickerLevel;
|
|
41
42
|
images: Images;
|
|
42
|
-
|
|
43
|
+
guid?: string;
|
|
44
|
+
constructor(parentId: string, apiKey: string, designRequestProps?: DesignRequestProps);
|
|
43
45
|
getOptions(imageCount?: number): Promise<{
|
|
44
46
|
densities: {
|
|
45
47
|
low: {
|
|
@@ -66,6 +68,7 @@ export declare class DesignRequest {
|
|
|
66
68
|
};
|
|
67
69
|
}>;
|
|
68
70
|
submit(submitDesignRequestProps?: DesignRequestProps): Promise<this>;
|
|
71
|
+
setGuid(guid: string): Promise<string>;
|
|
69
72
|
getJSON(): Promise<{
|
|
70
73
|
title: string;
|
|
71
74
|
coverSpecId: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magiclabs.ai/magicbook-client",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0-dev",
|
|
5
5
|
"description": "TypeScript package to create photo books with the Magicbook API.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./magicbook-client.umd.cjs",
|
|
@@ -26,22 +26,22 @@
|
|
|
26
26
|
"coverage": "vitest run --coverage"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/node": "^18.
|
|
30
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
31
|
-
"@typescript-eslint/parser": "^5.59.
|
|
32
|
-
"@vitest/coverage-c8": "^0.
|
|
33
|
-
"@vitest/coverage-istanbul": "^0.
|
|
34
|
-
"@vitest/ui": "^0.
|
|
29
|
+
"@types/node": "^18.14.0",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^5.59.6",
|
|
31
|
+
"@typescript-eslint/parser": "^5.59.6",
|
|
32
|
+
"@vitest/coverage-c8": "^0.31.1",
|
|
33
|
+
"@vitest/coverage-istanbul": "^0.31.1",
|
|
34
|
+
"@vitest/ui": "^0.31.1",
|
|
35
35
|
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
|
|
36
36
|
"jsdom": "^22.0.0",
|
|
37
37
|
"rollup-plugin-execute": "^1.1.1",
|
|
38
38
|
"typescript": "^5.0.4",
|
|
39
|
-
"vite": "^4.3.
|
|
39
|
+
"vite": "^4.3.8",
|
|
40
40
|
"vite-plugin-dts": "^2.3.0",
|
|
41
|
-
"vitest": "^0.
|
|
41
|
+
"vitest": "^0.31.1"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@faker-js/faker": "^
|
|
44
|
+
"@faker-js/faker": "^8.0.1",
|
|
45
45
|
"axios": "^1.4.0",
|
|
46
46
|
"zod": "^3.21.4"
|
|
47
47
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
2
|
type baseRequest = {
|
|
3
3
|
url: string;
|
|
4
|
-
|
|
4
|
+
apiKey: string;
|
|
5
5
|
options?: AxiosRequestConfig<any>;
|
|
6
6
|
};
|
|
7
7
|
type payloadRequest = baseRequest & {
|
|
8
8
|
payload?: unknown;
|
|
9
9
|
};
|
|
10
|
-
export declare function get({ url,
|
|
11
|
-
export declare function remove({ url,
|
|
12
|
-
export declare function post({ url,
|
|
13
|
-
export declare function put({ url,
|
|
10
|
+
export declare function get({ url, apiKey, options }: baseRequest): Promise<import("axios").AxiosResponse<any, any>>;
|
|
11
|
+
export declare function remove({ url, apiKey, options }: baseRequest): Promise<import("axios").AxiosResponse<any, any>>;
|
|
12
|
+
export declare function post({ url, apiKey, options, payload }: payloadRequest): Promise<import("axios").AxiosResponse<any, any>>;
|
|
13
|
+
export declare function put({ url, apiKey, options, payload }: payloadRequest): Promise<import("axios").AxiosResponse<any, any>>;
|
|
14
14
|
export declare function APIHandler<T>(fn: () => Promise<T>): Promise<T>;
|
|
15
15
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Book } from '../../models/book';
|
|
2
|
-
export declare function createBook(payload?: Book): Promise<Book>;
|
|
3
|
-
export declare function retrieveBook(bookId: string): Promise<Book>;
|
|
4
|
-
export declare function updateBook(payload: Book): Promise<Book>;
|
|
5
|
-
export declare function retrieveGalleon(bookId: string): Promise<{
|
|
2
|
+
export declare function createBook(apiKey: string, payload?: Book): Promise<Book>;
|
|
3
|
+
export declare function retrieveBook(apiKey: string, bookId: string): Promise<Book>;
|
|
4
|
+
export declare function updateBook(apiKey: string, payload: Partial<Book>): Promise<Book>;
|
|
5
|
+
export declare function retrieveGalleon(apiKey: string, bookId: string): Promise<{
|
|
6
6
|
title: string;
|
|
7
7
|
coverSpecId: string;
|
|
8
8
|
styleId: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BookSize } from '../../models/design-request';
|
|
2
|
-
export declare function getDesignOptions(bookSize: BookSize, imageCount: number): Promise<{
|
|
2
|
+
export declare function getDesignOptions(apiKey: string, bookSize: BookSize, imageCount: number): Promise<{
|
|
3
3
|
densities: {
|
|
4
4
|
low: {
|
|
5
5
|
maxPageCount: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ImageServer } from '../../models/design-request/image';
|
|
2
|
-
export declare function addImageInBook(bookId: string, payload: ImageServer): Promise<ImageServer>;
|
|
2
|
+
export declare function addImageInBook(apiKey: string, bookId: string, payload: ImageServer): Promise<ImageServer>;
|