@scenario-labs/sdk 0.3.0 → 1.0.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.
Files changed (180) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +40 -6
  3. package/client.d.mts +34 -14
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +34 -14
  6. package/client.d.ts.map +1 -1
  7. package/client.js +10 -0
  8. package/client.js.map +1 -1
  9. package/client.mjs +10 -0
  10. package/client.mjs.map +1 -1
  11. package/core/pagination.d.mts +153 -0
  12. package/core/pagination.d.mts.map +1 -0
  13. package/core/pagination.d.ts +153 -0
  14. package/core/pagination.d.ts.map +1 -0
  15. package/core/pagination.js +276 -0
  16. package/core/pagination.js.map +1 -0
  17. package/core/pagination.mjs +263 -0
  18. package/core/pagination.mjs.map +1 -0
  19. package/index.d.mts +2 -0
  20. package/index.d.mts.map +1 -1
  21. package/index.d.ts +2 -0
  22. package/index.d.ts.map +1 -1
  23. package/index.js +7 -1
  24. package/index.js.map +1 -1
  25. package/index.mjs +2 -0
  26. package/index.mjs.map +1 -1
  27. package/lib/models.d.mts +34 -2
  28. package/lib/models.d.mts.map +1 -1
  29. package/lib/models.d.ts +34 -2
  30. package/lib/models.d.ts.map +1 -1
  31. package/lib/models.js +39 -2
  32. package/lib/models.js.map +1 -1
  33. package/lib/models.mjs +37 -1
  34. package/lib/models.mjs.map +1 -1
  35. package/lib/scenario.d.mts +2 -0
  36. package/lib/scenario.d.mts.map +1 -1
  37. package/lib/scenario.d.ts +2 -0
  38. package/lib/scenario.d.ts.map +1 -1
  39. package/lib/scenario.js +2 -0
  40. package/lib/scenario.js.map +1 -1
  41. package/lib/scenario.mjs +2 -0
  42. package/lib/scenario.mjs.map +1 -1
  43. package/lib/upload.d.mts +89 -0
  44. package/lib/upload.d.mts.map +1 -0
  45. package/lib/upload.d.ts +89 -0
  46. package/lib/upload.d.ts.map +1 -0
  47. package/lib/upload.js +193 -0
  48. package/lib/upload.js.map +1 -0
  49. package/lib/upload.mjs +156 -0
  50. package/lib/upload.mjs.map +1 -0
  51. package/lib/workflow.d.mts +13 -2
  52. package/lib/workflow.d.mts.map +1 -1
  53. package/lib/workflow.d.ts +13 -2
  54. package/lib/workflow.d.ts.map +1 -1
  55. package/lib/workflow.js +17 -4
  56. package/lib/workflow.js.map +1 -1
  57. package/lib/workflow.mjs +17 -4
  58. package/lib/workflow.mjs.map +1 -1
  59. package/lib/workflow_import_validator.d.mts +40 -0
  60. package/lib/workflow_import_validator.d.mts.map +1 -0
  61. package/lib/workflow_import_validator.d.ts +40 -0
  62. package/lib/workflow_import_validator.d.ts.map +1 -0
  63. package/lib/workflow_import_validator.js +69 -0
  64. package/lib/workflow_import_validator.js.map +1 -0
  65. package/lib/workflow_import_validator.mjs +64 -0
  66. package/lib/workflow_import_validator.mjs.map +1 -0
  67. package/package.json +11 -1
  68. package/pagination.d.mts +2 -0
  69. package/pagination.d.mts.map +1 -0
  70. package/pagination.d.ts +2 -0
  71. package/pagination.d.ts.map +1 -0
  72. package/pagination.js +6 -0
  73. package/pagination.js.map +1 -0
  74. package/pagination.mjs +2 -0
  75. package/pagination.mjs.map +1 -0
  76. package/resources/assets/assets.d.mts +623 -646
  77. package/resources/assets/assets.d.mts.map +1 -1
  78. package/resources/assets/assets.d.ts +623 -646
  79. package/resources/assets/assets.d.ts.map +1 -1
  80. package/resources/assets/assets.js +3 -2
  81. package/resources/assets/assets.js.map +1 -1
  82. package/resources/assets/assets.mjs +3 -2
  83. package/resources/assets/assets.mjs.map +1 -1
  84. package/resources/assets/index.d.mts +1 -1
  85. package/resources/assets/index.d.mts.map +1 -1
  86. package/resources/assets/index.d.ts +1 -1
  87. package/resources/assets/index.d.ts.map +1 -1
  88. package/resources/assets/index.js.map +1 -1
  89. package/resources/assets/index.mjs.map +1 -1
  90. package/resources/collections/collections.d.mts +38 -49
  91. package/resources/collections/collections.d.mts.map +1 -1
  92. package/resources/collections/collections.d.ts +38 -49
  93. package/resources/collections/collections.d.ts.map +1 -1
  94. package/resources/collections/collections.js +5 -1
  95. package/resources/collections/collections.js.map +1 -1
  96. package/resources/collections/collections.mjs +5 -1
  97. package/resources/collections/collections.mjs.map +1 -1
  98. package/resources/collections/index.d.mts +1 -1
  99. package/resources/collections/index.d.mts.map +1 -1
  100. package/resources/collections/index.d.ts +1 -1
  101. package/resources/collections/index.d.ts.map +1 -1
  102. package/resources/collections/index.js.map +1 -1
  103. package/resources/collections/index.mjs.map +1 -1
  104. package/resources/index.d.mts +7 -7
  105. package/resources/index.d.mts.map +1 -1
  106. package/resources/index.d.ts +7 -7
  107. package/resources/index.d.ts.map +1 -1
  108. package/resources/index.js.map +1 -1
  109. package/resources/index.mjs.map +1 -1
  110. package/resources/jobs.d.mts +369 -380
  111. package/resources/jobs.d.mts.map +1 -1
  112. package/resources/jobs.d.ts +369 -380
  113. package/resources/jobs.d.ts.map +1 -1
  114. package/resources/jobs.js +2 -1
  115. package/resources/jobs.js.map +1 -1
  116. package/resources/jobs.mjs +2 -1
  117. package/resources/jobs.mjs.map +1 -1
  118. package/resources/models/index.d.mts +1 -1
  119. package/resources/models/index.d.mts.map +1 -1
  120. package/resources/models/index.d.ts +1 -1
  121. package/resources/models/index.d.ts.map +1 -1
  122. package/resources/models/index.js.map +1 -1
  123. package/resources/models/index.mjs.map +1 -1
  124. package/resources/models/models.d.mts +839 -850
  125. package/resources/models/models.d.mts.map +1 -1
  126. package/resources/models/models.d.ts +839 -850
  127. package/resources/models/models.d.ts.map +1 -1
  128. package/resources/models/models.js +2 -1
  129. package/resources/models/models.js.map +1 -1
  130. package/resources/models/models.mjs +2 -1
  131. package/resources/models/models.mjs.map +1 -1
  132. package/resources/search.d.mts +215 -295
  133. package/resources/search.d.mts.map +1 -1
  134. package/resources/search.d.ts +215 -295
  135. package/resources/search.d.ts.map +1 -1
  136. package/resources/search.js +9 -2
  137. package/resources/search.js.map +1 -1
  138. package/resources/search.mjs +9 -2
  139. package/resources/search.mjs.map +1 -1
  140. package/resources/tags.d.mts +23 -35
  141. package/resources/tags.d.mts.map +1 -1
  142. package/resources/tags.d.ts +23 -35
  143. package/resources/tags.d.ts.map +1 -1
  144. package/resources/tags.js +2 -1
  145. package/resources/tags.js.map +1 -1
  146. package/resources/tags.mjs +2 -1
  147. package/resources/tags.mjs.map +1 -1
  148. package/resources/workflows.d.mts +688 -704
  149. package/resources/workflows.d.mts.map +1 -1
  150. package/resources/workflows.d.ts +688 -704
  151. package/resources/workflows.d.ts.map +1 -1
  152. package/resources/workflows.js +5 -1
  153. package/resources/workflows.js.map +1 -1
  154. package/resources/workflows.mjs +5 -1
  155. package/resources/workflows.mjs.map +1 -1
  156. package/src/client.ts +103 -2
  157. package/src/core/pagination.ts +497 -0
  158. package/src/index.ts +8 -0
  159. package/src/lib/models.ts +62 -2
  160. package/src/lib/scenario.ts +2 -0
  161. package/src/lib/upload.ts +250 -0
  162. package/src/lib/workflow.ts +29 -4
  163. package/src/lib/workflow_import_validator.ts +104 -0
  164. package/src/pagination.ts +2 -0
  165. package/src/resources/assets/assets.ts +887 -902
  166. package/src/resources/assets/index.ts +2 -0
  167. package/src/resources/collections/collections.ts +45 -54
  168. package/src/resources/collections/index.ts +1 -0
  169. package/src/resources/index.ts +9 -1
  170. package/src/resources/jobs.ts +613 -622
  171. package/src/resources/models/index.ts +1 -0
  172. package/src/resources/models/models.ts +1052 -1064
  173. package/src/resources/search.ts +239 -327
  174. package/src/resources/tags.ts +32 -39
  175. package/src/resources/workflows.ts +850 -864
  176. package/src/version.ts +1 -1
  177. package/version.d.mts +1 -1
  178. package/version.d.ts +1 -1
  179. package/version.js +1 -1
  180. package/version.mjs +1 -1
