|
1 |
| -import { ApiError, Collection, Hardware, Model, ModelVersion, Page, Prediction, Status, Training, Visibility, WebhookEventType } from "replicate"; |
| 1 | +import { |
| 2 | + Account, |
| 3 | + ApiError, |
| 4 | + Collection, |
| 5 | + Deployment, |
| 6 | + Hardware, |
| 7 | + Model, |
| 8 | + ModelVersion, |
| 9 | + Page, |
| 10 | + Prediction, |
| 11 | + Status, |
| 12 | + Training, |
| 13 | + Visibility, |
| 14 | + WebhookEventType, |
| 15 | +} from "replicate"; |
2 | 16 |
|
3 |
| -export type Equals<X, Y> = |
4 |
| - (<T>() => T extends X ? 1 : 2) extends |
5 |
| - (<T>() => T extends Y ? 1 : 2) ? true : false; |
| 17 | +export type Equals<X, Y> = (<T>() => T extends X ? 1 : 2) extends < |
| 18 | + T, |
| 19 | +>() => T extends Y ? 1 : 2 |
| 20 | + ? true |
| 21 | + : false; |
6 | 22 |
|
7 |
| - |
8 |
| -type AssertFalse<A extends false> = A |
| 23 | +type AssertFalse<A extends false> = A; |
9 | 24 |
|
10 | 25 | // @ts-expect-error
|
11 |
| -export type TestAssertion = AssertFalse<Equals<any, any>> |
12 |
| - |
13 |
| -export type TestApiError = AssertFalse<Equals<ApiError, any>> |
14 |
| -export type TestCollection = AssertFalse<Equals<Collection, any>> |
15 |
| -export type TestHardware = AssertFalse<Equals<Hardware, any>> |
16 |
| -export type TestModel = AssertFalse<Equals<Model, any>> |
17 |
| -export type TestModelVersion = AssertFalse<Equals<ModelVersion, any>> |
18 |
| -export type TestPage = AssertFalse<Equals<Page<unknown>, any>> |
19 |
| -export type TestPrediction = AssertFalse<Equals<Prediction, any>> |
20 |
| -export type TestStatus = AssertFalse<Equals<Status, any>> |
21 |
| -export type TestTraining = AssertFalse<Equals<Training, any>> |
22 |
| -export type TestVisibility = AssertFalse<Equals<Visibility, any>> |
23 |
| -export type TestWebhookEventType = AssertFalse<Equals<WebhookEventType, any>> |
| 26 | +export type TestAssertion = AssertFalse<Equals<any, any>>; |
24 | 27 |
|
| 28 | +export type TestAccount = AssertFalse<Equals<Account, any>>; |
| 29 | +export type TestApiError = AssertFalse<Equals<ApiError, any>>; |
| 30 | +export type TestCollection = AssertFalse<Equals<Collection, any>>; |
| 31 | +export type TestDeployment = AssertFalse<Equals<Deployment, any>>; |
| 32 | +export type TestHardware = AssertFalse<Equals<Hardware, any>>; |
| 33 | +export type TestModel = AssertFalse<Equals<Model, any>>; |
| 34 | +export type TestModelVersion = AssertFalse<Equals<ModelVersion, any>>; |
| 35 | +export type TestPage = AssertFalse<Equals<Page<unknown>, any>>; |
| 36 | +export type TestPrediction = AssertFalse<Equals<Prediction, any>>; |
| 37 | +export type TestStatus = AssertFalse<Equals<Status, any>>; |
| 38 | +export type TestTraining = AssertFalse<Equals<Training, any>>; |
| 39 | +export type TestVisibility = AssertFalse<Equals<Visibility, any>>; |
| 40 | +export type TestWebhookEventType = AssertFalse<Equals<WebhookEventType, any>>; |
25 | 41 |
|
26 | 42 | // NOTE: We export the constants to avoid unused varaible issues.
|
27 | 43 |
|
28 |
| -export const collection: Collection = { name: "", slug: "", description: "", models: [] }; |
| 44 | +export const account: Account = { |
| 45 | + type: "user", |
| 46 | + name: "", |
| 47 | + username: "", |
| 48 | + github_url: "", |
| 49 | +}; |
| 50 | +export const collection: Collection = { |
| 51 | + name: "", |
| 52 | + slug: "", |
| 53 | + description: "", |
| 54 | + models: [], |
| 55 | +}; |
| 56 | +export const deployment: Deployment = { |
| 57 | + owner: "", |
| 58 | + name: "", |
| 59 | + current_release: { |
| 60 | + number: 1, |
| 61 | + model: "", |
| 62 | + version: "", |
| 63 | + created_at: "", |
| 64 | + created_by: { |
| 65 | + type: "user", |
| 66 | + username: "", |
| 67 | + name: "", |
| 68 | + github_url: "", |
| 69 | + }, |
| 70 | + configuration: { |
| 71 | + hardware: "gpu-a100", |
| 72 | + min_instances: 0, |
| 73 | + max_instances: 5, |
| 74 | + }, |
| 75 | + }, |
| 76 | +}; |
29 | 77 | export const status: Status = "starting";
|
30 | 78 | export const visibility: Visibility = "public";
|
31 | 79 | export const webhookType: WebhookEventType = "start";
|
32 |
| -export const err: ApiError = Object.assign(new Error(), {request: new Request("file://"), response: new Response()}); |
| 80 | +export const err: ApiError = Object.assign(new Error(), { |
| 81 | + request: new Request("file://"), |
| 82 | + response: new Response(), |
| 83 | +}); |
33 | 84 | export const hardware: Hardware = { sku: "", name: "" };
|
34 | 85 | export const model: Model = {
|
35 |
| - url: "", |
36 |
| - owner: "", |
37 |
| - name: "", |
38 |
| - description: "", |
39 |
| - visibility: "public", |
40 |
| - github_url: "", |
41 |
| - paper_url: "", |
42 |
| - license_url: "", |
43 |
| - run_count: 10, |
44 |
| - cover_image_url: "", |
45 |
| - default_example: undefined, |
46 |
| - latest_version: undefined, |
| 86 | + url: "", |
| 87 | + owner: "", |
| 88 | + name: "", |
| 89 | + description: "", |
| 90 | + visibility: "public", |
| 91 | + github_url: "", |
| 92 | + paper_url: "", |
| 93 | + license_url: "", |
| 94 | + run_count: 10, |
| 95 | + cover_image_url: "", |
| 96 | + default_example: undefined, |
| 97 | + latest_version: undefined, |
47 | 98 | };
|
48 | 99 | export const version: ModelVersion = {
|
49 |
| - id: "", |
50 |
| - created_at: "", |
51 |
| - cog_version: "", |
52 |
| - openapi_schema: "", |
| 100 | + id: "", |
| 101 | + created_at: "", |
| 102 | + cog_version: "", |
| 103 | + openapi_schema: "", |
53 | 104 | };
|
54 | 105 | export const prediction: Prediction = {
|
55 |
| - id: "", |
56 |
| - status: "starting", |
57 |
| - model: "", |
58 |
| - version: "", |
59 |
| - input: {}, |
60 |
| - output: {}, |
61 |
| - source: "api", |
62 |
| - error: undefined, |
63 |
| - logs: "", |
64 |
| - metrics: { |
65 |
| - predict_time: 100, |
66 |
| - }, |
67 |
| - webhook: "", |
68 |
| - webhook_events_filter: [], |
69 |
| - created_at: "", |
70 |
| - started_at: "", |
71 |
| - completed_at: "", |
72 |
| - urls: { |
73 |
| - get: "", |
74 |
| - cancel: "", |
75 |
| - stream: "", |
76 |
| - }, |
| 106 | + id: "", |
| 107 | + status: "starting", |
| 108 | + model: "", |
| 109 | + version: "", |
| 110 | + input: {}, |
| 111 | + output: {}, |
| 112 | + source: "api", |
| 113 | + error: undefined, |
| 114 | + logs: "", |
| 115 | + metrics: { |
| 116 | + predict_time: 100, |
| 117 | + }, |
| 118 | + webhook: "", |
| 119 | + webhook_events_filter: [], |
| 120 | + created_at: "", |
| 121 | + started_at: "", |
| 122 | + completed_at: "", |
| 123 | + urls: { |
| 124 | + get: "", |
| 125 | + cancel: "", |
| 126 | + stream: "", |
| 127 | + }, |
77 | 128 | };
|
78 | 129 | export const training: Training = prediction;
|
79 | 130 |
|
80 | 131 | export const page: Page<ModelVersion> = {
|
81 |
| - previous: "", |
82 |
| - next: "", |
83 |
| - results: [version], |
| 132 | + previous: "", |
| 133 | + next: "", |
| 134 | + results: [version], |
84 | 135 | };
|
0 commit comments