@ark/attest 0.12.0 → 0.12.1
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/out/assert/assertions.d.ts +5 -4
- package/out/assert/attest.d.ts +4 -4
- package/out/assert/chainableAssertions.d.ts +2 -2
- package/out/bench/baseline.d.ts +2 -2
- package/out/bench/bench.d.ts +5 -5
- package/out/bench/bench.js +3 -3
- package/out/bench/measure.d.ts +1 -1
- package/out/bench/type.d.ts +2 -2
- package/out/cache/getCachedAssertions.d.ts +1 -1
- package/out/cache/ts.d.ts +2 -2
- package/out/cache/ts.js +5 -5
- package/out/cache/utils.d.ts +1 -1
- package/out/cache/utils.js +4 -3
- package/out/cache/writeAssertionCache.d.ts +1 -1
- package/out/config.d.ts +1 -1
- package/out/fixtures.d.ts +1 -1
- package/out/index.d.ts +8 -8
- package/out/tsVersioning.js +2 -1
- package/out/utils.js +10 -3
- package/package.json +15 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TypeRelationshipAssertionData } from "../cache/writeAssertionCache.
|
|
2
|
-
import type { AssertionContext } from "./attest.
|
|
1
|
+
import type { TypeRelationshipAssertionData } from "../cache/writeAssertionCache.ts";
|
|
2
|
+
import type { AssertionContext } from "./attest.ts";
|
|
3
3
|
export type ThrowAssertionErrorContext = {
|
|
4
4
|
message: string;
|
|
5
5
|
expected?: unknown;
|
|
@@ -12,9 +12,10 @@ export type MappedTypeAssertionResult = {
|
|
|
12
12
|
actual: unknown;
|
|
13
13
|
expected?: unknown;
|
|
14
14
|
} | null;
|
|
15
|
+
export type TypeAssertionMapper = (data: TypeRelationshipAssertionData, ctx: AssertionContext) => MappedTypeAssertionResult;
|
|
15
16
|
export declare class TypeAssertionMapping {
|
|
16
|
-
fn:
|
|
17
|
-
constructor(fn:
|
|
17
|
+
fn: TypeAssertionMapper;
|
|
18
|
+
constructor(fn: TypeAssertionMapper);
|
|
18
19
|
}
|
|
19
20
|
export declare const versionableAssertion: (fn: AssertFn) => AssertFn;
|
|
20
21
|
export declare const assertEquals: AssertFn;
|
package/out/assert/attest.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type SourcePosition } from "@ark/fs";
|
|
2
2
|
import type { ErrorMessage } from "@ark/util";
|
|
3
|
-
import type { Measure } from "../bench/measure.
|
|
4
|
-
import { type VersionedTypeAssertion } from "../cache/getCachedAssertions.
|
|
5
|
-
import { type AttestConfig } from "../config.
|
|
6
|
-
import { ChainableAssertions, type AssertionKind, type rootAssertions } from "./chainableAssertions.
|
|
3
|
+
import type { Measure } from "../bench/measure.ts";
|
|
4
|
+
import { type VersionedTypeAssertion } from "../cache/getCachedAssertions.ts";
|
|
5
|
+
import { type AttestConfig } from "../config.ts";
|
|
6
|
+
import { ChainableAssertions, type AssertionKind, type rootAssertions } from "./chainableAssertions.ts";
|
|
7
7
|
export type AttestFn = {
|
|
8
8
|
<expected>(actual: expected): rootAssertions<expected, AssertionKind>;
|
|
9
9
|
<expected, actual extends expected = never>(...args: actual extends never ? [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { snapshot, type Constructor } from "@ark/util";
|
|
2
2
|
import { type validateTypeRoot } from "arktype";
|
|
3
|
-
import type { Completions } from "../cache/writeAssertionCache.
|
|
4
|
-
import type { AssertionContext } from "./attest.
|
|
3
|
+
import type { Completions } from "../cache/writeAssertionCache.ts";
|
|
4
|
+
import type { AssertionContext } from "./attest.ts";
|
|
5
5
|
export type ChainableAssertionOptions = {
|
|
6
6
|
allowRegex?: boolean;
|
|
7
7
|
defaultExpected?: unknown;
|
package/out/bench/baseline.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BenchContext } from "./bench.
|
|
2
|
-
import { type MarkMeasure, type Measure, type MeasureComparison } from "./measure.
|
|
1
|
+
import type { BenchContext } from "./bench.ts";
|
|
2
|
+
import { type MarkMeasure, type Measure, type MeasureComparison } from "./measure.ts";
|
|
3
3
|
export declare const queueBaselineUpdateIfNeeded: (updated: Measure | MarkMeasure, baseline: Measure | MarkMeasure | undefined, ctx: BenchContext) => void;
|
|
4
4
|
/** Pretty print comparison and set the process.exitCode to 1 if delta threshold is exceeded */
|
|
5
5
|
export declare const compareToBaseline: (result: MeasureComparison, ctx: BenchContext) => void;
|
package/out/bench/bench.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SourcePosition } from "@ark/fs";
|
|
2
|
-
import { type ParsedAttestConfig } from "../config.
|
|
3
|
-
import { type MarkMeasure, type Measure, type TimeUnit } from "./measure.
|
|
4
|
-
import { type BenchTypeAssertions } from "./type.
|
|
2
|
+
import { type ParsedAttestConfig } from "../config.ts";
|
|
3
|
+
import { type MarkMeasure, type Measure, type TimeUnit } from "./measure.ts";
|
|
4
|
+
import { type BenchTypeAssertions } from "./type.ts";
|
|
5
5
|
export type StatName = keyof typeof stats;
|
|
6
6
|
export type TimeAssertionName = StatName | "mark";
|
|
7
7
|
type BenchFn = <fn extends BenchableFunction>(name: string, fn: fn, options?: BenchOptions) => InitialBenchAssertions<fn>;
|
|
@@ -14,10 +14,10 @@ export declare const stats: {
|
|
|
14
14
|
median: (callTimes: number[]) => number;
|
|
15
15
|
};
|
|
16
16
|
export declare class BenchAssertions<Fn extends BenchableFunction, NextAssertions = BenchTypeAssertions, ReturnedAssertions = Fn extends () => Promise<void> ? Promise<NextAssertions> : NextAssertions> {
|
|
17
|
-
private fn;
|
|
18
|
-
private ctx;
|
|
19
17
|
private label;
|
|
20
18
|
private lastCallTimes;
|
|
19
|
+
private fn;
|
|
20
|
+
private ctx;
|
|
21
21
|
constructor(fn: Fn, ctx: BenchContext);
|
|
22
22
|
private applyCallTimeHooks;
|
|
23
23
|
private callTimesSync;
|
package/out/bench/bench.js
CHANGED
|
@@ -45,11 +45,11 @@ export const stats = {
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
class ResultCollector {
|
|
48
|
-
ctx;
|
|
49
48
|
results = [];
|
|
50
49
|
benchStart = performance.now();
|
|
51
50
|
bounds;
|
|
52
51
|
lastInvocationStart;
|
|
52
|
+
ctx;
|
|
53
53
|
constructor(ctx) {
|
|
54
54
|
this.ctx = ctx;
|
|
55
55
|
// By default, will run for either 5 seconds or 100_000 call sets (of 1000 calls), whichever comes first
|
|
@@ -95,10 +95,10 @@ const loopAsyncCalls = async (fn, ctx) => {
|
|
|
95
95
|
return collector.results;
|
|
96
96
|
};
|
|
97
97
|
export class BenchAssertions {
|
|
98
|
-
fn;
|
|
99
|
-
ctx;
|
|
100
98
|
label;
|
|
101
99
|
lastCallTimes;
|
|
100
|
+
fn;
|
|
101
|
+
ctx;
|
|
102
102
|
constructor(fn, ctx) {
|
|
103
103
|
this.fn = fn;
|
|
104
104
|
this.ctx = ctx;
|
package/out/bench/measure.d.ts
CHANGED
package/out/bench/type.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BenchContext } from "./bench.
|
|
2
|
-
import { type Measure, type TypeUnit } from "./measure.
|
|
1
|
+
import type { BenchContext } from "./bench.ts";
|
|
2
|
+
import { type Measure, type TypeUnit } from "./measure.ts";
|
|
3
3
|
export type BenchTypeAssertions = {
|
|
4
4
|
types: (instantiations?: Measure<TypeUnit>) => void;
|
|
5
5
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SourcePosition } from "@ark/fs";
|
|
2
|
-
import type { AssertionsByFile, TypeAssertionData, TypeAssertionKind } from "./writeAssertionCache.
|
|
2
|
+
import type { AssertionsByFile, TypeAssertionData, TypeAssertionKind } from "./writeAssertionCache.ts";
|
|
3
3
|
export type VersionedAssertionsByFile = [
|
|
4
4
|
tsVersion: string,
|
|
5
5
|
relationshipAssertions: AssertionsByFile,
|
package/out/cache/ts.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import { type SourcePosition } from "@ark/fs";
|
|
|
2
2
|
import * as tsvfs from "@typescript/vfs";
|
|
3
3
|
import ts from "typescript";
|
|
4
4
|
export declare class TsServer {
|
|
5
|
-
private tsConfigInfo;
|
|
6
5
|
rootFiles: string[];
|
|
7
6
|
virtualEnv: tsvfs.VirtualTypeScriptEnvironment;
|
|
8
7
|
program: ts.Program;
|
|
9
8
|
private static _instance;
|
|
10
9
|
static get instance(): TsServer;
|
|
11
|
-
private
|
|
10
|
+
private tsConfigInfo;
|
|
11
|
+
constructor(tsConfigInfo?: TsconfigInfo);
|
|
12
12
|
getSourceFileOrThrow(path: string): ts.SourceFile;
|
|
13
13
|
}
|
|
14
14
|
export declare const nearestCallExpressionChild: (node: ts.Node, position: number) => ts.CallExpression;
|
package/out/cache/ts.js
CHANGED
|
@@ -6,7 +6,6 @@ import { dirname, join } from "node:path";
|
|
|
6
6
|
import ts from "typescript";
|
|
7
7
|
import { getConfig } from "../config.js";
|
|
8
8
|
export class TsServer {
|
|
9
|
-
tsConfigInfo;
|
|
10
9
|
rootFiles;
|
|
11
10
|
virtualEnv;
|
|
12
11
|
program;
|
|
@@ -14,14 +13,15 @@ export class TsServer {
|
|
|
14
13
|
static get instance() {
|
|
15
14
|
return new TsServer();
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
tsConfigInfo;
|
|
17
|
+
constructor(tsConfigInfo) {
|
|
19
18
|
if (TsServer._instance)
|
|
20
19
|
return TsServer._instance;
|
|
21
|
-
|
|
20
|
+
this.tsConfigInfo = tsConfigInfo ?? getTsConfigInfoOrThrow();
|
|
21
|
+
const tsLibPaths = getTsLibFiles(this.tsConfigInfo.parsed.options);
|
|
22
22
|
// TS represents windows paths as `C:/Users/ssalb/...`
|
|
23
23
|
const normalizedCwd = fromCwd().replaceAll(/\\/g, "/");
|
|
24
|
-
this.rootFiles = tsConfigInfo.parsed.fileNames.filter(path => path.startsWith(normalizedCwd));
|
|
24
|
+
this.rootFiles = this.tsConfigInfo.parsed.fileNames.filter(path => path.startsWith(normalizedCwd));
|
|
25
25
|
const system = tsvfs.createFSBackedSystem(tsLibPaths.defaultMapFromNodeModules, dirname(this.tsConfigInfo.path), ts);
|
|
26
26
|
this.virtualEnv = tsvfs.createVirtualTypeScriptEnvironment(system, this.rootFiles, ts, this.tsConfigInfo.parsed.options);
|
|
27
27
|
this.program = this.virtualEnv.languageService.getProgram();
|
package/out/cache/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as tsvfs from "@typescript/vfs";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import type { AssertionsByFile, LinePositionRange } from "./writeAssertionCache.
|
|
3
|
+
import type { AssertionsByFile, LinePositionRange } from "./writeAssertionCache.ts";
|
|
4
4
|
export declare const getCallLocationFromCallExpression: (callExpression: ts.CallExpression) => LinePositionRange;
|
|
5
5
|
export declare const gatherInlineInstantiationData: (file: ts.SourceFile, fileAssertions: AssertionsByFile, attestAliasInstantiationMethodCalls: string[]) => void;
|
|
6
6
|
export declare const getCallExpressionsByName: (startNode: ts.Node, names: string[], isSnapCall?: boolean) => ts.CallExpression[];
|
package/out/cache/utils.js
CHANGED
|
@@ -76,9 +76,10 @@ export const getInstantiationsContributedByNode = (file, benchBlock) => {
|
|
|
76
76
|
return instantiationsWithNode - instantiationsByPath[fakePath];
|
|
77
77
|
};
|
|
78
78
|
export const createOrUpdateFile = (env, fileName, fileText) => {
|
|
79
|
-
env.sys.fileExists(fileName)
|
|
80
|
-
env.updateFile(fileName, fileText)
|
|
81
|
-
|
|
79
|
+
if (env.sys.fileExists(fileName))
|
|
80
|
+
env.updateFile(fileName, fileText);
|
|
81
|
+
else
|
|
82
|
+
env.createFile(fileName, fileText);
|
|
82
83
|
return env.getSourceFile(fileName);
|
|
83
84
|
};
|
|
84
85
|
const getInstantiationsWithFile = (fileText, fileName) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LinePosition } from "@ark/fs";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import { type StringifiableType } from "./ts.
|
|
3
|
+
import { type StringifiableType } from "./ts.ts";
|
|
4
4
|
export type AssertionsByFile = Record<string, TypeAssertionData[]>;
|
|
5
5
|
export declare const analyzeProjectAssertions: () => AssertionsByFile;
|
|
6
6
|
export declare const getAssertionsInFile: (file: ts.SourceFile, diagnosticsByFile: DiagnosticsByFile, attestAliases: string[]) => TypeAssertionData[];
|
package/out/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type autocomplete } from "@ark/util";
|
|
2
2
|
import type * as prettier from "prettier";
|
|
3
3
|
import type ts from "typescript";
|
|
4
|
-
import { type TsVersionData } from "./tsVersioning.
|
|
4
|
+
import { type TsVersionData } from "./tsVersioning.ts";
|
|
5
5
|
export type TsVersionAliases = autocomplete<"*"> | string[];
|
|
6
6
|
type BaseAttestConfig = {
|
|
7
7
|
tsconfig: string | undefined;
|
package/out/fixtures.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AttestConfig } from "./config.
|
|
1
|
+
import { type AttestConfig } from "./config.ts";
|
|
2
2
|
export declare const setup: (options?: Partial<AttestConfig>) => typeof teardown;
|
|
3
3
|
export declare const writeAssertionData: (toPath: string) => void;
|
|
4
4
|
export declare const cleanup: () => void;
|
package/out/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { cleanup, setup, teardown, writeAssertionData } from "./fixtures.
|
|
1
|
+
export { cleanup, setup, teardown, writeAssertionData } from "./fixtures.ts";
|
|
2
2
|
export { caller, type CallerOfOptions } from "@ark/fs";
|
|
3
|
-
export { attest } from "./assert/attest.
|
|
4
|
-
export { bench } from "./bench/bench.
|
|
5
|
-
export { getBenchAssertionsAtPosition, getTypeAssertionsAtPosition } from "./cache/getCachedAssertions.
|
|
6
|
-
export type { ArgAssertionData, LinePositionRange, TypeAssertionData, TypeRelationship } from "./cache/writeAssertionCache.
|
|
7
|
-
export { getDefaultAttestConfig, type AttestConfig } from "./config.
|
|
8
|
-
export { findAttestTypeScriptVersions, getPrimaryTsVersionUnderTest } from "./tsVersioning.
|
|
9
|
-
export { contextualize } from "./utils.
|
|
3
|
+
export { attest } from "./assert/attest.ts";
|
|
4
|
+
export { bench } from "./bench/bench.ts";
|
|
5
|
+
export { getBenchAssertionsAtPosition, getTypeAssertionsAtPosition } from "./cache/getCachedAssertions.ts";
|
|
6
|
+
export type { ArgAssertionData, LinePositionRange, TypeAssertionData, TypeRelationship } from "./cache/writeAssertionCache.ts";
|
|
7
|
+
export { getDefaultAttestConfig, type AttestConfig } from "./config.ts";
|
|
8
|
+
export { findAttestTypeScriptVersions, getPrimaryTsVersionUnderTest } from "./tsVersioning.ts";
|
|
9
|
+
export { contextualize } from "./utils.ts";
|
package/out/tsVersioning.js
CHANGED
|
@@ -102,7 +102,8 @@ export const findAttestTypeScriptVersions = () => {
|
|
|
102
102
|
if (!existsSync(path)) {
|
|
103
103
|
throw Error(`TypeScript version ${alias} specified in ${packageJsonPath} must be installed at ${path} `);
|
|
104
104
|
}
|
|
105
|
-
const version = readJson(join(path, "package.json"))
|
|
105
|
+
const version = readJson(join(path, "package.json"))
|
|
106
|
+
.version;
|
|
106
107
|
versions.push({
|
|
107
108
|
alias,
|
|
108
109
|
version,
|
package/out/utils.js
CHANGED
|
@@ -8,19 +8,26 @@ export const getFileKey = (path) => relative(".", path);
|
|
|
8
8
|
export const chainableNoOpProxy = new Proxy(() => chainableNoOpProxy, {
|
|
9
9
|
get: () => chainableNoOpProxy
|
|
10
10
|
});
|
|
11
|
+
const testDirName = "__tests__";
|
|
12
|
+
const testSuffix = ".test.ts";
|
|
11
13
|
const contextualizeRoot = (first, contextualTests) => {
|
|
12
14
|
const describe = globalThis.describe;
|
|
13
15
|
if (!describe) {
|
|
14
16
|
throw new Error(`contextualize cannot be used without a global 'describe' function.`);
|
|
15
17
|
}
|
|
16
|
-
const
|
|
18
|
+
const filePath = caller().file;
|
|
19
|
+
const testsDirChar = filePath.search(testDirName);
|
|
20
|
+
const suiteNamePath = testsDirChar === -1 ?
|
|
21
|
+
basename(filePath)
|
|
22
|
+
: filePath.slice(testsDirChar + testDirName.length);
|
|
23
|
+
const suiteName = suiteNamePath.slice(0, -testSuffix.length);
|
|
17
24
|
if (contextualTests) {
|
|
18
|
-
describe(
|
|
25
|
+
describe(suiteName, () => contextualTests((name, test) => {
|
|
19
26
|
it(name, () => test(first()));
|
|
20
27
|
}));
|
|
21
28
|
}
|
|
22
29
|
else
|
|
23
|
-
describe(
|
|
30
|
+
describe(suiteName, first);
|
|
24
31
|
};
|
|
25
32
|
const contextualizeEach = (name, createCtx, tests) => {
|
|
26
33
|
const describe = globalThis.describe;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ark/attest",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "David Blass",
|
|
6
6
|
"email": "david@arktype.io",
|
|
@@ -15,8 +15,14 @@
|
|
|
15
15
|
"main": "./out/index.js",
|
|
16
16
|
"types": "./out/index.d.ts",
|
|
17
17
|
"exports": {
|
|
18
|
-
".":
|
|
19
|
-
|
|
18
|
+
".": {
|
|
19
|
+
"ark-ts": "./index.ts",
|
|
20
|
+
"default": "./out/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./internal/*": {
|
|
23
|
+
"ark-ts": "./*",
|
|
24
|
+
"default": "./out/*"
|
|
25
|
+
}
|
|
20
26
|
},
|
|
21
27
|
"files": [
|
|
22
28
|
"out"
|
|
@@ -25,13 +31,13 @@
|
|
|
25
31
|
"attest": "out/cli/cli.js"
|
|
26
32
|
},
|
|
27
33
|
"dependencies": {
|
|
28
|
-
"@typescript/vfs": "1.
|
|
34
|
+
"@typescript/vfs": "1.6.0",
|
|
29
35
|
"@typescript/analyze-trace": "0.10.1",
|
|
30
36
|
"prettier": "3.3.3",
|
|
31
37
|
"@prettier/sync": "0.5.2",
|
|
32
|
-
"arktype": "2.0.0-beta.
|
|
33
|
-
"@ark/
|
|
34
|
-
"@ark/
|
|
38
|
+
"arktype": "2.0.0-beta.6",
|
|
39
|
+
"@ark/util": "0.2.2",
|
|
40
|
+
"@ark/fs": "0.2.2"
|
|
35
41
|
},
|
|
36
42
|
"devDependencies": {
|
|
37
43
|
"typescript": "5.5.4"
|
|
@@ -43,8 +49,7 @@
|
|
|
43
49
|
"access": "public"
|
|
44
50
|
},
|
|
45
51
|
"scripts": {
|
|
46
|
-
"build": "
|
|
47
|
-
"test": "
|
|
48
|
-
"bunTest": "bun test --preload ../repo/bunTestSetup.ts"
|
|
52
|
+
"build": "ts ../repo/build.ts",
|
|
53
|
+
"test": "ts ../repo/testPackage.ts"
|
|
49
54
|
}
|
|
50
55
|
}
|