s3db.js 13.5.1 → 13.6.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.
- package/README.md +25 -10
- package/dist/{s3db.cjs.js → s3db.cjs} +30323 -24958
- package/dist/s3db.cjs.map +1 -0
- package/dist/s3db.es.js +24026 -18654
- package/dist/s3db.es.js.map +1 -1
- package/package.json +216 -20
- package/src/concerns/id.js +90 -6
- package/src/concerns/index.js +2 -1
- package/src/concerns/password-hashing.js +150 -0
- package/src/database.class.js +4 -0
- package/src/plugins/api/auth/basic-auth.js +23 -1
- package/src/plugins/api/auth/index.js +49 -3
- package/src/plugins/api/auth/oauth2-auth.js +171 -0
- package/src/plugins/api/auth/oidc-auth.js +789 -0
- package/src/plugins/api/auth/oidc-client.js +462 -0
- package/src/plugins/api/auth/path-auth-matcher.js +284 -0
- package/src/plugins/api/concerns/event-emitter.js +134 -0
- package/src/plugins/api/concerns/failban-manager.js +651 -0
- package/src/plugins/api/concerns/guards-helpers.js +402 -0
- package/src/plugins/api/concerns/metrics-collector.js +346 -0
- package/src/plugins/api/index.js +503 -54
- package/src/plugins/api/middlewares/failban.js +305 -0
- package/src/plugins/api/middlewares/rate-limit.js +301 -0
- package/src/plugins/api/middlewares/request-id.js +74 -0
- package/src/plugins/api/middlewares/security-headers.js +120 -0
- package/src/plugins/api/middlewares/session-tracking.js +194 -0
- package/src/plugins/api/routes/auth-routes.js +23 -3
- package/src/plugins/api/routes/resource-routes.js +71 -29
- package/src/plugins/api/server.js +1017 -94
- package/src/plugins/api/utils/guards.js +213 -0
- package/src/plugins/api/utils/mime-types.js +154 -0
- package/src/plugins/api/utils/openapi-generator.js +44 -11
- package/src/plugins/api/utils/path-matcher.js +173 -0
- package/src/plugins/api/utils/static-filesystem.js +262 -0
- package/src/plugins/api/utils/static-s3.js +231 -0
- package/src/plugins/api/utils/template-engine.js +188 -0
- package/src/plugins/cloud-inventory/drivers/alibaba-driver.js +853 -0
- package/src/plugins/cloud-inventory/drivers/aws-driver.js +2554 -0
- package/src/plugins/cloud-inventory/drivers/azure-driver.js +637 -0
- package/src/plugins/cloud-inventory/drivers/base-driver.js +99 -0
- package/src/plugins/cloud-inventory/drivers/cloudflare-driver.js +620 -0
- package/src/plugins/cloud-inventory/drivers/digitalocean-driver.js +698 -0
- package/src/plugins/cloud-inventory/drivers/gcp-driver.js +645 -0
- package/src/plugins/cloud-inventory/drivers/hetzner-driver.js +559 -0
- package/src/plugins/cloud-inventory/drivers/linode-driver.js +614 -0
- package/src/plugins/cloud-inventory/drivers/mock-drivers.js +449 -0
- package/src/plugins/cloud-inventory/drivers/mongodb-atlas-driver.js +771 -0
- package/src/plugins/cloud-inventory/drivers/oracle-driver.js +768 -0
- package/src/plugins/cloud-inventory/drivers/vultr-driver.js +636 -0
- package/src/plugins/cloud-inventory/index.js +20 -0
- package/src/plugins/cloud-inventory/registry.js +146 -0
- package/src/plugins/cloud-inventory/terraform-exporter.js +362 -0
- package/src/plugins/cloud-inventory.plugin.js +1333 -0
- package/src/plugins/concerns/plugin-dependencies.js +61 -1
- package/src/plugins/eventual-consistency/analytics.js +1 -0
- package/src/plugins/identity/README.md +335 -0
- package/src/plugins/identity/concerns/mfa-manager.js +204 -0
- package/src/plugins/identity/concerns/password.js +138 -0
- package/src/plugins/identity/concerns/resource-schemas.js +273 -0
- package/src/plugins/identity/concerns/token-generator.js +172 -0
- package/src/plugins/identity/email-service.js +422 -0
- package/src/plugins/identity/index.js +1052 -0
- package/src/plugins/identity/oauth2-server.js +1033 -0
- package/src/plugins/identity/oidc-discovery.js +285 -0
- package/src/plugins/identity/rsa-keys.js +323 -0
- package/src/plugins/identity/server.js +500 -0
- package/src/plugins/identity/session-manager.js +453 -0
- package/src/plugins/identity/ui/layouts/base.js +251 -0
- package/src/plugins/identity/ui/middleware.js +135 -0
- package/src/plugins/identity/ui/pages/admin/client-form.js +247 -0
- package/src/plugins/identity/ui/pages/admin/clients.js +179 -0
- package/src/plugins/identity/ui/pages/admin/dashboard.js +181 -0
- package/src/plugins/identity/ui/pages/admin/user-form.js +283 -0
- package/src/plugins/identity/ui/pages/admin/users.js +263 -0
- package/src/plugins/identity/ui/pages/consent.js +262 -0
- package/src/plugins/identity/ui/pages/forgot-password.js +104 -0
- package/src/plugins/identity/ui/pages/login.js +144 -0
- package/src/plugins/identity/ui/pages/mfa-backup-codes.js +180 -0
- package/src/plugins/identity/ui/pages/mfa-enrollment.js +187 -0
- package/src/plugins/identity/ui/pages/mfa-verification.js +178 -0
- package/src/plugins/identity/ui/pages/oauth-error.js +225 -0
- package/src/plugins/identity/ui/pages/profile.js +361 -0
- package/src/plugins/identity/ui/pages/register.js +226 -0
- package/src/plugins/identity/ui/pages/reset-password.js +128 -0
- package/src/plugins/identity/ui/pages/verify-email.js +172 -0
- package/src/plugins/identity/ui/routes.js +2541 -0
- package/src/plugins/identity/ui/styles/main.css +465 -0
- package/src/plugins/index.js +4 -1
- package/src/plugins/ml/base-model.class.js +32 -7
- package/src/plugins/ml/classification-model.class.js +1 -1
- package/src/plugins/ml/timeseries-model.class.js +3 -1
- package/src/plugins/ml.plugin.js +124 -32
- package/src/plugins/shared/error-handler.js +147 -0
- package/src/plugins/shared/index.js +9 -0
- package/src/plugins/shared/middlewares/compression.js +117 -0
- package/src/plugins/shared/middlewares/cors.js +49 -0
- package/src/plugins/shared/middlewares/index.js +11 -0
- package/src/plugins/shared/middlewares/logging.js +54 -0
- package/src/plugins/shared/middlewares/rate-limit.js +73 -0
- package/src/plugins/shared/middlewares/security.js +158 -0
- package/src/plugins/shared/response-formatter.js +264 -0
- package/src/resource.class.js +140 -12
- package/src/schema.class.js +30 -1
- package/src/validator.class.js +57 -6
- package/dist/s3db.cjs.js.map +0 -1
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import { BaseCloudDriver } from './base-driver.js';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_TAGS = { environment: 'mock' };
|
|
4
|
+
|
|
5
|
+
function cloneValue(value) {
|
|
6
|
+
if (Array.isArray(value)) {
|
|
7
|
+
return value.map(cloneValue);
|
|
8
|
+
}
|
|
9
|
+
if (value && typeof value === 'object') {
|
|
10
|
+
return JSON.parse(JSON.stringify(value));
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function mergeWithDefaults(defaults, resource = {}) {
|
|
16
|
+
const merged = {
|
|
17
|
+
...defaults,
|
|
18
|
+
...resource
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const baseTags = defaults.tags || null;
|
|
22
|
+
const resourceTags = resource.tags || null;
|
|
23
|
+
merged.tags = baseTags || resourceTags
|
|
24
|
+
? { ...(baseTags || {}), ...(resourceTags || {}) }
|
|
25
|
+
: null;
|
|
26
|
+
|
|
27
|
+
const baseLabels = defaults.labels || null;
|
|
28
|
+
const resourceLabels = resource.labels || null;
|
|
29
|
+
merged.labels = baseLabels || resourceLabels
|
|
30
|
+
? { ...(baseLabels || {}), ...(resourceLabels || {}) }
|
|
31
|
+
: null;
|
|
32
|
+
|
|
33
|
+
const baseMetadata = defaults.metadata || {};
|
|
34
|
+
const resourceMetadata = resource.metadata || {};
|
|
35
|
+
merged.metadata = { ...baseMetadata, ...resourceMetadata };
|
|
36
|
+
|
|
37
|
+
const configuration = resource.configuration ?? defaults.configuration ?? {
|
|
38
|
+
id: merged.resourceId,
|
|
39
|
+
note: `Mock configuration for ${defaults.provider}`
|
|
40
|
+
};
|
|
41
|
+
merged.configuration = cloneValue(configuration);
|
|
42
|
+
|
|
43
|
+
return merged;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
class MockCloudDriver extends BaseCloudDriver {
|
|
47
|
+
constructor(options = {}, defaultsBuilder) {
|
|
48
|
+
super(options);
|
|
49
|
+
this._defaultsBuilder = defaultsBuilder;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_buildDefaults() {
|
|
53
|
+
return this._defaultsBuilder(this);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async initialize() {
|
|
57
|
+
this.logger('debug', 'Mock cloud driver initialized', {
|
|
58
|
+
cloudId: this.id,
|
|
59
|
+
driver: this.driver
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async listResources() {
|
|
64
|
+
const defaults = this._buildDefaults();
|
|
65
|
+
const samples = Array.isArray(this.config.sampleResources) && this.config.sampleResources.length
|
|
66
|
+
? this.config.sampleResources
|
|
67
|
+
: [defaults];
|
|
68
|
+
|
|
69
|
+
return samples.map(entry => mergeWithDefaults(defaults, entry));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function awsDefaults(driver) {
|
|
74
|
+
const accountId = driver.config.accountId || 'mock-aws-account';
|
|
75
|
+
const region = driver.config.region || driver.config.regions?.[0] || 'us-east-1';
|
|
76
|
+
const resourceId = driver.config.resourceId || `i-${accountId.slice(-6) || 'mock'}001`;
|
|
77
|
+
return {
|
|
78
|
+
provider: 'aws',
|
|
79
|
+
driver: 'aws',
|
|
80
|
+
accountId,
|
|
81
|
+
region,
|
|
82
|
+
service: 'ec2',
|
|
83
|
+
resourceType: 'ec2.instance',
|
|
84
|
+
resourceId,
|
|
85
|
+
name: 'mock-ec2-instance',
|
|
86
|
+
tags: { ...DEFAULT_TAGS, Owner: 'cloud-inventory' },
|
|
87
|
+
metadata: { source: 'cloud-inventory-mock' },
|
|
88
|
+
configuration: {
|
|
89
|
+
instanceId: resourceId,
|
|
90
|
+
instanceType: 't3.micro',
|
|
91
|
+
region,
|
|
92
|
+
accountId,
|
|
93
|
+
state: 'running',
|
|
94
|
+
tags: { Environment: 'mock', Owner: 'cloud-inventory' }
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function gcpDefaults(driver) {
|
|
100
|
+
const projectId = driver.config.projectId || 'mock-gcp-project';
|
|
101
|
+
const region = driver.config.region || driver.config.regions?.[0] || 'us-central1';
|
|
102
|
+
const zone = driver.config.zone || `${region}-a`;
|
|
103
|
+
const resourceId = driver.config.resourceId || `${projectId}-instance-1`;
|
|
104
|
+
return {
|
|
105
|
+
provider: 'gcp',
|
|
106
|
+
driver: 'gcp',
|
|
107
|
+
projectId,
|
|
108
|
+
region,
|
|
109
|
+
service: 'compute',
|
|
110
|
+
resourceType: 'gcp.compute.instance',
|
|
111
|
+
resourceId,
|
|
112
|
+
name: 'mock-gce-instance',
|
|
113
|
+
labels: { ...DEFAULT_TAGS, owner: 'cloud-inventory' },
|
|
114
|
+
metadata: { source: 'cloud-inventory-mock', zone },
|
|
115
|
+
configuration: {
|
|
116
|
+
id: resourceId,
|
|
117
|
+
name: 'mock-gce-instance',
|
|
118
|
+
machineType: 'e2-medium',
|
|
119
|
+
status: 'RUNNING',
|
|
120
|
+
projectId,
|
|
121
|
+
zone,
|
|
122
|
+
labels: { environment: 'mock', owner: 'cloud-inventory' }
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function digitalOceanDefaults(driver) {
|
|
128
|
+
const accountId = driver.config.accountId || 'mock-do-account';
|
|
129
|
+
const region = driver.config.region || driver.config.regions?.[0] || 'nyc3';
|
|
130
|
+
const resourceId = driver.config.resourceId || `do-${accountId.slice(-6) || 'mock'}-droplet`;
|
|
131
|
+
return {
|
|
132
|
+
provider: 'digitalocean',
|
|
133
|
+
driver: 'digitalocean',
|
|
134
|
+
accountId,
|
|
135
|
+
region,
|
|
136
|
+
service: 'droplet',
|
|
137
|
+
resourceType: 'do.droplet',
|
|
138
|
+
resourceId,
|
|
139
|
+
name: 'mock-droplet',
|
|
140
|
+
tags: { ...DEFAULT_TAGS, owner: 'cloud-inventory' },
|
|
141
|
+
metadata: { source: 'cloud-inventory-mock' },
|
|
142
|
+
configuration: {
|
|
143
|
+
id: resourceId,
|
|
144
|
+
name: 'mock-droplet',
|
|
145
|
+
size: 's-2vcpu-4gb',
|
|
146
|
+
region,
|
|
147
|
+
status: 'active',
|
|
148
|
+
tags: ['mock', 'cloud-inventory']
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function oracleDefaults(driver) {
|
|
154
|
+
const tenancyId = driver.config.tenancyId || driver.config.organizationId || 'ocid1.tenancy.oc1..mock';
|
|
155
|
+
const compartmentId = driver.config.compartmentId || 'ocid1.compartment.oc1..mock';
|
|
156
|
+
const region = driver.config.region || 'us-phoenix-1';
|
|
157
|
+
const resourceId = driver.config.resourceId || 'ocid1.instance.oc1..mock';
|
|
158
|
+
return {
|
|
159
|
+
provider: 'oracle',
|
|
160
|
+
driver: 'oracle',
|
|
161
|
+
organizationId: tenancyId,
|
|
162
|
+
region,
|
|
163
|
+
service: 'compute',
|
|
164
|
+
resourceType: 'oci.compute.instance',
|
|
165
|
+
resourceId,
|
|
166
|
+
name: 'mock-oci-instance',
|
|
167
|
+
tags: { ...DEFAULT_TAGS, owner: 'cloud-inventory' },
|
|
168
|
+
metadata: {
|
|
169
|
+
source: 'cloud-inventory-mock',
|
|
170
|
+
compartmentId
|
|
171
|
+
},
|
|
172
|
+
configuration: {
|
|
173
|
+
id: resourceId,
|
|
174
|
+
displayName: 'mock-oci-instance',
|
|
175
|
+
compartmentId,
|
|
176
|
+
lifecycleState: 'RUNNING',
|
|
177
|
+
region,
|
|
178
|
+
shape: 'VM.Standard.E4.Flex',
|
|
179
|
+
freeformTags: { Environment: 'mock', Owner: 'cloud-inventory' }
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function azureDefaults(driver) {
|
|
185
|
+
const subscriptionId = driver.config.subscriptionId || driver.config.accountId || '00000000-0000-0000-0000-000000000000';
|
|
186
|
+
const resourceGroup = driver.config.resourceGroup || 'rg-mock';
|
|
187
|
+
const region = driver.config.region || 'eastus';
|
|
188
|
+
const vmName = driver.config.vmName || 'mock-azure-vm';
|
|
189
|
+
const resourceId = driver.config.resourceId || `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.Compute/virtualMachines/${vmName}`;
|
|
190
|
+
return {
|
|
191
|
+
provider: 'azure',
|
|
192
|
+
driver: 'azure',
|
|
193
|
+
subscriptionId,
|
|
194
|
+
region,
|
|
195
|
+
service: 'compute',
|
|
196
|
+
resourceType: 'azure.vm',
|
|
197
|
+
resourceId,
|
|
198
|
+
name: vmName,
|
|
199
|
+
tags: { ...DEFAULT_TAGS, owner: 'cloud-inventory' },
|
|
200
|
+
metadata: {
|
|
201
|
+
source: 'cloud-inventory-mock',
|
|
202
|
+
resourceGroup
|
|
203
|
+
},
|
|
204
|
+
configuration: {
|
|
205
|
+
id: resourceId,
|
|
206
|
+
name: vmName,
|
|
207
|
+
location: region,
|
|
208
|
+
resourceGroup,
|
|
209
|
+
subscriptionId,
|
|
210
|
+
hardwareProfile: { vmSize: 'Standard_B2s' },
|
|
211
|
+
provisioningState: 'Succeeded',
|
|
212
|
+
tags: { Environment: 'mock', Owner: 'cloud-inventory' }
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function vultrDefaults(driver) {
|
|
218
|
+
const accountId = driver.config.accountId || 'mock-vultr-account';
|
|
219
|
+
const region = driver.config.region || 'ewr';
|
|
220
|
+
const resourceId = driver.config.resourceId || `vultr-${accountId.slice(-6) || 'mock'}-instance`;
|
|
221
|
+
return {
|
|
222
|
+
provider: 'vultr',
|
|
223
|
+
driver: 'vultr',
|
|
224
|
+
accountId,
|
|
225
|
+
region,
|
|
226
|
+
service: 'compute',
|
|
227
|
+
resourceType: 'vultr.instance',
|
|
228
|
+
resourceId,
|
|
229
|
+
name: 'mock-vultr-instance',
|
|
230
|
+
tags: { ...DEFAULT_TAGS, owner: 'cloud-inventory' },
|
|
231
|
+
metadata: { source: 'cloud-inventory-mock' },
|
|
232
|
+
configuration: {
|
|
233
|
+
id: resourceId,
|
|
234
|
+
label: 'mock-vultr-instance',
|
|
235
|
+
plan: 'vc2-1c-1gb',
|
|
236
|
+
region,
|
|
237
|
+
status: 'active',
|
|
238
|
+
tags: ['mock', 'cloud-inventory']
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export class AwsMockDriver extends MockCloudDriver {
|
|
244
|
+
constructor(options = {}) {
|
|
245
|
+
super(options, awsDefaults);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export class GcpMockDriver extends MockCloudDriver {
|
|
250
|
+
constructor(options = {}) {
|
|
251
|
+
super(options, gcpDefaults);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export class DigitalOceanMockDriver extends MockCloudDriver {
|
|
256
|
+
constructor(options = {}) {
|
|
257
|
+
super(options, digitalOceanDefaults);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export class OracleMockDriver extends MockCloudDriver {
|
|
262
|
+
constructor(options = {}) {
|
|
263
|
+
super(options, oracleDefaults);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export class AzureMockDriver extends MockCloudDriver {
|
|
268
|
+
constructor(options = {}) {
|
|
269
|
+
super(options, azureDefaults);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export class VultrMockDriver extends MockCloudDriver {
|
|
274
|
+
constructor(options = {}) {
|
|
275
|
+
super(options, vultrDefaults);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function linodeDefaults(driver) {
|
|
280
|
+
const accountId = driver.config.accountId || 'mock-linode-account';
|
|
281
|
+
const region = driver.config.region || driver.config.regions?.[0] || 'us-east';
|
|
282
|
+
const resourceId = driver.config.resourceId || `linode-${accountId.slice(-6) || 'mock'}-instance`;
|
|
283
|
+
return {
|
|
284
|
+
provider: 'linode',
|
|
285
|
+
driver: 'linode',
|
|
286
|
+
accountId,
|
|
287
|
+
region,
|
|
288
|
+
service: 'linodes',
|
|
289
|
+
resourceType: 'linode.compute.instance',
|
|
290
|
+
resourceId,
|
|
291
|
+
name: 'mock-linode-instance',
|
|
292
|
+
tags: ['mock', 'cloud-inventory'],
|
|
293
|
+
metadata: { source: 'cloud-inventory-mock' },
|
|
294
|
+
configuration: {
|
|
295
|
+
id: resourceId,
|
|
296
|
+
label: 'mock-linode-instance',
|
|
297
|
+
type: 'g6-nanode-1',
|
|
298
|
+
region,
|
|
299
|
+
status: 'running',
|
|
300
|
+
tags: ['mock', 'cloud-inventory']
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function hetznerDefaults(driver) {
|
|
306
|
+
const accountId = driver.config.accountId || 'mock-hetzner-account';
|
|
307
|
+
const region = driver.config.region || 'fsn1';
|
|
308
|
+
const resourceId = driver.config.resourceId || `hetzner-${accountId.slice(-6) || 'mock'}-server`;
|
|
309
|
+
return {
|
|
310
|
+
provider: 'hetzner',
|
|
311
|
+
driver: 'hetzner',
|
|
312
|
+
accountId,
|
|
313
|
+
region,
|
|
314
|
+
service: 'servers',
|
|
315
|
+
resourceType: 'hetzner.server',
|
|
316
|
+
resourceId,
|
|
317
|
+
name: 'mock-hetzner-server',
|
|
318
|
+
tags: { ...DEFAULT_TAGS, owner: 'cloud-inventory' },
|
|
319
|
+
metadata: { source: 'cloud-inventory-mock' },
|
|
320
|
+
configuration: {
|
|
321
|
+
id: resourceId,
|
|
322
|
+
name: 'mock-hetzner-server',
|
|
323
|
+
serverType: 'cx11',
|
|
324
|
+
datacenter: { location: { name: region } },
|
|
325
|
+
status: 'running',
|
|
326
|
+
labels: { environment: 'mock', owner: 'cloud-inventory' }
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function alibabaDefaults(driver) {
|
|
332
|
+
const accountId = driver.config.accountId || 'mock-alibaba-account';
|
|
333
|
+
const region = driver.config.region || driver.config.regions?.[0] || 'cn-hangzhou';
|
|
334
|
+
const resourceId = driver.config.resourceId || `i-${accountId.slice(-6) || 'mock'}001`;
|
|
335
|
+
return {
|
|
336
|
+
provider: 'alibaba',
|
|
337
|
+
driver: 'alibaba',
|
|
338
|
+
accountId,
|
|
339
|
+
region,
|
|
340
|
+
service: 'ecs',
|
|
341
|
+
resourceType: 'alibaba.ecs.instance',
|
|
342
|
+
resourceId,
|
|
343
|
+
name: 'mock-ecs-instance',
|
|
344
|
+
tags: { ...DEFAULT_TAGS, owner: 'cloud-inventory' },
|
|
345
|
+
metadata: { source: 'cloud-inventory-mock' },
|
|
346
|
+
configuration: {
|
|
347
|
+
InstanceId: resourceId,
|
|
348
|
+
InstanceName: 'mock-ecs-instance',
|
|
349
|
+
InstanceType: 'ecs.t5-lc1m1.small',
|
|
350
|
+
RegionId: region,
|
|
351
|
+
Status: 'Running',
|
|
352
|
+
Tags: { Tag: [{ TagKey: 'environment', TagValue: 'mock' }] }
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function cloudflareDefaults(driver) {
|
|
358
|
+
const accountId = driver.config.accountId || 'mock-cloudflare-account';
|
|
359
|
+
const resourceId = driver.config.resourceId || `cf-worker-${accountId.slice(-6) || 'mock'}`;
|
|
360
|
+
return {
|
|
361
|
+
provider: 'cloudflare',
|
|
362
|
+
driver: 'cloudflare',
|
|
363
|
+
accountId,
|
|
364
|
+
region: 'global',
|
|
365
|
+
service: 'workers',
|
|
366
|
+
resourceType: 'cloudflare.workers.script',
|
|
367
|
+
resourceId,
|
|
368
|
+
name: 'mock-worker-script',
|
|
369
|
+
tags: ['mock', 'cloud-inventory'],
|
|
370
|
+
metadata: { source: 'cloud-inventory-mock' },
|
|
371
|
+
configuration: {
|
|
372
|
+
id: resourceId,
|
|
373
|
+
script: 'mock-worker-script',
|
|
374
|
+
etag: 'mock-etag',
|
|
375
|
+
created_on: new Date().toISOString(),
|
|
376
|
+
modified_on: new Date().toISOString(),
|
|
377
|
+
tags: ['mock', 'cloud-inventory']
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export class LinodeMockDriver extends MockCloudDriver {
|
|
383
|
+
constructor(options = {}) {
|
|
384
|
+
super(options, linodeDefaults);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export class HetznerMockDriver extends MockCloudDriver {
|
|
389
|
+
constructor(options = {}) {
|
|
390
|
+
super(options, hetznerDefaults);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export class AlibabaMockDriver extends MockCloudDriver {
|
|
395
|
+
constructor(options = {}) {
|
|
396
|
+
super(options, alibabaDefaults);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export class CloudflareMockDriver extends MockCloudDriver {
|
|
401
|
+
constructor(options = {}) {
|
|
402
|
+
super(options, cloudflareDefaults);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function mongodbAtlasDefaults(driver) {
|
|
407
|
+
const organizationId = driver.config.organizationId || 'mock-atlas-org';
|
|
408
|
+
const projectId = driver.config.projectId || 'mock-atlas-project';
|
|
409
|
+
const resourceId = driver.config.resourceId || `cluster-${projectId.slice(-6) || 'mock'}`;
|
|
410
|
+
return {
|
|
411
|
+
provider: 'mongodb-atlas',
|
|
412
|
+
driver: 'mongodb-atlas',
|
|
413
|
+
accountId: organizationId,
|
|
414
|
+
region: 'US_EAST_1',
|
|
415
|
+
service: 'clusters',
|
|
416
|
+
resourceType: 'mongodb-atlas.cluster',
|
|
417
|
+
resourceId,
|
|
418
|
+
name: 'mock-atlas-cluster',
|
|
419
|
+
tags: { ...DEFAULT_TAGS, environment: 'development' },
|
|
420
|
+
metadata: {
|
|
421
|
+
source: 'cloud-inventory-mock',
|
|
422
|
+
projectId,
|
|
423
|
+
tier: 'M10',
|
|
424
|
+
provider: 'AWS',
|
|
425
|
+
mongoDBVersion: '7.0'
|
|
426
|
+
},
|
|
427
|
+
configuration: {
|
|
428
|
+
id: resourceId,
|
|
429
|
+
name: 'mock-atlas-cluster',
|
|
430
|
+
clusterType: 'REPLICASET',
|
|
431
|
+
stateName: 'IDLE',
|
|
432
|
+
mongoDBVersion: '7.0.2',
|
|
433
|
+
providerSettings: {
|
|
434
|
+
providerName: 'AWS',
|
|
435
|
+
regionName: 'US_EAST_1',
|
|
436
|
+
instanceSizeName: 'M10'
|
|
437
|
+
},
|
|
438
|
+
tags: { environment: 'development', owner: 'cloud-inventory' }
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export class MongoDBAtlasMockDriver extends MockCloudDriver {
|
|
444
|
+
constructor(options = {}) {
|
|
445
|
+
super(options, mongodbAtlasDefaults);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export default MockCloudDriver;
|