@mediaviz/sdk 1.7.0 → 1.8.0-dev.100
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/dist/sdk.cjs +561 -26
- package/dist/sdk.d.cts +130 -3
- package/dist/sdk.d.ts +130 -3
- package/dist/sdk.esm.d.ts +130 -3
- package/dist/sdk.esm.js +554 -27
- package/dist/sdk.umd.js +561 -26
- package/package.json +1 -1
package/dist/sdk.d.cts
CHANGED
|
@@ -60,6 +60,79 @@ export class ServerError extends ApiError {
|
|
|
60
60
|
|
|
61
61
|
export function handleResponse(response: Response): Promise<any>;
|
|
62
62
|
|
|
63
|
+
export type WebhookAck = 'handled' | 'duplicate' | 'bad_signature';
|
|
64
|
+
|
|
65
|
+
export interface WebhookDeliveryEvent {
|
|
66
|
+
event_id: string;
|
|
67
|
+
event_type: string;
|
|
68
|
+
schema_version?: string;
|
|
69
|
+
subscription_id: string;
|
|
70
|
+
project_table_name: string;
|
|
71
|
+
photo_id: number;
|
|
72
|
+
target: string;
|
|
73
|
+
completed_at?: string;
|
|
74
|
+
result_location?: string;
|
|
75
|
+
[key: string]: any;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface WebhookStoreLike {
|
|
79
|
+
markSeen(eventId: string, ttlS: number): boolean;
|
|
80
|
+
unmarkSeen(eventId: string): void;
|
|
81
|
+
saveSecret(subscriptionId: string, secret: string): void;
|
|
82
|
+
rotateSecret(subscriptionId: string, newSecret: string, windowS: number): void;
|
|
83
|
+
getSecrets(subscriptionId: string): [string | null, string | null];
|
|
84
|
+
getCursor(subscriptionId: string): string | null;
|
|
85
|
+
setCursor(subscriptionId: string, cursor: string): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export class InMemoryWebhookStore implements WebhookStoreLike {
|
|
89
|
+
markSeen(eventId: string, ttlS: number): boolean;
|
|
90
|
+
unmarkSeen(eventId: string): void;
|
|
91
|
+
saveSecret(subscriptionId: string, secret: string): void;
|
|
92
|
+
rotateSecret(subscriptionId: string, newSecret: string, windowS: number): void;
|
|
93
|
+
getSecrets(subscriptionId: string): [string | null, string | null];
|
|
94
|
+
getCursor(subscriptionId: string): string | null;
|
|
95
|
+
setCursor(subscriptionId: string, cursor: string): void;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export class WebhookConsumer {
|
|
99
|
+
constructor(ctx: any, subscriptionApi: any, options?: {
|
|
100
|
+
store?: WebhookStoreLike;
|
|
101
|
+
onEvent?: (event: WebhookDeliveryEvent) => void | Promise<void>;
|
|
102
|
+
skewToleranceS?: number;
|
|
103
|
+
rotationWindowS?: number;
|
|
104
|
+
dedupeTtlS?: number;
|
|
105
|
+
pageLimit?: number;
|
|
106
|
+
});
|
|
107
|
+
store: WebhookStoreLike;
|
|
108
|
+
skewToleranceS: number;
|
|
109
|
+
rotationWindowS: number;
|
|
110
|
+
dedupeTtlS: number;
|
|
111
|
+
pageLimit: number;
|
|
112
|
+
onEvent(fn: (event: WebhookDeliveryEvent) => void | Promise<void>): (event: WebhookDeliveryEvent) => void | Promise<void>;
|
|
113
|
+
useStore(store: WebhookStoreLike): void;
|
|
114
|
+
classifyMessage(body: any): 'verification' | 'delivery' | 'unknown';
|
|
115
|
+
handleChallenge(body: any): { challenge: string };
|
|
116
|
+
handleDelivery(headers: any, rawBody: string | Uint8Array | ArrayBuffer): Promise<WebhookAck>;
|
|
117
|
+
handleRequest(headers: any, rawBody: string | Uint8Array | ArrayBuffer): Promise<{ status: number; body: any }>;
|
|
118
|
+
register(projectTableName: string, callbackUrl: string, targets: string[]): Promise<any>;
|
|
119
|
+
confirm(subscriptionId: string): Promise<any>;
|
|
120
|
+
rotateSecret(subscriptionId: string): Promise<string>;
|
|
121
|
+
updateCallback(subscriptionId: string, callbackUrl: string): Promise<any>;
|
|
122
|
+
disable(subscriptionId: string): Promise<any>;
|
|
123
|
+
listSubscriptions(): Promise<any>;
|
|
124
|
+
pullEvents(subscriptionId: string, options?: { since?: string; limit?: number }): Promise<any>;
|
|
125
|
+
reconcile(subscriptionId: string, projectTableName: string): Promise<{ pulled: number; dispatched: number }>;
|
|
126
|
+
fetchResult(event: WebhookDeliveryEvent): Promise<{ photo: any; selected: Record<string, any> | null }>;
|
|
127
|
+
saveSecret(subscriptionId: string, secret: string): void;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function signWebhookPayload(secret: string, timestamp: string, rawBody: string | Uint8Array | ArrayBuffer): Promise<string>;
|
|
131
|
+
export function verifyWebhookSignature(secretCurrent: string | null, secretPrevious: string | null, headers: any, rawBody: string | Uint8Array | ArrayBuffer, options?: { skewToleranceS?: number; now?: number }): Promise<boolean>;
|
|
132
|
+
export function selectResultColumns(photo: any, target: string): Record<string, any> | null;
|
|
133
|
+
export const WEBHOOK_MODEL_COLUMNS: Record<string, string[]>;
|
|
134
|
+
export const WEBHOOK_OUTCOME_MODELS: Record<string, string[]>;
|
|
135
|
+
|
|
63
136
|
// ── response schemas ──
|
|
64
137
|
export interface AlbumDisplay {
|
|
65
138
|
name?: string;
|
|
@@ -107,6 +180,11 @@ export interface CuratedAlbumDisplay {
|
|
|
107
180
|
confidence_value?: number;
|
|
108
181
|
}
|
|
109
182
|
|
|
183
|
+
export interface EventPage {
|
|
184
|
+
events: PullEvent[];
|
|
185
|
+
next_cursor?: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
110
188
|
export interface HealthCheck {
|
|
111
189
|
status?: string;
|
|
112
190
|
timestamp?: string;
|
|
@@ -190,6 +268,15 @@ export interface PhotoDisplay {
|
|
|
190
268
|
hue_values?: number[];
|
|
191
269
|
light_values?: number[];
|
|
192
270
|
saturation_values?: number[];
|
|
271
|
+
aesthetic_appeal?: number;
|
|
272
|
+
lighting?: number;
|
|
273
|
+
subject_significance?: number;
|
|
274
|
+
emotional_intensity?: number;
|
|
275
|
+
positive_emotion?: number;
|
|
276
|
+
universal_relatability?: number;
|
|
277
|
+
memorability?: number;
|
|
278
|
+
composition?: number;
|
|
279
|
+
judgment_overall_score?: number;
|
|
193
280
|
user_id: number;
|
|
194
281
|
company_id: number;
|
|
195
282
|
id: number;
|
|
@@ -248,7 +335,7 @@ export interface PhotoPersonWithS3Link {
|
|
|
248
335
|
export interface ProjectRunDisplay {
|
|
249
336
|
name: string;
|
|
250
337
|
private?: boolean;
|
|
251
|
-
type
|
|
338
|
+
type: number;
|
|
252
339
|
description?: string;
|
|
253
340
|
directory?: string;
|
|
254
341
|
photo_upload_vector?: number;
|
|
@@ -283,6 +370,14 @@ export interface ProjectRunDisplay {
|
|
|
283
370
|
evidence_model?: boolean;
|
|
284
371
|
insights_model?: boolean;
|
|
285
372
|
normalize?: boolean;
|
|
373
|
+
is_continuous_upload?: boolean;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export interface PullEvent {
|
|
377
|
+
event_id: string;
|
|
378
|
+
photo_id: number;
|
|
379
|
+
target: string;
|
|
380
|
+
completed_at: string;
|
|
286
381
|
}
|
|
287
382
|
|
|
288
383
|
export interface SearchDisplay {
|
|
@@ -305,6 +400,24 @@ export interface SearchDisplay {
|
|
|
305
400
|
curated_album_id?: number;
|
|
306
401
|
}
|
|
307
402
|
|
|
403
|
+
export interface SubscriptionActivated {
|
|
404
|
+
subscription_id: string;
|
|
405
|
+
status: string;
|
|
406
|
+
signing_secret: string;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export interface SubscriptionDisplay {
|
|
410
|
+
id: string;
|
|
411
|
+
project_table_name: string;
|
|
412
|
+
callback_url: string;
|
|
413
|
+
targets: string[];
|
|
414
|
+
status: string;
|
|
415
|
+
consecutive_failures: number;
|
|
416
|
+
last_delivery_at?: string;
|
|
417
|
+
last_status_code?: number;
|
|
418
|
+
created_at: string;
|
|
419
|
+
}
|
|
420
|
+
|
|
308
421
|
export interface UserDisplay {
|
|
309
422
|
id: number;
|
|
310
423
|
company_id: number;
|
|
@@ -397,7 +510,7 @@ export class OauthAuthorization {
|
|
|
397
510
|
export class OauthToken {
|
|
398
511
|
token(body: { grantType: string, code: string, redirectUri: string, clientId: string, codeVerifier: string, refreshToken: string, clientSecret: string }): Promise<Record<string, any>>;
|
|
399
512
|
adminRevokeUserTokens(userId: number): Promise<Record<string, any>>;
|
|
400
|
-
revoke(body: { token: string, tokenTypeHint: string, clientId: string }): Promise<any
|
|
513
|
+
revoke(body: { token: string, tokenTypeHint: string, clientId: string }): Promise<Record<string, any>>;
|
|
401
514
|
}
|
|
402
515
|
|
|
403
516
|
export class OauthLogin {
|
|
@@ -407,12 +520,14 @@ export class OauthLogin {
|
|
|
407
520
|
|
|
408
521
|
export class Person {
|
|
409
522
|
updatePerson(projectTableName: string, personId: string, options?: { personName?: string | string[] }): Promise<any>;
|
|
523
|
+
removePersonName(projectTableName: string, personId: string): Promise<PhotoPersonLight>;
|
|
410
524
|
combinePersons(projectTableName: string, destinationPersonId: string, oldPersonId: string): Promise<PhotoPersonLight>;
|
|
411
525
|
splitPersons(projectTableName: string, id: number, options?: { newName?: string | string[], destinationPersonId?: string | string[] }): Promise<PhotoPersonLight>;
|
|
412
526
|
getAllPersonsFromProject(projectTableName: string): Promise<PhotoPersonWithS3Link[]>;
|
|
413
527
|
getAllPersonNamesFromProject(projectTableName: string): Promise<any>;
|
|
414
528
|
getPhotoIdsByPersons(projectTableName: string, options?: { personId?: string[] | string[][] }): Promise<any>;
|
|
415
529
|
getAllPersonsFromPhoto(projectTableName: string, photoId: number): Promise<PhotoPersonLight[]>;
|
|
530
|
+
removePerson(projectTableName: string, personId: string): Promise<Record<string, any>>;
|
|
416
531
|
}
|
|
417
532
|
|
|
418
533
|
export class Photoupload {
|
|
@@ -432,7 +547,7 @@ export class Photos {
|
|
|
432
547
|
}
|
|
433
548
|
|
|
434
549
|
export class Projects {
|
|
435
|
-
createProjectAndRun(name: string,
|
|
550
|
+
createProjectAndRun(name: string, type: number, private_?: boolean, description?: string, directory?: string, photoUploadVector?: number, thumbnail?: string, runName?: string, options?: { outcomes?: any, models?: any }): Promise<ProjectRunDisplay>;
|
|
436
551
|
markProjectUploadComplete(projectTableName: string, options?: { skippedFileCount?: number | number[] }): Promise<any>;
|
|
437
552
|
checkProjectStatus(projectTableName: string): Promise<any>;
|
|
438
553
|
getProjectPrelimModelRequestTemplate(projectTableName: string): Promise<Record<string, any>>;
|
|
@@ -464,6 +579,16 @@ export class Search {
|
|
|
464
579
|
deleteSavedSearchById(searchId: number): Promise<Record<string, any>>;
|
|
465
580
|
}
|
|
466
581
|
|
|
582
|
+
export class Subscription {
|
|
583
|
+
createSubscription(projectTableName: string, callbackUrl: string, targets: string[]): Promise<SubscriptionActivated>;
|
|
584
|
+
verifySubscription(subscriptionId: string): Promise<SubscriptionActivated>;
|
|
585
|
+
listSubscriptions(): Promise<SubscriptionDisplay[]>;
|
|
586
|
+
listSubscriptionEvents(subscriptionId: string, options?: { since?: string | string[], limit?: number | number[] }): Promise<EventPage>;
|
|
587
|
+
updateSubscription(subscriptionId: string, body?: { callbackUrl?: string, targets?: string[] }): Promise<SubscriptionDisplay>;
|
|
588
|
+
deleteSubscription(subscriptionId: string): Promise<Record<string, any>>;
|
|
589
|
+
rotateSubscriptionSecret(subscriptionId: string): Promise<SubscriptionActivated>;
|
|
590
|
+
}
|
|
591
|
+
|
|
467
592
|
export class Users {
|
|
468
593
|
createUser(name: string, email: string, accountType: number, companyId?: number, profilePicture?: string, paymentPlanType?: string): Promise<UserDisplay>;
|
|
469
594
|
createUserAndCompany(name: string, email: string, password: string, companyId?: number, profilePicture?: string, paymentPlanType?: string, companyName?: string, credits?: number, options?: { inviteToken?: string | string[] }): Promise<UserDisplay>;
|
|
@@ -499,6 +624,8 @@ export class MediaViz {
|
|
|
499
624
|
readonly photos: Photos;
|
|
500
625
|
readonly projects: Projects;
|
|
501
626
|
readonly search: Search;
|
|
627
|
+
readonly subscription: Subscription;
|
|
502
628
|
readonly users: Users;
|
|
629
|
+
readonly webhooks: WebhookConsumer;
|
|
503
630
|
}
|
|
504
631
|
|
package/dist/sdk.d.ts
CHANGED
|
@@ -60,6 +60,79 @@ export class ServerError extends ApiError {
|
|
|
60
60
|
|
|
61
61
|
export function handleResponse(response: Response): Promise<any>;
|
|
62
62
|
|
|
63
|
+
export type WebhookAck = 'handled' | 'duplicate' | 'bad_signature';
|
|
64
|
+
|
|
65
|
+
export interface WebhookDeliveryEvent {
|
|
66
|
+
event_id: string;
|
|
67
|
+
event_type: string;
|
|
68
|
+
schema_version?: string;
|
|
69
|
+
subscription_id: string;
|
|
70
|
+
project_table_name: string;
|
|
71
|
+
photo_id: number;
|
|
72
|
+
target: string;
|
|
73
|
+
completed_at?: string;
|
|
74
|
+
result_location?: string;
|
|
75
|
+
[key: string]: any;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface WebhookStoreLike {
|
|
79
|
+
markSeen(eventId: string, ttlS: number): boolean;
|
|
80
|
+
unmarkSeen(eventId: string): void;
|
|
81
|
+
saveSecret(subscriptionId: string, secret: string): void;
|
|
82
|
+
rotateSecret(subscriptionId: string, newSecret: string, windowS: number): void;
|
|
83
|
+
getSecrets(subscriptionId: string): [string | null, string | null];
|
|
84
|
+
getCursor(subscriptionId: string): string | null;
|
|
85
|
+
setCursor(subscriptionId: string, cursor: string): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export class InMemoryWebhookStore implements WebhookStoreLike {
|
|
89
|
+
markSeen(eventId: string, ttlS: number): boolean;
|
|
90
|
+
unmarkSeen(eventId: string): void;
|
|
91
|
+
saveSecret(subscriptionId: string, secret: string): void;
|
|
92
|
+
rotateSecret(subscriptionId: string, newSecret: string, windowS: number): void;
|
|
93
|
+
getSecrets(subscriptionId: string): [string | null, string | null];
|
|
94
|
+
getCursor(subscriptionId: string): string | null;
|
|
95
|
+
setCursor(subscriptionId: string, cursor: string): void;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export class WebhookConsumer {
|
|
99
|
+
constructor(ctx: any, subscriptionApi: any, options?: {
|
|
100
|
+
store?: WebhookStoreLike;
|
|
101
|
+
onEvent?: (event: WebhookDeliveryEvent) => void | Promise<void>;
|
|
102
|
+
skewToleranceS?: number;
|
|
103
|
+
rotationWindowS?: number;
|
|
104
|
+
dedupeTtlS?: number;
|
|
105
|
+
pageLimit?: number;
|
|
106
|
+
});
|
|
107
|
+
store: WebhookStoreLike;
|
|
108
|
+
skewToleranceS: number;
|
|
109
|
+
rotationWindowS: number;
|
|
110
|
+
dedupeTtlS: number;
|
|
111
|
+
pageLimit: number;
|
|
112
|
+
onEvent(fn: (event: WebhookDeliveryEvent) => void | Promise<void>): (event: WebhookDeliveryEvent) => void | Promise<void>;
|
|
113
|
+
useStore(store: WebhookStoreLike): void;
|
|
114
|
+
classifyMessage(body: any): 'verification' | 'delivery' | 'unknown';
|
|
115
|
+
handleChallenge(body: any): { challenge: string };
|
|
116
|
+
handleDelivery(headers: any, rawBody: string | Uint8Array | ArrayBuffer): Promise<WebhookAck>;
|
|
117
|
+
handleRequest(headers: any, rawBody: string | Uint8Array | ArrayBuffer): Promise<{ status: number; body: any }>;
|
|
118
|
+
register(projectTableName: string, callbackUrl: string, targets: string[]): Promise<any>;
|
|
119
|
+
confirm(subscriptionId: string): Promise<any>;
|
|
120
|
+
rotateSecret(subscriptionId: string): Promise<string>;
|
|
121
|
+
updateCallback(subscriptionId: string, callbackUrl: string): Promise<any>;
|
|
122
|
+
disable(subscriptionId: string): Promise<any>;
|
|
123
|
+
listSubscriptions(): Promise<any>;
|
|
124
|
+
pullEvents(subscriptionId: string, options?: { since?: string; limit?: number }): Promise<any>;
|
|
125
|
+
reconcile(subscriptionId: string, projectTableName: string): Promise<{ pulled: number; dispatched: number }>;
|
|
126
|
+
fetchResult(event: WebhookDeliveryEvent): Promise<{ photo: any; selected: Record<string, any> | null }>;
|
|
127
|
+
saveSecret(subscriptionId: string, secret: string): void;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function signWebhookPayload(secret: string, timestamp: string, rawBody: string | Uint8Array | ArrayBuffer): Promise<string>;
|
|
131
|
+
export function verifyWebhookSignature(secretCurrent: string | null, secretPrevious: string | null, headers: any, rawBody: string | Uint8Array | ArrayBuffer, options?: { skewToleranceS?: number; now?: number }): Promise<boolean>;
|
|
132
|
+
export function selectResultColumns(photo: any, target: string): Record<string, any> | null;
|
|
133
|
+
export const WEBHOOK_MODEL_COLUMNS: Record<string, string[]>;
|
|
134
|
+
export const WEBHOOK_OUTCOME_MODELS: Record<string, string[]>;
|
|
135
|
+
|
|
63
136
|
// ── response schemas ──
|
|
64
137
|
export interface AlbumDisplay {
|
|
65
138
|
name?: string;
|
|
@@ -107,6 +180,11 @@ export interface CuratedAlbumDisplay {
|
|
|
107
180
|
confidence_value?: number;
|
|
108
181
|
}
|
|
109
182
|
|
|
183
|
+
export interface EventPage {
|
|
184
|
+
events: PullEvent[];
|
|
185
|
+
next_cursor?: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
110
188
|
export interface HealthCheck {
|
|
111
189
|
status?: string;
|
|
112
190
|
timestamp?: string;
|
|
@@ -190,6 +268,15 @@ export interface PhotoDisplay {
|
|
|
190
268
|
hue_values?: number[];
|
|
191
269
|
light_values?: number[];
|
|
192
270
|
saturation_values?: number[];
|
|
271
|
+
aesthetic_appeal?: number;
|
|
272
|
+
lighting?: number;
|
|
273
|
+
subject_significance?: number;
|
|
274
|
+
emotional_intensity?: number;
|
|
275
|
+
positive_emotion?: number;
|
|
276
|
+
universal_relatability?: number;
|
|
277
|
+
memorability?: number;
|
|
278
|
+
composition?: number;
|
|
279
|
+
judgment_overall_score?: number;
|
|
193
280
|
user_id: number;
|
|
194
281
|
company_id: number;
|
|
195
282
|
id: number;
|
|
@@ -248,7 +335,7 @@ export interface PhotoPersonWithS3Link {
|
|
|
248
335
|
export interface ProjectRunDisplay {
|
|
249
336
|
name: string;
|
|
250
337
|
private?: boolean;
|
|
251
|
-
type
|
|
338
|
+
type: number;
|
|
252
339
|
description?: string;
|
|
253
340
|
directory?: string;
|
|
254
341
|
photo_upload_vector?: number;
|
|
@@ -283,6 +370,14 @@ export interface ProjectRunDisplay {
|
|
|
283
370
|
evidence_model?: boolean;
|
|
284
371
|
insights_model?: boolean;
|
|
285
372
|
normalize?: boolean;
|
|
373
|
+
is_continuous_upload?: boolean;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export interface PullEvent {
|
|
377
|
+
event_id: string;
|
|
378
|
+
photo_id: number;
|
|
379
|
+
target: string;
|
|
380
|
+
completed_at: string;
|
|
286
381
|
}
|
|
287
382
|
|
|
288
383
|
export interface SearchDisplay {
|
|
@@ -305,6 +400,24 @@ export interface SearchDisplay {
|
|
|
305
400
|
curated_album_id?: number;
|
|
306
401
|
}
|
|
307
402
|
|
|
403
|
+
export interface SubscriptionActivated {
|
|
404
|
+
subscription_id: string;
|
|
405
|
+
status: string;
|
|
406
|
+
signing_secret: string;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export interface SubscriptionDisplay {
|
|
410
|
+
id: string;
|
|
411
|
+
project_table_name: string;
|
|
412
|
+
callback_url: string;
|
|
413
|
+
targets: string[];
|
|
414
|
+
status: string;
|
|
415
|
+
consecutive_failures: number;
|
|
416
|
+
last_delivery_at?: string;
|
|
417
|
+
last_status_code?: number;
|
|
418
|
+
created_at: string;
|
|
419
|
+
}
|
|
420
|
+
|
|
308
421
|
export interface UserDisplay {
|
|
309
422
|
id: number;
|
|
310
423
|
company_id: number;
|
|
@@ -397,7 +510,7 @@ export class OauthAuthorization {
|
|
|
397
510
|
export class OauthToken {
|
|
398
511
|
token(body: { grantType: string, code: string, redirectUri: string, clientId: string, codeVerifier: string, refreshToken: string, clientSecret: string }): Promise<Record<string, any>>;
|
|
399
512
|
adminRevokeUserTokens(userId: number): Promise<Record<string, any>>;
|
|
400
|
-
revoke(body: { token: string, tokenTypeHint: string, clientId: string }): Promise<any
|
|
513
|
+
revoke(body: { token: string, tokenTypeHint: string, clientId: string }): Promise<Record<string, any>>;
|
|
401
514
|
}
|
|
402
515
|
|
|
403
516
|
export class OauthLogin {
|
|
@@ -407,12 +520,14 @@ export class OauthLogin {
|
|
|
407
520
|
|
|
408
521
|
export class Person {
|
|
409
522
|
updatePerson(projectTableName: string, personId: string, options?: { personName?: string | string[] }): Promise<any>;
|
|
523
|
+
removePersonName(projectTableName: string, personId: string): Promise<PhotoPersonLight>;
|
|
410
524
|
combinePersons(projectTableName: string, destinationPersonId: string, oldPersonId: string): Promise<PhotoPersonLight>;
|
|
411
525
|
splitPersons(projectTableName: string, id: number, options?: { newName?: string | string[], destinationPersonId?: string | string[] }): Promise<PhotoPersonLight>;
|
|
412
526
|
getAllPersonsFromProject(projectTableName: string): Promise<PhotoPersonWithS3Link[]>;
|
|
413
527
|
getAllPersonNamesFromProject(projectTableName: string): Promise<any>;
|
|
414
528
|
getPhotoIdsByPersons(projectTableName: string, options?: { personId?: string[] | string[][] }): Promise<any>;
|
|
415
529
|
getAllPersonsFromPhoto(projectTableName: string, photoId: number): Promise<PhotoPersonLight[]>;
|
|
530
|
+
removePerson(projectTableName: string, personId: string): Promise<Record<string, any>>;
|
|
416
531
|
}
|
|
417
532
|
|
|
418
533
|
export class Photoupload {
|
|
@@ -432,7 +547,7 @@ export class Photos {
|
|
|
432
547
|
}
|
|
433
548
|
|
|
434
549
|
export class Projects {
|
|
435
|
-
createProjectAndRun(name: string,
|
|
550
|
+
createProjectAndRun(name: string, type: number, private_?: boolean, description?: string, directory?: string, photoUploadVector?: number, thumbnail?: string, runName?: string, options?: { outcomes?: any, models?: any }): Promise<ProjectRunDisplay>;
|
|
436
551
|
markProjectUploadComplete(projectTableName: string, options?: { skippedFileCount?: number | number[] }): Promise<any>;
|
|
437
552
|
checkProjectStatus(projectTableName: string): Promise<any>;
|
|
438
553
|
getProjectPrelimModelRequestTemplate(projectTableName: string): Promise<Record<string, any>>;
|
|
@@ -464,6 +579,16 @@ export class Search {
|
|
|
464
579
|
deleteSavedSearchById(searchId: number): Promise<Record<string, any>>;
|
|
465
580
|
}
|
|
466
581
|
|
|
582
|
+
export class Subscription {
|
|
583
|
+
createSubscription(projectTableName: string, callbackUrl: string, targets: string[]): Promise<SubscriptionActivated>;
|
|
584
|
+
verifySubscription(subscriptionId: string): Promise<SubscriptionActivated>;
|
|
585
|
+
listSubscriptions(): Promise<SubscriptionDisplay[]>;
|
|
586
|
+
listSubscriptionEvents(subscriptionId: string, options?: { since?: string | string[], limit?: number | number[] }): Promise<EventPage>;
|
|
587
|
+
updateSubscription(subscriptionId: string, body?: { callbackUrl?: string, targets?: string[] }): Promise<SubscriptionDisplay>;
|
|
588
|
+
deleteSubscription(subscriptionId: string): Promise<Record<string, any>>;
|
|
589
|
+
rotateSubscriptionSecret(subscriptionId: string): Promise<SubscriptionActivated>;
|
|
590
|
+
}
|
|
591
|
+
|
|
467
592
|
export class Users {
|
|
468
593
|
createUser(name: string, email: string, accountType: number, companyId?: number, profilePicture?: string, paymentPlanType?: string): Promise<UserDisplay>;
|
|
469
594
|
createUserAndCompany(name: string, email: string, password: string, companyId?: number, profilePicture?: string, paymentPlanType?: string, companyName?: string, credits?: number, options?: { inviteToken?: string | string[] }): Promise<UserDisplay>;
|
|
@@ -499,6 +624,8 @@ export class MediaViz {
|
|
|
499
624
|
readonly photos: Photos;
|
|
500
625
|
readonly projects: Projects;
|
|
501
626
|
readonly search: Search;
|
|
627
|
+
readonly subscription: Subscription;
|
|
502
628
|
readonly users: Users;
|
|
629
|
+
readonly webhooks: WebhookConsumer;
|
|
503
630
|
}
|
|
504
631
|
|
package/dist/sdk.esm.d.ts
CHANGED
|
@@ -60,6 +60,79 @@ export class ServerError extends ApiError {
|
|
|
60
60
|
|
|
61
61
|
export function handleResponse(response: Response): Promise<any>;
|
|
62
62
|
|
|
63
|
+
export type WebhookAck = 'handled' | 'duplicate' | 'bad_signature';
|
|
64
|
+
|
|
65
|
+
export interface WebhookDeliveryEvent {
|
|
66
|
+
event_id: string;
|
|
67
|
+
event_type: string;
|
|
68
|
+
schema_version?: string;
|
|
69
|
+
subscription_id: string;
|
|
70
|
+
project_table_name: string;
|
|
71
|
+
photo_id: number;
|
|
72
|
+
target: string;
|
|
73
|
+
completed_at?: string;
|
|
74
|
+
result_location?: string;
|
|
75
|
+
[key: string]: any;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface WebhookStoreLike {
|
|
79
|
+
markSeen(eventId: string, ttlS: number): boolean;
|
|
80
|
+
unmarkSeen(eventId: string): void;
|
|
81
|
+
saveSecret(subscriptionId: string, secret: string): void;
|
|
82
|
+
rotateSecret(subscriptionId: string, newSecret: string, windowS: number): void;
|
|
83
|
+
getSecrets(subscriptionId: string): [string | null, string | null];
|
|
84
|
+
getCursor(subscriptionId: string): string | null;
|
|
85
|
+
setCursor(subscriptionId: string, cursor: string): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export class InMemoryWebhookStore implements WebhookStoreLike {
|
|
89
|
+
markSeen(eventId: string, ttlS: number): boolean;
|
|
90
|
+
unmarkSeen(eventId: string): void;
|
|
91
|
+
saveSecret(subscriptionId: string, secret: string): void;
|
|
92
|
+
rotateSecret(subscriptionId: string, newSecret: string, windowS: number): void;
|
|
93
|
+
getSecrets(subscriptionId: string): [string | null, string | null];
|
|
94
|
+
getCursor(subscriptionId: string): string | null;
|
|
95
|
+
setCursor(subscriptionId: string, cursor: string): void;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export class WebhookConsumer {
|
|
99
|
+
constructor(ctx: any, subscriptionApi: any, options?: {
|
|
100
|
+
store?: WebhookStoreLike;
|
|
101
|
+
onEvent?: (event: WebhookDeliveryEvent) => void | Promise<void>;
|
|
102
|
+
skewToleranceS?: number;
|
|
103
|
+
rotationWindowS?: number;
|
|
104
|
+
dedupeTtlS?: number;
|
|
105
|
+
pageLimit?: number;
|
|
106
|
+
});
|
|
107
|
+
store: WebhookStoreLike;
|
|
108
|
+
skewToleranceS: number;
|
|
109
|
+
rotationWindowS: number;
|
|
110
|
+
dedupeTtlS: number;
|
|
111
|
+
pageLimit: number;
|
|
112
|
+
onEvent(fn: (event: WebhookDeliveryEvent) => void | Promise<void>): (event: WebhookDeliveryEvent) => void | Promise<void>;
|
|
113
|
+
useStore(store: WebhookStoreLike): void;
|
|
114
|
+
classifyMessage(body: any): 'verification' | 'delivery' | 'unknown';
|
|
115
|
+
handleChallenge(body: any): { challenge: string };
|
|
116
|
+
handleDelivery(headers: any, rawBody: string | Uint8Array | ArrayBuffer): Promise<WebhookAck>;
|
|
117
|
+
handleRequest(headers: any, rawBody: string | Uint8Array | ArrayBuffer): Promise<{ status: number; body: any }>;
|
|
118
|
+
register(projectTableName: string, callbackUrl: string, targets: string[]): Promise<any>;
|
|
119
|
+
confirm(subscriptionId: string): Promise<any>;
|
|
120
|
+
rotateSecret(subscriptionId: string): Promise<string>;
|
|
121
|
+
updateCallback(subscriptionId: string, callbackUrl: string): Promise<any>;
|
|
122
|
+
disable(subscriptionId: string): Promise<any>;
|
|
123
|
+
listSubscriptions(): Promise<any>;
|
|
124
|
+
pullEvents(subscriptionId: string, options?: { since?: string; limit?: number }): Promise<any>;
|
|
125
|
+
reconcile(subscriptionId: string, projectTableName: string): Promise<{ pulled: number; dispatched: number }>;
|
|
126
|
+
fetchResult(event: WebhookDeliveryEvent): Promise<{ photo: any; selected: Record<string, any> | null }>;
|
|
127
|
+
saveSecret(subscriptionId: string, secret: string): void;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function signWebhookPayload(secret: string, timestamp: string, rawBody: string | Uint8Array | ArrayBuffer): Promise<string>;
|
|
131
|
+
export function verifyWebhookSignature(secretCurrent: string | null, secretPrevious: string | null, headers: any, rawBody: string | Uint8Array | ArrayBuffer, options?: { skewToleranceS?: number; now?: number }): Promise<boolean>;
|
|
132
|
+
export function selectResultColumns(photo: any, target: string): Record<string, any> | null;
|
|
133
|
+
export const WEBHOOK_MODEL_COLUMNS: Record<string, string[]>;
|
|
134
|
+
export const WEBHOOK_OUTCOME_MODELS: Record<string, string[]>;
|
|
135
|
+
|
|
63
136
|
// ── response schemas ──
|
|
64
137
|
export interface AlbumDisplay {
|
|
65
138
|
name?: string;
|
|
@@ -107,6 +180,11 @@ export interface CuratedAlbumDisplay {
|
|
|
107
180
|
confidence_value?: number;
|
|
108
181
|
}
|
|
109
182
|
|
|
183
|
+
export interface EventPage {
|
|
184
|
+
events: PullEvent[];
|
|
185
|
+
next_cursor?: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
110
188
|
export interface HealthCheck {
|
|
111
189
|
status?: string;
|
|
112
190
|
timestamp?: string;
|
|
@@ -190,6 +268,15 @@ export interface PhotoDisplay {
|
|
|
190
268
|
hue_values?: number[];
|
|
191
269
|
light_values?: number[];
|
|
192
270
|
saturation_values?: number[];
|
|
271
|
+
aesthetic_appeal?: number;
|
|
272
|
+
lighting?: number;
|
|
273
|
+
subject_significance?: number;
|
|
274
|
+
emotional_intensity?: number;
|
|
275
|
+
positive_emotion?: number;
|
|
276
|
+
universal_relatability?: number;
|
|
277
|
+
memorability?: number;
|
|
278
|
+
composition?: number;
|
|
279
|
+
judgment_overall_score?: number;
|
|
193
280
|
user_id: number;
|
|
194
281
|
company_id: number;
|
|
195
282
|
id: number;
|
|
@@ -248,7 +335,7 @@ export interface PhotoPersonWithS3Link {
|
|
|
248
335
|
export interface ProjectRunDisplay {
|
|
249
336
|
name: string;
|
|
250
337
|
private?: boolean;
|
|
251
|
-
type
|
|
338
|
+
type: number;
|
|
252
339
|
description?: string;
|
|
253
340
|
directory?: string;
|
|
254
341
|
photo_upload_vector?: number;
|
|
@@ -283,6 +370,14 @@ export interface ProjectRunDisplay {
|
|
|
283
370
|
evidence_model?: boolean;
|
|
284
371
|
insights_model?: boolean;
|
|
285
372
|
normalize?: boolean;
|
|
373
|
+
is_continuous_upload?: boolean;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export interface PullEvent {
|
|
377
|
+
event_id: string;
|
|
378
|
+
photo_id: number;
|
|
379
|
+
target: string;
|
|
380
|
+
completed_at: string;
|
|
286
381
|
}
|
|
287
382
|
|
|
288
383
|
export interface SearchDisplay {
|
|
@@ -305,6 +400,24 @@ export interface SearchDisplay {
|
|
|
305
400
|
curated_album_id?: number;
|
|
306
401
|
}
|
|
307
402
|
|
|
403
|
+
export interface SubscriptionActivated {
|
|
404
|
+
subscription_id: string;
|
|
405
|
+
status: string;
|
|
406
|
+
signing_secret: string;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export interface SubscriptionDisplay {
|
|
410
|
+
id: string;
|
|
411
|
+
project_table_name: string;
|
|
412
|
+
callback_url: string;
|
|
413
|
+
targets: string[];
|
|
414
|
+
status: string;
|
|
415
|
+
consecutive_failures: number;
|
|
416
|
+
last_delivery_at?: string;
|
|
417
|
+
last_status_code?: number;
|
|
418
|
+
created_at: string;
|
|
419
|
+
}
|
|
420
|
+
|
|
308
421
|
export interface UserDisplay {
|
|
309
422
|
id: number;
|
|
310
423
|
company_id: number;
|
|
@@ -397,7 +510,7 @@ export class OauthAuthorization {
|
|
|
397
510
|
export class OauthToken {
|
|
398
511
|
token(body: { grantType: string, code: string, redirectUri: string, clientId: string, codeVerifier: string, refreshToken: string, clientSecret: string }): Promise<Record<string, any>>;
|
|
399
512
|
adminRevokeUserTokens(userId: number): Promise<Record<string, any>>;
|
|
400
|
-
revoke(body: { token: string, tokenTypeHint: string, clientId: string }): Promise<any
|
|
513
|
+
revoke(body: { token: string, tokenTypeHint: string, clientId: string }): Promise<Record<string, any>>;
|
|
401
514
|
}
|
|
402
515
|
|
|
403
516
|
export class OauthLogin {
|
|
@@ -407,12 +520,14 @@ export class OauthLogin {
|
|
|
407
520
|
|
|
408
521
|
export class Person {
|
|
409
522
|
updatePerson(projectTableName: string, personId: string, options?: { personName?: string | string[] }): Promise<any>;
|
|
523
|
+
removePersonName(projectTableName: string, personId: string): Promise<PhotoPersonLight>;
|
|
410
524
|
combinePersons(projectTableName: string, destinationPersonId: string, oldPersonId: string): Promise<PhotoPersonLight>;
|
|
411
525
|
splitPersons(projectTableName: string, id: number, options?: { newName?: string | string[], destinationPersonId?: string | string[] }): Promise<PhotoPersonLight>;
|
|
412
526
|
getAllPersonsFromProject(projectTableName: string): Promise<PhotoPersonWithS3Link[]>;
|
|
413
527
|
getAllPersonNamesFromProject(projectTableName: string): Promise<any>;
|
|
414
528
|
getPhotoIdsByPersons(projectTableName: string, options?: { personId?: string[] | string[][] }): Promise<any>;
|
|
415
529
|
getAllPersonsFromPhoto(projectTableName: string, photoId: number): Promise<PhotoPersonLight[]>;
|
|
530
|
+
removePerson(projectTableName: string, personId: string): Promise<Record<string, any>>;
|
|
416
531
|
}
|
|
417
532
|
|
|
418
533
|
export class Photoupload {
|
|
@@ -432,7 +547,7 @@ export class Photos {
|
|
|
432
547
|
}
|
|
433
548
|
|
|
434
549
|
export class Projects {
|
|
435
|
-
createProjectAndRun(name: string,
|
|
550
|
+
createProjectAndRun(name: string, type: number, private_?: boolean, description?: string, directory?: string, photoUploadVector?: number, thumbnail?: string, runName?: string, options?: { outcomes?: any, models?: any }): Promise<ProjectRunDisplay>;
|
|
436
551
|
markProjectUploadComplete(projectTableName: string, options?: { skippedFileCount?: number | number[] }): Promise<any>;
|
|
437
552
|
checkProjectStatus(projectTableName: string): Promise<any>;
|
|
438
553
|
getProjectPrelimModelRequestTemplate(projectTableName: string): Promise<Record<string, any>>;
|
|
@@ -464,6 +579,16 @@ export class Search {
|
|
|
464
579
|
deleteSavedSearchById(searchId: number): Promise<Record<string, any>>;
|
|
465
580
|
}
|
|
466
581
|
|
|
582
|
+
export class Subscription {
|
|
583
|
+
createSubscription(projectTableName: string, callbackUrl: string, targets: string[]): Promise<SubscriptionActivated>;
|
|
584
|
+
verifySubscription(subscriptionId: string): Promise<SubscriptionActivated>;
|
|
585
|
+
listSubscriptions(): Promise<SubscriptionDisplay[]>;
|
|
586
|
+
listSubscriptionEvents(subscriptionId: string, options?: { since?: string | string[], limit?: number | number[] }): Promise<EventPage>;
|
|
587
|
+
updateSubscription(subscriptionId: string, body?: { callbackUrl?: string, targets?: string[] }): Promise<SubscriptionDisplay>;
|
|
588
|
+
deleteSubscription(subscriptionId: string): Promise<Record<string, any>>;
|
|
589
|
+
rotateSubscriptionSecret(subscriptionId: string): Promise<SubscriptionActivated>;
|
|
590
|
+
}
|
|
591
|
+
|
|
467
592
|
export class Users {
|
|
468
593
|
createUser(name: string, email: string, accountType: number, companyId?: number, profilePicture?: string, paymentPlanType?: string): Promise<UserDisplay>;
|
|
469
594
|
createUserAndCompany(name: string, email: string, password: string, companyId?: number, profilePicture?: string, paymentPlanType?: string, companyName?: string, credits?: number, options?: { inviteToken?: string | string[] }): Promise<UserDisplay>;
|
|
@@ -499,6 +624,8 @@ export class MediaViz {
|
|
|
499
624
|
readonly photos: Photos;
|
|
500
625
|
readonly projects: Projects;
|
|
501
626
|
readonly search: Search;
|
|
627
|
+
readonly subscription: Subscription;
|
|
502
628
|
readonly users: Users;
|
|
629
|
+
readonly webhooks: WebhookConsumer;
|
|
503
630
|
}
|
|
504
631
|
|