@optique/core 1.0.0-dev.1716 → 1.0.0-dev.1720
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/constructs.cjs +14 -2
- package/dist/constructs.d.cts +4 -4
- package/dist/constructs.d.ts +4 -4
- package/dist/constructs.js +14 -2
- package/package.json +1 -1
package/dist/constructs.cjs
CHANGED
|
@@ -4497,7 +4497,19 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4497
4497
|
dependencyRegistry: runtime.registry
|
|
4498
4498
|
};
|
|
4499
4499
|
const needsDiscriminatorCompletion = state.selectedBranch.kind !== "default" && !(state.discriminatorValue != null && state.discriminatorValue === state.selectedBranch.key);
|
|
4500
|
-
|
|
4500
|
+
let discriminatorCompletionExec = completionExec;
|
|
4501
|
+
if (wasSpeculative && needsDiscriminatorCompletion) {
|
|
4502
|
+
const discOnlyState = { _discriminator: annotatedDiscriminatorState };
|
|
4503
|
+
const discOnlyRuntime = require_dependency_runtime.createDependencyRuntimeContext(exec?.dependencyRegistry?.clone());
|
|
4504
|
+
await require_dependency_runtime.collectExplicitSourceValuesAsync(require_dependency_runtime.buildRuntimeNodesFromPairs([["_discriminator", discriminator]], discOnlyState, exec?.path), discOnlyRuntime);
|
|
4505
|
+
require_dependency_runtime.collectSourcesFromState(discOnlyState, discOnlyRuntime);
|
|
4506
|
+
discriminatorCompletionExec = {
|
|
4507
|
+
...completionExec,
|
|
4508
|
+
dependencyRuntime: discOnlyRuntime,
|
|
4509
|
+
dependencyRegistry: discOnlyRuntime.registry
|
|
4510
|
+
};
|
|
4511
|
+
}
|
|
4512
|
+
const discriminatorCompleteResult = needsDiscriminatorCompletion ? await discriminator.complete(annotatedDiscriminatorState, withChildExecPath(discriminatorCompletionExec, "_discriminator")) : void 0;
|
|
4501
4513
|
let discriminatorValue;
|
|
4502
4514
|
if (state.selectedBranch.kind === "default") discriminatorValue = void 0;
|
|
4503
4515
|
else if (state.discriminatorValue != null && state.discriminatorValue === state.selectedBranch.key) discriminatorValue = state.discriminatorValue;
|
|
@@ -4509,7 +4521,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4509
4521
|
}
|
|
4510
4522
|
if (wasSpeculative && state.selectedBranch.kind === "branch" && discriminatorValue !== state.selectedBranch.key) {
|
|
4511
4523
|
const speculativeKey = state.selectedBranch.key;
|
|
4512
|
-
const resolvedKey = discriminatorValue
|
|
4524
|
+
const resolvedKey = typeof discriminatorValue === "string" ? discriminatorValue : "<unknown>";
|
|
4513
4525
|
return {
|
|
4514
4526
|
success: false,
|
|
4515
4527
|
error: options?.errors?.branchMismatch ? options.errors.branchMismatch(resolvedKey, speculativeKey) : require_message.message`Branch mismatch: tokens for ${speculativeKey} were consumed, but the discriminator resolved to ${resolvedKey}.`
|
package/dist/constructs.d.cts
CHANGED
|
@@ -1327,11 +1327,11 @@ interface ConditionalErrorOptions {
|
|
|
1327
1327
|
* Custom error message when branch parser fails.
|
|
1328
1328
|
* Receives the discriminator value for context.
|
|
1329
1329
|
*/
|
|
1330
|
-
branchError?: (discriminatorValue: string | undefined, error: Message) => Message;
|
|
1330
|
+
readonly branchError?: (discriminatorValue: string | undefined, error: Message) => Message;
|
|
1331
1331
|
/**
|
|
1332
1332
|
* Custom error message for no matching input.
|
|
1333
1333
|
*/
|
|
1334
|
-
noMatch?: Message | ((context: NoMatchContext) => Message);
|
|
1334
|
+
readonly noMatch?: Message | ((context: NoMatchContext) => Message);
|
|
1335
1335
|
/**
|
|
1336
1336
|
* Custom error message when speculative branch parsing committed
|
|
1337
1337
|
* to one branch but the resolved discriminator value names a
|
|
@@ -1345,7 +1345,7 @@ interface ConditionalErrorOptions {
|
|
|
1345
1345
|
* branch tokens were committed to (`speculativeKey`).
|
|
1346
1346
|
* @since 0.10.1
|
|
1347
1347
|
*/
|
|
1348
|
-
branchMismatch?: (discriminatorValue: string, speculativeKey: string) => Message;
|
|
1348
|
+
readonly branchMismatch?: (discriminatorValue: string, speculativeKey: string) => Message;
|
|
1349
1349
|
}
|
|
1350
1350
|
/**
|
|
1351
1351
|
* Options for customizing the {@link conditional} combinator behavior.
|
|
@@ -1355,7 +1355,7 @@ interface ConditionalOptions {
|
|
|
1355
1355
|
/**
|
|
1356
1356
|
* Custom error messages.
|
|
1357
1357
|
*/
|
|
1358
|
-
errors?: ConditionalErrorOptions;
|
|
1358
|
+
readonly errors?: ConditionalErrorOptions;
|
|
1359
1359
|
}
|
|
1360
1360
|
/**
|
|
1361
1361
|
* Helper type to infer result type without default branch.
|
package/dist/constructs.d.ts
CHANGED
|
@@ -1327,11 +1327,11 @@ interface ConditionalErrorOptions {
|
|
|
1327
1327
|
* Custom error message when branch parser fails.
|
|
1328
1328
|
* Receives the discriminator value for context.
|
|
1329
1329
|
*/
|
|
1330
|
-
branchError?: (discriminatorValue: string | undefined, error: Message) => Message;
|
|
1330
|
+
readonly branchError?: (discriminatorValue: string | undefined, error: Message) => Message;
|
|
1331
1331
|
/**
|
|
1332
1332
|
* Custom error message for no matching input.
|
|
1333
1333
|
*/
|
|
1334
|
-
noMatch?: Message | ((context: NoMatchContext) => Message);
|
|
1334
|
+
readonly noMatch?: Message | ((context: NoMatchContext) => Message);
|
|
1335
1335
|
/**
|
|
1336
1336
|
* Custom error message when speculative branch parsing committed
|
|
1337
1337
|
* to one branch but the resolved discriminator value names a
|
|
@@ -1345,7 +1345,7 @@ interface ConditionalErrorOptions {
|
|
|
1345
1345
|
* branch tokens were committed to (`speculativeKey`).
|
|
1346
1346
|
* @since 0.10.1
|
|
1347
1347
|
*/
|
|
1348
|
-
branchMismatch?: (discriminatorValue: string, speculativeKey: string) => Message;
|
|
1348
|
+
readonly branchMismatch?: (discriminatorValue: string, speculativeKey: string) => Message;
|
|
1349
1349
|
}
|
|
1350
1350
|
/**
|
|
1351
1351
|
* Options for customizing the {@link conditional} combinator behavior.
|
|
@@ -1355,7 +1355,7 @@ interface ConditionalOptions {
|
|
|
1355
1355
|
/**
|
|
1356
1356
|
* Custom error messages.
|
|
1357
1357
|
*/
|
|
1358
|
-
errors?: ConditionalErrorOptions;
|
|
1358
|
+
readonly errors?: ConditionalErrorOptions;
|
|
1359
1359
|
}
|
|
1360
1360
|
/**
|
|
1361
1361
|
* Helper type to infer result type without default branch.
|
package/dist/constructs.js
CHANGED
|
@@ -4497,7 +4497,19 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4497
4497
|
dependencyRegistry: runtime.registry
|
|
4498
4498
|
};
|
|
4499
4499
|
const needsDiscriminatorCompletion = state.selectedBranch.kind !== "default" && !(state.discriminatorValue != null && state.discriminatorValue === state.selectedBranch.key);
|
|
4500
|
-
|
|
4500
|
+
let discriminatorCompletionExec = completionExec;
|
|
4501
|
+
if (wasSpeculative && needsDiscriminatorCompletion) {
|
|
4502
|
+
const discOnlyState = { _discriminator: annotatedDiscriminatorState };
|
|
4503
|
+
const discOnlyRuntime = createDependencyRuntimeContext(exec?.dependencyRegistry?.clone());
|
|
4504
|
+
await collectExplicitSourceValuesAsync(buildRuntimeNodesFromPairs([["_discriminator", discriminator]], discOnlyState, exec?.path), discOnlyRuntime);
|
|
4505
|
+
collectSourcesFromState(discOnlyState, discOnlyRuntime);
|
|
4506
|
+
discriminatorCompletionExec = {
|
|
4507
|
+
...completionExec,
|
|
4508
|
+
dependencyRuntime: discOnlyRuntime,
|
|
4509
|
+
dependencyRegistry: discOnlyRuntime.registry
|
|
4510
|
+
};
|
|
4511
|
+
}
|
|
4512
|
+
const discriminatorCompleteResult = needsDiscriminatorCompletion ? await discriminator.complete(annotatedDiscriminatorState, withChildExecPath(discriminatorCompletionExec, "_discriminator")) : void 0;
|
|
4501
4513
|
let discriminatorValue;
|
|
4502
4514
|
if (state.selectedBranch.kind === "default") discriminatorValue = void 0;
|
|
4503
4515
|
else if (state.discriminatorValue != null && state.discriminatorValue === state.selectedBranch.key) discriminatorValue = state.discriminatorValue;
|
|
@@ -4509,7 +4521,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
|
|
|
4509
4521
|
}
|
|
4510
4522
|
if (wasSpeculative && state.selectedBranch.kind === "branch" && discriminatorValue !== state.selectedBranch.key) {
|
|
4511
4523
|
const speculativeKey = state.selectedBranch.key;
|
|
4512
|
-
const resolvedKey = discriminatorValue
|
|
4524
|
+
const resolvedKey = typeof discriminatorValue === "string" ? discriminatorValue : "<unknown>";
|
|
4513
4525
|
return {
|
|
4514
4526
|
success: false,
|
|
4515
4527
|
error: options?.errors?.branchMismatch ? options.errors.branchMismatch(resolvedKey, speculativeKey) : message`Branch mismatch: tokens for ${speculativeKey} were consumed, but the discriminator resolved to ${resolvedKey}.`
|