semola 0.5.0 → 0.5.2

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 (273) hide show
  1. package/README.md +75 -20
  2. package/dist/api/core/index.cjs +206 -0
  3. package/dist/api/core/index.d.cts +21 -0
  4. package/dist/api/core/index.d.cts.map +1 -0
  5. package/dist/api/core/index.d.mts +21 -0
  6. package/dist/api/core/index.d.mts.map +1 -0
  7. package/dist/api/core/index.mjs +208 -0
  8. package/dist/api/core/index.mjs.map +1 -0
  9. package/dist/api/core/types.d.cts +107 -0
  10. package/dist/api/core/types.d.cts.map +1 -0
  11. package/dist/api/core/types.d.mts +107 -0
  12. package/dist/api/core/types.d.mts.map +1 -0
  13. package/dist/api/middleware/index.cjs +8 -0
  14. package/dist/api/middleware/index.d.cts +11 -0
  15. package/dist/api/middleware/index.d.cts.map +1 -0
  16. package/dist/api/middleware/index.d.mts +11 -0
  17. package/dist/api/middleware/index.d.mts.map +1 -0
  18. package/dist/api/middleware/index.mjs +10 -0
  19. package/dist/api/middleware/index.mjs.map +1 -0
  20. package/dist/api/middleware/types.d.cts +16 -0
  21. package/dist/api/middleware/types.d.cts.map +1 -0
  22. package/dist/api/middleware/types.d.mts +16 -0
  23. package/dist/api/middleware/types.d.mts.map +1 -0
  24. package/dist/api/openapi/index.cjs +254 -0
  25. package/dist/api/openapi/index.mjs +256 -0
  26. package/dist/api/openapi/index.mjs.map +1 -0
  27. package/dist/api/openapi/types.d.cts +60 -0
  28. package/dist/api/openapi/types.d.cts.map +1 -0
  29. package/dist/api/openapi/types.d.mts +60 -0
  30. package/dist/api/openapi/types.d.mts.map +1 -0
  31. package/dist/api/validation/index.cjs +64 -0
  32. package/dist/api/validation/index.mjs +61 -0
  33. package/dist/api/validation/index.mjs.map +1 -0
  34. package/dist/cache/types.d.cts +17 -0
  35. package/dist/cache/types.d.cts.map +1 -0
  36. package/dist/cache/types.d.mts +17 -0
  37. package/dist/cache/types.d.mts.map +1 -0
  38. package/dist/cron/scanner.cjs +237 -0
  39. package/dist/cron/scanner.mjs +238 -0
  40. package/dist/cron/scanner.mjs.map +1 -0
  41. package/dist/cron/types.d.cts +11 -0
  42. package/dist/cron/types.d.cts.map +1 -0
  43. package/dist/cron/types.d.mts +11 -0
  44. package/dist/cron/types.d.mts.map +1 -0
  45. package/dist/errors/types.d.cts +5 -0
  46. package/dist/errors/types.d.cts.map +1 -0
  47. package/dist/errors/types.d.mts +5 -0
  48. package/dist/errors/types.d.mts.map +1 -0
  49. package/dist/i18n/types.d.cts +13 -0
  50. package/dist/i18n/types.d.cts.map +1 -0
  51. package/dist/i18n/types.d.mts +13 -0
  52. package/dist/i18n/types.d.mts.map +1 -0
  53. package/dist/lib/api/index.cjs +5 -0
  54. package/dist/lib/api/index.d.cts +5 -0
  55. package/dist/lib/api/index.d.mts +5 -0
  56. package/dist/lib/api/index.mjs +3 -0
  57. package/dist/lib/cache/index.cjs +74 -0
  58. package/dist/lib/cache/index.d.cts +36 -0
  59. package/dist/lib/cache/index.d.cts.map +1 -0
  60. package/dist/lib/cache/index.d.mts +36 -0
  61. package/dist/lib/cache/index.d.mts.map +1 -0
  62. package/dist/lib/cache/index.mjs +75 -0
  63. package/dist/lib/cache/index.mjs.map +1 -0
  64. package/dist/lib/cron/index.cjs +276 -0
  65. package/dist/lib/cron/index.d.cts +39 -0
  66. package/dist/lib/cron/index.d.cts.map +1 -0
  67. package/dist/lib/cron/index.d.mts +39 -0
  68. package/dist/lib/cron/index.d.mts.map +1 -0
  69. package/dist/lib/cron/index.mjs +277 -0
  70. package/dist/lib/cron/index.mjs.map +1 -0
  71. package/dist/lib/errors/index.cjs +30 -0
  72. package/dist/lib/errors/index.d.cts +13 -0
  73. package/dist/lib/errors/index.d.cts.map +1 -0
  74. package/dist/lib/errors/index.d.mts +13 -0
  75. package/dist/lib/errors/index.d.mts.map +1 -0
  76. package/dist/lib/errors/index.mjs +28 -0
  77. package/dist/lib/errors/index.mjs.map +1 -0
  78. package/dist/lib/i18n/index.cjs +37 -0
  79. package/dist/lib/i18n/index.d.cts +20 -0
  80. package/dist/lib/i18n/index.d.cts.map +1 -0
  81. package/dist/lib/i18n/index.d.mts +20 -0
  82. package/dist/lib/i18n/index.d.mts.map +1 -0
  83. package/dist/lib/i18n/index.mjs +38 -0
  84. package/dist/lib/i18n/index.mjs.map +1 -0
  85. package/dist/lib/policy/index.cjs +99 -0
  86. package/dist/lib/policy/index.d.cts +21 -0
  87. package/dist/lib/policy/index.d.cts.map +1 -0
  88. package/dist/lib/policy/index.d.mts +21 -0
  89. package/dist/lib/policy/index.d.mts.map +1 -0
  90. package/dist/lib/policy/index.mjs +81 -0
  91. package/dist/lib/policy/index.mjs.map +1 -0
  92. package/dist/lib/prompts/index.cjs +409 -0
  93. package/dist/lib/prompts/index.d.cts +31 -0
  94. package/dist/lib/prompts/index.d.cts.map +1 -0
  95. package/dist/lib/prompts/index.d.mts +31 -0
  96. package/dist/lib/prompts/index.d.mts.map +1 -0
  97. package/dist/lib/prompts/index.mjs +405 -0
  98. package/dist/lib/prompts/index.mjs.map +1 -0
  99. package/dist/lib/pubsub/index.cjs +48 -0
  100. package/dist/lib/pubsub/index.d.cts +27 -0
  101. package/dist/lib/pubsub/index.d.cts.map +1 -0
  102. package/dist/lib/pubsub/index.d.mts +27 -0
  103. package/dist/lib/pubsub/index.d.mts.map +1 -0
  104. package/dist/lib/pubsub/index.mjs +49 -0
  105. package/dist/lib/pubsub/index.mjs.map +1 -0
  106. package/dist/lib/queue/index.cjs +182 -0
  107. package/dist/lib/queue/index.d.cts +32 -0
  108. package/dist/lib/queue/index.d.cts.map +1 -0
  109. package/dist/lib/queue/index.d.mts +32 -0
  110. package/dist/lib/queue/index.d.mts.map +1 -0
  111. package/dist/lib/queue/index.mjs +183 -0
  112. package/dist/lib/queue/index.mjs.map +1 -0
  113. package/dist/node_modules/@standard-schema/spec/dist/index.d.cts +80 -0
  114. package/dist/node_modules/@standard-schema/spec/dist/index.d.cts.map +1 -0
  115. package/dist/node_modules/@standard-schema/spec/dist/index.d.mts +80 -0
  116. package/dist/node_modules/@standard-schema/spec/dist/index.d.mts.map +1 -0
  117. package/dist/policy/helpers.cjs +206 -0
  118. package/dist/policy/helpers.d.cts +50 -0
  119. package/dist/policy/helpers.d.cts.map +1 -0
  120. package/dist/policy/helpers.d.mts +50 -0
  121. package/dist/policy/helpers.d.mts.map +1 -0
  122. package/dist/policy/helpers.mjs +190 -0
  123. package/dist/policy/helpers.mjs.map +1 -0
  124. package/dist/policy/types.d.cts +16 -0
  125. package/dist/policy/types.d.cts.map +1 -0
  126. package/dist/policy/types.d.mts +16 -0
  127. package/dist/policy/types.d.mts.map +1 -0
  128. package/dist/prompts/core/keys.cjs +165 -0
  129. package/dist/prompts/core/keys.mjs +167 -0
  130. package/dist/prompts/core/keys.mjs.map +1 -0
  131. package/dist/prompts/core/runtime.cjs +104 -0
  132. package/dist/prompts/core/runtime.mjs +106 -0
  133. package/dist/prompts/core/runtime.mjs.map +1 -0
  134. package/dist/prompts/core/session.cjs +98 -0
  135. package/dist/prompts/core/session.mjs +100 -0
  136. package/dist/prompts/core/session.mjs.map +1 -0
  137. package/dist/prompts/core/types.d.cts +21 -0
  138. package/dist/prompts/core/types.d.cts.map +1 -0
  139. package/dist/prompts/core/types.d.mts +21 -0
  140. package/dist/prompts/core/types.d.mts.map +1 -0
  141. package/dist/prompts/types.d.cts +52 -0
  142. package/dist/prompts/types.d.cts.map +1 -0
  143. package/dist/prompts/types.d.mts +52 -0
  144. package/dist/prompts/types.d.mts.map +1 -0
  145. package/dist/pubsub/types.d.cts +10 -0
  146. package/dist/pubsub/types.d.cts.map +1 -0
  147. package/dist/pubsub/types.d.mts +10 -0
  148. package/dist/pubsub/types.d.mts.map +1 -0
  149. package/dist/queue/types.d.cts +47 -0
  150. package/dist/queue/types.d.cts.map +1 -0
  151. package/dist/queue/types.d.mts +47 -0
  152. package/dist/queue/types.d.mts.map +1 -0
  153. package/package.json +86 -16
  154. package/dist/lib/api/core/index.d.ts +0 -15
  155. package/dist/lib/api/core/index.d.ts.map +0 -1
  156. package/dist/lib/api/core/index.js +0 -166
  157. package/dist/lib/api/core/index.js.map +0 -1
  158. package/dist/lib/api/core/index.test.d.ts +0 -2
  159. package/dist/lib/api/core/index.test.d.ts.map +0 -1
  160. package/dist/lib/api/core/index.test.js +0 -219
  161. package/dist/lib/api/core/index.test.js.map +0 -1
  162. package/dist/lib/api/core/types.d.ts +0 -102
  163. package/dist/lib/api/core/types.d.ts.map +0 -1
  164. package/dist/lib/api/core/types.js +0 -2
  165. package/dist/lib/api/core/types.js.map +0 -1
  166. package/dist/lib/api/index.d.ts +0 -5
  167. package/dist/lib/api/index.d.ts.map +0 -1
  168. package/dist/lib/api/index.js +0 -3
  169. package/dist/lib/api/index.js.map +0 -1
  170. package/dist/lib/api/middleware/index.d.ts +0 -7
  171. package/dist/lib/api/middleware/index.d.ts.map +0 -1
  172. package/dist/lib/api/middleware/index.js +0 -7
  173. package/dist/lib/api/middleware/index.js.map +0 -1
  174. package/dist/lib/api/middleware/index.test.d.ts +0 -2
  175. package/dist/lib/api/middleware/index.test.d.ts.map +0 -1
  176. package/dist/lib/api/middleware/index.test.js +0 -67
  177. package/dist/lib/api/middleware/index.test.js.map +0 -1
  178. package/dist/lib/api/middleware/types.d.ts +0 -12
  179. package/dist/lib/api/middleware/types.d.ts.map +0 -1
  180. package/dist/lib/api/middleware/types.js +0 -2
  181. package/dist/lib/api/middleware/types.js.map +0 -1
  182. package/dist/lib/api/openapi/index.d.ts +0 -31
  183. package/dist/lib/api/openapi/index.d.ts.map +0 -1
  184. package/dist/lib/api/openapi/index.js +0 -328
  185. package/dist/lib/api/openapi/index.js.map +0 -1
  186. package/dist/lib/api/openapi/index.test.d.ts +0 -2
  187. package/dist/lib/api/openapi/index.test.d.ts.map +0 -1
  188. package/dist/lib/api/openapi/index.test.js +0 -359
  189. package/dist/lib/api/openapi/index.test.js.map +0 -1
  190. package/dist/lib/api/openapi/types.d.ts +0 -57
  191. package/dist/lib/api/openapi/types.d.ts.map +0 -1
  192. package/dist/lib/api/openapi/types.js +0 -5
  193. package/dist/lib/api/openapi/types.js.map +0 -1
  194. package/dist/lib/api/validation/index.d.ts +0 -33
  195. package/dist/lib/api/validation/index.d.ts.map +0 -1
  196. package/dist/lib/api/validation/index.js +0 -81
  197. package/dist/lib/api/validation/index.js.map +0 -1
  198. package/dist/lib/api/validation/index.test.d.ts +0 -2
  199. package/dist/lib/api/validation/index.test.d.ts.map +0 -1
  200. package/dist/lib/api/validation/index.test.js +0 -135
  201. package/dist/lib/api/validation/index.test.js.map +0 -1
  202. package/dist/lib/cache/index.d.ts +0 -25
  203. package/dist/lib/cache/index.d.ts.map +0 -1
  204. package/dist/lib/cache/index.js +0 -62
  205. package/dist/lib/cache/index.js.map +0 -1
  206. package/dist/lib/cache/index.test.d.ts +0 -2
  207. package/dist/lib/cache/index.test.d.ts.map +0 -1
  208. package/dist/lib/cache/index.test.js +0 -314
  209. package/dist/lib/cache/index.test.js.map +0 -1
  210. package/dist/lib/cache/types.d.ts +0 -5
  211. package/dist/lib/cache/types.d.ts.map +0 -1
  212. package/dist/lib/cache/types.js +0 -2
  213. package/dist/lib/cache/types.js.map +0 -1
  214. package/dist/lib/errors/index.d.ts +0 -9
  215. package/dist/lib/errors/index.d.ts.map +0 -1
  216. package/dist/lib/errors/index.js +0 -25
  217. package/dist/lib/errors/index.js.map +0 -1
  218. package/dist/lib/errors/index.test.d.ts +0 -2
  219. package/dist/lib/errors/index.test.d.ts.map +0 -1
  220. package/dist/lib/errors/index.test.js +0 -197
  221. package/dist/lib/errors/index.test.js.map +0 -1
  222. package/dist/lib/errors/types.d.ts +0 -2
  223. package/dist/lib/errors/types.d.ts.map +0 -1
  224. package/dist/lib/errors/types.js +0 -2
  225. package/dist/lib/errors/types.js.map +0 -1
  226. package/dist/lib/i18n/index.d.ts +0 -18
  227. package/dist/lib/i18n/index.d.ts.map +0 -1
  228. package/dist/lib/i18n/index.js +0 -38
  229. package/dist/lib/i18n/index.js.map +0 -1
  230. package/dist/lib/i18n/index.test.d.ts +0 -2
  231. package/dist/lib/i18n/index.test.d.ts.map +0 -1
  232. package/dist/lib/i18n/index.test.js +0 -402
  233. package/dist/lib/i18n/index.test.js.map +0 -1
  234. package/dist/lib/i18n/types.d.ts +0 -15
  235. package/dist/lib/i18n/types.d.ts.map +0 -1
  236. package/dist/lib/i18n/types.js +0 -2
  237. package/dist/lib/i18n/types.js.map +0 -1
  238. package/dist/lib/policy/index.d.ts +0 -9
  239. package/dist/lib/policy/index.d.ts.map +0 -1
  240. package/dist/lib/policy/index.js +0 -51
  241. package/dist/lib/policy/index.js.map +0 -1
  242. package/dist/lib/policy/index.test.d.ts +0 -2
  243. package/dist/lib/policy/index.test.d.ts.map +0 -1
  244. package/dist/lib/policy/index.test.js +0 -328
  245. package/dist/lib/policy/index.test.js.map +0 -1
  246. package/dist/lib/policy/types.d.ts +0 -27
  247. package/dist/lib/policy/types.d.ts.map +0 -1
  248. package/dist/lib/policy/types.js +0 -2
  249. package/dist/lib/policy/types.js.map +0 -1
  250. package/dist/lib/pubsub/index.d.ts +0 -23
  251. package/dist/lib/pubsub/index.d.ts.map +0 -1
  252. package/dist/lib/pubsub/index.js +0 -55
  253. package/dist/lib/pubsub/index.js.map +0 -1
  254. package/dist/lib/pubsub/index.test.d.ts +0 -2
  255. package/dist/lib/pubsub/index.test.d.ts.map +0 -1
  256. package/dist/lib/pubsub/index.test.js +0 -550
  257. package/dist/lib/pubsub/index.test.js.map +0 -1
  258. package/dist/lib/pubsub/types.d.ts +0 -7
  259. package/dist/lib/pubsub/types.d.ts.map +0 -1
  260. package/dist/lib/pubsub/types.js +0 -2
  261. package/dist/lib/pubsub/types.js.map +0 -1
  262. package/dist/lib/queue/index.d.ts +0 -28
  263. package/dist/lib/queue/index.d.ts.map +0 -1
  264. package/dist/lib/queue/index.js +0 -211
  265. package/dist/lib/queue/index.js.map +0 -1
  266. package/dist/lib/queue/index.test.d.ts +0 -2
  267. package/dist/lib/queue/index.test.d.ts.map +0 -1
  268. package/dist/lib/queue/index.test.js +0 -740
  269. package/dist/lib/queue/index.test.js.map +0 -1
  270. package/dist/lib/queue/types.d.ts +0 -52
  271. package/dist/lib/queue/types.d.ts.map +0 -1
  272. package/dist/lib/queue/types.js +0 -2
  273. package/dist/lib/queue/types.js.map +0 -1
