semola 0.5.2 → 0.5.4

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 (160) hide show
  1. package/README.md +88 -13
  2. package/dist/index-BhGNDjPq.d.mts +13 -0
  3. package/dist/index-DxSbeGP-.d.cts +13 -0
  4. package/dist/lib/api/index.cjs +522 -4
  5. package/dist/lib/api/index.d.cts +270 -4
  6. package/dist/lib/api/index.d.mts +270 -4
  7. package/dist/lib/api/index.mjs +520 -2
  8. package/dist/lib/cache/index.d.cts +19 -7
  9. package/dist/lib/cache/index.d.mts +19 -7
  10. package/dist/lib/cache/index.mjs +0 -2
  11. package/dist/lib/cron/index.cjs +470 -11
  12. package/dist/lib/cron/index.d.cts +112 -5
  13. package/dist/lib/cron/index.d.mts +112 -5
  14. package/dist/lib/cron/index.mjs +461 -12
  15. package/dist/lib/errors/index.d.cts +2 -13
  16. package/dist/lib/errors/index.d.mts +2 -13
  17. package/dist/lib/errors/index.mjs +0 -2
  18. package/dist/lib/i18n/index.cjs +6 -1
  19. package/dist/lib/i18n/index.d.cts +12 -4
  20. package/dist/lib/i18n/index.d.mts +12 -4
  21. package/dist/lib/i18n/index.mjs +6 -3
  22. package/dist/lib/logging/index.cjs +387 -0
  23. package/dist/lib/logging/index.d.cts +108 -0
  24. package/dist/lib/logging/index.d.mts +108 -0
  25. package/dist/lib/logging/index.mjs +374 -0
  26. package/dist/lib/policy/index.cjs +206 -20
  27. package/dist/lib/policy/index.d.cts +61 -5
  28. package/dist/lib/policy/index.d.mts +61 -5
  29. package/dist/lib/policy/index.mjs +187 -3
  30. package/dist/lib/prompts/index.cjs +374 -14
  31. package/dist/lib/prompts/index.d.cts +77 -12
  32. package/dist/lib/prompts/index.d.mts +77 -12
  33. package/dist/lib/prompts/index.mjs +362 -4
  34. package/dist/lib/pubsub/index.cjs +82 -13
  35. package/dist/lib/pubsub/index.d.cts +23 -9
  36. package/dist/lib/pubsub/index.d.mts +23 -9
  37. package/dist/lib/pubsub/index.mjs +82 -15
  38. package/dist/lib/queue/index.d.cts +46 -4
  39. package/dist/lib/queue/index.d.mts +46 -4
  40. package/dist/lib/queue/index.mjs +0 -2
  41. package/dist/lib/workflow/index.cjs +534 -0
  42. package/dist/lib/workflow/index.d.cts +85 -0
  43. package/dist/lib/workflow/index.d.mts +85 -0
  44. package/dist/lib/workflow/index.mjs +533 -0
  45. package/package.json +29 -3
  46. package/dist/api/core/index.cjs +0 -206
  47. package/dist/api/core/index.d.cts +0 -21
  48. package/dist/api/core/index.d.cts.map +0 -1
  49. package/dist/api/core/index.d.mts +0 -21
  50. package/dist/api/core/index.d.mts.map +0 -1
  51. package/dist/api/core/index.mjs +0 -208
  52. package/dist/api/core/index.mjs.map +0 -1
  53. package/dist/api/core/types.d.cts +0 -107
  54. package/dist/api/core/types.d.cts.map +0 -1
  55. package/dist/api/core/types.d.mts +0 -107
  56. package/dist/api/core/types.d.mts.map +0 -1
  57. package/dist/api/middleware/index.cjs +0 -8
  58. package/dist/api/middleware/index.d.cts +0 -11
  59. package/dist/api/middleware/index.d.cts.map +0 -1
  60. package/dist/api/middleware/index.d.mts +0 -11
  61. package/dist/api/middleware/index.d.mts.map +0 -1
  62. package/dist/api/middleware/index.mjs +0 -10
  63. package/dist/api/middleware/index.mjs.map +0 -1
  64. package/dist/api/middleware/types.d.cts +0 -16
  65. package/dist/api/middleware/types.d.cts.map +0 -1
  66. package/dist/api/middleware/types.d.mts +0 -16
  67. package/dist/api/middleware/types.d.mts.map +0 -1
  68. package/dist/api/openapi/index.cjs +0 -254
  69. package/dist/api/openapi/index.mjs +0 -256
  70. package/dist/api/openapi/index.mjs.map +0 -1
  71. package/dist/api/openapi/types.d.cts +0 -60
  72. package/dist/api/openapi/types.d.cts.map +0 -1
  73. package/dist/api/openapi/types.d.mts +0 -60
  74. package/dist/api/openapi/types.d.mts.map +0 -1
  75. package/dist/api/validation/index.cjs +0 -64
  76. package/dist/api/validation/index.mjs +0 -61
  77. package/dist/api/validation/index.mjs.map +0 -1
  78. package/dist/cache/types.d.cts +0 -17
  79. package/dist/cache/types.d.cts.map +0 -1
  80. package/dist/cache/types.d.mts +0 -17
  81. package/dist/cache/types.d.mts.map +0 -1
  82. package/dist/cron/scanner.cjs +0 -237
  83. package/dist/cron/scanner.mjs +0 -238
  84. package/dist/cron/scanner.mjs.map +0 -1
  85. package/dist/cron/types.d.cts +0 -11
  86. package/dist/cron/types.d.cts.map +0 -1
  87. package/dist/cron/types.d.mts +0 -11
  88. package/dist/cron/types.d.mts.map +0 -1
  89. package/dist/errors/types.d.cts +0 -5
  90. package/dist/errors/types.d.cts.map +0 -1
  91. package/dist/errors/types.d.mts +0 -5
  92. package/dist/errors/types.d.mts.map +0 -1
  93. package/dist/i18n/types.d.cts +0 -13
  94. package/dist/i18n/types.d.cts.map +0 -1
  95. package/dist/i18n/types.d.mts +0 -13
  96. package/dist/i18n/types.d.mts.map +0 -1
  97. package/dist/lib/cache/index.d.cts.map +0 -1
  98. package/dist/lib/cache/index.d.mts.map +0 -1
  99. package/dist/lib/cache/index.mjs.map +0 -1
  100. package/dist/lib/cron/index.d.cts.map +0 -1
  101. package/dist/lib/cron/index.d.mts.map +0 -1
  102. package/dist/lib/cron/index.mjs.map +0 -1
  103. package/dist/lib/errors/index.d.cts.map +0 -1
  104. package/dist/lib/errors/index.d.mts.map +0 -1
  105. package/dist/lib/errors/index.mjs.map +0 -1
  106. package/dist/lib/i18n/index.d.cts.map +0 -1
  107. package/dist/lib/i18n/index.d.mts.map +0 -1
  108. package/dist/lib/i18n/index.mjs.map +0 -1
  109. package/dist/lib/policy/index.d.cts.map +0 -1
  110. package/dist/lib/policy/index.d.mts.map +0 -1
  111. package/dist/lib/policy/index.mjs.map +0 -1
  112. package/dist/lib/prompts/index.d.cts.map +0 -1
  113. package/dist/lib/prompts/index.d.mts.map +0 -1
  114. package/dist/lib/prompts/index.mjs.map +0 -1
  115. package/dist/lib/pubsub/index.d.cts.map +0 -1
  116. package/dist/lib/pubsub/index.d.mts.map +0 -1
  117. package/dist/lib/pubsub/index.mjs.map +0 -1
  118. package/dist/lib/queue/index.d.cts.map +0 -1
  119. package/dist/lib/queue/index.d.mts.map +0 -1
  120. package/dist/lib/queue/index.mjs.map +0 -1
  121. package/dist/node_modules/@standard-schema/spec/dist/index.d.cts +0 -80
  122. package/dist/node_modules/@standard-schema/spec/dist/index.d.cts.map +0 -1
  123. package/dist/node_modules/@standard-schema/spec/dist/index.d.mts +0 -80
  124. package/dist/node_modules/@standard-schema/spec/dist/index.d.mts.map +0 -1
  125. package/dist/policy/helpers.cjs +0 -206
  126. package/dist/policy/helpers.d.cts +0 -50
  127. package/dist/policy/helpers.d.cts.map +0 -1
  128. package/dist/policy/helpers.d.mts +0 -50
  129. package/dist/policy/helpers.d.mts.map +0 -1
  130. package/dist/policy/helpers.mjs +0 -190
  131. package/dist/policy/helpers.mjs.map +0 -1
  132. package/dist/policy/types.d.cts +0 -16
  133. package/dist/policy/types.d.cts.map +0 -1
  134. package/dist/policy/types.d.mts +0 -16
  135. package/dist/policy/types.d.mts.map +0 -1
  136. package/dist/prompts/core/keys.cjs +0 -165
  137. package/dist/prompts/core/keys.mjs +0 -167
  138. package/dist/prompts/core/keys.mjs.map +0 -1
  139. package/dist/prompts/core/runtime.cjs +0 -104
  140. package/dist/prompts/core/runtime.mjs +0 -106
  141. package/dist/prompts/core/runtime.mjs.map +0 -1
  142. package/dist/prompts/core/session.cjs +0 -98
  143. package/dist/prompts/core/session.mjs +0 -100
  144. package/dist/prompts/core/session.mjs.map +0 -1
  145. package/dist/prompts/core/types.d.cts +0 -21
  146. package/dist/prompts/core/types.d.cts.map +0 -1
  147. package/dist/prompts/core/types.d.mts +0 -21
  148. package/dist/prompts/core/types.d.mts.map +0 -1
  149. package/dist/prompts/types.d.cts +0 -52
  150. package/dist/prompts/types.d.cts.map +0 -1
  151. package/dist/prompts/types.d.mts +0 -52
  152. package/dist/prompts/types.d.mts.map +0 -1
  153. package/dist/pubsub/types.d.cts +0 -10
  154. package/dist/pubsub/types.d.cts.map +0 -1
  155. package/dist/pubsub/types.d.mts +0 -10
  156. package/dist/pubsub/types.d.mts.map +0 -1
  157. package/dist/queue/types.d.cts +0 -47
  158. package/dist/queue/types.d.cts.map +0 -1
  159. package/dist/queue/types.d.mts +0 -47
  160. package/dist/queue/types.d.mts.map +0 -1
@@ -1,206 +0,0 @@
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;
@@ -1,50 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,50 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.d.mts","names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,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"}
@@ -1,190 +0,0 @@
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
@@ -1 +0,0 @@
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 fn,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AAM,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"}
@@ -1,16 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,16 +0,0 @@
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
@@ -1 +0,0 @@
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"}