package/lib/models.d.mts CHANGED
@@ -1,8 +1,37 @@
1
1
  import type { APIPromise } from "../core/api-promise.mjs";
2
2
  import type { RequestOptions } from "../internal/request-options.mjs";
3
- import { Models } from "../resources/models/models.mjs";
3
+ import type { GenerateRunModelParams, GenerateRunModelResponse } from "../resources/generate.mjs";
4
+ import { Models, type ModelRetrieveParams, type ModelRetrieveResponse } from "../resources/models/models.mjs";
4
5
  import { Train, type TrainTriggerParams, type TrainTriggerResponse } from "../resources/models/train.mjs";
5
6
  import { type WithJob } from "./job.mjs";
7
+ import type { Scenario } from "./scenario.mjs";
8
+ /**
9
+ * Enhanced Model entity with helper methods.
10
+ * Has all original model fields plus `.run()`.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const { model } = await client.models.retrieve(modelId);
15
+ * const gen = await model.run({ body: { prompt: 'a red car' } });
16
+ * const completed = await gen.job.wait();
17
+ * ```
18
+ */
19
+ export declare class ModelEntity {
20
+ /** @internal */ readonly _client: Scenario;
21
+ /**
22
+ * Generate with this model. Shortcut for
23
+ * `client.generate.runModel(this.id, params)`.
24
+ *
25
+ * Returns an enhanced response where `response.job` has `.wait()`.
26
+ */
27
+ run(this: ModelEntity & ModelRetrieveResponse.Model, params: GenerateRunModelParams, options?: RequestOptions): APIPromise<WithJob<GenerateRunModelResponse>>;
28
+ /** @internal Create a ModelEntity wrapping raw model data. */
29
+ static from(client: Scenario, data: ModelRetrieveResponse.Model): ModelRetrieveResponse.Model & ModelEntity;
30
+ }
31
+ /** Enhanced retrieve response where `model` has `.run()` on top of its original fields. */
32
+ export type EnhancedModelRetrieveResponse = Omit<ModelRetrieveResponse, 'model'> & {
33
+ model: ModelRetrieveResponse.Model & ModelEntity;
34
+ };
6
35
  /**
7
36
  * Enhanced Train resource.
8
37
  * `trigger()` returns a response where `job` has `.wait()`.
@@ -12,9 +41,12 @@ export declare class EnhancedTrain extends Train {
12
41
  }
13
42
  /**
14
43
  * Enhanced Models resource.
15
- * All original methods inherited. `train` is an {@link EnhancedTrain}.
44
+ * All original methods inherited.
45
+ * - `train` is an {@link EnhancedTrain}
46
+ * - `retrieve()` returns a response where `model` has `.run()`
16
47
  */
