@openedges/pkl-napi 0.32.0-rc.3 → 0.32.0
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/README.md +12 -8
- package/THIRD-PARTY-NOTICES.md +19 -3
- package/dist/index.cjs +585 -272
- package/dist/index.d.cts +547 -0
- package/dist/index.d.mts +575 -0
- package/dist/index.d.ts +37 -24
- package/dist/index.mjs +0 -5
- package/dist/testing.cjs +114 -0
- package/dist/testing.d.cts +29 -0
- package/dist/testing.d.mts +38 -0
- package/dist/testing.d.ts +29 -0
- package/dist/testing.mjs +14 -0
- package/native/pkl_napi.darwin-arm64.node +0 -0
- package/native/pkl_napi.darwin-x64.node +0 -0
- package/native/pkl_napi.linux-arm64-gnu.node +0 -0
- package/native/pkl_napi.linux-arm64-musl.node +0 -0
- package/native/pkl_napi.linux-x64-gnu.node +0 -0
- package/native/pkl_napi.linux-x64-musl.node +0 -0
- package/native/pkl_napi.win32-x64.node +0 -0
- package/package.json +19 -4
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
export const PKL_VERSION: "0.32.0";
|
|
2
|
+
|
|
3
|
+
export interface PklCapabilities {
|
|
4
|
+
vfs: boolean;
|
|
5
|
+
asyncModuleLoader: boolean;
|
|
6
|
+
asyncResourceLoader: boolean;
|
|
7
|
+
nativeFs: boolean;
|
|
8
|
+
nativeHttp: boolean;
|
|
9
|
+
externalReaders: boolean;
|
|
10
|
+
modulePathJar: boolean;
|
|
11
|
+
projectResolution: boolean;
|
|
12
|
+
packageCache: boolean;
|
|
13
|
+
formatter: boolean;
|
|
14
|
+
repl: boolean;
|
|
15
|
+
schema: boolean;
|
|
16
|
+
analyzeImports: boolean;
|
|
17
|
+
bigint64: boolean;
|
|
18
|
+
uint8ArrayBytes: boolean;
|
|
19
|
+
clock64Bit: boolean;
|
|
20
|
+
platform: string;
|
|
21
|
+
runtime: "wasm-browser" | "wasm-node" | "napi-node";
|
|
22
|
+
arch: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function capabilities(): PklCapabilities;
|
|
26
|
+
|
|
27
|
+
export type PklErrorKind =
|
|
28
|
+
| "evaluation"
|
|
29
|
+
| "security"
|
|
30
|
+
| "timeout"
|
|
31
|
+
| "closed"
|
|
32
|
+
| "cancelled"
|
|
33
|
+
| "configuration"
|
|
34
|
+
| "decode"
|
|
35
|
+
| "io"
|
|
36
|
+
| "invalid-argument"
|
|
37
|
+
| "capability-unavailable";
|
|
38
|
+
|
|
39
|
+
export class PklError extends Error {
|
|
40
|
+
readonly name: "PklError";
|
|
41
|
+
readonly kind: PklErrorKind;
|
|
42
|
+
readonly code: PklErrorKind;
|
|
43
|
+
readonly capability?: keyof PklCapabilities;
|
|
44
|
+
constructor(message: string, kind?: PklErrorKind, capability?: keyof PklCapabilities);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class ModuleSource {
|
|
48
|
+
readonly uri: string;
|
|
49
|
+
readonly contents?: string;
|
|
50
|
+
constructor(uri: string, contents?: string);
|
|
51
|
+
static text(text: string, uri?: string): ModuleSource;
|
|
52
|
+
static uri(uri: string): ModuleSource;
|
|
53
|
+
static path(path: string): ModuleSource;
|
|
54
|
+
static modulePath(path: string): ModuleSource;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export class PklDuration {
|
|
58
|
+
readonly value: number;
|
|
59
|
+
readonly unit: string;
|
|
60
|
+
constructor(value: number, unit: string);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class PklDataSize {
|
|
64
|
+
readonly value: number;
|
|
65
|
+
readonly unit: string;
|
|
66
|
+
constructor(value: number, unit: string);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export class PklPair<A = PklValue, B = PklValue> {
|
|
70
|
+
readonly first: A;
|
|
71
|
+
readonly second: B;
|
|
72
|
+
constructor(first: A, second: B);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export class PklRegex {
|
|
76
|
+
readonly pattern: string;
|
|
77
|
+
constructor(pattern: string);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class PklObject {
|
|
81
|
+
readonly className: string;
|
|
82
|
+
readonly moduleUri: string;
|
|
83
|
+
readonly properties: Record<string, PklValue>;
|
|
84
|
+
readonly entries: Map<PklValue, PklValue>;
|
|
85
|
+
readonly elements: PklValue[];
|
|
86
|
+
constructor(
|
|
87
|
+
className: string,
|
|
88
|
+
moduleUri: string,
|
|
89
|
+
properties?: Record<string, PklValue>,
|
|
90
|
+
entries?: Map<PklValue, PklValue> | Iterable<[PklValue, PklValue]>,
|
|
91
|
+
elements?: Iterable<PklValue>,
|
|
92
|
+
);
|
|
93
|
+
toJSON(): {
|
|
94
|
+
className: string;
|
|
95
|
+
moduleUri: string;
|
|
96
|
+
properties: Record<string, PklValue>;
|
|
97
|
+
entries: [PklValue, PklValue][];
|
|
98
|
+
elements: PklValue[];
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export class PklClass {
|
|
103
|
+
readonly name: string;
|
|
104
|
+
readonly moduleUri: string;
|
|
105
|
+
constructor(name: string, moduleUri: string);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export class PklTypeAlias {
|
|
109
|
+
readonly name: string;
|
|
110
|
+
readonly moduleUri: string;
|
|
111
|
+
constructor(name: string, moduleUri: string);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export class PklIntSeq {
|
|
115
|
+
readonly start: bigint;
|
|
116
|
+
readonly end: bigint;
|
|
117
|
+
readonly step: bigint;
|
|
118
|
+
constructor(start: bigint, end: bigint, step: bigint);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export class PklFunction {
|
|
122
|
+
constructor();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export class PklReference {
|
|
126
|
+
readonly domain: PklValue;
|
|
127
|
+
readonly data: PklValue;
|
|
128
|
+
readonly path: PklValue[];
|
|
129
|
+
constructor(domain: PklValue, data: PklValue, path?: PklValue[]);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export type PklValue =
|
|
133
|
+
| null
|
|
134
|
+
| boolean
|
|
135
|
+
| bigint
|
|
136
|
+
| number
|
|
137
|
+
| string
|
|
138
|
+
| Uint8Array
|
|
139
|
+
| PklValue[]
|
|
140
|
+
| Set<PklValue>
|
|
141
|
+
| Map<PklValue, PklValue>
|
|
142
|
+
| PklDuration
|
|
143
|
+
| PklDataSize
|
|
144
|
+
| PklPair
|
|
145
|
+
| PklRegex
|
|
146
|
+
| PklObject
|
|
147
|
+
| PklClass
|
|
148
|
+
| PklTypeAlias
|
|
149
|
+
| PklIntSeq
|
|
150
|
+
| PklFunction
|
|
151
|
+
| PklReference;
|
|
152
|
+
|
|
153
|
+
export interface StackFrame {
|
|
154
|
+
moduleUri: string;
|
|
155
|
+
memberName: string | null;
|
|
156
|
+
sourceLines: string[];
|
|
157
|
+
startLine: number;
|
|
158
|
+
startColumn: number;
|
|
159
|
+
endLine: number;
|
|
160
|
+
endColumn: number;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface PathElement {
|
|
164
|
+
name: string;
|
|
165
|
+
isDirectory: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface ModuleReader {
|
|
169
|
+
scheme: string;
|
|
170
|
+
isLocal?: boolean;
|
|
171
|
+
isGlobbable?: boolean;
|
|
172
|
+
hasHierarchicalUris?: boolean;
|
|
173
|
+
hasFragmentPaths?: boolean;
|
|
174
|
+
isCached?: boolean;
|
|
175
|
+
read(
|
|
176
|
+
uri: string,
|
|
177
|
+
): string | Uint8Array | null | undefined | Promise<string | Uint8Array | null | undefined>;
|
|
178
|
+
listElements?(uri: string): PathElement[] | Promise<PathElement[]>;
|
|
179
|
+
hasElement?(uri: string): boolean | Promise<boolean>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface ResourceReader {
|
|
183
|
+
scheme: string;
|
|
184
|
+
isGlobbable?: boolean;
|
|
185
|
+
hasHierarchicalUris?: boolean;
|
|
186
|
+
read(
|
|
187
|
+
uri: string,
|
|
188
|
+
): Uint8Array | string | null | undefined | Promise<Uint8Array | string | null | undefined>;
|
|
189
|
+
listElements?(uri: string): PathElement[] | Promise<PathElement[]>;
|
|
190
|
+
hasElement?(uri: string): boolean | Promise<boolean>;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface SecurityManager {
|
|
194
|
+
checkResolveModule?(uri: string): void | Promise<void>;
|
|
195
|
+
checkImportModule?(importingUri: string, importedUri: string): void | Promise<void>;
|
|
196
|
+
checkReadResource?(uri: string): void | Promise<void>;
|
|
197
|
+
checkResolveResource?(uri: string): void | Promise<void>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface Logger {
|
|
201
|
+
trace?(msg: string, frame?: StackFrame): void | Promise<void>;
|
|
202
|
+
warn?(msg: string, frame?: StackFrame): void | Promise<void>;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface HttpOptions {
|
|
206
|
+
caCertificates?: (string | Uint8Array)[];
|
|
207
|
+
caCertificateFiles?: string[];
|
|
208
|
+
caCertificatePems?: (string | Uint8Array)[];
|
|
209
|
+
proxy?: { address?: string; noProxy?: string[] };
|
|
210
|
+
rewrites?: Record<string, string>;
|
|
211
|
+
headers?: Record<string, Record<string, string>>;
|
|
212
|
+
testPort?: number;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface ExternalReaderSpec {
|
|
216
|
+
executable: string;
|
|
217
|
+
arguments?: string[];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface EvaluatorOptions {
|
|
221
|
+
allowedModules?: string[];
|
|
222
|
+
allowedResources?: string[];
|
|
223
|
+
rootDir?: string;
|
|
224
|
+
workingDir?: string;
|
|
225
|
+
properties?: Record<string, string> | Map<string, string>;
|
|
226
|
+
env?: Record<string, string> | Map<string, string>;
|
|
227
|
+
outputFormat?: string;
|
|
228
|
+
traceMode?: "compact" | "pretty";
|
|
229
|
+
powerAssertions?: boolean;
|
|
230
|
+
color?: boolean | "never" | "auto" | "always";
|
|
231
|
+
timeoutMs?: number | bigint;
|
|
232
|
+
signal?: AbortSignal;
|
|
233
|
+
logger?: Logger;
|
|
234
|
+
frameTransformer?: (frame: StackFrame) => StackFrame | Promise<StackFrame>;
|
|
235
|
+
securityManager?: SecurityManager;
|
|
236
|
+
moduleReaders?: ModuleReader[];
|
|
237
|
+
resourceReaders?: ResourceReader[];
|
|
238
|
+
modulePaths?: string[];
|
|
239
|
+
projectDir?: string;
|
|
240
|
+
project?: Project;
|
|
241
|
+
cacheDir?: string | null;
|
|
242
|
+
noCache?: boolean;
|
|
243
|
+
testMode?: boolean;
|
|
244
|
+
http?: HttpOptions;
|
|
245
|
+
externalModuleReaders?: Record<string, ExternalReaderSpec>;
|
|
246
|
+
externalResourceReaders?: Record<string, ExternalReaderSpec>;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface CallOptions {
|
|
250
|
+
timeoutMs?: number | bigint;
|
|
251
|
+
signal?: AbortSignal;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface TestOptions extends CallOptions {
|
|
255
|
+
overwrite?: boolean;
|
|
256
|
+
reporter?: "spec" | "minimal" | "junit";
|
|
257
|
+
}
|
|
258
|
+
export type EvaluateTestOptions = TestOptions;
|
|
259
|
+
|
|
260
|
+
export interface SourceLocation {
|
|
261
|
+
startLine: number;
|
|
262
|
+
endLine: number;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface TypeParameter {
|
|
266
|
+
name: string;
|
|
267
|
+
variance: "invariant" | "covariant" | "contravariant";
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface PClassInfo {
|
|
271
|
+
moduleName: string;
|
|
272
|
+
simpleName: string;
|
|
273
|
+
qualifiedName: string;
|
|
274
|
+
displayName: string;
|
|
275
|
+
moduleUri: string;
|
|
276
|
+
isModuleClass: boolean;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export interface TypeAliasInfo {
|
|
280
|
+
moduleName: string;
|
|
281
|
+
simpleName: string;
|
|
282
|
+
qualifiedName: string;
|
|
283
|
+
displayName: string;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export type PType =
|
|
287
|
+
| { kind: "unknown" }
|
|
288
|
+
| { kind: "nothing" }
|
|
289
|
+
| { kind: "module" }
|
|
290
|
+
| { kind: "stringLiteral"; literal: string }
|
|
291
|
+
| { kind: "class"; classInfo: PClassInfo; typeArguments: PType[] }
|
|
292
|
+
| { kind: "nullable"; baseType: PType }
|
|
293
|
+
| { kind: "union"; elementTypes: PType[] }
|
|
294
|
+
| { kind: "function"; parameterTypes: PType[]; returnType: PType }
|
|
295
|
+
| { kind: "constrained"; baseType: PType; constraints: string[] }
|
|
296
|
+
| { kind: "alias"; aliasInfo: TypeAliasInfo; typeArguments: PType[]; aliasedType: PType }
|
|
297
|
+
| { kind: "typeVariable"; typeParameter: TypeParameter };
|
|
298
|
+
|
|
299
|
+
export interface PClassProperty {
|
|
300
|
+
name: string;
|
|
301
|
+
simpleName: string;
|
|
302
|
+
moduleName: string;
|
|
303
|
+
docComment: string | null;
|
|
304
|
+
sourceLocation: SourceLocation;
|
|
305
|
+
modifiers: string[];
|
|
306
|
+
annotations: PklObject[];
|
|
307
|
+
type: PType;
|
|
308
|
+
}
|
|
309
|
+
export type PPropertySchema = PClassProperty;
|
|
310
|
+
|
|
311
|
+
export interface PClassMethod {
|
|
312
|
+
name: string;
|
|
313
|
+
simpleName: string;
|
|
314
|
+
moduleName: string;
|
|
315
|
+
docComment: string | null;
|
|
316
|
+
sourceLocation: SourceLocation;
|
|
317
|
+
modifiers: string[];
|
|
318
|
+
annotations: PklObject[];
|
|
319
|
+
typeParameters: TypeParameter[];
|
|
320
|
+
parameters: Record<string, PType>;
|
|
321
|
+
returnType: PType;
|
|
322
|
+
}
|
|
323
|
+
export type PMethodSchema = PClassMethod;
|
|
324
|
+
|
|
325
|
+
export interface PClassSchema extends PClassInfo {
|
|
326
|
+
info: PClassInfo;
|
|
327
|
+
docComment: string | null;
|
|
328
|
+
sourceLocation: SourceLocation;
|
|
329
|
+
modifiers: string[];
|
|
330
|
+
annotations: PklObject[];
|
|
331
|
+
typeParameters: TypeParameter[];
|
|
332
|
+
superclass: PClassInfo | null;
|
|
333
|
+
supertype: PType | null;
|
|
334
|
+
properties: Record<string, PClassProperty>;
|
|
335
|
+
allProperties: Record<string, PClassProperty>;
|
|
336
|
+
methods: Record<string, PClassMethod>;
|
|
337
|
+
allMethods: Record<string, PClassMethod>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export interface TypeAliasSchema extends TypeAliasInfo {
|
|
341
|
+
info: TypeAliasInfo;
|
|
342
|
+
docComment: string | null;
|
|
343
|
+
sourceLocation: SourceLocation;
|
|
344
|
+
modifiers: string[];
|
|
345
|
+
annotations: PklObject[];
|
|
346
|
+
typeParameters: TypeParameter[];
|
|
347
|
+
aliasedType: PType;
|
|
348
|
+
}
|
|
349
|
+
export type PTypeAliasSchema = TypeAliasSchema;
|
|
350
|
+
|
|
351
|
+
export interface ModuleSchema {
|
|
352
|
+
moduleUri: string;
|
|
353
|
+
moduleName: string;
|
|
354
|
+
shortModuleName: string;
|
|
355
|
+
isAmend: boolean;
|
|
356
|
+
isExtend: boolean;
|
|
357
|
+
docComment: string | null;
|
|
358
|
+
annotations: PklObject[];
|
|
359
|
+
supermodule: ModuleSchema | null;
|
|
360
|
+
moduleClass: PClassSchema;
|
|
361
|
+
classes: Record<string, PClassSchema>;
|
|
362
|
+
allClasses: Record<string, PClassSchema>;
|
|
363
|
+
typeAliases: Record<string, TypeAliasSchema>;
|
|
364
|
+
allTypeAliases: Record<string, TypeAliasSchema>;
|
|
365
|
+
imports: Record<string, string>;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export interface TestFailure {
|
|
369
|
+
kind: string;
|
|
370
|
+
message: string;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export interface TestError {
|
|
374
|
+
message: string;
|
|
375
|
+
rendered: string;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
export interface TestResult {
|
|
379
|
+
name: string;
|
|
380
|
+
totalAsserts: number;
|
|
381
|
+
failed: boolean;
|
|
382
|
+
isExampleWritten: boolean;
|
|
383
|
+
failures: TestFailure[];
|
|
384
|
+
errors: TestError[];
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export interface TestSectionResults {
|
|
388
|
+
name: "facts" | "examples";
|
|
389
|
+
failed: boolean;
|
|
390
|
+
totalTests: number;
|
|
391
|
+
totalFailures: number;
|
|
392
|
+
totalAsserts: number;
|
|
393
|
+
results: TestResult[];
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export interface TestResults {
|
|
397
|
+
moduleName: string;
|
|
398
|
+
displayUri: string;
|
|
399
|
+
failed: boolean;
|
|
400
|
+
totalTests: number;
|
|
401
|
+
totalFailures: number;
|
|
402
|
+
totalAsserts: number;
|
|
403
|
+
totalAssertsFailed: number;
|
|
404
|
+
facts: TestSectionResults;
|
|
405
|
+
examples: TestSectionResults;
|
|
406
|
+
logs: string;
|
|
407
|
+
error: TestError | null;
|
|
408
|
+
rendered: string;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export interface ProjectPackageInfo {
|
|
412
|
+
name: string;
|
|
413
|
+
baseUri: string;
|
|
414
|
+
version: string;
|
|
415
|
+
uri: string;
|
|
416
|
+
packageZipUrl: string;
|
|
417
|
+
description: string | null;
|
|
418
|
+
authors: string[];
|
|
419
|
+
website: string | null;
|
|
420
|
+
documentation: string | null;
|
|
421
|
+
sourceCode: string | null;
|
|
422
|
+
sourceCodeUrlScheme: string | null;
|
|
423
|
+
license: string | null;
|
|
424
|
+
issueTracker: string | null;
|
|
425
|
+
apiTests: string[];
|
|
426
|
+
exclude: string[];
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export interface ProjectEvaluatorSettings {
|
|
430
|
+
allowedModules: string[] | null;
|
|
431
|
+
allowedResources: string[] | null;
|
|
432
|
+
rootDir: string | null;
|
|
433
|
+
moduleCacheDir: string | null;
|
|
434
|
+
noCache: boolean | null;
|
|
435
|
+
traceMode: string | null;
|
|
436
|
+
color: string | null;
|
|
437
|
+
timeoutMs: bigint | null;
|
|
438
|
+
env: Record<string, string> | null;
|
|
439
|
+
externalProperties: Record<string, string> | null;
|
|
440
|
+
modulePath: string[] | null;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export class Project {
|
|
444
|
+
readonly projectDir: string;
|
|
445
|
+
readonly projectFileUri: string;
|
|
446
|
+
readonly projectBaseUri: string;
|
|
447
|
+
readonly package: ProjectPackageInfo | null;
|
|
448
|
+
readonly evaluatorSettings: ProjectEvaluatorSettings | null;
|
|
449
|
+
readonly tests: string[];
|
|
450
|
+
static load(
|
|
451
|
+
dirOrFile: string,
|
|
452
|
+
options?: {
|
|
453
|
+
env?: Record<string, string> | Map<string, string>;
|
|
454
|
+
properties?: Record<string, string> | Map<string, string>;
|
|
455
|
+
},
|
|
456
|
+
): Promise<Project>;
|
|
457
|
+
static loadSync(
|
|
458
|
+
dirOrFile: string,
|
|
459
|
+
options?: {
|
|
460
|
+
env?: Record<string, string> | Map<string, string>;
|
|
461
|
+
properties?: Record<string, string> | Map<string, string>;
|
|
462
|
+
},
|
|
463
|
+
): Project;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export class Evaluator {
|
|
467
|
+
private constructor();
|
|
468
|
+
readonly isClosed: boolean;
|
|
469
|
+
evaluateOutputText(source: ModuleSource, options?: CallOptions): Promise<string>;
|
|
470
|
+
evaluateOutputTextSync(source: ModuleSource, options?: CallOptions): string;
|
|
471
|
+
evaluateOutputBytes(source: ModuleSource, options?: CallOptions): Promise<Uint8Array>;
|
|
472
|
+
evaluateOutputBytesSync(source: ModuleSource, options?: CallOptions): Uint8Array;
|
|
473
|
+
evaluateOutputFiles(source: ModuleSource, options?: CallOptions): Promise<Map<string, Uint8Array>>;
|
|
474
|
+
evaluateOutputFilesSync(source: ModuleSource, options?: CallOptions): Map<string, Uint8Array>;
|
|
475
|
+
evaluateOutputValue(source: ModuleSource, options?: CallOptions): Promise<PklValue>;
|
|
476
|
+
evaluateOutputValueSync(source: ModuleSource, options?: CallOptions): PklValue;
|
|
477
|
+
evaluateExpression(source: ModuleSource, expr: string, options?: CallOptions): Promise<string>;
|
|
478
|
+
evaluateExpressionSync(source: ModuleSource, expr: string, options?: CallOptions): string;
|
|
479
|
+
evaluateExpressionValue(
|
|
480
|
+
source: ModuleSource,
|
|
481
|
+
expr: string,
|
|
482
|
+
options?: CallOptions,
|
|
483
|
+
): Promise<PklValue>;
|
|
484
|
+
evaluateExpressionValueSync(source: ModuleSource, expr: string, options?: CallOptions): PklValue;
|
|
485
|
+
evaluateExpressionPklBinary(
|
|
486
|
+
source: ModuleSource,
|
|
487
|
+
expr: string,
|
|
488
|
+
options?: CallOptions,
|
|
489
|
+
): Promise<Uint8Array>;
|
|
490
|
+
evaluateExpressionPklBinarySync(
|
|
491
|
+
source: ModuleSource,
|
|
492
|
+
expr: string,
|
|
493
|
+
options?: CallOptions,
|
|
494
|
+
): Uint8Array;
|
|
495
|
+
evaluateSchema(source: ModuleSource, options?: CallOptions): Promise<ModuleSchema>;
|
|
496
|
+
evaluateSchemaSync(source: ModuleSource, options?: CallOptions): ModuleSchema;
|
|
497
|
+
evaluateTest(source: ModuleSource, options?: TestOptions): Promise<TestResults>;
|
|
498
|
+
evaluateTestSync(source: ModuleSource, options?: TestOptions): TestResults;
|
|
499
|
+
cancel(): void;
|
|
500
|
+
close(): Promise<void>;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
export function createEvaluator(options?: EvaluatorOptions): Promise<Evaluator>;
|
|
504
|
+
export function createEvaluatorSync(options?: EvaluatorOptions): Evaluator;
|
|
505
|
+
|
|
506
|
+
export interface ReplResponse {
|
|
507
|
+
kind:
|
|
508
|
+
| "evalSuccess"
|
|
509
|
+
| "evalError"
|
|
510
|
+
| "incompleteInput"
|
|
511
|
+
| "invalidRequest"
|
|
512
|
+
| "internalError"
|
|
513
|
+
| "completion";
|
|
514
|
+
result?: string;
|
|
515
|
+
message?: string;
|
|
516
|
+
members?: string[];
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
export class ReplSession {
|
|
520
|
+
private constructor();
|
|
521
|
+
readonly isClosed: boolean;
|
|
522
|
+
eval(
|
|
523
|
+
input: string,
|
|
524
|
+
options?: { force?: boolean; evalDefinitions?: boolean; id?: string },
|
|
525
|
+
): Promise<ReplResponse[]>;
|
|
526
|
+
load(uriOrSource: string | ModuleSource, options?: { id?: string }): Promise<ReplResponse[]>;
|
|
527
|
+
reset(options?: { id?: string }): Promise<void>;
|
|
528
|
+
complete(prefix: string, options?: { id?: string }): Promise<string[]>;
|
|
529
|
+
cancel(): void;
|
|
530
|
+
close(): Promise<void>;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
export function createRepl(options?: EvaluatorOptions): Promise<ReplSession>;
|
|
534
|
+
|
|
535
|
+
export interface ImportGraph {
|
|
536
|
+
imports: Record<string, string[]>;
|
|
537
|
+
resolvedImports: Record<string, string>;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
export function analyzeImportGraph(
|
|
541
|
+
uris: (string | ModuleSource)[],
|
|
542
|
+
options?: EvaluatorOptions,
|
|
543
|
+
): Promise<ImportGraph>;
|
|
544
|
+
|
|
545
|
+
export function format(source: string, options?: { grammarVersion?: 1 | 2 | null }): string;
|
|
546
|
+
export function decodePklBinary(bytes: Uint8Array, options?: { strict?: boolean }): PklValue;
|
|
547
|
+
export function monotonicClockMs(): bigint;
|
|
548
|
+
|
|
549
|
+
declare const _default: {
|
|
550
|
+
PKL_VERSION: typeof PKL_VERSION;
|
|
551
|
+
capabilities: typeof capabilities;
|
|
552
|
+
PklError: typeof PklError;
|
|
553
|
+
ModuleSource: typeof ModuleSource;
|
|
554
|
+
PklDuration: typeof PklDuration;
|
|
555
|
+
PklDataSize: typeof PklDataSize;
|
|
556
|
+
PklPair: typeof PklPair;
|
|
557
|
+
PklRegex: typeof PklRegex;
|
|
558
|
+
PklObject: typeof PklObject;
|
|
559
|
+
PklClass: typeof PklClass;
|
|
560
|
+
PklTypeAlias: typeof PklTypeAlias;
|
|
561
|
+
PklIntSeq: typeof PklIntSeq;
|
|
562
|
+
PklFunction: typeof PklFunction;
|
|
563
|
+
PklReference: typeof PklReference;
|
|
564
|
+
Evaluator: typeof Evaluator;
|
|
565
|
+
Project: typeof Project;
|
|
566
|
+
ReplSession: typeof ReplSession;
|
|
567
|
+
createEvaluator: typeof createEvaluator;
|
|
568
|
+
createEvaluatorSync: typeof createEvaluatorSync;
|
|
569
|
+
createRepl: typeof createRepl;
|
|
570
|
+
analyzeImportGraph: typeof analyzeImportGraph;
|
|
571
|
+
format: typeof format;
|
|
572
|
+
decodePklBinary: typeof decodePklBinary;
|
|
573
|
+
monotonicClockMs: typeof monotonicClockMs;
|
|
574
|
+
};
|
|
575
|
+
export default _default;
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export type PklErrorKind =
|
|
|
37
37
|
| "capability-unavailable";
|
|
38
38
|
|
|
39
39
|
export class PklError extends Error {
|
|
40
|
+
readonly name: "PklError";
|
|
40
41
|
readonly kind: PklErrorKind;
|
|
41
42
|
readonly code: PklErrorKind;
|
|
42
43
|
readonly capability?: keyof PklCapabilities;
|
|
@@ -86,9 +87,16 @@ export class PklObject {
|
|
|
86
87
|
className: string,
|
|
87
88
|
moduleUri: string,
|
|
88
89
|
properties?: Record<string, PklValue>,
|
|
89
|
-
entries?: Map<PklValue, PklValue>,
|
|
90
|
-
elements?: PklValue
|
|
90
|
+
entries?: Map<PklValue, PklValue> | Iterable<[PklValue, PklValue]>,
|
|
91
|
+
elements?: Iterable<PklValue>,
|
|
91
92
|
);
|
|
93
|
+
toJSON(): {
|
|
94
|
+
className: string;
|
|
95
|
+
moduleUri: string;
|
|
96
|
+
properties: Record<string, PklValue>;
|
|
97
|
+
entries: [PklValue, PklValue][];
|
|
98
|
+
elements: PklValue[];
|
|
99
|
+
};
|
|
92
100
|
}
|
|
93
101
|
|
|
94
102
|
export class PklClass {
|
|
@@ -162,8 +170,11 @@ export interface ModuleReader {
|
|
|
162
170
|
isLocal?: boolean;
|
|
163
171
|
isGlobbable?: boolean;
|
|
164
172
|
hasHierarchicalUris?: boolean;
|
|
173
|
+
hasFragmentPaths?: boolean;
|
|
165
174
|
isCached?: boolean;
|
|
166
|
-
read(
|
|
175
|
+
read(
|
|
176
|
+
uri: string,
|
|
177
|
+
): string | Uint8Array | null | undefined | Promise<string | Uint8Array | null | undefined>;
|
|
167
178
|
listElements?(uri: string): PathElement[] | Promise<PathElement[]>;
|
|
168
179
|
hasElement?(uri: string): boolean | Promise<boolean>;
|
|
169
180
|
}
|
|
@@ -244,6 +255,7 @@ export interface TestOptions extends CallOptions {
|
|
|
244
255
|
overwrite?: boolean;
|
|
245
256
|
reporter?: "spec" | "minimal" | "junit";
|
|
246
257
|
}
|
|
258
|
+
export type EvaluateTestOptions = TestOptions;
|
|
247
259
|
|
|
248
260
|
export interface SourceLocation {
|
|
249
261
|
startLine: number;
|
|
@@ -294,6 +306,7 @@ export interface PClassProperty {
|
|
|
294
306
|
annotations: PklObject[];
|
|
295
307
|
type: PType;
|
|
296
308
|
}
|
|
309
|
+
export type PPropertySchema = PClassProperty;
|
|
297
310
|
|
|
298
311
|
export interface PClassMethod {
|
|
299
312
|
name: string;
|
|
@@ -307,8 +320,10 @@ export interface PClassMethod {
|
|
|
307
320
|
parameters: Record<string, PType>;
|
|
308
321
|
returnType: PType;
|
|
309
322
|
}
|
|
323
|
+
export type PMethodSchema = PClassMethod;
|
|
310
324
|
|
|
311
325
|
export interface PClassSchema extends PClassInfo {
|
|
326
|
+
info: PClassInfo;
|
|
312
327
|
docComment: string | null;
|
|
313
328
|
sourceLocation: SourceLocation;
|
|
314
329
|
modifiers: string[];
|
|
@@ -323,6 +338,7 @@ export interface PClassSchema extends PClassInfo {
|
|
|
323
338
|
}
|
|
324
339
|
|
|
325
340
|
export interface TypeAliasSchema extends TypeAliasInfo {
|
|
341
|
+
info: TypeAliasInfo;
|
|
326
342
|
docComment: string | null;
|
|
327
343
|
sourceLocation: SourceLocation;
|
|
328
344
|
modifiers: string[];
|
|
@@ -330,6 +346,7 @@ export interface TypeAliasSchema extends TypeAliasInfo {
|
|
|
330
346
|
typeParameters: TypeParameter[];
|
|
331
347
|
aliasedType: PType;
|
|
332
348
|
}
|
|
349
|
+
export type PTypeAliasSchema = TypeAliasSchema;
|
|
333
350
|
|
|
334
351
|
export interface ModuleSchema {
|
|
335
352
|
moduleUri: string;
|
|
@@ -447,6 +464,7 @@ export class Project {
|
|
|
447
464
|
}
|
|
448
465
|
|
|
449
466
|
export class Evaluator {
|
|
467
|
+
private constructor();
|
|
450
468
|
readonly isClosed: boolean;
|
|
451
469
|
evaluateOutputText(source: ModuleSource, options?: CallOptions): Promise<string>;
|
|
452
470
|
evaluateOutputTextSync(source: ModuleSource, options?: CallOptions): string;
|
|
@@ -486,17 +504,29 @@ export function createEvaluator(options?: EvaluatorOptions): Promise<Evaluator>;
|
|
|
486
504
|
export function createEvaluatorSync(options?: EvaluatorOptions): Evaluator;
|
|
487
505
|
|
|
488
506
|
export interface ReplResponse {
|
|
489
|
-
kind:
|
|
507
|
+
kind:
|
|
508
|
+
| "evalSuccess"
|
|
509
|
+
| "evalError"
|
|
510
|
+
| "incompleteInput"
|
|
511
|
+
| "invalidRequest"
|
|
512
|
+
| "internalError"
|
|
513
|
+
| "completion";
|
|
490
514
|
result?: string;
|
|
491
515
|
message?: string;
|
|
516
|
+
members?: string[];
|
|
492
517
|
}
|
|
493
518
|
|
|
494
519
|
export class ReplSession {
|
|
520
|
+
private constructor();
|
|
495
521
|
readonly isClosed: boolean;
|
|
496
|
-
eval(
|
|
522
|
+
eval(
|
|
523
|
+
input: string,
|
|
524
|
+
options?: { force?: boolean; evalDefinitions?: boolean; id?: string },
|
|
525
|
+
): Promise<ReplResponse[]>;
|
|
497
526
|
load(uriOrSource: string | ModuleSource, options?: { id?: string }): Promise<ReplResponse[]>;
|
|
498
527
|
reset(options?: { id?: string }): Promise<void>;
|
|
499
528
|
complete(prefix: string, options?: { id?: string }): Promise<string[]>;
|
|
529
|
+
cancel(): void;
|
|
500
530
|
close(): Promise<void>;
|
|
501
531
|
}
|
|
502
532
|
|
|
@@ -512,23 +542,6 @@ export function analyzeImportGraph(
|
|
|
512
542
|
options?: EvaluatorOptions,
|
|
513
543
|
): Promise<ImportGraph>;
|
|
514
544
|
|
|
515
|
-
export function format(source: string, options?: { grammarVersion?: 1 | 2 }): string;
|
|
516
|
-
export function decodePklBinary(bytes: Uint8Array): PklValue;
|
|
545
|
+
export function format(source: string, options?: { grammarVersion?: 1 | 2 | null }): string;
|
|
546
|
+
export function decodePklBinary(bytes: Uint8Array, options?: { strict?: boolean }): PklValue;
|
|
517
547
|
export function monotonicClockMs(): bigint;
|
|
518
|
-
|
|
519
|
-
export function roundtripValue<T extends PklValue>(val: T): PklValue;
|
|
520
|
-
export function roundtripInteger(val: bigint): bigint;
|
|
521
|
-
export function roundtripBytes(val: Uint8Array): Uint8Array;
|
|
522
|
-
export function roundtripString(val: string): string;
|
|
523
|
-
|
|
524
|
-
export interface ConversionBenchmarkResult {
|
|
525
|
-
iterations: number;
|
|
526
|
-
elapsedMs: number;
|
|
527
|
-
nativeElapsedMs: number;
|
|
528
|
-
perIterationUs: number;
|
|
529
|
-
nativePerIterationUs: number;
|
|
530
|
-
lastValue: PklValue;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
export function measureConversion(iterations?: number): ConversionBenchmarkResult;
|
|
534
|
-
export function measureConversion(value: PklValue, iterations?: number): ConversionBenchmarkResult;
|