@bosunski/laravel-cloud-sdk 0.1.2 → 0.1.5
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/dist/resources/applications.d.ts +197 -11
- package/dist/resources/applications.js +9 -17
- package/dist/resources/databases.d.ts +283 -35
- package/dist/resources/databases.js +18 -40
- package/dist/resources/deployments.d.ts +330 -24
- package/dist/resources/deployments.js +36 -23
- package/dist/resources/domains.d.ts +202 -9
- package/dist/resources/domains.js +9 -17
- package/dist/resources/environments.d.ts +329 -31
- package/dist/resources/environments.js +25 -34
- package/dist/resources/instances.d.ts +221 -16
- package/dist/resources/instances.js +15 -26
- package/dist/utils/caseConversion.d.ts +20 -0
- package/dist/utils/caseConversion.js +35 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createJsonApiCollectionSchema, createJsonApiResponseSchema, JsonApiResourceSchema, } from '../types/jsonApi.js';
|
|
3
3
|
import { deploymentResponseSchema, serializeDeploymentResponse, } from './deployments.js';
|
|
4
|
+
import { keysToCamel } from '../utils/caseConversion.js';
|
|
4
5
|
const colorSchema = z.enum([
|
|
5
6
|
'blue',
|
|
6
7
|
'green',
|
|
@@ -11,6 +12,13 @@ const colorSchema = z.enum([
|
|
|
11
12
|
'cyan',
|
|
12
13
|
'gray',
|
|
13
14
|
]);
|
|
15
|
+
const environmentStatusSchema = z.enum([
|
|
16
|
+
'deploying',
|
|
17
|
+
'running',
|
|
18
|
+
'hibernating',
|
|
19
|
+
'stopped',
|
|
20
|
+
]);
|
|
21
|
+
const phpMajorVersionSchema = z.enum(['8.2', '8.3', '8.4', '8.5']);
|
|
14
22
|
const phpVersionSchema = z.enum(['8.2:1', '8.3:1', '8.4:1', '8.5:1']);
|
|
15
23
|
const nodeVersionSchema = z.enum(['20', '22', '24']);
|
|
16
24
|
const environmentVariableSchema = z.object({
|
|
@@ -55,17 +63,19 @@ const environmentLogsResponseSchema = z.object({
|
|
|
55
63
|
data: z.array(environmentLogEntrySchema),
|
|
56
64
|
meta: environmentLogMetaSchema,
|
|
57
65
|
});
|
|
66
|
+
// Transform log entry to camelCase
|
|
67
|
+
const transformedLogEntrySchema = environmentLogEntrySchema.transform((data) => keysToCamel(data));
|
|
58
68
|
const environmentAttributesSchema = z
|
|
59
69
|
.object({
|
|
60
70
|
name: z.string(),
|
|
61
71
|
slug: z.string(),
|
|
62
|
-
status:
|
|
72
|
+
status: environmentStatusSchema,
|
|
63
73
|
created_at: z.string(),
|
|
64
74
|
created_from_automation: z.boolean().optional(),
|
|
65
75
|
vanity_domain: z.string().nullable().optional(),
|
|
66
|
-
php_major_version:
|
|
76
|
+
php_major_version: phpMajorVersionSchema.optional(),
|
|
67
77
|
build_command: z.string().nullable().optional(),
|
|
68
|
-
node_version:
|
|
78
|
+
node_version: nodeVersionSchema.nullable().optional(),
|
|
69
79
|
deploy_command: z.string().nullable().optional(),
|
|
70
80
|
uses_octane: z.boolean().optional(),
|
|
71
81
|
uses_hibernation: z.boolean().optional(),
|
|
@@ -79,33 +89,17 @@ const environmentResourceSchema = JsonApiResourceSchema.extend({
|
|
|
79
89
|
type: z.literal('environments'),
|
|
80
90
|
attributes: environmentAttributesSchema,
|
|
81
91
|
});
|
|
92
|
+
// Transform resource to camelCase with raw data preserved
|
|
93
|
+
const transformedEnvironmentSchema = environmentResourceSchema.transform((data) => ({
|
|
94
|
+
...keysToCamel(data.attributes),
|
|
95
|
+
id: data.id,
|
|
96
|
+
raw: data,
|
|
97
|
+
}));
|
|
82
98
|
const environmentResponseSchema = createJsonApiResponseSchema(environmentResourceSchema);
|
|
83
99
|
const environmentCollectionSchema = createJsonApiCollectionSchema(environmentResourceSchema);
|
|
100
|
+
// Simple transformation - schema handles the conversion
|
|
84
101
|
const mapEnvironment = (resource) => {
|
|
85
|
-
|
|
86
|
-
const { attributes } = parsed;
|
|
87
|
-
return {
|
|
88
|
-
id: parsed.id,
|
|
89
|
-
name: attributes.name,
|
|
90
|
-
slug: attributes.slug,
|
|
91
|
-
status: attributes.status,
|
|
92
|
-
createdAt: attributes.created_at,
|
|
93
|
-
createdFromAutomation: attributes.created_from_automation,
|
|
94
|
-
vanityDomain: attributes.vanity_domain ?? null,
|
|
95
|
-
phpMajorVersion: attributes.php_major_version,
|
|
96
|
-
buildCommand: attributes.build_command ?? null,
|
|
97
|
-
nodeVersion: attributes.node_version ?? null,
|
|
98
|
-
deployCommand: attributes.deploy_command ?? null,
|
|
99
|
-
usesOctane: attributes.uses_octane,
|
|
100
|
-
usesHibernation: attributes.uses_hibernation,
|
|
101
|
-
usesPushToDeploy: attributes.uses_push_to_deploy,
|
|
102
|
-
usesDeployHook: attributes.uses_deploy_hook,
|
|
103
|
-
environmentVariables: attributes.environment_variables?.map((variable) => ({
|
|
104
|
-
key: variable.key,
|
|
105
|
-
value: variable.value ?? null,
|
|
106
|
-
})),
|
|
107
|
-
raw: parsed,
|
|
108
|
-
};
|
|
102
|
+
return transformedEnvironmentSchema.parse(resource);
|
|
109
103
|
};
|
|
110
104
|
const serializeEnvironmentList = (response) => ({
|
|
111
105
|
data: response.data.map(mapEnvironment),
|
|
@@ -247,13 +241,10 @@ const mapVariablesToApi = (variables) => variables.map((variable) => ({
|
|
|
247
241
|
key: variable.key,
|
|
248
242
|
value: variable.value ?? null,
|
|
249
243
|
}));
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
loggedAt: entry.logged_at,
|
|
255
|
-
data: entry.data ? { ...entry.data } : undefined,
|
|
256
|
-
});
|
|
244
|
+
// Simple transformation - schema handles the conversion
|
|
245
|
+
const mapEnvironmentLogEntry = (entry) => {
|
|
246
|
+
return transformedLogEntrySchema.parse(entry);
|
|
247
|
+
};
|
|
257
248
|
export class EnvironmentsResource {
|
|
258
249
|
client;
|
|
259
250
|
constructor(client) {
|
|
@@ -1,13 +1,141 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { HttpClient } from '../http/client.js';
|
|
2
|
-
import { JsonApiResponse
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import { JsonApiResponse } from '../types/jsonApi.js';
|
|
4
|
+
declare const transformedInstanceSchema: z.ZodPipe<z.ZodObject<{
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
relationships: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
7
|
+
data: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
8
|
+
type: z.ZodString;
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
11
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
12
|
+
type: z.ZodString;
|
|
13
|
+
id: z.ZodString;
|
|
14
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
15
|
+
}, z.core.$strip>>]>>;
|
|
16
|
+
links: z.ZodOptional<z.ZodObject<{
|
|
17
|
+
related: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
href: z.ZodOptional<z.ZodString>;
|
|
19
|
+
rel: z.ZodOptional<z.ZodString>;
|
|
20
|
+
describedby: z.ZodOptional<z.ZodString>;
|
|
21
|
+
title: z.ZodOptional<z.ZodString>;
|
|
22
|
+
type: z.ZodOptional<z.ZodString>;
|
|
23
|
+
hreflang: z.ZodOptional<z.ZodString>;
|
|
24
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
25
|
+
}, z.core.$loose>>;
|
|
26
|
+
self: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
href: z.ZodOptional<z.ZodString>;
|
|
28
|
+
rel: z.ZodOptional<z.ZodString>;
|
|
29
|
+
describedby: z.ZodOptional<z.ZodString>;
|
|
30
|
+
title: z.ZodOptional<z.ZodString>;
|
|
31
|
+
type: z.ZodOptional<z.ZodString>;
|
|
32
|
+
hreflang: z.ZodOptional<z.ZodString>;
|
|
33
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
34
|
+
}, z.core.$loose>>;
|
|
35
|
+
}, z.core.$strip>>;
|
|
36
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
37
|
+
}, z.core.$loose>>>;
|
|
38
|
+
links: z.ZodOptional<z.ZodObject<{
|
|
39
|
+
self: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
href: z.ZodOptional<z.ZodString>;
|
|
41
|
+
rel: z.ZodOptional<z.ZodString>;
|
|
42
|
+
describedby: z.ZodOptional<z.ZodString>;
|
|
43
|
+
title: z.ZodOptional<z.ZodString>;
|
|
44
|
+
type: z.ZodOptional<z.ZodString>;
|
|
45
|
+
hreflang: z.ZodOptional<z.ZodString>;
|
|
46
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
47
|
+
}, z.core.$loose>>;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
50
|
+
type: z.ZodLiteral<"instances">;
|
|
51
|
+
attributes: z.ZodObject<{
|
|
52
|
+
name: z.ZodString;
|
|
53
|
+
type: z.ZodString;
|
|
54
|
+
size: z.ZodString;
|
|
55
|
+
scaling_type: z.ZodString;
|
|
56
|
+
min_replicas: z.ZodNumber;
|
|
57
|
+
max_replicas: z.ZodNumber;
|
|
58
|
+
uses_scheduler: z.ZodBoolean;
|
|
59
|
+
uses_sleep_mode: z.ZodBoolean;
|
|
60
|
+
sleep_timeout: z.ZodNullable<z.ZodNumber>;
|
|
61
|
+
uses_octane: z.ZodBoolean;
|
|
62
|
+
uses_inertia_ssr: z.ZodBoolean;
|
|
63
|
+
scaling_cpu_threshold_percentage: z.ZodNullable<z.ZodNumber>;
|
|
64
|
+
scaling_memory_threshold_percentage: z.ZodNullable<z.ZodNumber>;
|
|
65
|
+
created_at: z.ZodString;
|
|
66
|
+
}, z.core.$loose>;
|
|
67
|
+
}, z.core.$loose>, z.ZodTransform<{
|
|
10
68
|
id: string;
|
|
69
|
+
raw: {
|
|
70
|
+
[x: string]: unknown;
|
|
71
|
+
id: string;
|
|
72
|
+
type: "instances";
|
|
73
|
+
attributes: {
|
|
74
|
+
[x: string]: unknown;
|
|
75
|
+
name: string;
|
|
76
|
+
type: string;
|
|
77
|
+
size: string;
|
|
78
|
+
scaling_type: string;
|
|
79
|
+
min_replicas: number;
|
|
80
|
+
max_replicas: number;
|
|
81
|
+
uses_scheduler: boolean;
|
|
82
|
+
uses_sleep_mode: boolean;
|
|
83
|
+
sleep_timeout: number | null;
|
|
84
|
+
uses_octane: boolean;
|
|
85
|
+
uses_inertia_ssr: boolean;
|
|
86
|
+
scaling_cpu_threshold_percentage: number | null;
|
|
87
|
+
scaling_memory_threshold_percentage: number | null;
|
|
88
|
+
created_at: string;
|
|
89
|
+
};
|
|
90
|
+
relationships?: Record<string, {
|
|
91
|
+
[x: string]: unknown;
|
|
92
|
+
data?: {
|
|
93
|
+
type: string;
|
|
94
|
+
id: string;
|
|
95
|
+
meta?: Record<string, any> | undefined;
|
|
96
|
+
} | {
|
|
97
|
+
type: string;
|
|
98
|
+
id: string;
|
|
99
|
+
meta?: Record<string, any> | undefined;
|
|
100
|
+
}[] | undefined;
|
|
101
|
+
links?: {
|
|
102
|
+
related?: {
|
|
103
|
+
[x: string]: unknown;
|
|
104
|
+
href?: string | undefined;
|
|
105
|
+
rel?: string | undefined;
|
|
106
|
+
describedby?: string | undefined;
|
|
107
|
+
title?: string | undefined;
|
|
108
|
+
type?: string | undefined;
|
|
109
|
+
hreflang?: string | undefined;
|
|
110
|
+
meta?: Record<string, any> | undefined;
|
|
111
|
+
} | undefined;
|
|
112
|
+
self?: {
|
|
113
|
+
[x: string]: unknown;
|
|
114
|
+
href?: string | undefined;
|
|
115
|
+
rel?: string | undefined;
|
|
116
|
+
describedby?: string | undefined;
|
|
117
|
+
title?: string | undefined;
|
|
118
|
+
type?: string | undefined;
|
|
119
|
+
hreflang?: string | undefined;
|
|
120
|
+
meta?: Record<string, any> | undefined;
|
|
121
|
+
} | undefined;
|
|
122
|
+
} | undefined;
|
|
123
|
+
meta?: Record<string, any> | undefined;
|
|
124
|
+
}> | undefined;
|
|
125
|
+
links?: {
|
|
126
|
+
self?: {
|
|
127
|
+
[x: string]: unknown;
|
|
128
|
+
href?: string | undefined;
|
|
129
|
+
rel?: string | undefined;
|
|
130
|
+
describedby?: string | undefined;
|
|
131
|
+
title?: string | undefined;
|
|
132
|
+
type?: string | undefined;
|
|
133
|
+
hreflang?: string | undefined;
|
|
134
|
+
meta?: Record<string, any> | undefined;
|
|
135
|
+
} | undefined;
|
|
136
|
+
} | undefined;
|
|
137
|
+
meta?: Record<string, any> | undefined;
|
|
138
|
+
};
|
|
11
139
|
name: string;
|
|
12
140
|
type: string;
|
|
13
141
|
size: string;
|
|
@@ -15,15 +143,91 @@ export interface Instance {
|
|
|
15
143
|
minReplicas: number;
|
|
16
144
|
maxReplicas: number;
|
|
17
145
|
usesScheduler: boolean;
|
|
18
|
-
usesSleepMode
|
|
19
|
-
sleepTimeout
|
|
20
|
-
usesOctane
|
|
21
|
-
usesInertiaSsr
|
|
22
|
-
scalingCpuThresholdPercentage
|
|
23
|
-
scalingMemoryThresholdPercentage
|
|
146
|
+
usesSleepMode: boolean;
|
|
147
|
+
sleepTimeout: number | null;
|
|
148
|
+
usesOctane: boolean;
|
|
149
|
+
usesInertiaSsr: boolean;
|
|
150
|
+
scalingCpuThresholdPercentage: number | null;
|
|
151
|
+
scalingMemoryThresholdPercentage: number | null;
|
|
24
152
|
createdAt: string;
|
|
25
|
-
|
|
26
|
-
|
|
153
|
+
}, {
|
|
154
|
+
[x: string]: unknown;
|
|
155
|
+
id: string;
|
|
156
|
+
type: "instances";
|
|
157
|
+
attributes: {
|
|
158
|
+
[x: string]: unknown;
|
|
159
|
+
name: string;
|
|
160
|
+
type: string;
|
|
161
|
+
size: string;
|
|
162
|
+
scaling_type: string;
|
|
163
|
+
min_replicas: number;
|
|
164
|
+
max_replicas: number;
|
|
165
|
+
uses_scheduler: boolean;
|
|
166
|
+
uses_sleep_mode: boolean;
|
|
167
|
+
sleep_timeout: number | null;
|
|
168
|
+
uses_octane: boolean;
|
|
169
|
+
uses_inertia_ssr: boolean;
|
|
170
|
+
scaling_cpu_threshold_percentage: number | null;
|
|
171
|
+
scaling_memory_threshold_percentage: number | null;
|
|
172
|
+
created_at: string;
|
|
173
|
+
};
|
|
174
|
+
relationships?: Record<string, {
|
|
175
|
+
[x: string]: unknown;
|
|
176
|
+
data?: {
|
|
177
|
+
type: string;
|
|
178
|
+
id: string;
|
|
179
|
+
meta?: Record<string, any> | undefined;
|
|
180
|
+
} | {
|
|
181
|
+
type: string;
|
|
182
|
+
id: string;
|
|
183
|
+
meta?: Record<string, any> | undefined;
|
|
184
|
+
}[] | undefined;
|
|
185
|
+
links?: {
|
|
186
|
+
related?: {
|
|
187
|
+
[x: string]: unknown;
|
|
188
|
+
href?: string | undefined;
|
|
189
|
+
rel?: string | undefined;
|
|
190
|
+
describedby?: string | undefined;
|
|
191
|
+
title?: string | undefined;
|
|
192
|
+
type?: string | undefined;
|
|
193
|
+
hreflang?: string | undefined;
|
|
194
|
+
meta?: Record<string, any> | undefined;
|
|
195
|
+
} | undefined;
|
|
196
|
+
self?: {
|
|
197
|
+
[x: string]: unknown;
|
|
198
|
+
href?: string | undefined;
|
|
199
|
+
rel?: string | undefined;
|
|
200
|
+
describedby?: string | undefined;
|
|
201
|
+
title?: string | undefined;
|
|
202
|
+
type?: string | undefined;
|
|
203
|
+
hreflang?: string | undefined;
|
|
204
|
+
meta?: Record<string, any> | undefined;
|
|
205
|
+
} | undefined;
|
|
206
|
+
} | undefined;
|
|
207
|
+
meta?: Record<string, any> | undefined;
|
|
208
|
+
}> | undefined;
|
|
209
|
+
links?: {
|
|
210
|
+
self?: {
|
|
211
|
+
[x: string]: unknown;
|
|
212
|
+
href?: string | undefined;
|
|
213
|
+
rel?: string | undefined;
|
|
214
|
+
describedby?: string | undefined;
|
|
215
|
+
title?: string | undefined;
|
|
216
|
+
type?: string | undefined;
|
|
217
|
+
hreflang?: string | undefined;
|
|
218
|
+
meta?: Record<string, any> | undefined;
|
|
219
|
+
} | undefined;
|
|
220
|
+
} | undefined;
|
|
221
|
+
meta?: Record<string, any> | undefined;
|
|
222
|
+
}>>;
|
|
223
|
+
export type Instance = z.infer<typeof transformedInstanceSchema>;
|
|
224
|
+
declare const backgroundProcessSchema: z.ZodObject<{
|
|
225
|
+
type: z.ZodString;
|
|
226
|
+
processes: z.ZodNumber;
|
|
227
|
+
command: z.ZodOptional<z.ZodString>;
|
|
228
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
229
|
+
}, z.core.$strict>;
|
|
230
|
+
export type InstanceBackgroundProcess = z.infer<typeof backgroundProcessSchema>;
|
|
27
231
|
export interface ListInstancesOptions {
|
|
28
232
|
include?: Array<'environment' | 'backgroundProcesses'>;
|
|
29
233
|
filter?: {
|
|
@@ -81,3 +285,4 @@ export declare class InstancesResource {
|
|
|
81
285
|
update(instanceId: string, payload: UpdateInstancePayload): Promise<InstanceResponse>;
|
|
82
286
|
delete(instanceId: string): Promise<void>;
|
|
83
287
|
}
|
|
288
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { createJsonApiCollectionSchema, createJsonApiResponseSchema, JsonApiResourceSchema, } from '../types/jsonApi.js';
|
|
3
|
+
import { keysToCamel } from '../utils/caseConversion.js';
|
|
3
4
|
const instanceAttributesSchema = z
|
|
4
5
|
.object({
|
|
5
6
|
name: z.string(),
|
|
@@ -9,12 +10,12 @@ const instanceAttributesSchema = z
|
|
|
9
10
|
min_replicas: z.number(),
|
|
10
11
|
max_replicas: z.number(),
|
|
11
12
|
uses_scheduler: z.boolean(),
|
|
12
|
-
uses_sleep_mode: z.boolean()
|
|
13
|
-
sleep_timeout: z.number().nullable()
|
|
14
|
-
uses_octane: z.boolean()
|
|
15
|
-
uses_inertia_ssr: z.boolean()
|
|
16
|
-
scaling_cpu_threshold_percentage: z.number().nullable()
|
|
17
|
-
scaling_memory_threshold_percentage: z.number().nullable()
|
|
13
|
+
uses_sleep_mode: z.boolean(),
|
|
14
|
+
sleep_timeout: z.number().nullable(),
|
|
15
|
+
uses_octane: z.boolean(),
|
|
16
|
+
uses_inertia_ssr: z.boolean(),
|
|
17
|
+
scaling_cpu_threshold_percentage: z.number().nullable(),
|
|
18
|
+
scaling_memory_threshold_percentage: z.number().nullable(),
|
|
18
19
|
created_at: z.string(),
|
|
19
20
|
})
|
|
20
21
|
.passthrough();
|
|
@@ -22,6 +23,12 @@ const instanceResourceSchema = JsonApiResourceSchema.extend({
|
|
|
22
23
|
type: z.literal('instances'),
|
|
23
24
|
attributes: instanceAttributesSchema,
|
|
24
25
|
});
|
|
26
|
+
// Transform resource to camelCase with raw data preserved
|
|
27
|
+
const transformedInstanceSchema = instanceResourceSchema.transform((data) => ({
|
|
28
|
+
...keysToCamel(data.attributes),
|
|
29
|
+
id: data.id,
|
|
30
|
+
raw: data,
|
|
31
|
+
}));
|
|
25
32
|
const instanceResponseSchema = createJsonApiResponseSchema(instanceResourceSchema);
|
|
26
33
|
const instanceCollectionSchema = createJsonApiCollectionSchema(instanceResourceSchema);
|
|
27
34
|
const backgroundProcessSchema = z
|
|
@@ -32,27 +39,9 @@ const backgroundProcessSchema = z
|
|
|
32
39
|
config: z.record(z.string(), z.any()).optional(),
|
|
33
40
|
})
|
|
34
41
|
.strict();
|
|
42
|
+
// Simple transformation - schema handles the conversion
|
|
35
43
|
const mapInstance = (resource) => {
|
|
36
|
-
|
|
37
|
-
const { attributes } = parsed;
|
|
38
|
-
return {
|
|
39
|
-
id: parsed.id,
|
|
40
|
-
name: attributes.name,
|
|
41
|
-
type: attributes.type,
|
|
42
|
-
size: attributes.size,
|
|
43
|
-
scalingType: attributes.scaling_type,
|
|
44
|
-
minReplicas: attributes.min_replicas,
|
|
45
|
-
maxReplicas: attributes.max_replicas,
|
|
46
|
-
usesScheduler: attributes.uses_scheduler,
|
|
47
|
-
usesSleepMode: attributes.uses_sleep_mode,
|
|
48
|
-
sleepTimeout: attributes.sleep_timeout ?? null,
|
|
49
|
-
usesOctane: attributes.uses_octane,
|
|
50
|
-
usesInertiaSsr: attributes.uses_inertia_ssr,
|
|
51
|
-
scalingCpuThresholdPercentage: attributes.scaling_cpu_threshold_percentage ?? null,
|
|
52
|
-
scalingMemoryThresholdPercentage: attributes.scaling_memory_threshold_percentage ?? null,
|
|
53
|
-
createdAt: attributes.created_at,
|
|
54
|
-
raw: parsed,
|
|
55
|
-
};
|
|
44
|
+
return transformedInstanceSchema.parse(resource);
|
|
56
45
|
};
|
|
57
46
|
const serializeInstanceList = (response) => ({
|
|
58
47
|
data: response.data.map(mapInstance),
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a snake_case string to camelCase
|
|
3
|
+
*/
|
|
4
|
+
export declare function snakeToCamel(str: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* TypeScript utility type to convert snake_case to camelCase at the type level
|
|
7
|
+
*/
|
|
8
|
+
type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCase<P3>}` : S;
|
|
9
|
+
/**
|
|
10
|
+
* Convert all keys of an object type from snake_case to camelCase
|
|
11
|
+
*/
|
|
12
|
+
export type KeysToCamelCase<T> = {
|
|
13
|
+
[K in keyof T as K extends string ? CamelCase<K> : K]: T[K];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Convert all keys in an object from snake_case to camelCase
|
|
17
|
+
* Recursively handles nested objects and arrays
|
|
18
|
+
*/
|
|
19
|
+
export declare function keysToCamel<T extends Record<string, unknown>>(obj: T): KeysToCamelCase<T>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a snake_case string to camelCase
|
|
3
|
+
*/
|
|
4
|
+
export function snakeToCamel(str) {
|
|
5
|
+
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Convert all keys in an object from snake_case to camelCase
|
|
9
|
+
* Recursively handles nested objects and arrays
|
|
10
|
+
*/
|
|
11
|
+
export function keysToCamel(obj) {
|
|
12
|
+
if (!obj || typeof obj !== 'object') {
|
|
13
|
+
return obj;
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(obj)) {
|
|
16
|
+
return obj.map((item) => typeof item === 'object' && item !== null ? keysToCamel(item) : item);
|
|
17
|
+
}
|
|
18
|
+
const result = {};
|
|
19
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
20
|
+
const camelKey = snakeToCamel(key);
|
|
21
|
+
// Recursively convert nested objects and arrays
|
|
22
|
+
if (value && typeof value === 'object') {
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
result[camelKey] = value.map((item) => typeof item === 'object' && item !== null ? keysToCamel(item) : item);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
result[camelKey] = keysToCamel(value);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
result[camelKey] = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|