@snowtop/ent 0.1.0-alpha → 0.1.0-alpha6

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.
@@ -309,7 +309,7 @@ class Orchestrator {
309
309
  for (const [fieldName, field] of schemaFields) {
310
310
  let value = editedFields.get(fieldName);
311
311
  let defaultValue = undefined;
312
- let dbKey = field.storageKey || (0, snake_case_1.snakeCase)(field.name);
312
+ let dbKey = field.storageKey || (0, snake_case_1.snakeCase)(fieldName);
313
313
  if (value === undefined) {
314
314
  if (this.options.operation === action_1.WriteOperation.Insert) {
315
315
  if (field.defaultToViewerOnCreate && field.defaultValueOnCreate) {
@@ -321,7 +321,7 @@ class Orchestrator {
321
321
  if (field.defaultValueOnCreate) {
322
322
  defaultValue = field.defaultValueOnCreate(builder, input);
323
323
  if (defaultValue === undefined) {
324
- throw new Error(`defaultValueOnCreate() returned undefined for field ${field.name}`);
324
+ throw new Error(`defaultValueOnCreate() returned undefined for field ${fieldName}`);
325
325
  }
326
326
  }
327
327
  }
@@ -360,11 +360,11 @@ class Orchestrator {
360
360
  }
361
361
  return false;
362
362
  }
363
- async transformFieldValue(field, dbKey, value) {
363
+ async transformFieldValue(fieldName, field, dbKey, value) {
364
364
  // now format and validate...
365
365
  if (value === null) {
366
366
  if (!field.nullable) {
367
- throw new Error(`field ${field.name} set to null for non-nullable field`);
367
+ throw new Error(`field ${fieldName} set to null for non-nullable field`);
368
368
  }
369
369
  }
370
370
  else if (value === undefined) {
@@ -375,14 +375,14 @@ class Orchestrator {
375
375
  // server default allowed
376
376
  field.serverDefault === undefined &&
377
377
  this.options.operation === action_1.WriteOperation.Insert) {
378
- throw new Error(`required field ${field.name} not set`);
378
+ throw new Error(`required field ${fieldName} not set`);
379
379
  }
380
380
  }
381
381
  else if (this.isBuilder(value)) {
382
382
  if (field.valid) {
383
383
  const valid = await Promise.resolve(field.valid(value));
384
384
  if (!valid) {
385
- throw new Error(`invalid field ${field.name} with value ${value}`);
385
+ throw new Error(`invalid field ${fieldName} with value ${value}`);
386
386
  }
387
387
  }
388
388
  // keep track of dependencies to resolve
@@ -395,7 +395,7 @@ class Orchestrator {
395
395
  // TODO this could be async. handle this better
396
396
  const valid = await Promise.resolve(field.valid(value));
397
397
  if (!valid) {
398
- throw new Error(`invalid field ${field.name} with value ${value}`);
398
+ throw new Error(`invalid field ${fieldName} with value ${value}`);
399
399
  }
400
400
  }
401
401
  if (field.format) {
@@ -420,8 +420,8 @@ class Orchestrator {
420
420
  // null allowed
421
421
  value = this.defaultFieldsByFieldName[fieldName];
422
422
  }
423
- let dbKey = field.storageKey || (0, snake_case_1.snakeCase)(field.name);
424
- value = await this.transformFieldValue(field, dbKey, value);
423
+ let dbKey = field.storageKey || (0, snake_case_1.snakeCase)(fieldName);
424
+ value = await this.transformFieldValue(fieldName, field, dbKey, value);
425
425
  if (value !== undefined) {
426
426
  data[dbKey] = value;
427
427
  logValues[dbKey] = field.logValue(value);
@@ -433,10 +433,10 @@ class Orchestrator {
433
433
  for (const fieldName in this.defaultFieldsByFieldName) {
434
434
  const defaultValue = this.defaultFieldsByFieldName[fieldName];
435
435
  let field = schemaFields.get(fieldName);
436
- let dbKey = field.storageKey || (0, snake_case_1.snakeCase)(field.name);
436
+ let dbKey = field.storageKey || (0, snake_case_1.snakeCase)(fieldName);
437
437
  // no value, let's just default
438
438
  if (data[dbKey] === undefined) {
439
- const value = await this.transformFieldValue(field, dbKey, defaultValue);
439
+ const value = await this.transformFieldValue(fieldName, field, dbKey, defaultValue);
440
440
  data[dbKey] = value;
441
441
  logValues[dbKey] = field.logValue(value);
442
442
  }
@@ -8,3 +8,4 @@ export { GraphQLConnectionInterface } from "./builtins/connection";
8
8
  export { GraphQLEdgeInterface } from "./builtins/edge";
9
9
  export { NodeResolver, EntNodeResolver, registerResolver, clearResolvers, resolveID, nodeIDEncoder, mustDecodeIDFromGQLID, mustDecodeNullableIDFromGQLID, encodeGQLID, } from "./node_resolver";
10
10
  export { convertFromGQLEnum, convertToGQLEnum } from "./enums";
11
+ export { transformUnionTypes } from "./mutations/union";
package/graphql/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertToGQLEnum = exports.convertFromGQLEnum = exports.encodeGQLID = exports.mustDecodeNullableIDFromGQLID = exports.mustDecodeIDFromGQLID = exports.nodeIDEncoder = exports.resolveID = exports.clearResolvers = exports.registerResolver = exports.EntNodeResolver = exports.GraphQLEdgeInterface = exports.GraphQLConnectionInterface = exports.GraphQLNodeInterface = exports.GraphQLConnectionType = exports.GraphQLEdgeType = exports.GraphQLEdgeConnection = exports.GraphQLPageInfo = exports.GraphQLTime = exports.gqlFileUpload = exports.GQLCapture = exports.gqlConnection = exports.gqlContextType = exports.gqlMutation = exports.gqlQuery = exports.gqlObjectType = exports.gqlInputObjectType = exports.gqlArgType = exports.gqlArg = exports.gqlField = void 0;
3
+ exports.transformUnionTypes = exports.convertToGQLEnum = exports.convertFromGQLEnum = exports.encodeGQLID = exports.mustDecodeNullableIDFromGQLID = exports.mustDecodeIDFromGQLID = exports.nodeIDEncoder = exports.resolveID = exports.clearResolvers = exports.registerResolver = exports.EntNodeResolver = exports.GraphQLEdgeInterface = exports.GraphQLConnectionInterface = exports.GraphQLNodeInterface = exports.GraphQLConnectionType = exports.GraphQLEdgeType = exports.GraphQLEdgeConnection = exports.GraphQLPageInfo = exports.GraphQLTime = exports.gqlFileUpload = exports.GQLCapture = exports.gqlConnection = exports.gqlContextType = exports.gqlMutation = exports.gqlQuery = exports.gqlObjectType = exports.gqlInputObjectType = exports.gqlArgType = exports.gqlArg = exports.gqlField = void 0;
4
4
  var graphql_1 = require("./graphql");
5
5
  Object.defineProperty(exports, "gqlField", { enumerable: true, get: function () { return graphql_1.gqlField; } });
6
6
  Object.defineProperty(exports, "gqlArg", { enumerable: true, get: function () { return graphql_1.gqlArg; } });
@@ -40,3 +40,5 @@ Object.defineProperty(exports, "encodeGQLID", { enumerable: true, get: function
40
40
  var enums_1 = require("./enums");
41
41
  Object.defineProperty(exports, "convertFromGQLEnum", { enumerable: true, get: function () { return enums_1.convertFromGQLEnum; } });
42
42
  Object.defineProperty(exports, "convertToGQLEnum", { enumerable: true, get: function () { return enums_1.convertToGQLEnum; } });
43
+ var union_1 = require("./mutations/union");
44
+ Object.defineProperty(exports, "transformUnionTypes", { enumerable: true, get: function () { return union_1.transformUnionTypes; } });
@@ -0,0 +1,2 @@
1
+ import { Data } from "../../core/base";
2
+ export declare function transformUnionTypes<T extends Data>(input: T, pathsList: string[][]): T;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformUnionTypes = void 0;
4
+ // this transforms an input for union types from graphql format to TS format
5
+ // in graphql, we represent it as UnionType = {foo: FooType, bar: BarType, baz: BazType}
6
+ // in TS, we repseent it as UnionType = FooType | BarType | BazType
7
+ // this takes an input, paths to unions and transforms them as needed
8
+ // only works on fields that are defined. depends on graphql to handle nullable/missing fields
9
+ function transformUnionTypes(input, pathsList) {
10
+ for (const paths of pathsList) {
11
+ const lastPath = paths[paths.length - 1];
12
+ let last = input;
13
+ for (const path of paths) {
14
+ let curr = last[path];
15
+ if (curr === undefined) {
16
+ break;
17
+ }
18
+ if (path === lastPath) {
19
+ let count = 0;
20
+ let lastKey = undefined;
21
+ for (const k in curr) {
22
+ count++;
23
+ lastKey = k;
24
+ }
25
+ if (count != 1) {
26
+ throw new Error(`can only only pass one key of union. passed ${count}`);
27
+ }
28
+ last[path] = curr[lastKey];
29
+ }
30
+ last = curr;
31
+ }
32
+ }
33
+ return input;
34
+ }
35
+ exports.transformUnionTypes = transformUnionTypes;
@@ -11,7 +11,6 @@ interface classResult {
11
11
  file: file;
12
12
  }
13
13
  export declare function parseCustomImports(filePath: string, opts?: Options): PathResult;
14
- export declare function findTSConfigFile(filePath: string): string | null;
15
14
  export interface importInfo {
16
15
  name: string;
17
16
  importPath: string;
package/imports/index.js CHANGED
@@ -22,12 +22,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.findTSConfigFile = exports.parseCustomImports = void 0;
25
+ exports.parseCustomImports = void 0;
26
26
  const glob_1 = __importDefault(require("glob"));
27
27
  const typescript_1 = __importDefault(require("typescript"));
28
- const json5_1 = __importDefault(require("json5"));
29
28
  const fs = __importStar(require("fs"));
30
29
  const path = __importStar(require("path"));
30
+ const compilerOptions_1 = require("../tsc/compilerOptions");
31
31
  function getFiles(filePath, opts) {
32
32
  if (!path.isAbsolute(filePath)) {
33
33
  throw new Error("absolute file path required");
@@ -44,7 +44,7 @@ function getFiles(filePath, opts) {
44
44
  }
45
45
  function parseCustomImports(filePath, opts) {
46
46
  const files = getFiles(filePath, opts);
47
- const options = readCompilerOptions(filePath);
47
+ const options = (0, compilerOptions_1.readCompilerOptions)(filePath);
48
48
  let classMap = new Map();
49
49
  files.forEach((file) => {
50
50
  const sourceFile = typescript_1.default.createSourceFile(file, fs.readFileSync(file).toString(), options.target || typescript_1.default.ScriptTarget.ES2015);
@@ -77,39 +77,6 @@ function parseCustomImports(filePath, opts) {
77
77
  };
78
78
  }
79
79
  exports.parseCustomImports = parseCustomImports;
80
- function findTSConfigFile(filePath) {
81
- while (filePath != "/") {
82
- let configPath = `${filePath}/tsconfig.json`;
83
- if (fs.existsSync(configPath)) {
84
- return configPath;
85
- }
86
- filePath = path.join(filePath, "..");
87
- }
88
- return null;
89
- }
90
- exports.findTSConfigFile = findTSConfigFile;
91
- // inspiration taken from compiler.ts
92
- function readCompilerOptions(filePath) {
93
- let configPath = findTSConfigFile(filePath);
94
- if (!configPath) {
95
- return {};
96
- }
97
- let json = {};
98
- try {
99
- json = json5_1.default.parse(fs.readFileSync(configPath, {
100
- encoding: "utf8",
101
- }));
102
- }
103
- catch (e) {
104
- console.error("couldn't read tsconfig.json file");
105
- return {};
106
- }
107
- let options = json["compilerOptions"] || {};
108
- if (options.moduleResolution === "node") {
109
- options.moduleResolution = typescript_1.default.ModuleResolutionKind.NodeJs;
110
- }
111
- return options;
112
- }
113
80
  function traverse(sourceFile, f, classMap) {
114
81
  typescript_1.default.forEachChild(sourceFile, function (node) {
115
82
  switch (node.kind) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowtop/ent",
3
- "version": "0.1.0-alpha",
3
+ "version": "0.1.0-alpha6",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,4 +1,4 @@
1
- import { Schema, Field, AssocEdge, AssocEdgeGroup, Action } from "../schema";
1
+ import { Schema, Field, AssocEdge, AssocEdgeGroup, Action, Type } from "../schema";
2
2
  import { ActionField } from "../schema/schema";
3
3
  declare enum NullableResult {
4
4
  CONTENTS = "contents",
@@ -32,10 +32,18 @@ interface ProcessedPattern {
32
32
  assocEdges: ProcessedAssocEdge[];
33
33
  fields: ProcessedField[];
34
34
  }
35
- declare type ProcessedField = Omit<Field, "defaultValueOnEdit" | "defaultValueOnCreate"> & {
35
+ declare type ProcessedType = Omit<Type, "subFields" | "listElemType" | "unionFields"> & {
36
+ subFields?: ProcessedField[];
37
+ listElemType?: ProcessedType;
38
+ unionFields?: ProcessedField[];
39
+ };
40
+ declare type ProcessedField = Omit<Field, "defaultValueOnEdit" | "defaultValueOnCreate" | "type"> & {
41
+ name: string;
36
42
  hasDefaultValueOnCreate?: boolean;
37
43
  hasDefaultValueOnEdit?: boolean;
38
44
  patternName?: string;
45
+ derivedFields?: ProcessedField[];
46
+ type: ProcessedType;
39
47
  };
40
48
  interface patternsDict {
41
49
  [key: string]: ProcessedPattern;
@@ -3,8 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseSchema = void 0;
4
4
  function processFields(src, patternName) {
5
5
  const ret = [];
6
- for (const field of src) {
7
- let f = { ...field };
6
+ let m = {};
7
+ if (Array.isArray(src)) {
8
+ for (const field of src) {
9
+ const name = field.name;
10
+ if (!name) {
11
+ throw new Error(`name is required`);
12
+ }
13
+ m[name] = field;
14
+ }
15
+ }
16
+ else {
17
+ m = src;
18
+ }
19
+ for (const name in m) {
20
+ const field = m[name];
21
+ //@ts-ignore type and other changed fields with different type in ProcessedField vs Field
22
+ let f = { name, ...field };
8
23
  f.hasDefaultValueOnCreate = field.defaultValueOnCreate != undefined;
9
24
  f.hasDefaultValueOnEdit = field.defaultValueOnEdit != undefined;
10
25
  if (field.polymorphic) {
@@ -17,6 +32,9 @@ function processFields(src, patternName) {
17
32
  f.polymorphic = field.polymorphic;
18
33
  }
19
34
  }
35
+ else {
36
+ delete f.polymorphic;
37
+ }
20
38
  // convert string to object to make API consumed by go simple
21
39
  if (f.fieldEdge && f.fieldEdge.inverseEdge) {
22
40
  if (typeof f.fieldEdge.inverseEdge === "string") {
@@ -28,6 +46,21 @@ function processFields(src, patternName) {
28
46
  if (patternName) {
29
47
  f.patternName = patternName;
30
48
  }
49
+ if (field.getDerivedFields) {
50
+ f.derivedFields = processFields(field.getDerivedFields(name));
51
+ }
52
+ if (field.type.subFields) {
53
+ f.type.subFields = processFields(field.type.subFields);
54
+ }
55
+ if (field.type.unionFields) {
56
+ f.type.unionFields = processFields(field.type.unionFields);
57
+ }
58
+ if (field.type.listElemType &&
59
+ field.type.listElemType.subFields &&
60
+ // check to avoid ts-ignore below. exists just for tsc
61
+ f.type.listElemType) {
62
+ f.type.listElemType.subFields = processFields(field.type.listElemType.subFields);
63
+ }
31
64
  ret.push(f);
32
65
  }
33
66
  return ret;
@@ -91,6 +124,7 @@ function processAction(action) {
91
124
  let actionOnlyFields = action.actionOnlyFields.map((f) => {
92
125
  let f2 = f;
93
126
  if (!f.nullable) {
127
+ delete f2.nullable;
94
128
  return f2;
95
129
  }
96
130
  if (typeof f.nullable === "boolean") {
@@ -3,17 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseEntSchemaWithTZ = exports.BaseEntSchema = exports.Node = exports.Timestamps = void 0;
4
4
  const uuid_1 = require("uuid");
5
5
  const field_1 = require("./field");
6
- let tsFields = [
7
- (0, field_1.TimestampType)({
8
- name: "createdAt",
6
+ let tsFields = {
7
+ createdAt: (0, field_1.TimestampType)({
9
8
  hideFromGraphQL: true,
10
9
  disableUserEditable: true,
11
10
  defaultValueOnCreate: () => {
12
11
  return new Date();
13
12
  },
14
13
  }),
15
- (0, field_1.TimestampType)({
16
- name: "updatedAt",
14
+ updatedAt: (0, field_1.TimestampType)({
17
15
  hideFromGraphQL: true,
18
16
  disableUserEditable: true,
19
17
  defaultValueOnCreate: () => {
@@ -23,25 +21,28 @@ let tsFields = [
23
21
  return new Date();
24
22
  },
25
23
  }),
26
- ];
24
+ };
27
25
  // Timestamps is a Pattern that adds a createdAt and updatedAt timestamp fields to the ent
28
26
  exports.Timestamps = {
29
27
  name: "timestamps",
30
28
  fields: tsFields,
31
29
  };
32
30
  let nodeField = (0, field_1.UUIDType)({
33
- name: "ID",
34
31
  primaryKey: true,
35
32
  disableUserEditable: true,
36
33
  defaultValueOnCreate: () => {
37
34
  return (0, uuid_1.v4)();
38
35
  },
39
36
  });
40
- let nodeFields = [nodeField, ...tsFields];
41
- let nodeFieldsWithTZ = [
42
- nodeField,
43
- (0, field_1.TimestampType)({
44
- name: "createdAt",
37
+ let nodeFields = {
38
+ // inconsistent naming :(
39
+ ID: nodeField,
40
+ ...tsFields,
41
+ };
42
+ let nodeFieldsWithTZ = {
43
+ // inconsistent naming :(
44
+ ID: nodeField,
45
+ createdAt: (0, field_1.TimestampType)({
45
46
  hideFromGraphQL: true,
46
47
  disableUserEditable: true,
47
48
  defaultValueOnCreate: () => {
@@ -49,8 +50,7 @@ let nodeFieldsWithTZ = [
49
50
  },
50
51
  withTimezone: true,
51
52
  }),
52
- (0, field_1.TimestampType)({
53
- name: "updatedAt",
53
+ updatedAt: (0, field_1.TimestampType)({
54
54
  hideFromGraphQL: true,
55
55
  disableUserEditable: true,
56
56
  defaultValueOnCreate: () => {
@@ -61,7 +61,7 @@ let nodeFieldsWithTZ = [
61
61
  },
62
62
  withTimezone: true,
63
63
  }),
64
- ];
64
+ };
65
65
  // Node is a Pattern that adds 3 fields to the ent: (id, createdAt, and updatedAt timestamps)
66
66
  exports.Node = {
67
67
  name: "node",
package/schema/field.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Field, FieldOptions, ForeignKey, PolymorphicOptions, Type } from "./schema";
1
+ import { Field, FieldMap, FieldOptions, ForeignKey, PolymorphicOptions, Type } from "./schema";
2
2
  export declare abstract class BaseField {
3
3
  name: string;
4
4
  nullable?: boolean;
@@ -12,18 +12,18 @@ export declare abstract class BaseField {
12
12
  index?: boolean;
13
13
  foreignKey?: ForeignKey;
14
14
  polymorphic?: boolean | PolymorphicOptions;
15
- derivedFields?: Field[];
16
15
  derivedWhenEmbedded?: boolean;
17
16
  logValue(val: any): any;
18
17
  }
19
18
  export declare class UUIDField extends BaseField implements Field {
20
- private options;
19
+ private options?;
21
20
  type: Type;
22
- constructor(options: FieldOptions);
21
+ constructor(options?: FieldOptions | undefined);
22
+ getDerivedFields(fieldName: string): FieldMap;
23
23
  private isBuilder;
24
24
  valid(val: any): Promise<boolean>;
25
25
  }
26
- export declare function UUIDType(options: FieldOptions): UUIDField;
26
+ export declare function UUIDType(options?: FieldOptions): UUIDField;
27
27
  export interface IntegerOptions extends FieldOptions {
28
28
  min?: number;
29
29
  max?: number;
@@ -40,7 +40,7 @@ export declare class IntegerField extends BaseField implements Field {
40
40
  valid(val: any): boolean;
41
41
  validate(validator: (str: number) => boolean): this;
42
42
  }
43
- export declare function IntegerType(options: IntegerOptions): IntegerField;
43
+ export declare function IntegerType(options?: IntegerOptions): IntegerField;
44
44
  export declare class BigIntegerField extends BaseField implements Field {
45
45
  type: Type;
46
46
  }
@@ -48,11 +48,11 @@ export declare function BigIntegerType(options: FieldOptions): BigIntegerField;
48
48
  export declare class FloatField extends BaseField implements Field {
49
49
  type: Type;
50
50
  }
51
- export declare function FloatType(options: FieldOptions): FloatField;
51
+ export declare function FloatType(options?: FieldOptions): FloatField;
52
52
  export declare class BooleanField extends BaseField implements Field {
53
53
  type: Type;
54
54
  }
55
- export declare function BooleanType(options: FieldOptions): BooleanField;
55
+ export declare function BooleanType(options?: FieldOptions): BooleanField;
56
56
  export interface StringOptions extends FieldOptions {
57
57
  minLen?: number;
58
58
  maxLen?: number;
@@ -88,7 +88,7 @@ export declare class StringField extends BaseField implements Field {
88
88
  trimLeft(): this;
89
89
  trimRight(): this;
90
90
  }
91
- export declare function StringType(options: StringOptions): StringField;
91
+ export declare function StringType(options?: StringOptions): StringField;
92
92
  export interface TimestampOptions extends FieldOptions {
93
93
  withTimezone?: boolean;
94
94
  }
@@ -98,8 +98,8 @@ export declare class TimestampField extends BaseField implements Field {
98
98
  constructor(options: TimestampOptions);
99
99
  format(val: Date): any;
100
100
  }
101
- export declare function TimestampType(options: TimestampOptions): TimestampField;
102
- export declare function TimestamptzType(options: FieldOptions): TimestampField;
101
+ export declare function TimestampType(options?: TimestampOptions): TimestampField;
102
+ export declare function TimestamptzType(options?: FieldOptions): TimestampField;
103
103
  export interface TimeOptions extends FieldOptions {
104
104
  withTimezone?: boolean;
105
105
  precision?: number;
@@ -108,16 +108,16 @@ export declare const leftPad: (val: number) => string;
108
108
  export declare class TimeField extends BaseField implements Field {
109
109
  type: Type;
110
110
  withTimezone?: boolean;
111
- constructor(options: TimeOptions);
111
+ constructor(options?: TimeOptions);
112
112
  format(val: any): any;
113
113
  }
114
- export declare function TimeType(options: TimeOptions): TimeField;
115
- export declare function TimetzType(options: FieldOptions): TimeField;
114
+ export declare function TimeType(options?: TimeOptions): TimeField;
115
+ export declare function TimetzType(options?: FieldOptions): TimeField;
116
116
  export declare class DateField extends BaseField implements Field {
117
117
  type: Type;
118
118
  format(val: any): any;
119
119
  }
120
- export declare function DateType(options: FieldOptions): DateField;
120
+ export declare function DateType(options?: FieldOptions): DateField;
121
121
  declare type EnumMap = {
122
122
  [key: string]: string;
123
123
  };
@@ -142,27 +142,27 @@ export declare class ListField extends BaseField {
142
142
  private field;
143
143
  type: Type;
144
144
  private validators;
145
- constructor(field: Field, options: FieldOptions);
145
+ constructor(field: Field, options?: FieldOptions);
146
146
  validate(validator: (val: any[]) => boolean): this;
147
147
  valid(val: any): Promise<boolean>;
148
148
  private postgresVal;
149
- format(val: any): any;
149
+ format(val: any, nested?: boolean): any;
150
150
  minLen(l: number): this;
151
151
  maxLen(l: number): this;
152
152
  length(l: number): this;
153
153
  range(start: any, stop: any): this;
154
154
  }
155
- export declare function StringListType(options: StringOptions): ListField;
155
+ export declare function StringListType(options?: StringOptions): ListField;
156
156
  export declare function IntListType(options: FieldOptions): ListField;
157
- export declare function IntegerListType(options: FieldOptions): ListField;
158
- export declare function FloatListType(options: FieldOptions): ListField;
157
+ export declare function IntegerListType(options?: FieldOptions): ListField;
158
+ export declare function FloatListType(options?: FieldOptions): ListField;
159
159
  export declare function BigIntegerListType(options: FieldOptions): ListField;
160
- export declare function BooleanListType(options: FieldOptions): ListField;
160
+ export declare function BooleanListType(options?: FieldOptions): ListField;
161
161
  export declare function TimestampListType(options: TimestampOptions): ListField;
162
- export declare function TimestamptzListType(options: TimestampOptions): ListField;
163
- export declare function TimeListType(options: TimeOptions): ListField;
162
+ export declare function TimestamptzListType(options?: TimestampOptions): ListField;
163
+ export declare function TimeListType(options?: TimeOptions): ListField;
164
164
  export declare function TimetzListType(options: TimeOptions): ListField;
165
- export declare function DateListType(options: FieldOptions): ListField;
165
+ export declare function DateListType(options?: FieldOptions): ListField;
166
166
  export declare function EnumListType(options: EnumOptions): ListField;
167
- export declare function UUIDListType(options: FieldOptions): ListField;
167
+ export declare function UUIDListType(options?: FieldOptions): ListField;
168
168
  export {};