@xnetjs/data 0.0.2 → 0.1.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/README.md +112 -0
- package/dist/account-MWNCH4GJ.js +12 -0
- package/dist/account-ledger-R2GAFJL6.js +38 -0
- package/dist/auth/index.d.ts +420 -0
- package/dist/auth/index.js +102 -0
- package/dist/budget-NN7P35XP.js +12 -0
- package/dist/canvas-6WYBNH53.js +10 -0
- package/dist/channel-AT3LQF4A.js +12 -0
- package/dist/chat-message-DSVO72B3.js +10 -0
- package/dist/chunk-2ZNJWIQG.js +84 -0
- package/dist/chunk-3J3HILXO.js +46 -0
- package/dist/chunk-3RUDVTMH.js +5543 -0
- package/dist/chunk-4EYKGTSQ.js +49 -0
- package/dist/chunk-53F4PRNC.js +32 -0
- package/dist/chunk-5EXHNXPL.js +48 -0
- package/dist/{chunk-BQBPA5HS.js → chunk-5HC5NO57.js} +16 -2
- package/dist/chunk-6KLGA6IR.js +47 -0
- package/dist/chunk-6OMG4I7M.js +41 -0
- package/dist/chunk-7PDRDSFH.js +69 -0
- package/dist/chunk-BQLQSWKZ.js +232 -0
- package/dist/chunk-BY5O6LNC.js +380 -0
- package/dist/chunk-DCTRX6II.js +40 -0
- package/dist/{chunk-VYR5GPJP.js → chunk-DWEXKD6E.js} +9 -3
- package/dist/chunk-EBNMV2VO.js +896 -0
- package/dist/chunk-FVEACSKE.js +102 -0
- package/dist/chunk-GU6THOAB.js +45 -0
- package/dist/chunk-H4GA4BBK.js +75 -0
- package/dist/chunk-IJ44LR7N.js +76 -0
- package/dist/chunk-J4ANIXIV.js +402 -0
- package/dist/chunk-JDFNMFOZ.js +45 -0
- package/dist/chunk-K7DOZWWT.js +1811 -0
- package/dist/chunk-KQAT4XBL.js +49 -0
- package/dist/chunk-KQUALW4O.js +183 -0
- package/dist/chunk-LYSWLCOI.js +47 -0
- package/dist/chunk-MBTUO3ZL.js +65 -0
- package/dist/chunk-NI4FHG2K.js +52 -0
- package/dist/chunk-OCMSAKWV.js +78 -0
- package/dist/chunk-OGJCRNGE.js +57 -0
- package/dist/chunk-OPPHF3TF.js +143 -0
- package/dist/{chunk-IDMBCRUC.js → chunk-OSAWNZVM.js} +1 -1
- package/dist/chunk-PMUQACPY.js +33 -0
- package/dist/chunk-PNESGUH5.js +63 -0
- package/dist/chunk-Q3IEGH4B.js +51 -0
- package/dist/chunk-QJW5LDP4.js +52 -0
- package/dist/chunk-QWFTRZQT.js +142 -0
- package/dist/{chunk-SZC345Z2.js → chunk-RL64OJJ5.js} +1025 -1110
- package/dist/chunk-S5RP5RKY.js +416 -0
- package/dist/chunk-S6U6TCMN.js +722 -0
- package/dist/chunk-SVNGSZZA.js +69 -0
- package/dist/chunk-T5AZAOG5.js +54 -0
- package/dist/chunk-TCTZW4A6.js +42 -0
- package/dist/chunk-U64CW73O.js +109 -0
- package/dist/chunk-UDWKWTAX.js +6526 -0
- package/dist/chunk-UQM3G5A2.js +148 -0
- package/dist/chunk-VQ7JHB67.js +57 -0
- package/dist/chunk-W7EBL7ZU.js +73 -0
- package/dist/chunk-WEPK7SZF.js +65 -0
- package/dist/chunk-XHEA5UER.js +75 -0
- package/dist/chunk-XMSKJ5PV.js +66 -0
- package/dist/chunk-XROI44ZP.js +64 -0
- package/dist/chunk-Y3S5SRVM.js +45 -0
- package/dist/chunk-YEFKQYKA.js +43 -0
- package/dist/chunk-YSUIXD2Y.js +105 -0
- package/dist/chunk-ZCOFZY5M.js +70 -0
- package/dist/chunk-ZLU4Y3O2.js +50 -0
- package/dist/chunk-ZPZ7XDA6.js +54 -0
- package/dist/chunk-ZZ6TWKGS.js +40 -0
- package/dist/clone-C0Jhk2UN.d.ts +2205 -0
- package/dist/comment-QSWYAQVS.js +10 -0
- package/dist/crm-L5RYAAF3.js +68 -0
- package/dist/dashboard-JMKTTRA7.js +10 -0
- package/dist/database/index.d.ts +882 -0
- package/dist/database/index.js +523 -0
- package/dist/database-GIXSPZJW.js +10 -0
- package/dist/database-field-3EPAMZUR.js +10 -0
- package/dist/database-row-6Q6TRVE4.js +10 -0
- package/dist/database-select-option-BBBJFLLH.js +10 -0
- package/dist/database-view-5PLSOBI2.js +10 -0
- package/dist/experiment-DOVOZ34Y.js +10 -0
- package/dist/external-item-P2E5X7BZ.js +14 -0
- package/dist/external-reference-7BSFF6SA.js +8 -0
- package/dist/feed-2IXHHP6O.js +12 -0
- package/dist/feed-item-DPE6LN7I.js +12 -0
- package/dist/folder-6KM3KYD5.js +21 -0
- package/dist/game-5AK5XWBR.js +50 -0
- package/dist/grant-WTQSNT5A.js +8 -0
- package/dist/grant-expiration-cleaner-CY6BcmlR.d.ts +249 -0
- package/dist/import-batch-IXBJLQPJ.js +12 -0
- package/dist/inbox-state-E5NSVOGP.js +12 -0
- package/dist/index.d.ts +224 -4548
- package/dist/index.js +2252 -4754
- package/dist/map-RG5Y3CPC.js +10 -0
- package/dist/media-asset-QTCGLIZA.js +8 -0
- package/dist/memory-PNRTMBZO.js +12 -0
- package/dist/metric-65SVOX5C.js +10 -0
- package/dist/milestone-XEO6ZGDG.js +12 -0
- package/dist/moderation-FFHETMRB.js +30 -0
- package/dist/observation-2Y3QKUXM.js +10 -0
- package/dist/page-2V27JGKJ.js +10 -0
- package/dist/posting-GBOSZCMZ.js +12 -0
- package/dist/profile-BLLDWIDK.js +8 -0
- package/dist/project-CQL5LN26.js +10 -0
- package/dist/query-ast-C3m6kZYv.d.ts +226 -0
- package/dist/reaction-T2DTJBBV.js +10 -0
- package/dist/registry-DunPv__d.d.ts +99 -0
- package/dist/saved-view-4R2DBCL3.js +10 -0
- package/dist/schema/index.d.ts +6489 -0
- package/dist/schema/index.js +677 -0
- package/dist/schema-extension-LNRF2YRD.js +18 -0
- package/dist/space-IJU24PBH.js +42 -0
- package/dist/space-membership-DEUMM7NV.js +14 -0
- package/dist/store/index.d.ts +518 -0
- package/dist/store/index.js +135 -0
- package/dist/store-DtIDjk7c.d.ts +355 -0
- package/dist/sync/awareness.d.ts +69 -0
- package/dist/sync/awareness.js +20 -0
- package/dist/system-ILHCZOVO.js +38 -0
- package/dist/tag-SKCHM3U5.js +16 -0
- package/dist/task-7AOBP7WC.js +16 -0
- package/dist/task-view-NUGKELJP.js +10 -0
- package/dist/transaction-ZDSEGDIR.js +12 -0
- package/dist/transcription-PSCLDAGX.js +12 -0
- package/dist/types-S-BJAKyK.d.ts +1576 -0
- package/dist/updates.d.ts +44 -0
- package/dist/updates.js +16 -0
- package/dist/user-widget-RLY2N46A.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,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spaceCascadeAuthorization
|
|
3
|
+
} from "./chunk-OCMSAKWV.js";
|
|
4
|
+
import {
|
|
5
|
+
checkbox,
|
|
6
|
+
defineSchema,
|
|
7
|
+
json,
|
|
8
|
+
number,
|
|
9
|
+
relation,
|
|
10
|
+
text
|
|
11
|
+
} from "./chunk-EBNMV2VO.js";
|
|
12
|
+
|
|
13
|
+
// src/schema/schemas/database-field.ts
|
|
14
|
+
var DatabaseFieldSchema = defineSchema({
|
|
15
|
+
name: "DatabaseField",
|
|
16
|
+
namespace: "xnet://xnet.fyi/",
|
|
17
|
+
properties: {
|
|
18
|
+
/** Parent database */
|
|
19
|
+
database: relation({
|
|
20
|
+
target: "xnet://xnet.fyi/Database@2.0.0",
|
|
21
|
+
required: true
|
|
22
|
+
}),
|
|
23
|
+
/** Display name */
|
|
24
|
+
name: text({ required: true, maxLength: 200 }),
|
|
25
|
+
/** Field type (FieldType union, enforced in field-operations) */
|
|
26
|
+
type: text({ required: true, maxLength: 50 }),
|
|
27
|
+
/**
|
|
28
|
+
* Type-specific configuration (FieldConfig).
|
|
29
|
+
* Note: select/multiSelect options are NOT stored here — they are
|
|
30
|
+
* separate DatabaseSelectOption nodes so concurrent option creation
|
|
31
|
+
* merges cleanly.
|
|
32
|
+
*/
|
|
33
|
+
config: json({}),
|
|
34
|
+
/** Fractional index for default column ordering */
|
|
35
|
+
sortKey: text({ required: true }),
|
|
36
|
+
/** Default column width in pixels (table views) */
|
|
37
|
+
width: number({ min: 40, integer: true }),
|
|
38
|
+
/** Whether this is the title field (exactly one per database) */
|
|
39
|
+
isTitle: checkbox({}),
|
|
40
|
+
/** Hidden by default (views can override) */
|
|
41
|
+
hidden: checkbox({})
|
|
42
|
+
},
|
|
43
|
+
// Inherits access from its home Space (exploration 0181/0192).
|
|
44
|
+
authorization: spaceCascadeAuthorization("database")
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
DatabaseFieldSchema
|
|
49
|
+
};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import {
|
|
2
|
+
created,
|
|
3
|
+
createdBy,
|
|
4
|
+
defineSchema,
|
|
5
|
+
json,
|
|
6
|
+
number,
|
|
7
|
+
person,
|
|
8
|
+
select,
|
|
9
|
+
text
|
|
10
|
+
} from "./chunk-EBNMV2VO.js";
|
|
11
|
+
|
|
12
|
+
// src/schema/schemas/account-ledger.ts
|
|
13
|
+
var NS = "xnet://xnet.fyi/";
|
|
14
|
+
var ACCOUNT_RECORD_SCHEMA_IRI = "xnet://xnet.fyi/AccountRecord@1.0.0";
|
|
15
|
+
var DEVICE_RECORD_SCHEMA_IRI = "xnet://xnet.fyi/DeviceRecord@1.0.0";
|
|
16
|
+
var RECOVERY_RECORD_SCHEMA_IRI = "xnet://xnet.fyi/RecoveryRecord@1.0.0";
|
|
17
|
+
var REVOCATION_RECORD_SCHEMA_IRI = "xnet://xnet.fyi/RevocationRecord@1.0.0";
|
|
18
|
+
var ledgerStatus = () => select({
|
|
19
|
+
options: [
|
|
20
|
+
{ id: "active", name: "Active", color: "green" },
|
|
21
|
+
{ id: "revoked", name: "Revoked", color: "red" }
|
|
22
|
+
],
|
|
23
|
+
required: true,
|
|
24
|
+
default: "active"
|
|
25
|
+
});
|
|
26
|
+
var AccountRecordSchema = defineSchema({
|
|
27
|
+
name: "AccountRecord",
|
|
28
|
+
namespace: NS,
|
|
29
|
+
properties: {
|
|
30
|
+
/** Stable subject, e.g. `xnet:account:<hash>`. Appears in grants + the cloud binding. */
|
|
31
|
+
accountId: text({ required: true }),
|
|
32
|
+
label: text({}),
|
|
33
|
+
/** Device DIDs allowed to sign ledger changes (admit/revoke). JSON array of DIDs. */
|
|
34
|
+
controllers: json({}),
|
|
35
|
+
/** Monotonic epoch, bumped on every revocation so stale authorizations are detectable. */
|
|
36
|
+
epoch: number({}),
|
|
37
|
+
createdAt: created(),
|
|
38
|
+
createdBy: createdBy()
|
|
39
|
+
},
|
|
40
|
+
document: void 0
|
|
41
|
+
});
|
|
42
|
+
var DeviceRecordSchema = defineSchema({
|
|
43
|
+
name: "DeviceRecord",
|
|
44
|
+
namespace: NS,
|
|
45
|
+
properties: {
|
|
46
|
+
/** The owning account subject (id, for portability across hub mirrors). */
|
|
47
|
+
account: text({ required: true }),
|
|
48
|
+
/** The device's data identity (`did:key`). */
|
|
49
|
+
deviceDid: person({ required: true }),
|
|
50
|
+
label: text({}),
|
|
51
|
+
/** WebAuthn relying-party id the gating passkey is scoped to. */
|
|
52
|
+
rpId: text({}),
|
|
53
|
+
/** Hash of the WebAuthn credential id (never the credential itself). */
|
|
54
|
+
credentialIdHash: text({}),
|
|
55
|
+
/** Capability hints (JSON), e.g. which scopes this device may exercise. */
|
|
56
|
+
capabilities: json({}),
|
|
57
|
+
status: ledgerStatus(),
|
|
58
|
+
/** The controller DID that admitted this device. */
|
|
59
|
+
addedBy: person({}),
|
|
60
|
+
addedAt: number({}),
|
|
61
|
+
lastSeenAt: number({}),
|
|
62
|
+
/** Epoch at which this device was admitted. */
|
|
63
|
+
epoch: number({}),
|
|
64
|
+
createdAt: created(),
|
|
65
|
+
createdBy: createdBy()
|
|
66
|
+
},
|
|
67
|
+
document: void 0
|
|
68
|
+
});
|
|
69
|
+
var RecoveryRecordSchema = defineSchema({
|
|
70
|
+
name: "RecoveryRecord",
|
|
71
|
+
namespace: NS,
|
|
72
|
+
properties: {
|
|
73
|
+
account: text({ required: true }),
|
|
74
|
+
method: select({
|
|
75
|
+
options: [
|
|
76
|
+
{ id: "phrase", name: "Recovery phrase", color: "blue" },
|
|
77
|
+
{ id: "social", name: "Social recovery", color: "purple" },
|
|
78
|
+
{ id: "hardware", name: "Hardware key", color: "gray" },
|
|
79
|
+
{ id: "admin", name: "Enterprise admin", color: "yellow" },
|
|
80
|
+
{ id: "backup-passkey", name: "Backup passkey", color: "green" }
|
|
81
|
+
],
|
|
82
|
+
required: true,
|
|
83
|
+
default: "phrase"
|
|
84
|
+
}),
|
|
85
|
+
label: text({}),
|
|
86
|
+
/** Public commitment to the recovery key (e.g. the recovery DID), not the secret. */
|
|
87
|
+
publicKeyHash: text({}),
|
|
88
|
+
status: ledgerStatus(),
|
|
89
|
+
addedBy: person({}),
|
|
90
|
+
addedAt: number({}),
|
|
91
|
+
createdAt: created(),
|
|
92
|
+
createdBy: createdBy()
|
|
93
|
+
},
|
|
94
|
+
document: void 0
|
|
95
|
+
});
|
|
96
|
+
var RevocationRecordSchema = defineSchema({
|
|
97
|
+
name: "RevocationRecord",
|
|
98
|
+
namespace: NS,
|
|
99
|
+
properties: {
|
|
100
|
+
account: text({ required: true }),
|
|
101
|
+
subjectKind: select({
|
|
102
|
+
options: [
|
|
103
|
+
{ id: "device", name: "Device", color: "blue" },
|
|
104
|
+
{ id: "recovery", name: "Recovery method", color: "purple" }
|
|
105
|
+
],
|
|
106
|
+
required: true,
|
|
107
|
+
default: "device"
|
|
108
|
+
}),
|
|
109
|
+
/** The revoked subject: a device DID or a recovery record id. */
|
|
110
|
+
subject: text({ required: true }),
|
|
111
|
+
reason: text({}),
|
|
112
|
+
effectiveAt: number({}),
|
|
113
|
+
/** Epoch this revocation takes effect at. */
|
|
114
|
+
epoch: number({}),
|
|
115
|
+
/** The controller DID that signed the revocation. */
|
|
116
|
+
signedBy: person({}),
|
|
117
|
+
createdAt: created(),
|
|
118
|
+
createdBy: createdBy()
|
|
119
|
+
},
|
|
120
|
+
document: void 0
|
|
121
|
+
});
|
|
122
|
+
function accountRecordId(accountId) {
|
|
123
|
+
return `account:${accountId}`;
|
|
124
|
+
}
|
|
125
|
+
function deviceRecordId(accountId, deviceDid) {
|
|
126
|
+
return `device:${accountId}:${deviceDid}`;
|
|
127
|
+
}
|
|
128
|
+
function recoveryRecordId(accountId, recoveryKey) {
|
|
129
|
+
return `recovery:${accountId}:${recoveryKey}`;
|
|
130
|
+
}
|
|
131
|
+
function revocationRecordId(accountId, subject) {
|
|
132
|
+
return `revocation:${accountId}:${subject}`;
|
|
133
|
+
}
|
|
134
|
+
function revokedSubjects(revocations) {
|
|
135
|
+
return new Set(revocations.map((r) => r.subject));
|
|
136
|
+
}
|
|
137
|
+
function resolveActiveDevices(devices, revocations) {
|
|
138
|
+
const revoked = revokedSubjects(revocations);
|
|
139
|
+
return devices.filter((d) => d.status !== "revoked" && !revoked.has(d.deviceDid));
|
|
140
|
+
}
|
|
141
|
+
function isDeviceAuthorized(accountId, deviceDid, devices, revocations) {
|
|
142
|
+
const revoked = revokedSubjects(revocations);
|
|
143
|
+
if (revoked.has(deviceDid)) return false;
|
|
144
|
+
return devices.some(
|
|
145
|
+
(d) => d.account === accountId && d.deviceDid === deviceDid && d.status !== "revoked"
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
function deviceRecipientExpander(devices, revocations) {
|
|
149
|
+
const active = resolveActiveDevices(devices, revocations);
|
|
150
|
+
const activeByAccount = /* @__PURE__ */ new Map();
|
|
151
|
+
for (const d of active) {
|
|
152
|
+
const list = activeByAccount.get(d.account);
|
|
153
|
+
if (list) list.push(d.deviceDid);
|
|
154
|
+
else activeByAccount.set(d.account, [d.deviceDid]);
|
|
155
|
+
}
|
|
156
|
+
const accountOf = /* @__PURE__ */ new Map();
|
|
157
|
+
for (const d of devices) accountOf.set(d.deviceDid, d.account);
|
|
158
|
+
return (did) => {
|
|
159
|
+
const account = accountOf.get(did);
|
|
160
|
+
if (!account) return [did];
|
|
161
|
+
const siblings = activeByAccount.get(account);
|
|
162
|
+
return siblings && siblings.length > 0 ? [.../* @__PURE__ */ new Set([did, ...siblings])] : [did];
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export {
|
|
167
|
+
ACCOUNT_RECORD_SCHEMA_IRI,
|
|
168
|
+
DEVICE_RECORD_SCHEMA_IRI,
|
|
169
|
+
RECOVERY_RECORD_SCHEMA_IRI,
|
|
170
|
+
REVOCATION_RECORD_SCHEMA_IRI,
|
|
171
|
+
AccountRecordSchema,
|
|
172
|
+
DeviceRecordSchema,
|
|
173
|
+
RecoveryRecordSchema,
|
|
174
|
+
RevocationRecordSchema,
|
|
175
|
+
accountRecordId,
|
|
176
|
+
deviceRecordId,
|
|
177
|
+
recoveryRecordId,
|
|
178
|
+
revocationRecordId,
|
|
179
|
+
revokedSubjects,
|
|
180
|
+
resolveActiveDevices,
|
|
181
|
+
isDeviceAuthorized,
|
|
182
|
+
deviceRecipientExpander
|
|
183
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spaceCascadeAuthorization
|
|
3
|
+
} from "./chunk-OCMSAKWV.js";
|
|
4
|
+
import {
|
|
5
|
+
defineSchema,
|
|
6
|
+
relation,
|
|
7
|
+
select,
|
|
8
|
+
text
|
|
9
|
+
} from "./chunk-EBNMV2VO.js";
|
|
10
|
+
|
|
11
|
+
// src/schema/schemas/canvas.ts
|
|
12
|
+
var CanvasSchema = defineSchema({
|
|
13
|
+
name: "Canvas",
|
|
14
|
+
namespace: "xnet://xnet.fyi/",
|
|
15
|
+
properties: {
|
|
16
|
+
/** Canvas title */
|
|
17
|
+
title: text({ required: true, maxLength: 500 }),
|
|
18
|
+
/** Emoji or icon URL */
|
|
19
|
+
icon: text({}),
|
|
20
|
+
/** Canonical home; empty = Unfiled (exploration 0169) */
|
|
21
|
+
folder: relation({ target: "xnet://xnet.fyi/Folder@1.0.0" }),
|
|
22
|
+
/** Order among folder siblings — fractional index */
|
|
23
|
+
sortKey: text({ maxLength: 500 }),
|
|
24
|
+
/** Workspace-wide labels, referenced by id (exploration 0169) */
|
|
25
|
+
tags: relation({ target: "xnet://xnet.fyi/Tag@1.0.0", multiple: true }),
|
|
26
|
+
/** Canonical SECURITY home; empty = personal/private (exploration 0179) */
|
|
27
|
+
space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" }),
|
|
28
|
+
/** Per-node visibility; `inherit` defers to the Space (exploration 0179) */
|
|
29
|
+
visibility: select({
|
|
30
|
+
options: [
|
|
31
|
+
{ id: "inherit", name: "Inherit", color: "gray" },
|
|
32
|
+
{ id: "private", name: "Private", color: "gray" },
|
|
33
|
+
{ id: "unlisted", name: "Unlisted", color: "yellow" },
|
|
34
|
+
{ id: "public", name: "Public", color: "green" }
|
|
35
|
+
],
|
|
36
|
+
default: "inherit"
|
|
37
|
+
})
|
|
38
|
+
},
|
|
39
|
+
document: "yjs",
|
|
40
|
+
// Collaborative Y.Doc for canvas data (nodes, edges)
|
|
41
|
+
// Inherits access from its home Space (exploration 0181/0192).
|
|
42
|
+
authorization: spaceCascadeAuthorization()
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
CanvasSchema
|
|
47
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spaceCascadeAuthorization
|
|
3
|
+
} from "./chunk-OCMSAKWV.js";
|
|
4
|
+
import {
|
|
5
|
+
date,
|
|
6
|
+
defineSchema,
|
|
7
|
+
relation,
|
|
8
|
+
select,
|
|
9
|
+
text
|
|
10
|
+
} from "./chunk-EBNMV2VO.js";
|
|
11
|
+
|
|
12
|
+
// src/schema/schemas/transaction.ts
|
|
13
|
+
var TRANSACTION_SCHEMA_IRI = "xnet://xnet.fyi/Transaction@1.0.0";
|
|
14
|
+
var TransactionSchema = defineSchema({
|
|
15
|
+
name: "Transaction",
|
|
16
|
+
namespace: "xnet://xnet.fyi/",
|
|
17
|
+
properties: {
|
|
18
|
+
/** When the transaction posted (Unix ms). */
|
|
19
|
+
date: date({ required: true }),
|
|
20
|
+
/** Who was paid / who paid (free text). */
|
|
21
|
+
payee: text({ maxLength: 200 }),
|
|
22
|
+
/** Note / description. */
|
|
23
|
+
memo: text({ maxLength: 2e3 }),
|
|
24
|
+
/**
|
|
25
|
+
* Counterparty in the person/contact graph (AR/AP). Untyped so it can point
|
|
26
|
+
* at a Profile, a ConnectableProfile (CRM), or any contact node.
|
|
27
|
+
*/
|
|
28
|
+
counterparty: relation({}),
|
|
29
|
+
/** Reconciliation state. */
|
|
30
|
+
status: select({
|
|
31
|
+
options: [
|
|
32
|
+
{ id: "pending", name: "Pending", color: "gray" },
|
|
33
|
+
{ id: "cleared", name: "Cleared", color: "blue" },
|
|
34
|
+
{ id: "reconciled", name: "Reconciled", color: "green" }
|
|
35
|
+
],
|
|
36
|
+
default: "pending"
|
|
37
|
+
}),
|
|
38
|
+
/** The import batch that produced this transaction, if any. */
|
|
39
|
+
importBatch: relation({ target: "xnet://xnet.fyi/ImportBatch@1.0.0" }),
|
|
40
|
+
/** Stable provider/file id for de-duplication on re-import. */
|
|
41
|
+
externalId: text({ maxLength: 200 }),
|
|
42
|
+
/** Optional folder home for uniform filing; empty = Unfiled (0190). */
|
|
43
|
+
folder: relation({ target: "xnet://xnet.fyi/Folder@1.0.0" }),
|
|
44
|
+
/** Optional CRM deal this transaction realizes (quote-to-cash, 0190). */
|
|
45
|
+
deal: relation({ target: "xnet://xnet.fyi/Deal@1.0.0" }),
|
|
46
|
+
/** Canonical SECURITY home; empty = personal/private book (0179/0181). */
|
|
47
|
+
space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" }),
|
|
48
|
+
/** Per-node visibility; defaults to `private` (financial data, 0187). */
|
|
49
|
+
visibility: select({
|
|
50
|
+
options: [
|
|
51
|
+
{ id: "inherit", name: "Inherit", color: "gray" },
|
|
52
|
+
{ id: "private", name: "Private", color: "gray" },
|
|
53
|
+
{ id: "unlisted", name: "Unlisted", color: "yellow" },
|
|
54
|
+
{ id: "public", name: "Public", color: "green" }
|
|
55
|
+
],
|
|
56
|
+
default: "private"
|
|
57
|
+
})
|
|
58
|
+
},
|
|
59
|
+
authorization: spaceCascadeAuthorization()
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
TRANSACTION_SCHEMA_IRI,
|
|
64
|
+
TransactionSchema
|
|
65
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spaceCascadeAuthorization
|
|
3
|
+
} from "./chunk-OCMSAKWV.js";
|
|
4
|
+
import {
|
|
5
|
+
defineSchema,
|
|
6
|
+
json,
|
|
7
|
+
relation,
|
|
8
|
+
select,
|
|
9
|
+
text
|
|
10
|
+
} from "./chunk-EBNMV2VO.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,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SPACE_MEMBERSHIP_SCHEMA_IRI
|
|
3
|
+
} from "./chunk-T5AZAOG5.js";
|
|
4
|
+
import {
|
|
5
|
+
allow,
|
|
6
|
+
role
|
|
7
|
+
} from "./chunk-RL64OJJ5.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,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
spaceCascadeAuthorization
|
|
3
|
+
} from "./chunk-OCMSAKWV.js";
|
|
4
|
+
import {
|
|
5
|
+
date,
|
|
6
|
+
defineSchema,
|
|
7
|
+
relation,
|
|
8
|
+
select,
|
|
9
|
+
text
|
|
10
|
+
} from "./chunk-EBNMV2VO.js";
|
|
11
|
+
|
|
12
|
+
// src/schema/schemas/milestone.ts
|
|
13
|
+
var MILESTONE_SCHEMA_IRI = "xnet://xnet.fyi/Milestone@1.0.0";
|
|
14
|
+
var MilestoneSchema = defineSchema({
|
|
15
|
+
name: "Milestone",
|
|
16
|
+
namespace: "xnet://xnet.fyi/",
|
|
17
|
+
properties: {
|
|
18
|
+
/** Milestone name */
|
|
19
|
+
name: text({ required: true, maxLength: 200 }),
|
|
20
|
+
/** Lifecycle status */
|
|
21
|
+
status: select({
|
|
22
|
+
options: [
|
|
23
|
+
{ id: "upcoming", name: "Upcoming", color: "gray" },
|
|
24
|
+
{ id: "active", name: "Active", color: "blue" },
|
|
25
|
+
{ id: "done", name: "Done", color: "green" },
|
|
26
|
+
{ id: "cancelled", name: "Cancelled", color: "red" }
|
|
27
|
+
],
|
|
28
|
+
default: "upcoming"
|
|
29
|
+
}),
|
|
30
|
+
/** Target completion date */
|
|
31
|
+
targetDate: date({}),
|
|
32
|
+
/** The project this milestone belongs to */
|
|
33
|
+
project: relation({ target: "xnet://xnet.fyi/Project@1.0.0", required: true }),
|
|
34
|
+
/** Order among sibling milestones — fractional index */
|
|
35
|
+
sortKey: text({ maxLength: 500 }),
|
|
36
|
+
/** Canonical SECURITY home; empty = inherits via project (exploration 0181) */
|
|
37
|
+
space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" }),
|
|
38
|
+
/** Per-node visibility; `inherit` defers to the Space */
|
|
39
|
+
visibility: select({
|
|
40
|
+
options: [
|
|
41
|
+
{ id: "inherit", name: "Inherit", color: "gray" },
|
|
42
|
+
{ id: "private", name: "Private", color: "gray" },
|
|
43
|
+
{ id: "unlisted", name: "Unlisted", color: "yellow" },
|
|
44
|
+
{ id: "public", name: "Public", color: "green" }
|
|
45
|
+
],
|
|
46
|
+
default: "inherit"
|
|
47
|
+
})
|
|
48
|
+
},
|
|
49
|
+
document: "yjs",
|
|
50
|
+
// Inherits access from its home Space (exploration 0181).
|
|
51
|
+
authorization: spaceCascadeAuthorization()
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export {
|
|
55
|
+
MILESTONE_SCHEMA_IRI,
|
|
56
|
+
MilestoneSchema
|
|
57
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildFolderTree,
|
|
3
|
+
flattenFolderTree,
|
|
4
|
+
folderAncestorIds,
|
|
5
|
+
folderPathIds,
|
|
6
|
+
wouldCreateFolderCycle
|
|
7
|
+
} from "./chunk-YSUIXD2Y.js";
|
|
8
|
+
import {
|
|
9
|
+
spaceOwnAuthorization
|
|
10
|
+
} from "./chunk-OCMSAKWV.js";
|
|
11
|
+
import {
|
|
12
|
+
checkbox,
|
|
13
|
+
created,
|
|
14
|
+
createdBy,
|
|
15
|
+
defineSchema,
|
|
16
|
+
person,
|
|
17
|
+
relation,
|
|
18
|
+
select,
|
|
19
|
+
text
|
|
20
|
+
} from "./chunk-EBNMV2VO.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
|
+
};
|