Skip to content

Commit 4994995

Browse files
committed
Generate TypeScript definitions from source
1 parent 09a117a commit 4994995

File tree

14 files changed

+205
-335
lines changed

14 files changed

+205
-335
lines changed

index.d.ts

Lines changed: 0 additions & 296 deletions
This file was deleted.

index.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
const Replicate = require("./lib/replicate");
1+
const ReplicateClass = require("./lib/replicate");
22
const ApiError = require("./lib/error");
3+
require("./lib/types");
34

45
/**
56
* Placeholder class used to warn of deprecated constructor.
67
* @deprecated use exported Replicate class instead
78
*/
8-
class DeprecatedReplicate extends Replicate {
9+
class DeprecatedReplicate extends ReplicateClass {
910
/** @deprecated Use `import { Replicate } from "replicate";` instead */
1011
// biome-ignore lint/complexity/noUselessConstructor: exists for the tsdoc comment
1112
constructor(...args) {
1213
super(...args);
1314
}
1415
}
1516

16-
const named = { ApiError, Replicate };
17-
const singleton = new Replicate();
17+
const named = { ApiError, Replicate: ReplicateClass };
18+
const singleton = new ReplicateClass();
1819

1920
/**
2021
* Default instance of the Replicate class that gets the access token
@@ -48,7 +49,7 @@ const singleton = new Replicate();
4849
* const client = new Replicate({...});
4950
* ```
5051
*
51-
* @type { Replicate & typeof DeprecatedReplicate & {ApiError: ApiError, Replicate: Replicate} }
52+
* @type { Replicate & typeof DeprecatedReplicate & {Replicate: typeof ReplicateClass} }
5253
*/
5354
const replicate = new Proxy(DeprecatedReplicate, {
5455
get(target, prop, receiver) {
@@ -70,3 +71,26 @@ const replicate = new Proxy(DeprecatedReplicate, {
7071
});
7172

7273
module.exports = replicate;
74+
75+
// - Type Definitions
76+
77+
/**
78+
* @typedef {import("./lib/replicate")} Replicate
79+
* @typedef {import("./lib/error")} ApiError
80+
* @typedef {typeof import("./lib/types").Collection} Collection
81+
* @typedef {typeof import("./lib/types").ModelVersion} ModelVersion
82+
* @typedef {typeof import("./lib/types").Hardware} Hardware
83+
* @typedef {typeof import("./lib/types").Model} Model
84+
* @typedef {typeof import("./lib/types").Prediction} Prediction
85+
* @typedef {typeof import("./lib/types").Training} Training
86+
* @typedef {typeof import("./lib/types").ServerSentEvent} ServerSentEvent
87+
* @typedef {typeof import("./lib/types").Status} Status
88+
* @typedef {typeof import("./lib/types").Visibility} Visibility
89+
* @typedef {typeof import("./lib/types").WebhookEventType} WebhookEventType
90+
*/
91+
92+
/**
93+
* @template T
94+
* @typedef {typeof import("./lib/types").Page} Page
95+
*/
96+

0 commit comments

Comments
 (0)