segmind 0.3.0 → 0.4.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 +7 -2
- package/dist/index.cjs +23 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -6
- package/dist/index.d.ts +60 -6
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -251,6 +251,13 @@ interface RequestRecord {
|
|
|
251
251
|
latency_ms?: number | null;
|
|
252
252
|
model_created?: string;
|
|
253
253
|
error?: string | null;
|
|
254
|
+
/** What sent the request, such as `API`, `API_V2`, `SDK_JS_V2` or `WEBPROD_V2`. */
|
|
255
|
+
initiator?: string | null;
|
|
256
|
+
/** The last 6 characters of the API key that made the request; null when no key did. */
|
|
257
|
+
key_mask?: string | null;
|
|
258
|
+
user_id?: string | null;
|
|
259
|
+
/** Inside a team, whose request it was. Empty when the lookup failed. */
|
|
260
|
+
user_email?: string | null;
|
|
254
261
|
[key: string]: unknown;
|
|
255
262
|
}
|
|
256
263
|
interface GenerationsListOptions {
|
|
@@ -275,6 +282,17 @@ interface HistoryOptions {
|
|
|
275
282
|
/** Substring match on the model slug. */
|
|
276
283
|
modelName?: string;
|
|
277
284
|
status?: 'COMPLETED' | 'FAILED' | 'PENDING';
|
|
285
|
+
/**
|
|
286
|
+
* Only requests from these sources; a list matches any of them. Either
|
|
287
|
+
* spelling works, `API_V2` or `API-V2`. An unknown source is refused (400).
|
|
288
|
+
*/
|
|
289
|
+
initiator?: string | string[];
|
|
290
|
+
/**
|
|
291
|
+
* Only one key's requests, by the last 6 characters of the key, lowercase:
|
|
292
|
+
* the `key_mask` on each row. The full key is never sent, because a URL ends
|
|
293
|
+
* up in access logs.
|
|
294
|
+
*/
|
|
295
|
+
keySuffix?: string;
|
|
278
296
|
/** Inside a team, any member's user id; otherwise only your own. */
|
|
279
297
|
userId?: string;
|
|
280
298
|
/** Same as `userId`, by email. Pass one or the other. */
|
|
@@ -416,7 +434,7 @@ declare class PixelflowJob {
|
|
|
416
434
|
type WebhookEventType = 'PIXELFLOW' | 'WORKFLOW' | 'INFERENCE' | 'FINETUNE' | (string & {});
|
|
417
435
|
/** A webhook registration, as the API returns it. */
|
|
418
436
|
interface Webhook {
|
|
419
|
-
/** Pass to `update`, `delete` and `
|
|
437
|
+
/** Pass to `update`, `delete`, `logs` and `test`. */
|
|
420
438
|
id: string;
|
|
421
439
|
user_id: string;
|
|
422
440
|
webhook_url: string;
|
|
@@ -427,6 +445,22 @@ interface Webhook {
|
|
|
427
445
|
created_ts: string;
|
|
428
446
|
[key: string]: unknown;
|
|
429
447
|
}
|
|
448
|
+
/** One delivery to a registration, as `logs` lists it. */
|
|
449
|
+
interface WebhookDelivery {
|
|
450
|
+
/** Pass to `resend`. */
|
|
451
|
+
id: string;
|
|
452
|
+
webhook_url: string;
|
|
453
|
+
request_id: string;
|
|
454
|
+
event_type: string;
|
|
455
|
+
payload: unknown;
|
|
456
|
+
/** Your endpoint's HTTP status; null when it never answered. */
|
|
457
|
+
status_code: number | null;
|
|
458
|
+
/** The start of your endpoint's reply. */
|
|
459
|
+
response_body: string | null;
|
|
460
|
+
success: boolean;
|
|
461
|
+
created_ts: string;
|
|
462
|
+
[key: string]: unknown;
|
|
463
|
+
}
|
|
430
464
|
/** Your webhook registrations. One active registration per set of event types. */
|
|
431
465
|
declare class Webhooks {
|
|
432
466
|
private readonly client;
|
|
@@ -456,10 +490,30 @@ declare class Webhooks {
|
|
|
456
490
|
delete(webhookId: string, options?: {
|
|
457
491
|
signal?: AbortSignal;
|
|
458
492
|
}): Promise<Record<string, unknown>>;
|
|
459
|
-
/**
|
|
493
|
+
/** Every delivery made to one registration. */
|
|
460
494
|
logs(webhookId: string, options?: {
|
|
461
495
|
signal?: AbortSignal;
|
|
462
|
-
}): Promise<
|
|
496
|
+
}): Promise<WebhookDelivery[]>;
|
|
497
|
+
/**
|
|
498
|
+
* Sends a `WEBHOOK_TEST` delivery to an active registration. It goes out in
|
|
499
|
+
* the background after this returns, so read `logs` to see how your endpoint
|
|
500
|
+
* answered. Not retried: each attempt is another delivery.
|
|
501
|
+
*/
|
|
502
|
+
test(webhookId: string, options?: {
|
|
503
|
+
signal?: AbortSignal;
|
|
504
|
+
}): Promise<{
|
|
505
|
+
message: string;
|
|
506
|
+
}>;
|
|
507
|
+
/**
|
|
508
|
+
* Sends a past delivery's payload again, by its `id` from `logs`. Refused
|
|
509
|
+
* (406) when the registration is no longer active. Not retried: each
|
|
510
|
+
* attempt is another delivery.
|
|
511
|
+
*/
|
|
512
|
+
resend(deliveryId: string, options?: {
|
|
513
|
+
signal?: AbortSignal;
|
|
514
|
+
}): Promise<{
|
|
515
|
+
message: string;
|
|
516
|
+
}>;
|
|
463
517
|
private call;
|
|
464
518
|
}
|
|
465
519
|
|
|
@@ -752,7 +806,7 @@ declare class InferenceTimeout extends SegmindError {
|
|
|
752
806
|
constructor(requestId: string, elapsedMs: number);
|
|
753
807
|
}
|
|
754
808
|
|
|
755
|
-
declare const VERSION = "0.
|
|
809
|
+
declare const VERSION = "0.4.0";
|
|
756
810
|
|
|
757
811
|
/** `new Segmind().run(...)` with the key from `SEGMIND_API_KEY`. */
|
|
758
812
|
declare const run: (slug: string, params?: Params, options?: RunOptions) => Promise<RunResult>;
|
|
@@ -784,9 +838,9 @@ declare const files: Pick<Files, 'upload'>;
|
|
|
784
838
|
/** `new Segmind().generations` with the key from `SEGMIND_API_KEY`. */
|
|
785
839
|
declare const generations: Pick<Generations, 'list' | 'recent' | 'history' | 'get'>;
|
|
786
840
|
/** `new Segmind().webhooks` with the key from `SEGMIND_API_KEY`. */
|
|
787
|
-
declare const webhooks: Pick<Webhooks, 'get' | 'add' | 'update' | 'delete' | 'logs'>;
|
|
841
|
+
declare const webhooks: Pick<Webhooks, 'get' | 'add' | 'update' | 'delete' | 'logs' | 'test' | 'resend'>;
|
|
788
842
|
/** `new Segmind().pixelflows` with the key from `SEGMIND_API_KEY`. */
|
|
789
843
|
declare const pixelflows: Pick<PixelFlows, 'run' | 'submit' | 'getStatus' | 'poll'>;
|
|
790
844
|
|
|
791
845
|
export { APIConnectionError, Accounts, ChatResponse, DEFAULT_BASE_URL, DEFAULT_CONSOLE_URL, DEFAULT_SPOT_URL, DEFAULT_WAIT_INTERVAL_MS, DEFAULT_WAIT_TIMEOUT_MS, Files, Generations, InferenceFailed, InferenceTimeout, InsufficientCredits, Job, Models, PixelFlows, PixelflowJob, RateLimited, Segmind, SegmindError, VERSION, Webhooks, accounts, chat, chatSync, files, generations, imageUrl, job, models, pixelflows, run, runSync, submit, submitChat, webhooks };
|
|
792
|
-
export type { AccountCredits, CallOptions, ChatMessage, ChatParams, ClientOptions, FileInput, Generation, GenerationsListOptions, HistoryOptions, ImageInput, ImageUrlPart, Initiator, InitiatorOptions, JobState, JobStatus, ModelInfo, ModelInput, ModelListParams, ModelOutput, ModelSort, ModelsPage, Page, Params, PixelflowStatus, PixelflowSubmitOptions, PixelflowWaitOptions, PollInterval, RequestRecord, RunOptions, RunResult, SubmitOptions, SubmitResponse, TokenProvider, UploadOptions, UploadedFile, WaitOptions, Webhook, WebhookEventType };
|
|
846
|
+
export type { AccountCredits, CallOptions, ChatMessage, ChatParams, ClientOptions, FileInput, Generation, GenerationsListOptions, HistoryOptions, ImageInput, ImageUrlPart, Initiator, InitiatorOptions, JobState, JobStatus, ModelInfo, ModelInput, ModelListParams, ModelOutput, ModelSort, ModelsPage, Page, Params, PixelflowStatus, PixelflowSubmitOptions, PixelflowWaitOptions, PollInterval, RequestRecord, RunOptions, RunResult, SubmitOptions, SubmitResponse, TokenProvider, UploadOptions, UploadedFile, WaitOptions, Webhook, WebhookDelivery, WebhookEventType };
|
package/dist/index.d.ts
CHANGED
|
@@ -251,6 +251,13 @@ interface RequestRecord {
|
|
|
251
251
|
latency_ms?: number | null;
|
|
252
252
|
model_created?: string;
|
|
253
253
|
error?: string | null;
|
|
254
|
+
/** What sent the request, such as `API`, `API_V2`, `SDK_JS_V2` or `WEBPROD_V2`. */
|
|
255
|
+
initiator?: string | null;
|
|
256
|
+
/** The last 6 characters of the API key that made the request; null when no key did. */
|
|
257
|
+
key_mask?: string | null;
|
|
258
|
+
user_id?: string | null;
|
|
259
|
+
/** Inside a team, whose request it was. Empty when the lookup failed. */
|
|
260
|
+
user_email?: string | null;
|
|
254
261
|
[key: string]: unknown;
|
|
255
262
|
}
|
|
256
263
|
interface GenerationsListOptions {
|
|
@@ -275,6 +282,17 @@ interface HistoryOptions {
|
|
|
275
282
|
/** Substring match on the model slug. */
|
|
276
283
|
modelName?: string;
|
|
277
284
|
status?: 'COMPLETED' | 'FAILED' | 'PENDING';
|
|
285
|
+
/**
|
|
286
|
+
* Only requests from these sources; a list matches any of them. Either
|
|
287
|
+
* spelling works, `API_V2` or `API-V2`. An unknown source is refused (400).
|
|
288
|
+
*/
|
|
289
|
+
initiator?: string | string[];
|
|
290
|
+
/**
|
|
291
|
+
* Only one key's requests, by the last 6 characters of the key, lowercase:
|
|
292
|
+
* the `key_mask` on each row. The full key is never sent, because a URL ends
|
|
293
|
+
* up in access logs.
|
|
294
|
+
*/
|
|
295
|
+
keySuffix?: string;
|
|
278
296
|
/** Inside a team, any member's user id; otherwise only your own. */
|
|
279
297
|
userId?: string;
|
|
280
298
|
/** Same as `userId`, by email. Pass one or the other. */
|
|
@@ -416,7 +434,7 @@ declare class PixelflowJob {
|
|
|
416
434
|
type WebhookEventType = 'PIXELFLOW' | 'WORKFLOW' | 'INFERENCE' | 'FINETUNE' | (string & {});
|
|
417
435
|
/** A webhook registration, as the API returns it. */
|
|
418
436
|
interface Webhook {
|
|
419
|
-
/** Pass to `update`, `delete` and `
|
|
437
|
+
/** Pass to `update`, `delete`, `logs` and `test`. */
|
|
420
438
|
id: string;
|
|
421
439
|
user_id: string;
|
|
422
440
|
webhook_url: string;
|
|
@@ -427,6 +445,22 @@ interface Webhook {
|
|
|
427
445
|
created_ts: string;
|
|
428
446
|
[key: string]: unknown;
|
|
429
447
|
}
|
|
448
|
+
/** One delivery to a registration, as `logs` lists it. */
|
|
449
|
+
interface WebhookDelivery {
|
|
450
|
+
/** Pass to `resend`. */
|
|
451
|
+
id: string;
|
|
452
|
+
webhook_url: string;
|
|
453
|
+
request_id: string;
|
|
454
|
+
event_type: string;
|
|
455
|
+
payload: unknown;
|
|
456
|
+
/** Your endpoint's HTTP status; null when it never answered. */
|
|
457
|
+
status_code: number | null;
|
|
458
|
+
/** The start of your endpoint's reply. */
|
|
459
|
+
response_body: string | null;
|
|
460
|
+
success: boolean;
|
|
461
|
+
created_ts: string;
|
|
462
|
+
[key: string]: unknown;
|
|
463
|
+
}
|
|
430
464
|
/** Your webhook registrations. One active registration per set of event types. */
|
|
431
465
|
declare class Webhooks {
|
|
432
466
|
private readonly client;
|
|
@@ -456,10 +490,30 @@ declare class Webhooks {
|
|
|
456
490
|
delete(webhookId: string, options?: {
|
|
457
491
|
signal?: AbortSignal;
|
|
458
492
|
}): Promise<Record<string, unknown>>;
|
|
459
|
-
/**
|
|
493
|
+
/** Every delivery made to one registration. */
|
|
460
494
|
logs(webhookId: string, options?: {
|
|
461
495
|
signal?: AbortSignal;
|
|
462
|
-
}): Promise<
|
|
496
|
+
}): Promise<WebhookDelivery[]>;
|
|
497
|
+
/**
|
|
498
|
+
* Sends a `WEBHOOK_TEST` delivery to an active registration. It goes out in
|
|
499
|
+
* the background after this returns, so read `logs` to see how your endpoint
|
|
500
|
+
* answered. Not retried: each attempt is another delivery.
|
|
501
|
+
*/
|
|
502
|
+
test(webhookId: string, options?: {
|
|
503
|
+
signal?: AbortSignal;
|
|
504
|
+
}): Promise<{
|
|
505
|
+
message: string;
|
|
506
|
+
}>;
|
|
507
|
+
/**
|
|
508
|
+
* Sends a past delivery's payload again, by its `id` from `logs`. Refused
|
|
509
|
+
* (406) when the registration is no longer active. Not retried: each
|
|
510
|
+
* attempt is another delivery.
|
|
511
|
+
*/
|
|
512
|
+
resend(deliveryId: string, options?: {
|
|
513
|
+
signal?: AbortSignal;
|
|
514
|
+
}): Promise<{
|
|
515
|
+
message: string;
|
|
516
|
+
}>;
|
|
463
517
|
private call;
|
|
464
518
|
}
|
|
465
519
|
|
|
@@ -752,7 +806,7 @@ declare class InferenceTimeout extends SegmindError {
|
|
|
752
806
|
constructor(requestId: string, elapsedMs: number);
|
|
753
807
|
}
|
|
754
808
|
|
|
755
|
-
declare const VERSION = "0.
|
|
809
|
+
declare const VERSION = "0.4.0";
|
|
756
810
|
|
|
757
811
|
/** `new Segmind().run(...)` with the key from `SEGMIND_API_KEY`. */
|
|
758
812
|
declare const run: (slug: string, params?: Params, options?: RunOptions) => Promise<RunResult>;
|
|
@@ -784,9 +838,9 @@ declare const files: Pick<Files, 'upload'>;
|
|
|
784
838
|
/** `new Segmind().generations` with the key from `SEGMIND_API_KEY`. */
|
|
785
839
|
declare const generations: Pick<Generations, 'list' | 'recent' | 'history' | 'get'>;
|
|
786
840
|
/** `new Segmind().webhooks` with the key from `SEGMIND_API_KEY`. */
|
|
787
|
-
declare const webhooks: Pick<Webhooks, 'get' | 'add' | 'update' | 'delete' | 'logs'>;
|
|
841
|
+
declare const webhooks: Pick<Webhooks, 'get' | 'add' | 'update' | 'delete' | 'logs' | 'test' | 'resend'>;
|
|
788
842
|
/** `new Segmind().pixelflows` with the key from `SEGMIND_API_KEY`. */
|
|
789
843
|
declare const pixelflows: Pick<PixelFlows, 'run' | 'submit' | 'getStatus' | 'poll'>;
|
|
790
844
|
|
|
791
845
|
export { APIConnectionError, Accounts, ChatResponse, DEFAULT_BASE_URL, DEFAULT_CONSOLE_URL, DEFAULT_SPOT_URL, DEFAULT_WAIT_INTERVAL_MS, DEFAULT_WAIT_TIMEOUT_MS, Files, Generations, InferenceFailed, InferenceTimeout, InsufficientCredits, Job, Models, PixelFlows, PixelflowJob, RateLimited, Segmind, SegmindError, VERSION, Webhooks, accounts, chat, chatSync, files, generations, imageUrl, job, models, pixelflows, run, runSync, submit, submitChat, webhooks };
|
|
792
|
-
export type { AccountCredits, CallOptions, ChatMessage, ChatParams, ClientOptions, FileInput, Generation, GenerationsListOptions, HistoryOptions, ImageInput, ImageUrlPart, Initiator, InitiatorOptions, JobState, JobStatus, ModelInfo, ModelInput, ModelListParams, ModelOutput, ModelSort, ModelsPage, Page, Params, PixelflowStatus, PixelflowSubmitOptions, PixelflowWaitOptions, PollInterval, RequestRecord, RunOptions, RunResult, SubmitOptions, SubmitResponse, TokenProvider, UploadOptions, UploadedFile, WaitOptions, Webhook, WebhookEventType };
|
|
846
|
+
export type { AccountCredits, CallOptions, ChatMessage, ChatParams, ClientOptions, FileInput, Generation, GenerationsListOptions, HistoryOptions, ImageInput, ImageUrlPart, Initiator, InitiatorOptions, JobState, JobStatus, ModelInfo, ModelInput, ModelListParams, ModelOutput, ModelSort, ModelsPage, Page, Params, PixelflowStatus, PixelflowSubmitOptions, PixelflowWaitOptions, PollInterval, RequestRecord, RunOptions, RunResult, SubmitOptions, SubmitResponse, TokenProvider, UploadOptions, UploadedFile, WaitOptions, Webhook, WebhookDelivery, WebhookEventType };
|
package/dist/index.js
CHANGED
|
@@ -598,6 +598,8 @@ var Generations = class {
|
|
|
598
598
|
to_date: options.toDate,
|
|
599
599
|
model_name: options.modelName,
|
|
600
600
|
status: options.status,
|
|
601
|
+
initiator: [options.initiator ?? []].flat().join(",") || void 0,
|
|
602
|
+
key_suffix: options.keySuffix,
|
|
601
603
|
user_id: options.userId,
|
|
602
604
|
user_email: options.userEmail,
|
|
603
605
|
sort_by: options.sortBy,
|
|
@@ -802,7 +804,7 @@ function failureDetail(body) {
|
|
|
802
804
|
}
|
|
803
805
|
|
|
804
806
|
// src/version.ts
|
|
805
|
-
var VERSION = "0.
|
|
807
|
+
var VERSION = "0.4.0";
|
|
806
808
|
|
|
807
809
|
// src/webhooks.ts
|
|
808
810
|
var Webhooks = class {
|
|
@@ -842,10 +844,26 @@ var Webhooks = class {
|
|
|
842
844
|
async delete(webhookId, options = {}) {
|
|
843
845
|
return this.call("DELETE", "/inactive", { query: { webhook_id: webhookId }, signal: options.signal });
|
|
844
846
|
}
|
|
845
|
-
/**
|
|
847
|
+
/** Every delivery made to one registration. */
|
|
846
848
|
async logs(webhookId, options = {}) {
|
|
847
849
|
return this.call("GET", "/dispatch-logs", { query: { webhook_id: webhookId }, signal: options.signal, retry: true });
|
|
848
850
|
}
|
|
851
|
+
/**
|
|
852
|
+
* Sends a `WEBHOOK_TEST` delivery to an active registration. It goes out in
|
|
853
|
+
* the background after this returns, so read `logs` to see how your endpoint
|
|
854
|
+
* answered. Not retried: each attempt is another delivery.
|
|
855
|
+
*/
|
|
856
|
+
async test(webhookId, options = {}) {
|
|
857
|
+
return this.call("POST", "/test", { body: { webhook_id: webhookId }, signal: options.signal });
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Sends a past delivery's payload again, by its `id` from `logs`. Refused
|
|
861
|
+
* (406) when the registration is no longer active. Not retried: each
|
|
862
|
+
* attempt is another delivery.
|
|
863
|
+
*/
|
|
864
|
+
async resend(deliveryId, options = {}) {
|
|
865
|
+
return this.call("POST", "/resend", { body: { webhook_dispatch_id: deliveryId }, signal: options.signal });
|
|
866
|
+
}
|
|
849
867
|
call(method, path2, req) {
|
|
850
868
|
return this.client.http.json({ method, url: `${this.client.spotURL}/webhook${path2}`, ...req });
|
|
851
869
|
}
|
|
@@ -1186,7 +1204,9 @@ var webhooks = {
|
|
|
1186
1204
|
add: (webhookUrl, eventTypes, options) => client().webhooks.add(webhookUrl, eventTypes, options),
|
|
1187
1205
|
update: (webhookId, webhookUrl, eventTypes, options) => client().webhooks.update(webhookId, webhookUrl, eventTypes, options),
|
|
1188
1206
|
delete: (webhookId, options) => client().webhooks.delete(webhookId, options),
|
|
1189
|
-
logs: (webhookId, options) => client().webhooks.logs(webhookId, options)
|
|
1207
|
+
logs: (webhookId, options) => client().webhooks.logs(webhookId, options),
|
|
1208
|
+
test: (webhookId, options) => client().webhooks.test(webhookId, options),
|
|
1209
|
+
resend: (deliveryId, options) => client().webhooks.resend(deliveryId, options)
|
|
1190
1210
|
};
|
|
1191
1211
|
var pixelflows = {
|
|
1192
1212
|
run: (slug, inputs, options) => client().pixelflows.run(slug, inputs, options),
|