@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.
Files changed (139) hide show
  1. package/README.md +112 -0
  2. package/dist/account-MWNCH4GJ.js +12 -0
  3. package/dist/account-ledger-R2GAFJL6.js +38 -0
  4. package/dist/auth/index.d.ts +420 -0
  5. package/dist/auth/index.js +102 -0
  6. package/dist/budget-NN7P35XP.js +12 -0
  7. package/dist/canvas-6WYBNH53.js +10 -0
  8. package/dist/channel-AT3LQF4A.js +12 -0
  9. package/dist/chat-message-DSVO72B3.js +10 -0
  10. package/dist/chunk-2ZNJWIQG.js +84 -0
  11. package/dist/chunk-3J3HILXO.js +46 -0
  12. package/dist/chunk-3RUDVTMH.js +5543 -0
  13. package/dist/chunk-4EYKGTSQ.js +49 -0
  14. package/dist/chunk-53F4PRNC.js +32 -0
  15. package/dist/chunk-5EXHNXPL.js +48 -0
  16. package/dist/{chunk-BQBPA5HS.js → chunk-5HC5NO57.js} +16 -2
  17. package/dist/chunk-6KLGA6IR.js +47 -0
  18. package/dist/chunk-6OMG4I7M.js +41 -0
  19. package/dist/chunk-7PDRDSFH.js +69 -0
  20. package/dist/chunk-BQLQSWKZ.js +232 -0
  21. package/dist/chunk-BY5O6LNC.js +380 -0
  22. package/dist/chunk-DCTRX6II.js +40 -0
  23. package/dist/{chunk-VYR5GPJP.js → chunk-DWEXKD6E.js} +9 -3
  24. package/dist/chunk-EBNMV2VO.js +896 -0
  25. package/dist/chunk-FVEACSKE.js +102 -0
  26. package/dist/chunk-GU6THOAB.js +45 -0
  27. package/dist/chunk-H4GA4BBK.js +75 -0
  28. package/dist/chunk-IJ44LR7N.js +76 -0
  29. package/dist/chunk-J4ANIXIV.js +402 -0
  30. package/dist/chunk-JDFNMFOZ.js +45 -0
  31. package/dist/chunk-K7DOZWWT.js +1811 -0
  32. package/dist/chunk-KQAT4XBL.js +49 -0
  33. package/dist/chunk-KQUALW4O.js +183 -0
  34. package/dist/chunk-LYSWLCOI.js +47 -0
  35. package/dist/chunk-MBTUO3ZL.js +65 -0
  36. package/dist/chunk-NI4FHG2K.js +52 -0
  37. package/dist/chunk-OCMSAKWV.js +78 -0
  38. package/dist/chunk-OGJCRNGE.js +57 -0
  39. package/dist/chunk-OPPHF3TF.js +143 -0
  40. package/dist/{chunk-IDMBCRUC.js → chunk-OSAWNZVM.js} +1 -1
  41. package/dist/chunk-PMUQACPY.js +33 -0
  42. package/dist/chunk-PNESGUH5.js +63 -0
  43. package/dist/chunk-Q3IEGH4B.js +51 -0
  44. package/dist/chunk-QJW5LDP4.js +52 -0
  45. package/dist/chunk-QWFTRZQT.js +142 -0
  46. package/dist/{chunk-SZC345Z2.js → chunk-RL64OJJ5.js} +1025 -1110
  47. package/dist/chunk-S5RP5RKY.js +416 -0
  48. package/dist/chunk-S6U6TCMN.js +722 -0
  49. package/dist/chunk-SVNGSZZA.js +69 -0
  50. package/dist/chunk-T5AZAOG5.js +54 -0
  51. package/dist/chunk-TCTZW4A6.js +42 -0
  52. package/dist/chunk-U64CW73O.js +109 -0
  53. package/dist/chunk-UDWKWTAX.js +6526 -0
  54. package/dist/chunk-UQM3G5A2.js +148 -0
  55. package/dist/chunk-VQ7JHB67.js +57 -0
  56. package/dist/chunk-W7EBL7ZU.js +73 -0
  57. package/dist/chunk-WEPK7SZF.js +65 -0
  58. package/dist/chunk-XHEA5UER.js +75 -0
  59. package/dist/chunk-XMSKJ5PV.js +66 -0
  60. package/dist/chunk-XROI44ZP.js +64 -0
  61. package/dist/chunk-Y3S5SRVM.js +45 -0
  62. package/dist/chunk-YEFKQYKA.js +43 -0
  63. package/dist/chunk-YSUIXD2Y.js +105 -0
  64. package/dist/chunk-ZCOFZY5M.js +70 -0
  65. package/dist/chunk-ZLU4Y3O2.js +50 -0
  66. package/dist/chunk-ZPZ7XDA6.js +54 -0
  67. package/dist/chunk-ZZ6TWKGS.js +40 -0
  68. package/dist/clone-C0Jhk2UN.d.ts +2205 -0
  69. package/dist/comment-QSWYAQVS.js +10 -0
  70. package/dist/crm-L5RYAAF3.js +68 -0
  71. package/dist/dashboard-JMKTTRA7.js +10 -0
  72. package/dist/database/index.d.ts +882 -0
  73. package/dist/database/index.js +523 -0
  74. package/dist/database-GIXSPZJW.js +10 -0
  75. package/dist/database-field-3EPAMZUR.js +10 -0
  76. package/dist/database-row-6Q6TRVE4.js +10 -0
  77. package/dist/database-select-option-BBBJFLLH.js +10 -0
  78. package/dist/database-view-5PLSOBI2.js +10 -0
  79. package/dist/experiment-DOVOZ34Y.js +10 -0
  80. package/dist/external-item-P2E5X7BZ.js +14 -0
  81. package/dist/external-reference-7BSFF6SA.js +8 -0
  82. package/dist/feed-2IXHHP6O.js +12 -0
  83. package/dist/feed-item-DPE6LN7I.js +12 -0
  84. package/dist/folder-6KM3KYD5.js +21 -0
  85. package/dist/game-5AK5XWBR.js +50 -0
  86. package/dist/grant-WTQSNT5A.js +8 -0
  87. package/dist/grant-expiration-cleaner-CY6BcmlR.d.ts +249 -0
  88. package/dist/import-batch-IXBJLQPJ.js +12 -0
  89. package/dist/inbox-state-E5NSVOGP.js +12 -0
  90. package/dist/index.d.ts +224 -4548
  91. package/dist/index.js +2252 -4754
  92. package/dist/map-RG5Y3CPC.js +10 -0
  93. package/dist/media-asset-QTCGLIZA.js +8 -0
  94. package/dist/memory-PNRTMBZO.js +12 -0
  95. package/dist/metric-65SVOX5C.js +10 -0
  96. package/dist/milestone-XEO6ZGDG.js +12 -0
  97. package/dist/moderation-FFHETMRB.js +30 -0
  98. package/dist/observation-2Y3QKUXM.js +10 -0
  99. package/dist/page-2V27JGKJ.js +10 -0
  100. package/dist/posting-GBOSZCMZ.js +12 -0
  101. package/dist/profile-BLLDWIDK.js +8 -0
  102. package/dist/project-CQL5LN26.js +10 -0
  103. package/dist/query-ast-C3m6kZYv.d.ts +226 -0
  104. package/dist/reaction-T2DTJBBV.js +10 -0
  105. package/dist/registry-DunPv__d.d.ts +99 -0
  106. package/dist/saved-view-4R2DBCL3.js +10 -0
  107. package/dist/schema/index.d.ts +6489 -0
  108. package/dist/schema/index.js +677 -0
  109. package/dist/schema-extension-LNRF2YRD.js +18 -0
  110. package/dist/space-IJU24PBH.js +42 -0
  111. package/dist/space-membership-DEUMM7NV.js +14 -0
  112. package/dist/store/index.d.ts +518 -0
  113. package/dist/store/index.js +135 -0
  114. package/dist/store-DtIDjk7c.d.ts +355 -0
  115. package/dist/sync/awareness.d.ts +69 -0
  116. package/dist/sync/awareness.js +20 -0
  117. package/dist/system-ILHCZOVO.js +38 -0
  118. package/dist/tag-SKCHM3U5.js +16 -0
  119. package/dist/task-7AOBP7WC.js +16 -0
  120. package/dist/task-view-NUGKELJP.js +10 -0
  121. package/dist/transaction-ZDSEGDIR.js +12 -0
  122. package/dist/transcription-PSCLDAGX.js +12 -0
  123. package/dist/types-S-BJAKyK.d.ts +1576 -0
  124. package/dist/updates.d.ts +44 -0
  125. package/dist/updates.js +16 -0
  126. package/dist/user-widget-RLY2N46A.js +8 -0
  127. package/dist/view-types-DSde-uT_.d.ts +316 -0
  128. package/package.json +32 -9
  129. package/dist/canvas-HSIKIQFK.js +0 -7
  130. package/dist/chunk-2L5ZUGG5.js +0 -53
  131. package/dist/chunk-4MTS5KAQ.js +0 -22
  132. package/dist/chunk-GZHARFKC.js +0 -25
  133. package/dist/chunk-WKIKJTI2.js +0 -45
  134. package/dist/comment-277JD7DV.js +0 -7
  135. package/dist/database-W3KEHLI3.js +0 -7
  136. package/dist/database-row-3O2QSNZN.js +0 -7
  137. package/dist/grant-QVZ454YC.js +0 -7
  138. package/dist/page-O4WTOIEO.js +0 -7
  139. package/dist/task-SEKAYJH7.js +0 -7
