@bosunski/laravel-cloud-sdk 0.1.1
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/README.md +56 -0
- package/dist/http/client.d.ts +28 -0
- package/dist/http/client.js +79 -0
- package/dist/http/errors.d.ts +21 -0
- package/dist/http/errors.js +17 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +28 -0
- package/dist/resources/applications.d.ts +66 -0
- package/dist/resources/applications.js +163 -0
- package/dist/resources/databases.d.ts +74 -0
- package/dist/resources/databases.js +198 -0
- package/dist/resources/deployments.d.ts +223 -0
- package/dist/resources/deployments.js +112 -0
- package/dist/resources/domains.d.ts +66 -0
- package/dist/resources/domains.js +164 -0
- package/dist/resources/environments.d.ts +159 -0
- package/dist/resources/environments.js +417 -0
- package/dist/resources/instances.d.ts +83 -0
- package/dist/resources/instances.js +257 -0
- package/dist/types/jsonApi.d.ts +211 -0
- package/dist/types/jsonApi.js +57 -0
- package/dist/utils/query.d.ts +4 -0
- package/dist/utils/query.js +29 -0
- package/package.json +49 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createJsonApiCollectionSchema, createJsonApiResponseSchema, JsonApiResourceSchema, } from '../types/jsonApi.js';
|
|
3
|
+
const domainVerificationMethodSchema = z.enum([
|
|
4
|
+
'pre_verification',
|
|
5
|
+
'real_time',
|
|
6
|
+
]);
|
|
7
|
+
const domainRedirectSchema = z.enum(['root_to_www', 'www_to_root']);
|
|
8
|
+
const domainAttributesSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
name: z.string(),
|
|
11
|
+
type: z.string(),
|
|
12
|
+
hostname_status: z.string(),
|
|
13
|
+
ssl_status: z.string(),
|
|
14
|
+
origin_status: z.string(),
|
|
15
|
+
redirect: z.string().nullable().optional(),
|
|
16
|
+
dns_records: z.record(z.string(), z.any()).optional(),
|
|
17
|
+
wildcard: z.record(z.string(), z.any()).optional(),
|
|
18
|
+
www: z.record(z.string(), z.any()).optional(),
|
|
19
|
+
last_verified_at: z.string().nullable().optional(),
|
|
20
|
+
created_at: z.string(),
|
|
21
|
+
})
|
|
22
|
+
.passthrough();
|
|
23
|
+
const domainResourceSchema = JsonApiResourceSchema.extend({
|
|
24
|
+
type: z.literal('domains'),
|
|
25
|
+
attributes: domainAttributesSchema,
|
|
26
|
+
});
|
|
27
|
+
const domainResponseSchema = createJsonApiResponseSchema(domainResourceSchema);
|
|
28
|
+
const domainCollectionSchema = createJsonApiCollectionSchema(domainResourceSchema);
|
|
29
|
+
const mapDomain = (resource) => {
|
|
30
|
+
const parsed = domainResourceSchema.parse(resource);
|
|
31
|
+
const { attributes } = parsed;
|
|
32
|
+
return {
|
|
33
|
+
id: parsed.id,
|
|
34
|
+
name: attributes.name,
|
|
35
|
+
type: attributes.type,
|
|
36
|
+
hostnameStatus: attributes.hostname_status,
|
|
37
|
+
sslStatus: attributes.ssl_status,
|
|
38
|
+
originStatus: attributes.origin_status,
|
|
39
|
+
redirect: attributes.redirect ?? null,
|
|
40
|
+
lastVerifiedAt: attributes.last_verified_at ?? null,
|
|
41
|
+
createdAt: attributes.created_at,
|
|
42
|
+
dnsRecords: attributes.dns_records,
|
|
43
|
+
wildcard: attributes.wildcard,
|
|
44
|
+
www: attributes.www,
|
|
45
|
+
raw: parsed,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
const serializeDomainList = (response) => ({
|
|
49
|
+
data: response.data.map(mapDomain),
|
|
50
|
+
included: response.included,
|
|
51
|
+
meta: response.meta,
|
|
52
|
+
links: response.links,
|
|
53
|
+
});
|
|
54
|
+
const serializeDomainResponse = (response) => ({
|
|
55
|
+
data: mapDomain(response.data),
|
|
56
|
+
included: response.included,
|
|
57
|
+
meta: response.meta,
|
|
58
|
+
links: response.links,
|
|
59
|
+
});
|
|
60
|
+
const createDomainSchema = z.object({
|
|
61
|
+
name: z.string().min(3).max(255),
|
|
62
|
+
wwwRedirect: domainRedirectSchema.nullable().optional(),
|
|
63
|
+
wildcardEnabled: z.boolean().optional(),
|
|
64
|
+
verificationMethod: domainVerificationMethodSchema.optional(),
|
|
65
|
+
});
|
|
66
|
+
const updateDomainSchema = z
|
|
67
|
+
.object({
|
|
68
|
+
verificationMethod: domainVerificationMethodSchema.optional(),
|
|
69
|
+
})
|
|
70
|
+
.strict();
|
|
71
|
+
export class DomainsResource {
|
|
72
|
+
client;
|
|
73
|
+
constructor(client) {
|
|
74
|
+
this.client = client;
|
|
75
|
+
}
|
|
76
|
+
async list(environmentId, options) {
|
|
77
|
+
const query = {};
|
|
78
|
+
if (options?.include?.length) {
|
|
79
|
+
query.include = options.include.join(',');
|
|
80
|
+
}
|
|
81
|
+
if (options?.filter?.name) {
|
|
82
|
+
query['filter[name]'] = options.filter.name;
|
|
83
|
+
}
|
|
84
|
+
if (options?.filter?.hostnameStatus) {
|
|
85
|
+
query['filter[hostname_status]'] = options.filter.hostnameStatus;
|
|
86
|
+
}
|
|
87
|
+
if (options?.filter?.sslStatus) {
|
|
88
|
+
query['filter[ssl_status]'] = options.filter.sslStatus;
|
|
89
|
+
}
|
|
90
|
+
if (options?.filter?.originStatus) {
|
|
91
|
+
query['filter[origin_status]'] = options.filter.originStatus;
|
|
92
|
+
}
|
|
93
|
+
if (options?.page?.number !== undefined) {
|
|
94
|
+
query['page[number]'] = options.page.number;
|
|
95
|
+
}
|
|
96
|
+
if (options?.page?.size !== undefined) {
|
|
97
|
+
query['page[size]'] = options.page.size;
|
|
98
|
+
}
|
|
99
|
+
const response = await this.client.request({
|
|
100
|
+
path: `/environments/${environmentId}/domains`,
|
|
101
|
+
method: 'GET',
|
|
102
|
+
query,
|
|
103
|
+
schema: domainCollectionSchema,
|
|
104
|
+
});
|
|
105
|
+
return serializeDomainList(response);
|
|
106
|
+
}
|
|
107
|
+
async create(environmentId, payload) {
|
|
108
|
+
const parsedPayload = createDomainSchema.parse(payload);
|
|
109
|
+
const response = await this.client.request({
|
|
110
|
+
path: `/environments/${environmentId}/domains`,
|
|
111
|
+
method: 'POST',
|
|
112
|
+
json: {
|
|
113
|
+
name: parsedPayload.name,
|
|
114
|
+
www_redirect: parsedPayload.wwwRedirect ?? undefined,
|
|
115
|
+
wildcard_enabled: parsedPayload.wildcardEnabled,
|
|
116
|
+
verification_method: parsedPayload.verificationMethod,
|
|
117
|
+
},
|
|
118
|
+
schema: domainResponseSchema,
|
|
119
|
+
});
|
|
120
|
+
return serializeDomainResponse(response);
|
|
121
|
+
}
|
|
122
|
+
async retrieve(domainId, options) {
|
|
123
|
+
const query = {};
|
|
124
|
+
if (options?.include?.length) {
|
|
125
|
+
query.include = options.include.join(',');
|
|
126
|
+
}
|
|
127
|
+
if (options?.verify !== undefined) {
|
|
128
|
+
query.verify = String(options.verify);
|
|
129
|
+
}
|
|
130
|
+
const response = await this.client.request({
|
|
131
|
+
path: `/domains/${domainId}`,
|
|
132
|
+
method: 'GET',
|
|
133
|
+
query: Object.keys(query).length ? query : undefined,
|
|
134
|
+
schema: domainResponseSchema,
|
|
135
|
+
});
|
|
136
|
+
return serializeDomainResponse(response);
|
|
137
|
+
}
|
|
138
|
+
async update(domainId, payload) {
|
|
139
|
+
const parsedPayload = updateDomainSchema.parse(payload);
|
|
140
|
+
const response = await this.client.request({
|
|
141
|
+
path: `/domains/${domainId}`,
|
|
142
|
+
method: 'PATCH',
|
|
143
|
+
json: {
|
|
144
|
+
verification_method: parsedPayload.verificationMethod,
|
|
145
|
+
},
|
|
146
|
+
schema: domainResponseSchema,
|
|
147
|
+
});
|
|
148
|
+
return serializeDomainResponse(response);
|
|
149
|
+
}
|
|
150
|
+
async verify(domainId) {
|
|
151
|
+
const response = await this.client.request({
|
|
152
|
+
path: `/domains/${domainId}/verify`,
|
|
153
|
+
method: 'POST',
|
|
154
|
+
schema: domainResponseSchema,
|
|
155
|
+
});
|
|
156
|
+
return serializeDomainResponse(response);
|
|
157
|
+
}
|
|
158
|
+
async delete(domainId) {
|
|
159
|
+
await this.client.request({
|
|
160
|
+
path: `/domains/${domainId}`,
|
|
161
|
+
method: 'DELETE',
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { HttpClient } from '../http/client.js';
|
|
3
|
+
import { JsonApiResponse, JsonApiResource } from '../types/jsonApi.js';
|
|
4
|
+
import type { DeploymentResponse } from './deployments.js';
|
|
5
|
+
declare const colorSchema: z.ZodEnum<{
|
|
6
|
+
blue: "blue";
|
|
7
|
+
green: "green";
|
|
8
|
+
orange: "orange";
|
|
9
|
+
purple: "purple";
|
|
10
|
+
red: "red";
|
|
11
|
+
yellow: "yellow";
|
|
12
|
+
cyan: "cyan";
|
|
13
|
+
gray: "gray";
|
|
14
|
+
}>;
|
|
15
|
+
declare const phpVersionSchema: z.ZodEnum<{
|
|
16
|
+
"8.2:1": "8.2:1";
|
|
17
|
+
"8.3:1": "8.3:1";
|
|
18
|
+
"8.4:1": "8.4:1";
|
|
19
|
+
"8.5:1": "8.5:1";
|
|
20
|
+
}>;
|
|
21
|
+
declare const nodeVersionSchema: z.ZodEnum<{
|
|
22
|
+
20: "20";
|
|
23
|
+
22: "22";
|
|
24
|
+
24: "24";
|
|
25
|
+
}>;
|
|
26
|
+
export interface EnvironmentVariable {
|
|
27
|
+
key: string;
|
|
28
|
+
value?: string | null;
|
|
29
|
+
}
|
|
30
|
+
export interface FilesystemKey {
|
|
31
|
+
id: string;
|
|
32
|
+
disk: string;
|
|
33
|
+
isDefaultDisk?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface Environment {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
slug: string;
|
|
39
|
+
status: string;
|
|
40
|
+
createdAt: string;
|
|
41
|
+
createdFromAutomation?: boolean;
|
|
42
|
+
vanityDomain?: string | null;
|
|
43
|
+
phpMajorVersion?: string;
|
|
44
|
+
buildCommand?: string | null;
|
|
45
|
+
nodeVersion?: string | null;
|
|
46
|
+
deployCommand?: string | null;
|
|
47
|
+
usesOctane?: boolean;
|
|
48
|
+
usesHibernation?: boolean;
|
|
49
|
+
usesPushToDeploy?: boolean;
|
|
50
|
+
usesDeployHook?: boolean;
|
|
51
|
+
environmentVariables?: EnvironmentVariable[];
|
|
52
|
+
raw: JsonApiResource;
|
|
53
|
+
}
|
|
54
|
+
export interface ListEnvironmentsOptions {
|
|
55
|
+
include?: Array<'application' | 'branch' | 'deployments' | 'currentDeployment' | 'primaryDomain' | 'instances'>;
|
|
56
|
+
filter?: {
|
|
57
|
+
name?: string;
|
|
58
|
+
status?: string;
|
|
59
|
+
slug?: string;
|
|
60
|
+
};
|
|
61
|
+
page?: {
|
|
62
|
+
number?: number;
|
|
63
|
+
size?: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export interface CreateEnvironmentPayload {
|
|
67
|
+
branch: string;
|
|
68
|
+
name: string;
|
|
69
|
+
}
|
|
70
|
+
export interface UpdateEnvironmentPayload {
|
|
71
|
+
name?: string;
|
|
72
|
+
slug?: string;
|
|
73
|
+
color?: z.infer<typeof colorSchema>;
|
|
74
|
+
branch?: string;
|
|
75
|
+
usesPushToDeploy?: boolean;
|
|
76
|
+
usesDeployHook?: boolean;
|
|
77
|
+
timeout?: number;
|
|
78
|
+
phpVersion?: z.infer<typeof phpVersionSchema>;
|
|
79
|
+
buildCommand?: string | null;
|
|
80
|
+
nodeVersion?: z.infer<typeof nodeVersionSchema>;
|
|
81
|
+
deployCommand?: string | null;
|
|
82
|
+
usesVanityDomain?: boolean;
|
|
83
|
+
databaseSchemaId?: string | null;
|
|
84
|
+
cacheId?: string | null;
|
|
85
|
+
websocketApplicationId?: string | null;
|
|
86
|
+
environmentVariables?: EnvironmentVariable[];
|
|
87
|
+
usesOctane?: boolean;
|
|
88
|
+
sleepTimeout?: number;
|
|
89
|
+
shutdownTimeout?: number;
|
|
90
|
+
usesPurgeEdgeCacheOnDeploy?: boolean;
|
|
91
|
+
nightwatchToken?: string | null;
|
|
92
|
+
cacheStrategy?: string;
|
|
93
|
+
responseHeadersFrame?: string;
|
|
94
|
+
responseHeadersContentType?: string;
|
|
95
|
+
responseHeadersRobotsTag?: string;
|
|
96
|
+
responseHeadersHsts?: {
|
|
97
|
+
max_age: number;
|
|
98
|
+
include_subdomains?: boolean;
|
|
99
|
+
preload?: boolean;
|
|
100
|
+
} | null;
|
|
101
|
+
filesystemKeys?: Array<Omit<FilesystemKey, 'isDefaultDisk'> & {
|
|
102
|
+
isDefaultDisk?: boolean;
|
|
103
|
+
}>;
|
|
104
|
+
firewallRateLimitLevel?: 'challenge' | 'throttle' | 'ban';
|
|
105
|
+
firewallUnderAttackMode?: boolean;
|
|
106
|
+
}
|
|
107
|
+
export interface StartEnvironmentOptions {
|
|
108
|
+
redeploy?: boolean;
|
|
109
|
+
}
|
|
110
|
+
export interface AddEnvironmentVariablesPayload {
|
|
111
|
+
method: 'append' | 'set';
|
|
112
|
+
variables: EnvironmentVariable[];
|
|
113
|
+
}
|
|
114
|
+
export interface ReplaceEnvironmentVariablesPayload {
|
|
115
|
+
content?: string | null;
|
|
116
|
+
variables?: EnvironmentVariable[];
|
|
117
|
+
}
|
|
118
|
+
export interface ListEnvironmentLogsOptions {
|
|
119
|
+
from: string;
|
|
120
|
+
to: string;
|
|
121
|
+
query?: string;
|
|
122
|
+
type?: 'all' | 'application' | 'access';
|
|
123
|
+
cursor?: string;
|
|
124
|
+
}
|
|
125
|
+
export interface EnvironmentLogEntry {
|
|
126
|
+
message: string;
|
|
127
|
+
level: string;
|
|
128
|
+
type: string;
|
|
129
|
+
loggedAt: string;
|
|
130
|
+
data?: Record<string, unknown>;
|
|
131
|
+
}
|
|
132
|
+
export interface EnvironmentLogsResponse {
|
|
133
|
+
data: EnvironmentLogEntry[];
|
|
134
|
+
meta: Record<string, unknown> & {
|
|
135
|
+
cursor?: string | null;
|
|
136
|
+
type?: string | null;
|
|
137
|
+
from: string;
|
|
138
|
+
to: string;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export interface EnvironmentListResponse extends JsonApiResponse<Environment[]> {
|
|
142
|
+
}
|
|
143
|
+
export interface EnvironmentResponse extends JsonApiResponse<Environment> {
|
|
144
|
+
}
|
|
145
|
+
export declare class EnvironmentsResource {
|
|
146
|
+
private readonly client;
|
|
147
|
+
constructor(client: HttpClient);
|
|
148
|
+
list(applicationId: string, options?: ListEnvironmentsOptions): Promise<EnvironmentListResponse>;
|
|
149
|
+
retrieve(environmentId: string, options?: Pick<ListEnvironmentsOptions, 'include'>): Promise<EnvironmentResponse>;
|
|
150
|
+
create(applicationId: string, payload: CreateEnvironmentPayload): Promise<EnvironmentResponse>;
|
|
151
|
+
update(environmentId: string, payload: UpdateEnvironmentPayload): Promise<EnvironmentResponse>;
|
|
152
|
+
delete(environmentId: string): Promise<void>;
|
|
153
|
+
start(environmentId: string, options?: StartEnvironmentOptions): Promise<DeploymentResponse>;
|
|
154
|
+
stop(environmentId: string): Promise<EnvironmentResponse>;
|
|
155
|
+
addVariables(environmentId: string, payload: AddEnvironmentVariablesPayload): Promise<EnvironmentResponse>;
|
|
156
|
+
replaceVariables(environmentId: string, payload: ReplaceEnvironmentVariablesPayload): Promise<EnvironmentResponse>;
|
|
157
|
+
listLogs(environmentId: string, options: ListEnvironmentLogsOptions): Promise<EnvironmentLogsResponse>;
|
|
158
|
+
}
|
|
159
|
+
export {};
|