WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
import {generateKeypair, getPublicKey, Ed25519Keypair} from './utils/ed25519';
|
||||
import {PublicKey} from './publickey';
|
||||
|
||||
/**
|
||||
* Keypair signer interface
|
||||
*/
|
||||
export interface Signer {
|
||||
publicKey: PublicKey;
|
||||
secretKey: Uint8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* An account keypair used for signing transactions.
|
||||
*/
|
||||
export class Keypair {
|
||||
private _keypair: Ed25519Keypair;
|
||||
|
||||
/**
|
||||
* Create a new keypair instance.
|
||||
* Generate random keypair if no {@link Ed25519Keypair} is provided.
|
||||
*
|
||||
* @param {Ed25519Keypair} keypair ed25519 keypair
|
||||
*/
|
||||
constructor(keypair?: Ed25519Keypair) {
|
||||
this._keypair = keypair ?? generateKeypair();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new random keypair
|
||||
*
|
||||
* @returns {Keypair} Keypair
|
||||
*/
|
||||
static generate(): Keypair {
|
||||
return new Keypair(generateKeypair());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a keypair from a raw secret key byte array.
|
||||
*
|
||||
* This method should only be used to recreate a keypair from a previously
|
||||
* generated secret key. Generating keypairs from a random seed should be done
|
||||
* with the {@link Keypair.fromSeed} method.
|
||||
*
|
||||
* @throws error if the provided secret key is invalid and validation is not skipped.
|
||||
*
|
||||
* @param secretKey secret key byte array
|
||||
* @param options skip secret key validation
|
||||
*
|
||||
* @returns {Keypair} Keypair
|
||||
*/
|
||||
static fromSecretKey(
|
||||
secretKey: Uint8Array,
|
||||
options?: {skipValidation?: boolean},
|
||||
): Keypair {
|
||||
if (secretKey.byteLength !== 64) {
|
||||
throw new Error('bad secret key size');
|
||||
}
|
||||
const publicKey = secretKey.slice(32, 64);
|
||||
if (!options || !options.skipValidation) {
|
||||
const privateScalar = secretKey.slice(0, 32);
|
||||
const computedPublicKey = getPublicKey(privateScalar);
|
||||
for (let ii = 0; ii < 32; ii++) {
|
||||
if (publicKey[ii] !== computedPublicKey[ii]) {
|
||||
throw new Error('provided secretKey is invalid');
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Keypair({publicKey, secretKey});
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a keypair from a 32 byte seed.
|
||||
*
|
||||
* @param seed seed byte array
|
||||
*
|
||||
* @returns {Keypair} Keypair
|
||||
*/
|
||||
static fromSeed(seed: Uint8Array): Keypair {
|
||||
const publicKey = getPublicKey(seed);
|
||||
const secretKey = new Uint8Array(64);
|
||||
secretKey.set(seed);
|
||||
secretKey.set(publicKey, 32);
|
||||
return new Keypair({publicKey, secretKey});
|
||||
}
|
||||
|
||||
/**
|
||||
* The public key for this keypair
|
||||
*
|
||||
* @returns {PublicKey} PublicKey
|
||||
*/
|
||||
get publicKey(): PublicKey {
|
||||
return new PublicKey(this._keypair.publicKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* The raw secret key for this keypair
|
||||
* @returns {Uint8Array} Secret key in an array of Uint8 bytes
|
||||
*/
|
||||
get secretKey(): Uint8Array {
|
||||
return new Uint8Array(this._keypair.secretKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
const kDone = Symbol('kDone');
|
||||
const kRun = Symbol('kRun');
|
||||
|
||||
/**
|
||||
* A very simple job queue with adjustable concurrency. Adapted from
|
||||
* https://github.com/STRML/async-limiter
|
||||
*/
|
||||
class Limiter {
|
||||
/**
|
||||
* Creates a new `Limiter`.
|
||||
*
|
||||
* @param {Number} [concurrency=Infinity] The maximum number of jobs allowed
|
||||
* to run concurrently
|
||||
*/
|
||||
constructor(concurrency) {
|
||||
this[kDone] = () => {
|
||||
this.pending--;
|
||||
this[kRun]();
|
||||
};
|
||||
this.concurrency = concurrency || Infinity;
|
||||
this.jobs = [];
|
||||
this.pending = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a job to the queue.
|
||||
*
|
||||
* @param {Function} job The job to run
|
||||
* @public
|
||||
*/
|
||||
add(job) {
|
||||
this.jobs.push(job);
|
||||
this[kRun]();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a job from the queue and runs it if possible.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
[kRun]() {
|
||||
if (this.pending === this.concurrency) return;
|
||||
|
||||
if (this.jobs.length) {
|
||||
const job = this.jobs.shift();
|
||||
|
||||
this.pending++;
|
||||
job(this[kDone]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Limiter;
|
||||
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// SEE https://typescript-eslint.io/users/configs
|
||||
//
|
||||
// For developers working in the typescript-eslint monorepo:
|
||||
// You can regenerate it using `pnpm run generate-configs`
|
||||
module.exports = {
|
||||
extends: ['./configs/eslintrc/base', './configs/eslintrc/eslint-recommended'],
|
||||
rules: {
|
||||
'@typescript-eslint/await-thenable': 'error',
|
||||
'@typescript-eslint/no-array-delete': 'error',
|
||||
'@typescript-eslint/no-base-to-string': 'error',
|
||||
'@typescript-eslint/no-duplicate-type-constituents': 'error',
|
||||
'@typescript-eslint/no-floating-promises': 'error',
|
||||
'@typescript-eslint/no-for-in-array': 'error',
|
||||
'no-implied-eval': 'off',
|
||||
'@typescript-eslint/no-implied-eval': 'error',
|
||||
'@typescript-eslint/no-misused-promises': 'error',
|
||||
'@typescript-eslint/no-redundant-type-constituents': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
||||
'@typescript-eslint/no-unsafe-argument': 'error',
|
||||
'@typescript-eslint/no-unsafe-assignment': 'error',
|
||||
'@typescript-eslint/no-unsafe-call': 'error',
|
||||
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
|
||||
'@typescript-eslint/no-unsafe-member-access': 'error',
|
||||
'@typescript-eslint/no-unsafe-return': 'error',
|
||||
'@typescript-eslint/no-unsafe-unary-minus': 'error',
|
||||
'no-throw-literal': 'off',
|
||||
'@typescript-eslint/only-throw-error': 'error',
|
||||
'prefer-promise-reject-errors': 'off',
|
||||
'@typescript-eslint/prefer-promise-reject-errors': 'error',
|
||||
'require-await': 'off',
|
||||
'@typescript-eslint/require-await': 'error',
|
||||
'@typescript-eslint/restrict-plus-operands': 'error',
|
||||
'@typescript-eslint/restrict-template-expressions': 'error',
|
||||
'@typescript-eslint/unbound-method': 'error',
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,227 @@
|
||||
/**
|
||||
* @fileoverview Rule to flag use of console object
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Types
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("eslint-scope").Reference} Reference */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
|
||||
defaultOptions: [{}],
|
||||
|
||||
docs: {
|
||||
description: "Disallow the use of `console`",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-console",
|
||||
},
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
allow: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "string",
|
||||
},
|
||||
minItems: 1,
|
||||
uniqueItems: true,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
|
||||
hasSuggestions: true,
|
||||
|
||||
messages: {
|
||||
unexpected: "Unexpected console statement.",
|
||||
limited:
|
||||
"Unexpected console statement. Only these console methods are allowed: {{ allowed }}.",
|
||||
removeConsole: "Remove the console.{{ propertyName }}().",
|
||||
removeMethodCall: "Remove the console method call.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const [{ allow: allowed = [] }] = context.options;
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Checks whether the given reference is 'console' or not.
|
||||
* @param {Reference} reference The reference to check.
|
||||
* @returns {boolean} `true` if the reference is 'console'.
|
||||
*/
|
||||
function isConsole(reference) {
|
||||
const id = reference.identifier;
|
||||
|
||||
return id && id.name === "console";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the property name of the given MemberExpression node
|
||||
* is allowed by options or not.
|
||||
* @param {ASTNode} node The MemberExpression node to check.
|
||||
* @returns {boolean} `true` if the property name of the node is allowed.
|
||||
*/
|
||||
function isAllowed(node) {
|
||||
const propertyName = astUtils.getStaticPropertyName(node);
|
||||
|
||||
return propertyName && allowed.includes(propertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given reference is a member access which is not
|
||||
* allowed by options or not.
|
||||
* @param {Reference} reference The reference to check.
|
||||
* @returns {boolean} `true` if the reference is a member access which
|
||||
* is not allowed by options.
|
||||
*/
|
||||
function isMemberAccessExceptAllowed(reference) {
|
||||
const node = reference.identifier;
|
||||
const parent = node.parent;
|
||||
|
||||
return (
|
||||
parent.type === "MemberExpression" &&
|
||||
parent.object === node &&
|
||||
!isAllowed(parent)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if removing the ExpressionStatement node will cause ASI to
|
||||
* break.
|
||||
* eg.
|
||||
* foo()
|
||||
* console.log();
|
||||
* [1, 2, 3].forEach(a => doSomething(a))
|
||||
*
|
||||
* Removing the console.log(); statement should leave two statements, but
|
||||
* here the two statements will become one because [ causes continuation after
|
||||
* foo().
|
||||
* @param {ASTNode} node The ExpressionStatement node to check.
|
||||
* @returns {boolean} `true` if ASI will break after removing the ExpressionStatement
|
||||
* node.
|
||||
*/
|
||||
function maybeAsiHazard(node) {
|
||||
const SAFE_TOKENS_BEFORE = /^[:;{]$/u; // One of :;{
|
||||
const UNSAFE_CHARS_AFTER = /^[-[(/+`]/u; // One of [(/+-`
|
||||
|
||||
const tokenBefore = sourceCode.getTokenBefore(node);
|
||||
const tokenAfter = sourceCode.getTokenAfter(node);
|
||||
|
||||
return (
|
||||
Boolean(tokenAfter) &&
|
||||
UNSAFE_CHARS_AFTER.test(tokenAfter.value) &&
|
||||
tokenAfter.value !== "++" &&
|
||||
tokenAfter.value !== "--" &&
|
||||
Boolean(tokenBefore) &&
|
||||
!SAFE_TOKENS_BEFORE.test(tokenBefore.value)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the MemberExpression node's parent.parent.parent is a
|
||||
* Program, BlockStatement, StaticBlock, or SwitchCase node. This check
|
||||
* is necessary to avoid providing a suggestion that might cause a syntax error.
|
||||
*
|
||||
* eg. if (a) console.log(b), removing console.log() here will lead to a
|
||||
* syntax error.
|
||||
* if (a) { console.log(b) }, removing console.log() here is acceptable.
|
||||
*
|
||||
* Additionally, it checks if the callee of the CallExpression node is
|
||||
* the node itself.
|
||||
*
|
||||
* eg. foo(console.log), cannot provide a suggestion here.
|
||||
* @param {ASTNode} node The MemberExpression node to check.
|
||||
* @returns {boolean} `true` if a suggestion can be provided for a node.
|
||||
*/
|
||||
function canProvideSuggestions(node) {
|
||||
return (
|
||||
node.parent.type === "CallExpression" &&
|
||||
node.parent.callee === node &&
|
||||
node.parent.parent.type === "ExpressionStatement" &&
|
||||
astUtils.STATEMENT_LIST_PARENTS.has(
|
||||
node.parent.parent.parent.type,
|
||||
) &&
|
||||
!maybeAsiHazard(node.parent.parent)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports the given reference as a violation.
|
||||
* @param {Reference} reference The reference to report.
|
||||
* @returns {void}
|
||||
*/
|
||||
function report(reference) {
|
||||
const node = reference.identifier.parent;
|
||||
|
||||
const suggest = [];
|
||||
|
||||
if (canProvideSuggestions(node)) {
|
||||
const suggestion = {
|
||||
fix(fixer) {
|
||||
return fixer.remove(node.parent.parent);
|
||||
},
|
||||
};
|
||||
|
||||
if (node.computed) {
|
||||
suggestion.messageId = "removeMethodCall";
|
||||
} else {
|
||||
suggestion.messageId = "removeConsole";
|
||||
suggestion.data = { propertyName: node.property.name };
|
||||
}
|
||||
suggest.push(suggestion);
|
||||
}
|
||||
context.report({
|
||||
node,
|
||||
loc: node.loc,
|
||||
messageId: allowed.length ? "limited" : "unexpected",
|
||||
data: { allowed: allowed.join(", ") },
|
||||
suggest,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
"Program:exit"(node) {
|
||||
const scope = sourceCode.getScope(node);
|
||||
const consoleVar = astUtils.getVariableByName(scope, "console");
|
||||
const shadowed = consoleVar && consoleVar.defs.length > 0;
|
||||
|
||||
/*
|
||||
* 'scope.through' includes all references to undefined
|
||||
* variables. If the variable 'console' is not defined, it uses
|
||||
* 'scope.through'.
|
||||
*/
|
||||
const references = consoleVar
|
||||
? consoleVar.references
|
||||
: scope.through.filter(isConsole);
|
||||
|
||||
if (!shadowed) {
|
||||
references
|
||||
.filter(isMemberAccessExceptAllowed)
|
||||
.forEach(report);
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,181 @@
|
||||
/**
|
||||
* @fileoverview Rule to disallow use of Object.prototype builtins on objects
|
||||
* @author Andrew Levine
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if the node or any of the objects
|
||||
* to the left of it in the member/call chain is optional.
|
||||
*
|
||||
* e.g. `a?.b`, `a?.b.c`, `a?.()`, `a()?.()`
|
||||
* @param {ASTNode} node The expression to check
|
||||
* @returns {boolean} `true` if there is a short-circuiting optional `?.`
|
||||
* in the same option chain to the left of this call or member expression,
|
||||
* or the node itself is an optional call or member `?.`.
|
||||
*/
|
||||
function isAfterOptional(node) {
|
||||
let leftNode;
|
||||
|
||||
if (node.type === "MemberExpression") {
|
||||
leftNode = node.object;
|
||||
} else if (node.type === "CallExpression") {
|
||||
leftNode = node.callee;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (node.optional) {
|
||||
return true;
|
||||
}
|
||||
return isAfterOptional(leftNode);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "problem",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Disallow calling some `Object.prototype` methods directly on objects",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/latest/rules/no-prototype-builtins",
|
||||
},
|
||||
|
||||
hasSuggestions: true,
|
||||
|
||||
schema: [],
|
||||
|
||||
messages: {
|
||||
prototypeBuildIn:
|
||||
"Do not access Object.prototype method '{{prop}}' from target object.",
|
||||
callObjectPrototype: "Call Object.prototype.{{prop}} explicitly.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const DISALLOWED_PROPS = new Set([
|
||||
"hasOwnProperty",
|
||||
"isPrototypeOf",
|
||||
"propertyIsEnumerable",
|
||||
]);
|
||||
|
||||
/**
|
||||
* Reports if a disallowed property is used in a CallExpression
|
||||
* @param {ASTNode} node The CallExpression node.
|
||||
* @returns {void}
|
||||
*/
|
||||
function disallowBuiltIns(node) {
|
||||
const callee = astUtils.skipChainExpression(node.callee);
|
||||
|
||||
if (callee.type !== "MemberExpression") {
|
||||
return;
|
||||
}
|
||||
|
||||
const propName = astUtils.getStaticPropertyName(callee);
|
||||
|
||||
if (propName !== null && DISALLOWED_PROPS.has(propName)) {
|
||||
context.report({
|
||||
messageId: "prototypeBuildIn",
|
||||
loc: callee.property.loc,
|
||||
data: { prop: propName },
|
||||
node,
|
||||
suggest: [
|
||||
{
|
||||
messageId: "callObjectPrototype",
|
||||
data: { prop: propName },
|
||||
fix(fixer) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/*
|
||||
* A call after an optional chain (e.g. a?.b.hasOwnProperty(c))
|
||||
* must be fixed manually because the call can be short-circuited
|
||||
*/
|
||||
if (isAfterOptional(node)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* A call on a ChainExpression (e.g. (a?.hasOwnProperty)(c)) will trigger
|
||||
* no-unsafe-optional-chaining which should be fixed before this suggestion
|
||||
*/
|
||||
if (node.callee.type === "ChainExpression") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const objectVariable =
|
||||
astUtils.getVariableByName(
|
||||
sourceCode.getScope(node),
|
||||
"Object",
|
||||
);
|
||||
|
||||
/*
|
||||
* We can't use Object if the global Object was shadowed,
|
||||
* or Object does not exist in the global scope for some reason
|
||||
*/
|
||||
if (
|
||||
!objectVariable ||
|
||||
objectVariable.scope.type !== "global" ||
|
||||
objectVariable.defs.length > 0
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let objectText = sourceCode.getText(
|
||||
callee.object,
|
||||
);
|
||||
|
||||
if (
|
||||
astUtils.getPrecedence(callee.object) <=
|
||||
astUtils.getPrecedence({
|
||||
type: "SequenceExpression",
|
||||
})
|
||||
) {
|
||||
objectText = `(${objectText})`;
|
||||
}
|
||||
|
||||
const openParenToken = sourceCode.getTokenAfter(
|
||||
node.callee,
|
||||
astUtils.isOpeningParenToken,
|
||||
);
|
||||
const isEmptyParameters =
|
||||
node.arguments.length === 0;
|
||||
const delim = isEmptyParameters ? "" : ", ";
|
||||
const fixes = [
|
||||
fixer.replaceText(
|
||||
callee,
|
||||
`Object.prototype.${propName}.call`,
|
||||
),
|
||||
fixer.insertTextAfter(
|
||||
openParenToken,
|
||||
objectText + delim,
|
||||
),
|
||||
];
|
||||
|
||||
return fixes;
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
CallExpression: disallowBuiltIns,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
function _object_without_properties_loose(source, excluded) {
|
||||
if (source == null) return {};
|
||||
|
||||
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
||||
for (i = 0; i < sourceKeys.length; i++) {
|
||||
key = sourceKeys[i];
|
||||
if (excluded.indexOf(key) >= 0) continue;
|
||||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
||||
target[key] = source[key];
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
exports._ = _object_without_properties_loose;
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "espree",
|
||||
"description": "An Esprima-compatible JavaScript parser built on Acorn",
|
||||
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
||||
"homepage": "https://github.com/eslint/js/blob/main/packages/espree/README.md",
|
||||
"main": "dist/espree.cjs",
|
||||
"types": "./dist/espree.d.cts",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": {
|
||||
"import": "./dist/espree.d.ts",
|
||||
"require": "./dist/espree.d.cts"
|
||||
},
|
||||
"import": "./espree.js",
|
||||
"require": "./dist/espree.cjs",
|
||||
"default": "./dist/espree.cjs"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"version": "11.2.0",
|
||||
"files": [
|
||||
"lib",
|
||||
"dist",
|
||||
"espree.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.13.0 || >=24"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/eslint/js.git",
|
||||
"directory": "packages/espree"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint/js/issues"
|
||||
},
|
||||
"funding": "https://opencollective.com/eslint",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"acorn": "^8.16.0",
|
||||
"acorn-jsx": "^5.3.2",
|
||||
"eslint-visitor-keys": "^5.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"shelljs": "^0.8.5",
|
||||
"tsd": "^0.33.0"
|
||||
},
|
||||
"keywords": [
|
||||
"ast",
|
||||
"ecmascript",
|
||||
"javascript",
|
||||
"parser",
|
||||
"syntax",
|
||||
"acorn"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "rollup -c rollup.config.js && npm run build:types && node -e \"fs.rmSync('dist/lib', { recursive: true })\"",
|
||||
"build:debug": "npm run build -- -m",
|
||||
"build:docs": "node tools/sync-docs.js",
|
||||
"build:types": "tsc && tsc -p tsconfig-cjs.json",
|
||||
"lint:types": "attw --pack",
|
||||
"pretest": "npm run build",
|
||||
"test": "npm run test:types && npm run test:cjs && npm run test:esm",
|
||||
"test:cjs": "mocha --color --reporter progress --timeout 30000 \"tests/**/*.test.cjs\"",
|
||||
"test:esm": "c8 mocha --color --reporter progress --timeout 30000 \"tests/**/*.test.js\"",
|
||||
"test:types": "tsd --typings dist/espree.d.ts"
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { _ as default } from "../esm/_class_private_field_destructure.js";
|
||||
@@ -0,0 +1,5 @@
|
||||
import classPrivateFieldGet2 from "./classPrivateFieldGet2.js";
|
||||
function _classExtractFieldDescriptor(e, t) {
|
||||
return classPrivateFieldGet2(t, e);
|
||||
}
|
||||
export { _classExtractFieldDescriptor as default };
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "../../cjs/_is_native_reflect_construct.cjs",
|
||||
"module": "../../esm/_is_native_reflect_construct.js"
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
'use strict'
|
||||
|
||||
const types = require('pg-types')
|
||||
|
||||
const matchRegexp = /^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/
|
||||
|
||||
// result object returned from query
|
||||
// in the 'end' event and also
|
||||
// passed as second argument to provided callback
|
||||
class Result {
|
||||
constructor(rowMode, types) {
|
||||
this.command = null
|
||||
this.rowCount = null
|
||||
this.oid = null
|
||||
this.rows = []
|
||||
this.fields = []
|
||||
this._parsers = undefined
|
||||
this._types = types
|
||||
this.RowCtor = null
|
||||
this.rowAsArray = rowMode === 'array'
|
||||
if (this.rowAsArray) {
|
||||
this.parseRow = this._parseRowAsArray
|
||||
}
|
||||
this._prebuiltEmptyResultObject = null
|
||||
}
|
||||
|
||||
// adds a command complete message
|
||||
addCommandComplete(msg) {
|
||||
let match
|
||||
if (msg.text) {
|
||||
// pure javascript
|
||||
match = matchRegexp.exec(msg.text)
|
||||
} else {
|
||||
// native bindings
|
||||
match = matchRegexp.exec(msg.command)
|
||||
}
|
||||
if (match) {
|
||||
this.command = match[1]
|
||||
if (match[3]) {
|
||||
// COMMAND OID ROWS
|
||||
this.oid = parseInt(match[2], 10)
|
||||
this.rowCount = parseInt(match[3], 10)
|
||||
} else if (match[2]) {
|
||||
// COMMAND ROWS
|
||||
this.rowCount = parseInt(match[2], 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_parseRowAsArray(rowData) {
|
||||
const row = new Array(rowData.length)
|
||||
for (let i = 0, len = rowData.length; i < len; i++) {
|
||||
const rawValue = rowData[i]
|
||||
if (rawValue !== null) {
|
||||
row[i] = this._parsers[i](rawValue)
|
||||
} else {
|
||||
row[i] = null
|
||||
}
|
||||
}
|
||||
return row
|
||||
}
|
||||
|
||||
parseRow(rowData) {
|
||||
const row = { ...this._prebuiltEmptyResultObject }
|
||||
for (let i = 0, len = rowData.length; i < len; i++) {
|
||||
const rawValue = rowData[i]
|
||||
const field = this.fields[i].name
|
||||
if (rawValue !== null) {
|
||||
const v = this.fields[i].format === 'binary' ? Buffer.from(rawValue) : rawValue
|
||||
row[field] = this._parsers[i](v)
|
||||
} else {
|
||||
row[field] = null
|
||||
}
|
||||
}
|
||||
return row
|
||||
}
|
||||
|
||||
addRow(row) {
|
||||
this.rows.push(row)
|
||||
}
|
||||
|
||||
addFields(fieldDescriptions) {
|
||||
// clears field definitions
|
||||
// multiple query statements in 1 action can result in multiple sets
|
||||
// of rowDescriptions...eg: 'select NOW(); select 1::int;'
|
||||
// you need to reset the fields
|
||||
this.fields = fieldDescriptions
|
||||
if (this.fields.length) {
|
||||
this._parsers = new Array(fieldDescriptions.length)
|
||||
}
|
||||
|
||||
const row = Object.create(null)
|
||||
|
||||
for (let i = 0; i < fieldDescriptions.length; i++) {
|
||||
const desc = fieldDescriptions[i]
|
||||
row[desc.name] = null
|
||||
|
||||
if (this._types) {
|
||||
this._parsers[i] = this._types.getTypeParser(desc.dataTypeID, desc.format || 'text')
|
||||
} else {
|
||||
this._parsers[i] = types.getTypeParser(desc.dataTypeID, desc.format || 'text')
|
||||
}
|
||||
}
|
||||
|
||||
this._prebuiltEmptyResultObject = { ...row }
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Result
|
||||
@@ -0,0 +1,95 @@
|
||||
export var __create = Object.create;
|
||||
export var __defProp = Object.defineProperty;
|
||||
export var __name = (target, value) => __defProp(target, 'name', { value, configurable: true });
|
||||
export var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
export var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
export var __getProtoOf = Object.getPrototypeOf;
|
||||
export var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
export var __esm = (fn, res, err) =>
|
||||
function () {
|
||||
if (err) throw err[0];
|
||||
try {
|
||||
return (fn && (res = (0, fn[__getOwnPropNames(fn)[0]])((fn = 0))), res);
|
||||
} catch (e) {
|
||||
throw ((err = [e]), e);
|
||||
}
|
||||
};
|
||||
export var __esmMin = (fn, res, err) => () => {
|
||||
if (err) throw err[0];
|
||||
try {
|
||||
return (fn && (res = fn((fn = 0))), res);
|
||||
} catch (e) {
|
||||
throw ((err = [e]), e);
|
||||
}
|
||||
};
|
||||
export var __commonJS = (cb, mod) =>
|
||||
function () {
|
||||
return (
|
||||
mod || ((0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), cb = null), mod.exports
|
||||
);
|
||||
};
|
||||
export var __commonJSMin = (cb, mod) => () => (
|
||||
mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports
|
||||
);
|
||||
export var __exportAll = (all, no_symbols) => {
|
||||
let target = {};
|
||||
for (var name in all) {
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
}
|
||||
if (!no_symbols) {
|
||||
__defProp(target, Symbol.toStringTag, { value: 'Module' });
|
||||
}
|
||||
return target;
|
||||
};
|
||||
export var __copyProps = (to, from, except, desc) => {
|
||||
if ((from && typeof from === 'object') || typeof from === 'function') {
|
||||
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
||||
key = keys[i];
|
||||
if (!__hasOwnProp.call(to, key) && key !== except) {
|
||||
__defProp(to, key, {
|
||||
get: ((k) => from[k]).bind(null, key),
|
||||
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return to;
|
||||
};
|
||||
export var __reExport = (target, mod, secondTarget) => (
|
||||
__copyProps(target, mod, 'default'), secondTarget && __copyProps(secondTarget, mod, 'default')
|
||||
);
|
||||
export var __toESM = (mod, isNodeMode, target) => (
|
||||
(target = mod != null ? __create(__getProtoOf(mod)) : {}),
|
||||
__copyProps(
|
||||
// `__esModule` alone is not enough: the module must own a `default` (#10360).
|
||||
isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, 'default')
|
||||
? __defProp(target, 'default', { value: mod, enumerable: true })
|
||||
: target,
|
||||
mod,
|
||||
)
|
||||
);
|
||||
export var __toCommonJS = (mod) =>
|
||||
__hasOwnProp.call(mod, 'module.exports')
|
||||
? mod['module.exports']
|
||||
: __copyProps(__defProp({}, '__esModule', { value: true }), mod);
|
||||
export var __toBinaryNode = (base64) => new Uint8Array(Buffer.from(base64, 'base64'));
|
||||
export var __toBinary = /* @__PURE__ */ (() => {
|
||||
var table = new Uint8Array(128);
|
||||
for (var i = 0; i < 64; i++) {
|
||||
table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i;
|
||||
}
|
||||
return (base64) => {
|
||||
var n = base64.length,
|
||||
bytes = new Uint8Array((((n - (base64[n - 1] == '=') - (base64[n - 2] == '=')) * 3) / 4) | 0);
|
||||
for (var i = 0, j = 0; i < n; ) {
|
||||
var c0 = table[base64.charCodeAt(i++)],
|
||||
c1 = table[base64.charCodeAt(i++)];
|
||||
var c2 = table[base64.charCodeAt(i++)],
|
||||
c3 = table[base64.charCodeAt(i++)];
|
||||
bytes[j++] = (c0 << 2) | (c1 >> 4);
|
||||
bytes[j++] = (c1 << 4) | (c2 >> 2);
|
||||
bytes[j++] = (c2 << 6) | c3;
|
||||
}
|
||||
return bytes;
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1 @@
|
||||
export { parse, safeParse, parseAsync, safeParseAsync, encode, decode, encodeAsync, decodeAsync, safeEncode, safeDecode, safeEncodeAsync, safeDecodeAsync, } from "../core/index.cjs";
|
||||
@@ -0,0 +1 @@
|
||||
"use strict";const a=new Set(["Custom ESM Loaders is an experimental feature. This feature could change at any time","Custom ESM Loaders is an experimental feature and might change at any time","Import assertions are not a stable feature of the JavaScript language. Avoid relying on their current behavior and syntax as those might change in a future version of Node.js."]),{emit:n}=process;process.emit=function(e,t){if(!(e==="warning"&&a.has(t.message)))return Reflect.apply(n,this,arguments)};
|
||||
@@ -0,0 +1,81 @@
|
||||
import type { Program } from 'typescript';
|
||||
import type { Lib } from './lib';
|
||||
export type DebugLevel = boolean | ('eslint' | 'typescript' | 'typescript-eslint')[];
|
||||
export type CacheDurationSeconds = number | 'Infinity';
|
||||
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' | undefined;
|
||||
export type SourceTypeClassic = 'module' | 'script';
|
||||
export type SourceType = 'commonjs' | SourceTypeClassic;
|
||||
export type JSDocParsingMode = 'all' | 'none' | 'type-info';
|
||||
/**
|
||||
* Granular options to configure the project service.
|
||||
*/
|
||||
export interface ProjectServiceOptions {
|
||||
/**
|
||||
* Globs of files to allow running with the default project compiler options
|
||||
* despite not being matched by the project service.
|
||||
*/
|
||||
allowDefaultProject?: string[];
|
||||
/**
|
||||
* Path to a TSConfig to use instead of TypeScript's default project configuration.
|
||||
* @default 'tsconfig.json'
|
||||
*/
|
||||
defaultProject?: string;
|
||||
/**
|
||||
* Whether to allow TypeScript plugins as configured in the TSConfig.
|
||||
*/
|
||||
loadTypeScriptPlugins?: boolean;
|
||||
/**
|
||||
* The maximum number of files {@link allowDefaultProject} may match.
|
||||
* Each file match slows down linting, so if you do need to use this, please
|
||||
* file an informative issue on typescript-eslint explaining why - so we can
|
||||
* help you avoid using it!
|
||||
* @default 8
|
||||
*/
|
||||
maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING?: number;
|
||||
}
|
||||
export interface ParserOptions {
|
||||
[additionalProperties: string]: unknown;
|
||||
cacheLifetime?: {
|
||||
glob?: CacheDurationSeconds;
|
||||
};
|
||||
debugLevel?: DebugLevel;
|
||||
ecmaFeatures?: {
|
||||
[key: string]: unknown;
|
||||
globalReturn?: boolean | undefined;
|
||||
jsx?: boolean | undefined;
|
||||
} | undefined;
|
||||
ecmaVersion?: EcmaVersion;
|
||||
emitDecoratorMetadata?: boolean;
|
||||
errorOnTypeScriptSyntacticAndSemanticIssues?: boolean;
|
||||
errorOnUnknownASTType?: boolean;
|
||||
experimentalDecorators?: boolean;
|
||||
extraFileExtensions?: string[];
|
||||
filePath?: string;
|
||||
isolatedDeclarations?: boolean;
|
||||
jsDocParsingMode?: JSDocParsingMode;
|
||||
jsxFragmentName?: string | null;
|
||||
jsxPragma?: string | null;
|
||||
lib?: Lib[];
|
||||
programs?: Program[] | null;
|
||||
project?: boolean | string | string[] | null;
|
||||
projectFolderIgnoreList?: string[];
|
||||
projectService?: boolean | ProjectServiceOptions;
|
||||
range?: boolean;
|
||||
sourceType?: SourceType | undefined;
|
||||
tokens?: boolean;
|
||||
tsconfigRootDir?: string;
|
||||
/**
|
||||
* Controls how the parser reacts when run with a TypeScript version that is
|
||||
* not officially supported by typescript-eslint.
|
||||
* - `'warn'` (default): log a warning to the console.
|
||||
* - `'error'`: throw, causing the lint run to fail. Useful in CI to prevent
|
||||
* unsupported TypeScript versions from being merged unnoticed.
|
||||
* - `'ignore'`: do nothing.
|
||||
*/
|
||||
onUnsupportedTypeScriptVersion?: 'error' | 'ignore' | 'warn';
|
||||
/**
|
||||
* @deprecated Use {@link onUnsupportedTypeScriptVersion} instead.
|
||||
* `true` is equivalent to `'warn'` and `false` is equivalent to `'ignore'`.
|
||||
*/
|
||||
warnOnUnsupportedTypeScriptVersion?: boolean;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Code generated by Herebyfile.mjs generate:enums from internal/ast/modifierflags.go. DO NOT EDIT.
|
||||
export var ModifierFlags;
|
||||
(function (ModifierFlags) {
|
||||
ModifierFlags[ModifierFlags["None"] = 0] = "None";
|
||||
ModifierFlags[ModifierFlags["Public"] = 1] = "Public";
|
||||
ModifierFlags[ModifierFlags["Private"] = 2] = "Private";
|
||||
ModifierFlags[ModifierFlags["Protected"] = 4] = "Protected";
|
||||
ModifierFlags[ModifierFlags["Readonly"] = 8] = "Readonly";
|
||||
ModifierFlags[ModifierFlags["Override"] = 16] = "Override";
|
||||
ModifierFlags[ModifierFlags["Export"] = 32] = "Export";
|
||||
ModifierFlags[ModifierFlags["Abstract"] = 64] = "Abstract";
|
||||
ModifierFlags[ModifierFlags["Ambient"] = 128] = "Ambient";
|
||||
ModifierFlags[ModifierFlags["Static"] = 256] = "Static";
|
||||
ModifierFlags[ModifierFlags["Accessor"] = 512] = "Accessor";
|
||||
ModifierFlags[ModifierFlags["Async"] = 1024] = "Async";
|
||||
ModifierFlags[ModifierFlags["Default"] = 2048] = "Default";
|
||||
ModifierFlags[ModifierFlags["Const"] = 4096] = "Const";
|
||||
ModifierFlags[ModifierFlags["In"] = 8192] = "In";
|
||||
ModifierFlags[ModifierFlags["Out"] = 16384] = "Out";
|
||||
ModifierFlags[ModifierFlags["Decorator"] = 32768] = "Decorator";
|
||||
ModifierFlags[ModifierFlags["Deprecated"] = 65536] = "Deprecated";
|
||||
ModifierFlags[ModifierFlags["JSDocPublic"] = 8388608] = "JSDocPublic";
|
||||
ModifierFlags[ModifierFlags["JSDocPrivate"] = 16777216] = "JSDocPrivate";
|
||||
ModifierFlags[ModifierFlags["JSDocProtected"] = 33554432] = "JSDocProtected";
|
||||
ModifierFlags[ModifierFlags["JSDocReadonly"] = 67108864] = "JSDocReadonly";
|
||||
ModifierFlags[ModifierFlags["JSDocOverride"] = 134217728] = "JSDocOverride";
|
||||
ModifierFlags[ModifierFlags["HasComputedJSDocModifiers"] = 268435456] = "HasComputedJSDocModifiers";
|
||||
ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags";
|
||||
ModifierFlags[ModifierFlags["SyntacticOrJSDocModifiers"] = 31] = "SyntacticOrJSDocModifiers";
|
||||
ModifierFlags[ModifierFlags["SyntacticOnlyModifiers"] = 65504] = "SyntacticOnlyModifiers";
|
||||
ModifierFlags[ModifierFlags["SyntacticModifiers"] = 65535] = "SyntacticModifiers";
|
||||
ModifierFlags[ModifierFlags["JSDocCacheOnlyModifiers"] = 260046848] = "JSDocCacheOnlyModifiers";
|
||||
ModifierFlags[ModifierFlags["JSDocOnlyModifiers"] = 65536] = "JSDocOnlyModifiers";
|
||||
ModifierFlags[ModifierFlags["NonCacheOnlyModifiers"] = 131071] = "NonCacheOnlyModifiers";
|
||||
ModifierFlags[ModifierFlags["AccessibilityModifier"] = 7] = "AccessibilityModifier";
|
||||
ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 31] = "ParameterPropertyModifier";
|
||||
ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 6] = "NonPublicAccessibilityModifier";
|
||||
ModifierFlags[ModifierFlags["TypeScriptModifier"] = 28895] = "TypeScriptModifier";
|
||||
ModifierFlags[ModifierFlags["ExportDefault"] = 2080] = "ExportDefault";
|
||||
ModifierFlags[ModifierFlags["All"] = 131071] = "All";
|
||||
ModifierFlags[ModifierFlags["Modifier"] = 98303] = "Modifier";
|
||||
ModifierFlags[ModifierFlags["JavaScript"] = 3872] = "JavaScript";
|
||||
})(ModifierFlags || (ModifierFlags = {}));
|
||||
//# sourceMappingURL=modifierFlags.js.map
|
||||
@@ -0,0 +1 @@
|
||||
export { _ as default } from "../esm/_ts_generator.js";
|
||||
@@ -0,0 +1,315 @@
|
||||
/**
|
||||
* @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {VisitorKeys}
|
||||
*/
|
||||
const KEYS = {
|
||||
ArrayExpression: [
|
||||
"elements"
|
||||
],
|
||||
ArrayPattern: [
|
||||
"elements"
|
||||
],
|
||||
ArrowFunctionExpression: [
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
AssignmentExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
AssignmentPattern: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
AwaitExpression: [
|
||||
"argument"
|
||||
],
|
||||
BinaryExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
BlockStatement: [
|
||||
"body"
|
||||
],
|
||||
BreakStatement: [
|
||||
"label"
|
||||
],
|
||||
CallExpression: [
|
||||
"callee",
|
||||
"arguments"
|
||||
],
|
||||
CatchClause: [
|
||||
"param",
|
||||
"body"
|
||||
],
|
||||
ChainExpression: [
|
||||
"expression"
|
||||
],
|
||||
ClassBody: [
|
||||
"body"
|
||||
],
|
||||
ClassDeclaration: [
|
||||
"id",
|
||||
"superClass",
|
||||
"body"
|
||||
],
|
||||
ClassExpression: [
|
||||
"id",
|
||||
"superClass",
|
||||
"body"
|
||||
],
|
||||
ConditionalExpression: [
|
||||
"test",
|
||||
"consequent",
|
||||
"alternate"
|
||||
],
|
||||
ContinueStatement: [
|
||||
"label"
|
||||
],
|
||||
DebuggerStatement: [],
|
||||
DoWhileStatement: [
|
||||
"body",
|
||||
"test"
|
||||
],
|
||||
EmptyStatement: [],
|
||||
ExperimentalRestProperty: [
|
||||
"argument"
|
||||
],
|
||||
ExperimentalSpreadProperty: [
|
||||
"argument"
|
||||
],
|
||||
ExportAllDeclaration: [
|
||||
"exported",
|
||||
"source"
|
||||
],
|
||||
ExportDefaultDeclaration: [
|
||||
"declaration"
|
||||
],
|
||||
ExportNamedDeclaration: [
|
||||
"declaration",
|
||||
"specifiers",
|
||||
"source"
|
||||
],
|
||||
ExportSpecifier: [
|
||||
"exported",
|
||||
"local"
|
||||
],
|
||||
ExpressionStatement: [
|
||||
"expression"
|
||||
],
|
||||
ForInStatement: [
|
||||
"left",
|
||||
"right",
|
||||
"body"
|
||||
],
|
||||
ForOfStatement: [
|
||||
"left",
|
||||
"right",
|
||||
"body"
|
||||
],
|
||||
ForStatement: [
|
||||
"init",
|
||||
"test",
|
||||
"update",
|
||||
"body"
|
||||
],
|
||||
FunctionDeclaration: [
|
||||
"id",
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
FunctionExpression: [
|
||||
"id",
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
Identifier: [],
|
||||
IfStatement: [
|
||||
"test",
|
||||
"consequent",
|
||||
"alternate"
|
||||
],
|
||||
ImportDeclaration: [
|
||||
"specifiers",
|
||||
"source"
|
||||
],
|
||||
ImportDefaultSpecifier: [
|
||||
"local"
|
||||
],
|
||||
ImportExpression: [
|
||||
"source"
|
||||
],
|
||||
ImportNamespaceSpecifier: [
|
||||
"local"
|
||||
],
|
||||
ImportSpecifier: [
|
||||
"imported",
|
||||
"local"
|
||||
],
|
||||
JSXAttribute: [
|
||||
"name",
|
||||
"value"
|
||||
],
|
||||
JSXClosingElement: [
|
||||
"name"
|
||||
],
|
||||
JSXClosingFragment: [],
|
||||
JSXElement: [
|
||||
"openingElement",
|
||||
"children",
|
||||
"closingElement"
|
||||
],
|
||||
JSXEmptyExpression: [],
|
||||
JSXExpressionContainer: [
|
||||
"expression"
|
||||
],
|
||||
JSXFragment: [
|
||||
"openingFragment",
|
||||
"children",
|
||||
"closingFragment"
|
||||
],
|
||||
JSXIdentifier: [],
|
||||
JSXMemberExpression: [
|
||||
"object",
|
||||
"property"
|
||||
],
|
||||
JSXNamespacedName: [
|
||||
"namespace",
|
||||
"name"
|
||||
],
|
||||
JSXOpeningElement: [
|
||||
"name",
|
||||
"attributes"
|
||||
],
|
||||
JSXOpeningFragment: [],
|
||||
JSXSpreadAttribute: [
|
||||
"argument"
|
||||
],
|
||||
JSXSpreadChild: [
|
||||
"expression"
|
||||
],
|
||||
JSXText: [],
|
||||
LabeledStatement: [
|
||||
"label",
|
||||
"body"
|
||||
],
|
||||
Literal: [],
|
||||
LogicalExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
MemberExpression: [
|
||||
"object",
|
||||
"property"
|
||||
],
|
||||
MetaProperty: [
|
||||
"meta",
|
||||
"property"
|
||||
],
|
||||
MethodDefinition: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
NewExpression: [
|
||||
"callee",
|
||||
"arguments"
|
||||
],
|
||||
ObjectExpression: [
|
||||
"properties"
|
||||
],
|
||||
ObjectPattern: [
|
||||
"properties"
|
||||
],
|
||||
PrivateIdentifier: [],
|
||||
Program: [
|
||||
"body"
|
||||
],
|
||||
Property: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
PropertyDefinition: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
RestElement: [
|
||||
"argument"
|
||||
],
|
||||
ReturnStatement: [
|
||||
"argument"
|
||||
],
|
||||
SequenceExpression: [
|
||||
"expressions"
|
||||
],
|
||||
SpreadElement: [
|
||||
"argument"
|
||||
],
|
||||
StaticBlock: [
|
||||
"body"
|
||||
],
|
||||
Super: [],
|
||||
SwitchCase: [
|
||||
"test",
|
||||
"consequent"
|
||||
],
|
||||
SwitchStatement: [
|
||||
"discriminant",
|
||||
"cases"
|
||||
],
|
||||
TaggedTemplateExpression: [
|
||||
"tag",
|
||||
"quasi"
|
||||
],
|
||||
TemplateElement: [],
|
||||
TemplateLiteral: [
|
||||
"quasis",
|
||||
"expressions"
|
||||
],
|
||||
ThisExpression: [],
|
||||
ThrowStatement: [
|
||||
"argument"
|
||||
],
|
||||
TryStatement: [
|
||||
"block",
|
||||
"handler",
|
||||
"finalizer"
|
||||
],
|
||||
UnaryExpression: [
|
||||
"argument"
|
||||
],
|
||||
UpdateExpression: [
|
||||
"argument"
|
||||
],
|
||||
VariableDeclaration: [
|
||||
"declarations"
|
||||
],
|
||||
VariableDeclarator: [
|
||||
"id",
|
||||
"init"
|
||||
],
|
||||
WhileStatement: [
|
||||
"test",
|
||||
"body"
|
||||
],
|
||||
WithStatement: [
|
||||
"object",
|
||||
"body"
|
||||
],
|
||||
YieldExpression: [
|
||||
"argument"
|
||||
]
|
||||
};
|
||||
|
||||
// Types.
|
||||
const NODE_TYPES = Object.keys(KEYS);
|
||||
|
||||
// Freeze the keys.
|
||||
for (const type of NODE_TYPES) {
|
||||
Object.freeze(KEYS[type]);
|
||||
}
|
||||
Object.freeze(KEYS);
|
||||
|
||||
export default KEYS;
|
||||
@@ -0,0 +1 @@
|
||||
declare var global: NodeJS.Global & typeof globalThis;
|
||||
@@ -0,0 +1,75 @@
|
||||
let p = process || {}, argv = p.argv || [], env = p.env || {}
|
||||
let isColorSupported =
|
||||
!(!!env.NO_COLOR || argv.includes("--no-color")) &&
|
||||
(!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || ((p.stdout || {}).isTTY && env.TERM !== "dumb") || !!env.CI)
|
||||
|
||||
let formatter = (open, close, replace = open) =>
|
||||
input => {
|
||||
let string = "" + input, index = string.indexOf(close, open.length)
|
||||
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close
|
||||
}
|
||||
|
||||
let replaceClose = (string, close, replace, index) => {
|
||||
let result = "", cursor = 0
|
||||
do {
|
||||
result += string.substring(cursor, index) + replace
|
||||
cursor = index + close.length
|
||||
index = string.indexOf(close, cursor)
|
||||
} while (~index)
|
||||
return result + string.substring(cursor)
|
||||
}
|
||||
|
||||
let createColors = (enabled = isColorSupported) => {
|
||||
let f = enabled ? formatter : () => String
|
||||
return {
|
||||
isColorSupported: enabled,
|
||||
reset: f("\x1b[0m", "\x1b[0m"),
|
||||
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
||||
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
||||
italic: f("\x1b[3m", "\x1b[23m"),
|
||||
underline: f("\x1b[4m", "\x1b[24m"),
|
||||
inverse: f("\x1b[7m", "\x1b[27m"),
|
||||
hidden: f("\x1b[8m", "\x1b[28m"),
|
||||
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
||||
|
||||
black: f("\x1b[30m", "\x1b[39m"),
|
||||
red: f("\x1b[31m", "\x1b[39m"),
|
||||
green: f("\x1b[32m", "\x1b[39m"),
|
||||
yellow: f("\x1b[33m", "\x1b[39m"),
|
||||
blue: f("\x1b[34m", "\x1b[39m"),
|
||||
magenta: f("\x1b[35m", "\x1b[39m"),
|
||||
cyan: f("\x1b[36m", "\x1b[39m"),
|
||||
white: f("\x1b[37m", "\x1b[39m"),
|
||||
gray: f("\x1b[90m", "\x1b[39m"),
|
||||
|
||||
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
||||
bgRed: f("\x1b[41m", "\x1b[49m"),
|
||||
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
||||
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
||||
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
||||
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
||||
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
||||
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
||||
|
||||
blackBright: f("\x1b[90m", "\x1b[39m"),
|
||||
redBright: f("\x1b[91m", "\x1b[39m"),
|
||||
greenBright: f("\x1b[92m", "\x1b[39m"),
|
||||
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
||||
blueBright: f("\x1b[94m", "\x1b[39m"),
|
||||
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
||||
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
||||
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
||||
|
||||
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
||||
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
||||
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
||||
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
||||
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
||||
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
||||
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
||||
bgWhiteBright: f("\x1b[107m", "\x1b[49m"),
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = createColors()
|
||||
module.exports.createColors = createColors
|
||||
@@ -0,0 +1,289 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.StreamMessageWriter = exports.StreamMessageReader = exports.SocketMessageWriter = exports.SocketMessageReader = exports.PortMessageWriter = exports.PortMessageReader = exports.IPCMessageWriter = exports.IPCMessageReader = void 0;
|
||||
exports.generateRandomPipeName = generateRandomPipeName;
|
||||
exports.createClientPipeTransport = createClientPipeTransport;
|
||||
exports.createServerPipeTransport = createServerPipeTransport;
|
||||
exports.createClientSocketTransport = createClientSocketTransport;
|
||||
exports.createServerSocketTransport = createServerSocketTransport;
|
||||
exports.createMessageConnection = createMessageConnection;
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
* ----------------------------------------------------------------------------------------- */
|
||||
const ril_1 = __importDefault(require("./ril"));
|
||||
// Install the node runtime abstract.
|
||||
ril_1.default.install();
|
||||
const path = __importStar(require("path"));
|
||||
const os = __importStar(require("os"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const crypto_1 = require("crypto");
|
||||
const net_1 = require("net");
|
||||
const api_1 = require("../common/api");
|
||||
__exportStar(require("../common/api"), exports);
|
||||
class IPCMessageReader extends api_1.AbstractMessageReader {
|
||||
process;
|
||||
constructor(process) {
|
||||
super();
|
||||
this.process = process;
|
||||
const eventEmitter = this.process;
|
||||
eventEmitter.on('error', (error) => this.fireError(error));
|
||||
eventEmitter.on('close', () => this.fireClose());
|
||||
}
|
||||
listen(callback) {
|
||||
this.process.on('message', callback);
|
||||
return api_1.Disposable.create(() => this.process.off('message', callback));
|
||||
}
|
||||
}
|
||||
exports.IPCMessageReader = IPCMessageReader;
|
||||
class IPCMessageWriter extends api_1.AbstractMessageWriter {
|
||||
process;
|
||||
errorCount;
|
||||
constructor(process) {
|
||||
super();
|
||||
this.process = process;
|
||||
this.errorCount = 0;
|
||||
const eventEmitter = this.process;
|
||||
eventEmitter.on('error', (error) => this.fireError(error));
|
||||
eventEmitter.on('close', () => this.fireClose);
|
||||
}
|
||||
write(msg) {
|
||||
try {
|
||||
if (typeof this.process.send === 'function') {
|
||||
this.process.send(msg, undefined, undefined, (error) => {
|
||||
if (error) {
|
||||
this.errorCount++;
|
||||
this.handleError(error, msg);
|
||||
}
|
||||
else {
|
||||
this.errorCount = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
catch (error) {
|
||||
this.handleError(error, msg);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
handleError(error, msg) {
|
||||
this.errorCount++;
|
||||
this.fireError(error, msg, this.errorCount);
|
||||
}
|
||||
end() {
|
||||
}
|
||||
}
|
||||
exports.IPCMessageWriter = IPCMessageWriter;
|
||||
class PortMessageReader extends api_1.AbstractMessageReader {
|
||||
onData;
|
||||
constructor(port) {
|
||||
super();
|
||||
this.onData = new api_1.Emitter;
|
||||
port.on('close', () => this.fireClose);
|
||||
port.on('error', (error) => this.fireError(error));
|
||||
port.on('message', (message) => {
|
||||
this.onData.fire(message);
|
||||
});
|
||||
}
|
||||
listen(callback) {
|
||||
return this.onData.event(callback);
|
||||
}
|
||||
}
|
||||
exports.PortMessageReader = PortMessageReader;
|
||||
class PortMessageWriter extends api_1.AbstractMessageWriter {
|
||||
port;
|
||||
errorCount;
|
||||
constructor(port) {
|
||||
super();
|
||||
this.port = port;
|
||||
this.errorCount = 0;
|
||||
port.on('close', () => this.fireClose());
|
||||
port.on('error', (error) => this.fireError(error));
|
||||
}
|
||||
write(msg) {
|
||||
try {
|
||||
this.port.postMessage(msg);
|
||||
return Promise.resolve();
|
||||
}
|
||||
catch (error) {
|
||||
this.handleError(error, msg);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
handleError(error, msg) {
|
||||
this.errorCount++;
|
||||
this.fireError(error, msg, this.errorCount);
|
||||
}
|
||||
end() {
|
||||
}
|
||||
}
|
||||
exports.PortMessageWriter = PortMessageWriter;
|
||||
class SocketMessageReader extends api_1.ReadableStreamMessageReader {
|
||||
constructor(socket, encoding = 'utf-8') {
|
||||
super((0, ril_1.default)().stream.asReadableStream(socket), encoding);
|
||||
}
|
||||
}
|
||||
exports.SocketMessageReader = SocketMessageReader;
|
||||
class SocketMessageWriter extends api_1.WriteableStreamMessageWriter {
|
||||
socket;
|
||||
constructor(socket, options) {
|
||||
super((0, ril_1.default)().stream.asWritableStream(socket), options);
|
||||
this.socket = socket;
|
||||
}
|
||||
dispose() {
|
||||
super.dispose();
|
||||
this.socket.destroy();
|
||||
}
|
||||
}
|
||||
exports.SocketMessageWriter = SocketMessageWriter;
|
||||
class StreamMessageReader extends api_1.ReadableStreamMessageReader {
|
||||
constructor(readable, encoding) {
|
||||
super((0, ril_1.default)().stream.asReadableStream(readable), encoding);
|
||||
}
|
||||
}
|
||||
exports.StreamMessageReader = StreamMessageReader;
|
||||
class StreamMessageWriter extends api_1.WriteableStreamMessageWriter {
|
||||
constructor(writable, options) {
|
||||
super((0, ril_1.default)().stream.asWritableStream(writable), options);
|
||||
}
|
||||
}
|
||||
exports.StreamMessageWriter = StreamMessageWriter;
|
||||
const XDG_RUNTIME_DIR = process.env['XDG_RUNTIME_DIR'];
|
||||
const safeIpcPathLengths = new Map([
|
||||
['linux', 107],
|
||||
['darwin', 103]
|
||||
]);
|
||||
function generateRandomPipeName() {
|
||||
if (process.platform === 'win32') {
|
||||
return `\\\\.\\pipe\\lsp-${(0, crypto_1.randomBytes)(16).toString('hex')}-sock`;
|
||||
}
|
||||
let randomLength = 32;
|
||||
const fixedLength = '/lsp-.sock'.length;
|
||||
const tmpDir = fs.realpathSync(XDG_RUNTIME_DIR ?? os.tmpdir());
|
||||
const limit = safeIpcPathLengths.get(process.platform);
|
||||
if (limit !== undefined) {
|
||||
randomLength = Math.min(limit - tmpDir.length - fixedLength, randomLength);
|
||||
}
|
||||
if (randomLength < 16) {
|
||||
throw new Error(`Unable to generate a random pipe name with ${randomLength} characters.`);
|
||||
}
|
||||
const randomSuffix = (0, crypto_1.randomBytes)(Math.floor(randomLength / 2)).toString('hex');
|
||||
return path.join(tmpDir, `lsp-${randomSuffix}.sock`);
|
||||
}
|
||||
function createClientPipeTransport(pipeName, encoding = 'utf-8') {
|
||||
let connectResolve;
|
||||
const connected = new Promise((resolve, _reject) => {
|
||||
connectResolve = resolve;
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
const server = (0, net_1.createServer)((socket) => {
|
||||
server.close();
|
||||
connectResolve([
|
||||
new SocketMessageReader(socket, encoding),
|
||||
new SocketMessageWriter(socket, encoding)
|
||||
]);
|
||||
});
|
||||
server.on('error', reject);
|
||||
server.listen(pipeName, () => {
|
||||
server.removeListener('error', reject);
|
||||
resolve({
|
||||
onConnected: () => { return connected; }
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
function createServerPipeTransport(pipeName, encoding = 'utf-8') {
|
||||
const socket = (0, net_1.createConnection)(pipeName);
|
||||
return [
|
||||
new SocketMessageReader(socket, encoding),
|
||||
new SocketMessageWriter(socket, encoding)
|
||||
];
|
||||
}
|
||||
function createClientSocketTransport(port, encoding = 'utf-8') {
|
||||
let connectResolve;
|
||||
const connected = new Promise((resolve, _reject) => {
|
||||
connectResolve = resolve;
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
const server = (0, net_1.createServer)((socket) => {
|
||||
server.close();
|
||||
connectResolve([
|
||||
new SocketMessageReader(socket, encoding),
|
||||
new SocketMessageWriter(socket, encoding)
|
||||
]);
|
||||
});
|
||||
server.on('error', reject);
|
||||
server.listen(port, '127.0.0.1', () => {
|
||||
server.removeListener('error', reject);
|
||||
resolve({
|
||||
onConnected: () => { return connected; }
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
function createServerSocketTransport(port, encoding = 'utf-8') {
|
||||
const socket = (0, net_1.createConnection)(port, '127.0.0.1');
|
||||
return [
|
||||
new SocketMessageReader(socket, encoding),
|
||||
new SocketMessageWriter(socket, encoding)
|
||||
];
|
||||
}
|
||||
function isReadableStream(value) {
|
||||
const candidate = value;
|
||||
return candidate.read !== undefined && candidate.addListener !== undefined;
|
||||
}
|
||||
function isWritableStream(value) {
|
||||
const candidate = value;
|
||||
return candidate.write !== undefined && candidate.addListener !== undefined;
|
||||
}
|
||||
function createMessageConnection(input, output, logger, options) {
|
||||
if (!logger) {
|
||||
logger = api_1.NullLogger;
|
||||
}
|
||||
const reader = isReadableStream(input) ? new StreamMessageReader(input) : input;
|
||||
const writer = isWritableStream(output) ? new StreamMessageWriter(output) : output;
|
||||
if (api_1.ConnectionStrategy.is(options)) {
|
||||
options = { connectionStrategy: options };
|
||||
}
|
||||
return (0, api_1.createMessageConnection)(reader, writer, logger, options);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import {secp256k1} from '@noble/curves/secp256k1';
|
||||
|
||||
export const ecdsaSign = (
|
||||
msgHash: Parameters<typeof secp256k1.sign>[0],
|
||||
privKey: Parameters<typeof secp256k1.sign>[1],
|
||||
) => {
|
||||
const signature = secp256k1.sign(msgHash, privKey);
|
||||
return [signature.toCompactRawBytes(), signature.recovery!] as const;
|
||||
};
|
||||
export const isValidPrivateKey = secp256k1.utils.isValidPrivateKey;
|
||||
export const publicKeyCreate = secp256k1.getPublicKey;
|
||||
@@ -0,0 +1,30 @@
|
||||
import * as core from "../core/index.js";
|
||||
import { $ZodError } from "../core/index.js";
|
||||
/** @deprecated Use `z.core.$ZodIssue` from `@zod/core` instead, especially if you are building a library on top of Zod. */
|
||||
export type ZodIssue = core.$ZodIssue;
|
||||
/** An Error-like class used to store Zod validation issues. */
|
||||
export interface ZodError<T = unknown> extends $ZodError<T> {
|
||||
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
||||
format(): core.$ZodFormattedError<T>;
|
||||
format<U>(mapper: (issue: core.$ZodIssue) => U): core.$ZodFormattedError<T, U>;
|
||||
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
||||
flatten(): core.$ZodFlattenedError<T>;
|
||||
flatten<U>(mapper: (issue: core.$ZodIssue) => U): core.$ZodFlattenedError<T, U>;
|
||||
/** @deprecated Push directly to `.issues` instead. */
|
||||
addIssue(issue: core.$ZodIssue): void;
|
||||
/** @deprecated Push directly to `.issues` instead. */
|
||||
addIssues(issues: core.$ZodIssue[]): void;
|
||||
/** @deprecated Check `err.issues.length === 0` instead. */
|
||||
isEmpty: boolean;
|
||||
}
|
||||
export declare const ZodError: core.$constructor<ZodError>;
|
||||
export declare const ZodRealError: core.$constructor<ZodError>;
|
||||
export type {
|
||||
/** @deprecated Use `z.core.$ZodFlattenedError` instead. */
|
||||
$ZodFlattenedError as ZodFlattenedError,
|
||||
/** @deprecated Use `z.core.$ZodFormattedError` instead. */
|
||||
$ZodFormattedError as ZodFormattedError,
|
||||
/** @deprecated Use `z.core.$ZodErrorMap` instead. */
|
||||
$ZodErrorMap as ZodErrorMap, } from "../core/index.js";
|
||||
/** @deprecated Use `z.core.$ZodRawIssue` instead. */
|
||||
export type IssueData = core.$ZodRawIssue;
|
||||
@@ -0,0 +1,2 @@
|
||||
import { PredefinedFormats } from './enums';
|
||||
export declare const PredefinedFormatToCheckFunction: Readonly<Record<PredefinedFormats, (name: string) => boolean>>;
|
||||
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// RUN THE FOLLOWING COMMAND FROM THE WORKSPACE ROOT TO REGENERATE:
|
||||
// npx nx generate-lib repo
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.es2019_symbol = void 0;
|
||||
const base_config_1 = require("./base-config");
|
||||
exports.es2019_symbol = {
|
||||
libs: [],
|
||||
variables: [['Symbol', base_config_1.TYPE]],
|
||||
};
|
||||
@@ -0,0 +1,365 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import events = require("events");
|
||||
import stream = require("stream");
|
||||
import pgTypes = require("pg-types");
|
||||
import { NoticeMessage } from "pg-protocol/dist/messages.js";
|
||||
|
||||
import { ConnectionOptions } from "tls";
|
||||
|
||||
export type QueryConfigValues<T> = T extends Array<infer U> ? T : never;
|
||||
|
||||
export interface ClientConfig {
|
||||
user?: string | undefined;
|
||||
database?: string | undefined;
|
||||
password?: string | (() => string | Promise<string>) | undefined;
|
||||
port?: number | undefined;
|
||||
host?: string | undefined;
|
||||
connectionString?: string | undefined;
|
||||
keepAlive?: boolean | undefined;
|
||||
stream?: () => stream.Duplex | undefined;
|
||||
statement_timeout?: false | number | undefined;
|
||||
ssl?: boolean | ConnectionOptions | undefined;
|
||||
query_timeout?: number | undefined;
|
||||
lock_timeout?: number | undefined;
|
||||
keepAliveInitialDelayMillis?: number | undefined;
|
||||
idle_in_transaction_session_timeout?: number | undefined;
|
||||
application_name?: string | undefined;
|
||||
fallback_application_name?: string | undefined;
|
||||
connectionTimeoutMillis?: number | undefined;
|
||||
types?: CustomTypesConfig | undefined;
|
||||
options?: string | undefined;
|
||||
client_encoding?: string | undefined;
|
||||
}
|
||||
|
||||
export type ConnectionConfig = ClientConfig;
|
||||
|
||||
export interface Defaults extends ClientConfig {
|
||||
poolSize?: number | undefined;
|
||||
poolIdleTimeout?: number | undefined;
|
||||
reapIntervalMillis?: number | undefined;
|
||||
binary?: boolean | undefined;
|
||||
parseInt8?: boolean | undefined;
|
||||
parseInputDatesAsUTC?: boolean | undefined;
|
||||
}
|
||||
|
||||
export interface PoolConfig extends ClientConfig {
|
||||
// properties from module 'pg-pool'
|
||||
max?: number | undefined;
|
||||
min?: number | undefined;
|
||||
idleTimeoutMillis?: number | undefined | null;
|
||||
log?: ((...messages: any[]) => void) | undefined;
|
||||
Promise?: PromiseConstructorLike | undefined;
|
||||
allowExitOnIdle?: boolean | undefined;
|
||||
maxUses?: number | undefined;
|
||||
maxLifetimeSeconds?: number | undefined;
|
||||
Client?: (new() => ClientBase) | undefined;
|
||||
onConnect?: ((client: ClientBase) => void) | undefined;
|
||||
verify?: ((client: PoolClient, done: (err?: Error) => void) => void) | undefined;
|
||||
}
|
||||
|
||||
export interface QueryConfig<I = any[]> {
|
||||
name?: string | undefined;
|
||||
text: string;
|
||||
values?: QueryConfigValues<I>;
|
||||
types?: CustomTypesConfig | undefined;
|
||||
}
|
||||
|
||||
export interface CustomTypesConfig {
|
||||
getTypeParser: typeof pgTypes.getTypeParser;
|
||||
}
|
||||
|
||||
export interface Submittable {
|
||||
submit: (connection: Connection) => void;
|
||||
}
|
||||
|
||||
export interface QueryArrayConfig<I = any[]> extends QueryConfig<I> {
|
||||
rowMode: "array";
|
||||
}
|
||||
|
||||
export interface FieldDef {
|
||||
name: string;
|
||||
tableID: number;
|
||||
columnID: number;
|
||||
dataTypeID: number;
|
||||
dataTypeSize: number;
|
||||
dataTypeModifier: number;
|
||||
format: string;
|
||||
}
|
||||
|
||||
export interface QueryResultBase {
|
||||
command: string;
|
||||
rowCount: number | null;
|
||||
oid: number;
|
||||
fields: FieldDef[];
|
||||
}
|
||||
|
||||
export interface QueryResultRow {
|
||||
[column: string]: any;
|
||||
}
|
||||
|
||||
export interface QueryResult<R extends QueryResultRow = any> extends QueryResultBase {
|
||||
rows: R[];
|
||||
}
|
||||
|
||||
export interface QueryArrayResult<R extends any[] = any[]> extends QueryResultBase {
|
||||
rows: R[];
|
||||
}
|
||||
|
||||
export interface Notification {
|
||||
processId: number;
|
||||
channel: string;
|
||||
payload?: string | undefined;
|
||||
}
|
||||
|
||||
export interface ResultBuilder<R extends QueryResultRow = any> extends QueryResult<R> {
|
||||
addRow(row: R): void;
|
||||
}
|
||||
|
||||
export interface QueryParse {
|
||||
name: string;
|
||||
text: string;
|
||||
types: string[];
|
||||
}
|
||||
|
||||
type ValueMapper = (param: any, index: number) => any;
|
||||
|
||||
export type TransactionStatus = "I" | "T" | "E" | null;
|
||||
|
||||
export interface BindConfig {
|
||||
portal?: string | undefined;
|
||||
statement?: string | undefined;
|
||||
binary?: string | undefined;
|
||||
values?: Array<Buffer | null | undefined | string> | undefined;
|
||||
valueMapper?: ValueMapper | undefined;
|
||||
}
|
||||
|
||||
export interface ExecuteConfig {
|
||||
portal?: string | undefined;
|
||||
rows?: string | undefined;
|
||||
}
|
||||
|
||||
export interface MessageConfig {
|
||||
type: string;
|
||||
name?: string | undefined;
|
||||
}
|
||||
|
||||
export function escapeIdentifier(str: string): string;
|
||||
|
||||
export function escapeLiteral(str: string): string;
|
||||
|
||||
export class Connection extends events.EventEmitter {
|
||||
readonly stream: stream.Duplex;
|
||||
|
||||
constructor(config?: ConnectionConfig);
|
||||
|
||||
bind(config: BindConfig | null, more: boolean): void;
|
||||
execute(config: ExecuteConfig | null, more: boolean): void;
|
||||
parse(query: QueryParse, more: boolean): void;
|
||||
|
||||
query(text: string): void;
|
||||
|
||||
describe(msg: MessageConfig, more: boolean): void;
|
||||
close(msg: MessageConfig, more: boolean): void;
|
||||
|
||||
flush(): void;
|
||||
sync(): void;
|
||||
end(): void;
|
||||
}
|
||||
|
||||
export interface PoolOptions extends PoolConfig {
|
||||
max: number;
|
||||
maxUses: number;
|
||||
allowExitOnIdle: boolean;
|
||||
maxLifetimeSeconds: number;
|
||||
idleTimeoutMillis: number | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link https://node-postgres.com/apis/pool}
|
||||
*/
|
||||
export class Pool extends events.EventEmitter {
|
||||
/**
|
||||
* Every field of the config object is entirely optional.
|
||||
* The config passed to the pool is also passed to every client
|
||||
* instance within the pool when the pool creates that client.
|
||||
*/
|
||||
constructor(config?: PoolConfig);
|
||||
|
||||
readonly totalCount: number;
|
||||
readonly idleCount: number;
|
||||
readonly waitingCount: number;
|
||||
readonly expiredCount: number;
|
||||
|
||||
readonly ending: boolean;
|
||||
readonly ended: boolean;
|
||||
|
||||
options: PoolOptions;
|
||||
|
||||
connect(): Promise<PoolClient>;
|
||||
connect(
|
||||
callback: (err: Error | undefined, client: PoolClient | undefined, done: (release?: any) => void) => void,
|
||||
): void;
|
||||
|
||||
end(): Promise<void>;
|
||||
end(callback: () => void): void;
|
||||
|
||||
query<T extends Submittable>(queryStream: T): T;
|
||||
// tslint:disable:no-unnecessary-generics
|
||||
query<R extends any[] = any[], I = any[]>(
|
||||
queryConfig: QueryArrayConfig<I>,
|
||||
values?: QueryConfigValues<I>,
|
||||
): Promise<QueryArrayResult<R>>;
|
||||
query<R extends QueryResultRow = any, I = any[]>(
|
||||
queryConfig: QueryConfig<I>,
|
||||
): Promise<QueryResult<R>>;
|
||||
query<R extends QueryResultRow = any, I = any[]>(
|
||||
queryTextOrConfig: string | QueryConfig<I>,
|
||||
values?: QueryConfigValues<I>,
|
||||
): Promise<QueryResult<R>>;
|
||||
query<R extends any[] = any[], I = any[]>(
|
||||
queryConfig: QueryArrayConfig<I>,
|
||||
callback: (err: Error, result: QueryArrayResult<R>) => void,
|
||||
): void;
|
||||
query<R extends QueryResultRow = any, I = any[]>(
|
||||
queryTextOrConfig: string | QueryConfig<I>,
|
||||
callback: (err: Error, result: QueryResult<R>) => void,
|
||||
): void;
|
||||
query<R extends QueryResultRow = any, I = any[]>(
|
||||
queryText: string,
|
||||
values: QueryConfigValues<I>,
|
||||
callback: (err: Error, result: QueryResult<R>) => void,
|
||||
): void;
|
||||
// tslint:enable:no-unnecessary-generics
|
||||
|
||||
on<K extends "error" | "release" | "connect" | "acquire" | "remove">(
|
||||
event: K,
|
||||
listener: K extends "error" | "release" ? (err: Error, client: PoolClient) => void
|
||||
: (client: PoolClient) => void,
|
||||
): this;
|
||||
}
|
||||
|
||||
export class ClientBase extends events.EventEmitter {
|
||||
constructor(config?: string | ClientConfig);
|
||||
|
||||
connect(): Promise<ClientBase>;
|
||||
connect(callback: ((err: Error) => void) | ((err: null, c: ClientBase) => void)): void;
|
||||
|
||||
query<T extends Submittable>(queryStream: T): T;
|
||||
// tslint:disable:no-unnecessary-generics
|
||||
query<R extends any[] = any[], I = any[]>(
|
||||
queryConfig: QueryArrayConfig<I>,
|
||||
values?: QueryConfigValues<I>,
|
||||
): Promise<QueryArrayResult<R>>;
|
||||
query<R extends QueryResultRow = any, I = any>(
|
||||
queryConfig: QueryConfig<I>,
|
||||
): Promise<QueryResult<R>>;
|
||||
query<R extends QueryResultRow = any, I = any[]>(
|
||||
queryTextOrConfig: string | QueryConfig<I>,
|
||||
values?: QueryConfigValues<I>,
|
||||
): Promise<QueryResult<R>>;
|
||||
query<R extends any[] = any[], I = any[]>(
|
||||
queryConfig: QueryArrayConfig<I>,
|
||||
callback: (err: Error, result: QueryArrayResult<R>) => void,
|
||||
): void;
|
||||
query<R extends QueryResultRow = any, I = any[]>(
|
||||
queryTextOrConfig: string | QueryConfig<I>,
|
||||
callback: (err: Error, result: QueryResult<R>) => void,
|
||||
): void;
|
||||
query<R extends QueryResultRow = any, I = any[]>(
|
||||
queryText: string,
|
||||
values: QueryConfigValues<I>,
|
||||
callback: (err: Error, result: QueryResult<R>) => void,
|
||||
): void;
|
||||
// tslint:enable:no-unnecessary-generics
|
||||
|
||||
copyFrom(queryText: string): stream.Writable;
|
||||
copyTo(queryText: string): stream.Readable;
|
||||
|
||||
pauseDrain(): void;
|
||||
resumeDrain(): void;
|
||||
|
||||
escapeIdentifier: typeof escapeIdentifier;
|
||||
escapeLiteral: typeof escapeLiteral;
|
||||
setTypeParser: typeof pgTypes.setTypeParser;
|
||||
getTypeParser: typeof pgTypes.getTypeParser;
|
||||
|
||||
getTransactionStatus(): TransactionStatus;
|
||||
|
||||
on<E extends "connect" | "drain" | "error" | "notice" | "notification" | "end">(
|
||||
event: E,
|
||||
listener: E extends "connect" | "drain" | "end" ? () => void
|
||||
: E extends "error" ? (err: Error) => void
|
||||
: E extends "notice" ? (notice: NoticeMessage) => void
|
||||
: (message: Notification) => void,
|
||||
): this;
|
||||
}
|
||||
|
||||
export class Client extends ClientBase {
|
||||
user?: string | undefined;
|
||||
database?: string | undefined;
|
||||
port: number;
|
||||
host: string;
|
||||
password?: string | undefined;
|
||||
ssl: boolean;
|
||||
readonly connection: Connection;
|
||||
|
||||
constructor(config?: string | ClientConfig);
|
||||
|
||||
connect(): Promise<Client>;
|
||||
connect(callback: ((err: Error) => void) | ((err: null, c: Client) => void)): void;
|
||||
|
||||
end(): Promise<void>;
|
||||
end(callback: (err: Error) => void): void;
|
||||
}
|
||||
|
||||
export interface PoolClient extends Client {
|
||||
release(err?: Error | boolean): void;
|
||||
}
|
||||
|
||||
export class Query<R extends QueryResultRow = any, I extends any[] = any> extends events.EventEmitter
|
||||
implements Submittable
|
||||
{
|
||||
constructor(
|
||||
queryTextOrConfig?: string | QueryConfig<I>,
|
||||
callback?: (error: Error | undefined, result: ResultBuilder<R>) => void,
|
||||
);
|
||||
constructor(
|
||||
queryTextOrConfig?: string | QueryConfig<I>,
|
||||
values?: I,
|
||||
callback?: (error: Error | undefined, result: ResultBuilder<R>) => void,
|
||||
);
|
||||
submit: (connection: Connection) => void;
|
||||
on<E extends "row" | "error" | "end">(
|
||||
event: E,
|
||||
listener: E extends "row" ? (row: R, result?: ResultBuilder<R>) => void
|
||||
: E extends "error" ? (err: Error) => void
|
||||
: (result: ResultBuilder<R>) => void,
|
||||
): this;
|
||||
}
|
||||
|
||||
export class Events extends events.EventEmitter {
|
||||
on(event: "error", listener: (err: Error, client: Client) => void): this;
|
||||
}
|
||||
|
||||
export const types: typeof pgTypes;
|
||||
|
||||
export const defaults: Defaults & ClientConfig;
|
||||
|
||||
import * as Pg from ".";
|
||||
|
||||
export const native: typeof Pg | null;
|
||||
|
||||
export { DatabaseError } from "pg-protocol";
|
||||
export { TypeOverrides };
|
||||
import TypeOverrides = require("./lib/type-overrides");
|
||||
|
||||
export class Result<R extends QueryResultRow = any> implements QueryResult<R> {
|
||||
command: string;
|
||||
rowCount: number | null;
|
||||
oid: number;
|
||||
fields: FieldDef[];
|
||||
rows: R[];
|
||||
|
||||
constructor(rowMode: string, t: typeof types);
|
||||
}
|
||||
Reference in New Issue
Block a user