@scalekit-sdk/node 2.1.1 → 2.1.2

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/lib/core.js CHANGED
@@ -57,7 +57,7 @@ class CoreClient {
57
57
  this.clientSecret = clientSecret;
58
58
  this.keys = [];
59
59
  this.accessToken = null;
60
- this.sdkVersion = `Scalekit-Node/2.1.1`;
60
+ this.sdkVersion = `Scalekit-Node/2.1.2`;
61
61
  this.apiVersion = "20250830";
62
62
  this.userAgent = `${this.sdkVersion} Node/${process.version} (${process.platform}; ${os_1.default.arch()})`;
63
63
  this.axios = axios_1.default.create({ baseURL: envUrl });
package/lib/domain.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import GrpcConnect from './connect';
2
2
  import CoreClient from './core';
3
- import { CreateDomainResponse, ListDomainResponse, DomainType } from './pkg/grpc/scalekit/v1/domains/domains_pb';
3
+ import { CreateDomainResponse, GetDomainResponse, ListDomainResponse, DomainType } from './pkg/grpc/scalekit/v1/domains/domains_pb';
4
+ import { Empty } from '@bufbuild/protobuf';
4
5
  export default class DomainClient {
5
6
  private readonly grpcConncet;
6
7
  private readonly coreClient;
@@ -11,16 +12,24 @@ export default class DomainClient {
11
12
  * @param {string} organizationId The organization id
12
13
  * @param {string} name The domain name
13
14
  * @param {object} options The options to create a domain
14
- * @param {DomainType} options.domainType The type of domain (ALLOWED_EMAIL_DOMAIN or ORGANIZATION_DOMAIN)
15
+ * @param {DomainType | string} options.domainType The type of domain (ALLOWED_EMAIL_DOMAIN or ORGANIZATION_DOMAIN)
15
16
  * @returns {Promise<CreateDomainResponse>} The created domain
16
17
  */
17
18
  createDomain(organizationId: string, name: string, options?: {
18
- domainType?: DomainType;
19
+ domainType?: DomainType | string;
19
20
  }): Promise<CreateDomainResponse>;
21
+ /**
22
+ * Get a specific domain by ID for an organization
23
+ * @param organizationId The organization id
24
+ * @param domainId The domain id
25
+ * @returns {Promise<GetDomainResponse>} The domain details
26
+ */
27
+ getDomain(organizationId: string, domainId: string): Promise<GetDomainResponse>;
20
28
  /**
21
29
  * List domains for an organization
22
30
  * @param organizationId The organization id
23
31
  * @returns {Promise<ListDomainResponse>} The list of domains for the organization
24
32
  */
25
33
  listDomains(organizationId: string): Promise<ListDomainResponse>;
34
+ deleteDomain(organizationId: string, domainId: string): Promise<Empty>;
26
35
  }
package/lib/domain.js CHANGED
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const domains_connect_1 = require("./pkg/grpc/scalekit/v1/domains/domains_connect");
13
+ const domains_pb_1 = require("./pkg/grpc/scalekit/v1/domains/domains_pb");
13
14
  class DomainClient {
14
15
  constructor(grpcConncet, coreClient) {
15
16
  this.grpcConncet = grpcConncet;
@@ -21,17 +22,46 @@ class DomainClient {
21
22
  * @param {string} organizationId The organization id
22
23
  * @param {string} name The domain name
23
24
  * @param {object} options The options to create a domain
24
- * @param {DomainType} options.domainType The type of domain (ALLOWED_EMAIL_DOMAIN or ORGANIZATION_DOMAIN)
25
+ * @param {DomainType | string} options.domainType The type of domain (ALLOWED_EMAIL_DOMAIN or ORGANIZATION_DOMAIN)
25
26
  * @returns {Promise<CreateDomainResponse>} The created domain
26
27
  */
27
28
  createDomain(organizationId, name, options) {
28
29
  return __awaiter(this, void 0, void 0, function* () {
30
+ let domainTypeValue;
31
+ if (options === null || options === void 0 ? void 0 : options.domainType) {
32
+ if (typeof options.domainType === 'string') {
33
+ domainTypeValue = domains_pb_1.DomainType[options.domainType];
34
+ if (domainTypeValue === undefined) {
35
+ throw new Error('Invalid domain type');
36
+ }
37
+ }
38
+ else {
39
+ domainTypeValue = options.domainType;
40
+ }
41
+ }
29
42
  return this.coreClient.connectExec(this.client.createDomain, {
30
43
  identities: {
31
44
  case: 'organizationId',
32
45
  value: organizationId
33
46
  },
34
- domain: Object.assign({ domain: name }, ((options === null || options === void 0 ? void 0 : options.domainType) && { domainType: options.domainType }))
47
+ domain: Object.assign({ domain: name }, (domainTypeValue && { domainType: domainTypeValue }))
48
+ });
49
+ });
50
+ }
51
+ /**
52
+ * Get a specific domain by ID for an organization
53
+ * @param organizationId The organization id
54
+ * @param domainId The domain id
55
+ * @returns {Promise<GetDomainResponse>} The domain details
56
+ */
57
+ getDomain(organizationId, domainId) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ return this.coreClient.connectExec(this.client.getDomain, {
60
+ id: domainId,
61
+ identities: {
62
+ case: 'organizationId',
63
+ value: organizationId
64
+ }
35
65
  });
36
66
  });
37
67
  }
@@ -50,6 +80,17 @@ class DomainClient {
50
80
  });
51
81
  });
