@bosunski/laravel-cloud-sdk 0.1.1 → 0.1.2

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.
@@ -48,7 +48,7 @@ export class HttpClient {
48
48
  signal: config.signal,
49
49
  });
50
50
  const contentType = response.headers.get('content-type') ?? '';
51
- const isJson = contentType.includes('application/json');
51
+ const isJson = /json/i.test(contentType);
52
52
  let parsedBody;
53
53
  if (response.status !== 204) {
54
54
  if (isJson) {
@@ -10,7 +10,6 @@ declare const regionSchema: z.ZodEnum<{
10
10
  "ap-southeast-1": "ap-southeast-1";
11
11
  "ap-southeast-2": "ap-southeast-2";
12
12
  "ca-central-1": "ca-central-1";
13
- "me-central-1": "me-central-1";
14
13
  }>;
15
14
  export type Region = z.infer<typeof regionSchema>;
16
15
  export interface ApplicationRepository {
@@ -50,6 +49,7 @@ export interface UpdateApplicationPayload {
50
49
  defaultEnvironmentId?: string;
51
50
  repository?: string;
52
51
  slackChannel?: string | null;
52
+ avatar?: File | Blob;
53
53
  }
54
54
  export interface ApplicationListResponse extends JsonApiResponse<Application[]> {
55
55
  }
@@ -9,14 +9,13 @@ const regionSchema = z.enum([
9
9
  'ap-southeast-1',
10
10
  'ap-southeast-2',
11
11
  'ca-central-1',
12
- 'me-central-1',
13
12
  ]);
14
13
  const repositorySchema = z
15
14
  .object({
16
15
  full_name: z.string(),
17
16
  default_branch: z.string(),
18
17
  })
19
- .partial();
18
+ .strict();
20
19
  const applicationAttributesSchema = z
21
20
  .object({
22
21
  name: z.string(),
@@ -24,7 +23,7 @@ const applicationAttributesSchema = z
24
23
  region: z.string(),
25
24
  slack_channel: z.string().nullable().optional(),
26
25
  created_at: z.string(),
27
- repository: repositorySchema.optional(),
26
+ repository: repositorySchema.nullable().optional(),
28
27
  })
29
28
  .passthrough();
30
29
  const applicationResourceSchema = JsonApiResourceSchema.extend({
@@ -64,6 +63,22 @@ const serializeApplicationResponse = (response) => ({
64
63
  meta: response.meta,
65
64
  links: response.links,
66
65
  });
66
+ const createApplicationSchema = z
67
+ .object({
68
+ repository: z.string().min(1),
69
+ name: z.string().min(3).max(40),
70
+ region: regionSchema,
71
+ })
72
+ .strict();
73
+ const updateApplicationSchema = z
74
+ .object({
75
+ name: z.string().min(3).max(40).optional(),
76
+ slug: z.string().min(3).optional(),
77
+ defaultEnvironmentId: z.string().optional(),
78
+ repository: z.string().optional(),
79
+ slackChannel: z.string().nullable().optional(),
80
+ })
81
+ .strict();
67
82
  export class ApplicationsResource {
68
83
  client;
69
84
  constructor(client) {
@@ -110,33 +125,22 @@ export class ApplicationsResource {
110
125
  return serializeApplicationResponse(response);
111
126
  }
112
127
  async create(payload) {
113
- const parsePayload = z
114
- .object({
115
- repository: z.string().min(1),
116
- name: z.string().min(3).max(40),
117
- region: regionSchema,
118
- })
119
- .parse(payload);
128
+ const parsedPayload = createApplicationSchema.parse(payload);
120
129
  const response = await this.client.request({
121
130
  path: '/applications',
122
131
  method: 'POST',
123
- json: parsePayload,
132
+ json: parsedPayload,
124
133
  schema: applicationResponseSchema,
125
134
  });
126
135
  return serializeApplicationResponse(response);
127
136
  }
128
137
  async update(applicationId, payload) {
129
- const parsedPayload = z
130
- .object({
131
- name: z.string().min(3).max(40).optional(),
132
- slug: z.string().min(3).optional(),
133
- defaultEnvironmentId: z.string().optional(),
134
- repository: z.string().optional(),
135
- slackChannel: z.string().nullable().optional(),
136
- })
137
- .strict()
138
- .parse(payload);
138
+ const { avatar, ...rest } = payload;
139
+ const parsedPayload = updateApplicationSchema.parse(rest);
139
140
  const form = new FormData();
141
+ if (avatar !== undefined) {
142
+ form.set('avatar', avatar);
143
+ }
140
144
  if (parsedPayload.name !== undefined) {
141
145
  form.set('name', parsedPayload.name);
142
146
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bosunski/laravel-cloud-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "TypeScript client for the Laravel Cloud API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",