@haustle/notion-orm 0.0.44 → 0.0.45

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 (406) hide show
  1. package/README.md +449 -109
  2. package/build/src/agents-sdk-resolver.d.ts +8 -0
  3. package/build/src/agents-sdk-resolver.d.ts.map +1 -0
  4. package/build/src/agents-sdk-resolver.js +23 -0
  5. package/build/src/agents-sdk-resolver.js.map +1 -0
  6. package/build/src/ast/agents/agent-file-writer.d.ts +21 -0
  7. package/build/src/ast/agents/agent-file-writer.d.ts.map +1 -0
  8. package/build/src/ast/agents/agent-file-writer.js +99 -0
  9. package/build/src/ast/agents/agent-file-writer.js.map +1 -0
  10. package/build/src/ast/agents/generate-agents-cli.d.ts +24 -0
  11. package/build/src/ast/agents/generate-agents-cli.d.ts.map +1 -0
  12. package/build/src/ast/agents/generate-agents-cli.js +193 -0
  13. package/build/src/ast/agents/generate-agents-cli.js.map +1 -0
  14. package/build/src/ast/database/database-file-writer.d.ts +37 -0
  15. package/build/src/ast/database/database-file-writer.d.ts.map +1 -0
  16. package/build/src/ast/database/database-file-writer.js +240 -0
  17. package/build/src/ast/database/database-file-writer.js.map +1 -0
  18. package/build/src/ast/database/generate-databases-cli.d.ts +27 -0
  19. package/build/src/ast/database/generate-databases-cli.d.ts.map +1 -0
  20. package/build/src/ast/database/generate-databases-cli.js +141 -0
  21. package/build/src/ast/database/generate-databases-cli.js.map +1 -0
  22. package/build/src/ast/database/notion-column-generators.d.ts +180 -0
  23. package/build/src/ast/database/notion-column-generators.d.ts.map +1 -0
  24. package/build/src/ast/database/notion-column-generators.js +269 -0
  25. package/build/src/ast/database/notion-column-generators.js.map +1 -0
  26. package/build/src/ast/database/zod-schema.d.ts +17 -0
  27. package/build/src/ast/database/zod-schema.d.ts.map +1 -0
  28. package/build/src/ast/database/zod-schema.js +5 -0
  29. package/build/src/ast/database/zod-schema.js.map +1 -0
  30. package/build/src/ast/demo/datasource-fixture-builder.d.ts +38 -0
  31. package/build/src/ast/demo/datasource-fixture-builder.d.ts.map +1 -0
  32. package/build/src/ast/demo/datasource-fixture-builder.js +274 -0
  33. package/build/src/ast/demo/datasource-fixture-builder.js.map +1 -0
  34. package/build/src/ast/demo/demo-entry-builders.d.ts +28 -0
  35. package/build/src/ast/demo/demo-entry-builders.d.ts.map +1 -0
  36. package/build/src/ast/demo/demo-entry-builders.js +133 -0
  37. package/build/src/ast/demo/demo-entry-builders.js.map +1 -0
  38. package/build/src/ast/demo/demo-playground-spec.d.ts +51 -0
  39. package/build/src/ast/demo/demo-playground-spec.d.ts.map +1 -0
  40. package/build/src/ast/demo/demo-playground-spec.js +91 -0
  41. package/build/src/ast/demo/demo-playground-spec.js.map +1 -0
  42. package/build/src/ast/demo/demo-workspace-builder.d.ts +24 -0
  43. package/build/src/ast/demo/demo-workspace-builder.d.ts.map +1 -0
  44. package/build/src/ast/demo/demo-workspace-builder.js +90 -0
  45. package/build/src/ast/demo/demo-workspace-builder.js.map +1 -0
  46. package/build/src/ast/shared/ast-builders.d.ts +112 -0
  47. package/build/src/ast/shared/ast-builders.d.ts.map +1 -0
  48. package/build/src/ast/shared/ast-builders.js +181 -0
  49. package/build/src/ast/shared/ast-builders.js.map +1 -0
  50. package/build/src/ast/shared/cached-metadata.d.ts +26 -0
  51. package/build/src/ast/shared/cached-metadata.d.ts.map +1 -0
  52. package/build/src/ast/shared/cached-metadata.js +76 -0
  53. package/build/src/ast/shared/cached-metadata.js.map +1 -0
  54. package/build/src/ast/shared/codegen-diagnostics.d.ts +23 -0
  55. package/build/src/ast/shared/codegen-diagnostics.d.ts.map +1 -0
  56. package/build/src/ast/shared/codegen-diagnostics.js +13 -0
  57. package/build/src/ast/shared/codegen-diagnostics.js.map +1 -0
  58. package/build/src/ast/shared/codegen-environment.d.ts +37 -0
  59. package/build/src/ast/shared/codegen-environment.d.ts.map +1 -0
  60. package/build/src/ast/shared/codegen-environment.js +53 -0
  61. package/build/src/ast/shared/codegen-environment.js.map +1 -0
  62. package/build/src/ast/shared/constants.d.ts +98 -0
  63. package/build/src/ast/shared/constants.d.ts.map +1 -0
  64. package/build/src/ast/shared/constants.js +145 -0
  65. package/build/src/ast/shared/constants.js.map +1 -0
  66. package/build/src/ast/shared/emit/config-emitter.d.ts +56 -0
  67. package/build/src/ast/shared/emit/config-emitter.d.ts.map +1 -0
  68. package/build/src/ast/shared/emit/config-emitter.js +454 -0
  69. package/build/src/ast/shared/emit/config-emitter.js.map +1 -0
  70. package/build/src/ast/shared/emit/emit-value-as-expression.d.ts +10 -0
  71. package/build/src/ast/shared/emit/emit-value-as-expression.d.ts.map +1 -0
  72. package/build/src/ast/shared/emit/emit-value-as-expression.js +37 -0
  73. package/build/src/ast/shared/emit/emit-value-as-expression.js.map +1 -0
  74. package/build/src/ast/shared/emit/orm-index-emitter.d.ts +61 -0
  75. package/build/src/ast/shared/emit/orm-index-emitter.d.ts.map +1 -0
  76. package/build/src/ast/shared/emit/orm-index-emitter.js +376 -0
  77. package/build/src/ast/shared/emit/orm-index-emitter.js.map +1 -0
  78. package/build/src/ast/shared/emit/registry-emitter.d.ts +35 -0
  79. package/build/src/ast/shared/emit/registry-emitter.d.ts.map +1 -0
  80. package/build/src/ast/shared/emit/registry-emitter.js +39 -0
  81. package/build/src/ast/shared/emit/registry-emitter.js.map +1 -0
  82. package/build/src/ast/shared/emit/ts-emit-core.d.ts +79 -0
  83. package/build/src/ast/shared/emit/ts-emit-core.d.ts.map +1 -0
  84. package/build/src/ast/shared/emit/ts-emit-core.js +135 -0
  85. package/build/src/ast/shared/emit/ts-emit-core.js.map +1 -0
  86. package/build/src/ast/shared/emit/ts-emit-options.d.ts +29 -0
  87. package/build/src/ast/shared/emit/ts-emit-options.d.ts.map +1 -0
  88. package/build/src/ast/shared/emit/ts-emit-options.js +29 -0
  89. package/build/src/ast/shared/emit/ts-emit-options.js.map +1 -0
  90. package/build/src/base.d.ts +21 -0
  91. package/build/src/base.d.ts.map +1 -0
  92. package/build/src/base.js +19 -0
  93. package/build/src/base.js.map +1 -0
  94. package/build/src/cli/agents-sdk-setup.d.ts +2 -0
  95. package/build/src/cli/agents-sdk-setup.d.ts.map +1 -0
  96. package/build/src/cli/agents-sdk-setup.js +107 -0
  97. package/build/src/cli/agents-sdk-setup.js.map +1 -0
  98. package/build/src/cli/helpers.d.ts +14 -0
  99. package/build/src/cli/helpers.d.ts.map +1 -0
  100. package/build/src/cli/helpers.js +125 -0
  101. package/build/src/cli/helpers.js.map +1 -0
  102. package/build/src/cli/index.d.ts +3 -0
  103. package/build/src/cli/index.d.ts.map +1 -0
  104. package/build/src/cli/index.js +244 -0
  105. package/build/src/cli/index.js.map +1 -0
  106. package/build/src/cli/sync-progress-renderer.d.ts +20 -0
  107. package/build/src/cli/sync-progress-renderer.d.ts.map +1 -0
  108. package/build/src/cli/sync-progress-renderer.js +79 -0
  109. package/build/src/cli/sync-progress-renderer.js.map +1 -0
  110. package/build/src/cli/sync-progress.d.ts +55 -0
  111. package/build/src/cli/sync-progress.d.ts.map +1 -0
  112. package/build/src/cli/sync-progress.js +120 -0
  113. package/build/src/cli/sync-progress.js.map +1 -0
  114. package/build/src/cli/sync-report.d.ts +17 -0
  115. package/build/src/cli/sync-report.d.ts.map +1 -0
  116. package/build/src/cli/sync-report.js +86 -0
  117. package/build/src/cli/sync-report.js.map +1 -0
  118. package/build/src/client/agent/AgentClient.d.ts +84 -0
  119. package/build/src/client/agent/AgentClient.d.ts.map +1 -0
  120. package/build/src/client/agent/AgentClient.js +118 -0
  121. package/build/src/client/agent/AgentClient.js.map +1 -0
  122. package/build/src/client/database/DatabaseClient.d.ts +37 -0
  123. package/build/src/client/database/DatabaseClient.d.ts.map +1 -0
  124. package/build/src/client/database/DatabaseClient.js +328 -0
  125. package/build/src/client/database/DatabaseClient.js.map +1 -0
  126. package/build/src/client/database/create/build-create-page-parameters.d.ts +9 -0
  127. package/build/src/client/database/create/build-create-page-parameters.d.ts.map +1 -0
  128. package/build/src/client/database/create/build-create-page-parameters.js +13 -0
  129. package/build/src/client/database/create/build-create-page-parameters.js.map +1 -0
  130. package/build/src/client/database/create/index.d.ts +4 -0
  131. package/build/src/client/database/create/index.d.ts.map +1 -0
  132. package/build/src/client/database/create/index.js +4 -0
  133. package/build/src/client/database/create/index.js.map +1 -0
  134. package/build/src/client/database/create/map-to-notion-properties.d.ts +14 -0
  135. package/build/src/client/database/create/map-to-notion-properties.d.ts.map +1 -0
  136. package/build/src/client/database/create/map-to-notion-properties.js +31 -0
  137. package/build/src/client/database/create/map-to-notion-properties.js.map +1 -0
  138. package/build/src/client/database/create/property-value.d.ts +16 -0
  139. package/build/src/client/database/create/property-value.d.ts.map +1 -0
  140. package/build/src/client/database/create/property-value.js +213 -0
  141. package/build/src/client/database/create/property-value.js.map +1 -0
  142. package/build/src/client/database/query/build-query-params.d.ts +11 -0
  143. package/build/src/client/database/query/build-query-params.d.ts.map +1 -0
  144. package/build/src/client/database/query/build-query-params.js +24 -0
  145. package/build/src/client/database/query/build-query-params.js.map +1 -0
  146. package/build/src/client/database/query/build-query-response.d.ts +23 -0
  147. package/build/src/client/database/query/build-query-response.d.ts.map +1 -0
  148. package/build/src/client/database/query/build-query-response.js +41 -0
  149. package/build/src/client/database/query/build-query-response.js.map +1 -0
  150. package/build/src/client/database/query/filter/builders.d.ts +4 -0
  151. package/build/src/client/database/query/filter/builders.d.ts.map +1 -0
  152. package/build/src/client/database/query/filter/builders.js +141 -0
  153. package/build/src/client/database/query/filter/builders.js.map +1 -0
  154. package/build/src/client/database/query/filter/compound.d.ts +3 -0
  155. package/build/src/client/database/query/filter/compound.d.ts.map +1 -0
  156. package/build/src/client/database/query/filter/compound.js +13 -0
  157. package/build/src/client/database/query/filter/compound.js.map +1 -0
  158. package/build/src/client/database/query/filter/index.d.ts +3 -0
  159. package/build/src/client/database/query/filter/index.d.ts.map +1 -0
  160. package/build/src/client/database/query/filter/index.js +89 -0
  161. package/build/src/client/database/query/filter/index.js.map +1 -0
  162. package/build/src/client/database/query/http-guards.d.ts +2 -0
  163. package/build/src/client/database/query/http-guards.d.ts.map +1 -0
  164. package/build/src/client/database/query/http-guards.js +10 -0
  165. package/build/src/client/database/query/http-guards.js.map +1 -0
  166. package/build/src/client/database/query/index.d.ts +5 -0
  167. package/build/src/client/database/query/index.d.ts.map +1 -0
  168. package/build/src/client/database/query/index.js +5 -0
  169. package/build/src/client/database/query/index.js.map +1 -0
  170. package/build/src/client/database/query/normalize-page-result.d.ts +15 -0
  171. package/build/src/client/database/query/normalize-page-result.d.ts.map +1 -0
  172. package/build/src/client/database/query/normalize-page-result.js +35 -0
  173. package/build/src/client/database/query/normalize-page-result.js.map +1 -0
  174. package/build/src/client/database/query/page-collection.d.ts +42 -0
  175. package/build/src/client/database/query/page-collection.d.ts.map +1 -0
  176. package/build/src/client/database/query/page-collection.js +71 -0
  177. package/build/src/client/database/query/page-collection.js.map +1 -0
  178. package/build/src/client/database/query/projection.d.ts +9 -0
  179. package/build/src/client/database/query/projection.d.ts.map +1 -0
  180. package/build/src/client/database/query/projection.js +43 -0
  181. package/build/src/client/database/query/projection.js.map +1 -0
  182. package/build/src/client/database/query/response/checkbox.d.ts +3 -0
  183. package/build/src/client/database/query/response/checkbox.d.ts.map +1 -0
  184. package/build/src/client/database/query/response/checkbox.js +7 -0
  185. package/build/src/client/database/query/response/checkbox.js.map +1 -0
  186. package/build/src/client/database/query/response/created_by.d.ts +3 -0
  187. package/build/src/client/database/query/response/created_by.d.ts.map +1 -0
  188. package/build/src/client/database/query/response/created_by.js +8 -0
  189. package/build/src/client/database/query/response/created_by.js.map +1 -0
  190. package/build/src/client/database/query/response/created_time.d.ts +3 -0
  191. package/build/src/client/database/query/response/created_time.d.ts.map +1 -0
  192. package/build/src/client/database/query/response/created_time.js +7 -0
  193. package/build/src/client/database/query/response/created_time.js.map +1 -0
  194. package/build/src/client/database/query/response/date.d.ts +6 -0
  195. package/build/src/client/database/query/response/date.d.ts.map +1 -0
  196. package/build/src/client/database/query/response/date.js +13 -0
  197. package/build/src/client/database/query/response/date.js.map +1 -0
  198. package/build/src/client/database/query/response/email.d.ts +3 -0
  199. package/build/src/client/database/query/response/email.d.ts.map +1 -0
  200. package/build/src/client/database/query/response/email.js +7 -0
  201. package/build/src/client/database/query/response/email.js.map +1 -0
  202. package/build/src/client/database/query/response/files.d.ts +6 -0
  203. package/build/src/client/database/query/response/files.d.ts.map +1 -0
  204. package/build/src/client/database/query/response/files.js +8 -0
  205. package/build/src/client/database/query/response/files.js.map +1 -0
  206. package/build/src/client/database/query/response/index.d.ts +53 -0
  207. package/build/src/client/database/query/response/index.d.ts.map +1 -0
  208. package/build/src/client/database/query/response/index.js +44 -0
  209. package/build/src/client/database/query/response/index.js.map +1 -0
  210. package/build/src/client/database/query/response/last_edited_by.d.ts +3 -0
  211. package/build/src/client/database/query/response/last_edited_by.d.ts.map +1 -0
  212. package/build/src/client/database/query/response/last_edited_by.js +8 -0
  213. package/build/src/client/database/query/response/last_edited_by.js.map +1 -0
  214. package/build/src/client/database/query/response/last_edited_time.d.ts +3 -0
  215. package/build/src/client/database/query/response/last_edited_time.d.ts.map +1 -0
  216. package/build/src/client/database/query/response/last_edited_time.js +7 -0
  217. package/build/src/client/database/query/response/last_edited_time.js.map +1 -0
  218. package/build/src/client/database/query/response/multi_select.d.ts +3 -0
  219. package/build/src/client/database/query/response/multi_select.d.ts.map +1 -0
  220. package/build/src/client/database/query/response/multi_select.js +10 -0
  221. package/build/src/client/database/query/response/multi_select.js.map +1 -0
  222. package/build/src/client/database/query/response/number.d.ts +3 -0
  223. package/build/src/client/database/query/response/number.d.ts.map +1 -0
  224. package/build/src/client/database/query/response/number.js +7 -0
  225. package/build/src/client/database/query/response/number.js.map +1 -0
  226. package/build/src/client/database/query/response/people.d.ts +3 -0
  227. package/build/src/client/database/query/response/people.d.ts.map +1 -0
  228. package/build/src/client/database/query/response/people.js +13 -0
  229. package/build/src/client/database/query/response/people.js.map +1 -0
  230. package/build/src/client/database/query/response/phone_number.d.ts +3 -0
  231. package/build/src/client/database/query/response/phone_number.d.ts.map +1 -0
  232. package/build/src/client/database/query/response/phone_number.js +7 -0
  233. package/build/src/client/database/query/response/phone_number.js.map +1 -0
  234. package/build/src/client/database/query/response/relation.d.ts +4 -0
  235. package/build/src/client/database/query/response/relation.d.ts.map +1 -0
  236. package/build/src/client/database/query/response/relation.js +14 -0
  237. package/build/src/client/database/query/response/relation.js.map +1 -0
  238. package/build/src/client/database/query/response/rich_text.d.ts +3 -0
  239. package/build/src/client/database/query/response/rich_text.d.ts.map +1 -0
  240. package/build/src/client/database/query/response/rich_text.js +12 -0
  241. package/build/src/client/database/query/response/rich_text.js.map +1 -0
  242. package/build/src/client/database/query/response/select.d.ts +3 -0
  243. package/build/src/client/database/query/response/select.d.ts.map +1 -0
  244. package/build/src/client/database/query/response/select.js +7 -0
  245. package/build/src/client/database/query/response/select.js.map +1 -0
  246. package/build/src/client/database/query/response/shared.d.ts +6 -0
  247. package/build/src/client/database/query/response/shared.d.ts.map +1 -0
  248. package/build/src/client/database/query/response/shared.js +41 -0
  249. package/build/src/client/database/query/response/shared.js.map +1 -0
  250. package/build/src/client/database/query/response/status.d.ts +3 -0
  251. package/build/src/client/database/query/response/status.d.ts.map +1 -0
  252. package/build/src/client/database/query/response/status.js +7 -0
  253. package/build/src/client/database/query/response/status.js.map +1 -0
  254. package/build/src/client/database/query/response/title.d.ts +3 -0
  255. package/build/src/client/database/query/response/title.d.ts.map +1 -0
  256. package/build/src/client/database/query/response/title.js +12 -0
  257. package/build/src/client/database/query/response/title.js.map +1 -0
  258. package/build/src/client/database/query/response/unique_id.d.ts +3 -0
  259. package/build/src/client/database/query/response/unique_id.d.ts.map +1 -0
  260. package/build/src/client/database/query/response/unique_id.js +14 -0
  261. package/build/src/client/database/query/response/unique_id.js.map +1 -0
  262. package/build/src/client/database/query/response/url.d.ts +3 -0
  263. package/build/src/client/database/query/response/url.d.ts.map +1 -0
  264. package/build/src/client/database/query/response/url.js +7 -0
  265. package/build/src/client/database/query/response/url.js.map +1 -0
  266. package/build/src/client/database/query/schema-drift-validation.d.ts +31 -0
  267. package/build/src/client/database/query/schema-drift-validation.d.ts.map +1 -0
  268. package/build/src/client/database/query/schema-drift-validation.js +68 -0
  269. package/build/src/client/database/query/schema-drift-validation.js.map +1 -0
  270. package/build/src/client/database/query/sort-transform.d.ts +6 -0
  271. package/build/src/client/database/query/sort-transform.d.ts.map +1 -0
  272. package/build/src/client/database/query/sort-transform.js +13 -0
  273. package/build/src/client/database/query/sort-transform.js.map +1 -0
  274. package/build/src/client/database/query/types.d.ts +42 -0
  275. package/build/src/client/database/query/types.d.ts.map +1 -0
  276. package/build/src/client/database/query/types.js +2 -0
  277. package/build/src/client/database/query/types.js.map +1 -0
  278. package/build/src/client/database/schema-builder.d.ts +8 -0
  279. package/build/src/client/database/schema-builder.d.ts.map +1 -0
  280. package/build/src/client/database/schema-builder.js +78 -0
  281. package/build/src/client/database/schema-builder.js.map +1 -0
  282. package/build/src/client/database/types/crud.d.ts +40 -0
  283. package/build/src/client/database/types/crud.d.ts.map +1 -0
  284. package/build/src/client/database/types/crud.js +5 -0
  285. package/build/src/client/database/types/crud.js.map +1 -0
  286. package/build/src/client/database/types/filter-capability.d.ts +30 -0
  287. package/build/src/client/database/types/filter-capability.d.ts.map +1 -0
  288. package/build/src/client/database/types/filter-capability.js +28 -0
  289. package/build/src/client/database/types/filter-capability.js.map +1 -0
  290. package/build/src/client/database/types/index.d.ts +16 -0
  291. package/build/src/client/database/types/index.d.ts.map +1 -0
  292. package/build/src/client/database/types/index.js +16 -0
  293. package/build/src/client/database/types/index.js.map +1 -0
  294. package/build/src/client/database/types/notion-database-id.d.ts +14 -0
  295. package/build/src/client/database/types/notion-database-id.d.ts.map +1 -0
  296. package/build/src/client/database/types/notion-database-id.js +9 -0
  297. package/build/src/client/database/types/notion-database-id.js.map +1 -0
  298. package/build/src/client/database/types/notion-filter-model.d.ts +98 -0
  299. package/build/src/client/database/types/notion-filter-model.d.ts.map +1 -0
  300. package/build/src/client/database/types/notion-filter-model.js +5 -0
  301. package/build/src/client/database/types/notion-filter-model.js.map +1 -0
  302. package/build/src/client/database/types/notion-id-brand.d.ts +27 -0
  303. package/build/src/client/database/types/notion-id-brand.d.ts.map +1 -0
  304. package/build/src/client/database/types/notion-id-brand.js +8 -0
  305. package/build/src/client/database/types/notion-id-brand.js.map +1 -0
  306. package/build/src/client/database/types/notion-page-id.d.ts +10 -0
  307. package/build/src/client/database/types/notion-page-id.d.ts.map +1 -0
  308. package/build/src/client/database/types/notion-page-id.js +6 -0
  309. package/build/src/client/database/types/notion-page-id.js.map +1 -0
  310. package/build/src/client/database/types/notion-user-id.d.ts +10 -0
  311. package/build/src/client/database/types/notion-user-id.d.ts.map +1 -0
  312. package/build/src/client/database/types/notion-user-id.js +6 -0
  313. package/build/src/client/database/types/notion-user-id.js.map +1 -0
  314. package/build/src/client/database/types/projection.d.ts +78 -0
  315. package/build/src/client/database/types/projection.d.ts.map +1 -0
  316. package/build/src/client/database/types/projection.js +6 -0
  317. package/build/src/client/database/types/projection.js.map +1 -0
  318. package/build/src/client/database/types/query-filter.d.ts +19 -0
  319. package/build/src/client/database/types/query-filter.d.ts.map +1 -0
  320. package/build/src/client/database/types/query-filter.js +5 -0
  321. package/build/src/client/database/types/query-filter.js.map +1 -0
  322. package/build/src/client/database/types/query-object.d.ts +42 -0
  323. package/build/src/client/database/types/query-object.d.ts.map +1 -0
  324. package/build/src/client/database/types/query-object.js +5 -0
  325. package/build/src/client/database/types/query-object.js.map +1 -0
  326. package/build/src/client/database/types/schema.d.ts +190 -0
  327. package/build/src/client/database/types/schema.d.ts.map +1 -0
  328. package/build/src/client/database/types/schema.js +41 -0
  329. package/build/src/client/database/types/schema.js.map +1 -0
  330. package/build/src/client/database/types/sort.d.ts +22 -0
  331. package/build/src/client/database/types/sort.d.ts.map +1 -0
  332. package/build/src/client/database/types/sort.js +5 -0
  333. package/build/src/client/database/types/sort.js.map +1 -0
  334. package/build/src/config/findConfigFile.d.ts +8 -0
  335. package/build/src/config/findConfigFile.d.ts.map +1 -0
  336. package/build/src/config/findConfigFile.js +18 -0
  337. package/build/src/config/findConfigFile.js.map +1 -0
  338. package/build/src/config/helpers.d.ts +7 -0
  339. package/build/src/config/helpers.d.ts.map +1 -0
  340. package/build/src/config/helpers.js +57 -0
  341. package/build/src/config/helpers.js.map +1 -0
  342. package/build/src/config/init.d.ts +7 -0
  343. package/build/src/config/init.d.ts.map +1 -0
  344. package/build/src/config/init.js +28 -0
  345. package/build/src/config/init.js.map +1 -0
  346. package/build/src/config/loadConfig.d.ts +11 -0
  347. package/build/src/config/loadConfig.d.ts.map +1 -0
  348. package/build/src/config/loadConfig.js +91 -0
  349. package/build/src/config/loadConfig.js.map +1 -0
  350. package/build/src/config/loadDotEnvFromCwd.d.ts +12 -0
  351. package/build/src/config/loadDotEnvFromCwd.d.ts.map +1 -0
  352. package/build/src/config/loadDotEnvFromCwd.js +47 -0
  353. package/build/src/config/loadDotEnvFromCwd.js.map +1 -0
  354. package/build/src/config/notion-config-filenames.d.ts +20 -0
  355. package/build/src/config/notion-config-filenames.d.ts.map +1 -0
  356. package/build/src/config/notion-config-filenames.js +24 -0
  357. package/build/src/config/notion-config-filenames.js.map +1 -0
  358. package/build/src/config/resolveNotionAuth.d.ts +18 -0
  359. package/build/src/config/resolveNotionAuth.d.ts.map +1 -0
  360. package/build/src/config/resolveNotionAuth.js +24 -0
  361. package/build/src/config/resolveNotionAuth.js.map +1 -0
  362. package/build/src/config/types.d.ts +16 -0
  363. package/build/src/config/types.d.ts.map +1 -0
  364. package/build/src/config/types.js +7 -0
  365. package/build/src/config/types.js.map +1 -0
  366. package/build/src/helpers.d.ts +22 -0
  367. package/build/src/helpers.d.ts.map +1 -0
  368. package/build/src/helpers.js +67 -0
  369. package/build/src/helpers.js.map +1 -0
  370. package/build/src/index.d.ts +15 -11
  371. package/build/src/index.d.ts.map +1 -1
  372. package/build/src/index.js +11 -116
  373. package/build/src/index.js.map +1 -1
  374. package/build/src/notion-id-patterns.d.ts +9 -0
  375. package/build/src/notion-id-patterns.d.ts.map +1 -0
  376. package/build/src/notion-id-patterns.js +9 -0
  377. package/build/src/notion-id-patterns.js.map +1 -0
  378. package/build/src/runtime-constants.d.ts +13 -0
  379. package/build/src/runtime-constants.d.ts.map +1 -0
  380. package/build/src/runtime-constants.js +13 -0
  381. package/build/src/runtime-constants.js.map +1 -0
  382. package/build/src/typeUtils.d.ts +77 -0
  383. package/build/src/typeUtils.d.ts.map +1 -0
  384. package/build/src/typeUtils.js +52 -0
  385. package/build/src/typeUtils.js.map +1 -0
  386. package/package.json +86 -32
  387. package/build/src/BuildCall.d.ts +0 -45
  388. package/build/src/BuildCall.d.ts.map +0 -1
  389. package/build/src/BuildCall.js +0 -114
  390. package/build/src/BuildCall.js.map +0 -1
  391. package/build/src/DatabaseActions.d.ts +0 -19
  392. package/build/src/DatabaseActions.d.ts.map +0 -1
  393. package/build/src/DatabaseActions.js +0 -158
  394. package/build/src/DatabaseActions.js.map +0 -1
  395. package/build/src/GenerateTypes.d.ts +0 -8
  396. package/build/src/GenerateTypes.d.ts.map +0 -1
  397. package/build/src/GenerateTypes.js +0 -257
  398. package/build/src/GenerateTypes.js.map +0 -1
  399. package/build/src/cli.d.ts +0 -3
  400. package/build/src/cli.d.ts.map +0 -1
  401. package/build/src/cli.js +0 -48
  402. package/build/src/cli.js.map +0 -1
  403. package/build/src/queryTypes.d.ts +0 -117
  404. package/build/src/queryTypes.d.ts.map +0 -1
  405. package/build/src/queryTypes.js +0 -7
  406. package/build/src/queryTypes.js.map +0 -1
