@scalekit-sdk/node 1.0.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 (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -0
  3. package/buf.gen.yaml +14 -0
  4. package/lib/connect.d.ts +9 -0
  5. package/lib/connect.js +31 -0
  6. package/lib/connect.js.map +1 -0
  7. package/lib/connection.d.ts +28 -0
  8. package/lib/connection.js +68 -0
  9. package/lib/connection.js.map +1 -0
  10. package/lib/constants/user.d.ts +4 -0
  11. package/lib/constants/user.js +24 -0
  12. package/lib/constants/user.js.map +1 -0
  13. package/lib/core.d.ts +37 -0
  14. package/lib/core.js +160 -0
  15. package/lib/core.js.map +1 -0
  16. package/lib/domain.d.ts +33 -0
  17. package/lib/domain.js +74 -0
  18. package/lib/domain.js.map +1 -0
  19. package/lib/index.d.ts +5 -0
  20. package/lib/index.js +26 -0
  21. package/lib/index.js.map +1 -0
  22. package/lib/organization.d.ts +64 -0
  23. package/lib/organization.js +116 -0
  24. package/lib/organization.js.map +1 -0
  25. package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.d.ts +20 -0
  26. package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +36 -0
  27. package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -0
  28. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts +73 -0
  29. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +81 -0
  30. package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js.map +1 -0
  31. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +1252 -0
  32. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +1536 -0
  33. package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -0
  34. package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.d.ts +55 -0
  35. package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.js +63 -0
  36. package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.js.map +1 -0
  37. package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.d.ts +394 -0
  38. package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js +469 -0
  39. package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js.map +1 -0
  40. package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.d.ts +245 -0
  41. package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js +369 -0
  42. package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js.map +1 -0
  43. package/lib/pkg/grpc/scalekit/v1/options/options_pb.d.ts +98 -0
  44. package/lib/pkg/grpc/scalekit/v1/options/options_pb.js +135 -0
  45. package/lib/pkg/grpc/scalekit/v1/options/options_pb.js.map +1 -0
  46. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.d.ts +92 -0
  47. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js +100 -0
  48. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js.map +1 -0
  49. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.d.ts +424 -0
  50. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js +559 -0
  51. package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js.map +1 -0
  52. package/lib/scalekit.d.ts +60 -0
  53. package/lib/scalekit.js +140 -0
  54. package/lib/scalekit.js.map +1 -0
  55. package/lib/types/scalekit.d.ts +26 -0
  56. package/lib/types/scalekit.js +10 -0
  57. package/lib/types/scalekit.js.map +1 -0
  58. package/lib/types/user.d.ts +56 -0
  59. package/lib/types/user.js +3 -0
  60. package/lib/types/user.js.map +1 -0
  61. package/package.json +45 -0
  62. package/src/connect.ts +33 -0
  63. package/src/connection.ts +69 -0
  64. package/src/constants/user.ts +22 -0
  65. package/src/core.ts +127 -0
  66. package/src/domain.ts +75 -0
  67. package/src/index.ts +7 -0
  68. package/src/organization.ts +129 -0
  69. package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +36 -0
  70. package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +80 -0
  71. package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +2138 -0
  72. package/src/pkg/grpc/scalekit/v1/domains/domains_connect.ts +62 -0
  73. package/src/pkg/grpc/scalekit/v1/domains/domains_pb.ts +687 -0
  74. package/src/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.ts +461 -0
  75. package/src/pkg/grpc/scalekit/v1/options/options_pb.ts +156 -0
  76. package/src/pkg/grpc/scalekit/v1/organizations/organizations_connect.ts +99 -0
  77. package/src/pkg/grpc/scalekit/v1/organizations/organizations_pb.ts +774 -0
  78. package/src/scalekit.ts +155 -0
  79. package/src/types/scalekit.ts +30 -0
  80. package/src/types/user.ts +59 -0
  81. package/tsconfig.json +18 -0
@@ -0,0 +1,129 @@
1
+ import { PartialMessage } from '@bufbuild/protobuf';
2
+ import { PromiseClient } from '@connectrpc/connect';
3
+ import GrpcConnect from './connect';
4
+ import CoreClient from './core';
5
+ import { OrganizationService } from './pkg/grpc/scalekit/v1/organizations/organizations_connect';
6
+ import { CreateOrganizationResponse, GetOrganizationResponse, ListOrganizationsResponse, UpdateOrganization, UpdateOrganizationResponse } from './pkg/grpc/scalekit/v1/organizations/organizations_pb';
7
+
8
+ export default class OrganizationClient {
9
+ private client: PromiseClient<typeof OrganizationService>;
10
+ constructor(
11
+ private readonly grpcConncet: GrpcConnect,
12
+ private readonly coreClient: CoreClient
13
+ ) {
14
+ this.client = this.grpcConncet.createClient(OrganizationService);
15
+ }
16
+
17
+ /**
18
+ * Create an organization with the given name. Optionally, you can provide an external id.
19
+ * @param {object} options The options to create an organization
20
+ * @param {string} options.name The organization name
21
+ * @param {string} options.externalId The external id
22
+ * @returns {Promise<CreateOrganizationResponse>} The created organization
23
+ */
24
+ async createOrganization(options: { name: string, externalId?: string }): Promise<CreateOrganizationResponse> {
25
+ const { name, externalId } = options;
26
+ return this.coreClient.connectExec(
27
+ this.client.createOrganization,
28
+ {
29
+ organization: {
30
+ displayName: name,
31
+ externalId: externalId
32
+ }
33
+ }
34
+ )
35
+ }
36
+
37
+ /**
38
+ * List organizations with pagination
39
+ * @param {object} options The options to list organizations
40
+ * @param {number} options.pageSize The page size
41
+ * @param {string} options.pageToken The page token
42
+ * @returns {Promise<ListOrganizationResponse>} The list of organizations
43
+ */
44
+ async listOrganization(options?: {
45
+ pageSize?: number,
46
+ pageToken?: string
47
+ }): Promise<ListOrganizationsResponse> {
48
+ return this.coreClient.connectExec(
49
+ this.client.listOrganization,
50
+ options ? options : {},
51
+ )
52
+ }
53
+
54
+ /**
55
+ * Get an organization by id
56
+ * @param {string} id The organization id
57
+ * @returns {Promise<GetOrganizationResponse>} The organization
58
+ */
59
+ async getOrganization(id: string): Promise<GetOrganizationResponse> {
60
+ return this.coreClient.connectExec(
61
+ this.client.getOrganization,
62
+ { identities: { case: 'id', value: id } },
63
+ )
64
+ }
65
+
66
+ /**
67
+ * Get an organization by external id
68
+ * @param {string} externalId The external id
69
+ * @returns {Promise<GetOrganizationResponse>} The organization
70
+ */
71
+ async getOrganizationByExternalId(externalId: string): Promise<GetOrganizationResponse> {
72
+ return this.coreClient.connectExec(
73
+ this.client.getOrganization,
74
+ { identities: { case: 'externalId', value: externalId } },
75
+ )
76
+ }
77
+
78
+ /**
79
+ * Update an organization by id
80
+ * @param {string} id The organization id
81
+ * @param {PartialMessage<UpdateOrganization>} organization The organization to update
82
+ * @returns {Promise<UpdateOrganizationResponse>} The updated organization
83
+ */
84
+ async updateOrganization(id: string, organization: PartialMessage<UpdateOrganization>): Promise<UpdateOrganizationResponse> {
85
+ return this.coreClient.connectExec(
86
+ this.client.updateOrganization,
87
+ {
88
+ identities: { case: "id", value: id },
89
+ organization
90
+ },
91
+ )
92
+ }
93
+
94
+ /**
95
+ * Update an organization by external id
96
+ * @param {string} externalId The external id
97
+ * @param {PartialMessage<UpdateOrganization>} organization The organization to update
98
+ * @returns {Promise<UpdateOrganizationResponse>} The updated organization
99
+ */
100
+ async updateOrganizationByExternalId(externalId: string, organization: PartialMessage<UpdateOrganization>): Promise<UpdateOrganizationResponse> {
101
+ return this.coreClient.connectExec(
102
+ this.client.updateOrganization,
103
+ {
104
+ identities: { case: "externalId", value: externalId, },
105
+ organization
106
+ },
107
+ )
108
+ }
109
+
110
+ /**
111
+ * Generate customer portal link for an organization
112
+ * @param organizationId The organization id
113
+ * @returns {Promise<string>} The customer portal link
114
+ */
115
+ async generateCustomerPortalLink(organizationId: string): Promise<string> {
116
+ const response = await this.coreClient.connectExec(
117
+ this.client.generateCustomerPortalLink,
118
+ {
119
+ id: organizationId
120
+ },
121
+ )
122
+ if (!response.link) {
123
+ throw new Error('Error generating customer portal link');
124
+ }
125
+
126
+ return response.link?.location
127
+ }
128
+ }
129
+
@@ -0,0 +1,36 @@
1
+ // @generated by protoc-gen-es v1.8.0 with parameter "target=ts"
2
+ // @generated from file scalekit/v1/commons/commons.proto (package scalekit.v1.commons, syntax proto3)
3
+ /* eslint-disable */
4
+ // @ts-nocheck
5
+
6
+ import { proto3 } from "@bufbuild/protobuf";
7
+
8
+ /**
9
+ * @generated from enum scalekit.v1.commons.RegionCode
10
+ */
11
+ export enum RegionCode {
12
+ /**
13
+ *
14
+ * If the region code is unspecified the selected region will automatically be decided based on the origin of the call.
15
+ *
16
+ * @generated from enum value: REGION_CODE_UNSPECIFIED = 0;
17
+ */
18
+ REGION_CODE_UNSPECIFIED = 0,
19
+
20
+ /**
21
+ * @generated from enum value: US = 1;
22
+ */
23
+ US = 1,
24
+
25
+ /**
26
+ * @generated from enum value: EU = 2;
27
+ */
28
+ EU = 2,
29
+ }
30
+ // Retrieve enum metadata with: proto3.getEnumType(RegionCode)
31
+ proto3.util.setEnumType(RegionCode, "scalekit.v1.commons.RegionCode", [
32
+ { no: 0, name: "REGION_CODE_UNSPECIFIED" },
33
+ { no: 1, name: "US" },
34
+ { no: 2, name: "EU" },
35
+ ]);
36
+
@@ -0,0 +1,80 @@
1
+ // @generated by protoc-gen-connect-es v1.4.0 with parameter "target=ts"
2
+ // @generated from file scalekit/v1/connections/connections.proto (package scalekit.v1.connections, syntax proto3)
3
+ /* eslint-disable */
4
+ // @ts-nocheck
5
+
6
+ import { CreateConnectionRequest, CreateConnectionResponse, DeleteConnectionRequest, DisableConnectionRequest, EnableConnectionRequest, GetConnectionRequest, GetConnectionResponse, ListConnectionsRequest, ListConnectionsResponse, ToggleConnectionResponse, UpdateConnectionRequest, UpdateConnectionResponse } from "./connections_pb.js";
7
+ import { Empty, MethodKind } from "@bufbuild/protobuf";
8
+
9
+ /**
10
+ * @generated from service scalekit.v1.connections.ConnectionService
11
+ */
12
+ export const ConnectionService = {
13
+ typeName: "scalekit.v1.connections.ConnectionService",
14
+ methods: {
15
+ /**
16
+ * @generated from rpc scalekit.v1.connections.ConnectionService.CreateConnection
17
+ */
18
+ createConnection: {
19
+ name: "CreateConnection",
20
+ I: CreateConnectionRequest,
21
+ O: CreateConnectionResponse,
22
+ kind: MethodKind.Unary,
23
+ },
24
+ /**
25
+ * @generated from rpc scalekit.v1.connections.ConnectionService.GetConnection
26
+ */
27
+ getConnection: {
28
+ name: "GetConnection",
29
+ I: GetConnectionRequest,
30
+ O: GetConnectionResponse,
31
+ kind: MethodKind.Unary,
32
+ },
33
+ /**
34
+ * @generated from rpc scalekit.v1.connections.ConnectionService.ListConnections
35
+ */
36
+ listConnections: {
37
+ name: "ListConnections",
38
+ I: ListConnectionsRequest,
39
+ O: ListConnectionsResponse,
40
+ kind: MethodKind.Unary,
41
+ },
42
+ /**
43
+ * @generated from rpc scalekit.v1.connections.ConnectionService.UpdateConnection
44
+ */
45
+ updateConnection: {
46
+ name: "UpdateConnection",
47
+ I: UpdateConnectionRequest,
48
+ O: UpdateConnectionResponse,
49
+ kind: MethodKind.Unary,
50
+ },
51
+ /**
52
+ * @generated from rpc scalekit.v1.connections.ConnectionService.DeleteConnection
53
+ */
54
+ deleteConnection: {
55
+ name: "DeleteConnection",
56
+ I: DeleteConnectionRequest,
57
+ O: Empty,
58
+ kind: MethodKind.Unary,
59
+ },
60
+ /**
61
+ * @generated from rpc scalekit.v1.connections.ConnectionService.EnableConnection
62
+ */
63
+ enableConnection: {
64
+ name: "EnableConnection",
65
+ I: EnableConnectionRequest,
66
+ O: ToggleConnectionResponse,
67
+ kind: MethodKind.Unary,
68
+ },
69
+ /**
70
+ * @generated from rpc scalekit.v1.connections.ConnectionService.DisableConnection
71
+ */
72
+ disableConnection: {
73
+ name: "DisableConnection",
74
+ I: DisableConnectionRequest,
75
+ O: ToggleConnectionResponse,
76
+ kind: MethodKind.Unary,
77
+ },
78
+ }
79
+ } as const;
80
+