@kumori/kdsl 0.0.14 → 0.0.16

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 (171) hide show
  1. package/dist/build/deployment_spec.d.ts +2586 -0
  2. package/dist/build/deployment_spec.js +293 -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 +80 -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 +189 -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 +85 -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 +196 -0
  21. package/dist/build/helpers/service.js.map +1 -0
  22. package/dist/build/helpers/utils.d.ts +30 -0
  23. package/dist/build/helpers/utils.js +77 -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 +188 -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 +71 -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/deployment/gen/deployment-template.kumori +33 -0
  38. package/dist/deployment/gen/main.d.ts +15 -0
  39. package/dist/deployment/gen/main.js +158 -0
  40. package/dist/deployment/gen/main.js.map +1 -0
  41. package/dist/deployment/gen/types.d.ts +27 -0
  42. package/dist/deployment/gen/types.js +2 -0
  43. package/dist/deployment/gen/types.js.map +1 -0
  44. package/dist/deployment/main.d.ts +8 -0
  45. package/dist/deployment/main.js +17 -0
  46. package/dist/deployment/main.js.map +1 -0
  47. package/dist/help/main.d.ts +13 -0
  48. package/dist/help/main.js +49 -0
  49. package/dist/help/main.js.map +1 -0
  50. package/dist/help/topic/build.d.ts +2 -0
  51. package/dist/help/topic/build.js +7 -0
  52. package/dist/help/topic/build.js.map +1 -0
  53. package/dist/help/topic/mod_dep.d.ts +2 -0
  54. package/dist/help/topic/mod_dep.js +8 -0
  55. package/dist/help/topic/mod_dep.js.map +1 -0
  56. package/dist/help/topic/mod_dl.d.ts +2 -0
  57. package/dist/help/topic/mod_dl.js +25 -0
  58. package/dist/help/topic/mod_dl.js.map +1 -0
  59. package/dist/index/create/main.d.ts +14 -0
  60. package/dist/index/create/main.js +286 -0
  61. package/dist/index/create/main.js.map +1 -0
  62. package/dist/index/main.d.ts +8 -0
  63. package/dist/index/main.js +17 -0
  64. package/dist/index/main.js.map +1 -0
  65. package/dist/lib/build.d.ts +42 -0
  66. package/dist/lib/build.js +42 -0
  67. package/dist/lib/build.js.map +1 -0
  68. package/dist/lib/check.d.ts +41 -0
  69. package/dist/lib/check.js +45 -0
  70. package/dist/lib/check.js.map +1 -0
  71. package/dist/lib/clean.d.ts +31 -0
  72. package/dist/lib/clean.js +39 -0
  73. package/dist/lib/clean.js.map +1 -0
  74. package/dist/lib/deployment.d.ts +35 -0
  75. package/dist/lib/deployment.js +31 -0
  76. package/dist/lib/deployment.js.map +1 -0
  77. package/dist/lib/index-cmd.d.ts +54 -0
  78. package/dist/lib/index-cmd.js +60 -0
  79. package/dist/lib/index-cmd.js.map +1 -0
  80. package/dist/lib/index.d.ts +58 -0
  81. package/dist/lib/index.js +54 -0
  82. package/dist/lib/index.js.map +1 -0
  83. package/dist/lib/io/lib.kumori +5 -0
  84. package/dist/lib/kumori/builtin/httpinbound.h.kumori +27 -0
  85. package/dist/lib/kumori/builtin/tcpinbound.h.kumori +25 -0
  86. package/dist/lib/kumori/builtin.kumori +18 -0
  87. package/dist/lib/kumori/component.kumori +120 -0
  88. package/dist/lib/kumori/deployment.kumori +16 -0
  89. package/dist/lib/kumori/resource.kumori +25 -0
  90. package/dist/lib/kumori/service.kumori +49 -0
  91. package/dist/lib/kumori/shared.kumori +11 -0
  92. package/dist/lib/kumori/sized.kumori +25 -0
  93. package/dist/lib/logger.d.ts +10 -0
  94. package/dist/lib/logger.js +23 -0
  95. package/dist/lib/logger.js.map +1 -0
  96. package/dist/lib/mod.d.ts +156 -0
  97. package/dist/lib/mod.js +144 -0
  98. package/dist/lib/mod.js.map +1 -0
  99. package/dist/lib/registry.d.ts +61 -0
  100. package/dist/lib/registry.js +67 -0
  101. package/dist/lib/registry.js.map +1 -0
  102. package/dist/lib/sized.kumori +8 -0
  103. package/dist/lib/std.kumori +8 -0
  104. package/dist/lib/strconv/lib.kumori +11 -0
  105. package/dist/lib/types.d.ts +26 -0
  106. package/dist/lib/types.js +2 -0
  107. package/dist/lib/types.js.map +1 -0
  108. package/dist/main.d.ts +1 -0
  109. package/dist/main.js +37 -0
  110. package/dist/main.js.map +1 -0
  111. package/dist/mod/checksum/main.d.ts +11 -0
  112. package/dist/mod/checksum/main.js +33 -0
  113. package/dist/mod/checksum/main.js.map +1 -0
  114. package/dist/mod/dependency/main.d.ts +19 -0
  115. package/dist/mod/dependency/main.js +163 -0
  116. package/dist/mod/dependency/main.js.map +1 -0
  117. package/dist/mod/download/functions.d.ts +53 -0
  118. package/dist/mod/download/functions.js +235 -0
  119. package/dist/mod/download/functions.js.map +1 -0
  120. package/dist/mod/download/main.d.ts +26 -0
  121. package/dist/mod/download/main.js +99 -0
  122. package/dist/mod/download/main.js.map +1 -0
  123. package/dist/mod/init/main.d.ts +13 -0
  124. package/dist/mod/init/main.js +66 -0
  125. package/dist/mod/init/main.js.map +1 -0
  126. package/dist/mod/jsonschema/gen/main.d.ts +11 -0
  127. package/dist/mod/jsonschema/gen/main.js +288 -0
  128. package/dist/mod/jsonschema/gen/main.js.map +1 -0
  129. package/dist/mod/jsonschema/get/kdslschema.d.ts +28 -0
  130. package/dist/mod/jsonschema/get/kdslschema.js +3 -0
  131. package/dist/mod/jsonschema/get/kdslschema.js.map +1 -0
  132. package/dist/mod/jsonschema/get/main.d.ts +76 -0
  133. package/dist/mod/jsonschema/get/main.js +346 -0
  134. package/dist/mod/jsonschema/get/main.js.map +1 -0
  135. package/dist/mod/jsonschema/main.d.ts +8 -0
  136. package/dist/mod/jsonschema/main.js +20 -0
  137. package/dist/mod/jsonschema/main.js.map +1 -0
  138. package/dist/mod/main.d.ts +8 -0
  139. package/dist/mod/main.js +27 -0
  140. package/dist/mod/main.js.map +1 -0
  141. package/dist/mod/update/main.d.ts +17 -0
  142. package/dist/mod/update/main.js +68 -0
  143. package/dist/mod/update/main.js.map +1 -0
  144. package/dist/registry/add.d.ts +15 -0
  145. package/dist/registry/add.js +58 -0
  146. package/dist/registry/add.js.map +1 -0
  147. package/dist/registry/list.d.ts +15 -0
  148. package/dist/registry/list.js +29 -0
  149. package/dist/registry/list.js.map +1 -0
  150. package/dist/registry/main.d.ts +8 -0
  151. package/dist/registry/main.js +21 -0
  152. package/dist/registry/main.js.map +1 -0
  153. package/dist/registry/remove.d.ts +15 -0
  154. package/dist/registry/remove.js +34 -0
  155. package/dist/registry/remove.js.map +1 -0
  156. package/dist/util/err-format.d.ts +2 -0
  157. package/dist/util/err-format.js +10 -0
  158. package/dist/util/err-format.js.map +1 -0
  159. package/dist/util/err-handler.d.ts +3 -0
  160. package/dist/util/err-handler.js +11 -0
  161. package/dist/util/err-handler.js.map +1 -0
  162. package/dist/util.d.ts +2 -0
  163. package/dist/util.js +2 -0
  164. package/dist/util.js.map +1 -0
  165. package/dist/version.d.ts +2 -0
  166. package/dist/version.js +5 -0
  167. package/dist/version.js.map +1 -0
  168. package/out/deployment/gen/deployment-template.kumori +33 -0
  169. package/out/deployment-template.kumori +33 -0
  170. package/out/main.cjs +378 -209
  171. package/package.json +67 -17
