@snowtop/ent 0.0.40-alpha6 → 0.1.0-alpha10

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.
Files changed (65) hide show
  1. package/action/action.d.ts +14 -14
  2. package/action/executor.d.ts +1 -1
  3. package/action/experimental_action.d.ts +20 -20
  4. package/action/experimental_action.js +1 -1
  5. package/action/orchestrator.d.ts +10 -10
  6. package/action/orchestrator.js +14 -14
  7. package/core/base.d.ts +6 -6
  8. package/core/ent.d.ts +2 -1
  9. package/core/ent.js +14 -10
  10. package/core/privacy.d.ts +1 -1
  11. package/core/query/assoc_query.js +2 -2
  12. package/core/query/query.d.ts +1 -1
  13. package/graphql/builtins/connection.js +3 -3
  14. package/graphql/builtins/edge.js +2 -2
  15. package/graphql/builtins/node.js +1 -1
  16. package/graphql/graphql.js +2 -2
  17. package/graphql/index.d.ts +1 -0
  18. package/graphql/index.js +3 -1
  19. package/graphql/mutations/union.d.ts +2 -0
  20. package/graphql/mutations/union.js +35 -0
  21. package/graphql/query/connection_type.js +6 -6
  22. package/graphql/query/page_info.js +4 -4
  23. package/graphql/query/shared_assoc_test.js +2 -2
  24. package/graphql/scalars/time.d.ts +1 -1
  25. package/imports/index.d.ts +0 -1
  26. package/imports/index.js +3 -36
  27. package/package.json +2 -2
  28. package/parse_schema/parse.d.ts +15 -3
  29. package/parse_schema/parse.js +42 -7
  30. package/schema/base_schema.d.ts +36 -1
  31. package/schema/base_schema.js +63 -17
  32. package/schema/field.d.ts +25 -25
  33. package/schema/field.js +42 -33
  34. package/schema/index.d.ts +4 -2
  35. package/schema/index.js +5 -1
  36. package/schema/json_field.d.ts +6 -6
  37. package/schema/json_field.js +2 -2
  38. package/schema/schema.d.ts +11 -6
  39. package/schema/schema.js +46 -12
  40. package/schema/struct_field.d.ts +17 -0
  41. package/schema/struct_field.js +102 -0
  42. package/schema/union_field.d.ts +23 -0
  43. package/schema/union_field.js +79 -0
  44. package/scripts/custom_compiler.js +2 -19
  45. package/scripts/read_schema.js +15 -1
  46. package/scripts/transform_code.d.ts +1 -0
  47. package/scripts/transform_code.js +114 -0
  48. package/scripts/transform_schema.d.ts +1 -0
  49. package/scripts/transform_schema.js +357 -0
  50. package/testutils/builder.d.ts +19 -15
  51. package/testutils/builder.js +41 -7
  52. package/testutils/db/test_db.js +9 -9
  53. package/testutils/ent-graphql-tests/index.js +19 -12
  54. package/testutils/fake_data/fake_contact.d.ts +3 -7
  55. package/testutils/fake_data/fake_contact.js +14 -26
  56. package/testutils/fake_data/fake_event.d.ts +3 -7
  57. package/testutils/fake_data/fake_event.js +20 -33
  58. package/testutils/fake_data/fake_user.d.ts +3 -7
  59. package/testutils/fake_data/fake_user.js +22 -36
  60. package/testutils/fake_data/test_helpers.js +1 -1
  61. package/testutils/fake_data/user_query.d.ts +2 -2
  62. package/tsc/ast.d.ts +20 -0
  63. package/tsc/ast.js +131 -0
  64. package/tsc/compilerOptions.d.ts +7 -0
  65. package/tsc/compilerOptions.js +95 -0
