@magiclabs.ai/magicbook-client 0.2.0 → 0.3.0

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 ADDED
@@ -0,0 +1,109 @@
1
+
2
+ ![GitHub CI](https://github.com/magiclabs-ai/mb-client/actions/workflows/test.yml/badge.svg) ![GitHub CI](https://github.com/magiclabs-ai/mb-client/actions/workflows/linter.yml/badge.svg) [![npm version](https://img.shields.io/npm/v/@magiclabs.ai/magicbook-client.svg)](https://www.npmjs.com/package/@magiclabs.ai/magicbook-client)
3
+
4
+ # magicbook-client
5
+
6
+ TypeScript package to create photo books with the Magicbook API.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @magiclabs.ai/magicbook-client
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ Create a Magicbook API client instance with your API key.
17
+
18
+ ```ts
19
+ const client = new MagicBookClient('api-key')`
20
+ ```
21
+
22
+ Initiate the creation of a photo book by creating a design request. The design request can be initialized by passing parameters (design choices) to the initialization object.
23
+
24
+ ```ts
25
+ const designRequest = await client.createDesignRequest({
26
+ title: 'Australia 2023',
27
+ occasion: 'travel',
28
+ style: '1234',
29
+ bookSize: '8x8',
30
+ coverType: 'hc',
31
+ pageType: 'sp'
32
+ })
33
+ ```
34
+
35
+ Individual parameters can also be set directly on the design request instance:
36
+
37
+ ```ts
38
+ const designRequest = await client.createDesignRequest()
39
+ designRequest.title = 'Australia 2023',
40
+ designRequest.occasion = 'travel',
41
+ designRequest.style = '1234',
42
+ designRequest.bookSize = '8x8',
43
+ designRequest.coverType = 'hc',
44
+ designRequest.pageType = 'sp'
45
+ ```
46
+ As images are getting ready to be handed over to Magicbook, for example when successfully uploaded, add them to the design request object.
47
+
48
+ ```ts
49
+ import {Image} from '@magiclabs.ai/magicbook-client'
50
+
51
+ const image: Image = {...}
52
+ await designRequest.images.add(image)
53
+ ```
54
+
55
+ This would typically be done in an event handler connected to the image manager.
56
+
57
+ ```ts
58
+ window.addEventListener('ImageManager.ImageUploaded', async (item) => {
59
+ const image: DesignRequestImage = {...}
60
+ await designRequest.images.add(image)
61
+ })
62
+ ```
63
+
64
+ Optionally, you can retrieve design options for the design request by calling the `getOptions` method, providing the total number of images selected by the user. The returned object contains the image densities (i.e. page count and image per page estimations)
65
+
66
+ ```ts
67
+ const selectedImageCount = 200
68
+ ...
69
+ const designOptions = designRequest.getOptions(selectedImageCount)
70
+ ```
71
+
72
+ Before submitting the design request to Magicbook, register a callback to receive update events.
73
+
74
+ ```ts
75
+ window.addEventListener('Magicbook.designRequestUpdated', async ((designRequestEvent: DesignRequestEvent) => {
76
+ console.log(designRequestEvent.detail)
77
+ }) as EventListener)
78
+ ```
79
+
80
+ Submit the design request. Again, the argument object can receive additional or updated design parameters.
81
+
82
+ ```ts
83
+ designRequest.submit({
84
+ imageDensity: 'high',
85
+ imageFiltering: 'best',
86
+ embellishmentLevel: 'few',
87
+ textStickerLevel: 'none'
88
+ })
89
+ ```
90
+
91
+ Finally, once the design request is complete, retrieve it in JSON format.
92
+
93
+ ```ts
94
+ await designRequest.getJSON()
95
+ ```
96
+
97
+ ___
98
+
99
+
100
+ ## Example
101
+
102
+ To see the Magicbook client in action, run the following commands after navigating to the `./example` directory:
103
+
104
+ ```bash
105
+ npm run build
106
+ cd example
107
+ npm i
108
+ npm run dev
109
+ ```
@@ -0,0 +1,2 @@
1
+ import { DesignOptions } from '../models/design-request/design-options';
2
+ export declare const designOptions: DesignOptions;
@@ -0,0 +1,10 @@
1
+ export declare const States: readonly ["new", "designing", "completed", "canceled", "error"];
2
+ export declare const Occasions: readonly ["baby", "birthday", "default", "everyday", "family", "kids", "life-stories", "none", "portfolio", "school-memories", "seasonal-holidays", "special-celebrations", "sports-and-hobbies", "travel", "wedding", "year-in-review"];
3
+ export declare const Styles: readonly ["2020-what-a-year-sfly", "a-year-in-color-sfly", "adventure-awaits-sfly", "autumn-memories-sfly", "babys-first-sfly", "babys-first-year-sfly", "beach-bliss-sfly", "beach-travel-sfly", "beach-wedding-sfly", "best-dad-ever-sfly", "best-day-ever-sfly", "best-grandparents-ever-sfly", "best-mom-ever-sfly", "black-and-white-rustic-sfly", "black-white-photo-album-sfly", "boho-baby-sfly", "boho-summer-sfly", "boho-travel-by-umaiana-studio-sfly", "boho-wedding-sfly", "bold-year-in-review-by-float-paperie-sfly", "bon-voyage-sfly", "bright-and-bold-kids-year-in-review-by-sarah-hawkins-designs-sfly", "bright-color-pop-sfly", "celebrate-family-by-float-paperie-sfly", "celebration-of-life-by-sarah-hawkins-designs-sfly", "chalkboard-chic-sfly", "cheerful-color-sfly", "chic-celebrations-by-float-paperie-sfly", "classic-baby-sfly", "classic-disney-sfly", "classic-recipes-sfly", "classic-school-yearbook-sfly", "classic-wedding-mma", "classic-wedding-sfly", "colorful-birthday-sfly", "colorful-childhood-sfly", "colorful-elementary-school-yearbook-sfly", "colorful-florals-by-potts-design-sfly", "colorful-gradients-sfly", "colorful-memories-by-britt-bass-sfly", "colorful-school-days-by-float-paperie-sfly", "colorful-year-in-review-by-sarah-hawkins-designs-sfly", "colorfully-fun-sfly", "digiscrap-sfly", "disney-adventure-sfly", "disney-family-adventures-sfly", "elegant-wedding-greenery-by-kim-thoa-sfly", "elegant-wedding-sfly", "elegantly-scripted-year-in-review-sfly", "elevated-rustic-sfly", "everyday-boho-by-umaiana-studio-sfly", "everyday-chalkboard-by-potts-design-sfly", "everyday-fairytale-by-jenny-romanski-sfly", "everyday-happiness-sfly", "everyday-indigo-sfly", "everyday-neutrals-sfly", "everyday-recipes-by-slightly-stationery-sfly", "everyday-rustic-sfly", "everyday-sentiments-sfly", "everyday-watercolor-sfly", "everything-sports-sfly", "family-blessings-by-potts-design-sfly", "family-favorites-by-lure-design-sfly", "family-vacation-sfly", "family-yearbook-sfly", "familygram-sfly", "forever-love-by-with-merriment-sfly", "fun-in-the-sun-sfly", "gilded-wedding-guestbook-sfly", "gilded-wedding-sfly", "go-sports-by-lure-design-sfly", "graduation-celebration-sfly", "graduation-photo-album-sfly", "hello-spring-sfly", "hello-summer-sfly", "high-school-memories-sfly", "holiday-memories-sfly", "its-a-girl-thing-sfly", "kraft-pop-sfly", "life-is-grand-sfly", "little-love-sfly", "love-and-thanks-sfly", "love-grows-sfly", "love-is-all-we-need-sfly", "love-you-because-sfly", "made-with-love-sfly", "milestone-anniversaries-sfly", "modern-baby-sfly", "modern-black-sfly", "modern-celebrations-sfly", "modern-dark-neutrals-sfly", "modern-grey-sfly", "modern-indigo-sfly", "modern-light-neutrals-sfly", "modern-love-story-sfly", "modern-photo-album-sfly", "modern-travel-sfly", "modern-wedding-mma", "modern-wedding-sfly", "modern-wedding-story-sfly", "modern-white-sfly", "modern-year-in-review-photo-album-sfly", "muted-everyday-abstract-sfly", "national-parks-travel-by-eiman-design-co-sfly", "natural-neutrals-sfly", "ombre-watercolor-sfly", "our-wedding-day-guestbook-sfly", "our-wedding-day-sfly", "outdoor-adventures-by-sarah-hawkins-designs-sfly", "outdoor-wedding-sfly", "painted-seasons-sfly", "pet-lover-sfly", "reunion-sfly", "road-trip-travel-by-sarah-hawkins-designs-sfly", "rustic-farmhouse-sfly", "rustic-gilded-wedding-sfly", "rustic-wedding-mma", "rustic-wedding-sfly", "school-days-yearbook-sfly", "shimmer-and-shine-sfly", "simple-elegant-wedding-sfly", "simply-black-sfly", "simply-bold-type-sfly", "simply-gallery-sfly", "simply-gray-sfly", "simply-modern-sfly", "simply-scrapbook-sfly", "softly-rustic-sfly", "sparkle-and-shine-sfly", "summertime-fun-sfly", "the-story-of-me-sfly", "the-travel-bug-sfly", "this-is-love-sfly", "together-again-sfly", "travel-abroad-sfly", "travel-adventures-sfly", "travel-gallery-sfly", "travel-memories-sfly", "travel-snapshots-sfly", "tropical-travel-sfly", "tropical-travels-sfly", "usa-travel-sfly", "vintage-disney-sfly", "vintage-travel-sfly", "vintage-wedding-sfly", "vivid-watercolor-sfly", "watercolor-baby-boy-sfly", "watercolor-baby-girl-sfly", "watercolor-floral-wedding-by-kim-thoa-sfly", "watercolor-greenery-by-sarah-hawkins-designs-sfly", "watercolor-year-in-review-sfly", "watercolorwashes-sfly", "wedding-gallery-sfly", "welcome-baby-sfly", "what-i-love-about-you-sfly", "whimsical-recipes-by-slightly-stationery-sfly", "whimsy-chalkboard-sfly", "winter-getaway-sfly", "winter-memories-by-sarah-hawkins-design-sfly", "world-travel-sfly"];
4
+ export declare const BookSizes: readonly ["8x8", "10x10", "12x12", "8x11", "11x8", "11x14"];
5
+ export declare const CoverTypes: readonly ["sc", "hc", "pl"];
6
+ export declare const PageTypes: readonly ["sp", "sl", "dl"];
7
+ export declare const ImageDensities: readonly ["low", "medium", "high"];
8
+ export declare const ImageFilterings: readonly ["best", "most", "all"];
9
+ export declare const EmbellishmentLevels: readonly ["none", "few", "lots"];
10
+ export declare const TextStickerLevels: readonly ["none", "few", "lots"];
@@ -0,0 +1,2 @@
1
+ import { BookCreationRequest } from '../models/galleon';
2
+ export declare const galleonJSON: BookCreationRequest;
package/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { default as MagicBookClient } from './models/client';
2
- export type { Image } from './models/image';
3
- export type { DesignRequestEvent, DesignRequestProps, DesignRequestEventDetail } from './models/design-request';
1
+ export * from './models/client';
2
+ export * from './models/design-request/image';
3
+ export * from './models/design-request';