17
48
  export declare class EnhancedModels extends Models {
18
49
  train: EnhancedTrain;
50
+ retrieve(modelID: string, query?: ModelRetrieveParams | null | undefined, options?: RequestOptions): APIPromise<EnhancedModelRetrieveResponse>;
19
51
  }
20
52
  //# sourceMappingURL=models.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.mts","sourceRoot":"","sources":["../src/lib/models.ts"],"names":[],"mappings":"OAAO,KAAK,EAAE,UAAU,EAAE;OACnB,KAAK,EAAE,cAAc,EAAE;OACvB,EAAE,MAAM,EAAE;OACV,EAAE,KAAK,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE;OAC7D,EAAE,KAAK,OAAO,EAAc;AAEnC;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;IAC7B,OAAO,CACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,kBAAkB,EAC1B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAG7C;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,MAAM;IAC/B,KAAK,EAAE,aAAa,CAAmC;CACjE"}
1
+ {"version":3,"file":"models.d.mts","sourceRoot":"","sources":["../src/lib/models.ts"],"names":[],"mappings":"OAAO,KAAK,EAAE,UAAU,EAAE;OACnB,KAAK,EAAE,cAAc,EAAE;OACvB,KAAK,EAAE,sBAAsB,EAAE,wBAAwB,EAAE;OACzD,EAAE,MAAM,EAAE,KAAK,mBAAmB,EAAE,KAAK,qBAAqB,EAAE;OAChE,EAAE,KAAK,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE;OAC7D,EAAE,KAAK,OAAO,EAAc;OAE5B,KAAK,EAAE,QAAQ,EAAE;AAExB;;;;;;;;;;GAUG;AACH,qBAAa,WAAW;IACtB,gBAAgB,CAAC,SAAiB,OAAO,EAAE,QAAQ,CAAC;IAEpD;;;;;OAKG;IACH,GAAG,CACD,IAAI,EAAE,WAAW,GAAG,qBAAqB,CAAC,KAAK,EAC/C,MAAM,EAAE,sBAAsB,EAC9B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAIhD,8DAA8D;IAC9D,MAAM,CAAC,IAAI,CACT,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,qBAAqB,CAAC,KAAK,GAChC,qBAAqB,CAAC,KAAK,GAAG,WAAW;CAK7C;AAED,2FAA2F;AAC3F,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC,GAAG;IACjF,KAAK,EAAE,qBAAqB,CAAC,KAAK,GAAG,WAAW,CAAC;CAClD,CAAC;AAEF;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;IAC7B,OAAO,CACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,kBAAkB,EAC1B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAG7C;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,MAAM;IAC/B,KAAK,EAAE,aAAa,CAAmC;IAEvD,QAAQ,CACf,OAAO,EAAE,MAAM,EACf,KAAK,GAAE,mBAAmB,GAAG,IAAI,GAAG,SAAc,EAClD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,6BAA6B,CAAC;CAM7C"}
package/lib/models.d.ts CHANGED
@@ -1,8 +1,37 @@
1
1
  import type { APIPromise } from "../core/api-promise.js";
2
2
  import type { RequestOptions } from "../internal/request-options.js";
3
- import { Models } from "../resources/models/models.js";
3
+ import type { GenerateRunModelParams, GenerateRunModelResponse } from "../resources/generate.js";
4
+ import { Models, type ModelRetrieveParams, type ModelRetrieveResponse } from "../resources/models/models.js";
4
5
  import { Train, type TrainTriggerParams, type TrainTriggerResponse } from "../resources/models/train.js";
5
6
  import { type WithJob } from "./job.js";
7
+ import type { Scenario } from "./scenario.js";
8
+ /**
9
+ * Enhanced Model entity with helper methods.
10
+ * Has all original model fields plus `.run()`.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const { model } = await client.models.retrieve(modelId);
15
+ * const gen = await model.run({ body: { prompt: 'a red car' } });
16
+ * const completed = await gen.job.wait();
17
+ * ```
18
+ */
19
+ export declare class ModelEntity {
20
+ /** @internal */ readonly _client: Scenario;
21
+ /**
22
+ * Generate with this model. Shortcut for
23
+ * `client.generate.runModel(this.id, params)`.
24
+ *
25
+ * Returns an enhanced response where `response.job` has `.wait()`.
26
+ */
27
+ run(this: ModelEntity & ModelRetrieveResponse.Model, params: GenerateRunModelParams, options?: RequestOptions): APIPromise<WithJob<GenerateRunModelResponse>>;
28
+ /** @internal Create a ModelEntity wrapping raw model data. */
29
+ static from(client: Scenario, data: ModelRetrieveResponse.Model): ModelRetrieveResponse.Model & ModelEntity;
30
+ }
31
+ /** Enhanced retrieve response where `model` has `.run()` on top of its original fields. */
32
+ export type EnhancedModelRetrieveResponse = Omit<ModelRetrieveResponse, 'model'> & {
33
+ model: ModelRetrieveResponse.Model & ModelEntity;
34
+ };
6
35
  /**
7
36
  * Enhanced Train resource.
8
37
  * `trigger()` returns a response where `job` has `.wait()`.
@@ -12,9 +41,12 @@ export declare class EnhancedTrain extends Train {
12
41
  }
13
42
  /**
14
43
  * Enhanced Models resource.
15
- * All original methods inherited. `train` is an {@link EnhancedTrain}.
44
+ * All original methods inherited.
45
+ * - `train` is an {@link EnhancedTrain}
46
+ * - `retrieve()` returns a response where `model` has `.run()`
16
47
  */
17
48
  export declare class EnhancedModels extends Models {
18
49
  train: EnhancedTrain;
50
+ retrieve(modelID: string, query?: ModelRetrieveParams | null | undefined, options?: RequestOptions): APIPromise<EnhancedModelRetrieveResponse>;
19
51
  }
