@openpeepshq/core 0.1.31

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 (500) hide show
  1. package/LICENSE +674 -0
  2. package/dist/accessTokens/finders.d.ts +11 -0
  3. package/dist/accessTokens/finders.js +43 -0
  4. package/dist/accessTokens/helpers.d.ts +13 -0
  5. package/dist/accessTokens/helpers.js +15 -0
  6. package/dist/accessTokens/index.d.ts +4 -0
  7. package/dist/accessTokens/index.js +4 -0
  8. package/dist/accessTokens/mapping.d.ts +10 -0
  9. package/dist/accessTokens/mapping.js +25 -0
  10. package/dist/accessTokens/mutations.d.ts +4 -0
  11. package/dist/accessTokens/mutations.js +24 -0
  12. package/dist/accessTokens/revokations.d.ts +2 -0
  13. package/dist/accessTokens/revokations.js +18 -0
  14. package/dist/accessTokens/tokens.d.ts +31 -0
  15. package/dist/accessTokens/tokens.js +174 -0
  16. package/dist/accounts/cache.d.ts +3 -0
  17. package/dist/accounts/cache.js +13 -0
  18. package/dist/accounts/finders.d.ts +6 -0
  19. package/dist/accounts/finders.js +17 -0
  20. package/dist/accounts/helpers.d.ts +7 -0
  21. package/dist/accounts/helpers.js +36 -0
  22. package/dist/accounts/index.d.ts +6 -0
  23. package/dist/accounts/index.js +6 -0
  24. package/dist/accounts/mapping.d.ts +10 -0
  25. package/dist/accounts/mapping.js +28 -0
  26. package/dist/accounts/mutations.d.ts +21 -0
  27. package/dist/accounts/mutations.js +204 -0
  28. package/dist/analytics/cache.d.ts +6 -0
  29. package/dist/analytics/cache.js +29 -0
  30. package/dist/analytics/compile.d.ts +4 -0
  31. package/dist/analytics/compile.js +296 -0
  32. package/dist/analytics/dateRange.d.ts +39 -0
  33. package/dist/analytics/dateRange.js +181 -0
  34. package/dist/analytics/index.d.ts +8 -0
  35. package/dist/analytics/index.js +8 -0
  36. package/dist/analytics/jobs.d.ts +20 -0
  37. package/dist/analytics/jobs.js +84 -0
  38. package/dist/analytics/metrics.d.ts +4 -0
  39. package/dist/analytics/metrics.js +13 -0
  40. package/dist/analytics/pdfReport.d.ts +8 -0
  41. package/dist/analytics/pdfReport.js +821 -0
  42. package/dist/analytics/read.d.ts +6 -0
  43. package/dist/analytics/read.js +696 -0
  44. package/dist/analytics/report.d.ts +293 -0
  45. package/dist/analytics/report.js +153 -0
  46. package/dist/analytics/settings.d.ts +3 -0
  47. package/dist/analytics/settings.js +37 -0
  48. package/dist/backups/index.d.ts +5 -0
  49. package/dist/backups/index.js +260 -0
  50. package/dist/backups/metadata.d.ts +9 -0
  51. package/dist/backups/metadata.js +2 -0
  52. package/dist/config/db.d.ts +7 -0
  53. package/dist/config/db.js +26 -0
  54. package/dist/config/defaults/capabilities.d.ts +2 -0
  55. package/dist/config/defaults/capabilities.js +47 -0
  56. package/dist/config/defaults/community.d.ts +2 -0
  57. package/dist/config/defaults/community.js +41 -0
  58. package/dist/config/defaults/core.d.ts +2 -0
  59. package/dist/config/defaults/core.js +113 -0
  60. package/dist/config/defaults/db.d.ts +6 -0
  61. package/dist/config/defaults/db.js +8 -0
  62. package/dist/config/defaults/logs.d.ts +6 -0
  63. package/dist/config/defaults/logs.js +7 -0
  64. package/dist/config/defaults/redis.d.ts +4 -0
  65. package/dist/config/defaults/redis.js +5 -0
  66. package/dist/config/helpers.d.ts +11 -0
  67. package/dist/config/helpers.js +31 -0
  68. package/dist/config/index.d.ts +392 -0
  69. package/dist/config/index.js +83 -0
  70. package/dist/config/pruneEmptyConfigStrings.d.ts +7 -0
  71. package/dist/config/pruneEmptyConfigStrings.js +29 -0
  72. package/dist/db/aql.d.ts +0 -0
  73. package/dist/db/aql.js +1 -0
  74. package/dist/db/arango.d.ts +2 -0
  75. package/dist/db/arango.js +110 -0
  76. package/dist/db/bootMigrate.d.ts +1 -0
  77. package/dist/db/bootMigrate.js +15 -0
  78. package/dist/db/examples.d.ts +1 -0
  79. package/dist/db/examples.js +13 -0
  80. package/dist/db/explorer/csv.d.ts +1 -0
  81. package/dist/db/explorer/csv.js +18 -0
  82. package/dist/db/explorer/index.d.ts +6 -0
  83. package/dist/db/explorer/index.js +5 -0
  84. package/dist/db/explorer/mutate.d.ts +6 -0
  85. package/dist/db/explorer/mutate.js +66 -0
  86. package/dist/db/explorer/query.d.ts +17 -0
  87. package/dist/db/explorer/query.js +48 -0
  88. package/dist/db/explorer/sql.d.ts +11 -0
  89. package/dist/db/explorer/sql.js +42 -0
  90. package/dist/db/explorer/tables.d.ts +9 -0
  91. package/dist/db/explorer/tables.js +65 -0
  92. package/dist/db/helpers.d.ts +64 -0
  93. package/dist/db/helpers.js +240 -0
  94. package/dist/db/index.d.ts +13 -0
  95. package/dist/db/index.js +15 -0
  96. package/dist/db/init.d.ts +2 -0
  97. package/dist/db/init.js +10 -0
  98. package/dist/db/migration/autoMigrate.d.ts +2 -0
  99. package/dist/db/migration/autoMigrate.js +111 -0
  100. package/dist/db/migration/cli.d.ts +1 -0
  101. package/dist/db/migration/cli.js +56 -0
  102. package/dist/db/migration/detect.d.ts +6 -0
  103. package/dist/db/migration/detect.js +87 -0
  104. package/dist/db/migration/exportArango.d.ts +4 -0
  105. package/dist/db/migration/exportArango.js +80 -0
  106. package/dist/db/migration/importCollections.d.ts +19 -0
  107. package/dist/db/migration/importCollections.js +280 -0
  108. package/dist/db/migration/importPostgres.d.ts +3 -0
  109. package/dist/db/migration/importPostgres.js +18 -0
  110. package/dist/db/migration/shared.d.ts +39 -0
  111. package/dist/db/migration/shared.js +158 -0
  112. package/dist/db/migration/transform.d.ts +18 -0
  113. package/dist/db/migration/transform.js +209 -0
  114. package/dist/db/migration/validate.d.ts +18 -0
  115. package/dist/db/migration/validate.js +69 -0
  116. package/dist/db/pg/client.d.ts +35 -0
  117. package/dist/db/pg/client.js +126 -0
  118. package/dist/db/pg/collections.d.ts +48 -0
  119. package/dist/db/pg/collections.js +53 -0
  120. package/dist/db/pg/filters/common.d.ts +21 -0
  121. package/dist/db/pg/filters/common.js +48 -0
  122. package/dist/db/pg/filters/edges.d.ts +9 -0
  123. package/dist/db/pg/filters/edges.js +10 -0
  124. package/dist/db/pg/filters/groups.d.ts +7 -0
  125. package/dist/db/pg/filters/groups.js +15 -0
  126. package/dist/db/pg/filters/index.d.ts +22 -0
  127. package/dist/db/pg/filters/index.js +35 -0
  128. package/dist/db/pg/filters/notifications.d.ts +6 -0
  129. package/dist/db/pg/filters/notifications.js +10 -0
  130. package/dist/db/pg/filters/posts.d.ts +18 -0
  131. package/dist/db/pg/filters/posts.js +25 -0
  132. package/dist/db/pg/filters/profiles.d.ts +6 -0
  133. package/dist/db/pg/filters/profiles.js +9 -0
  134. package/dist/db/pg/filters/types.d.ts +7 -0
  135. package/dist/db/pg/filters/types.js +5 -0
  136. package/dist/db/pg/helpers.d.ts +19 -0
  137. package/dist/db/pg/helpers.js +67 -0
  138. package/dist/db/pg/map/filters.d.ts +22 -0
  139. package/dist/db/pg/map/filters.js +566 -0
  140. package/dist/db/pg/map/helpers.d.ts +2 -0
  141. package/dist/db/pg/map/helpers.js +2 -0
  142. package/dist/db/pg/map/index.d.ts +46 -0
  143. package/dist/db/pg/map/index.js +93 -0
  144. package/dist/db/pg/map/mutations.d.ts +11 -0
  145. package/dist/db/pg/map/mutations.js +135 -0
  146. package/dist/db/pg/map/queryTypes.d.ts +115 -0
  147. package/dist/db/pg/map/queryTypes.js +1 -0
  148. package/dist/db/pg/map/registry.d.ts +29 -0
  149. package/dist/db/pg/map/registry.js +413 -0
  150. package/dist/db/pg/map/relations.d.ts +28 -0
  151. package/dist/db/pg/map/relations.js +399 -0
  152. package/dist/db/pg/map/search.d.ts +6 -0
  153. package/dist/db/pg/map/search.js +190 -0
  154. package/dist/db/pg/map/types.d.ts +11 -0
  155. package/dist/db/pg/map/types.js +1 -0
  156. package/dist/db/pg/mappers.d.ts +28 -0
  157. package/dist/db/pg/mappers.js +29 -0
  158. package/dist/db/pg/migrate.d.ts +14 -0
  159. package/dist/db/pg/migrate.js +134 -0
  160. package/dist/db/pg/queries/activity.d.ts +10 -0
  161. package/dist/db/pg/queries/activity.js +47 -0
  162. package/dist/db/pg/queries/computed.d.ts +7 -0
  163. package/dist/db/pg/queries/computed.js +19 -0
  164. package/dist/db/pg/queries/derived.d.ts +22 -0
  165. package/dist/db/pg/queries/derived.js +100 -0
  166. package/dist/db/pg/queries/index.d.ts +4 -0
  167. package/dist/db/pg/queries/index.js +4 -0
  168. package/dist/db/pg/queries/sorts.d.ts +10 -0
  169. package/dist/db/pg/queries/sorts.js +9 -0
  170. package/dist/db/pg/schema/analytics.d.ts +998 -0
  171. package/dist/db/pg/schema/analytics.js +110 -0
  172. package/dist/db/pg/schema/base.d.ts +36 -0
  173. package/dist/db/pg/schema/base.js +23 -0
  174. package/dist/db/pg/schema/documents.d.ts +2002 -0
  175. package/dist/db/pg/schema/documents.js +40 -0
  176. package/dist/db/pg/schema/edges.d.ts +2725 -0
  177. package/dist/db/pg/schema/edges.js +34 -0
  178. package/dist/db/pg/schema/index.d.ts +5724 -0
  179. package/dist/db/pg/schema/index.js +7 -0
  180. package/dist/db/pg/sql/0000_bizarre_chat.sql +456 -0
  181. package/dist/db/pg/sql/0001_search_vector.sql +122 -0
  182. package/dist/db/pg/sql/0002_data_migrations_id_text.sql +1 -0
  183. package/dist/db/pg/sql/0003_fix_group_post_visibility.sql +4 -0
  184. package/dist/db/pg/sql/0004_analytics.sql +90 -0
  185. package/dist/db/pg/sql/meta/0000_snapshot.json +3380 -0
  186. package/dist/db/pg/sql/meta/0004_snapshot.json +4114 -0
  187. package/dist/db/pg/sql/meta/_journal.json +41 -0
  188. package/dist/db/replaceHostname.d.ts +1 -0
  189. package/dist/db/replaceHostname.js +88 -0
  190. package/dist/db/types.d.ts +17 -0
  191. package/dist/db/types.js +1 -0
  192. package/dist/email/index.d.ts +9 -0
  193. package/dist/email/index.js +19 -0
  194. package/dist/email/jobs.d.ts +3 -0
  195. package/dist/email/jobs.js +13 -0
  196. package/dist/email/queueStats.d.ts +2 -0
  197. package/dist/email/queueStats.js +27 -0
  198. package/dist/email/registry.d.ts +3 -0
  199. package/dist/email/registry.js +4 -0
  200. package/dist/email/render.d.ts +8 -0
  201. package/dist/email/render.js +34 -0
  202. package/dist/email/send.d.ts +9 -0
  203. package/dist/email/send.js +97 -0
  204. package/dist/email/smtpTest.d.ts +2 -0
  205. package/dist/email/smtpTest.js +26 -0
  206. package/dist/errors/index.d.ts +8 -0
  207. package/dist/errors/index.js +13 -0
  208. package/dist/events/index.d.ts +31 -0
  209. package/dist/events/index.js +66 -0
  210. package/dist/events/once.d.ts +4 -0
  211. package/dist/events/once.js +23 -0
  212. package/dist/groups/finders.d.ts +125 -0
  213. package/dist/groups/finders.js +18 -0
  214. package/dist/groups/helpers.d.ts +227 -0
  215. package/dist/groups/helpers.js +17 -0
  216. package/dist/groups/index.d.ts +3 -0
  217. package/dist/groups/index.js +3 -0
  218. package/dist/groups/mapping.d.ts +188 -0
  219. package/dist/groups/mapping.js +47 -0
  220. package/dist/groups/mutations.d.ts +26 -0
  221. package/dist/groups/mutations.js +41 -0
  222. package/dist/hashtags/finders.d.ts +3 -0
  223. package/dist/hashtags/finders.js +22 -0
  224. package/dist/hashtags/index.d.ts +2 -0
  225. package/dist/hashtags/index.js +2 -0
  226. package/dist/hashtags/mapping.d.ts +4 -0
  227. package/dist/hashtags/mapping.js +5 -0
  228. package/dist/hashtags/mutations.d.ts +0 -0
  229. package/dist/hashtags/mutations.js +1 -0
  230. package/dist/i18n/index.d.ts +14 -0
  231. package/dist/i18n/index.js +53 -0
  232. package/dist/index.d.ts +0 -0
  233. package/dist/index.js +1 -0
  234. package/dist/inviteLinks/finders.d.ts +3 -0
  235. package/dist/inviteLinks/finders.js +5 -0
  236. package/dist/inviteLinks/helpers.d.ts +20 -0
  237. package/dist/inviteLinks/helpers.js +4 -0
  238. package/dist/inviteLinks/index.d.ts +3 -0
  239. package/dist/inviteLinks/index.js +3 -0
  240. package/dist/inviteLinks/mapping.d.ts +10 -0
  241. package/dist/inviteLinks/mapping.js +35 -0
  242. package/dist/inviteLinks/mutations.d.ts +4 -0
  243. package/dist/inviteLinks/mutations.js +39 -0
  244. package/dist/jams/cache.d.ts +9 -0
  245. package/dist/jams/cache.js +13 -0
  246. package/dist/jams/finders.d.ts +23 -0
  247. package/dist/jams/finders.js +24 -0
  248. package/dist/jams/helpers.d.ts +70 -0
  249. package/dist/jams/helpers.js +29 -0
  250. package/dist/jams/index.d.ts +15 -0
  251. package/dist/jams/index.js +108 -0
  252. package/dist/jams/jobs.d.ts +9 -0
  253. package/dist/jams/jobs.js +42 -0
  254. package/dist/jams/livekit.d.ts +24 -0
  255. package/dist/jams/livekit.js +220 -0
  256. package/dist/jams/mapping.d.ts +137 -0
  257. package/dist/jams/mapping.js +35 -0
  258. package/dist/jams/mutations.d.ts +40 -0
  259. package/dist/jams/mutations.js +4 -0
  260. package/dist/jams/recording.d.ts +8 -0
  261. package/dist/jams/recording.js +67 -0
  262. package/dist/jams/recordingUploadAuth.d.ts +9 -0
  263. package/dist/jams/recordingUploadAuth.js +19 -0
  264. package/dist/jams/token.d.ts +4 -0
  265. package/dist/jams/token.js +129 -0
  266. package/dist/jams/waitingRoom.d.ts +5 -0
  267. package/dist/jams/waitingRoom.js +71 -0
  268. package/dist/jobs/index.d.ts +10 -0
  269. package/dist/jobs/index.js +60 -0
  270. package/dist/jobs/jobDetail.d.ts +2 -0
  271. package/dist/jobs/jobDetail.js +31 -0
  272. package/dist/jobs/jobLog.d.ts +18 -0
  273. package/dist/jobs/jobLog.js +61 -0
  274. package/dist/jwt/index.d.ts +10 -0
  275. package/dist/jwt/index.js +43 -0
  276. package/dist/lib/index.d.ts +2 -0
  277. package/dist/lib/index.js +2 -0
  278. package/dist/lib/streams.d.ts +2 -0
  279. package/dist/lib/streams.js +56 -0
  280. package/dist/lib/utils.d.ts +2 -0
  281. package/dist/lib/utils.js +17 -0
  282. package/dist/lib/zodDeepPartial.d.ts +3 -0
  283. package/dist/lib/zodDeepPartial.js +26 -0
  284. package/dist/location/index.d.ts +2 -0
  285. package/dist/location/index.js +28 -0
  286. package/dist/log/index.d.ts +3 -0
  287. package/dist/log/index.js +97 -0
  288. package/dist/mastodon/index.d.ts +4 -0
  289. package/dist/mastodon/index.js +51 -0
  290. package/dist/mastodon/types.d.ts +7579 -0
  291. package/dist/mastodon/types.js +523 -0
  292. package/dist/mastodon/typescript.d.ts +1578 -0
  293. package/dist/mastodon/typescript.js +1 -0
  294. package/dist/media/index.d.ts +40 -0
  295. package/dist/media/index.js +248 -0
  296. package/dist/media/ipfs/index.d.ts +0 -0
  297. package/dist/media/ipfs/index.js +39 -0
  298. package/dist/media/jobs.d.ts +19 -0
  299. package/dist/media/jobs.js +90 -0
  300. package/dist/media/openpeeps/index.d.ts +3 -0
  301. package/dist/media/openpeeps/index.js +131 -0
  302. package/dist/media/processing.d.ts +19 -0
  303. package/dist/media/processing.js +83 -0
  304. package/dist/media/streaming.d.ts +77 -0
  305. package/dist/media/streaming.js +257 -0
  306. package/dist/media/streamingCleanupJobs.d.ts +14 -0
  307. package/dist/media/streamingCleanupJobs.js +47 -0
  308. package/dist/media/streamingJobs.d.ts +5 -0
  309. package/dist/media/streamingJobs.js +329 -0
  310. package/dist/media/streamingPrewarm.d.ts +36 -0
  311. package/dist/media/streamingPrewarm.js +109 -0
  312. package/dist/mediaAttachments/finders.d.ts +1 -0
  313. package/dist/mediaAttachments/finders.js +3 -0
  314. package/dist/mediaAttachments/index.d.ts +5 -0
  315. package/dist/mediaAttachments/index.js +12 -0
  316. package/dist/mediaAttachments/mapping.d.ts +21 -0
  317. package/dist/mediaAttachments/mapping.js +4 -0
  318. package/dist/mediaAttachments/mutations.d.ts +3 -0
  319. package/dist/mediaAttachments/mutations.js +10 -0
  320. package/dist/notifications/defaultNotifications/announcement/index.d.ts +24 -0
  321. package/dist/notifications/defaultNotifications/announcement/index.js +42 -0
  322. package/dist/notifications/defaultNotifications/directMessage/index.d.ts +28 -0
  323. package/dist/notifications/defaultNotifications/directMessage/index.js +69 -0
  324. package/dist/notifications/defaultNotifications/follow/index.d.ts +24 -0
  325. package/dist/notifications/defaultNotifications/follow/index.js +31 -0
  326. package/dist/notifications/defaultNotifications/groupAdded/index.d.ts +18 -0
  327. package/dist/notifications/defaultNotifications/groupAdded/index.js +33 -0
  328. package/dist/notifications/defaultNotifications/groupMemberJoined/index.d.ts +18 -0
  329. package/dist/notifications/defaultNotifications/groupMemberJoined/index.js +36 -0
  330. package/dist/notifications/defaultNotifications/groupMemberLeft/index.d.ts +18 -0
  331. package/dist/notifications/defaultNotifications/groupMemberLeft/index.js +36 -0
  332. package/dist/notifications/defaultNotifications/index.d.ts +3 -0
  333. package/dist/notifications/defaultNotifications/index.js +43 -0
  334. package/dist/notifications/defaultNotifications/jamModerator/index.d.ts +23 -0
  335. package/dist/notifications/defaultNotifications/jamModerator/index.js +49 -0
  336. package/dist/notifications/defaultNotifications/jamSpeaker/index.d.ts +23 -0
  337. package/dist/notifications/defaultNotifications/jamSpeaker/index.js +47 -0
  338. package/dist/notifications/defaultNotifications/jamStarted/index.d.ts +18 -0
  339. package/dist/notifications/defaultNotifications/jamStarted/index.js +82 -0
  340. package/dist/notifications/defaultNotifications/mention/index.d.ts +24 -0
  341. package/dist/notifications/defaultNotifications/mention/index.js +89 -0
  342. package/dist/notifications/defaultNotifications/newGroupPost/index.d.ts +24 -0
  343. package/dist/notifications/defaultNotifications/newGroupPost/index.js +47 -0
  344. package/dist/notifications/defaultNotifications/newProfile/index.d.ts +24 -0
  345. package/dist/notifications/defaultNotifications/newProfile/index.js +40 -0
  346. package/dist/notifications/defaultNotifications/pollVote/index.d.ts +19 -0
  347. package/dist/notifications/defaultNotifications/pollVote/index.js +40 -0
  348. package/dist/notifications/defaultNotifications/reaction/index.d.ts +18 -0
  349. package/dist/notifications/defaultNotifications/reaction/index.js +43 -0
  350. package/dist/notifications/defaultNotifications/reply/index.d.ts +25 -0
  351. package/dist/notifications/defaultNotifications/reply/index.js +57 -0
  352. package/dist/notifications/defaultNotifications/repost/index.d.ts +18 -0
  353. package/dist/notifications/defaultNotifications/repost/index.js +42 -0
  354. package/dist/notifications/defaultNotifications/rsvp/index.d.ts +19 -0
  355. package/dist/notifications/defaultNotifications/rsvp/index.js +40 -0
  356. package/dist/notifications/fcmCredential.d.ts +14 -0
  357. package/dist/notifications/fcmCredential.js +68 -0
  358. package/dist/notifications/finders.d.ts +7 -0
  359. package/dist/notifications/finders.js +13 -0
  360. package/dist/notifications/firebase.d.ts +1 -0
  361. package/dist/notifications/firebase.js +33 -0
  362. package/dist/notifications/handlers.d.ts +3 -0
  363. package/dist/notifications/handlers.js +6 -0
  364. package/dist/notifications/helpers.d.ts +7 -0
  365. package/dist/notifications/helpers.js +31 -0
  366. package/dist/notifications/index.d.ts +9 -0
  367. package/dist/notifications/index.js +43 -0
  368. package/dist/notifications/jobs.d.ts +2 -0
  369. package/dist/notifications/jobs.js +75 -0
  370. package/dist/notifications/mapping.d.ts +25 -0
  371. package/dist/notifications/mapping.js +25 -0
  372. package/dist/notifications/mutations.d.ts +6 -0
  373. package/dist/notifications/mutations.js +40 -0
  374. package/dist/notifications/push.d.ts +9 -0
  375. package/dist/notifications/push.js +261 -0
  376. package/dist/notifications/pushInvalidation.d.ts +10 -0
  377. package/dist/notifications/pushInvalidation.js +10 -0
  378. package/dist/performance/index.d.ts +24 -0
  379. package/dist/performance/index.js +61 -0
  380. package/dist/plugins/helpers.d.ts +3 -0
  381. package/dist/plugins/helpers.js +72 -0
  382. package/dist/plugins/index.d.ts +10 -0
  383. package/dist/plugins/index.js +84 -0
  384. package/dist/plugins/pluginAuth.d.ts +30 -0
  385. package/dist/plugins/pluginAuth.js +44 -0
  386. package/dist/posts/contextClosure.d.ts +16 -0
  387. package/dist/posts/contextClosure.js +66 -0
  388. package/dist/posts/finders.d.ts +298 -0
  389. package/dist/posts/finders.js +259 -0
  390. package/dist/posts/helpers/filters.d.ts +14 -0
  391. package/dist/posts/helpers/filters.js +39 -0
  392. package/dist/posts/helpers/index.d.ts +837 -0
  393. package/dist/posts/helpers/index.js +117 -0
  394. package/dist/posts/index.d.ts +6 -0
  395. package/dist/posts/index.js +6 -0
  396. package/dist/posts/mapping.d.ts +2187 -0
  397. package/dist/posts/mapping.js +222 -0
  398. package/dist/posts/mutations.d.ts +19 -0
  399. package/dist/posts/mutations.js +202 -0
  400. package/dist/posts/rsvpConfirmationEmail.d.ts +2 -0
  401. package/dist/posts/rsvpConfirmationEmail.js +82 -0
  402. package/dist/processingStats/index.d.ts +3 -0
  403. package/dist/processingStats/index.js +3 -0
  404. package/dist/processingStats/mapping.d.ts +7 -0
  405. package/dist/processingStats/mapping.js +4 -0
  406. package/dist/processingStats/mutations.d.ts +2 -0
  407. package/dist/processingStats/mutations.js +6 -0
  408. package/dist/processingStats/queries.d.ts +4 -0
  409. package/dist/processingStats/queries.js +46 -0
  410. package/dist/profileSettings/cache.d.ts +2 -0
  411. package/dist/profileSettings/cache.js +24 -0
  412. package/dist/profileSettings/finders.d.ts +1 -0
  413. package/dist/profileSettings/finders.js +2 -0
  414. package/dist/profileSettings/index.d.ts +3 -0
  415. package/dist/profileSettings/index.js +3 -0
  416. package/dist/profileSettings/mapping.d.ts +38 -0
  417. package/dist/profileSettings/mapping.js +5 -0
  418. package/dist/profileSettings/mutations.d.ts +3 -0
  419. package/dist/profileSettings/mutations.js +24 -0
  420. package/dist/profiles/cache.d.ts +5 -0
  421. package/dist/profiles/cache.js +19 -0
  422. package/dist/profiles/capacity.d.ts +2 -0
  423. package/dist/profiles/capacity.js +20 -0
  424. package/dist/profiles/export.d.ts +3 -0
  425. package/dist/profiles/export.js +85 -0
  426. package/dist/profiles/finders.d.ts +11 -0
  427. package/dist/profiles/finders.js +39 -0
  428. package/dist/profiles/helpers.d.ts +35 -0
  429. package/dist/profiles/helpers.js +10 -0
  430. package/dist/profiles/index.d.ts +5 -0
  431. package/dist/profiles/index.js +18 -0
  432. package/dist/profiles/mapping.d.ts +157 -0
  433. package/dist/profiles/mapping.js +132 -0
  434. package/dist/profiles/mutations.d.ts +9 -0
  435. package/dist/profiles/mutations.js +75 -0
  436. package/dist/pushSubscriptions/finders.d.ts +187 -0
  437. package/dist/pushSubscriptions/finders.js +6 -0
  438. package/dist/pushSubscriptions/helpers.d.ts +99 -0
  439. package/dist/pushSubscriptions/helpers.js +3 -0
  440. package/dist/pushSubscriptions/index.d.ts +3 -0
  441. package/dist/pushSubscriptions/index.js +3 -0
  442. package/dist/pushSubscriptions/mapping.d.ts +261 -0
  443. package/dist/pushSubscriptions/mapping.js +6 -0
  444. package/dist/pushSubscriptions/mutations.d.ts +95 -0
  445. package/dist/pushSubscriptions/mutations.js +21 -0
  446. package/dist/redis/connection.d.ts +4 -0
  447. package/dist/redis/connection.js +17 -0
  448. package/dist/redis/index.d.ts +1 -0
  449. package/dist/redis/index.js +1 -0
  450. package/dist/reports/finders.d.ts +6 -0
  451. package/dist/reports/finders.js +44 -0
  452. package/dist/reports/helpers.d.ts +21 -0
  453. package/dist/reports/helpers.js +12 -0
  454. package/dist/reports/index.d.ts +3 -0
  455. package/dist/reports/index.js +3 -0
  456. package/dist/reports/mapping.d.ts +9 -0
  457. package/dist/reports/mapping.js +34 -0
  458. package/dist/reports/mutations.d.ts +5 -0
  459. package/dist/reports/mutations.js +16 -0
  460. package/dist/roles/defaults.d.ts +2 -0
  461. package/dist/roles/defaults.js +94 -0
  462. package/dist/roles/finders.d.ts +5 -0
  463. package/dist/roles/finders.js +9 -0
  464. package/dist/roles/index.d.ts +4 -0
  465. package/dist/roles/index.js +4 -0
  466. package/dist/roles/mapping.d.ts +11 -0
  467. package/dist/roles/mapping.js +5 -0
  468. package/dist/roles/mutations.d.ts +4 -0
  469. package/dist/roles/mutations.js +30 -0
  470. package/dist/search/finders.d.ts +47 -0
  471. package/dist/search/finders.js +59 -0
  472. package/dist/search/helpers.d.ts +3 -0
  473. package/dist/search/helpers.js +1 -0
  474. package/dist/search/index.d.ts +1 -0
  475. package/dist/search/index.js +1 -0
  476. package/dist/search/mapping.d.ts +40 -0
  477. package/dist/search/mapping.js +43 -0
  478. package/dist/sentry/index.d.ts +34 -0
  479. package/dist/sentry/index.js +113 -0
  480. package/dist/server/helpers.d.ts +0 -0
  481. package/dist/server/helpers.js +1 -0
  482. package/dist/server/index.d.ts +105 -0
  483. package/dist/server/index.js +64 -0
  484. package/dist/stats/finders.d.ts +16156 -0
  485. package/dist/stats/finders.js +167 -0
  486. package/dist/stats/helpers.d.ts +17 -0
  487. package/dist/stats/helpers.js +34 -0
  488. package/dist/stats/index.d.ts +1 -0
  489. package/dist/stats/index.js +1 -0
  490. package/dist/stats/mapping.d.ts +188 -0
  491. package/dist/stats/mapping.js +19 -0
  492. package/dist/stripe/cache.d.ts +30 -0
  493. package/dist/stripe/cache.js +37 -0
  494. package/dist/stripe/connection.d.ts +5 -0
  495. package/dist/stripe/connection.js +23 -0
  496. package/dist/stripe/helpers.d.ts +25 -0
  497. package/dist/stripe/helpers.js +211 -0
  498. package/dist/stripe/index.d.ts +3 -0
  499. package/dist/stripe/index.js +3 -0
  500. package/package.json +99 -0
