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