@gepetto/sdk 0.1.2 → 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.
- package/README.md +20 -2
- package/dist/index.cjs +13 -1
- package/dist/index.d.cts +75 -10
- package/dist/index.d.ts +75 -10
- package/dist/index.js +13 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ CommonJS: `const { Gepetto } = require('@gepetto/sdk');`
|
|
|
46
46
|
|
|
47
47
|
## Tools
|
|
48
48
|
|
|
49
|
-
The `url`
|
|
49
|
+
The `url` of every tool is a public http(s) URL of a JPEG, PNG, WebP or HEIC image: upload the photo to your own storage first. The output URL is public too; copy the image if you keep it.
|
|
50
50
|
|
|
51
51
|
| Method | What it does |
|
|
52
52
|
| --- | --- |
|
|
@@ -63,7 +63,7 @@ The `url` (and `mask`) of every tool is a public http(s) URL of a JPEG, PNG, Web
|
|
|
63
63
|
| `surfaces({ url, surface: 'finish', finishId })` | A finish applied |
|
|
64
64
|
| `upscale({ url, resolution? })` | Enlarged to about 4 (`2k`) or 16 megapixels (`4k`, default) |
|
|
65
65
|
|
|
66
|
-
A mask is a black image with the zone painted in white, drawn on the photo. Output sizes are in the docs (Images and masks).
|
|
66
|
+
A mask is a black image with the zone painted in white, drawn on the photo. Give its URL, or the image itself in base64: the value of `canvas.toDataURL('image/png')` works as is, so there is nothing to host. Output sizes are in the docs (Images and masks).
|
|
67
67
|
|
|
68
68
|
Every tool takes a second argument:
|
|
69
69
|
|
|
@@ -80,6 +80,23 @@ await gepetto.enhance(
|
|
|
80
80
|
|
|
81
81
|
A key always answers the job it first started, whatever the tool and even if that render failed: use one key per photo and per tool, and a new key to try a failed render again.
|
|
82
82
|
|
|
83
|
+
## Videos
|
|
84
|
+
|
|
85
|
+
Two 6-second videos, as MP4. They need a live key (a test key gets `live_key_required`) and take 2 to 10 minutes: the method waits up to 30 minutes, or returns at once with `webhook`.
|
|
86
|
+
|
|
87
|
+
| Method | What it does |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| `cameraMove({ url, camera, timelapse?, resolution? })` | A slow camera move in the photo (`zoom_in`, `zoom_out`, `crane_up`, `crab_left`...), 0.80 € |
|
|
90
|
+
| `transition({ jobId, transitionId })` | From the original of a finished render to its result, 1.60 € |
|
|
91
|
+
| `transition({ url, endUrl, prompt })` | From one photo to another, with your own animation |
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
const staged = await gepetto.furnish({ url, roomId: 'living_room', styleId: 'scandinave' });
|
|
95
|
+
const transitions = await gepetto.listTransitions(); // the animations, with their names
|
|
96
|
+
const video = await gepetto.transition({ jobId: staged.id, transitionId: transitions[0].id });
|
|
97
|
+
console.log(video.output); // https://assets.gepettoapp.com/api/v2/jobs/.../output.mp4
|
|
98
|
+
```
|
|
99
|
+
|
|
83
100
|
## Lists
|
|
84
101
|
|
|
85
102
|
The valid ids, with their names in French, English, Spanish, Portuguese and German:
|
|
@@ -89,6 +106,7 @@ await gepetto.listRooms(); // [{ id: 'living_room', name_en: 'Living room',
|
|
|
89
106
|
await gepetto.listStyles();
|
|
90
107
|
await gepetto.listFurnitures(); // grouped by type: { interior: [...], kitchen: [...], ... }
|
|
91
108
|
await gepetto.listSkies();
|
|
109
|
+
await gepetto.listTransitions(); // for transition
|
|
92
110
|
await gepetto.listSurfaces(); // { walls, floors, finishes }
|
|
93
111
|
```
|
|
94
112
|
|
package/dist/index.cjs
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.Gepetto = exports.GepettoError = exports.VERSION = void 0;
|
|
10
10
|
exports.verifyWebhook = verifyWebhook;
|
|
11
|
-
exports.VERSION = '0.
|
|
11
|
+
exports.VERSION = '0.2.0';
|
|
12
12
|
const DEFAULT_BASE_URL = 'https://europe-west1-gepettoai.cloudfunctions.net/v2';
|
|
13
13
|
/** A render is stopped by the API after 450 s: 10 minutes covers it, retries included. */
|
|
14
14
|
const DEFAULT_TIMEOUT_MS = 10 * 60 * 1000;
|
|
15
|
+
/** A video takes 2 to 10 minutes; the API gives it up after 30. */
|
|
16
|
+
const VIDEO_TIMEOUT_MS = 30 * 60 * 1000;
|
|
15
17
|
const DEFAULT_MAX_RETRIES = 2;
|
|
16
18
|
const POLL_INTERVAL_MS = 2500;
|
|
17
19
|
/**
|
|
@@ -105,6 +107,12 @@ class Gepetto {
|
|
|
105
107
|
upscale(params, options) {
|
|
106
108
|
return this.#render('/upscale', params, options);
|
|
107
109
|
}
|
|
110
|
+
cameraMove(params, options = {}) {
|
|
111
|
+
return this.#render('/video/camera-move', params, { ...options, timeout: options.timeout ?? VIDEO_TIMEOUT_MS });
|
|
112
|
+
}
|
|
113
|
+
transition(params, options = {}) {
|
|
114
|
+
return this.#render('/video/transition', params, { ...options, timeout: options.timeout ?? VIDEO_TIMEOUT_MS });
|
|
115
|
+
}
|
|
108
116
|
// --- Jobs
|
|
109
117
|
/** A job as it is now. */
|
|
110
118
|
async getJob(id, options = {}) {
|
|
@@ -139,6 +147,10 @@ class Gepetto {
|
|
|
139
147
|
listSkies() {
|
|
140
148
|
return this.#get('/skies');
|
|
141
149
|
}
|
|
150
|
+
/** The animations of `transition`, for `transitionId`. */
|
|
151
|
+
listTransitions() {
|
|
152
|
+
return this.#get('/video/transitions');
|
|
153
|
+
}
|
|
142
154
|
/** Wall colours, floors and finishes, for `surfaces`. */
|
|
143
155
|
listSurfaces() {
|
|
144
156
|
return this.#get('/surfaces');
|
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Methods and fields have the names of the API: what the docs say of an endpoint is true of the method.
|
|
6
6
|
*/
|
|
7
|
-
export declare const VERSION = "0.
|
|
7
|
+
export declare const VERSION = "0.2.0";
|
|
8
8
|
/** Rooms of `GET /rooms`. */
|
|
9
9
|
export type KnownRoomId = 'bar' | 'bath_room' | 'bedroom' | 'clothing_store' | 'coworking_space' | 'dining_room' | 'dressing' | 'gaming_room' | 'hall' | 'home_office' | 'kitchen' | 'kitchen_living' | 'living_dining' | 'living_room' | 'meeting_room' | 'office' | 'optician' | 'osteopathy_clinic' | 'outdoor_garden' | 'outdoor_piscine' | 'outdoor_snowy_garden' | 'outdoor_terrace' | 'psychologist_office' | 'restaurant' | 'salle_de_sport' | 'shoe_store' | 'teenager_bedroom' | 'toilet';
|
|
10
10
|
/** Rooms that can be furnished whole, without a mask (mode `auto`). */
|
|
@@ -32,7 +32,7 @@ export type SkyId = OrString<KnownSkyId>;
|
|
|
32
32
|
export type WallTypeId = OrString<KnownWallTypeId>;
|
|
33
33
|
export type FloorTypeId = OrString<KnownFloorTypeId>;
|
|
34
34
|
export type FinishId = OrString<KnownFinishId>;
|
|
35
|
-
export type Tool = 'declutter' | 'furnish' | 'sunshine' | 'creative-redesign' | 'surfaces' | 'enhance' | 'upscale';
|
|
35
|
+
export type Tool = 'declutter' | 'furnish' | 'sunshine' | 'creative-redesign' | 'surfaces' | 'enhance' | 'upscale' | 'camera-move' | 'transition';
|
|
36
36
|
export type JobStatus = 'pending' | 'processing' | 'success' | 'error';
|
|
37
37
|
/** A render, as the API returns it (synchronous answer, `GET /job/{id}`, webhook body). */
|
|
38
38
|
export interface Job {
|
|
@@ -40,9 +40,11 @@ export interface Job {
|
|
|
40
40
|
status: JobStatus;
|
|
41
41
|
tool: Tool;
|
|
42
42
|
/** declutter and furnish: `auto` or `zone`; sunshine: the sky id; surfaces: `walls`, `floor` or `finish`;
|
|
43
|
-
* enhance: `straighten` or null; upscale: `2k` or `4k`; creative-redesign: null
|
|
43
|
+
* enhance: `straighten` or null; upscale: `2k` or `4k`; creative-redesign: null; camera-move: the camera;
|
|
44
|
+
* transition: the transitionId, or `custom`. */
|
|
44
45
|
mode: string | null;
|
|
45
|
-
/** The image, once `status` is `success`. Public URL: copy it to
|
|
46
|
+
/** The image (an MP4 video for camera-move and transition), once `status` is `success`. Public URL: copy it to
|
|
47
|
+
* your storage if you keep it. */
|
|
46
48
|
output: string | null;
|
|
47
49
|
error: {
|
|
48
50
|
code: string;
|
|
@@ -62,6 +64,9 @@ export interface CompletedJob extends Job {
|
|
|
62
64
|
}
|
|
63
65
|
/** A public http(s) URL of a JPEG, PNG, WebP or HEIC image (100 megapixels at most). */
|
|
64
66
|
export type ImageUrl = string | URL;
|
|
67
|
+
/** A black image with the zone painted in white, drawn on the photo: a public URL, or the image itself in base64 as
|
|
68
|
+
* a data URL, such as `canvas.toDataURL('image/png')` gives (5 MB at most; a black and white PNG weighs a few KB). */
|
|
69
|
+
export type MaskImage = string | URL;
|
|
65
70
|
interface Common {
|
|
66
71
|
/** The photo: a public http(s) URL. */
|
|
67
72
|
url: ImageUrl;
|
|
@@ -76,8 +81,8 @@ export type DeclutterParams = Common & ({
|
|
|
76
81
|
keepBathroom?: boolean;
|
|
77
82
|
keepFireplace?: boolean;
|
|
78
83
|
} | {
|
|
79
|
-
/**
|
|
80
|
-
mask:
|
|
84
|
+
/** The zone to remove, painted in white on black: a URL, or base64 (`canvas.toDataURL('image/png')`). */
|
|
85
|
+
mask: MaskImage;
|
|
81
86
|
});
|
|
82
87
|
export type FurnishParams = Common & ({
|
|
83
88
|
/** Without a mask, the whole room is furnished: the room must have the `auto` mode in `GET /rooms`. */
|
|
@@ -85,14 +90,15 @@ export type FurnishParams = Common & ({
|
|
|
85
90
|
roomId: OrString<KnownAutoRoomId>;
|
|
86
91
|
styleId: StyleId;
|
|
87
92
|
} | {
|
|
88
|
-
/**
|
|
89
|
-
mask:
|
|
93
|
+
/** The zone to furnish, painted in white on black: a URL, or base64 (`canvas.toDataURL('image/png')`). */
|
|
94
|
+
mask: MaskImage;
|
|
90
95
|
/** The zone furnished as a room (mode `zone` in `GET /rooms`). */
|
|
91
96
|
roomId: OrString<KnownZoneRoomId>;
|
|
92
97
|
styleId: StyleId;
|
|
93
98
|
furnitureId?: undefined;
|
|
94
99
|
} | {
|
|
95
|
-
|
|
100
|
+
/** The zone to furnish, painted in white on black: a URL, or base64 (`canvas.toDataURL('image/png')`). */
|
|
101
|
+
mask: MaskImage;
|
|
96
102
|
/** One piece of furniture in the zone, instead of a room. */
|
|
97
103
|
furnitureId: FurnitureId;
|
|
98
104
|
styleId?: StyleId;
|
|
@@ -138,6 +144,47 @@ export interface UpscaleParams extends Common {
|
|
|
138
144
|
/** About 4 megapixels (`2k`) or 16 megapixels (`4k`, the default). */
|
|
139
145
|
resolution?: '2k' | '4k';
|
|
140
146
|
}
|
|
147
|
+
/** The camera moves of `cameraMove`. */
|
|
148
|
+
export type CameraMove = 'zoom_in' | 'zoom_out' | 'zoom_in_pan_left' | 'zoom_in_pan_right' | 'crane_up' | 'crane_down' | 'crab_left' | 'crab_right';
|
|
149
|
+
export interface CameraMoveParams extends Common {
|
|
150
|
+
camera: CameraMove;
|
|
151
|
+
/** The hours of the day passing, with the lights turning on, ending at night. */
|
|
152
|
+
timelapse?: boolean;
|
|
153
|
+
/** `1080p` by default. */
|
|
154
|
+
resolution?: '768p' | '1080p';
|
|
155
|
+
}
|
|
156
|
+
/** The two images of a transition: a finished job of your account, or two URLs of the same proportions. */
|
|
157
|
+
type TransitionImages = {
|
|
158
|
+
/** A finished image job: its original goes to its result. */
|
|
159
|
+
jobId: string;
|
|
160
|
+
url?: undefined;
|
|
161
|
+
endUrl?: undefined;
|
|
162
|
+
} | {
|
|
163
|
+
/** The photo before. */
|
|
164
|
+
url: ImageUrl;
|
|
165
|
+
/** The photo after, same proportions. */
|
|
166
|
+
endUrl: ImageUrl;
|
|
167
|
+
jobId?: undefined;
|
|
168
|
+
};
|
|
169
|
+
/** The animation: one of `listTransitions()`, or your own prompt. */
|
|
170
|
+
type TransitionAnimation = {
|
|
171
|
+
transitionId: string;
|
|
172
|
+
prompt?: undefined;
|
|
173
|
+
negativePrompt?: undefined;
|
|
174
|
+
} | {
|
|
175
|
+
/** Your own animation, in English (2000 characters at most), sent as it is. */
|
|
176
|
+
prompt: string;
|
|
177
|
+
/** What the video must avoid. */
|
|
178
|
+
negativePrompt?: string;
|
|
179
|
+
transitionId?: undefined;
|
|
180
|
+
};
|
|
181
|
+
export type TransitionParams = TransitionImages & TransitionAnimation & {
|
|
182
|
+
webhook?: string | URL;
|
|
183
|
+
};
|
|
184
|
+
export interface Transition extends NamedItem {
|
|
185
|
+
/** A sample video, when there is one. */
|
|
186
|
+
preview: string | null;
|
|
187
|
+
}
|
|
141
188
|
/** Options of one call. */
|
|
142
189
|
export interface RequestOptions {
|
|
143
190
|
/** Any unique string (your photo id, for example): the same key never starts, nor bills, a second render. One is
|
|
@@ -220,7 +267,7 @@ export interface Usage {
|
|
|
220
267
|
}
|
|
221
268
|
/** Codes of the API (docs: Errors), plus those of the SDK itself: `connection_error`, `timeout`, `aborted`,
|
|
222
269
|
* `invalid_response`, `invalid_signature`. */
|
|
223
|
-
export type ErrorCode = OrString<'missing_parameter' | 'invalid_parameter' | 'invalid_url' | 'private_url' | 'image_unreachable' | 'unsupported_image' | 'image_too_large' | 'mask_size_mismatch' | 'empty_mask' | 'unknown_room' | 'mode_not_available' | 'unknown_style' | 'unknown_furniture' | 'unknown_sky' | 'unknown_wall_type' | 'unknown_floor_type' | 'unknown_finish' | 'missing_api_key' | 'invalid_api_key' | 'api_key_inactive' | 'test_limit_reached' | 'api_v2_subscription_required' | 'job_not_found' | 'not_found' | 'account_not_found' | 'already_subscribed' | 'api_v1_subscription_active' | 'rate_limited' | 'internal_error' | 'render_failed' | 'render_timeout' | 'connection_error' | 'timeout' | 'aborted' | 'invalid_response' | 'invalid_signature'>;
|
|
270
|
+
export type ErrorCode = OrString<'missing_parameter' | 'invalid_parameter' | 'invalid_url' | 'private_url' | 'image_unreachable' | 'unsupported_image' | 'image_too_large' | 'mask_size_mismatch' | 'empty_mask' | 'unknown_room' | 'mode_not_available' | 'unknown_style' | 'unknown_furniture' | 'unknown_sky' | 'unknown_wall_type' | 'unknown_floor_type' | 'unknown_finish' | 'missing_api_key' | 'invalid_api_key' | 'api_key_inactive' | 'test_limit_reached' | 'live_key_required' | 'unknown_camera' | 'unknown_transition' | 'images_mismatch' | 'api_v2_subscription_required' | 'job_not_found' | 'not_found' | 'account_not_found' | 'already_subscribed' | 'api_v1_subscription_active' | 'rate_limited' | 'internal_error' | 'render_failed' | 'render_timeout' | 'connection_error' | 'timeout' | 'aborted' | 'invalid_response' | 'invalid_signature'>;
|
|
224
271
|
/**
|
|
225
272
|
* Every failure: an invalid request, a failed render (not charged), a network problem. `message` says what to do
|
|
226
273
|
* next; `code` is stable, for your code.
|
|
@@ -328,6 +375,22 @@ export declare class Gepetto {
|
|
|
328
375
|
webhook?: undefined;
|
|
329
376
|
}, options?: RequestOptions): Promise<CompletedJob>;
|
|
330
377
|
upscale(params: UpscaleParams, options?: RequestOptions): Promise<Job>;
|
|
378
|
+
/** A slow camera move in the photo. 0.80 € per video. */
|
|
379
|
+
cameraMove(params: CameraMoveParams & {
|
|
380
|
+
webhook: string | URL;
|
|
381
|
+
}, options?: RequestOptions): Promise<Job>;
|
|
382
|
+
cameraMove(params: CameraMoveParams & {
|
|
383
|
+
webhook?: undefined;
|
|
384
|
+
}, options?: RequestOptions): Promise<CompletedJob>;
|
|
385
|
+
cameraMove(params: CameraMoveParams, options?: RequestOptions): Promise<Job>;
|
|
386
|
+
/** From a photo to its edited version: `jobId` of a finished render, or `url` and `endUrl`. 1.60 € per video. */
|
|
387
|
+
transition(params: TransitionParams & {
|
|
388
|
+
webhook: string | URL;
|
|
389
|
+
}, options?: RequestOptions): Promise<Job>;
|
|
390
|
+
transition(params: TransitionParams & {
|
|
391
|
+
webhook?: undefined;
|
|
392
|
+
}, options?: RequestOptions): Promise<CompletedJob>;
|
|
393
|
+
transition(params: TransitionParams, options?: RequestOptions): Promise<Job>;
|
|
331
394
|
/** A job as it is now. */
|
|
332
395
|
getJob(id: string, options?: {
|
|
333
396
|
signal?: AbortSignal;
|
|
@@ -343,6 +406,8 @@ export declare class Gepetto {
|
|
|
343
406
|
listStyles(): Promise<Style[]>;
|
|
344
407
|
listFurnitures(): Promise<FurnitureCatalog>;
|
|
345
408
|
listSkies(): Promise<NamedItem[]>;
|
|
409
|
+
/** The animations of `transition`, for `transitionId`. */
|
|
410
|
+
listTransitions(): Promise<Transition[]>;
|
|
346
411
|
/** Wall colours, floors and finishes, for `surfaces`. */
|
|
347
412
|
listSurfaces(): Promise<SurfaceOptions>;
|
|
348
413
|
/** The account of the key, its test renders, the subscription, and the webhook secret of this key type. */
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Methods and fields have the names of the API: what the docs say of an endpoint is true of the method.
|
|
6
6
|
*/
|
|
7
|
-
export declare const VERSION = "0.
|
|
7
|
+
export declare const VERSION = "0.2.0";
|
|
8
8
|
/** Rooms of `GET /rooms`. */
|
|
9
9
|
export type KnownRoomId = 'bar' | 'bath_room' | 'bedroom' | 'clothing_store' | 'coworking_space' | 'dining_room' | 'dressing' | 'gaming_room' | 'hall' | 'home_office' | 'kitchen' | 'kitchen_living' | 'living_dining' | 'living_room' | 'meeting_room' | 'office' | 'optician' | 'osteopathy_clinic' | 'outdoor_garden' | 'outdoor_piscine' | 'outdoor_snowy_garden' | 'outdoor_terrace' | 'psychologist_office' | 'restaurant' | 'salle_de_sport' | 'shoe_store' | 'teenager_bedroom' | 'toilet';
|
|
10
10
|
/** Rooms that can be furnished whole, without a mask (mode `auto`). */
|
|
@@ -32,7 +32,7 @@ export type SkyId = OrString<KnownSkyId>;
|
|
|
32
32
|
export type WallTypeId = OrString<KnownWallTypeId>;
|
|
33
33
|
export type FloorTypeId = OrString<KnownFloorTypeId>;
|
|
34
34
|
export type FinishId = OrString<KnownFinishId>;
|
|
35
|
-
export type Tool = 'declutter' | 'furnish' | 'sunshine' | 'creative-redesign' | 'surfaces' | 'enhance' | 'upscale';
|
|
35
|
+
export type Tool = 'declutter' | 'furnish' | 'sunshine' | 'creative-redesign' | 'surfaces' | 'enhance' | 'upscale' | 'camera-move' | 'transition';
|
|
36
36
|
export type JobStatus = 'pending' | 'processing' | 'success' | 'error';
|
|
37
37
|
/** A render, as the API returns it (synchronous answer, `GET /job/{id}`, webhook body). */
|
|
38
38
|
export interface Job {
|
|
@@ -40,9 +40,11 @@ export interface Job {
|
|
|
40
40
|
status: JobStatus;
|
|
41
41
|
tool: Tool;
|
|
42
42
|
/** declutter and furnish: `auto` or `zone`; sunshine: the sky id; surfaces: `walls`, `floor` or `finish`;
|
|
43
|
-
* enhance: `straighten` or null; upscale: `2k` or `4k`; creative-redesign: null
|
|
43
|
+
* enhance: `straighten` or null; upscale: `2k` or `4k`; creative-redesign: null; camera-move: the camera;
|
|
44
|
+
* transition: the transitionId, or `custom`. */
|
|
44
45
|
mode: string | null;
|
|
45
|
-
/** The image, once `status` is `success`. Public URL: copy it to
|
|
46
|
+
/** The image (an MP4 video for camera-move and transition), once `status` is `success`. Public URL: copy it to
|
|
47
|
+
* your storage if you keep it. */
|
|
46
48
|
output: string | null;
|
|
47
49
|
error: {
|
|
48
50
|
code: string;
|
|
@@ -62,6 +64,9 @@ export interface CompletedJob extends Job {
|
|
|
62
64
|
}
|
|
63
65
|
/** A public http(s) URL of a JPEG, PNG, WebP or HEIC image (100 megapixels at most). */
|
|
64
66
|
export type ImageUrl = string | URL;
|
|
67
|
+
/** A black image with the zone painted in white, drawn on the photo: a public URL, or the image itself in base64 as
|
|
68
|
+
* a data URL, such as `canvas.toDataURL('image/png')` gives (5 MB at most; a black and white PNG weighs a few KB). */
|
|
69
|
+
export type MaskImage = string | URL;
|
|
65
70
|
interface Common {
|
|
66
71
|
/** The photo: a public http(s) URL. */
|
|
67
72
|
url: ImageUrl;
|
|
@@ -76,8 +81,8 @@ export type DeclutterParams = Common & ({
|
|
|
76
81
|
keepBathroom?: boolean;
|
|
77
82
|
keepFireplace?: boolean;
|
|
78
83
|
} | {
|
|
79
|
-
/**
|
|
80
|
-
mask:
|
|
84
|
+
/** The zone to remove, painted in white on black: a URL, or base64 (`canvas.toDataURL('image/png')`). */
|
|
85
|
+
mask: MaskImage;
|
|
81
86
|
});
|
|
82
87
|
export type FurnishParams = Common & ({
|
|
83
88
|
/** Without a mask, the whole room is furnished: the room must have the `auto` mode in `GET /rooms`. */
|
|
@@ -85,14 +90,15 @@ export type FurnishParams = Common & ({
|
|
|
85
90
|
roomId: OrString<KnownAutoRoomId>;
|
|
86
91
|
styleId: StyleId;
|
|
87
92
|
} | {
|
|
88
|
-
/**
|
|
89
|
-
mask:
|
|
93
|
+
/** The zone to furnish, painted in white on black: a URL, or base64 (`canvas.toDataURL('image/png')`). */
|
|
94
|
+
mask: MaskImage;
|
|
90
95
|
/** The zone furnished as a room (mode `zone` in `GET /rooms`). */
|
|
91
96
|
roomId: OrString<KnownZoneRoomId>;
|
|
92
97
|
styleId: StyleId;
|
|
93
98
|
furnitureId?: undefined;
|
|
94
99
|
} | {
|
|
95
|
-
|
|
100
|
+
/** The zone to furnish, painted in white on black: a URL, or base64 (`canvas.toDataURL('image/png')`). */
|
|
101
|
+
mask: MaskImage;
|
|
96
102
|
/** One piece of furniture in the zone, instead of a room. */
|
|
97
103
|
furnitureId: FurnitureId;
|
|
98
104
|
styleId?: StyleId;
|
|
@@ -138,6 +144,47 @@ export interface UpscaleParams extends Common {
|
|
|
138
144
|
/** About 4 megapixels (`2k`) or 16 megapixels (`4k`, the default). */
|
|
139
145
|
resolution?: '2k' | '4k';
|
|
140
146
|
}
|
|
147
|
+
/** The camera moves of `cameraMove`. */
|
|
148
|
+
export type CameraMove = 'zoom_in' | 'zoom_out' | 'zoom_in_pan_left' | 'zoom_in_pan_right' | 'crane_up' | 'crane_down' | 'crab_left' | 'crab_right';
|
|
149
|
+
export interface CameraMoveParams extends Common {
|
|
150
|
+
camera: CameraMove;
|
|
151
|
+
/** The hours of the day passing, with the lights turning on, ending at night. */
|
|
152
|
+
timelapse?: boolean;
|
|
153
|
+
/** `1080p` by default. */
|
|
154
|
+
resolution?: '768p' | '1080p';
|
|
155
|
+
}
|
|
156
|
+
/** The two images of a transition: a finished job of your account, or two URLs of the same proportions. */
|
|
157
|
+
type TransitionImages = {
|
|
158
|
+
/** A finished image job: its original goes to its result. */
|
|
159
|
+
jobId: string;
|
|
160
|
+
url?: undefined;
|
|
161
|
+
endUrl?: undefined;
|
|
162
|
+
} | {
|
|
163
|
+
/** The photo before. */
|
|
164
|
+
url: ImageUrl;
|
|
165
|
+
/** The photo after, same proportions. */
|
|
166
|
+
endUrl: ImageUrl;
|
|
167
|
+
jobId?: undefined;
|
|
168
|
+
};
|
|
169
|
+
/** The animation: one of `listTransitions()`, or your own prompt. */
|
|
170
|
+
type TransitionAnimation = {
|
|
171
|
+
transitionId: string;
|
|
172
|
+
prompt?: undefined;
|
|
173
|
+
negativePrompt?: undefined;
|
|
174
|
+
} | {
|
|
175
|
+
/** Your own animation, in English (2000 characters at most), sent as it is. */
|
|
176
|
+
prompt: string;
|
|
177
|
+
/** What the video must avoid. */
|
|
178
|
+
negativePrompt?: string;
|
|
179
|
+
transitionId?: undefined;
|
|
180
|
+
};
|
|
181
|
+
export type TransitionParams = TransitionImages & TransitionAnimation & {
|
|
182
|
+
webhook?: string | URL;
|
|
183
|
+
};
|
|
184
|
+
export interface Transition extends NamedItem {
|
|
185
|
+
/** A sample video, when there is one. */
|
|
186
|
+
preview: string | null;
|
|
187
|
+
}
|
|
141
188
|
/** Options of one call. */
|
|
142
189
|
export interface RequestOptions {
|
|
143
190
|
/** Any unique string (your photo id, for example): the same key never starts, nor bills, a second render. One is
|
|
@@ -220,7 +267,7 @@ export interface Usage {
|
|
|
220
267
|
}
|
|
221
268
|
/** Codes of the API (docs: Errors), plus those of the SDK itself: `connection_error`, `timeout`, `aborted`,
|
|
222
269
|
* `invalid_response`, `invalid_signature`. */
|
|
223
|
-
export type ErrorCode = OrString<'missing_parameter' | 'invalid_parameter' | 'invalid_url' | 'private_url' | 'image_unreachable' | 'unsupported_image' | 'image_too_large' | 'mask_size_mismatch' | 'empty_mask' | 'unknown_room' | 'mode_not_available' | 'unknown_style' | 'unknown_furniture' | 'unknown_sky' | 'unknown_wall_type' | 'unknown_floor_type' | 'unknown_finish' | 'missing_api_key' | 'invalid_api_key' | 'api_key_inactive' | 'test_limit_reached' | 'api_v2_subscription_required' | 'job_not_found' | 'not_found' | 'account_not_found' | 'already_subscribed' | 'api_v1_subscription_active' | 'rate_limited' | 'internal_error' | 'render_failed' | 'render_timeout' | 'connection_error' | 'timeout' | 'aborted' | 'invalid_response' | 'invalid_signature'>;
|
|
270
|
+
export type ErrorCode = OrString<'missing_parameter' | 'invalid_parameter' | 'invalid_url' | 'private_url' | 'image_unreachable' | 'unsupported_image' | 'image_too_large' | 'mask_size_mismatch' | 'empty_mask' | 'unknown_room' | 'mode_not_available' | 'unknown_style' | 'unknown_furniture' | 'unknown_sky' | 'unknown_wall_type' | 'unknown_floor_type' | 'unknown_finish' | 'missing_api_key' | 'invalid_api_key' | 'api_key_inactive' | 'test_limit_reached' | 'live_key_required' | 'unknown_camera' | 'unknown_transition' | 'images_mismatch' | 'api_v2_subscription_required' | 'job_not_found' | 'not_found' | 'account_not_found' | 'already_subscribed' | 'api_v1_subscription_active' | 'rate_limited' | 'internal_error' | 'render_failed' | 'render_timeout' | 'connection_error' | 'timeout' | 'aborted' | 'invalid_response' | 'invalid_signature'>;
|
|
224
271
|
/**
|
|
225
272
|
* Every failure: an invalid request, a failed render (not charged), a network problem. `message` says what to do
|
|
226
273
|
* next; `code` is stable, for your code.
|
|
@@ -328,6 +375,22 @@ export declare class Gepetto {
|
|
|
328
375
|
webhook?: undefined;
|
|
329
376
|
}, options?: RequestOptions): Promise<CompletedJob>;
|
|
330
377
|
upscale(params: UpscaleParams, options?: RequestOptions): Promise<Job>;
|
|
378
|
+
/** A slow camera move in the photo. 0.80 € per video. */
|
|
379
|
+
cameraMove(params: CameraMoveParams & {
|
|
380
|
+
webhook: string | URL;
|
|
381
|
+
}, options?: RequestOptions): Promise<Job>;
|
|
382
|
+
cameraMove(params: CameraMoveParams & {
|
|
383
|
+
webhook?: undefined;
|
|
384
|
+
}, options?: RequestOptions): Promise<CompletedJob>;
|
|
385
|
+
cameraMove(params: CameraMoveParams, options?: RequestOptions): Promise<Job>;
|
|
386
|
+
/** From a photo to its edited version: `jobId` of a finished render, or `url` and `endUrl`. 1.60 € per video. */
|
|
387
|
+
transition(params: TransitionParams & {
|
|
388
|
+
webhook: string | URL;
|
|
389
|
+
}, options?: RequestOptions): Promise<Job>;
|
|
390
|
+
transition(params: TransitionParams & {
|
|
391
|
+
webhook?: undefined;
|
|
392
|
+
}, options?: RequestOptions): Promise<CompletedJob>;
|
|
393
|
+
transition(params: TransitionParams, options?: RequestOptions): Promise<Job>;
|
|
331
394
|
/** A job as it is now. */
|
|
332
395
|
getJob(id: string, options?: {
|
|
333
396
|
signal?: AbortSignal;
|
|
@@ -343,6 +406,8 @@ export declare class Gepetto {
|
|
|
343
406
|
listStyles(): Promise<Style[]>;
|
|
344
407
|
listFurnitures(): Promise<FurnitureCatalog>;
|
|
345
408
|
listSkies(): Promise<NamedItem[]>;
|
|
409
|
+
/** The animations of `transition`, for `transitionId`. */
|
|
410
|
+
listTransitions(): Promise<Transition[]>;
|
|
346
411
|
/** Wall colours, floors and finishes, for `surfaces`. */
|
|
347
412
|
listSurfaces(): Promise<SurfaceOptions>;
|
|
348
413
|
/** The account of the key, its test renders, the subscription, and the webhook secret of this key type. */
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Methods and fields have the names of the API: what the docs say of an endpoint is true of the method.
|
|
6
6
|
*/
|
|
7
|
-
export const VERSION = '0.
|
|
7
|
+
export const VERSION = '0.2.0';
|
|
8
8
|
const DEFAULT_BASE_URL = 'https://europe-west1-gepettoai.cloudfunctions.net/v2';
|
|
9
9
|
/** A render is stopped by the API after 450 s: 10 minutes covers it, retries included. */
|
|
10
10
|
const DEFAULT_TIMEOUT_MS = 10 * 60 * 1000;
|
|
11
|
+
/** A video takes 2 to 10 minutes; the API gives it up after 30. */
|
|
12
|
+
const VIDEO_TIMEOUT_MS = 30 * 60 * 1000;
|
|
11
13
|
const DEFAULT_MAX_RETRIES = 2;
|
|
12
14
|
const POLL_INTERVAL_MS = 2500;
|
|
13
15
|
/**
|
|
@@ -100,6 +102,12 @@ export class Gepetto {
|
|
|
100
102
|
upscale(params, options) {
|
|
101
103
|
return this.#render('/upscale', params, options);
|
|
102
104
|
}
|
|
105
|
+
cameraMove(params, options = {}) {
|
|
106
|
+
return this.#render('/video/camera-move', params, { ...options, timeout: options.timeout ?? VIDEO_TIMEOUT_MS });
|
|
107
|
+
}
|
|
108
|
+
transition(params, options = {}) {
|
|
109
|
+
return this.#render('/video/transition', params, { ...options, timeout: options.timeout ?? VIDEO_TIMEOUT_MS });
|
|
110
|
+
}
|
|
103
111
|
// --- Jobs
|
|
104
112
|
/** A job as it is now. */
|
|
105
113
|
async getJob(id, options = {}) {
|
|
@@ -134,6 +142,10 @@ export class Gepetto {
|
|
|
134
142
|
listSkies() {
|
|
135
143
|
return this.#get('/skies');
|
|
136
144
|
}
|
|
145
|
+
/** The animations of `transition`, for `transitionId`. */
|
|
146
|
+
listTransitions() {
|
|
147
|
+
return this.#get('/video/transitions');
|
|
148
|
+
}
|
|
137
149
|
/** Wall colours, floors and finishes, for `surfaces`. */
|
|
138
150
|
listSurfaces() {
|
|
139
151
|
return this.#get('/surfaces');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gepetto/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Official TypeScript / JavaScript SDK of the Gepetto API v2: real estate photo editing (enhance, declutter, furnish, sky, restyle, walls and floors, upscale).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|