@inixiative/json-rules 2.15.1 → 2.16.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/index.d.cts CHANGED
@@ -45,6 +45,13 @@ declare const DateOperator: {
45
45
  };
46
46
  type DateOperator = (typeof DateOperator)[keyof typeof DateOperator];
47
47
 
48
+ type FuzzyConfig = {
49
+ maxDistance?: number;
50
+ maxRatio?: number;
51
+ };
52
+ declare const maxFuzzyDistance: (length: number) => number;
53
+ declare const fuzzyContains: (haystack: string, query: string, config?: FuzzyConfig) => boolean;
54
+
48
55
  declare const FieldKind: {
49
56
  readonly String: "String";
50
57
  readonly Boolean: "Boolean";
@@ -206,6 +213,7 @@ type RuleBase<TOperator extends Operator> = {
206
213
  operator: TOperator;
207
214
  error?: string;
208
215
  caseInsensitive?: boolean;
216
+ fuzzy?: boolean | FuzzyConfig;
209
217
  };
210
218
  type DateRuleBase<TOperator extends DateOperator> = {
211
219
  field: string;
@@ -312,6 +320,7 @@ type Rule<TValue = RuleValue> = {
312
320
  bind?: string;
313
321
  error?: string;
314
322
  caseInsensitive?: boolean;
323
+ fuzzy?: boolean | FuzzyConfig;
315
324
  coerceType?: FieldKind;
316
325
  };
317
326
  type ArrayRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowFields & {
@@ -385,6 +394,7 @@ type PrismaProvider = 'postgresql' | 'mysql' | 'sqlite' | 'sqlserver' | 'cockroa
385
394
  type EngineGlobalsState = {
386
395
  string: {
387
396
  caseInsensitive: boolean;
397
+ fuzzy: boolean | FuzzyConfig;
388
398
  };
389
399
  prismaOptions: {
390
400
  datasource: {
@@ -392,13 +402,18 @@ type EngineGlobalsState = {
392
402
  };
393
403
  };
394
404
  };
405
+ type DeepPartial<T> = {
406
+ [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
407
+ };
395
408
  declare const engineGlobals: {
396
409
  set: (path: string, value: unknown) => void;
397
410
  get: (path: string) => unknown;
398
411
  reset: () => void;
412
+ with: <T>(partial: DeepPartial<EngineGlobalsState>, fn: () => T) => T;
399
413
  };
400
414
  declare const supportsQueryMode: (provider: PrismaProvider) => boolean;
401
415
  declare const resolveCaseInsensitive: (ruleFlag?: boolean) => boolean;
416
+ declare const resolveFuzzy: (ruleFlag?: boolean | FuzzyConfig) => FuzzyConfig | false;
402
417
 
403
418
  type PrismaWhere = Record<string, unknown>;
404
419
  /** A selectable option — the standard `<select>` shape: a value with an optional display label. */
@@ -814,4 +829,4 @@ declare const assertValidRule: (condition: unknown, options?: {
814
829
  target?: RuleTarget;
815
830
  }) => asserts condition is Condition;
816
831
 
817
- 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 EngineGlobalsState, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type ModelDefaultNarrowing, type ModelNarrowing, NULLABLE_KINDS, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaProvider, type PrismaStep, type PrismaWhere, type ProjectOptions, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, RuleTarget, type RuleValue, STRINGY_KINDS, type SortDir, type SourceOption, type SourcePrismaQuery, type SourceQuery, type SourceSpec, type SourceSqlQuery, type SourceValue, type SourceValues, 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 TimeZoneConfig, 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, engineGlobals, executePrismaQueryPlan, exposedSurface, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, projectByPath, requiredBindings, resolveBindings, resolveCaseInsensitive, resolveLensBindings, sourceQueries, sourceValuesFromRows, stampCoercions, stitchFieldMaps, supportsQueryMode, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
832
+ 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 EngineGlobalsState, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type ModelDefaultNarrowing, type ModelNarrowing, NULLABLE_KINDS, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaProvider, type PrismaStep, type PrismaWhere, type ProjectOptions, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, RuleTarget, type RuleValue, STRINGY_KINDS, type SortDir, type SourceOption, type SourcePrismaQuery, type SourceQuery, type SourceSpec, type SourceSqlQuery, type SourceValue, type SourceValues, 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 TimeZoneConfig, 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, engineGlobals, executePrismaQueryPlan, exposedSurface, fuzzyContains, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, maxFuzzyDistance, projectByPath, requiredBindings, resolveBindings, resolveCaseInsensitive, resolveFuzzy, resolveLensBindings, sourceQueries, sourceValuesFromRows, stampCoercions, stitchFieldMaps, supportsQueryMode, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
package/dist/index.d.ts CHANGED
@@ -45,6 +45,13 @@ declare const DateOperator: {
45
45
  };
46
46
  type DateOperator = (typeof DateOperator)[keyof typeof DateOperator];
47
47
 
48
+ type FuzzyConfig = {
49
+ maxDistance?: number;
50
+ maxRatio?: number;
51
+ };
52
+ declare const maxFuzzyDistance: (length: number) => number;
53
+ declare const fuzzyContains: (haystack: string, query: string, config?: FuzzyConfig) => boolean;
54
+
48
55
  declare const FieldKind: {
49
56
  readonly String: "String";
50
57
  readonly Boolean: "Boolean";
@@ -206,6 +213,7 @@ type RuleBase<TOperator extends Operator> = {
206
213
  operator: TOperator;
207
214
  error?: string;
208
215
  caseInsensitive?: boolean;
216
+ fuzzy?: boolean | FuzzyConfig;
209
217
  };
210
218
  type DateRuleBase<TOperator extends DateOperator> = {
211
219
  field: string;
@@ -312,6 +320,7 @@ type Rule<TValue = RuleValue> = {
312
320
  bind?: string;
313
321
  error?: string;
314
322
  caseInsensitive?: boolean;
323
+ fuzzy?: boolean | FuzzyConfig;
315
324
  coerceType?: FieldKind;
316
325
  };
317
326
  type ArrayRule<TRuleValue = RuleValue, TDateValue = DateRuleValue> = WindowFields & {
@@ -385,6 +394,7 @@ type PrismaProvider = 'postgresql' | 'mysql' | 'sqlite' | 'sqlserver' | 'cockroa
385
394
  type EngineGlobalsState = {
386
395
  string: {
387
396
  caseInsensitive: boolean;
397
+ fuzzy: boolean | FuzzyConfig;
388
398
  };
389
399
  prismaOptions: {
390
400
  datasource: {
@@ -392,13 +402,18 @@ type EngineGlobalsState = {
392
402
  };
393
403
  };
394
404
  };
405
+ type DeepPartial<T> = {
406
+ [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
407
+ };
395
408
  declare const engineGlobals: {
396
409
  set: (path: string, value: unknown) => void;
397
410
  get: (path: string) => unknown;
398
411
  reset: () => void;
412
+ with: <T>(partial: DeepPartial<EngineGlobalsState>, fn: () => T) => T;
399
413
  };
400
414
  declare const supportsQueryMode: (provider: PrismaProvider) => boolean;
401
415
  declare const resolveCaseInsensitive: (ruleFlag?: boolean) => boolean;
416
+ declare const resolveFuzzy: (ruleFlag?: boolean | FuzzyConfig) => FuzzyConfig | false;
402
417
 
403
418
  type PrismaWhere = Record<string, unknown>;
404
419
  /** A selectable option — the standard `<select>` shape: a value with an optional display label. */
@@ -814,4 +829,4 @@ declare const assertValidRule: (condition: unknown, options?: {
814
829
  target?: RuleTarget;
815
830
  }) => asserts condition is Condition;
816
831
 
817
- 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 EngineGlobalsState, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type ModelDefaultNarrowing, type ModelNarrowing, NULLABLE_KINDS, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaProvider, type PrismaStep, type PrismaWhere, type ProjectOptions, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, RuleTarget, type RuleValue, STRINGY_KINDS, type SortDir, type SourceOption, type SourcePrismaQuery, type SourceQuery, type SourceSpec, type SourceSqlQuery, type SourceValue, type SourceValues, 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 TimeZoneConfig, 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, engineGlobals, executePrismaQueryPlan, exposedSurface, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, projectByPath, requiredBindings, resolveBindings, resolveCaseInsensitive, resolveLensBindings, sourceQueries, sourceValuesFromRows, stampCoercions, stitchFieldMaps, supportsQueryMode, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };
832
+ 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 EngineGlobalsState, type EnumNarrowing, FIELD_OPERATOR_CATALOG, FieldKind, type FieldMap, type FieldMapEntry, type FieldMapSet, type FuzzyConfig, type GroupByStep, type IfThenElse, type Lens, type LensNarrowing, type ModelDefaultNarrowing, type ModelNarrowing, NULLABLE_KINDS, NUMERIC_KINDS, type NarrowingDefaults, ORDERABLE_KINDS, Operator, type OrderBy, type OrderedRuleValue, type PathProjection, type PeriodExpr, type PeriodUnit, type PrismaProvider, type PrismaStep, type PrismaWhere, type ProjectOptions, type ProjectedVisit, type RelativeUnits, type RollingExpr, type Rule, type RuleDescription, type RuleLensCheck, type RuleLensViolation, type RuleScalar, RuleTarget, type RuleValue, STRINGY_KINDS, type SortDir, type SourceOption, type SourcePrismaQuery, type SourceQuery, type SourceSpec, type SourceSqlQuery, type SourceValue, type SourceValues, 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 TimeZoneConfig, 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, engineGlobals, executePrismaQueryPlan, exposedSurface, fuzzyContains, getArrayOperators, getOperatorsForKind, getValueShape, getWindowSupport, isAggregateRangeOperator, isAggregateSingleOperator, isOperatorSupportedForTarget, lensRequiredBindings, maxFuzzyDistance, projectByPath, requiredBindings, resolveBindings, resolveCaseInsensitive, resolveFuzzy, resolveLensBindings, sourceQueries, sourceValuesFromRows, stampCoercions, stitchFieldMaps, supportsQueryMode, toPrisma, toSql, validateBindNames, validateFieldMap, validateFieldMapSet, validateNarrowing, validateRule };