11type Identifier = `${string } /${string } :${string } `;
2- type WebhookEventType = " start" | " output" | " logs" | " completed" ;
2+ type WebhookEventType = ' start' | ' output' | ' logs' | ' completed' ;
33
4- declare module "replicate" {
5- export interface ReplicateOptions {
6- auth : string ;
7- userAgent ?: string ;
8- baseUrl ?: string ;
9- }
4+ interface Page < T > {
5+ previous ?: string ;
6+ next ?: string ;
7+ results : T [ ] ;
8+ }
109
10+ declare module 'replicate' {
1111 export interface Collection {
1212 id : string ;
1313 name : string ;
@@ -43,39 +43,17 @@ declare module "replicate" {
4343 updated : string ;
4444 }
4545
46- export interface CollectionsGetOptions {
47- collection_slug : string ;
48- }
49-
50- export interface ModelsGetOptions {
51- model_owner : string ;
52- model_name : string ;
53- }
54-
55- export interface ModelsVersionsListOptions {
56- model_owner : string ;
57- model_name : string ;
58- }
46+ export default class Replicate {
47+ constructor ( options : {
48+ auth : string ;
49+ userAgent ?: string ;
50+ baseUrl ?: string ;
51+ } ) ;
5952
60- export interface ModelsVersionsGetOptions {
61- model_owner : string ;
62- model_name : string ;
63- id : string ;
64- }
65-
66- export interface PredictionsCreateOptions {
67- version : string ;
68- input : any ;
69- webhook ?: string ;
70- webhook_events_filter ?: WebhookEventType [ ] ;
71- }
72-
73- export interface PredictionsGetOptions {
74- predictionId : string ;
75- }
76-
77- export class Replicate {
78- constructor ( options : ReplicateOptions ) ;
53+ auth : string ;
54+ userAgent ?: string ;
55+ baseUrl ?: string ;
56+ private instance : any ;
7957
8058 run (
8159 identifier : Identifier ,
@@ -87,7 +65,7 @@ declare module "replicate" {
8765 }
8866 ) : Promise < object > ;
8967 request ( route : string , parameters : any ) : Promise < any > ;
90- paginate < T > ( endpoint : ( ) => Promise < T > ) : AsyncGenerator < T [ ] > ;
68+ paginate < T > ( endpoint : ( ) => Promise < Page < T > > ) : AsyncGenerator < [ T ] > ;
9169 wait (
9270 prediction : Prediction ,
9371 options : {
@@ -97,23 +75,30 @@ declare module "replicate" {
9775 ) : Promise < Prediction > ;
9876
9977 collections : {
100- get ( options : CollectionsGetOptions ) : Promise < Collection > ;
78+ get ( collection_slug : string ) : Promise < Collection > ;
10179 } ;
10280
10381 models : {
104- get ( options : ModelsGetOptions ) : Promise < Model > ;
82+ get ( model_owner : string , model_name : string ) : Promise < Model > ;
10583 versions : {
106- list ( options : ModelsVersionsListOptions ) : Promise < ModelVersion [ ] > ;
107- get ( options : ModelsVersionsGetOptions ) : Promise < ModelVersion > ;
84+ list ( model_owner : string , model_name : string ) : Promise < ModelVersion [ ] > ;
85+ get (
86+ model_owner : string ,
87+ model_name : string ,
88+ version_id : string
89+ ) : Promise < ModelVersion > ;
10890 } ;
10991 } ;
11092
11193 predictions : {
112- create ( options : PredictionsCreateOptions ) : Promise < Prediction > ;
113- get ( options : PredictionsGetOptions ) : Promise < Prediction > ;
114- list ( ) : Promise < Prediction [ ] > ;
94+ create ( options : {
95+ version : string ;
96+ input : any ;
97+ webhook ?: string ;
98+ webhook_events_filter ?: WebhookEventType [ ] ;
99+ } ) : Promise < Prediction > ;
100+ get ( prediction_id : string ) : Promise < Prediction > ;
101+ list ( ) : Promise < Page < Prediction > > ;
115102 } ;
116103 }
117-
118- export default Replicate ;
119104}
0 commit comments