@space-df/sdk 0.0.1-dev.3.3 → 0.0.1-dev.5
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/.editorconfig +24 -0
- package/.github/pull_request_template.md +25 -0
- package/.github/workflows/bump-version.yml +67 -0
- package/.github/workflows/publish-package.yml +28 -0
- package/.gitignore +11 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +89 -0
- package/api.doc.md +1537 -0
- package/dist/LICENSE +7 -0
- package/dist/README.md +382 -0
- package/{index.d.mts → dist/index.d.mts} +4 -0
- package/{index.d.ts → dist/index.d.ts} +4 -0
- package/{index.d.ts.map → dist/index.d.ts.map} +1 -1
- package/{index.js → dist/index.js} +4 -0
- package/dist/index.js.map +1 -0
- package/{index.mjs → dist/index.mjs} +4 -0
- package/dist/index.mjs.map +1 -0
- package/dist/package.json +101 -0
- package/{resources → dist/resources}/auth/auth.d.ts +5 -0
- package/dist/resources/auth/auth.d.ts.map +1 -0
- package/{resources → dist/resources}/auth/auth.js +3 -0
- package/dist/resources/auth/auth.js.map +1 -0
- package/{resources → dist/resources}/auth/auth.mjs +3 -0
- package/dist/resources/auth/auth.mjs.map +1 -0
- package/{resources → dist/resources}/auth/index.d.ts +4 -0
- package/{resources → dist/resources}/auth/index.d.ts.map +1 -1
- package/{resources → dist/resources}/auth/index.js +4 -0
- package/{resources → dist/resources}/auth/index.js.map +1 -1
- package/{resources → dist/resources}/auth/index.mjs +4 -0
- package/dist/resources/auth/invitation.d.ts +13 -0
- package/dist/resources/auth/invitation.d.ts.map +1 -0
- package/dist/resources/auth/invitation.js +11 -0
- package/dist/resources/auth/invitation.js.map +1 -0
- package/dist/resources/auth/invitation.mjs +7 -0
- package/dist/resources/auth/invitation.mjs.map +1 -0
- package/dist/resources/auth/join-space.d.ts +6 -0
- package/dist/resources/auth/join-space.d.ts.map +1 -0
- package/dist/resources/auth/join-space.js +11 -0
- package/dist/resources/auth/join-space.js.map +1 -0
- package/dist/resources/auth/join-space.mjs +7 -0
- package/dist/resources/auth/join-space.mjs.map +1 -0
- package/dist/resources/auth/presigned-url.d.ts +10 -0
- package/dist/resources/auth/presigned-url.d.ts.map +1 -0
- package/dist/resources/auth/presigned-url.js +11 -0
- package/dist/resources/auth/presigned-url.js.map +1 -0
- package/dist/resources/auth/presigned-url.mjs +7 -0
- package/dist/resources/auth/presigned-url.mjs.map +1 -0
- package/{resources → dist/resources}/auth/space-role-users.d.ts +5 -0
- package/dist/resources/auth/space-role-users.d.ts.map +1 -0
- package/{resources → dist/resources}/auth/space-role-users.js +16 -0
- package/dist/resources/auth/space-role-users.js.map +1 -0
- package/{resources → dist/resources}/auth/space-role-users.mjs +16 -0
- package/dist/resources/auth/space-role-users.mjs.map +1 -0
- package/dist/resources/auth/users.d.ts +19 -0
- package/dist/resources/auth/users.d.ts.map +1 -0
- package/dist/resources/auth/users.js +17 -0
- package/dist/resources/auth/users.js.map +1 -0
- package/dist/resources/auth/users.mjs +13 -0
- package/dist/resources/auth/users.mjs.map +1 -0
- package/dist/src/_shims/MultipartBody.ts +9 -0
- package/dist/src/_shims/README.md +46 -0
- package/dist/src/_shims/auto/runtime-bun.ts +4 -0
- package/dist/src/_shims/auto/runtime-node.ts +4 -0
- package/dist/src/_shims/auto/runtime.ts +4 -0
- package/dist/src/_shims/auto/types-node.ts +4 -0
- package/dist/src/_shims/auto/types.d.ts +101 -0
- package/dist/src/_shims/auto/types.js +3 -0
- package/dist/src/_shims/auto/types.mjs +3 -0
- package/dist/src/_shims/bun-runtime.ts +14 -0
- package/dist/src/_shims/index.d.ts +72 -0
- package/dist/src/_shims/index.js +13 -0
- package/dist/src/_shims/index.mjs +7 -0
- package/dist/src/_shims/manual-types.d.ts +12 -0
- package/dist/src/_shims/manual-types.js +3 -0
- package/dist/src/_shims/manual-types.mjs +3 -0
- package/dist/src/_shims/node-runtime.ts +78 -0
- package/dist/src/_shims/node-types.d.ts +42 -0
- package/dist/src/_shims/node-types.js +3 -0
- package/dist/src/_shims/node-types.mjs +3 -0
- package/dist/src/_shims/registry.ts +60 -0
- package/dist/src/_shims/web-runtime.ts +91 -0
- package/dist/src/_shims/web-types.d.ts +83 -0
- package/dist/src/_shims/web-types.js +3 -0
- package/dist/src/_shims/web-types.mjs +3 -0
- package/dist/src/core.ts +1061 -0
- package/dist/src/error.ts +134 -0
- package/dist/src/index.ts +210 -0
- package/dist/src/libs/utils.ts +66 -0
- package/dist/src/resource.ts +9 -0
- package/dist/src/resources/auth/auth.ts +102 -0
- package/dist/src/resources/auth/credentials.ts +12 -0
- package/dist/src/resources/auth/index.ts +10 -0
- package/dist/src/resources/auth/invitation.ts +17 -0
- package/dist/src/resources/auth/join-space.ts +8 -0
- package/dist/src/resources/auth/presigned-url.ts +13 -0
- package/dist/src/resources/auth/space-policies.ts +55 -0
- package/dist/src/resources/auth/space-role-users.ts +64 -0
- package/dist/src/resources/auth/space-roles.ts +95 -0
- package/dist/src/resources/auth/spaces.ts +118 -0
- package/dist/src/resources/auth/users.ts +36 -0
- package/dist/src/resources/console/index.ts +1 -0
- package/dist/src/resources/console/oauth2.ts +83 -0
- package/dist/src/resources/dashboard/dashboards.ts +171 -0
- package/dist/src/resources/dashboard/device-states.ts +142 -0
- package/dist/src/resources/dashboard/index.ts +2 -0
- package/dist/src/resources/index.ts +6 -0
- package/dist/src/shims/node.ts +50 -0
- package/dist/src/shims/web.ts +50 -0
- package/dist/src/types/api.ts +31 -0
- package/dist/src/types/jwt.ts +12 -0
- package/dist/src/version.ts +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/{version.js → dist/version.js} +1 -1
- package/dist/version.js.map +1 -0
- package/dist/version.mjs +2 -0
- package/{version.mjs.map → dist/version.mjs.map} +1 -1
- package/eslint.config.mjs +33 -0
- package/examples/auth/login.ts +14 -0
- package/examples/auth/register.ts +15 -0
- package/examples/console/oauth2.ts +15 -0
- package/package.json +52 -36
- package/scripts/build +56 -0
- package/scripts/utils/check-version.cjs +20 -0
- package/scripts/utils/fix-index-exports.cjs +8 -0
- package/scripts/utils/make-dist-package-json.cjs +21 -0
- package/scripts/utils/postprocess-files.cjs +153 -0
- package/src/_shims/auto/runtime-deno.ts +4 -0
- package/src/_shims/auto/types-deno.ts +4 -0
- package/src/_shims/auto/types.d.ts +18 -18
- package/src/_shims/index-deno.ts +105 -0
- package/src/_shims/index.d.ts +1 -1
- package/src/_shims/index.mjs +1 -1
- package/src/index.ts +4 -0
- package/src/resources/auth/auth.ts +10 -0
- package/src/resources/auth/index.ts +4 -0
- package/src/resources/auth/invitation.ts +17 -0
- package/src/resources/auth/join-space.ts +8 -0
- package/src/resources/auth/presigned-url.ts +13 -0
- package/src/resources/auth/space-role-users.ts +22 -0
- package/src/resources/auth/users.ts +36 -0
- package/src/version.ts +1 -1
- package/tsc-multi.json +7 -0
- package/tsconfig.build.json +18 -0
- package/tsconfig.deno.json +20 -0
- package/tsconfig.dist-src.json +11 -0
- package/tsconfig.json +38 -0
- package/index.js.map +0 -1
- package/index.mjs.map +0 -1
- package/resources/auth/auth.d.ts.map +0 -1
- package/resources/auth/auth.js.map +0 -1
- package/resources/auth/auth.mjs.map +0 -1
- package/resources/auth/space-role-users.d.ts.map +0 -1
- package/resources/auth/space-role-users.js.map +0 -1
- package/resources/auth/space-role-users.mjs.map +0 -1
- package/src/resources/.DS_Store +0 -0
- package/version.d.ts +0 -2
- package/version.d.ts.map +0 -1
- package/version.js.map +0 -1
- package/version.mjs +0 -2
- package/yarn.lock +0 -268
- /package/{_shims → dist/_shims}/MultipartBody.d.ts +0 -0
- /package/{_shims → dist/_shims}/MultipartBody.d.ts.map +0 -0
- /package/{_shims → dist/_shims}/MultipartBody.js +0 -0
- /package/{_shims → dist/_shims}/MultipartBody.js.map +0 -0
- /package/{_shims → dist/_shims}/MultipartBody.mjs +0 -0
- /package/{_shims → dist/_shims}/MultipartBody.mjs.map +0 -0
- /package/{_shims → dist/_shims}/README.md +0 -0
- /package/{_shims → dist/_shims}/auto/runtime-bun.d.ts +0 -0
- /package/{_shims → dist/_shims}/auto/runtime-bun.d.ts.map +0 -0
- /package/{_shims → dist/_shims}/auto/runtime-bun.js +0 -0
- /package/{_shims → dist/_shims}/auto/runtime-bun.js.map +0 -0
- /package/{_shims → dist/_shims}/auto/runtime-bun.mjs +0 -0
- /package/{_shims → dist/_shims}/auto/runtime-bun.mjs.map +0 -0
- /package/{_shims → dist/_shims}/auto/runtime-node.d.ts +0 -0
- /package/{_shims → dist/_shims}/auto/runtime-node.d.ts.map +0 -0
- /package/{_shims → dist/_shims}/auto/runtime-node.js +0 -0
- /package/{_shims → dist/_shims}/auto/runtime-node.js.map +0 -0
- /package/{_shims → dist/_shims}/auto/runtime-node.mjs +0 -0
- /package/{_shims → dist/_shims}/auto/runtime-node.mjs.map +0 -0
- /package/{_shims → dist/_shims}/auto/runtime.d.ts +0 -0
- /package/{_shims → dist/_shims}/auto/runtime.d.ts.map +0 -0
- /package/{_shims → dist/_shims}/auto/runtime.js +0 -0
- /package/{_shims → dist/_shims}/auto/runtime.js.map +0 -0
- /package/{_shims → dist/_shims}/auto/runtime.mjs +0 -0
- /package/{_shims → dist/_shims}/auto/runtime.mjs.map +0 -0
- /package/{_shims → dist/_shims}/auto/types-node.d.ts +0 -0
- /package/{_shims → dist/_shims}/auto/types-node.d.ts.map +0 -0
- /package/{_shims → dist/_shims}/auto/types-node.js +0 -0
- /package/{_shims → dist/_shims}/auto/types-node.js.map +0 -0
- /package/{_shims → dist/_shims}/auto/types-node.mjs +0 -0
- /package/{_shims → dist/_shims}/auto/types-node.mjs.map +0 -0
- /package/{_shims → dist/_shims}/auto/types.d.ts +0 -0
- /package/{_shims → dist/_shims}/auto/types.js +0 -0
- /package/{_shims → dist/_shims}/auto/types.mjs +0 -0
- /package/{_shims → dist/_shims}/bun-runtime.d.ts +0 -0
- /package/{_shims → dist/_shims}/bun-runtime.d.ts.map +0 -0
- /package/{_shims → dist/_shims}/bun-runtime.js +0 -0
- /package/{_shims → dist/_shims}/bun-runtime.js.map +0 -0
- /package/{_shims → dist/_shims}/bun-runtime.mjs +0 -0
- /package/{_shims → dist/_shims}/bun-runtime.mjs.map +0 -0
- /package/{_shims → dist/_shims}/index.d.ts +0 -0
- /package/{_shims → dist/_shims}/index.js +0 -0
- /package/{_shims → dist/_shims}/index.mjs +0 -0
- /package/{_shims → dist/_shims}/manual-types.d.ts +0 -0
- /package/{_shims → dist/_shims}/manual-types.js +0 -0
- /package/{_shims → dist/_shims}/manual-types.mjs +0 -0
- /package/{_shims → dist/_shims}/node-runtime.d.ts +0 -0
- /package/{_shims → dist/_shims}/node-runtime.d.ts.map +0 -0
- /package/{_shims → dist/_shims}/node-runtime.js +0 -0
- /package/{_shims → dist/_shims}/node-runtime.js.map +0 -0
- /package/{_shims → dist/_shims}/node-runtime.mjs +0 -0
- /package/{_shims → dist/_shims}/node-runtime.mjs.map +0 -0
- /package/{_shims → dist/_shims}/node-types.d.ts +0 -0
- /package/{_shims → dist/_shims}/node-types.js +0 -0
- /package/{_shims → dist/_shims}/node-types.mjs +0 -0
- /package/{_shims → dist/_shims}/registry.d.ts +0 -0
- /package/{_shims → dist/_shims}/registry.d.ts.map +0 -0
- /package/{_shims → dist/_shims}/registry.js +0 -0
- /package/{_shims → dist/_shims}/registry.js.map +0 -0
- /package/{_shims → dist/_shims}/registry.mjs +0 -0
- /package/{_shims → dist/_shims}/registry.mjs.map +0 -0
- /package/{_shims → dist/_shims}/web-runtime.d.ts +0 -0
- /package/{_shims → dist/_shims}/web-runtime.d.ts.map +0 -0
- /package/{_shims → dist/_shims}/web-runtime.js +0 -0
- /package/{_shims → dist/_shims}/web-runtime.js.map +0 -0
- /package/{_shims → dist/_shims}/web-runtime.mjs +0 -0
- /package/{_shims → dist/_shims}/web-runtime.mjs.map +0 -0
- /package/{_shims → dist/_shims}/web-types.d.ts +0 -0
- /package/{_shims → dist/_shims}/web-types.js +0 -0
- /package/{_shims → dist/_shims}/web-types.mjs +0 -0
- /package/{core.d.ts → dist/core.d.ts} +0 -0
- /package/{core.d.ts.map → dist/core.d.ts.map} +0 -0
- /package/{core.js → dist/core.js} +0 -0
- /package/{core.js.map → dist/core.js.map} +0 -0
- /package/{core.mjs → dist/core.mjs} +0 -0
- /package/{core.mjs.map → dist/core.mjs.map} +0 -0
- /package/{error.d.ts → dist/error.d.ts} +0 -0
- /package/{error.d.ts.map → dist/error.d.ts.map} +0 -0
- /package/{error.js → dist/error.js} +0 -0
- /package/{error.js.map → dist/error.js.map} +0 -0
- /package/{error.mjs → dist/error.mjs} +0 -0
- /package/{error.mjs.map → dist/error.mjs.map} +0 -0
- /package/{libs → dist/libs}/utils.d.ts +0 -0
- /package/{libs → dist/libs}/utils.d.ts.map +0 -0
- /package/{libs → dist/libs}/utils.js +0 -0
- /package/{libs → dist/libs}/utils.js.map +0 -0
- /package/{libs → dist/libs}/utils.mjs +0 -0
- /package/{libs → dist/libs}/utils.mjs.map +0 -0
- /package/{resource.d.ts → dist/resource.d.ts} +0 -0
- /package/{resource.d.ts.map → dist/resource.d.ts.map} +0 -0
- /package/{resource.js → dist/resource.js} +0 -0
- /package/{resource.js.map → dist/resource.js.map} +0 -0
- /package/{resource.mjs → dist/resource.mjs} +0 -0
- /package/{resource.mjs.map → dist/resource.mjs.map} +0 -0
- /package/{resources → dist/resources}/auth/credentials.d.ts +0 -0
- /package/{resources → dist/resources}/auth/credentials.d.ts.map +0 -0
- /package/{resources → dist/resources}/auth/credentials.js +0 -0
- /package/{resources → dist/resources}/auth/credentials.js.map +0 -0
- /package/{resources → dist/resources}/auth/credentials.mjs +0 -0
- /package/{resources → dist/resources}/auth/credentials.mjs.map +0 -0
- /package/{resources → dist/resources}/auth/index.mjs.map +0 -0
- /package/{resources → dist/resources}/auth/space-policies.d.ts +0 -0
- /package/{resources → dist/resources}/auth/space-policies.d.ts.map +0 -0
- /package/{resources → dist/resources}/auth/space-policies.js +0 -0
- /package/{resources → dist/resources}/auth/space-policies.js.map +0 -0
- /package/{resources → dist/resources}/auth/space-policies.mjs +0 -0
- /package/{resources → dist/resources}/auth/space-policies.mjs.map +0 -0
- /package/{resources → dist/resources}/auth/space-roles.d.ts +0 -0
- /package/{resources → dist/resources}/auth/space-roles.d.ts.map +0 -0
- /package/{resources → dist/resources}/auth/space-roles.js +0 -0
- /package/{resources → dist/resources}/auth/space-roles.js.map +0 -0
- /package/{resources → dist/resources}/auth/space-roles.mjs +0 -0
- /package/{resources → dist/resources}/auth/space-roles.mjs.map +0 -0
- /package/{resources → dist/resources}/auth/spaces.d.ts +0 -0
- /package/{resources → dist/resources}/auth/spaces.d.ts.map +0 -0
- /package/{resources → dist/resources}/auth/spaces.js +0 -0
- /package/{resources → dist/resources}/auth/spaces.js.map +0 -0
- /package/{resources → dist/resources}/auth/spaces.mjs +0 -0
- /package/{resources → dist/resources}/auth/spaces.mjs.map +0 -0
- /package/{resources → dist/resources}/console/index.d.ts +0 -0
- /package/{resources → dist/resources}/console/index.d.ts.map +0 -0
- /package/{resources → dist/resources}/console/index.js +0 -0
- /package/{resources → dist/resources}/console/index.js.map +0 -0
- /package/{resources → dist/resources}/console/index.mjs +0 -0
- /package/{resources → dist/resources}/console/index.mjs.map +0 -0
- /package/{resources → dist/resources}/console/oauth2.d.ts +0 -0
- /package/{resources → dist/resources}/console/oauth2.d.ts.map +0 -0
- /package/{resources → dist/resources}/console/oauth2.js +0 -0
- /package/{resources → dist/resources}/console/oauth2.js.map +0 -0
- /package/{resources → dist/resources}/console/oauth2.mjs +0 -0
- /package/{resources → dist/resources}/console/oauth2.mjs.map +0 -0
- /package/{resources → dist/resources}/dashboard/dashboards.d.ts +0 -0
- /package/{resources → dist/resources}/dashboard/dashboards.d.ts.map +0 -0
- /package/{resources → dist/resources}/dashboard/dashboards.js +0 -0
- /package/{resources → dist/resources}/dashboard/dashboards.js.map +0 -0
- /package/{resources → dist/resources}/dashboard/dashboards.mjs +0 -0
- /package/{resources → dist/resources}/dashboard/dashboards.mjs.map +0 -0
- /package/{resources → dist/resources}/dashboard/device-states.d.ts +0 -0
- /package/{resources → dist/resources}/dashboard/device-states.d.ts.map +0 -0
- /package/{resources → dist/resources}/dashboard/device-states.js +0 -0
- /package/{resources → dist/resources}/dashboard/device-states.js.map +0 -0
- /package/{resources → dist/resources}/dashboard/device-states.mjs +0 -0
- /package/{resources → dist/resources}/dashboard/device-states.mjs.map +0 -0
- /package/{resources → dist/resources}/dashboard/index.d.ts +0 -0
- /package/{resources → dist/resources}/dashboard/index.d.ts.map +0 -0
- /package/{resources → dist/resources}/dashboard/index.js +0 -0
- /package/{resources → dist/resources}/dashboard/index.js.map +0 -0
- /package/{resources → dist/resources}/dashboard/index.mjs +0 -0
- /package/{resources → dist/resources}/dashboard/index.mjs.map +0 -0
- /package/{resources → dist/resources}/index.d.ts +0 -0
- /package/{resources → dist/resources}/index.d.ts.map +0 -0
- /package/{resources → dist/resources}/index.js +0 -0
- /package/{resources → dist/resources}/index.js.map +0 -0
- /package/{resources → dist/resources}/index.mjs +0 -0
- /package/{resources → dist/resources}/index.mjs.map +0 -0
- /package/{shims → dist/shims}/node.d.ts +0 -0
- /package/{shims → dist/shims}/node.d.ts.map +0 -0
- /package/{shims → dist/shims}/node.js +0 -0
- /package/{shims → dist/shims}/node.js.map +0 -0
- /package/{shims → dist/shims}/node.mjs +0 -0
- /package/{shims → dist/shims}/node.mjs.map +0 -0
- /package/{shims → dist/shims}/web.d.ts +0 -0
- /package/{shims → dist/shims}/web.d.ts.map +0 -0
- /package/{shims → dist/shims}/web.js +0 -0
- /package/{shims → dist/shims}/web.js.map +0 -0
- /package/{shims → dist/shims}/web.mjs +0 -0
- /package/{shims → dist/shims}/web.mjs.map +0 -0
- /package/{src → dist/src}/tsconfig.json +0 -0
- /package/{types → dist/types}/api.d.ts +0 -0
- /package/{types → dist/types}/api.d.ts.map +0 -0
- /package/{types → dist/types}/api.js +0 -0
- /package/{types → dist/types}/api.js.map +0 -0
- /package/{types → dist/types}/api.mjs +0 -0
- /package/{types → dist/types}/api.mjs.map +0 -0
- /package/{types → dist/types}/jwt.d.ts +0 -0
- /package/{types → dist/types}/jwt.d.ts.map +0 -0
- /package/{types → dist/types}/jwt.js +0 -0
- /package/{types → dist/types}/jwt.js.map +0 -0
- /package/{types → dist/types}/jwt.mjs +0 -0
- /package/{types → dist/types}/jwt.mjs.map +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { castToError, Headers } from './core';
|
|
2
|
+
|
|
3
|
+
export class SpaceDFError extends Error {}
|
|
4
|
+
|
|
5
|
+
export class APIError extends SpaceDFError {
|
|
6
|
+
readonly status: number | undefined;
|
|
7
|
+
readonly headers: Headers | undefined;
|
|
8
|
+
readonly error: object | undefined;
|
|
9
|
+
|
|
10
|
+
constructor(status: number | undefined, error: object | undefined, message: string | undefined, headers: Headers | undefined) {
|
|
11
|
+
super(`${APIError.makeMessage(status, error, message)}`);
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.headers = headers;
|
|
14
|
+
this.error = error;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
|
|
18
|
+
const msg = error?.message
|
|
19
|
+
? typeof error.message === 'string'
|
|
20
|
+
? error.message
|
|
21
|
+
: JSON.stringify(error.message)
|
|
22
|
+
: error
|
|
23
|
+
? JSON.stringify(error)
|
|
24
|
+
: message;
|
|
25
|
+
|
|
26
|
+
if (status && msg) {
|
|
27
|
+
return `${status} ${msg}`;
|
|
28
|
+
}
|
|
29
|
+
if (status) {
|
|
30
|
+
return `${status} status code (no body)`;
|
|
31
|
+
}
|
|
32
|
+
if (msg) {
|
|
33
|
+
return msg;
|
|
34
|
+
}
|
|
35
|
+
return '(no status code or body)';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static generate(status: number | undefined, errorResponse: object | undefined, message: string | undefined, headers: Headers | undefined) {
|
|
39
|
+
if (!status) {
|
|
40
|
+
return new APIConnectionError({ message, cause: castToError(errorResponse) });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const error = errorResponse as Record<string, any>;
|
|
44
|
+
|
|
45
|
+
if (status === 400) {
|
|
46
|
+
return new BadRequestError(status, error, message, headers);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (status === 401) {
|
|
50
|
+
return new AuthenticationError(status, error, message, headers);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (status === 403) {
|
|
54
|
+
return new PermissionDeniedError(status, error, message, headers);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (status === 404) {
|
|
58
|
+
return new NotFoundError(status, error, message, headers);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (status === 409) {
|
|
62
|
+
return new ConflictError(status, error, message, headers);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (status === 422) {
|
|
66
|
+
return new UnprocessableEntityError(status, error, message, headers);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (status === 429) {
|
|
70
|
+
return new RateLimitError(status, error, message, headers);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (status >= 500) {
|
|
74
|
+
return new InternalServerError(status, error, message, headers);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return new APIError(status, error, message, headers);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export class APIUserAbortError extends APIError {
|
|
82
|
+
override readonly status: undefined = undefined;
|
|
83
|
+
|
|
84
|
+
constructor({ message }: { message?: string } = {}) {
|
|
85
|
+
super(undefined, undefined, message || 'Request was aborted.', undefined);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export class APIConnectionError extends APIError {
|
|
90
|
+
override readonly status: undefined = undefined;
|
|
91
|
+
|
|
92
|
+
constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
|
|
93
|
+
super(undefined, undefined, message || 'Connection error.', undefined);
|
|
94
|
+
// in some environments the 'cause' property is already declared
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
if (cause) this.cause = cause;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export class APIConnectionTimeoutError extends APIConnectionError {
|
|
101
|
+
constructor({ message }: { message?: string } = {}) {
|
|
102
|
+
super({ message: message ?? 'Request timed out.' });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export class BadRequestError extends APIError {
|
|
107
|
+
override readonly status = 400 as const;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export class AuthenticationError extends APIError {
|
|
111
|
+
override readonly status = 401 as const;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export class PermissionDeniedError extends APIError {
|
|
115
|
+
override readonly status = 403 as const;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export class NotFoundError extends APIError {
|
|
119
|
+
override readonly status = 404 as const;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export class ConflictError extends APIError {
|
|
123
|
+
override readonly status = 409 as const;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export class UnprocessableEntityError extends APIError {
|
|
127
|
+
override readonly status = 422 as const;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export class RateLimitError extends APIError {
|
|
131
|
+
override readonly status = 429 as const;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export class InternalServerError extends APIError {}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import * as Errors from './error';
|
|
2
|
+
import { type Agent } from './_shims/index';
|
|
3
|
+
import * as Core from './core';
|
|
4
|
+
import * as API from './resources/index';
|
|
5
|
+
|
|
6
|
+
export interface ClientOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Defaults to process.env['SPACEDF_ORG_ID'].
|
|
9
|
+
*/
|
|
10
|
+
organization?: string | null | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Defaults to process.env['SPACEDF_API_KEY'].
|
|
13
|
+
*/
|
|
14
|
+
APIKey?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
17
|
+
*
|
|
18
|
+
* Defaults to process.env['SPACEDF_SDK_BASE_URL'].
|
|
19
|
+
*/
|
|
20
|
+
baseURL?: string | null | undefined;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
24
|
+
* from the server before timing out a single request.
|
|
25
|
+
*
|
|
26
|
+
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
27
|
+
* much longer than this timeout before the promise succeeds or fails.
|
|
28
|
+
*/
|
|
29
|
+
timeout?: number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* An HTTP agent used to manage HTTP(S) connections.
|
|
33
|
+
*
|
|
34
|
+
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
35
|
+
* otherwise no agent is used.
|
|
36
|
+
*/
|
|
37
|
+
httpAgent?: Agent;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Specify a custom `fetch` function implementation.
|
|
41
|
+
*
|
|
42
|
+
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
43
|
+
* defined globally.
|
|
44
|
+
*/
|
|
45
|
+
fetch?: Core.Fetch | undefined;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The maximum number of times that the client will retry a request in case of a
|
|
49
|
+
* temporary failure, like a network error or a 5XX error from the server.
|
|
50
|
+
*
|
|
51
|
+
* @default 2
|
|
52
|
+
*/
|
|
53
|
+
maxRetries?: number;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Default headers to include with every request to the API.
|
|
57
|
+
*
|
|
58
|
+
* These can be removed in individual requests by explicitly setting the
|
|
59
|
+
* header to `undefined` or `null` in request options.
|
|
60
|
+
*/
|
|
61
|
+
defaultHeaders?: Core.Headers;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Default query parameters to include with every request to the API.
|
|
65
|
+
*
|
|
66
|
+
* These can be removed in individual requests by explicitly setting the
|
|
67
|
+
* param to `undefined` in request options.
|
|
68
|
+
*/
|
|
69
|
+
defaultQuery?: Core.DefaultQuery;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* By default, only use one instance per organization. If you want to use multiple organizations, use them on the server side.
|
|
73
|
+
*
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
allowMultiOrgs?: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* API Client for interfacing with the SpaceDF SDK API.
|
|
81
|
+
*/
|
|
82
|
+
export class SpaceDFSDK extends Core.APIClient {
|
|
83
|
+
organization: string | null;
|
|
84
|
+
accessToken: string | null | undefined;
|
|
85
|
+
|
|
86
|
+
private _options: ClientOptions;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* API Client for interfacing with the Spacedf SDK API.
|
|
90
|
+
*
|
|
91
|
+
* @param {string | null | undefined} [opts.organization=process.env['SPACEDF_ORG_ID'] ?? null]
|
|
92
|
+
* @param {string | undefined} [opts.APIKey=process.env['SPACEDF_API_KEY']]
|
|
93
|
+
* @param {string} [opts.baseURL=process.env['SPACEDF_SDK_BASE_URL'] ?? https://api.v0.spacedf.net/] - Override the default base URL for the API.
|
|
94
|
+
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
95
|
+
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
96
|
+
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
97
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
98
|
+
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
99
|
+
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
100
|
+
* @param {boolean} [opts.allowMultiOrgs=false] - Only set this option to `true` if you handle it on the server side or using multiple organizations.
|
|
101
|
+
*/
|
|
102
|
+
constructor({
|
|
103
|
+
baseURL = Core.readEnv('SPACEDF_SDK_BASE_URL'),
|
|
104
|
+
organization = Core.readEnv('SPACEDF_ORG_ID') ?? null,
|
|
105
|
+
APIKey = Core.readEnv('SPACEDF_API_KEY'),
|
|
106
|
+
allowMultiOrgs = false,
|
|
107
|
+
...opts
|
|
108
|
+
}: ClientOptions = {}) {
|
|
109
|
+
if (!allowMultiOrgs) {
|
|
110
|
+
if (baseURL && organization)
|
|
111
|
+
throw new Errors.SpaceDFError('`baseURL` will be overridden by `organization`. You should only configure a single property.');
|
|
112
|
+
|
|
113
|
+
if (organization) {
|
|
114
|
+
baseURL = `https://${organization}.api.v0.spacedf.net/api`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const options: ClientOptions = {
|
|
119
|
+
organization,
|
|
120
|
+
APIKey,
|
|
121
|
+
baseURL: baseURL || `https://api.v0.spacedf.net/api`,
|
|
122
|
+
...opts,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
super({
|
|
126
|
+
APIKey: options.APIKey,
|
|
127
|
+
baseURL: options.baseURL!,
|
|
128
|
+
timeout: options.timeout ?? 60 * 1000 /* 1 minute */,
|
|
129
|
+
httpAgent: options.httpAgent,
|
|
130
|
+
maxRetries: options.maxRetries,
|
|
131
|
+
allowMultiOrgs,
|
|
132
|
+
fetch: options.fetch,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
this._options = options;
|
|
136
|
+
this.APIKey = APIKey;
|
|
137
|
+
this.organization = organization;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
auth: API.Auth = new API.Auth(this);
|
|
141
|
+
spacePolicies: API.SpacePolicies = new API.SpacePolicies(this);
|
|
142
|
+
spaceRoleUsers: API.SpaceRoleUsers = new API.SpaceRoleUsers(this);
|
|
143
|
+
spaceRoles: API.SpaceRoles = new API.SpaceRoles(this);
|
|
144
|
+
spaces: API.Spaces = new API.Spaces(this);
|
|
145
|
+
dashboards: API.Dashboards = new API.Dashboards(this);
|
|
146
|
+
deviceStates: API.DeviceStates = new API.DeviceStates(this);
|
|
147
|
+
oauth2: API.OAuth2 = new API.OAuth2(this);
|
|
148
|
+
credentials: API.Credentials = new API.Credentials(this);
|
|
149
|
+
users: API.Users = new API.Users(this);
|
|
150
|
+
invitation: API.Invitation = new API.Invitation(this);
|
|
151
|
+
joinSpace: API.JoinSpace = new API.JoinSpace(this);
|
|
152
|
+
presignedUrl: API.PresignedUrl = new API.PresignedUrl(this);
|
|
153
|
+
|
|
154
|
+
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
155
|
+
return this._options.defaultQuery;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
159
|
+
return {
|
|
160
|
+
...super.defaultHeaders(opts),
|
|
161
|
+
...this._options.defaultHeaders,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
166
|
+
const Authorization = `Bearer ${(this.allowMultiOrgs && opts.accessToken) || this.accessToken || ''}`;
|
|
167
|
+
const APIKey = (this.allowMultiOrgs && opts.APIKey) || this.APIKey;
|
|
168
|
+
|
|
169
|
+
return { Authorization, 'x-api-key': APIKey };
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
public setAccessToken(token: string | null): void {
|
|
173
|
+
this.accessToken = token;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
static SpaceDFSDK = this;
|
|
177
|
+
static DEFAULT_TIMEOUT = 60 * 1000; // 1 minute
|
|
178
|
+
|
|
179
|
+
static SpaceDFError = Errors.SpaceDFError;
|
|
180
|
+
static APIError = Errors.APIError;
|
|
181
|
+
static APIConnectionError = Errors.APIConnectionError;
|
|
182
|
+
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
183
|
+
static APIUserAbortError = Errors.APIUserAbortError;
|
|
184
|
+
static NotFoundError = Errors.NotFoundError;
|
|
185
|
+
static ConflictError = Errors.ConflictError;
|
|
186
|
+
static RateLimitError = Errors.RateLimitError;
|
|
187
|
+
static BadRequestError = Errors.BadRequestError;
|
|
188
|
+
static AuthenticationError = Errors.AuthenticationError;
|
|
189
|
+
static InternalServerError = Errors.InternalServerError;
|
|
190
|
+
static PermissionDeniedError = Errors.PermissionDeniedError;
|
|
191
|
+
static UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export const {
|
|
195
|
+
SpaceDFError,
|
|
196
|
+
APIError,
|
|
197
|
+
APIConnectionError,
|
|
198
|
+
APIConnectionTimeoutError,
|
|
199
|
+
APIUserAbortError,
|
|
200
|
+
NotFoundError,
|
|
201
|
+
ConflictError,
|
|
202
|
+
RateLimitError,
|
|
203
|
+
BadRequestError,
|
|
204
|
+
AuthenticationError,
|
|
205
|
+
InternalServerError,
|
|
206
|
+
PermissionDeniedError,
|
|
207
|
+
UnprocessableEntityError,
|
|
208
|
+
} = Errors;
|
|
209
|
+
|
|
210
|
+
export default SpaceDFSDK;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { SpaceDFError } from '../error';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Converts a given string to its Base64 encoded representation.
|
|
6
|
+
*
|
|
7
|
+
* @param {string | null | undefined} str - The input string to be encoded in Base64. If the input is `null` or `undefined`, an empty string is returned.
|
|
8
|
+
*
|
|
9
|
+
* @returns {string} - The Base64 encoded string. If the input is invalid (null or undefined), an empty string is returned.
|
|
10
|
+
*
|
|
11
|
+
* This function works in both Node.js and browser environments:
|
|
12
|
+
* - In **Node.js**, it uses `Buffer.from()` to convert the string into Base64.
|
|
13
|
+
* - In **browser environments**, it uses the `btoa()` function to generate the Base64 encoded string.
|
|
14
|
+
*
|
|
15
|
+
* If neither `Buffer` (Node.js) nor `btoa` (browser) are available, it throws a custom `SpaceDFError`.
|
|
16
|
+
*
|
|
17
|
+
* @throws {SpaceDFError} - Throws an error if neither `Buffer` nor `btoa` are available for Base64 encoding.
|
|
18
|
+
*/
|
|
19
|
+
export const toBase64 = (str: string | null | undefined): string => {
|
|
20
|
+
if (!str) return '';
|
|
21
|
+
if (typeof Buffer !== 'undefined') {
|
|
22
|
+
return Buffer.from(str).toString('base64');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (typeof btoa !== 'undefined') {
|
|
26
|
+
return btoa(str);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
throw new SpaceDFError('Cannot generate b64 string; Expected `Buffer` or `btoa` to be defined');
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Generates a SHA-256 hash for the provided data, compatible with both Node.js and browser environments.
|
|
34
|
+
*
|
|
35
|
+
* @param data - The data to hash, either as a string or a binary-like object.
|
|
36
|
+
* @returns A promise that resolves to the SHA-256 hash as an ArrayBuffer (in browser) or Buffer (in Node.js).
|
|
37
|
+
*/
|
|
38
|
+
export const toSHA256 = async (data: string | NodeJS.ArrayBufferView) => {
|
|
39
|
+
const encodedData = typeof data === 'string' ? new TextEncoder().encode(data) : data;
|
|
40
|
+
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
if (typeof globalThis !== 'undefined' && typeof globalThis.crypto !== 'undefined') {
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
const hash = await globalThis.crypto.subtle.digest('SHA-256', encodedData);
|
|
45
|
+
return hash;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return createHash('sha256').update(encodedData).digest();
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export function isObj(obj: unknown): obj is Record<string, unknown> {
|
|
52
|
+
return obj != null && typeof obj === 'object' && !Array.isArray(obj);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* https://stackoverflow.com/a/2117523
|
|
57
|
+
*/
|
|
58
|
+
export const uuid4 = () => {
|
|
59
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
60
|
+
const r = (Math.random() * 16) | 0;
|
|
61
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
62
|
+
return v.toString(16);
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const rstripBase64 = (base64: string) => base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { APIResource } from '../../resource';
|
|
2
|
+
import * as Core from '../../core';
|
|
3
|
+
|
|
4
|
+
export class Auth extends APIResource {
|
|
5
|
+
login(body: AuthLoginParams, options?: Core.RequestOptions): Core.APIPromise<AuthTokenPair> {
|
|
6
|
+
return this._client.post(`/auth/login`, { body, ...options });
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
oauth2Google(body: OAuthLogin, options?: Core.RequestOptions): Core.APIPromise<OAuthLogin> {
|
|
10
|
+
return this._client.post(`/auth/oauth2/google`, { body, ...options });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
oauthSendOtp(body: OAuthSendOtp, options?: Core.RequestOptions): Core.APIPromise<OAuthSendOtp> {
|
|
14
|
+
return this._client.post(`/auth/send-otp`, { body, ...options });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
oauth2SpaceDF(body: OAuthSpaceDF, options?: Core.RequestOptions): Core.APIPromise<OAuthSpaceDF> {
|
|
18
|
+
return this._client.post(`/auth/oauth2/spacedf-console`, { body, ...options });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
refreshToken(body: AuthRefreshTokenParams, options?: Core.RequestOptions): Core.APIPromise<CustomTokenRefresh> {
|
|
22
|
+
return this._client.post(`/auth/refresh-token`, { body, ...options });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
register(body: AuthRegisterParams, options?: Core.RequestOptions): Core.APIPromise<Registration> {
|
|
26
|
+
return this._client.post(`/auth/register`, { body, ...options });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
switchSpaces(body: AuthRefreshTokenParams, options?: Core.RequestOptions): Core.APIPromise<CustomTokenRefresh> {
|
|
30
|
+
return this._client.post(`/auth/spaces/switch`, { body, ...options });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface AuthTokenPair {
|
|
35
|
+
refresh: string;
|
|
36
|
+
|
|
37
|
+
access: string;
|
|
38
|
+
|
|
39
|
+
default_space: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface CustomTokenRefresh {
|
|
43
|
+
refresh: string;
|
|
44
|
+
|
|
45
|
+
access?: string;
|
|
46
|
+
|
|
47
|
+
space?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface OAuthLogin {
|
|
51
|
+
authorization_code: string;
|
|
52
|
+
|
|
53
|
+
code_verifier: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface OAuthSendOtp {
|
|
57
|
+
email: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface OAuthSpaceDF {
|
|
61
|
+
code_verifier: string;
|
|
62
|
+
|
|
63
|
+
code: string;
|
|
64
|
+
|
|
65
|
+
client_id: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface Registration {
|
|
69
|
+
id?: number;
|
|
70
|
+
|
|
71
|
+
first_name: string;
|
|
72
|
+
|
|
73
|
+
last_name: string;
|
|
74
|
+
|
|
75
|
+
email: string;
|
|
76
|
+
|
|
77
|
+
default_space?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface AuthLoginParams {
|
|
81
|
+
email: string;
|
|
82
|
+
|
|
83
|
+
password: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface AuthRefreshTokenParams {
|
|
87
|
+
refresh: string;
|
|
88
|
+
|
|
89
|
+
space: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface AuthRegisterParams {
|
|
93
|
+
email: string;
|
|
94
|
+
|
|
95
|
+
password: string;
|
|
96
|
+
|
|
97
|
+
first_name: string;
|
|
98
|
+
|
|
99
|
+
last_name: string;
|
|
100
|
+
|
|
101
|
+
otp: string;
|
|
102
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { APIResource } from '../../resource';
|
|
2
|
+
import * as Core from '../../core';
|
|
3
|
+
|
|
4
|
+
export class Credentials extends APIResource {
|
|
5
|
+
retrieve(options?: Core.RequestOptions): Core.APIPromise<OAuthCredentials> {
|
|
6
|
+
return this._client.get(`/credentials`, options);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface OAuthCredentials {
|
|
11
|
+
client_id: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './auth';
|
|
2
|
+
export * from './spaces';
|
|
3
|
+
export * from './space-policies';
|
|
4
|
+
export * from './space-roles';
|
|
5
|
+
export * from './space-role-users';
|
|
6
|
+
export * from './credentials';
|
|
7
|
+
export * from './users';
|
|
8
|
+
export * from './invitation';
|
|
9
|
+
export * from './join-space';
|
|
10
|
+
export * from './presigned-url';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { APIResource } from '../../resource';
|
|
2
|
+
import * as Core from '../../core';
|
|
3
|
+
|
|
4
|
+
export class Invitation extends APIResource {
|
|
5
|
+
create(id: number, body: OAuthInvitation, options?: Core.RequestOptions): Core.APIPromise<OAuthInvitation> {
|
|
6
|
+
return this._client.post(`/invitation/${id}`, { body, ...options });
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface OAuthInvitation {
|
|
11
|
+
receiver_list: Receiver[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface Receiver {
|
|
15
|
+
email: string;
|
|
16
|
+
space_role_id: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { APIResource } from '../../resource';
|
|
2
|
+
import * as Core from '../../core';
|
|
3
|
+
|
|
4
|
+
export class JoinSpace extends APIResource {
|
|
5
|
+
get(token: string, options?: Core.RequestOptions): Core.APIPromise<void> {
|
|
6
|
+
return this._client.get(`/join-space/${token}`, options);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { APIResource } from '../../resource';
|
|
2
|
+
import * as Core from '../../core';
|
|
3
|
+
|
|
4
|
+
export class PresignedUrl extends APIResource {
|
|
5
|
+
get(options?: Core.RequestOptions): Core.APIPromise<PresignedUrlResponse> {
|
|
6
|
+
return this._client.get('/presigned-url', options);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface PresignedUrlResponse {
|
|
11
|
+
presigned_url: string;
|
|
12
|
+
file_name: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { APIResource } from '../../resource';
|
|
2
|
+
import { isRequestOptions } from '../../core';
|
|
3
|
+
import { ListParamsResponse, ListResponse } from '../../types/api';
|
|
4
|
+
import * as Core from '../../core';
|
|
5
|
+
|
|
6
|
+
export class SpacePolicies extends APIResource {
|
|
7
|
+
retrieve(id: number, options?: Core.RequestOptions): Core.APIPromise<SpacePolicy> {
|
|
8
|
+
return this._client.get(`/space-policies/${id}`, options);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
list(query?: SpacePolicyListParams, options?: Core.RequestOptions): Core.APIPromise<SpacePolicyListResponse>;
|
|
12
|
+
list(options?: Core.RequestOptions): Core.APIPromise<SpacePolicyListResponse>;
|
|
13
|
+
list(query: SpacePolicyListParams | Core.RequestOptions = {}, options?: Core.RequestOptions): Core.APIPromise<SpacePolicyListResponse> {
|
|
14
|
+
if (isRequestOptions(query)) {
|
|
15
|
+
return this.list({}, query);
|
|
16
|
+
}
|
|
17
|
+
return this._client.get(`/space-policies`, { query, ...options });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SpacePolicy {
|
|
22
|
+
description: string;
|
|
23
|
+
|
|
24
|
+
name: string;
|
|
25
|
+
|
|
26
|
+
permissions: Array<
|
|
27
|
+
| 'UPDATE_SPACE'
|
|
28
|
+
| 'DELETE_SPACE'
|
|
29
|
+
| 'READ_SPACE_ROLE'
|
|
30
|
+
| 'CREATE_SPACE_ROLE'
|
|
31
|
+
| 'UPDATE_SPACE_ROLE'
|
|
32
|
+
| 'DELETE_SPACE_ROLE'
|
|
33
|
+
| 'READ_SPACE_MEMBER'
|
|
34
|
+
| 'INVITE_SPACE_MEMBER'
|
|
35
|
+
| 'UPDATE_SPACE_MEMBER_ROLE'
|
|
36
|
+
| 'REMOVE_SPACE_MEMBER'
|
|
37
|
+
| 'READ_DASHBOARD'
|
|
38
|
+
| 'CREATE_DASHBOARD'
|
|
39
|
+
| 'UPDATE_DASHBOARD'
|
|
40
|
+
| 'DELETE_DASHBOARD'
|
|
41
|
+
| 'READ_DEVICE_STATE'
|
|
42
|
+
>;
|
|
43
|
+
|
|
44
|
+
tags: Array<string>;
|
|
45
|
+
|
|
46
|
+
id?: number;
|
|
47
|
+
|
|
48
|
+
readonly created_at?: string;
|
|
49
|
+
|
|
50
|
+
readonly updated_at?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type SpacePolicyListResponse = ListResponse<SpacePolicy>;
|
|
54
|
+
|
|
55
|
+
export type SpacePolicyListParams = ListParamsResponse;
|