@shwfed/nuxt 0.7.8 → 0.7.9
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/module.json +1 -1
- package/dist/runtime/components/app.d.vue.ts +0 -2
- package/dist/runtime/components/app.vue +1 -7
- package/dist/runtime/components/app.vue.d.ts +0 -2
- package/dist/runtime/components/fields.d.vue.ts +155 -0
- package/dist/runtime/components/fields.vue +312 -0
- package/dist/runtime/components/fields.vue.d.ts +155 -0
- package/dist/runtime/components/ui/button-group/ButtonGroupSeparator.vue +1 -1
- package/dist/runtime/components/ui/button-group/ButtonGroupText.vue +1 -1
- package/dist/runtime/components/ui/calendar/Calendar.d.vue.ts +5 -12
- package/dist/runtime/components/ui/calendar/Calendar.vue +77 -92
- package/dist/runtime/components/ui/calendar/Calendar.vue.d.ts +5 -12
- package/dist/runtime/components/ui/calendar/CalendarCellTrigger.vue +1 -1
- package/dist/runtime/components/ui/calendar/index.d.ts +1 -1
- package/dist/runtime/components/ui/command/CommandGroup.vue +4 -0
- package/dist/runtime/components/ui/dialog/DialogOverlay.vue +1 -1
- package/dist/runtime/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +1 -1
- package/dist/runtime/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
- package/dist/runtime/components/ui/field/FieldDescription.vue +1 -1
- package/dist/runtime/components/ui/field/FieldError.vue +1 -1
- package/dist/runtime/components/ui/field/FieldLabel.vue +1 -1
- package/dist/runtime/components/ui/field/FieldSeparator.vue +1 -1
- package/dist/runtime/components/ui/field/index.js +7 -5
- package/dist/runtime/components/ui/input/Input.vue +1 -1
- package/dist/runtime/components/ui/input-group/InputGroup.vue +3 -0
- package/dist/runtime/components/ui/input-group/InputGroupCombobox.d.vue.ts +4 -1
- package/dist/runtime/components/ui/input-group/InputGroupCombobox.vue +10 -4
- package/dist/runtime/components/ui/input-group/InputGroupCombobox.vue.d.ts +4 -1
- package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.vue +3 -1
- package/dist/runtime/components/ui/input-group/InputGroupInput.vue +1 -1
- package/dist/runtime/components/ui/input-group/InputGroupNumberField.vue +1 -1
- package/dist/runtime/components/ui/input-group/InputGroupText.vue +1 -1
- package/dist/runtime/components/ui/input-group/InputGroupTextarea.vue +1 -1
- package/dist/runtime/components/ui/input-group/index.js +1 -1
- package/dist/runtime/components/ui/label/Label.vue +1 -1
- package/dist/runtime/components/ui/native-select/NativeSelect.vue +3 -3
- package/dist/runtime/components/ui/navigation-menu/NavigationMenuLink.vue +1 -1
- package/dist/runtime/components/ui/navigation-menu/NavigationMenuViewport.vue +1 -1
- package/dist/runtime/components/ui/range-calendar/RangeCalendarCell.vue +1 -1
- package/dist/runtime/components/ui/range-calendar/RangeCalendarCellTrigger.vue +1 -1
- package/dist/runtime/components/ui/sheet/SheetOverlay.vue +1 -1
- package/dist/runtime/components/ui/switch/Switch.d.vue.ts +24 -0
- package/dist/runtime/components/ui/switch/Switch.vue +46 -0
- package/dist/runtime/components/ui/switch/Switch.vue.d.ts +24 -0
- package/dist/runtime/components/ui/switch/index.d.ts +1 -0
- package/dist/runtime/components/ui/switch/index.js +1 -0
- package/dist/runtime/components/ui/textarea/Textarea.vue +1 -1
- package/dist/runtime/plugins/cel/env.d.ts +2 -2
- package/dist/runtime/plugins/cel/env.js +5 -4
- package/dist/runtime/plugins/cel/index.d.ts +3 -3
- package/dist/runtime/plugins/cel/index.js +7 -3
- package/dist/runtime/plugins/markdown/index.d.ts +1 -1
- package/dist/runtime/utils/coders.d.ts +7 -0
- package/dist/runtime/utils/coders.js +39 -0
- package/dist/runtime/vendor/cel/index.d.ts +17 -0
- package/dist/runtime/vendor/cel/index.js +10 -0
- package/dist/runtime/vendor/cel-js/LICENSE +21 -0
- package/dist/runtime/vendor/cel-js/UPSTREAM.md +17 -0
- package/dist/runtime/vendor/cel-js/lib/errors.d.ts +21 -0
- package/dist/runtime/vendor/cel-js/lib/errors.js +97 -0
- package/dist/runtime/vendor/cel-js/lib/evaluator.d.ts +4 -0
- package/dist/runtime/vendor/cel-js/lib/evaluator.js +192 -0
- package/dist/runtime/vendor/cel-js/lib/functions.d.ts +53 -0
- package/dist/runtime/vendor/cel-js/lib/functions.js +513 -0
- package/dist/runtime/vendor/cel-js/lib/globals.d.ts +27 -0
- package/dist/runtime/vendor/cel-js/lib/globals.js +33 -0
- package/dist/runtime/vendor/cel-js/lib/index.d.ts +469 -0
- package/dist/runtime/vendor/cel-js/lib/index.js +18 -0
- package/dist/runtime/vendor/cel-js/lib/macros.d.ts +1 -0
- package/dist/runtime/vendor/cel-js/lib/macros.js +230 -0
- package/dist/runtime/vendor/cel-js/lib/operators.d.ts +117 -0
- package/dist/runtime/vendor/cel-js/lib/operators.js +739 -0
- package/dist/runtime/vendor/cel-js/lib/optional.d.ts +14 -0
- package/dist/runtime/vendor/cel-js/lib/optional.js +161 -0
- package/dist/runtime/vendor/cel-js/lib/options.d.ts +23 -0
- package/dist/runtime/vendor/cel-js/lib/options.js +47 -0
- package/dist/runtime/vendor/cel-js/lib/overloads.d.ts +1 -0
- package/dist/runtime/vendor/cel-js/lib/overloads.js +214 -0
- package/dist/runtime/vendor/cel-js/lib/parser.d.ts +56 -0
- package/dist/runtime/vendor/cel-js/lib/parser.js +827 -0
- package/dist/runtime/vendor/cel-js/lib/registry.d.ts +279 -0
- package/dist/runtime/vendor/cel-js/lib/registry.js +1596 -0
- package/dist/runtime/vendor/cel-js/lib/serialize.d.ts +1 -0
- package/dist/runtime/vendor/cel-js/lib/serialize.js +259 -0
- package/dist/runtime/vendor/cel-js/lib/type-checker.d.ts +26 -0
- package/dist/runtime/vendor/cel-js/lib/type-checker.js +81 -0
- package/package.json +7 -4
- package/dist/runtime/components/locale.d.vue.ts +0 -14
- package/dist/runtime/components/locale.vue +0 -89
- package/dist/runtime/components/locale.vue.d.ts +0 -14
- package/dist/runtime/components/query.d.vue.ts +0 -30
- package/dist/runtime/components/query.vue +0 -266
- package/dist/runtime/components/query.vue.d.ts +0 -30
- package/dist/runtime/utilities/query-config/global.d.ts +0 -4
- package/dist/runtime/utilities/query-config/global.js +0 -18
- package/dist/runtime/utilities/query-config/index.d.ts +0 -3
- package/dist/runtime/utilities/query-config/index.js +0 -14
- package/dist/runtime/utilities/query-config/schema.d.ts +0 -96
- package/dist/runtime/utilities/query-config/schema.js +0 -51
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export class ParseError extends Error {
|
|
2
|
+
#node
|
|
3
|
+
constructor(message, node, cause) {
|
|
4
|
+
super(message, {cause})
|
|
5
|
+
this.name = 'ParseError'
|
|
6
|
+
this.#node = node
|
|
7
|
+
|
|
8
|
+
if (!node?.input) return
|
|
9
|
+
this.message = formatErrorWithHighlight(this.message, node)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get node() {
|
|
13
|
+
return this.#node
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
withAst(node) {
|
|
17
|
+
if (this.#node || !node?.input) return this
|
|
18
|
+
this.#node = node
|
|
19
|
+
this.message = formatErrorWithHighlight(this.message, node)
|
|
20
|
+
return this
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class EvaluationError extends Error {
|
|
25
|
+
#node
|
|
26
|
+
constructor(message, node, cause) {
|
|
27
|
+
super(message, {cause})
|
|
28
|
+
this.name = 'EvaluationError'
|
|
29
|
+
this.#node = node
|
|
30
|
+
|
|
31
|
+
if (!node?.input) return
|
|
32
|
+
this.message = formatErrorWithHighlight(this.message, node)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get node() {
|
|
36
|
+
return this.#node
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
withAst(node) {
|
|
40
|
+
if (this.#node || !node?.input) return this
|
|
41
|
+
this.#node = node
|
|
42
|
+
this.message = formatErrorWithHighlight(this.message, node)
|
|
43
|
+
return this
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class TypeError extends Error {
|
|
48
|
+
#node
|
|
49
|
+
constructor(message, node, cause) {
|
|
50
|
+
super(message, {cause})
|
|
51
|
+
this.name = 'TypeError'
|
|
52
|
+
this.#node = node
|
|
53
|
+
|
|
54
|
+
if (!node?.input) return
|
|
55
|
+
this.message = formatErrorWithHighlight(this.message, node)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get node() {
|
|
59
|
+
return this.#node
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
withAst(node) {
|
|
63
|
+
if (this.#node || !node?.input) return this
|
|
64
|
+
this.#node = node
|
|
65
|
+
this.message = formatErrorWithHighlight(this.message, node)
|
|
66
|
+
return this
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function formatErrorWithHighlight(message, node) {
|
|
71
|
+
if (node?.pos === undefined) return message
|
|
72
|
+
const pos = node.pos
|
|
73
|
+
const input = node.input
|
|
74
|
+
|
|
75
|
+
let lineNum = 1
|
|
76
|
+
let currentPos = 0
|
|
77
|
+
let columnNum = 0
|
|
78
|
+
while (currentPos < pos) {
|
|
79
|
+
if (input[currentPos] === '\n') {
|
|
80
|
+
lineNum++
|
|
81
|
+
columnNum = 0
|
|
82
|
+
} else {
|
|
83
|
+
columnNum++
|
|
84
|
+
}
|
|
85
|
+
currentPos++
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Show a few lines of context
|
|
89
|
+
let contextStart = pos
|
|
90
|
+
let contextEnd = pos
|
|
91
|
+
while (contextStart > 0 && input[contextStart - 1] !== '\n') contextStart--
|
|
92
|
+
while (contextEnd < input.length && input[contextEnd] !== '\n') contextEnd++
|
|
93
|
+
|
|
94
|
+
const line = input.slice(contextStart, contextEnd)
|
|
95
|
+
const highlight = `> ${`${lineNum}`.padStart(4, ' ')} | ${line}\n${' '.repeat(9 + columnNum)}^`
|
|
96
|
+
return `${message}\n\n${highlight}`
|
|
97
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import {createRegistry, RootContext} from './registry.js'
|
|
2
|
+
import {EvaluationError} from './errors.js'
|
|
3
|
+
import {registerFunctions, Duration, UnsignedInt} from './functions.js'
|
|
4
|
+
import {registerMacros} from './macros.js'
|
|
5
|
+
import {registerOverloads} from './overloads.js'
|
|
6
|
+
import {TypeChecker} from './type-checker.js'
|
|
7
|
+
import {Parser} from './parser.js'
|
|
8
|
+
import {createOptions} from './options.js'
|
|
9
|
+
import {Base} from './operators.js'
|
|
10
|
+
|
|
11
|
+
const globalRegistry = createRegistry({enableOptionalTypes: false})
|
|
12
|
+
registerFunctions(globalRegistry)
|
|
13
|
+
registerOverloads(globalRegistry)
|
|
14
|
+
registerMacros(globalRegistry)
|
|
15
|
+
|
|
16
|
+
class Environment {
|
|
17
|
+
#registry
|
|
18
|
+
#evaluator
|
|
19
|
+
#typeChecker
|
|
20
|
+
#evalTypeChecker
|
|
21
|
+
#parser
|
|
22
|
+
|
|
23
|
+
constructor(opts, inherited) {
|
|
24
|
+
this.opts = createOptions(opts, inherited?.opts)
|
|
25
|
+
this.#registry = (
|
|
26
|
+
inherited instanceof Environment ? inherited.#registry : globalRegistry
|
|
27
|
+
).clone(this.opts)
|
|
28
|
+
|
|
29
|
+
const childOpts = {registry: this.#registry, opts: this.opts}
|
|
30
|
+
this.#typeChecker = new TypeChecker(childOpts)
|
|
31
|
+
this.#evalTypeChecker = new TypeChecker(childOpts, true)
|
|
32
|
+
this.#evaluator = new Evaluator(childOpts)
|
|
33
|
+
this.#parser = new Parser(this.opts.limits, this.#registry)
|
|
34
|
+
Object.freeze(this)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
clone(opts) {
|
|
38
|
+
return new Environment(opts, this)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
registerFunction(signature, handler, opts) {
|
|
42
|
+
this.#registry.registerFunctionOverload(signature, handler, opts)
|
|
43
|
+
return this
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
registerOperator(string, handler, opts) {
|
|
47
|
+
this.#registry.registerOperatorOverload(string, handler, opts)
|
|
48
|
+
return this
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
registerType(typename, constructor) {
|
|
52
|
+
this.#registry.registerType(typename, constructor)
|
|
53
|
+
return this
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
registerVariable(name, type, opts) {
|
|
57
|
+
this.#registry.registerVariable(name, type, opts)
|
|
58
|
+
return this
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
registerConstant(name, type, value) {
|
|
62
|
+
this.#registry.registerConstant(name, type, value)
|
|
63
|
+
return this
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
hasVariable(name) {
|
|
67
|
+
return this.#registry.variables.has(name)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getDefinitions() {
|
|
71
|
+
return this.#registry.getDefinitions()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
check(expression) {
|
|
75
|
+
try {
|
|
76
|
+
return this.#checkAST(this.#parser.parse(expression))
|
|
77
|
+
} catch (e) {
|
|
78
|
+
return {valid: false, error: e}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
#checkAST(ast) {
|
|
83
|
+
try {
|
|
84
|
+
const typeDecl = this.#typeChecker.check(ast, new RootContext(this.#registry))
|
|
85
|
+
return {valid: true, type: this.#formatTypeForCheck(typeDecl)}
|
|
86
|
+
} catch (e) {
|
|
87
|
+
return {valid: false, error: e}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#formatTypeForCheck(typeDecl) {
|
|
92
|
+
if (typeDecl.name === `list<dyn>`) return 'list'
|
|
93
|
+
if (typeDecl.name === `map<dyn, dyn>`) return 'map'
|
|
94
|
+
return typeDecl.name
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
parse(expression) {
|
|
98
|
+
const ast = this.#parser.parse(expression)
|
|
99
|
+
const evaluateParsed = this.#evaluateAST.bind(this, ast)
|
|
100
|
+
evaluateParsed.check = this.#checkAST.bind(this, ast)
|
|
101
|
+
evaluateParsed.ast = ast
|
|
102
|
+
return evaluateParsed
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
evaluate(expression, context) {
|
|
106
|
+
return this.#evaluateAST(this.#parser.parse(expression), context)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
#evaluateAST(ast, ctx) {
|
|
110
|
+
ctx = new RootContext(this.#registry, ctx)
|
|
111
|
+
if (!ast.checkedType) this.#evalTypeChecker.check(ast, ctx)
|
|
112
|
+
return this.#evaluator.eval(ast, ctx)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
class Evaluator extends Base {
|
|
117
|
+
constructor(opts) {
|
|
118
|
+
super(opts)
|
|
119
|
+
this.Error = EvaluationError
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
#firstMapElement(coll) {
|
|
123
|
+
if (coll instanceof Map) return coll.entries().next().value
|
|
124
|
+
for (const key in coll) return [key, coll[key]]
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
debugRuntimeType(value, checkedType) {
|
|
128
|
+
return checkedType?.hasDynType === false ? checkedType : this.debugTypeDeep(value)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
debugTypeDeep(value) {
|
|
132
|
+
const runtimeType = this.debugType(value)
|
|
133
|
+
switch (runtimeType.kind) {
|
|
134
|
+
case 'list': {
|
|
135
|
+
const first = value instanceof Array ? value[0] : value.values().next().value
|
|
136
|
+
if (first === undefined) return runtimeType
|
|
137
|
+
return this.registry.getListType(this.debugTypeDeep(first))
|
|
138
|
+
}
|
|
139
|
+
case 'map': {
|
|
140
|
+
const first = this.#firstMapElement(value)
|
|
141
|
+
if (!first) return runtimeType
|
|
142
|
+
return this.registry.getMapType(
|
|
143
|
+
runtimeType.keyType.hasDynType ? this.debugTypeDeep(first[0]) : runtimeType.keyType,
|
|
144
|
+
runtimeType.valueType.hasDynType ? this.debugTypeDeep(first[1]) : runtimeType.valueType
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
default:
|
|
148
|
+
return runtimeType
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
tryEval(ast, ctx) {
|
|
153
|
+
try {
|
|
154
|
+
const res = this.eval(ast, ctx)
|
|
155
|
+
if (res instanceof Promise) return res.catch((err) => err)
|
|
156
|
+
return res
|
|
157
|
+
} catch (err) {
|
|
158
|
+
return err
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
eval(ast, ctx) {
|
|
163
|
+
return ast.evaluate(this, ast, ctx)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const globalEnvironment = new Environment({
|
|
168
|
+
unlistedVariablesAreDyn: true
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
export function parse(expression) {
|
|
172
|
+
return globalEnvironment.parse(expression)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function evaluate(expression, context) {
|
|
176
|
+
return globalEnvironment.evaluate(expression, context)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function check(expression) {
|
|
180
|
+
return globalEnvironment.check(expression)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export {Duration, UnsignedInt, Environment}
|
|
184
|
+
|
|
185
|
+
export default {
|
|
186
|
+
parse,
|
|
187
|
+
evaluate,
|
|
188
|
+
check,
|
|
189
|
+
Environment,
|
|
190
|
+
Duration,
|
|
191
|
+
UnsignedInt
|
|
192
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type {Registry} from './registry.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents an unsigned integer value in CEL.
|
|
5
|
+
* Used for uint type values.
|
|
6
|
+
*/
|
|
7
|
+
export class UnsignedInt {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new UnsignedInt.
|
|
10
|
+
* @param value - The unsigned integer value (as bigint or number)
|
|
11
|
+
* @throws Error if value is negative or exceeds uint64 max
|
|
12
|
+
*/
|
|
13
|
+
constructor(value: bigint | number)
|
|
14
|
+
|
|
15
|
+
/** Get the bigint value. */
|
|
16
|
+
get value(): bigint
|
|
17
|
+
|
|
18
|
+
/** Convert to primitive bigint for operations. */
|
|
19
|
+
valueOf(): bigint
|
|
20
|
+
|
|
21
|
+
/** Convert to string representation. */
|
|
22
|
+
toString(): string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Represents a duration value in CEL.
|
|
27
|
+
* Used for google.protobuf.Duration type.
|
|
28
|
+
*/
|
|
29
|
+
export class Duration {
|
|
30
|
+
/**
|
|
31
|
+
* Create a new Duration.
|
|
32
|
+
* @param seconds - The number of seconds
|
|
33
|
+
* @param nanos - The number of nanoseconds (0-999999999)
|
|
34
|
+
*/
|
|
35
|
+
constructor(seconds: bigint | number, nanos?: number)
|
|
36
|
+
|
|
37
|
+
/** Get the seconds component. */
|
|
38
|
+
get seconds(): bigint
|
|
39
|
+
|
|
40
|
+
/** Get the nanoseconds component. */
|
|
41
|
+
get nanos(): number
|
|
42
|
+
|
|
43
|
+
/** Convert to primitive bigint (seconds only) for operations. */
|
|
44
|
+
valueOf(): bigint
|
|
45
|
+
|
|
46
|
+
/** Convert to string representation in format like "5s", "1h30m", etc. */
|
|
47
|
+
toString(): string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Register all built-in CEL functions on the provided registry instance.
|
|
52
|
+
*/
|
|
53
|
+
export function registerFunctions(registry: Registry): void
|