@milaboratories/pl-middle-layer 1.70.0 → 1.71.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.
@@ -1,52 +0,0 @@
1
- import type { ProjectTemplateV1 } from "@milaboratories/pl-model-common";
2
- import { parseBlockPackLocation } from "@milaboratories/pl-model-common";
3
-
4
- /** One template entry standing in the way of sharing the template, and why. */
5
- export type TemplateShareProblem = {
6
- /** The template-local id of the entry the problem belongs to; on an exported template it is
7
- * the block's project-local uuid. */
8
- readonly entryId: string;
9
- readonly error: string;
10
- };
11
-
12
- /**
13
- * Every entry of a template that cannot travel to another machine, or an empty list for a
14
- * template that can be shared.
15
- *
16
- * An entry's `location` names a place rather than a name, and a `file:` place is a folder on
17
- * the author's own disk: a recipient resolving it finds nothing, or worse finds something
18
- * else. Such a template stays perfectly usable where it was made, so it is stored and applied
19
- * as normal — only sharing it is refused.
20
- *
21
- * A location whose scheme cannot be read is refused for the same reason: nothing can resolve
22
- * it anywhere, here included.
23
- *
24
- * Every offending entry is reported, not only the first, so a UI can name each block instead
25
- * of sending its user round the loop once per entry.
26
- */
27
- export function unshareableTemplateEntries(
28
- document: ProjectTemplateV1,
29
- ): readonly TemplateShareProblem[] {
30
- const problems: TemplateShareProblem[] = [];
31
- for (const entry of document.blocks) {
32
- if (entry.location === undefined) continue;
33
- let scheme: string;
34
- try {
35
- scheme = parseBlockPackLocation(entry.location).scheme;
36
- } catch (e) {
37
- problems.push({
38
- entryId: entry.id,
39
- error: `Block is installed from a location nothing can resolve: ${e instanceof Error ? e.message : String(e)}`,
40
- });
41
- continue;
42
- }
43
- if (scheme === "file")
44
- problems.push({
45
- entryId: entry.id,
46
- error:
47
- `Block is installed from ${entry.location}, a folder on this machine — it resolves ` +
48
- "to nothing on the recipient's, so this template cannot be shared",
49
- });
50
- }
51
- return problems;
52
- }