@gepetto/sdk 0.0.0-stage → 0.1.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 +170 -2
- package/dist/index.cjs +385 -0
- package/dist/index.d.cts +383 -0
- package/dist/index.d.ts +383 -0
- package/dist/index.js +379 -0
- package/package.json +50 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official TypeScript / JavaScript SDK of the Gepetto API v2: real estate photo editing.
|
|
3
|
+
* Docs: https://docs.gepettoapp.com
|
|
4
|
+
*
|
|
5
|
+
* Methods and fields have the names of the API: what the docs say of an endpoint is true of the method.
|
|
6
|
+
*/
|
|
7
|
+
export declare const VERSION = "0.1.0";
|
|
8
|
+
/** Rooms of `GET /rooms`. */
|
|
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
|
+
/** Rooms that can be furnished whole, without a mask (mode `auto`). */
|
|
11
|
+
export type KnownAutoRoomId = 'bar' | 'bath_room' | 'bedroom' | 'clothing_store' | 'coworking_space' | 'dining_room' | 'dressing' | 'home_office' | 'kitchen' | 'kitchen_living' | 'living_dining' | 'living_room' | 'meeting_room' | 'office' | 'optician' | 'osteopathy_clinic' | 'outdoor_terrace' | 'psychologist_office' | 'restaurant' | 'salle_de_sport' | 'shoe_store' | 'teenager_bedroom';
|
|
12
|
+
/** Rooms that can furnish the zone of a mask (mode `zone`). */
|
|
13
|
+
export type KnownZoneRoomId = 'bar' | 'bath_room' | 'bedroom' | 'clothing_store' | 'coworking_space' | 'dining_room' | 'dressing' | 'gaming_room' | 'hall' | 'home_office' | 'kitchen' | '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';
|
|
14
|
+
/** Styles of `GET /styles`. */
|
|
15
|
+
export type KnownStyleId = 'art_deco' | 'bali' | 'baroco' | 'bauhaus' | 'boheme' | 'bord_de_mer' | 'californien' | 'cap_ferret' | 'chamonix' | 'classique' | 'colonial' | 'contemporain' | 'copenhagen' | 'cyberpunk' | 'demeures' | 'ethnic' | 'hampton' | 'haussmann' | 'hippie_chic' | 'industriel' | 'japon' | 'kid' | 'miami' | 'milan_design' | 'minimalist' | 'modern' | 'normandie' | 'orientaliste' | 'oxford' | 'perigord' | 'provence' | 'retro' | 'rococo' | 'scandinave' | 'tropicalist';
|
|
16
|
+
/** Pieces of furniture of `GET /furnitures`. */
|
|
17
|
+
export type KnownFurnitureId = 'armchair' | 'audio_system' | 'baby_crib' | 'bar_stools' | 'bathroom_cabiner_regular' | 'bathroom_cabinet' | 'bathtub' | 'bed' | 'bookshelf' | 'builtin_bathtub' | 'closet' | 'coffee_table' | 'console_table' | 'couch' | 'countertop' | 'curtains' | 'dining_table' | 'dresser' | 'flowers' | 'fridge' | 'garden_furniture' | 'grass' | 'gravel_path' | 'hanging_light' | 'house' | 'jacuzzi' | 'kitchen_cabinets' | 'kitchen_hood' | 'kitchen_island' | 'lounge_chair' | 'miror' | 'nightstand' | 'oven' | 'painting' | 'paved_way' | 'plant_bed' | 'plant_hedge' | 'pool' | 'potted_plant' | 'pouf' | 'round_dining_table' | 'rug' | 'shelves' | 'shower_cubible' | 'single_bed' | 'television' | 'television_alone' | 'toilet' | 'towel_racks' | 'wooden_terrace';
|
|
18
|
+
/** Skies of `GET /skies`. */
|
|
19
|
+
export type KnownSkyId = 'sunny' | 'sunrise' | 'sunset' | 'sunset_night' | 'sunset_rose' | 'sunset_twilight' | 'very_sunny';
|
|
20
|
+
/** Wall colours of `GET /surfaces` (`custom` takes `customWallColor`). */
|
|
21
|
+
export type KnownWallTypeId = 'blue_navy' | 'custom' | 'dark_gray' | 'egg_shell' | 'gray_silver' | 'nude' | 'olive' | 'stone_facade_restoration' | 'terracotta' | 'white';
|
|
22
|
+
/** Floors of `GET /surfaces`. */
|
|
23
|
+
export type KnownFloorTypeId = 'carpet' | 'concrete' | 'gray_hardwood' | 'hardwood' | 'hardwood_light' | 'marble' | 'mosaic' | 'parquet' | 'stone_terrace' | 'terrazzo' | 'tile' | 'tomette' | 'travertine' | 'wooden_terrace';
|
|
24
|
+
/** Finishes of `GET /surfaces`. */
|
|
25
|
+
export type KnownFinishId = 'clean_floor' | 'clean_pool' | 'lawn_mowed' | 'lawn_mowed_summer' | 'stone_facade_restoration';
|
|
26
|
+
/** A known id, suggested by the editor, or any other string (ids added on the server work at once). */
|
|
27
|
+
export type OrString<T extends string> = T | (string & {});
|
|
28
|
+
export type RoomId = OrString<KnownRoomId>;
|
|
29
|
+
export type StyleId = OrString<KnownStyleId>;
|
|
30
|
+
export type FurnitureId = OrString<KnownFurnitureId>;
|
|
31
|
+
export type SkyId = OrString<KnownSkyId>;
|
|
32
|
+
export type WallTypeId = OrString<KnownWallTypeId>;
|
|
33
|
+
export type FloorTypeId = OrString<KnownFloorTypeId>;
|
|
34
|
+
export type FinishId = OrString<KnownFinishId>;
|
|
35
|
+
export type Tool = 'declutter' | 'furnish' | 'sunshine' | 'creative-redesign' | 'surfaces' | 'enhance' | 'upscale';
|
|
36
|
+
export type JobStatus = 'pending' | 'processing' | 'success' | 'error';
|
|
37
|
+
/** A render, as the API returns it (synchronous answer, `GET /job/{id}`, webhook body). */
|
|
38
|
+
export interface Job {
|
|
39
|
+
id: string;
|
|
40
|
+
status: JobStatus;
|
|
41
|
+
tool: Tool;
|
|
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. */
|
|
44
|
+
mode: string | null;
|
|
45
|
+
/** The image, once `status` is `success`. Public URL: copy it to your storage if you keep it. */
|
|
46
|
+
output: string | null;
|
|
47
|
+
error: {
|
|
48
|
+
code: string;
|
|
49
|
+
message: string;
|
|
50
|
+
} | null;
|
|
51
|
+
/** Price in euro cents (0 with a test key; charged only on success). */
|
|
52
|
+
priceCents: number;
|
|
53
|
+
test: boolean;
|
|
54
|
+
createdAt: string | null;
|
|
55
|
+
finishedAt: string | null;
|
|
56
|
+
}
|
|
57
|
+
/** A finished render: `output` is the URL of the image. */
|
|
58
|
+
export interface CompletedJob extends Job {
|
|
59
|
+
status: 'success';
|
|
60
|
+
output: string;
|
|
61
|
+
error: null;
|
|
62
|
+
}
|
|
63
|
+
/** A public http(s) URL of a JPEG, PNG, WebP or HEIC image (100 megapixels at most). */
|
|
64
|
+
export type ImageUrl = string | URL;
|
|
65
|
+
interface Common {
|
|
66
|
+
/** The photo: a public http(s) URL. */
|
|
67
|
+
url: ImageUrl;
|
|
68
|
+
/** A public URL that receives the finished job as a POST (signed: see `verifyWebhook`). With it, the method
|
|
69
|
+
* returns at once with the job in `pending` instead of waiting for the image. */
|
|
70
|
+
webhook?: string | URL;
|
|
71
|
+
}
|
|
72
|
+
export type DeclutterParams = Common & ({
|
|
73
|
+
/** Without a mask, the whole room is emptied. */
|
|
74
|
+
mask?: undefined;
|
|
75
|
+
keepKitchen?: boolean;
|
|
76
|
+
keepBathroom?: boolean;
|
|
77
|
+
keepFireplace?: boolean;
|
|
78
|
+
} | {
|
|
79
|
+
/** A black image with the zone to remove painted in white, drawn on the photo. */
|
|
80
|
+
mask: ImageUrl;
|
|
81
|
+
});
|
|
82
|
+
export type FurnishParams = Common & ({
|
|
83
|
+
/** Without a mask, the whole room is furnished: the room must have the `auto` mode in `GET /rooms`. */
|
|
84
|
+
mask?: undefined;
|
|
85
|
+
roomId: OrString<KnownAutoRoomId>;
|
|
86
|
+
styleId: StyleId;
|
|
87
|
+
} | {
|
|
88
|
+
/** A black image with the zone to furnish painted in white, drawn on the photo. */
|
|
89
|
+
mask: ImageUrl;
|
|
90
|
+
/** The zone furnished as a room (mode `zone` in `GET /rooms`). */
|
|
91
|
+
roomId: OrString<KnownZoneRoomId>;
|
|
92
|
+
styleId: StyleId;
|
|
93
|
+
furnitureId?: undefined;
|
|
94
|
+
} | {
|
|
95
|
+
mask: ImageUrl;
|
|
96
|
+
/** One piece of furniture in the zone, instead of a room. */
|
|
97
|
+
furnitureId: FurnitureId;
|
|
98
|
+
styleId?: StyleId;
|
|
99
|
+
roomId?: undefined;
|
|
100
|
+
});
|
|
101
|
+
export interface SunshineParams extends Common {
|
|
102
|
+
skyId: SkyId;
|
|
103
|
+
/** With a sunset sky: the pool glows with underwater lights. */
|
|
104
|
+
poolLight?: boolean;
|
|
105
|
+
/** Direct sunlight and its shadows; inside, sun patches through the windows. */
|
|
106
|
+
lightProjection?: boolean;
|
|
107
|
+
/** With a sunny sky: foliage on bare trees, as in summer. */
|
|
108
|
+
addLeafs?: boolean;
|
|
109
|
+
}
|
|
110
|
+
export interface CreativeRedesignParams extends Common {
|
|
111
|
+
roomId: RoomId;
|
|
112
|
+
styleId: StyleId;
|
|
113
|
+
/** Keep the current floor. */
|
|
114
|
+
preserveFloor?: boolean;
|
|
115
|
+
}
|
|
116
|
+
export type SurfacesParams = Common & ({
|
|
117
|
+
surface: 'walls';
|
|
118
|
+
/** A wall colour id, or `custom` with `customWallColor`. */
|
|
119
|
+
wallType: WallTypeId;
|
|
120
|
+
/** With `wallType: 'custom'`: the colour, in English, 30 characters at most. */
|
|
121
|
+
customWallColor?: string;
|
|
122
|
+
/** Keep the ceiling as it is. */
|
|
123
|
+
preserveCeiling?: boolean;
|
|
124
|
+
} | {
|
|
125
|
+
surface: 'floor';
|
|
126
|
+
floorType: FloorTypeId;
|
|
127
|
+
/** Change the baseboards too. */
|
|
128
|
+
includeBaseboard?: boolean;
|
|
129
|
+
} | {
|
|
130
|
+
surface: 'finish';
|
|
131
|
+
finishId: FinishId;
|
|
132
|
+
});
|
|
133
|
+
export interface EnhanceParams extends Common {
|
|
134
|
+
/** Straighten converging verticals. The photo is cropped a little at the edges and keeps its size. */
|
|
135
|
+
straighten?: boolean;
|
|
136
|
+
}
|
|
137
|
+
export interface UpscaleParams extends Common {
|
|
138
|
+
/** About 4 megapixels (`2k`) or 16 megapixels (`4k`, the default). */
|
|
139
|
+
resolution?: '2k' | '4k';
|
|
140
|
+
}
|
|
141
|
+
/** Options of one call. */
|
|
142
|
+
export interface RequestOptions {
|
|
143
|
+
/** Any unique string (your photo id, for example): the same key never starts, nor bills, a second render. One is
|
|
144
|
+
* generated when you give none, so that the SDK's own retries are safe. */
|
|
145
|
+
idempotencyKey?: string;
|
|
146
|
+
/** Stops waiting (the render itself goes on, and is billed if it succeeds). */
|
|
147
|
+
signal?: AbortSignal;
|
|
148
|
+
/** In ms, for this call: overrides the client's `timeout`. */
|
|
149
|
+
timeout?: number;
|
|
150
|
+
}
|
|
151
|
+
export interface WaitOptions {
|
|
152
|
+
signal?: AbortSignal;
|
|
153
|
+
/** In ms. Default: the client's `timeout`. */
|
|
154
|
+
timeout?: number;
|
|
155
|
+
/** In ms, between two checks. Default 2500. */
|
|
156
|
+
interval?: number;
|
|
157
|
+
}
|
|
158
|
+
export interface NamedItem {
|
|
159
|
+
id: string;
|
|
160
|
+
/** French name. */
|
|
161
|
+
name: string;
|
|
162
|
+
name_en?: string;
|
|
163
|
+
name_es?: string;
|
|
164
|
+
name_pt?: string;
|
|
165
|
+
name_de?: string;
|
|
166
|
+
}
|
|
167
|
+
export interface Room extends NamedItem {
|
|
168
|
+
type: string;
|
|
169
|
+
/** `auto`: the whole room, without a mask; `zone`: the zone of a mask. */
|
|
170
|
+
modes: Array<'auto' | 'zone'>;
|
|
171
|
+
}
|
|
172
|
+
export interface Style {
|
|
173
|
+
id: string;
|
|
174
|
+
name: string;
|
|
175
|
+
}
|
|
176
|
+
export interface Furniture extends NamedItem {
|
|
177
|
+
type: string;
|
|
178
|
+
}
|
|
179
|
+
/** The furniture, grouped by type (interior, kitchen, bathroom, outdoor...). */
|
|
180
|
+
export type FurnitureCatalog = Record<string, Furniture[]>;
|
|
181
|
+
export interface SurfaceOptions {
|
|
182
|
+
walls: NamedItem[];
|
|
183
|
+
floors: NamedItem[];
|
|
184
|
+
finishes: NamedItem[];
|
|
185
|
+
}
|
|
186
|
+
export interface Account {
|
|
187
|
+
email: string;
|
|
188
|
+
key_type: 'test' | 'live';
|
|
189
|
+
/** 2 for a live v2 key, null for a test key. */
|
|
190
|
+
api_version: number | null;
|
|
191
|
+
/** For a test key only. */
|
|
192
|
+
test_renders: {
|
|
193
|
+
used: number;
|
|
194
|
+
limit: number;
|
|
195
|
+
} | null;
|
|
196
|
+
subscription: {
|
|
197
|
+
active: boolean;
|
|
198
|
+
};
|
|
199
|
+
/** The secret that signs the webhooks of this key type (`whsec_...`). */
|
|
200
|
+
webhook_secret: string;
|
|
201
|
+
}
|
|
202
|
+
export interface Usage {
|
|
203
|
+
key_type: 'test' | 'live';
|
|
204
|
+
periodStart: string;
|
|
205
|
+
periodEnd: string | null;
|
|
206
|
+
/** Successful renders. */
|
|
207
|
+
renders: number;
|
|
208
|
+
/** Failed renders (not charged). */
|
|
209
|
+
failed: number;
|
|
210
|
+
byTool: Partial<Record<Tool, number>>;
|
|
211
|
+
/** Live key: renders charged in the period, in euro cents. */
|
|
212
|
+
consumedCents: number;
|
|
213
|
+
includedCents: number | null;
|
|
214
|
+
/** Beyond the included amount, billed at the end of the period. */
|
|
215
|
+
overageCents: number | null;
|
|
216
|
+
testRenders: {
|
|
217
|
+
used: number;
|
|
218
|
+
limit: number;
|
|
219
|
+
} | null;
|
|
220
|
+
}
|
|
221
|
+
/** Codes of the API (docs: Errors), plus those of the SDK itself: `connection_error`, `timeout`, `aborted`,
|
|
222
|
+
* `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'>;
|
|
224
|
+
/**
|
|
225
|
+
* Every failure: an invalid request, a failed render (not charged), a network problem. `message` says what to do
|
|
226
|
+
* next; `code` is stable, for your code.
|
|
227
|
+
*/
|
|
228
|
+
export declare class GepettoError extends Error {
|
|
229
|
+
readonly code: ErrorCode;
|
|
230
|
+
/** HTTP status, or null when the API was not reached. */
|
|
231
|
+
readonly status: number | null;
|
|
232
|
+
/** The request field at fault, when there is one. */
|
|
233
|
+
readonly param?: string;
|
|
234
|
+
/** The job, when the error concerns a render (it can be followed with `getJob`). */
|
|
235
|
+
readonly jobId?: string;
|
|
236
|
+
readonly job?: Job;
|
|
237
|
+
constructor(init: {
|
|
238
|
+
code: ErrorCode;
|
|
239
|
+
message: string;
|
|
240
|
+
status?: number | null;
|
|
241
|
+
param?: string;
|
|
242
|
+
jobId?: string;
|
|
243
|
+
job?: Job;
|
|
244
|
+
cause?: unknown;
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
export interface ClientOptions {
|
|
248
|
+
/** Default: `GEPETTO_API_KEY` from the environment. A test key (`test_...`) is free: 200 renders. */
|
|
249
|
+
apiKey?: string;
|
|
250
|
+
/** In ms: how long a call may last, waiting for the image included. Default 10 minutes. */
|
|
251
|
+
timeout?: number;
|
|
252
|
+
/** Retries of a request on a network error, a 429 or a 5xx (always with the same idempotency key). Default 2. */
|
|
253
|
+
maxRetries?: number;
|
|
254
|
+
baseUrl?: string;
|
|
255
|
+
/** A `fetch` of your own (tests, proxies). Default: the global one. */
|
|
256
|
+
fetch?: typeof fetch;
|
|
257
|
+
/** The key gives access to your account and bills it: keep it on a server. Set this only if you know why. */
|
|
258
|
+
dangerouslyAllowBrowser?: boolean;
|
|
259
|
+
}
|
|
260
|
+
export declare class Gepetto {
|
|
261
|
+
#private;
|
|
262
|
+
readonly baseUrl: string;
|
|
263
|
+
readonly timeout: number;
|
|
264
|
+
readonly maxRetries: number;
|
|
265
|
+
/**
|
|
266
|
+
* ```ts
|
|
267
|
+
* const gepetto = new Gepetto(); // reads GEPETTO_API_KEY
|
|
268
|
+
* const gepetto = new Gepetto('test_...');
|
|
269
|
+
* const gepetto = new Gepetto({ apiKey, timeout: 120_000 });
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
constructor(apiKeyOrOptions?: string | ClientOptions, options?: ClientOptions);
|
|
273
|
+
/** True with a test key: renders are free (200 per account) and `priceCents` is 0. */
|
|
274
|
+
get isTest(): boolean;
|
|
275
|
+
/** Empty the whole room, or remove what a mask covers. 0.30 € per successful render. */
|
|
276
|
+
declutter(params: DeclutterParams & {
|
|
277
|
+
webhook: string | URL;
|
|
278
|
+
}, options?: RequestOptions): Promise<Job>;
|
|
279
|
+
declutter(params: DeclutterParams & {
|
|
280
|
+
webhook?: undefined;
|
|
281
|
+
}, options?: RequestOptions): Promise<CompletedJob>;
|
|
282
|
+
declutter(params: DeclutterParams, options?: RequestOptions): Promise<Job>;
|
|
283
|
+
/** Furnish a whole room (`roomId` + `styleId`), or the zone of a mask (as a room, or with one `furnitureId`).
|
|
284
|
+
* 0.30 € per successful render. */
|
|
285
|
+
furnish(params: FurnishParams & {
|
|
286
|
+
webhook: string | URL;
|
|
287
|
+
}, options?: RequestOptions): Promise<Job>;
|
|
288
|
+
furnish(params: FurnishParams & {
|
|
289
|
+
webhook?: undefined;
|
|
290
|
+
}, options?: RequestOptions): Promise<CompletedJob>;
|
|
291
|
+
furnish(params: FurnishParams, options?: RequestOptions): Promise<Job>;
|
|
292
|
+
/** A blue sky (`skyId`) and the matching light, outside or through the windows. 0.30 € per successful render. */
|
|
293
|
+
sunshine(params: SunshineParams & {
|
|
294
|
+
webhook: string | URL;
|
|
295
|
+
}, options?: RequestOptions): Promise<Job>;
|
|
296
|
+
sunshine(params: SunshineParams & {
|
|
297
|
+
webhook?: undefined;
|
|
298
|
+
}, options?: RequestOptions): Promise<CompletedJob>;
|
|
299
|
+
sunshine(params: SunshineParams, options?: RequestOptions): Promise<Job>;
|
|
300
|
+
/** The room redesigned in a style. 0.30 € per successful render. */
|
|
301
|
+
creativeRedesign(params: CreativeRedesignParams & {
|
|
302
|
+
webhook: string | URL;
|
|
303
|
+
}, options?: RequestOptions): Promise<Job>;
|
|
304
|
+
creativeRedesign(params: CreativeRedesignParams & {
|
|
305
|
+
webhook?: undefined;
|
|
306
|
+
}, options?: RequestOptions): Promise<CompletedJob>;
|
|
307
|
+
creativeRedesign(params: CreativeRedesignParams, options?: RequestOptions): Promise<Job>;
|
|
308
|
+
/** Repaint the walls, change the floor, or apply a finish: one `surface` per call. 0.30 € per successful render. */
|
|
309
|
+
surfaces(params: SurfacesParams & {
|
|
310
|
+
webhook: string | URL;
|
|
311
|
+
}, options?: RequestOptions): Promise<Job>;
|
|
312
|
+
surfaces(params: SurfacesParams & {
|
|
313
|
+
webhook?: undefined;
|
|
314
|
+
}, options?: RequestOptions): Promise<CompletedJob>;
|
|
315
|
+
surfaces(params: SurfacesParams, options?: RequestOptions): Promise<Job>;
|
|
316
|
+
/** Light and colours corrected at the size of the photo, nothing redrawn; `straighten` for the verticals.
|
|
317
|
+
* 0.20 € per successful render. */
|
|
318
|
+
enhance(params: EnhanceParams & {
|
|
319
|
+
webhook: string | URL;
|
|
320
|
+
}, options?: RequestOptions): Promise<Job>;
|
|
321
|
+
enhance(params: EnhanceParams & {
|
|
322
|
+
webhook?: undefined;
|
|
323
|
+
}, options?: RequestOptions): Promise<CompletedJob>;
|
|
324
|
+
enhance(params: EnhanceParams, options?: RequestOptions): Promise<Job>;
|
|
325
|
+
/** Enlarge an image to about 4 (`2k`) or 16 megapixels (`4k`, the default). 0.10 € per successful render. */
|
|
326
|
+
upscale(params: UpscaleParams & {
|
|
327
|
+
webhook: string | URL;
|
|
328
|
+
}, options?: RequestOptions): Promise<Job>;
|
|
329
|
+
upscale(params: UpscaleParams & {
|
|
330
|
+
webhook?: undefined;
|
|
331
|
+
}, options?: RequestOptions): Promise<CompletedJob>;
|
|
332
|
+
upscale(params: UpscaleParams, options?: RequestOptions): Promise<Job>;
|
|
333
|
+
/** A job as it is now. */
|
|
334
|
+
getJob(id: string, options?: {
|
|
335
|
+
signal?: AbortSignal;
|
|
336
|
+
}): Promise<Job>;
|
|
337
|
+
/** Waits until the job is finished. Resolves with it, or throws a GepettoError if the render failed. */
|
|
338
|
+
waitForJob(id: string, options?: WaitOptions): Promise<CompletedJob>;
|
|
339
|
+
/** The latest jobs of the key's type (test or live), newest first. `status: 'error'` for the failures. */
|
|
340
|
+
listJobs(params?: {
|
|
341
|
+
status?: JobStatus;
|
|
342
|
+
limit?: number;
|
|
343
|
+
}): Promise<Job[]>;
|
|
344
|
+
listRooms(): Promise<Room[]>;
|
|
345
|
+
listStyles(): Promise<Style[]>;
|
|
346
|
+
listFurnitures(): Promise<FurnitureCatalog>;
|
|
347
|
+
listSkies(): Promise<NamedItem[]>;
|
|
348
|
+
/** Wall colours, floors and finishes, for `surfaces`. */
|
|
349
|
+
listSurfaces(): Promise<SurfaceOptions>;
|
|
350
|
+
/** The account of the key, its test renders, the subscription, and the webhook secret of this key type. */
|
|
351
|
+
account(): Promise<Account>;
|
|
352
|
+
/** Renders and consumption of the current period. */
|
|
353
|
+
usage(): Promise<Usage>;
|
|
354
|
+
/** The payment link of the subscription (100 € excl. tax per month including 100 € of renders). A test key is
|
|
355
|
+
* enough; once paid, the live key is on https://app.gepettoapp.com/easy/account/api. */
|
|
356
|
+
subscribe(): Promise<{
|
|
357
|
+
url: string;
|
|
358
|
+
message: string;
|
|
359
|
+
}>;
|
|
360
|
+
}
|
|
361
|
+
export default Gepetto;
|
|
362
|
+
export interface VerifyWebhookParams {
|
|
363
|
+
/** The raw body, exactly as received (not parsed then serialised again). */
|
|
364
|
+
body: string | Uint8Array | ArrayBuffer;
|
|
365
|
+
/** The `Gepetto-Signature` header: `t=<unix time>,v1=<hex>`. */
|
|
366
|
+
signature: string | null | undefined;
|
|
367
|
+
/** `webhook_secret` of `account()` (`whsec_...`); default: `GEPETTO_WEBHOOK_SECRET` from the environment.
|
|
368
|
+
* Test and live keys have different secrets. */
|
|
369
|
+
secret?: string;
|
|
370
|
+
/** In seconds: older signatures are refused. Default 300. */
|
|
371
|
+
tolerance?: number;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Checks that a webhook comes from Gepetto, and returns its job. Throws a GepettoError `invalid_signature` otherwise.
|
|
375
|
+
*
|
|
376
|
+
* ```ts
|
|
377
|
+
* app.post('/gepetto-webhook', express.raw({ type: 'application/json' }), async (req, res) => {
|
|
378
|
+
* const job = await verifyWebhook({ body: req.body, signature: req.get('Gepetto-Signature') });
|
|
379
|
+
* res.sendStatus(200);
|
|
380
|
+
* });
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
export declare function verifyWebhook(params: VerifyWebhookParams): Promise<Job>;
|