@magiclabs.ai/magicbook-client 0.7.11-canary → 0.7.13-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 +6 -0
- package/index.cjs +32 -13
- package/index.cjs.map +1 -1
- package/index.d.cts +20 -8
- package/index.d.ts +20 -8
- package/index.iife.js +32 -13
- package/index.js +32 -13
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -920,6 +920,7 @@ declare class ImagesEndpoints {
|
|
|
920
920
|
id?: string | undefined;
|
|
921
921
|
camera_make?: string | undefined;
|
|
922
922
|
camera?: string | undefined;
|
|
923
|
+
metadata?: Record<string, unknown> | undefined;
|
|
923
924
|
}[]>;
|
|
924
925
|
retrieve(imageId: string, bookId: string): Promise<{
|
|
925
926
|
handle: string;
|
|
@@ -932,6 +933,7 @@ declare class ImagesEndpoints {
|
|
|
932
933
|
id?: string | undefined;
|
|
933
934
|
camera_make?: string | undefined;
|
|
934
935
|
camera?: string | undefined;
|
|
936
|
+
metadata?: Record<string, unknown> | undefined;
|
|
935
937
|
}>;
|
|
936
938
|
update(imageId: string, bookId: string, image: ImageServer): Promise<{
|
|
937
939
|
handle: string;
|
|
@@ -944,6 +946,7 @@ declare class ImagesEndpoints {
|
|
|
944
946
|
id?: string | undefined;
|
|
945
947
|
camera_make?: string | undefined;
|
|
946
948
|
camera?: string | undefined;
|
|
949
|
+
metadata?: Record<string, unknown> | undefined;
|
|
947
950
|
}>;
|
|
948
951
|
delete(imageId: string, bookId: string): Promise<void>;
|
|
949
952
|
addToBook(bookId: string, image: ImageServer): Promise<{
|
|
@@ -957,6 +960,7 @@ declare class ImagesEndpoints {
|
|
|
957
960
|
id?: string | undefined;
|
|
958
961
|
camera_make?: string | undefined;
|
|
959
962
|
camera?: string | undefined;
|
|
963
|
+
metadata?: Record<string, unknown> | undefined;
|
|
960
964
|
}>;
|
|
961
965
|
}
|
|
962
966
|
|
|
@@ -988,8 +992,8 @@ declare const spreadServerSchema: z.ZodObject<{
|
|
|
988
992
|
url?: string | null | undefined;
|
|
989
993
|
width?: number | undefined;
|
|
990
994
|
height?: number | undefined;
|
|
991
|
-
background?: unknown;
|
|
992
995
|
metadata?: unknown;
|
|
996
|
+
background?: unknown;
|
|
993
997
|
}, {
|
|
994
998
|
state: string;
|
|
995
999
|
book_id: string;
|
|
@@ -1003,8 +1007,8 @@ declare const spreadServerSchema: z.ZodObject<{
|
|
|
1003
1007
|
url?: string | null | undefined;
|
|
1004
1008
|
width?: number | undefined;
|
|
1005
1009
|
height?: number | undefined;
|
|
1006
|
-
background?: unknown;
|
|
1007
1010
|
metadata?: unknown;
|
|
1011
|
+
background?: unknown;
|
|
1008
1012
|
}>;
|
|
1009
1013
|
type SpreadServer = z.infer<typeof spreadServerSchema>;
|
|
1010
1014
|
|
|
@@ -1024,8 +1028,8 @@ declare class SpreadsEndpoints {
|
|
|
1024
1028
|
url?: string | null | undefined;
|
|
1025
1029
|
width?: number | undefined;
|
|
1026
1030
|
height?: number | undefined;
|
|
1027
|
-
background?: unknown;
|
|
1028
1031
|
metadata?: unknown;
|
|
1032
|
+
background?: unknown;
|
|
1029
1033
|
}[]>;
|
|
1030
1034
|
create(bookId: string, spread: SpreadServer): Promise<{
|
|
1031
1035
|
state: string;
|
|
@@ -1040,8 +1044,8 @@ declare class SpreadsEndpoints {
|
|
|
1040
1044
|
url?: string | null | undefined;
|
|
1041
1045
|
width?: number | undefined;
|
|
1042
1046
|
height?: number | undefined;
|
|
1043
|
-
background?: unknown;
|
|
1044
1047
|
metadata?: unknown;
|
|
1048
|
+
background?: unknown;
|
|
1045
1049
|
}>;
|
|
1046
1050
|
retrieve(spreadId: string, bookId: string): Promise<{
|
|
1047
1051
|
state: string;
|
|
@@ -1056,8 +1060,8 @@ declare class SpreadsEndpoints {
|
|
|
1056
1060
|
url?: string | null | undefined;
|
|
1057
1061
|
width?: number | undefined;
|
|
1058
1062
|
height?: number | undefined;
|
|
1059
|
-
background?: unknown;
|
|
1060
1063
|
metadata?: unknown;
|
|
1064
|
+
background?: unknown;
|
|
1061
1065
|
}>;
|
|
1062
1066
|
update(spreadId: string, bookId: string, spread: SpreadServer): Promise<{
|
|
1063
1067
|
state: string;
|
|
@@ -1072,8 +1076,8 @@ declare class SpreadsEndpoints {
|
|
|
1072
1076
|
url?: string | null | undefined;
|
|
1073
1077
|
width?: number | undefined;
|
|
1074
1078
|
height?: number | undefined;
|
|
1075
|
-
background?: unknown;
|
|
1076
1079
|
metadata?: unknown;
|
|
1080
|
+
background?: unknown;
|
|
1077
1081
|
}>;
|
|
1078
1082
|
delete(spreadId: string, bookId: string): Promise<void>;
|
|
1079
1083
|
layouts(bookId: string, page: number, surfaceCategoryName?: SurfaceCategoryName): Promise<({
|
|
@@ -1179,6 +1183,7 @@ declare class MagicBookClient {
|
|
|
1179
1183
|
}
|
|
1180
1184
|
|
|
1181
1185
|
type Image = {
|
|
1186
|
+
id?: string;
|
|
1182
1187
|
handle: string;
|
|
1183
1188
|
url: string;
|
|
1184
1189
|
width: number;
|
|
@@ -1188,15 +1193,17 @@ type Image = {
|
|
|
1188
1193
|
cameraMake?: string;
|
|
1189
1194
|
cameraModel?: string;
|
|
1190
1195
|
filename: string;
|
|
1196
|
+
metadata?: Record<string, unknown>;
|
|
1191
1197
|
};
|
|
1192
1198
|
declare class Images {
|
|
1193
1199
|
private readonly client;
|
|
1194
1200
|
private parentId;
|
|
1195
|
-
|
|
1201
|
+
list: Array<Image>;
|
|
1196
1202
|
length: number;
|
|
1197
1203
|
designRequestState: State;
|
|
1198
1204
|
constructor(client: MagicBookClient, parentId: string, designRequestState: State);
|
|
1199
|
-
add(image: Image): Promise<
|
|
1205
|
+
add(image: Image): Promise<Image>;
|
|
1206
|
+
delete(imageId: string): Promise<number>;
|
|
1200
1207
|
}
|
|
1201
1208
|
declare const imageServerSchema: z.ZodObject<{
|
|
1202
1209
|
id: z.ZodOptional<z.ZodString>;
|
|
@@ -1209,6 +1216,7 @@ declare const imageServerSchema: z.ZodObject<{
|
|
|
1209
1216
|
camera_make: z.ZodOptional<z.ZodString>;
|
|
1210
1217
|
camera: z.ZodOptional<z.ZodString>;
|
|
1211
1218
|
filename: z.ZodString;
|
|
1219
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1212
1220
|
}, "strip", z.ZodTypeAny, {
|
|
1213
1221
|
handle: string;
|
|
1214
1222
|
url: string;
|
|
@@ -1220,6 +1228,7 @@ declare const imageServerSchema: z.ZodObject<{
|
|
|
1220
1228
|
id?: string | undefined;
|
|
1221
1229
|
camera_make?: string | undefined;
|
|
1222
1230
|
camera?: string | undefined;
|
|
1231
|
+
metadata?: Record<string, unknown> | undefined;
|
|
1223
1232
|
}, {
|
|
1224
1233
|
handle: string;
|
|
1225
1234
|
url: string;
|
|
@@ -1231,8 +1240,10 @@ declare const imageServerSchema: z.ZodObject<{
|
|
|
1231
1240
|
id?: string | undefined;
|
|
1232
1241
|
camera_make?: string | undefined;
|
|
1233
1242
|
camera?: string | undefined;
|
|
1243
|
+
metadata?: Record<string, unknown> | undefined;
|
|
1234
1244
|
}>;
|
|
1235
1245
|
declare class ImageServer {
|
|
1246
|
+
id?: string;
|
|
1236
1247
|
handle: string;
|
|
1237
1248
|
url: string;
|
|
1238
1249
|
width: number;
|
|
@@ -1242,6 +1253,7 @@ declare class ImageServer {
|
|
|
1242
1253
|
camera_make?: string;
|
|
1243
1254
|
camera?: string;
|
|
1244
1255
|
filename: string;
|
|
1256
|
+
metadata?: Record<string, unknown>;
|
|
1245
1257
|
constructor(image: Image);
|
|
1246
1258
|
}
|
|
1247
1259
|
declare function imageServerToImage(imageServer: ImageServer): Image;
|
package/index.d.ts
CHANGED
|
@@ -920,6 +920,7 @@ declare class ImagesEndpoints {
|
|
|
920
920
|
id?: string | undefined;
|
|
921
921
|
camera_make?: string | undefined;
|
|
922
922
|
camera?: string | undefined;
|
|
923
|
+
metadata?: Record<string, unknown> | undefined;
|
|
923
924
|
}[]>;
|
|
924
925
|
retrieve(imageId: string, bookId: string): Promise<{
|
|
925
926
|
handle: string;
|
|
@@ -932,6 +933,7 @@ declare class ImagesEndpoints {
|
|
|
932
933
|
id?: string | undefined;
|
|
933
934
|
camera_make?: string | undefined;
|
|
934
935
|
camera?: string | undefined;
|
|
936
|
+
metadata?: Record<string, unknown> | undefined;
|
|
935
937
|
}>;
|
|
936
938
|
update(imageId: string, bookId: string, image: ImageServer): Promise<{
|
|
937
939
|
handle: string;
|
|
@@ -944,6 +946,7 @@ declare class ImagesEndpoints {
|
|
|
944
946
|
id?: string | undefined;
|
|
945
947
|
camera_make?: string | undefined;
|
|
946
948
|
camera?: string | undefined;
|
|
949
|
+
metadata?: Record<string, unknown> | undefined;
|
|
947
950
|
}>;
|
|
948
951
|
delete(imageId: string, bookId: string): Promise<void>;
|
|
949
952
|
addToBook(bookId: string, image: ImageServer): Promise<{
|
|
@@ -957,6 +960,7 @@ declare class ImagesEndpoints {
|
|
|
957
960
|
id?: string | undefined;
|
|
958
961
|
camera_make?: string | undefined;
|
|
959
962
|
camera?: string | undefined;
|
|
963
|
+
metadata?: Record<string, unknown> | undefined;
|
|
960
964
|
}>;
|
|
961
965
|
}
|
|
962
966
|
|
|
@@ -988,8 +992,8 @@ declare const spreadServerSchema: z.ZodObject<{
|
|
|
988
992
|
url?: string | null | undefined;
|
|
989
993
|
width?: number | undefined;
|
|
990
994
|
height?: number | undefined;
|
|
991
|
-
background?: unknown;
|
|
992
995
|
metadata?: unknown;
|
|
996
|
+
background?: unknown;
|
|
993
997
|
}, {
|
|
994
998
|
state: string;
|
|
995
999
|
book_id: string;
|
|
@@ -1003,8 +1007,8 @@ declare const spreadServerSchema: z.ZodObject<{
|
|
|
1003
1007
|
url?: string | null | undefined;
|
|
1004
1008
|
width?: number | undefined;
|
|
1005
1009
|
height?: number | undefined;
|
|
1006
|
-
background?: unknown;
|
|
1007
1010
|
metadata?: unknown;
|
|
1011
|
+
background?: unknown;
|
|
1008
1012
|
}>;
|
|
1009
1013
|
type SpreadServer = z.infer<typeof spreadServerSchema>;
|
|
1010
1014
|
|
|
@@ -1024,8 +1028,8 @@ declare class SpreadsEndpoints {
|
|
|
1024
1028
|
url?: string | null | undefined;
|
|
1025
1029
|
width?: number | undefined;
|
|
1026
1030
|
height?: number | undefined;
|
|
1027
|
-
background?: unknown;
|
|
1028
1031
|
metadata?: unknown;
|
|
1032
|
+
background?: unknown;
|
|
1029
1033
|
}[]>;
|
|
1030
1034
|
create(bookId: string, spread: SpreadServer): Promise<{
|
|
1031
1035
|
state: string;
|
|
@@ -1040,8 +1044,8 @@ declare class SpreadsEndpoints {
|
|
|
1040
1044
|
url?: string | null | undefined;
|
|
1041
1045
|
width?: number | undefined;
|
|
1042
1046
|
height?: number | undefined;
|
|
1043
|
-
background?: unknown;
|
|
1044
1047
|
metadata?: unknown;
|
|
1048
|
+
background?: unknown;
|
|
1045
1049
|
}>;
|
|
1046
1050
|
retrieve(spreadId: string, bookId: string): Promise<{
|
|
1047
1051
|
state: string;
|
|
@@ -1056,8 +1060,8 @@ declare class SpreadsEndpoints {
|
|
|
1056
1060
|
url?: string | null | undefined;
|
|
1057
1061
|
width?: number | undefined;
|
|
1058
1062
|
height?: number | undefined;
|
|
1059
|
-
background?: unknown;
|
|
1060
1063
|
metadata?: unknown;
|
|
1064
|
+
background?: unknown;
|
|
1061
1065
|
}>;
|
|
1062
1066
|
update(spreadId: string, bookId: string, spread: SpreadServer): Promise<{
|
|
1063
1067
|
state: string;
|
|
@@ -1072,8 +1076,8 @@ declare class SpreadsEndpoints {
|
|
|
1072
1076
|
url?: string | null | undefined;
|
|
1073
1077
|
width?: number | undefined;
|
|
1074
1078
|
height?: number | undefined;
|
|
1075
|
-
background?: unknown;
|
|
1076
1079
|
metadata?: unknown;
|
|
1080
|
+
background?: unknown;
|
|
1077
1081
|
}>;
|
|
1078
1082
|
delete(spreadId: string, bookId: string): Promise<void>;
|
|
1079
1083
|
layouts(bookId: string, page: number, surfaceCategoryName?: SurfaceCategoryName): Promise<({
|
|
@@ -1179,6 +1183,7 @@ declare class MagicBookClient {
|
|
|
1179
1183
|
}
|
|
1180
1184
|
|
|
1181
1185
|
type Image = {
|
|
1186
|
+
id?: string;
|
|
1182
1187
|
handle: string;
|
|
1183
1188
|
url: string;
|
|
1184
1189
|
width: number;
|
|
@@ -1188,15 +1193,17 @@ type Image = {
|
|
|
1188
1193
|
cameraMake?: string;
|
|
1189
1194
|
cameraModel?: string;
|
|
1190
1195
|
filename: string;
|
|
1196
|
+
metadata?: Record<string, unknown>;
|
|
1191
1197
|
};
|
|
1192
1198
|
declare class Images {
|
|
1193
1199
|
private readonly client;
|
|
1194
1200
|
private parentId;
|
|
1195
|
-
|
|
1201
|
+
list: Array<Image>;
|
|
1196
1202
|
length: number;
|
|
1197
1203
|
designRequestState: State;
|
|
1198
1204
|
constructor(client: MagicBookClient, parentId: string, designRequestState: State);
|
|
1199
|
-
add(image: Image): Promise<
|
|
1205
|
+
add(image: Image): Promise<Image>;
|
|
1206
|
+
delete(imageId: string): Promise<number>;
|
|
1200
1207
|
}
|
|
1201
1208
|
declare const imageServerSchema: z.ZodObject<{
|
|
1202
1209
|
id: z.ZodOptional<z.ZodString>;
|
|
@@ -1209,6 +1216,7 @@ declare const imageServerSchema: z.ZodObject<{
|
|
|
1209
1216
|
camera_make: z.ZodOptional<z.ZodString>;
|
|
1210
1217
|
camera: z.ZodOptional<z.ZodString>;
|
|
1211
1218
|
filename: z.ZodString;
|
|
1219
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1212
1220
|
}, "strip", z.ZodTypeAny, {
|
|
1213
1221
|
handle: string;
|
|
1214
1222
|
url: string;
|
|
@@ -1220,6 +1228,7 @@ declare const imageServerSchema: z.ZodObject<{
|
|
|
1220
1228
|
id?: string | undefined;
|
|
1221
1229
|
camera_make?: string | undefined;
|
|
1222
1230
|
camera?: string | undefined;
|
|
1231
|
+
metadata?: Record<string, unknown> | undefined;
|
|
1223
1232
|
}, {
|
|
1224
1233
|
handle: string;
|
|
1225
1234
|
url: string;
|
|
@@ -1231,8 +1240,10 @@ declare const imageServerSchema: z.ZodObject<{
|
|
|
1231
1240
|
id?: string | undefined;
|
|
1232
1241
|
camera_make?: string | undefined;
|
|
1233
1242
|
camera?: string | undefined;
|
|
1243
|
+
metadata?: Record<string, unknown> | undefined;
|
|
1234
1244
|
}>;
|
|
1235
1245
|
declare class ImageServer {
|
|
1246
|
+
id?: string;
|
|
1236
1247
|
handle: string;
|
|
1237
1248
|
url: string;
|
|
1238
1249
|
width: number;
|
|
@@ -1242,6 +1253,7 @@ declare class ImageServer {
|
|
|
1242
1253
|
camera_make?: string;
|
|
1243
1254
|
camera?: string;
|
|
1244
1255
|
filename: string;
|
|
1256
|
+
metadata?: Record<string, unknown>;
|
|
1245
1257
|
constructor(image: Image);
|
|
1246
1258
|
}
|
|
1247
1259
|
declare function imageServerToImage(imageServer: ImageServer): Image;
|
package/index.iife.js
CHANGED
|
@@ -4482,25 +4482,37 @@ var MagicLabs = (() => {
|
|
|
4482
4482
|
}
|
|
4483
4483
|
};
|
|
4484
4484
|
var Images = class {
|
|
4485
|
-
// eslint-disable-next-line no-unused-vars
|
|
4486
4485
|
constructor(client, parentId, designRequestState) {
|
|
4487
4486
|
this.client = client;
|
|
4488
4487
|
this.parentId = parentId;
|
|
4489
|
-
this.
|
|
4490
|
-
this.length = this.
|
|
4488
|
+
this.list = [];
|
|
4489
|
+
this.length = this.list.length;
|
|
4491
4490
|
this.designRequestState = designRequestState;
|
|
4492
4491
|
}
|
|
4493
4492
|
parentId;
|
|
4494
|
-
|
|
4493
|
+
list;
|
|
4495
4494
|
length;
|
|
4496
4495
|
designRequestState;
|
|
4497
4496
|
async add(image) {
|
|
4498
4497
|
if (!canSubmitDesignRequest(this.designRequestState)) {
|
|
4499
4498
|
throw new Error("You need to wait for the current design request to be ready before adding new images.");
|
|
4500
4499
|
} else {
|
|
4501
|
-
this.images.
|
|
4502
|
-
|
|
4503
|
-
|
|
4500
|
+
const serverImage = await this.client.engineAPI.images.addToBook(this.parentId, new ImageServer(image));
|
|
4501
|
+
const img = imageServerToImage(serverImage);
|
|
4502
|
+
this.list.push(img);
|
|
4503
|
+
this.length = this.list.length;
|
|
4504
|
+
return new Promise((resolve) => {
|
|
4505
|
+
resolve(img);
|
|
4506
|
+
});
|
|
4507
|
+
}
|
|
4508
|
+
}
|
|
4509
|
+
async delete(imageId) {
|
|
4510
|
+
if (!canSubmitDesignRequest(this.designRequestState)) {
|
|
4511
|
+
throw new Error("You need to wait for the current design request to be ready before deleting images.");
|
|
4512
|
+
} else {
|
|
4513
|
+
await this.client.engineAPI.images.delete(imageId, this.parentId);
|
|
4514
|
+
this.list.splice(this.list.findIndex((image) => image.handle === imageId), 1);
|
|
4515
|
+
this.length = this.list.length;
|
|
4504
4516
|
return new Promise((resolve) => {
|
|
4505
4517
|
resolve(this.length);
|
|
4506
4518
|
});
|
|
@@ -4517,9 +4529,11 @@ var MagicLabs = (() => {
|
|
|
4517
4529
|
taken_at: z.string(),
|
|
4518
4530
|
camera_make: z.string().optional(),
|
|
4519
4531
|
camera: z.string().optional(),
|
|
4520
|
-
filename: z.string()
|
|
4532
|
+
filename: z.string(),
|
|
4533
|
+
metadata: z.record(z.unknown()).optional()
|
|
4521
4534
|
});
|
|
4522
4535
|
var ImageServer = class {
|
|
4536
|
+
id;
|
|
4523
4537
|
handle;
|
|
4524
4538
|
url;
|
|
4525
4539
|
width;
|
|
@@ -4529,7 +4543,9 @@ var MagicLabs = (() => {
|
|
|
4529
4543
|
camera_make;
|
|
4530
4544
|
camera;
|
|
4531
4545
|
filename;
|
|
4546
|
+
metadata;
|
|
4532
4547
|
constructor(image) {
|
|
4548
|
+
this.id = image.id;
|
|
4533
4549
|
this.handle = image.handle;
|
|
4534
4550
|
this.url = image.url;
|
|
4535
4551
|
this.width = image.width;
|
|
@@ -4539,10 +4555,12 @@ var MagicLabs = (() => {
|
|
|
4539
4555
|
this.camera_make = image.cameraMake;
|
|
4540
4556
|
this.camera = image.cameraModel;
|
|
4541
4557
|
this.filename = image.filename;
|
|
4558
|
+
this.metadata = image.metadata;
|
|
4542
4559
|
}
|
|
4543
4560
|
};
|
|
4544
4561
|
function imageServerToImage(imageServer) {
|
|
4545
4562
|
return {
|
|
4563
|
+
id: imageServer.id,
|
|
4546
4564
|
handle: imageServer.handle,
|
|
4547
4565
|
url: imageServer.url,
|
|
4548
4566
|
width: imageServer.width,
|
|
@@ -4551,7 +4569,8 @@ var MagicLabs = (() => {
|
|
|
4551
4569
|
captureTime: imageServer.taken_at,
|
|
4552
4570
|
cameraMake: imageServer.camera_make,
|
|
4553
4571
|
cameraModel: imageServer.camera,
|
|
4554
|
-
filename: imageServer.filename
|
|
4572
|
+
filename: imageServer.filename,
|
|
4573
|
+
metadata: imageServer.metadata
|
|
4555
4574
|
};
|
|
4556
4575
|
}
|
|
4557
4576
|
var imageDensityOptionSchema = z.object({
|
|
@@ -4748,7 +4767,7 @@ var MagicLabs = (() => {
|
|
|
4748
4767
|
toBook() {
|
|
4749
4768
|
const designRequest = {
|
|
4750
4769
|
...this,
|
|
4751
|
-
images: this.images
|
|
4770
|
+
images: this.images.list
|
|
4752
4771
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4753
4772
|
};
|
|
4754
4773
|
delete designRequest.client;
|
|
@@ -4959,7 +4978,7 @@ var MagicLabs = (() => {
|
|
|
4959
4978
|
retrieve(imageId, bookId) {
|
|
4960
4979
|
return handleAsyncFunction(async () => {
|
|
4961
4980
|
const res = await this.engineAPI.fetcher.call({
|
|
4962
|
-
path: `/v1/images/${imageId}/book/${bookId}
|
|
4981
|
+
path: `/v1/images/${imageId}/book/${bookId}`
|
|
4963
4982
|
});
|
|
4964
4983
|
return imageServerSchema.parse(res);
|
|
4965
4984
|
});
|
|
@@ -4967,7 +4986,7 @@ var MagicLabs = (() => {
|
|
|
4967
4986
|
update(imageId, bookId, image) {
|
|
4968
4987
|
return handleAsyncFunction(async () => {
|
|
4969
4988
|
const res = await this.engineAPI.fetcher.call({
|
|
4970
|
-
path: `/v1/images/${imageId}/book/${bookId}
|
|
4989
|
+
path: `/v1/images/${imageId}/book/${bookId}`,
|
|
4971
4990
|
options: {
|
|
4972
4991
|
method: "PUT",
|
|
4973
4992
|
body: cleanJSON(image)
|
|
@@ -4979,7 +4998,7 @@ var MagicLabs = (() => {
|
|
|
4979
4998
|
delete(imageId, bookId) {
|
|
4980
4999
|
return handleAsyncFunction(async () => {
|
|
4981
5000
|
await this.engineAPI.fetcher.call({
|
|
4982
|
-
path: `/v1/images/${imageId}/book/${bookId}
|
|
5001
|
+
path: `/v1/images/${imageId}/book/${bookId}`,
|
|
4983
5002
|
options: {
|
|
4984
5003
|
method: "DELETE"
|
|
4985
5004
|
}
|
package/index.js
CHANGED
|
@@ -4420,25 +4420,37 @@ var Book = class {
|
|
|
4420
4420
|
|
|
4421
4421
|
// ../../core/models/design-request/image.ts
|
|
4422
4422
|
var Images = class {
|
|
4423
|
-
// eslint-disable-next-line no-unused-vars
|
|
4424
4423
|
constructor(client, parentId, designRequestState) {
|
|
4425
4424
|
this.client = client;
|
|
4426
4425
|
this.parentId = parentId;
|
|
4427
|
-
this.
|
|
4428
|
-
this.length = this.
|
|
4426
|
+
this.list = [];
|
|
4427
|
+
this.length = this.list.length;
|
|
4429
4428
|
this.designRequestState = designRequestState;
|
|
4430
4429
|
}
|
|
4431
4430
|
parentId;
|
|
4432
|
-
|
|
4431
|
+
list;
|
|
4433
4432
|
length;
|
|
4434
4433
|
designRequestState;
|
|
4435
4434
|
async add(image) {
|
|
4436
4435
|
if (!canSubmitDesignRequest(this.designRequestState)) {
|
|
4437
4436
|
throw new Error("You need to wait for the current design request to be ready before adding new images.");
|
|
4438
4437
|
} else {
|
|
4439
|
-
this.images.
|
|
4440
|
-
|
|
4441
|
-
|
|
4438
|
+
const serverImage = await this.client.engineAPI.images.addToBook(this.parentId, new ImageServer(image));
|
|
4439
|
+
const img = imageServerToImage(serverImage);
|
|
4440
|
+
this.list.push(img);
|
|
4441
|
+
this.length = this.list.length;
|
|
4442
|
+
return new Promise((resolve) => {
|
|
4443
|
+
resolve(img);
|
|
4444
|
+
});
|
|
4445
|
+
}
|
|
4446
|
+
}
|
|
4447
|
+
async delete(imageId) {
|
|
4448
|
+
if (!canSubmitDesignRequest(this.designRequestState)) {
|
|
4449
|
+
throw new Error("You need to wait for the current design request to be ready before deleting images.");
|
|
4450
|
+
} else {
|
|
4451
|
+
await this.client.engineAPI.images.delete(imageId, this.parentId);
|
|
4452
|
+
this.list.splice(this.list.findIndex((image) => image.handle === imageId), 1);
|
|
4453
|
+
this.length = this.list.length;
|
|
4442
4454
|
return new Promise((resolve) => {
|
|
4443
4455
|
resolve(this.length);
|
|
4444
4456
|
});
|
|
@@ -4455,9 +4467,11 @@ var imageServerSchema = z.object({
|
|
|
4455
4467
|
taken_at: z.string(),
|
|
4456
4468
|
camera_make: z.string().optional(),
|
|
4457
4469
|
camera: z.string().optional(),
|
|
4458
|
-
filename: z.string()
|
|
4470
|
+
filename: z.string(),
|
|
4471
|
+
metadata: z.record(z.unknown()).optional()
|
|
4459
4472
|
});
|
|
4460
4473
|
var ImageServer = class {
|
|
4474
|
+
id;
|
|
4461
4475
|
handle;
|
|
4462
4476
|
url;
|
|
4463
4477
|
width;
|
|
@@ -4467,7 +4481,9 @@ var ImageServer = class {
|
|
|
4467
4481
|
camera_make;
|
|
4468
4482
|
camera;
|
|
4469
4483
|
filename;
|
|
4484
|
+
metadata;
|
|
4470
4485
|
constructor(image) {
|
|
4486
|
+
this.id = image.id;
|
|
4471
4487
|
this.handle = image.handle;
|
|
4472
4488
|
this.url = image.url;
|
|
4473
4489
|
this.width = image.width;
|
|
@@ -4477,10 +4493,12 @@ var ImageServer = class {
|
|
|
4477
4493
|
this.camera_make = image.cameraMake;
|
|
4478
4494
|
this.camera = image.cameraModel;
|
|
4479
4495
|
this.filename = image.filename;
|
|
4496
|
+
this.metadata = image.metadata;
|
|
4480
4497
|
}
|
|
4481
4498
|
};
|
|
4482
4499
|
function imageServerToImage(imageServer) {
|
|
4483
4500
|
return {
|
|
4501
|
+
id: imageServer.id,
|
|
4484
4502
|
handle: imageServer.handle,
|
|
4485
4503
|
url: imageServer.url,
|
|
4486
4504
|
width: imageServer.width,
|
|
@@ -4489,7 +4507,8 @@ function imageServerToImage(imageServer) {
|
|
|
4489
4507
|
captureTime: imageServer.taken_at,
|
|
4490
4508
|
cameraMake: imageServer.camera_make,
|
|
4491
4509
|
cameraModel: imageServer.camera,
|
|
4492
|
-
filename: imageServer.filename
|
|
4510
|
+
filename: imageServer.filename,
|
|
4511
|
+
metadata: imageServer.metadata
|
|
4493
4512
|
};
|
|
4494
4513
|
}
|
|
4495
4514
|
|
|
@@ -4690,7 +4709,7 @@ var DesignRequest = class {
|
|
|
4690
4709
|
toBook() {
|
|
4691
4710
|
const designRequest = {
|
|
4692
4711
|
...this,
|
|
4693
|
-
images: this.images
|
|
4712
|
+
images: this.images.list
|
|
4694
4713
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4695
4714
|
};
|
|
4696
4715
|
delete designRequest.client;
|
|
@@ -4913,7 +4932,7 @@ var ImagesEndpoints = class {
|
|
|
4913
4932
|
retrieve(imageId, bookId) {
|
|
4914
4933
|
return handleAsyncFunction(async () => {
|
|
4915
4934
|
const res = await this.engineAPI.fetcher.call({
|
|
4916
|
-
path: `/v1/images/${imageId}/book/${bookId}
|
|
4935
|
+
path: `/v1/images/${imageId}/book/${bookId}`
|
|
4917
4936
|
});
|
|
4918
4937
|
return imageServerSchema.parse(res);
|
|
4919
4938
|
});
|
|
@@ -4921,7 +4940,7 @@ var ImagesEndpoints = class {
|
|
|
4921
4940
|
update(imageId, bookId, image) {
|
|
4922
4941
|
return handleAsyncFunction(async () => {
|
|
4923
4942
|
const res = await this.engineAPI.fetcher.call({
|
|
4924
|
-
path: `/v1/images/${imageId}/book/${bookId}
|
|
4943
|
+
path: `/v1/images/${imageId}/book/${bookId}`,
|
|
4925
4944
|
options: {
|
|
4926
4945
|
method: "PUT",
|
|
4927
4946
|
body: cleanJSON(image)
|
|
@@ -4933,7 +4952,7 @@ var ImagesEndpoints = class {
|
|
|
4933
4952
|
delete(imageId, bookId) {
|
|
4934
4953
|
return handleAsyncFunction(async () => {
|
|
4935
4954
|
await this.engineAPI.fetcher.call({
|
|
4936
|
-
path: `/v1/images/${imageId}/book/${bookId}
|
|
4955
|
+
path: `/v1/images/${imageId}/book/${bookId}`,
|
|
4937
4956
|
options: {
|
|
4938
4957
|
method: "DELETE"
|
|
4939
4958
|
}
|