@segmentstream/ontology 0.0.0-stage → 0.92.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 (483) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +2 -0
  3. package/README.md +1655 -2
  4. package/dist/action.d.ts +193 -0
  5. package/dist/action.js +41 -0
  6. package/dist/agent-chat.d.ts +44 -0
  7. package/dist/agent-chat.js +91 -0
  8. package/dist/agent-task-contract.d.ts +64 -0
  9. package/dist/agent-task-contract.js +15 -0
  10. package/dist/agent-task.d.ts +39 -0
  11. package/dist/agent-task.js +112 -0
  12. package/dist/analyze.d.ts +215 -0
  13. package/dist/analyze.js +2438 -0
  14. package/dist/app-feedback.d.ts +167 -0
  15. package/dist/app-feedback.js +176 -0
  16. package/dist/authoring-input.d.ts +3 -0
  17. package/dist/authoring-input.js +107 -0
  18. package/dist/authoring-names.d.ts +4 -0
  19. package/dist/authoring-names.js +13 -0
  20. package/dist/authoring-records.d.ts +35 -0
  21. package/dist/authoring-records.js +264 -0
  22. package/dist/authoring.d.ts +15 -0
  23. package/dist/authoring.js +331 -0
  24. package/dist/bin/check.d.ts +30 -0
  25. package/dist/bin/check.js +99 -0
  26. package/dist/bin/load.d.ts +48 -0
  27. package/dist/bin/load.js +139 -0
  28. package/dist/bin/main.d.ts +31 -0
  29. package/dist/bin/main.js +121 -0
  30. package/dist/bin/migrate.d.ts +57 -0
  31. package/dist/bin/migrate.js +170 -0
  32. package/dist/bin/output.d.ts +31 -0
  33. package/dist/bin/output.js +84 -0
  34. package/dist/bin.d.ts +2 -0
  35. package/dist/bin.js +31 -0
  36. package/dist/blob.d.ts +52 -0
  37. package/dist/blob.js +87 -0
  38. package/dist/channel-session.d.ts +16 -0
  39. package/dist/channel-session.js +16 -0
  40. package/dist/chat.d.ts +43 -0
  41. package/dist/chat.js +34 -0
  42. package/dist/confirmation.d.ts +46 -0
  43. package/dist/confirmation.js +41 -0
  44. package/dist/connection.d.ts +213 -0
  45. package/dist/connection.js +289 -0
  46. package/dist/deployment.d.ts +35 -0
  47. package/dist/deployment.js +76 -0
  48. package/dist/diagnostics.d.ts +27 -0
  49. package/dist/diagnostics.js +106 -0
  50. package/dist/emails.d.ts +70 -0
  51. package/dist/emails.js +221 -0
  52. package/dist/entity.d.ts +331 -0
  53. package/dist/entity.js +153 -0
  54. package/dist/errors.d.ts +154 -0
  55. package/dist/errors.js +109 -0
  56. package/dist/feedback-config.d.ts +24 -0
  57. package/dist/feedback-config.js +126 -0
  58. package/dist/files.d.ts +39 -0
  59. package/dist/files.js +4 -0
  60. package/dist/groups.d.ts +95 -0
  61. package/dist/groups.js +280 -0
  62. package/dist/index.d.ts +109 -0
  63. package/dist/index.js +70 -0
  64. package/dist/internal/diagnostics.js +594 -0
  65. package/dist/legacy.d.ts +160 -0
  66. package/dist/legacy.js +270 -0
  67. package/dist/manifest-compatibility.d.ts +8 -0
  68. package/dist/manifest-compatibility.js +87 -0
  69. package/dist/manifest.d.ts +3329 -0
  70. package/dist/manifest.js +757 -0
  71. package/dist/me.d.ts +46 -0
  72. package/dist/me.js +109 -0
  73. package/dist/metric-filters.d.ts +48 -0
  74. package/dist/metric-filters.js +252 -0
  75. package/dist/metric-routes.d.ts +132 -0
  76. package/dist/metric-routes.js +498 -0
  77. package/dist/metric.d.ts +172 -0
  78. package/dist/metric.js +132 -0
  79. package/dist/migrate/apply.d.ts +94 -0
  80. package/dist/migrate/apply.js +526 -0
  81. package/dist/migrate/errors.d.ts +46 -0
  82. package/dist/migrate/errors.js +38 -0
  83. package/dist/migrate/index.d.ts +10 -0
  84. package/dist/migrate/index.js +7 -0
  85. package/dist/migrate/model.d.ts +2311 -0
  86. package/dist/migrate/model.js +148 -0
  87. package/dist/migrate/plan.d.ts +51 -0
  88. package/dist/migrate/plan.js +1856 -0
  89. package/dist/migrate/preview.d.ts +13 -0
  90. package/dist/migrate/preview.js +65 -0
  91. package/dist/migrate/storage.d.ts +226 -0
  92. package/dist/migrate/storage.js +774 -0
  93. package/dist/model-metrics.d.ts +22 -0
  94. package/dist/model-metrics.js +545 -0
  95. package/dist/names.d.ts +49 -0
  96. package/dist/names.js +110 -0
  97. package/dist/navigation-artifact.d.ts +13 -0
  98. package/dist/navigation-artifact.js +11 -0
  99. package/dist/navigation-catalog.d.ts +55 -0
  100. package/dist/navigation-catalog.js +297 -0
  101. package/dist/nitro-navigation.d.ts +3 -0
  102. package/dist/nitro-navigation.js +64 -0
  103. package/dist/nitro-workflows.d.ts +108 -0
  104. package/dist/nitro-workflows.js +286 -0
  105. package/dist/nitro.d.ts +40 -0
  106. package/dist/nitro.js +50 -0
  107. package/dist/ontology.d.ts +41 -0
  108. package/dist/ontology.js +46 -0
  109. package/dist/permissions.d.ts +198 -0
  110. package/dist/permissions.js +272 -0
  111. package/dist/property.d.ts +188 -0
  112. package/dist/property.js +301 -0
  113. package/dist/query.d.ts +245 -0
  114. package/dist/query.js +615 -0
  115. package/dist/relationship.d.ts +99 -0
  116. package/dist/relationship.js +33 -0
  117. package/dist/render.d.ts +81 -0
  118. package/dist/render.js +512 -0
  119. package/dist/replication/baseline.d.ts +51 -0
  120. package/dist/replication/baseline.js +215 -0
  121. package/dist/replication/bigquery.d.ts +37 -0
  122. package/dist/replication/bigquery.js +211 -0
  123. package/dist/replication/coverage.d.ts +14 -0
  124. package/dist/replication/coverage.js +53 -0
  125. package/dist/replication/evolution.d.ts +25 -0
  126. package/dist/replication/evolution.js +184 -0
  127. package/dist/replication/identities.d.ts +6 -0
  128. package/dist/replication/identities.js +47 -0
  129. package/dist/replication/legacy-baseline.d.ts +27 -0
  130. package/dist/replication/legacy-baseline.js +109 -0
  131. package/dist/replication/legacy-store.d.ts +19 -0
  132. package/dist/replication/legacy-store.js +63 -0
  133. package/dist/replication/lineage.d.ts +36 -0
  134. package/dist/replication/lineage.js +72 -0
  135. package/dist/replication/migrate.d.ts +21 -0
  136. package/dist/replication/migrate.js +84 -0
  137. package/dist/replication/model.d.ts +52 -0
  138. package/dist/replication/model.js +99 -0
  139. package/dist/replication/scans.d.ts +34 -0
  140. package/dist/replication/scans.js +158 -0
  141. package/dist/replication/schema.d.ts +11 -0
  142. package/dist/replication/schema.js +226 -0
  143. package/dist/replication/shadow-schema.d.ts +4 -0
  144. package/dist/replication/shadow-schema.js +61 -0
  145. package/dist/replication/shadow.d.ts +127 -0
  146. package/dist/replication/shadow.js +614 -0
  147. package/dist/replication/source-replacement.d.ts +33 -0
  148. package/dist/replication/source-replacement.js +76 -0
  149. package/dist/replication/store.d.ts +36 -0
  150. package/dist/replication/store.js +382 -0
  151. package/dist/replication/transaction.d.ts +23 -0
  152. package/dist/replication/transaction.js +88 -0
  153. package/dist/role.d.ts +61 -0
  154. package/dist/role.js +76 -0
  155. package/dist/runtime/action-deadlocks.d.ts +21 -0
  156. package/dist/runtime/action-deadlocks.js +130 -0
  157. package/dist/runtime/action-transactions.d.ts +35 -0
  158. package/dist/runtime/action-transactions.js +54 -0
  159. package/dist/runtime/agent-counters.d.ts +26 -0
  160. package/dist/runtime/agent-counters.js +98 -0
  161. package/dist/runtime/agent-tasks.d.ts +63 -0
  162. package/dist/runtime/agent-tasks.js +120 -0
  163. package/dist/runtime/agents.d.ts +15 -0
  164. package/dist/runtime/agents.js +457 -0
  165. package/dist/runtime/batch-diagnostics.d.ts +22 -0
  166. package/dist/runtime/batch-diagnostics.js +89 -0
  167. package/dist/runtime/batch.d.ts +52 -0
  168. package/dist/runtime/batch.js +534 -0
  169. package/dist/runtime/channel-session-revocation.d.ts +3 -0
  170. package/dist/runtime/channel-session-revocation.js +5 -0
  171. package/dist/runtime/channel-sessions.d.ts +4 -0
  172. package/dist/runtime/channel-sessions.js +61 -0
  173. package/dist/runtime/confirmations.d.ts +29 -0
  174. package/dist/runtime/confirmations.js +57 -0
  175. package/dist/runtime/cursor.d.ts +23 -0
  176. package/dist/runtime/cursor.js +100 -0
  177. package/dist/runtime/deployment.d.ts +7 -0
  178. package/dist/runtime/deployment.js +4 -0
  179. package/dist/runtime/errors.d.ts +118 -0
  180. package/dist/runtime/errors.js +109 -0
  181. package/dist/runtime/federation-tables.d.ts +2 -0
  182. package/dist/runtime/federation-tables.js +20 -0
  183. package/dist/runtime/federation.d.ts +42 -0
  184. package/dist/runtime/federation.js +222 -0
  185. package/dist/runtime/files.d.ts +39 -0
  186. package/dist/runtime/files.js +44 -0
  187. package/dist/runtime/generated-actions.d.ts +37 -0
  188. package/dist/runtime/generated-actions.js +307 -0
  189. package/dist/runtime/history.d.ts +91 -0
  190. package/dist/runtime/history.js +77 -0
  191. package/dist/runtime/ids.d.ts +6 -0
  192. package/dist/runtime/ids.js +39 -0
  193. package/dist/runtime/member-tables.d.ts +8 -0
  194. package/dist/runtime/member-tables.js +33 -0
  195. package/dist/runtime/member-writes.d.ts +78 -0
  196. package/dist/runtime/member-writes.js +202 -0
  197. package/dist/runtime/metric-query.d.ts +19 -0
  198. package/dist/runtime/metric-query.js +411 -0
  199. package/dist/runtime/model.d.ts +67 -0
  200. package/dist/runtime/model.js +150 -0
  201. package/dist/runtime/new-user-hook.d.ts +6 -0
  202. package/dist/runtime/new-user-hook.js +37 -0
  203. package/dist/runtime/oauth.d.ts +9 -0
  204. package/dist/runtime/oauth.js +299 -0
  205. package/dist/runtime/pipeline.d.ts +155 -0
  206. package/dist/runtime/pipeline.js +597 -0
  207. package/dist/runtime/postgres-tls.d.ts +10 -0
  208. package/dist/runtime/postgres-tls.js +14 -0
  209. package/dist/runtime/principals.d.ts +302 -0
  210. package/dist/runtime/principals.js +1307 -0
  211. package/dist/runtime/reads.d.ts +55 -0
  212. package/dist/runtime/reads.js +313 -0
  213. package/dist/runtime/records.d.ts +42 -0
  214. package/dist/runtime/records.js +245 -0
  215. package/dist/runtime/resolve-agent-identity.d.ts +6 -0
  216. package/dist/runtime/resolve-agent-identity.js +181 -0
  217. package/dist/runtime/service-binding.d.ts +18 -0
  218. package/dist/runtime/service-binding.js +266 -0
  219. package/dist/runtime/sign-in-links.d.ts +68 -0
  220. package/dist/runtime/sign-in-links.js +147 -0
  221. package/dist/runtime/sql-runtime.d.ts +131 -0
  222. package/dist/runtime/sql-runtime.js +362 -0
  223. package/dist/runtime/statement.d.ts +18 -0
  224. package/dist/runtime/statement.js +31 -0
  225. package/dist/runtime/user-identities.d.ts +66 -0
  226. package/dist/runtime/user-identities.js +106 -0
  227. package/dist/runtime/user-identity-sql.d.ts +86 -0
  228. package/dist/runtime/user-identity-sql.js +297 -0
  229. package/dist/runtime/user-roles.d.ts +16 -0
  230. package/dist/runtime/user-roles.js +32 -0
  231. package/dist/runtime/validation.d.ts +16 -0
  232. package/dist/runtime/validation.js +26 -0
  233. package/dist/runtime/where.d.ts +57 -0
  234. package/dist/runtime/where.js +404 -0
  235. package/dist/runtime/workflow-admission.d.ts +49 -0
  236. package/dist/runtime/workflow-admission.js +92 -0
  237. package/dist/runtime/workflow-argument-codec.d.ts +10 -0
  238. package/dist/runtime/workflow-argument-codec.js +120 -0
  239. package/dist/runtime/workflow-arguments.d.ts +17 -0
  240. package/dist/runtime/workflow-arguments.js +99 -0
  241. package/dist/runtime/workflow-starts.d.ts +203 -0
  242. package/dist/runtime/workflow-starts.js +493 -0
  243. package/dist/runtime/workflow-users.d.ts +9 -0
  244. package/dist/runtime/workflow-users.js +17 -0
  245. package/dist/runtime/workload.d.ts +25 -0
  246. package/dist/runtime/workload.js +24 -0
  247. package/dist/runtime/writes.d.ts +108 -0
  248. package/dist/runtime/writes.js +491 -0
  249. package/dist/runtime-source.d.ts +22 -0
  250. package/dist/runtime-source.js +28 -0
  251. package/dist/runtime.d.ts +310 -0
  252. package/dist/runtime.js +31 -0
  253. package/dist/server.d.ts +23 -0
  254. package/dist/server.js +107 -0
  255. package/dist/service/agent/attachments.d.ts +33 -0
  256. package/dist/service/agent/attachments.js +228 -0
  257. package/dist/service/agent/authentication.d.ts +22 -0
  258. package/dist/service/agent/authentication.js +58 -0
  259. package/dist/service/agent/confirmations.d.ts +5 -0
  260. package/dist/service/agent/confirmations.js +73 -0
  261. package/dist/service/agent/conversation-routes.d.ts +14 -0
  262. package/dist/service/agent/conversation-routes.js +45 -0
  263. package/dist/service/agent/conversations.d.ts +40 -0
  264. package/dist/service/agent/conversations.js +69 -0
  265. package/dist/service/agent/files.d.ts +12 -0
  266. package/dist/service/agent/files.js +69 -0
  267. package/dist/service/agent/protocol.d.ts +90 -0
  268. package/dist/service/agent/protocol.js +114 -0
  269. package/dist/service/agent/server.d.ts +28 -0
  270. package/dist/service/agent/server.js +374 -0
  271. package/dist/service/agent/task-caller.d.ts +21 -0
  272. package/dist/service/agent/task-caller.js +35 -0
  273. package/dist/service/agent/task-start.d.ts +53 -0
  274. package/dist/service/agent/task-start.js +161 -0
  275. package/dist/service/agent/tasks.d.ts +40 -0
  276. package/dist/service/agent/tasks.js +155 -0
  277. package/dist/service/api.d.ts +50 -0
  278. package/dist/service/api.js +288 -0
  279. package/dist/service/authentication.d.ts +227 -0
  280. package/dist/service/authentication.js +767 -0
  281. package/dist/service/caller-context.d.ts +24 -0
  282. package/dist/service/caller-context.js +6 -0
  283. package/dist/service/catalog.d.ts +42 -0
  284. package/dist/service/catalog.js +66 -0
  285. package/dist/service/channel/provider.d.ts +10 -0
  286. package/dist/service/channel/provider.js +1 -0
  287. package/dist/service/channel/providers/telegram.d.ts +18 -0
  288. package/dist/service/channel/providers/telegram.js +108 -0
  289. package/dist/service/channel/sessions.d.ts +5 -0
  290. package/dist/service/channel/sessions.js +53 -0
  291. package/dist/service/channel/sign-in.d.ts +7 -0
  292. package/dist/service/channel/sign-in.js +78 -0
  293. package/dist/service/chat/archive.d.ts +64 -0
  294. package/dist/service/chat/archive.js +62 -0
  295. package/dist/service/chat/attribution.d.ts +26 -0
  296. package/dist/service/chat/attribution.js +28 -0
  297. package/dist/service/chat/delivery.d.ts +18 -0
  298. package/dist/service/chat/delivery.js +251 -0
  299. package/dist/service/chat/diagnostics.d.ts +2 -0
  300. package/dist/service/chat/diagnostics.js +35 -0
  301. package/dist/service/chat/envelope.d.ts +96 -0
  302. package/dist/service/chat/envelope.js +39 -0
  303. package/dist/service/chat/idempotency.d.ts +19 -0
  304. package/dist/service/chat/idempotency.js +37 -0
  305. package/dist/service/chat/providers/telegram.d.ts +36 -0
  306. package/dist/service/chat/providers/telegram.js +133 -0
  307. package/dist/service/chat/reads.d.ts +25 -0
  308. package/dist/service/chat/reads.js +75 -0
  309. package/dist/service/chat/resolve.d.ts +34 -0
  310. package/dist/service/chat/resolve.js +150 -0
  311. package/dist/service/chat/routes.d.ts +23 -0
  312. package/dist/service/chat/routes.js +75 -0
  313. package/dist/service/chat/schemas.d.ts +43 -0
  314. package/dist/service/chat/schemas.js +31 -0
  315. package/dist/service/config.d.ts +218 -0
  316. package/dist/service/config.js +265 -0
  317. package/dist/service/connection-stream.d.ts +10 -0
  318. package/dist/service/connection-stream.js +191 -0
  319. package/dist/service/connections.d.ts +60 -0
  320. package/dist/service/connections.js +271 -0
  321. package/dist/service/decisions.d.ts +35 -0
  322. package/dist/service/decisions.js +63 -0
  323. package/dist/service/descriptions.d.ts +8 -0
  324. package/dist/service/descriptions.js +20 -0
  325. package/dist/service/discovery-schemas.d.ts +92 -0
  326. package/dist/service/discovery-schemas.js +59 -0
  327. package/dist/service/discovery-search.d.ts +30 -0
  328. package/dist/service/discovery-search.js +95 -0
  329. package/dist/service/discovery.d.ts +37 -0
  330. package/dist/service/discovery.js +436 -0
  331. package/dist/service/docs.d.ts +9 -0
  332. package/dist/service/docs.js +197 -0
  333. package/dist/service/errors.d.ts +145 -0
  334. package/dist/service/errors.js +704 -0
  335. package/dist/service/federation-provider.d.ts +36 -0
  336. package/dist/service/federation-provider.js +110 -0
  337. package/dist/service/federation-server.d.ts +20 -0
  338. package/dist/service/federation-server.js +249 -0
  339. package/dist/service/federation-status.d.ts +40 -0
  340. package/dist/service/federation-status.js +151 -0
  341. package/dist/service/handlers.d.ts +18 -0
  342. package/dist/service/handlers.js +287 -0
  343. package/dist/service/mcp/confirmation.d.ts +68 -0
  344. package/dist/service/mcp/confirmation.js +178 -0
  345. package/dist/service/mcp/find-input.d.ts +12 -0
  346. package/dist/service/mcp/find-input.js +122 -0
  347. package/dist/service/mcp/input-schema.d.ts +6 -0
  348. package/dist/service/mcp/input-schema.js +126 -0
  349. package/dist/service/mcp/listing.d.ts +26 -0
  350. package/dist/service/mcp/listing.js +92 -0
  351. package/dist/service/mcp/metric-tools.d.ts +85 -0
  352. package/dist/service/mcp/metric-tools.js +258 -0
  353. package/dist/service/mcp/request-log.d.ts +5 -0
  354. package/dist/service/mcp/request-log.js +53 -0
  355. package/dist/service/mcp/runtime-policy.d.ts +27 -0
  356. package/dist/service/mcp/runtime-policy.js +62 -0
  357. package/dist/service/mcp/server.d.ts +52 -0
  358. package/dist/service/mcp/server.js +861 -0
  359. package/dist/service/mcp/tools.d.ts +99 -0
  360. package/dist/service/mcp/tools.js +938 -0
  361. package/dist/service/member-file-routes.d.ts +22 -0
  362. package/dist/service/member-file-routes.js +52 -0
  363. package/dist/service/member-files.d.ts +245 -0
  364. package/dist/service/member-files.js +258 -0
  365. package/dist/service/metric-query-platform.d.ts +77 -0
  366. package/dist/service/metric-query-platform.js +198 -0
  367. package/dist/service/metric-query-scopes.d.ts +43 -0
  368. package/dist/service/metric-query-scopes.js +147 -0
  369. package/dist/service/metric-query.d.ts +48 -0
  370. package/dist/service/metric-query.js +200 -0
  371. package/dist/service/name-suggestions.d.ts +3 -0
  372. package/dist/service/name-suggestions.js +38 -0
  373. package/dist/service/navigation-schemas.d.ts +80 -0
  374. package/dist/service/navigation-schemas.js +49 -0
  375. package/dist/service/navigation.d.ts +20 -0
  376. package/dist/service/navigation.js +165 -0
  377. package/dist/service/oauth/protocol.d.ts +70 -0
  378. package/dist/service/oauth/protocol.js +157 -0
  379. package/dist/service/oauth/refresh-replay.d.ts +2 -0
  380. package/dist/service/oauth/refresh-replay.js +20 -0
  381. package/dist/service/oauth/server.d.ts +28 -0
  382. package/dist/service/oauth/server.js +769 -0
  383. package/dist/service/operations.d.ts +170 -0
  384. package/dist/service/operations.js +392 -0
  385. package/dist/service/plan.d.ts +57 -0
  386. package/dist/service/plan.js +96 -0
  387. package/dist/service/rate-limit.d.ts +22 -0
  388. package/dist/service/rate-limit.js +52 -0
  389. package/dist/service/record-reads.d.ts +21 -0
  390. package/dist/service/record-reads.js +155 -0
  391. package/dist/service/replication.d.ts +5 -0
  392. package/dist/service/replication.js +39 -0
  393. package/dist/service/runtime-contract.d.ts +508 -0
  394. package/dist/service/runtime-contract.js +18 -0
  395. package/dist/service/runtime-identity.d.ts +71 -0
  396. package/dist/service/runtime-identity.js +122 -0
  397. package/dist/service/schemas.d.ts +961 -0
  398. package/dist/service/schemas.js +639 -0
  399. package/dist/service/service.d.ts +21 -0
  400. package/dist/service/service.js +526 -0
  401. package/dist/service/warehouse-platform.d.ts +17 -0
  402. package/dist/service/warehouse-platform.js +122 -0
  403. package/dist/service/warehouse-query.d.ts +24 -0
  404. package/dist/service/warehouse-query.js +280 -0
  405. package/dist/service/webhooks.d.ts +106 -0
  406. package/dist/service/webhooks.js +233 -0
  407. package/dist/service/workflow-admission-provider.d.ts +31 -0
  408. package/dist/service/workflow-admission-provider.js +205 -0
  409. package/dist/service/workflow-argument-serialization.d.ts +2 -0
  410. package/dist/service/workflow-argument-serialization.js +14 -0
  411. package/dist/service/workflow-callback.d.ts +22 -0
  412. package/dist/service/workflow-callback.js +75 -0
  413. package/dist/service/workflow-deployment.d.ts +8 -0
  414. package/dist/service/workflow-deployment.js +131 -0
  415. package/dist/service/workflow-diagnostics.d.ts +23 -0
  416. package/dist/service/workflow-diagnostics.js +263 -0
  417. package/dist/service/workflow-errors.d.ts +26 -0
  418. package/dist/service/workflow-errors.js +181 -0
  419. package/dist/service/workflow-logging.d.ts +2 -0
  420. package/dist/service/workflow-logging.js +50 -0
  421. package/dist/service/workflow-queue-fence.d.ts +6 -0
  422. package/dist/service/workflow-queue-fence.js +66 -0
  423. package/dist/service/workflows.d.ts +200 -0
  424. package/dist/service/workflows.js +1549 -0
  425. package/dist/sign-in.d.ts +58 -0
  426. package/dist/sign-in.js +57 -0
  427. package/dist/source.d.ts +30 -0
  428. package/dist/source.js +107 -0
  429. package/dist/start-recovery-contract.d.ts +49 -0
  430. package/dist/start-recovery-contract.js +26 -0
  431. package/dist/start-recovery.d.ts +27 -0
  432. package/dist/start-recovery.js +81 -0
  433. package/dist/storage/api.d.ts +4 -0
  434. package/dist/storage/api.js +40 -0
  435. package/dist/storage/attachments.d.ts +146 -0
  436. package/dist/storage/attachments.js +733 -0
  437. package/dist/storage/authorization.d.ts +38 -0
  438. package/dist/storage/authorization.js +83 -0
  439. package/dist/storage/file-access.d.ts +17 -0
  440. package/dist/storage/file-access.js +8 -0
  441. package/dist/storage/limits.d.ts +12 -0
  442. package/dist/storage/limits.js +17 -0
  443. package/dist/storage/maintenance-auth.d.ts +20 -0
  444. package/dist/storage/maintenance-auth.js +24 -0
  445. package/dist/storage/maintenance.d.ts +11 -0
  446. package/dist/storage/maintenance.js +67 -0
  447. package/dist/storage/neon.d.ts +4 -0
  448. package/dist/storage/neon.js +318 -0
  449. package/dist/storage/operator.d.ts +11 -0
  450. package/dist/storage/operator.js +30 -0
  451. package/dist/storage/provider.d.ts +93 -0
  452. package/dist/storage/provider.js +36 -0
  453. package/dist/storage/sessions.d.ts +184 -0
  454. package/dist/storage/sessions.js +688 -0
  455. package/dist/storage/tables.d.ts +54 -0
  456. package/dist/storage/tables.js +205 -0
  457. package/dist/storage/transfers.d.ts +16 -0
  458. package/dist/storage/transfers.js +153 -0
  459. package/dist/storage/writes.d.ts +7 -0
  460. package/dist/storage/writes.js +88 -0
  461. package/dist/telegram.d.ts +35 -0
  462. package/dist/telegram.js +173 -0
  463. package/dist/user-identity.d.ts +28 -0
  464. package/dist/user-identity.js +106 -0
  465. package/dist/user.d.ts +75 -0
  466. package/dist/user.js +111 -0
  467. package/dist/warehouse-backed.d.ts +6 -0
  468. package/dist/warehouse-backed.js +495 -0
  469. package/dist/webhook-token.d.ts +11 -0
  470. package/dist/webhook-token.js +18 -0
  471. package/dist/webhooks.d.ts +40 -0
  472. package/dist/webhooks.js +55 -0
  473. package/dist/wire.d.ts +10 -0
  474. package/dist/wire.js +35 -0
  475. package/dist/workflow-runtime.d.ts +116 -0
  476. package/dist/workflow-runtime.js +109 -0
  477. package/dist/workflow-topics.d.ts +28 -0
  478. package/dist/workflow-topics.js +28 -0
  479. package/dist/workflow.d.ts +284 -0
  480. package/dist/workflow.js +259 -0
  481. package/dist/workflows.d.ts +24 -0
  482. package/dist/workflows.js +18 -0
  483. package/package.json +127 -4
