@flowcore/sdk 1.53.0 → 1.55.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/esm/commands/api-key/api-key.create.d.ts +20 -23
  3. package/esm/commands/api-key/api-key.create.d.ts.map +1 -1
  4. package/esm/commands/api-key/api-key.create.js +21 -62
  5. package/esm/commands/api-key/api-key.delete.d.ts +22 -12
  6. package/esm/commands/api-key/api-key.delete.d.ts.map +1 -1
  7. package/esm/commands/api-key/api-key.delete.js +27 -41
  8. package/esm/commands/api-key/api-key.edit.d.ts +41 -0
  9. package/esm/commands/api-key/api-key.edit.d.ts.map +1 -0
  10. package/esm/commands/api-key/api-key.edit.js +40 -0
  11. package/esm/commands/api-key/api-key.list.d.ts +20 -8
  12. package/esm/commands/api-key/api-key.list.d.ts.map +1 -1
  13. package/esm/commands/api-key/api-key.list.js +27 -36
  14. package/esm/commands/index.d.ts +1 -0
  15. package/esm/commands/index.d.ts.map +1 -1
  16. package/esm/commands/index.js +1 -0
  17. package/esm/commands/tenant/tenant.list.d.ts +13 -17
  18. package/esm/commands/tenant/tenant.list.d.ts.map +1 -1
  19. package/esm/commands/tenant/tenant.list.js +20 -66
  20. package/esm/contracts/api-key.d.ts +22 -1
  21. package/esm/contracts/api-key.d.ts.map +1 -1
  22. package/esm/contracts/api-key.js +17 -0
  23. package/esm/contracts/tenant.d.ts +17 -1
  24. package/esm/contracts/tenant.d.ts.map +1 -1
  25. package/esm/contracts/tenant.js +12 -0
  26. package/package.json +1 -1
  27. package/script/commands/api-key/api-key.create.d.ts +20 -23
  28. package/script/commands/api-key/api-key.create.d.ts.map +1 -1
  29. package/script/commands/api-key/api-key.create.js +21 -62
  30. package/script/commands/api-key/api-key.delete.d.ts +22 -12
  31. package/script/commands/api-key/api-key.delete.d.ts.map +1 -1
  32. package/script/commands/api-key/api-key.delete.js +27 -41
  33. package/script/commands/api-key/api-key.edit.d.ts +41 -0
  34. package/script/commands/api-key/api-key.edit.d.ts.map +1 -0
  35. package/script/commands/api-key/api-key.edit.js +44 -0
  36. package/script/commands/api-key/api-key.list.d.ts +20 -8
  37. package/script/commands/api-key/api-key.list.d.ts.map +1 -1
  38. package/script/commands/api-key/api-key.list.js +27 -36
  39. package/script/commands/index.d.ts +1 -0
  40. package/script/commands/index.d.ts.map +1 -1
  41. package/script/commands/index.js +1 -0
  42. package/script/commands/tenant/tenant.list.d.ts +13 -17
  43. package/script/commands/tenant/tenant.list.d.ts.map +1 -1
  44. package/script/commands/tenant/tenant.list.js +20 -66
  45. package/script/contracts/api-key.d.ts +22 -1
  46. package/script/contracts/api-key.d.ts.map +1 -1
  47. package/script/contracts/api-key.js +18 -1
  48. package/script/contracts/tenant.d.ts +17 -1
  49. package/script/contracts/tenant.d.ts.map +1 -1
  50. package/script/contracts/tenant.js +13 -1
@@ -1,80 +1,34 @@
1
1
  import { Type } from "@sinclair/typebox";
2
- import { GraphQlCommand } from "../../common/command-graphql.js";
2
+ import { Command } from "../../common/command.js";
3
+ import { TenantListItemSchema } from "../../contracts/tenant.js";
3
4
  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
- });
44
5
  /**
45
6
  * List tenants
46
7
  */
47
- export class TenantListCommand extends GraphQlCommand {
8
+ export class TenantListCommand extends Command {
48
9
  /**
49
- * The allowed modes for the command
10
+ * Get the method
50
11
  */
51
- allowedModes = ["bearer"];
12
+ getMethod() {
13
+ return "GET";
14
+ }
52
15
  /**
53
- * Parse the response
16
+ * Get the base url
54
17
  */
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
- }));
18
+ getBaseUrl() {
19
+ return "https://tenant.api.flowcore.io";
71
20
  }
