@magiclabs.ai/magicbook-client 0.2.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.
@@ -0,0 +1,6 @@
1
+ import DesignRequest, { DesignRequestProps } from './design-request';
2
+ export default class MagicBookClient {
3
+ apiKey: string;
4
+ constructor(apiKey: string);
5
+ createDesignRequest(designRequestProps?: DesignRequestProps): Promise<DesignRequest>;
6
+ }
@@ -0,0 +1,34 @@
1
+ import { BookCreationRequest } from './nautilus';
2
+ import { Images } from './image';
3
+ export type DesignRequestProps = {
4
+ title?: string;
5
+ occasion?: string;
6
+ style?: string;
7
+ bookFormat?: string;
8
+ coverType?: string;
9
+ pageType?: string;
10
+ imageDensity?: string;
11
+ embellishmentLevel?: string;
12
+ textStickerLevel?: string;
13
+ };
14
+ export type DesignRequestEventDetail = {
15
+ state: 'new' | 'designing' | 'completed' | 'canceled' | 'error';
16
+ };
17
+ export type DesignRequestEvent = CustomEvent<DesignRequestEventDetail>;
18
+ export default class DesignRequest {
19
+ id: string;
20
+ title?: string;
21
+ occasion?: string;
22
+ style?: string;
23
+ bookFormat?: string;
24
+ coverType?: string;
25
+ pageType?: string;
26
+ imageDensity?: string;
27
+ embellishmentLevel?: string;
28
+ textStickerLevel?: string;
29
+ images: Images;
30
+ constructor(id: string, designRequestProps?: DesignRequestProps);
31
+ submit(submitDesignRequest?: DesignRequestProps): Promise<DesignRequest>;
32
+ getJSON(): Promise<BookCreationRequest>;
33
+ startFakeProgress(): void;
34
+ }
@@ -0,0 +1,16 @@
1
+ export type Image = {
2
+ handle: string;
3
+ url: string;
4
+ width: number;
5
+ height: number;
6
+ rotation: number;
7
+ captureTime: string;
8
+ cameraMake?: string;
9
+ cameraModel?: string;
10
+ filename: string;
11
+ };
12
+ export declare class Images {
13
+ private images;
14
+ constructor();
15
+ add(image: Image): Promise<Image>;
16
+ }
@@ -0,0 +1,75 @@
1
+ export interface BookCreationRequest {
2
+ title: string;
3
+ coverSpecId: string;
4
+ styleId: number;
5
+ userId: string;
6
+ magicShopBook: MagicShopBook;
7
+ reportingData: ReportingData;
8
+ }
9
+ export interface MagicShopBook {
10
+ pages: Page[];
11
+ photoStrip: PhotoStrip[];
12
+ }
13
+ export interface Page {
14
+ pageNum: number;
15
+ type: string;
16
+ canvas: Canvas;
17
+ }
18
+ export interface Canvas {
19
+ backgroundId?: string;
20
+ assets: Asset[];
21
+ }
22
+ export interface Asset {
23
+ type: string;
24
+ imageAssignment?: ImageAssignment;
25
+ position: Position;
26
+ seqNum: number;
27
+ z: number;
28
+ id?: string;
29
+ horizJustification?: string;
30
+ vertJustification?: string;
31
+ text?: string;
32
+ fontId?: string;
33
+ fontSize?: number;
34
+ fontColor?: string;
35
+ frame?: string;
36
+ }
37
+ export interface ImageAssignment {
38
+ photoRefId: number;
39
+ finalCrop: number[];
40
+ }
41
+ export interface Position {
42
+ x: number;
43
+ y: number;
44
+ width?: number;
45
+ height?: number;
46
+ rotation: number;
47
+ }
48
+ export interface PhotoStrip {
49
+ url: string;
50
+ encryptId: string;
51
+ photoRefId: number;
52
+ photoMetadata: PhotoMetadata;
53
+ }
54
+ export interface PhotoMetadata {
55
+ id: string;
56
+ llx: number;
57
+ lly: number;
58
+ urx: number;
59
+ ury: number;
60
+ data: string;
61
+ title: string;
62
+ width: number;
63
+ effect: string;
64
+ height: number;
65
+ source: string;
66
+ rotation: number;
67
+ uploadTime: string;
68
+ }
69
+ export interface ReportingData {
70
+ properties: Property[];
71
+ }
72
+ export interface Property {
73
+ key: string;
74
+ value: string | number | boolean | null;
75
+ }
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@magiclabs.ai/magicbook-client",
3
+ "private": false,
4
+ "version": "0.2.0",
5
+ "description": "TypeScript package to create photo books with the Magicbook API.",
6
+ "type": "module",
7
+ "main": "./magicbook-client.umd.cjs",
8
+ "module": "./magicbook-client.js",
9
+ "types": "./index.d.ts",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/56kcloud/mb-client.git"
13
+ },
14
+ "exports": {
15
+ ".": {
16
+ "import": "./magicbook-client.js",
17
+ "require": "./magicbook-client.umd.cjs"
18
+ }
19
+ },
20
+ "scripts": {
21
+ "watch": "vite build --watch",
22
+ "build": "./scripts/build.sh",
23
+ "deploy": "./scripts/deploy-npm.sh",
24
+ "lint": "eslint . --ext js,jsx,ts,tsx --config .eslintrc.json --no-eslintrc",
25
+ "test": "vitest --ui",
26
+ "coverage": "vitest run --coverage"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^18.15.10",
30
+ "@typescript-eslint/eslint-plugin": "^5.57.0",
31
+ "@typescript-eslint/parser": "^5.57.0",
32
+ "@vitest/coverage-c8": "^0.29.8",
33
+ "@vitest/coverage-istanbul": "^0.29.8",
34
+ "@vitest/ui": "^0.29.8",
35
+ "eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
36
+ "jsdom": "^21.1.1",
37
+ "typescript": "^5.0.2",
38
+ "vite": "^4.2.1",
39
+ "vite-plugin-dts": "^2.1.0",
40
+ "vitest": "^0.29.8"
41
+ },
42
+ "dependencies": {
43
+ "@faker-js/faker": "^7.6.0",
44
+ "axios": "^1.3.4"
45
+ }
46
+ }