@bosunski/laravel-cloud-sdk 0.1.2 → 0.1.4

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.
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { HttpClient } from '../http/client.js';
3
- import { JsonApiResponse, JsonApiResource } from '../types/jsonApi.js';
3
+ import { JsonApiResponse } from '../types/jsonApi.js';
4
4
  declare const regionSchema: z.ZodEnum<{
5
5
  "us-east-2": "us-east-2";
6
6
  "us-east-1": "us-east-1";
@@ -11,21 +11,207 @@ declare const regionSchema: z.ZodEnum<{
11
11
  "ap-southeast-2": "ap-southeast-2";
12
12
  "ca-central-1": "ca-central-1";
13
13
  }>;
14
- export type Region = z.infer<typeof regionSchema>;
15
- export interface ApplicationRepository {
16
- fullName?: string;
17
- defaultBranch?: string;
18
- }
19
- export interface Application {
14
+ declare const transformedApplicationSchema: z.ZodPipe<z.ZodObject<{
15
+ id: z.ZodString;
16
+ relationships: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
17
+ data: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
18
+ type: z.ZodString;
19
+ id: z.ZodString;
20
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
21
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
22
+ type: z.ZodString;
23
+ id: z.ZodString;
24
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
25
+ }, z.core.$strip>>]>>;
26
+ links: z.ZodOptional<z.ZodObject<{
27
+ related: z.ZodOptional<z.ZodObject<{
28
+ href: z.ZodOptional<z.ZodString>;
29
+ rel: z.ZodOptional<z.ZodString>;
30
+ describedby: z.ZodOptional<z.ZodString>;
31
+ title: z.ZodOptional<z.ZodString>;
32
+ type: z.ZodOptional<z.ZodString>;
33
+ hreflang: z.ZodOptional<z.ZodString>;
34
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
35
+ }, z.core.$loose>>;
36
+ self: z.ZodOptional<z.ZodObject<{
37
+ href: z.ZodOptional<z.ZodString>;
38
+ rel: z.ZodOptional<z.ZodString>;
39
+ describedby: z.ZodOptional<z.ZodString>;
40
+ title: z.ZodOptional<z.ZodString>;
41
+ type: z.ZodOptional<z.ZodString>;
42
+ hreflang: z.ZodOptional<z.ZodString>;
43
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
44
+ }, z.core.$loose>>;
45
+ }, z.core.$strip>>;
46
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
47
+ }, z.core.$loose>>>;
48
+ links: z.ZodOptional<z.ZodObject<{
49
+ self: z.ZodOptional<z.ZodObject<{
50
+ href: z.ZodOptional<z.ZodString>;
51
+ rel: z.ZodOptional<z.ZodString>;
52
+ describedby: z.ZodOptional<z.ZodString>;
53
+ title: z.ZodOptional<z.ZodString>;
54
+ type: z.ZodOptional<z.ZodString>;
55
+ hreflang: z.ZodOptional<z.ZodString>;
56
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
57
+ }, z.core.$loose>>;
58
+ }, z.core.$strip>>;
59
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
60
+ type: z.ZodLiteral<"applications">;
61
+ attributes: z.ZodObject<{
62
+ name: z.ZodString;
63
+ slug: z.ZodString;
64
+ region: z.ZodString;
65
+ slack_channel: z.ZodOptional<z.ZodNullable<z.ZodString>>;
66
+ created_at: z.ZodString;
67
+ repository: z.ZodOptional<z.ZodNullable<z.ZodObject<{
68
+ full_name: z.ZodString;
69
+ default_branch: z.ZodString;
70
+ }, z.core.$strict>>>;
71
+ }, z.core.$loose>;
72
+ }, z.core.$loose>, z.ZodTransform<{
20
73
  id: string;
74
+ raw: {
75
+ [x: string]: unknown;
76
+ id: string;
77
+ type: "applications";
78
+ attributes: {
79
+ [x: string]: unknown;
80
+ name: string;
81
+ slug: string;
82
+ region: string;
83
+ created_at: string;
84
+ slack_channel?: string | null | undefined;
85
+ repository?: {
86
+ full_name: string;
87
+ default_branch: string;
88
+ } | null | undefined;
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
+ };
21
139
  name: string;
22
140
  slug: string;
23
141
  region: string;
24
- slackChannel?: string | null;
25
142
  createdAt: string;
26
- repository?: ApplicationRepository;
27
- raw: JsonApiResource;
28
- }
143
+ slackChannel?: string | null | undefined;
144
+ repository?: {
145
+ full_name: string;
146
+ default_branch: string;
147
+ } | null | undefined;
148
+ }, {
149
+ [x: string]: unknown;
150
+ id: string;
151
+ type: "applications";
152
+ attributes: {
153
+ [x: string]: unknown;
154
+ name: string;
155
+ slug: string;
156
+ region: string;
157
+ created_at: string;
158
+ slack_channel?: string | null | undefined;
159
+ repository?: {
160
+ full_name: string;
161
+ default_branch: string;
162
+ } | null | undefined;
163
+ };
164
+ relationships?: Record<string, {
165
+ [x: string]: unknown;
166
+ data?: {
167
+ type: string;
168
+ id: string;
169
+ meta?: Record<string, any> | undefined;
170
+ } | {
171
+ type: string;
172
+ id: string;
173
+ meta?: Record<string, any> | undefined;
174
+ }[] | undefined;
175
+ links?: {
176
+ related?: {
177
+ [x: string]: unknown;
178
+ href?: string | undefined;
179
+ rel?: string | undefined;
180
+ describedby?: string | undefined;
181
+ title?: string | undefined;
182
+ type?: string | undefined;
183
+ hreflang?: string | undefined;
184
+ meta?: Record<string, any> | undefined;
185
+ } | undefined;
186
+ self?: {
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
+ } | undefined;
197
+ meta?: Record<string, any> | undefined;
198
+ }> | undefined;
199
+ links?: {
200
+ self?: {
201
+ [x: string]: unknown;
202
+ href?: string | undefined;
203
+ rel?: string | undefined;
204
+ describedby?: string | undefined;
205
+ title?: string | undefined;
206
+ type?: string | undefined;
207
+ hreflang?: string | undefined;
208
+ meta?: Record<string, any> | undefined;
209
+ } | undefined;
210
+ } | undefined;
211
+ meta?: Record<string, any> | undefined;
212
+ }>>;
213
+ export type Region = z.infer<typeof regionSchema>;
214
+ export type Application = z.infer<typeof transformedApplicationSchema>;
29
215
  export interface ListApplicationsOptions {
30
216
  include?: Array<'organization' | 'environments' | 'defaultEnvironment'>;
31
217
  filter?: {
@@ -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 regionSchema = z.enum([
4
5
  'us-east-2',
5
6
  'us-east-1',
@@ -30,26 +31,17 @@ const applicationResourceSchema = JsonApiResourceSchema.extend({
30
31
  type: z.literal('applications'),
31
32
  attributes: applicationAttributesSchema,
32
33
  });
34
+ // Transform resource to camelCase with raw data preserved
35
+ const transformedApplicationSchema = applicationResourceSchema.transform((data) => ({
36
+ ...keysToCamel(data.attributes),
37
+ id: data.id,
38
+ raw: data,
39
+ }));
33
40
  const applicationResponseSchema = createJsonApiResponseSchema(applicationResourceSchema);
34
41
  const applicationCollectionSchema = createJsonApiCollectionSchema(applicationResourceSchema);
42
+ // Simple transformation - schema handles the conversion
35
43
  const mapApplication = (resource) => {
36
- const parsed = applicationResourceSchema.parse(resource);
37
- const { attributes } = parsed;
38
- return {
39
- id: parsed.id,
40
- name: attributes.name,
41
- slug: attributes.slug,
42
- region: attributes.region,
43
- slackChannel: attributes.slack_channel ?? null,
44
- createdAt: attributes.created_at,
45
- repository: attributes.repository
46
- ? {
47
- fullName: attributes.repository.full_name,
48
- defaultBranch: attributes.repository.default_branch,
49
- }
50
- : undefined,
51
- raw: parsed,
52
- };
44
+ return transformedApplicationSchema.parse(resource);
53
45
  };
54
46
  const serializeApplicationList = (response) => ({
55
47
  data: response.data.map(mapApplication),
@@ -1,26 +1,292 @@
1
+ import { z } from 'zod';
1
2
  import { HttpClient } from '../http/client.js';
2
- import { JsonApiResponse, JsonApiResource } from '../types/jsonApi.js';
3
- export interface DatabaseConnection {
4
- hostname: string;
5
- port: number;
6
- protocol: string;
7
- driver: string;
8
- username: string;
9
- password: string;
10
- [key: string]: unknown;
11
- }
12
- export type DatabaseConfig = Record<string, unknown>;
13
- export interface Database {
3
+ import { JsonApiResponse } from '../types/jsonApi.js';
4
+ declare const transformedDatabaseSchema: 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<"databases">;
51
+ attributes: z.ZodObject<{
52
+ name: z.ZodString;
53
+ type: z.ZodString;
54
+ status: z.ZodString;
55
+ region: z.ZodString;
56
+ created_at: z.ZodString;
57
+ config: z.ZodRecord<z.ZodString, z.ZodAny>;
58
+ connection: z.ZodObject<{
59
+ hostname: z.ZodString;
60
+ port: z.ZodNumber;
61
+ protocol: z.ZodString;
62
+ driver: z.ZodString;
63
+ username: z.ZodString;
64
+ password: z.ZodString;
65
+ }, z.core.$loose>;
66
+ }, z.core.$loose>;
67
+ }, z.core.$loose>, z.ZodTransform<{
14
68
  id: string;
69
+ raw: {
70
+ [x: string]: unknown;
71
+ id: string;
72
+ type: "databases";
73
+ attributes: {
74
+ [x: string]: unknown;
75
+ name: string;
76
+ type: string;
77
+ status: string;
78
+ region: string;
79
+ created_at: string;
80
+ config: Record<string, any>;
81
+ connection: {
82
+ [x: string]: unknown;
83
+ hostname: string;
84
+ port: number;
85
+ protocol: string;
86
+ driver: string;
87
+ username: string;
88
+ password: string;
89
+ };
90
+ };
91
+ relationships?: Record<string, {
92
+ [x: string]: unknown;
93
+ data?: {
94
+ type: string;
95
+ id: string;
96
+ meta?: Record<string, any> | undefined;
97
+ } | {
98
+ type: string;
99
+ id: string;
100
+ meta?: Record<string, any> | undefined;
101
+ }[] | undefined;
102
+ links?: {
103
+ related?: {
104
+ [x: string]: unknown;
105
+ href?: string | undefined;
106
+ rel?: string | undefined;
107
+ describedby?: string | undefined;
108
+ title?: string | undefined;
109
+ type?: string | undefined;
110
+ hreflang?: string | undefined;
111
+ meta?: Record<string, any> | undefined;
112
+ } | undefined;
113
+ self?: {
114
+ [x: string]: unknown;
115
+ href?: string | undefined;
116
+ rel?: string | undefined;
117
+ describedby?: string | undefined;
118
+ title?: string | undefined;
119
+ type?: string | undefined;
120
+ hreflang?: string | undefined;
121
+ meta?: Record<string, any> | undefined;
122
+ } | undefined;
123
+ } | undefined;
124
+ meta?: Record<string, any> | undefined;
125
+ }> | undefined;
126
+ links?: {
127
+ self?: {
128
+ [x: string]: unknown;
129
+ href?: string | undefined;
130
+ rel?: string | undefined;
131
+ describedby?: string | undefined;
132
+ title?: string | undefined;
133
+ type?: string | undefined;
134
+ hreflang?: string | undefined;
135
+ meta?: Record<string, any> | undefined;
136
+ } | undefined;
137
+ } | undefined;
138
+ meta?: Record<string, any> | undefined;
139
+ };
15
140
  name: string;
16
141
  type: string;
17
142
  status: string;
18
143
  region: string;
19
144
  createdAt: string;
20
- config: DatabaseConfig;
21
- connection: DatabaseConnection;
22
- raw: JsonApiResource;
23
- }
145
+ config: Record<string, any>;
146
+ connection: {
147
+ [x: string]: unknown;
148
+ hostname: string;
149
+ port: number;
150
+ protocol: string;
151
+ driver: string;
152
+ username: string;
153
+ password: string;
154
+ };
155
+ }, {
156
+ [x: string]: unknown;
157
+ id: string;
158
+ type: "databases";
159
+ attributes: {
160
+ [x: string]: unknown;
161
+ name: string;
162
+ type: string;
163
+ status: string;
164
+ region: string;
165
+ created_at: string;
166
+ config: Record<string, any>;
167
+ connection: {
168
+ [x: string]: unknown;
169
+ hostname: string;
170
+ port: number;
171
+ protocol: string;
172
+ driver: string;
173
+ username: string;
174
+ password: string;
175
+ };
176
+ };
177
+ relationships?: Record<string, {
178
+ [x: string]: unknown;
179
+ data?: {
180
+ type: string;
181
+ id: string;
182
+ meta?: Record<string, any> | undefined;
183
+ } | {
184
+ type: string;
185
+ id: string;
186
+ meta?: Record<string, any> | undefined;
187
+ }[] | undefined;
188
+ links?: {
189
+ related?: {
190
+ [x: string]: unknown;
191
+ href?: string | undefined;
192
+ rel?: string | undefined;
193
+ describedby?: string | undefined;
194
+ title?: string | undefined;
195
+ type?: string | undefined;
196
+ hreflang?: string | undefined;
197
+ meta?: Record<string, any> | undefined;
198
+ } | undefined;
199
+ self?: {
200
+ [x: string]: unknown;
201
+ href?: string | undefined;
202
+ rel?: string | undefined;
203
+ describedby?: string | undefined;
204
+ title?: string | undefined;
205
+ type?: string | undefined;
206
+ hreflang?: string | undefined;
207
+ meta?: Record<string, any> | undefined;
208
+ } | undefined;
209
+ } | undefined;
210
+ meta?: Record<string, any> | undefined;
211
+ }> | undefined;
212
+ links?: {
213
+ self?: {
214
+ [x: string]: unknown;
215
+ href?: string | undefined;
216
+ rel?: string | undefined;
217
+ describedby?: string | undefined;
218
+ title?: string | undefined;
219
+ type?: string | undefined;
220
+ hreflang?: string | undefined;
221
+ meta?: Record<string, any> | undefined;
222
+ } | undefined;
223
+ } | undefined;
224
+ meta?: Record<string, any> | undefined;
225
+ }>>;
226
+ export type Database = z.infer<typeof transformedDatabaseSchema>;
227
+ export type DatabaseConfig = Record<string, unknown>;
228
+ declare const databaseTypeFieldSchema: z.ZodObject<{
229
+ name: z.ZodString;
230
+ type: z.ZodString;
231
+ required: z.ZodBoolean;
232
+ nullable: z.ZodOptional<z.ZodBoolean>;
233
+ description: z.ZodOptional<z.ZodString>;
234
+ min: z.ZodOptional<z.ZodNumber>;
235
+ max: z.ZodOptional<z.ZodNumber>;
236
+ enum: z.ZodOptional<z.ZodArray<z.ZodString>>;
237
+ example: z.ZodOptional<z.ZodString>;
238
+ }, z.core.$loose>;
239
+ declare const transformedDatabaseTypeSchema: z.ZodPipe<z.ZodObject<{
240
+ type: z.ZodString;
241
+ label: z.ZodString;
242
+ regions: z.ZodArray<z.ZodString>;
243
+ config_schema: z.ZodArray<z.ZodObject<{
244
+ name: z.ZodString;
245
+ type: z.ZodString;
246
+ required: z.ZodBoolean;
247
+ nullable: z.ZodOptional<z.ZodBoolean>;
248
+ description: z.ZodOptional<z.ZodString>;
249
+ min: z.ZodOptional<z.ZodNumber>;
250
+ max: z.ZodOptional<z.ZodNumber>;
251
+ enum: z.ZodOptional<z.ZodArray<z.ZodString>>;
252
+ example: z.ZodOptional<z.ZodString>;
253
+ }, z.core.$loose>>;
254
+ }, z.core.$loose>, z.ZodTransform<{
255
+ configSchema: {
256
+ [x: string]: unknown;
257
+ name: string;
258
+ type: string;
259
+ required: boolean;
260
+ nullable?: boolean | undefined;
261
+ description?: string | undefined;
262
+ min?: number | undefined;
263
+ max?: number | undefined;
264
+ enum?: string[] | undefined;
265
+ example?: string | undefined;
266
+ }[];
267
+ type: string;
268
+ label: string;
269
+ regions: string[];
270
+ }, {
271
+ [x: string]: unknown;
272
+ type: string;
273
+ label: string;
274
+ regions: string[];
275
+ config_schema: {
276
+ [x: string]: unknown;
277
+ name: string;
278
+ type: string;
279
+ required: boolean;
280
+ nullable?: boolean | undefined;
281
+ description?: string | undefined;
282
+ min?: number | undefined;
283
+ max?: number | undefined;
284
+ enum?: string[] | undefined;
285
+ example?: string | undefined;
286
+ }[];
287
+ }>>;
288
+ export type DatabaseTypeDefinition = z.infer<typeof transformedDatabaseTypeSchema>;
289
+ export type DatabaseTypeField = z.infer<typeof databaseTypeFieldSchema>;
24
290
  export interface ListDatabasesOptions {
25
291
  include?: Array<'schemas'>;
26
292
  filter?: {
@@ -40,25 +306,6 @@ export interface CreateDatabasePayload {
40
306
  config: DatabaseConfig;
41
307
  clusterId?: number | null;
42
308
  }
43
- export interface DatabaseTypeField {
44
- name: string;
45
- type: string;
46
- required: boolean;
47
- nullable?: boolean;
48
- description?: string;
49
- min?: number;
50
- max?: number;
51
- enum?: string[];
52
- example?: string;
53
- raw: Record<string, unknown>;
54
- }
55
- export interface DatabaseTypeDefinition {
56
- type: string;
57
- label: string;
58
- regions: string[];
59
- configSchema: DatabaseTypeField[];
60
- raw: Record<string, unknown>;
61
- }
62
309
  export interface DatabaseListResponse extends JsonApiResponse<Database[]> {
63
310
  }
64
311
  export interface DatabaseResponse extends JsonApiResponse<Database> {
@@ -72,3 +319,4 @@ export declare class DatabasesResource {
72
319
  delete(databaseId: string): Promise<void>;
73
320
  listTypes(): Promise<DatabaseTypeDefinition[]>;
74
321
  }
322
+ 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 databaseAttributesSchema = z
4
5
  .object({
5
6
  name: z.string(),
@@ -24,6 +25,12 @@ const databaseResourceSchema = JsonApiResourceSchema.extend({
24
25
  type: z.literal('databases'),
25
26
  attributes: databaseAttributesSchema,
26
27
  });
28
+ // Transform resource to camelCase with raw data preserved
29
+ const transformedDatabaseSchema = databaseResourceSchema.transform((data) => ({
30
+ ...keysToCamel(data.attributes),
31
+ id: data.id,
32
+ raw: data,
33
+ }));
27
34
  const databaseResponseSchema = createJsonApiResponseSchema(databaseResourceSchema);
28
35
  const databaseCollectionSchema = createJsonApiCollectionSchema(databaseResourceSchema);
29
36
  const databaseTypeFieldSchema = z
@@ -50,29 +57,14 @@ const databaseTypeSchema = z
50
57
  const databaseTypesResponseSchema = z.object({
51
58
  data: z.array(databaseTypeSchema),
52
59
  });
60
+ // Transform database type schema to camelCase
61
+ const transformedDatabaseTypeSchema = databaseTypeSchema.transform((data) => ({
62
+ ...keysToCamel(data),
63
+ configSchema: data.config_schema,
64
+ }));
65
+ // Simple transformation - schema handles the conversion
53
66
  const mapDatabase = (resource) => {
54
- const parsed = databaseResourceSchema.parse(resource);
55
- const { attributes } = parsed;
56
- const { hostname, port, protocol, driver, username, password, ...restConnection } = attributes.connection;
57
- return {
58
- id: parsed.id,
59
- name: attributes.name,
60
- type: attributes.type,
61
- status: attributes.status,
62
- region: attributes.region,
63
- createdAt: attributes.created_at,
64
- config: attributes.config,
65
- connection: {
66
- hostname,
67
- port,
68
- protocol,
69
- driver,
70
- username,
71
- password,
72
- ...restConnection,
73
- },
74
- raw: parsed,
75
- };
67
+ return transformedDatabaseSchema.parse(resource);
76
68
  };
77
69
  const serializeDatabaseList = (response) => ({
78
70
  data: response.data.map(mapDatabase),
@@ -95,24 +87,10 @@ const createDatabaseSchema = z
95
87
  clusterId: z.number().int().nullable().optional(),
96
88
  })
97
89
  .strict();
98
- const mapDatabaseType = (item) => ({
99
- type: item.type,
100
- label: item.label,
101
- regions: item.regions,
102
- configSchema: item.config_schema.map((field) => ({
103
- name: field.name,
104
- type: field.type,
105
- required: field.required,
106
- nullable: field.nullable,
107
- description: field.description,
108
- min: field.min,
109
- max: field.max,
110
- enum: field.enum,
111
- example: field.example,
112
- raw: field,
113
- })),
114
- raw: item,
115
- });
90
+ // Simple transformation - schema handles the conversion
91
+ const mapDatabaseType = (item) => {
92
+ return transformedDatabaseTypeSchema.parse(item);
93
+ };
116
94
  const mapCreatePayload = (payload) => {
117
95
  const body = {
118
96
  type: payload.type,