New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@contember/schema

Package Overview
Dependencies
Maintainers
5
Versions
272
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contember/schema - npm Package Compare versions

Comparing version 1.1.0-alpha.5 to 1.1.0-alpha.6

dist/src/schema/json.d.ts

10

dist/src/index.d.ts

@@ -8,8 +8,12 @@ import Input from './schema/input';

export * from './ProjectRole';
export * from './schema/json';
declare type Schema = {
model: Model.Schema;
acl: Acl.Schema;
validation: Validation.Schema;
readonly model: Model.Schema;
readonly acl: Acl.Schema;
readonly validation: Validation.Schema;
};
export declare type Writable<V> = {
-readonly [K in keyof V]: V[K];
};
export { Input, Model, Acl, Schema, Validation, Value, Result };
//# sourceMappingURL=index.d.ts.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -25,2 +29,3 @@ if (k2 === undefined) k2 = k;

__exportStar(require("./ProjectRole"), exports);
__exportStar(require("./schema/json"), exports);
//# sourceMappingURL=index.js.map
import Input from './input';
import { JSONValue } from './json';
declare namespace Acl {

@@ -8,23 +9,23 @@ enum VariableType {

type Variable = EntityVariable | PredefinedVariable;
interface EntityVariable {
type: VariableType.entity;
entityName: string;
}
interface PredefinedVariable {
type: VariableType.predefined;
value: 'identityID' | 'personID';
}
type EntityVariable = {
readonly type: VariableType.entity;
readonly entityName: string;
};
type PredefinedVariable = {
readonly type: VariableType.predefined;
readonly value: 'identityID' | 'personID';
};
type VariableValue = string | number | readonly (string | number)[];
interface VariablesMap {
[name: string]: VariableValue;
}
type VariablesMap = {
readonly [name: string]: VariableValue;
};
type PredicateVariable = string;
type PredicateDefinition<E = never> = Input.Where<PredicateVariable | Input.Condition | E>;
type PredicateMap = {
[name: string]: PredicateDefinition;
readonly [name: string]: PredicateDefinition;
};
interface EntityPermissions {
predicates: PredicateMap;
operations: EntityOperations;
}
type EntityPermissions = {
readonly predicates: PredicateMap;
readonly operations: EntityOperations;
};
enum Operation {

@@ -36,11 +37,11 @@ read = "read",

}
interface EntityOperations {
read?: FieldPermissions;
create?: FieldPermissions;
customPrimary?: boolean;
update?: FieldPermissions;
delete?: Predicate;
}
type EntityOperations = {
readonly read?: FieldPermissions;
readonly create?: FieldPermissions;
readonly customPrimary?: boolean;
readonly update?: FieldPermissions;
readonly delete?: Predicate;
};
type FieldPermissions = {
[field: string]: Predicate | undefined;
readonly [field: string]: Predicate;
};

@@ -50,16 +51,16 @@ type PredicateReference = string;

type AnyStage = '*';
type StagesDefinition = AnyStage | string[];
type StagesDefinition = AnyStage | readonly string[];
type TenantManagedVariableSource = true | string;
type TenantManagePermissions = {
[role: string]: {
variables?: true | {
[targetVariable: string]: TenantManagedVariableSource;
readonly [role: string]: {
readonly variables?: true | {
readonly [targetVariable: string]: TenantManagedVariableSource;
};
};
};
interface TenantPermissions {
invite?: boolean;
unmanagedInvite?: boolean;
manage?: TenantManagePermissions;
}
type TenantPermissions = {
readonly invite?: boolean;
readonly unmanagedInvite?: boolean;
readonly manage?: TenantManagePermissions;
};
enum SystemPermissionsLevel {

@@ -73,31 +74,34 @@ none = "none",

*/
type LimitedSystemPermissionsLevel = SystemPermissionsLevel.any | SystemPermissionsLevel.none;
interface SystemPermissions {
history?: boolean | LimitedSystemPermissionsLevel;
migrate?: boolean;
assumeIdentity?: boolean;
type LimitedSystemPermissionsLevel = 'any' | 'none';
type SystemPermissions = {
readonly history?: boolean | LimitedSystemPermissionsLevel;
readonly migrate?: boolean;
readonly assumeIdentity?: boolean;
};
interface BaseRolePermissions {
readonly inherits?: readonly string[];
readonly implicit?: boolean;
readonly tenant?: TenantPermissions;
readonly system?: SystemPermissions;
readonly variables: Acl.Variables;
readonly stages?: StagesDefinition;
readonly entities: Permissions;
}
type RolePermissions = {
inherits?: string[];
implicit?: boolean;
tenant?: TenantPermissions;
system?: SystemPermissions;
variables: Acl.Variables;
stages?: StagesDefinition;
entities: Permissions;
} & Record<string, unknown>;
interface Permissions {
[entity: string]: EntityPermissions;
}
type RolePermissions = BaseRolePermissions & {
readonly [key: string]: JSONValue;
};
type Permissions = {
readonly [entity: string]: EntityPermissions;
};
type Roles = {
[role: string]: RolePermissions;
readonly [role: string]: RolePermissions;
};
type Variables = {
[name: string]: Variable;
readonly [name: string]: Variable;
};
interface Schema {
roles: Acl.Roles;
}
type Schema = {
readonly roles: Acl.Roles;
};
}
export default Acl;
//# sourceMappingURL=acl.d.ts.map

@@ -120,35 +120,35 @@ import Value from './value';

};
interface Condition<T = Value.FieldValue> {
and?: Array<Condition<T>>;
or?: Array<Condition<T>>;
not?: Condition<T>;
eq?: T;
null?: boolean;
isNull?: boolean;
notEq?: T;
in?: T[];
notIn?: T[];
lt?: T;
lte?: T;
gt?: T;
gte?: T;
never?: true;
always?: true;
contains?: string;
startsWith?: string;
endsWith?: string;
containsCI?: string;
startsWithCI?: string;
endsWithCI?: string;
}
interface UniqueWhere<E = never> {
[field: string]: Value.PrimaryValue<E> | UniqueWhere<E>;
}
type Condition<T = Value.FieldValue> = {
readonly and?: readonly Condition<T>[];
readonly or?: readonly Condition<T>[];
readonly not?: Condition<T>;
readonly eq?: T;
readonly null?: boolean;
readonly isNull?: boolean;
readonly notEq?: T;
readonly in?: readonly T[];
readonly notIn?: readonly T[];
readonly lt?: T;
readonly lte?: T;
readonly gt?: T;
readonly gte?: T;
readonly never?: true;
readonly always?: true;
readonly contains?: string;
readonly startsWith?: string;
readonly endsWith?: string;
readonly containsCI?: string;
readonly startsWithCI?: string;
readonly endsWithCI?: string;
};
type UniqueWhere<E = never> = {
readonly [field: string]: Value.PrimaryValue<E> | UniqueWhere<E>;
};
type ComposedWhere<C, Opt = never> = {
and?: (Where<C, Opt> | Opt)[];
or?: (Where<C, Opt> | Opt)[];
not?: Where<C, Opt>;
readonly and?: readonly (Where<C, Opt> | Opt)[];
readonly or?: readonly (Where<C, Opt> | Opt)[];
readonly not?: Where<C, Opt>;
};
interface FieldWhere<C = Condition, Opt = never> {
[name: string]: C | Where<C, Opt> | undefined | (Where<C, Opt> | Opt)[];
readonly [name: string]: C | Where<C, Opt> | readonly (Where<C, Opt> | Opt)[];
}

@@ -155,0 +155,0 @@ type Where<C = Condition, Opt = never> = ComposedWhere<C, Opt> & FieldWhere<C, Opt>;

import Input from './input';
declare namespace Model {
interface Entity {
name: string;
primary: string;
primaryColumn: string;
tableName: string;
fields: {
[name: string]: AnyField;
type Entity = {
readonly name: string;
readonly primary: string;
readonly primaryColumn: string;
readonly tableName: string;
readonly fields: {
readonly [name: string]: AnyField;
};
unique: UniqueConstraints;
view?: View;
}
interface View {
sql: string;
dependencies?: string[];
}
readonly unique: UniqueConstraints;
readonly view?: View;
readonly eventLog: EventLogConfig;
};
type View = {
readonly sql: string;
readonly dependencies?: readonly string[];
};
type EventLogConfig = {
readonly enabled: boolean;
};
type FieldType = RelationType | ColumnType;
interface Field<T extends FieldType> {
type: T;
}
type Field<T extends FieldType> = {
readonly type: T;
};
type AnyField = AnyColumn | AnyRelation;

@@ -36,11 +40,15 @@ type AnyColumn<T extends ColumnType = ColumnType> = Column<T>;

type Column<T extends ColumnType> = ColumnTypeDefinition<T> & {
name: string;
columnName: string;
readonly name: string;
readonly columnName: string;
};
interface ColumnTypeDefinition<T extends ColumnType = ColumnType> extends Field<T> {
columnType: string;
typeAlias?: string;
nullable: boolean;
default?: string | number | boolean | null;
}
type ColumnTypeDefinition<T extends ColumnType = ColumnType> = Field<T> & {
readonly columnType: string;
readonly typeAlias?: string;
readonly nullable: boolean;
readonly default?: string | number | boolean | null;
readonly sequence?: {
readonly precedence: 'ALWAYS' | 'BY DEFAULT';
readonly start?: number;
};
};
interface ColumnVisitor<T> {

@@ -76,19 +84,17 @@ visitColumn(entity: Entity, column: AnyColumn): T;

type AnyRelation = AnyInverseRelation | AnyOwningRelation;
interface Relation<T extends RelationType = RelationType> extends Field<T> {
name: string;
type: T;
target: string;
}
interface InverseRelation extends Relation {
ownedBy: string;
}
type Relation<T extends RelationType = RelationType> = Field<T> & {
readonly name: string;
readonly type: T;
readonly target: string;
};
type InverseRelation = Relation & {
readonly ownedBy: string;
};
/** @deprecated */
interface InversedRelation extends InverseRelation {
}
interface OwningRelation extends Relation {
inversedBy?: string;
}
type InversedRelation = InverseRelation;
type OwningRelation = Relation & {
readonly inversedBy?: string;
};
/** @deprecated */
interface OwnerRelation extends OwningRelation {
}
type OwnerRelation = OwningRelation;
enum OnDelete {

@@ -100,27 +106,28 @@ cascade = "cascade",

type JoiningColumn = {
columnName: string;
onDelete: OnDelete;
readonly columnName: string;
readonly onDelete: OnDelete;
};
interface JoiningColumnRelation {
joiningColumn: JoiningColumn;
}
interface NullableRelation {
nullable: boolean;
}
interface JoiningTable {
tableName: string;
joiningColumn: JoiningColumn;
inverseJoiningColumn: JoiningColumn;
}
interface JoiningTableRelation {
joiningTable: JoiningTable;
}
type JoiningColumnRelation = {
readonly joiningColumn: JoiningColumn;
};
type NullableRelation = {
readonly nullable: boolean;
};
type JoiningTable = {
readonly tableName: string;
readonly joiningColumn: JoiningColumn;
readonly inverseJoiningColumn: JoiningColumn;
readonly eventLog: EventLogConfig;
};
type JoiningTableRelation = {
readonly joiningTable: JoiningTable;
};
export import OrderDirection = Input.OrderDirection;
type OrderBy = {
path: string[];
direction: OrderDirection;
readonly path: readonly string[];
readonly direction: OrderDirection;
};
interface OrderableRelation {
orderBy?: OrderBy[];
}
type OrderableRelation = {
readonly orderBy?: readonly OrderBy[];
};
type OneHasManyRelation = Relation<RelationType.OneHasMany> & InverseRelation & OrderableRelation;

@@ -132,3 +139,3 @@ type ManyHasOneRelation = Relation<RelationType.ManyHasOne> & OwningRelation & JoiningColumnRelation & NullableRelation;

type OneHasOneOwningRelation = Relation<RelationType.OneHasOne> & OwningRelation & JoiningColumnRelation & NullableRelation & {
orphanRemoval?: true;
readonly orphanRemoval?: true;
};

@@ -143,19 +150,19 @@ /** @deprecated */

type ManyHasManyOwnerRelation = ManyHasManyOwningRelation;
interface Schema {
enums: {
[name: string]: string[];
type Schema = {
readonly enums: {
readonly [name: string]: readonly string[];
};
entities: {
[name: string]: Entity;
readonly entities: {
readonly [name: string]: Entity;
};
}
interface UniqueConstraints {
[name: string]: UniqueConstraint;
}
interface UniqueConstraint {
fields: string[];
name: string;
}
};
type UniqueConstraints = {
readonly [name: string]: UniqueConstraint;
};
type UniqueConstraint = {
readonly fields: readonly string[];
readonly name: string;
};
}
export default Model;
//# sourceMappingURL=model.d.ts.map

@@ -0,3 +1,4 @@

import { JSONValue } from './json';
declare namespace Validation {
type ContextPath = string[];
type ContextPath = readonly string[];
enum ArgumentType {

@@ -9,52 +10,52 @@ validator = "validator",

type ValidatorArgument = {
type: ArgumentType.validator;
validator: Validator;
readonly type: ArgumentType.validator;
readonly validator: Validator;
};
type PathArgument = {
type: ArgumentType.path;
path: ContextPath;
readonly type: ArgumentType.path;
readonly path: ContextPath;
};
type LiteralArgument<V = any> = {
type: ArgumentType.literal;
value: V;
type LiteralArgument<V = JSONValue> = {
readonly type: ArgumentType.literal;
readonly value: V;
};
type ValidatorArguments = {
and: ValidatorArgument[];
or: ValidatorArgument[];
conditional: [ValidatorArgument, ValidatorArgument];
pattern: [LiteralArgument<[string, string]>];
lengthRange: [LiteralArgument<number | null>, LiteralArgument<number | null>];
range: [LiteralArgument<number | null>, LiteralArgument<number | null>];
equals: [LiteralArgument<any>];
not: [ValidatorArgument];
empty: [];
defined: [];
inContext: [PathArgument, ValidatorArgument];
every: [ValidatorArgument];
any: [ValidatorArgument];
filter: [ValidatorArgument, ValidatorArgument];
readonly and: readonly ValidatorArgument[];
readonly or: readonly ValidatorArgument[];
readonly conditional: readonly [ValidatorArgument, ValidatorArgument];
readonly pattern: readonly [LiteralArgument<readonly [string, string]>];
readonly lengthRange: readonly [LiteralArgument<number | null>, LiteralArgument<number | null>];
readonly range: readonly [LiteralArgument<number | null>, LiteralArgument<number | null>];
readonly equals: readonly [LiteralArgument<JSONValue>];
readonly not: readonly [ValidatorArgument];
readonly empty: readonly [];
readonly defined: readonly [];
readonly inContext: readonly [PathArgument, ValidatorArgument];
readonly every: readonly [ValidatorArgument];
readonly any: readonly [ValidatorArgument];
readonly filter: readonly [ValidatorArgument, ValidatorArgument];
};
type SpecificValidator<N extends keyof ValidatorArguments> = {
operation: N;
args: ValidatorArguments[N];
readonly operation: N;
readonly args: ValidatorArguments[N];
};
type Validator = {
[N in keyof ValidatorArguments]: SpecificValidator<N>;
readonly [N in keyof ValidatorArguments]: SpecificValidator<N>;
}[keyof ValidatorArguments];
type Message = {
text: string;
parameters?: (string | number)[];
readonly text: string;
readonly parameters?: readonly (string | number)[];
};
interface ValidationRule {
validator: Validator;
message: Message;
}
interface EntityRules {
[field: string]: ValidationRule[];
}
interface Schema {
[entity: string]: EntityRules;
}
type ValidationRule = {
readonly validator: Validator;
readonly message: Message;
};
type EntityRules = {
readonly [field: string]: readonly ValidationRule[];
};
type Schema = {
readonly [entity: string]: EntityRules;
};
}
export default Validation;
//# sourceMappingURL=validation.d.ts.map
declare namespace Value {
interface Object<E = never> {
[key: string]: FieldValue<E>;
}
interface List<E = never> extends Array<FieldValue<E>> {
}
type Object<E = never> = {
readonly [key: string]: FieldValue<E>;
};
type List<E = never> = readonly FieldValue<E>[];
type PrimaryValue<E = never> = string | number | E;

@@ -8,0 +7,0 @@ type AtomicValue<E = never> = PrimaryValue<E> | null | boolean;

{
"name": "@contember/schema",
"version": "1.1.0-alpha.5",
"version": "1.1.0-alpha.6",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

@@ -9,9 +9,12 @@ import Input from './schema/input'

export * from './ProjectRole'
export * from './schema/json'
type Schema = {
model: Model.Schema
acl: Acl.Schema
validation: Validation.Schema
readonly model: Model.Schema
readonly acl: Acl.Schema
readonly validation: Validation.Schema
}
export type Writable<V> = {-readonly [K in keyof V]: V[K]}
export { Input, Model, Acl, Schema, Validation, Value, Result }
import Input from './input'
import { JSONValue } from './json'

@@ -20,10 +21,10 @@ namespace Acl {

export interface EntityVariable {
type: VariableType.entity
entityName: string
export type EntityVariable = {
readonly type: VariableType.entity
readonly entityName: string
}
export interface PredefinedVariable {
type: VariableType.predefined
value: 'identityID' | 'personID'
export type PredefinedVariable = {
readonly type: VariableType.predefined
readonly value: 'identityID' | 'personID'
}

@@ -40,4 +41,4 @@

export interface VariablesMap {
[name: string]: VariableValue
export type VariablesMap = {
readonly [name: string]: VariableValue
}

@@ -48,7 +49,7 @@

export type PredicateMap = { [name: string]: PredicateDefinition }
export type PredicateMap = { readonly [name: string]: PredicateDefinition }
export interface EntityPermissions {
predicates: PredicateMap
operations: EntityOperations
export type EntityPermissions = {
readonly predicates: PredicateMap
readonly operations: EntityOperations
}

@@ -63,11 +64,11 @@

export interface EntityOperations {
read?: FieldPermissions
create?: FieldPermissions
customPrimary?: boolean
update?: FieldPermissions
delete?: Predicate
export type EntityOperations = {
readonly read?: FieldPermissions
readonly create?: FieldPermissions
readonly customPrimary?: boolean
readonly update?: FieldPermissions
readonly delete?: Predicate
}
export type FieldPermissions = { [field: string]: Predicate | undefined }
export type FieldPermissions = { readonly [field: string]: Predicate }

@@ -78,3 +79,3 @@ export type PredicateReference = string

export type AnyStage = '*'
export type StagesDefinition = AnyStage | string[]
export type StagesDefinition = AnyStage | readonly string[]

@@ -84,7 +85,7 @@ export type TenantManagedVariableSource = true | string

export type TenantManagePermissions = {
[role: string]: {
variables?:
readonly [role: string]: {
readonly variables?:
| true
| {
[targetVariable: string]: TenantManagedVariableSource
readonly [targetVariable: string]: TenantManagedVariableSource
}

@@ -94,6 +95,6 @@ }

export interface TenantPermissions {
invite?: boolean
unmanagedInvite?: boolean
manage?: TenantManagePermissions
export type TenantPermissions = {
readonly invite?: boolean
readonly unmanagedInvite?: boolean
readonly manage?: TenantManagePermissions
}

@@ -110,29 +111,33 @@

*/
export type LimitedSystemPermissionsLevel = SystemPermissionsLevel.any | SystemPermissionsLevel.none
export type LimitedSystemPermissionsLevel = 'any' | 'none'
export interface SystemPermissions {
history?: boolean | LimitedSystemPermissionsLevel
migrate?: boolean
assumeIdentity?: boolean
export type SystemPermissions = {
readonly history?: boolean | LimitedSystemPermissionsLevel
readonly migrate?: boolean
readonly assumeIdentity?: boolean
}
export type RolePermissions = {
inherits?: string[]
implicit?: boolean
tenant?: TenantPermissions
system?: SystemPermissions
variables: Acl.Variables
stages?: StagesDefinition
entities: Permissions
} & Record<string, unknown>
export interface Permissions {
[entity: string]: EntityPermissions
export interface BaseRolePermissions {
readonly inherits?: readonly string[]
readonly implicit?: boolean
readonly tenant?: TenantPermissions
readonly system?: SystemPermissions
readonly variables: Acl.Variables
readonly stages?: StagesDefinition
readonly entities: Permissions
}
export type RolePermissions =
& BaseRolePermissions
& {
readonly [key: string] : JSONValue
}
export type Permissions = {
readonly [entity: string]: EntityPermissions
}
export type Roles = { [role: string]: RolePermissions }
export type Variables = { [name: string]: Variable }
export type Roles = { readonly [role: string]: RolePermissions }
export type Variables = { readonly [name: string]: Variable }
export interface Schema {
roles: Acl.Roles
export type Schema = {
readonly roles: Acl.Roles
}

@@ -139,0 +144,0 @@ }

@@ -153,39 +153,38 @@ import Value from './value'

export interface Condition<T = Value.FieldValue> {
and?: Array<Condition<T>>
or?: Array<Condition<T>>
not?: Condition<T>
eq?: T
null?: boolean // deprecated
isNull?: boolean
notEq?: T
in?: T[]
notIn?: T[]
lt?: T
lte?: T
gt?: T
gte?: T
never?: true
always?: true
contains?: string
startsWith?: string
endsWith?: string
containsCI?: string
startsWithCI?: string
endsWithCI?: string
export type Condition<T = Value.FieldValue> = {
readonly and?: readonly Condition<T>[]
readonly or?: readonly Condition<T>[]
readonly not?: Condition<T>
readonly eq?: T
readonly null?: boolean // deprecated
readonly isNull?: boolean
readonly notEq?: T
readonly in?: readonly T[]
readonly notIn?: readonly T[]
readonly lt?: T
readonly lte?: T
readonly gt?: T
readonly gte?: T
readonly never?: true
readonly always?: true
readonly contains?: string
readonly startsWith?: string
readonly endsWith?: string
readonly containsCI?: string
readonly startsWithCI?: string
readonly endsWithCI?: string
}
export interface UniqueWhere<E = never> {
[field: string]: Value.PrimaryValue<E> | UniqueWhere<E>
export type UniqueWhere<E = never> = {
readonly [field: string]: Value.PrimaryValue<E> | UniqueWhere<E>
}
export type ComposedWhere<C, Opt = never> = {
and?: (Where<C, Opt> | Opt)[]
or?: (Where<C, Opt> | Opt)[]
not?: Where<C, Opt>
readonly and?: readonly (Where<C, Opt> | Opt)[]
readonly or?: readonly (Where<C, Opt> | Opt)[]
readonly not?: Where<C, Opt>
}
export interface FieldWhere<C = Condition, Opt = never> {
[name: string]: C | Where<C, Opt> | undefined | (Where<C, Opt> | Opt)[] //last one if for ComposedWhere
readonly [name: string]: C | Where<C, Opt> | readonly (Where<C, Opt> | Opt)[] //last one if for ComposedWhere
}

@@ -192,0 +191,0 @@

import Input from './input'
namespace Model {
export interface Entity {
name: string
primary: string
primaryColumn: string
tableName: string
fields: { [name: string]: AnyField }
unique: UniqueConstraints
view?: View
export type Entity = {
readonly name: string
readonly primary: string
readonly primaryColumn: string
readonly tableName: string
readonly fields: { readonly [name: string]: AnyField }
readonly unique: UniqueConstraints
readonly view?: View
readonly eventLog: EventLogConfig
}
export interface View {
sql: string
dependencies?: string[]
export type View = {
readonly sql: string
readonly dependencies?: readonly string[]
}
export type EventLogConfig = {
readonly enabled: boolean
}
export type FieldType = RelationType | ColumnType
export interface Field<T extends FieldType> {
type: T
export type Field<T extends FieldType> = {
readonly type: T
}

@@ -40,12 +46,18 @@

export type Column<T extends ColumnType> = ColumnTypeDefinition<T> & {
name: string
columnName: string
readonly name: string
readonly columnName: string
}
export interface ColumnTypeDefinition<T extends ColumnType = ColumnType> extends Field<T> {
columnType: string
typeAlias?: string
nullable: boolean
default?: string | number | boolean | null
}
export type ColumnTypeDefinition<T extends ColumnType = ColumnType> =
& Field<T>
& {
readonly columnType: string
readonly typeAlias?: string
readonly nullable: boolean
readonly default?: string | number | boolean | null
readonly sequence?: {
readonly precedence: 'ALWAYS' | 'BY DEFAULT'
readonly start?: number
}
}

@@ -145,21 +157,27 @@ export interface ColumnVisitor<T> {

export interface Relation<T extends RelationType = RelationType> extends Field<T> {
name: string
type: T
target: string
}
export type Relation<T extends RelationType = RelationType>=
& Field<T>
& {
readonly name: string
readonly type: T
readonly target: string
}
export interface InverseRelation extends Relation {
ownedBy: string
}
export type InverseRelation =
& Relation
& {
readonly ownedBy: string
}
/** @deprecated */
export interface InversedRelation extends InverseRelation {}
export type InversedRelation = InverseRelation
export interface OwningRelation extends Relation {
inversedBy?: string
}
export type OwningRelation =
& Relation
& {
readonly inversedBy?: string
}
/** @deprecated */
export interface OwnerRelation extends OwningRelation {}
export type OwnerRelation = OwningRelation

@@ -173,29 +191,33 @@ export enum OnDelete {

export type JoiningColumn = {
columnName: string
onDelete: OnDelete
readonly columnName: string
readonly onDelete: OnDelete
}
export interface JoiningColumnRelation {
joiningColumn: JoiningColumn
export type JoiningColumnRelation = {
readonly joiningColumn: JoiningColumn
}
export interface NullableRelation {
nullable: boolean
export type NullableRelation = {
readonly nullable: boolean
}
export interface JoiningTable {
tableName: string
joiningColumn: JoiningColumn
inverseJoiningColumn: JoiningColumn
export type JoiningTable = {
readonly tableName: string
readonly joiningColumn: JoiningColumn
readonly inverseJoiningColumn: JoiningColumn
readonly eventLog: EventLogConfig
}
export interface JoiningTableRelation {
joiningTable: JoiningTable
export type JoiningTableRelation = {
readonly joiningTable: JoiningTable
}
export import OrderDirection = Input.OrderDirection
export type OrderBy = { path: string[]; direction: OrderDirection }
export type OrderBy = {
readonly path: readonly string[]
readonly direction: OrderDirection
}
export interface OrderableRelation {
orderBy?: OrderBy[]
export type OrderableRelation = {
readonly orderBy?: readonly OrderBy[]
}

@@ -227,3 +249,3 @@

& {
orphanRemoval?: true
readonly orphanRemoval?: true
}

@@ -248,14 +270,14 @@ /** @deprecated */

export interface Schema {
enums: { [name: string]: string[] }
entities: { [name: string]: Entity }
export type Schema = {
readonly enums: { readonly [name: string]: readonly string[] }
readonly entities: { readonly [name: string]: Entity }
}
export interface UniqueConstraints {
[name: string]: UniqueConstraint
export type UniqueConstraints = {
readonly [name: string]: UniqueConstraint
}
export interface UniqueConstraint {
fields: string[]
name: string
export type UniqueConstraint = {
readonly fields: readonly string[]
readonly name: string
}

@@ -262,0 +284,0 @@ }

@@ -0,3 +1,5 @@

import { JSONValue } from './json'
namespace Validation {
export type ContextPath = string[]
export type ContextPath = readonly string[]

@@ -10,43 +12,57 @@ export enum ArgumentType {

export type ValidatorArgument = { type: ArgumentType.validator; validator: Validator }
export type PathArgument = { type: ArgumentType.path; path: ContextPath }
export type LiteralArgument<V = any> = { type: ArgumentType.literal; value: V }
export type ValidatorArgument = {
readonly type: ArgumentType.validator
readonly validator: Validator
}
export type PathArgument = {
readonly type: ArgumentType.path
readonly path: ContextPath
}
export type LiteralArgument<V = JSONValue> = {
readonly type: ArgumentType.literal
readonly value: V
}
export type ValidatorArguments = {
and: ValidatorArgument[]
or: ValidatorArgument[]
conditional: [ValidatorArgument, ValidatorArgument]
pattern: [LiteralArgument<[string, string]>]
lengthRange: [LiteralArgument<number | null>, LiteralArgument<number | null>]
range: [LiteralArgument<number | null>, LiteralArgument<number | null>]
equals: [LiteralArgument<any>]
not: [ValidatorArgument]
empty: []
defined: []
inContext: [PathArgument, ValidatorArgument]
every: [ValidatorArgument]
any: [ValidatorArgument]
filter: [ValidatorArgument, ValidatorArgument]
readonly and: readonly ValidatorArgument[]
readonly or: readonly ValidatorArgument[]
readonly conditional: readonly [ValidatorArgument, ValidatorArgument]
readonly pattern: readonly [LiteralArgument<readonly [string, string]>]
readonly lengthRange: readonly [LiteralArgument<number | null>, LiteralArgument<number | null>]
readonly range: readonly [LiteralArgument<number | null>, LiteralArgument<number | null>]
readonly equals: readonly [LiteralArgument<JSONValue>]
readonly not: readonly [ValidatorArgument]
readonly empty: readonly[]
readonly defined: readonly[]
readonly inContext: readonly [PathArgument, ValidatorArgument]
readonly every: readonly [ValidatorArgument]
readonly any: readonly [ValidatorArgument]
readonly filter: readonly [ValidatorArgument, ValidatorArgument]
}
export type SpecificValidator<N extends keyof ValidatorArguments> = {
operation: N
args: ValidatorArguments[N]
readonly operation: N
readonly args: ValidatorArguments[N]
}
export type Validator = { [N in keyof ValidatorArguments]: SpecificValidator<N> }[keyof ValidatorArguments]
export type Validator = {
readonly [N in keyof ValidatorArguments]: SpecificValidator<N>
}[keyof ValidatorArguments]
export type Message = { text: string; parameters?: (string | number)[] }
export type Message = {
readonly text: string
readonly parameters?: readonly (string | number)[]
}
export interface ValidationRule {
validator: Validator
message: Message
export type ValidationRule = {
readonly validator: Validator
readonly message: Message
}
export interface EntityRules {
[field: string]: ValidationRule[]
export type EntityRules = {
readonly [field: string]: readonly ValidationRule[]
}
export interface Schema {
[entity: string]: EntityRules
export type Schema = {
readonly [entity: string]: EntityRules
}

@@ -53,0 +69,0 @@ }

namespace Value {
export interface Object<E = never> {
[key: string]: FieldValue<E>
export type Object<E = never> = {
readonly [key: string]: FieldValue<E>
}
export interface List<E = never> extends Array<FieldValue<E>> {}
export type List<E = never> = readonly FieldValue<E>[]

@@ -8,0 +8,0 @@ export type PrimaryValue<E = never> = string | number | E

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc