@kumori/kdsl 0.0.13 → 0.0.15

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 (163) hide show
  1. package/dist/build/deployment_spec.d.ts +21095 -0
  2. package/dist/build/deployment_spec.js +292 -0
  3. package/dist/build/deployment_spec.js.map +1 -0
  4. package/dist/build/helpers/builtin.d.ts +17 -0
  5. package/dist/build/helpers/builtin.js +82 -0
  6. package/dist/build/helpers/builtin.js.map +1 -0
  7. package/dist/build/helpers/component.d.ts +17 -0
  8. package/dist/build/helpers/component.js +212 -0
  9. package/dist/build/helpers/component.js.map +1 -0
  10. package/dist/build/helpers/connector.d.ts +13 -0
  11. package/dist/build/helpers/connector.js +190 -0
  12. package/dist/build/helpers/connector.js.map +1 -0
  13. package/dist/build/helpers/deployment.d.ts +326 -0
  14. package/dist/build/helpers/deployment.js +86 -0
  15. package/dist/build/helpers/deployment.js.map +1 -0
  16. package/dist/build/helpers/resource.d.ts +97 -0
  17. package/dist/build/helpers/resource.js +54 -0
  18. package/dist/build/helpers/resource.js.map +1 -0
  19. package/dist/build/helpers/service.d.ts +27 -0
  20. package/dist/build/helpers/service.js +199 -0
  21. package/dist/build/helpers/service.js.map +1 -0
  22. package/dist/build/helpers/utils.d.ts +22 -0
  23. package/dist/build/helpers/utils.js +55 -0
  24. package/dist/build/helpers/utils.js.map +1 -0
  25. package/dist/build/main.d.ts +17 -0
  26. package/dist/build/main.js +139 -0
  27. package/dist/build/main.js.map +1 -0
  28. package/dist/build/solution.d.ts +20 -0
  29. package/dist/build/solution.js +72 -0
  30. package/dist/build/solution.js.map +1 -0
  31. package/dist/check/main.d.ts +21 -0
  32. package/dist/check/main.js +99 -0
  33. package/dist/check/main.js.map +1 -0
  34. package/dist/clean/main.d.ts +11 -0
  35. package/dist/clean/main.js +26 -0
  36. package/dist/clean/main.js.map +1 -0
  37. package/dist/help/main.d.ts +13 -0
  38. package/dist/help/main.js +49 -0
  39. package/dist/help/main.js.map +1 -0
  40. package/dist/help/topic/build.d.ts +2 -0
  41. package/dist/help/topic/build.js +7 -0
  42. package/dist/help/topic/build.js.map +1 -0
  43. package/dist/help/topic/mod_dep.d.ts +2 -0
  44. package/dist/help/topic/mod_dep.js +8 -0
  45. package/dist/help/topic/mod_dep.js.map +1 -0
  46. package/dist/help/topic/mod_dl.d.ts +2 -0
  47. package/dist/help/topic/mod_dl.js +25 -0
  48. package/dist/help/topic/mod_dl.js.map +1 -0
  49. package/dist/index/create/main.d.ts +14 -0
  50. package/dist/index/create/main.js +264 -0
  51. package/dist/index/create/main.js.map +1 -0
  52. package/dist/index/main.d.ts +8 -0
  53. package/dist/index/main.js +17 -0
  54. package/dist/index/main.js.map +1 -0
  55. package/dist/lib/build.d.ts +42 -0
  56. package/dist/lib/build.js +28 -0
  57. package/dist/lib/build.js.map +1 -0
  58. package/dist/lib/check.d.ts +41 -0
  59. package/dist/lib/check.js +15 -0
  60. package/dist/lib/check.js.map +1 -0
  61. package/dist/lib/clean.d.ts +31 -0
  62. package/dist/lib/clean.js +1 -0
  63. package/dist/lib/clean.js.map +1 -0
  64. package/dist/lib/index-cmd.d.ts +54 -0
  65. package/dist/lib/index-cmd.js +57 -0
  66. package/dist/lib/index-cmd.js.map +1 -0
  67. package/dist/lib/index.d.ts +56 -0
  68. package/dist/lib/index.js +117 -0
  69. package/dist/lib/index.js.map +1 -0
  70. package/dist/lib/io/lib.kumori +5 -0
  71. package/dist/lib/kumori/builtin/httpinbound.h.kumori +27 -0
  72. package/dist/lib/kumori/builtin/tcpinbound.h.kumori +25 -0
  73. package/dist/lib/kumori/builtin.kumori +18 -0
  74. package/dist/lib/kumori/component.kumori +120 -0
  75. package/dist/lib/kumori/deployment.kumori +16 -0
  76. package/dist/lib/kumori/resource.kumori +25 -0
  77. package/dist/lib/kumori/service.kumori +49 -0
  78. package/dist/lib/kumori/shared.kumori +11 -0
  79. package/dist/lib/kumori/sized.kumori +25 -0
  80. package/dist/lib/logger.d.ts +10 -0
  81. package/dist/lib/logger.js +23 -0
  82. package/dist/lib/logger.js.map +1 -0
  83. package/dist/lib/mod.d.ts +156 -0
  84. package/dist/lib/mod.js +70 -0
  85. package/dist/lib/mod.js.map +1 -0
  86. package/dist/lib/registry.d.ts +61 -0
  87. package/dist/lib/registry.js +1 -0
  88. package/dist/lib/registry.js.map +1 -0
  89. package/dist/lib/sized.kumori +8 -0
  90. package/dist/lib/std.kumori +8 -0
  91. package/dist/lib/strconv/lib.kumori +11 -0
  92. package/dist/lib/types.d.ts +26 -0
  93. package/dist/lib/types.js +2 -0
  94. package/dist/lib/types.js.map +1 -0
  95. package/dist/main.d.ts +1 -0
  96. package/dist/main.js +35 -0
  97. package/dist/main.js.map +1 -0
  98. package/dist/mod/checksum/main.d.ts +11 -0
  99. package/dist/mod/checksum/main.js +33 -0
  100. package/dist/mod/checksum/main.js.map +1 -0
  101. package/dist/mod/dependency/main.d.ts +19 -0
  102. package/dist/mod/dependency/main.js +156 -0
  103. package/dist/mod/dependency/main.js.map +1 -0
  104. package/dist/mod/download/functions.d.ts +53 -0
  105. package/dist/mod/download/functions.js +235 -0
  106. package/dist/mod/download/functions.js.map +1 -0
  107. package/dist/mod/download/main.d.ts +26 -0
  108. package/dist/mod/download/main.js +89 -0
  109. package/dist/mod/download/main.js.map +1 -0
  110. package/dist/mod/init/main.d.ts +13 -0
  111. package/dist/mod/init/main.js +66 -0
  112. package/dist/mod/init/main.js.map +1 -0
  113. package/dist/mod/jsonschema/gen/main.d.ts +11 -0
  114. package/dist/mod/jsonschema/gen/main.js +281 -0
  115. package/dist/mod/jsonschema/gen/main.js.map +1 -0
  116. package/dist/mod/jsonschema/get/kdslschema.d.ts +28 -0
  117. package/dist/mod/jsonschema/get/kdslschema.js +3 -0
  118. package/dist/mod/jsonschema/get/kdslschema.js.map +1 -0
  119. package/dist/mod/jsonschema/get/main.d.ts +76 -0
  120. package/dist/mod/jsonschema/get/main.js +338 -0
  121. package/dist/mod/jsonschema/get/main.js.map +1 -0
  122. package/dist/mod/jsonschema/main.d.ts +8 -0
  123. package/dist/mod/jsonschema/main.js +20 -0
  124. package/dist/mod/jsonschema/main.js.map +1 -0
  125. package/dist/mod/main.d.ts +8 -0
  126. package/dist/mod/main.js +27 -0
  127. package/dist/mod/main.js.map +1 -0
  128. package/dist/mod/update/main.d.ts +17 -0
  129. package/dist/mod/update/main.js +69 -0
  130. package/dist/mod/update/main.js.map +1 -0
  131. package/dist/registry/add.d.ts +15 -0
  132. package/dist/registry/add.js +53 -0
  133. package/dist/registry/add.js.map +1 -0
  134. package/dist/registry/list.d.ts +15 -0
  135. package/dist/registry/list.js +29 -0
  136. package/dist/registry/list.js.map +1 -0
  137. package/dist/registry/main.d.ts +8 -0
  138. package/dist/registry/main.js +21 -0
  139. package/dist/registry/main.js.map +1 -0
  140. package/dist/registry/remove.d.ts +15 -0
  141. package/dist/registry/remove.js +34 -0
  142. package/dist/registry/remove.js.map +1 -0
  143. package/dist/util/err-format.d.ts +2 -0
  144. package/dist/util/err-format.js +11 -0
  145. package/dist/util/err-format.js.map +1 -0
  146. package/dist/util/err-handler.d.ts +3 -0
  147. package/dist/util/err-handler.js +11 -0
  148. package/dist/util/err-handler.js.map +1 -0
  149. package/dist/util.d.ts +2 -0
  150. package/dist/util.js +2 -0
  151. package/dist/util.js.map +1 -0
  152. package/dist/version.d.ts +2 -0
  153. package/dist/version.js +6 -0
  154. package/dist/version.js.map +1 -0
  155. package/out/lib/build.cjs +29 -0
  156. package/out/lib/check.cjs +16 -0
  157. package/out/lib/clean.cjs +2 -0
  158. package/out/lib/index-cmd.cjs +58 -0
  159. package/out/lib/index.cjs +118 -0
  160. package/out/lib/mod.cjs +71 -0
  161. package/out/lib/registry.cjs +2 -0
  162. package/out/main.cjs +172 -172
  163. package/package.json +50 -6
