@snowtop/ent 0.1.0-alpha160-test7 → 0.1.0-alpha161-test1
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/{dist/core → core}/query/assoc_query.d.ts +3 -0
- package/{dist/core → core}/query/assoc_query.js +71 -0
- package/{dist/core → core}/query/query.d.ts +3 -0
- package/{dist/core → core}/query/query.js +20 -6
- package/core/query/shared_assoc_test.d.ts +2 -0
- package/core/query/shared_assoc_test.js +1089 -0
- package/core/query/shared_test.d.ts +21 -0
- package/core/query/shared_test.js +736 -0
- package/graphql/query/shared_assoc_test.d.ts +1 -0
- package/graphql/query/shared_assoc_test.js +203 -0
- package/package.json +8 -53
- package/{dist/testutils → testutils}/fake_data/test_helpers.js +2 -1
- package/dist/package.json +0 -64
- package/src/action/action.ts +0 -330
- package/src/action/executor.ts +0 -453
- package/src/action/experimental_action.ts +0 -277
- package/src/action/index.ts +0 -31
- package/src/action/operations.ts +0 -967
- package/src/action/orchestrator.ts +0 -1527
- package/src/action/privacy.ts +0 -37
- package/src/action/relative_value.ts +0 -242
- package/src/action/transaction.ts +0 -38
- package/src/auth/auth.ts +0 -77
- package/src/auth/index.ts +0 -8
- package/src/core/base.ts +0 -367
- package/src/core/clause.ts +0 -1065
- package/src/core/config.ts +0 -219
- package/src/core/const.ts +0 -5
- package/src/core/context.ts +0 -135
- package/src/core/convert.ts +0 -106
- package/src/core/date.ts +0 -23
- package/src/core/db.ts +0 -498
- package/src/core/ent.ts +0 -1740
- package/src/core/global_schema.ts +0 -49
- package/src/core/loaders/assoc_count_loader.ts +0 -99
- package/src/core/loaders/assoc_edge_loader.ts +0 -250
- package/src/core/loaders/index.ts +0 -12
- package/src/core/loaders/loader.ts +0 -66
- package/src/core/loaders/object_loader.ts +0 -489
- package/src/core/loaders/query_loader.ts +0 -314
- package/src/core/loaders/raw_count_loader.ts +0 -175
- package/src/core/logger.ts +0 -49
- package/src/core/privacy.ts +0 -660
- package/src/core/query/assoc_query.ts +0 -240
- package/src/core/query/custom_clause_query.ts +0 -174
- package/src/core/query/custom_query.ts +0 -302
- package/src/core/query/index.ts +0 -9
- package/src/core/query/query.ts +0 -674
- package/src/core/query_impl.ts +0 -32
- package/src/core/viewer.ts +0 -52
- package/src/ent.code-workspace +0 -73
- package/src/graphql/builtins/connection.ts +0 -25
- package/src/graphql/builtins/edge.ts +0 -16
- package/src/graphql/builtins/node.ts +0 -12
- package/src/graphql/graphql.ts +0 -891
- package/src/graphql/graphql_field_helpers.ts +0 -221
- package/src/graphql/index.ts +0 -42
- package/src/graphql/mutations/union.ts +0 -39
- package/src/graphql/node_resolver.ts +0 -122
- package/src/graphql/query/connection_type.ts +0 -113
- package/src/graphql/query/edge_connection.ts +0 -171
- package/src/graphql/query/page_info.ts +0 -34
- package/src/graphql/query/shared_edge_connection.ts +0 -287
- package/src/graphql/scalars/orderby_direction.ts +0 -13
- package/src/graphql/scalars/time.ts +0 -38
- package/src/imports/dataz/example1/_auth.ts +0 -51
- package/src/imports/dataz/example1/_viewer.ts +0 -35
- package/src/imports/index.ts +0 -213
- package/src/index.ts +0 -145
- package/src/parse_schema/parse.ts +0 -585
- package/src/schema/base_schema.ts +0 -224
- package/src/schema/field.ts +0 -1087
- package/src/schema/index.ts +0 -53
- package/src/schema/json_field.ts +0 -94
- package/src/schema/schema.ts +0 -1028
- package/src/schema/struct_field.ts +0 -234
- package/src/schema/union_field.ts +0 -105
- package/src/scripts/custom_compiler.ts +0 -331
- package/src/scripts/custom_graphql.ts +0 -550
- package/src/scripts/migrate_v0.1.ts +0 -41
- package/src/scripts/move_types.ts +0 -131
- package/src/scripts/read_schema.ts +0 -67
- package/src/setupPackage.js +0 -42
- package/src/testutils/action/complex_schemas.ts +0 -517
- package/src/testutils/builder.ts +0 -422
- package/src/testutils/context/test_context.ts +0 -25
- package/src/testutils/db/fixture.ts +0 -32
- package/src/testutils/db/temp_db.ts +0 -941
- package/src/testutils/db/value.ts +0 -294
- package/src/testutils/db_mock.ts +0 -351
- package/src/testutils/db_time_zone.ts +0 -40
- package/src/testutils/ent-graphql-tests/index.ts +0 -653
- package/src/testutils/fake_comms.ts +0 -50
- package/src/testutils/fake_data/const.ts +0 -64
- package/src/testutils/fake_data/events_query.ts +0 -145
- package/src/testutils/fake_data/fake_contact.ts +0 -150
- package/src/testutils/fake_data/fake_event.ts +0 -150
- package/src/testutils/fake_data/fake_tag.ts +0 -139
- package/src/testutils/fake_data/fake_user.ts +0 -232
- package/src/testutils/fake_data/index.ts +0 -1
- package/src/testutils/fake_data/internal.ts +0 -8
- package/src/testutils/fake_data/tag_query.ts +0 -56
- package/src/testutils/fake_data/test_helpers.ts +0 -388
- package/src/testutils/fake_data/user_query.ts +0 -524
- package/src/testutils/fake_log.ts +0 -52
- package/src/testutils/mock_date.ts +0 -10
- package/src/testutils/mock_log.ts +0 -39
- package/src/testutils/parse_sql.ts +0 -685
- package/src/testutils/test_edge_global_schema.ts +0 -49
- package/src/testutils/write.ts +0 -70
- package/src/tsc/ast.ts +0 -351
- package/src/tsc/compilerOptions.ts +0 -85
- package/src/tsc/move_generated.ts +0 -191
- package/src/tsc/transform.ts +0 -226
- package/src/tsc/transform_action.ts +0 -224
- package/src/tsc/transform_ent.ts +0 -66
- package/src/tsc/transform_schema.ts +0 -546
- package/tsconfig.json +0 -20
- /package/{dist/action → action}/action.d.ts +0 -0
- /package/{dist/action → action}/action.js +0 -0
- /package/{dist/action → action}/executor.d.ts +0 -0
- /package/{dist/action → action}/executor.js +0 -0
- /package/{dist/action → action}/experimental_action.d.ts +0 -0
- /package/{dist/action → action}/experimental_action.js +0 -0
- /package/{dist/action → action}/index.d.ts +0 -0
- /package/{dist/action → action}/index.js +0 -0
- /package/{dist/action → action}/operations.d.ts +0 -0
- /package/{dist/action → action}/operations.js +0 -0
- /package/{dist/action → action}/orchestrator.d.ts +0 -0
- /package/{dist/action → action}/orchestrator.js +0 -0
- /package/{dist/action → action}/privacy.d.ts +0 -0
- /package/{dist/action → action}/privacy.js +0 -0
- /package/{dist/action → action}/relative_value.d.ts +0 -0
- /package/{dist/action → action}/relative_value.js +0 -0
- /package/{dist/action → action}/transaction.d.ts +0 -0
- /package/{dist/action → action}/transaction.js +0 -0
- /package/{dist/auth → auth}/auth.d.ts +0 -0
- /package/{dist/auth → auth}/auth.js +0 -0
- /package/{dist/auth → auth}/index.d.ts +0 -0
- /package/{dist/auth → auth}/index.js +0 -0
- /package/{dist/core → core}/base.d.ts +0 -0
- /package/{dist/core → core}/base.js +0 -0
- /package/{dist/core → core}/clause.d.ts +0 -0
- /package/{dist/core → core}/clause.js +0 -0
- /package/{dist/core → core}/config.d.ts +0 -0
- /package/{dist/core → core}/config.js +0 -0
- /package/{dist/core → core}/const.d.ts +0 -0
- /package/{dist/core → core}/const.js +0 -0
- /package/{dist/core → core}/context.d.ts +0 -0
- /package/{dist/core → core}/context.js +0 -0
- /package/{dist/core → core}/convert.d.ts +0 -0
- /package/{dist/core → core}/convert.js +0 -0
- /package/{dist/core → core}/date.d.ts +0 -0
- /package/{dist/core → core}/date.js +0 -0
- /package/{dist/core → core}/db.d.ts +0 -0
- /package/{dist/core → core}/db.js +0 -0
- /package/{dist/core → core}/ent.d.ts +0 -0
- /package/{dist/core → core}/ent.js +0 -0
- /package/{dist/core → core}/global_schema.d.ts +0 -0
- /package/{dist/core → core}/global_schema.js +0 -0
- /package/{dist/core → core}/loaders/assoc_count_loader.d.ts +0 -0
- /package/{dist/core → core}/loaders/assoc_count_loader.js +0 -0
- /package/{dist/core → core}/loaders/assoc_edge_loader.d.ts +0 -0
- /package/{dist/core → core}/loaders/assoc_edge_loader.js +0 -0
- /package/{dist/core → core}/loaders/index.d.ts +0 -0
- /package/{dist/core → core}/loaders/index.js +0 -0
- /package/{dist/core → core}/loaders/loader.d.ts +0 -0
- /package/{dist/core → core}/loaders/loader.js +0 -0
- /package/{dist/core → core}/loaders/object_loader.d.ts +0 -0
- /package/{dist/core → core}/loaders/object_loader.js +0 -0
- /package/{dist/core → core}/loaders/query_loader.d.ts +0 -0
- /package/{dist/core → core}/loaders/query_loader.js +0 -0
- /package/{dist/core → core}/loaders/raw_count_loader.d.ts +0 -0
- /package/{dist/core → core}/loaders/raw_count_loader.js +0 -0
- /package/{dist/core → core}/logger.d.ts +0 -0
- /package/{dist/core → core}/logger.js +0 -0
- /package/{dist/core → core}/privacy.d.ts +0 -0
- /package/{dist/core → core}/privacy.js +0 -0
- /package/{dist/core → core}/query/custom_clause_query.d.ts +0 -0
- /package/{dist/core → core}/query/custom_clause_query.js +0 -0
- /package/{dist/core → core}/query/custom_query.d.ts +0 -0
- /package/{dist/core → core}/query/custom_query.js +0 -0
- /package/{dist/core → core}/query/index.d.ts +0 -0
- /package/{dist/core → core}/query/index.js +0 -0
- /package/{dist/core → core}/query_impl.d.ts +0 -0
- /package/{dist/core → core}/query_impl.js +0 -0
- /package/{dist/core → core}/viewer.d.ts +0 -0
- /package/{dist/core → core}/viewer.js +0 -0
- /package/{dist/graphql → graphql}/builtins/connection.d.ts +0 -0
- /package/{dist/graphql → graphql}/builtins/connection.js +0 -0
- /package/{dist/graphql → graphql}/builtins/edge.d.ts +0 -0
- /package/{dist/graphql → graphql}/builtins/edge.js +0 -0
- /package/{dist/graphql → graphql}/builtins/node.d.ts +0 -0
- /package/{dist/graphql → graphql}/builtins/node.js +0 -0
- /package/{dist/graphql → graphql}/graphql.d.ts +0 -0
- /package/{dist/graphql → graphql}/graphql.js +0 -0
- /package/{dist/graphql → graphql}/graphql_field_helpers.d.ts +0 -0
- /package/{dist/graphql → graphql}/graphql_field_helpers.js +0 -0
- /package/{dist/graphql → graphql}/index.d.ts +0 -0
- /package/{dist/graphql → graphql}/index.js +0 -0
- /package/{dist/graphql → graphql}/mutations/union.d.ts +0 -0
- /package/{dist/graphql → graphql}/mutations/union.js +0 -0
- /package/{dist/graphql → graphql}/node_resolver.d.ts +0 -0
- /package/{dist/graphql → graphql}/node_resolver.js +0 -0
- /package/{dist/graphql → graphql}/query/connection_type.d.ts +0 -0
- /package/{dist/graphql → graphql}/query/connection_type.js +0 -0
- /package/{dist/graphql → graphql}/query/edge_connection.d.ts +0 -0
- /package/{dist/graphql → graphql}/query/edge_connection.js +0 -0
- /package/{dist/graphql → graphql}/query/page_info.d.ts +0 -0
- /package/{dist/graphql → graphql}/query/page_info.js +0 -0
- /package/{dist/graphql → graphql}/query/shared_edge_connection.d.ts +0 -0
- /package/{dist/graphql → graphql}/query/shared_edge_connection.js +0 -0
- /package/{dist/graphql → graphql}/scalars/orderby_direction.d.ts +0 -0
- /package/{dist/graphql → graphql}/scalars/orderby_direction.js +0 -0
- /package/{dist/graphql → graphql}/scalars/time.d.ts +0 -0
- /package/{dist/graphql → graphql}/scalars/time.js +0 -0
- /package/{dist/imports → imports}/dataz/example1/_auth.d.ts +0 -0
- /package/{dist/imports → imports}/dataz/example1/_auth.js +0 -0
- /package/{dist/imports → imports}/dataz/example1/_viewer.d.ts +0 -0
- /package/{dist/imports → imports}/dataz/example1/_viewer.js +0 -0
- /package/{dist/imports → imports}/index.d.ts +0 -0
- /package/{dist/imports → imports}/index.js +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/parse_schema → parse_schema}/parse.d.ts +0 -0
- /package/{dist/parse_schema → parse_schema}/parse.js +0 -0
- /package/{dist/schema → schema}/base_schema.d.ts +0 -0
- /package/{dist/schema → schema}/base_schema.js +0 -0
- /package/{dist/schema → schema}/field.d.ts +0 -0
- /package/{dist/schema → schema}/field.js +0 -0
- /package/{dist/schema → schema}/index.d.ts +0 -0
- /package/{dist/schema → schema}/index.js +0 -0
- /package/{dist/schema → schema}/json_field.d.ts +0 -0
- /package/{dist/schema → schema}/json_field.js +0 -0
- /package/{dist/schema → schema}/schema.d.ts +0 -0
- /package/{dist/schema → schema}/schema.js +0 -0
- /package/{dist/schema → schema}/struct_field.d.ts +0 -0
- /package/{dist/schema → schema}/struct_field.js +0 -0
- /package/{dist/schema → schema}/union_field.d.ts +0 -0
- /package/{dist/schema → schema}/union_field.js +0 -0
- /package/{dist/scripts → scripts}/custom_compiler.d.ts +0 -0
- /package/{dist/scripts → scripts}/custom_compiler.js +0 -0
- /package/{dist/scripts → scripts}/custom_graphql.d.ts +0 -0
- /package/{dist/scripts → scripts}/custom_graphql.js +0 -0
- /package/{dist/scripts → scripts}/migrate_v0.1.d.ts +0 -0
- /package/{dist/scripts → scripts}/migrate_v0.1.js +0 -0
- /package/{dist/scripts → scripts}/move_types.d.ts +0 -0
- /package/{dist/scripts → scripts}/move_types.js +0 -0
- /package/{dist/scripts → scripts}/read_schema.d.ts +0 -0
- /package/{dist/scripts → scripts}/read_schema.js +0 -0
- /package/{dist/testutils → testutils}/action/complex_schemas.d.ts +0 -0
- /package/{dist/testutils → testutils}/action/complex_schemas.js +0 -0
- /package/{dist/testutils → testutils}/builder.d.ts +0 -0
- /package/{dist/testutils → testutils}/builder.js +0 -0
- /package/{dist/testutils → testutils}/context/test_context.d.ts +0 -0
- /package/{dist/testutils → testutils}/context/test_context.js +0 -0
- /package/{dist/testutils → testutils}/db/fixture.d.ts +0 -0
- /package/{dist/testutils → testutils}/db/fixture.js +0 -0
- /package/{dist/testutils → testutils}/db/temp_db.d.ts +0 -0
- /package/{dist/testutils → testutils}/db/temp_db.js +0 -0
- /package/{dist/testutils → testutils}/db/value.d.ts +0 -0
- /package/{dist/testutils → testutils}/db/value.js +0 -0
- /package/{dist/testutils → testutils}/db_mock.d.ts +0 -0
- /package/{dist/testutils → testutils}/db_mock.js +0 -0
- /package/{dist/testutils → testutils}/db_time_zone.d.ts +0 -0
- /package/{dist/testutils → testutils}/db_time_zone.js +0 -0
- /package/{dist/testutils → testutils}/ent-graphql-tests/index.d.ts +0 -0
- /package/{dist/testutils → testutils}/ent-graphql-tests/index.js +0 -0
- /package/{dist/testutils → testutils}/fake_comms.d.ts +0 -0
- /package/{dist/testutils → testutils}/fake_comms.js +0 -0
- /package/{dist/testutils → testutils}/fake_data/const.d.ts +0 -0
- /package/{dist/testutils → testutils}/fake_data/const.js +0 -0
- /package/{dist/testutils → testutils}/fake_data/events_query.d.ts +0 -0
- /package/{dist/testutils → testutils}/fake_data/events_query.js +0 -0
- /package/{dist/testutils → testutils}/fake_data/fake_contact.d.ts +0 -0
- /package/{dist/testutils → testutils}/fake_data/fake_contact.js +0 -0
- /package/{dist/testutils → testutils}/fake_data/fake_event.d.ts +0 -0
- /package/{dist/testutils → testutils}/fake_data/fake_event.js +0 -0
- /package/{dist/testutils → testutils}/fake_data/fake_tag.d.ts +0 -0
- /package/{dist/testutils → testutils}/fake_data/fake_tag.js +0 -0
- /package/{dist/testutils → testutils}/fake_data/fake_user.d.ts +0 -0
- /package/{dist/testutils → testutils}/fake_data/fake_user.js +0 -0
- /package/{dist/testutils → testutils}/fake_data/index.d.ts +0 -0
- /package/{dist/testutils → testutils}/fake_data/index.js +0 -0
- /package/{dist/testutils → testutils}/fake_data/internal.d.ts +0 -0
- /package/{dist/testutils → testutils}/fake_data/internal.js +0 -0
- /package/{dist/testutils → testutils}/fake_data/tag_query.d.ts +0 -0
- /package/{dist/testutils → testutils}/fake_data/tag_query.js +0 -0
- /package/{dist/testutils → testutils}/fake_data/test_helpers.d.ts +0 -0
- /package/{dist/testutils → testutils}/fake_data/user_query.d.ts +0 -0
- /package/{dist/testutils → testutils}/fake_data/user_query.js +0 -0
- /package/{dist/testutils → testutils}/fake_log.d.ts +0 -0
- /package/{dist/testutils → testutils}/fake_log.js +0 -0
- /package/{dist/testutils → testutils}/mock_date.d.ts +0 -0
- /package/{dist/testutils → testutils}/mock_date.js +0 -0
- /package/{dist/testutils → testutils}/mock_log.d.ts +0 -0
- /package/{dist/testutils → testutils}/mock_log.js +0 -0
- /package/{dist/testutils → testutils}/parse_sql.d.ts +0 -0
- /package/{dist/testutils → testutils}/parse_sql.js +0 -0
- /package/{dist/testutils → testutils}/test_edge_global_schema.d.ts +0 -0
- /package/{dist/testutils → testutils}/test_edge_global_schema.js +0 -0
- /package/{dist/testutils → testutils}/write.d.ts +0 -0
- /package/{dist/testutils → testutils}/write.js +0 -0
- /package/{dist/tsc → tsc}/ast.d.ts +0 -0
- /package/{dist/tsc → tsc}/ast.js +0 -0
- /package/{dist/tsc → tsc}/compilerOptions.d.ts +0 -0
- /package/{dist/tsc → tsc}/compilerOptions.js +0 -0
- /package/{dist/tsc → tsc}/move_generated.d.ts +0 -0
- /package/{dist/tsc → tsc}/move_generated.js +0 -0
- /package/{dist/tsc → tsc}/transform.d.ts +0 -0
- /package/{dist/tsc → tsc}/transform.js +0 -0
- /package/{dist/tsc → tsc}/transform_action.d.ts +0 -0
- /package/{dist/tsc → tsc}/transform_action.js +0 -0
- /package/{dist/tsc → tsc}/transform_ent.d.ts +0 -0
- /package/{dist/tsc → tsc}/transform_ent.js +0 -0
- /package/{dist/tsc → tsc}/transform_schema.d.ts +0 -0
- /package/{dist/tsc → tsc}/transform_schema.js +0 -0
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GraphQLBoolean,
|
|
3
|
-
GraphQLFieldConfigMap,
|
|
4
|
-
GraphQLNonNull,
|
|
5
|
-
GraphQLString,
|
|
6
|
-
GraphQLObjectType,
|
|
7
|
-
} from "graphql";
|
|
8
|
-
import { RequestContext } from "../../core/context";
|
|
9
|
-
import { PaginationInfo } from "../../core/query/query";
|
|
10
|
-
|
|
11
|
-
// NB: if this changes, need to update renderer.go also
|
|
12
|
-
export const GraphQLPageInfo = new GraphQLObjectType({
|
|
13
|
-
name: "PageInfo",
|
|
14
|
-
fields: (): GraphQLFieldConfigMap<PaginationInfo, RequestContext> => ({
|
|
15
|
-
hasNextPage: {
|
|
16
|
-
type: new GraphQLNonNull(GraphQLBoolean),
|
|
17
|
-
resolve: (source: PaginationInfo) => {
|
|
18
|
-
return source.hasNextPage || false;
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
hasPreviousPage: {
|
|
22
|
-
type: new GraphQLNonNull(GraphQLBoolean),
|
|
23
|
-
resolve: (source: PaginationInfo) => {
|
|
24
|
-
return source.hasPreviousPage || false;
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
startCursor: {
|
|
28
|
-
type: new GraphQLNonNull(GraphQLString),
|
|
29
|
-
},
|
|
30
|
-
endCursor: {
|
|
31
|
-
type: new GraphQLNonNull(GraphQLString),
|
|
32
|
-
},
|
|
33
|
-
}),
|
|
34
|
-
});
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import { IDViewer } from "../../core/viewer";
|
|
2
|
-
import { Viewer, Data, Ent } from "../../core/base";
|
|
3
|
-
import { getCursor } from "../../core/ent";
|
|
4
|
-
import { GraphQLEdgeConnection } from "./edge_connection";
|
|
5
|
-
import { FakeUser, FakeContact } from "../../testutils/fake_data/index";
|
|
6
|
-
import {
|
|
7
|
-
inputs,
|
|
8
|
-
createAllContacts,
|
|
9
|
-
} from "../../testutils/fake_data/test_helpers";
|
|
10
|
-
import { EdgeQuery } from "../../core/query/query";
|
|
11
|
-
|
|
12
|
-
class TestConnection<TEdge extends Data> {
|
|
13
|
-
private user: FakeUser;
|
|
14
|
-
private allContacts: FakeContact[];
|
|
15
|
-
private filteredContacts: FakeContact[] = [];
|
|
16
|
-
|
|
17
|
-
conn: GraphQLEdgeConnection<Ent, TEdge>;
|
|
18
|
-
constructor(
|
|
19
|
-
private getQuery: (
|
|
20
|
-
v: Viewer,
|
|
21
|
-
user: FakeUser,
|
|
22
|
-
) => EdgeQuery<FakeContact, Ent, TEdge>,
|
|
23
|
-
private ents: (contacts: FakeContact[]) => FakeContact[],
|
|
24
|
-
private filter?: (
|
|
25
|
-
conn: GraphQLEdgeConnection<Ent, TEdge>,
|
|
26
|
-
user: FakeUser,
|
|
27
|
-
contacts: FakeContact[],
|
|
28
|
-
) => void,
|
|
29
|
-
) {}
|
|
30
|
-
|
|
31
|
-
async beforeEach() {
|
|
32
|
-
[this.user, this.allContacts] = await createAllContacts();
|
|
33
|
-
this.allContacts = this.allContacts.reverse();
|
|
34
|
-
this.conn = new GraphQLEdgeConnection<Ent, TEdge>(
|
|
35
|
-
new IDViewer(this.user.id),
|
|
36
|
-
this.user,
|
|
37
|
-
(v, user: FakeUser) => this.getQuery(v, user),
|
|
38
|
-
);
|
|
39
|
-
if (this.filter) {
|
|
40
|
-
this.filter(this.conn, this.user, this.allContacts);
|
|
41
|
-
}
|
|
42
|
-
this.filteredContacts = this.ents(this.allContacts);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async testTotalCount() {
|
|
46
|
-
const count = await this.conn.queryTotalCount();
|
|
47
|
-
expect(count).toBe(inputs.length);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async testNodes() {
|
|
51
|
-
const nodes = await this.conn.queryNodes();
|
|
52
|
-
expect(nodes.length).toBe(this.filteredContacts.length);
|
|
53
|
-
for (let i = 0; i < this.filteredContacts.length; i++) {
|
|
54
|
-
expect(nodes[i].id).toBe(this.filteredContacts[i].id);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async testEdges() {
|
|
59
|
-
const edges = await this.conn.queryEdges();
|
|
60
|
-
expect(edges.length).toBe(this.filteredContacts.length);
|
|
61
|
-
for (let i = 0; i < this.filteredContacts.length; i++) {
|
|
62
|
-
const edge = edges[i];
|
|
63
|
-
expect(edge.node.id).toBe(this.filteredContacts[i].id);
|
|
64
|
-
expect(this.conn.query.dataToID(edge.edge)).toBe(
|
|
65
|
-
this.filteredContacts[i].id,
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface options<TEnt extends Ent, TEdge extends Data> {
|
|
72
|
-
getQuery: (v: Viewer, src: Ent) => EdgeQuery<TEnt, Ent, TEdge>;
|
|
73
|
-
tableName: string;
|
|
74
|
-
sortCol: string;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export const commonTests = <TEdge extends Data>(
|
|
78
|
-
opts: options<FakeContact, TEdge>,
|
|
79
|
-
) => {
|
|
80
|
-
function getCursorFrom(contacts: FakeContact[], idx: number) {
|
|
81
|
-
return getCursor({
|
|
82
|
-
row: contacts[idx],
|
|
83
|
-
col: "id",
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
describe("no filters", () => {
|
|
88
|
-
const filter = new TestConnection(
|
|
89
|
-
(v, user: FakeUser) => opts.getQuery(v, user),
|
|
90
|
-
(contacts) => contacts,
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
beforeEach(async () => {
|
|
94
|
-
await filter.beforeEach();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test("totalCount", async () => {
|
|
98
|
-
await filter.testTotalCount();
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test("nodes", async () => {
|
|
102
|
-
await filter.testNodes();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
test("edges", async () => {
|
|
106
|
-
await filter.testEdges();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test("pagination", async () => {
|
|
110
|
-
const pagination = await filter.conn.queryPageInfo();
|
|
111
|
-
expect(pagination.hasNextPage).toBe(false);
|
|
112
|
-
expect(pagination.hasPreviousPage).toBe(false);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe("filters. firstN", () => {
|
|
117
|
-
const filter = new TestConnection(
|
|
118
|
-
(v, user: FakeUser) => opts.getQuery(v, user),
|
|
119
|
-
(contacts) => contacts.slice(0, 2),
|
|
120
|
-
(conn: GraphQLEdgeConnection<Ent, TEdge>) => {
|
|
121
|
-
conn.first(2);
|
|
122
|
-
},
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
beforeEach(async () => {
|
|
126
|
-
await filter.beforeEach();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
test("totalCount", async () => {
|
|
130
|
-
await filter.testTotalCount();
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
test("nodes", async () => {
|
|
134
|
-
await filter.testNodes();
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
test("edges", async () => {
|
|
138
|
-
await filter.testEdges();
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
test("pagination", async () => {
|
|
142
|
-
const [pagination, edges] = await Promise.all([
|
|
143
|
-
filter.conn.queryPageInfo(),
|
|
144
|
-
filter.conn.queryEdges(),
|
|
145
|
-
]);
|
|
146
|
-
expect(pagination.hasNextPage).toBe(true);
|
|
147
|
-
expect(pagination.hasPreviousPage).toBe(false);
|
|
148
|
-
expect(edges.length).toBe(2);
|
|
149
|
-
expect(edges[0].cursor).toBe(pagination.startCursor);
|
|
150
|
-
expect(edges[1].cursor).toBe(pagination.endCursor);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
describe("filters. firstN + cursor", () => {
|
|
155
|
-
const idx = 1;
|
|
156
|
-
const N = 3;
|
|
157
|
-
const filter = new TestConnection(
|
|
158
|
-
(v, user: FakeUser) => opts.getQuery(v, user),
|
|
159
|
-
// get the next 2
|
|
160
|
-
(contacts) => contacts.slice(idx + 1, idx + N),
|
|
161
|
-
(
|
|
162
|
-
conn: GraphQLEdgeConnection<Ent, TEdge>,
|
|
163
|
-
user: FakeUser,
|
|
164
|
-
contacts: FakeContact[],
|
|
165
|
-
) => {
|
|
166
|
-
const cursor = getCursorFrom(contacts, idx);
|
|
167
|
-
conn.first(2, cursor);
|
|
168
|
-
},
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
beforeEach(async () => {
|
|
172
|
-
await filter.beforeEach();
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
test("totalCount", async () => {
|
|
176
|
-
await filter.testTotalCount();
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
test("nodes", async () => {
|
|
180
|
-
await filter.testNodes();
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
test("edges", async () => {
|
|
184
|
-
await filter.testEdges();
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
test("pagination", async () => {
|
|
188
|
-
const [pagination, edges] = await Promise.all([
|
|
189
|
-
filter.conn.queryPageInfo(),
|
|
190
|
-
filter.conn.queryEdges(),
|
|
191
|
-
]);
|
|
192
|
-
expect(pagination.hasNextPage).toBe(true);
|
|
193
|
-
expect(pagination.hasPreviousPage).toBe(false);
|
|
194
|
-
expect(edges.length).toBe(2);
|
|
195
|
-
expect(edges[0].cursor).toBe(pagination.startCursor);
|
|
196
|
-
expect(edges[1].cursor).toBe(pagination.endCursor);
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
describe("filters. before cursor", () => {
|
|
201
|
-
const filter = new TestConnection(
|
|
202
|
-
(v, user: FakeUser) => opts.getQuery(v, user),
|
|
203
|
-
(contacts) => contacts.slice(2, 4).reverse(),
|
|
204
|
-
(
|
|
205
|
-
conn: GraphQLEdgeConnection<Ent, TEdge>,
|
|
206
|
-
user: FakeUser,
|
|
207
|
-
contacts: FakeContact[],
|
|
208
|
-
) => {
|
|
209
|
-
// get the 2 before it
|
|
210
|
-
const cursor = getCursorFrom(contacts, 4);
|
|
211
|
-
|
|
212
|
-
conn.last(2, cursor);
|
|
213
|
-
},
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
beforeEach(async () => {
|
|
217
|
-
await filter.beforeEach();
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
test("totalCount", async () => {
|
|
221
|
-
await filter.testTotalCount();
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
test("nodes", async () => {
|
|
225
|
-
await filter.testNodes();
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
test("edges", async () => {
|
|
229
|
-
await filter.testEdges();
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
test("pagination", async () => {
|
|
233
|
-
const [pagination, edges] = await Promise.all([
|
|
234
|
-
filter.conn.queryPageInfo(),
|
|
235
|
-
filter.conn.queryEdges(),
|
|
236
|
-
]);
|
|
237
|
-
expect(pagination.hasNextPage).toBe(false);
|
|
238
|
-
expect(pagination.hasPreviousPage).toBe(true);
|
|
239
|
-
expect(edges.length).toBe(2);
|
|
240
|
-
expect(edges[0].cursor).toBe(pagination.startCursor);
|
|
241
|
-
expect(edges[1].cursor).toBe(pagination.endCursor);
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
describe("no source", () => {
|
|
246
|
-
test("no filter", async () => {
|
|
247
|
-
const [user, allContacts] = await createAllContacts();
|
|
248
|
-
|
|
249
|
-
const conn = new GraphQLEdgeConnection<FakeContact, TEdge>(
|
|
250
|
-
new IDViewer(user.id),
|
|
251
|
-
(v) => opts.getQuery(v, user),
|
|
252
|
-
);
|
|
253
|
-
allContacts.reverse();
|
|
254
|
-
|
|
255
|
-
const nodes = await conn.queryNodes();
|
|
256
|
-
expect(nodes.length).toBe(allContacts.length);
|
|
257
|
-
for (let i = 0; i < allContacts.length; i++) {
|
|
258
|
-
expect(nodes[i].id).toBe(allContacts[i].id);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const pagination = await conn.queryPageInfo();
|
|
262
|
-
expect(pagination.hasNextPage).toBe(false);
|
|
263
|
-
expect(pagination.hasPreviousPage).toBe(false);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
test("with filter", async () => {
|
|
267
|
-
const [user, allContacts] = await createAllContacts();
|
|
268
|
-
|
|
269
|
-
const conn = new GraphQLEdgeConnection<Ent, TEdge>(
|
|
270
|
-
new IDViewer(user.id),
|
|
271
|
-
(v) => opts.getQuery(v, user).first(2),
|
|
272
|
-
);
|
|
273
|
-
allContacts.reverse();
|
|
274
|
-
const filtered = allContacts.slice(0, 2);
|
|
275
|
-
|
|
276
|
-
const nodes = await conn.queryNodes();
|
|
277
|
-
expect(nodes.length).toBe(filtered.length);
|
|
278
|
-
for (let i = 0; i < filtered.length; i++) {
|
|
279
|
-
expect(nodes[i].id).toBe(filtered[i].id);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const pagination = await conn.queryPageInfo();
|
|
283
|
-
expect(pagination.hasNextPage).toBe(true);
|
|
284
|
-
expect(pagination.hasPreviousPage).toBe(false);
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { GraphQLScalarType, GraphQLError } from "graphql";
|
|
2
|
-
import { Kind, ValueNode } from "graphql/language";
|
|
3
|
-
import { DateTime } from "luxon";
|
|
4
|
-
import { parseDate } from "../../core/date";
|
|
5
|
-
|
|
6
|
-
// Time refers to a Timestamp or Date scalar
|
|
7
|
-
|
|
8
|
-
function parseValue(input: any): Date {
|
|
9
|
-
return parseDate(input, (msg: string) => {
|
|
10
|
-
return new GraphQLError(msg);
|
|
11
|
-
}).toJSDate();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Date or Timestamp
|
|
15
|
-
// Need feedback. should this be renamed to Timestamp?
|
|
16
|
-
// This is called Time but only supports Date and Timestamp values
|
|
17
|
-
// and `Time` isn't supported. that's a string
|
|
18
|
-
export const GraphQLTime = new GraphQLScalarType({
|
|
19
|
-
name: "Time",
|
|
20
|
-
description: "Time scalar type",
|
|
21
|
-
serialize: (outputValue: any) => {
|
|
22
|
-
if (outputValue instanceof Date) {
|
|
23
|
-
return outputValue.toISOString();
|
|
24
|
-
} else if (outputValue instanceof DateTime) {
|
|
25
|
-
return outputValue.toUTC().toISO();
|
|
26
|
-
}
|
|
27
|
-
return parseValue(outputValue).toISOString();
|
|
28
|
-
},
|
|
29
|
-
parseValue: parseValue,
|
|
30
|
-
parseLiteral: (ast: ValueNode) => {
|
|
31
|
-
// console.log("literal", ast);
|
|
32
|
-
if (ast.kind === Kind.INT) {
|
|
33
|
-
return new Date(+ast.value);
|
|
34
|
-
}
|
|
35
|
-
// TODO?
|
|
36
|
-
throw new GraphQLError(`Time cannot represent literal value ${ast}`);
|
|
37
|
-
},
|
|
38
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
gqlInputObjectType,
|
|
3
|
-
gqlField,
|
|
4
|
-
gqlMutation,
|
|
5
|
-
gqlObjectType,
|
|
6
|
-
} from "../../../graphql/graphql";
|
|
7
|
-
import { ID } from "../../../core/base";
|
|
8
|
-
import { GraphQLID, GraphQLString } from "graphql";
|
|
9
|
-
|
|
10
|
-
@gqlInputObjectType()
|
|
11
|
-
class UserAuthInput {
|
|
12
|
-
@gqlField({
|
|
13
|
-
class: "UserAuthInput",
|
|
14
|
-
type: GraphQLString,
|
|
15
|
-
})
|
|
16
|
-
emailAddress: string;
|
|
17
|
-
@gqlField({
|
|
18
|
-
class: "UserAuthInput",
|
|
19
|
-
type: GraphQLString,
|
|
20
|
-
})
|
|
21
|
-
password: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@gqlObjectType()
|
|
25
|
-
class UserAuthResponse {
|
|
26
|
-
@gqlField({
|
|
27
|
-
class: "UserAuthResponse",
|
|
28
|
-
type: GraphQLString,
|
|
29
|
-
})
|
|
30
|
-
token: string;
|
|
31
|
-
|
|
32
|
-
@gqlField({ class: "UserAuthResponses", type: GraphQLID })
|
|
33
|
-
viewerID: ID;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
class AuthResolver {
|
|
37
|
-
@gqlMutation({
|
|
38
|
-
class: "AuthResolver",
|
|
39
|
-
name: "userAuth",
|
|
40
|
-
type: UserAuthResponse,
|
|
41
|
-
args: [
|
|
42
|
-
{
|
|
43
|
-
name: "input",
|
|
44
|
-
type: UserAuthInput,
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
})
|
|
48
|
-
async userAuth(input: UserAuthInput): Promise<UserAuthResponse> {
|
|
49
|
-
throw new Error("not implemented");
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
gqlField,
|
|
3
|
-
gqlObjectType,
|
|
4
|
-
gqlContextType,
|
|
5
|
-
gqlQuery,
|
|
6
|
-
} from "../../../graphql/graphql";
|
|
7
|
-
import { Viewer } from "../../../core/base";
|
|
8
|
-
import { GraphQLID } from "graphql";
|
|
9
|
-
import { RequestContext } from "../../../core/context";
|
|
10
|
-
|
|
11
|
-
@gqlObjectType({ name: "Viewer" })
|
|
12
|
-
class ViewerType {
|
|
13
|
-
constructor(private viewer: Viewer) {}
|
|
14
|
-
|
|
15
|
-
@gqlField({
|
|
16
|
-
class: "ViewerType",
|
|
17
|
-
type: GraphQLID,
|
|
18
|
-
nullable: true,
|
|
19
|
-
})
|
|
20
|
-
get viewerID() {
|
|
21
|
-
return this.viewer.viewerID;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default class ViewerResolver {
|
|
26
|
-
@gqlQuery({
|
|
27
|
-
class: "ViewerResolver",
|
|
28
|
-
name: "viewer",
|
|
29
|
-
type: ViewerType,
|
|
30
|
-
args: [gqlContextType()],
|
|
31
|
-
})
|
|
32
|
-
viewer(context: RequestContext): ViewerType {
|
|
33
|
-
return new ViewerType(context.getViewer());
|
|
34
|
-
}
|
|
35
|
-
}
|
package/src/imports/index.ts
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import * as glob from "glob";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
import * as fs from "fs";
|
|
4
|
-
import * as path from "path";
|
|
5
|
-
import { readCompilerOptions } from "../tsc/compilerOptions";
|
|
6
|
-
|
|
7
|
-
function getFiles(filePath: string, opts?: Options): string[] {
|
|
8
|
-
if (!path.isAbsolute(filePath)) {
|
|
9
|
-
throw new Error("absolute file path required");
|
|
10
|
-
}
|
|
11
|
-
// graphql path should be passed to this
|
|
12
|
-
// this is more agnostic about what it expect here
|
|
13
|
-
|
|
14
|
-
let pattern = `${filePath}/**/*.ts`;
|
|
15
|
-
if (opts?.justCurrentDir) {
|
|
16
|
-
pattern = `${filePath}/**.ts`;
|
|
17
|
-
}
|
|
18
|
-
let files = glob.sync(pattern, {
|
|
19
|
-
ignore: opts?.ignore,
|
|
20
|
-
});
|
|
21
|
-
if (opts?.filter) {
|
|
22
|
-
files = files.filter(opts.filter);
|
|
23
|
-
}
|
|
24
|
-
return files;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface Options {
|
|
28
|
-
filter?: (file: string, index: number, array: string[]) => boolean;
|
|
29
|
-
justCurrentDir?: boolean;
|
|
30
|
-
ignore?: string | string[] | undefined;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface PathResult {
|
|
34
|
-
m: Map<string, file[]>;
|
|
35
|
-
// throws if there's more than one class that maps to this
|
|
36
|
-
getInfoForClass(className: string): classResult;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
interface classResult {
|
|
40
|
-
class: classInfo;
|
|
41
|
-
file: file;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
interface ParseInput {
|
|
45
|
-
root: string;
|
|
46
|
-
opts?: Options;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function parseCustomImports(
|
|
50
|
-
filePath: string,
|
|
51
|
-
inputs: ParseInput[],
|
|
52
|
-
): PathResult {
|
|
53
|
-
const files: string[] = [];
|
|
54
|
-
// simplifies tests and other simple callsites
|
|
55
|
-
if (inputs.length === 0) {
|
|
56
|
-
inputs.push({ root: filePath });
|
|
57
|
-
}
|
|
58
|
-
for (const input of inputs) {
|
|
59
|
-
files.push(...getFiles(input.root, input.opts));
|
|
60
|
-
}
|
|
61
|
-
const options = readCompilerOptions(filePath);
|
|
62
|
-
|
|
63
|
-
let classMap = new Map<string, file[]>();
|
|
64
|
-
|
|
65
|
-
files.forEach((file) => {
|
|
66
|
-
const sourceFile = ts.createSourceFile(
|
|
67
|
-
file,
|
|
68
|
-
fs.readFileSync(file).toString(),
|
|
69
|
-
options.target || ts.ScriptTarget.ES2015,
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
let f: file = {
|
|
73
|
-
path: sourceFile.fileName,
|
|
74
|
-
imports: new Map(),
|
|
75
|
-
classes: new Map(),
|
|
76
|
-
};
|
|
77
|
-
traverse(sourceFile, f, classMap);
|
|
78
|
-
//console.log(f);
|
|
79
|
-
// console.log(classMap);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
return {
|
|
83
|
-
m: classMap,
|
|
84
|
-
getInfoForClass: (className: string) => {
|
|
85
|
-
let files = classMap.get(className);
|
|
86
|
-
if (files?.length !== 1) {
|
|
87
|
-
throw new Error(
|
|
88
|
-
`expected 1 class with name ${className}, got ${
|
|
89
|
-
files?.length || 0
|
|
90
|
-
} classes instead`,
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
let f = files[0];
|
|
94
|
-
let info = f.classes.get(className);
|
|
95
|
-
if (!info) {
|
|
96
|
-
throw new Error(
|
|
97
|
-
`expected to find info for class ${className} in file ${f.path}`,
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
class: info,
|
|
102
|
-
file: f,
|
|
103
|
-
};
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface importInfo {
|
|
109
|
-
name: string; // name in the file
|
|
110
|
-
importPath: string; // where it's imported from
|
|
111
|
-
defaultImport?: boolean; // default import?
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export interface classInfo {
|
|
115
|
-
name: string;
|
|
116
|
-
exported: boolean;
|
|
117
|
-
defaultExport: boolean;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export interface file {
|
|
121
|
-
path: string; // path to file
|
|
122
|
-
imports: Map<string, importInfo>; // imported things, mapping from name to importInfo
|
|
123
|
-
classes: Map<string, classInfo>; // classInfo
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function traverse(
|
|
127
|
-
sourceFile: ts.SourceFile,
|
|
128
|
-
f: file,
|
|
129
|
-
classMap: Map<string, file[]>,
|
|
130
|
-
) {
|
|
131
|
-
ts.forEachChild(sourceFile, function (node: ts.Node) {
|
|
132
|
-
switch (node.kind) {
|
|
133
|
-
case ts.SyntaxKind.ImportDeclaration:
|
|
134
|
-
let importNode = node as ts.ImportDeclaration;
|
|
135
|
-
let text = importNode.moduleSpecifier.getText(sourceFile);
|
|
136
|
-
// remove quotes
|
|
137
|
-
text = text.slice(1, -1);
|
|
138
|
-
|
|
139
|
-
let imported = importNode.importClause?.namedBindings;
|
|
140
|
-
if (imported) {
|
|
141
|
-
if (imported?.kind === ts.SyntaxKind.NamedImports) {
|
|
142
|
-
imported.elements.forEach((el) => {
|
|
143
|
-
f.imports.set(el.name.text, {
|
|
144
|
-
name: el.name.text,
|
|
145
|
-
importPath: text,
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
// TODO
|
|
150
|
-
// console.log("ttt?", sourceFile.fileName, text, imported.name);
|
|
151
|
-
}
|
|
152
|
-
} else {
|
|
153
|
-
let name = importNode.importClause?.name?.text;
|
|
154
|
-
if (name) {
|
|
155
|
-
f.imports.set(name, {
|
|
156
|
-
name,
|
|
157
|
-
importPath: text,
|
|
158
|
-
defaultImport: true,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
break;
|
|
164
|
-
case ts.SyntaxKind.ClassDeclaration:
|
|
165
|
-
let classNode = node as ts.ClassDeclaration;
|
|
166
|
-
// console.log(classNode);
|
|
167
|
-
let exported = false;
|
|
168
|
-
let defaultExport = false;
|
|
169
|
-
if (classNode.modifiers?.length) {
|
|
170
|
-
classNode.modifiers.forEach((modifier) => {
|
|
171
|
-
if (modifier.kind === ts.SyntaxKind.ExportKeyword) {
|
|
172
|
-
exported = true;
|
|
173
|
-
}
|
|
174
|
-
if (modifier.kind === ts.SyntaxKind.DefaultKeyword) {
|
|
175
|
-
defaultExport = true;
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
let name = classNode.name?.text;
|
|
180
|
-
if (name) {
|
|
181
|
-
f.classes.set(name, {
|
|
182
|
-
name,
|
|
183
|
-
exported,
|
|
184
|
-
defaultExport,
|
|
185
|
-
});
|
|
186
|
-
if (classMap.has(name)) {
|
|
187
|
-
let files = classMap.get(name)!;
|
|
188
|
-
files.push(f);
|
|
189
|
-
} else {
|
|
190
|
-
let files = [f];
|
|
191
|
-
classMap.set(name, files);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
// TODO functions and other things from files incase needed to disambiguate duplicate classes
|
|
195
|
-
// console.log(classNode.name?.text, exported, defaultExport);
|
|
196
|
-
// classNode.members.forEach((member) => {
|
|
197
|
-
// member.decorators?.forEach((decorator) => {
|
|
198
|
-
// console.log(decorator.expression.getText(sourceFile));
|
|
199
|
-
// });
|
|
200
|
-
// console.log(
|
|
201
|
-
// classNode.name?.text,
|
|
202
|
-
// member.name?.getText(sourceFile),
|
|
203
|
-
// member.decorators?.length,
|
|
204
|
-
// );
|
|
205
|
-
// });
|
|
206
|
-
|
|
207
|
-
// console.log(classNode.modifiers);
|
|
208
|
-
// console.log(classNode);
|
|
209
|
-
// classNode.members.map((member) => console.log(member));
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}
|