@kumori/kdsl 0.0.14 → 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,264 @@
1
+ import { createKumoriServices } from "@kumori/kdsl-lsp/language/kumori.js";
2
+ import { NodeFileSystem } from "langium/node";
3
+ import { ModuleContext } from "@kumori/kdsl-lsp/module/context.js";
4
+ import { URI } from "langium";
5
+ import path from "path";
6
+ import { Result } from "@kumori/kdsl-lsp/util/result.js";
7
+ import { RegistryManager } from "@kumori/kdsl-lsp/module/registry/manager.js";
8
+ import { GatherModuleDocuments } from "@kumori/kdsl-lsp/module/documents.js";
9
+ import { promises as nodefs } from "node:fs";
10
+ import { CalculateChecksum } from "@kumori/kdsl-lsp/module/integrity/checksum.js";
11
+ import { confirm, input } from "@inquirer/prompts";
12
+ import { GetSchema } from "../../mod/jsonschema/get/main.js";
13
+ import { Check } from "../../check/main.js";
14
+ const Summary = `Creates an index file`;
15
+ export const Description = `
16
+ Creates a new index file entry for the current module. Additionally, you can provide
17
+ the location of the module from which generate the entry for.
18
+
19
+ This command will generate the entry for the current module:
20
+ kdsl index create
21
+
22
+ Or you can provide a module location to generate the entry for:
23
+ kdsl index create --module path/to/module
24
+
25
+ The generated index entry will be printed to the standard output. However, you can directly add
26
+ the new entry onto an existing index file by providing the --index option:
27
+ kdsl index create --index path/to/index/file.json
28
+
29
+ If the index file is empty, a new index file will be created with just the new entry. Otherwise,
30
+ if the index file already contains entries, the new entry will be appended to the existing ones.
31
+ `.trim();
32
+ export default { Register };
33
+ export function Register(cmd, log) {
34
+ const c = cmd
35
+ .command("create")
36
+ .option("--module <module>", "Path to the module to generate the index entry for. It can be either a relative or absolute path. Defaults to the current directory.")
37
+ .option("--index <index>", "Path to the index file to append the new entry to. It can be either a relative or absolute path. If not provided, the entry will be printed to standard output.")
38
+ .summary(Summary)
39
+ .description(Description)
40
+ .action(Action(log));
41
+ return c;
42
+ }
43
+ export function Action(log) {
44
+ return async (options) => {
45
+ const svcs = createKumoriServices(NodeFileSystem).Kumori;
46
+ const kumoriFs = svcs.shared.workspace.FileSystemProvider;
47
+ let location = process.cwd();
48
+ if (options.module) {
49
+ const isPath = options.module[0] === "." || path.isAbsolute(options.module);
50
+ if (isPath) {
51
+ // If the path is relative, build an absolute path based on the current working directory
52
+ location = path.isAbsolute(options.module)
53
+ ? options.module
54
+ : path.resolve(process.cwd(), options.module);
55
+ }
56
+ }
57
+ const ctx = await ModuleContext(kumoriFs, URI.file(location));
58
+ if (Result.isErr(ctx)) {
59
+ throw new Error(ctx.err);
60
+ }
61
+ // The module has been located, it has been downloaded and its context
62
+ // initialized. Now, let's download (and check) its dependencies.
63
+ await Check(log, svcs, ctx.value);
64
+ let indexLocation = null;
65
+ if (options.index) {
66
+ const isPath = options.index[0] === "." || path.isAbsolute(options.index);
67
+ if (isPath) {
68
+ // If the path is relative, build an absolute path based on the current working directory
69
+ indexLocation = path.isAbsolute(options.index)
70
+ ? options.index
71
+ : path.resolve(process.cwd(), options.index);
72
+ }
73
+ else {
74
+ indexLocation = path.resolve(process.cwd(), options.index);
75
+ }
76
+ }
77
+ console.log(indexLocation);
78
+ // Read the index file and validate against the JSON Schema
79
+ let parsed = null;
80
+ if (indexLocation) {
81
+ try {
82
+ let data = null;
83
+ try {
84
+ data = await kumoriFs.readFile(URI.file(indexLocation));
85
+ }
86
+ catch (_a) {
87
+ // File does not exist, will create a new one
88
+ data = "";
89
+ }
90
+ if (data === null || data === "") {
91
+ // Empty index file, initialize a new one
92
+ parsed = { modules: [] };
93
+ log.info(`Index file at ${indexLocation} is either missing or empty. A new one will be created.`);
94
+ try {
95
+ await nodefs.mkdir(path.dirname(indexLocation), { recursive: true });
96
+ await nodefs.writeFile(URI.file(indexLocation).fsPath, JSON.stringify(parsed, null, 2));
97
+ log.info(`Created new index file at ${indexLocation}`);
98
+ }
99
+ catch (err) {
100
+ log.error(`Failed to create new index file at ${indexLocation}: ${err}`);
101
+ return;
102
+ }
103
+ }
104
+ try {
105
+ data = await kumoriFs.readFile(URI.file(indexLocation));
106
+ parsed = (await JSON.parse(data));
107
+ }
108
+ catch (e) {
109
+ throw new Error(`Failed to parse index file at ${indexLocation}: ${e}`);
110
+ }
111
+ const manager = new RegistryManager();
112
+ const isValid = manager.validateIndexSchema(parsed);
113
+ if (!isValid) {
114
+ throw new Error(`Index schema validation failed for ${indexLocation}`);
115
+ }
116
+ }
117
+ catch (err) {
118
+ log.error(`Failed to read index file at ${indexLocation}: ${err}`);
119
+ return;
120
+ }
121
+ }
122
+ // Attempt to find the current module in the index file
123
+ let moduleAlreadyInIndex = undefined;
124
+ if (parsed === null || parsed === void 0 ? void 0 : parsed.modules) {
125
+ moduleAlreadyInIndex = parsed.modules.find((m) => m.domain === ctx.value.Current.Manifest.module &&
126
+ m.version === ctx.value.Current.Manifest.version);
127
+ }
128
+ if (moduleAlreadyInIndex) {
129
+ log.warn(`Module ${moduleAlreadyInIndex.domain} version ${moduleAlreadyInIndex.version} already exists in the index file at ${indexLocation}. Proceeding will override the current entry.`);
130
+ const proceed = await confirm({
131
+ message: `Do you want to proceed anyway?`,
132
+ default: false,
133
+ });
134
+ if (!proceed) {
135
+ log.info(`Aborting index entry creation.`);
136
+ return;
137
+ }
138
+ }
139
+ // Gather all module documents
140
+ const moduleDocuments = await GatherModuleDocuments(svcs.shared, ctx.value.Current.Root);
141
+ // First field is the artifact route, then artifact name and type
142
+ // For example: { "services/postgresql.h.kumori": { name: "PostgreSQLService", type: "service" } }
143
+ const artifactNames = {};
144
+ for (const doc of moduleDocuments) {
145
+ const fileName = path.basename(doc.path);
146
+ if (fileName.endsWith(".h.kumori")) {
147
+ // Remove location and filename from the path to get the route
148
+ const route = doc.path.substring(URI.parse(location).fsPath.length);
149
+ const routeWithoutFileName = path.dirname(route);
150
+ const content = await kumoriFs.readFile(doc);
151
+ const lines = content.split("\n");
152
+ for (const line of lines) {
153
+ const serviceMatch = line.match(/service\s+(\w+)/);
154
+ const componentMatch = line.match(/component\s+(\w+)/);
155
+ if (serviceMatch) {
156
+ artifactNames[routeWithoutFileName] = {
157
+ name: serviceMatch[1],
158
+ type: "service",
159
+ };
160
+ }
161
+ else if (componentMatch) {
162
+ artifactNames[routeWithoutFileName] = {
163
+ name: componentMatch[1],
164
+ type: "component",
165
+ };
166
+ }
167
+ }
168
+ }
169
+ }
170
+ const currentManifest = ctx.value.Current.Manifest;
171
+ const checksum = await CalculateChecksum(location);
172
+ // Prompt the user for the module location
173
+ const moduleLocation = await input({
174
+ message: "Enter the module location (remember it has to be a valid Git repository):",
175
+ required: true,
176
+ });
177
+ const moduleEntry = {
178
+ domain: currentManifest.module,
179
+ version: currentManifest.version,
180
+ location: moduleLocation,
181
+ checksum: checksum,
182
+ releaseDate: new Date().toISOString().split("T")[0],
183
+ artifacts: [],
184
+ };
185
+ // For each artifact, create an index entry
186
+ for (const [route, artifact] of Object.entries(artifactNames)) {
187
+ // Ask the user if we want to include this artifact
188
+ const includeArtifact = await confirm({
189
+ message: `Do you want to include artifact ${artifact.name} located at route ${route} in the index?`,
190
+ default: true,
191
+ });
192
+ if (!includeArtifact) {
193
+ continue;
194
+ }
195
+ // Generate the JSON Schema for the given artifact
196
+ const artifactSchema = await GetSchema(svcs, ctx.value, route, artifact.name);
197
+ if (Result.isErr(artifactSchema)) {
198
+ throw new Error(`Failed to generate JSON Schema for artifact ${artifact.name} at route ${route}: ${artifactSchema.err}`);
199
+ }
200
+ // Let's start asking the user for input for this artifact
201
+ const artifactRoute = await input({
202
+ message: `Enter the route for artifact ${artifact.name} (default: ${route}):`,
203
+ default: route,
204
+ required: true,
205
+ });
206
+ const artifactDescription = await input({
207
+ message: `Enter a description for artifact ${artifact.name} (optional):`,
208
+ });
209
+ const publishToMarketPlace = await confirm({
210
+ message: `Do you want to publish artifact ${artifact.name} to the marketplace?`,
211
+ default: true,
212
+ });
213
+ const iconRoute = await input({
214
+ message: `Enter an icon route for artifact ${artifact.name}. This is an optional field and it should be a path to an image file within the artifact route.
215
+ For example, your icon could be located at ${artifactRoute}/icon.png or ${artifactRoute}/img/icon.jpg`,
216
+ });
217
+ const categories = await input({
218
+ message: `Enter categories for artifact ${artifact.name}, separated by commas. For example: utility,network,storage (optional):`,
219
+ }).then((res) => (res ? res.split(",").map((c) => c.trim()) : []));
220
+ const tags = await input({
221
+ message: `Enter tags for artifact ${artifact.name}, separated by commas. For example: sql,database,relational (optional):`,
222
+ }).then((res) => (res ? res.split(",").map((t) => t.trim()) : []));
223
+ moduleEntry.artifacts.push({
224
+ name: artifact.name,
225
+ description: artifactDescription,
226
+ location: artifactRoute,
227
+ type: artifact.type,
228
+ marketplace: publishToMarketPlace,
229
+ schema: artifactSchema.value,
230
+ icon: iconRoute,
231
+ categories: categories,
232
+ tags: tags,
233
+ });
234
+ }
235
+ if (indexLocation && parsed) {
236
+ if (!moduleAlreadyInIndex) {
237
+ parsed.modules.push(moduleEntry);
238
+ const updatedIndex = JSON.stringify(parsed, null, 2);
239
+ await nodefs.writeFile(URI.file(indexLocation).fsPath, updatedIndex);
240
+ log.info(`Appended new module entry to index file at ${indexLocation}`);
241
+ }
242
+ else {
243
+ // Override existing module entry
244
+ parsed.modules = parsed.modules.map((m) => {
245
+ if (m.domain === moduleAlreadyInIndex.domain &&
246
+ m.version === moduleAlreadyInIndex.version) {
247
+ return moduleEntry;
248
+ }
249
+ return m;
250
+ });
251
+ const updatedIndex = JSON.stringify(parsed, null, 2);
252
+ await nodefs.writeFile(URI.file(indexLocation).fsPath, updatedIndex);
253
+ log.info(`Updated module entry in index file at ${indexLocation}`);
254
+ }
255
+ }
256
+ else {
257
+ const newIndex = {
258
+ modules: [moduleEntry],
259
+ };
260
+ console.log(JSON.stringify(newIndex, null, 2));
261
+ }
262
+ };
263
+ }
264
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../../src/index/create/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAG1E,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MA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,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;oBACxC,IACE,CAAC,CAAC,MAAM,KAAK,oBAAoB,CAAC,MAAM;wBACxC,CAAC,CAAC,OAAO,KAAK,oBAAoB,CAAC,OAAO,EAC1C,CAAC;wBACD,OAAO,WAAW,CAAA;oBACpB,CAAC;oBAED,OAAO,CAAC,CAAA;gBACV,CAAC,CAAC,CAAA;gBAEF,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;gBACpD,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;gBACpE,GAAG,CAAC,IAAI,CAAC,yCAAyC,aAAa,EAAE,CAAC,CAAA;YACpE,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,QAAQ,GAAG;gBACf,OAAO,EAAE,CAAC,WAAW,CAAC;aACvB,CAAA;YAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;QAChD,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Command } from "@commander-js/extra-typings";
2
+ import { ILogLayer } from "loglayer";
3
+ declare const _default: {
4
+ Register: typeof Register;
5
+ };
6
+ export default _default;
7
+ export declare function Register(cmd: Command, log: ILogLayer): Command<[], {}, {}>;
8
+ export declare const Description: string;
@@ -0,0 +1,17 @@
1
+ import create from "./create/main.js";
2
+ export default { Register };
3
+ export function Register(cmd, log) {
4
+ const program = cmd
5
+ .command("index")
6
+ .summary(Summary)
7
+ .description(Description)
8
+ .helpCommand(false)
9
+ .helpOption(false);
10
+ create.Register(program, log);
11
+ return program;
12
+ }
13
+ const Summary = `index operations`;
14
+ export const Description = `
15
+ Provides access to operations over indexes.
16
+ `.trim();
17
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/index/main.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,kBAAkB,CAAA;AAErC,eAAe,EAAE,QAAQ,EAAE,CAAA;AAC3B,MAAM,UAAU,QAAQ,CAAC,GAAY,EAAE,GAAc;IACnD,MAAM,OAAO,GAAG,GAAG;SAChB,OAAO,CAAC,OAAO,CAAC;SAChB,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,WAAW,CAAC;SACxB,WAAW,CAAC,KAAK,CAAC;SAClB,UAAU,CAAC,KAAK,CAAC,CAAA;IAEpB,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IAE7B,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,OAAO,GAAG,kBAAkB,CAAA;AAClC,MAAM,CAAC,MAAM,WAAW,GAAG;;CAE1B,CAAC,IAAI,EAAE,CAAA"}
@@ -0,0 +1,42 @@
1
+ import { LibraryOptions, LibraryResult } from "./types.js";
2
+ export interface BuildOptions extends LibraryOptions {
3
+ /**
4
+ * Package containing the target deployment.
5
+ * Defaults to '.' (current directory)
6
+ */
7
+ package?: string;
8
+ /**
9
+ * Directory containing the Kumori module.
10
+ * Defaults to cwd or '.'
11
+ */
12
+ directory?: string;
13
+ }
14
+ /**
15
+ * Produces deployable artifact specifications.
16
+ * Generates a solution.json file for a specified Kumori package.
17
+ *
18
+ * @param options - Build command options
19
+ * @returns Result with void on success, or string[] of errors
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import { createKumoriServices } from '@kumori/kdsl-lsp/language/kumori.js'
24
+ * import { NodeFileSystem } from 'langium/node'
25
+ * import { build } from '@kumori/kdsl'
26
+ *
27
+ * const services = createKumoriServices(NodeFileSystem).Kumori
28
+ *
29
+ * const result = await build({
30
+ * services,
31
+ * package: 'my-package',
32
+ * directory: '.'
33
+ * })
34
+ *
35
+ * if (result.ok) {
36
+ * console.log('Build succeeded!')
37
+ * } else {
38
+ * console.error('Errors:', result.err)
39
+ * }
40
+ * ```
41
+ */
42
+ export declare function build(options: BuildOptions): Promise<LibraryResult<void>>;
@@ -0,0 +1,28 @@
1
+ var Qe=Object.defineProperty,Xe=Object.defineProperties;var Ye=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var Ze=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;var ue=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t);var Y=(t,e,r)=>e in t?Qe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,m=(t,e)=>{for(var r in e||(e={}))Ze.call(e,r)&&Y(t,r,e[r]);if(le)for(var r of le(e))et.call(e,r)&&Y(t,r,e[r]);return t},y=(t,e)=>Xe(t,Ye(e));var M=(t,e,r)=>(Y(t,typeof e!="symbol"?e+"":e,r),r);var ce=(t,e,r)=>{if(e!=null){if(typeof e!="object"&&typeof e!="function")throw TypeError("Object expected");var o;if(r&&(o=e[ue("asyncDispose")]),o===void 0&&(o=e[ue("dispose")]),typeof o!="function")throw TypeError("Object not disposable");t.push([r,o,e])}else r&&t.push([r]);return e},de=(t,e,r)=>{var o=typeof SuppressedError=="function"?SuppressedError:function(s,a,u,c){return c=Error(u),c.name="SuppressedError",c.error=s,c.suppressed=a,c},n=s=>e=r?new o(s,e,"An error was suppressed during disposal"):(r=!0,s),i=s=>{for(;s=t.pop();)try{var a=s[1]&&s[1].call(s[2]);if(s[0])return Promise.resolve(a).then(i,u=>(n(u),i()))}catch(u){n(u)}if(r)throw e};return i()};var T=function(t){return t.info="info",t.warn="warn",t.error="error",t.debug="debug",t.trace="trace",t.fatal="fatal",t}({}),Dr={[T.trace]:10,[T.debug]:20,[T.info]:30,[T.warn]:40,[T.error]:50,[T.fatal]:60},Er={10:T.trace,20:T.debug,30:T.info,40:T.warn,50:T.error,60:T.fatal};var k=function(t){return t.onBeforeDataOut="onBeforeDataOut",t.shouldSendToLogger="shouldSendToLogger",t.onMetadataCalled="onMetadataCalled",t.onBeforeMessageOut="onBeforeMessageOut",t.onContextCalled="onContextCalled",t}({});var v=function(t){return t.info="info",t.warn="warn",t.error="error",t.debug="debug",t.trace="trace",t.fatal="fatal",t}({}),K={[v.trace]:10,[v.debug]:20,[v.info]:30,[v.warn]:40,[v.error]:50,[v.fatal]:60},_r={10:v.trace,20:v.debug,30:v.info,40:v.warn,50:v.error,60:v.fatal};var fe=class me{constructor(){M(this,"context",{});M(this,"hasContext",!1)}setContext(e){if(!e){this.context={},this.hasContext=!1;return}this.context=e,this.hasContext=!0}appendContext(e){this.context=m(m({},this.context),e),this.hasContext=!0}getContext(){return this.context}hasContextData(){return this.hasContext}onChildLoggerCreated({parentContextManager:e,childContextManager:r}){if(e.hasContextData()){let o=e.getContext();r.setContext(m({},o))}}clone(){let e=new me;return e.setContext(m({},this.context)),e.hasContext=this.hasContext,e}};var ge=class{constructor(t){M(this,"err");M(this,"metadata");M(this,"structuredLogger");M(this,"hasMetadata");M(this,"pluginManager");this.err=null,this.metadata={},this.structuredLogger=t,this.hasMetadata=!1,this.pluginManager=t.pluginManager}withMetadata(t){let{pluginManager:e,structuredLogger:{_config:{consoleDebug:r}}}=this;if(!t)return r&&console.debug("[LogLayer] withMetadata was called with no metadata; dropping."),this;let o=t;return e.hasPlugins(k.onMetadataCalled)&&(o=e.runOnMetadataCalled(t,this.structuredLogger),!o)?(r&&console.debug("[LogLayer] Metadata was dropped due to plugin returning falsy value."),this):(this.metadata=m(m({},this.metadata),o),this.hasMetadata=!0,this)}withError(t){return this.err=t,this}info(...t){this.structuredLogger.isLevelEnabled(v.info)&&(this.structuredLogger._formatMessage(t),this.formatLog(v.info,t))}warn(...t){this.structuredLogger.isLevelEnabled(v.warn)&&(this.structuredLogger._formatMessage(t),this.formatLog(v.warn,t))}error(...t){this.structuredLogger.isLevelEnabled(v.error)&&(this.structuredLogger._formatMessage(t),this.formatLog(v.error,t))}debug(...t){this.structuredLogger.isLevelEnabled(v.debug)&&(this.structuredLogger._formatMessage(t),this.formatLog(v.debug,t))}trace(...t){this.structuredLogger.isLevelEnabled(v.trace)&&(this.structuredLogger._formatMessage(t),this.formatLog(v.trace,t))}fatal(...t){this.structuredLogger.isLevelEnabled(v.fatal)&&(this.structuredLogger._formatMessage(t),this.formatLog(v.fatal,t))}disableLogging(){return this.structuredLogger.disableLogging(),this}enableLogging(){return this.structuredLogger.enableLogging(),this}formatLog(t,e){let{muteMetadata:r}=this.structuredLogger._config,o=r?!1:this.hasMetadata;this.structuredLogger._formatLog({logLevel:t,params:e,metadata:o?this.metadata:null,err:this.err})}},tt=[k.onBeforeDataOut,k.onMetadataCalled,k.shouldSendToLogger,k.onBeforeMessageOut,k.onContextCalled],pe=class{constructor(t){M(this,"idToPlugin");M(this,"onBeforeDataOut",[]);M(this,"shouldSendToLogger",[]);M(this,"onMetadataCalled",[]);M(this,"onBeforeMessageOut",[]);M(this,"onContextCalled",[]);this.idToPlugin={},this.mapPlugins(t),this.indexPlugins()}mapPlugins(t){for(let e of t){if(e.id||(e.id=Date.now().toString()+Math.random().toString()),this.idToPlugin[e.id])throw new Error(`[LogLayer] Plugin with id ${e.id} already exists.`);e.registeredAt=Date.now(),this.idToPlugin[e.id]=e}}indexPlugins(){this.onBeforeDataOut=[],this.shouldSendToLogger=[],this.onMetadataCalled=[],this.onBeforeMessageOut=[],this.onContextCalled=[];let t=Object.values(this.idToPlugin).sort((e,r)=>e.registeredAt-r.registeredAt);for(let e of t){if(e.disabled)return;for(let r of tt)e[r]&&e.id&&this[r].push(e.id)}}hasPlugins(t){return this[t].length>0}countPlugins(t){return t?this[t].length:Object.keys(this.idToPlugin).length}addPlugins(t){this.mapPlugins(t),this.indexPlugins()}enablePlugin(t){let e=this.idToPlugin[t];e&&(e.disabled=!1),this.indexPlugins()}disablePlugin(t){let e=this.idToPlugin[t];e&&(e.disabled=!0),this.indexPlugins()}removePlugin(t){delete this.idToPlugin[t],this.indexPlugins()}runOnBeforeDataOut(t,e){let r=m({},t);for(let o of this.onBeforeDataOut){let n=this.idToPlugin[o];if(n.onBeforeDataOut){let i=n.onBeforeDataOut({data:r.data,logLevel:r.logLevel,error:r.error,metadata:r.metadata,context:r.context},e);i&&(r.data||(r.data={}),Object.assign(r.data,i))}}return r.data}runShouldSendToLogger(t,e){return!this.shouldSendToLogger.some(r=>{var o,n;return!((n=(o=this.idToPlugin[r]).shouldSendToLogger)!=null&&n.call(o,t,e))})}runOnMetadataCalled(t,e){var o,n;let r=m({},t);for(let i of this.onMetadataCalled){let s=(n=(o=this.idToPlugin[i]).onMetadataCalled)==null?void 0:n.call(o,r,e);if(s)r=s;else return null}return r}runOnBeforeMessageOut(t,e){var o,n;let r=[...t.messages];for(let i of this.onBeforeMessageOut){let s=(n=(o=this.idToPlugin[i]).onBeforeMessageOut)==null?void 0:n.call(o,{messages:r,logLevel:t.logLevel},e);s&&(r=s)}return r}runOnContextCalled(t,e){var o,n;let r=m({},t);for(let i of this.onContextCalled){let s=(n=(o=this.idToPlugin[i]).onContextCalled)==null?void 0:n.call(o,r,e);if(s)r=s;else return null}return r}},he=class ve{constructor(e){M(this,"pluginManager");M(this,"idToTransport");M(this,"hasMultipleTransports");M(this,"singleTransport");M(this,"contextManager");M(this,"logLevelEnabledStatus",{info:!0,warn:!0,error:!0,debug:!0,trace:!0,fatal:!0});M(this,"_config");var r;this._config=y(m({},e),{enabled:(r=e.enabled)!=null?r:!0}),this._config.enabled||this.disableLogging(),this.contextManager=new fe,this.pluginManager=new pe(e.plugins||[]),this._config.errorFieldName||(this._config.errorFieldName="err"),this._config.copyMsgOnOnlyError||(this._config.copyMsgOnOnlyError=!1),this._initializeTransports(this._config.transport)}withContextManager(e){return this.contextManager&&typeof this.contextManager[Symbol.dispose]=="function"&&this.contextManager[Symbol.dispose](),this.contextManager=e,this}getContextManager(){return this.contextManager}_initializeTransports(e){if(this.idToTransport)for(let r in this.idToTransport)this.idToTransport[r]&&typeof this.idToTransport[r][Symbol.dispose]=="function"&&this.idToTransport[r][Symbol.dispose]();this.hasMultipleTransports=Array.isArray(e)&&e.length>1,this.singleTransport=this.hasMultipleTransports?null:Array.isArray(e)?e[0]:e,Array.isArray(e)?this.idToTransport=e.reduce((r,o)=>(r[o.id]=o,r),{}):this.idToTransport={[e.id]:e}}withPrefix(e){let r=this.child();return r._config.prefix=e,r}withContext(e){let r=e;return e?this.pluginManager.hasPlugins(k.onContextCalled)&&(r=this.pluginManager.runOnContextCalled(e,this),!r)?(this._config.consoleDebug&&console.debug("[LogLayer] Context was dropped due to plugin returning falsy value."),this):(this.contextManager.appendContext(r),this):(this._config.consoleDebug&&console.debug("[LogLayer] withContext was called with no context; dropping."),this)}clearContext(){return this.contextManager.setContext(void 0),this}getContext(){return this.contextManager.getContext()}addPlugins(e){this.pluginManager.addPlugins(e)}enablePlugin(e){this.pluginManager.enablePlugin(e)}disablePlugin(e){this.pluginManager.disablePlugin(e)}removePlugin(e){this.pluginManager.removePlugin(e)}withMetadata(e){return new ge(this).withMetadata(e)}withError(e){return new ge(this).withError(e)}child(){let e=new ve(y(m({},this._config),{transport:Array.isArray(this._config.transport)?[...this._config.transport]:this._config.transport})).withPluginManager(this.pluginManager).withContextManager(this.contextManager.clone());return this.contextManager.onChildLoggerCreated({parentContextManager:this.contextManager,childContextManager:e.contextManager,parentLogger:this,childLogger:e}),e}withFreshTransports(e){return this._config.transport=e,this._initializeTransports(e),this}withFreshPlugins(e){return this._config.plugins=e,this.pluginManager=new pe(e),this}withPluginManager(e){return this.pluginManager=e,this}errorOnly(e,r){let o=(r==null?void 0:r.logLevel)||v.error;if(!this.isLevelEnabled(o))return;let{copyMsgOnOnlyError:n}=this._config,i={logLevel:o,err:e};(n&&(r==null?void 0:r.copyMsg)!==!1||(r==null?void 0:r.copyMsg)===!0)&&(e!=null&&e.message)&&(i.params=[e.message]),this._formatLog(i)}metadataOnly(e,r=v.info){if(!this.isLevelEnabled(r))return;let{muteMetadata:o,consoleDebug:n}=this._config;if(o)return;if(!e){n&&console.debug("[LogLayer] metadataOnly was called with no metadata; dropping.");return}let i=e;if(this.pluginManager.hasPlugins(k.onMetadataCalled)&&(i=this.pluginManager.runOnMetadataCalled(e,this),!i)){n&&console.debug("[LogLayer] Metadata was dropped due to plugin returning falsy value.");return}let s={logLevel:r,metadata:i};this._formatLog(s)}info(...e){this.isLevelEnabled(v.info)&&(this._formatMessage(e),this._formatLog({logLevel:v.info,params:e}))}warn(...e){this.isLevelEnabled(v.warn)&&(this._formatMessage(e),this._formatLog({logLevel:v.warn,params:e}))}error(...e){this.isLevelEnabled(v.error)&&(this._formatMessage(e),this._formatLog({logLevel:v.error,params:e}))}debug(...e){this.isLevelEnabled(v.debug)&&(this._formatMessage(e),this._formatLog({logLevel:v.debug,params:e}))}trace(...e){this.isLevelEnabled(v.trace)&&(this._formatMessage(e),this._formatLog({logLevel:v.trace,params:e}))}fatal(...e){this.isLevelEnabled(v.fatal)&&(this._formatMessage(e),this._formatLog({logLevel:v.fatal,params:e}))}raw(e){if(!this.isLevelEnabled(e.logLevel))return;let r={logLevel:e.logLevel,params:e.messages,metadata:e.metadata,err:e.error,context:e.context};this._formatMessage(e.messages),this._formatLog(r)}disableLogging(){for(let e of Object.keys(this.logLevelEnabledStatus))this.logLevelEnabledStatus[e]=!1;return this}enableLogging(){for(let e of Object.keys(this.logLevelEnabledStatus))this.logLevelEnabledStatus[e]=!0;return this}muteContext(){return this._config.muteContext=!0,this}unMuteContext(){return this._config.muteContext=!1,this}muteMetadata(){return this._config.muteMetadata=!0,this}unMuteMetadata(){return this._config.muteMetadata=!1,this}enableIndividualLevel(e){let r=e;return r in this.logLevelEnabledStatus&&(this.logLevelEnabledStatus[r]=!0),this}disableIndividualLevel(e){let r=e;return r in this.logLevelEnabledStatus&&(this.logLevelEnabledStatus[r]=!1),this}setLevel(e){let r=K[e];for(let o of Object.values(v)){let n=o,i=K[o];this.logLevelEnabledStatus[n]=i>=r}return this}isLevelEnabled(e){let r=e;return this.logLevelEnabledStatus[r]}formatContext(e){let{contextFieldName:r,muteContext:o}=this._config;return e&&Object.keys(e).length>0&&!o?r?{[r]:m({},e)}:m({},e):{}}formatMetadata(e=null){let{metadataFieldName:r,muteMetadata:o}=this._config;return e&&!o?r?{[r]:m({},e)}:m({},e):{}}getLoggerInstance(e){let r=this.idToTransport[e];if(r)return r.getLoggerInstance()}_formatMessage(e=[]){let{prefix:r}=this._config;r&&typeof e[0]=="string"&&(e[0]=`${r} ${e[0]}`)}_formatLog({logLevel:e,params:r=[],metadata:o=null,err:n,context:i=null}){var b;let{errorSerializer:s,errorFieldInMetadata:a,muteContext:u,contextFieldName:c,metadataFieldName:d,errorFieldName:l}=this._config,g=i!==null?i:this.contextManager.getContext(),h=!!o||(u?!1:i!==null?Object.keys(i).length>0:this.contextManager.hasContextData()),p={};if(h)if(c&&c===d){let w=this.formatContext(g)[c],f=this.formatMetadata(o)[d];p={[c]:m(m({},w),f)}}else p=m(m({},this.formatContext(g)),this.formatMetadata(o));if(n){let w=s?s(n):n;a&&o&&d?p!=null&&p[d]?p[d][l]=w:p=y(m({},p),{[d]:{[l]:w}}):a&&!o&&d?p=y(m({},p),{[d]:{[l]:w}}):p=y(m({},p),{[l]:w}),h=!0}if(this.pluginManager.hasPlugins(k.onBeforeDataOut)&&(p=this.pluginManager.runOnBeforeDataOut({data:h?p:void 0,logLevel:e,error:n,metadata:o,context:g},this),p&&!h&&(h=!0)),this.pluginManager.hasPlugins(k.onBeforeMessageOut)&&(r=this.pluginManager.runOnBeforeMessageOut({messages:[...r],logLevel:e},this)),this.hasMultipleTransports){let w=this._config.transport.filter(f=>f.enabled).map(async f=>{if(!(this.pluginManager.hasPlugins(k.shouldSendToLogger)&&!this.pluginManager.runShouldSendToLogger({messages:[...r],data:h?p:void 0,logLevel:e,transportId:f.id,error:n,metadata:o,context:g},this)))return f._sendToLogger({logLevel:e,messages:[...r],data:h?p:void 0,hasData:h,error:n,metadata:o,context:g})});Promise.all(w).catch(f=>{this._config.consoleDebug&&console.error("[LogLayer] Error executing transports:",f)})}else{if(!((b=this.singleTransport)!=null&&b.enabled)||this.pluginManager.hasPlugins(k.shouldSendToLogger)&&!this.pluginManager.runShouldSendToLogger({messages:[...r],data:h?p:void 0,logLevel:e,transportId:this.singleTransport.id,error:n,metadata:o,context:g},this))return;this.singleTransport._sendToLogger({logLevel:e,messages:[...r],data:h?p:void 0,hasData:h,error:n,metadata:o,context:g})}}};function rt(){let t={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}};return new he({transport:t})}function Se(t){return t!=null?t:rt()}import{RegistryManager as Or}from"@kumori/kdsl-lsp/module/registry/manager.js";import{DeploymentArtifact as hr,isDeploymentArtifact as vr}from"@kumori/kdsl-lsp/language/generated/ast.js";import{createKumoriServices as ci}from"@kumori/kdsl-lsp/language/kumori.js";import{URI as Sr,UriUtils as yr}from"langium";import{NodeFileSystem as gi}from"langium/node";import{Result as q,Err as I,Ok as br}from"@kumori/kdsl-lsp/util/result.js";import{Deployment as Jt}from"@kumori/kdsl-lsp/language/builtin/lib/kumori/deployment.js";import{toJSON as Kt}from"@kumori/kdsl-lsp/language/type-system/toJSON.js";import{Result as zt,Err as oe,Ok as Vt}from"@kumori/kdsl-lsp/util/result.js";import{AstUtils as ke}from"langium";import{ToUnits as Dt}from"@kumori/kdsl-lsp/util/sized.js";import{EphemeralName as ot,Ephemeral as nt,PersistentName as it,Persistent as st,RegisteredName as at,Registered as lt,VolatileName as ut,Volatile as ct,PersistedName as dt,Persisted as ft,NonReplicatedName as mt,NonReplicated as gt,CAName as pt,CA as ht,CertificateName as vt,SecretName as St,Secret as yt,DomainName as bt,PortName as wt,Port as Lt,Domain as Ct,Certificate as Mt}from"@kumori/kdsl-lsp/language/builtin/lib/kumori/resource.js";function _(t){if(t.$type===ot){let e=nt.parse(t);return{volume:{size:e.value.size,unit:e.value.unit,kind:"storage"}}}if(t.$type===it)return{volume:st.parse(t).value};if(t.$type===at)return{volume:lt.parse(t).value};if(t.$type===ut){let e=ct.parse(t);return{volume:{size:e.value.size,unit:e.value.unit,kind:"storage",type:"volatile"}}}if(t.$type===dt){let e=ft.parse(t);return{volume:{size:e.value.size,unit:e.value.unit,kind:"storage",type:"persistent"}}}if(t.$type===mt){let e=gt.parse(t);return{volume:{size:e.value.size,unit:e.value.unit,kind:"storage",type:"nonreplicated"}}}if(t.$type===pt)return{ca:ht.parse(t).value};if(t.$type===vt)return{certificate:Mt.parse(t).value};if(t.$type===St)return{secret:yt.parse(t).value};if(t.$type===bt)return{domain:Ct.parse(t).value};if(t.$type===wt)return{port:Lt.parse(t).value};throw new Error(`unknown resource type '${t.$type}'`)}import{ParseOCIString as xt}from"@kumori/kdsl-lsp/util/oci.js";import{Result as z}from"@kumori/kdsl-lsp/util/result.js";import{AstUtils as Ot}from"langium";import{basename as kt}from"path";function ye(t){return typeof t=="string"?z.orElse(z.map(xt(t),e=>{var r,o;return{tag:e.tag,hub:{name:e.hub,secret:typeof t=="string"?"":(o=(r=t.hub)==null?void 0:r.secret)!=null?o:""}}}),e=>{throw new Error(e)}):t}function F(t,e){if(!e)return[];let r=Ot.getDocument(e).uri,o=t.getModule(r);if(z.isErr(o))return[];let n=z.tryCatch(()=>new URL(`file://${o.value.Manifest.module}`));if(z.isErr(n))return[];let i=[];return n.value.hostname.length&&i.push(s=>s.domain=n.value.hostname),n.value.pathname.length&&i.push(s=>{s.module=n.value.pathname.replace(/^\//,""),s.name=kt(s.module)}),i}import{isComponentArtifact as Et}from"@kumori/kdsl-lsp/language/generated/ast.js";function be(t,e){let r={version:[0,0,0],kind:"service",domain:"unknown",module:"unknown",name:"unknown"},o=t.svcs.shared.references.KumoriModules,n=F(o,t.nodes.get(e));for(let a of n)a(r);let i=t.nodes.get(e),s="";if(i&&Et(i)&&(s=i.name.value.$refText),s==="")throw new Error("Unable to determine component name for service artifact conversion.");return{spec:[1,0],ref:r,description:{builtin:!1,connector:{},config:{resilience:0,scale:{},parameter:{},resource:{}},role:{[s]:{name:s,meta:{},artifact:Z(t,e)}}}}}function Z(t,e){var c,d,l,g,h,p,b,w,f,L;let r={version:[0,0,0],kind:"component",domain:"unknown",module:"unknown",name:"unknown"},o=t.svcs.shared.references.KumoriModules,n=F(o,t.nodes.get(e));for(let S of n)S(r);function i(S,C=!1){return Object.fromEntries(Object.entries(S!=null?S:{}).map(([D,E])=>{var J,P;return[D,{name:D,init:C,entrypoint:E.entrypoint,image:ye(E.image),cmd:E.cmd,size:{memory:y(m({},E.size.memory),{kind:"ram"}),cpu:y(m({},E.size.cpu),{kind:"cpu"}),mincpu:E.size.mincpu?E.size.mincpu.size:E.size.cpu.size},mapping:{filesystem:Object.fromEntries(Object.entries((J=E.fs)!=null?J:{}).map(([x,O])=>[x,Pt(x,O)])),env:Object.fromEntries(Object.entries((P=E.env)!=null?P:{}).map(([x,O])=>{let R=x,He=typeof O=="string"||typeof O=="number"||typeof O=="boolean"?{value:String(O)}:O;return[R,He]}))}}]}))}let s=Object.fromEntries(((c=e.init)!=null?c:[]).map((S,C)=>[`INIT_${C}`,S])),a=i(e.code),u=i(s,!0);return{spec:[1,0],ref:r,description:{builtin:!1,config:{resilience:0,scale:{hsize:1},parameter:e.config,resource:Object.fromEntries(Object.entries((d=e.resource)!=null?d:{}).map(([S,C])=>[S,_(C)]))},size:{bandwidth:y(m({},e.size.bandwidth),{kind:"bandwidth"}),minbandwidth:Math.ceil(Dt((l=e.size.minbandwidth)!=null?l:e.size.bandwidth,e.size.bandwidth.unit).size),mincpu:y(m({},e.size.mincpu),{kind:"cpu"})},profile:{threadability:"*",iopsintensive:!1},srv:{client:Object.fromEntries(Object.entries((h=(g=e.srv)==null?void 0:g.client)!=null?h:{}).map(([S,C])=>[S,{protocol:C,inherited:!1}])),server:Object.fromEntries(Object.entries((b=(p=e.srv)==null?void 0:p.server)!=null?b:{}).map(([S,C])=>{let D;return typeof C=="string"?D={port:80,portnum:1,inherited:!1,protocol:C}:D=y(m({},C),{portnum:1,inherited:!1}),[S,D]})),duplex:Object.fromEntries(Object.entries((f=(w=e.srv)==null?void 0:w.duplex)!=null?f:{}).map(([S,C])=>{let D;return typeof C=="string"?D={port:80,portnum:1,inherited:!1,protocol:C}:D=y(m({},C),{portnum:1,inherited:!1}),[S,D]}))},code:m(m({},u),a),probe:Object.fromEntries(Object.entries((L=e.probe)!=null?L:{}).map(([S,C])=>[S,C]))}}}function Pt(t,e){var r,o,n,i;if(typeof e=="string")return{path:t,data:{value:e},format:"text"};if(typeof e=="object"){if("volume"in e)return{path:t,volume:e.volume};if("data"in e)return{path:t,data:{value:e.data},format:(r=e.format)!=null?r:"text",mode:(o=e.mode)!=null?o:420};let a=["secret","port","domain","certificate","ca"].find(u=>u in e);if(a){let u=a;return{path:t,data:{[u]:e[u]},format:(n=e.format)!=null?n:"text",mode:(i=e.mode)!=null?i:420}}}throw new Error(`Unknown key '${t}': ${JSON.stringify(e)}`)}import{Maybe as $t,None as jt,Some as Ft}from"@kumori/kdsl-lsp/util/maybe.js";import{SemVer as Tt}from"@kumori/kdsl-lsp/util/semver.js";function Rt(t){var r,o,n;let e=Tt(t.id.version);return{spec:[1,0],ref:{version:[e.major,e.minor,e.patch],kind:t.id.kind,domain:t.id.domain,module:t.id.module,name:t.id.name},description:{builtin:!0,srv:{client:Object.fromEntries(Object.entries((r=t.srv.client)!=null?r:{}).map(([i])=>[i,{protocol:"http",inherited:!1}])),server:Object.fromEntries(Object.entries((o=t.srv.server)!=null?o:{}).map(([i,s])=>{let a;return typeof s=="string"?a={port:80,portnum:1,inherited:!1,protocol:s}:a=y(m({},s),{inherited:!1}),[i,a]})),duplex:Object.fromEntries(Object.entries((n=t.srv.duplex)!=null?n:{}).map(([i,s])=>{let a;return typeof s=="string"?a={port:80,portnum:1,inherited:!1,protocol:s}:a=y(m({},s),{inherited:!1}),[i,a]}))},config:{resilience:0,scale:{},parameter:t.config,resource:Object.fromEntries(Object.entries(t.resource).map(([i,s])=>[i,_(s)]))},connector:{},role:{}}}}function we(t,e){var r,o;return{name:A(t),up:B(t),meta:{},config:{resilience:0,scale:{},parameter:(r=e.config)!=null?r:{},resource:Object.fromEntries(Object.entries((o=e.resource)!=null?o:{}).map(([n,i])=>[n,_(i)]))},artifact:Rt(e)}}import{LoadBalancerName as _t,FullConnectorName as Nt}from"@kumori/kdsl-lsp/language/builtin/lib/kumori/service.js";function G(t,e,r,o){let n=t.svcs.shared.references.KumoriModules,i=F(n,t.nodes.get(e));for(let s of i)s(r);return o&&(r.kind="service"),r}function ee(t,e){return t.some(r=>JSON.stringify(r)===JSON.stringify(e))}function te(t,e){return{role:t,channel:e}}function W(t,e,r){return{meta:t,links:[{role:e,channel:r}]}}function Le(t,e,r){var n,i,s,a;let o={version:[0,0,0],kind:"component",domain:"unknown",module:"unknown",name:"unknown"};if(r.$type===_t){r=r;let u=[],c=[];if("from"in r.value&&Array.isArray(r.value.from)&&"to"in r.value&&Array.isArray(r.value.to))for(let d of r.value.from){c.push(te(d.target,d.channel));for(let l of r.value.to){let g=e.role[l.target=="self"?d.target:l.target],h=$(g.artifact)||l.target=="self";G(t,g,o,h);let p=(n=r.value.meta)!=null?n:[{auto:{channel:l.target!=="self"?l.target+"."+l.channel:l.channel,compRef:o,roleName:l.target=="self"?d.target:l.target},user:{}}],b=W(p,l.target,l.channel);ee(u,b)||u.push(b)}}else if("from"in r.value&&!Array.isArray(r.value.from)&&!Array.isArray(r.value.to)){let d=r.value.from,l=r.value.to;c.push(te(d.target,d.channel));let g=e.role[l.target=="self"?d.target:l.target],h=$(g.artifact)||l.target=="self";G(t,g,o,h);let p=(i=r.value.meta)!=null?i:[{auto:{channel:l.target!=="self"?l.target+"."+l.channel:l.channel,compRef:o,roleName:l.target=="self"?d.target:l.target},user:{}}],b=W(p,l.target,l.channel);ee(u,b)||u.push(b)}return{kind:"lb",clients:c,servers:u}}if(r.$type===Nt){r=r;let u=[],c=[];if("from"in r.value&&Array.isArray(r.value.from)&&"to"in r.value&&Array.isArray(r.value.to))for(let d of r.value.from){c.push(te(d.target,d.channel));for(let l of r.value.to){let g=e.role[l.target=="self"?d.target:l.target],h=$(g.artifact);G(t,g,o,h);let p=(s=r.value.meta)!=null?s:[{auto:{channel:l.target!=="self"?l.target+"."+l.channel:l.channel,compRef:o,roleName:l.target=="self"?d.target:l.target},user:{}}],b=W(p,l.target,l.channel);ee(u,b)||u.push(b)}}else if("target"in r.value&&"channel"in r.value){let d=e.role[r.value.target],l=$(d.artifact);G(t,d,o,l);let g=(a=r.value.meta)!=null?a:[{auto:{channel:r.value.channel,compRef:o,roleName:r.value.target},user:{}}];u.push(W(g,r.value.target,r.value.channel))}return{kind:"full",clients:c,servers:u}}throw new Error(`unknown connection type '${r.$type}'`)}function re(t,e){var s,a,u,c,d,l,g,h,p,b,w;let r={version:[0,0,0],kind:"service",domain:"unknown",module:"unknown",name:"unknown"},o=t.svcs.shared.references.KumoriModules,n=F(o,t.nodes.get(e));for(let f of n)f(r);let i={spec:[1,0],ref:r,description:{builtin:!1,config:{resilience:0,scale:{detail:Object.fromEntries(Object.entries((s=e.role)!=null?s:{}).map(([f])=>[f,{hsize:1}]))},parameter:(a=e==null?void 0:e.config)!=null?a:{},resource:Object.fromEntries(Object.entries((u=e.resource)!=null?u:{}).map(([f,L])=>[f,_(L)]))},role:{},connector:Object.fromEntries(Object.entries((c=e.connect)!=null?c:{}).map(([f,L])=>[f,Le(t,e,L)])),srv:{client:Object.fromEntries(Object.entries((l=(d=e.srv)==null?void 0:d.client)!=null?l:{}).map(([f,L])=>[f,{protocol:L,inherited:!1}])),server:Object.fromEntries(Object.entries((h=(g=e.srv)==null?void 0:g.server)!=null?h:{}).map(([f,L])=>{let S;return typeof L=="string"?S={port:80,inherited:!1,protocol:L}:S=y(m({},L),{inherited:!1}),[f,S]})),duplex:Object.fromEntries(Object.entries((b=(p=e.srv)==null?void 0:p.duplex)!=null?b:{}).map(([f,L])=>{let S;return typeof L=="string"?S={port:80,inherited:!1,protocol:L}:S=y(m({},L),{inherited:!1}),[f,S]}))}}};return i.description.role=Object.fromEntries(Object.entries((w=e.role)!=null?w:{}).map(([f,L])=>[f,Bt(t,f,L,i)]).filter(([,f])=>$t.isSome(f)).map(([f,L])=>[f,L.value])),i}function At(t,e){var r,o,n,i,s,a,u;return{name:A(t),up:B(t),meta:{},config:{resilience:0,scale:(n=(r=e.config)==null?void 0:r.scale)!=null?n:{hsize:(o=e.config)==null?void 0:o.scale},parameter:(s=(i=e.config)==null?void 0:i.parameter)!=null?s:{},resource:Object.fromEntries(Object.entries((u=(a=e.config)==null?void 0:a.resource)!=null?u:{}).map(([c,d])=>[c,_(d)]))},artifact:re(t,e)}}function Bt(t,e,r,o){var s,a,u,c,d,l,g,h,p,b,w,f,L,S,C,D,E,X;if(V(r.artifact))return Ft({name:e,meta:r.meta,config:{resilience:0,scale:{hsize:1},parameter:(s=r.artifact.config)!=null?s:{},resource:{}},artifact:Z(t,r.artifact)});let n=r.artifact;t=Ce(t,e),Me(t,$(n)?At(t,n):we(t,n)),(u=(a=o.description).srv)!=null||(a.srv={}),(d=(c=o.description.srv).server)!=null||(c.server={}),(g=(l=o.description.srv).client)!=null||(l.client={});for(let[,J]of Object.entries((h=o.description.connector)!=null?h:{})){for(let P of J.clients){if(P.role!==e)continue;let x=m({},P),O=`${P.role}.${P.channel}`,R=((b=(p=n==null?void 0:n.srv)==null?void 0:p.client)!=null?b:{})[P.channel];o.description.srv.server[O]={inherited:!0,protocol:P.channel=="inbound"?"http":R},P.role="self",P.channel=O,(f=(w=t.root).links)!=null||(w.links=[]),t.root.links.push({meta:{},s_d:A(t),s_c:x.channel,t_d:B(t),t_c:O})}for(let P of J.servers)for(let x of P.links)if(x.role===e){let O=`${x.role}.${x.channel}`,R=((S=(L=n==null?void 0:n.srv)==null?void 0:L.server)!=null?S:{})[x.channel];R===void 0&&(R=((D=(C=n==null?void 0:n.srv)==null?void 0:C.duplex)!=null?D:{})[x.channel]),o.description.srv.client[O]={inherited:!0,protocol:typeof R=="string"?R:R.protocol,port:typeof R=="object"?R.port:void 0},(X=(E=t.root).links)!=null||(E.links=[]),t.root.links.push({meta:{},s_d:B(t),s_c:O,t_d:A(t),t_c:x.channel}),x.role="self",x.channel=O}}return jt}import{isComponentArtifact as It}from"@kumori/kdsl-lsp/language/generated/ast.js";var A=t=>t.path.join("."),B=t=>t.path.slice(0,-1).join("."),Ce=(t,e)=>y(m({},t),{path:[...t.path,e]}),Me=(t,e)=>t.root.deployments[A(t)]=e;function xe(t,e,r){var i,s,a;let o={top:r.name,deployments:{},links:[]},n={svcs:t,path:[r.name],root:o,nodes:e};return o.deployments[r.name]={name:r.name,meta:r.meta,config:{parameter:(i=r.config)!=null?i:{},resource:Object.fromEntries(Object.entries((s=r.resource)!=null?s:{}).map(([u,c])=>[u,_(c)])),resilience:(a=r.resilience)!=null?a:0,scale:{detail:(()=>{var u;if(V(r.artifact)){let c=n.nodes.get(r.artifact),d="";if(c&&It(c)&&(d=c.name.value.$refText),d==="")throw new Error("Unable to determine component name for scale detail.");return{[d]:{hsize:typeof r.scale=="number"?r.scale:1}}}if($(r.artifact)){let c=Object.entries((u=r.artifact.role)!=null?u:{});return Object.fromEntries(c.map(([d])=>[d,{hsize:r.scale&&typeof r.scale=="object"&&!Array.isArray(r.scale)&&d in r.scale?r.scale[d]:1}]))}return{}})()}},artifact:(()=>{if(V(r.artifact))return be(n,r.artifact);if($(r.artifact))return re(n,r.artifact);throw Oe(r.artifact)?new Error("not implemented: handle builtin"):new Error("unknown artifact")})()},o}function V(t){return"size"in t}function $(t){return!(V(t)||Oe(t))}function Oe(t){return"id"in t}function De(t,e,r){var d,l;let o=e.validation.KumoriTypeSystem,[{Value:n},i]=o.Eval(e.validation.KumoriValidations.ctx(),r);if(i.length!==0){let g=[];for(let h of i){let p=h.node,b=ke.getDocument(p),w=((d=p.$cstNode)==null?void 0:d.range.start)||{line:0,character:0},f=`${b.uri.fsPath}:${w.line}:${w.character}: type error: ${h.message}`;t.error(f),g.push(f)}return oe(g)}let s=new Map,a=Kt({svcs:e,nodes:s},n);if(zt.isErr(a)){let g=[];for(let h of a.err){let p=h.node,b=ke.getDocument(p),w=((l=p.$cstNode)==null?void 0:l.range.start)||{line:0,character:0},f=`${b.uri.fsPath}:${w.line}:${w.character}: json conversion error: ${h.message}`;t.error(f),g.push(f)}return oe(g)}let u=Jt.safeParse(a.value);if(!u.success){let g=[];for(let h of u.error.issues){let p=`${h.code}: ${h.path}: invalid deployment: ${h.message}`;t.error(p),g.push(p)}return oe(g)}let c=JSON.stringify(xe(e,s,a.value),null,2);return Vt(c)}import{ModuleContext as qe}from"@kumori/kdsl-lsp/module/context.js";import{ListDependencies as wr}from"@kumori/kdsl-lsp/module/dependency/list.js";import Ve from"assert";import{LocateDependency as Lr}from"@kumori/kdsl-lsp/module/dependency/locate.js";import{Maybe as Cr}from"@kumori/kdsl-lsp/util/maybe.js";import{DependencyId as Mr}from"@kumori/kdsl-lsp/module/dependency/id.js";import Ue from"path";import{createKumoriServices as zn}from"@kumori/kdsl-lsp/language/kumori.js";import{URI as Hn,UriUtils as ae}from"langium";import{NodeFileSystem as Xn}from"langium/node";import{DiagnosticSeverity as Je}from"vscode-languageserver";import{Err as se,Ok as Ke,Result as Q}from"@kumori/kdsl-lsp/util/result.js";import{ModuleContext as ti}from"@kumori/kdsl-lsp/module/context.js";import{ModuleContext as ar}from"@kumori/kdsl-lsp/module/context.js";import{SumDB as lr}from"@kumori/kdsl-lsp/module/integrity/sumdb.js";import{RemoteFetcherFactory as Ae}from"@kumori/kdsl-lsp/module/remote/factory.js";import{Maybe as ur}from"@kumori/kdsl-lsp/util/maybe.js";import{Err as Be,Ok as cr,Result as U}from"@kumori/kdsl-lsp/util/result.js";import{URI as dr}from"langium";import{NodeFileSystem as Pn}from"langium/node";import{createKumoriServices as Rn}from"@kumori/kdsl-lsp/language/kumori.js";import{Result as en}from"@kumori/kdsl-lsp/util/result.js";import{ParseQuery as Te}from"@kumori/kdsl-lsp/module/query.js";import{Maybe as H,None as Ut,Some as qt}from"@kumori/kdsl-lsp/util/maybe.js";import{Err as N,Ok as ne,Result as j}from"@kumori/kdsl-lsp/util/result.js";import{Version as Ee}from"@kumori/kdsl-lsp/module/version.js";import{ListDependencies as Gt}from"@kumori/kdsl-lsp/module/dependency/list.js";import ie from"assert";import{LocateDependency as Re}from"@kumori/kdsl-lsp/module/dependency/locate.js";import{ModuleContext as Wt}from"@kumori/kdsl-lsp/module/context.js";import{MkdirTemp as Ht}from"@kumori/kdsl-lsp/util/tmp.js";import{ValidateChecksum as Qt}from"@kumori/kdsl-lsp/module/integrity/validate.js";import{URI as Xt,UriUtils as Yt}from"langium";import{mkdir as Zt,rename as er,rm as tr}from"fs/promises";import{ForURL as rr}from"@kumori/kdsl-lsp/module/remote/factory.js";import{SemVer as Pe}from"@kumori/kdsl-lsp/util/semver.js";import{URL as or}from"@kumori/kdsl-lsp/util/url.js";import{DependencyId as _e}from"@kumori/kdsl-lsp/module/dependency/id.js";async function Ne(t){let e=new Map;return await je(t,e),e}async function $e(t,e){let r=new Map;console.log(e);for(let o of e){let n=Te(o);if(H.isNone(n)){let u=`invalid download query '${o}': failed to parse`;r.set(o,y(m({},N(u)),{required:!0}));continue}let i=Ee(n.value.Version);if(H.isNone(i)){let u=`invalid download query '${o}': invalid version specifier '${n.value.Version}': failed to parse`;r.set(o,y(m({},N(u)),{required:!0}));continue}if(!Ee.isSemVer(i.value)){let u=`invalid download query '${o}': invalid version specifier '${n.value.Version}': invalid semver`;r.set(o,y(m({},N(u)),{required:!0}));continue}let s=`${n.value.Scheme}://${n.value.Location}`,a=n.value.Version;await Fe(t,s,a,r)}return r}async function je(t,e){var o;let r=Gt(t.Current);for(let n of r.keys()){let i=r.get(n);if(i.length<1)continue;let{target:s,version:a}=i[0];await Fe(t,s,a,e);let u=i.reduce((d,l)=>d||l.interface===void 0,!1),c=_e(s,a);ie(e.has(c)),(o=e.get(c)).required||(o.required=u)}}async function Fe(t,e,r,o){let n=_e(e,r);if(o.has(n))return;let i=await nr(t,e,r);if(o.set(n,y(m({},i),{required:!1})),j.isErr(i))return;let s=await Re(t,e,r);ie(H.isSome(s));let a=await Wt.Move(t,t.FS,s.value.Root);ie(j.isOk(a)),t=m(m({},t),a.value),await je(t,o)}async function nr(t,e,r){var c=[];try{let o=await Re(t,e,r);if(j.isOk(o))return ne(Ut);let n=ce(c,await Ht(),!0);let i=await ir(t,e,r,n.Path);if(j.isErr(i))return N(`failed to fetch ${e}@${r}: ${i.err}`);let s=await Qt(t.SumDB,Xt.file(n.Path),t,e,i.value);if(j.isErr(s))return s;let a=`${e}@${r}`;let u=Yt.joinPath(t.Locations.Cache(),a);await Zt(u.fsPath,{recursive:!0});await tr(u.fsPath,{recursive:!0,force:!0});await er(n.Path,u.fsPath);return ne(qt(a))}catch(d){var l=d,g=!0}finally{var h=de(c,l,g);h&&await h}}async function ir(t,e,r,o){let n=`${e}@${r}`,i=Te(n);if(H.isNone(i))return N(`failed to resolve ${n}: invalid download query`);let s=Pe(i.value.Version),a=new or(`${i.value.Scheme}://${i.value.Location}`),u=rr(t.Remotes,a);if(j.isErr(u))return N(`failed to resolve ${n}': invalid remote ${a}: ${u.err}`);let c=await u.value.Versions(a);if(j.isErr(c))return N(`failed to read ${a}: ${c.err}`);let d=s,l=c.value.filter(p=>Pe.Compare(p,d)===0);if(l.length===0)return N(`no remote matches for ${a}@v${s}`);if(l.length>1){let p=`[${l.map(String).join(", ")}]`;return N(`ambiguous match for ${a}@v${s}: found ${p}`)}let g=l[0],h=await u.value.Get(a,g.toString(),o);return j.isErr(h)?N(`failed to fetch ${a}@${s.toString()}: ${h.err}`):ne(g)}import{RegistryManager as An}from"@kumori/kdsl-lsp/module/registry/manager.js";var Bn=`
2
+ Downloads the specified modules, which can be module patterns selecting depen-
3
+ dencies of the current module or module queries of the form path@version.
4
+
5
+ With no arguments, download applies to the modules needed to build the packages
6
+ in the current module.
7
+
8
+ The kdsl command will automatically download modules as needed during ordinary
9
+ execution. The "kdsl mod download" command is useful mainly for pre-filling the
10
+ local cache.
11
+
12
+ By default, download writes nothing to standard output. It may print progress
13
+ messages and errors to standard error.
14
+ `.trim();var Ie=async(t,e,r,o,n)=>{let i=e.shared.workspace.FileSystemProvider,s=await ar(i,dr.file(r));if(U.isErr(s))return Be([s.err]);let a=await lr.Open(s.value.Locations.Checksum());if(U.isErr(a))return U.mapErr(a,l=>[l]);let u;o.length?u=await $e(y(m({},s.value),{FS:i,Remotes:Ae(),SumDB:a.value}),o):u=await Ne(y(m({},s.value),{FS:i,Remotes:Ae(),SumDB:a.value}));let c=[];for(let[l,g]of u){if(U.isOk(g)){ur.isSome(g.value)&&t.info(`Downloaded dependency ${l}`);continue}g.required?c.push(`${l}: ${g.err}`):n.quiet||(t.warn(`${l}: ${g.err}`),t.warn(`${l}: not required - continuing`))}return Array.from(u.entries()).filter(([,l])=>U.isErr(l)&&l.required).length>0?Be(c):cr(void 0)};import{RegistryManager as ii}from"@kumori/kdsl-lsp/module/registry/manager.js";var si=`
15
+ `.trim();var ze=async(t,e,r)=>{let o=r.Current.Root,n=await Ie(t,e,o.fsPath,[],{quiet:!0});if(Q.isErr(n))return n;let i=await fr(e,r);if(Q.isErr(i)){let s=i.err.warnings.concat(i.err.errors);return se(s)}return Ke(void 0)},fr=async(t,e)=>{let r={errors:[],warnings:[]},o=t.shared.workspace.FileSystemProvider,n=e.Current.Root,i=await Q.tryCatchAsync(()=>o.readDirectory(n));if(Q.isErr(i)){let c=""+i.err;return i.err instanceof Error&&(c=i.err.message),r.errors.push(`failed to read directory '${n.fsPath}': ${c}`),se(r)}await t.shared.workspace.WorkspaceManager.initializeWorkspace([{name:"root",uri:n.toString()}]);let a=t.shared.workspace.LangiumDocuments;await t.shared.workspace.DocumentBuilder.build(a.all.toArray(),{validation:!0});for(let c of t.shared.workspace.LangiumDocuments.all){for(let d of c.parseResult.lexerErrors)r.errors.push(mr(c,d));for(let d of c.parseResult.parserErrors)r.errors.push(gr(c,d));for(let d of c.diagnostics||[]){let l=pr(c,d);d.severity===Je.Error&&r.errors.push(l),d.severity===Je.Warning&&r.warnings.push(l)}}return r.errors.length>0?se(r):Ke(void 0)};function mr(t,e){return`lexer error: ${ae.relative(process.cwd(),t.uri.fsPath)}:${e.line||1}:${e.column||1}: ${e.message}`}function gr(t,e){return`parser error: ${ae.relative(process.cwd(),t.uri.fsPath)}:${e.token.startLine||1}:${e.token.startColumn||1}: ${e.message}`}function pr(t,e){return`diagnostic error: ${ae.relative(process.cwd(),t.uri.fsPath)}:${e.range.start.line+1}:${e.range.start.character+1}: ${e.message}`}import{promises as xr}from"fs";import{RegistryManager as Di}from"@kumori/kdsl-lsp/module/registry/manager.js";var Ei=`
16
+ Generates a solution.json file for a specified Kumori package containing deployment definitions.
17
+ The command requires the path to the package as an argument, and optionally accepts a directory
18
+ path where the Kumori module is located. If the directory is not provided, the current working
19
+ directory is used by default.
20
+
21
+ Some usage examples:
22
+ kdsl build
23
+ kdsl build my-package
24
+ kdsl build my-package path/to/module
25
+
26
+ The generated solution.json file will be created in the package directory, containing all necessary
27
+ information for deploying the resources defined in the package's deployment artifacts.
28
+ `.trim();async function Ge(t,e,r,o){let n=e.shared.workspace.FileSystemProvider,i=await qe(n,Sr.file(Ue.resolve(o)));if(q.isErr(i)){let f=`error: ${i.err}`;return t.error(f),I([f])}let s=m({FS:n},i.value),a=await We(s);if(a.size>0){let f=["error: missing modules"];t.error(f[0]);for(let S of a){let C=`+ ${S}`;t.error(C),f.push(C)}let L="unable to build solution.json";return t.error(L),f.push(L),I(f)}let u=await ze(t,e,i.value);if(q.isErr(u))return u;let c=yr.joinPath(i.value.Current.Root,r),d=e.references.KumoriPackages.GetPackage(c);if(q.isErr(d)){let f=`error: failed to retrieve package: ${c.toString()}`;return t.error(f),I([f])}let l=new Set(d.value.docs.map(f=>f.uri.toString())),g=e.shared.workspace.IndexManager.allElements(hr.$type,l).toArray();if(g.length<1){let f=`error: no deployment defined in ${c.toString()}`;return t.error(f),I([f])}if(g.length>1){let f=`error: too many deployments in ${c.toString()}`;return t.error(f),I([f])}let h=g[0],p=h.node;if(!vr(p)){let f=`error: invalid target doc=${h.documentUri} location=${h.path}`;return t.error(f),I([f])}let b=De(t,e,p);if(q.isErr(b))return b;let w=Ue.join(c.fsPath,"solution.json");return await xr.writeFile(w,b.value,"utf-8"),t.info(`solution.json written to ${w}`),br(void 0)}async function We(t,e=new Set){let r=wr(t.Current);for(let[,o]of r.entriesGroupedByKey()){Ve(o.length>0);let{target:n,version:i}=o[0],s=await Lr(t,n,i);if(Cr.isNone(s)){e.add(Mr(n,i));continue}let a=await qe.Move(t,t.FS,s.value.Root);Ve(q.isOk(a));let u=m(m({},t),a.value);await We(u,e)}return e}async function $i(t){var s,a,u;let e=Se(t.logger),r=(s=t.package)!=null?s:".",o=(u=(a=t.directory)!=null?a:t.cwd)!=null?u:".",n=t.services;return await new Or().ensureIndexes(),await Ge(e,n,r,o)}export{$i as build};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/lib/build.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAgB5C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,OAAqB;;IAErB,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACrC,MAAM,MAAM,GAAG,MAAA,OAAO,CAAC,OAAO,mCAAI,GAAG,CAAA;IACrC,MAAM,MAAM,GAAG,MAAA,MAAA,OAAO,CAAC,SAAS,mCAAI,OAAO,CAAC,GAAG,mCAAI,GAAG,CAAA;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAA;IAE7B,MAAM,OAAO,GAAG,IAAI,eAAe,EAAE,CAAA;IACrC,MAAM,OAAO,CAAC,aAAa,EAAE,CAAA;IAE7B,oCAAoC;IACpC,OAAO,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AACnD,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { LibraryOptions, LibraryResult } from "./types.js";
2
+ export interface CheckOptions extends LibraryOptions {
3
+ /**
4
+ * Directory containing the module to check.
5
+ * Defaults to cwd or '.'
6
+ */
7
+ directory?: string;
8
+ /**
9
+ * Skip downloading dependencies before checking.
10
+ * Defaults to false.
11
+ */
12
+ skipDownload?: boolean;
13
+ }
14
+ /**
15
+ * Typecheck and validate a Kumori module.
16
+ * Downloads dependencies unless skipDownload is true.
17
+ *
18
+ * @param options - Check command options
19
+ * @returns Result with void on success, or string[] of errors
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import { createKumoriServices } from '@kumori/kdsl-lsp/language/kumori.js'
24
+ * import { NodeFileSystem } from 'langium/node'
25
+ * import { check } from '@kumori/kdsl'
26
+ *
27
+ * const services = createKumoriServices(NodeFileSystem).Kumori
28
+ *
29
+ * const result = await check({
30
+ * services,
31
+ * directory: './my-module'
32
+ * })
33
+ *
34
+ * if (result.ok) {
35
+ * console.log('Check passed!')
36
+ * } else {
37
+ * console.error('Errors:', result.err)
38
+ * }
39
+ * ```
40
+ */
41
+ export declare function check(options: CheckOptions): Promise<LibraryResult<void>>;
@@ -0,0 +1,15 @@
1
+ var se=Object.defineProperty,le=Object.defineProperties;var ue=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var ge=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable;var $=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r);var T=(r,e,t)=>e in r?se(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,u=(r,e)=>{for(var t in e||(e={}))ge.call(e,t)&&T(r,t,e[t]);if(B)for(var t of B(e))de.call(e,t)&&T(r,t,e[t]);return r},w=(r,e)=>le(r,ue(e));var m=(r,e,t)=>(T(r,typeof e!="symbol"?e+"":e,t),t);var I=(r,e,t)=>{if(e!=null){if(typeof e!="object"&&typeof e!="function")throw TypeError("Object expected");var o;if(t&&(o=e[$("asyncDispose")]),o===void 0&&(o=e[$("dispose")]),typeof o!="function")throw TypeError("Object not disposable");r.push([t,o,e])}else t&&r.push([t]);return e},A=(r,e,t)=>{var o=typeof SuppressedError=="function"?SuppressedError:function(a,l,d,g){return g=Error(d),g.name="SuppressedError",g.error=a,g.suppressed=l,g},n=a=>e=t?new o(a,e,"An error was suppressed during disposal"):(t=!0,a),i=a=>{for(;a=r.pop();)try{var l=a[1]&&a[1].call(a[2]);if(a[0])return Promise.resolve(l).then(i,d=>(n(d),i()))}catch(d){n(d)}if(t)throw e};return i()};var b=function(r){return r.info="info",r.warn="warn",r.error="error",r.debug="debug",r.trace="trace",r.fatal="fatal",r}({}),ze={[b.trace]:10,[b.debug]:20,[b.info]:30,[b.warn]:40,[b.error]:50,[b.fatal]:60},He={10:b.trace,20:b.debug,30:b.info,40:b.warn,50:b.error,60:b.fatal};var v=function(r){return r.onBeforeDataOut="onBeforeDataOut",r.shouldSendToLogger="shouldSendToLogger",r.onMetadataCalled="onMetadataCalled",r.onBeforeMessageOut="onBeforeMessageOut",r.onContextCalled="onContextCalled",r}({});var s=function(r){return r.info="info",r.warn="warn",r.error="error",r.debug="debug",r.trace="trace",r.fatal="fatal",r}({}),P={[s.trace]:10,[s.debug]:20,[s.info]:30,[s.warn]:40,[s.error]:50,[s.fatal]:60},Ge={10:s.trace,20:s.debug,30:s.info,40:s.warn,50:s.error,60:s.fatal};var N=class q{constructor(){m(this,"context",{});m(this,"hasContext",!1)}setContext(e){if(!e){this.context={},this.hasContext=!1;return}this.context=e,this.hasContext=!0}appendContext(e){this.context=u(u({},this.context),e),this.hasContext=!0}getContext(){return this.context}hasContextData(){return this.hasContext}onChildLoggerCreated({parentContextManager:e,childContextManager:t}){if(e.hasContextData()){let o=e.getContext();t.setContext(u({},o))}}clone(){let e=new q;return e.setContext(u({},this.context)),e.hasContext=this.hasContext,e}};var j=class{constructor(r){m(this,"err");m(this,"metadata");m(this,"structuredLogger");m(this,"hasMetadata");m(this,"pluginManager");this.err=null,this.metadata={},this.structuredLogger=r,this.hasMetadata=!1,this.pluginManager=r.pluginManager}withMetadata(r){let{pluginManager:e,structuredLogger:{_config:{consoleDebug:t}}}=this;if(!r)return t&&console.debug("[LogLayer] withMetadata was called with no metadata; dropping."),this;let o=r;return e.hasPlugins(v.onMetadataCalled)&&(o=e.runOnMetadataCalled(r,this.structuredLogger),!o)?(t&&console.debug("[LogLayer] Metadata was dropped due to plugin returning falsy value."),this):(this.metadata=u(u({},this.metadata),o),this.hasMetadata=!0,this)}withError(r){return this.err=r,this}info(...r){this.structuredLogger.isLevelEnabled(s.info)&&(this.structuredLogger._formatMessage(r),this.formatLog(s.info,r))}warn(...r){this.structuredLogger.isLevelEnabled(s.warn)&&(this.structuredLogger._formatMessage(r),this.formatLog(s.warn,r))}error(...r){this.structuredLogger.isLevelEnabled(s.error)&&(this.structuredLogger._formatMessage(r),this.formatLog(s.error,r))}debug(...r){this.structuredLogger.isLevelEnabled(s.debug)&&(this.structuredLogger._formatMessage(r),this.formatLog(s.debug,r))}trace(...r){this.structuredLogger.isLevelEnabled(s.trace)&&(this.structuredLogger._formatMessage(r),this.formatLog(s.trace,r))}fatal(...r){this.structuredLogger.isLevelEnabled(s.fatal)&&(this.structuredLogger._formatMessage(r),this.formatLog(s.fatal,r))}disableLogging(){return this.structuredLogger.disableLogging(),this}enableLogging(){return this.structuredLogger.enableLogging(),this}formatLog(r,e){let{muteMetadata:t}=this.structuredLogger._config,o=t?!1:this.hasMetadata;this.structuredLogger._formatLog({logLevel:r,params:e,metadata:o?this.metadata:null,err:this.err})}},ce=[v.onBeforeDataOut,v.onMetadataCalled,v.shouldSendToLogger,v.onBeforeMessageOut,v.onContextCalled],V=class{constructor(r){m(this,"idToPlugin");m(this,"onBeforeDataOut",[]);m(this,"shouldSendToLogger",[]);m(this,"onMetadataCalled",[]);m(this,"onBeforeMessageOut",[]);m(this,"onContextCalled",[]);this.idToPlugin={},this.mapPlugins(r),this.indexPlugins()}mapPlugins(r){for(let e of r){if(e.id||(e.id=Date.now().toString()+Math.random().toString()),this.idToPlugin[e.id])throw new Error(`[LogLayer] Plugin with id ${e.id} already exists.`);e.registeredAt=Date.now(),this.idToPlugin[e.id]=e}}indexPlugins(){this.onBeforeDataOut=[],this.shouldSendToLogger=[],this.onMetadataCalled=[],this.onBeforeMessageOut=[],this.onContextCalled=[];let r=Object.values(this.idToPlugin).sort((e,t)=>e.registeredAt-t.registeredAt);for(let e of r){if(e.disabled)return;for(let t of ce)e[t]&&e.id&&this[t].push(e.id)}}hasPlugins(r){return this[r].length>0}countPlugins(r){return r?this[r].length:Object.keys(this.idToPlugin).length}addPlugins(r){this.mapPlugins(r),this.indexPlugins()}enablePlugin(r){let e=this.idToPlugin[r];e&&(e.disabled=!1),this.indexPlugins()}disablePlugin(r){let e=this.idToPlugin[r];e&&(e.disabled=!0),this.indexPlugins()}removePlugin(r){delete this.idToPlugin[r],this.indexPlugins()}runOnBeforeDataOut(r,e){let t=u({},r);for(let o of this.onBeforeDataOut){let n=this.idToPlugin[o];if(n.onBeforeDataOut){let i=n.onBeforeDataOut({data:t.data,logLevel:t.logLevel,error:t.error,metadata:t.metadata,context:t.context},e);i&&(t.data||(t.data={}),Object.assign(t.data,i))}}return t.data}runShouldSendToLogger(r,e){return!this.shouldSendToLogger.some(t=>{var o,n;return!((n=(o=this.idToPlugin[t]).shouldSendToLogger)!=null&&n.call(o,r,e))})}runOnMetadataCalled(r,e){var o,n;let t=u({},r);for(let i of this.onMetadataCalled){let a=(n=(o=this.idToPlugin[i]).onMetadataCalled)==null?void 0:n.call(o,t,e);if(a)t=a;else return null}return t}runOnBeforeMessageOut(r,e){var o,n;let t=[...r.messages];for(let i of this.onBeforeMessageOut){let a=(n=(o=this.idToPlugin[i]).onBeforeMessageOut)==null?void 0:n.call(o,{messages:t,logLevel:r.logLevel},e);a&&(t=a)}return t}runOnContextCalled(r,e){var o,n;let t=u({},r);for(let i of this.onContextCalled){let a=(n=(o=this.idToPlugin[i]).onContextCalled)==null?void 0:n.call(o,t,e);if(a)t=a;else return null}return t}},K=class U{constructor(e){m(this,"pluginManager");m(this,"idToTransport");m(this,"hasMultipleTransports");m(this,"singleTransport");m(this,"contextManager");m(this,"logLevelEnabledStatus",{info:!0,warn:!0,error:!0,debug:!0,trace:!0,fatal:!0});m(this,"_config");var t;this._config=w(u({},e),{enabled:(t=e.enabled)!=null?t:!0}),this._config.enabled||this.disableLogging(),this.contextManager=new N,this.pluginManager=new V(e.plugins||[]),this._config.errorFieldName||(this._config.errorFieldName="err"),this._config.copyMsgOnOnlyError||(this._config.copyMsgOnOnlyError=!1),this._initializeTransports(this._config.transport)}withContextManager(e){return this.contextManager&&typeof this.contextManager[Symbol.dispose]=="function"&&this.contextManager[Symbol.dispose](),this.contextManager=e,this}getContextManager(){return this.contextManager}_initializeTransports(e){if(this.idToTransport)for(let t in this.idToTransport)this.idToTransport[t]&&typeof this.idToTransport[t][Symbol.dispose]=="function"&&this.idToTransport[t][Symbol.dispose]();this.hasMultipleTransports=Array.isArray(e)&&e.length>1,this.singleTransport=this.hasMultipleTransports?null:Array.isArray(e)?e[0]:e,Array.isArray(e)?this.idToTransport=e.reduce((t,o)=>(t[o.id]=o,t),{}):this.idToTransport={[e.id]:e}}withPrefix(e){let t=this.child();return t._config.prefix=e,t}withContext(e){let t=e;return e?this.pluginManager.hasPlugins(v.onContextCalled)&&(t=this.pluginManager.runOnContextCalled(e,this),!t)?(this._config.consoleDebug&&console.debug("[LogLayer] Context was dropped due to plugin returning falsy value."),this):(this.contextManager.appendContext(t),this):(this._config.consoleDebug&&console.debug("[LogLayer] withContext was called with no context; dropping."),this)}clearContext(){return this.contextManager.setContext(void 0),this}getContext(){return this.contextManager.getContext()}addPlugins(e){this.pluginManager.addPlugins(e)}enablePlugin(e){this.pluginManager.enablePlugin(e)}disablePlugin(e){this.pluginManager.disablePlugin(e)}removePlugin(e){this.pluginManager.removePlugin(e)}withMetadata(e){return new j(this).withMetadata(e)}withError(e){return new j(this).withError(e)}child(){let e=new U(w(u({},this._config),{transport:Array.isArray(this._config.transport)?[...this._config.transport]:this._config.transport})).withPluginManager(this.pluginManager).withContextManager(this.contextManager.clone());return this.contextManager.onChildLoggerCreated({parentContextManager:this.contextManager,childContextManager:e.contextManager,parentLogger:this,childLogger:e}),e}withFreshTransports(e){return this._config.transport=e,this._initializeTransports(e),this}withFreshPlugins(e){return this._config.plugins=e,this.pluginManager=new V(e),this}withPluginManager(e){return this.pluginManager=e,this}errorOnly(e,t){let o=(t==null?void 0:t.logLevel)||s.error;if(!this.isLevelEnabled(o))return;let{copyMsgOnOnlyError:n}=this._config,i={logLevel:o,err:e};(n&&(t==null?void 0:t.copyMsg)!==!1||(t==null?void 0:t.copyMsg)===!0)&&(e!=null&&e.message)&&(i.params=[e.message]),this._formatLog(i)}metadataOnly(e,t=s.info){if(!this.isLevelEnabled(t))return;let{muteMetadata:o,consoleDebug:n}=this._config;if(o)return;if(!e){n&&console.debug("[LogLayer] metadataOnly was called with no metadata; dropping.");return}let i=e;if(this.pluginManager.hasPlugins(v.onMetadataCalled)&&(i=this.pluginManager.runOnMetadataCalled(e,this),!i)){n&&console.debug("[LogLayer] Metadata was dropped due to plugin returning falsy value.");return}let a={logLevel:t,metadata:i};this._formatLog(a)}info(...e){this.isLevelEnabled(s.info)&&(this._formatMessage(e),this._formatLog({logLevel:s.info,params:e}))}warn(...e){this.isLevelEnabled(s.warn)&&(this._formatMessage(e),this._formatLog({logLevel:s.warn,params:e}))}error(...e){this.isLevelEnabled(s.error)&&(this._formatMessage(e),this._formatLog({logLevel:s.error,params:e}))}debug(...e){this.isLevelEnabled(s.debug)&&(this._formatMessage(e),this._formatLog({logLevel:s.debug,params:e}))}trace(...e){this.isLevelEnabled(s.trace)&&(this._formatMessage(e),this._formatLog({logLevel:s.trace,params:e}))}fatal(...e){this.isLevelEnabled(s.fatal)&&(this._formatMessage(e),this._formatLog({logLevel:s.fatal,params:e}))}raw(e){if(!this.isLevelEnabled(e.logLevel))return;let t={logLevel:e.logLevel,params:e.messages,metadata:e.metadata,err:e.error,context:e.context};this._formatMessage(e.messages),this._formatLog(t)}disableLogging(){for(let e of Object.keys(this.logLevelEnabledStatus))this.logLevelEnabledStatus[e]=!1;return this}enableLogging(){for(let e of Object.keys(this.logLevelEnabledStatus))this.logLevelEnabledStatus[e]=!0;return this}muteContext(){return this._config.muteContext=!0,this}unMuteContext(){return this._config.muteContext=!1,this}muteMetadata(){return this._config.muteMetadata=!0,this}unMuteMetadata(){return this._config.muteMetadata=!1,this}enableIndividualLevel(e){let t=e;return t in this.logLevelEnabledStatus&&(this.logLevelEnabledStatus[t]=!0),this}disableIndividualLevel(e){let t=e;return t in this.logLevelEnabledStatus&&(this.logLevelEnabledStatus[t]=!1),this}setLevel(e){let t=P[e];for(let o of Object.values(s)){let n=o,i=P[o];this.logLevelEnabledStatus[n]=i>=t}return this}isLevelEnabled(e){let t=e;return this.logLevelEnabledStatus[t]}formatContext(e){let{contextFieldName:t,muteContext:o}=this._config;return e&&Object.keys(e).length>0&&!o?t?{[t]:u({},e)}:u({},e):{}}formatMetadata(e=null){let{metadataFieldName:t,muteMetadata:o}=this._config;return e&&!o?t?{[t]:u({},e)}:u({},e):{}}getLoggerInstance(e){let t=this.idToTransport[e];if(t)return t.getLoggerInstance()}_formatMessage(e=[]){let{prefix:t}=this._config;t&&typeof e[0]=="string"&&(e[0]=`${t} ${e[0]}`)}_formatLog({logLevel:e,params:t=[],metadata:o=null,err:n,context:i=null}){var R;let{errorSerializer:a,errorFieldInMetadata:l,muteContext:d,contextFieldName:g,metadataFieldName:h,errorFieldName:c}=this._config,p=i!==null?i:this.contextManager.getContext(),L=!!o||(d?!1:i!==null?Object.keys(i).length>0:this.contextManager.hasContextData()),f={};if(L)if(g&&g===h){let x=this.formatContext(p)[g],y=this.formatMetadata(o)[h];f={[g]:u(u({},x),y)}}else f=u(u({},this.formatContext(p)),this.formatMetadata(o));if(n){let x=a?a(n):n;l&&o&&h?f!=null&&f[h]?f[h][c]=x:f=w(u({},f),{[h]:{[c]:x}}):l&&!o&&h?f=w(u({},f),{[h]:{[c]:x}}):f=w(u({},f),{[c]:x}),L=!0}if(this.pluginManager.hasPlugins(v.onBeforeDataOut)&&(f=this.pluginManager.runOnBeforeDataOut({data:L?f:void 0,logLevel:e,error:n,metadata:o,context:p},this),f&&!L&&(L=!0)),this.pluginManager.hasPlugins(v.onBeforeMessageOut)&&(t=this.pluginManager.runOnBeforeMessageOut({messages:[...t],logLevel:e},this)),this.hasMultipleTransports){let x=this._config.transport.filter(y=>y.enabled).map(async y=>{if(!(this.pluginManager.hasPlugins(v.shouldSendToLogger)&&!this.pluginManager.runShouldSendToLogger({messages:[...t],data:L?f:void 0,logLevel:e,transportId:y.id,error:n,metadata:o,context:p},this)))return y._sendToLogger({logLevel:e,messages:[...t],data:L?f:void 0,hasData:L,error:n,metadata:o,context:p})});Promise.all(x).catch(y=>{this._config.consoleDebug&&console.error("[LogLayer] Error executing transports:",y)})}else{if(!((R=this.singleTransport)!=null&&R.enabled)||this.pluginManager.hasPlugins(v.shouldSendToLogger)&&!this.pluginManager.runShouldSendToLogger({messages:[...t],data:L?f:void 0,logLevel:e,transportId:this.singleTransport.id,error:n,metadata:o,context:p},this))return;this.singleTransport._sendToLogger({logLevel:e,messages:[...t],data:L?f:void 0,hasData:L,error:n,metadata:o,context:p})}}};function he(){let r={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}};return new K({transport:r})}function z(r){return r!=null?r:he()}import{createKumoriServices as ir}from"@kumori/kdsl-lsp/language/kumori.js";import{URI as dr,UriUtils as F}from"langium";import{NodeFileSystem as hr}from"langium/node";import{DiagnosticSeverity as ne}from"vscode-languageserver";import{Err as O,Ok as ie,Result as S}from"@kumori/kdsl-lsp/util/result.js";import{ModuleContext as Lr}from"@kumori/kdsl-lsp/module/context.js";import{ModuleContext as Ee}from"@kumori/kdsl-lsp/module/context.js";import{SumDB as ke}from"@kumori/kdsl-lsp/module/integrity/sumdb.js";import{RemoteFetcherFactory as te}from"@kumori/kdsl-lsp/module/remote/factory.js";import{Maybe as Oe}from"@kumori/kdsl-lsp/util/maybe.js";import{Err as re,Ok as Fe,Result as D}from"@kumori/kdsl-lsp/util/result.js";import{URI as Re}from"langium";import{NodeFileSystem as Ht}from"langium/node";import{createKumoriServices as Qt}from"@kumori/kdsl-lsp/language/kumori.js";import{Result as Lt}from"@kumori/kdsl-lsp/util/result.js";import{ParseQuery as Q}from"@kumori/kdsl-lsp/module/query.js";import{Maybe as _,None as fe,Some as me}from"@kumori/kdsl-lsp/util/maybe.js";import{Err as M,Ok as E,Result as C}from"@kumori/kdsl-lsp/util/result.js";import{Version as H}from"@kumori/kdsl-lsp/module/version.js";import{ListDependencies as pe}from"@kumori/kdsl-lsp/module/dependency/list.js";import k from"assert";import{LocateDependency as J}from"@kumori/kdsl-lsp/module/dependency/locate.js";import{ModuleContext as Le}from"@kumori/kdsl-lsp/module/context.js";import{MkdirTemp as we}from"@kumori/kdsl-lsp/util/tmp.js";import{ValidateChecksum as ve}from"@kumori/kdsl-lsp/module/integrity/validate.js";import{URI as be,UriUtils as Me}from"langium";import{mkdir as xe,rename as ye,rm as Ce}from"fs/promises";import{ForURL as Pe}from"@kumori/kdsl-lsp/module/remote/factory.js";import{SemVer as W}from"@kumori/kdsl-lsp/util/semver.js";import{URL as De}from"@kumori/kdsl-lsp/util/url.js";import{DependencyId as G}from"@kumori/kdsl-lsp/module/dependency/id.js";async function X(r){let e=new Map;return await Z(r,e),e}async function Y(r,e){let t=new Map;console.log(e);for(let o of e){let n=Q(o);if(_.isNone(n)){let d=`invalid download query '${o}': failed to parse`;t.set(o,w(u({},M(d)),{required:!0}));continue}let i=H(n.value.Version);if(_.isNone(i)){let d=`invalid download query '${o}': invalid version specifier '${n.value.Version}': failed to parse`;t.set(o,w(u({},M(d)),{required:!0}));continue}if(!H.isSemVer(i.value)){let d=`invalid download query '${o}': invalid version specifier '${n.value.Version}': invalid semver`;t.set(o,w(u({},M(d)),{required:!0}));continue}let a=`${n.value.Scheme}://${n.value.Location}`,l=n.value.Version;await ee(r,a,l,t)}return t}async function Z(r,e){var o;let t=pe(r.Current);for(let n of t.keys()){let i=t.get(n);if(i.length<1)continue;let{target:a,version:l}=i[0];await ee(r,a,l,e);let d=i.reduce((h,c)=>h||c.interface===void 0,!1),g=G(a,l);k(e.has(g)),(o=e.get(g)).required||(o.required=d)}}async function ee(r,e,t,o){let n=G(e,t);if(o.has(n))return;let i=await _e(r,e,t);if(o.set(n,w(u({},i),{required:!1})),C.isErr(i))return;let a=await J(r,e,t);k(_.isSome(a));let l=await Le.Move(r,r.FS,a.value.Root);k(C.isOk(l)),r=u(u({},r),l.value),await Z(r,o)}async function _e(r,e,t){var g=[];try{let o=await J(r,e,t);if(C.isOk(o))return E(fe);let n=I(g,await we(),!0);let i=await Se(r,e,t,n.Path);if(C.isErr(i))return M(`failed to fetch ${e}@${t}: ${i.err}`);let a=await ve(r.SumDB,be.file(n.Path),r,e,i.value);if(C.isErr(a))return a;let l=`${e}@${t}`;let d=Me.joinPath(r.Locations.Cache(),l);await xe(d.fsPath,{recursive:!0});await Ce(d.fsPath,{recursive:!0,force:!0});await ye(n.Path,d.fsPath);return E(me(l))}catch(h){var c=h,p=!0}finally{var L=A(g,c,p);L&&await L}}async function Se(r,e,t,o){let n=`${e}@${t}`,i=Q(n);if(_.isNone(i))return M(`failed to resolve ${n}: invalid download query`);let a=W(i.value.Version),l=new De(`${i.value.Scheme}://${i.value.Location}`),d=Pe(r.Remotes,l);if(C.isErr(d))return M(`failed to resolve ${n}': invalid remote ${l}: ${d.err}`);let g=await d.value.Versions(l);if(C.isErr(g))return M(`failed to read ${l}: ${g.err}`);let h=a,c=g.value.filter(f=>W.Compare(f,h)===0);if(c.length===0)return M(`no remote matches for ${l}@v${a}`);if(c.length>1){let f=`[${c.map(String).join(", ")}]`;return M(`ambiguous match for ${l}@v${a}: found ${f}`)}let p=c[0],L=await d.value.Get(l,p.toString(),o);return C.isErr(L)?M(`failed to fetch ${l}@${a.toString()}: ${L.err}`):E(p)}import{RegistryManager as er}from"@kumori/kdsl-lsp/module/registry/manager.js";var tr=`
2
+ Downloads the specified modules, which can be module patterns selecting depen-
3
+ dencies of the current module or module queries of the form path@version.
4
+
5
+ With no arguments, download applies to the modules needed to build the packages
6
+ in the current module.
7
+
8
+ The kdsl command will automatically download modules as needed during ordinary
9
+ execution. The "kdsl mod download" command is useful mainly for pre-filling the
10
+ local cache.
11
+
12
+ By default, download writes nothing to standard output. It may print progress
13
+ messages and errors to standard error.
14
+ `.trim();var oe=async(r,e,t,o,n)=>{let i=e.shared.workspace.FileSystemProvider,a=await Ee(i,Re.file(t));if(D.isErr(a))return re([a.err]);let l=await ke.Open(a.value.Locations.Checksum());if(D.isErr(l))return D.mapErr(l,c=>[c]);let d;o.length?d=await Y(w(u({},a.value),{FS:i,Remotes:te(),SumDB:l.value}),o):d=await X(w(u({},a.value),{FS:i,Remotes:te(),SumDB:l.value}));let g=[];for(let[c,p]of d){if(D.isOk(p)){Oe.isSome(p.value)&&r.info(`Downloaded dependency ${c}`);continue}p.required?g.push(`${c}: ${p.err}`):n.quiet||(r.warn(`${c}: ${p.err}`),r.warn(`${c}: not required - continuing`))}return Array.from(d.entries()).filter(([,c])=>D.isErr(c)&&c.required).length>0?re(g):Fe(void 0)};import{RegistryManager as Mr}from"@kumori/kdsl-lsp/module/registry/manager.js";var xr=`
15
+ `.trim();var ae=async(r,e,t)=>{let o=t.Current.Root,n=await oe(r,e,o.fsPath,[],{quiet:!0});if(S.isErr(n))return n;let i=await Be(e,t);if(S.isErr(i)){let a=i.err.warnings.concat(i.err.errors);return O(a)}return ie(void 0)},Be=async(r,e)=>{let t={errors:[],warnings:[]},o=r.shared.workspace.FileSystemProvider,n=e.Current.Root,i=await S.tryCatchAsync(()=>o.readDirectory(n));if(S.isErr(i)){let g=""+i.err;return i.err instanceof Error&&(g=i.err.message),t.errors.push(`failed to read directory '${n.fsPath}': ${g}`),O(t)}await r.shared.workspace.WorkspaceManager.initializeWorkspace([{name:"root",uri:n.toString()}]);let l=r.shared.workspace.LangiumDocuments;await r.shared.workspace.DocumentBuilder.build(l.all.toArray(),{validation:!0});for(let g of r.shared.workspace.LangiumDocuments.all){for(let h of g.parseResult.lexerErrors)t.errors.push($e(g,h));for(let h of g.parseResult.parserErrors)t.errors.push(Ie(g,h));for(let h of g.diagnostics||[]){let c=Ae(g,h);h.severity===ne.Error&&t.errors.push(c),h.severity===ne.Warning&&t.warnings.push(c)}}return t.errors.length>0?O(t):ie(void 0)};function $e(r,e){return`lexer error: ${F.relative(process.cwd(),r.uri.fsPath)}:${e.line||1}:${e.column||1}: ${e.message}`}function Ie(r,e){return`parser error: ${F.relative(process.cwd(),r.uri.fsPath)}:${e.token.startLine||1}:${e.token.startColumn||1}: ${e.message}`}function Ae(r,e){return`diagnostic error: ${F.relative(process.cwd(),r.uri.fsPath)}:${e.range.start.line+1}:${e.range.start.character+1}: ${e.message}`}import{ModuleContext as Ne}from"@kumori/kdsl-lsp/module/context.js";import{URI as qe}from"langium";import{Result as je,Err as Ve}from"@kumori/kdsl-lsp/util/result.js";import Ke from"path";async function Er(r){var a,l;let e=z(r.logger),t=(l=(a=r.directory)!=null?a:r.cwd)!=null?l:".",o=r.services,n=o.shared.workspace.FileSystemProvider,i=await Ne(n,qe.file(Ke.resolve(t)));return je.isErr(i)?Ve([i.err]):await ae(e,o,i.value)}export{Er as check};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/lib/check.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAClE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAA;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAA;AAgB5B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,OAAqB;;IAErB,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACrC,MAAM,MAAM,GAAG,MAAA,MAAA,OAAO,CAAC,SAAS,mCAAI,OAAO,CAAC,GAAG,mCAAI,GAAG,CAAA;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAA;IAE7B,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAA;IACnD,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAEnE,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IACvB,CAAC;IAED,OAAO,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAA;AAC9C,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { LibraryOptions, LibraryResult } from "./types.js";
2
+ export interface CleanOptions {
3
+ /**
4
+ * Optional logger for output.
5
+ * If not provided, a silent logger is used.
6
+ */
7
+ logger?: LibraryOptions["logger"];
8
+ }
9
+ /**
10
+ * Remove cached files.
11
+ *
12
+ * The kdsl command builds most artifacts in a temporary directory,
13
+ * so clean is mainly concerned with files left by manual invocations.
14
+ *
15
+ * @param options - Clean command options
16
+ * @returns Result with void on success, or string[] of errors
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { clean } from '@kumori/kdsl'
21
+ *
22
+ * const result = await clean()
23
+ *
24
+ * if (result.ok) {
25
+ * console.log('Cache cleaned!')
26
+ * } else {
27
+ * console.error('Errors:', result.err)
28
+ * }
29
+ * ```
30
+ */
31
+ export declare function clean(options?: CleanOptions): Promise<LibraryResult<void>>;