@snowtop/ent 0.1.0-alpha16 → 0.1.0-alpha160-test2
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/action/action.d.ts +25 -14
- package/action/action.js +22 -7
- package/action/executor.d.ts +16 -3
- package/action/executor.js +89 -28
- package/action/experimental_action.d.ts +25 -16
- package/action/experimental_action.js +34 -14
- package/action/index.d.ts +4 -1
- package/action/index.js +7 -1
- package/action/operations.d.ts +126 -0
- package/action/operations.js +686 -0
- package/action/orchestrator.d.ts +43 -12
- package/action/orchestrator.js +461 -101
- package/action/relative_value.d.ts +47 -0
- package/action/relative_value.js +125 -0
- package/action/transaction.d.ts +10 -0
- package/action/transaction.js +23 -0
- package/auth/auth.d.ts +1 -1
- package/core/base.d.ts +56 -23
- package/core/base.js +7 -1
- package/core/clause.d.ts +103 -39
- package/core/clause.js +430 -66
- package/core/config.d.ts +13 -3
- package/core/config.js +10 -1
- package/core/const.d.ts +3 -0
- package/core/const.js +6 -0
- package/core/context.d.ts +6 -3
- package/core/context.js +22 -3
- package/core/convert.d.ts +1 -1
- package/core/date.js +1 -5
- package/core/db.d.ts +12 -8
- package/core/db.js +21 -9
- package/core/ent.d.ts +99 -95
- package/core/ent.js +550 -602
- package/core/global_schema.d.ts +7 -0
- package/core/global_schema.js +51 -0
- package/core/loaders/assoc_count_loader.d.ts +5 -2
- package/core/loaders/assoc_count_loader.js +19 -3
- package/core/loaders/assoc_edge_loader.d.ts +2 -3
- package/core/loaders/assoc_edge_loader.js +23 -17
- package/core/loaders/index.d.ts +1 -2
- package/core/loaders/index.js +1 -5
- package/core/loaders/loader.d.ts +3 -3
- package/core/loaders/loader.js +4 -21
- package/core/loaders/object_loader.d.ts +30 -9
- package/core/loaders/object_loader.js +226 -79
- package/core/loaders/query_loader.d.ts +7 -13
- package/core/loaders/query_loader.js +60 -24
- package/core/loaders/raw_count_loader.d.ts +1 -0
- package/core/loaders/raw_count_loader.js +8 -3
- package/core/logger.d.ts +1 -1
- package/core/logger.js +1 -0
- package/core/privacy.d.ts +26 -16
- package/core/privacy.js +68 -51
- package/core/query/assoc_query.d.ts +3 -2
- package/core/query/assoc_query.js +10 -2
- package/core/query/custom_clause_query.d.ts +29 -0
- package/core/query/custom_clause_query.js +105 -0
- package/core/query/custom_query.d.ts +19 -2
- package/core/query/custom_query.js +111 -13
- package/core/query/index.d.ts +1 -0
- package/core/query/index.js +3 -1
- package/core/query/query.d.ts +18 -4
- package/core/query/query.js +135 -58
- package/core/query/shared_assoc_test.d.ts +2 -1
- package/core/query/shared_assoc_test.js +186 -55
- package/core/query/shared_test.d.ts +9 -2
- package/core/query/shared_test.js +529 -236
- package/core/query_impl.d.ts +8 -0
- package/core/query_impl.js +28 -0
- package/core/viewer.d.ts +2 -0
- package/core/viewer.js +3 -1
- package/graphql/graphql.d.ts +108 -22
- package/graphql/graphql.js +183 -137
- package/graphql/graphql_field_helpers.d.ts +9 -3
- package/graphql/graphql_field_helpers.js +22 -2
- package/graphql/index.d.ts +2 -2
- package/graphql/index.js +5 -5
- package/graphql/query/connection_type.d.ts +9 -9
- package/graphql/query/shared_assoc_test.js +1 -1
- package/graphql/query/shared_edge_connection.js +1 -19
- package/graphql/scalars/orderby_direction.d.ts +2 -0
- package/graphql/scalars/orderby_direction.js +15 -0
- package/imports/dataz/example1/_auth.js +128 -47
- package/imports/dataz/example1/_viewer.js +87 -39
- package/imports/index.d.ts +7 -2
- package/imports/index.js +20 -5
- package/index.d.ts +23 -5
- package/index.js +35 -10
- package/package.json +20 -19
- package/parse_schema/parse.d.ts +33 -9
- package/parse_schema/parse.js +182 -33
- package/schema/base_schema.d.ts +13 -3
- package/schema/base_schema.js +13 -0
- package/schema/field.d.ts +78 -21
- package/schema/field.js +232 -72
- package/schema/index.d.ts +2 -2
- package/schema/index.js +7 -2
- package/schema/json_field.d.ts +16 -4
- package/schema/json_field.js +32 -2
- package/schema/schema.d.ts +109 -20
- package/schema/schema.js +42 -53
- package/schema/struct_field.d.ts +15 -3
- package/schema/struct_field.js +117 -22
- package/schema/union_field.d.ts +1 -1
- package/scripts/custom_compiler.js +12 -8
- package/scripts/custom_graphql.js +167 -64
- package/scripts/migrate_v0.1.js +36 -0
- package/scripts/move_types.js +120 -0
- package/scripts/read_schema.js +22 -7
- package/testutils/action/complex_schemas.d.ts +69 -0
- package/testutils/action/complex_schemas.js +405 -0
- package/testutils/builder.d.ts +37 -41
- package/testutils/builder.js +66 -46
- package/testutils/db/fixture.d.ts +10 -0
- package/testutils/db/fixture.js +26 -0
- package/testutils/db/{test_db.d.ts → temp_db.d.ts} +32 -8
- package/testutils/db/{test_db.js → temp_db.js} +251 -48
- package/testutils/db/value.d.ts +7 -0
- package/testutils/db/value.js +251 -0
- package/testutils/db_mock.d.ts +16 -4
- package/testutils/db_mock.js +52 -9
- package/testutils/db_time_zone.d.ts +4 -0
- package/testutils/db_time_zone.js +41 -0
- package/testutils/ent-graphql-tests/index.d.ts +7 -1
- package/testutils/ent-graphql-tests/index.js +56 -26
- package/testutils/fake_comms.js +1 -1
- package/testutils/fake_data/const.d.ts +2 -1
- package/testutils/fake_data/const.js +3 -0
- package/testutils/fake_data/fake_contact.d.ts +7 -3
- package/testutils/fake_data/fake_contact.js +13 -7
- package/testutils/fake_data/fake_event.d.ts +4 -1
- package/testutils/fake_data/fake_event.js +7 -6
- package/testutils/fake_data/fake_tag.d.ts +36 -0
- package/testutils/fake_data/fake_tag.js +89 -0
- package/testutils/fake_data/fake_user.d.ts +8 -5
- package/testutils/fake_data/fake_user.js +31 -19
- package/testutils/fake_data/index.js +5 -1
- package/testutils/fake_data/internal.d.ts +2 -0
- package/testutils/fake_data/internal.js +7 -1
- package/testutils/fake_data/tag_query.d.ts +13 -0
- package/testutils/fake_data/tag_query.js +48 -0
- package/testutils/fake_data/test_helpers.d.ts +14 -6
- package/testutils/fake_data/test_helpers.js +31 -15
- package/testutils/fake_data/user_query.d.ts +16 -6
- package/testutils/fake_data/user_query.js +72 -23
- package/testutils/fake_log.js +1 -1
- package/testutils/parse_sql.d.ts +6 -0
- package/testutils/parse_sql.js +16 -2
- package/testutils/test_edge_global_schema.d.ts +15 -0
- package/testutils/test_edge_global_schema.js +62 -0
- package/testutils/write.d.ts +2 -2
- package/testutils/write.js +33 -7
- package/tsc/ast.d.ts +15 -3
- package/tsc/ast.js +114 -23
- package/tsc/compilerOptions.js +5 -1
- package/tsc/move_generated.d.ts +1 -0
- package/tsc/move_generated.js +164 -0
- package/tsc/transform.d.ts +22 -0
- package/tsc/transform.js +182 -0
- package/tsc/transform_action.d.ts +22 -0
- package/tsc/transform_action.js +183 -0
- package/tsc/transform_ent.d.ts +17 -0
- package/tsc/transform_ent.js +60 -0
- package/tsc/transform_schema.d.ts +27 -0
- package/{scripts → tsc}/transform_schema.js +146 -117
- package/core/loaders/index_loader.d.ts +0 -14
- package/core/loaders/index_loader.js +0 -27
- package/graphql/enums.d.ts +0 -3
- package/graphql/enums.js +0 -25
- package/scripts/move_generated.js +0 -141
- package/scripts/transform_actions.js +0 -266
- package/scripts/transform_code.d.ts +0 -1
- package/scripts/transform_code.js +0 -111
- package/scripts/transform_schema.d.ts +0 -1
- /package/scripts/{move_generated.d.ts → migrate_v0.1.d.ts} +0 -0
- /package/scripts/{transform_actions.d.ts → move_types.d.ts} +0 -0
package/testutils/builder.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SimpleAction = exports.SimpleBuilder = exports.getFieldInfo = exports.getTableName = exports.getSchemaName = exports.getBuilderSchemaTZFromFields = exports.getBuilderSchemaFromFields = exports.getBuilderSchema = exports.Address = exports.Message = exports.Group = exports.Contact = exports.Event = exports.User = void 0;
|
|
6
|
+
exports.SimpleAction = exports.SimpleBuilder = exports.getFieldInfo = exports.getTableName = exports.getSchemaName = exports.getBuilderSchemaTZFromFields = exports.getBuilderSchemaFromFields = exports.getBuilderSchema = exports.EntBuilderSchema = exports.Address = exports.Message = exports.Group = exports.Contact = exports.Event = exports.User = exports.BaseEnt = void 0;
|
|
7
7
|
const privacy_1 = require("../core/privacy");
|
|
8
8
|
const orchestrator_1 = require("../action/orchestrator");
|
|
9
9
|
const action_1 = require("../action");
|
|
@@ -16,89 +16,89 @@ const convert_1 = require("../core/convert");
|
|
|
16
16
|
const camel_case_1 = require("camel-case");
|
|
17
17
|
const base_schema_1 = require("../schema/base_schema");
|
|
18
18
|
const schema_2 = require("../schema/schema");
|
|
19
|
-
class
|
|
19
|
+
class BaseEnt {
|
|
20
20
|
constructor(viewer, data) {
|
|
21
21
|
this.viewer = viewer;
|
|
22
22
|
this.data = data;
|
|
23
|
-
this.accountID = "";
|
|
24
|
-
this.nodeType = "User";
|
|
25
23
|
this.data.created_at = (0, convert_1.convertDate)(data.created_at);
|
|
26
24
|
this.data.updated_at = (0, convert_1.convertDate)(data.updated_at);
|
|
27
|
-
this.id = data.
|
|
28
|
-
|
|
25
|
+
this.id = data[this.getKey()];
|
|
26
|
+
}
|
|
27
|
+
getKey() {
|
|
28
|
+
return "id";
|
|
29
29
|
}
|
|
30
30
|
getPrivacyPolicy() {
|
|
31
31
|
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
32
32
|
}
|
|
33
|
+
__setRawDBData(data) {
|
|
34
|
+
// doesn't apply here so ignore...
|
|
35
|
+
}
|
|
33
36
|
}
|
|
34
|
-
exports.
|
|
35
|
-
class
|
|
37
|
+
exports.BaseEnt = BaseEnt;
|
|
38
|
+
class User extends BaseEnt {
|
|
36
39
|
constructor(viewer, data) {
|
|
40
|
+
super(viewer, data);
|
|
37
41
|
this.viewer = viewer;
|
|
38
42
|
this.data = data;
|
|
39
43
|
this.accountID = "";
|
|
40
|
-
this.nodeType = "
|
|
41
|
-
this.
|
|
44
|
+
this.nodeType = "User";
|
|
45
|
+
this.firstName = data.first_name;
|
|
42
46
|
}
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
}
|
|
48
|
+
exports.User = User;
|
|
49
|
+
class Event extends BaseEnt {
|
|
50
|
+
constructor() {
|
|
51
|
+
super(...arguments);
|
|
52
|
+
this.accountID = "";
|
|
53
|
+
this.nodeType = "Event";
|
|
45
54
|
}
|
|
46
55
|
}
|
|
47
56
|
exports.Event = Event;
|
|
48
|
-
class Contact {
|
|
49
|
-
constructor(
|
|
50
|
-
|
|
51
|
-
this.data = data;
|
|
57
|
+
class Contact extends BaseEnt {
|
|
58
|
+
constructor() {
|
|
59
|
+
super(...arguments);
|
|
52
60
|
this.accountID = "";
|
|
53
61
|
this.nodeType = "Contact";
|
|
54
|
-
this.data.created_at = (0, convert_1.convertDate)(data.created_at);
|
|
55
|
-
this.data.updated_at = (0, convert_1.convertDate)(data.updated_at);
|
|
56
|
-
this.id = data.id;
|
|
57
62
|
}
|
|
58
63
|
getPrivacyPolicy() {
|
|
59
64
|
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
67
|
exports.Contact = Contact;
|
|
63
|
-
class Group {
|
|
64
|
-
constructor(
|
|
65
|
-
|
|
66
|
-
this.data = data;
|
|
68
|
+
class Group extends BaseEnt {
|
|
69
|
+
constructor() {
|
|
70
|
+
super(...arguments);
|
|
67
71
|
this.accountID = "";
|
|
68
72
|
this.nodeType = "Group";
|
|
69
|
-
this.id = data.id;
|
|
70
73
|
}
|
|
71
74
|
getPrivacyPolicy() {
|
|
72
75
|
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
exports.Group = Group;
|
|
76
|
-
class Message {
|
|
77
|
-
constructor(
|
|
78
|
-
|
|
79
|
-
this.data = data;
|
|
79
|
+
class Message extends BaseEnt {
|
|
80
|
+
constructor() {
|
|
81
|
+
super(...arguments);
|
|
80
82
|
this.accountID = "";
|
|
81
83
|
this.nodeType = "Message";
|
|
82
|
-
this.id = data.id;
|
|
83
|
-
}
|
|
84
|
-
getPrivacyPolicy() {
|
|
85
|
-
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
exports.Message = Message;
|
|
89
|
-
class Address {
|
|
90
|
-
constructor(
|
|
91
|
-
|
|
92
|
-
this.data = data;
|
|
87
|
+
class Address extends BaseEnt {
|
|
88
|
+
constructor() {
|
|
89
|
+
super(...arguments);
|
|
93
90
|
this.accountID = "";
|
|
94
91
|
this.nodeType = "Address";
|
|
95
|
-
this.id = data.id;
|
|
96
|
-
}
|
|
97
|
-
getPrivacyPolicy() {
|
|
98
|
-
return privacy_1.AlwaysAllowPrivacyPolicy;
|
|
99
92
|
}
|
|
100
93
|
}
|
|
101
94
|
exports.Address = Address;
|
|
95
|
+
class EntBuilderSchema extends base_schema_1.EntSchema {
|
|
96
|
+
constructor(ent, cfg) {
|
|
97
|
+
super(cfg);
|
|
98
|
+
this.ent = ent;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.EntBuilderSchema = EntBuilderSchema;
|
|
102
102
|
function getBuilderSchema(cfg, ent) {
|
|
103
103
|
return {
|
|
104
104
|
...new base_schema_1.EntSchema(cfg),
|
|
@@ -106,9 +106,9 @@ function getBuilderSchema(cfg, ent) {
|
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
exports.getBuilderSchema = getBuilderSchema;
|
|
109
|
-
function getBuilderSchemaFromFields(fields, ent) {
|
|
109
|
+
function getBuilderSchemaFromFields(fields, ent, opts) {
|
|
110
110
|
return {
|
|
111
|
-
...new base_schema_1.EntSchema({ fields }),
|
|
111
|
+
...new base_schema_1.EntSchema({ ...opts, fields }),
|
|
112
112
|
ent,
|
|
113
113
|
};
|
|
114
114
|
}
|
|
@@ -137,7 +137,8 @@ function getFieldInfo(value) {
|
|
|
137
137
|
for (const [k, f] of fields) {
|
|
138
138
|
ret[k] = {
|
|
139
139
|
dbCol: (0, schema_2.getStorageKey)(f, k),
|
|
140
|
-
|
|
140
|
+
// in tests (anything using SimpleBuilder), make it be the same as the fieldName
|
|
141
|
+
inputKey: k,
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
144
|
return ret;
|
|
@@ -145,11 +146,12 @@ function getFieldInfo(value) {
|
|
|
145
146
|
exports.getFieldInfo = getFieldInfo;
|
|
146
147
|
// reuses orchestrator and standard things
|
|
147
148
|
class SimpleBuilder {
|
|
148
|
-
constructor(viewer, schema, fields, operation = action_1.WriteOperation.Insert, existingEnt, action) {
|
|
149
|
+
constructor(viewer, schema, fields, operation = action_1.WriteOperation.Insert, existingEnt, action, expressions) {
|
|
149
150
|
this.viewer = viewer;
|
|
150
151
|
this.schema = schema;
|
|
151
152
|
this.operation = operation;
|
|
152
153
|
this.existingEnt = existingEnt;
|
|
154
|
+
this.m = new Map();
|
|
153
155
|
// create dynamic placeholder
|
|
154
156
|
// TODO: do we need to use this as the node when there's an existingEnt
|
|
155
157
|
// same for generated builders.
|
|
@@ -195,6 +197,7 @@ class SimpleBuilder {
|
|
|
195
197
|
},
|
|
196
198
|
builder: this,
|
|
197
199
|
action: action,
|
|
200
|
+
expressions,
|
|
198
201
|
schema: this.schema,
|
|
199
202
|
editedFields: () => {
|
|
200
203
|
// to simulate what we do in generated builders where we return a new Map
|
|
@@ -230,9 +233,20 @@ class SimpleBuilder {
|
|
|
230
233
|
}
|
|
231
234
|
}
|
|
232
235
|
}
|
|
236
|
+
// store data in Builder that can be retrieved by another validator, trigger, observer later in the action
|
|
237
|
+
storeData(k, v) {
|
|
238
|
+
this.m.set(k, v);
|
|
239
|
+
}
|
|
240
|
+
// retrieve data stored in this Builder with key
|
|
241
|
+
getStoredData(k) {
|
|
242
|
+
return this.m.get(k);
|
|
243
|
+
}
|
|
233
244
|
build() {
|
|
234
245
|
return this.orchestrator.build();
|
|
235
246
|
}
|
|
247
|
+
buildWithOptions_BETA(options) {
|
|
248
|
+
return this.orchestrator.buildWithOptions_BETA(options);
|
|
249
|
+
}
|
|
236
250
|
async editedEnt() {
|
|
237
251
|
return await this.orchestrator.editedEnt();
|
|
238
252
|
}
|
|
@@ -254,10 +268,10 @@ class SimpleBuilder {
|
|
|
254
268
|
}
|
|
255
269
|
exports.SimpleBuilder = SimpleBuilder;
|
|
256
270
|
class SimpleAction {
|
|
257
|
-
constructor(viewer, schema, fields, operation = action_1.WriteOperation.Insert, existingEnt) {
|
|
271
|
+
constructor(viewer, schema, fields, operation = action_1.WriteOperation.Insert, existingEnt, expressions) {
|
|
258
272
|
this.viewer = viewer;
|
|
259
273
|
this.fields = fields;
|
|
260
|
-
this.builder = new SimpleBuilder(this.viewer, schema, fields, operation, existingEnt, this);
|
|
274
|
+
this.builder = new SimpleBuilder(this.viewer, schema, fields, operation, existingEnt, this, expressions);
|
|
261
275
|
}
|
|
262
276
|
getTriggers() {
|
|
263
277
|
return [];
|
|
@@ -281,12 +295,18 @@ class SimpleAction {
|
|
|
281
295
|
changeset() {
|
|
282
296
|
return this.builder.build();
|
|
283
297
|
}
|
|
298
|
+
changesetWithOptions_BETA(options) {
|
|
299
|
+
return this.builder.buildWithOptions_BETA(options);
|
|
300
|
+
}
|
|
284
301
|
valid() {
|
|
285
302
|
return this.builder.orchestrator.valid();
|
|
286
303
|
}
|
|
287
304
|
validX() {
|
|
288
305
|
return this.builder.orchestrator.validX();
|
|
289
306
|
}
|
|
307
|
+
validWithErrors() {
|
|
308
|
+
return this.builder.orchestrator.validWithErrors();
|
|
309
|
+
}
|
|
290
310
|
async save() {
|
|
291
311
|
await (0, action_1.saveBuilder)(this.builder);
|
|
292
312
|
if (this.builder.operation !== action_1.WriteOperation.Delete) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Client } from "pg";
|
|
2
|
+
import { Data } from "../../core/base";
|
|
3
|
+
import { Schema } from "../../schema";
|
|
4
|
+
interface Options {
|
|
5
|
+
overrides?: Data;
|
|
6
|
+
client: Client;
|
|
7
|
+
tableName: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function writeFixture(schema: Schema, opts: Options): Promise<void>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeFixture = void 0;
|
|
4
|
+
const schema_1 = require("../../schema");
|
|
5
|
+
const value_1 = require("./value");
|
|
6
|
+
const ent_1 = require("../../core/ent");
|
|
7
|
+
async function writeFixture(schema, opts) {
|
|
8
|
+
const fields = (0, schema_1.getFields)(schema);
|
|
9
|
+
const d = {};
|
|
10
|
+
for (const [fieldName, field] of fields) {
|
|
11
|
+
const col = (0, schema_1.getStorageKey)(field, fieldName);
|
|
12
|
+
const val = (0, value_1.getDefaultValue)(field, col);
|
|
13
|
+
d[col] = val;
|
|
14
|
+
}
|
|
15
|
+
if (opts.overrides) {
|
|
16
|
+
for (const k in opts.overrides) {
|
|
17
|
+
d[k] = opts.overrides[k];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const q = (0, ent_1.buildInsertQuery)({
|
|
21
|
+
tableName: opts.tableName,
|
|
22
|
+
fields: d,
|
|
23
|
+
});
|
|
24
|
+
await opts.client.query(q[0], q[1]);
|
|
25
|
+
}
|
|
26
|
+
exports.writeFixture = writeFixture;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Client as PGClient } from "pg";
|
|
2
2
|
import { Dialect } from "../../core/db";
|
|
3
3
|
import { Database as SqliteDatabase } from "better-sqlite3";
|
|
4
|
+
import { Field } from "../../schema";
|
|
4
5
|
import { BuilderSchema } from "../builder";
|
|
5
6
|
import { Ent } from "../../core/base";
|
|
6
7
|
interface SchemaItem {
|
|
@@ -12,6 +13,7 @@ interface Column extends SchemaItem {
|
|
|
12
13
|
primaryKey?: boolean;
|
|
13
14
|
unique?: boolean;
|
|
14
15
|
default?: string;
|
|
16
|
+
index?: boolean | indexOptions;
|
|
15
17
|
foreignKey?: {
|
|
16
18
|
table: string;
|
|
17
19
|
col: string;
|
|
@@ -19,23 +21,34 @@ interface Column extends SchemaItem {
|
|
|
19
21
|
}
|
|
20
22
|
interface Constraint extends SchemaItem {
|
|
21
23
|
generate(): string;
|
|
24
|
+
postCreate?(): boolean;
|
|
25
|
+
}
|
|
26
|
+
interface Index extends SchemaItem {
|
|
27
|
+
generate(): string;
|
|
28
|
+
postCreate?(): boolean;
|
|
22
29
|
}
|
|
23
30
|
export interface CoreConcept {
|
|
24
31
|
name: string;
|
|
25
32
|
create(): string;
|
|
33
|
+
postCreate?(): string[];
|
|
26
34
|
drop(): string;
|
|
27
35
|
}
|
|
28
36
|
export interface Table extends CoreConcept {
|
|
29
37
|
columns: Column[];
|
|
30
38
|
constraints?: Constraint[];
|
|
31
39
|
}
|
|
32
|
-
|
|
40
|
+
type options = Pick<Column, "nullable" | "primaryKey" | "default" | "foreignKey" | "unique" | "index">;
|
|
33
41
|
export declare function primaryKey(name: string, cols: string[]): Constraint;
|
|
34
42
|
export declare function foreignKey(name: string, cols: string[], fkey: {
|
|
35
43
|
table: string;
|
|
36
44
|
cols: string[];
|
|
37
45
|
}): Constraint;
|
|
38
|
-
export declare function
|
|
46
|
+
export declare function check(name: string, condition: string): Constraint;
|
|
47
|
+
interface indexOptions {
|
|
48
|
+
type?: string;
|
|
49
|
+
unique?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export declare function index(tableName: string, cols: string[], opts?: indexOptions): Index;
|
|
39
52
|
export declare function uuid(name: string, opts?: options): Column;
|
|
40
53
|
export declare function text(name: string, opts?: options): Column;
|
|
41
54
|
export declare function enumCol(name: string, type: string): Column;
|
|
@@ -60,6 +73,11 @@ export declare function dateList(name: string, opts?: options): Column;
|
|
|
60
73
|
export declare function boolList(name: string, opts?: options): Column;
|
|
61
74
|
export declare function table(name: string, ...items: SchemaItem[]): Table;
|
|
62
75
|
export declare function enumType(name: string, values: string[]): CoreConcept;
|
|
76
|
+
interface TempDBOptions {
|
|
77
|
+
dialect: Dialect;
|
|
78
|
+
sqliteConnString?: string;
|
|
79
|
+
tables?: CoreConcept[] | (() => CoreConcept[]);
|
|
80
|
+
}
|
|
63
81
|
export declare class TempDB {
|
|
64
82
|
private db;
|
|
65
83
|
private client;
|
|
@@ -67,11 +85,14 @@ export declare class TempDB {
|
|
|
67
85
|
private tables;
|
|
68
86
|
private dialect;
|
|
69
87
|
private sqlite;
|
|
70
|
-
|
|
71
|
-
|
|
88
|
+
private setTables;
|
|
89
|
+
private sqliteConnString;
|
|
90
|
+
constructor(dialect: Dialect, tables?: CoreConcept[] | (() => CoreConcept[]));
|
|
91
|
+
constructor(opts: TempDBOptions);
|
|
72
92
|
getDialect(): Dialect;
|
|
73
|
-
|
|
93
|
+
__getTables(): Map<string, CoreConcept>;
|
|
74
94
|
beforeAll(setupConnString?: boolean): Promise<void>;
|
|
95
|
+
createImpl(table: CoreConcept): Promise<void>;
|
|
75
96
|
getSqliteClient(): SqliteDatabase;
|
|
76
97
|
getPostgresClient(): PGClient;
|
|
77
98
|
afterAll(): Promise<void>;
|
|
@@ -81,10 +102,13 @@ export declare class TempDB {
|
|
|
81
102
|
create(...tables: CoreConcept[]): Promise<void>;
|
|
82
103
|
}
|
|
83
104
|
export declare function assoc_edge_config_table(): Table;
|
|
84
|
-
export declare function assoc_edge_table(name: string): Table;
|
|
85
|
-
interface
|
|
105
|
+
export declare function assoc_edge_table(name: string, global?: boolean, unique_edge?: boolean): Table;
|
|
106
|
+
interface setupOptions {
|
|
86
107
|
disableDeleteAfterEachTest?: boolean;
|
|
87
108
|
}
|
|
88
|
-
export declare function setupSqlite(connString: string, tables: () => Table[], opts?:
|
|
109
|
+
export declare function setupSqlite(connString: string, tables: () => Table[], opts?: setupOptions): TempDB;
|
|
110
|
+
export declare function setupPostgres(tables: () => Table[], opts?: setupOptions): void;
|
|
111
|
+
export declare function doSQLiteTestFromSchemas(schemas: BuilderSchema<Ent>[], doTest: () => Promise<void>, db?: string): Promise<TempDB>;
|
|
89
112
|
export declare function getSchemaTable(schema: BuilderSchema<Ent>, dialect: Dialect): Table;
|
|
113
|
+
export declare function getColumnFromField(fieldName: string, f: Field, dialect: Dialect): Column;
|
|
90
114
|
export {};
|