@flowcore/sdk 1.48.0 → 1.49.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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.49.0](https://github.com/flowcore-io/flowcore-sdk/compare/v1.48.0...v1.49.0) (2025-05-14)
4
+
5
+
6
+ ### Features
7
+
8
+ * **scenario:** :tada: enhance scenario fetch command to support fetching by tenantId and name ([c31bfb8](https://github.com/flowcore-io/flowcore-sdk/commit/c31bfb87fe99b1944886c0436ea94cadffbd2571))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **scenario:** :art: clean up whitespace in scenario fetch and test files ([f8248d6](https://github.com/flowcore-io/flowcore-sdk/commit/f8248d6f9ba91544f0b7088a254153456084c4e4))
14
+
3
15
  ## [1.48.0](https://github.com/flowcore-io/flowcore-sdk/compare/v1.47.1...v1.48.0) (2025-05-14)
4
16
 
5
17
 
@@ -1,12 +1,26 @@
1
1
  import { Command } from "../../common/command.js";
2
2
  import { type Scenario } from "../../contracts/scenario.js";
3
- /**
4
- * The input for the scenario fetch command
5
- */
6
- export interface ScenarioFetchInput {
3
+ import type { ClientError } from "../../exceptions/client-error.js";
4
+ export interface ScenarioFetchByIdInput {
7
5
  /** The scenario id */
8
6
  scenarioId: string;
7
+ /** The tenant id */
8
+ tenantId?: never;
9
+ /** scenario name */
10
+ name?: never;
11
+ }
12
+ export interface ScenarioFetchByNameInput {
13
+ /** The scenario id */
14
+ scenarioId?: never;
15
+ /** The tenant id */
16
+ tenantId: string;
17
+ /** scenario name */
18
+ name: string;
9
19
  }
20
+ /**
21
+ * The input for the scenario fetch command
22
+ */
23
+ export type ScenarioFetchInput = ScenarioFetchByIdInput | ScenarioFetchByNameInput;
10
24
  /**
11
25
  * fetch a scenario
12
26
  */
@@ -31,5 +45,9 @@ export declare class ScenarioFetchCommand extends Command<ScenarioFetchInput, Sc
31
45
  * Parse the response
32
46
  */
33
47
  protected parseResponse(rawResponse: unknown): Scenario;
48
+ /**
49
+ * Handle the client error
50
+ */
51
+ protected handleClientError(error: ClientError): void;
34
52
  }
35
53
  //# sourceMappingURL=scenario.fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scenario.fetch.d.ts","sourceRoot":"","sources":["../../../src/commands/scenario/scenario.fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,6BAA6B,CAAA;AAG3E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,OAAO,CAAC,kBAAkB,EAAE,QAAQ,CAAC;IAC7E;;OAEG;IACH,UAAmB,cAAc,EAAE,OAAO,CAAQ;IAElD;;OAEG;cACgB,SAAS,IAAI,MAAM;IAGtC;;OAEG;cACgB,UAAU,IAAI,MAAM;IAIvC;;OAEG;cACgB,OAAO,IAAI,MAAM;IAIpC;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ;CAGjE"}
1
+ {"version":3,"file":"scenario.fetch.d.ts","sourceRoot":"","sources":["../../../src/commands/scenario/scenario.fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,6BAA6B,CAAA;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAInE,MAAM,WAAW,sBAAsB;IACrC,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,oBAAoB;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,oBAAoB;IACpB,IAAI,CAAC,EAAE,KAAK,CAAA;CACb;AAED,MAAM,WAAW,wBAAwB;IACvC,sBAAsB;IACtB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAA;CACb;AAUD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG,wBAAwB,CAAA;AAElF;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,OAAO,CAAC,kBAAkB,EAAE,QAAQ,CAAC;IAC7E;;OAEG;IACH,UAAmB,cAAc,EAAE,OAAO,CAAQ;IAElD;;OAEG;cACgB,SAAS,IAAI,MAAM;IAGtC;;OAEG;cACgB,UAAU,IAAI,MAAM;IAIvC;;OAEG;cACgB,OAAO,IAAI,MAAM;IAOpC;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ;IAIhE;;OAEG;cACgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;CAU/D"}
@@ -1,6 +1,13 @@
1
1
  import { Command } from "../../common/command.js";
2
2
  import { ScenarioSchema } from "../../contracts/scenario.js";
3
+ import { NotFoundException } from "../../exceptions/not-found.js";
3
4
  import { parseResponseHelper } from "../../utils/parse-response-helper.js";
5
+ function isScenarioFetchByIdInput(input) {
6
+ return "scenarioId" in input;
7
+ }
8
+ function isScenarioFetchByNameAndTenantInput(input) {
9
+ return "tenantId" in input;
10
+ }
4
11
  /**
5
12
  * fetch a scenario
6
13
  */
@@ -33,7 +40,10 @@ export class ScenarioFetchCommand extends Command {
33
40
  * Get the path
34
41
  */
35
42
  getPath() {
36
- return `/api/v1/scenarios/${this.input.scenarioId}`;
43
+ if (this.input.scenarioId) {
44
+ return `/api/v1/scenarios/${this.input.scenarioId}`;
45
+ }
46
+ return `/api/v1/scenarios/tenant/${this.input.tenantId}/name/${this.input.name}`;
37
47
  }
38
48
  /**
39
49
  * Parse the response
@@ -41,4 +51,18 @@ export class ScenarioFetchCommand extends Command {
41
51
  parseResponse(rawResponse) {
42
52
  return parseResponseHelper(ScenarioSchema, rawResponse);
43
53
  }
54
+ /**
55
+ * Handle the client error
56
+ */
57
+ handleClientError(error) {
58
+ if (error.status === 404) {
59
+ if (isScenarioFetchByIdInput(this.input)) {
60
+ throw new NotFoundException("Scenario", { id: this.input.scenarioId });
61
+ }
62
+ else if (isScenarioFetchByNameAndTenantInput(this.input)) {
63
+ throw new NotFoundException("Scenario", { name: this.input.name, tenantId: this.input.tenantId });
64
+ }
65
+ }
66
+ throw error;
67
+ }
44
68
  }
@@ -4,8 +4,6 @@ import { type Scenario } from "../../contracts/scenario.js";
4
4
  * The input for the scenario update command
5
5
  */
6
6
  export interface ScenarioUpdateInput {
7
- /** The tenant id */
8
- tenantId: string;
9
7
  /** The scenario id */
10
8
  scenarioId: string;
11
9
  /** The description of the scenario */
@@ -29,6 +27,10 @@ export declare class ScenarioUpdateCommand extends Command<ScenarioUpdateInput,
29
27
  * Get the base url
30
28
  */
31
29
  protected getBaseUrl(): string;
30
+ /**
31
+ * Get the body
32
+ */
33
+ protected getBody(): Record<string, unknown> | Array<unknown> | undefined;
32
34
  /**
33
35
  * Get the path
34
36
  */
@@ -1 +1 @@
1
- {"version":3,"file":"scenario.update.d.ts","sourceRoot":"","sources":["../../../src/commands/scenario/scenario.update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,6BAA6B,CAAA;AAG3E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,OAAO,CAAC,mBAAmB,EAAE,QAAQ,CAAC;IAC/E;;OAEG;IACH,UAAmB,cAAc,EAAE,OAAO,CAAQ;IAElD;;OAEG;cACgB,SAAS,IAAI,MAAM;IAGtC;;OAEG;cACgB,UAAU,IAAI,MAAM;IAIvC;;OAEG;cACgB,OAAO,IAAI,MAAM;IAIpC;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ;CAGjE"}
1
+ {"version":3,"file":"scenario.update.d.ts","sourceRoot":"","sources":["../../../src/commands/scenario/scenario.update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,6BAA6B,CAAA;AAG3E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,OAAO,CAAC,mBAAmB,EAAE,QAAQ,CAAC;IAC/E;;OAEG;IACH,UAAmB,cAAc,EAAE,OAAO,CAAQ;IAElD;;OAEG;cACgB,SAAS,IAAI,MAAM;IAGtC;;OAEG;cACgB,UAAU,IAAI,MAAM;IAIvC;;OAEG;cACgB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,SAAS;IAOlF;;OAEG;cACgB,OAAO,IAAI,MAAM;IAIpC;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ;CAGjE"}
@@ -29,6 +29,15 @@ export class ScenarioUpdateCommand extends Command {
29
29
  getBaseUrl() {
30
30
  return "https://scenario-2.api.flowcore.io";
31
31
  }
32
+ /**
33
+ * Get the body
34
+ */
35
+ getBody() {
36
+ return {
37
+ ...(this.input.description && { description: this.input.description }),
38
+ ...(this.input.displayName && { displayName: this.input.displayName }),
39
+ };
40
+ }
32
41
  /**
33
42
  * Get the path
34
43
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowcore/sdk",
3
- "version": "1.48.0",
3
+ "version": "1.49.0",
4
4
  "description": "Flowcore SDK",
5
5
  "homepage": "https://github.com/flowcore-io/flowcore-sdk#readme",
6
6
  "repository": {
@@ -1,12 +1,26 @@
1
1
  import { Command } from "../../common/command.js";
2
2
  import { type Scenario } from "../../contracts/scenario.js";
3
- /**
4
- * The input for the scenario fetch command
5
- */
6
- export interface ScenarioFetchInput {
3
+ import type { ClientError } from "../../exceptions/client-error.js";
4
+ export interface ScenarioFetchByIdInput {
7
5
  /** The scenario id */
8
6
  scenarioId: string;
7
+ /** The tenant id */
8
+ tenantId?: never;
9
+ /** scenario name */
10
+ name?: never;
11
+ }
12
+ export interface ScenarioFetchByNameInput {
13
+ /** The scenario id */
14
+ scenarioId?: never;
15
+ /** The tenant id */
16
+ tenantId: string;
17
+ /** scenario name */
18
+ name: string;
9
19
  }
20
+ /**
21
+ * The input for the scenario fetch command
22
+ */
23
+ export type ScenarioFetchInput = ScenarioFetchByIdInput | ScenarioFetchByNameInput;
10
24
  /**
11
25
  * fetch a scenario
12
26
  */
@@ -31,5 +45,9 @@ export declare class ScenarioFetchCommand extends Command<ScenarioFetchInput, Sc
31
45
  * Parse the response
32
46
  */
33
47
  protected parseResponse(rawResponse: unknown): Scenario;
48
+ /**
49
+ * Handle the client error
50
+ */
51
+ protected handleClientError(error: ClientError): void;
34
52
  }
35
53
  //# sourceMappingURL=scenario.fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scenario.fetch.d.ts","sourceRoot":"","sources":["../../../src/commands/scenario/scenario.fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,KAAK,QAAQ,EAAkB,MA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CAAQ;IAElD;;OAEG;cACgB,SAAS,IAAI,MAAM;IAGtC;;OAEG;cACgB,UAAU,IAAI,MAAM;IAIvC;;OAEG;cACgB,OAAO,IAAI,MAAM;IAOpC;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ;IAIhE;;OAEG;cACgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;CAU/D"}
@@ -3,7 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ScenarioFetchCommand = void 0;
4
4
  const command_js_1 = require("../../common/command.js");
5
5
  const scenario_js_1 = require("../../contracts/scenario.js");
6
+ const not_found_js_1 = require("../../exceptions/not-found.js");
6
7
  const parse_response_helper_js_1 = require("../../utils/parse-response-helper.js");
8
+ function isScenarioFetchByIdInput(input) {
9
+ return "scenarioId" in input;
10
+ }
11
+ function isScenarioFetchByNameAndTenantInput(input) {
12
+ return "tenantId" in input;
13
+ }
7
14
  /**
8
15
  * fetch a scenario
9
16
  */
@@ -36,7 +43,10 @@ class ScenarioFetchCommand extends command_js_1.Command {
36
43
  * Get the path
37
44
  */
38
45
  getPath() {
39
- return `/api/v1/scenarios/${this.input.scenarioId}`;
46
+ if (this.input.scenarioId) {
47
+ return `/api/v1/scenarios/${this.input.scenarioId}`;
48
+ }
49
+ return `/api/v1/scenarios/tenant/${this.input.tenantId}/name/${this.input.name}`;
40
50
  }
41
51
  /**
42
52
  * Parse the response
@@ -44,5 +54,19 @@ class ScenarioFetchCommand extends command_js_1.Command {
44
54
  parseResponse(rawResponse) {
45
55
  return (0, parse_response_helper_js_1.parseResponseHelper)(scenario_js_1.ScenarioSchema, rawResponse);
46
56
  }
57
+ /**
58
+ * Handle the client error
59
+ */
60
+ handleClientError(error) {
61
+ if (error.status === 404) {
62
+ if (isScenarioFetchByIdInput(this.input)) {
63
+ throw new not_found_js_1.NotFoundException("Scenario", { id: this.input.scenarioId });
64
+ }
65
+ else if (isScenarioFetchByNameAndTenantInput(this.input)) {
66
+ throw new not_found_js_1.NotFoundException("Scenario", { name: this.input.name, tenantId: this.input.tenantId });
67
+ }
68
+ }
69
+ throw error;
70
+ }
47
71
  }
48
72
  exports.ScenarioFetchCommand = ScenarioFetchCommand;
@@ -4,8 +4,6 @@ import { type Scenario } from "../../contracts/scenario.js";
4
4
  * The input for the scenario update command
5
5
  */
6
6
  export interface ScenarioUpdateInput {
7
- /** The tenant id */
8
- tenantId: string;
9
7
  /** The scenario id */
10
8
  scenarioId: string;
11
9
  /** The description of the scenario */
@@ -29,6 +27,10 @@ export declare class ScenarioUpdateCommand extends Command<ScenarioUpdateInput,
29
27
  * Get the base url
30
28
  */
31
29
  protected getBaseUrl(): string;
30
+ /**
31
+ * Get the body
32
+ */
33
+ protected getBody(): Record<string, unknown> | Array<unknown> | undefined;
32
34
  /**
33
35
  * Get the path
34
36
  */
@@ -1 +1 @@
1
- {"version":3,"file":"scenario.update.d.ts","sourceRoot":"","sources":["../../../src/commands/scenario/scenario.update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,6BAA6B,CAAA;AAG3E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,OAAO,CAAC,mBAAmB,EAAE,QAAQ,CAAC;IAC/E;;OAEG;IACH,UAAmB,cAAc,EAAE,OAAO,CAAQ;IAElD;;OAEG;cACgB,SAAS,IAAI,MAAM;IAGtC;;OAEG;cACgB,UAAU,IAAI,MAAM;IAIvC;;OAEG;cACgB,OAAO,IAAI,MAAM;IAIpC;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ;CAGjE"}
1
+ {"version":3,"file":"scenario.update.d.ts","sourceRoot":"","sources":["../../../src/commands/scenario/scenario.update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,KAAK,QAAQ,EAAkB,MAAM,6BAA6B,CAAA;AAG3E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,OAAO,CAAC,mBAAmB,EAAE,QAAQ,CAAC;IAC/E;;OAEG;IACH,UAAmB,cAAc,EAAE,OAAO,CAAQ;IAElD;;OAEG;cACgB,SAAS,IAAI,MAAM;IAGtC;;OAEG;cACgB,UAAU,IAAI,MAAM;IAIvC;;OAEG;cACgB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,SAAS;IAOlF;;OAEG;cACgB,OAAO,IAAI,MAAM;IAIpC;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,QAAQ;CAGjE"}
@@ -32,6 +32,15 @@ class ScenarioUpdateCommand extends command_js_1.Command {
32
32
  getBaseUrl() {
33
33
  return "https://scenario-2.api.flowcore.io";
34
34
  }
35
+ /**
36
+ * Get the body
37
+ */
38
+ getBody() {
39
+ return {
40
+ ...(this.input.description && { description: this.input.description }),
41
+ ...(this.input.displayName && { displayName: this.input.displayName }),
42
+ };
43
+ }
35
44
  /**
36
45
  * Get the path
37
46
  */