@fndchagas/coolify-mcp 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.
@@ -0,0 +1,137 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
3
+ let lastEventId;
4
+ const sleep = sseSleepFn ??
5
+ ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
6
+ const createStream = async function* () {
7
+ let retryDelay = sseDefaultRetryDelay ?? 3000;
8
+ let attempt = 0;
9
+ const signal = options.signal ?? new AbortController().signal;
10
+ while (true) {
11
+ if (signal.aborted)
12
+ break;
13
+ attempt++;
14
+ const headers = options.headers instanceof Headers
15
+ ? options.headers
16
+ : new Headers(options.headers);
17
+ if (lastEventId !== undefined) {
18
+ headers.set('Last-Event-ID', lastEventId);
19
+ }
20
+ try {
21
+ const requestInit = {
22
+ redirect: 'follow',
23
+ ...options,
24
+ body: options.serializedBody,
25
+ headers,
26
+ signal,
27
+ };
28
+ let request = new Request(url, requestInit);
29
+ if (onRequest) {
30
+ request = await onRequest(url, requestInit);
31
+ }
32
+ // fetch must be assigned here, otherwise it would throw the error:
33
+ // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
34
+ const _fetch = options.fetch ?? globalThis.fetch;
35
+ const response = await _fetch(request);
36
+ if (!response.ok)
37
+ throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
38
+ if (!response.body)
39
+ throw new Error('No body in SSE response');
40
+ const reader = response.body
41
+ .pipeThrough(new TextDecoderStream())
42
+ .getReader();
43
+ let buffer = '';
44
+ const abortHandler = () => {
45
+ try {
46
+ reader.cancel();
47
+ }
48
+ catch {
49
+ // noop
50
+ }
51
+ };
52
+ signal.addEventListener('abort', abortHandler);
53
+ try {
54
+ while (true) {
55
+ const { done, value } = await reader.read();
56
+ if (done)
57
+ break;
58
+ buffer += value;
59
+ // Normalize line endings: CRLF -> LF, then CR -> LF
60
+ buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
61
+ const chunks = buffer.split('\n\n');
62
+ buffer = chunks.pop() ?? '';
63
+ for (const chunk of chunks) {
64
+ const lines = chunk.split('\n');
65
+ const dataLines = [];
66
+ let eventName;
67
+ for (const line of lines) {
68
+ if (line.startsWith('data:')) {
69
+ dataLines.push(line.replace(/^data:\s*/, ''));
70
+ }
71
+ else if (line.startsWith('event:')) {
72
+ eventName = line.replace(/^event:\s*/, '');
73
+ }
74
+ else if (line.startsWith('id:')) {
75
+ lastEventId = line.replace(/^id:\s*/, '');
76
+ }
77
+ else if (line.startsWith('retry:')) {
78
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10);
79
+ if (!Number.isNaN(parsed)) {
80
+ retryDelay = parsed;
81
+ }
82
+ }
83
+ }
84
+ let data;
85
+ let parsedJson = false;
86
+ if (dataLines.length) {
87
+ const rawData = dataLines.join('\n');
88
+ try {
89
+ data = JSON.parse(rawData);
90
+ parsedJson = true;
91
+ }
92
+ catch {
93
+ data = rawData;
94
+ }
95
+ }
96
+ if (parsedJson) {
97
+ if (responseValidator) {
98
+ await responseValidator(data);
99
+ }
100
+ if (responseTransformer) {
101
+ data = await responseTransformer(data);
102
+ }
103
+ }
104
+ onSseEvent?.({
105
+ data,
106
+ event: eventName,
107
+ id: lastEventId,
108
+ retry: retryDelay,
109
+ });
110
+ if (dataLines.length) {
111
+ yield data;
112
+ }
113
+ }
114
+ }
115
+ }
116
+ finally {
117
+ signal.removeEventListener('abort', abortHandler);
118
+ reader.releaseLock();
119
+ }
120
+ break; // exit loop on normal completion
121
+ }
122
+ catch (error) {
123
+ // connection failed or aborted; retry after delay
124
+ onSseError?.(error);
125
+ if (sseMaxRetryAttempts !== undefined &&
126
+ attempt >= sseMaxRetryAttempts) {
127
+ break; // stop after firing error
128
+ }
129
+ // exponential backoff: double retry each attempt, cap at 30s
130
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
131
+ await sleep(backoff);
132
+ }
133
+ }
134
+ };
135
+ const stream = createStream();
136
+ return { stream };
137
+ };
@@ -0,0 +1,2 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export {};
@@ -0,0 +1,87 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from './pathSerializer.gen.js';
3
+ export const PATH_PARAM_RE = /\{[^{}]+\}/g;
4
+ export const defaultPathSerializer = ({ path, url: _url }) => {
5
+ let url = _url;
6
+ const matches = _url.match(PATH_PARAM_RE);
7
+ if (matches) {
8
+ for (const match of matches) {
9
+ let explode = false;
10
+ let name = match.substring(1, match.length - 1);
11
+ let style = 'simple';
12
+ if (name.endsWith('*')) {
13
+ explode = true;
14
+ name = name.substring(0, name.length - 1);
15
+ }
16
+ if (name.startsWith('.')) {
17
+ name = name.substring(1);
18
+ style = 'label';
19
+ }
20
+ else if (name.startsWith(';')) {
21
+ name = name.substring(1);
22
+ style = 'matrix';
23
+ }
24
+ const value = path[name];
25
+ if (value === undefined || value === null) {
26
+ continue;
27
+ }
28
+ if (Array.isArray(value)) {
29
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
30
+ continue;
31
+ }
32
+ if (typeof value === 'object') {
33
+ url = url.replace(match, serializeObjectParam({
34
+ explode,
35
+ name,
36
+ style,
37
+ value: value,
38
+ valueOnly: true,
39
+ }));
40
+ continue;
41
+ }
42
+ if (style === 'matrix') {
43
+ url = url.replace(match, `;${serializePrimitiveParam({
44
+ name,
45
+ value: value,
46
+ })}`);
47
+ continue;
48
+ }
49
+ const replaceValue = encodeURIComponent(style === 'label' ? `.${value}` : value);
50
+ url = url.replace(match, replaceValue);
51
+ }
52
+ }
53
+ return url;
54
+ };
55
+ export const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
56
+ const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
57
+ let url = (baseUrl ?? '') + pathUrl;
58
+ if (path) {
59
+ url = defaultPathSerializer({ path, url });
60
+ }
61
+ let search = query ? querySerializer(query) : '';
62
+ if (search.startsWith('?')) {
63
+ search = search.substring(1);
64
+ }
65
+ if (search) {
66
+ url += `?${search}`;
67
+ }
68
+ return url;
69
+ };
70
+ export function getValidRequestBody(options) {
71
+ const hasBody = options.body !== undefined;
72
+ const isSerializedBody = hasBody && options.bodySerializer;
73
+ if (isSerializedBody) {
74
+ if ('serializedBody' in options) {
75
+ const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== '';
76
+ return hasSerializedBody ? options.serializedBody : null;
77
+ }
78
+ // not all clients implement a serializedBody property (i.e. client-axios)
79
+ return options.body !== '' ? options.body : null;
80
+ }
81
+ // plain/text body
82
+ if (hasBody) {
83
+ return options.body;
84
+ }
85
+ // no body was provided
86
+ return undefined;
87
+ }
@@ -0,0 +1,2 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export { cancelDeploymentByUuid, createEnvByApplicationUuid, deployByTagOrUuid, getApplicationByUuid, getApplicationLogsByUuid, getDatabaseByUuid, getDeploymentByUuid, listApplications, listDatabases, listDeployments, listDeploymentsByAppUuid, listEnvsByApplicationUuid, listResources, updateEnvByApplicationUuid, version } from './sdk.gen.js';
@@ -0,0 +1,176 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ import { client } from './client.gen.js';
3
+ import { zCancelDeploymentByUuidData, zCreateEnvByApplicationUuidData, zDeployByTagOrUuidData, zGetApplicationByUuidData, zGetApplicationLogsByUuidData, zGetDatabaseByUuidData, zGetDeploymentByUuidData, zListApplicationsData, zListDatabasesData, zListDeploymentsByAppUuidData, zListDeploymentsData, zListEnvsByApplicationUuidData, zListResourcesData, zUpdateEnvByApplicationUuidData, zVersionData } from './zod.gen.js';
4
+ /**
5
+ * List
6
+ *
7
+ * List all applications.
8
+ */
9
+ export const listApplications = (options) => (options?.client ?? client).get({
10
+ requestValidator: async (data) => await zListApplicationsData.parseAsync(data),
11
+ security: [{ scheme: 'bearer', type: 'http' }],
12
+ url: '/applications',
13
+ ...options
14
+ });
15
+ /**
16
+ * Get
17
+ *
18
+ * Get application by UUID.
19
+ */
20
+ export const getApplicationByUuid = (options) => (options.client ?? client).get({
21
+ requestValidator: async (data) => await zGetApplicationByUuidData.parseAsync(data),
22
+ security: [{ scheme: 'bearer', type: 'http' }],
23
+ url: '/applications/{uuid}',
24
+ ...options
25
+ });
26
+ /**
27
+ * Get application logs.
28
+ *
29
+ * Get application logs by UUID.
30
+ */
31
+ export const getApplicationLogsByUuid = (options) => (options.client ?? client).get({
32
+ requestValidator: async (data) => await zGetApplicationLogsByUuidData.parseAsync(data),
33
+ security: [{ scheme: 'bearer', type: 'http' }],
34
+ url: '/applications/{uuid}/logs',
35
+ ...options
36
+ });
37
+ /**
38
+ * List Envs
39
+ *
40
+ * List all envs by application UUID.
41
+ */
42
+ export const listEnvsByApplicationUuid = (options) => (options.client ?? client).get({
43
+ requestValidator: async (data) => await zListEnvsByApplicationUuidData.parseAsync(data),
44
+ security: [{ scheme: 'bearer', type: 'http' }],
45
+ url: '/applications/{uuid}/envs',
46
+ ...options
47
+ });
48
+ /**
49
+ * Update Env
50
+ *
51
+ * Update env by application UUID.
52
+ */
53
+ export const updateEnvByApplicationUuid = (options) => (options.client ?? client).patch({
54
+ requestValidator: async (data) => await zUpdateEnvByApplicationUuidData.parseAsync(data),
55
+ security: [{ scheme: 'bearer', type: 'http' }],
56
+ url: '/applications/{uuid}/envs',
57
+ ...options,
58
+ headers: {
59
+ 'Content-Type': 'application/json',
60
+ ...options.headers
61
+ }
62
+ });
63
+ /**
64
+ * Create Env
65
+ *
66
+ * Create env by application UUID.
67
+ */
68
+ export const createEnvByApplicationUuid = (options) => (options.client ?? client).post({
69
+ requestValidator: async (data) => await zCreateEnvByApplicationUuidData.parseAsync(data),
70
+ security: [{ scheme: 'bearer', type: 'http' }],
71
+ url: '/applications/{uuid}/envs',
72
+ ...options,
73
+ headers: {
74
+ 'Content-Type': 'application/json',
75
+ ...options.headers
76
+ }
77
+ });
78
+ /**
79
+ * List
80
+ *
81
+ * List all databases.
82
+ */
83
+ export const listDatabases = (options) => (options?.client ?? client).get({
84
+ requestValidator: async (data) => await zListDatabasesData.parseAsync(data),
85
+ security: [{ scheme: 'bearer', type: 'http' }],
86
+ url: '/databases',
87
+ ...options
88
+ });
89
+ /**
90
+ * Get
91
+ *
92
+ * Get database by UUID.
93
+ */
94
+ export const getDatabaseByUuid = (options) => (options.client ?? client).get({
95
+ requestValidator: async (data) => await zGetDatabaseByUuidData.parseAsync(data),
96
+ security: [{ scheme: 'bearer', type: 'http' }],
97
+ url: '/databases/{uuid}',
98
+ ...options
99
+ });
100
+ /**
101
+ * List
102
+ *
103
+ * List currently running deployments
104
+ */
105
+ export const listDeployments = (options) => (options?.client ?? client).get({
106
+ requestValidator: async (data) => await zListDeploymentsData.parseAsync(data),
107
+ security: [{ scheme: 'bearer', type: 'http' }],
108
+ url: '/deployments',
109
+ ...options
110
+ });
111
+ /**
112
+ * Get
113
+ *
114
+ * Get deployment by UUID.
115
+ */
116
+ export const getDeploymentByUuid = (options) => (options.client ?? client).get({
117
+ requestValidator: async (data) => await zGetDeploymentByUuidData.parseAsync(data),
118
+ security: [{ scheme: 'bearer', type: 'http' }],
119
+ url: '/deployments/{uuid}',
120
+ ...options
121
+ });
122
+ /**
123
+ * Cancel
124
+ *
125
+ * Cancel a deployment by UUID.
126
+ */
127
+ export const cancelDeploymentByUuid = (options) => (options.client ?? client).post({
128
+ requestValidator: async (data) => await zCancelDeploymentByUuidData.parseAsync(data),
129
+ security: [{ scheme: 'bearer', type: 'http' }],
130
+ url: '/deployments/{uuid}/cancel',
131
+ ...options
132
+ });
133
+ /**
134
+ * Deploy
135
+ *
136
+ * Deploy by tag or uuid. `Post` request also accepted with `uuid` and `tag` json body.
137
+ */
138
+ export const deployByTagOrUuid = (options) => (options?.client ?? client).get({
139
+ requestValidator: async (data) => await zDeployByTagOrUuidData.parseAsync(data),
140
+ security: [{ scheme: 'bearer', type: 'http' }],
141
+ url: '/deploy',
142
+ ...options
143
+ });
144
+ /**
145
+ * List application deployments
146
+ *
147
+ * List application deployments by using the app uuid
148
+ */
149
+ export const listDeploymentsByAppUuid = (options) => (options.client ?? client).get({
150
+ requestValidator: async (data) => await zListDeploymentsByAppUuidData.parseAsync(data),
151
+ security: [{ scheme: 'bearer', type: 'http' }],
152
+ url: '/deployments/applications/{uuid}',
153
+ ...options
154
+ });
155
+ /**
156
+ * Version
157
+ *
158
+ * Get Coolify version.
159
+ */
160
+ export const version = (options) => (options?.client ?? client).get({
161
+ requestValidator: async (data) => await zVersionData.parseAsync(data),
162
+ security: [{ scheme: 'bearer', type: 'http' }],
163
+ url: '/version',
164
+ ...options
165
+ });
166
+ /**
167
+ * List
168
+ *
169
+ * Get all resources.
170
+ */
171
+ export const listResources = (options) => (options?.client ?? client).get({
172
+ requestValidator: async (data) => await zListResourcesData.parseAsync(data),
173
+ security: [{ scheme: 'bearer', type: 'http' }],
174
+ url: '/resources',
175
+ ...options
176
+ });
@@ -0,0 +1,2 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export {};