semola 0.5.3 → 0.6.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 (367) hide show
  1. package/README.md +18 -45
  2. package/dist/chunk-CKQMccvm.cjs +28 -0
  3. package/dist/lib/api/index.cjs +536 -4
  4. package/dist/lib/api/index.d.cts +270 -4
  5. package/dist/lib/api/index.d.mts +270 -4
  6. package/dist/lib/api/index.mjs +534 -2
  7. package/dist/lib/cache/index.cjs +47 -22
  8. package/dist/lib/cache/index.d.cts +14 -23
  9. package/dist/lib/cache/index.d.mts +14 -23
  10. package/dist/lib/cache/index.mjs +48 -25
  11. package/dist/lib/cron/index.cjs +734 -12
  12. package/dist/lib/cron/index.d.cts +145 -3
  13. package/dist/lib/cron/index.d.mts +145 -3
  14. package/dist/lib/cron/index.mjs +725 -3
  15. package/dist/lib/errors/index.d.cts +4 -4
  16. package/dist/lib/errors/index.d.mts +4 -4
  17. package/dist/lib/errors/index.mjs +0 -2
  18. package/dist/lib/i18n/index.d.cts +12 -4
  19. package/dist/lib/i18n/index.d.mts +12 -4
  20. package/dist/lib/i18n/index.mjs +0 -2
  21. package/dist/lib/logging/index.cjs +387 -17
  22. package/dist/lib/logging/index.d.cts +107 -6
  23. package/dist/lib/logging/index.d.mts +107 -6
  24. package/dist/lib/logging/index.mjs +373 -4
  25. package/dist/lib/orm/index.cjs +1641 -19
  26. package/dist/lib/orm/index.d.cts +402 -7
  27. package/dist/lib/orm/index.d.mts +402 -7
  28. package/dist/lib/orm/index.mjs +1630 -6
  29. package/dist/lib/policy/index.cjs +206 -20
  30. package/dist/lib/policy/index.d.cts +61 -5
  31. package/dist/lib/policy/index.d.mts +61 -5
  32. package/dist/lib/policy/index.mjs +187 -3
  33. package/dist/lib/prompts/index.cjs +374 -14
  34. package/dist/lib/prompts/index.d.cts +73 -29
  35. package/dist/lib/prompts/index.d.mts +73 -29
  36. package/dist/lib/prompts/index.mjs +361 -4
  37. package/dist/lib/pubsub/index.cjs +43 -19
  38. package/dist/lib/pubsub/index.d.cts +12 -22
  39. package/dist/lib/pubsub/index.d.mts +12 -22
  40. package/dist/lib/pubsub/index.mjs +44 -22
  41. package/dist/lib/queue/index.cjs +40 -10
  42. package/dist/lib/queue/index.d.cts +57 -8
  43. package/dist/lib/queue/index.d.mts +57 -8
  44. package/dist/lib/queue/index.mjs +39 -13
  45. package/dist/lib/workflow/index.cjs +285 -282
  46. package/dist/lib/workflow/index.d.cts +147 -4
  47. package/dist/lib/workflow/index.d.mts +147 -4
  48. package/dist/lib/workflow/index.mjs +278 -286
  49. package/package.json +11 -1
  50. package/dist/api/core/index.cjs +0 -206
  51. package/dist/api/core/index.d.cts +0 -21
  52. package/dist/api/core/index.d.cts.map +0 -1
  53. package/dist/api/core/index.d.mts +0 -21
  54. package/dist/api/core/index.d.mts.map +0 -1
  55. package/dist/api/core/index.mjs +0 -208
  56. package/dist/api/core/index.mjs.map +0 -1
  57. package/dist/api/core/types.d.cts +0 -107
  58. package/dist/api/core/types.d.cts.map +0 -1
  59. package/dist/api/core/types.d.mts +0 -107
  60. package/dist/api/core/types.d.mts.map +0 -1
  61. package/dist/api/middleware/index.cjs +0 -8
  62. package/dist/api/middleware/index.d.cts +0 -11
  63. package/dist/api/middleware/index.d.cts.map +0 -1
  64. package/dist/api/middleware/index.d.mts +0 -11
  65. package/dist/api/middleware/index.d.mts.map +0 -1
  66. package/dist/api/middleware/index.mjs +0 -10
  67. package/dist/api/middleware/index.mjs.map +0 -1
  68. package/dist/api/middleware/types.d.cts +0 -16
  69. package/dist/api/middleware/types.d.cts.map +0 -1
  70. package/dist/api/middleware/types.d.mts +0 -16
  71. package/dist/api/middleware/types.d.mts.map +0 -1
  72. package/dist/api/openapi/index.cjs +0 -254
  73. package/dist/api/openapi/index.mjs +0 -256
  74. package/dist/api/openapi/index.mjs.map +0 -1
  75. package/dist/api/openapi/types.d.cts +0 -60
  76. package/dist/api/openapi/types.d.cts.map +0 -1
  77. package/dist/api/openapi/types.d.mts +0 -60
  78. package/dist/api/openapi/types.d.mts.map +0 -1
  79. package/dist/api/validation/index.cjs +0 -64
  80. package/dist/api/validation/index.mjs +0 -61
  81. package/dist/api/validation/index.mjs.map +0 -1
  82. package/dist/cache/types.d.cts +0 -17
  83. package/dist/cache/types.d.cts.map +0 -1
  84. package/dist/cache/types.d.mts +0 -17
  85. package/dist/cache/types.d.mts.map +0 -1
  86. package/dist/cron/builder/index.cjs +0 -166
  87. package/dist/cron/builder/index.d.cts +0 -28
  88. package/dist/cron/builder/index.d.cts.map +0 -1
  89. package/dist/cron/builder/index.d.mts +0 -28
  90. package/dist/cron/builder/index.d.mts.map +0 -1
  91. package/dist/cron/builder/index.mjs +0 -163
  92. package/dist/cron/builder/index.mjs.map +0 -1
  93. package/dist/cron/builder/types.cjs +0 -27
  94. package/dist/cron/builder/types.d.cts +0 -79
  95. package/dist/cron/builder/types.d.cts.map +0 -1
  96. package/dist/cron/builder/types.d.mts +0 -79
  97. package/dist/cron/builder/types.d.mts.map +0 -1
  98. package/dist/cron/builder/types.mjs +0 -28
  99. package/dist/cron/builder/types.mjs.map +0 -1
  100. package/dist/cron/core/index.cjs +0 -308
  101. package/dist/cron/core/index.d.cts +0 -39
  102. package/dist/cron/core/index.d.cts.map +0 -1
  103. package/dist/cron/core/index.d.mts +0 -39
  104. package/dist/cron/core/index.d.mts.map +0 -1
  105. package/dist/cron/core/index.mjs +0 -310
  106. package/dist/cron/core/index.mjs.map +0 -1
  107. package/dist/cron/core/scanner.cjs +0 -237
  108. package/dist/cron/core/scanner.mjs +0 -238
  109. package/dist/cron/core/scanner.mjs.map +0 -1
  110. package/dist/cron/core/types.d.cts +0 -11
  111. package/dist/cron/core/types.d.cts.map +0 -1
  112. package/dist/cron/core/types.d.mts +0 -11
  113. package/dist/cron/core/types.d.mts.map +0 -1
  114. package/dist/errors/types.d.cts +0 -5
  115. package/dist/errors/types.d.cts.map +0 -1
  116. package/dist/errors/types.d.mts +0 -5
  117. package/dist/errors/types.d.mts.map +0 -1
  118. package/dist/i18n/types.d.cts +0 -13
  119. package/dist/i18n/types.d.cts.map +0 -1
  120. package/dist/i18n/types.d.mts +0 -13
  121. package/dist/i18n/types.d.mts.map +0 -1
  122. package/dist/lib/cache/index.d.cts.map +0 -1
  123. package/dist/lib/cache/index.d.mts.map +0 -1
  124. package/dist/lib/cache/index.mjs.map +0 -1
  125. package/dist/lib/errors/index.d.cts.map +0 -1
  126. package/dist/lib/errors/index.d.mts.map +0 -1
  127. package/dist/lib/errors/index.mjs.map +0 -1
  128. package/dist/lib/i18n/index.d.cts.map +0 -1
  129. package/dist/lib/i18n/index.d.mts.map +0 -1
  130. package/dist/lib/i18n/index.mjs.map +0 -1
  131. package/dist/lib/policy/index.d.cts.map +0 -1
  132. package/dist/lib/policy/index.d.mts.map +0 -1
  133. package/dist/lib/policy/index.mjs.map +0 -1
  134. package/dist/lib/prompts/index.d.cts.map +0 -1
  135. package/dist/lib/prompts/index.d.mts.map +0 -1
  136. package/dist/lib/prompts/index.mjs.map +0 -1
  137. package/dist/lib/pubsub/index.d.cts.map +0 -1
  138. package/dist/lib/pubsub/index.d.mts.map +0 -1
  139. package/dist/lib/pubsub/index.mjs.map +0 -1
  140. package/dist/lib/queue/index.d.cts.map +0 -1
  141. package/dist/lib/queue/index.d.mts.map +0 -1
  142. package/dist/lib/queue/index.mjs.map +0 -1
  143. package/dist/lib/workflow/index.d.cts.map +0 -1
  144. package/dist/lib/workflow/index.d.mts.map +0 -1
  145. package/dist/lib/workflow/index.mjs.map +0 -1
  146. package/dist/logging/core/index.cjs +0 -99
  147. package/dist/logging/core/index.d.cts +0 -26
  148. package/dist/logging/core/index.d.cts.map +0 -1
  149. package/dist/logging/core/index.d.mts +0 -26
  150. package/dist/logging/core/index.d.mts.map +0 -1
  151. package/dist/logging/core/index.mjs +0 -99
  152. package/dist/logging/core/index.mjs.map +0 -1
  153. package/dist/logging/core/types.cjs +0 -10
  154. package/dist/logging/core/types.d.cts +0 -22
  155. package/dist/logging/core/types.d.cts.map +0 -1
  156. package/dist/logging/core/types.d.mts +0 -22
  157. package/dist/logging/core/types.d.mts.map +0 -1
  158. package/dist/logging/core/types.mjs +0 -12
  159. package/dist/logging/core/types.mjs.map +0 -1
  160. package/dist/logging/formatter/index.cjs +0 -119
  161. package/dist/logging/formatter/index.d.cts +0 -27
  162. package/dist/logging/formatter/index.d.cts.map +0 -1
  163. package/dist/logging/formatter/index.d.mts +0 -27
  164. package/dist/logging/formatter/index.d.mts.map +0 -1
  165. package/dist/logging/formatter/index.mjs +0 -115
  166. package/dist/logging/formatter/index.mjs.map +0 -1
  167. package/dist/logging/formatter/types.d.cts +0 -5
  168. package/dist/logging/formatter/types.d.cts.map +0 -1
  169. package/dist/logging/formatter/types.d.mts +0 -5
  170. package/dist/logging/formatter/types.d.mts.map +0 -1
  171. package/dist/logging/provider/index.cjs +0 -165
  172. package/dist/logging/provider/index.d.cts +0 -28
  173. package/dist/logging/provider/index.d.cts.map +0 -1
  174. package/dist/logging/provider/index.d.mts +0 -28
  175. package/dist/logging/provider/index.d.mts.map +0 -1
  176. package/dist/logging/provider/index.mjs +0 -165
  177. package/dist/logging/provider/index.mjs.map +0 -1
  178. package/dist/logging/provider/types.d.cts +0 -23
  179. package/dist/logging/provider/types.d.cts.map +0 -1
  180. package/dist/logging/provider/types.d.mts +0 -23
  181. package/dist/logging/provider/types.d.mts.map +0 -1
  182. package/dist/node_modules/@standard-schema/spec/dist/index.d.cts +0 -80
  183. package/dist/node_modules/@standard-schema/spec/dist/index.d.cts.map +0 -1
  184. package/dist/node_modules/@standard-schema/spec/dist/index.d.mts +0 -80
  185. package/dist/node_modules/@standard-schema/spec/dist/index.d.mts.map +0 -1
  186. package/dist/orm/column.cjs +0 -137
  187. package/dist/orm/column.d.cts +0 -121
  188. package/dist/orm/column.d.cts.map +0 -1
  189. package/dist/orm/column.d.mts +0 -121
  190. package/dist/orm/column.d.mts.map +0 -1
  191. package/dist/orm/column.mjs +0 -132
  192. package/dist/orm/column.mjs.map +0 -1
  193. package/dist/orm/dialect/index.cjs +0 -14
  194. package/dist/orm/dialect/index.mjs +0 -16
  195. package/dist/orm/dialect/index.mjs.map +0 -1
  196. package/dist/orm/dialect/mysql.cjs +0 -31
  197. package/dist/orm/dialect/mysql.mjs +0 -33
  198. package/dist/orm/dialect/mysql.mjs.map +0 -1
  199. package/dist/orm/dialect/postgres.cjs +0 -23
  200. package/dist/orm/dialect/postgres.mjs +0 -25
  201. package/dist/orm/dialect/postgres.mjs.map +0 -1
  202. package/dist/orm/dialect/sqlite.cjs +0 -31
  203. package/dist/orm/dialect/sqlite.mjs +0 -33
  204. package/dist/orm/dialect/sqlite.mjs.map +0 -1
  205. package/dist/orm/dialect/utils.cjs +0 -8
  206. package/dist/orm/dialect/utils.mjs +0 -10
  207. package/dist/orm/dialect/utils.mjs.map +0 -1
  208. package/dist/orm/internal/table-columns.cjs +0 -31
  209. package/dist/orm/internal/table-columns.mjs +0 -32
  210. package/dist/orm/internal/table-columns.mjs.map +0 -1
  211. package/dist/orm/internal/table-lookup.cjs +0 -35
  212. package/dist/orm/internal/table-lookup.mjs +0 -35
  213. package/dist/orm/internal/table-lookup.mjs.map +0 -1
  214. package/dist/orm/internal/table-relations.cjs +0 -28
  215. package/dist/orm/internal/table-relations.mjs +0 -29
  216. package/dist/orm/internal/table-relations.mjs.map +0 -1
  217. package/dist/orm/migration/config.cjs +0 -7
  218. package/dist/orm/migration/config.d.cts +0 -7
  219. package/dist/orm/migration/config.d.cts.map +0 -1
  220. package/dist/orm/migration/config.d.mts +0 -7
  221. package/dist/orm/migration/config.d.mts.map +0 -1
  222. package/dist/orm/migration/config.mjs +0 -8
  223. package/dist/orm/migration/config.mjs.map +0 -1
  224. package/dist/orm/migration/types.d.cts +0 -20
  225. package/dist/orm/migration/types.d.cts.map +0 -1
  226. package/dist/orm/migration/types.d.mts +0 -20
  227. package/dist/orm/migration/types.d.mts.map +0 -1
  228. package/dist/orm/orm.cjs +0 -41
  229. package/dist/orm/orm.d.cts +0 -18
  230. package/dist/orm/orm.d.cts.map +0 -1
  231. package/dist/orm/orm.d.mts +0 -18
  232. package/dist/orm/orm.d.mts.map +0 -1
  233. package/dist/orm/orm.mjs +0 -43
  234. package/dist/orm/orm.mjs.map +0 -1
  235. package/dist/orm/relation.cjs +0 -18
  236. package/dist/orm/relation.d.cts +0 -8
  237. package/dist/orm/relation.d.cts.map +0 -1
  238. package/dist/orm/relation.d.mts +0 -8
  239. package/dist/orm/relation.d.mts.map +0 -1
  240. package/dist/orm/relation.mjs +0 -19
  241. package/dist/orm/relation.mjs.map +0 -1
  242. package/dist/orm/runtime/builders/mutations.cjs +0 -29
  243. package/dist/orm/runtime/builders/mutations.mjs +0 -28
  244. package/dist/orm/runtime/builders/mutations.mjs.map +0 -1
  245. package/dist/orm/runtime/builders/select.cjs +0 -18
  246. package/dist/orm/runtime/builders/select.mjs +0 -19
  247. package/dist/orm/runtime/builders/select.mjs.map +0 -1
  248. package/dist/orm/runtime/client.cjs +0 -90
  249. package/dist/orm/runtime/client.mjs +0 -92
  250. package/dist/orm/runtime/client.mjs.map +0 -1
  251. package/dist/orm/runtime/context.cjs +0 -49
  252. package/dist/orm/runtime/context.mjs +0 -51
  253. package/dist/orm/runtime/context.mjs.map +0 -1
  254. package/dist/orm/runtime/dialect/index.cjs +0 -11
  255. package/dist/orm/runtime/dialect/index.mjs +0 -13
  256. package/dist/orm/runtime/dialect/index.mjs.map +0 -1
  257. package/dist/orm/runtime/dialect/mysql.cjs +0 -95
  258. package/dist/orm/runtime/dialect/mysql.mjs +0 -97
  259. package/dist/orm/runtime/dialect/mysql.mjs.map +0 -1
  260. package/dist/orm/runtime/dialect/postgres.cjs +0 -51
  261. package/dist/orm/runtime/dialect/postgres.mjs +0 -53
  262. package/dist/orm/runtime/dialect/postgres.mjs.map +0 -1
  263. package/dist/orm/runtime/dialect/sqlite.cjs +0 -4
  264. package/dist/orm/runtime/dialect/sqlite.mjs +0 -7
  265. package/dist/orm/runtime/dialect/sqlite.mjs.map +0 -1
  266. package/dist/orm/runtime/errors.cjs +0 -19
  267. package/dist/orm/runtime/errors.mjs +0 -21
  268. package/dist/orm/runtime/errors.mjs.map +0 -1
  269. package/dist/orm/runtime/hydrate/many.cjs +0 -46
  270. package/dist/orm/runtime/hydrate/many.mjs +0 -48
  271. package/dist/orm/runtime/hydrate/many.mjs.map +0 -1
  272. package/dist/orm/runtime/hydrate/one.cjs +0 -38
  273. package/dist/orm/runtime/hydrate/one.mjs +0 -40
  274. package/dist/orm/runtime/hydrate/one.mjs.map +0 -1
  275. package/dist/orm/runtime/hydrate.cjs +0 -49
  276. package/dist/orm/runtime/hydrate.mjs +0 -51
  277. package/dist/orm/runtime/hydrate.mjs.map +0 -1
  278. package/dist/orm/runtime/rows.cjs +0 -30
  279. package/dist/orm/runtime/rows.mjs +0 -31
  280. package/dist/orm/runtime/rows.mjs.map +0 -1
  281. package/dist/orm/runtime/utils.cjs +0 -27
  282. package/dist/orm/runtime/utils.mjs +0 -27
  283. package/dist/orm/runtime/utils.mjs.map +0 -1
  284. package/dist/orm/sql/parse-array.cjs +0 -64
  285. package/dist/orm/sql/parse-array.mjs +0 -66
  286. package/dist/orm/sql/parse-array.mjs.map +0 -1
  287. package/dist/orm/sql/plan/select.cjs +0 -36
  288. package/dist/orm/sql/plan/select.mjs +0 -38
  289. package/dist/orm/sql/plan/select.mjs.map +0 -1
  290. package/dist/orm/sql/plan/where/operators.cjs +0 -95
  291. package/dist/orm/sql/plan/where/operators.mjs +0 -97
  292. package/dist/orm/sql/plan/where/operators.mjs.map +0 -1
  293. package/dist/orm/sql/plan/where.cjs +0 -59
  294. package/dist/orm/sql/plan/where.mjs +0 -61
  295. package/dist/orm/sql/plan/where.mjs.map +0 -1
  296. package/dist/orm/sql/serialize/clauses.cjs +0 -36
  297. package/dist/orm/sql/serialize/clauses.mjs +0 -37
  298. package/dist/orm/sql/serialize/clauses.mjs.map +0 -1
  299. package/dist/orm/sql/serialize/joins.cjs +0 -31
  300. package/dist/orm/sql/serialize/joins.mjs +0 -33
  301. package/dist/orm/sql/serialize/joins.mjs.map +0 -1
  302. package/dist/orm/sql/serialize/values.cjs +0 -30
  303. package/dist/orm/sql/serialize/values.mjs +0 -32
  304. package/dist/orm/sql/serialize/values.mjs.map +0 -1
  305. package/dist/orm/sql/serialize/where/predicate.cjs +0 -73
  306. package/dist/orm/sql/serialize/where/predicate.mjs +0 -75
  307. package/dist/orm/sql/serialize/where/predicate.mjs.map +0 -1
  308. package/dist/orm/sql/serialize/where/tree.cjs +0 -26
  309. package/dist/orm/sql/serialize/where/tree.mjs +0 -28
  310. package/dist/orm/sql/serialize/where/tree.mjs.map +0 -1
  311. package/dist/orm/sql/serialize/where.cjs +0 -10
  312. package/dist/orm/sql/serialize/where.mjs +0 -12
  313. package/dist/orm/sql/serialize/where.mjs.map +0 -1
  314. package/dist/orm/sql/serialize.cjs +0 -24
  315. package/dist/orm/sql/serialize.mjs +0 -25
  316. package/dist/orm/sql/serialize.mjs.map +0 -1
  317. package/dist/orm/table.cjs +0 -12
  318. package/dist/orm/table.d.cts +0 -12
  319. package/dist/orm/table.d.cts.map +0 -1
  320. package/dist/orm/table.d.mts +0 -12
  321. package/dist/orm/table.d.mts.map +0 -1
  322. package/dist/orm/table.mjs +0 -14
  323. package/dist/orm/table.mjs.map +0 -1
  324. package/dist/orm/types.d.cts +0 -183
  325. package/dist/orm/types.d.cts.map +0 -1
  326. package/dist/orm/types.d.mts +0 -183
  327. package/dist/orm/types.d.mts.map +0 -1
  328. package/dist/policy/helpers.cjs +0 -206
  329. package/dist/policy/helpers.d.cts +0 -50
  330. package/dist/policy/helpers.d.cts.map +0 -1
  331. package/dist/policy/helpers.d.mts +0 -50
  332. package/dist/policy/helpers.d.mts.map +0 -1
  333. package/dist/policy/helpers.mjs +0 -190
  334. package/dist/policy/helpers.mjs.map +0 -1
  335. package/dist/policy/types.d.cts +0 -16
  336. package/dist/policy/types.d.cts.map +0 -1
  337. package/dist/policy/types.d.mts +0 -16
  338. package/dist/policy/types.d.mts.map +0 -1
  339. package/dist/prompts/core/keys.cjs +0 -165
  340. package/dist/prompts/core/keys.mjs +0 -167
  341. package/dist/prompts/core/keys.mjs.map +0 -1
  342. package/dist/prompts/core/runtime.cjs +0 -104
  343. package/dist/prompts/core/runtime.mjs +0 -106
  344. package/dist/prompts/core/runtime.mjs.map +0 -1
  345. package/dist/prompts/core/session.cjs +0 -98
  346. package/dist/prompts/core/session.mjs +0 -100
  347. package/dist/prompts/core/session.mjs.map +0 -1
  348. package/dist/prompts/core/types.d.cts +0 -21
  349. package/dist/prompts/core/types.d.cts.map +0 -1
  350. package/dist/prompts/core/types.d.mts +0 -21
  351. package/dist/prompts/core/types.d.mts.map +0 -1
  352. package/dist/prompts/types.d.cts +0 -52
  353. package/dist/prompts/types.d.cts.map +0 -1
  354. package/dist/prompts/types.d.mts +0 -52
  355. package/dist/prompts/types.d.mts.map +0 -1
  356. package/dist/pubsub/types.d.cts +0 -10
  357. package/dist/pubsub/types.d.cts.map +0 -1
  358. package/dist/pubsub/types.d.mts +0 -10
  359. package/dist/pubsub/types.d.mts.map +0 -1
  360. package/dist/queue/types.d.cts +0 -47
  361. package/dist/queue/types.d.cts.map +0 -1
  362. package/dist/queue/types.d.mts +0 -47
  363. package/dist/queue/types.d.mts.map +0 -1
  364. package/dist/workflow/types.d.cts +0 -83
  365. package/dist/workflow/types.d.cts.map +0 -1
  366. package/dist/workflow/types.d.mts +0 -83
  367. package/dist/workflow/types.d.mts.map +0 -1
