Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- novas/novacore-zephyr/groq-code-cli/node_modules/acorn-walk/dist/walk.d.mts +177 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/acorn-walk/dist/walk.d.ts +177 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/acorn-walk/dist/walk.js +455 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/acorn-walk/dist/walk.mjs +437 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/acorn/bin/acorn +4 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/acorn/dist/acorn.d.mts +883 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/acorn/dist/acorn.d.ts +883 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/acorn/dist/acorn.js +0 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/acorn/dist/acorn.mjs +0 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/acorn/dist/bin.js +90 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/helpers.d.ts +15 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/helpers.d.ts.map +1 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/helpers.js +66 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/helpers.js.map +1 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/index.d.ts +41 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/index.d.ts.map +1 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/index.js +178 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/index.js.map +1 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/agentkeepalive/lib/agent.js +402 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/agentkeepalive/lib/constants.js +14 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/agentkeepalive/lib/https_agent.js +51 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/dist/ajv.bundle.js +0 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/dist/ajv.min.js +0 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/dist/ajv.min.js.map +0 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/ajv.d.ts +397 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/ajv.js +506 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/cache.js +26 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/async.js +90 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/equal.js +5 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/error_classes.js +34 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/formats.js +142 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/index.js +387 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/resolve.js +270 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/rules.js +66 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/schema_obj.js +9 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/ucs2length.js +20 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/util.js +239 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/data.js +49 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/definition_schema.js +37 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/_limit.jst +113 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/_limitItems.jst +12 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/_limitLength.jst +12 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/_limitProperties.jst +12 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/allOf.jst +32 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/anyOf.jst +46 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/coerce.def +51 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/comment.jst +9 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/const.jst +11 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/contains.jst +55 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/custom.jst +191 -0
novas/novacore-zephyr/groq-code-cli/node_modules/acorn-walk/dist/walk.d.mts
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as acorn from "acorn"
|
| 2 |
+
|
| 3 |
+
export type FullWalkerCallback<TState> = (
|
| 4 |
+
node: acorn.Node,
|
| 5 |
+
state: TState,
|
| 6 |
+
type: string
|
| 7 |
+
) => void
|
| 8 |
+
|
| 9 |
+
export type FullAncestorWalkerCallback<TState> = (
|
| 10 |
+
node: acorn.Node,
|
| 11 |
+
state: TState,
|
| 12 |
+
ancestors: acorn.Node[],
|
| 13 |
+
type: string
|
| 14 |
+
) => void
|
| 15 |
+
|
| 16 |
+
type AggregateType = {
|
| 17 |
+
Expression: acorn.Expression,
|
| 18 |
+
Statement: acorn.Statement,
|
| 19 |
+
Function: acorn.Function,
|
| 20 |
+
Class: acorn.Class,
|
| 21 |
+
Pattern: acorn.Pattern,
|
| 22 |
+
ForInit: acorn.VariableDeclaration | acorn.Expression
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
export type SimpleVisitors<TState> = {
|
| 26 |
+
[type in acorn.AnyNode["type"]]?: (node: Extract<acorn.AnyNode, { type: type }>, state: TState) => void
|
| 27 |
+
} & {
|
| 28 |
+
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState) => void
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
export type AncestorVisitors<TState> = {
|
| 32 |
+
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, ancestors: acorn.Node[]
|
| 33 |
+
) => void
|
| 34 |
+
} & {
|
| 35 |
+
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, ancestors: acorn.Node[]) => void
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
export type WalkerCallback<TState> = (node: acorn.Node, state: TState) => void
|
| 39 |
+
|
| 40 |
+
export type RecursiveVisitors<TState> = {
|
| 41 |
+
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, callback: WalkerCallback<TState>) => void
|
| 42 |
+
} & {
|
| 43 |
+
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, callback: WalkerCallback<TState>) => void
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
export type FindPredicate = (type: string, node: acorn.Node) => boolean
|
| 47 |
+
|
| 48 |
+
export interface Found<TState> {
|
| 49 |
+
node: acorn.Node,
|
| 50 |
+
state: TState
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* does a 'simple' walk over a tree
|
| 55 |
+
* @param node the AST node to walk
|
| 56 |
+
* @param visitors an object with properties whose names correspond to node types in the {@link https://github.com/estree/estree | ESTree spec}. The properties should contain functions that will be called with the node object and, if applicable the state at that point.
|
| 57 |
+
* @param base a walker algorithm
|
| 58 |
+
* @param state a start state. The default walker will simply visit all statements and expressions and not produce a meaningful state. (An example of a use of state is to track scope at each point in the tree.)
|
| 59 |
+
*/
|
| 60 |
+
export function simple<TState>(
|
| 61 |
+
node: acorn.Node,
|
| 62 |
+
visitors: SimpleVisitors<TState>,
|
| 63 |
+
base?: RecursiveVisitors<TState>,
|
| 64 |
+
state?: TState
|
| 65 |
+
): void
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* does a 'simple' walk over a tree, building up an array of ancestor nodes (including the current node) and passing the array to the callbacks as a third parameter.
|
| 69 |
+
* @param node
|
| 70 |
+
* @param visitors
|
| 71 |
+
* @param base
|
| 72 |
+
* @param state
|
| 73 |
+
*/
|
| 74 |
+
export function ancestor<TState>(
|
| 75 |
+
node: acorn.Node,
|
| 76 |
+
visitors: AncestorVisitors<TState>,
|
| 77 |
+
base?: RecursiveVisitors<TState>,
|
| 78 |
+
state?: TState
|
| 79 |
+
): void
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* does a 'recursive' walk, where the walker functions are responsible for continuing the walk on the child nodes of their target node.
|
| 83 |
+
* @param node
|
| 84 |
+
* @param state the start state
|
| 85 |
+
* @param functions contain an object that maps node types to walker functions
|
| 86 |
+
* @param base provides the fallback walker functions for node types that aren't handled in the {@link functions} object. If not given, the default walkers will be used.
|
| 87 |
+
*/
|
| 88 |
+
export function recursive<TState>(
|
| 89 |
+
node: acorn.Node,
|
| 90 |
+
state: TState,
|
| 91 |
+
functions: RecursiveVisitors<TState>,
|
| 92 |
+
base?: RecursiveVisitors<TState>
|
| 93 |
+
): void
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* does a 'full' walk over a tree, calling the {@link callback} with the arguments (node, state, type) for each node
|
| 97 |
+
* @param node
|
| 98 |
+
* @param callback
|
| 99 |
+
* @param base
|
| 100 |
+
* @param state
|
| 101 |
+
*/
|
| 102 |
+
export function full<TState>(
|
| 103 |
+
node: acorn.Node,
|
| 104 |
+
callback: FullWalkerCallback<TState>,
|
| 105 |
+
base?: RecursiveVisitors<TState>,
|
| 106 |
+
state?: TState
|
| 107 |
+
): void
|
| 108 |
+
|
| 109 |
+
/**
|
| 110 |
+
* does a 'full' walk over a tree, building up an array of ancestor nodes (including the current node) and passing the array to the callbacks as a third parameter.
|
| 111 |
+
* @param node
|
| 112 |
+
* @param callback
|
| 113 |
+
* @param base
|
| 114 |
+
* @param state
|
| 115 |
+
*/
|
| 116 |
+
export function fullAncestor<TState>(
|
| 117 |
+
node: acorn.Node,
|
| 118 |
+
callback: FullAncestorWalkerCallback<TState>,
|
| 119 |
+
base?: RecursiveVisitors<TState>,
|
| 120 |
+
state?: TState
|
| 121 |
+
): void
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* builds a new walker object by using the walker functions in {@link functions} and filling in the missing ones by taking defaults from {@link base}.
|
| 125 |
+
* @param functions
|
| 126 |
+
* @param base
|
| 127 |
+
*/
|
| 128 |
+
export function make<TState>(
|
| 129 |
+
functions: RecursiveVisitors<TState>,
|
| 130 |
+
base?: RecursiveVisitors<TState>
|
| 131 |
+
): RecursiveVisitors<TState>
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* tries to locate a node in a tree at the given start and/or end offsets, which satisfies the predicate test. {@link start} and {@link end} can be either `null` (as wildcard) or a `number`. {@link test} may be a string (indicating a node type) or a function that takes (nodeType, node) arguments and returns a boolean indicating whether this node is interesting. {@link base} and {@link state} are optional, and can be used to specify a custom walker. Nodes are tested from inner to outer, so if two nodes match the boundaries, the inner one will be preferred.
|
| 135 |
+
* @param node
|
| 136 |
+
* @param start
|
| 137 |
+
* @param end
|
| 138 |
+
* @param type
|
| 139 |
+
* @param base
|
| 140 |
+
* @param state
|
| 141 |
+
*/
|
| 142 |
+
export function findNodeAt<TState>(
|
| 143 |
+
node: acorn.Node,
|
| 144 |
+
start: number | undefined,
|
| 145 |
+
end?: number | undefined,
|
| 146 |
+
type?: FindPredicate | string,
|
| 147 |
+
base?: RecursiveVisitors<TState>,
|
| 148 |
+
state?: TState
|
| 149 |
+
): Found<TState> | undefined
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* like {@link findNodeAt}, but will match any node that exists 'around' (spanning) the given position.
|
| 153 |
+
* @param node
|
| 154 |
+
* @param start
|
| 155 |
+
* @param type
|
| 156 |
+
* @param base
|
| 157 |
+
* @param state
|
| 158 |
+
*/
|
| 159 |
+
export function findNodeAround<TState>(
|
| 160 |
+
node: acorn.Node,
|
| 161 |
+
start: number | undefined,
|
| 162 |
+
type?: FindPredicate | string,
|
| 163 |
+
base?: RecursiveVisitors<TState>,
|
| 164 |
+
state?: TState
|
| 165 |
+
): Found<TState> | undefined
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* Find the outermost matching node after a given position.
|
| 169 |
+
*/
|
| 170 |
+
export const findNodeAfter: typeof findNodeAround
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* Find the outermost matching node before a given position.
|
| 174 |
+
*/
|
| 175 |
+
export const findNodeBefore: typeof findNodeAround
|
| 176 |
+
|
| 177 |
+
export const base: RecursiveVisitors<any>
|
novas/novacore-zephyr/groq-code-cli/node_modules/acorn-walk/dist/walk.d.ts
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import * as acorn from "acorn"
|
| 2 |
+
|
| 3 |
+
export type FullWalkerCallback<TState> = (
|
| 4 |
+
node: acorn.Node,
|
| 5 |
+
state: TState,
|
| 6 |
+
type: string
|
| 7 |
+
) => void
|
| 8 |
+
|
| 9 |
+
export type FullAncestorWalkerCallback<TState> = (
|
| 10 |
+
node: acorn.Node,
|
| 11 |
+
state: TState,
|
| 12 |
+
ancestors: acorn.Node[],
|
| 13 |
+
type: string
|
| 14 |
+
) => void
|
| 15 |
+
|
| 16 |
+
type AggregateType = {
|
| 17 |
+
Expression: acorn.Expression,
|
| 18 |
+
Statement: acorn.Statement,
|
| 19 |
+
Function: acorn.Function,
|
| 20 |
+
Class: acorn.Class,
|
| 21 |
+
Pattern: acorn.Pattern,
|
| 22 |
+
ForInit: acorn.VariableDeclaration | acorn.Expression
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
export type SimpleVisitors<TState> = {
|
| 26 |
+
[type in acorn.AnyNode["type"]]?: (node: Extract<acorn.AnyNode, { type: type }>, state: TState) => void
|
| 27 |
+
} & {
|
| 28 |
+
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState) => void
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
export type AncestorVisitors<TState> = {
|
| 32 |
+
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, ancestors: acorn.Node[]
|
| 33 |
+
) => void
|
| 34 |
+
} & {
|
| 35 |
+
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, ancestors: acorn.Node[]) => void
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
export type WalkerCallback<TState> = (node: acorn.Node, state: TState) => void
|
| 39 |
+
|
| 40 |
+
export type RecursiveVisitors<TState> = {
|
| 41 |
+
[type in acorn.AnyNode["type"]]?: ( node: Extract<acorn.AnyNode, { type: type }>, state: TState, callback: WalkerCallback<TState>) => void
|
| 42 |
+
} & {
|
| 43 |
+
[type in keyof AggregateType]?: (node: AggregateType[type], state: TState, callback: WalkerCallback<TState>) => void
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
export type FindPredicate = (type: string, node: acorn.Node) => boolean
|
| 47 |
+
|
| 48 |
+
export interface Found<TState> {
|
| 49 |
+
node: acorn.Node,
|
| 50 |
+
state: TState
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* does a 'simple' walk over a tree
|
| 55 |
+
* @param node the AST node to walk
|
| 56 |
+
* @param visitors an object with properties whose names correspond to node types in the {@link https://github.com/estree/estree | ESTree spec}. The properties should contain functions that will be called with the node object and, if applicable the state at that point.
|
| 57 |
+
* @param base a walker algorithm
|
| 58 |
+
* @param state a start state. The default walker will simply visit all statements and expressions and not produce a meaningful state. (An example of a use of state is to track scope at each point in the tree.)
|
| 59 |
+
*/
|
| 60 |
+
export function simple<TState>(
|
| 61 |
+
node: acorn.Node,
|
| 62 |
+
visitors: SimpleVisitors<TState>,
|
| 63 |
+
base?: RecursiveVisitors<TState>,
|
| 64 |
+
state?: TState
|
| 65 |
+
): void
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* does a 'simple' walk over a tree, building up an array of ancestor nodes (including the current node) and passing the array to the callbacks as a third parameter.
|
| 69 |
+
* @param node
|
| 70 |
+
* @param visitors
|
| 71 |
+
* @param base
|
| 72 |
+
* @param state
|
| 73 |
+
*/
|
| 74 |
+
export function ancestor<TState>(
|
| 75 |
+
node: acorn.Node,
|
| 76 |
+
visitors: AncestorVisitors<TState>,
|
| 77 |
+
base?: RecursiveVisitors<TState>,
|
| 78 |
+
state?: TState
|
| 79 |
+
): void
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* does a 'recursive' walk, where the walker functions are responsible for continuing the walk on the child nodes of their target node.
|
| 83 |
+
* @param node
|
| 84 |
+
* @param state the start state
|
| 85 |
+
* @param functions contain an object that maps node types to walker functions
|
| 86 |
+
* @param base provides the fallback walker functions for node types that aren't handled in the {@link functions} object. If not given, the default walkers will be used.
|
| 87 |
+
*/
|
| 88 |
+
export function recursive<TState>(
|
| 89 |
+
node: acorn.Node,
|
| 90 |
+
state: TState,
|
| 91 |
+
functions: RecursiveVisitors<TState>,
|
| 92 |
+
base?: RecursiveVisitors<TState>
|
| 93 |
+
): void
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* does a 'full' walk over a tree, calling the {@link callback} with the arguments (node, state, type) for each node
|
| 97 |
+
* @param node
|
| 98 |
+
* @param callback
|
| 99 |
+
* @param base
|
| 100 |
+
* @param state
|
| 101 |
+
*/
|
| 102 |
+
export function full<TState>(
|
| 103 |
+
node: acorn.Node,
|
| 104 |
+
callback: FullWalkerCallback<TState>,
|
| 105 |
+
base?: RecursiveVisitors<TState>,
|
| 106 |
+
state?: TState
|
| 107 |
+
): void
|
| 108 |
+
|
| 109 |
+
/**
|
| 110 |
+
* does a 'full' walk over a tree, building up an array of ancestor nodes (including the current node) and passing the array to the callbacks as a third parameter.
|
| 111 |
+
* @param node
|
| 112 |
+
* @param callback
|
| 113 |
+
* @param base
|
| 114 |
+
* @param state
|
| 115 |
+
*/
|
| 116 |
+
export function fullAncestor<TState>(
|
| 117 |
+
node: acorn.Node,
|
| 118 |
+
callback: FullAncestorWalkerCallback<TState>,
|
| 119 |
+
base?: RecursiveVisitors<TState>,
|
| 120 |
+
state?: TState
|
| 121 |
+
): void
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* builds a new walker object by using the walker functions in {@link functions} and filling in the missing ones by taking defaults from {@link base}.
|
| 125 |
+
* @param functions
|
| 126 |
+
* @param base
|
| 127 |
+
*/
|
| 128 |
+
export function make<TState>(
|
| 129 |
+
functions: RecursiveVisitors<TState>,
|
| 130 |
+
base?: RecursiveVisitors<TState>
|
| 131 |
+
): RecursiveVisitors<TState>
|
| 132 |
+
|
| 133 |
+
/**
|
| 134 |
+
* tries to locate a node in a tree at the given start and/or end offsets, which satisfies the predicate test. {@link start} and {@link end} can be either `null` (as wildcard) or a `number`. {@link test} may be a string (indicating a node type) or a function that takes (nodeType, node) arguments and returns a boolean indicating whether this node is interesting. {@link base} and {@link state} are optional, and can be used to specify a custom walker. Nodes are tested from inner to outer, so if two nodes match the boundaries, the inner one will be preferred.
|
| 135 |
+
* @param node
|
| 136 |
+
* @param start
|
| 137 |
+
* @param end
|
| 138 |
+
* @param type
|
| 139 |
+
* @param base
|
| 140 |
+
* @param state
|
| 141 |
+
*/
|
| 142 |
+
export function findNodeAt<TState>(
|
| 143 |
+
node: acorn.Node,
|
| 144 |
+
start: number | undefined,
|
| 145 |
+
end?: number | undefined,
|
| 146 |
+
type?: FindPredicate | string,
|
| 147 |
+
base?: RecursiveVisitors<TState>,
|
| 148 |
+
state?: TState
|
| 149 |
+
): Found<TState> | undefined
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* like {@link findNodeAt}, but will match any node that exists 'around' (spanning) the given position.
|
| 153 |
+
* @param node
|
| 154 |
+
* @param start
|
| 155 |
+
* @param type
|
| 156 |
+
* @param base
|
| 157 |
+
* @param state
|
| 158 |
+
*/
|
| 159 |
+
export function findNodeAround<TState>(
|
| 160 |
+
node: acorn.Node,
|
| 161 |
+
start: number | undefined,
|
| 162 |
+
type?: FindPredicate | string,
|
| 163 |
+
base?: RecursiveVisitors<TState>,
|
| 164 |
+
state?: TState
|
| 165 |
+
): Found<TState> | undefined
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* Find the outermost matching node after a given position.
|
| 169 |
+
*/
|
| 170 |
+
export const findNodeAfter: typeof findNodeAround
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* Find the outermost matching node before a given position.
|
| 174 |
+
*/
|
| 175 |
+
export const findNodeBefore: typeof findNodeAround
|
| 176 |
+
|
| 177 |
+
export const base: RecursiveVisitors<any>
|
novas/novacore-zephyr/groq-code-cli/node_modules/acorn-walk/dist/walk.js
ADDED
|
@@ -0,0 +1,455 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function (global, factory) {
|
| 2 |
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
| 3 |
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
| 4 |
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.acorn = global.acorn || {}, global.acorn.walk = {})));
|
| 5 |
+
})(this, (function (exports) { 'use strict';
|
| 6 |
+
|
| 7 |
+
// AST walker module for ESTree compatible trees
|
| 8 |
+
|
| 9 |
+
// A simple walk is one where you simply specify callbacks to be
|
| 10 |
+
// called on specific nodes. The last two arguments are optional. A
|
| 11 |
+
// simple use would be
|
| 12 |
+
//
|
| 13 |
+
// walk.simple(myTree, {
|
| 14 |
+
// Expression: function(node) { ... }
|
| 15 |
+
// });
|
| 16 |
+
//
|
| 17 |
+
// to do something with all expressions. All ESTree node types
|
| 18 |
+
// can be used to identify node types, as well as Expression and
|
| 19 |
+
// Statement, which denote categories of nodes.
|
| 20 |
+
//
|
| 21 |
+
// The base argument can be used to pass a custom (recursive)
|
| 22 |
+
// walker, and state can be used to give this walked an initial
|
| 23 |
+
// state.
|
| 24 |
+
|
| 25 |
+
function simple(node, visitors, baseVisitor, state, override) {
|
| 26 |
+
if (!baseVisitor) { baseVisitor = base
|
| 27 |
+
; }(function c(node, st, override) {
|
| 28 |
+
var type = override || node.type;
|
| 29 |
+
baseVisitor[type](node, st, c);
|
| 30 |
+
if (visitors[type]) { visitors[type](node, st); }
|
| 31 |
+
})(node, state, override);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
// An ancestor walk keeps an array of ancestor nodes (including the
|
| 35 |
+
// current node) and passes them to the callback as third parameter
|
| 36 |
+
// (and also as state parameter when no other state is present).
|
| 37 |
+
function ancestor(node, visitors, baseVisitor, state, override) {
|
| 38 |
+
var ancestors = [];
|
| 39 |
+
if (!baseVisitor) { baseVisitor = base
|
| 40 |
+
; }(function c(node, st, override) {
|
| 41 |
+
var type = override || node.type;
|
| 42 |
+
var isNew = node !== ancestors[ancestors.length - 1];
|
| 43 |
+
if (isNew) { ancestors.push(node); }
|
| 44 |
+
baseVisitor[type](node, st, c);
|
| 45 |
+
if (visitors[type]) { visitors[type](node, st || ancestors, ancestors); }
|
| 46 |
+
if (isNew) { ancestors.pop(); }
|
| 47 |
+
})(node, state, override);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
// A recursive walk is one where your functions override the default
|
| 51 |
+
// walkers. They can modify and replace the state parameter that's
|
| 52 |
+
// threaded through the walk, and can opt how and whether to walk
|
| 53 |
+
// their child nodes (by calling their third argument on these
|
| 54 |
+
// nodes).
|
| 55 |
+
function recursive(node, state, funcs, baseVisitor, override) {
|
| 56 |
+
var visitor = funcs ? make(funcs, baseVisitor || undefined) : baseVisitor
|
| 57 |
+
;(function c(node, st, override) {
|
| 58 |
+
visitor[override || node.type](node, st, c);
|
| 59 |
+
})(node, state, override);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
function makeTest(test) {
|
| 63 |
+
if (typeof test === "string")
|
| 64 |
+
{ return function (type) { return type === test; } }
|
| 65 |
+
else if (!test)
|
| 66 |
+
{ return function () { return true; } }
|
| 67 |
+
else
|
| 68 |
+
{ return test }
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
var Found = function Found(node, state) { this.node = node; this.state = state; };
|
| 72 |
+
|
| 73 |
+
// A full walk triggers the callback on each node
|
| 74 |
+
function full(node, callback, baseVisitor, state, override) {
|
| 75 |
+
if (!baseVisitor) { baseVisitor = base; }
|
| 76 |
+
var last
|
| 77 |
+
;(function c(node, st, override) {
|
| 78 |
+
var type = override || node.type;
|
| 79 |
+
baseVisitor[type](node, st, c);
|
| 80 |
+
if (last !== node) {
|
| 81 |
+
callback(node, st, type);
|
| 82 |
+
last = node;
|
| 83 |
+
}
|
| 84 |
+
})(node, state, override);
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
// An fullAncestor walk is like an ancestor walk, but triggers
|
| 88 |
+
// the callback on each node
|
| 89 |
+
function fullAncestor(node, callback, baseVisitor, state) {
|
| 90 |
+
if (!baseVisitor) { baseVisitor = base; }
|
| 91 |
+
var ancestors = [], last
|
| 92 |
+
;(function c(node, st, override) {
|
| 93 |
+
var type = override || node.type;
|
| 94 |
+
var isNew = node !== ancestors[ancestors.length - 1];
|
| 95 |
+
if (isNew) { ancestors.push(node); }
|
| 96 |
+
baseVisitor[type](node, st, c);
|
| 97 |
+
if (last !== node) {
|
| 98 |
+
callback(node, st || ancestors, ancestors, type);
|
| 99 |
+
last = node;
|
| 100 |
+
}
|
| 101 |
+
if (isNew) { ancestors.pop(); }
|
| 102 |
+
})(node, state);
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
// Find a node with a given start, end, and type (all are optional,
|
| 106 |
+
// null can be used as wildcard). Returns a {node, state} object, or
|
| 107 |
+
// undefined when it doesn't find a matching node.
|
| 108 |
+
function findNodeAt(node, start, end, test, baseVisitor, state) {
|
| 109 |
+
if (!baseVisitor) { baseVisitor = base; }
|
| 110 |
+
test = makeTest(test);
|
| 111 |
+
try {
|
| 112 |
+
(function c(node, st, override) {
|
| 113 |
+
var type = override || node.type;
|
| 114 |
+
if ((start == null || node.start <= start) &&
|
| 115 |
+
(end == null || node.end >= end))
|
| 116 |
+
{ baseVisitor[type](node, st, c); }
|
| 117 |
+
if ((start == null || node.start === start) &&
|
| 118 |
+
(end == null || node.end === end) &&
|
| 119 |
+
test(type, node))
|
| 120 |
+
{ throw new Found(node, st) }
|
| 121 |
+
})(node, state);
|
| 122 |
+
} catch (e) {
|
| 123 |
+
if (e instanceof Found) { return e }
|
| 124 |
+
throw e
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
// Find the innermost node of a given type that contains the given
|
| 129 |
+
// position. Interface similar to findNodeAt.
|
| 130 |
+
function findNodeAround(node, pos, test, baseVisitor, state) {
|
| 131 |
+
test = makeTest(test);
|
| 132 |
+
if (!baseVisitor) { baseVisitor = base; }
|
| 133 |
+
try {
|
| 134 |
+
(function c(node, st, override) {
|
| 135 |
+
var type = override || node.type;
|
| 136 |
+
if (node.start > pos || node.end < pos) { return }
|
| 137 |
+
baseVisitor[type](node, st, c);
|
| 138 |
+
if (test(type, node)) { throw new Found(node, st) }
|
| 139 |
+
})(node, state);
|
| 140 |
+
} catch (e) {
|
| 141 |
+
if (e instanceof Found) { return e }
|
| 142 |
+
throw e
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
// Find the outermost matching node after a given position.
|
| 147 |
+
function findNodeAfter(node, pos, test, baseVisitor, state) {
|
| 148 |
+
test = makeTest(test);
|
| 149 |
+
if (!baseVisitor) { baseVisitor = base; }
|
| 150 |
+
try {
|
| 151 |
+
(function c(node, st, override) {
|
| 152 |
+
if (node.end < pos) { return }
|
| 153 |
+
var type = override || node.type;
|
| 154 |
+
if (node.start >= pos && test(type, node)) { throw new Found(node, st) }
|
| 155 |
+
baseVisitor[type](node, st, c);
|
| 156 |
+
})(node, state);
|
| 157 |
+
} catch (e) {
|
| 158 |
+
if (e instanceof Found) { return e }
|
| 159 |
+
throw e
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
// Find the outermost matching node before a given position.
|
| 164 |
+
function findNodeBefore(node, pos, test, baseVisitor, state) {
|
| 165 |
+
test = makeTest(test);
|
| 166 |
+
if (!baseVisitor) { baseVisitor = base; }
|
| 167 |
+
var max
|
| 168 |
+
;(function c(node, st, override) {
|
| 169 |
+
if (node.start > pos) { return }
|
| 170 |
+
var type = override || node.type;
|
| 171 |
+
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node))
|
| 172 |
+
{ max = new Found(node, st); }
|
| 173 |
+
baseVisitor[type](node, st, c);
|
| 174 |
+
})(node, state);
|
| 175 |
+
return max
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
// Used to create a custom walker. Will fill in all missing node
|
| 179 |
+
// type properties with the defaults.
|
| 180 |
+
function make(funcs, baseVisitor) {
|
| 181 |
+
var visitor = Object.create(baseVisitor || base);
|
| 182 |
+
for (var type in funcs) { visitor[type] = funcs[type]; }
|
| 183 |
+
return visitor
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
function skipThrough(node, st, c) { c(node, st); }
|
| 187 |
+
function ignore(_node, _st, _c) {}
|
| 188 |
+
|
| 189 |
+
// Node walkers.
|
| 190 |
+
|
| 191 |
+
var base = {};
|
| 192 |
+
|
| 193 |
+
base.Program = base.BlockStatement = base.StaticBlock = function (node, st, c) {
|
| 194 |
+
for (var i = 0, list = node.body; i < list.length; i += 1)
|
| 195 |
+
{
|
| 196 |
+
var stmt = list[i];
|
| 197 |
+
|
| 198 |
+
c(stmt, st, "Statement");
|
| 199 |
+
}
|
| 200 |
+
};
|
| 201 |
+
base.Statement = skipThrough;
|
| 202 |
+
base.EmptyStatement = ignore;
|
| 203 |
+
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression =
|
| 204 |
+
function (node, st, c) { return c(node.expression, st, "Expression"); };
|
| 205 |
+
base.IfStatement = function (node, st, c) {
|
| 206 |
+
c(node.test, st, "Expression");
|
| 207 |
+
c(node.consequent, st, "Statement");
|
| 208 |
+
if (node.alternate) { c(node.alternate, st, "Statement"); }
|
| 209 |
+
};
|
| 210 |
+
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); };
|
| 211 |
+
base.BreakStatement = base.ContinueStatement = ignore;
|
| 212 |
+
base.WithStatement = function (node, st, c) {
|
| 213 |
+
c(node.object, st, "Expression");
|
| 214 |
+
c(node.body, st, "Statement");
|
| 215 |
+
};
|
| 216 |
+
base.SwitchStatement = function (node, st, c) {
|
| 217 |
+
c(node.discriminant, st, "Expression");
|
| 218 |
+
for (var i = 0, list = node.cases; i < list.length; i += 1) {
|
| 219 |
+
var cs = list[i];
|
| 220 |
+
|
| 221 |
+
c(cs, st);
|
| 222 |
+
}
|
| 223 |
+
};
|
| 224 |
+
base.SwitchCase = function (node, st, c) {
|
| 225 |
+
if (node.test) { c(node.test, st, "Expression"); }
|
| 226 |
+
for (var i = 0, list = node.consequent; i < list.length; i += 1)
|
| 227 |
+
{
|
| 228 |
+
var cons = list[i];
|
| 229 |
+
|
| 230 |
+
c(cons, st, "Statement");
|
| 231 |
+
}
|
| 232 |
+
};
|
| 233 |
+
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
|
| 234 |
+
if (node.argument) { c(node.argument, st, "Expression"); }
|
| 235 |
+
};
|
| 236 |
+
base.ThrowStatement = base.SpreadElement =
|
| 237 |
+
function (node, st, c) { return c(node.argument, st, "Expression"); };
|
| 238 |
+
base.TryStatement = function (node, st, c) {
|
| 239 |
+
c(node.block, st, "Statement");
|
| 240 |
+
if (node.handler) { c(node.handler, st); }
|
| 241 |
+
if (node.finalizer) { c(node.finalizer, st, "Statement"); }
|
| 242 |
+
};
|
| 243 |
+
base.CatchClause = function (node, st, c) {
|
| 244 |
+
if (node.param) { c(node.param, st, "Pattern"); }
|
| 245 |
+
c(node.body, st, "Statement");
|
| 246 |
+
};
|
| 247 |
+
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
|
| 248 |
+
c(node.test, st, "Expression");
|
| 249 |
+
c(node.body, st, "Statement");
|
| 250 |
+
};
|
| 251 |
+
base.ForStatement = function (node, st, c) {
|
| 252 |
+
if (node.init) { c(node.init, st, "ForInit"); }
|
| 253 |
+
if (node.test) { c(node.test, st, "Expression"); }
|
| 254 |
+
if (node.update) { c(node.update, st, "Expression"); }
|
| 255 |
+
c(node.body, st, "Statement");
|
| 256 |
+
};
|
| 257 |
+
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
|
| 258 |
+
c(node.left, st, "ForInit");
|
| 259 |
+
c(node.right, st, "Expression");
|
| 260 |
+
c(node.body, st, "Statement");
|
| 261 |
+
};
|
| 262 |
+
base.ForInit = function (node, st, c) {
|
| 263 |
+
if (node.type === "VariableDeclaration") { c(node, st); }
|
| 264 |
+
else { c(node, st, "Expression"); }
|
| 265 |
+
};
|
| 266 |
+
base.DebuggerStatement = ignore;
|
| 267 |
+
|
| 268 |
+
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); };
|
| 269 |
+
base.VariableDeclaration = function (node, st, c) {
|
| 270 |
+
for (var i = 0, list = node.declarations; i < list.length; i += 1)
|
| 271 |
+
{
|
| 272 |
+
var decl = list[i];
|
| 273 |
+
|
| 274 |
+
c(decl, st);
|
| 275 |
+
}
|
| 276 |
+
};
|
| 277 |
+
base.VariableDeclarator = function (node, st, c) {
|
| 278 |
+
c(node.id, st, "Pattern");
|
| 279 |
+
if (node.init) { c(node.init, st, "Expression"); }
|
| 280 |
+
};
|
| 281 |
+
|
| 282 |
+
base.Function = function (node, st, c) {
|
| 283 |
+
if (node.id) { c(node.id, st, "Pattern"); }
|
| 284 |
+
for (var i = 0, list = node.params; i < list.length; i += 1)
|
| 285 |
+
{
|
| 286 |
+
var param = list[i];
|
| 287 |
+
|
| 288 |
+
c(param, st, "Pattern");
|
| 289 |
+
}
|
| 290 |
+
c(node.body, st, node.expression ? "Expression" : "Statement");
|
| 291 |
+
};
|
| 292 |
+
|
| 293 |
+
base.Pattern = function (node, st, c) {
|
| 294 |
+
if (node.type === "Identifier")
|
| 295 |
+
{ c(node, st, "VariablePattern"); }
|
| 296 |
+
else if (node.type === "MemberExpression")
|
| 297 |
+
{ c(node, st, "MemberPattern"); }
|
| 298 |
+
else
|
| 299 |
+
{ c(node, st); }
|
| 300 |
+
};
|
| 301 |
+
base.VariablePattern = ignore;
|
| 302 |
+
base.MemberPattern = skipThrough;
|
| 303 |
+
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); };
|
| 304 |
+
base.ArrayPattern = function (node, st, c) {
|
| 305 |
+
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
| 306 |
+
var elt = list[i];
|
| 307 |
+
|
| 308 |
+
if (elt) { c(elt, st, "Pattern"); }
|
| 309 |
+
}
|
| 310 |
+
};
|
| 311 |
+
base.ObjectPattern = function (node, st, c) {
|
| 312 |
+
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
| 313 |
+
var prop = list[i];
|
| 314 |
+
|
| 315 |
+
if (prop.type === "Property") {
|
| 316 |
+
if (prop.computed) { c(prop.key, st, "Expression"); }
|
| 317 |
+
c(prop.value, st, "Pattern");
|
| 318 |
+
} else if (prop.type === "RestElement") {
|
| 319 |
+
c(prop.argument, st, "Pattern");
|
| 320 |
+
}
|
| 321 |
+
}
|
| 322 |
+
};
|
| 323 |
+
|
| 324 |
+
base.Expression = skipThrough;
|
| 325 |
+
base.ThisExpression = base.Super = base.MetaProperty = ignore;
|
| 326 |
+
base.ArrayExpression = function (node, st, c) {
|
| 327 |
+
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
| 328 |
+
var elt = list[i];
|
| 329 |
+
|
| 330 |
+
if (elt) { c(elt, st, "Expression"); }
|
| 331 |
+
}
|
| 332 |
+
};
|
| 333 |
+
base.ObjectExpression = function (node, st, c) {
|
| 334 |
+
for (var i = 0, list = node.properties; i < list.length; i += 1)
|
| 335 |
+
{
|
| 336 |
+
var prop = list[i];
|
| 337 |
+
|
| 338 |
+
c(prop, st);
|
| 339 |
+
}
|
| 340 |
+
};
|
| 341 |
+
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
|
| 342 |
+
base.SequenceExpression = function (node, st, c) {
|
| 343 |
+
for (var i = 0, list = node.expressions; i < list.length; i += 1)
|
| 344 |
+
{
|
| 345 |
+
var expr = list[i];
|
| 346 |
+
|
| 347 |
+
c(expr, st, "Expression");
|
| 348 |
+
}
|
| 349 |
+
};
|
| 350 |
+
base.TemplateLiteral = function (node, st, c) {
|
| 351 |
+
for (var i = 0, list = node.quasis; i < list.length; i += 1)
|
| 352 |
+
{
|
| 353 |
+
var quasi = list[i];
|
| 354 |
+
|
| 355 |
+
c(quasi, st);
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
for (var i$1 = 0, list$1 = node.expressions; i$1 < list$1.length; i$1 += 1)
|
| 359 |
+
{
|
| 360 |
+
var expr = list$1[i$1];
|
| 361 |
+
|
| 362 |
+
c(expr, st, "Expression");
|
| 363 |
+
}
|
| 364 |
+
};
|
| 365 |
+
base.TemplateElement = ignore;
|
| 366 |
+
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
|
| 367 |
+
c(node.argument, st, "Expression");
|
| 368 |
+
};
|
| 369 |
+
base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
|
| 370 |
+
c(node.left, st, "Expression");
|
| 371 |
+
c(node.right, st, "Expression");
|
| 372 |
+
};
|
| 373 |
+
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
|
| 374 |
+
c(node.left, st, "Pattern");
|
| 375 |
+
c(node.right, st, "Expression");
|
| 376 |
+
};
|
| 377 |
+
base.ConditionalExpression = function (node, st, c) {
|
| 378 |
+
c(node.test, st, "Expression");
|
| 379 |
+
c(node.consequent, st, "Expression");
|
| 380 |
+
c(node.alternate, st, "Expression");
|
| 381 |
+
};
|
| 382 |
+
base.NewExpression = base.CallExpression = function (node, st, c) {
|
| 383 |
+
c(node.callee, st, "Expression");
|
| 384 |
+
if (node.arguments)
|
| 385 |
+
{ for (var i = 0, list = node.arguments; i < list.length; i += 1)
|
| 386 |
+
{
|
| 387 |
+
var arg = list[i];
|
| 388 |
+
|
| 389 |
+
c(arg, st, "Expression");
|
| 390 |
+
} }
|
| 391 |
+
};
|
| 392 |
+
base.MemberExpression = function (node, st, c) {
|
| 393 |
+
c(node.object, st, "Expression");
|
| 394 |
+
if (node.computed) { c(node.property, st, "Expression"); }
|
| 395 |
+
};
|
| 396 |
+
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
|
| 397 |
+
if (node.declaration)
|
| 398 |
+
{ c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); }
|
| 399 |
+
if (node.source) { c(node.source, st, "Expression"); }
|
| 400 |
+
};
|
| 401 |
+
base.ExportAllDeclaration = function (node, st, c) {
|
| 402 |
+
if (node.exported)
|
| 403 |
+
{ c(node.exported, st); }
|
| 404 |
+
c(node.source, st, "Expression");
|
| 405 |
+
};
|
| 406 |
+
base.ImportDeclaration = function (node, st, c) {
|
| 407 |
+
for (var i = 0, list = node.specifiers; i < list.length; i += 1)
|
| 408 |
+
{
|
| 409 |
+
var spec = list[i];
|
| 410 |
+
|
| 411 |
+
c(spec, st);
|
| 412 |
+
}
|
| 413 |
+
c(node.source, st, "Expression");
|
| 414 |
+
};
|
| 415 |
+
base.ImportExpression = function (node, st, c) {
|
| 416 |
+
c(node.source, st, "Expression");
|
| 417 |
+
};
|
| 418 |
+
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.PrivateIdentifier = base.Literal = ignore;
|
| 419 |
+
|
| 420 |
+
base.TaggedTemplateExpression = function (node, st, c) {
|
| 421 |
+
c(node.tag, st, "Expression");
|
| 422 |
+
c(node.quasi, st, "Expression");
|
| 423 |
+
};
|
| 424 |
+
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); };
|
| 425 |
+
base.Class = function (node, st, c) {
|
| 426 |
+
if (node.id) { c(node.id, st, "Pattern"); }
|
| 427 |
+
if (node.superClass) { c(node.superClass, st, "Expression"); }
|
| 428 |
+
c(node.body, st);
|
| 429 |
+
};
|
| 430 |
+
base.ClassBody = function (node, st, c) {
|
| 431 |
+
for (var i = 0, list = node.body; i < list.length; i += 1)
|
| 432 |
+
{
|
| 433 |
+
var elt = list[i];
|
| 434 |
+
|
| 435 |
+
c(elt, st);
|
| 436 |
+
}
|
| 437 |
+
};
|
| 438 |
+
base.MethodDefinition = base.PropertyDefinition = base.Property = function (node, st, c) {
|
| 439 |
+
if (node.computed) { c(node.key, st, "Expression"); }
|
| 440 |
+
if (node.value) { c(node.value, st, "Expression"); }
|
| 441 |
+
};
|
| 442 |
+
|
| 443 |
+
exports.ancestor = ancestor;
|
| 444 |
+
exports.base = base;
|
| 445 |
+
exports.findNodeAfter = findNodeAfter;
|
| 446 |
+
exports.findNodeAround = findNodeAround;
|
| 447 |
+
exports.findNodeAt = findNodeAt;
|
| 448 |
+
exports.findNodeBefore = findNodeBefore;
|
| 449 |
+
exports.full = full;
|
| 450 |
+
exports.fullAncestor = fullAncestor;
|
| 451 |
+
exports.make = make;
|
| 452 |
+
exports.recursive = recursive;
|
| 453 |
+
exports.simple = simple;
|
| 454 |
+
|
| 455 |
+
}));
|
novas/novacore-zephyr/groq-code-cli/node_modules/acorn-walk/dist/walk.mjs
ADDED
|
@@ -0,0 +1,437 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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| 3 |
+
// A simple walk is one where you simply specify callbacks to be
|
| 4 |
+
// called on specific nodes. The last two arguments are optional. A
|
| 5 |
+
// simple use would be
|
| 6 |
+
//
|
| 7 |
+
// walk.simple(myTree, {
|
| 8 |
+
// Expression: function(node) { ... }
|
| 9 |
+
// });
|
| 10 |
+
//
|
| 11 |
+
// to do something with all expressions. All ESTree node types
|
| 12 |
+
// can be used to identify node types, as well as Expression and
|
| 13 |
+
// Statement, which denote categories of nodes.
|
| 14 |
+
//
|
| 15 |
+
// The base argument can be used to pass a custom (recursive)
|
| 16 |
+
// walker, and state can be used to give this walked an initial
|
| 17 |
+
// state.
|
| 18 |
+
|
| 19 |
+
function simple(node, visitors, baseVisitor, state, override) {
|
| 20 |
+
if (!baseVisitor) { baseVisitor = base
|
| 21 |
+
; }(function c(node, st, override) {
|
| 22 |
+
var type = override || node.type;
|
| 23 |
+
baseVisitor[type](node, st, c);
|
| 24 |
+
if (visitors[type]) { visitors[type](node, st); }
|
| 25 |
+
})(node, state, override);
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
// An ancestor walk keeps an array of ancestor nodes (including the
|
| 29 |
+
// current node) and passes them to the callback as third parameter
|
| 30 |
+
// (and also as state parameter when no other state is present).
|
| 31 |
+
function ancestor(node, visitors, baseVisitor, state, override) {
|
| 32 |
+
var ancestors = [];
|
| 33 |
+
if (!baseVisitor) { baseVisitor = base
|
| 34 |
+
; }(function c(node, st, override) {
|
| 35 |
+
var type = override || node.type;
|
| 36 |
+
var isNew = node !== ancestors[ancestors.length - 1];
|
| 37 |
+
if (isNew) { ancestors.push(node); }
|
| 38 |
+
baseVisitor[type](node, st, c);
|
| 39 |
+
if (visitors[type]) { visitors[type](node, st || ancestors, ancestors); }
|
| 40 |
+
if (isNew) { ancestors.pop(); }
|
| 41 |
+
})(node, state, override);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
// A recursive walk is one where your functions override the default
|
| 45 |
+
// walkers. They can modify and replace the state parameter that's
|
| 46 |
+
// threaded through the walk, and can opt how and whether to walk
|
| 47 |
+
// their child nodes (by calling their third argument on these
|
| 48 |
+
// nodes).
|
| 49 |
+
function recursive(node, state, funcs, baseVisitor, override) {
|
| 50 |
+
var visitor = funcs ? make(funcs, baseVisitor || undefined) : baseVisitor
|
| 51 |
+
;(function c(node, st, override) {
|
| 52 |
+
visitor[override || node.type](node, st, c);
|
| 53 |
+
})(node, state, override);
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
function makeTest(test) {
|
| 57 |
+
if (typeof test === "string")
|
| 58 |
+
{ return function (type) { return type === test; } }
|
| 59 |
+
else if (!test)
|
| 60 |
+
{ return function () { return true; } }
|
| 61 |
+
else
|
| 62 |
+
{ return test }
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
var Found = function Found(node, state) { this.node = node; this.state = state; };
|
| 66 |
+
|
| 67 |
+
// A full walk triggers the callback on each node
|
| 68 |
+
function full(node, callback, baseVisitor, state, override) {
|
| 69 |
+
if (!baseVisitor) { baseVisitor = base; }
|
| 70 |
+
var last
|
| 71 |
+
;(function c(node, st, override) {
|
| 72 |
+
var type = override || node.type;
|
| 73 |
+
baseVisitor[type](node, st, c);
|
| 74 |
+
if (last !== node) {
|
| 75 |
+
callback(node, st, type);
|
| 76 |
+
last = node;
|
| 77 |
+
}
|
| 78 |
+
})(node, state, override);
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
// An fullAncestor walk is like an ancestor walk, but triggers
|
| 82 |
+
// the callback on each node
|
| 83 |
+
function fullAncestor(node, callback, baseVisitor, state) {
|
| 84 |
+
if (!baseVisitor) { baseVisitor = base; }
|
| 85 |
+
var ancestors = [], last
|
| 86 |
+
;(function c(node, st, override) {
|
| 87 |
+
var type = override || node.type;
|
| 88 |
+
var isNew = node !== ancestors[ancestors.length - 1];
|
| 89 |
+
if (isNew) { ancestors.push(node); }
|
| 90 |
+
baseVisitor[type](node, st, c);
|
| 91 |
+
if (last !== node) {
|
| 92 |
+
callback(node, st || ancestors, ancestors, type);
|
| 93 |
+
last = node;
|
| 94 |
+
}
|
| 95 |
+
if (isNew) { ancestors.pop(); }
|
| 96 |
+
})(node, state);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
// Find a node with a given start, end, and type (all are optional,
|
| 100 |
+
// null can be used as wildcard). Returns a {node, state} object, or
|
| 101 |
+
// undefined when it doesn't find a matching node.
|
| 102 |
+
function findNodeAt(node, start, end, test, baseVisitor, state) {
|
| 103 |
+
if (!baseVisitor) { baseVisitor = base; }
|
| 104 |
+
test = makeTest(test);
|
| 105 |
+
try {
|
| 106 |
+
(function c(node, st, override) {
|
| 107 |
+
var type = override || node.type;
|
| 108 |
+
if ((start == null || node.start <= start) &&
|
| 109 |
+
(end == null || node.end >= end))
|
| 110 |
+
{ baseVisitor[type](node, st, c); }
|
| 111 |
+
if ((start == null || node.start === start) &&
|
| 112 |
+
(end == null || node.end === end) &&
|
| 113 |
+
test(type, node))
|
| 114 |
+
{ throw new Found(node, st) }
|
| 115 |
+
})(node, state);
|
| 116 |
+
} catch (e) {
|
| 117 |
+
if (e instanceof Found) { return e }
|
| 118 |
+
throw e
|
| 119 |
+
}
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
// Find the innermost node of a given type that contains the given
|
| 123 |
+
// position. Interface similar to findNodeAt.
|
| 124 |
+
function findNodeAround(node, pos, test, baseVisitor, state) {
|
| 125 |
+
test = makeTest(test);
|
| 126 |
+
if (!baseVisitor) { baseVisitor = base; }
|
| 127 |
+
try {
|
| 128 |
+
(function c(node, st, override) {
|
| 129 |
+
var type = override || node.type;
|
| 130 |
+
if (node.start > pos || node.end < pos) { return }
|
| 131 |
+
baseVisitor[type](node, st, c);
|
| 132 |
+
if (test(type, node)) { throw new Found(node, st) }
|
| 133 |
+
})(node, state);
|
| 134 |
+
} catch (e) {
|
| 135 |
+
if (e instanceof Found) { return e }
|
| 136 |
+
throw e
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
// Find the outermost matching node after a given position.
|
| 141 |
+
function findNodeAfter(node, pos, test, baseVisitor, state) {
|
| 142 |
+
test = makeTest(test);
|
| 143 |
+
if (!baseVisitor) { baseVisitor = base; }
|
| 144 |
+
try {
|
| 145 |
+
(function c(node, st, override) {
|
| 146 |
+
if (node.end < pos) { return }
|
| 147 |
+
var type = override || node.type;
|
| 148 |
+
if (node.start >= pos && test(type, node)) { throw new Found(node, st) }
|
| 149 |
+
baseVisitor[type](node, st, c);
|
| 150 |
+
})(node, state);
|
| 151 |
+
} catch (e) {
|
| 152 |
+
if (e instanceof Found) { return e }
|
| 153 |
+
throw e
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
// Find the outermost matching node before a given position.
|
| 158 |
+
function findNodeBefore(node, pos, test, baseVisitor, state) {
|
| 159 |
+
test = makeTest(test);
|
| 160 |
+
if (!baseVisitor) { baseVisitor = base; }
|
| 161 |
+
var max
|
| 162 |
+
;(function c(node, st, override) {
|
| 163 |
+
if (node.start > pos) { return }
|
| 164 |
+
var type = override || node.type;
|
| 165 |
+
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node))
|
| 166 |
+
{ max = new Found(node, st); }
|
| 167 |
+
baseVisitor[type](node, st, c);
|
| 168 |
+
})(node, state);
|
| 169 |
+
return max
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
// Used to create a custom walker. Will fill in all missing node
|
| 173 |
+
// type properties with the defaults.
|
| 174 |
+
function make(funcs, baseVisitor) {
|
| 175 |
+
var visitor = Object.create(baseVisitor || base);
|
| 176 |
+
for (var type in funcs) { visitor[type] = funcs[type]; }
|
| 177 |
+
return visitor
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
function skipThrough(node, st, c) { c(node, st); }
|
| 181 |
+
function ignore(_node, _st, _c) {}
|
| 182 |
+
|
| 183 |
+
// Node walkers.
|
| 184 |
+
|
| 185 |
+
var base = {};
|
| 186 |
+
|
| 187 |
+
base.Program = base.BlockStatement = base.StaticBlock = function (node, st, c) {
|
| 188 |
+
for (var i = 0, list = node.body; i < list.length; i += 1)
|
| 189 |
+
{
|
| 190 |
+
var stmt = list[i];
|
| 191 |
+
|
| 192 |
+
c(stmt, st, "Statement");
|
| 193 |
+
}
|
| 194 |
+
};
|
| 195 |
+
base.Statement = skipThrough;
|
| 196 |
+
base.EmptyStatement = ignore;
|
| 197 |
+
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression =
|
| 198 |
+
function (node, st, c) { return c(node.expression, st, "Expression"); };
|
| 199 |
+
base.IfStatement = function (node, st, c) {
|
| 200 |
+
c(node.test, st, "Expression");
|
| 201 |
+
c(node.consequent, st, "Statement");
|
| 202 |
+
if (node.alternate) { c(node.alternate, st, "Statement"); }
|
| 203 |
+
};
|
| 204 |
+
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); };
|
| 205 |
+
base.BreakStatement = base.ContinueStatement = ignore;
|
| 206 |
+
base.WithStatement = function (node, st, c) {
|
| 207 |
+
c(node.object, st, "Expression");
|
| 208 |
+
c(node.body, st, "Statement");
|
| 209 |
+
};
|
| 210 |
+
base.SwitchStatement = function (node, st, c) {
|
| 211 |
+
c(node.discriminant, st, "Expression");
|
| 212 |
+
for (var i = 0, list = node.cases; i < list.length; i += 1) {
|
| 213 |
+
var cs = list[i];
|
| 214 |
+
|
| 215 |
+
c(cs, st);
|
| 216 |
+
}
|
| 217 |
+
};
|
| 218 |
+
base.SwitchCase = function (node, st, c) {
|
| 219 |
+
if (node.test) { c(node.test, st, "Expression"); }
|
| 220 |
+
for (var i = 0, list = node.consequent; i < list.length; i += 1)
|
| 221 |
+
{
|
| 222 |
+
var cons = list[i];
|
| 223 |
+
|
| 224 |
+
c(cons, st, "Statement");
|
| 225 |
+
}
|
| 226 |
+
};
|
| 227 |
+
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
|
| 228 |
+
if (node.argument) { c(node.argument, st, "Expression"); }
|
| 229 |
+
};
|
| 230 |
+
base.ThrowStatement = base.SpreadElement =
|
| 231 |
+
function (node, st, c) { return c(node.argument, st, "Expression"); };
|
| 232 |
+
base.TryStatement = function (node, st, c) {
|
| 233 |
+
c(node.block, st, "Statement");
|
| 234 |
+
if (node.handler) { c(node.handler, st); }
|
| 235 |
+
if (node.finalizer) { c(node.finalizer, st, "Statement"); }
|
| 236 |
+
};
|
| 237 |
+
base.CatchClause = function (node, st, c) {
|
| 238 |
+
if (node.param) { c(node.param, st, "Pattern"); }
|
| 239 |
+
c(node.body, st, "Statement");
|
| 240 |
+
};
|
| 241 |
+
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
|
| 242 |
+
c(node.test, st, "Expression");
|
| 243 |
+
c(node.body, st, "Statement");
|
| 244 |
+
};
|
| 245 |
+
base.ForStatement = function (node, st, c) {
|
| 246 |
+
if (node.init) { c(node.init, st, "ForInit"); }
|
| 247 |
+
if (node.test) { c(node.test, st, "Expression"); }
|
| 248 |
+
if (node.update) { c(node.update, st, "Expression"); }
|
| 249 |
+
c(node.body, st, "Statement");
|
| 250 |
+
};
|
| 251 |
+
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
|
| 252 |
+
c(node.left, st, "ForInit");
|
| 253 |
+
c(node.right, st, "Expression");
|
| 254 |
+
c(node.body, st, "Statement");
|
| 255 |
+
};
|
| 256 |
+
base.ForInit = function (node, st, c) {
|
| 257 |
+
if (node.type === "VariableDeclaration") { c(node, st); }
|
| 258 |
+
else { c(node, st, "Expression"); }
|
| 259 |
+
};
|
| 260 |
+
base.DebuggerStatement = ignore;
|
| 261 |
+
|
| 262 |
+
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); };
|
| 263 |
+
base.VariableDeclaration = function (node, st, c) {
|
| 264 |
+
for (var i = 0, list = node.declarations; i < list.length; i += 1)
|
| 265 |
+
{
|
| 266 |
+
var decl = list[i];
|
| 267 |
+
|
| 268 |
+
c(decl, st);
|
| 269 |
+
}
|
| 270 |
+
};
|
| 271 |
+
base.VariableDeclarator = function (node, st, c) {
|
| 272 |
+
c(node.id, st, "Pattern");
|
| 273 |
+
if (node.init) { c(node.init, st, "Expression"); }
|
| 274 |
+
};
|
| 275 |
+
|
| 276 |
+
base.Function = function (node, st, c) {
|
| 277 |
+
if (node.id) { c(node.id, st, "Pattern"); }
|
| 278 |
+
for (var i = 0, list = node.params; i < list.length; i += 1)
|
| 279 |
+
{
|
| 280 |
+
var param = list[i];
|
| 281 |
+
|
| 282 |
+
c(param, st, "Pattern");
|
| 283 |
+
}
|
| 284 |
+
c(node.body, st, node.expression ? "Expression" : "Statement");
|
| 285 |
+
};
|
| 286 |
+
|
| 287 |
+
base.Pattern = function (node, st, c) {
|
| 288 |
+
if (node.type === "Identifier")
|
| 289 |
+
{ c(node, st, "VariablePattern"); }
|
| 290 |
+
else if (node.type === "MemberExpression")
|
| 291 |
+
{ c(node, st, "MemberPattern"); }
|
| 292 |
+
else
|
| 293 |
+
{ c(node, st); }
|
| 294 |
+
};
|
| 295 |
+
base.VariablePattern = ignore;
|
| 296 |
+
base.MemberPattern = skipThrough;
|
| 297 |
+
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); };
|
| 298 |
+
base.ArrayPattern = function (node, st, c) {
|
| 299 |
+
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
| 300 |
+
var elt = list[i];
|
| 301 |
+
|
| 302 |
+
if (elt) { c(elt, st, "Pattern"); }
|
| 303 |
+
}
|
| 304 |
+
};
|
| 305 |
+
base.ObjectPattern = function (node, st, c) {
|
| 306 |
+
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
| 307 |
+
var prop = list[i];
|
| 308 |
+
|
| 309 |
+
if (prop.type === "Property") {
|
| 310 |
+
if (prop.computed) { c(prop.key, st, "Expression"); }
|
| 311 |
+
c(prop.value, st, "Pattern");
|
| 312 |
+
} else if (prop.type === "RestElement") {
|
| 313 |
+
c(prop.argument, st, "Pattern");
|
| 314 |
+
}
|
| 315 |
+
}
|
| 316 |
+
};
|
| 317 |
+
|
| 318 |
+
base.Expression = skipThrough;
|
| 319 |
+
base.ThisExpression = base.Super = base.MetaProperty = ignore;
|
| 320 |
+
base.ArrayExpression = function (node, st, c) {
|
| 321 |
+
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
| 322 |
+
var elt = list[i];
|
| 323 |
+
|
| 324 |
+
if (elt) { c(elt, st, "Expression"); }
|
| 325 |
+
}
|
| 326 |
+
};
|
| 327 |
+
base.ObjectExpression = function (node, st, c) {
|
| 328 |
+
for (var i = 0, list = node.properties; i < list.length; i += 1)
|
| 329 |
+
{
|
| 330 |
+
var prop = list[i];
|
| 331 |
+
|
| 332 |
+
c(prop, st);
|
| 333 |
+
}
|
| 334 |
+
};
|
| 335 |
+
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
|
| 336 |
+
base.SequenceExpression = function (node, st, c) {
|
| 337 |
+
for (var i = 0, list = node.expressions; i < list.length; i += 1)
|
| 338 |
+
{
|
| 339 |
+
var expr = list[i];
|
| 340 |
+
|
| 341 |
+
c(expr, st, "Expression");
|
| 342 |
+
}
|
| 343 |
+
};
|
| 344 |
+
base.TemplateLiteral = function (node, st, c) {
|
| 345 |
+
for (var i = 0, list = node.quasis; i < list.length; i += 1)
|
| 346 |
+
{
|
| 347 |
+
var quasi = list[i];
|
| 348 |
+
|
| 349 |
+
c(quasi, st);
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
for (var i$1 = 0, list$1 = node.expressions; i$1 < list$1.length; i$1 += 1)
|
| 353 |
+
{
|
| 354 |
+
var expr = list$1[i$1];
|
| 355 |
+
|
| 356 |
+
c(expr, st, "Expression");
|
| 357 |
+
}
|
| 358 |
+
};
|
| 359 |
+
base.TemplateElement = ignore;
|
| 360 |
+
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
|
| 361 |
+
c(node.argument, st, "Expression");
|
| 362 |
+
};
|
| 363 |
+
base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
|
| 364 |
+
c(node.left, st, "Expression");
|
| 365 |
+
c(node.right, st, "Expression");
|
| 366 |
+
};
|
| 367 |
+
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
|
| 368 |
+
c(node.left, st, "Pattern");
|
| 369 |
+
c(node.right, st, "Expression");
|
| 370 |
+
};
|
| 371 |
+
base.ConditionalExpression = function (node, st, c) {
|
| 372 |
+
c(node.test, st, "Expression");
|
| 373 |
+
c(node.consequent, st, "Expression");
|
| 374 |
+
c(node.alternate, st, "Expression");
|
| 375 |
+
};
|
| 376 |
+
base.NewExpression = base.CallExpression = function (node, st, c) {
|
| 377 |
+
c(node.callee, st, "Expression");
|
| 378 |
+
if (node.arguments)
|
| 379 |
+
{ for (var i = 0, list = node.arguments; i < list.length; i += 1)
|
| 380 |
+
{
|
| 381 |
+
var arg = list[i];
|
| 382 |
+
|
| 383 |
+
c(arg, st, "Expression");
|
| 384 |
+
} }
|
| 385 |
+
};
|
| 386 |
+
base.MemberExpression = function (node, st, c) {
|
| 387 |
+
c(node.object, st, "Expression");
|
| 388 |
+
if (node.computed) { c(node.property, st, "Expression"); }
|
| 389 |
+
};
|
| 390 |
+
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
|
| 391 |
+
if (node.declaration)
|
| 392 |
+
{ c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); }
|
| 393 |
+
if (node.source) { c(node.source, st, "Expression"); }
|
| 394 |
+
};
|
| 395 |
+
base.ExportAllDeclaration = function (node, st, c) {
|
| 396 |
+
if (node.exported)
|
| 397 |
+
{ c(node.exported, st); }
|
| 398 |
+
c(node.source, st, "Expression");
|
| 399 |
+
};
|
| 400 |
+
base.ImportDeclaration = function (node, st, c) {
|
| 401 |
+
for (var i = 0, list = node.specifiers; i < list.length; i += 1)
|
| 402 |
+
{
|
| 403 |
+
var spec = list[i];
|
| 404 |
+
|
| 405 |
+
c(spec, st);
|
| 406 |
+
}
|
| 407 |
+
c(node.source, st, "Expression");
|
| 408 |
+
};
|
| 409 |
+
base.ImportExpression = function (node, st, c) {
|
| 410 |
+
c(node.source, st, "Expression");
|
| 411 |
+
};
|
| 412 |
+
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.PrivateIdentifier = base.Literal = ignore;
|
| 413 |
+
|
| 414 |
+
base.TaggedTemplateExpression = function (node, st, c) {
|
| 415 |
+
c(node.tag, st, "Expression");
|
| 416 |
+
c(node.quasi, st, "Expression");
|
| 417 |
+
};
|
| 418 |
+
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); };
|
| 419 |
+
base.Class = function (node, st, c) {
|
| 420 |
+
if (node.id) { c(node.id, st, "Pattern"); }
|
| 421 |
+
if (node.superClass) { c(node.superClass, st, "Expression"); }
|
| 422 |
+
c(node.body, st);
|
| 423 |
+
};
|
| 424 |
+
base.ClassBody = function (node, st, c) {
|
| 425 |
+
for (var i = 0, list = node.body; i < list.length; i += 1)
|
| 426 |
+
{
|
| 427 |
+
var elt = list[i];
|
| 428 |
+
|
| 429 |
+
c(elt, st);
|
| 430 |
+
}
|
| 431 |
+
};
|
| 432 |
+
base.MethodDefinition = base.PropertyDefinition = base.Property = function (node, st, c) {
|
| 433 |
+
if (node.computed) { c(node.key, st, "Expression"); }
|
| 434 |
+
if (node.value) { c(node.value, st, "Expression"); }
|
| 435 |
+
};
|
| 436 |
+
|
| 437 |
+
export { ancestor, base, findNodeAfter, findNodeAround, findNodeAt, findNodeBefore, full, fullAncestor, make, recursive, simple };
|
novas/novacore-zephyr/groq-code-cli/node_modules/acorn/bin/acorn
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env node
|
| 2 |
+
"use strict"
|
| 3 |
+
|
| 4 |
+
require("../dist/bin.js")
|
novas/novacore-zephyr/groq-code-cli/node_modules/acorn/dist/acorn.d.mts
ADDED
|
@@ -0,0 +1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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export interface Node {
|
| 2 |
+
start: number
|
| 3 |
+
end: number
|
| 4 |
+
type: string
|
| 5 |
+
range?: [number, number]
|
| 6 |
+
loc?: SourceLocation | null
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
export interface SourceLocation {
|
| 10 |
+
source?: string | null
|
| 11 |
+
start: Position
|
| 12 |
+
end: Position
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
export interface Position {
|
| 16 |
+
/** 1-based */
|
| 17 |
+
line: number
|
| 18 |
+
/** 0-based */
|
| 19 |
+
column: number
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
export interface Identifier extends Node {
|
| 23 |
+
type: "Identifier"
|
| 24 |
+
name: string
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
export interface Literal extends Node {
|
| 28 |
+
type: "Literal"
|
| 29 |
+
value?: string | boolean | null | number | RegExp | bigint
|
| 30 |
+
raw?: string
|
| 31 |
+
regex?: {
|
| 32 |
+
pattern: string
|
| 33 |
+
flags: string
|
| 34 |
+
}
|
| 35 |
+
bigint?: string
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
export interface Program extends Node {
|
| 39 |
+
type: "Program"
|
| 40 |
+
body: Array<Statement | ModuleDeclaration>
|
| 41 |
+
sourceType: "script" | "module"
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
export interface Function extends Node {
|
| 45 |
+
id?: Identifier | null
|
| 46 |
+
params: Array<Pattern>
|
| 47 |
+
body: BlockStatement | Expression
|
| 48 |
+
generator: boolean
|
| 49 |
+
expression: boolean
|
| 50 |
+
async: boolean
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
export interface ExpressionStatement extends Node {
|
| 54 |
+
type: "ExpressionStatement"
|
| 55 |
+
expression: Expression | Literal
|
| 56 |
+
directive?: string
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
export interface BlockStatement extends Node {
|
| 60 |
+
type: "BlockStatement"
|
| 61 |
+
body: Array<Statement>
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
export interface EmptyStatement extends Node {
|
| 65 |
+
type: "EmptyStatement"
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
export interface DebuggerStatement extends Node {
|
| 69 |
+
type: "DebuggerStatement"
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
export interface WithStatement extends Node {
|
| 73 |
+
type: "WithStatement"
|
| 74 |
+
object: Expression
|
| 75 |
+
body: Statement
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
export interface ReturnStatement extends Node {
|
| 79 |
+
type: "ReturnStatement"
|
| 80 |
+
argument?: Expression | null
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
export interface LabeledStatement extends Node {
|
| 84 |
+
type: "LabeledStatement"
|
| 85 |
+
label: Identifier
|
| 86 |
+
body: Statement
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
export interface BreakStatement extends Node {
|
| 90 |
+
type: "BreakStatement"
|
| 91 |
+
label?: Identifier | null
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
export interface ContinueStatement extends Node {
|
| 95 |
+
type: "ContinueStatement"
|
| 96 |
+
label?: Identifier | null
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
export interface IfStatement extends Node {
|
| 100 |
+
type: "IfStatement"
|
| 101 |
+
test: Expression
|
| 102 |
+
consequent: Statement
|
| 103 |
+
alternate?: Statement | null
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
export interface SwitchStatement extends Node {
|
| 107 |
+
type: "SwitchStatement"
|
| 108 |
+
discriminant: Expression
|
| 109 |
+
cases: Array<SwitchCase>
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
export interface SwitchCase extends Node {
|
| 113 |
+
type: "SwitchCase"
|
| 114 |
+
test?: Expression | null
|
| 115 |
+
consequent: Array<Statement>
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
export interface ThrowStatement extends Node {
|
| 119 |
+
type: "ThrowStatement"
|
| 120 |
+
argument: Expression
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
export interface TryStatement extends Node {
|
| 124 |
+
type: "TryStatement"
|
| 125 |
+
block: BlockStatement
|
| 126 |
+
handler?: CatchClause | null
|
| 127 |
+
finalizer?: BlockStatement | null
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
export interface CatchClause extends Node {
|
| 131 |
+
type: "CatchClause"
|
| 132 |
+
param?: Pattern | null
|
| 133 |
+
body: BlockStatement
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
export interface WhileStatement extends Node {
|
| 137 |
+
type: "WhileStatement"
|
| 138 |
+
test: Expression
|
| 139 |
+
body: Statement
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
export interface DoWhileStatement extends Node {
|
| 143 |
+
type: "DoWhileStatement"
|
| 144 |
+
body: Statement
|
| 145 |
+
test: Expression
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
export interface ForStatement extends Node {
|
| 149 |
+
type: "ForStatement"
|
| 150 |
+
init?: VariableDeclaration | Expression | null
|
| 151 |
+
test?: Expression | null
|
| 152 |
+
update?: Expression | null
|
| 153 |
+
body: Statement
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
export interface ForInStatement extends Node {
|
| 157 |
+
type: "ForInStatement"
|
| 158 |
+
left: VariableDeclaration | Pattern
|
| 159 |
+
right: Expression
|
| 160 |
+
body: Statement
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
export interface FunctionDeclaration extends Function {
|
| 164 |
+
type: "FunctionDeclaration"
|
| 165 |
+
id: Identifier
|
| 166 |
+
body: BlockStatement
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
export interface VariableDeclaration extends Node {
|
| 170 |
+
type: "VariableDeclaration"
|
| 171 |
+
declarations: Array<VariableDeclarator>
|
| 172 |
+
kind: "var" | "let" | "const" | "using" | "await using"
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
export interface VariableDeclarator extends Node {
|
| 176 |
+
type: "VariableDeclarator"
|
| 177 |
+
id: Pattern
|
| 178 |
+
init?: Expression | null
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
export interface ThisExpression extends Node {
|
| 182 |
+
type: "ThisExpression"
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
export interface ArrayExpression extends Node {
|
| 186 |
+
type: "ArrayExpression"
|
| 187 |
+
elements: Array<Expression | SpreadElement | null>
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
export interface ObjectExpression extends Node {
|
| 191 |
+
type: "ObjectExpression"
|
| 192 |
+
properties: Array<Property | SpreadElement>
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
export interface Property extends Node {
|
| 196 |
+
type: "Property"
|
| 197 |
+
key: Expression
|
| 198 |
+
value: Expression
|
| 199 |
+
kind: "init" | "get" | "set"
|
| 200 |
+
method: boolean
|
| 201 |
+
shorthand: boolean
|
| 202 |
+
computed: boolean
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
export interface FunctionExpression extends Function {
|
| 206 |
+
type: "FunctionExpression"
|
| 207 |
+
body: BlockStatement
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
export interface UnaryExpression extends Node {
|
| 211 |
+
type: "UnaryExpression"
|
| 212 |
+
operator: UnaryOperator
|
| 213 |
+
prefix: boolean
|
| 214 |
+
argument: Expression
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
export type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete"
|
| 218 |
+
|
| 219 |
+
export interface UpdateExpression extends Node {
|
| 220 |
+
type: "UpdateExpression"
|
| 221 |
+
operator: UpdateOperator
|
| 222 |
+
argument: Expression
|
| 223 |
+
prefix: boolean
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
export type UpdateOperator = "++" | "--"
|
| 227 |
+
|
| 228 |
+
export interface BinaryExpression extends Node {
|
| 229 |
+
type: "BinaryExpression"
|
| 230 |
+
operator: BinaryOperator
|
| 231 |
+
left: Expression | PrivateIdentifier
|
| 232 |
+
right: Expression
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
export type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "in" | "instanceof" | "**"
|
| 236 |
+
|
| 237 |
+
export interface AssignmentExpression extends Node {
|
| 238 |
+
type: "AssignmentExpression"
|
| 239 |
+
operator: AssignmentOperator
|
| 240 |
+
left: Pattern
|
| 241 |
+
right: Expression
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
export type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "**=" | "||=" | "&&=" | "??="
|
| 245 |
+
|
| 246 |
+
export interface LogicalExpression extends Node {
|
| 247 |
+
type: "LogicalExpression"
|
| 248 |
+
operator: LogicalOperator
|
| 249 |
+
left: Expression
|
| 250 |
+
right: Expression
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
export type LogicalOperator = "||" | "&&" | "??"
|
| 254 |
+
|
| 255 |
+
export interface MemberExpression extends Node {
|
| 256 |
+
type: "MemberExpression"
|
| 257 |
+
object: Expression | Super
|
| 258 |
+
property: Expression | PrivateIdentifier
|
| 259 |
+
computed: boolean
|
| 260 |
+
optional: boolean
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
export interface ConditionalExpression extends Node {
|
| 264 |
+
type: "ConditionalExpression"
|
| 265 |
+
test: Expression
|
| 266 |
+
alternate: Expression
|
| 267 |
+
consequent: Expression
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
export interface CallExpression extends Node {
|
| 271 |
+
type: "CallExpression"
|
| 272 |
+
callee: Expression | Super
|
| 273 |
+
arguments: Array<Expression | SpreadElement>
|
| 274 |
+
optional: boolean
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
export interface NewExpression extends Node {
|
| 278 |
+
type: "NewExpression"
|
| 279 |
+
callee: Expression
|
| 280 |
+
arguments: Array<Expression | SpreadElement>
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
export interface SequenceExpression extends Node {
|
| 284 |
+
type: "SequenceExpression"
|
| 285 |
+
expressions: Array<Expression>
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
export interface ForOfStatement extends Node {
|
| 289 |
+
type: "ForOfStatement"
|
| 290 |
+
left: VariableDeclaration | Pattern
|
| 291 |
+
right: Expression
|
| 292 |
+
body: Statement
|
| 293 |
+
await: boolean
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
export interface Super extends Node {
|
| 297 |
+
type: "Super"
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
export interface SpreadElement extends Node {
|
| 301 |
+
type: "SpreadElement"
|
| 302 |
+
argument: Expression
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
export interface ArrowFunctionExpression extends Function {
|
| 306 |
+
type: "ArrowFunctionExpression"
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
export interface YieldExpression extends Node {
|
| 310 |
+
type: "YieldExpression"
|
| 311 |
+
argument?: Expression | null
|
| 312 |
+
delegate: boolean
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
export interface TemplateLiteral extends Node {
|
| 316 |
+
type: "TemplateLiteral"
|
| 317 |
+
quasis: Array<TemplateElement>
|
| 318 |
+
expressions: Array<Expression>
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
export interface TaggedTemplateExpression extends Node {
|
| 322 |
+
type: "TaggedTemplateExpression"
|
| 323 |
+
tag: Expression
|
| 324 |
+
quasi: TemplateLiteral
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
export interface TemplateElement extends Node {
|
| 328 |
+
type: "TemplateElement"
|
| 329 |
+
tail: boolean
|
| 330 |
+
value: {
|
| 331 |
+
cooked?: string | null
|
| 332 |
+
raw: string
|
| 333 |
+
}
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
export interface AssignmentProperty extends Node {
|
| 337 |
+
type: "Property"
|
| 338 |
+
key: Expression
|
| 339 |
+
value: Pattern
|
| 340 |
+
kind: "init"
|
| 341 |
+
method: false
|
| 342 |
+
shorthand: boolean
|
| 343 |
+
computed: boolean
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
export interface ObjectPattern extends Node {
|
| 347 |
+
type: "ObjectPattern"
|
| 348 |
+
properties: Array<AssignmentProperty | RestElement>
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
export interface ArrayPattern extends Node {
|
| 352 |
+
type: "ArrayPattern"
|
| 353 |
+
elements: Array<Pattern | null>
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
export interface RestElement extends Node {
|
| 357 |
+
type: "RestElement"
|
| 358 |
+
argument: Pattern
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
export interface AssignmentPattern extends Node {
|
| 362 |
+
type: "AssignmentPattern"
|
| 363 |
+
left: Pattern
|
| 364 |
+
right: Expression
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
export interface Class extends Node {
|
| 368 |
+
id?: Identifier | null
|
| 369 |
+
superClass?: Expression | null
|
| 370 |
+
body: ClassBody
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
export interface ClassBody extends Node {
|
| 374 |
+
type: "ClassBody"
|
| 375 |
+
body: Array<MethodDefinition | PropertyDefinition | StaticBlock>
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
export interface MethodDefinition extends Node {
|
| 379 |
+
type: "MethodDefinition"
|
| 380 |
+
key: Expression | PrivateIdentifier
|
| 381 |
+
value: FunctionExpression
|
| 382 |
+
kind: "constructor" | "method" | "get" | "set"
|
| 383 |
+
computed: boolean
|
| 384 |
+
static: boolean
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
export interface ClassDeclaration extends Class {
|
| 388 |
+
type: "ClassDeclaration"
|
| 389 |
+
id: Identifier
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
export interface ClassExpression extends Class {
|
| 393 |
+
type: "ClassExpression"
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
export interface MetaProperty extends Node {
|
| 397 |
+
type: "MetaProperty"
|
| 398 |
+
meta: Identifier
|
| 399 |
+
property: Identifier
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
export interface ImportDeclaration extends Node {
|
| 403 |
+
type: "ImportDeclaration"
|
| 404 |
+
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>
|
| 405 |
+
source: Literal
|
| 406 |
+
attributes: Array<ImportAttribute>
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
export interface ImportSpecifier extends Node {
|
| 410 |
+
type: "ImportSpecifier"
|
| 411 |
+
imported: Identifier | Literal
|
| 412 |
+
local: Identifier
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
export interface ImportDefaultSpecifier extends Node {
|
| 416 |
+
type: "ImportDefaultSpecifier"
|
| 417 |
+
local: Identifier
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
export interface ImportNamespaceSpecifier extends Node {
|
| 421 |
+
type: "ImportNamespaceSpecifier"
|
| 422 |
+
local: Identifier
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
export interface ImportAttribute extends Node {
|
| 426 |
+
type: "ImportAttribute"
|
| 427 |
+
key: Identifier | Literal
|
| 428 |
+
value: Literal
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
export interface ExportNamedDeclaration extends Node {
|
| 432 |
+
type: "ExportNamedDeclaration"
|
| 433 |
+
declaration?: Declaration | null
|
| 434 |
+
specifiers: Array<ExportSpecifier>
|
| 435 |
+
source?: Literal | null
|
| 436 |
+
attributes: Array<ImportAttribute>
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
export interface ExportSpecifier extends Node {
|
| 440 |
+
type: "ExportSpecifier"
|
| 441 |
+
exported: Identifier | Literal
|
| 442 |
+
local: Identifier | Literal
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
export interface AnonymousFunctionDeclaration extends Function {
|
| 446 |
+
type: "FunctionDeclaration"
|
| 447 |
+
id: null
|
| 448 |
+
body: BlockStatement
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
export interface AnonymousClassDeclaration extends Class {
|
| 452 |
+
type: "ClassDeclaration"
|
| 453 |
+
id: null
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
export interface ExportDefaultDeclaration extends Node {
|
| 457 |
+
type: "ExportDefaultDeclaration"
|
| 458 |
+
declaration: AnonymousFunctionDeclaration | FunctionDeclaration | AnonymousClassDeclaration | ClassDeclaration | Expression
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
export interface ExportAllDeclaration extends Node {
|
| 462 |
+
type: "ExportAllDeclaration"
|
| 463 |
+
source: Literal
|
| 464 |
+
exported?: Identifier | Literal | null
|
| 465 |
+
attributes: Array<ImportAttribute>
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
export interface AwaitExpression extends Node {
|
| 469 |
+
type: "AwaitExpression"
|
| 470 |
+
argument: Expression
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
export interface ChainExpression extends Node {
|
| 474 |
+
type: "ChainExpression"
|
| 475 |
+
expression: MemberExpression | CallExpression
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
export interface ImportExpression extends Node {
|
| 479 |
+
type: "ImportExpression"
|
| 480 |
+
source: Expression
|
| 481 |
+
options: Expression | null
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
export interface ParenthesizedExpression extends Node {
|
| 485 |
+
type: "ParenthesizedExpression"
|
| 486 |
+
expression: Expression
|
| 487 |
+
}
|
| 488 |
+
|
| 489 |
+
export interface PropertyDefinition extends Node {
|
| 490 |
+
type: "PropertyDefinition"
|
| 491 |
+
key: Expression | PrivateIdentifier
|
| 492 |
+
value?: Expression | null
|
| 493 |
+
computed: boolean
|
| 494 |
+
static: boolean
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
export interface PrivateIdentifier extends Node {
|
| 498 |
+
type: "PrivateIdentifier"
|
| 499 |
+
name: string
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
export interface StaticBlock extends Node {
|
| 503 |
+
type: "StaticBlock"
|
| 504 |
+
body: Array<Statement>
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
+
export type Statement =
|
| 508 |
+
| ExpressionStatement
|
| 509 |
+
| BlockStatement
|
| 510 |
+
| EmptyStatement
|
| 511 |
+
| DebuggerStatement
|
| 512 |
+
| WithStatement
|
| 513 |
+
| ReturnStatement
|
| 514 |
+
| LabeledStatement
|
| 515 |
+
| BreakStatement
|
| 516 |
+
| ContinueStatement
|
| 517 |
+
| IfStatement
|
| 518 |
+
| SwitchStatement
|
| 519 |
+
| ThrowStatement
|
| 520 |
+
| TryStatement
|
| 521 |
+
| WhileStatement
|
| 522 |
+
| DoWhileStatement
|
| 523 |
+
| ForStatement
|
| 524 |
+
| ForInStatement
|
| 525 |
+
| ForOfStatement
|
| 526 |
+
| Declaration
|
| 527 |
+
|
| 528 |
+
export type Declaration =
|
| 529 |
+
| FunctionDeclaration
|
| 530 |
+
| VariableDeclaration
|
| 531 |
+
| ClassDeclaration
|
| 532 |
+
|
| 533 |
+
export type Expression =
|
| 534 |
+
| Identifier
|
| 535 |
+
| Literal
|
| 536 |
+
| ThisExpression
|
| 537 |
+
| ArrayExpression
|
| 538 |
+
| ObjectExpression
|
| 539 |
+
| FunctionExpression
|
| 540 |
+
| UnaryExpression
|
| 541 |
+
| UpdateExpression
|
| 542 |
+
| BinaryExpression
|
| 543 |
+
| AssignmentExpression
|
| 544 |
+
| LogicalExpression
|
| 545 |
+
| MemberExpression
|
| 546 |
+
| ConditionalExpression
|
| 547 |
+
| CallExpression
|
| 548 |
+
| NewExpression
|
| 549 |
+
| SequenceExpression
|
| 550 |
+
| ArrowFunctionExpression
|
| 551 |
+
| YieldExpression
|
| 552 |
+
| TemplateLiteral
|
| 553 |
+
| TaggedTemplateExpression
|
| 554 |
+
| ClassExpression
|
| 555 |
+
| MetaProperty
|
| 556 |
+
| AwaitExpression
|
| 557 |
+
| ChainExpression
|
| 558 |
+
| ImportExpression
|
| 559 |
+
| ParenthesizedExpression
|
| 560 |
+
|
| 561 |
+
export type Pattern =
|
| 562 |
+
| Identifier
|
| 563 |
+
| MemberExpression
|
| 564 |
+
| ObjectPattern
|
| 565 |
+
| ArrayPattern
|
| 566 |
+
| RestElement
|
| 567 |
+
| AssignmentPattern
|
| 568 |
+
|
| 569 |
+
export type ModuleDeclaration =
|
| 570 |
+
| ImportDeclaration
|
| 571 |
+
| ExportNamedDeclaration
|
| 572 |
+
| ExportDefaultDeclaration
|
| 573 |
+
| ExportAllDeclaration
|
| 574 |
+
|
| 575 |
+
/**
|
| 576 |
+
* This interface is only used for defining {@link AnyNode}.
|
| 577 |
+
* It exists so that it can be extended by plugins:
|
| 578 |
+
*
|
| 579 |
+
* @example
|
| 580 |
+
* ```typescript
|
| 581 |
+
* declare module 'acorn' {
|
| 582 |
+
* interface NodeTypes {
|
| 583 |
+
* pluginName: FirstNode | SecondNode | ThirdNode | ... | LastNode
|
| 584 |
+
* }
|
| 585 |
+
* }
|
| 586 |
+
* ```
|
| 587 |
+
*/
|
| 588 |
+
interface NodeTypes {
|
| 589 |
+
core: Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
export type AnyNode = NodeTypes[keyof NodeTypes]
|
| 593 |
+
|
| 594 |
+
export function parse(input: string, options: Options): Program
|
| 595 |
+
|
| 596 |
+
export function parseExpressionAt(input: string, pos: number, options: Options): Expression
|
| 597 |
+
|
| 598 |
+
export function tokenizer(input: string, options: Options): {
|
| 599 |
+
getToken(): Token
|
| 600 |
+
[Symbol.iterator](): Iterator<Token>
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026 | "latest"
|
| 604 |
+
|
| 605 |
+
export interface Options {
|
| 606 |
+
/**
|
| 607 |
+
* `ecmaVersion` indicates the ECMAScript version to parse. Can be a
|
| 608 |
+
* number, either in year (`2022`) or plain version number (`6`) form,
|
| 609 |
+
* or `"latest"` (the latest the library supports). This influences
|
| 610 |
+
* support for strict mode, the set of reserved words, and support for
|
| 611 |
+
* new syntax features.
|
| 612 |
+
*/
|
| 613 |
+
ecmaVersion: ecmaVersion
|
| 614 |
+
|
| 615 |
+
/**
|
| 616 |
+
* `sourceType` indicates the mode the code should be parsed in.
|
| 617 |
+
* Can be either `"script"` or `"module"`. This influences global
|
| 618 |
+
* strict mode and parsing of `import` and `export` declarations.
|
| 619 |
+
*/
|
| 620 |
+
sourceType?: "script" | "module"
|
| 621 |
+
|
| 622 |
+
/**
|
| 623 |
+
* a callback that will be called when a semicolon is automatically inserted.
|
| 624 |
+
* @param lastTokEnd the position of the comma as an offset
|
| 625 |
+
* @param lastTokEndLoc location if {@link locations} is enabled
|
| 626 |
+
*/
|
| 627 |
+
onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
|
| 628 |
+
|
| 629 |
+
/**
|
| 630 |
+
* similar to `onInsertedSemicolon`, but for trailing commas
|
| 631 |
+
* @param lastTokEnd the position of the comma as an offset
|
| 632 |
+
* @param lastTokEndLoc location if `locations` is enabled
|
| 633 |
+
*/
|
| 634 |
+
onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
|
| 635 |
+
|
| 636 |
+
/**
|
| 637 |
+
* By default, reserved words are only enforced if ecmaVersion >= 5.
|
| 638 |
+
* Set `allowReserved` to a boolean value to explicitly turn this on
|
| 639 |
+
* an off. When this option has the value "never", reserved words
|
| 640 |
+
* and keywords can also not be used as property names.
|
| 641 |
+
*/
|
| 642 |
+
allowReserved?: boolean | "never"
|
| 643 |
+
|
| 644 |
+
/**
|
| 645 |
+
* When enabled, a return at the top level is not considered an error.
|
| 646 |
+
*/
|
| 647 |
+
allowReturnOutsideFunction?: boolean
|
| 648 |
+
|
| 649 |
+
/**
|
| 650 |
+
* When enabled, import/export statements are not constrained to
|
| 651 |
+
* appearing at the top of the program, and an import.meta expression
|
| 652 |
+
* in a script isn't considered an error.
|
| 653 |
+
*/
|
| 654 |
+
allowImportExportEverywhere?: boolean
|
| 655 |
+
|
| 656 |
+
/**
|
| 657 |
+
* By default, `await` identifiers are allowed to appear at the top-level scope only if {@link ecmaVersion} >= 2022.
|
| 658 |
+
* When enabled, await identifiers are allowed to appear at the top-level scope,
|
| 659 |
+
* but they are still not allowed in non-async functions.
|
| 660 |
+
*/
|
| 661 |
+
allowAwaitOutsideFunction?: boolean
|
| 662 |
+
|
| 663 |
+
/**
|
| 664 |
+
* When enabled, super identifiers are not constrained to
|
| 665 |
+
* appearing in methods and do not raise an error when they appear elsewhere.
|
| 666 |
+
*/
|
| 667 |
+
allowSuperOutsideMethod?: boolean
|
| 668 |
+
|
| 669 |
+
/**
|
| 670 |
+
* When enabled, hashbang directive in the beginning of file is
|
| 671 |
+
* allowed and treated as a line comment. Enabled by default when
|
| 672 |
+
* {@link ecmaVersion} >= 2023.
|
| 673 |
+
*/
|
| 674 |
+
allowHashBang?: boolean
|
| 675 |
+
|
| 676 |
+
/**
|
| 677 |
+
* By default, the parser will verify that private properties are
|
| 678 |
+
* only used in places where they are valid and have been declared.
|
| 679 |
+
* Set this to false to turn such checks off.
|
| 680 |
+
*/
|
| 681 |
+
checkPrivateFields?: boolean
|
| 682 |
+
|
| 683 |
+
/**
|
| 684 |
+
* When `locations` is on, `loc` properties holding objects with
|
| 685 |
+
* `start` and `end` properties as {@link Position} objects will be attached to the
|
| 686 |
+
* nodes.
|
| 687 |
+
*/
|
| 688 |
+
locations?: boolean
|
| 689 |
+
|
| 690 |
+
/**
|
| 691 |
+
* a callback that will cause Acorn to call that export function with object in the same
|
| 692 |
+
* format as tokens returned from `tokenizer().getToken()`. Note
|
| 693 |
+
* that you are not allowed to call the parser from the
|
| 694 |
+
* callback—that will corrupt its internal state.
|
| 695 |
+
*/
|
| 696 |
+
onToken?: ((token: Token) => void) | Token[]
|
| 697 |
+
|
| 698 |
+
|
| 699 |
+
/**
|
| 700 |
+
* This takes a export function or an array.
|
| 701 |
+
*
|
| 702 |
+
* When a export function is passed, Acorn will call that export function with `(block, text, start,
|
| 703 |
+
* end)` parameters whenever a comment is skipped. `block` is a
|
| 704 |
+
* boolean indicating whether this is a block (`/* *\/`) comment,
|
| 705 |
+
* `text` is the content of the comment, and `start` and `end` are
|
| 706 |
+
* character offsets that denote the start and end of the comment.
|
| 707 |
+
* When the {@link locations} option is on, two more parameters are
|
| 708 |
+
* passed, the full locations of {@link Position} export type of the start and
|
| 709 |
+
* end of the comments.
|
| 710 |
+
*
|
| 711 |
+
* When a array is passed, each found comment of {@link Comment} export type is pushed to the array.
|
| 712 |
+
*
|
| 713 |
+
* Note that you are not allowed to call the
|
| 714 |
+
* parser from the callback—that will corrupt its internal state.
|
| 715 |
+
*/
|
| 716 |
+
onComment?: ((
|
| 717 |
+
isBlock: boolean, text: string, start: number, end: number, startLoc?: Position,
|
| 718 |
+
endLoc?: Position
|
| 719 |
+
) => void) | Comment[]
|
| 720 |
+
|
| 721 |
+
/**
|
| 722 |
+
* Nodes have their start and end characters offsets recorded in
|
| 723 |
+
* `start` and `end` properties (directly on the node, rather than
|
| 724 |
+
* the `loc` object, which holds line/column data. To also add a
|
| 725 |
+
* [semi-standardized][range] `range` property holding a `[start,
|
| 726 |
+
* end]` array with the same numbers, set the `ranges` option to
|
| 727 |
+
* `true`.
|
| 728 |
+
*/
|
| 729 |
+
ranges?: boolean
|
| 730 |
+
|
| 731 |
+
/**
|
| 732 |
+
* It is possible to parse multiple files into a single AST by
|
| 733 |
+
* passing the tree produced by parsing the first file as
|
| 734 |
+
* `program` option in subsequent parses. This will add the
|
| 735 |
+
* toplevel forms of the parsed file to the `Program` (top) node
|
| 736 |
+
* of an existing parse tree.
|
| 737 |
+
*/
|
| 738 |
+
program?: Node
|
| 739 |
+
|
| 740 |
+
/**
|
| 741 |
+
* When {@link locations} is on, you can pass this to record the source
|
| 742 |
+
* file in every node's `loc` object.
|
| 743 |
+
*/
|
| 744 |
+
sourceFile?: string
|
| 745 |
+
|
| 746 |
+
/**
|
| 747 |
+
* This value, if given, is stored in every node, whether {@link locations} is on or off.
|
| 748 |
+
*/
|
| 749 |
+
directSourceFile?: string
|
| 750 |
+
|
| 751 |
+
/**
|
| 752 |
+
* When enabled, parenthesized expressions are represented by
|
| 753 |
+
* (non-standard) ParenthesizedExpression nodes
|
| 754 |
+
*/
|
| 755 |
+
preserveParens?: boolean
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
+
export class Parser {
|
| 759 |
+
options: Options
|
| 760 |
+
input: string
|
| 761 |
+
|
| 762 |
+
protected constructor(options: Options, input: string, startPos?: number)
|
| 763 |
+
parse(): Program
|
| 764 |
+
|
| 765 |
+
static parse(input: string, options: Options): Program
|
| 766 |
+
static parseExpressionAt(input: string, pos: number, options: Options): Expression
|
| 767 |
+
static tokenizer(input: string, options: Options): {
|
| 768 |
+
getToken(): Token
|
| 769 |
+
[Symbol.iterator](): Iterator<Token>
|
| 770 |
+
}
|
| 771 |
+
static extend(...plugins: ((BaseParser: typeof Parser) => typeof Parser)[]): typeof Parser
|
| 772 |
+
}
|
| 773 |
+
|
| 774 |
+
export const defaultOptions: Options
|
| 775 |
+
|
| 776 |
+
export function getLineInfo(input: string, offset: number): Position
|
| 777 |
+
|
| 778 |
+
export class TokenType {
|
| 779 |
+
label: string
|
| 780 |
+
keyword: string | undefined
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
export const tokTypes: {
|
| 784 |
+
num: TokenType
|
| 785 |
+
regexp: TokenType
|
| 786 |
+
string: TokenType
|
| 787 |
+
name: TokenType
|
| 788 |
+
privateId: TokenType
|
| 789 |
+
eof: TokenType
|
| 790 |
+
|
| 791 |
+
bracketL: TokenType
|
| 792 |
+
bracketR: TokenType
|
| 793 |
+
braceL: TokenType
|
| 794 |
+
braceR: TokenType
|
| 795 |
+
parenL: TokenType
|
| 796 |
+
parenR: TokenType
|
| 797 |
+
comma: TokenType
|
| 798 |
+
semi: TokenType
|
| 799 |
+
colon: TokenType
|
| 800 |
+
dot: TokenType
|
| 801 |
+
question: TokenType
|
| 802 |
+
questionDot: TokenType
|
| 803 |
+
arrow: TokenType
|
| 804 |
+
template: TokenType
|
| 805 |
+
invalidTemplate: TokenType
|
| 806 |
+
ellipsis: TokenType
|
| 807 |
+
backQuote: TokenType
|
| 808 |
+
dollarBraceL: TokenType
|
| 809 |
+
|
| 810 |
+
eq: TokenType
|
| 811 |
+
assign: TokenType
|
| 812 |
+
incDec: TokenType
|
| 813 |
+
prefix: TokenType
|
| 814 |
+
logicalOR: TokenType
|
| 815 |
+
logicalAND: TokenType
|
| 816 |
+
bitwiseOR: TokenType
|
| 817 |
+
bitwiseXOR: TokenType
|
| 818 |
+
bitwiseAND: TokenType
|
| 819 |
+
equality: TokenType
|
| 820 |
+
relational: TokenType
|
| 821 |
+
bitShift: TokenType
|
| 822 |
+
plusMin: TokenType
|
| 823 |
+
modulo: TokenType
|
| 824 |
+
star: TokenType
|
| 825 |
+
slash: TokenType
|
| 826 |
+
starstar: TokenType
|
| 827 |
+
coalesce: TokenType
|
| 828 |
+
|
| 829 |
+
_break: TokenType
|
| 830 |
+
_case: TokenType
|
| 831 |
+
_catch: TokenType
|
| 832 |
+
_continue: TokenType
|
| 833 |
+
_debugger: TokenType
|
| 834 |
+
_default: TokenType
|
| 835 |
+
_do: TokenType
|
| 836 |
+
_else: TokenType
|
| 837 |
+
_finally: TokenType
|
| 838 |
+
_for: TokenType
|
| 839 |
+
_function: TokenType
|
| 840 |
+
_if: TokenType
|
| 841 |
+
_return: TokenType
|
| 842 |
+
_switch: TokenType
|
| 843 |
+
_throw: TokenType
|
| 844 |
+
_try: TokenType
|
| 845 |
+
_var: TokenType
|
| 846 |
+
_const: TokenType
|
| 847 |
+
_while: TokenType
|
| 848 |
+
_with: TokenType
|
| 849 |
+
_new: TokenType
|
| 850 |
+
_this: TokenType
|
| 851 |
+
_super: TokenType
|
| 852 |
+
_class: TokenType
|
| 853 |
+
_extends: TokenType
|
| 854 |
+
_export: TokenType
|
| 855 |
+
_import: TokenType
|
| 856 |
+
_null: TokenType
|
| 857 |
+
_true: TokenType
|
| 858 |
+
_false: TokenType
|
| 859 |
+
_in: TokenType
|
| 860 |
+
_instanceof: TokenType
|
| 861 |
+
_typeof: TokenType
|
| 862 |
+
_void: TokenType
|
| 863 |
+
_delete: TokenType
|
| 864 |
+
}
|
| 865 |
+
|
| 866 |
+
export interface Comment {
|
| 867 |
+
type: "Line" | "Block"
|
| 868 |
+
value: string
|
| 869 |
+
start: number
|
| 870 |
+
end: number
|
| 871 |
+
loc?: SourceLocation
|
| 872 |
+
range?: [number, number]
|
| 873 |
+
}
|
| 874 |
+
|
| 875 |
+
export class Token {
|
| 876 |
+
type: TokenType
|
| 877 |
+
start: number
|
| 878 |
+
end: number
|
| 879 |
+
lo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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export interface Node {
|
| 2 |
+
start: number
|
| 3 |
+
end: number
|
| 4 |
+
type: string
|
| 5 |
+
range?: [number, number]
|
| 6 |
+
loc?: SourceLocation | null
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
export interface SourceLocation {
|
| 10 |
+
source?: string | null
|
| 11 |
+
start: Position
|
| 12 |
+
end: Position
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
export interface Position {
|
| 16 |
+
/** 1-based */
|
| 17 |
+
line: number
|
| 18 |
+
/** 0-based */
|
| 19 |
+
column: number
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
export interface Identifier extends Node {
|
| 23 |
+
type: "Identifier"
|
| 24 |
+
name: string
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
export interface Literal extends Node {
|
| 28 |
+
type: "Literal"
|
| 29 |
+
value?: string | boolean | null | number | RegExp | bigint
|
| 30 |
+
raw?: string
|
| 31 |
+
regex?: {
|
| 32 |
+
pattern: string
|
| 33 |
+
flags: string
|
| 34 |
+
}
|
| 35 |
+
bigint?: string
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
export interface Program extends Node {
|
| 39 |
+
type: "Program"
|
| 40 |
+
body: Array<Statement | ModuleDeclaration>
|
| 41 |
+
sourceType: "script" | "module"
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
export interface Function extends Node {
|
| 45 |
+
id?: Identifier | null
|
| 46 |
+
params: Array<Pattern>
|
| 47 |
+
body: BlockStatement | Expression
|
| 48 |
+
generator: boolean
|
| 49 |
+
expression: boolean
|
| 50 |
+
async: boolean
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
export interface ExpressionStatement extends Node {
|
| 54 |
+
type: "ExpressionStatement"
|
| 55 |
+
expression: Expression | Literal
|
| 56 |
+
directive?: string
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
export interface BlockStatement extends Node {
|
| 60 |
+
type: "BlockStatement"
|
| 61 |
+
body: Array<Statement>
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
export interface EmptyStatement extends Node {
|
| 65 |
+
type: "EmptyStatement"
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
export interface DebuggerStatement extends Node {
|
| 69 |
+
type: "DebuggerStatement"
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
export interface WithStatement extends Node {
|
| 73 |
+
type: "WithStatement"
|
| 74 |
+
object: Expression
|
| 75 |
+
body: Statement
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
export interface ReturnStatement extends Node {
|
| 79 |
+
type: "ReturnStatement"
|
| 80 |
+
argument?: Expression | null
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
export interface LabeledStatement extends Node {
|
| 84 |
+
type: "LabeledStatement"
|
| 85 |
+
label: Identifier
|
| 86 |
+
body: Statement
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
export interface BreakStatement extends Node {
|
| 90 |
+
type: "BreakStatement"
|
| 91 |
+
label?: Identifier | null
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
export interface ContinueStatement extends Node {
|
| 95 |
+
type: "ContinueStatement"
|
| 96 |
+
label?: Identifier | null
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
export interface IfStatement extends Node {
|
| 100 |
+
type: "IfStatement"
|
| 101 |
+
test: Expression
|
| 102 |
+
consequent: Statement
|
| 103 |
+
alternate?: Statement | null
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
export interface SwitchStatement extends Node {
|
| 107 |
+
type: "SwitchStatement"
|
| 108 |
+
discriminant: Expression
|
| 109 |
+
cases: Array<SwitchCase>
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
export interface SwitchCase extends Node {
|
| 113 |
+
type: "SwitchCase"
|
| 114 |
+
test?: Expression | null
|
| 115 |
+
consequent: Array<Statement>
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
export interface ThrowStatement extends Node {
|
| 119 |
+
type: "ThrowStatement"
|
| 120 |
+
argument: Expression
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
export interface TryStatement extends Node {
|
| 124 |
+
type: "TryStatement"
|
| 125 |
+
block: BlockStatement
|
| 126 |
+
handler?: CatchClause | null
|
| 127 |
+
finalizer?: BlockStatement | null
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
export interface CatchClause extends Node {
|
| 131 |
+
type: "CatchClause"
|
| 132 |
+
param?: Pattern | null
|
| 133 |
+
body: BlockStatement
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
export interface WhileStatement extends Node {
|
| 137 |
+
type: "WhileStatement"
|
| 138 |
+
test: Expression
|
| 139 |
+
body: Statement
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
export interface DoWhileStatement extends Node {
|
| 143 |
+
type: "DoWhileStatement"
|
| 144 |
+
body: Statement
|
| 145 |
+
test: Expression
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
export interface ForStatement extends Node {
|
| 149 |
+
type: "ForStatement"
|
| 150 |
+
init?: VariableDeclaration | Expression | null
|
| 151 |
+
test?: Expression | null
|
| 152 |
+
update?: Expression | null
|
| 153 |
+
body: Statement
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
export interface ForInStatement extends Node {
|
| 157 |
+
type: "ForInStatement"
|
| 158 |
+
left: VariableDeclaration | Pattern
|
| 159 |
+
right: Expression
|
| 160 |
+
body: Statement
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
export interface FunctionDeclaration extends Function {
|
| 164 |
+
type: "FunctionDeclaration"
|
| 165 |
+
id: Identifier
|
| 166 |
+
body: BlockStatement
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
export interface VariableDeclaration extends Node {
|
| 170 |
+
type: "VariableDeclaration"
|
| 171 |
+
declarations: Array<VariableDeclarator>
|
| 172 |
+
kind: "var" | "let" | "const" | "using" | "await using"
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
export interface VariableDeclarator extends Node {
|
| 176 |
+
type: "VariableDeclarator"
|
| 177 |
+
id: Pattern
|
| 178 |
+
init?: Expression | null
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
export interface ThisExpression extends Node {
|
| 182 |
+
type: "ThisExpression"
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
export interface ArrayExpression extends Node {
|
| 186 |
+
type: "ArrayExpression"
|
| 187 |
+
elements: Array<Expression | SpreadElement | null>
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
export interface ObjectExpression extends Node {
|
| 191 |
+
type: "ObjectExpression"
|
| 192 |
+
properties: Array<Property | SpreadElement>
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
export interface Property extends Node {
|
| 196 |
+
type: "Property"
|
| 197 |
+
key: Expression
|
| 198 |
+
value: Expression
|
| 199 |
+
kind: "init" | "get" | "set"
|
| 200 |
+
method: boolean
|
| 201 |
+
shorthand: boolean
|
| 202 |
+
computed: boolean
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
export interface FunctionExpression extends Function {
|
| 206 |
+
type: "FunctionExpression"
|
| 207 |
+
body: BlockStatement
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
export interface UnaryExpression extends Node {
|
| 211 |
+
type: "UnaryExpression"
|
| 212 |
+
operator: UnaryOperator
|
| 213 |
+
prefix: boolean
|
| 214 |
+
argument: Expression
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
export type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete"
|
| 218 |
+
|
| 219 |
+
export interface UpdateExpression extends Node {
|
| 220 |
+
type: "UpdateExpression"
|
| 221 |
+
operator: UpdateOperator
|
| 222 |
+
argument: Expression
|
| 223 |
+
prefix: boolean
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
export type UpdateOperator = "++" | "--"
|
| 227 |
+
|
| 228 |
+
export interface BinaryExpression extends Node {
|
| 229 |
+
type: "BinaryExpression"
|
| 230 |
+
operator: BinaryOperator
|
| 231 |
+
left: Expression | PrivateIdentifier
|
| 232 |
+
right: Expression
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
export type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "in" | "instanceof" | "**"
|
| 236 |
+
|
| 237 |
+
export interface AssignmentExpression extends Node {
|
| 238 |
+
type: "AssignmentExpression"
|
| 239 |
+
operator: AssignmentOperator
|
| 240 |
+
left: Pattern
|
| 241 |
+
right: Expression
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
export type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "**=" | "||=" | "&&=" | "??="
|
| 245 |
+
|
| 246 |
+
export interface LogicalExpression extends Node {
|
| 247 |
+
type: "LogicalExpression"
|
| 248 |
+
operator: LogicalOperator
|
| 249 |
+
left: Expression
|
| 250 |
+
right: Expression
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
export type LogicalOperator = "||" | "&&" | "??"
|
| 254 |
+
|
| 255 |
+
export interface MemberExpression extends Node {
|
| 256 |
+
type: "MemberExpression"
|
| 257 |
+
object: Expression | Super
|
| 258 |
+
property: Expression | PrivateIdentifier
|
| 259 |
+
computed: boolean
|
| 260 |
+
optional: boolean
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
export interface ConditionalExpression extends Node {
|
| 264 |
+
type: "ConditionalExpression"
|
| 265 |
+
test: Expression
|
| 266 |
+
alternate: Expression
|
| 267 |
+
consequent: Expression
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
export interface CallExpression extends Node {
|
| 271 |
+
type: "CallExpression"
|
| 272 |
+
callee: Expression | Super
|
| 273 |
+
arguments: Array<Expression | SpreadElement>
|
| 274 |
+
optional: boolean
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
export interface NewExpression extends Node {
|
| 278 |
+
type: "NewExpression"
|
| 279 |
+
callee: Expression
|
| 280 |
+
arguments: Array<Expression | SpreadElement>
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
export interface SequenceExpression extends Node {
|
| 284 |
+
type: "SequenceExpression"
|
| 285 |
+
expressions: Array<Expression>
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
export interface ForOfStatement extends Node {
|
| 289 |
+
type: "ForOfStatement"
|
| 290 |
+
left: VariableDeclaration | Pattern
|
| 291 |
+
right: Expression
|
| 292 |
+
body: Statement
|
| 293 |
+
await: boolean
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
export interface Super extends Node {
|
| 297 |
+
type: "Super"
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
export interface SpreadElement extends Node {
|
| 301 |
+
type: "SpreadElement"
|
| 302 |
+
argument: Expression
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
export interface ArrowFunctionExpression extends Function {
|
| 306 |
+
type: "ArrowFunctionExpression"
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
export interface YieldExpression extends Node {
|
| 310 |
+
type: "YieldExpression"
|
| 311 |
+
argument?: Expression | null
|
| 312 |
+
delegate: boolean
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
export interface TemplateLiteral extends Node {
|
| 316 |
+
type: "TemplateLiteral"
|
| 317 |
+
quasis: Array<TemplateElement>
|
| 318 |
+
expressions: Array<Expression>
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
export interface TaggedTemplateExpression extends Node {
|
| 322 |
+
type: "TaggedTemplateExpression"
|
| 323 |
+
tag: Expression
|
| 324 |
+
quasi: TemplateLiteral
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
export interface TemplateElement extends Node {
|
| 328 |
+
type: "TemplateElement"
|
| 329 |
+
tail: boolean
|
| 330 |
+
value: {
|
| 331 |
+
cooked?: string | null
|
| 332 |
+
raw: string
|
| 333 |
+
}
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
export interface AssignmentProperty extends Node {
|
| 337 |
+
type: "Property"
|
| 338 |
+
key: Expression
|
| 339 |
+
value: Pattern
|
| 340 |
+
kind: "init"
|
| 341 |
+
method: false
|
| 342 |
+
shorthand: boolean
|
| 343 |
+
computed: boolean
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
export interface ObjectPattern extends Node {
|
| 347 |
+
type: "ObjectPattern"
|
| 348 |
+
properties: Array<AssignmentProperty | RestElement>
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
export interface ArrayPattern extends Node {
|
| 352 |
+
type: "ArrayPattern"
|
| 353 |
+
elements: Array<Pattern | null>
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
export interface RestElement extends Node {
|
| 357 |
+
type: "RestElement"
|
| 358 |
+
argument: Pattern
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
export interface AssignmentPattern extends Node {
|
| 362 |
+
type: "AssignmentPattern"
|
| 363 |
+
left: Pattern
|
| 364 |
+
right: Expression
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
export interface Class extends Node {
|
| 368 |
+
id?: Identifier | null
|
| 369 |
+
superClass?: Expression | null
|
| 370 |
+
body: ClassBody
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
export interface ClassBody extends Node {
|
| 374 |
+
type: "ClassBody"
|
| 375 |
+
body: Array<MethodDefinition | PropertyDefinition | StaticBlock>
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
export interface MethodDefinition extends Node {
|
| 379 |
+
type: "MethodDefinition"
|
| 380 |
+
key: Expression | PrivateIdentifier
|
| 381 |
+
value: FunctionExpression
|
| 382 |
+
kind: "constructor" | "method" | "get" | "set"
|
| 383 |
+
computed: boolean
|
| 384 |
+
static: boolean
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
export interface ClassDeclaration extends Class {
|
| 388 |
+
type: "ClassDeclaration"
|
| 389 |
+
id: Identifier
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
export interface ClassExpression extends Class {
|
| 393 |
+
type: "ClassExpression"
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
export interface MetaProperty extends Node {
|
| 397 |
+
type: "MetaProperty"
|
| 398 |
+
meta: Identifier
|
| 399 |
+
property: Identifier
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
export interface ImportDeclaration extends Node {
|
| 403 |
+
type: "ImportDeclaration"
|
| 404 |
+
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>
|
| 405 |
+
source: Literal
|
| 406 |
+
attributes: Array<ImportAttribute>
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
export interface ImportSpecifier extends Node {
|
| 410 |
+
type: "ImportSpecifier"
|
| 411 |
+
imported: Identifier | Literal
|
| 412 |
+
local: Identifier
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
export interface ImportDefaultSpecifier extends Node {
|
| 416 |
+
type: "ImportDefaultSpecifier"
|
| 417 |
+
local: Identifier
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
export interface ImportNamespaceSpecifier extends Node {
|
| 421 |
+
type: "ImportNamespaceSpecifier"
|
| 422 |
+
local: Identifier
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
export interface ImportAttribute extends Node {
|
| 426 |
+
type: "ImportAttribute"
|
| 427 |
+
key: Identifier | Literal
|
| 428 |
+
value: Literal
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
export interface ExportNamedDeclaration extends Node {
|
| 432 |
+
type: "ExportNamedDeclaration"
|
| 433 |
+
declaration?: Declaration | null
|
| 434 |
+
specifiers: Array<ExportSpecifier>
|
| 435 |
+
source?: Literal | null
|
| 436 |
+
attributes: Array<ImportAttribute>
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
export interface ExportSpecifier extends Node {
|
| 440 |
+
type: "ExportSpecifier"
|
| 441 |
+
exported: Identifier | Literal
|
| 442 |
+
local: Identifier | Literal
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
export interface AnonymousFunctionDeclaration extends Function {
|
| 446 |
+
type: "FunctionDeclaration"
|
| 447 |
+
id: null
|
| 448 |
+
body: BlockStatement
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
export interface AnonymousClassDeclaration extends Class {
|
| 452 |
+
type: "ClassDeclaration"
|
| 453 |
+
id: null
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
export interface ExportDefaultDeclaration extends Node {
|
| 457 |
+
type: "ExportDefaultDeclaration"
|
| 458 |
+
declaration: AnonymousFunctionDeclaration | FunctionDeclaration | AnonymousClassDeclaration | ClassDeclaration | Expression
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
export interface ExportAllDeclaration extends Node {
|
| 462 |
+
type: "ExportAllDeclaration"
|
| 463 |
+
source: Literal
|
| 464 |
+
exported?: Identifier | Literal | null
|
| 465 |
+
attributes: Array<ImportAttribute>
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
export interface AwaitExpression extends Node {
|
| 469 |
+
type: "AwaitExpression"
|
| 470 |
+
argument: Expression
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
export interface ChainExpression extends Node {
|
| 474 |
+
type: "ChainExpression"
|
| 475 |
+
expression: MemberExpression | CallExpression
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
export interface ImportExpression extends Node {
|
| 479 |
+
type: "ImportExpression"
|
| 480 |
+
source: Expression
|
| 481 |
+
options: Expression | null
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
export interface ParenthesizedExpression extends Node {
|
| 485 |
+
type: "ParenthesizedExpression"
|
| 486 |
+
expression: Expression
|
| 487 |
+
}
|
| 488 |
+
|
| 489 |
+
export interface PropertyDefinition extends Node {
|
| 490 |
+
type: "PropertyDefinition"
|
| 491 |
+
key: Expression | PrivateIdentifier
|
| 492 |
+
value?: Expression | null
|
| 493 |
+
computed: boolean
|
| 494 |
+
static: boolean
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
export interface PrivateIdentifier extends Node {
|
| 498 |
+
type: "PrivateIdentifier"
|
| 499 |
+
name: string
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
export interface StaticBlock extends Node {
|
| 503 |
+
type: "StaticBlock"
|
| 504 |
+
body: Array<Statement>
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
+
export type Statement =
|
| 508 |
+
| ExpressionStatement
|
| 509 |
+
| BlockStatement
|
| 510 |
+
| EmptyStatement
|
| 511 |
+
| DebuggerStatement
|
| 512 |
+
| WithStatement
|
| 513 |
+
| ReturnStatement
|
| 514 |
+
| LabeledStatement
|
| 515 |
+
| BreakStatement
|
| 516 |
+
| ContinueStatement
|
| 517 |
+
| IfStatement
|
| 518 |
+
| SwitchStatement
|
| 519 |
+
| ThrowStatement
|
| 520 |
+
| TryStatement
|
| 521 |
+
| WhileStatement
|
| 522 |
+
| DoWhileStatement
|
| 523 |
+
| ForStatement
|
| 524 |
+
| ForInStatement
|
| 525 |
+
| ForOfStatement
|
| 526 |
+
| Declaration
|
| 527 |
+
|
| 528 |
+
export type Declaration =
|
| 529 |
+
| FunctionDeclaration
|
| 530 |
+
| VariableDeclaration
|
| 531 |
+
| ClassDeclaration
|
| 532 |
+
|
| 533 |
+
export type Expression =
|
| 534 |
+
| Identifier
|
| 535 |
+
| Literal
|
| 536 |
+
| ThisExpression
|
| 537 |
+
| ArrayExpression
|
| 538 |
+
| ObjectExpression
|
| 539 |
+
| FunctionExpression
|
| 540 |
+
| UnaryExpression
|
| 541 |
+
| UpdateExpression
|
| 542 |
+
| BinaryExpression
|
| 543 |
+
| AssignmentExpression
|
| 544 |
+
| LogicalExpression
|
| 545 |
+
| MemberExpression
|
| 546 |
+
| ConditionalExpression
|
| 547 |
+
| CallExpression
|
| 548 |
+
| NewExpression
|
| 549 |
+
| SequenceExpression
|
| 550 |
+
| ArrowFunctionExpression
|
| 551 |
+
| YieldExpression
|
| 552 |
+
| TemplateLiteral
|
| 553 |
+
| TaggedTemplateExpression
|
| 554 |
+
| ClassExpression
|
| 555 |
+
| MetaProperty
|
| 556 |
+
| AwaitExpression
|
| 557 |
+
| ChainExpression
|
| 558 |
+
| ImportExpression
|
| 559 |
+
| ParenthesizedExpression
|
| 560 |
+
|
| 561 |
+
export type Pattern =
|
| 562 |
+
| Identifier
|
| 563 |
+
| MemberExpression
|
| 564 |
+
| ObjectPattern
|
| 565 |
+
| ArrayPattern
|
| 566 |
+
| RestElement
|
| 567 |
+
| AssignmentPattern
|
| 568 |
+
|
| 569 |
+
export type ModuleDeclaration =
|
| 570 |
+
| ImportDeclaration
|
| 571 |
+
| ExportNamedDeclaration
|
| 572 |
+
| ExportDefaultDeclaration
|
| 573 |
+
| ExportAllDeclaration
|
| 574 |
+
|
| 575 |
+
/**
|
| 576 |
+
* This interface is only used for defining {@link AnyNode}.
|
| 577 |
+
* It exists so that it can be extended by plugins:
|
| 578 |
+
*
|
| 579 |
+
* @example
|
| 580 |
+
* ```typescript
|
| 581 |
+
* declare module 'acorn' {
|
| 582 |
+
* interface NodeTypes {
|
| 583 |
+
* pluginName: FirstNode | SecondNode | ThirdNode | ... | LastNode
|
| 584 |
+
* }
|
| 585 |
+
* }
|
| 586 |
+
* ```
|
| 587 |
+
*/
|
| 588 |
+
interface NodeTypes {
|
| 589 |
+
core: Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportAttribute | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock | VariableDeclarator
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
export type AnyNode = NodeTypes[keyof NodeTypes]
|
| 593 |
+
|
| 594 |
+
export function parse(input: string, options: Options): Program
|
| 595 |
+
|
| 596 |
+
export function parseExpressionAt(input: string, pos: number, options: Options): Expression
|
| 597 |
+
|
| 598 |
+
export function tokenizer(input: string, options: Options): {
|
| 599 |
+
getToken(): Token
|
| 600 |
+
[Symbol.iterator](): Iterator<Token>
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
export type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026 | "latest"
|
| 604 |
+
|
| 605 |
+
export interface Options {
|
| 606 |
+
/**
|
| 607 |
+
* `ecmaVersion` indicates the ECMAScript version to parse. Can be a
|
| 608 |
+
* number, either in year (`2022`) or plain version number (`6`) form,
|
| 609 |
+
* or `"latest"` (the latest the library supports). This influences
|
| 610 |
+
* support for strict mode, the set of reserved words, and support for
|
| 611 |
+
* new syntax features.
|
| 612 |
+
*/
|
| 613 |
+
ecmaVersion: ecmaVersion
|
| 614 |
+
|
| 615 |
+
/**
|
| 616 |
+
* `sourceType` indicates the mode the code should be parsed in.
|
| 617 |
+
* Can be either `"script"` or `"module"`. This influences global
|
| 618 |
+
* strict mode and parsing of `import` and `export` declarations.
|
| 619 |
+
*/
|
| 620 |
+
sourceType?: "script" | "module"
|
| 621 |
+
|
| 622 |
+
/**
|
| 623 |
+
* a callback that will be called when a semicolon is automatically inserted.
|
| 624 |
+
* @param lastTokEnd the position of the comma as an offset
|
| 625 |
+
* @param lastTokEndLoc location if {@link locations} is enabled
|
| 626 |
+
*/
|
| 627 |
+
onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
|
| 628 |
+
|
| 629 |
+
/**
|
| 630 |
+
* similar to `onInsertedSemicolon`, but for trailing commas
|
| 631 |
+
* @param lastTokEnd the position of the comma as an offset
|
| 632 |
+
* @param lastTokEndLoc location if `locations` is enabled
|
| 633 |
+
*/
|
| 634 |
+
onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
|
| 635 |
+
|
| 636 |
+
/**
|
| 637 |
+
* By default, reserved words are only enforced if ecmaVersion >= 5.
|
| 638 |
+
* Set `allowReserved` to a boolean value to explicitly turn this on
|
| 639 |
+
* an off. When this option has the value "never", reserved words
|
| 640 |
+
* and keywords can also not be used as property names.
|
| 641 |
+
*/
|
| 642 |
+
allowReserved?: boolean | "never"
|
| 643 |
+
|
| 644 |
+
/**
|
| 645 |
+
* When enabled, a return at the top level is not considered an error.
|
| 646 |
+
*/
|
| 647 |
+
allowReturnOutsideFunction?: boolean
|
| 648 |
+
|
| 649 |
+
/**
|
| 650 |
+
* When enabled, import/export statements are not constrained to
|
| 651 |
+
* appearing at the top of the program, and an import.meta expression
|
| 652 |
+
* in a script isn't considered an error.
|
| 653 |
+
*/
|
| 654 |
+
allowImportExportEverywhere?: boolean
|
| 655 |
+
|
| 656 |
+
/**
|
| 657 |
+
* By default, `await` identifiers are allowed to appear at the top-level scope only if {@link ecmaVersion} >= 2022.
|
| 658 |
+
* When enabled, await identifiers are allowed to appear at the top-level scope,
|
| 659 |
+
* but they are still not allowed in non-async functions.
|
| 660 |
+
*/
|
| 661 |
+
allowAwaitOutsideFunction?: boolean
|
| 662 |
+
|
| 663 |
+
/**
|
| 664 |
+
* When enabled, super identifiers are not constrained to
|
| 665 |
+
* appearing in methods and do not raise an error when they appear elsewhere.
|
| 666 |
+
*/
|
| 667 |
+
allowSuperOutsideMethod?: boolean
|
| 668 |
+
|
| 669 |
+
/**
|
| 670 |
+
* When enabled, hashbang directive in the beginning of file is
|
| 671 |
+
* allowed and treated as a line comment. Enabled by default when
|
| 672 |
+
* {@link ecmaVersion} >= 2023.
|
| 673 |
+
*/
|
| 674 |
+
allowHashBang?: boolean
|
| 675 |
+
|
| 676 |
+
/**
|
| 677 |
+
* By default, the parser will verify that private properties are
|
| 678 |
+
* only used in places where they are valid and have been declared.
|
| 679 |
+
* Set this to false to turn such checks off.
|
| 680 |
+
*/
|
| 681 |
+
checkPrivateFields?: boolean
|
| 682 |
+
|
| 683 |
+
/**
|
| 684 |
+
* When `locations` is on, `loc` properties holding objects with
|
| 685 |
+
* `start` and `end` properties as {@link Position} objects will be attached to the
|
| 686 |
+
* nodes.
|
| 687 |
+
*/
|
| 688 |
+
locations?: boolean
|
| 689 |
+
|
| 690 |
+
/**
|
| 691 |
+
* a callback that will cause Acorn to call that export function with object in the same
|
| 692 |
+
* format as tokens returned from `tokenizer().getToken()`. Note
|
| 693 |
+
* that you are not allowed to call the parser from the
|
| 694 |
+
* callback—that will corrupt its internal state.
|
| 695 |
+
*/
|
| 696 |
+
onToken?: ((token: Token) => void) | Token[]
|
| 697 |
+
|
| 698 |
+
|
| 699 |
+
/**
|
| 700 |
+
* This takes a export function or an array.
|
| 701 |
+
*
|
| 702 |
+
* When a export function is passed, Acorn will call that export function with `(block, text, start,
|
| 703 |
+
* end)` parameters whenever a comment is skipped. `block` is a
|
| 704 |
+
* boolean indicating whether this is a block (`/* *\/`) comment,
|
| 705 |
+
* `text` is the content of the comment, and `start` and `end` are
|
| 706 |
+
* character offsets that denote the start and end of the comment.
|
| 707 |
+
* When the {@link locations} option is on, two more parameters are
|
| 708 |
+
* passed, the full locations of {@link Position} export type of the start and
|
| 709 |
+
* end of the comments.
|
| 710 |
+
*
|
| 711 |
+
* When a array is passed, each found comment of {@link Comment} export type is pushed to the array.
|
| 712 |
+
*
|
| 713 |
+
* Note that you are not allowed to call the
|
| 714 |
+
* parser from the callback—that will corrupt its internal state.
|
| 715 |
+
*/
|
| 716 |
+
onComment?: ((
|
| 717 |
+
isBlock: boolean, text: string, start: number, end: number, startLoc?: Position,
|
| 718 |
+
endLoc?: Position
|
| 719 |
+
) => void) | Comment[]
|
| 720 |
+
|
| 721 |
+
/**
|
| 722 |
+
* Nodes have their start and end characters offsets recorded in
|
| 723 |
+
* `start` and `end` properties (directly on the node, rather than
|
| 724 |
+
* the `loc` object, which holds line/column data. To also add a
|
| 725 |
+
* [semi-standardized][range] `range` property holding a `[start,
|
| 726 |
+
* end]` array with the same numbers, set the `ranges` option to
|
| 727 |
+
* `true`.
|
| 728 |
+
*/
|
| 729 |
+
ranges?: boolean
|
| 730 |
+
|
| 731 |
+
/**
|
| 732 |
+
* It is possible to parse multiple files into a single AST by
|
| 733 |
+
* passing the tree produced by parsing the first file as
|
| 734 |
+
* `program` option in subsequent parses. This will add the
|
| 735 |
+
* toplevel forms of the parsed file to the `Program` (top) node
|
| 736 |
+
* of an existing parse tree.
|
| 737 |
+
*/
|
| 738 |
+
program?: Node
|
| 739 |
+
|
| 740 |
+
/**
|
| 741 |
+
* When {@link locations} is on, you can pass this to record the source
|
| 742 |
+
* file in every node's `loc` object.
|
| 743 |
+
*/
|
| 744 |
+
sourceFile?: string
|
| 745 |
+
|
| 746 |
+
/**
|
| 747 |
+
* This value, if given, is stored in every node, whether {@link locations} is on or off.
|
| 748 |
+
*/
|
| 749 |
+
directSourceFile?: string
|
| 750 |
+
|
| 751 |
+
/**
|
| 752 |
+
* When enabled, parenthesized expressions are represented by
|
| 753 |
+
* (non-standard) ParenthesizedExpression nodes
|
| 754 |
+
*/
|
| 755 |
+
preserveParens?: boolean
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
+
export class Parser {
|
| 759 |
+
options: Options
|
| 760 |
+
input: string
|
| 761 |
+
|
| 762 |
+
protected constructor(options: Options, input: string, startPos?: number)
|
| 763 |
+
parse(): Program
|
| 764 |
+
|
| 765 |
+
static parse(input: string, options: Options): Program
|
| 766 |
+
static parseExpressionAt(input: string, pos: number, options: Options): Expression
|
| 767 |
+
static tokenizer(input: string, options: Options): {
|
| 768 |
+
getToken(): Token
|
| 769 |
+
[Symbol.iterator](): Iterator<Token>
|
| 770 |
+
}
|
| 771 |
+
static extend(...plugins: ((BaseParser: typeof Parser) => typeof Parser)[]): typeof Parser
|
| 772 |
+
}
|
| 773 |
+
|
| 774 |
+
export const defaultOptions: Options
|
| 775 |
+
|
| 776 |
+
export function getLineInfo(input: string, offset: number): Position
|
| 777 |
+
|
| 778 |
+
export class TokenType {
|
| 779 |
+
label: string
|
| 780 |
+
keyword: string | undefined
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
export const tokTypes: {
|
| 784 |
+
num: TokenType
|
| 785 |
+
regexp: TokenType
|
| 786 |
+
string: TokenType
|
| 787 |
+
name: TokenType
|
| 788 |
+
privateId: TokenType
|
| 789 |
+
eof: TokenType
|
| 790 |
+
|
| 791 |
+
bracketL: TokenType
|
| 792 |
+
bracketR: TokenType
|
| 793 |
+
braceL: TokenType
|
| 794 |
+
braceR: TokenType
|
| 795 |
+
parenL: TokenType
|
| 796 |
+
parenR: TokenType
|
| 797 |
+
comma: TokenType
|
| 798 |
+
semi: TokenType
|
| 799 |
+
colon: TokenType
|
| 800 |
+
dot: TokenType
|
| 801 |
+
question: TokenType
|
| 802 |
+
questionDot: TokenType
|
| 803 |
+
arrow: TokenType
|
| 804 |
+
template: TokenType
|
| 805 |
+
invalidTemplate: TokenType
|
| 806 |
+
ellipsis: TokenType
|
| 807 |
+
backQuote: TokenType
|
| 808 |
+
dollarBraceL: TokenType
|
| 809 |
+
|
| 810 |
+
eq: TokenType
|
| 811 |
+
assign: TokenType
|
| 812 |
+
incDec: TokenType
|
| 813 |
+
prefix: TokenType
|
| 814 |
+
logicalOR: TokenType
|
| 815 |
+
logicalAND: TokenType
|
| 816 |
+
bitwiseOR: TokenType
|
| 817 |
+
bitwiseXOR: TokenType
|
| 818 |
+
bitwiseAND: TokenType
|
| 819 |
+
equality: TokenType
|
| 820 |
+
relational: TokenType
|
| 821 |
+
bitShift: TokenType
|
| 822 |
+
plusMin: TokenType
|
| 823 |
+
modulo: TokenType
|
| 824 |
+
star: TokenType
|
| 825 |
+
slash: TokenType
|
| 826 |
+
starstar: TokenType
|
| 827 |
+
coalesce: TokenType
|
| 828 |
+
|
| 829 |
+
_break: TokenType
|
| 830 |
+
_case: TokenType
|
| 831 |
+
_catch: TokenType
|
| 832 |
+
_continue: TokenType
|
| 833 |
+
_debugger: TokenType
|
| 834 |
+
_default: TokenType
|
| 835 |
+
_do: TokenType
|
| 836 |
+
_else: TokenType
|
| 837 |
+
_finally: TokenType
|
| 838 |
+
_for: TokenType
|
| 839 |
+
_function: TokenType
|
| 840 |
+
_if: TokenType
|
| 841 |
+
_return: TokenType
|
| 842 |
+
_switch: TokenType
|
| 843 |
+
_throw: TokenType
|
| 844 |
+
_try: TokenType
|
| 845 |
+
_var: TokenType
|
| 846 |
+
_const: TokenType
|
| 847 |
+
_while: TokenType
|
| 848 |
+
_with: TokenType
|
| 849 |
+
_new: TokenType
|
| 850 |
+
_this: TokenType
|
| 851 |
+
_super: TokenType
|
| 852 |
+
_class: TokenType
|
| 853 |
+
_extends: TokenType
|
| 854 |
+
_export: TokenType
|
| 855 |
+
_import: TokenType
|
| 856 |
+
_null: TokenType
|
| 857 |
+
_true: TokenType
|
| 858 |
+
_false: TokenType
|
| 859 |
+
_in: TokenType
|
| 860 |
+
_instanceof: TokenType
|
| 861 |
+
_typeof: TokenType
|
| 862 |
+
_void: TokenType
|
| 863 |
+
_delete: TokenType
|
| 864 |
+
}
|
| 865 |
+
|
| 866 |
+
export interface Comment {
|
| 867 |
+
type: "Line" | "Block"
|
| 868 |
+
value: string
|
| 869 |
+
start: number
|
| 870 |
+
end: number
|
| 871 |
+
loc?: SourceLocation
|
| 872 |
+
range?: [number, number]
|
| 873 |
+
}
|
| 874 |
+
|
| 875 |
+
export class Token {
|
| 876 |
+
type: TokenType
|
| 877 |
+
start: number
|
| 878 |
+
end: number
|
| 879 |
+
loc?: SourceLocation
|
| 880 |
+
range?: [number, number]
|
| 881 |
+
}
|
| 882 |
+
|
| 883 |
+
export const version: string
|
novas/novacore-zephyr/groq-code-cli/node_modules/acorn/dist/acorn.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
novas/novacore-zephyr/groq-code-cli/node_modules/acorn/dist/acorn.mjs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
novas/novacore-zephyr/groq-code-cli/node_modules/acorn/dist/bin.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var path = require('path');
|
| 4 |
+
var fs = require('fs');
|
| 5 |
+
var acorn = require('./acorn.js');
|
| 6 |
+
|
| 7 |
+
function _interopNamespaceDefault(e) {
|
| 8 |
+
var n = Object.create(null);
|
| 9 |
+
if (e) {
|
| 10 |
+
Object.keys(e).forEach(function (k) {
|
| 11 |
+
if (k !== 'default') {
|
| 12 |
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
| 13 |
+
Object.defineProperty(n, k, d.get ? d : {
|
| 14 |
+
enumerable: true,
|
| 15 |
+
get: function () { return e[k]; }
|
| 16 |
+
});
|
| 17 |
+
}
|
| 18 |
+
});
|
| 19 |
+
}
|
| 20 |
+
n.default = e;
|
| 21 |
+
return Object.freeze(n);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
var acorn__namespace = /*#__PURE__*/_interopNamespaceDefault(acorn);
|
| 25 |
+
|
| 26 |
+
var inputFilePaths = [], forceFileName = false, fileMode = false, silent = false, compact = false, tokenize = false;
|
| 27 |
+
var options = {};
|
| 28 |
+
|
| 29 |
+
function help(status) {
|
| 30 |
+
var print = (status === 0) ? console.log : console.error;
|
| 31 |
+
print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|...|--ecma2015|--ecma2016|--ecma2017|--ecma2018|...]");
|
| 32 |
+
print(" [--tokenize] [--locations] [--allow-hash-bang] [--allow-await-outside-function] [--compact] [--silent] [--module] [--help] [--] [<infile>...]");
|
| 33 |
+
process.exit(status);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
for (var i = 2; i < process.argv.length; ++i) {
|
| 37 |
+
var arg = process.argv[i];
|
| 38 |
+
if (arg[0] !== "-" || arg === "-") { inputFilePaths.push(arg); }
|
| 39 |
+
else if (arg === "--") {
|
| 40 |
+
inputFilePaths.push.apply(inputFilePaths, process.argv.slice(i + 1));
|
| 41 |
+
forceFileName = true;
|
| 42 |
+
break
|
| 43 |
+
} else if (arg === "--locations") { options.locations = true; }
|
| 44 |
+
else if (arg === "--allow-hash-bang") { options.allowHashBang = true; }
|
| 45 |
+
else if (arg === "--allow-await-outside-function") { options.allowAwaitOutsideFunction = true; }
|
| 46 |
+
else if (arg === "--silent") { silent = true; }
|
| 47 |
+
else if (arg === "--compact") { compact = true; }
|
| 48 |
+
else if (arg === "--help") { help(0); }
|
| 49 |
+
else if (arg === "--tokenize") { tokenize = true; }
|
| 50 |
+
else if (arg === "--module") { options.sourceType = "module"; }
|
| 51 |
+
else {
|
| 52 |
+
var match = arg.match(/^--ecma(\d+)$/);
|
| 53 |
+
if (match)
|
| 54 |
+
{ options.ecmaVersion = +match[1]; }
|
| 55 |
+
else
|
| 56 |
+
{ help(1); }
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
function run(codeList) {
|
| 61 |
+
var result = [], fileIdx = 0;
|
| 62 |
+
try {
|
| 63 |
+
codeList.forEach(function (code, idx) {
|
| 64 |
+
fileIdx = idx;
|
| 65 |
+
if (!tokenize) {
|
| 66 |
+
result = acorn__namespace.parse(code, options);
|
| 67 |
+
options.program = result;
|
| 68 |
+
} else {
|
| 69 |
+
var tokenizer = acorn__namespace.tokenizer(code, options), token;
|
| 70 |
+
do {
|
| 71 |
+
token = tokenizer.getToken();
|
| 72 |
+
result.push(token);
|
| 73 |
+
} while (token.type !== acorn__namespace.tokTypes.eof)
|
| 74 |
+
}
|
| 75 |
+
});
|
| 76 |
+
} catch (e) {
|
| 77 |
+
console.error(fileMode ? e.message.replace(/\(\d+:\d+\)$/, function (m) { return m.slice(0, 1) + inputFilePaths[fileIdx] + " " + m.slice(1); }) : e.message);
|
| 78 |
+
process.exit(1);
|
| 79 |
+
}
|
| 80 |
+
if (!silent) { console.log(JSON.stringify(result, function (_, value) { return typeof value === "bigint" ? null : value; }, compact ? null : 2)); }
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
if (fileMode = inputFilePaths.length && (forceFileName || !inputFilePaths.includes("-") || inputFilePaths.length !== 1)) {
|
| 84 |
+
run(inputFilePaths.map(function (path) { return fs.readFileSync(path, "utf8"); }));
|
| 85 |
+
} else {
|
| 86 |
+
var code = "";
|
| 87 |
+
process.stdin.resume();
|
| 88 |
+
process.stdin.on("data", function (chunk) { return code += chunk; });
|
| 89 |
+
process.stdin.on("end", function () { return run([code]); });
|
| 90 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/helpers.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/// <reference types="node" />
|
| 2 |
+
/// <reference types="node" />
|
| 3 |
+
/// <reference types="node" />
|
| 4 |
+
/// <reference types="node" />
|
| 5 |
+
/// <reference types="node" />
|
| 6 |
+
import * as http from 'http';
|
| 7 |
+
import * as https from 'https';
|
| 8 |
+
import type { Readable } from 'stream';
|
| 9 |
+
export type ThenableRequest = http.ClientRequest & {
|
| 10 |
+
then: Promise<http.IncomingMessage>['then'];
|
| 11 |
+
};
|
| 12 |
+
export declare function toBuffer(stream: Readable): Promise<Buffer>;
|
| 13 |
+
export declare function json(stream: Readable): Promise<any>;
|
| 14 |
+
export declare function req(url: string | URL, opts?: https.RequestOptions): ThenableRequest;
|
| 15 |
+
//# sourceMappingURL=helpers.d.ts.map
|
novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/helpers.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEvC,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,GAAG;IAClD,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;CAC5C,CAAC;AAEF,wBAAsB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAQhE;AAGD,wBAAsB,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAUzD;AAED,wBAAgB,GAAG,CAClB,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,GAAE,KAAK,CAAC,cAAmB,GAC7B,eAAe,CAcjB"}
|
novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/helpers.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 3 |
+
if (k2 === undefined) k2 = k;
|
| 4 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 5 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 6 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 7 |
+
}
|
| 8 |
+
Object.defineProperty(o, k2, desc);
|
| 9 |
+
}) : (function(o, m, k, k2) {
|
| 10 |
+
if (k2 === undefined) k2 = k;
|
| 11 |
+
o[k2] = m[k];
|
| 12 |
+
}));
|
| 13 |
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
| 14 |
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
| 15 |
+
}) : function(o, v) {
|
| 16 |
+
o["default"] = v;
|
| 17 |
+
});
|
| 18 |
+
var __importStar = (this && this.__importStar) || function (mod) {
|
| 19 |
+
if (mod && mod.__esModule) return mod;
|
| 20 |
+
var result = {};
|
| 21 |
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
| 22 |
+
__setModuleDefault(result, mod);
|
| 23 |
+
return result;
|
| 24 |
+
};
|
| 25 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 26 |
+
exports.req = exports.json = exports.toBuffer = void 0;
|
| 27 |
+
const http = __importStar(require("http"));
|
| 28 |
+
const https = __importStar(require("https"));
|
| 29 |
+
async function toBuffer(stream) {
|
| 30 |
+
let length = 0;
|
| 31 |
+
const chunks = [];
|
| 32 |
+
for await (const chunk of stream) {
|
| 33 |
+
length += chunk.length;
|
| 34 |
+
chunks.push(chunk);
|
| 35 |
+
}
|
| 36 |
+
return Buffer.concat(chunks, length);
|
| 37 |
+
}
|
| 38 |
+
exports.toBuffer = toBuffer;
|
| 39 |
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
| 40 |
+
async function json(stream) {
|
| 41 |
+
const buf = await toBuffer(stream);
|
| 42 |
+
const str = buf.toString('utf8');
|
| 43 |
+
try {
|
| 44 |
+
return JSON.parse(str);
|
| 45 |
+
}
|
| 46 |
+
catch (_err) {
|
| 47 |
+
const err = _err;
|
| 48 |
+
err.message += ` (input: ${str})`;
|
| 49 |
+
throw err;
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
exports.json = json;
|
| 53 |
+
function req(url, opts = {}) {
|
| 54 |
+
const href = typeof url === 'string' ? url : url.href;
|
| 55 |
+
const req = (href.startsWith('https:') ? https : http).request(url, opts);
|
| 56 |
+
const promise = new Promise((resolve, reject) => {
|
| 57 |
+
req
|
| 58 |
+
.once('response', resolve)
|
| 59 |
+
.once('error', reject)
|
| 60 |
+
.end();
|
| 61 |
+
});
|
| 62 |
+
req.then = promise.then.bind(promise);
|
| 63 |
+
return req;
|
| 64 |
+
}
|
| 65 |
+
exports.req = req;
|
| 66 |
+
//# sourceMappingURL=helpers.js.map
|
novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/helpers.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,6CAA+B;AAOxB,KAAK,UAAU,QAAQ,CAAC,MAAgB;IAC9C,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;QACvB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACnB;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC;AARD,4BAQC;AAED,8DAA8D;AACvD,KAAK,UAAU,IAAI,CAAC,MAAgB;IAC1C,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACvB;IAAC,OAAO,IAAa,EAAE;QACvB,MAAM,GAAG,GAAG,IAAa,CAAC;QAC1B,GAAG,CAAC,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// <reference types="node" />
|
| 4 |
+
/// <reference types="node" />
|
| 5 |
+
import * as net from 'net';
|
| 6 |
+
import * as tls from 'tls';
|
| 7 |
+
import * as http from 'http';
|
| 8 |
+
import type { Duplex } from 'stream';
|
| 9 |
+
export * from './helpers';
|
| 10 |
+
interface HttpConnectOpts extends net.TcpNetConnectOpts {
|
| 11 |
+
secureEndpoint: false;
|
| 12 |
+
protocol?: string;
|
| 13 |
+
}
|
| 14 |
+
interface HttpsConnectOpts extends tls.ConnectionOptions {
|
| 15 |
+
secureEndpoint: true;
|
| 16 |
+
protocol?: string;
|
| 17 |
+
port: number;
|
| 18 |
+
}
|
| 19 |
+
export type AgentConnectOpts = HttpConnectOpts | HttpsConnectOpts;
|
| 20 |
+
declare const INTERNAL: unique symbol;
|
| 21 |
+
export declare abstract class Agent extends http.Agent {
|
| 22 |
+
private [INTERNAL];
|
| 23 |
+
options: Partial<net.TcpNetConnectOpts & tls.ConnectionOptions>;
|
| 24 |
+
keepAlive: boolean;
|
| 25 |
+
constructor(opts?: http.AgentOptions);
|
| 26 |
+
abstract connect(req: http.ClientRequest, options: AgentConnectOpts): Promise<Duplex | http.Agent> | Duplex | http.Agent;
|
| 27 |
+
/**
|
| 28 |
+
* Determine whether this is an `http` or `https` request.
|
| 29 |
+
*/
|
| 30 |
+
isSecureEndpoint(options?: AgentConnectOpts): boolean;
|
| 31 |
+
private incrementSockets;
|
| 32 |
+
private decrementSockets;
|
| 33 |
+
getName(options?: AgentConnectOpts): string;
|
| 34 |
+
createSocket(req: http.ClientRequest, options: AgentConnectOpts, cb: (err: Error | null, s?: Duplex) => void): void;
|
| 35 |
+
createConnection(): Duplex;
|
| 36 |
+
get defaultPort(): number;
|
| 37 |
+
set defaultPort(v: number);
|
| 38 |
+
get protocol(): string;
|
| 39 |
+
set protocol(v: string);
|
| 40 |
+
}
|
| 41 |
+
//# sourceMappingURL=index.d.ts.map
|
novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/index.d.ts.map
AD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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
| 3 |
+
if (k2 === undefined) k2 = k;
|
| 4 |
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
| 5 |
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
| 6 |
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
| 7 |
+
}
|
| 8 |
+
Object.defineProperty(o, k2, desc);
|
| 9 |
+
}) : (function(o, m, k, k2) {
|
| 10 |
+
if (k2 === undefined) k2 = k;
|
| 11 |
+
o[k2] = m[k];
|
| 12 |
+
}));
|
| 13 |
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
| 14 |
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
| 15 |
+
}) : function(o, v) {
|
| 16 |
+
o["default"] = v;
|
| 17 |
+
});
|
| 18 |
+
var __importStar = (this && this.__importStar) || function (mod) {
|
| 19 |
+
if (mod && mod.__esModule) return mod;
|
| 20 |
+
var result = {};
|
| 21 |
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
| 22 |
+
__setModuleDefault(result, mod);
|
| 23 |
+
return result;
|
| 24 |
+
};
|
| 25 |
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
| 26 |
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
| 27 |
+
};
|
| 28 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 29 |
+
exports.Agent = void 0;
|
| 30 |
+
const net = __importStar(require("net"));
|
| 31 |
+
const http = __importStar(require("http"));
|
| 32 |
+
const https_1 = require("https");
|
| 33 |
+
__exportStar(require("./helpers"), exports);
|
| 34 |
+
const INTERNAL = Symbol('AgentBaseInternalState');
|
| 35 |
+
class Agent extends http.Agent {
|
| 36 |
+
constructor(opts) {
|
| 37 |
+
super(opts);
|
| 38 |
+
this[INTERNAL] = {};
|
| 39 |
+
}
|
| 40 |
+
/**
|
| 41 |
+
* Determine whether this is an `http` or `https` request.
|
| 42 |
+
*/
|
| 43 |
+
isSecureEndpoint(options) {
|
| 44 |
+
if (options) {
|
| 45 |
+
// First check the `secureEndpoint` property explicitly, since this
|
| 46 |
+
// means that a parent `Agent` is "passing through" to this instance.
|
| 47 |
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
| 48 |
+
if (typeof options.secureEndpoint === 'boolean') {
|
| 49 |
+
return options.secureEndpoint;
|
| 50 |
+
}
|
| 51 |
+
// If no explicit `secure` endpoint, check if `protocol` property is
|
| 52 |
+
// set. This will usually be the case since using a full string URL
|
| 53 |
+
// or `URL` instance should be the most common usage.
|
| 54 |
+
if (typeof options.protocol === 'string') {
|
| 55 |
+
return options.protocol === 'https:';
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
// Finally, if no `protocol` property was set, then fall back to
|
| 59 |
+
// checking the stack trace of the current call stack, and try to
|
| 60 |
+
// detect the "https" module.
|
| 61 |
+
const { stack } = new Error();
|
| 62 |
+
if (typeof stack !== 'string')
|
| 63 |
+
return false;
|
| 64 |
+
return stack
|
| 65 |
+
.split('\n')
|
| 66 |
+
.some((l) => l.indexOf('(https.js:') !== -1 ||
|
| 67 |
+
l.indexOf('node:https:') !== -1);
|
| 68 |
+
}
|
| 69 |
+
// In order to support async signatures in `connect()` and Node's native
|
| 70 |
+
// connection pooling in `http.Agent`, the array of sockets for each origin
|
| 71 |
+
// has to be updated synchronously. This is so the length of the array is
|
| 72 |
+
// accurate when `addRequest()` is next called. We achieve this by creating a
|
| 73 |
+
// fake socket and adding it to `sockets[origin]` and incrementing
|
| 74 |
+
// `totalSocketCount`.
|
| 75 |
+
incrementSockets(name) {
|
| 76 |
+
// If `maxSockets` and `maxTotalSockets` are both Infinity then there is no
|
| 77 |
+
// need to create a fake socket because Node.js native connection pooling
|
| 78 |
+
// will never be invoked.
|
| 79 |
+
if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) {
|
| 80 |
+
return null;
|
| 81 |
+
}
|
| 82 |
+
// All instances of `sockets` are expected TypeScript errors. The
|
| 83 |
+
// alternative is to add it as a private property of this class but that
|
| 84 |
+
// will break TypeScript subclassing.
|
| 85 |
+
if (!this.sockets[name]) {
|
| 86 |
+
// @ts-expect-error `sockets` is readonly in `@types/node`
|
| 87 |
+
this.sockets[name] = [];
|
| 88 |
+
}
|
| 89 |
+
const fakeSocket = new net.Socket({ writable: false });
|
| 90 |
+
this.sockets[name].push(fakeSocket);
|
| 91 |
+
// @ts-expect-error `totalSocketCount` isn't defined in `@types/node`
|
| 92 |
+
this.totalSocketCount++;
|
| 93 |
+
return fakeSocket;
|
| 94 |
+
}
|
| 95 |
+
decrementSockets(name, socket) {
|
| 96 |
+
if (!this.sockets[name] || socket === null) {
|
| 97 |
+
return;
|
| 98 |
+
}
|
| 99 |
+
const sockets = this.sockets[name];
|
| 100 |
+
const index = sockets.indexOf(socket);
|
| 101 |
+
if (index !== -1) {
|
| 102 |
+
sockets.splice(index, 1);
|
| 103 |
+
// @ts-expect-error `totalSocketCount` isn't defined in `@types/node`
|
| 104 |
+
this.totalSocketCount--;
|
| 105 |
+
if (sockets.length === 0) {
|
| 106 |
+
// @ts-expect-error `sockets` is readonly in `@types/node`
|
| 107 |
+
delete this.sockets[name];
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
// In order to properly update the socket pool, we need to call `getName()` on
|
| 112 |
+
// the core `https.Agent` if it is a secureEndpoint.
|
| 113 |
+
getName(options) {
|
| 114 |
+
const secureEndpoint = this.isSecureEndpoint(options);
|
| 115 |
+
if (secureEndpoint) {
|
| 116 |
+
// @ts-expect-error `getName()` isn't defined in `@types/node`
|
| 117 |
+
return https_1.Agent.prototype.getName.call(this, options);
|
| 118 |
+
}
|
| 119 |
+
// @ts-expect-error `getName()` isn't defined in `@types/node`
|
| 120 |
+
return super.getName(options);
|
| 121 |
+
}
|
| 122 |
+
createSocket(req, options, cb) {
|
| 123 |
+
const connectOpts = {
|
| 124 |
+
...options,
|
| 125 |
+
secureEndpoint: this.isSecureEndpoint(options),
|
| 126 |
+
};
|
| 127 |
+
const name = this.getName(connectOpts);
|
| 128 |
+
const fakeSocket = this.incrementSockets(name);
|
| 129 |
+
Promise.resolve()
|
| 130 |
+
.then(() => this.connect(req, connectOpts))
|
| 131 |
+
.then((socket) => {
|
| 132 |
+
this.decrementSockets(name, fakeSocket);
|
| 133 |
+
if (socket instanceof http.Agent) {
|
| 134 |
+
try {
|
| 135 |
+
// @ts-expect-error `addRequest()` isn't defined in `@types/node`
|
| 136 |
+
return socket.addRequest(req, connectOpts);
|
| 137 |
+
}
|
| 138 |
+
catch (err) {
|
| 139 |
+
return cb(err);
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
this[INTERNAL].currentSocket = socket;
|
| 143 |
+
// @ts-expect-error `createSocket()` isn't defined in `@types/node`
|
| 144 |
+
super.createSocket(req, options, cb);
|
| 145 |
+
}, (err) => {
|
| 146 |
+
this.decrementSockets(name, fakeSocket);
|
| 147 |
+
cb(err);
|
| 148 |
+
});
|
| 149 |
+
}
|
| 150 |
+
createConnection() {
|
| 151 |
+
const socket = this[INTERNAL].currentSocket;
|
| 152 |
+
this[INTERNAL].currentSocket = undefined;
|
| 153 |
+
if (!socket) {
|
| 154 |
+
throw new Error('No socket was returned in the `connect()` function');
|
| 155 |
+
}
|
| 156 |
+
return socket;
|
| 157 |
+
}
|
| 158 |
+
get defaultPort() {
|
| 159 |
+
return (this[INTERNAL].defaultPort ??
|
| 160 |
+
(this.protocol === 'https:' ? 443 : 80));
|
| 161 |
+
}
|
| 162 |
+
set defaultPort(v) {
|
| 163 |
+
if (this[INTERNAL]) {
|
| 164 |
+
this[INTERNAL].defaultPort = v;
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
get protocol() {
|
| 168 |
+
return (this[INTERNAL].protocol ??
|
| 169 |
+
(this.isSecureEndpoint() ? 'https:' : 'http:'));
|
| 170 |
+
}
|
| 171 |
+
set protocol(v) {
|
| 172 |
+
if (this[INTERNAL]) {
|
| 173 |
+
this[INTERNAL].protocol = v;
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
exports.Agent = Agent;
|
| 178 |
+
//# sourceMappingURL=index.js.map
|
novas/novacore-zephyr/groq-code-cli/node_modules/agent-base/dist/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAE3B,2CAA6B;AAC7B,iCAA4C;AAG5C,4CAA0B;AAe1B,MAAM,QAAQ,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAQlD,MAAsB,KAAM,SAAQ,IAAI,CAAC,KAAK;IAO7C,YAAY,IAAwB;Q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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
const OriginalAgent = require('http').Agent;
|
| 4 |
+
const ms = require('humanize-ms');
|
| 5 |
+
const debug = require('util').debuglog('agentkeepalive');
|
| 6 |
+
const {
|
| 7 |
+
INIT_SOCKET,
|
| 8 |
+
CURRENT_ID,
|
| 9 |
+
CREATE_ID,
|
| 10 |
+
SOCKET_CREATED_TIME,
|
| 11 |
+
SOCKET_NAME,
|
| 12 |
+
SOCKET_REQUEST_COUNT,
|
| 13 |
+
SOCKET_REQUEST_FINISHED_COUNT,
|
| 14 |
+
} = require('./constants');
|
| 15 |
+
|
| 16 |
+
// OriginalAgent come from
|
| 17 |
+
// - https://github.com/nodejs/node/blob/v8.12.0/lib/_http_agent.js
|
| 18 |
+
// - https://github.com/nodejs/node/blob/v10.12.0/lib/_http_agent.js
|
| 19 |
+
|
| 20 |
+
// node <= 10
|
| 21 |
+
let defaultTimeoutListenerCount = 1;
|
| 22 |
+
const majorVersion = parseInt(process.version.split('.', 1)[0].substring(1));
|
| 23 |
+
if (majorVersion >= 11 && majorVersion <= 12) {
|
| 24 |
+
defaultTimeoutListenerCount = 2;
|
| 25 |
+
} else if (majorVersion >= 13) {
|
| 26 |
+
defaultTimeoutListenerCount = 3;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
function deprecate(message) {
|
| 30 |
+
console.log('[agentkeepalive:deprecated] %s', message);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
class Agent extends OriginalAgent {
|
| 34 |
+
constructor(options) {
|
| 35 |
+
options = options || {};
|
| 36 |
+
options.keepAlive = options.keepAlive !== false;
|
| 37 |
+
// default is keep-alive and 4s free socket timeout
|
| 38 |
+
// see https://medium.com/ssense-tech/reduce-networking-errors-in-nodejs-23b4eb9f2d83
|
| 39 |
+
if (options.freeSocketTimeout === undefined) {
|
| 40 |
+
options.freeSocketTimeout = 4000;
|
| 41 |
+
}
|
| 42 |
+
// Legacy API: keepAliveTimeout should be rename to `freeSocketTimeout`
|
| 43 |
+
if (options.keepAliveTimeout) {
|
| 44 |
+
deprecate('options.keepAliveTimeout is deprecated, please use options.freeSocketTimeout instead');
|
| 45 |
+
options.freeSocketTimeout = options.keepAliveTimeout;
|
| 46 |
+
delete options.keepAliveTimeout;
|
| 47 |
+
}
|
| 48 |
+
// Legacy API: freeSocketKeepAliveTimeout should be rename to `freeSocketTimeout`
|
| 49 |
+
if (options.freeSocketKeepAliveTimeout) {
|
| 50 |
+
deprecate('options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead');
|
| 51 |
+
options.freeSocketTimeout = options.freeSocketKeepAliveTimeout;
|
| 52 |
+
delete options.freeSocketKeepAliveTimeout;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
// Sets the socket to timeout after timeout milliseconds of inactivity on the socket.
|
| 56 |
+
// By default is double free socket timeout.
|
| 57 |
+
if (options.timeout === undefined) {
|
| 58 |
+
// make sure socket default inactivity timeout >= 8s
|
| 59 |
+
options.timeout = Math.max(options.freeSocketTimeout * 2, 8000);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
// support humanize format
|
| 63 |
+
options.timeout = ms(options.timeout);
|
| 64 |
+
options.freeSocketTimeout = ms(options.freeSocketTimeout);
|
| 65 |
+
options.socketActiveTTL = options.socketActiveTTL ? ms(options.socketActiveTTL) : 0;
|
| 66 |
+
|
| 67 |
+
super(options);
|
| 68 |
+
|
| 69 |
+
this[CURRENT_ID] = 0;
|
| 70 |
+
|
| 71 |
+
// create socket success counter
|
| 72 |
+
this.createSocketCount = 0;
|
| 73 |
+
this.createSocketCountLastCheck = 0;
|
| 74 |
+
|
| 75 |
+
this.createSocketErrorCount = 0;
|
| 76 |
+
this.createSocketErrorCountLastCheck = 0;
|
| 77 |
+
|
| 78 |
+
this.closeSocketCount = 0;
|
| 79 |
+
this.closeSocketCountLastCheck = 0;
|
| 80 |
+
|
| 81 |
+
// socket error event count
|
| 82 |
+
this.errorSocketCount = 0;
|
| 83 |
+
this.errorSocketCountLastCheck = 0;
|
| 84 |
+
|
| 85 |
+
// request finished counter
|
| 86 |
+
this.requestCount = 0;
|
| 87 |
+
this.requestCountLastCheck = 0;
|
| 88 |
+
|
| 89 |
+
// including free socket timeout counter
|
| 90 |
+
this.timeoutSocketCount = 0;
|
| 91 |
+
this.timeoutSocketCountLastCheck = 0;
|
| 92 |
+
|
| 93 |
+
this.on('free', socket => {
|
| 94 |
+
// https://github.com/nodejs/node/pull/32000
|
| 95 |
+
// Node.js native agent will check socket timeout eqs agent.options.timeout.
|
| 96 |
+
// Use the ttl or freeSocketTimeout to overwrite.
|
| 97 |
+
const timeout = this.calcSocketTimeout(socket);
|
| 98 |
+
if (timeout > 0 && socket.timeout !== timeout) {
|
| 99 |
+
socket.setTimeout(timeout);
|
| 100 |
+
}
|
| 101 |
+
});
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
get freeSocketKeepAliveTimeout() {
|
| 105 |
+
deprecate('agent.freeSocketKeepAliveTimeout is deprecated, please use agent.options.freeSocketTimeout instead');
|
| 106 |
+
return this.options.freeSocketTimeout;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
get timeout() {
|
| 110 |
+
deprecate('agent.timeout is deprecated, please use agent.options.timeout instead');
|
| 111 |
+
return this.options.timeout;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
get socketActiveTTL() {
|
| 115 |
+
deprecate('agent.socketActiveTTL is deprecated, please use agent.options.socketActiveTTL instead');
|
| 116 |
+
return this.options.socketActiveTTL;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
calcSocketTimeout(socket) {
|
| 120 |
+
/**
|
| 121 |
+
* return <= 0: should free socket
|
| 122 |
+
* return > 0: should update socket timeout
|
| 123 |
+
* return undefined: not find custom timeout
|
| 124 |
+
*/
|
| 125 |
+
let freeSocketTimeout = this.options.freeSocketTimeout;
|
| 126 |
+
const socketActiveTTL = this.options.socketActiveTTL;
|
| 127 |
+
if (socketActiveTTL) {
|
| 128 |
+
// check socketActiveTTL
|
| 129 |
+
const aliveTime = Date.now() - socket[SOCKET_CREATED_TIME];
|
| 130 |
+
const diff = socketActiveTTL - aliveTime;
|
| 131 |
+
if (diff <= 0) {
|
| 132 |
+
return diff;
|
| 133 |
+
}
|
| 134 |
+
if (freeSocketTimeout && diff < freeSocketTimeout) {
|
| 135 |
+
freeSocketTimeout = diff;
|
| 136 |
+
}
|
| 137 |
+
}
|
| 138 |
+
// set freeSocketTimeout
|
| 139 |
+
if (freeSocketTimeout) {
|
| 140 |
+
// set free keepalive timer
|
| 141 |
+
// try to use socket custom freeSocketTimeout first, support headers['keep-alive']
|
| 142 |
+
// https://github.com/node-modules/urllib/blob/b76053020923f4d99a1c93cf2e16e0c5ba10bacf/lib/urllib.js#L498
|
| 143 |
+
const customFreeSocketTimeout = socket.freeSocketTimeout || socket.freeSocketKeepAliveTimeout;
|
| 144 |
+
return customFreeSocketTimeout || freeSocketTimeout;
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
keepSocketAlive(socket) {
|
| 149 |
+
const result = super.keepSocketAlive(socket);
|
| 150 |
+
// should not keepAlive, do nothing
|
| 151 |
+
if (!result) return result;
|
| 152 |
+
|
| 153 |
+
const customTimeout = this.calcSocketTimeout(socket);
|
| 154 |
+
if (typeof customTimeout === 'undefined') {
|
| 155 |
+
return true;
|
| 156 |
+
}
|
| 157 |
+
if (customTimeout <= 0) {
|
| 158 |
+
debug('%s(requests: %s, finished: %s) free but need to destroy by TTL, request count %s, diff is %s',
|
| 159 |
+
socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], customTimeout);
|
| 160 |
+
return false;
|
| 161 |
+
}
|
| 162 |
+
if (socket.timeout !== customTimeout) {
|
| 163 |
+
socket.setTimeout(customTimeout);
|
| 164 |
+
}
|
| 165 |
+
return true;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
// only call on addRequest
|
| 169 |
+
reuseSocket(...args) {
|
| 170 |
+
// reuseSocket(socket, req)
|
| 171 |
+
super.reuseSocket(...args);
|
| 172 |
+
const socket = args[0];
|
| 173 |
+
const req = args[1];
|
| 174 |
+
req.reusedSocket = true;
|
| 175 |
+
const agentTimeout = this.options.timeout;
|
| 176 |
+
if (getSocketTimeout(socket) !== agentTimeout) {
|
| 177 |
+
// reset timeout before use
|
| 178 |
+
socket.setTimeout(agentTimeout);
|
| 179 |
+
debug('%s reset timeout to %sms', socket[SOCKET_NAME], agentTimeout);
|
| 180 |
+
}
|
| 181 |
+
socket[SOCKET_REQUEST_COUNT]++;
|
| 182 |
+
debug('%s(requests: %s, finished: %s) reuse on addRequest, timeout %sms',
|
| 183 |
+
socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT],
|
| 184 |
+
getSocketTimeout(socket));
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
[CREATE_ID]() {
|
| 188 |
+
const id = this[CURRENT_ID]++;
|
| 189 |
+
if (this[CURRENT_ID] === Number.MAX_SAFE_INTEGER) this[CURRENT_ID] = 0;
|
| 190 |
+
return id;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
[INIT_SOCKET](socket, options) {
|
| 194 |
+
// bugfix here.
|
| 195 |
+
// https on node 8, 10 won't set agent.options.timeout by default
|
| 196 |
+
// TODO: need to fix on node itself
|
| 197 |
+
if (options.timeout) {
|
| 198 |
+
const timeout = getSocketTimeout(socket);
|
| 199 |
+
if (!timeout) {
|
| 200 |
+
socket.setTimeout(options.timeout);
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
if (this.options.keepAlive) {
|
| 205 |
+
// Disable Nagle's algorithm: http://blog.caustik.com/2012/04/08/scaling-node-js-to-100k-concurrent-connections/
|
| 206 |
+
// https://fengmk2.com/benchmark/nagle-algorithm-delayed-ack-mock.html
|
| 207 |
+
socket.setNoDelay(true);
|
| 208 |
+
}
|
| 209 |
+
this.createSocketCount++;
|
| 210 |
+
if (this.options.socketActiveTTL) {
|
| 211 |
+
socket[SOCKET_CREATED_TIME] = Date.now();
|
| 212 |
+
}
|
| 213 |
+
// don't show the hole '-----BEGIN CERTIFICATE----' key string
|
| 214 |
+
socket[SOCKET_NAME] = `sock[${this[CREATE_ID]()}#${options._agentKey}]`.split('-----BEGIN', 1)[0];
|
| 215 |
+
socket[SOCKET_REQUEST_COUNT] = 1;
|
| 216 |
+
socket[SOCKET_REQUEST_FINISHED_COUNT] = 0;
|
| 217 |
+
installListeners(this, socket, options);
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
createConnection(options, oncreate) {
|
| 221 |
+
let called = false;
|
| 222 |
+
const onNewCreate = (err, socket) => {
|
| 223 |
+
if (called) return;
|
| 224 |
+
called = true;
|
| 225 |
+
|
| 226 |
+
if (err) {
|
| 227 |
+
this.createSocketErrorCount++;
|
| 228 |
+
return oncreate(err);
|
| 229 |
+
}
|
| 230 |
+
this[INIT_SOCKET](socket, options);
|
| 231 |
+
oncreate(err, socket);
|
| 232 |
+
};
|
| 233 |
+
|
| 234 |
+
const newSocket = super.createConnection(options, onNewCreate);
|
| 235 |
+
if (newSocket) onNewCreate(null, newSocket);
|
| 236 |
+
return newSocket;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
get statusChanged() {
|
| 240 |
+
const changed = this.createSocketCount !== this.createSocketCountLastCheck ||
|
| 241 |
+
this.createSocketErrorCount !== this.createSocketErrorCountLastCheck ||
|
| 242 |
+
this.closeSocketCount !== this.closeSocketCountLastCheck ||
|
| 243 |
+
this.errorSocketCount !== this.errorSocketCountLastCheck ||
|
| 244 |
+
this.timeoutSocketCount !== this.timeoutSocketCountLastCheck ||
|
| 245 |
+
this.requestCount !== this.requestCountLastCheck;
|
| 246 |
+
if (changed) {
|
| 247 |
+
this.createSocketCountLastCheck = this.createSocketCount;
|
| 248 |
+
this.createSocketErrorCountLastCheck = this.createSocketErrorCount;
|
| 249 |
+
this.closeSocketCountLastCheck = this.closeSocketCount;
|
| 250 |
+
this.errorSocketCountLastCheck = this.errorSocketCount;
|
| 251 |
+
this.timeoutSocketCountLastCheck = this.timeoutSocketCount;
|
| 252 |
+
this.requestCountLastCheck = this.requestCount;
|
| 253 |
+
}
|
| 254 |
+
return changed;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
getCurrentStatus() {
|
| 258 |
+
return {
|
| 259 |
+
createSocketCount: this.createSocketCount,
|
| 260 |
+
createSocketErrorCount: this.createSocketErrorCount,
|
| 261 |
+
closeSocketCount: this.closeSocketCount,
|
| 262 |
+
errorSocketCount: this.errorSocketCount,
|
| 263 |
+
timeoutSocketCount: this.timeoutSocketCount,
|
| 264 |
+
requestCount: this.requestCount,
|
| 265 |
+
freeSockets: inspect(this.freeSockets),
|
| 266 |
+
sockets: inspect(this.sockets),
|
| 267 |
+
requests: inspect(this.requests),
|
| 268 |
+
};
|
| 269 |
+
}
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
// node 8 don't has timeout attribute on socket
|
| 273 |
+
// https://github.com/nodejs/node/pull/21204/files#diff-e6ef024c3775d787c38487a6309e491dR408
|
| 274 |
+
function getSocketTimeout(socket) {
|
| 275 |
+
return socket.timeout || socket._idleTimeout;
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
function installListeners(agent, socket, options) {
|
| 279 |
+
debug('%s create, timeout %sms', socket[SOCKET_NAME], getSocketTimeout(socket));
|
| 280 |
+
|
| 281 |
+
// listener socket events: close, timeout, error, free
|
| 282 |
+
function onFree() {
|
| 283 |
+
// create and socket.emit('free') logic
|
| 284 |
+
// https://github.com/nodejs/node/blob/master/lib/_http_agent.js#L311
|
| 285 |
+
// no req on the socket, it should be the new socket
|
| 286 |
+
if (!socket._httpMessage && socket[SOCKET_REQUEST_COUNT] === 1) return;
|
| 287 |
+
|
| 288 |
+
socket[SOCKET_REQUEST_FINISHED_COUNT]++;
|
| 289 |
+
agent.requestCount++;
|
| 290 |
+
debug('%s(requests: %s, finished: %s) free',
|
| 291 |
+
socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]);
|
| 292 |
+
|
| 293 |
+
// should reuse on pedding requests?
|
| 294 |
+
const name = agent.getName(options);
|
| 295 |
+
if (socket.writable && agent.requests[name] && agent.requests[name].length) {
|
| 296 |
+
// will be reuse on agent free listener
|
| 297 |
+
socket[SOCKET_REQUEST_COUNT]++;
|
| 298 |
+
debug('%s(requests: %s, finished: %s) will be reuse on agent free event',
|
| 299 |
+
socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]);
|
| 300 |
+
}
|
| 301 |
+
}
|
| 302 |
+
socket.on('free', onFree);
|
| 303 |
+
|
| 304 |
+
function onClose(isError) {
|
| 305 |
+
debug('%s(requests: %s, finished: %s) close, isError: %s',
|
| 306 |
+
socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT], isError);
|
| 307 |
+
agent.closeSocketCount++;
|
| 308 |
+
}
|
| 309 |
+
socket.on('close', onClose);
|
| 310 |
+
|
| 311 |
+
// start socket timeout handler
|
| 312 |
+
function onTimeout() {
|
| 313 |
+
// onTimeout and emitRequestTimeout(_http_client.js)
|
| 314 |
+
// https://github.com/nodejs/node/blob/v12.x/lib/_http_client.js#L711
|
| 315 |
+
const listenerCount = socket.listeners('timeout').length;
|
| 316 |
+
// node <= 10, default listenerCount is 1, onTimeout
|
| 317 |
+
// 11 < node <= 12, default listenerCount is 2, onTimeout and emitRequestTimeout
|
| 318 |
+
// node >= 13, default listenerCount is 3, onTimeout,
|
| 319 |
+
// onTimeout(https://github.com/nodejs/node/pull/32000/files#diff-5f7fb0850412c6be189faeddea6c5359R333)
|
| 320 |
+
// and emitRequestTimeout
|
| 321 |
+
const timeout = getSocketTimeout(socket);
|
| 322 |
+
const req = socket._httpMessage;
|
| 323 |
+
const reqTimeoutListenerCount = req && req.listeners('timeout').length || 0;
|
| 324 |
+
debug('%s(requests: %s, finished: %s) timeout after %sms, listeners %s, defaultTimeoutListenerCount %s, hasHttpRequest %s, HttpRequest timeoutListenerCount %s',
|
| 325 |
+
socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT],
|
| 326 |
+
timeout, listenerCount, defaultTimeoutListenerCount, !!req, reqTimeoutListenerCount);
|
| 327 |
+
if (debug.enabled) {
|
| 328 |
+
debug('timeout listeners: %s', socket.listeners('timeout').map(f => f.name).join(', '));
|
| 329 |
+
}
|
| 330 |
+
agent.timeoutSocketCount++;
|
| 331 |
+
const name = agent.getName(options);
|
| 332 |
+
if (agent.freeSockets[name] && agent.freeSockets[name].indexOf(socket) !== -1) {
|
| 333 |
+
// free socket timeout, destroy quietly
|
| 334 |
+
socket.destroy();
|
| 335 |
+
// Remove it from freeSockets list immediately to prevent new requests
|
| 336 |
+
// from being sent through this socket.
|
| 337 |
+
agent.removeSocket(socket, options);
|
| 338 |
+
debug('%s is free, destroy quietly', socket[SOCKET_NAME]);
|
| 339 |
+
} else {
|
| 340 |
+
// if there is no any request socket timeout handler,
|
| 341 |
+
// agent need to handle socket timeout itself.
|
| 342 |
+
//
|
| 343 |
+
// custom request socket timeout handle logic must follow these rules:
|
| 344 |
+
// 1. Destroy socket first
|
| 345 |
+
// 2. Must emit socket 'agentRemove' event tell agent remove socket
|
| 346 |
+
// from freeSockets list immediately.
|
| 347 |
+
// Otherise you may be get 'socket hang up' error when reuse
|
| 348 |
+
// free socket and timeout happen in the same time.
|
| 349 |
+
if (reqTimeoutListenerCount === 0) {
|
| 350 |
+
const error = new Error('Socket timeout');
|
| 351 |
+
error.code = 'ERR_SOCKET_TIMEOUT';
|
| 352 |
+
error.timeout = timeout;
|
| 353 |
+
// must manually call socket.end() or socket.destroy() to end the connection.
|
| 354 |
+
// https://nodejs.org/dist/latest-v10.x/docs/api/net.html#net_socket_settimeout_timeout_callback
|
| 355 |
+
socket.destroy(error);
|
| 356 |
+
agent.removeSocket(socket, options);
|
| 357 |
+
debug('%s destroy with timeout error', socket[SOCKET_NAME]);
|
| 358 |
+
}
|
| 359 |
+
}
|
| 360 |
+
}
|
| 361 |
+
socket.on('timeout', onTimeout);
|
| 362 |
+
|
| 363 |
+
function onError(err) {
|
| 364 |
+
const listenerCount = socket.listeners('error').length;
|
| 365 |
+
debug('%s(requests: %s, finished: %s) error: %s, listenerCount: %s',
|
| 366 |
+
socket[SOCKET_NAME], socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT],
|
| 367 |
+
err, listenerCount);
|
| 368 |
+
agent.errorSocketCount++;
|
| 369 |
+
if (listenerCount === 1) {
|
| 370 |
+
// if socket don't contain error event handler, don't catch it, emit it again
|
| 371 |
+
debug('%s emit uncaught error event', socket[SOCKET_NAME]);
|
| 372 |
+
socket.removeListener('error', onError);
|
| 373 |
+
socket.emit('error', err);
|
| 374 |
+
}
|
| 375 |
+
}
|
| 376 |
+
socket.on('error', onError);
|
| 377 |
+
|
| 378 |
+
function onRemove() {
|
| 379 |
+
debug('%s(requests: %s, finished: %s) agentRemove',
|
| 380 |
+
socket[SOCKET_NAME],
|
| 381 |
+
socket[SOCKET_REQUEST_COUNT], socket[SOCKET_REQUEST_FINISHED_COUNT]);
|
| 382 |
+
// We need this function for cases like HTTP 'upgrade'
|
| 383 |
+
// (defined by WebSockets) where we need to remove a socket from the
|
| 384 |
+
// pool because it'll be locked up indefinitely
|
| 385 |
+
socket.removeListener('close', onClose);
|
| 386 |
+
socket.removeListener('error', onError);
|
| 387 |
+
socket.removeListener('free', onFree);
|
| 388 |
+
socket.removeListener('timeout', onTimeout);
|
| 389 |
+
socket.removeListener('agentRemove', onRemove);
|
| 390 |
+
}
|
| 391 |
+
socket.on('agentRemove', onRemove);
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
module.exports = Agent;
|
| 395 |
+
|
| 396 |
+
function inspect(obj) {
|
| 397 |
+
const res = {};
|
| 398 |
+
for (const key in obj) {
|
| 399 |
+
res[key] = obj[key].length;
|
| 400 |
+
}
|
| 401 |
+
return res;
|
| 402 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/agentkeepalive/lib/constants.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
module.exports = {
|
| 4 |
+
// agent
|
| 5 |
+
CURRENT_ID: Symbol('agentkeepalive#currentId'),
|
| 6 |
+
CREATE_ID: Symbol('agentkeepalive#createId'),
|
| 7 |
+
INIT_SOCKET: Symbol('agentkeepalive#initSocket'),
|
| 8 |
+
CREATE_HTTPS_CONNECTION: Symbol('agentkeepalive#createHttpsConnection'),
|
| 9 |
+
// socket
|
| 10 |
+
SOCKET_CREATED_TIME: Symbol('agentkeepalive#socketCreatedTime'),
|
| 11 |
+
SOCKET_NAME: Symbol('agentkeepalive#socketName'),
|
| 12 |
+
SOCKET_REQUEST_COUNT: Symbol('agentkeepalive#socketRequestCount'),
|
| 13 |
+
SOCKET_REQUEST_FINISHED_COUNT: Symbol('agentkeepalive#socketRequestFinishedCount'),
|
| 14 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/agentkeepalive/lib/https_agent.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
const OriginalHttpsAgent = require('https').Agent;
|
| 4 |
+
const HttpAgent = require('./agent');
|
| 5 |
+
const {
|
| 6 |
+
INIT_SOCKET,
|
| 7 |
+
CREATE_HTTPS_CONNECTION,
|
| 8 |
+
} = require('./constants');
|
| 9 |
+
|
| 10 |
+
class HttpsAgent extends HttpAgent {
|
| 11 |
+
constructor(options) {
|
| 12 |
+
super(options);
|
| 13 |
+
|
| 14 |
+
this.defaultPort = 443;
|
| 15 |
+
this.protocol = 'https:';
|
| 16 |
+
this.maxCachedSessions = this.options.maxCachedSessions;
|
| 17 |
+
/* istanbul ignore next */
|
| 18 |
+
if (this.maxCachedSessions === undefined) {
|
| 19 |
+
this.maxCachedSessions = 100;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
this._sessionCache = {
|
| 23 |
+
map: {},
|
| 24 |
+
list: [],
|
| 25 |
+
};
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
createConnection(options, oncreate) {
|
| 29 |
+
const socket = this[CREATE_HTTPS_CONNECTION](options, oncreate);
|
| 30 |
+
this[INIT_SOCKET](socket, options);
|
| 31 |
+
return socket;
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
// https://github.com/nodejs/node/blob/master/lib/https.js#L89
|
| 36 |
+
HttpsAgent.prototype[CREATE_HTTPS_CONNECTION] = OriginalHttpsAgent.prototype.createConnection;
|
| 37 |
+
|
| 38 |
+
[
|
| 39 |
+
'getName',
|
| 40 |
+
'_getSession',
|
| 41 |
+
'_cacheSession',
|
| 42 |
+
// https://github.com/nodejs/node/pull/4982
|
| 43 |
+
'_evictSession',
|
| 44 |
+
].forEach(function(method) {
|
| 45 |
+
/* istanbul ignore next */
|
| 46 |
+
if (typeof OriginalHttpsAgent.prototype[method] === 'function') {
|
| 47 |
+
HttpsAgent.prototype[method] = OriginalHttpsAgent.prototype[method];
|
| 48 |
+
}
|
| 49 |
+
});
|
| 50 |
+
|
| 51 |
+
module.exports = HttpsAgent;
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/dist/ajv.bundle.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/dist/ajv.min.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/dist/ajv.min.js.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/ajv.d.ts
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
declare var ajv: {
|
| 2 |
+
(options?: ajv.Options): ajv.Ajv;
|
| 3 |
+
new(options?: ajv.Options): ajv.Ajv;
|
| 4 |
+
ValidationError: typeof AjvErrors.ValidationError;
|
| 5 |
+
MissingRefError: typeof AjvErrors.MissingRefError;
|
| 6 |
+
$dataMetaSchema: object;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
declare namespace AjvErrors {
|
| 10 |
+
class ValidationError extends Error {
|
| 11 |
+
constructor(errors: Array<ajv.ErrorObject>);
|
| 12 |
+
|
| 13 |
+
message: string;
|
| 14 |
+
errors: Array<ajv.ErrorObject>;
|
| 15 |
+
ajv: true;
|
| 16 |
+
validation: true;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
class MissingRefError extends Error {
|
| 20 |
+
constructor(baseId: string, ref: string, message?: string);
|
| 21 |
+
static message: (baseId: string, ref: string) => string;
|
| 22 |
+
|
| 23 |
+
message: string;
|
| 24 |
+
missingRef: string;
|
| 25 |
+
missingSchema: string;
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
declare namespace ajv {
|
| 30 |
+
type ValidationError = AjvErrors.ValidationError;
|
| 31 |
+
|
| 32 |
+
type MissingRefError = AjvErrors.MissingRefError;
|
| 33 |
+
|
| 34 |
+
interface Ajv {
|
| 35 |
+
/**
|
| 36 |
+
* Validate data using schema
|
| 37 |
+
* Schema will be compiled and cached (using serialized JSON as key, [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used to serialize by default).
|
| 38 |
+
* @param {string|object|Boolean} schemaKeyRef key, ref or schema object
|
| 39 |
+
* @param {Any} data to be validated
|
| 40 |
+
* @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
|
| 41 |
+
*/
|
| 42 |
+
validate(schemaKeyRef: object | string | boolean, data: any): boolean | PromiseLike<any>;
|
| 43 |
+
/**
|
| 44 |
+
* Create validating function for passed schema.
|
| 45 |
+
* @param {object|Boolean} schema schema object
|
| 46 |
+
* @return {Function} validating function
|
| 47 |
+
*/
|
| 48 |
+
compile(schema: object | boolean): ValidateFunction;
|
| 49 |
+
/**
|
| 50 |
+
* Creates validating function for passed schema with asynchronous loading of missing schemas.
|
| 51 |
+
* `loadSchema` option should be a function that accepts schema uri and node-style callback.
|
| 52 |
+
* @this Ajv
|
| 53 |
+
* @param {object|Boolean} schema schema object
|
| 54 |
+
* @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
|
| 55 |
+
* @param {Function} callback optional node-style callback, it is always called with 2 parameters: error (or null) and validating function.
|
| 56 |
+
* @return {PromiseLike<ValidateFunction>} validating function
|
| 57 |
+
*/
|
| 58 |
+
compileAsync(schema: object | boolean, meta?: Boolean, callback?: (err: Error, validate: ValidateFunction) => any): PromiseLike<ValidateFunction>;
|
| 59 |
+
/**
|
| 60 |
+
* Adds schema to the instance.
|
| 61 |
+
* @param {object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
|
| 62 |
+
* @param {string} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
|
| 63 |
+
* @return {Ajv} this for method chaining
|
| 64 |
+
*/
|
| 65 |
+
addSchema(schema: Array<object> | object, key?: string): Ajv;
|
| 66 |
+
/**
|
| 67 |
+
* Add schema that will be used to validate other schemas
|
| 68 |
+
* options in META_IGNORE_OPTIONS are alway set to false
|
| 69 |
+
* @param {object} schema schema object
|
| 70 |
+
* @param {string} key optional schema key
|
| 71 |
+
* @return {Ajv} this for method chaining
|
| 72 |
+
*/
|
| 73 |
+
addMetaSchema(schema: object, key?: string): Ajv;
|
| 74 |
+
/**
|
| 75 |
+
* Validate schema
|
| 76 |
+
* @param {object|Boolean} schema schema to validate
|
| 77 |
+
* @return {Boolean} true if schema is valid
|
| 78 |
+
*/
|
| 79 |
+
validateSchema(schema: object | boolean): boolean;
|
| 80 |
+
/**
|
| 81 |
+
* Get compiled schema from the instance by `key` or `ref`.
|
| 82 |
+
* @param {string} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id).
|
| 83 |
+
* @return {Function} schema validating function (with property `schema`). Returns undefined if keyRef can't be resolved to an existing schema.
|
| 84 |
+
*/
|
| 85 |
+
getSchema(keyRef: string): ValidateFunction | undefined;
|
| 86 |
+
/**
|
| 87 |
+
* Remove cached schema(s).
|
| 88 |
+
* If no parameter is passed all schemas but meta-schemas are removed.
|
| 89 |
+
* If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
|
| 90 |
+
* Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
|
| 91 |
+
* @param {string|object|RegExp|Boolean} schemaKeyRef key, ref, pattern to match key/ref or schema object
|
| 92 |
+
* @return {Ajv} this for method chaining
|
| 93 |
+
*/
|
| 94 |
+
removeSchema(schemaKeyRef?: object | string | RegExp | boolean): Ajv;
|
| 95 |
+
/**
|
| 96 |
+
* Add custom format
|
| 97 |
+
* @param {string} name format name
|
| 98 |
+
* @param {string|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid)
|
| 99 |
+
* @return {Ajv} this for method chaining
|
| 100 |
+
*/
|
| 101 |
+
addFormat(name: string, format: FormatValidator | FormatDefinition): Ajv;
|
| 102 |
+
/**
|
| 103 |
+
* Define custom keyword
|
| 104 |
+
* @this Ajv
|
| 105 |
+
* @param {string} keyword custom keyword, should be a valid identifier, should be different from all standard, custom and macro keywords.
|
| 106 |
+
* @param {object} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`.
|
| 107 |
+
* @return {Ajv} this for method chaining
|
| 108 |
+
*/
|
| 109 |
+
addKeyword(keyword: string, definition: KeywordDefinition): Ajv;
|
| 110 |
+
/**
|
| 111 |
+
* Get keyword definition
|
| 112 |
+
* @this Ajv
|
| 113 |
+
* @param {string} keyword pre-defined or custom keyword.
|
| 114 |
+
* @return {object|Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise.
|
| 115 |
+
*/
|
| 116 |
+
getKeyword(keyword: string): object | boolean;
|
| 117 |
+
/**
|
| 118 |
+
* Remove keyword
|
| 119 |
+
* @this Ajv
|
| 120 |
+
* @param {string} keyword pre-defined or custom keyword.
|
| 121 |
+
* @return {Ajv} this for method chaining
|
| 122 |
+
*/
|
| 123 |
+
removeKeyword(keyword: string): Ajv;
|
| 124 |
+
/**
|
| 125 |
+
* Validate keyword
|
| 126 |
+
* @this Ajv
|
| 127 |
+
* @param {object} definition keyword definition object
|
| 128 |
+
* @param {boolean} throwError true to throw exception if definition is invalid
|
| 129 |
+
* @return {boolean} validation result
|
| 130 |
+
*/
|
| 131 |
+
validateKeyword(definition: KeywordDefinition, throwError: boolean): boolean;
|
| 132 |
+
/**
|
| 133 |
+
* Convert array of error message objects to string
|
| 134 |
+
* @param {Array<object>} errors optional array of validation errors, if not passed errors from the instance are used.
|
| 135 |
+
* @param {object} options optional options with properties `separator` and `dataVar`.
|
| 136 |
+
* @return {string} human readable string with all errors descriptions
|
| 137 |
+
*/
|
| 138 |
+
errorsText(errors?: Array<ErrorObject> | null, options?: ErrorsTextOptions): string;
|
| 139 |
+
errors?: Array<ErrorObject> | null;
|
| 140 |
+
_opts: Options;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
interface CustomLogger {
|
| 144 |
+
log(...args: any[]): any;
|
| 145 |
+
warn(...args: any[]): any;
|
| 146 |
+
error(...args: any[]): any;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
interface ValidateFunction {
|
| 150 |
+
(
|
| 151 |
+
data: any,
|
| 152 |
+
dataPath?: string,
|
| 153 |
+
parentData?: object | Array<any>,
|
| 154 |
+
parentDataProperty?: string | number,
|
| 155 |
+
rootData?: object | Array<any>
|
| 156 |
+
): boolean | PromiseLike<any>;
|
| 157 |
+
schema?: object | boolean;
|
| 158 |
+
errors?: null | Array<ErrorObject>;
|
| 159 |
+
refs?: object;
|
| 160 |
+
refVal?: Array<any>;
|
| 161 |
+
root?: ValidateFunction | object;
|
| 162 |
+
$async?: true;
|
| 163 |
+
source?: object;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
interface Options {
|
| 167 |
+
$data?: boolean;
|
| 168 |
+
allErrors?: boolean;
|
| 169 |
+
verbose?: boolean;
|
| 170 |
+
jsonPointers?: boolean;
|
| 171 |
+
uniqueItems?: boolean;
|
| 172 |
+
unicode?: boolean;
|
| 173 |
+
format?: false | string;
|
| 174 |
+
formats?: object;
|
| 175 |
+
keywords?: object;
|
| 176 |
+
unknownFormats?: true | string[] | 'ignore';
|
| 177 |
+
schemas?: Array<object> | object;
|
| 178 |
+
schemaId?: '$id' | 'id' | 'auto';
|
| 179 |
+
missingRefs?: true | 'ignore' | 'fail';
|
| 180 |
+
extendRefs?: true | 'ignore' | 'fail';
|
| 181 |
+
loadSchema?: (uri: string, cb?: (err: Error, schema: object) => void) => PromiseLike<object | boolean>;
|
| 182 |
+
removeAdditional?: boolean | 'all' | 'failing';
|
| 183 |
+
useDefaults?: boolean | 'empty' | 'shared';
|
| 184 |
+
coerceTypes?: boolean | 'array';
|
| 185 |
+
strictDefaults?: boolean | 'log';
|
| 186 |
+
strictKeywords?: boolean | 'log';
|
| 187 |
+
strictNumbers?: boolean;
|
| 188 |
+
async?: boolean | string;
|
| 189 |
+
transpile?: string | ((code: string) => string);
|
| 190 |
+
meta?: boolean | object;
|
| 191 |
+
validateSchema?: boolean | 'log';
|
| 192 |
+
addUsedSchema?: boolean;
|
| 193 |
+
inlineRefs?: boolean | number;
|
| 194 |
+
passContext?: boolean;
|
| 195 |
+
loopRequired?: number;
|
| 196 |
+
ownProperties?: boolean;
|
| 197 |
+
multipleOfPrecision?: boolean | number;
|
| 198 |
+
errorDataPath?: string,
|
| 199 |
+
messages?: boolean;
|
| 200 |
+
sourceCode?: boolean;
|
| 201 |
+
processCode?: (code: string, schema: object) => string;
|
| 202 |
+
cache?: object;
|
| 203 |
+
logger?: CustomLogger | false;
|
| 204 |
+
nullable?: boolean;
|
| 205 |
+
serialize?: ((schema: object | boolean) => any) | false;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
type FormatValidator = string | RegExp | ((data: string) => boolean | PromiseLike<any>);
|
| 209 |
+
type NumberFormatValidator = ((data: number) => boolean | PromiseLike<any>);
|
| 210 |
+
|
| 211 |
+
interface NumberFormatDefinition {
|
| 212 |
+
type: "number",
|
| 213 |
+
validate: NumberFormatValidator;
|
| 214 |
+
compare?: (data1: number, data2: number) => number;
|
| 215 |
+
async?: boolean;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
interface StringFormatDefinition {
|
| 219 |
+
type?: "string",
|
| 220 |
+
validate: FormatValidator;
|
| 221 |
+
compare?: (data1: string, data2: string) => number;
|
| 222 |
+
async?: boolean;
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
type FormatDefinition = NumberFormatDefinition | StringFormatDefinition;
|
| 226 |
+
|
| 227 |
+
interface KeywordDefinition {
|
| 228 |
+
type?: string | Array<string>;
|
| 229 |
+
async?: boolean;
|
| 230 |
+
$data?: boolean;
|
| 231 |
+
errors?: boolean | string;
|
| 232 |
+
metaSchema?: object;
|
| 233 |
+
// schema: false makes validate not to expect schema (ValidateFunction)
|
| 234 |
+
schema?: boolean;
|
| 235 |
+
statements?: boolean;
|
| 236 |
+
dependencies?: Array<string>;
|
| 237 |
+
modifying?: boolean;
|
| 238 |
+
valid?: boolean;
|
| 239 |
+
// one and only one of the following properties should be present
|
| 240 |
+
validate?: SchemaValidateFunction | ValidateFunction;
|
| 241 |
+
compile?: (schema: any, parentSchema: object, it: CompilationContext) => ValidateFunction;
|
| 242 |
+
macro?: (schema: any, parentSchema: object, it: CompilationContext) => object | boolean;
|
| 243 |
+
inline?: (it: CompilationContext, keyword: string, schema: any, parentSchema: object) => string;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
interface CompilationContext {
|
| 247 |
+
level: number;
|
| 248 |
+
dataLevel: number;
|
| 249 |
+
dataPathArr: string[];
|
| 250 |
+
schema: any;
|
| 251 |
+
schemaPath: string;
|
| 252 |
+
baseId: string;
|
| 253 |
+
async: boolean;
|
| 254 |
+
opts: Options;
|
| 255 |
+
formats: {
|
| 256 |
+
[index: string]: FormatDefinition | undefined;
|
| 257 |
+
};
|
| 258 |
+
keywords: {
|
| 259 |
+
[index: string]: KeywordDefinition | undefined;
|
| 260 |
+
};
|
| 261 |
+
compositeRule: boolean;
|
| 262 |
+
validate: (schema: object) => boolean;
|
| 263 |
+
util: {
|
| 264 |
+
copy(obj: any, target?: any): any;
|
| 265 |
+
toHash(source: string[]): { [index: string]: true | undefined };
|
| 266 |
+
equal(obj: any, target: any): boolean;
|
| 267 |
+
getProperty(str: string): string;
|
| 268 |
+
schemaHasRules(schema: object, rules: any): string;
|
| 269 |
+
escapeQuotes(str: string): string;
|
| 270 |
+
toQuotedString(str: string): string;
|
| 271 |
+
getData(jsonPointer: string, dataLevel: number, paths: string[]): string;
|
| 272 |
+
escapeJsonPointer(str: string): string;
|
| 273 |
+
unescapeJsonPointer(str: string): string;
|
| 274 |
+
escapeFragment(str: string): string;
|
| 275 |
+
unescapeFragment(str: string): string;
|
| 276 |
+
};
|
| 277 |
+
self: Ajv;
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
interface SchemaValidateFunction {
|
| 281 |
+
(
|
| 282 |
+
schema: any,
|
| 283 |
+
data: any,
|
| 284 |
+
parentSchema?: object,
|
| 285 |
+
dataPath?: string,
|
| 286 |
+
parentData?: object | Array<any>,
|
| 287 |
+
parentDataProperty?: string | number,
|
| 288 |
+
rootData?: object | Array<any>
|
| 289 |
+
): boolean | PromiseLike<any>;
|
| 290 |
+
errors?: Array<ErrorObject>;
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
interface ErrorsTextOptions {
|
| 294 |
+
separator?: string;
|
| 295 |
+
dataVar?: string;
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
interface ErrorObject {
|
| 299 |
+
keyword: string;
|
| 300 |
+
dataPath: string;
|
| 301 |
+
schemaPath: string;
|
| 302 |
+
params: ErrorParameters;
|
| 303 |
+
// Added to validation errors of propertyNames keyword schema
|
| 304 |
+
propertyName?: string;
|
| 305 |
+
// Excluded if messages set to false.
|
| 306 |
+
message?: string;
|
| 307 |
+
// These are added with the `verbose` option.
|
| 308 |
+
schema?: any;
|
| 309 |
+
parentSchema?: object;
|
| 310 |
+
data?: any;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
type ErrorParameters = RefParams | LimitParams | AdditionalPropertiesParams |
|
| 314 |
+
DependenciesParams | FormatParams | ComparisonParams |
|
| 315 |
+
MultipleOfParams | PatternParams | RequiredParams |
|
| 316 |
+
TypeParams | UniqueItemsParams | CustomParams |
|
| 317 |
+
PatternRequiredParams | PropertyNamesParams |
|
| 318 |
+
IfParams | SwitchParams | NoParams | EnumParams;
|
| 319 |
+
|
| 320 |
+
interface RefParams {
|
| 321 |
+
ref: string;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
interface LimitParams {
|
| 325 |
+
limit: number;
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
interface AdditionalPropertiesParams {
|
| 329 |
+
additionalProperty: string;
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
interface DependenciesParams {
|
| 333 |
+
property: string;
|
| 334 |
+
missingProperty: string;
|
| 335 |
+
depsCount: number;
|
| 336 |
+
deps: string;
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
interface FormatParams {
|
| 340 |
+
format: string
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
interface ComparisonParams {
|
| 344 |
+
comparison: string;
|
| 345 |
+
limit: number | string;
|
| 346 |
+
exclusive: boolean;
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
interface MultipleOfParams {
|
| 350 |
+
multipleOf: number;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
interface PatternParams {
|
| 354 |
+
pattern: string;
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
interface RequiredParams {
|
| 358 |
+
missingProperty: string;
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
interface TypeParams {
|
| 362 |
+
type: string;
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
interface UniqueItemsParams {
|
| 366 |
+
i: number;
|
| 367 |
+
j: number;
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
interface CustomParams {
|
| 371 |
+
keyword: string;
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
interface PatternRequiredParams {
|
| 375 |
+
missingPattern: string;
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
interface PropertyNamesParams {
|
| 379 |
+
propertyName: string;
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
interface IfParams {
|
| 383 |
+
failingKeyword: string;
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
interface SwitchParams {
|
| 387 |
+
caseIndex: number;
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
interface NoParams { }
|
| 391 |
+
|
| 392 |
+
interface EnumParams {
|
| 393 |
+
allowedValues: Array<any>;
|
| 394 |
+
}
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
export = ajv;
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/ajv.js
ADDED
|
@@ -0,0 +1,506 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var compileSchema = require('./compile')
|
| 4 |
+
, resolve = require('./compile/resolve')
|
| 5 |
+
, Cache = require('./cache')
|
| 6 |
+
, SchemaObject = require('./compile/schema_obj')
|
| 7 |
+
, stableStringify = require('fast-json-stable-stringify')
|
| 8 |
+
, formats = require('./compile/formats')
|
| 9 |
+
, rules = require('./compile/rules')
|
| 10 |
+
, $dataMetaSchema = require('./data')
|
| 11 |
+
, util = require('./compile/util');
|
| 12 |
+
|
| 13 |
+
module.exports = Ajv;
|
| 14 |
+
|
| 15 |
+
Ajv.prototype.validate = validate;
|
| 16 |
+
Ajv.prototype.compile = compile;
|
| 17 |
+
Ajv.prototype.addSchema = addSchema;
|
| 18 |
+
Ajv.prototype.addMetaSchema = addMetaSchema;
|
| 19 |
+
Ajv.prototype.validateSchema = validateSchema;
|
| 20 |
+
Ajv.prototype.getSchema = getSchema;
|
| 21 |
+
Ajv.prototype.removeSchema = removeSchema;
|
| 22 |
+
Ajv.prototype.addFormat = addFormat;
|
| 23 |
+
Ajv.prototype.errorsText = errorsText;
|
| 24 |
+
|
| 25 |
+
Ajv.prototype._addSchema = _addSchema;
|
| 26 |
+
Ajv.prototype._compile = _compile;
|
| 27 |
+
|
| 28 |
+
Ajv.prototype.compileAsync = require('./compile/async');
|
| 29 |
+
var customKeyword = require('./keyword');
|
| 30 |
+
Ajv.prototype.addKeyword = customKeyword.add;
|
| 31 |
+
Ajv.prototype.getKeyword = customKeyword.get;
|
| 32 |
+
Ajv.prototype.removeKeyword = customKeyword.remove;
|
| 33 |
+
Ajv.prototype.validateKeyword = customKeyword.validate;
|
| 34 |
+
|
| 35 |
+
var errorClasses = require('./compile/error_classes');
|
| 36 |
+
Ajv.ValidationError = errorClasses.Validation;
|
| 37 |
+
Ajv.MissingRefError = errorClasses.MissingRef;
|
| 38 |
+
Ajv.$dataMetaSchema = $dataMetaSchema;
|
| 39 |
+
|
| 40 |
+
var META_SCHEMA_ID = 'http://json-schema.org/draft-07/schema';
|
| 41 |
+
|
| 42 |
+
var META_IGNORE_OPTIONS = [ 'removeAdditional', 'useDefaults', 'coerceTypes', 'strictDefaults' ];
|
| 43 |
+
var META_SUPPORT_DATA = ['/properties'];
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Creates validator instance.
|
| 47 |
+
* Usage: `Ajv(opts)`
|
| 48 |
+
* @param {Object} opts optional options
|
| 49 |
+
* @return {Object} ajv instance
|
| 50 |
+
*/
|
| 51 |
+
function Ajv(opts) {
|
| 52 |
+
if (!(this instanceof Ajv)) return new Ajv(opts);
|
| 53 |
+
opts = this._opts = util.copy(opts) || {};
|
| 54 |
+
setLogger(this);
|
| 55 |
+
this._schemas = {};
|
| 56 |
+
this._refs = {};
|
| 57 |
+
this._fragments = {};
|
| 58 |
+
this._formats = formats(opts.format);
|
| 59 |
+
|
| 60 |
+
this._cache = opts.cache || new Cache;
|
| 61 |
+
this._loadingSchemas = {};
|
| 62 |
+
this._compilations = [];
|
| 63 |
+
this.RULES = rules();
|
| 64 |
+
this._getId = chooseGetId(opts);
|
| 65 |
+
|
| 66 |
+
opts.loopRequired = opts.loopRequired || Infinity;
|
| 67 |
+
if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true;
|
| 68 |
+
if (opts.serialize === undefined) opts.serialize = stableStringify;
|
| 69 |
+
this._metaOpts = getMetaSchemaOptions(this);
|
| 70 |
+
|
| 71 |
+
if (opts.formats) addInitialFormats(this);
|
| 72 |
+
if (opts.keywords) addInitialKeywords(this);
|
| 73 |
+
addDefaultMetaSchema(this);
|
| 74 |
+
if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta);
|
| 75 |
+
if (opts.nullable) this.addKeyword('nullable', {metaSchema: {type: 'boolean'}});
|
| 76 |
+
addInitialSchemas(this);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* Validate data using schema
|
| 83 |
+
* Schema will be compiled and cached (using serialized JSON as key. [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used to serialize.
|
| 84 |
+
* @this Ajv
|
| 85 |
+
* @param {String|Object} schemaKeyRef key, ref or schema object
|
| 86 |
+
* @param {Any} data to be validated
|
| 87 |
+
* @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`).
|
| 88 |
+
*/
|
| 89 |
+
function validate(schemaKeyRef, data) {
|
| 90 |
+
var v;
|
| 91 |
+
if (typeof schemaKeyRef == 'string') {
|
| 92 |
+
v = this.getSchema(schemaKeyRef);
|
| 93 |
+
if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"');
|
| 94 |
+
} else {
|
| 95 |
+
var schemaObj = this._addSchema(schemaKeyRef);
|
| 96 |
+
v = schemaObj.validate || this._compile(schemaObj);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
var valid = v(data);
|
| 100 |
+
if (v.$async !== true) this.errors = v.errors;
|
| 101 |
+
return valid;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
/**
|
| 106 |
+
* Create validating function for passed schema.
|
| 107 |
+
* @this Ajv
|
| 108 |
+
* @param {Object} schema schema object
|
| 109 |
+
* @param {Boolean} _meta true if schema is a meta-schema. Used internally to compile meta schemas of custom keywords.
|
| 110 |
+
* @return {Function} validating function
|
| 111 |
+
*/
|
| 112 |
+
function compile(schema, _meta) {
|
| 113 |
+
var schemaObj = this._addSchema(schema, undefined, _meta);
|
| 114 |
+
return schemaObj.validate || this._compile(schemaObj);
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
* Adds schema to the instance.
|
| 120 |
+
* @this Ajv
|
| 121 |
+
* @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored.
|
| 122 |
+
* @param {String} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`.
|
| 123 |
+
* @param {Boolean} _skipValidation true to skip schema validation. Used internally, option validateSchema should be used instead.
|
| 124 |
+
* @param {Boolean} _meta true if schema is a meta-schema. Used internally, addMetaSchema should be used instead.
|
| 125 |
+
* @return {Ajv} this for method chaining
|
| 126 |
+
*/
|
| 127 |
+
function addSchema(schema, key, _skipValidation, _meta) {
|
| 128 |
+
if (Array.isArray(schema)){
|
| 129 |
+
for (var i=0; i<schema.length; i++) this.addSchema(schema[i], undefined, _skipValidation, _meta);
|
| 130 |
+
return this;
|
| 131 |
+
}
|
| 132 |
+
var id = this._getId(schema);
|
| 133 |
+
if (id !== undefined && typeof id != 'string')
|
| 134 |
+
throw new Error('schema id must be string');
|
| 135 |
+
key = resolve.normalizeId(key || id);
|
| 136 |
+
checkUnique(this, key);
|
| 137 |
+
this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
|
| 138 |
+
return this;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* Add schema that will be used to validate other schemas
|
| 144 |
+
* options in META_IGNORE_OPTIONS are alway set to false
|
| 145 |
+
* @this Ajv
|
| 146 |
+
* @param {Object} schema schema object
|
| 147 |
+
* @param {String} key optional schema key
|
| 148 |
+
* @param {Boolean} skipValidation true to skip schema validation, can be used to override validateSchema option for meta-schema
|
| 149 |
+
* @return {Ajv} this for method chaining
|
| 150 |
+
*/
|
| 151 |
+
function addMetaSchema(schema, key, skipValidation) {
|
| 152 |
+
this.addSchema(schema, key, skipValidation, true);
|
| 153 |
+
return this;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
/**
|
| 158 |
+
* Validate schema
|
| 159 |
+
* @this Ajv
|
| 160 |
+
* @param {Object} schema schema to validate
|
| 161 |
+
* @param {Boolean} throwOrLogError pass true to throw (or log) an error if invalid
|
| 162 |
+
* @return {Boolean} true if schema is valid
|
| 163 |
+
*/
|
| 164 |
+
function validateSchema(schema, throwOrLogError) {
|
| 165 |
+
var $schema = schema.$schema;
|
| 166 |
+
if ($schema !== undefined && typeof $schema != 'string')
|
| 167 |
+
throw new Error('$schema must be a string');
|
| 168 |
+
$schema = $schema || this._opts.defaultMeta || defaultMeta(this);
|
| 169 |
+
if (!$schema) {
|
| 170 |
+
this.logger.warn('meta-schema not available');
|
| 171 |
+
this.errors = null;
|
| 172 |
+
return true;
|
| 173 |
+
}
|
| 174 |
+
var valid = this.validate($schema, schema);
|
| 175 |
+
if (!valid && throwOrLogError) {
|
| 176 |
+
var message = 'schema is invalid: ' + this.errorsText();
|
| 177 |
+
if (this._opts.validateSchema == 'log') this.logger.error(message);
|
| 178 |
+
else throw new Error(message);
|
| 179 |
+
}
|
| 180 |
+
return valid;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
function defaultMeta(self) {
|
| 185 |
+
var meta = self._opts.meta;
|
| 186 |
+
self._opts.defaultMeta = typeof meta == 'object'
|
| 187 |
+
? self._getId(meta) || meta
|
| 188 |
+
: self.getSchema(META_SCHEMA_ID)
|
| 189 |
+
? META_SCHEMA_ID
|
| 190 |
+
: undefined;
|
| 191 |
+
return self._opts.defaultMeta;
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
/**
|
| 196 |
+
* Get compiled schema from the instance by `key` or `ref`.
|
| 197 |
+
* @this Ajv
|
| 198 |
+
* @param {String} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id).
|
| 199 |
+
* @return {Function} schema validating function (with property `schema`).
|
| 200 |
+
*/
|
| 201 |
+
function getSchema(keyRef) {
|
| 202 |
+
var schemaObj = _getSchemaObj(this, keyRef);
|
| 203 |
+
switch (typeof schemaObj) {
|
| 204 |
+
case 'object': return schemaObj.validate || this._compile(schemaObj);
|
| 205 |
+
case 'string': return this.getSchema(schemaObj);
|
| 206 |
+
case 'undefined': return _getSchemaFragment(this, keyRef);
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
function _getSchemaFragment(self, ref) {
|
| 212 |
+
var res = resolve.schema.call(self, { schema: {} }, ref);
|
| 213 |
+
if (res) {
|
| 214 |
+
var schema = res.schema
|
| 215 |
+
, root = res.root
|
| 216 |
+
, baseId = res.baseId;
|
| 217 |
+
var v = compileSchema.call(self, schema, root, undefined, baseId);
|
| 218 |
+
self._fragments[ref] = new SchemaObject({
|
| 219 |
+
ref: ref,
|
| 220 |
+
fragment: true,
|
| 221 |
+
schema: schema,
|
| 222 |
+
root: root,
|
| 223 |
+
baseId: baseId,
|
| 224 |
+
validate: v
|
| 225 |
+
});
|
| 226 |
+
return v;
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
function _getSchemaObj(self, keyRef) {
|
| 232 |
+
keyRef = resolve.normalizeId(keyRef);
|
| 233 |
+
return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef];
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
/**
|
| 238 |
+
* Remove cached schema(s).
|
| 239 |
+
* If no parameter is passed all schemas but meta-schemas are removed.
|
| 240 |
+
* If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
|
| 241 |
+
* Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
|
| 242 |
+
* @this Ajv
|
| 243 |
+
* @param {String|Object|RegExp} schemaKeyRef key, ref, pattern to match key/ref or schema object
|
| 244 |
+
* @return {Ajv} this for method chaining
|
| 245 |
+
*/
|
| 246 |
+
function removeSchema(schemaKeyRef) {
|
| 247 |
+
if (schemaKeyRef instanceof RegExp) {
|
| 248 |
+
_removeAllSchemas(this, this._schemas, schemaKeyRef);
|
| 249 |
+
_removeAllSchemas(this, this._refs, schemaKeyRef);
|
| 250 |
+
return this;
|
| 251 |
+
}
|
| 252 |
+
switch (typeof schemaKeyRef) {
|
| 253 |
+
case 'undefined':
|
| 254 |
+
_removeAllSchemas(this, this._schemas);
|
| 255 |
+
_removeAllSchemas(this, this._refs);
|
| 256 |
+
this._cache.clear();
|
| 257 |
+
return this;
|
| 258 |
+
case 'string':
|
| 259 |
+
var schemaObj = _getSchemaObj(this, schemaKeyRef);
|
| 260 |
+
if (schemaObj) this._cache.del(schemaObj.cacheKey);
|
| 261 |
+
delete this._schemas[schemaKeyRef];
|
| 262 |
+
delete this._refs[schemaKeyRef];
|
| 263 |
+
return this;
|
| 264 |
+
case 'object':
|
| 265 |
+
var serialize = this._opts.serialize;
|
| 266 |
+
var cacheKey = serialize ? serialize(schemaKeyRef) : schemaKeyRef;
|
| 267 |
+
this._cache.del(cacheKey);
|
| 268 |
+
var id = this._getId(schemaKeyRef);
|
| 269 |
+
if (id) {
|
| 270 |
+
id = resolve.normalizeId(id);
|
| 271 |
+
delete this._schemas[id];
|
| 272 |
+
delete this._refs[id];
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
return this;
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
function _removeAllSchemas(self, schemas, regex) {
|
| 280 |
+
for (var keyRef in schemas) {
|
| 281 |
+
var schemaObj = schemas[keyRef];
|
| 282 |
+
if (!schemaObj.meta && (!regex || regex.test(keyRef))) {
|
| 283 |
+
self._cache.del(schemaObj.cacheKey);
|
| 284 |
+
delete schemas[keyRef];
|
| 285 |
+
}
|
| 286 |
+
}
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
/* @this Ajv */
|
| 291 |
+
function _addSchema(schema, skipValidation, meta, shouldAddSchema) {
|
| 292 |
+
if (typeof schema != 'object' && typeof schema != 'boolean')
|
| 293 |
+
throw new Error('schema should be object or boolean');
|
| 294 |
+
var serialize = this._opts.serialize;
|
| 295 |
+
var cacheKey = serialize ? serialize(schema) : schema;
|
| 296 |
+
var cached = this._cache.get(cacheKey);
|
| 297 |
+
if (cached) return cached;
|
| 298 |
+
|
| 299 |
+
shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
|
| 300 |
+
|
| 301 |
+
var id = resolve.normalizeId(this._getId(schema));
|
| 302 |
+
if (id && shouldAddSchema) checkUnique(this, id);
|
| 303 |
+
|
| 304 |
+
var willValidate = this._opts.validateSchema !== false && !skipValidation;
|
| 305 |
+
var recursiveMeta;
|
| 306 |
+
if (willValidate && !(recursiveMeta = id && id == resolve.normalizeId(schema.$schema)))
|
| 307 |
+
this.validateSchema(schema, true);
|
| 308 |
+
|
| 309 |
+
var localRefs = resolve.ids.call(this, schema);
|
| 310 |
+
|
| 311 |
+
var schemaObj = new SchemaObject({
|
| 312 |
+
id: id,
|
| 313 |
+
schema: schema,
|
| 314 |
+
localRefs: localRefs,
|
| 315 |
+
cacheKey: cacheKey,
|
| 316 |
+
meta: meta
|
| 317 |
+
});
|
| 318 |
+
|
| 319 |
+
if (id[0] != '#' && shouldAddSchema) this._refs[id] = schemaObj;
|
| 320 |
+
this._cache.put(cacheKey, schemaObj);
|
| 321 |
+
|
| 322 |
+
if (willValidate && recursiveMeta) this.validateSchema(schema, true);
|
| 323 |
+
|
| 324 |
+
return schemaObj;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
/* @this Ajv */
|
| 329 |
+
function _compile(schemaObj, root) {
|
| 330 |
+
if (schemaObj.compiling) {
|
| 331 |
+
schemaObj.validate = callValidate;
|
| 332 |
+
callValidate.schema = schemaObj.schema;
|
| 333 |
+
callValidate.errors = null;
|
| 334 |
+
callValidate.root = root ? root : callValidate;
|
| 335 |
+
if (schemaObj.schema.$async === true)
|
| 336 |
+
callValidate.$async = true;
|
| 337 |
+
return callValidate;
|
| 338 |
+
}
|
| 339 |
+
schemaObj.compiling = true;
|
| 340 |
+
|
| 341 |
+
var currentOpts;
|
| 342 |
+
if (schemaObj.meta) {
|
| 343 |
+
currentOpts = this._opts;
|
| 344 |
+
this._opts = this._metaOpts;
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
var v;
|
| 348 |
+
try { v = compileSchema.call(this, schemaObj.schema, root, schemaObj.localRefs); }
|
| 349 |
+
catch(e) {
|
| 350 |
+
delete schemaObj.validate;
|
| 351 |
+
throw e;
|
| 352 |
+
}
|
| 353 |
+
finally {
|
| 354 |
+
schemaObj.compiling = false;
|
| 355 |
+
if (schemaObj.meta) this._opts = currentOpts;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
schemaObj.validate = v;
|
| 359 |
+
schemaObj.refs = v.refs;
|
| 360 |
+
schemaObj.refVal = v.refVal;
|
| 361 |
+
schemaObj.root = v.root;
|
| 362 |
+
return v;
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
/* @this {*} - custom context, see passContext option */
|
| 366 |
+
function callValidate() {
|
| 367 |
+
/* jshint validthis: true */
|
| 368 |
+
var _validate = schemaObj.validate;
|
| 369 |
+
var result = _validate.apply(this, arguments);
|
| 370 |
+
callValidate.errors = _validate.errors;
|
| 371 |
+
return result;
|
| 372 |
+
}
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
|
| 376 |
+
function chooseGetId(opts) {
|
| 377 |
+
switch (opts.schemaId) {
|
| 378 |
+
case 'auto': return _get$IdOrId;
|
| 379 |
+
case 'id': return _getId;
|
| 380 |
+
default: return _get$Id;
|
| 381 |
+
}
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
/* @this Ajv */
|
| 385 |
+
function _getId(schema) {
|
| 386 |
+
if (schema.$id) this.logger.warn('schema $id ignored', schema.$id);
|
| 387 |
+
return schema.id;
|
| 388 |
+
}
|
| 389 |
+
|
| 390 |
+
/* @this Ajv */
|
| 391 |
+
function _get$Id(schema) {
|
| 392 |
+
if (schema.id) this.logger.warn('schema id ignored', schema.id);
|
| 393 |
+
return schema.$id;
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
function _get$IdOrId(schema) {
|
| 398 |
+
if (schema.$id && schema.id && schema.$id != schema.id)
|
| 399 |
+
throw new Error('schema $id is different from id');
|
| 400 |
+
return schema.$id || schema.id;
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
|
| 404 |
+
/**
|
| 405 |
+
* Convert array of error message objects to string
|
| 406 |
+
* @this Ajv
|
| 407 |
+
* @param {Array<Object>} errors optional array of validation errors, if not passed errors from the instance are used.
|
| 408 |
+
* @param {Object} options optional options with properties `separator` and `dataVar`.
|
| 409 |
+
* @return {String} human readable string with all errors descriptions
|
| 410 |
+
*/
|
| 411 |
+
function errorsText(errors, options) {
|
| 412 |
+
errors = errors || this.errors;
|
| 413 |
+
if (!errors) return 'No errors';
|
| 414 |
+
options = options || {};
|
| 415 |
+
var separator = options.separator === undefined ? ', ' : options.separator;
|
| 416 |
+
var dataVar = options.dataVar === undefined ? 'data' : options.dataVar;
|
| 417 |
+
|
| 418 |
+
var text = '';
|
| 419 |
+
for (var i=0; i<errors.length; i++) {
|
| 420 |
+
var e = errors[i];
|
| 421 |
+
if (e) text += dataVar + e.dataPath + ' ' + e.message + separator;
|
| 422 |
+
}
|
| 423 |
+
return text.slice(0, -separator.length);
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
|
| 427 |
+
/**
|
| 428 |
+
* Add custom format
|
| 429 |
+
* @this Ajv
|
| 430 |
+
* @param {String} name format name
|
| 431 |
+
* @param {String|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid)
|
| 432 |
+
* @return {Ajv} this for method chaining
|
| 433 |
+
*/
|
| 434 |
+
function addFormat(name, format) {
|
| 435 |
+
if (typeof format == 'string') format = new RegExp(format);
|
| 436 |
+
this._formats[name] = format;
|
| 437 |
+
return this;
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
+
|
| 441 |
+
function addDefaultMetaSchema(self) {
|
| 442 |
+
var $dataSchema;
|
| 443 |
+
if (self._opts.$data) {
|
| 444 |
+
$dataSchema = require('./refs/data.json');
|
| 445 |
+
self.addMetaSchema($dataSchema, $dataSchema.$id, true);
|
| 446 |
+
}
|
| 447 |
+
if (self._opts.meta === false) return;
|
| 448 |
+
var metaSchema = require('./refs/json-schema-draft-07.json');
|
| 449 |
+
if (self._opts.$data) metaSchema = $dataMetaSchema(metaSchema, META_SUPPORT_DATA);
|
| 450 |
+
self.addMetaSchema(metaSchema, META_SCHEMA_ID, true);
|
| 451 |
+
self._refs['http://json-schema.org/schema'] = META_SCHEMA_ID;
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
|
| 455 |
+
function addInitialSchemas(self) {
|
| 456 |
+
var optsSchemas = self._opts.schemas;
|
| 457 |
+
if (!optsSchemas) return;
|
| 458 |
+
if (Array.isArray(optsSchemas)) self.addSchema(optsSchemas);
|
| 459 |
+
else for (var key in optsSchemas) self.addSchema(optsSchemas[key], key);
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
function addInitialFormats(self) {
|
| 464 |
+
for (var name in self._opts.formats) {
|
| 465 |
+
var format = self._opts.formats[name];
|
| 466 |
+
self.addFormat(name, format);
|
| 467 |
+
}
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
+
|
| 471 |
+
function addInitialKeywords(self) {
|
| 472 |
+
for (var name in self._opts.keywords) {
|
| 473 |
+
var keyword = self._opts.keywords[name];
|
| 474 |
+
self.addKeyword(name, keyword);
|
| 475 |
+
}
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
|
| 479 |
+
function checkUnique(self, id) {
|
| 480 |
+
if (self._schemas[id] || self._refs[id])
|
| 481 |
+
throw new Error('schema with key or id "' + id + '" already exists');
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
|
| 485 |
+
function getMetaSchemaOptions(self) {
|
| 486 |
+
var metaOpts = util.copy(self._opts);
|
| 487 |
+
for (var i=0; i<META_IGNORE_OPTIONS.length; i++)
|
| 488 |
+
delete metaOpts[META_IGNORE_OPTIONS[i]];
|
| 489 |
+
return metaOpts;
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
|
| 493 |
+
function setLogger(self) {
|
| 494 |
+
var logger = self._opts.logger;
|
| 495 |
+
if (logger === false) {
|
| 496 |
+
self.logger = {log: noop, warn: noop, error: noop};
|
| 497 |
+
} else {
|
| 498 |
+
if (logger === undefined) logger = console;
|
| 499 |
+
if (!(typeof logger == 'object' && logger.log && logger.warn && logger.error))
|
| 500 |
+
throw new Error('logger must implement log, warn and error methods');
|
| 501 |
+
self.logger = logger;
|
| 502 |
+
}
|
| 503 |
+
}
|
| 504 |
+
|
| 505 |
+
|
| 506 |
+
function noop() {}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/cache.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
var Cache = module.exports = function Cache() {
|
| 5 |
+
this._cache = {};
|
| 6 |
+
};
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
Cache.prototype.put = function Cache_put(key, value) {
|
| 10 |
+
this._cache[key] = value;
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
Cache.prototype.get = function Cache_get(key) {
|
| 15 |
+
return this._cache[key];
|
| 16 |
+
};
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
Cache.prototype.del = function Cache_del(key) {
|
| 20 |
+
delete this._cache[key];
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
Cache.prototype.clear = function Cache_clear() {
|
| 25 |
+
this._cache = {};
|
| 26 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/async.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var MissingRefError = require('./error_classes').MissingRef;
|
| 4 |
+
|
| 5 |
+
module.exports = compileAsync;
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* Creates validating function for passed schema with asynchronous loading of missing schemas.
|
| 10 |
+
* `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema.
|
| 11 |
+
* @this Ajv
|
| 12 |
+
* @param {Object} schema schema object
|
| 13 |
+
* @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
|
| 14 |
+
* @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function.
|
| 15 |
+
* @return {Promise} promise that resolves with a validating function.
|
| 16 |
+
*/
|
| 17 |
+
function compileAsync(schema, meta, callback) {
|
| 18 |
+
/* eslint no-shadow: 0 */
|
| 19 |
+
/* global Promise */
|
| 20 |
+
/* jshint validthis: true */
|
| 21 |
+
var self = this;
|
| 22 |
+
if (typeof this._opts.loadSchema != 'function')
|
| 23 |
+
throw new Error('options.loadSchema should be a function');
|
| 24 |
+
|
| 25 |
+
if (typeof meta == 'function') {
|
| 26 |
+
callback = meta;
|
| 27 |
+
meta = undefined;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
var p = loadMetaSchemaOf(schema).then(function () {
|
| 31 |
+
var schemaObj = self._addSchema(schema, undefined, meta);
|
| 32 |
+
return schemaObj.validate || _compileAsync(schemaObj);
|
| 33 |
+
});
|
| 34 |
+
|
| 35 |
+
if (callback) {
|
| 36 |
+
p.then(
|
| 37 |
+
function(v) { callback(null, v); },
|
| 38 |
+
callback
|
| 39 |
+
);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
return p;
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
function loadMetaSchemaOf(sch) {
|
| 46 |
+
var $schema = sch.$schema;
|
| 47 |
+
return $schema && !self.getSchema($schema)
|
| 48 |
+
? compileAsync.call(self, { $ref: $schema }, true)
|
| 49 |
+
: Promise.resolve();
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
function _compileAsync(schemaObj) {
|
| 54 |
+
try { return self._compile(schemaObj); }
|
| 55 |
+
catch(e) {
|
| 56 |
+
if (e instanceof MissingRefError) return loadMissingSchema(e);
|
| 57 |
+
throw e;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
function loadMissingSchema(e) {
|
| 62 |
+
var ref = e.missingSchema;
|
| 63 |
+
if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved');
|
| 64 |
+
|
| 65 |
+
var schemaPromise = self._loadingSchemas[ref];
|
| 66 |
+
if (!schemaPromise) {
|
| 67 |
+
schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
|
| 68 |
+
schemaPromise.then(removePromise, removePromise);
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
return schemaPromise.then(function (sch) {
|
| 72 |
+
if (!added(ref)) {
|
| 73 |
+
return loadMetaSchemaOf(sch).then(function () {
|
| 74 |
+
if (!added(ref)) self.addSchema(sch, ref, undefined, meta);
|
| 75 |
+
});
|
| 76 |
+
}
|
| 77 |
+
}).then(function() {
|
| 78 |
+
return _compileAsync(schemaObj);
|
| 79 |
+
});
|
| 80 |
+
|
| 81 |
+
function removePromise() {
|
| 82 |
+
delete self._loadingSchemas[ref];
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
function added(ref) {
|
| 86 |
+
return self._refs[ref] || self._schemas[ref];
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/equal.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
// do NOT remove this file - it would break pre-compiled schemas
|
| 4 |
+
// https://github.com/ajv-validator/ajv/issues/889
|
| 5 |
+
module.exports = require('fast-deep-equal');
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/error_classes.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var resolve = require('./resolve');
|
| 4 |
+
|
| 5 |
+
module.exports = {
|
| 6 |
+
Validation: errorSubclass(ValidationError),
|
| 7 |
+
MissingRef: errorSubclass(MissingRefError)
|
| 8 |
+
};
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
function ValidationError(errors) {
|
| 12 |
+
this.message = 'validation failed';
|
| 13 |
+
this.errors = errors;
|
| 14 |
+
this.ajv = this.validation = true;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
MissingRefError.message = function (baseId, ref) {
|
| 19 |
+
return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
function MissingRefError(baseId, ref, message) {
|
| 24 |
+
this.message = message || MissingRefError.message(baseId, ref);
|
| 25 |
+
this.missingRef = resolve.url(baseId, ref);
|
| 26 |
+
this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
function errorSubclass(Subclass) {
|
| 31 |
+
Subclass.prototype = Object.create(Error.prototype);
|
| 32 |
+
Subclass.prototype.constructor = Subclass;
|
| 33 |
+
return Subclass;
|
| 34 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/formats.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
| 11 |
+
// uri-template: https://tools.ietf.org/html/rfc6570
|
| 12 |
+
var URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
|
| 13 |
+
// For the source: https://gist.github.com/dperini/729294
|
| 14 |
+
// For test cases: https://mathiasbynens.be/demo/url-regex
|
| 15 |
+
// @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983.
|
| 16 |
+
// var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
|
| 17 |
+
var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i;
|
| 18 |
+
var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
| 19 |
+
var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
|
| 20 |
+
var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
|
| 21 |
+
var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
module.exports = formats;
|
| 25 |
+
|
| 26 |
+
function formats(mode) {
|
| 27 |
+
mode = mode == 'full' ? 'full' : 'fast';
|
| 28 |
+
return util.copy(formats[mode]);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
formats.fast = {
|
| 33 |
+
// date: http://tools.ietf.org/html/rfc3339#section-5.6
|
| 34 |
+
date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
|
| 35 |
+
// date-time: http://tools.ietf.org/html/rfc3339#section-5.6
|
| 36 |
+
time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,
|
| 37 |
+
'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,
|
| 38 |
+
// uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js
|
| 39 |
+
uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,
|
| 40 |
+
'uri-reference': /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
|
| 41 |
+
'uri-template': URITEMPLATE,
|
| 42 |
+
url: URL,
|
| 43 |
+
// email (sources from jsen validator):
|
| 44 |
+
// http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363
|
| 45 |
+
// http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation')
|
| 46 |
+
email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,
|
| 47 |
+
hostname: HOSTNAME,
|
| 48 |
+
// optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
|
| 49 |
+
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
|
| 50 |
+
// optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
|
| 51 |
+
ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){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2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
|
| 52 |
+
regex: regex,
|
| 53 |
+
// uuid: http://tools.ietf.org/html/rfc4122
|
| 54 |
+
uuid: UUID,
|
| 55 |
+
// JSON-pointer: https://tools.ietf.org/html/rfc6901
|
| 56 |
+
// uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A
|
| 57 |
+
'json-pointer': JSON_POINTER,
|
| 58 |
+
'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
|
| 59 |
+
// relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00
|
| 60 |
+
'relative-json-pointer': RELATIVE_JSON_POINTER
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
formats.full = {
|
| 65 |
+
date: date,
|
| 66 |
+
time: time,
|
| 67 |
+
'date-time': date_time,
|
| 68 |
+
uri: uri,
|
| 69 |
+
'uri-reference': URIREF,
|
| 70 |
+
'uri-template': URITEMPLATE,
|
| 71 |
+
url: URL,
|
| 72 |
+
email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
|
| 73 |
+
hostname: HOSTNAME,
|
| 74 |
+
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
|
| 75 |
+
ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
|
| 76 |
+
regex: regex,
|
| 77 |
+
uuid: UUID,
|
| 78 |
+
'json-pointer': JSON_POINTER,
|
| 79 |
+
'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT,
|
| 80 |
+
'relative-json-pointer': RELATIVE_JSON_POINTER
|
| 81 |
+
};
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
function isLeapYear(year) {
|
| 85 |
+
// https://tools.ietf.org/html/rfc3339#appendix-C
|
| 86 |
+
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
function date(str) {
|
| 91 |
+
// full-date from http://tools.ietf.org/html/rfc3339#section-5.6
|
| 92 |
+
var matches = str.match(DATE);
|
| 93 |
+
if (!matches) return false;
|
| 94 |
+
|
| 95 |
+
var year = +matches[1];
|
| 96 |
+
var month = +matches[2];
|
| 97 |
+
var day = +matches[3];
|
| 98 |
+
|
| 99 |
+
return month >= 1 && month <= 12 && day >= 1 &&
|
| 100 |
+
day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
function time(str, full) {
|
| 105 |
+
var matches = str.match(TIME);
|
| 106 |
+
if (!matches) return false;
|
| 107 |
+
|
| 108 |
+
var hour = matches[1];
|
| 109 |
+
var minute = matches[2];
|
| 110 |
+
var second = matches[3];
|
| 111 |
+
var timeZone = matches[5];
|
| 112 |
+
return ((hour <= 23 && minute <= 59 && second <= 59) ||
|
| 113 |
+
(hour == 23 && minute == 59 && second == 60)) &&
|
| 114 |
+
(!full || timeZone);
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
var DATE_TIME_SEPARATOR = /t|\s/i;
|
| 119 |
+
function date_time(str) {
|
| 120 |
+
// http://tools.ietf.org/html/rfc3339#section-5.6
|
| 121 |
+
var dateTime = str.split(DATE_TIME_SEPARATOR);
|
| 122 |
+
return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true);
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
var NOT_URI_FRAGMENT = /\/|:/;
|
| 127 |
+
function uri(str) {
|
| 128 |
+
// http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
|
| 129 |
+
return NOT_URI_FRAGMENT.test(str) && URI.test(str);
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
var Z_ANCHOR = /[^\\]\\Z/;
|
| 134 |
+
function regex(str) {
|
| 135 |
+
if (Z_ANCHOR.test(str)) return false;
|
| 136 |
+
try {
|
| 137 |
+
new RegExp(str);
|
| 138 |
+
return true;
|
| 139 |
+
} catch(e) {
|
| 140 |
+
return false;
|
| 141 |
+
}
|
| 142 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/index.js
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var resolve = require('./resolve')
|
| 4 |
+
, util = require('./util')
|
| 5 |
+
, errorClasses = require('./error_classes')
|
| 6 |
+
, stableStringify = require('fast-json-stable-stringify');
|
| 7 |
+
|
| 8 |
+
var validateGenerator = require('../dotjs/validate');
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Functions below are used inside compiled validations function
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
var ucs2length = util.ucs2length;
|
| 15 |
+
var equal = require('fast-deep-equal');
|
| 16 |
+
|
| 17 |
+
// this error is thrown by async schemas to return validation errors via exception
|
| 18 |
+
var ValidationError = errorClasses.Validation;
|
| 19 |
+
|
| 20 |
+
module.exports = compile;
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Compiles schema to validation function
|
| 25 |
+
* @this Ajv
|
| 26 |
+
* @param {Object} schema schema object
|
| 27 |
+
* @param {Object} root object with information about the root schema for this schema
|
| 28 |
+
* @param {Object} localRefs the hash of local references inside the schema (created by resolve.id), used for inline resolution
|
| 29 |
+
* @param {String} baseId base ID for IDs in the schema
|
| 30 |
+
* @return {Function} validation function
|
| 31 |
+
*/
|
| 32 |
+
function compile(schema, root, localRefs, baseId) {
|
| 33 |
+
/* jshint validthis: true, evil: true */
|
| 34 |
+
/* eslint no-shadow: 0 */
|
| 35 |
+
var self = this
|
| 36 |
+
, opts = this._opts
|
| 37 |
+
, refVal = [ undefined ]
|
| 38 |
+
, refs = {}
|
| 39 |
+
, patterns = []
|
| 40 |
+
, patternsHash = {}
|
| 41 |
+
, defaults = []
|
| 42 |
+
, defaultsHash = {}
|
| 43 |
+
, customRules = [];
|
| 44 |
+
|
| 45 |
+
root = root || { schema: schema, refVal: refVal, refs: refs };
|
| 46 |
+
|
| 47 |
+
var c = checkCompiling.call(this, schema, root, baseId);
|
| 48 |
+
var compilation = this._compilations[c.index];
|
| 49 |
+
if (c.compiling) return (compilation.callValidate = callValidate);
|
| 50 |
+
|
| 51 |
+
var formats = this._formats;
|
| 52 |
+
var RULES = this.RULES;
|
| 53 |
+
|
| 54 |
+
try {
|
| 55 |
+
var v = localCompile(schema, root, localRefs, baseId);
|
| 56 |
+
compilation.validate = v;
|
| 57 |
+
var cv = compilation.callValidate;
|
| 58 |
+
if (cv) {
|
| 59 |
+
cv.schema = v.schema;
|
| 60 |
+
cv.errors = null;
|
| 61 |
+
cv.refs = v.refs;
|
| 62 |
+
cv.refVal = v.refVal;
|
| 63 |
+
cv.root = v.root;
|
| 64 |
+
cv.$async = v.$async;
|
| 65 |
+
if (opts.sourceCode) cv.source = v.source;
|
| 66 |
+
}
|
| 67 |
+
return v;
|
| 68 |
+
} finally {
|
| 69 |
+
endCompiling.call(this, schema, root, baseId);
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
/* @this {*} - custom context, see passContext option */
|
| 73 |
+
function callValidate() {
|
| 74 |
+
/* jshint validthis: true */
|
| 75 |
+
var validate = compilation.validate;
|
| 76 |
+
var result = validate.apply(this, arguments);
|
| 77 |
+
callValidate.errors = validate.errors;
|
| 78 |
+
return result;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
function localCompile(_schema, _root, localRefs, baseId) {
|
| 82 |
+
var isRoot = !_root || (_root && _root.schema == _schema);
|
| 83 |
+
if (_root.schema != root.schema)
|
| 84 |
+
return compile.call(self, _schema, _root, localRefs, baseId);
|
| 85 |
+
|
| 86 |
+
var $async = _schema.$async === true;
|
| 87 |
+
|
| 88 |
+
var sourceCode = validateGenerator({
|
| 89 |
+
isTop: true,
|
| 90 |
+
schema: _schema,
|
| 91 |
+
isRoot: isRoot,
|
| 92 |
+
baseId: baseId,
|
| 93 |
+
root: _root,
|
| 94 |
+
schemaPath: '',
|
| 95 |
+
errSchemaPath: '#',
|
| 96 |
+
errorPath: '""',
|
| 97 |
+
MissingRefError: errorClasses.MissingRef,
|
| 98 |
+
RULES: RULES,
|
| 99 |
+
validate: validateGenerator,
|
| 100 |
+
util: util,
|
| 101 |
+
resolve: resolve,
|
| 102 |
+
resolveRef: resolveRef,
|
| 103 |
+
usePattern: usePattern,
|
| 104 |
+
useDefault: useDefault,
|
| 105 |
+
useCustomRule: useCustomRule,
|
| 106 |
+
opts: opts,
|
| 107 |
+
formats: formats,
|
| 108 |
+
logger: self.logger,
|
| 109 |
+
self: self
|
| 110 |
+
});
|
| 111 |
+
|
| 112 |
+
sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode)
|
| 113 |
+
+ vars(defaults, defaultCode) + vars(customRules, customRuleCode)
|
| 114 |
+
+ sourceCode;
|
| 115 |
+
|
| 116 |
+
if (opts.processCode) sourceCode = opts.processCode(sourceCode, _schema);
|
| 117 |
+
// console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
|
| 118 |
+
var validate;
|
| 119 |
+
try {
|
| 120 |
+
var makeValidate = new Function(
|
| 121 |
+
'self',
|
| 122 |
+
'RULES',
|
| 123 |
+
'formats',
|
| 124 |
+
'root',
|
| 125 |
+
'refVal',
|
| 126 |
+
'defaults',
|
| 127 |
+
'customRules',
|
| 128 |
+
'equal',
|
| 129 |
+
'ucs2length',
|
| 130 |
+
'ValidationError',
|
| 131 |
+
sourceCode
|
| 132 |
+
);
|
| 133 |
+
|
| 134 |
+
validate = makeValidate(
|
| 135 |
+
self,
|
| 136 |
+
RULES,
|
| 137 |
+
formats,
|
| 138 |
+
root,
|
| 139 |
+
refVal,
|
| 140 |
+
defaults,
|
| 141 |
+
customRules,
|
| 142 |
+
equal,
|
| 143 |
+
ucs2length,
|
| 144 |
+
ValidationError
|
| 145 |
+
);
|
| 146 |
+
|
| 147 |
+
refVal[0] = validate;
|
| 148 |
+
} catch(e) {
|
| 149 |
+
self.logger.error('Error compiling schema, function code:', sourceCode);
|
| 150 |
+
throw e;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
validate.schema = _schema;
|
| 154 |
+
validate.errors = null;
|
| 155 |
+
validate.refs = refs;
|
| 156 |
+
validate.refVal = refVal;
|
| 157 |
+
validate.root = isRoot ? validate : _root;
|
| 158 |
+
if ($async) validate.$async = true;
|
| 159 |
+
if (opts.sourceCode === true) {
|
| 160 |
+
validate.source = {
|
| 161 |
+
code: sourceCode,
|
| 162 |
+
patterns: patterns,
|
| 163 |
+
defaults: defaults
|
| 164 |
+
};
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
return validate;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
function resolveRef(baseId, ref, isRoot) {
|
| 171 |
+
ref = resolve.url(baseId, ref);
|
| 172 |
+
var refIndex = refs[ref];
|
| 173 |
+
var _refVal, refCode;
|
| 174 |
+
if (refIndex !== undefined) {
|
| 175 |
+
_refVal = refVal[refIndex];
|
| 176 |
+
refCode = 'refVal[' + refIndex + ']';
|
| 177 |
+
return resolvedRef(_refVal, refCode);
|
| 178 |
+
}
|
| 179 |
+
if (!isRoot && root.refs) {
|
| 180 |
+
var rootRefId = root.refs[ref];
|
| 181 |
+
if (rootRefId !== undefined) {
|
| 182 |
+
_refVal = root.refVal[rootRefId];
|
| 183 |
+
refCode = addLocalRef(ref, _refVal);
|
| 184 |
+
return resolvedRef(_refVal, refCode);
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
refCode = addLocalRef(ref);
|
| 189 |
+
var v = resolve.call(self, localCompile, root, ref);
|
| 190 |
+
if (v === undefined) {
|
| 191 |
+
var localSchema = localRefs && localRefs[ref];
|
| 192 |
+
if (localSchema) {
|
| 193 |
+
v = resolve.inlineRef(localSchema, opts.inlineRefs)
|
| 194 |
+
? localSchema
|
| 195 |
+
: compile.call(self, localSchema, root, localRefs, baseId);
|
| 196 |
+
}
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
if (v === undefined) {
|
| 200 |
+
removeLocalRef(ref);
|
| 201 |
+
} else {
|
| 202 |
+
replaceLocalRef(ref, v);
|
| 203 |
+
return resolvedRef(v, refCode);
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
function addLocalRef(ref, v) {
|
| 208 |
+
var refId = refVal.length;
|
| 209 |
+
refVal[refId] = v;
|
| 210 |
+
refs[ref] = refId;
|
| 211 |
+
return 'refVal' + refId;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
function removeLocalRef(ref) {
|
| 215 |
+
delete refs[ref];
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
function replaceLocalRef(ref, v) {
|
| 219 |
+
var refId = refs[ref];
|
| 220 |
+
refVal[refId] = v;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
function resolvedRef(refVal, code) {
|
| 224 |
+
return typeof refVal == 'object' || typeof refVal == 'boolean'
|
| 225 |
+
? { code: code, schema: refVal, inline: true }
|
| 226 |
+
: { code: code, $async: refVal && !!refVal.$async };
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
function usePattern(regexStr) {
|
| 230 |
+
var index = patternsHash[regexStr];
|
| 231 |
+
if (index === undefined) {
|
| 232 |
+
index = patternsHash[regexStr] = patterns.length;
|
| 233 |
+
patterns[index] = regexStr;
|
| 234 |
+
}
|
| 235 |
+
return 'pattern' + index;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
function useDefault(value) {
|
| 239 |
+
switch (typeof value) {
|
| 240 |
+
case 'boolean':
|
| 241 |
+
case 'number':
|
| 242 |
+
return '' + value;
|
| 243 |
+
case 'string':
|
| 244 |
+
return util.toQuotedString(value);
|
| 245 |
+
case 'object':
|
| 246 |
+
if (value === null) return 'null';
|
| 247 |
+
var valueStr = stableStringify(value);
|
| 248 |
+
var index = defaultsHash[valueStr];
|
| 249 |
+
if (index === undefined) {
|
| 250 |
+
index = defaultsHash[valueStr] = defaults.length;
|
| 251 |
+
defaults[index] = value;
|
| 252 |
+
}
|
| 253 |
+
return 'default' + index;
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
function useCustomRule(rule, schema, parentSchema, it) {
|
| 258 |
+
if (self._opts.validateSchema !== false) {
|
| 259 |
+
var deps = rule.definition.dependencies;
|
| 260 |
+
if (deps && !deps.every(function(keyword) {
|
| 261 |
+
return Object.prototype.hasOwnProperty.call(parentSchema, keyword);
|
| 262 |
+
}))
|
| 263 |
+
throw new Error('parent schema must have all required keywords: ' + deps.join(','));
|
| 264 |
+
|
| 265 |
+
var validateSchema = rule.definition.validateSchema;
|
| 266 |
+
if (validateSchema) {
|
| 267 |
+
var valid = validateSchema(schema);
|
| 268 |
+
if (!valid) {
|
| 269 |
+
var message = 'keyword schema is invalid: ' + self.errorsText(validateSchema.errors);
|
| 270 |
+
if (self._opts.validateSchema == 'log') self.logger.error(message);
|
| 271 |
+
else throw new Error(message);
|
| 272 |
+
}
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
var compile = rule.definition.compile
|
| 277 |
+
, inline = rule.definition.inline
|
| 278 |
+
, macro = rule.definition.macro;
|
| 279 |
+
|
| 280 |
+
var validate;
|
| 281 |
+
if (compile) {
|
| 282 |
+
validate = compile.call(self, schema, parentSchema, it);
|
| 283 |
+
} else if (macro) {
|
| 284 |
+
validate = macro.call(self, schema, parentSchema, it);
|
| 285 |
+
if (opts.validateSchema !== false) self.validateSchema(validate, true);
|
| 286 |
+
} else if (inline) {
|
| 287 |
+
validate = inline.call(self, it, rule.keyword, schema, parentSchema);
|
| 288 |
+
} else {
|
| 289 |
+
validate = rule.definition.validate;
|
| 290 |
+
if (!validate) return;
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
if (validate === undefined)
|
| 294 |
+
throw new Error('custom keyword "' + rule.keyword + '"failed to compile');
|
| 295 |
+
|
| 296 |
+
var index = customRules.length;
|
| 297 |
+
customRules[index] = validate;
|
| 298 |
+
|
| 299 |
+
return {
|
| 300 |
+
code: 'customRule' + index,
|
| 301 |
+
validate: validate
|
| 302 |
+
};
|
| 303 |
+
}
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
/**
|
| 308 |
+
* Checks if the schema is currently compiled
|
| 309 |
+
* @this Ajv
|
| 310 |
+
* @param {Object} schema schema to compile
|
| 311 |
+
* @param {Object} root root object
|
| 312 |
+
* @param {String} baseId base schema ID
|
| 313 |
+
* @return {Object} object with properties "index" (compilation index) and "compiling" (boolean)
|
| 314 |
+
*/
|
| 315 |
+
function checkCompiling(schema, root, baseId) {
|
| 316 |
+
/* jshint validthis: true */
|
| 317 |
+
var index = compIndex.call(this, schema, root, baseId);
|
| 318 |
+
if (index >= 0) return { index: index, compiling: true };
|
| 319 |
+
index = this._compilations.length;
|
| 320 |
+
this._compilations[index] = {
|
| 321 |
+
schema: schema,
|
| 322 |
+
root: root,
|
| 323 |
+
baseId: baseId
|
| 324 |
+
};
|
| 325 |
+
return { index: index, compiling: false };
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
|
| 329 |
+
/**
|
| 330 |
+
* Removes the schema from the currently compiled list
|
| 331 |
+
* @this Ajv
|
| 332 |
+
* @param {Object} schema schema to compile
|
| 333 |
+
* @param {Object} root root object
|
| 334 |
+
* @param {String} baseId base schema ID
|
| 335 |
+
*/
|
| 336 |
+
function endCompiling(schema, root, baseId) {
|
| 337 |
+
/* jshint validthis: true */
|
| 338 |
+
var i = compIndex.call(this, schema, root, baseId);
|
| 339 |
+
if (i >= 0) this._compilations.splice(i, 1);
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
/**
|
| 344 |
+
* Index of schema compilation in the currently compiled list
|
| 345 |
+
* @this Ajv
|
| 346 |
+
* @param {Object} schema schema to compile
|
| 347 |
+
* @param {Object} root root object
|
| 348 |
+
* @param {String} baseId base schema ID
|
| 349 |
+
* @return {Integer} compilation index
|
| 350 |
+
*/
|
| 351 |
+
function compIndex(schema, root, baseId) {
|
| 352 |
+
/* jshint validthis: true */
|
| 353 |
+
for (var i=0; i<this._compilations.length; i++) {
|
| 354 |
+
var c = this._compilations[i];
|
| 355 |
+
if (c.schema == schema && c.root == root && c.baseId == baseId) return i;
|
| 356 |
+
}
|
| 357 |
+
return -1;
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
|
| 361 |
+
function patternCode(i, patterns) {
|
| 362 |
+
return 'var pattern' + i + ' = new RegExp(' + util.toQuotedString(patterns[i]) + ');';
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
|
| 366 |
+
function defaultCode(i) {
|
| 367 |
+
return 'var default' + i + ' = defaults[' + i + '];';
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
|
| 371 |
+
function refValCode(i, refVal) {
|
| 372 |
+
return refVal[i] === undefined ? '' : 'var refVal' + i + ' = refVal[' + i + '];';
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
|
| 376 |
+
function customRuleCode(i) {
|
| 377 |
+
return 'var customRule' + i + ' = customRules[' + i + '];';
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
|
| 381 |
+
function vars(arr, statement) {
|
| 382 |
+
if (!arr.length) return '';
|
| 383 |
+
var code = '';
|
| 384 |
+
for (var i=0; i<arr.length; i++)
|
| 385 |
+
code += statement(i, arr);
|
| 386 |
+
return code;
|
| 387 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/resolve.js
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var URI = require('uri-js')
|
| 4 |
+
, equal = require('fast-deep-equal')
|
| 5 |
+
, util = require('./util')
|
| 6 |
+
, SchemaObject = require('./schema_obj')
|
| 7 |
+
, traverse = require('json-schema-traverse');
|
| 8 |
+
|
| 9 |
+
module.exports = resolve;
|
| 10 |
+
|
| 11 |
+
resolve.normalizeId = normalizeId;
|
| 12 |
+
resolve.fullPath = getFullPath;
|
| 13 |
+
resolve.url = resolveUrl;
|
| 14 |
+
resolve.ids = resolveIds;
|
| 15 |
+
resolve.inlineRef = inlineRef;
|
| 16 |
+
resolve.schema = resolveSchema;
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* [resolve and compile the references ($ref)]
|
| 20 |
+
* @this Ajv
|
| 21 |
+
* @param {Function} compile reference to schema compilation funciton (localCompile)
|
| 22 |
+
* @param {Object} root object with information about the root schema for the current schema
|
| 23 |
+
* @param {String} ref reference to resolve
|
| 24 |
+
* @return {Object|Function} schema object (if the schema can be inlined) or validation function
|
| 25 |
+
*/
|
| 26 |
+
function resolve(compile, root, ref) {
|
| 27 |
+
/* jshint validthis: true */
|
| 28 |
+
var refVal = this._refs[ref];
|
| 29 |
+
if (typeof refVal == 'string') {
|
| 30 |
+
if (this._refs[refVal]) refVal = this._refs[refVal];
|
| 31 |
+
else return resolve.call(this, compile, root, refVal);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
refVal = refVal || this._schemas[ref];
|
| 35 |
+
if (refVal instanceof SchemaObject) {
|
| 36 |
+
return inlineRef(refVal.schema, this._opts.inlineRefs)
|
| 37 |
+
? refVal.schema
|
| 38 |
+
: refVal.validate || this._compile(refVal);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
var res = resolveSchema.call(this, root, ref);
|
| 42 |
+
var schema, v, baseId;
|
| 43 |
+
if (res) {
|
| 44 |
+
schema = res.schema;
|
| 45 |
+
root = res.root;
|
| 46 |
+
baseId = res.baseId;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
if (schema instanceof SchemaObject) {
|
| 50 |
+
v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
|
| 51 |
+
} else if (schema !== undefined) {
|
| 52 |
+
v = inlineRef(schema, this._opts.inlineRefs)
|
| 53 |
+
? schema
|
| 54 |
+
: compile.call(this, schema, root, undefined, baseId);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
return v;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* Resolve schema, its root and baseId
|
| 63 |
+
* @this Ajv
|
| 64 |
+
* @param {Object} root root object with properties schema, refVal, refs
|
| 65 |
+
* @param {String} ref reference to resolve
|
| 66 |
+
* @return {Object} object with properties schema, root, baseId
|
| 67 |
+
*/
|
| 68 |
+
function resolveSchema(root, ref) {
|
| 69 |
+
/* jshint validthis: true */
|
| 70 |
+
var p = URI.parse(ref)
|
| 71 |
+
, refPath = _getFullPath(p)
|
| 72 |
+
, baseId = getFullPath(this._getId(root.schema));
|
| 73 |
+
if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
|
| 74 |
+
var id = normalizeId(refPath);
|
| 75 |
+
var refVal = this._refs[id];
|
| 76 |
+
if (typeof refVal == 'string') {
|
| 77 |
+
return resolveRecursive.call(this, root, refVal, p);
|
| 78 |
+
} else if (refVal instanceof SchemaObject) {
|
| 79 |
+
if (!refVal.validate) this._compile(refVal);
|
| 80 |
+
root = refVal;
|
| 81 |
+
} else {
|
| 82 |
+
refVal = this._schemas[id];
|
| 83 |
+
if (refVal instanceof SchemaObject) {
|
| 84 |
+
if (!refVal.validate) this._compile(refVal);
|
| 85 |
+
if (id == normalizeId(ref))
|
| 86 |
+
return { schema: refVal, root: root, baseId: baseId };
|
| 87 |
+
root = refVal;
|
| 88 |
+
} else {
|
| 89 |
+
return;
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
if (!root.schema) return;
|
| 93 |
+
baseId = getFullPath(this._getId(root.schema));
|
| 94 |
+
}
|
| 95 |
+
return getJsonPointer.call(this, p, baseId, root.schema, root);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
/* @this Ajv */
|
| 100 |
+
function resolveRecursive(root, ref, parsedRef) {
|
| 101 |
+
/* jshint validthis: true */
|
| 102 |
+
var res = resolveSchema.call(this, root, ref);
|
| 103 |
+
if (res) {
|
| 104 |
+
var schema = res.schema;
|
| 105 |
+
var baseId = res.baseId;
|
| 106 |
+
root = res.root;
|
| 107 |
+
var id = this._getId(schema);
|
| 108 |
+
if (id) baseId = resolveUrl(baseId, id);
|
| 109 |
+
return getJsonPointer.call(this, parsedRef, baseId, schema, root);
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']);
|
| 115 |
+
/* @this Ajv */
|
| 116 |
+
function getJsonPointer(parsedRef, baseId, schema, root) {
|
| 117 |
+
/* jshint validthis: true */
|
| 118 |
+
parsedRef.fragment = parsedRef.fragment || '';
|
| 119 |
+
if (parsedRef.fragment.slice(0,1) != '/') return;
|
| 120 |
+
var parts = parsedRef.fragment.split('/');
|
| 121 |
+
|
| 122 |
+
for (var i = 1; i < parts.length; i++) {
|
| 123 |
+
var part = parts[i];
|
| 124 |
+
if (part) {
|
| 125 |
+
part = util.unescapeFragment(part);
|
| 126 |
+
schema = schema[part];
|
| 127 |
+
if (schema === undefined) break;
|
| 128 |
+
var id;
|
| 129 |
+
if (!PREVENT_SCOPE_CHANGE[part]) {
|
| 130 |
+
id = this._getId(schema);
|
| 131 |
+
if (id) baseId = resolveUrl(baseId, id);
|
| 132 |
+
if (schema.$ref) {
|
| 133 |
+
var $ref = resolveUrl(baseId, schema.$ref);
|
| 134 |
+
var res = resolveSchema.call(this, root, $ref);
|
| 135 |
+
if (res) {
|
| 136 |
+
schema = res.schema;
|
| 137 |
+
root = res.root;
|
| 138 |
+
baseId = res.baseId;
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
if (schema !== undefined && schema !== root.schema)
|
| 145 |
+
return { schema: schema, root: root, baseId: baseId };
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
var SIMPLE_INLINED = util.toHash([
|
| 150 |
+
'type', 'format', 'pattern',
|
| 151 |
+
'maxLength', 'minLength',
|
| 152 |
+
'maxProperties', 'minProperties',
|
| 153 |
+
'maxItems', 'minItems',
|
| 154 |
+
'maximum', 'minimum',
|
| 155 |
+
'uniqueItems', 'multipleOf',
|
| 156 |
+
'required', 'enum'
|
| 157 |
+
]);
|
| 158 |
+
function inlineRef(schema, limit) {
|
| 159 |
+
if (limit === false) return false;
|
| 160 |
+
if (limit === undefined || limit === true) return checkNoRef(schema);
|
| 161 |
+
else if (limit) return countKeys(schema) <= limit;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
function checkNoRef(schema) {
|
| 166 |
+
var item;
|
| 167 |
+
if (Array.isArray(schema)) {
|
| 168 |
+
for (var i=0; i<schema.length; i++) {
|
| 169 |
+
item = schema[i];
|
| 170 |
+
if (typeof item == 'object' && !checkNoRef(item)) return false;
|
| 171 |
+
}
|
| 172 |
+
} else {
|
| 173 |
+
for (var key in schema) {
|
| 174 |
+
if (key == '$ref') return false;
|
| 175 |
+
item = schema[key];
|
| 176 |
+
if (typeof item == 'object' && !checkNoRef(item)) return false;
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
return true;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
function countKeys(schema) {
|
| 184 |
+
var count = 0, item;
|
| 185 |
+
if (Array.isArray(schema)) {
|
| 186 |
+
for (var i=0; i<schema.length; i++) {
|
| 187 |
+
item = schema[i];
|
| 188 |
+
if (typeof item == 'object') count += countKeys(item);
|
| 189 |
+
if (count == Infinity) return Infinity;
|
| 190 |
+
}
|
| 191 |
+
} else {
|
| 192 |
+
for (var key in schema) {
|
| 193 |
+
if (key == '$ref') return Infinity;
|
| 194 |
+
if (SIMPLE_INLINED[key]) {
|
| 195 |
+
count++;
|
| 196 |
+
} else {
|
| 197 |
+
item = schema[key];
|
| 198 |
+
if (typeof item == 'object') count += countKeys(item) + 1;
|
| 199 |
+
if (count == Infinity) return Infinity;
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
return count;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
function getFullPath(id, normalize) {
|
| 208 |
+
if (normalize !== false) id = normalizeId(id);
|
| 209 |
+
var p = URI.parse(id);
|
| 210 |
+
return _getFullPath(p);
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
function _getFullPath(p) {
|
| 215 |
+
return URI.serialize(p).split('#')[0] + '#';
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
var TRAILING_SLASH_HASH = /#\/?$/;
|
| 220 |
+
function normalizeId(id) {
|
| 221 |
+
return id ? id.replace(TRAILING_SLASH_HASH, '') : '';
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
function resolveUrl(baseId, id) {
|
| 226 |
+
id = normalizeId(id);
|
| 227 |
+
return URI.resolve(baseId, id);
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
/* @this Ajv */
|
| 232 |
+
function resolveIds(schema) {
|
| 233 |
+
var schemaId = normalizeId(this._getId(schema));
|
| 234 |
+
var baseIds = {'': schemaId};
|
| 235 |
+
var fullPaths = {'': getFullPath(schemaId, false)};
|
| 236 |
+
var localRefs = {};
|
| 237 |
+
var self = this;
|
| 238 |
+
|
| 239 |
+
traverse(schema, {allKeys: true}, function(sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
|
| 240 |
+
if (jsonPtr === '') return;
|
| 241 |
+
var id = self._getId(sch);
|
| 242 |
+
var baseId = baseIds[parentJsonPtr];
|
| 243 |
+
var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword;
|
| 244 |
+
if (keyIndex !== undefined)
|
| 245 |
+
fullPath += '/' + (typeof keyIndex == 'number' ? keyIndex : util.escapeFragment(keyIndex));
|
| 246 |
+
|
| 247 |
+
if (typeof id == 'string') {
|
| 248 |
+
id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id);
|
| 249 |
+
|
| 250 |
+
var refVal = self._refs[id];
|
| 251 |
+
if (typeof refVal == 'string') refVal = self._refs[refVal];
|
| 252 |
+
if (refVal && refVal.schema) {
|
| 253 |
+
if (!equal(sch, refVal.schema))
|
| 254 |
+
throw new Error('id "' + id + '" resolves to more than one schema');
|
| 255 |
+
} else if (id != normalizeId(fullPath)) {
|
| 256 |
+
if (id[0] == '#') {
|
| 257 |
+
if (localRefs[id] && !equal(sch, localRefs[id]))
|
| 258 |
+
throw new Error('id "' + id + '" resolves to more than one schema');
|
| 259 |
+
localRefs[id] = sch;
|
| 260 |
+
} else {
|
| 261 |
+
self._refs[id] = fullPath;
|
| 262 |
+
}
|
| 263 |
+
}
|
| 264 |
+
}
|
| 265 |
+
baseIds[jsonPtr] = baseId;
|
| 266 |
+
fullPaths[jsonPtr] = fullPath;
|
| 267 |
+
});
|
| 268 |
+
|
| 269 |
+
return localRefs;
|
| 270 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/rules.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var ruleModules = require('../dotjs')
|
| 4 |
+
, toHash = require('./util').toHash;
|
| 5 |
+
|
| 6 |
+
module.exports = function rules() {
|
| 7 |
+
var RULES = [
|
| 8 |
+
{ type: 'number',
|
| 9 |
+
rules: [ { 'maximum': ['exclusiveMaximum'] },
|
| 10 |
+
{ 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] },
|
| 11 |
+
{ type: 'string',
|
| 12 |
+
rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
|
| 13 |
+
{ type: 'array',
|
| 14 |
+
rules: [ 'maxItems', 'minItems', 'items', 'contains', 'uniqueItems' ] },
|
| 15 |
+
{ type: 'object',
|
| 16 |
+
rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames',
|
| 17 |
+
{ 'properties': ['additionalProperties', 'patternProperties'] } ] },
|
| 18 |
+
{ rules: [ '$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf', 'if' ] }
|
| 19 |
+
];
|
| 20 |
+
|
| 21 |
+
var ALL = [ 'type', '$comment' ];
|
| 22 |
+
var KEYWORDS = [
|
| 23 |
+
'$schema', '$id', 'id', '$data', '$async', 'title',
|
| 24 |
+
'description', 'default', 'definitions',
|
| 25 |
+
'examples', 'readOnly', 'writeOnly',
|
| 26 |
+
'contentMediaType', 'contentEncoding',
|
| 27 |
+
'additionalItems', 'then', 'else'
|
| 28 |
+
];
|
| 29 |
+
var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
|
| 30 |
+
RULES.all = toHash(ALL);
|
| 31 |
+
RULES.types = toHash(TYPES);
|
| 32 |
+
|
| 33 |
+
RULES.forEach(function (group) {
|
| 34 |
+
group.rules = group.rules.map(function (keyword) {
|
| 35 |
+
var implKeywords;
|
| 36 |
+
if (typeof keyword == 'object') {
|
| 37 |
+
var key = Object.keys(keyword)[0];
|
| 38 |
+
implKeywords = keyword[key];
|
| 39 |
+
keyword = key;
|
| 40 |
+
implKeywords.forEach(function (k) {
|
| 41 |
+
ALL.push(k);
|
| 42 |
+
RULES.all[k] = true;
|
| 43 |
+
});
|
| 44 |
+
}
|
| 45 |
+
ALL.push(keyword);
|
| 46 |
+
var rule = RULES.all[keyword] = {
|
| 47 |
+
keyword: keyword,
|
| 48 |
+
code: ruleModules[keyword],
|
| 49 |
+
implements: implKeywords
|
| 50 |
+
};
|
| 51 |
+
return rule;
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
RULES.all.$comment = {
|
| 55 |
+
keyword: '$comment',
|
| 56 |
+
code: ruleModules.$comment
|
| 57 |
+
};
|
| 58 |
+
|
| 59 |
+
if (group.type) RULES.types[group.type] = group;
|
| 60 |
+
});
|
| 61 |
+
|
| 62 |
+
RULES.keywords = toHash(ALL.concat(KEYWORDS));
|
| 63 |
+
RULES.custom = {};
|
| 64 |
+
|
| 65 |
+
return RULES;
|
| 66 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/schema_obj.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var util = require('./util');
|
| 4 |
+
|
| 5 |
+
module.exports = SchemaObject;
|
| 6 |
+
|
| 7 |
+
function SchemaObject(obj) {
|
| 8 |
+
util.copy(obj, this);
|
| 9 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/ucs2length.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
// https://mathiasbynens.be/notes/javascript-encoding
|
| 4 |
+
// https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
|
| 5 |
+
module.exports = function ucs2length(str) {
|
| 6 |
+
var length = 0
|
| 7 |
+
, len = str.length
|
| 8 |
+
, pos = 0
|
| 9 |
+
, value;
|
| 10 |
+
while (pos < len) {
|
| 11 |
+
length++;
|
| 12 |
+
value = str.charCodeAt(pos++);
|
| 13 |
+
if (value >= 0xD800 && value <= 0xDBFF && pos < len) {
|
| 14 |
+
// high surrogate, and there is a next character
|
| 15 |
+
value = str.charCodeAt(pos);
|
| 16 |
+
if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
return length;
|
| 20 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/compile/util.js
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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+
coerceToTypes: coerceToTypes,
|
| 9 |
+
toHash: toHash,
|
| 10 |
+
getProperty: getProperty,
|
| 11 |
+
escapeQuotes: escapeQuotes,
|
| 12 |
+
equal: require('fast-deep-equal'),
|
| 13 |
+
ucs2length: require('./ucs2length'),
|
| 14 |
+
varOccurences: varOccurences,
|
| 15 |
+
varReplace: varReplace,
|
| 16 |
+
schemaHasRules: schemaHasRules,
|
| 17 |
+
schemaHasRulesExcept: schemaHasRulesExcept,
|
| 18 |
+
schemaUnknownRules: schemaUnknownRules,
|
| 19 |
+
toQuotedString: toQuotedString,
|
| 20 |
+
getPathExpr: getPathExpr,
|
| 21 |
+
getPath: getPath,
|
| 22 |
+
getData: getData,
|
| 23 |
+
unescapeFragment: unescapeFragment,
|
| 24 |
+
unescapeJsonPointer: unescapeJsonPointer,
|
| 25 |
+
escapeFragment: escapeFragment,
|
| 26 |
+
escapeJsonPointer: escapeJsonPointer
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
function copy(o, to) {
|
| 31 |
+
to = to || {};
|
| 32 |
+
for (var key in o) to[key] = o[key];
|
| 33 |
+
return to;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
function checkDataType(dataType, data, strictNumbers, negate) {
|
| 38 |
+
var EQUAL = negate ? ' !== ' : ' === '
|
| 39 |
+
, AND = negate ? ' || ' : ' && '
|
| 40 |
+
, OK = negate ? '!' : ''
|
| 41 |
+
, NOT = negate ? '' : '!';
|
| 42 |
+
switch (dataType) {
|
| 43 |
+
case 'null': return data + EQUAL + 'null';
|
| 44 |
+
case 'array': return OK + 'Array.isArray(' + data + ')';
|
| 45 |
+
case 'object': return '(' + OK + data + AND +
|
| 46 |
+
'typeof ' + data + EQUAL + '"object"' + AND +
|
| 47 |
+
NOT + 'Array.isArray(' + data + '))';
|
| 48 |
+
case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
|
| 49 |
+
NOT + '(' + data + ' % 1)' +
|
| 50 |
+
AND + data + EQUAL + data +
|
| 51 |
+
(strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
|
| 52 |
+
case 'number': return '(typeof ' + data + EQUAL + '"' + dataType + '"' +
|
| 53 |
+
(strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
|
| 54 |
+
default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
function checkDataTypes(dataTypes, data, strictNumbers) {
|
| 60 |
+
switch (dataTypes.length) {
|
| 61 |
+
case 1: return checkDataType(dataTypes[0], data, strictNumbers, true);
|
| 62 |
+
default:
|
| 63 |
+
var code = '';
|
| 64 |
+
var types = toHash(dataTypes);
|
| 65 |
+
if (types.array && types.object) {
|
| 66 |
+
code = types.null ? '(': '(!' + data + ' || ';
|
| 67 |
+
code += 'typeof ' + data + ' !== "object")';
|
| 68 |
+
delete types.null;
|
| 69 |
+
delete types.array;
|
| 70 |
+
delete types.object;
|
| 71 |
+
}
|
| 72 |
+
if (types.number) delete types.integer;
|
| 73 |
+
for (var t in types)
|
| 74 |
+
code += (code ? ' && ' : '' ) + checkDataType(t, data, strictNumbers, true);
|
| 75 |
+
|
| 76 |
+
return code;
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]);
|
| 82 |
+
function coerceToTypes(optionCoerceTypes, dataTypes) {
|
| 83 |
+
if (Array.isArray(dataTypes)) {
|
| 84 |
+
var types = [];
|
| 85 |
+
for (var i=0; i<dataTypes.length; i++) {
|
| 86 |
+
var t = dataTypes[i];
|
| 87 |
+
if (COERCE_TO_TYPES[t]) types[types.length] = t;
|
| 88 |
+
else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t;
|
| 89 |
+
}
|
| 90 |
+
if (types.length) return types;
|
| 91 |
+
} else if (COERCE_TO_TYPES[dataTypes]) {
|
| 92 |
+
return [dataTypes];
|
| 93 |
+
} else if (optionCoerceTypes === 'array' && dataTypes === 'array') {
|
| 94 |
+
return ['array'];
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
function toHash(arr) {
|
| 100 |
+
var hash = {};
|
| 101 |
+
for (var i=0; i<arr.length; i++) hash[arr[i]] = true;
|
| 102 |
+
return hash;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
|
| 107 |
+
var SINGLE_QUOTE = /'|\\/g;
|
| 108 |
+
function getProperty(key) {
|
| 109 |
+
return typeof key == 'number'
|
| 110 |
+
? '[' + key + ']'
|
| 111 |
+
: IDENTIFIER.test(key)
|
| 112 |
+
? '.' + key
|
| 113 |
+
: "['" + escapeQuotes(key) + "']";
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
function escapeQuotes(str) {
|
| 118 |
+
return str.replace(SINGLE_QUOTE, '\\$&')
|
| 119 |
+
.replace(/\n/g, '\\n')
|
| 120 |
+
.replace(/\r/g, '\\r')
|
| 121 |
+
.replace(/\f/g, '\\f')
|
| 122 |
+
.replace(/\t/g, '\\t');
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
function varOccurences(str, dataVar) {
|
| 127 |
+
dataVar += '[^0-9]';
|
| 128 |
+
var matches = str.match(new RegExp(dataVar, 'g'));
|
| 129 |
+
return matches ? matches.length : 0;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
function varReplace(str, dataVar, expr) {
|
| 134 |
+
dataVar += '([^0-9])';
|
| 135 |
+
expr = expr.replace(/\$/g, '$$$$');
|
| 136 |
+
return str.replace(new RegExp(dataVar, 'g'), expr + '$1');
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
function schemaHasRules(schema, rules) {
|
| 141 |
+
if (typeof schema == 'boolean') return !schema;
|
| 142 |
+
for (var key in schema) if (rules[key]) return true;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
function schemaHasRulesExcept(schema, rules, exceptKeyword) {
|
| 147 |
+
if (typeof schema == 'boolean') return !schema && exceptKeyword != 'not';
|
| 148 |
+
for (var key in schema) if (key != exceptKeyword && rules[key]) return true;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
function schemaUnknownRules(schema, rules) {
|
| 153 |
+
if (typeof schema == 'boolean') return;
|
| 154 |
+
for (var key in schema) if (!rules[key]) return key;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
function toQuotedString(str) {
|
| 159 |
+
return '\'' + escapeQuotes(str) + '\'';
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
|
| 164 |
+
var path = jsonPointers // false by default
|
| 165 |
+
? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')')
|
| 166 |
+
: (isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\'');
|
| 167 |
+
return joinPaths(currentPath, path);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
function getPath(currentPath, prop, jsonPointers) {
|
| 172 |
+
var path = jsonPointers // false by default
|
| 173 |
+
? toQuotedString('/' + escapeJsonPointer(prop))
|
| 174 |
+
: toQuotedString(getProperty(prop));
|
| 175 |
+
return joinPaths(currentPath, path);
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
|
| 180 |
+
var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
| 181 |
+
function getData($data, lvl, paths) {
|
| 182 |
+
var up, jsonPointer, data, matches;
|
| 183 |
+
if ($data === '') return 'rootData';
|
| 184 |
+
if ($data[0] == '/') {
|
| 185 |
+
if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data);
|
| 186 |
+
jsonPointer = $data;
|
| 187 |
+
data = 'rootData';
|
| 188 |
+
} else {
|
| 189 |
+
matches = $data.match(RELATIVE_JSON_POINTER);
|
| 190 |
+
if (!matches) throw new Error('Invalid JSON-pointer: ' + $data);
|
| 191 |
+
up = +matches[1];
|
| 192 |
+
jsonPointer = matches[2];
|
| 193 |
+
if (jsonPointer == '#') {
|
| 194 |
+
if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl);
|
| 195 |
+
return paths[lvl - up];
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl);
|
| 199 |
+
data = 'data' + ((lvl - up) || '');
|
| 200 |
+
if (!jsonPointer) return data;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
var expr = data;
|
| 204 |
+
var segments = jsonPointer.split('/');
|
| 205 |
+
for (var i=0; i<segments.length; i++) {
|
| 206 |
+
var segment = segments[i];
|
| 207 |
+
if (segment) {
|
| 208 |
+
data += getProperty(unescapeJsonPointer(segment));
|
| 209 |
+
expr += ' && ' + data;
|
| 210 |
+
}
|
| 211 |
+
}
|
| 212 |
+
return expr;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
function joinPaths (a, b) {
|
| 217 |
+
if (a == '""') return b;
|
| 218 |
+
return (a + ' + ' + b).replace(/([^\\])' \+ '/g, '$1');
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
function unescapeFragment(str) {
|
| 223 |
+
return unescapeJsonPointer(decodeURIComponent(str));
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
function escapeFragment(str) {
|
| 228 |
+
return encodeURIComponent(escapeJsonPointer(str));
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
function escapeJsonPointer(str) {
|
| 233 |
+
return str.replace(/~/g, '~0').replace(/\//g, '~1');
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
function unescapeJsonPointer(str) {
|
| 238 |
+
return str.replace(/~1/g, '/').replace(/~0/g, '~');
|
| 239 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/data.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var KEYWORDS = [
|
| 4 |
+
'multipleOf',
|
| 5 |
+
'maximum',
|
| 6 |
+
'exclusiveMaximum',
|
| 7 |
+
'minimum',
|
| 8 |
+
'exclusiveMinimum',
|
| 9 |
+
'maxLength',
|
| 10 |
+
'minLength',
|
| 11 |
+
'pattern',
|
| 12 |
+
'additionalItems',
|
| 13 |
+
'maxItems',
|
| 14 |
+
'minItems',
|
| 15 |
+
'uniqueItems',
|
| 16 |
+
'maxProperties',
|
| 17 |
+
'minProperties',
|
| 18 |
+
'required',
|
| 19 |
+
'additionalProperties',
|
| 20 |
+
'enum',
|
| 21 |
+
'format',
|
| 22 |
+
'const'
|
| 23 |
+
];
|
| 24 |
+
|
| 25 |
+
module.exports = function (metaSchema, keywordsJsonPointers) {
|
| 26 |
+
for (var i=0; i<keywordsJsonPointers.length; i++) {
|
| 27 |
+
metaSchema = JSON.parse(JSON.stringify(metaSchema));
|
| 28 |
+
var segments = keywordsJsonPointers[i].split('/');
|
| 29 |
+
var keywords = metaSchema;
|
| 30 |
+
var j;
|
| 31 |
+
for (j=1; j<segments.length; j++)
|
| 32 |
+
keywords = keywords[segments[j]];
|
| 33 |
+
|
| 34 |
+
for (j=0; j<KEYWORDS.length; j++) {
|
| 35 |
+
var key = KEYWORDS[j];
|
| 36 |
+
var schema = keywords[key];
|
| 37 |
+
if (schema) {
|
| 38 |
+
keywords[key] = {
|
| 39 |
+
anyOf: [
|
| 40 |
+
schema,
|
| 41 |
+
{ $ref: 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
|
| 42 |
+
]
|
| 43 |
+
};
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
return metaSchema;
|
| 49 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/definition_schema.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var metaSchema = require('./refs/json-schema-draft-07.json');
|
| 4 |
+
|
| 5 |
+
module.exports = {
|
| 6 |
+
$id: 'https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js',
|
| 7 |
+
definitions: {
|
| 8 |
+
simpleTypes: metaSchema.definitions.simpleTypes
|
| 9 |
+
},
|
| 10 |
+
type: 'object',
|
| 11 |
+
dependencies: {
|
| 12 |
+
schema: ['validate'],
|
| 13 |
+
$data: ['validate'],
|
| 14 |
+
statements: ['inline'],
|
| 15 |
+
valid: {not: {required: ['macro']}}
|
| 16 |
+
},
|
| 17 |
+
properties: {
|
| 18 |
+
type: metaSchema.properties.type,
|
| 19 |
+
schema: {type: 'boolean'},
|
| 20 |
+
statements: {type: 'boolean'},
|
| 21 |
+
dependencies: {
|
| 22 |
+
type: 'array',
|
| 23 |
+
items: {type: 'string'}
|
| 24 |
+
},
|
| 25 |
+
metaSchema: {type: 'object'},
|
| 26 |
+
modifying: {type: 'boolean'},
|
| 27 |
+
valid: {type: 'boolean'},
|
| 28 |
+
$data: {type: 'boolean'},
|
| 29 |
+
async: {type: 'boolean'},
|
| 30 |
+
errors: {
|
| 31 |
+
anyOf: [
|
| 32 |
+
{type: 'boolean'},
|
| 33 |
+
{const: 'full'}
|
| 34 |
+
]
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/_limit.jst
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{# def.definitions }}
|
| 2 |
+
{{# def.errors }}
|
| 3 |
+
{{# def.setupKeyword }}
|
| 4 |
+
{{# def.$data }}
|
| 5 |
+
|
| 6 |
+
{{## def.setExclusiveLimit:
|
| 7 |
+
$exclusive = true;
|
| 8 |
+
$errorKeyword = $exclusiveKeyword;
|
| 9 |
+
$errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
|
| 10 |
+
#}}
|
| 11 |
+
|
| 12 |
+
{{
|
| 13 |
+
var $isMax = $keyword == 'maximum'
|
| 14 |
+
, $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum'
|
| 15 |
+
, $schemaExcl = it.schema[$exclusiveKeyword]
|
| 16 |
+
, $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data
|
| 17 |
+
, $op = $isMax ? '<' : '>'
|
| 18 |
+
, $notOp = $isMax ? '>' : '<'
|
| 19 |
+
, $errorKeyword = undefined;
|
| 20 |
+
|
| 21 |
+
if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
|
| 22 |
+
throw new Error($keyword + ' must be number');
|
| 23 |
+
}
|
| 24 |
+
if (!($isDataExcl || $schemaExcl === undefined
|
| 25 |
+
|| typeof $schemaExcl == 'number'
|
| 26 |
+
|| typeof $schemaExcl == 'boolean')) {
|
| 27 |
+
throw new Error($exclusiveKeyword + ' must be number or boolean');
|
| 28 |
+
}
|
| 29 |
+
}}
|
| 30 |
+
|
| 31 |
+
{{? $isDataExcl }}
|
| 32 |
+
{{
|
| 33 |
+
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
|
| 34 |
+
, $exclusive = 'exclusive' + $lvl
|
| 35 |
+
, $exclType = 'exclType' + $lvl
|
| 36 |
+
, $exclIsNumber = 'exclIsNumber' + $lvl
|
| 37 |
+
, $opExpr = 'op' + $lvl
|
| 38 |
+
, $opStr = '\' + ' + $opExpr + ' + \'';
|
| 39 |
+
}}
|
| 40 |
+
var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
|
| 41 |
+
{{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
|
| 42 |
+
|
| 43 |
+
var {{=$exclusive}};
|
| 44 |
+
var {{=$exclType}} = typeof {{=$schemaValueExcl}};
|
| 45 |
+
if ({{=$exclType}} != 'boolean' && {{=$exclType}} != 'undefined' && {{=$exclType}} != 'number') {
|
| 46 |
+
{{ var $errorKeyword = $exclusiveKeyword; }}
|
| 47 |
+
{{# def.error:'_exclusiveLimit' }}
|
| 48 |
+
} else if ({{# def.$dataNotType:'number' }}
|
| 49 |
+
{{=$exclType}} == 'number'
|
| 50 |
+
? (
|
| 51 |
+
({{=$exclusive}} = {{=$schemaValue}} === undefined || {{=$schemaValueExcl}} {{=$op}}= {{=$schemaValue}})
|
| 52 |
+
? {{=$data}} {{=$notOp}}= {{=$schemaValueExcl}}
|
| 53 |
+
: {{=$data}} {{=$notOp}} {{=$schemaValue}}
|
| 54 |
+
)
|
| 55 |
+
: (
|
| 56 |
+
({{=$exclusive}} = {{=$schemaValueExcl}} === true)
|
| 57 |
+
? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
|
| 58 |
+
: {{=$data}} {{=$notOp}} {{=$schemaValue}}
|
| 59 |
+
)
|
| 60 |
+
|| {{=$data}} !== {{=$data}}) {
|
| 61 |
+
var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
|
| 62 |
+
{{
|
| 63 |
+
if ($schema === undefined) {
|
| 64 |
+
$errorKeyword = $exclusiveKeyword;
|
| 65 |
+
$errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
|
| 66 |
+
$schemaValue = $schemaValueExcl;
|
| 67 |
+
$isData = $isDataExcl;
|
| 68 |
+
}
|
| 69 |
+
}}
|
| 70 |
+
{{??}}
|
| 71 |
+
{{
|
| 72 |
+
var $exclIsNumber = typeof $schemaExcl == 'number'
|
| 73 |
+
, $opStr = $op; /*used in error*/
|
| 74 |
+
}}
|
| 75 |
+
|
| 76 |
+
{{? $exclIsNumber && $isData }}
|
| 77 |
+
{{ var $opExpr = '\'' + $opStr + '\''; /*used in error*/ }}
|
| 78 |
+
if ({{# def.$dataNotType:'number' }}
|
| 79 |
+
( {{=$schemaValue}} === undefined
|
| 80 |
+
|| {{=$schemaExcl}} {{=$op}}= {{=$schemaValue}}
|
| 81 |
+
? {{=$data}} {{=$notOp}}= {{=$schemaExcl}}
|
| 82 |
+
: {{=$data}} {{=$notOp}} {{=$schemaValue}} )
|
| 83 |
+
|| {{=$data}} !== {{=$data}}) {
|
| 84 |
+
{{??}}
|
| 85 |
+
{{
|
| 86 |
+
if ($exclIsNumber && $schema === undefined) {
|
| 87 |
+
{{# def.setExclusiveLimit }}
|
| 88 |
+
$schemaValue = $schemaExcl;
|
| 89 |
+
$notOp += '=';
|
| 90 |
+
} else {
|
| 91 |
+
if ($exclIsNumber)
|
| 92 |
+
$schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
|
| 93 |
+
|
| 94 |
+
if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
|
| 95 |
+
{{# def.setExclusiveLimit }}
|
| 96 |
+
$notOp += '=';
|
| 97 |
+
} else {
|
| 98 |
+
$exclusive = false;
|
| 99 |
+
$opStr += '=';
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
var $opExpr = '\'' + $opStr + '\''; /*used in error*/
|
| 104 |
+
}}
|
| 105 |
+
|
| 106 |
+
if ({{# def.$dataNotType:'number' }}
|
| 107 |
+
{{=$data}} {{=$notOp}} {{=$schemaValue}}
|
| 108 |
+
|| {{=$data}} !== {{=$data}}) {
|
| 109 |
+
{{?}}
|
| 110 |
+
{{?}}
|
| 111 |
+
{{ $errorKeyword = $errorKeyword || $keyword; }}
|
| 112 |
+
{{# def.error:'_limit' }}
|
| 113 |
+
} {{? $breakOnError }} else { {{?}}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/_limitItems.jst
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{# def.definitions }}
|
| 2 |
+
{{# def.errors }}
|
| 3 |
+
{{# def.setupKeyword }}
|
| 4 |
+
{{# def.$data }}
|
| 5 |
+
|
| 6 |
+
{{# def.numberKeyword }}
|
| 7 |
+
|
| 8 |
+
{{ var $op = $keyword == 'maxItems' ? '>' : '<'; }}
|
| 9 |
+
if ({{# def.$dataNotType:'number' }} {{=$data}}.length {{=$op}} {{=$schemaValue}}) {
|
| 10 |
+
{{ var $errorKeyword = $keyword; }}
|
| 11 |
+
{{# def.error:'_limitItems' }}
|
| 12 |
+
} {{? $breakOnError }} else { {{?}}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/_limitLength.jst
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{# def.definitions }}
|
| 2 |
+
{{# def.errors }}
|
| 3 |
+
{{# def.setupKeyword }}
|
| 4 |
+
{{# def.$data }}
|
| 5 |
+
|
| 6 |
+
{{# def.numberKeyword }}
|
| 7 |
+
|
| 8 |
+
{{ var $op = $keyword == 'maxLength' ? '>' : '<'; }}
|
| 9 |
+
if ({{# def.$dataNotType:'number' }} {{# def.strLength }} {{=$op}} {{=$schemaValue}}) {
|
| 10 |
+
{{ var $errorKeyword = $keyword; }}
|
| 11 |
+
{{# def.error:'_limitLength' }}
|
| 12 |
+
} {{? $breakOnError }} else { {{?}}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/_limitProperties.jst
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{# def.definitions }}
|
| 2 |
+
{{# def.errors }}
|
| 3 |
+
{{# def.setupKeyword }}
|
| 4 |
+
{{# def.$data }}
|
| 5 |
+
|
| 6 |
+
{{# def.numberKeyword }}
|
| 7 |
+
|
| 8 |
+
{{ var $op = $keyword == 'maxProperties' ? '>' : '<'; }}
|
| 9 |
+
if ({{# def.$dataNotType:'number' }} Object.keys({{=$data}}).length {{=$op}} {{=$schemaValue}}) {
|
| 10 |
+
{{ var $errorKeyword = $keyword; }}
|
| 11 |
+
{{# def.error:'_limitProperties' }}
|
| 12 |
+
} {{? $breakOnError }} else { {{?}}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/allOf.jst
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{# def.definitions }}
|
| 2 |
+
{{# def.errors }}
|
| 3 |
+
{{# def.setupKeyword }}
|
| 4 |
+
{{# def.setupNextLevel }}
|
| 5 |
+
|
| 6 |
+
{{
|
| 7 |
+
var $currentBaseId = $it.baseId
|
| 8 |
+
, $allSchemasEmpty = true;
|
| 9 |
+
}}
|
| 10 |
+
|
| 11 |
+
{{~ $schema:$sch:$i }}
|
| 12 |
+
{{? {{# def.nonEmptySchema:$sch }} }}
|
| 13 |
+
{{
|
| 14 |
+
$allSchemasEmpty = false;
|
| 15 |
+
$it.schema = $sch;
|
| 16 |
+
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
| 17 |
+
$it.errSchemaPath = $errSchemaPath + '/' + $i;
|
| 18 |
+
}}
|
| 19 |
+
|
| 20 |
+
{{# def.insertSubschemaCode }}
|
| 21 |
+
|
| 22 |
+
{{# def.ifResultValid }}
|
| 23 |
+
{{?}}
|
| 24 |
+
{{~}}
|
| 25 |
+
|
| 26 |
+
{{? $breakOnError }}
|
| 27 |
+
{{? $allSchemasEmpty }}
|
| 28 |
+
if (true) {
|
| 29 |
+
{{??}}
|
| 30 |
+
{{= $closingBraces.slice(0,-1) }}
|
| 31 |
+
{{?}}
|
| 32 |
+
{{?}}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/anyOf.jst
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{# def.definitions }}
|
| 2 |
+
{{# def.errors }}
|
| 3 |
+
{{# def.setupKeyword }}
|
| 4 |
+
{{# def.setupNextLevel }}
|
| 5 |
+
|
| 6 |
+
{{
|
| 7 |
+
var $noEmptySchema = $schema.every(function($sch) {
|
| 8 |
+
return {{# def.nonEmptySchema:$sch }};
|
| 9 |
+
});
|
| 10 |
+
}}
|
| 11 |
+
{{? $noEmptySchema }}
|
| 12 |
+
{{ var $currentBaseId = $it.baseId; }}
|
| 13 |
+
var {{=$errs}} = errors;
|
| 14 |
+
var {{=$valid}} = false;
|
| 15 |
+
|
| 16 |
+
{{# def.setCompositeRule }}
|
| 17 |
+
|
| 18 |
+
{{~ $schema:$sch:$i }}
|
| 19 |
+
{{
|
| 20 |
+
$it.schema = $sch;
|
| 21 |
+
$it.schemaPath = $schemaPath + '[' + $i + ']';
|
| 22 |
+
$it.errSchemaPath = $errSchemaPath + '/' + $i;
|
| 23 |
+
}}
|
| 24 |
+
|
| 25 |
+
{{# def.insertSubschemaCode }}
|
| 26 |
+
|
| 27 |
+
{{=$valid}} = {{=$valid}} || {{=$nextValid}};
|
| 28 |
+
|
| 29 |
+
if (!{{=$valid}}) {
|
| 30 |
+
{{ $closingBraces += '}'; }}
|
| 31 |
+
{{~}}
|
| 32 |
+
|
| 33 |
+
{{# def.resetCompositeRule }}
|
| 34 |
+
|
| 35 |
+
{{= $closingBraces }}
|
| 36 |
+
|
| 37 |
+
if (!{{=$valid}}) {
|
| 38 |
+
{{# def.extraError:'anyOf' }}
|
| 39 |
+
} else {
|
| 40 |
+
{{# def.resetErrors }}
|
| 41 |
+
{{? it.opts.allErrors }} } {{?}}
|
| 42 |
+
{{??}}
|
| 43 |
+
{{? $breakOnError }}
|
| 44 |
+
if (true) {
|
| 45 |
+
{{?}}
|
| 46 |
+
{{?}}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/coerce.def
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{## def.coerceType:
|
| 2 |
+
{{
|
| 3 |
+
var $dataType = 'dataType' + $lvl
|
| 4 |
+
, $coerced = 'coerced' + $lvl;
|
| 5 |
+
}}
|
| 6 |
+
var {{=$dataType}} = typeof {{=$data}};
|
| 7 |
+
var {{=$coerced}} = undefined;
|
| 8 |
+
|
| 9 |
+
{{? it.opts.coerceTypes == 'array' }}
|
| 10 |
+
if ({{=$dataType}} == 'object' && Array.isArray({{=$data}}) && {{=$data}}.length == 1) {
|
| 11 |
+
{{=$data}} = {{=$data}}[0];
|
| 12 |
+
{{=$dataType}} = typeof {{=$data}};
|
| 13 |
+
if ({{=it.util.checkDataType(it.schema.type, $data, it.opts.strictNumbers)}}) {{=$coerced}} = {{=$data}};
|
| 14 |
+
}
|
| 15 |
+
{{?}}
|
| 16 |
+
|
| 17 |
+
if ({{=$coerced}} !== undefined) ;
|
| 18 |
+
{{~ $coerceToTypes:$type:$i }}
|
| 19 |
+
{{? $type == 'string' }}
|
| 20 |
+
else if ({{=$dataType}} == 'number' || {{=$dataType}} == 'boolean')
|
| 21 |
+
{{=$coerced}} = '' + {{=$data}};
|
| 22 |
+
else if ({{=$data}} === null) {{=$coerced}} = '';
|
| 23 |
+
{{?? $type == 'number' || $type == 'integer' }}
|
| 24 |
+
else if ({{=$dataType}} == 'boolean' || {{=$data}} === null
|
| 25 |
+
|| ({{=$dataType}} == 'string' && {{=$data}} && {{=$data}} == +{{=$data}}
|
| 26 |
+
{{? $type == 'integer' }} && !({{=$data}} % 1){{?}}))
|
| 27 |
+
{{=$coerced}} = +{{=$data}};
|
| 28 |
+
{{?? $type == 'boolean' }}
|
| 29 |
+
else if ({{=$data}} === 'false' || {{=$data}} === 0 || {{=$data}} === null)
|
| 30 |
+
{{=$coerced}} = false;
|
| 31 |
+
else if ({{=$data}} === 'true' || {{=$data}} === 1)
|
| 32 |
+
{{=$coerced}} = true;
|
| 33 |
+
{{?? $type == 'null' }}
|
| 34 |
+
else if ({{=$data}} === '' || {{=$data}} === 0 || {{=$data}} === false)
|
| 35 |
+
{{=$coerced}} = null;
|
| 36 |
+
{{?? it.opts.coerceTypes == 'array' && $type == 'array' }}
|
| 37 |
+
else if ({{=$dataType}} == 'string' || {{=$dataType}} == 'number' || {{=$dataType}} == 'boolean' || {{=$data}} == null)
|
| 38 |
+
{{=$coerced}} = [{{=$data}}];
|
| 39 |
+
{{?}}
|
| 40 |
+
{{~}}
|
| 41 |
+
else {
|
| 42 |
+
{{# def.error:'type' }}
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
if ({{=$coerced}} !== undefined) {
|
| 46 |
+
{{# def.setParentData }}
|
| 47 |
+
{{=$data}} = {{=$coerced}};
|
| 48 |
+
{{? !$dataLvl }}if ({{=$parentData}} !== undefined){{?}}
|
| 49 |
+
{{=$parentData}}[{{=$parentDataProperty}}] = {{=$coerced}};
|
| 50 |
+
}
|
| 51 |
+
#}}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/comment.jst
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{# def.definitions }}
|
| 2 |
+
{{# def.setupKeyword }}
|
| 3 |
+
|
| 4 |
+
{{ var $comment = it.util.toQuotedString($schema); }}
|
| 5 |
+
{{? it.opts.$comment === true }}
|
| 6 |
+
console.log({{=$comment}});
|
| 7 |
+
{{?? typeof it.opts.$comment == 'function' }}
|
| 8 |
+
self._opts.$comment({{=$comment}}, {{=it.util.toQuotedString($errSchemaPath)}}, validate.root.schema);
|
| 9 |
+
{{?}}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/const.jst
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{# def.definitions }}
|
| 2 |
+
{{# def.errors }}
|
| 3 |
+
{{# def.setupKeyword }}
|
| 4 |
+
{{# def.$data }}
|
| 5 |
+
|
| 6 |
+
{{? !$isData }}
|
| 7 |
+
var schema{{=$lvl}} = validate.schema{{=$schemaPath}};
|
| 8 |
+
{{?}}
|
| 9 |
+
var {{=$valid}} = equal({{=$data}}, schema{{=$lvl}});
|
| 10 |
+
{{# def.checkError:'const' }}
|
| 11 |
+
{{? $breakOnError }} else { {{?}}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/contains.jst
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{# def.definitions }}
|
| 2 |
+
{{# def.errors }}
|
| 3 |
+
{{# def.setupKeyword }}
|
| 4 |
+
{{# def.setupNextLevel }}
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
{{
|
| 8 |
+
var $idx = 'i' + $lvl
|
| 9 |
+
, $dataNxt = $it.dataLevel = it.dataLevel + 1
|
| 10 |
+
, $nextData = 'data' + $dataNxt
|
| 11 |
+
, $currentBaseId = it.baseId
|
| 12 |
+
, $nonEmptySchema = {{# def.nonEmptySchema:$schema }};
|
| 13 |
+
}}
|
| 14 |
+
|
| 15 |
+
var {{=$errs}} = errors;
|
| 16 |
+
var {{=$valid}};
|
| 17 |
+
|
| 18 |
+
{{? $nonEmptySchema }}
|
| 19 |
+
{{# def.setCompositeRule }}
|
| 20 |
+
|
| 21 |
+
{{
|
| 22 |
+
$it.schema = $schema;
|
| 23 |
+
$it.schemaPath = $schemaPath;
|
| 24 |
+
$it.errSchemaPath = $errSchemaPath;
|
| 25 |
+
}}
|
| 26 |
+
|
| 27 |
+
var {{=$nextValid}} = false;
|
| 28 |
+
|
| 29 |
+
for (var {{=$idx}} = 0; {{=$idx}} < {{=$data}}.length; {{=$idx}}++) {
|
| 30 |
+
{{
|
| 31 |
+
$it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
|
| 32 |
+
var $passData = $data + '[' + $idx + ']';
|
| 33 |
+
$it.dataPathArr[$dataNxt] = $idx;
|
| 34 |
+
}}
|
| 35 |
+
|
| 36 |
+
{{# def.generateSubschemaCode }}
|
| 37 |
+
{{# def.optimizeValidate }}
|
| 38 |
+
|
| 39 |
+
if ({{=$nextValid}}) break;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
{{# def.resetCompositeRule }}
|
| 43 |
+
{{= $closingBraces }}
|
| 44 |
+
|
| 45 |
+
if (!{{=$nextValid}}) {
|
| 46 |
+
{{??}}
|
| 47 |
+
if ({{=$data}}.length == 0) {
|
| 48 |
+
{{?}}
|
| 49 |
+
|
| 50 |
+
{{# def.error:'contains' }}
|
| 51 |
+
} else {
|
| 52 |
+
{{? $nonEmptySchema }}
|
| 53 |
+
{{# def.resetErrors }}
|
| 54 |
+
{{?}}
|
| 55 |
+
{{? it.opts.allErrors }} } {{?}}
|
novas/novacore-zephyr/groq-code-cli/node_modules/ajv/lib/dot/custom.jst
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{# def.definitions }}
|
| 2 |
+
{{# def.errors }}
|
| 3 |
+
{{# def.setupKeyword }}
|
| 4 |
+
{{# def.$data }}
|
| 5 |
+
|
| 6 |
+
{{
|
| 7 |
+
var $rule = this
|
| 8 |
+
, $definition = 'definition' + $lvl
|
| 9 |
+
, $rDef = $rule.definition
|
| 10 |
+
, $closingBraces = '';
|
| 11 |
+
var $validate = $rDef.validate;
|
| 12 |
+
var $compile, $inline, $macro, $ruleValidate, $validateCode;
|
| 13 |
+
}}
|
| 14 |
+
|
| 15 |
+
{{? $isData && $rDef.$data }}
|
| 16 |
+
{{
|
| 17 |
+
$validateCode = 'keywordValidate' + $lvl;
|
| 18 |
+
var $validateSchema = $rDef.validateSchema;
|
| 19 |
+
}}
|
| 20 |
+
var {{=$definition}} = RULES.custom['{{=$keyword}}'].definition;
|
| 21 |
+
var {{=$validateCode}} = {{=$definition}}.validate;
|
| 22 |
+
{{??}}
|
| 23 |
+
{{
|
| 24 |
+
$ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
|
| 25 |
+
if (!$ruleValidate) return;
|
| 26 |
+
$schemaValue = 'validate.schema' + $schemaPath;
|
| 27 |
+
$validateCode = $ruleValidate.code;
|
| 28 |
+
$compile = $rDef.compile;
|
| 29 |
+
$inline = $rDef.inline;
|
| 30 |
+
$macro = $rDef.macro;
|
| 31 |
+
}}
|
| 32 |
+
{{?}}
|
| 33 |
+
|
| 34 |
+
{{
|
| 35 |
+
var $ruleErrs = $validateCode + '.errors'
|
| 36 |
+
, $i = 'i' + $lvl
|
| 37 |
+
, $ruleErr = 'ruleErr' + $lvl
|
| 38 |
+
, $asyncKeyword = $rDef.async;
|
| 39 |
+
|
| 40 |
+
if ($asyncKeyword && !it.async)
|
| 41 |
+
throw new Error('async keyword in sync schema');
|
| 42 |
+
}}
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
{{? !($inline || $macro) }}{{=$ruleErrs}} = null;{{?}}
|
| 46 |
+
var {{=$errs}} = errors;
|
| 47 |
+
var {{=$valid}};
|
| 48 |
+
|
| 49 |
+
{{## def.callRuleValidate:
|
| 50 |
+
{{=$validateCode}}.call(
|
| 51 |
+
{{? it.opts.passContext }}this{{??}}self{{?}}
|
| 52 |
+
{{? $compile || $rDef.schema === false }}
|
| 53 |
+
, {{=$data}}
|
| 54 |
+
{{??}}
|
| 55 |
+
, {{=$schemaValue}}
|
| 56 |
+
, {{=$data}}
|
| 57 |
+
, validate.schema{{=it.schemaPath}}
|
| 58 |
+
{{?}}
|
| 59 |
+
, {{# def.dataPath }}
|
| 60 |
+
{{# def.passParentData }}
|
| 61 |
+
, rootData
|
| 62 |
+
)
|
| 63 |
+
#}}
|
| 64 |
+
|
| 65 |
+
{{## def.extendErrors:_inline:
|
| 66 |
+
for (var {{=$i}}={{=$errs}}; {{=$i}}<errors; {{=$i}}++) {
|
| 67 |
+
var {{=$ruleErr}} = vErrors[{{=$i}}];
|
| 68 |
+
if ({{=$ruleErr}}.dataPath === undefined)
|
| 69 |
+
{{=$ruleErr}}.dataPath = (dataPath || '') + {{= it.errorPath }};
|
| 70 |
+
{{# _inline ? 'if (\{\{=$ruleErr\}\}.schemaPath === undefined) {' : '' }}
|
| 71 |
+
{{=$ruleErr}}.schemaPath = "{{=$errSchemaPath}}";
|
| 72 |
+
{{# _inline ? '}' : '' }}
|
| 73 |
+
{{? it.opts.verbose }}
|
| 74 |
+
{{=$ruleErr}}.schema = {{=$schemaValue}};
|
| 75 |
+
{{=$ruleErr}}.data = {{=$data}};
|
| 76 |
+
{{?}}
|
| 77 |
+
}
|
| 78 |
+
#}}
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
{{? $isData && $rDef.$data }}
|
| 82 |
+
{{ $closingBraces += '}'; }}
|
| 83 |
+
if ({{=$schemaValue}} === undefined) {
|
| 84 |
+
{{=$valid}} = true;
|
| 85 |
+
} else {
|
| 86 |
+
{{? $validateSchema }}
|
| 87 |
+
{{ $closingBraces += '}'; }}
|
| 88 |
+
{{=$valid}} = {{=$definition}}.validateSchema({{=$schemaValue}});
|
| 89 |
+
if ({{=$valid}}) {
|
| 90 |
+
{{?}}
|
| 91 |
+
{{?}}
|
| 92 |
+
|
| 93 |
+
{{? $inline }}
|
| 94 |
+
{{? $rDef.statements }}
|
| 95 |
+
{{= $ruleValidate.validate }}
|
| 96 |
+
{{??}}
|
| 97 |
+
{{=$valid}} = {{= $ruleValidate.validate }};
|
| 98 |
+
{{?}}
|
| 99 |
+
{{?? $macro }}
|
| 100 |
+
{{# def.setupNextLevel }}
|
| 101 |
+
{{
|
| 102 |
+
$it.schema = $ruleValidate.validate;
|
| 103 |
+
$it.schemaPath = '';
|
| 104 |
+
}}
|
| 105 |
+
{{# def.setCompositeRule }}
|
| 106 |
+
{{ var $code = it.validate($it).replace(/validate\.schema/g, $validateCode); }}
|
| 107 |
+
{{# def.resetCompositeRule }}
|
| 108 |
+
{{= $code }}
|
| 109 |
+
{{??}}
|
| 110 |
+
{{# def.beginDefOut}}
|
| 111 |
+
{{# def.callRuleValidate }}
|
| 112 |
+
{{# def.storeDefOut:def_callRuleValidate }}
|
| 113 |
+
|
| 114 |
+
{{? $rDef.errors === false }}
|
| 115 |
+
{{=$valid}} = {{? $asyncKeyword }}await {{?}}{{= def_callRuleValidate }};
|
| 116 |
+
{{??}}
|
| 117 |
+
{{? $asyncKeyword }}
|
| 118 |
+
{{ $ruleErrs = 'customErrors' + $lvl; }}
|
| 119 |
+
var {{=$ruleErrs}} = null;
|
| 120 |
+
try {
|
| 121 |
+
{{=$valid}} = await {{= def_callRuleValidate }};
|
| 122 |
+
} catch (e) {
|
| 123 |
+
{{=$valid}} = false;
|
| 124 |
+
if (e instanceof ValidationError) {{=$ruleErrs}} = e.errors;
|
| 125 |
+
else throw e;
|
| 126 |
+
}
|
| 127 |
+
{{??}}
|
| 128 |
+
{{=$ruleErrs}} = null;
|
| 129 |
+
{{=$valid}} = {{= def_callRuleValidate }};
|
| 130 |
+
{{?}}
|
| 131 |
+
{{?}}
|
| 132 |
+
{{?}}
|
| 133 |
+
|
| 134 |
+
{{? $rDef.modifying }}
|
| 135 |
+
if ({{=$parentData}}) {{=$data}} = {{=$parentData}}[{{=$parentDataProperty}}];
|
| 136 |
+
{{?}}
|
| 137 |
+
|
| 138 |
+
{{= $closingBraces }}
|
| 139 |
+
|
| 140 |
+
{{## def.notValidationResult:
|
| 141 |
+
{{? $rDef.valid === undefined }}
|
| 142 |
+
!{{? $macro }}{{=$nextValid}}{{??}}{{=$valid}}{{?}}
|
| 143 |
+
{{??}}
|
| 144 |
+
{{= !$rDef.valid }}
|
| 145 |
+
{{?}}
|
| 146 |
+
#}}
|
| 147 |
+
|
| 148 |
+
{{? $rDef.valid }}
|
| 149 |
+
{{? $breakOnError }} if (true) { {{?}}
|
| 150 |
+
{{??}}
|
| 151 |
+
if ({{# def.notValidationResult }}) {
|
| 152 |
+
{{ $errorKeyword = $rule.keyword; }}
|
| 153 |
+
{{# def.beginDefOut}}
|
| 154 |
+
{{# def.error:'custom' }}
|
| 155 |
+
{{# def.storeDefOut:def_customError }}
|
| 156 |
+
|
| 157 |
+
{{? $inline }}
|
| 158 |
+
{{? $rDef.errors }}
|
| 159 |
+
{{? $rDef.errors != 'full' }}
|
| 160 |
+
{{# def.extendErrors:true }}
|
| 161 |
+
{{?}}
|
| 162 |
+
{{??}}
|
| 163 |
+
{{? $rDef.errors === false}}
|
| 164 |
+
{{= def_customError }}
|
| 165 |
+
{{??}}
|
| 166 |
+
if ({{=$errs}} == errors) {
|
| 167 |
+
{{= def_customError }}
|
| 168 |
+
} else {
|
| 169 |
+
{{# def.extendErrors:true }}
|
| 170 |
+
}
|
| 171 |
+
{{?}}
|
| 172 |
+
{{?}}
|
| 173 |
+
{{?? $macro }}
|
| 174 |
+
{{# def.extraError:'custom' }}
|
| 175 |
+
{{??}}
|
| 176 |
+
{{? $rDef.errors === false}}
|
| 177 |
+
{{= def_customError }}
|
| 178 |
+
{{??}}
|
| 179 |
+
if (Array.isArray({{=$ruleErrs}})) {
|
| 180 |
+
if (vErrors === null) vErrors = {{=$ruleErrs}};
|
| 181 |
+
else vErrors = vErrors.concat({{=$ruleErrs}});
|
| 182 |
+
errors = vErrors.length;
|
| 183 |
+
{{# def.extendErrors:false }}
|
| 184 |
+
} else {
|
| 185 |
+
{{= def_customError }}
|
| 186 |
+
}
|
| 187 |
+
{{?}}
|
| 188 |
+
{{?}}
|
| 189 |
+
|
| 190 |
+
} {{? $breakOnError }} else { {{?}}
|
| 191 |
+
{{?}}
|