52
82
  }
83
+ deleteDomain(organizationId, domainId) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ return this.coreClient.connectExec(this.client.deleteDomain, {
86
+ id: domainId,
87
+ identities: {
88
+ case: 'organizationId',
89
+ value: organizationId
90
+ }
91
+ });
92
+ });
93
+ }
53
94
  }
54
95
  exports.default = DomainClient;
55
96
  //# sourceMappingURL=domain.js.map
package/lib/domain.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"domain.js","sourceRoot":"","sources":["../src/domain.ts"],"names":[],"mappings":";;;;;;;;;;;AAGA,oFAA+E;AAG/E,MAAqB,YAAY;IAE/B,YACmB,WAAwB,EACxB,UAAsB;QADtB,gBAAW,GAAX,WAAW,CAAa;QACxB,eAAU,GAAV,UAAU,CAAY;QAEvC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,+BAAa,CAAC,CAAC;IAC7D,CAAC;IAED;;;;;;;MAOE;IACI,YAAY,CAAC,cAAsB,EAAE,IAAY,EAAE,OAAqC;;YAC5F,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,IAAI,CAAC,MAAM,CAAC,YAAY,EACxB;gBACE,UAAU,EAAE;oBACV,IAAI,EAAE,gBAAgB;oBACtB,KAAK,EAAE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node",
4
4
  "description": "Official Scalekit Node SDK",
5
5
  "main": "lib/index.js",
