@m5kdev/backend 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (553) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +13 -0
  2. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/api/index.d.mts +1 -0
  3. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/db/adapter/factory.d.mts +1 -0
  4. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/db/adapter/get-field-attributes.d.mts +1 -0
  5. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/db/adapter/get-id-field.d.mts +1 -0
  6. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/db/adapter/index.d.mts +1 -0
  7. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/db/adapter/types.d.mts +1 -0
  8. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/db/get-tables.d.mts +1 -0
  9. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/db/index.d.mts +1 -0
  10. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/db/schema/account.d.mts +1 -0
  11. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/db/schema/rate-limit.d.mts +1 -0
  12. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/db/schema/session.d.mts +1 -0
  13. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/db/schema/shared.d.mts +1 -0
  14. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/db/schema/user.d.mts +1 -0
  15. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/db/schema/verification.d.mts +1 -0
  16. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/index.d.mts +1 -0
  17. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/social-providers/index.d.mts +1 -0
  18. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/types/context.d.mts +1 -0
  19. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/types/helper.d.mts +7 -0
  20. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/types/init-options.d.mts +1 -0
  21. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/types/plugin-client.d.mts +1 -0
  22. package/dist/node_modules/.pnpm/@better-auth_core@1.4.18_@better-auth_utils@0.3.0_@better-fetch_fetch@1.1.21_better-cal_347838d331444e5371f256b914727290/node_modules/@better-auth/core/dist/types/plugin.d.mts +1 -0
  23. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/dialect-adapter-base.d.mts +1 -0
  24. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/dialect-adapter.d.mts +1 -0
  25. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/dialect.d.mts +1 -0
  26. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/mssql/mssql-adapter.d.mts +1 -0
  27. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/mssql/mssql-dialect.d.mts +1 -0
  28. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/mssql/mssql-introspector.d.mts +1 -0
  29. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/mysql/mysql-adapter.d.mts +1 -0
  30. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/mysql/mysql-dialect.d.mts +1 -0
  31. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/mysql/mysql-introspector.d.mts +1 -0
  32. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/postgres/postgres-adapter.d.mts +1 -0
  33. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/postgres/postgres-dialect.d.mts +1 -0
  34. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/postgres/postgres-introspector.d.mts +1 -0
  35. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/sqlite/sqlite-adapter.d.mts +1 -0
  36. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/sqlite/sqlite-dialect.d.mts +1 -0
  37. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/dialect/sqlite/sqlite-introspector.d.mts +1 -0
  38. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/expression/expression-builder.d.mts +1 -0
  39. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/index.d.mts +1 -0
  40. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/kysely.d.mts +38 -0
  41. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/migration/file-migration-provider.d.mts +1 -0
  42. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/migration/migrator.d.mts +1 -0
  43. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/binary-operation-parser.d.mts +1 -0
  44. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/delete-from-parser.d.mts +1 -0
  45. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/expression-parser.d.mts +1 -0
  46. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/group-by-parser.d.mts +1 -0
  47. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/insert-values-parser.d.mts +1 -0
  48. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/join-parser.d.mts +1 -0
  49. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/merge-into-parser.d.mts +1 -0
  50. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/reference-parser.d.mts +1 -0
  51. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/returning-parser.d.mts +1 -0
  52. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/select-from-parser.d.mts +1 -0
  53. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/select-parser.d.mts +1 -0
  54. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/set-operation-parser.d.mts +1 -0
  55. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/tuple-parser.d.mts +1 -0
  56. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/unary-operation-parser.d.mts +1 -0
  57. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/update-parser.d.mts +1 -0
  58. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/update-set-parser.d.mts +1 -0
  59. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/value-parser.d.mts +1 -0
  60. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/parser/with-parser.d.mts +1 -0
  61. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-builder/case-builder.d.mts +1 -0
  62. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-builder/delete-query-builder.d.mts +1 -0
  63. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-builder/having-interface.d.mts +1 -0
  64. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-builder/insert-query-builder.d.mts +1 -0
  65. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-builder/join-builder.d.mts +1 -0
  66. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-builder/merge-query-builder.d.mts +1 -0
  67. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-builder/on-conflict-builder.d.mts +1 -0
  68. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-builder/output-interface.d.mts +1 -0
  69. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-builder/returning-interface.d.mts +1 -0
  70. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-builder/select-query-builder.d.mts +1 -0
  71. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-builder/update-query-builder.d.mts +1 -0
  72. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-builder/where-interface.d.mts +1 -0
  73. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-creator.d.mts +1 -0
  74. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-executor/default-query-executor.d.mts +1 -0
  75. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-executor/noop-query-executor.d.mts +1 -0
  76. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-executor/query-executor-base.d.mts +1 -0
  77. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-executor/query-executor-provider.d.mts +1 -0
  78. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/query-executor/query-executor.d.mts +1 -0
  79. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/raw-builder/raw-builder.d.mts +1 -0
  80. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/raw-builder/sql.d.mts +1 -0
  81. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/alter-table-add-foreign-key-constraint-builder.d.mts +1 -0
  82. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/alter-table-add-index-builder.d.mts +1 -0
  83. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/alter-table-builder.d.mts +1 -0
  84. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/alter-table-drop-constraint-builder.d.mts +1 -0
  85. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/alter-table-executor.d.mts +1 -0
  86. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/create-index-builder.d.mts +1 -0
  87. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/create-schema-builder.d.mts +1 -0
  88. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/create-table-builder.d.mts +1 -0
  89. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/create-type-builder.d.mts +1 -0
  90. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/create-view-builder.d.mts +1 -0
  91. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/drop-index-builder.d.mts +1 -0
  92. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/drop-schema-builder.d.mts +1 -0
  93. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/drop-table-builder.d.mts +1 -0
  94. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/drop-type-builder.d.mts +1 -0
  95. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/drop-view-builder.d.mts +1 -0
  96. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/refresh-materialized-view-builder.d.mts +1 -0
  97. package/dist/node_modules/.pnpm/kysely@0.28.5/node_modules/kysely/dist/esm/schema/schema.d.mts +1 -0
  98. package/dist/src/lib/posthog.d.mts +7 -0
  99. package/dist/src/lib/posthog.mjs +7 -0
  100. package/dist/src/lib/posthog.mjs.map +1 -0
  101. package/dist/src/lib/sentry.d.mts +1 -0
  102. package/dist/src/lib/sentry.mjs +10 -0
  103. package/dist/src/lib/sentry.mjs.map +1 -0
  104. package/dist/src/modules/access/access.repository.d.mts +2352 -0
  105. package/dist/src/modules/access/access.repository.mjs +24 -0
  106. package/dist/src/modules/access/access.repository.mjs.map +1 -0
  107. package/dist/src/modules/access/access.service.d.mts +25 -0
  108. package/dist/src/modules/access/access.service.mjs +40 -0
  109. package/dist/src/modules/access/access.service.mjs.map +1 -0
  110. package/dist/src/modules/access/access.utils.d.mts +19 -0
  111. package/dist/src/modules/access/access.utils.mjs +21 -0
  112. package/dist/src/modules/access/access.utils.mjs.map +1 -0
  113. package/dist/src/modules/ai/ai.db.d.mts +401 -0
  114. package/dist/src/modules/ai/ai.db.mjs +38 -0
  115. package/dist/src/modules/ai/ai.db.mjs.map +1 -0
  116. package/dist/src/modules/ai/ai.prompt.d.mts +30 -0
  117. package/dist/src/modules/ai/ai.prompt.mjs +30 -0
  118. package/dist/src/modules/ai/ai.prompt.mjs.map +1 -0
  119. package/dist/src/modules/ai/ai.prompts.d.mts +10 -0
  120. package/dist/src/modules/ai/{ai.prompts.js → ai.prompts.mjs} +17 -15
  121. package/dist/src/modules/ai/ai.prompts.mjs.map +1 -0
  122. package/dist/src/modules/ai/ai.repository.d.mts +428 -0
  123. package/dist/src/modules/ai/ai.repository.mjs +23 -0
  124. package/dist/src/modules/ai/ai.repository.mjs.map +1 -0
  125. package/dist/src/modules/ai/ai.router.d.mts +1 -0
  126. package/dist/src/modules/ai/ai.service.d.mts +128 -0
  127. package/dist/src/modules/ai/ai.service.mjs +267 -0
  128. package/dist/src/modules/ai/ai.service.mjs.map +1 -0
  129. package/dist/src/modules/ai/ai.trpc.d.mts +31 -0
  130. package/dist/src/modules/ai/ai.trpc.mjs +17 -0
  131. package/dist/src/modules/ai/ai.trpc.mjs.map +1 -0
  132. package/dist/src/modules/ai/ideogram/ideogram.constants.d.mts +11 -0
  133. package/dist/src/modules/ai/ideogram/ideogram.constants.mjs +184 -0
  134. package/dist/src/modules/ai/ideogram/ideogram.constants.mjs.map +1 -0
  135. package/dist/src/modules/ai/ideogram/ideogram.dto.d.mts +234 -0
  136. package/dist/src/modules/ai/ideogram/ideogram.dto.mjs +45 -0
  137. package/dist/src/modules/ai/ideogram/ideogram.dto.mjs.map +1 -0
  138. package/dist/src/modules/ai/ideogram/ideogram.prompt.d.mts +7 -0
  139. package/dist/src/modules/ai/ideogram/{ideogram.prompt.js → ideogram.prompt.mjs} +861 -859
  140. package/dist/src/modules/ai/ideogram/ideogram.prompt.mjs.map +1 -0
  141. package/dist/src/modules/ai/ideogram/ideogram.repository.d.mts +11 -0
  142. package/dist/src/modules/ai/ideogram/ideogram.repository.mjs +32 -0
  143. package/dist/src/modules/ai/ideogram/ideogram.repository.mjs.map +1 -0
  144. package/dist/src/modules/ai/ideogram/ideogram.service.d.mts +14 -0
  145. package/dist/src/modules/ai/ideogram/ideogram.service.mjs +11 -0
  146. package/dist/src/modules/ai/ideogram/ideogram.service.mjs.map +1 -0
  147. package/dist/src/modules/auth/auth.db.d.mts +2341 -0
  148. package/dist/src/modules/auth/auth.db.mjs +169 -0
  149. package/dist/src/modules/auth/auth.db.mjs.map +1 -0
  150. package/dist/src/modules/auth/auth.dto.d.mts +70 -0
  151. package/dist/src/modules/auth/auth.dto.mjs +43 -0
  152. package/dist/src/modules/auth/auth.dto.mjs.map +1 -0
  153. package/dist/src/modules/auth/auth.lib.d.mts +4894 -0
  154. package/dist/src/modules/auth/auth.lib.mjs +232 -0
  155. package/dist/src/modules/auth/auth.lib.mjs.map +1 -0
  156. package/dist/src/modules/auth/auth.middleware.d.mts +619 -0
  157. package/dist/src/modules/auth/auth.middleware.mjs +38 -0
  158. package/dist/src/modules/auth/auth.middleware.mjs.map +1 -0
  159. package/dist/src/modules/auth/auth.repository.d.mts +2453 -0
  160. package/dist/src/modules/auth/auth.repository.mjs +401 -0
  161. package/dist/src/modules/auth/auth.repository.mjs.map +1 -0
  162. package/dist/src/modules/auth/auth.service.d.mts +105 -0
  163. package/dist/src/modules/auth/auth.service.mjs +227 -0
  164. package/dist/src/modules/auth/auth.service.mjs.map +1 -0
  165. package/dist/src/modules/auth/auth.trpc.d.mts +303 -0
  166. package/dist/src/modules/auth/auth.trpc.mjs +108 -0
  167. package/dist/src/modules/auth/auth.trpc.mjs.map +1 -0
  168. package/dist/src/modules/auth/auth.utils.d.mts +2356 -0
  169. package/dist/src/modules/auth/auth.utils.mjs +77 -0
  170. package/dist/src/modules/auth/auth.utils.mjs.map +1 -0
  171. package/dist/src/modules/base/base.abstract.d.mts +29 -0
  172. package/dist/src/modules/base/base.abstract.mjs +60 -0
  173. package/dist/src/modules/base/base.abstract.mjs.map +1 -0
  174. package/dist/src/modules/base/base.actor.d.mts +73 -0
  175. package/dist/src/modules/base/base.actor.mjs +78 -0
  176. package/dist/src/modules/base/base.actor.mjs.map +1 -0
  177. package/dist/src/modules/base/base.dto.d.mts +67 -0
  178. package/dist/src/modules/base/base.dto.mjs +79 -0
  179. package/dist/src/modules/base/base.dto.mjs.map +1 -0
  180. package/dist/src/modules/base/base.grants.d.mts +28 -0
  181. package/dist/src/modules/base/base.grants.mjs +103 -0
  182. package/dist/src/modules/base/base.grants.mjs.map +1 -0
  183. package/dist/src/modules/base/base.procedure.d.mts +111 -0
  184. package/dist/src/modules/base/base.procedure.mjs +252 -0
  185. package/dist/src/modules/base/base.procedure.mjs.map +1 -0
  186. package/dist/src/modules/base/base.repository.d.mts +123 -0
  187. package/dist/src/modules/base/base.repository.mjs +250 -0
  188. package/dist/src/modules/base/base.repository.mjs.map +1 -0
  189. package/dist/src/modules/base/base.service.d.mts +44 -0
  190. package/dist/src/modules/base/base.service.mjs +116 -0
  191. package/dist/src/modules/base/base.service.mjs.map +1 -0
  192. package/dist/src/modules/base/base.types.d.mts +5 -0
  193. package/dist/src/modules/billing/billing.db.d.mts +371 -0
  194. package/dist/src/modules/billing/billing.db.mjs +31 -0
  195. package/dist/src/modules/billing/billing.db.mjs.map +1 -0
  196. package/dist/src/modules/billing/billing.repository.d.mts +2787 -0
  197. package/dist/src/modules/billing/billing.repository.mjs +188 -0
  198. package/dist/src/modules/billing/billing.repository.mjs.map +1 -0
  199. package/dist/src/modules/billing/billing.router.d.mts +9 -0
  200. package/dist/src/modules/billing/billing.router.mjs +40 -0
  201. package/dist/src/modules/billing/billing.router.mjs.map +1 -0
  202. package/dist/src/modules/billing/billing.service.d.mts +53 -0
  203. package/dist/src/modules/billing/billing.service.mjs +125 -0
  204. package/dist/src/modules/billing/billing.service.mjs.map +1 -0
  205. package/dist/src/modules/billing/billing.trpc.d.mts +29 -0
  206. package/dist/src/modules/billing/billing.trpc.mjs +17 -0
  207. package/dist/src/modules/billing/billing.trpc.mjs.map +1 -0
  208. package/dist/src/modules/clay/clay.repository.d.mts +10 -0
  209. package/dist/src/modules/clay/clay.repository.mjs +27 -0
  210. package/dist/src/modules/clay/clay.repository.mjs.map +1 -0
  211. package/dist/src/modules/clay/clay.service.d.mts +32 -0
  212. package/dist/src/modules/clay/clay.service.mjs +23 -0
  213. package/dist/src/modules/clay/clay.service.mjs.map +1 -0
  214. package/dist/src/modules/connect/connect.db.d.mts +362 -0
  215. package/dist/src/modules/connect/connect.db.mjs +30 -0
  216. package/dist/src/modules/connect/connect.db.mjs.map +1 -0
  217. package/dist/src/modules/connect/connect.dto.d.mts +79 -0
  218. package/dist/src/modules/connect/connect.dto.mjs +38 -0
  219. package/dist/src/modules/connect/connect.dto.mjs.map +1 -0
  220. package/dist/src/modules/connect/connect.linkedin.d.mts +7 -0
  221. package/dist/src/modules/connect/connect.linkedin.mjs +47 -0
  222. package/dist/src/modules/connect/connect.linkedin.mjs.map +1 -0
  223. package/dist/src/modules/connect/connect.oauth.d.mts +32 -0
  224. package/dist/src/modules/connect/connect.oauth.mjs +145 -0
  225. package/dist/src/modules/connect/connect.oauth.mjs.map +1 -0
  226. package/dist/src/modules/connect/connect.repository.d.mts +419 -0
  227. package/dist/src/modules/connect/connect.repository.mjs +40 -0
  228. package/dist/src/modules/connect/connect.repository.mjs.map +1 -0
  229. package/dist/src/modules/connect/connect.router.d.mts +9 -0
  230. package/dist/src/modules/connect/connect.router.mjs +46 -0
  231. package/dist/src/modules/connect/connect.router.mjs.map +1 -0
  232. package/dist/src/modules/connect/connect.service.d.mts +103 -0
  233. package/dist/src/modules/connect/connect.service.mjs +88 -0
  234. package/dist/src/modules/connect/connect.service.mjs.map +1 -0
  235. package/dist/src/modules/connect/connect.trpc.d.mts +53 -0
  236. package/dist/src/modules/connect/connect.trpc.mjs +17 -0
  237. package/dist/src/modules/connect/connect.trpc.mjs.map +1 -0
  238. package/dist/src/modules/connect/connect.types.d.mts +29 -0
  239. package/dist/src/modules/crypto/crypto.db.d.mts +157 -0
  240. package/dist/src/modules/crypto/crypto.db.mjs +19 -0
  241. package/dist/src/modules/crypto/crypto.db.mjs.map +1 -0
  242. package/dist/src/modules/crypto/crypto.repository.d.mts +163 -0
  243. package/dist/src/modules/crypto/crypto.repository.mjs +9 -0
  244. package/dist/src/modules/crypto/crypto.repository.mjs.map +1 -0
  245. package/dist/src/modules/crypto/crypto.service.d.mts +15 -0
  246. package/dist/src/modules/crypto/crypto.service.mjs +40 -0
  247. package/dist/src/modules/crypto/crypto.service.mjs.map +1 -0
  248. package/dist/src/modules/email/email.service.d.mts +62 -0
  249. package/dist/src/modules/email/email.service.mjs +105 -0
  250. package/dist/src/modules/email/email.service.mjs.map +1 -0
  251. package/dist/src/modules/file/file.repository.d.mts +17 -0
  252. package/dist/src/modules/file/file.repository.mjs +72 -0
  253. package/dist/src/modules/file/file.repository.mjs.map +1 -0
  254. package/dist/src/modules/file/{file.router.d.ts → file.router.d.mts} +4 -0
  255. package/dist/src/modules/file/file.router.mjs +88 -0
  256. package/dist/src/modules/file/file.router.mjs.map +1 -0
  257. package/dist/src/modules/file/file.service.d.mts +30 -0
  258. package/dist/src/modules/file/file.service.mjs +117 -0
  259. package/dist/src/modules/file/file.service.mjs.map +1 -0
  260. package/dist/src/modules/recurrence/recurrence.db.d.mts +568 -0
  261. package/dist/src/modules/recurrence/recurrence.db.mjs +47 -0
  262. package/dist/src/modules/recurrence/recurrence.db.mjs.map +1 -0
  263. package/dist/src/modules/recurrence/recurrence.repository.d.mts +588 -0
  264. package/dist/src/modules/recurrence/recurrence.repository.mjs +28 -0
  265. package/dist/src/modules/recurrence/recurrence.repository.mjs.map +1 -0
  266. package/dist/src/modules/recurrence/recurrence.service.d.mts +51 -0
  267. package/dist/src/modules/recurrence/recurrence.service.mjs +64 -0
  268. package/dist/src/modules/recurrence/recurrence.service.mjs.map +1 -0
  269. package/dist/src/modules/recurrence/recurrence.trpc.d.mts +65 -0
  270. package/dist/src/modules/recurrence/recurrence.trpc.mjs +44 -0
  271. package/dist/src/modules/recurrence/recurrence.trpc.mjs.map +1 -0
  272. package/dist/src/modules/social/social.dto.d.mts +39 -0
  273. package/dist/src/modules/social/social.dto.mjs +22 -0
  274. package/dist/src/modules/social/social.dto.mjs.map +1 -0
  275. package/dist/src/modules/social/{social.linkedin.d.ts → social.linkedin.d.mts} +8 -3
  276. package/dist/src/modules/social/social.linkedin.mjs +346 -0
  277. package/dist/src/modules/social/social.linkedin.mjs.map +1 -0
  278. package/dist/src/modules/social/social.service.d.mts +34 -0
  279. package/dist/src/modules/social/social.service.mjs +55 -0
  280. package/dist/src/modules/social/social.service.mjs.map +1 -0
  281. package/dist/src/modules/social/social.types.d.mts +40 -0
  282. package/dist/src/modules/tag/tag.db.d.mts +352 -0
  283. package/dist/src/modules/tag/tag.db.mjs +35 -0
  284. package/dist/src/modules/tag/tag.db.mjs.map +1 -0
  285. package/dist/src/modules/tag/tag.dto.d.mts +1025 -0
  286. package/dist/src/modules/tag/tag.dto.mjs +11 -0
  287. package/dist/src/modules/tag/tag.dto.mjs.map +1 -0
  288. package/dist/src/modules/tag/tag.repository.d.mts +394 -0
  289. package/dist/src/modules/tag/tag.repository.mjs +114 -0
  290. package/dist/src/modules/tag/tag.repository.mjs.map +1 -0
  291. package/dist/src/modules/tag/tag.service.d.mts +93 -0
  292. package/dist/src/modules/tag/tag.service.mjs +47 -0
  293. package/dist/src/modules/tag/tag.service.mjs.map +1 -0
  294. package/dist/src/modules/tag/tag.trpc.d.mts +109 -0
  295. package/dist/src/modules/tag/tag.trpc.mjs +30 -0
  296. package/dist/src/modules/tag/tag.trpc.mjs.map +1 -0
  297. package/dist/src/modules/utils/{applyPagination.d.ts → applyPagination.d.mts} +5 -1
  298. package/dist/src/modules/utils/applyPagination.mjs +15 -0
  299. package/dist/src/modules/utils/applyPagination.mjs.map +1 -0
  300. package/dist/src/modules/utils/applySorting.d.mts +13 -0
  301. package/dist/src/modules/utils/applySorting.mjs +18 -0
  302. package/dist/src/modules/utils/applySorting.mjs.map +1 -0
  303. package/dist/src/modules/utils/getConditionsFromFilters.d.mts +9 -0
  304. package/dist/src/modules/utils/getConditionsFromFilters.mjs +150 -0
  305. package/dist/src/modules/utils/getConditionsFromFilters.mjs.map +1 -0
  306. package/dist/src/modules/video/video.service.d.mts +12 -0
  307. package/dist/src/modules/video/video.service.mjs +50 -0
  308. package/dist/src/modules/video/video.service.mjs.map +1 -0
  309. package/dist/src/modules/webhook/webhook.constants.d.mts +12 -0
  310. package/dist/src/modules/webhook/webhook.constants.mjs +12 -0
  311. package/dist/src/modules/webhook/webhook.constants.mjs.map +1 -0
  312. package/dist/src/modules/webhook/webhook.db.d.mts +142 -0
  313. package/dist/src/modules/webhook/webhook.db.mjs +17 -0
  314. package/dist/src/modules/webhook/webhook.db.mjs.map +1 -0
  315. package/dist/src/modules/webhook/webhook.dto.d.mts +402 -0
  316. package/dist/src/modules/webhook/webhook.dto.mjs +9 -0
  317. package/dist/src/modules/webhook/webhook.dto.mjs.map +1 -0
  318. package/dist/src/modules/webhook/webhook.repository.d.mts +154 -0
  319. package/dist/src/modules/webhook/webhook.repository.mjs +50 -0
  320. package/dist/src/modules/webhook/webhook.repository.mjs.map +1 -0
  321. package/dist/src/modules/webhook/webhook.router.d.mts +8 -0
  322. package/dist/src/modules/webhook/webhook.router.mjs +23 -0
  323. package/dist/src/modules/webhook/webhook.router.mjs.map +1 -0
  324. package/dist/src/modules/webhook/webhook.service.d.mts +14 -0
  325. package/dist/src/modules/webhook/webhook.service.mjs +59 -0
  326. package/dist/src/modules/webhook/webhook.service.mjs.map +1 -0
  327. package/dist/src/modules/workflow/workflow.db.d.mts +302 -0
  328. package/dist/src/modules/workflow/workflow.db.mjs +28 -0
  329. package/dist/src/modules/workflow/workflow.db.mjs.map +1 -0
  330. package/dist/src/modules/workflow/workflow.repository.d.mts +371 -0
  331. package/dist/src/modules/workflow/workflow.repository.mjs +93 -0
  332. package/dist/src/modules/workflow/workflow.repository.mjs.map +1 -0
  333. package/dist/src/modules/workflow/workflow.service.d.mts +31 -0
  334. package/dist/src/modules/workflow/workflow.service.mjs +40 -0
  335. package/dist/src/modules/workflow/workflow.service.mjs.map +1 -0
  336. package/dist/src/modules/workflow/workflow.trpc.d.mts +28 -0
  337. package/dist/src/modules/workflow/workflow.trpc.mjs +17 -0
  338. package/dist/src/modules/workflow/workflow.trpc.mjs.map +1 -0
  339. package/dist/src/modules/workflow/workflow.types.d.mts +25 -0
  340. package/dist/src/modules/workflow/workflow.utils.d.mts +36 -0
  341. package/dist/src/modules/workflow/workflow.utils.mjs +181 -0
  342. package/dist/src/modules/workflow/workflow.utils.mjs.map +1 -0
  343. package/dist/src/types.d.mts +346 -0
  344. package/dist/src/types.mjs +13 -0
  345. package/dist/src/types.mjs.map +1 -0
  346. package/dist/src/utils/errors.d.mts +62 -0
  347. package/dist/src/utils/errors.mjs +96 -0
  348. package/dist/src/utils/errors.mjs.map +1 -0
  349. package/dist/src/utils/logger.d.mts +7 -0
  350. package/dist/src/utils/logger.mjs +10 -0
  351. package/dist/src/utils/logger.mjs.map +1 -0
  352. package/dist/src/utils/posthog.d.mts +17 -0
  353. package/dist/src/utils/posthog.mjs +25 -0
  354. package/dist/src/utils/posthog.mjs.map +1 -0
  355. package/dist/src/utils/trpc.d.mts +54 -0
  356. package/dist/src/utils/trpc.mjs +146 -0
  357. package/dist/src/utils/trpc.mjs.map +1 -0
  358. package/dist/src/utils/types.d.mts +9 -0
  359. package/package.json +5 -4
  360. package/dist/src/lib/posthog.d.ts +0 -2
  361. package/dist/src/lib/posthog.js +0 -7
  362. package/dist/src/lib/sentry.js +0 -9
  363. package/dist/src/modules/access/access.repository.d.ts +0 -2347
  364. package/dist/src/modules/access/access.repository.js +0 -32
  365. package/dist/src/modules/access/access.service.d.ts +0 -21
  366. package/dist/src/modules/access/access.service.js +0 -51
  367. package/dist/src/modules/access/access.test.js +0 -182
  368. package/dist/src/modules/access/access.utils.d.ts +0 -16
  369. package/dist/src/modules/access/access.utils.js +0 -20
  370. package/dist/src/modules/ai/ai.db.d.ts +0 -395
  371. package/dist/src/modules/ai/ai.db.js +0 -39
  372. package/dist/src/modules/ai/ai.prompt.d.ts +0 -26
  373. package/dist/src/modules/ai/ai.prompt.js +0 -30
  374. package/dist/src/modules/ai/ai.prompts.d.ts +0 -5
  375. package/dist/src/modules/ai/ai.repository.d.ts +0 -423
  376. package/dist/src/modules/ai/ai.repository.js +0 -26
  377. package/dist/src/modules/ai/ai.router.js +0 -132
  378. package/dist/src/modules/ai/ai.service.d.ts +0 -127
  379. package/dist/src/modules/ai/ai.service.js +0 -297
  380. package/dist/src/modules/ai/ai.trpc.d.ts +0 -22
  381. package/dist/src/modules/ai/ai.trpc.js +0 -20
  382. package/dist/src/modules/ai/ideogram/ideogram.constants.d.ts +0 -7
  383. package/dist/src/modules/ai/ideogram/ideogram.constants.js +0 -167
  384. package/dist/src/modules/ai/ideogram/ideogram.dto.d.ts +0 -229
  385. package/dist/src/modules/ai/ideogram/ideogram.dto.js +0 -49
  386. package/dist/src/modules/ai/ideogram/ideogram.prompt.d.ts +0 -2
  387. package/dist/src/modules/ai/ideogram/ideogram.repository.d.ts +0 -6
  388. package/dist/src/modules/ai/ideogram/ideogram.repository.js +0 -46
  389. package/dist/src/modules/ai/ideogram/ideogram.service.d.ts +0 -9
  390. package/dist/src/modules/ai/ideogram/ideogram.service.js +0 -11
  391. package/dist/src/modules/auth/auth.db.d.ts +0 -2335
  392. package/dist/src/modules/auth/auth.db.js +0 -215
  393. package/dist/src/modules/auth/auth.dto.d.ts +0 -65
  394. package/dist/src/modules/auth/auth.dto.js +0 -38
  395. package/dist/src/modules/auth/auth.lib.d.ts +0 -4873
  396. package/dist/src/modules/auth/auth.lib.js +0 -284
  397. package/dist/src/modules/auth/auth.middleware.d.ts +0 -614
  398. package/dist/src/modules/auth/auth.middleware.js +0 -52
  399. package/dist/src/modules/auth/auth.repository.d.ts +0 -2421
  400. package/dist/src/modules/auth/auth.repository.js +0 -636
  401. package/dist/src/modules/auth/auth.service.d.ts +0 -108
  402. package/dist/src/modules/auth/auth.service.js +0 -246
  403. package/dist/src/modules/auth/auth.trpc.d.ts +0 -292
  404. package/dist/src/modules/auth/auth.trpc.js +0 -179
  405. package/dist/src/modules/auth/auth.utils.d.ts +0 -2351
  406. package/dist/src/modules/auth/auth.utils.js +0 -97
  407. package/dist/src/modules/base/base.abstract.d.ts +0 -19
  408. package/dist/src/modules/base/base.abstract.js +0 -62
  409. package/dist/src/modules/base/base.dto.d.ts +0 -69
  410. package/dist/src/modules/base/base.dto.js +0 -112
  411. package/dist/src/modules/base/base.grants.d.ts +0 -28
  412. package/dist/src/modules/base/base.grants.js +0 -123
  413. package/dist/src/modules/base/base.grants.test.js +0 -668
  414. package/dist/src/modules/base/base.procedure.d.ts +0 -112
  415. package/dist/src/modules/base/base.procedure.js +0 -289
  416. package/dist/src/modules/base/base.repository.d.ts +0 -97
  417. package/dist/src/modules/base/base.repository.js +0 -317
  418. package/dist/src/modules/base/base.service.d.ts +0 -52
  419. package/dist/src/modules/base/base.service.js +0 -116
  420. package/dist/src/modules/base/base.service.test.js +0 -415
  421. package/dist/src/modules/base/base.types.d.ts +0 -1
  422. package/dist/src/modules/base/base.types.js +0 -2
  423. package/dist/src/modules/billing/billing.db.d.ts +0 -365
  424. package/dist/src/modules/billing/billing.db.js +0 -29
  425. package/dist/src/modules/billing/billing.repository.d.ts +0 -2763
  426. package/dist/src/modules/billing/billing.repository.js +0 -235
  427. package/dist/src/modules/billing/billing.router.d.ts +0 -4
  428. package/dist/src/modules/billing/billing.router.js +0 -56
  429. package/dist/src/modules/billing/billing.service.d.ts +0 -59
  430. package/dist/src/modules/billing/billing.service.js +0 -147
  431. package/dist/src/modules/billing/billing.trpc.d.ts +0 -38
  432. package/dist/src/modules/billing/billing.trpc.js +0 -17
  433. package/dist/src/modules/clay/clay.repository.d.ts +0 -5
  434. package/dist/src/modules/clay/clay.repository.js +0 -26
  435. package/dist/src/modules/clay/clay.service.d.ts +0 -28
  436. package/dist/src/modules/clay/clay.service.js +0 -24
  437. package/dist/src/modules/connect/connect.db.d.ts +0 -356
  438. package/dist/src/modules/connect/connect.db.js +0 -30
  439. package/dist/src/modules/connect/connect.dto.d.ts +0 -74
  440. package/dist/src/modules/connect/connect.dto.js +0 -36
  441. package/dist/src/modules/connect/connect.linkedin.d.ts +0 -2
  442. package/dist/src/modules/connect/connect.linkedin.js +0 -53
  443. package/dist/src/modules/connect/connect.oauth.d.ts +0 -27
  444. package/dist/src/modules/connect/connect.oauth.js +0 -198
  445. package/dist/src/modules/connect/connect.repository.d.ts +0 -413
  446. package/dist/src/modules/connect/connect.repository.js +0 -54
  447. package/dist/src/modules/connect/connect.router.d.ts +0 -4
  448. package/dist/src/modules/connect/connect.router.js +0 -54
  449. package/dist/src/modules/connect/connect.service.d.ts +0 -88
  450. package/dist/src/modules/connect/connect.service.js +0 -114
  451. package/dist/src/modules/connect/connect.trpc.d.ts +0 -44
  452. package/dist/src/modules/connect/connect.trpc.js +0 -21
  453. package/dist/src/modules/connect/connect.types.d.ts +0 -25
  454. package/dist/src/modules/connect/connect.types.js +0 -2
  455. package/dist/src/modules/crypto/crypto.db.d.ts +0 -151
  456. package/dist/src/modules/crypto/crypto.db.js +0 -17
  457. package/dist/src/modules/crypto/crypto.repository.d.ts +0 -159
  458. package/dist/src/modules/crypto/crypto.repository.js +0 -10
  459. package/dist/src/modules/crypto/crypto.service.d.ts +0 -10
  460. package/dist/src/modules/crypto/crypto.service.js +0 -52
  461. package/dist/src/modules/email/email.service.d.ts +0 -56
  462. package/dist/src/modules/email/email.service.js +0 -106
  463. package/dist/src/modules/file/file.repository.d.ts +0 -12
  464. package/dist/src/modules/file/file.repository.js +0 -79
  465. package/dist/src/modules/file/file.router.js +0 -99
  466. package/dist/src/modules/file/file.service.d.ts +0 -24
  467. package/dist/src/modules/file/file.service.js +0 -150
  468. package/dist/src/modules/recurrence/recurrence.db.d.ts +0 -562
  469. package/dist/src/modules/recurrence/recurrence.db.js +0 -66
  470. package/dist/src/modules/recurrence/recurrence.repository.d.ts +0 -584
  471. package/dist/src/modules/recurrence/recurrence.repository.js +0 -39
  472. package/dist/src/modules/recurrence/recurrence.service.d.ts +0 -50
  473. package/dist/src/modules/recurrence/recurrence.service.js +0 -69
  474. package/dist/src/modules/recurrence/recurrence.trpc.d.ts +0 -206
  475. package/dist/src/modules/recurrence/recurrence.trpc.js +0 -65
  476. package/dist/src/modules/social/social.dto.d.ts +0 -34
  477. package/dist/src/modules/social/social.dto.js +0 -18
  478. package/dist/src/modules/social/social.linkedin.js +0 -427
  479. package/dist/src/modules/social/social.linkedin.test.js +0 -235
  480. package/dist/src/modules/social/social.service.d.ts +0 -28
  481. package/dist/src/modules/social/social.service.js +0 -76
  482. package/dist/src/modules/social/social.types.d.ts +0 -35
  483. package/dist/src/modules/social/social.types.js +0 -2
  484. package/dist/src/modules/tag/tag.db.d.ts +0 -346
  485. package/dist/src/modules/tag/tag.db.js +0 -42
  486. package/dist/src/modules/tag/tag.dto.d.ts +0 -1018
  487. package/dist/src/modules/tag/tag.dto.js +0 -9
  488. package/dist/src/modules/tag/tag.repository.d.ts +0 -383
  489. package/dist/src/modules/tag/tag.repository.js +0 -156
  490. package/dist/src/modules/tag/tag.service.d.ts +0 -109
  491. package/dist/src/modules/tag/tag.service.js +0 -42
  492. package/dist/src/modules/tag/tag.trpc.d.ts +0 -164
  493. package/dist/src/modules/tag/tag.trpc.js +0 -53
  494. package/dist/src/modules/utils/applyPagination.js +0 -16
  495. package/dist/src/modules/utils/applySorting.d.ts +0 -8
  496. package/dist/src/modules/utils/applySorting.js +0 -18
  497. package/dist/src/modules/utils/getConditionsFromFilters.d.ts +0 -4
  498. package/dist/src/modules/utils/getConditionsFromFilters.js +0 -200
  499. package/dist/src/modules/video/video.service.d.ts +0 -7
  500. package/dist/src/modules/video/video.service.js +0 -84
  501. package/dist/src/modules/webhook/webhook.constants.d.ts +0 -8
  502. package/dist/src/modules/webhook/webhook.constants.js +0 -10
  503. package/dist/src/modules/webhook/webhook.db.d.ts +0 -136
  504. package/dist/src/modules/webhook/webhook.db.js +0 -17
  505. package/dist/src/modules/webhook/webhook.dto.d.ts +0 -394
  506. package/dist/src/modules/webhook/webhook.dto.js +0 -7
  507. package/dist/src/modules/webhook/webhook.repository.d.ts +0 -148
  508. package/dist/src/modules/webhook/webhook.repository.js +0 -56
  509. package/dist/src/modules/webhook/webhook.router.d.ts +0 -3
  510. package/dist/src/modules/webhook/webhook.router.js +0 -30
  511. package/dist/src/modules/webhook/webhook.service.d.ts +0 -9
  512. package/dist/src/modules/webhook/webhook.service.js +0 -68
  513. package/dist/src/modules/workflow/workflow.db.d.ts +0 -296
  514. package/dist/src/modules/workflow/workflow.db.js +0 -30
  515. package/dist/src/modules/workflow/workflow.repository.d.ts +0 -343
  516. package/dist/src/modules/workflow/workflow.repository.js +0 -105
  517. package/dist/src/modules/workflow/workflow.service.d.ts +0 -21
  518. package/dist/src/modules/workflow/workflow.service.js +0 -37
  519. package/dist/src/modules/workflow/workflow.trpc.d.ts +0 -56
  520. package/dist/src/modules/workflow/workflow.trpc.js +0 -21
  521. package/dist/src/modules/workflow/workflow.types.d.ts +0 -20
  522. package/dist/src/modules/workflow/workflow.types.js +0 -2
  523. package/dist/src/modules/workflow/workflow.utils.d.ts +0 -21
  524. package/dist/src/modules/workflow/workflow.utils.js +0 -173
  525. package/dist/src/test/stubs/utils.d.ts +0 -2
  526. package/dist/src/test/stubs/utils.js +0 -5
  527. package/dist/src/trpc/context.d.ts +0 -41
  528. package/dist/src/trpc/context.js +0 -17
  529. package/dist/src/trpc/index.d.ts +0 -3
  530. package/dist/src/trpc/index.js +0 -6
  531. package/dist/src/trpc/procedures.d.ts +0 -233
  532. package/dist/src/trpc/procedures.js +0 -32
  533. package/dist/src/trpc/utils.d.ts +0 -4
  534. package/dist/src/trpc/utils.js +0 -20
  535. package/dist/src/types.d.ts +0 -358
  536. package/dist/src/types.js +0 -12
  537. package/dist/src/utils/errors.d.ts +0 -49
  538. package/dist/src/utils/errors.js +0 -104
  539. package/dist/src/utils/logger.d.ts +0 -1
  540. package/dist/src/utils/logger.js +0 -11
  541. package/dist/src/utils/posthog.d.ts +0 -13
  542. package/dist/src/utils/posthog.js +0 -31
  543. package/dist/src/utils/trpc.d.ts +0 -58
  544. package/dist/src/utils/trpc.js +0 -63
  545. package/dist/src/utils/types.d.ts +0 -4
  546. package/dist/src/utils/types.js +0 -2
  547. package/dist/tsconfig.tsbuildinfo +0 -1
  548. /package/dist/src/{lib/sentry.d.ts → modules/ai/ai.router.mjs} +0 -0
  549. /package/dist/src/modules/{access/access.test.d.ts → base/base.types.mjs} +0 -0
  550. /package/dist/src/modules/{ai/ai.router.d.ts → connect/connect.types.mjs} +0 -0
  551. /package/dist/src/modules/{base/base.grants.test.d.ts → social/social.types.mjs} +0 -0
  552. /package/dist/src/modules/{base/base.service.test.d.ts → workflow/workflow.types.mjs} +0 -0
  553. /package/dist/src/{modules/social/social.linkedin.test.d.ts → utils/types.mjs} +0 -0
