fal-endpoint-types 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.
- package/LICENSE +21 -0
- package/package.json +40 -0
- package/readme.md +56 -0
- package/types/fal/endpoints/index.d.ts +5325 -0
- package/types/fal/endpoints/index.next.d.ts +20 -0
- package/types/fal/endpoints/schema.d.ts +139824 -0
- package/types/fal/endpoints/schema.next.d.ts +177 -0
- package/types/fal/index.d.ts +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vincent
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fal-endpoint-types",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"homepage": "https://github.com/rawpixel-vincent/fal-endpoint-types#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/rawpixel-vincent/fal-endpoint-types/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/rawpixel-vincent/fal-endpoint-types.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"author": "rawpixel-vincent",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./types/fal/index.d.ts",
|
|
17
|
+
"types": "./types/fal/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./types/fal/index.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./endpoints": {
|
|
23
|
+
"types": "./types/fal/endpoints/index.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"types/**/*.d.ts",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"generate": "node scripts/generate-fal-types.mjs",
|
|
33
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"prettier": "^3.8.0",
|
|
37
|
+
"typescript": ">=5.9.3",
|
|
38
|
+
"@types/node": ">=24.1.1"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
input and output shapes exported from the openapi.json of fal.ai endpoints to typescript types.
|
|
2
|
+
|
|
3
|
+
Usage:
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
const input: fal.EndpointInput<'fal-ai/hyper3d/rodin'> = {
|
|
7
|
+
// ...
|
|
8
|
+
};
|
|
9
|
+
const output: fal.EndpointOutput<'fal-ai/hyper3d/rodin'> = {
|
|
10
|
+
// ...
|
|
11
|
+
};
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
const getMyMappedEndpointInput = (endpointId: Endpoint, userInputs: any): EndpointInput<typeof endpointId> => {
|
|
16
|
+
// ...
|
|
17
|
+
// Narrow down the endpoint id
|
|
18
|
+
// to infer the type of the returned value
|
|
19
|
+
switch (endpointId) {
|
|
20
|
+
case 'fal-ai/minimax/hailuo-02/standard/text-to-video':
|
|
21
|
+
return {
|
|
22
|
+
prompt: userInputs.prompt, // type safe, will be infered by the narrowed endpoint id
|
|
23
|
+
};
|
|
24
|
+
default:
|
|
25
|
+
throw new Error(`Unsupported endpoint: ${endpointId}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const endpointId = req.endpointId; // 'fal-ai/minimax/hailuo-02/standard/text-to-video'
|
|
30
|
+
const input = getMyMappedEndpointInput(endpointId, req.userInputs);
|
|
31
|
+
|
|
32
|
+
// --------------------------
|
|
33
|
+
|
|
34
|
+
const res = await fetch('https://fal.ai/api/v1/endpoints/{endpointId}', {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
body: JSON.stringify({
|
|
37
|
+
input: {
|
|
38
|
+
...input,
|
|
39
|
+
}),
|
|
40
|
+
}).then(res => res.json());
|
|
41
|
+
// check the api urls in the docs, this is just an example.
|
|
42
|
+
const result = await fetch('https://fal.ai/api/v1/endpoints/{endpointId}/requests/{res.requestId}', {
|
|
43
|
+
method: 'GET',
|
|
44
|
+
}).then(res => res.json())
|
|
45
|
+
const output = data.data as unknown as EndpointOutput<typeof endpointId>;
|
|
46
|
+
|
|
47
|
+
// --------------------------
|
|
48
|
+
// OR
|
|
49
|
+
|
|
50
|
+
const res = await fal.queue.submit(endpointId, {input});
|
|
51
|
+
|
|
52
|
+
// import('@fal/client').Result<EndpointOutput<typeof endpointId>>
|
|
53
|
+
const result = await fal.queue.result(res.requestId);
|
|
54
|
+
|
|
55
|
+
const output = result.data as unknown as EndpointOutput<typeof endpointId>;
|
|
56
|
+
```
|