@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,6 +1,37 @@
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
+ declare const deploymentStatusSchema: z.ZodEnum<{
5
+ pending: "pending";
6
+ "build.pending": "build.pending";
7
+ "build.created": "build.created";
8
+ "build.queued": "build.queued";
9
+ "build.running": "build.running";
10
+ "build.succeeded": "build.succeeded";
11
+ "build.failed": "build.failed";
12
+ cancelled: "cancelled";
13
+ failed: "failed";
14
+ "deployment.pending": "deployment.pending";
15
+ "deployment.created": "deployment.created";
16
+ "deployment.queued": "deployment.queued";
17
+ "deployment.running": "deployment.running";
18
+ "deployment.succeeded": "deployment.succeeded";
19
+ "deployment.failed": "deployment.failed";
20
+ }>;
21
+ declare const nodeVersionSchema: z.ZodEnum<{
22
+ 20: "20";
23
+ 22: "22";
24
+ 24: "24";
25
+ }>;
26
+ declare const phpMajorVersionSchema: z.ZodEnum<{
27
+ 8.2: "8.2";
28
+ 8.3: "8.3";
29
+ 8.4: "8.4";
30
+ 8.5: "8.5";
31
+ }>;
32
+ export type DeploymentStatus = z.infer<typeof deploymentStatusSchema>;
33
+ export type NodeVersion = z.infer<typeof nodeVersionSchema>;
34
+ export type PhpMajorVersion = z.infer<typeof phpMajorVersionSchema>;
4
35
  export declare const deploymentResourceSchema: z.ZodObject<{
5
36
  id: z.ZodString;
6
37
  relationships: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -49,21 +80,287 @@ export declare const deploymentResourceSchema: z.ZodObject<{
49
80
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
50
81
  type: z.ZodLiteral<"deployments">;
51
82
  attributes: z.ZodObject<{
52
- status: z.ZodString;
83
+ status: z.ZodEnum<{
84
+ pending: "pending";
85
+ "build.pending": "build.pending";
86
+ "build.created": "build.created";
87
+ "build.queued": "build.queued";
88
+ "build.running": "build.running";
89
+ "build.succeeded": "build.succeeded";
90
+ "build.failed": "build.failed";
91
+ cancelled: "cancelled";
92
+ failed: "failed";
93
+ "deployment.pending": "deployment.pending";
94
+ "deployment.created": "deployment.created";
95
+ "deployment.queued": "deployment.queued";
96
+ "deployment.running": "deployment.running";
97
+ "deployment.succeeded": "deployment.succeeded";
98
+ "deployment.failed": "deployment.failed";
99
+ }>;
53
100
  branch_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
54
101
  commit_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
55
102
  commit_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
56
103
  commit_author: z.ZodOptional<z.ZodNullable<z.ZodString>>;
57
104
  failure_reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
- php_major_version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
105
+ php_major_version: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
106
+ 8.2: "8.2";
107
+ 8.3: "8.3";
108
+ 8.4: "8.4";
109
+ 8.5: "8.5";
110
+ }>>>;
59
111
  build_command: z.ZodOptional<z.ZodNullable<z.ZodString>>;
60
- node_version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
112
+ node_version: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
113
+ 20: "20";
114
+ 22: "22";
115
+ 24: "24";
116
+ }>>>;
61
117
  uses_octane: z.ZodOptional<z.ZodBoolean>;
62
118
  uses_hibernation: z.ZodOptional<z.ZodBoolean>;
63
119
  started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
64
120
  finished_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
65
121
  }, z.core.$loose>;
66
122
  }, z.core.$loose>;