20
52
  //# sourceMappingURL=models.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/lib/models.ts"],"names":[],"mappings":"OAAO,KAAK,EAAE,UAAU,EAAE;OACnB,KAAK,EAAE,cAAc,EAAE;OACvB,EAAE,MAAM,EAAE;OACV,EAAE,KAAK,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE;OAC7D,EAAE,KAAK,OAAO,EAAc;AAEnC;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;IAC7B,OAAO,CACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,kBAAkB,EAC1B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAG7C;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,MAAM;IAC/B,KAAK,EAAE,aAAa,CAAmC;CACjE"}
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/lib/models.ts"],"names":[],"mappings":"OAAO,KAAK,EAAE,UAAU,EAAE;OACnB,KAAK,EAAE,cAAc,EAAE;OACvB,KAAK,EAAE,sBAAsB,EAAE,wBAAwB,EAAE;OACzD,EAAE,MAAM,EAAE,KAAK,mBAAmB,EAAE,KAAK,qBAAqB,EAAE;OAChE,EAAE,KAAK,EAAE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE;OAC7D,EAAE,KAAK,OAAO,EAAc;OAE5B,KAAK,EAAE,QAAQ,EAAE;AAExB;;;;;;;;;;GAUG;AACH,qBAAa,WAAW;IACtB,gBAAgB,CAAC,SAAiB,OAAO,EAAE,QAAQ,CAAC;IAEpD;;;;;OAKG;IACH,GAAG,CACD,IAAI,EAAE,WAAW,GAAG,qBAAqB,CAAC,KAAK,EAC/C,MAAM,EAAE,sBAAsB,EAC9B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAIhD,8DAA8D;IAC9D,MAAM,CAAC,IAAI,CACT,MAAM,EAAE,QAAQ,EAChB,IAAI,EAAE,qBAAqB,CAAC,KAAK,GAChC,qBAAqB,CAAC,KAAK,GAAG,WAAW;CAK7C;AAED,2FAA2F;AAC3F,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC,GAAG;IACjF,KAAK,EAAE,qBAAqB,CAAC,KAAK,GAAG,WAAW,CAAC;CAClD,CAAC;AAEF;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;IAC7B,OAAO,CACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,kBAAkB,EAC1B,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAG7C;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,MAAM;IAC/B,KAAK,EAAE,aAAa,CAAmC;IAEvD,QAAQ,CACf,OAAO,EAAE,MAAM,EACf,KAAK,GAAE,mBAAmB,GAAG,IAAI,GAAG,SAAc,EAClD,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,6BAA6B,CAAC;CAM7C"}
package/lib/models.js CHANGED
@@ -1,9 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnhancedModels = exports.EnhancedTrain = void 0;
3
+ exports.EnhancedModels = exports.EnhancedTrain = exports.ModelEntity = void 0;
4
4
  const models_1 = require("../resources/models/models.js");
5
5
  const train_1 = require("../resources/models/train.js");
6
6
  const job_1 = require("./job.js");
7
+ /**
8
+ * Enhanced Model entity with helper methods.
9
+ * Has all original model fields plus `.run()`.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const { model } = await client.models.retrieve(modelId);
14
+ * const gen = await model.run({ body: { prompt: 'a red car' } });
15
+ * const completed = await gen.job.wait();
16
+ * ```
17
+ */
18
+ class ModelEntity {
19
+ /**
20
+ * Generate with this model. Shortcut for
21
+ * `client.generate.runModel(this.id, params)`.
22
+ *
23
+ * Returns an enhanced response where `response.job` has `.wait()`.
24
+ */
25
+ run(params, options) {
26
+ return this._client.generate.runModel(this.id, params, options);
27
+ }
28
+ /** @internal Create a ModelEntity wrapping raw model data. */
29
+ static from(client, data) {
30
+ const entity = Object.assign(Object.create(ModelEntity.prototype), data);
31
+ Object.defineProperty(entity, '_client', { value: client, enumerable: false });
32
+ return entity;
33
+ }
34
+ }
35
+ exports.ModelEntity = ModelEntity;
7
36
  /**
8
37
  * Enhanced Train resource.
9
38
  * `trigger()` returns a response where `job` has `.wait()`.
@@ -16,13 +45,21 @@ class EnhancedTrain extends train_1.Train {
16
45
  exports.EnhancedTrain = EnhancedTrain;
17
46
  /**
18
47
  * Enhanced Models resource.
19
- * All original methods inherited. `train` is an {@link EnhancedTrain}.
48
+ * All original methods inherited.
49
+ * - `train` is an {@link EnhancedTrain}
50
+ * - `retrieve()` returns a response where `model` has `.run()`
20
51
  */
21
52
  class EnhancedModels extends models_1.Models {
22
53
  constructor() {
23
54
  super(...arguments);
24
55
  this.train = new EnhancedTrain(this._client);
25
56
  }
57
+ retrieve(modelID, query = {}, options) {
58
+ return super.retrieve(modelID, query, options)._thenUnwrap((data) => ({
59
+ ...data,
60
+ model: ModelEntity.from(this._client, data.model),
61
+ }));
62
+ }
26
63
  }
27
64
  exports.EnhancedModels = EnhancedModels;
28
65
  //# sourceMappingURL=models.js.map
