@magiclabs.ai/magicbook-client 0.7.4-canary → 0.7.4
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/index.cjs +6 -7
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -2
- package/index.d.ts +2 -2
- package/index.js +5 -6
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -446,7 +446,7 @@ declare const states: readonly ["new", "ingesting", "submitted", "storyboarding"
|
|
|
446
446
|
declare const statesToCloseWS: ReadonlyArray<typeof states[number]>;
|
|
447
447
|
declare const statesToReport: ReadonlyArray<typeof states[number]>;
|
|
448
448
|
declare const isDesignRequestSubmitted: (state: string) => boolean;
|
|
449
|
-
declare const
|
|
449
|
+
declare const canSubmitDesignRequest: (state: string) => boolean;
|
|
450
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"];
|
|
451
451
|
declare const styles: {
|
|
452
452
|
1005: {
|
|
@@ -3465,4 +3465,4 @@ declare const bookCreationRequestSchema: z.ZodObject<{
|
|
|
3465
3465
|
}>;
|
|
3466
3466
|
type BookCreationRequest = z.infer<typeof bookCreationRequestSchema>;
|
|
3467
3467
|
|
|
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,
|
|
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, canSubmitDesignRequest, 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
|
@@ -446,7 +446,7 @@ declare const states: readonly ["new", "ingesting", "submitted", "storyboarding"
|
|
|
446
446
|
declare const statesToCloseWS: ReadonlyArray<typeof states[number]>;
|
|
447
447
|
declare const statesToReport: ReadonlyArray<typeof states[number]>;
|
|
448
448
|
declare const isDesignRequestSubmitted: (state: string) => boolean;
|
|
449
|
-
declare const
|
|
449
|
+
declare const canSubmitDesignRequest: (state: string) => boolean;
|
|
450
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"];
|
|
451
451
|
declare const styles: {
|
|
452
452
|
1005: {
|
|
@@ -3465,4 +3465,4 @@ declare const bookCreationRequestSchema: z.ZodObject<{
|
|
|
3465
3465
|
}>;
|
|
3466
3466
|
type BookCreationRequest = z.infer<typeof bookCreationRequestSchema>;
|
|
3467
3467
|
|
|
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,
|
|
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, canSubmitDesignRequest, 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,7 +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
|
|
21
|
+
var canSubmitDesignRequest = (state) => ["new", "ingesting", "ready"].includes(state);
|
|
22
22
|
var occasions = [
|
|
23
23
|
"baby",
|
|
24
24
|
"birthday",
|
|
@@ -4080,7 +4080,7 @@ var Images = class {
|
|
|
4080
4080
|
length;
|
|
4081
4081
|
designRequestState;
|
|
4082
4082
|
async add(image) {
|
|
4083
|
-
if (!
|
|
4083
|
+
if (!canSubmitDesignRequest(this.designRequestState)) {
|
|
4084
4084
|
throw new Error("You need to wait for the current design request to be ready before adding new images.");
|
|
4085
4085
|
} else {
|
|
4086
4086
|
this.images.push(image);
|
|
@@ -4224,7 +4224,7 @@ var DesignRequest = class {
|
|
|
4224
4224
|
return options;
|
|
4225
4225
|
}
|
|
4226
4226
|
async submit(submitDesignRequestProps) {
|
|
4227
|
-
if (!
|
|
4227
|
+
if (!canSubmitDesignRequest(this.state)) {
|
|
4228
4228
|
throw new Error("You need to wait for the current design request to be ready before submitting a new one");
|
|
4229
4229
|
} else {
|
|
4230
4230
|
submitDesignRequestProps && this.updateDesignRequest(submitDesignRequestProps);
|
|
@@ -4234,7 +4234,6 @@ var DesignRequest = class {
|
|
|
4234
4234
|
(await this.client.engineAPI.books.design(this.parentId)).toDesignRequestProps()
|
|
4235
4235
|
);
|
|
4236
4236
|
this.getProgress();
|
|
4237
|
-
this.updateDesignRequest({ state: states[1] });
|
|
4238
4237
|
return this;
|
|
4239
4238
|
}
|
|
4240
4239
|
}
|
|
@@ -4303,7 +4302,7 @@ var DesignRequest = class {
|
|
|
4303
4302
|
let timeout;
|
|
4304
4303
|
this.webSocket.onmessage = async (event) => {
|
|
4305
4304
|
const detail = JSON.parse(event.data);
|
|
4306
|
-
if (this.state !== detail.slug) {
|
|
4305
|
+
if (this.state !== detail.slug || detail.slug === "submitted") {
|
|
4307
4306
|
timeout && clearTimeout(timeout);
|
|
4308
4307
|
timeout = this.timeoutHandler();
|
|
4309
4308
|
await this.eventHandler(detail);
|
|
@@ -4915,7 +4914,7 @@ export {
|
|
|
4915
4914
|
bookDesignRequestSchema,
|
|
4916
4915
|
bookPropsSchema,
|
|
4917
4916
|
bookSizes,
|
|
4918
|
-
|
|
4917
|
+
canSubmitDesignRequest,
|
|
4919
4918
|
cancelledEventDetail,
|
|
4920
4919
|
canvasSchema,
|
|
4921
4920
|
coverTypes,
|