72
21
  /**
73
- * Get the body for the request
22
+ * Get the path
74
23
  */
75
- getBody() {
76
- return {
77
- query: graphQlQueryById,
78
- };
24
+ getPath() {
25
+ return `/api/v1/tenants/list`;
26
+ }
27
+ /**
28
+ * Parse the response
29
+ */
30
+ parseResponse(rawResponse) {
31
+ const response = parseResponseHelper(Type.Array(TenantListItemSchema), rawResponse);
32
+ return response;
79
33
  }
80
34
  }
@@ -1,14 +1,35 @@
1
- import { type Static, type TObject, type TString } from "@sinclair/typebox";
1
+ import { type Static, type TNull, type TObject, type TString, type TUnion } from "@sinclair/typebox";
2
2
  /**
3
3
  * The schema for an api key
4
4
  */
5
5
  export declare const ApiKeySchema: TObject<{
6
6
  id: TString;
7
+ tenantId: TString;
7
8
  name: TString;
9
+ description: TString;
10
+ maskedApiKey: TString;
8
11
  createdAt: TString;
12
+ lastUsedAt: TUnion<[TString, TNull]>;
9
13
  }>;
10
14
  /**
11
15
  * The type for an api key
12
16
  */
13
17
  export type ApiKey = Static<typeof ApiKeySchema>;
18
+ /**
19
+ * The schema for an api key with value
20
+ */
21
+ export declare const ApiKeyWithValueSchema: TObject<{
22
+ id: TString;
23
+ tenantId: TString;
24
+ name: TString;
25
+ description: TString;
26
+ maskedApiKey: TString;
27
+ createdAt: TString;
28
+ lastUsedAt: TUnion<[TString, TNull]>;
29
+ apiKey: TString;
30
+ }>;
31
+ /**
32
+ * The type for an api key with value
33
+ */
34
+ export type ApiKeyWithValue = Static<typeof ApiKeyWithValueSchema>;
14
35
  //# sourceMappingURL=api-key.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/contracts/api-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAQ,MAAM,mBAAmB,CAAA;AAEjF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC;IACjC,EAAE,EAAE,OAAO,CAAA;IACX,IAAI,EAAE,OAAO,CAAA;IACb,SAAS,EAAE,OAAO,CAAA;CACnB,CAIC,CAAA;AACF;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAA"}
1
+ {"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../src/contracts/api-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAA;AAE1G;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC;IACjC,EAAE,EAAE,OAAO,CAAA;IACX,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;CACrC,CAQC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAA;AAEhD;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,OAAO,CAAC;IAC1C,EAAE,EAAE,OAAO,CAAA;IACX,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,MAAM,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IACpC,MAAM,EAAE,OAAO,CAAA;CAChB,CASC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAA"}
@@ -4,6 +4,23 @@ import { Type } from "@sinclair/typebox";
4
4
  */
5
5
  export const ApiKeySchema = Type.Object({
6
6
  id: Type.String(),
7
+ tenantId: Type.String(),
7
8
  name: Type.String(),
9
+ description: Type.String(),
10
+ maskedApiKey: Type.String(),
8
11
  createdAt: Type.String(),
12
+ lastUsedAt: Type.Union([Type.String(), Type.Null()]),
13
+ });
14
+ /**
15
+ * The schema for an api key with value
16
+ */
17
+ export const ApiKeyWithValueSchema = Type.Object({
18
+ id: Type.String(),
19
+ tenantId: Type.String(),
20
+ name: Type.String(),
21
+ description: Type.String(),
22
+ maskedApiKey: Type.String(),
23
+ createdAt: Type.String(),
24
+ lastUsedAt: Type.Union([Type.String(), Type.Null()]),
25
+ apiKey: Type.String(),
9
26
  });
