@xnetjs/data 0.0.2 → 0.0.3
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/README.md +112 -0
- package/dist/account-BZHETMC4.js +12 -0
- package/dist/auth/index.d.ts +413 -0
- package/dist/auth/index.js +102 -0
- package/dist/budget-WR2Q4YH3.js +12 -0
- package/dist/canvas-HFMMVQLD.js +10 -0
- package/dist/channel-DXDYJ3ZH.js +12 -0
- package/dist/chat-message-QUUQGXEW.js +10 -0
- package/dist/chunk-2DSDH2ZH.js +52 -0
- package/dist/chunk-337E3ZOB.js +54 -0
- package/dist/chunk-37267RSF.js +41 -0
- package/dist/chunk-3JKW6TDE.js +66 -0
- package/dist/chunk-3RB2FMMO.js +148 -0
- package/dist/{chunk-BQBPA5HS.js → chunk-4U4KBCDN.js} +16 -2
- package/dist/chunk-4UQTURCD.js +722 -0
- package/dist/chunk-54Y7QRZN.js +109 -0
- package/dist/chunk-5FHJE7RC.js +46 -0
- package/dist/chunk-64AM6JPM.js +40 -0
- package/dist/chunk-6CN53PON.js +143 -0
- package/dist/chunk-6GB7PBCR.js +40 -0
- package/dist/chunk-6OPZJ7MG.js +78 -0
- package/dist/{chunk-IDMBCRUC.js → chunk-77UDLVQY.js} +1 -1
- package/dist/chunk-7GMJOAPF.js +52 -0
- package/dist/chunk-7PDRDSFH.js +69 -0
- package/dist/chunk-C5IRSEEZ.js +69 -0
- package/dist/chunk-CHZUSBSB.js +45 -0
- package/dist/chunk-DOZJXPQ6.js +232 -0
- package/dist/chunk-DTPSTMUD.js +105 -0
- package/dist/chunk-E6S557NC.js +402 -0
- package/dist/chunk-EIQX7INF.js +45 -0
- package/dist/chunk-ENTHVNOC.js +57 -0
- package/dist/chunk-EZA5UT4Y.js +5543 -0
- package/dist/chunk-GR3NDMBY.js +76 -0
- package/dist/chunk-GWYVY2K4.js +63 -0
- package/dist/chunk-IJ675GJR.js +42 -0
- package/dist/chunk-IP4BEVVD.js +57 -0
- package/dist/chunk-J4IVJA5M.js +102 -0
- package/dist/chunk-J6EDPPH4.js +84 -0
- package/dist/{chunk-SZC345Z2.js → chunk-JESSJ5CZ.js} +1015 -1110
- package/dist/chunk-JO6Y4E5V.js +73 -0
- package/dist/chunk-KPVBKKZS.js +47 -0
- package/dist/chunk-KTJLFJEQ.js +43 -0
- package/dist/chunk-L66WXPTW.js +32 -0
- package/dist/chunk-LGD72FVD.js +48 -0
- package/dist/chunk-O64EK5FK.js +887 -0
- package/dist/chunk-PMUQACPY.js +33 -0
- package/dist/chunk-PSUJEKVV.js +1722 -0
- package/dist/chunk-QVZXXJSP.js +6122 -0
- package/dist/chunk-QWFTRZQT.js +142 -0
- package/dist/chunk-RSSZXCLL.js +51 -0
- package/dist/chunk-S4B5OPZU.js +415 -0
- package/dist/{chunk-VYR5GPJP.js → chunk-SPFKSTPT.js} +9 -3
- package/dist/chunk-U6CBYDVZ.js +50 -0
- package/dist/chunk-UDUPQKRB.js +49 -0
- package/dist/chunk-V6HZ3LF3.js +380 -0
- package/dist/chunk-WMSCEBFH.js +64 -0
- package/dist/chunk-WUR3WWQM.js +65 -0
- package/dist/chunk-XHEA5UER.js +75 -0
- package/dist/chunk-XTUGZSYQ.js +75 -0
- package/dist/chunk-XWA3CJQ6.js +45 -0
- package/dist/chunk-YEQ6LLUY.js +49 -0
- package/dist/chunk-YWN27MLD.js +47 -0
- package/dist/chunk-YXZGYLKV.js +65 -0
- package/dist/chunk-ZICIXDEE.js +54 -0
- package/dist/chunk-ZMCO3O2Z.js +70 -0
- package/dist/clone-DpbVKLUu.d.ts +2205 -0
- package/dist/comment-Y2Y3QYYI.js +10 -0
- package/dist/crm-AAJXYIJY.js +68 -0
- package/dist/dashboard-3DC6B4BJ.js +10 -0
- package/dist/database/index.d.ts +882 -0
- package/dist/database/index.js +523 -0
- package/dist/database-DRGL5UYS.js +10 -0
- package/dist/database-field-F47FY3XX.js +10 -0
- package/dist/database-row-77OXW2NF.js +10 -0
- package/dist/database-select-option-6S3TTA7A.js +10 -0
- package/dist/database-view-YW7DQG5X.js +10 -0
- package/dist/experiment-TJOAL3OH.js +10 -0
- package/dist/external-item-D654PKLI.js +14 -0
- package/dist/external-reference-K5SUJIQN.js +8 -0
- package/dist/feed-L23XTNDI.js +12 -0
- package/dist/feed-item-GSO242J6.js +12 -0
- package/dist/folder-ONKSWHUT.js +21 -0
- package/dist/game-BF7DP5JU.js +50 -0
- package/dist/grant-NNKMWXPX.js +8 -0
- package/dist/grant-expiration-cleaner-DBiNTWbD.d.ts +249 -0
- package/dist/import-batch-JMESZ4VI.js +12 -0
- package/dist/inbox-state-AN6FPCIY.js +12 -0
- package/dist/index.d.ts +224 -4548
- package/dist/index.js +2206 -4754
- package/dist/map-AUV65YS3.js +10 -0
- package/dist/media-asset-4I5YPR4R.js +8 -0
- package/dist/memory-NV6EVJBE.js +12 -0
- package/dist/metric-X7W55DLC.js +10 -0
- package/dist/milestone-JJGOGK4R.js +12 -0
- package/dist/moderation-QSUVBCNS.js +30 -0
- package/dist/observation-UZSXXGBC.js +10 -0
- package/dist/page-NI7XODS6.js +10 -0
- package/dist/posting-FZOYVGH2.js +12 -0
- package/dist/profile-42A43GES.js +8 -0
- package/dist/project-G2CTLDXY.js +10 -0
- package/dist/query-ast-CWo6_30h.d.ts +226 -0
- package/dist/reaction-VAQBVDUD.js +10 -0
- package/dist/registry-CQoN_p8U.d.ts +99 -0
- package/dist/saved-view-AOQHGHNM.js +10 -0
- package/dist/schema/index.d.ts +6182 -0
- package/dist/schema/index.js +631 -0
- package/dist/schema-extension-5BUXRDPB.js +18 -0
- package/dist/space-PZ737CIS.js +42 -0
- package/dist/space-membership-N35NRX6F.js +14 -0
- package/dist/store/index.d.ts +391 -0
- package/dist/store/index.js +135 -0
- package/dist/store-CvgiydME.d.ts +338 -0
- package/dist/sync/awareness.d.ts +69 -0
- package/dist/sync/awareness.js +20 -0
- package/dist/system-Q5I6STDC.js +38 -0
- package/dist/tag-C677GKQW.js +16 -0
- package/dist/task-WQLMPN5U.js +16 -0
- package/dist/task-view-T5S32V4L.js +10 -0
- package/dist/transaction-U3ITRGJP.js +12 -0
- package/dist/transcription-F3T23LLO.js +12 -0
- package/dist/types-Def-5Nka.d.ts +1525 -0
- package/dist/updates.d.ts +44 -0
- package/dist/updates.js +16 -0
- package/dist/user-widget-4SJJFPG5.js +8 -0
- package/dist/view-types-DSde-uT_.d.ts +316 -0
- package/package.json +32 -9
- package/dist/canvas-HSIKIQFK.js +0 -7
- package/dist/chunk-2L5ZUGG5.js +0 -53
- package/dist/chunk-4MTS5KAQ.js +0 -22
- package/dist/chunk-GZHARFKC.js +0 -25
- package/dist/chunk-WKIKJTI2.js +0 -45
- package/dist/comment-277JD7DV.js +0 -7
- package/dist/database-W3KEHLI3.js +0 -7
- package/dist/database-row-3O2QSNZN.js +0 -7
- package/dist/grant-QVZ454YC.js +0 -7
- package/dist/page-O4WTOIEO.js +0 -7
- package/dist/task-SEKAYJH7.js +0 -7
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spaceCascadeAuthorization
|
|
3
|
+
} from "./chunk-6OPZJ7MG.js";
|
|
4
|
+
import {
|
|
5
|
+
defineSchema,
|
|
6
|
+
json,
|
|
7
|
+
number,
|
|
8
|
+
relation,
|
|
9
|
+
select,
|
|
10
|
+
text
|
|
11
|
+
} from "./chunk-O64EK5FK.js";
|
|
12
|
+
|
|
13
|
+
// src/schema/schemas/metric.ts
|
|
14
|
+
var MetricSchema = defineSchema({
|
|
15
|
+
name: "Metric",
|
|
16
|
+
namespace: "xnet://xnet.fyi/",
|
|
17
|
+
properties: {
|
|
18
|
+
/** Display name, e.g. "Meditate" or "Sleep latency". */
|
|
19
|
+
name: text({ required: true, maxLength: 200 }),
|
|
20
|
+
/** Emoji or icon URL. */
|
|
21
|
+
icon: text({ maxLength: 500 }),
|
|
22
|
+
/** Accent color for streak chips / charts. */
|
|
23
|
+
color: text({ maxLength: 40 }),
|
|
24
|
+
/**
|
|
25
|
+
* What kind of value an Observation carries — drives both logging UI and
|
|
26
|
+
* aggregation. `boolean` is the classic habit check-in (value 0/1);
|
|
27
|
+
* `scale` is a bounded rating (mood 1–5); the rest are free numerics.
|
|
28
|
+
*/
|
|
29
|
+
kind: select({
|
|
30
|
+
options: [
|
|
31
|
+
{ id: "boolean", name: "Yes / No" },
|
|
32
|
+
{ id: "count", name: "Count" },
|
|
33
|
+
{ id: "duration", name: "Duration" },
|
|
34
|
+
{ id: "scale", name: "Scale" },
|
|
35
|
+
{ id: "number", name: "Number" }
|
|
36
|
+
],
|
|
37
|
+
default: "boolean"
|
|
38
|
+
}),
|
|
39
|
+
/** Unit label for numeric kinds, e.g. "min", "pages", "glasses". */
|
|
40
|
+
unit: text({ maxLength: 40 }),
|
|
41
|
+
/** Lower bound for `scale` kind (e.g. 1). */
|
|
42
|
+
scaleMin: number({}),
|
|
43
|
+
/** Upper bound for `scale` kind (e.g. 5). */
|
|
44
|
+
scaleMax: number({}),
|
|
45
|
+
/**
|
|
46
|
+
* A recurring schedule makes this Metric a habit. `none` = ad-hoc /
|
|
47
|
+
* continuous (no streak, no "miss").
|
|
48
|
+
*/
|
|
49
|
+
schedule: select({
|
|
50
|
+
options: [
|
|
51
|
+
{ id: "none", name: "No schedule" },
|
|
52
|
+
{ id: "daily", name: "Daily" },
|
|
53
|
+
{ id: "weekly", name: "Weekly" },
|
|
54
|
+
{ id: "specificDays", name: "Specific days" }
|
|
55
|
+
],
|
|
56
|
+
default: "none"
|
|
57
|
+
}),
|
|
58
|
+
/** Weekdays (0 = Sun … 6 = Sat) for `specificDays`, or anchor for `weekly`. */
|
|
59
|
+
scheduleDays: json({}),
|
|
60
|
+
/** Which direction counts as improvement, for the verdict engine. */
|
|
61
|
+
polarity: select({
|
|
62
|
+
options: [
|
|
63
|
+
{ id: "higherBetter", name: "Higher is better" },
|
|
64
|
+
{ id: "lowerBetter", name: "Lower is better" },
|
|
65
|
+
{ id: "neutral", name: "Neutral" }
|
|
66
|
+
],
|
|
67
|
+
default: "higherBetter"
|
|
68
|
+
}),
|
|
69
|
+
/** Optional target value (e.g. "50 pushups", "≥ 7 h sleep"). */
|
|
70
|
+
target: number({}),
|
|
71
|
+
/**
|
|
72
|
+
* Implementation intention — "after I pour my morning coffee, I will…".
|
|
73
|
+
* A written cue roughly doubles follow-through (Gollwitzer, 1999).
|
|
74
|
+
*/
|
|
75
|
+
cue: text({ maxLength: 280 }),
|
|
76
|
+
/**
|
|
77
|
+
* Optional owning experiment. A Metric can be standalone (mood, sleep) and
|
|
78
|
+
* referenced by many experiments, so this is not required.
|
|
79
|
+
*/
|
|
80
|
+
experiment: relation({ target: "xnet://xnet.fyi/Experiment@1.0.0" }),
|
|
81
|
+
/** Canonical home; empty = Unfiled (exploration 0169). */
|
|
82
|
+
folder: relation({ target: "xnet://xnet.fyi/Folder@1.0.0" }),
|
|
83
|
+
/** Order among siblings — fractional index. */
|
|
84
|
+
sortKey: text({ maxLength: 500 }),
|
|
85
|
+
/** Workspace-wide labels, referenced by id (exploration 0169). */
|
|
86
|
+
tags: relation({ target: "xnet://xnet.fyi/Tag@1.0.0", multiple: true }),
|
|
87
|
+
/** Canonical SECURITY home; empty = personal/private (exploration 0179). */
|
|
88
|
+
space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" }),
|
|
89
|
+
/**
|
|
90
|
+
* Per-node visibility. Defaults to `private` — mood/health/habit data is
|
|
91
|
+
* sensitive and must never leak to public surfaces by accident (0180).
|
|
92
|
+
*/
|
|
93
|
+
visibility: select({
|
|
94
|
+
options: [
|
|
95
|
+
{ id: "inherit", name: "Inherit", color: "gray" },
|
|
96
|
+
{ id: "private", name: "Private", color: "gray" },
|
|
97
|
+
{ id: "unlisted", name: "Unlisted", color: "yellow" },
|
|
98
|
+
{ id: "public", name: "Public", color: "green" }
|
|
99
|
+
],
|
|
100
|
+
default: "private"
|
|
101
|
+
})
|
|
102
|
+
},
|
|
103
|
+
// Inherits access from its home Space (exploration 0181/0192).
|
|
104
|
+
authorization: spaceCascadeAuthorization()
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
MetricSchema
|
|
109
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineSchema,
|
|
3
|
+
file,
|
|
4
|
+
number,
|
|
5
|
+
select,
|
|
6
|
+
text
|
|
7
|
+
} from "./chunk-O64EK5FK.js";
|
|
8
|
+
import {
|
|
9
|
+
presets
|
|
10
|
+
} from "./chunk-JESSJ5CZ.js";
|
|
11
|
+
|
|
12
|
+
// src/schema/schemas/media-asset.ts
|
|
13
|
+
var MediaAssetSchema = defineSchema({
|
|
14
|
+
name: "MediaAsset",
|
|
15
|
+
namespace: "xnet://xnet.fyi/",
|
|
16
|
+
properties: {
|
|
17
|
+
/** Display title */
|
|
18
|
+
title: text({ required: true, maxLength: 500 }),
|
|
19
|
+
/** Primary file reference */
|
|
20
|
+
file: file({ required: true }),
|
|
21
|
+
/** Normalized media kind */
|
|
22
|
+
kind: select({
|
|
23
|
+
options: [
|
|
24
|
+
{ id: "image", name: "Image" },
|
|
25
|
+
{ id: "video", name: "Video" },
|
|
26
|
+
{ id: "audio", name: "Audio" },
|
|
27
|
+
{ id: "document", name: "Document" },
|
|
28
|
+
{ id: "file", name: "File" }
|
|
29
|
+
],
|
|
30
|
+
default: "file"
|
|
31
|
+
}),
|
|
32
|
+
/** Optional alt text or description */
|
|
33
|
+
alt: text({ maxLength: 2e3 }),
|
|
34
|
+
/** Natural width when known */
|
|
35
|
+
width: number({ integer: true, min: 0 }),
|
|
36
|
+
/** Natural height when known */
|
|
37
|
+
height: number({ integer: true, min: 0 })
|
|
38
|
+
},
|
|
39
|
+
document: void 0,
|
|
40
|
+
// Standalone/personal content: owner-only by default (exploration 0192).
|
|
41
|
+
authorization: presets.private()
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
MediaAssetSchema
|
|
46
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
created,
|
|
3
|
+
createdBy,
|
|
4
|
+
defineSchema,
|
|
5
|
+
person,
|
|
6
|
+
text
|
|
7
|
+
} from "./chunk-O64EK5FK.js";
|
|
8
|
+
|
|
9
|
+
// src/schema/schemas/profile.ts
|
|
10
|
+
var ProfileSchema = defineSchema({
|
|
11
|
+
name: "Profile",
|
|
12
|
+
namespace: "xnet://xnet.fyi/",
|
|
13
|
+
properties: {
|
|
14
|
+
/** The DID this profile describes (should match createdBy) */
|
|
15
|
+
did: person({ required: true }),
|
|
16
|
+
/** Human-readable display name */
|
|
17
|
+
displayName: text({ required: true, maxLength: 120 }),
|
|
18
|
+
/**
|
|
19
|
+
* Optional @handle — a short, workspace-unique slug for typing mentions
|
|
20
|
+
* (exploration 0172). The stable identity is always the DID; the handle is
|
|
21
|
+
* a resolver input at compose time and a display option at read time, so a
|
|
22
|
+
* rename never breaks an existing mention. Global uniqueness is out of
|
|
23
|
+
* scope — the DID remains the source of truth.
|
|
24
|
+
*/
|
|
25
|
+
handle: text({ maxLength: 32 }),
|
|
26
|
+
/** Avatar URL or blob reference */
|
|
27
|
+
avatar: text({ maxLength: 500 }),
|
|
28
|
+
/** Short status emoji (e.g. 🔴, 🌴) */
|
|
29
|
+
statusEmoji: text({ maxLength: 32 }),
|
|
30
|
+
/** Free-form status message */
|
|
31
|
+
statusMessage: text({ maxLength: 200 }),
|
|
32
|
+
createdAt: created(),
|
|
33
|
+
createdBy: createdBy()
|
|
34
|
+
},
|
|
35
|
+
document: void 0
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
ProfileSchema
|
|
40
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildFolderTree,
|
|
3
|
+
flattenFolderTree,
|
|
4
|
+
folderAncestorIds,
|
|
5
|
+
folderPathIds,
|
|
6
|
+
wouldCreateFolderCycle
|
|
7
|
+
} from "./chunk-DTPSTMUD.js";
|
|
8
|
+
import {
|
|
9
|
+
spaceOwnAuthorization
|
|
10
|
+
} from "./chunk-6OPZJ7MG.js";
|
|
11
|
+
import {
|
|
12
|
+
checkbox,
|
|
13
|
+
created,
|
|
14
|
+
createdBy,
|
|
15
|
+
defineSchema,
|
|
16
|
+
person,
|
|
17
|
+
relation,
|
|
18
|
+
select,
|
|
19
|
+
text
|
|
20
|
+
} from "./chunk-O64EK5FK.js";
|
|
21
|
+
|
|
22
|
+
// src/schema/schemas/space.ts
|
|
23
|
+
var SPACE_SCHEMA_IRI = "xnet://xnet.fyi/Space@1.0.0";
|
|
24
|
+
var SPACE_KINDS = [
|
|
25
|
+
"personal",
|
|
26
|
+
"workspace",
|
|
27
|
+
"organization",
|
|
28
|
+
"team",
|
|
29
|
+
"community",
|
|
30
|
+
"family"
|
|
31
|
+
];
|
|
32
|
+
var SPACE_VISIBILITY = ["private", "unlisted", "public"];
|
|
33
|
+
var NODE_VISIBILITY = ["inherit", "private", "unlisted", "public"];
|
|
34
|
+
var SpaceSchema = defineSchema({
|
|
35
|
+
name: "Space",
|
|
36
|
+
namespace: "xnet://xnet.fyi/",
|
|
37
|
+
properties: {
|
|
38
|
+
/** Space display name */
|
|
39
|
+
name: text({ required: true, maxLength: 200 }),
|
|
40
|
+
/** Flavor — selects presets only */
|
|
41
|
+
kind: select({
|
|
42
|
+
options: [
|
|
43
|
+
{ id: "personal", name: "Personal", color: "gray" },
|
|
44
|
+
{ id: "workspace", name: "Workspace", color: "blue" },
|
|
45
|
+
{ id: "organization", name: "Organization", color: "purple" },
|
|
46
|
+
{ id: "team", name: "Team", color: "green" },
|
|
47
|
+
{ id: "community", name: "Community", color: "pink" },
|
|
48
|
+
{ id: "family", name: "Family", color: "red" }
|
|
49
|
+
],
|
|
50
|
+
required: true,
|
|
51
|
+
default: "workspace"
|
|
52
|
+
}),
|
|
53
|
+
/** Nesting parent; empty = top-level (exploration 0179) */
|
|
54
|
+
parent: relation({ target: "xnet://xnet.fyi/Space@1.0.0" }),
|
|
55
|
+
/** Private by default; unlisted via links; public is a deliberate escalation */
|
|
56
|
+
visibility: select({
|
|
57
|
+
options: [
|
|
58
|
+
{ id: "private", name: "Private", color: "gray" },
|
|
59
|
+
{ id: "unlisted", name: "Unlisted", color: "yellow" },
|
|
60
|
+
{ id: "public", name: "Public", color: "green" }
|
|
61
|
+
],
|
|
62
|
+
required: true,
|
|
63
|
+
default: "private"
|
|
64
|
+
}),
|
|
65
|
+
/** Governance set — the admin/owner DIDs (no group DID needed in v1) */
|
|
66
|
+
owners: person({ multiple: true }),
|
|
67
|
+
/** Short description / purpose */
|
|
68
|
+
description: text({ maxLength: 2e3 }),
|
|
69
|
+
/** Emoji or icon URL */
|
|
70
|
+
icon: text({ maxLength: 500 }),
|
|
71
|
+
/** Accent color */
|
|
72
|
+
color: text({ maxLength: 30 }),
|
|
73
|
+
/** Order among siblings — fractional index, code-unit compare */
|
|
74
|
+
sortKey: text({ maxLength: 500 }),
|
|
75
|
+
/** Archived spaces are hidden from the default list */
|
|
76
|
+
archived: checkbox({ default: false }),
|
|
77
|
+
createdAt: created(),
|
|
78
|
+
createdBy: createdBy()
|
|
79
|
+
},
|
|
80
|
+
document: void 0,
|
|
81
|
+
// Members resolve from SpaceMembership edges and cascade down the `parent`
|
|
82
|
+
// chain (exploration 0181). Content inherits these via `role.relation`.
|
|
83
|
+
authorization: spaceOwnAuthorization()
|
|
84
|
+
});
|
|
85
|
+
var SPACE_ROLES = ["viewer", "commenter", "member", "admin", "owner"];
|
|
86
|
+
var SPACE_ROLE_RANK = {
|
|
87
|
+
viewer: 0,
|
|
88
|
+
commenter: 1,
|
|
89
|
+
member: 2,
|
|
90
|
+
admin: 3,
|
|
91
|
+
owner: 4
|
|
92
|
+
};
|
|
93
|
+
var compareSpaceRoles = (a, b) => SPACE_ROLE_RANK[a] - SPACE_ROLE_RANK[b];
|
|
94
|
+
function effectiveSpaceRole(roles) {
|
|
95
|
+
let best = null;
|
|
96
|
+
for (const role of roles) {
|
|
97
|
+
if (!best || compareSpaceRoles(role, best) > 0) best = role;
|
|
98
|
+
}
|
|
99
|
+
return best;
|
|
100
|
+
}
|
|
101
|
+
var canManageSpace = (role) => role === "admin" || role === "owner";
|
|
102
|
+
function spaceRoleGrantActions(role) {
|
|
103
|
+
switch (role) {
|
|
104
|
+
case "viewer":
|
|
105
|
+
return ["read"];
|
|
106
|
+
case "commenter":
|
|
107
|
+
return ["read", "comment"];
|
|
108
|
+
case "member":
|
|
109
|
+
return ["read", "comment", "write"];
|
|
110
|
+
case "admin":
|
|
111
|
+
case "owner":
|
|
112
|
+
return ["read", "comment", "write", "share", "admin"];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function spaceRoleToShareRole(role) {
|
|
116
|
+
if (role === "viewer") return "read";
|
|
117
|
+
if (role === "commenter") return "comment";
|
|
118
|
+
return "write";
|
|
119
|
+
}
|
|
120
|
+
var buildSpaceTree = buildFolderTree;
|
|
121
|
+
var flattenSpaceTree = flattenFolderTree;
|
|
122
|
+
var spaceAncestorIds = folderAncestorIds;
|
|
123
|
+
var spacePathIds = folderPathIds;
|
|
124
|
+
var wouldCreateSpaceCycle = wouldCreateFolderCycle;
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
SPACE_SCHEMA_IRI,
|
|
128
|
+
SPACE_KINDS,
|
|
129
|
+
SPACE_VISIBILITY,
|
|
130
|
+
NODE_VISIBILITY,
|
|
131
|
+
SpaceSchema,
|
|
132
|
+
SPACE_ROLES,
|
|
133
|
+
compareSpaceRoles,
|
|
134
|
+
effectiveSpaceRole,
|
|
135
|
+
canManageSpace,
|
|
136
|
+
spaceRoleGrantActions,
|
|
137
|
+
spaceRoleToShareRole,
|
|
138
|
+
buildSpaceTree,
|
|
139
|
+
flattenSpaceTree,
|
|
140
|
+
spaceAncestorIds,
|
|
141
|
+
spacePathIds,
|
|
142
|
+
wouldCreateSpaceCycle
|
|
143
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spaceCascadeAuthorization
|
|
3
|
+
} from "./chunk-6OPZJ7MG.js";
|
|
4
|
+
import {
|
|
5
|
+
defineSchema,
|
|
6
|
+
relation,
|
|
7
|
+
select,
|
|
8
|
+
text
|
|
9
|
+
} from "./chunk-O64EK5FK.js";
|
|
10
|
+
|
|
11
|
+
// src/schema/schemas/saved-view.ts
|
|
12
|
+
var SavedViewSchema = defineSchema({
|
|
13
|
+
name: "SavedView",
|
|
14
|
+
namespace: "xnet://xnet.fyi/",
|
|
15
|
+
properties: {
|
|
16
|
+
/** Human-readable view title */
|
|
17
|
+
title: text({ required: true, maxLength: 500 }),
|
|
18
|
+
/** Optional user-facing description */
|
|
19
|
+
description: text({ maxLength: 4e3 }),
|
|
20
|
+
/** JSON-serialized SavedViewDescriptor from store/query-ast */
|
|
21
|
+
descriptor: text({ required: true }),
|
|
22
|
+
/** Visibility and ownership boundary for the saved descriptor */
|
|
23
|
+
scope: select({
|
|
24
|
+
options: [
|
|
25
|
+
{ id: "user", name: "User" },
|
|
26
|
+
{ id: "workspace", name: "Workspace" },
|
|
27
|
+
{ id: "database", name: "Database" }
|
|
28
|
+
],
|
|
29
|
+
default: "workspace"
|
|
30
|
+
}),
|
|
31
|
+
/** Optional database that owns database-scoped views */
|
|
32
|
+
database: relation({ target: "xnet://xnet.fyi/Database@2.0.0" })
|
|
33
|
+
},
|
|
34
|
+
// Inherits access from its home Space (exploration 0181/0192).
|
|
35
|
+
authorization: spaceCascadeAuthorization("database")
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
SavedViewSchema
|
|
40
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SPACE_MEMBERSHIP_SCHEMA_IRI
|
|
3
|
+
} from "./chunk-ZICIXDEE.js";
|
|
4
|
+
import {
|
|
5
|
+
allow,
|
|
6
|
+
role
|
|
7
|
+
} from "./chunk-JESSJ5CZ.js";
|
|
8
|
+
|
|
9
|
+
// src/schema/schemas/space-authorization.ts
|
|
10
|
+
var ROLE_ORDER = ["viewer", "commenter", "member", "admin", "owner"];
|
|
11
|
+
var membersAtLeast = (minRole) => role.members({
|
|
12
|
+
edgeSchema: SPACE_MEMBERSHIP_SCHEMA_IRI,
|
|
13
|
+
containerProp: "space",
|
|
14
|
+
memberProp: "member",
|
|
15
|
+
roleProp: "role",
|
|
16
|
+
minRole,
|
|
17
|
+
roleOrder: ROLE_ORDER,
|
|
18
|
+
parentProp: "parent"
|
|
19
|
+
});
|
|
20
|
+
function spaceOwnAuthorization() {
|
|
21
|
+
return {
|
|
22
|
+
roles: {
|
|
23
|
+
owner: role.creator(),
|
|
24
|
+
spaceManager: role.property("owners"),
|
|
25
|
+
spaceOwner: membersAtLeast("owner"),
|
|
26
|
+
spaceAdmin: membersAtLeast("admin"),
|
|
27
|
+
spaceMember: membersAtLeast("member"),
|
|
28
|
+
spaceCommenter: membersAtLeast("commenter"),
|
|
29
|
+
spaceViewer: membersAtLeast("viewer")
|
|
30
|
+
},
|
|
31
|
+
actions: {
|
|
32
|
+
// commenters/viewers fold into read; write needs member+; manage needs admin+
|
|
33
|
+
read: allow(
|
|
34
|
+
"owner",
|
|
35
|
+
"spaceManager",
|
|
36
|
+
"spaceOwner",
|
|
37
|
+
"spaceAdmin",
|
|
38
|
+
"spaceMember",
|
|
39
|
+
"spaceCommenter",
|
|
40
|
+
"spaceViewer"
|
|
41
|
+
),
|
|
42
|
+
write: allow("owner", "spaceManager", "spaceOwner", "spaceAdmin", "spaceMember"),
|
|
43
|
+
delete: allow("owner", "spaceManager", "spaceOwner", "spaceAdmin"),
|
|
44
|
+
share: allow("owner", "spaceManager", "spaceOwner", "spaceAdmin"),
|
|
45
|
+
admin: allow("owner", "spaceManager", "spaceOwner", "spaceAdmin")
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function spaceCascadeAuthorization(relationName = "space") {
|
|
50
|
+
return {
|
|
51
|
+
roles: {
|
|
52
|
+
owner: role.creator(),
|
|
53
|
+
spaceOwner: role.relation(relationName, "spaceOwner"),
|
|
54
|
+
spaceAdmin: role.relation(relationName, "spaceAdmin"),
|
|
55
|
+
spaceMember: role.relation(relationName, "spaceMember"),
|
|
56
|
+
spaceCommenter: role.relation(relationName, "spaceCommenter"),
|
|
57
|
+
spaceViewer: role.relation(relationName, "spaceViewer")
|
|
58
|
+
},
|
|
59
|
+
actions: {
|
|
60
|
+
read: allow(
|
|
61
|
+
"owner",
|
|
62
|
+
"spaceOwner",
|
|
63
|
+
"spaceAdmin",
|
|
64
|
+
"spaceMember",
|
|
65
|
+
"spaceCommenter",
|
|
66
|
+
"spaceViewer"
|
|
67
|
+
),
|
|
68
|
+
write: allow("owner", "spaceOwner", "spaceAdmin", "spaceMember"),
|
|
69
|
+
delete: allow("owner", "spaceOwner", "spaceAdmin"),
|
|
70
|
+
share: allow("owner", "spaceOwner", "spaceAdmin")
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
spaceOwnAuthorization,
|
|
77
|
+
spaceCascadeAuthorization
|
|
78
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spaceCascadeAuthorization
|
|
3
|
+
} from "./chunk-6OPZJ7MG.js";
|
|
4
|
+
import {
|
|
5
|
+
defineSchema,
|
|
6
|
+
json,
|
|
7
|
+
relation,
|
|
8
|
+
select,
|
|
9
|
+
text
|
|
10
|
+
} from "./chunk-O64EK5FK.js";
|
|
11
|
+
|
|
12
|
+
// src/schema/schemas/map.ts
|
|
13
|
+
var MapSchema = defineSchema({
|
|
14
|
+
name: "Map",
|
|
15
|
+
namespace: "xnet://xnet.fyi/",
|
|
16
|
+
properties: {
|
|
17
|
+
/** Map title */
|
|
18
|
+
title: text({ required: true, maxLength: 500 }),
|
|
19
|
+
/** Emoji or icon URL */
|
|
20
|
+
icon: text({}),
|
|
21
|
+
/** Basemap identifier (open/key-less). Defaults to protomaps-light. */
|
|
22
|
+
basemap: text({ maxLength: 64 }),
|
|
23
|
+
/** Camera position — whole-value LWW */
|
|
24
|
+
viewport: json({}),
|
|
25
|
+
/** Ordered layer stack (bottom→top) — whole-list LWW */
|
|
26
|
+
layers: json({}),
|
|
27
|
+
/** Canonical home; empty = Unfiled (exploration 0169) */
|
|
28
|
+
folder: relation({ target: "xnet://xnet.fyi/Folder@1.0.0" }),
|
|
29
|
+
/** Order among folder siblings — fractional index */
|
|
30
|
+
sortKey: text({ maxLength: 500 }),
|
|
31
|
+
/** Workspace-wide labels, referenced by id (exploration 0169) */
|
|
32
|
+
tags: relation({ target: "xnet://xnet.fyi/Tag@1.0.0", multiple: true }),
|
|
33
|
+
/** Canonical SECURITY home; empty = personal/private (exploration 0179) */
|
|
34
|
+
space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" }),
|
|
35
|
+
/** Per-node visibility; `inherit` defers to the Space (exploration 0179) */
|
|
36
|
+
visibility: select({
|
|
37
|
+
options: [
|
|
38
|
+
{ id: "inherit", name: "Inherit", color: "gray" },
|
|
39
|
+
{ id: "private", name: "Private", color: "gray" },
|
|
40
|
+
{ id: "unlisted", name: "Unlisted", color: "yellow" },
|
|
41
|
+
{ id: "public", name: "Public", color: "green" }
|
|
42
|
+
],
|
|
43
|
+
default: "inherit"
|
|
44
|
+
})
|
|
45
|
+
},
|
|
46
|
+
// Inherits access from its home Space (exploration 0181/0192).
|
|
47
|
+
authorization: spaceCascadeAuthorization()
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
MapSchema
|
|
52
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/sync/awareness.ts
|
|
2
|
+
import { Awareness } from "y-protocols/awareness";
|
|
3
|
+
function createAwareness(doc) {
|
|
4
|
+
return new Awareness(doc);
|
|
5
|
+
}
|
|
6
|
+
function setLocalPresence(awareness, presence) {
|
|
7
|
+
awareness.setLocalState(presence);
|
|
8
|
+
}
|
|
9
|
+
function clearLocalPresence(awareness) {
|
|
10
|
+
awareness.setLocalState(null);
|
|
11
|
+
}
|
|
12
|
+
function getRemotePresences(awareness) {
|
|
13
|
+
const states = awareness.getStates();
|
|
14
|
+
const result = /* @__PURE__ */ new Map();
|
|
15
|
+
states.forEach((state, clientId) => {
|
|
16
|
+
if (state && clientId !== awareness.clientID) {
|
|
17
|
+
result.set(clientId, state);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
function getAllPresences(awareness) {
|
|
23
|
+
const states = awareness.getStates();
|
|
24
|
+
const result = /* @__PURE__ */ new Map();
|
|
25
|
+
states.forEach((state, clientId) => {
|
|
26
|
+
if (state) {
|
|
27
|
+
result.set(clientId, state);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
function onPresenceChange(awareness, callback) {
|
|
33
|
+
awareness.on("change", callback);
|
|
34
|
+
return () => awareness.off("change", callback);
|
|
35
|
+
}
|
|
36
|
+
function getLocalClientId(awareness) {
|
|
37
|
+
return awareness.clientID;
|
|
38
|
+
}
|
|
39
|
+
function generateUserColor() {
|
|
40
|
+
const colors = [
|
|
41
|
+
"#F44336",
|
|
42
|
+
"#E91E63",
|
|
43
|
+
"#9C27B0",
|
|
44
|
+
"#673AB7",
|
|
45
|
+
"#3F51B5",
|
|
46
|
+
"#2196F3",
|
|
47
|
+
"#03A9F4",
|
|
48
|
+
"#00BCD4",
|
|
49
|
+
"#009688",
|
|
50
|
+
"#4CAF50",
|
|
51
|
+
"#8BC34A",
|
|
52
|
+
"#CDDC39",
|
|
53
|
+
"#FFC107",
|
|
54
|
+
"#FF9800",
|
|
55
|
+
"#FF5722"
|
|
56
|
+
];
|
|
57
|
+
return colors[Math.floor(Math.random() * colors.length)];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
createAwareness,
|
|
62
|
+
setLocalPresence,
|
|
63
|
+
clearLocalPresence,
|
|
64
|
+
getRemotePresences,
|
|
65
|
+
getAllPresences,
|
|
66
|
+
onPresenceChange,
|
|
67
|
+
getLocalClientId,
|
|
68
|
+
generateUserColor
|
|
69
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineSchema,
|
|
3
|
+
select,
|
|
4
|
+
text,
|
|
5
|
+
url
|
|
6
|
+
} from "./chunk-O64EK5FK.js";
|
|
7
|
+
import {
|
|
8
|
+
presets
|
|
9
|
+
} from "./chunk-JESSJ5CZ.js";
|
|
10
|
+
|
|
11
|
+
// src/schema/schemas/external-reference.ts
|
|
12
|
+
var ExternalReferenceSchema = defineSchema({
|
|
13
|
+
name: "ExternalReference",
|
|
14
|
+
namespace: "xnet://xnet.fyi/",
|
|
15
|
+
properties: {
|
|
16
|
+
/** Canonical external URL */
|
|
17
|
+
url: url({ required: true }),
|
|
18
|
+
/** Normalized provider identifier */
|
|
19
|
+
provider: select({
|
|
20
|
+
options: [
|
|
21
|
+
{ id: "github", name: "GitHub" },
|
|
22
|
+
{ id: "figma", name: "Figma" },
|
|
23
|
+
{ id: "youtube", name: "YouTube" },
|
|
24
|
+
{ id: "loom", name: "Loom" },
|
|
25
|
+
{ id: "vimeo", name: "Vimeo" },
|
|
26
|
+
{ id: "codesandbox", name: "CodeSandbox" },
|
|
27
|
+
{ id: "spotify", name: "Spotify" },
|
|
28
|
+
{ id: "twitter", name: "Twitter" },
|
|
29
|
+
{ id: "instagram", name: "Instagram" },
|
|
30
|
+
{ id: "tiktok", name: "TikTok" },
|
|
31
|
+
{ id: "generic", name: "Generic Link" }
|
|
32
|
+
],
|
|
33
|
+
default: "generic"
|
|
34
|
+
}),
|
|
35
|
+
/** Normalized reference kind */
|
|
36
|
+
kind: select({
|
|
37
|
+
options: [
|
|
38
|
+
{ id: "issue", name: "Issue" },
|
|
39
|
+
{ id: "pull-request", name: "Pull Request" },
|
|
40
|
+
{ id: "design", name: "Design" },
|
|
41
|
+
{ id: "video", name: "Video" },
|
|
42
|
+
{ id: "sandbox", name: "Sandbox" },
|
|
43
|
+
{ id: "social", name: "Social Post" },
|
|
44
|
+
{ id: "audio", name: "Audio" },
|
|
45
|
+
{ id: "link", name: "Link" }
|
|
46
|
+
],
|
|
47
|
+
default: "link"
|
|
48
|
+
}),
|
|
49
|
+
/** Provider-specific stable identifier */
|
|
50
|
+
refId: text({}),
|
|
51
|
+
/** Compact display title */
|
|
52
|
+
title: text({ required: true, maxLength: 500 }),
|
|
53
|
+
/** Secondary display label */
|
|
54
|
+
subtitle: text({ maxLength: 500 }),
|
|
55
|
+
/** Small icon or provider marker */
|
|
56
|
+
icon: text({ maxLength: 32 }),
|
|
57
|
+
/** Optional richer preview/embed URL */
|
|
58
|
+
embedUrl: url({}),
|
|
59
|
+
/** Provider-specific metadata stored as JSON */
|
|
60
|
+
metadata: text({ maxLength: 1e4 })
|
|
61
|
+
},
|
|
62
|
+
document: void 0,
|
|
63
|
+
// Standalone/personal content: owner-only by default (exploration 0192).
|
|
64
|
+
authorization: presets.private()
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
ExternalReferenceSchema
|
|
69
|
+
};
|