windmill-cli 1.518.2 → 1.519.0

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 (204) hide show
  1. package/esm/gen/core/OpenAPI.js +1 -1
  2. package/esm/gen/services.gen.js +74 -2
  3. package/esm/{apps.js → src/commands/app/apps.js} +6 -6
  4. package/esm/{dev.js → src/commands/dev/dev.js} +11 -11
  5. package/esm/{flow.js → src/commands/flow/flow.js} +13 -13
  6. package/esm/{folder.js → src/commands/folder/folder.js} +6 -6
  7. package/esm/src/commands/gitsync-settings/converter.js +134 -0
  8. package/esm/src/commands/gitsync-settings/gitsync-settings.js +2 -0
  9. package/esm/src/commands/gitsync-settings/index.js +28 -0
  10. package/esm/src/commands/gitsync-settings/legacySettings.js +119 -0
  11. package/esm/src/commands/gitsync-settings/pull.js +372 -0
  12. package/esm/src/commands/gitsync-settings/push.js +263 -0
  13. package/esm/src/commands/gitsync-settings/types.js +37 -0
  14. package/esm/src/commands/gitsync-settings/utils.js +129 -0
  15. package/esm/{hub.js → src/commands/hub/hub.js} +6 -6
  16. package/esm/src/commands/init/init.js +214 -0
  17. package/esm/{instance.js → src/commands/instance/instance.js} +18 -18
  18. package/esm/{queues.js → src/commands/queues/queues.js} +4 -4
  19. package/esm/{resource.js → src/commands/resource/resource.js} +7 -7
  20. package/esm/{resource-type.js → src/commands/resource-type/resource-type.js} +6 -6
  21. package/esm/{schedule.js → src/commands/schedule/schedule.js} +6 -6
  22. package/esm/{script.js → src/commands/script/script.js} +14 -14
  23. package/esm/{pull.js → src/commands/sync/pull.js} +2 -2
  24. package/esm/{sync.js → src/commands/sync/sync.js} +47 -146
  25. package/esm/{trigger.js → src/commands/trigger/trigger.js} +6 -6
  26. package/esm/{user.js → src/commands/user/user.js} +6 -6
  27. package/esm/{variable.js → src/commands/variable/variable.js} +6 -6
  28. package/esm/{worker_groups.js → src/commands/worker-groups/worker_groups.js} +5 -5
  29. package/esm/{workers.js → src/commands/workers/workers.js} +4 -4
  30. package/esm/{workspace.js → src/commands/workspace/workspace.js} +78 -44
  31. package/esm/{auth.js → src/core/auth.js} +3 -3
  32. package/esm/src/core/branch-profiles.js +46 -0
  33. package/esm/src/core/conf.js +162 -0
  34. package/esm/src/core/context.js +263 -0
  35. package/esm/{login.js → src/core/login.js} +2 -2
  36. package/esm/{settings.js → src/core/settings.js} +8 -8
  37. package/esm/src/core/store.js +19 -0
  38. package/esm/src/main.js +174 -0
  39. package/esm/{types.js → src/types.js} +16 -16
  40. package/esm/{codebase.js → src/utils/codebase.js} +1 -1
  41. package/esm/src/utils/git.js +29 -0
  42. package/esm/{metadata.js → src/utils/metadata.js} +31 -31
  43. package/esm/{upgrade.js → src/utils/upgrade.js} +1 -1
  44. package/esm/{utils.js → src/utils/utils.js} +11 -3
  45. package/esm/windmill-utils-internal/src/config/config.js +190 -0
  46. package/esm/windmill-utils-internal/src/inline-scripts/extractor.js +13 -9
  47. package/esm/windmill-utils-internal/src/path-utils/path-assigner.js +25 -9
  48. package/package.json +6 -6
  49. package/types/gen/services.gen.d.ts +37 -1
  50. package/types/gen/services.gen.d.ts.map +1 -1
  51. package/types/gen/types.gen.d.ts +48 -3
  52. package/types/gen/types.gen.d.ts.map +1 -1
  53. package/types/src/commands/app/apps.d.ts +17 -0
  54. package/types/src/commands/app/apps.d.ts.map +1 -0
  55. package/types/src/commands/dev/dev.d.ts +12 -0
  56. package/types/src/commands/dev/dev.d.ts.map +1 -0
  57. package/types/{flow.d.ts → src/commands/flow/flow.d.ts} +5 -5
  58. package/types/src/commands/flow/flow.d.ts.map +1 -0
  59. package/types/{folder.d.ts → src/commands/folder/folder.d.ts} +3 -3
  60. package/types/src/commands/folder/folder.d.ts.map +1 -0
  61. package/types/src/commands/gitsync-settings/converter.d.ts +10 -0
  62. package/types/src/commands/gitsync-settings/converter.d.ts.map +1 -0
  63. package/types/src/commands/gitsync-settings/gitsync-settings.d.ts +3 -0
  64. package/types/src/commands/gitsync-settings/gitsync-settings.d.ts.map +1 -0
  65. package/types/src/commands/gitsync-settings/index.d.ts +25 -0
  66. package/types/src/commands/gitsync-settings/index.d.ts.map +1 -0
  67. package/types/src/commands/gitsync-settings/legacySettings.d.ts +4 -0
  68. package/types/src/commands/gitsync-settings/legacySettings.d.ts.map +1 -0
  69. package/types/src/commands/gitsync-settings/pull.d.ts +14 -0
  70. package/types/src/commands/gitsync-settings/pull.d.ts.map +1 -0
  71. package/types/src/commands/gitsync-settings/push.d.ts +10 -0
  72. package/types/src/commands/gitsync-settings/push.d.ts.map +1 -0
  73. package/types/src/commands/gitsync-settings/types.d.ts +35 -0
  74. package/types/src/commands/gitsync-settings/types.d.ts.map +1 -0
  75. package/types/src/commands/gitsync-settings/utils.d.ts +36 -0
  76. package/types/src/commands/gitsync-settings/utils.d.ts.map +1 -0
  77. package/types/{hub.d.ts → src/commands/hub/hub.d.ts} +2 -2
  78. package/types/src/commands/hub/hub.d.ts.map +1 -0
  79. package/types/src/commands/init/init.d.ts +34 -0
  80. package/types/src/commands/init/init.d.ts.map +1 -0
  81. package/types/{instance.d.ts → src/commands/instance/instance.d.ts} +1 -1
  82. package/types/src/commands/instance/instance.d.ts.map +1 -0
  83. package/types/src/commands/queues/queues.d.ts +14 -0
  84. package/types/src/commands/queues/queues.d.ts.map +1 -0
  85. package/types/{resource.d.ts → src/commands/resource/resource.d.ts} +3 -3
  86. package/types/src/commands/resource/resource.d.ts.map +1 -0
  87. package/types/src/commands/resource-type/resource-type.d.ts +16 -0
  88. package/types/src/commands/resource-type/resource-type.d.ts.map +1 -0
  89. package/types/{schedule.d.ts → src/commands/schedule/schedule.d.ts} +3 -3
  90. package/types/src/commands/schedule/schedule.d.ts.map +1 -0
  91. package/types/{script.d.ts → src/commands/script/script.d.ts} +9 -9
  92. package/types/src/commands/script/script.d.ts.map +1 -0
  93. package/types/{pull.d.ts → src/commands/sync/pull.d.ts} +3 -3
  94. package/types/src/commands/sync/pull.d.ts.map +1 -0
  95. package/types/{sync.d.ts → src/commands/sync/sync.d.ts} +11 -13
  96. package/types/src/commands/sync/sync.d.ts.map +1 -0
  97. package/types/{trigger.d.ts → src/commands/trigger/trigger.d.ts} +3 -3
  98. package/types/src/commands/trigger/trigger.d.ts.map +1 -0
  99. package/types/{user.d.ts → src/commands/user/user.d.ts} +5 -5
  100. package/types/src/commands/user/user.d.ts.map +1 -0
  101. package/types/{variable.d.ts → src/commands/variable/variable.d.ts} +3 -3
  102. package/types/src/commands/variable/variable.d.ts.map +1 -0
  103. package/types/{worker_groups.d.ts → src/commands/worker-groups/worker_groups.d.ts} +2 -3
  104. package/types/src/commands/worker-groups/worker_groups.d.ts.map +1 -0
  105. package/types/{workers.d.ts → src/commands/workers/workers.d.ts} +1 -1
  106. package/types/src/commands/workers/workers.d.ts.map +1 -0
  107. package/types/{workspace.d.ts → src/commands/workspace/workspace.d.ts} +6 -4
  108. package/types/src/commands/workspace/workspace.d.ts.map +1 -0
  109. package/types/{auth.d.ts → src/core/auth.d.ts} +2 -2
  110. package/types/src/core/auth.d.ts.map +1 -0
  111. package/types/src/core/branch-profiles.d.ts +12 -0
  112. package/types/src/core/branch-profiles.d.ts.map +1 -0
  113. package/types/{conf.d.ts → src/core/conf.d.ts} +12 -3
  114. package/types/src/core/conf.d.ts.map +1 -0
  115. package/types/{context.d.ts → src/core/context.d.ts} +2 -2
  116. package/types/src/core/context.d.ts.map +1 -0
  117. package/types/{login.d.ts → src/core/login.d.ts} +1 -1
  118. package/types/src/core/login.d.ts.map +1 -0
  119. package/types/{settings.d.ts → src/core/settings.d.ts} +2 -2
  120. package/types/src/core/settings.d.ts.map +1 -0
  121. package/types/src/core/store.d.ts +2 -0
  122. package/types/src/core/store.d.ts.map +1 -0
  123. package/types/src/guidance/flow_guidance.d.ts.map +1 -0
  124. package/types/src/guidance/script_guidance.d.ts.map +1 -0
  125. package/types/src/main.d.ts +74 -0
  126. package/types/src/main.d.ts.map +1 -0
  127. package/types/src/types.d.ts.map +1 -0
  128. package/types/{codebase.d.ts → src/utils/codebase.d.ts} +1 -1
  129. package/types/src/utils/codebase.d.ts.map +1 -0
  130. package/types/src/utils/git.d.ts +3 -0
  131. package/types/src/utils/git.d.ts.map +1 -0
  132. package/types/src/utils/local_encryption.d.ts.map +1 -0
  133. package/types/{metadata.d.ts → src/utils/metadata.d.ts} +4 -4
  134. package/types/src/utils/metadata.d.ts.map +1 -0
  135. package/types/src/utils/script_common.d.ts.map +1 -0
  136. package/types/{upgrade.d.ts → src/utils/upgrade.d.ts} +1 -1
  137. package/types/src/utils/upgrade.d.ts.map +1 -0
  138. package/types/{utils.d.ts → src/utils/utils.d.ts} +2 -1
  139. package/types/src/utils/utils.d.ts.map +1 -0
  140. package/types/windmill-utils-internal/src/config/config.d.ts +12 -0
  141. package/types/windmill-utils-internal/src/config/config.d.ts.map +1 -0
  142. package/types/windmill-utils-internal/src/gen/types.gen.d.ts +48 -3
  143. package/types/windmill-utils-internal/src/gen/types.gen.d.ts.map +1 -1
  144. package/types/windmill-utils-internal/src/inline-scripts/extractor.d.ts +1 -4
  145. package/types/windmill-utils-internal/src/inline-scripts/extractor.d.ts.map +1 -1
  146. package/types/windmill-utils-internal/src/path-utils/path-assigner.d.ts +6 -6
  147. package/types/windmill-utils-internal/src/path-utils/path-assigner.d.ts.map +1 -1
  148. package/esm/conf.js +0 -78
  149. package/esm/context.js +0 -121
  150. package/esm/gitsync-settings.js +0 -984
  151. package/esm/main.js +0 -337
  152. package/esm/store.js +0 -76
  153. package/types/apps.d.ts +0 -17
  154. package/types/apps.d.ts.map +0 -1
  155. package/types/auth.d.ts.map +0 -1
  156. package/types/codebase.d.ts.map +0 -1
  157. package/types/conf.d.ts.map +0 -1
  158. package/types/context.d.ts.map +0 -1
  159. package/types/dev.d.ts +0 -12
  160. package/types/dev.d.ts.map +0 -1
  161. package/types/flow.d.ts.map +0 -1
  162. package/types/flow_guidance.d.ts.map +0 -1
  163. package/types/folder.d.ts.map +0 -1
  164. package/types/gitsync-settings.d.ts +0 -40
  165. package/types/gitsync-settings.d.ts.map +0 -1
  166. package/types/hub.d.ts.map +0 -1
  167. package/types/instance.d.ts.map +0 -1
  168. package/types/local_encryption.d.ts.map +0 -1
  169. package/types/login.d.ts.map +0 -1
  170. package/types/main.d.ts +0 -70
  171. package/types/main.d.ts.map +0 -1
  172. package/types/metadata.d.ts.map +0 -1
  173. package/types/pull.d.ts.map +0 -1
  174. package/types/queues.d.ts +0 -14
  175. package/types/queues.d.ts.map +0 -1
  176. package/types/resource-type.d.ts +0 -16
  177. package/types/resource-type.d.ts.map +0 -1
  178. package/types/resource.d.ts.map +0 -1
  179. package/types/schedule.d.ts.map +0 -1
  180. package/types/script.d.ts.map +0 -1
  181. package/types/script_common.d.ts.map +0 -1
  182. package/types/script_guidance.d.ts.map +0 -1
  183. package/types/settings.d.ts.map +0 -1
  184. package/types/store.d.ts +0 -3
  185. package/types/store.d.ts.map +0 -1
  186. package/types/sync.d.ts.map +0 -1
  187. package/types/trigger.d.ts.map +0 -1
  188. package/types/types.d.ts.map +0 -1
  189. package/types/upgrade.d.ts.map +0 -1
  190. package/types/user.d.ts.map +0 -1
  191. package/types/utils.d.ts.map +0 -1
  192. package/types/variable.d.ts.map +0 -1
  193. package/types/worker_groups.d.ts.map +0 -1
  194. package/types/workers.d.ts.map +0 -1
  195. package/types/workspace.d.ts.map +0 -1
  196. /package/esm/{flow_guidance.js → src/guidance/flow_guidance.js} +0 -0
  197. /package/esm/{script_guidance.js → src/guidance/script_guidance.js} +0 -0
  198. /package/esm/{local_encryption.js → src/utils/local_encryption.js} +0 -0
  199. /package/esm/{script_common.js → src/utils/script_common.js} +0 -0
  200. /package/types/{flow_guidance.d.ts → src/guidance/flow_guidance.d.ts} +0 -0
  201. /package/types/{script_guidance.d.ts → src/guidance/script_guidance.d.ts} +0 -0
  202. /package/types/{types.d.ts → src/types.d.ts} +0 -0
  203. /package/types/{local_encryption.d.ts → src/utils/local_encryption.d.ts} +0 -0
  204. /package/types/{script_common.d.ts → src/utils/script_common.d.ts} +0 -0
