@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
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Core schema value shapes and Notion column-type unions for database clients.
3
+ */
4
+ import type { DataSourceObjectResponse } from "@notionhq/client/build/src/api-endpoints";
5
+ import type { Simplify } from "../../../typeUtils";
6
+ import type { NotionDatabaseId } from "./notion-database-id";
7
+ import type { NotionPageId } from "./notion-page-id";
8
+ type NotionPropertyTypeToConfigMap = DataSourceObjectResponse["properties"];
9
+ export type DatabasePropertyType = NotionPropertyTypeToConfigMap[keyof NotionPropertyTypeToConfigMap]["type"];
10
+ /**
11
+ * Union of all value types a database property can hold (read or write).
12
+ * Used as the base constraint for schema generics throughout the client.
13
+ */
14
+ export type DatabasePropertyValue = string | number | boolean | undefined | null | string[] | NotionPageId[] | {
15
+ name: string;
16
+ url: string;
17
+ }[] | {
18
+ start: string;
19
+ end?: string | null;
20
+ };
21
+ export type SchemaRecord = Record<string, DatabasePropertyValue>;
22
+ export type ColumnTypeMap<Schema extends SchemaRecord> = Record<keyof Schema, SupportedNotionColumnType>;
23
+ export declare const SUPPORTED_PROPERTY_TYPES: {
24
+ readonly formula: false;
25
+ readonly files: true;
26
+ readonly people: true;
27
+ readonly relation: true;
28
+ readonly rollup: false;
29
+ readonly created_by: true;
30
+ readonly last_edited_by: true;
31
+ readonly created_time: true;
32
+ readonly last_edited_time: true;
33
+ readonly url: true;
34
+ readonly phone_number: true;
35
+ readonly title: true;
36
+ readonly email: true;
37
+ readonly checkbox: true;
38
+ readonly date: true;
39
+ readonly multi_select: true;
40
+ readonly status: true;
41
+ readonly number: true;
42
+ readonly rich_text: true;
43
+ readonly select: true;
44
+ readonly unique_id: true;
45
+ };
46
+ export declare function isSupportedPropertyType(propertyType: DatabasePropertyType): propertyType is SupportedNotionColumnType;
47
+ export type SupportedNotionColumnType = {
48
+ [K in keyof typeof SUPPORTED_PROPERTY_TYPES]: (typeof SUPPORTED_PROPERTY_TYPES)[K] extends true ? K : never;
49
+ }[keyof typeof SUPPORTED_PROPERTY_TYPES];
50
+ /**
51
+ * Notion column types whose generated `columns` metadata includes a fixed
52
+ * `options` list (select-like properties).
53
+ */
54
+ export type ColumnTypesWithOptions = Extract<SupportedNotionColumnType, "select" | "status" | "multi_select">;
55
+ /** Runtime narrow for select / status / multi_select column metadata. */
56
+ export declare function isColumnTypesWithOptions(type: SupportedNotionColumnType): type is ColumnTypesWithOptions;
57
+ /** Shared fields for every emitted `columns` entry. */
58
+ export type ColumnDefinitionBase = {
59
+ readonly columnName: string;
60
+ };
61
+ export type SelectColumnDefinition = ColumnDefinitionBase & {
62
+ readonly type: "select";
63
+ readonly options: readonly string[];
64
+ };
65
+ export type StatusColumnDefinition = ColumnDefinitionBase & {
66
+ readonly type: "status";
67
+ readonly options: readonly string[];
68
+ };
69
+ export type MultiSelectColumnDefinition = ColumnDefinitionBase & {
70
+ readonly type: "multi_select";
71
+ readonly options: readonly string[];
72
+ };
73
+ /**
74
+ * Relation columns: Notion exposes the linked database id on the property config;
75
+ * codegen emits it as `relatedDatabaseId` (canonical undashed id) for cross-database typing.
76
+ */
77
+ export type RelationColumnDefinition = ColumnDefinitionBase & {
78
+ readonly type: "relation";
79
+ readonly relatedDatabaseId: NotionDatabaseId;
80
+ };
81
+ /**
82
+ * Maps each supported Notion property type to its emitted `columns` metadata shape.
83
+ * Select-like types use dedicated definitions with `options`; relation includes
84
+ * `relatedDatabaseId`; all others are plain `{ columnName, type }` entries keyed by the
85
+ * exact Notion `type` string.
86
+ *
87
+ * Adding a new `SupportedNotionColumnType` forces an entry here (via `Exclude` / intersection).
88
+ */
89
+ export type NotionPropertyTypeToColumnDefinitionMap = {
90
+ [K in Exclude<SupportedNotionColumnType, ColumnTypesWithOptions | "relation">]: ColumnDefinitionBase & {
91
+ readonly type: K;
92
+ };
93
+ } & {
94
+ select: SelectColumnDefinition;
95
+ status: StatusColumnDefinition;
96
+ multi_select: MultiSelectColumnDefinition;
97
+ relation: RelationColumnDefinition;
98
+ };
99
+ /**
100
+ * Column metadata for types that do not carry a fixed `options` list.
101
+ */
102
+ export type PlainColumnDefinition = NotionPropertyTypeToColumnDefinitionMap[Exclude<SupportedNotionColumnType, ColumnTypesWithOptions>];
103
+ /**
104
+ * Definition for one generated Notion column in the emitted `columns` object.
105
+ */
106
+ export type ColumnDefinition = NotionPropertyTypeToColumnDefinitionMap[SupportedNotionColumnType];
107
+ /** The full generated `columns` object keyed by ORM property name. */
108
+ export type DatabaseColumns = Record<string, ColumnDefinition>;
109
+ /**
110
+ * Base value mapping for each supported Notion column type.
111
+ * Extending Record<SupportedNotionColumnType, ...> forces a decision for new SDK types.
112
+ */
113
+ export interface NotionTypeToValueMap extends Record<SupportedNotionColumnType, DatabasePropertyValue> {
114
+ checkbox: boolean;
115
+ number: number;
116
+ date: {
117
+ start: string;
118
+ end?: string;
119
+ };
120
+ files: {
121
+ name: string;
122
+ url: string;
123
+ }[];
124
+ people: string[];
125
+ relation: NotionPageId[];
126
+ multi_select: string[];
127
+ select: string;
128
+ status: string;
129
+ title: string;
130
+ rich_text: string;
131
+ url: string;
132
+ email: string;
133
+ phone_number: string;
134
+ unique_id: string;
135
+ created_by: string;
136
+ last_edited_by: string;
137
+ created_time: string;
138
+ last_edited_time: string;
139
+ }
140
+ type InferColumnValue<Column extends ColumnDefinition> = Column extends {
141
+ type: "multi_select";
142
+ options: infer Options extends readonly string[];
143
+ } ? Array<Options[number] | (string & {})> : Column extends {
144
+ type: "select" | "status";
145
+ options: infer Options extends readonly string[];
146
+ } ? Options[number] | (string & {}) : Column extends {
147
+ type: infer Type extends SupportedNotionColumnType;
148
+ } ? NotionTypeToValueMap[Type] : never;
149
+ /** Derives the typed row shape directly from a generated `columns` object. */
150
+ export type InferDatabaseSchema<Columns extends DatabaseColumns> = Simplify<{
151
+ [Property in keyof Columns as Columns[Property]["type"] extends "title" ? Property : never]: InferColumnValue<Columns[Property]>;
152
+ } & {
153
+ [Property in keyof Columns as Columns[Property]["type"] extends "title" ? never : Property]?: InferColumnValue<Columns[Property]>;
154
+ }>;
155
+ /**
156
+ * Column types included on full query rows but not settable via this client's
157
+ * create/update mappers. Kept in lockstep with `ADD_PROPERTY_BUILDERS` in
158
+ * `create/property-value.ts` (that object uses `satisfies` against this union).
159
+ */
160
+ export type NotWritableDatabaseColumnType = "created_by" | "last_edited_by" | "created_time" | "last_edited_time" | "unique_id";
161
+ type NonWritablePropertyKeys<Columns extends DatabaseColumns> = {
162
+ [K in keyof Columns]: Columns[K]["type"] extends NotWritableDatabaseColumnType ? K : never;
163
+ }[keyof Columns];
164
+ /**
165
+ * Row fields that can be passed to create/update: drops Notion-managed columns
166
+ * the API does not accept from this client.
167
+ */
168
+ export type InferCreateSchema<Columns extends DatabaseColumns> = Simplify<Omit<InferDatabaseSchema<Columns>, NonWritablePropertyKeys<Columns>>>;
169
+ /** Bundles the row shape and property -> column-type map for one database. */
170
+ export interface DatabaseDefinition<Columns extends DatabaseColumns = DatabaseColumns> {
171
+ /** The typed row shape exposed by the client for this database. */
172
+ schema: InferDatabaseSchema<Columns>;
173
+ /** The property -> Notion column type lookup derived from `columns`. */
174
+ columns: {
175
+ [Property in keyof Columns]: Columns[Property]["type"];
176
+ };
177
+ }
178
+ export type InferDatabaseColumns<Definition extends DatabaseDefinition> = Definition extends DatabaseDefinition<infer Columns> ? Columns : never;
179
+ /** Create/update payload row derived from a `DatabaseDefinition`. */
180
+ export type CreateSchema<Definition extends DatabaseDefinition> = InferCreateSchema<InferDatabaseColumns<Definition>>;
181
+ /** Extracts the row shape from a `DatabaseDefinition`. */
182
+ export type DatabaseSchema<Definition extends DatabaseDefinition> = Definition["schema"];
183
+ /** Extracts the property -> column-type map from a `DatabaseDefinition`. */
184
+ export type DatabaseColumnTypes<Definition extends DatabaseDefinition> = Definition["columns"];
185
+ /** @deprecated Use `DatabaseColumns` instead. */
186
+ export type PropertyNameToColumnMetadataMap = DatabaseColumns;
187
+ /** @deprecated Use `DatabaseColumns` instead. */
188
+ export type camelPropertyNameToNameAndTypeMapType = DatabaseColumns;
189
+ export {};
190
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../../src/client/database/types/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,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,QAAQ,CACxE,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,uBAAuB,CAAC,OAAO,CAAC,CAAC,CACpE,CAAC;AAEF,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB,CAClC,OAAO,SAAS,eAAe,GAAG,eAAe;IAEjD,mEAAmE;IACnE,MAAM,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACrC,wEAAwE;IACxE,OAAO,EAAE;SACP,QAAQ,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;KACtD,CAAC;CACF;AAED,MAAM,MAAM,oBAAoB,CAAC,UAAU,SAAS,kBAAkB,IACrE,UAAU,SAAS,kBAAkB,CAAC,MAAM,OAAO,CAAC,GAAG,OAAO,GAAG,KAAK,CAAC;AAExE,qEAAqE;AACrE,MAAM,MAAM,YAAY,CAAC,UAAU,SAAS,kBAAkB,IAC7D,iBAAiB,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC;AAErD,0DAA0D;AAC1D,MAAM,MAAM,cAAc,CACzB,UAAU,SAAS,kBAAkB,IAClC,UAAU,CAAC,QAAQ,CAAC,CAAC;AACzB,4EAA4E;AAC5E,MAAM,MAAM,mBAAmB,CAC9B,UAAU,SAAS,kBAAkB,IAClC,UAAU,CAAC,SAAS,CAAC,CAAC;AAE1B,iDAAiD;AACjD,MAAM,MAAM,+BAA+B,GAAG,eAAe,CAAC;AAE9D,iDAAiD;AACjD,MAAM,MAAM,qCAAqC,GAAG,eAAe,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Core schema value shapes and Notion column-type unions for database clients.
3
+ */
4
+ export const SUPPORTED_PROPERTY_TYPES = {
5
+ formula: false,
6
+ files: true,
7
+ people: true,
8
+ relation: true,
9
+ rollup: false,
10
+ created_by: true,
11
+ last_edited_by: true,
12
+ created_time: true,
13
+ last_edited_time: true,
14
+ url: true,
15
+ phone_number: true,
16
+ title: true,
17
+ email: true,
18
+ checkbox: true,
19
+ date: true,
20
+ multi_select: true,
21
+ status: true,
22
+ number: true,
23
+ rich_text: true,
24
+ select: true,
25
+ unique_id: true,
26
+ };
27
+ export function isSupportedPropertyType(propertyType) {
28
+ return SUPPORTED_PROPERTY_TYPES[propertyType];
29
+ }
30
+ /** Runtime narrow for select / status / multi_select column metadata. */
31
+ export function isColumnTypesWithOptions(type) {
32
+ switch (type) {
33
+ case "select":
34
+ case "status":
35
+ case "multi_select":
36
+ return true;
37
+ default:
38
+ return false;
39
+ }
40
+ }
41
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../src/client/database/types/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiCH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACvC,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,IAAI;IACpB,YAAY,EAAE,IAAI;IAClB,gBAAgB,EAAE,IAAI;IAEtB,GAAG,EAAE,IAAI;IACT,YAAY,EAAE,IAAI;IAClB,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,IAAI;IACV,YAAY,EAAE,IAAI;IAClB,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,IAAI;CAC0C,CAAC;AAE3D,MAAM,UAAU,uBAAuB,CACtC,YAAkC;IAElC,OAAO,wBAAwB,CAAC,YAAY,CAAC,CAAC;AAC/C,CAAC;AAiBD,yEAAyE;AACzE,MAAM,UAAU,wBAAwB,CACvC,IAA+B;IAE/B,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,cAAc;YAClB,OAAO,IAAI,CAAC;QACb;YACC,OAAO,KAAK,CAAC;IACf,CAAC;AACF,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Typed sort lists for database queries (property sorts + timestamp sorts).
3
+ */
4
+ import type { QueryDataSourceParameters } from "@notionhq/client/build/src/api-endpoints";
5
+ import type { DatabaseColumnTypes, DatabaseDefinition } from "./schema";
6
+ type NotionApiSort = NonNullable<QueryDataSourceParameters["sorts"]>[number];
7
+ type NotionPropertySort = Extract<NotionApiSort, {
8
+ property: string;
9
+ }>;
10
+ type NotionTimestampSort = Extract<NotionApiSort, {
11
+ timestamp: string;
12
+ }>;
13
+ export type QuerySortDirection = NotionPropertySort["direction"];
14
+ export type QuerySortPropertyName<Definition extends DatabaseDefinition> = Extract<keyof DatabaseColumnTypes<Definition>, string>;
15
+ export type QueryPropertySort<Definition extends DatabaseDefinition> = {
16
+ property: QuerySortPropertyName<Definition>;
17
+ direction: QuerySortDirection;
18
+ };
19
+ export type QueryTimestampSort = NotionTimestampSort;
20
+ export type QuerySort<Definition extends DatabaseDefinition> = Array<QueryPropertySort<Definition> | QueryTimestampSort>;
21
+ export {};
22
+ //# sourceMappingURL=sort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../../src/client/database/types/sort.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAC1F,OAAO,KAAK,EACX,mBAAmB,EACnB,kBAAkB,EAClB,MAAM,UAAU,CAAC;AAElB,KAAK,aAAa,GAAG,WAAW,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC7E,KAAK,kBAAkB,GAAG,OAAO,CAAC,aAAa,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AACvE,KAAK,mBAAmB,GAAG,OAAO,CAAC,aAAa,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEzE,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;AAEjE,MAAM,MAAM,qBAAqB,CAAC,UAAU,SAAS,kBAAkB,IAAI,OAAO,CACjF,MAAM,mBAAmB,CAAC,UAAU,CAAC,EACrC,MAAM,CACN,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,UAAU,SAAS,kBAAkB,IAAI;IACtE,QAAQ,EAAE,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAC5C,SAAS,EAAE,kBAAkB,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAErD,MAAM,MAAM,SAAS,CAAC,UAAU,SAAS,kBAAkB,IAAI,KAAK,CACnE,iBAAiB,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAClD,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Typed sort lists for database queries (property sorts + timestamp sorts).
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=sort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort.js","sourceRoot":"","sources":["../../../../../src/client/database/types/sort.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,8 @@
1
+ type NotionConfigFile = {
2
+ path: string;
3
+ isTS: boolean;
4
+ };
5
+ /** Looks for supported notion config filenames in the same order as the loader. */
6
+ export declare function findConfigFile(): NotionConfigFile | undefined;
7
+ export {};
8
+ //# sourceMappingURL=findConfigFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findConfigFile.d.ts","sourceRoot":"","sources":["../../../src/config/findConfigFile.ts"],"names":[],"mappings":"AAOA,KAAK,gBAAgB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACd,CAAC;AAEF,mFAAmF;AACnF,wBAAgB,cAAc,IAAI,gBAAgB,GAAG,SAAS,CAY7D"}
@@ -0,0 +1,18 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { NOTION_CONFIG_CANDIDATE_FILENAMES, NOTION_CONFIG_FILENAMES, } from "./notion-config-filenames.js";
4
+ /** Looks for supported notion config filenames in the same order as the loader. */
5
+ export function findConfigFile() {
6
+ const projectDir = process.cwd();
7
+ for (const filename of NOTION_CONFIG_CANDIDATE_FILENAMES) {
8
+ const candidatePath = path.join(projectDir, filename);
9
+ if (fs.existsSync(candidatePath)) {
10
+ return {
11
+ path: candidatePath,
12
+ isTS: filename === NOTION_CONFIG_FILENAMES.ts,
13
+ };
14
+ }
15
+ }
16
+ return undefined;
17
+ }
18
+ //# sourceMappingURL=findConfigFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findConfigFile.js","sourceRoot":"","sources":["../../../src/config/findConfigFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EACN,iCAAiC,EACjC,uBAAuB,GACvB,MAAM,2BAA2B,CAAC;AAOnC,mFAAmF;AACnF,MAAM,UAAU,cAAc;IAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IACjC,KAAK,MAAM,QAAQ,IAAI,iCAAiC,EAAE,CAAC;QAC1D,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACtD,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;YAClC,OAAO;gBACN,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,QAAQ,KAAK,uBAAuB,CAAC,EAAE;aAC7C,CAAC;QACH,CAAC;IACF,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /** Verifies that config can be resolved and parsed before running CLI commands. */
2
+ export declare function validateConfig(): Promise<void>;
3
+ /** Creates a starter config file unless one already exists in the project root. */
4
+ export declare function initializeNotionConfigFile(options?: {
5
+ force?: "ts" | "js";
6
+ }): Promise<void>;
7
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/config/helpers.ts"],"names":[],"mappings":"AAgBA,mFAAmF;AACnF,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAWpD;AAED,mFAAmF;AACnF,wBAAsB,0BAA0B,CAC/C,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAAO,GACnC,OAAO,CAAC,IAAI,CAAC,CA4Cf"}
@@ -0,0 +1,57 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { findConfigFile } from "./findConfigFile.js";
4
+ import { createConfigTemplate, shouldUseTypeScript, showSetupInstructions, } from "./init.js";
5
+ import { NOTION_CONFIG_FILENAMES } from "./notion-config-filenames.js";
6
+ import { getNotionConfig } from "./loadConfig.js";
7
+ /** Filename used by `notion init` when creating a new config file. */
8
+ function getNotionConfigInitFilename(isTS) {
9
+ return isTS ? NOTION_CONFIG_FILENAMES.ts : NOTION_CONFIG_FILENAMES.js;
10
+ }
11
+ /** Verifies that config can be resolved and parsed before running CLI commands. */
12
+ export async function validateConfig() {
13
+ try {
14
+ await getNotionConfig();
15
+ }
16
+ catch (error) {
17
+ console.error("❌ Invalid notion config");
18
+ if (error instanceof Error) {
19
+ console.error(` ${error.message}`);
20
+ }
21
+ showSetupInstructions();
22
+ process.exit(1);
23
+ }
24
+ }
25
+ /** Creates a starter config file unless one already exists in the project root. */
26
+ export async function initializeNotionConfigFile(options = {}) {
27
+ const existingConfig = findConfigFile();
28
+ if (existingConfig) {
29
+ console.log("⚠️ A notion.config file already exists:");
30
+ console.log(` Found ${path.basename(existingConfig.path)}`);
31
+ console.log(" Skipping init. Use that file or remove it before re-running init.");
32
+ return;
33
+ }
34
+ const isTS = options.force === "ts" || (options.force !== "js" && shouldUseTypeScript());
35
+ const filename = getNotionConfigInitFilename(isTS);
36
+ const configPath = path.join(process.cwd(), filename);
37
+ if (fs.existsSync(configPath)) {
38
+ console.log("⚠️ Config file already exists at:");
39
+ console.log(` ${configPath}`);
40
+ console.log(" Skipping init. Remove the file if you want to regenerate it.");
41
+ return;
42
+ }
43
+ try {
44
+ fs.writeFileSync(configPath, createConfigTemplate(isTS));
45
+ console.log(`✅ Created ${filename} (${isTS ? "TypeScript" : "JavaScript"})`);
46
+ console.log(" Next steps:");
47
+ console.log(" • Add your NOTION_KEY to a .env file (or export it in your shell)");
48
+ console.log(" • Use `notion add <data-source-id or URL>` to append databases");
49
+ console.log(" • Run `notion sync` to build local types");
50
+ }
51
+ catch (error) {
52
+ console.error("❌ Error creating config file:");
53
+ console.error(error);
54
+ process.exit(1);
55
+ }
56
+ }
57
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/config/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EACN,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,GACrB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,sEAAsE;AACtE,SAAS,2BAA2B,CAAC,IAAa;IACjD,OAAO,IAAI,CAAC,CAAC,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC,CAAC,uBAAuB,CAAC,EAAE,CAAC;AACvE,CAAC;AAED,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,cAAc;IACnC,IAAI,CAAC;QACJ,MAA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C;IAED,IAAI,CAAC;QACJ,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CACV,aAAa,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,GAAG,CAC/D,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC9B,OAAO,CAAC,GAAG,CACV,sEAAsE,CACtE,CAAC;QACF,OAAO,CAAC,GAAG,CACV,mEAAmE,CACnE,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;IAC5D,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAC/C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;AACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ /** Heuristic for `notion init`: TS projects get a TS config template by default. */
2
+ export declare function shouldUseTypeScript(): boolean;
3
+ /** Renders the starter config template and guarantees a trailing newline. */
4
+ export declare function createConfigTemplate(isTS: boolean): string;
5
+ /** Prints setup guidance together with copy-pastable example configs. */
6
+ export declare function showSetupInstructions(): void;
7
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/config/init.ts"],"names":[],"mappings":"AAGA,oFAAoF;AACpF,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAK1D;AAED,yEAAyE;AACzE,wBAAgB,qBAAqB,IAAI,IAAI,CAqB5C"}
@@ -0,0 +1,28 @@
1
+ import { renderConfigTemplateModule } from "../ast/shared/emit/config-emitter.js";
2
+ import { resolveCodegenEnvironment } from "../ast/shared/codegen-environment.js";
3
+ /** Heuristic for `notion init`: TS projects get a TS config template by default. */
4
+ export function shouldUseTypeScript() {
5
+ return resolveCodegenEnvironment() === "typescript";
6
+ }
7
+ /** Renders the starter config template and guarantees a trailing newline. */
8
+ export function createConfigTemplate(isTS) {
9
+ const renderedTemplate = renderConfigTemplateModule({ isTS });
10
+ return renderedTemplate.endsWith("\n")
11
+ ? renderedTemplate
12
+ : `${renderedTemplate}\n`;
13
+ }
14
+ /** Prints setup guidance together with copy-pastable example configs. */
15
+ export function showSetupInstructions() {
16
+ console.log("\n📚 Setup Instructions:");
17
+ console.log("1. Run: notion init [--ts|--js] (defaults to TypeScript when tsconfig.json is present)");
18
+ console.log("2. Add your Notion integration token and database IDs");
19
+ console.log("3. Run: notion sync (generates database types)");
20
+ console.log("4. (Optional) Run: notion setup-agents-sdk (installs the paid Agents SDK, then re-run notion sync)");
21
+ console.log("\n📝 Example JavaScript config (notion.config.js):");
22
+ console.log(`\n${createConfigTemplate(false).trimEnd()}\n`);
23
+ console.log("📝 Example TypeScript config (notion.config.ts):");
24
+ console.log(`\n${createConfigTemplate(true).trimEnd()}\n`);
25
+ console.log("\n🔗 Need help getting your integration token?");
26
+ console.log(" Visit: https://developers.notion.com/docs/create-a-notion-integration");
27
+ }
28
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/config/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,oFAAoF;AACpF,MAAM,UAAU,mBAAmB;IAClC,OAAO,yBAAyB,EAAE,KAAK,YAAY,CAAC;AACrD,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,oBAAoB,CAAC,IAAa;IACjD,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9D,OAAO,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC;QACrC,CAAC,CAAC,gBAAgB;QAClB,CAAC,CAAC,GAAG,gBAAgB,IAAI,CAAC;AAC5B,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,qBAAqB;IACpC,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CACV,wFAAwF,CACxF,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;IAC9D,OAAO,CAAC,GAAG,CACV,oGAAoG,CACpG,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAC;IAClE,OAAO,CAAC,GAAG,CAAC,KAAK,oBAAoB,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAE5D,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;IAChE,OAAO,CAAC,GAAG,CAAC,KAAK,oBAAoB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAE3D,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;IAC9D,OAAO,CAAC,GAAG,CACV,0EAA0E,CAC1E,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type NotionConfigType } from "./types";
2
+ /** Loads and validates a user config module from a known path. */
3
+ export declare function loadConfig(configPath: string): Promise<NotionConfigType>;
4
+ /**
5
+ * Resolves config once per process, falling back to environment variables when
6
+ * no config file is present. This keeps CLI calls fast while preserving a
7
+ * single trust boundary for config validation.
8
+ */
9
+ export declare function getNotionConfig(): Promise<NotionConfigType>;
10
+ export declare function clearConfigCache(): void;
11
+ //# sourceMappingURL=loadConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../../../src/config/loadConfig.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AA+CpE,kEAAkE;AAClE,wBAAsB,UAAU,CAC/B,UAAU,EAAE,MAAM,GAChB,OAAO,CAAC,gBAAgB,CAAC,CAU3B;AAED;;;;GAIG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAiCjE;AAGD,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
@@ -0,0 +1,91 @@
1
+ import { pathToFileURL } from "url";
2
+ import { findConfigFile } from "./findConfigFile.js";
3
+ import { loadDotEnvFromCwd } from "./loadDotEnvFromCwd.js";
4
+ import { NOTION_CONFIG_EXTENSION_LABELS } from "./notion-config-filenames.js";
5
+ import { notionConfigSchema } from "./types.js";
6
+ let cachedConfig;
7
+ function getErrorMessage(error) {
8
+ return error instanceof Error ? error.message : String(error);
9
+ }
10
+ /** Validates the user config at the ingestion boundary and returns a typed shape. */
11
+ function parseNotionConfig(input) {
12
+ const parseResult = notionConfigSchema.safeParse(input);
13
+ if (!parseResult.success) {
14
+ const details = parseResult.error.issues
15
+ .map((issue) => {
16
+ const pathLabel = issue.path.length > 0 ? issue.path.join(".") : "config";
17
+ return `${pathLabel}: ${issue.message}`;
18
+ })
19
+ .join(", ");
20
+ throw new Error(`Invalid notion config shape: ${details}`);
21
+ }
22
+ const data = parseResult.data;
23
+ return {
24
+ auth: data.auth,
25
+ databases: data.databases,
26
+ agents: data.agents,
27
+ };
28
+ }
29
+ /**
30
+ * Dynamically loads the user's notion.config file via `import()`.
31
+ * Use a `file://` URL so Node, Bun, and other ESM runtimes resolve the path consistently.
32
+ * Plain Node loads `.js`/`.mjs` natively; `.ts` requires a runtime that can execute TypeScript
33
+ * (or compile the config to JavaScript first).
34
+ */
35
+ async function loadUserConfig(absolutePath) {
36
+ try {
37
+ const importPath = pathToFileURL(absolutePath).href;
38
+ const mod = await import(importPath);
39
+ return mod.default ?? mod;
40
+ }
41
+ catch (error) {
42
+ throw new Error(`Failed to load config from '${absolutePath}': ${getErrorMessage(error)}`);
43
+ }
44
+ }
45
+ /** Loads and validates a user config module from a known path. */
46
+ export async function loadConfig(configPath) {
47
+ try {
48
+ loadDotEnvFromCwd();
49
+ const config = await loadUserConfig(configPath);
50
+ return parseNotionConfig(config);
51
+ }
52
+ catch (error) {
53
+ throw new Error(`Failed to load config from ${configPath}: ${getErrorMessage(error)}`);
54
+ }
55
+ }
56
+ /**
57
+ * Resolves config once per process, falling back to environment variables when
58
+ * no config file is present. This keeps CLI calls fast while preserving a
59
+ * single trust boundary for config validation.
60
+ */
61
+ export async function getNotionConfig() {
62
+ if (cachedConfig) {
63
+ return cachedConfig;
64
+ }
65
+ loadDotEnvFromCwd();
66
+ // Try to find config file
67
+ const configFile = findConfigFile();
68
+ if (!configFile) {
69
+ // Fallback to environment variable
70
+ const authFromEnv = process.env.NOTION_KEY;
71
+ if (authFromEnv) {
72
+ const config = parseNotionConfig({
73
+ auth: authFromEnv,
74
+ databases: [],
75
+ agents: [],
76
+ });
77
+ cachedConfig = config;
78
+ return config;
79
+ }
80
+ throw new Error(`No notion.config.${NOTION_CONFIG_EXTENSION_LABELS} file found and no NOTION_KEY environment variable set. ` +
81
+ "Please create a config file or set NOTION_KEY.");
82
+ }
83
+ const config = await loadConfig(configFile.path);
84
+ cachedConfig = config;
85
+ return config;
86
+ }
87
+ // Clear cache (useful for testing or config updates)
88
+ export function clearConfigCache() {
89
+ cachedConfig = undefined;
90
+ }
91
+ //# sourceMappingURL=loadConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadConfig.js","sourceRoot":"","sources":["../../../src/config/loadConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,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AAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAEjD,YAAY,GAAG,MAAM,CAAC;IACtB,OAAO,MAAM,CAAC;AACf,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,gBAAgB;IAC/B,YAAY,GAAG,SAAS,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Loads `.env*` files from the current project root using a runtime-agnostic cascade.
3
+ * Explicit shell environment variables always win over file values.
4
+ *
5
+ * Precedence (highest to lowest):
6
+ * 1) `.env.<NODE_ENV>.local`
7
+ * 2) `.env.local`
8
+ * 3) `.env.<NODE_ENV>`
9
+ * 4) `.env`
10
+ */
11
+ export declare function loadDotEnvFromCwd(): void;
12
+ //# sourceMappingURL=loadDotEnvFromCwd.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadDotEnvFromCwd.d.ts","sourceRoot":"","sources":["../../../src/config/loadDotEnvFromCwd.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CA0BxC"}
@@ -0,0 +1,47 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { config as loadDotEnv } from "dotenv";
4
+ const DOT_ENV_FILENAME = ".env";
5
+ const loadedDirectories = new Set();
6
+ function getDotEnvCandidateFilenames(nodeEnv) {
7
+ const candidates = [
8
+ nodeEnv ? `${DOT_ENV_FILENAME}.${nodeEnv}.local` : undefined,
9
+ `${DOT_ENV_FILENAME}.local`,
10
+ nodeEnv ? `${DOT_ENV_FILENAME}.${nodeEnv}` : undefined,
11
+ DOT_ENV_FILENAME,
12
+ ];
13
+ return Array.from(new Set(candidates.filter((value) => value !== undefined)));
14
+ }
15
+ /**
16
+ * Loads `.env*` files from the current project root using a runtime-agnostic cascade.
17
+ * Explicit shell environment variables always win over file values.
18
+ *
19
+ * Precedence (highest to lowest):
20
+ * 1) `.env.<NODE_ENV>.local`
21
+ * 2) `.env.local`
22
+ * 3) `.env.<NODE_ENV>`
23
+ * 4) `.env`
24
+ */
25
+ export function loadDotEnvFromCwd() {
26
+ const cwd = process.cwd();
27
+ if (loadedDirectories.has(cwd)) {
28
+ return;
29
+ }
30
+ for (const filename of getDotEnvCandidateFilenames(process.env.NODE_ENV)) {
31
+ const envPath = path.join(cwd, filename);
32
+ if (!fs.existsSync(envPath)) {
33
+ continue;
34
+ }
35
+ const result = loadDotEnv({
36
+ path: envPath,
37
+ override: false,
38
+ processEnv: process.env,
39
+ quiet: true,
40
+ });
41
+ if (result.error) {
42
+ console.warn(`Warning: failed to parse ${envPath}: ${result.error.message}`);
43
+ }
44
+ }
45
+ loadedDirectories.add(cwd);
46
+ }
47
+ //# sourceMappingURL=loadDotEnvFromCwd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadDotEnvFromCwd.js","sourceRoot":"","sources":["../../../src/config/loadDotEnvFromCwd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE9C,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;AAE5C,SAAS,2BAA2B,CAAC,OAA2B;IAC/D,MAAM,UAAU,GAAG;QAClB,OAAO,CAAC,CAAC,CAAC,GAAG,gBAAgB,IAAI,OAAO,QAAQ,CAAC,CAAC,CAAC,SAAS;QAC5D,GAAG,gBAAgB,QAAQ;QAC3B,OAAO,CAAC,CAAC,CAAC,GAAG,gBAAgB,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS;QACtD,gBAAgB;KAChB,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CA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