@sliceapi/sdk 0.0.1
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/README.md +333 -0
- package/dist/sdk/src/client.d.ts +38 -0
- package/dist/sdk/src/client.d.ts.map +1 -0
- package/dist/sdk/src/client.js +210 -0
- package/dist/sdk/src/client.js.map +1 -0
- package/dist/sdk/src/errors.d.ts +40 -0
- package/dist/sdk/src/errors.d.ts.map +1 -0
- package/dist/sdk/src/errors.js +64 -0
- package/dist/sdk/src/errors.js.map +1 -0
- package/dist/sdk/src/index.d.ts +62 -0
- package/dist/sdk/src/index.d.ts.map +1 -0
- package/dist/sdk/src/index.js +76 -0
- package/dist/sdk/src/index.js.map +1 -0
- package/dist/sdk/src/methods/licenses.d.ts +36 -0
- package/dist/sdk/src/methods/licenses.d.ts.map +1 -0
- package/dist/sdk/src/methods/licenses.js +54 -0
- package/dist/sdk/src/methods/licenses.js.map +1 -0
- package/dist/sdk/src/methods/users.d.ts +27 -0
- package/dist/sdk/src/methods/users.d.ts.map +1 -0
- package/dist/sdk/src/methods/users.js +32 -0
- package/dist/sdk/src/methods/users.js.map +1 -0
- package/dist/sdk/src/methods/validate.d.ts +24 -0
- package/dist/sdk/src/methods/validate.d.ts.map +1 -0
- package/dist/sdk/src/methods/validate.js +29 -0
- package/dist/sdk/src/methods/validate.js.map +1 -0
- package/dist/sdk/src/types.d.ts +22 -0
- package/dist/sdk/src/types.d.ts.map +1 -0
- package/dist/sdk/src/types.js +2 -0
- package/dist/sdk/src/types.js.map +1 -0
- package/dist/shared/api-types.d.ts +213 -0
- package/dist/shared/api-types.d.ts.map +1 -0
- package/dist/shared/api-types.js +2 -0
- package/dist/shared/api-types.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all Slice SDK errors
|
|
3
|
+
*/
|
|
4
|
+
export class SliceError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'SliceError';
|
|
8
|
+
Object.setPrototypeOf(this, SliceError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Error thrown when API returns an error response (4xx, 5xx)
|
|
13
|
+
*/
|
|
14
|
+
export class SliceAPIError extends SliceError {
|
|
15
|
+
constructor(message, statusCode, response) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = 'SliceAPIError';
|
|
18
|
+
this.statusCode = statusCode;
|
|
19
|
+
this.response = response;
|
|
20
|
+
Object.setPrototypeOf(this, SliceAPIError.prototype);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Error thrown when authentication fails (401, 403)
|
|
25
|
+
*/
|
|
26
|
+
export class SliceAuthenticationError extends SliceAPIError {
|
|
27
|
+
constructor(message, statusCode = 401, response) {
|
|
28
|
+
super(message, statusCode, response);
|
|
29
|
+
this.name = 'SliceAuthenticationError';
|
|
30
|
+
Object.setPrototypeOf(this, SliceAuthenticationError.prototype);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Error thrown when validation fails (400)
|
|
35
|
+
*/
|
|
36
|
+
export class SliceValidationError extends SliceAPIError {
|
|
37
|
+
constructor(message, response) {
|
|
38
|
+
super(message, 400, response);
|
|
39
|
+
this.name = 'SliceValidationError';
|
|
40
|
+
Object.setPrototypeOf(this, SliceValidationError.prototype);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Error thrown when a network error occurs
|
|
45
|
+
*/
|
|
46
|
+
export class SliceNetworkError extends SliceError {
|
|
47
|
+
constructor(message, originalError) {
|
|
48
|
+
super(message);
|
|
49
|
+
this.name = 'SliceNetworkError';
|
|
50
|
+
this.originalError = originalError;
|
|
51
|
+
Object.setPrototypeOf(this, SliceNetworkError.prototype);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Error thrown when a request times out
|
|
56
|
+
*/
|
|
57
|
+
export class SliceTimeoutError extends SliceError {
|
|
58
|
+
constructor(message = 'Request timeout') {
|
|
59
|
+
super(message);
|
|
60
|
+
this.name = 'SliceTimeoutError';
|
|
61
|
+
Object.setPrototypeOf(this, SliceTimeoutError.prototype);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAU;IAI3C,YAAY,OAAe,EAAE,UAAkB,EAAE,QAAc;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,aAAa;IACzD,YAAY,OAAe,EAAE,aAAqB,GAAG,EAAE,QAAc;QACnE,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAClE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,aAAa;IACrD,YAAY,OAAe,EAAE,QAAc;QACzC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAG/C,YAAY,OAAe,EAAE,aAAqB;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAC/C,YAAY,UAAkB,iBAAiB;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ValidateMethods } from './methods/validate';
|
|
2
|
+
import { UserMethods } from './methods/users';
|
|
3
|
+
import { LicenseMethods } from './methods/licenses';
|
|
4
|
+
import type { SliceClientOptions } from './types';
|
|
5
|
+
export type { Tenant, TenantApiKey, LaaSUser, Product, Plan, License, LicenseStatus, UserLicense, Activation, AuditLog, AuditLogAction, ValidateLicenseRequest, ValidateLicenseResponse, CreateUserRequest, AssignLicenseRequest, ApiResponse, SliceClientOptions, } from './types';
|
|
6
|
+
export { SliceError, SliceAPIError, SliceAuthenticationError, SliceValidationError, SliceNetworkError, SliceTimeoutError, } from './errors';
|
|
7
|
+
/**
|
|
8
|
+
* Slice Client - Main SDK class for interacting with the Slice LaaS API
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { SliceClient } from '@sliceapi/sdk';
|
|
13
|
+
*
|
|
14
|
+
* const client = new SliceClient('sk_live_...', {
|
|
15
|
+
* baseUrl: 'https://api.example.com'
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Validate a user's license
|
|
19
|
+
* const result = await client.validate.validate('user_123');
|
|
20
|
+
*
|
|
21
|
+
* // Create a user
|
|
22
|
+
* const user = await client.users.createUser({
|
|
23
|
+
* externalId: 'user_123',
|
|
24
|
+
* email: 'user@example.com'
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Assign a license
|
|
28
|
+
* const assignment = await client.licenses.assignLicense('license_123', 'user_123');
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class SliceClient {
|
|
32
|
+
private client;
|
|
33
|
+
readonly validate: ValidateMethods;
|
|
34
|
+
readonly users: UserMethods;
|
|
35
|
+
readonly licenses: LicenseMethods;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new SliceClient instance
|
|
38
|
+
*
|
|
39
|
+
* @param apiKey - Your Slice API key (starts with 'sk_live_' or 'sk_test_')
|
|
40
|
+
* @param options - Optional configuration
|
|
41
|
+
* @param options.baseUrl - Base URL for the API (defaults to process.env.SLICE_API_URL or 'http://localhost:3001')
|
|
42
|
+
* @param options.timeout - Request timeout in milliseconds (defaults to 30000)
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* // Using default settings
|
|
47
|
+
* const client = new SliceClient('sk_live_...');
|
|
48
|
+
*
|
|
49
|
+
* // With custom base URL
|
|
50
|
+
* const client = new SliceClient('sk_live_...', {
|
|
51
|
+
* baseUrl: 'https://api.example.com'
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* // Use method groups
|
|
55
|
+
* const result = await client.validate.validate('user_123');
|
|
56
|
+
* const user = await client.users.createUser({ externalId: 'user_123' });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
constructor(apiKey: string, options?: SliceClientOptions);
|
|
60
|
+
}
|
|
61
|
+
export default SliceClient;
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGlD,YAAY,EAEV,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,OAAO,EACP,aAAa,EACb,WAAW,EACX,UAAU,EACV,QAAQ,EACR,cAAc,EAGd,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EAGX,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,UAAU,EACV,aAAa,EACb,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAa;IAC3B,SAAgB,QAAQ,EAAE,eAAe,CAAC;IAC1C,SAAgB,KAAK,EAAE,WAAW,CAAC;IACnC,SAAgB,QAAQ,EAAE,cAAc,CAAC;IAEzC;;;;;;;;;;;;;;;;;;;;;;OAsBG;gBACS,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB;CAoBzD;AAGD,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { HttpClient } from './client';
|
|
2
|
+
import { ValidateMethods } from './methods/validate';
|
|
3
|
+
import { UserMethods } from './methods/users';
|
|
4
|
+
import { LicenseMethods } from './methods/licenses';
|
|
5
|
+
// Re-export error classes
|
|
6
|
+
export { SliceError, SliceAPIError, SliceAuthenticationError, SliceValidationError, SliceNetworkError, SliceTimeoutError, } from './errors';
|
|
7
|
+
/**
|
|
8
|
+
* Slice Client - Main SDK class for interacting with the Slice LaaS API
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { SliceClient } from '@sliceapi/sdk';
|
|
13
|
+
*
|
|
14
|
+
* const client = new SliceClient('sk_live_...', {
|
|
15
|
+
* baseUrl: 'https://api.example.com'
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Validate a user's license
|
|
19
|
+
* const result = await client.validate.validate('user_123');
|
|
20
|
+
*
|
|
21
|
+
* // Create a user
|
|
22
|
+
* const user = await client.users.createUser({
|
|
23
|
+
* externalId: 'user_123',
|
|
24
|
+
* email: 'user@example.com'
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Assign a license
|
|
28
|
+
* const assignment = await client.licenses.assignLicense('license_123', 'user_123');
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export class SliceClient {
|
|
32
|
+
/**
|
|
33
|
+
* Create a new SliceClient instance
|
|
34
|
+
*
|
|
35
|
+
* @param apiKey - Your Slice API key (starts with 'sk_live_' or 'sk_test_')
|
|
36
|
+
* @param options - Optional configuration
|
|
37
|
+
* @param options.baseUrl - Base URL for the API (defaults to process.env.SLICE_API_URL or 'http://localhost:3001')
|
|
38
|
+
* @param options.timeout - Request timeout in milliseconds (defaults to 30000)
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* // Using default settings
|
|
43
|
+
* const client = new SliceClient('sk_live_...');
|
|
44
|
+
*
|
|
45
|
+
* // With custom base URL
|
|
46
|
+
* const client = new SliceClient('sk_live_...', {
|
|
47
|
+
* baseUrl: 'https://api.example.com'
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* // Use method groups
|
|
51
|
+
* const result = await client.validate.validate('user_123');
|
|
52
|
+
* const user = await client.users.createUser({ externalId: 'user_123' });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
constructor(apiKey, options) {
|
|
56
|
+
// Determine base URL
|
|
57
|
+
let baseUrl = options?.baseUrl || 'http://localhost:3001';
|
|
58
|
+
if (!options?.baseUrl) {
|
|
59
|
+
// Check for process.env in Node.js environment
|
|
60
|
+
// @ts-ignore - process may not be defined in browser environments
|
|
61
|
+
const envUrl = typeof process !== 'undefined' && process?.env?.SLICE_API_URL;
|
|
62
|
+
if (envUrl) {
|
|
63
|
+
baseUrl = envUrl;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Create HTTP client
|
|
67
|
+
this.client = new HttpClient(apiKey, baseUrl, options?.timeout);
|
|
68
|
+
// Initialize method groups
|
|
69
|
+
this.validate = new ValidateMethods(this.client);
|
|
70
|
+
this.users = new UserMethods(this.client);
|
|
71
|
+
this.licenses = new LicenseMethods(this.client);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Default export
|
|
75
|
+
export default SliceClient;
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AA6BpD,0BAA0B;AAC1B,OAAO,EACL,UAAU,EACV,aAAa,EACb,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,WAAW;IAMtB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,YAAY,MAAc,EAAE,OAA4B;QACtD,qBAAqB;QACrB,IAAI,OAAO,GAAW,OAAO,EAAE,OAAO,IAAI,uBAAuB,CAAC;QAClE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;YACtB,+CAA+C;YAC/C,kEAAkE;YAClE,MAAM,MAAM,GAAG,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,EAAE,GAAG,EAAE,aAAa,CAAC;YAC7E,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,GAAG,MAAM,CAAC;YACnB,CAAC;QACH,CAAC;QAED,qBAAqB;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAEhE,2BAA2B;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClD,CAAC;CACF;AAED,iBAAiB;AACjB,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { HttpClient } from '../client';
|
|
2
|
+
import type { License, LicenseStatus, UserLicense } from '../types';
|
|
3
|
+
export declare class LicenseMethods {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: HttpClient);
|
|
6
|
+
/**
|
|
7
|
+
* Assign a license to a user
|
|
8
|
+
*
|
|
9
|
+
* @param licenseId - The license ID to assign
|
|
10
|
+
* @param userId - The user ID to assign the license to
|
|
11
|
+
* @param metadata - Optional metadata for the assignment
|
|
12
|
+
* @returns Promise resolving to the user-license relationship
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const assignment = await client.assignLicense('license_123', 'user_456', {
|
|
17
|
+
* source: 'admin_panel'
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
assignLicense(licenseId: string, userId: string, metadata?: Record<string, any>): Promise<UserLicense>;
|
|
22
|
+
/**
|
|
23
|
+
* Update a license's status
|
|
24
|
+
*
|
|
25
|
+
* @param licenseId - The license ID to update
|
|
26
|
+
* @param status - The new status for the license
|
|
27
|
+
* @returns Promise resolving to the updated license
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const license = await client.updateLicenseStatus('license_123', 'suspended');
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
updateLicenseStatus(licenseId: string, status: LicenseStatus): Promise<License>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=licenses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"licenses.d.ts","sourceRoot":"","sources":["../../../../src/methods/licenses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEpE,qBAAa,cAAc;IACb,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;;;;;;;;;;;;OAcG;IACG,aAAa,CACjB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC7B,OAAO,CAAC,WAAW,CAAC;IAiBvB;;;;;;;;;;;OAWG;IACG,mBAAmB,CACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,OAAO,CAAC;CAiBpB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export class LicenseMethods {
|
|
2
|
+
constructor(client) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Assign a license to a user
|
|
7
|
+
*
|
|
8
|
+
* @param licenseId - The license ID to assign
|
|
9
|
+
* @param userId - The user ID to assign the license to
|
|
10
|
+
* @param metadata - Optional metadata for the assignment
|
|
11
|
+
* @returns Promise resolving to the user-license relationship
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const assignment = await client.assignLicense('license_123', 'user_456', {
|
|
16
|
+
* source: 'admin_panel'
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
async assignLicense(licenseId, userId, metadata) {
|
|
21
|
+
if (!licenseId || typeof licenseId !== 'string') {
|
|
22
|
+
throw new Error('licenseId must be a non-empty string');
|
|
23
|
+
}
|
|
24
|
+
if (!userId || typeof userId !== 'string') {
|
|
25
|
+
throw new Error('userId must be a non-empty string');
|
|
26
|
+
}
|
|
27
|
+
const response = await this.client.post(`/api/v1/admin/licenses/${encodeURIComponent(licenseId)}/assign`, { userId, metadata });
|
|
28
|
+
return response.data;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Update a license's status
|
|
32
|
+
*
|
|
33
|
+
* @param licenseId - The license ID to update
|
|
34
|
+
* @param status - The new status for the license
|
|
35
|
+
* @returns Promise resolving to the updated license
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const license = await client.updateLicenseStatus('license_123', 'suspended');
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
async updateLicenseStatus(licenseId, status) {
|
|
43
|
+
if (!licenseId || typeof licenseId !== 'string') {
|
|
44
|
+
throw new Error('licenseId must be a non-empty string');
|
|
45
|
+
}
|
|
46
|
+
const validStatuses = ['active', 'suspended', 'revoked', 'expired'];
|
|
47
|
+
if (!validStatuses.includes(status)) {
|
|
48
|
+
throw new Error(`status must be one of: ${validStatuses.join(', ')}`);
|
|
49
|
+
}
|
|
50
|
+
const response = await this.client.patch(`/api/v1/admin/licenses/${encodeURIComponent(licenseId)}/status`, { status });
|
|
51
|
+
return response.data;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=licenses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"licenses.js","sourceRoot":"","sources":["../../../../src/methods/licenses.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,cAAc;IACzB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE1C;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,aAAa,CACjB,SAAiB,EACjB,MAAc,EACd,QAA8B;QAE9B,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,CAAC;QAED,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrC,0BAA0B,kBAAkB,CAAC,SAAS,CAAC,SAAS,EAChE,EAAE,MAAM,EAAE,QAAQ,EAAE,CACrB,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,mBAAmB,CACvB,SAAiB,EACjB,MAAqB;QAErB,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,CAAC;QAED,MAAM,aAAa,GAAoB,CAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QACrF,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,0BAA0B,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CACtC,0BAA0B,kBAAkB,CAAC,SAAS,CAAC,SAAS,EAChE,EAAE,MAAM,EAAE,CACX,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HttpClient } from '../client';
|
|
2
|
+
import type { CreateUserRequest, LaaSUser } from '../types';
|
|
3
|
+
export declare class UserMethods {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: HttpClient);
|
|
6
|
+
/**
|
|
7
|
+
* Create a new user
|
|
8
|
+
*
|
|
9
|
+
* @param params - User creation parameters
|
|
10
|
+
* @param params.externalId - The tenant's internal user ID (required)
|
|
11
|
+
* @param params.email - User's email address (optional)
|
|
12
|
+
* @param params.name - User's name (optional)
|
|
13
|
+
* @param params.metadata - Additional metadata (optional)
|
|
14
|
+
* @returns Promise resolving to the created user
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const user = await client.createUser({
|
|
19
|
+
* externalId: 'user_123',
|
|
20
|
+
* email: 'user@example.com',
|
|
21
|
+
* name: 'John Doe'
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
createUser(params: CreateUserRequest): Promise<LaaSUser>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=users.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../../src/methods/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE5D,qBAAa,WAAW;IACV,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;;;;;;;;;;;;;;;;OAkBG;IACG,UAAU,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC;CAY/D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class UserMethods {
|
|
2
|
+
constructor(client) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Create a new user
|
|
7
|
+
*
|
|
8
|
+
* @param params - User creation parameters
|
|
9
|
+
* @param params.externalId - The tenant's internal user ID (required)
|
|
10
|
+
* @param params.email - User's email address (optional)
|
|
11
|
+
* @param params.name - User's name (optional)
|
|
12
|
+
* @param params.metadata - Additional metadata (optional)
|
|
13
|
+
* @returns Promise resolving to the created user
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const user = await client.createUser({
|
|
18
|
+
* externalId: 'user_123',
|
|
19
|
+
* email: 'user@example.com',
|
|
20
|
+
* name: 'John Doe'
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
async createUser(params) {
|
|
25
|
+
if (!params.externalId || typeof params.externalId !== 'string') {
|
|
26
|
+
throw new Error('externalId must be a non-empty string');
|
|
27
|
+
}
|
|
28
|
+
const response = await this.client.post('/api/v1/admin/users', params);
|
|
29
|
+
return response.data;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=users.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.js","sourceRoot":"","sources":["../../../../src/methods/users.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,WAAW;IACtB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE1C;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,UAAU,CAAC,MAAyB;QACxC,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;YAChE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3D,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrC,qBAAqB,EACrB,MAAM,CACP,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { HttpClient } from '../client';
|
|
2
|
+
import type { ValidateLicenseResponse } from '../types';
|
|
3
|
+
export declare class ValidateMethods {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: HttpClient);
|
|
6
|
+
/**
|
|
7
|
+
* Validate a user's license
|
|
8
|
+
*
|
|
9
|
+
* @param userId - The tenant's internal user ID
|
|
10
|
+
* @returns Promise resolving to the validation response
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const result = await client.validate('user_123');
|
|
15
|
+
* if (result.valid) {
|
|
16
|
+
* console.log('License is valid:', result.license);
|
|
17
|
+
* } else {
|
|
18
|
+
* console.log('License invalid:', result.reason);
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
validate(userId: string): Promise<ValidateLicenseResponse>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/methods/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD,qBAAa,eAAe;IACd,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;;;;;;;;;;;;;OAeG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAYjE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export class ValidateMethods {
|
|
2
|
+
constructor(client) {
|
|
3
|
+
this.client = client;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Validate a user's license
|
|
7
|
+
*
|
|
8
|
+
* @param userId - The tenant's internal user ID
|
|
9
|
+
* @returns Promise resolving to the validation response
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const result = await client.validate('user_123');
|
|
14
|
+
* if (result.valid) {
|
|
15
|
+
* console.log('License is valid:', result.license);
|
|
16
|
+
* } else {
|
|
17
|
+
* console.log('License invalid:', result.reason);
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
async validate(userId) {
|
|
22
|
+
if (!userId || typeof userId !== 'string') {
|
|
23
|
+
throw new Error('userId must be a non-empty string');
|
|
24
|
+
}
|
|
25
|
+
const response = await this.client.post('/api/v1/validate', { userId });
|
|
26
|
+
return response.data;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../../src/methods/validate.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,eAAe;IAC1B,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE1C;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,QAAQ,CAAC,MAAc;QAC3B,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACrC,kBAAkB,EAClB,EAAE,MAAM,EAAE,CACX,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type { Tenant, TenantApiKey, LaaSUser, Product, Plan, License, LicenseStatus, UserLicense, Activation, AuditLog, AuditLogAction, ValidateLicenseRequest, ValidateLicenseResponse, CreateUserRequest, AssignLicenseRequest, ApiResponse, } from '../../shared/api-types';
|
|
2
|
+
export interface SliceClientOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Base URL for the API (defaults to process.env.SLICE_API_URL or 'http://localhost:3001')
|
|
5
|
+
*/
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Timeout for requests in milliseconds (defaults to 30000)
|
|
9
|
+
*/
|
|
10
|
+
timeout?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface SliceRequestOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Additional headers to include in the request
|
|
15
|
+
*/
|
|
16
|
+
headers?: Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Request timeout in milliseconds
|
|
19
|
+
*/
|
|
20
|
+
timeout?: number;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AACA,YAAY,EAEV,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,OAAO,EACP,aAAa,EACb,WAAW,EACX,UAAU,EACV,QAAQ,EACR,cAAc,EAGd,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAGhC,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":""}
|