@magiclabs.ai/magicbook-client 0.7.2 → 0.7.4-canary
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/README.md +1 -0
- package/index.cjs +58 -24
- package/index.cjs.map +1 -1
- package/index.d.cts +22 -3
- package/index.d.ts +22 -3
- package/index.js +57 -24
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -9,6 +9,7 @@ declare class BooksEndpoints {
|
|
|
9
9
|
create(book: Partial<Book>): Promise<Book>;
|
|
10
10
|
retrieve(bookId: string): Promise<Book>;
|
|
11
11
|
update(bookId: string, book: Partial<Book>): Promise<Book>;
|
|
12
|
+
design(bookId: string): Promise<Book>;
|
|
12
13
|
cancel(bookId: string): Promise<Book>;
|
|
13
14
|
report(bookId: string, report: BookReport): Promise<void>;
|
|
14
15
|
delete(bookId: string): Promise<void>;
|
|
@@ -390,7 +391,8 @@ declare class Images {
|
|
|
390
391
|
private parentId;
|
|
391
392
|
private images;
|
|
392
393
|
length: number;
|
|
393
|
-
|
|
394
|
+
designRequestState: State;
|
|
395
|
+
constructor(client: MagicBookClient, parentId: string, designRequestState: State);
|
|
394
396
|
add(image: Image): Promise<number>;
|
|
395
397
|
}
|
|
396
398
|
declare const imageServerSchema: z.ZodObject<{
|
|
@@ -444,6 +446,7 @@ declare const states: readonly ["new", "ingesting", "submitted", "storyboarding"
|
|
|
444
446
|
declare const statesToCloseWS: ReadonlyArray<typeof states[number]>;
|
|
445
447
|
declare const statesToReport: ReadonlyArray<typeof states[number]>;
|
|
446
448
|
declare const isDesignRequestSubmitted: (state: string) => boolean;
|
|
449
|
+
declare const canResubmitDesignRequest: (state: string) => boolean;
|
|
447
450
|
declare const occasions: readonly ["baby", "birthday", "default", "everyday", "family", "kids", "life-stories", "portfolio", "school-memories", "seasonal-holidays", "special-celebrations", "sports-and-hobbies", "travel", "wedding", "year-in-review"];
|
|
448
451
|
declare const styles: {
|
|
449
452
|
1005: {
|
|
@@ -917,6 +920,18 @@ declare const styles: {
|
|
|
917
920
|
6146: {
|
|
918
921
|
slug: string;
|
|
919
922
|
};
|
|
923
|
+
6148: {
|
|
924
|
+
slug: string;
|
|
925
|
+
};
|
|
926
|
+
6151: {
|
|
927
|
+
slug: string;
|
|
928
|
+
};
|
|
929
|
+
6152: {
|
|
930
|
+
slug: string;
|
|
931
|
+
};
|
|
932
|
+
6153: {
|
|
933
|
+
slug: string;
|
|
934
|
+
};
|
|
920
935
|
6062: {
|
|
921
936
|
slug: string;
|
|
922
937
|
};
|
|
@@ -996,7 +1011,7 @@ type DesignRequestEventDetail = {
|
|
|
996
1011
|
};
|
|
997
1012
|
type DesignRequestEvent = CustomEvent<DesignRequestEventDetail>;
|
|
998
1013
|
declare class DesignRequest {
|
|
999
|
-
|
|
1014
|
+
readonly parentId: string;
|
|
1000
1015
|
private readonly client;
|
|
1001
1016
|
state: State;
|
|
1002
1017
|
title: string;
|
|
@@ -1220,6 +1235,7 @@ declare const bookPropsSchema: z.ZodObject<{
|
|
|
1220
1235
|
cancelled_at: z.ZodOptional<z.ZodString>;
|
|
1221
1236
|
mb_client_timeout: z.ZodOptional<z.ZodNumber>;
|
|
1222
1237
|
user_id: z.ZodOptional<z.ZodString>;
|
|
1238
|
+
revision: z.ZodOptional<z.ZodNumber>;
|
|
1223
1239
|
}, "strip", z.ZodTypeAny, {
|
|
1224
1240
|
title: string;
|
|
1225
1241
|
design_request: {
|
|
@@ -1240,6 +1256,7 @@ declare const bookPropsSchema: z.ZodObject<{
|
|
|
1240
1256
|
cancelled_at?: string | undefined;
|
|
1241
1257
|
mb_client_timeout?: number | undefined;
|
|
1242
1258
|
user_id?: string | undefined;
|
|
1259
|
+
revision?: number | undefined;
|
|
1243
1260
|
}, {
|
|
1244
1261
|
title: string;
|
|
1245
1262
|
design_request: {
|
|
@@ -1260,11 +1277,13 @@ declare const bookPropsSchema: z.ZodObject<{
|
|
|
1260
1277
|
cancelled_at?: string | undefined;
|
|
1261
1278
|
mb_client_timeout?: number | undefined;
|
|
1262
1279
|
user_id?: string | undefined;
|
|
1280
|
+
revision?: number | undefined;
|
|
1263
1281
|
}>;
|
|
1264
1282
|
type BookProps = z.infer<typeof bookPropsSchema>;
|
|
1265
1283
|
declare class Book {
|
|
1266
1284
|
id: string;
|
|
1267
1285
|
title: string;
|
|
1286
|
+
revision?: number;
|
|
1268
1287
|
subtitle?: string;
|
|
1269
1288
|
design_request: BookDesignRequest;
|
|
1270
1289
|
state?: State;
|
|
@@ -3446,4 +3465,4 @@ declare const bookCreationRequestSchema: z.ZodObject<{
|
|
|
3446
3465
|
}>;
|
|
3447
3466
|
type BookCreationRequest = z.infer<typeof bookCreationRequestSchema>;
|
|
3448
3467
|
|
|
3449
|
-
export { Asset, Book, BookCreationRequest, BookDesignRequest, BookDesignRequestProps, BookProps, BookReport, BookSize, Canvas, CoverType, DesignOptions, DesignOptionsServer, DesignRequest, DesignRequestEvent, DesignRequestEventDetail, DesignRequestOptions, DesignRequestProps, EmbellishmentLevel, Image, ImageAssignment, ImageDensity, ImageDensityOption, ImageDensityOptionServer, ImageDensityOptions, ImageDensityOptionsServer, ImageFilteringLevel, ImageServer, Images, MagicBookClient, MagicShopBook, Occasion, Page, PageType, PhotoMetadata, PhotoStrip, Position, Property, ReportingData, State, Style, TextStickerLevel, assetSchema, bookCreationRequestSchema, bookDesignRequestSchema, bookPropsSchema, bookSizes, cancelledEventDetail, canvasSchema, coverTypes, designOptionsSchema, designOptionsServerSchema, embellishmentLevels, imageAssignmentSchema, imageDensities, imageDensityOptionSchema, imageDensityOptionServerSchema, imageDensityOptionsSchema, imageDensityOptionsServerSchema, imageFilteringLevels, imageServerSchema, isDesignRequestSubmitted, magicShopBookSchema, occasions, pageSchema, pageTypes, photoMetadataSchema, photoStripSchema, positionSchema, propertySchema, reportingDataSchema, states, statesToCloseWS, statesToReport, styles, textStickerLevels, timeoutEventDetail };
|
|
3468
|
+
export { Asset, Book, BookCreationRequest, BookDesignRequest, BookDesignRequestProps, BookProps, BookReport, BookSize, Canvas, CoverType, DesignOptions, DesignOptionsServer, DesignRequest, DesignRequestEvent, DesignRequestEventDetail, DesignRequestOptions, DesignRequestProps, EmbellishmentLevel, Image, ImageAssignment, ImageDensity, ImageDensityOption, ImageDensityOptionServer, ImageDensityOptions, ImageDensityOptionsServer, ImageFilteringLevel, ImageServer, Images, MagicBookClient, MagicShopBook, Occasion, Page, PageType, PhotoMetadata, PhotoStrip, Position, Property, ReportingData, State, Style, TextStickerLevel, assetSchema, bookCreationRequestSchema, bookDesignRequestSchema, bookPropsSchema, bookSizes, canResubmitDesignRequest, cancelledEventDetail, canvasSchema, coverTypes, designOptionsSchema, designOptionsServerSchema, embellishmentLevels, imageAssignmentSchema, imageDensities, imageDensityOptionSchema, imageDensityOptionServerSchema, imageDensityOptionsSchema, imageDensityOptionsServerSchema, imageFilteringLevels, imageServerSchema, isDesignRequestSubmitted, magicShopBookSchema, occasions, pageSchema, pageTypes, photoMetadataSchema, photoStripSchema, positionSchema, propertySchema, reportingDataSchema, states, statesToCloseWS, statesToReport, styles, textStickerLevels, timeoutEventDetail };
|
package/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ declare class BooksEndpoints {
|
|
|
9
9
|
create(book: Partial<Book>): Promise<Book>;
|
|
10
10
|
retrieve(bookId: string): Promise<Book>;
|
|
11
11
|
update(bookId: string, book: Partial<Book>): Promise<Book>;
|
|
12
|
+
design(bookId: string): Promise<Book>;
|
|
12
13
|
cancel(bookId: string): Promise<Book>;
|
|
13
14
|
report(bookId: string, report: BookReport): Promise<void>;
|
|
14
15
|
delete(bookId: string): Promise<void>;
|
|
@@ -390,7 +391,8 @@ declare class Images {
|
|
|
390
391
|
private parentId;
|
|
391
392
|
private images;
|
|
392
393
|
length: number;
|
|
393
|
-
|
|
394
|
+
designRequestState: State;
|
|
395
|
+
constructor(client: MagicBookClient, parentId: string, designRequestState: State);
|
|
394
396
|
add(image: Image): Promise<number>;
|
|
395
397
|
}
|
|
396
398
|
declare const imageServerSchema: z.ZodObject<{
|
|
@@ -444,6 +446,7 @@ declare const states: readonly ["new", "ingesting", "submitted", "storyboarding"
|
|
|
444
446
|
declare const statesToCloseWS: ReadonlyArray<typeof states[number]>;
|
|
445
447
|
declare const statesToReport: ReadonlyArray<typeof states[number]>;
|
|
446
448
|
declare const isDesignRequestSubmitted: (state: string) => boolean;
|
|
449
|
+
declare const canResubmitDesignRequest: (state: string) => boolean;
|
|
447
450
|
declare const occasions: readonly ["baby", "birthday", "default", "everyday", "family", "kids", "life-stories", "portfolio", "school-memories", "seasonal-holidays", "special-celebrations", "sports-and-hobbies", "travel", "wedding", "year-in-review"];
|
|
448
451
|
declare const styles: {
|
|
449
452
|
1005: {
|
|
@@ -917,6 +920,18 @@ declare const styles: {
|
|
|
917
920
|
6146: {
|
|
918
921
|
slug: string;
|
|
919
922
|
};
|
|
923
|
+
6148: {
|
|
924
|
+
slug: string;
|
|
925
|
+
};
|
|
926
|
+
6151: {
|
|
927
|
+
slug: string;
|
|
928
|
+
};
|
|
929
|
+
6152: {
|
|
930
|
+
slug: string;
|
|
931
|
+
};
|
|
932
|
+
6153: {
|
|
933
|
+
slug: string;
|
|
934
|
+
};
|
|
920
935
|
6062: {
|
|
921
936
|
slug: string;
|
|
922
937
|
};
|
|
@@ -996,7 +1011,7 @@ type DesignRequestEventDetail = {
|
|
|
996
1011
|
};
|
|
997
1012
|
type DesignRequestEvent = CustomEvent<DesignRequestEventDetail>;
|
|
998
1013
|
declare class DesignRequest {
|
|
999
|
-
|
|
1014
|
+
readonly parentId: string;
|
|
1000
1015
|
private readonly client;
|
|
1001
1016
|
state: State;
|
|
1002
1017
|
title: string;
|
|
@@ -1220,6 +1235,7 @@ declare const bookPropsSchema: z.ZodObject<{
|
|
|
1220
1235
|
cancelled_at: z.ZodOptional<z.ZodString>;
|
|
1221
1236
|
mb_client_timeout: z.ZodOptional<z.ZodNumber>;
|
|
1222
1237
|
user_id: z.ZodOptional<z.ZodString>;
|
|
1238
|
+
revision: z.ZodOptional<z.ZodNumber>;
|
|
1223
1239
|
}, "strip", z.ZodTypeAny, {
|
|
1224
1240
|
title: string;
|
|
1225
1241
|
design_request: {
|
|
@@ -1240,6 +1256,7 @@ declare const bookPropsSchema: z.ZodObject<{
|
|
|
1240
1256
|
cancelled_at?: string | undefined;
|
|
1241
1257
|
mb_client_timeout?: number | undefined;
|
|
1242
1258
|
user_id?: string | undefined;
|
|
1259
|
+
revision?: number | undefined;
|
|
1243
1260
|
}, {
|
|
1244
1261
|
title: string;
|
|
1245
1262
|
design_request: {
|
|
@@ -1260,11 +1277,13 @@ declare const bookPropsSchema: z.ZodObject<{
|
|
|
1260
1277
|
cancelled_at?: string | undefined;
|
|
1261
1278
|
mb_client_timeout?: number | undefined;
|
|
1262
1279
|
user_id?: string | undefined;
|
|
1280
|
+
revision?: number | undefined;
|
|
1263
1281
|
}>;
|
|
1264
1282
|
type BookProps = z.infer<typeof bookPropsSchema>;
|
|
1265
1283
|
declare class Book {
|
|
1266
1284
|
id: string;
|
|
1267
1285
|
title: string;
|
|
1286
|
+
revision?: number;
|
|
1268
1287
|
subtitle?: string;
|
|
1269
1288
|
design_request: BookDesignRequest;
|
|
1270
1289
|
state?: State;
|
|
@@ -3446,4 +3465,4 @@ declare const bookCreationRequestSchema: z.ZodObject<{
|
|
|
3446
3465
|
}>;
|
|
3447
3466
|
type BookCreationRequest = z.infer<typeof bookCreationRequestSchema>;
|
|
3448
3467
|
|
|
3449
|
-
export { Asset, Book, BookCreationRequest, BookDesignRequest, BookDesignRequestProps, BookProps, BookReport, BookSize, Canvas, CoverType, DesignOptions, DesignOptionsServer, DesignRequest, DesignRequestEvent, DesignRequestEventDetail, DesignRequestOptions, DesignRequestProps, EmbellishmentLevel, Image, ImageAssignment, ImageDensity, ImageDensityOption, ImageDensityOptionServer, ImageDensityOptions, ImageDensityOptionsServer, ImageFilteringLevel, ImageServer, Images, MagicBookClient, MagicShopBook, Occasion, Page, PageType, PhotoMetadata, PhotoStrip, Position, Property, ReportingData, State, Style, TextStickerLevel, assetSchema, bookCreationRequestSchema, bookDesignRequestSchema, bookPropsSchema, bookSizes, cancelledEventDetail, canvasSchema, coverTypes, designOptionsSchema, designOptionsServerSchema, embellishmentLevels, imageAssignmentSchema, imageDensities, imageDensityOptionSchema, imageDensityOptionServerSchema, imageDensityOptionsSchema, imageDensityOptionsServerSchema, imageFilteringLevels, imageServerSchema, isDesignRequestSubmitted, magicShopBookSchema, occasions, pageSchema, pageTypes, photoMetadataSchema, photoStripSchema, positionSchema, propertySchema, reportingDataSchema, states, statesToCloseWS, statesToReport, styles, textStickerLevels, timeoutEventDetail };
|
|
3468
|
+
export { Asset, Book, BookCreationRequest, BookDesignRequest, BookDesignRequestProps, BookProps, BookReport, BookSize, Canvas, CoverType, DesignOptions, DesignOptionsServer, DesignRequest, DesignRequestEvent, DesignRequestEventDetail, DesignRequestOptions, DesignRequestProps, EmbellishmentLevel, Image, ImageAssignment, ImageDensity, ImageDensityOption, ImageDensityOptionServer, ImageDensityOptions, ImageDensityOptionsServer, ImageFilteringLevel, ImageServer, Images, MagicBookClient, MagicShopBook, Occasion, Page, PageType, PhotoMetadata, PhotoStrip, Position, Property, ReportingData, State, Style, TextStickerLevel, assetSchema, bookCreationRequestSchema, bookDesignRequestSchema, bookPropsSchema, bookSizes, canResubmitDesignRequest, cancelledEventDetail, canvasSchema, coverTypes, designOptionsSchema, designOptionsServerSchema, embellishmentLevels, imageAssignmentSchema, imageDensities, imageDensityOptionSchema, imageDensityOptionServerSchema, imageDensityOptionsSchema, imageDensityOptionsServerSchema, imageFilteringLevels, imageServerSchema, isDesignRequestSubmitted, magicShopBookSchema, occasions, pageSchema, pageTypes, photoMetadataSchema, photoStripSchema, positionSchema, propertySchema, reportingDataSchema, states, statesToCloseWS, statesToReport, styles, textStickerLevels, timeoutEventDetail };
|
package/index.js
CHANGED
|
@@ -18,6 +18,7 @@ var states = [
|
|
|
18
18
|
var statesToCloseWS = ["error", "timeout", "ready", "cancelled"];
|
|
19
19
|
var statesToReport = ["error", "timeout"];
|
|
20
20
|
var isDesignRequestSubmitted = (state) => !["new", "ingesting"].includes(state);
|
|
21
|
+
var canResubmitDesignRequest = (state) => ["new", "ingesting", "ready"].includes(state);
|
|
21
22
|
var occasions = [
|
|
22
23
|
"baby",
|
|
23
24
|
"birthday",
|
|
@@ -181,7 +182,7 @@ var styles = {
|
|
|
181
182
|
6116: { slug: "boho-baby-sfly" },
|
|
182
183
|
6117: { slug: "simply-gallery-sfly" },
|
|
183
184
|
6118: { slug: "this-is-love-sfly" },
|
|
184
|
-
6120: { slug: "wedding-
|
|
185
|
+
6120: { slug: "wedding-photo-album-sfly" },
|
|
185
186
|
6121: { slug: "watercolorwashes-sfly" },
|
|
186
187
|
6124: { slug: "graduation-photo-album-sfly" },
|
|
187
188
|
6125: { slug: "modern-year-in-review-photo-album-sfly" },
|
|
@@ -193,6 +194,10 @@ var styles = {
|
|
|
193
194
|
6144: { slug: "seasonal-year-in-review-sfly" },
|
|
194
195
|
6143: { slug: "wanderlust-gallery-sfly" },
|
|
195
196
|
6146: { slug: "wedding-elopement-gallery-sfly" },
|
|
197
|
+
6148: { slug: "love-wins-sfly" },
|
|
198
|
+
6151: { slug: "adventures-in-mexico-sfly" },
|
|
199
|
+
6152: { slug: "generations-of-love-sfly" },
|
|
200
|
+
6153: { slug: "cheerful-patterns-sfly" },
|
|
196
201
|
6062: { slug: "create-your-own-sfly" },
|
|
197
202
|
6075: { slug: "together-again-sfly" },
|
|
198
203
|
6078: { slug: "everyday-boho-by-umaiana-studio-sfly" },
|
|
@@ -4019,11 +4024,13 @@ var bookPropsSchema = z.object({
|
|
|
4019
4024
|
guid: z.string().optional(),
|
|
4020
4025
|
cancelled_at: z.string().optional(),
|
|
4021
4026
|
mb_client_timeout: z.number().optional(),
|
|
4022
|
-
user_id: z.string().optional()
|
|
4027
|
+
user_id: z.string().optional(),
|
|
4028
|
+
revision: z.number().optional()
|
|
4023
4029
|
});
|
|
4024
4030
|
var Book = class {
|
|
4025
4031
|
id;
|
|
4026
4032
|
title;
|
|
4033
|
+
revision;
|
|
4027
4034
|
subtitle;
|
|
4028
4035
|
design_request;
|
|
4029
4036
|
state;
|
|
@@ -4041,11 +4048,13 @@ var Book = class {
|
|
|
4041
4048
|
this.cancelled_at = props.cancelled_at;
|
|
4042
4049
|
this.timeout = props.mb_client_timeout ? props.mb_client_timeout * 1e3 : void 0;
|
|
4043
4050
|
this.user_id = props.user_id;
|
|
4051
|
+
this.revision = props.revision;
|
|
4044
4052
|
}
|
|
4045
4053
|
toDesignRequestProps() {
|
|
4046
4054
|
const props = { ...this, ...this.design_request };
|
|
4047
4055
|
props.style = getStyleIdBySlug(props.style);
|
|
4048
4056
|
delete props.design_request;
|
|
4057
|
+
delete props.revision;
|
|
4049
4058
|
return snakeCaseObjectKeysToCamelCase(props);
|
|
4050
4059
|
}
|
|
4051
4060
|
toBookProps() {
|
|
@@ -4059,22 +4068,28 @@ var Book = class {
|
|
|
4059
4068
|
// ../../core/models/design-request/image.ts
|
|
4060
4069
|
var Images = class {
|
|
4061
4070
|
// eslint-disable-next-line no-unused-vars
|
|
4062
|
-
constructor(client, parentId) {
|
|
4071
|
+
constructor(client, parentId, designRequestState) {
|
|
4063
4072
|
this.client = client;
|
|
4064
4073
|
this.parentId = parentId;
|
|
4065
4074
|
this.images = [];
|
|
4066
4075
|
this.length = this.images.length;
|
|
4076
|
+
this.designRequestState = designRequestState;
|
|
4067
4077
|
}
|
|
4068
4078
|
parentId;
|
|
4069
4079
|
images;
|
|
4070
4080
|
length;
|
|
4081
|
+
designRequestState;
|
|
4071
4082
|
async add(image) {
|
|
4072
|
-
this.
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4083
|
+
if (!canResubmitDesignRequest(this.designRequestState)) {
|
|
4084
|
+
throw new Error("You need to wait for the current design request to be ready before adding new images.");
|
|
4085
|
+
} else {
|
|
4086
|
+
this.images.push(image);
|
|
4087
|
+
this.length = this.images.length;
|
|
4088
|
+
await this.client.engineAPI.images.addToBook(this.parentId, new ImageServer(image));
|
|
4089
|
+
return new Promise((resolve) => {
|
|
4090
|
+
resolve(this.length);
|
|
4091
|
+
});
|
|
4092
|
+
}
|
|
4078
4093
|
}
|
|
4079
4094
|
};
|
|
4080
4095
|
var imageServerSchema = z.object({
|
|
@@ -4172,7 +4187,7 @@ var DesignRequest = class {
|
|
|
4172
4187
|
this.imageFilteringLevel = designRequestProps?.imageFilteringLevel || imageFilteringLevels[0];
|
|
4173
4188
|
this.embellishmentLevel = designRequestProps?.embellishmentLevel || embellishmentLevels[0];
|
|
4174
4189
|
this.textStickerLevel = designRequestProps?.textStickerLevel || textStickerLevels[0];
|
|
4175
|
-
this.images = new Images(this.client, this.parentId);
|
|
4190
|
+
this.images = new Images(this.client, this.parentId, this.state);
|
|
4176
4191
|
this.userId = designRequestProps?.userId;
|
|
4177
4192
|
}
|
|
4178
4193
|
state;
|
|
@@ -4194,6 +4209,9 @@ var DesignRequest = class {
|
|
|
4194
4209
|
timeout;
|
|
4195
4210
|
updateDesignRequest(designRequestProps) {
|
|
4196
4211
|
Object.assign(this, designRequestProps);
|
|
4212
|
+
if (designRequestProps.state) {
|
|
4213
|
+
this.images.designRequestState = designRequestProps.state;
|
|
4214
|
+
}
|
|
4197
4215
|
}
|
|
4198
4216
|
async getOptions(imageCount) {
|
|
4199
4217
|
const options = designOptionsSchema.parse(snakeCaseObjectKeysToCamelCase(
|
|
@@ -4206,16 +4224,17 @@ var DesignRequest = class {
|
|
|
4206
4224
|
return options;
|
|
4207
4225
|
}
|
|
4208
4226
|
async submit(submitDesignRequestProps) {
|
|
4209
|
-
if (
|
|
4210
|
-
throw new Error("
|
|
4227
|
+
if (!canResubmitDesignRequest(this.state)) {
|
|
4228
|
+
throw new Error("You need to wait for the current design request to be ready before submitting a new one");
|
|
4211
4229
|
} else {
|
|
4212
|
-
submitDesignRequestProps &&
|
|
4230
|
+
submitDesignRequestProps && this.updateDesignRequest(submitDesignRequestProps);
|
|
4213
4231
|
this.webSocket = new WebSocket(`${this.client.webSocketHost}/?book_id=${this.parentId}`);
|
|
4232
|
+
await this.client.engineAPI.books.update(this.parentId, this.toBook());
|
|
4214
4233
|
this.updateDesignRequest(
|
|
4215
|
-
(await this.client.engineAPI.books.
|
|
4234
|
+
(await this.client.engineAPI.books.design(this.parentId)).toDesignRequestProps()
|
|
4216
4235
|
);
|
|
4217
4236
|
this.getProgress();
|
|
4218
|
-
this.state
|
|
4237
|
+
this.updateDesignRequest({ state: states[1] });
|
|
4219
4238
|
return this;
|
|
4220
4239
|
}
|
|
4221
4240
|
}
|
|
@@ -4238,10 +4257,10 @@ var DesignRequest = class {
|
|
|
4238
4257
|
} else if (!isDesignRequestSubmitted(this.state)) {
|
|
4239
4258
|
throw new Error("Design request not submitted");
|
|
4240
4259
|
} else {
|
|
4241
|
-
this.updateDesignRequest(
|
|
4242
|
-
(await this.client.engineAPI.books.cancel(this.parentId)).toDesignRequestProps()
|
|
4243
|
-
|
|
4244
|
-
|
|
4260
|
+
this.updateDesignRequest({
|
|
4261
|
+
...(await this.client.engineAPI.books.cancel(this.parentId)).toDesignRequestProps(),
|
|
4262
|
+
state: "cancelled"
|
|
4263
|
+
});
|
|
4245
4264
|
await this.eventHandler(cancelledEventDetail);
|
|
4246
4265
|
return this;
|
|
4247
4266
|
}
|
|
@@ -4267,7 +4286,7 @@ var DesignRequest = class {
|
|
|
4267
4286
|
});
|
|
4268
4287
|
}
|
|
4269
4288
|
}
|
|
4270
|
-
this.state
|
|
4289
|
+
this.updateDesignRequest({ state: detail.slug });
|
|
4271
4290
|
window.dispatchEvent(customEvent);
|
|
4272
4291
|
}
|
|
4273
4292
|
timeoutHandler() {
|
|
@@ -4294,10 +4313,13 @@ var DesignRequest = class {
|
|
|
4294
4313
|
}
|
|
4295
4314
|
}
|
|
4296
4315
|
toBook() {
|
|
4297
|
-
const designRequest = {
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4316
|
+
const designRequest = {
|
|
4317
|
+
...this,
|
|
4318
|
+
images: this.images["images"]
|
|
4319
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4320
|
+
};
|
|
4321
|
+
delete designRequest.client;
|
|
4322
|
+
delete designRequest.webSocket;
|
|
4301
4323
|
const styleSlug = styles[this.style].slug;
|
|
4302
4324
|
const bookDesignRequest = camelCaseObjectKeysToSnakeCase(cleanJSON(designRequest));
|
|
4303
4325
|
bookDesignRequest.style = styleSlug;
|
|
@@ -4432,6 +4454,16 @@ var BooksEndpoints = class {
|
|
|
4432
4454
|
return new Book(res);
|
|
4433
4455
|
});
|
|
4434
4456
|
}
|
|
4457
|
+
design(bookId) {
|
|
4458
|
+
return handleAsyncFunction(async () => {
|
|
4459
|
+
const res = await this.engineAPI.fetcher.call({
|
|
4460
|
+
path: `/v1/books/${bookId}/design`,
|
|
4461
|
+
options: { method: "POST" }
|
|
4462
|
+
});
|
|
4463
|
+
bookPropsSchema.safeParse(res);
|
|
4464
|
+
return new Book(res);
|
|
4465
|
+
});
|
|
4466
|
+
}
|
|
4435
4467
|
cancel(bookId) {
|
|
4436
4468
|
return handleAsyncFunction(async () => {
|
|
4437
4469
|
const res = await this.engineAPI.fetcher.call({
|
|
@@ -4883,6 +4915,7 @@ export {
|
|
|
4883
4915
|
bookDesignRequestSchema,
|
|
4884
4916
|
bookPropsSchema,
|
|
4885
4917
|
bookSizes,
|
|
4918
|
+
canResubmitDesignRequest,
|
|
4886
4919
|
cancelledEventDetail,
|
|
4887
4920
|
canvasSchema,
|
|
4888
4921
|
coverTypes,
|