@@ -0,0 +1,188 @@
1
+ import { DeploymentArtifact, isDeploymentArtifact } from "@kumori/kdsl-lsp/language/generated/ast.js";
2
+ import { createKumoriServices } from "@kumori/kdsl-lsp/language/kumori.js";
3
+ import { URI, UriUtils } from "langium";
4
+ import { NodeFileSystem } from "langium/node";
5
+ import { Result, Err, Ok } from "@kumori/kdsl-lsp/util/result.js";
6
+ import { GenerateSolutionResult } from "./solution.js";
7
+ import { ModuleContext } from "@kumori/kdsl-lsp/module/context.js";
8
+ import { ListDependencies } from "@kumori/kdsl-lsp/module/dependency/list.js";
9
+ import assert from "assert";
10
+ import { LocateDependency } from "@kumori/kdsl-lsp/module/dependency/locate.js";
11
+ import { Maybe } from "@kumori/kdsl-lsp/util/maybe.js";
12
+ import { DependencyId } from "@kumori/kdsl-lsp/module/dependency/id.js";
13
+ import path from "node:path";
14
+ import { Check } from "../check/main.js";
15
+ import { promises as nodefs } from "node:fs";
16
+ import { RegistryManager } from "@kumori/kdsl-lsp/module/registry/manager.js";
17
+ import { GetReferencePath } from "./helpers/utils.js";
18
+ export function Register(cmd, log) {
19
+ const c = cmd.command('build')
20
+ .argument('[package]', `package containing the target deployment, defaults to current directory`, '.')
21
+ .argument('[directory]', `directory containing a Kumori module, defaults to current directory`, '.')
22
+ .description(Description)
23
+ .summary(Summary)
24
+ .action(Action(log));
25
+ return c;
26
+ }
27
+ const Summary = `produces deployable artifact specifications`;
28
+ const Description = `
29
+ Generates a solution.json file for a specified Kumori package containing deployment definitions.
30
+ The command requires the path to the package as an argument, and optionally accepts a directory
31
+ path where the Kumori module is located. If the directory is not provided, the current working
32
+ directory is used by default.
33
+
34
+ Some usage examples:
35
+ kdsl build
36
+ kdsl build my-package
37
+ kdsl build my-package path/to/module
38
+
39
+ The generated solution.json file will be created in the package directory, containing all necessary
40
+ information for deploying the resources defined in the package's deployment artifacts.
41
+ `.trim();
42
+ export function Action(log) {
43
+ return async (pkgStr = ".", target = ".") => {
44
+ const manager = new RegistryManager();
45
+ await manager.ensureIndexes();
46
+ const svcs = createKumoriServices(NodeFileSystem).Kumori;
47
+ const result = await BuildImpl(log, svcs, pkgStr, target);
48
+ if (Result.isErr(result)) {
49
+ // Errors already logged by BuildImpl
50
+ process.exit(1);
51
+ }
52
+ };
53
+ }
54
+ /**
55
+ * Build implementation that returns Result instead of exiting.
56
+ * This can be used by both CLI and library.
57
+ */
58
+ export async function BuildImpl(log, svcs, pkgStr, target) {
59
+ const fs = svcs.shared.workspace.FileSystemProvider;
60
+ const ctx = await ModuleContext(fs, URI.file(path.resolve(target)));
61
+ if (Result.isErr(ctx)) {
62
+ const err = `error: ${ctx.err}`;
63
+ log.error(err);
64
+ return Err([err]);
65
+ }
66
+ const locctx = { FS: fs, ...ctx.value };
67
+ const missing = await MissingDependencies(locctx);
68
+ if (missing.size > 0) {
69
+ const errs = [`error: missing modules`];
70
+ log.error(errs[0]);
71
+ for (const mod of missing) {
72
+ const msg = `+ ${mod}`;
73
+ log.error(msg);
74
+ errs.push(msg);
75
+ }
76
+ const finalMsg = `unable to build solution.json`;
77
+ log.error(finalMsg);
78
+ errs.push(finalMsg);
79
+ return Err(errs);
80
+ }
81
+ const checkResult = await Check(log, svcs, ctx.value);
82
+ if (Result.isErr(checkResult)) {
83
+ log.error(`failed to check modules ${checkResult.err.join("\n")}`);
84
+ return checkResult;
85
+ }
86
+ const pkgUri = UriUtils.joinPath(ctx.value.Current.Root, pkgStr);
87
+ const pkg = svcs.references.KumoriPackages.GetPackage(pkgUri);
88
+ if (Result.isErr(pkg)) {
89
+ const err = `error: failed to retrieve package: ${pkgUri.toString()}`;
90
+ log.error(err);
91
+ return Err([err]);
92
+ }
93
+ const pkgUris = new Set(pkg.value.docs.map(p => p.uri.toString()));
94
+ const deployments = svcs.shared.workspace.IndexManager
95
+ .allElements(DeploymentArtifact.$type, pkgUris)
96
+ .toArray();
97
+ if (deployments.length < 1) {
98
+ const err = `error: no deployment defined in ${pkgUri.toString()}`;
99
+ log.error(err);
100
+ return Err([err]);
101
+ }
102
+ if (deployments.length > 1) {
103
+ const err = `error: too many deployments in ${pkgUri.toString()}`;
104
+ log.error(err);
105
+ return Err([err]);
106
+ }
107
+ const description = deployments[0];
108
+ const deployment = description.node;
109
+ if (!isDeploymentArtifact(deployment)) {
110
+ const err = `error: invalid target doc=${description.documentUri} location=${description.path}`;
111
+ log.error(err);
112
+ return Err([err]);
113
+ }
114
+ const solutionResult = GenerateSolutionResult(log, svcs, deployment);
115
+ if (Result.isErr(solutionResult)) {
116
+ return solutionResult;
117
+ }
118
+ const solutionPath = path.join(pkgUri.fsPath, 'solution.json');
119
+ await nodefs.writeFile(solutionPath, solutionResult.value, 'utf-8');
120
+ log.info(`solution.json written to ${solutionPath}`);
121
+ // Generate the config JSON
122
+ // The config JSON is essentially the representation in JSON of the deployment artifact
123
+ const configContent = JSON.parse(solutionResult.value);
124
+ // Find the name of the deployment from the AST. In the manifest, we specified a name, we have to use that.
125
+ // To do that, we look for the StructEntry with key "name" in the deployment.
126
+ const configDeploymentName = deployment.body.stmt.find(s => s.$type === 'StructEntry' && s.key === 'name');
127
+ // This is just for type safety
128
+ assert(configDeploymentName && configDeploymentName.$type === 'StructEntry' && configDeploymentName.value.$type === 'StringLiteralExpression');
129
+ const configDeployment = configContent.deployments[configDeploymentName.value.value];
130
+ // Remove the description and spec fields from the artifact, as it's not needed in deployment-config.json
131
+ if (configDeployment && configDeployment.artifact) {
132
+ delete configDeployment.artifact.description;
133
+ delete configDeployment.artifact.spec;
134
+ }
135
+ // To enable better support for converting back from a JSON config to a deployment artifact,
136
+ // we write additional fields to the artifact.ref section. In particular, we add the package
137
+ // and rewrite the artifact name
138
+ // First, find the artifact declared in the deployment
139
+ const configDeploymentArtifact = deployment.body.stmt.find(s => s.$type === 'StructEntry' && s.key === 'artifact');
140
+ assert(configDeploymentArtifact && configDeploymentArtifact.$type === 'StructEntry');
141
+ assert(configDeploymentArtifact.value.$type === 'IdentifierExpression');
142
+ // Now, the package field needs to contain the route to the artifact within the module
143
+ // and the name of the package, if exists.
144
+ // We would get something like: "kumori.examples/module/path/to/artifact"
145
+ assert(configDeploymentArtifact.value.value.ref);
146
+ const artifactRef = configDeployment.artifact.ref;
147
+ const artifactRefPath = GetReferencePath(artifactRef);
148
+ // We not have the artifact module path. Now, let's find in the deployment's imports
149
+ // the import that matches this module path.
150
+ // We would get something like: "kumori.examples/module/path/to/artifact/service"
151
+ const artifactImport = deployment.$container.imports.find(imp => imp.target.$refText.includes(artifactRefPath))?.target.$refText;
152
+ // Finally, remove the artifact reference path from the artifact import, and we will be left with
153
+ // the actual path within the module.
154
+ // We would be left with just "service" (that's why we add 1 to the substring, to remove the trailing slash)
155
+ const artifactPath = artifactImport?.substring(artifactRefPath.length + 1);
156
+ // Now, set the package and name fields in the configDeployment.artifact.ref
157
+ configDeployment.artifact.ref.package = artifactPath ? artifactPath + "/" + configDeploymentArtifact.value.value.$refText : "";
158
+ if (configDeploymentArtifact.value.next) {
159
+ assert(configDeploymentArtifact.value.next.$type === 'IdentifierExpression');
160
+ configDeployment.artifact.ref.name = configDeploymentArtifact.value.next.value.$refText;
161
+ }
162
+ else {
163
+ configDeployment.artifact.ref.name = configDeploymentArtifact.value.value.$refText;
164
+ }
165
+ const configPath = path.join(pkgUri.fsPath, 'deployment-config.json');
166
+ await nodefs.writeFile(configPath, JSON.stringify(configDeployment, null, 2), 'utf-8');
167
+ log.info(`deployment-config.json written to ${configPath}`);
168
+ return Ok(undefined);
169
+ }
170
+ async function MissingDependencies(ctx, missing = new Set()) {
171
+ const deps = ListDependencies(ctx.Current);
172
+ for (const [, dep] of deps.entriesGroupedByKey()) {
173
+ assert(dep.length > 0);
174
+ const { target, version } = dep[0];
175
+ const descriptor = await LocateDependency(ctx, target, version);
176
+ if (Maybe.isNone(descriptor)) {
177
+ missing.add(DependencyId(target, version));
178
+ continue;
179
+ }
180
+ const mod = await ModuleContext.Move(ctx, ctx.FS, descriptor.value.Root);
181
+ assert(Result.isOk(mod));
182
+ const subctx = { ...ctx, ...mod.value };
183
+ await MissingDependencies(subctx, missing);
184
+ }
185
+ return missing;
186
+ }
187
+ export default { Register };
188
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/build/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AACtG,OAAO,EAAE,oBAAoB,EAAkB,MAAM,qCAAqC,CAAC;AAE3F,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAA4B,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAC1G,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,IAAI,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAA;AAE7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAA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AU;IACzF,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAE1C,KAAK,MAAM,CAAC,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,mBAAmB,EAAE,EAAE,CAAC;QAC/C,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACtB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;QAClC,MAAM,UAAU,GAAG,MAAM,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAC/D,IAAI,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;YAC1C,SAAQ;QACZ,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACxE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;QACxB,MAAM,MAAM,GAAG,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,CAAC,KAAK,EAAE,CAAA;QACvC,MAAM,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;IAED,OAAO,OAAO,CAAA;AAClB,CAAC;AAED,eAAe,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { DeploymentArtifact } from "@kumori/kdsl-lsp/language/generated/ast.js";
2
+ import { KumoriServices } from "@kumori/kdsl-lsp/language/kumori.js";
3
+ import { Result } from "@kumori/kdsl-lsp/util/result.js";
4
+ import { ILogLayer } from "loglayer";
5
+ /**
6
+ * Generate a solution from a deployment artifact.
7
+ * @param deployment - The deployment artifact to process.
8
+ * @returns The generated solution as a JSON string.
9
+ */
10
+ export declare function GenerateSolution(log: ILogLayer, svcs: KumoriServices, deployment: DeploymentArtifact): string;
11
+ /**
12
+ * Generate a solution from a deployment artifact.
13
+ * This version returns a Result instead of calling process.exit().
14
+ *
15
+ * @param log - Logger instance
16
+ * @param svcs - Kumori services
17
+ * @param deployment - The deployment artifact to process
18
+ * @returns Result with the generated solution as a JSON string, or string[] of errors
19
+ */
20
+ export declare function GenerateSolutionResult(log: ILogLayer, svcs: KumoriServices, deployment: DeploymentArtifact): Result<string, string[]>;
@@ -0,0 +1,71 @@
1
+ import { Deployment } from "@kumori/kdsl-lsp/language/builtin/lib/kumori/deployment.js";
2
+ import { toJSON } from "@kumori/kdsl-lsp/language/type-system/toJSON.js";
3
+ import { Result, Err, Ok } from "@kumori/kdsl-lsp/util/result.js";
4
+ import { AstUtils } from "langium";
5
+ import { DeploymentToSolutionJSON } from "./helpers/deployment.js";
6
+ /**
7
+ * Generate a solution from a deployment artifact.
8
+ * @param deployment - The deployment artifact to process.
9
+ * @returns The generated solution as a JSON string.
10
+ */
11
+ export function GenerateSolution(log, svcs, deployment) {
12
+ const result = GenerateSolutionResult(log, svcs, deployment);
13
+ if (Result.isErr(result)) {
14
+ process.exit(1);
15
+ }
16
+ return result.value;
17
+ }
18
+ /**
19
+ * Generate a solution from a deployment artifact.
20
+ * This version returns a Result instead of calling process.exit().
21
+ *
22
+ * @param log - Logger instance
23
+ * @param svcs - Kumori services
24
+ * @param deployment - The deployment artifact to process
25
+ * @returns Result with the generated solution as a JSON string, or string[] of errors
26
+ */
27
+ export function GenerateSolutionResult(log, svcs, deployment) {
28
+ const types = svcs.validation.KumoriTypeSystem;
29
+ const [{ Value: dep }, errs] = types.Eval(svcs.validation.KumoriValidations.ctx(), deployment);
30
+ if (errs.length !== 0) {
31
+ const errorMessages = [];
32
+ for (const err of errs) {
33
+ const node = err.node;
34
+ const doc = AstUtils.getDocument(node);
35
+ const pos = node.$cstNode?.range.start || { line: 0, character: 0 };
36
+ const msg = `${doc.uri.fsPath}:${pos.line}:${pos.character}: type error: ${err.message}`;
37
+ log.error(msg);
38
+ errorMessages.push(msg);
39
+ }
40
+ return Err(errorMessages);
41
+ }
42
+ const nodes = new Map();
43
+ const result = toJSON({ svcs, nodes }, dep);
44
+ if (Result.isErr(result)) {
45
+ const errorMessages = [];
46
+ for (const err of result.err) {
47
+ const node = err.node;
48
+ const doc = AstUtils.getDocument(node);
49
+ const pos = node.$cstNode?.range.start || { line: 0, character: 0 };
50
+ const msg = `${doc.uri.fsPath}:${pos.line}:${pos.character}: json conversion error: ${err.message}`;
51
+ log.error(msg);
52
+ errorMessages.push(msg);
53
+ }
54
+ return Err(errorMessages);
55
+ }
56
+ const parsed = Deployment.safeParse(result.value);
57
+ if (!parsed.success) {
58
+ const errorMessages = [];
59
+ for (const err of parsed.error.issues) {
60
+ const msg = `${err.code}: ${err.path}: invalid deployment: ${err.message}`;
61
+ log.error(msg);
62
+ errorMessages.push(msg);
63
+ }
64
+ return Err(errorMessages);
65
+ }
66
+ // IMPORTANT: Use [result.value as Deployment] instead of [parsed.data] to
67
+ // be able to use the [nodes] Map.
68
+ const solutionJSON = JSON.stringify(DeploymentToSolutionJSON(svcs, nodes, result.value), null, 2);
69
+ return Ok(solutionJSON);
70
+ }
71
+ //# sourceMappingURL=solution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solution.js","sourceRoot":"","sources":["../../src/build/solution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,4DAA4D,CAAA;AAGvF,OAAO,EAAE,MAAM,EAAE,MAAM,iDAAiD,CAAA;AACxE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,EAAW,QAAQ,EAAE,MAAM,SAAS,CAAA;AAG3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAElE;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC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AAyB,GAAG,CAAC,OAAO,EAAE,CAAA;YAC1E,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YACd,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC3B,CAAC;QACD,OAAO,GAAG,CAAC,aAAa,CAAC,CAAA;IAC7B,CAAC;IAED,0EAA0E;IAC1E,6CAA6C;IAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAC/B,wBAAwB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAmB,CAAC,EACjE,IAAI,EACJ,CAAC,CACJ,CAAA;IACD,OAAO,EAAE,CAAC,YAAY,CAAC,CAAA;AAC3B,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { KumoriServices } from "@kumori/kdsl-lsp/language/kumori.js";
2
+ import { Command } from "@commander-js/extra-typings";
3
+ import { CommanderActionParams } from "../util.js";
4
+ import { Result } from "@kumori/kdsl-lsp/util/result.js";
5
+ import { ModuleContext } from "@kumori/kdsl-lsp/module/context.js";
6
+ import { ILogLayer } from "loglayer";
7
+ export declare function Register(cmd: Command, log: ILogLayer): Command<[string | undefined], {}, {}>;
8
+ type Exec = CommanderActionParams<ReturnType<typeof Register>>;
9
+ export declare function Action(log: ILogLayer): Exec;
10
+ /** Performs a validation of the current module. Downloads any required dependencies. */
11
+ export declare const Check: (log: ILogLayer, svcs: KumoriServices, ctx: ModuleContext) => Promise<Result<void, string[]>>;
12
+ type ValidationErrs = {
13
+ errors: string[];
14
+ warnings: string[];
15
+ };
16
+ /** Performs a validation of the current module as is. It does not attempt to download any dependencies. */
17
+ export declare const RawCheck: (svcs: KumoriServices, ctx: ModuleContext) => Promise<Result<void, ValidationErrs>>;
18
+ declare const _default: {
19
+ Register: typeof Register;
20
+ };
21
+ export default _default;
@@ -0,0 +1,99 @@
1
+ import { createKumoriServices, } from "@kumori/kdsl-lsp/language/kumori.js";
2
+ import { URI, UriUtils } from "langium";
3
+ import { NodeFileSystem } from "langium/node";
4
+ import { DiagnosticSeverity } from "vscode-languageserver";
5
+ import { Err, Ok, Result } from "@kumori/kdsl-lsp/util/result.js";
6
+ import { ModuleContext } from "@kumori/kdsl-lsp/module/context.js";
7
+ import { Download } from "../mod/download/main.js";
8
+ import { DefaultErrHandler } from "../util/err-handler.js";
9
+ import path from "node:path";
10
+ import { RegistryManager } from "@kumori/kdsl-lsp/module/registry/manager.js";
11
+ export function Register(cmd, log) {
12
+ const c = cmd
13
+ .command("check")
14
+ .argument("[directory]", `directory containing a Kumori module`)
15
+ .description(Description)
16
+ .summary(Summary)
17
+ .action(Action(log));
18
+ return c;
19
+ }
20
+ const Summary = `typecheck and validate a module`;
21
+ const Description = `
22
+ `.trim();
23
+ export function Action(log) {
24
+ return async (target) => {
25
+ const manager = new RegistryManager();
26
+ await manager.ensureIndexes();
27
+ const svcs = createKumoriServices(NodeFileSystem).Kumori;
28
+ const fs = svcs.shared.workspace.FileSystemProvider;
29
+ const ErrHandler = (v) => DefaultErrHandler(log, v);
30
+ const ctx = ErrHandler(Result.mapErr(await ModuleContext(fs, URI.file(path.resolve(target ?? "."))), (err) => [err]));
31
+ ErrHandler(await Check(log, svcs, ctx));
32
+ };
33
+ }
34
+ /** Performs a validation of the current module. Downloads any required dependencies. */
35
+ export const Check = async (log, svcs, ctx) => {
36
+ const uri = ctx.Current.Root;
37
+ const dl = await Download(log, svcs, uri.fsPath, [], { quiet: true });
38
+ if (Result.isErr(dl)) {
39
+ return dl;
40
+ }
41
+ const valid = await RawCheck(svcs, ctx);
42
+ if (Result.isErr(valid)) {
43
+ const errs = valid.err.warnings.concat(valid.err.errors);
44
+ return Err(errs);
45
+ }
46
+ return Ok(undefined);
47
+ };
48
+ /** Performs a validation of the current module as is. It does not attempt to download any dependencies. */
49
+ export const RawCheck = async (svcs, ctx) => {
50
+ const err = { errors: [], warnings: [] };
51
+ const fs = svcs.shared.workspace.FileSystemProvider;
52
+ const root = ctx.Current.Root;
53
+ const stat = await Result.tryCatchAsync(() => fs.readDirectory(root));
54
+ if (Result.isErr(stat)) {
55
+ let msg = "" + stat.err;
56
+ if (stat.err instanceof Error) {
57
+ msg = stat.err.message;
58
+ }
59
+ err.errors.push(`failed to read directory '${root.fsPath}': ${msg}`);
60
+ return Err(err);
61
+ }
62
+ const ws = svcs.shared.workspace.WorkspaceManager;
63
+ await ws.initializeWorkspace([{ name: "root", uri: root.toString() }]);
64
+ const documents = svcs.shared.workspace.LangiumDocuments;
65
+ const builder = svcs.shared.workspace.DocumentBuilder;
66
+ await builder.build(documents.all.toArray(), { validation: true });
67
+ for (const doc of svcs.shared.workspace.LangiumDocuments.all) {
68
+ for (const e of doc.parseResult.lexerErrors) {
69
+ err.errors.push(LexerError(doc, e));
70
+ }
71
+ for (const e of doc.parseResult.parserErrors) {
72
+ err.errors.push(ParserError(doc, e));
73
+ }
74
+ for (const e of doc.diagnostics || []) {
75
+ const error = DiagnosticError(doc, e);
76
+ if (e.severity === DiagnosticSeverity.Error) {
77
+ err.errors.push(error);
78
+ }
79
+ if (e.severity === DiagnosticSeverity.Warning) {
80
+ err.warnings.push(error);
81
+ }
82
+ }
83
+ }
84
+ if (err.errors.length > 0) {
85
+ return Err(err);
86
+ }
87
+ return Ok(undefined);
88
+ };
89
+ function LexerError(doc, err) {
90
+ return `lexer error: ${UriUtils.relative(process.cwd(), doc.uri.fsPath)}:${err.line || 1}:${err.column || 1}: ${err.message}`;
91
+ }
92
+ function ParserError(doc, err) {
93
+ return `parser error: ${UriUtils.relative(process.cwd(), doc.uri.fsPath)}:${err.token.startLine || 1}:${err.token.startColumn || 1}: ${err.message}`;
94
+ }
95
+ function DiagnosticError(doc, err) {
96
+ return `diagnostic error: ${UriUtils.relative(process.cwd(), doc.uri.fsPath)}:${err.range.start.line + 1}:${err.range.start.character + 1}: ${err.message}`;
97
+ }
98
+ export default { Register };
99
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/check/main.ts"],"names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OAAO,gBAAgB,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,KAAK,GAAG,CAAC,OAAO,EAAE,CAAA;AAC/H,CAAC;AAGD,SAAS,WAAW,CAAC,GAA6B,EAAE,GAAiB;IACnE,OAAO,iBAAiB,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,GAAG,CAAC,OAAO,EAAE,CAAA;AACtJ,CAAC;AAMD,SAAS,eAAe,CACtB,GAA6B,EAC7B,GAAgB;IAEhB,OAAO,qBAAqB,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,KAAK,GAAG,CAAC,OAAO,EAAE,CAAA;AAC7J,CAAC;AAED,eAAe,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { Command } from "@commander-js/extra-typings";
2
+ import { ILogLayer } from "loglayer";
3
+ import { CommanderActionParams } from "../util.js";
4
+ declare const _default: {
5
+ Register: typeof Register;
6
+ };
7
+ export default _default;
8
+ export declare function Register(cmd: Command, log: ILogLayer): Command<[], {}, {}>;
9
+ export declare const Description: string;
10
+ type Exec = CommanderActionParams<ReturnType<typeof Register>>;
11
+ export declare function Action(log: ILogLayer): Exec;
@@ -0,0 +1,26 @@
1
+ import { TempCache } from "@kumori/kdsl-lsp/util/tmp.js";
2
+ import { rm } from "fs/promises";
3
+ export default { Register };
4
+ export function Register(cmd, log) {
5
+ const c = cmd
6
+ .command("clean")
7
+ .summary(Summary)
8
+ .description(Description)
9
+ .action(Action(log));
10
+ return c;
11
+ }
12
+ const Summary = `
13
+ remove cached files
14
+ `.trim();
15
+ export const Description = `
16
+ The kdsl command builds most artifacts in a temporary directory, so kdsl clean is
17
+ mainly concerned with files left by manual invocations of kdsl commands.
18
+ `.trim();
19
+ export function Action(log) {
20
+ return async () => {
21
+ const location = await TempCache();
22
+ log.info(location.fsPath);
23
+ await rm(location.fsPath, { force: true, recursive: true });
24
+ };
25
+ }
26
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/clean/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAIhC,eAAe,EAAE,QAAQ,EAAE,CAAA;AAC3B,MAAM,UAAU,QAAQ,CAAC,GAAY,EAAE,GAAc;IACnD,MAAM,CAAC,GAAG,GAAG;SACV,OAAO,CAAC,OAAO,CAAC;SAChB,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,WAAW,CAAC;SACxB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;IACtB,OAAO,CAAC,CAAA;AACV,CAAC;AAED,MAAM,OAAO,GAAG;;CAEf,CAAC,IAAI,EAAE,CAAA;AACR,MAAM,CAAC,MAAM,WAAW,GAAG;;;CAG1B,CAAC,IAAI,EAAE,CAAA;AAGR,MAAM,UAAU,MAAM,CAAC,GAAc;IACnC,OAAO,KAAK,IAAmB,EAAE;QAC/B,MAAM,QAAQ,GAAG,MAAM,SAAS,EAAE,CAAA;QAClC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QACzB,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7D,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,33 @@
1
+ import (
2
+ {{#each imports}}
3
+ "{{this}}"
4
+ {{/each}}
5
+ )
6
+
7
+ deployment {
8
+ name "{{name}}"
9
+ artifact {{artifact}}
10
+ resilience {{resilience}}
11
+
12
+ config {
13
+ {{#each config}}
14
+ {{this}}
15
+ {{/each}}
16
+ }
17
+
18
+ resource {
19
+ {{#each resources}}
20
+ {{this}}
21
+ {{/each}}
22
+ }
23
+
24
+ {{#if scale}}
25
+ scale {
26
+ {{#each scale}}
27
+ {{this}}
28
+ {{/each}}
29
+ }
30
+ {{else}}
31
+ scale {{scaleValue}}
32
+ {{/if}}
33
+ }
@@ -0,0 +1,15 @@
1
+ import { Result } from "@kumori/kdsl-lsp/util/result.js";
2
+ import { Command } from "@commander-js/extra-typings";
3
+ import { CommanderActionParams } from "../../util.js";
4
+ import { KumoriServices } from "@kumori/kdsl-lsp/language/kumori.js";
5
+ import { ILogLayer } from "loglayer";
6
+ export declare const Description: string;
7
+ declare const _default: {
8
+ Register: typeof Register;
9
+ };
10
+ export default _default;
11
+ export declare function Register(cmd: Command, log: ILogLayer): Command<[string, string], {}, {}>;
12
+ export type Exec = CommanderActionParams<ReturnType<typeof Register>>;
13
+ export type Params = Parameters<Exec>;
14
+ export declare function Action(log: ILogLayer): Exec;
15
+ export declare function GenDeployment(log: ILogLayer, svcs: KumoriServices, input: string, output: string): Promise<Result<void, string[]>>;