@@ -0,0 +1,123 @@
1
+ import { ServerResultAsync, pickColumns } from "./base.dto.mjs";
2
+ import { Base } from "./base.abstract.mjs";
3
+ import { InferInsertModel, InferSelectModel, SQL, SelectedFields } from "drizzle-orm";
4
+ import { SQLiteColumn, SQLiteTableWithColumns } from "drizzle-orm/sqlite-core";
5
+ import { QueryFilters, QueryInput } from "@m5kdev/commons/modules/schemas/query.schema";
6
+ import { LibSQLDatabase } from "drizzle-orm/libsql";
7
+
8
+ //#region src/modules/base/base.repository.d.ts
9
+ /** Payload for update/updateMany: id key required (string), other table fields optional. */
10
+ type TableUpdatePayload<TTable extends SQLiteTableWithColumns<any>, TIdKey extends Extract<keyof InferSelectModel<TTable>, string> = "id"> = Record<TIdKey, string> & Partial<Omit<InferSelectModel<TTable>, TIdKey>>;
11
+ declare class ConditionBuilder {
12
+ private conditions;
13
+ constructor(conditions?: SQL[]);
14
+ push(condition?: SQL): void;
15
+ join(type?: "and" | "or"): SQL<unknown> | undefined;
16
+ [Symbol.iterator](): ArrayIterator<SQL<unknown>>;
17
+ }
18
+ declare class TableConditionBuilder<TTable extends SQLiteTableWithColumns<any>> extends ConditionBuilder {
19
+ private table;
20
+ constructor(table: TTable);
21
+ applyFilters({
22
+ filters
23
+ }?: {
24
+ filters?: QueryFilters;
25
+ }): void;
26
+ }
27
+ declare const arrayContains: (table: SQLiteColumn, values: string[]) => SQL<unknown> | undefined;
28
+ declare class BaseRepository<O extends LibSQLDatabase<any>, S extends Record<string, SQLiteTableWithColumns<any>>, R extends Record<string, BaseRepository<any, any, any> | BaseExternaRepository>> extends Base {
29
+ protected orm: O;
30
+ protected schema: S;
31
+ repository?: R;
32
+ constructor(options: {
33
+ orm: O;
34
+ schema: S;
35
+ }, repository?: R);
36
+ getConditionBuilder(): ConditionBuilder;
37
+ getConditionBuilder(table: undefined): ConditionBuilder;
38
+ getConditionBuilder<TTable extends SQLiteTableWithColumns<any>>(table: TTable): TableConditionBuilder<TTable>;
39
+ throwableQuery<T>(fn: () => Promise<T>): ServerResultAsync<T>;
40
+ withPagination<TQuery>(query: TQuery, {
41
+ page,
42
+ limit
43
+ }: Pick<QueryInput, "page" | "limit">): TQuery;
44
+ withSorting<TTable extends SQLiteTableWithColumns<any>, TQuery>(query: TQuery, {
45
+ sort,
46
+ order
47
+ }: Pick<QueryInput, "sort" | "order">, table?: TTable): TQuery;
48
+ withSortingAndPagination<TTable extends SQLiteTableWithColumns<any>, TQuery>(query: TQuery, {
49
+ sort,
50
+ order,
51
+ page,
52
+ limit
53
+ }: Pick<QueryInput, "sort" | "order" | "page" | "limit">, table?: TTable): TQuery;
54
+ addUserIdFilter(userId: string, query?: QueryInput): QueryInput;
55
+ helpers: {
56
+ pickColumns: typeof pickColumns;
57
+ arrayContains: (table: SQLiteColumn, values: string[]) => SQL<unknown> | undefined;
58
+ ConditionBuilder: typeof ConditionBuilder;
59
+ };
60
+ }
61
+ /**
62
+ * Generic table-bound repository with typed CRUD, returning ServerResultAsync via throwableAsync.
63
+ *
64
+ * Example:
65
+ * const userRepo = new UserRepository(db, schema);
66
+ * class UserRepository extends BaseTableRepository<typeof schema.user> {
67
+ * constructor(db: LibSQLDatabase<typeof schema>, schema: typeof schema) {
68
+ * super(db, schema, schema.user);
69
+ * }
70
+ * }
71
+ */
72
+ declare class BaseTableRepository<O extends LibSQLDatabase<any>, S extends Record<string, SQLiteTableWithColumns<any>>, R extends Record<string, BaseRepository<any, any, any> | BaseExternaRepository>, TTable extends SQLiteTableWithColumns<any>, TIdKey extends Extract<keyof InferSelectModel<TTable>, string> = "id"> extends BaseRepository<O, S, R> {
73
+ protected readonly table: TTable;
74
+ protected readonly idKey: TIdKey;
75
+ protected readonly idColumn: SQLiteColumn;
76
+ constructor(options: {
77
+ orm: O;
78
+ schema: S;
79
+ table: TTable;
80
+ idKey?: TIdKey;
81
+ }, repository?: R);
82
+ withSorting<TQuery>(query: TQuery, {
83
+ sort,
84
+ order
85
+ }: Pick<QueryInput, "sort" | "order">, table?: SQLiteTableWithColumns<any>): TQuery;
86
+ withSortingAndPagination<MTable extends SQLiteTableWithColumns<any>, TQuery>(query: TQuery, {
87
+ sort,
88
+ order,
89
+ page,
90
+ limit
91
+ }: Pick<QueryInput, "sort" | "order" | "page" | "limit">, table?: MTable): TQuery;
92
+ queryList(query?: QueryInput, options?: {
93
+ conditions?: TableConditionBuilder<TTable>;
94
+ select?: SelectedFields<SQLiteColumn, TTable>;
95
+ }, tx?: O): ServerResultAsync<{
96
+ rows: InferSelectModel<TTable>[];
97
+ total: number;
98
+ }>;
99
+ findById(id: string, tx?: O): ServerResultAsync<InferSelectModel<TTable> | undefined>;
100
+ findManyById(ids: readonly string[], tx?: O): ServerResultAsync<Array<InferSelectModel<TTable>>>;
101
+ create(data: InferInsertModel<TTable>, tx?: O): ServerResultAsync<InferSelectModel<TTable>>;
102
+ createMany(data: readonly InferInsertModel<TTable>[], tx?: O): ServerResultAsync<Array<InferSelectModel<TTable>>>;
103
+ update(data: TableUpdatePayload<TTable, TIdKey>, tx?: O): ServerResultAsync<InferSelectModel<TTable>>;
104
+ updateMany(data: readonly TableUpdatePayload<TTable, TIdKey>[], tx?: O): ServerResultAsync<Array<InferSelectModel<TTable>>>;
105
+ softDeleteById(id: string, tx?: O): ServerResultAsync<{
106
+ id: string;
107
+ }>;
108
+ softDeleteManyById(ids: readonly string[], tx?: O): ServerResultAsync<Array<{
109
+ id: string;
110
+ }>>;
111
+ deleteById(id: string, tx?: O): ServerResultAsync<{
112
+ id: string;
113
+ }>;
114
+ deleteManyById(ids: readonly string[], tx?: O): ServerResultAsync<Array<{
115
+ id: string;
116
+ }>>;
117
+ }
118
+ declare class BaseExternaRepository extends Base {
119
+ constructor();
120
+ }
121
+ //#endregion
122
+ export { BaseExternaRepository, BaseRepository, BaseTableRepository, ConditionBuilder, TableConditionBuilder, TableUpdatePayload, arrayContains };
123
+ //# sourceMappingURL=base.repository.d.mts.map
@@ -0,0 +1,250 @@
1
+ import { ServerError } from "../../utils/errors.mjs";
2
+ import { applyPagination } from "../utils/applyPagination.mjs";
3
+ import { applySorting } from "../utils/applySorting.mjs";
4
+ import { getConditionsFromFilters } from "../utils/getConditionsFromFilters.mjs";
5
+ import { Base } from "./base.abstract.mjs";
6
+ import { pickColumns } from "./base.dto.mjs";
7
+ import { and, count, eq, inArray, like, or } from "drizzle-orm";
8
+ import { ok } from "neverthrow";
9
+ //#region src/modules/base/base.repository.ts
10
+ var ConditionBuilder = class {
11
+ constructor(conditions = []) {
12
+ this.conditions = conditions;
13
+ this.conditions = conditions;
14
+ }
15
+ push(condition) {
16
+ if (condition) this.conditions.push(condition);
17
+ }
18
+ join(type = "and") {
19
+ if (this.conditions.length === 0) return void 0;
20
+ if (this.conditions.length === 1) return this.conditions[0];
21
+ return type === "and" ? and(...this.conditions) : or(...this.conditions);
22
+ }
23
+ [Symbol.iterator]() {
24
+ return this.conditions[Symbol.iterator]();
25
+ }
26
+ };
27
+ var TableConditionBuilder = class extends ConditionBuilder {
28
+ table;
29
+ constructor(table) {
30
+ super();
31
+ this.table = table;
32
+ }
33
+ applyFilters({ filters } = {}) {
34
+ if (filters && filters.length > 0) getConditionsFromFilters(this, filters, this.table);
35
+ }
36
+ };
37
+ const arrayContains = (table, values) => {
38
+ const arrayContains = [];
39
+ for (const value of values) arrayContains.push(like(table, `%"${value}%"`));
40
+ return or(...arrayContains);
41
+ };
42
+ var BaseRepository = class extends Base {
43
+ orm;
44
+ schema;
45
+ repository;
46
+ constructor(options, repository) {
47
+ super("repository");
48
+ this.orm = options.orm;
49
+ this.schema = options.schema;
50
+ this.repository = repository;
51
+ }
52
+ getConditionBuilder(table) {
53
+ if (table === void 0) return new ConditionBuilder();
54
+ return new TableConditionBuilder(table);
55
+ }
56
+ throwableQuery(fn) {
57
+ return this.throwablePromise(() => fn(), (error) => new ServerError({
58
+ code: "INTERNAL_SERVER_ERROR",
59
+ layer: "repository",
60
+ layerName: this.constructor.name,
61
+ message: "Database query failed",
62
+ cause: error
63
+ }));
64
+ }
65
+ withPagination(query, { page, limit }) {
66
+ return applyPagination(query, limit, page);
67
+ }
68
+ withSorting(query, { sort, order }, table) {
69
+ if (!table) throw new Error("No table provided");
70
+ return applySorting(query, table, sort, order);
71
+ }
72
+ withSortingAndPagination(query, { sort, order, page, limit }, table) {
73
+ if (!table) throw new Error("No table provided");
74
+ return this.withSorting(this.withPagination(query, {
75
+ page,
76
+ limit
77
+ }), {
78
+ sort,
79
+ order
80
+ }, table);
81
+ }
82
+ addUserIdFilter(userId, query) {
83
+ const userIdFilter = {
84
+ columnId: "userId",
85
+ type: "string",
86
+ method: "equals",
87
+ value: userId
88
+ };
89
+ return query ? {
90
+ ...query,
91
+ filters: [...query?.filters ?? [], userIdFilter]
92
+ } : { filters: [userIdFilter] };
93
+ }
94
+ helpers = {
95
+ pickColumns,
96
+ arrayContains,
97
+ ConditionBuilder
98
+ };
99
+ };
100
+ /**
101
+ * Generic table-bound repository with typed CRUD, returning ServerResultAsync via throwableAsync.
102
+ *
103
+ * Example:
104
+ * const userRepo = new UserRepository(db, schema);
105
+ * class UserRepository extends BaseTableRepository<typeof schema.user> {
106
+ * constructor(db: LibSQLDatabase<typeof schema>, schema: typeof schema) {
107
+ * super(db, schema, schema.user);
108
+ * }
109
+ * }
110
+ */
111
+ var BaseTableRepository = class extends BaseRepository {
112
+ table;
113
+ idKey;
114
+ idColumn;
115
+ constructor(options, repository) {
116
+ super({
117
+ orm: options.orm,
118
+ schema: options.schema
119
+ }, repository);
120
+ this.table = options.table;
121
+ this.idKey = options.idKey ?? "id";
122
+ this.idColumn = this.table[this.idKey];
123
+ }
124
+ withSorting(query, { sort, order }, table) {
125
+ return super.withSorting(query, {
126
+ sort,
127
+ order
128
+ }, table || this.table);
129
+ }
130
+ withSortingAndPagination(query, { sort, order, page, limit }, table) {
131
+ return super.withSortingAndPagination(query, {
132
+ sort,
133
+ order,
134
+ page,
135
+ limit
136
+ }, table || this.table);
137
+ }
138
+ async queryList(query, options, tx) {
139
+ return this.throwableAsync(async () => {
140
+ const db = tx ?? this.orm;
141
+ const conditions = options?.conditions ?? this.getConditionBuilder(this.table);
142
+ conditions.applyFilters(query);
143
+ const whereClause = conditions.join();
144
+ const rowsQuery = this.withSortingAndPagination((options?.select ? db.select(options.select) : db.select()).from(this.table).where(whereClause), query || {});
145
+ const countQuery = db.select({ count: count() }).from(this.table).where(whereClause);
146
+ const [rows, [totalResult]] = await Promise.all([rowsQuery, countQuery]);
147
+ return ok({
148
+ rows,
149
+ total: totalResult?.count ?? 0
150
+ });
151
+ });
152
+ }
153
+ async findById(id, tx) {
154
+ return this.throwableAsync(async () => {
155
+ return ok((await (tx ?? this.orm).select().from(this.table).where(eq(this.idColumn, id)))[0]);
156
+ });
157
+ }
158
+ async findManyById(ids, tx) {
159
+ return this.throwableAsync(async () => {
160
+ const db = tx ?? this.orm;
161
+ if (ids.length === 0) return ok([]);
162
+ return ok(await db.select().from(this.table).where(inArray(this.idColumn, ids)));
163
+ });
164
+ }
165
+ async create(data, tx) {
166
+ return this.throwableAsync(async () => {
167
+ const rows = await (tx ?? this.orm).insert(this.table).values(data).returning();
168
+ if (rows.length === 0) return this.error("UNPROCESSABLE_CONTENT");
169
+ return ok(rows[0]);
170
+ });
171
+ }
172
+ async createMany(data, tx) {
173
+ return this.throwableAsync(async () => {
174
+ const db = tx ?? this.orm;
175
+ if (data.length === 0) return ok([]);
176
+ return ok(await db.insert(this.table).values(data).returning());
177
+ });
178
+ }
179
+ async update(data, tx) {
180
+ return this.throwableAsync(async () => {
181
+ const db = tx ?? this.orm;
182
+ const single = data;
183
+ const id = String(single[this.idKey]);
184
+ const { [this.idKey]: _removed, ...rest } = single;
185
+ const update = rest;
186
+ if (this.table.updatedAt) update.updatedAt = /* @__PURE__ */ new Date();
187
+ const [row] = await db.update(this.table).set(update).where(eq(this.idColumn, id)).returning();
188
+ if (!row) return this.error("NOT_FOUND");
189
+ return ok(row);
190
+ });
191
+ }
192
+ async updateMany(data, tx) {
193
+ return this.throwableAsync(async () => {
194
+ const db = tx ?? this.orm;
195
+ if (data.length === 0) return ok([]);
196
+ const results = [];
197
+ for (const item of data) {
198
+ const record = item;
199
+ const id = String(record[this.idKey]);
200
+ const { [this.idKey]: _removed, ...rest } = record;
201
+ const update = rest;
202
+ if (this.table.updatedAt) update.updatedAt = /* @__PURE__ */ new Date();
203
+ const rows = await db.update(this.table).set(update).where(eq(this.idColumn, id)).returning();
204
+ if (rows[0]) results.push(rows[0]);
205
+ }
206
+ return ok(results);
207
+ });
208
+ }
209
+ async softDeleteById(id, tx) {
210
+ return this.throwableAsync(async () => {
211
+ const db = tx ?? this.orm;
212
+ if (!this.table.deletedAt) return this.error("METHOD_NOT_SUPPORTED");
213
+ const rows = await db.update(this.table).set({ deletedAt: /* @__PURE__ */ new Date() }).where(eq(this.idColumn, id)).returning({ id: this.idColumn });
214
+ if (rows.length === 0) return this.error("NOT_FOUND");
215
+ return ok(rows[0]);
216
+ });
217
+ }
218
+ async softDeleteManyById(ids, tx) {
219
+ return this.throwableAsync(async () => {
220
+ const db = tx ?? this.orm;
221
+ if (!this.table.deletedAt) return this.error("METHOD_NOT_SUPPORTED");
222
+ const rows = await db.update(this.table).set({ deletedAt: /* @__PURE__ */ new Date() }).where(inArray(this.idColumn, ids)).returning({ id: this.idColumn });
223
+ if (rows.length === 0) return this.error("NOT_FOUND");
224
+ return ok(rows);
225
+ });
226
+ }
227
+ async deleteById(id, tx) {
228
+ return this.throwableAsync(async () => {
229
+ const rows = await (tx ?? this.orm).delete(this.table).where(eq(this.idColumn, id)).returning({ id: this.idColumn });
230
+ if (rows.length === 0) return this.error("NOT_FOUND");
231
+ return ok(rows[0]);
232
+ });
233
+ }
234
+ async deleteManyById(ids, tx) {
235
+ return this.throwableAsync(async () => {
236
+ const db = tx ?? this.orm;
237
+ if (ids.length === 0) return ok([]);
238
+ return ok(await db.delete(this.table).where(inArray(this.idColumn, ids)).returning({ id: this.idColumn }));
239
+ });
240
+ }
241
+ };
242
+ var BaseExternaRepository = class extends Base {
243
+ constructor() {
244
+ super("repository");
245
+ }
246
+ };
247
+ //#endregion
248
+ export { BaseExternaRepository, BaseRepository, BaseTableRepository, ConditionBuilder, TableConditionBuilder, arrayContains };
249
+
250
+ //# sourceMappingURL=base.repository.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.repository.mjs","names":[],"sources":["../../../../src/modules/base/base.repository.ts"],"sourcesContent":["import type {\r\n QueryFilter,\r\n QueryFilters,\r\n QueryInput,\r\n} from \"@m5kdev/commons/modules/schemas/query.schema\";\r\nimport {\r\n and,\r\n count,\r\n eq,\r\n type InferInsertModel,\r\n type InferSelectModel,\r\n inArray,\r\n like,\r\n or,\r\n type SelectedFields,\r\n type SQL,\r\n} from \"drizzle-orm\";\r\nimport type { LibSQLDatabase } from \"drizzle-orm/libsql\";\r\nimport type { SQLiteColumn, SQLiteTableWithColumns } from \"drizzle-orm/sqlite-core\";\r\nimport { ok } from \"neverthrow\";\r\nimport { ServerError } from \"../../utils/errors\";\r\nimport { applyPagination } from \"../utils/applyPagination\";\r\nimport { applySorting } from \"../utils/applySorting\";\r\nimport { getConditionsFromFilters } from \"../utils/getConditionsFromFilters\";\r\nimport { Base } from \"./base.abstract\";\r\nimport { pickColumns, type ServerResult, type ServerResultAsync } from \"./base.dto\";\r\n\r\n/** Payload for update/updateMany: id key required (string), other table fields optional. */\r\nexport type TableUpdatePayload<\r\n TTable extends SQLiteTableWithColumns<any>,\r\n TIdKey extends Extract<keyof InferSelectModel<TTable>, string> = \"id\",\r\n> = Record<TIdKey, string> & Partial<Omit<InferSelectModel<TTable>, TIdKey>>;\r\n\r\nexport class ConditionBuilder {\r\n constructor(private conditions: SQL[] = []) {\r\n this.conditions = conditions;\r\n }\r\n\r\n push(condition?: SQL) {\r\n if (condition) this.conditions.push(condition);\r\n }\r\n\r\n join(type: \"and\" | \"or\" = \"and\") {\r\n if (this.conditions.length === 0) return undefined;\r\n if (this.conditions.length === 1) return this.conditions[0];\r\n return type === \"and\" ? and(...this.conditions) : or(...this.conditions);\r\n }\r\n\r\n [Symbol.iterator]() {\r\n return this.conditions[Symbol.iterator]();\r\n }\r\n}\r\n\r\nexport class TableConditionBuilder<\r\n TTable extends SQLiteTableWithColumns<any>,\r\n> extends ConditionBuilder {\r\n private table: TTable;\r\n\r\n constructor(table: TTable) {\r\n super();\r\n this.table = table;\r\n }\r\n\r\n applyFilters({ filters }: { filters?: QueryFilters } = {}) {\r\n if (filters && filters.length > 0) getConditionsFromFilters(this, filters, this.table);\r\n }\r\n}\r\n\r\nexport const arrayContains = (table: SQLiteColumn, values: string[]) => {\r\n const arrayContains: SQL[] = [];\r\n for (const value of values) {\r\n arrayContains.push(like(table, `%\"${value}%\"`));\r\n }\r\n return or(...arrayContains);\r\n};\r\n\r\nexport class BaseRepository<\r\n O extends LibSQLDatabase<any>,\r\n S extends Record<string, SQLiteTableWithColumns<any>>,\r\n R extends Record<string, BaseRepository<any, any, any> | BaseExternaRepository>,\r\n> extends Base {\r\n protected orm: O;\r\n protected schema: S;\r\n public repository?: R;\r\n\r\n constructor(options: { orm: O; schema: S }, repository?: R) {\r\n super(\"repository\");\r\n this.orm = options.orm;\r\n this.schema = options.schema;\r\n this.repository = repository;\r\n }\r\n getConditionBuilder(): ConditionBuilder;\r\n getConditionBuilder(table: undefined): ConditionBuilder;\r\n getConditionBuilder<TTable extends SQLiteTableWithColumns<any>>(\r\n table: TTable\r\n ): TableConditionBuilder<TTable>;\r\n getConditionBuilder<TTable extends SQLiteTableWithColumns<any>>(\r\n table?: TTable\r\n ): ConditionBuilder | TableConditionBuilder<TTable> {\r\n if (table === undefined) {\r\n return new ConditionBuilder();\r\n }\r\n return new TableConditionBuilder(table);\r\n }\r\n throwableQuery<T>(fn: () => Promise<T>): ServerResultAsync<T> {\r\n return this.throwablePromise(\r\n () => fn(),\r\n (error) =>\r\n new ServerError({\r\n code: \"INTERNAL_SERVER_ERROR\",\r\n layer: \"repository\",\r\n layerName: this.constructor.name,\r\n message: \"Database query failed\",\r\n cause: error,\r\n })\r\n );\r\n }\r\n\r\n withPagination<TQuery>(\r\n query: TQuery,\r\n { page, limit }: Pick<QueryInput, \"page\" | \"limit\">\r\n ): TQuery {\r\n return applyPagination(query, limit, page);\r\n }\r\n\r\n withSorting<TTable extends SQLiteTableWithColumns<any>, TQuery>(\r\n query: TQuery,\r\n { sort, order }: Pick<QueryInput, \"sort\" | \"order\">,\r\n table?: TTable\r\n ): TQuery {\r\n if (!table) throw new Error(\"No table provided\");\r\n return applySorting(query, table, sort, order);\r\n }\r\n\r\n withSortingAndPagination<TTable extends SQLiteTableWithColumns<any>, TQuery>(\r\n query: TQuery,\r\n { sort, order, page, limit }: Pick<QueryInput, \"sort\" | \"order\" | \"page\" | \"limit\">,\r\n table?: TTable\r\n ): TQuery {\r\n if (!table) throw new Error(\"No table provided\");\r\n return this.withSorting(this.withPagination(query, { page, limit }), { sort, order }, table);\r\n }\r\n\r\n addUserIdFilter(userId: string, query?: QueryInput): QueryInput {\r\n const userIdFilter: QueryFilter = {\r\n columnId: \"userId\",\r\n type: \"string\",\r\n method: \"equals\",\r\n value: userId,\r\n };\r\n return query\r\n ? { ...query, filters: [...(query?.filters ?? []), userIdFilter] }\r\n : { filters: [userIdFilter] };\r\n }\r\n\r\n helpers = {\r\n pickColumns,\r\n arrayContains,\r\n ConditionBuilder,\r\n };\r\n}\r\n\r\n/**\r\n * Generic table-bound repository with typed CRUD, returning ServerResultAsync via throwableAsync.\r\n *\r\n * Example:\r\n * const userRepo = new UserRepository(db, schema);\r\n * class UserRepository extends BaseTableRepository<typeof schema.user> {\r\n * constructor(db: LibSQLDatabase<typeof schema>, schema: typeof schema) {\r\n * super(db, schema, schema.user);\r\n * }\r\n * }\r\n */\r\nexport class BaseTableRepository<\r\n O extends LibSQLDatabase<any>,\r\n S extends Record<string, SQLiteTableWithColumns<any>>,\r\n R extends Record<string, BaseRepository<any, any, any> | BaseExternaRepository>,\r\n TTable extends SQLiteTableWithColumns<any>,\r\n TIdKey extends Extract<keyof InferSelectModel<TTable>, string> = \"id\",\r\n> extends BaseRepository<O, S, R> {\r\n protected readonly table: TTable;\r\n protected readonly idKey: TIdKey;\r\n protected readonly idColumn: SQLiteColumn;\r\n\r\n constructor(options: { orm: O; schema: S; table: TTable; idKey?: TIdKey }, repository?: R) {\r\n super({ orm: options.orm, schema: options.schema }, repository);\r\n this.table = options.table;\r\n this.idKey = options.idKey ?? (\"id\" as TIdKey);\r\n this.idColumn = (this.table as any)[this.idKey] as SQLiteColumn;\r\n }\r\n\r\n override withSorting<TQuery>(\r\n query: TQuery,\r\n { sort, order }: Pick<QueryInput, \"sort\" | \"order\">,\r\n table?: SQLiteTableWithColumns<any>\r\n ): TQuery {\r\n return super.withSorting(query, { sort, order }, table || this.table);\r\n }\r\n\r\n override withSortingAndPagination<MTable extends SQLiteTableWithColumns<any>, TQuery>(\r\n query: TQuery,\r\n { sort, order, page, limit }: Pick<QueryInput, \"sort\" | \"order\" | \"page\" | \"limit\">,\r\n table?: MTable\r\n ): TQuery {\r\n return super.withSortingAndPagination(query, { sort, order, page, limit }, table || this.table);\r\n }\r\n\r\n async queryList(\r\n query?: QueryInput,\r\n options?: {\r\n conditions?: TableConditionBuilder<TTable>;\r\n select?: SelectedFields<SQLiteColumn, TTable>;\r\n },\r\n tx?: O\r\n ): ServerResultAsync<{ rows: InferSelectModel<TTable>[]; total: number }> {\r\n return this.throwableAsync(async () => {\r\n type Row = InferSelectModel<TTable>;\r\n\r\n const db = tx ?? this.orm;\r\n const conditions = options?.conditions ?? this.getConditionBuilder(this.table);\r\n conditions.applyFilters(query);\r\n const whereClause = conditions.join();\r\n const rowsQuery = this.withSortingAndPagination(\r\n (options?.select ? db.select(options.select) : db.select())\r\n .from(this.table as any)\r\n .where(whereClause),\r\n query || {}\r\n );\r\n const countQuery = db\r\n .select({ count: count() })\r\n .from(this.table as any)\r\n .where(whereClause);\r\n const [rows, [totalResult]] = await Promise.all([rowsQuery, countQuery]);\r\n\r\n return ok({ rows: rows as Row[], total: totalResult?.count ?? 0 });\r\n });\r\n }\r\n\r\n async findById(id: string, tx?: O): ServerResultAsync<InferSelectModel<TTable> | undefined> {\r\n return this.throwableAsync(async () => {\r\n const db = tx ?? this.orm;\r\n type Row = InferSelectModel<TTable>;\r\n\r\n const rows = (await db\r\n .select()\r\n .from(this.table as any)\r\n .where(eq(this.idColumn as SQLiteColumn, id))) as Row[];\r\n\r\n return ok(rows[0]);\r\n });\r\n }\r\n\r\n async findManyById(\r\n ids: readonly string[],\r\n tx?: O\r\n ): ServerResultAsync<Array<InferSelectModel<TTable>>> {\r\n return this.throwableAsync(async () => {\r\n const db = tx ?? this.orm;\r\n type Row = InferSelectModel<TTable>;\r\n\r\n if (ids.length === 0) {\r\n return ok<Row[]>([]);\r\n }\r\n\r\n const rows = (await db\r\n .select()\r\n .from(this.table as any)\r\n .where(inArray(this.idColumn as SQLiteColumn, ids as string[]))) as Row[];\r\n\r\n return ok(rows);\r\n });\r\n }\r\n\r\n async create(\r\n data: InferInsertModel<TTable>,\r\n tx?: O\r\n ): ServerResultAsync<InferSelectModel<TTable>> {\r\n return this.throwableAsync(async () => {\r\n const db = tx ?? this.orm;\r\n type Row = InferSelectModel<TTable>;\r\n\r\n const rows = (await db\r\n .insert(this.table as any)\r\n .values(data as any)\r\n .returning()) as unknown as Row[];\r\n\r\n if (rows.length === 0) return this.error(\"UNPROCESSABLE_CONTENT\");\r\n return ok(rows[0] as Row);\r\n });\r\n }\r\n\r\n async createMany(\r\n data: readonly InferInsertModel<TTable>[],\r\n tx?: O\r\n ): ServerResultAsync<Array<InferSelectModel<TTable>>> {\r\n return this.throwableAsync(async () => {\r\n const db = tx ?? this.orm;\r\n type Row = InferSelectModel<TTable>;\r\n\r\n if (data.length === 0) {\r\n return ok<Row[]>([]);\r\n }\r\n\r\n const rows = (await db\r\n .insert(this.table as any)\r\n .values(data as any)\r\n .returning()) as unknown as Row[];\r\n\r\n return ok(rows as Row[]);\r\n });\r\n }\r\n\r\n async update(\r\n data: TableUpdatePayload<TTable, TIdKey>,\r\n tx?: O\r\n ): ServerResultAsync<InferSelectModel<TTable>> {\r\n return this.throwableAsync(async () => {\r\n const db = tx ?? this.orm;\r\n type Row = InferSelectModel<TTable>;\r\n\r\n const single = data as Record<string, unknown>;\r\n const id = String(single[this.idKey]);\r\n const { [this.idKey]: _removed, ...rest } = single;\r\n const update = rest;\r\n if (this.table.updatedAt) (update as any).updatedAt = new Date();\r\n const rows = (await db\r\n .update(this.table as any)\r\n .set(update as unknown as Partial<InferInsertModel<TTable>>)\r\n .where(eq(this.idColumn as SQLiteColumn, id))\r\n .returning()) as unknown as Row[];\r\n const [row] = rows;\r\n\r\n if (!row) return this.error(\"NOT_FOUND\");\r\n return ok(row) as ServerResult<Row>;\r\n });\r\n }\r\n\r\n async updateMany(\r\n data: readonly TableUpdatePayload<TTable, TIdKey>[],\r\n tx?: O\r\n ): ServerResultAsync<Array<InferSelectModel<TTable>>> {\r\n return this.throwableAsync(async () => {\r\n const db = tx ?? this.orm;\r\n type Row = InferSelectModel<TTable>;\r\n\r\n if (data.length === 0) {\r\n return ok<Row[]>([]);\r\n }\r\n\r\n const results: Row[] = [];\r\n for (const item of data) {\r\n const record = item as Record<string, unknown>;\r\n const id = String(record[this.idKey]);\r\n const { [this.idKey]: _removed, ...rest } = record;\r\n const update = rest;\r\n if (this.table.updatedAt) (update as any).updatedAt = new Date();\r\n const rows = (await db\r\n .update(this.table as any)\r\n .set(update as unknown as Partial<InferInsertModel<TTable>>)\r\n .where(eq(this.idColumn as SQLiteColumn, id))\r\n .returning()) as unknown as Row[];\r\n if (rows[0]) results.push(rows[0]);\r\n }\r\n\r\n return ok(results) as ServerResult<Row[]>;\r\n });\r\n }\r\n\r\n async softDeleteById(id: string, tx?: O): ServerResultAsync<{ id: string }> {\r\n return this.throwableAsync(async () => {\r\n const db = tx ?? this.orm;\r\n if (!this.table.deletedAt) return this.error(\"METHOD_NOT_SUPPORTED\");\r\n\r\n const rows = await db\r\n .update(this.table as any)\r\n .set({ deletedAt: new Date() })\r\n .where(eq(this.idColumn as SQLiteColumn, id))\r\n .returning({\r\n id: this.idColumn as SQLiteColumn,\r\n });\r\n\r\n if (rows.length === 0) return this.error(\"NOT_FOUND\");\r\n return ok(rows[0] as { id: string });\r\n });\r\n }\r\n\r\n async softDeleteManyById(\r\n ids: readonly string[],\r\n tx?: O\r\n ): ServerResultAsync<Array<{ id: string }>> {\r\n return this.throwableAsync(async () => {\r\n const db = tx ?? this.orm;\r\n if (!this.table.deletedAt) return this.error(\"METHOD_NOT_SUPPORTED\");\r\n\r\n const rows = await db\r\n .update(this.table as any)\r\n .set({ deletedAt: new Date() })\r\n .where(inArray(this.idColumn as SQLiteColumn, ids as string[]))\r\n .returning({\r\n id: this.idColumn as SQLiteColumn,\r\n });\r\n if (rows.length === 0) return this.error(\"NOT_FOUND\");\r\n return ok(rows as { id: string }[]);\r\n });\r\n }\r\n\r\n async deleteById(id: string, tx?: O): ServerResultAsync<{ id: string }> {\r\n return this.throwableAsync(async () => {\r\n const db = tx ?? this.orm;\r\n\r\n const rows = await db\r\n .delete(this.table as any)\r\n .where(eq(this.idColumn as SQLiteColumn, id))\r\n .returning({\r\n id: this.idColumn as SQLiteColumn,\r\n });\r\n\r\n if (rows.length === 0) return this.error(\"NOT_FOUND\");\r\n return ok(rows[0] as { id: string });\r\n });\r\n }\r\n\r\n async deleteManyById(ids: readonly string[], tx?: O): ServerResultAsync<Array<{ id: string }>> {\r\n return this.throwableAsync(async () => {\r\n const db = tx ?? this.orm;\r\n\r\n if (ids.length === 0) {\r\n return ok<{ id: string }[]>([]);\r\n }\r\n\r\n const rows = await db\r\n .delete(this.table as any)\r\n .where(inArray(this.idColumn as SQLiteColumn, ids as string[]))\r\n .returning({\r\n id: this.idColumn as SQLiteColumn,\r\n });\r\n\r\n return ok(rows as { id: string }[]);\r\n });\r\n }\r\n}\r\n\r\nexport class BaseExternaRepository extends Base {\r\n constructor() {\r\n super(\"repository\");\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;AAiCA,IAAa,mBAAb,MAA8B;CAC5B,YAAY,aAA4B,EAAE,EAAE;AAAxB,OAAA,aAAA;AAClB,OAAK,aAAa;;CAGpB,KAAK,WAAiB;AACpB,MAAI,UAAW,MAAK,WAAW,KAAK,UAAU;;CAGhD,KAAK,OAAqB,OAAO;AAC/B,MAAI,KAAK,WAAW,WAAW,EAAG,QAAO,KAAA;AACzC,MAAI,KAAK,WAAW,WAAW,EAAG,QAAO,KAAK,WAAW;AACzD,SAAO,SAAS,QAAQ,IAAI,GAAG,KAAK,WAAW,GAAG,GAAG,GAAG,KAAK,WAAW;;CAG1E,CAAC,OAAO,YAAY;AAClB,SAAO,KAAK,WAAW,OAAO,WAAW;;;AAI7C,IAAa,wBAAb,cAEU,iBAAiB;CACzB;CAEA,YAAY,OAAe;AACzB,SAAO;AACP,OAAK,QAAQ;;CAGf,aAAa,EAAE,YAAwC,EAAE,EAAE;AACzD,MAAI,WAAW,QAAQ,SAAS,EAAG,0BAAyB,MAAM,SAAS,KAAK,MAAM;;;AAI1F,MAAa,iBAAiB,OAAqB,WAAqB;CACtE,MAAM,gBAAuB,EAAE;AAC/B,MAAK,MAAM,SAAS,OAClB,eAAc,KAAK,KAAK,OAAO,KAAK,MAAM,IAAI,CAAC;AAEjD,QAAO,GAAG,GAA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IAAI,MAAM,EAAE,CAAC,CAC9B,MAAM,QAAQ,KAAK,UAA0B,IAAgB,CAAC,CAC9D,UAAU,EACT,IAAI,KAAK,UACV,CAAC;AACJ,OAAI,KAAK,WAAW,EAAG,QAAO,KAAK,MAAM,YAAY;AACrD,UAAO,GAAG,KAAyB;IACnC;;CAGJ,MAAM,WAAW,IAAY,IAA2C;AACtE,SAAO,KAAK,eAAe,YAAY;GAGrC,MAAM,OAAO,OAFF,MAAM,KAAK,KAGnB,OAAO,KAAK,MAAa,CACzB,MAAM,GAAG,KAAK,UAA0B,GAAG,CAAC,CAC5C,UAAU,EACT,IAAI,KAAK,UACV,CAAC;AAEJ,OAAI,KAAK,WAAW,EAAG,QAAO,KAAK,MAAM,YAAY;AACrD,UAAO,GAAG,KAAK,GAAqB;IACpC;;CAGJ,MAAM,eAAe,KAAwB,IAAkD;AAC7F,SAAO,KAAK,eAAe,YAAY;GACrC,MAAM,KAAK,MAAM,KAAK;AAEtB,OAAI,IAAI,WAAW,EACjB,QAAO,GAAqB,EAAE,CAAC;AAUjC,UAAO,GAPM,MAAM,GAChB,OAAO,KAAK,MAAa,CACzB,MAAM,QAAQ,KAAK,UAA0B,IAAgB,CAAC,CAC9D,UAAU,EACT,IAAI,KAAK,UACV,CAAC,CAE+B;IACnC;;;AAIN,IAAa,wBAAb,cAA2C,KAAK;CAC9C,cAAc;AACZ,QAAM,aAAa"}
@@ -0,0 +1,44 @@
1
+ import { ServerResult, ServerResultAsync } from "./base.dto.mjs";
2
+ import { Base } from "./base.abstract.mjs";
3
+ import { AuthenticatedActor } from "./base.actor.mjs";
4
+ import { Entity, ResourceActionGrant, ResourceGrant } from "./base.grants.mjs";
5
+ import { PermissionServiceProcedureBuilder, ServiceProcedure, ServiceProcedureAccessConfig, ServiceProcedureAccessEntitiesConfig, ServiceProcedureAccessStateConfig, ServiceProcedureArgs, ServiceProcedureBuilder, ServiceProcedureContext, ServiceProcedureContextFilterScope, ServiceProcedureContextFilteredInput, ServiceProcedureEntityStepName, ServiceProcedureInputMapper } from "./base.procedure.mjs";
6
+ import { QueryFilter, QueryInput } from "@m5kdev/commons/modules/schemas/query.schema";
7
+
8
+ //#region src/modules/base/base.service.d.ts
9
+ declare class BaseService<Repositories extends Record<string, Base>, Services extends Record<string, Base>, DefaultContext extends ServiceProcedureContext = ServiceProcedureContext> extends Base {
10
+ repository: Repositories;
11
+ service: Services;
12
+ constructor(repository?: Repositories, service?: Services);
13
+ addUserFilter(value: string, query?: undefined, columnId?: string, method?: QueryFilter["method"]): QueryInput;
14
+ addUserFilter<TQuery extends QueryInput>(value: string, query: TQuery, columnId?: string, method?: QueryFilter["method"]): TQuery;
15
+ protected procedure<TInput, TCtx extends ServiceProcedureContext = DefaultContext>(name: string): ServiceProcedureBuilder<TInput, TCtx, Repositories, Services>;
16
+ addContextFilter(actor: AuthenticatedActor, include?: {
17
+ user?: boolean;
18
+ organization?: boolean;
19
+ team?: boolean;
20
+ }, query?: undefined, map?: Record<string, {
21
+ columnId: string;
22
+ method: QueryFilter["method"];
23
+ }>): QueryInput;
24
+ addContextFilter<TQuery extends QueryInput>(actor: AuthenticatedActor, include: {
25
+ user?: boolean;
26
+ organization?: boolean;
27
+ team?: boolean;
28
+ } | undefined, query: TQuery, map?: Record<string, {
29
+ columnId: string;
30
+ method: QueryFilter["method"];
31
+ }>): TQuery;
32
+ }
33
+ declare class BasePermissionService<Repositories extends Record<string, Base>, Services extends Record<string, Base>, DefaultContext extends ServiceProcedureContext = ServiceProcedureContext> extends BaseService<Repositories, Services, DefaultContext> {
34
+ grants: ResourceGrant[];
35
+ constructor(repository: Repositories, service: Services, grants?: ResourceGrant[]);
36
+ accessGuard<T extends Entity>(actor: AuthenticatedActor, action: string, entities?: T | T[], grants?: ResourceActionGrant[]): ServerResult<true>;
37
+ accessGuardAsync<T extends Entity>(actor: AuthenticatedActor, action: string, getEntities: () => ServerResultAsync<T | T[] | undefined>, grants?: ResourceActionGrant[]): ServerResultAsync<true>;
38
+ protected procedure<TInput, TCtx extends ServiceProcedureContext = DefaultContext>(name: string): PermissionServiceProcedureBuilder<TInput, TCtx, Repositories, Services>;
39
+ checkPermission<T extends Entity>(actor: AuthenticatedActor, action: string, entities?: T | T[], grants?: ResourceActionGrant[]): boolean;
40
+ checkPermissionAsync<T extends Entity>(actor: AuthenticatedActor, action: string, getEntities: () => ServerResultAsync<T | T[] | undefined>, grants?: ResourceActionGrant[]): ServerResultAsync<boolean>;
41
+ }
42
+ //#endregion
43
+ export { BasePermissionService, BaseService, type PermissionServiceProcedureBuilder, type ServiceProcedure, type ServiceProcedureAccessConfig, type ServiceProcedureAccessEntitiesConfig, type ServiceProcedureAccessStateConfig, type ServiceProcedureArgs, type ServiceProcedureBuilder, type ServiceProcedureContext, type ServiceProcedureContextFilterScope, type ServiceProcedureContextFilteredInput, type ServiceProcedureEntityStepName, type ServiceProcedureInputMapper };
44
+ //# sourceMappingURL=base.service.d.mts.map
@@ -0,0 +1,116 @@
1
+ import { validateActor } from "./base.actor.mjs";
2
+ import { Base } from "./base.abstract.mjs";
3
+ import { checkPermissionAsync, checkPermissionSync } from "./base.grants.mjs";
4
+ import { createPermissionServiceProcedureBuilder, createServiceProcedureBuilder } from "./base.procedure.mjs";
5
+ import { err, ok } from "neverthrow";
6
+ //#region src/modules/base/base.service.ts
7
+ var BaseService = class extends Base {
8
+ constructor(repository = {}, service = {}) {
9
+ super("service");
10
+ this.repository = repository;
11
+ this.service = service;
12
+ this.repository = repository;
13
+ this.service = service;
14
+ }
15
+ addUserFilter(value, query, columnId = "userId", method = "equals") {
16
+ const userFilter = {
17
+ columnId,
18
+ type: "string",
19
+ method,
20
+ value
21
+ };
22
+ return query ? {
23
+ ...query,
24
+ filters: [...query?.filters ?? [], userFilter]
25
+ } : { filters: [userFilter] };
26
+ }
27
+ procedure(name) {
28
+ return createServiceProcedureBuilder(this, {
29
+ name,
30
+ steps: []
31
+ });
32
+ }
33
+ addContextFilter(actor, include = {
34
+ user: true,
35
+ organization: false,
36
+ team: false
37
+ }, query, map = {
38
+ userId: {
39
+ columnId: "userId",
40
+ method: "equals"
41
+ },
42
+ organizationId: {
43
+ columnId: "organizationId",
44
+ method: "equals"
45
+ },
46
+ teamId: {
47
+ columnId: "teamId",
48
+ method: "equals"
49
+ }
50
+ }) {
51
+ const filters = [];
52
+ if (include.user) filters.push({
53
+ columnId: map.userId.columnId,
54
+ type: "string",
55
+ method: map.userId.method,
56
+ value: actor.userId
57
+ });
58
+ if (include.organization) {
59
+ if (!validateActor(actor, "organization")) throw new Error("Organization-scoped context filter requires an organization actor");
60
+ filters.push({
61
+ columnId: map.organizationId.columnId,
62
+ type: "string",
63
+ method: map.organizationId.method,
64
+ value: actor.organizationId
65
+ });
66
+ }
67
+ if (include.team) {
68
+ if (!validateActor(actor, "team")) throw new Error("Team-scoped context filter requires a team actor");
69
+ filters.push({
70
+ columnId: map.teamId.columnId,
71
+ type: "string",
72
+ method: map.teamId.method,
73
+ value: actor.teamId
74
+ });
75
+ }
76
+ return query ? {
77
+ ...query,
78
+ filters: [...query?.filters ?? [], ...filters]
79
+ } : { filters };
80
+ }
81
+ };
82
+ var BasePermissionService = class extends BaseService {
83
+ grants;
84
+ constructor(repository, service, grants = []) {
85
+ super(repository, service);
86
+ this.grants = grants;
87
+ }
88
+ accessGuard(actor, action, entities, grants) {
89
+ if (!this.checkPermission(actor, action, entities, grants)) return this.error("FORBIDDEN");
90
+ return ok(true);
91
+ }
92
+ async accessGuardAsync(actor, action, getEntities, grants) {
93
+ const hasPermission = await this.checkPermissionAsync(actor, action, getEntities, grants);
94
+ if (hasPermission.isErr()) return err(hasPermission.error);
95
+ if (!hasPermission.value) return this.error("FORBIDDEN");
96
+ return ok(true);
97
+ }
98
+ procedure(name) {
99
+ return createPermissionServiceProcedureBuilder(this, {
100
+ name,
101
+ steps: []
102
+ });
103
+ }
104
+ checkPermission(actor, action, entities, grants) {
105
+ return checkPermissionSync(actor, grants ?? this.grants.filter((grant) => grant.action === action), entities);
106
+ }
107
+ async checkPermissionAsync(actor, action, getEntities, grants) {
108
+ const permission = await checkPermissionAsync(actor, grants ?? this.grants.filter((grant) => grant.action === action), getEntities);
109
+ if (permission.isErr()) return this.error("INTERNAL_SERVER_ERROR", "Failed to check permission", { cause: permission.error });
110
+ return ok(permission.value);
111
+ }
112
+ };
113
+ //#endregion
114
+ export { BasePermissionService, BaseService };
115
+
116
+ //# sourceMappingURL=base.service.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.service.mjs","names":[],"sources":["../../../../src/modules/base/base.service.ts"],"sourcesContent":["import type { QueryFilter, QueryInput } from \"@m5kdev/commons/modules/schemas/query.schema\";\r\nimport { err, ok } from \"neverthrow\";\r\nimport { Base } from \"./base.abstract\";\r\nimport { type AuthenticatedActor, validateActor } from \"./base.actor\";\r\nimport type { ServerResult, ServerResultAsync } from \"./base.dto\";\r\nimport {\r\n checkPermissionAsync,\r\n checkPermissionSync,\r\n type Entity,\r\n type ResourceActionGrant,\r\n type ResourceGrant,\r\n} from \"./base.grants\";\r\nimport {\r\n createPermissionServiceProcedureBuilder,\r\n createServiceProcedureBuilder,\r\n type PermissionServiceProcedureBuilder,\r\n type ServiceProcedureBuilder,\r\n type ServiceProcedureContext,\r\n} from \"./base.procedure\";\r\n\r\nexport type {\r\n PermissionServiceProcedureBuilder,\r\n ServiceProcedure,\r\n ServiceProcedureAccessConfig,\r\n ServiceProcedureAccessEntitiesConfig,\r\n ServiceProcedureAccessStateConfig,\r\n ServiceProcedureArgs,\r\n ServiceProcedureBuilder,\r\n ServiceProcedureContext,\r\n ServiceProcedureContextFilteredInput,\r\n ServiceProcedureContextFilterScope,\r\n ServiceProcedureEntityStepName,\r\n ServiceProcedureInputMapper,\r\n} from \"./base.procedure\";\r\n\r\nexport class BaseService<\r\n Repositories extends Record<string, Base>,\r\n Services extends Record<string, Base>,\r\n DefaultContext extends ServiceProcedureContext = ServiceProcedureContext,\r\n> extends Base {\r\n constructor(\r\n public repository: Repositories = {} as Repositories,\r\n public service: Services = {} as Services\r\n ) {\r\n super(\"service\");\r\n this.repository = repository;\r\n this.service = service;\r\n }\r\n\r\n addUserFilter(\r\n value: string,\r\n query?: undefined,\r\n columnId?: string,\r\n method?: QueryFilter[\"method\"]\r\n ): QueryInput;\r\n addUserFilter<TQuery extends QueryInput>(\r\n value: string,\r\n query: TQuery,\r\n columnId?: string,\r\n method?: QueryFilter[\"method\"]\r\n ): TQuery;\r\n addUserFilter(\r\n value: string,\r\n query?: QueryInput,\r\n columnId = \"userId\",\r\n method: QueryFilter[\"method\"] = \"equals\"\r\n ): QueryInput {\r\n const userFilter: QueryFilter = {\r\n columnId,\r\n type: \"string\",\r\n method,\r\n value,\r\n };\r\n return query\r\n ? { ...query, filters: [...(query?.filters ?? []), userFilter] }\r\n : { filters: [userFilter] };\r\n }\r\n\r\n protected procedure<TInput, TCtx extends ServiceProcedureContext = DefaultContext>(\r\n name: string\r\n ): ServiceProcedureBuilder<TInput, TCtx, Repositories, Services> {\r\n return createServiceProcedureBuilder(this, { name, steps: [] });\r\n }\r\n\r\n addContextFilter(\r\n actor: AuthenticatedActor,\r\n include?: { user?: boolean; organization?: boolean; team?: boolean },\r\n query?: undefined,\r\n map?: Record<string, { columnId: string; method: QueryFilter[\"method\"] }>\r\n ): QueryInput;\r\n addContextFilter<TQuery extends QueryInput>(\r\n actor: AuthenticatedActor,\r\n include: { user?: boolean; organization?: boolean; team?: boolean } | undefined,\r\n query: TQuery,\r\n map?: Record<string, { columnId: string; method: QueryFilter[\"method\"] }>\r\n ): TQuery;\r\n addContextFilter(\r\n actor: AuthenticatedActor,\r\n include: { user?: boolean; organization?: boolean; team?: boolean } = {\r\n user: true,\r\n organization: false,\r\n team: false,\r\n },\r\n query?: QueryInput,\r\n map: Record<string, { columnId: string; method: QueryFilter[\"method\"] }> = {\r\n userId: {\r\n columnId: \"userId\",\r\n method: \"equals\",\r\n },\r\n organizationId: {\r\n columnId: \"organizationId\",\r\n method: \"equals\",\r\n },\r\n teamId: {\r\n columnId: \"teamId\",\r\n method: \"equals\",\r\n },\r\n }\r\n ): QueryInput {\r\n const filters: QueryFilter[] = [];\r\n\r\n if (include.user) {\r\n filters.push({\r\n columnId: map.userId.columnId,\r\n type: \"string\",\r\n method: map.userId.method,\r\n value: actor.userId,\r\n });\r\n }\r\n if (include.organization) {\r\n if (!validateActor(actor, \"organization\")) {\r\n throw new Error(\"Organization-scoped context filter requires an organization actor\");\r\n }\r\n filters.push({\r\n columnId: map.organizationId.columnId,\r\n type: \"string\",\r\n method: map.organizationId.method,\r\n value: actor.organizationId!,\r\n });\r\n }\r\n if (include.team) {\r\n if (!validateActor(actor, \"team\")) {\r\n throw new Error(\"Team-scoped context filter requires a team actor\");\r\n }\r\n filters.push({\r\n columnId: map.teamId.columnId,\r\n type: \"string\",\r\n method: map.teamId.method,\r\n value: actor.teamId!,\r\n });\r\n }\r\n return query ? { ...query, filters: [...(query?.filters ?? []), ...filters] } : { filters };\r\n }\r\n}\r\n\r\nexport class BasePermissionService<\r\n Repositories extends Record<string, Base>,\r\n Services extends Record<string, Base>,\r\n DefaultContext extends ServiceProcedureContext = ServiceProcedureContext,\r\n> extends BaseService<Repositories, Services, DefaultContext> {\r\n grants: ResourceGrant[];\r\n constructor(repository: Repositories, service: Services, grants: ResourceGrant[] = []) {\r\n super(repository, service);\r\n this.grants = grants;\r\n }\r\n\r\n accessGuard<T extends Entity>(\r\n actor: AuthenticatedActor,\r\n action: string,\r\n entities?: T | T[],\r\n grants?: ResourceActionGrant[]\r\n ): ServerResult<true> {\r\n const hasPermission = this.checkPermission(actor, action, entities, grants);\r\n if (!hasPermission) return this.error(\"FORBIDDEN\");\r\n return ok(true);\r\n }\r\n\r\n async accessGuardAsync<T extends Entity>(\r\n actor: AuthenticatedActor,\r\n action: string,\r\n getEntities: () => ServerResultAsync<T | T[] | undefined>,\r\n grants?: ResourceActionGrant[]\r\n ): ServerResultAsync<true> {\r\n const hasPermission = await this.checkPermissionAsync(actor, action, getEntities, grants);\r\n if (hasPermission.isErr()) return err(hasPermission.error);\r\n if (!hasPermission.value) return this.error(\"FORBIDDEN\");\r\n return ok(true);\r\n }\r\n\r\n protected override procedure<TInput, TCtx extends ServiceProcedureContext = DefaultContext>(\r\n name: string\r\n ): PermissionServiceProcedureBuilder<TInput, TCtx, Repositories, Services> {\r\n return createPermissionServiceProcedureBuilder(this, { name, steps: [] });\r\n }\r\n\r\n checkPermission<T extends Entity>(\r\n actor: AuthenticatedActor,\r\n action: string,\r\n entities?: T | T[],\r\n grants?: ResourceActionGrant[]\r\n ): boolean {\r\n const actionGrants = grants ?? this.grants.filter((grant) => grant.action === action);\r\n return checkPermissionSync(actor, actionGrants, entities);\r\n }\r\n\r\n async checkPermissionAsync<T extends Entity>(\r\n actor: AuthenticatedActor,\r\n action: string,\r\n getEntities: () => ServerResultAsync<T | T[] | undefined>,\r\n grants?: ResourceActionGrant[]\r\n ): ServerResultAsync<boolean> {\r\n const actionGrants = grants ?? this.grants.filter((grant) => grant.action === action);\r\n const permission = await checkPermissionAsync(actor, actionGrants, getEntities);\r\n if (permission.isErr())\r\n return this.error(\"INTERNAL_SERVER_ERROR\", \"Failed to check permission\", {\r\n cause: permission.error,\r\n });\r\n return ok(permission.value);\r\n }\r\n}\r\n"],"mappings":";;;;;;AAmCA,IAAa,cAAb,cAIU,KAAK;CACb,YACE,aAAkC,EAAE,EACpC,UAA2B,EAAE,EAC7B;AACA,QAAM,UAAU;AAHT,OAAA,aAAA;AACA,OAAA,UAAA;AAGP,OAAK,aAAa;AAClB,OAAK,UAAU;;CAejB,cACE,OACA,OACA,WAAW,UACX,SAAgC,UACpB;EACZ,MAAM,aAA0B;GAC9B;GACA,MAAM;GACN;GACA;GACD;AACD,SAAO,QACH;GAAE,GAAG;GAAO,SAAS,CAAC,GAAI,OAAO,WAAW,EAAE,EAAG,WAAW;GAAE,GAC9D,EAAE,SAAS,CAAC,WAAW,EAAE;;CAG/B,UACE,MAC+D;AAC/D,SAAO,8BAA8B,MAAM;GAA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ACA,aACA,QACyB;EACzB,MAAM,gBAAgB,MAAM,KAAK,qBAAqB,OAAO,QAAQ,aAAa,OAAO;AACzF,MAAI,cAAc,OAAO,CAAE,QAAO,IAAI,cAAc,MAAM;AAC1D,MAAI,CAAC,cAAc,MAAO,QAAO,KAAK,MAAM,YAAY;AACxD,SAAO,GAAG,KAAK;;CAGjB,UACE,MACyE;AACzE,SAAO,wCAAwC,MAAM;GAAE;GAAM,OAAO,EAAE;GAAE,CAAC;;CAG3E,gBACE,OACA,QACA,UACA,QACS;AAET,SAAO,oBAAoB,OADN,UAAU,KAAK,OAAO,QAAQ,UAAU,MAAM,WAAW,OAAO,EACrC,SAAS;;CAG3D,MAAM,qBACJ,OACA,QACA,aACA,QAC4B;EAE5B,MAAM,aAAa,MAAM,qBAAqB,OADzB,UAAU,KAAK,OAAO,QAAQ,UAAU,MAAM,WAAW,OAAO,EAClB,YAAY;AAC/E,MAAI,WAAW,OAAO,CACpB,QAAO,KAAK,MAAM,yBAAyB,8BAA8B,EACvE,OAAO,WAAW,OACnB,CAAC;AACJ,SAAO,GAAG,WAAW,MAAM"}
@@ -0,0 +1,5 @@
1
+ //#region src/modules/base/base.types.d.ts
2
+ type ServerErrorLayer = "unknown" | "repository" | "service" | "controller" | "auth" | "workflow";
3
+ //#endregion
4
+ export { ServerErrorLayer };
5
+ //# sourceMappingURL=base.types.d.mts.map