windmill-cli 1.396.1 → 1.397.3

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 (89) hide show
  1. package/esm/apps.js +6 -5
  2. package/esm/bootstrap/script_bootstrap.js +18 -0
  3. package/esm/context.js +4 -3
  4. package/esm/deps.js +19 -2
  5. package/esm/flow.js +9 -8
  6. package/esm/folder.js +6 -5
  7. package/esm/gen/core/ApiError.js +41 -0
  8. package/esm/gen/core/ApiRequestOptions.js +1 -0
  9. package/esm/gen/core/ApiResult.js +1 -0
  10. package/esm/gen/core/CancelablePromise.js +130 -0
  11. package/esm/gen/core/OpenAPI.js +41 -0
  12. package/esm/gen/core/request.js +305 -0
  13. package/esm/gen/index.js +6 -0
  14. package/esm/gen/services.gen.js +6782 -0
  15. package/esm/gen/types.gen.js +2 -0
  16. package/esm/hub.js +5 -4
  17. package/esm/instance.js +5 -4
  18. package/esm/main.js +5 -3
  19. package/esm/metadata.js +1 -1
  20. package/esm/resource-type.js +6 -5
  21. package/esm/resource.js +11 -5
  22. package/esm/schedule.js +6 -5
  23. package/esm/script.js +42 -10
  24. package/esm/script_common.js +6 -0
  25. package/esm/settings.js +28 -27
  26. package/esm/sync.js +89 -23
  27. package/esm/types.js +9 -3
  28. package/esm/user.js +27 -27
  29. package/esm/utils.js +7 -0
  30. package/esm/variable.js +7 -6
  31. package/esm/workspace.js +7 -6
  32. package/package.json +1 -2
  33. package/types/apps.d.ts +2 -1
  34. package/types/apps.d.ts.map +1 -1
  35. package/types/bootstrap/script_bootstrap.d.ts +2 -0
  36. package/types/bootstrap/script_bootstrap.d.ts.map +1 -1
  37. package/types/context.d.ts +1 -1
  38. package/types/context.d.ts.map +1 -1
  39. package/types/deps.d.ts +1 -1
  40. package/types/deps.d.ts.map +1 -1
  41. package/types/flow.d.ts +2 -1
  42. package/types/flow.d.ts.map +1 -1
  43. package/types/folder.d.ts +5 -2
  44. package/types/folder.d.ts.map +1 -1
  45. package/types/gen/core/ApiError.d.ts +11 -0
  46. package/types/gen/core/ApiError.d.ts.map +1 -0
  47. package/types/gen/core/ApiRequestOptions.d.ts +15 -0
  48. package/types/gen/core/ApiRequestOptions.d.ts.map +1 -0
  49. package/types/gen/core/ApiResult.d.ts +8 -0
  50. package/types/gen/core/ApiResult.d.ts.map +1 -0
  51. package/types/gen/core/CancelablePromise.d.ts +27 -0
  52. package/types/gen/core/CancelablePromise.d.ts.map +1 -0
  53. package/types/gen/core/OpenAPI.d.ts +28 -0
  54. package/types/gen/core/OpenAPI.d.ts.map +1 -0
  55. package/types/gen/core/request.d.ts +30 -0
  56. package/types/gen/core/request.d.ts.map +1 -0
  57. package/types/gen/index.d.ts +6 -0
  58. package/types/gen/index.d.ts.map +1 -0
  59. package/types/gen/services.gen.d.ts +3339 -0
  60. package/types/gen/services.gen.d.ts.map +1 -0
  61. package/types/gen/types.gen.d.ts +4831 -0
  62. package/types/gen/types.gen.d.ts.map +1 -0
  63. package/types/hub.d.ts.map +1 -1
  64. package/types/instance.d.ts.map +1 -1
  65. package/types/main.d.ts +1 -1
  66. package/types/main.d.ts.map +1 -1
  67. package/types/metadata.d.ts +1 -1
  68. package/types/metadata.d.ts.map +1 -1
  69. package/types/resource-type.d.ts +2 -1
  70. package/types/resource-type.d.ts.map +1 -1
  71. package/types/resource.d.ts +2 -1
  72. package/types/resource.d.ts.map +1 -1
  73. package/types/schedule.d.ts +2 -1
  74. package/types/schedule.d.ts.map +1 -1
  75. package/types/script.d.ts +1 -0
  76. package/types/script.d.ts.map +1 -1
  77. package/types/script_common.d.ts +1 -1
  78. package/types/script_common.d.ts.map +1 -1
  79. package/types/settings.d.ts.map +1 -1
  80. package/types/sync.d.ts +2 -1
  81. package/types/sync.d.ts.map +1 -1
  82. package/types/types.d.ts +1 -1
  83. package/types/types.d.ts.map +1 -1
  84. package/types/user.d.ts.map +1 -1
  85. package/types/utils.d.ts +1 -0
  86. package/types/utils.d.ts.map +1 -1
  87. package/types/variable.d.ts +2 -1
  88. package/types/variable.d.ts.map +1 -1
  89. package/types/workspace.d.ts.map +1 -1
