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 CHANGED
@@ -137,11 +137,12 @@ const videoModels = await segmind.models.listAll({ output: 'video', sort: 'cheap
137
137
  ```ts
138
138
  const page = await segmind.generations.list({ modelName: 'flux-schnell' });
139
139
  const history = await segmind.generations.history({ status: 'FAILED', perPage: 50 }); // failures included
140
+ const fromKey = await segmind.generations.history({ keySuffix: 'a1b2c3', initiator: ['API', 'API_V2'] });
140
141
  const one = await segmind.generations.get(requestId);
141
142
  const latest = await segmind.generations.recent('flux-schnell');
142
143
  ```
143
144
 
144
- `history` lists one row per output, each with the request's full cost: de-duplicate on `request_id` before summing `credits_deduction`.
145
+ `history` lists one row per output, each with the request's full cost: de-duplicate on `request_id` before summing `credits_deduction`. Each row carries its `initiator` and the `key_mask` of the key that made it. Filter by key with `keySuffix`, the last 6 characters of the key: the full key is never sent.
145
146
 
146
147
  ## Webhooks
147
148
 
@@ -149,12 +150,16 @@ const latest = await segmind.generations.recent('flux-schnell');
149
150
  const hook = await segmind.webhooks.add('https://example.com/hooks/segmind', ['PIXELFLOW']);
150
151
  const hooks = await segmind.webhooks.get(); // each with its signing_secret
151
152
  await segmind.webhooks.update(hook.id, 'https://example.com/hooks/v2'); // URL only
152
- await segmind.webhooks.logs(hook.id);
153
+ await segmind.webhooks.test(hook.id); // a WEBHOOK_TEST delivery
154
+ const deliveries = await segmind.webhooks.logs(hook.id);
155
+ await segmind.webhooks.resend(deliveries[0].id); // that payload again
153
156
  await segmind.webhooks.delete(hook.id);
154
157
  ```
155
158
 
156
159
  Event types are subscription types: `PIXELFLOW` for PixelFlow runs, plus `WORKFLOW`, `INFERENCE` and `FINETUNE`. `update` changes the URL only; to change the event types, `delete` the registration and `add` a new one. Before 0.2.4, `update` registered a second hook and `delete` deactivated nothing, so check `webhooks.get()` for registrations left behind.
157
160
 
161
+ `test` and `resend` each send a real delivery, in the background after they return: read `logs` to see how your endpoint answered. Neither is retried, since every attempt is another delivery.
162
+
158
163
  ## PixelFlow workflows
159
164
 
160
165
  ```ts
package/dist/index.cjs CHANGED
@@ -669,6 +669,8 @@ var Generations = class {
669
669
  to_date: options.toDate,
670
670
  model_name: options.modelName,
671
671
  status: options.status,
672
+ initiator: [options.initiator ?? []].flat().join(",") || void 0,
673
+ key_suffix: options.keySuffix,
672
674
  user_id: options.userId,
673
675
  user_email: options.userEmail,
674
676
  sort_by: options.sortBy,
@@ -873,7 +875,7 @@ function failureDetail(body) {
873
875
  }
874
876
 
875
877
  // src/version.ts
876
- var VERSION = "0.3.0";
878
+ var VERSION = "0.4.0";
877
879
 
878
880
  // src/webhooks.ts
879
881
  var Webhooks = class {
@@ -913,10 +915,26 @@ var Webhooks = class {
913
915
  async delete(webhookId, options = {}) {
914
916
  return this.call("DELETE", "/inactive", { query: { webhook_id: webhookId }, signal: options.signal });
915
917
  }
916
- /** Delivery history for one registration. */
918
+ /** Every delivery made to one registration. */
917
919
  async logs(webhookId, options = {}) {
918
920
  return this.call("GET", "/dispatch-logs", { query: { webhook_id: webhookId }, signal: options.signal, retry: true });
919
921
  }
922
+ /**
923
+ * Sends a `WEBHOOK_TEST` delivery to an active registration. It goes out in
924
+ * the background after this returns, so read `logs` to see how your endpoint
925
+ * answered. Not retried: each attempt is another delivery.
926
+ */
927
+ async test(webhookId, options = {}) {
928
+ return this.call("POST", "/test", { body: { webhook_id: webhookId }, signal: options.signal });
929
+ }
930
+ /**
931
+ * Sends a past delivery's payload again, by its `id` from `logs`. Refused
932
+ * (406) when the registration is no longer active. Not retried: each
933
+ * attempt is another delivery.
934
+ */
935
+ async resend(deliveryId, options = {}) {
936
+ return this.call("POST", "/resend", { body: { webhook_dispatch_id: deliveryId }, signal: options.signal });
937
+ }
920
938
  call(method, path2, req) {
921
939
  return this.client.http.json({ method, url: `${this.client.spotURL}/webhook${path2}`, ...req });
922
940
  }
@@ -1257,7 +1275,9 @@ var webhooks = {
1257
1275
  add: (webhookUrl, eventTypes, options) => client().webhooks.add(webhookUrl, eventTypes, options),
1258
1276
  update: (webhookId, webhookUrl, eventTypes, options) => client().webhooks.update(webhookId, webhookUrl, eventTypes, options),
1259
1277
  delete: (webhookId, options) => client().webhooks.delete(webhookId, options),
1260
- logs: (webhookId, options) => client().webhooks.logs(webhookId, options)
1278
+ logs: (webhookId, options) => client().webhooks.logs(webhookId, options),
1279
+ test: (webhookId, options) => client().webhooks.test(webhookId, options),
1280
+ resend: (deliveryId, options) => client().webhooks.resend(deliveryId, options)
1261
1281
  };
1262
1282
  var pixelflows = {
1263
1283
  run: (slug, inputs, options) => client().pixelflows.run(slug, inputs, options),