@okfit/engine 0.15.0 → 0.16.1
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/config/anchor.js +1 -1
- package/config/layer.js +1 -1
- package/errors.js +81 -6
- package/index.d.ts +288 -7
- package/index.js +7 -3
- package/move/references.js +267 -0
- package/move/run.js +212 -0
- package/package.json +18 -19
- package/render/move.js +52 -0
- package/sync/index.js +4 -3
- package/targets/inside.js +15 -0
- package/targets/resolve.js +146 -0
- package/verify/run.js +63 -27
- package/version.js +1 -1
package/config/anchor.js
CHANGED
|
@@ -47,7 +47,7 @@ const resolveProjectRoot = (input) => {
|
|
|
47
47
|
* `<project root>/<bundle.path>`, absolute (K-2). `config` is the MERGED
|
|
48
48
|
* config, so `bundle.path` is `OkfitConfig.DEFAULTS.bundle.path` (`"okf"`)
|
|
49
49
|
* unless a file or profile overrode it. The bundle root is never what
|
|
50
|
-
* `
|
|
50
|
+
* `--root` names.
|
|
51
51
|
*
|
|
52
52
|
* @public
|
|
53
53
|
*/
|
package/config/layer.js
CHANGED
|
@@ -31,7 +31,7 @@ import { Cause, Effect, FileSystem, Option, Result } from "effect";
|
|
|
31
31
|
* `save`/`update` do not fail with `ConfigDefaultPathMissingError`; nothing
|
|
32
32
|
* here sets it explicitly any more.
|
|
33
33
|
*
|
|
34
|
-
* `discoveryCwd` is `
|
|
34
|
+
* `discoveryCwd` is `--root` when given, else `process.cwd()` (K-2), passed
|
|
35
35
|
* straight through as `upwardWalk`'s own `cwd` so nothing in this module
|
|
36
36
|
* reads the process.
|
|
37
37
|
*
|
package/errors.js
CHANGED
|
@@ -174,7 +174,7 @@ var SyncPublicationConflictError = class extends Schema.TaggedError()("SyncPubli
|
|
|
174
174
|
var VerifySelectionError = class extends Schema.TaggedError()("VerifySelectionError", {
|
|
175
175
|
reason: Schema.Literals([
|
|
176
176
|
"no-selection",
|
|
177
|
-
"
|
|
177
|
+
"targets-and-batch",
|
|
178
178
|
"unknown-type",
|
|
179
179
|
"status-conflict",
|
|
180
180
|
"status-and-batch",
|
|
@@ -187,12 +187,12 @@ var VerifySelectionError = class extends Schema.TaggedError()("VerifySelectionEr
|
|
|
187
187
|
[Runtime.errorExitCode] = 64;
|
|
188
188
|
get message() {
|
|
189
189
|
if (this.reason === "no-selection") return "verify needs a concept id, --all, or --type <Type> (run in a terminal to pick interactively)";
|
|
190
|
-
if (this.reason === "
|
|
191
|
-
if (this.reason === "revoke-needs-id") return "--revoke needs
|
|
192
|
-
if (this.reason === "revoke-conflict") return `--revoke removes your own verification of
|
|
190
|
+
if (this.reason === "targets-and-batch") return "verify takes concept targets or --all/--type, not both";
|
|
191
|
+
if (this.reason === "revoke-needs-id") return "--revoke needs at least one concept target";
|
|
192
|
+
if (this.reason === "revoke-conflict") return `--revoke removes your own verification of the named concepts; it cannot combine with ${this.detail ?? "other selectors"}`;
|
|
193
193
|
if (this.reason === "status-conflict") return "verify takes --stable or --draft, not both";
|
|
194
194
|
if (this.reason === "dry-run-needs-verify") return "--dry-run needs --verify; bare okfit stale writes nothing";
|
|
195
|
-
if (this.reason === "status-and-batch") return "--stable and --draft need
|
|
195
|
+
if (this.reason === "status-and-batch") return "--stable and --draft need exactly one concept target; batch mode never changes status";
|
|
196
196
|
return `type "${this.detail ?? ""}" is not declared in the config`;
|
|
197
197
|
}
|
|
198
198
|
};
|
|
@@ -272,6 +272,81 @@ var QuerySelectionError = class extends Schema.TaggedError()("QuerySelectionErro
|
|
|
272
272
|
return "query list takes --verified or --unverified, not both";
|
|
273
273
|
}
|
|
274
274
|
};
|
|
275
|
+
/**
|
|
276
|
+
* One argument that did not resolve to a concept target.
|
|
277
|
+
*
|
|
278
|
+
* @public
|
|
279
|
+
*/
|
|
280
|
+
const TargetFailure = Schema.Struct({
|
|
281
|
+
arg: Schema.String,
|
|
282
|
+
reason: Schema.Literals([
|
|
283
|
+
"not-found",
|
|
284
|
+
"ambiguous",
|
|
285
|
+
"outside-bundle",
|
|
286
|
+
"reserved",
|
|
287
|
+
"not-a-concept"
|
|
288
|
+
]),
|
|
289
|
+
suggestion: Schema.optionalKey(Schema.String),
|
|
290
|
+
candidates: Schema.optionalKey(Schema.Tuple([Schema.String, Schema.String]))
|
|
291
|
+
});
|
|
292
|
+
const targetLine = (failure) => {
|
|
293
|
+
switch (failure.reason) {
|
|
294
|
+
case "ambiguous": return `"${failure.arg}" is ambiguous: it names both ${failure.candidates?.[0]} and ${failure.candidates?.[1]}; pass an id or an absolute path`;
|
|
295
|
+
case "outside-bundle": return `"${failure.arg}" is outside the bundle`;
|
|
296
|
+
case "reserved": return `"${failure.arg}" is a reserved file, not a concept`;
|
|
297
|
+
case "not-a-concept": return `"${failure.arg}" did not load as a concept (run okfit validate)`;
|
|
298
|
+
default: return `no concept "${failure.arg}"${failure.suggestion === void 0 ? "" : ` (did you mean ${failure.suggestion}?)`}`;
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* One or more concept targets did not resolve. Every bad argument is listed;
|
|
303
|
+
* nothing ran. Exit 64: a usage error.
|
|
304
|
+
*
|
|
305
|
+
* @public
|
|
306
|
+
*/
|
|
307
|
+
var TargetResolutionError = class extends Schema.TaggedError()("TargetResolutionError", { failures: Schema.Array(TargetFailure) }) {
|
|
308
|
+
[Runtime.errorExitCode] = 64;
|
|
309
|
+
get message() {
|
|
310
|
+
return this.failures.map(targetLine).join("\n");
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* `okfit mv` refused before writing anything. `outside-bundle`, `destination-exists`, `reserved`,
|
|
315
|
+
* `same-path` and `invalid-name` (whitespace in a destination path segment) name a bad destination
|
|
316
|
+
* (`detail` is the destination); `unrewritable` lists every link that needs rewriting for this move
|
|
317
|
+
* (`file: url`, one per line) whose URL text could not be located; `project-file` refuses to move the
|
|
318
|
+
* bundle's root project file (`detail` is its path), which must stay at the bundle root;
|
|
319
|
+
* `unloaded-files` lists (one per line) the bundle's Markdown files that did not load as concepts,
|
|
320
|
+
* whose links to the moved file could not be rewritten.
|
|
321
|
+
*
|
|
322
|
+
* @public
|
|
323
|
+
*/
|
|
324
|
+
var MoveError = class extends Schema.TaggedError()("MoveError", {
|
|
325
|
+
reason: Schema.Literals([
|
|
326
|
+
"outside-bundle",
|
|
327
|
+
"destination-exists",
|
|
328
|
+
"reserved",
|
|
329
|
+
"same-path",
|
|
330
|
+
"invalid-name",
|
|
331
|
+
"unrewritable",
|
|
332
|
+
"project-file",
|
|
333
|
+
"unloaded-files"
|
|
334
|
+
]),
|
|
335
|
+
detail: Schema.optionalKey(Schema.String)
|
|
336
|
+
}) {
|
|
337
|
+
[Runtime.errorExitCode] = 64;
|
|
338
|
+
get message() {
|
|
339
|
+
const detail = this.detail ?? "";
|
|
340
|
+
if (this.reason === "outside-bundle") return `destination ${detail} is outside the bundle`;
|
|
341
|
+
if (this.reason === "destination-exists") return `destination ${detail} already exists`;
|
|
342
|
+
if (this.reason === "reserved") return `${detail} is a reserved file name`;
|
|
343
|
+
if (this.reason === "same-path") return "source and destination are the same file";
|
|
344
|
+
if (this.reason === "invalid-name") return `destination ${detail} contains whitespace; name it without spaces`;
|
|
345
|
+
if (this.reason === "project-file") return `${detail} is the bundle's project file and must stay at the bundle root; edit it in place`;
|
|
346
|
+
if (this.reason === "unloaded-files") return `these Markdown files are in the bundle but did not load as concepts, so their links to the moved file cannot be rewritten; run \`okfit validate\` and fix them first:\n${detail}`;
|
|
347
|
+
return `these links could not be located for rewriting; nothing was moved:\n${detail}`;
|
|
348
|
+
}
|
|
349
|
+
};
|
|
275
350
|
|
|
276
351
|
//#endregion
|
|
277
|
-
export { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, SyncStagedLogError, VerifyConceptNotFoundError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError };
|
|
352
|
+
export { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, SyncStagedLogError, TargetFailure, TargetResolutionError, VerifyConceptNotFoundError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError };
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Actor, BundleLoadError, ConceptId, Diagnostic, DiagnosticRange, DiagnosticSeverity, GraphLink, GraphNode, GraphNodeKind, LinkGraph, LoadedBundle, LoadedConcept, OkfitConfig, OkfitConfigFile, StaleConcept, Status, ValidationReport } from "@okfit/core";
|
|
1
|
+
import { Actor, BundleLoadError, ConceptId, Diagnostic, DiagnosticRange, DiagnosticSeverity, GraphLink, GraphNode, GraphNodeKind, LinkGraph, LoadedBundle, LoadedConcept, OkfitConfig, OkfitConfigFile, PathField, StaleConcept, Status, ValidationReport } from "@okfit/core";
|
|
2
2
|
import { Context, Crypto, DateTime, Effect, FileSystem, Layer, Option, Path, PlatformError, Result, Runtime, Schema } from "effect";
|
|
3
3
|
import { AppDirs, Xdg } from "@effected/xdg";
|
|
4
4
|
import { ConfigReadError } from "@effected/config-file";
|
|
@@ -65,7 +65,7 @@ export declare const resolveProjectRoot: (input: {
|
|
|
65
65
|
* `<project root>/<bundle.path>`, absolute (K-2). `config` is the MERGED
|
|
66
66
|
* config, so `bundle.path` is `OkfitConfig.DEFAULTS.bundle.path` (`"okf"`)
|
|
67
67
|
* unless a file or profile overrode it. The bundle root is never what
|
|
68
|
-
* `
|
|
68
|
+
* `--root` names.
|
|
69
69
|
*
|
|
70
70
|
* @public
|
|
71
71
|
*/
|
|
@@ -217,7 +217,7 @@ export declare class SyncPublicationConflictError extends SyncPublicationConflic
|
|
|
217
217
|
get message(): string;
|
|
218
218
|
}
|
|
219
219
|
declare const VerifySelectionError_base: Schema.Class<VerifySelectionError, Schema.TaggedStruct<"VerifySelectionError", {
|
|
220
|
-
readonly reason: Schema.Literals<readonly ["no-selection", "
|
|
220
|
+
readonly reason: Schema.Literals<readonly ["no-selection", "targets-and-batch", "unknown-type", "status-conflict", "status-and-batch", "dry-run-needs-verify", "revoke-needs-id", "revoke-conflict"]>;
|
|
221
221
|
readonly detail: Schema.optionalKey<Schema.String>;
|
|
222
222
|
}>, import("effect/Cause").YieldableError>;
|
|
223
223
|
/**
|
|
@@ -289,6 +289,56 @@ export declare class QuerySelectionError extends QuerySelectionError_base {
|
|
|
289
289
|
readonly [Runtime.errorExitCode] = 64;
|
|
290
290
|
get message(): string;
|
|
291
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* One argument that did not resolve to a concept target.
|
|
294
|
+
*
|
|
295
|
+
* @public
|
|
296
|
+
*/
|
|
297
|
+
export declare const TargetFailure: Schema.Struct<{
|
|
298
|
+
readonly arg: Schema.String;
|
|
299
|
+
readonly reason: Schema.Literals<readonly ["not-found", "ambiguous", "outside-bundle", "reserved", "not-a-concept"]>;
|
|
300
|
+
readonly suggestion: Schema.optionalKey<Schema.String>;
|
|
301
|
+
readonly candidates: Schema.optionalKey<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
|
|
302
|
+
}>;
|
|
303
|
+
/** @public */
|
|
304
|
+
export type TargetFailure = typeof TargetFailure.Type;
|
|
305
|
+
declare const TargetResolutionError_base: Schema.Class<TargetResolutionError, Schema.TaggedStruct<"TargetResolutionError", {
|
|
306
|
+
readonly failures: Schema.$Array<Schema.Struct<{
|
|
307
|
+
readonly arg: Schema.String;
|
|
308
|
+
readonly reason: Schema.Literals<readonly ["not-found", "ambiguous", "outside-bundle", "reserved", "not-a-concept"]>;
|
|
309
|
+
readonly suggestion: Schema.optionalKey<Schema.String>;
|
|
310
|
+
readonly candidates: Schema.optionalKey<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
|
|
311
|
+
}>>;
|
|
312
|
+
}>, import("effect/Cause").YieldableError>;
|
|
313
|
+
/**
|
|
314
|
+
* One or more concept targets did not resolve. Every bad argument is listed;
|
|
315
|
+
* nothing ran. Exit 64: a usage error.
|
|
316
|
+
*
|
|
317
|
+
* @public
|
|
318
|
+
*/
|
|
319
|
+
export declare class TargetResolutionError extends TargetResolutionError_base {
|
|
320
|
+
readonly [Runtime.errorExitCode] = 64;
|
|
321
|
+
get message(): string;
|
|
322
|
+
}
|
|
323
|
+
declare const MoveError_base: Schema.Class<MoveError, Schema.TaggedStruct<"MoveError", {
|
|
324
|
+
readonly reason: Schema.Literals<readonly ["outside-bundle", "destination-exists", "reserved", "same-path", "invalid-name", "unrewritable", "project-file", "unloaded-files"]>;
|
|
325
|
+
readonly detail: Schema.optionalKey<Schema.String>;
|
|
326
|
+
}>, import("effect/Cause").YieldableError>;
|
|
327
|
+
/**
|
|
328
|
+
* `okfit mv` refused before writing anything. `outside-bundle`, `destination-exists`, `reserved`,
|
|
329
|
+
* `same-path` and `invalid-name` (whitespace in a destination path segment) name a bad destination
|
|
330
|
+
* (`detail` is the destination); `unrewritable` lists every link that needs rewriting for this move
|
|
331
|
+
* (`file: url`, one per line) whose URL text could not be located; `project-file` refuses to move the
|
|
332
|
+
* bundle's root project file (`detail` is its path), which must stay at the bundle root;
|
|
333
|
+
* `unloaded-files` lists (one per line) the bundle's Markdown files that did not load as concepts,
|
|
334
|
+
* whose links to the moved file could not be rewritten.
|
|
335
|
+
*
|
|
336
|
+
* @public
|
|
337
|
+
*/
|
|
338
|
+
export declare class MoveError extends MoveError_base {
|
|
339
|
+
readonly [Runtime.errorExitCode] = 64;
|
|
340
|
+
get message(): string;
|
|
341
|
+
}
|
|
292
342
|
//#endregion
|
|
293
343
|
//#region src/config/layer.d.ts
|
|
294
344
|
/**
|
|
@@ -317,7 +367,7 @@ export declare class QuerySelectionError extends QuerySelectionError_base {
|
|
|
317
367
|
* `save`/`update` do not fail with `ConfigDefaultPathMissingError`; nothing
|
|
318
368
|
* here sets it explicitly any more.
|
|
319
369
|
*
|
|
320
|
-
* `discoveryCwd` is `
|
|
370
|
+
* `discoveryCwd` is `--root` when given, else `process.cwd()` (K-2), passed
|
|
321
371
|
* straight through as `upwardWalk`'s own `cwd` so nothing in this module
|
|
322
372
|
* reads the process.
|
|
323
373
|
*
|
|
@@ -408,7 +458,7 @@ interface ResolvedProjectConfig {
|
|
|
408
458
|
}
|
|
409
459
|
/**
|
|
410
460
|
* Input to {@link resolveProjectConfig}: the same three values every command
|
|
411
|
-
* handler already has in hand (its own `
|
|
461
|
+
* handler already has in hand (its own `--root` flag, its own
|
|
412
462
|
* `--config` flag, and `process.cwd()`) — nothing this function needs is
|
|
413
463
|
* read from `process` itself.
|
|
414
464
|
*
|
|
@@ -657,6 +707,127 @@ export declare const targetPaths: (options: ScaffoldOptions) => ReadonlyArray<st
|
|
|
657
707
|
*/
|
|
658
708
|
export declare const files: (options: ScaffoldOptions) => Effect.Effect<ReadonlyArray<ScaffoldFile>, MarkdownParseError | FrontmatterWriteError>;
|
|
659
709
|
//#endregion
|
|
710
|
+
//#region src/move/references.d.ts
|
|
711
|
+
/**
|
|
712
|
+
* One reference's value text inside a file: whole-file offsets, quotes excluded. `field` is set for
|
|
713
|
+
* the frontmatter fields core resolves with path-field rules (`resource`, `sources.resource`, ...).
|
|
714
|
+
*
|
|
715
|
+
* @public
|
|
716
|
+
*/
|
|
717
|
+
interface Reference {
|
|
718
|
+
readonly file: string;
|
|
719
|
+
readonly offset: number;
|
|
720
|
+
readonly length: number;
|
|
721
|
+
readonly raw: string;
|
|
722
|
+
readonly quote: "" | "'" | '"';
|
|
723
|
+
readonly field?: PathField;
|
|
724
|
+
/** Set for a body link whose destination sits inside angle brackets (`](<...>)`), where whitespace is legal. */
|
|
725
|
+
readonly angle?: true;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* A reference {@link referencesOf} could not locate in its file: the `file: value` line and the
|
|
729
|
+
* decoded value, so a caller can tell whether it would have needed rewriting.
|
|
730
|
+
*
|
|
731
|
+
* @public
|
|
732
|
+
*/
|
|
733
|
+
interface UnlocatableReference {
|
|
734
|
+
readonly entry: string;
|
|
735
|
+
readonly raw: string;
|
|
736
|
+
readonly field?: PathField;
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Every rewritable reference in a concept, plus the references that could not be located in their file
|
|
740
|
+
* (`unlocatable` as `file: value` lines, `unlocatableRefs` with the decoded value). Body links, images and definitions with a URL; the path-valued frontmatter fields;
|
|
741
|
+
* every field the concept's type declares with `kind = "path"`; and `renders[].path`.
|
|
742
|
+
*
|
|
743
|
+
* @public
|
|
744
|
+
*/
|
|
745
|
+
export declare const referencesOf: (concept: LoadedConcept, config: OkfitConfig) => {
|
|
746
|
+
readonly references: ReadonlyArray<Reference>;
|
|
747
|
+
readonly unlocatable: ReadonlyArray<string>;
|
|
748
|
+
readonly unlocatableRefs: ReadonlyArray<UnlocatableReference>;
|
|
749
|
+
};
|
|
750
|
+
/**
|
|
751
|
+
* The new text for one reference after `movedFrom` (a bundle-relative `.md` path) moves to `movedTo`,
|
|
752
|
+
* or `undefined` when the text stays as written. The reference was written in `fromOld`, which is
|
|
753
|
+
* now at `fromNew` (equal unless the file itself is the one that moved). The spelling is kept: a
|
|
754
|
+
* rooted reference stays rooted, a bare one stays bare, `./`, a dropped `.md`, a `#fragment`/`?query`
|
|
755
|
+
* suffix and a trailing `/` survive. The result may hold whitespace even when `angle` is unset (a
|
|
756
|
+
* percent-encoded space decodes); the caller must then refuse rather than write it outside angle brackets.
|
|
757
|
+
*
|
|
758
|
+
* @public
|
|
759
|
+
*/
|
|
760
|
+
export declare const rewriteReference: (raw: string, options: {
|
|
761
|
+
readonly bundle: LoadedBundle;
|
|
762
|
+
readonly fromOld: string;
|
|
763
|
+
readonly fromNew: string;
|
|
764
|
+
readonly movedFrom: string;
|
|
765
|
+
readonly movedTo: string;
|
|
766
|
+
readonly field?: PathField;
|
|
767
|
+
/** The reference is a body link inside angle brackets, so its path may hold whitespace. */
|
|
768
|
+
readonly angle?: boolean;
|
|
769
|
+
}) => string | undefined;
|
|
770
|
+
//#endregion
|
|
771
|
+
//#region src/move/run.d.ts
|
|
772
|
+
/**
|
|
773
|
+
* What `okfit mv` will do. `from` and `to` are bundle-relative `.md` paths, `fromPath` and `toPath`
|
|
774
|
+
* their absolute forms. `edits` holds the post-move path, the edit count and the full new text of
|
|
775
|
+
* every file that changes, the moved file always among them (`count` may be 0). `drifts` lists the
|
|
776
|
+
* ids (the moved file by its old id) whose human verification is `current` now and whose text changes.
|
|
777
|
+
*
|
|
778
|
+
* @public
|
|
779
|
+
*/
|
|
780
|
+
interface MovePlan {
|
|
781
|
+
readonly from: string;
|
|
782
|
+
readonly to: string;
|
|
783
|
+
readonly fromPath: string;
|
|
784
|
+
readonly toPath: string;
|
|
785
|
+
readonly edits: ReadonlyArray<{
|
|
786
|
+
readonly path: string;
|
|
787
|
+
readonly count: number;
|
|
788
|
+
readonly text: string;
|
|
789
|
+
}>;
|
|
790
|
+
readonly drifts: ReadonlyArray<string>;
|
|
791
|
+
}
|
|
792
|
+
/** @public */
|
|
793
|
+
interface PlanMoveOptions {
|
|
794
|
+
/** The concept to move: a path or id, resolved like any other concept target. */
|
|
795
|
+
readonly from: string;
|
|
796
|
+
/** The destination: an absolute path, a cwd-relative path or a bundle-relative id; `.md` is appended when missing. */
|
|
797
|
+
readonly to: string;
|
|
798
|
+
readonly cwd: string;
|
|
799
|
+
readonly bundleRoot: string;
|
|
800
|
+
readonly config: OkfitConfig;
|
|
801
|
+
readonly now: DateTime.Utc;
|
|
802
|
+
}
|
|
803
|
+
/** @public */
|
|
804
|
+
interface RunMoveOptions extends PlanMoveOptions {
|
|
805
|
+
readonly dryRun: boolean;
|
|
806
|
+
}
|
|
807
|
+
/** Every failure {@link planMove} and {@link runMove} can raise. @public */
|
|
808
|
+
type PlanError = MoveError | TargetResolutionError | BundleLoadError | PlatformError.PlatformError;
|
|
809
|
+
/**
|
|
810
|
+
* Plan moving one concept: resolve both ends, find every reference to it across the bundle (and the
|
|
811
|
+
* moved file's own outbound references), and compute the new text of each file that changes. Pure of
|
|
812
|
+
* writes; refuses with {@link MoveError} when the destination is unusable or any body link cannot be
|
|
813
|
+
* located for rewriting.
|
|
814
|
+
*
|
|
815
|
+
* @public
|
|
816
|
+
*/
|
|
817
|
+
export declare const planMove: (options: PlanMoveOptions) => Effect.Effect<MovePlan, PlanError, Crypto.Crypto | FileSystem.FileSystem | Path.Path>;
|
|
818
|
+
/**
|
|
819
|
+
* Plan the move, then (unless `dryRun`) write it: every referrer atomically, the moved file's new
|
|
820
|
+
* text over its old path, then a rename to the destination (its directory created first). Nothing is
|
|
821
|
+
* written until the whole plan succeeded; the writes themselves are not transactional (the rename is last).
|
|
822
|
+
*
|
|
823
|
+
* @public
|
|
824
|
+
*/
|
|
825
|
+
export declare const runMove: (options: RunMoveOptions) => Effect.Effect<{
|
|
826
|
+
readonly plan: MovePlan;
|
|
827
|
+
readonly bundleRoot: string;
|
|
828
|
+
readonly dryRun: boolean;
|
|
829
|
+
}, PlanError, Crypto.Crypto | FileSystem.FileSystem | Path.Path>;
|
|
830
|
+
//#endregion
|
|
660
831
|
//#region src/overlay/documents.d.ts
|
|
661
832
|
/**
|
|
662
833
|
* One unsaved document: `path` is bundle-relative posix (`metrics/churn.md`),
|
|
@@ -1287,6 +1458,54 @@ export declare const json: (input: {
|
|
|
1287
1458
|
/** K-22. `tag` is the error's `_tag` when it has one, else its constructor name. @public */
|
|
1288
1459
|
export declare const jsonError: (error: unknown, okfitVersion: string, distribution?: Distribution) => JsonErrorEnvelope;
|
|
1289
1460
|
//#endregion
|
|
1461
|
+
//#region src/render/move.d.ts
|
|
1462
|
+
/**
|
|
1463
|
+
* `okfit mv`'s success envelope, schema 1, snake_case. `from`/`to` are bundle-relative paths, `path`
|
|
1464
|
+
* the display form of the destination; `edits` lists every file that changes (post-move path) with
|
|
1465
|
+
* its edit count, and `drifts` the ids whose current human verification the move invalidates.
|
|
1466
|
+
*
|
|
1467
|
+
* @public
|
|
1468
|
+
*/
|
|
1469
|
+
export declare const MoveEnvelope: Schema.Struct<{
|
|
1470
|
+
readonly schema: Schema.Literal<1>;
|
|
1471
|
+
readonly okfit_version: Schema.String;
|
|
1472
|
+
readonly engine_version: Schema.String;
|
|
1473
|
+
readonly distribution: Schema.NullOr<Schema.Struct<{
|
|
1474
|
+
readonly name: Schema.String;
|
|
1475
|
+
readonly version: Schema.String;
|
|
1476
|
+
}>>;
|
|
1477
|
+
readonly from: Schema.String;
|
|
1478
|
+
readonly to: Schema.String;
|
|
1479
|
+
readonly path: Schema.String;
|
|
1480
|
+
readonly dry_run: Schema.Boolean;
|
|
1481
|
+
readonly edits: Schema.$Array<Schema.Struct<{
|
|
1482
|
+
readonly path: Schema.String;
|
|
1483
|
+
readonly count: Schema.Number;
|
|
1484
|
+
}>>;
|
|
1485
|
+
readonly drifts: Schema.$Array<Schema.String>;
|
|
1486
|
+
readonly exit_code: Schema.Literal<0>;
|
|
1487
|
+
}>;
|
|
1488
|
+
/** @public */
|
|
1489
|
+
export type MoveEnvelope = typeof MoveEnvelope.Type;
|
|
1490
|
+
/**
|
|
1491
|
+
* `path` is already the display form, as for the other envelope builders.
|
|
1492
|
+
*
|
|
1493
|
+
* @public
|
|
1494
|
+
*/
|
|
1495
|
+
export declare const moveEnvelope: (input: {
|
|
1496
|
+
readonly okfitVersion: string;
|
|
1497
|
+
readonly from: string;
|
|
1498
|
+
readonly to: string;
|
|
1499
|
+
readonly path: string;
|
|
1500
|
+
readonly dryRun: boolean;
|
|
1501
|
+
readonly edits: ReadonlyArray<{
|
|
1502
|
+
readonly path: string;
|
|
1503
|
+
readonly count: number;
|
|
1504
|
+
}>;
|
|
1505
|
+
readonly drifts: ReadonlyArray<string>;
|
|
1506
|
+
readonly distribution?: Distribution;
|
|
1507
|
+
}) => MoveEnvelope;
|
|
1508
|
+
//#endregion
|
|
1290
1509
|
//#region src/render/query.d.ts
|
|
1291
1510
|
/**
|
|
1292
1511
|
* Why a human verification no longer binds, as the wire reports it. `edited_by`
|
|
@@ -2205,6 +2424,39 @@ export declare const stampPublication: (options: {
|
|
|
2205
2424
|
readonly dryRun: boolean;
|
|
2206
2425
|
}) => Effect.Effect<PublicationEnvelope, PublicationNotFoundError | NotAPublicationError | BundleLoadError | YamlParseError | UnsupportedFrontmatterError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Crypto.Crypto>;
|
|
2207
2426
|
//#endregion
|
|
2427
|
+
//#region src/targets/resolve.d.ts
|
|
2428
|
+
/**
|
|
2429
|
+
* One resolved concept target: the argument as typed, the bundle-relative
|
|
2430
|
+
* posix file path, and the concept id (absent only for a non-concept file
|
|
2431
|
+
* accepted under `files: true`).
|
|
2432
|
+
*
|
|
2433
|
+
* @public
|
|
2434
|
+
*/
|
|
2435
|
+
interface ResolvedTarget {
|
|
2436
|
+
readonly arg: string;
|
|
2437
|
+
readonly path: string;
|
|
2438
|
+
readonly id: ConceptId | undefined;
|
|
2439
|
+
}
|
|
2440
|
+
/**
|
|
2441
|
+
* Concept targets on the CLI (spec section 13): the shared resolver every
|
|
2442
|
+
* concept command calls before it reads or writes anything. Resolution order
|
|
2443
|
+
* is absolute path, cwd-relative path, then bundle-relative id; a candidate
|
|
2444
|
+
* outside the bundle is discarded, never matched. With `files: true` any
|
|
2445
|
+
* walked bundle file is accepted, so a reserved or undecodable file can still
|
|
2446
|
+
* be validated.
|
|
2447
|
+
*
|
|
2448
|
+
* @public
|
|
2449
|
+
*/
|
|
2450
|
+
export declare class Targets {
|
|
2451
|
+
private constructor();
|
|
2452
|
+
/** Resolve every argument or fail with every bad one; duplicates collapse to the first spelling. */
|
|
2453
|
+
static readonly resolve: (args: ReadonlyArray<string>, bundle: LoadedBundle, cwd: string, options?: {
|
|
2454
|
+
readonly files?: boolean;
|
|
2455
|
+
}) => Effect.Effect<ReadonlyArray<ResolvedTarget>, TargetResolutionError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path>;
|
|
2456
|
+
/** The nearest concept id to `arg`: a unique basename match first, else the closest by edit distance. */
|
|
2457
|
+
static readonly suggest: (arg: string, bundle: LoadedBundle) => string | undefined;
|
|
2458
|
+
}
|
|
2459
|
+
//#endregion
|
|
2208
2460
|
//#region src/trust/run.d.ts
|
|
2209
2461
|
/** @public */
|
|
2210
2462
|
interface ContextTrustOptions {
|
|
@@ -2554,11 +2806,40 @@ export declare const runRevoke: (options: RevokeOptions) => Effect.Effect<{
|
|
|
2554
2806
|
id: ConceptId;
|
|
2555
2807
|
bundleRoot: string;
|
|
2556
2808
|
conceptPath: string;
|
|
2557
|
-
by:
|
|
2809
|
+
by: string;
|
|
2558
2810
|
removed: string[];
|
|
2559
2811
|
bindingCleared: boolean;
|
|
2560
2812
|
dryRun: boolean;
|
|
2561
2813
|
}, import("effect/PlatformError").PlatformError | VerifyConceptNotFoundError | VerifyNothingToRevokeError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
|
|
2814
|
+
/**
|
|
2815
|
+
* Options for {@link runRevokeIds}.
|
|
2816
|
+
*
|
|
2817
|
+
* @internal
|
|
2818
|
+
*/
|
|
2819
|
+
interface RevokeIdsOptions {
|
|
2820
|
+
readonly ids: ReadonlyArray<string>;
|
|
2821
|
+
readonly bundleRoot: string;
|
|
2822
|
+
readonly projectRoot: string;
|
|
2823
|
+
readonly config: OkfitConfig;
|
|
2824
|
+
readonly dryRun: boolean;
|
|
2825
|
+
}
|
|
2826
|
+
/**
|
|
2827
|
+
* {@link runRevoke} for several concepts, all or nothing: every revoke is
|
|
2828
|
+
* prepared before the first write, so one concept with nothing to revoke (or an
|
|
2829
|
+
* unsupported shape, or an unknown id) fails the call with the tree untouched.
|
|
2830
|
+
* Duplicate ids collapse to one. Results come back in the order given.
|
|
2831
|
+
*
|
|
2832
|
+
* @internal
|
|
2833
|
+
*/
|
|
2834
|
+
export declare const runRevokeIds: (options: RevokeIdsOptions) => Effect.Effect<{
|
|
2835
|
+
id: ConceptId;
|
|
2836
|
+
bundleRoot: string;
|
|
2837
|
+
conceptPath: string;
|
|
2838
|
+
by: string;
|
|
2839
|
+
removed: string[];
|
|
2840
|
+
bindingCleared: boolean;
|
|
2841
|
+
dryRun: boolean;
|
|
2842
|
+
}[], import("effect/PlatformError").PlatformError | VerifyConceptNotFoundError | VerifyNothingToRevokeError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
|
|
2562
2843
|
/**
|
|
2563
2844
|
* Issue #138. Attests every concept selected by `options.types` (or, when
|
|
2564
2845
|
* empty, every type whose declaration sets `require_verified = true`) that
|
|
@@ -2693,5 +2974,5 @@ export declare const loadPreviews: (candidates: readonly PickerCandidate[]) => E
|
|
|
2693
2974
|
*/
|
|
2694
2975
|
export declare const ENGINE_VERSION: string;
|
|
2695
2976
|
//#endregion
|
|
2696
|
-
export type { AttestableSelection, BundleSessionOptions, BundleSessionServices, BundleSessionShape, ChangeSince, ConceptFilter, ConceptLink, ConceptNeighbor, ContextResult, ContextRunOptions, ContextTrustOptions, DiagnosticSource, DiscoveredConfig, Distribution, DocumentInput, DriftInspection, ExternalReferencesShape, GraphRunOptions, GraphRunResult, OverlayDocument, OverlayDocumentsShape, PendingWrite, PickerCandidate, PickerCandidatesOptions, RenderedDiagnostic, ResolveProjectConfigInput, ResolvedProjectConfig, RevalidateError, RevalidateOptions, RevalidateResult, RevalidateTier, RevokeOptions, RevokeResult, RunOptions, RunResult, ScaffoldFile, ScaffoldOptions, StaleRunOptions, StaleRunResult, SyncMode, SyncModeResult, SyncOptions, SyncPlan, SyncResult, Tally, VerifyBatchOptions, VerifyBatchResult, VerifyBatchSkipReason, VerifyIdsOptions, VerifyOptions, VerifyResult, WatchedFilesOutcome };
|
|
2977
|
+
export type { AttestableSelection, BundleSessionOptions, BundleSessionServices, BundleSessionShape, ChangeSince, ConceptFilter, ConceptLink, ConceptNeighbor, ContextResult, ContextRunOptions, ContextTrustOptions, DiagnosticSource, DiscoveredConfig, Distribution, DocumentInput, DriftInspection, ExternalReferencesShape, GraphRunOptions, GraphRunResult, MovePlan, OverlayDocument, OverlayDocumentsShape, PendingWrite, PickerCandidate, PickerCandidatesOptions, PlanError, PlanMoveOptions, Reference, RenderedDiagnostic, ResolveProjectConfigInput, ResolvedProjectConfig, ResolvedTarget, RevalidateError, RevalidateOptions, RevalidateResult, RevalidateTier, RevokeIdsOptions, RevokeOptions, RevokeResult, RunMoveOptions, RunOptions, RunResult, ScaffoldFile, ScaffoldOptions, StaleRunOptions, StaleRunResult, SyncMode, SyncModeResult, SyncOptions, SyncPlan, SyncResult, Tally, UnlocatableReference, VerifyBatchOptions, VerifyBatchResult, VerifyBatchSkipReason, VerifyIdsOptions, VerifyOptions, VerifyResult, WatchedFilesOutcome };
|
|
2697
2978
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveBundleRoot, resolveProjectRoot } from "./config/anchor.js";
|
|
2
|
-
import { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, SyncStagedLogError, VerifyConceptNotFoundError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError } from "./errors.js";
|
|
2
|
+
import { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, SyncStagedLogError, TargetFailure, TargetResolutionError, VerifyConceptNotFoundError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError } from "./errors.js";
|
|
3
3
|
import { buildConfigLayer, provideConfig } from "./config/layer.js";
|
|
4
4
|
import { DEFAULT_PROFILE_NAME, resolveProjectConfig } from "./config/resolve.js";
|
|
5
5
|
import { runContext } from "./context/run.js";
|
|
@@ -7,6 +7,9 @@ import { FrontmatterEdits, UnsupportedFrontmatterError } from "./edits/Frontmatt
|
|
|
7
7
|
import { ExternalReferences, ReferenceCheck, ReferenceState } from "./external/ExternalReferences.js";
|
|
8
8
|
import { runGraph } from "./graph/run.js";
|
|
9
9
|
import { CONFIG_RELATIVE_PATH, configValue, files, targetPaths } from "./init/scaffold.js";
|
|
10
|
+
import { referencesOf, rewriteReference } from "./move/references.js";
|
|
11
|
+
import { Targets } from "./targets/resolve.js";
|
|
12
|
+
import { planMove, runMove } from "./move/run.js";
|
|
10
13
|
import { OverlayDocuments, layerOverlayFileSystem, makeOverlayFileSystem } from "./overlay/layer.js";
|
|
11
14
|
import { provideDocuments, resolveDocumentPath } from "./overlay/documents.js";
|
|
12
15
|
import { OkfitPlatform } from "./platform.js";
|
|
@@ -18,6 +21,7 @@ import { ENGINE_VERSION } from "./version.js";
|
|
|
18
21
|
import { GraphEdgeEnvelope, GraphEnvelope, GraphNodeEnvelope, GraphSummary, graphEnvelope } from "./render/graph.js";
|
|
19
22
|
import { collect, sort } from "./render/sort.js";
|
|
20
23
|
import { JsonDiagnostic, JsonEnvelope, JsonErrorEnvelope, JsonSummary, json, jsonError } from "./render/json.js";
|
|
24
|
+
import { MoveEnvelope, moveEnvelope } from "./render/move.js";
|
|
21
25
|
import { ConceptSummary, QueryGetEnvelope, QueryLink, QueryListEnvelope, QueryNeighbor, QueryNeighborsEnvelope, TrustDrift, queryGetEnvelope, queryListEnvelope, queryNeighborsEnvelope, signalFor, toConceptSummary, toTrustDrift } from "./render/query.js";
|
|
22
26
|
import { StaleEnvelope, StaleItem, StaleSummary, staleEnvelope } from "./render/stale.js";
|
|
23
27
|
import { SkipReason, applySyncPlan, planSync, runSync } from "./sync/run.js";
|
|
@@ -32,6 +36,6 @@ import { NotAPublicationError, PublicationNotFoundError, stampPublication } from
|
|
|
32
36
|
import { runContextTrust } from "./trust/run.js";
|
|
33
37
|
import { changeSince } from "./verify/diff.js";
|
|
34
38
|
import { resolveBatchTypes, selectAttestable, selectPickerCandidates, selectStaleCandidates } from "./verify/select.js";
|
|
35
|
-
import { inspectDrift, loadPickerCandidates, loadPreviews, loadStaleCandidates, runRevoke, runVerify, runVerifyBatch, runVerifyIds } from "./verify/run.js";
|
|
39
|
+
import { inspectDrift, loadPickerCandidates, loadPreviews, loadStaleCandidates, runRevoke, runRevokeIds, runVerify, runVerifyBatch, runVerifyIds } from "./verify/run.js";
|
|
36
40
|
|
|
37
|
-
export { BundleSession, CONFIG_RELATIVE_PATH, ConceptQuery, ConceptSummary, ConfigMalformedError, ConfigPathNotFoundError, ContextEnvelope, ContextField, ContextFieldValue, ContextTag, ContextTrust, ContextType, DEFAULT_PROFILE_NAME, DistributionField, DocumentPathError, ENGINE_VERSION, ExternalReferences, FrontmatterEdits, GraphEdgeEnvelope, GraphEnvelope, GraphNodeEnvelope, GraphSummary, InitOverwriteError, JsonDiagnostic, JsonEnvelope, JsonErrorEnvelope, JsonSummary, NotAPublicationError, Now, OkfitPlatform, OverlayDocuments, PublicationEnvelope, PublicationNotFoundError, QueryConceptNotFoundError, QueryGetEnvelope, QueryLink, QueryListEnvelope, QueryNeighbor, QueryNeighborsEnvelope, QuerySelectionError, QueryUnknownVocabularyError, ReferenceCheck, ReferenceState, RevokeEnvelope, SkipReason, StaleEnvelope, StaleItem, StaleSummary, SyncEnvelope, SyncModeEnvelope, SyncPlanStaleError, SyncPublicationConflictError, SyncStagedLogError, TrustDrift, UnsupportedFrontmatterError, VerifyBatchEnvelope, VerifyConceptNotFoundError, VerifyEnvelope, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError, applySyncPlan, buildConfigLayer, changeSince, collect, conceptFor, configValue, contextEnvelope, files, forDiagnostics, graphEnvelope, inspectDrift, json, jsonError, layerOverlayFileSystem, loadPickerCandidates, loadPreviews, loadStaleCandidates, makeOverlayFileSystem, planSync, provideConfig, provideDocuments, queryGetEnvelope, queryListEnvelope, queryNeighborsEnvelope, resolveBatchTypes, resolveBundleRoot, resolveDocumentPath, resolveProjectConfig, resolveProjectRoot, revokeEnvelope, run, runContext, runContextTrust, runGraph, runRevoke, runStale, runSync, runVerify, runVerifyBatch, runVerifyIds, selectAttestable, selectPickerCandidates, selectStaleCandidates, signalFor, sort, staleEnvelope, stampPublication, syncEnvelope, tally, targetPaths, toConceptSummary, toTrustDrift, verifyBatchEnvelope, verifyEnvelope, withFallbackRange };
|
|
41
|
+
export { BundleSession, CONFIG_RELATIVE_PATH, ConceptQuery, ConceptSummary, ConfigMalformedError, ConfigPathNotFoundError, ContextEnvelope, ContextField, ContextFieldValue, ContextTag, ContextTrust, ContextType, DEFAULT_PROFILE_NAME, DistributionField, DocumentPathError, ENGINE_VERSION, ExternalReferences, FrontmatterEdits, GraphEdgeEnvelope, GraphEnvelope, GraphNodeEnvelope, GraphSummary, InitOverwriteError, JsonDiagnostic, JsonEnvelope, JsonErrorEnvelope, JsonSummary, MoveEnvelope, MoveError, NotAPublicationError, Now, OkfitPlatform, OverlayDocuments, PublicationEnvelope, PublicationNotFoundError, QueryConceptNotFoundError, QueryGetEnvelope, QueryLink, QueryListEnvelope, QueryNeighbor, QueryNeighborsEnvelope, QuerySelectionError, QueryUnknownVocabularyError, ReferenceCheck, ReferenceState, RevokeEnvelope, SkipReason, StaleEnvelope, StaleItem, StaleSummary, SyncEnvelope, SyncModeEnvelope, SyncPlanStaleError, SyncPublicationConflictError, SyncStagedLogError, TargetFailure, TargetResolutionError, Targets, TrustDrift, UnsupportedFrontmatterError, VerifyBatchEnvelope, VerifyConceptNotFoundError, VerifyEnvelope, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError, applySyncPlan, buildConfigLayer, changeSince, collect, conceptFor, configValue, contextEnvelope, files, forDiagnostics, graphEnvelope, inspectDrift, json, jsonError, layerOverlayFileSystem, loadPickerCandidates, loadPreviews, loadStaleCandidates, makeOverlayFileSystem, moveEnvelope, planMove, planSync, provideConfig, provideDocuments, queryGetEnvelope, queryListEnvelope, queryNeighborsEnvelope, referencesOf, resolveBatchTypes, resolveBundleRoot, resolveDocumentPath, resolveProjectConfig, resolveProjectRoot, revokeEnvelope, rewriteReference, run, runContext, runContextTrust, runGraph, runMove, runRevoke, runRevokeIds, runStale, runSync, runVerify, runVerifyBatch, runVerifyIds, selectAttestable, selectPickerCandidates, selectStaleCandidates, signalFor, sort, staleEnvelope, stampPublication, syncEnvelope, tally, targetPaths, toConceptSummary, toTrustDrift, verifyBatchEnvelope, verifyEnvelope, withFallbackRange };
|