@@ -0,0 +1,2 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ export {};
package/esm/hub.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
- import { Command, ResourceService, SettingService, log } from "./deps.js";
2
+ import { Command, log } from "./deps.js";
3
+ import * as wmill from "./gen/services.gen.js";
3
4
  import { requireLogin, resolveWorkspace } from "./context.js";
4
5
  import { pushResourceType } from "./resource-type.js";
5
6
  import { deepEqual } from "./utils.js";
@@ -10,10 +11,10 @@ export async function pull(opts) {
10
11
  return;
11
12
  }
12
13
  const userInfo = await requireLogin(opts);
13
- const uid = (await SettingService.getGlobal({
14
+ const uid = (await wmill.getGlobal({
14
15
  key: "uid",
15
16
  }));
16
- const hubBaseUrl = (await SettingService.getGlobal({
17
+ const hubBaseUrl = (await wmill.getGlobal({
17
18
  key: "hubBaseUrl",
18
19
  })) ?? "https://hub.windmill.dev";
19
20
  const headers = {
@@ -41,7 +42,7 @@ export async function pull(opts) {
41
42
  .then((x) => x
42
43
  .filter((x) => x)
43
44
  .map((x) => x.resource_type));
44
- const resourceTypes = await ResourceService.listResourceType({
45
+ const resourceTypes = await wmill.listResourceType({
45
46
  workspace: workspace.workspaceId,
46
47
  });
47
48
  for (const x of list) {
package/esm/instance.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as dntShim from "./_dnt.shims.js";
2
- import { Select, WorkspaceService, path, Confirm, yamlStringify, yamlParse, Command, setClient, } from "./deps.js";
2
+ import { Select, path, Confirm, yamlStringify, yamlParse, Command, setClient, } from "./deps.js";
3
+ import * as wmill from "./gen/services.gen.js";
3
4
  import { Input, colors, log } from "./deps.js";
4
5
  import { loginInteractive } from "./login.js";
5
6
  import { getRootStore } from "./store.js";
@@ -170,7 +171,7 @@ async function instancePull(opts) {
170
171
  sleep(1000);
171
172
  if (opts.includeWorkspaces) {
172
173
  log.info("\nPulling all workspaces");
173
- const remoteWorkspaces = await WorkspaceService.listWorkspacesAsSuperAdmin({
174
+ const remoteWorkspaces = await wmill.listWorkspacesAsSuperAdmin({
174
175
  page: 1,
175
176
  perPage: 1000,
176
177
  });
@@ -304,7 +305,7 @@ async function instancePush(opts) {
304
305
  ],
305
306
  default: instance.prefix,
306
307
  }));
307
- const remoteWorkspaces = await WorkspaceService.listWorkspacesAsSuperAdmin({
308
+ const remoteWorkspaces = await wmill.listWorkspacesAsSuperAdmin({
308
309
  page: 1,
309
310
  perPage: 1000,
310
311
  });
@@ -356,7 +357,7 @@ async function instancePush(opts) {
356
357
  });
357
358
  if (confirmDelete) {
358
359
  for (const workspace of workspacesToDelete) {
359
- await WorkspaceService.deleteWorkspace({ workspace: workspace.id });
360
+ await wmill.deleteWorkspace({ workspace: workspace.id });
360
361
  log.info(colors.green.underline("Deleted workspace " + workspace.id));
361
362
  }
362
363
  }
package/esm/main.js CHANGED
@@ -17,7 +17,7 @@ import sync from "./sync.js";
17
17
  import instance from "./instance.js";
18
18
  import dev from "./dev.js";
19
19
  import { fetchVersion } from "./context.js";
20
- import { OpenAPI } from "./deps.js";
20
+ import { OpenAPI } from "./gen/index.js";
21
21
  import { getHeaders } from "./utils.js";
22
22
  import { NpmProvider } from "./upgrade.js";
23
23
  import { pull as hubPull } from "./hub.js";
@@ -30,7 +30,7 @@ export { flow, app, script, workspace, resource, user, variable, hub, folder, sc
30
30
  // console.error(JSON.stringify(event.error, null, 4));
31
31
  // }
32
32
  // });
33
- export const VERSION = "1.396.1";
33
+ export const VERSION = "1.397.3";
34
34
  const command = new Command()
35
35
  .name("wmill")
36
36
  .action(() => log.info(`Welcome to Windmill CLI ${VERSION}. Use -h for help.`))
@@ -142,7 +142,9 @@ function isMain() {
142
142
  if (isDeno) {
143
143
  const isMain = (import.meta.url === ("file:///" + process.argv[1].replace(/\\/g, "/")).replace(/\/{3,}/, "///"));
144
144
  if (isMain) {
145
- log.warn("Using the deno runtime for the Windmill CLI is deprecated, you can now use node: deno uninstall wmill && npm install -g windmill-cli");
145
+ if (!Deno.args.includes("completions")) {
146
+ log.warn("Using the deno runtime for the Windmill CLI is deprecated, you can now use node: deno uninstall wmill && npm install -g windmill-cli");
147
+ }
146
148
  }
147
149
  return isMain;
148
150
  }
package/esm/metadata.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
2
  import * as dntShim from "./_dnt.shims.js";
3
- import { SEP, colors, log, path, yamlParse, yamlStringify, } from "./deps.js";
3
+ import { SEP, colors, log, path, yamlParse, yamlStringify } from "./deps.js";
4
4
  import { defaultScriptMetadata, } from "./bootstrap/script_bootstrap.js";
5
5
  import { instantiate as instantiateWasm, parse_bash, parse_bigquery, parse_deno, parse_go, parse_graphql, parse_mssql, parse_mysql, parse_powershell, parse_python, parse_snowflake, parse_sql, } from "./wasm/windmill_parser_wasm.generated.js";
6
6
  import { inferContentTypeFromFilePath } from "./script_common.js";
@@ -2,11 +2,12 @@
2
2
  import * as dntShim from "./_dnt.shims.js";
3
3
  import { isSuperset, parseFromFile, removeType, } from "./types.js";
4
4
  import { requireLogin, resolveWorkspace } from "./context.js";
5
- import { colors, Command, log, ResourceService, Table, } from "./deps.js";
5
+ import { colors, Command, log, Table } from "./deps.js";
6
+ import * as wmill from "./gen/services.gen.js";
6
7
  export async function pushResourceType(workspace, remotePath, resource, localResource) {
7
8
  remotePath = removeType(remotePath, "resource-type");
8
9
  try {
9
- resource = await ResourceService.getResourceType({
10
+ resource = await wmill.getResourceType({
10
11
  workspace: workspace,
11
12
  path: remotePath,
12
13
  });
@@ -18,7 +19,7 @@ export async function pushResourceType(workspace, remotePath, resource, localRes
18
19
  if (isSuperset(localResource, resource)) {
19
20
  return;
20
21
  }
21
- await ResourceService.updateResourceType({
22
+ await wmill.updateResourceType({
22
23
  workspace: workspace,
23
24
  path: remotePath,
24
25
  requestBody: {
@@ -28,7 +29,7 @@ export async function pushResourceType(workspace, remotePath, resource, localRes
28
29
  }
29
30
  else {
30
31
  log.info(colors.yellow.bold("Creating new resource type..."));
31
- await ResourceService.createResourceType({
32
+ await wmill.createResourceType({
32
33
  workspace: workspace,
33
34
  requestBody: {
34
35
  name: remotePath,
@@ -51,7 +52,7 @@ async function push(opts, filePath, name) {
51
52
  async function list(opts) {
52
53
  const workspace = await resolveWorkspace(opts);
53
54
  await requireLogin(opts);
54
- const res = await ResourceService.listResourceType({
55
+ const res = await wmill.listResourceType({
55
56
  workspace: workspace.workspaceId,
56
57
  });
57
58
  new Table()
package/esm/resource.js CHANGED
@@ -2,11 +2,13 @@
2
2
  import * as dntShim from "./_dnt.shims.js";
3
3
  import { isSuperset, parseFromFile, removeType, } from "./types.js";
4
4
  import { requireLogin, resolveWorkspace, validatePath } from "./context.js";
5
- import { colors, Command, log, ResourceService, SEP, Table, } from "./deps.js";
5
+ import { colors, Command, log, SEP, Table } from "./deps.js";
6
+ import * as wmill from "./gen/services.gen.js";
7
+ import { readInlinePathSync } from "./utils.js";
6
8
  export async function pushResource(workspace, remotePath, resource, localResource) {
7
9
  remotePath = removeType(remotePath, "resource");
8
10
  try {
9
- resource = await ResourceService.getResource({
11
+ resource = await wmill.getResource({
10
12
  workspace: workspace,
11
13
  path: remotePath.replaceAll(SEP, "/"),
12
14
  });
@@ -14,11 +16,15 @@ export async function pushResource(workspace, remotePath, resource, localResourc
14
16
  catch {
15
17
  // flow doesn't exist
16
18
  }
19
+ if (localResource.value["content"]?.startsWith("!inline ")) {
20
+ const basePath = localResource.value["content"].split(" ")[1];
21
+ localResource.value["content"] = readInlinePathSync(basePath);
22
+ }
17
23
  if (resource) {
18
24
  if (isSuperset(localResource, resource)) {
19
25
  return;
20
26
  }
21
- await ResourceService.updateResource({
27
+ await wmill.updateResource({
22
28
  workspace: workspace,
23
29
  path: remotePath.replaceAll(SEP, "/"),
24
30
  requestBody: { ...localResource },
@@ -29,7 +35,7 @@ export async function pushResource(workspace, remotePath, resource, localResourc
29
35
  log.info(colors.yellow("! is_oauth has been removed in newer versions. Ignoring."));
30
36
  }
31
37
  log.info(colors.yellow.bold("Creating new resource..."));
32
- await ResourceService.createResource({
38
+ await wmill.createResource({
33
39
  workspace: workspace,
34
40
  requestBody: {
35
41
  path: remotePath.replaceAll(SEP, "/"),
@@ -59,7 +65,7 @@ async function list(opts) {
59
65
  const perPage = 10;
60
66
  const total = [];
61
67
  while (true) {
62
- const res = await ResourceService.listResource({
68
+ const res = await wmill.listResource({
63
69
  workspace: workspace.workspaceId,
64
70
  page,
65
71
  perPage,
package/esm/schedule.js CHANGED
@@ -1,12 +1,13 @@
1
1
  // deno-lint-ignore-file no-explicit-any
2
2
  import * as dntShim from "./_dnt.shims.js";
3
- import { colors, Command, ScheduleService, log, Table, } from "./deps.js";
3
+ import { colors, Command, log, Table } from "./deps.js";
4
4
  import { requireLogin, resolveWorkspace, validatePath } from "./context.js";
5
+ import * as wmill from "./gen/services.gen.js";
5
6
  import { isSuperset, parseFromFile, removeType, } from "./types.js";
6
7
  async function list(opts) {
7
8
  const workspace = await resolveWorkspace(opts);
8
9
  await requireLogin(opts);
9
- const schedules = await ScheduleService.listSchedules({
10
+ const schedules = await wmill.listSchedules({
10
11
  workspace: workspace.workspaceId,
11
12
  });
12
13
  new Table()
@@ -21,7 +22,7 @@ export async function pushSchedule(workspace, path, schedule, localSchedule) {
21
22
  log.debug(`Processing local schedule ${path}`);
22
23
  // deleting old app if it exists in raw mode
23
24
  try {
24
- schedule = await ScheduleService.getSchedule({ workspace, path });
25
+ schedule = await wmill.getSchedule({ workspace, path });
25
26
  log.debug(`Schedule ${path} exists on remote`);
26
27
  }
27
28
  catch {
@@ -35,7 +36,7 @@ export async function pushSchedule(workspace, path, schedule, localSchedule) {
35
36
  }
36
37
  log.debug(`Schedule ${path} is not up-to-date, updating...`);
37
38
  try {
38
- await ScheduleService.updateSchedule({
39
+ await wmill.updateSchedule({
39
40
  workspace: workspace,
40
41
  path,
41
42
  requestBody: {
@@ -51,7 +52,7 @@ export async function pushSchedule(workspace, path, schedule, localSchedule) {
51
52
  else {
52
53
  console.log(colors.bold.yellow("Creating new schedule: " + path));
53
54
  try {
54
- await ScheduleService.createSchedule({
55
+ await wmill.createSchedule({
55
56
  workspace: workspace,
56
57
  requestBody: {
57
58
  path: path,
package/esm/script.js CHANGED
@@ -2,8 +2,9 @@
2
2
  import * as dntShim from "./_dnt.shims.js";
3
3
  import { showDiff } from "./types.js";
4
4
  import { requireLogin, resolveWorkspace, validatePath } from "./context.js";
5
- import { colors, Command, Confirm, JobService, log, readAll, ScriptService, SEP, Table, writeAllSync, yamlStringify, } from "./deps.js";
5
+ import { colors, Command, Confirm, log, readAll, SEP, Table, writeAllSync, yamlStringify, } from "./deps.js";
6
6
  import { deepEqual } from "./utils.js";
7
+ import * as wmill from "./gen/services.gen.js";
7
8
  import { defaultScriptMetadata, scriptBootstrapCode, } from "./bootstrap/script_bootstrap.js";
8
9
  import { generateScriptMetadataInternal, parseMetadataFile, updateScriptSchema, } from "./metadata.js";
9
10
  import { inferContentTypeFromFilePath, } from "./script_common.js";
@@ -33,6 +34,29 @@ async function push(opts, filePath) {
33
34
  await handleFile(filePath, workspace, [], undefined, opts, globalDeps, codebases);
34
35
  log.info(colors.bold.underline.green(`Script ${filePath} pushed`));
35
36
  }
37
+ export async function findResourceFile(path) {
38
+ const splitPath = path.split(".");
39
+ const contentBasePathJSON = splitPath[0] + "." + splitPath[1] + ".json";
40
+ const contentBasePathYAML = splitPath[0] + "." + splitPath[1] + ".yaml";
41
+ const validCandidates = (await Promise.all([contentBasePathJSON, contentBasePathYAML].map((x) => {
42
+ return dntShim.Deno.stat(x)
43
+ .catch(() => undefined)
44
+ .then((x) => x?.isFile)
45
+ .then((e) => {
46
+ return { path: x, file: e };
47
+ });
48
+ })))
49
+ .filter((x) => x.file)
50
+ .map((x) => x.path);
51
+ if (validCandidates.length > 1) {
52
+ throw new Error("Found two resource files for the same resource" +
53
+ validCandidates.join(", "));
54
+ }
55
+ if (validCandidates.length < 1) {
56
+ throw new Error(`No resource matching file resource: ${path}.`);
57
+ }
58
+ return validCandidates[0];
59
+ }
36
60
  export async function handleScriptMetadata(path, workspace, alreadySynced, message, globalDeps, codebases, opts) {
37
61
  if (path.endsWith(".script.json") ||
38
62
  path.endsWith(".script.yaml") ||
@@ -109,7 +133,7 @@ export async function handleFile(path, workspace, alreadySynced, message, opts,
109
133
  const workspaceId = workspace.workspaceId;
110
134
  let remote = undefined;
111
135
  try {
112
- remote = await ScriptService.getScriptByPath({
136
+ remote = await wmill.getScriptByPath({
113
137
  workspace: workspaceId,
114
138
  path: remotePath,
115
139
  });
@@ -227,7 +251,7 @@ async function createScript(bundleContent, workspaceId, body, workspace) {
227
251
  if (!bundleContent) {
228
252
  try {
229
253
  // no parent hash
230
- await ScriptService.createScript({
254
+ await wmill.createScript({
231
255
  workspace: workspaceId,
232
256
  requestBody: body,
233
257
  });
@@ -334,6 +358,12 @@ export function filePathExtensionFromContentType(language, defaultTs) {
334
358
  else if (language === "php") {
335
359
  return ".php";
336
360
  }
361
+ else if (language === "rust") {
362
+ return ".rs";
363
+ }
364
+ else if (language === "ansible") {
365
+ return ".playbook.yml";
366
+ }
337
367
  else {
338
368
  throw new Error("Invalid language: " + language);
339
369
  }
@@ -355,6 +385,8 @@ export const exts = [
355
385
  ".gql",
356
386
  ".ps1",
357
387
  ".php",
388
+ ".rs",
389
+ ".playbook.yml",
358
390
  ];
359
391
  export function removeExtensionToPath(path) {
360
392
  for (const ext of exts) {
@@ -371,7 +403,7 @@ async function list(opts) {
371
403
  const perPage = 10;
372
404
  const total = [];
373
405
  while (true) {
374
- const res = await ScriptService.listScripts({
406
+ const res = await wmill.listScripts({
375
407
  workspace: workspace.workspaceId,
376
408
  page,
377
409
  perPage,
@@ -414,7 +446,7 @@ async function run(opts, path) {
414
446
  const workspace = await resolveWorkspace(opts);
415
447
  await requireLogin(opts);
416
448
  const input = opts.data ? await resolve(opts.data) : {};
417
- const id = await JobService.runScriptByPath({
449
+ const id = await wmill.runScriptByPath({
418
450
  workspace: workspace.workspaceId,
419
451
  path,
420
452
  requestBody: input,
@@ -424,7 +456,7 @@ async function run(opts, path) {
424
456
  }
425
457
  while (true) {
426
458
  try {
427
- const result = (await JobService.getCompletedJob({
459
+ const result = (await wmill.getCompletedJob({
428
460
  workspace: workspace.workspaceId,
429
461
  id,
430
462
  })).result ?? {};
@@ -443,7 +475,7 @@ async function run(opts, path) {
443
475
  }
444
476
  export async function track_job(workspace, id) {
445
477
  try {
446
- const result = await JobService.getCompletedJob({ workspace, id });
478
+ const result = await wmill.getCompletedJob({ workspace, id });
447
479
  log.info(result.logs);
448
480
  log.info("\n");
449
481
  log.info(colors.bold.underline.green("Job Completed"));
@@ -460,7 +492,7 @@ export async function track_job(workspace, id) {
460
492
  while (true) {
461
493
  let updates;
462
494
  try {
463
- updates = await JobService.getJobUpdates({
495
+ updates = await wmill.getJobUpdates({
464
496
  workspace,
465
497
  id,
466
498
  logOffset,
@@ -494,7 +526,7 @@ export async function track_job(workspace, id) {
494
526
  }
495
527
  await new Promise((resolve, _) => setTimeout(() => resolve(undefined), 1000));
496
528
  try {
497
- const final_job = await JobService.getCompletedJob({ workspace, id });
529
+ const final_job = await wmill.getCompletedJob({ workspace, id });
498
530
  if ((final_job.logs?.length ?? -1) > logOffset) {
499
531
  log.info(final_job.logs.substring(logOffset));
500
532
  }
@@ -514,7 +546,7 @@ export async function track_job(workspace, id) {
514
546
  async function show(opts, path) {
515
547
  const workspace = await resolveWorkspace(opts);
516
548
  await requireLogin(opts);
517
- const s = await ScriptService.getScriptByPath({
549
+ const s = await wmill.getScriptByPath({
518
550
  workspace: workspace.workspaceId,
519
551
  path,
520
552
  });
@@ -44,6 +44,12 @@ export function inferContentTypeFromFilePath(contentPath, defaultTs) {
44
44
  else if (contentPath.endsWith("php")) {
45
45
  return "php";
46
46
  }
47
+ else if (contentPath.endsWith("rs")) {
48
+ return "rust";
49
+ }
50
+ else if (contentPath.endsWith(".playbook.yml")) {
51
+ return "ansible";
52
+ }
47
53
  else {
48
54
  throw new Error("Invalid language: " + contentPath.substring(contentPath.lastIndexOf(".")));
49
55
  }
package/esm/settings.js CHANGED
@@ -1,20 +1,19 @@
1
1
  import * as dntShim from "./_dnt.shims.js";
2
- import { SettingService } from "./deps.js";
3
2
  import { yamlStringify } from "./deps.js";
4
3
  import { Confirm } from "./deps.js";
5
4
  import { colors } from "./deps.js";
6
- import { ConfigService } from "./deps.js";
7
5
  import { yamlParse } from "./deps.js";
8
- import { WorkspaceService, log } from "./deps.js";
6
+ import { log } from "./deps.js";
9
7
  import { compareInstanceObjects } from "./instance.js";
10
8
  import { isSuperset } from "./types.js";
11
9
  import { deepEqual } from "./utils.js";
10
+ import * as wmill from "./gen/services.gen.js";
12
11
  export async function pushWorkspaceSettings(workspace, _path, settings, localSettings) {
13
12
  try {
14
- const remoteSettings = await WorkspaceService.getSettings({
13
+ const remoteSettings = await wmill.getSettings({
15
14
  workspace,
16
15
  });
17
- const workspaceName = await WorkspaceService.getWorkspaceName({
16
+ const workspaceName = await wmill.getWorkspaceName({
18
17
  workspace,
19
18
  });
20
19
  settings = {
@@ -51,7 +50,7 @@ export async function pushWorkspaceSettings(workspace, _path, settings, localSet
51
50
  log.debug(`Workspace settings are not up-to-date, updating...`);
52
51
  if (localSettings.webhook !== settings.webhook) {
53
52
  log.debug(`Updateing webhook...`);
54
- await WorkspaceService.editWebhook({
53
+ await wmill.editWebhook({
55
54
  workspace,
56
55
  requestBody: {
57
56
  webhook: localSettings.webhook,
@@ -69,7 +68,7 @@ export async function pushWorkspaceSettings(workspace, _path, settings, localSet
69
68
  throw new Error(`Invalid value for auto_invite_mode. Valid values are "invite" and "add"`);
70
69
  }
71
70
  try {
72
- await WorkspaceService.editAutoInvite({
71
+ await wmill.editAutoInvite({
73
72
  workspace,
74
73
  requestBody: localSettings.auto_invite_enabled
75
74
  ? {
@@ -83,7 +82,7 @@ export async function pushWorkspaceSettings(workspace, _path, settings, localSet
83
82
  catch (_) {
84
83
  // on cloud
85
84
  log.debug(`Auto invite is not possible on cloud, only auto-inviting same domain...`);
86
- await WorkspaceService.editAutoInvite({
85
+ await wmill.editAutoInvite({
87
86
  workspace,
88
87
  requestBody: localSettings.auto_invite_enabled
89
88
  ? {
@@ -98,7 +97,7 @@ export async function pushWorkspaceSettings(workspace, _path, settings, localSet
98
97
  if (localSettings.openai_resource_path !== settings.openai_resource_path ||
99
98
  localSettings.code_completion_enabled !== settings.code_completion_enabled) {
100
99
  log.debug(`Updating openai settings...`);
101
- await WorkspaceService.editCopilotConfig({
100
+ await wmill.editCopilotConfig({
102
101
  workspace,
103
102
  requestBody: {
104
103
  openai_resource_path: localSettings.openai_resource_path,
@@ -111,7 +110,7 @@ export async function pushWorkspaceSettings(workspace, _path, settings, localSet
111
110
  localSettings.error_handler_muted_on_cancel !==
112
111
  settings.error_handler_muted_on_cancel) {
113
112
  log.debug(`Updating error handler...`);
114
- await WorkspaceService.editErrorHandler({
113
+ await wmill.editErrorHandler({
115
114
  workspace,
116
115
  requestBody: {
117
116
  error_handler: localSettings.error_handler,
@@ -122,7 +121,7 @@ export async function pushWorkspaceSettings(workspace, _path, settings, localSet
122
121
  }
123
122
  if (localSettings.deploy_to !== settings.deploy_to) {
124
123
  log.debug(`Updating deploy to...`);
125
- await WorkspaceService.editDeployTo({
124
+ await wmill.editDeployTo({
126
125
  workspace,
127
126
  requestBody: {
128
127
  deploy_to: localSettings.deploy_to,
@@ -131,7 +130,7 @@ export async function pushWorkspaceSettings(workspace, _path, settings, localSet
131
130
  }
132
131
  if (!deepEqual(localSettings.large_file_storage, settings.large_file_storage)) {
133
132
  log.debug(`Updating large file storage...`);
134
- await WorkspaceService.editLargeFileStorageConfig({
133
+ await wmill.editLargeFileStorageConfig({
135
134
  workspace,
136
135
  requestBody: {
137
136
  large_file_storage: localSettings.large_file_storage,
@@ -140,7 +139,7 @@ export async function pushWorkspaceSettings(workspace, _path, settings, localSet
140
139
  }
141
140
  if (!deepEqual(localSettings.git_sync, settings.git_sync)) {
142
141
  log.debug(`Updating git sync...`);
143
- await WorkspaceService.editWorkspaceGitSyncConfig({
142
+ await wmill.editWorkspaceGitSyncConfig({
144
143
  workspace,
145
144
  requestBody: {
146
145
  git_sync_settings: localSettings.git_sync,
@@ -149,14 +148,14 @@ export async function pushWorkspaceSettings(workspace, _path, settings, localSet
149
148
  }
150
149
  if (!deepEqual(localSettings.default_scripts, settings.default_scripts)) {
151
150
  log.debug(`Updating default scripts...`);
152
- await WorkspaceService.editDefaultScripts({
151
+ await wmill.editDefaultScripts({
153
152
  workspace,
154
153
  requestBody: localSettings.default_scripts,
155
154
  });
156
155
  }
157
156
  if (localSettings.default_app !== settings.default_app) {
158
157
  log.debug(`Updating default app...`);
159
- await WorkspaceService.editWorkspaceDefaultApp({
158
+ await wmill.editWorkspaceDefaultApp({
160
159
  workspace,
161
160
  requestBody: {
162
161
  default_app_path: localSettings.default_app,
@@ -165,7 +164,7 @@ export async function pushWorkspaceSettings(workspace, _path, settings, localSet
165
164
  }
166
165
  if (localSettings.name !== settings.name) {
167
166
  log.debug(`Updating workspace name...`);
168
- await WorkspaceService.changeWorkspaceName({
167
+ await wmill.changeWorkspaceName({
169
168
  workspace,
170
169
  requestBody: {
171
170
  new_name: localSettings.name,
@@ -175,9 +174,11 @@ export async function pushWorkspaceSettings(workspace, _path, settings, localSet
175
174
  }
176
175
  export async function pushWorkspaceKey(workspace, _path, key, localKey) {
177
176
  try {
178
- key = await WorkspaceService.getWorkspaceEncryptionKey({
177
+ key = await wmill
178
+ .getWorkspaceEncryptionKey({
179
179
  workspace,
180
- }).then((r) => r.key);
180
+ })
181
+ .then((r) => r.key);
181
182
  }
182
183
  catch (err) {
183
184
  throw new Error(`Failed to get workspace encryption key: ${err}`);
@@ -188,7 +189,7 @@ export async function pushWorkspaceKey(workspace, _path, key, localKey) {
188
189
  default: true,
189
190
  });
190
191
  log.debug(`Updating workspace encryption key...`);
191
- await WorkspaceService.setWorkspaceEncryptionKey({
192
+ await wmill.setWorkspaceEncryptionKey({
192
193
  workspace,
193
194
  requestBody: {
194
195
  new_key: localKey,
@@ -201,7 +202,7 @@ export async function pushWorkspaceKey(workspace, _path, key, localKey) {
201
202
  }
202
203
  }
203
204
  export async function pullInstanceSettings(preview = false) {
204
- const remoteSettings = await SettingService.listGlobalSettings();
205
+ const remoteSettings = await wmill.listGlobalSettings();
205
206
  if (preview) {
206
207
  let localSettings = [];
207
208
  try {
@@ -217,7 +218,7 @@ export async function pullInstanceSettings(preview = false) {
217
218
  }
218
219
  }
219
220
  export async function pushInstanceSettings(preview = false, baseUrl) {
220
- const remoteSettings = await SettingService.listGlobalSettings();
221
+ const remoteSettings = await wmill.listGlobalSettings();
221
222
  let localSettings = (await dntShim.Deno.readTextFile("instance_settings.yaml")
222
223
  .then((raw) => yamlParse(raw))
223
224
  .catch(() => []));
@@ -239,7 +240,7 @@ export async function pushInstanceSettings(preview = false, baseUrl) {
239
240
  continue;
240
241
  }
241
242
  try {
242
- await SettingService.setGlobal({
243
+ await wmill.setGlobal({
243
244
  key: setting.name,
244
245
  requestBody: {
245
246
  value: setting.value,
@@ -254,7 +255,7 @@ export async function pushInstanceSettings(preview = false, baseUrl) {
254
255
  const localMatch = localSettings.find((s) => s.name === remoteSetting.name);
255
256
  if (!localMatch) {
256
257
  try {
257
- await SettingService.setGlobal({
258
+ await wmill.setGlobal({
258
259
  key: remoteSetting.name,
259
260
  requestBody: {
260
261
  value: null,
@@ -270,7 +271,7 @@ export async function pushInstanceSettings(preview = false, baseUrl) {
270
271
  }
271
272
  }
272
273
  export async function pullInstanceConfigs(preview = false) {
273
- const remoteConfigs = await ConfigService.listConfigs();
274
+ const remoteConfigs = await wmill.listConfigs();
274
275
  if (preview) {
275
276
  let localConfigs = [];
276
277
  try {
@@ -286,7 +287,7 @@ export async function pullInstanceConfigs(preview = false) {
286
287
  }
287
288
  }
288
289
  export async function pushInstanceConfigs(preview = false) {
289
- const remoteConfigs = await ConfigService.listConfigs();
290
+ const remoteConfigs = await wmill.listConfigs();
290
291
  const localConfigs = (await dntShim.Deno.readTextFile("instance_configs.yaml")
291
292
  .then((raw) => yamlParse(raw))
292
293
  .catch(() => []));
@@ -301,7 +302,7 @@ export async function pushInstanceConfigs(preview = false) {
301
302
  continue;
302
303
  }
303
304
  try {
304
- await ConfigService.updateConfig({
305
+ await wmill.updateConfig({
305
306
  name: config.name,
306
307
  requestBody: config.config,
307
308
  });
@@ -314,7 +315,7 @@ export async function pushInstanceConfigs(preview = false) {
314
315
  const localMatch = localConfigs.find((c) => c.name === removeConfig.name);
315
316
  if (!localMatch) {
316
317
  try {
317
- await ConfigService.deleteConfig({
318
+ await wmill.deleteConfig({
318
319
  name: removeConfig.name,
319
320
  });
320
321
  }