@@ -1,5 +1,191 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_helpers = require("../../policy/helpers.cjs");
2
+ //#region src/lib/policy/helpers.ts
3
+ const _brand = Symbol("conditionHelper");
4
+ const eq = (value) => {
5
+ const fn = (actual) => actual === value;
6
+ return {
7
+ [_brand]: fn,
8
+ operator: "eq",
9
+ value,
10
+ fn
11
+ };
12
+ };
13
+ const neq = (value) => {
14
+ const fn = (actual) => actual !== value;
15
+ return {
16
+ [_brand]: fn,
17
+ operator: "neq",
18
+ value,
19
+ fn
20
+ };
21
+ };
22
+ const gt = (value) => {
23
+ const fn = (actual) => actual > value;
24
+ return {
25
+ [_brand]: fn,
26
+ operator: "gt",
27
+ value,
28
+ fn
29
+ };
30
+ };
31
+ const gte = (value) => {
32
+ const fn = (actual) => actual >= value;
33
+ return {
34
+ [_brand]: fn,
35
+ operator: "gte",
36
+ value,
37
+ fn
38
+ };
39
+ };
40
+ const lt = (value) => {
41
+ const fn = (actual) => actual < value;
42
+ return {
43
+ [_brand]: fn,
44
+ operator: "lt",
45
+ value,
46
+ fn
47
+ };
48
+ };
49
+ const lte = (value) => {
50
+ const fn = (actual) => actual <= value;
51
+ return {
52
+ [_brand]: fn,
53
+ operator: "lte",
54
+ value,
55
+ fn
56
+ };
57
+ };
58
+ const not = (inner) => {
59
+ const fn = (actual) => !inner.fn(actual);
60
+ return {
61
+ [_brand]: fn,
62
+ operator: "not",
63
+ value: inner,
64
+ fn
65
+ };
66
+ };
67
+ const and = (...helpers) => {
68
+ const fn = (actual) => helpers.every((h) => h.fn(actual));
69
+ return {
70
+ [_brand]: fn,
71
+ operator: "and",
72
+ value: helpers,
73
+ fn
74
+ };
75
+ };
76
+ const or = (...helpers) => {
77
+ const fn = (actual) => helpers.some((h) => h.fn(actual));
78
+ return {
79
+ [_brand]: fn,
80
+ operator: "or",
81
+ value: helpers,
82
+ fn
83
+ };
84
+ };
85
+ const startsWith = (prefix) => {
86
+ const fn = (actual) => actual.startsWith(prefix);
87
+ return {
88
+ [_brand]: fn,
89
+ operator: "startsWith",
90
+ value: prefix,
91
+ fn
92
+ };
93
+ };
94
+ const endsWith = (suffix) => {
95
+ const fn = (actual) => actual.endsWith(suffix);
96
+ return {
97
+ [_brand]: fn,
98
+ operator: "endsWith",
99
+ value: suffix,
100
+ fn
101
+ };
102
+ };
103
+ const includes = (substring) => {
104
+ const fn = (actual) => actual.includes(substring);
105
+ return {
106
+ [_brand]: fn,
107
+ operator: "includes",
108
+ value: substring,
109
+ fn
110
+ };
111
+ };
112
+ const matches = (pattern) => {
113
+ const fn = (actual) => {
114
+ pattern.lastIndex = 0;
115
+ return pattern.test(actual);
116
+ };
117
+ return {
118
+ [_brand]: fn,
119
+ operator: "matches",
120
+ value: pattern,
121
+ fn
122
+ };
123
+ };
124
+ const has = (items) => {
125
+ const fn = (actual) => {
126
+ if (Array.isArray(items)) return items.every((item) => actual.includes(item));
127
+ return actual.includes(items);
128
+ };
129
+ return {
130
+ [_brand]: fn,
131
+ operator: "has",
132
+ value: items,
133
+ fn
134
+ };
135
+ };
136
+ const hasAny = (items) => {
137
+ const normalized = Array.isArray(items) ? items : [items];
138
+ const fn = (actual) => normalized.some((item) => actual.includes(item));
139
+ return {
140
+ [_brand]: fn,
141
+ operator: "hasAny",
142
+ value: items,
143
+ fn
144
+ };
145
+ };
146
+ const hasLength = (length) => {
147
+ const fn = (actual) => {
148
+ const len = actual.length;
149
+ if (typeof length === "number") return len === length;
150
+ if (length.min !== void 0 && len < length.min) return false;
151
+ if (length.max !== void 0 && len > length.max) return false;
152
+ return true;
153
+ };
154
+ return {
155
+ [_brand]: fn,
156
+ operator: "hasLength",
157
+ value: length,
158
+ fn
159
+ };
160
+ };
161
+ const isEmpty = () => {
162
+ const fn = (actual) => actual.length === 0;
163
+ return {
164
+ [_brand]: fn,
165
+ operator: "isEmpty",
166
+ value: void 0,
167
+ fn
168
+ };
169
+ };
170
+ const isDefined = () => {
171
+ const fn = (actual) => actual !== null && actual !== void 0;
172
+ return {
173
+ [_brand]: fn,
174
+ operator: "isDefined",
175
+ value: void 0,
176
+ fn
177
+ };
178
+ };
179
+ const isNullish = () => {
180
+ const fn = (actual) => actual === null || actual === void 0;
181
+ return {
182
+ [_brand]: fn,
183
+ operator: "isNullish",
184
+ value: void 0,
185
+ fn
186
+ };
187
+ };
188
+ //#endregion
3
189
  //#region src/lib/policy/index.ts
