@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,8 @@
1
+ import {
2
+ GrantSchema
3
+ } from "./chunk-OSAWNZVM.js";
4
+ import "./chunk-EBNMV2VO.js";
5
+ import "./chunk-RL64OJJ5.js";
6
+ export {
7
+ GrantSchema
8
+ };
@@ -0,0 +1,249 @@
1
+ import { SerializedAuthorization, SerializedRoleResolver, PolicyEvaluator, DID, AuthDecision, RoleResolver, AuthDenyReason, AuthCheckInput, AuthTrace, AuthExpression } from '@xnetjs/core';
2
+ import { a as Schema, h as NodeState, v as NodeChangeEvent, w as GrantIndex, O as OfflineAuthPolicy, D as DefinedSchema } from './types-S-BJAKyK.js';
3
+ import { S as SchemaRegistry } from './registry-DunPv__d.js';
4
+
5
+ /**
6
+ * Permission-matrix reflection.
7
+ *
8
+ * Turns a schema's `authorization` definition into a role × action matrix for
9
+ * display — the data behind a "who can do what" panel (e.g. a Permissions tab
10
+ * in the share dialog). This is a *structural summary* of the policy, not an
11
+ * evaluator: it reports which roles each action references and whether the
12
+ * action is public / authenticated. Actual per-subject decisions still come
13
+ * from the policy evaluator; per-member resolution (who holds each role) is a
14
+ * separate, store-backed step (see `computeRecipients`).
15
+ */
16
+
17
+ /** How an action's expression resolves, summarized for display. */
18
+ interface ActionPermission {
19
+ action: string;
20
+ /** Roles that grant this action (allow / bare role refs, negation-aware). */
21
+ roles: string[];
22
+ /** Roles explicitly denied (deny takes precedence at evaluation time). */
23
+ denied: string[];
24
+ /** Anyone, including anonymous, is allowed. */
25
+ public: boolean;
26
+ /** Any authenticated user is allowed. */
27
+ authenticated: boolean;
28
+ }
29
+ /** A role and a human-readable description of how a subject comes to hold it. */
30
+ interface RoleSummary {
31
+ role: string;
32
+ /** Resolver kind: creator | property | relation | membership */
33
+ kind: SerializedRoleResolver['_tag'];
34
+ /** Human-readable provenance (e.g. "Inherited from space", "Node creator"). */
35
+ provenance: string;
36
+ }
37
+ interface PermissionMatrix {
38
+ /** All roles declared on the schema, with provenance. */
39
+ roles: RoleSummary[];
40
+ /** One entry per action the schema defines (in canonical order). */
41
+ actions: ActionPermission[];
42
+ }
43
+ /** Human-readable description of how a subject comes to hold a role. */
44
+ declare function describeRoleResolver(resolver: SerializedRoleResolver): string;
45
+ /**
46
+ * Build the role × action matrix for a schema's authorization. Returns an
47
+ * empty matrix (no roles, every action public) when the schema has no
48
+ * authorization — an unauthorized schema is open by construction.
49
+ */
50
+ declare function buildPermissionMatrix(authorization: SerializedAuthorization | undefined): PermissionMatrix;
51
+
52
+ /**
53
+ * Derive the hub's grant-action expectations from a schema's authorization
54
+ * block (exploration 0192).
55
+ *
56
+ * The hub enforces access with a grant model whose vocabulary is
57
+ * `read | comment | write | share | admin` (see `spaceRoleGrantActions`). The
58
+ * schema authorization DSL speaks `read | write | delete | share`. These two
59
+ * have historically been maintained by hand in separate places and were free
60
+ * to drift. `schemaToHubPolicy` projects a schema's declared per-action role
61
+ * sets onto the hub vocabulary so the relationship can be asserted in CI
62
+ * (`hub-policy.test.ts`) — the schema authorization block becomes the single
63
+ * declarative source the hub mapping is checked against.
64
+ *
65
+ * Correspondence:
66
+ * read → read write → write share → share delete → admin
67
+ *
68
+ * `comment` is a hub-only refinement of `read` (a commenter may annotate but
69
+ * not edit). The Space cascade folds commenters into `read` and does not model
70
+ * a distinct `comment` action, so it is intentionally absent here.
71
+ */
72
+
73
+ interface HubPolicy {
74
+ /** For each role declared by the schema, the hub grant actions it implies. */
75
+ roleActions: Record<string, string[]>;
76
+ /** True when the schema's `read` action grants PUBLIC. */
77
+ public: boolean;
78
+ }
79
+ /** Project a schema's authorization block onto the hub grant-action model. */
80
+ declare function schemaToHubPolicy(schema: Schema): HubPolicy;
81
+ /**
82
+ * Hub grant actions a Space *member* with the given Space role inherits on a
83
+ * node governed by the Space cascade, derived purely from the schema. A member
84
+ * with role `R` resolves to the cascade role `spaceR` (e.g. `viewer` →
85
+ * `spaceViewer`), so this looks up that role's projected hub actions.
86
+ *
87
+ * Used by the parity test to prove the cascade and `spaceRoleGrantActions`
88
+ * agree, so neither can change without the other.
89
+ */
90
+ declare function hubActionsForSpaceRole(schema: Schema, spaceRole: string): string[];
91
+
92
+ interface NodeStoreReader {
93
+ get(id: string): Promise<NodeState | null>;
94
+ list(options?: {
95
+ schemaId?: string;
96
+ includeDeleted?: boolean;
97
+ }): Promise<NodeState[]>;
98
+ subscribe(listener: (event: NodeChangeEvent) => void): () => void;
99
+ }
100
+ interface DecisionCacheOptions {
101
+ ttlMs?: number;
102
+ maxSize?: number;
103
+ now?: () => number;
104
+ }
105
+ declare class DecisionCache {
106
+ private cache;
107
+ private ttlMs;
108
+ private readonly maxSize;
109
+ private readonly now;
110
+ constructor(options?: DecisionCacheOptions);
111
+ get(subject: DID, action: string, nodeId: string): AuthDecision | null;
112
+ set(subject: DID, action: string, nodeId: string, decision: AuthDecision): void;
113
+ invalidateNode(nodeId: string): void;
114
+ invalidateSubject(did: DID): void;
115
+ clear(): void;
116
+ setTTL(ttlMs: number): void;
117
+ private key;
118
+ }
119
+ interface DefaultRoleResolverOptions {
120
+ maxDepth?: number;
121
+ maxNodes?: number;
122
+ }
123
+ declare class DefaultRoleResolver {
124
+ private readonly store;
125
+ private readonly schemaRegistry;
126
+ private readonly maxDepth;
127
+ private readonly maxNodes;
128
+ constructor(store: NodeStoreReader, schemaRegistry: SchemaRegistry, options?: DefaultRoleResolverOptions);
129
+ resolveRoles(did: DID, node: NodeState, schema: Schema): Promise<Set<string>>;
130
+ resolveRoleMembers(resolver: RoleResolver, node: NodeState): Promise<DID[]>;
131
+ private resolveRoleMembersInner;
132
+ private checkRole;
133
+ private membershipMatchesContainer;
134
+ /**
135
+ * The node's own id plus the ids of every ancestor reachable by walking
136
+ * `parentProp`. Cycle- and depth-bounded. When `parentProp` is undefined the
137
+ * set is just the node itself (no inheritance).
138
+ */
139
+ private collectContainerIds;
140
+ private loadRelatedNodes;
141
+ }
142
+ declare function evaluateExpression(expr: AuthExpression, roles: Set<string>, isAuthenticated: boolean): boolean;
143
+ interface DefaultPolicyEvaluatorOptions {
144
+ store: NodeStoreReader;
145
+ schemaRegistry: SchemaRegistry;
146
+ grantIndex?: GrantIndex;
147
+ cache?: DecisionCache;
148
+ roleResolver?: DefaultRoleResolver;
149
+ maxDepth?: number;
150
+ maxNodes?: number;
151
+ now?: () => number;
152
+ offlinePolicy?: Partial<OfflineAuthPolicy>;
153
+ getLastSyncedAt?: () => number;
154
+ isOnline?: () => boolean;
155
+ onRevalidation?: (event: RevalidationEvent) => void;
156
+ onDecision?: (event: AuthDecisionEvent) => void;
157
+ }
158
+ interface RevalidationEvent {
159
+ type: 'hybrid-revalidation';
160
+ at: number;
161
+ invalidated: 'all';
162
+ }
163
+ interface AuthDecisionEvent {
164
+ type: 'auth:decision';
165
+ timestamp: number;
166
+ subject: DID;
167
+ action: AuthDecision['action'];
168
+ resource: string;
169
+ allowed: boolean;
170
+ cached: boolean;
171
+ roles: string[];
172
+ reasons: AuthDenyReason[];
173
+ duration: number;
174
+ }
175
+ declare class DefaultPolicyEvaluator implements PolicyEvaluator {
176
+ private readonly options;
177
+ private readonly grantIndex?;
178
+ private readonly cache;
179
+ private readonly roleResolver;
180
+ private readonly now;
181
+ private offlinePolicy;
182
+ private readonly getLastSyncedAt?;
183
+ private readonly isOnline;
184
+ private readonly onRevalidation?;
185
+ private readonly onDecision?;
186
+ private lastConnectivityOnline;
187
+ constructor(options: DefaultPolicyEvaluatorOptions);
188
+ can(input: AuthCheckInput): Promise<AuthDecision>;
189
+ explain(input: AuthCheckInput): Promise<AuthTrace>;
190
+ invalidate(nodeId: string): void;
191
+ invalidateSubject(did: DID): void;
192
+ getOfflinePolicy(): OfflineAuthPolicy;
193
+ setOfflinePolicy(patch: Partial<OfflineAuthPolicy>): void;
194
+ handleConnectivityChange(isOnline: boolean): void;
195
+ private findMatchingGrant;
196
+ private checkFieldRules;
197
+ private decision;
198
+ private deny;
199
+ private loadNodeFromInput;
200
+ private isAuthStateStale;
201
+ private emitDecision;
202
+ }
203
+ declare function createPolicyEvaluator(options: {
204
+ store: NodeStoreReader;
205
+ schemaRegistry: SchemaRegistry;
206
+ grantSchemaId?: string;
207
+ cache?: DecisionCache;
208
+ maxDepth?: number;
209
+ maxNodes?: number;
210
+ }): Promise<DefaultPolicyEvaluator>;
211
+ type SchemaRegistryReader = Pick<SchemaRegistry, 'get'>;
212
+ type DefinedSchemaLike = DefinedSchema;
213
+
214
+ interface GrantExpirationStore {
215
+ list(options?: {
216
+ schemaId?: string;
217
+ includeDeleted?: boolean;
218
+ }): Promise<Array<{
219
+ id: string;
220
+ properties: Record<string, unknown>;
221
+ }>>;
222
+ update(nodeId: string, options: {
223
+ properties: Record<string, unknown>;
224
+ }): Promise<unknown>;
225
+ }
226
+ interface GrantExpirationCleanerOptions {
227
+ clock?: () => number;
228
+ cleanupIntervalMs?: number;
229
+ clockSkewToleranceMs?: number;
230
+ systemRevoker?: string;
231
+ }
232
+ declare class GrantExpirationCleaner {
233
+ private readonly store;
234
+ static readonly DEFAULT_CLOCK_SKEW_TOLERANCE_MS = 60000;
235
+ static readonly DEFAULT_CLEANUP_INTERVAL_MS: number;
236
+ private readonly clock;
237
+ private readonly cleanupIntervalMs;
238
+ private readonly clockSkewToleranceMs;
239
+ private readonly systemRevoker;
240
+ private timer;
241
+ constructor(store: GrantExpirationStore, options?: GrantExpirationCleanerOptions);
242
+ start(): void;
243
+ stop(): void;
244
+ cleanup(): Promise<{
245
+ pruned: number;
246
+ }>;
247
+ }
248
+
249
+ export { type ActionPermission as A, DefaultPolicyEvaluator as D, GrantExpirationCleaner as G, type HubPolicy as H, type NodeStoreReader as N, type PermissionMatrix as P, type RoleSummary as R, type SchemaRegistryReader as S, DefaultRoleResolver as a, DecisionCache as b, buildPermissionMatrix as c, describeRoleResolver as d, evaluateExpression as e, createPolicyEvaluator as f, type DecisionCacheOptions as g, hubActionsForSpaceRole as h, type DefaultRoleResolverOptions as i, type DefaultPolicyEvaluatorOptions as j, type DefinedSchemaLike as k, type RevalidationEvent as l, type AuthDecisionEvent as m, type GrantExpirationStore as n, type GrantExpirationCleanerOptions as o, schemaToHubPolicy as s };
@@ -0,0 +1,12 @@
1
+ import {
2
+ IMPORT_BATCH_SCHEMA_IRI,
3
+ ImportBatchSchema
4
+ } from "./chunk-VQ7JHB67.js";
5
+ import "./chunk-OCMSAKWV.js";
6
+ import "./chunk-T5AZAOG5.js";
7
+ import "./chunk-EBNMV2VO.js";
8
+ import "./chunk-RL64OJJ5.js";
9
+ export {
10
+ IMPORT_BATCH_SCHEMA_IRI,
11
+ ImportBatchSchema
12
+ };
@@ -0,0 +1,12 @@
1
+ import {
2
+ DEFAULT_CHANNEL_TIER,
3
+ InboxStateSchema,
4
+ inboxStateNodeId
5
+ } from "./chunk-YEFKQYKA.js";
6
+ import "./chunk-EBNMV2VO.js";
7
+ import "./chunk-RL64OJJ5.js";
8
+ export {
9
+ DEFAULT_CHANNEL_TIER,
10
+ InboxStateSchema,
11
+ inboxStateNodeId
12
+ };