@dbsp/core 6.2.0 → 6.3.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/dist/{assertion-functions-BcRg_kzj.d.ts → assertion-functions-dyf-Q__5.d.ts} +17 -2
- package/dist/{chunk-64RIEJGN.js → chunk-5UI5IH5U.js} +4816 -4597
- package/dist/chunk-5UI5IH5U.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +13 -3
- package/dist/internal.js +3 -1
- package/dist/internal.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-64RIEJGN.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as _dbsp_types from '@dbsp/types';
|
|
2
2
|
import { ModelIR, ObservationContext, TransitionLessor, ApplyPolicy, ApplyResult, TableIR, RelationIR, EnumIR, SequenceIR, AmbiguityCheckResult, Adapter, DialectCapabilities, PlanOptions, SortDirection, PlanReport, Dump, UnnestCteIntent, CteQueryIntent, RawCteIntent, WhereIntent as WhereIntent$1, TruncateOptions, VacuumOptions, AlterColumnOptions, CreateIndexOptions, DropIndexOptions, IndexInfo, TransactionOptions, PinnedConnectionOptions, ColumnJsReadType, ExpressionIntent, UnsupportedFeatureBehavior, FeatureBehaviorConfig, RangeValue, RangeOperand, CompiledQuery } from '@dbsp/types';
|
|
3
|
-
export { Adapter, AdapterLogger, AlterColumnOptions, AmbiguousIncludeError, Assumption, BaseAdapter, Cardinality, ColumnIR, ColumnType, CompileOptions, CompiledQuery, CompilingAdapter, CreateIndexOptions, DbCasing, DialectCapabilities, DropIndexOptions, Dump, ExecutingAdapter, IncludeStrategy, IndexColumnDef, IndexIR, IndexInfo, IndexMethod, IntrospectingAdapter, ModelIR, Optionality, PlanDecision, PlanOptions, PlanReport, PlanWarning, ProvenPlanStep, RangeValue, RawSqlAdapter, StreamingAdapter, TableIR, TransactionalAdapter, TruncateOptions, VacuumOptions } from '@dbsp/types';
|
|
3
|
+
export { Adapter, AdapterLogger, AlterColumnOptions, AmbiguousIncludeError, Assumption, BaseAdapter, Cardinality, ColumnIR, ColumnType, CompileOptions, CompiledQuery, CompilingAdapter, CreateIndexOptions, DbCasing, DialectCapabilities, DropIndexOptions, Dump, ExecutingAdapter, IncludeStrategy, IndexColumnDef, IndexIR, IndexInfo, IndexMethod, IntrospectingAdapter, ModelIR, NotYetSupportedError, Optionality, PlanDecision, PlanOptions, PlanReport, PlanWarning, ProvenPlanStep, RangeValue, RawSqlAdapter, StreamingAdapter, TableIR, TransactionalAdapter, TruncateOptions, VacuumOptions } from '@dbsp/types';
|
|
4
4
|
import { IncludeIntent, SelectIntent, WhereIntent, AggregateIntent, OrderByIntent, JoinIntent, QueryIntent, WhereRangeIntent } from '@dbsp/types/internal';
|
|
5
5
|
export { AggregateExpressionIntent, AggregateIntent, ExpressionIntent, IncludeIntent, InsertFromIntent, InsertIntent, JoinIntent, MutationIntent, OrderByIntent, QueryIntent, RecursiveIntent, SelectAggregateIntent, SelectFieldsIntent, SelectIntent, SelectWithExpressionsIntent, SubqueryRefIntent, UpsertFromIntent, WhereAndIntent, WhereComparisonIntent, WhereInIntent, WhereIntent, WhereLikeIntent, WhereNotIntent, WhereNullIntent, WhereOrIntent, WhereRangeIntent, WindowIntent, isDeleteIntent, isInsertIntent, isUpdateIntent, isUpsertIntent } from '@dbsp/types/internal';
|
|
6
|
-
import { P as PackRegistry, T as TransitionRunPersister, R as RecursiveIncludeOptions, D as DefaultFilters, H as HookStore, a as HookErrorHandler, O as ObserverErrorHandler, Q as QueryBuilder, b as RelationHints, I as IncludeOptionsWithRecursive, A as AliasedExprColumn, C as ColumnSpec, c as AggregateOptions, d as DistinctField, e as OrderByRecord, f as OrderBySpec, E as ExpressionRef, g as ExpressionSpec, N as NullsPosition, h as PredicateRef, W as WhereFilter, B as BatchValuesRef, i as DumpMetaInput, S as StreamOptions, j as PaginateOptions, k as PaginatedResult, l as CursorPaginateOptions, m as CursorPaginatedResult, n as SetOperationBuilder, o as TableRef, p as ColumnRef, q as InsertBuilder, U as UpdateBuilder, r as DeleteBuilder, s as UpsertBuilder, t as InferTableRow, L as ListHierarchyOptions, u as NqlTag, v as BatchValuesOptions, w as Schema, x as SchemaDefinition, y as InferDB, z as PredicateExpressionRef, F as AssertionBlock, G as AssertionQueryResult, J as AssertionSummary, K as HookManager } from './assertion-functions-
|
|
7
|
-
export { M as AfterMutationHook, V as AfterMutationObserver, X as AfterQueryHook, Y as AfterQueryObserver, Z as AmbiguousPlanError, _ as Assertion, $ as AssertionOutcome, a0 as BeforeMutationHook, a1 as BeforeQueryHook, a2 as ColumnDef, a3 as IncludeOptions, a4 as IntentSummary, a5 as JsonValue, a6 as ManyToManyDefinition, a7 as ManyToManyOptions, a8 as MutationDump, a9 as MutationHookContext, aa as NqlBuilder, ab as OnErrorHook, ac as POSTGRESQL_CAPABILITIES, ad as ParseError, ae as ParseResult, af as QueryAssertionResult, ag as QueryHookContext, ah as RefOptions, ai as RelationRef, aj as SchemaColumnType, ak as SchemaIndexOptions, al as SchemaOptions, am as SchemaTableOptions, an as SelfRefRoles, ao as SqlRawExpression, ap as SubqueryBuilder, aq as SubqueryExpression, ar as TABLE_META, as as TableDef, at as admitRecordedIdentity, au as aggOrderBy, av as and, aw as any, ax as array, ay as arrayAgg, az as assertEquals, aA as assertParamsEquals, aB as assertParamsType, aC as assertSQLEquals, aD as batchValues, aE as boolFn, aF as cast, aG as coalesce, aH as col, aI as createHookManager, aJ as distinct, aK as eq, aL as every, aM as exists, aN as exprRef, aO as extractPseudoColumnKeywords, aP as fn, aQ as getSchemaFromDb, aR as gt, aS as gte, aT as inArray, aU as inSubquery, aV as isBatchValuesRef, aW as isDistinctFrom, aX as isNotNull, aY as isNull, aZ as isOperationRuntime, a_ as isRef, a$ as isSqlRaw, b0 as like, b1 as literal, b2 as lt, b3 as lte, b4 as manyToMany, b5 as namedArg, b6 as neq, b7 as none, b8 as not, b9 as notExists, ba as nqlRaw, bb as op, bc as or, bd as outerRef, be as param, bf as parseAssertionFile, bg as plan, bh as planRecursive, bi as raw, bj as rawExists, bk as ref, bl as relationColumn, bm as schema, bn as some, bo as sql, bp as star, bq as subquery, br as unary, bs as unsafeAsPredicate, bt as validateAssertionBlocks } from './assertion-functions-
|
|
6
|
+
import { P as PackRegistry, T as TransitionRunPersister, R as RecursiveIncludeOptions, D as DefaultFilters, H as HookStore, a as HookErrorHandler, O as ObserverErrorHandler, Q as QueryBuilder, b as RelationHints, I as IncludeOptionsWithRecursive, A as AliasedExprColumn, C as ColumnSpec, c as AggregateOptions, d as DistinctField, e as OrderByRecord, f as OrderBySpec, E as ExpressionRef, g as ExpressionSpec, N as NullsPosition, h as PredicateRef, W as WhereFilter, B as BatchValuesRef, i as DumpMetaInput, S as StreamOptions, j as PaginateOptions, k as PaginatedResult, l as CursorPaginateOptions, m as CursorPaginatedResult, n as SetOperationBuilder, o as TableRef, p as ColumnRef, q as InsertBuilder, U as UpdateBuilder, r as DeleteBuilder, s as UpsertBuilder, t as InferTableRow, L as ListHierarchyOptions, u as NqlTag, v as BatchValuesOptions, w as Schema, x as SchemaDefinition, y as InferDB, z as PredicateExpressionRef, F as AssertionBlock, G as AssertionQueryResult, J as AssertionSummary, K as HookManager } from './assertion-functions-dyf-Q__5.js';
|
|
7
|
+
export { M as AfterMutationHook, V as AfterMutationObserver, X as AfterQueryHook, Y as AfterQueryObserver, Z as AmbiguousPlanError, _ as Assertion, $ as AssertionOutcome, a0 as BeforeMutationHook, a1 as BeforeQueryHook, a2 as ColumnDef, a3 as IncludeOptions, a4 as IntentSummary, a5 as JsonValue, a6 as ManyToManyDefinition, a7 as ManyToManyOptions, a8 as MutationDump, a9 as MutationHookContext, aa as NqlBuilder, ab as OnErrorHook, ac as POSTGRESQL_CAPABILITIES, ad as ParseError, ae as ParseResult, af as QueryAssertionResult, ag as QueryHookContext, ah as RefOptions, ai as RelationRef, aj as SchemaColumnType, ak as SchemaIndexOptions, al as SchemaOptions, am as SchemaTableOptions, an as SelfRefRoles, ao as SqlRawExpression, ap as SubqueryBuilder, aq as SubqueryExpression, ar as TABLE_META, as as TableDef, at as admitRecordedIdentity, au as aggOrderBy, av as and, aw as any, ax as array, ay as arrayAgg, az as assertEquals, aA as assertParamsEquals, aB as assertParamsType, aC as assertSQLEquals, aD as batchValues, aE as boolFn, aF as cast, aG as coalesce, aH as col, aI as createHookManager, aJ as distinct, aK as eq, aL as every, aM as exists, aN as exprRef, aO as extractPseudoColumnKeywords, aP as fn, aQ as getSchemaFromDb, aR as gt, aS as gte, aT as inArray, aU as inSubquery, aV as isBatchValuesRef, aW as isDistinctFrom, aX as isNotNull, aY as isNull, aZ as isOperationRuntime, a_ as isRef, a$ as isSqlRaw, b0 as like, b1 as literal, b2 as lt, b3 as lte, b4 as manyToMany, b5 as namedArg, b6 as neq, b7 as none, b8 as not, b9 as notExists, ba as nqlRaw, bb as op, bc as or, bd as outerRef, be as param, bf as parseAssertionFile, bg as plan, bh as planRecursive, bi as raw, bj as rawExists, bk as ref, bl as relationColumn, bm as schema, bn as some, bo as sql, bp as star, bq as subquery, br as unary, bs as unsafeAsPredicate, bt as validateAssertionBlocks } from './assertion-functions-dyf-Q__5.js';
|
|
8
8
|
import '@dbsp/nql';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -221,7 +221,7 @@ declare class QueryBuilderImpl<TResult = unknown> implements QueryBuilder<TResul
|
|
|
221
221
|
*/
|
|
222
222
|
private getEffectiveStrictMode;
|
|
223
223
|
private withDefaultFilterPlanOptions;
|
|
224
|
-
plan(): PlanReport;
|
|
224
|
+
plan(localSources?: readonly string[]): PlanReport;
|
|
225
225
|
all(): Promise<TResult[]>;
|
|
226
226
|
first(): Promise<TResult | undefined>;
|
|
227
227
|
firstOrThrow(): Promise<TResult>;
|
|
@@ -346,7 +346,7 @@ declare class QueryBuilderImpl<TResult = unknown> implements QueryBuilder<TResul
|
|
|
346
346
|
* ```
|
|
347
347
|
*/
|
|
348
348
|
/** @internal — keep each relational body bound to its issuing policy. */
|
|
349
|
-
buildRelationalReadIntent(path: string, bindings?: readonly string[]): QueryIntent;
|
|
349
|
+
buildRelationalReadIntent(path: string, bindings?: readonly string[], localSources?: readonly string[]): QueryIntent;
|
|
350
350
|
/** @internal — remaining legacy read issuers keep refusing filtered scans. */
|
|
351
351
|
buildUnplannedReadIntent(path: string): QueryIntent;
|
|
352
352
|
union(other: QueryBuilder<TResult>): SetOperationBuilder<TResult>;
|
package/dist/index.js
CHANGED
|
@@ -121,10 +121,10 @@ import {
|
|
|
121
121
|
wMax,
|
|
122
122
|
wMin,
|
|
123
123
|
wSum
|
|
124
|
-
} from "./chunk-
|
|
124
|
+
} from "./chunk-5UI5IH5U.js";
|
|
125
125
|
|
|
126
126
|
// src/index.ts
|
|
127
|
-
import { AmbiguousIncludeError } from "@dbsp/types";
|
|
127
|
+
import { AmbiguousIncludeError, NotYetSupportedError } from "@dbsp/types";
|
|
128
128
|
var export_isDeleteIntent = intent_ast_exports.isDeleteIntent;
|
|
129
129
|
var export_isInsertIntent = intent_ast_exports.isInsertIntent;
|
|
130
130
|
var export_isUpdateIntent = intent_ast_exports.isUpdateIntent;
|
|
@@ -148,6 +148,7 @@ export {
|
|
|
148
148
|
InvalidOperationError,
|
|
149
149
|
ModelIRImpl,
|
|
150
150
|
NotFoundError,
|
|
151
|
+
NotYetSupportedError,
|
|
151
152
|
POSTGRESQL_CAPABILITIES,
|
|
152
153
|
RawCteQueryBuilder,
|
|
153
154
|
RelationNotFoundError,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @dbsp/core\n * Schema definition and query planning for db-semantic-planner.\n */\n\n// ============================================================================\n// ModelIR Types\n// ============================================================================\n\nexport type {\n\tCardinality,\n\tColumnIR,\n\tColumnType,\n\tIncludeStrategy,\n\tIndexIR,\n\tModelIR,\n\tOptionality,\n\tTableIR,\n} from './model-ir.js';\n\n// CLI-NQL: Relation kind helpers and pseudo-column factory\n\n// ============================================================================\n// IntentAST Types\n// ============================================================================\n\nexport type {\n\tAggregateExpressionIntent,\n\tAggregateIntent,\n\tExpressionIntent,\n\tIncludeIntent,\n\tInsertFromIntent,\n\tInsertIntent,\n\tJoinIntent,\n\tMutationIntent,\n\tOrderByIntent,\n\tQueryIntent,\n\tRecursiveIntent,\n\tSelectAggregateIntent,\n\tSelectFieldsIntent,\n\tSelectIntent,\n\tSelectWithExpressionsIntent,\n\tSubqueryRefIntent,\n\tUpsertFromIntent,\n\tWhereAndIntent,\n\tWhereComparisonIntent,\n\tWhereInIntent,\n\tWhereIntent,\n\tWhereLikeIntent,\n\tWhereNotIntent,\n\tWhereNullIntent,\n\tWhereOrIntent,\n\tWhereRangeIntent,\n\tWindowIntent,\n} from './intent-ast.js';\nexport {\n\tisDeleteIntent,\n\tisInsertIntent,\n\tisUpdateIntent,\n\tisUpsertIntent,\n} from './intent-ast.js';\n\n// ============================================================================\n// Schema DSL (User-facing API)\n// ============================================================================\n\n// ARCH-005: Unified Schema API\nexport {\n\ttype ColumnDef,\n\tgetSchemaFromDb,\n\tisRef,\n\ttype JsonValue,\n\ttype ManyToManyDefinition,\n\ttype ManyToManyOptions,\n\tmanyToMany,\n\ttype RefOptions,\n\tref,\n\ttype Schema,\n\ttype SchemaColumnType,\n\ttype SchemaDefinition,\n\ttype SchemaTableOptions,\n\ttype SelfRefRoles,\n\tschema,\n\ttype TableDef,\n} from './dx/schema.js';\n\n// ============================================================================\n// Conventions (pluralization and casing)\n// ============================================================================\n\nexport {\n\tIRREGULAR_PLURALS,\n\tpluralize,\n\tsingularize,\n} from './conventions.js';\n\n// ============================================================================\n// Semantic Planner\n// ============================================================================\n\nexport { AmbiguousIncludeError } from '@dbsp/types';\nexport type {\n\tPlanDecision,\n\tPlanOptions,\n\tPlanReport,\n\tPlanWarning,\n} from './planner.js';\nexport {\n\tAmbiguousPlanError,\n\tplan,\n\tplanRecursive,\n} from './planner.js';\n\n// ============================================================================\n// ADR-0003 Transition Planner Interfaces\n// ============================================================================\n\nexport type {\n\tAssumption,\n\tProvenPlanStep,\n} from './transition/index.js';\nexport {\n\tadmitRecordedIdentity,\n\tcreateStagedTransitionOrchestrator,\n\tisOperationRuntime,\n} from './transition/index.js';\n\n// ============================================================================\n// Implementation (for advanced use cases)\n// ============================================================================\n\nexport { ModelIRImpl } from './model-impl.js';\n\n// ============================================================================\n// Adapter Interface (for multi-adapter support)\n// ============================================================================\n\nexport type {\n\tAdapter,\n\tAdapterLogger,\n\tBaseAdapter,\n\tCompiledQuery,\n\tCompileOptions,\n\tCompilingAdapter,\n\tDbCasing,\n\tDump,\n\tExecutingAdapter,\n\tIntrospectingAdapter,\n\tRawSqlAdapter,\n\tStreamingAdapter,\n\tTransactionalAdapter,\n} from './adapter.js';\n\n// ============================================================================\n// DX Layer (Developer Experience)\n// ============================================================================\n\nexport {\n\ttype AfterMutationHook,\n\ttype AfterMutationObserver,\n\ttype AfterQueryHook,\n\ttype AfterQueryObserver,\n\ttype AggregateOptions,\n\ttype AlterColumnOptions,\n\tAmbiguousRelationError,\n\taggOrderBy,\n\tand,\n\tany,\n\tarray,\n\tarrayAgg,\n\ttype BatchValuesOptions,\n\ttype BatchValuesRef,\n\ttype BeforeMutationHook,\n\ttype BeforeQueryHook,\n\tbatchValues,\n\tboolFn,\n\tCaseBuilder,\n\ttype CaseValue,\n\tColumnNotFoundError,\n\ttype ColumnRef,\n\ttype ColumnSpec,\n\ttype CreateIndexOptions,\n\tCteBuilder,\n\tCteQueryBuilder,\n\ttype CursorPaginatedResult,\n\ttype CursorPaginateOptions,\n\tcaseWhen,\n\tcast,\n\tcoalesce,\n\tcol,\n\tcreateHookManager,\n\tcreateOrm,\n\tcreateRawCteBuilder,\n\tDeleteBuilder,\n\ttype DistinctField,\n\ttype DropIndexOptions,\n\tdenseRank,\n\tdistinct,\n\tErrorCode,\n\tErrors,\n\tExecutionError,\n\tExpressionRef,\n\ttype ExpressionSpec,\n\temitWarning,\n\teq,\n\tevery,\n\texists,\n\texprRef,\n\textractPseudoColumnKeywords,\n\ttype FullTextSearchField,\n\tfn,\n\tfullTextSearch,\n\tgetLogger,\n\tgt,\n\tgte,\n\ttype HookManager,\n\ttype IncludeOptions,\n\ttype IndexColumnDef,\n\ttype IndexInfo,\n\ttype IndexMethod,\n\ttype InferTableRow,\n\tInsertBuilder,\n\tInvalidOperationError,\n\tinArray,\n\tinSubquery,\n\tisBatchValuesRef,\n\tisDistinctFrom,\n\tisNotNull,\n\tisNull,\n\tisSqlRaw,\n\ttype Logger,\n\tlag,\n\tlead,\n\tlike,\n\tliteral,\n\tlt,\n\tlte,\n\ttype MutationDump,\n\ttype MutationHookContext,\n\tNotFoundError,\n\ttype NqlBuilder,\n\ttype NqlTag,\n\tnamedArg,\n\tneq,\n\tnone,\n\tnot,\n\tnotExists,\n\tnqlRaw,\n\ttype OnErrorHook,\n\ttype OrmInstance,\n\ttype OrmOf,\n\top,\n\tor,\n\touterRef,\n\ttype PaginatedResult,\n\ttype PaginateOptions,\n\ttype PredicateExpressionRef,\n\ttype PredicateRef,\n\tparam,\n\ttype QueryBuilder,\n\ttype QueryHookContext,\n\ttype RangeType,\n\ttype RangeValue,\n\tRawCteQueryBuilder,\n\ttype RecursiveOptions,\n\ttype RelationHints,\n\tRelationNotFoundError,\n\ttype RelationRef,\n\tResultHydrator,\n\trangeContainedBy,\n\trangeContains,\n\trangeOverlaps,\n\trank,\n\traw,\n\trawExists,\n\trelationColumn,\n\tresetLogger,\n\trowNumber,\n\ttype SchemaIndexOptions,\n\ttype SchemaOptions,\n\ttype SetOperationBuilder,\n\ttype SqlRawExpression,\n\ttype StreamOptions,\n\tSubqueryBuilder,\n\tSubqueryExpression,\n\tsetLogger,\n\tsilentLogger,\n\tsome,\n\tsql,\n\tstar,\n\tsubquery,\n\tTABLE_META,\n\ttype TableDDL,\n\ttype TableIndexes,\n\tTableNotFoundError,\n\ttype TableRef,\n\ttype TruncateOptions,\n\ttextScore,\n\tUnsafeOperationError,\n\tUpdateBuilder,\n\tUpsertBuilder,\n\tunary,\n\tunsafeAsPredicate,\n\ttype VacuumOptions,\n\ttype WarningCategory,\n\twAvg,\n\twCount,\n\twMax,\n\twMin,\n\twSum,\n} from './dx/index.js';\n\n// ============================================================================\n// Dialect Capabilities (CORE-004)\n// ============================================================================\n\nexport type { DialectCapabilities } from './dialects/index.js';\nexport { POSTGRESQL_CAPABILITIES } from './dialects/index.js';\n\n// ============================================================================\n// SQL Utilities\n// ============================================================================\n\nexport { normalizeSQL } from './sql-utils.js';\n\n// ============================================================================\n// Assertion System (.assert.dbsp)\n// ============================================================================\n\nexport type {\n\tAssertion,\n\tAssertionOutcome,\n\tAssertionQueryResult,\n\tAssertionSummary,\n\tIntentSummary,\n\tParseError,\n\tParseResult,\n\tQueryAssertionResult,\n} from './assert/index.js';\nexport {\n\tassertEquals,\n\tassertParamsEquals,\n\tassertParamsType,\n\tassertSQLEquals,\n\tparseAssertionFile,\n\trunAssertions,\n\tvalidateAssertionBlocks,\n} from './assert/index.js';\n\nexport { InvalidJsonAggPayloadError } from './dx/include-payload-hydration.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGA,SAAS,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @dbsp/core\n * Schema definition and query planning for db-semantic-planner.\n */\n\n// ============================================================================\n// ModelIR Types\n// ============================================================================\n\nexport type {\n\tCardinality,\n\tColumnIR,\n\tColumnType,\n\tIncludeStrategy,\n\tIndexIR,\n\tModelIR,\n\tOptionality,\n\tTableIR,\n} from './model-ir.js';\n\n// CLI-NQL: Relation kind helpers and pseudo-column factory\n\n// ============================================================================\n// IntentAST Types\n// ============================================================================\n\nexport type {\n\tAggregateExpressionIntent,\n\tAggregateIntent,\n\tExpressionIntent,\n\tIncludeIntent,\n\tInsertFromIntent,\n\tInsertIntent,\n\tJoinIntent,\n\tMutationIntent,\n\tOrderByIntent,\n\tQueryIntent,\n\tRecursiveIntent,\n\tSelectAggregateIntent,\n\tSelectFieldsIntent,\n\tSelectIntent,\n\tSelectWithExpressionsIntent,\n\tSubqueryRefIntent,\n\tUpsertFromIntent,\n\tWhereAndIntent,\n\tWhereComparisonIntent,\n\tWhereInIntent,\n\tWhereIntent,\n\tWhereLikeIntent,\n\tWhereNotIntent,\n\tWhereNullIntent,\n\tWhereOrIntent,\n\tWhereRangeIntent,\n\tWindowIntent,\n} from './intent-ast.js';\nexport {\n\tisDeleteIntent,\n\tisInsertIntent,\n\tisUpdateIntent,\n\tisUpsertIntent,\n} from './intent-ast.js';\n\n// ============================================================================\n// Schema DSL (User-facing API)\n// ============================================================================\n\n// ARCH-005: Unified Schema API\nexport {\n\ttype ColumnDef,\n\tgetSchemaFromDb,\n\tisRef,\n\ttype JsonValue,\n\ttype ManyToManyDefinition,\n\ttype ManyToManyOptions,\n\tmanyToMany,\n\ttype RefOptions,\n\tref,\n\ttype Schema,\n\ttype SchemaColumnType,\n\ttype SchemaDefinition,\n\ttype SchemaTableOptions,\n\ttype SelfRefRoles,\n\tschema,\n\ttype TableDef,\n} from './dx/schema.js';\n\n// ============================================================================\n// Conventions (pluralization and casing)\n// ============================================================================\n\nexport {\n\tIRREGULAR_PLURALS,\n\tpluralize,\n\tsingularize,\n} from './conventions.js';\n\n// ============================================================================\n// Semantic Planner\n// ============================================================================\n\nexport { AmbiguousIncludeError, NotYetSupportedError } from '@dbsp/types';\nexport type {\n\tPlanDecision,\n\tPlanOptions,\n\tPlanReport,\n\tPlanWarning,\n} from './planner.js';\nexport {\n\tAmbiguousPlanError,\n\tplan,\n\tplanRecursive,\n} from './planner.js';\n\n// ============================================================================\n// ADR-0003 Transition Planner Interfaces\n// ============================================================================\n\nexport type {\n\tAssumption,\n\tProvenPlanStep,\n} from './transition/index.js';\nexport {\n\tadmitRecordedIdentity,\n\tcreateStagedTransitionOrchestrator,\n\tisOperationRuntime,\n} from './transition/index.js';\n\n// ============================================================================\n// Implementation (for advanced use cases)\n// ============================================================================\n\nexport { ModelIRImpl } from './model-impl.js';\n\n// ============================================================================\n// Adapter Interface (for multi-adapter support)\n// ============================================================================\n\nexport type {\n\tAdapter,\n\tAdapterLogger,\n\tBaseAdapter,\n\tCompiledQuery,\n\tCompileOptions,\n\tCompilingAdapter,\n\tDbCasing,\n\tDump,\n\tExecutingAdapter,\n\tIntrospectingAdapter,\n\tRawSqlAdapter,\n\tStreamingAdapter,\n\tTransactionalAdapter,\n} from './adapter.js';\n\n// ============================================================================\n// DX Layer (Developer Experience)\n// ============================================================================\n\nexport {\n\ttype AfterMutationHook,\n\ttype AfterMutationObserver,\n\ttype AfterQueryHook,\n\ttype AfterQueryObserver,\n\ttype AggregateOptions,\n\ttype AlterColumnOptions,\n\tAmbiguousRelationError,\n\taggOrderBy,\n\tand,\n\tany,\n\tarray,\n\tarrayAgg,\n\ttype BatchValuesOptions,\n\ttype BatchValuesRef,\n\ttype BeforeMutationHook,\n\ttype BeforeQueryHook,\n\tbatchValues,\n\tboolFn,\n\tCaseBuilder,\n\ttype CaseValue,\n\tColumnNotFoundError,\n\ttype ColumnRef,\n\ttype ColumnSpec,\n\ttype CreateIndexOptions,\n\tCteBuilder,\n\tCteQueryBuilder,\n\ttype CursorPaginatedResult,\n\ttype CursorPaginateOptions,\n\tcaseWhen,\n\tcast,\n\tcoalesce,\n\tcol,\n\tcreateHookManager,\n\tcreateOrm,\n\tcreateRawCteBuilder,\n\tDeleteBuilder,\n\ttype DistinctField,\n\ttype DropIndexOptions,\n\tdenseRank,\n\tdistinct,\n\tErrorCode,\n\tErrors,\n\tExecutionError,\n\tExpressionRef,\n\ttype ExpressionSpec,\n\temitWarning,\n\teq,\n\tevery,\n\texists,\n\texprRef,\n\textractPseudoColumnKeywords,\n\ttype FullTextSearchField,\n\tfn,\n\tfullTextSearch,\n\tgetLogger,\n\tgt,\n\tgte,\n\ttype HookManager,\n\ttype IncludeOptions,\n\ttype IndexColumnDef,\n\ttype IndexInfo,\n\ttype IndexMethod,\n\ttype InferTableRow,\n\tInsertBuilder,\n\tInvalidOperationError,\n\tinArray,\n\tinSubquery,\n\tisBatchValuesRef,\n\tisDistinctFrom,\n\tisNotNull,\n\tisNull,\n\tisSqlRaw,\n\ttype Logger,\n\tlag,\n\tlead,\n\tlike,\n\tliteral,\n\tlt,\n\tlte,\n\ttype MutationDump,\n\ttype MutationHookContext,\n\tNotFoundError,\n\ttype NqlBuilder,\n\ttype NqlTag,\n\tnamedArg,\n\tneq,\n\tnone,\n\tnot,\n\tnotExists,\n\tnqlRaw,\n\ttype OnErrorHook,\n\ttype OrmInstance,\n\ttype OrmOf,\n\top,\n\tor,\n\touterRef,\n\ttype PaginatedResult,\n\ttype PaginateOptions,\n\ttype PredicateExpressionRef,\n\ttype PredicateRef,\n\tparam,\n\ttype QueryBuilder,\n\ttype QueryHookContext,\n\ttype RangeType,\n\ttype RangeValue,\n\tRawCteQueryBuilder,\n\ttype RecursiveOptions,\n\ttype RelationHints,\n\tRelationNotFoundError,\n\ttype RelationRef,\n\tResultHydrator,\n\trangeContainedBy,\n\trangeContains,\n\trangeOverlaps,\n\trank,\n\traw,\n\trawExists,\n\trelationColumn,\n\tresetLogger,\n\trowNumber,\n\ttype SchemaIndexOptions,\n\ttype SchemaOptions,\n\ttype SetOperationBuilder,\n\ttype SqlRawExpression,\n\ttype StreamOptions,\n\tSubqueryBuilder,\n\tSubqueryExpression,\n\tsetLogger,\n\tsilentLogger,\n\tsome,\n\tsql,\n\tstar,\n\tsubquery,\n\tTABLE_META,\n\ttype TableDDL,\n\ttype TableIndexes,\n\tTableNotFoundError,\n\ttype TableRef,\n\ttype TruncateOptions,\n\ttextScore,\n\tUnsafeOperationError,\n\tUpdateBuilder,\n\tUpsertBuilder,\n\tunary,\n\tunsafeAsPredicate,\n\ttype VacuumOptions,\n\ttype WarningCategory,\n\twAvg,\n\twCount,\n\twMax,\n\twMin,\n\twSum,\n} from './dx/index.js';\n\n// ============================================================================\n// Dialect Capabilities (CORE-004)\n// ============================================================================\n\nexport type { DialectCapabilities } from './dialects/index.js';\nexport { POSTGRESQL_CAPABILITIES } from './dialects/index.js';\n\n// ============================================================================\n// SQL Utilities\n// ============================================================================\n\nexport { normalizeSQL } from './sql-utils.js';\n\n// ============================================================================\n// Assertion System (.assert.dbsp)\n// ============================================================================\n\nexport type {\n\tAssertion,\n\tAssertionOutcome,\n\tAssertionQueryResult,\n\tAssertionSummary,\n\tIntentSummary,\n\tParseError,\n\tParseResult,\n\tQueryAssertionResult,\n} from './assert/index.js';\nexport {\n\tassertEquals,\n\tassertParamsEquals,\n\tassertParamsType,\n\tassertSQLEquals,\n\tparseAssertionFile,\n\trunAssertions,\n\tvalidateAssertionBlocks,\n} from './assert/index.js';\n\nexport { InvalidJsonAggPayloadError } from './dx/include-payload-hydration.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGA,SAAS,uBAAuB,4BAA4B;","names":[]}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseAdapter, ExecutingAdapter, StreamingAdapter, TransactionalAdapter, CheckConstraintIR, Comparator, ObservationContext, AdmittedOutcomeClaim, DestructiveAuthorityPermit, DestructiveDecision, OutcomeClaimAdmissionInput, OutcomeClaimAdmission, OutcomeProtocolRefusal, DestructiveAction, DestructiveAuthorityEvidence, EnumIR, EvidenceObservation, ObservationRequest, EvidenceView, ProofObligation, ExecutionContract, ExecutionRequirement, AdvisoryObservationId, AssumptionId, ClaimId, EvidenceId, SemanticArtifactId, IndexIR, LedgerHome, LedgerAddress, LedgerChainMember, LedgerChainProjection, ClaimToken, OutcomeRecoveryInput, OutcomeRecoveryClassification, ClaimBundleStatement, ClaimStatementBundle, OutcomeClaimPlan, ProvenPlanShape, Assumption, ApplyPolicy, ResourceAddress, ResourceSelector, TransitionRunMetadata, NormalizedManagedStep, TransitionFragment, ProofClaim, OperationEffectAssessment, WhereIntent, QueryIntent, PlanReport, ResolvedRange, RangeAllocator, ModelIR, ResolvedCondition, PlanDecision, SelectExecution } from '@dbsp/types';
|
|
2
2
|
export { AdapterCapabilities, AdapterStreamOptions, ApplicableEvaluation, ApplyPolicy, CapabilityDescriptor, ColumnJsReadType, CompareOutcome, DumpMeta, DurableIntentRecord, ExclusiveTransitionTarget, FingerprintManifest, ForeignKeyIR, LogicalIdentity, ObservationContext, ObservationIssuer, ObservationRequest, OnDeleteAction, OperationEffectAssessment, PhysicalOperation, ProvenPlanShape, RecognitionResult, RecursivePlanReport, RelationIR, RelationType, ResourceAddress, RuleEvaluation, StepJournal, TableReaddressDeclaration, TransactionOptions, TransactionalCompletionRecord, TransitionLessor, TransitionQueryClient, TransitionRule, TransitionRunMetadata, TransitionSessionClient } from '@dbsp/types';
|
|
3
|
-
import { P as PackRegistry, T as TransitionRunPersister, bu as Applier, bv as InProcessProvenPlan, bw as Prover } from './assertion-functions-
|
|
4
|
-
export { bx as ASSERTION_TYPES, F as AssertionBlock, by as DUCKDB_CAPABILITIES, bz as DurablyLoadedRun, bA as ExecutionCoordinator, bB as MSSQL_CAPABILITIES, bC as MYSQL_CAPABILITIES, bD as ManagedOutcomeExecutionRequest, bE as ManagedOutcomePreflightRequest, bF as NonRollbackableExecutionTracker, e as OrderByRecord, bG as
|
|
3
|
+
import { P as PackRegistry, T as TransitionRunPersister, bu as Applier, bv as InProcessProvenPlan, bw as Prover } from './assertion-functions-dyf-Q__5.js';
|
|
4
|
+
export { bx as ASSERTION_TYPES, F as AssertionBlock, by as DUCKDB_CAPABILITIES, bz as DurablyLoadedRun, bA as ExecutionCoordinator, bB as MSSQL_CAPABILITIES, bC as MYSQL_CAPABILITIES, bD as ManagedOutcomeExecutionRequest, bE as ManagedOutcomePreflightRequest, bF as NonRollbackableExecutionTracker, e as OrderByRecord, bG as PlanScope, bH as RefDefinition, bI as RegisteredOperationSemantics, bJ as SQLITE_CAPABILITIES, bK as TRANSITION_LESSOR_REJECTION, bL as TransitionExecutionClient, bM as TransitionLeaseFailure, bN as TransitionPack, bO as acquireExclusiveTransitionLease, bP as acquireTransitionLease, bQ as acquireTransitionTargetLease, bR as assertCanonicalizableJson, bS as assertContains, bT as assertDbColumnExists, bU as assertDbOutput, bV as assertDbRowsEquals, bW as assertDbRowsMax, bX as assertDbRowsMin, bY as assertDbValueEquals, bZ as assertIntentHasGroupBy, b_ as assertIntentHasOrderBy, b$ as assertIntentHasWhere, c0 as assertIntentTable, c1 as assertIntentType, c2 as assertIntentWith, c3 as assertMatches, c4 as assertParamsLength, c5 as assertParamsValue, c6 as assertSQLColumn, c7 as assertSQLJoin, c8 as assertSQLTable, c9 as assertSuccess, ca as bindDeclarationSet, cb as compileNqlRead, cc as createBindingFinalPlan, cd as createExclusiveTransitionTarget, ce as createPackRegistry, cf as createTransitionLessor, cg as declarationSetFromModel, ch as isDurablyLoadedRun, ci as isExclusiveTransitionTarget, cj as isExpressionSpec, ck as isOverallSuccess, cl as isTransitionLessor, cm as isWhereIntent, cn as loadVerifiedRecoveryJournal, co as markTransitionClientCompromised, cp as mintDurablyLoadedRun, cq as normalizeRecursiveIncludeOptions, cr as objectToWhereIntent, cs as planInScope, ct as planOperationSession, cu as rawNotExists, cv as requiresDatabase, cw as resolveQueryIndex, cx as serverVersionNum, cy as stringAgg, cz as transitionPhysicalSessionIsCompromised, cA as validateDeclarationModel, cB as validateIncludeInput, cC as validateIncludeOptions, cD as validateIncludeOrdering, cE as validateIncludeStrategy, cF as validateRecursiveIncludeStrategy, cG as validateRecursiveSetOperation, cH as validateResolvedIncludeStrategy, cI as validateSchemaIndexOptions, cJ as validateTypeName } from './assertion-functions-dyf-Q__5.js';
|
|
5
5
|
export { CaseExpressionIntent, CompileOnlyAdapter, ConnectionAvailability, DeleteIntent, LiteralExpressionIntent, PartitionIR, RequiredEnumLabelIR, SelectAllIntent, UpdateIntent, UpsertIntent, WhereAnyIntent, WhereExistsIntent, WhereNotExistsIntent, WhereRelationFilterIntent, WhereSubqueryIntent, isSubqueryRef } from '@dbsp/types/internal';
|
|
6
6
|
import '@dbsp/nql';
|
|
7
7
|
|
|
@@ -309,7 +309,7 @@ declare function assertNoPathRefInConditionBodies(condition: unknown): void;
|
|
|
309
309
|
declare function getRelationalReadPlan(intent: QueryIntent, queryLocalSource?: boolean): PlanReport | undefined;
|
|
310
310
|
|
|
311
311
|
/** One traversal, with one shared allocator and no reconstruction of ancestor name sets. */
|
|
312
|
-
declare function resolveSelectWhere(where: WhereIntent | undefined, root: ResolvedRange, visible: readonly ResolvedRange[], allocator: RangeAllocator, model: ModelIR | undefined, initialAliasCount?: number, additionalOuterRanges?: readonly ResolvedRange[]): ResolvedCondition | undefined;
|
|
312
|
+
declare function resolveSelectWhere(where: WhereIntent | undefined, root: ResolvedRange, visible: readonly ResolvedRange[], allocator: RangeAllocator, model: ModelIR | undefined, initialAliasCount?: number, additionalOuterRanges?: readonly ResolvedRange[], isLocalSource?: (name: string) => boolean): ResolvedCondition | undefined;
|
|
313
313
|
|
|
314
314
|
/**
|
|
315
315
|
* Called during planning or once after legacy boundary validation. Never by SQL emission.
|
|
@@ -321,6 +321,16 @@ declare function resolveReportIncludes(intent: QueryIntent, decisions: readonly
|
|
|
321
321
|
whereReservedNames?: readonly string[];
|
|
322
322
|
defaultPk?: string;
|
|
323
323
|
deriveFk?: (table: string, pk: string) => string;
|
|
324
|
+
/** Whether a FROM name is a visible query-local source (an NQL binding or a CTE). */
|
|
325
|
+
isLocalSource?: ((name: string) => boolean) | undefined;
|
|
326
|
+
/** A scalar subquery body: the enclosing query's allocator and ranges. */
|
|
327
|
+
nested?: {
|
|
328
|
+
readonly allocator: RangeAllocator;
|
|
329
|
+
readonly enclosing: readonly (readonly ResolvedRange[])[];
|
|
330
|
+
/** The names written for ranges of each enclosing scope, aligned with `enclosing`. */
|
|
331
|
+
readonly qualifiers: readonly ReadonlyMap<string, ResolvedRange>[];
|
|
332
|
+
readonly entryDepth: number;
|
|
333
|
+
};
|
|
324
334
|
}): {
|
|
325
335
|
readonly execution: SelectExecution;
|
|
326
336
|
readonly intent: QueryIntent;
|
package/dist/internal.js
CHANGED
|
@@ -87,6 +87,7 @@ import {
|
|
|
87
87
|
observeIncludeDecisions,
|
|
88
88
|
outcomeClaimEventId,
|
|
89
89
|
outcomeClaimId,
|
|
90
|
+
planInScope,
|
|
90
91
|
planOperationSession,
|
|
91
92
|
projectLedgerChain,
|
|
92
93
|
rawNotExists,
|
|
@@ -118,7 +119,7 @@ import {
|
|
|
118
119
|
validateSchemaIndexOptions,
|
|
119
120
|
validateTransitionRelationalInvariants,
|
|
120
121
|
validateTypeName
|
|
121
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-5UI5IH5U.js";
|
|
122
123
|
|
|
123
124
|
// src/transition/destructive-authority.ts
|
|
124
125
|
import { sameLedgerAddress } from "@dbsp/types";
|
|
@@ -287,6 +288,7 @@ export {
|
|
|
287
288
|
observeIncludeDecisions,
|
|
288
289
|
outcomeClaimEventId,
|
|
289
290
|
outcomeClaimId,
|
|
291
|
+
planInScope,
|
|
290
292
|
planOperationSession,
|
|
291
293
|
projectLedgerChain,
|
|
292
294
|
rawNotExists,
|
package/dist/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/transition/destructive-authority.ts"],"sourcesContent":["import type {\n\tAdmittedOutcomeClaim,\n\tDestructiveAction,\n\tDestructiveAuthorityEvidence,\n\tDestructiveAuthorityPermit,\n\tDestructiveDecision,\n\tOutcomeClaimAdmission,\n\tOutcomeClaimAdmissionInput,\n\tOutcomeProtocolRefusal,\n} from '@dbsp/types';\nimport { sameLedgerAddress } from '@dbsp/types';\nimport { admitOutcomeClaim } from './outcome-protocol.js';\n\nconst permits = new WeakMap<object, { readonly closureDigest?: string }>();\n\nfunction declarationPermits(\n\taction: DestructiveAction,\n\tevidence: DestructiveAuthorityEvidence,\n): boolean {\n\tif (action.kind === 'removal')\n\t\treturn (\n\t\t\tevidence.declaration === 'requires-removal' ||\n\t\t\t(evidence.declaration === 'replacement-requested-by-plan' &&\n\t\t\t\tevidence.replacementAddress !== undefined &&\n\t\t\t\tsameLedgerAddress(evidence.replacementAddress, action.address))\n\t\t);\n\treturn evidence.declaration === 'requires-lossy-change';\n}\n\nfunction refusalReasons(\n\taction: DestructiveAction,\n\tevidence: DestructiveAuthorityEvidence,\n): readonly string[] {\n\tconst reasons: string[] = [];\n\tif (!declarationPermits(action, evidence))\n\t\treasons.push('declaration does not permit this destructive action');\n\tif (evidence.ownership !== 'managed-by-me')\n\t\treasons.push(`ownership is ${evidence.ownership}`);\n\tif (evidence.catalogueIdentity !== 'matches-recorded')\n\t\treasons.push(`catalogue identity is ${evidence.catalogueIdentity}`);\n\tif (evidence.operatorAcceptance !== 'destructive-plan-accepted')\n\t\treasons.push('operator acceptance is absent');\n\tif (\n\t\taction.kind === 'removal' &&\n\t\tevidence.containment !== 'all-contained-or-managed'\n\t)\n\t\treasons.push(\n\t\t\tevidence.containment === 'reaches-unmanaged' &&\n\t\t\t\tevidence.containmentUnmanaged !== undefined\n\t\t\t\t? `containment closure is reaches-unmanaged: ${evidence.containmentUnmanaged.kind} ${evidence.containmentUnmanaged.schema ?? '<database>'}.${evidence.containmentUnmanaged.name}`\n\t\t\t\t: evidence.containment === 'undecidable' &&\n\t\t\t\t\t\tevidence.containmentReason !== undefined\n\t\t\t\t\t? `containment closure is undecidable: ${evidence.containmentReason}`\n\t\t\t\t\t: `containment closure is ${evidence.containment ?? 'undecidable'}`,\n\t\t);\n\tif (evidence.ledgerLineage !== 'matches-database')\n\t\treasons.push(`ledger lineage is ${evidence.ledgerLineage}`);\n\treturn reasons;\n}\n\n/**\n * The total destructive classifier produces a decision for every evidence\n * tuple; only its permitting cells produce positive destructive authority.\n */\nexport function decideDestructiveDecision(\n\taction: DestructiveAction,\n\tevidence: DestructiveAuthorityEvidence,\n): DestructiveDecision {\n\tconst reasons = refusalReasons(action, evidence);\n\tif (reasons.length > 0)\n\t\treturn { kind: 'destructive-decision-refused', action, reasons };\n\tconst permit = Object.freeze({}) as DestructiveAuthorityPermit;\n\tpermits.set(\n\t\tpermit,\n\t\taction.kind === 'removal' && action.closureDigest !== undefined\n\t\t\t? { closureDigest: action.closureDigest }\n\t\t\t: {},\n\t);\n\treturn { kind: 'destructive-decision-permitted', action, permit };\n}\n\n/** Runtime defense for the erased opaque type at adapter boundaries. */\nexport function isDestructiveAuthorityPermit(\n\tpermit: DestructiveAuthorityPermit,\n): boolean {\n\treturn permits.has(permit);\n}\n\n/** The adapter compares this immutable admission set after taking its locks. */\nexport function closureDigestForDestructiveAuthorityPermit(\n\tpermit: DestructiveAuthorityPermit,\n): string | undefined {\n\treturn permits.get(permit)?.closureDigest;\n}\n\n/**\n * Couples the positive authority result to the existing single token producer.\n * The adapter's destructive emitter accepts this value, never raw evidence.\n */\nexport type AdmittedDestructiveOutcomeClaim = AdmittedOutcomeClaim & {\n\treadonly destructivePermit: DestructiveAuthorityPermit;\n};\n\nexport function admitDestructiveOutcomeClaim(input: {\n\treadonly decision: Extract<\n\t\tDestructiveDecision,\n\t\t{ readonly kind: 'destructive-decision-permitted' }\n\t>;\n\treadonly admission: OutcomeClaimAdmissionInput;\n}):\n\t| AdmittedDestructiveOutcomeClaim\n\t| Exclude<OutcomeClaimAdmission, AdmittedOutcomeClaim> {\n\tif (!isDestructiveAuthorityPermit(input.decision.permit)) {\n\t\treturn {\n\t\t\tkind: 'outcome-protocol-refused',\n\t\t\treason: 'destructive authority permit was not minted by the interpreter',\n\t\t};\n\t}\n\tif (\n\t\t!sameLedgerAddress(\n\t\t\tinput.decision.action.address,\n\t\t\tinput.admission.plan.address,\n\t\t)\n\t) {\n\t\treturn {\n\t\t\tkind: 'outcome-protocol-refused',\n\t\t\treason: 'destructive authority address does not match the claim address',\n\t\t};\n\t}\n\tconst admitted = admitOutcomeClaim(input.admission);\n\tif (admitted.kind !== 'admitted-outcome-claim') return admitted;\n\treturn { ...admitted, destructivePermit: input.decision.permit };\n}\n\n/** Attach a real interpreter permit to an adapter-opened, already minted claim. */\nexport function attachDestructiveAuthorityPermit(input: {\n\treadonly decision: Extract<\n\t\tDestructiveDecision,\n\t\t{ readonly kind: 'destructive-decision-permitted' }\n\t>;\n\treadonly claim: AdmittedOutcomeClaim;\n}): AdmittedDestructiveOutcomeClaim | OutcomeProtocolRefusal {\n\tif (!isDestructiveAuthorityPermit(input.decision.permit))\n\t\treturn {\n\t\t\tkind: 'outcome-protocol-refused',\n\t\t\treason: 'destructive authority permit was not minted by the interpreter',\n\t\t};\n\tif (\n\t\t!sameLedgerAddress(input.decision.action.address, input.claim.plan.address)\n\t)\n\t\treturn {\n\t\t\tkind: 'outcome-protocol-refused',\n\t\t\treason: 'destructive authority address does not match the claim address',\n\t\t};\n\treturn { ...input.claim, destructivePermit: input.decision.permit };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/transition/destructive-authority.ts"],"sourcesContent":["import type {\n\tAdmittedOutcomeClaim,\n\tDestructiveAction,\n\tDestructiveAuthorityEvidence,\n\tDestructiveAuthorityPermit,\n\tDestructiveDecision,\n\tOutcomeClaimAdmission,\n\tOutcomeClaimAdmissionInput,\n\tOutcomeProtocolRefusal,\n} from '@dbsp/types';\nimport { sameLedgerAddress } from '@dbsp/types';\nimport { admitOutcomeClaim } from './outcome-protocol.js';\n\nconst permits = new WeakMap<object, { readonly closureDigest?: string }>();\n\nfunction declarationPermits(\n\taction: DestructiveAction,\n\tevidence: DestructiveAuthorityEvidence,\n): boolean {\n\tif (action.kind === 'removal')\n\t\treturn (\n\t\t\tevidence.declaration === 'requires-removal' ||\n\t\t\t(evidence.declaration === 'replacement-requested-by-plan' &&\n\t\t\t\tevidence.replacementAddress !== undefined &&\n\t\t\t\tsameLedgerAddress(evidence.replacementAddress, action.address))\n\t\t);\n\treturn evidence.declaration === 'requires-lossy-change';\n}\n\nfunction refusalReasons(\n\taction: DestructiveAction,\n\tevidence: DestructiveAuthorityEvidence,\n): readonly string[] {\n\tconst reasons: string[] = [];\n\tif (!declarationPermits(action, evidence))\n\t\treasons.push('declaration does not permit this destructive action');\n\tif (evidence.ownership !== 'managed-by-me')\n\t\treasons.push(`ownership is ${evidence.ownership}`);\n\tif (evidence.catalogueIdentity !== 'matches-recorded')\n\t\treasons.push(`catalogue identity is ${evidence.catalogueIdentity}`);\n\tif (evidence.operatorAcceptance !== 'destructive-plan-accepted')\n\t\treasons.push('operator acceptance is absent');\n\tif (\n\t\taction.kind === 'removal' &&\n\t\tevidence.containment !== 'all-contained-or-managed'\n\t)\n\t\treasons.push(\n\t\t\tevidence.containment === 'reaches-unmanaged' &&\n\t\t\t\tevidence.containmentUnmanaged !== undefined\n\t\t\t\t? `containment closure is reaches-unmanaged: ${evidence.containmentUnmanaged.kind} ${evidence.containmentUnmanaged.schema ?? '<database>'}.${evidence.containmentUnmanaged.name}`\n\t\t\t\t: evidence.containment === 'undecidable' &&\n\t\t\t\t\t\tevidence.containmentReason !== undefined\n\t\t\t\t\t? `containment closure is undecidable: ${evidence.containmentReason}`\n\t\t\t\t\t: `containment closure is ${evidence.containment ?? 'undecidable'}`,\n\t\t);\n\tif (evidence.ledgerLineage !== 'matches-database')\n\t\treasons.push(`ledger lineage is ${evidence.ledgerLineage}`);\n\treturn reasons;\n}\n\n/**\n * The total destructive classifier produces a decision for every evidence\n * tuple; only its permitting cells produce positive destructive authority.\n */\nexport function decideDestructiveDecision(\n\taction: DestructiveAction,\n\tevidence: DestructiveAuthorityEvidence,\n): DestructiveDecision {\n\tconst reasons = refusalReasons(action, evidence);\n\tif (reasons.length > 0)\n\t\treturn { kind: 'destructive-decision-refused', action, reasons };\n\tconst permit = Object.freeze({}) as DestructiveAuthorityPermit;\n\tpermits.set(\n\t\tpermit,\n\t\taction.kind === 'removal' && action.closureDigest !== undefined\n\t\t\t? { closureDigest: action.closureDigest }\n\t\t\t: {},\n\t);\n\treturn { kind: 'destructive-decision-permitted', action, permit };\n}\n\n/** Runtime defense for the erased opaque type at adapter boundaries. */\nexport function isDestructiveAuthorityPermit(\n\tpermit: DestructiveAuthorityPermit,\n): boolean {\n\treturn permits.has(permit);\n}\n\n/** The adapter compares this immutable admission set after taking its locks. */\nexport function closureDigestForDestructiveAuthorityPermit(\n\tpermit: DestructiveAuthorityPermit,\n): string | undefined {\n\treturn permits.get(permit)?.closureDigest;\n}\n\n/**\n * Couples the positive authority result to the existing single token producer.\n * The adapter's destructive emitter accepts this value, never raw evidence.\n */\nexport type AdmittedDestructiveOutcomeClaim = AdmittedOutcomeClaim & {\n\treadonly destructivePermit: DestructiveAuthorityPermit;\n};\n\nexport function admitDestructiveOutcomeClaim(input: {\n\treadonly decision: Extract<\n\t\tDestructiveDecision,\n\t\t{ readonly kind: 'destructive-decision-permitted' }\n\t>;\n\treadonly admission: OutcomeClaimAdmissionInput;\n}):\n\t| AdmittedDestructiveOutcomeClaim\n\t| Exclude<OutcomeClaimAdmission, AdmittedOutcomeClaim> {\n\tif (!isDestructiveAuthorityPermit(input.decision.permit)) {\n\t\treturn {\n\t\t\tkind: 'outcome-protocol-refused',\n\t\t\treason: 'destructive authority permit was not minted by the interpreter',\n\t\t};\n\t}\n\tif (\n\t\t!sameLedgerAddress(\n\t\t\tinput.decision.action.address,\n\t\t\tinput.admission.plan.address,\n\t\t)\n\t) {\n\t\treturn {\n\t\t\tkind: 'outcome-protocol-refused',\n\t\t\treason: 'destructive authority address does not match the claim address',\n\t\t};\n\t}\n\tconst admitted = admitOutcomeClaim(input.admission);\n\tif (admitted.kind !== 'admitted-outcome-claim') return admitted;\n\treturn { ...admitted, destructivePermit: input.decision.permit };\n}\n\n/** Attach a real interpreter permit to an adapter-opened, already minted claim. */\nexport function attachDestructiveAuthorityPermit(input: {\n\treadonly decision: Extract<\n\t\tDestructiveDecision,\n\t\t{ readonly kind: 'destructive-decision-permitted' }\n\t>;\n\treadonly claim: AdmittedOutcomeClaim;\n}): AdmittedDestructiveOutcomeClaim | OutcomeProtocolRefusal {\n\tif (!isDestructiveAuthorityPermit(input.decision.permit))\n\t\treturn {\n\t\t\tkind: 'outcome-protocol-refused',\n\t\t\treason: 'destructive authority permit was not minted by the interpreter',\n\t\t};\n\tif (\n\t\t!sameLedgerAddress(input.decision.action.address, input.claim.plan.address)\n\t)\n\t\treturn {\n\t\t\tkind: 'outcome-protocol-refused',\n\t\t\treason: 'destructive authority address does not match the claim address',\n\t\t};\n\treturn { ...input.claim, destructivePermit: input.decision.permit };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,SAAS,yBAAyB;AAGlC,IAAM,UAAU,oBAAI,QAAqD;AAEzE,SAAS,mBACR,QACA,UACU;AACV,MAAI,OAAO,SAAS;AACnB,WACC,SAAS,gBAAgB,sBACxB,SAAS,gBAAgB,mCACzB,SAAS,uBAAuB,UAChC,kBAAkB,SAAS,oBAAoB,OAAO,OAAO;AAEhE,SAAO,SAAS,gBAAgB;AACjC;AAEA,SAAS,eACR,QACA,UACoB;AACpB,QAAM,UAAoB,CAAC;AAC3B,MAAI,CAAC,mBAAmB,QAAQ,QAAQ;AACvC,YAAQ,KAAK,qDAAqD;AACnE,MAAI,SAAS,cAAc;AAC1B,YAAQ,KAAK,gBAAgB,SAAS,SAAS,EAAE;AAClD,MAAI,SAAS,sBAAsB;AAClC,YAAQ,KAAK,yBAAyB,SAAS,iBAAiB,EAAE;AACnE,MAAI,SAAS,uBAAuB;AACnC,YAAQ,KAAK,+BAA+B;AAC7C,MACC,OAAO,SAAS,aAChB,SAAS,gBAAgB;AAEzB,YAAQ;AAAA,MACP,SAAS,gBAAgB,uBACxB,SAAS,yBAAyB,SAChC,6CAA6C,SAAS,qBAAqB,IAAI,IAAI,SAAS,qBAAqB,UAAU,YAAY,IAAI,SAAS,qBAAqB,IAAI,KAC7K,SAAS,gBAAgB,iBACzB,SAAS,sBAAsB,SAC9B,uCAAuC,SAAS,iBAAiB,KACjE,0BAA0B,SAAS,eAAe,aAAa;AAAA,IACpE;AACD,MAAI,SAAS,kBAAkB;AAC9B,YAAQ,KAAK,qBAAqB,SAAS,aAAa,EAAE;AAC3D,SAAO;AACR;AAMO,SAAS,0BACf,QACA,UACsB;AACtB,QAAM,UAAU,eAAe,QAAQ,QAAQ;AAC/C,MAAI,QAAQ,SAAS;AACpB,WAAO,EAAE,MAAM,gCAAgC,QAAQ,QAAQ;AAChE,QAAM,SAAS,OAAO,OAAO,CAAC,CAAC;AAC/B,UAAQ;AAAA,IACP;AAAA,IACA,OAAO,SAAS,aAAa,OAAO,kBAAkB,SACnD,EAAE,eAAe,OAAO,cAAc,IACtC,CAAC;AAAA,EACL;AACA,SAAO,EAAE,MAAM,kCAAkC,QAAQ,OAAO;AACjE;AAGO,SAAS,6BACf,QACU;AACV,SAAO,QAAQ,IAAI,MAAM;AAC1B;AAiBO,SAAS,6BAA6B,OAQW;AACvD,MAAI,CAAC,6BAA6B,MAAM,SAAS,MAAM,GAAG;AACzD,WAAO;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,IACT;AAAA,EACD;AACA,MACC,CAAC;AAAA,IACA,MAAM,SAAS,OAAO;AAAA,IACtB,MAAM,UAAU,KAAK;AAAA,EACtB,GACC;AACD,WAAO;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,IACT;AAAA,EACD;AACA,QAAM,WAAW,kBAAkB,MAAM,SAAS;AAClD,MAAI,SAAS,SAAS,yBAA0B,QAAO;AACvD,SAAO,EAAE,GAAG,UAAU,mBAAmB,MAAM,SAAS,OAAO;AAChE;AAGO,SAAS,iCAAiC,OAMY;AAC5D,MAAI,CAAC,6BAA6B,MAAM,SAAS,MAAM;AACtD,WAAO;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,IACT;AACD,MACC,CAAC,kBAAkB,MAAM,SAAS,OAAO,SAAS,MAAM,MAAM,KAAK,OAAO;AAE1E,WAAO;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,IACT;AACD,SAAO,EAAE,GAAG,MAAM,OAAO,mBAAmB,MAAM,SAAS,OAAO;AACnE;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbsp/core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"description": "Intent-first semantic query planner for databases — declare WHAT to fetch, the planner decides HOW",
|
|
5
5
|
"author": "Olivier Orabona <oorabona@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@dbsp/nql": "^2.0.
|
|
49
|
-
"@dbsp/types": "^6.
|
|
48
|
+
"@dbsp/nql": "^2.0.4",
|
|
49
|
+
"@dbsp/types": "^6.3.0",
|
|
50
50
|
"valibot": "^1.4.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|