@@ -0,0 +1,173 @@
1
+ import { TelegramFormatConverter } from "@chat-adapter/telegram";
2
+ import { Lexer, Tokenizer } from "marked";
3
+ export const TELEGRAM_LINK_PREVIEWS = ["external", "none", "all"];
4
+ const converter = new TelegramFormatConverter();
5
+ const urlTokenizer = new Tokenizer({ gfm: true });
6
+ const visibleUrlStart = new RegExp(String.raw `(?<![\p{L}\p{N}_@/.:+-])(?:https?:\/\/|(?:` +
7
+ String.raw `(?:[\p{L}\p{N}](?:[\p{L}\p{N}-]*[\p{L}\p{N}])?\.)+(?:[\p{L}]{2,}|xn--[a-z0-9]+(?:-[a-z0-9]+)*)|` +
8
+ String.raw `(?:\d{1,3}\.){3}\d{1,3})(?![\p{L}\p{N}-]))`, "giu");
9
+ // Initialize the public tokenizer with the same GFM rules used by the agent renderer.
10
+ new Lexer({ gfm: true, tokenizer: urlTokenizer });
11
+ /** Normalize HTTP(S) origins only; credential-bearing and non-web destinations are ineligible. */
12
+ export function httpOrigin(value) {
13
+ const url = URL.parse(value);
14
+ return url && ["http:", "https:"].includes(url.protocol) && !url.username && !url.password
15
+ ? url.origin
16
+ : undefined;
17
+ }
18
+ export function isHttpOrigin(value) {
19
+ if (typeof value !== "string" || value !== value.trim() || !httpOrigin(value)) {
20
+ return false;
21
+ }
22
+ const url = new URL(value);
23
+ return url.pathname === "/" && !url.search && !url.hash;
24
+ }
25
+ /** Also validates programmatic standalone service configuration. */
26
+ export function validateTelegramPreviews(settings) {
27
+ if (!/^[a-z][a-z0-9_]{0,63}$/.test(settings.connection) ||
28
+ (settings.linkPreviews !== undefined &&
29
+ !TELEGRAM_LINK_PREVIEWS.includes(settings.linkPreviews)) ||
30
+ (settings.additionalOwnOrigins !== undefined &&
31
+ (!Array.isArray(settings.additionalOwnOrigins) ||
32
+ !settings.additionalOwnOrigins.every(isHttpOrigin)))) {
33
+ throw new Error("Invalid Telegram channel preview settings.");
34
+ }
35
+ }
36
+ /** Public, non-secret deployment metadata; no request headers or cross-tenant suffix matching. */
37
+ export function telegramPreviewEnvironment(environment) {
38
+ const channels = environment.SEGMENTSTREAM_CHANNELS
39
+ ? JSON.parse(environment.SEGMENTSTREAM_CHANNELS)
40
+ : {};
41
+ if (!channels || typeof channels !== "object" || Array.isArray(channels)) {
42
+ throw new Error("Invalid SEGMENTSTREAM_CHANNELS.");
43
+ }
44
+ if (channels.telegram !== undefined) {
45
+ validateTelegramPreviews(channels.telegram);
46
+ }
47
+ const declared = environment.SEGMENTSTREAM_APP_ORIGINS
48
+ ? JSON.parse(environment.SEGMENTSTREAM_APP_ORIGINS)
49
+ : [];
50
+ if (!Array.isArray(declared) || !declared.every(isHttpOrigin)) {
51
+ throw new Error("Invalid SEGMENTSTREAM_APP_ORIGINS.");
52
+ }
53
+ const candidates = [
54
+ ...declared,
55
+ environment.SEGMENTSTREAM_AGENT_ONTOLOGY_URL,
56
+ ...["VERCEL_PROJECT_PRODUCTION_URL", "VERCEL_URL", "VERCEL_BRANCH_URL"].map((key) => environment[key] ? `https://${environment[key]}` : undefined),
57
+ ];
58
+ return {
59
+ ...(channels.telegram === undefined ? {} : { channels }),
60
+ appOrigins: [
61
+ ...new Set(candidates.flatMap((value) => (value ? [httpOrigin(value)] : []))),
62
+ ].filter((value) => value !== undefined),
63
+ };
64
+ }
65
+ /** Telegram also auto-links visible domains without an HTTP scheme. */
66
+ function bareLinks(text) {
67
+ let end = 0;
68
+ return [...text.matchAll(visibleUrlStart)].flatMap((match) => {
69
+ if (match.index < end) {
70
+ return []; // A URL inside another URL's query/fragment is not a separate destination.
71
+ }
72
+ const source = text.slice(match.index);
73
+ const prefix = /^https?:\/\//iu.test(source) ? "" : "http://";
74
+ const token = urlTokenizer.url(prefix + source);
75
+ end = match.index + (token ? token.raw.length - prefix.length : 0);
76
+ return token && httpOrigin(token.href) ? [{ url: token.href, offset: match.index, end }] : [];
77
+ });
78
+ }
79
+ /** Parse source Markdown, never escaped Telegram MarkdownV2. AST offsets are UTF-16. */
80
+ function markdownLinks(markdown, plain = false) {
81
+ const links = [];
82
+ const visit = (node, base = 0, depth = 0) => {
83
+ const offset = base + (node.position?.start.offset ?? 0);
84
+ if (node.type === "code" || node.type === "inlineCode") {
85
+ // A formatting fallback sends literal code text, so its URLs become eligible again.
86
+ if (plain && depth < 32) {
87
+ visit(converter.toAst(node.value), offset, depth + 1);
88
+ }
89
+ return;
90
+ }
91
+ if (!plain && node.type === "table") {
92
+ return; // The existing Telegram renderer renders tables as code.
93
+ }
94
+ if (node.type === "link" || node.type === "image") {
95
+ if (httpOrigin(node.url)) {
96
+ links.push({ url: node.url, offset });
97
+ }
98
+ return;
99
+ }
100
+ if (node.type === "text") {
101
+ links.push(...bareLinks(node.value).map((link) => ({ ...link, offset: offset + link.offset })));
102
+ }
103
+ if ("children" in node) {
104
+ for (const child of node.children) {
105
+ visit(child, base, depth);
106
+ }
107
+ }
108
+ };
109
+ visit(converter.toAst(markdown));
110
+ return links.sort((a, b) => a.offset - b.offset);
111
+ }
112
+ export function telegramMarkdownLinks(markdown) {
113
+ return markdownLinks(markdown).map((link) => link.url);
114
+ }
115
+ /** Visible URLs and hidden destinations, excluding formatted code and linked-label lookalikes. */
116
+ export function telegramTextLinks(text, entities = []) {
117
+ const protectedEntities = entities.filter((entity) => ["code", "pre", "text_link", "url"].includes(entity.type));
118
+ // Literal fallbacks can expose URLs in Markdown labels, definitions or HTML. The URL
119
+ // tokenizer handles their punctuation without interpreting that text as Markdown.
120
+ const bare = bareLinks(text);
121
+ const parsed = markdownLinks(text, true).flatMap((link) => {
122
+ const offset = text.indexOf(link.url, link.offset);
123
+ // An embedded Markdown match belongs to the complete visible URL's query/fragment.
124
+ return offset < 0 || bare.some((visible) => offset > visible.offset && offset < visible.end)
125
+ ? []
126
+ : [{ ...link, offset }];
127
+ });
128
+ const visible = [...parsed, ...bare].filter((link) => !protectedEntities.some((entity) => link.offset >= entity.offset && link.offset < entity.offset + entity.length));
129
+ const hidden = entities.flatMap((entity) => {
130
+ if (entity.type === "url") {
131
+ const value = text.slice(entity.offset, entity.offset + entity.length);
132
+ const url = /\s/u.test(value)
133
+ ? null
134
+ : URL.parse(/^[a-z][a-z0-9+.-]*:\/\//iu.test(value) ? value : `http://${value}`);
135
+ return url && httpOrigin(url.href) ? [{ url: url.href, offset: entity.offset }] : [];
136
+ }
137
+ return entity.type === "text_link" && entity.url && httpOrigin(entity.url)
138
+ ? [{ url: entity.url, offset: entity.offset }]
139
+ : [];
140
+ });
141
+ const ordered = new Map();
142
+ for (const link of [...visible, ...hidden].sort((a, b) => a.offset - b.offset)) {
143
+ if (!ordered.has(link.offset)) {
144
+ ordered.set(link.offset, link.url);
145
+ }
146
+ }
147
+ return [...ordered.values()];
148
+ }
149
+ /** Explicit modern > explicit legacy > channel mode > external default. Never merge caller options. */
150
+ export function telegramPreviewOptions(caller, links, context = {}) {
151
+ if (caller.link_preview_options !== undefined) {
152
+ return { link_preview_options: caller.link_preview_options };
153
+ }
154
+ if (caller.disable_web_page_preview !== undefined) {
155
+ return { disable_web_page_preview: caller.disable_web_page_preview };
156
+ }
157
+ const eligible = links.filter((link) => httpOrigin(link) !== undefined);
158
+ const mode = context.settings?.linkPreviews ?? "external";
159
+ if (eligible.length === 0 || mode === "all") {
160
+ return {};
161
+ }
162
+ if (mode === "none") {
163
+ return { link_preview_options: { is_disabled: true } };
164
+ }
165
+ const own = new Set([...(context.ownOrigins ?? []), ...(context.settings?.additionalOwnOrigins ?? [])].flatMap((value) => (httpOrigin(value) ? [httpOrigin(value)] : [])));
166
+ if (own.size === 0) {
167
+ return {};
168
+ }
169
+ const external = eligible.find((link) => !own.has(httpOrigin(link)));
170
+ return {
171
+ link_preview_options: external === undefined ? { is_disabled: true } : { url: external },
172
+ };
173
+ }
@@ -0,0 +1,28 @@
1
+ /** How a sign-in identity came to be, as the `origin` property stores it. */
2
+ export declare const USER_IDENTITY_ORIGINS: readonly ["invite", "sign_in", "link", "pairing", "channel"];
3
+ export type UserIdentityOrigin = (typeof USER_IDENTITY_ORIGINS)[number];
4
+ /**
5
+ * The built-in record of every external account a member signs in or talks with: their Neon Auth
6
+ * account, their SegmentStream (OIDC) accounts and their channel accounts, such as Telegram. Every
7
+ * ontology includes it next to `User` and `AgentChat`. Only the platform writes it, with history;
8
+ * no generated or authored action does. Reading it needs a permission that names it, such as
9
+ * `user_identity:read`: an entity wildcard (`*:read`, `*:*`) does not cover it.
10
+ *
11
+ * At most one live identity holds an account, and a member holds at most one live identity per
12
+ * provider other than `oidc`. Both are unique keys that hold a value only while the identity is
13
+ * live, and none once it is revoked.
14
+ */
15
+ export declare const UserIdentity: import("./entity.js").DraftEntity<"user_identity", {
16
+ readonly provider: import("./property.js").Property<string, false, false>;
17
+ readonly issuer: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
18
+ readonly subject: import("./property.js").Property<string, false, false>;
19
+ readonly username: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
20
+ readonly display: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
21
+ readonly origin: import("./property.js").Property<"link" | "invite" | "sign_in" | "pairing" | "channel", false, false>;
22
+ readonly revokedAt: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
23
+ readonly accountKey: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, true>>;
24
+ readonly memberKey: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, true>>;
25
+ }, {
26
+ readonly user: import("./relationship.js").OneRelationship<false, false, "user">;
27
+ }, Readonly<Record<never, never>>, "actions">;
28
+ export type UserIdentity = typeof UserIdentity.Type;
@@ -0,0 +1,106 @@
1
+ import { entity } from "./entity.js";
2
+ import { p } from "./property.js";
3
+ import { rel } from "./relationship.js";
4
+ /** How a sign-in identity came to be, as the `origin` property stores it. */
5
+ export const USER_IDENTITY_ORIGINS = ["invite", "sign_in", "link", "pairing", "channel"];
6
+ /**
7
+ * The built-in record of every external account a member signs in or talks with: their Neon Auth
8
+ * account, their SegmentStream (OIDC) accounts and their channel accounts, such as Telegram. Every
9
+ * ontology includes it next to `User` and `AgentChat`. Only the platform writes it, with history;
10
+ * no generated or authored action does. Reading it needs a permission that names it, such as
11
+ * `user_identity:read`: an entity wildcard (`*:read`, `*:*`) does not cover it.
12
+ *
13
+ * At most one live identity holds an account, and a member holds at most one live identity per
14
+ * provider other than `oidc`. Both are unique keys that hold a value only while the identity is
15
+ * live, and none once it is revoked.
16
+ */
17
+ export const UserIdentity = entity("user_identity", {
18
+ id: "ent_user_identity",
19
+ label: "Sign-in identity",
20
+ plural: "Sign-in identities",
21
+ title: "subject",
22
+ description: "An external account a member signs in or talks with: their email sign-in, a SegmentStream " +
23
+ "account, or a chat account such as Telegram. The platform records them; nobody edits them.",
24
+ writes: "actions",
25
+ properties: {
26
+ provider: p.text({
27
+ managed: true,
28
+ description: "Who holds the account: neon-auth for email sign-in, oidc for SegmentStream sign-in, " +
29
+ "segmentstream for SegmentStream app tokens, or a chat provider such as telegram.",
30
+ }),
31
+ issuer: p.text({
32
+ optional: true,
33
+ managed: true,
34
+ description: "The OIDC issuer of an oidc account. Empty for every other provider.",
35
+ }),
36
+ subject: p.text({
37
+ managed: true,
38
+ description: "The account's id at the provider: the Neon Auth user id, the OIDC subject, or the " +
39
+ "chat user id.",
40
+ }),
41
+ username: p.text({
42
+ optional: true,
43
+ managed: true,
44
+ description: "The account's username at the provider, without @, when it has one.",
45
+ }),
46
+ display: p.text({
47
+ optional: true,
48
+ managed: true,
49
+ description: "The name the provider shows for the account, when it gives one.",
50
+ }),
51
+ origin: p.select([
52
+ {
53
+ value: "invite",
54
+ description: "The member's first sign-in claimed the invitation sent to their email.",
55
+ },
56
+ {
57
+ value: "sign_in",
58
+ label: "Sign-in",
59
+ description: "The member's first sign-in created the member or found them by it.",
60
+ },
61
+ {
62
+ value: "link",
63
+ description: "A signed-in member linked the account to themselves.",
64
+ },
65
+ {
66
+ value: "pairing",
67
+ description: "A signed-in member paired the chat account with a code.",
68
+ },
69
+ {
70
+ value: "channel",
71
+ description: "An open chat channel created the member for the chat account.",
72
+ },
73
+ ], { managed: true, description: "How the account came to belong to the member." }),
74
+ revokedAt: p.timestamp({
75
+ optional: true,
76
+ managed: true,
77
+ label: "Revoked",
78
+ description: "When the account stopped working for the member. Empty while it is live.",
79
+ }),
80
+ accountKey: p.text({
81
+ optional: true,
82
+ unique: true,
83
+ managed: true,
84
+ label: "Account key",
85
+ description: "provider, issuer and subject while the identity is live, so that one account belongs " +
86
+ "to one live identity. Empty once revoked.",
87
+ }),
88
+ memberKey: p.text({
89
+ optional: true,
90
+ unique: true,
91
+ managed: true,
92
+ label: "Member key",
93
+ description: "The member and provider while the identity is live, for providers that allow one live " +
94
+ "account per member. Empty once revoked, and for oidc, which allows several.",
95
+ }),
96
+ },
97
+ relationships: {
98
+ // By name, so that an ontology rebuilt with the deployed `user` still resolves it.
99
+ user: rel.one("user", {
100
+ inverse: "identities",
101
+ onDelete: "cascade",
102
+ phrase: ["belongs to", "signs in with"],
103
+ description: "The member the account belongs to.",
104
+ }),
105
+ },
106
+ });
package/dist/user.d.ts ADDED
@@ -0,0 +1,75 @@
1
+ import { Effect } from "effect";
2
+ import type { Actions } from "./action.js";
3
+ import { type Entity, type InvocableActions, type NoActions, type NoRelationships, type RecordRef } from "./entity.js";
4
+ import type { ActionRejected, Conflict, NotFound } from "./errors.js";
5
+ import { OntologyWrites } from "./runtime.js";
6
+ /**
7
+ * The built-in user: an app member who signs in with the workspace's Neon Auth (or, during the
8
+ * transition, with SegmentStream), or a service principal that authenticates with an API key. Every
9
+ * ontology includes it, and entities reference it like any other (`rel.one(User, …)`). Principals
10
+ * are users, so `principal.id` is a user id.
11
+ *
12
+ * The sign-in fields are managed: the ontology service links a member on first sign-in by the
13
+ * token's subject and records when they last signed in. A member's external accounts are the
14
+ * built-in `UserIdentity` records (`identities`); `identityProvider` and `identitySubject` keep a
15
+ * member's first sign-in for earlier SDKs, and a service's identity. Role assignments and API keys are kept by
16
+ * the service beside this table. Role assignments are changed through the `user` actions, the
17
+ * console or the CLI, and read as the record's managed, read-only `roles`.
18
+ */
19
+ declare const UserEntity: import("./entity.js").DraftEntity<"user", {
20
+ readonly name: import("./property.js").Property<string, false, false>;
21
+ readonly email: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, true>>;
22
+ readonly kind: import("./property.js").Property<"member" | "service", false, false>;
23
+ readonly active: import("./property.js").Property<boolean, true, false>;
24
+ readonly identityProvider: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
25
+ readonly identitySubject: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
26
+ readonly lastSignInAt: import("effect/Schema").optionalKey<import("./property.js").Property<string, false, false>>;
27
+ readonly roles: import("./property.js").Property<readonly string[], false, false>;
28
+ }, import("./entity.js").Relationships, Readonly<Record<never, never>>, "generated">;
29
+ type UserRecord = typeof UserEntity.Type;
30
+ /**
31
+ * The member writes of the `User` handle, for action handlers: they require {@link OntologyWrites},
32
+ * which `prepare` never has. They are the generated `user` actions' own writes, in the action's
33
+ * transaction, with history under the action's name and principal; only members are managed, so a
34
+ * service or an unknown id fails with NotFound. Roles are the ontology's declared roles; one it does
35
+ * not declare, or `member`, is ActionRejected. Each returns the user with its new `roles`.
36
+ */
37
+ export interface UserMemberWrites {
38
+ /** Grants roles; a role the member holds changes nothing. */
39
+ grantRoles(record: RecordRef, roles: ReadonlyArray<string>): Effect.Effect<UserRecord, ActionRejected | NotFound, OntologyWrites>;
40
+ /** Revokes roles, or every role; a role the member does not hold changes nothing. */
41
+ revokeRoles(record: RecordRef, roles: ReadonlyArray<string> | "all"): Effect.Effect<UserRecord, ActionRejected | NotFound, OntologyWrites>;
42
+ /**
43
+ * Creates a member for an email no user has, linked at their first sign-in; a known email fails
44
+ * with Conflict. The name defaults to the email.
45
+ */
46
+ invite(input: {
47
+ readonly email: string;
48
+ readonly name?: string;
49
+ readonly roles?: ReadonlyArray<string>;
50
+ }): Effect.Effect<UserRecord, ActionRejected | Conflict, OntologyWrites>;
51
+ /** Deactivates a member, which ends their sessions, or reactivates one. */
52
+ setActive(record: RecordRef, active: boolean): Effect.Effect<UserRecord, NotFound, OntologyWrites>;
53
+ /**
54
+ * Emails an active member a link that signs them in and opens `returnTo`, a path of the app, `/`
55
+ * by default. The email is `template`, one of the ontology's `emails` filled with `values`; or,
56
+ * without one, the platform's own: the invitation for a member who has not signed in yet, else
57
+ * the sign-in link. It is sent once the action commits; a send that fails never fails the action.
58
+ * An inactive member, an unknown email, a missing or unused value, or a path outside the app is
59
+ * ActionRejected.
60
+ */
61
+ sendSignInLink(record: RecordRef, options?: {
62
+ readonly template?: string;
63
+ readonly returnTo?: string;
64
+ readonly values?: Readonly<Record<string, string>>;
65
+ }): Effect.Effect<void, ActionRejected | NotFound, OntologyWrites>;
66
+ }
67
+ /** The built-in user's handle with actions `A`: its entity, and the member writes. */
68
+ export type UserHandle<A extends object> = Entity<"user", typeof UserEntity.properties, NoRelationships, A> & UserMemberWrites;
69
+ /** `User.actions((self) => ({ … }))`, whose `self` has the member writes too. */
70
+ interface UserActionsBuilder {
71
+ <const A extends Actions>(define: (self: UserHandle<NoActions>) => A): UserHandle<InvocableActions<A>>;
72
+ }
73
+ export declare const User: UserHandle<UserActionsBuilder>;
74
+ export type User = UserRecord;
75
+ export {};
package/dist/user.js ADDED
@@ -0,0 +1,111 @@
1
+ import { Effect } from "effect";
2
+ import { nameToWire } from "./authoring-names.js";
3
+ import { recordFromWire } from "./authoring-records.js";
4
+ import { entity, } from "./entity.js";
5
+ import { p } from "./property.js";
6
+ import { OntologyWrites } from "./runtime.js";
7
+ /**
8
+ * The built-in user: an app member who signs in with the workspace's Neon Auth (or, during the
9
+ * transition, with SegmentStream), or a service principal that authenticates with an API key. Every
10
+ * ontology includes it, and entities reference it like any other (`rel.one(User, …)`). Principals
11
+ * are users, so `principal.id` is a user id.
12
+ *
13
+ * The sign-in fields are managed: the ontology service links a member on first sign-in by the
14
+ * token's subject and records when they last signed in. A member's external accounts are the
15
+ * built-in `UserIdentity` records (`identities`); `identityProvider` and `identitySubject` keep a
16
+ * member's first sign-in for earlier SDKs, and a service's identity. Role assignments and API keys are kept by
17
+ * the service beside this table. Role assignments are changed through the `user` actions, the
18
+ * console or the CLI, and read as the record's managed, read-only `roles`.
19
+ */
20
+ const UserEntity = entity("user", {
21
+ id: "ent_user",
22
+ label: "User",
23
+ plural: "Users",
24
+ title: "name",
25
+ description: "A person or service that uses the app. Members sign in to the app; " +
26
+ "services authenticate with an API key.",
27
+ properties: {
28
+ name: p.text({ description: "The name shown in the app." }),
29
+ email: p.email({
30
+ optional: true,
31
+ unique: true,
32
+ description: "The member's sign-in address. Services have none.",
33
+ }),
34
+ kind: p.select([
35
+ {
36
+ value: "member",
37
+ label: "Member",
38
+ description: "A person who signs in to the app.",
39
+ },
40
+ {
41
+ value: "service",
42
+ label: "Service",
43
+ description: "A program that authenticates with an API key.",
44
+ },
45
+ ], { managed: true, description: "Whether the user is a person or a program." }),
46
+ active: p.boolean({
47
+ default: true,
48
+ managed: true,
49
+ description: "Inactive users cannot sign in or run actions.",
50
+ }),
51
+ identityProvider: p.text({
52
+ renamedFrom: "identityProvider",
53
+ optional: true,
54
+ managed: true,
55
+ description: "Who authenticates a service, or signed a member in first, for example neon-auth. A " +
56
+ "member's accounts are their sign-in identities.",
57
+ }),
58
+ identitySubject: p.text({
59
+ renamedFrom: "identitySubject",
60
+ optional: true,
61
+ managed: true,
62
+ description: "The user's id at that identity provider: the subject of their token.",
63
+ }),
64
+ // Optional so that a table created before it gains the column without a backfill: a member
65
+ // who has not signed in since simply has none.
66
+ lastSignInAt: p.timestamp({
67
+ renamedFrom: "lastSignInAt",
68
+ optional: true,
69
+ managed: true,
70
+ label: "Last sign-in",
71
+ description: "When the member last signed in to the app. Empty until they do.",
72
+ }),
73
+ // Read from the role assignments beside the table, in the statement that reads the record; it
74
+ // has no column, so adding it needed no migration.
75
+ roles: p.list(p.text(), {
76
+ managed: true,
77
+ description: "The roles assigned to the member, without the implicit member role.",
78
+ }),
79
+ },
80
+ indexes: [{ properties: ["identityProvider", "identitySubject"], unique: true }],
81
+ });
82
+ function idOf(record) {
83
+ return typeof record === "string" ? record : record.id;
84
+ }
85
+ function written(operation) {
86
+ return Effect.flatMap(OntologyWrites, operation).pipe(Effect.map((record) => recordFromWire(record, UserEntity.definition)));
87
+ }
88
+ const memberWrites = {
89
+ grantRoles: (record, roles) => written((writes) => writes.grantUserRoles({ id: idOf(record), roles: roles.map(nameToWire) })),
90
+ revokeRoles: (record, roles) => written((writes) => writes.revokeUserRoles({
91
+ id: idOf(record),
92
+ roles: roles === "all" ? "all" : roles.map(nameToWire),
93
+ })),
94
+ invite: ({ email, name, roles }) => written((writes) => writes.inviteUser({ email, name, roles: roles?.map(nameToWire) })),
95
+ setActive: (record, active) => written((writes) => writes.setUserActive({ id: idOf(record), active })),
96
+ sendSignInLink: (record, options = {}) => Effect.flatMap(OntologyWrites, (writes) => writes.sendUserSignInLink({
97
+ id: idOf(record),
98
+ template: options.template === undefined ? undefined : nameToWire(options.template),
99
+ returnTo: options.returnTo,
100
+ values: options.values,
101
+ })),
102
+ };
103
+ export const User = {
104
+ ...UserEntity,
105
+ ...memberWrites,
106
+ // Every form shares the definition, which is how defineOntology recognises the built-in.
107
+ actions: (define) => ({
108
+ ...UserEntity.actions((self) => define({ ...self, ...memberWrites })),
109
+ ...memberWrites,
110
+ }),
111
+ };
@@ -0,0 +1,6 @@
1
+ import type { ResolvedEntity } from "./analyze.js";
2
+ import type { DiagnosticCode } from "./diagnostics.js";
3
+ type Report = (code: DiagnosticCode, path: string, message: string) => void;
4
+ /** Cross-field validation runs after relationships have resolved their target entities. */
5
+ export declare function checkWarehouseSource(entities: ReadonlyArray<ResolvedEntity>, report: Report): void;
6
+ export {};