@@ -1,4 +1,4 @@
1
- import { type Static, type TBoolean, type TLiteral, type TNull, type TObject, type TOptional, type TString, type TUnion } from "@sinclair/typebox";
1
+ import { type Static, type TArray, type TBoolean, type TLiteral, type TNull, type TObject, type TOptional, type TString, type TUnion } from "@sinclair/typebox";
2
2
  interface TenantById {
3
3
  tenantId: string;
4
4
  tenant?: never;
@@ -39,5 +39,21 @@ export declare const TenantSchema: TObject<{
39
39
  * The type for a tenant
40
40
  */
41
41
  export type Tenant = Static<typeof TenantSchema>;
42
+ /**
43
+ * The schema for a tenant list item
44
+ */
45
+ export declare const TenantListItemSchema: TObject<{
46
+ id: TString;
47
+ name: TString;
48
+ displayName: TString;
49
+ description: TString;
50
+ websiteUrl: TString;
51
+ isDedicated: TBoolean;
52
+ permissions: TArray<TString>;
53
+ }>;
54
+ /**
55
+ * The type for a tenant list item
56
+ */
57
+ export type TenantListItem = Static<typeof TenantListItemSchema>;
42
58
  export {};
43
59
  //# sourceMappingURL=tenant.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tenant.d.ts","sourceRoot":"","sources":["../../src/contracts/tenant.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,MAAM,EAEZ,MAAM,mBAAmB,CAAA;AAE1B,UAAU,UAAU;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,KAAK,CAAA;CACf;AAED,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,KAAK,CAAA;CACjB;AAED,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,YAAY,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC;IACjC,EAAE,EAAE,OAAO,CAAA;IACX,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,OAAO,CAAA;IACnB,WAAW,EAAE,QAAQ,CAAA;IACrB,SAAS,EAAE,MAAM,CAAC;QAChB,KAAK;QACL,OAAO,CAAC;YACN,MAAM,EAAE,MAAM,CAAC;gBACb,QAAQ,CAAC,OAAO,CAAC;gBACjB,QAAQ,CAAC,UAAU,CAAC;gBACpB,QAAQ,CAAC,SAAS,CAAC;aACpB,CAAC,CAAA;YACF,aAAa,EAAE,OAAO,CAAC;gBACrB,MAAM,EAAE,OAAO,CAAA;gBACf,oBAAoB,EAAE,OAAO,CAAA;gBAC7B,4BAA4B,EAAE,OAAO,CAAA;aACtC,CAAC,CAAA;SACH,CAAC;KACH,CAAC,CAAA;IACF,oBAAoB,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAA;CAC1C,CAuBC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAA"}
1
+ {"version":3,"file":"tenant.d.ts","sourceRoot":"","sources":["../../src/contracts/tenant.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,MAAM,EAEZ,MAAM,mBAAmB,CAAA;AAE1B,UAAU,UAAU;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,KAAK,CAAA;CACf;AAED,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,KAAK,CAAA;CACjB;AAED,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,YAAY,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,OAAO,CAAC;IACjC,EAAE,EAAE,OAAO,CAAA;IACX,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,OAAO,CAAA;IACnB,WAAW,EAAE,QAAQ,CAAA;IACrB,SAAS,EAAE,MAAM,CAAC;QAChB,KAAK;QACL,OAAO,CAAC;YACN,MAAM,EAAE,MAAM,CAAC;gBACb,QAAQ,CAAC,OAAO,CAAC;gBACjB,QAAQ,CAAC,UAAU,CAAC;gBACpB,QAAQ,CAAC,SAAS,CAAC;aACpB,CAAC,CAAA;YACF,aAAa,EAAE,OAAO,CAAC;gBACrB,MAAM,EAAE,OAAO,CAAA;gBACf,oBAAoB,EAAE,OAAO,CAAA;gBAC7B,4BAA4B,EAAE,OAAO,CAAA;aACtC,CAAC,CAAA;SACH,CAAC;KACH,CAAC,CAAA;IACF,oBAAoB,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAA;CAC1C,CAuBC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAA;AAEhD;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC;IACzC,EAAE,EAAE,OAAO,CAAA;IACX,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,CAAA;IACpB,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,OAAO,CAAA;IACnB,WAAW,EAAE,QAAQ,CAAA;IACrB,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;CAC7B,CAQC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
@@ -26,3 +26,15 @@ export const TenantSchema = Type.Object({
26
26
  ]),
27
27
  sensitiveDataEnabled: Type.Optional(Type.Boolean()),
28
28
  });
29
+ /**
30
+ * The schema for a tenant list item
31
+ */
32
+ export const TenantListItemSchema = Type.Object({
33
+ id: Type.String(),
34
+ name: Type.String(),
35
+ displayName: Type.String(),
36
+ description: Type.String(),
37
+ websiteUrl: Type.String(),
38
+ isDedicated: Type.Boolean(),
39
+ permissions: Type.Array(Type.String()),
40
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowcore/sdk",
3
- "version": "1.53.0",
3
+ "version": "1.55.0",
4
4
  "description": "Flowcore SDK",
5
5
  "homepage": "https://github.com/flowcore-io/flowcore-sdk#readme",
6
6
  "repository": {
@@ -1,46 +1,43 @@
1
- import { GraphQlCommand } from "../../common/command-graphql.js";
2
- import type { ApiKey } from "../../contracts/api-key.js";
3
- import type { FlowcoreClient } from "../../common/flowcore-client.js";
1
+ import { Command } from "../../common/command.js";
2
+ import { type ApiKeyWithValue } from "../../contracts/api-key.js";
4
3
  /**
5
- * The input for the API key create command
4
+ * The input for the api key create command
6
5
  */
7
6
  export interface ApiKeyCreateInput {
8
7
  /** The tenant id */
9
8
  tenantId: string;
10
- /** The name of the API key */
9
+ /** The name of the api key */
11
10
  name: string;
11
+ /** The description of the api key */
12
+ description?: string;
12
13
  }
13
14
  /**
14
- * Create an API key
15
+ * Create an api key
15
16
  */
16
- export declare class ApiKeyCreateCommand extends GraphQlCommand<ApiKeyCreateInput, ApiKey & {
17
- value: string;
18
- }> {
17
+ export declare class ApiKeyCreateCommand extends Command<ApiKeyCreateInput, ApiKeyWithValue> {
19
18
  /**
20
19
  * Whether the command should retry on failure
21
20
  */
22
21
  protected retryOnFailure: boolean;
23
22
  /**
24
- * The allowed modes for the command
23
+ * Get the method
25
24
  */
26
- protected allowedModes: ("apiKey" | "bearer")[];
25
+ protected getMethod(): string;
27
26
  /**
28
- * Parse the response
27
+ * Get the base url
28
+ */
29
+ protected getBaseUrl(): string;
30
+ /**
31
+ * Get the path
29
32
  */
30
- protected parseResponse(rawResponse: unknown): ApiKey & {
31
- value: string;
32
- };
33
+ protected getPath(): string;
33
34
  /**
34
- * Get the body for the request
35
+ * The allowed modes for the command
35
36
  */
36
- protected getBody(): Record<string, unknown>;
37
+ protected allowedModes: ("apiKey" | "bearer")[];
37
38
  /**
38
- * Fill in the missing fields
39
+ * Parse the response
39
40
  */
40
- protected processResponse(flowcoreClient: FlowcoreClient, response: ApiKey & {
41
- value: string;
42
- }): Promise<ApiKey & {
43
- value: string;
44
- }>;
41
+ protected parseResponse(rawResponse: unknown): ApiKeyWithValue;
45
42
  }
46
43
  //# sourceMappingURL=api-key.create.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-key.create.d.ts","sourceRoot":"","sources":["../../../src/commands/api-key/api-key.create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAIrE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAA;CACb;AA4BD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,iBAAiB,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;IACpG;;OAEG;IACH,UAAmB,cAAc,EAAE,OAAO,CAAQ;IAElD;;OAEG;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,aAAa,CAC9B,WAAW,EAAE,OAAO,GACnB,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IAiB7B;;OAEG;cACgB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAOrD;;OAEG;cACsB,eAAe,CACtC,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GACnC,OAAO,CAAC,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAevC"}
1
+ {"version":3,"file":"api-key.create.d.ts","sourceRoot":"","sources":["../../../src/commands/api-key/api-key.create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEjD,OAAO,EAAE,KAAK,eAAe,EAAyB,MAAM,4BAA4B,CAAA;AAExF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,OAAO,CAAC,iBAAiB,EAAE,eAAe,CAAC;IAClF;;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;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,eAAe;CAGxE"}
@@ -1,85 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiKeyCreateCommand = void 0;
4
- const typebox_1 = require("@sinclair/typebox");
5
- const command_graphql_js_1 = require("../../common/command-graphql.js");
4
+ const command_js_1 = require("../../common/command.js");
6
5
  const parse_response_helper_js_1 = require("../../utils/parse-response-helper.js");
7
- const api_key_list_js_1 = require("./api-key.list.js");
8
- const command_error_js_1 = require("../../exceptions/command-error.js");
9
- const graphQlQueryById = `
10
- mutation FLOWCORE_SDK_API_KEY_CREATE($tenantId: ID!, $name: String!) {
11
- organization(id: $tenantId) {
12
- createApiKey(name: $name)
13
- }
14
- }
15
- `;
16
- const responseSchema = typebox_1.Type.Object({
17
- errors: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.Object({
18
- message: typebox_1.Type.String(),
19
- }))),
20
- data: typebox_1.Type.Union([
21
- typebox_1.Type.Object({
22
- organization: typebox_1.Type.Object({
23
- createApiKey: typebox_1.Type.Union([typebox_1.Type.String(), typebox_1.Type.Null()]),
24
- }),
25
- }),
26
- typebox_1.Type.Null(),
27
- ]),
28
- });
6
+ const api_key_js_1 = require("../../contracts/api-key.js");
29
7
  /**
30
- * Create an API key
8
+ * Create an api key
31
9
  */
32
- class ApiKeyCreateCommand extends command_graphql_js_1.GraphQlCommand {
10
+ class ApiKeyCreateCommand extends command_js_1.Command {
33
11
  /**
34
12
  * Whether the command should retry on failure
35
13
  */
36
14
  retryOnFailure = false;
37
15
  /**
38
- * The allowed modes for the command
16
+ * Get the method
39
17
  */
40
- allowedModes = ["bearer"];
18
+ getMethod() {
19
+ return "POST";
20
+ }
41
21
  /**
42
- * Parse the response
22
+ * Get the base url
43
23
  */
44
- parseResponse(rawResponse) {
45
- const response = (0, parse_response_helper_js_1.parseResponseHelper)(responseSchema, rawResponse);
46
- if (response.errors) {
47
- throw new command_error_js_1.CommandError(this.constructor.name, response.errors[0].message);
48
- }
49
- if (!response.data || response.data?.organization.createApiKey === null) {
50
- throw new command_error_js_1.CommandError(this.constructor.name, "Failed to create API key");
51
- }
52
- return {
53
- id: "",
54
- name: "",
55
- createdAt: "",
56
- value: response.data.organization.createApiKey,
57
- };
24
+ getBaseUrl() {
25
+ return "https://tenant-store.api.flowcore.io";
58
26
  }
59
27
  /**
60
- * Get the body for the request
28
+ * Get the path
61
29
  */
62
- getBody() {
63
- return {
64
- query: graphQlQueryById,
65
- variables: this.input,
66
- };
30
+ getPath() {
31
+ return "/api/v1/api-keys";
67
32
  }
68
33
  /**
69
- * Fill in the missing fields
34
+ * The allowed modes for the command
35
+ */
36
+ allowedModes = ["bearer"];
37
+ /**
38
+ * Parse the response
70
39
  */
71
- async processResponse(flowcoreClient, response) {
72
- const apiKeys = await flowcoreClient.execute(new api_key_list_js_1.ApiKeyListCommand({
73
- tenantId: this.input.tenantId,
74
- }));
75
- const apiKey = apiKeys.find((apiKey) => apiKey.name === this.input.name);
76
- if (!apiKey) {
77
- throw new Error("API key not found");
78
- }
79
- return {
80
- ...apiKey,
81
- value: response.value,
82
- };
40
+ parseResponse(rawResponse) {
41
+ return (0, parse_response_helper_js_1.parseResponseHelper)(api_key_js_1.ApiKeyWithValueSchema, rawResponse);
83
42
  }
84
43
  }
85
44
  exports.ApiKeyCreateCommand = ApiKeyCreateCommand;
@@ -1,17 +1,31 @@
1
- import { GraphQlCommand } from "../../common/command-graphql.js";
1
+ import { Command } from "../../common/command.js";
2
2
  /**
3
- * The input for the API key delete command
3
+ * The input for the api key delete command
4
4
  */
5
5
  export interface ApiKeyDeleteInput {
6
- /** The id of the tenant */
7
- tenantId: string;
8
- /** The id of the API key */
6
+ /** The api key id */
9
7
  apiKeyId: string;
10
8
  }
11
9
  /**
12
- * Delete an API key
10
+ * Delete an api key
13
11
  */
14
- export declare class ApiKeyDeleteCommand extends GraphQlCommand<ApiKeyDeleteInput, boolean> {
12
+ export declare class ApiKeyDeleteCommand extends Command<ApiKeyDeleteInput, boolean> {
13
+ /**
14
+ * Whether the command should retry on failure
15
+ */
16
+ protected retryOnFailure: boolean;
17
+ /**
18
+ * Get the method
19
+ */
20
+ protected getMethod(): string;
21
+ /**
22
+ * Get the base url
23
+ */
24
+ protected getBaseUrl(): string;
25
+ /**
26
+ * Get the path
27
+ */
28
+ protected getPath(): string;
15
29
  /**
16
30
  * The allowed modes for the command
17
31
  */
@@ -19,10 +33,6 @@ export declare class ApiKeyDeleteCommand extends GraphQlCommand<ApiKeyDeleteInpu
19
33
  /**
20
34
  * Parse the response
21
35
  */
22
- protected parseResponse(rawResponse: unknown): boolean;
23
- /**
24
- * Get the body for the request
25
- */
26
- protected getBody(): Record<string, unknown>;
36
+ protected parseResponse(_rawResponse: unknown): boolean;
27
37
  }
28
38
  //# sourceMappingURL=api-key.delete.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-key.delete.d.ts","sourceRoot":"","sources":["../../../src/commands/api-key/api-key.delete.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAIhE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAA;CACjB;AAyBD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACjF;;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,CAAC,MAAM,EAAE,OAAO,CAAC;CAMtD"}
1
+ {"version":3,"file":"api-key.delete.d.ts","sourceRoot":"","sources":["../../../src/commands/api-key/api-key.delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEjD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,qBAAqB;IACrB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;IAC1E;;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;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,aAAa,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO;CAGjE"}
@@ -1,56 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiKeyDeleteCommand = void 0;
4
- const typebox_1 = require("@sinclair/typebox");
5
- const command_graphql_js_1 = require("../../common/command-graphql.js");
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
- mutation FLOWCORE_SDK_API_KEY_DELETE($tenantId: ID!, $apiKeyId: ID!) {
10
- organization(id: $tenantId) {
11
- deleteApiKey(id: $apiKeyId)
12
- }
13
- }
14
- `;
15
- const responseSchema = typebox_1.Type.Object({
16
- errors: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.Object({
17
- message: typebox_1.Type.String(),
18
- }))),
19
- data: typebox_1.Type.Object({
20
- organization: typebox_1.Type.Object({
21
- deleteApiKey: typebox_1.Type.Union([typebox_1.Type.Boolean(), typebox_1.Type.Null()]),
22
- }),
23
- }),
24
- });
4
+ const command_js_1 = require("../../common/command.js");
25
5
  /**
26
- * Delete an API key
6
+ * Delete an api key
27
7
  */
28
- class ApiKeyDeleteCommand extends command_graphql_js_1.GraphQlCommand {
8
+ class ApiKeyDeleteCommand extends command_js_1.Command {
29
9
  /**
30
- * The allowed modes for the command
10
+ * Whether the command should retry on failure
31
11
  */
32
- allowedModes = ["bearer"];
12
+ retryOnFailure = false;
33
13
  /**
34
- * Parse the response
14
+ * Get the method
35
15
  */
36
- parseResponse(rawResponse) {
37
- const response = (0, parse_response_helper_js_1.parseResponseHelper)(responseSchema, rawResponse);
38
- if (response.errors) {
39
- throw new command_error_js_1.CommandError(this.constructor.name, response.errors[0].message);
40
- }
41
- if (response.data.organization.deleteApiKey !== true) {
42
- throw new command_error_js_1.CommandError(this.constructor.name, "Failed to delete API key");
43
- }
44
- return response.data.organization.deleteApiKey;
16
+ getMethod() {
17
+ return "DELETE";
45
18
  }
46
19
  /**
47
- * Get the body for the request
20
+ * Get the base url
21
+ */
22
+ getBaseUrl() {
23
+ return "https://tenant-store.api.flowcore.io";
24
+ }
25
+ /**
26
+ * Get the path
27
+ */
28
+ getPath() {
29
+ return `/api/v1/api-keys/${this.input.apiKeyId}`;
30
+ }
31
+ /**
32
+ * The allowed modes for the command
33
+ */
34
+ allowedModes = ["bearer"];
35
+ /**
36
+ * Parse the response
48
37
  */
49
- getBody() {
50
- return {
51
- query: graphQlQueryById,
52
- variables: this.input,
53
- };
38
+ parseResponse(_rawResponse) {
39
+ return true;
54
40
  }
55
41
  }
56
42
  exports.ApiKeyDeleteCommand = ApiKeyDeleteCommand;
@@ -0,0 +1,41 @@
1
+ import { Command } from "../../common/command.js";
2
+ import { type ApiKey } from "../../contracts/api-key.js";
3
+ /**
4
+ * The input for the api key edit command
5
+ */
6
+ export interface ApiKeyEditInput {
7
+ /** The api key id */
8
+ apiKeyId: string;
9
+ /** The description of the api key */
10
+ description: string;
11
+ }
12
+ /**
13
+ * Edit an api key
14
+ */
15
+ export declare class ApiKeyEditCommand extends Command<ApiKeyEditInput, ApiKey> {
16
+ /**
17
+ * Whether the command should retry on failure
18
+ */
19
+ protected retryOnFailure: boolean;
20
+ /**
21
+ * Get the method
22
+ */
23
+ protected getMethod(): string;
24
+ /**
25
+ * Get the base url
26
+ */
27
+ protected getBaseUrl(): string;
28
+ /**
29
+ * Get the path
30
+ */
31
+ protected getPath(): string;
32
+ /**
33
+ * The allowed modes for the command
34
+ */
35
+ protected allowedModes: ("apiKey" | "bearer")[];
36
+ /**
37
+ * Parse the response
38
+ */
39
+ protected parseResponse(rawResponse: unknown): ApiKey;
40
+ }
41
+ //# sourceMappingURL=api-key.edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-key.edit.d.ts","sourceRoot":"","sources":["../../../src/commands/api-key/api-key.edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAEjD,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,4BAA4B,CAAA;AAEtE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,qBAAqB;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC;IACrE;;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;IACH,UAAmB,YAAY,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,CAAa;IAErE;;OAEG;cACgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM;CAG/D"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiKeyEditCommand = void 0;
4
+ const command_js_1 = require("../../common/command.js");
5
+ const parse_response_helper_js_1 = require("../../utils/parse-response-helper.js");
6
+ const api_key_js_1 = require("../../contracts/api-key.js");
7
+ /**
8
+ * Edit an api key
9
+ */
10
+ class ApiKeyEditCommand extends command_js_1.Command {
11
+ /**
12
+ * Whether the command should retry on failure
13
+ */
14
+ retryOnFailure = false;
15
+ /**
16
+ * Get the method
17
+ */
18
+ getMethod() {
19
+ return "PATCH";
20
+ }
21
+ /**
22
+ * Get the base url
23
+ */
24
+ getBaseUrl() {
25
+ return "https://tenant-store.api.flowcore.io";
26
+ }
27
+ /**
28
+ * Get the path
29
+ */
30
+ getPath() {
31
+ return `/api/v1/api-keys/${this.input.apiKeyId}`;
32
+ }
33
+ /**
34
+ * The allowed modes for the command
35
+ */
36
+ allowedModes = ["bearer"];
37
+ /**
38
+ * Parse the response
39
+ */
40
+ parseResponse(rawResponse) {
41
+ return (0, parse_response_helper_js_1.parseResponseHelper)(api_key_js_1.ApiKeySchema, rawResponse);
42
+ }
43
+ }
44
+ exports.ApiKeyEditCommand = ApiKeyEditCommand;