@@ -0,0 +1,392 @@
1
+ import { ConfigSchema, CoreConfig, ConfigSchemaFactory, CapabilitiesConfig } from '@openpeepshq/common/types';
2
+ import { defaultConfig } from './defaults/core';
3
+ import { defaultCommunityConfig } from './defaults/community';
4
+ import { default as logsConfig } from './defaults/logs';
5
+ import { default as dbConfig } from './defaults/db';
6
+ export { defaultConfig, defaultCommunityConfig, logsConfig, dbConfig };
7
+ export { pruneEmptyConfigStrings } from './pruneEmptyConfigStrings';
8
+ export declare const hasConfigSchema: (namespace: string, name: string) => boolean;
9
+ export declare const registerConfigSchema: <T>(namespace: string, name: string, factory: ConfigSchemaFactory<T>, defaults: T) => Map<string, ConfigSchema<unknown>>;
10
+ export declare const refreshConfig: (namespace?: string, name?: string) => void;
11
+ /**
12
+ * Merge a sparse patch into the stored config overrides.
13
+ * Callers must use this (not a full replace) so unrelated keys survive —
14
+ * admin UI forms and pin/unpin all send partial trees.
15
+ */
16
+ export declare const updateConfigValues: (configValues: unknown, namespace?: string, name?: string) => Promise<void>;
17
+ export declare const config: <T = {
18
+ version: string;
19
+ environment: string;
20
+ server: {
21
+ host: string;
22
+ signUpsOpen: boolean;
23
+ publicContent: boolean;
24
+ maxProfiles?: number | undefined;
25
+ };
26
+ db: {
27
+ url: string;
28
+ databaseUrl: string;
29
+ databaseName?: string | undefined;
30
+ };
31
+ redis: {
32
+ host: string;
33
+ };
34
+ email: {
35
+ service: string;
36
+ defaultTemplatePath: string;
37
+ transportConfig: {
38
+ host: string;
39
+ port: number;
40
+ secure: boolean;
41
+ auth?: {
42
+ user?: string | undefined;
43
+ pass?: string | undefined;
44
+ } | undefined;
45
+ };
46
+ defaultFrom?: string | undefined;
47
+ };
48
+ logs: {
49
+ local: {
50
+ path: string;
51
+ };
52
+ };
53
+ media: {
54
+ storage: {
55
+ driver: "openpeeps";
56
+ params: {
57
+ path: string;
58
+ prefix: string;
59
+ host?: string | undefined;
60
+ };
61
+ };
62
+ };
63
+ network: {
64
+ port: number;
65
+ };
66
+ plugins: {
67
+ path: string;
68
+ };
69
+ secrets: {
70
+ jwt: string;
71
+ };
72
+ jams: {
73
+ livekit: {
74
+ url: string;
75
+ apiKey?: string | undefined;
76
+ apiSecret?: string | undefined;
77
+ recordingEnabled?: boolean | undefined;
78
+ };
79
+ };
80
+ vapid: {
81
+ privateKey?: string | undefined;
82
+ publicKey?: string | undefined;
83
+ };
84
+ federation: {
85
+ active: boolean;
86
+ };
87
+ activityPub: {
88
+ defaultDomain: string;
89
+ itemsPerPage: number;
90
+ threadDepth: number;
91
+ federation: {
92
+ requestTimeout: number;
93
+ };
94
+ };
95
+ sso: {
96
+ generic: {
97
+ userProfileRequest: {
98
+ url: string;
99
+ authHeader?: string | undefined;
100
+ };
101
+ userProfilePaths: {
102
+ email: string;
103
+ handle?: string | undefined;
104
+ avatar?: string | undefined;
105
+ displayName?: string | undefined;
106
+ };
107
+ createAccounts?: boolean | undefined;
108
+ createProfiles?: boolean | undefined;
109
+ }[];
110
+ oidc: {
111
+ id: string;
112
+ name: string;
113
+ authorizationUrl: string;
114
+ tokenUrl: string;
115
+ userinfoUrl: string;
116
+ clientId: string;
117
+ jwksUri?: string | undefined;
118
+ clientSecret?: string | undefined;
119
+ scope?: string | undefined;
120
+ claimMapping?: {
121
+ email?: string | undefined;
122
+ handle?: string | undefined;
123
+ displayName?: string | undefined;
124
+ avatar?: string | undefined;
125
+ } | undefined;
126
+ approvalRequired?: boolean | undefined;
127
+ }[];
128
+ };
129
+ services: {
130
+ sentry: {
131
+ enabled: boolean;
132
+ dsn?: string | undefined;
133
+ replayEnabled?: boolean | undefined;
134
+ };
135
+ location: {
136
+ type: string;
137
+ url: string;
138
+ apiKey?: string | undefined;
139
+ };
140
+ };
141
+ apps: {
142
+ ios: {
143
+ url?: string | undefined;
144
+ bundleIdentifier?: string | undefined;
145
+ teamId?: string | undefined;
146
+ appId?: string | undefined;
147
+ apnKeyId?: string | undefined;
148
+ apnSigningKey?: string | undefined;
149
+ };
150
+ android: {
151
+ url?: string | undefined;
152
+ packageName?: string | undefined;
153
+ appId?: string | undefined;
154
+ fcmCredentials?: string | undefined;
155
+ };
156
+ };
157
+ payments: {
158
+ stripe: {
159
+ paidMembership?: {
160
+ enabled: boolean;
161
+ productId?: string | undefined;
162
+ trialPeriodDays?: number | undefined;
163
+ } | undefined;
164
+ publishableKey?: string | undefined;
165
+ secretKey?: string | undefined;
166
+ webhookSecret?: string | undefined;
167
+ };
168
+ };
169
+ }>(namespace?: string, name?: string) => Promise<T>;
170
+ export declare const communityConfig: () => Promise<{
171
+ theme: {
172
+ base: string;
173
+ primaryHex: string;
174
+ light: {
175
+ primaryHex: string;
176
+ logoSmall?: string | undefined;
177
+ defaultProfileAvatar?: string | undefined;
178
+ defaultGroupAvatar?: string | undefined;
179
+ backgroundAuth?: string | undefined;
180
+ background?: string | undefined;
181
+ };
182
+ dark: {
183
+ primaryHex: string;
184
+ logoSmall?: string | undefined;
185
+ defaultProfileAvatar?: string | undefined;
186
+ defaultGroupAvatar?: string | undefined;
187
+ backgroundAuth?: string | undefined;
188
+ background?: string | undefined;
189
+ };
190
+ icon?: string | undefined;
191
+ mobileIcon?: string | undefined;
192
+ logoFull?: string | undefined;
193
+ logoSmall?: string | undefined;
194
+ defaultProfileAvatar?: string | undefined;
195
+ defaultGroupAvatar?: string | undefined;
196
+ backgroundAuth?: string | undefined;
197
+ background?: string | undefined;
198
+ };
199
+ info: {
200
+ name: string;
201
+ tagLine: string;
202
+ contactEmail?: string | undefined;
203
+ privacyPolicy?: string | undefined;
204
+ termsAndConditions?: string | undefined;
205
+ };
206
+ content: {
207
+ aboutPage?: string | undefined;
208
+ welcomePage?: string | undefined;
209
+ codeOfConduct?: string | undefined;
210
+ welcomeEmail?: string | undefined;
211
+ pinnedPost?: string | undefined;
212
+ };
213
+ settings: {
214
+ openRegistrations: boolean;
215
+ defaultLanguage?: string | undefined;
216
+ };
217
+ roles: {
218
+ onRegistration: {
219
+ add: string[];
220
+ remove: string[];
221
+ };
222
+ onEmailValidation: {
223
+ add: string[];
224
+ remove: string[];
225
+ };
226
+ };
227
+ profiles?: {
228
+ additionalFields?: {
229
+ key: string;
230
+ label: string;
231
+ icon?: string | undefined;
232
+ linkPattern?: string | undefined;
233
+ }[] | undefined;
234
+ } | undefined;
235
+ }>;
236
+ export declare const capabilitiesConfig: () => Promise<CapabilitiesConfig>;
237
+ export declare const sanitizedConfigWithDefaults: <T = {
238
+ version: string;
239
+ environment: string;
240
+ server: {
241
+ host: string;
242
+ signUpsOpen: boolean;
243
+ publicContent: boolean;
244
+ maxProfiles?: number | undefined;
245
+ };
246
+ db: {
247
+ url: string;
248
+ databaseUrl: string;
249
+ databaseName?: string | undefined;
250
+ };
251
+ redis: {
252
+ host: string;
253
+ };
254
+ email: {
255
+ service: string;
256
+ defaultTemplatePath: string;
257
+ transportConfig: {
258
+ host: string;
259
+ port: number;
260
+ secure: boolean;
261
+ auth?: {
262
+ user?: string | undefined;
263
+ pass?: string | undefined;
264
+ } | undefined;
265
+ };
266
+ defaultFrom?: string | undefined;
267
+ };
268
+ logs: {
269
+ local: {
270
+ path: string;
271
+ };
272
+ };
273
+ media: {
274
+ storage: {
275
+ driver: "openpeeps";
276
+ params: {
277
+ path: string;
278
+ prefix: string;
279
+ host?: string | undefined;
280
+ };
281
+ };
282
+ };
283
+ network: {
284
+ port: number;
285
+ };
286
+ plugins: {
287
+ path: string;
288
+ };
289
+ secrets: {
290
+ jwt: string;
291
+ };
292
+ jams: {
293
+ livekit: {
294
+ url: string;
295
+ apiKey?: string | undefined;
296
+ apiSecret?: string | undefined;
297
+ recordingEnabled?: boolean | undefined;
298
+ };
299
+ };
300
+ vapid: {
301
+ privateKey?: string | undefined;
302
+ publicKey?: string | undefined;
303
+ };
304
+ federation: {
305
+ active: boolean;
306
+ };
307
+ activityPub: {
308
+ defaultDomain: string;
309
+ itemsPerPage: number;
310
+ threadDepth: number;
311
+ federation: {
312
+ requestTimeout: number;
313
+ };
314
+ };
315
+ sso: {
316
+ generic: {
317
+ userProfileRequest: {
318
+ url: string;
319
+ authHeader?: string | undefined;
320
+ };
321
+ userProfilePaths: {
322
+ email: string;
323
+ handle?: string | undefined;
324
+ avatar?: string | undefined;
325
+ displayName?: string | undefined;
326
+ };
327
+ createAccounts?: boolean | undefined;
328
+ createProfiles?: boolean | undefined;
329
+ }[];
330
+ oidc: {
331
+ id: string;
332
+ name: string;
333
+ authorizationUrl: string;
334
+ tokenUrl: string;
335
+ userinfoUrl: string;
336
+ clientId: string;
337
+ jwksUri?: string | undefined;
338
+ clientSecret?: string | undefined;
339
+ scope?: string | undefined;
340
+ claimMapping?: {
341
+ email?: string | undefined;
342
+ handle?: string | undefined;
343
+ displayName?: string | undefined;
344
+ avatar?: string | undefined;
345
+ } | undefined;
346
+ approvalRequired?: boolean | undefined;
347
+ }[];
348
+ };
349
+ services: {
350
+ sentry: {
351
+ enabled: boolean;
352
+ dsn?: string | undefined;
353
+ replayEnabled?: boolean | undefined;
354
+ };
355
+ location: {
356
+ type: string;
357
+ url: string;
358
+ apiKey?: string | undefined;
359
+ };
360
+ };
361
+ apps: {
362
+ ios: {
363
+ url?: string | undefined;
364
+ bundleIdentifier?: string | undefined;
365
+ teamId?: string | undefined;
366
+ appId?: string | undefined;
367
+ apnKeyId?: string | undefined;
368
+ apnSigningKey?: string | undefined;
369
+ };
370
+ android: {
371
+ url?: string | undefined;
372
+ packageName?: string | undefined;
373
+ appId?: string | undefined;
374
+ fcmCredentials?: string | undefined;
375
+ };
376
+ };
377
+ payments: {
378
+ stripe: {
379
+ paidMembership?: {
380
+ enabled: boolean;
381
+ productId?: string | undefined;
382
+ trialPeriodDays?: number | undefined;
383
+ } | undefined;
384
+ publishableKey?: string | undefined;
385
+ secretKey?: string | undefined;
386
+ webhookSecret?: string | undefined;
387
+ };
388
+ };
389
+ }>(namespace?: string, name?: string) => Promise<{
390
+ config: unknown;
391
+ defaults: unknown;
392
+ }>;
@@ -0,0 +1,83 @@
1
+ import { deepmergeCustom } from 'deepmerge-ts';
2
+ import { coreConfigSchemaFactory, communityConfigSchemaFactory, capabilitiesConfigSchemaFactory, } from '@openpeepshq/common/types';
3
+ import { zodDeepPartialSchema } from '../lib/zodDeepPartial.js';
4
+ import { defaultConfig } from './defaults/core.js';
5
+ import { defaultCommunityConfig } from './defaults/community.js';
6
+ import { default as logsConfig } from './defaults/logs.js';
7
+ import { default as dbConfig } from './defaults/db.js';
8
+ import { hub } from '../events/index.js';
9
+ import { loadConfig, storeConfig } from './db.js';
10
+ import { defaultCapabilitiesConfig } from './defaults/capabilities.js';
11
+ import { pruneEmptyConfigStrings } from './pruneEmptyConfigStrings.js';
12
+ export { defaultConfig, defaultCommunityConfig, logsConfig, dbConfig };
13
+ export { pruneEmptyConfigStrings } from './pruneEmptyConfigStrings.js';
14
+ const deepmerge = deepmergeCustom({
15
+ mergeArrays: (values) => values[1],
16
+ });
17
+ const configPromises = new Map();
18
+ const configSchemaRegistry = new Map();
19
+ const configKey = (namespace, name) => `${namespace}-${name}`;
20
+ export const hasConfigSchema = (namespace, name) => configSchemaRegistry.has(configKey(namespace, name));
21
+ export const registerConfigSchema = (namespace, name, factory, defaults) => configSchemaRegistry.set(configKey(namespace, name), {
22
+ factory,
23
+ defaults,
24
+ });
25
+ registerConfigSchema('openpeeps', 'core', coreConfigSchemaFactory, defaultConfig);
26
+ registerConfigSchema('openpeeps', 'community', communityConfigSchemaFactory, defaultCommunityConfig);
27
+ registerConfigSchema('openpeeps', 'capabilities', capabilitiesConfigSchemaFactory, defaultCapabilitiesConfig);
28
+ const initConfig = async (namespace, name) => {
29
+ const key = configKey(namespace, name);
30
+ const customConfigDocument = await loadConfig(key);
31
+ const { defaults, factory } = configSchemaRegistry.get(configKey(namespace, name)) || {};
32
+ if (!factory) {
33
+ throw new Error(`No config registered for ${key}`);
34
+ }
35
+ const customConfig = (customConfigDocument === null || customConfigDocument === void 0 ? void 0 : customConfigDocument.config) &&
36
+ zodDeepPartialSchema(factory()).parse(pruneEmptyConfigStrings(customConfigDocument.config));
37
+ return (customConfig ? deepmerge(defaults, customConfig) : defaults);
38
+ };
39
+ export const refreshConfig = (namespace = 'openpeeps', name = 'core') => {
40
+ configPromises.set(configKey(namespace, name), initConfig(namespace, name));
41
+ };
42
+ /** Full-document write. Prefer `updateConfigValues` for patches. */
43
+ const replaceStoredConfig = (config, namespace = 'openpeeps', name = 'core') => storeConfig(configKey(namespace, name), {
44
+ config: pruneEmptyConfigStrings(config),
45
+ })
46
+ .then(() => refreshConfig(namespace, name))
47
+ .then(() => hub.emit('configUpdated', namespace, name));
48
+ /**
49
+ * Merge a sparse patch into the stored config overrides.
50
+ * Callers must use this (not a full replace) so unrelated keys survive —
51
+ * admin UI forms and pin/unpin all send partial trees.
52
+ */
53
+ export const updateConfigValues = (configValues, namespace = 'openpeeps', name = 'core') => loadConfig(configKey(namespace, name)).then((configDocument) => {
54
+ var _a;
55
+ return replaceStoredConfig(deepmerge((_a = configDocument === null || configDocument === void 0 ? void 0 : configDocument.config) !== null && _a !== void 0 ? _a : {}, configValues), namespace, name);
56
+ });
57
+ export const config = (namespace = 'openpeeps', name = 'core') => {
58
+ const key = configKey(namespace, name);
59
+ // Integration suites restore backups while the process is running; skip the
60
+ // in-memory cache so config always reflects the current DB.
61
+ if (process.env.DISABLE_CONFIG_CACHE === 'true') {
62
+ return initConfig(namespace, name);
63
+ }
64
+ if (!configPromises.has(key)) {
65
+ configPromises.set(key, initConfig(namespace, name));
66
+ }
67
+ return configPromises.get(key);
68
+ };
69
+ export const communityConfig = () => config('openpeeps', 'community');
70
+ export const capabilitiesConfig = () => config('openpeeps', 'capabilities').then((loaded) => {
71
+ var _a, _b;
72
+ return (Object.assign(Object.assign({}, loaded), { accessToken: deepmerge((_a = defaultCapabilitiesConfig.accessToken) !== null && _a !== void 0 ? _a : {}, (_b = loaded.accessToken) !== null && _b !== void 0 ? _b : {}) }));
73
+ });
74
+ export const sanitizedConfigWithDefaults = async (namespace = 'openpeeps', name = 'core') => {
75
+ var _a;
76
+ const key = configKey(namespace, name);
77
+ const { defaults, factory } = (_a = configSchemaRegistry.get(key)) !== null && _a !== void 0 ? _a : {};
78
+ const sanitizedSchema = factory && factory(true);
79
+ return {
80
+ config: sanitizedSchema === null || sanitizedSchema === void 0 ? void 0 : sanitizedSchema.parse(await config(namespace, name)),
81
+ defaults: sanitizedSchema === null || sanitizedSchema === void 0 ? void 0 : sanitizedSchema.parse(defaults),
82
+ };
83
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Drop object keys whose value is exactly `""` so cleared config fields are
3
+ * absent from stored overrides and fall back to defaults on merge.
4
+ * Leaves arrays intact (only recurses into object elements). Drops empty
5
+ * plain objects left after pruning children.
6
+ */
7
+ export declare const pruneEmptyConfigStrings: (value: unknown) => unknown;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Drop object keys whose value is exactly `""` so cleared config fields are
3
+ * absent from stored overrides and fall back to defaults on merge.
4
+ * Leaves arrays intact (only recurses into object elements). Drops empty
5
+ * plain objects left after pruning children.
6
+ */
7
+ export const pruneEmptyConfigStrings = (value) => {
8
+ if (value === null || typeof value !== 'object')
9
+ return value;
10
+ if (Array.isArray(value)) {
11
+ return value.map((item) => item !== null && typeof item === 'object'
12
+ ? pruneEmptyConfigStrings(item)
13
+ : item);
14
+ }
15
+ const result = {};
16
+ for (const [key, child] of Object.entries(value)) {
17
+ if (child === '')
18
+ continue;
19
+ const pruned = pruneEmptyConfigStrings(child);
20
+ if (pruned !== null &&
21
+ typeof pruned === 'object' &&
22
+ !Array.isArray(pruned) &&
23
+ Object.keys(pruned).length === 0) {
24
+ continue;
25
+ }
26
+ result[key] = pruned;
27
+ }
28
+ return result;
29
+ };
File without changes
package/dist/db/aql.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,2 @@
1
+ import { Database } from 'arangojs';
2
+ export declare const arangoDb: () => Promise<Database>;
@@ -0,0 +1,110 @@
1
+ import { Database } from 'arangojs';
2
+ import { defaultConfig } from '../config/defaults/core.js';
3
+ import { ArangoError } from 'arangojs/errors';
4
+ import { logger } from '../log/index.js';
5
+ import { sleep } from '@openpeepshq/common/lib';
6
+ const log = logger('openpeeps:db');
7
+ const DB_AVAILABILITY_TIMEOUT = 10000;
8
+ let dbPromise;
9
+ const handleArangoError = (method, params) => (e) => {
10
+ var _a;
11
+ if (e instanceof ArangoError) {
12
+ if (method === 'query') {
13
+ log.error('===============================');
14
+ log.error('===============================');
15
+ // @ts-expect-error type guaranteed because of method name
16
+ if (params[0].query && typeof params[0].query === 'string') {
17
+ // @ts-expect-error type guaranteed because of method name
18
+ const queryText = params[0].query;
19
+ log.error(queryText
20
+ .split('\n')
21
+ .map((line, i) => `${i + 1}: ${line}`)
22
+ .join('\n'));
23
+ // @ts-expect-error type guaranteed because of method name
24
+ log.error(params[0].bindVars);
25
+ log.error('querylength', queryText.length);
26
+ }
27
+ log.error('===============================');
28
+ log.error(e.message);
29
+ log.error('===============================');
30
+ throw new Error(e.message);
31
+ }
32
+ throw {
33
+ request: {
34
+ method,
35
+ params,
36
+ },
37
+ response: (_a = e.response) === null || _a === void 0 ? void 0 : _a.body,
38
+ };
39
+ }
40
+ else {
41
+ throw e;
42
+ }
43
+ };
44
+ const waitForDatabase = async (config) => {
45
+ const start = Date.now();
46
+ // Ping the server via `_system`; the target database may not exist yet.
47
+ const database = new Database(Object.assign(Object.assign({}, config), { databaseName: '_system' }));
48
+ let tryCount = 1;
49
+ while (true) {
50
+ log.info(`Checking ArangoDB availability at ${config.url} (try ${tryCount})`);
51
+ const availability = await database.availability(true).catch(() => false);
52
+ if (availability) {
53
+ log.info(`ArangoDB is available at ${config.url}`);
54
+ break;
55
+ }
56
+ if (Date.now() - start > DB_AVAILABILITY_TIMEOUT) {
57
+ log.error(`ArangoDB is not available at ${config.url} after ${DB_AVAILABILITY_TIMEOUT}ms`);
58
+ process.exit(1);
59
+ }
60
+ await sleep(1);
61
+ tryCount++;
62
+ }
63
+ };
64
+ const initArangoDb = async () => {
65
+ const config = defaultConfig.db;
66
+ await waitForDatabase(config);
67
+ if (config.databaseName) {
68
+ log.info(`Using database "${config.databaseName}"`);
69
+ const systemDb = new Database(Object.assign(Object.assign({}, config), { databaseName: '_system' }));
70
+ if (!(await systemDb.database(config.databaseName).exists())) {
71
+ log.info(`Creating database "${config.databaseName}"`);
72
+ await systemDb.createDatabase(config.databaseName);
73
+ }
74
+ }
75
+ else {
76
+ log.info('Using default database');
77
+ }
78
+ return new Proxy(new Database(defaultConfig.db), {
79
+ get: (target, propertyName) => {
80
+ const property = target[propertyName];
81
+ if (typeof property === 'function') {
82
+ const decoratedFunction = (...args) => {
83
+ try {
84
+ // @ts-expect-error typing is guaranteed to be correct
85
+ const result = target[propertyName](...args);
86
+ if (result instanceof Promise) {
87
+ return result.catch(handleArangoError(propertyName, args));
88
+ }
89
+ else {
90
+ return result;
91
+ }
92
+ }
93
+ catch (e) {
94
+ handleArangoError(propertyName, args)(e);
95
+ }
96
+ };
97
+ return decoratedFunction.bind(target);
98
+ }
99
+ else {
100
+ return target[propertyName];
101
+ }
102
+ },
103
+ });
104
+ };
105
+ export const arangoDb = async () => {
106
+ if (!dbPromise) {
107
+ dbPromise = initArangoDb();
108
+ }
109
+ return dbPromise;
110
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { logger } from '../log/index.js';
2
+ import { initDb } from './init.js';
3
+ import { closePostgres } from './pg/client.js';
4
+ const log = logger('allpeep:db:boot-migrate');
5
+ // One-shot deploy migrate (`start.sh migrate` / apatmigrate).
6
+ initDb()
7
+ .then(() => closePostgres())
8
+ .then(() => {
9
+ log.info('Migrate job finished');
10
+ process.exit(0);
11
+ })
12
+ .catch((err) => {
13
+ log.error('Migrate job failed', err);
14
+ void closePostgres().finally(() => process.exit(1));
15
+ });
@@ -0,0 +1 @@
1
+ export declare const empty: () => Promise<void>;
@@ -0,0 +1,13 @@
1
+ import { getTableName } from 'drizzle-orm';
2
+ import { initPostgres, pgPool } from './pg/client.js';
3
+ import { schema } from './pg/schema/index.js';
4
+ export const empty = async () => {
5
+ await initPostgres();
6
+ const tableNames = Object.values(schema).map((table) => getTableName(table));
7
+ if (tableNames.length === 0) {
8
+ return;
9
+ }
10
+ const quoted = tableNames.map((name) => `"${name}"`).join(', ');
11
+ await pgPool().query(`TRUNCATE ${quoted} RESTART IDENTITY CASCADE`);
12
+ console.log(`Truncated ${tableNames.length} tables`);
13
+ };
@@ -0,0 +1 @@
1
+ export declare const rowsToCsv: (columns: string[], rows: Array<Record<string, unknown>>) => string;
@@ -0,0 +1,18 @@
1
+ import { toCsvRow } from '@openpeepshq/common/lib';
2
+ export const rowsToCsv = (columns, rows) => {
3
+ const header = toCsvRow(columns);
4
+ const body = rows.map((row) => toCsvRow(columns.map((col) => {
5
+ const value = row[col];
6
+ if (value == null)
7
+ return '';
8
+ if (typeof value === 'object')
9
+ return JSON.stringify(value);
10
+ if (typeof value === 'string' ||
11
+ typeof value === 'number' ||
12
+ typeof value === 'boolean') {
13
+ return value;
14
+ }
15
+ return String(value);
16
+ })));
17
+ return [header, ...body].join('\n');
18
+ };