package/src/core.ts CHANGED
@@ -20,7 +20,7 @@ export default class CoreClient {
20
20
  public keys: JWK[] = [];
21
21
  public accessToken: string | null = null;
22
22
  public axios: Axios;
23
- public sdkVersion = `Scalekit-Node/2.1.1`;
23
+ public sdkVersion = `Scalekit-Node/2.1.2`;
24
24
  public apiVersion = "20250830";
25
25
  public userAgent = `${this.sdkVersion} Node/${process.version} (${process.platform}; ${os.arch()})`;
26
26
  constructor(
package/src/domain.ts CHANGED
@@ -3,6 +3,7 @@ import GrpcConnect from './connect';
3
3
  import CoreClient from './core';
4
4
  import { DomainService } from './pkg/grpc/scalekit/v1/domains/domains_connect';
5
5
  import { CreateDomainResponse, GetDomainResponse, ListDomainResponse, DomainType } from './pkg/grpc/scalekit/v1/domains/domains_pb';
6
+ import { Empty } from '@bufbuild/protobuf';
6
7
 
7
8
  export default class DomainClient {
8
9
  private client: PromiseClient<typeof DomainService>;
@@ -18,10 +19,22 @@ export default class DomainClient {
18
19
  * @param {string} organizationId The organization id
19
20
  * @param {string} name The domain name
20
21
  * @param {object} options The options to create a domain
21
- * @param {DomainType} options.domainType The type of domain (ALLOWED_EMAIL_DOMAIN or ORGANIZATION_DOMAIN)
22
+ * @param {DomainType | string} options.domainType The type of domain (ALLOWED_EMAIL_DOMAIN or ORGANIZATION_DOMAIN)
22
23
  * @returns {Promise<CreateDomainResponse>} The created domain
23
24
  */
24
- async createDomain(organizationId: string, name: string, options?: { domainType?: DomainType }): Promise<CreateDomainResponse> {
25
+ async createDomain(organizationId: string, name: string, options?: { domainType?: DomainType | string }): Promise<CreateDomainResponse> {
26
+ let domainTypeValue: DomainType | undefined;
27
+ if (options?.domainType) {
28
+ if (typeof options.domainType === 'string') {
29
+ domainTypeValue = DomainType[options.domainType as keyof typeof DomainType];
30
+ if (domainTypeValue === undefined) {
31
+ throw new Error('Invalid domain type');
32
+ }
33
+ } else {
34
+ domainTypeValue = options.domainType;
35
+ }
36
+ }
37
+
25
38
  return this.coreClient.connectExec(
26
39
  this.client.createDomain,
27
40
  {
@@ -31,12 +44,31 @@ export default class DomainClient {
31
44
  },
32
45
  domain: {
33
46
  domain: name,
34
- ...(options?.domainType && { domainType: options.domainType })
47
+ ...(domainTypeValue && { domainType: domainTypeValue })
35
48
  }
36
49
  }
37
50
  )
38
51
  }
39
52
 
53
+ /**
54
+ * Get a specific domain by ID for an organization
55
+ * @param organizationId The organization id
56
+ * @param domainId The domain id
57
+ * @returns {Promise<GetDomainResponse>} The domain details
58
+ */
59
+ async getDomain(organizationId: string, domainId: string): Promise<GetDomainResponse> {
60
+ return this.coreClient.connectExec(
61
+ this.client.getDomain,
62
+ {
63
+ id: domainId,
64
+ identities: {
65
+ case: 'organizationId',
66
+ value: organizationId
67
+ }
68
+ }
69
+ );
70
+ }
71
+
40
72
  /**
41
73
  * List domains for an organization
42
74
  * @param organizationId The organization id
@@ -53,5 +85,19 @@ export default class DomainClient {
53
85
  },
54
86
  );
55
87
  }
88
+
89
+ async deleteDomain(organizationId: string, domainId: string): Promise<Empty> {
90
+ return this.coreClient.connectExec(
91
+ this.client.deleteDomain,
92
+ {
93
+ id: domainId,
94
+ identities: {
95
+ case: 'organizationId',
96
+ value: organizationId
97
+ }
98
+ }
99
+ );
100
+ }
101
+
56
102
  }
57
103
 
@@ -151,6 +151,69 @@ describe('Domains', () => {
151
151
  });
152
152
  });
153
153
 
154
+ describe('getDomain', () => {
155
+ it('should get domain by ID successfully', async () => {
156
+ // Create a test domain first
157
+ const { domainId, domainName } = await TestDomainManager.createTestDomain(client, testOrg, 'allowed');
158
+
159
+ const response = await client.domain.getDomain(testOrg, domainId);
160
+
161
+ expect(response).toBeDefined();
162
+ expect(response.domain).toBeDefined();
163
+ expect(response.domain?.id).toBe(domainId);
164
+ expect(response.domain?.domain).toBe(domainName);
165
+ expect(response.domain?.organizationId).toBe(testOrg);
166
+ });
167
+
168
+ it('should throw error for non-existent domain', async () => {
169
+ const nonExistentDomainId = 'non-existent-domain-id';
170
+
171
+ await expect(
172
+ client.domain.getDomain(testOrg, nonExistentDomainId)
173
+ ).rejects.toThrow();
174
+ });
175
+
176
+ it('should throw error for invalid organization ID', async () => {
177
+ // Create a test domain first
178
+ const { domainId } = await TestDomainManager.createTestDomain(client, testOrg, 'allowed');
179
+ const invalidOrgId = 'invalid-org-id';
180
+
181
+ await expect(
182
+ client.domain.getDomain(invalidOrgId, domainId)
183
+ ).rejects.toThrow();
184
+ });
185
+ });
186
+
187
+ describe('deleteDomain', () => {
188
+ it('should delete domain successfully', async () => {
189
+ // Create a test domain for deletion
190
+ const { domainId, domainName } = await TestDomainManager.createTestDomain(client, testOrg, 'allowed');
191
+
192
+ // Verify domain exists before deletion
193
+ const getResponse = await client.domain.getDomain(testOrg, domainId);
194
+ expect(getResponse.domain?.id).toBe(domainId);
195
+
196
+ // Delete the domain
197
+ const deleteResponse = await client.domain.deleteDomain(testOrg, domainId);
198
+ expect(deleteResponse).toBeDefined();
199
+
200
+ // Verify domain is deleted by trying to get it
201
+ await expect(
202
+ client.domain.getDomain(testOrg, domainId)
203
+ ).rejects.toThrow();
204
+ });
205
+
206
+ it('should throw error when deleting non-existent domain', async () => {
207
+ const nonExistentDomainId = 'non-existent-domain-id';
208
+
209
+ await expect(
210
+ client.domain.deleteDomain(testOrg, nonExistentDomainId)
211
+ ).rejects.toThrow();
212
+ });
213
+
214
+
215
+ });
216
+
154
217
  describe('error handling', () => {
155
218
  it('should handle invalid organization ID', async () => {
156
219
  const invalidOrgId = 'invalid-org-id';