@seljs/env 1.0.0 → 1.0.1

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.
package/dist/builtins.js DELETED
@@ -1,307 +0,0 @@
1
- import { SOLIDITY_TYPES } from "@seljs/types";
2
- /**
3
- * Built-in CEL functions available in SEL expressions.
4
- * These functions are part of the CEL standard library.
5
- */
6
- export const CEL_BUILTIN_FUNCTIONS = [
7
- {
8
- name: "size",
9
- signature: "size(list|map|string|bytes): int",
10
- description: "Returns the size of a collection or string",
11
- params: [{ name: "value", type: "list|map|string|bytes" }],
12
- returns: "int",
13
- },
14
- {
15
- name: "size",
16
- signature: "string.size(): int",
17
- description: "Returns the length of the string",
18
- params: [],
19
- returns: "int",
20
- receiverType: "string",
21
- },
22
- {
23
- name: "size",
24
- signature: "list.size(): int",
25
- description: "Returns the number of elements in the list",
26
- params: [],
27
- returns: "int",
28
- receiverType: "list",
29
- },
30
- {
31
- name: "size",
32
- signature: "map.size(): int",
33
- description: "Returns the number of entries in the map",
34
- params: [],
35
- returns: "int",
36
- receiverType: "map",
37
- },
38
- {
39
- name: "size",
40
- signature: "bytes.size(): int",
41
- description: "Returns the number of bytes",
42
- params: [],
43
- returns: "int",
44
- receiverType: "bytes",
45
- },
46
- {
47
- name: "type",
48
- signature: "type(value): type",
49
- description: "Returns the type of a value",
50
- params: [{ name: "value", type: "any" }],
51
- returns: "type",
52
- },
53
- {
54
- name: "int",
55
- signature: "int(value): int",
56
- description: "Converts a value to an integer",
57
- params: [{ name: "value", type: "any" }],
58
- returns: "int",
59
- },
60
- {
61
- name: "uint",
62
- signature: "uint(value): uint",
63
- description: "Converts a value to an unsigned integer",
64
- params: [{ name: "value", type: "any" }],
65
- returns: "uint",
66
- },
67
- {
68
- name: "double",
69
- signature: "double(value): double",
70
- description: "Converts a value to a double",
71
- params: [{ name: "value", type: "any" }],
72
- returns: "double",
73
- },
74
- {
75
- name: "string",
76
- signature: "string(value): string",
77
- description: "Converts a value to a string",
78
- params: [{ name: "value", type: "any" }],
79
- returns: "string",
80
- },
81
- {
82
- name: "bytes",
83
- signature: "bytes(value): bytes",
84
- description: "Converts a value to bytes",
85
- params: [{ name: "value", type: "any" }],
86
- returns: "bytes",
87
- },
88
- {
89
- name: "dyn",
90
- signature: "dyn(value): dyn",
91
- description: "Converts a value to a dynamic type",
92
- params: [{ name: "value", type: "any" }],
93
- returns: "dyn",
94
- },
95
- {
96
- name: "bool",
97
- signature: "bool(value): bool",
98
- description: "Converts a value to a boolean",
99
- params: [{ name: "value", type: "string" }],
100
- returns: "bool",
101
- },
102
- {
103
- name: "solInt",
104
- signature: "solInt(string): sol_int",
105
- description: "Converts a string or int to a sol_int (arbitrary-precision integer)",
106
- params: [{ name: "value", type: "string|int" }],
107
- returns: "sol_int",
108
- },
109
- {
110
- name: "solAddress",
111
- signature: "solAddress(string): sol_address",
112
- description: "Converts a hex string to a sol_address type",
113
- params: [{ name: "value", type: "string" }],
114
- returns: "sol_address",
115
- },
116
- {
117
- name: "parseUnits",
118
- signature: "parseUnits(string|int|double|sol_int, int): sol_int",
119
- description: "Scales a human-readable value by 10^decimals, producing a sol_int. Mirrors viem/ethers parseUnits.",
120
- params: [
121
- { name: "value", type: "string|int|double|sol_int" },
122
- { name: "decimals", type: "int" },
123
- ],
124
- returns: "sol_int",
125
- },
126
- {
127
- name: "formatUnits",
128
- signature: "formatUnits(sol_int|int, int): double",
129
- description: "Scales a sol_int down by 10^decimals, producing a double for readable comparisons.",
130
- params: [
131
- { name: "value", type: "sol_int|int" },
132
- { name: "decimals", type: "int" },
133
- ],
134
- returns: "double",
135
- },
136
- {
137
- name: "min",
138
- signature: "min(sol_int|int, sol_int|int): sol_int",
139
- description: "Returns the smaller of two integer values",
140
- params: [
141
- { name: "a", type: "sol_int|int" },
142
- { name: "b", type: "sol_int|int" },
143
- ],
144
- returns: "sol_int",
145
- },
146
- {
147
- name: "max",
148
- signature: "max(sol_int|int, sol_int|int): sol_int",
149
- description: "Returns the larger of two integer values",
150
- params: [
151
- { name: "a", type: "sol_int|int" },
152
- { name: "b", type: "sol_int|int" },
153
- ],
154
- returns: "sol_int",
155
- },
156
- {
157
- name: "abs",
158
- signature: "abs(sol_int|int): sol_int",
159
- description: "Returns the absolute value of an integer",
160
- params: [{ name: "value", type: "sol_int|int" }],
161
- returns: "sol_int",
162
- },
163
- {
164
- name: "isZeroAddress",
165
- signature: "isZeroAddress(sol_address|string): bool",
166
- description: "Returns true if the address is the zero address (0x0000...0000)",
167
- params: [{ name: "address", type: "sol_address|string" }],
168
- returns: "bool",
169
- },
170
- {
171
- name: "timestamp",
172
- signature: "timestamp(string): timestamp",
173
- description: "Parses a timestamp string",
174
- params: [{ name: "value", type: "string" }],
175
- returns: "timestamp",
176
- },
177
- {
178
- name: "duration",
179
- signature: "duration(string): duration",
180
- description: "Parses a duration string",
181
- params: [{ name: "value", type: "string" }],
182
- returns: "duration",
183
- },
184
- {
185
- name: "matches",
186
- signature: "string.matches(pattern): bool",
187
- description: "Tests if a string matches a regex pattern",
188
- params: [{ name: "pattern", type: "string" }],
189
- returns: "bool",
190
- receiverType: "string",
191
- },
192
- {
193
- name: "contains",
194
- signature: "string.contains(substring): bool",
195
- description: "Tests if a string contains a substring",
196
- params: [{ name: "substring", type: "string" }],
197
- returns: "bool",
198
- receiverType: "string",
199
- },
200
- {
201
- name: "startsWith",
202
- signature: "string.startsWith(prefix): bool",
203
- description: "Tests if a string starts with a prefix",
204
- params: [{ name: "prefix", type: "string" }],
205
- returns: "bool",
206
- receiverType: "string",
207
- },
208
- {
209
- name: "endsWith",
210
- signature: "string.endsWith(suffix): bool",
211
- description: "Tests if a string ends with a suffix",
212
- params: [{ name: "suffix", type: "string" }],
213
- returns: "bool",
214
- receiverType: "string",
215
- },
216
- ];
217
- /**
218
- * Built-in CEL macros available in SEL expressions.
219
- * Macros are syntactic sugar that expand to function calls.
220
- */
221
- export const CEL_BUILTIN_MACROS = [
222
- {
223
- name: "all",
224
- pattern: "list.all(identifier, predicate)",
225
- description: "Returns true if all elements satisfy the predicate",
226
- example: "tokens.all(t, t.balance > 0)",
227
- },
228
- {
229
- name: "exists",
230
- pattern: "list.exists(identifier, predicate)",
231
- description: "Returns true if any element satisfies the predicate",
232
- example: "users.exists(u, u.isAdmin)",
233
- },
234
- {
235
- name: "exists_one",
236
- pattern: "list.exists_one(identifier, predicate)",
237
- description: "Returns true if exactly one element satisfies the predicate",
238
- example: "tokens.exists_one(t, t.id == 123)",
239
- },
240
- {
241
- name: "map",
242
- pattern: "list.map(identifier, transform)",
243
- description: "Transforms each element in the list",
244
- example: "tokens.map(t, t.balance)",
245
- },
246
- {
247
- name: "map",
248
- pattern: "list.map(identifier, predicate, transform)",
249
- description: "Transforms elements that satisfy the predicate",
250
- example: "tokens.map(t, t.balance > 0, t.balance)",
251
- },
252
- {
253
- name: "filter",
254
- pattern: "list.filter(identifier, predicate)",
255
- description: "Filters elements by predicate",
256
- example: "users.filter(u, u.age >= 18)",
257
- },
258
- {
259
- name: "has",
260
- pattern: "has(e.f)",
261
- description: "Tests if a field exists on an object",
262
- example: "has(user.email)",
263
- },
264
- {
265
- name: "cel.bind",
266
- pattern: "cel.bind(var, value, expr)",
267
- description: "Binds a variable for use in an expression",
268
- example: "cel.bind(x, user.balance, x > 1000)",
269
- },
270
- ];
271
- /**
272
- * Primitive types from Solidity available in SEL.
273
- * These are the basic type building blocks for the schema.
274
- */
275
- export const SOLIDITY_PRIMITIVE_TYPES = [
276
- // Solidity types from the registry (address, bytes)
277
- ...SOLIDITY_TYPES.map((it) => {
278
- /*
279
- * The registry contains both built-in and custom types.
280
- * We only want to include the custom types here, since the built-in types are already included as CEL primitives below.
281
- */
282
- if (it.type !== "custom") {
283
- return null;
284
- }
285
- return {
286
- name: it.name,
287
- kind: "primitive",
288
- description: it.schema.description,
289
- };
290
- }).filter((it) => it !== null),
291
- // CEL builtins presented as Solidity primitives for editor tooling
292
- {
293
- name: "bool",
294
- kind: "primitive",
295
- description: "Boolean value (true or false)",
296
- },
297
- {
298
- name: "string",
299
- kind: "primitive",
300
- description: "UTF-8 string",
301
- },
302
- {
303
- name: "bytes32",
304
- kind: "primitive",
305
- description: "32-byte fixed array",
306
- },
307
- ];
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from "./builder.js";
2
- export * from "./builtins.js";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from "./builder.js";
2
- export * from "./builtins.js";