@@ -110,7 +110,7 @@ function sharedAssocTests() {
110
110
  name: "User",
111
111
  fields: {
112
112
  id: {
113
- type: (0, graphql_1.GraphQLNonNull)(graphql_1.GraphQLID),
113
+ type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
114
114
  },
115
115
  firstName: {
116
116
  type: graphql_1.GraphQLString,
@@ -128,7 +128,7 @@ function sharedAssocTests() {
128
128
  name: "Event",
129
129
  fields: {
130
130
  id: {
131
- type: (0, graphql_1.GraphQLNonNull)(graphql_1.GraphQLID),
131
+ type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID),
132
132
  },
133
133
  },
134
134
  interfaces: [node_1.GraphQLNodeInterface],
@@ -1,2 +1,2 @@
1
1
  import { GraphQLScalarType } from "graphql";
2
- export declare const GraphQLTime: GraphQLScalarType;
2
+ export declare const GraphQLTime: GraphQLScalarType<Date, string>;
@@ -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.0.40-alpha6",
3
+ "version": "0.1.0-alpha10",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "peerDependencies": {
33
33
  "better-sqlite3": "^7.4.1",
34
- "graphql": "^15.5"
34
+ "graphql": "^16.5.0"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "better-sqlite3": {
@@ -1,5 +1,5 @@
1
1
  import { Schema, Field, AssocEdge, AssocEdgeGroup, Action } from "../schema";
2
- import { ActionField } from "../schema/schema";
2
+ import { ActionField, Type } from "../schema/schema";
3
3
  declare enum NullableResult {
4
4
  CONTENTS = "contents",
5
5
  CONTENTS_AND_LIST = "contentsAndList",
@@ -23,6 +23,7 @@ declare type ProcessedSchema = Omit<Schema, "edges" | "actions" | "edgeGroups" |
23
23
  assocEdges: ProcessedAssocEdge[];
24
24
  assocEdgeGroups: ProcessedAssocEdgeGroup[];
25
25
  fields: ProcessedField[];
26
+ schemaPath?: string;
26
27
  };
27
28
  declare type ProcessedAssocEdgeGroup = Omit<AssocEdgeGroup, "edgeAction"> & {
28
29
  edgeAction?: OutputAction;
@@ -38,11 +39,19 @@ interface ProcessedPattern {
38
39
  assocEdges: ProcessedAssocEdge[];
39
40
  fields: ProcessedField[];
40
41
  }
41
- declare type ProcessedField = Omit<Field, "defaultValueOnEdit" | "defaultValueOnCreate" | "privacyPolicy"> & {
42
+ declare type ProcessedType = Omit<Type, "subFields" | "listElemType" | "unionFields"> & {
43
+ subFields?: ProcessedField[];
44
+ listElemType?: ProcessedType;
45
+ unionFields?: ProcessedField[];
46
+ };
47
+ declare type ProcessedField = Omit<Field, "defaultValueOnEdit" | "defaultValueOnCreate" | "privacyPolicy" | "type"> & {
48
+ name: string;
42
49
  hasDefaultValueOnCreate?: boolean;
43
50
  hasDefaultValueOnEdit?: boolean;
44
51
  patternName?: string;
45
52
  hasFieldPrivacy?: boolean;
53
+ derivedFields?: ProcessedField[];
54
+ type: ProcessedType;
46
55
  };
47
56
  interface patternsDict {
48
57
  [key: string]: ProcessedPattern;
@@ -51,5 +60,8 @@ interface Result {
51
60
  schemas: schemasDict;
52
61
  patterns: patternsDict;
53
62
  }
54
- export declare function parseSchema(potentialSchemas: {}): Result;
63
+ declare type PotentialSchemas = {
64
+ [key: string]: any;
65
+ };
66
+ export declare function parseSchema(potentialSchemas: PotentialSchemas): Result;
55
67
  export {};
@@ -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
  f.hasFieldPrivacy = field.privacyPolicy !== undefined;
@@ -33,6 +48,21 @@ function processFields(src, patternName) {
33
48
  f.patternName = patternName;
34
49
  }
35
50
  transformType(field.type);
51
+ if (field.getDerivedFields) {
52
+ f.derivedFields = processFields(field.getDerivedFields(name));
53
+ }
54
+ if (field.type.subFields) {
55
+ f.type.subFields = processFields(field.type.subFields);
56
+ }
57
+ if (field.type.unionFields) {
58
+ f.type.unionFields = processFields(field.type.unionFields);
59
+ }
60
+ if (field.type.listElemType &&
61
+ field.type.listElemType.subFields &&
62
+ // check to avoid ts-ignore below. exists just for tsc
63
+ f.type.listElemType) {
64
+ f.type.listElemType.subFields = processFields(field.type.listElemType.subFields);
65
+ }
36
66
  ret.push(f);
37
67
  }
38
68
  return ret;
@@ -147,14 +177,19 @@ function parseSchema(potentialSchemas) {
147
177
  for (const key in potentialSchemas) {
148
178
  const value = potentialSchemas[key];
149
179
  let schema;
150
- if (value.constructor == Object) {
151
- schema = value;
152
- }
153
- else {
154
- schema = new value();
180
+ const name = value.constructor.name;
181
+ // named class e.g. new BaseEntSchema
182
+ switch (name) {
183
+ case "Function":
184
+ schema = new value();
185
+ break;
186
+ default:
187
+ // implicit schema or named class
188
+ schema = value;
155
189
  }
156
190
  let processedSchema = {
157
191
  fields: [],
192
+ schemaPath: schema.schemaPath,
158
193
  tableName: schema.tableName,
159
194
  enumTable: schema.enumTable,
160
195
  dbRows: schema.dbRows,
@@ -1,6 +1,41 @@
1
- import { Pattern } from "./schema";
1
+ import { Field, FieldMap, Pattern } from "./schema";
2
+ import { Action, AssocEdgeGroup, Constraint, Edge, Index, Schema } from ".";
2
3
  export declare const Timestamps: Pattern;
3
4
  export declare const Node: Pattern;
5
+ export interface SchemaConfig extends Schema {
6
+ }
7
+ export declare class EntSchema implements Schema {
8
+ fields: FieldMap | Field[];
9
+ tableName: string | undefined;
10
+ patterns: Pattern[];
11
+ edges: Edge[] | undefined;
12
+ edgeGroups: AssocEdgeGroup[] | undefined;
13
+ actions: Action[] | undefined;
14
+ enumTable: boolean | undefined;
15
+ dbRows: {
16
+ [key: string]: any;
17
+ }[] | undefined;
18
+ constraints: Constraint[] | undefined;
19
+ indices: Index[] | undefined;
20
+ hideFromGraphQL?: boolean;
21
+ constructor(cfg: SchemaConfig);
22
+ }
23
+ export declare class EntSchemaWithTZ implements Schema {
24
+ fields: FieldMap | Field[];
25
+ tableName: string | undefined;
26
+ patterns: Pattern[];
27
+ edges: Edge[] | undefined;
28
+ edgeGroups: AssocEdgeGroup[] | undefined;
29
+ actions: Action[] | undefined;
30
+ enumTable: boolean | undefined;
31
+ dbRows: {
32
+ [key: string]: any;
33
+ }[] | undefined;
34
+ constraints: Constraint[] | undefined;
35
+ indices: Index[] | undefined;
36
+ hideFromGraphQL?: boolean;
37
+ constructor(cfg: SchemaConfig);
38
+ }
4
39
  export declare abstract class BaseEntSchema {
5
40
  addPatterns(...patterns: Pattern[]): void;
6
41
  patterns: Pattern[];
@@ -1,19 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseEntSchemaWithTZ = exports.BaseEntSchema = exports.Node = exports.Timestamps = void 0;
3
+ exports.BaseEntSchemaWithTZ = exports.BaseEntSchema = exports.EntSchemaWithTZ = exports.EntSchema = 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,14 +61,59 @@ 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",
68
68
  fields: nodeFields,
69
69
  };
70
- // Base ent schema. has Node Pattern by default.
70
+ // Ent schema. has Node Pattern by default.
71
71
  // exists just to have less typing and easier for clients to implement
72
+ class EntSchema {
73
+ constructor(cfg) {
74
+ this.patterns = [exports.Node];
75
+ this.fields = cfg.fields;
76
+ this.tableName = cfg.tableName;
77
+ if (cfg.patterns) {
78
+ this.patterns.push(...cfg.patterns);
79
+ }
80
+ this.edges = cfg.edges;
81
+ this.edgeGroups = cfg.edgeGroups;
82
+ this.actions = cfg.actions;
83
+ this.enumTable = cfg.enumTable;
84
+ this.dbRows = cfg.dbRows;
85
+ this.constraints = cfg.constraints;
86
+ this.indices = cfg.indices;
87
+ this.hideFromGraphQL = cfg.hideFromGraphQL;
88
+ }
89
+ }
90
+ exports.EntSchema = EntSchema;
91
+ class EntSchemaWithTZ {
92
+ constructor(cfg) {
93
+ this.patterns = [
94
+ {
95
+ // default schema added
96
+ name: "nodeWithTZ",
97
+ fields: nodeFieldsWithTZ,
98
+ },
99
+ ];
100
+ this.fields = cfg.fields;
101
+ this.tableName = cfg.tableName;
102
+ if (cfg.patterns) {
103
+ this.patterns.push(...cfg.patterns);
104
+ }
105
+ this.edges = cfg.edges;
106
+ this.edgeGroups = cfg.edgeGroups;
107
+ this.actions = cfg.actions;
108
+ this.enumTable = cfg.enumTable;
109
+ this.dbRows = cfg.dbRows;
110
+ this.constraints = cfg.constraints;
111
+ this.indices = cfg.indices;
112
+ this.hideFromGraphQL = cfg.hideFromGraphQL;
113
+ }
114
+ }
115
+ exports.EntSchemaWithTZ = EntSchemaWithTZ;
116
+ // @deprecated use EntSchema
72
117
  class BaseEntSchema {
73
118
  constructor() {
74
119
  this.patterns = [exports.Node];
@@ -78,6 +123,7 @@ class BaseEntSchema {
78
123
  }
79
124
  }
80
125
  exports.BaseEntSchema = BaseEntSchema;
126
+ // @deprecated use EntSchemaWithTZ
81
127
  class BaseEntSchemaWithTZ {
82
128
  constructor() {
83
129
  this.patterns = [
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 {};