@@ -32,7 +32,7 @@ export const OpenAPI = {
32
32
  PASSWORD: undefined,
33
33
  TOKEN: getEnv("WM_TOKEN"),
34
34
  USERNAME: undefined,
35
- VERSION: '1.518.2',
35
+ VERSION: '1.519.0',
36
36
  WITH_CREDENTIALS: true,
37
37
  interceptors: {
38
38
  request: new Interceptors(),
@@ -476,6 +476,37 @@ export const existsUsername = (data) => {
476
476
  mediaType: 'application/json'
477
477
  });
478
478
  };
479
+ /**
480
+ * checks that all given databases exist or else return the ones that don't
481
+ * @param data The data for the request.
482
+ * @param data.requestBody
483
+ * @returns string databases that do not exist
484
+ * @throws ApiError
485
+ */
486
+ export const databasesExist = (data) => {
487
+ return __request(OpenAPI, {
488
+ method: 'POST',
489
+ url: '/settings/databases_exist',
490
+ body: data.requestBody,
491
+ mediaType: 'application/json'
492
+ });
493
+ };
494
+ /**
495
+ * Runs CREATE DATABASE on the Windmill Postgres and grants access to the ducklake_user
496
+ * @param data The data for the request.
497
+ * @param data.name The name of the database to create
498
+ * @returns unknown status
499
+ * @throws ApiError
500
+ */
501
+ export const createDucklakeDatabase = (data) => {
502
+ return __request(OpenAPI, {
503
+ method: 'POST',
504
+ url: '/settings/create_ducklake_database/{name}',
505
+ path: {
506
+ name: data.name
507
+ }
508
+ });
509
+ };
479
510
  /**
480
511
  * get global settings
481
512
  * @param data The data for the request.
@@ -1599,6 +1630,41 @@ export const editLargeFileStorageConfig = (data) => {
1599
1630
  mediaType: 'application/json'
1600
1631
  });
1601
1632
  };
1633
+ /**
1634
+ * list ducklakes
1635
+ * @param data The data for the request.
1636
+ * @param data.workspace
1637
+ * @returns string status
1638
+ * @throws ApiError
1639
+ */
1640
+ export const listDucklakes = (data) => {
1641
+ return __request(OpenAPI, {
1642
+ method: 'GET',
1643
+ url: '/w/{workspace}/workspaces/list_ducklakes',
1644
+ path: {
1645
+ workspace: data.workspace
1646
+ }
1647
+ });
1648
+ };
1649
+ /**
1650
+ * edit ducklake settings
1651
+ * @param data The data for the request.
1652
+ * @param data.workspace
1653
+ * @param data.requestBody Ducklake settings
1654
+ * @returns unknown status
1655
+ * @throws ApiError
1656
+ */
1657
+ export const editDucklakeConfig = (data) => {
1658
+ return __request(OpenAPI, {
1659
+ method: 'POST',
1660
+ url: '/w/{workspace}/workspaces/edit_ducklake_config',
1661
+ path: {
1662
+ workspace: data.workspace
1663
+ },
1664
+ body: data.requestBody,
1665
+ mediaType: 'application/json'
1666
+ });
1667
+ };
1602
1668
  /**
1603
1669
  * edit workspace git sync settings
1604
1670
  * @param data The data for the request.
@@ -5725,7 +5791,9 @@ export const getJobArgs = (data) => {
5725
5791
  * @param data.id
5726
5792
  * @param data.running
5727
5793
  * @param data.logOffset
5794
+ * @param data.streamOffset
5728
5795
  * @param data.getProgress
5796
+ * @param data.noLogs
5729
5797
  * @returns unknown job details
5730
5798
  * @throws ApiError
5731
5799
  */
