@crossworks/content-core 0.239.100 → 0.300.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/package.json +2 -2
- package/src/table-model.ts +1 -10
- package/src/tree.test.ts +0 -14
- package/src/tree.ts +0 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossworks/content-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.300.0",
|
|
4
4
|
"description": "Browser-safe content logic — markdown, blocks, pages, tables, formulas — shared by the server and any client. Zero server deps by design: nothing here may reach @mantle/db, node-only APIs, or the network (the jackdaw-repo-split P0 boundary).",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./app-nav": "./src/app-nav.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"./tree": "./src/tree.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@mantle/client-types": "npm:@crossworks/client-types@0.
|
|
36
|
+
"@mantle/client-types": "npm:@crossworks/client-types@0.300.0",
|
|
37
37
|
"marked": "^18.1.0",
|
|
38
38
|
"mathjs": "15.2.0"
|
|
39
39
|
},
|
package/src/table-model.ts
CHANGED
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
// The mathjs-backed engine (see table-formula-mathjs.ts). `table-formula.ts`
|
|
21
21
|
// remains for one release as a revertible fallback and as the differential
|
|
22
22
|
// baseline in table-formula-diff.test.ts; nothing else should import it.
|
|
23
|
-
import type { AccessLevel } from '@mantle/client-types';
|
|
24
23
|
import { evalFormulaMath as evalFormula } from './table-formula-mathjs';
|
|
25
24
|
|
|
26
25
|
/** Isomorphic UUID — no `node:crypto`, no DB, so this module stays a
|
|
@@ -855,15 +854,7 @@ export type TableRow = {
|
|
|
855
854
|
/** Quick stats for the list (cheap to compute from the doc). */
|
|
856
855
|
columnCount: number;
|
|
857
856
|
rowCount: number;
|
|
858
|
-
|
|
859
|
-
audience: AccessLevel;
|
|
860
|
-
/** The share it inherits from a folder above it (team or client), or
|
|
861
|
-
* null; it is read at the more open of this and `audience`. Optional:
|
|
862
|
-
* absent from brains before the folder audit fixes. */
|
|
863
|
-
inherited?: 'team' | 'client' | null;
|
|
864
|
-
/** The share it is read at through something that embeds it (migration
|
|
865
|
-
* 0208), or null. Optional: absent from brains before it. */
|
|
866
|
-
embedded?: 'team' | 'client' | null;
|
|
857
|
+
|
|
867
858
|
/** A read-only snapshot copy of an accepted item (data.snapshot_of,
|
|
868
859
|
* workspaces W6b fix round 1): nobody edits it, moves it out of its
|
|
869
860
|
* private workspace or shares it; its author may delete it. Absent on
|
package/src/tree.test.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { describe, expect, it } from 'vitest';
|
|
|
2
2
|
import { TREE_KIND_SPECS, TREE_KINDS, TREE_MAX_DEPTH } from '@mantle/client-types/tree';
|
|
3
3
|
import {
|
|
4
4
|
clampTreePath,
|
|
5
|
-
effectiveLevel,
|
|
6
5
|
isTreeFolderPathAllowed,
|
|
7
6
|
treeDepth,
|
|
8
7
|
treeFolderChain,
|
|
@@ -58,16 +57,3 @@ describe('tree path math', () => {
|
|
|
58
57
|
}
|
|
59
58
|
});
|
|
60
59
|
});
|
|
61
|
-
|
|
62
|
-
describe('the effective level', () => {
|
|
63
|
-
it('is the more open of an item’s own level and its folder’s share', () => {
|
|
64
|
-
expect(effectiveLevel('admin', null)).toBe('admin');
|
|
65
|
-
expect(effectiveLevel('admin', 'team')).toBe('team');
|
|
66
|
-
expect(effectiveLevel('admin', 'client')).toBe('client');
|
|
67
|
-
expect(effectiveLevel('team', 'client')).toBe('client');
|
|
68
|
-
expect(effectiveLevel('client', 'team')).toBe('client');
|
|
69
|
-
// A public item stays public in a client folder: folding its text for the
|
|
70
|
-
// public reader is safe for the client reader too.
|
|
71
|
-
expect(effectiveLevel('public', 'client')).toBe('public');
|
|
72
|
-
});
|
|
73
|
-
});
|
package/src/tree.ts
CHANGED
|
@@ -10,34 +10,7 @@ import {
|
|
|
10
10
|
TREE_KINDS,
|
|
11
11
|
TREE_MAX_DEPTH,
|
|
12
12
|
type TreeKind,
|
|
13
|
-
type TreeShareLevel,
|
|
14
13
|
} from '@mantle/client-types/tree';
|
|
15
|
-
import type { AccessLevel } from '@mantle/client-types';
|
|
16
|
-
|
|
17
|
-
const LEVEL_RANK: Record<AccessLevel, number> = { public: 0, client: 1, team: 2, admin: 3 };
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The level an item is read at: the most open of its own level, the share it
|
|
21
|
-
* inherits from a folder, and the share of something that embeds it
|
|
22
|
-
* (public < client < team < admin). This is the level its pill shows and its
|
|
23
|
-
* indexed page text is folded for. Folding for the more open reader is safe
|
|
24
|
-
* for every reader of the row: what a public or client reader may see, every
|
|
25
|
-
* reader above may too. (Which ROLES read the row is the database's union of
|
|
26
|
-
* the three: nodes_viewer_read, migrations 0204 and 0208.)
|
|
27
|
-
*/
|
|
28
|
-
export function effectiveLevel(
|
|
29
|
-
own: AccessLevel,
|
|
30
|
-
inherited: TreeShareLevel | null | undefined,
|
|
31
|
-
/** The share of something that embeds the item (a shared note's image),
|
|
32
|
-
* when the brain sends it. */
|
|
33
|
-
embedded?: TreeShareLevel | null,
|
|
34
|
-
): AccessLevel {
|
|
35
|
-
let level = own;
|
|
36
|
-
for (const share of [inherited, embedded]) {
|
|
37
|
-
if (share && LEVEL_RANK[share] < LEVEL_RANK[level]) level = share;
|
|
38
|
-
}
|
|
39
|
-
return level;
|
|
40
|
-
}
|
|
41
14
|
|
|
42
15
|
function labels(path: string): string[] {
|
|
43
16
|
return path ? path.split('.') : [];
|