@kumori/kdsl 0.0.15 → 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.
- package/dist/build/deployment_spec.d.ts +1133 -19642
- package/dist/build/deployment_spec.js +14 -13
- package/dist/build/deployment_spec.js.map +1 -1
- package/dist/build/helpers/builtin.js +7 -9
- package/dist/build/helpers/builtin.js.map +1 -1
- package/dist/build/helpers/component.d.ts +2 -2
- package/dist/build/helpers/component.js +28 -28
- package/dist/build/helpers/component.js.map +1 -1
- package/dist/build/helpers/connector.js +4 -5
- package/dist/build/helpers/connector.js.map +1 -1
- package/dist/build/helpers/deployment.d.ts +96 -96
- package/dist/build/helpers/deployment.js +8 -9
- package/dist/build/helpers/deployment.js.map +1 -1
- package/dist/build/helpers/resource.d.ts +4 -4
- package/dist/build/helpers/service.d.ts +1 -1
- package/dist/build/helpers/service.js +29 -32
- package/dist/build/helpers/service.js.map +1 -1
- package/dist/build/helpers/utils.d.ts +8 -0
- package/dist/build/helpers/utils.js +23 -1
- package/dist/build/helpers/utils.js.map +1 -1
- package/dist/build/main.js +51 -2
- package/dist/build/main.js.map +1 -1
- package/dist/build/solution.js +2 -3
- package/dist/build/solution.js.map +1 -1
- package/dist/check/main.js +1 -1
- package/dist/check/main.js.map +1 -1
- package/dist/deployment/gen/deployment-template.kumori +33 -0
- package/dist/deployment/gen/main.d.ts +15 -0
- package/dist/deployment/gen/main.js +158 -0
- package/dist/deployment/gen/main.js.map +1 -0
- package/dist/deployment/gen/types.d.ts +27 -0
- package/dist/deployment/gen/types.js +2 -0
- package/dist/deployment/gen/types.js.map +1 -0
- package/dist/deployment/main.d.ts +8 -0
- package/dist/deployment/main.js +17 -0
- package/dist/deployment/main.js.map +1 -0
- package/dist/index/create/main.js +38 -16
- package/dist/index/create/main.js.map +1 -1
- package/dist/lib/build.js +42 -28
- package/dist/lib/build.js.map +1 -1
- package/dist/lib/check.js +45 -15
- package/dist/lib/check.js.map +1 -1
- package/dist/lib/clean.js +39 -1
- package/dist/lib/deployment.d.ts +35 -0
- package/dist/lib/deployment.js +31 -0
- package/dist/lib/deployment.js.map +1 -0
- package/dist/lib/index-cmd.js +60 -57
- package/dist/lib/index-cmd.js.map +1 -1
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +54 -117
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/logger.js +1 -1
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/mod.js +144 -70
- package/dist/lib/mod.js.map +1 -1
- package/dist/lib/registry.d.ts +4 -4
- package/dist/lib/registry.js +67 -1
- package/dist/lib/registry.js.map +1 -1
- package/dist/main.js +2 -0
- package/dist/main.js.map +1 -1
- package/dist/mod/dependency/main.js +17 -10
- package/dist/mod/dependency/main.js.map +1 -1
- package/dist/mod/download/functions.js +5 -5
- package/dist/mod/download/functions.js.map +1 -1
- package/dist/mod/download/main.js +12 -2
- package/dist/mod/download/main.js.map +1 -1
- package/dist/mod/init/main.js +1 -1
- package/dist/mod/init/main.js.map +1 -1
- package/dist/mod/jsonschema/gen/main.js +14 -7
- package/dist/mod/jsonschema/gen/main.js.map +1 -1
- package/dist/mod/jsonschema/get/main.js +10 -2
- package/dist/mod/jsonschema/get/main.js.map +1 -1
- package/dist/mod/update/main.js +3 -4
- package/dist/mod/update/main.js.map +1 -1
- package/dist/registry/add.d.ts +1 -1
- package/dist/registry/add.js +12 -7
- package/dist/registry/add.js.map +1 -1
- package/dist/util/err-format.js +1 -2
- package/dist/util/err-format.js.map +1 -1
- package/dist/version.js +1 -2
- package/dist/version.js.map +1 -1
- package/out/deployment/gen/deployment-template.kumori +33 -0
- package/out/deployment-template.kumori +33 -0
- package/out/main.cjs +378 -209
- package/package.json +20 -14
- package/out/lib/build.cjs +0 -29
- package/out/lib/check.cjs +0 -16
- package/out/lib/clean.cjs +0 -2
- package/out/lib/index-cmd.cjs +0 -58
- package/out/lib/index.cjs +0 -118
- package/out/lib/mod.cjs +0 -71
- package/out/lib/registry.cjs +0 -2
|
@@ -37,6 +37,8 @@ export function Register(cmd, log) {
|
|
|
37
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
38
|
.summary(Summary)
|
|
39
39
|
.description(Description)
|
|
40
|
+
.helpOption(true)
|
|
41
|
+
.showHelpAfterError(true)
|
|
40
42
|
.action(Action(log));
|
|
41
43
|
return c;
|
|
42
44
|
}
|
|
@@ -74,7 +76,6 @@ export function Action(log) {
|
|
|
74
76
|
indexLocation = path.resolve(process.cwd(), options.index);
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
|
-
console.log(indexLocation);
|
|
78
79
|
// Read the index file and validate against the JSON Schema
|
|
79
80
|
let parsed = null;
|
|
80
81
|
if (indexLocation) {
|
|
@@ -83,7 +84,7 @@ export function Action(log) {
|
|
|
83
84
|
try {
|
|
84
85
|
data = await kumoriFs.readFile(URI.file(indexLocation));
|
|
85
86
|
}
|
|
86
|
-
catch
|
|
87
|
+
catch {
|
|
87
88
|
// File does not exist, will create a new one
|
|
88
89
|
data = "";
|
|
89
90
|
}
|
|
@@ -121,7 +122,7 @@ export function Action(log) {
|
|
|
121
122
|
}
|
|
122
123
|
// Attempt to find the current module in the index file
|
|
123
124
|
let moduleAlreadyInIndex = undefined;
|
|
124
|
-
if (parsed
|
|
125
|
+
if (parsed?.modules) {
|
|
125
126
|
moduleAlreadyInIndex = parsed.modules.find((m) => m.domain === ctx.value.Current.Manifest.module &&
|
|
126
127
|
m.version === ctx.value.Current.Manifest.version);
|
|
127
128
|
}
|
|
@@ -138,9 +139,7 @@ export function Action(log) {
|
|
|
138
139
|
}
|
|
139
140
|
// Gather all module documents
|
|
140
141
|
const moduleDocuments = await GatherModuleDocuments(svcs.shared, ctx.value.Current.Root);
|
|
141
|
-
|
|
142
|
-
// For example: { "services/postgresql.h.kumori": { name: "PostgreSQLService", type: "service" } }
|
|
143
|
-
const artifactNames = {};
|
|
142
|
+
const artifactNames = [];
|
|
144
143
|
for (const doc of moduleDocuments) {
|
|
145
144
|
const fileName = path.basename(doc.path);
|
|
146
145
|
if (fileName.endsWith(".h.kumori")) {
|
|
@@ -149,20 +148,33 @@ export function Action(log) {
|
|
|
149
148
|
const routeWithoutFileName = path.dirname(route);
|
|
150
149
|
const content = await kumoriFs.readFile(doc);
|
|
151
150
|
const lines = content.split("\n");
|
|
151
|
+
// Find package name from the file content
|
|
152
|
+
let packageName = "";
|
|
153
|
+
for (const line of lines) {
|
|
154
|
+
const packageMatch = line.match(/package\s+(\w+)/);
|
|
155
|
+
if (packageMatch) {
|
|
156
|
+
packageName = packageMatch[1];
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
152
160
|
for (const line of lines) {
|
|
153
161
|
const serviceMatch = line.match(/service\s+(\w+)/);
|
|
154
162
|
const componentMatch = line.match(/component\s+(\w+)/);
|
|
155
163
|
if (serviceMatch) {
|
|
156
|
-
artifactNames
|
|
164
|
+
artifactNames.push({
|
|
165
|
+
location: routeWithoutFileName,
|
|
166
|
+
package: packageName,
|
|
157
167
|
name: serviceMatch[1],
|
|
158
168
|
type: "service",
|
|
159
|
-
};
|
|
169
|
+
});
|
|
160
170
|
}
|
|
161
171
|
else if (componentMatch) {
|
|
162
|
-
artifactNames
|
|
172
|
+
artifactNames.push({
|
|
173
|
+
location: routeWithoutFileName,
|
|
174
|
+
package: packageName,
|
|
163
175
|
name: componentMatch[1],
|
|
164
176
|
type: "component",
|
|
165
|
-
};
|
|
177
|
+
});
|
|
166
178
|
}
|
|
167
179
|
}
|
|
168
180
|
}
|
|
@@ -183,24 +195,34 @@ export function Action(log) {
|
|
|
183
195
|
artifacts: [],
|
|
184
196
|
};
|
|
185
197
|
// For each artifact, create an index entry
|
|
186
|
-
for (const
|
|
198
|
+
for (const artifact of artifactNames) {
|
|
187
199
|
// Ask the user if we want to include this artifact
|
|
188
200
|
const includeArtifact = await confirm({
|
|
189
|
-
message: `Do you want to include artifact ${artifact.name} located at route ${
|
|
201
|
+
message: `Do you want to include artifact ${artifact.name} located at route ${artifact.location} in the index?`,
|
|
190
202
|
default: true,
|
|
191
203
|
});
|
|
192
204
|
if (!includeArtifact) {
|
|
193
205
|
continue;
|
|
194
206
|
}
|
|
195
207
|
// Generate the JSON Schema for the given artifact
|
|
196
|
-
const artifactSchema = await GetSchema(svcs, ctx.value,
|
|
208
|
+
const artifactSchema = await GetSchema(svcs, ctx.value, artifact.location, artifact.name);
|
|
197
209
|
if (Result.isErr(artifactSchema)) {
|
|
198
|
-
throw new Error(`Failed to generate JSON Schema for artifact ${artifact.name} at route ${
|
|
210
|
+
throw new Error(`Failed to generate JSON Schema for artifact ${artifact.name} at route ${artifact.location}: ${artifactSchema.err}`);
|
|
199
211
|
}
|
|
200
212
|
// Let's start asking the user for input for this artifact
|
|
213
|
+
let artifactLocation = "";
|
|
214
|
+
if (artifact.location === "") {
|
|
215
|
+
artifactLocation = artifact.package;
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
artifactLocation =
|
|
219
|
+
artifact.package !== ""
|
|
220
|
+
? `${artifact.location}/${artifact.package}`
|
|
221
|
+
: artifact.location;
|
|
222
|
+
}
|
|
201
223
|
const artifactRoute = await input({
|
|
202
|
-
message: `Enter the route for artifact ${artifact.name} (default: ${
|
|
203
|
-
default:
|
|
224
|
+
message: `Enter the <route>/<package> for artifact ${artifact.name} (default: ${artifactLocation}):`,
|
|
225
|
+
default: artifactLocation,
|
|
204
226
|
required: true,
|
|
205
227
|
});
|
|
206
228
|
const artifactDescription = await input({
|
|
@@ -1 +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,EAA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ACzE,CAAC;iBAAM,CAAC;gBACN,iCAAiC;gBACjC,MAAM,CAAC,OAAO,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"}
|
package/dist/lib/build.js
CHANGED
|
@@ -1,28 +1,42 @@
|
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import { getLogger } from "./logger.js";
|
|
2
|
+
import { RegistryManager } from "@kumori/kdsl-lsp/module/registry/manager.js";
|
|
3
|
+
import { BuildImpl } from "../build/main.js";
|
|
4
|
+
/**
|
|
5
|
+
* Produces deployable artifact specifications.
|
|
6
|
+
* Generates a solution.json file for a specified Kumori package.
|
|
7
|
+
*
|
|
8
|
+
* @param options - Build command options
|
|
9
|
+
* @returns Result with void on success, or string[] of errors
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createKumoriServices } from '@kumori/kdsl-lsp/language/kumori.js'
|
|
14
|
+
* import { NodeFileSystem } from 'langium/node'
|
|
15
|
+
* import { build } from '@kumori/kdsl'
|
|
16
|
+
*
|
|
17
|
+
* const services = createKumoriServices(NodeFileSystem).Kumori
|
|
18
|
+
*
|
|
19
|
+
* const result = await build({
|
|
20
|
+
* services,
|
|
21
|
+
* package: 'my-package',
|
|
22
|
+
* directory: '.'
|
|
23
|
+
* })
|
|
24
|
+
*
|
|
25
|
+
* if (result.ok) {
|
|
26
|
+
* console.log('Build succeeded!')
|
|
27
|
+
* } else {
|
|
28
|
+
* console.error('Errors:', result.err)
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export async function build(options) {
|
|
33
|
+
const log = getLogger(options.logger);
|
|
34
|
+
const pkgStr = options.package ?? ".";
|
|
35
|
+
const target = options.directory ?? options.cwd ?? ".";
|
|
36
|
+
const svcs = options.services;
|
|
37
|
+
const manager = new RegistryManager();
|
|
38
|
+
await manager.ensureIndexes();
|
|
39
|
+
// Use the shared BuildImpl function
|
|
40
|
+
return await BuildImpl(log, svcs, pkgStr, target);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=build.js.map
|
package/dist/lib/build.js.map
CHANGED
|
@@ -1 +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
|
|
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,OAAO,CAAC,OAAO,IAAI,GAAG,CAAA;IACrC,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,IAAI,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"}
|
package/dist/lib/check.js
CHANGED
|
@@ -1,15 +1,45 @@
|
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { getLogger } from "./logger.js";
|
|
2
|
+
import { Check as CheckImpl } from "../check/main.js";
|
|
3
|
+
import { ModuleContext } from "@kumori/kdsl-lsp/module/context.js";
|
|
4
|
+
import { URI } from "langium";
|
|
5
|
+
import { Result, Err } from "@kumori/kdsl-lsp/util/result.js";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
/**
|
|
8
|
+
* Typecheck and validate a Kumori module.
|
|
9
|
+
* Downloads dependencies unless skipDownload is true.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Check command options
|
|
12
|
+
* @returns Result with void on success, or string[] of errors
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { createKumoriServices } from '@kumori/kdsl-lsp/language/kumori.js'
|
|
17
|
+
* import { NodeFileSystem } from 'langium/node'
|
|
18
|
+
* import { check } from '@kumori/kdsl'
|
|
19
|
+
*
|
|
20
|
+
* const services = createKumoriServices(NodeFileSystem).Kumori
|
|
21
|
+
*
|
|
22
|
+
* const result = await check({
|
|
23
|
+
* services,
|
|
24
|
+
* directory: './my-module'
|
|
25
|
+
* })
|
|
26
|
+
*
|
|
27
|
+
* if (result.ok) {
|
|
28
|
+
* console.log('Check passed!')
|
|
29
|
+
* } else {
|
|
30
|
+
* console.error('Errors:', result.err)
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export async function check(options) {
|
|
35
|
+
const log = getLogger(options.logger);
|
|
36
|
+
const target = options.directory ?? options.cwd ?? ".";
|
|
37
|
+
const svcs = options.services;
|
|
38
|
+
const fs = svcs.shared.workspace.FileSystemProvider;
|
|
39
|
+
const ctx = await ModuleContext(fs, URI.file(path.resolve(target)));
|
|
40
|
+
if (Result.isErr(ctx)) {
|
|
41
|
+
return Err([ctx.err]);
|
|
42
|
+
}
|
|
43
|
+
return await CheckImpl(log, svcs, ctx.value);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=check.js.map
|
package/dist/lib/check.js.map
CHANGED
|
@@ -1 +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
|
|
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,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,IAAI,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"}
|
package/dist/lib/clean.js
CHANGED
|
@@ -1 +1,39 @@
|
|
|
1
|
-
var B=Object.defineProperty,j=Object.defineProperties;var A=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var w=(r,e,t)=>e in r?B(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,o=(r,e)=>{for(var t in e||(e={}))N.call(e,t)&&w(r,t,e[t]);if(T)for(var t of T(e))I.call(e,t)&&w(r,t,e[t]);return r},M=(r,e)=>j(r,A(e));var s=(r,e,t)=>(w(r,typeof e!="symbol"?e+"":e,t),t);var d=function(r){return r.info="info",r.warn="warn",r.error="error",r.debug="debug",r.trace="trace",r.fatal="fatal",r}({}),H={[d.trace]:10,[d.debug]:20,[d.info]:30,[d.warn]:40,[d.error]:50,[d.fatal]:60},Q={10:d.trace,20:d.debug,30:d.info,40:d.warn,50:d.error,60:d.fatal};var u=function(r){return r.onBeforeDataOut="onBeforeDataOut",r.shouldSendToLogger="shouldSendToLogger",r.onMetadataCalled="onMetadataCalled",r.onBeforeMessageOut="onBeforeMessageOut",r.onContextCalled="onContextCalled",r}({});var i=function(r){return r.info="info",r.warn="warn",r.error="error",r.debug="debug",r.trace="trace",r.fatal="fatal",r}({}),m={[i.trace]:10,[i.debug]:20,[i.info]:30,[i.warn]:40,[i.error]:50,[i.fatal]:60},Y={10:i.trace,20:i.debug,30:i.info,40:i.warn,50:i.error,60:i.fatal};var O=class P{constructor(){s(this,"context",{});s(this,"hasContext",!1)}setContext(e){if(!e){this.context={},this.hasContext=!1;return}this.context=e,this.hasContext=!0}appendContext(e){this.context=o(o({},this.context),e),this.hasContext=!0}getContext(){return this.context}hasContextData(){return this.hasContext}onChildLoggerCreated({parentContextManager:e,childContextManager:t}){if(e.hasContextData()){let n=e.getContext();t.setContext(o({},n))}}clone(){let e=new P;return e.setContext(o({},this.context)),e.hasContext=this.hasContext,e}};var y=class{constructor(r){s(this,"err");s(this,"metadata");s(this,"structuredLogger");s(this,"hasMetadata");s(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 n=r;return e.hasPlugins(u.onMetadataCalled)&&(n=e.runOnMetadataCalled(r,this.structuredLogger),!n)?(t&&console.debug("[LogLayer] Metadata was dropped due to plugin returning falsy value."),this):(this.metadata=o(o({},this.metadata),n),this.hasMetadata=!0,this)}withError(r){return this.err=r,this}info(...r){this.structuredLogger.isLevelEnabled(i.info)&&(this.structuredLogger._formatMessage(r),this.formatLog(i.info,r))}warn(...r){this.structuredLogger.isLevelEnabled(i.warn)&&(this.structuredLogger._formatMessage(r),this.formatLog(i.warn,r))}error(...r){this.structuredLogger.isLevelEnabled(i.error)&&(this.structuredLogger._formatMessage(r),this.formatLog(i.error,r))}debug(...r){this.structuredLogger.isLevelEnabled(i.debug)&&(this.structuredLogger._formatMessage(r),this.formatLog(i.debug,r))}trace(...r){this.structuredLogger.isLevelEnabled(i.trace)&&(this.structuredLogger._formatMessage(r),this.formatLog(i.trace,r))}fatal(...r){this.structuredLogger.isLevelEnabled(i.fatal)&&(this.structuredLogger._formatMessage(r),this.formatLog(i.fatal,r))}disableLogging(){return this.structuredLogger.disableLogging(),this}enableLogging(){return this.structuredLogger.enableLogging(),this}formatLog(r,e){let{muteMetadata:t}=this.structuredLogger._config,n=t?!1:this.hasMetadata;this.structuredLogger._formatLog({logLevel:r,params:e,metadata:n?this.metadata:null,err:this.err})}},z=[u.onBeforeDataOut,u.onMetadataCalled,u.shouldSendToLogger,u.onBeforeMessageOut,u.onContextCalled],F=class{constructor(r){s(this,"idToPlugin");s(this,"onBeforeDataOut",[]);s(this,"shouldSendToLogger",[]);s(this,"onMetadataCalled",[]);s(this,"onBeforeMessageOut",[]);s(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 z)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=o({},r);for(let n of this.onBeforeDataOut){let a=this.idToPlugin[n];if(a.onBeforeDataOut){let l=a.onBeforeDataOut({data:t.data,logLevel:t.logLevel,error:t.error,metadata:t.metadata,context:t.context},e);l&&(t.data||(t.data={}),Object.assign(t.data,l))}}return t.data}runShouldSendToLogger(r,e){return!this.shouldSendToLogger.some(t=>{var n,a;return!((a=(n=this.idToPlugin[t]).shouldSendToLogger)!=null&&a.call(n,r,e))})}runOnMetadataCalled(r,e){var n,a;let t=o({},r);for(let l of this.onMetadataCalled){let h=(a=(n=this.idToPlugin[l]).onMetadataCalled)==null?void 0:a.call(n,t,e);if(h)t=h;else return null}return t}runOnBeforeMessageOut(r,e){var n,a;let t=[...r.messages];for(let l of this.onBeforeMessageOut){let h=(a=(n=this.idToPlugin[l]).onBeforeMessageOut)==null?void 0:a.call(n,{messages:t,logLevel:r.logLevel},e);h&&(t=h)}return t}runOnContextCalled(r,e){var n,a;let t=o({},r);for(let l of this.onContextCalled){let h=(a=(n=this.idToPlugin[l]).onContextCalled)==null?void 0:a.call(n,t,e);if(h)t=h;else return null}return t}},D=class S{constructor(e){s(this,"pluginManager");s(this,"idToTransport");s(this,"hasMultipleTransports");s(this,"singleTransport");s(this,"contextManager");s(this,"logLevelEnabledStatus",{info:!0,warn:!0,error:!0,debug:!0,trace:!0,fatal:!0});s(this,"_config");var t;this._config=M(o({},e),{enabled:(t=e.enabled)!=null?t:!0}),this._config.enabled||this.disableLogging(),this.contextManager=new O,this.pluginManager=new F(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,n)=>(t[n.id]=n,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(u.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 y(this).withMetadata(e)}withError(e){return new y(this).withError(e)}child(){let e=new S(M(o({},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 F(e),this}withPluginManager(e){return this.pluginManager=e,this}errorOnly(e,t){let n=(t==null?void 0:t.logLevel)||i.error;if(!this.isLevelEnabled(n))return;let{copyMsgOnOnlyError:a}=this._config,l={logLevel:n,err:e};(a&&(t==null?void 0:t.copyMsg)!==!1||(t==null?void 0:t.copyMsg)===!0)&&(e!=null&&e.message)&&(l.params=[e.message]),this._formatLog(l)}metadataOnly(e,t=i.info){if(!this.isLevelEnabled(t))return;let{muteMetadata:n,consoleDebug:a}=this._config;if(n)return;if(!e){a&&console.debug("[LogLayer] metadataOnly was called with no metadata; dropping.");return}let l=e;if(this.pluginManager.hasPlugins(u.onMetadataCalled)&&(l=this.pluginManager.runOnMetadataCalled(e,this),!l)){a&&console.debug("[LogLayer] Metadata was dropped due to plugin returning falsy value.");return}let h={logLevel:t,metadata:l};this._formatLog(h)}info(...e){this.isLevelEnabled(i.info)&&(this._formatMessage(e),this._formatLog({logLevel:i.info,params:e}))}warn(...e){this.isLevelEnabled(i.warn)&&(this._formatMessage(e),this._formatLog({logLevel:i.warn,params:e}))}error(...e){this.isLevelEnabled(i.error)&&(this._formatMessage(e),this._formatLog({logLevel:i.error,params:e}))}debug(...e){this.isLevelEnabled(i.debug)&&(this._formatMessage(e),this._formatLog({logLevel:i.debug,params:e}))}trace(...e){this.isLevelEnabled(i.trace)&&(this._formatMessage(e),this._formatLog({logLevel:i.trace,params:e}))}fatal(...e){this.isLevelEnabled(i.fatal)&&(this._formatMessage(e),this._formatLog({logLevel:i.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=m[e];for(let n of Object.values(i)){let a=n,l=m[n];this.logLevelEnabledStatus[a]=l>=t}return this}isLevelEnabled(e){let t=e;return this.logLevelEnabledStatus[t]}formatContext(e){let{contextFieldName:t,muteContext:n}=this._config;return e&&Object.keys(e).length>0&&!n?t?{[t]:o({},e)}:o({},e):{}}formatMetadata(e=null){let{metadataFieldName:t,muteMetadata:n}=this._config;return e&&!n?t?{[t]:o({},e)}:o({},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:n=null,err:a,context:l=null}){var _;let{errorSerializer:h,errorFieldInMetadata:C,muteContext:k,contextFieldName:x,metadataFieldName:f,errorFieldName:v}=this._config,p=l!==null?l:this.contextManager.getContext(),c=!!n||(k?!1:l!==null?Object.keys(l).length>0:this.contextManager.hasContextData()),g={};if(c)if(x&&x===f){let L=this.formatContext(p)[x],b=this.formatMetadata(n)[f];g={[x]:o(o({},L),b)}}else g=o(o({},this.formatContext(p)),this.formatMetadata(n));if(a){let L=h?h(a):a;C&&n&&f?g!=null&&g[f]?g[f][v]=L:g=M(o({},g),{[f]:{[v]:L}}):C&&!n&&f?g=M(o({},g),{[f]:{[v]:L}}):g=M(o({},g),{[v]:L}),c=!0}if(this.pluginManager.hasPlugins(u.onBeforeDataOut)&&(g=this.pluginManager.runOnBeforeDataOut({data:c?g:void 0,logLevel:e,error:a,metadata:n,context:p},this),g&&!c&&(c=!0)),this.pluginManager.hasPlugins(u.onBeforeMessageOut)&&(t=this.pluginManager.runOnBeforeMessageOut({messages:[...t],logLevel:e},this)),this.hasMultipleTransports){let L=this._config.transport.filter(b=>b.enabled).map(async b=>{if(!(this.pluginManager.hasPlugins(u.shouldSendToLogger)&&!this.pluginManager.runShouldSendToLogger({messages:[...t],data:c?g:void 0,logLevel:e,transportId:b.id,error:a,metadata:n,context:p},this)))return b._sendToLogger({logLevel:e,messages:[...t],data:c?g:void 0,hasData:c,error:a,metadata:n,context:p})});Promise.all(L).catch(b=>{this._config.consoleDebug&&console.error("[LogLayer] Error executing transports:",b)})}else{if(!((_=this.singleTransport)!=null&&_.enabled)||this.pluginManager.hasPlugins(u.shouldSendToLogger)&&!this.pluginManager.runShouldSendToLogger({messages:[...t],data:c?g:void 0,logLevel:e,transportId:this.singleTransport.id,error:a,metadata:n,context:p},this))return;this.singleTransport._sendToLogger({logLevel:e,messages:[...t],data:c?g:void 0,hasData:c,error:a,metadata:n,context:p})}}};function J(){let r={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}};return new D({transport:r})}function E(r){return r!=null?r:J()}import{TempCache as K}from"@kumori/kdsl-lsp/util/tmp.js";import{rm as R}from"fs/promises";import{Ok as V,Err as q}from"@kumori/kdsl-lsp/util/result.js";async function ve(r={}){let e=E(r.logger);try{let t=await K();return e.info(t.fsPath),await R(t.fsPath,{force:!0,recursive:!0}),V(void 0)}catch(t){return q([String(t)])}}export{ve as clean};
|
|
1
|
+
import { getLogger } from "./logger.js";
|
|
2
|
+
import { TempCache } from "@kumori/kdsl-lsp/util/tmp.js";
|
|
3
|
+
import { rm } from "fs/promises";
|
|
4
|
+
import { Ok, Err } from "@kumori/kdsl-lsp/util/result.js";
|
|
5
|
+
/**
|
|
6
|
+
* Remove cached files.
|
|
7
|
+
*
|
|
8
|
+
* The kdsl command builds most artifacts in a temporary directory,
|
|
9
|
+
* so clean is mainly concerned with files left by manual invocations.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Clean command options
|
|
12
|
+
* @returns Result with void on success, or string[] of errors
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { clean } from '@kumori/kdsl'
|
|
17
|
+
*
|
|
18
|
+
* const result = await clean()
|
|
19
|
+
*
|
|
20
|
+
* if (result.ok) {
|
|
21
|
+
* console.log('Cache cleaned!')
|
|
22
|
+
* } else {
|
|
23
|
+
* console.error('Errors:', result.err)
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export async function clean(options = {}) {
|
|
28
|
+
const log = getLogger(options.logger);
|
|
29
|
+
try {
|
|
30
|
+
const location = await TempCache();
|
|
31
|
+
log.info(location.fsPath);
|
|
32
|
+
await rm(location.fsPath, { force: true, recursive: true });
|
|
33
|
+
return Ok(undefined);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
return Err([String(err)]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=clean.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LibraryOptions, LibraryResult } from "./types.js";
|
|
2
|
+
export interface DeploymentGenOptions extends LibraryOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Path to the deployment-config.json file.
|
|
5
|
+
* Defaults to 'deployment-config.json' in the current directory.
|
|
6
|
+
*/
|
|
7
|
+
input?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Output directory for generated deployment artifacts.
|
|
10
|
+
* Defaults to cwd or '.'
|
|
11
|
+
*/
|
|
12
|
+
output?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generates deployment artifacts based on the provided deployment configuration.
|
|
16
|
+
*
|
|
17
|
+
* @param options - Deployment generation options
|
|
18
|
+
* @returns Promise that resolves when generation is complete
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { createKumoriServices } from '@kumori/kdsl-lsp/language/kumori.js'
|
|
23
|
+
* import { NodeFileSystem } from 'langium/node'
|
|
24
|
+
* import { generateDeployment } from '@kumori/kdsl'
|
|
25
|
+
*
|
|
26
|
+
* const services = createKumoriServices(NodeFileSystem).Kumori
|
|
27
|
+
*
|
|
28
|
+
* await generateDeployment({
|
|
29
|
+
* services,
|
|
30
|
+
* input: 'path/to/deployment-config.json',
|
|
31
|
+
* output: 'path/to/output/directory'
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function generateDeployment(options: DeploymentGenOptions): Promise<LibraryResult<void>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getLogger } from "./logger.js";
|
|
2
|
+
import { GenDeployment } from "../deployment/gen/main.js";
|
|
3
|
+
/**
|
|
4
|
+
* Generates deployment artifacts based on the provided deployment configuration.
|
|
5
|
+
*
|
|
6
|
+
* @param options - Deployment generation options
|
|
7
|
+
* @returns Promise that resolves when generation is complete
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { createKumoriServices } from '@kumori/kdsl-lsp/language/kumori.js'
|
|
12
|
+
* import { NodeFileSystem } from 'langium/node'
|
|
13
|
+
* import { generateDeployment } from '@kumori/kdsl'
|
|
14
|
+
*
|
|
15
|
+
* const services = createKumoriServices(NodeFileSystem).Kumori
|
|
16
|
+
*
|
|
17
|
+
* await generateDeployment({
|
|
18
|
+
* services,
|
|
19
|
+
* input: 'path/to/deployment-config.json',
|
|
20
|
+
* output: 'path/to/output/directory'
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export async function generateDeployment(options) {
|
|
25
|
+
const log = getLogger(options.logger);
|
|
26
|
+
const inputPath = options.input ?? "deployment-config.json";
|
|
27
|
+
const outputDir = options.output ?? options.cwd ?? ".";
|
|
28
|
+
const svcs = options.services;
|
|
29
|
+
return await GenDeployment(log, svcs, inputPath, outputDir);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=deployment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../../src/lib/deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAgBzD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAA6B;IAE7B,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACrC,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,wBAAwB,CAAA;IAC3D,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,IAAI,GAAG,CAAA;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAA;IAE7B,OAAO,MAAM,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;AAC7D,CAAC"}
|