@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.
- package/README.md +41 -0
- package/esm/commands/api-key/api-key.create.d.ts +34 -0
- package/esm/commands/api-key/api-key.create.d.ts.map +1 -0
- package/esm/commands/api-key/api-key.create.js +74 -0
- package/esm/commands/api-key/api-key.delete.d.ts +28 -0
- package/esm/commands/api-key/api-key.delete.d.ts.map +1 -0
- package/esm/commands/api-key/api-key.delete.js +60 -0
- package/esm/commands/api-key/api-key.list.d.ts +27 -0
- package/esm/commands/api-key/api-key.list.d.ts.map +1 -0
- package/esm/commands/api-key/api-key.list.js +58 -0
- package/esm/commands/data-core/data-core.create.d.ts +39 -0
- package/esm/commands/data-core/data-core.create.d.ts.map +1 -0
- package/esm/commands/data-core/data-core.create.js +32 -0
- package/esm/commands/data-core/data-core.delete-request.d.ts +37 -0
- package/esm/commands/data-core/data-core.delete-request.d.ts.map +1 -0
- package/esm/commands/data-core/data-core.delete-request.js +94 -0
- package/esm/commands/data-core/data-core.exists.d.ts +37 -0
- package/esm/commands/data-core/data-core.exists.d.ts.map +1 -0
- package/esm/commands/data-core/data-core.exists.js +33 -0
- package/esm/commands/data-core/data-core.fetch.d.ts +51 -0
- package/esm/commands/data-core/data-core.fetch.d.ts.map +1 -0
- package/esm/commands/data-core/data-core.fetch.js +48 -0
- package/esm/commands/data-core/data-core.list.d.ts +33 -0
- package/esm/commands/data-core/data-core.list.d.ts.map +1 -0
- package/esm/commands/data-core/data-core.list.js +40 -0
- package/esm/commands/data-core/data-core.update.d.ts +41 -0
- package/esm/commands/data-core/data-core.update.d.ts.map +1 -0
- package/esm/commands/data-core/data-core.update.js +43 -0
- package/esm/commands/event-type/event-type.create.d.ts +35 -0
- package/esm/commands/event-type/event-type.create.d.ts.map +1 -0
- package/esm/commands/event-type/event-type.create.js +32 -0
- package/esm/commands/event-type/event-type.delete-request.d.ts +37 -0
- package/esm/commands/event-type/event-type.delete-request.d.ts.map +1 -0
- package/esm/commands/event-type/event-type.delete-request.js +98 -0
- package/esm/commands/event-type/event-type.exists.d.ts +37 -0
- package/esm/commands/event-type/event-type.exists.d.ts.map +1 -0
- package/esm/commands/event-type/event-type.exists.js +33 -0
- package/esm/commands/event-type/event-type.fetch.d.ts +45 -0
- package/esm/commands/event-type/event-type.fetch.d.ts.map +1 -0
- package/esm/commands/event-type/event-type.fetch.js +48 -0
- package/esm/commands/event-type/event-type.list.d.ts +31 -0
- package/esm/commands/event-type/event-type.list.d.ts.map +1 -0
- package/esm/commands/event-type/event-type.list.js +36 -0
- package/esm/commands/event-type/event-type.update.d.ts +37 -0
- package/esm/commands/event-type/event-type.update.d.ts.map +1 -0
- package/esm/commands/event-type/event-type.update.js +39 -0
- package/esm/commands/events/events.fetch-time-buckets-by-names.d.ts +53 -0
- package/esm/commands/events/events.fetch-time-buckets-by-names.d.ts.map +1 -0
- package/esm/commands/events/events.fetch-time-buckets-by-names.js +40 -0
- package/esm/commands/events/events.fetch.d.ts +58 -0
- package/esm/commands/events/events.fetch.d.ts.map +1 -0
- package/esm/commands/events/events.fetch.js +54 -0
- package/esm/commands/flow-type/flow-type.create.d.ts +35 -0
- package/esm/commands/flow-type/flow-type.create.d.ts.map +1 -0
- package/esm/commands/flow-type/flow-type.create.js +32 -0
- package/esm/commands/flow-type/flow-type.delete-request.d.ts +47 -0
- package/esm/commands/flow-type/flow-type.delete-request.d.ts.map +1 -0
- package/esm/commands/flow-type/flow-type.delete-request.js +118 -0
- package/esm/commands/flow-type/flow-type.exists.d.ts +39 -0
- package/esm/commands/flow-type/flow-type.exists.d.ts.map +1 -0
- package/esm/commands/flow-type/flow-type.exists.js +33 -0
- package/esm/commands/flow-type/flow-type.fetch.d.ts +51 -0
- package/esm/commands/flow-type/flow-type.fetch.d.ts.map +1 -0
- package/esm/commands/flow-type/flow-type.fetch.js +48 -0
- package/esm/commands/flow-type/flow-type.list.d.ts +31 -0
- package/esm/commands/flow-type/flow-type.list.d.ts.map +1 -0
- package/esm/commands/flow-type/flow-type.list.js +36 -0
- package/esm/commands/flow-type/flow-type.update.d.ts +37 -0
- package/esm/commands/flow-type/flow-type.update.d.ts.map +1 -0
- package/esm/commands/flow-type/flow-type.update.js +39 -0
- package/esm/commands/index.d.ts +32 -0
- package/esm/commands/index.d.ts.map +1 -0
- package/esm/commands/index.js +39 -0
- package/esm/commands/secret/secret.create.d.ts +30 -0
- package/esm/commands/secret/secret.create.d.ts.map +1 -0
- package/esm/commands/secret/secret.create.js +60 -0
- package/esm/commands/secret/secret.delete.d.ts +28 -0
- package/esm/commands/secret/secret.delete.d.ts.map +1 -0
- package/esm/commands/secret/secret.delete.js +61 -0
- package/esm/commands/secret/secret.list.d.ts +26 -0
- package/esm/commands/secret/secret.list.d.ts.map +1 -0
- package/esm/commands/secret/secret.list.js +63 -0
- package/esm/commands/tenant/tenant.fetch.d.ts +43 -0
- package/esm/commands/tenant/tenant.fetch.d.ts.map +1 -0
- package/esm/commands/tenant/tenant.fetch.js +77 -0
- package/esm/commands/tenant/tenant.list.d.ts +20 -0
- package/esm/commands/tenant/tenant.list.d.ts.map +1 -0
- package/esm/commands/tenant/tenant.list.js +65 -0
- package/esm/commands/variable/variable.create.d.ts +31 -0
- package/esm/commands/variable/variable.create.d.ts.map +1 -0
- package/esm/commands/variable/variable.create.js +66 -0
- package/esm/commands/variable/variable.delete.d.ts +28 -0
- package/esm/commands/variable/variable.delete.d.ts.map +1 -0
- package/esm/commands/variable/variable.delete.js +63 -0
- package/esm/commands/variable/variable.list.d.ts +27 -0
- package/esm/commands/variable/variable.list.d.ts.map +1 -0
- package/esm/commands/variable/variable.list.js +69 -0
- package/esm/common/command.d.ts +63 -0
- package/esm/common/command.d.ts.map +1 -0
- package/esm/common/command.js +91 -0
- package/esm/common/flowcore-client.d.ts +39 -0
- package/esm/common/flowcore-client.d.ts.map +1 -0
- package/esm/common/flowcore-client.js +72 -0
- package/esm/contracts/api-key.d.ts +14 -0
- package/esm/contracts/api-key.d.ts.map +1 -0
- package/esm/contracts/api-key.js +9 -0
- package/esm/contracts/data-core.d.ts +38 -0
- package/esm/contracts/data-core.d.ts.map +1 -0
- package/esm/contracts/data-core.js +38 -0
- package/esm/contracts/event-type.d.ts +33 -0
- package/esm/contracts/event-type.d.ts.map +1 -0
- package/esm/contracts/event-type.js +33 -0
- package/esm/contracts/event.d.ts +20 -0
- package/esm/contracts/event.d.ts.map +1 -0
- package/esm/contracts/event.js +15 -0
- package/esm/contracts/flow-type.d.ts +32 -0
- package/esm/contracts/flow-type.d.ts.map +1 -0
- package/esm/contracts/flow-type.js +31 -0
- package/esm/contracts/index.d.ts +4 -0
- package/esm/contracts/index.d.ts.map +1 -0
- package/esm/contracts/index.js +1 -0
- package/esm/contracts/tenant.d.ts +50 -0
- package/esm/contracts/tenant.d.ts.map +1 -0
- package/esm/contracts/tenant.js +33 -0
- package/esm/contracts/variable.d.ts +13 -0
- package/esm/contracts/variable.d.ts.map +1 -0
- package/esm/contracts/variable.js +8 -0
- package/esm/exceptions/client-error.d.ts +9 -0
- package/esm/exceptions/client-error.d.ts.map +1 -0
- package/esm/exceptions/client-error.js +20 -0
- package/esm/exceptions/command-error.d.ts +7 -0
- package/esm/exceptions/command-error.d.ts.map +1 -0
- package/esm/exceptions/command-error.js +8 -0
- package/esm/exceptions/index.d.ts +4 -0
- package/esm/exceptions/index.d.ts.map +1 -0
- package/esm/exceptions/index.js +3 -0
- package/esm/exceptions/invalid-response.d.ts +8 -0
- package/esm/exceptions/invalid-response.d.ts.map +1 -0
- package/esm/exceptions/invalid-response.js +15 -0
- package/esm/exceptions/not-found.d.ts +7 -0
- package/esm/exceptions/not-found.d.ts.map +1 -0
- package/esm/exceptions/not-found.js +8 -0
- package/esm/mod.d.ts +6 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +5 -0
- package/esm/package.json +3 -0
- package/esm/utils/parse-response-helper.d.ts +6 -0
- package/esm/utils/parse-response-helper.d.ts.map +1 -0
- package/esm/utils/parse-response-helper.js +16 -0
- package/package.json +28 -0
- package/script/commands/api-key/api-key.create.d.ts +34 -0
- package/script/commands/api-key/api-key.create.d.ts.map +1 -0
- package/script/commands/api-key/api-key.create.js +78 -0
- package/script/commands/api-key/api-key.delete.d.ts +28 -0
- package/script/commands/api-key/api-key.delete.d.ts.map +1 -0
- package/script/commands/api-key/api-key.delete.js +64 -0
- package/script/commands/api-key/api-key.list.d.ts +27 -0
- package/script/commands/api-key/api-key.list.d.ts.map +1 -0
- package/script/commands/api-key/api-key.list.js +62 -0
- package/script/commands/data-core/data-core.create.d.ts +39 -0
- package/script/commands/data-core/data-core.create.d.ts.map +1 -0
- package/script/commands/data-core/data-core.create.js +36 -0
- package/script/commands/data-core/data-core.delete-request.d.ts +37 -0
- package/script/commands/data-core/data-core.delete-request.d.ts.map +1 -0
- package/script/commands/data-core/data-core.delete-request.js +98 -0
- package/script/commands/data-core/data-core.exists.d.ts +37 -0
- package/script/commands/data-core/data-core.exists.d.ts.map +1 -0
- package/script/commands/data-core/data-core.exists.js +37 -0
- package/script/commands/data-core/data-core.fetch.d.ts +51 -0
- package/script/commands/data-core/data-core.fetch.d.ts.map +1 -0
- package/script/commands/data-core/data-core.fetch.js +52 -0
- package/script/commands/data-core/data-core.list.d.ts +33 -0
- package/script/commands/data-core/data-core.list.d.ts.map +1 -0
- package/script/commands/data-core/data-core.list.js +44 -0
- package/script/commands/data-core/data-core.update.d.ts +41 -0
- package/script/commands/data-core/data-core.update.d.ts.map +1 -0
- package/script/commands/data-core/data-core.update.js +47 -0
- package/script/commands/event-type/event-type.create.d.ts +35 -0
- package/script/commands/event-type/event-type.create.d.ts.map +1 -0
- package/script/commands/event-type/event-type.create.js +36 -0
- package/script/commands/event-type/event-type.delete-request.d.ts +37 -0
- package/script/commands/event-type/event-type.delete-request.d.ts.map +1 -0
- package/script/commands/event-type/event-type.delete-request.js +102 -0
- package/script/commands/event-type/event-type.exists.d.ts +37 -0
- package/script/commands/event-type/event-type.exists.d.ts.map +1 -0
- package/script/commands/event-type/event-type.exists.js +37 -0
- package/script/commands/event-type/event-type.fetch.d.ts +45 -0
- package/script/commands/event-type/event-type.fetch.d.ts.map +1 -0
- package/script/commands/event-type/event-type.fetch.js +52 -0
- package/script/commands/event-type/event-type.list.d.ts +31 -0
- package/script/commands/event-type/event-type.list.d.ts.map +1 -0
- package/script/commands/event-type/event-type.list.js +40 -0
- package/script/commands/event-type/event-type.update.d.ts +37 -0
- package/script/commands/event-type/event-type.update.d.ts.map +1 -0
- package/script/commands/event-type/event-type.update.js +43 -0
- package/script/commands/events/events.fetch-time-buckets-by-names.d.ts +53 -0
- package/script/commands/events/events.fetch-time-buckets-by-names.d.ts.map +1 -0
- package/script/commands/events/events.fetch-time-buckets-by-names.js +44 -0
- package/script/commands/events/events.fetch.d.ts +58 -0
- package/script/commands/events/events.fetch.d.ts.map +1 -0
- package/script/commands/events/events.fetch.js +58 -0
- package/script/commands/flow-type/flow-type.create.d.ts +35 -0
- package/script/commands/flow-type/flow-type.create.d.ts.map +1 -0
- package/script/commands/flow-type/flow-type.create.js +36 -0
- package/script/commands/flow-type/flow-type.delete-request.d.ts +47 -0
- package/script/commands/flow-type/flow-type.delete-request.d.ts.map +1 -0
- package/script/commands/flow-type/flow-type.delete-request.js +122 -0
- package/script/commands/flow-type/flow-type.exists.d.ts +39 -0
- package/script/commands/flow-type/flow-type.exists.d.ts.map +1 -0
- package/script/commands/flow-type/flow-type.exists.js +37 -0
- package/script/commands/flow-type/flow-type.fetch.d.ts +51 -0
- package/script/commands/flow-type/flow-type.fetch.d.ts.map +1 -0
- package/script/commands/flow-type/flow-type.fetch.js +52 -0
- package/script/commands/flow-type/flow-type.list.d.ts +31 -0
- package/script/commands/flow-type/flow-type.list.d.ts.map +1 -0
- package/script/commands/flow-type/flow-type.list.js +40 -0
- package/script/commands/flow-type/flow-type.update.d.ts +37 -0
- package/script/commands/flow-type/flow-type.update.d.ts.map +1 -0
- package/script/commands/flow-type/flow-type.update.js +43 -0
- package/script/commands/index.d.ts +32 -0
- package/script/commands/index.d.ts.map +1 -0
- package/script/commands/index.js +55 -0
- package/script/commands/secret/secret.create.d.ts +30 -0
- package/script/commands/secret/secret.create.d.ts.map +1 -0
- package/script/commands/secret/secret.create.js +64 -0
- package/script/commands/secret/secret.delete.d.ts +28 -0
- package/script/commands/secret/secret.delete.d.ts.map +1 -0
- package/script/commands/secret/secret.delete.js +65 -0
- package/script/commands/secret/secret.list.d.ts +26 -0
- package/script/commands/secret/secret.list.d.ts.map +1 -0
- package/script/commands/secret/secret.list.js +67 -0
- package/script/commands/tenant/tenant.fetch.d.ts +43 -0
- package/script/commands/tenant/tenant.fetch.d.ts.map +1 -0
- package/script/commands/tenant/tenant.fetch.js +81 -0
- package/script/commands/tenant/tenant.list.d.ts +20 -0
- package/script/commands/tenant/tenant.list.d.ts.map +1 -0
- package/script/commands/tenant/tenant.list.js +69 -0
- package/script/commands/variable/variable.create.d.ts +31 -0
- package/script/commands/variable/variable.create.d.ts.map +1 -0
- package/script/commands/variable/variable.create.js +70 -0
- package/script/commands/variable/variable.delete.d.ts +28 -0
- package/script/commands/variable/variable.delete.d.ts.map +1 -0
- package/script/commands/variable/variable.delete.js +67 -0
- package/script/commands/variable/variable.list.d.ts +27 -0
- package/script/commands/variable/variable.list.d.ts.map +1 -0
- package/script/commands/variable/variable.list.js +73 -0
- package/script/common/command.d.ts +63 -0
- package/script/common/command.d.ts.map +1 -0
- package/script/common/command.js +96 -0
- package/script/common/flowcore-client.d.ts +39 -0
- package/script/common/flowcore-client.d.ts.map +1 -0
- package/script/common/flowcore-client.js +76 -0
- package/script/contracts/api-key.d.ts +14 -0
- package/script/contracts/api-key.d.ts.map +1 -0
- package/script/contracts/api-key.js +12 -0
- package/script/contracts/data-core.d.ts +38 -0
- package/script/contracts/data-core.d.ts.map +1 -0
- package/script/contracts/data-core.js +42 -0
- package/script/contracts/event-type.d.ts +33 -0
- package/script/contracts/event-type.d.ts.map +1 -0
- package/script/contracts/event-type.js +37 -0
- package/script/contracts/event.d.ts +20 -0
- package/script/contracts/event.d.ts.map +1 -0
- package/script/contracts/event.js +18 -0
- package/script/contracts/flow-type.d.ts +32 -0
- package/script/contracts/flow-type.d.ts.map +1 -0
- package/script/contracts/flow-type.js +35 -0
- package/script/contracts/index.d.ts +4 -0
- package/script/contracts/index.d.ts.map +1 -0
- package/script/contracts/index.js +2 -0
- package/script/contracts/tenant.d.ts +50 -0
- package/script/contracts/tenant.d.ts.map +1 -0
- package/script/contracts/tenant.js +37 -0
- package/script/contracts/variable.d.ts +13 -0
- package/script/contracts/variable.d.ts.map +1 -0
- package/script/contracts/variable.js +11 -0
- package/script/exceptions/client-error.d.ts +9 -0
- package/script/exceptions/client-error.d.ts.map +1 -0
- package/script/exceptions/client-error.js +24 -0
- package/script/exceptions/command-error.d.ts +7 -0
- package/script/exceptions/command-error.d.ts.map +1 -0
- package/script/exceptions/command-error.js +12 -0
- package/script/exceptions/index.d.ts +4 -0
- package/script/exceptions/index.d.ts.map +1 -0
- package/script/exceptions/index.js +19 -0
- package/script/exceptions/invalid-response.d.ts +8 -0
- package/script/exceptions/invalid-response.d.ts.map +1 -0
- package/script/exceptions/invalid-response.js +19 -0
- package/script/exceptions/not-found.d.ts +7 -0
- package/script/exceptions/not-found.d.ts.map +1 -0
- package/script/exceptions/not-found.js +12 -0
- package/script/mod.d.ts +6 -0
- package/script/mod.d.ts.map +1 -0
- package/script/mod.js +21 -0
- package/script/package.json +3 -0
- package/script/utils/parse-response-helper.d.ts +6 -0
- package/script/utils/parse-response-helper.d.ts.map +1 -0
- package/script/utils/parse-response-helper.js +20 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { GraphQlCommand } from "../../common/command.js";
|
|
3
|
+
import { TenantV0Schema, tenantV0ToTenant } from "../../contracts/tenant.js";
|
|
4
|
+
import { parseResponseHelper } from "../../utils/parse-response-helper.js";
|
|
5
|
+
import { NotFoundException } from "../../exceptions/not-found.js";
|
|
6
|
+
const graphQlQueryById = `
|
|
7
|
+
query FLOWCORE_SDK_TENANT_FETCH($tenantId: ID!) {
|
|
8
|
+
organization(search: {id: $tenantId}) {
|
|
9
|
+
id
|
|
10
|
+
org
|
|
11
|
+
displayName
|
|
12
|
+
description
|
|
13
|
+
website
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
const graphQlQueryByName = `
|
|
18
|
+
query FLOWCORE_SDK_TENANT_FETCH($tenant: String) {
|
|
19
|
+
organization(search: {org: $tenant}) {
|
|
20
|
+
id
|
|
21
|
+
org
|
|
22
|
+
displayName
|
|
23
|
+
description
|
|
24
|
+
website
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
const responseSchema = Type.Object({
|
|
29
|
+
data: Type.Object({
|
|
30
|
+
organization: Type.Union([
|
|
31
|
+
TenantV0Schema,
|
|
32
|
+
Type.Null(),
|
|
33
|
+
]),
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Fetch a tenant
|
|
38
|
+
*/
|
|
39
|
+
export class TenantFetchCommand extends GraphQlCommand {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
/**
|
|
43
|
+
* The allowed modes for the command
|
|
44
|
+
*/
|
|
45
|
+
Object.defineProperty(this, "allowedModes", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: ["bearer"]
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Parse the response
|
|
54
|
+
*/
|
|
55
|
+
parseResponse(rawResponse) {
|
|
56
|
+
const response = parseResponseHelper(responseSchema, rawResponse);
|
|
57
|
+
if (!response.data.organization) {
|
|
58
|
+
throw new NotFoundException("Tenant", this.input.tenantId ?? this.input.tenant);
|
|
59
|
+
}
|
|
60
|
+
return tenantV0ToTenant(response.data.organization);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get the body for the request
|
|
64
|
+
*/
|
|
65
|
+
getBody() {
|
|
66
|
+
if ("tenantId" in this.input) {
|
|
67
|
+
return JSON.stringify({
|
|
68
|
+
query: graphQlQueryById,
|
|
69
|
+
variables: this.input,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return JSON.stringify({
|
|
73
|
+
query: graphQlQueryByName,
|
|
74
|
+
variables: this.input,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GraphQlCommand } from "../../common/command.js";
|
|
2
|
+
import { type TenantWithLinkType } from "../../contracts/tenant.js";
|
|
3
|
+
/**
|
|
4
|
+
* List tenants
|
|
5
|
+
*/
|
|
6
|
+
export declare class TenantListCommand extends GraphQlCommand<Record<string, never>, TenantWithLinkType[]> {
|
|
7
|
+
/**
|
|
8
|
+
* The allowed modes for the command
|
|
9
|
+
*/
|
|
10
|
+
protected allowedModes: ("apiKey" | "bearer")[];
|
|
11
|
+
/**
|
|
12
|
+
* Parse the response
|
|
13
|
+
*/
|
|
14
|
+
protected parseResponse(rawResponse: unknown): TenantWithLinkType[];
|
|
15
|
+
/**
|
|
16
|
+
* Get the body for the request
|
|
17
|
+
*/
|
|
18
|
+
protected getBody(): string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=tenant.list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant.list.d.ts","sourceRoot":"","sources":["../../../src/commands/tenant/tenant.list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAoC,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AA+BrG;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAChG;;OAEG;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,kBAAkB,EAAE;IAQ5E;;OAEG;cACgB,OAAO,IAAI,MAAM;CAKrC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { GraphQlCommand } from "../../common/command.js";
|
|
3
|
+
import { TenantV0Schema, tenantV0ToTenant } from "../../contracts/tenant.js";
|
|
4
|
+
import { parseResponseHelper } from "../../utils/parse-response-helper.js";
|
|
5
|
+
const graphQlQueryById = `
|
|
6
|
+
query FLOWCORE_SDK_TENANT_LIST {
|
|
7
|
+
me {
|
|
8
|
+
organizations {
|
|
9
|
+
linkType
|
|
10
|
+
organization {
|
|
11
|
+
id
|
|
12
|
+
org
|
|
13
|
+
displayName
|
|
14
|
+
description
|
|
15
|
+
website
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
const responseSchema = Type.Object({
|
|
22
|
+
data: Type.Object({
|
|
23
|
+
me: Type.Object({
|
|
24
|
+
organizations: Type.Array(Type.Object({
|
|
25
|
+
linkType: Type.Union([Type.Literal("OWNER"), Type.Literal("COLLABORATOR")]),
|
|
26
|
+
organization: TenantV0Schema,
|
|
27
|
+
})),
|
|
28
|
+
}),
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* List tenants
|
|
33
|
+
*/
|
|
34
|
+
export class TenantListCommand extends GraphQlCommand {
|
|
35
|
+
constructor() {
|
|
36
|
+
super(...arguments);
|
|
37
|
+
/**
|
|
38
|
+
* The allowed modes for the command
|
|
39
|
+
*/
|
|
40
|
+
Object.defineProperty(this, "allowedModes", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: ["bearer"]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parse the response
|
|
49
|
+
*/
|
|
50
|
+
parseResponse(rawResponse) {
|
|
51
|
+
const response = parseResponseHelper(responseSchema, rawResponse);
|
|
52
|
+
return response.data.me.organizations.flatMap((organization) => ({
|
|
53
|
+
...tenantV0ToTenant(organization.organization),
|
|
54
|
+
linkType: organization.linkType,
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get the body for the request
|
|
59
|
+
*/
|
|
60
|
+
getBody() {
|
|
61
|
+
return JSON.stringify({
|
|
62
|
+
query: graphQlQueryById,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { GraphQlCommand } from "../../common/command.js";
|
|
2
|
+
import type { Variable } from "../../contracts/variable.js";
|
|
3
|
+
/**
|
|
4
|
+
* The input for the variable create command
|
|
5
|
+
*/
|
|
6
|
+
export interface VariableCreateInput {
|
|
7
|
+
/** The tenant id */
|
|
8
|
+
tenantId: string;
|
|
9
|
+
/** The key of the variable */
|
|
10
|
+
key: string;
|
|
11
|
+
/** The value of the variable */
|
|
12
|
+
value: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create a variable
|
|
16
|
+
*/
|
|
17
|
+
export declare class VariableCreateCommand extends GraphQlCommand<VariableCreateInput, Variable> {
|
|
18
|
+
/**
|
|
19
|
+
* The allowed modes for the command
|
|
20
|
+
*/
|
|
21
|
+
protected allowedModes: ("apiKey" | "bearer")[];
|
|
22
|
+
/**
|
|
23
|
+
* Parse the response
|
|
24
|
+
*/
|
|
25
|
+
protected parseResponse(rawResponse: unknown): Variable;
|
|
26
|
+
/**
|
|
27
|
+
* Get the body for the request
|
|
28
|
+
*/
|
|
29
|
+
protected getBody(): string;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=variable.create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable.create.d.ts","sourceRoot":"","sources":["../../../src/commands/variable/variable.create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAG3D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAA;CACd;AA4BD;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,cAAc,CAAC,mBAAmB,EAAE,QAAQ,CAAC;IACtF;;OAEG;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ;IAchE;;OAEG;cACgB,OAAO,IAAI,MAAM;CAMrC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { GraphQlCommand } from "../../common/command.js";
|
|
3
|
+
import { parseResponseHelper } from "../../utils/parse-response-helper.js";
|
|
4
|
+
import { CommandError } from "../../exceptions/command-error.js";
|
|
5
|
+
const graphQlQueryById = `
|
|
6
|
+
mutation FLOWCORE_SDK_VARIABLE_CREATE($tenantId: ID!, $key: String!, $value: String!) {
|
|
7
|
+
organization(id: $tenantId) {
|
|
8
|
+
createVariable(key: $key, value: $value)
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
const responseSchema = Type.Object({
|
|
13
|
+
errors: Type.Optional(Type.Array(Type.Object({
|
|
14
|
+
message: Type.String(),
|
|
15
|
+
}))),
|
|
16
|
+
data: Type.Union([
|
|
17
|
+
Type.Object({
|
|
18
|
+
organization: Type.Object({
|
|
19
|
+
createVariable: Type.Union([Type.Boolean(), Type.Null()]),
|
|
20
|
+
}),
|
|
21
|
+
}),
|
|
22
|
+
Type.Null(),
|
|
23
|
+
]),
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Create a variable
|
|
27
|
+
*/
|
|
28
|
+
export class VariableCreateCommand extends GraphQlCommand {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
/**
|
|
32
|
+
* The allowed modes for the command
|
|
33
|
+
*/
|
|
34
|
+
Object.defineProperty(this, "allowedModes", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: ["bearer"]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Parse the response
|
|
43
|
+
*/
|
|
44
|
+
parseResponse(rawResponse) {
|
|
45
|
+
const response = parseResponseHelper(responseSchema, rawResponse);
|
|
46
|
+
if (response.errors) {
|
|
47
|
+
throw new CommandError(this.constructor.name, response.errors[0].message);
|
|
48
|
+
}
|
|
49
|
+
if (!response.data || response.data.organization.createVariable !== true) {
|
|
50
|
+
throw new CommandError(this.constructor.name, "Failed to create variable");
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
key: this.input.key,
|
|
54
|
+
value: this.input.value,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get the body for the request
|
|
59
|
+
*/
|
|
60
|
+
getBody() {
|
|
61
|
+
return JSON.stringify({
|
|
62
|
+
query: graphQlQueryById,
|
|
63
|
+
variables: this.input,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { GraphQlCommand } from "../../common/command.js";
|
|
2
|
+
/**
|
|
3
|
+
* The input for the variable delete command
|
|
4
|
+
*/
|
|
5
|
+
export interface VariableDeleteInput {
|
|
6
|
+
/** The tenant id */
|
|
7
|
+
tenantId: string;
|
|
8
|
+
/** The key of the variable */
|
|
9
|
+
key: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create a variable
|
|
13
|
+
*/
|
|
14
|
+
export declare class VariableDeleteCommand extends GraphQlCommand<VariableDeleteInput, boolean> {
|
|
15
|
+
/**
|
|
16
|
+
* The allowed modes for the command
|
|
17
|
+
*/
|
|
18
|
+
protected allowedModes: ("apiKey" | "bearer")[];
|
|
19
|
+
/**
|
|
20
|
+
* Parse the response
|
|
21
|
+
*/
|
|
22
|
+
protected parseResponse(rawResponse: unknown): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Get the body for the request
|
|
25
|
+
*/
|
|
26
|
+
protected getBody(): string;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=variable.delete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable.delete.d.ts","sourceRoot":"","sources":["../../../src/commands/variable/variable.delete.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAIxD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAA;CACZ;AA4BD;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,cAAc,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACrF;;OAEG;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO;IAW/D;;OAEG;cACgB,OAAO,IAAI,MAAM;CAMrC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { GraphQlCommand } from "../../common/command.js";
|
|
3
|
+
import { parseResponseHelper } from "../../utils/parse-response-helper.js";
|
|
4
|
+
import { CommandError } from "../../exceptions/command-error.js";
|
|
5
|
+
const graphQlQueryById = `
|
|
6
|
+
mutation FLOWCORE_SDK_VARIABLE_DELETE($tenantId: ID!, $key: String!) {
|
|
7
|
+
organization(id: $tenantId) {
|
|
8
|
+
removeVariable(key: $key)
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
const responseSchema = Type.Object({
|
|
13
|
+
errors: Type.Optional(Type.Array(Type.Object({
|
|
14
|
+
message: Type.String(),
|
|
15
|
+
}))),
|
|
16
|
+
data: Type.Union([
|
|
17
|
+
Type.Object({
|
|
18
|
+
organization: Type.Object({
|
|
19
|
+
removeVariable: Type.Union([Type.Boolean(), Type.Null()]),
|
|
20
|
+
}),
|
|
21
|
+
}),
|
|
22
|
+
Type.Null(),
|
|
23
|
+
]),
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Create a variable
|
|
27
|
+
*/
|
|
28
|
+
export class VariableDeleteCommand extends GraphQlCommand {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
/**
|
|
32
|
+
* The allowed modes for the command
|
|
33
|
+
*/
|
|
34
|
+
Object.defineProperty(this, "allowedModes", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: ["bearer"]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Parse the response
|
|
43
|
+
*/
|
|
44
|
+
parseResponse(rawResponse) {
|
|
45
|
+
const response = parseResponseHelper(responseSchema, rawResponse);
|
|
46
|
+
if (response.errors) {
|
|
47
|
+
throw new CommandError(this.constructor.name, response.errors[0].message);
|
|
48
|
+
}
|
|
49
|
+
if (!response.data || response.data.organization.removeVariable !== true) {
|
|
50
|
+
throw new CommandError(this.constructor.name, "Failed to delete variable");
|
|
51
|
+
}
|
|
52
|
+
return response.data.organization.removeVariable;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the body for the request
|
|
56
|
+
*/
|
|
57
|
+
getBody() {
|
|
58
|
+
return JSON.stringify({
|
|
59
|
+
query: graphQlQueryById,
|
|
60
|
+
variables: this.input,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { GraphQlCommand } from "../../common/command.js";
|
|
2
|
+
import type { Variable } from "../../contracts/variable.js";
|
|
3
|
+
/**
|
|
4
|
+
* The input for the variable list command
|
|
5
|
+
*/
|
|
6
|
+
export interface VariableListInput {
|
|
7
|
+
/** The tenant id */
|
|
8
|
+
tenantId: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* List variables
|
|
12
|
+
*/
|
|
13
|
+
export declare class VariableListCommand extends GraphQlCommand<VariableListInput, Variable[]> {
|
|
14
|
+
/**
|
|
15
|
+
* The allowed modes for the command
|
|
16
|
+
*/
|
|
17
|
+
protected allowedModes: ("apiKey" | "bearer")[];
|
|
18
|
+
/**
|
|
19
|
+
* Parse the response
|
|
20
|
+
*/
|
|
21
|
+
protected parseResponse(rawResponse: unknown): Variable[];
|
|
22
|
+
/**
|
|
23
|
+
* Get the body for the request
|
|
24
|
+
*/
|
|
25
|
+
protected getBody(): string;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=variable.list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable.list.d.ts","sourceRoot":"","sources":["../../../src/commands/variable/variable.list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAG3D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAkCD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,iBAAiB,EAAE,QAAQ,EAAE,CAAC;IACpF;;OAEG;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ,EAAE;IAWlE;;OAEG;cACgB,OAAO,IAAI,MAAM;CAMrC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { GraphQlCommand } from "../../common/command.js";
|
|
3
|
+
import { parseResponseHelper } from "../../utils/parse-response-helper.js";
|
|
4
|
+
import { CommandError } from "../../exceptions/command-error.js";
|
|
5
|
+
const graphQlQueryById = `
|
|
6
|
+
query FLOWCORE_SDK_VARIABLE_LIST($tenantId: ID!) {
|
|
7
|
+
organization(search: {id: $tenantId}) {
|
|
8
|
+
variables {
|
|
9
|
+
key
|
|
10
|
+
value
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
const responseSchema = Type.Object({
|
|
16
|
+
errors: Type.Optional(Type.Array(Type.Object({
|
|
17
|
+
message: Type.String(),
|
|
18
|
+
}))),
|
|
19
|
+
data: Type.Union([
|
|
20
|
+
Type.Object({
|
|
21
|
+
organization: Type.Object({
|
|
22
|
+
variables: Type.Array(Type.Object({
|
|
23
|
+
key: Type.String(),
|
|
24
|
+
value: Type.String(),
|
|
25
|
+
})),
|
|
26
|
+
}),
|
|
27
|
+
}),
|
|
28
|
+
Type.Null(),
|
|
29
|
+
]),
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* List variables
|
|
33
|
+
*/
|
|
34
|
+
export class VariableListCommand extends GraphQlCommand {
|
|
35
|
+
constructor() {
|
|
36
|
+
super(...arguments);
|
|
37
|
+
/**
|
|
38
|
+
* The allowed modes for the command
|
|
39
|
+
*/
|
|
40
|
+
Object.defineProperty(this, "allowedModes", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: ["bearer"]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parse the response
|
|
49
|
+
*/
|
|
50
|
+
parseResponse(rawResponse) {
|
|
51
|
+
const response = parseResponseHelper(responseSchema, rawResponse);
|
|
52
|
+
if (response.errors) {
|
|
53
|
+
throw new CommandError(this.constructor.name, response.errors[0].message);
|
|
54
|
+
}
|
|
55
|
+
if (!response.data) {
|
|
56
|
+
throw new CommandError(this.constructor.name, "Failed to list variables");
|
|
57
|
+
}
|
|
58
|
+
return response.data.organization.variables;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the body for the request
|
|
62
|
+
*/
|
|
63
|
+
getBody() {
|
|
64
|
+
return JSON.stringify({
|
|
65
|
+
query: graphQlQueryById,
|
|
66
|
+
variables: this.input,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -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,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract command for executing requests
|
|
3
|
+
*/
|
|
4
|
+
export class Command {
|
|
5
|
+
constructor(input) {
|
|
6
|
+
/**
|
|
7
|
+
* The allowed modes for the command
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(this, "allowedModes", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: ["apiKey", "bearer"]
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* The input for the command
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(this, "input", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: void 0
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* The input for the command
|
|
26
|
+
*/
|
|
27
|
+
this.input = input;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the method for the request
|
|
31
|
+
*/
|
|
32
|
+
getMethod() {
|
|
33
|
+
return "POST";
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get the path for the request
|
|
37
|
+
*/
|
|
38
|
+
getPath() {
|
|
39
|
+
return "/";
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the body for the request
|
|
43
|
+
*/
|
|
44
|
+
getBody() {
|
|
45
|
+
if (this.getMethod() === "GET") {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
return this.input ? JSON.stringify(this.input) : undefined;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get the headers for the request
|
|
52
|
+
*/
|
|
53
|
+
getHeaders() {
|
|
54
|
+
return this.getBody()
|
|
55
|
+
? {
|
|
56
|
+
"Content-Type": "application/json",
|
|
57
|
+
}
|
|
58
|
+
: {};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the request object
|
|
62
|
+
*/
|
|
63
|
+
// deno-lint-ignore require-await
|
|
64
|
+
async getRequest(_client) {
|
|
65
|
+
return {
|
|
66
|
+
allowedModes: this.allowedModes,
|
|
67
|
+
body: this.getBody(),
|
|
68
|
+
headers: this.getHeaders(),
|
|
69
|
+
baseUrl: this.getBaseUrl(),
|
|
70
|
+
path: this.getPath(),
|
|
71
|
+
method: this.getMethod(),
|
|
72
|
+
parseResponse: this.parseResponse.bind(this),
|
|
73
|
+
waitForResponse: this.waitForResponse.bind(this),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Wait for the response
|
|
78
|
+
*/
|
|
79
|
+
// deno-lint-ignore require-await
|
|
80
|
+
async waitForResponse(_client, response) {
|
|
81
|
+
return response;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Abstract command for executing GraphQL requests
|
|
86
|
+
*/
|
|
87
|
+
export class GraphQlCommand extends Command {
|
|
88
|
+
getBaseUrl() {
|
|
89
|
+
return "https://graph.api.flowcore.io/graphql";
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -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"}
|