WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
var assertClassBrand = require("./assertClassBrand.js");
|
||||
function _classPrivateFieldGet2(s, a) {
|
||||
return s.get(assertClassBrand(s, a));
|
||||
}
|
||||
module.exports = _classPrivateFieldGet2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"modular.d.ts","sourceRoot":"","sources":["../../src/abstract/modular.ts"],"names":[],"mappings":"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"}
|
||||
@@ -0,0 +1,10 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '6'
|
||||
install: npm install
|
||||
script: npm run test-browsers
|
||||
|
||||
env:
|
||||
global:
|
||||
- secure: dxsYyywaNs56mtg5zSJgA3GTUIzGKt6btJrE0+j0oB/6pwJt2GvPNetd6bCe9ddyvoRA1ZwW/PlL86tsLpSSM4hf3hySw9ozb0dC0wPDPN3rfHyI8sNW7LjcPAxCncVwJ1CQf3kO/NGVgQi4K8HCy0LkOPrQ0NCWhsnUaAtY0IOOdeBYahFoQ2boK6F5RFnK65gIaPdk9PqRiS7B43XPOFOSP/vVQd2AzcrZzMgjit505EF8oozlgMBM6eFQvX4vX1I4OgFuO1owOQBMrS/bvmeURoAt3313UvuMeezq7MgTWABo19WDHMg3KUs2aJO4QxiOiQek9jluKhOmjkNJ08lum5d2s6UnoD3MNoN7mdvy2DsifrzZzDzxjkvEsQ0E15+hyMdPpILBXqIXjXZdIs46TiGlX5No2In0zwfzuAXkJVgpQ7jTkqdvEejDk5Kf4nl01TscZFNMpmq9+gL6xUE95BCHLx8YwYZN9hME98CffSgWQTRGcOd9sI9SC3fgWr7k3GZtuuXMATc2U/cZtuJrClOGTaK0l3FEe9U0d6cf+rZDQh72iBHy4Y1/RERaoM37eOyKg7tngRIevmftnvRRALIeoIb2KAxV5XrxcwxQRumV7jbs8Y5g/gsFnwbJBgcn9a7tez/wQSVQ2/fiQn93OJOQrXHOywk3PV3PX0Y=
|
||||
- secure: Nyatsejgr4rJfqCrhQ9U+mrx1hsGkP4qqZWVsc/MC8RG3XfmKuyJFGwbJAhAlGHiebG2a2PrErvwnr8Veo/QwkuDy5beQ+5KocCuIT/hIsGMIFuRDs0RRPMFPX0j4xQmZr47iCPdSHSh67jrURf/sXlIdCfrX1eYDsNiKfmS/mFAaQKkcnfJu0PO2IRmucHNKgU5jpH2SvVmEK0kxYIG8kkk5A8NUzbqJn3E7kVzZ3zslYT2gRDxSVP7Hb13LR1ZLDStKvAjuZHMckQYF6Wl8+vKja041yDgmh88+L6HoDPigKEGH5vJzaoBdoxT+asdsvDbMkbBVQMLm4RdkHIlRAUNASOfsUSOe9LBFRp6eSJkGRhc5JQxjf8G246dRae8dBIcloRMethGelc7WR4Pdm5u6ByswbfCIHFszIlJLWiq/QM81akHHbWcTUtaaM/8/s4R3luO/d6IL2RyTN9NZfoZmrCb7xF9UAVnlqogkrQ5VKvv+222Nmpa7jPhckJStURAKYi4IulYLWkBXv5uMvpKt8riCBQUft+arHwWOfJsT07ksYy/+K39t45ut1tKBjtInLErd7P/ROjPrsHSdMsdZspey7dpxXt3ePrUry+NgsLPwqOqo9wV+TZA3pBijxH93/C4eHCSOydKJ3+MGr2A+eLLjc3Ky8qG73trYdc=
|
||||
@@ -0,0 +1,3 @@
|
||||
export declare function unsafeStringify(arr: Uint8Array, offset?: number): string;
|
||||
declare function stringify(arr: Uint8Array, offset?: number): string;
|
||||
export default stringify;
|
||||
@@ -0,0 +1,31 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { TlsOptions } from 'cloudflare:sockets';
|
||||
import { EventEmitter } from 'events';
|
||||
/**
|
||||
* Wrapper around the Cloudflare built-in socket that can be used by the `Connection`.
|
||||
*/
|
||||
export declare class CloudflareSocket extends EventEmitter {
|
||||
readonly ssl: boolean;
|
||||
writable: boolean;
|
||||
destroyed: boolean;
|
||||
private _upgrading;
|
||||
private _upgraded;
|
||||
private _cfSocket;
|
||||
private _cfWriter;
|
||||
private _cfReader;
|
||||
constructor(ssl: boolean);
|
||||
setNoDelay(): this;
|
||||
setKeepAlive(): this;
|
||||
ref(): this;
|
||||
unref(): this;
|
||||
connect(port: number, host: string, connectListener?: (...args: unknown[]) => void): Promise<this | undefined>;
|
||||
_listen(): Promise<void>;
|
||||
_listenOnce(): Promise<void>;
|
||||
write(data: Uint8Array | string, encoding?: BufferEncoding, callback?: (...args: unknown[]) => void): true | void;
|
||||
end(data?: Buffer, encoding?: BufferEncoding, callback?: (...args: unknown[]) => void): this;
|
||||
destroy(reason: string): this;
|
||||
startTls(options: TlsOptions): void;
|
||||
_addClosedHandler(): void;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
function _new_arrow_check(innerThis, boundThis) {
|
||||
if (innerThis !== boundThis) throw new TypeError("Cannot instantiate an arrow function");
|
||||
}
|
||||
export { _new_arrow_check as _ };
|
||||
@@ -0,0 +1,137 @@
|
||||
"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 (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: { unit: "belgi", verb: "bo‘lishi kerak" },
|
||||
file: { unit: "bayt", verb: "bo‘lishi kerak" },
|
||||
array: { unit: "element", verb: "bo‘lishi kerak" },
|
||||
set: { unit: "element", verb: "bo‘lishi kerak" },
|
||||
map: { unit: "yozuv", verb: "bo‘lishi kerak" },
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "kirish",
|
||||
email: "elektron pochta manzili",
|
||||
url: "URL",
|
||||
emoji: "emoji",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO sana va vaqti",
|
||||
date: "ISO sana",
|
||||
time: "ISO vaqt",
|
||||
duration: "ISO davomiylik",
|
||||
ipv4: "IPv4 manzil",
|
||||
ipv6: "IPv6 manzil",
|
||||
mac: "MAC manzil",
|
||||
cidrv4: "IPv4 diapazon",
|
||||
cidrv6: "IPv6 diapazon",
|
||||
base64: "base64 kodlangan satr",
|
||||
base64url: "base64url kodlangan satr",
|
||||
json_string: "JSON satr",
|
||||
e164: "E.164 raqam",
|
||||
jwt: "JWT",
|
||||
template_literal: "kirish",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "raqam",
|
||||
array: "massiv",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Noto‘g‘ri kirish: kutilgan instanceof ${issue.expected}, qabul qilingan ${received}`;
|
||||
}
|
||||
return `Noto‘g‘ri kirish: kutilgan ${expected}, qabul qilingan ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Noto‘g‘ri kirish: kutilgan ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Noto‘g‘ri variant: quyidagilardan biri kutilgan ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing)
|
||||
return `Juda katta: kutilgan ${issue.origin ?? "qiymat"} ${adj}${issue.maximum.toString()} ${sizing.unit} ${sizing.verb}`;
|
||||
return `Juda katta: kutilgan ${issue.origin ?? "qiymat"} ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
return `Juda kichik: kutilgan ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} ${sizing.verb}`;
|
||||
}
|
||||
return `Juda kichik: kutilgan ${issue.origin} ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Noto‘g‘ri satr: "${_issue.prefix}" bilan boshlanishi kerak`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Noto‘g‘ri satr: "${_issue.suffix}" bilan tugashi kerak`;
|
||||
if (_issue.format === "includes")
|
||||
return `Noto‘g‘ri satr: "${_issue.includes}" ni o‘z ichiga olishi kerak`;
|
||||
if (_issue.format === "regex")
|
||||
return `Noto‘g‘ri satr: ${_issue.pattern} shabloniga mos kelishi kerak`;
|
||||
return `Noto‘g‘ri ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Noto‘g‘ri raqam: ${issue.divisor} ning karralisi bo‘lishi kerak`;
|
||||
case "unrecognized_keys":
|
||||
return `Noma’lum kalit${issue.keys.length > 1 ? "lar" : ""}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `${issue.origin} dagi kalit noto‘g‘ri`;
|
||||
case "invalid_union":
|
||||
return "Noto‘g‘ri kirish";
|
||||
case "invalid_element":
|
||||
return `${issue.origin} da noto‘g‘ri qiymat`;
|
||||
default:
|
||||
return `Noto‘g‘ri kirish`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
@@ -0,0 +1,4 @@
|
||||
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"regExpExecOverStringMatch", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
||||
name: string;
|
||||
};
|
||||
export default _default;
|
||||
@@ -0,0 +1,27 @@
|
||||
interface Result {
|
||||
name: "AssertionError" | "AssertionResult";
|
||||
ok: boolean;
|
||||
toJSON(...args: unknown[]): Record<string, unknown>;
|
||||
}
|
||||
|
||||
declare class AssertionError<T> extends Error implements Result {
|
||||
[key: string]: unknown
|
||||
name: "AssertionError";
|
||||
ok: false;
|
||||
message: string;
|
||||
// deno-lint-ignore ban-types
|
||||
constructor(message: string, props?: T, ssf?: Function);
|
||||
stack: string;
|
||||
toJSON(stack?: boolean): Record<string, unknown>;
|
||||
}
|
||||
|
||||
declare class AssertionResult<T> implements Result {
|
||||
[key: string]: unknown
|
||||
name: "AssertionResult";
|
||||
ok: true;
|
||||
message: string;
|
||||
constructor(props?: T);
|
||||
toJSON(): Record<string, unknown>;
|
||||
}
|
||||
|
||||
export { AssertionError, AssertionResult, Result };
|
||||
@@ -0,0 +1,56 @@
|
||||
import * as pg from "./index.js";
|
||||
|
||||
declare const PG: {
|
||||
defaults: typeof pg.defaults;
|
||||
Client: typeof pg.Client;
|
||||
ClientBase: typeof pg.ClientBase;
|
||||
Events: typeof pg.Events;
|
||||
Query: typeof pg.Query;
|
||||
Pool: typeof pg.Pool;
|
||||
Connection: typeof pg.Connection;
|
||||
types: typeof pg.types;
|
||||
DatabaseError: typeof pg.DatabaseError;
|
||||
TypeOverrides: typeof pg.TypeOverrides;
|
||||
escapeIdentifier: typeof pg.escapeIdentifier;
|
||||
escapeLiteral: typeof pg.escapeLiteral;
|
||||
Result: typeof pg.Result;
|
||||
native: typeof pg.native;
|
||||
};
|
||||
|
||||
declare namespace PG {
|
||||
type QueryConfigValues<T> = pg.QueryConfigValues<T>;
|
||||
type ClientConfig = pg.ClientConfig;
|
||||
type ConnectionConfig = pg.ConnectionConfig;
|
||||
type Defaults = pg.Defaults;
|
||||
type PoolConfig = pg.PoolConfig;
|
||||
type QueryConfig<I = any[]> = pg.QueryConfig<I>;
|
||||
type CustomTypesConfig = pg.CustomTypesConfig;
|
||||
type Submittable = pg.Submittable;
|
||||
type QueryArrayConfig<I = any[]> = pg.QueryArrayConfig<I>;
|
||||
type FieldDef = pg.FieldDef;
|
||||
type QueryResultBase = pg.QueryResultBase;
|
||||
type QueryResultRow = pg.QueryResultRow;
|
||||
type QueryResult<R extends QueryResultRow = any> = pg.QueryResult<R>;
|
||||
type QueryArrayResult<R extends any[] = any[]> = pg.QueryArrayResult<R>;
|
||||
type Notification = pg.Notification;
|
||||
type ResultBuilder<R extends QueryResultRow = any> = pg.ResultBuilder<R>;
|
||||
type QueryParse = pg.QueryParse;
|
||||
type BindConfig = pg.BindConfig;
|
||||
type ExecuteConfig = pg.ExecuteConfig;
|
||||
type MessageConfig = pg.MessageConfig;
|
||||
type PoolOptions = pg.PoolOptions;
|
||||
type PoolClient = pg.PoolClient;
|
||||
|
||||
type ClientBase = pg.ClientBase;
|
||||
type Client = pg.Client;
|
||||
type Query = pg.Query;
|
||||
type Events = pg.Events;
|
||||
type Pool = pg.Pool;
|
||||
type Connection = pg.Connection;
|
||||
type DatabaseError = pg.DatabaseError;
|
||||
type TypeOverrides = pg.TypeOverrides;
|
||||
type Result = pg.Result;
|
||||
}
|
||||
|
||||
export * from "./index.js";
|
||||
export default PG;
|
||||
@@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = _default;
|
||||
exports.URL = exports.DNS = void 0;
|
||||
|
||||
var _stringify = _interopRequireDefault(require("./stringify.js"));
|
||||
|
||||
var _parse = _interopRequireDefault(require("./parse.js"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function stringToBytes(str) {
|
||||
str = unescape(encodeURIComponent(str)); // UTF8 escape
|
||||
|
||||
const bytes = [];
|
||||
|
||||
for (let i = 0; i < str.length; ++i) {
|
||||
bytes.push(str.charCodeAt(i));
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
||||
exports.DNS = DNS;
|
||||
const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
||||
exports.URL = URL;
|
||||
|
||||
function _default(name, version, hashfunc) {
|
||||
function generateUUID(value, namespace, buf, offset) {
|
||||
if (typeof value === 'string') {
|
||||
value = stringToBytes(value);
|
||||
}
|
||||
|
||||
if (typeof namespace === 'string') {
|
||||
namespace = (0, _parse.default)(namespace);
|
||||
}
|
||||
|
||||
if (namespace.length !== 16) {
|
||||
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
||||
} // Compute hash of namespace and value, Per 4.3
|
||||
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
|
||||
// hashfunc([...namespace, ... value])`
|
||||
|
||||
|
||||
let bytes = new Uint8Array(16 + value.length);
|
||||
bytes.set(namespace);
|
||||
bytes.set(value, namespace.length);
|
||||
bytes = hashfunc(bytes);
|
||||
bytes[6] = bytes[6] & 0x0f | version;
|
||||
bytes[8] = bytes[8] & 0x3f | 0x80;
|
||||
|
||||
if (buf) {
|
||||
offset = offset || 0;
|
||||
|
||||
for (let i = 0; i < 16; ++i) {
|
||||
buf[offset + i] = bytes[i];
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
return (0, _stringify.default)(bytes);
|
||||
} // Function#name is not settable on some platforms (#270)
|
||||
|
||||
|
||||
try {
|
||||
generateUUID.name = name; // eslint-disable-next-line no-empty
|
||||
} catch (err) {} // For CommonJS default export support
|
||||
|
||||
|
||||
generateUUID.DNS = DNS;
|
||||
generateUUID.URL = URL;
|
||||
return generateUUID;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).EventEmitter3=t()}(this,function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t,n={exports:{}};var r=(t||(t=1,function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new o(r,s||e,i),f=n?n+t:t;return e._events[f]?e._events[f].fn?e._events[f]=[e._events[f],c]:e._events[f].push(c):(e._events[f]=c,e._eventsCount++),e}function i(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function c(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),c.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},c.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i},c.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,o,s,i){var c=n?n+e:e;if(!this._events[c])return!1;var f,u,a=this._events[c],l=arguments.length;if(a.fn){switch(a.once&&this.removeListener(e,a.fn,void 0,!0),l){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,t),!0;case 3:return a.fn.call(a.context,t,r),!0;case 4:return a.fn.call(a.context,t,r,o),!0;case 5:return a.fn.call(a.context,t,r,o,s),!0;case 6:return a.fn.call(a.context,t,r,o,s,i),!0}for(u=1,f=new Array(l-1);u<l;u++)f[u-1]=arguments[u];a.fn.apply(a.context,f)}else{var p,v=a.length;for(u=0;u<v;u++)switch(a[u].once&&this.removeListener(e,a[u].fn,void 0,!0),l){case 1:a[u].fn.call(a[u].context);break;case 2:a[u].fn.call(a[u].context,t);break;case 3:a[u].fn.call(a[u].context,t,r);break;case 4:a[u].fn.call(a[u].context,t,r,o);break;default:if(!f)for(p=1,f=new Array(l-1);p<l;p++)f[p-1]=arguments[p];a[u].fn.apply(a[u].context,f)}}return!0},c.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,r,o){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return i(this,s),this;var c=this._events[s];if(c.fn)c.fn!==t||o&&!c.once||r&&c.context!==r||i(this,s);else{for(var f=0,u=[],a=c.length;f<a;f++)(c[f].fn!==t||o&&!c[f].once||r&&c[f].context!==r)&&u.push(c[f]);u.length?this._events[s]=1===u.length?u[0]:u:i(this,s)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,e.exports=c}(n)),n.exports);return e(r)});//# sourceMappingURL=eventemitter3.umd.min.js.map
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"JSON.stringify@native": {
|
||||
"name": "JSON.stringify@native",
|
||||
"browser": "Mobile Safari 10.0.0 (iOS 10.3.0)",
|
||||
"suite": "libs",
|
||||
"hz": 19950.666709438065,
|
||||
"success": true,
|
||||
"fastest": false,
|
||||
"rme": 0.04273375035790549,
|
||||
"rhz": 4.812102268741366,
|
||||
"sampleSize": 159
|
||||
},
|
||||
"fast-stable-stringify@a9f81e8": {
|
||||
"name": "fast-stable-stringify@a9f81e8",
|
||||
"browser": "Mobile Safari 10.0.0 (iOS 10.3.0)",
|
||||
"suite": "libs",
|
||||
"hz": 4145.935725230603,
|
||||
"success": true,
|
||||
"fastest": true,
|
||||
"rme": 0.03670494962202425,
|
||||
"rhz": 1,
|
||||
"sampleSize": 162
|
||||
},
|
||||
"json-stable-stringify@1.0.1": {
|
||||
"name": "json-stable-stringify@1.0.1",
|
||||
"browser": "Mobile Safari 10.0.0 (iOS 10.3.0)",
|
||||
"suite": "libs",
|
||||
"hz": 3594.843462246778,
|
||||
"success": true,
|
||||
"fastest": false,
|
||||
"rme": 0.031147610553987737,
|
||||
"rhz": 0.8670765058825961,
|
||||
"sampleSize": 138
|
||||
},
|
||||
"faster-stable-stringify@1.0.0": {
|
||||
"name": "faster-stable-stringify@1.0.0",
|
||||
"browser": "Mobile Safari 10.0.0 (iOS 10.3.0)",
|
||||
"suite": "libs",
|
||||
"hz": 4265.550460127418,
|
||||
"success": true,
|
||||
"fastest": true,
|
||||
"rme": 0.024960420577611418,
|
||||
"rhz": 1.028851082801136,
|
||||
"sampleSize": 142
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
Copyright (c) 2015-present, Facebook, Inc.
|
||||
|
||||
This source code is licensed under the MIT license found in the
|
||||
LICENSE file at
|
||||
https://github.com/react/create-react-app/blob/main/LICENSE
|
||||
*/
|
||||
|
||||
/* global Application */
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
function run(argv) {
|
||||
const urlToOpen = argv[0]
|
||||
// Allow requested program to be optional, default to Google Chrome
|
||||
const programName = argv[1] ?? 'Google Chrome'
|
||||
|
||||
const app = Application(programName)
|
||||
|
||||
if (app.windows.length === 0) {
|
||||
app.Window().make()
|
||||
}
|
||||
|
||||
// 1: Looking for tab running debugger then,
|
||||
// Reload debugging tab if found, then return
|
||||
const found = lookupTabWithUrl(urlToOpen, app)
|
||||
if (found) {
|
||||
found.targetWindow.activeTabIndex = found.targetTabIndex
|
||||
found.targetTab.reload()
|
||||
found.targetWindow.index = 1
|
||||
app.activate()
|
||||
return
|
||||
}
|
||||
|
||||
// 2: Looking for Empty tab
|
||||
// In case debugging tab was not found
|
||||
// We try to find an empty tab instead
|
||||
const emptyTabFound = lookupTabWithUrl('chrome://newtab/', app)
|
||||
if (emptyTabFound) {
|
||||
emptyTabFound.targetWindow.activeTabIndex = emptyTabFound.targetTabIndex
|
||||
emptyTabFound.targetTab.url = urlToOpen
|
||||
app.activate()
|
||||
return
|
||||
}
|
||||
|
||||
// 3: Create new tab
|
||||
// both debugging and empty tab were not found make a new tab with url
|
||||
const firstWindow = app.windows[0]
|
||||
firstWindow.tabs.push(app.Tab({ url: urlToOpen }))
|
||||
app.activate()
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup tab with given url
|
||||
*/
|
||||
function lookupTabWithUrl(lookupUrl, app) {
|
||||
const windows = app.windows()
|
||||
for (const window of windows) {
|
||||
for (const [tabIndex, tab] of window.tabs().entries()) {
|
||||
if (tab.url().includes(lookupUrl)) {
|
||||
return {
|
||||
targetTab: tab,
|
||||
targetTabIndex: tabIndex + 1,
|
||||
targetWindow: window,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,423 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const os = require('os')
|
||||
const crypto = require('crypto')
|
||||
|
||||
// Array of tips to display randomly
|
||||
const TIPS = [
|
||||
'◈ encrypted .env [www.dotenvx.com]',
|
||||
'◈ secrets for agents [www.dotenvx.com]',
|
||||
'⌁ auth for agents [www.vestauth.com]',
|
||||
'⌘ custom filepath { path: \'/custom/path/.env\' }',
|
||||
'⌘ enable debugging { debug: true }',
|
||||
'⌘ override existing { override: true }',
|
||||
'⌘ suppress logs { quiet: true }',
|
||||
'⌘ multiple files { path: [\'.env.local\', \'.env\'] }'
|
||||
]
|
||||
|
||||
// Get a random tip from the tips array
|
||||
function _getRandomTip () {
|
||||
return TIPS[Math.floor(Math.random() * TIPS.length)]
|
||||
}
|
||||
|
||||
function parseBoolean (value) {
|
||||
if (typeof value === 'string') {
|
||||
return !['false', '0', 'no', 'off', ''].includes(value.toLowerCase())
|
||||
}
|
||||
return Boolean(value)
|
||||
}
|
||||
|
||||
function supportsAnsi () {
|
||||
return process.stdout.isTTY // && process.env.TERM !== 'dumb'
|
||||
}
|
||||
|
||||
function dim (text) {
|
||||
return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text
|
||||
}
|
||||
|
||||
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg
|
||||
|
||||
// Parse src into an Object
|
||||
function parse (src) {
|
||||
const obj = {}
|
||||
|
||||
// Convert buffer to string
|
||||
let lines = src.toString()
|
||||
|
||||
// Convert line breaks to same format
|
||||
lines = lines.replace(/\r\n?/mg, '\n')
|
||||
|
||||
let match
|
||||
while ((match = LINE.exec(lines)) != null) {
|
||||
const key = match[1]
|
||||
|
||||
// Default undefined or null to empty string
|
||||
let value = (match[2] || '')
|
||||
|
||||
// Remove whitespace
|
||||
value = value.trim()
|
||||
|
||||
// Check if double quoted
|
||||
const maybeQuote = value[0]
|
||||
|
||||
// Remove surrounding quotes
|
||||
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2')
|
||||
|
||||
// Expand newlines if double quoted
|
||||
if (maybeQuote === '"') {
|
||||
value = value.replace(/\\n/g, '\n')
|
||||
value = value.replace(/\\r/g, '\r')
|
||||
}
|
||||
|
||||
// Add to object
|
||||
obj[key] = value
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
function _parseVault (options) {
|
||||
options = options || {}
|
||||
|
||||
const vaultPath = _vaultPath(options)
|
||||
options.path = vaultPath // parse .env.vault
|
||||
const result = DotenvModule.configDotenv(options)
|
||||
if (!result.parsed) {
|
||||
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)
|
||||
err.code = 'MISSING_DATA'
|
||||
throw err
|
||||
}
|
||||
|
||||
// handle scenario for comma separated keys - for use with key rotation
|
||||
// example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod"
|
||||
const keys = _dotenvKey(options).split(',')
|
||||
const length = keys.length
|
||||
|
||||
let decrypted
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
// Get full key
|
||||
const key = keys[i].trim()
|
||||
|
||||
// Get instructions for decrypt
|
||||
const attrs = _instructions(result, key)
|
||||
|
||||
// Decrypt
|
||||
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key)
|
||||
|
||||
break
|
||||
} catch (error) {
|
||||
// last key
|
||||
if (i + 1 >= length) {
|
||||
throw error
|
||||
}
|
||||
// try next key
|
||||
}
|
||||
}
|
||||
|
||||
// Parse decrypted .env string
|
||||
return DotenvModule.parse(decrypted)
|
||||
}
|
||||
|
||||
function _warn (message) {
|
||||
console.error(`⚠ ${message}`)
|
||||
}
|
||||
|
||||
function _debug (message) {
|
||||
console.log(`┆ ${message}`)
|
||||
}
|
||||
|
||||
function _log (message) {
|
||||
console.log(`◇ ${message}`)
|
||||
}
|
||||
|
||||
function _dotenvKey (options) {
|
||||
// prioritize developer directly setting options.DOTENV_KEY
|
||||
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
||||
return options.DOTENV_KEY
|
||||
}
|
||||
|
||||
// secondary infra already contains a DOTENV_KEY environment variable
|
||||
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
||||
return process.env.DOTENV_KEY
|
||||
}
|
||||
|
||||
// fallback to empty string
|
||||
return ''
|
||||
}
|
||||
|
||||
function _instructions (result, dotenvKey) {
|
||||
// Parse DOTENV_KEY. Format is a URI
|
||||
let uri
|
||||
try {
|
||||
uri = new URL(dotenvKey)
|
||||
} catch (error) {
|
||||
if (error.code === 'ERR_INVALID_URL') {
|
||||
const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development')
|
||||
err.code = 'INVALID_DOTENV_KEY'
|
||||
throw err
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
|
||||
// Get decrypt key
|
||||
const key = uri.password
|
||||
if (!key) {
|
||||
const err = new Error('INVALID_DOTENV_KEY: Missing key part')
|
||||
err.code = 'INVALID_DOTENV_KEY'
|
||||
throw err
|
||||
}
|
||||
|
||||
// Get environment
|
||||
const environment = uri.searchParams.get('environment')
|
||||
if (!environment) {
|
||||
const err = new Error('INVALID_DOTENV_KEY: Missing environment part')
|
||||
err.code = 'INVALID_DOTENV_KEY'
|
||||
throw err
|
||||
}
|
||||
|
||||
// Get ciphertext payload
|
||||
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`
|
||||
const ciphertext = result.parsed[environmentKey] // DOTENV_VAULT_PRODUCTION
|
||||
if (!ciphertext) {
|
||||
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)
|
||||
err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT'
|
||||
throw err
|
||||
}
|
||||
|
||||
return { ciphertext, key }
|
||||
}
|
||||
|
||||
function _vaultPath (options) {
|
||||
let possibleVaultPath = null
|
||||
|
||||
if (options && options.path && options.path.length > 0) {
|
||||
if (Array.isArray(options.path)) {
|
||||
for (const filepath of options.path) {
|
||||
if (fs.existsSync(filepath)) {
|
||||
possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`
|
||||
}
|
||||
}
|
||||
} else {
|
||||
possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`
|
||||
}
|
||||
} else {
|
||||
possibleVaultPath = path.resolve(process.cwd(), '.env.vault')
|
||||
}
|
||||
|
||||
if (fs.existsSync(possibleVaultPath)) {
|
||||
return possibleVaultPath
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
function _resolveHome (envPath) {
|
||||
return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath
|
||||
}
|
||||
|
||||
function _configVault (options) {
|
||||
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || (options && options.debug))
|
||||
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || (options && options.quiet))
|
||||
|
||||
if (debug || !quiet) {
|
||||
_log('loading env from encrypted .env.vault')
|
||||
}
|
||||
|
||||
const parsed = DotenvModule._parseVault(options)
|
||||
|
||||
let processEnv = process.env
|
||||
if (options && options.processEnv != null) {
|
||||
processEnv = options.processEnv
|
||||
}
|
||||
|
||||
DotenvModule.populate(processEnv, parsed, options)
|
||||
|
||||
return { parsed }
|
||||
}
|
||||
|
||||
function configDotenv (options) {
|
||||
const dotenvPath = path.resolve(process.cwd(), '.env')
|
||||
let encoding = 'utf8'
|
||||
let processEnv = process.env
|
||||
if (options && options.processEnv != null) {
|
||||
processEnv = options.processEnv
|
||||
}
|
||||
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || (options && options.debug))
|
||||
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || (options && options.quiet))
|
||||
|
||||
if (options && options.encoding) {
|
||||
encoding = options.encoding
|
||||
} else {
|
||||
if (debug) {
|
||||
_debug('no encoding is specified (UTF-8 is used by default)')
|
||||
}
|
||||
}
|
||||
|
||||
let optionPaths = [dotenvPath] // default, look for .env
|
||||
if (options && options.path) {
|
||||
if (!Array.isArray(options.path)) {
|
||||
optionPaths = [_resolveHome(options.path)]
|
||||
} else {
|
||||
optionPaths = [] // reset default
|
||||
for (const filepath of options.path) {
|
||||
optionPaths.push(_resolveHome(filepath))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build the parsed data in a temporary object (because we need to return it). Once we have the final
|
||||
// parsed data, we will combine it with process.env (or options.processEnv if provided).
|
||||
let lastError
|
||||
const parsedAll = {}
|
||||
for (const path of optionPaths) {
|
||||
try {
|
||||
// Specifying an encoding returns a string instead of a buffer
|
||||
const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))
|
||||
|
||||
DotenvModule.populate(parsedAll, parsed, options)
|
||||
} catch (e) {
|
||||
if (debug) {
|
||||
_debug(`failed to load ${path} ${e.message}`)
|
||||
}
|
||||
lastError = e
|
||||
}
|
||||
}
|
||||
|
||||
const populated = DotenvModule.populate(processEnv, parsedAll, options)
|
||||
|
||||
// handle user settings DOTENV_CONFIG_ options inside .env file(s)
|
||||
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug)
|
||||
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet)
|
||||
|
||||
if (debug || !quiet) {
|
||||
const keysCount = Object.keys(populated).length
|
||||
const shortPaths = []
|
||||
for (const filePath of optionPaths) {
|
||||
try {
|
||||
const relative = path.relative(process.cwd(), filePath)
|
||||
shortPaths.push(relative)
|
||||
} catch (e) {
|
||||
if (debug) {
|
||||
_debug(`failed to load ${filePath} ${e.message}`)
|
||||
}
|
||||
lastError = e
|
||||
}
|
||||
}
|
||||
|
||||
_log(`injected env (${keysCount}) from ${shortPaths.join(',')} ${dim(`// tip: ${_getRandomTip()}`)}`)
|
||||
}
|
||||
|
||||
if (lastError) {
|
||||
return { parsed: parsedAll, error: lastError }
|
||||
} else {
|
||||
return { parsed: parsedAll }
|
||||
}
|
||||
}
|
||||
|
||||
// Populates process.env from .env file
|
||||
function config (options) {
|
||||
// fallback to original dotenv if DOTENV_KEY is not set
|
||||
if (_dotenvKey(options).length === 0) {
|
||||
return DotenvModule.configDotenv(options)
|
||||
}
|
||||
|
||||
const vaultPath = _vaultPath(options)
|
||||
|
||||
// dotenvKey exists but .env.vault file does not exist
|
||||
if (!vaultPath) {
|
||||
_warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`)
|
||||
|
||||
return DotenvModule.configDotenv(options)
|
||||
}
|
||||
|
||||
return DotenvModule._configVault(options)
|
||||
}
|
||||
|
||||
function decrypt (encrypted, keyStr) {
|
||||
const key = Buffer.from(keyStr.slice(-64), 'hex')
|
||||
let ciphertext = Buffer.from(encrypted, 'base64')
|
||||
|
||||
const nonce = ciphertext.subarray(0, 12)
|
||||
const authTag = ciphertext.subarray(-16)
|
||||
ciphertext = ciphertext.subarray(12, -16)
|
||||
|
||||
try {
|
||||
const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)
|
||||
aesgcm.setAuthTag(authTag)
|
||||
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`
|
||||
} catch (error) {
|
||||
const isRange = error instanceof RangeError
|
||||
const invalidKeyLength = error.message === 'Invalid key length'
|
||||
const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data'
|
||||
|
||||
if (isRange || invalidKeyLength) {
|
||||
const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)')
|
||||
err.code = 'INVALID_DOTENV_KEY'
|
||||
throw err
|
||||
} else if (decryptionFailed) {
|
||||
const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY')
|
||||
err.code = 'DECRYPTION_FAILED'
|
||||
throw err
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Populate process.env with parsed values
|
||||
function populate (processEnv, parsed, options = {}) {
|
||||
const debug = Boolean(options && options.debug)
|
||||
const override = Boolean(options && options.override)
|
||||
const populated = {}
|
||||
|
||||
if (typeof parsed !== 'object') {
|
||||
const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')
|
||||
err.code = 'OBJECT_REQUIRED'
|
||||
throw err
|
||||
}
|
||||
|
||||
// Set process.env
|
||||
for (const key of Object.keys(parsed)) {
|
||||
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
||||
if (override === true) {
|
||||
processEnv[key] = parsed[key]
|
||||
populated[key] = parsed[key]
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
if (override === true) {
|
||||
_debug(`"${key}" is already defined and WAS overwritten`)
|
||||
} else {
|
||||
_debug(`"${key}" is already defined and was NOT overwritten`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
processEnv[key] = parsed[key]
|
||||
populated[key] = parsed[key]
|
||||
}
|
||||
}
|
||||
|
||||
return populated
|
||||
}
|
||||
|
||||
const DotenvModule = {
|
||||
configDotenv,
|
||||
_configVault,
|
||||
_parseVault,
|
||||
config,
|
||||
decrypt,
|
||||
parse,
|
||||
populate
|
||||
}
|
||||
|
||||
module.exports.configDotenv = DotenvModule.configDotenv
|
||||
module.exports._configVault = DotenvModule._configVault
|
||||
module.exports._parseVault = DotenvModule._parseVault
|
||||
module.exports.config = DotenvModule.config
|
||||
module.exports.decrypt = DotenvModule.decrypt
|
||||
module.exports.parse = DotenvModule.parse
|
||||
module.exports.populate = DotenvModule.populate
|
||||
|
||||
module.exports = DotenvModule
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"files": ["src/hfs-types.ts"],
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"outDir": "dist",
|
||||
"target": "ES2022",
|
||||
"moduleResolution": "NodeNext",
|
||||
"module": "NodeNext"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// @ts-ignore TS6133
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import * as z from "zod/v3";
|
||||
|
||||
const description = "a description";
|
||||
|
||||
test("passing `description` to schema should add a description", () => {
|
||||
expect(z.string({ description }).description).toEqual(description);
|
||||
expect(z.number({ description }).description).toEqual(description);
|
||||
expect(z.boolean({ description }).description).toEqual(description);
|
||||
});
|
||||
|
||||
test("`.describe` should add a description", () => {
|
||||
expect(z.string().describe(description).description).toEqual(description);
|
||||
expect(z.number().describe(description).description).toEqual(description);
|
||||
expect(z.boolean().describe(description).description).toEqual(description);
|
||||
});
|
||||
|
||||
test("description should carry over to chained schemas", () => {
|
||||
const schema = z.string({ description });
|
||||
expect(schema.description).toEqual(description);
|
||||
expect(schema.optional().description).toEqual(description);
|
||||
expect(schema.optional().nullable().default("default").description).toEqual(description);
|
||||
});
|
||||
|
||||
test("description should not carry over to chained array schema", () => {
|
||||
const schema = z.string().describe(description);
|
||||
|
||||
expect(schema.description).toEqual(description);
|
||||
expect(schema.array().description).toEqual(undefined);
|
||||
expect(z.array(schema).description).toEqual(undefined);
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"jubjub.js","sourceRoot":"","sources":["src/jubjub.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAAsF;AAEtF,wEAAwE;AAC3D,QAAA,MAAM,GAAmB,gBAAO,CAAC;AAC9C,sFAAsF;AACzE,QAAA,aAAa,GAAgC,8BAAoB,CAAC;AAC/E,kFAAkF;AACrE,QAAA,SAAS,GAA4B,0BAAgB,CAAC"}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "@oxc-project/types",
|
||||
"version": "0.144.0",
|
||||
"description": "Types for Oxc AST nodes",
|
||||
"keywords": [
|
||||
"AST",
|
||||
"Parser"
|
||||
],
|
||||
"homepage": "https://oxc.rs",
|
||||
"bugs": "https://github.com/oxc-project/oxc/issues",
|
||||
"license": "MIT",
|
||||
"author": "Boshen and oxc contributors",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/oxc-project/oxc.git",
|
||||
"directory": "npm/oxc-types"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/Boshen"
|
||||
},
|
||||
"files": [
|
||||
"types.d.ts"
|
||||
],
|
||||
"type": "module",
|
||||
"types": "types.d.ts"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
function _throw(e) {
|
||||
throw e;
|
||||
}
|
||||
exports._ = _throw;
|
||||
@@ -0,0 +1,200 @@
|
||||
import type * as checks from "./checks.js";
|
||||
import type { $ZodConfig } from "./core.js";
|
||||
import type * as errors from "./errors.js";
|
||||
import type * as schemas from "./schemas.js";
|
||||
export type JSONType = string | number | boolean | null | JSONType[] | {
|
||||
[key: string]: JSONType;
|
||||
};
|
||||
export type JWTAlgorithm = "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | "EdDSA" | (string & {});
|
||||
export type HashAlgorithm = "md5" | "sha1" | "sha256" | "sha384" | "sha512";
|
||||
export type HashEncoding = "hex" | "base64" | "base64url";
|
||||
export type HashFormat = `${HashAlgorithm}_${HashEncoding}`;
|
||||
export type IPVersion = "v4" | "v6";
|
||||
export type MimeTypes = "application/json" | "application/xml" | "application/x-www-form-urlencoded" | "application/javascript" | "application/pdf" | "application/zip" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/octet-stream" | "application/graphql" | "text/html" | "text/plain" | "text/css" | "text/javascript" | "text/csv" | "image/png" | "image/jpeg" | "image/gif" | "image/svg+xml" | "image/webp" | "audio/mpeg" | "audio/ogg" | "audio/wav" | "audio/webm" | "video/mp4" | "video/webm" | "video/ogg" | "font/woff" | "font/woff2" | "font/ttf" | "font/otf" | "multipart/form-data" | (string & {});
|
||||
export type ParsedTypes = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "file" | "date" | "array" | "map" | "set" | "nan" | "null" | "promise";
|
||||
export type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
|
||||
export type AssertNotEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? false : true;
|
||||
export type AssertExtends<T, U> = T extends U ? T : never;
|
||||
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
|
||||
export type MakePartial<T, K extends keyof T> = Omit<T, K> & InexactPartial<Pick<T, K>>;
|
||||
export type MakeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
||||
export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
|
||||
export type NoUndefined<T> = T extends undefined ? never : T;
|
||||
export type Whatever = {} | undefined | null;
|
||||
export type LoosePartial<T extends object> = InexactPartial<T> & {
|
||||
[k: string]: unknown;
|
||||
};
|
||||
export type Mask<Keys extends PropertyKey> = {
|
||||
[K in Keys]?: true;
|
||||
};
|
||||
export type Writeable<T> = {
|
||||
-readonly [P in keyof T]: T[P];
|
||||
} & {};
|
||||
export type InexactPartial<T> = {
|
||||
[P in keyof T]?: T[P] | undefined;
|
||||
};
|
||||
export type EmptyObject = Record<string, never>;
|
||||
export type BuiltIn = (((...args: any[]) => any) | (new (...args: any[]) => any)) | {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
} | Date | Error | Generator | Promise<unknown> | RegExp;
|
||||
export type MakeReadonly<T> = T extends Map<infer K, infer V> ? ReadonlyMap<K, V> : T extends Set<infer V> ? ReadonlySet<V> : T extends [infer Head, ...infer Tail] ? readonly [Head, ...Tail] : T extends Array<infer V> ? ReadonlyArray<V> : T extends BuiltIn ? T : Readonly<T>;
|
||||
export type SomeObject = Record<PropertyKey, any>;
|
||||
export type Identity<T> = T;
|
||||
export type Flatten<T> = Identity<{
|
||||
[k in keyof T]: T[k];
|
||||
}>;
|
||||
export type Mapped<T> = {
|
||||
[k in keyof T]: T[k];
|
||||
};
|
||||
export type Prettify<T> = {
|
||||
[K in keyof T]: T[K];
|
||||
} & {};
|
||||
export type NoNeverKeys<T> = {
|
||||
[k in keyof T]: [T[k]] extends [never] ? never : k;
|
||||
}[keyof T];
|
||||
export type NoNever<T> = Identity<{
|
||||
[k in NoNeverKeys<T>]: k extends keyof T ? T[k] : never;
|
||||
}>;
|
||||
export type Extend<A extends SomeObject, B extends SomeObject> = Flatten<keyof A & keyof B extends never ? A & B : {
|
||||
[K in keyof A as K extends keyof B ? never : K]: A[K];
|
||||
} & {
|
||||
[K in keyof B]: B[K];
|
||||
}>;
|
||||
export type TupleItems = ReadonlyArray<schemas.SomeType>;
|
||||
export type AnyFunc = (...args: any[]) => any;
|
||||
export type IsProp<T, K extends keyof T> = T[K] extends AnyFunc ? never : K;
|
||||
export type MaybeAsync<T> = T | Promise<T>;
|
||||
export type KeyOf<T> = keyof OmitIndexSignature<T>;
|
||||
export type OmitIndexSignature<T> = {
|
||||
[K in keyof T as string extends K ? never : K extends string ? K : never]: T[K];
|
||||
};
|
||||
export type ExtractIndexSignature<T> = {
|
||||
[K in keyof T as string extends K ? K : K extends string ? never : K]: T[K];
|
||||
};
|
||||
export type Keys<T extends object> = keyof OmitIndexSignature<T>;
|
||||
export type SchemaClass<T extends schemas.SomeType> = {
|
||||
new (def: T["_zod"]["def"]): T;
|
||||
};
|
||||
export type EnumValue = string | number;
|
||||
export type EnumLike = Readonly<Record<string, EnumValue>>;
|
||||
export type ToEnum<T extends EnumValue> = Flatten<{
|
||||
[k in T]: k;
|
||||
}>;
|
||||
export type KeysEnum<T extends object> = ToEnum<Exclude<keyof T, symbol>>;
|
||||
export type KeysArray<T extends object> = Flatten<(keyof T & string)[]>;
|
||||
export type Literal = string | number | bigint | boolean | null | undefined;
|
||||
export type LiteralArray = Array<Literal>;
|
||||
export type Primitive = string | number | symbol | bigint | boolean | null | undefined;
|
||||
export type PrimitiveArray = Array<Primitive>;
|
||||
export type HasSize = {
|
||||
size: number;
|
||||
};
|
||||
export type HasLength = {
|
||||
length: number;
|
||||
};
|
||||
export type Numeric = number | bigint | Date;
|
||||
export type SafeParseResult<T> = SafeParseSuccess<T> | SafeParseError<T>;
|
||||
export type SafeParseSuccess<T> = {
|
||||
success: true;
|
||||
data: T;
|
||||
error?: never;
|
||||
};
|
||||
export type SafeParseError<T> = {
|
||||
success: false;
|
||||
data?: never;
|
||||
error: errors.$ZodError<T>;
|
||||
};
|
||||
export type PropValues = Record<string, Set<Primitive>>;
|
||||
export type PrimitiveSet = Set<Primitive>;
|
||||
export declare function assertEqual<A, B>(val: AssertEqual<A, B>): AssertEqual<A, B>;
|
||||
export declare function assertNotEqual<A, B>(val: AssertNotEqual<A, B>): AssertNotEqual<A, B>;
|
||||
export declare function assertIs<T>(_arg: T): void;
|
||||
export declare function assertNever(_x: never): never;
|
||||
export declare function assert<T>(_: any): asserts _ is T;
|
||||
export declare function getEnumValues(entries: EnumLike): EnumValue[];
|
||||
export declare function joinValues<T extends Primitive[]>(array: T, separator?: string): string;
|
||||
export declare function jsonStringifyReplacer(_: string, value: any): any;
|
||||
export declare function cached<T>(getter: () => T): {
|
||||
value: T;
|
||||
};
|
||||
export declare function nullish(input: any): boolean;
|
||||
export declare function cleanRegex(source: string): string;
|
||||
export declare function floatSafeRemainder(val: number, step: number): number;
|
||||
export declare function defineLazy<T, K extends keyof T>(object: T, key: K, getter: () => T[K]): void;
|
||||
export declare function objectClone(obj: object): any;
|
||||
export declare function assignProp<T extends object, K extends PropertyKey>(target: T, prop: K, value: K extends keyof T ? T[K] : any): void;
|
||||
export declare function mergeDefs(...defs: Record<string, any>[]): any;
|
||||
export declare function cloneDef(schema: schemas.$ZodType): any;
|
||||
export declare function getElementAtPath(obj: any, path: (string | number)[] | null | undefined): any;
|
||||
export declare function promiseAllObject<T extends object>(promisesObj: T): Promise<{
|
||||
[k in keyof T]: Awaited<T[k]>;
|
||||
}>;
|
||||
export declare function randomString(length?: number): string;
|
||||
export declare function esc(str: string): string;
|
||||
export declare function slugify(input: string): string;
|
||||
export declare const captureStackTrace: (targetObject: object, constructorOpt?: Function) => void;
|
||||
export declare function isObject(data: any): data is Record<PropertyKey, unknown>;
|
||||
export declare const allowsEval: {
|
||||
value: boolean;
|
||||
};
|
||||
export declare function isPlainObject(o: any): o is Record<PropertyKey, unknown>;
|
||||
export declare function shallowClone(o: any): any;
|
||||
export declare function numKeys(data: any): number;
|
||||
export declare const getParsedType: (data: any) => ParsedTypes;
|
||||
export declare const propertyKeyTypes: Set<string>;
|
||||
export declare const primitiveTypes: Set<string>;
|
||||
export declare function escapeRegex(str: string): string;
|
||||
export declare function clone<T extends schemas.$ZodType>(inst: T, def?: T["_zod"]["def"], params?: {
|
||||
parent: boolean;
|
||||
}): T;
|
||||
export type EmptyToNever<T> = keyof T extends never ? never : T;
|
||||
export type Normalize<T> = T extends undefined ? never : T extends Record<any, any> ? Flatten<{
|
||||
[k in keyof Omit<T, "error" | "message">]: T[k];
|
||||
} & ("error" extends keyof T ? {
|
||||
error?: Exclude<T["error"], string>;
|
||||
} : unknown)> : never;
|
||||
export declare function normalizeParams<T>(_params: T): Normalize<T>;
|
||||
export declare function createTransparentProxy<T extends object>(getter: () => T): T;
|
||||
export declare function stringifyPrimitive(value: any): string;
|
||||
export declare function optionalKeys(shape: schemas.$ZodShape): string[];
|
||||
export type CleanKey<T extends PropertyKey> = T extends `?${infer K}` ? K : T extends `${infer K}?` ? K : T;
|
||||
export type ToCleanMap<T extends schemas.$ZodLooseShape> = {
|
||||
[k in keyof T]: k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k;
|
||||
};
|
||||
export type FromCleanMap<T extends schemas.$ZodLooseShape> = {
|
||||
[k in keyof T as k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k]: k;
|
||||
};
|
||||
export declare const NUMBER_FORMAT_RANGES: Record<checks.$ZodNumberFormats, [number, number]>;
|
||||
export declare const BIGINT_FORMAT_RANGES: Record<checks.$ZodBigIntFormats, [bigint, bigint]>;
|
||||
export declare function pick(schema: schemas.$ZodObject, mask: Record<string, unknown>): any;
|
||||
export declare function omit(schema: schemas.$ZodObject, mask: object): any;
|
||||
export declare function extend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any;
|
||||
export declare function safeExtend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any;
|
||||
export declare function merge(a: schemas.$ZodObject, b: schemas.$ZodObject): any;
|
||||
export declare function partial(Class: SchemaClass<schemas.$ZodOptional> | null, schema: schemas.$ZodObject, mask: object | undefined): any;
|
||||
export declare function required(Class: SchemaClass<schemas.$ZodNonOptional>, schema: schemas.$ZodObject, mask: object | undefined): any;
|
||||
export type Constructor<T, Def extends any[] = any[]> = new (...args: Def) => T;
|
||||
export declare function aborted(x: schemas.ParsePayload, startIndex?: number): boolean;
|
||||
export declare function explicitlyAborted(x: schemas.ParsePayload, startIndex?: number): boolean;
|
||||
export declare function prefixIssues(path: PropertyKey, issues: errors.$ZodRawIssue[]): errors.$ZodRawIssue[];
|
||||
export declare function unwrapMessage(message: string | {
|
||||
message: string;
|
||||
} | undefined | null): string | undefined;
|
||||
export declare function finalizeIssue(iss: errors.$ZodRawIssue, ctx: schemas.ParseContextInternal | undefined, config: $ZodConfig): errors.$ZodIssue;
|
||||
export declare function getSizableOrigin(input: any): "set" | "map" | "file" | "unknown";
|
||||
export declare function getLengthableOrigin(input: any): "array" | "string" | "unknown";
|
||||
export declare function parsedType(data: unknown): errors.$ZodInvalidTypeExpected;
|
||||
export declare function issue(_iss: string, input: any, inst: any): errors.$ZodRawIssue;
|
||||
export declare function issue(_iss: errors.$ZodRawIssue): errors.$ZodRawIssue;
|
||||
export declare function cleanEnum(obj: Record<string, EnumValue>): EnumValue[];
|
||||
export declare function base64ToUint8Array(base64: string): InstanceType<typeof Uint8Array>;
|
||||
export declare function uint8ArrayToBase64(bytes: Uint8Array): string;
|
||||
export declare function base64urlToUint8Array(base64url: string): InstanceType<typeof Uint8Array>;
|
||||
export declare function uint8ArrayToBase64url(bytes: Uint8Array): string;
|
||||
export declare function hexToUint8Array(hex: string): InstanceType<typeof Uint8Array>;
|
||||
export declare function uint8ArrayToHex(bytes: Uint8Array): string;
|
||||
export declare abstract class Class {
|
||||
constructor(..._args: any[]);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Code generated by Herebyfile.mjs generate:enums from internal/ast/symbol.go. DO NOT EDIT.
|
||||
export var InternalSymbolName;
|
||||
(function (InternalSymbolName) {
|
||||
InternalSymbolName["Call"] = "__call";
|
||||
InternalSymbolName["Constructor"] = "__constructor";
|
||||
InternalSymbolName["New"] = "__new";
|
||||
InternalSymbolName["Index"] = "__index";
|
||||
InternalSymbolName["ExportStar"] = "__export";
|
||||
InternalSymbolName["Global"] = "__global";
|
||||
InternalSymbolName["Missing"] = "__missing";
|
||||
InternalSymbolName["Type"] = "__type";
|
||||
InternalSymbolName["Object"] = "__object";
|
||||
InternalSymbolName["JSXAttributes"] = "__jsxAttributes";
|
||||
InternalSymbolName["Class"] = "__class";
|
||||
InternalSymbolName["Function"] = "__function";
|
||||
InternalSymbolName["Computed"] = "__computed";
|
||||
InternalSymbolName["AssignmentDeclaration"] = "__assignment";
|
||||
InternalSymbolName["InstantiationExpression"] = "__instantiationExpression";
|
||||
InternalSymbolName["ImportAttributes"] = "__importAttributes";
|
||||
InternalSymbolName["ExportEquals"] = "export=";
|
||||
InternalSymbolName["Default"] = "default";
|
||||
InternalSymbolName["This"] = "this";
|
||||
InternalSymbolName["ModuleExports"] = "module.exports";
|
||||
})(InternalSymbolName || (InternalSymbolName = {}));
|
||||
//# sourceMappingURL=internalSymbolName.js.map
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,215 @@
|
||||
import { expect, test } from "vitest";
|
||||
import { z } from "../../../../index.js";
|
||||
import el from "../../../locales/el.js";
|
||||
|
||||
test("Greek locale - too_small errors", () => {
|
||||
z.config(el());
|
||||
|
||||
// Test string type translation
|
||||
const stringSchema = z.string().min(5);
|
||||
const stringResult = stringSchema.safeParse("abc");
|
||||
expect(stringResult.success).toBe(false);
|
||||
if (!stringResult.success) {
|
||||
expect(stringResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν string να έχει >=5 χαρακτήρες");
|
||||
}
|
||||
|
||||
// Test number type translation
|
||||
const numberSchema = z.number().min(10);
|
||||
const numberResult = numberSchema.safeParse(5);
|
||||
expect(numberResult.success).toBe(false);
|
||||
if (!numberResult.success) {
|
||||
expect(numberResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν number να είναι >=10");
|
||||
}
|
||||
|
||||
// Test array type translation
|
||||
const arraySchema = z.array(z.string()).min(3);
|
||||
const arrayResult = arraySchema.safeParse(["a", "b"]);
|
||||
expect(arrayResult.success).toBe(false);
|
||||
if (!arrayResult.success) {
|
||||
expect(arrayResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν array να έχει >=3 στοιχεία");
|
||||
}
|
||||
|
||||
// Test set type translation
|
||||
const setSchema = z.set(z.string()).min(2);
|
||||
const setResult = setSchema.safeParse(new Set(["a"]));
|
||||
expect(setResult.success).toBe(false);
|
||||
if (!setResult.success) {
|
||||
expect(setResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν set να έχει >=2 στοιχεία");
|
||||
}
|
||||
});
|
||||
|
||||
test("Greek locale - too_big errors", () => {
|
||||
z.config(el());
|
||||
|
||||
// Test string type translation
|
||||
const stringSchema = z.string().max(3);
|
||||
const stringResult = stringSchema.safeParse("abcde");
|
||||
expect(stringResult.success).toBe(false);
|
||||
if (!stringResult.success) {
|
||||
expect(stringResult.error.issues[0].message).toBe("Πολύ μεγάλο: αναμενόταν string να έχει <=3 χαρακτήρες");
|
||||
}
|
||||
|
||||
// Test number type translation
|
||||
const numberSchema = z.number().max(10);
|
||||
const numberResult = numberSchema.safeParse(15);
|
||||
expect(numberResult.success).toBe(false);
|
||||
if (!numberResult.success) {
|
||||
expect(numberResult.error.issues[0].message).toBe("Πολύ μεγάλο: αναμενόταν number να είναι <=10");
|
||||
}
|
||||
|
||||
// Test array type translation
|
||||
const arraySchema = z.array(z.string()).max(2);
|
||||
const arrayResult = arraySchema.safeParse(["a", "b", "c"]);
|
||||
expect(arrayResult.success).toBe(false);
|
||||
if (!arrayResult.success) {
|
||||
expect(arrayResult.error.issues[0].message).toBe("Πολύ μεγάλο: αναμενόταν array να έχει <=2 στοιχεία");
|
||||
}
|
||||
});
|
||||
|
||||
test("Greek locale - invalid_type errors", () => {
|
||||
z.config(el());
|
||||
|
||||
// Test string expected, number received
|
||||
const stringSchema = z.string();
|
||||
const stringResult = stringSchema.safeParse(123);
|
||||
expect(stringResult.success).toBe(false);
|
||||
if (!stringResult.success) {
|
||||
expect(stringResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν string, λήφθηκε number");
|
||||
}
|
||||
|
||||
// Test number expected, string received
|
||||
const numberSchema = z.number();
|
||||
const numberResult = numberSchema.safeParse("abc");
|
||||
expect(numberResult.success).toBe(false);
|
||||
if (!numberResult.success) {
|
||||
expect(numberResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν number, λήφθηκε string");
|
||||
}
|
||||
|
||||
// Test boolean expected, null received
|
||||
const booleanSchema = z.boolean();
|
||||
const booleanResult = booleanSchema.safeParse(null);
|
||||
expect(booleanResult.success).toBe(false);
|
||||
if (!booleanResult.success) {
|
||||
expect(booleanResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν boolean, λήφθηκε null");
|
||||
}
|
||||
|
||||
// Test array expected, object received
|
||||
const arraySchema = z.array(z.string());
|
||||
const arrayResult = arraySchema.safeParse({});
|
||||
expect(arrayResult.success).toBe(false);
|
||||
if (!arrayResult.success) {
|
||||
expect(arrayResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν array, λήφθηκε object");
|
||||
}
|
||||
});
|
||||
|
||||
test("Greek locale - other error cases", () => {
|
||||
z.config(el());
|
||||
|
||||
// Test invalid_element with map (only "map" | "set" produce invalid_element)
|
||||
const mapSchema = z.map(z.bigint(), z.number());
|
||||
const mapResult = mapSchema.safeParse(new Map([[BigInt(123), BigInt(123)]]));
|
||||
expect(mapResult.success).toBe(false);
|
||||
if (!mapResult.success) {
|
||||
expect(mapResult.error.issues[0].code).toBe("invalid_element");
|
||||
expect(mapResult.error.issues[0].message).toBe("Μη έγκυρη τιμή στο map");
|
||||
}
|
||||
|
||||
// Test invalid_key with record (only "map" | "record" produce invalid_key)
|
||||
const recordSchema = z.record(z.number(), z.string());
|
||||
const recordResult = recordSchema.safeParse({ notANumber: "value" });
|
||||
expect(recordResult.success).toBe(false);
|
||||
if (!recordResult.success) {
|
||||
expect(recordResult.error.issues[0].code).toBe("invalid_key");
|
||||
expect(recordResult.error.issues[0].message).toBe("Μη έγκυρο κλειδί στο record");
|
||||
}
|
||||
|
||||
// Test invalid_value with enum
|
||||
const enumSchema = z.enum(["a", "b"]);
|
||||
const enumResult = enumSchema.safeParse("c");
|
||||
expect(enumResult.success).toBe(false);
|
||||
if (!enumResult.success) {
|
||||
expect(enumResult.error.issues[0].message).toBe('Μη έγκυρη επιλογή: αναμενόταν ένα από "a"|"b"');
|
||||
}
|
||||
|
||||
// Test not_multiple_of
|
||||
const multipleSchema = z.number().multipleOf(3);
|
||||
const multipleResult = multipleSchema.safeParse(10);
|
||||
expect(multipleResult.success).toBe(false);
|
||||
if (!multipleResult.success) {
|
||||
expect(multipleResult.error.issues[0].message).toBe("Μη έγκυρος αριθμός: πρέπει να είναι πολλαπλάσιο του 3");
|
||||
}
|
||||
|
||||
// Test unrecognized_keys (single key)
|
||||
const strictSchema = z.object({ a: z.string() }).strict();
|
||||
const strictResult = strictSchema.safeParse({ a: "test", b: "extra" });
|
||||
expect(strictResult.success).toBe(false);
|
||||
if (!strictResult.success) {
|
||||
expect(strictResult.error.issues[0].message).toBe('Άγνωστο κλειδί: "b"');
|
||||
}
|
||||
|
||||
// Test unrecognized_keys (multiple keys)
|
||||
const strictMultipleResult = strictSchema.safeParse({
|
||||
a: "test",
|
||||
b: "extra",
|
||||
c: "another",
|
||||
});
|
||||
expect(strictMultipleResult.success).toBe(false);
|
||||
if (!strictMultipleResult.success) {
|
||||
expect(strictMultipleResult.error.issues[0].message).toBe('Άγνωστα κλειδιά: "b", "c"');
|
||||
}
|
||||
|
||||
// Test invalid_union
|
||||
const unionSchema = z.union([z.string(), z.number()]);
|
||||
const unionResult = unionSchema.safeParse(true);
|
||||
expect(unionResult.success).toBe(false);
|
||||
if (!unionResult.success) {
|
||||
expect(unionResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος");
|
||||
}
|
||||
|
||||
// Test invalid_format with regex
|
||||
const regexSchema = z.string().regex(/^[a-z]+$/);
|
||||
const regexResult = regexSchema.safeParse("ABC123");
|
||||
expect(regexResult.success).toBe(false);
|
||||
if (!regexResult.success) {
|
||||
expect(regexResult.error.issues[0].message).toBe(
|
||||
"Μη έγκυρη συμβολοσειρά: πρέπει να ταιριάζει με το μοτίβο /^[a-z]+$/"
|
||||
);
|
||||
}
|
||||
|
||||
// Test invalid_format with startsWith
|
||||
const startsWithSchema = z.string().startsWith("hello");
|
||||
const startsWithResult = startsWithSchema.safeParse("world");
|
||||
expect(startsWithResult.success).toBe(false);
|
||||
if (!startsWithResult.success) {
|
||||
expect(startsWithResult.error.issues[0].message).toBe('Μη έγκυρη συμβολοσειρά: πρέπει να ξεκινά με "hello"');
|
||||
}
|
||||
|
||||
// Test invalid_format with endsWith
|
||||
const endsWithSchema = z.string().endsWith("world");
|
||||
const endsWithResult = endsWithSchema.safeParse("hello");
|
||||
expect(endsWithResult.success).toBe(false);
|
||||
if (!endsWithResult.success) {
|
||||
expect(endsWithResult.error.issues[0].message).toBe('Μη έγκυρη συμβολοσειρά: πρέπει να τελειώνει με "world"');
|
||||
}
|
||||
|
||||
// Test invalid_format with includes
|
||||
const includesSchema = z.string().includes("test");
|
||||
const includesResult = includesSchema.safeParse("hello");
|
||||
expect(includesResult.success).toBe(false);
|
||||
if (!includesResult.success) {
|
||||
expect(includesResult.error.issues[0].message).toBe('Μη έγκυρη συμβολοσειρά: πρέπει να περιέχει "test"');
|
||||
}
|
||||
});
|
||||
|
||||
test("Greek locale - invalid_type with instanceof (class-name expected)", () => {
|
||||
z.config(el());
|
||||
|
||||
// When `expected` starts with a capital letter, render an `instanceof` message,
|
||||
// matching the convention used by most other locales (de, es, fr, it, etc.).
|
||||
const dateSchema = z.instanceof(Date);
|
||||
const dateResult = dateSchema.safeParse("not a date");
|
||||
expect(dateResult.success).toBe(false);
|
||||
if (!dateResult.success) {
|
||||
expect(dateResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν instanceof Date, λήφθηκε string");
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import classApplyDescriptorSet from "./classApplyDescriptorSet.js";
|
||||
import assertClassBrand from "./assertClassBrand.js";
|
||||
import classCheckPrivateStaticFieldDescriptor from "./classCheckPrivateStaticFieldDescriptor.js";
|
||||
function _classStaticPrivateFieldSpecSet(s, t, r, e) {
|
||||
return assertClassBrand(t, s), classCheckPrivateStaticFieldDescriptor(r, "set"), classApplyDescriptorSet(s, r, e), e;
|
||||
}
|
||||
export { _classStaticPrivateFieldSpecSet as default };
|
||||
@@ -0,0 +1 @@
|
||||
"use strict";var p=Object.defineProperty;var o=(n,s)=>p(n,"name",{value:s,configurable:!0});var f=require("./get-pipe-path-D4YM6rQt.cjs"),h=require("node:os"),q=require("node:worker_threads"),H=require("./client-D3mGB526.cjs");require("./suppress-warnings.cjs"),require("module"),require("node:path"),require("./temporary-directory-B83uKxJF.cjs"),require("node:net");const T=o((n,s)=>{const i=new Map;for(const e of n){const r=o(t=>{s(t),process.listenerCount(e)===0&&process.exit(128+h.constants.signals[e])},"hiddenHandler");process.prependListener(e,r),i.set(e,r)}const{listenerCount:l,listeners:u}=process;process.listenerCount=function(e){let r=Reflect.apply(l,this,arguments);const t=i.get(e),c=arguments[1],a=l.length===1||arguments.length<2||c===void 0||c===null;if(t&&(a||c===t)){const d=Reflect.apply(u,this,[e]).filter(g=>g===t).length;r-=d}return r},process.listeners=function(e){const r=Reflect.apply(u,this,arguments);return n.includes(e)?r.filter(t=>t!==i.get(e)):r}},"bindHiddenSignalsHandler");q.isMainThread&&(f.require("./cjs/index.cjs"),(async()=>{const n=await H.connectingToServer;n&&T(["SIGINT","SIGTERM"],s=>{n({type:"signal",signal:s})})})());
|
||||
@@ -0,0 +1,421 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OperatorPrecedence = void 0;
|
||||
exports.getOperatorPrecedenceForNode = getOperatorPrecedenceForNode;
|
||||
exports.getOperatorPrecedence = getOperatorPrecedence;
|
||||
exports.getBinaryOperatorPrecedence = getBinaryOperatorPrecedence;
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const typescript_1 = require("typescript");
|
||||
var OperatorPrecedence;
|
||||
(function (OperatorPrecedence) {
|
||||
// Expression:
|
||||
// AssignmentExpression
|
||||
// Expression `,` AssignmentExpression
|
||||
OperatorPrecedence[OperatorPrecedence["Comma"] = 0] = "Comma";
|
||||
// NOTE: `Spread` is higher than `Comma` due to how it is parsed in |ElementList|
|
||||
// SpreadElement:
|
||||
// `...` AssignmentExpression
|
||||
OperatorPrecedence[OperatorPrecedence["Spread"] = 1] = "Spread";
|
||||
// AssignmentExpression:
|
||||
// ConditionalExpression
|
||||
// YieldExpression
|
||||
// ArrowFunction
|
||||
// AsyncArrowFunction
|
||||
// LeftHandSideExpression `=` AssignmentExpression
|
||||
// LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
//
|
||||
// NOTE: AssignmentExpression is broken down into several precedences due to the requirements
|
||||
// of the parenthesize rules.
|
||||
// AssignmentExpression: YieldExpression
|
||||
// YieldExpression:
|
||||
// `yield`
|
||||
// `yield` AssignmentExpression
|
||||
// `yield` `*` AssignmentExpression
|
||||
OperatorPrecedence[OperatorPrecedence["Yield"] = 2] = "Yield";
|
||||
// AssignmentExpression: LeftHandSideExpression `=` AssignmentExpression
|
||||
// AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression
|
||||
// AssignmentOperator: one of
|
||||
// `*=` `/=` `%=` `+=` `-=` `<<=` `>>=` `>>>=` `&=` `^=` `|=` `**=`
|
||||
OperatorPrecedence[OperatorPrecedence["Assignment"] = 3] = "Assignment";
|
||||
// NOTE: `Conditional` is considered higher than `Assignment` here, but in reality they have
|
||||
// the same precedence.
|
||||
// AssignmentExpression: ConditionalExpression
|
||||
// ConditionalExpression:
|
||||
// ShortCircuitExpression
|
||||
// ShortCircuitExpression `?` AssignmentExpression `:` AssignmentExpression
|
||||
// ShortCircuitExpression:
|
||||
// LogicalORExpression
|
||||
// CoalesceExpression
|
||||
OperatorPrecedence[OperatorPrecedence["Conditional"] = 4] = "Conditional";
|
||||
// CoalesceExpression:
|
||||
// CoalesceExpressionHead `??` BitwiseORExpression
|
||||
// CoalesceExpressionHead:
|
||||
// CoalesceExpression
|
||||
// BitwiseORExpression
|
||||
OperatorPrecedence[OperatorPrecedence["Coalesce"] = 4] = "Coalesce";
|
||||
// LogicalORExpression:
|
||||
// LogicalANDExpression
|
||||
// LogicalORExpression `||` LogicalANDExpression
|
||||
OperatorPrecedence[OperatorPrecedence["LogicalOR"] = 5] = "LogicalOR";
|
||||
// LogicalANDExpression:
|
||||
// BitwiseORExpression
|
||||
// LogicalANDExpression `&&` BitwiseORExpression
|
||||
OperatorPrecedence[OperatorPrecedence["LogicalAND"] = 6] = "LogicalAND";
|
||||
// BitwiseORExpression:
|
||||
// BitwiseXORExpression
|
||||
// BitwiseORExpression `^` BitwiseXORExpression
|
||||
OperatorPrecedence[OperatorPrecedence["BitwiseOR"] = 7] = "BitwiseOR";
|
||||
// BitwiseXORExpression:
|
||||
// BitwiseANDExpression
|
||||
// BitwiseXORExpression `^` BitwiseANDExpression
|
||||
OperatorPrecedence[OperatorPrecedence["BitwiseXOR"] = 8] = "BitwiseXOR";
|
||||
// BitwiseANDExpression:
|
||||
// EqualityExpression
|
||||
// BitwiseANDExpression `^` EqualityExpression
|
||||
OperatorPrecedence[OperatorPrecedence["BitwiseAND"] = 9] = "BitwiseAND";
|
||||
// EqualityExpression:
|
||||
// RelationalExpression
|
||||
// EqualityExpression `==` RelationalExpression
|
||||
// EqualityExpression `!=` RelationalExpression
|
||||
// EqualityExpression `===` RelationalExpression
|
||||
// EqualityExpression `!==` RelationalExpression
|
||||
OperatorPrecedence[OperatorPrecedence["Equality"] = 10] = "Equality";
|
||||
// RelationalExpression:
|
||||
// ShiftExpression
|
||||
// RelationalExpression `<` ShiftExpression
|
||||
// RelationalExpression `>` ShiftExpression
|
||||
// RelationalExpression `<=` ShiftExpression
|
||||
// RelationalExpression `>=` ShiftExpression
|
||||
// RelationalExpression `instanceof` ShiftExpression
|
||||
// RelationalExpression `in` ShiftExpression
|
||||
// [+TypeScript] RelationalExpression `as` Type
|
||||
OperatorPrecedence[OperatorPrecedence["Relational"] = 11] = "Relational";
|
||||
// ShiftExpression:
|
||||
// AdditiveExpression
|
||||
// ShiftExpression `<<` AdditiveExpression
|
||||
// ShiftExpression `>>` AdditiveExpression
|
||||
// ShiftExpression `>>>` AdditiveExpression
|
||||
OperatorPrecedence[OperatorPrecedence["Shift"] = 12] = "Shift";
|
||||
// AdditiveExpression:
|
||||
// MultiplicativeExpression
|
||||
// AdditiveExpression `+` MultiplicativeExpression
|
||||
// AdditiveExpression `-` MultiplicativeExpression
|
||||
OperatorPrecedence[OperatorPrecedence["Additive"] = 13] = "Additive";
|
||||
// MultiplicativeExpression:
|
||||
// ExponentiationExpression
|
||||
// MultiplicativeExpression MultiplicativeOperator ExponentiationExpression
|
||||
// MultiplicativeOperator: one of `*`, `/`, `%`
|
||||
OperatorPrecedence[OperatorPrecedence["Multiplicative"] = 14] = "Multiplicative";
|
||||
// ExponentiationExpression:
|
||||
// UnaryExpression
|
||||
// UpdateExpression `**` ExponentiationExpression
|
||||
OperatorPrecedence[OperatorPrecedence["Exponentiation"] = 15] = "Exponentiation";
|
||||
// UnaryExpression:
|
||||
// UpdateExpression
|
||||
// `delete` UnaryExpression
|
||||
// `void` UnaryExpression
|
||||
// `typeof` UnaryExpression
|
||||
// `+` UnaryExpression
|
||||
// `-` UnaryExpression
|
||||
// `~` UnaryExpression
|
||||
// `!` UnaryExpression
|
||||
// AwaitExpression
|
||||
// UpdateExpression: // TODO: Do we need to investigate the precedence here?
|
||||
// `++` UnaryExpression
|
||||
// `--` UnaryExpression
|
||||
OperatorPrecedence[OperatorPrecedence["Unary"] = 16] = "Unary";
|
||||
// UpdateExpression:
|
||||
// LeftHandSideExpression
|
||||
// LeftHandSideExpression `++`
|
||||
// LeftHandSideExpression `--`
|
||||
OperatorPrecedence[OperatorPrecedence["Update"] = 17] = "Update";
|
||||
// LeftHandSideExpression:
|
||||
// NewExpression
|
||||
// CallExpression
|
||||
// NewExpression:
|
||||
// MemberExpression
|
||||
// `new` NewExpression
|
||||
OperatorPrecedence[OperatorPrecedence["LeftHandSide"] = 18] = "LeftHandSide";
|
||||
// CallExpression:
|
||||
// CoverCallExpressionAndAsyncArrowHead
|
||||
// SuperCall
|
||||
// ImportCall
|
||||
// CallExpression Arguments
|
||||
// CallExpression `[` Expression `]`
|
||||
// CallExpression `.` IdentifierName
|
||||
// CallExpression TemplateLiteral
|
||||
// MemberExpression:
|
||||
// PrimaryExpression
|
||||
// MemberExpression `[` Expression `]`
|
||||
// MemberExpression `.` IdentifierName
|
||||
// MemberExpression TemplateLiteral
|
||||
// SuperProperty
|
||||
// MetaProperty
|
||||
// `new` MemberExpression Arguments
|
||||
OperatorPrecedence[OperatorPrecedence["Member"] = 19] = "Member";
|
||||
// TODO: JSXElement?
|
||||
// PrimaryExpression:
|
||||
// `this`
|
||||
// IdentifierReference
|
||||
// Literal
|
||||
// ArrayLiteral
|
||||
// ObjectLiteral
|
||||
// FunctionExpression
|
||||
// ClassExpression
|
||||
// GeneratorExpression
|
||||
// AsyncFunctionExpression
|
||||
// AsyncGeneratorExpression
|
||||
// RegularExpressionLiteral
|
||||
// TemplateLiteral
|
||||
// CoverParenthesizedExpressionAndArrowParameterList
|
||||
OperatorPrecedence[OperatorPrecedence["Primary"] = 20] = "Primary";
|
||||
OperatorPrecedence[OperatorPrecedence["Highest"] = 20] = "Highest";
|
||||
OperatorPrecedence[OperatorPrecedence["Lowest"] = 0] = "Lowest";
|
||||
// -1 is lower than all other precedences. Returning it will cause binary expression
|
||||
// parsing to stop.
|
||||
OperatorPrecedence[OperatorPrecedence["Invalid"] = -1] = "Invalid";
|
||||
})(OperatorPrecedence || (exports.OperatorPrecedence = OperatorPrecedence = {}));
|
||||
/**
|
||||
* Note that this does not take into account parenthesization. You should check
|
||||
* for parenthesization separately if it's relevant to your usage.
|
||||
*/
|
||||
function getOperatorPrecedenceForNode(node) {
|
||||
switch (node.type) {
|
||||
case utils_1.AST_NODE_TYPES.SpreadElement:
|
||||
case utils_1.AST_NODE_TYPES.RestElement:
|
||||
return OperatorPrecedence.Spread;
|
||||
case utils_1.AST_NODE_TYPES.YieldExpression:
|
||||
case utils_1.AST_NODE_TYPES.ArrowFunctionExpression:
|
||||
return OperatorPrecedence.Yield;
|
||||
case utils_1.AST_NODE_TYPES.ConditionalExpression:
|
||||
return OperatorPrecedence.Conditional;
|
||||
case utils_1.AST_NODE_TYPES.SequenceExpression:
|
||||
return OperatorPrecedence.Comma;
|
||||
case utils_1.AST_NODE_TYPES.AssignmentExpression:
|
||||
case utils_1.AST_NODE_TYPES.BinaryExpression:
|
||||
case utils_1.AST_NODE_TYPES.LogicalExpression:
|
||||
switch (node.operator) {
|
||||
case '==':
|
||||
case '+=':
|
||||
case '-=':
|
||||
case '**=':
|
||||
case '*=':
|
||||
case '/=':
|
||||
case '%=':
|
||||
case '<<=':
|
||||
case '>>=':
|
||||
case '>>>=':
|
||||
case '&=':
|
||||
case '^=':
|
||||
case '|=':
|
||||
case '||=':
|
||||
case '&&=':
|
||||
case '??=':
|
||||
return OperatorPrecedence.Assignment;
|
||||
default:
|
||||
return getBinaryOperatorPrecedence(node.operator);
|
||||
}
|
||||
case utils_1.AST_NODE_TYPES.TSTypeAssertion:
|
||||
case utils_1.AST_NODE_TYPES.TSNonNullExpression:
|
||||
case utils_1.AST_NODE_TYPES.UnaryExpression:
|
||||
case utils_1.AST_NODE_TYPES.AwaitExpression:
|
||||
return OperatorPrecedence.Unary;
|
||||
case utils_1.AST_NODE_TYPES.UpdateExpression:
|
||||
// TODO: Should prefix `++` and `--` be moved to the `Update` precedence?
|
||||
if (node.prefix) {
|
||||
return OperatorPrecedence.Unary;
|
||||
}
|
||||
return OperatorPrecedence.Update;
|
||||
case utils_1.AST_NODE_TYPES.ChainExpression:
|
||||
return getOperatorPrecedenceForNode(node.expression);
|
||||
case utils_1.AST_NODE_TYPES.CallExpression:
|
||||
return OperatorPrecedence.LeftHandSide;
|
||||
case utils_1.AST_NODE_TYPES.NewExpression:
|
||||
return node.arguments.length > 0
|
||||
? OperatorPrecedence.Member
|
||||
: OperatorPrecedence.LeftHandSide;
|
||||
case utils_1.AST_NODE_TYPES.TaggedTemplateExpression:
|
||||
case utils_1.AST_NODE_TYPES.MemberExpression:
|
||||
case utils_1.AST_NODE_TYPES.MetaProperty:
|
||||
return OperatorPrecedence.Member;
|
||||
case utils_1.AST_NODE_TYPES.TSAsExpression:
|
||||
return OperatorPrecedence.Relational;
|
||||
case utils_1.AST_NODE_TYPES.ThisExpression:
|
||||
case utils_1.AST_NODE_TYPES.Super:
|
||||
case utils_1.AST_NODE_TYPES.Identifier:
|
||||
case utils_1.AST_NODE_TYPES.PrivateIdentifier:
|
||||
case utils_1.AST_NODE_TYPES.Literal:
|
||||
case utils_1.AST_NODE_TYPES.ArrayExpression:
|
||||
case utils_1.AST_NODE_TYPES.ObjectExpression:
|
||||
case utils_1.AST_NODE_TYPES.FunctionExpression:
|
||||
case utils_1.AST_NODE_TYPES.ClassExpression:
|
||||
case utils_1.AST_NODE_TYPES.TemplateLiteral:
|
||||
case utils_1.AST_NODE_TYPES.JSXElement:
|
||||
case utils_1.AST_NODE_TYPES.JSXFragment:
|
||||
// we don't have nodes for these cases
|
||||
// case SyntaxKind.ParenthesizedExpression:
|
||||
// case SyntaxKind.OmittedExpression:
|
||||
return OperatorPrecedence.Primary;
|
||||
default:
|
||||
return OperatorPrecedence.Invalid;
|
||||
}
|
||||
}
|
||||
function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
|
||||
switch (nodeKind) {
|
||||
// A list of comma-separated expressions. This node is only created by transformations.
|
||||
case typescript_1.SyntaxKind.CommaListExpression:
|
||||
return OperatorPrecedence.Comma;
|
||||
case typescript_1.SyntaxKind.SpreadElement:
|
||||
return OperatorPrecedence.Spread;
|
||||
case typescript_1.SyntaxKind.YieldExpression:
|
||||
return OperatorPrecedence.Yield;
|
||||
case typescript_1.SyntaxKind.ConditionalExpression:
|
||||
return OperatorPrecedence.Conditional;
|
||||
case typescript_1.SyntaxKind.BinaryExpression:
|
||||
switch (operatorKind) {
|
||||
case typescript_1.SyntaxKind.AmpersandAmpersandEqualsToken:
|
||||
case typescript_1.SyntaxKind.AmpersandEqualsToken:
|
||||
case typescript_1.SyntaxKind.AsteriskAsteriskEqualsToken:
|
||||
case typescript_1.SyntaxKind.AsteriskEqualsToken:
|
||||
case typescript_1.SyntaxKind.BarBarEqualsToken:
|
||||
case typescript_1.SyntaxKind.BarEqualsToken:
|
||||
case typescript_1.SyntaxKind.CaretEqualsToken:
|
||||
case typescript_1.SyntaxKind.EqualsToken:
|
||||
case typescript_1.SyntaxKind.GreaterThanGreaterThanEqualsToken:
|
||||
case typescript_1.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
|
||||
case typescript_1.SyntaxKind.LessThanLessThanEqualsToken:
|
||||
case typescript_1.SyntaxKind.MinusEqualsToken:
|
||||
case typescript_1.SyntaxKind.PercentEqualsToken:
|
||||
case typescript_1.SyntaxKind.PlusEqualsToken:
|
||||
case typescript_1.SyntaxKind.QuestionQuestionEqualsToken:
|
||||
case typescript_1.SyntaxKind.SlashEqualsToken:
|
||||
return OperatorPrecedence.Assignment;
|
||||
case typescript_1.SyntaxKind.CommaToken:
|
||||
return OperatorPrecedence.Comma;
|
||||
default:
|
||||
return getBinaryOperatorPrecedence(operatorKind);
|
||||
}
|
||||
// TODO: Should prefix `++` and `--` be moved to the `Update` precedence?
|
||||
case typescript_1.SyntaxKind.TypeAssertionExpression:
|
||||
case typescript_1.SyntaxKind.NonNullExpression:
|
||||
case typescript_1.SyntaxKind.PrefixUnaryExpression:
|
||||
case typescript_1.SyntaxKind.TypeOfExpression:
|
||||
case typescript_1.SyntaxKind.VoidExpression:
|
||||
case typescript_1.SyntaxKind.DeleteExpression:
|
||||
case typescript_1.SyntaxKind.AwaitExpression:
|
||||
return OperatorPrecedence.Unary;
|
||||
case typescript_1.SyntaxKind.PostfixUnaryExpression:
|
||||
return OperatorPrecedence.Update;
|
||||
case typescript_1.SyntaxKind.CallExpression:
|
||||
return OperatorPrecedence.LeftHandSide;
|
||||
case typescript_1.SyntaxKind.NewExpression:
|
||||
return hasArguments
|
||||
? OperatorPrecedence.Member
|
||||
: OperatorPrecedence.LeftHandSide;
|
||||
case typescript_1.SyntaxKind.TaggedTemplateExpression:
|
||||
case typescript_1.SyntaxKind.PropertyAccessExpression:
|
||||
case typescript_1.SyntaxKind.ElementAccessExpression:
|
||||
case typescript_1.SyntaxKind.MetaProperty:
|
||||
return OperatorPrecedence.Member;
|
||||
case typescript_1.SyntaxKind.AsExpression:
|
||||
case typescript_1.SyntaxKind.SatisfiesExpression:
|
||||
return OperatorPrecedence.Relational;
|
||||
case typescript_1.SyntaxKind.ThisKeyword:
|
||||
case typescript_1.SyntaxKind.SuperKeyword:
|
||||
case typescript_1.SyntaxKind.Identifier:
|
||||
case typescript_1.SyntaxKind.PrivateIdentifier:
|
||||
case typescript_1.SyntaxKind.NullKeyword:
|
||||
case typescript_1.SyntaxKind.TrueKeyword:
|
||||
case typescript_1.SyntaxKind.FalseKeyword:
|
||||
case typescript_1.SyntaxKind.NumericLiteral:
|
||||
case typescript_1.SyntaxKind.BigIntLiteral:
|
||||
case typescript_1.SyntaxKind.StringLiteral:
|
||||
case typescript_1.SyntaxKind.ArrayLiteralExpression:
|
||||
case typescript_1.SyntaxKind.ObjectLiteralExpression:
|
||||
case typescript_1.SyntaxKind.FunctionExpression:
|
||||
case typescript_1.SyntaxKind.ArrowFunction:
|
||||
case typescript_1.SyntaxKind.ClassExpression:
|
||||
case typescript_1.SyntaxKind.RegularExpressionLiteral:
|
||||
case typescript_1.SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case typescript_1.SyntaxKind.TemplateExpression:
|
||||
case typescript_1.SyntaxKind.ParenthesizedExpression:
|
||||
case typescript_1.SyntaxKind.OmittedExpression:
|
||||
case typescript_1.SyntaxKind.JsxElement:
|
||||
case typescript_1.SyntaxKind.JsxSelfClosingElement:
|
||||
case typescript_1.SyntaxKind.JsxFragment:
|
||||
return OperatorPrecedence.Primary;
|
||||
default:
|
||||
return OperatorPrecedence.Invalid;
|
||||
}
|
||||
}
|
||||
function getBinaryOperatorPrecedence(kind) {
|
||||
switch (kind) {
|
||||
case '-':
|
||||
case '+':
|
||||
case typescript_1.SyntaxKind.MinusToken:
|
||||
case typescript_1.SyntaxKind.PlusToken:
|
||||
return OperatorPrecedence.Additive;
|
||||
case '!=':
|
||||
case '!==':
|
||||
case '==':
|
||||
case '===':
|
||||
case typescript_1.SyntaxKind.EqualsEqualsEqualsToken:
|
||||
case typescript_1.SyntaxKind.EqualsEqualsToken:
|
||||
case typescript_1.SyntaxKind.ExclamationEqualsEqualsToken:
|
||||
case typescript_1.SyntaxKind.ExclamationEqualsToken:
|
||||
return OperatorPrecedence.Equality;
|
||||
case '??':
|
||||
case typescript_1.SyntaxKind.QuestionQuestionToken:
|
||||
return OperatorPrecedence.Coalesce;
|
||||
case '*':
|
||||
case '/':
|
||||
case '%':
|
||||
case typescript_1.SyntaxKind.AsteriskToken:
|
||||
case typescript_1.SyntaxKind.PercentToken:
|
||||
case typescript_1.SyntaxKind.SlashToken:
|
||||
return OperatorPrecedence.Multiplicative;
|
||||
case '**':
|
||||
case typescript_1.SyntaxKind.AsteriskAsteriskToken:
|
||||
return OperatorPrecedence.Exponentiation;
|
||||
case '&':
|
||||
case typescript_1.SyntaxKind.AmpersandToken:
|
||||
return OperatorPrecedence.BitwiseAND;
|
||||
case '&&':
|
||||
case typescript_1.SyntaxKind.AmpersandAmpersandToken:
|
||||
return OperatorPrecedence.LogicalAND;
|
||||
case '^':
|
||||
case typescript_1.SyntaxKind.CaretToken:
|
||||
return OperatorPrecedence.BitwiseXOR;
|
||||
case '<':
|
||||
case '<=':
|
||||
case '>':
|
||||
case '>=':
|
||||
case 'in':
|
||||
case 'instanceof':
|
||||
case typescript_1.SyntaxKind.AsKeyword:
|
||||
case typescript_1.SyntaxKind.GreaterThanEqualsToken:
|
||||
case typescript_1.SyntaxKind.GreaterThanToken:
|
||||
case typescript_1.SyntaxKind.InKeyword:
|
||||
case typescript_1.SyntaxKind.InstanceOfKeyword:
|
||||
case typescript_1.SyntaxKind.LessThanEqualsToken:
|
||||
case typescript_1.SyntaxKind.LessThanToken:
|
||||
// case 'as': -- we don't have a token for this
|
||||
return OperatorPrecedence.Relational;
|
||||
case '<<':
|
||||
case '>>':
|
||||
case '>>>':
|
||||
case typescript_1.SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
|
||||
case typescript_1.SyntaxKind.GreaterThanGreaterThanToken:
|
||||
case typescript_1.SyntaxKind.LessThanLessThanToken:
|
||||
return OperatorPrecedence.Shift;
|
||||
case '|':
|
||||
case typescript_1.SyntaxKind.BarToken:
|
||||
return OperatorPrecedence.BitwiseOR;
|
||||
case '||':
|
||||
case typescript_1.SyntaxKind.BarBarToken:
|
||||
return OperatorPrecedence.LogicalOR;
|
||||
}
|
||||
// -1 is lower than all other precedences. Returning it will cause binary expression
|
||||
// parsing to stop.
|
||||
return -1;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
'use strict'
|
||||
|
||||
const { test } = require('node:test')
|
||||
const { spawnSync } = require('node:child_process')
|
||||
const { resolve } = require('node:path')
|
||||
|
||||
const entry = resolve(__dirname, '../examples', 'example.js')
|
||||
|
||||
test('--no-warnings is set in cli', t => {
|
||||
t.plan(1)
|
||||
const child = spawnSync(process.execPath, [
|
||||
'--no-warnings',
|
||||
entry
|
||||
])
|
||||
|
||||
const stderr = child.stderr.toString()
|
||||
t.assert.deepStrictEqual(stderr, '')
|
||||
})
|
||||
|
||||
test('--no-warnings is not set in cli', t => {
|
||||
t.plan(1)
|
||||
const child = spawnSync(process.execPath, [
|
||||
entry
|
||||
])
|
||||
|
||||
const stderr = child.stderr.toString()
|
||||
t.assert.match(stderr, /\[CUSTDEP001\] DeprecationWarning: This is a deprecation warning/)
|
||||
})
|
||||
|
||||
test('NODE_NO_WARNINGS is set to 1', t => {
|
||||
t.plan(1)
|
||||
const child = spawnSync(process.execPath, [
|
||||
entry
|
||||
], {
|
||||
env: {
|
||||
NODE_NO_WARNINGS: '1'
|
||||
}
|
||||
})
|
||||
|
||||
const stderr = child.stderr.toString()
|
||||
t.assert.deepStrictEqual(stderr, '')
|
||||
})
|
||||
|
||||
test('NODE_NO_WARNINGS is set to 0', t => {
|
||||
t.plan(1)
|
||||
const child = spawnSync(process.execPath, [
|
||||
entry
|
||||
], {
|
||||
env: {
|
||||
NODE_NO_WARNINGS: '0'
|
||||
}
|
||||
})
|
||||
|
||||
const stderr = child.stderr.toString()
|
||||
t.assert.match(stderr, /\[CUSTDEP001\] DeprecationWarning: This is a deprecation warning/)
|
||||
})
|
||||
|
||||
test('NODE_NO_WARNINGS is not set', t => {
|
||||
t.plan(1)
|
||||
const child = spawnSync(process.execPath, [
|
||||
entry
|
||||
])
|
||||
|
||||
const stderr = child.stderr.toString()
|
||||
t.assert.match(stderr, /\[CUSTDEP001\] DeprecationWarning: This is a deprecation warning/)
|
||||
})
|
||||
|
||||
test('NODE_Options contains --no-warnings', t => {
|
||||
t.plan(1)
|
||||
const child = spawnSync(process.execPath, [
|
||||
entry
|
||||
], {
|
||||
env: {
|
||||
NODE_OPTIONS: '--no-warnings'
|
||||
}
|
||||
})
|
||||
|
||||
const stderr = child.stderr.toString()
|
||||
t.assert.deepStrictEqual(stderr, '')
|
||||
})
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"signatureFlags.enum.d.ts","sourceRoot":"","sources":["../../src/enums/signatureFlags.enum.ts"],"names":[],"mappings":"AAEA,oBAAY,cAAc;IACtB,IAAI,IAAI;IACR,gBAAgB,IAAS;IACzB,eAAe,IAAS;IACxB,SAAS,IAAS;IAClB,QAAQ,IAAS;IACjB,gBAAgB,KAAS;IACzB,gBAAgB,KAAS;IACzB,0BAA0B,KAAS;IACnC,eAAe,MAAS;IACxB,sCAAsC,MAAS;IAC/C,gBAAgB,MAAkI;IAClJ,cAAc,KAAsC;CACvD"}
|
||||
Reference in New Issue
Block a user