@flowcore/sdk 1.64.3 → 1.65.0

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.65.0](https://github.com/flowcore-io/flowcore-sdk/compare/v1.64.3...v1.65.0) (2026-01-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * update UserInitializeInKeycloakCommand to use new response stru… ([361d377](https://github.com/flowcore-io/flowcore-sdk/commit/361d37741c34ea2207ca9c9dc4431fb389df8ce6))
9
+ * update UserInitializeInKeycloakCommand to use new response structure and API endpoint ([0aa16a4](https://github.com/flowcore-io/flowcore-sdk/commit/0aa16a498c8ed20db881e1d227d5681410a9dfef))
10
+
3
11
  ## [1.64.3](https://github.com/flowcore-io/flowcore-sdk/compare/v1.64.2...v1.64.3) (2025-12-19)
4
12
 
5
13
 
@@ -1,4 +1,5 @@
1
- import { GraphQlCommand } from "../../common/command-graphql.js";
1
+ import { Command } from "../../common/command.js";
2
+ import type { Static, TObject, TString } from "@sinclair/typebox";
2
3
  /**
3
4
  * The input for initializing user in Keycloak
4
5
  * No input parameters needed - checks current authenticated user
@@ -6,19 +7,41 @@ import { GraphQlCommand } from "../../common/command-graphql.js";
6
7
  export type UserInitializeInKeycloakInput = Record<PropertyKey, never>;
7
8
  /**
8
9
  * The output for initializing user in Keycloak
10
+ * (matches the REST API response)
9
11
  */
10
- export interface UserInitializeInKeycloakOutput {
11
- /** Whether the user is initialized */
12
- isInitialized: boolean;
13
- /** User data if available */
14
- me?: unknown;
15
- }
12
+ export type UserInitializeInKeycloakOutput = Static<typeof responseSchema>;
13
+ declare const responseSchema: TObject<{
14
+ id: TString;
15
+ username: TString;
16
+ email: TString;
17
+ firstName: TString;
18
+ lastName: TString;
19
+ }>;
16
20
  /**
17
- * Initialize user in Keycloak - checks if user exists and is initialized
21
+ * Finalize user initialization by setting Flowcore User ID in Keycloak.
22
+ *
23
+ * Calls `POST /api/users` on the user service with an empty JSON body.
24
+ * Requires a bearer token.
18
25
  */
19
- export declare class UserInitializeInKeycloakCommand extends GraphQlCommand<UserInitializeInKeycloakInput, UserInitializeInKeycloakOutput> {
26
+ export declare class UserInitializeInKeycloakCommand extends Command<UserInitializeInKeycloakInput, UserInitializeInKeycloakOutput> {
27
+ /**
28
+ * The allowed modes for the command
29
+ */
30
+ protected allowedModes: ("apiKey" | "bearer")[];
31
+ /**
32
+ * Get the base URL for the request
33
+ */
34
+ protected getBaseUrl(): string;
35
+ /**
36
+ * Get the method
37
+ */
38
+ protected getMethod(): string;
39
+ /**
40
+ * Get the path for the request
41
+ */
42
+ protected getPath(): string;
20
43
  /**
21
- * Get the body for the request
44
+ * Get the body for the request (must be an empty JSON object)
22
45
  */
23
46
  protected getBody(): Record<string, unknown>;
24
47
  /**
@@ -26,4 +49,5 @@ export declare class UserInitializeInKeycloakCommand extends GraphQlCommand<User
26
49
  */
27
50
  protected parseResponse(rawResponse: unknown): UserInitializeInKeycloakOutput;
28
51
  }
52
+ export {};
29
53
  //# sourceMappingURL=user.initialize-in-keycloak.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.initialize-in-keycloak.d.ts","sourceRoot":"","sources":["../../../src/commands/user/user.initialize-in-keycloak.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAGhE;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;AAEtE;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,sCAAsC;IACtC,aAAa,EAAE,OAAO,CAAA;IACtB,6BAA6B;IAC7B,EAAE,CAAC,EAAE,OAAO,CAAA;CACb;AAUD;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,cAAc,CACjE,6BAA6B,EAC7B,8BAA8B,CAC/B;IACC;;OAEG;cACgB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAOrD;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,8BAA8B;CAyBvF"}
1
+ {"version":3,"file":"user.initialize-in-keycloak.d.ts","sourceRoot":"","sources":["../../../src/commands/user/user.initialize-in-keycloak.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEjD,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEjE;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;AAEtE;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAA;AAE1E,QAAA,MAAM,cAAc,EAAE,OAAO,CAAC;IAC5B,EAAE,EAAE,OAAO,CAAA;IACX,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,OAAO,CAAA;IACd,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAMC,CAAA;AAEF;;;;;GAKG;AACH,qBAAa,+BAAgC,SAAQ,OAAO,CAC1D,6BAA6B,EAC7B,8BAA8B,CAC/B;IACC;;OAEG;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,UAAU,IAAI,MAAM;IAIvC;;OAEG;cACgB,SAAS,IAAI,MAAM;IAItC;;OAEG;cACgB,OAAO,IAAI,MAAM;IAIpC;;OAEG;cACgB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAMrD;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,8BAA8B;CAIvF"}
@@ -1,38 +1,55 @@
1
- import { GraphQlCommand } from "../../common/command-graphql.js";
2
- import { InvalidResponseException } from "../../exceptions/invalid-response.js";
3
- const QUERY = `
4
- query UserIsInitializedIfDoesNotExist {
5
- me {
6
- id
7
- }
8
- }
9
- `;
1
+ import { Type } from "@sinclair/typebox";
2
+ import { Command } from "../../common/command.js";
3
+ import { parseResponseHelper } from "../../utils/parse-response-helper.js";
4
+ const responseSchema = Type.Object({
5
+ id: Type.String(),
6
+ username: Type.String(),
7
+ email: Type.String(),
8
+ firstName: Type.String(),
9
+ lastName: Type.String(),
10
+ });
10
11
  /**
11
- * Initialize user in Keycloak - checks if user exists and is initialized
12
+ * Finalize user initialization by setting Flowcore User ID in Keycloak.
13
+ *
14
+ * Calls `POST /api/users` on the user service with an empty JSON body.
15
+ * Requires a bearer token.
12
16
  */
13
- export class UserInitializeInKeycloakCommand extends GraphQlCommand {
17
+ export class UserInitializeInKeycloakCommand extends Command {
18
+ /**
19
+ * The allowed modes for the command
20
+ */
21
+ allowedModes = ["bearer"];
22
+ /**
23
+ * Get the base URL for the request
24
+ */
25
+ getBaseUrl() {
26
+ return "https://user-2.api.flowcore.io";
27
+ }
28
+ /**
29
+ * Get the method
30
+ */
31
+ getMethod() {
32
+ return "POST";
33
+ }
14
34
  /**
15
- * Get the body for the request
35
+ * Get the path for the request
36
+ */
37
+ getPath() {
38
+ return "/api/users";
39
+ }
40
+ /**
41
+ * Get the body for the request (must be an empty JSON object)
16
42
  */
17
43
  getBody() {
18
44
  return {
19
- query: QUERY,
20
- variables: {},
45
+ // intentionally empty
21
46
  };
22
47
  }
23
48
  /**
24
49
  * Parse the response
25
50
  */
26
51
  parseResponse(rawResponse) {
27
- const response = rawResponse;
28
- if (response.errors && response.errors.length > 0) {
29
- throw new InvalidResponseException(response.errors.map((e) => e.message).join(", "), { graphql: response.errors.map((e) => e.message).join(", ") });
30
- }
31
- // If me exists and is not null i.e. flowcore_user_id is not null, user is initialized
32
- const isInitialized = response.data?.me !== null && response.data?.me !== undefined;
33
- return {
34
- isInitialized,
35
- me: response.data?.me,
36
- };
52
+ const response = parseResponseHelper(responseSchema, rawResponse);
53
+ return response;
37
54
  }
38
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowcore/sdk",
3
- "version": "1.64.3",
3
+ "version": "1.65.0",
4
4
  "description": "Flowcore SDK",
5
5
  "homepage": "https://github.com/flowcore-io/flowcore-sdk#readme",
6
6
  "repository": {
@@ -1,4 +1,5 @@
1
- import { GraphQlCommand } from "../../common/command-graphql.js";
1
+ import { Command } from "../../common/command.js";
2
+ import type { Static, TObject, TString } from "@sinclair/typebox";
2
3
  /**
3
4
  * The input for initializing user in Keycloak
4
5
  * No input parameters needed - checks current authenticated user
@@ -6,19 +7,41 @@ import { GraphQlCommand } from "../../common/command-graphql.js";
6
7
  export type UserInitializeInKeycloakInput = Record<PropertyKey, never>;
7
8
  /**
8
9
  * The output for initializing user in Keycloak
10
+ * (matches the REST API response)
9
11
  */
10
- export interface UserInitializeInKeycloakOutput {
11
- /** Whether the user is initialized */
12
- isInitialized: boolean;
13
- /** User data if available */
14
- me?: unknown;
15
- }
12
+ export type UserInitializeInKeycloakOutput = Static<typeof responseSchema>;
13
+ declare const responseSchema: TObject<{
14
+ id: TString;
15
+ username: TString;
16
+ email: TString;
17
+ firstName: TString;
18
+ lastName: TString;
19
+ }>;
16
20
  /**
17
- * Initialize user in Keycloak - checks if user exists and is initialized
21
+ * Finalize user initialization by setting Flowcore User ID in Keycloak.
22
+ *
23
+ * Calls `POST /api/users` on the user service with an empty JSON body.
24
+ * Requires a bearer token.
18
25
  */
19
- export declare class UserInitializeInKeycloakCommand extends GraphQlCommand<UserInitializeInKeycloakInput, UserInitializeInKeycloakOutput> {
26
+ export declare class UserInitializeInKeycloakCommand extends Command<UserInitializeInKeycloakInput, UserInitializeInKeycloakOutput> {
27
+ /**
28
+ * The allowed modes for the command
29
+ */
30
+ protected allowedModes: ("apiKey" | "bearer")[];
31
+ /**
32
+ * Get the base URL for the request
33
+ */
34
+ protected getBaseUrl(): string;
35
+ /**
36
+ * Get the method
37
+ */
38
+ protected getMethod(): string;
39
+ /**
40
+ * Get the path for the request
41
+ */
42
+ protected getPath(): string;
20
43
  /**
21
- * Get the body for the request
44
+ * Get the body for the request (must be an empty JSON object)
22
45
  */
23
46
  protected getBody(): Record<string, unknown>;
24
47
  /**
@@ -26,4 +49,5 @@ export declare class UserInitializeInKeycloakCommand extends GraphQlCommand<User
26
49
  */
27
50
  protected parseResponse(rawResponse: unknown): UserInitializeInKeycloakOutput;
28
51
  }
52
+ export {};
29
53
  //# sourceMappingURL=user.initialize-in-keycloak.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.initialize-in-keycloak.d.ts","sourceRoot":"","sources":["../../../src/commands/user/user.initialize-in-keycloak.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAGhE;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;AAEtE;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,sCAAsC;IACtC,aAAa,EAAE,OAAO,CAAA;IACtB,6BAA6B;IAC7B,EAAE,CAAC,EAAE,OAAO,CAAA;CACb;AAUD;;GAEG;AACH,qBAAa,+BAAgC,SAAQ,cAAc,CACjE,6BAA6B,EAC7B,8BAA8B,CAC/B;IACC;;OAEG;cACgB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAOrD;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,8BAA8B;CAyBvF"}
1
+ {"version":3,"file":"user.initialize-in-keycloak.d.ts","sourceRoot":"","sources":["../../../src/commands/user/user.initialize-in-keycloak.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEjD,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAEjE;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;AAEtE;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAA;AAE1E,QAAA,MAAM,cAAc,EAAE,OAAO,CAAC;IAC5B,EAAE,EAAE,OAAO,CAAA;IACX,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,OAAO,CAAA;IACd,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAMC,CAAA;AAEF;;;;;GAKG;AACH,qBAAa,+BAAgC,SAAQ,OAAO,CAC1D,6BAA6B,EAC7B,8BAA8B,CAC/B;IACC;;OAEG;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,UAAU,IAAI,MAAM;IAIvC;;OAEG;cACgB,SAAS,IAAI,MAAM;IAItC;;OAEG;cACgB,OAAO,IAAI,MAAM;IAIpC;;OAEG;cACgB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAMrD;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,8BAA8B;CAIvF"}
@@ -1,42 +1,59 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserInitializeInKeycloakCommand = void 0;
4
- const command_graphql_js_1 = require("../../common/command-graphql.js");
5
- const invalid_response_js_1 = require("../../exceptions/invalid-response.js");
6
- const QUERY = `
7
- query UserIsInitializedIfDoesNotExist {
8
- me {
9
- id
10
- }
11
- }
12
- `;
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 responseSchema = typebox_1.Type.Object({
8
+ id: typebox_1.Type.String(),
9
+ username: typebox_1.Type.String(),
10
+ email: typebox_1.Type.String(),
11
+ firstName: typebox_1.Type.String(),
12
+ lastName: typebox_1.Type.String(),
13
+ });
13
14
  /**
14
- * Initialize user in Keycloak - checks if user exists and is initialized
15
+ * Finalize user initialization by setting Flowcore User ID in Keycloak.
16
+ *
17
+ * Calls `POST /api/users` on the user service with an empty JSON body.
18
+ * Requires a bearer token.
15
19
  */
16
- class UserInitializeInKeycloakCommand extends command_graphql_js_1.GraphQlCommand {
20
+ class UserInitializeInKeycloakCommand extends command_js_1.Command {
21
+ /**
22
+ * The allowed modes for the command
23
+ */
24
+ allowedModes = ["bearer"];
25
+ /**
26
+ * Get the base URL for the request
27
+ */
28
+ getBaseUrl() {
29
+ return "https://user-2.api.flowcore.io";
30
+ }
31
+ /**
32
+ * Get the method
33
+ */
34
+ getMethod() {
35
+ return "POST";
36
+ }
17
37
  /**
18
- * Get the body for the request
38
+ * Get the path for the request
39
+ */
40
+ getPath() {
41
+ return "/api/users";
42
+ }
43
+ /**
44
+ * Get the body for the request (must be an empty JSON object)
19
45
  */
20
46
  getBody() {
21
47
  return {
22
- query: QUERY,
23
- variables: {},
48
+ // intentionally empty
24
49
  };
25
50
  }
26
51
  /**
27
52
  * Parse the response
28
53
  */
29
54
  parseResponse(rawResponse) {
30
- const response = rawResponse;
31
- if (response.errors && response.errors.length > 0) {
32
- throw new invalid_response_js_1.InvalidResponseException(response.errors.map((e) => e.message).join(", "), { graphql: response.errors.map((e) => e.message).join(", ") });
33
- }
34
- // If me exists and is not null i.e. flowcore_user_id is not null, user is initialized
35
- const isInitialized = response.data?.me !== null && response.data?.me !== undefined;
36
- return {
37
- isInitialized,
38
- me: response.data?.me,
39
- };
55
+ const response = (0, parse_response_helper_js_1.parseResponseHelper)(responseSchema, rawResponse);
56
+ return response;
40
57
  }
41
58
  }
42
59
  exports.UserInitializeInKeycloakCommand = UserInitializeInKeycloakCommand;