oblien 1.3.0 → 2.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 +482 -422
- package/dist/client.d.ts +31 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +33 -0
- package/dist/client.js.map +1 -0
- package/dist/error.d.ts +29 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +52 -0
- package/dist/error.js.map +1 -0
- package/dist/http.d.ts +20 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +108 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/api-access.d.ts +21 -0
- package/dist/resources/api-access.d.ts.map +1 -0
- package/dist/resources/api-access.js +32 -0
- package/dist/resources/api-access.js.map +1 -0
- package/dist/resources/base.d.ts +17 -0
- package/dist/resources/base.d.ts.map +1 -0
- package/dist/resources/base.js +21 -0
- package/dist/resources/base.js.map +1 -0
- package/dist/resources/images.d.ts +11 -0
- package/dist/resources/images.d.ts.map +1 -0
- package/dist/resources/images.js +16 -0
- package/dist/resources/images.js.map +1 -0
- package/dist/resources/lifecycle.d.ts +23 -0
- package/dist/resources/lifecycle.d.ts.map +1 -0
- package/dist/resources/lifecycle.js +32 -0
- package/dist/resources/lifecycle.js.map +1 -0
- package/dist/resources/logs.d.ts +25 -0
- package/dist/resources/logs.d.ts.map +1 -0
- package/dist/resources/logs.js +51 -0
- package/dist/resources/logs.js.map +1 -0
- package/dist/resources/metadata.d.ts +15 -0
- package/dist/resources/metadata.d.ts.map +1 -0
- package/dist/resources/metadata.js +20 -0
- package/dist/resources/metadata.js.map +1 -0
- package/dist/resources/metrics.d.ts +17 -0
- package/dist/resources/metrics.d.ts.map +1 -0
- package/dist/resources/metrics.js +27 -0
- package/dist/resources/metrics.js.map +1 -0
- package/dist/resources/network.d.ts +17 -0
- package/dist/resources/network.d.ts.map +1 -0
- package/dist/resources/network.js +20 -0
- package/dist/resources/network.js.map +1 -0
- package/dist/resources/public-access.d.ts +15 -0
- package/dist/resources/public-access.d.ts.map +1 -0
- package/dist/resources/public-access.js +21 -0
- package/dist/resources/public-access.js.map +1 -0
- package/dist/resources/resources.d.ts +15 -0
- package/dist/resources/resources.d.ts.map +1 -0
- package/dist/resources/resources.js +20 -0
- package/dist/resources/resources.js.map +1 -0
- package/dist/resources/snapshots.d.ts +27 -0
- package/dist/resources/snapshots.d.ts.map +1 -0
- package/dist/resources/snapshots.js +45 -0
- package/dist/resources/snapshots.js.map +1 -0
- package/dist/resources/ssh.d.ts +19 -0
- package/dist/resources/ssh.d.ts.map +1 -0
- package/dist/resources/ssh.js +28 -0
- package/dist/resources/ssh.js.map +1 -0
- package/dist/resources/usage.d.ts +25 -0
- package/dist/resources/usage.d.ts.map +1 -0
- package/dist/resources/usage.js +44 -0
- package/dist/resources/usage.js.map +1 -0
- package/dist/resources/workloads.d.ts +39 -0
- package/dist/resources/workloads.d.ts.map +1 -0
- package/dist/resources/workloads.js +83 -0
- package/dist/resources/workloads.js.map +1 -0
- package/dist/runtime/exec.d.ts +71 -0
- package/dist/runtime/exec.d.ts.map +1 -0
- package/dist/runtime/exec.js +163 -0
- package/dist/runtime/exec.js.map +1 -0
- package/dist/runtime/files.d.ts +39 -0
- package/dist/runtime/files.d.ts.map +1 -0
- package/dist/runtime/files.js +143 -0
- package/dist/runtime/files.js.map +1 -0
- package/dist/runtime/search.d.ts +23 -0
- package/dist/runtime/search.d.ts.map +1 -0
- package/dist/runtime/search.js +65 -0
- package/dist/runtime/search.js.map +1 -0
- package/dist/runtime/terminal.d.ts +29 -0
- package/dist/runtime/terminal.d.ts.map +1 -0
- package/dist/runtime/terminal.js +58 -0
- package/dist/runtime/terminal.js.map +1 -0
- package/dist/runtime/watcher.d.ts +27 -0
- package/dist/runtime/watcher.d.ts.map +1 -0
- package/dist/runtime/watcher.js +53 -0
- package/dist/runtime/watcher.js.map +1 -0
- package/dist/runtime/ws.d.ts +92 -0
- package/dist/runtime/ws.d.ts.map +1 -0
- package/dist/runtime/ws.js +228 -0
- package/dist/runtime/ws.js.map +1 -0
- package/dist/runtime-http.d.ts +35 -0
- package/dist/runtime-http.d.ts.map +1 -0
- package/dist/runtime-http.js +99 -0
- package/dist/runtime-http.js.map +1 -0
- package/dist/runtime.d.ts +77 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +97 -0
- package/dist/runtime.js.map +1 -0
- package/dist/types/client.d.ts +7 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/client.js +3 -0
- package/dist/types/client.js.map +1 -0
- package/dist/types/common.d.ts +13 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +3 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/network.d.ts +15 -0
- package/dist/types/network.d.ts.map +1 -0
- package/dist/types/network.js +3 -0
- package/dist/types/network.js.map +1 -0
- package/dist/types/resources.d.ts +10 -0
- package/dist/types/resources.d.ts.map +1 -0
- package/dist/types/resources.js +3 -0
- package/dist/types/resources.js.map +1 -0
- package/dist/types/runtime.d.ts +302 -0
- package/dist/types/runtime.d.ts.map +1 -0
- package/dist/types/runtime.js +3 -0
- package/dist/types/runtime.js.map +1 -0
- package/dist/types/workspace-resources.d.ts +186 -0
- package/dist/types/workspace-resources.d.ts.map +1 -0
- package/dist/types/workspace-resources.js +3 -0
- package/dist/types/workspace-resources.js.map +1 -0
- package/dist/types/workspace.d.ts +41 -0
- package/dist/types/workspace.d.ts.map +1 -0
- package/dist/types/workspace.js +3 -0
- package/dist/types/workspace.js.map +1 -0
- package/dist/workspace.d.ts +135 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +194 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +30 -69
- package/LICENSE +0 -21
- package/agents.js +0 -14
- package/browser.js +0 -6
- package/cdn.js +0 -6
- package/chat.js +0 -21
- package/credits.js +0 -11
- package/icons.js +0 -11
- package/index.d.ts +0 -986
- package/index.js +0 -63
- package/namespaces.js +0 -12
- package/sandbox.js +0 -12
- package/search.js +0 -11
- package/src/agents/agent.js +0 -229
- package/src/agents/index.js +0 -227
- package/src/agents/settings.js +0 -100
- package/src/agents/tools.js +0 -155
- package/src/browser/index.js +0 -474
- package/src/cdn/index.js +0 -769
- package/src/chat/index.js +0 -724
- package/src/chat/session.js +0 -93
- package/src/client.js +0 -175
- package/src/credits/index.js +0 -492
- package/src/icons/index.js +0 -185
- package/src/namespaces/index.js +0 -236
- package/src/namespaces/namespace.js +0 -274
- package/src/sandbox/core/api/base.js +0 -89
- package/src/sandbox/core/api/database.js +0 -340
- package/src/sandbox/core/api/files.js +0 -141
- package/src/sandbox/core/api/git.js +0 -174
- package/src/sandbox/core/api/search.js +0 -29
- package/src/sandbox/core/api/snapshots.js +0 -132
- package/src/sandbox/core/api/terminal.js +0 -20
- package/src/sandbox/core/auth.js +0 -256
- package/src/sandbox/core/client.js +0 -197
- package/src/sandbox/core/index.js +0 -22
- package/src/sandbox/core/managers/terminal.js +0 -453
- package/src/sandbox/core/managers/watcher.js +0 -197
- package/src/sandbox/core/types.js +0 -92
- package/src/sandbox/core/utils/http.js +0 -89
- package/src/sandbox/core/websocket/connection.js +0 -479
- package/src/sandbox/index.d.ts +0 -542
- package/src/sandbox/index.js +0 -234
- package/src/sandbox/sandbox.js +0 -313
- package/src/search/index.js +0 -206
- package/src/utils/guest-manager.js +0 -454
package/src/namespaces/index.js
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Namespaces Module
|
|
3
|
-
* Manages namespaces, service configurations, and usage tracking
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { OblienClient } from '../client.js';
|
|
7
|
-
import { Namespace } from './namespace.js';
|
|
8
|
-
|
|
9
|
-
export class OblienNamespaces {
|
|
10
|
-
/**
|
|
11
|
-
* @param {import('../client.js').OblienClient|Object} clientOrConfig - Oblien client instance or { clientId, clientSecret }
|
|
12
|
-
*/
|
|
13
|
-
constructor(clientOrConfig) {
|
|
14
|
-
if (!clientOrConfig) {
|
|
15
|
-
throw new Error('Either provide OblienClient instance or { clientId, clientSecret }');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// If it's already a client instance
|
|
19
|
-
if (clientOrConfig.clientId && clientOrConfig.clientSecret && typeof clientOrConfig.get === 'function') {
|
|
20
|
-
this.client = clientOrConfig;
|
|
21
|
-
}
|
|
22
|
-
// If credentials provided, create client
|
|
23
|
-
else if (clientOrConfig.clientId && clientOrConfig.clientSecret) {
|
|
24
|
-
this.client = new OblienClient(clientOrConfig);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
throw new Error('Either provide OblienClient instance or { clientId, clientSecret }');
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Create a new namespace
|
|
33
|
-
* @param {Object} options - Namespace options
|
|
34
|
-
* @param {string} options.name - Namespace name (required)
|
|
35
|
-
* @param {string} [options.slug] - URL-friendly slug
|
|
36
|
-
* @param {string} [options.description] - Description
|
|
37
|
-
* @param {string} [options.type] - Type: 'default', 'production', 'testing', 'development'
|
|
38
|
-
* @param {boolean} [options.isDefault] - Is default namespace
|
|
39
|
-
* @param {Object} [options.metadata] - Custom metadata
|
|
40
|
-
* @param {Array<string>} [options.tags] - Tags
|
|
41
|
-
* @param {string} [options.endUserId] - End user ID
|
|
42
|
-
* @returns {Promise<Object>} Created namespace data
|
|
43
|
-
*/
|
|
44
|
-
async create(options) {
|
|
45
|
-
const namespace = new Namespace({ client: this.client });
|
|
46
|
-
return await namespace.create(options);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Get namespace by ID or slug
|
|
51
|
-
* @param {string} identifier - Namespace ID or slug
|
|
52
|
-
* @returns {Promise<Object>} Namespace data
|
|
53
|
-
*/
|
|
54
|
-
async get(identifier) {
|
|
55
|
-
const namespace = new Namespace({ client: this.client });
|
|
56
|
-
return await namespace.get(identifier);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* List all namespaces with filtering and pagination
|
|
61
|
-
* @param {Object} [options] - Query options
|
|
62
|
-
* @param {number} [options.limit] - Max results (default: 50, max: 100)
|
|
63
|
-
* @param {number} [options.offset] - Offset for pagination
|
|
64
|
-
* @param {string} [options.status] - Filter by status: 'active', 'inactive', 'suspended', 'archived'
|
|
65
|
-
* @param {string} [options.type] - Filter by type: 'default', 'production', 'testing', 'development'
|
|
66
|
-
* @param {string} [options.search] - Search in name, slug, description
|
|
67
|
-
* @param {string} [options.sortBy] - Sort by: 'name', 'created_at', 'updated_at', 'last_active_at'
|
|
68
|
-
* @param {string} [options.sortOrder] - Sort order: 'ASC', 'DESC'
|
|
69
|
-
* @returns {Promise<Object>} Namespaces data with pagination info
|
|
70
|
-
*/
|
|
71
|
-
async list(options = {}) {
|
|
72
|
-
const response = await this.client.get('namespaces', options);
|
|
73
|
-
return response;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Update namespace
|
|
78
|
-
* @param {string} namespaceId - Namespace ID
|
|
79
|
-
* @param {Object} updates - Fields to update
|
|
80
|
-
* @returns {Promise<Object>} Updated namespace data
|
|
81
|
-
*/
|
|
82
|
-
async update(namespaceId, updates) {
|
|
83
|
-
const namespace = new Namespace({ client: this.client, namespaceId });
|
|
84
|
-
return await namespace.update(updates);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Delete (archive) namespace
|
|
89
|
-
* @param {string} namespaceId - Namespace ID
|
|
90
|
-
* @returns {Promise<Object>} Deletion result
|
|
91
|
-
*/
|
|
92
|
-
async delete(namespaceId) {
|
|
93
|
-
const namespace = new Namespace({ client: this.client, namespaceId });
|
|
94
|
-
return await namespace.delete();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Get namespace activity log
|
|
99
|
-
* @param {string} namespaceId - Namespace ID
|
|
100
|
-
* @param {Object} [options] - Query options
|
|
101
|
-
* @param {number} [options.limit] - Number of activities (default: 50)
|
|
102
|
-
* @param {number} [options.offset] - Offset for pagination
|
|
103
|
-
* @returns {Promise<Array>} Array of activity logs
|
|
104
|
-
*/
|
|
105
|
-
async getActivity(namespaceId, options = {}) {
|
|
106
|
-
const namespace = new Namespace({ client: this.client, namespaceId });
|
|
107
|
-
return await namespace.getActivity(options);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Get namespace usage statistics
|
|
112
|
-
* @param {string} namespaceId - Namespace ID
|
|
113
|
-
* @param {Object} [options] - Query options
|
|
114
|
-
* @param {string} [options.service] - Filter by service
|
|
115
|
-
* @param {number} [options.days] - Number of days (default: 30)
|
|
116
|
-
* @returns {Promise<Object>} Usage statistics
|
|
117
|
-
*/
|
|
118
|
-
async getUsage(namespaceId, options = {}) {
|
|
119
|
-
const namespace = new Namespace({ client: this.client, namespaceId });
|
|
120
|
-
return await namespace.getUsage(options);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Get available services
|
|
125
|
-
* @returns {Promise<Array>} Array of available services
|
|
126
|
-
*/
|
|
127
|
-
async getAvailableServices() {
|
|
128
|
-
const response = await this.client.get('namespaces/services/available');
|
|
129
|
-
return response.data || response;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Configure a service for a namespace
|
|
134
|
-
* @param {string} namespaceId - Namespace ID
|
|
135
|
-
* @param {Object} options - Service configuration
|
|
136
|
-
* @param {string} options.service - Service name (required)
|
|
137
|
-
* @param {boolean} [options.enabled] - Enable/disable service
|
|
138
|
-
* @param {Object} [options.config] - Service-specific configuration
|
|
139
|
-
* @param {number} [options.rateLimitRequests] - Rate limit requests
|
|
140
|
-
* @param {string} [options.rateLimitPeriod] - Rate limit period
|
|
141
|
-
* @param {Array<string>} [options.features] - Enabled features
|
|
142
|
-
* @returns {Promise<Object>} Service configuration
|
|
143
|
-
*/
|
|
144
|
-
async configureService(namespaceId, options) {
|
|
145
|
-
const namespace = new Namespace({ client: this.client, namespaceId });
|
|
146
|
-
return await namespace.configureService(options);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* List all services for a namespace
|
|
151
|
-
* @param {string} namespaceId - Namespace ID
|
|
152
|
-
* @returns {Promise<Array>} Array of service configurations
|
|
153
|
-
*/
|
|
154
|
-
async listServices(namespaceId) {
|
|
155
|
-
const namespace = new Namespace({ client: this.client, namespaceId });
|
|
156
|
-
return await namespace.listServices();
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Get specific service configuration
|
|
161
|
-
* @param {string} namespaceId - Namespace ID
|
|
162
|
-
* @param {string} service - Service name
|
|
163
|
-
* @returns {Promise<Object>} Service configuration
|
|
164
|
-
*/
|
|
165
|
-
async getServiceConfig(namespaceId, service) {
|
|
166
|
-
const namespace = new Namespace({ client: this.client, namespaceId });
|
|
167
|
-
return await namespace.getServiceConfig(service);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Toggle service enabled/disabled
|
|
172
|
-
* @param {string} namespaceId - Namespace ID
|
|
173
|
-
* @param {string} service - Service name
|
|
174
|
-
* @param {boolean} enabled - Enable or disable
|
|
175
|
-
* @returns {Promise<Object>} Updated service configuration
|
|
176
|
-
*/
|
|
177
|
-
async toggleService(namespaceId, service, enabled) {
|
|
178
|
-
const namespace = new Namespace({ client: this.client, namespaceId });
|
|
179
|
-
return await namespace.toggleService(service, enabled);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Enable a service for a namespace
|
|
184
|
-
* @param {string} namespaceId - Namespace ID
|
|
185
|
-
* @param {string} service - Service name
|
|
186
|
-
* @returns {Promise<Object>} Updated service configuration
|
|
187
|
-
*/
|
|
188
|
-
async enableService(namespaceId, service) {
|
|
189
|
-
return await this.toggleService(namespaceId, service, true);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Disable a service for a namespace
|
|
194
|
-
* @param {string} namespaceId - Namespace ID
|
|
195
|
-
* @param {string} service - Service name
|
|
196
|
-
* @returns {Promise<Object>} Updated service configuration
|
|
197
|
-
*/
|
|
198
|
-
async disableService(namespaceId, service) {
|
|
199
|
-
return await this.toggleService(namespaceId, service, false);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Delete service configuration
|
|
204
|
-
* @param {string} namespaceId - Namespace ID
|
|
205
|
-
* @param {string} service - Service name
|
|
206
|
-
* @returns {Promise<Object>} Deletion result
|
|
207
|
-
*/
|
|
208
|
-
async deleteService(namespaceId, service) {
|
|
209
|
-
const namespace = new Namespace({ client: this.client, namespaceId });
|
|
210
|
-
return await namespace.deleteService(service);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Bulk configure multiple services
|
|
215
|
-
* @param {string} namespaceId - Namespace ID
|
|
216
|
-
* @param {Array<Object>} services - Array of service configurations
|
|
217
|
-
* @returns {Promise<Array>} Array of configured services
|
|
218
|
-
*/
|
|
219
|
-
async bulkConfigureServices(namespaceId, services) {
|
|
220
|
-
const namespace = new Namespace({ client: this.client, namespaceId });
|
|
221
|
-
return await namespace.bulkConfigureServices(services);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Create a Namespace instance for chaining operations
|
|
226
|
-
* @param {string} [namespaceId] - Namespace ID
|
|
227
|
-
* @returns {Namespace} Namespace instance
|
|
228
|
-
*/
|
|
229
|
-
namespace(namespaceId) {
|
|
230
|
-
return new Namespace({ client: this.client, namespaceId });
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
export { Namespace };
|
|
235
|
-
export default OblienNamespaces;
|
|
236
|
-
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Namespace Entity Manager
|
|
3
|
-
* Manages individual namespace operations
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export class Namespace {
|
|
7
|
-
/**
|
|
8
|
-
* @param {Object} options - Namespace options
|
|
9
|
-
* @param {import('../client.js').OblienClient} options.client - Oblien client instance
|
|
10
|
-
* @param {string} [options.namespaceId] - Existing namespace ID
|
|
11
|
-
* @param {Object} [options.data] - Namespace data
|
|
12
|
-
*/
|
|
13
|
-
constructor(options) {
|
|
14
|
-
if (!options.client) {
|
|
15
|
-
throw new Error('Oblien client is required');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
this.client = options.client;
|
|
19
|
-
this.namespaceId = options.namespaceId || null;
|
|
20
|
-
this.data = options.data || null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Create a new namespace
|
|
25
|
-
* @param {Object} options - Namespace options
|
|
26
|
-
* @param {string} options.name - Namespace name (required)
|
|
27
|
-
* @param {string} [options.slug] - URL-friendly slug (auto-generated from name if not provided)
|
|
28
|
-
* @param {string} [options.description] - Namespace description
|
|
29
|
-
* @param {string} [options.type] - Type: 'default', 'production', 'testing', 'development'
|
|
30
|
-
* @param {boolean} [options.isDefault] - Is this the default namespace
|
|
31
|
-
* @param {Object} [options.metadata] - Custom metadata object
|
|
32
|
-
* @param {Array<string>} [options.tags] - Array of tags
|
|
33
|
-
* @param {string} [options.endUserId] - End user ID (creator)
|
|
34
|
-
* @returns {Promise<Object>} Created namespace data
|
|
35
|
-
*/
|
|
36
|
-
async create(options) {
|
|
37
|
-
if (!options.name) {
|
|
38
|
-
throw new Error('Namespace name is required');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const payload = {
|
|
42
|
-
name: options.name,
|
|
43
|
-
slug: options.slug,
|
|
44
|
-
description: options.description,
|
|
45
|
-
type: options.type || 'default',
|
|
46
|
-
isDefault: options.isDefault || false,
|
|
47
|
-
metadata: options.metadata || {},
|
|
48
|
-
tags: options.tags || [],
|
|
49
|
-
endUserId: options.endUserId,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const response = await this.client.post('namespaces', payload);
|
|
53
|
-
this.data = response.data;
|
|
54
|
-
this.namespaceId = this.data.id;
|
|
55
|
-
|
|
56
|
-
return this.data;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Get namespace details
|
|
61
|
-
* @param {string} [identifier] - Namespace ID or slug (uses instance namespaceId if not provided)
|
|
62
|
-
* @returns {Promise<Object>} Namespace data
|
|
63
|
-
*/
|
|
64
|
-
async get(identifier) {
|
|
65
|
-
const id = identifier || this.namespaceId;
|
|
66
|
-
if (!id) {
|
|
67
|
-
throw new Error('Namespace ID or slug is required');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const response = await this.client.get(`namespaces/${id}`);
|
|
71
|
-
this.data = response.data;
|
|
72
|
-
this.namespaceId = this.data.id;
|
|
73
|
-
|
|
74
|
-
return this.data;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Update namespace
|
|
79
|
-
* @param {Object} updates - Fields to update
|
|
80
|
-
* @param {string} [updates.name] - New name
|
|
81
|
-
* @param {string} [updates.description] - New description
|
|
82
|
-
* @param {string} [updates.status] - New status: 'active', 'inactive', 'suspended', 'archived'
|
|
83
|
-
* @param {string} [updates.type] - New type
|
|
84
|
-
* @param {Object} [updates.metadata] - New metadata
|
|
85
|
-
* @param {Array<string>} [updates.tags] - New tags
|
|
86
|
-
* @param {string} [namespaceId] - Namespace ID (uses instance namespaceId if not provided)
|
|
87
|
-
* @returns {Promise<Object>} Updated namespace data
|
|
88
|
-
*/
|
|
89
|
-
async update(updates, namespaceId) {
|
|
90
|
-
const id = namespaceId || this.namespaceId;
|
|
91
|
-
if (!id) {
|
|
92
|
-
throw new Error('Namespace ID is required');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const response = await this.client.put(`namespaces/${id}`, updates);
|
|
96
|
-
this.data = response.data;
|
|
97
|
-
|
|
98
|
-
return this.data;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Delete (archive) namespace
|
|
103
|
-
* @param {string} [namespaceId] - Namespace ID (uses instance namespaceId if not provided)
|
|
104
|
-
* @returns {Promise<Object>} Deletion result
|
|
105
|
-
*/
|
|
106
|
-
async delete(namespaceId) {
|
|
107
|
-
const id = namespaceId || this.namespaceId;
|
|
108
|
-
if (!id) {
|
|
109
|
-
throw new Error('Namespace ID is required');
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return await this.client.delete(`namespaces/${id}`);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Get namespace activity log
|
|
117
|
-
* @param {Object} [options] - Query options
|
|
118
|
-
* @param {number} [options.limit] - Number of activities to return (default: 50)
|
|
119
|
-
* @param {number} [options.offset] - Offset for pagination
|
|
120
|
-
* @param {string} [namespaceId] - Namespace ID (uses instance namespaceId if not provided)
|
|
121
|
-
* @returns {Promise<Array>} Array of activity logs
|
|
122
|
-
*/
|
|
123
|
-
async getActivity(options = {}, namespaceId) {
|
|
124
|
-
const id = namespaceId || this.namespaceId;
|
|
125
|
-
if (!id) {
|
|
126
|
-
throw new Error('Namespace ID is required');
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const response = await this.client.get(`namespaces/${id}/activity`, options);
|
|
130
|
-
return response.data || response;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Get namespace usage statistics
|
|
135
|
-
* @param {Object} [options] - Query options
|
|
136
|
-
* @param {string} [options.service] - Filter by specific service
|
|
137
|
-
* @param {number} [options.days] - Number of days to include (default: 30)
|
|
138
|
-
* @param {string} [namespaceId] - Namespace ID (uses instance namespaceId if not provided)
|
|
139
|
-
* @returns {Promise<Object>} Usage statistics
|
|
140
|
-
*/
|
|
141
|
-
async getUsage(options = {}, namespaceId) {
|
|
142
|
-
const id = namespaceId || this.namespaceId;
|
|
143
|
-
if (!id) {
|
|
144
|
-
throw new Error('Namespace ID is required');
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const response = await this.client.get(`namespaces/${id}/usage`, options);
|
|
148
|
-
return response.data || response;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Configure a service for this namespace
|
|
153
|
-
* @param {Object} options - Service configuration
|
|
154
|
-
* @param {string} options.service - Service name (required)
|
|
155
|
-
* @param {boolean} [options.enabled] - Enable/disable service
|
|
156
|
-
* @param {Object} [options.config] - Service-specific configuration
|
|
157
|
-
* @param {number} [options.rateLimitRequests] - Rate limit requests per period
|
|
158
|
-
* @param {string} [options.rateLimitPeriod] - Rate limit period: 'minute', 'hour', 'day'
|
|
159
|
-
* @param {Array<string>} [options.features] - Enabled features
|
|
160
|
-
* @param {string} [namespaceId] - Namespace ID (uses instance namespaceId if not provided)
|
|
161
|
-
* @returns {Promise<Object>} Service configuration
|
|
162
|
-
*/
|
|
163
|
-
async configureService(options, namespaceId) {
|
|
164
|
-
const id = namespaceId || this.namespaceId;
|
|
165
|
-
if (!id) {
|
|
166
|
-
throw new Error('Namespace ID is required');
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (!options.service) {
|
|
170
|
-
throw new Error('Service name is required');
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const response = await this.client.post(`namespaces/${id}/services`, options);
|
|
174
|
-
return response.data || response;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* List all services for this namespace
|
|
179
|
-
* @param {string} [namespaceId] - Namespace ID (uses instance namespaceId if not provided)
|
|
180
|
-
* @returns {Promise<Array>} Array of service configurations
|
|
181
|
-
*/
|
|
182
|
-
async listServices(namespaceId) {
|
|
183
|
-
const id = namespaceId || this.namespaceId;
|
|
184
|
-
if (!id) {
|
|
185
|
-
throw new Error('Namespace ID is required');
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const response = await this.client.get(`namespaces/${id}/services`);
|
|
189
|
-
return response.data || response;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Get specific service configuration
|
|
194
|
-
* @param {string} service - Service name
|
|
195
|
-
* @param {string} [namespaceId] - Namespace ID (uses instance namespaceId if not provided)
|
|
196
|
-
* @returns {Promise<Object>} Service configuration
|
|
197
|
-
*/
|
|
198
|
-
async getServiceConfig(service, namespaceId) {
|
|
199
|
-
const id = namespaceId || this.namespaceId;
|
|
200
|
-
if (!id) {
|
|
201
|
-
throw new Error('Namespace ID is required');
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (!service) {
|
|
205
|
-
throw new Error('Service name is required');
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const response = await this.client.get(`namespaces/${id}/services/${service}`);
|
|
209
|
-
return response.data || response;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Toggle service enabled/disabled
|
|
214
|
-
* @param {string} service - Service name
|
|
215
|
-
* @param {boolean} enabled - Enable or disable
|
|
216
|
-
* @param {string} [namespaceId] - Namespace ID (uses instance namespaceId if not provided)
|
|
217
|
-
* @returns {Promise<Object>} Updated service configuration
|
|
218
|
-
*/
|
|
219
|
-
async toggleService(service, enabled, namespaceId) {
|
|
220
|
-
const id = namespaceId || this.namespaceId;
|
|
221
|
-
if (!id) {
|
|
222
|
-
throw new Error('Namespace ID is required');
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (!service) {
|
|
226
|
-
throw new Error('Service name is required');
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
const response = await this.client.patch(`namespaces/${id}/services/${service}/toggle`, { enabled });
|
|
230
|
-
return response.data || response;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Delete service configuration
|
|
235
|
-
* @param {string} service - Service name
|
|
236
|
-
* @param {string} [namespaceId] - Namespace ID (uses instance namespaceId if not provided)
|
|
237
|
-
* @returns {Promise<Object>} Deletion result
|
|
238
|
-
*/
|
|
239
|
-
async deleteService(service, namespaceId) {
|
|
240
|
-
const id = namespaceId || this.namespaceId;
|
|
241
|
-
if (!id) {
|
|
242
|
-
throw new Error('Namespace ID is required');
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (!service) {
|
|
246
|
-
throw new Error('Service name is required');
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return await this.client.delete(`namespaces/${id}/services/${service}`);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Bulk configure multiple services
|
|
254
|
-
* @param {Array<Object>} services - Array of service configurations
|
|
255
|
-
* @param {string} [namespaceId] - Namespace ID (uses instance namespaceId if not provided)
|
|
256
|
-
* @returns {Promise<Array>} Array of service configurations
|
|
257
|
-
*/
|
|
258
|
-
async bulkConfigureServices(services, namespaceId) {
|
|
259
|
-
const id = namespaceId || this.namespaceId;
|
|
260
|
-
if (!id) {
|
|
261
|
-
throw new Error('Namespace ID is required');
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (!Array.isArray(services)) {
|
|
265
|
-
throw new Error('Services must be an array');
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
const response = await this.client.post(`namespaces/${id}/services/bulk`, { services });
|
|
269
|
-
return response.data || response;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export default Namespace;
|
|
274
|
-
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import * as http from '../utils/http.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Base API class that handles authentication and common request logic
|
|
5
|
-
* Token is resolved dynamically from the parent client
|
|
6
|
-
*/
|
|
7
|
-
export class BaseAPI {
|
|
8
|
-
/**
|
|
9
|
-
* @param {Object} client - Parent client with getToken() and getBaseURL() methods
|
|
10
|
-
*/
|
|
11
|
-
constructor(client) {
|
|
12
|
-
this.client = client;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Get base URL from client
|
|
17
|
-
* @returns {string}
|
|
18
|
-
*/
|
|
19
|
-
get baseURL() {
|
|
20
|
-
const url = this.client.getBaseURL();
|
|
21
|
-
return url ? url.replace(/\/$/, '') : '';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Get token from client (supports async fetching)
|
|
26
|
-
* @returns {Promise<string>}
|
|
27
|
-
*/
|
|
28
|
-
async getToken() {
|
|
29
|
-
return await this.client.getToken();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Get headers with authentication
|
|
34
|
-
* @returns {Promise<Object>} Headers object
|
|
35
|
-
*/
|
|
36
|
-
async getHeaders() {
|
|
37
|
-
const token = await this.getToken();
|
|
38
|
-
return {
|
|
39
|
-
'Authorization': `Bearer ${token}`,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Make a GET request
|
|
45
|
-
* @param {string} path - API path
|
|
46
|
-
* @returns {Promise<any>} Response data
|
|
47
|
-
*/
|
|
48
|
-
async get(path) {
|
|
49
|
-
const url = `${this.baseURL}${path}`;
|
|
50
|
-
const headers = await this.getHeaders();
|
|
51
|
-
return http.get(url, headers);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Make a POST request
|
|
56
|
-
* @param {string} path - API path
|
|
57
|
-
* @param {Object} body - Request body
|
|
58
|
-
* @returns {Promise<any>} Response data
|
|
59
|
-
*/
|
|
60
|
-
async post(path, body = {}) {
|
|
61
|
-
const url = `${this.baseURL}${path}`;
|
|
62
|
-
const headers = await this.getHeaders();
|
|
63
|
-
return http.post(url, body, headers);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Make a PUT request
|
|
68
|
-
* @param {string} path - API path
|
|
69
|
-
* @param {Object} body - Request body
|
|
70
|
-
* @returns {Promise<any>} Response data
|
|
71
|
-
*/
|
|
72
|
-
async put(path, body = {}) {
|
|
73
|
-
const url = `${this.baseURL}${path}`;
|
|
74
|
-
const headers = await this.getHeaders();
|
|
75
|
-
return http.put(url, body, headers);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Make a DELETE request
|
|
80
|
-
* @param {string} path - API path
|
|
81
|
-
* @returns {Promise<any>} Response data
|
|
82
|
-
*/
|
|
83
|
-
async delete(path) {
|
|
84
|
-
const url = `${this.baseURL}${path}`;
|
|
85
|
-
const headers = await this.getHeaders();
|
|
86
|
-
return http.del(url, headers);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|