@effected/engine 0.17.2 → 0.18.0
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/build/ActionInit.js +4 -1
- package/package.json +4 -4
- package/schema/ConfigLoader.js +12 -5
- package/schema/Runner.js +5 -1
- package/schema/SchemaRun.js +2 -0
- package/schema.d.ts +17 -0
package/build/ActionInit.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NotAPackageError } from "./BuildRun.js";
|
|
2
2
|
import { ErrorText, PathContainment } from "@effected/kit";
|
|
3
3
|
import { Effect, FileSystem, Path, Predicate, Result, Schema } from "effect";
|
|
4
|
+
import { EffectedConfigSchema } from "@effected/bundler";
|
|
4
5
|
import { AtomicFile } from "@effected/files";
|
|
5
6
|
|
|
6
7
|
// src/build/ActionInit.ts
|
|
@@ -166,7 +167,9 @@ const DEV_DEPENDENCIES = [
|
|
|
166
167
|
const isControl = (code) => code < 32 && code !== 9 || code >= 127 && code <= 159;
|
|
167
168
|
const codePoint = (character) => `U+${(character.codePointAt(0) ?? 0).toString(16).toUpperCase().padStart(4, "0")}`;
|
|
168
169
|
const yamlString = (value) => JSON.stringify(value).replace(/[\u007F-\u009F\u2028\u2029]/g, (character) => `\\u${codePoint(character).slice(2)}`);
|
|
169
|
-
const effectedToml =
|
|
170
|
+
const effectedToml = `${EffectedConfigSchema.directive}
|
|
171
|
+
|
|
172
|
+
# \`effected action build\` reads the [action] tables. A key left out takes its default.
|
|
170
173
|
|
|
171
174
|
[action.entries]
|
|
172
175
|
main = "src/main.ts"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The effected tool's shared logic, consumed by its CLI and MCP front ends",
|
|
6
6
|
"keywords": [
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@effected/bundler": "0.
|
|
49
|
+
"@effected/bundler": "0.6.0",
|
|
50
50
|
"@effected/files": "0.3.0",
|
|
51
51
|
"@effected/jsonc": "0.25.0",
|
|
52
52
|
"@effected/jsonl": "0.19.0",
|
|
53
53
|
"@effected/kit": "0.14.0",
|
|
54
|
-
"@effected/schemastore": "0.
|
|
54
|
+
"@effected/schemastore": "0.33.0",
|
|
55
55
|
"@effected/source": "0.5.0",
|
|
56
|
-
"@effected/workspaces": "0.47.
|
|
56
|
+
"@effected/workspaces": "0.47.1",
|
|
57
57
|
"ajv": "8.20.0",
|
|
58
58
|
"ajv-formats": "3.0.1",
|
|
59
59
|
"effect": "4.1.4",
|
package/schema/ConfigLoader.js
CHANGED
|
@@ -49,15 +49,21 @@ const IN_NODE_MODULES = /[\\/]node_modules[\\/]/;
|
|
|
49
49
|
const jitiImport = async (path, source) => {
|
|
50
50
|
const { cache } = createRequire(path);
|
|
51
51
|
for (const key of Object.keys(cache)) if (key.endsWith(".json") && !IN_NODE_MODULES.test(key)) Reflect.deleteProperty(cache, key);
|
|
52
|
-
|
|
52
|
+
const jiti = createJiti(path, {
|
|
53
53
|
interopDefault: true,
|
|
54
54
|
moduleCache: false,
|
|
55
55
|
fsCache: false
|
|
56
|
-
})
|
|
56
|
+
});
|
|
57
|
+
const module = await jiti.evalModule(source, {
|
|
57
58
|
filename: path,
|
|
58
59
|
async: true,
|
|
59
60
|
forceTranspile: true
|
|
60
61
|
});
|
|
62
|
+
const lower = await jiti.import("effect/Schema").then((schema) => schema.toJsonSchemaDocument, () => void 0);
|
|
63
|
+
return typeof lower === "function" ? {
|
|
64
|
+
module,
|
|
65
|
+
toJsonSchemaDocument: lower
|
|
66
|
+
} : { module };
|
|
61
67
|
};
|
|
62
68
|
const describeCause = (cause) => {
|
|
63
69
|
return (Predicate.hasProperty(cause, "stack") && Predicate.isString(cause.stack) && cause.stack.trim() !== "" ? cause.stack : void 0) ?? causeMessage(cause) ?? String(cause);
|
|
@@ -238,10 +244,10 @@ var ConfigLoader = class ConfigLoader {
|
|
|
238
244
|
path: configPath,
|
|
239
245
|
reason: describeImportFailure(cause)
|
|
240
246
|
});
|
|
241
|
-
const module = importModule !== void 0 ? yield* Effect.tryPromise({
|
|
247
|
+
const { module, toJsonSchemaDocument } = importModule !== void 0 ? { module: yield* Effect.tryPromise({
|
|
242
248
|
try: () => importModule(configPath),
|
|
243
249
|
catch: failed
|
|
244
|
-
}) : yield* fs.readFileString(configPath).pipe(Effect.mapError(failed), Effect.flatMap((source) => Effect.tryPromise({
|
|
250
|
+
}) } : yield* fs.readFileString(configPath).pipe(Effect.mapError(failed), Effect.flatMap((source) => Effect.tryPromise({
|
|
245
251
|
try: () => jitiImport(configPath, source),
|
|
246
252
|
catch: failed
|
|
247
253
|
})));
|
|
@@ -265,7 +271,8 @@ var ConfigLoader = class ConfigLoader {
|
|
|
265
271
|
return {
|
|
266
272
|
path: configPath,
|
|
267
273
|
directory,
|
|
268
|
-
config
|
|
274
|
+
config,
|
|
275
|
+
...toJsonSchemaDocument !== void 0 ? { toJsonSchemaDocument } : {}
|
|
269
276
|
};
|
|
270
277
|
});
|
|
271
278
|
};
|
package/schema/Runner.js
CHANGED
|
@@ -96,7 +96,7 @@ const listingFailureReason = (error) => {
|
|
|
96
96
|
default: return error.reason.description ?? error.reason._tag;
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
const
|
|
99
|
+
const basePipelineOptions = { contractChanges: "allow" };
|
|
100
100
|
const orNone = (read) => read.pipe(Effect.map(Option.some), Effect.catchIf((error) => error.reason._tag === "NotFound", () => Effect.succeed(Option.none())));
|
|
101
101
|
const pendingOutcome = (wouldWrite, refused) => !wouldWrite ? "unchanged" : refused ? "held" : "would-write";
|
|
102
102
|
const declaredId = (text) => {
|
|
@@ -376,6 +376,10 @@ const syncCatalog = Effect.fn("Runner.syncCatalog")(function* (config, names, wr
|
|
|
376
376
|
var Runner = class {
|
|
377
377
|
constructor() {}
|
|
378
378
|
static run = Effect.fn("Runner.run")(function* (config, options) {
|
|
379
|
+
const pipelineOptions = options.toJsonSchemaDocument !== void 0 ? {
|
|
380
|
+
...basePipelineOptions,
|
|
381
|
+
toJsonSchemaDocument: options.toJsonSchemaDocument
|
|
382
|
+
} : basePipelineOptions;
|
|
379
383
|
const fs = yield* FileSystem.FileSystem;
|
|
380
384
|
const path = yield* Path.Path;
|
|
381
385
|
const missing = [];
|
package/schema/SchemaRun.js
CHANGED
|
@@ -83,11 +83,13 @@ var SchemaRun = class {
|
|
|
83
83
|
...Option.isSome(mismatch) ? { versionMismatch: mismatch.value } : {}
|
|
84
84
|
}) ?? Effect.void;
|
|
85
85
|
const policy = input.force ? "allow" : input.drift;
|
|
86
|
+
const lower = loaded.toJsonSchemaDocument ?? deps.toJsonSchemaDocument;
|
|
86
87
|
const report = yield* Runner.run(loaded.config, {
|
|
87
88
|
mode: input.mode,
|
|
88
89
|
configPath: loaded.path,
|
|
89
90
|
onDrift: input.onDrift ?? loaded.config.onDrift,
|
|
90
91
|
...policy !== void 0 ? { policy } : {},
|
|
92
|
+
...lower !== void 0 ? { toJsonSchemaDocument: lower } : {},
|
|
91
93
|
...onProgress !== void 0 ? { onChecked: (checked) => onProgress({
|
|
92
94
|
_tag: "SchemaChecked",
|
|
93
95
|
...checked
|
package/schema.d.ts
CHANGED
|
@@ -162,6 +162,13 @@ interface LoadedConfig {
|
|
|
162
162
|
readonly directory: string;
|
|
163
163
|
/** The config, with its paths resolved. */
|
|
164
164
|
readonly config: SchemastoreConfig;
|
|
165
|
+
/**
|
|
166
|
+
* `Schema.toJsonSchemaDocument` from the `effect` beside the config, the
|
|
167
|
+
* copy its schemas were built with. Absent when none resolves there, or
|
|
168
|
+
* when an injected `importModule` loaded the config; the tool's own copy
|
|
169
|
+
* lowers the schemas then.
|
|
170
|
+
*/
|
|
171
|
+
readonly toJsonSchemaDocument?: typeof Schema.toJsonSchemaDocument;
|
|
165
172
|
}
|
|
166
173
|
/**
|
|
167
174
|
* Options for {@link ConfigLoader.load}.
|
|
@@ -744,6 +751,11 @@ interface RunOptions {
|
|
|
744
751
|
readonly policy?: DriftTolerance;
|
|
745
752
|
/** Told as each schema's check finishes, before the next one starts. */
|
|
746
753
|
readonly onChecked?: (checked: SchemaChecked) => Effect.Effect<void>;
|
|
754
|
+
/**
|
|
755
|
+
* The generator of the `effect` copy that built the config's schemas
|
|
756
|
+
* ({@link LoadedConfig.toJsonSchemaDocument}); omitted, the tool's own.
|
|
757
|
+
*/
|
|
758
|
+
readonly toJsonSchemaDocument?: LoadedConfig["toJsonSchemaDocument"];
|
|
747
759
|
}
|
|
748
760
|
/**
|
|
749
761
|
* The shared `build` / `check` walk: verify every advertised frozen version
|
|
@@ -909,6 +921,11 @@ interface SchemaRunDeps {
|
|
|
909
921
|
readonly instanceValidator?: Layer.Layer<InstanceValidator>;
|
|
910
922
|
/** Told when the walk starts and of each schema's report. */
|
|
911
923
|
readonly onProgress?: (event: SchemaProgress) => Effect.Effect<void>;
|
|
924
|
+
/**
|
|
925
|
+
* The generator of the `effect` copy beside the config, for a caller that loaded the config itself and hands it in
|
|
926
|
+
* through `importModule`, which resolves none. Omitted, the loader's own resolution, then the tool's copy.
|
|
927
|
+
*/
|
|
928
|
+
readonly toJsonSchemaDocument?: LoadedConfig["toJsonSchemaDocument"];
|
|
912
929
|
}
|
|
913
930
|
declare const SchemaRunResult_base: Schema.Class<SchemaRunResult, Schema.Struct<{
|
|
914
931
|
readonly report: typeof RunReport;
|