@flowcore/sdk 1.4.2

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 (298) hide show
  1. package/README.md +41 -0
  2. package/esm/commands/api-key/api-key.create.d.ts +34 -0
  3. package/esm/commands/api-key/api-key.create.d.ts.map +1 -0
  4. package/esm/commands/api-key/api-key.create.js +74 -0
  5. package/esm/commands/api-key/api-key.delete.d.ts +28 -0
  6. package/esm/commands/api-key/api-key.delete.d.ts.map +1 -0
  7. package/esm/commands/api-key/api-key.delete.js +60 -0
  8. package/esm/commands/api-key/api-key.list.d.ts +27 -0
  9. package/esm/commands/api-key/api-key.list.d.ts.map +1 -0
  10. package/esm/commands/api-key/api-key.list.js +58 -0
  11. package/esm/commands/data-core/data-core.create.d.ts +39 -0
  12. package/esm/commands/data-core/data-core.create.d.ts.map +1 -0
  13. package/esm/commands/data-core/data-core.create.js +32 -0
  14. package/esm/commands/data-core/data-core.delete-request.d.ts +37 -0
  15. package/esm/commands/data-core/data-core.delete-request.d.ts.map +1 -0
  16. package/esm/commands/data-core/data-core.delete-request.js +94 -0
  17. package/esm/commands/data-core/data-core.exists.d.ts +37 -0
  18. package/esm/commands/data-core/data-core.exists.d.ts.map +1 -0
  19. package/esm/commands/data-core/data-core.exists.js +33 -0
  20. package/esm/commands/data-core/data-core.fetch.d.ts +51 -0
  21. package/esm/commands/data-core/data-core.fetch.d.ts.map +1 -0
  22. package/esm/commands/data-core/data-core.fetch.js +48 -0
  23. package/esm/commands/data-core/data-core.list.d.ts +33 -0
  24. package/esm/commands/data-core/data-core.list.d.ts.map +1 -0
  25. package/esm/commands/data-core/data-core.list.js +40 -0
  26. package/esm/commands/data-core/data-core.update.d.ts +41 -0
  27. package/esm/commands/data-core/data-core.update.d.ts.map +1 -0
  28. package/esm/commands/data-core/data-core.update.js +43 -0
  29. package/esm/commands/event-type/event-type.create.d.ts +35 -0
  30. package/esm/commands/event-type/event-type.create.d.ts.map +1 -0
  31. package/esm/commands/event-type/event-type.create.js +32 -0
  32. package/esm/commands/event-type/event-type.delete-request.d.ts +37 -0
  33. package/esm/commands/event-type/event-type.delete-request.d.ts.map +1 -0
  34. package/esm/commands/event-type/event-type.delete-request.js +98 -0
  35. package/esm/commands/event-type/event-type.exists.d.ts +37 -0
  36. package/esm/commands/event-type/event-type.exists.d.ts.map +1 -0
  37. package/esm/commands/event-type/event-type.exists.js +33 -0
  38. package/esm/commands/event-type/event-type.fetch.d.ts +45 -0
  39. package/esm/commands/event-type/event-type.fetch.d.ts.map +1 -0
  40. package/esm/commands/event-type/event-type.fetch.js +48 -0
  41. package/esm/commands/event-type/event-type.list.d.ts +31 -0
  42. package/esm/commands/event-type/event-type.list.d.ts.map +1 -0
  43. package/esm/commands/event-type/event-type.list.js +36 -0
  44. package/esm/commands/event-type/event-type.update.d.ts +37 -0
  45. package/esm/commands/event-type/event-type.update.d.ts.map +1 -0
  46. package/esm/commands/event-type/event-type.update.js +39 -0
  47. package/esm/commands/events/events.fetch-time-buckets-by-names.d.ts +53 -0
  48. package/esm/commands/events/events.fetch-time-buckets-by-names.d.ts.map +1 -0
  49. package/esm/commands/events/events.fetch-time-buckets-by-names.js +40 -0
  50. package/esm/commands/events/events.fetch.d.ts +58 -0
  51. package/esm/commands/events/events.fetch.d.ts.map +1 -0
  52. package/esm/commands/events/events.fetch.js +54 -0
  53. package/esm/commands/flow-type/flow-type.create.d.ts +35 -0
  54. package/esm/commands/flow-type/flow-type.create.d.ts.map +1 -0
  55. package/esm/commands/flow-type/flow-type.create.js +32 -0
  56. package/esm/commands/flow-type/flow-type.delete-request.d.ts +47 -0
  57. package/esm/commands/flow-type/flow-type.delete-request.d.ts.map +1 -0
  58. package/esm/commands/flow-type/flow-type.delete-request.js +118 -0
  59. package/esm/commands/flow-type/flow-type.exists.d.ts +39 -0
  60. package/esm/commands/flow-type/flow-type.exists.d.ts.map +1 -0
  61. package/esm/commands/flow-type/flow-type.exists.js +33 -0
  62. package/esm/commands/flow-type/flow-type.fetch.d.ts +51 -0
  63. package/esm/commands/flow-type/flow-type.fetch.d.ts.map +1 -0
  64. package/esm/commands/flow-type/flow-type.fetch.js +48 -0
  65. package/esm/commands/flow-type/flow-type.list.d.ts +31 -0
  66. package/esm/commands/flow-type/flow-type.list.d.ts.map +1 -0
  67. package/esm/commands/flow-type/flow-type.list.js +36 -0
  68. package/esm/commands/flow-type/flow-type.update.d.ts +37 -0
  69. package/esm/commands/flow-type/flow-type.update.d.ts.map +1 -0
  70. package/esm/commands/flow-type/flow-type.update.js +39 -0
  71. package/esm/commands/index.d.ts +32 -0
  72. package/esm/commands/index.d.ts.map +1 -0
  73. package/esm/commands/index.js +39 -0
  74. package/esm/commands/secret/secret.create.d.ts +30 -0
  75. package/esm/commands/secret/secret.create.d.ts.map +1 -0
  76. package/esm/commands/secret/secret.create.js +60 -0
  77. package/esm/commands/secret/secret.delete.d.ts +28 -0
  78. package/esm/commands/secret/secret.delete.d.ts.map +1 -0
  79. package/esm/commands/secret/secret.delete.js +61 -0
  80. package/esm/commands/secret/secret.list.d.ts +26 -0
  81. package/esm/commands/secret/secret.list.d.ts.map +1 -0
  82. package/esm/commands/secret/secret.list.js +63 -0
  83. package/esm/commands/tenant/tenant.fetch.d.ts +43 -0
  84. package/esm/commands/tenant/tenant.fetch.d.ts.map +1 -0
  85. package/esm/commands/tenant/tenant.fetch.js +77 -0
  86. package/esm/commands/tenant/tenant.list.d.ts +20 -0
  87. package/esm/commands/tenant/tenant.list.d.ts.map +1 -0
  88. package/esm/commands/tenant/tenant.list.js +65 -0
  89. package/esm/commands/variable/variable.create.d.ts +31 -0
  90. package/esm/commands/variable/variable.create.d.ts.map +1 -0
  91. package/esm/commands/variable/variable.create.js +66 -0
  92. package/esm/commands/variable/variable.delete.d.ts +28 -0
  93. package/esm/commands/variable/variable.delete.d.ts.map +1 -0
  94. package/esm/commands/variable/variable.delete.js +63 -0
  95. package/esm/commands/variable/variable.list.d.ts +27 -0
  96. package/esm/commands/variable/variable.list.d.ts.map +1 -0
  97. package/esm/commands/variable/variable.list.js +69 -0
  98. package/esm/common/command.d.ts +63 -0
  99. package/esm/common/command.d.ts.map +1 -0
  100. package/esm/common/command.js +91 -0
  101. package/esm/common/flowcore-client.d.ts +39 -0
  102. package/esm/common/flowcore-client.d.ts.map +1 -0
  103. package/esm/common/flowcore-client.js +72 -0
  104. package/esm/contracts/api-key.d.ts +14 -0
  105. package/esm/contracts/api-key.d.ts.map +1 -0
  106. package/esm/contracts/api-key.js +9 -0
  107. package/esm/contracts/data-core.d.ts +38 -0
  108. package/esm/contracts/data-core.d.ts.map +1 -0
  109. package/esm/contracts/data-core.js +38 -0
  110. package/esm/contracts/event-type.d.ts +33 -0
  111. package/esm/contracts/event-type.d.ts.map +1 -0
  112. package/esm/contracts/event-type.js +33 -0
  113. package/esm/contracts/event.d.ts +20 -0
  114. package/esm/contracts/event.d.ts.map +1 -0
  115. package/esm/contracts/event.js +15 -0
  116. package/esm/contracts/flow-type.d.ts +32 -0
  117. package/esm/contracts/flow-type.d.ts.map +1 -0
  118. package/esm/contracts/flow-type.js +31 -0
  119. package/esm/contracts/index.d.ts +4 -0
  120. package/esm/contracts/index.d.ts.map +1 -0
  121. package/esm/contracts/index.js +1 -0
  122. package/esm/contracts/tenant.d.ts +50 -0
  123. package/esm/contracts/tenant.d.ts.map +1 -0
  124. package/esm/contracts/tenant.js +33 -0
  125. package/esm/contracts/variable.d.ts +13 -0
  126. package/esm/contracts/variable.d.ts.map +1 -0
  127. package/esm/contracts/variable.js +8 -0
  128. package/esm/exceptions/client-error.d.ts +9 -0
  129. package/esm/exceptions/client-error.d.ts.map +1 -0
  130. package/esm/exceptions/client-error.js +20 -0
  131. package/esm/exceptions/command-error.d.ts +7 -0
  132. package/esm/exceptions/command-error.d.ts.map +1 -0
  133. package/esm/exceptions/command-error.js +8 -0
  134. package/esm/exceptions/index.d.ts +4 -0
  135. package/esm/exceptions/index.d.ts.map +1 -0
  136. package/esm/exceptions/index.js +3 -0
  137. package/esm/exceptions/invalid-response.d.ts +8 -0
  138. package/esm/exceptions/invalid-response.d.ts.map +1 -0
  139. package/esm/exceptions/invalid-response.js +15 -0
  140. package/esm/exceptions/not-found.d.ts +7 -0
  141. package/esm/exceptions/not-found.d.ts.map +1 -0
  142. package/esm/exceptions/not-found.js +8 -0
  143. package/esm/mod.d.ts +6 -0
  144. package/esm/mod.d.ts.map +1 -0
  145. package/esm/mod.js +5 -0
  146. package/esm/package.json +3 -0
  147. package/esm/utils/parse-response-helper.d.ts +6 -0
  148. package/esm/utils/parse-response-helper.d.ts.map +1 -0
  149. package/esm/utils/parse-response-helper.js +16 -0
  150. package/package.json +28 -0
  151. package/script/commands/api-key/api-key.create.d.ts +34 -0
  152. package/script/commands/api-key/api-key.create.d.ts.map +1 -0
  153. package/script/commands/api-key/api-key.create.js +78 -0
  154. package/script/commands/api-key/api-key.delete.d.ts +28 -0
  155. package/script/commands/api-key/api-key.delete.d.ts.map +1 -0
  156. package/script/commands/api-key/api-key.delete.js +64 -0
  157. package/script/commands/api-key/api-key.list.d.ts +27 -0
  158. package/script/commands/api-key/api-key.list.d.ts.map +1 -0
  159. package/script/commands/api-key/api-key.list.js +62 -0
  160. package/script/commands/data-core/data-core.create.d.ts +39 -0
  161. package/script/commands/data-core/data-core.create.d.ts.map +1 -0
  162. package/script/commands/data-core/data-core.create.js +36 -0
  163. package/script/commands/data-core/data-core.delete-request.d.ts +37 -0
  164. package/script/commands/data-core/data-core.delete-request.d.ts.map +1 -0
  165. package/script/commands/data-core/data-core.delete-request.js +98 -0
  166. package/script/commands/data-core/data-core.exists.d.ts +37 -0
  167. package/script/commands/data-core/data-core.exists.d.ts.map +1 -0
  168. package/script/commands/data-core/data-core.exists.js +37 -0
  169. package/script/commands/data-core/data-core.fetch.d.ts +51 -0
  170. package/script/commands/data-core/data-core.fetch.d.ts.map +1 -0
  171. package/script/commands/data-core/data-core.fetch.js +52 -0
  172. package/script/commands/data-core/data-core.list.d.ts +33 -0
  173. package/script/commands/data-core/data-core.list.d.ts.map +1 -0
  174. package/script/commands/data-core/data-core.list.js +44 -0
  175. package/script/commands/data-core/data-core.update.d.ts +41 -0
  176. package/script/commands/data-core/data-core.update.d.ts.map +1 -0
  177. package/script/commands/data-core/data-core.update.js +47 -0
  178. package/script/commands/event-type/event-type.create.d.ts +35 -0
  179. package/script/commands/event-type/event-type.create.d.ts.map +1 -0
  180. package/script/commands/event-type/event-type.create.js +36 -0
  181. package/script/commands/event-type/event-type.delete-request.d.ts +37 -0
  182. package/script/commands/event-type/event-type.delete-request.d.ts.map +1 -0
  183. package/script/commands/event-type/event-type.delete-request.js +102 -0
  184. package/script/commands/event-type/event-type.exists.d.ts +37 -0
  185. package/script/commands/event-type/event-type.exists.d.ts.map +1 -0
  186. package/script/commands/event-type/event-type.exists.js +37 -0
  187. package/script/commands/event-type/event-type.fetch.d.ts +45 -0
  188. package/script/commands/event-type/event-type.fetch.d.ts.map +1 -0
  189. package/script/commands/event-type/event-type.fetch.js +52 -0
  190. package/script/commands/event-type/event-type.list.d.ts +31 -0
  191. package/script/commands/event-type/event-type.list.d.ts.map +1 -0
  192. package/script/commands/event-type/event-type.list.js +40 -0
  193. package/script/commands/event-type/event-type.update.d.ts +37 -0
  194. package/script/commands/event-type/event-type.update.d.ts.map +1 -0
  195. package/script/commands/event-type/event-type.update.js +43 -0
  196. package/script/commands/events/events.fetch-time-buckets-by-names.d.ts +53 -0
  197. package/script/commands/events/events.fetch-time-buckets-by-names.d.ts.map +1 -0
  198. package/script/commands/events/events.fetch-time-buckets-by-names.js +44 -0
  199. package/script/commands/events/events.fetch.d.ts +58 -0
  200. package/script/commands/events/events.fetch.d.ts.map +1 -0
  201. package/script/commands/events/events.fetch.js +58 -0
  202. package/script/commands/flow-type/flow-type.create.d.ts +35 -0
  203. package/script/commands/flow-type/flow-type.create.d.ts.map +1 -0
  204. package/script/commands/flow-type/flow-type.create.js +36 -0
  205. package/script/commands/flow-type/flow-type.delete-request.d.ts +47 -0
  206. package/script/commands/flow-type/flow-type.delete-request.d.ts.map +1 -0
  207. package/script/commands/flow-type/flow-type.delete-request.js +122 -0
  208. package/script/commands/flow-type/flow-type.exists.d.ts +39 -0
  209. package/script/commands/flow-type/flow-type.exists.d.ts.map +1 -0
  210. package/script/commands/flow-type/flow-type.exists.js +37 -0
  211. package/script/commands/flow-type/flow-type.fetch.d.ts +51 -0
  212. package/script/commands/flow-type/flow-type.fetch.d.ts.map +1 -0
  213. package/script/commands/flow-type/flow-type.fetch.js +52 -0
  214. package/script/commands/flow-type/flow-type.list.d.ts +31 -0
  215. package/script/commands/flow-type/flow-type.list.d.ts.map +1 -0
  216. package/script/commands/flow-type/flow-type.list.js +40 -0
  217. package/script/commands/flow-type/flow-type.update.d.ts +37 -0
  218. package/script/commands/flow-type/flow-type.update.d.ts.map +1 -0
  219. package/script/commands/flow-type/flow-type.update.js +43 -0
  220. package/script/commands/index.d.ts +32 -0
  221. package/script/commands/index.d.ts.map +1 -0
  222. package/script/commands/index.js +55 -0
  223. package/script/commands/secret/secret.create.d.ts +30 -0
  224. package/script/commands/secret/secret.create.d.ts.map +1 -0
  225. package/script/commands/secret/secret.create.js +64 -0
  226. package/script/commands/secret/secret.delete.d.ts +28 -0
  227. package/script/commands/secret/secret.delete.d.ts.map +1 -0
  228. package/script/commands/secret/secret.delete.js +65 -0
  229. package/script/commands/secret/secret.list.d.ts +26 -0
  230. package/script/commands/secret/secret.list.d.ts.map +1 -0
  231. package/script/commands/secret/secret.list.js +67 -0
  232. package/script/commands/tenant/tenant.fetch.d.ts +43 -0
  233. package/script/commands/tenant/tenant.fetch.d.ts.map +1 -0
  234. package/script/commands/tenant/tenant.fetch.js +81 -0
  235. package/script/commands/tenant/tenant.list.d.ts +20 -0
  236. package/script/commands/tenant/tenant.list.d.ts.map +1 -0
  237. package/script/commands/tenant/tenant.list.js +69 -0
  238. package/script/commands/variable/variable.create.d.ts +31 -0
  239. package/script/commands/variable/variable.create.d.ts.map +1 -0
  240. package/script/commands/variable/variable.create.js +70 -0
  241. package/script/commands/variable/variable.delete.d.ts +28 -0
  242. package/script/commands/variable/variable.delete.d.ts.map +1 -0
  243. package/script/commands/variable/variable.delete.js +67 -0
  244. package/script/commands/variable/variable.list.d.ts +27 -0
  245. package/script/commands/variable/variable.list.d.ts.map +1 -0
  246. package/script/commands/variable/variable.list.js +73 -0
  247. package/script/common/command.d.ts +63 -0
  248. package/script/common/command.d.ts.map +1 -0
  249. package/script/common/command.js +96 -0
  250. package/script/common/flowcore-client.d.ts +39 -0
  251. package/script/common/flowcore-client.d.ts.map +1 -0
  252. package/script/common/flowcore-client.js +76 -0
  253. package/script/contracts/api-key.d.ts +14 -0
  254. package/script/contracts/api-key.d.ts.map +1 -0
  255. package/script/contracts/api-key.js +12 -0
  256. package/script/contracts/data-core.d.ts +38 -0
  257. package/script/contracts/data-core.d.ts.map +1 -0
  258. package/script/contracts/data-core.js +42 -0
  259. package/script/contracts/event-type.d.ts +33 -0
  260. package/script/contracts/event-type.d.ts.map +1 -0
  261. package/script/contracts/event-type.js +37 -0
  262. package/script/contracts/event.d.ts +20 -0
  263. package/script/contracts/event.d.ts.map +1 -0
  264. package/script/contracts/event.js +18 -0
  265. package/script/contracts/flow-type.d.ts +32 -0
  266. package/script/contracts/flow-type.d.ts.map +1 -0
  267. package/script/contracts/flow-type.js +35 -0
  268. package/script/contracts/index.d.ts +4 -0
  269. package/script/contracts/index.d.ts.map +1 -0
  270. package/script/contracts/index.js +2 -0
  271. package/script/contracts/tenant.d.ts +50 -0
  272. package/script/contracts/tenant.d.ts.map +1 -0
  273. package/script/contracts/tenant.js +37 -0
  274. package/script/contracts/variable.d.ts +13 -0
  275. package/script/contracts/variable.d.ts.map +1 -0
  276. package/script/contracts/variable.js +11 -0
  277. package/script/exceptions/client-error.d.ts +9 -0
  278. package/script/exceptions/client-error.d.ts.map +1 -0
  279. package/script/exceptions/client-error.js +24 -0
  280. package/script/exceptions/command-error.d.ts +7 -0
  281. package/script/exceptions/command-error.d.ts.map +1 -0
  282. package/script/exceptions/command-error.js +12 -0
  283. package/script/exceptions/index.d.ts +4 -0
  284. package/script/exceptions/index.d.ts.map +1 -0
  285. package/script/exceptions/index.js +19 -0
  286. package/script/exceptions/invalid-response.d.ts +8 -0
  287. package/script/exceptions/invalid-response.d.ts.map +1 -0
  288. package/script/exceptions/invalid-response.js +19 -0
  289. package/script/exceptions/not-found.d.ts +7 -0
  290. package/script/exceptions/not-found.d.ts.map +1 -0
  291. package/script/exceptions/not-found.js +12 -0
  292. package/script/mod.d.ts +6 -0
  293. package/script/mod.d.ts.map +1 -0
  294. package/script/mod.js +21 -0
  295. package/script/package.json +3 -0
  296. package/script/utils/parse-response-helper.d.ts +6 -0
  297. package/script/utils/parse-response-helper.d.ts.map +1 -0
  298. package/script/utils/parse-response-helper.js +20 -0
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VariableListCommand = void 0;
4
+ const typebox_1 = require("@sinclair/typebox");
5
+ const command_js_1 = require("../../common/command.js");
6
+ const parse_response_helper_js_1 = require("../../utils/parse-response-helper.js");
7
+ const command_error_js_1 = require("../../exceptions/command-error.js");
8
+ const graphQlQueryById = `
9
+ query FLOWCORE_SDK_VARIABLE_LIST($tenantId: ID!) {
10
+ organization(search: {id: $tenantId}) {
11
+ variables {
12
+ key
13
+ value
14
+ }
15
+ }
16
+ }
17
+ `;
18
+ const responseSchema = typebox_1.Type.Object({
19
+ errors: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.Object({
20
+ message: typebox_1.Type.String(),
21
+ }))),
22
+ data: typebox_1.Type.Union([
23
+ typebox_1.Type.Object({
24
+ organization: typebox_1.Type.Object({
25
+ variables: typebox_1.Type.Array(typebox_1.Type.Object({
26
+ key: typebox_1.Type.String(),
27
+ value: typebox_1.Type.String(),
28
+ })),
29
+ }),
30
+ }),
31
+ typebox_1.Type.Null(),
32
+ ]),
33
+ });
34
+ /**
35
+ * List variables
36
+ */
37
+ class VariableListCommand extends command_js_1.GraphQlCommand {
38
+ constructor() {
39
+ super(...arguments);
40
+ /**
41
+ * The allowed modes for the command
42
+ */
43
+ Object.defineProperty(this, "allowedModes", {
44
+ enumerable: true,
45
+ configurable: true,
46
+ writable: true,
47
+ value: ["bearer"]
48
+ });
49
+ }
50
+ /**
51
+ * Parse the response
52
+ */
53
+ parseResponse(rawResponse) {
54
+ const response = (0, parse_response_helper_js_1.parseResponseHelper)(responseSchema, rawResponse);
55
+ if (response.errors) {
56
+ throw new command_error_js_1.CommandError(this.constructor.name, response.errors[0].message);
57
+ }
58
+ if (!response.data) {
59
+ throw new command_error_js_1.CommandError(this.constructor.name, "Failed to list variables");
60
+ }
61
+ return response.data.organization.variables;
62
+ }
63
+ /**
64
+ * Get the body for the request
65
+ */
66
+ getBody() {
67
+ return JSON.stringify({
68
+ query: graphQlQueryById,
69
+ variables: this.input,
70
+ });
71
+ }
72
+ }
73
+ exports.VariableListCommand = VariableListCommand;
@@ -0,0 +1,63 @@
1
+ import type { FlowcoreClient } from "./flowcore-client.js";
2
+ /**
3
+ * Abstract command for executing requests
4
+ */
5
+ export declare abstract class Command<Input, Output> {
6
+ /**
7
+ * The allowed modes for the command
8
+ */
9
+ protected readonly allowedModes: ("apiKey" | "bearer")[];
10
+ /**
11
+ * The input for the command
12
+ */
13
+ protected readonly input: Input;
14
+ constructor(input: Input);
15
+ /**
16
+ * Get the base URL for the request
17
+ */
18
+ protected abstract getBaseUrl(): string;
19
+ /**
20
+ * Get the method for the request
21
+ */
22
+ protected getMethod(): string;
23
+ /**
24
+ * Get the path for the request
25
+ */
26
+ protected getPath(): string;
27
+ /**
28
+ * Get the body for the request
29
+ */
30
+ protected getBody(): string | undefined;
31
+ /**
32
+ * Get the headers for the request
33
+ */
34
+ protected getHeaders(): Record<string, string>;
35
+ /**
36
+ * Parse the response
37
+ */
38
+ protected abstract parseResponse(response: unknown, flowcoreClient: FlowcoreClient): Output | Promise<Output>;
39
+ /**
40
+ * Get the request object
41
+ */
42
+ getRequest(_client: FlowcoreClient): Promise<{
43
+ allowedModes: ("apiKey" | "bearer")[];
44
+ body: string | undefined;
45
+ headers: Record<string, string>;
46
+ baseUrl: string;
47
+ path: string;
48
+ method: string;
49
+ parseResponse: (response: unknown, client: FlowcoreClient) => Output | Promise<Output>;
50
+ waitForResponse: (client: FlowcoreClient, response: Output) => Promise<Output>;
51
+ }>;
52
+ /**
53
+ * Wait for the response
54
+ */
55
+ protected waitForResponse(_client: FlowcoreClient, response: Output): Promise<Output>;
56
+ }
57
+ /**
58
+ * Abstract command for executing GraphQL requests
59
+ */
60
+ export declare abstract class GraphQlCommand<Input, Output> extends Command<Input, Output> {
61
+ protected getBaseUrl(): string;
62
+ }
63
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/common/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;GAEG;AACH,8BAAsB,OAAO,CAAC,KAAK,EAAE,MAAM;IACzC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAuB;IAE/E;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;gBAEnB,KAAK,EAAE,KAAK;IAOxB;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,IAAI,MAAM;IAEvC;;OAEG;IACH,SAAS,CAAC,SAAS,IAAI,MAAM;IAI7B;;OAEG;IACH,SAAS,CAAC,OAAO,IAAI,MAAM;IAI3B;;OAEG;IACH,SAAS,CAAC,OAAO,IAAI,MAAM,GAAG,SAAS;IAOvC;;OAEG;IACH,SAAS,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAQ9C;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAE7G;;OAEG;IAEU,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC;QACxD,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAA;QACrC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;QACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC/B,OAAO,EAAE,MAAM,CAAA;QACf,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAA;QACd,aAAa,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;QACtF,eAAe,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;KAC/E,CAAC;IAaF;;OAEG;cAEa,eAAe,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG5F;AAED;;GAEG;AACH,8BAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAE,SAAQ,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;cAC7D,UAAU,IAAI,MAAM;CAGxC"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GraphQlCommand = exports.Command = void 0;
4
+ /**
5
+ * Abstract command for executing requests
6
+ */
7
+ class Command {
8
+ constructor(input) {
9
+ /**
10
+ * The allowed modes for the command
11
+ */
12
+ Object.defineProperty(this, "allowedModes", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: ["apiKey", "bearer"]
17
+ });
18
+ /**
19
+ * The input for the command
20
+ */
21
+ Object.defineProperty(this, "input", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: void 0
26
+ });
27
+ /**
28
+ * The input for the command
29
+ */
30
+ this.input = input;
31
+ }
32
+ /**
33
+ * Get the method for the request
34
+ */
35
+ getMethod() {
36
+ return "POST";
37
+ }
38
+ /**
39
+ * Get the path for the request
40
+ */
41
+ getPath() {
42
+ return "/";
43
+ }
44
+ /**
45
+ * Get the body for the request
46
+ */
47
+ getBody() {
48
+ if (this.getMethod() === "GET") {
49
+ return undefined;
50
+ }
51
+ return this.input ? JSON.stringify(this.input) : undefined;
52
+ }
53
+ /**
54
+ * Get the headers for the request
55
+ */
56
+ getHeaders() {
57
+ return this.getBody()
58
+ ? {
59
+ "Content-Type": "application/json",
60
+ }
61
+ : {};
62
+ }
63
+ /**
64
+ * Get the request object
65
+ */
66
+ // deno-lint-ignore require-await
67
+ async getRequest(_client) {
68
+ return {
69
+ allowedModes: this.allowedModes,
70
+ body: this.getBody(),
71
+ headers: this.getHeaders(),
72
+ baseUrl: this.getBaseUrl(),
73
+ path: this.getPath(),
74
+ method: this.getMethod(),
75
+ parseResponse: this.parseResponse.bind(this),
76
+ waitForResponse: this.waitForResponse.bind(this),
77
+ };
78
+ }
79
+ /**
80
+ * Wait for the response
81
+ */
82
+ // deno-lint-ignore require-await
83
+ async waitForResponse(_client, response) {
84
+ return response;
85
+ }
86
+ }
87
+ exports.Command = Command;
88
+ /**
89
+ * Abstract command for executing GraphQL requests
90
+ */
91
+ class GraphQlCommand extends Command {
92
+ getBaseUrl() {
93
+ return "https://graph.api.flowcore.io/graphql";
94
+ }
95
+ }
96
+ exports.GraphQlCommand = GraphQlCommand;
@@ -0,0 +1,39 @@
1
+ import type { Command } from "./command.js";
2
+ /**
3
+ * The options for the bearer token
4
+ */
5
+ interface ClientOptionsBearer {
6
+ getBearerToken: () => Promise<string | null> | string | null;
7
+ apiKeyId?: never;
8
+ apiKey?: never;
9
+ }
10
+ /**
11
+ * The options for the api key
12
+ */
13
+ interface ClientOptionsApiKey {
14
+ apiKeyId: string;
15
+ apiKey: string;
16
+ getBearerToken?: never;
17
+ }
18
+ /**
19
+ * The options for the client
20
+ */
21
+ export type ClientOptions = ClientOptionsBearer | ClientOptionsApiKey;
22
+ /**
23
+ * A base client for executing commands
24
+ */
25
+ export declare class FlowcoreClient {
26
+ private readonly options;
27
+ private mode;
28
+ constructor(options: ClientOptions);
29
+ /**
30
+ * Get the auth header
31
+ */
32
+ private getAuthHeader;
33
+ /**
34
+ * Execute a command
35
+ */
36
+ execute<Input, Output>(command: Command<Input, Output>): Promise<Output>;
37
+ }
38
+ export {};
39
+ //# sourceMappingURL=flowcore-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowcore-client.d.ts","sourceRoot":"","sources":["../../src/common/flowcore-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C;;GAEG;AACH,UAAU,mBAAmB;IAC3B,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAA;IAC5D,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,MAAM,CAAC,EAAE,KAAK,CAAA;CACf;AAED;;GAEG;AACH,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,KAAK,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG,mBAAmB,CAAA;AAErE;;GAEG;AACH,qBAAa,cAAc;IAEb,OAAO,CAAC,QAAQ,CAAC,OAAO;IADpC,OAAO,CAAC,IAAI,CAAqB;gBACJ,OAAO,EAAE,aAAa;IAUnD;;OAEG;YACW,aAAa;IAc3B;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CA+B/E"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowcoreClient = void 0;
4
+ const client_error_js_1 = require("../exceptions/client-error.js");
5
+ const command_error_js_1 = require("../exceptions/command-error.js");
6
+ /**
7
+ * A base client for executing commands
8
+ */
9
+ class FlowcoreClient {
10
+ constructor(options) {
11
+ Object.defineProperty(this, "options", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: options
16
+ });
17
+ Object.defineProperty(this, "mode", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ if (this.options.getBearerToken) {
24
+ this.mode = "bearer";
25
+ }
26
+ else if (this.options.apiKeyId && this.options.apiKey) {
27
+ this.mode = "apiKey";
28
+ }
29
+ else {
30
+ throw new Error("Invalid client options");
31
+ }
32
+ }
33
+ /**
34
+ * Get the auth header
35
+ */
36
+ async getAuthHeader() {
37
+ if (this.options.getBearerToken) {
38
+ const bearerToken = await this.options.getBearerToken();
39
+ if (!bearerToken) {
40
+ return null;
41
+ }
42
+ return `Bearer ${bearerToken}`;
43
+ }
44
+ if (this.options.apiKeyId && this.options.apiKey) {
45
+ return `ApiKey ${this.options.apiKeyId}:${this.options.apiKey}`;
46
+ }
47
+ return null;
48
+ }
49
+ /**
50
+ * Execute a command
51
+ */
52
+ async execute(command) {
53
+ const request = await command.getRequest(this);
54
+ if (!request.allowedModes.includes(this.mode)) {
55
+ throw new command_error_js_1.CommandError(command.constructor.name, `Not allowed in "${this.mode}" mode`);
56
+ }
57
+ const authHeader = await this.getAuthHeader();
58
+ const response = await fetch(request.baseUrl + request.path, {
59
+ method: request.method,
60
+ headers: {
61
+ ...request.headers,
62
+ ...(authHeader ? { Authorization: authHeader } : {}),
63
+ },
64
+ body: request.body,
65
+ });
66
+ if (!response.ok) {
67
+ const body = await response.json().catch(() => undefined);
68
+ const commandName = command.constructor.name;
69
+ throw new client_error_js_1.ClientError(`${commandName} failed with ${response.status}: ${response.statusText}`, response.status, body);
70
+ }
71
+ const body = await response.json();
72
+ const parsedBody = await request.parseResponse(body, this);
73
+ return request.waitForResponse(this, parsedBody);
74
+ }
75
+ }
76
+ exports.FlowcoreClient = FlowcoreClient;
@@ -0,0 +1,14 @@
1
+ import { type Static, type TObject, type TString } from "@sinclair/typebox";
2
+ /**
3
+ * The schema for an api key
4
+ */
5
+ export declare const ApiKeySchema: TObject<{
6
+ id: TString;
7
+ name: TString;
8
+ createdAt: TString;
9
+ }>;
10
+ /**
11
+ * The type for an api key
12
+ */
13
+ export type ApiKey = Static<typeof ApiKeySchema>;
14
+ //# sourceMappingURL=api-key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/contracts/api-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAA;AAEjF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC;IACjC,EAAE,EAAE,OAAO,CAAA;IACX,IAAI,EAAE,OAAO,CAAA;IACb,SAAS,EAAE,OAAO,CAAA;CACnB,CAIC,CAAA;AACF;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiKeySchema = void 0;
4
+ const typebox_1 = require("@sinclair/typebox");
5
+ /**
6
+ * The schema for an api key
7
+ */
8
+ exports.ApiKeySchema = typebox_1.Type.Object({
9
+ id: typebox_1.Type.String(),
10
+ name: typebox_1.Type.String(),
11
+ createdAt: typebox_1.Type.String(),
12
+ });
@@ -0,0 +1,38 @@
1
+ import { type Static, type TArray, type TBoolean, type TLiteral, type TNull, type TObject, type TOptional, type TString, type TUnion } from "@sinclair/typebox";
2
+ /**
3
+ * The schema for a data core
4
+ */
5
+ export declare const DataCoreSchema: TObject<{
6
+ id: TString;
7
+ tenantId: TString;
8
+ name: TString;
9
+ description: TString;
10
+ accessControl: TUnion<[TLiteral<"public">, TLiteral<"private">]>;
11
+ deleteProtected: TBoolean;
12
+ }>;
13
+ /**
14
+ * The type for a data core
15
+ */
16
+ export type DataCore = Static<typeof DataCoreSchema>;
17
+ /**
18
+ * The schema for a data core v0
19
+ */
20
+ export declare const DataCoreV0Schema: TObject<{
21
+ id: TString;
22
+ name: TString;
23
+ description: TUnion<[TString, TNull]>;
24
+ isPublic: TBoolean;
25
+ configuration: TOptional<TArray<TObject<{
26
+ key: TLiteral<"DELETE_PROTECTION_ENABLED">;
27
+ value: TUnion<[TLiteral<"true">, TLiteral<"false">]>;
28
+ }>>>;
29
+ }>;
30
+ /**
31
+ * The type for a data core v0
32
+ */
33
+ export type DataCoreV0 = Static<typeof DataCoreV0Schema>;
34
+ /**
35
+ * Convert a data core v0 to a data core
36
+ */
37
+ export declare const dataCoreV0ToDataCore: (dataCoreV0: DataCoreV0, organizationId: string) => DataCore;
38
+ //# sourceMappingURL=data-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-core.d.ts","sourceRoot":"","sources":["../../src/contracts/data-core.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,MAAM,EAEZ,MAAM,mBAAmB,CAAA;AAE1B;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,CAAC;IACnC,EAAE,EAAE,OAAO,CAAA;IACX,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,aAAa,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAChE,eAAe,EAAE,QAAQ,CAAA;CAC1B,CAOC,CAAA;AACF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,OAAO,CAAC;IACrC,EAAE,EAAE,OAAO,CAAA;IACX,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IACrC,QAAQ,EAAE,QAAQ,CAAA;IAClB,aAAa,EAAE,SAAS,CACtB,MAAM,CACJ,OAAO,CAAC;QACN,GAAG,EAAE,QAAQ,CAAC,2BAA2B,CAAC,CAAA;QAC1C,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;KACrD,CAAC,CACH,CACF,CAAA;CACF,CAcC,CAAA;AACF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,oBAAoB,eACnB,UAAU,kBACN,MAAM,KACrB,QASF,CAAA"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dataCoreV0ToDataCore = exports.DataCoreV0Schema = exports.DataCoreSchema = void 0;
4
+ const typebox_1 = require("@sinclair/typebox");
5
+ /**
6
+ * The schema for a data core
7
+ */
8
+ exports.DataCoreSchema = typebox_1.Type.Object({
9
+ id: typebox_1.Type.String(),
10
+ tenantId: typebox_1.Type.String(),
11
+ name: typebox_1.Type.String(),
12
+ description: typebox_1.Type.String(),
13
+ accessControl: typebox_1.Type.Union([typebox_1.Type.Literal("public"), typebox_1.Type.Literal("private")]),
14
+ deleteProtected: typebox_1.Type.Boolean(),
15
+ });
16
+ /**
17
+ * The schema for a data core v0
18
+ */
19
+ exports.DataCoreV0Schema = typebox_1.Type.Object({
20
+ id: typebox_1.Type.String(),
21
+ name: typebox_1.Type.String(),
22
+ description: typebox_1.Type.Union([typebox_1.Type.String(), typebox_1.Type.Null()]),
23
+ isPublic: typebox_1.Type.Boolean(),
24
+ configuration: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.Object({
25
+ key: typebox_1.Type.Literal("DELETE_PROTECTION_ENABLED"),
26
+ value: typebox_1.Type.Union([typebox_1.Type.Literal("true"), typebox_1.Type.Literal("false")]),
27
+ }), { minItems: 0, maxItems: 1 })),
28
+ });
29
+ /**
30
+ * Convert a data core v0 to a data core
31
+ */
32
+ const dataCoreV0ToDataCore = (dataCoreV0, organizationId) => {
33
+ return {
34
+ id: dataCoreV0.id,
35
+ tenantId: organizationId,
36
+ name: dataCoreV0.name,
37
+ description: dataCoreV0.description ?? "",
38
+ accessControl: dataCoreV0.isPublic ? "public" : "private",
39
+ deleteProtected: dataCoreV0.configuration?.[0]?.value === "true",
40
+ };
41
+ };
42
+ exports.dataCoreV0ToDataCore = dataCoreV0ToDataCore;
@@ -0,0 +1,33 @@
1
+ import { type Static, type TNull, type TObject, type TString, type TUnion } from "@sinclair/typebox";
2
+ /**
3
+ * The schema for an event type
4
+ */
5
+ export declare const EventTypeSchema: TObject<{
6
+ id: TString;
7
+ tenantId: TString;
8
+ dataCoreId: TString;
9
+ flowTypeId: TString;
10
+ name: TString;
11
+ description: TString;
12
+ }>;
13
+ /**
14
+ * The type for an event type
15
+ */
16
+ export type EventType = Static<typeof EventTypeSchema>;
17
+ /**
18
+ * The schema for an event type v0
19
+ */
20
+ export declare const EventTypeV0Schema: TObject<{
21
+ id: TString;
22
+ name: TString;
23
+ description: TUnion<[TString, TNull]>;
24
+ }>;
25
+ /**
26
+ * The type for an event type v0
27
+ */
28
+ export type EventTypeV0 = Static<typeof EventTypeV0Schema>;
29
+ /**
30
+ * Convert an event type v0 to an event type
31
+ */
32
+ export declare const eventTypeV0ToEventType: (eventTypeV0: EventTypeV0, organizationId: string, dataCoreId: string, flowTypeId: string) => EventType;
33
+ //# sourceMappingURL=event-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-type.d.ts","sourceRoot":"","sources":["../../src/contracts/event-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAA;AAE1G;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC;IACpC,EAAE,EAAE,OAAO,CAAA;IACX,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;CACrB,CAOC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAA;AAEtD;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,CAAC;IACtC,EAAE,EAAE,OAAO,CAAA;IACX,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;CACtC,CAIC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAE1D;;GAEG;AACH,eAAO,MAAM,sBAAsB,gBACpB,WAAW,kBACR,MAAM,cACV,MAAM,cACN,MAAM,KACjB,SASF,CAAA"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.eventTypeV0ToEventType = exports.EventTypeV0Schema = exports.EventTypeSchema = void 0;
4
+ const typebox_1 = require("@sinclair/typebox");
5
+ /**
6
+ * The schema for an event type
7
+ */
8
+ exports.EventTypeSchema = typebox_1.Type.Object({
9
+ id: typebox_1.Type.String(),
10
+ tenantId: typebox_1.Type.String(),
11
+ dataCoreId: typebox_1.Type.String(),
12
+ flowTypeId: typebox_1.Type.String(),
13
+ name: typebox_1.Type.String(),
14
+ description: typebox_1.Type.String(),
15
+ });
16
+ /**
17
+ * The schema for an event type v0
18
+ */
19
+ exports.EventTypeV0Schema = typebox_1.Type.Object({
20
+ id: typebox_1.Type.String(),
21
+ name: typebox_1.Type.String(),
22
+ description: typebox_1.Type.Union([typebox_1.Type.String(), typebox_1.Type.Null()]),
23
+ });
24
+ /**
25
+ * Convert an event type v0 to an event type
26
+ */
27
+ const eventTypeV0ToEventType = (eventTypeV0, organizationId, dataCoreId, flowTypeId) => {
28
+ return {
29
+ id: eventTypeV0.id,
30
+ tenantId: organizationId,
31
+ dataCoreId,
32
+ flowTypeId,
33
+ name: eventTypeV0.name,
34
+ description: eventTypeV0.description ?? "",
35
+ };
36
+ };
37
+ exports.eventTypeV0ToEventType = eventTypeV0ToEventType;
@@ -0,0 +1,20 @@
1
+ import { type Static, type TObject, type TRecord, type TString, type TUnknown } from "@sinclair/typebox";
2
+ /**
3
+ * The schema for an event
4
+ */
5
+ export declare const FlowcoreEventSchema: TObject<{
6
+ eventId: TString;
7
+ timeBucket: TString;
8
+ tenant: TString;
9
+ dataCoreId: TString;
10
+ flowType: TString;
11
+ eventType: TString;
12
+ metadata: TRecord<TString, TUnknown>;
13
+ payload: TRecord<TString, TUnknown>;
14
+ validTime: TString;
15
+ }>;
16
+ /**
17
+ * The type for an event
18
+ */
19
+ export type FlowcoreEvent = Static<typeof FlowcoreEventSchema>;
20
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/contracts/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAQ,MAAM,mBAAmB,CAAA;AAE9G;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC;IACxC,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,OAAO,CAAA;IACnB,MAAM,EAAE,OAAO,CAAA;IACf,UAAU,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACpC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACnC,SAAS,EAAE,OAAO,CAAA;CACnB,CAUC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowcoreEventSchema = void 0;
4
+ const typebox_1 = require("@sinclair/typebox");
5
+ /**
6
+ * The schema for an event
7
+ */
8
+ exports.FlowcoreEventSchema = typebox_1.Type.Object({
9
+ eventId: typebox_1.Type.String(),
10
+ timeBucket: typebox_1.Type.String(),
11
+ tenant: typebox_1.Type.String(),
12
+ dataCoreId: typebox_1.Type.String(),
13
+ flowType: typebox_1.Type.String(),
14
+ eventType: typebox_1.Type.String(),
15
+ metadata: typebox_1.Type.Record(typebox_1.Type.String(), typebox_1.Type.Unknown()),
16
+ payload: typebox_1.Type.Record(typebox_1.Type.String(), typebox_1.Type.Unknown()),
17
+ validTime: typebox_1.Type.String(),
18
+ });
@@ -0,0 +1,32 @@
1
+ import { type Static, type TNull, type TObject, type TString, type TUnion } from "@sinclair/typebox";
2
+ /**
3
+ * The schema for a flow type
4
+ */
5
+ export declare const FlowTypeSchema: TObject<{
6
+ id: TString;
7
+ tenantId: TString;
8
+ dataCoreId: TString;
9
+ name: TString;
10
+ description: TString;
11
+ }>;
12
+ /**
13
+ * The type for a flow type
14
+ */
15
+ export type FlowType = Static<typeof FlowTypeSchema>;
16
+ /**
17
+ * The schema for a flow type v0
18
+ */
19
+ export declare const FlowTypeV0Schema: TObject<{
20
+ id: TString;
21
+ aggregator: TString;
22
+ description: TUnion<[TString, TNull]>;
23
+ }>;
24
+ /**
25
+ * The type for a flow type v0
26
+ */
27
+ export type FlowTypeV0 = Static<typeof FlowTypeV0Schema>;
28
+ /**
29
+ * Convert a flow type v0 to a flow type
30
+ */
31
+ export declare const flowTypeV0ToFlowType: (flowTypeV0: FlowTypeV0, organizationId: string, dataCoreId: string) => FlowType;
32
+ //# sourceMappingURL=flow-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-type.d.ts","sourceRoot":"","sources":["../../src/contracts/flow-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAA;AAE1G;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,CAAC;IACnC,EAAE,EAAE,OAAO,CAAA;IACX,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,OAAO,CAAA;IACnB,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;CACrB,CAMC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,OAAO,CAAC;IACrC,EAAE,EAAE,OAAO,CAAA;IACX,UAAU,EAAE,OAAO,CAAA;IACnB,WAAW,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;CACtC,CAIC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,oBAAoB,eACnB,UAAU,kBACN,MAAM,cACV,MAAM,KACjB,QAQF,CAAA"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flowTypeV0ToFlowType = exports.FlowTypeV0Schema = exports.FlowTypeSchema = void 0;
4
+ const typebox_1 = require("@sinclair/typebox");
5
+ /**
6
+ * The schema for a flow type
7
+ */
8
+ exports.FlowTypeSchema = typebox_1.Type.Object({
9
+ id: typebox_1.Type.String(),
10
+ tenantId: typebox_1.Type.String(),
11
+ dataCoreId: typebox_1.Type.String(),
12
+ name: typebox_1.Type.String(),
13
+ description: typebox_1.Type.String(),
14
+ });
15
+ /**
16
+ * The schema for a flow type v0
17
+ */
18
+ exports.FlowTypeV0Schema = typebox_1.Type.Object({
19
+ id: typebox_1.Type.String(),
20
+ aggregator: typebox_1.Type.String(),
21
+ description: typebox_1.Type.Union([typebox_1.Type.String(), typebox_1.Type.Null()]),
22
+ });
23
+ /**
24
+ * Convert a flow type v0 to a flow type
25
+ */
26
+ const flowTypeV0ToFlowType = (flowTypeV0, organizationId, dataCoreId) => {
27
+ return {
28
+ id: flowTypeV0.id,
29
+ tenantId: organizationId,
30
+ dataCoreId,
31
+ name: flowTypeV0.aggregator,
32
+ description: flowTypeV0.description ?? "",
33
+ };
34
+ };
35
+ exports.flowTypeV0ToFlowType = flowTypeV0ToFlowType;