@faable/deploy-sdk 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/.github/workflows/release.yml +20 -0
- package/README.md +20 -0
- package/ava.config.cjs +7 -0
- package/package.json +47 -0
- package/src/FaableDeployApi.test.ts +13 -0
- package/src/FaableDeployApi.ts +40 -0
- package/src/api/api-types.ts +32 -0
- package/src/api/types.d.ts +2021 -0
- package/src/auth/apikey.ts +11 -0
- package/src/fetcher/Fetcher.ts +42 -0
- package/src/fetcher/fetcher_axios.ts +50 -0
- package/src/helpers/authorize-client-credentials.ts +54 -0
- package/src/helpers/authorize.ts +58 -0
- package/src/helpers/error_handler.ts +7 -0
- package/src/helpers/paginator.ts +37 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
"on":
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
jobs:
|
|
7
|
+
release:
|
|
8
|
+
name: release
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/setup-node@v3
|
|
13
|
+
with:
|
|
14
|
+
cache: npm
|
|
15
|
+
node-version: lts/*
|
|
16
|
+
- run: npm ci
|
|
17
|
+
- run: npm run release
|
|
18
|
+
env:
|
|
19
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
20
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Faable Deploy SDK
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://faable.com">
|
|
5
|
+
<h1 align="center">Faable Deploy SDK</h1>
|
|
6
|
+
</a>
|
|
7
|
+
<p align="center">Faable Deploy management and API Client</p>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a aria-label="NPM version" href="https://www.npmjs.com/package/@faable/deploy-sdk">
|
|
12
|
+
<img alt="" src="https://img.shields.io/npm/v/@faable/deploy-sdk.svg?style=for-the-badge&labelColor=000000">
|
|
13
|
+
</a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @faable/deploy-sdk
|
|
20
|
+
```
|
package/ava.config.cjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@faable/deploy-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"author": "Marc Pomar <marc@faable.com>",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"axios": "^1.7.7",
|
|
14
|
+
"jwt-decode": "^4.0.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@septh/ts-run": "^1.3.0",
|
|
18
|
+
"@types/node": "^22.5.5",
|
|
19
|
+
"ava": "^6.1.3",
|
|
20
|
+
"dotenv": "^16.4.5",
|
|
21
|
+
"openapi-typescript": "^7.4.0",
|
|
22
|
+
"rimraf": "^6.0.1",
|
|
23
|
+
"semantic-release": "^24.1.1",
|
|
24
|
+
"tsimp": "^2.0.11",
|
|
25
|
+
"tsx": "^4.19.1",
|
|
26
|
+
"typescript": "^5.6.2"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"generate-types": "openapi-typescript https://api.faable.com/docs/json -o src/api/types.d.ts",
|
|
30
|
+
"prebuild": "rimraf dist",
|
|
31
|
+
"build": "tsc",
|
|
32
|
+
"test": "ava",
|
|
33
|
+
"release": "semantic-release"
|
|
34
|
+
},
|
|
35
|
+
"release": {
|
|
36
|
+
"branches": [
|
|
37
|
+
"main"
|
|
38
|
+
],
|
|
39
|
+
"plugins": [
|
|
40
|
+
"@semantic-release/release-notes-generator",
|
|
41
|
+
"@semantic-release/github",
|
|
42
|
+
[
|
|
43
|
+
"@semantic-release/npm"
|
|
44
|
+
]
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import test from "ava";
|
|
2
|
+
import { faableapi } from "./FaableDeployApi.js";
|
|
3
|
+
import { createApikeyAuth } from "./auth/apikey.js";
|
|
4
|
+
|
|
5
|
+
test("instance", async (t) => {
|
|
6
|
+
const auth = createApikeyAuth();
|
|
7
|
+
const api = faableapi({
|
|
8
|
+
auth,
|
|
9
|
+
});
|
|
10
|
+
const app = await api.getApp("app_64f312b7347d780011861a0f");
|
|
11
|
+
console.log(app);
|
|
12
|
+
t.pass();
|
|
13
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Deployment, App } from "./api/api-types.js";
|
|
2
|
+
import { buildPaginator, Paginator, Page } from "./helpers/paginator.js";
|
|
3
|
+
import { fetcher_axios } from "./fetcher/fetcher_axios.js";
|
|
4
|
+
import { Fetcher, FetcherCreateParams } from "./fetcher/Fetcher.js";
|
|
5
|
+
|
|
6
|
+
type ApiParams = {
|
|
7
|
+
fetcher?: FetcherCreateParams;
|
|
8
|
+
auth?: FetcherCreateParams;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export class FaableDeployApi {
|
|
12
|
+
private fetcher: Fetcher;
|
|
13
|
+
private paginator: Paginator;
|
|
14
|
+
|
|
15
|
+
constructor(params: ApiParams = {}) {
|
|
16
|
+
this.fetcher = fetcher_axios({
|
|
17
|
+
baseURL: "https://api.faable.com",
|
|
18
|
+
...params.fetcher,
|
|
19
|
+
...params.auth,
|
|
20
|
+
});
|
|
21
|
+
this.paginator = buildPaginator(this.fetcher);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getDeployment(id: string) {
|
|
25
|
+
return this.fetcher.get<Deployment>(`/deployment/${id}`);
|
|
26
|
+
}
|
|
27
|
+
getApp(id: string) {
|
|
28
|
+
return this.fetcher.get<App>(`/app/${id}`);
|
|
29
|
+
}
|
|
30
|
+
listApps() {
|
|
31
|
+
return this.paginator({ url: "/app" });
|
|
32
|
+
}
|
|
33
|
+
updateStatus<T>(id: string, data: T) {
|
|
34
|
+
return this.fetcher.post(`/status/${id}`, data);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const faableapi = (params: ApiParams = {}) => {
|
|
39
|
+
return new FaableDeployApi(params);
|
|
40
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { components } from "./types.js";
|
|
2
|
+
|
|
3
|
+
export type App = components["schemas"]["App"];
|
|
4
|
+
export type AppStatus = components["schemas"]["AppStatus"];
|
|
5
|
+
export type AppRuntime = components["schemas"]["AppRuntime"];
|
|
6
|
+
export type AppRuntimeStrategy = components["schemas"]["AppRuntimeStrategy"];
|
|
7
|
+
export type Deployment = components["schemas"]["Deployment"];
|
|
8
|
+
export type DeploymentStatus = components["schemas"]["DeploymentStatus"];
|
|
9
|
+
export type Secret = components["schemas"]["Secret"];
|
|
10
|
+
export type Domain = components["schemas"]["Domain"];
|
|
11
|
+
|
|
12
|
+
export type Volume = components["schemas"]["Volume"];
|
|
13
|
+
|
|
14
|
+
export type EventSecretsCreateBatchEvent =
|
|
15
|
+
components["schemas"]["Event_secret.create_batch"];
|
|
16
|
+
export type EventDeploymentCreated =
|
|
17
|
+
components["schemas"]["Event_deployment.created"];
|
|
18
|
+
export type EventAppDelete = components["schemas"]["Event_app.delete"];
|
|
19
|
+
export type EventAppCreate = components["schemas"]["Event_app.create"];
|
|
20
|
+
export type EventAppUpdate = components["schemas"]["Event_app.update"];
|
|
21
|
+
|
|
22
|
+
export type EventDomainCreate = components["schemas"]["Event_domain.create"];
|
|
23
|
+
export type EventDomainUpdate = components["schemas"]["Event_domain.update"];
|
|
24
|
+
|
|
25
|
+
export type EventVolumeCreate = components["schemas"]["Event_volume.create"];
|
|
26
|
+
export type EventVolumeDelete = components["schemas"]["Event_volume.delete"];
|
|
27
|
+
|
|
28
|
+
export type EventSecretsUpdated =
|
|
29
|
+
components["schemas"]["Event_secret.create_batch"];
|
|
30
|
+
|
|
31
|
+
export type EventDeploymentStatusUpdate =
|
|
32
|
+
components["schemas"]["Event_deployment.update_status"];
|