@eloxiv/client 0.0.0-stage → 0.1.1

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 (269) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +6 -2
  3. package/dist/Account.d.ts +131 -0
  4. package/dist/Account.d.ts.map +1 -0
  5. package/dist/Account.js +169 -0
  6. package/dist/Account.js.map +1 -0
  7. package/dist/Agent.d.ts +496 -0
  8. package/dist/Agent.d.ts.map +1 -0
  9. package/dist/Agent.js +228 -0
  10. package/dist/Agent.js.map +1 -0
  11. package/dist/AgentSync.d.ts +990 -0
  12. package/dist/AgentSync.d.ts.map +1 -0
  13. package/dist/AgentSync.js +46 -0
  14. package/dist/AgentSync.js.map +1 -0
  15. package/dist/AppState.d.ts +127 -0
  16. package/dist/AppState.d.ts.map +1 -0
  17. package/dist/AppState.js +145 -0
  18. package/dist/AppState.js.map +1 -0
  19. package/dist/AppStateSync.d.ts +193 -0
  20. package/dist/AppStateSync.d.ts.map +1 -0
  21. package/dist/AppStateSync.js +23 -0
  22. package/dist/AppStateSync.js.map +1 -0
  23. package/dist/Auth.d.ts +95 -0
  24. package/dist/Auth.d.ts.map +1 -0
  25. package/dist/Auth.js +139 -0
  26. package/dist/Auth.js.map +1 -0
  27. package/dist/Avatars.d.ts +53 -0
  28. package/dist/Avatars.d.ts.map +1 -0
  29. package/dist/Avatars.js +121 -0
  30. package/dist/Avatars.js.map +1 -0
  31. package/dist/BrowserAnalytics.d.ts +56 -0
  32. package/dist/BrowserAnalytics.d.ts.map +1 -0
  33. package/dist/BrowserAnalytics.js +94 -0
  34. package/dist/BrowserAnalytics.js.map +1 -0
  35. package/dist/Chat.d.ts +712 -0
  36. package/dist/Chat.d.ts.map +1 -0
  37. package/dist/Chat.js +883 -0
  38. package/dist/Chat.js.map +1 -0
  39. package/dist/ChatIntegrity.d.ts +63 -0
  40. package/dist/ChatIntegrity.d.ts.map +1 -0
  41. package/dist/ChatIntegrity.js +89 -0
  42. package/dist/ChatIntegrity.js.map +1 -0
  43. package/dist/ChatSends.d.ts +103 -0
  44. package/dist/ChatSends.d.ts.map +1 -0
  45. package/dist/ChatSends.js +157 -0
  46. package/dist/ChatSends.js.map +1 -0
  47. package/dist/Client.d.ts +113 -0
  48. package/dist/Client.d.ts.map +1 -0
  49. package/dist/Client.js +189 -0
  50. package/dist/Client.js.map +1 -0
  51. package/dist/Collab.d.ts +138 -0
  52. package/dist/Collab.d.ts.map +1 -0
  53. package/dist/Collab.js +454 -0
  54. package/dist/Collab.js.map +1 -0
  55. package/dist/CollabTools.d.ts +129 -0
  56. package/dist/CollabTools.d.ts.map +1 -0
  57. package/dist/CollabTools.js +277 -0
  58. package/dist/CollabTools.js.map +1 -0
  59. package/dist/Connections.d.ts +288 -0
  60. package/dist/Connections.d.ts.map +1 -0
  61. package/dist/Connections.js +316 -0
  62. package/dist/Connections.js.map +1 -0
  63. package/dist/Consent.d.ts +338 -0
  64. package/dist/Consent.d.ts.map +1 -0
  65. package/dist/Consent.js +142 -0
  66. package/dist/Consent.js.map +1 -0
  67. package/dist/Desktop.d.ts +61 -0
  68. package/dist/Desktop.d.ts.map +1 -0
  69. package/dist/Desktop.js +101 -0
  70. package/dist/Desktop.js.map +1 -0
  71. package/dist/Directory.d.ts +36 -0
  72. package/dist/Directory.d.ts.map +1 -0
  73. package/dist/Directory.js +42 -0
  74. package/dist/Directory.js.map +1 -0
  75. package/dist/ErrorReporter.d.ts +48 -0
  76. package/dist/ErrorReporter.d.ts.map +1 -0
  77. package/dist/ErrorReporter.js +70 -0
  78. package/dist/ErrorReporter.js.map +1 -0
  79. package/dist/ExpoSqlite.d.ts +7 -0
  80. package/dist/ExpoSqlite.d.ts.map +1 -0
  81. package/dist/ExpoSqlite.js +7 -0
  82. package/dist/ExpoSqlite.js.map +1 -0
  83. package/dist/FileSync.d.ts +265 -0
  84. package/dist/FileSync.d.ts.map +1 -0
  85. package/dist/FileSync.js +29 -0
  86. package/dist/FileSync.js.map +1 -0
  87. package/dist/FileTables.gen.d.ts +109 -0
  88. package/dist/FileTables.gen.d.ts.map +1 -0
  89. package/dist/FileTables.gen.js +23 -0
  90. package/dist/FileTables.gen.js.map +1 -0
  91. package/dist/Foldkit.d.ts +487 -0
  92. package/dist/Foldkit.d.ts.map +1 -0
  93. package/dist/Foldkit.js +617 -0
  94. package/dist/Foldkit.js.map +1 -0
  95. package/dist/History.d.ts +133 -0
  96. package/dist/History.d.ts.map +1 -0
  97. package/dist/History.js +210 -0
  98. package/dist/History.js.map +1 -0
  99. package/dist/InboxSync.d.ts +428 -0
  100. package/dist/InboxSync.d.ts.map +1 -0
  101. package/dist/InboxSync.js +37 -0
  102. package/dist/InboxSync.js.map +1 -0
  103. package/dist/KernelTables.gen.d.ts +1522 -0
  104. package/dist/KernelTables.gen.d.ts.map +1 -0
  105. package/dist/KernelTables.gen.js +307 -0
  106. package/dist/KernelTables.gen.js.map +1 -0
  107. package/dist/Make.d.ts +75 -0
  108. package/dist/Make.d.ts.map +1 -0
  109. package/dist/Make.js +70 -0
  110. package/dist/Make.js.map +1 -0
  111. package/dist/Models.d.ts +88 -0
  112. package/dist/Models.d.ts.map +1 -0
  113. package/dist/Models.js +80 -0
  114. package/dist/Models.js.map +1 -0
  115. package/dist/Optimistic.d.ts +120 -0
  116. package/dist/Optimistic.d.ts.map +1 -0
  117. package/dist/Optimistic.js +231 -0
  118. package/dist/Optimistic.js.map +1 -0
  119. package/dist/PlatformSync.d.ts +273 -0
  120. package/dist/PlatformSync.d.ts.map +1 -0
  121. package/dist/PlatformSync.js +92 -0
  122. package/dist/PlatformSync.js.map +1 -0
  123. package/dist/Poll.d.ts +113 -0
  124. package/dist/Poll.d.ts.map +1 -0
  125. package/dist/Poll.js +179 -0
  126. package/dist/Poll.js.map +1 -0
  127. package/dist/Preferences.d.ts +18 -0
  128. package/dist/Preferences.d.ts.map +1 -0
  129. package/dist/Preferences.js +22 -0
  130. package/dist/Preferences.js.map +1 -0
  131. package/dist/Proposals.d.ts +29 -0
  132. package/dist/Proposals.d.ts.map +1 -0
  133. package/dist/Proposals.js +41 -0
  134. package/dist/Proposals.js.map +1 -0
  135. package/dist/React.d.ts +17 -0
  136. package/dist/React.d.ts.map +1 -0
  137. package/dist/React.js +17 -0
  138. package/dist/React.js.map +1 -0
  139. package/dist/Reader.d.ts +35 -0
  140. package/dist/Reader.d.ts.map +1 -0
  141. package/dist/Reader.js +136 -0
  142. package/dist/Reader.js.map +1 -0
  143. package/dist/Resources.d.ts +98 -0
  144. package/dist/Resources.d.ts.map +1 -0
  145. package/dist/Resources.js +161 -0
  146. package/dist/Resources.js.map +1 -0
  147. package/dist/Rows.d.ts +4 -0
  148. package/dist/Rows.d.ts.map +1 -0
  149. package/dist/Rows.js +16 -0
  150. package/dist/Rows.js.map +1 -0
  151. package/dist/Runtime.d.ts +254 -0
  152. package/dist/Runtime.d.ts.map +1 -0
  153. package/dist/Runtime.js +1283 -0
  154. package/dist/Runtime.js.map +1 -0
  155. package/dist/RuntimeRuns.d.ts +74 -0
  156. package/dist/RuntimeRuns.d.ts.map +1 -0
  157. package/dist/RuntimeRuns.js +118 -0
  158. package/dist/RuntimeRuns.js.map +1 -0
  159. package/dist/ServicesSync.d.ts +286 -0
  160. package/dist/ServicesSync.d.ts.map +1 -0
  161. package/dist/ServicesSync.js +40 -0
  162. package/dist/ServicesSync.js.map +1 -0
  163. package/dist/Session.d.ts +228 -0
  164. package/dist/Session.d.ts.map +1 -0
  165. package/dist/Session.js +792 -0
  166. package/dist/Session.js.map +1 -0
  167. package/dist/ShareGrant.d.ts +47 -0
  168. package/dist/ShareGrant.d.ts.map +1 -0
  169. package/dist/ShareGrant.js +20 -0
  170. package/dist/ShareGrant.js.map +1 -0
  171. package/dist/Sharing.d.ts +203 -0
  172. package/dist/Sharing.d.ts.map +1 -0
  173. package/dist/Sharing.js +520 -0
  174. package/dist/Sharing.js.map +1 -0
  175. package/dist/Skew.d.ts +52 -0
  176. package/dist/Skew.d.ts.map +1 -0
  177. package/dist/Skew.js +77 -0
  178. package/dist/Skew.js.map +1 -0
  179. package/dist/SpacesSync.d.ts +247 -0
  180. package/dist/SpacesSync.d.ts.map +1 -0
  181. package/dist/SpacesSync.js +30 -0
  182. package/dist/SpacesSync.js.map +1 -0
  183. package/dist/Storage.d.ts +51 -0
  184. package/dist/Storage.d.ts.map +1 -0
  185. package/dist/Storage.js +107 -0
  186. package/dist/Storage.js.map +1 -0
  187. package/dist/Sync.d.ts +48 -0
  188. package/dist/Sync.d.ts.map +1 -0
  189. package/dist/Sync.js +48 -0
  190. package/dist/Sync.js.map +1 -0
  191. package/dist/SyncTables.d.ts +13 -0
  192. package/dist/SyncTables.d.ts.map +1 -0
  193. package/dist/SyncTables.js +13 -0
  194. package/dist/SyncTables.js.map +1 -0
  195. package/dist/Tab.d.ts +36 -0
  196. package/dist/Tab.d.ts.map +1 -0
  197. package/dist/Tab.js +44 -0
  198. package/dist/Tab.js.map +1 -0
  199. package/dist/Transport.d.ts +139 -0
  200. package/dist/Transport.d.ts.map +1 -0
  201. package/dist/Transport.js +232 -0
  202. package/dist/Transport.js.map +1 -0
  203. package/dist/Upload.d.ts +41 -0
  204. package/dist/Upload.d.ts.map +1 -0
  205. package/dist/Upload.js +93 -0
  206. package/dist/Upload.js.map +1 -0
  207. package/dist/WebMcp.d.ts +78 -0
  208. package/dist/WebMcp.d.ts.map +1 -0
  209. package/dist/WebMcp.js +204 -0
  210. package/dist/WebMcp.js.map +1 -0
  211. package/dist/index.d.ts +27 -0
  212. package/dist/index.d.ts.map +1 -0
  213. package/dist/index.js +27 -0
  214. package/dist/index.js.map +1 -0
  215. package/package.json +97 -3
  216. package/src/Account.ts +249 -0
  217. package/src/Agent.ts +387 -0
  218. package/src/AgentSync.ts +59 -0
  219. package/src/AppState.ts +222 -0
  220. package/src/AppStateSync.ts +26 -0
  221. package/src/Auth.ts +225 -0
  222. package/src/Avatars.ts +144 -0
  223. package/src/BrowserAnalytics.ts +133 -0
  224. package/src/Chat.ts +1150 -0
  225. package/src/ChatIntegrity.ts +130 -0
  226. package/src/ChatSends.ts +209 -0
  227. package/src/Client.ts +319 -0
  228. package/src/Collab.ts +524 -0
  229. package/src/CollabTools.ts +381 -0
  230. package/src/Connections.ts +517 -0
  231. package/src/Consent.ts +176 -0
  232. package/src/Desktop.ts +139 -0
  233. package/src/Directory.ts +71 -0
  234. package/src/ErrorReporter.ts +112 -0
  235. package/src/ExpoSqlite.ts +6 -0
  236. package/src/FileSync.ts +34 -0
  237. package/src/FileTables.gen.ts +23 -0
  238. package/src/Foldkit.ts +960 -0
  239. package/src/History.ts +337 -0
  240. package/src/InboxSync.ts +47 -0
  241. package/src/KernelTables.gen.ts +329 -0
  242. package/src/Make.ts +120 -0
  243. package/src/Models.ts +134 -0
  244. package/src/Optimistic.ts +364 -0
  245. package/src/PlatformSync.ts +156 -0
  246. package/src/Poll.ts +227 -0
  247. package/src/Preferences.ts +42 -0
  248. package/src/Proposals.ts +57 -0
  249. package/src/React.ts +26 -0
  250. package/src/Reader.ts +180 -0
  251. package/src/Resources.ts +257 -0
  252. package/src/Rows.ts +16 -0
  253. package/src/Runtime.ts +1442 -0
  254. package/src/RuntimeRuns.ts +180 -0
  255. package/src/ServicesSync.ts +58 -0
  256. package/src/Session.ts +844 -0
  257. package/src/ShareGrant.ts +20 -0
  258. package/src/Sharing.ts +696 -0
  259. package/src/Skew.ts +97 -0
  260. package/src/SpacesSync.ts +61 -0
  261. package/src/Storage.ts +167 -0
  262. package/src/Sync.ts +125 -0
  263. package/src/SyncTables.ts +12 -0
  264. package/src/Tab.ts +59 -0
  265. package/src/Transport.ts +321 -0
  266. package/src/Upload.ts +125 -0
  267. package/src/WebMcp.ts +279 -0
  268. package/src/index.ts +26 -0
  269. package/src/web-globals.d.ts +103 -0
