@space-df/sdk 0.0.1-dev.10

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.
Files changed (353) hide show
  1. package/.editorconfig +24 -0
  2. package/.github/pull_request_template.md +25 -0
  3. package/.github/workflows/bump-version.yml +67 -0
  4. package/.github/workflows/publish-package.yml +28 -0
  5. package/.gitignore +11 -0
  6. package/CODE_OF_CONDUCT.md +128 -0
  7. package/CONTRIBUTING.md +89 -0
  8. package/LICENSE +7 -0
  9. package/README.md +382 -0
  10. package/api.doc.md +1558 -0
  11. package/dist/LICENSE +7 -0
  12. package/dist/README.md +382 -0
  13. package/dist/_shims/MultipartBody.d.ts +9 -0
  14. package/dist/_shims/MultipartBody.d.ts.map +1 -0
  15. package/dist/_shims/MultipartBody.js +16 -0
  16. package/dist/_shims/MultipartBody.js.map +1 -0
  17. package/dist/_shims/MultipartBody.mjs +12 -0
  18. package/dist/_shims/MultipartBody.mjs.map +1 -0
  19. package/dist/_shims/README.md +46 -0
  20. package/dist/_shims/auto/runtime-bun.d.ts +5 -0
  21. package/dist/_shims/auto/runtime-bun.d.ts.map +1 -0
  22. package/dist/_shims/auto/runtime-bun.js +21 -0
  23. package/dist/_shims/auto/runtime-bun.js.map +1 -0
  24. package/dist/_shims/auto/runtime-bun.mjs +2 -0
  25. package/dist/_shims/auto/runtime-bun.mjs.map +1 -0
  26. package/dist/_shims/auto/runtime-node.d.ts +5 -0
  27. package/dist/_shims/auto/runtime-node.d.ts.map +1 -0
  28. package/dist/_shims/auto/runtime-node.js +21 -0
  29. package/dist/_shims/auto/runtime-node.js.map +1 -0
  30. package/dist/_shims/auto/runtime-node.mjs +2 -0
  31. package/dist/_shims/auto/runtime-node.mjs.map +1 -0
  32. package/dist/_shims/auto/runtime.d.ts +5 -0
  33. package/dist/_shims/auto/runtime.d.ts.map +1 -0
  34. package/dist/_shims/auto/runtime.js +21 -0
  35. package/dist/_shims/auto/runtime.js.map +1 -0
  36. package/dist/_shims/auto/runtime.mjs +2 -0
  37. package/dist/_shims/auto/runtime.mjs.map +1 -0
  38. package/dist/_shims/auto/types-node.d.ts +5 -0
  39. package/dist/_shims/auto/types-node.d.ts.map +1 -0
  40. package/dist/_shims/auto/types-node.js +21 -0
  41. package/dist/_shims/auto/types-node.js.map +1 -0
  42. package/dist/_shims/auto/types-node.mjs +2 -0
  43. package/dist/_shims/auto/types-node.mjs.map +1 -0
  44. package/dist/_shims/auto/types.d.ts +101 -0
  45. package/dist/_shims/auto/types.js +3 -0
  46. package/dist/_shims/auto/types.mjs +3 -0
  47. package/dist/_shims/bun-runtime.d.ts +6 -0
  48. package/dist/_shims/bun-runtime.d.ts.map +1 -0
  49. package/dist/_shims/bun-runtime.js +14 -0
  50. package/dist/_shims/bun-runtime.js.map +1 -0
  51. package/dist/_shims/bun-runtime.mjs +10 -0
  52. package/dist/_shims/bun-runtime.mjs.map +1 -0
  53. package/dist/_shims/index.d.ts +72 -0
  54. package/dist/_shims/index.js +13 -0
  55. package/dist/_shims/index.mjs +7 -0
  56. package/dist/_shims/manual-types.d.ts +12 -0
  57. package/dist/_shims/manual-types.js +3 -0
  58. package/dist/_shims/manual-types.mjs +3 -0
  59. package/dist/_shims/node-runtime.d.ts +3 -0
  60. package/dist/_shims/node-runtime.d.ts.map +1 -0
  61. package/dist/_shims/node-runtime.js +89 -0
  62. package/dist/_shims/node-runtime.js.map +1 -0
  63. package/dist/_shims/node-runtime.mjs +56 -0
  64. package/dist/_shims/node-runtime.mjs.map +1 -0
  65. package/dist/_shims/node-types.d.ts +42 -0
  66. package/dist/_shims/node-types.js +3 -0
  67. package/dist/_shims/node-types.mjs +3 -0
  68. package/dist/_shims/registry.d.ts +37 -0
  69. package/dist/_shims/registry.d.ts.map +1 -0
  70. package/dist/_shims/registry.js +41 -0
  71. package/dist/_shims/registry.js.map +1 -0
  72. package/dist/_shims/registry.mjs +37 -0
  73. package/dist/_shims/registry.mjs.map +1 -0
  74. package/dist/_shims/web-runtime.d.ts +5 -0
  75. package/dist/_shims/web-runtime.d.ts.map +1 -0
  76. package/dist/_shims/web-runtime.js +89 -0
  77. package/dist/_shims/web-runtime.js.map +1 -0
  78. package/dist/_shims/web-runtime.mjs +82 -0
  79. package/dist/_shims/web-runtime.mjs.map +1 -0
  80. package/dist/_shims/web-types.d.ts +83 -0
  81. package/dist/_shims/web-types.js +3 -0
  82. package/dist/_shims/web-types.mjs +3 -0
  83. package/dist/core.d.ts +237 -0
  84. package/dist/core.d.ts.map +1 -0
  85. package/dist/core.js +855 -0
  86. package/dist/core.js.map +1 -0
  87. package/dist/core.mjs +829 -0
  88. package/dist/core.mjs.map +1 -0
  89. package/dist/error.d.ts +53 -0
  90. package/dist/error.d.ts.map +1 -0
  91. package/dist/error.js +143 -0
  92. package/dist/error.js.map +1 -0
  93. package/dist/error.mjs +127 -0
  94. package/dist/error.mjs.map +1 -0
  95. package/dist/index.d.mts +125 -0
  96. package/dist/index.d.ts +125 -0
  97. package/dist/index.d.ts.map +1 -0
  98. package/dist/index.js +125 -0
  99. package/dist/index.js.map +1 -0
  100. package/dist/index.mjs +97 -0
  101. package/dist/index.mjs.map +1 -0
  102. package/dist/libs/utils.d.ts +34 -0
  103. package/dist/libs/utils.d.ts.map +1 -0
  104. package/dist/libs/utils.js +67 -0
  105. package/dist/libs/utils.js.map +1 -0
  106. package/dist/libs/utils.mjs +59 -0
  107. package/dist/libs/utils.mjs.map +1 -0
  108. package/dist/package.json +101 -0
  109. package/dist/resource.d.ts +6 -0
  110. package/dist/resource.d.ts.map +1 -0
  111. package/dist/resource.js +10 -0
  112. package/dist/resource.js.map +1 -0
  113. package/dist/resource.mjs +6 -0
  114. package/dist/resource.mjs.map +1 -0
  115. package/dist/resources/auth/auth.d.ts +60 -0
  116. package/dist/resources/auth/auth.d.ts.map +1 -0
  117. package/dist/resources/auth/auth.js +32 -0
  118. package/dist/resources/auth/auth.js.map +1 -0
  119. package/dist/resources/auth/auth.mjs +28 -0
  120. package/dist/resources/auth/auth.mjs.map +1 -0
  121. package/dist/resources/auth/credentials.d.ts +9 -0
  122. package/dist/resources/auth/credentials.d.ts.map +1 -0
  123. package/dist/resources/auth/credentials.js +11 -0
  124. package/dist/resources/auth/credentials.js.map +1 -0
  125. package/dist/resources/auth/credentials.mjs +7 -0
  126. package/dist/resources/auth/credentials.mjs.map +1 -0
  127. package/dist/resources/auth/index.d.ts +9 -0
  128. package/dist/resources/auth/index.d.ts.map +1 -0
  129. package/dist/resources/auth/index.js +25 -0
  130. package/dist/resources/auth/index.js.map +1 -0
  131. package/dist/resources/auth/index.mjs +9 -0
  132. package/dist/resources/auth/index.mjs.map +1 -0
  133. package/dist/resources/auth/presigned-url.d.ts +10 -0
  134. package/dist/resources/auth/presigned-url.d.ts.map +1 -0
  135. package/dist/resources/auth/presigned-url.js +11 -0
  136. package/dist/resources/auth/presigned-url.js.map +1 -0
  137. package/dist/resources/auth/presigned-url.mjs +7 -0
  138. package/dist/resources/auth/presigned-url.mjs.map +1 -0
  139. package/dist/resources/auth/space-policies.d.ts +20 -0
  140. package/dist/resources/auth/space-policies.d.ts.map +1 -0
  141. package/dist/resources/auth/space-policies.js +18 -0
  142. package/dist/resources/auth/space-policies.js.map +1 -0
  143. package/dist/resources/auth/space-policies.mjs +14 -0
  144. package/dist/resources/auth/space-policies.mjs.map +1 -0
  145. package/dist/resources/auth/space-role-users.d.ts +22 -0
  146. package/dist/resources/auth/space-role-users.d.ts.map +1 -0
  147. package/dist/resources/auth/space-role-users.js +44 -0
  148. package/dist/resources/auth/space-role-users.js.map +1 -0
  149. package/dist/resources/auth/space-role-users.mjs +40 -0
  150. package/dist/resources/auth/space-role-users.mjs.map +1 -0
  151. package/dist/resources/auth/space-roles.d.ts +41 -0
  152. package/dist/resources/auth/space-roles.d.ts.map +1 -0
  153. package/dist/resources/auth/space-roles.js +52 -0
  154. package/dist/resources/auth/space-roles.js.map +1 -0
  155. package/dist/resources/auth/space-roles.mjs +48 -0
  156. package/dist/resources/auth/space-roles.mjs.map +1 -0
  157. package/dist/resources/auth/spaces.d.ts +74 -0
  158. package/dist/resources/auth/spaces.d.ts.map +1 -0
  159. package/dist/resources/auth/spaces.js +51 -0
  160. package/dist/resources/auth/spaces.js.map +1 -0
  161. package/dist/resources/auth/spaces.mjs +47 -0
  162. package/dist/resources/auth/spaces.mjs.map +1 -0
  163. package/dist/resources/auth/users.d.ts +19 -0
  164. package/dist/resources/auth/users.d.ts.map +1 -0
  165. package/dist/resources/auth/users.js +17 -0
  166. package/dist/resources/auth/users.js.map +1 -0
  167. package/dist/resources/auth/users.mjs +13 -0
  168. package/dist/resources/auth/users.mjs.map +1 -0
  169. package/dist/resources/console/index.d.ts +2 -0
  170. package/dist/resources/console/index.d.ts.map +1 -0
  171. package/dist/resources/console/index.js +18 -0
  172. package/dist/resources/console/index.js.map +1 -0
  173. package/dist/resources/console/index.mjs +2 -0
  174. package/dist/resources/console/index.mjs.map +1 -0
  175. package/dist/resources/console/oauth2.d.ts +53 -0
  176. package/dist/resources/console/oauth2.d.ts.map +1 -0
  177. package/dist/resources/console/oauth2.js +20 -0
  178. package/dist/resources/console/oauth2.js.map +1 -0
  179. package/dist/resources/console/oauth2.mjs +16 -0
  180. package/dist/resources/console/oauth2.mjs.map +1 -0
  181. package/dist/resources/dashboard/dashboards.d.ts +67 -0
  182. package/dist/resources/dashboard/dashboards.d.ts.map +1 -0
  183. package/dist/resources/dashboard/dashboards.js +96 -0
  184. package/dist/resources/dashboard/dashboards.js.map +1 -0
  185. package/dist/resources/dashboard/dashboards.mjs +92 -0
  186. package/dist/resources/dashboard/dashboards.mjs.map +1 -0
  187. package/dist/resources/dashboard/device-states.d.ts +69 -0
  188. package/dist/resources/dashboard/device-states.d.ts.map +1 -0
  189. package/dist/resources/dashboard/device-states.js +40 -0
  190. package/dist/resources/dashboard/device-states.js.map +1 -0
  191. package/dist/resources/dashboard/device-states.mjs +36 -0
  192. package/dist/resources/dashboard/device-states.mjs.map +1 -0
  193. package/dist/resources/dashboard/index.d.ts +3 -0
  194. package/dist/resources/dashboard/index.d.ts.map +1 -0
  195. package/dist/resources/dashboard/index.js +19 -0
  196. package/dist/resources/dashboard/index.js.map +1 -0
  197. package/dist/resources/dashboard/index.mjs +3 -0
  198. package/dist/resources/dashboard/index.mjs.map +1 -0
  199. package/dist/resources/index.d.ts +7 -0
  200. package/dist/resources/index.d.ts.map +1 -0
  201. package/dist/resources/index.js +23 -0
  202. package/dist/resources/index.js.map +1 -0
  203. package/dist/resources/index.mjs +4 -0
  204. package/dist/resources/index.mjs.map +1 -0
  205. package/dist/shims/node.d.ts +30 -0
  206. package/dist/shims/node.d.ts.map +1 -0
  207. package/dist/shims/node.js +31 -0
  208. package/dist/shims/node.js.map +1 -0
  209. package/dist/shims/node.mjs +5 -0
  210. package/dist/shims/node.mjs.map +1 -0
  211. package/dist/shims/web.d.ts +26 -0
  212. package/dist/shims/web.d.ts.map +1 -0
  213. package/dist/shims/web.js +31 -0
  214. package/dist/shims/web.js.map +1 -0
  215. package/dist/shims/web.mjs +5 -0
  216. package/dist/shims/web.mjs.map +1 -0
  217. package/dist/src/_shims/MultipartBody.ts +9 -0
  218. package/dist/src/_shims/README.md +46 -0
  219. package/dist/src/_shims/auto/runtime-bun.ts +4 -0
  220. package/dist/src/_shims/auto/runtime-node.ts +4 -0
  221. package/dist/src/_shims/auto/runtime.ts +4 -0
  222. package/dist/src/_shims/auto/types-node.ts +4 -0
  223. package/dist/src/_shims/auto/types.d.ts +101 -0
  224. package/dist/src/_shims/auto/types.js +3 -0
  225. package/dist/src/_shims/auto/types.mjs +3 -0
  226. package/dist/src/_shims/bun-runtime.ts +14 -0
  227. package/dist/src/_shims/index.d.ts +72 -0
  228. package/dist/src/_shims/index.js +13 -0
  229. package/dist/src/_shims/index.mjs +7 -0
  230. package/dist/src/_shims/manual-types.d.ts +12 -0
  231. package/dist/src/_shims/manual-types.js +3 -0
  232. package/dist/src/_shims/manual-types.mjs +3 -0
  233. package/dist/src/_shims/node-runtime.ts +78 -0
  234. package/dist/src/_shims/node-types.d.ts +42 -0
  235. package/dist/src/_shims/node-types.js +3 -0
  236. package/dist/src/_shims/node-types.mjs +3 -0
  237. package/dist/src/_shims/registry.ts +60 -0
  238. package/dist/src/_shims/web-runtime.ts +91 -0
  239. package/dist/src/_shims/web-types.d.ts +83 -0
  240. package/dist/src/_shims/web-types.js +3 -0
  241. package/dist/src/_shims/web-types.mjs +3 -0
  242. package/dist/src/core.ts +1061 -0
  243. package/dist/src/error.ts +134 -0
  244. package/dist/src/index.ts +208 -0
  245. package/dist/src/libs/utils.ts +66 -0
  246. package/dist/src/resource.ts +9 -0
  247. package/dist/src/resources/auth/auth.ts +110 -0
  248. package/dist/src/resources/auth/credentials.ts +12 -0
  249. package/dist/src/resources/auth/index.ts +8 -0
  250. package/dist/src/resources/auth/presigned-url.ts +13 -0
  251. package/dist/src/resources/auth/space-policies.ts +55 -0
  252. package/dist/src/resources/auth/space-role-users.ts +64 -0
  253. package/dist/src/resources/auth/space-roles.ts +95 -0
  254. package/dist/src/resources/auth/spaces.ts +140 -0
  255. package/dist/src/resources/auth/users.ts +36 -0
  256. package/dist/src/resources/console/index.ts +1 -0
  257. package/dist/src/resources/console/oauth2.ts +83 -0
  258. package/dist/src/resources/dashboard/dashboards.ts +171 -0
  259. package/dist/src/resources/dashboard/device-states.ts +142 -0
  260. package/dist/src/resources/dashboard/index.ts +2 -0
  261. package/dist/src/resources/index.ts +6 -0
  262. package/dist/src/shims/node.ts +50 -0
  263. package/dist/src/shims/web.ts +50 -0
  264. package/dist/src/tsconfig.json +11 -0
  265. package/dist/src/types/api.ts +31 -0
  266. package/dist/src/types/jwt.ts +12 -0
  267. package/dist/src/version.ts +1 -0
  268. package/dist/types/api.d.ts +25 -0
  269. package/dist/types/api.d.ts.map +1 -0
  270. package/dist/types/api.js +3 -0
  271. package/dist/types/api.js.map +1 -0
  272. package/dist/types/api.mjs +2 -0
  273. package/dist/types/api.mjs.map +1 -0
  274. package/dist/types/jwt.d.ts +13 -0
  275. package/dist/types/jwt.d.ts.map +1 -0
  276. package/dist/types/jwt.js +3 -0
  277. package/dist/types/jwt.js.map +1 -0
  278. package/dist/types/jwt.mjs +2 -0
  279. package/dist/types/jwt.mjs.map +1 -0
  280. package/dist/version.d.ts +2 -0
  281. package/dist/version.d.ts.map +1 -0
  282. package/dist/version.js +5 -0
  283. package/dist/version.js.map +1 -0
  284. package/dist/version.mjs +2 -0
  285. package/dist/version.mjs.map +1 -0
  286. package/eslint.config.mjs +33 -0
  287. package/examples/auth/login.ts +14 -0
  288. package/examples/auth/register.ts +15 -0
  289. package/examples/console/oauth2.ts +15 -0
  290. package/package.json +118 -0
  291. package/scripts/build +56 -0
  292. package/scripts/utils/check-version.cjs +20 -0
  293. package/scripts/utils/fix-index-exports.cjs +8 -0
  294. package/scripts/utils/make-dist-package-json.cjs +21 -0
  295. package/scripts/utils/postprocess-files.cjs +153 -0
  296. package/src/_shims/MultipartBody.ts +9 -0
  297. package/src/_shims/README.md +46 -0
  298. package/src/_shims/auto/runtime-bun.ts +4 -0
  299. package/src/_shims/auto/runtime-deno.ts +4 -0
  300. package/src/_shims/auto/runtime-node.ts +4 -0
  301. package/src/_shims/auto/runtime.ts +4 -0
  302. package/src/_shims/auto/types-deno.ts +4 -0
  303. package/src/_shims/auto/types-node.ts +4 -0
  304. package/src/_shims/auto/types.d.ts +101 -0
  305. package/src/_shims/auto/types.js +3 -0
  306. package/src/_shims/auto/types.mjs +3 -0
  307. package/src/_shims/bun-runtime.ts +14 -0
  308. package/src/_shims/index-deno.ts +105 -0
  309. package/src/_shims/index.d.ts +72 -0
  310. package/src/_shims/index.js +13 -0
  311. package/src/_shims/index.mjs +7 -0
  312. package/src/_shims/manual-types.d.ts +12 -0
  313. package/src/_shims/manual-types.js +3 -0
  314. package/src/_shims/manual-types.mjs +3 -0
  315. package/src/_shims/node-runtime.ts +78 -0
  316. package/src/_shims/node-types.d.ts +42 -0
  317. package/src/_shims/node-types.js +3 -0
  318. package/src/_shims/node-types.mjs +3 -0
  319. package/src/_shims/registry.ts +60 -0
  320. package/src/_shims/web-runtime.ts +91 -0
  321. package/src/_shims/web-types.d.ts +83 -0
  322. package/src/_shims/web-types.js +3 -0
  323. package/src/_shims/web-types.mjs +3 -0
  324. package/src/core.ts +1061 -0
  325. package/src/error.ts +134 -0
  326. package/src/index.ts +208 -0
  327. package/src/libs/utils.ts +66 -0
  328. package/src/resource.ts +9 -0
  329. package/src/resources/auth/auth.ts +110 -0
  330. package/src/resources/auth/credentials.ts +12 -0
  331. package/src/resources/auth/index.ts +8 -0
  332. package/src/resources/auth/presigned-url.ts +13 -0
  333. package/src/resources/auth/space-policies.ts +55 -0
  334. package/src/resources/auth/space-role-users.ts +64 -0
  335. package/src/resources/auth/space-roles.ts +95 -0
  336. package/src/resources/auth/spaces.ts +140 -0
  337. package/src/resources/auth/users.ts +36 -0
  338. package/src/resources/console/index.ts +1 -0
  339. package/src/resources/console/oauth2.ts +83 -0
  340. package/src/resources/dashboard/dashboards.ts +171 -0
  341. package/src/resources/dashboard/device-states.ts +142 -0
  342. package/src/resources/dashboard/index.ts +2 -0
  343. package/src/resources/index.ts +6 -0
  344. package/src/shims/node.ts +50 -0
  345. package/src/shims/web.ts +50 -0
  346. package/src/types/api.ts +31 -0
  347. package/src/types/jwt.ts +12 -0
  348. package/src/version.ts +1 -0
  349. package/tsc-multi.json +7 -0
  350. package/tsconfig.build.json +18 -0
  351. package/tsconfig.deno.json +20 -0
  352. package/tsconfig.dist-src.json +11 -0
  353. package/tsconfig.json +38 -0
