@flowcore/sdk 1.11.8 → 1.11.9
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/CHANGELOG.md +7 -0
- package/esm/commands/tenant/tenant.list.d.ts +1 -1
- package/esm/commands/tenant/tenant.list.d.ts.map +1 -1
- package/esm/commands/tenant/tenant.list.js +21 -7
- package/package.json +1 -1
- package/script/commands/tenant/tenant.list.d.ts +1 -1
- package/script/commands/tenant/tenant.list.d.ts.map +1 -1
- package/script/commands/tenant/tenant.list.js +21 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.11.9](https://github.com/flowcore-io/flowcore-sdk/compare/v1.11.8...v1.11.9) (2025-02-14)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* handle error response in tenant list ([0cbf9f5](https://github.com/flowcore-io/flowcore-sdk/commit/0cbf9f5c8d526c1d1ebe2d22624f02c603115130))
|
|
9
|
+
|
|
3
10
|
## [1.11.8](https://github.com/flowcore-io/flowcore-sdk/compare/v1.11.7...v1.11.8) (2025-02-13)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -3,7 +3,7 @@ import { type TenantWithLinkType } from "../../contracts/tenant.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* List tenants
|
|
5
5
|
*/
|
|
6
|
-
export declare class TenantListCommand extends GraphQlCommand<
|
|
6
|
+
export declare class TenantListCommand extends GraphQlCommand<void, TenantWithLinkType[]> {
|
|
7
7
|
/**
|
|
8
8
|
* The allowed modes for the command
|
|
9
9
|
*/
|
|
@@ -1 +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;
|
|
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;AAyCrG;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC/E;;OAEG;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,kBAAkB,EAAE;IAa5E;;OAEG;cACgB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAKtD"}
|
|
@@ -2,6 +2,7 @@ import { Type } from "@sinclair/typebox";
|
|
|
2
2
|
import { GraphQlCommand } from "../../common/command.js";
|
|
3
3
|
import { TenantV0Schema, tenantV0ToTenant } from "../../contracts/tenant.js";
|
|
4
4
|
import { parseResponseHelper } from "../../utils/parse-response-helper.js";
|
|
5
|
+
import { CommandError } from "../../exceptions/command-error.js";
|
|
5
6
|
const graphQlQueryById = `
|
|
6
7
|
query FLOWCORE_SDK_TENANT_LIST {
|
|
7
8
|
me {
|
|
@@ -19,14 +20,21 @@ const graphQlQueryById = `
|
|
|
19
20
|
}
|
|
20
21
|
`;
|
|
21
22
|
const responseSchema = Type.Object({
|
|
22
|
-
data: Type.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
data: Type.Union([
|
|
24
|
+
Type.Object({
|
|
25
|
+
me: Type.Object({
|
|
26
|
+
organizations: Type.Array(Type.Object({
|
|
27
|
+
linkType: Type.Union([Type.Literal("OWNER"), Type.Literal("COLLABORATOR")]),
|
|
28
|
+
organization: TenantV0Schema,
|
|
29
|
+
})),
|
|
30
|
+
}),
|
|
28
31
|
}),
|
|
29
|
-
|
|
32
|
+
Type.Null(),
|
|
33
|
+
]),
|
|
34
|
+
errors: Type.Optional(Type.Array(Type.Object({
|
|
35
|
+
message: Type.String(),
|
|
36
|
+
path: Type.Optional(Type.Array(Type.String())),
|
|
37
|
+
}))),
|
|
30
38
|
});
|
|
31
39
|
/**
|
|
32
40
|
* List tenants
|
|
@@ -49,6 +57,12 @@ export class TenantListCommand extends GraphQlCommand {
|
|
|
49
57
|
*/
|
|
50
58
|
parseResponse(rawResponse) {
|
|
51
59
|
const response = parseResponseHelper(responseSchema, rawResponse);
|
|
60
|
+
if (response.errors?.length) {
|
|
61
|
+
throw new CommandError(this.constructor.name, response.errors.map((error) => error.message).join("; "));
|
|
62
|
+
}
|
|
63
|
+
else if (!response.data) {
|
|
64
|
+
throw new CommandError(this.constructor.name, "No data returned from the command");
|
|
65
|
+
}
|
|
52
66
|
return response.data.me.organizations.flatMap((organization) => ({
|
|
53
67
|
...tenantV0ToTenant(organization.organization),
|
|
54
68
|
linkType: organization.linkType,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { type TenantWithLinkType } from "../../contracts/tenant.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* List tenants
|
|
5
5
|
*/
|
|
6
|
-
export declare class TenantListCommand extends GraphQlCommand<
|
|
6
|
+
export declare class TenantListCommand extends GraphQlCommand<void, TenantWithLinkType[]> {
|
|
7
7
|
/**
|
|
8
8
|
* The allowed modes for the command
|
|
9
9
|
*/
|
|
@@ -1 +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;
|
|
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;AAyCrG;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC/E;;OAEG;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,kBAAkB,EAAE;IAa5E;;OAEG;cACgB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAKtD"}
|
|
@@ -5,6 +5,7 @@ const typebox_1 = require("@sinclair/typebox");
|
|
|
5
5
|
const command_js_1 = require("../../common/command.js");
|
|
6
6
|
const tenant_js_1 = require("../../contracts/tenant.js");
|
|
7
7
|
const parse_response_helper_js_1 = require("../../utils/parse-response-helper.js");
|
|
8
|
+
const command_error_js_1 = require("../../exceptions/command-error.js");
|
|
8
9
|
const graphQlQueryById = `
|
|
9
10
|
query FLOWCORE_SDK_TENANT_LIST {
|
|
10
11
|
me {
|
|
@@ -22,14 +23,21 @@ const graphQlQueryById = `
|
|
|
22
23
|
}
|
|
23
24
|
`;
|
|
24
25
|
const responseSchema = typebox_1.Type.Object({
|
|
25
|
-
data: typebox_1.Type.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
data: typebox_1.Type.Union([
|
|
27
|
+
typebox_1.Type.Object({
|
|
28
|
+
me: typebox_1.Type.Object({
|
|
29
|
+
organizations: typebox_1.Type.Array(typebox_1.Type.Object({
|
|
30
|
+
linkType: typebox_1.Type.Union([typebox_1.Type.Literal("OWNER"), typebox_1.Type.Literal("COLLABORATOR")]),
|
|
31
|
+
organization: tenant_js_1.TenantV0Schema,
|
|
32
|
+
})),
|
|
33
|
+
}),
|
|
31
34
|
}),
|
|
32
|
-
|
|
35
|
+
typebox_1.Type.Null(),
|
|
36
|
+
]),
|
|
37
|
+
errors: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.Object({
|
|
38
|
+
message: typebox_1.Type.String(),
|
|
39
|
+
path: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.String())),
|
|
40
|
+
}))),
|
|
33
41
|
});
|
|
34
42
|
/**
|
|
35
43
|
* List tenants
|
|
@@ -52,6 +60,12 @@ class TenantListCommand extends command_js_1.GraphQlCommand {
|
|
|
52
60
|
*/
|
|
53
61
|
parseResponse(rawResponse) {
|
|
54
62
|
const response = (0, parse_response_helper_js_1.parseResponseHelper)(responseSchema, rawResponse);
|
|
63
|
+
if (response.errors?.length) {
|
|
64
|
+
throw new command_error_js_1.CommandError(this.constructor.name, response.errors.map((error) => error.message).join("; "));
|
|
65
|
+
}
|
|
66
|
+
else if (!response.data) {
|
|
67
|
+
throw new command_error_js_1.CommandError(this.constructor.name, "No data returned from the command");
|
|
68
|
+
}
|
|
55
69
|
return response.data.me.organizations.flatMap((organization) => ({
|
|
56
70
|
...(0, tenant_js_1.tenantV0ToTenant)(organization.organization),
|
|
57
71
|
linkType: organization.linkType,
|