package/README.md CHANGED
@@ -1,132 +1,472 @@
1
1
  # Notion ORM
2
2
 
3
- <aside>
4
- 👉 This package is currently still in development.
3
+ A lightweight TypeScript [Notion API](https://developers.notion.com/) wrapper that aims to improve interactions with databases and custom agents, by leveraging static schema types
5
4
 
6
- </aside>
5
+ ## Key Features
7
6
 
8
- # Description
7
+ - Type inference when interacting with databases (e.g, `add` and `query`)
8
+ - Sync remote schema changes in single command
9
+ - Quickly start/resume chat streams with your agents
10
+ - Access exported property values, schemas, and types
11
+ - Logs console warnings when local vs remote schema drift is detected
9
12
 
10
- A library to simplify interacting with [Notion](https://notion.so/product) databases/tables via Notion API
13
+ ## Installation
11
14
 
12
- ## Disclaimer
13
- ### Available Database Features
14
- - Adding
15
- - Querying
15
+ ```bash
16
+ npm install @haustle/notion-orm
17
+ # or: pnpm add / yarn add / bun add @haustle/notion-orm
18
+ ```
19
+
20
+ The CLI is installed as the `**notion**` binary and runs on **Node.js 18+** (the published shebang is `node`). After upgrading the package, run `**npx notion sync`** (or `**pnpm exec notion sync**`, `**yarn notion sync**`, `**bunx notion sync**`) so generated files under `**notion/**` stay in sync with the version you installed (stale codegen can break at runtime when imports from the ORM package change). In app code, prefer `**import { NotionORM } from "./notion/"**` — the directory import resolves to `index.ts`, so you do not need to spell `**index**`.
21
+
22
+ **Config file:** use `**notion.config.js`** or `**notion.config.mjs**` if you run the CLI with plain Node. `**notion.config.ts**` is supported when your runtime can load TypeScript (for example Bun or a project using a TS loader); otherwise compile the config or use JavaScript.
16
23
 
17
- ### Supported Column Types
18
- - Multiselect
19
- - Select
20
- - Status
21
- - Date
22
- - Text
23
- - Url
24
- - Checkbox
25
- - Email
26
- - Phone Number
24
+ Generated database and agent modules live in your app's local `**./notion/**` folder after `notion sync`; import those relative files directly if you need a generated factory outside the `NotionORM` wrapper.
27
25
 
28
- # Install and Setup
26
+ # Quick start
27
+
28
+ Initialize config from your project root (recommended):
29
29
 
30
30
  ```bash
31
- npm install @haustle/notion-orm
31
+ npx notion init
32
+ ```
33
+
34
+ Generated config shape:
35
+
36
+ ```ts
37
+ // notion.config.ts
38
+
39
+ // If you don't have an API key, sign up for free
40
+ // [here](https://developers.notion.com)
41
+
42
+ const auth = process.env.NOTION_KEY || "your-notion-api-key-here";
43
+ const NotionConfig = {
44
+ auth,
45
+ databases: [
46
+ // Use: notion add <database-id>
47
+ ],
48
+ agents: [
49
+ // Auto-populated by: notion sync
50
+ ],
51
+ };
52
+
53
+ export default NotionConfig;
54
+ ```
55
+
56
+ ### Adding databases
57
+
58
+ Add new database to track and generate static types (ex. how to find ID [here](https://developers.notion.com/guides/data-apis/working-with-databases#adding-pages-to-a-database) )
59
+
60
+ ```bash
61
+ npx notion add <database-id>
32
62
  ```
33
63
 
34
- The only requirement is a Notion Developer API Key ([here](https://developers.notion.com/)) and database IDs you want
35
-
36
- 1. At the root of your project create pass your developer key and database IDs ([help](https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping)).
37
- ```
38
- Copy database/table URL
39
- https://www.notion.so/haustle/<This-is-the-database-id>?v=123
40
- ```
41
- ```jsx
42
- // notion.config.js
43
-
44
- const NotionConfig = {
45
- auth: process.env.NOTION_KEY,
46
- databaseIds: [
47
- "a52239e4839d4a3a8f4875376cfbfb02",
48
- "5f4bf76a1e3f48d684d2506ea2690d64"
49
- ],
50
- };
51
-
52
- module.exports = NotionConfig;
53
- ```
54
- - Be sure to connect your integration with your tables
55
-
56
- 2. Generate Types
57
-
58
- ```bash
59
- npx notion generate
60
- ```
61
-
62
- 3. Import databases in your TypeScript file
63
-
64
- ```tsx
65
- // Barrel import, giving you access to all your databases
66
- import * as notion from "@haustle/notion-orm"
67
-
68
- // Import specific database
69
- import { databaseName } from "@haustle/notion-orm"
70
- ```
71
-
72
-
73
- # Actions
74
-
75
- ## Add a page
76
-
77
- Page title is required when adding
78
-
79
- ```tsx
80
- notion.books.add({
81
- name: "Catcher in the Rye",
82
- rating: "⭐️⭐️⭐️⭐️⭐️"
83
- })
84
- ```
85
-
86
- ## Query Database
87
-
88
- ### Single Filter
89
-
90
- ```tsx
91
- notion.books.query({
92
- filter: {
93
- genre: {
94
- contains: "Sci-Fi"
95
- }
96
- }
97
- })
98
- ```
99
-
100
- ### Nested Filters
101
-
102
- ```tsx
103
- await notion.books.query({
104
- filter: {
64
+ ### Adding agents (paid feature)
65
+
66
+ Agent support requires the [Notion Agents SDK](https://github.com/makenotion/notion-agents-sdk-js), which is **currently in alpha** and not published to npm. Because of this, a one-command setup handles the entire download-and-install flow for you:
67
+
68
+ ```bash
69
+ npx notion setup-agents-sdk
70
+ ```
71
+
72
+ **What this does:**
73
+
74
+ 1. Clones the SDK repository into a local cache (`node_modules/.cache/.notion-agents-sdk`)
75
+ 2. Installs the SDK's dependencies and builds it
76
+ 3. Adds the built `@notionhq/agents-client` package to your project
77
+
78
+ After setup, run `notion sync` to generate agent types. Agents linked to your integration are automatically discovered.
79
+
80
+ **Updating:** When the upstream SDK receives changes, rerun the same command. It pulls the latest from the cached clone, rebuilds, and reinstalls:
81
+
82
+ ```bash
83
+ npx notion setup-agents-sdk
84
+ npx notion sync
85
+ ```
86
+
87
+ If you have not run the setup command, `notion sync` will skip agent generation and only produce database types. Once the SDK is published to npm, this step will no longer be necessary.
88
+
89
+ Learn more about [Custom Agents](https://www.notion.com/help/custom-agents) in the Notion documentation.
90
+
91
+ ### Full sync command (`notion sync`)
92
+
93
+ Fetch/refresh database schemas. If the agents SDK is installed, also syncs custom agents.
94
+
95
+ ```bash
96
+ npx notion sync
97
+ ```
98
+
99
+ ## Basic examples
100
+
101
+ ### Create page in a database
102
+
103
+ ```ts
104
+ await notion.databases.books.create({
105
+ icon: {
106
+ type: "emoji",
107
+ emoji: "📕",
108
+ },
109
+ // Expected <key,value> is constrained to `books` database schema
110
+ properties: {
111
+ bookName: "Creativity, Inc.",
112
+ genre: ["Non-fiction"],
113
+ publishDate: {
114
+ start: "2026-03-01",
115
+ },
116
+ },
117
+ });
118
+
119
+ ```
120
+
121
+ ### Query/filter database
122
+
123
+ ```ts
124
+ const books = await notion.databases.books.findMany({
125
+ where: {
126
+ and: [
127
+ { genre: { contains: "Non-fiction" } },
128
+ { publishDate: { on_or_after: "2026-01-01" } },
129
+ {
105
130
  or: [
106
- {
107
- genre: {
108
- contains: "Sci-Fi",
109
- },
110
- },
111
- {
112
- genre: {
113
- contains: "Biography",
114
- },
115
- },
131
+ { bookName: { contains: "Creativity" } },
132
+ { bookName: { contains: "Innovation" } },
116
133
  ],
134
+ },
135
+ ],
136
+ },
137
+ sortBy: [{ property: "bookName", direction: "ascending" }],
138
+ select: ["bookName", "genre"],
139
+ });
140
+
141
+ ```
142
+
143
+ ### Chat with agent
144
+
145
+ ```ts
146
+ const chat = await notion.agents.helpBot.chat({message: "Is the company closed today"})
147
+ await notion.agents.helpBot.pollThread(chat.threadId)
148
+ const messages = await notion.agents.helpBot.getMessages(chat.threadId, {
149
+ role: "agent",
150
+ });
151
+ ```
152
+
153
+ ### Chat with agent (stream)
154
+
155
+ ```ts
156
+ const thread = await notion.agents.helpBot.chatStream({
157
+ message: "How can I update my shipping address?",
158
+ onMessage: ({content, role}) => (msg.content),
159
+ });
160
+
161
+ ```
162
+
163
+ # Implementation
164
+
165
+ ### Client setup
166
+
167
+ Create a single ORM instance with your Notion integration key. Import from the generated `**notion/**` folder (directory specifier → `index`):
168
+
169
+ ```ts
170
+ import { NotionORM } from "./notion/";
171
+
172
+ const notion = new NotionORM({
173
+ auth: process.env.NOTION_KEY!,
174
+ });
175
+
176
+ const db = notion.databases.yourDatabaseName; // DatabaseClient
177
+ const agent = notion.agents.yourAgentName; // AgentClient
178
+ ```
179
+
180
+ Generated database and agent names are camelCased and exposed on an instance of `NotionORM`.
181
+
182
+ - Use `notion.databases.<camelCaseDatabaseName>` for typed CRUD + query operations (`findMany`, `findFirst`, `findUnique`, `create`, `update`, `delete`, and more).
183
+ - Use `notion.agents.<camelCaseAgentName>` for `chat()`, `chatStream()`, thread helpers, and history APIs.
184
+ - For full method signatures and response shapes, see [API Reference](#api-reference).
185
+
186
+ # Available database operations
187
+
188
+ ## Adding
189
+
190
+ Only title is required by Notion for a minimal page.
191
+
192
+ ```ts
193
+ await notion.databases.books.create({
194
+ properties: {
195
+ bookName: "Raphael, Painter in Rome: a Novel", // title
196
+ author: "Stephanie Storey", // rich_text
197
+ status: "In progress", // status
198
+ numberOfPages: 307, // number
199
+ genre: ["Historical Fiction"], // multi_select
200
+ startDate: {
201
+ start: "2023-01-01",
202
+ }, // date
203
+ phone: "0000000000", // phone_number
204
+ email: "tyrus@haustle.studio", // email
205
+ },
206
+ });
207
+ ```
208
+
209
+ ## Adding page content with markdown
210
+
211
+ Pass a `markdown` string alongside `properties` to create a page with body content in a single call. This uses Notion's [enhanced markdown format](https://developers.notion.com/guides/data-apis/working-with-markdown-content#block-type-support), which supports headings, lists, code blocks, quotes, checklists, and more.
212
+
213
+ ```ts
214
+ await notion.databases.books.create({
215
+ properties: {
216
+ bookName: "Hello World",
217
+ },
218
+ markdown: "# Hello World\n\nThis is a page created with **markdown**.",
219
+ });
220
+ ```
221
+
222
+ `markdown` is mutually exclusive with `children` / `content` — use one or the other. When `properties.title` is provided, the `# h1` heading is treated as body content; when omitted, Notion extracts it as the page title.
223
+
224
+ ## Querying
225
+
226
+ Query filters are typed by your generated schema, including nested compound filters. Find Notion filter operators [here](https://developers.notion.com/reference/post-database-query-filter).
227
+
228
+ Example single filter:
229
+
230
+ ```ts
231
+ await notion.databases.books.findMany({
232
+ where: {
233
+ genre: {
234
+ contains: "Sci-Fi",
235
+ },
236
+ },
237
+ sortBy: [
238
+ {
239
+ property: "bookName",
240
+ direction: "ascending",
117
241
  },
242
+ ],
243
+ });
244
+ ```
245
+
246
+ Example compound filters:
247
+
248
+ ```ts
249
+ await notion.databases.books.findMany({
250
+ where: {
251
+ and: [
252
+ {
253
+ or: [
254
+ { genre: { contains: "Sci-Fi" } },
255
+ { genre: { contains: "Biography" } },
256
+ ],
257
+ },
258
+ { numberOfPages: { greater_than: 250 } },
259
+ ],
260
+ },
261
+ });
262
+ ```
263
+
264
+ Projection is available via `select` and `omit` string arrays:
265
+
266
+ ```ts
267
+ const response = await notion.databases.books.findMany({
268
+ where: {
269
+ genre: { contains: "Sci-Fi" },
270
+ },
271
+ select: ["bookName", "genre"],
118
272
  });
119
273
  ```
120
274
 
121
- ## What is Object Relational Map (ORM)
275
+ Successful response shape:
276
+
277
+ ```ts
278
+ [
279
+ {
280
+ bookName: "The Dream Machine",
281
+ genre: ["Non-fiction"],
282
+ },
283
+ ]
284
+ ```
285
+
286
+ ### Agents
122
287
 
123
- > …[programming](https://en.wikipedia.org/wiki/Computer_programming) technique for converting data between [type systems](https://en.wikipedia.org/wiki/Type_system) using [object-oriented](https://en.wikipedia.org/wiki/Object-oriented)  programming languages. This creates, in effect, a "virtual [object database](https://en.wikipedia.org/wiki/Object_database)" that can be used from within the programming language.
124
- >
288
+ Agents are generated from those shared with your integration and exposed at `notion.agents.*`.
125
289
 
126
- [Wikipedia](https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping)
290
+ #### Basic chat (non-streaming)
127
291
 
128
- # Story
292
+ - Useful when you want a straightforward request/response flow.
293
+ - Helpful when you plan to fetch message history after completion.
129
294
 
130
- While taking a databases class I got exposed to Prisma and thought the developer experience was magical. Around the same time the Notion Developer API was rolling out and I thought the idea of bringing creating a ORM to Notion databases would be a fun cool idea, but I was terrible at TypeScript.
295
+ ```ts
296
+ const chat = await notion.agents.yourAgentName.chat({
297
+ message: "Give me a summary of this month",
298
+ });
299
+
300
+ await notion.agents.yourAgentName.pollThread(chat.threadId);
301
+
302
+ const messages = await notion.agents.yourAgentName.getMessages(chat.threadId, {
303
+ role: "agent",
304
+ });
305
+ ```
306
+
307
+ #### Continue an existing thread
308
+
309
+ - Useful when you want to preserve context across follow-up prompts.
310
+ - Helpful for chat UIs where users continue the same conversation.
311
+
312
+ ```ts
313
+ const nextTurn = await notion.agents.yourAgentName.chat({
314
+ threadId: chat.threadId,
315
+ message: "Now turn that into a grocery list.",
316
+ });
317
+ ```
318
+
319
+ #### Streaming patterns
320
+
321
+ How to start a new chat stream (pass `threadId` to resume):
322
+
323
+ ```ts
324
+ import { AgentClient } from "@haustle/notion-orm";
325
+
326
+ const thread = await notion.agents.yourAgentName.chatStream({
327
+ message: "Generate a prep list for that plan.",
328
+
329
+ onMessage: (msg) => {
330
+ if (msg.role === "agent") process.stdout.write(msg.content);
331
+ },
332
+ });
333
+
334
+
335
+ const finalResponse = AgentClient.getAgentResponse(thread);
336
+ console.log("Thread ID:", thread.threadId);
337
+ console.log("Final:", finalResponse);
338
+ ```
339
+
340
+ See [API Reference](#api-reference) for full method signatures, `ThreadInfo` shape, and message schemas.
341
+
342
+ # API Reference
343
+
344
+ ## Runtime access (detailed)
345
+
346
+
347
+ | runtime property | type | description | go deeper |
348
+ | ------------------ | -------------------------------- | -------------------------------------------------------------- | -------------------------------------------------- |
349
+ | `notion.databases` | `Record<string, DatabaseClient>` | Generated database client map keyed by camelCase database name | [Adding](#adding), [Querying](#querying) |
350
+ | `notion.agents` | `Record<string, AgentClient>` | Generated agent client map keyed by camelCase agent name | [Agents](#agents), [Agent methods](#agent-methods) |
351
+
352
+
353
+ ## Database client methods
354
+
355
+
356
+ | member | kind | description | go deeper |
357
+ | ----------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
358
+ | `id` | property | Notion data source ID used by this client instance | - |
359
+ | `name` | property | Human-readable database name captured during generation | - |
360
+ | `findMany({ where?, sortBy?, size?, select?, omit?, stream?, after? })` | method | Queries database pages with typed filters, projection, pagination, or streaming | [Querying](#querying), [Supported database properties](#supported-database-properties) |
361
+ | `findFirst({ where?, sortBy?, select?, omit? })` | method | Returns the first matching row or `null` | [Querying](#querying) |
362
+ | `findUnique({ where: { id }, select?, omit? })` | method | Fetches a row by page ID with optional projection | [Querying](#querying) |
363
+ | `create({ properties, icon?, cover?, markdown? })` | method | Creates a page with optional [markdown body content](https://developers.notion.com/guides/data-apis/working-with-markdown-content#block-type-support) | [Adding](#adding), [Markdown](#adding-page-content-with-markdown) |
364
+
365
+
366
+ ## Agent methods
367
+
368
+
369
+ | member | kind | description | go deeper |
370
+ | ------------------------------------------------ | -------- | --------------------------------------------------------------- | -------------------------------------------------------------------- |
371
+ | `id` | property | Notion agent ID used by this client instance | - |
372
+ | `name` | property | Human-readable agent name | - |
373
+ | `icon` | property | Normalized agent icon metadata (or `null`) | - |
374
+ | `listThreads()` | method | Lists recent threads with `id`, `title`, and `status` | [Thread response shapes](#thread-response-shapes) |
375
+ | `getThreadInfo(threadId)` | method | Fetches a single thread record | [Thread response shapes](#thread-response-shapes) |
376
+ | `getThreadTitle(threadId)` | method | Convenience helper to fetch just the thread title | [Thread response shapes](#thread-response-shapes) |
377
+ | `chat({ message, threadId? })` | method | Sends a message and creates/resumes a thread | [Agents](#agents), [Thread response shapes](#thread-response-shapes) |
378
+ | `chatStream({ message, threadId?, onMessage? })` | method | Streams messages and returns final `ThreadInfo` | [Agents](#agents), [Thread response shapes](#thread-response-shapes) |
379
+ | `getMessages(threadId, { role? })` | method | Gets full (or role-filtered) message history | [Thread response shapes](#thread-response-shapes) |
380
+ | `pollThread(threadId, options?)` | method | Polls until thread processing completes | [Thread response shapes](#thread-response-shapes) |
381
+ | `AgentClient.getAgentResponse(threadInfo)` | method | Extract combined plain-text agent output from a streamed thread | [Thread response shapes](#thread-response-shapes) |
382
+
383
+
384
+ ## Generated exports
385
+
386
+
387
+ | import path | what you get | when to use |
388
+ | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
389
+ | `./notion/` (relative) | `NotionORM` class (generated entry; same as `./notion/index` but shorter) | Typical app code after `**notion sync**` |
390
+ | `./notion/databases/<DatabaseName>.js` | `<DatabaseName>(auth)` factory, `PageSchema`, `CreateSchema`, `QuerySchema`, generated Zod schema, generated option tuples (for select/status/multi-select), schema/type aliases | Script-level direct DB usage without the `NotionORM` wrapper |
391
+ | `./notion/agents/<AgentName>.js` | `<AgentName>(auth)` factory that returns an `AgentClient` (PascalCase export; registry keys on `notion.agents` stay camelCase) | Script-level direct agent usage |
392
+ | `./notion/databases/index.js` | `databases` barrel object (all database factories) | Dynamic database selection or custom registry wiring |
393
+ | `./notion/agents/index.js` | `agents` barrel object (all agent factories) | Dynamic agent selection or custom registry wiring |
394
+
395
+
396
+ ## Thread response shapes
397
+
398
+ `chatStream(...)` returns `ThreadInfo` with the following properties:
399
+
400
+
401
+ | ThreadInfo property | type | description | example |
402
+ | ------------------- | --------------------- | -------------------------------------------------------- | ------------------------------------------------------ |
403
+ | `threadId` | `string` | Stable thread identifier used to continue a conversation | `"1f4e6f4a-5b58-4d91-a7fc-2f5f2a0f6bb1"` |
404
+ | `agentId` | `string` | Agent identifier that produced the response | `"2c3c495da03c8078b95500927f02d213"` |
405
+ | `messages` | `Array<{ role: "user" | "agent"; content: string }>` | Full message history currently available in the thread |
406
+
407
+
408
+ `messages` item shape:
409
+
410
+
411
+ | message property | type | description |
412
+ | ---------------- | -------- | -------------------------- |
413
+ | `role` | `user` | `agent` (`string`) |
414
+ | `content` | `string` | Plain text message content |
415
+
416
+
417
+ ## Supported database properties
418
+
419
+
420
+ | property_type | expected returned shape | example value |
421
+ | ------------------ | -------------------------------------- | --------------------------------------------- |
422
+ | `title` | `string` | `"The Dream Machine"` |
423
+ | `rich_text` | `string` | `"Long-form notes from the page"` |
424
+ | `number` | `number` | `460` |
425
+ | `date` | `{ start: string; end: string }` | `{ start: "2026-03-01", end: "2026-03-02" }` |
426
+ | `status` | `string` | `"In progress"` |
427
+ | `select` | `string` | `"Non-fiction"` |
428
+ | `multi_select` | `string[]` | `["Sci-Fi", "Biography"]` |
429
+ | `checkbox` | `boolean` | `true` |
430
+ | `email` | `string` | `"tyrus@haustle.studio"` |
431
+ | `phone_number` | `string` | `"0000000000"` |
432
+ | `url` | `string` | `"https://developers.notion.com/"` |
433
+ | `files` | `Array<{ name: string; url: string }>` | `[{ name: "brief.pdf", url: "https://..." }]` |
434
+ | `people` | `string[]` | `["1f4e6f4a-5b58-4d91-a7fc-2f5f2a0f6bb1"]` |
435
+ | `relation` | `string[]` | `["6f7f9cbf-8d45-48f8-a194-661e73f7f5d9"]` |
436
+ | `created_by` | `string` | `"Ada Lovelace"` |
437
+ | `last_edited_by` | `string` | `"user_123"` |
438
+ | `created_time` | `string` | `"2026-03-01T10:30:00.000Z"` |
439
+ | `last_edited_time` | `string` | `"2026-03-01T13:15:00.000Z"` |
440
+ | `unique_id` | `string` | `"TASK-42"` |
441
+
442
+
443
+ ## Unsupported properties
444
+
445
+ `rollup` and `formula` are intentionally unsupported.
446
+
447
+ - `formula`: Notion computes formula values at read time, and the actual output shape depends on the formula expression and its current result type. That makes it a poor fit for the generated static schema this client exposes. Because we cannot provide a stable contract for reads, writes, or filters, formula properties are skipped entirely during code generation.
448
+ - `rollup`: Rollup values are polymorphic and still need additional normalization before we can expose them as a predictable typed contract.
449
+
450
+ All supported properties can be used in typed filters. Formula properties are not surfaced in the generated client at all, so they are unavailable for selection, filtering, and normalized query results.
451
+
452
+ ## Project Structure
453
+
454
+ ```txt
455
+ .
456
+ ├── src
457
+ │ ├── cli # notion init / add / sync / setup-agents-sdk
458
+ │ ├── config # config discovery, loading, and validation
459
+ │ ├── client # runtime DatabaseClient + AgentClient
460
+ │ │ └── query # typed filters + response simplification
461
+ │ ├── ast # code generation internals
462
+ │ │ ├── database
463
+ │ │ ├── agents
464
+ │ │ └── shared
465
+ │ └── types # local type bridges
466
+ ├── plugins # lint/tooling helpers
467
+ └── notion # generated output (after notion sync)
468
+ ├── index.* # import as ./notion/
469
+ ├── databases
470
+ └── agents
471
+ ```
131
472
 
132
- This project was started as a way to strengthen my TypeScript knowledge. I’ve succeeded in some regard, but there are still a few `@ts-ignore` in the project.
@@ -0,0 +1,8 @@
1
+ export declare const AGENTS_SDK_SETUP_COMMAND = "notion setup-agents-sdk";
2
+ export declare const AGENTS_SDK_REPO_URL = "https://github.com/makenotion/notion-agents-sdk-js.git";
3
+ /** Filesystem probe instead of `createRequire` so resolution works the same in Node and other runtimes. */
4
+ export declare function isAgentsSdkAvailable(): boolean;
5
+ export declare function loadAgentsSdk(): Promise<typeof import("@notionhq/agents-client")>;
6
+ /** Inlined so `AgentClient.getAgentResponse` works without eagerly importing the SDK. */
7
+ export declare function stripLangTags(text: string): string;
8
+ //# sourceMappingURL=agents-sdk-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents-sdk-resolver.d.ts","sourceRoot":"","sources":["../../src/agents-sdk-resolver.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,wBAAwB,4BAA4B,CAAC;AAElE,eAAO,MAAM,mBAAmB,2DACyB,CAAC;AAM1D,2GAA2G;AAC3G,wBAAgB,oBAAoB,IAAI,OAAO,CAQ9C;AAED,wBAAsB,aAAa,IAAI,OAAO,CAC7C,cAAc,yBAAyB,CAAC,CACxC,CAKA;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD"}
@@ -0,0 +1,23 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ const AGENTS_SDK_PACKAGE = "@notionhq/agents-client";
4
+ export const AGENTS_SDK_SETUP_COMMAND = "notion setup-agents-sdk";
5
+ export const AGENTS_SDK_REPO_URL = "https://github.com/makenotion/notion-agents-sdk-js.git";
6
+ const AGENTS_SDK_MISSING_MESSAGE = `Agent support requires the Notion Agents SDK (paid feature).\n` +
7
+ `Run \`${AGENTS_SDK_SETUP_COMMAND}\` to install it, then run \`notion sync\`.`;
8
+ /** Filesystem probe instead of `createRequire` so resolution works the same in Node and other runtimes. */
9
+ export function isAgentsSdkAvailable() {
10
+ const sdkPackageJson = path.join(process.cwd(), "node_modules", ...AGENTS_SDK_PACKAGE.split("/"), "package.json");
11
+ return fs.existsSync(sdkPackageJson);
12
+ }
13
+ export async function loadAgentsSdk() {
14
+ if (!isAgentsSdkAvailable()) {
15
+ throw new Error(AGENTS_SDK_MISSING_MESSAGE);
16
+ }
17
+ return import(AGENTS_SDK_PACKAGE);
18
+ }
19
+ /** Inlined so `AgentClient.getAgentResponse` works without eagerly importing the SDK. */
20
+ export function stripLangTags(text) {
21
+ return text.replace(/<\/?lang[^>]*>/g, "");
22
+ }
23
+ //# sourceMappingURL=agents-sdk-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agents-sdk-resolver.js","sourceRoot":"","sources":["../../src/agents-sdk-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,kBAAkB,GAAG,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,wBAAwB,GAAG,yBAAyB,CAAC;AAElE,MAAM,CAAC,MAAM,mBAAmB,GAC/B,wDAAwD,CAAC;AAE1D,MAAM,0BAA0B,GAC/B,gEAAgE;IAChE,SAAS,wBAAwB,6CAA6C,CAAC;AAEhF,2GAA2G;AAC3G,MAAM,UAAU,oBAAoB;IACnC,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAC/B,OAAO,CAAC,GAAG,EAAE,EACb,cAAc,EACd,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,EAChC,cAAc,CACd,CAAC;IACF,OAAO,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa;IAGlC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,MAAM,CAAC,kBAAkB,CAAC,CAAC;AACnC,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,aAAa,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { AgentIcon } from "../../client/agent/AgentClient";
2
+ import { type CodegenEnvironment } from "../shared/codegen-environment";
3
+ export declare function renderAgentModule(args: {
4
+ agentId: string;
5
+ agentName: string;
6
+ agentIcon: AgentIcon;
7
+ agentModuleName?: string;
8
+ }): {
9
+ tsCode: string;
10
+ agentId: string;
11
+ agentName: string;
12
+ agentModuleName: string;
13
+ };
14
+ export declare function createTypescriptFileForAgent(args: {
15
+ agentId: string;
16
+ agentName: string;
17
+ agentModuleName: string;
18
+ agentIcon: AgentIcon;
19
+ environment: CodegenEnvironment;
20
+ }): Promise<void>;
21
+ //# sourceMappingURL=agent-file-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-file-writer.d.ts","sourceRoot":"","sources":["../../../../src/ast/agents/agent-file-writer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAIhE,OAAO,EACN,KAAK,kBAAkB,EAEvB,MAAM,+BAA+B,CAAC;AAwLvC,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;CACxB,CAQA;AAED,wBAAsB,4BAA4B,CAAC,IAAI,EAAE;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,kBAAkB,CAAC;CAChC,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBhB"}