@bosunski/laravel-cloud-sdk 0.1.1 → 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,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,