@milaboratories/pl-model-middle-layer 1.32.2 → 1.33.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/dist/folders/commit.cjs +79 -0
- package/dist/folders/commit.cjs.map +1 -0
- package/dist/folders/commit.d.ts +82 -0
- package/dist/folders/commit.d.ts.map +1 -0
- package/dist/folders/commit.js +78 -0
- package/dist/folders/commit.js.map +1 -0
- package/dist/folders/decode.cjs +79 -0
- package/dist/folders/decode.cjs.map +1 -0
- package/dist/folders/decode.d.ts +57 -0
- package/dist/folders/decode.d.ts.map +1 -0
- package/dist/folders/decode.js +77 -0
- package/dist/folders/decode.js.map +1 -0
- package/dist/folders/document.cjs +49 -0
- package/dist/folders/document.cjs.map +1 -0
- package/dist/folders/document.d.ts +56 -0
- package/dist/folders/document.d.ts.map +1 -0
- package/dist/folders/document.js +45 -0
- package/dist/folders/document.js.map +1 -0
- package/dist/folders/index.cjs +37 -0
- package/dist/folders/index.d.ts +10 -0
- package/dist/folders/index.js +10 -0
- package/dist/folders/inheritance.cjs +23 -0
- package/dist/folders/inheritance.cjs.map +1 -0
- package/dist/folders/inheritance.d.ts +19 -0
- package/dist/folders/inheritance.d.ts.map +1 -0
- package/dist/folders/inheritance.js +23 -0
- package/dist/folders/inheritance.js.map +1 -0
- package/dist/folders/invariants.cjs +115 -0
- package/dist/folders/invariants.cjs.map +1 -0
- package/dist/folders/invariants.d.ts +48 -0
- package/dist/folders/invariants.d.ts.map +1 -0
- package/dist/folders/invariants.js +114 -0
- package/dist/folders/invariants.js.map +1 -0
- package/dist/folders/naming.cjs +53 -0
- package/dist/folders/naming.cjs.map +1 -0
- package/dist/folders/naming.d.ts +31 -0
- package/dist/folders/naming.d.ts.map +1 -0
- package/dist/folders/naming.js +51 -0
- package/dist/folders/naming.js.map +1 -0
- package/dist/folders/planner.cjs +187 -0
- package/dist/folders/planner.cjs.map +1 -0
- package/dist/folders/planner.d.ts +100 -0
- package/dist/folders/planner.d.ts.map +1 -0
- package/dist/folders/planner.js +185 -0
- package/dist/folders/planner.js.map +1 -0
- package/dist/folders/removal.cjs +47 -0
- package/dist/folders/removal.cjs.map +1 -0
- package/dist/folders/removal.d.ts +42 -0
- package/dist/folders/removal.d.ts.map +1 -0
- package/dist/folders/removal.js +45 -0
- package/dist/folders/removal.js.map +1 -0
- package/dist/folders/view.cjs +210 -0
- package/dist/folders/view.cjs.map +1 -0
- package/dist/folders/view.d.ts +93 -0
- package/dist/folders/view.d.ts.map +1 -0
- package/dist/folders/view.js +205 -0
- package/dist/folders/view.js.map +1 -0
- package/dist/index.cjs +43 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +12 -1
- package/dist/project.cjs +23 -0
- package/dist/project.cjs.map +1 -0
- package/dist/project.d.ts +13 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +22 -0
- package/dist/project.js.map +1 -0
- package/package.json +7 -4
- package/src/folders/commit.ts +133 -0
- package/src/folders/decode.test.ts +128 -0
- package/src/folders/decode.ts +142 -0
- package/src/folders/document.ts +96 -0
- package/src/folders/index.ts +9 -0
- package/src/folders/inheritance.test.ts +86 -0
- package/src/folders/inheritance.ts +32 -0
- package/src/folders/invariants.test.ts +157 -0
- package/src/folders/invariants.ts +155 -0
- package/src/folders/naming.test.ts +62 -0
- package/src/folders/naming.ts +58 -0
- package/src/folders/planner.test.ts +436 -0
- package/src/folders/planner.ts +276 -0
- package/src/folders/removal.test.ts +142 -0
- package/src/folders/removal.ts +77 -0
- package/src/folders/test_utils.ts +86 -0
- package/src/folders/view.test.ts +422 -0
- package/src/folders/view.ts +324 -0
- package/src/index.ts +1 -0
- package/src/project.ts +21 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.js","names":[],"sources":["../../src/folders/view.ts"],"sourcesContent":["import type { ProjectId, TemplateId } from \"@milaboratories/pl-model-common\";\nimport { normalizeDescription } from \"../project\";\nimport type { FoldersDecoded, FoldersDocumentProblem } from \"./decode\";\nimport type { FoldersDocument, FolderId } from \"./document\";\nimport { emptyFoldersDocument } from \"./document\";\n\n/** An item as the folder machinery needs to see it: an identity and the label shown to a user. */\nexport interface FoldersItemInput<Id extends string> {\n readonly id: Id;\n readonly name: string;\n}\n\n/** Where an item sits in the tree. */\nexport interface FoldersPlacement {\n /** Absent for an item at the top level. */\n readonly folder?: FolderId;\n /** Containing folders, outermost first, including the folder holding the item. */\n readonly ancestors: readonly FolderId[];\n /**\n * Names of those folders, outermost first. Empty for an item at the top level. This is what\n * tells two identically named items apart in a search across the whole tree.\n */\n readonly path: readonly string[];\n}\n\n/** An item with the folder holding it resolved. */\nexport interface FoldersItemView<Id extends string>\n extends FoldersItemInput<Id>, FoldersPlacement {}\n\nexport type FoldersProjectInput = FoldersItemInput<ProjectId>;\nexport type FoldersTemplateInput = FoldersItemInput<TemplateId>;\nexport type FoldersProjectView = FoldersItemView<ProjectId>;\nexport type FoldersTemplateView = FoldersItemView<TemplateId>;\n\n/** A folder with its place in the tree resolved. */\nexport interface FolderView {\n readonly id: FolderId;\n readonly name: string;\n /** Absent for a top-level folder. */\n readonly parent?: FolderId;\n /** Containing folders, outermost first, excluding this folder. */\n readonly ancestors: readonly FolderId[];\n /** Names of the ancestors followed by this folder's own name. */\n readonly path: readonly string[];\n /** Free text the user wrote about the folder. Absent when there is none. */\n readonly description?: string;\n /** True when the stored parent was unusable and this folder was lifted to the top level. */\n readonly lifted: boolean;\n}\n\n/** The whole tree as the desktop consumes it. */\nexport interface FoldersView {\n readonly folders: readonly FolderView[];\n /** Every project handed in, in the order it was handed in. Nothing here is ever dropped. */\n readonly projects: readonly FoldersProjectView[];\n /** Every template handed in, in the order it was handed in. Nothing here is ever dropped. */\n readonly templates: readonly FoldersTemplateView[];\n /** False when folder writes must be refused. */\n readonly writable: boolean;\n /** Present when the stored document could not be used as it stands. */\n readonly problem?: FoldersDocumentProblem;\n /** True when what the view shows differs from what is stored, because the read healed it. */\n readonly healed: boolean;\n}\n\n/**\n * Resolve a decoded document against the project and template lists into the view the desktop\n * renders.\n *\n * The read heals rather than fails. An item the document does not mention is at the top level;\n * an assignment naming an item that is gone is ignored; a folder whose parent is missing, or\n * which sits in a cycle, is lifted to the top level instead of being hidden. No input can make a\n * project or a template disappear.\n */\nexport function healFolders(\n decoded: FoldersDecoded,\n projects: readonly FoldersProjectInput[],\n templates: readonly FoldersTemplateInput[] = [],\n): FoldersView {\n const view = foldersViewFromDocument(decoded.document, projects, templates);\n return { ...view, writable: decoded.writable, problem: decoded.problem };\n}\n\n/** The same healing read, for a caller that already holds a document. */\nexport function foldersViewFromDocument(\n document: FoldersDocument,\n projects: readonly FoldersProjectInput[],\n templates: readonly FoldersTemplateInput[] = [],\n): FoldersView {\n const resolution = resolveFolders(document);\n const { folders, byId } = resolution;\n let healed = resolution.healed;\n\n const placedProjects = place(projects, document.assignments, byId);\n const placedTemplates = place(templates, document.templateAssignments, byId);\n if (placedProjects.healed || placedTemplates.healed) healed = true;\n\n return {\n folders,\n projects: placedProjects.items,\n templates: placedTemplates.items,\n writable: true,\n healed,\n };\n}\n\n/** Direct children of a folder, or of the top level when no folder is given. */\nexport function foldersChildren(\n view: FoldersView,\n parent?: FolderId,\n): {\n readonly folders: readonly FolderView[];\n readonly projects: readonly FoldersProjectView[];\n readonly templates: readonly FoldersTemplateView[];\n} {\n return {\n folders: view.folders.filter((folder) => folder.parent === parent),\n projects: view.projects.filter((project) => project.folder === parent),\n templates: view.templates.filter((template) => template.folder === parent),\n };\n}\n\n/**\n * Names already taken directly inside a folder, or at the top level when no folder is given.\n *\n * Folders, projects and templates share one namespace: whatever kind two things beside each other\n * are, they never answer to one name. This is the one list every naming decision is made against.\n *\n * `exclude` names the ids that must not count against themselves — the items being renamed or\n * moved.\n */\nexport function foldersSiblingNames(\n view: FoldersView,\n parent?: FolderId,\n exclude: Iterable<string> = [],\n): string[] {\n const skipped = new Set<string>(exclude);\n const children = foldersChildren(view, parent);\n return [...children.folders, ...children.projects, ...children.templates]\n .filter((item) => !skipped.has(item.id))\n .map((item) => item.name);\n}\n\n/** A folder and every folder beneath it, the folder itself first. */\nexport function foldersSubtree(view: FoldersView, folder: FolderId): readonly FolderId[] {\n const subtree: FolderId[] = [];\n const queue: FolderId[] = [folder];\n while (queue.length > 0) {\n const current = queue.shift();\n if (current === undefined) break;\n subtree.push(current);\n for (const candidate of view.folders)\n if (candidate.parent === current) queue.push(candidate.id);\n }\n return subtree;\n}\n\n/**\n * The document a healed view stands for — what a write must persist so that the next read finds\n * the tree it just rendered.\n */\nexport function foldersDocumentFromView(view: FoldersView): FoldersDocument {\n const document = emptyFoldersDocument();\n return {\n ...document,\n folders: view.folders.map((folder) => {\n const description = normalizeDescription(folder.description);\n return {\n id: folder.id,\n name: folder.name,\n ...(folder.parent === undefined ? {} : { parent: folder.parent }),\n ...(description === undefined ? {} : { description }),\n };\n }),\n assignments: Object.fromEntries(\n view.projects.flatMap((project) =>\n project.folder === undefined ? [] : [[project.id, project.folder] as const],\n ),\n ),\n templateAssignments: Object.fromEntries(\n view.templates.flatMap((template) =>\n template.folder === undefined ? [] : [[template.id, template.folder] as const],\n ),\n ),\n };\n}\n\n//\n// Internals\n//\n\n/**\n * Resolve where each item of one list sits, and report whether doing so had to heal anything: a\n * duplicate id in the list, an assignment to a folder that is not there, or an assignment naming\n * an item the list no longer holds.\n */\nfunction place<Id extends string>(\n items: readonly FoldersItemInput<Id>[],\n assignments: Readonly<Record<string, FolderId>>,\n byId: ReadonlyMap<FolderId, FolderView>,\n): { readonly items: FoldersItemView<Id>[]; readonly healed: boolean } {\n let healed = false;\n const seen = new Set<string>();\n const placed: FoldersItemView<Id>[] = [];\n\n for (const item of items) {\n if (seen.has(item.id)) {\n healed = true;\n continue;\n }\n seen.add(item.id);\n\n const assigned = assignments[item.id];\n const folder = assigned === undefined ? undefined : byId.get(assigned);\n if (assigned !== undefined && folder === undefined) healed = true;\n\n placed.push(\n folder === undefined\n ? { id: item.id, name: item.name, ancestors: [], path: [] }\n : {\n id: item.id,\n name: item.name,\n folder: folder.id,\n ancestors: [...folder.ancestors, folder.id],\n path: [...folder.path],\n },\n );\n }\n\n for (const id of Object.keys(assignments)) if (!seen.has(id)) healed = true;\n\n return { items: placed, healed };\n}\n\ninterface FolderResolution {\n readonly folders: readonly FolderView[];\n readonly byId: ReadonlyMap<FolderId, FolderView>;\n readonly healed: boolean;\n}\n\n/**\n * Place every folder in the tree, lifting to the top level the ones whose stored parent cannot be\n * honoured. A lifted folder keeps its own children, which simply sit one or more levels higher.\n */\nfunction resolveFolders(document: FoldersDocument): FolderResolution {\n const stored = new Map<FolderId, { name: string; parent?: FolderId; description?: string }>();\n let healed = false;\n for (const folder of document.folders) {\n if (stored.has(folder.id)) {\n healed = true;\n continue;\n }\n stored.set(folder.id, {\n name: folder.name,\n parent: folder.parent,\n description: folder.description,\n });\n }\n\n const resolved = new Map<FolderId, FolderView>();\n const visiting = new Set<FolderId>();\n\n const resolve = (id: FolderId): FolderView => {\n const existing = resolved.get(id);\n if (existing !== undefined) return existing;\n\n const entry = stored.get(id);\n if (entry === undefined) throw new Error(`folder ${id} is not in the document`);\n\n if (visiting.has(id)) {\n // A cycle. Cutting it here, at the folder the walk came back to, keeps the rest of the\n // chain attached below this one instead of scattering every folder in the cycle.\n const lifted = topLevel(id, entry.name, true, entry.description);\n resolved.set(id, lifted);\n healed = true;\n return lifted;\n }\n\n visiting.add(id);\n try {\n const parentId = entry.parent;\n const parent =\n parentId === undefined || !stored.has(parentId) ? undefined : resolve(parentId);\n\n const alreadyResolved = resolved.get(id);\n if (alreadyResolved !== undefined) return alreadyResolved;\n\n const view =\n parent === undefined\n ? topLevel(id, entry.name, parentId !== undefined, entry.description)\n : {\n id,\n name: entry.name,\n parent: parent.id,\n ancestors: [...parent.ancestors, parent.id],\n path: [...parent.path, entry.name],\n ...(entry.description === undefined ? {} : { description: entry.description }),\n lifted: false,\n };\n\n if (view.lifted) healed = true;\n resolved.set(id, view);\n return view;\n } finally {\n visiting.delete(id);\n }\n };\n\n const folders: FolderView[] = [];\n for (const id of stored.keys()) folders.push(resolve(id));\n\n return { folders, byId: resolved, healed };\n}\n\nfunction topLevel(id: FolderId, name: string, lifted: boolean, description?: string): FolderView {\n return {\n id,\n name,\n ancestors: [],\n path: [name],\n ...(description === undefined ? {} : { description }),\n lifted,\n };\n}\n"],"mappings":"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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_block_settings = require("./block_settings.cjs");
|
|
3
|
+
const require_project = require("./project.cjs");
|
|
4
|
+
const require_document = require("./folders/document.cjs");
|
|
5
|
+
const require_decode = require("./folders/decode.cjs");
|
|
6
|
+
const require_view = require("./folders/view.cjs");
|
|
7
|
+
const require_naming = require("./folders/naming.cjs");
|
|
8
|
+
const require_invariants = require("./folders/invariants.cjs");
|
|
9
|
+
const require_planner = require("./folders/planner.cjs");
|
|
10
|
+
const require_removal = require("./folders/removal.cjs");
|
|
11
|
+
const require_commit = require("./folders/commit.cjs");
|
|
12
|
+
const require_inheritance = require("./folders/inheritance.cjs");
|
|
13
|
+
require("./folders/index.cjs");
|
|
3
14
|
const require_content_types = require("./block_meta/content_types.cjs");
|
|
4
15
|
const require_semver = require("./block_meta/semver.cjs");
|
|
5
16
|
const require_content_conversion = require("./block_meta/content_conversion.cjs");
|
|
@@ -13,7 +24,7 @@ const require_block_pack_spec = require("./block_registry/block_pack_spec.cjs");
|
|
|
13
24
|
const require_registry_spec = require("./block_registry/registry_spec.cjs");
|
|
14
25
|
const require_overview = require("./block_registry/overview.cjs");
|
|
15
26
|
require("./block_registry/index.cjs");
|
|
16
|
-
const require_index$
|
|
27
|
+
const require_index$3 = require("./pframe/internal_api/index.cjs");
|
|
17
28
|
const require_json = require("./json.cjs");
|
|
18
29
|
exports.AnyChannel = require_overview.AnyChannel;
|
|
19
30
|
exports.BlockComponentsDescriptionRaw = require_block_components.BlockComponentsDescriptionRaw;
|
|
@@ -51,14 +62,17 @@ exports.ContentRelativeText = require_content_types.ContentRelativeText;
|
|
|
51
62
|
exports.CreateBlockPackDescriptionSchema = require_block_description.CreateBlockPackDescriptionSchema;
|
|
52
63
|
exports.DescriptionContentBinary = require_content_types.DescriptionContentBinary;
|
|
53
64
|
exports.DescriptionContentText = require_content_types.DescriptionContentText;
|
|
65
|
+
exports.FOLDERS_SCHEMA_VERSION = require_document.FOLDERS_SCHEMA_VERSION;
|
|
54
66
|
exports.FeatureFlags = require_block_description.FeatureFlags;
|
|
67
|
+
exports.FolderEntry = require_document.FolderEntry;
|
|
68
|
+
exports.FoldersDocument = require_document.FoldersDocument;
|
|
55
69
|
exports.InitialBlockSettings = require_block_settings.InitialBlockSettings;
|
|
56
70
|
exports.LocalDevFolder = require_registry_spec.LocalDevFolder;
|
|
57
71
|
exports.ManifestFileInfo = require_block_manifest.ManifestFileInfo;
|
|
58
72
|
Object.defineProperty(exports, "PFrameInternal", {
|
|
59
73
|
enumerable: true,
|
|
60
74
|
get: function() {
|
|
61
|
-
return require_index$
|
|
75
|
+
return require_index$3.internal_api_exports;
|
|
62
76
|
}
|
|
63
77
|
});
|
|
64
78
|
exports.RegistryEntry = require_registry_spec.RegistryEntry;
|
|
@@ -74,14 +88,41 @@ exports.StableChannel = require_overview.StableChannel;
|
|
|
74
88
|
exports.VersionWithChannels = require_overview.VersionWithChannels;
|
|
75
89
|
exports.WorkflowSchemaV1 = require_block_components.WorkflowSchemaV1;
|
|
76
90
|
exports.addPrefixToRelative = require_content_conversion.addPrefixToRelative;
|
|
91
|
+
exports.applyFoldersMove = require_planner.applyFoldersMove;
|
|
92
|
+
exports.applyFoldersRemoval = require_removal.applyFoldersRemoval;
|
|
93
|
+
exports.asFolderId = require_document.asFolderId;
|
|
77
94
|
exports.blockPackIdEquals = require_block_id.blockPackIdEquals;
|
|
78
95
|
exports.blockPackIdNoVersionEquals = require_block_id.blockPackIdNoVersionEquals;
|
|
79
96
|
exports.blockPackIdNoVersionToString = require_block_id.blockPackIdNoVersionToString;
|
|
80
97
|
exports.blockPackIdToString = require_block_id.blockPackIdToString;
|
|
81
98
|
exports.blockPackOverviewToLegacy = require_overview.blockPackOverviewToLegacy;
|
|
99
|
+
exports.commitFoldersMove = require_commit.commitFoldersMove;
|
|
100
|
+
exports.commitFoldersRemoval = require_commit.commitFoldersRemoval;
|
|
101
|
+
exports.decodeFoldersDocument = require_decode.decodeFoldersDocument;
|
|
102
|
+
exports.decodeStoredFoldersDocument = require_decode.decodeStoredFoldersDocument;
|
|
103
|
+
exports.emptyFoldersDocument = require_document.emptyFoldersDocument;
|
|
104
|
+
exports.encodeFoldersDocument = require_decode.encodeFoldersDocument;
|
|
105
|
+
exports.foldersChildren = require_view.foldersChildren;
|
|
106
|
+
exports.foldersDocumentFromView = require_view.foldersDocumentFromView;
|
|
107
|
+
exports.foldersMovePlansEqual = require_planner.foldersMovePlansEqual;
|
|
108
|
+
exports.foldersNameBlank = require_naming.foldersNameBlank;
|
|
109
|
+
exports.foldersNameTaken = require_naming.foldersNameTaken;
|
|
110
|
+
exports.foldersRemovalsEqual = require_removal.foldersRemovalsEqual;
|
|
111
|
+
exports.foldersSiblingNames = require_view.foldersSiblingNames;
|
|
112
|
+
exports.foldersSubtree = require_view.foldersSubtree;
|
|
113
|
+
exports.foldersUniqueName = require_naming.foldersUniqueName;
|
|
114
|
+
exports.foldersViewFromDocument = require_view.foldersViewFromDocument;
|
|
115
|
+
exports.formatFoldersViolation = require_invariants.formatFoldersViolation;
|
|
82
116
|
exports.hashJson = require_json.hashJson;
|
|
117
|
+
exports.healFolders = require_view.healFolders;
|
|
118
|
+
exports.inheritedFolder = require_inheritance.inheritedFolder;
|
|
83
119
|
exports.mapRemoteToAbsolute = require_content_conversion.mapRemoteToAbsolute;
|
|
120
|
+
exports.normalizeDescription = require_project.normalizeDescription;
|
|
121
|
+
exports.normalizeProjectMeta = require_project.normalizeProjectMeta;
|
|
84
122
|
exports.overrideDescriptionVersion = require_block_description.overrideDescriptionVersion;
|
|
85
123
|
exports.overrideManifestVersion = require_block_manifest.overrideManifestVersion;
|
|
124
|
+
exports.planFoldersMove = require_planner.planFoldersMove;
|
|
125
|
+
exports.planFoldersRemoval = require_removal.planFoldersRemoval;
|
|
86
126
|
exports.readJson = require_json.readJson;
|
|
87
127
|
exports.readJsonSync = require_json.readJsonSync;
|
|
128
|
+
exports.validateFoldersDocument = require_invariants.validateFoldersDocument;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AuthorMarker } from "./author_marker.js";
|
|
|
2
2
|
import { BlockSettings, InitialBlockSettings, VersionLock } from "./block_settings.js";
|
|
3
3
|
import { StorageDebugView } from "./storage_debug_view.js";
|
|
4
4
|
import { BlockStateInternal, BlockStateInternalV3 } from "./block_state.js";
|
|
5
|
-
import { ProjectMeta } from "./project.js";
|
|
5
|
+
import { ProjectMeta, normalizeDescription, normalizeProjectMeta } from "./project.js";
|
|
6
6
|
import { ProjectListEntry } from "./project_list.js";
|
|
7
7
|
import { BlockPackDevV1, BlockPackDevV2, BlockPackFromPackV2, BlockPackFromRegistryV1, BlockPackFromRegistryV2, BlockPackSpec } from "./block_registry/block_pack_spec.js";
|
|
8
8
|
import { AnyChannel, BlockPackListing, BlockPackOverview, BlockPackOverviewLegacy, BlockPackOverviewNoRegistryId, BlockPackOverviewRaw, RegistryStatus, SingleBlockPackOverview, StableChannel, VersionWithChannels, blockPackOverviewToLegacy } from "./block_registry/overview.js";
|
|
@@ -10,6 +10,16 @@ import { LocalDevFolder, RegistryEntry, RegistryList, RegistrySpec, RemoteRegist
|
|
|
10
10
|
import "./block_registry/index.js";
|
|
11
11
|
import { UpdateSuggestion, UpdateSuggestions } from "./update_info.js";
|
|
12
12
|
import { BlockCalculationStatus, BlockStateOverview, ProjectOverview } from "./project_overview.js";
|
|
13
|
+
import { FOLDERS_SCHEMA_VERSION, FolderEntry, FolderId, FoldersDocument, asFolderId, emptyFoldersDocument } from "./folders/document.js";
|
|
14
|
+
import { FoldersDecoded, FoldersDocumentProblem, FoldersStoredDocument, decodeFoldersDocument, decodeStoredFoldersDocument, encodeFoldersDocument } from "./folders/decode.js";
|
|
15
|
+
import { FolderView, FoldersItemInput, FoldersItemView, FoldersPlacement, FoldersProjectInput, FoldersProjectView, FoldersTemplateInput, FoldersTemplateView, FoldersView, foldersChildren, foldersDocumentFromView, foldersSiblingNames, foldersSubtree, foldersViewFromDocument, healFolders } from "./folders/view.js";
|
|
16
|
+
import { FoldersViolation, formatFoldersViolation, validateFoldersDocument } from "./folders/invariants.js";
|
|
17
|
+
import { foldersNameBlank, foldersNameTaken, foldersUniqueName } from "./folders/naming.js";
|
|
18
|
+
import { FoldersItem, FoldersLabelRename, FoldersLeafItem, FoldersMoveApplication, FoldersMoveEntry, FoldersMoveIssue, FoldersMovePlan, FoldersMovePlanResult, applyFoldersMove, foldersMovePlansEqual, planFoldersMove } from "./folders/planner.js";
|
|
19
|
+
import { FoldersRemoval, FoldersRemovalIssue, FoldersRemovalPlanResult, applyFoldersRemoval, foldersRemovalsEqual, planFoldersRemoval } from "./folders/removal.js";
|
|
20
|
+
import { FoldersEdit, FoldersMoveOutcome, FoldersRemovalOutcome, commitFoldersMove, commitFoldersRemoval } from "./folders/commit.js";
|
|
21
|
+
import { inheritedFolder } from "./folders/inheritance.js";
|
|
22
|
+
import "./folders/index.js";
|
|
13
23
|
import { ContentType, ContextType } from "./block_meta/common.js";
|
|
14
24
|
import { Content, ContentAbsoluteBinaryLocal, ContentAbsoluteFile, ContentAbsoluteFolder, ContentAbsoluteTextLocal, ContentAbsoluteUrl, ContentAnyBinaryLocal, ContentAnyLocal, ContentAnyTextLocal, ContentExplicitBase64, ContentExplicitBytes, ContentExplicitOrRelative, ContentExplicitString, ContentRelative, ContentRelativeBinary, ContentRelativeText, DescriptionContentBinary, DescriptionContentText } from "./block_meta/content_types.js";
|
|
15
25
|
import { SemVer } from "./block_meta/semver.js";
|
|
@@ -23,4 +33,4 @@ import "./block_meta/index.js";
|
|
|
23
33
|
import { index_d_exports } from "./pframe/internal_api/index.js";
|
|
24
34
|
import "./pframe/index.js";
|
|
25
35
|
import { HashedJson, hashJson, readJson, readJsonSync } from "./json.js";
|
|
26
|
-
export { AnyChannel, type AuthorMarker, BlockCalculationStatus, BlockComponents, BlockComponentsDescriptionRaw, BlockComponentsManifest, BlockKindRef, BlockPackDescription, BlockPackDescriptionFromPackageJsonRaw, BlockPackDescriptionManifest, BlockPackDescriptionRaw, BlockPackDevV1, BlockPackDevV2, BlockPackFromPackV2, BlockPackFromRegistryV1, BlockPackFromRegistryV2, BlockPackId, BlockPackIdNoVersion, BlockPackListing, BlockPackManifest, BlockPackManifestFile, BlockPackMeta, BlockPackMetaDescriptionRaw, BlockPackMetaEmbeddedBase64, BlockPackMetaEmbeddedBytes, BlockPackMetaManifest, BlockPackOverview, BlockPackOverviewLegacy, BlockPackOverviewNoRegistryId, BlockPackOverviewRaw, BlockPackSpec, BlockPlatform, BlockSettings, BlockStateInternal, BlockStateInternalV3, BlockStateOverview, Content, ContentAbsoluteBinaryLocal, ContentAbsoluteFile, ContentAbsoluteFolder, ContentAbsoluteTextLocal, ContentAbsoluteUrl, ContentAnyBinaryLocal, ContentAnyLocal, ContentAnyTextLocal, ContentExplicitBase64, ContentExplicitBytes, ContentExplicitOrRelative, ContentExplicitString, ContentRelative, ContentRelativeBinary, ContentRelativeText, ContentType, ContextType, CreateBlockPackDescriptionSchema, DescriptionContentBinary, DescriptionContentText, FeatureFlags, HashedJson, InitialBlockSettings, LocalDevFolder, ManifestFileInfo, index_d_exports as PFrameInternal, ProjectListEntry, ProjectMeta, ProjectOverview, RegistryEntry, RegistryList, RegistrySpec, RegistryStatus, RemoteRegistryV1Spec, RemoteRegistryV2Spec, SemVer, Sha256Schema, SingleBlockPackOverview, StableChannel, StorageDebugView, UpdateSuggestion, UpdateSuggestions, VersionLock, VersionWithChannels, Workflow, WorkflowSchemaV1, WorkflowV1, addPrefixToRelative, blockPackIdEquals, blockPackIdNoVersionEquals, blockPackIdNoVersionToString, blockPackIdToString, blockPackOverviewToLegacy, hashJson, mapRemoteToAbsolute, overrideDescriptionVersion, overrideManifestVersion, readJson, readJsonSync };
|
|
36
|
+
export { AnyChannel, type AuthorMarker, BlockCalculationStatus, BlockComponents, BlockComponentsDescriptionRaw, BlockComponentsManifest, BlockKindRef, BlockPackDescription, BlockPackDescriptionFromPackageJsonRaw, BlockPackDescriptionManifest, BlockPackDescriptionRaw, BlockPackDevV1, BlockPackDevV2, BlockPackFromPackV2, BlockPackFromRegistryV1, BlockPackFromRegistryV2, BlockPackId, BlockPackIdNoVersion, BlockPackListing, BlockPackManifest, BlockPackManifestFile, BlockPackMeta, BlockPackMetaDescriptionRaw, BlockPackMetaEmbeddedBase64, BlockPackMetaEmbeddedBytes, BlockPackMetaManifest, BlockPackOverview, BlockPackOverviewLegacy, BlockPackOverviewNoRegistryId, BlockPackOverviewRaw, BlockPackSpec, BlockPlatform, BlockSettings, BlockStateInternal, BlockStateInternalV3, BlockStateOverview, Content, ContentAbsoluteBinaryLocal, ContentAbsoluteFile, ContentAbsoluteFolder, ContentAbsoluteTextLocal, ContentAbsoluteUrl, ContentAnyBinaryLocal, ContentAnyLocal, ContentAnyTextLocal, ContentExplicitBase64, ContentExplicitBytes, ContentExplicitOrRelative, ContentExplicitString, ContentRelative, ContentRelativeBinary, ContentRelativeText, ContentType, ContextType, CreateBlockPackDescriptionSchema, DescriptionContentBinary, DescriptionContentText, FOLDERS_SCHEMA_VERSION, FeatureFlags, FolderEntry, FolderId, FolderView, FoldersDecoded, FoldersDocument, FoldersDocumentProblem, FoldersEdit, FoldersItem, FoldersItemInput, FoldersItemView, FoldersLabelRename, FoldersLeafItem, FoldersMoveApplication, FoldersMoveEntry, FoldersMoveIssue, FoldersMoveOutcome, FoldersMovePlan, FoldersMovePlanResult, FoldersPlacement, FoldersProjectInput, FoldersProjectView, FoldersRemoval, FoldersRemovalIssue, FoldersRemovalOutcome, FoldersRemovalPlanResult, FoldersStoredDocument, FoldersTemplateInput, FoldersTemplateView, FoldersView, FoldersViolation, HashedJson, InitialBlockSettings, LocalDevFolder, ManifestFileInfo, index_d_exports as PFrameInternal, ProjectListEntry, ProjectMeta, ProjectOverview, RegistryEntry, RegistryList, RegistrySpec, RegistryStatus, RemoteRegistryV1Spec, RemoteRegistryV2Spec, SemVer, Sha256Schema, SingleBlockPackOverview, StableChannel, StorageDebugView, UpdateSuggestion, UpdateSuggestions, VersionLock, VersionWithChannels, Workflow, WorkflowSchemaV1, WorkflowV1, addPrefixToRelative, applyFoldersMove, applyFoldersRemoval, asFolderId, blockPackIdEquals, blockPackIdNoVersionEquals, blockPackIdNoVersionToString, blockPackIdToString, blockPackOverviewToLegacy, commitFoldersMove, commitFoldersRemoval, decodeFoldersDocument, decodeStoredFoldersDocument, emptyFoldersDocument, encodeFoldersDocument, foldersChildren, foldersDocumentFromView, foldersMovePlansEqual, foldersNameBlank, foldersNameTaken, foldersRemovalsEqual, foldersSiblingNames, foldersSubtree, foldersUniqueName, foldersViewFromDocument, formatFoldersViolation, hashJson, healFolders, inheritedFolder, mapRemoteToAbsolute, normalizeDescription, normalizeProjectMeta, overrideDescriptionVersion, overrideManifestVersion, planFoldersMove, planFoldersRemoval, readJson, readJsonSync, validateFoldersDocument };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { InitialBlockSettings } from "./block_settings.js";
|
|
2
|
+
import { normalizeDescription, normalizeProjectMeta } from "./project.js";
|
|
3
|
+
import { FOLDERS_SCHEMA_VERSION, FolderEntry, FoldersDocument, asFolderId, emptyFoldersDocument } from "./folders/document.js";
|
|
4
|
+
import { decodeFoldersDocument, decodeStoredFoldersDocument, encodeFoldersDocument } from "./folders/decode.js";
|
|
5
|
+
import { foldersChildren, foldersDocumentFromView, foldersSiblingNames, foldersSubtree, foldersViewFromDocument, healFolders } from "./folders/view.js";
|
|
6
|
+
import { foldersNameBlank, foldersNameTaken, foldersUniqueName } from "./folders/naming.js";
|
|
7
|
+
import { formatFoldersViolation, validateFoldersDocument } from "./folders/invariants.js";
|
|
8
|
+
import { applyFoldersMove, foldersMovePlansEqual, planFoldersMove } from "./folders/planner.js";
|
|
9
|
+
import { applyFoldersRemoval, foldersRemovalsEqual, planFoldersRemoval } from "./folders/removal.js";
|
|
10
|
+
import { commitFoldersMove, commitFoldersRemoval } from "./folders/commit.js";
|
|
11
|
+
import { inheritedFolder } from "./folders/inheritance.js";
|
|
12
|
+
import "./folders/index.js";
|
|
2
13
|
import { ContentExplicitBase64, ContentExplicitBytes, ContentRelative, ContentRelativeBinary, ContentRelativeText, DescriptionContentBinary, DescriptionContentText } from "./block_meta/content_types.js";
|
|
3
14
|
import { SemVer } from "./block_meta/semver.js";
|
|
4
15
|
import { addPrefixToRelative, mapRemoteToAbsolute } from "./block_meta/content_conversion.js";
|
|
@@ -14,4 +25,4 @@ import { AnyChannel, BlockPackListing, BlockPackOverview, BlockPackOverviewLegac
|
|
|
14
25
|
import "./block_registry/index.js";
|
|
15
26
|
import { internal_api_exports } from "./pframe/internal_api/index.js";
|
|
16
27
|
import { hashJson, readJson, readJsonSync } from "./json.js";
|
|
17
|
-
export { AnyChannel, BlockComponentsDescriptionRaw, BlockComponentsManifest, BlockKindRef, BlockPackDescriptionFromPackageJsonRaw, BlockPackDescriptionManifest, BlockPackDescriptionRaw, BlockPackDevV1, BlockPackDevV2, BlockPackFromPackV2, BlockPackFromRegistryV1, BlockPackFromRegistryV2, BlockPackId, BlockPackIdNoVersion, BlockPackListing, BlockPackManifest, BlockPackManifestFile, BlockPackMeta, BlockPackMetaDescriptionRaw, BlockPackMetaEmbeddedBase64, BlockPackMetaEmbeddedBytes, BlockPackMetaManifest, BlockPackOverview, BlockPackOverviewLegacy, BlockPackOverviewNoRegistryId, BlockPackOverviewRaw, BlockPackSpec, BlockPlatform, ContentExplicitBase64, ContentExplicitBytes, ContentRelative, ContentRelativeBinary, ContentRelativeText, CreateBlockPackDescriptionSchema, DescriptionContentBinary, DescriptionContentText, FeatureFlags, InitialBlockSettings, LocalDevFolder, ManifestFileInfo, internal_api_exports as PFrameInternal, RegistryEntry, RegistryList, RegistrySpec, RegistryStatus, RemoteRegistryV1Spec, RemoteRegistryV2Spec, SemVer, Sha256Schema, SingleBlockPackOverview, StableChannel, VersionWithChannels, WorkflowSchemaV1, addPrefixToRelative, blockPackIdEquals, blockPackIdNoVersionEquals, blockPackIdNoVersionToString, blockPackIdToString, blockPackOverviewToLegacy, hashJson, mapRemoteToAbsolute, overrideDescriptionVersion, overrideManifestVersion, readJson, readJsonSync };
|
|
28
|
+
export { AnyChannel, BlockComponentsDescriptionRaw, BlockComponentsManifest, BlockKindRef, BlockPackDescriptionFromPackageJsonRaw, BlockPackDescriptionManifest, BlockPackDescriptionRaw, BlockPackDevV1, BlockPackDevV2, BlockPackFromPackV2, BlockPackFromRegistryV1, BlockPackFromRegistryV2, BlockPackId, BlockPackIdNoVersion, BlockPackListing, BlockPackManifest, BlockPackManifestFile, BlockPackMeta, BlockPackMetaDescriptionRaw, BlockPackMetaEmbeddedBase64, BlockPackMetaEmbeddedBytes, BlockPackMetaManifest, BlockPackOverview, BlockPackOverviewLegacy, BlockPackOverviewNoRegistryId, BlockPackOverviewRaw, BlockPackSpec, BlockPlatform, ContentExplicitBase64, ContentExplicitBytes, ContentRelative, ContentRelativeBinary, ContentRelativeText, CreateBlockPackDescriptionSchema, DescriptionContentBinary, DescriptionContentText, FOLDERS_SCHEMA_VERSION, FeatureFlags, FolderEntry, FoldersDocument, InitialBlockSettings, LocalDevFolder, ManifestFileInfo, internal_api_exports as PFrameInternal, RegistryEntry, RegistryList, RegistrySpec, RegistryStatus, RemoteRegistryV1Spec, RemoteRegistryV2Spec, SemVer, Sha256Schema, SingleBlockPackOverview, StableChannel, VersionWithChannels, WorkflowSchemaV1, addPrefixToRelative, applyFoldersMove, applyFoldersRemoval, asFolderId, blockPackIdEquals, blockPackIdNoVersionEquals, blockPackIdNoVersionToString, blockPackIdToString, blockPackOverviewToLegacy, commitFoldersMove, commitFoldersRemoval, decodeFoldersDocument, decodeStoredFoldersDocument, emptyFoldersDocument, encodeFoldersDocument, foldersChildren, foldersDocumentFromView, foldersMovePlansEqual, foldersNameBlank, foldersNameTaken, foldersRemovalsEqual, foldersSiblingNames, foldersSubtree, foldersUniqueName, foldersViewFromDocument, formatFoldersViolation, hashJson, healFolders, inheritedFolder, mapRemoteToAbsolute, normalizeDescription, normalizeProjectMeta, overrideDescriptionVersion, overrideManifestVersion, planFoldersMove, planFoldersRemoval, readJson, readJsonSync, validateFoldersDocument };
|
package/dist/project.cjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region src/project.ts
|
|
2
|
+
/**
|
|
3
|
+
* A description as it is stored: trimmed, and absent when nothing is left. A description of
|
|
4
|
+
* whitespace only is no description, and storing it as an empty string would make an untouched
|
|
5
|
+
* item and a cleared one look different everywhere the value is compared or rendered.
|
|
6
|
+
*/
|
|
7
|
+
function normalizeDescription(text) {
|
|
8
|
+
const trimmed = text?.trim();
|
|
9
|
+
return trimmed === void 0 || trimmed === "" ? void 0 : trimmed;
|
|
10
|
+
}
|
|
11
|
+
/** Project metadata with a blank description left out. */
|
|
12
|
+
function normalizeProjectMeta(meta) {
|
|
13
|
+
const description = normalizeDescription(meta.description);
|
|
14
|
+
return description === void 0 ? { label: meta.label } : {
|
|
15
|
+
label: meta.label,
|
|
16
|
+
description
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.normalizeDescription = normalizeDescription;
|
|
21
|
+
exports.normalizeProjectMeta = normalizeProjectMeta;
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=project.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.cjs","names":[],"sources":["../src/project.ts"],"sourcesContent":["export interface ProjectMeta {\n /** Project name */\n readonly label: string;\n /**\n * Free text the user wrote about the project. Absent when there is none — a project nobody\n * described and one whose description was cleared carry the same metadata.\n */\n readonly description?: string;\n}\n\n/**\n * A description as it is stored: trimmed, and absent when nothing is left. A description of\n * whitespace only is no description, and storing it as an empty string would make an untouched\n * item and a cleared one look different everywhere the value is compared or rendered.\n */\nexport function normalizeDescription(text?: string): string | undefined {\n const trimmed = text?.trim();\n return trimmed === undefined || trimmed === \"\" ? undefined : trimmed;\n}\n\n/** Project metadata with a blank description left out. */\nexport function normalizeProjectMeta(meta: ProjectMeta): ProjectMeta {\n const description = normalizeDescription(meta.description);\n return description === undefined ? { label: meta.label } : { label: meta.label, description };\n}\n"],"mappings":";;;;;;AAeA,SAAgB,qBAAqB,MAAmC;CACtE,MAAM,UAAU,MAAM,KAAK;CAC3B,OAAO,YAAY,KAAA,KAAa,YAAY,KAAK,KAAA,IAAY;AAC/D;;AAGA,SAAgB,qBAAqB,MAAgC;CACnE,MAAM,cAAc,qBAAqB,KAAK,WAAW;CACzD,OAAO,gBAAgB,KAAA,IAAY,EAAE,OAAO,KAAK,MAAM,IAAI;EAAE,OAAO,KAAK;EAAO;CAAY;AAC9F"}
|
package/dist/project.d.ts
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
export interface ProjectMeta {
|
|
3
3
|
/** Project name */
|
|
4
4
|
readonly label: string;
|
|
5
|
+
/**
|
|
6
|
+
* Free text the user wrote about the project. Absent when there is none — a project nobody
|
|
7
|
+
* described and one whose description was cleared carry the same metadata.
|
|
8
|
+
*/
|
|
9
|
+
readonly description?: string;
|
|
5
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* A description as it is stored: trimmed, and absent when nothing is left. A description of
|
|
13
|
+
* whitespace only is no description, and storing it as an empty string would make an untouched
|
|
14
|
+
* item and a cleared one look different everywhere the value is compared or rendered.
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizeDescription(text?: string): string | undefined;
|
|
17
|
+
/** Project metadata with a blank description left out. */
|
|
18
|
+
export declare function normalizeProjectMeta(meta: ProjectMeta): ProjectMeta;
|
|
6
19
|
//#endregion
|
|
7
20
|
//# sourceMappingURL=project.d.ts.map
|
package/dist/project.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","names":[],"sources":["../src/project.ts"],"mappings":";iBAAiB;;WAEN"}
|
|
1
|
+
{"version":3,"file":"project.d.ts","names":[],"sources":["../src/project.ts"],"mappings":";iBAAiB;;WAEN;;;;;WAKA;;;;;;;wBAQK,qBAAqB;;wBAMrB,qBAAqB,MAAM,cAAc"}
|
package/dist/project.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/project.ts
|
|
2
|
+
/**
|
|
3
|
+
* A description as it is stored: trimmed, and absent when nothing is left. A description of
|
|
4
|
+
* whitespace only is no description, and storing it as an empty string would make an untouched
|
|
5
|
+
* item and a cleared one look different everywhere the value is compared or rendered.
|
|
6
|
+
*/
|
|
7
|
+
function normalizeDescription(text) {
|
|
8
|
+
const trimmed = text?.trim();
|
|
9
|
+
return trimmed === void 0 || trimmed === "" ? void 0 : trimmed;
|
|
10
|
+
}
|
|
11
|
+
/** Project metadata with a blank description left out. */
|
|
12
|
+
function normalizeProjectMeta(meta) {
|
|
13
|
+
const description = normalizeDescription(meta.description);
|
|
14
|
+
return description === void 0 ? { label: meta.label } : {
|
|
15
|
+
label: meta.label,
|
|
16
|
+
description
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { normalizeDescription, normalizeProjectMeta };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","names":[],"sources":["../src/project.ts"],"sourcesContent":["export interface ProjectMeta {\n /** Project name */\n readonly label: string;\n /**\n * Free text the user wrote about the project. Absent when there is none — a project nobody\n * described and one whose description was cleared carry the same metadata.\n */\n readonly description?: string;\n}\n\n/**\n * A description as it is stored: trimmed, and absent when nothing is left. A description of\n * whitespace only is no description, and storing it as an empty string would make an untouched\n * item and a cleared one look different everywhere the value is compared or rendered.\n */\nexport function normalizeDescription(text?: string): string | undefined {\n const trimmed = text?.trim();\n return trimmed === undefined || trimmed === \"\" ? undefined : trimmed;\n}\n\n/** Project metadata with a blank description left out. */\nexport function normalizeProjectMeta(meta: ProjectMeta): ProjectMeta {\n const description = normalizeDescription(meta.description);\n return description === undefined ? { label: meta.label } : { label: meta.label, description };\n}\n"],"mappings":";;;;;;AAeA,SAAgB,qBAAqB,MAAmC;CACtE,MAAM,UAAU,MAAM,KAAK;CAC3B,OAAO,YAAY,KAAA,KAAa,YAAY,KAAK,KAAA,IAAY;AAC/D;;AAGA,SAAgB,qBAAqB,MAAgC;CACnE,MAAM,cAAc,qBAAqB,KAAK,WAAW;CACzD,OAAO,gBAAgB,KAAA,IAAY,EAAE,OAAO,KAAK,MAAM,IAAI;EAAE,OAAO,KAAK;EAAO;CAAY;AAC9F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-model-middle-layer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.33.0",
|
|
4
4
|
"description": "Common model between middle layer and non-block UI code",
|
|
5
5
|
"files": [
|
|
6
6
|
"./dist/**/*",
|
|
@@ -20,20 +20,23 @@
|
|
|
20
20
|
"es-toolkit": "^1.39.10",
|
|
21
21
|
"utility-types": "^3.11.0",
|
|
22
22
|
"zod": "~3.25.76",
|
|
23
|
-
"@milaboratories/
|
|
24
|
-
"@milaboratories/
|
|
23
|
+
"@milaboratories/helpers": "1.14.5",
|
|
24
|
+
"@milaboratories/pl-model-common": "1.51.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "~24.5.2",
|
|
28
|
+
"@vitest/coverage-istanbul": "^4.1.3",
|
|
28
29
|
"typescript": "7.0.2",
|
|
29
|
-
"
|
|
30
|
+
"vitest": "^4.1.3",
|
|
30
31
|
"@milaboratories/ts-configs": "1.4.0",
|
|
32
|
+
"@milaboratories/build-configs": "2.0.2",
|
|
31
33
|
"@milaboratories/ts-builder": "1.7.2"
|
|
32
34
|
},
|
|
33
35
|
"scripts": {
|
|
34
36
|
"build": "ts-builder build --target node",
|
|
35
37
|
"watch": "ts-builder build --target node --watch",
|
|
36
38
|
"check": "ts-builder check --target node",
|
|
39
|
+
"test": "vitest run --coverage",
|
|
37
40
|
"formatter:check": "ts-builder formatter --check",
|
|
38
41
|
"linter:check": "ts-builder linter --check",
|
|
39
42
|
"types:check": "ts-builder type-check --target node",
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { ProjectId, TemplateId } from "@milaboratories/pl-model-common";
|
|
2
|
+
import type { FoldersDocument } from "./document";
|
|
3
|
+
import type {
|
|
4
|
+
FoldersLabelRename,
|
|
5
|
+
FoldersMoveIssue,
|
|
6
|
+
FoldersMovePlan,
|
|
7
|
+
FoldersMovePlanResult,
|
|
8
|
+
} from "./planner";
|
|
9
|
+
import { applyFoldersMove, foldersMovePlansEqual } from "./planner";
|
|
10
|
+
import type { FoldersRemoval, FoldersRemovalIssue, FoldersRemovalPlanResult } from "./removal";
|
|
11
|
+
import { applyFoldersRemoval, foldersRemovalsEqual } from "./removal";
|
|
12
|
+
import type { FoldersView } from "./view";
|
|
13
|
+
|
|
14
|
+
/** What one attempt of a folder write decided to do. */
|
|
15
|
+
export interface FoldersEdit<T> {
|
|
16
|
+
/** Value handed back to the caller, whether or not anything is written. */
|
|
17
|
+
readonly result: T;
|
|
18
|
+
/** The document to persist. Absent means write nothing — a refused plan, or a no-op. */
|
|
19
|
+
readonly document?: FoldersDocument;
|
|
20
|
+
/** Project and template labels the edit changes; their names live in their own metadata. */
|
|
21
|
+
readonly labelRenames?: readonly FoldersLabelRename[];
|
|
22
|
+
/** Projects the edit destroys. A folder deletion is the only edit that sets this. */
|
|
23
|
+
readonly deletedProjects?: readonly ProjectId[];
|
|
24
|
+
/** Templates the edit destroys. A folder deletion is the only edit that sets this. */
|
|
25
|
+
readonly deletedTemplates?: readonly TemplateId[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* What a move did.
|
|
30
|
+
*
|
|
31
|
+
* `plan-changed` is the whole point of the confirm step: the plan was recomputed inside the write
|
|
32
|
+
* transaction, it no longer matches the one the user confirmed, and nothing was written. The
|
|
33
|
+
* fresh plan comes back to be confirmed again, so a confirmation dialog cannot lie about what an
|
|
34
|
+
* item will end up called. `needs-confirmation` is the same guarantee reached from the other
|
|
35
|
+
* side — a caller that supplied no plan at all for a move that renames something.
|
|
36
|
+
*
|
|
37
|
+
* All four cases have to be handled by whoever calls a move, which is why this type lives in this
|
|
38
|
+
* package rather than in the node package.
|
|
39
|
+
*/
|
|
40
|
+
export type FoldersMoveOutcome =
|
|
41
|
+
| { readonly ok: true; readonly plan: FoldersMovePlan }
|
|
42
|
+
| { readonly ok: false; readonly reason: "plan-changed"; readonly plan: FoldersMovePlan }
|
|
43
|
+
| {
|
|
44
|
+
readonly ok: false;
|
|
45
|
+
readonly reason: "needs-confirmation";
|
|
46
|
+
readonly plan: FoldersMovePlan;
|
|
47
|
+
}
|
|
48
|
+
| {
|
|
49
|
+
readonly ok: false;
|
|
50
|
+
readonly reason: "cannot-plan";
|
|
51
|
+
readonly issues: readonly FoldersMoveIssue[];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** What a folder deletion did. */
|
|
55
|
+
export type FoldersRemovalOutcome =
|
|
56
|
+
| { readonly ok: true; readonly removal: FoldersRemoval }
|
|
57
|
+
| {
|
|
58
|
+
readonly ok: false;
|
|
59
|
+
readonly reason: "plan-changed";
|
|
60
|
+
readonly removal: FoldersRemoval;
|
|
61
|
+
}
|
|
62
|
+
| {
|
|
63
|
+
readonly ok: false;
|
|
64
|
+
readonly reason: "needs-confirmation";
|
|
65
|
+
readonly removal: FoldersRemoval;
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
readonly ok: false;
|
|
69
|
+
readonly reason: "cannot-plan";
|
|
70
|
+
readonly issues: readonly FoldersRemovalIssue[];
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The one place a move plan turns into a write.
|
|
75
|
+
*
|
|
76
|
+
* A move that renames nothing commits without a confirmed plan, because there is nothing to
|
|
77
|
+
* confirm. A move that renames something needs one, and a confirmed plan must equal the plan
|
|
78
|
+
* recomputed here, or nothing is written and the fresh plan goes back to be confirmed. A move of
|
|
79
|
+
* nothing writes nothing.
|
|
80
|
+
*/
|
|
81
|
+
export function commitFoldersMove(
|
|
82
|
+
view: FoldersView,
|
|
83
|
+
planned: FoldersMovePlanResult,
|
|
84
|
+
confirmedPlan: FoldersMovePlan | undefined,
|
|
85
|
+
): FoldersEdit<FoldersMoveOutcome> {
|
|
86
|
+
if (!planned.ok) return { result: { ok: false, reason: "cannot-plan", issues: planned.issues } };
|
|
87
|
+
|
|
88
|
+
if (confirmedPlan !== undefined) {
|
|
89
|
+
if (!foldersMovePlansEqual(planned.plan, confirmedPlan))
|
|
90
|
+
return { result: { ok: false, reason: "plan-changed", plan: planned.plan } };
|
|
91
|
+
} else if (planned.plan.entries.some((entry) => entry.renamed)) {
|
|
92
|
+
return { result: { ok: false, reason: "needs-confirmation", plan: planned.plan } };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// A move of nothing changes nothing. Without this it still mints a value and re-points the
|
|
96
|
+
// field, so an empty selection would conflict with whatever else is editing the tree and would
|
|
97
|
+
// persist a heal nobody asked for.
|
|
98
|
+
if (planned.plan.entries.length === 0) return { result: { ok: true, plan: planned.plan } };
|
|
99
|
+
|
|
100
|
+
const applied = applyFoldersMove(view, planned.plan);
|
|
101
|
+
return {
|
|
102
|
+
result: { ok: true, plan: planned.plan },
|
|
103
|
+
document: applied.document,
|
|
104
|
+
labelRenames: applied.labelRenames,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The one place a removal turns into a write.
|
|
110
|
+
*
|
|
111
|
+
* A deletion always needs a confirmed removal, however little it destroys: unlike a move, it has
|
|
112
|
+
* no harmless outcome to fall back on.
|
|
113
|
+
*/
|
|
114
|
+
export function commitFoldersRemoval(
|
|
115
|
+
view: FoldersView,
|
|
116
|
+
planned: FoldersRemovalPlanResult,
|
|
117
|
+
confirmed: FoldersRemoval | undefined,
|
|
118
|
+
): FoldersEdit<FoldersRemovalOutcome> {
|
|
119
|
+
if (!planned.ok) return { result: { ok: false, reason: "cannot-plan", issues: planned.issues } };
|
|
120
|
+
|
|
121
|
+
if (confirmed === undefined)
|
|
122
|
+
return { result: { ok: false, reason: "needs-confirmation", removal: planned.removal } };
|
|
123
|
+
|
|
124
|
+
if (!foldersRemovalsEqual(planned.removal, confirmed))
|
|
125
|
+
return { result: { ok: false, reason: "plan-changed", removal: planned.removal } };
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
result: { ok: true, removal: planned.removal },
|
|
129
|
+
document: applyFoldersRemoval(view, planned.removal),
|
|
130
|
+
deletedProjects: planned.removal.projects,
|
|
131
|
+
deletedTemplates: planned.removal.templates,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
decodeFoldersDocument,
|
|
4
|
+
decodeStoredFoldersDocument,
|
|
5
|
+
encodeFoldersDocument,
|
|
6
|
+
} from "./decode";
|
|
7
|
+
import { FOLDERS_SCHEMA_VERSION, emptyFoldersDocument } from "./document";
|
|
8
|
+
import { document } from "./test_utils";
|
|
9
|
+
|
|
10
|
+
const validDocument = document(
|
|
11
|
+
[
|
|
12
|
+
{ id: "f1", name: "Samples" },
|
|
13
|
+
{ id: "f2", name: "Runs", parent: "f1" },
|
|
14
|
+
],
|
|
15
|
+
{ p1: "f2" },
|
|
16
|
+
{ t1: "f1" },
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
describe("decodeStoredFoldersDocument", () => {
|
|
20
|
+
test("no stored document is a user with no folders, and writes stay allowed", () => {
|
|
21
|
+
const decoded = decodeStoredFoldersDocument({ present: false });
|
|
22
|
+
expect(decoded.document).toEqual(emptyFoldersDocument());
|
|
23
|
+
expect(decoded.writable).toBe(true);
|
|
24
|
+
expect(decoded.problem).toBeUndefined();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("a stored document without bytes reads as no folders and refuses writes", () => {
|
|
28
|
+
for (const raw of [undefined, ""]) {
|
|
29
|
+
const decoded = decodeStoredFoldersDocument({ present: true, raw });
|
|
30
|
+
expect(decoded.document).toEqual(emptyFoldersDocument());
|
|
31
|
+
expect(decoded.writable).toBe(false);
|
|
32
|
+
expect(decoded.problem).toEqual({
|
|
33
|
+
kind: "unreadable",
|
|
34
|
+
message: "the folder document is stored in a shape this build cannot read",
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("a stored document of whitespace only is not JSON, and refuses writes", () => {
|
|
40
|
+
const decoded = decodeStoredFoldersDocument({ present: true, raw: " " });
|
|
41
|
+
expect(decoded.writable).toBe(false);
|
|
42
|
+
expect(decoded.problem?.kind).toBe("unreadable");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("a stored document with bytes is decoded", () => {
|
|
46
|
+
const decoded = decodeStoredFoldersDocument({
|
|
47
|
+
present: true,
|
|
48
|
+
raw: JSON.stringify(validDocument),
|
|
49
|
+
});
|
|
50
|
+
expect(decoded.writable).toBe(true);
|
|
51
|
+
expect(decoded.document).toEqual(validDocument);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe("decodeFoldersDocument", () => {
|
|
56
|
+
test("a current document round-trips", () => {
|
|
57
|
+
const encoded = encodeFoldersDocument(validDocument);
|
|
58
|
+
const decoded = decodeFoldersDocument(encoded);
|
|
59
|
+
expect(decoded.writable).toBe(true);
|
|
60
|
+
expect(decoded.document).toEqual(validDocument);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("a document written by a newer build reads as no folders and refuses writes", () => {
|
|
64
|
+
const decoded = decodeFoldersDocument(
|
|
65
|
+
JSON.stringify({ ...validDocument, schemaVersion: FOLDERS_SCHEMA_VERSION + 1 }),
|
|
66
|
+
);
|
|
67
|
+
expect(decoded.document).toEqual(emptyFoldersDocument());
|
|
68
|
+
expect(decoded.writable).toBe(false);
|
|
69
|
+
expect(decoded.problem?.kind).toBe("newer-schema");
|
|
70
|
+
if (decoded.problem?.kind === "newer-schema")
|
|
71
|
+
expect(decoded.problem.documentSchemaVersion).toBe(FOLDERS_SCHEMA_VERSION + 1);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("invalid JSON reads as no folders and refuses writes", () => {
|
|
75
|
+
const decoded = decodeFoldersDocument("{not json");
|
|
76
|
+
expect(decoded.document).toEqual(emptyFoldersDocument());
|
|
77
|
+
expect(decoded.writable).toBe(false);
|
|
78
|
+
expect(decoded.problem?.kind).toBe("unreadable");
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test("a document of the right version but the wrong shape refuses writes", () => {
|
|
82
|
+
for (const value of [
|
|
83
|
+
{ ...validDocument, folders: "nope" },
|
|
84
|
+
{ ...validDocument, folders: [{ id: "f1" }] },
|
|
85
|
+
{ ...validDocument, folders: [{ id: "f1", name: "" }] },
|
|
86
|
+
{ ...validDocument, assignments: { p1: 7 } },
|
|
87
|
+
{ ...validDocument, templateAssignments: { t1: 7 } },
|
|
88
|
+
{ ...validDocument, extra: 1 },
|
|
89
|
+
{ schemaVersion: FOLDERS_SCHEMA_VERSION, folders: [], assignments: {} },
|
|
90
|
+
]) {
|
|
91
|
+
const decoded = decodeFoldersDocument(JSON.stringify(value));
|
|
92
|
+
expect(decoded.writable).toBe(false);
|
|
93
|
+
expect(decoded.problem?.kind).toBe("unreadable");
|
|
94
|
+
expect(decoded.document).toEqual(emptyFoldersDocument());
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("a value that is not an object, or carries no usable version, refuses writes", () => {
|
|
99
|
+
for (const value of [
|
|
100
|
+
null,
|
|
101
|
+
7,
|
|
102
|
+
[],
|
|
103
|
+
"text",
|
|
104
|
+
{},
|
|
105
|
+
{ schemaVersion: "1" },
|
|
106
|
+
{ schemaVersion: 0 },
|
|
107
|
+
{ schemaVersion: 1.5 },
|
|
108
|
+
]) {
|
|
109
|
+
const decoded = decodeFoldersDocument(JSON.stringify(value));
|
|
110
|
+
expect(decoded.writable).toBe(false);
|
|
111
|
+
expect(decoded.problem?.kind).toBe("unreadable");
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test("the problem names the schema version it checked against", () => {
|
|
116
|
+
const decoded = decodeFoldersDocument(
|
|
117
|
+
JSON.stringify({ ...validDocument, folders: [{ id: "f1" }] }),
|
|
118
|
+
);
|
|
119
|
+
expect(decoded.problem?.message).toBe(
|
|
120
|
+
`the folder document does not match schema ${FOLDERS_SCHEMA_VERSION}: folders.0.name: Required`,
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("the problem carries a message a log can be read from", () => {
|
|
125
|
+
const decoded = decodeFoldersDocument("{not json");
|
|
126
|
+
expect(decoded.problem?.message).toMatch(/folder document/);
|
|
127
|
+
});
|
|
128
|
+
});
|