@inixiative/json-rules 2.7.0 → 2.8.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 +13 -2
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -12
- package/dist/index.d.ts +56 -12
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -435,17 +435,6 @@ type CreateLensInput = {
|
|
|
435
435
|
};
|
|
436
436
|
declare const createLens: (input: CreateLensInput) => Lens;
|
|
437
437
|
|
|
438
|
-
declare const validateNarrowing: (narrowing: LensNarrowing) => void;
|
|
439
|
-
|
|
440
|
-
type ProjectedVisit = {
|
|
441
|
-
mapName: string;
|
|
442
|
-
modelName: string;
|
|
443
|
-
fields: Record<string, FieldMapEntry>;
|
|
444
|
-
whereClauses: Condition[];
|
|
445
|
-
};
|
|
446
|
-
type PathProjection = Map<string, ProjectedVisit>;
|
|
447
|
-
declare const projectByPath: (lensOrNarrowing: Lens | LensNarrowing) => PathProjection;
|
|
448
|
-
|
|
449
438
|
declare const FieldKind: {
|
|
450
439
|
readonly String: "String";
|
|
451
440
|
readonly Boolean: "Boolean";
|
|
@@ -534,6 +523,61 @@ declare const getOperatorsForKind: (kind: FieldKind, target?: RuleTarget) => {
|
|
|
534
523
|
};
|
|
535
524
|
declare const getArrayOperators: (target?: RuleTarget) => ArrayOperator[];
|
|
536
525
|
|
|
526
|
+
type RuleDescription = {
|
|
527
|
+
/** Map (source) names the rule's fields touch, sorted. */
|
|
528
|
+
sources: string[];
|
|
529
|
+
/** True if any field/path crosses a bridge into another source. */
|
|
530
|
+
bridgesCrossed: boolean;
|
|
531
|
+
/** Execution targets that can run this rule, in canonical order. */
|
|
532
|
+
supportedTargets: RuleTarget[];
|
|
533
|
+
/** Field paths that don't resolve through the lens. */
|
|
534
|
+
violations: string[];
|
|
535
|
+
};
|
|
536
|
+
/**
|
|
537
|
+
* Classifies a rule against a lens: which sources it touches, whether it crosses
|
|
538
|
+
* a bridge, and which execution targets can run it. A bridge-crossing rule is
|
|
539
|
+
* `check()`-only — `toPrisma`/`toSql` can't join across sources, so the host must
|
|
540
|
+
* hydrate foreign rows (see `buildBridgeDictionary`) and evaluate in memory.
|
|
541
|
+
* Windowing further restricts targets (`toSql` never; `toPrisma` only the
|
|
542
|
+
* extremal array rewrite). `violations` lists field paths that don't resolve
|
|
543
|
+
* through the lens — use `checkRuleAgainstLens` for the full security gate.
|
|
544
|
+
*/
|
|
545
|
+
declare const describeRule: (rule: Condition, lensOrNarrowing: Lens | LensNarrowing) => RuleDescription;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Produces the total exposed surface of a (possibly narrowed) lens as a **Lens**
|
|
549
|
+
* (maps intact — the navigable graph), NOT a projection (path-keyed view). This
|
|
550
|
+
* is the leak-safe server→client surface: every model reachable from the anchor
|
|
551
|
+
* through visible relation/bridge edges, with the FULL narrowing applied — root
|
|
552
|
+
* at the anchor, path-specific narrowing along declared relation paths,
|
|
553
|
+
* model-default (`mapDefaults`) everywhere else — then unioned per model. A field
|
|
554
|
+
* appears iff it is visible on at least one reachable, narrowed path; fields
|
|
555
|
+
* hidden on every path (including those hidden only by `root`) are absent, so it
|
|
556
|
+
* never exposes the raw, un-narrowed lens.
|
|
557
|
+
*
|
|
558
|
+
* `where` (data-scope) narrowing is dropped — this is the client schema surface.
|
|
559
|
+
* For a server→subtenant handoff that must preserve `where` and per-path
|
|
560
|
+
* narrowing, use `seal` (planned) instead. Per-path divergence (a model that
|
|
561
|
+
* looks different at two sibling paths) is not represented here; pair with
|
|
562
|
+
* `projectByPath` when that distinction matters.
|
|
563
|
+
*
|
|
564
|
+
* Cycle-safe: declared-path visits are keyed by path (the declared tree is
|
|
565
|
+
* finite) and off-path visits by model (visited once), so recursive schemas
|
|
566
|
+
* (User → Org → members(User) → …) terminate.
|
|
567
|
+
*/
|
|
568
|
+
declare const exposedSurface: (lensOrNarrowing: Lens | LensNarrowing) => Lens;
|
|
569
|
+
|
|
570
|
+
declare const validateNarrowing: (narrowing: LensNarrowing) => void;
|
|
571
|
+
|
|
572
|
+
type ProjectedVisit = {
|
|
573
|
+
mapName: string;
|
|
574
|
+
modelName: string;
|
|
575
|
+
fields: Record<string, FieldMapEntry>;
|
|
576
|
+
whereClauses: Condition[];
|
|
577
|
+
};
|
|
578
|
+
type PathProjection = Map<string, ProjectedVisit>;
|
|
579
|
+
declare const projectByPath: (lensOrNarrowing: Lens | LensNarrowing) => PathProjection;
|
|
580
|
+
|
|
537
581
|
/**
|
|
538
582
|
* Execute a Prisma query plan produced by toPrisma().
|
|
539
583
|
*
|
|
@@ -619,4 +663,4 @@ declare const assertValidRule: (condition: unknown, options?: {
|
|
|
619
663
|
target?: RuleTarget;
|
|
620
664
|
}) => asserts condition is Condition;
|
|
621
665
|
|
|
622
|
-
export { AGGREGATE_OPERATORS, ALL_KINDS, ARRAY_OPERATOR_CATALOG, type AggregateMode, type AggregateRule, type All, type Any, type ArrayCatalogEntry, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BuildOptions, type CatalogEntry, type CheckOptions, type Condition, type CreateLensInput, DATE_OPERATOR_CATALOG, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, DateOperator, type DateRule, type DateRuleValue, EQUATABLE_KINDS, type EdgeExpr, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type ModelDefaultNarrowing, type ModelNarrowing, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaStep, type PrismaWhere, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleLensCheck, type RuleLensViolation, type RuleScalar, RuleTarget, type RuleValue, STRINGY_KINDS, type SortDir, type SqlResult, type StepRef, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type ToPrismaResult, type ValidationIssue, type ValidationResult, ValueShape, WINDOW_SELECTOR, type WeekStart, type WhereStep, type WindowFields, type WindowRuleType, WindowSupport, applyLens, assertValidRule, buildBridgeDictionary, check, checkRuleAgainstLens, createLens, executePrismaQueryPlan, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, projectByPath, stitchFieldMaps, toPrisma, toSql, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
|
|
666
|
+
export { AGGREGATE_OPERATORS, ALL_KINDS, ARRAY_OPERATOR_CATALOG, type AggregateMode, type AggregateRule, type All, type Any, type ArrayCatalogEntry, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BuildOptions, type CatalogEntry, type CheckOptions, type Condition, type CreateLensInput, DATE_OPERATOR_CATALOG, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, DateOperator, type DateRule, type DateRuleValue, EQUATABLE_KINDS, type EdgeExpr, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type ModelDefaultNarrowing, type ModelNarrowing, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaStep, type PrismaWhere, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, RuleTarget, type RuleValue, STRINGY_KINDS, type SortDir, type SqlResult, type StepRef, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type ToPrismaResult, type ValidationIssue, type ValidationResult, ValueShape, WINDOW_SELECTOR, type WeekStart, type WhereStep, type WindowFields, type WindowRuleType, WindowSupport, applyLens, assertValidRule, buildBridgeDictionary, check, checkRuleAgainstLens, createLens, describeRule, executePrismaQueryPlan, exposedSurface, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, projectByPath, stitchFieldMaps, toPrisma, toSql, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
|
package/dist/index.d.ts
CHANGED
|
@@ -435,17 +435,6 @@ type CreateLensInput = {
|
|
|
435
435
|
};
|
|
436
436
|
declare const createLens: (input: CreateLensInput) => Lens;
|
|
437
437
|
|
|
438
|
-
declare const validateNarrowing: (narrowing: LensNarrowing) => void;
|
|
439
|
-
|
|
440
|
-
type ProjectedVisit = {
|
|
441
|
-
mapName: string;
|
|
442
|
-
modelName: string;
|
|
443
|
-
fields: Record<string, FieldMapEntry>;
|
|
444
|
-
whereClauses: Condition[];
|
|
445
|
-
};
|
|
446
|
-
type PathProjection = Map<string, ProjectedVisit>;
|
|
447
|
-
declare const projectByPath: (lensOrNarrowing: Lens | LensNarrowing) => PathProjection;
|
|
448
|
-
|
|
449
438
|
declare const FieldKind: {
|
|
450
439
|
readonly String: "String";
|
|
451
440
|
readonly Boolean: "Boolean";
|
|
@@ -534,6 +523,61 @@ declare const getOperatorsForKind: (kind: FieldKind, target?: RuleTarget) => {
|
|
|
534
523
|
};
|
|
535
524
|
declare const getArrayOperators: (target?: RuleTarget) => ArrayOperator[];
|
|
536
525
|
|
|
526
|
+
type RuleDescription = {
|
|
527
|
+
/** Map (source) names the rule's fields touch, sorted. */
|
|
528
|
+
sources: string[];
|
|
529
|
+
/** True if any field/path crosses a bridge into another source. */
|
|
530
|
+
bridgesCrossed: boolean;
|
|
531
|
+
/** Execution targets that can run this rule, in canonical order. */
|
|
532
|
+
supportedTargets: RuleTarget[];
|
|
533
|
+
/** Field paths that don't resolve through the lens. */
|
|
534
|
+
violations: string[];
|
|
535
|
+
};
|
|
536
|
+
/**
|
|
537
|
+
* Classifies a rule against a lens: which sources it touches, whether it crosses
|
|
538
|
+
* a bridge, and which execution targets can run it. A bridge-crossing rule is
|
|
539
|
+
* `check()`-only — `toPrisma`/`toSql` can't join across sources, so the host must
|
|
540
|
+
* hydrate foreign rows (see `buildBridgeDictionary`) and evaluate in memory.
|
|
541
|
+
* Windowing further restricts targets (`toSql` never; `toPrisma` only the
|
|
542
|
+
* extremal array rewrite). `violations` lists field paths that don't resolve
|
|
543
|
+
* through the lens — use `checkRuleAgainstLens` for the full security gate.
|
|
544
|
+
*/
|
|
545
|
+
declare const describeRule: (rule: Condition, lensOrNarrowing: Lens | LensNarrowing) => RuleDescription;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Produces the total exposed surface of a (possibly narrowed) lens as a **Lens**
|
|
549
|
+
* (maps intact — the navigable graph), NOT a projection (path-keyed view). This
|
|
550
|
+
* is the leak-safe server→client surface: every model reachable from the anchor
|
|
551
|
+
* through visible relation/bridge edges, with the FULL narrowing applied — root
|
|
552
|
+
* at the anchor, path-specific narrowing along declared relation paths,
|
|
553
|
+
* model-default (`mapDefaults`) everywhere else — then unioned per model. A field
|
|
554
|
+
* appears iff it is visible on at least one reachable, narrowed path; fields
|
|
555
|
+
* hidden on every path (including those hidden only by `root`) are absent, so it
|
|
556
|
+
* never exposes the raw, un-narrowed lens.
|
|
557
|
+
*
|
|
558
|
+
* `where` (data-scope) narrowing is dropped — this is the client schema surface.
|
|
559
|
+
* For a server→subtenant handoff that must preserve `where` and per-path
|
|
560
|
+
* narrowing, use `seal` (planned) instead. Per-path divergence (a model that
|
|
561
|
+
* looks different at two sibling paths) is not represented here; pair with
|
|
562
|
+
* `projectByPath` when that distinction matters.
|
|
563
|
+
*
|
|
564
|
+
* Cycle-safe: declared-path visits are keyed by path (the declared tree is
|
|
565
|
+
* finite) and off-path visits by model (visited once), so recursive schemas
|
|
566
|
+
* (User → Org → members(User) → …) terminate.
|
|
567
|
+
*/
|
|
568
|
+
declare const exposedSurface: (lensOrNarrowing: Lens | LensNarrowing) => Lens;
|
|
569
|
+
|
|
570
|
+
declare const validateNarrowing: (narrowing: LensNarrowing) => void;
|
|
571
|
+
|
|
572
|
+
type ProjectedVisit = {
|
|
573
|
+
mapName: string;
|
|
574
|
+
modelName: string;
|
|
575
|
+
fields: Record<string, FieldMapEntry>;
|
|
576
|
+
whereClauses: Condition[];
|
|
577
|
+
};
|
|
578
|
+
type PathProjection = Map<string, ProjectedVisit>;
|
|
579
|
+
declare const projectByPath: (lensOrNarrowing: Lens | LensNarrowing) => PathProjection;
|
|
580
|
+
|
|
537
581
|
/**
|
|
538
582
|
* Execute a Prisma query plan produced by toPrisma().
|
|
539
583
|
*
|
|
@@ -619,4 +663,4 @@ declare const assertValidRule: (condition: unknown, options?: {
|
|
|
619
663
|
target?: RuleTarget;
|
|
620
664
|
}) => asserts condition is Condition;
|
|
621
665
|
|
|
622
|
-
export { AGGREGATE_OPERATORS, ALL_KINDS, ARRAY_OPERATOR_CATALOG, type AggregateMode, type AggregateRule, type All, type Any, type ArrayCatalogEntry, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BuildOptions, type CatalogEntry, type CheckOptions, type Condition, type CreateLensInput, DATE_OPERATOR_CATALOG, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, DateOperator, type DateRule, type DateRuleValue, EQUATABLE_KINDS, type EdgeExpr, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type ModelDefaultNarrowing, type ModelNarrowing, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaStep, type PrismaWhere, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleLensCheck, type RuleLensViolation, type RuleScalar, RuleTarget, type RuleValue, STRINGY_KINDS, type SortDir, type SqlResult, type StepRef, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type ToPrismaResult, type ValidationIssue, type ValidationResult, ValueShape, WINDOW_SELECTOR, type WeekStart, type WhereStep, type WindowFields, type WindowRuleType, WindowSupport, applyLens, assertValidRule, buildBridgeDictionary, check, checkRuleAgainstLens, createLens, executePrismaQueryPlan, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, projectByPath, stitchFieldMaps, toPrisma, toSql, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
|
|
666
|
+
export { AGGREGATE_OPERATORS, ALL_KINDS, ARRAY_OPERATOR_CATALOG, type AggregateMode, type AggregateRule, type All, type Any, type ArrayCatalogEntry, ArrayOperator, type ArrayRule, type Bridge, type BridgeCardinality, type BridgeDictionary, type BridgeEndpoint, type BuildOptions, type CatalogEntry, type CheckOptions, type Condition, type CreateLensInput, DATE_OPERATOR_CATALOG, type DateConfig, type DateExpr, type DateInputOrExpr, type DateInputValue, DateOperator, type DateRule, type DateRuleValue, EQUATABLE_KINDS, type EdgeExpr, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type ModelDefaultNarrowing, type ModelNarrowing, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaStep, type PrismaWhere, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, RuleTarget, type RuleValue, STRINGY_KINDS, type SortDir, type SqlResult, type StepRef, type StrictAggregateRule, type StrictAll, type StrictAny, type StrictArrayCountRule, type StrictArrayPredicateRule, type StrictArrayPresenceRule, type StrictArrayRule, type StrictCondition, type StrictContainsRule, type StrictDateComparisonRule, type StrictDateDayRule, type StrictDateRangeRule, type StrictDateRule, type StrictEqualityRule, type StrictIfThenElse, type StrictMembershipRule, type StrictOrderedComparisonRule, type StrictPatternRule, type StrictPresenceRule, type StrictRangeRule, type StrictRule, type StrictStringBoundaryRule, type ToPrismaResult, type ValidationIssue, type ValidationResult, ValueShape, WINDOW_SELECTOR, type WeekStart, type WhereStep, type WindowFields, type WindowRuleType, WindowSupport, applyLens, assertValidRule, buildBridgeDictionary, check, checkRuleAgainstLens, createLens, describeRule, executePrismaQueryPlan, exposedSurface, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, projectByPath, stitchFieldMaps, toPrisma, toSql, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
|