@flowcore/sdk 1.55.0 → 1.55.1

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.55.1](https://github.com/flowcore-io/flowcore-sdk/compare/v1.55.0...v1.55.1) (2025-07-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * revert to tenant list graphql ([3245bb9](https://github.com/flowcore-io/flowcore-sdk/commit/3245bb93d198801ad16f09e2fc9115513534777b))
9
+
3
10
  ## [1.55.0](https://github.com/flowcore-io/flowcore-sdk/compare/v1.54.0...v1.55.0) (2025-07-17)
4
11
 
5
12
 
@@ -1,24 +1,28 @@
1
- import { Command } from "../../common/command.js";
2
- import { type TenantListItem } from "../../contracts/tenant.js";
1
+ import { GraphQlCommand } from "../../common/command-graphql.js";
2
+ interface TenantListItem {
3
+ id: string;
4
+ name: string;
5
+ displayName: string;
6
+ description: string;
7
+ websiteUrl: string;
8
+ linkType: "OWNER" | "COLLABORATOR";
9
+ }
3
10
  /**
4
11
  * List tenants
5
12
  */
6
- export declare class TenantListCommand extends Command<Record<string, never>, TenantListItem[]> {
7
- /**
8
- * Get the method
9
- */
10
- protected getMethod(): string;
13
+ export declare class TenantListCommand extends GraphQlCommand<void, TenantListItem[]> {
11
14
  /**
12
- * Get the base url
15
+ * The allowed modes for the command
13
16
  */
14
- protected getBaseUrl(): string;
15
- /**
16
- * Get the path
17
- */
18
- protected getPath(): string;
17
+ protected allowedModes: ("apiKey" | "bearer")[];
19
18
  /**
20
19
  * Parse the response
21
20
  */
22
21
  protected parseResponse(rawResponse: unknown): TenantListItem[];
22
+ /**
23
+ * Get the body for the request
24
+ */
25
+ protected getBody(): Record<string, unknown>;
23
26
  }
27
+ export {};
24
28
  //# sourceMappingURL=tenant.list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tenant.list.d.ts","sourceRoot":"","sources":["../../../src/commands/tenant/tenant.list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,2BAA2B,CAAA;AAGrF;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACrF;;OAEG;cACgB,SAAS,IAAI,MAAM;IAItC;;OAEG;cACgB,UAAU,IAAI,MAAM;IAIvC;;OAEG;cACgB,OAAO,IAAI,MAAM;IAIpC;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,cAAc,EAAE;CAIzE"}
1
+ {"version":3,"file":"tenant.list.d.ts","sourceRoot":"","sources":["../../../src/commands/tenant/tenant.list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAIhE,UAAU,cAAc;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,OAAO,GAAG,cAAc,CAAA;CACnC;AA6CD;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE,CAAC;IAC3E;;OAEG;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,cAAc,EAAE;IAiBxE;;OAEG;cACgB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAKtD"}
@@ -1,34 +1,80 @@
1
1
  import { Type } from "@sinclair/typebox";
2
- import { Command } from "../../common/command.js";
3
- import { TenantListItemSchema } from "../../contracts/tenant.js";
2
+ import { GraphQlCommand } from "../../common/command-graphql.js";
4
3
  import { parseResponseHelper } from "../../utils/parse-response-helper.js";
4
+ import { CommandError } from "../../exceptions/command-error.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.Union([
23
+ Type.Object({
24
+ me: Type.Object({
25
+ organizations: Type.Array(Type.Object({
26
+ linkType: Type.Union([Type.Literal("OWNER"), Type.Literal("COLLABORATOR")]),
27
+ organization: Type.Object({
28
+ id: Type.String(),
29
+ org: Type.String(),
30
+ displayName: Type.String(),
31
+ description: Type.String(),
32
+ website: Type.String(),
33
+ }),
34
+ })),
35
+ }),
36
+ }),
37
+ Type.Null(),
38
+ ]),
39
+ errors: Type.Optional(Type.Array(Type.Object({
40
+ message: Type.String(),
41
+ path: Type.Optional(Type.Array(Type.String())),
42
+ }))),
43
+ });
5
44
  /**
6
45
  * List tenants
7
46
  */