@@ -0,0 +1,80 @@
1
+ //#region node_modules/@standard-schema/spec/dist/index.d.ts
2
+ /** The Standard Typed interface. This is a base type extended by other specs. */
3
+ interface StandardTypedV1<Input = unknown, Output = Input> {
4
+ /** The Standard properties. */
5
+ readonly "~standard": StandardTypedV1.Props<Input, Output>;
6
+ }
7
+ declare namespace StandardTypedV1 {
8
+ /** The Standard Typed properties interface. */
9
+ interface Props<Input = unknown, Output = Input> {
10
+ /** The version number of the standard. */
11
+ readonly version: 1;
12
+ /** The vendor name of the schema library. */
13
+ readonly vendor: string;
14
+ /** Inferred types associated with the schema. */
15
+ readonly types?: Types<Input, Output> | undefined;
16
+ }
17
+ /** The Standard Typed types interface. */
18
+ interface Types<Input = unknown, Output = Input> {
19
+ /** The input type of the schema. */
20
+ readonly input: Input;
21
+ /** The output type of the schema. */
22
+ readonly output: Output;
23
+ }
24
+ /** Infers the input type of a Standard Typed. */
25
+ type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
26
+ /** Infers the output type of a Standard Typed. */
27
+ type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
28
+ }
29
+ /** The Standard Schema interface. */
30
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
31
+ /** The Standard Schema properties. */
32
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
33
+ }
34
+ declare namespace StandardSchemaV1 {
35
+ /** The Standard Schema properties interface. */
36
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
37
+ /** Validates unknown input values. */
38
+ readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
39
+ }
40
+ /** The result interface of the validate function. */
41
+ type Result<Output> = SuccessResult<Output> | FailureResult;
42
+ /** The result interface if validation succeeds. */
43
+ interface SuccessResult<Output> {
44
+ /** The typed output value. */
45
+ readonly value: Output;
46
+ /** A falsy value for `issues` indicates success. */
47
+ readonly issues?: undefined;
48
+ }
49
+ interface Options {
50
+ /** Explicit support for additional vendor-specific parameters, if needed. */
51
+ readonly libraryOptions?: Record<string, unknown> | undefined;
52
+ }
53
+ /** The result interface if validation fails. */
54
+ interface FailureResult {
55
+ /** The issues of failed validation. */
56
+ readonly issues: ReadonlyArray<Issue>;
57
+ }
58
+ /** The issue interface of the failure output. */
59
+ interface Issue {
60
+ /** The error message of the issue. */
61
+ readonly message: string;
62
+ /** The path of the issue, if any. */
63
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
64
+ }
65
+ /** The path segment interface of the issue. */
66
+ interface PathSegment {
67
+ /** The key representing a path segment. */
68
+ readonly key: PropertyKey;
69
+ }
70
+ /** The Standard types interface. */
71
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
72
+ /** Infers the input type of a Standard. */
73
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
74
+ /** Infers the output type of a Standard. */
75
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
76
+ }
77
+ /** The Standard JSON Schema interface. */
78
+ //#endregion
79
+ export { StandardSchemaV1 };
80
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":["StandardTypedV1","Input","Output","Props","Schema","Types","NonNullable","version","vendor","types","input","output","InferInput","InferOutput","StandardSchemaV1","Options","Result","Promise","SuccessResult","FailureResult","Record","Issue","ReadonlyArray","PropertyKey","PathSegment","validate","value","options","issues","libraryOptions","message","path","key","StandardJSONSchemaV1","Converter","Target","jsonSchema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A;EAhCbjB;EAAAA,UAkCvBgB,aAAAA;IAhCGX;IAAAA,SAkCAmB,KAAAA,EAAOxB,MAAAA;IA9BPO;IAAAA,SAgCAmB,MAAAA;EAAAA;EAAAA,UAEHb,OAAAA;IA/BAV;IAAAA,SAiCGwB,cAAAA,GAAiBT,MAAAA;EAAAA;EAjCYnB;EAAAA,UAoChCkB,aAAAA;IAlCUlB;IAAAA,SAoCP2B,MAAAA,EAAQN,aAAAA,CAAcD,KAAAA;EAAAA;EA/B9BT;EAAAA,UAkCKS,KAAAA;IAlCqBrB;IAAAA,SAoClB8B,OAAAA;IApCiD1B;IAAAA,SAsCjD2B,IAAAA,GAAOT,aAAAA,CAAcC,WAAAA,GAAcC,WAAAA;EAAAA;EApChBxB;EAAAA,UAuCtBwB,WAAAA;IAvCqDpB;IAAAA,SAyClD4B,GAAAA,EAAKT,WAAAA;EAAAA;EAtCZT;EAAAA,UAyCIT,KAAAA,2BAAgCJ,KAAAA,UAAeD,eAAAA,CAAgBK,KAAAA,CAAMJ,KAAAA,EAAOC,MAAAA;EAzCrCD;EAAAA,KA4C5CW,UAAAA,gBAA0BZ,eAAAA,IAAmBA,eAAAA,CAAgBY,UAAAA,CAAWR,MAAAA;EA1CzBF;EAAAA,KA4C/CW,WAAAA,gBAA2Bb,eAAAA,IAAmBA,eAAAA,CAAgBa,WAAAA,CAAYT,MAAAA;AAAAA"}
@@ -0,0 +1,206 @@
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
188
+ exports.and = and;
189
+ exports.endsWith = endsWith;
190
+ exports.eq = eq;
191
+ exports.gt = gt;
192
+ exports.gte = gte;
193
+ exports.has = has;
194
+ exports.hasAny = hasAny;
195
+ exports.hasLength = hasLength;
196
+ exports.includes = includes;
197
+ exports.isDefined = isDefined;
198
+ exports.isEmpty = isEmpty;
199
+ exports.isNullish = isNullish;
200
+ exports.lt = lt;
201
+ exports.lte = lte;
202
+ exports.matches = matches;
203
+ exports.neq = neq;
204
+ exports.not = not;
205
+ exports.or = or;
206
+ exports.startsWith = startsWith;
@@ -0,0 +1,50 @@
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
+ export { ConditionHelper, and, endsWith, eq, gt, gte, has, hasAny, hasLength, includes, isDefined, isEmpty, isNullish, lt, lte, matches, neq, not, or, startsWith };
50
+ //# sourceMappingURL=helpers.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.cts","names":[],"sources":["../../src/lib/policy/helpers.ts"],"mappings":";cAAM,MAAA;AAAA,KAEM,eAAA;EAAA,UACA,MAAA,IAAU,MAAA,EAAQ,CAAA;EAC5B,QAAA;EACA,KAAA;EACA,EAAA,GAAK,MAAA,EAAQ,CAAA;AAAA;AAAA,cAGF,EAAA,MAAS,KAAA,EAAO,CAAA,KAAI,eAAA,CAAgB,CAAA;AAAA,cAWpC,GAAA,MAAU,KAAA,EAAO,CAAA,KAAI,eAAA,CAAgB,CAAA;AAAA,cAWrC,EAAA;EAAA,CACV,KAAA,EAAO,IAAA,GAAO,eAAA,CAAgB,IAAA;EAAA,CAC9B,KAAA,WAAgB,eAAA;EAAA,CAChB,KAAA,WAAgB,eAAA;AAAA;AAAA,cAcN,GAAA;EAAA,CACV,KAAA,EAAO,IAAA,GAAO,eAAA,CAAgB,IAAA;EAAA,CAC9B,KAAA,WAAgB,eAAA;EAAA,CAChB,KAAA,WAAgB,eAAA;AAAA;AAAA,cAcN,EAAA;EAAA,CACV,KAAA,EAAO,IAAA,GAAO,eAAA,CAAgB,IAAA;EAAA,CAC9B,KAAA,WAAgB,eAAA;EAAA,CAChB,KAAA,WAAgB,eAAA;AAAA;AAAA,cAcN,GAAA;EAAA,CACV,KAAA,EAAO,IAAA,GAAO,eAAA,CAAgB,IAAA;EAAA,CAC9B,KAAA,WAAgB,eAAA;EAAA,CAChB,KAAA,WAAgB,eAAA;AAAA;AAAA,cAcN,GAAA,MAAU,KAAA,EAAO,eAAA,CAAgB,CAAA,MAAK,eAAA,CAAgB,CAAA;AAAA,cAWtD,GAAA,SACR,OAAA,EAAS,eAAA,CAAgB,CAAA,QAC3B,eAAA,CAAgB,CAAA;AAAA,cAWN,EAAA,SAAY,OAAA,EAAS,eAAA,CAAgB,CAAA,QAAO,eAAA,CAAgB,CAAA;AAAA,cAW5D,UAAA,GAAc,MAAA,aAAiB,eAAA;AAAA,cAW/B,QAAA,GAAY,MAAA,aAAiB,eAAA;AAAA,cAW7B,QAAA,GAAY,SAAA,aAAoB,eAAA;AAAA,cAWhC,OAAA,GAAW,OAAA,EAAS,MAAA,KAAS,eAAA;AAAA,cAe7B,GAAA,MAAU,KAAA,EAAO,CAAA,GAAI,CAAA,OAAM,eAAA,CAAgB,CAAA;AAAA,cAiB3C,MAAA,MAAa,KAAA,EAAO,CAAA,GAAI,CAAA,OAAM,eAAA,CAAgB,CAAA;AAAA,KAYtD,YAAA;EAA0B,GAAA;EAAc,GAAA;AAAA;AAAA,cAEhC,SAAA,GACX,MAAA,EAAQ,YAAA,KACP,eAAA;AAAA,cA2BU,OAAA,QAAc,eAAA;AAAA,cAWd,SAAA,QAAgB,eAAA;AAAA,cAWhB,SAAA,QAAgB,eAAA"}
@@ -0,0 +1,50 @@
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
+ export { ConditionHelper, and, endsWith, eq, gt, gte, has, hasAny, hasLength, includes, isDefined, isEmpty, isNullish, lt, lte, matches, neq, not, or, startsWith };
50
+ //# sourceMappingURL=helpers.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.mts","names":[],"sources":["../../src/lib/policy/helpers.ts"],"mappings":";cAAM,MAAA;AAAA,KAEM,eAAA;EAAA,UACA,MAAA,IAAU,MAAA,EAAQ,CAAA;EAC5B,QAAA;EACA,KAAA;EACA,EAAA,GAAK,MAAA,EAAQ,CAAA;AAAA;AAAA,cAGF,EAAA,MAAS,KAAA,EAAO,CAAA,KAAI,e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AAA,CAAgB,CAAA;AAAA,KAYtD,YAAA;EAA0B,GAAA;EAAc,GAAA;AAAA;AAAA,cAEhC,SAAA,GACX,MAAA,EAAQ,YAAA,KACP,eAAA;AAAA,cA2BU,OAAA,QAAc,eAAA;AAAA,cAWd,SAAA,QAAgB,eAAA;AAAA,cAWhB,SAAA,QAAgB,eAAA"}
@@ -0,0 +1,190 @@
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
188
+ export { and, endsWith, eq, gt, gte, has, hasAny, hasLength, includes, isDefined, isEmpty, isNullish, lt, lte, matches, neq, not, or, startsWith };
189
+
190
+ //# sourceMappingURL=helpers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.mjs","names":[],"sources":["../../src/lib/policy/helpers.ts"],"sourcesContent":["const _brand = Symbol(\"conditionHelper\");\n\nexport type ConditionHelper<V> = {\n readonly [_brand]: (actual: V) => boolean;\n operator: string;\n value: unknown;\n fn: (actual: V) => boolean;\n};\n\nexport const eq = <V>(value: V): ConditionHelper<V> => {\n const fn = (actual: V) => actual === value;\n\n return {\n [_brand]: fn,\n operator: \"eq\",\n value,\n fn,\n };\n};\n\nexport const neq = <V>(value: V): ConditionHelper<V> => {\n const fn = (actual: V) => actual !== value;\n\n return {\n [_brand]: fn,\n operator: \"neq\",\n value,\n fn,\n };\n};\n\nexport const gt: {\n (value: Date): ConditionHelper<Date>;\n (value: number): ConditionHelper<number>;\n (value: string): ConditionHelper<string>;\n} = (\n value: string | number | Date,\n): ConditionHelper<string | number | Date> => {\n const fn = (actual: string | number | Date) => actual > value;\n\n return {\n [_brand]: fn,\n operator: \"gt\",\n value,\n fn,\n };\n};\n\nexport const gte: {\n (value: Date): ConditionHelper<Date>;\n (value: number): ConditionHelper<number>;\n (value: string): ConditionHelper<string>;\n} = (\n value: string | number | Date,\n): ConditionHelper<string | number | Date> => {\n const fn = (actual: string | number | Date) => actual >= value;\n\n return {\n [_brand]: fn,\n operator: \"gte\",\n value,\n fn,\n };\n};\n\nexport const lt: {\n (value: Date): ConditionHelper<Date>;\n (value: number): ConditionHelper<number>;\n (value: string): ConditionHelper<string>;\n} = (\n value: string | number | Date,\n): ConditionHelper<string | number | Date> => {\n const fn = (actual: string | number | Date) => actual < value;\n\n return {\n [_brand]: fn,\n operator: \"lt\",\n value,\n fn,\n };\n};\n\nexport const lte: {\n (value: Date): ConditionHelper<Date>;\n (value: number): ConditionHelper<number>;\n (value: string): ConditionHelper<string>;\n} = (\n value: string | number | Date,\n): ConditionHelper<string | number | Date> => {\n const fn = (actual: string | number | Date) => actual <= value;\n\n return {\n [_brand]: fn,\n operator: \"lte\",\n value,\n fn,\n };\n};\n\nexport const not = <V>(inner: ConditionHelper<V>): ConditionHelper<V> => {\n const fn = (actual: V) => !inner.fn(actual);\n\n return {\n [_brand]: fn,\n operator: \"not\",\n value: inner,\n fn,\n };\n};\n\nexport const and = <V>(\n ...helpers: ConditionHelper<V>[]\n): ConditionHelper<V> => {\n const fn = (actual: V) => helpers.every((h) => h.fn(actual));\n\n return {\n [_brand]: fn,\n operator: \"and\",\n value: helpers,\n fn,\n };\n};\n\nexport const or = <V>(...helpers: ConditionHelper<V>[]): ConditionHelper<V> => {\n const fn = (actual: V) => helpers.some((h) => h.fn(actual));\n\n return {\n [_brand]: fn,\n operator: \"or\",\n value: helpers,\n fn,\n };\n};\n\nexport const startsWith = (prefix: string): ConditionHelper<string> => {\n const fn = (actual: string) => actual.startsWith(prefix);\n\n return {\n [_brand]: fn,\n operator: \"startsWith\",\n value: prefix,\n fn,\n };\n};\n\nexport const endsWith = (suffix: string): ConditionHelper<string> => {\n const fn = (actual: string) => actual.endsWith(suffix);\n\n return {\n [_brand]: fn,\n operator: \"endsWith\",\n value: suffix,\n fn,\n };\n};\n\nexport const includes = (substring: string): ConditionHelper<string> => {\n const fn = (actual: string) => actual.includes(substring);\n\n return {\n [_brand]: fn,\n operator: \"includes\",\n value: substring,\n fn,\n };\n};\n\nexport const matches = (pattern: RegExp): ConditionHelper<string> => {\n const fn = (actual: string) => {\n pattern.lastIndex = 0;\n\n return pattern.test(actual);\n };\n\n return {\n [_brand]: fn,\n operator: \"matches\",\n value: pattern,\n fn,\n };\n};\n\nexport const has = <V>(items: V | V[]): ConditionHelper<V[]> => {\n const fn = (actual: V[]) => {\n if (Array.isArray(items)) {\n return items.every((item) => actual.includes(item));\n }\n\n return actual.includes(items);\n };\n\n return {\n [_brand]: fn,\n operator: \"has\",\n value: items,\n fn,\n };\n};\n\nexport const hasAny = <V>(items: V | V[]): ConditionHelper<V[]> => {\n const normalized = Array.isArray(items) ? items : [items];\n const fn = (actual: V[]) => normalized.some((item) => actual.includes(item));\n\n return {\n [_brand]: fn,\n operator: \"hasAny\",\n value: items,\n fn,\n };\n};\n\ntype HasLengthArg = number | { min?: number; max?: number };\n\nexport const hasLength = (\n length: HasLengthArg,\n): ConditionHelper<string | unknown[]> => {\n const fn = (actual: string | unknown[]) => {\n const len = actual.length;\n\n if (typeof length === \"number\") {\n return len === length;\n }\n\n if (length.min !== undefined && len < length.min) {\n return false;\n }\n\n if (length.max !== undefined && len > length.max) {\n return false;\n }\n\n return true;\n };\n\n return {\n [_brand]: fn,\n operator: \"hasLength\",\n value: length,\n fn,\n };\n};\n\nexport const isEmpty = (): ConditionHelper<string | unknown[]> => {\n const fn = (actual: string | unknown[]) => actual.length === 0;\n\n return {\n [_brand]: fn,\n operator: \"isEmpty\",\n value: undefined,\n fn,\n };\n};\n\nexport const isDefined = (): ConditionHelper<unknown> => {\n const fn = (actual: unknown) => actual !== null && actual !== undefined;\n\n return {\n [_brand]: fn,\n operator: \"isDefined\",\n value: undefined,\n fn,\n };\n};\n\nexport const isNullish = (): ConditionHelper<unknown> => {\n const fn = (actual: unknown) => actual === null || actual === undefined;\n\n return {\n [_brand]: fn,\n operator: \"isNullish\",\n value: undefined,\n f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,MAAM,MAAM,WAA+B,OAAO,WAAW;AAE7D,QAAO;GACJ,SAAS;EACV,UAAU;EACV,OAAO,KAAA;EACP;EACD;;AAGH,MAAa,kBAA4C;CACvD,MAAM,MAAM,WAAoB,WAAW,QAAQ,WAAW,KAAA;AAE9D,QAAO;GACJ,SAAS;EACV,UAAU;EACV,OAAO,KAAA;EACP;EACD;;AAGH,MAAa,kBAA4C;CACvD,MAAM,MAAM,WAAoB,WAAW,QAAQ,WAAW,KAAA;AAE9D,QAAO;GACJ,SAAS;EACV,UAAU;EACV,OAAO,KAAA;EACP;EACD"}
@@ -0,0 +1,16 @@
1
+ import { ConditionHelper } from "./helpers.cjs";
2
+
3
+ //#region src/lib/policy/types.d.ts
4
+ type Action = "read" | "create" | "update" | "delete" | (string & {});
5
+ type ConditionValue<V> = V extends Record<string, unknown> ? ConditionHelper<V> | Conditions<V> : ConditionHelper<V>;
6
+ type Conditions<T = Record<string, unknown>> = { [K in keyof T]?: ConditionValue<T[K]> };
7
+ type PolicyRuleParams<T = Record<string, unknown>> = {
8
+ action: Action | Action[];
9
+ conditions?: Conditions<T>;
10
+ reason?: string;
11
+ };
12
+ type AllowParams<T = Record<string, unknown>> = PolicyRuleParams<T>;
13
+ type ForbidParams<T = Record<string, unknown>> = PolicyRuleParams<T>;
14
+ //#endregion
15
+ export { Action, AllowParams, ForbidParams };
16
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/lib/policy/types.ts"],"mappings":";;;KAEY,MAAA;AAAA,KAEA,cAAA,MACV,CAAA,SAAU,MAAA,oBACN,eAAA,CAAgB,CAAA,IAAK,UAAA,CAAW,CAAA,IAChC,eAAA,CAAgB,CAAA;AAAA,KAEV,UAAA,KAAe,MAAA,mCACb,CAAA,IAAK,cAAA,CAAe,CAAA,CAAE,CAAA;AAAA,KAU/B,gBAAA,KAAqB,MAAA;EACxB,MAAA,EAAQ,MAAA,GAAS,MAAA;EACjB,UAAA,GAAa,UAAA,CAAW,CAAA;EACxB,MAAA;AAAA;AAAA,KAGU,WAAA,KAAgB,MAAA,qBAA2B,gBAAA,CAAiB,CAAA;AAAA,KAE5D,YAAA,KAAiB,MAAA,qBAA2B,gBAAA,CAAiB,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { ConditionHelper } from "./helpers.mjs";
2
+
3
+ //#region src/lib/policy/types.d.ts
4
+ type Action = "read" | "create" | "update" | "delete" | (string & {});
5
+ type ConditionValue<V> = V extends Record<string, unknown> ? ConditionHelper<V> | Conditions<V> : ConditionHelper<V>;
6
+ type Conditions<T = Record<string, unknown>> = { [K in keyof T]?: ConditionValue<T[K]> };
7
+ type PolicyRuleParams<T = Record<string, unknown>> = {
8
+ action: Action | Action[];
9
+ conditions?: Conditions<T>;
10
+ reason?: string;
11
+ };
12
+ type AllowParams<T = Record<string, unknown>> = PolicyRuleParams<T>;
13
+ type ForbidParams<T = Record<string, unknown>> = PolicyRuleParams<T>;
14
+ //#endregion
15
+ export { Action, AllowParams, ForbidParams };
16
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../../src/lib/policy/types.ts"],"mappings":";;;KAEY,MAAA;AAAA,KAEA,cAAA,MACV,CAAA,SAAU,MAAA,oBACN,eAAA,CAAgB,CAAA,IAAK,UAAA,CAAW,CAAA,IAChC,eAAA,CAAgB,CAAA;AAAA,KAEV,UAAA,KAAe,MAAA,mCACb,CAAA,IAAK,cAAA,CAAe,CAAA,CAAE,CAAA;AAAA,KAU/B,gBAAA,KAAqB,MAAA;EACxB,MAAA,EAAQ,MAAA,GAAS,MAAA;EACjB,UAAA,GAAa,UAAA,CAAW,CAAA;EACxB,MAAA;AAAA;AAAA,KAGU,WAAA,KAAgB,MAAA,qBAA2B,gBAAA,CAAiB,CAAA;AAAA,KAE5D,YAAA,KAAiB,MAAA,qBAA2B,gBAAA,CAAiB,CAAA"}