segmind 0.3.0 → 0.5.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
@@ -135,13 +135,17 @@ const videoModels = await segmind.models.listAll({ output: 'video', sort: 'cheap
135
135
  ## Generations
136
136
 
137
137
  ```ts
138
- const page = await segmind.generations.list({ modelName: 'flux-schnell' });
138
+ const page = await segmind.generations.list({ modelName: 'flux-schnell', perPage: 50 });
139
+ const theirs = await segmind.generations.list({ userEmail: 'teammate@example.com' }); // inside a team
139
140
  const history = await segmind.generations.history({ status: 'FAILED', perPage: 50 }); // failures included
141
+ const fromKey = await segmind.generations.history({ keySuffix: 'a1b2c3', initiator: ['API', 'API_V2'] });
140
142
  const one = await segmind.generations.get(requestId);
141
143
  const latest = await segmind.generations.recent('flux-schnell');
142
144
  ```
143
145
 
144
- `history` lists one row per output, each with the request's full cost: de-duplicate on `request_id` before summing `credits_deduction`.
146
+ `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.
147
+
148
+ Inside a team, `list` and `history` narrow to one member with `userId` or `userEmail`, one or the other; outside a team only your own id or email is accepted.
145
149
 
146
150
  ## Webhooks
147
151
 
@@ -149,12 +153,16 @@ const latest = await segmind.generations.recent('flux-schnell');
149
153
  const hook = await segmind.webhooks.add('https://example.com/hooks/segmind', ['PIXELFLOW']);
150
154
  const hooks = await segmind.webhooks.get(); // each with its signing_secret
151
155
  await segmind.webhooks.update(hook.id, 'https://example.com/hooks/v2'); // URL only
152
- await segmind.webhooks.logs(hook.id);
156
+ await segmind.webhooks.test(hook.id); // a WEBHOOK_TEST delivery
157
+ const deliveries = await segmind.webhooks.logs(hook.id);
158
+ await segmind.webhooks.resend(deliveries[0].id); // that payload again
153
159
  await segmind.webhooks.delete(hook.id);
154
160
  ```
155
161
 
156
162
  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
163
 
164
+ `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.
165
+
158
166
  ## PixelFlow workflows
159
167
 
160
168
  ```ts
package/dist/index.cjs CHANGED
@@ -646,10 +646,12 @@ var Generations = class {
646
646
  async list(options = {}) {
647
647
  return this.read("/inference-request/generations", options.signal, {
648
648
  page: options.page ?? 1,
649
+ per_page: options.perPage,
649
650
  model_name: options.modelName,
650
651
  start_date: options.startDate,
651
652
  end_date: options.endDate,
652
- user_id: options.userId
653
+ user_id: options.userId,
654
+ user_email: options.userEmail
653
655
  });
654
656
  }
655
657
  /** The newest generations for one model. */
@@ -669,6 +671,8 @@ var Generations = class {
669
671
  to_date: options.toDate,
670
672
  model_name: options.modelName,
671
673
  status: options.status,
674
+ initiator: [options.initiator ?? []].flat().join(",") || void 0,
675
+ key_suffix: options.keySuffix,
672
676
  user_id: options.userId,
673
677
  user_email: options.userEmail,
674
678
  sort_by: options.sortBy,
@@ -873,7 +877,7 @@ function failureDetail(body) {
873
877
  }
874
878
 
875
879
  // src/version.ts
876
- var VERSION = "0.3.0";
880
+ var VERSION = "0.5.0";
877
881
 
878
882
  // src/webhooks.ts
879
883
  var Webhooks = class {
@@ -913,10 +917,26 @@ var Webhooks = class {
913
917
  async delete(webhookId, options = {}) {
914
918
  return this.call("DELETE", "/inactive", { query: { webhook_id: webhookId }, signal: options.signal });
915
919
  }
916
- /** Delivery history for one registration. */
920
+ /** Every delivery made to one registration. */
917
921
  async logs(webhookId, options = {}) {
918
922
  return this.call("GET", "/dispatch-logs", { query: { webhook_id: webhookId }, signal: options.signal, retry: true });
919
923
  }
924
+ /**
925
+ * Sends a `WEBHOOK_TEST` delivery to an active registration. It goes out in
926
+ * the background after this returns, so read `logs` to see how your endpoint
927
+ * answered. Not retried: each attempt is another delivery.
928
+ */
929
+ async test(webhookId, options = {}) {
930
+ return this.call("POST", "/test", { body: { webhook_id: webhookId }, signal: options.signal });
931
+ }
932
+ /**
933
+ * Sends a past delivery's payload again, by its `id` from `logs`. Refused
934
+ * (406) when the registration is no longer active. Not retried: each
935
+ * attempt is another delivery.
936
+ */
937
+ async resend(deliveryId, options = {}) {
938
+ return this.call("POST", "/resend", { body: { webhook_dispatch_id: deliveryId }, signal: options.signal });
939
+ }
920
940
  call(method, path2, req) {
921
941
  return this.client.http.json({ method, url: `${this.client.spotURL}/webhook${path2}`, ...req });
922
942
  }
@@ -1257,7 +1277,9 @@ var webhooks = {
1257
1277
  add: (webhookUrl, eventTypes, options) => client().webhooks.add(webhookUrl, eventTypes, options),
1258
1278
  update: (webhookId, webhookUrl, eventTypes, options) => client().webhooks.update(webhookId, webhookUrl, eventTypes, options),
1259
1279
  delete: (webhookId, options) => client().webhooks.delete(webhookId, options),
1260
- logs: (webhookId, options) => client().webhooks.logs(webhookId, options)
1280
+ logs: (webhookId, options) => client().webhooks.logs(webhookId, options),
1281
+ test: (webhookId, options) => client().webhooks.test(webhookId, options),
1282
+ resend: (deliveryId, options) => client().webhooks.resend(deliveryId, options)
1261
1283
  };
1262
1284
  var pixelflows = {
1263
1285
  run: (slug, inputs, options) => client().pixelflows.run(slug, inputs, options),