@geekmidas/cli 10.0.0-alpha.2 → 10.0.0-alpha.21

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.
Files changed (241) hide show
  1. package/README.md +25 -48
  2. package/bin/adjacent-tsconfig.mjs +59 -0
  3. package/bin/gkm.mjs +7 -1
  4. package/dist/{HostingerProvider-Cft7lEYr.mjs → HostingerProvider-BY26bWwB.mjs} +20 -21
  5. package/dist/HostingerProvider-BY26bWwB.mjs.map +1 -0
  6. package/dist/{HostingerProvider-h3EbEp-Z.cjs → HostingerProvider-BZFGYYVA.cjs} +21 -22
  7. package/dist/HostingerProvider-BZFGYYVA.cjs.map +1 -0
  8. package/dist/{LocalStateProvider-Db9SEjyH.cjs → LocalStateProvider-7HR6SS2t.cjs} +11 -6
  9. package/dist/LocalStateProvider-7HR6SS2t.cjs.map +1 -0
  10. package/dist/{LocalStateProvider-Bn6tS-oL.mjs → LocalStateProvider-D7QyJoLM.mjs} +10 -4
  11. package/dist/LocalStateProvider-D7QyJoLM.mjs.map +1 -0
  12. package/dist/{Route53Provider-RdpUDJQk.mjs → Route53Provider-Cvj40A8I.mjs} +12 -12
  13. package/dist/Route53Provider-Cvj40A8I.mjs.map +1 -0
  14. package/dist/{Route53Provider-di2fMM5N.cjs → Route53Provider-DVILBsvV.cjs} +20 -21
  15. package/dist/Route53Provider-DVILBsvV.cjs.map +1 -0
  16. package/dist/{SSMStateProvider-BRt2py-A.mjs → SSMStateProvider-B0Hu1MKZ.mjs} +13 -4
  17. package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +1 -0
  18. package/dist/{SSMStateProvider-DyX8s9HI.cjs → SSMStateProvider-VrQ-yeqd.cjs} +17 -9
  19. package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +1 -0
  20. package/dist/{backup-provisioner-BrsHwYG0.cjs → backup-provisioner-BmhIO_Yr.cjs} +21 -19
  21. package/dist/backup-provisioner-BmhIO_Yr.cjs.map +1 -0
  22. package/dist/{backup-provisioner-Bgj5Vi_L.mjs → backup-provisioner-DIVCbfee.mjs} +10 -7
  23. package/dist/backup-provisioner-DIVCbfee.mjs.map +1 -0
  24. package/dist/{bundler-BY1OmV1e.cjs → bundler-mjqGAvu1.cjs} +10 -28
  25. package/dist/bundler-mjqGAvu1.cjs.map +1 -0
  26. package/dist/{bundler-Be8Zg4Wd.mjs → bundler-mwH7WOb1.mjs} +9 -26
  27. package/dist/bundler-mwH7WOb1.mjs.map +1 -0
  28. package/dist/{config-BholeD-0.cjs → config-DSXI480r.cjs} +80 -148
  29. package/dist/config-DSXI480r.cjs.map +1 -0
  30. package/dist/{config-CzWnfcXM.mjs → config-DdKkoUE1.mjs} +33 -88
  31. package/dist/config-DdKkoUE1.mjs.map +1 -0
  32. package/dist/config.cjs +4 -5
  33. package/dist/config.d.cts +14 -17
  34. package/dist/config.d.cts.map +1 -1
  35. package/dist/config.d.mts +14 -17
  36. package/dist/config.d.mts.map +1 -1
  37. package/dist/config.mjs +3 -5
  38. package/dist/{credentials-DQmbRnr1.cjs → credentials-BfmmB4WD.cjs} +1508 -1243
  39. package/dist/credentials-BfmmB4WD.cjs.map +1 -0
  40. package/dist/{credentials-BZcp3CGx.mjs → credentials-CD8ftUS6.mjs} +1374 -1114
  41. package/dist/credentials-CD8ftUS6.mjs.map +1 -0
  42. package/dist/deploy/sniffer-envkit-patch.cjs +18 -10
  43. package/dist/deploy/sniffer-envkit-patch.cjs.map +1 -1
  44. package/dist/deploy/sniffer-envkit-patch.d.cts +0 -2
  45. package/dist/deploy/sniffer-envkit-patch.d.cts.map +1 -1
  46. package/dist/deploy/sniffer-envkit-patch.d.mts +0 -2
  47. package/dist/deploy/sniffer-envkit-patch.d.mts.map +1 -1
  48. package/dist/deploy/sniffer-envkit-patch.mjs +10 -2
  49. package/dist/deploy/sniffer-envkit-patch.mjs.map +1 -1
  50. package/dist/deploy/sniffer-hooks.cjs +13 -7
  51. package/dist/deploy/sniffer-hooks.cjs.map +1 -1
  52. package/dist/deploy/sniffer-hooks.d.cts +1 -2
  53. package/dist/deploy/sniffer-hooks.d.cts.map +1 -1
  54. package/dist/deploy/sniffer-hooks.d.mts +1 -2
  55. package/dist/deploy/sniffer-hooks.d.mts.map +1 -1
  56. package/dist/deploy/sniffer-hooks.mjs +9 -2
  57. package/dist/deploy/sniffer-hooks.mjs.map +1 -1
  58. package/dist/deploy/sniffer-loader.cjs +16 -7
  59. package/dist/deploy/sniffer-loader.cjs.map +1 -1
  60. package/dist/deploy/sniffer-loader.d.cts +1 -1
  61. package/dist/deploy/sniffer-loader.d.mts +1 -1
  62. package/dist/deploy/sniffer-loader.mjs +13 -2
  63. package/dist/deploy/sniffer-loader.mjs.map +1 -1
  64. package/dist/deploy/sniffer-routes-worker.cjs +11 -11
  65. package/dist/deploy/sniffer-routes-worker.cjs.map +1 -1
  66. package/dist/deploy/sniffer-routes-worker.d.cts +1 -1
  67. package/dist/deploy/sniffer-routes-worker.d.mts +1 -1
  68. package/dist/deploy/sniffer-routes-worker.mjs +2 -2
  69. package/dist/deploy/sniffer-routes-worker.mjs.map +1 -1
  70. package/dist/deploy/sniffer-worker.cjs +15 -6
  71. package/dist/deploy/sniffer-worker.cjs.map +1 -1
  72. package/dist/deploy/sniffer-worker.d.cts +1 -3
  73. package/dist/deploy/sniffer-worker.d.cts.map +1 -1
  74. package/dist/deploy/sniffer-worker.d.mts +1 -3
  75. package/dist/deploy/sniffer-worker.d.mts.map +1 -1
  76. package/dist/deploy/sniffer-worker.mjs +15 -4
  77. package/dist/deploy/sniffer-worker.mjs.map +1 -1
  78. package/dist/{discover-DTmFeloL.cjs → discover-BERGFg8v.cjs} +81 -64
  79. package/dist/discover-BERGFg8v.cjs.map +1 -0
  80. package/dist/{discover-CAlFgYec.mjs → discover-CK-n3w6b.mjs} +35 -20
  81. package/dist/discover-CK-n3w6b.mjs.map +1 -0
  82. package/dist/{emit-CbcRolsa.cjs → emit-BdoPFjZf.cjs} +53 -36
  83. package/dist/emit-BdoPFjZf.cjs.map +1 -0
  84. package/dist/{emit-CiZS_5Ub.mjs → emit-Bzq7JsMP.mjs} +24 -6
  85. package/dist/emit-Bzq7JsMP.mjs.map +1 -0
  86. package/dist/{generator-VE2JrFlY.mjs → generator-LfZU7NlU.mjs} +8 -14
  87. package/dist/generator-LfZU7NlU.mjs.map +1 -0
  88. package/dist/{generator-CNzBw7g5.cjs → generator-Wdfp0jCS.cjs} +38 -45
  89. package/dist/generator-Wdfp0jCS.cjs.map +1 -0
  90. package/dist/github-Bho-C6Zg.cjs +216 -0
  91. package/dist/github-Bho-C6Zg.cjs.map +1 -0
  92. package/dist/github-De-yMwVt.mjs +216 -0
  93. package/dist/github-De-yMwVt.mjs.map +1 -0
  94. package/dist/{index-CHB4tSzX.d.cts → index-B4H4XF7A.d.mts} +4 -13
  95. package/dist/index-B4H4XF7A.d.mts.map +1 -0
  96. package/dist/{index-BThUzEIp.d.mts → index-RCUizGxL.d.cts} +4 -13
  97. package/dist/index-RCUizGxL.d.cts.map +1 -0
  98. package/dist/index.cjs +5108 -3381
  99. package/dist/index.cjs.map +1 -1
  100. package/dist/index.d.cts +1 -1
  101. package/dist/index.d.mts +1 -1
  102. package/dist/index.mjs +5025 -3315
  103. package/dist/index.mjs.map +1 -1
  104. package/dist/{openapi-c9bpieI5.cjs → openapi-B8bu_OXN.cjs} +228 -188
  105. package/dist/openapi-B8bu_OXN.cjs.map +1 -0
  106. package/dist/{openapi-CY9xFkTH.mjs → openapi-DfjbhrsM.mjs} +172 -143
  107. package/dist/openapi-DfjbhrsM.mjs.map +1 -0
  108. package/dist/openapi.cjs +5 -6
  109. package/dist/openapi.d.cts +47 -14
  110. package/dist/openapi.d.cts.map +1 -1
  111. package/dist/openapi.d.mts +47 -14
  112. package/dist/openapi.d.mts.map +1 -1
  113. package/dist/openapi.mjs +2 -6
  114. package/dist/reconcile/public.cjs +4 -4
  115. package/dist/reconcile/public.d.cts +8 -26
  116. package/dist/reconcile/public.d.cts.map +1 -1
  117. package/dist/reconcile/public.d.mts +8 -26
  118. package/dist/reconcile/public.d.mts.map +1 -1
  119. package/dist/reconcile/public.mjs +3 -4
  120. package/dist/{fullstack-secrets-D1o9-G5l.mjs → reconcile-gb1lz1Dk.mjs} +43 -17
  121. package/dist/reconcile-gb1lz1Dk.mjs.map +1 -0
  122. package/dist/{fullstack-secrets-C-GGohke.cjs → reconcile-hx_vBvux.cjs} +63 -38
  123. package/dist/reconcile-hx_vBvux.cjs.map +1 -0
  124. package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
  125. package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-C0BPl7ul.cjs} +23 -10
  126. package/dist/ssm-BKN1Cg4z.mjs +60 -0
  127. package/dist/ssm-BKN1Cg4z.mjs.map +1 -0
  128. package/dist/ssm-FxeSAt35.cjs +60 -0
  129. package/dist/ssm-FxeSAt35.cjs.map +1 -0
  130. package/dist/{storage-BJmzYxt8.cjs → storage-DgypfSD6.cjs} +65 -77
  131. package/dist/storage-DgypfSD6.cjs.map +1 -0
  132. package/dist/{storage-Bi24WfoW.mjs → storage-TP0x118M.mjs} +22 -15
  133. package/dist/storage-TP0x118M.mjs.map +1 -0
  134. package/dist/transfer-CXoyQZbB.cjs +151 -0
  135. package/dist/transfer-CXoyQZbB.cjs.map +1 -0
  136. package/dist/transfer-Gsxfy6m-.mjs +122 -0
  137. package/dist/transfer-Gsxfy6m-.mjs.map +1 -0
  138. package/dist/types-7R81hu0i.d.mts +6302 -0
  139. package/dist/types-7R81hu0i.d.mts.map +1 -0
  140. package/dist/types-N7c2O2m7.d.cts +6303 -0
  141. package/dist/types-N7c2O2m7.d.cts.map +1 -0
  142. package/dist/workspace/index.cjs +3 -3
  143. package/dist/workspace/index.d.cts +3 -3
  144. package/dist/workspace/index.d.mts +3 -3
  145. package/dist/workspace/index.mjs +2 -3
  146. package/dist/workspace-Bu3xNCej.mjs +6563 -0
  147. package/dist/workspace-Bu3xNCej.mjs.map +1 -0
  148. package/dist/workspace-CRD9YinV.cjs +6741 -0
  149. package/dist/workspace-CRD9YinV.cjs.map +1 -0
  150. package/package.json +33 -43
  151. package/dist/CachedStateProvider-BLo7zv7S.cjs +0 -3
  152. package/dist/CachedStateProvider-BxoAm-B2.mjs +0 -3
  153. package/dist/CachedStateProvider-CqPdW7CB.cjs +0 -60
  154. package/dist/CachedStateProvider-CqPdW7CB.cjs.map +0 -1
  155. package/dist/CachedStateProvider-DTniehMP.mjs +0 -54
  156. package/dist/CachedStateProvider-DTniehMP.mjs.map +0 -1
  157. package/dist/HostingerProvider-Cft7lEYr.mjs.map +0 -1
  158. package/dist/HostingerProvider-h3EbEp-Z.cjs.map +0 -1
  159. package/dist/LocalStateProvider-Bn6tS-oL.mjs.map +0 -1
  160. package/dist/LocalStateProvider-Db9SEjyH.cjs.map +0 -1
  161. package/dist/Route53Provider-RdpUDJQk.mjs.map +0 -1
  162. package/dist/Route53Provider-di2fMM5N.cjs.map +0 -1
  163. package/dist/SSMStateProvider-BRt2py-A.mjs.map +0 -1
  164. package/dist/SSMStateProvider-DyX8s9HI.cjs.map +0 -1
  165. package/dist/backup-provisioner-Bgj5Vi_L.mjs.map +0 -1
  166. package/dist/backup-provisioner-BrsHwYG0.cjs.map +0 -1
  167. package/dist/bundler-BY1OmV1e.cjs.map +0 -1
  168. package/dist/bundler-Be8Zg4Wd.mjs.map +0 -1
  169. package/dist/chunk-Duj1WY3L.mjs +0 -7
  170. package/dist/config-BholeD-0.cjs.map +0 -1
  171. package/dist/config-CzWnfcXM.mjs.map +0 -1
  172. package/dist/credentials-B5zRHdAl.mjs +0 -141
  173. package/dist/credentials-B5zRHdAl.mjs.map +0 -1
  174. package/dist/credentials-BZcp3CGx.mjs.map +0 -1
  175. package/dist/credentials-BapzjyV5.cjs +0 -195
  176. package/dist/credentials-BapzjyV5.cjs.map +0 -1
  177. package/dist/credentials-DQmbRnr1.cjs.map +0 -1
  178. package/dist/discover-CAlFgYec.mjs.map +0 -1
  179. package/dist/discover-DTmFeloL.cjs.map +0 -1
  180. package/dist/dokploy-api-BS2xnJLZ.mjs +0 -3
  181. package/dist/dokploy-api-BsVH0y_s.cjs +0 -718
  182. package/dist/dokploy-api-BsVH0y_s.cjs.map +0 -1
  183. package/dist/dokploy-api-BuxDRo3l.cjs +0 -3
  184. package/dist/dokploy-api-aTFPz7_4.mjs +0 -706
  185. package/dist/dokploy-api-aTFPz7_4.mjs.map +0 -1
  186. package/dist/emit-CbcRolsa.cjs.map +0 -1
  187. package/dist/emit-CiZS_5Ub.mjs.map +0 -1
  188. package/dist/encryption-C6jaU0hE.cjs +0 -54
  189. package/dist/encryption-C6jaU0hE.cjs.map +0 -1
  190. package/dist/encryption-CHzzeR8a.cjs +0 -4
  191. package/dist/encryption-CQUncu7v.mjs +0 -3
  192. package/dist/encryption-D-abyhZx.mjs +0 -42
  193. package/dist/encryption-D-abyhZx.mjs.map +0 -1
  194. package/dist/fullstack-secrets-C-GGohke.cjs.map +0 -1
  195. package/dist/fullstack-secrets-D1o9-G5l.mjs.map +0 -1
  196. package/dist/generator-CNzBw7g5.cjs.map +0 -1
  197. package/dist/generator-VE2JrFlY.mjs.map +0 -1
  198. package/dist/index-BThUzEIp.d.mts.map +0 -1
  199. package/dist/index-CHB4tSzX.d.cts.map +0 -1
  200. package/dist/openapi-CY9xFkTH.mjs.map +0 -1
  201. package/dist/openapi-c9bpieI5.cjs.map +0 -1
  202. package/dist/openapi-react-query-Byltvm_7.mjs +0 -167
  203. package/dist/openapi-react-query-Byltvm_7.mjs.map +0 -1
  204. package/dist/openapi-react-query-CmJ1xDbn.cjs +0 -173
  205. package/dist/openapi-react-query-CmJ1xDbn.cjs.map +0 -1
  206. package/dist/openapi-react-query.cjs +0 -4
  207. package/dist/openapi-react-query.d.cts +0 -11
  208. package/dist/openapi-react-query.d.cts.map +0 -1
  209. package/dist/openapi-react-query.d.mts +0 -11
  210. package/dist/openapi-react-query.d.mts.map +0 -1
  211. package/dist/openapi-react-query.mjs +0 -4
  212. package/dist/reconcile-CFs8C_1a.mjs +0 -37
  213. package/dist/reconcile-CFs8C_1a.mjs.map +0 -1
  214. package/dist/reconcile-D0pimNiy.cjs +0 -37
  215. package/dist/reconcile-D0pimNiy.cjs.map +0 -1
  216. package/dist/setup-Bc73t0ve.mjs +0 -443
  217. package/dist/setup-Bc73t0ve.mjs.map +0 -1
  218. package/dist/setup-C48C9hto.cjs +0 -473
  219. package/dist/setup-C48C9hto.cjs.map +0 -1
  220. package/dist/setup-DCuudnCl.mjs +0 -11
  221. package/dist/setup-fG_ivuxO.cjs +0 -11
  222. package/dist/storage-BJmzYxt8.cjs.map +0 -1
  223. package/dist/storage-BM9hGpgv.cjs +0 -7
  224. package/dist/storage-Bi24WfoW.mjs.map +0 -1
  225. package/dist/storage-CYlGwWTj.mjs +0 -3
  226. package/dist/sync-CmEuNZsB.mjs +0 -76
  227. package/dist/sync-CmEuNZsB.mjs.map +0 -1
  228. package/dist/sync-D306yOWu.cjs +0 -4
  229. package/dist/sync-SizaChmC.cjs +0 -93
  230. package/dist/sync-SizaChmC.cjs.map +0 -1
  231. package/dist/sync-hOqAWHR6.mjs +0 -3
  232. package/dist/types-C-arnQ1r.d.mts +0 -2184
  233. package/dist/types-C-arnQ1r.d.mts.map +0 -1
  234. package/dist/types-abJQuk7m.d.cts +0 -2184
  235. package/dist/types-abJQuk7m.d.cts.map +0 -1
  236. package/dist/workspace-7FqprxuJ.mjs +0 -4323
  237. package/dist/workspace-7FqprxuJ.mjs.map +0 -1
  238. package/dist/workspace-BO_KWohI.cjs +0 -9
  239. package/dist/workspace-DK4WWJIn.mjs +0 -8
  240. package/dist/workspace-XvqO9jIv.cjs +0 -4472
  241. package/dist/workspace-XvqO9jIv.cjs.map +0 -1