package/lib/models.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../src/lib/models.ts"],"names":[],"mappings":";;;AAEA,0DAAoD;AACpD,wDAAsG;AACtG,kCAAiD;AAEjD;;;GAGG;AACH,MAAa,aAAc,SAAQ,aAAK;IAC7B,OAAO,CACd,OAAe,EACf,MAA0B,EAC1B,OAAwB;QAExB,OAAO,IAAA,gBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;CACF;AARD,sCAQC;AAED;;;GAGG;AACH,MAAa,cAAe,SAAQ,eAAM;IAA1C;;QACW,UAAK,GAAkB,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClE,CAAC;CAAA;AAFD,wCAEC"}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../src/lib/models.ts"],"names":[],"mappings":";;;AAGA,0DAA0G;AAC1G,wDAAsG;AACtG,kCAAiD;AAIjD;;;;;;;;;;GAUG;AACH,MAAa,WAAW;IAGtB;;;;;OAKG;IACH,GAAG,CAED,MAA8B,EAC9B,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;IAED,8DAA8D;IAC9D,MAAM,CAAC,IAAI,CACT,MAAgB,EAChB,IAAiC;QAEjC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC;QACzE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/E,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA1BD,kCA0BC;AAOD;;;GAGG;AACH,MAAa,aAAc,SAAQ,aAAK;IAC7B,OAAO,CACd,OAAe,EACf,MAA0B,EAC1B,OAAwB;QAExB,OAAO,IAAA,gBAAU,EAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;CACF;AARD,sCAQC;AAED;;;;;GAKG;AACH,MAAa,cAAe,SAAQ,eAAM;IAA1C;;QACW,UAAK,GAAkB,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAYlE,CAAC;IAVU,QAAQ,CACf,OAAe,EACf,QAAgD,EAAE,EAClD,OAAwB;QAExB,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACpE,GAAG,IAAI;YACP,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,OAAmB,EAAE,IAAI,CAAC,KAAK,CAAC;SAC9D,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AAbD,wCAaC"}
package/lib/models.mjs CHANGED
@@ -1,6 +1,34 @@
1
1
  import { Models } from "../resources/models/models.mjs";
2
2
  import { Train } from "../resources/models/train.mjs";
3
3
  import { enhanceJob } from "./job.mjs";
4
+ /**
5
+ * Enhanced Model entity with helper methods.
6
+ * Has all original model fields plus `.run()`.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const { model } = await client.models.retrieve(modelId);
11
+ * const gen = await model.run({ body: { prompt: 'a red car' } });
12
+ * const completed = await gen.job.wait();
13
+ * ```
14
+ */
15
+ export class ModelEntity {
16
+ /**
17
+ * Generate with this model. Shortcut for
18
+ * `client.generate.runModel(this.id, params)`.
19
+ *
20
+ * Returns an enhanced response where `response.job` has `.wait()`.
21
+ */
22
+ run(params, options) {
23
+ return this._client.generate.runModel(this.id, params, options);
24
+ }
25
+ /** @internal Create a ModelEntity wrapping raw model data. */
26
+ static from(client, data) {
27
+ const entity = Object.assign(Object.create(ModelEntity.prototype), data);
28
+ Object.defineProperty(entity, '_client', { value: client, enumerable: false });
29
+ return entity;
30
+ }
31
+ }
4
32
  /**
5
33
  * Enhanced Train resource.
6
34
  * `trigger()` returns a response where `job` has `.wait()`.
@@ -12,12 +40,20 @@ export class EnhancedTrain extends Train {
12
40
  }
13
41
  /**
14
42
  * Enhanced Models resource.
15
- * All original methods inherited. `train` is an {@link EnhancedTrain}.
43
+ * All original methods inherited.
44
+ * - `train` is an {@link EnhancedTrain}
45
+ * - `retrieve()` returns a response where `model` has `.run()`
16
46
  */
17
47
  export class EnhancedModels extends Models {
18
48
  constructor() {
19
49
  super(...arguments);
20
50
  this.train = new EnhancedTrain(this._client);
21
51
  }
52
+ retrieve(modelID, query = {}, options) {
53
+ return super.retrieve(modelID, query, options)._thenUnwrap((data) => ({
54
+ ...data,
55
+ model: ModelEntity.from(this._client, data.model),
56
+ }));
57
+ }
22
58
  }
23
59
  //# sourceMappingURL=models.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"models.mjs","sourceRoot":"","sources":["../src/lib/models.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,EAAE;OACV,EAAE,KAAK,EAAsD;OAC7D,EAAgB,UAAU,EAAE;AAEnC;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,OAAO,CACd,OAAe,EACf,MAA0B,EAC1B,OAAwB;QAExB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,MAAM;IAA1C;;QACW,UAAK,GAAkB,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClE,CAAC;CAAA"}
1
+ {"version":3,"file":"models.mjs","sourceRoot":"","sources":["../src/lib/models.ts"],"names":[],"mappings":"OAGO,EAAE,MAAM,EAAwD;OAChE,EAAE,KAAK,EAAsD;OAC7D,EAAgB,UAAU,EAAE;AAInC;;;;;;;;;;GAUG;AACH,MAAM,OAAO,WAAW;IAGtB;;;;;OAKG;IACH,GAAG,CAED,MAA8B,EAC9B,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;IAED,8DAA8D;IAC9D,MAAM,CAAC,IAAI,CACT,MAAgB,EAChB,IAAiC;QAEjC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC;QACzE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/E,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAOD;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,OAAO,CACd,OAAe,EACf,MAA0B,EAC1B,OAAwB;QAExB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,cAAe,SAAQ,MAAM;IAA1C;;QACW,UAAK,GAAkB,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAYlE,CAAC;IAVU,QAAQ,CACf,OAAe,EACf,QAAgD,EAAE,EAClD,OAAwB;QAExB,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACpE,GAAG,IAAI;YACP,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,OAAmB,EAAE,IAAI,CAAC,KAAK,CAAC;SAC9D,CAAC,CAAC,CAAC;IACN,CAAC;CACF"}
@@ -1,6 +1,7 @@
1
1
  import { Scenario as BaseScenario } from "../client.mjs";
2
2
  import { EnhancedGenerate } from "./generate.mjs";
3
3
  import { EnhancedModels } from "./models.mjs";
4
+ import { EnhancedUploads } from "./upload.mjs";
4
5
  import { EnhancedWorkflows } from "./workflow.mjs";