123
+ declare const transformedDeploymentSchema: z.ZodPipe<z.ZodObject<{
124
+ id: z.ZodString;
125
+ relationships: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
126
+ data: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
127
+ type: z.ZodString;
128
+ id: z.ZodString;
129
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
130
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
131
+ type: z.ZodString;
132
+ id: z.ZodString;
133
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
134
+ }, z.core.$strip>>]>>;
135
+ links: z.ZodOptional<z.ZodObject<{
136
+ related: z.ZodOptional<z.ZodObject<{
137
+ href: z.ZodOptional<z.ZodString>;
138
+ rel: z.ZodOptional<z.ZodString>;
139
+ describedby: z.ZodOptional<z.ZodString>;
140
+ title: z.ZodOptional<z.ZodString>;
141
+ type: z.ZodOptional<z.ZodString>;
142
+ hreflang: z.ZodOptional<z.ZodString>;
143
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
144
+ }, z.core.$loose>>;
145
+ self: z.ZodOptional<z.ZodObject<{
146
+ href: z.ZodOptional<z.ZodString>;
147
+ rel: z.ZodOptional<z.ZodString>;
148
+ describedby: z.ZodOptional<z.ZodString>;
149
+ title: z.ZodOptional<z.ZodString>;
150
+ type: z.ZodOptional<z.ZodString>;
151
+ hreflang: z.ZodOptional<z.ZodString>;
152
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
153
+ }, z.core.$loose>>;
154
+ }, z.core.$strip>>;
155
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
156
+ }, z.core.$loose>>>;
157
+ links: z.ZodOptional<z.ZodObject<{
158
+ self: z.ZodOptional<z.ZodObject<{
159
+ href: z.ZodOptional<z.ZodString>;
160
+ rel: z.ZodOptional<z.ZodString>;
161
+ describedby: z.ZodOptional<z.ZodString>;
162
+ title: z.ZodOptional<z.ZodString>;
163
+ type: z.ZodOptional<z.ZodString>;
164
+ hreflang: z.ZodOptional<z.ZodString>;
165
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
166
+ }, z.core.$loose>>;
167
+ }, z.core.$strip>>;
168
+ meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
169
+ type: z.ZodLiteral<"deployments">;
170
+ attributes: z.ZodObject<{
171
+ status: z.ZodEnum<{
172
+ pending: "pending";
173
+ "build.pending": "build.pending";
174
+ "build.created": "build.created";
175
+ "build.queued": "build.queued";
176
+ "build.running": "build.running";
177
+ "build.succeeded": "build.succeeded";
178
+ "build.failed": "build.failed";
179
+ cancelled: "cancelled";
180
+ failed: "failed";
181
+ "deployment.pending": "deployment.pending";
182
+ "deployment.created": "deployment.created";
183
+ "deployment.queued": "deployment.queued";
184
+ "deployment.running": "deployment.running";
185
+ "deployment.succeeded": "deployment.succeeded";
186
+ "deployment.failed": "deployment.failed";
187
+ }>;
188
+ branch_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
189
+ commit_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
190
+ commit_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
191
+ commit_author: z.ZodOptional<z.ZodNullable<z.ZodString>>;
192
+ failure_reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
193
+ php_major_version: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
194
+ 8.2: "8.2";
195
+ 8.3: "8.3";
196
+ 8.4: "8.4";
197
+ 8.5: "8.5";
198
+ }>>>;
199
+ build_command: z.ZodOptional<z.ZodNullable<z.ZodString>>;
200
+ node_version: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
201
+ 20: "20";
202
+ 22: "22";
203
+ 24: "24";
204
+ }>>>;
205
+ uses_octane: z.ZodOptional<z.ZodBoolean>;
206
+ uses_hibernation: z.ZodOptional<z.ZodBoolean>;
207
+ started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
208
+ finished_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
209
+ }, z.core.$loose>;
210
+ }, z.core.$loose>, z.ZodTransform<{
211
+ id: string;
212
+ raw: {
213
+ [x: string]: unknown;
214
+ id: string;
215
+ type: "deployments";
216
+ attributes: {
217
+ [x: string]: unknown;
218
+ status: "pending" | "build.pending" | "build.created" | "build.queued" | "build.running" | "build.succeeded" | "build.failed" | "cancelled" | "failed" | "deployment.pending" | "deployment.created" | "deployment.queued" | "deployment.running" | "deployment.succeeded" | "deployment.failed";
219
+ branch_name?: string | null | undefined;
220
+ commit_hash?: string | null | undefined;
221
+ commit_message?: string | null | undefined;
222
+ commit_author?: string | null | undefined;
223
+ failure_reason?: string | null | undefined;
224
+ php_major_version?: "8.2" | "8.3" | "8.4" | "8.5" | null | undefined;
225
+ build_command?: string | null | undefined;
226
+ node_version?: "20" | "22" | "24" | null | undefined;
227
+ uses_octane?: boolean | undefined;
228
+ uses_hibernation?: boolean | undefined;
229
+ started_at?: string | null | undefined;
230
+ finished_at?: string | null | undefined;
231
+ };
232
+ relationships?: Record<string, {
233
+ [x: string]: unknown;
234
+ data?: {
235
+ type: string;
236
+ id: string;
237
+ meta?: Record<string, any> | undefined;
238
+ } | {
239
+ type: string;
240
+ id: string;
241
+ meta?: Record<string, any> | undefined;
242
+ }[] | undefined;
243
+ links?: {
244
+ related?: {
245
+ [x: string]: unknown;
246
+ href?: string | undefined;
247
+ rel?: string | undefined;
248
+ describedby?: string | undefined;
249
+ title?: string | undefined;
250
+ type?: string | undefined;
251
+ hreflang?: string | undefined;
252
+ meta?: Record<string, any> | undefined;
253
+ } | undefined;
254
+ self?: {
255
+ [x: string]: unknown;
256
+ href?: string | undefined;
257
+ rel?: string | undefined;
258
+ describedby?: string | undefined;
259
+ title?: string | undefined;
260
+ type?: string | undefined;
261
+ hreflang?: string | undefined;
262
+ meta?: Record<string, any> | undefined;
263
+ } | undefined;
264
+ } | undefined;
265
+ meta?: Record<string, any> | undefined;
266
+ }> | undefined;
267
+ links?: {
268
+ self?: {
269
+ [x: string]: unknown;
270
+ href?: string | undefined;
271
+ rel?: string | undefined;
272
+ describedby?: string | undefined;
273
+ title?: string | undefined;
274
+ type?: string | undefined;
275
+ hreflang?: string | undefined;
276
+ meta?: Record<string, any> | undefined;
277
+ } | undefined;
278
+ } | undefined;
279
+ meta?: Record<string, any> | undefined;
280
+ };
281
+ status: "pending" | "build.pending" | "build.created" | "build.queued" | "build.running" | "build.succeeded" | "build.failed" | "cancelled" | "failed" | "deployment.pending" | "deployment.created" | "deployment.queued" | "deployment.running" | "deployment.succeeded" | "deployment.failed";
282
+ branchName?: string | null | undefined;
283
+ commitHash?: string | null | undefined;
284
+ commitMessage?: string | null | undefined;
285
+ commitAuthor?: string | null | undefined;
286
+ failureReason?: string | null | undefined;
287
+ phpMajorVersion?: "8.2" | "8.3" | "8.4" | "8.5" | null | undefined;
288
+ buildCommand?: string | null | undefined;
289
+ nodeVersion?: "20" | "22" | "24" | null | undefined;
290
+ usesOctane?: boolean | undefined;
291
+ usesHibernation?: boolean | undefined;
292
+ startedAt?: string | null | undefined;
293
+ finishedAt?: string | null | undefined;
294
+ }, {
295
+ [x: string]: unknown;
296
+ id: string;
297
+ type: "deployments";
298
+ attributes: {
299
+ [x: string]: unknown;
300
+ status: "pending" | "build.pending" | "build.created" | "build.queued" | "build.running" | "build.succeeded" | "build.failed" | "cancelled" | "failed" | "deployment.pending" | "deployment.created" | "deployment.queued" | "deployment.running" | "deployment.succeeded" | "deployment.failed";
301
+ branch_name?: string | null | undefined;
302
+ commit_hash?: string | null | undefined;
303
+ commit_message?: string | null | undefined;
304
+ commit_author?: string | null | undefined;
305
+ failure_reason?: string | null | undefined;
306
+ php_major_version?: "8.2" | "8.3" | "8.4" | "8.5" | null | undefined;
307
+ build_command?: string | null | undefined;
308
+ node_version?: "20" | "22" | "24" | null | undefined;
309
+ uses_octane?: boolean | undefined;
310
+ uses_hibernation?: boolean | undefined;
311
+ started_at?: string | null | undefined;
312
+ finished_at?: string | null | undefined;
313
+ };
314
+ relationships?: Record<string, {
315
+ [x: string]: unknown;
316
+ data?: {
317
+ type: string;
318
+ id: string;
319
+ meta?: Record<string, any> | undefined;
320
+ } | {
321
+ type: string;
322
+ id: string;
323
+ meta?: Record<string, any> | undefined;
324
+ }[] | undefined;
325
+ links?: {
326
+ related?: {
327
+ [x: string]: unknown;
328
+ href?: string | undefined;
329
+ rel?: string | undefined;
330
+ describedby?: string | undefined;
331
+ title?: string | undefined;
332
+ type?: string | undefined;
333
+ hreflang?: string | undefined;
334
+ meta?: Record<string, any> | undefined;
335
+ } | undefined;
336
+ self?: {
337
+ [x: string]: unknown;
338
+ href?: string | undefined;
339
+ rel?: string | undefined;
340
+ describedby?: string | undefined;
341
+ title?: string | undefined;
342
+ type?: string | undefined;
343
+ hreflang?: string | undefined;
344
+ meta?: Record<string, any> | undefined;
345
+ } | undefined;
346
+ } | undefined;
347
+ meta?: Record<string, any> | undefined;
348
+ }> | undefined;
349
+ links?: {
350
+ self?: {
351
+ [x: string]: unknown;
352
+ href?: string | undefined;
353
+ rel?: string | undefined;
354
+ describedby?: string | undefined;
355
+ title?: string | undefined;
356
+ type?: string | undefined;
357
+ hreflang?: string | undefined;
358
+ meta?: Record<string, any> | undefined;
359
+ } | undefined;
360
+ } | undefined;
361
+ meta?: Record<string, any> | undefined;
362
+ }>>;
363
+ export type Deployment = z.infer<typeof transformedDeploymentSchema>;
67
364
  export declare const deploymentResponseSchema: z.ZodObject<{
68
365
  data: z.ZodObject<{
69
366
  id: z.ZodString;
@@ -113,15 +410,40 @@ export declare const deploymentResponseSchema: z.ZodObject<{
113
410
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
114
411
  type: z.ZodLiteral<"deployments">;
115
412
  attributes: z.ZodObject<{
116
- status: z.ZodString;
413
+ status: z.ZodEnum<{
414
+ pending: "pending";
415
+ "build.pending": "build.pending";
416
+ "build.created": "build.created";
417
+ "build.queued": "build.queued";
418
+ "build.running": "build.running";
419
+ "build.succeeded": "build.succeeded";
420
+ "build.failed": "build.failed";
421
+ cancelled: "cancelled";
422
+ failed: "failed";
423
+ "deployment.pending": "deployment.pending";
424
+ "deployment.created": "deployment.created";
425
+ "deployment.queued": "deployment.queued";
426
+ "deployment.running": "deployment.running";
427
+ "deployment.succeeded": "deployment.succeeded";
428
+ "deployment.failed": "deployment.failed";
429
+ }>;
117
430
  branch_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
118
431
  commit_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
119
432
  commit_message: z.ZodOptional<z.ZodNullable<z.ZodString>>;
120
433
  commit_author: z.ZodOptional<z.ZodNullable<z.ZodString>>;
121
434
  failure_reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
122
- php_major_version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
435
+ php_major_version: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
436
+ 8.2: "8.2";
437
+ 8.3: "8.3";
438
+ 8.4: "8.4";
439
+ 8.5: "8.5";
440
+ }>>>;
123
441
  build_command: z.ZodOptional<z.ZodNullable<z.ZodString>>;
124
- node_version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
442
+ node_version: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
443
+ 20: "20";
444
+ 22: "22";
445
+ 24: "24";
446
+ }>>>;
125
447
  uses_octane: z.ZodOptional<z.ZodBoolean>;
126
448
  uses_hibernation: z.ZodOptional<z.ZodBoolean>;
127
449
  started_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -180,23 +502,6 @@ export declare const deploymentResponseSchema: z.ZodObject<{
180
502
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
181
503
  links: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
182
504
  }, z.core.$strip>;
183
- export interface Deployment {
184
- id: string;
185
- status: string;
186
- branchName?: string | null;
187
- commitHash?: string | null;
188
- commitMessage?: string | null;
189
- commitAuthor?: string | null;
190
- failureReason?: string | null;
191
- phpMajorVersion?: string | null;
192
- buildCommand?: string | null;
193
- nodeVersion?: string | null;
194
- usesOctane?: boolean;
195
- usesHibernation?: boolean;
196
- startedAt?: string | null;
197
- finishedAt?: string | null;
198
- raw: JsonApiResource;
199
- }
200
505
  export interface ListDeploymentsOptions {
201
506
  include?: Array<'environment' | 'initiator'>;
202
507
  filter?: {
@@ -221,3 +526,4 @@ export declare class DeploymentsResource {
221
526
  retrieve(deploymentId: string, options?: Pick<ListDeploymentsOptions, 'include'>): Promise<DeploymentResponse>;
222
527
  initiate(environmentId: string): Promise<DeploymentResponse>;
223
528
  }
529
+ export {};
@@ -1,48 +1,61 @@
1
1
  import { z } from 'zod';
2
2
  import { createJsonApiCollectionSchema, createJsonApiResponseSchema, JsonApiResourceSchema, } from '../types/jsonApi.js';
3
+ import { keysToCamel } from '../utils/caseConversion.js';
4
+ // Define enum schemas
5
+ const deploymentStatusSchema = z.enum([
6
+ 'pending',
7
+ 'build.pending',
8
+ 'build.created',
9
+ 'build.queued',
10
+ 'build.running',
11
+ 'build.succeeded',
12
+ 'build.failed',
13
+ 'cancelled',
14
+ 'failed',
15
+ 'deployment.pending',
16
+ 'deployment.created',
17
+ 'deployment.queued',
18
+ 'deployment.running',
19
+ 'deployment.succeeded',
20
+ 'deployment.failed',
21
+ ]);
22
+ const nodeVersionSchema = z.enum(['20', '22', '24']);
23
+ const phpMajorVersionSchema = z.enum(['8.2', '8.3', '8.4', '8.5']);
24
+ // Define attributes schema with snake_case (matches API)
3
25
  const deploymentAttributesSchema = z
4
26
  .object({
5
- status: z.string(),
27
+ status: deploymentStatusSchema,
6
28
  branch_name: z.string().nullable().optional(),
7
29
  commit_hash: z.string().nullable().optional(),
8
30
  commit_message: z.string().nullable().optional(),
9
31
  commit_author: z.string().nullable().optional(),
10
32
  failure_reason: z.string().nullable().optional(),
11
- php_major_version: z.string().nullable().optional(),
33
+ php_major_version: phpMajorVersionSchema.nullable().optional(),
12
34
  build_command: z.string().nullable().optional(),
13
- node_version: z.string().nullable().optional(),
35
+ node_version: nodeVersionSchema.nullable().optional(),
14
36
  uses_octane: z.boolean().optional(),
15
37
  uses_hibernation: z.boolean().optional(),
16
38
  started_at: z.string().nullable().optional(),
17
39
  finished_at: z.string().nullable().optional(),
18
40
  })
19
- .passthrough();
41
+ .loose();
42
+ // Resource schema for validation
20
43
  export const deploymentResourceSchema = JsonApiResourceSchema.extend({
21
44
  type: z.literal('deployments'),
22
45
  attributes: deploymentAttributesSchema,
23
46
  });
47
+ // Transform resource to camelCase with raw data preserved
48
+ const transformedDeploymentSchema = deploymentResourceSchema.transform((data) => ({
49
+ ...keysToCamel(data.attributes),
50
+ id: data.id,
51
+ raw: data,
52
+ }));
53
+ // Response schemas for API validation
24
54
  export const deploymentResponseSchema = createJsonApiResponseSchema(deploymentResourceSchema);
25
55
  const deploymentCollectionSchema = createJsonApiCollectionSchema(deploymentResourceSchema);
56
+ // Simple transformation - schema handles the conversion
26
57
  const mapDeployment = (resource) => {
27
- const parsed = deploymentResourceSchema.parse(resource);
28
- const { attributes } = parsed;
29
- return {
30
- id: parsed.id,
31
- status: attributes.status,
32
- branchName: attributes.branch_name ?? null,
33
- commitHash: attributes.commit_hash ?? null,
34
- commitMessage: attributes.commit_message ?? null,
35
- commitAuthor: attributes.commit_author ?? null,
36
- failureReason: attributes.failure_reason ?? null,
37
- phpMajorVersion: attributes.php_major_version ?? null,
38
- buildCommand: attributes.build_command ?? null,
39
- nodeVersion: attributes.node_version ?? null,
40
- usesOctane: attributes.uses_octane,
41
- usesHibernation: attributes.uses_hibernation,
42
- startedAt: attributes.started_at ?? null,
43
- finishedAt: attributes.finished_at ?? null,
44
- raw: parsed,
45
- };
58
+ return transformedDeploymentSchema.parse(resource);
46
59
  };
47
60
  const serializeDeploymentList = (response) => ({
48
61
  data: response.data.map(mapDeployment),