@@ -0,0 +1,95 @@
1
+ import { APIResource } from '../../resource';
2
+ import { ListParamsResponse, ListResponse } from '../../types/api';
3
+ import * as Core from '../../core';
4
+
5
+ export class SpaceRoles extends APIResource {
6
+ create(params: SpaceRoleCreateParams, options?: Core.RequestOptions): Core.APIPromise<SpaceRole> {
7
+ const { ...body } = params;
8
+ return this._client.post(`/space-roles`, {
9
+ body,
10
+ ...options,
11
+ headers: { ...options?.headers },
12
+ });
13
+ }
14
+
15
+ retrieve(id: number, options?: Core.RequestOptions): Core.APIPromise<SpaceRole> {
16
+ return this._client.get(`/space-roles/${id}`, {
17
+ ...options,
18
+ headers: { ...options?.headers },
19
+ });
20
+ }
21
+
22
+ update(id: number, params: SpaceRoleUpdateParams, options?: Core.RequestOptions): Core.APIPromise<SpaceRole> {
23
+ const { ...body } = params;
24
+ return this._client.put(`/space-roles/${id}`, {
25
+ body,
26
+ ...options,
27
+ headers: { ...options?.headers },
28
+ });
29
+ }
30
+
31
+ partialUpdate(id: number, params: SpaceRoleUpdateParams, options?: Core.RequestOptions): Core.APIPromise<SpaceRole> {
32
+ const { ...body } = params;
33
+ return this._client.patch(`/space-roles/${id}`, {
34
+ body,
35
+ ...options,
36
+ headers: { ...options?.headers },
37
+ });
38
+ }
39
+
40
+ list(params: ListParamsResponse, options?: Core.RequestOptions): Core.APIPromise<SpaceRoleListResponse> {
41
+ const { ...query } = params;
42
+ return this._client.get(`/space-roles`, {
43
+ query,
44
+ ...options,
45
+ headers: { ...options?.headers },
46
+ });
47
+ }
48
+
49
+ delete(id: number, options?: Core.RequestOptions): Core.APIPromise<void> {
50
+ return this._client.delete(`/space-roles/${id}`, {
51
+ ...options,
52
+ headers: { Accept: '*/*', ...options?.headers },
53
+ });
54
+ }
55
+ }
56
+
57
+ export interface SpaceRole {
58
+ name: string;
59
+
60
+ policies: Array<number>;
61
+
62
+ id?: number;
63
+
64
+ readonly created_at?: string;
65
+
66
+ space?: number;
67
+
68
+ updated_at?: string;
69
+ }
70
+
71
+ export type SpaceRoleListResponse = ListResponse<SpaceRole>;
72
+
73
+ export interface SpaceRoleCreateParams {
74
+ /**
75
+ * Body param:
76
+ */
77
+ name: string;
78
+
79
+ /**
80
+ * Body param:
81
+ */
82
+ policies: Array<number>;
83
+ }
84
+
85
+ export interface SpaceRoleUpdateParams {
86
+ /**
87
+ * Body param:
88
+ */
89
+ name: string;
90
+
91
+ /**
92
+ * Body param:
93
+ */
94
+ policies: Array<number>;
95
+ }
@@ -0,0 +1,140 @@
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 Spaces extends APIResource {
7
+ create(body: SpaceCreateParams, options?: Core.RequestOptions): Core.APIPromise<Space> {
8
+ return this._client.post(`/spaces`, { body, ...options });
9
+ }
10
+
11
+ update(params: SpaceUpdateParams, options?: Core.RequestOptions): Core.APIPromise<Space> {
12
+ const { ...body } = params;
13
+ return this._client.put(`/spaces`, {
14
+ body,
15
+ ...options,
16
+ headers: { ...options?.headers },
17
+ });
18
+ }
19
+
20
+ partialUpdate(params: SpaceUpdateParams, options?: Core.RequestOptions): Core.APIPromise<Space> {
21
+ const { ...body } = params;
22
+ return this._client.patch(`/spaces`, {
23
+ body,
24
+ ...options,
25
+ headers: { ...options?.headers },
26
+ });
27
+ }
28
+
29
+ list(params?: ListParamsResponse, options?: Core.RequestOptions): Core.APIPromise<SpaceListResponse>;
30
+ list(options?: Core.RequestOptions): Core.APIPromise<SpaceListResponse>;
31
+ list(params: ListParamsResponse | Core.RequestOptions = {}, options?: Core.RequestOptions): Core.APIPromise<SpaceListResponse> {
32
+ if (isRequestOptions(params)) {
33
+ return this.list({}, params);
34
+ }
35
+ const { ...query } = params;
36
+ return this._client.get(`/spaces`, {
37
+ query,
38
+ ...options,
39
+ headers: { ...options?.headers },
40
+ });
41
+ }
42
+
43
+ delete(options?: Core.RequestOptions): Core.APIPromise<void> {
44
+ return this._client.delete(`/spaces`, {
45
+ ...options,
46
+ headers: { Accept: '*/*', ...options?.headers },
47
+ });
48
+ }
49
+
50
+ invitation(body: OAuthInvitation, options?: Core.RequestOptions): Core.APIPromise<OAuthInvitation> {
51
+ return this._client.post(`/spaces/invitation`, { body, ...options });
52
+ }
53
+
54
+ joinSpace(token: string, options?: Core.RequestOptions): Core.APIPromise<JoinSpaceResponse> {
55
+ return this._client.get(`/spaces/join-space/${token}`, options);
56
+ }
57
+ }
58
+
59
+ export interface Space {
60
+ logo: string;
61
+
62
+ name: string;
63
+
64
+ slug_name: string;
65
+
66
+ id?: number;
67
+
68
+ created_by?: number | null;
69
+
70
+ is_active?: boolean;
71
+
72
+ total_devices: number;
73
+
74
+ readonly created_at?: string;
75
+
76
+ readonly updated_at?: string;
77
+ }
78
+
79
+ export type SpaceListResponse = ListResponse<Space>;
80
+
81
+ export interface SpaceCreateParams {
82
+ logo: string;
83
+
84
+ name: string;
85
+
86
+ slug_name: string;
87
+ }
88
+
89
+ export interface SpaceUpdateParams {
90
+ /**
91
+ * Body param:
92
+ */
93
+ logo: string;
94
+
95
+ /**
96
+ * Body param:
97
+ */
98
+ name: string;
99
+
100
+ /**
101
+ * Body param:
102
+ */
103
+ slug_name: string;
104
+ }
105
+
106
+ export interface SpaceUpdateParams {
107
+ /**
108
+ * Body param:
109
+ */
110
+ logo: string;
111
+
112
+ /**
113
+ * Body param:
114
+ */
115
+ name: string;
116
+
117
+ /**
118
+ * Body param:
119
+ */
120
+ slug_name: string;
121
+
122
+ /**
123
+ * Body param:
124
+ */
125
+ is_active?: boolean;
126
+ }
127
+
128
+ export interface OAuthInvitation {
129
+ receiver_list: Receiver[];
130
+ }
131
+
132
+ export interface Receiver {
133
+ email: string;
134
+ space_role_id: string;
135
+ }
136
+
137
+ export interface JoinSpaceResponse {
138
+ error?: string;
139
+ result?: string;
140
+ }
@@ -0,0 +1,36 @@
1
+ import { APIResource } from '../../resource';
2
+ import * as Core from '../../core';
3
+
4
+ export class Users extends APIResource {
5
+ getMe(options?: Core.RequestOptions): Core.APIPromise<Profile> {
6
+ return this._client.get(`/users/me`, options);
7
+ }
8
+
9
+ updateMe(body: Profile, options?: Core.RequestOptions): Core.APIPromise<Profile> {
10
+ return this._client.put(`/users/me`, { body, ...options });
11
+ }
12
+
13
+ deleteMe(options?: Core.RequestOptions): Core.APIPromise<void> {
14
+ return this._client.delete(`/users/me`, options);
15
+ }
16
+ }
17
+
18
+ export interface Profile {
19
+ id?: string;
20
+
21
+ first_name?: string;
22
+
23
+ last_name?: string;
24
+
25
+ email?: string;
26
+
27
+ location?: string;
28
+
29
+ avatar?: string;
30
+
31
+ company_name?: string;
32
+
33
+ title?: string;
34
+
35
+ is_owner?: boolean;
36
+ }
@@ -0,0 +1 @@
1
+ export * from './oauth2';
@@ -0,0 +1,83 @@
1
+ import { APIResource } from '../../resource';
2
+ import * as Core from '../../core';
3
+ import { rstripBase64, toBase64, toSHA256, uuid4 } from '../../libs/utils';
4
+
5
+ export class OAuth2 extends APIResource {
6
+ async authorize(body: OAuth2AuthorizeParams, options?: Core.RequestOptions): Promise<OAuth2Authorize> {
7
+ const verifier = rstripBase64(toBase64(uuid4()));
8
+ const codeChallenge = rstripBase64(toBase64(await toSHA256(verifier)));
9
+
10
+ const oAuth2AuthorizeBody: OAuth2Authorize = {
11
+ ...body,
12
+ response_type: 'code',
13
+ code_challenge: codeChallenge,
14
+ code_challenge_method: 'S256',
15
+ };
16
+
17
+ return (
18
+ this._client.post(`/auth/login`, { body: oAuth2AuthorizeBody, ...options }) as Core.APIPromise<{
19
+ data: OAuth2Authorize;
20
+ }>
21
+ )._thenUnwrap((obj) => ({ ...obj.data, verifier }));
22
+ }
23
+ }
24
+
25
+ export type OAuth2AuthorizeParams = Pick<OAuth2Authorize, 'client_id' | 'redirect_uri' | 'scopes'>;
26
+
27
+ export interface OAuth2Authorize {
28
+ /**
29
+ * Response type
30
+ */
31
+ response_type: 'code';
32
+
33
+ /**
34
+ * Code challenge, require min length > 1
35
+ */
36
+ code_challenge: string;
37
+
38
+ /**
39
+ * Code challenge method
40
+ */
41
+ code_challenge_method: 'plain' | 'S256';
42
+
43
+ /**
44
+ * Client id
45
+ */
46
+ client_id: string;
47
+
48
+ /**
49
+ * Redirect uri
50
+ */
51
+ redirect_uri: string;
52
+
53
+ scopes: Array<'organization'>;
54
+ }
55
+
56
+ export interface OAuth2Token {
57
+ /**
58
+ * Client id
59
+ */
60
+ client_id: string;
61
+
62
+ /**
63
+ * Client secret
64
+ */
65
+ client_secret: string;
66
+
67
+ /**
68
+ * Code
69
+ */
70
+ code: string;
71
+
72
+ /**
73
+ * Code verifier
74
+ */
75
+ code_verifier: string;
76
+
77
+ readonly scopes?: Array<'organization'>;
78
+
79
+ /**
80
+ * Id token
81
+ */
82
+ readonly id_token?: string;
83
+ }
@@ -0,0 +1,171 @@
1
+ import { APIResource } from '../../resource';
2
+ import * as Core from '../../core';
3
+ import { ListParamsResponse, ListResponse } from '../../types/api';
4
+
5
+ export class Dashboards extends APIResource {
6
+ create(params: DashboardCreateParams, options?: Core.RequestOptions): Core.APIPromise<Dashboard> {
7
+ const { ...body } = params;
8
+ return this._client.post(`/dashboards`, {
9
+ body,
10
+ ...options,
11
+ headers: { ...options?.headers },
12
+ });
13
+ }
14
+
15
+ retrieve(id: number, options?: Core.RequestOptions): Core.APIPromise<Dashboard> {
16
+ return this._client.get(`/dashboards/${id}`, {
17
+ ...options,
18
+ headers: { ...options?.headers },
19
+ });
20
+ }
21
+
22
+ update(id: number, params: DashboardUpdateParams, options?: Core.RequestOptions): Core.APIPromise<Dashboard> {
23
+ const { ...body } = params;
24
+ return this._client.put(`/dashboards/${id}`, {
25
+ body,
26
+ ...options,
27
+ headers: { ...options?.headers },
28
+ });
29
+ }
30
+
31
+ partialUpdate(id: number, params: DashboardUpdateParams, options?: Core.RequestOptions): Core.APIPromise<Dashboard> {
32
+ const { ...body } = params;
33
+ return this._client.patch(`/dashboards/${id}`, {
34
+ body,
35
+ ...options,
36
+ headers: { ...options?.headers },
37
+ });
38
+ }
39
+
40
+ list(params: ListParamsResponse, options?: Core.RequestOptions): Core.APIPromise<DashboardListResponse> {
41
+ const { ...query } = params;
42
+ return this._client.get(`/dashboards`, {
43
+ query,
44
+ ...options,
45
+ headers: { ...options?.headers },
46
+ });
47
+ }
48
+
49
+ delete(id: number, options?: Core.RequestOptions): Core.APIPromise<void> {
50
+ return this._client.delete(`/dashboards/${id}`, {
51
+ ...options,
52
+ headers: { Accept: '*/*', ...options?.headers },
53
+ });
54
+ }
55
+
56
+ createWidget(dashboardId: string, params: WidgetCreateParams, options?: Core.RequestOptions): Core.APIPromise<Widget> {
57
+ const { ...body } = params;
58
+ return this._client.post(`/dashboards/${dashboardId}/widgets`, {
59
+ body,
60
+ ...options,
61
+ headers: { ...options?.headers },
62
+ });
63
+ }
64
+
65
+ retrieveWidget(dashboardId: string, id: number, options?: Core.RequestOptions): Core.APIPromise<Widget> {
66
+ return this._client.get(`/dashboards/${dashboardId}/widgets/${id}`, {
67
+ ...options,
68
+ headers: { ...options?.headers },
69
+ });
70
+ }
71
+
72
+ updateWidget(dashboardId: string, id: number, params: WidgetUpdateParams, options?: Core.RequestOptions): Core.APIPromise<Widget> {
73
+ const { ...body } = params;
74
+ return this._client.put(`/dashboards/${dashboardId}/widgets/${id}`, {
75
+ body,
76
+ ...options,
77
+ headers: { ...options?.headers },
78
+ });
79
+ }
80
+
81
+ partialUpdateWidget(dashboardId: string, id: number, params: WidgetUpdateParams, options?: Core.RequestOptions): Core.APIPromise<Widget> {
82
+ const { ...body } = params;
83
+ return this._client.patch(`/dashboards/${dashboardId}/widgets/${id}`, {
84
+ body,
85
+ ...options,
86
+ headers: { ...options?.headers },
87
+ });
88
+ }
89
+
90
+ listWidgets(dashboardId: string, params: WidgetListParams, options?: Core.RequestOptions): Core.APIPromise<WidgetListResponse> {
91
+ const { ...query } = params;
92
+ return this._client.get(`/dashboards/${dashboardId}/widgets`, {
93
+ query,
94
+ ...options,
95
+ headers: { ...options?.headers },
96
+ });
97
+ }
98
+
99
+ deleteWidget(dashboardId: string, id: number, options?: Core.RequestOptions): Core.APIPromise<void> {
100
+ return this._client.delete(`/dashboards/${dashboardId}/widgets/${id}`, {
101
+ ...options,
102
+ headers: { Accept: '*/*', ...options?.headers },
103
+ });
104
+ }
105
+ }
106
+
107
+ export interface Dashboard {
108
+ name: string;
109
+
110
+ id?: number;
111
+
112
+ space?: number;
113
+
114
+ readonly created_at?: string;
115
+
116
+ readonly updated_at?: string;
117
+ }
118
+
119
+ export type DashboardListResponse = ListResponse<Dashboard>;
120
+
121
+ export interface DashboardCreateParams {
122
+ /**
123
+ * Body param:
124
+ */
125
+ name: string;
126
+ }
127
+
128
+ export interface DashboardUpdateParams {
129
+ /**
130
+ * Body param:
131
+ */
132
+ name: string;
133
+ }
134
+
135
+ /** ------------------------------------
136
+ * Widget type
137
+ ---------------------------------------*/
138
+ export interface Widget {
139
+ readonly id?: number;
140
+
141
+ configuration: any;
142
+
143
+ readonly dashboard?: number;
144
+
145
+ readonly created_at?: string;
146
+
147
+ readonly updated_at?: string;
148
+ }
149
+
150
+ export type WidgetListResponse = Array<Widget>;
151
+
152
+ export interface WidgetCreateParams {
153
+ /**
154
+ * Body param:
155
+ */
156
+ configuration: any;
157
+ }
158
+
159
+ export interface WidgetUpdateParams {
160
+ /**
161
+ * Body param:
162
+ */
163
+ configuration: any;
164
+ }
165
+
166
+ export interface WidgetListParams {
167
+ /**
168
+ * Query param: Which field to use when ordering the results.
169
+ */
170
+ ordering?: string;
171
+ }
@@ -0,0 +1,142 @@
1
+ import { APIResource } from '../../resource';
2
+ import { ListParamsResponse, ListResponse } from '../../types/api';
3
+ import * as Core from '../../core';
4
+
5
+ export class DeviceStates extends APIResource {
6
+ retrieveDaily(params: DailyRetrieveParams, options?: Core.RequestOptions): Core.APIPromise<DailyRetrieveResponse> {
7
+ const { ...query } = params;
8
+ return this._client.get(`/device-states/daily`, {
9
+ query,
10
+ ...options,
11
+ headers: { ...options?.headers },
12
+ });
13
+ }
14
+
15
+ retrieveHourly(params: HourlyRetrieveParams, options?: Core.RequestOptions): Core.APIPromise<HourlyRetrieveResponse> {
16
+ const { ...query } = params;
17
+ return this._client.get(`/device-states/hourly`, {
18
+ query,
19
+ ...options,
20
+ headers: { ...options?.headers },
21
+ });
22
+ }
23
+
24
+ retrieveMinutely(params: MinutelyRetrieveParams, options?: Core.RequestOptions): Core.APIPromise<MinutelyRetrieveResponse> {
25
+ const { ...query } = params;
26
+ return this._client.get(`/device-states/minutely`, {
27
+ query,
28
+ ...options,
29
+ headers: { ...options?.headers },
30
+ });
31
+ }
32
+
33
+ retrieveMonthly(params: MonthlyRetrieveParams, options?: Core.RequestOptions): Core.APIPromise<MonthlyRetrieveResponse> {
34
+ const { ...query } = params;
35
+ return this._client.get(`/device-states/monthly`, {
36
+ query,
37
+ ...options,
38
+ headers: { ...options?.headers },
39
+ });
40
+ }
41
+ }
42
+
43
+ export type DeviceStateListResponse<T> = ListResponse<T>;
44
+
45
+ export interface DeviceStateListParams extends Omit<ListParamsResponse, 'search'> {
46
+ /**
47
+ * Query param: device_slug_name
48
+ */
49
+ device_slug_name?: string;
50
+
51
+ /**
52
+ * Query param: state_name
53
+ */
54
+ state_name?: string;
55
+ }
56
+
57
+ export type DailyRetrieveResponse = DeviceStateListResponse<DailyRetrieveResult>;
58
+
59
+ export interface DailyRetrieveResult {
60
+ device_slug_name: string;
61
+
62
+ from_timestamp: string;
63
+
64
+ space: number;
65
+
66
+ state_name: string;
67
+
68
+ value: string;
69
+
70
+ id?: number;
71
+
72
+ readonly created_at?: string;
73
+
74
+ readonly updated_at?: string;
75
+ }
76
+
77
+ export type DailyRetrieveParams = DeviceStateListParams;
78
+
79
+ export type MinutelyRetrieveResponse = ListResponse<MinutelyRetrieveResult>;
80
+
81
+ export interface MinutelyRetrieveResult {
82
+ device_slug_name: string;
83
+
84
+ from_timestamp: string;
85
+
86
+ space: number;
87
+
88
+ state_name: string;
89
+
90
+ value: string;
91
+
92
+ id?: number;
93
+
94
+ readonly created_at?: string;
95
+
96
+ readonly updated_at?: string;
97
+ }
98
+
99
+ export type MinutelyRetrieveParams = DeviceStateListParams;
100
+
101
+ export type MonthlyRetrieveResponse = ListResponse<MonthlyRetrieveResult>;
102
+
103
+ export interface MonthlyRetrieveResult {
104
+ device_slug_name: string;
105
+
106
+ from_timestamp: string;
107
+
108
+ space: number;
109
+
110
+ state_name: string;
111
+
112
+ value: string;
113
+
114
+ id?: number;
115
+
116
+ readonly created_at?: string;
117
+
118
+ readonly updated_at?: string;
119
+ }
120
+
121
+ export type MonthlyRetrieveParams = DeviceStateListParams;
122
+
123
+ export type HourlyRetrieveResponse = ListResponse<HourlyRetrieveResult>;
124
+ export interface HourlyRetrieveResult {
125
+ device_slug_name: string;
126
+
127
+ from_timestamp: string;
128
+
129
+ space: number;
130
+
131
+ state_name: string;
132
+
133
+ value: string;
134
+
135
+ id?: number;
136
+
137
+ readonly created_at?: string;
138
+
139
+ readonly updated_at?: string;
140
+ }
141
+
142
+ export type HourlyRetrieveParams = DeviceStateListParams;
@@ -0,0 +1,2 @@
1
+ export * from './dashboards';
2
+ export * from './device-states';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * https://hacks.mozilla.org/2015/08/es6-in-depth-modules/
3
+ */
4
+ export * from './auth/index';
5
+ export * from './dashboard/index';
6
+ export * from './console/index';