@scalekit-sdk/node 2.1.8 → 2.1.9
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 +2 -2
- package/lib/domain.d.ts +6 -1
- package/lib/domain.js +20 -8
- package/lib/domain.js.map +1 -1
- package/package.json +1 -1
- package/src/core.ts +2 -2
- package/src/domain.ts +29 -7
- package/tests/domain.test.ts +54 -0
package/lib/core.js
CHANGED
|
@@ -57,8 +57,8 @@ class CoreClient {
|
|
|
57
57
|
this.clientSecret = clientSecret;
|
|
58
58
|
this.keys = [];
|
|
59
59
|
this.accessToken = null;
|
|
60
|
-
this.sdkVersion = `Scalekit-Node/2.1.
|
|
61
|
-
this.apiVersion = "
|
|
60
|
+
this.sdkVersion = `Scalekit-Node/2.1.9`;
|
|
61
|
+
this.apiVersion = "20260113";
|
|
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 });
|
|
64
64
|
this.axios.interceptors.request.use((config) => {
|
package/lib/domain.d.ts
CHANGED
|
@@ -124,6 +124,7 @@ export default class DomainClient {
|
|
|
124
124
|
* @see {@link listDomains} - List all domains for an organization
|
|
125
125
|
*/
|
|
126
126
|
getDomain(organizationId: string, domainId: string): Promise<GetDomainResponse>;
|
|
127
|
+
private resolveDomainType;
|
|
127
128
|
/**
|
|
128
129
|
* Retrieves all domain configurations for an organization.
|
|
129
130
|
*
|
|
@@ -136,6 +137,8 @@ export default class DomainClient {
|
|
|
136
137
|
*
|
|
137
138
|
* @param {string} organizationId - The organization ID (format: "org_...")
|
|
138
139
|
*
|
|
140
|
+
* @param options Optional parameters for filtering domains
|
|
141
|
+
* @param {DomainType | string} options.domainType Filter domains by type (ALLOWED_EMAIL_DOMAIN or ORGANIZATION_DOMAIN)
|
|
139
142
|
* @returns {Promise<ListDomainResponse>} List of all domains with their configurations
|
|
140
143
|
*
|
|
141
144
|
* @example
|
|
@@ -158,7 +161,9 @@ export default class DomainClient {
|
|
|
158
161
|
* @see {@link getDomain} - Get details for a specific domain
|
|
159
162
|
* @see {@link deleteDomain} - Remove a domain
|
|
160
163
|
*/
|
|
161
|
-
listDomains(organizationId: string
|
|
164
|
+
listDomains(organizationId: string, options?: {
|
|
165
|
+
domainType?: DomainType | string;
|
|
166
|
+
}): Promise<ListDomainResponse>;
|
|
162
167
|
/**
|
|
163
168
|
* Deletes a domain from an organization.
|
|
164
169
|
*
|
package/lib/domain.js
CHANGED
|
@@ -107,7 +107,7 @@ class DomainClient {
|
|
|
107
107
|
case: "organizationId",
|
|
108
108
|
value: organizationId,
|
|
109
109
|
},
|
|
110
|
-
domain: Object.assign({ domain: name }, (domainTypeValue && { domainType: domainTypeValue })),
|
|
110
|
+
domain: Object.assign({ domain: name }, (!!domainTypeValue && { domainType: domainTypeValue })),
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
113
|
}
|
|
@@ -165,6 +165,17 @@ class DomainClient {
|
|
|
165
165
|
});
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
|
+
resolveDomainType(domainType) {
|
|
169
|
+
if (domainType == null)
|
|
170
|
+
return;
|
|
171
|
+
if (typeof domainType !== 'string')
|
|
172
|
+
return domainType;
|
|
173
|
+
const resolved = domains_pb_1.DomainType[domainType];
|
|
174
|
+
if (resolved === undefined) {
|
|
175
|
+
throw new Error(`Invalid domain type: ${domainType}. Expected ALLOWED_EMAIL_DOMAIN or ORGANIZATION_DOMAIN`);
|
|
176
|
+
}
|
|
177
|
+
return resolved;
|
|
178
|
+
}
|
|
168
179
|
/**
|
|
169
180
|
* Retrieves all domain configurations for an organization.
|
|
170
181
|
*
|
|
@@ -177,6 +188,8 @@ class DomainClient {
|
|
|
177
188
|
*
|
|
178
189
|
* @param {string} organizationId - The organization ID (format: "org_...")
|
|
179
190
|
*
|
|
191
|
+
* @param options Optional parameters for filtering domains
|
|
192
|
+
* @param {DomainType | string} options.domainType Filter domains by type (ALLOWED_EMAIL_DOMAIN or ORGANIZATION_DOMAIN)
|
|
180
193
|
* @returns {Promise<ListDomainResponse>} List of all domains with their configurations
|
|
181
194
|
*
|
|
182
195
|
* @example
|
|
@@ -199,14 +212,13 @@ class DomainClient {
|
|
|
199
212
|
* @see {@link getDomain} - Get details for a specific domain
|
|
200
213
|
* @see {@link deleteDomain} - Remove a domain
|
|
201
214
|
*/
|
|
202
|
-
listDomains(organizationId) {
|
|
215
|
+
listDomains(organizationId, options) {
|
|
203
216
|
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
case:
|
|
207
|
-
value: organizationId
|
|
208
|
-
},
|
|
209
|
-
});
|
|
217
|
+
const domainTypeValue = this.resolveDomainType(options === null || options === void 0 ? void 0 : options.domainType);
|
|
218
|
+
return this.coreClient.connectExec(this.client.listDomains, Object.assign({ identities: {
|
|
219
|
+
case: 'organizationId',
|
|
220
|
+
value: organizationId
|
|
221
|
+
} }, (!!domainTypeValue && { domainType: domainTypeValue })));
|
|
210
222
|
});
|
|
211
223
|
}
|
|
212
224
|
/**
|
package/lib/domain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain.js","sourceRoot":"","sources":["../src/domain.ts"],"names":[],"mappings":";;;;;;;;;;;AAGA,oFAA+E;AAC/E,0EAKmD;AAGnD;;;;;;;;;;;;GAYG;AACH,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDG;IACG,YAAY,CAChB,cAAsB,EACtB,IAAY,EACZ,OAA8C;;YAE9C,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AAI,KAAK,CACb,wBAAwB,UAAU,wDAAwD,CAC3F,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,WAAW,CAAC,cAAsB,EAAE,OAA8C;;YACtF,MAAM,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,CAAC,CAAC;YAEpE,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAChC,IAAI,CAAC,MAAM,CAAC,WAAW,kBAErB,UAAU,EAAE;oBACV,IAAI,EAAE,gBAAgB;oBACtB,KAAK,EAAE,cAAc;iBACtB,IACE,CAAC,CAAC,CAAC,eAAe,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,EAE5D,CAAC;QACJ,CAAC;KAAA;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACG,YAAY,CAAC,cAAsB,EAAE,QAAgB;;YACzD,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;gBAC3D,EAAE,EAAE,QAAQ;gBACZ,UAAU,EAAE;oBACV,IAAI,EAAE,gBAAgB;oBACtB,KAAK,EAAE,cAAc;iBACtB;aACF,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AAtPD,+BAsPC"}
|
package/package.json
CHANGED
package/src/core.ts
CHANGED
|
@@ -23,8 +23,8 @@ export default class CoreClient {
|
|
|
23
23
|
public keys: JWK[] = [];
|
|
24
24
|
public accessToken: string | null = null;
|
|
25
25
|
public axios: Axios;
|
|
26
|
-
public sdkVersion = `Scalekit-Node/2.1.
|
|
27
|
-
public apiVersion = "
|
|
26
|
+
public sdkVersion = `Scalekit-Node/2.1.9`;
|
|
27
|
+
public apiVersion = "20260113";
|
|
28
28
|
public userAgent = `${this.sdkVersion} Node/${process.version} (${
|
|
29
29
|
process.platform
|
|
30
30
|
}; ${os.arch()})`;
|
package/src/domain.ts
CHANGED
|
@@ -114,7 +114,7 @@ export default class DomainClient {
|
|
|
114
114
|
},
|
|
115
115
|
domain: {
|
|
116
116
|
domain: name,
|
|
117
|
-
...(domainTypeValue && { domainType: domainTypeValue }),
|
|
117
|
+
...(!!domainTypeValue && { domainType: domainTypeValue }),
|
|
118
118
|
},
|
|
119
119
|
});
|
|
120
120
|
}
|
|
@@ -175,6 +175,20 @@ export default class DomainClient {
|
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
private resolveDomainType(
|
|
179
|
+
domainType?: DomainType | string
|
|
180
|
+
): DomainType | undefined {
|
|
181
|
+
if (domainType == null) return;
|
|
182
|
+
if (typeof domainType !== 'string') return domainType;
|
|
183
|
+
const resolved = DomainType[domainType as keyof typeof DomainType];
|
|
184
|
+
if (resolved === undefined) {
|
|
185
|
+
throw new Error(
|
|
186
|
+
`Invalid domain type: ${domainType}. Expected ALLOWED_EMAIL_DOMAIN or ORGANIZATION_DOMAIN`
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
return resolved;
|
|
190
|
+
}
|
|
191
|
+
|
|
178
192
|
/**
|
|
179
193
|
* Retrieves all domain configurations for an organization.
|
|
180
194
|
*
|
|
@@ -187,6 +201,8 @@ export default class DomainClient {
|
|
|
187
201
|
*
|
|
188
202
|
* @param {string} organizationId - The organization ID (format: "org_...")
|
|
189
203
|
*
|
|
204
|
+
* @param options Optional parameters for filtering domains
|
|
205
|
+
* @param {DomainType | string} options.domainType Filter domains by type (ALLOWED_EMAIL_DOMAIN or ORGANIZATION_DOMAIN)
|
|
190
206
|
* @returns {Promise<ListDomainResponse>} List of all domains with their configurations
|
|
191
207
|
*
|
|
192
208
|
* @example
|
|
@@ -209,13 +225,19 @@ export default class DomainClient {
|
|
|
209
225
|
* @see {@link getDomain} - Get details for a specific domain
|
|
210
226
|
* @see {@link deleteDomain} - Remove a domain
|
|
211
227
|
*/
|
|
212
|
-
async listDomains(organizationId: string): Promise<ListDomainResponse> {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
228
|
+
async listDomains(organizationId: string, options?: { domainType?: DomainType | string }): Promise<ListDomainResponse> {
|
|
229
|
+
const domainTypeValue = this.resolveDomainType(options?.domainType);
|
|
230
|
+
|
|
231
|
+
return this.coreClient.connectExec(
|
|
232
|
+
this.client.listDomains,
|
|
233
|
+
{
|
|
234
|
+
identities: {
|
|
235
|
+
case: 'organizationId',
|
|
236
|
+
value: organizationId
|
|
237
|
+
},
|
|
238
|
+
...(!!domainTypeValue && { domainType: domainTypeValue })
|
|
217
239
|
},
|
|
218
|
-
|
|
240
|
+
);
|
|
219
241
|
}
|
|
220
242
|
|
|
221
243
|
/**
|
package/tests/domain.test.ts
CHANGED
|
@@ -149,6 +149,60 @@ describe('Domains', () => {
|
|
|
149
149
|
expect(domainTypes).toContain(DomainType.ALLOWED_EMAIL_DOMAIN);
|
|
150
150
|
expect(domainTypes).toContain(DomainType.ORGANIZATION_DOMAIN);
|
|
151
151
|
});
|
|
152
|
+
|
|
153
|
+
it('should list domains filtered by ALLOWED_EMAIL_DOMAIN type', async () => {
|
|
154
|
+
// Create domains of different types
|
|
155
|
+
const { domainName: allowedDomainName } = await TestDomainManager.createTestDomain(client, testOrg, 'allowed');
|
|
156
|
+
const { domainName: orgDomainName } = await TestDomainManager.createTestDomain(client, testOrg, 'organization');
|
|
157
|
+
|
|
158
|
+
// Filter by ALLOWED_EMAIL_DOMAIN type
|
|
159
|
+
const response = await client.domain.listDomains(testOrg, {
|
|
160
|
+
domainType: DomainType.ALLOWED_EMAIL_DOMAIN
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
expect(response).toBeDefined();
|
|
164
|
+
expect(response.domains).toBeDefined();
|
|
165
|
+
expect(Array.isArray(response.domains)).toBe(true);
|
|
166
|
+
|
|
167
|
+
// Verify all returned domains are of type ALLOWED_EMAIL_DOMAIN
|
|
168
|
+
response.domains.forEach(domain => {
|
|
169
|
+
expect(domain.domainType).toBe(DomainType.ALLOWED_EMAIL_DOMAIN);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Verify the allowed domain is in the filtered list
|
|
173
|
+
const domainNames = response.domains.map(d => d.domain);
|
|
174
|
+
expect(domainNames).toContain(allowedDomainName);
|
|
175
|
+
|
|
176
|
+
// Verify the organization domain is NOT in the filtered list
|
|
177
|
+
expect(domainNames).not.toContain(orgDomainName);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('should list domains filtered by ORGANIZATION_DOMAIN type', async () => {
|
|
181
|
+
// Create domains of different types
|
|
182
|
+
const { domainName: allowedDomainName } = await TestDomainManager.createTestDomain(client, testOrg, 'allowed');
|
|
183
|
+
const { domainName: orgDomainName } = await TestDomainManager.createTestDomain(client, testOrg, 'organization');
|
|
184
|
+
|
|
185
|
+
// Filter by ORGANIZATION_DOMAIN type
|
|
186
|
+
const response = await client.domain.listDomains(testOrg, {
|
|
187
|
+
domainType: DomainType.ORGANIZATION_DOMAIN
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
expect(response).toBeDefined();
|
|
191
|
+
expect(response.domains).toBeDefined();
|
|
192
|
+
expect(Array.isArray(response.domains)).toBe(true);
|
|
193
|
+
|
|
194
|
+
// Verify all returned domains are of type ORGANIZATION_DOMAIN
|
|
195
|
+
response.domains.forEach(domain => {
|
|
196
|
+
expect(domain.domainType).toBe(DomainType.ORGANIZATION_DOMAIN);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Verify the organization domain is in the filtered list
|
|
200
|
+
const domainNames = response.domains.map(d => d.domain);
|
|
201
|
+
expect(domainNames).toContain(orgDomainName);
|
|
202
|
+
|
|
203
|
+
// Verify the allowed domain is NOT in the filtered list
|
|
204
|
+
expect(domainNames).not.toContain(allowedDomainName);
|
|
205
|
+
});
|
|
152
206
|
});
|
|
153
207
|
|
|
154
208
|
describe('getDomain', () => {
|