8
- export class TenantListCommand extends Command {
47
+ export class TenantListCommand extends GraphQlCommand {
9
48
  /**
10
- * Get the method
49
+ * The allowed modes for the command
11
50
  */
12
- getMethod() {
13
- return "GET";
14
- }
15
- /**
16
- * Get the base url
17
- */
18
- getBaseUrl() {
19
- return "https://tenant.api.flowcore.io";
20
- }
51
+ allowedModes = ["bearer"];
21
52
  /**
22
- * Get the path
53
+ * Parse the response
23
54
  */
24
- getPath() {
25
- return `/api/v1/tenants/list`;
55
+ parseResponse(rawResponse) {
56
+ const response = parseResponseHelper(responseSchema, rawResponse);
57
+ if (response.errors?.length) {
58
+ throw new CommandError(this.constructor.name, response.errors.map((error) => error.message).join("; "));
59
+ }
60
+ else if (!response.data) {
61
+ throw new CommandError(this.constructor.name, "No data returned from the command");
62
+ }
63
+ return response.data.me.organizations.flatMap((organization) => ({
64
+ id: organization.organization.id,
65
+ name: organization.organization.org,
66
+ displayName: organization.organization.displayName,
67
+ description: organization.organization.description,
68
+ websiteUrl: organization.organization.website,
69
+ linkType: organization.linkType,
70
+ }));
26
71
  }
27
72
  /**
28
- * Parse the response
73
+ * Get the body for the request
29
74
  */
30
- parseResponse(rawResponse) {
31
- const response = parseResponseHelper(Type.Array(TenantListItemSchema), rawResponse);
32
- return response;
75
+ getBody() {
76
+ return {
77
+ query: graphQlQueryById,
78
+ };
33
79
  }
34
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowcore/sdk",
3
- "version": "1.55.0",
3
+ "version": "1.55.1",
4
4
  "description": "Flowcore SDK",
5
5
  "homepage": "https://github.com/flowcore-io/flowcore-sdk#readme",
6
6
  "repository": {
@@ -1,24 +1,28 @@
1
- import { Command } from "../../common/command.js";
2
- import { type TenantListItem } from "../../contracts/tenant.js";
1
+ import { GraphQlCommand } from "../../common/command-graphql.js";
2
+ interface TenantListItem {
3
+ id: string;
4
+ name: string;
5
+ displayName: string;
6
+ description: string;
7
+ websiteUrl: string;
8
+ linkType: "OWNER" | "COLLABORATOR";
9
+ }
3
10
  /**
4
11
  * List tenants
5
12
  */
6
- export declare class TenantListCommand extends Command<Record<string, never>, TenantListItem[]> {
7
- /**
8
- * Get the method
9
- */
10
- protected getMethod(): string;
13
+ export declare class TenantListCommand extends GraphQlCommand<void, TenantListItem[]> {
11
14
  /**
12
- * Get the base url
15
+ * The allowed modes for the command
13
16
  */
14
- protected getBaseUrl(): string;
15
- /**
16
- * Get the path
17
- */
18
- protected getPath(): string;
17
+ protected allowedModes: ("apiKey" | "bearer")[];
19
18
  /**
20
19
  * Parse the response
21
20
  */
22
21
  protected parseResponse(rawResponse: unknown): TenantListItem[];
22
+ /**
23
+ * Get the body for the request
24
+ */
25
+ protected getBody(): Record<string, unknown>;
23
26
  }
27
+ export {};
24
28
  //# sourceMappingURL=tenant.list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tenant.list.d.ts","sourceRoot":"","sources":["../../../src/commands/tenant/tenant.list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,2BAA2B,CAAA;AAGrF;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACrF;;OAEG;cACgB,SAAS,IAAI,MAAM;IAItC;;OAEG;cACgB,UAAU,IAAI,MAAM;IAIvC;;OAEG;cACgB,OAAO,IAAI,MAAM;IAIpC;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,cAAc,EAAE;CAIzE"}
1
+ {"version":3,"file":"tenant.list.d.ts","sourceRoot":"","sources":["../../../src/commands/tenant/tenant.list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAIhE,UAAU,cAAc;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,OAAO,GAAG,cAAc,CAAA;CACnC;AA6CD;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE,CAAC;IAC3E;;OAEG;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,cAAc,EAAE;IAiBxE;;OAEG;cACgB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAKtD"}
@@ -2,37 +2,83 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TenantListCommand = void 0;
4
4
  const typebox_1 = require("@sinclair/typebox");
5
- const command_js_1 = require("../../common/command.js");
6
- const tenant_js_1 = require("../../contracts/tenant.js");
5
+ const command_graphql_js_1 = require("../../common/command-graphql.js");
7
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_TENANT_LIST {
10
+ me {
11
+ organizations {
12
+ linkType
13
+ organization {
14
+ id
15
+ org
16
+ displayName
17
+ description
18
+ website
19
+ }
20
+ }
21
+ }
22
+ }
23
+ `;
24
+ const responseSchema = typebox_1.Type.Object({
25
+ data: typebox_1.Type.Union([
26
+ typebox_1.Type.Object({
27
+ me: typebox_1.Type.Object({
28
+ organizations: typebox_1.Type.Array(typebox_1.Type.Object({
29
+ linkType: typebox_1.Type.Union([typebox_1.Type.Literal("OWNER"), typebox_1.Type.Literal("COLLABORATOR")]),
30
+ organization: typebox_1.Type.Object({
31
+ id: typebox_1.Type.String(),
32
+ org: typebox_1.Type.String(),
33
+ displayName: typebox_1.Type.String(),
34
+ description: typebox_1.Type.String(),
35
+ website: typebox_1.Type.String(),
36
+ }),
37
+ })),
38
+ }),
39
+ }),
40
+ typebox_1.Type.Null(),
41
+ ]),
42
+ errors: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.Object({
43
+ message: typebox_1.Type.String(),
44
+ path: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.String())),
45
+ }))),
46
+ });
8
47
  /**
9
48
  * List tenants
10
49
  */
11
- class TenantListCommand extends command_js_1.Command {
50
+ class TenantListCommand extends command_graphql_js_1.GraphQlCommand {
12
51
  /**
13
- * Get the method
52
+ * The allowed modes for the command
14
53
  */
15
- getMethod() {
16
- return "GET";
17
- }
18
- /**
19
- * Get the base url
20
- */
21
- getBaseUrl() {
22
- return "https://tenant.api.flowcore.io";
23
- }
54
+ allowedModes = ["bearer"];
24
55
  /**
25
- * Get the path
56
+ * Parse the response
26
57
  */
27
- getPath() {
28
- return `/api/v1/tenants/list`;
58
+ parseResponse(rawResponse) {
59
+ const response = (0, parse_response_helper_js_1.parseResponseHelper)(responseSchema, rawResponse);
60
+ if (response.errors?.length) {
61
+ throw new command_error_js_1.CommandError(this.constructor.name, response.errors.map((error) => error.message).join("; "));
62
+ }
63
+ else if (!response.data) {
64
+ throw new command_error_js_1.CommandError(this.constructor.name, "No data returned from the command");
65
+ }
66
+ return response.data.me.organizations.flatMap((organization) => ({
67
+ id: organization.organization.id,
68
+ name: organization.organization.org,
69
+ displayName: organization.organization.displayName,
70
+ description: organization.organization.description,
71
+ websiteUrl: organization.organization.website,
72
+ linkType: organization.linkType,
73
+ }));
29
74
  }
30
75
  /**
31
- * Parse the response
76
+ * Get the body for the request
32
77
  */
33
- parseResponse(rawResponse) {
34
- const response = (0, parse_response_helper_js_1.parseResponseHelper)(typebox_1.Type.Array(tenant_js_1.TenantListItemSchema), rawResponse);
35
- return response;
78
+ getBody() {
79
+ return {
80
+ query: graphQlQueryById,
81
+ };
36
82
  }
37
83
  }
38
84
  exports.TenantListCommand = TenantListCommand;