@mediaviz/sdk 1.8.0-dev.92 → 1.8.0-dev.95
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 +457 -7
- package/dist/sdk.d.cts +80 -5
- package/dist/sdk.d.ts +80 -5
- package/dist/sdk.esm.d.ts +80 -5
- package/dist/sdk.esm.js +451 -8
- package/dist/sdk.umd.js +457 -7
- package/package.json +1 -1
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;
|
|
@@ -255,7 +328,7 @@ export interface PhotoPersonWithS3Link {
|
|
|
255
328
|
export interface ProjectRunDisplay {
|
|
256
329
|
name: string;
|
|
257
330
|
private?: boolean;
|
|
258
|
-
type
|
|
331
|
+
type: number;
|
|
259
332
|
description?: string;
|
|
260
333
|
directory?: string;
|
|
261
334
|
photo_upload_vector?: number;
|
|
@@ -290,6 +363,7 @@ export interface ProjectRunDisplay {
|
|
|
290
363
|
evidence_model?: boolean;
|
|
291
364
|
insights_model?: boolean;
|
|
292
365
|
normalize?: boolean;
|
|
366
|
+
is_continuous_upload?: boolean;
|
|
293
367
|
}
|
|
294
368
|
|
|
295
369
|
export interface PullEvent {
|
|
@@ -430,7 +504,7 @@ export class OauthAuthorization {
|
|
|
430
504
|
export class OauthToken {
|
|
431
505
|
token(body: { grantType: string, code: string, redirectUri: string, clientId: string, codeVerifier: string, refreshToken: string, clientSecret: string }): Promise<Record<string, any>>;
|
|
432
506
|
adminRevokeUserTokens(userId: number): Promise<Record<string, any>>;
|
|
433
|
-
revoke(body: { token: string, tokenTypeHint: string, clientId: string }): Promise<any
|
|
507
|
+
revoke(body: { token: string, tokenTypeHint: string, clientId: string }): Promise<Record<string, any>>;
|
|
434
508
|
}
|
|
435
509
|
|
|
436
510
|
export class OauthLogin {
|
|
@@ -467,7 +541,7 @@ export class Photos {
|
|
|
467
541
|
}
|
|
468
542
|
|
|
469
543
|
export class Projects {
|
|
470
|
-
createProjectAndRun(name: string,
|
|
544
|
+
createProjectAndRun(name: string, type: number, private_?: boolean, description?: string, directory?: string, photoUploadVector?: number, thumbnail?: string, runName?: string, options?: { outcomes?: any, models?: any }): Promise<ProjectRunDisplay>;
|
|
471
545
|
markProjectUploadComplete(projectTableName: string, options?: { skippedFileCount?: number | number[] }): Promise<any>;
|
|
472
546
|
checkProjectStatus(projectTableName: string): Promise<any>;
|
|
473
547
|
getProjectPrelimModelRequestTemplate(projectTableName: string): Promise<Record<string, any>>;
|
|
@@ -500,8 +574,8 @@ export class Search {
|
|
|
500
574
|
}
|
|
501
575
|
|
|
502
576
|
export class Subscription {
|
|
503
|
-
createSubscription(projectTableName: string, callbackUrl: string, targets: string[]): Promise<
|
|
504
|
-
verifySubscription(subscriptionId: string): Promise<
|
|
577
|
+
createSubscription(projectTableName: string, callbackUrl: string, targets: string[]): Promise<SubscriptionActivated>;
|
|
578
|
+
verifySubscription(subscriptionId: string): Promise<SubscriptionActivated>;
|
|
505
579
|
listSubscriptions(): Promise<SubscriptionDisplay[]>;
|
|
506
580
|
listSubscriptionEvents(subscriptionId: string, options?: { since?: string | string[], limit?: number | number[] }): Promise<EventPage>;
|
|
507
581
|
updateSubscription(subscriptionId: string, body?: { callbackUrl?: string, targets?: string[] }): Promise<SubscriptionDisplay>;
|
|
@@ -546,5 +620,6 @@ export class MediaViz {
|
|
|
546
620
|
readonly search: Search;
|
|
547
621
|
readonly subscription: Subscription;
|
|
548
622
|
readonly users: Users;
|
|
623
|
+
readonly webhooks: WebhookConsumer;
|
|
549
624
|
}
|
|
550
625
|
|
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;
|
|
@@ -255,7 +328,7 @@ export interface PhotoPersonWithS3Link {
|
|
|
255
328
|
export interface ProjectRunDisplay {
|
|
256
329
|
name: string;
|
|
257
330
|
private?: boolean;
|
|
258
|
-
type
|
|
331
|
+
type: number;
|
|
259
332
|
description?: string;
|
|
260
333
|
directory?: string;
|
|
261
334
|
photo_upload_vector?: number;
|
|
@@ -290,6 +363,7 @@ export interface ProjectRunDisplay {
|
|
|
290
363
|
evidence_model?: boolean;
|
|
291
364
|
insights_model?: boolean;
|
|
292
365
|
normalize?: boolean;
|
|
366
|
+
is_continuous_upload?: boolean;
|
|
293
367
|
}
|
|
294
368
|
|
|
295
369
|
export interface PullEvent {
|
|
@@ -430,7 +504,7 @@ export class OauthAuthorization {
|
|
|
430
504
|
export class OauthToken {
|
|
431
505
|
token(body: { grantType: string, code: string, redirectUri: string, clientId: string, codeVerifier: string, refreshToken: string, clientSecret: string }): Promise<Record<string, any>>;
|
|
432
506
|
adminRevokeUserTokens(userId: number): Promise<Record<string, any>>;
|
|
433
|
-
revoke(body: { token: string, tokenTypeHint: string, clientId: string }): Promise<any
|
|
507
|
+
revoke(body: { token: string, tokenTypeHint: string, clientId: string }): Promise<Record<string, any>>;
|
|
434
508
|
}
|
|
435
509
|
|
|
436
510
|
export class OauthLogin {
|
|
@@ -467,7 +541,7 @@ export class Photos {
|
|
|
467
541
|
}
|
|
468
542
|
|
|
469
543
|
export class Projects {
|
|
470
|
-
createProjectAndRun(name: string,
|
|
544
|
+
createProjectAndRun(name: string, type: number, private_?: boolean, description?: string, directory?: string, photoUploadVector?: number, thumbnail?: string, runName?: string, options?: { outcomes?: any, models?: any }): Promise<ProjectRunDisplay>;
|
|
471
545
|
markProjectUploadComplete(projectTableName: string, options?: { skippedFileCount?: number | number[] }): Promise<any>;
|
|
472
546
|
checkProjectStatus(projectTableName: string): Promise<any>;
|
|
473
547
|
getProjectPrelimModelRequestTemplate(projectTableName: string): Promise<Record<string, any>>;
|
|
@@ -500,8 +574,8 @@ export class Search {
|
|
|
500
574
|
}
|
|
501
575
|
|
|
502
576
|
export class Subscription {
|
|
503
|
-
createSubscription(projectTableName: string, callbackUrl: string, targets: string[]): Promise<
|
|
504
|
-
verifySubscription(subscriptionId: string): Promise<
|
|
577
|
+
createSubscription(projectTableName: string, callbackUrl: string, targets: string[]): Promise<SubscriptionActivated>;
|
|
578
|
+
verifySubscription(subscriptionId: string): Promise<SubscriptionActivated>;
|
|
505
579
|
listSubscriptions(): Promise<SubscriptionDisplay[]>;
|
|
506
580
|
listSubscriptionEvents(subscriptionId: string, options?: { since?: string | string[], limit?: number | number[] }): Promise<EventPage>;
|
|
507
581
|
updateSubscription(subscriptionId: string, body?: { callbackUrl?: string, targets?: string[] }): Promise<SubscriptionDisplay>;
|
|
@@ -546,5 +620,6 @@ export class MediaViz {
|
|
|
546
620
|
readonly search: Search;
|
|
547
621
|
readonly subscription: Subscription;
|
|
548
622
|
readonly users: Users;
|
|
623
|
+
readonly webhooks: WebhookConsumer;
|
|
549
624
|
}
|
|
550
625
|
|