4
190
  var Policy = class {
5
191
  rules = [];
@@ -78,22 +264,22 @@ var Policy = class {
78
264
  };
79
265
  //#endregion
80
266
  exports.Policy = Policy;
81
- exports.and = require_helpers.and;
82
- exports.endsWith = require_helpers.endsWith;
83
- exports.eq = require_helpers.eq;
84
- exports.gt = require_helpers.gt;
85
- exports.gte = require_helpers.gte;
86
- exports.has = require_helpers.has;
87
- exports.hasAny = require_helpers.hasAny;
88
- exports.hasLength = require_helpers.hasLength;
89
- exports.includes = require_helpers.includes;
90
- exports.isDefined = require_helpers.isDefined;
91
- exports.isEmpty = require_helpers.isEmpty;
92
- exports.isNullish = require_helpers.isNullish;
93
- exports.lt = require_helpers.lt;
94
- exports.lte = require_helpers.lte;
95
- exports.matches = require_helpers.matches;
96
- exports.neq = require_helpers.neq;
97
- exports.not = require_helpers.not;
98
- exports.or = require_helpers.or;
99
- exports.startsWith = require_helpers.startsWith;
267
+ exports.and = and;
268
+ exports.endsWith = endsWith;
269
+ exports.eq = eq;
270
+ exports.gt = gt;
271
+ exports.gte = gte;
272
+ exports.has = has;
273
+ exports.hasAny = hasAny;
274
+ exports.hasLength = hasLength;
275
+ exports.includes = includes;
276
+ exports.isDefined = isDefined;
277
+ exports.isEmpty = isEmpty;
278
+ exports.isNullish = isNullish;
279
+ exports.lt = lt;
280
+ exports.lte = lte;
281
+ exports.matches = matches;
282
+ exports.neq = neq;
283
+ exports.not = not;
284
+ exports.or = or;
285
+ exports.startsWith = startsWith;
@@ -1,6 +1,63 @@
1
- import { ConditionHelper, and, endsWith, eq, gt, gte, has, hasAny, hasLength, includes, isDefined, isEmpty, isNullish, lt, lte, matches, neq, not, or, startsWith } from "../../policy/helpers.cjs";
2
- import { Action, AllowParams, ForbidParams } from "../../policy/types.cjs";
3
-
1
+ //#region src/lib/policy/helpers.d.ts
2
+ declare const _brand: unique symbol;
3
+ type ConditionHelper<V> = {
4
+ readonly [_brand]: (actual: V) => boolean;
5
+ operator: string;
6
+ value: unknown;
7
+ fn: (actual: V) => boolean;
8
+ };
9
+ declare const eq: <V>(value: V) => ConditionHelper<V>;
10
+ declare const neq: <V>(value: V) => ConditionHelper<V>;
11
+ declare const gt: {
12
+ (value: Date): ConditionHelper<Date>;
13
+ (value: number): ConditionHelper<number>;
14
+ (value: string): ConditionHelper<string>;
15
+ };
16
+ declare const gte: {
17
+ (value: Date): ConditionHelper<Date>;
18
+ (value: number): ConditionHelper<number>;
19
+ (value: string): ConditionHelper<string>;
20
+ };
21
+ declare const lt: {
22
+ (value: Date): ConditionHelper<Date>;
23
+ (value: number): ConditionHelper<number>;
24
+ (value: string): ConditionHelper<string>;
25
+ };
26
+ declare const lte: {
27
+ (value: Date): ConditionHelper<Date>;
28
+ (value: number): ConditionHelper<number>;
29
+ (value: string): ConditionHelper<string>;
30
+ };
31
+ declare const not: <V>(inner: ConditionHelper<V>) => ConditionHelper<V>;
32
+ declare const and: <V>(...helpers: ConditionHelper<V>[]) => ConditionHelper<V>;
33
+ declare const or: <V>(...helpers: ConditionHelper<V>[]) => ConditionHelper<V>;
34
+ declare const startsWith: (prefix: string) => ConditionHelper<string>;
35
+ declare const endsWith: (suffix: string) => ConditionHelper<string>;
36
+ declare const includes: (substring: string) => ConditionHelper<string>;
37
+ declare const matches: (pattern: RegExp) => ConditionHelper<string>;
38
+ declare const has: <V>(items: V | V[]) => ConditionHelper<V[]>;
39
+ declare const hasAny: <V>(items: V | V[]) => ConditionHelper<V[]>;
40
+ type HasLengthArg = number | {
41
+ min?: number;
42
+ max?: number;
43
+ };
44
+ declare const hasLength: (length: HasLengthArg) => ConditionHelper<string | unknown[]>;
45
+ declare const isEmpty: () => ConditionHelper<string | unknown[]>;
46
+ declare const isDefined: () => ConditionHelper<unknown>;
47
+ declare const isNullish: () => ConditionHelper<unknown>;
48
+ //#endregion
49
+ //#region src/lib/policy/types.d.ts
50
+ type Action = "read" | "create" | "update" | "delete" | (string & {});
51
+ type ConditionValue<V> = V extends Record<string, unknown> ? ConditionHelper<V> | Conditions<V> : ConditionHelper<V>;
52
+ type Conditions<T = Record<string, unknown>> = { [K in keyof T]?: ConditionValue<T[K]> };
53
+ type PolicyRuleParams<T = Record<string, unknown>> = {
54
+ action: Action | Action[];
55
+ conditions?: Conditions<T>;
56
+ reason?: string;
57
+ };
58
+ type AllowParams<T = Record<string, unknown>> = PolicyRuleParams<T>;
59
+ type ForbidParams<T = Record<string, unknown>> = PolicyRuleParams<T>;
60
+ //#endregion
4
61
  //#region src/lib/policy/index.d.ts
5
62
  declare class Policy<TEntity extends Record<string, unknown> = Record<string, unknown>> {
6
63
  private rules;
@@ -17,5 +74,4 @@ declare class Policy<TEntity extends Record<string, unknown> = Record<string, un
17
74
  private matchValue;
18
75
  }
19
76
  //#endregion
20
- export { type ConditionHelper, Policy, and, endsWith, eq, gt, gte, has, hasAny, hasLength, includes, isDefined, isEmpty, isNullish, lt, lte, matches, neq, not, or, startsWith };
21
- //# sourceMappingURL=index.d.cts.map
77
+ export { type ConditionHelper, Policy, and, endsWith, eq, gt, gte, has, hasAny, hasLength, includes, isDefined, isEmpty, isNullish, lt, lte, matches, neq, not, or, startsWith };
@@ -1,6 +1,63 @@
1
- import { ConditionHelper, and, endsWith, eq, gt, gte, has, hasAny, hasLength, includes, isDefined, isEmpty, isNullish, lt, lte, matches, neq, not, or, startsWith } from "../../policy/helpers.mjs";
2
- import { Action, AllowParams, ForbidParams } from "../../policy/types.mjs";
3
-
1
+ //#region src/lib/policy/helpers.d.ts
2
+ declare const _brand: unique symbol;
3
+ type ConditionHelper<V> = {
4
+ readonly [_brand]: (actual: V) => boolean;
5
+ operator: string;
6
+ value: unknown;
7
+ fn: (actual: V) => boolean;
8
+ };
9
+ declare const eq: <V>(value: V) => ConditionHelper<V>;
10
+ declare const neq: <V>(value: V) => ConditionHelper<V>;
11
+ declare const gt: {
12
+ (value: Date): ConditionHelper<Date>;
13
+ (value: number): ConditionHelper<number>;
14
+ (value: string): ConditionHelper<string>;
15
+ };
16
+ declare const gte: {
17
+ (value: Date): ConditionHelper<Date>;
18
+ (value: number): ConditionHelper<number>;
19
+ (value: string): ConditionHelper<string>;
20
+ };
21
+ declare const lt: {
22
+ (value: Date): ConditionHelper<Date>;
23
+ (value: number): ConditionHelper<number>;
24
+ (value: string): ConditionHelper<string>;
25
+ };
26
+ declare const lte: {
27
+ (value: Date): ConditionHelper<Date>;
28
+ (value: number): ConditionHelper<number>;
29
+ (value: string): ConditionHelper<string>;
30
+ };
31
+ declare const not: <V>(inner: ConditionHelper<V>) => ConditionHelper<V>;
32
+ declare const and: <V>(...helpers: ConditionHelper<V>[]) => ConditionHelper<V>;
33
+ declare const or: <V>(...helpers: ConditionHelper<V>[]) => ConditionHelper<V>;
34
+ declare const startsWith: (prefix: string) => ConditionHelper<string>;
35
+ declare const endsWith: (suffix: string) => ConditionHelper<string>;
36
+ declare const includes: (substring: string) => ConditionHelper<string>;
37
+ declare const matches: (pattern: RegExp) => ConditionHelper<string>;
38
+ declare const has: <V>(items: V | V[]) => ConditionHelper<V[]>;
39
+ declare const hasAny: <V>(items: V | V[]) => ConditionHelper<V[]>;
40
+ type HasLengthArg = number | {
41
+ min?: number;
42
+ max?: number;
43
+ };
44
+ declare const hasLength: (length: HasLengthArg) => ConditionHelper<string | unknown[]>;
45
+ declare const isEmpty: () => ConditionHelper<string | unknown[]>;
46
+ declare const isDefined: () => ConditionHelper<unknown>;
47
+ declare const isNullish: () => ConditionHelper<unknown>;
48
+ //#endregion
49
+ //#region src/lib/policy/types.d.ts
50
+ type Action = "read" | "create" | "update" | "delete" | (string & {});
51
+ type ConditionValue<V> = V extends Record<string, unknown> ? ConditionHelper<V> | Conditions<V> : ConditionHelper<V>;
52
+ type Conditions<T = Record<string, unknown>> = { [K in keyof T]?: ConditionValue<T[K]> };
53
+ type PolicyRuleParams<T = Record<string, unknown>> = {
54
+ action: Action | Action[];
55
+ conditions?: Conditions<T>;
56
+ reason?: string;
57
+ };
58
+ type AllowParams<T = Record<string, unknown>> = PolicyRuleParams<T>;
59
+ type ForbidParams<T = Record<string, unknown>> = PolicyRuleParams<T>;
60
+ //#endregion
4
61
  //#region src/lib/policy/index.d.ts
5
62
  declare class Policy<TEntity extends Record<string, unknown> = Record<string, unknown>> {
6
63
  private rules;
@@ -17,5 +74,4 @@ declare class Policy<TEntity extends Record<string, unknown> = Record<string, un
17
74
  private matchValue;
18
75
  }
19
76
  //#endregion
20
- export { type ConditionHelper, Policy, and, endsWith, eq, gt, gte, has, hasAny, hasLength, includes, isDefined, isEmpty, isNullish, lt, lte, matches, neq, not, or, startsWith };
21
- //# sourceMappingURL=index.d.mts.map
77
+ export { type ConditionHelper, Policy, and, endsWith, eq, gt, gte, has, hasAny, hasLength, includes, isDefined, isEmpty, isNullish, lt, lte, matches, neq, not, or, startsWith };
@@ -1,4 +1,190 @@
1
- import { and, endsWith, eq, gt, gte, has, hasAny, hasLength, includes, isDefined, isEmpty, isNullish, lt, lte, matches, neq, not, or, startsWith } from "../../policy/helpers.mjs";
1
+ //#region src/lib/policy/helpers.ts
2
+ const _brand = Symbol("conditionHelper");
3
+ const eq = (value) => {
4
+ const fn = (actual) => actual === value;
5
+ return {
6
+ [_brand]: fn,
7
+ operator: "eq",
8
+ value,
9
+ fn
10
+ };
11
+ };
12
+ const neq = (value) => {
13
+ const fn = (actual) => actual !== value;
14
+ return {
15
+ [_brand]: fn,
16
+ operator: "neq",
17
+ value,
18
+ fn
19
+ };
20
+ };
21
+ const gt = (value) => {
22
+ const fn = (actual) => actual > value;
23
+ return {
24
+ [_brand]: fn,
25
+ operator: "gt",
26
+ value,
27
+ fn
28
+ };
29
+ };
30
+ const gte = (value) => {
31
+ const fn = (actual) => actual >= value;
32
+ return {
33
+ [_brand]: fn,
34
+ operator: "gte",
35
+ value,
36
+ fn
37
+ };
38
+ };
39
+ const lt = (value) => {
40
+ const fn = (actual) => actual < value;
41
+ return {
42
+ [_brand]: fn,
43
+ operator: "lt",
44
+ value,
45
+ fn
46
+ };
47
+ };
48
+ const lte = (value) => {
49
+ const fn = (actual) => actual <= value;
50
+ return {
51
+ [_brand]: fn,
52
+ operator: "lte",
53
+ value,
54
+ fn
55
+ };
56
+ };
57
+ const not = (inner) => {
58
+ const fn = (actual) => !inner.fn(actual);
59
+ return {
60
+ [_brand]: fn,
61
+ operator: "not",
62
+ value: inner,
63
+ fn
64
+ };
65
+ };
66
+ const and = (...helpers) => {
67
+ const fn = (actual) => helpers.every((h) => h.fn(actual));
68
+ return {
69
+ [_brand]: fn,
70
+ operator: "and",
71
+ value: helpers,
72
+ fn
73
+ };
74
+ };
75
+ const or = (...helpers) => {
76
+ const fn = (actual) => helpers.some((h) => h.fn(actual));
77
+ return {
78
+ [_brand]: fn,
79
+ operator: "or",
80
+ value: helpers,
81
+ fn
82
+ };
83
+ };
84
+ const startsWith = (prefix) => {
85
+ const fn = (actual) => actual.startsWith(prefix);
86
+ return {
87
+ [_brand]: fn,
88
+ operator: "startsWith",
89
+ value: prefix,
90
+ fn
91
+ };
92
+ };
93
+ const endsWith = (suffix) => {
94
+ const fn = (actual) => actual.endsWith(suffix);
95
+ return {
96
+ [_brand]: fn,
97
+ operator: "endsWith",
98
+ value: suffix,
99
+ fn
100
+ };
101
+ };
102
+ const includes = (substring) => {
103
+ const fn = (actual) => actual.includes(substring);
104
+ return {
105
+ [_brand]: fn,
106
+ operator: "includes",
107
+ value: substring,
108
+ fn
109
+ };
110
+ };
111
+ const matches = (pattern) => {
112
+ const fn = (actual) => {
113
+ pattern.lastIndex = 0;
114
+ return pattern.test(actual);
115
+ };
116
+ return {
117
+ [_brand]: fn,
118
+ operator: "matches",
119
+ value: pattern,
120
+ fn
121
+ };
122
+ };
123
+ const has = (items) => {
124
+ const fn = (actual) => {
125
+ if (Array.isArray(items)) return items.every((item) => actual.includes(item));
126
+ return actual.includes(items);
127
+ };
128
+ return {
129
+ [_brand]: fn,
130
+ operator: "has",
131
+ value: items,
132
+ fn
133
+ };
134
+ };
135
+ const hasAny = (items) => {
136
+ const normalized = Array.isArray(items) ? items : [items];
137
+ const fn = (actual) => normalized.some((item) => actual.includes(item));
138
+ return {
139
+ [_brand]: fn,
140
+ operator: "hasAny",
141
+ value: items,
142
+ fn
143
+ };
144
+ };
145
+ const hasLength = (length) => {
146
+ const fn = (actual) => {
147
+ const len = actual.length;
148
+ if (typeof length === "number") return len === length;
149
+ if (length.min !== void 0 && len < length.min) return false;
150
+ if (length.max !== void 0 && len > length.max) return false;
151
+ return true;
152
+ };
153
+ return {
154
+ [_brand]: fn,
155
+ operator: "hasLength",
156
+ value: length,
157
+ fn
158
+ };
159
+ };
160
+ const isEmpty = () => {
161
+ const fn = (actual) => actual.length === 0;
162
+ return {
163
+ [_brand]: fn,
164
+ operator: "isEmpty",
165
+ value: void 0,
166
+ fn
167
+ };
168
+ };
169
+ const isDefined = () => {
170
+ const fn = (actual) => actual !== null && actual !== void 0;
171
+ return {
172
+ [_brand]: fn,
173
+ operator: "isDefined",
174
+ value: void 0,
175
+ fn
176
+ };
177
+ };
178
+ const isNullish = () => {
179
+ const fn = (actual) => actual === null || actual === void 0;
180
+ return {
181
+ [_brand]: fn,
182
+ operator: "isNullish",
183
+ value: void 0,
184
+ fn
185
+ };
186
+ };
187
+ //#endregion
2
188
  //#region src/lib/policy/index.ts
3
189
  var Policy = class {
4
190
  rules = [];
@@ -77,5 +263,3 @@ var Policy = class {
77
263
  };
78
264
  //#endregion
79
265
  export { Policy, and, endsWith, eq, gt, gte, has, hasAny, hasLength, includes, isDefined, isEmpty, isNullish, lt, lte, matches, neq, not, or, startsWith };
80
-
81
- //# sourceMappingURL=index.mjs.map