@@ -0,0 +1,89 @@
1
+ import { ModuleContext } from "@kumori/kdsl-lsp/module/context.js";
2
+ import { SumDB } from "@kumori/kdsl-lsp/module/integrity/sumdb.js";
3
+ import { RemoteFetcherFactory } from "@kumori/kdsl-lsp/module/remote/factory.js";
4
+ import { Maybe } from "@kumori/kdsl-lsp/util/maybe.js";
5
+ import { Err, Ok, Result } from "@kumori/kdsl-lsp/util/result.js";
6
+ import { URI } from "langium";
7
+ import { NodeFileSystem } from "langium/node";
8
+ import { createKumoriServices, } from "@kumori/kdsl-lsp/language/kumori.js";
9
+ import { DefaultErrHandler } from "../../util/err-handler.js";
10
+ import { DownloadDependencies, DownloadQueries, } from "./functions.js";
11
+ import { RegistryManager } from "@kumori/kdsl-lsp/module/registry/manager.js";
12
+ export default { Register };
13
+ export function Register(cmd, log) {
14
+ const c = cmd
15
+ .command("download")
16
+ .alias("dl")
17
+ .summary(Summary)
18
+ .argument("[module...]")
19
+ .option("-q, --quiet", "do not log warnings")
20
+ .description(Description)
21
+ .helpOption(true)
22
+ .action(Action(log));
23
+ return c;
24
+ }
25
+ const Summary = `download modules to local cache`;
26
+ export const Description = `
27
+ Downloads the specified modules, which can be module patterns selecting depen-
28
+ dencies of the current module or module queries of the form path@version.
29
+
30
+ With no arguments, download applies to the modules needed to build the packages
31
+ in the current module.
32
+
33
+ The kdsl command will automatically download modules as needed during ordinary
34
+ execution. The "kdsl mod download" command is useful mainly for pre-filling the
35
+ local cache.
36
+
37
+ By default, download writes nothing to standard output. It may print progress
38
+ messages and errors to standard error.
39
+ `.trim();
40
+ export function Action(log) {
41
+ const svcs = createKumoriServices(NodeFileSystem).Kumori;
42
+ const ErrHandler = (v) => DefaultErrHandler(log, v);
43
+ return async (modules, options) => {
44
+ const manager = new RegistryManager();
45
+ await manager.ensureIndexes();
46
+ ErrHandler(await Download(log, svcs, process.cwd(), modules, options));
47
+ };
48
+ }
49
+ export const Download = async (log, svcs, cwd, modules, options) => {
50
+ const fs = svcs.shared.workspace.FileSystemProvider;
51
+ const ctx = await ModuleContext(fs, URI.file(cwd));
52
+ if (Result.isErr(ctx)) {
53
+ return Err([ctx.err]);
54
+ }
55
+ const sums = await SumDB.Open(ctx.value.Locations.Checksum());
56
+ if (Result.isErr(sums)) {
57
+ return Result.mapErr(sums, (e) => [e]);
58
+ }
59
+ let result;
60
+ // If no arguments are provided, it should read from the module manifest.
61
+ if (!modules.length) {
62
+ result = await DownloadDependencies(Object.assign(Object.assign({}, ctx.value), { FS: fs, Remotes: RemoteFetcherFactory(), SumDB: sums.value }));
63
+ }
64
+ else {
65
+ result = await DownloadQueries(Object.assign(Object.assign({}, ctx.value), { FS: fs, Remotes: RemoteFetcherFactory(), SumDB: sums.value }), modules);
66
+ }
67
+ const errs = [];
68
+ for (const [mod, status] of result) {
69
+ if (Result.isOk(status)) {
70
+ if (Maybe.isSome(status.value)) {
71
+ log.info(`Downloaded dependency ${mod}`);
72
+ }
73
+ continue;
74
+ }
75
+ if (status.required) {
76
+ errs.push(`${mod}: ${status.err}`);
77
+ }
78
+ else if (!options.quiet) {
79
+ log.warn(`${mod}: ${status.err}`);
80
+ log.warn(`${mod}: not required - continuing`);
81
+ }
82
+ }
83
+ const failures = Array.from(result.entries()).filter(([, v]) => Result.isErr(v) && v.required);
84
+ if (failures.length > 0) {
85
+ return Err(errs);
86
+ }
87
+ return Ok(undefined);
88
+ };
89
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../src/mod/download/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,4CAA4C,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAA;AACtD,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,EAAsB,GAAG,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,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AM,IAAI,GAAa,EAAE,CAAA;IACzB,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACnC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,GAAG,CAAC,IAAI,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAA;YAC1C,CAAC;YACD,SAAQ;QACV,CAAC;QAED,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC,CAAA;QACpC,CAAC;aAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAC1B,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC,CAAA;YACjC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,6BAA6B,CAAC,CAAA;QAC/C,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAClD,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CACzC,CAAA;IACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,GAAG,CAAC,IAAI,CAAC,CAAA;IAClB,CAAC;IAED,OAAO,EAAE,CAAO,SAAS,CAAC,CAAA;AAC5B,CAAC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { Command } from "@commander-js/extra-typings";
2
+ import { CommanderActionParams } from "../../util.js";
3
+ import { ILogLayer } from "loglayer";
4
+ declare const _default: {
5
+ Register: typeof Register;
6
+ };
7
+ export default _default;
8
+ export declare function Register(cmd: Command, log: ILogLayer): Command<[string, string, string | undefined, string | undefined], {}, {}>;
9
+ export declare const Description: string;
10
+ export type Exec = CommanderActionParams<ReturnType<typeof Register>>;
11
+ export declare function Action(log: ILogLayer): Exec;
12
+ export type Params = Parameters<Exec>;
13
+ export declare const NewModule: (log: ILogLayer, cwd: string, ...[name, version, location, cacheLocation]: Params) => Promise<void>;
@@ -0,0 +1,66 @@
1
+ import { Maybe } from "@kumori/kdsl-lsp/util/maybe.js";
2
+ import { mkdir, writeFile } from "fs/promises";
3
+ import { URI } from "langium";
4
+ import { NodeFileSystem } from "langium/node";
5
+ import { LocateModuleManifest, MOD_FILE, } from "@kumori/kdsl-lsp/module/locator.js";
6
+ import path from "path";
7
+ export default { Register };
8
+ export function Register(cmd, log) {
9
+ const c = cmd
10
+ .command("init")
11
+ .summary(Summary)
12
+ .argument("<name>", "module name (e.g., kumori.systems/my-module)")
13
+ .argument("<version>", "module version - defaults to 0.0.1")
14
+ .argument("[path]", "location to create the module under - defaults to the current directory")
15
+ .argument("[cacheLocation]", "location to store cached modules - default to .kumori/mod")
16
+ .description(Description)
17
+ .helpOption(true)
18
+ .action(Action(log));
19
+ return c;
20
+ }
21
+ const Summary = `initializes a new kumori module`;
22
+ export const Description = `
23
+ Initializes a new Kumori module, which effectively means to create a new
24
+ kumori.mod.json file or overwrite it in case it already exists.
25
+ It is required to provide a name and a version for the module and optionally
26
+ a location path where the new module is going to be initialized.
27
+
28
+ kdsl mod init kumori.systems/my-module
29
+
30
+ You could as well provide a custom location for the module's local cache,
31
+ where all the dependencies will be downloaded. By default, the cache location
32
+ is set to ".kumori/mod" under the module location.
33
+
34
+ kdsl mod init kumori.systems/my-module ./my-module
35
+
36
+ `.trim();
37
+ export function Action(log) {
38
+ return async (...args) => {
39
+ await NewModule(log, process.cwd(), ...args);
40
+ };
41
+ }
42
+ export const NewModule = async (log, cwd, ...[name, version, location, cacheLocation]) => {
43
+ const fs = NodeFileSystem.fileSystemProvider();
44
+ location = location !== null && location !== void 0 ? location : cwd;
45
+ if (!path.isAbsolute(location)) {
46
+ location = path.join(cwd, location);
47
+ }
48
+ const uri = await LocateModuleManifest(fs, URI.file(location));
49
+ if (Maybe.isSome(uri) && uri.value.fsPath === location) {
50
+ log.error(`error: module ${location} already exists`);
51
+ process.exit(1);
52
+ }
53
+ const manifest = {
54
+ spec: "kumori/module/v1",
55
+ kumori: "0.0.1",
56
+ version: version,
57
+ module: name,
58
+ cacheLocation: cacheLocation,
59
+ requires: [],
60
+ };
61
+ const file = path.join(location, MOD_FILE);
62
+ await mkdir(location, { recursive: true });
63
+ await writeFile(file, JSON.stringify(manifest, null, 4));
64
+ log.info(`creating new ${MOD_FILE}: module ${name}`);
65
+ };
66
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../src/mod/init/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAA;AACtD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,EACL,oBAAoB,EACpB,QAAQ,GACT,MAAM,oCAAoC,CAAA;AAC3C,OAAO,IAAI,MAAM,MAAM,CAAA;AAIvB,eAAe,EAAE,QAAQ,EAAE,CAAA;AAC3B,MAAM,UAAU,QAAQ,CAAC,GAAY,EAAE,GAAc;IACnD,MAAM,CAAC,GAAG,GAAG;SACV,OAAO,CAAC,MAAM,CAAC;SACf,OAAO,CAAC,OAAO,CAAC;SAChB,QAAQ,CAAC,QAAQ,EAAE,8CAA8C,CAAC;SAClE,QAAQ,CAAC,WAAW,EAAE,oCAAoC,CAAC;SAC3D,QAAQ,CACP,QAAQ,EACR,yEAAyE,CAC1E;SACA,QAAQ,CACP,iBAAiB,EACjB,2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,CAAC,CAAA;IACjB,CAAC;IAED,MAAM,QAAQ,GAAmB;QAC/B,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,OAAO;QACf,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,IAAI;QACZ,aAAa,EAAE,aAAa;QAC5B,QAAQ,EAAE,EAAE;KACb,CAAA;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAC1C,MAAM,KAAK,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1C,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;IACxD,GAAG,CAAC,IAAI,CAAC,gBAAgB,QAAQ,YAAY,IAAI,EAAE,CAAC,CAAA;AACtD,CAAC,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { ILogLayer } from "loglayer";
2
+ import { CommanderActionParams } from "../../../util.js";
3
+ import { Command } from "@commander-js/extra-typings";
4
+ declare const _default: {
5
+ Register: typeof Register;
6
+ };
7
+ export default _default;
8
+ export declare function Register(cmd: Command, log: ILogLayer): Command<[string, string, string, string, string], {}, {}>;
9
+ export declare const Description: string;
10
+ export type Exec = CommanderActionParams<ReturnType<typeof Register>>;
11
+ export declare function Action(log: ILogLayer): Exec;
@@ -0,0 +1,281 @@
1
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
+ if (value !== null && value !== void 0) {
3
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
+ var dispose, inner;
5
+ if (async) {
6
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
+ dispose = value[Symbol.asyncDispose];
8
+ }
9
+ if (dispose === void 0) {
10
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
+ dispose = value[Symbol.dispose];
12
+ if (async) inner = dispose;
13
+ }
14
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
+ env.stack.push({ value: value, dispose: dispose, async: async });
17
+ }
18
+ else if (async) {
19
+ env.stack.push({ async: true });
20
+ }
21
+ return value;
22
+ };
23
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
+ return function (env) {
25
+ function fail(e) {
26
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
+ env.hasError = true;
28
+ }
29
+ var r, s = 0;
30
+ function next() {
31
+ while (r = env.stack.pop()) {
32
+ try {
33
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
+ if (r.dispose) {
35
+ var result = r.dispose.call(r.value);
36
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
+ }
38
+ else s |= 1;
39
+ }
40
+ catch (e) {
41
+ fail(e);
42
+ }
43
+ }
44
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
+ if (env.hasError) throw env.error;
46
+ }
47
+ return next();
48
+ };
49
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
+ var e = new Error(message);
51
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
+ });
53
+ import Ajv from "ajv";
54
+ import { readFile } from "node:fs/promises";
55
+ import { GetSchema, LocateModule } from "../get/main.js";
56
+ import { DefaultErrHandler } from "../../../util/err-handler.js";
57
+ import { createKumoriServices } from "@kumori/kdsl-lsp/language/kumori.js";
58
+ import { NodeFileSystem } from "langium/node";
59
+ import { Result } from "@kumori/kdsl-lsp/util/result.js";
60
+ import { ModuleContext } from "@kumori/kdsl-lsp/module/context.js";
61
+ import { Check } from "../../../check/main.js";
62
+ import { URI } from "langium";
63
+ import { MkdirTemp } from "@kumori/kdsl-lsp/util/tmp.js";
64
+ import assert from "node:assert";
65
+ import path from "node:path";
66
+ import fs from "node:fs/promises";
67
+ import { MOD_FILE } from "@kumori/kdsl-lsp/module/locator.js";
68
+ import { z } from "zod";
69
+ export default { Register };
70
+ export function Register(cmd, log) {
71
+ const c = cmd
72
+ .command("gen")
73
+ .summary(Summary)
74
+ .description(Description)
75
+ .argument("<target>", `Unique path of the kmodule where the artifact is defined. Accepts remote targets (e.g., "github.com/MyOrg/component@v1.2.3") or local paths (e.g. "/abs/path/to/module", "../rel/path/to/module").`)
76
+ .argument("<package-path>", `Relative path to the package that contains the artifact (e.g., "internal/service"). For artifacts in the module's root package, use ".".`)
77
+ .argument("<artifact-name>", `Name of the target artifact (e.g., "ExampleService").`)
78
+ .argument("<output-module-name>", `Name of the generated module (e.g., "example.com/my-org/module").`)
79
+ .argument("<json>", `Path to JSON file (TODO: use '-' to read from stdin).`)
80
+ .helpOption(true)
81
+ .action(Action(log));
82
+ return c;
83
+ }
84
+ // TODO: flag to build or generate module source files
85
+ const Summary = `generate deployments from an artifact jsonschema`;
86
+ export const Description = `
87
+ Creates a new Kumori DSL module and initializes a deployment definition within
88
+ it, structured according to a provided JSON Schema. This command is designed to
89
+ streamline the creation of new kmodules that consume or instantiate artifacts
90
+ whose configuration and resource requirements are already defined by a schema.
91
+ `.trim();
92
+ export function Action(log) {
93
+ return async (module, pkg, artifact, _outputName, data) => {
94
+ var _a;
95
+ const env_1 = { stack: [], error: void 0, hasError: false };
96
+ try {
97
+ const svcs = createKumoriServices(NodeFileSystem).Kumori;
98
+ const ErrHandler = (v) => DefaultErrHandler(log, v);
99
+ const loc = ErrHandler(await LocateModule(module));
100
+ const _fs = svcs.shared.workspace.FileSystemProvider;
101
+ const ctx = ErrHandler(Result.mapErr(await ModuleContext(_fs, URI.file(loc.fsPath)), (err) => [
102
+ err,
103
+ ]));
104
+ // The module has been located, it has been downloaded and its context
105
+ // initialized. Now, let's download its dependencies.
106
+ ErrHandler(await Check(log, svcs, ctx));
107
+ // The module and its dependencies are now available. Get me the schema!
108
+ const Schema = ErrHandler(await GetSchema(svcs, ctx, pkg, artifact));
109
+ // TODO: interactive user input instead of file
110
+ // Parse the given file as JSON
111
+ const rawData = await readFile(data);
112
+ const Data = JSON.parse(rawData.toString("utf8"));
113
+ // Ajv is a library that will help us validate the incoming JSON file
114
+ // against the requested artifact's JSON Schema
115
+ const ajv = new Ajv({ validateSchema: false, allErrors: true });
116
+ const v = ajv.compile(Schema);
117
+ const result = v(Data);
118
+ if (!result) {
119
+ const errs = (_a = v.errors) !== null && _a !== void 0 ? _a : [];
120
+ errs.sort((a, b) => {
121
+ const schema = a.schemaPath.localeCompare(b.schemaPath);
122
+ if (schema != 0)
123
+ return schema;
124
+ const path = a.dataPath.localeCompare(b.dataPath);
125
+ return path;
126
+ });
127
+ console.log(JSON.stringify(v.errors, null, 4));
128
+ process.exit(1);
129
+ }
130
+ // TODO: if loc.$type is:
131
+ // - local: include the module under vendor
132
+ // - remote: just include the dependency
133
+ const dependency = (() => {
134
+ switch (loc.$type) {
135
+ case "local":
136
+ return { target: ctx.Current.Manifest.module, version: "0.0.0" };
137
+ case "remote":
138
+ return {
139
+ target: ctx.Current.Manifest.module,
140
+ version: loc.query.Version,
141
+ };
142
+ }
143
+ })();
144
+ // We will write everything first in a temporary directory and
145
+ // then move it to the current location
146
+ // Write kumori.mod.json
147
+ const tmp = __addDisposableResource(env_1, await MkdirTemp(), true);
148
+ const manifest = {
149
+ spec: "kumori/module/v1",
150
+ kumori: "0.0.1",
151
+ version: "0.0.1",
152
+ module: _outputName,
153
+ requires: [dependency],
154
+ };
155
+ const manifestFile = path.join(tmp.Path, MOD_FILE);
156
+ await fs.writeFile(manifestFile, JSON.stringify(manifest, null, 4));
157
+ // Write main.kumori
158
+ const imports = [
159
+ { Alias: "ImportAlias0", Path: path.join(dependency.target, pkg) },
160
+ ];
161
+ const deploymentParts = [];
162
+ const indent = 0;
163
+ const write = (str) => deploymentParts.push(str);
164
+ write("deployment {");
165
+ write("\n" + TAB);
166
+ write(`name "${_outputName}"`);
167
+ write("\n" + TAB);
168
+ write(`artifact ImportAlias0.${artifact}`);
169
+ write("\n" + TAB);
170
+ write(`resilience 0`);
171
+ write("\n" + TAB);
172
+ write(KumoriJSONToKumoriSyntax({ imports }, Data, indent + 1));
173
+ write("}\n");
174
+ const deploymentData = [
175
+ "import (\n" +
176
+ imports.map((s) => `${TAB}${s.Alias} "${s.Path}"`).join("\n") +
177
+ "\n)\n\n",
178
+ ]
179
+ .concat(deploymentParts)
180
+ .join("");
181
+ await fs.writeFile(path.join(tmp.Path, "main.kumori"), deploymentData);
182
+ await fs.cp(tmp.Path, ".", { recursive: true });
183
+ }
184
+ catch (e_1) {
185
+ env_1.error = e_1;
186
+ env_1.hasError = true;
187
+ }
188
+ finally {
189
+ const result_1 = __disposeResources(env_1);
190
+ if (result_1)
191
+ await result_1;
192
+ }
193
+ };
194
+ }
195
+ const kdslNamedType = z.object({
196
+ $kdsl: z.object({
197
+ NamedType: z.object({ Import: z.string(), Name: z.string() }),
198
+ }),
199
+ inner: z.any(),
200
+ });
201
+ const TAB = " ";
202
+ /**
203
+ *
204
+ * @param ctx List of imports
205
+ * @param data Input file as JSON
206
+ * @param indent
207
+ * @returns
208
+ */
209
+ function KumoriJSONToKumoriSyntax(ctx, data, indent = 0) {
210
+ const child = Object.assign(Object.assign({}, ctx), { parts: [], skipScope: true });
211
+ KumoriJSONToKumoriSyntaxInternal(child, data, indent);
212
+ return child.parts.join("");
213
+ }
214
+ /**
215
+ * Parses each object and primitive from the input file (as a JSON)
216
+ * and writes the corresponding output in Kumori syntax
217
+ * @param ctx
218
+ * @param data Input file as JSON
219
+ * @param indent
220
+ * @returns
221
+ */
222
+ function KumoriJSONToKumoriSyntaxInternal(ctx, data, indent = 0) {
223
+ const write = (str) => ctx.parts.push(str);
224
+ // Process primitive values
225
+ switch (typeof data) {
226
+ case "number":
227
+ write(data.toString());
228
+ return;
229
+ case "string":
230
+ write(`"${data}"`);
231
+ return;
232
+ case "boolean":
233
+ write(data ? "true" : "false");
234
+ return;
235
+ }
236
+ // Only objects beyond this point
237
+ assert(typeof data === "object");
238
+ assert(data !== null);
239
+ const subCtx = Object.assign(Object.assign({}, ctx), { skipScope: false });
240
+ // Process special object definitions
241
+ const named = kdslNamedType.safeParse(data);
242
+ if (named.success) {
243
+ let existing = ctx.imports.find((imprt) => imprt.Path === named.data.$kdsl.NamedType.Import);
244
+ if (!existing) {
245
+ ctx.imports.push({
246
+ Path: named.data.$kdsl.NamedType.Import,
247
+ Alias: "ImportAlias" + ctx.imports.length,
248
+ });
249
+ }
250
+ existing = ctx.imports.find((imprt) => imprt.Path === named.data.$kdsl.NamedType.Import);
251
+ assert(existing);
252
+ write(`${existing.Alias}.${named.data.$kdsl.NamedType.Name}(`);
253
+ KumoriJSONToKumoriSyntaxInternal(subCtx, named.data.inner, indent);
254
+ write(")");
255
+ return;
256
+ }
257
+ // Process generic objects
258
+ const entries = Object.entries(data);
259
+ if (!ctx.skipScope) {
260
+ write(`{`);
261
+ if (entries.length) {
262
+ write(`\n${TAB.repeat(indent)}`);
263
+ }
264
+ }
265
+ while (entries.length > 0) {
266
+ const [key, value] = entries.pop();
267
+ write(`${key} `);
268
+ KumoriJSONToKumoriSyntaxInternal(subCtx, value, indent + 1);
269
+ if (entries.length) {
270
+ write(`\n${TAB.repeat(indent)}`);
271
+ }
272
+ else {
273
+ write(`\n${TAB.repeat(indent - 1)}`);
274
+ }
275
+ }
276
+ if (!ctx.skipScope) {
277
+ write(`}`);
278
+ }
279
+ return;
280
+ }
281
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../../src/mod/jsonschema/gen/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAErB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAG3C,OAA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MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,CAAA;QAC3D,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,KAAK,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QAClC,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAA;QACtC,CAAC;IACH,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QACnB,KAAK,CAAC,GAAG,CAAC,CAAA;IACZ,CAAC;IACD,OAAM;AACR,CAAC"}
@@ -0,0 +1,28 @@
1
+ export type KDSLSchemaV1 = {
2
+ $schema: "https://json-schema.org/draft/2020-12/schema";
3
+ $spec: "kumori/schema/v1";
4
+ $id: string;
5
+ } & KDSLSchemaV1Item;
6
+ export type KDSLSchemaV1Item = {} | {
7
+ type: "string";
8
+ } | {
9
+ type: "number";
10
+ } | {
11
+ type: "boolean";
12
+ } | {
13
+ type: "null";
14
+ } | {
15
+ type: "array";
16
+ items?: KDSLSchemaV1Item | KDSLSchemaV1Item[];
17
+ } | {
18
+ type: "object";
19
+ properties?: {
20
+ [k: string]: KDSLSchemaV1Item;
21
+ };
22
+ required?: string[];
23
+ additionalProperties?: KDSLSchemaV1Item;
24
+ } | {
25
+ const: string | number | boolean;
26
+ } | {
27
+ oneOf: KDSLSchemaV1Item[];
28
+ };
@@ -0,0 +1,3 @@
1
+ export {};
2
+ // TODO: Include more JSON Schema keywords like enum, anyOf, allOf, as necessary
3
+ //# sourceMappingURL=kdslschema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kdslschema.js","sourceRoot":"","sources":["../../../../src/mod/jsonschema/get/kdslschema.ts"],"names":[],"mappings":";AAgCA,gFAAgF"}
@@ -0,0 +1,76 @@
1
+ import { Command } from "@commander-js/extra-typings";
2
+ import { KumoriServices } from "@kumori/kdsl-lsp/language/kumori.js";
3
+ import { ModuleContext } from "@kumori/kdsl-lsp/module/context.js";
4
+ import { Query } from "@kumori/kdsl-lsp/module/query.js";
5
+ import { Result } from "@kumori/kdsl-lsp/util/result.js";
6
+ import { CommanderActionParams } from "../../../util.js";
7
+ import { ILogLayer } from "loglayer";
8
+ import { AstNodeType, TypeSystemError } from "@kumori/kdsl-lsp/language/type-system/type.js";
9
+ import { KDSLSchemaV1Item, KDSLSchemaV1 } from "./kdslschema.js";
10
+ declare const _default: {
11
+ Register: typeof Register;
12
+ };
13
+ export default _default;
14
+ export declare function Register(cmd: Command, log: ILogLayer): Command<[string, string, string], {}, {}>;
15
+ export declare const Description: string;
16
+ export type Exec = CommanderActionParams<ReturnType<typeof Register>>;
17
+ export declare function Action(log: ILogLayer): Exec;
18
+ /**
19
+ * Unique path of the kmodule where the artifact is defined. Accepts:
20
+ *
21
+ * - Remote targets (e.g., `"github.com/MyOrg/component@v1.2.3"`)
22
+ * - Local paths (e.g. `"/abs/path/to/module"`, `"../rel/path/to/module"`). **Relative paths MUST start with `'.'`**.
23
+ */
24
+ type ModuleNameOrPath = string;
25
+ type LocateModuleResult = LocalModule | RemoteModule;
26
+ type LocalModule = {
27
+ $type: "local";
28
+ fsPath: string;
29
+ };
30
+ type RemoteModule = {
31
+ $type: "remote";
32
+ fsPath: string;
33
+ query: Query;
34
+ };
35
+ /**
36
+ * Find the specified module. If it's not a locally-available module, download it
37
+ * into the global temporary directory
38
+ * @param module
39
+ * @returns Result
40
+ */
41
+ export declare function LocateModule(module: ModuleNameOrPath): Promise<Result<LocateModuleResult, string[]>>;
42
+ /**
43
+ * Given an artifact, returns its JSON Schema representation
44
+ * @param svcs
45
+ * @param ctx
46
+ * @param pkg
47
+ * @param artifact
48
+ * @returns
49
+ */
50
+ export declare function GetSchema(svcs: KumoriServices, ctx: ModuleContext, pkg: string, artifact: string): Promise<Result<KDSLSchemaV1, string[]>>;
51
+ /**
52
+ * Provides the JSON Schema representation of the given artifact
53
+ * @param svcs Kumori Services
54
+ * @param mod The context of the module
55
+ * @param node The artifact, as an AST node
56
+ * @param id Identifier to be used in the schema
57
+ * @returns JSON Schema
58
+ */
59
+ export declare function ToJSONSchema(svcs: KumoriServices, mod: ModuleContext, node: AstNodeType, id: string): Promise<Result<KDSLSchemaV1, TypeSystemError[]>>;
60
+ type ToJSONSchemaInternalCtx = {
61
+ svcs: KumoriServices;
62
+ mod: ModuleContext;
63
+ };
64
+ /**
65
+ * Converts a Kumori AST type node into a JSON Schema fragment (`KDSLSchemaV1Item`).
66
+ *
67
+ * This function recursively traverses the given `AstNodeType` and produces the
68
+ * corresponding JSON Schema representation. Each Kumori type maps to a JSON
69
+ * Schema construct.
70
+ *
71
+ * @param ctx Context providing access to services and the current module
72
+ * @param type The Kumori AST type node to translate
73
+ * @returns A `Result` containing either the JSON Schema fragment
74
+ * or a list of `TypeSystemError` if translation failed
75
+ */
76
+ export declare function ToJSONSchemaInternal(ctx: ToJSONSchemaInternalCtx, type: AstNodeType): Promise<Result<KDSLSchemaV1Item, TypeSystemError[]>>;