@@ -1,706 +0,0 @@
1
- //#region src/deploy/dokploy-api.ts
2
- var DokployApiError = class extends Error {
3
- constructor(message, status, statusText, issues) {
4
- super(message);
5
- this.status = status;
6
- this.statusText = statusText;
7
- this.issues = issues;
8
- this.name = "DokployApiError";
9
- }
10
- };
11
- /**
12
- * Dokploy API client
13
- */
14
- var DokployApi = class {
15
- baseUrl;
16
- token;
17
- constructor(options) {
18
- this.baseUrl = options.baseUrl.replace(/\/$/, "");
19
- this.token = options.token;
20
- }
21
- /**
22
- * Make a GET request to the Dokploy API
23
- */
24
- async get(endpoint) {
25
- return this.request("GET", endpoint);
26
- }
27
- /**
28
- * Make a POST request to the Dokploy API
29
- */
30
- async post(endpoint, body) {
31
- return this.request("POST", endpoint, body);
32
- }
33
- /**
34
- * Make a request to the Dokploy API
35
- */
36
- async request(method, endpoint, body) {
37
- const url = `${this.baseUrl}/api/${endpoint}`;
38
- let response;
39
- let lastError;
40
- for (let attempt = 1; attempt <= 3; attempt++) try {
41
- response = await fetch(url, {
42
- method,
43
- headers: {
44
- "Content-Type": "application/json",
45
- "x-api-key": this.token
46
- },
47
- body: body ? JSON.stringify(body) : void 0
48
- });
49
- break;
50
- } catch (error) {
51
- lastError = error;
52
- if (attempt === 3) break;
53
- await new Promise((resolve) => setTimeout(resolve, attempt * 750));
54
- }
55
- if (!response) {
56
- const detail = lastError instanceof Error ? lastError.message : String(lastError);
57
- throw new DokployApiError(`Could not reach Dokploy at ${this.baseUrl} (${endpoint}): ${detail}`, 0, "Network error");
58
- }
59
- if (!response.ok) {
60
- let errorMessage = `Dokploy API error: ${response.status} ${response.statusText}`;
61
- let issues;
62
- try {
63
- const errorBody = await response.json();
64
- if (errorBody.message) errorMessage = `Dokploy API error: ${errorBody.message}`;
65
- if (errorBody.issues?.length) {
66
- issues = errorBody.issues;
67
- errorMessage += `\n Issues: ${errorBody.issues.map((i) => i.message).join(", ")}`;
68
- }
69
- } catch {}
70
- throw new DokployApiError(errorMessage, response.status, response.statusText, issues);
71
- }
72
- const text = await response.text();
73
- if (!text || text.trim() === "") return void 0;
74
- return JSON.parse(text);
75
- }
76
- /**
77
- * Every external port published on this server, across every project.
78
- *
79
- * Dokploy knows what it has bound; guessing does not. A port that looks free
80
- * from here can be held by a service in a project this deploy has never
81
- * heard of — which surfaces as `Port 5432 is already in use by container
82
- * "…"`, naming something the caller cannot see.
83
- *
84
- * `project.all` is a summary, so each project is fetched: the per-service
85
- * `externalPort` only appears on `project.one`.
86
- */
87
- async publishedPorts() {
88
- const ports = /* @__PURE__ */ new Set();
89
- const projects = await this.listProjects();
90
- for (const project of projects) {
91
- const details = await this.getProject(project.projectId);
92
- for (const environment of details.environments ?? []) {
93
- const resources = [
94
- ...environment.postgres ?? [],
95
- ...environment.redis ?? [],
96
- ...environment.applications ?? []
97
- ];
98
- for (const resource of resources) if (typeof resource.externalPort === "number") ports.add(resource.externalPort);
99
- }
100
- }
101
- return ports;
102
- }
103
- /**
104
- * Validate the API token by making a test request
105
- */
106
- async validateToken() {
107
- try {
108
- await this.get("project.all");
109
- return true;
110
- } catch {
111
- return false;
112
- }
113
- }
114
- /**
115
- * List all projects
116
- */
117
- async listProjects() {
118
- return this.get("project.all");
119
- }
120
- /**
121
- * Get a single project by ID
122
- */
123
- async getProject(projectId) {
124
- return this.get(`project.one?projectId=${projectId}`);
125
- }
126
- /**
127
- * Create a new project
128
- */
129
- async createProject(name, description) {
130
- return this.post("project.create", {
131
- name,
132
- description: description ?? `Created by gkm CLI`
133
- });
134
- }
135
- /**
136
- * Delete a project and all its resources
137
- */
138
- async deleteProject(projectId) {
139
- await this.post("project.remove", { projectId });
140
- }
141
- /**
142
- * Create an environment in a project
143
- */
144
- async createEnvironment(projectId, name, description) {
145
- return this.post("environment.create", {
146
- projectId,
147
- name,
148
- description: description ?? `${name} environment`
149
- });
150
- }
151
- /**
152
- * List all applications in a project
153
- */
154
- async listApplications(projectId) {
155
- return this.listInProject(projectId, (env) => env.applications);
156
- }
157
- /**
158
- * Everything of one kind in a project, across its environments.
159
- *
160
- * From `project.one`, because the per-kind `*.all?projectId=` endpoints
161
- * return **404** on current Dokploy: resources live under environments now.
162
- * Those calls used to be wrapped in `catch { return [] }`, which turned "I
163
- * could not ask" into "there are none" — and for a find-or-create that is
164
- * the worst available answer. Every deploy created a second application, a
165
- * second Postgres and a second Redis, silently, for as long as the project
166
- * existed.
167
- *
168
- * A failure here is not swallowed: creating a duplicate is worse than
169
- * stopping.
170
- */
171
- async listInProject(projectId, pick) {
172
- const project = await this.getProject(projectId);
173
- return (project.environments ?? []).flatMap((environment) => (pick(environment) ?? []).map((resource) => ({
174
- ...resource,
175
- environmentId: environment.environmentId
176
- })));
177
- }
178
- /**
179
- * Find an application by name in a project
180
- */
181
- async findApplicationByName(projectId, name, environmentId) {
182
- const applications = await this.listApplications(projectId);
183
- const normalizedName = name.toLowerCase().replace(/[^a-z0-9-]/g, "-");
184
- return applications.find((app) => (!environmentId || app.environmentId === environmentId) && (app.name === name || app.appName === normalizedName));
185
- }
186
- /**
187
- * Create a new application
188
- */
189
- async createApplication(name, projectId, environmentId) {
190
- return this.post("application.create", {
191
- name,
192
- projectId,
193
- environmentId,
194
- appName: name.toLowerCase().replace(/[^a-z0-9-]/g, "-")
195
- });
196
- }
197
- /**
198
- * Find or create an application by name
199
- */
200
- async findOrCreateApplication(name, projectId, environmentId) {
201
- const existing = await this.findApplicationByName(projectId, name, environmentId);
202
- if (existing) return {
203
- application: existing,
204
- created: false
205
- };
206
- const application = await this.createApplication(name, projectId, environmentId);
207
- return {
208
- application,
209
- created: true
210
- };
211
- }
212
- /**
213
- * Get an application by ID
214
- */
215
- async getApplication(applicationId) {
216
- try {
217
- return await this.get(`application.one?applicationId=${applicationId}`);
218
- } catch {
219
- return null;
220
- }
221
- }
222
- /**
223
- * Update an application
224
- */
225
- async updateApplication(applicationId, updates) {
226
- await this.post("application.update", {
227
- applicationId,
228
- ...updates
229
- });
230
- }
231
- /**
232
- * Save environment variables for an application
233
- */
234
- async saveApplicationEnv(applicationId, env, options) {
235
- await this.post("application.saveEnvironment", {
236
- applicationId,
237
- env,
238
- buildArgs: options?.buildArgs ?? null,
239
- buildSecrets: options?.buildSecrets ?? null,
240
- createEnvFile: false
241
- });
242
- }
243
- /**
244
- * Configure application to use Docker provider (pull from registry)
245
- *
246
- * For private registries, either:
247
- * - Use `registryId` if the registry is configured in Dokploy
248
- * - Or provide `username`, `password`, and `registryUrl` directly
249
- */
250
- async saveDockerProvider(applicationId, dockerImage, options) {
251
- await this.post("application.saveDockerProvider", {
252
- applicationId,
253
- dockerImage,
254
- ...options,
255
- username: options?.username ?? null,
256
- password: options?.password ?? null,
257
- registryUrl: options?.registryUrl ?? null
258
- });
259
- }
260
- /**
261
- * Deploy an application
262
- */
263
- async deployApplication(applicationId) {
264
- await this.post("application.deploy", { applicationId });
265
- }
266
- /**
267
- * Delete an application
268
- */
269
- async deleteApplication(applicationId) {
270
- await this.post("application.remove", { applicationId });
271
- }
272
- /**
273
- * List all registries
274
- */
275
- async listRegistries() {
276
- return this.get("registry.all");
277
- }
278
- /**
279
- * Create a new registry
280
- */
281
- async createRegistry(registryName, registryUrl, username, password, options) {
282
- return this.post("registry.create", {
283
- registryName,
284
- registryUrl,
285
- username,
286
- password,
287
- imagePrefix: options?.imagePrefix
288
- });
289
- }
290
- /**
291
- * Get a registry by ID
292
- */
293
- async getRegistry(registryId) {
294
- return this.get(`registry.one?registryId=${registryId}`);
295
- }
296
- /**
297
- * Update a registry
298
- */
299
- async updateRegistry(registryId, updates) {
300
- await this.post("registry.update", {
301
- registryId,
302
- ...updates
303
- });
304
- }
305
- /**
306
- * Delete a registry
307
- */
308
- async deleteRegistry(registryId) {
309
- await this.post("registry.remove", { registryId });
310
- }
311
- /**
312
- * List all Postgres databases in a project
313
- */
314
- async listPostgres(projectId) {
315
- return this.listInProject(projectId, (env) => env.postgres);
316
- }
317
- /**
318
- * Find a Postgres database by name in a project
319
- */
320
- async findPostgresByName(projectId, name) {
321
- const databases = await this.listPostgres(projectId);
322
- const normalizedName = name.toLowerCase().replace(/[^a-z0-9-]/g, "-");
323
- const match = databases.find((db) => db.name === name || db.appName === normalizedName);
324
- if (!match) return void 0;
325
- return this.getPostgres(match.postgresId);
326
- }
327
- /**
328
- * Create a new Postgres database
329
- */
330
- async createPostgres(name, projectId, environmentId, options) {
331
- return this.post("postgres.create", {
332
- name,
333
- projectId,
334
- environmentId,
335
- appName: options?.appName ?? name.toLowerCase().replace(/[^a-z0-9-]/g, "-"),
336
- databaseName: options?.databaseName,
337
- databaseUser: options?.databaseUser ?? "postgres",
338
- databasePassword: options?.databasePassword,
339
- dockerImage: options?.dockerImage ?? "postgres:18",
340
- description: options?.description ?? `Postgres database for ${name}`
341
- });
342
- }
343
- /**
344
- * Find or create a Postgres database by name
345
- */
346
- async findOrCreatePostgres(name, projectId, environmentId, options) {
347
- const existing = await this.findPostgresByName(projectId, name);
348
- if (existing) return {
349
- postgres: existing,
350
- created: false
351
- };
352
- const postgres = await this.createPostgres(name, projectId, environmentId, options);
353
- return {
354
- postgres,
355
- created: true
356
- };
357
- }
358
- /**
359
- * Get a Postgres database by ID
360
- */
361
- async getPostgres(postgresId) {
362
- return this.get(`postgres.one?postgresId=${postgresId}`);
363
- }
364
- /**
365
- * Deploy a Postgres database
366
- */
367
- async deployPostgres(postgresId) {
368
- await this.post("postgres.deploy", { postgresId });
369
- }
370
- /**
371
- * Save environment variables for Postgres
372
- */
373
- async savePostgresEnv(postgresId, env) {
374
- await this.post("postgres.saveEnvironment", {
375
- postgresId,
376
- env
377
- });
378
- }
379
- /**
380
- * Set external port for Postgres (for external access)
381
- */
382
- async savePostgresExternalPort(postgresId, externalPort) {
383
- await this.post("postgres.saveExternalPort", {
384
- postgresId,
385
- externalPort
386
- });
387
- }
388
- /**
389
- * Update Postgres configuration
390
- */
391
- async updatePostgres(postgresId, updates) {
392
- await this.post("postgres.update", {
393
- postgresId,
394
- ...updates
395
- });
396
- }
397
- /**
398
- * Delete a Postgres database
399
- */
400
- async deletePostgres(postgresId) {
401
- await this.post("postgres.remove", { postgresId });
402
- }
403
- /**
404
- * The compose stacks in a project.
405
- *
406
- * Dokploy has first-class primitives for Postgres and Redis and none for
407
- * MinIO, so an object store is a compose stack — the one kind whose contents
408
- * this target writes rather than configures.
409
- */
410
- async listCompose(projectId) {
411
- return this.listInProject(projectId, (env) => env.compose);
412
- }
413
- /** A compose stack by name, hydrated — `project.one` returns summaries. */
414
- async findComposeByName(projectId, name) {
415
- const summary = (await this.listCompose(projectId)).find((compose) => compose.name === name);
416
- return summary ? this.getCompose(summary.composeId) : void 0;
417
- }
418
- async getCompose(composeId) {
419
- return this.get(`compose.one?composeId=${composeId}`);
420
- }
421
- /**
422
- * A compose stack carrying the file this target wrote.
423
- *
424
- * Created empty and then updated, because `compose.create` takes no file:
425
- * it defaults to `sourceType: 'github'` and expects a repository. `raw` is
426
- * what makes the file ours.
427
- */
428
- async findOrCreateCompose(name, projectId, environmentId, composeFile) {
429
- const existing = await this.findComposeByName(projectId, name);
430
- const compose = existing ?? await this.post("compose.create", {
431
- name,
432
- environmentId,
433
- composeType: "docker-compose"
434
- });
435
- await this.post("compose.update", {
436
- composeId: compose.composeId,
437
- sourceType: "raw",
438
- composeFile
439
- });
440
- return {
441
- compose,
442
- created: !existing
443
- };
444
- }
445
- async deployCompose(composeId) {
446
- await this.post("compose.deploy", { composeId });
447
- }
448
- async deleteCompose(composeId) {
449
- await this.post("compose.delete", {
450
- composeId,
451
- deleteVolumes: false
452
- });
453
- }
454
- /**
455
- * List all Redis instances in a project
456
- */
457
- async listRedis(projectId) {
458
- return this.listInProject(projectId, (env) => env.redis);
459
- }
460
- /**
461
- * Find a Redis instance by name in a project
462
- */
463
- async findRedisByName(projectId, name) {
464
- const instances = await this.listRedis(projectId);
465
- const normalizedName = name.toLowerCase().replace(/[^a-z0-9-]/g, "-");
466
- const match = instances.find((redis) => redis.name === name || redis.appName === normalizedName);
467
- return match ? this.getRedis(match.redisId) : void 0;
468
- }
469
- /**
470
- * Create a new Redis instance
471
- */
472
- async createRedis(name, projectId, environmentId, options) {
473
- return this.post("redis.create", {
474
- name,
475
- projectId,
476
- environmentId,
477
- appName: options?.appName ?? name.toLowerCase().replace(/[^a-z0-9-]/g, "-"),
478
- databasePassword: options?.databasePassword,
479
- dockerImage: options?.dockerImage ?? "redis:8",
480
- description: options?.description ?? `Redis instance for ${name}`
481
- });
482
- }
483
- /**
484
- * Find or create a Redis instance by name
485
- */
486
- async findOrCreateRedis(name, projectId, environmentId, options) {
487
- const existing = await this.findRedisByName(projectId, name);
488
- if (existing) return {
489
- redis: existing,
490
- created: false
491
- };
492
- const redis = await this.createRedis(name, projectId, environmentId, options);
493
- return {
494
- redis,
495
- created: true
496
- };
497
- }
498
- /**
499
- * Get a Redis instance by ID
500
- */
501
- async getRedis(redisId) {
502
- return this.get(`redis.one?redisId=${redisId}`);
503
- }
504
- /**
505
- * Deploy a Redis instance
506
- */
507
- async deployRedis(redisId) {
508
- await this.post("redis.deploy", { redisId });
509
- }
510
- /**
511
- * Save environment variables for Redis
512
- */
513
- async saveRedisEnv(redisId, env) {
514
- await this.post("redis.saveEnvironment", {
515
- redisId,
516
- env
517
- });
518
- }
519
- /**
520
- * Set external port for Redis (for external access)
521
- */
522
- async saveRedisExternalPort(redisId, externalPort) {
523
- await this.post("redis.saveExternalPort", {
524
- redisId,
525
- externalPort
526
- });
527
- }
528
- /**
529
- * Update Redis configuration
530
- */
531
- async updateRedis(redisId, updates) {
532
- await this.post("redis.update", {
533
- redisId,
534
- ...updates
535
- });
536
- }
537
- /**
538
- * Delete a Redis instance
539
- */
540
- async deleteRedis(redisId) {
541
- await this.post("redis.remove", { redisId });
542
- }
543
- /**
544
- * Create a new domain for an application
545
- */
546
- async createDomain(options) {
547
- return this.post("domain.create", options);
548
- }
549
- /**
550
- * Update an existing domain
551
- */
552
- async updateDomain(domainId, updates) {
553
- await this.post("domain.update", {
554
- domainId,
555
- ...updates
556
- });
557
- }
558
- /**
559
- * Delete a domain
560
- */
561
- async deleteDomain(domainId) {
562
- await this.post("domain.delete", { domainId });
563
- }
564
- /**
565
- * Get a domain by ID
566
- */
567
- async getDomain(domainId) {
568
- return this.get(`domain.one?domainId=${domainId}`);
569
- }
570
- /**
571
- * Get all domains for an application
572
- */
573
- async getDomainsByApplicationId(applicationId) {
574
- return this.get(`domain.byApplicationId?applicationId=${applicationId}`);
575
- }
576
- /**
577
- * Validate a domain and trigger SSL certificate generation
578
- *
579
- * This should be called after DNS records are created and propagated.
580
- * It triggers Let's Encrypt certificate generation for HTTPS domains.
581
- *
582
- * @param domain - The domain hostname to validate (e.g., 'api.example.com')
583
- */
584
- async validateDomain(domain) {
585
- return this.post("domain.validateDomain", { domain });
586
- }
587
- /**
588
- * Auto-generate a domain name for an application
589
- */
590
- async generateDomain(appName, serverId) {
591
- return this.post("domain.generateDomain", {
592
- appName,
593
- serverId
594
- });
595
- }
596
- /**
597
- * List all backup destinations
598
- */
599
- async listDestinations() {
600
- return this.get("destination.all");
601
- }
602
- /**
603
- * Get a destination by ID
604
- */
605
- async getDestination(destinationId) {
606
- return this.get(`destination.one?destinationId=${destinationId}`);
607
- }
608
- /**
609
- * Create a new S3 backup destination
610
- */
611
- async createDestination(options) {
612
- return this.post("destination.create", { ...options });
613
- }
614
- /**
615
- * Find a destination by name
616
- */
617
- async findDestinationByName(name) {
618
- const destinations = await this.listDestinations();
619
- return destinations.find((d) => d.name === name);
620
- }
621
- /**
622
- * Find or create a destination by name
623
- */
624
- async findOrCreateDestination(name, options) {
625
- const existing = await this.findDestinationByName(name);
626
- if (existing) return {
627
- destination: existing,
628
- created: false
629
- };
630
- const destination = await this.createDestination({
631
- name,
632
- ...options
633
- });
634
- return {
635
- destination,
636
- created: true
637
- };
638
- }
639
- /**
640
- * Update a destination
641
- */
642
- async updateDestination(destinationId, updates) {
643
- await this.post("destination.update", {
644
- destinationId,
645
- ...updates
646
- });
647
- }
648
- /**
649
- * Delete a destination
650
- */
651
- async deleteDestination(destinationId) {
652
- await this.post("destination.remove", { destinationId });
653
- }
654
- /**
655
- * Test connection to a destination
656
- */
657
- async testDestinationConnection(destinationId) {
658
- return this.post("destination.testConnection", { destinationId });
659
- }
660
- /**
661
- * Create a backup schedule for postgres
662
- */
663
- async createPostgresBackup(options) {
664
- return this.post("backup.create", {
665
- ...options,
666
- databaseType: "postgres"
667
- });
668
- }
669
- /**
670
- * List backups for a postgres database
671
- */
672
- async listPostgresBackups(postgresId) {
673
- return this.get(`backup.all?postgresId=${postgresId}&databaseType=postgres`);
674
- }
675
- /**
676
- * Get a backup by ID
677
- */
678
- async getBackup(backupId) {
679
- return this.get(`backup.one?backupId=${backupId}`);
680
- }
681
- /**
682
- * Update a backup schedule
683
- */
684
- async updateBackup(backupId, updates) {
685
- await this.post("backup.update", {
686
- backupId,
687
- ...updates
688
- });
689
- }
690
- /**
691
- * Delete a backup schedule
692
- */
693
- async deleteBackup(backupId) {
694
- await this.post("backup.remove", { backupId });
695
- }
696
- /**
697
- * Trigger a manual backup run
698
- */
699
- async runBackupManually(backupId) {
700
- await this.post("backup.manualBackup", { backupId });
701
- }
702
- };
703
-
704
- //#endregion
705
- export { DokployApi, DokployApiError };
706
- //# sourceMappingURL=dokploy-api-aTFPz7_4.mjs.map