@@ -0,0 +1,273 @@
1
+ /**
2
+ * Settings and feature flags in each person's replica (the Settings and Flags contracts): the kernel-provided
3
+ * `settings` and `flags` modules' synced tables (generated from their Drizzle tables, `KernelTables.gen.ts`) and
4
+ * named queries, and the functions that read them locally the way the kernel does. An app that installs those
5
+ * modules adds `platformTables` and `platformQueries` to its sync schema.
6
+ *
7
+ * The kernel filters every query by the entity's read policy, in the organisation the replica acts in:
8
+ * - settings: the person's own user-level values and the organisation's values, one key per query (reads are
9
+ * keyed; nothing lists settings);
10
+ * - flags: the rules that can apply to the person (the organisation's, rollouts, role rules, rules about them
11
+ * and rules of the groups they are in; leaving a group takes its rules off the replica).
12
+ */
13
+ import { ChecklistState, type Checklist, type FlagReason, type ResolvedSetting, type SettingScope } from "@eloxiv/contracts";
14
+ import { Schema } from "effect";
15
+ import { flagRuleTable, settingValueTable } from "./KernelTables.gen.ts";
16
+ export { flagRuleTable, settingValueTable };
17
+ export declare const platformTables: readonly [import("@rocicorp/zero").TableBuilderWithColumns<{
18
+ name: "settingValue";
19
+ columns: {
20
+ readonly id: {
21
+ type: "string";
22
+ optional: false;
23
+ customType: string;
24
+ };
25
+ readonly key: {
26
+ type: "string";
27
+ optional: false;
28
+ customType: string;
29
+ };
30
+ readonly level: {
31
+ type: "string";
32
+ optional: false;
33
+ customType: "org" | "user";
34
+ };
35
+ readonly orgId: {
36
+ type: "string";
37
+ optional: false;
38
+ customType: string;
39
+ } & {
40
+ serverName: string;
41
+ };
42
+ readonly userId: Omit<{
43
+ type: "string";
44
+ optional: false;
45
+ customType: string;
46
+ } & {
47
+ serverName: string;
48
+ }, "optional"> & {
49
+ optional: true;
50
+ };
51
+ readonly value: Omit<{
52
+ type: "json";
53
+ optional: false;
54
+ customType: import("@rocicorp/zero").ReadonlyJSONValue;
55
+ }, "optional"> & {
56
+ optional: true;
57
+ };
58
+ readonly updatedBy: {
59
+ type: "string";
60
+ optional: false;
61
+ customType: string;
62
+ } & {
63
+ serverName: string;
64
+ };
65
+ readonly updatedAt: {
66
+ type: "number";
67
+ optional: false;
68
+ customType: number;
69
+ } & {
70
+ serverName: string;
71
+ };
72
+ };
73
+ primaryKey: readonly [string, ...string[]];
74
+ } & {
75
+ primaryKey: ["id"];
76
+ }>, import("@rocicorp/zero").TableBuilderWithColumns<{
77
+ name: "flagRule";
78
+ columns: {
79
+ readonly id: {
80
+ type: "string";
81
+ optional: false;
82
+ customType: string;
83
+ };
84
+ readonly orgId: {
85
+ type: "string";
86
+ optional: false;
87
+ customType: string;
88
+ } & {
89
+ serverName: string;
90
+ };
91
+ readonly flag: {
92
+ type: "string";
93
+ optional: false;
94
+ customType: string;
95
+ };
96
+ readonly kind: {
97
+ type: "string";
98
+ optional: false;
99
+ customType: "group" | "org" | "role" | "rollout" | "user";
100
+ };
101
+ readonly subject: Omit<{
102
+ type: "string";
103
+ optional: false;
104
+ customType: string;
105
+ }, "optional"> & {
106
+ optional: true;
107
+ };
108
+ readonly userId: Omit<{
109
+ type: "string";
110
+ optional: false;
111
+ customType: string;
112
+ } & {
113
+ serverName: string;
114
+ }, "optional"> & {
115
+ optional: true;
116
+ };
117
+ readonly groupId: Omit<{
118
+ type: "string";
119
+ optional: false;
120
+ customType: string;
121
+ } & {
122
+ serverName: string;
123
+ }, "optional"> & {
124
+ optional: true;
125
+ };
126
+ readonly enabled: {
127
+ type: "boolean";
128
+ optional: false;
129
+ customType: boolean;
130
+ };
131
+ readonly percentage: Omit<{
132
+ type: "number";
133
+ optional: false;
134
+ customType: number;
135
+ }, "optional"> & {
136
+ optional: true;
137
+ };
138
+ readonly updatedBy: {
139
+ type: "string";
140
+ optional: false;
141
+ customType: string;
142
+ } & {
143
+ serverName: string;
144
+ };
145
+ readonly updatedAt: {
146
+ type: "number";
147
+ optional: false;
148
+ customType: number;
149
+ } & {
150
+ serverName: string;
151
+ };
152
+ };
153
+ primaryKey: readonly [string, ...string[]];
154
+ } & {
155
+ primaryKey: ["id"];
156
+ }>];
157
+ /** Named queries, namespaced like a module's (`settings.value`, `flags.mine`). */
158
+ export declare const platformQueries: {
159
+ settings: {
160
+ /** One setting's values for you: yours and your organisation's (the kernel adds the filter). */
161
+ value: import("@rocicorp/zero").QueryDefinition<"settingValue", string, string, {
162
+ readonly id: string;
163
+ readonly key: string;
164
+ readonly level: "org" | "user";
165
+ readonly orgId: string;
166
+ readonly userId: string | null;
167
+ readonly value: import("@rocicorp/zero").ReadonlyJSONValue;
168
+ readonly updatedBy: string;
169
+ readonly updatedAt: number;
170
+ }, unknown>;
171
+ };
172
+ flags: {
173
+ /**
174
+ * Every targeting rule that can apply to you, for every flag. Unbounded on purpose: a client that held only
175
+ * some of them would evaluate a flag differently from the kernel without knowing it. The rules are few (per
176
+ * flag: the organisation's, a rollout, role rules, the rule about you and your groups' rules).
177
+ */
178
+ mine: import("@rocicorp/zero").QueryDefinition<"flagRule", import("@rocicorp/zero").ReadonlyJSONValue | undefined, import("@rocicorp/zero").ReadonlyJSONValue | undefined, {
179
+ readonly id: string;
180
+ readonly orgId: string;
181
+ readonly flag: string;
182
+ readonly kind: "group" | "org" | "role" | "rollout" | "user";
183
+ readonly subject: string | null;
184
+ readonly userId: string | null;
185
+ readonly groupId: string | null;
186
+ readonly enabled: boolean;
187
+ readonly percentage: number | null;
188
+ readonly updatedBy: string;
189
+ readonly updatedAt: number;
190
+ }, unknown>;
191
+ };
192
+ };
193
+ /** A setting's stored value: `{ v: <encoded value> }`, or null once cleared (any other JSON is not a value). */
194
+ type SettingRow = {
195
+ readonly level: string;
196
+ readonly value?: unknown;
197
+ };
198
+ /**
199
+ * A setting's value from the replica's rows for its key (`settings.value`), resolved as the kernel resolves
200
+ * it: your own value, your organisation's, then `deployment` (app- and module-level values, which are
201
+ * configuration and not in the replica; read them once with `settings.get` if the app sets any), then the
202
+ * default. As in the kernel, a value that no longer decodes against the setting's schema (a module changed the
203
+ * schema) is skipped and the next level applies.
204
+ */
205
+ export declare const settingFromReplica: (declaration: {
206
+ readonly scope: SettingScope;
207
+ readonly default: unknown;
208
+ readonly schema: Schema.Top;
209
+ }, rows: ReadonlyArray<SettingRow>, deployment?: Partial<Readonly<Record<"app" | "module", unknown>>>) => ResolvedSetting;
210
+ type RuleRow = {
211
+ readonly flag: string;
212
+ readonly kind: string;
213
+ readonly subject?: string | null | undefined;
214
+ readonly enabled: boolean;
215
+ readonly percentage?: number | null | undefined;
216
+ };
217
+ /**
218
+ * A flag for you from the replica's rules (`flags.mine`), evaluated with the kernel's function: the replica
219
+ * holds only the rules about you and your groups, so group rules apply as given; role rules apply for the
220
+ * roles you hold (`roles`, from `GET /api/me/organizations`).
221
+ */
222
+ export declare const flagFromReplica: (flag: string, declaration: {
223
+ readonly default: boolean;
224
+ }, rows: ReadonlyArray<RuleRow>, subject: {
225
+ readonly userId: string;
226
+ readonly roles: ReadonlyArray<string>;
227
+ }) => {
228
+ readonly enabled: boolean;
229
+ readonly reason: FlagReason;
230
+ };
231
+ /**
232
+ * A setup checklist's state from the replica's rows for its key (`settings.value`, the checklist's setting), resolved
233
+ * as `settingFromReplica` resolves any setting: for a `user` checklist, the person's own progress, else what their
234
+ * organisation set, else nothing done. Feed it to `checklistSummary`; write the next state with `settings.set`
235
+ * (`checklistWrite`).
236
+ */
237
+ export declare const checklistFromReplica: (checklist: Checklist, rows: ReadonlyArray<SettingRow>) => ChecklistState;
238
+ /** Where a flag's rules are: still arriving, unreadable (with why), or in the replica. */
239
+ export type FlagRules = {
240
+ readonly state: "loading";
241
+ } | {
242
+ readonly state: "unavailable";
243
+ readonly reason: string;
244
+ } | {
245
+ readonly state: "settled";
246
+ readonly rows: ReadonlyArray<RuleRow>;
247
+ };
248
+ /**
249
+ * A flag's state for a UI, each case its own: `loading` (the rules or the person's roles have not arrived),
250
+ * `unavailable` (the rules cannot be read: the replica failed or is closed), `unregistered` (no installed module
251
+ * declares the flag), or `on` / `off` with the kernel's reason. Only `on` is on (`isFlagOn`): every other state
252
+ * fails closed, and a UI can still tell "still loading" from "off" from "broken".
253
+ */
254
+ export type FlagStatus = {
255
+ readonly status: "loading";
256
+ } | {
257
+ readonly status: "unavailable";
258
+ readonly reason: string;
259
+ } | {
260
+ readonly status: "unregistered";
261
+ } | {
262
+ readonly status: "on" | "off";
263
+ readonly reason: FlagReason;
264
+ };
265
+ export declare const flagStatus: (flag: string, declarations: Readonly<Record<string, {
266
+ readonly default: boolean;
267
+ }>>, rules: FlagRules, subject: {
268
+ readonly userId: string;
269
+ readonly roles: ReadonlyArray<string>;
270
+ } | undefined) => FlagStatus;
271
+ /** Is the flag on? Only a settled `on` is; loading, unavailable and unregistered are off (fail closed). */
272
+ export declare const isFlagOn: (status: FlagStatus) => boolean;
273
+ //# sourceMappingURL=PlatformSync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformSync.d.ts","sourceRoot":"","sources":["../src/PlatformSync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,cAAc,EAEd,KAAK,SAAS,EAEd,KAAK,UAAU,EACf,KAAK,eAAe,EAEpB,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAQ,MAAM,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAExE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,CAAA;AAE3C,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA8C,CAAA;AAMzE,kFAAkF;AAClF,eAAO,MAAM,eAAe;IAC1B,QAAQ;QACN,gGAAgG;QAChG,KAAK;;;;;;;;;;;IAEP,KAAK;QACH;;;;WAIG;QACH,IAAI;;;;;;;;;;;;;;CAEP,CAAA;AAED,gHAAgH;AAChH,KAAK,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAItE;;;;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EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;CAAE,CAAA;AAExE;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;CAAE,GAC9B;IAAE,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3D;IAAE,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;CAAE,GACnC;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,GAAG,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAA;AAElE,eAAO,MAAM,UAAU,SACf,MAAM,gBACE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,SAC9D,SAAS,WACP;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAE,GAAG,SAAS,KACtF,UAOF,CAAA;AAED,2GAA2G;AAC3G,eAAO,MAAM,QAAQ,WAAY,UAAU,KAAG,OAAiC,CAAA"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Settings and feature flags in each person's replica (the Settings and Flags contracts): the kernel-provided
3
+ * `settings` and `flags` modules' synced tables (generated from their Drizzle tables, `KernelTables.gen.ts`) and
4
+ * named queries, and the functions that read them locally the way the kernel does. An app that installs those
5
+ * modules adds `platformTables` and `platformQueries` to its sync schema.
6
+ *
7
+ * The kernel filters every query by the entity's read policy, in the organisation the replica acts in:
8
+ * - settings: the person's own user-level values and the organisation's values, one key per query (reads are
9
+ * keyed; nothing lists settings);
10
+ * - flags: the rules that can apply to the person (the organisation's, rollouts, role rules, rules about them
11
+ * and rules of the groups they are in; leaving a group takes its rules off the replica).
12
+ */
13
+ import { ChecklistState, evaluateFlag, resolveSetting, } from "@eloxiv/contracts";
14
+ import { createBuilder, createSchema, defineQueryWithType } from "@rocicorp/zero";
15
+ import { Exit, Schema } from "effect";
16
+ import { flagRuleTable, settingValueTable } from "./KernelTables.gen.js";
17
+ export { flagRuleTable, settingValueTable };
18
+ export const platformTables = [settingValueTable, flagRuleTable];
19
+ const localSchema = createSchema({ tables: [settingValueTable, flagRuleTable] });
20
+ const zql = createBuilder(localSchema);
21
+ const defineQuery = defineQueryWithType();
22
+ /** Named queries, namespaced like a module's (`settings.value`, `flags.mine`). */
23
+ export const platformQueries = {
24
+ settings: {
25
+ /** One setting's values for you: yours and your organisation's (the kernel adds the filter). */
26
+ value: defineQuery(({ args }) => zql.settingValue.where("key", args).limit(2)),
27
+ },
28
+ flags: {
29
+ /**
30
+ * Every targeting rule that can apply to you, for every flag. Unbounded on purpose: a client that held only
31
+ * some of them would evaluate a flag differently from the kernel without knowing it. The rules are few (per
32
+ * flag: the organisation's, a rollout, role rules, the rule about you and your groups' rules).
33
+ */
34
+ mine: defineQuery(() => zql.flagRule),
35
+ },
36
+ };
37
+ const storedValue = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && "v" in value ? value : undefined;
38
+ /**
39
+ * A setting's value from the replica's rows for its key (`settings.value`), resolved as the kernel resolves
40
+ * it: your own value, your organisation's, then `deployment` (app- and module-level values, which are
41
+ * configuration and not in the replica; read them once with `settings.get` if the app sets any), then the
42
+ * default. As in the kernel, a value that no longer decodes against the setting's schema (a module changed the
43
+ * schema) is skipped and the next level applies.
44
+ */
45
+ export const settingFromReplica = (declaration, rows, deployment = {}) => {
46
+ const values = { ...deployment };
47
+ for (const row of rows) {
48
+ const stored = storedValue(row.value);
49
+ if ((row.level === "user" || row.level === "org") && stored !== undefined) {
50
+ values[row.level] = stored.v;
51
+ }
52
+ }
53
+ const decode = Schema.decodeUnknownExit(declaration.schema);
54
+ for (const [level, value] of Object.entries(values)) {
55
+ if (value === undefined || Exit.isFailure(decode(value)))
56
+ delete values[level];
57
+ }
58
+ return resolveSetting(declaration, values);
59
+ };
60
+ /**
61
+ * A flag for you from the replica's rules (`flags.mine`), evaluated with the kernel's function: the replica
62
+ * holds only the rules about you and your groups, so group rules apply as given; role rules apply for the
63
+ * roles you hold (`roles`, from `GET /api/me/organizations`).
64
+ */
65
+ export const flagFromReplica = (flag, declaration, rows, subject) => evaluateFlag(flag, declaration, rows.map((r) => ({
66
+ flag: r.flag,
67
+ kind: r.kind,
68
+ subject: r.subject ?? null,
69
+ enabled: r.enabled,
70
+ percentage: r.percentage ?? null,
71
+ })), { userId: subject.userId, roles: subject.roles, groups: "given" });
72
+ /**
73
+ * A setup checklist's state from the replica's rows for its key (`settings.value`, the checklist's setting), resolved
74
+ * as `settingFromReplica` resolves any setting: for a `user` checklist, the person's own progress, else what their
75
+ * organisation set, else nothing done. Feed it to `checklistSummary`; write the next state with `settings.set`
76
+ * (`checklistWrite`).
77
+ */
78
+ export const checklistFromReplica = (checklist, rows) => Schema.decodeUnknownSync(ChecklistState)(settingFromReplica(checklist.setting, rows).value);
79
+ export const flagStatus = (flag, declarations, rules, subject) => {
80
+ const declaration = declarations[flag];
81
+ if (declaration === undefined)
82
+ return { status: "unregistered" };
83
+ if (rules.state === "unavailable")
84
+ return { status: "unavailable", reason: rules.reason };
85
+ if (rules.state === "loading" || subject === undefined)
86
+ return { status: "loading" };
87
+ const evaluated = flagFromReplica(flag, declaration, rules.rows, subject);
88
+ return { status: evaluated.enabled ? "on" : "off", reason: evaluated.reason };
89
+ };
90
+ /** Is the flag on? Only a settled `on` is; loading, unavailable and unregistered are off (fail closed). */
91
+ export const isFlagOn = (status) => status.status === "on";
92
+ //# sourceMappingURL=PlatformSync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlatformSync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,MAAM,EAAE,CAAA;AAC/E,CAAC,CAAA;AAED,2GAA2G;AAC3G,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAkB,EAAW,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,IAAI,CAAA"}
package/dist/Poll.d.ts ADDED
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Polling and status probes, runtime-neutral (timers, `fetch` and `AbortController` only): a host that knows
3
+ * whether it is visible passes a `Visibility` (`@eloxiv/shell-core/web`'s `webVisibility()` in a browser).
4
+ *
5
+ * - `poll`: one attempt at a time, each abortable and bounded by a timeout, on an interval; paused or slowed while
6
+ * hidden; `now()` polls at once (or right after the attempt in flight).
7
+ * - `makeProbe`: a status read shared by everyone who asks: one request in flight at a time, its answer kept for a
8
+ * while, and "the backend could not be reached" (`unavailable`) kept apart from what the backend answered.
9
+ * - `sessionProbe` and `engineProbe`: the person's session (signed in, signed out) and the kernel's readiness, as
10
+ * probes, so a network failure is never taken for a sign-out.
11
+ */
12
+ import { type SignalLike } from "./Transport.ts";
13
+ /** Whether the host is visible, and a way to hear when that changes. */
14
+ export interface Visibility {
15
+ readonly hidden: () => boolean;
16
+ /** Calls `listener` on every change; returns the unsubscribe. */
17
+ readonly subscribe: (listener: () => void) => () => void;
18
+ }
19
+ export interface PollOptions<A> {
20
+ /** Between the end of one attempt and the start of the next (ms). */
21
+ readonly intervalMs: number;
22
+ /** While hidden: `"pause"` (the default: no attempts) or a slower interval (ms). */
23
+ readonly hiddenIntervalMs?: number | "pause" | undefined;
24
+ /** An attempt still running after this long is aborted and reported as a `Timeout` error (default 30 000). */
25
+ readonly timeoutMs?: number | undefined;
26
+ /** Start with an attempt at once (default true), rather than after the first interval. */
27
+ readonly immediate?: boolean | undefined;
28
+ readonly visibility?: Visibility | undefined;
29
+ readonly onResult?: ((result: A) => void) | undefined;
30
+ readonly onError?: ((error: unknown) => void) | undefined;
31
+ }
32
+ /** A poller's handle. */
33
+ export interface Poller {
34
+ /** Poll now; with an attempt in flight, poll again as soon as it ends (never two at once). */
35
+ readonly now: () => void;
36
+ /** Stop: the attempt in flight is aborted and nothing more runs. */
37
+ readonly stop: () => void;
38
+ }
39
+ export declare class PollTimeout extends Error {
40
+ readonly name = "PollTimeout";
41
+ readonly _tag = "Timeout";
42
+ }
43
+ export declare const poll: <A>(attempt: (signal: SignalLike) => Promise<A>, options: PollOptions<A>) => Poller;
44
+ /** What a probe found: the backend's answer, or that it could not be had (and why). */
45
+ export type Probed<A> = {
46
+ readonly status: "available";
47
+ readonly value: A;
48
+ readonly at: number;
49
+ } | {
50
+ readonly status: "unavailable";
51
+ readonly reason: string;
52
+ readonly at: number;
53
+ };
54
+ export interface ProbeOptions {
55
+ /** How long an answer is kept (ms, default 5 000). */
56
+ readonly ttlMs?: number | undefined;
57
+ /** How long "unavailable" is kept (ms, default 1 000): sooner asked again. */
58
+ readonly unavailableTtlMs?: number | undefined;
59
+ /** A probe still running after this long is aborted, and found unavailable (ms, default 10 000). */
60
+ readonly timeoutMs?: number | undefined;
61
+ readonly now?: (() => number) | undefined;
62
+ }
63
+ /**
64
+ * A status read shared by its callers: `get()` returns the kept answer while it is fresh, else joins the request in
65
+ * flight, else makes one. `load` resolving is `available` with its value; `load` throwing or timing out is
66
+ * `unavailable` with the reason, never a value.
67
+ */
68
+ export declare const makeProbe: <A>(load: (signal: SignalLike) => Promise<A>, options?: ProbeOptions) => {
69
+ get: () => Promise<Probed<A>>;
70
+ /** Forget the kept answer (after a sign-in or sign-out): the next `get` asks again. */
71
+ invalidate: () => void;
72
+ };
73
+ export type Probe<A> = ReturnType<typeof makeProbe<A>>;
74
+ /** The person's session as the kernel sees it. */
75
+ export type ProbedSession = {
76
+ readonly signedIn: true;
77
+ readonly user: {
78
+ readonly id: string;
79
+ readonly email: string;
80
+ readonly name: string;
81
+ };
82
+ } | {
83
+ readonly signedIn: false;
84
+ };
85
+ /**
86
+ * The session `token` names, as a probe (Better Auth's `GET /auth/get-session`): `available` with `signedIn: true`
87
+ * and the user, or `signedIn: false` when the kernel says there is no such session (a 401, or no session in its
88
+ * answer); `unavailable` when the kernel could not be reached or failed, which is not a sign-out.
89
+ */
90
+ export declare const sessionProbe: (baseUrl: string, token: () => string | undefined, options?: ProbeOptions) => {
91
+ get: () => Promise<Probed<ProbedSession>>;
92
+ /** Forget the kept answer (after a sign-in or sign-out): the next `get` asks again. */
93
+ invalidate: () => void;
94
+ };
95
+ /** The kernel's readiness (`GET /ready`): every check with its verdict. */
96
+ export interface EngineState {
97
+ readonly status: "ready" | "degraded" | "not-ready";
98
+ readonly checks?: ReadonlyArray<{
99
+ readonly name: string;
100
+ readonly status: string;
101
+ readonly reason?: string;
102
+ }>;
103
+ }
104
+ /**
105
+ * The kernel's readiness as a probe: `available` with its report (ready, degraded or not ready: the kernel
106
+ * answered), `unavailable` when it could not be reached.
107
+ */
108
+ export declare const engineProbe: (baseUrl: string, options?: ProbeOptions) => {
109
+ get: () => Promise<Probed<EngineState>>;
110
+ /** Forget the kept answer (after a sign-in or sign-out): the next `get` asks again. */
111
+ invalidate: () => void;
112
+ };
113
+ //# sourceMappingURL=Poll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Poll.d.ts","sourceRoot":"","sources":["../src/Poll.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE7D,wEAAwE;AACxE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,OAAO,CAAA;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAA;CACzD;AAED,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,oFAAoF;IACpF,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,GAA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