@seljs/common 1.0.0 → 1.0.1-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abstracts/registry.cjs +41 -0
- package/dist/abstracts/registry.d.cts +43 -0
- package/dist/abstracts/registry.d.mts +43 -0
- package/dist/abstracts/registry.mjs +41 -0
- package/dist/ast.cjs +11 -0
- package/dist/{ast.js → ast.d.cts} +6 -5
- package/dist/{ast.d.ts → ast.d.mts} +6 -3
- package/dist/ast.mjs +11 -0
- package/dist/errors/base.cjs +16 -0
- package/dist/errors/{base.d.ts → base.d.cts} +5 -3
- package/dist/errors/base.d.mts +11 -0
- package/dist/errors/base.mjs +16 -0
- package/dist/errors/errors.cjs +15 -0
- package/dist/errors/{errors.js → errors.d.cts} +7 -5
- package/dist/errors/{errors.d.ts → errors.d.mts} +7 -6
- package/dist/errors/errors.mjs +14 -0
- package/dist/errors/utils.cjs +9 -0
- package/dist/errors/utils.d.cts +12 -0
- package/dist/errors/utils.d.mts +12 -0
- package/dist/errors/utils.mjs +9 -0
- package/dist/index.cjs +15 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +7 -0
- package/dist/naming.cjs +17 -0
- package/dist/{naming.d.ts → naming.d.cts} +5 -3
- package/dist/{naming.js → naming.d.mts} +5 -2
- package/dist/naming.mjs +16 -0
- package/package.json +17 -10
- package/dist/abstracts/index.d.ts +0 -2
- package/dist/abstracts/index.d.ts.map +0 -1
- package/dist/abstracts/index.js +0 -1
- package/dist/abstracts/registry.d.ts +0 -41
- package/dist/abstracts/registry.d.ts.map +0 -1
- package/dist/abstracts/registry.js +0 -39
- package/dist/abstracts/registry.test.d.ts +0 -2
- package/dist/abstracts/registry.test.d.ts.map +0 -1
- package/dist/abstracts/registry.test.js +0 -57
- package/dist/ast.d.ts.map +0 -1
- package/dist/errors/base.d.ts.map +0 -1
- package/dist/errors/base.js +0 -16
- package/dist/errors/base.test.d.ts +0 -2
- package/dist/errors/base.test.d.ts.map +0 -1
- package/dist/errors/base.test.js +0 -39
- package/dist/errors/errors.d.ts.map +0 -1
- package/dist/errors/errors.test.d.ts +0 -2
- package/dist/errors/errors.test.d.ts.map +0 -1
- package/dist/errors/errors.test.js +0 -104
- package/dist/errors/index.d.ts +0 -4
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js +0 -3
- package/dist/errors/utils.d.ts +0 -11
- package/dist/errors/utils.d.ts.map +0 -1
- package/dist/errors/utils.js +0 -6
- package/dist/errors/utils.test.d.ts +0 -2
- package/dist/errors/utils.test.d.ts.map +0 -1
- package/dist/errors/utils.test.js +0 -17
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4
- package/dist/naming.d.ts.map +0 -1
- package/dist/naming.test.d.ts +0 -2
- package/dist/naming.test.d.ts.map +0 -1
- package/dist/naming.test.js +0 -14
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/abstracts/registry.ts
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base registry providing a generic Map-based store
|
|
4
|
+
* with lookup by name.
|
|
5
|
+
*
|
|
6
|
+
* Subclasses implement `register()` to handle domain-specific
|
|
7
|
+
* validation and transformation before storing entries.
|
|
8
|
+
*
|
|
9
|
+
* @typeParam TConfig - The input configuration type for registration
|
|
10
|
+
* @typeParam TEntry - The stored entry type (what gets retrieved)
|
|
11
|
+
*/
|
|
12
|
+
var Registry = class {
|
|
13
|
+
entries = /* @__PURE__ */ new Map();
|
|
14
|
+
/**
|
|
15
|
+
* Get a registered entry by name.
|
|
16
|
+
*
|
|
17
|
+
* @param name - The entry identifier
|
|
18
|
+
* @returns The stored entry, or undefined if not found
|
|
19
|
+
*/
|
|
20
|
+
get(name) {
|
|
21
|
+
return this.entries.get(name);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get all registered entries.
|
|
25
|
+
*
|
|
26
|
+
* @returns Array of all stored entries
|
|
27
|
+
*/
|
|
28
|
+
getAll() {
|
|
29
|
+
return Array.from(this.entries.values());
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Check whether an entry with the given name exists.
|
|
33
|
+
*
|
|
34
|
+
* @param name - The entry identifier
|
|
35
|
+
*/
|
|
36
|
+
has(name) {
|
|
37
|
+
return this.entries.has(name);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.Registry = Registry;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/abstracts/registry.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base registry providing a generic Map-based store
|
|
4
|
+
* with lookup by name.
|
|
5
|
+
*
|
|
6
|
+
* Subclasses implement `register()` to handle domain-specific
|
|
7
|
+
* validation and transformation before storing entries.
|
|
8
|
+
*
|
|
9
|
+
* @typeParam TConfig - The input configuration type for registration
|
|
10
|
+
* @typeParam TEntry - The stored entry type (what gets retrieved)
|
|
11
|
+
*/
|
|
12
|
+
declare abstract class Registry<TConfig, TEntry> {
|
|
13
|
+
protected readonly entries: Map<string, TEntry>;
|
|
14
|
+
/**
|
|
15
|
+
* Register an entry with domain-specific validation/transformation.
|
|
16
|
+
*
|
|
17
|
+
* @param name - Unique identifier for the entry
|
|
18
|
+
* @param config - Configuration to transform into a stored entry
|
|
19
|
+
* @returns this for method chaining
|
|
20
|
+
*/
|
|
21
|
+
abstract register(name: string, config: TConfig): this;
|
|
22
|
+
/**
|
|
23
|
+
* Get a registered entry by name.
|
|
24
|
+
*
|
|
25
|
+
* @param name - The entry identifier
|
|
26
|
+
* @returns The stored entry, or undefined if not found
|
|
27
|
+
*/
|
|
28
|
+
get(name: string): TEntry | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Get all registered entries.
|
|
31
|
+
*
|
|
32
|
+
* @returns Array of all stored entries
|
|
33
|
+
*/
|
|
34
|
+
getAll(): TEntry[];
|
|
35
|
+
/**
|
|
36
|
+
* Check whether an entry with the given name exists.
|
|
37
|
+
*
|
|
38
|
+
* @param name - The entry identifier
|
|
39
|
+
*/
|
|
40
|
+
has(name: string): boolean;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { Registry };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/abstracts/registry.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base registry providing a generic Map-based store
|
|
4
|
+
* with lookup by name.
|
|
5
|
+
*
|
|
6
|
+
* Subclasses implement `register()` to handle domain-specific
|
|
7
|
+
* validation and transformation before storing entries.
|
|
8
|
+
*
|
|
9
|
+
* @typeParam TConfig - The input configuration type for registration
|
|
10
|
+
* @typeParam TEntry - The stored entry type (what gets retrieved)
|
|
11
|
+
*/
|
|
12
|
+
declare abstract class Registry<TConfig, TEntry> {
|
|
13
|
+
protected readonly entries: Map<string, TEntry>;
|
|
14
|
+
/**
|
|
15
|
+
* Register an entry with domain-specific validation/transformation.
|
|
16
|
+
*
|
|
17
|
+
* @param name - Unique identifier for the entry
|
|
18
|
+
* @param config - Configuration to transform into a stored entry
|
|
19
|
+
* @returns this for method chaining
|
|
20
|
+
*/
|
|
21
|
+
abstract register(name: string, config: TConfig): this;
|
|
22
|
+
/**
|
|
23
|
+
* Get a registered entry by name.
|
|
24
|
+
*
|
|
25
|
+
* @param name - The entry identifier
|
|
26
|
+
* @returns The stored entry, or undefined if not found
|
|
27
|
+
*/
|
|
28
|
+
get(name: string): TEntry | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Get all registered entries.
|
|
31
|
+
*
|
|
32
|
+
* @returns Array of all stored entries
|
|
33
|
+
*/
|
|
34
|
+
getAll(): TEntry[];
|
|
35
|
+
/**
|
|
36
|
+
* Check whether an entry with the given name exists.
|
|
37
|
+
*
|
|
38
|
+
* @param name - The entry identifier
|
|
39
|
+
*/
|
|
40
|
+
has(name: string): boolean;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { Registry };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/abstracts/registry.ts
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base registry providing a generic Map-based store
|
|
4
|
+
* with lookup by name.
|
|
5
|
+
*
|
|
6
|
+
* Subclasses implement `register()` to handle domain-specific
|
|
7
|
+
* validation and transformation before storing entries.
|
|
8
|
+
*
|
|
9
|
+
* @typeParam TConfig - The input configuration type for registration
|
|
10
|
+
* @typeParam TEntry - The stored entry type (what gets retrieved)
|
|
11
|
+
*/
|
|
12
|
+
var Registry = class {
|
|
13
|
+
entries = /* @__PURE__ */ new Map();
|
|
14
|
+
/**
|
|
15
|
+
* Get a registered entry by name.
|
|
16
|
+
*
|
|
17
|
+
* @param name - The entry identifier
|
|
18
|
+
* @returns The stored entry, or undefined if not found
|
|
19
|
+
*/
|
|
20
|
+
get(name) {
|
|
21
|
+
return this.entries.get(name);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get all registered entries.
|
|
25
|
+
*
|
|
26
|
+
* @returns Array of all stored entries
|
|
27
|
+
*/
|
|
28
|
+
getAll() {
|
|
29
|
+
return Array.from(this.entries.values());
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Check whether an entry with the given name exists.
|
|
33
|
+
*
|
|
34
|
+
* @param name - The entry identifier
|
|
35
|
+
*/
|
|
36
|
+
has(name) {
|
|
37
|
+
return this.entries.has(name);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { Registry };
|
package/dist/ast.cjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/ast.ts
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether a value is a CEL AST node with `op` and `args` fields.
|
|
4
|
+
*
|
|
5
|
+
* Needed as a runtime guard when traversing into `args` branches that
|
|
6
|
+
* may contain primitives (e.g. string for `id`, LiteralValue for `value`)
|
|
7
|
+
* alongside nested AST nodes.
|
|
8
|
+
*/
|
|
9
|
+
const isAstNode = (value) => typeof value === "object" && value !== null && "op" in value && "args" in value && typeof value.op === "string";
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.isAstNode = isAstNode;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ASTNode } from "@marcbachmann/cel-js";
|
|
2
|
+
|
|
3
|
+
//#region src/ast.d.ts
|
|
1
4
|
/**
|
|
2
5
|
* Checks whether a value is a CEL AST node with `op` and `args` fields.
|
|
3
6
|
*
|
|
@@ -5,8 +8,6 @@
|
|
|
5
8
|
* may contain primitives (e.g. string for `id`, LiteralValue for `value`)
|
|
6
9
|
* alongside nested AST nodes.
|
|
7
10
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"args" in value &&
|
|
12
|
-
typeof value.op === "string";
|
|
11
|
+
declare const isAstNode: (value: unknown) => value is ASTNode;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { isAstNode };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ASTNode } from "@marcbachmann/cel-js";
|
|
2
|
+
|
|
3
|
+
//#region src/ast.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Checks whether a value is a CEL AST node with `op` and `args` fields.
|
|
4
6
|
*
|
|
@@ -6,5 +8,6 @@ import type { ASTNode } from "@marcbachmann/cel-js";
|
|
|
6
8
|
* may contain primitives (e.g. string for `id`, LiteralValue for `value`)
|
|
7
9
|
* alongside nested AST nodes.
|
|
8
10
|
*/
|
|
9
|
-
|
|
10
|
-
//#
|
|
11
|
+
declare const isAstNode: (value: unknown) => value is ASTNode;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { isAstNode };
|
package/dist/ast.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/ast.ts
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether a value is a CEL AST node with `op` and `args` fields.
|
|
4
|
+
*
|
|
5
|
+
* Needed as a runtime guard when traversing into `args` branches that
|
|
6
|
+
* may contain primitives (e.g. string for `id`, LiteralValue for `value`)
|
|
7
|
+
* alongside nested AST nodes.
|
|
8
|
+
*/
|
|
9
|
+
const isAstNode = (value) => typeof value === "object" && value !== null && "op" in value && "args" in value && typeof value.op === "string";
|
|
10
|
+
//#endregion
|
|
11
|
+
export { isAstNode };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const require_utils = require("./utils.cjs");
|
|
2
|
+
//#region src/errors/base.ts
|
|
3
|
+
/**
|
|
4
|
+
* Base error class for SEL (Solidity Expression Language).
|
|
5
|
+
* All SEL errors extend this class, enabling catch-all handling
|
|
6
|
+
* via `instanceof SELError`.
|
|
7
|
+
*/
|
|
8
|
+
var SELError = class extends Error {
|
|
9
|
+
constructor(message, options) {
|
|
10
|
+
super(message, options);
|
|
11
|
+
this.name = this.constructor.name;
|
|
12
|
+
if (require_utils.hasCaptureStackTrace(Error)) Error.captureStackTrace(this, this.constructor);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.SELError = SELError;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
//#region src/errors/base.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Base error class for SEL (Solidity Expression Language).
|
|
3
4
|
* All SEL errors extend this class, enabling catch-all handling
|
|
4
5
|
* via `instanceof SELError`.
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
declare class SELError extends Error {
|
|
8
|
+
constructor(message: string, options?: ErrorOptions);
|
|
8
9
|
}
|
|
9
|
-
//#
|
|
10
|
+
//#endregion
|
|
11
|
+
export { SELError };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/errors/base.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Base error class for SEL (Solidity Expression Language).
|
|
4
|
+
* All SEL errors extend this class, enabling catch-all handling
|
|
5
|
+
* via `instanceof SELError`.
|
|
6
|
+
*/
|
|
7
|
+
declare class SELError extends Error {
|
|
8
|
+
constructor(message: string, options?: ErrorOptions);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { SELError };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { hasCaptureStackTrace } from "./utils.mjs";
|
|
2
|
+
//#region src/errors/base.ts
|
|
3
|
+
/**
|
|
4
|
+
* Base error class for SEL (Solidity Expression Language).
|
|
5
|
+
* All SEL errors extend this class, enabling catch-all handling
|
|
6
|
+
* via `instanceof SELError`.
|
|
7
|
+
*/
|
|
8
|
+
var SELError = class extends Error {
|
|
9
|
+
constructor(message, options) {
|
|
10
|
+
super(message, options);
|
|
11
|
+
this.name = this.constructor.name;
|
|
12
|
+
if (hasCaptureStackTrace(Error)) Error.captureStackTrace(this, this.constructor);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { SELError };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const require_base = require("./base.cjs");
|
|
2
|
+
//#region src/errors/errors.ts
|
|
3
|
+
/**
|
|
4
|
+
* Thrown when CEL expression parsing fails.
|
|
5
|
+
* Wraps cel-js ParseError with additional context.
|
|
6
|
+
*/
|
|
7
|
+
var SELParseError = class extends require_base.SELError {};
|
|
8
|
+
/**
|
|
9
|
+
* Thrown when Solidity type validation fails.
|
|
10
|
+
* Used for type checking errors specific to Solidity types.
|
|
11
|
+
*/
|
|
12
|
+
var SELTypeError = class extends require_base.SELError {};
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.SELParseError = SELParseError;
|
|
15
|
+
exports.SELTypeError = SELTypeError;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { SELError } from "./base.
|
|
1
|
+
import { SELError } from "./base.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/errors/errors.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Thrown when CEL expression parsing fails.
|
|
4
6
|
* Wraps cel-js ParseError with additional context.
|
|
5
7
|
*/
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
+
declare class SELParseError extends SELError {}
|
|
8
9
|
/**
|
|
9
10
|
* Thrown when Solidity type validation fails.
|
|
10
11
|
* Used for type checking errors specific to Solidity types.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
declare class SELTypeError extends SELError {}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { SELParseError, SELTypeError };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { SELError } from "./base.
|
|
1
|
+
import { SELError } from "./base.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/errors/errors.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Thrown when CEL expression parsing fails.
|
|
4
6
|
* Wraps cel-js ParseError with additional context.
|
|
5
7
|
*/
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
+
declare class SELParseError extends SELError {}
|
|
8
9
|
/**
|
|
9
10
|
* Thrown when Solidity type validation fails.
|
|
10
11
|
* Used for type checking errors specific to Solidity types.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
declare class SELTypeError extends SELError {}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { SELParseError, SELTypeError };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SELError } from "./base.mjs";
|
|
2
|
+
//#region src/errors/errors.ts
|
|
3
|
+
/**
|
|
4
|
+
* Thrown when CEL expression parsing fails.
|
|
5
|
+
* Wraps cel-js ParseError with additional context.
|
|
6
|
+
*/
|
|
7
|
+
var SELParseError = class extends SELError {};
|
|
8
|
+
/**
|
|
9
|
+
* Thrown when Solidity type validation fails.
|
|
10
|
+
* Used for type checking errors specific to Solidity types.
|
|
11
|
+
*/
|
|
12
|
+
var SELTypeError = class extends SELError {};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { SELParseError, SELTypeError };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/errors/utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if the Error constructor has the captureStackTrace method.
|
|
4
|
+
*
|
|
5
|
+
* @param error
|
|
6
|
+
*/
|
|
7
|
+
const hasCaptureStackTrace = (error) => "captureStackTrace" in error;
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.hasCaptureStackTrace = hasCaptureStackTrace;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/errors/utils.d.ts
|
|
2
|
+
type ErrorWithCaptureStackTrace = typeof Error & {
|
|
3
|
+
captureStackTrace: (target: object, constructor: unknown) => void;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Type guard to check if the Error constructor has the captureStackTrace method.
|
|
7
|
+
*
|
|
8
|
+
* @param error
|
|
9
|
+
*/
|
|
10
|
+
declare const hasCaptureStackTrace: (error: typeof Error) => error is ErrorWithCaptureStackTrace;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { hasCaptureStackTrace };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/errors/utils.d.ts
|
|
2
|
+
type ErrorWithCaptureStackTrace = typeof Error & {
|
|
3
|
+
captureStackTrace: (target: object, constructor: unknown) => void;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Type guard to check if the Error constructor has the captureStackTrace method.
|
|
7
|
+
*
|
|
8
|
+
* @param error
|
|
9
|
+
*/
|
|
10
|
+
declare const hasCaptureStackTrace: (error: typeof Error) => error is ErrorWithCaptureStackTrace;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { hasCaptureStackTrace };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/errors/utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if the Error constructor has the captureStackTrace method.
|
|
4
|
+
*
|
|
5
|
+
* @param error
|
|
6
|
+
*/
|
|
7
|
+
const hasCaptureStackTrace = (error) => "captureStackTrace" in error;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { hasCaptureStackTrace };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils = require("./errors/utils.cjs");
|
|
3
|
+
const require_base = require("./errors/base.cjs");
|
|
4
|
+
const require_errors = require("./errors/errors.cjs");
|
|
5
|
+
const require_registry = require("./abstracts/registry.cjs");
|
|
6
|
+
const require_naming = require("./naming.cjs");
|
|
7
|
+
const require_ast = require("./ast.cjs");
|
|
8
|
+
exports.Registry = require_registry.Registry;
|
|
9
|
+
exports.SELError = require_base.SELError;
|
|
10
|
+
exports.SELParseError = require_errors.SELParseError;
|
|
11
|
+
exports.SELTypeError = require_errors.SELTypeError;
|
|
12
|
+
exports.contractTypeName = require_naming.contractTypeName;
|
|
13
|
+
exports.hasCaptureStackTrace = require_utils.hasCaptureStackTrace;
|
|
14
|
+
exports.isAstNode = require_ast.isAstNode;
|
|
15
|
+
exports.structTypeName = require_naming.structTypeName;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SELError } from "./errors/base.cjs";
|
|
2
|
+
import { SELParseError, SELTypeError } from "./errors/errors.cjs";
|
|
3
|
+
import { hasCaptureStackTrace } from "./errors/utils.cjs";
|
|
4
|
+
import { Registry } from "./abstracts/registry.cjs";
|
|
5
|
+
import { contractTypeName, structTypeName } from "./naming.cjs";
|
|
6
|
+
import { isAstNode } from "./ast.cjs";
|
|
7
|
+
export { Registry, SELError, SELParseError, SELTypeError, contractTypeName, hasCaptureStackTrace, isAstNode, structTypeName };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SELError } from "./errors/base.mjs";
|
|
2
|
+
import { SELParseError, SELTypeError } from "./errors/errors.mjs";
|
|
3
|
+
import { hasCaptureStackTrace } from "./errors/utils.mjs";
|
|
4
|
+
import { Registry } from "./abstracts/registry.mjs";
|
|
5
|
+
import { contractTypeName, structTypeName } from "./naming.mjs";
|
|
6
|
+
import { isAstNode } from "./ast.mjs";
|
|
7
|
+
export { Registry, SELError, SELParseError, SELTypeError, contractTypeName, hasCaptureStackTrace, isAstNode, structTypeName };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { hasCaptureStackTrace } from "./errors/utils.mjs";
|
|
2
|
+
import { SELError } from "./errors/base.mjs";
|
|
3
|
+
import { SELParseError, SELTypeError } from "./errors/errors.mjs";
|
|
4
|
+
import { Registry } from "./abstracts/registry.mjs";
|
|
5
|
+
import { contractTypeName, structTypeName } from "./naming.mjs";
|
|
6
|
+
import { isAstNode } from "./ast.mjs";
|
|
7
|
+
export { Registry, SELError, SELParseError, SELTypeError, contractTypeName, hasCaptureStackTrace, isAstNode, structTypeName };
|
package/dist/naming.cjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/naming.ts
|
|
2
|
+
/**
|
|
3
|
+
* Generates the CEL type name for a contract.
|
|
4
|
+
*
|
|
5
|
+
* @param contractName Raw name of the contract.
|
|
6
|
+
*/
|
|
7
|
+
const contractTypeName = (contractName) => `SEL_Contract_${contractName}`;
|
|
8
|
+
/**
|
|
9
|
+
* Generates the CEL type name for a struct return type.
|
|
10
|
+
*
|
|
11
|
+
* @param contractName Raw name of the contract.
|
|
12
|
+
* @param functionName Raw name of the method.
|
|
13
|
+
*/
|
|
14
|
+
const structTypeName = (contractName, functionName) => `SEL_Struct_${contractName}_${functionName}`;
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.contractTypeName = contractTypeName;
|
|
17
|
+
exports.structTypeName = structTypeName;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
//#region src/naming.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Generates the CEL type name for a contract.
|
|
3
4
|
*
|
|
4
5
|
* @param contractName Raw name of the contract.
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
declare const contractTypeName: (contractName: string) => string;
|
|
7
8
|
/**
|
|
8
9
|
* Generates the CEL type name for a struct return type.
|
|
9
10
|
*
|
|
10
11
|
* @param contractName Raw name of the contract.
|
|
11
12
|
* @param functionName Raw name of the method.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
-
//#
|
|
14
|
+
declare const structTypeName: (contractName: string, functionName: string) => string;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { contractTypeName, structTypeName };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
//#region src/naming.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Generates the CEL type name for a contract.
|
|
3
4
|
*
|
|
4
5
|
* @param contractName Raw name of the contract.
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
declare const contractTypeName: (contractName: string) => string;
|
|
7
8
|
/**
|
|
8
9
|
* Generates the CEL type name for a struct return type.
|
|
9
10
|
*
|
|
10
11
|
* @param contractName Raw name of the contract.
|
|
11
12
|
* @param functionName Raw name of the method.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
declare const structTypeName: (contractName: string, functionName: string) => string;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { contractTypeName, structTypeName };
|
package/dist/naming.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/naming.ts
|
|
2
|
+
/**
|
|
3
|
+
* Generates the CEL type name for a contract.
|
|
4
|
+
*
|
|
5
|
+
* @param contractName Raw name of the contract.
|
|
6
|
+
*/
|
|
7
|
+
const contractTypeName = (contractName) => `SEL_Contract_${contractName}`;
|
|
8
|
+
/**
|
|
9
|
+
* Generates the CEL type name for a struct return type.
|
|
10
|
+
*
|
|
11
|
+
* @param contractName Raw name of the contract.
|
|
12
|
+
* @param functionName Raw name of the method.
|
|
13
|
+
*/
|
|
14
|
+
const structTypeName = (contractName, functionName) => `SEL_Struct_${contractName}_${functionName}`;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { contractTypeName, structTypeName };
|
package/package.json
CHANGED
|
@@ -1,30 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seljs/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1-beta.9",
|
|
4
|
+
"repository": {
|
|
5
|
+
"url": "https://github.com/abinnovision/seljs"
|
|
6
|
+
},
|
|
4
7
|
"license": "Apache-2.0",
|
|
5
8
|
"author": {
|
|
6
9
|
"name": "abi group GmbH",
|
|
7
10
|
"email": "info@abigroup.io",
|
|
8
11
|
"url": "https://abigroup.io/"
|
|
9
12
|
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"url": "https://github.com/abinnovision/seljs"
|
|
12
|
-
},
|
|
13
13
|
"type": "module",
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
|
-
"import":
|
|
17
|
-
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./dist/index.d.mts",
|
|
18
|
+
"default": "./dist/index.mjs"
|
|
19
|
+
},
|
|
20
|
+
"require": {
|
|
21
|
+
"types": "./dist/index.d.cts",
|
|
22
|
+
"default": "./dist/index.cjs"
|
|
23
|
+
}
|
|
18
24
|
}
|
|
19
25
|
},
|
|
20
|
-
"main": "./dist/index.
|
|
21
|
-
"types": "./dist/index.d.
|
|
26
|
+
"main": "./dist/index.cjs",
|
|
27
|
+
"types": "./dist/index.d.cts",
|
|
22
28
|
"files": [
|
|
23
29
|
"dist",
|
|
24
30
|
"LICENSE.md"
|
|
25
31
|
],
|
|
26
32
|
"scripts": {
|
|
27
|
-
"build": "
|
|
33
|
+
"build": "tsdown",
|
|
28
34
|
"format:check": "prettier --check '{{src,test}/**/*,*}.{{t,j}s{,x},json{,5},md,y{,a}ml}'",
|
|
29
35
|
"format:fix": "prettier --write '{{src,test}/**/*,*}.{{t,j}s{,x},json{,5},md,y{,a}ml}'",
|
|
30
36
|
"lint:check": "eslint '{{src,test}/**/*,*}.{t,j}s{,x}'",
|
|
@@ -42,7 +48,7 @@
|
|
|
42
48
|
]
|
|
43
49
|
},
|
|
44
50
|
"dependencies": {
|
|
45
|
-
"@marcbachmann/cel-js": "^7.5.
|
|
51
|
+
"@marcbachmann/cel-js": "^7.5.3"
|
|
46
52
|
},
|
|
47
53
|
"devDependencies": {
|
|
48
54
|
"@abinnovision/eslint-config-base": "^3.2.0",
|
|
@@ -50,6 +56,7 @@
|
|
|
50
56
|
"@seljs-internal/tsconfig": "^0.0.0",
|
|
51
57
|
"eslint": "^9.39.4",
|
|
52
58
|
"prettier": "^3.8.1",
|
|
59
|
+
"tsdown": "^0.21.3",
|
|
53
60
|
"typescript": "^5.9.3",
|
|
54
61
|
"vitest": "^4.0.18"
|
|
55
62
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/abstracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
package/dist/abstracts/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./registry.js";
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Abstract base registry providing a generic Map-based store
|
|
3
|
-
* with lookup by name.
|
|
4
|
-
*
|
|
5
|
-
* Subclasses implement `register()` to handle domain-specific
|
|
6
|
-
* validation and transformation before storing entries.
|
|
7
|
-
*
|
|
8
|
-
* @typeParam TConfig - The input configuration type for registration
|
|
9
|
-
* @typeParam TEntry - The stored entry type (what gets retrieved)
|
|
10
|
-
*/
|
|
11
|
-
export declare abstract class Registry<TConfig, TEntry> {
|
|
12
|
-
protected readonly entries: Map<string, TEntry>;
|
|
13
|
-
/**
|
|
14
|
-
* Register an entry with domain-specific validation/transformation.
|
|
15
|
-
*
|
|
16
|
-
* @param name - Unique identifier for the entry
|
|
17
|
-
* @param config - Configuration to transform into a stored entry
|
|
18
|
-
* @returns this for method chaining
|
|
19
|
-
*/
|
|
20
|
-
abstract register(name: string, config: TConfig): this;
|
|
21
|
-
/**
|
|
22
|
-
* Get a registered entry by name.
|
|
23
|
-
*
|
|
24
|
-
* @param name - The entry identifier
|
|
25
|
-
* @returns The stored entry, or undefined if not found
|
|
26
|
-
*/
|
|
27
|
-
get(name: string): TEntry | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* Get all registered entries.
|
|
30
|
-
*
|
|
31
|
-
* @returns Array of all stored entries
|
|
32
|
-
*/
|
|
33
|
-
getAll(): TEntry[];
|
|
34
|
-
/**
|
|
35
|
-
* Check whether an entry with the given name exists.
|
|
36
|
-
*
|
|
37
|
-
* @param name - The entry identifier
|
|
38
|
-
*/
|
|
39
|
-
has(name: string): boolean;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/abstracts/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,8BAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM;IAC7C,SAAS,CAAC,QAAQ,CAAC,OAAO,sBAA6B;IAEvD;;;;;;OAMG;aACa,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAE7D;;;;;OAKG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI5C;;;;OAIG;IACI,MAAM,IAAI,MAAM,EAAE;IAIzB;;;;OAIG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGjC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Abstract base registry providing a generic Map-based store
|
|
3
|
-
* with lookup by name.
|
|
4
|
-
*
|
|
5
|
-
* Subclasses implement `register()` to handle domain-specific
|
|
6
|
-
* validation and transformation before storing entries.
|
|
7
|
-
*
|
|
8
|
-
* @typeParam TConfig - The input configuration type for registration
|
|
9
|
-
* @typeParam TEntry - The stored entry type (what gets retrieved)
|
|
10
|
-
*/
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
12
|
-
export class Registry {
|
|
13
|
-
entries = new Map();
|
|
14
|
-
/**
|
|
15
|
-
* Get a registered entry by name.
|
|
16
|
-
*
|
|
17
|
-
* @param name - The entry identifier
|
|
18
|
-
* @returns The stored entry, or undefined if not found
|
|
19
|
-
*/
|
|
20
|
-
get(name) {
|
|
21
|
-
return this.entries.get(name);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Get all registered entries.
|
|
25
|
-
*
|
|
26
|
-
* @returns Array of all stored entries
|
|
27
|
-
*/
|
|
28
|
-
getAll() {
|
|
29
|
-
return Array.from(this.entries.values());
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Check whether an entry with the given name exists.
|
|
33
|
-
*
|
|
34
|
-
* @param name - The entry identifier
|
|
35
|
-
*/
|
|
36
|
-
has(name) {
|
|
37
|
-
return this.entries.has(name);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.test.d.ts","sourceRoot":"","sources":["../../src/abstracts/registry.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { Registry } from "./registry.js";
|
|
3
|
-
class TestRegistry extends Registry {
|
|
4
|
-
register(name, config) {
|
|
5
|
-
this.entries.set(name, { name, value: config.value });
|
|
6
|
-
return this;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
describe("registry", () => {
|
|
10
|
-
it("should register and retrieve an entry", () => {
|
|
11
|
-
const registry = new TestRegistry();
|
|
12
|
-
registry.register("test", { value: "hello" });
|
|
13
|
-
const entry = registry.get("test");
|
|
14
|
-
expect(entry).toEqual({ name: "test", value: "hello" });
|
|
15
|
-
});
|
|
16
|
-
it("should return undefined for unknown entries", () => {
|
|
17
|
-
const registry = new TestRegistry();
|
|
18
|
-
expect(registry.get("unknown")).toBeUndefined();
|
|
19
|
-
});
|
|
20
|
-
it("should check entry existence with has()", () => {
|
|
21
|
-
const registry = new TestRegistry();
|
|
22
|
-
registry.register("test", { value: "hello" });
|
|
23
|
-
expect(registry.has("test")).toBe(true);
|
|
24
|
-
expect(registry.has("unknown")).toBe(false);
|
|
25
|
-
});
|
|
26
|
-
it("should return all entries with getAll()", () => {
|
|
27
|
-
const registry = new TestRegistry();
|
|
28
|
-
registry.register("a", { value: "1" });
|
|
29
|
-
registry.register("b", { value: "2" });
|
|
30
|
-
const entries = registry.getAll();
|
|
31
|
-
expect(entries).toHaveLength(2);
|
|
32
|
-
expect(entries).toEqual(expect.arrayContaining([
|
|
33
|
-
{ name: "a", value: "1" },
|
|
34
|
-
{ name: "b", value: "2" },
|
|
35
|
-
]));
|
|
36
|
-
});
|
|
37
|
-
it("should return empty array when no entries registered", () => {
|
|
38
|
-
const registry = new TestRegistry();
|
|
39
|
-
expect(registry.getAll()).toEqual([]);
|
|
40
|
-
});
|
|
41
|
-
it("should overwrite entry on duplicate key registration", () => {
|
|
42
|
-
const registry = new TestRegistry();
|
|
43
|
-
registry.register("test", { value: "first" });
|
|
44
|
-
registry.register("test", { value: "second" });
|
|
45
|
-
const entry = registry.get("test");
|
|
46
|
-
expect(entry).toEqual({ name: "test", value: "second" });
|
|
47
|
-
expect(registry.getAll()).toHaveLength(1);
|
|
48
|
-
});
|
|
49
|
-
it("should support method chaining from register()", () => {
|
|
50
|
-
const registry = new TestRegistry();
|
|
51
|
-
const result = registry
|
|
52
|
-
.register("a", { value: "1" })
|
|
53
|
-
.register("b", { value: "2" });
|
|
54
|
-
expect(result).toBe(registry);
|
|
55
|
-
expect(registry.getAll()).toHaveLength(2);
|
|
56
|
-
});
|
|
57
|
-
});
|
package/dist/ast.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,OAKF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/errors/base.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,KAAK;gBACf,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAS1D"}
|
package/dist/errors/base.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { hasCaptureStackTrace } from "./utils.js";
|
|
2
|
-
/**
|
|
3
|
-
* Base error class for SEL (Solidity Expression Language).
|
|
4
|
-
* All SEL errors extend this class, enabling catch-all handling
|
|
5
|
-
* via `instanceof SELError`.
|
|
6
|
-
*/
|
|
7
|
-
export class SELError extends Error {
|
|
8
|
-
constructor(message, options) {
|
|
9
|
-
super(message, options);
|
|
10
|
-
this.name = this.constructor.name;
|
|
11
|
-
// Capture stack trace for better debugging (V8 engines).
|
|
12
|
-
if (hasCaptureStackTrace(Error)) {
|
|
13
|
-
Error.captureStackTrace(this, this.constructor);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.test.d.ts","sourceRoot":"","sources":["../../src/errors/base.test.ts"],"names":[],"mappings":""}
|
package/dist/errors/base.test.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { SELError } from "./base.js";
|
|
3
|
-
describe("sELError", () => {
|
|
4
|
-
it("should be an instance of Error", () => {
|
|
5
|
-
const error = new SELError("test message");
|
|
6
|
-
expect(error instanceof Error).toBe(true);
|
|
7
|
-
});
|
|
8
|
-
it("should be an instance of SELError", () => {
|
|
9
|
-
const error = new SELError("test message");
|
|
10
|
-
expect(error instanceof SELError).toBe(true);
|
|
11
|
-
});
|
|
12
|
-
it("should have correct name property", () => {
|
|
13
|
-
const error = new SELError("test message");
|
|
14
|
-
expect(error.name).toBe("SELError");
|
|
15
|
-
});
|
|
16
|
-
it("should have correct message property", () => {
|
|
17
|
-
const error = new SELError("test message");
|
|
18
|
-
expect(error.message).toBe("test message");
|
|
19
|
-
});
|
|
20
|
-
it("should support cause option", () => {
|
|
21
|
-
const originalError = new Error("original");
|
|
22
|
-
const error = new SELError("wrapped", { cause: originalError });
|
|
23
|
-
expect(error.cause).toBe(originalError);
|
|
24
|
-
});
|
|
25
|
-
it("should work without cause option", () => {
|
|
26
|
-
const error = new SELError("test message");
|
|
27
|
-
expect(error.cause).toBeUndefined();
|
|
28
|
-
});
|
|
29
|
-
it("should have a stack trace", () => {
|
|
30
|
-
const error = new SELError("test message");
|
|
31
|
-
expect(error.stack).toBeDefined();
|
|
32
|
-
});
|
|
33
|
-
it("should use subclass name when extended", () => {
|
|
34
|
-
class CustomError extends SELError {
|
|
35
|
-
}
|
|
36
|
-
const error = new CustomError("test");
|
|
37
|
-
expect(error.name).toBe("CustomError");
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC;;;GAGG;AACH,qBAAa,aAAc,SAAQ,QAAQ;CAAG;AAE9C;;;GAGG;AACH,qBAAa,YAAa,SAAQ,QAAQ;CAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.test.d.ts","sourceRoot":"","sources":["../../src/errors/errors.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { SELError } from "./base.js";
|
|
3
|
-
import { SELParseError, SELTypeError } from "./errors.js";
|
|
4
|
-
describe("sELParseError", () => {
|
|
5
|
-
it("should be an instance of Error", () => {
|
|
6
|
-
const error = new SELParseError("test message");
|
|
7
|
-
expect(error instanceof Error).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
it("should be an instance of SELParseError", () => {
|
|
10
|
-
const error = new SELParseError("test message");
|
|
11
|
-
expect(error instanceof SELParseError).toBe(true);
|
|
12
|
-
});
|
|
13
|
-
it("should be an instance of SELError", () => {
|
|
14
|
-
const error = new SELParseError("test message");
|
|
15
|
-
expect(error instanceof SELError).toBe(true);
|
|
16
|
-
});
|
|
17
|
-
it("should have correct name property", () => {
|
|
18
|
-
const error = new SELParseError("test message");
|
|
19
|
-
expect(error.name).toBe("SELParseError");
|
|
20
|
-
});
|
|
21
|
-
it("should have correct message property", () => {
|
|
22
|
-
const error = new SELParseError("test message");
|
|
23
|
-
expect(error.message).toBe("test message");
|
|
24
|
-
});
|
|
25
|
-
it("should support cause option", () => {
|
|
26
|
-
const originalError = new Error("original");
|
|
27
|
-
const error = new SELParseError("wrapped", { cause: originalError });
|
|
28
|
-
expect(error.cause).toBe(originalError);
|
|
29
|
-
});
|
|
30
|
-
it("should work without cause option", () => {
|
|
31
|
-
const error = new SELParseError("test message");
|
|
32
|
-
expect(error.cause).toBeUndefined();
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe("sELTypeError", () => {
|
|
36
|
-
it("should be an instance of Error", () => {
|
|
37
|
-
const error = new SELTypeError("test message");
|
|
38
|
-
expect(error instanceof Error).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
it("should be an instance of SELTypeError", () => {
|
|
41
|
-
const error = new SELTypeError("test message");
|
|
42
|
-
expect(error instanceof SELTypeError).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
it("should be an instance of SELError", () => {
|
|
45
|
-
const error = new SELTypeError("test message");
|
|
46
|
-
expect(error instanceof SELError).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
it("should have correct name property", () => {
|
|
49
|
-
const error = new SELTypeError("test message");
|
|
50
|
-
expect(error.name).toBe("SELTypeError");
|
|
51
|
-
});
|
|
52
|
-
it("should have correct message property", () => {
|
|
53
|
-
const error = new SELTypeError("test message");
|
|
54
|
-
expect(error.message).toBe("test message");
|
|
55
|
-
});
|
|
56
|
-
it("should support cause option", () => {
|
|
57
|
-
const originalError = new Error("original");
|
|
58
|
-
const error = new SELTypeError("wrapped", { cause: originalError });
|
|
59
|
-
expect(error.cause).toBe(originalError);
|
|
60
|
-
});
|
|
61
|
-
it("should work without cause option", () => {
|
|
62
|
-
const error = new SELTypeError("test message");
|
|
63
|
-
expect(error.cause).toBeUndefined();
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
describe("error class distinctions", () => {
|
|
67
|
-
it("should distinguish between different error types", () => {
|
|
68
|
-
const parseError = new SELParseError("parse");
|
|
69
|
-
const typeError = new SELTypeError("type");
|
|
70
|
-
expect(parseError instanceof SELParseError).toBe(true);
|
|
71
|
-
expect(parseError instanceof SELTypeError).toBe(false);
|
|
72
|
-
expect(typeError instanceof SELTypeError).toBe(true);
|
|
73
|
-
expect(typeError instanceof SELParseError).toBe(false);
|
|
74
|
-
});
|
|
75
|
-
it("should all be instances of SELError and Error", () => {
|
|
76
|
-
const parseError = new SELParseError("parse");
|
|
77
|
-
const typeError = new SELTypeError("type");
|
|
78
|
-
expect(parseError instanceof SELError).toBe(true);
|
|
79
|
-
expect(typeError instanceof SELError).toBe(true);
|
|
80
|
-
expect(parseError instanceof Error).toBe(true);
|
|
81
|
-
expect(typeError instanceof Error).toBe(true);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
describe("error wrapping with cause", () => {
|
|
85
|
-
it("should wrap multiple levels of errors", () => {
|
|
86
|
-
const originalError = new Error("original");
|
|
87
|
-
const wrappedError = new SELParseError("wrapped", {
|
|
88
|
-
cause: originalError,
|
|
89
|
-
});
|
|
90
|
-
const finalError = new SELTypeError("final", {
|
|
91
|
-
cause: wrappedError,
|
|
92
|
-
});
|
|
93
|
-
expect(finalError.cause).toBe(wrappedError);
|
|
94
|
-
expect(finalError.cause.cause).toBe(originalError);
|
|
95
|
-
});
|
|
96
|
-
it("should preserve error messages through wrapping", () => {
|
|
97
|
-
const originalError = new Error("original message");
|
|
98
|
-
const wrappedError = new SELParseError("wrapped message", {
|
|
99
|
-
cause: originalError,
|
|
100
|
-
});
|
|
101
|
-
expect(wrappedError.message).toBe("wrapped message");
|
|
102
|
-
expect(wrappedError.cause.message).toBe("original message");
|
|
103
|
-
});
|
|
104
|
-
});
|
package/dist/errors/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/errors/index.js
DELETED
package/dist/errors/utils.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
type ErrorWithCaptureStackTrace = typeof Error & {
|
|
2
|
-
captureStackTrace: (target: object, constructor: unknown) => void;
|
|
3
|
-
};
|
|
4
|
-
/**
|
|
5
|
-
* Type guard to check if the Error constructor has the captureStackTrace method.
|
|
6
|
-
*
|
|
7
|
-
* @param error
|
|
8
|
-
*/
|
|
9
|
-
export declare const hasCaptureStackTrace: (error: typeof Error) => error is ErrorWithCaptureStackTrace;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/errors/utils.ts"],"names":[],"mappings":"AAAA,KAAK,0BAA0B,GAAG,OAAO,KAAK,GAAG;IAChD,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,KAAK,IAAI,CAAC;CAClE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAChC,OAAO,OAAO,KAAK,KACjB,KAAK,IAAI,0BAA0D,CAAC"}
|
package/dist/errors/utils.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../src/errors/utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { hasCaptureStackTrace } from "./utils.js";
|
|
3
|
-
describe("hasCaptureStackTrace", () => {
|
|
4
|
-
it("should return true in V8 environments (Node.js)", () => {
|
|
5
|
-
expect(hasCaptureStackTrace(Error)).toBe(true);
|
|
6
|
-
});
|
|
7
|
-
it("should narrow the type to include captureStackTrace", () => {
|
|
8
|
-
expect(typeof Error.captureStackTrace).toBe("function");
|
|
9
|
-
});
|
|
10
|
-
it("should return false for objects without captureStackTrace", () => {
|
|
11
|
-
// Create a minimal object that looks like typeof Error but lacks captureStackTrace
|
|
12
|
-
const fakeError = {
|
|
13
|
-
prototype: Error.prototype,
|
|
14
|
-
};
|
|
15
|
-
expect(hasCaptureStackTrace(fakeError)).toBe(false);
|
|
16
|
-
});
|
|
17
|
-
});
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
|
package/dist/index.js
DELETED
package/dist/naming.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../src/naming.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,cAAc,MAAM,KAAG,MACzB,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAC1B,cAAc,MAAM,EACpB,cAAc,MAAM,KAClB,MAAsD,CAAC"}
|
package/dist/naming.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"naming.test.d.ts","sourceRoot":"","sources":["../src/naming.test.ts"],"names":[],"mappings":""}
|
package/dist/naming.test.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { contractTypeName, structTypeName } from "./naming.js";
|
|
3
|
-
describe("src/naming.ts", () => {
|
|
4
|
-
describe("contractTypeName", () => {
|
|
5
|
-
it("generates contract type name", () => {
|
|
6
|
-
expect(contractTypeName("pool")).toBe("SEL_Contract_pool");
|
|
7
|
-
});
|
|
8
|
-
});
|
|
9
|
-
describe("structTypeName", () => {
|
|
10
|
-
it("generates struct type name for contract and method", () => {
|
|
11
|
-
expect(structTypeName("pool", "getPool")).toBe("SEL_Struct_pool_getPool");
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
});
|