5
6
  /**
6
7
  * Enhanced Scenario client.
@@ -35,5 +36,6 @@ export declare class Scenario extends BaseScenario {
35
36
  workflows: EnhancedWorkflows;
36
37
  generate: EnhancedGenerate;
37
38
  models: EnhancedModels;
39
+ uploads: EnhancedUploads;
38
40
  }
39
41
  //# sourceMappingURL=scenario.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scenario.d.mts","sourceRoot":"","sources":["../src/lib/scenario.ts"],"names":[],"mappings":"OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE;OAC5B,EAAE,gBAAgB,EAAE;OACpB,EAAE,cAAc,EAAE;OAClB,EAAE,iBAAiB,EAAE;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,QAAS,SAAQ,YAAY;IAC/B,SAAS,EAAE,iBAAiB,CAA+B;IAC3D,QAAQ,EAAE,gBAAgB,CAA8B;IACxD,MAAM,EAAE,cAAc,CAA4B;CAC5D"}
1
+ {"version":3,"file":"scenario.d.mts","sourceRoot":"","sources":["../src/lib/scenario.ts"],"names":[],"mappings":"OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE;OAC5B,EAAE,gBAAgB,EAAE;OACpB,EAAE,cAAc,EAAE;OAClB,EAAE,eAAe,EAAE;OACnB,EAAE,iBAAiB,EAAE;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,QAAS,SAAQ,YAAY;IAC/B,SAAS,EAAE,iBAAiB,CAA+B;IAC3D,QAAQ,EAAE,gBAAgB,CAA8B;IACxD,MAAM,EAAE,cAAc,CAA4B;IAClD,OAAO,EAAE,eAAe,CAA6B;CAC/D"}
package/lib/scenario.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Scenario as BaseScenario } from "../client.js";
2
2
  import { EnhancedGenerate } from "./generate.js";
3
3
  import { EnhancedModels } from "./models.js";
4
+ import { EnhancedUploads } from "./upload.js";
4
5
  import { EnhancedWorkflows } from "./workflow.js";
5
6
  /**
6
7
  * Enhanced Scenario client.
@@ -35,5 +36,6 @@ export declare class Scenario extends BaseScenario {
35
36
  workflows: EnhancedWorkflows;
36
37
  generate: EnhancedGenerate;
37
38
  models: EnhancedModels;
39
+ uploads: EnhancedUploads;
38
40
  }
39
41
  //# sourceMappingURL=scenario.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scenario.d.ts","sourceRoot":"","sources":["../src/lib/scenario.ts"],"names":[],"mappings":"OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE;OAC5B,EAAE,gBAAgB,EAAE;OACpB,EAAE,cAAc,EAAE;OAClB,EAAE,iBAAiB,EAAE;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,QAAS,SAAQ,YAAY;IAC/B,SAAS,EAAE,iBAAiB,CAA+B;IAC3D,QAAQ,EAAE,gBAAgB,CAA8B;IACxD,MAAM,EAAE,cAAc,CAA4B;CAC5D"}
1
+ {"version":3,"file":"scenario.d.ts","sourceRoot":"","sources":["../src/lib/scenario.ts"],"names":[],"mappings":"OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE;OAC5B,EAAE,gBAAgB,EAAE;OACpB,EAAE,cAAc,EAAE;OAClB,EAAE,eAAe,EAAE;OACnB,EAAE,iBAAiB,EAAE;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,QAAS,SAAQ,YAAY;IAC/B,SAAS,EAAE,iBAAiB,CAA+B;IAC3D,QAAQ,EAAE,gBAAgB,CAA8B;IACxD,MAAM,EAAE,cAAc,CAA4B;IAClD,OAAO,EAAE,eAAe,CAA6B;CAC/D"}
package/lib/scenario.js CHANGED
@@ -4,6 +4,7 @@ exports.Scenario = void 0;
4
4
  const client_1 = require("../client.js");
5
5
  const generate_1 = require("./generate.js");
6
6
  const models_1 = require("./models.js");
7
+ const upload_1 = require("./upload.js");
7
8
  const workflow_1 = require("./workflow.js");
8
9
  /**
9
10
  * Enhanced Scenario client.
@@ -40,6 +41,7 @@ class Scenario extends client_1.Scenario {
40
41
  this.workflows = new workflow_1.EnhancedWorkflows(this);
41
42
  this.generate = new generate_1.EnhancedGenerate(this);
42
43
  this.models = new models_1.EnhancedModels(this);
44
+ this.uploads = new upload_1.EnhancedUploads(this);
43
45
  }
44
46
  }
45
47
  exports.Scenario = Scenario;
@@ -1 +1 @@
1
- {"version":3,"file":"scenario.js","sourceRoot":"","sources":["../src/lib/scenario.ts"],"names":[],"mappings":";;;AAAA,yCAAqD;AACrD,4CAA8C;AAC9C,wCAA0C;AAC1C,4CAA+C;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,QAAS,SAAQ,iBAAY;IAA1C;;QACW,cAAS,GAAsB,IAAI,4BAAiB,CAAC,IAAI,CAAC,CAAC;QAC3D,aAAQ,GAAqB,IAAI,2BAAgB,CAAC,IAAI,CAAC,CAAC;QACxD,WAAM,GAAmB,IAAI,uBAAc,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;CAAA;AAJD,4BAIC"}
1
+ {"version":3,"file":"scenario.js","sourceRoot":"","sources":["../src/lib/scenario.ts"],"names":[],"mappings":";;;AAAA,yCAAqD;AACrD,4CAA8C;AAC9C,wCAA0C;AAC1C,wCAA2C;AAC3C,4CAA+C;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,QAAS,SAAQ,iBAAY;IAA1C;;QACW,cAAS,GAAsB,IAAI,4BAAiB,CAAC,IAAI,CAAC,CAAC;QAC3D,aAAQ,GAAqB,IAAI,2BAAgB,CAAC,IAAI,CAAC,CAAC;QACxD,WAAM,GAAmB,IAAI,uBAAc,CAAC,IAAI,CAAC,CAAC;QAClD,YAAO,GAAoB,IAAI,wBAAe,CAAC,IAAI,CAAC,CAAC;IAChE,CAAC;CAAA;AALD,4BAKC"}
package/lib/scenario.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Scenario as BaseScenario } from "../client.mjs";
2
2
  import { EnhancedGenerate } from "./generate.mjs";
3
3
  import { EnhancedModels } from "./models.mjs";
4
+ import { EnhancedUploads } from "./upload.mjs";
4
5
  import { EnhancedWorkflows } from "./workflow.mjs";
5
6
  /**
6
7
  * Enhanced Scenario client.
@@ -37,6 +38,7 @@ export class Scenario extends BaseScenario {
37
38
  this.workflows = new EnhancedWorkflows(this);
38
39
  this.generate = new EnhancedGenerate(this);
39
40
  this.models = new EnhancedModels(this);
41
+ this.uploads = new EnhancedUploads(this);
40
42
  }
41
43
  }
42
44
  //# sourceMappingURL=scenario.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"scenario.mjs","sourceRoot":"","sources":["../src/lib/scenario.ts"],"names":[],"mappings":"OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE;OAC5B,EAAE,gBAAgB,EAAE;OACpB,EAAE,cAAc,EAAE;OAClB,EAAE,iBAAiB,EAAE;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;IAA1C;;QACW,cAAS,GAAsB,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC3D,aAAQ,GAAqB,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACxD,WAAM,GAAmB,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;CAAA"}
1
+ {"version":3,"file":"scenario.mjs","sourceRoot":"","sources":["../src/lib/scenario.ts"],"names":[],"mappings":"OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE;OAC5B,EAAE,gBAAgB,EAAE;OACpB,EAAE,cAAc,EAAE;OAClB,EAAE,eAAe,EAAE;OACnB,EAAE,iBAAiB,EAAE;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,QAAS,SAAQ,YAAY;IAA1C;;QACW,cAAS,GAAsB,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC3D,aAAQ,GAAqB,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACxD,WAAM,GAAmB,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;QAClD,YAAO,GAAoB,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;IAChE,CAAC;CAAA"}
@@ -0,0 +1,89 @@
1
+ import type { RequestOptions } from "../internal/request-options.mjs";
2
+ import { Uploads, type UploadCreateParams } from "../resources/uploads.mjs";
3
+ import type { AssetRetrieveResponse } from "../resources/assets/assets.mjs";
4
+ import type { ModelRetrieveResponse } from "../resources/models/models.mjs";
5
+ type UploadKind = NonNullable<UploadCreateParams['kind']>;
6
+ /** The resolved entity returned after a successful upload, narrowed by `kind`. */
7
+ export type UploadResult<K extends UploadKind> = K extends 'model' ? ModelRetrieveResponse : AssetRetrieveResponse;
8
+ /**
9
+ * Accepted upload inputs.
10
+ * - `string` — a local file path, read from disk (Node only; throws in browsers).
11
+ * - `Uint8Array` — raw bytes. `Buffer` is a `Uint8Array` and works too.
12
+ * - `Blob` / `File` — browser-native, or Node ≥ 18 via `fs.openAsBlob()` /
13
+ * constructors.
14
+ */
15
+ export type UploadFileInput = string | Uint8Array | Blob;
16
+ export interface UploadFileParams<K extends UploadKind> {
17
+ /**
18
+ * The file to upload. Accepts a local path (Node), a `Uint8Array` / `Buffer`,
19
+ * or a `Blob` / `File`.
20
+ */
21
+ file: UploadFileInput;
22
+ /** Original filename (e.g. `"my-model.safetensors"`). */
23
+ fileName: string;
24
+ /** MIME type (e.g. `"application/octet-stream"`, `"image/png"`). */
25
+ contentType: string;
26
+ /** The kind of upload. Determines the returned entity type. */
27
+ kind: K;
28
+ /**
29
+ * Extra asset options. Ignored when `kind === 'model'` — models don't
30
+ * produce an asset, so these options are not applicable server-side.
31
+ */
32
+ assetOptions?: UploadCreateParams['assetOptions'];
33
+ /**
34
+ * Maximum number of parts uploaded to S3 in parallel.
35
+ * @default 4
36
+ */
37
+ partConcurrency?: number;
38
+ /**
39
+ * Polling interval for the final "upload imported" check, in ms.
40
+ * @default 2000
41
+ */
42
+ pollIntervalMs?: number;
43
+ /**
44
+ * Maximum time to wait for the upload to reach a terminal state, in ms.
45
+ * Throws if exceeded.
46
+ * @default 300000
47
+ */
48
+ pollTimeoutMs?: number;
49
+ }
50
+ /**
51
+ * Enhanced Uploads resource.
52
+ * All original methods (`create`, `retrieve`, `triggerAction`) are inherited.
53
+ * Adds `uploadFile()` — a one-call wrapper around the 4-step upload flow:
54
+ * init → PUT parts to S3 → trigger complete → poll until imported.
55
+ */
56
+ export declare class EnhancedUploads extends Uploads {
57
+ /**
58
+ * Upload a file end-to-end. Computes an optimal part size (within AWS's
59
+ * 5 MiB / 5 GiB / 10,000-part bounds), uploads all parts in parallel,
60
+ * triggers completion, polls until the server has validated and imported
61
+ * the file, and returns the resolved entity.
62
+ *
63
+ * The returned type narrows on `kind`: `'model'` returns a Model,
64
+ * everything else returns an Asset.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * // From a file path (Node)
69
+ * const { asset } = await client.uploads.uploadFile({
70
+ * file: './photo.jpg',
71
+ * fileName: 'photo.jpg',
72
+ * contentType: 'image/jpeg',
73
+ * kind: 'image',
74
+ * });
75
+ * console.log(asset.id, asset.url);
76
+ *
77
+ * // Or from bytes / Blob — anything you already have in memory
78
+ * await client.uploads.uploadFile({
79
+ * file: new Blob([pngBytes], { type: 'image/png' }),
80
+ * fileName: 'generated.png',
81
+ * contentType: 'image/png',
82
+ * kind: 'image',
83
+ * });
84
+ * ```
85
+ */
86
+ uploadFile<K extends UploadKind>(params: UploadFileParams<K>, options?: RequestOptions): Promise<UploadResult<K>>;
87
+ }
88
+ export {};
89
+ //# sourceMappingURL=upload.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.d.mts","sourceRoot":"","sources":["../src/lib/upload.ts"],"names":[],"mappings":"OAAO,KAAK,EAAE,cAAc,EAAE;OACvB,EACL,OAAO,EACP,KAAK,kBAAkB,EAGxB;OACM,KAAK,EAAE,qBAAqB,EAAE;OAC9B,KAAK,EAAE,qBAAqB,EAAE;AAErC,KAAK,UAAU,GAAG,WAAW,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;AAE1D,kFAAkF;AAClF,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,UAAU,IAC3C,CAAC,SAAS,OAAO,GAAG,qBAAqB,GAAG,qBAAqB,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;AAEzD,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,UAAU;IACpD;;;OAGG;IACH,IAAI,EAAE,eAAe,CAAC;IACtB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,IAAI,EAAE,CAAC,CAAC;IACR;;;OAGG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;IAClD;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAcD;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,OAAO;IAC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,UAAU,CAAC,CAAC,SAAS,UAAU,EACnC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAC3B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAuE5B"}
@@ -0,0 +1,89 @@
1
+ import type { RequestOptions } from "../internal/request-options.js";
2
+ import { Uploads, type UploadCreateParams } from "../resources/uploads.js";
3
+ import type { AssetRetrieveResponse } from "../resources/assets/assets.js";
4
+ import type { ModelRetrieveResponse } from "../resources/models/models.js";
5
+ type UploadKind = NonNullable<UploadCreateParams['kind']>;
6
+ /** The resolved entity returned after a successful upload, narrowed by `kind`. */
7
+ export type UploadResult<K extends UploadKind> = K extends 'model' ? ModelRetrieveResponse : AssetRetrieveResponse;
8
+ /**
9
+ * Accepted upload inputs.
10
+ * - `string` — a local file path, read from disk (Node only; throws in browsers).
11
+ * - `Uint8Array` — raw bytes. `Buffer` is a `Uint8Array` and works too.
12
+ * - `Blob` / `File` — browser-native, or Node ≥ 18 via `fs.openAsBlob()` /
13
+ * constructors.
14
+ */
15
+ export type UploadFileInput = string | Uint8Array | Blob;
16
+ export interface UploadFileParams<K extends UploadKind> {
17
+ /**
18
+ * The file to upload. Accepts a local path (Node), a `Uint8Array` / `Buffer`,
19
+ * or a `Blob` / `File`.
20
+ */
21
+ file: UploadFileInput;
22
+ /** Original filename (e.g. `"my-model.safetensors"`). */
23
+ fileName: string;
24
+ /** MIME type (e.g. `"application/octet-stream"`, `"image/png"`). */
25
+ contentType: string;
26
+ /** The kind of upload. Determines the returned entity type. */
27
+ kind: K;
28
+ /**
29
+ * Extra asset options. Ignored when `kind === 'model'` — models don't
30
+ * produce an asset, so these options are not applicable server-side.
31
+ */
32
+ assetOptions?: UploadCreateParams['assetOptions'];
33
+ /**
34
+ * Maximum number of parts uploaded to S3 in parallel.
35
+ * @default 4
36
+ */
37
+ partConcurrency?: number;
38
+ /**
39
+ * Polling interval for the final "upload imported" check, in ms.
40
+ * @default 2000
41
+ */
42
+ pollIntervalMs?: number;
43
+ /**
44
+ * Maximum time to wait for the upload to reach a terminal state, in ms.
45
+ * Throws if exceeded.
46
+ * @default 300000
47
+ */
48
+ pollTimeoutMs?: number;
49
+ }
50
+ /**
51
+ * Enhanced Uploads resource.
52
+ * All original methods (`create`, `retrieve`, `triggerAction`) are inherited.
53
+ * Adds `uploadFile()` — a one-call wrapper around the 4-step upload flow:
54
+ * init → PUT parts to S3 → trigger complete → poll until imported.
55
+ */
56
+ export declare class EnhancedUploads extends Uploads {
57
+ /**
58
+ * Upload a file end-to-end. Computes an optimal part size (within AWS's
59
+ * 5 MiB / 5 GiB / 10,000-part bounds), uploads all parts in parallel,
60
+ * triggers completion, polls until the server has validated and imported
61
+ * the file, and returns the resolved entity.
62
+ *
63
+ * The returned type narrows on `kind`: `'model'` returns a Model,
64
+ * everything else returns an Asset.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * // From a file path (Node)
69
+ * const { asset } = await client.uploads.uploadFile({
70
+ * file: './photo.jpg',
71
+ * fileName: 'photo.jpg',
72
+ * contentType: 'image/jpeg',
73
+ * kind: 'image',
74
+ * });
75
+ * console.log(asset.id, asset.url);
76
+ *
77
+ * // Or from bytes / Blob — anything you already have in memory
78
+ * await client.uploads.uploadFile({
79
+ * file: new Blob([pngBytes], { type: 'image/png' }),
80
+ * fileName: 'generated.png',
81
+ * contentType: 'image/png',
82
+ * kind: 'image',
83
+ * });
84
+ * ```
85
+ */
86
+ uploadFile<K extends UploadKind>(params: UploadFileParams<K>, options?: RequestOptions): Promise<UploadResult<K>>;
87
+ }
88
+ export {};
89
+ //# sourceMappingURL=upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/lib/upload.ts"],"names":[],"mappings":"OAAO,KAAK,EAAE,cAAc,EAAE;OACvB,EACL,OAAO,EACP,KAAK,kBAAkB,EAGxB;OACM,KAAK,EAAE,qBAAqB,EAAE;OAC9B,KAAK,EAAE,qBAAqB,EAAE;AAErC,KAAK,UAAU,GAAG,WAAW,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;AAE1D,kFAAkF;AAClF,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,UAAU,IAC3C,CAAC,SAAS,OAAO,GAAG,qBAAqB,GAAG,qBAAqB,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;AAEzD,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,UAAU;IACpD;;;OAGG;IACH,IAAI,EAAE,eAAe,CAAC;IACtB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,IAAI,EAAE,CAAC,CAAC;IACR;;;OAGG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;IAClD;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAcD;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,OAAO;IAC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,UAAU,CAAC,CAAC,SAAS,UAAU,EACnC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAC3B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAuE5B"}