@@ -5740,7 +5808,9 @@ export const getJobUpdates = (data) => {
5740
5808
  query: {
5741
5809
  running: data.running,
5742
5810
  log_offset: data.logOffset,
5743
- get_progress: data.getProgress
5811
+ stream_offset: data.streamOffset,
5812
+ get_progress: data.getProgress,
5813
+ no_logs: data.noLogs
5744
5814
  }
5745
5815
  });
5746
5816
  };
@@ -5753,6 +5823,7 @@ export const getJobUpdates = (data) => {
5753
5823
  * @param data.logOffset
5754
5824
  * @param data.getProgress
5755
5825
  * @param data.onlyResult
5826
+ * @param data.noLogs
5756
5827
  * @returns string server-sent events stream of job updates
5757
5828
  * @throws ApiError
5758
5829
  */
@@ -5768,7 +5839,8 @@ export const getJobUpdatesSse = (data) => {
5768
5839
  running: data.running,
5769
5840
  log_offset: data.logOffset,
5770
5841
  get_progress: data.getProgress,
5771
- only_result: data.onlyResult
5842
+ only_result: data.onlyResult,
5843
+ no_logs: data.noLogs
5772
5844
  }
5773
5845
  });
5774
5846
  };
@@ -1,10 +1,10 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
- import { requireLogin } from "./auth.js";
3
- import { resolveWorkspace, validatePath } from "./context.js";
4
- import { colors, Command, log, SEP, Table, yamlParseFile } from "./deps.js";
5
- import * as wmill from "./gen/services.gen.js";
6
- import { isSuperset } from "./types.js";
7
- import { readInlinePathSync } from "./utils.js";
2
+ import { requireLogin } from "../../core/auth.js";
3
+ import { resolveWorkspace, validatePath } from "../../core/context.js";
4
+ import { colors, Command, log, SEP, Table, yamlParseFile } from "../../../deps.js";
5
+ import * as wmill from "../../../gen/services.gen.js";
6
+ import { isSuperset } from "../../types.js";
7
+ import { readInlinePathSync } from "../../utils/utils.js";
8
8
  const alreadySynced = [];
