@snowtop/ent 0.2.4 → 0.2.6
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.js +5 -5
- package/action/executor.d.ts +1 -1
- package/action/executor.js +4 -4
- package/action/experimental_action.d.ts +7 -4
- package/action/experimental_action.js +18 -8
- package/action/operations.js +17 -7
- package/action/orchestrator.d.ts +10 -2
- package/action/orchestrator.js +29 -31
- package/action/privacy.d.ts +2 -2
- package/action/relative_value.js +3 -3
- package/auth/auth.d.ts +0 -1
- package/auth/auth.js +4 -5
- package/core/base.js +5 -5
- package/core/clause.js +76 -67
- package/core/config.d.ts +1 -1
- package/core/config.js +22 -9
- package/core/context.d.ts +0 -1
- package/core/convert.d.ts +0 -1
- package/core/convert.js +16 -17
- package/core/date.js +1 -2
- package/core/db.js +17 -7
- package/core/ent.d.ts +2 -0
- package/core/ent.js +127 -92
- package/core/global_schema.js +6 -7
- package/core/loaders/assoc_count_loader.d.ts +2 -2
- package/core/loaders/assoc_count_loader.js +17 -7
- package/core/loaders/assoc_edge_loader.d.ts +2 -2
- package/core/loaders/assoc_edge_loader.js +44 -20
- package/core/loaders/cache_utils.d.ts +1 -0
- package/core/loaders/cache_utils.js +28 -0
- package/core/loaders/index.d.ts +1 -0
- package/core/loaders/index.js +4 -1
- package/core/loaders/loader.d.ts +2 -0
- package/core/loaders/loader.js +20 -3
- package/core/loaders/object_loader.d.ts +6 -4
- package/core/loaders/object_loader.js +86 -48
- package/core/loaders/query_loader.d.ts +2 -2
- package/core/loaders/query_loader.js +25 -9
- package/core/loaders/raw_count_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.js +22 -10
- package/core/logger.js +6 -7
- package/core/privacy.d.ts +2 -2
- package/core/privacy.js +4 -5
- package/core/query/assoc_query.js +17 -7
- package/core/query/query.js +17 -7
- package/core/query/shared_assoc_test.js +1 -2
- package/core/query_impl.js +4 -5
- package/core/viewer.d.ts +2 -2
- package/graphql/graphql_field_helpers.js +22 -22
- package/graphql/mutations/union.js +1 -2
- package/graphql/node_resolver.js +7 -7
- package/graphql/query/shared_assoc_test.js +1 -2
- package/graphql/scalars/date.js +8 -3
- package/graphql/scalars/time.d.ts +1 -1
- package/imports/dataz/example1/_auth.js +14 -10
- package/imports/index.js +18 -9
- package/index.js +17 -7
- package/names/names.js +61 -18
- package/package.json +14 -17
- package/parse_schema/parse.js +2 -3
- package/schema/binary_field.js +3 -3
- package/schema/field.js +45 -35
- package/schema/json_field.js +7 -7
- package/schema/schema.js +12 -12
- package/schema/struct_field.js +4 -4
- package/schema/union_field.js +3 -3
- package/scripts/custom_compiler.js +17 -7
- package/scripts/custom_graphql.js +17 -7
- package/scripts/fix_action_exports.js +17 -7
- package/scripts/move_types.js +17 -7
- package/scripts/read_schema.js +17 -7
- package/testutils/action/complex_schemas.js +28 -18
- package/testutils/builder.d.ts +1 -1
- package/testutils/builder.js +7 -7
- package/testutils/db/fixture.js +1 -2
- package/testutils/db/temp_db.js +54 -44
- package/testutils/db/value.js +3 -4
- package/testutils/db_mock.js +12 -0
- package/testutils/ent-graphql-tests/index.d.ts +3 -3
- package/testutils/ent-graphql-tests/index.js +27 -18
- package/testutils/fake_data/const.js +2 -2
- package/testutils/fake_data/fake_contact.js +20 -10
- package/testutils/fake_data/fake_event.js +20 -10
- package/testutils/fake_data/fake_tag.js +21 -11
- package/testutils/fake_data/fake_user.js +21 -11
- package/testutils/fake_data/test_helpers.js +17 -17
- package/testutils/fake_data/user_query.js +19 -9
- package/testutils/parse_sql.js +151 -43
- package/testutils/query.js +2 -3
- package/testutils/soft_delete.js +17 -7
- package/testutils/test_edge_global_schema.js +17 -7
- package/testutils/write.js +20 -11
- package/tsc/ast.js +27 -18
- package/tsc/compilerOptions.js +22 -13
- package/tsc/move_generated.js +18 -9
- package/tsc/transform.js +18 -9
- package/tsc/transform_action.js +17 -7
- package/tsc/transform_schema.js +17 -7
package/testutils/db/value.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.randomEmail = randomEmail;
|
|
4
|
+
exports.randomPhoneNumber = randomPhoneNumber;
|
|
5
|
+
exports.getDefaultValue = getDefaultValue;
|
|
4
6
|
const uuid_1 = require("uuid");
|
|
5
7
|
const schema_1 = require("../../schema");
|
|
6
8
|
const schema_2 = require("../../schema");
|
|
@@ -12,7 +14,6 @@ function randomEmail(domain) {
|
|
|
12
14
|
domain = domain || "email.com";
|
|
13
15
|
return `test+${random()}@${domain}`;
|
|
14
16
|
}
|
|
15
|
-
exports.randomEmail = randomEmail;
|
|
16
17
|
function randomPhoneNumber() {
|
|
17
18
|
// generate 12 digits from random bytes so we can safely carve out a NANP number
|
|
18
19
|
const raw = (0, crypto_1.randomBytes)(5).readUIntBE(0, 5).toString().padStart(12, "0");
|
|
@@ -21,7 +22,6 @@ function randomPhoneNumber() {
|
|
|
21
22
|
const localNumber = raw.slice(3, 10);
|
|
22
23
|
return `+1${areaCode}${localNumber}`;
|
|
23
24
|
}
|
|
24
|
-
exports.randomPhoneNumber = randomPhoneNumber;
|
|
25
25
|
function coinFlip() {
|
|
26
26
|
return Math.floor(Math.random() * 10) >= 5;
|
|
27
27
|
}
|
|
@@ -60,7 +60,6 @@ function getDefaultValue(f, col, infos) {
|
|
|
60
60
|
}
|
|
61
61
|
return getValueForType(f.type, f, infos);
|
|
62
62
|
}
|
|
63
|
-
exports.getDefaultValue = getDefaultValue;
|
|
64
63
|
function getValueForType(typ, f, infos) {
|
|
65
64
|
switch (typ.dbType) {
|
|
66
65
|
case schema_1.DBType.UUID:
|
package/testutils/db_mock.js
CHANGED
|
@@ -236,10 +236,22 @@ class QueryRecorder {
|
|
|
236
236
|
totalCount: 1,
|
|
237
237
|
idleCount: 1,
|
|
238
238
|
waitingCount: 1,
|
|
239
|
+
expiredCount: 0,
|
|
240
|
+
ending: false,
|
|
241
|
+
ended: false,
|
|
242
|
+
options: {
|
|
243
|
+
max: 0,
|
|
244
|
+
maxUses: 0,
|
|
245
|
+
allowExitOnIdle: false,
|
|
246
|
+
maxLifetimeSeconds: 0,
|
|
247
|
+
idleTimeoutMillis: 0,
|
|
248
|
+
},
|
|
239
249
|
connect: async () => {
|
|
240
250
|
return {
|
|
241
251
|
connect: jest.fn(),
|
|
242
252
|
release: jest.fn(),
|
|
253
|
+
setTypeParser: jest.fn(),
|
|
254
|
+
getTypeParser: jest.fn(),
|
|
243
255
|
query: jest
|
|
244
256
|
.fn()
|
|
245
257
|
.mockImplementation((query, values) => {
|
|
@@ -6,7 +6,7 @@ export type Option = [string, any] | [string, any, string];
|
|
|
6
6
|
interface queryConfig {
|
|
7
7
|
viewer?: Viewer;
|
|
8
8
|
init?: (app: Express) => void;
|
|
9
|
-
test?: supertest.
|
|
9
|
+
test?: supertest.Agent | ((express: Express) => supertest.Agent);
|
|
10
10
|
schema: GraphQLSchema;
|
|
11
11
|
headers?: object;
|
|
12
12
|
debugMode?: boolean;
|
|
@@ -31,11 +31,11 @@ export interface queryRootConfig extends queryConfig {
|
|
|
31
31
|
nullQueryPaths?: string[];
|
|
32
32
|
undefinedQueryPaths?: string[];
|
|
33
33
|
}
|
|
34
|
-
export declare function expectQueryFromRoot(config: queryRootConfig, ...options: Option[]): Promise<supertest.
|
|
34
|
+
export declare function expectQueryFromRoot(config: queryRootConfig, ...options: Option[]): Promise<supertest.Agent>;
|
|
35
35
|
export interface mutationRootConfig extends queryConfig {
|
|
36
36
|
mutation: string;
|
|
37
37
|
disableInputWrapping?: boolean;
|
|
38
38
|
nullQueryPaths?: string[];
|
|
39
39
|
}
|
|
40
|
-
export declare function expectMutation(config: mutationRootConfig, ...options: Option[]): Promise<supertest.
|
|
40
|
+
export declare function expectMutation(config: mutationRootConfig, ...options: Option[]): Promise<supertest.Agent>;
|
|
41
41
|
export {};
|
|
@@ -15,18 +15,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
39
|
+
exports.expectQueryFromRoot = expectQueryFromRoot;
|
|
40
|
+
exports.expectMutation = expectMutation;
|
|
30
41
|
// NB: this is copied from ent-graphql-tests package until I have time to figure out how to share code here effectively
|
|
31
42
|
// the circular dependencies btw this package and ent-graphql-tests seems to imply something needs to change
|
|
32
43
|
const express_1 = __importDefault(require("express"));
|
|
@@ -82,17 +93,17 @@ function getInnerType(typ, list) {
|
|
|
82
93
|
return [typ, list];
|
|
83
94
|
}
|
|
84
95
|
function makeGraphQLRequest(config, query, fieldArgs) {
|
|
85
|
-
let
|
|
96
|
+
let agent;
|
|
86
97
|
if (config.test) {
|
|
87
98
|
if (typeof config.test === "function") {
|
|
88
|
-
|
|
99
|
+
agent = config.test(config.server ? config.server : server(config));
|
|
89
100
|
}
|
|
90
101
|
else {
|
|
91
|
-
|
|
102
|
+
agent = config.test;
|
|
92
103
|
}
|
|
93
104
|
}
|
|
94
105
|
else {
|
|
95
|
-
|
|
106
|
+
agent = (0, supertest_1.default)(config.server ? config.server : server(config));
|
|
96
107
|
}
|
|
97
108
|
let files = new Map();
|
|
98
109
|
// handle files
|
|
@@ -123,7 +134,7 @@ function makeGraphQLRequest(config, query, fieldArgs) {
|
|
|
123
134
|
variables[k] = config.extraVariables[k].value;
|
|
124
135
|
}
|
|
125
136
|
if (files.size) {
|
|
126
|
-
let ret =
|
|
137
|
+
let ret = agent
|
|
127
138
|
.post(config.graphQLPath || "/graphql")
|
|
128
139
|
.set((config.headers || {}));
|
|
129
140
|
ret.field("operations", JSON.stringify({
|
|
@@ -145,12 +156,12 @@ function makeGraphQLRequest(config, query, fieldArgs) {
|
|
|
145
156
|
ret.attach(`${idx}`, val, key);
|
|
146
157
|
idx++;
|
|
147
158
|
}
|
|
148
|
-
return [
|
|
159
|
+
return [agent, ret];
|
|
149
160
|
}
|
|
150
161
|
else {
|
|
151
162
|
return [
|
|
152
|
-
|
|
153
|
-
|
|
163
|
+
agent,
|
|
164
|
+
agent
|
|
154
165
|
.post(config.graphQLPath || "/graphql")
|
|
155
166
|
.set((config.headers || {}))
|
|
156
167
|
.send({
|
|
@@ -282,7 +293,6 @@ async function expectQueryFromRoot(config, ...options // TODO queries? expected
|
|
|
282
293
|
queryFN: config.schema.getQueryType(),
|
|
283
294
|
}, ...options);
|
|
284
295
|
}
|
|
285
|
-
exports.expectQueryFromRoot = expectQueryFromRoot;
|
|
286
296
|
async function expectMutation(config, ...options) {
|
|
287
297
|
// wrap args in input because we simplify the args for mutations
|
|
288
298
|
// and don't require the input
|
|
@@ -301,7 +311,6 @@ async function expectMutation(config, ...options) {
|
|
|
301
311
|
queryFN: config.schema.getMutationType(),
|
|
302
312
|
}, ...options);
|
|
303
313
|
}
|
|
304
|
-
exports.expectMutation = expectMutation;
|
|
305
314
|
const fragmentRegex = /^...on (\w+)(.*)/;
|
|
306
315
|
function splitPath(path) {
|
|
307
316
|
// handle fragment queries. we don't want to compare against this when checking the result
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.InverseEdges = exports.SymmetricEdges = exports.NodeType = exports.EdgeType = void 0;
|
|
4
|
+
exports.getLoaderOptions = getLoaderOptions;
|
|
4
5
|
const internal_1 = require("./internal");
|
|
5
6
|
var EdgeType;
|
|
6
7
|
(function (EdgeType) {
|
|
@@ -53,4 +54,3 @@ function getLoaderOptions(type) {
|
|
|
53
54
|
return internal_1.FakeTag.loaderOptions();
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
exports.getLoaderOptions = getLoaderOptions;
|
|
@@ -15,15 +15,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.contactLoader = exports.
|
|
36
|
+
exports.contactLoader = exports.FakeContactSchemaWithDeletedAt = exports.FakeContactSchema = exports.FakeContact = void 0;
|
|
37
|
+
exports.getContactBuilder = getContactBuilder;
|
|
38
|
+
exports.createContact = createContact;
|
|
27
39
|
const ent_1 = require("../../core/ent");
|
|
28
40
|
const clause = __importStar(require("../../core/clause"));
|
|
29
41
|
const privacy_1 = require("../../core/privacy");
|
|
@@ -153,12 +165,10 @@ function getContactBuilder(viewer, input) {
|
|
|
153
165
|
m.set("updatedAt", new Date());
|
|
154
166
|
return new builder_1.SimpleBuilder(viewer, exports.FakeContactSchema, m, action_1.WriteOperation.Insert, null);
|
|
155
167
|
}
|
|
156
|
-
exports.getContactBuilder = getContactBuilder;
|
|
157
168
|
async function createContact(viewer, input) {
|
|
158
169
|
const builder = getContactBuilder(viewer, input);
|
|
159
170
|
return builder.saveX();
|
|
160
171
|
}
|
|
161
|
-
exports.createContact = createContact;
|
|
162
172
|
exports.contactLoader = new loaders_1.ObjectLoaderFactory({
|
|
163
173
|
tableName: "fake_contacts",
|
|
164
174
|
fields: FakeContact.getFields(),
|
|
@@ -15,15 +15,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
36
|
+
exports.FakeEventSchema = exports.FakeEvent = void 0;
|
|
37
|
+
exports.getEventBuilder = getEventBuilder;
|
|
38
|
+
exports.createEvent = createEvent;
|
|
27
39
|
const ent_1 = require("../../core/ent");
|
|
28
40
|
const clause = __importStar(require("../../core/clause"));
|
|
29
41
|
const privacy_1 = require("../../core/privacy");
|
|
@@ -142,9 +154,7 @@ function getEventBuilder(viewer, input) {
|
|
|
142
154
|
}
|
|
143
155
|
return new builder_1.SimpleBuilder(viewer, exports.FakeEventSchema, m, action_1.WriteOperation.Insert, null);
|
|
144
156
|
}
|
|
145
|
-
exports.getEventBuilder = getEventBuilder;
|
|
146
157
|
async function createEvent(viewer, input) {
|
|
147
158
|
const builder = getEventBuilder(viewer, input);
|
|
148
159
|
return builder.saveX();
|
|
149
160
|
}
|
|
150
|
-
exports.createEvent = createEvent;
|
|
@@ -15,15 +15,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.tagLoaderWithDeletedAt = exports.tagLoader = exports.
|
|
36
|
+
exports.tagLoaderWithDeletedAt = exports.tagLoader = exports.FakeTagSchema = exports.FakeTag = void 0;
|
|
37
|
+
exports.getTagBuilder = getTagBuilder;
|
|
38
|
+
exports.getTagAction = getTagAction;
|
|
39
|
+
exports.createTag = createTag;
|
|
27
40
|
const ent_1 = require("../../core/ent");
|
|
28
41
|
const clause = __importStar(require("../../core/clause"));
|
|
29
42
|
const privacy_1 = require("../../core/privacy");
|
|
@@ -109,7 +122,6 @@ function getTagBuilder(viewer, input) {
|
|
|
109
122
|
const action = getTagAction(viewer, input);
|
|
110
123
|
return action.builder;
|
|
111
124
|
}
|
|
112
|
-
exports.getTagBuilder = getTagBuilder;
|
|
113
125
|
function getTagAction(viewer, input) {
|
|
114
126
|
const m = new Map();
|
|
115
127
|
for (const key in input) {
|
|
@@ -118,12 +130,10 @@ function getTagAction(viewer, input) {
|
|
|
118
130
|
const action = new builder_1.SimpleAction(viewer, exports.FakeTagSchema, m, action_1.WriteOperation.Insert, null);
|
|
119
131
|
return action;
|
|
120
132
|
}
|
|
121
|
-
exports.getTagAction = getTagAction;
|
|
122
133
|
async function createTag(viewer, input) {
|
|
123
134
|
const action = getTagAction(viewer, input);
|
|
124
135
|
return action.saveX();
|
|
125
136
|
}
|
|
126
|
-
exports.createTag = createTag;
|
|
127
137
|
exports.tagLoader = new loaders_1.ObjectLoaderFactory({
|
|
128
138
|
tableName: "fake_tags",
|
|
129
139
|
fields: FakeTag.getFields(),
|
|
@@ -15,15 +15,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.userPhoneNumberLoader = exports.userEmailLoader = exports.userLoaderWithDeletedAt = exports.userLoader = exports.
|
|
36
|
+
exports.userPhoneNumberLoader = exports.userEmailLoader = exports.userLoaderWithDeletedAt = exports.userLoader = exports.FakeUserSchema = exports.FakeUser = exports.ViewerWithAccessToken = void 0;
|
|
37
|
+
exports.getUserBuilder = getUserBuilder;
|
|
38
|
+
exports.getUserAction = getUserAction;
|
|
39
|
+
exports.createUser = createUser;
|
|
27
40
|
const base_1 = require("../../core/base");
|
|
28
41
|
const ent_1 = require("../../core/ent");
|
|
29
42
|
const clause = __importStar(require("../../core/clause"));
|
|
@@ -172,7 +185,6 @@ function getUserBuilder(viewer, input) {
|
|
|
172
185
|
const action = getUserAction(viewer, input);
|
|
173
186
|
return action.builder;
|
|
174
187
|
}
|
|
175
|
-
exports.getUserBuilder = getUserBuilder;
|
|
176
188
|
function getUserAction(viewer, input) {
|
|
177
189
|
const m = new Map();
|
|
178
190
|
for (const key in input) {
|
|
@@ -187,12 +199,10 @@ function getUserAction(viewer, input) {
|
|
|
187
199
|
};
|
|
188
200
|
return action;
|
|
189
201
|
}
|
|
190
|
-
exports.getUserAction = getUserAction;
|
|
191
202
|
async function createUser(viewer, input) {
|
|
192
203
|
const action = getUserAction(viewer, input);
|
|
193
204
|
return action.saveX();
|
|
194
205
|
}
|
|
195
|
-
exports.createUser = createUser;
|
|
196
206
|
exports.userLoader = new loaders_1.ObjectLoaderFactory({
|
|
197
207
|
tableName: "fake_users",
|
|
198
208
|
fields: FakeUser.getFields(),
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.inputs = void 0;
|
|
4
|
+
exports.getContactInput = getContactInput;
|
|
5
|
+
exports.getUserInput = getUserInput;
|
|
6
|
+
exports.getEventInput = getEventInput;
|
|
7
|
+
exports.createTestUser = createTestUser;
|
|
8
|
+
exports.createAllContacts = createAllContacts;
|
|
9
|
+
exports.createUserPlusFriendRequests = createUserPlusFriendRequests;
|
|
10
|
+
exports.addEdge = addEdge;
|
|
11
|
+
exports.verifyUserToContactEdges = verifyUserToContactEdges;
|
|
12
|
+
exports.verifyUserToContactRawData = verifyUserToContactRawData;
|
|
13
|
+
exports.verifyUserToContacts = verifyUserToContacts;
|
|
14
|
+
exports.createEdges = createEdges;
|
|
15
|
+
exports.edgeTableNames = edgeTableNames;
|
|
16
|
+
exports.createTestEvent = createTestEvent;
|
|
17
|
+
exports.setupTempDB = setupTempDB;
|
|
18
|
+
exports.tempDBTables = tempDBTables;
|
|
19
|
+
exports.createAllEvents = createAllEvents;
|
|
4
20
|
const jest_date_mock_1 = require("jest-date-mock");
|
|
5
21
|
const viewer_1 = require("../../core/viewer");
|
|
6
22
|
const ent_1 = require("../../core/ent");
|
|
@@ -26,7 +42,6 @@ function getContactInput(user, input) {
|
|
|
26
42
|
...input,
|
|
27
43
|
};
|
|
28
44
|
}
|
|
29
|
-
exports.getContactInput = getContactInput;
|
|
30
45
|
function getUserInput(input) {
|
|
31
46
|
return {
|
|
32
47
|
firstName: "Jon",
|
|
@@ -39,7 +54,6 @@ function getUserInput(input) {
|
|
|
39
54
|
...input,
|
|
40
55
|
};
|
|
41
56
|
}
|
|
42
|
-
exports.getUserInput = getUserInput;
|
|
43
57
|
function getEventInput(user, input) {
|
|
44
58
|
return {
|
|
45
59
|
startTime: new Date(),
|
|
@@ -52,7 +66,6 @@ function getEventInput(user, input) {
|
|
|
52
66
|
...input,
|
|
53
67
|
};
|
|
54
68
|
}
|
|
55
|
-
exports.getEventInput = getEventInput;
|
|
56
69
|
async function createTestUser(input, ctx) {
|
|
57
70
|
const user = await (0, _1.createUser)(new viewer_1.LoggedOutViewer(ctx), {
|
|
58
71
|
firstName: "Jon",
|
|
@@ -67,7 +80,6 @@ async function createTestUser(input, ctx) {
|
|
|
67
80
|
}
|
|
68
81
|
return user;
|
|
69
82
|
}
|
|
70
|
-
exports.createTestUser = createTestUser;
|
|
71
83
|
exports.inputs = [
|
|
72
84
|
{
|
|
73
85
|
firstName: "Arya",
|
|
@@ -115,7 +127,6 @@ async function createAllContacts(opts) {
|
|
|
115
127
|
expect(contacts.length).toBe(userInputs.length);
|
|
116
128
|
return [userr, contacts];
|
|
117
129
|
}
|
|
118
|
-
exports.createAllContacts = createAllContacts;
|
|
119
130
|
async function createUserPlusFriendRequests(input, slice) {
|
|
120
131
|
const user = await createTestUser(input);
|
|
121
132
|
let userInputs = exports.inputs.slice(0, slice || exports.inputs.length);
|
|
@@ -126,7 +137,6 @@ async function createUserPlusFriendRequests(input, slice) {
|
|
|
126
137
|
await addEdge(user, _1.FakeUserSchema, _1.EdgeType.UserToFriendRequests, true, ...friendRequests);
|
|
127
138
|
return [user, friendRequests];
|
|
128
139
|
}
|
|
129
|
-
exports.createUserPlusFriendRequests = createUserPlusFriendRequests;
|
|
130
140
|
async function addEdge(source, schema, edgeType, inbound, // inbound or outbound
|
|
131
141
|
...dest) {
|
|
132
142
|
const action = new builder_1.SimpleAction(source.viewer, schema, new Map(), action_1.WriteOperation.Edit, source);
|
|
@@ -147,7 +157,6 @@ async function addEdge(source, schema, edgeType, inbound, // inbound or outbound
|
|
|
147
157
|
});
|
|
148
158
|
await action.saveX();
|
|
149
159
|
}
|
|
150
|
-
exports.addEdge = addEdge;
|
|
151
160
|
function verifyUserToContactEdges(user, edges, contacts) {
|
|
152
161
|
expect(edges.length).toBe(contacts.length);
|
|
153
162
|
for (let i = 0; i < contacts.length; i++) {
|
|
@@ -164,7 +173,6 @@ function verifyUserToContactEdges(user, edges, contacts) {
|
|
|
164
173
|
expect(edge.getCursor()).not.toBe("");
|
|
165
174
|
}
|
|
166
175
|
}
|
|
167
|
-
exports.verifyUserToContactEdges = verifyUserToContactEdges;
|
|
168
176
|
function verifyUserToContactRawData(user, edges, contacts) {
|
|
169
177
|
expect(edges.length).toBe(contacts.length);
|
|
170
178
|
for (let i = 0; i < contacts.length; i++) {
|
|
@@ -174,13 +182,11 @@ function verifyUserToContactRawData(user, edges, contacts) {
|
|
|
174
182
|
expect(edge, `${i}th index`).toMatchObject(expectedEdge);
|
|
175
183
|
}
|
|
176
184
|
}
|
|
177
|
-
exports.verifyUserToContactRawData = verifyUserToContactRawData;
|
|
178
185
|
function verifyUserToContacts(user, ents, contacts) {
|
|
179
186
|
expect(ents.length).toBe(contacts.length);
|
|
180
187
|
const expectedContacts = contacts.map((contact) => contact.id);
|
|
181
188
|
expect(ents.map((contact) => contact.id)).toStrictEqual(expectedContacts);
|
|
182
189
|
}
|
|
183
|
-
exports.verifyUserToContacts = verifyUserToContacts;
|
|
184
190
|
async function createEdges() {
|
|
185
191
|
// create all edges// for now all one-way
|
|
186
192
|
const edgeNames = Object.keys(_1.EdgeType);
|
|
@@ -203,12 +209,10 @@ async function createEdges() {
|
|
|
203
209
|
expect(edgeData).toBeDefined();
|
|
204
210
|
}
|
|
205
211
|
}
|
|
206
|
-
exports.createEdges = createEdges;
|
|
207
212
|
function edgeTableNames() {
|
|
208
213
|
const edges = Object.values(_1.EdgeType);
|
|
209
214
|
return edges.map((edge) => (0, names_1.toDBColumnOrTable)(edge, "table"));
|
|
210
215
|
}
|
|
211
|
-
exports.edgeTableNames = edgeTableNames;
|
|
212
216
|
async function createTestEvent(user, input) {
|
|
213
217
|
const vc = new viewer_1.IDViewer(user.id);
|
|
214
218
|
const builder = (0, fake_event_1.getEventBuilder)(vc, {
|
|
@@ -223,7 +227,6 @@ async function createTestEvent(user, input) {
|
|
|
223
227
|
await builder.saveX();
|
|
224
228
|
return builder.editedEntX();
|
|
225
229
|
}
|
|
226
|
-
exports.createTestEvent = createTestEvent;
|
|
227
230
|
async function setupTempDB(global = false) {
|
|
228
231
|
const tdb = new temp_db_1.TempDB(db_1.Dialect.Postgres, tempDBTables(global));
|
|
229
232
|
await tdb.beforeAll();
|
|
@@ -231,7 +234,6 @@ async function setupTempDB(global = false) {
|
|
|
231
234
|
await createEdges();
|
|
232
235
|
return tdb;
|
|
233
236
|
}
|
|
234
|
-
exports.setupTempDB = setupTempDB;
|
|
235
237
|
function tempDBTables(global = false) {
|
|
236
238
|
const tables = [
|
|
237
239
|
_1.FakeUser.getTestTableWithDeletedAt(),
|
|
@@ -243,7 +245,6 @@ function tempDBTables(global = false) {
|
|
|
243
245
|
edgeTableNames().forEach((tableName) => tables.push((0, temp_db_1.assoc_edge_table)(tableName, global)));
|
|
244
246
|
return tables;
|
|
245
247
|
}
|
|
246
|
-
exports.tempDBTables = tempDBTables;
|
|
247
248
|
async function createAllEvents(opts) {
|
|
248
249
|
const user = await createTestUser(opts.userInput);
|
|
249
250
|
let arr = new Array(opts.howMany);
|
|
@@ -263,4 +264,3 @@ async function createAllEvents(opts) {
|
|
|
263
264
|
expect(events.length).toBe(opts.howMany);
|
|
264
265
|
return [user, events];
|
|
265
266
|
}
|
|
266
|
-
exports.createAllEvents = createAllEvents;
|
|
@@ -15,15 +15,26 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.UserToFollowingQuery = exports.UserToEventsInNextWeekQuery = exports.
|
|
36
|
+
exports.UserToFollowingQuery = exports.UserToEventsInNextWeekQuery = exports.getNextWeekClause = exports.UserToHostedEventsQuery = exports.UserToEventsAttendingQuery = exports.UserToIncomingFriendRequestsQuery = exports.UserToFriendRequestsQuery = exports.UserToCustomEdgeQuery = exports.CustomEdge = exports.UserToFriendsQuery = exports.UserToContactsFkeyQueryDeletedAtAsc = exports.UserToContactsFkeyQueryAsc = exports.UserToContactsFkeyQueryDeletedAt = exports.UserToContactsFkeyQuery = exports.UserToContactsFkeyQueryDeprecated = exports.userToContactsDataLoaderFactory = exports.userToContactsCountLoaderFactory = exports.UserToContactsQuery = void 0;
|
|
37
|
+
exports.getCompleteClause = getCompleteClause;
|
|
27
38
|
const jest_date_mock_1 = require("jest-date-mock");
|
|
28
39
|
const _1 = require(".");
|
|
29
40
|
const clause = __importStar(require("../../core/clause"));
|
|
@@ -357,7 +368,6 @@ exports.getNextWeekClause = getNextWeekClause;
|
|
|
357
368
|
function getCompleteClause(id) {
|
|
358
369
|
return clause.And(clause.Eq("user_id", id), (0, exports.getNextWeekClause)());
|
|
359
370
|
}
|
|
360
|
-
exports.getCompleteClause = getCompleteClause;
|
|
361
371
|
class UserToEventsInNextWeekQuery extends custom_query_1.CustomEdgeQueryBase {
|
|
362
372
|
constructor(viewer, src) {
|
|
363
373
|
super(viewer, {
|