@@ -0,0 +1,148 @@
1
+ import {
2
+ spaceCascadeAuthorization
3
+ } from "./chunk-OCMSAKWV.js";
4
+ import {
5
+ checkbox,
6
+ date,
7
+ defineSchema,
8
+ person,
9
+ relation,
10
+ select,
11
+ text
12
+ } from "./chunk-EBNMV2VO.js";
13
+
14
+ // src/schema/schemas/task.ts
15
+ var TaskSchema = defineSchema({
16
+ name: "Task",
17
+ namespace: "xnet://xnet.fyi/",
18
+ properties: {
19
+ /** Task title */
20
+ title: text({ required: true, maxLength: 500 }),
21
+ /**
22
+ * Human-readable identifier, e.g. "XN-142". Allocated from hub-issued
23
+ * per-device blocks (see task-identifiers.ts) so offline mints never
24
+ * collide. Pattern-matched in branch names / commit messages / PR text
25
+ * by the GitHub integration.
26
+ */
27
+ shortId: text({ maxLength: 20 }),
28
+ /** Whether the task is completed */
29
+ completed: checkbox({ default: false }),
30
+ /**
31
+ * Task workflow status.
32
+ *
33
+ * Statuses belong to categories (TASK_STATUS_CATEGORIES); `completed`
34
+ * is derivable from the category (isCompletedTaskStatus) so checkboxes
35
+ * stay one-tap everywhere. The original four statuses are unchanged;
36
+ * triage/backlog/in-review are additive (no version bump needed).
37
+ */
38
+ status: select({
39
+ options: [
40
+ { id: "triage", name: "Triage", color: "yellow" },
41
+ { id: "backlog", name: "Backlog", color: "gray" },
42
+ { id: "todo", name: "To Do", color: "gray" },
43
+ { id: "in-progress", name: "In Progress", color: "blue" },
44
+ { id: "in-review", name: "In Review", color: "green" },
45
+ { id: "done", name: "Done", color: "green" },
46
+ { id: "cancelled", name: "Cancelled", color: "red" }
47
+ ],
48
+ default: "todo"
49
+ }),
50
+ /** Task priority */
51
+ priority: select({
52
+ options: [
53
+ { id: "low", name: "Low", color: "gray" },
54
+ { id: "medium", name: "Medium", color: "yellow" },
55
+ { id: "high", name: "High", color: "orange" },
56
+ { id: "urgent", name: "Urgent", color: "red" }
57
+ ],
58
+ default: "medium"
59
+ }),
60
+ /** Due date */
61
+ dueDate: date({}),
62
+ /** Assigned person (legacy single assignee for compatibility) */
63
+ assignee: person({}),
64
+ /** Assigned people */
65
+ assignees: person({ multiple: true }),
66
+ /** Parent task (for subtasks) */
67
+ parent: relation({ target: "xnet://xnet.fyi/Task" }),
68
+ /** Project this task belongs to */
69
+ project: relation({ target: "xnet://xnet.fyi/Project@1.0.0" }),
70
+ /** Milestone within the project this task targets (one per task) */
71
+ milestone: relation({ target: "xnet://xnet.fyi/Milestone@1.0.0" }),
72
+ /** Page that currently hosts this task */
73
+ page: relation({ target: "xnet://xnet.fyi/Page@1.0.0" }),
74
+ /** Canvas that currently hosts this task (canvas-sourced tasks) */
75
+ canvas: relation({ target: "xnet://xnet.fyi/Canvas@1.0.0" }),
76
+ /** Surface-specific anchor: block id inside the page document, or the
77
+ * hosting canvas object id for canvas-sourced tasks */
78
+ anchorBlockId: text({ maxLength: 500 }),
79
+ /** Stable sibling order key for cross-view projections */
80
+ sortKey: text({ maxLength: 500 }),
81
+ /** Workspace-wide labels, referenced by id (exploration 0169) */
82
+ tags: relation({ target: "xnet://xnet.fyi/Tag@1.0.0", multiple: true }),
83
+ /** Where this task was created */
84
+ source: select({
85
+ options: [
86
+ { id: "page", name: "Page" },
87
+ { id: "database", name: "Database" },
88
+ { id: "canvas", name: "Canvas" },
89
+ { id: "automation", name: "Automation" },
90
+ { id: "api", name: "API" }
91
+ ],
92
+ default: "page"
93
+ }),
94
+ /** Structured external references related to this task */
95
+ references: relation({
96
+ target: "xnet://xnet.fyi/ExternalReference@1.0.0",
97
+ multiple: true
98
+ }),
99
+ /** Canonical folder home for uniform filing; empty = Unfiled (0190) */
100
+ folder: relation({ target: "xnet://xnet.fyi/Folder@1.0.0" }),
101
+ /**
102
+ * Optional habit/metric this task tracks — completing the task can log an
103
+ * observation against the metric (cross-domain integration, 0190).
104
+ */
105
+ metric: relation({ target: "xnet://xnet.fyi/Metric@1.0.0" }),
106
+ /** Optional experiment this task belongs to (cross-domain, 0190). */
107
+ experiment: relation({ target: "xnet://xnet.fyi/Experiment@1.0.0" }),
108
+ /** Canonical SECURITY home; empty = personal/private (exploration 0179) */
109
+ space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" }),
110
+ /** Per-node visibility; `inherit` defers to the Space (exploration 0179) */
111
+ visibility: select({
112
+ options: [
113
+ { id: "inherit", name: "Inherit", color: "gray" },
114
+ { id: "private", name: "Private", color: "gray" },
115
+ { id: "unlisted", name: "Unlisted", color: "yellow" },
116
+ { id: "public", name: "Public", color: "green" }
117
+ ],
118
+ default: "inherit"
119
+ })
120
+ },
121
+ document: "yjs",
122
+ // Collaborative Y.Doc for description
123
+ // Inherits access from its home Space (exploration 0181).
124
+ authorization: spaceCascadeAuthorization()
125
+ });
126
+ var TASK_STATUS_CATEGORIES = {
127
+ triage: "triage",
128
+ backlog: "backlog",
129
+ todo: "unstarted",
130
+ "in-progress": "started",
131
+ "in-review": "started",
132
+ done: "completed",
133
+ cancelled: "cancelled"
134
+ };
135
+ function getTaskStatusCategory(status) {
136
+ return TASK_STATUS_CATEGORIES[status ?? "todo"] ?? "unstarted";
137
+ }
138
+ function isCompletedTaskStatus(status) {
139
+ const category = getTaskStatusCategory(status);
140
+ return category === "completed" || category === "cancelled";
141
+ }
142
+
143
+ export {
144
+ TaskSchema,
145
+ TASK_STATUS_CATEGORIES,
146
+ getTaskStatusCategory,
147
+ isCompletedTaskStatus
148
+ };
@@ -0,0 +1,57 @@
1
+ import {
2
+ spaceCascadeAuthorization
3
+ } from "./chunk-OCMSAKWV.js";
4
+ import {
5
+ date,
6
+ defineSchema,
7
+ number,
8
+ relation,
9
+ select,
10
+ text
11
+ } from "./chunk-EBNMV2VO.js";
12
+
13
+ // src/schema/schemas/import-batch.ts
14
+ var IMPORT_BATCH_SCHEMA_IRI = "xnet://xnet.fyi/ImportBatch@1.0.0";
15
+ var ImportBatchSchema = defineSchema({
16
+ name: "ImportBatch",
17
+ namespace: "xnet://xnet.fyi/",
18
+ properties: {
19
+ /** Where the rows came from. */
20
+ source: select({
21
+ options: [
22
+ { id: "csv", name: "CSV" },
23
+ { id: "ofx", name: "OFX / QFX" },
24
+ { id: "qif", name: "QIF" },
25
+ { id: "bank", name: "Bank sync" },
26
+ { id: "manual", name: "Manual" }
27
+ ],
28
+ default: "csv"
29
+ }),
30
+ /** Original file name, if any. */
31
+ filename: text({ maxLength: 500 }),
32
+ /** When the import ran (Unix ms). */
33
+ importedAt: date({ required: true }),
34
+ /** The account the statement was imported into. */
35
+ account: relation({ target: "xnet://xnet.fyi/Account@1.0.0" }),
36
+ /** Number of transactions created in this batch. */
37
+ count: number({ integer: true, min: 0 }),
38
+ /** Canonical SECURITY home; empty = personal/private book (0179/0181). */
39
+ space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" }),
40
+ /** Per-node visibility; defaults to `private` (financial data, 0187). */
41
+ visibility: select({
42
+ options: [
43
+ { id: "inherit", name: "Inherit", color: "gray" },
44
+ { id: "private", name: "Private", color: "gray" },
45
+ { id: "unlisted", name: "Unlisted", color: "yellow" },
46
+ { id: "public", name: "Public", color: "green" }
47
+ ],
48
+ default: "private"
49
+ })
50
+ },
51
+ authorization: spaceCascadeAuthorization()
52
+ });
53
+
54
+ export {
55
+ IMPORT_BATCH_SCHEMA_IRI,
56
+ ImportBatchSchema
57
+ };
@@ -0,0 +1,73 @@
1
+ import {
2
+ spaceCascadeAuthorization
3
+ } from "./chunk-OCMSAKWV.js";
4
+ import {
5
+ date,
6
+ defineSchema,
7
+ json,
8
+ number,
9
+ relation,
10
+ select,
11
+ text
12
+ } from "./chunk-EBNMV2VO.js";
13
+
14
+ // src/schema/schemas/observation.ts
15
+ var ObservationSchema = defineSchema({
16
+ name: "Observation",
17
+ namespace: "xnet://xnet.fyi/",
18
+ properties: {
19
+ /** The metric this datapoint measures. */
20
+ metric: relation({ target: "xnet://xnet.fyi/Metric@1.0.0", required: true }),
21
+ /**
22
+ * Canonical day — UTC midnight ms of the calendar day (see
23
+ * @xnetjs/experiments `canonicalDay`). One observation per day per metric is
24
+ * the norm; using `date()` gives date-aware filters + calendar binding.
25
+ */
26
+ day: date({ required: true }),
27
+ /** Measured value. Booleans encode 1 (done) / 0 (not). */
28
+ value: number({ required: true }),
29
+ /** Free-text note for the datapoint (qualitative context). */
30
+ note: text({ maxLength: 2e3 }),
31
+ /** Stamped from the experiment's active phase at entry time. */
32
+ phase: select({
33
+ options: [
34
+ { id: "none", name: "None" },
35
+ { id: "baseline", name: "Baseline" },
36
+ { id: "intervention", name: "Intervention" },
37
+ { id: "washout", name: "Washout" }
38
+ ],
39
+ default: "none"
40
+ }),
41
+ /** Where the value came from. */
42
+ source: select({
43
+ options: [
44
+ { id: "manual", name: "Manual" },
45
+ { id: "sensor", name: "Sensor" },
46
+ { id: "import", name: "Import" }
47
+ ],
48
+ default: "manual"
49
+ }),
50
+ /** Confounds logged for the day, e.g. ["alcohol","poor sleep"]. */
51
+ confounds: json({}),
52
+ /** Denormalized owning experiment (for fast per-experiment queries). */
53
+ experiment: relation({ target: "xnet://xnet.fyi/Experiment@1.0.0" }),
54
+ /** Canonical SECURITY home; empty = personal/private (exploration 0179). */
55
+ space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" }),
56
+ /** Per-node visibility. Defaults to `private` (sensitive data, 0180). */
57
+ visibility: select({
58
+ options: [
59
+ { id: "inherit", name: "Inherit", color: "gray" },
60
+ { id: "private", name: "Private", color: "gray" },
61
+ { id: "unlisted", name: "Unlisted", color: "yellow" },
62
+ { id: "public", name: "Public", color: "green" }
63
+ ],
64
+ default: "private"
65
+ })
66
+ },
67
+ // Inherits access from its home Space (exploration 0181/0192).
68
+ authorization: spaceCascadeAuthorization()
69
+ });
70
+
71
+ export {
72
+ ObservationSchema
73
+ };
@@ -0,0 +1,65 @@
1
+ import {
2
+ spaceCascadeAuthorization
3
+ } from "./chunk-OCMSAKWV.js";
4
+ import {
5
+ defineSchema,
6
+ json,
7
+ number,
8
+ relation,
9
+ text
10
+ } from "./chunk-EBNMV2VO.js";
11
+
12
+ // src/schema/schemas/schema-extension.ts
13
+ var SCHEMA_EXTENSION_SCHEMA_IRI = "xnet://xnet.fyi/SchemaExtension@1.0.0";
14
+ var EXTENSION_FIELD_SCHEMA_IRI = "xnet://xnet.fyi/ExtensionField@1.0.0";
15
+ var SchemaExtensionSchema = defineSchema({
16
+ name: "SchemaExtension",
17
+ namespace: "xnet://xnet.fyi/",
18
+ properties: {
19
+ /** Versioned IRI of the schema being extended, e.g. 'xnet://xnet.fyi/Contact@1.0.0' */
20
+ targetSchema: text({ required: true, maxLength: 300 }),
21
+ /**
22
+ * Namespace authority that owns these fields — a Space id, a DID, or a
23
+ * domain. Becomes the `<authority>` segment of every `ext:` key, so two
24
+ * tenants extending the same schema never collide.
25
+ */
26
+ authority: text({ required: true, maxLength: 200 }),
27
+ /** Human-readable label for the extension set (e.g. "Acme CRM fields") */
28
+ label: text({ maxLength: 200 }),
29
+ /** Optional owning Space — drives the authorization cascade for this overlay */
30
+ space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" })
31
+ },
32
+ authorization: spaceCascadeAuthorization()
33
+ });
34
+ var ExtensionFieldSchema = defineSchema({
35
+ name: "ExtensionField",
36
+ namespace: "xnet://xnet.fyi/",
37
+ properties: {
38
+ /** Parent SchemaExtension */
39
+ extension: relation({ target: SCHEMA_EXTENSION_SCHEMA_IRI, required: true }),
40
+ /** Field token — the `<field>` segment of the `ext:<authority>/<field>` key */
41
+ name: text({ required: true, maxLength: 200 }),
42
+ /** Field type (FieldType union, enforced in field-operations) */
43
+ type: text({ required: true, maxLength: 50 }),
44
+ /** Type-specific configuration (FieldConfig) */
45
+ config: json({}),
46
+ /** Fractional index for ordering among a schema's extension fields */
47
+ sortKey: text({ required: true }),
48
+ /** Default column width in pixels (table views) */
49
+ width: number({ min: 40, integer: true }),
50
+ /** Optional owning Space — mirrors the parent extension's cascade */
51
+ space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" })
52
+ },
53
+ authorization: spaceCascadeAuthorization()
54
+ });
55
+ function schemaExtensionId(authority, targetSchema) {
56
+ return `schemaext:${authority}:${targetSchema}`;
57
+ }
58
+
59
+ export {
60
+ SCHEMA_EXTENSION_SCHEMA_IRI,
61
+ EXTENSION_FIELD_SCHEMA_IRI,
62
+ SchemaExtensionSchema,
63
+ ExtensionFieldSchema,
64
+ schemaExtensionId
65
+ };
@@ -0,0 +1,75 @@
1
+ // src/updates.ts
2
+ import { sign, verify, hashHex } from "@xnetjs/crypto";
3
+ import * as Y from "yjs";
4
+ function signUpdate(options) {
5
+ const { update, authorDID, signingKey, parentHash, vectorClock } = options;
6
+ const updateHash = hashHex(update);
7
+ const timestamp = Date.now();
8
+ const signaturePayload = new TextEncoder().encode(
9
+ JSON.stringify({ updateHash, parentHash, authorDID, timestamp })
10
+ );
11
+ const signature = sign(signaturePayload, signingKey);
12
+ return {
13
+ update,
14
+ parentHash,
15
+ updateHash,
16
+ authorDID,
17
+ signature,
18
+ timestamp,
19
+ vectorClock
20
+ };
21
+ }
22
+ function verifyUpdate(update, getPublicKey) {
23
+ const publicKey = getPublicKey(update.authorDID);
24
+ if (!publicKey) return false;
25
+ const actualHash = hashHex(update.update);
26
+ if (actualHash !== update.updateHash) return false;
27
+ const signaturePayload = new TextEncoder().encode(
28
+ JSON.stringify({
29
+ updateHash: update.updateHash,
30
+ parentHash: update.parentHash,
31
+ authorDID: update.authorDID,
32
+ timestamp: update.timestamp
33
+ })
34
+ );
35
+ return verify(signaturePayload, update.signature, publicKey);
36
+ }
37
+ function applySignedUpdate(doc, update) {
38
+ Y.applyUpdate(doc, update.update);
39
+ }
40
+ function captureUpdate(doc, authorDID, signingKey, parentHash, vectorClock, callback) {
41
+ let capturedUpdate = null;
42
+ const handler = (update) => {
43
+ capturedUpdate = update;
44
+ };
45
+ doc.on("update", handler);
46
+ callback();
47
+ doc.off("update", handler);
48
+ if (!capturedUpdate) return null;
49
+ return signUpdate({
50
+ doc,
51
+ update: capturedUpdate,
52
+ authorDID,
53
+ signingKey,
54
+ parentHash,
55
+ vectorClock
56
+ });
57
+ }
58
+ function mergeDocuments(target, sources) {
59
+ for (const source of sources) {
60
+ const state = Y.encodeStateAsUpdate(source);
61
+ Y.applyUpdate(target, state);
62
+ }
63
+ }
64
+ function getMissingUpdates(doc, remoteStateVector) {
65
+ return Y.encodeStateAsUpdate(doc, remoteStateVector);
66
+ }
67
+
68
+ export {
69
+ signUpdate,
70
+ verifyUpdate,
71
+ applySignedUpdate,
72
+ captureUpdate,
73
+ mergeDocuments,
74
+ getMissingUpdates
75
+ };
@@ -0,0 +1,66 @@
1
+ import {
2
+ spaceCascadeAuthorization
3
+ } from "./chunk-OCMSAKWV.js";
4
+ import {
5
+ checkbox,
6
+ defineSchema,
7
+ relation,
8
+ select,
9
+ text
10
+ } from "./chunk-EBNMV2VO.js";
11
+
12
+ // src/schema/schemas/account.ts
13
+ var ACCOUNT_SCHEMA_IRI = "xnet://xnet.fyi/Account@1.0.0";
14
+ var AccountSchema = defineSchema({
15
+ name: "Account",
16
+ namespace: "xnet://xnet.fyi/",
17
+ properties: {
18
+ /** Display name, e.g. "Checking" or "Groceries". */
19
+ name: text({ required: true, maxLength: 200 }),
20
+ /** The double-entry class — drives debit/credit sign and reporting bucket. */
21
+ class: select({
22
+ options: [
23
+ { id: "asset", name: "Asset", color: "green" },
24
+ { id: "liability", name: "Liability", color: "red" },
25
+ { id: "equity", name: "Equity", color: "purple" },
26
+ { id: "income", name: "Income", color: "blue" },
27
+ { id: "expense", name: "Expense", color: "orange" }
28
+ ],
29
+ default: "expense"
30
+ }),
31
+ /** Hierarchical code for ordering / roll-up, e.g. "1000", "1010". */
32
+ code: text({ maxLength: 40 }),
33
+ /** ISO-4217 reporting currency for this account (app default: USD). */
34
+ currency: text({ maxLength: 3 }),
35
+ /** Roll-up group header (no postings of its own) vs a postable leaf. */
36
+ isGroup: checkbox({ default: false }),
37
+ /** Chart-of-accounts tree parent. */
38
+ parent: relation({ target: ACCOUNT_SCHEMA_IRI }),
39
+ /** Order among siblings — fractional index (exploration 0169 pattern). */
40
+ sortKey: text({ maxLength: 500 }),
41
+ /** Optional folder home for uniform filing; empty = Unfiled (0190). */
42
+ folder: relation({ target: "xnet://xnet.fyi/Folder@1.0.0" }),
43
+ /** Canonical SECURITY home; empty = personal/private book (0179/0181). */
44
+ space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" }),
45
+ /**
46
+ * Per-node visibility. Defaults to `private` — financial data is the most
47
+ * sensitive in the app and must never leak to public surfaces (0187).
48
+ */
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
+ // Inherits access from its home Space (exploration 0181).
60
+ authorization: spaceCascadeAuthorization()
61
+ });
62
+
63
+ export {
64
+ ACCOUNT_SCHEMA_IRI,
65
+ AccountSchema
66
+ };
@@ -0,0 +1,64 @@
1
+ import {
2
+ spaceCascadeAuthorization
3
+ } from "./chunk-OCMSAKWV.js";
4
+ import {
5
+ date,
6
+ defineSchema,
7
+ person,
8
+ relation,
9
+ select,
10
+ text
11
+ } from "./chunk-EBNMV2VO.js";
12
+
13
+ // src/schema/schemas/project.ts
14
+ var ProjectSchema = defineSchema({
15
+ name: "Project",
16
+ namespace: "xnet://xnet.fyi/",
17
+ properties: {
18
+ /** Project name */
19
+ name: text({ required: true, maxLength: 200 }),
20
+ /** Emoji or icon URL */
21
+ icon: text({ maxLength: 500 }),
22
+ /** Project lifecycle status */
23
+ status: select({
24
+ options: [
25
+ { id: "planned", name: "Planned", color: "gray" },
26
+ { id: "in-progress", name: "In Progress", color: "blue" },
27
+ { id: "paused", name: "Paused", color: "yellow" },
28
+ { id: "completed", name: "Completed", color: "green" },
29
+ { id: "cancelled", name: "Cancelled", color: "red" }
30
+ ],
31
+ default: "planned"
32
+ }),
33
+ /** Project lead */
34
+ lead: person({}),
35
+ /** Target completion date */
36
+ targetDate: date({}),
37
+ /** Canonical home; empty = Unfiled (exploration 0169) */
38
+ folder: relation({ target: "xnet://xnet.fyi/Folder@1.0.0" }),
39
+ /** Order among folder siblings — fractional index */
40
+ sortKey: text({ maxLength: 500 }),
41
+ /** Workspace-wide labels, referenced by id (exploration 0169) */
42
+ tags: relation({ target: "xnet://xnet.fyi/Tag@1.0.0", multiple: true }),
43
+ /** Canonical SECURITY home; empty = personal/private (exploration 0179) */
44
+ space: relation({ target: "xnet://xnet.fyi/Space@1.0.0" }),
45
+ /** Per-node visibility; `inherit` defers to the Space (exploration 0179) */
46
+ visibility: select({
47
+ options: [
48
+ { id: "inherit", name: "Inherit", color: "gray" },
49
+ { id: "private", name: "Private", color: "gray" },
50
+ { id: "unlisted", name: "Unlisted", color: "yellow" },
51
+ { id: "public", name: "Public", color: "green" }
52
+ ],
53
+ default: "inherit"
54
+ })
55
+ },
56
+ document: "yjs",
57
+ // Collaborative project brief
58
+ // Inherits access from its home Space (exploration 0181).
59
+ authorization: spaceCascadeAuthorization()
60
+ });
61
+
62
+ export {
63
+ ProjectSchema
64
+ };
@@ -0,0 +1,45 @@
1
+ import {
2
+ spaceCascadeAuthorization
3
+ } from "./chunk-OCMSAKWV.js";
4
+ import {
5
+ created,
6
+ createdBy,
7
+ defineSchema,
8
+ person,
9
+ relation,
10
+ select,
11
+ text
12
+ } from "./chunk-EBNMV2VO.js";
13
+
14
+ // src/schema/schemas/reaction.ts
15
+ var reactionTypes = [
16
+ { id: "like", name: "Like", color: "green" },
17
+ { id: "repost", name: "Repost", color: "blue" },
18
+ { id: "bookmark", name: "Bookmark", color: "purple" },
19
+ { id: "emoji", name: "Emoji", color: "yellow" }
20
+ ];
21
+ var ReactionSchema = defineSchema({
22
+ name: "Reaction",
23
+ namespace: "xnet://xnet.fyi/",
24
+ properties: {
25
+ target: relation({ required: true }),
26
+ targetSchema: text({}),
27
+ reactionType: select({
28
+ options: reactionTypes,
29
+ required: true,
30
+ default: "like"
31
+ }),
32
+ reactor: person({ required: true }),
33
+ emoji: text({ maxLength: 32 }),
34
+ annotation: text({ maxLength: 1e3 }),
35
+ createdAt: created(),
36
+ createdBy: createdBy()
37
+ },
38
+ document: void 0,
39
+ // Inherits access from its home Space (exploration 0181/0192).
40
+ authorization: spaceCascadeAuthorization("target")
41
+ });
42
+
43
+ export {
44
+ ReactionSchema
45
+ };
@@ -0,0 +1,43 @@
1
+ import {
2
+ created,
3
+ createdBy,
4
+ defineSchema,
5
+ json,
6
+ person
7
+ } from "./chunk-EBNMV2VO.js";
8
+ import {
9
+ presets
10
+ } from "./chunk-RL64OJJ5.js";
11
+
12
+ // src/schema/schemas/inbox-state.ts
13
+ var DEFAULT_CHANNEL_TIER = "mentions";
14
+ var InboxStateSchema = defineSchema({
15
+ name: "InboxState",
16
+ namespace: "xnet://xnet.fyi/",
17
+ properties: {
18
+ /** The user this state belongs to (must match createdBy) */
19
+ owner: person({ required: true }),
20
+ /** channelId → last-read watermark */
21
+ watermarks: json({}),
22
+ /** Source node IDs of explicitly acknowledged mentions */
23
+ ackedMentions: json({}),
24
+ /** Source node ID → triage state (sparse; absence = unread/read derived) */
25
+ items: json({}),
26
+ /** Notification preferences */
27
+ prefs: json({}),
28
+ createdAt: created(),
29
+ createdBy: createdBy()
30
+ },
31
+ document: void 0,
32
+ // Standalone/personal content: owner-only by default (exploration 0192).
33
+ authorization: presets.private()
34
+ });
35
+ function inboxStateNodeId(did) {
36
+ return `inbox-${did}`;
37
+ }
38
+
39
+ export {
40
+ DEFAULT_CHANNEL_TIER,
41
+ InboxStateSchema,
42
+ inboxStateNodeId
43
+ };