9
9
  export async function pushApp(workspace, remotePath, localPath, message) {
10
10
  if (alreadySynced.includes(localPath)) {
@@ -1,14 +1,14 @@
1
- import * as dntShim from "./_dnt.shims.js";
2
- import { Command, SEP, WebSocketServer, express, getPort, http, log, open, yamlParseFile, } from "./deps.js";
3
- import { getTypeStrFromPath } from "./types.js";
4
- import { ignoreF } from "./sync.js";
5
- import { requireLogin } from "./auth.js";
6
- import { resolveWorkspace } from "./context.js";
7
- import { mergeConfigWithConfigFile, readConfigFile, } from "./conf.js";
8
- import { exts, findGlobalDeps, removeExtensionToPath } from "./script.js";
9
- import { inferContentTypeFromFilePath } from "./script_common.js";
10
- import { replaceInlineScripts } from "./windmill-utils-internal/src/inline-scripts/replacer.js";
11
- import { parseMetadataFile } from "./metadata.js";
1
+ import * as dntShim from "../../../_dnt.shims.js";
2
+ import { Command, SEP, WebSocketServer, express, getPort, http, log, open, yamlParseFile, } from "../../../deps.js";
3
+ import { getTypeStrFromPath } from "../../types.js";
4
+ import { ignoreF } from "../sync/sync.js";
5
+ import { requireLogin } from "../../core/auth.js";
6
+ import { resolveWorkspace } from "../../core/context.js";
7
+ import { mergeConfigWithConfigFile, readConfigFile, } from "../../core/conf.js";
8
+ import { exts, findGlobalDeps, removeExtensionToPath } from "../script/script.js";
9
+ import { inferContentTypeFromFilePath } from "../../utils/script_common.js";
10
+ import { replaceInlineScripts } from "../../../windmill-utils-internal/src/inline-scripts/replacer.js";
11
+ import { parseMetadataFile } from "../../utils/metadata.js";
12
12
  const PORT = 3001;
13
13
  async function dev(opts) {
14
14
  const workspace = await resolveWorkspace(opts);
@@ -1,17 +1,17 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
- import * as dntShim from "./_dnt.shims.js";
3
- import { isSuperset } from "./types.js";
4
- import { Confirm, SEP, log, yamlStringify } from "./deps.js";
5
- import { colors, Command, Table, yamlParseFile } from "./deps.js";
6
- import * as wmill from "./gen/services.gen.js";
7
- import { requireLogin } from "./auth.js";
8
- import { resolveWorkspace, validatePath } from "./context.js";
9
- import { resolve, track_job } from "./script.js";
10
- import { defaultFlowDefinition } from "./bootstrap/flow_bootstrap.js";
11
- import { generateFlowLockInternal } from "./metadata.js";
12
- import { mergeConfigWithConfigFile } from "./conf.js";
13
- import { FSFSElement, elementsToMap, ignoreF } from "./sync.js";
14
- import { replaceInlineScripts } from "./windmill-utils-internal/src/inline-scripts/replacer.js";
2
+ import * as dntShim from "../../../_dnt.shims.js";
3
+ import { isSuperset } from "../../types.js";
4
+ import { Confirm, SEP, log, yamlStringify } from "../../../deps.js";
5
+ import { colors, Command, Table, yamlParseFile } from "../../../deps.js";
6
+ import * as wmill from "../../../gen/services.gen.js";
7
+ import { requireLogin } from "../../core/auth.js";
8
+ import { resolveWorkspace, validatePath } from "../../core/context.js";
9
+ import { resolve, track_job } from "../script/script.js";
10
+ import { defaultFlowDefinition } from "../../../bootstrap/flow_bootstrap.js";
11
+ import { generateFlowLockInternal } from "../../utils/metadata.js";
12
+ import { mergeConfigWithConfigFile } from "../../core/conf.js";
13
+ import { FSFSElement, elementsToMap, ignoreF } from "../sync/sync.js";
14
+ import { replaceInlineScripts } from "../../../windmill-utils-internal/src/inline-scripts/replacer.js";
15
15
  const alreadySynced = [];
16
16
  export async function pushFlow(workspace, remotePath, localPath, message) {
17
17
  if (alreadySynced.includes(localPath)) {
@@ -1,10 +1,10 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
- import * as dntShim from "./_dnt.shims.js";
3
- import { colors, Command, log, SEP, Table } from "./deps.js";
4
- import * as wmill from "./gen/services.gen.js";
5
- import { requireLogin } from "./auth.js";
6
- import { resolveWorkspace, validatePath } from "./context.js";
7
- import { isSuperset, parseFromFile } from "./types.js";
2
+ import * as dntShim from "../../../_dnt.shims.js";
3
+ import { colors, Command, log, SEP, Table } from "../../../deps.js";
4
+ import * as wmill from "../../../gen/services.gen.js";
5
+ import { requireLogin } from "../../core/auth.js";
6
+ import { resolveWorkspace, validatePath } from "../../core/context.js";
7
+ import { isSuperset, parseFromFile } from "../../types.js";
8
8
  async function list(opts) {
9
9
  const workspace = await resolveWorkspace(opts);
10
10
  await requireLogin(opts);
@@ -0,0 +1,134 @@
1
+ // Helper to compare string arrays (used for includes/excludes/extraIncludes)
2
+ function arraysEqual(arr1, arr2) {
3
+ if (arr1.length !== arr2.length) {
4
+ return false;
5
+ }
6
+ const sorted1 = [...arr1].sort();
7
+ const sorted2 = [...arr2].sort();
8
+ return sorted1.every((item, index) => item === sorted2[index]);
9
+ }
10
+ export class GitSyncSettingsConverter {
11
+ // Convert backend include_type array to SyncOptions boolean flags
12
+ static fromBackendFormat(settings) {
13
+ const includeTypes = settings.include_type || [];
14
+ const result = {
15
+ includes: settings.include_path || [],
16
+ excludes: settings.exclude_path || [],
17
+ skipScripts: !includeTypes.includes("script"),
18
+ skipFlows: !includeTypes.includes("flow"),
19
+ skipApps: !includeTypes.includes("app"),
20
+ skipFolders: !includeTypes.includes("folder"),
21
+ skipVariables: !includeTypes.includes("variable"),
22
+ skipResources: !includeTypes.includes("resource"),
23
+ skipResourceTypes: !includeTypes.includes("resourcetype"),
24
+ skipSecrets: !includeTypes.includes("secret"),
25
+ includeSchedules: includeTypes.includes("schedule"),
26
+ includeTriggers: includeTypes.includes("trigger"),
27
+ includeUsers: includeTypes.includes("user"),
28
+ includeGroups: includeTypes.includes("group"),
29
+ includeSettings: includeTypes.includes("settings"),
30
+ includeKey: includeTypes.includes("key"),
31
+ };
32
+ // Only include extraIncludes if it has content
33
+ if (settings.extra_include_path && settings.extra_include_path.length > 0) {
34
+ result.extraIncludes = settings.extra_include_path;
35
+ }
36
+ return result;
37
+ }
38
+ // Convert SyncOptions boolean flags to backend include_type array
39
+ static toBackendFormat(opts) {
40
+ const includeTypes = [];
41
+ if (!opts.skipScripts)
42
+ includeTypes.push("script");
43
+ if (!opts.skipFlows)
44
+ includeTypes.push("flow");
45
+ if (!opts.skipApps)
46
+ includeTypes.push("app");
47
+ if (!opts.skipFolders)
48
+ includeTypes.push("folder");
49
+ if (!opts.skipVariables)
50
+ includeTypes.push("variable");
51
+ if (!opts.skipResources)
52
+ includeTypes.push("resource");
53
+ if (!opts.skipResourceTypes)
54
+ includeTypes.push("resourcetype");
55
+ if (!opts.skipSecrets)
56
+ includeTypes.push("secret");
57
+ if (opts.includeSchedules)
58
+ includeTypes.push("schedule");
59
+ if (opts.includeTriggers)
60
+ includeTypes.push("trigger");
61
+ if (opts.includeUsers)
62
+ includeTypes.push("user");
63
+ if (opts.includeGroups)
64
+ includeTypes.push("group");
65
+ if (opts.includeSettings)
66
+ includeTypes.push("settings");
67
+ if (opts.includeKey)
68
+ includeTypes.push("key");
69
+ const result = {
70
+ include_path: opts.includes || [],
71
+ include_type: includeTypes,
72
+ };
73
+ // Only include optional arrays if they have content
74
+ if (opts.excludes && opts.excludes.length > 0) {
75
+ result.exclude_path = opts.excludes;
76
+ }
77
+ if (opts.extraIncludes && opts.extraIncludes.length > 0) {
78
+ result.extra_include_path = opts.extraIncludes;
79
+ }
80
+ return result;
81
+ }
82
+ // Normalize SyncOptions for semantic comparison - treat undefined values as their defaults
83
+ static normalize(opts) {
84
+ return {
85
+ ...opts,
86
+ includes: opts.includes || [],
87
+ excludes: opts.excludes || [],
88
+ extraIncludes: opts.extraIncludes || [],
89
+ skipVariables: opts.skipVariables ?? false,
90
+ skipResources: opts.skipResources ?? false,
91
+ skipResourceTypes: opts.skipResourceTypes ?? false,
92
+ skipSecrets: opts.skipSecrets ?? true,
93
+ skipScripts: opts.skipScripts ?? false,
94
+ skipFlows: opts.skipFlows ?? false,
95
+ skipApps: opts.skipApps ?? false,
96
+ skipFolders: opts.skipFolders ?? false,
97
+ includeSchedules: opts.includeSchedules ?? false,
98
+ includeTriggers: opts.includeTriggers ?? false,
99
+ includeUsers: opts.includeUsers ?? false,
100
+ includeGroups: opts.includeGroups ?? false,
101
+ includeSettings: opts.includeSettings ?? false,
102
+ includeKey: opts.includeKey ?? false,
103
+ };
104
+ }
105
+ // Extract only git-sync relevant fields for comparison
106
+ static extractGitSyncFields(opts) {
107
+ return {
108
+ includes: opts.includes || [],
109
+ excludes: opts.excludes || [],
110
+ extraIncludes: opts.extraIncludes || [],
111
+ skipScripts: opts.skipScripts,
112
+ skipFlows: opts.skipFlows,
113
+ skipApps: opts.skipApps,
114
+ skipFolders: opts.skipFolders,
115
+ skipVariables: opts.skipVariables,
116
+ skipResources: opts.skipResources,
117
+ skipResourceTypes: opts.skipResourceTypes,
118
+ skipSecrets: opts.skipSecrets,
119
+ includeSchedules: opts.includeSchedules,
120
+ includeTriggers: opts.includeTriggers,
121
+ includeUsers: opts.includeUsers,
122
+ includeGroups: opts.includeGroups,
123
+ includeSettings: opts.includeSettings,
124
+ includeKey: opts.includeKey,
125
+ };
126
+ }
127
+ // Check if two values are different, with special handling for arrays
128
+ static isDifferent(value1, value2) {
129
+ if (Array.isArray(value1) && Array.isArray(value2)) {
130
+ return !arraysEqual(value1, value2);
131
+ }
132
+ return value1 !== value2;
133
+ }
134
+ }
@@ -0,0 +1,2 @@
1
+ export { pullGitSyncSettings, pushGitSyncSettings } from "./index.js";
2
+ export { default } from "./index.js";
@@ -0,0 +1,28 @@
1
+ import { Command } from "../../../deps.js";
2
+ import { pullGitSyncSettings } from "./pull.js";
3
+ import { pushGitSyncSettings } from "./push.js";
4
+ const command = new Command()
5
+ .description("Manage git-sync settings between local wmill.yaml and Windmill backend")
6
+ .command("pull")
7
+ .description("Pull git-sync settings from Windmill backend to local wmill.yaml")
8
+ .option("--repository <repo:string>", "Specify repository path (e.g., u/user/repo)")
9
+ .option("--default", "Write settings to top-level defaults instead of overrides")
10
+ .option("--replace", "Replace existing settings (non-interactive mode)")
11
+ .option("--override", "Add branch-specific override (non-interactive mode)")
12
+ .option("--diff", "Show differences without applying changes")
13
+ .option("--json-output", "Output in JSON format")
14
+ .option("--with-backend-settings <json:string>", "Use provided JSON settings instead of querying backend (for testing)")
15
+ .option("--yes", "Skip interactive prompts and use default behavior")
16
+ .option("--promotion <branch:string>", "Use promotionOverrides from the specified branch instead of regular overrides")
17
+ .action(pullGitSyncSettings)
18
+ .command("push")
19
+ .description("Push git-sync settings from local wmill.yaml to Windmill backend")
20
+ .option("--repository <repo:string>", "Specify repository path (e.g., u/user/repo)")
21
+ .option("--diff", "Show what would be pushed without applying changes")
22
+ .option("--json-output", "Output in JSON format")
23
+ .option("--with-backend-settings <json:string>", "Use provided JSON settings instead of querying backend (for testing)")
24
+ .option("--yes", "Skip interactive prompts and use default behavior")
25
+ .option("--promotion <branch:string>", "Use promotionOverrides from the specified branch instead of regular overrides")
26
+ .action(pushGitSyncSettings);
27
+ export { pullGitSyncSettings, pushGitSyncSettings };
28
+ export default command;
@@ -0,0 +1,119 @@
1
+ import * as dntShim from "../../../_dnt.shims.js";
2
+ import { colors, Confirm } from "../../../deps.js";
3
+ import * as wmill from "../../../gen/services.gen.js";
4
+ // Shared migration function for legacy repositories
5
+ export async function handleLegacyRepositoryMigration(selectedRepo, gitSyncSettings, workspace, opts, operationName = "operation") {
6
+ if (selectedRepo.settings) {
7
+ return selectedRepo; // Already migrated
8
+ }
9
+ // This repository is in legacy format - handle migration
10
+ if (!gitSyncSettings.include_path || !gitSyncSettings.include_type) {
11
+ throw new Error(`Repository "${selectedRepo.git_repo_resource_path}" has legacy format but workspace-level include_path or include_type is missing. This indicates corrupted git-sync settings.`);
12
+ }
13
+ const workspaceIncludePath = gitSyncSettings.include_path;
14
+ const workspaceIncludeType = gitSyncSettings.include_type;
15
+ if (dntShim.Deno.stdout.isTerminal() && !opts.yes) {
16
+ // Interactive mode - show migration prompt
17
+ console.log(colors.yellow('\n⚠️ Legacy git-sync settings detected!'));
18
+ console.log(`\nRepository "${selectedRepo.git_repo_resource_path}" has legacy settings format.`);
19
+ console.log('The new format allows per-repository filter configuration.');
20
+ if (operationName === "push") {
21
+ console.log('This repository must be migrated before pushing settings.\n');
22
+ }
23
+ else {
24
+ console.log('\n');
25
+ }
26
+ console.log(colors.bold('Current workspace-level settings:'));
27
+ console.log(` Include paths: ${workspaceIncludePath.join(', ')}`);
28
+ console.log(` Include types: ${workspaceIncludeType.join(', ')}\n`);
29
+ // Show what the migration will do
30
+ let finalIncludeType = [...workspaceIncludeType];
31
+ if (selectedRepo.exclude_types_override && selectedRepo.exclude_types_override.length > 0) {
32
+ const originalCount = finalIncludeType.length;
33
+ finalIncludeType = finalIncludeType.filter(type => !selectedRepo.exclude_types_override.includes(type));
34
+ const excludedCount = originalCount - finalIncludeType.length;
35
+ console.log(colors.yellow(`Repository excludes ${excludedCount} types: ${selectedRepo.exclude_types_override.join(', ')}`));
36
+ }
37
+ console.log(colors.bold('\nAfter migration, repository will have:'));
38
+ console.log(` Include paths: ${workspaceIncludePath.join(', ')}`);
39
+ console.log(` Include types: ${finalIncludeType.join(', ')}\n`);
40
+ const confirm = await Confirm.prompt({
41
+ message: operationName === "push"
42
+ ? 'Do you want to migrate this repository before pushing?'
43
+ : 'Do you want to migrate this repository?',
44
+ default: true
45
+ });
46
+ if (!confirm) {
47
+ const message = operationName === "push"
48
+ ? '\n⚠️ Migration skipped. Cannot push to legacy repository.'
49
+ : '\n⚠️ Migration skipped. You can migrate later via the UI.';
50
+ console.log(colors.yellow(message));
51
+ if (operationName === "push") {
52
+ return null; // Signal to exit push operation
53
+ }
54
+ throw new Error('Migration cancelled by user');
55
+ }
56
+ // Perform the migration
57
+ let migratedIncludeType = [...workspaceIncludeType];
58
+ if (selectedRepo.exclude_types_override && selectedRepo.exclude_types_override.length > 0) {
59
+ migratedIncludeType = migratedIncludeType.filter(type => !selectedRepo.exclude_types_override.includes(type));
60
+ }
61
+ const migratedRepo = {
62
+ ...selectedRepo,
63
+ settings: {
64
+ include_path: [...workspaceIncludePath],
65
+ include_type: migratedIncludeType,
66
+ exclude_path: [],
67
+ extra_include_path: []
68
+ }
69
+ };
70
+ // Remove the old field
71
+ delete migratedRepo.exclude_types_override;
72
+ // Update the backend with migrated repository
73
+ const updatedRepositories = gitSyncSettings.repositories.map((repo) => {
74
+ if (repo.git_repo_resource_path === selectedRepo.git_repo_resource_path) {
75
+ return migratedRepo;
76
+ }
77
+ return repo;
78
+ });
79
+ await wmill.editWorkspaceGitSyncConfig({
80
+ workspace: workspace.workspaceId,
81
+ requestBody: {
82
+ git_sync_settings: {
83
+ repositories: updatedRepositories,
84
+ // Keep workspace-level settings if other repos are still legacy
85
+ ...(gitSyncSettings.repositories.some((r) => r.git_repo_resource_path !== selectedRepo.git_repo_resource_path && !r.settings) && {
86
+ include_path: workspaceIncludePath,
87
+ include_type: workspaceIncludeType
88
+ })
89
+ }
90
+ }
91
+ });
92
+ console.log(colors.green('\n✓ Repository migration completed successfully!'));
93
+ if (operationName === "push") {
94
+ console.log('Now proceeding with push operation...\n');
95
+ }
96
+ return migratedRepo;
97
+ }
98
+ else {
99
+ // Non-interactive mode - show error
100
+ console.error(colors.red('\n❌ Legacy git-sync settings detected!'));
101
+ console.error(`\nRepository "${selectedRepo.git_repo_resource_path}" has legacy settings format.`);
102
+ if (operationName === "push") {
103
+ console.error('This repository must be migrated before pushing settings.');
104
+ }
105
+ console.error('Please choose one of the following options:\n');
106
+ console.error('1. Go to the Windmill UI > Workspace Settings > Git Sync');
107
+ console.error(' Review and save this repository to migrate to the new format.\n');
108
+ console.error('2. Run this command in interactive mode (with TTY) to migrate.');
109
+ console.error(` Example: wmill gitsync-settings ${operationName}\n`);
110
+ if (operationName === "push") {
111
+ console.error('3. Pull settings first to migrate: wmill gitsync-settings pull\n');
112
+ }
113
+ else {
114
+ console.error('3. Push local settings to override backend settings:');
115
+ console.error(' wmill gitsync-settings push\n');
116
+ }
117
+ dntShim.Deno.exit(1);
118
+ }
119
+ }