@snowtop/ent 0.1.0-alpha160-test7 → 0.1.0-alpha160
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/core/query/shared_assoc_test.d.ts +2 -0
- package/core/query/shared_assoc_test.js +804 -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/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/assoc_query.d.ts +0 -0
- /package/{dist/core → core}/query/assoc_query.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/query.d.ts +0 -0
- /package/{dist/core → core}/query/query.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/test_helpers.js +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
package/src/core/config.ts
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import { load } from "js-yaml";
|
|
3
|
-
import DB, { Database, DBDict } from "./db";
|
|
4
|
-
import * as path from "path";
|
|
5
|
-
import { setLogLevels } from "./logger";
|
|
6
|
-
import { ___setLogQueryErrorWithError, setDefaultLimit } from "./ent";
|
|
7
|
-
|
|
8
|
-
type logType = "query" | "warn" | "info" | "error" | "debug";
|
|
9
|
-
|
|
10
|
-
// ent.config.ts eventually. for now ent.yml
|
|
11
|
-
// or ent.yml?
|
|
12
|
-
|
|
13
|
-
enum graphqlMutationName {
|
|
14
|
-
NOUN_VERB = "NounVerb",
|
|
15
|
-
VERB_NOUN = "VerbNoun",
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
enum graphQLFieldFormat {
|
|
19
|
-
LOWER_CAMEL = "lowerCamel",
|
|
20
|
-
SNAKE_CASE = "snake_case",
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
enum fieldPrivacyEvaluated {
|
|
24
|
-
AT_ENT_LOAD = "at_ent_load",
|
|
25
|
-
ON_DEMAND = "on_demand",
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// runtime configurations
|
|
29
|
-
export interface Config {
|
|
30
|
-
dbConnectionString?: string;
|
|
31
|
-
dbFile?: string; // config/database.yml is default
|
|
32
|
-
db?: Database | DBDict;
|
|
33
|
-
log?: logType | logType[]; // default is 'error'
|
|
34
|
-
// warn will be deprecared or weird things
|
|
35
|
-
// info is tbd. graphql/performance/timing/request stuff
|
|
36
|
-
// query includes cache hit. redis|memcache etc eventually
|
|
37
|
-
|
|
38
|
-
// logQueryWithError
|
|
39
|
-
logQueryWithError?: boolean;
|
|
40
|
-
|
|
41
|
-
// override the default limit for edges and connections.
|
|
42
|
-
// right now, it's 1000 but can be overriden to set a higher or lower limit
|
|
43
|
-
defaultConnectionLimit?: number;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// things that can be set in ent.yml
|
|
47
|
-
export interface ConfigWithCodegen extends Config {
|
|
48
|
-
// config for codegen
|
|
49
|
-
codegen?: CodegenConfig;
|
|
50
|
-
|
|
51
|
-
// because of swc issues, we might not be able to
|
|
52
|
-
// parse custom graphql via decorators so we put this
|
|
53
|
-
// in a json file for now
|
|
54
|
-
// the path should be relative to the root
|
|
55
|
-
// this is hopefully a temporary solution...
|
|
56
|
-
customGraphQLJSONPath?: string;
|
|
57
|
-
|
|
58
|
-
// dynamically add things to be considered in addition to customGraphQLJSONPath
|
|
59
|
-
// see examples for how it's used
|
|
60
|
-
dynamicScriptCustomGraphQLJSONPath?: string;
|
|
61
|
-
|
|
62
|
-
// defaults to __global__schema.ts if not provided
|
|
63
|
-
// relative to src/schema for now
|
|
64
|
-
globalSchemaPath?: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
interface CodegenConfig {
|
|
68
|
-
defaultEntPolicy?: PrivacyConfig;
|
|
69
|
-
defaultActionPolicy?: PrivacyConfig;
|
|
70
|
-
prettier?: PrettierConfig;
|
|
71
|
-
// use relativeImports in generated files instead of "src/ent/user" etc
|
|
72
|
-
// needed for legacy scenarios or situations where the custom compiler has issues
|
|
73
|
-
relativeImports?: boolean;
|
|
74
|
-
// the default graphql root is src/graphql/index.ts
|
|
75
|
-
// if integrating into an existing project (with an existing root) or just
|
|
76
|
-
// want to do something different, set this to true
|
|
77
|
-
disableGraphQLRoot?: boolean;
|
|
78
|
-
// add header to each generated file
|
|
79
|
-
// if provided, we'd generate a header as follows:
|
|
80
|
-
// /**
|
|
81
|
-
// * Copyright blah
|
|
82
|
-
// * Generated by github.com/lolopinto/... DO NOT EDIT.
|
|
83
|
-
//
|
|
84
|
-
// */
|
|
85
|
-
// If not provided, we'd do just:
|
|
86
|
-
// // Generated by github.com/lolopinto/ent, DO NOT EDIT."
|
|
87
|
-
// For files that are generated only once e.g. (src/ent/user.ts), if they exist on disk before this is provided,
|
|
88
|
-
// they are not changed
|
|
89
|
-
generatedHeader?: string;
|
|
90
|
-
|
|
91
|
-
// disable base64encoding of id fields
|
|
92
|
-
// when set to true, id fields aren't resolved with nodeIDEncoder and the actual uuid or integer is sent to the client
|
|
93
|
-
disableBase64Encoding?: boolean;
|
|
94
|
-
|
|
95
|
-
// generateRootResolvers for each type exposed to GraphQL instead of node(). Should be used in combination with
|
|
96
|
-
// disableBase64Encoding
|
|
97
|
-
generateRootResolvers?: boolean;
|
|
98
|
-
|
|
99
|
-
// default names for graphql actions|mutations is nounVerb e.g. userCreate
|
|
100
|
-
// if you wanna change it to verbNoun e.g. createUser, set this field to VERB_NOUN
|
|
101
|
-
defaultGraphQLMutationName?: graphqlMutationName;
|
|
102
|
-
|
|
103
|
-
// default format for fields is lowerCamelCase e.g. firstName
|
|
104
|
-
// if you wanna change it to snake_case e.g. first_name, set this field to snake_case
|
|
105
|
-
defaultGraphQLFieldFormat?: graphQLFieldFormat;
|
|
106
|
-
|
|
107
|
-
// if we should generate schema.sql file and path to generate it
|
|
108
|
-
schemaSQLFilePath?: boolean;
|
|
109
|
-
|
|
110
|
-
// TODO: would be ideal not to need this. so eventually make this work without
|
|
111
|
-
// if there's a schemaSQLFilePath, we compare against an empty database to see what
|
|
112
|
-
// has changed. we need this because if no database is provided, we'd then try and compare
|
|
113
|
-
// against database with same name as user
|
|
114
|
-
databaseToCompareTo?: string;
|
|
115
|
-
|
|
116
|
-
// copied from schema.ts
|
|
117
|
-
// when field privacy is evaluated.
|
|
118
|
-
// field can have privacy policy
|
|
119
|
-
// there's 2 modes of how this is treated that can be configured in ent.yml because it affects codegen
|
|
120
|
-
// 1: evaluate at the time of ent load, we apply the privacy of each object and then apply the privacy of every
|
|
121
|
-
// field which has field privacy and set the property to null if the field is not visible to the viewer
|
|
122
|
-
// The underlying column is no longer in the `data` field of the object
|
|
123
|
-
// 2: generate accessors for the field and all callsites which reference that field will use that.
|
|
124
|
-
// the privacy will be evaluated on demand when needed
|
|
125
|
-
|
|
126
|
-
// default is on_demand
|
|
127
|
-
fieldPrivacyEvaluated?: fieldPrivacyEvaluated;
|
|
128
|
-
|
|
129
|
-
templatizedViewer?: importedObject;
|
|
130
|
-
|
|
131
|
-
// if you want a new base class for AssocEdge e.g. to get extra data stored in custom assoc table
|
|
132
|
-
customAssocEdgePath?: importedObject;
|
|
133
|
-
|
|
134
|
-
// path to add to src/ent/internal.ts so that it's included everywhere
|
|
135
|
-
// where things like global augmentation can be done
|
|
136
|
-
// https://www.typescriptlang.org/docs/handbook/declaration-merging.html#global-augmentation
|
|
137
|
-
globalImportPath?: string;
|
|
138
|
-
|
|
139
|
-
userOveriddenFiles?: string[];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
interface PrettierConfig {
|
|
143
|
-
// indicates you have your own custom prettier configuration and should use that instead of the ent default
|
|
144
|
-
// https://prettier.io/docs/en/configuration.html
|
|
145
|
-
custom?: boolean;
|
|
146
|
-
// default glob is 'src/**/*.ts', can override this
|
|
147
|
-
glob?: string;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
interface PrivacyConfig {
|
|
151
|
-
path: string; // e.g. "@snowtop/ent"
|
|
152
|
-
policyName: string; // e.g. "AllowIfViewerHasIdentityPrivacyPolicy";
|
|
153
|
-
class?: boolean;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
interface importedObject {
|
|
157
|
-
path: string;
|
|
158
|
-
name: string;
|
|
159
|
-
alias?: string;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function setConfig(cfg: Config) {
|
|
163
|
-
if (cfg.log) {
|
|
164
|
-
setLogLevels(cfg.log);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (cfg.dbConnectionString || cfg.dbFile || cfg.db) {
|
|
168
|
-
DB.initDB({
|
|
169
|
-
connectionString: cfg.dbConnectionString,
|
|
170
|
-
dbFile: cfg.dbFile,
|
|
171
|
-
db: cfg.db,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
___setLogQueryErrorWithError(cfg.logQueryWithError);
|
|
176
|
-
|
|
177
|
-
if (cfg.defaultConnectionLimit) {
|
|
178
|
-
setDefaultLimit(cfg.defaultConnectionLimit);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function isBuffer(b: Buffer | Config): b is Buffer {
|
|
183
|
-
return (b as Buffer).write !== undefined;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export function loadConfig(file?: string | Buffer | Config) {
|
|
187
|
-
let data: string;
|
|
188
|
-
if (typeof file === "object") {
|
|
189
|
-
if (!isBuffer(file)) {
|
|
190
|
-
return setConfig(file);
|
|
191
|
-
}
|
|
192
|
-
data = file.toString();
|
|
193
|
-
} else {
|
|
194
|
-
file = file || "ent.yml";
|
|
195
|
-
if (!path.isAbsolute(file)) {
|
|
196
|
-
file = path.join(process.cwd(), file);
|
|
197
|
-
}
|
|
198
|
-
if (!fs.existsSync(file)) {
|
|
199
|
-
return DB.initDB();
|
|
200
|
-
}
|
|
201
|
-
try {
|
|
202
|
-
data = fs.readFileSync(file, { encoding: "utf8" });
|
|
203
|
-
} catch (e) {
|
|
204
|
-
console.error(`error opening file: ${file}`);
|
|
205
|
-
return DB.initDB();
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
try {
|
|
210
|
-
let yaml = load(data);
|
|
211
|
-
if (typeof yaml !== "object") {
|
|
212
|
-
throw new Error(`invalid yaml passed`);
|
|
213
|
-
}
|
|
214
|
-
setConfig(yaml as Config);
|
|
215
|
-
} catch (e) {
|
|
216
|
-
console.error(`error parsing yaml file`, e);
|
|
217
|
-
throw e;
|
|
218
|
-
}
|
|
219
|
-
}
|
package/src/core/const.ts
DELETED
package/src/core/context.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { Viewer, Data, Loader, LoaderWithLoadMany } from "./base";
|
|
2
|
-
import { IncomingMessage, ServerResponse } from "http";
|
|
3
|
-
|
|
4
|
-
import * as clause from "./clause";
|
|
5
|
-
import { log } from "./logger";
|
|
6
|
-
import { Context } from "./base";
|
|
7
|
-
import { OrderBy, getOrderByPhrase } from "./query_impl";
|
|
8
|
-
|
|
9
|
-
// RequestBasedContext e.g. from an HTTP request with a server/response conponent
|
|
10
|
-
export interface RequestContext<TViewer extends Viewer = Viewer>
|
|
11
|
-
extends Context<TViewer> {
|
|
12
|
-
authViewer(viewer: TViewer): Promise<void>; //logs user in and changes viewer to this
|
|
13
|
-
logout(): Promise<void>;
|
|
14
|
-
request: IncomingMessage;
|
|
15
|
-
response: ServerResponse;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class ContextCache {
|
|
19
|
-
loaders: Map<string, Loader<any, any>> = new Map();
|
|
20
|
-
// we should eventually combine the two but better for typing to be separate for now
|
|
21
|
-
loaderWithLoadMany: Map<string, LoaderWithLoadMany<any, any>> = new Map();
|
|
22
|
-
|
|
23
|
-
getLoader<K, V>(name: string, create: () => Loader<K, V>): Loader<K, V> {
|
|
24
|
-
let l = this.loaders.get(name);
|
|
25
|
-
if (l) {
|
|
26
|
-
return l;
|
|
27
|
-
}
|
|
28
|
-
log("debug", `new context-aware loader created for ${name}`);
|
|
29
|
-
l = create();
|
|
30
|
-
this.loaders.set(name, l);
|
|
31
|
-
return l;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
getLoaderWithLoadMany<K, V>(
|
|
35
|
-
name: string,
|
|
36
|
-
create: () => LoaderWithLoadMany<K, V>,
|
|
37
|
-
): LoaderWithLoadMany<K, V> {
|
|
38
|
-
let l = this.loaderWithLoadMany.get(name);
|
|
39
|
-
if (l) {
|
|
40
|
-
return l;
|
|
41
|
-
}
|
|
42
|
-
log("debug", `new context-aware loader created for ${name}`);
|
|
43
|
-
l = create();
|
|
44
|
-
this.loaderWithLoadMany.set(name, l);
|
|
45
|
-
return l;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// we have a per-table map to make it easier to purge and have less things to compare with
|
|
49
|
-
private itemMap: Map<string, Map<string, Data>> = new Map();
|
|
50
|
-
private listMap: Map<string, Map<string, Data[]>> = new Map();
|
|
51
|
-
|
|
52
|
-
// tableName is ignored bcos already indexed on that
|
|
53
|
-
// maybe we just want to store sql queries???
|
|
54
|
-
|
|
55
|
-
private getkey(options: queryOptions): string {
|
|
56
|
-
let parts: string[] = [
|
|
57
|
-
options.fields.join(","),
|
|
58
|
-
options.clause.instanceKey(),
|
|
59
|
-
];
|
|
60
|
-
if (options.orderby) {
|
|
61
|
-
parts.push(getOrderByPhrase(options.orderby));
|
|
62
|
-
}
|
|
63
|
-
return parts.join(",");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
getCachedRows(options: queryOptions): Data[] | null {
|
|
67
|
-
let m = this.listMap.get(options.tableName);
|
|
68
|
-
if (!m) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
const key = this.getkey(options);
|
|
72
|
-
let rows = m.get(key);
|
|
73
|
-
if (rows) {
|
|
74
|
-
log("cache", {
|
|
75
|
-
"cache-hit": key,
|
|
76
|
-
"tableName": options.tableName,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
return rows || null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
getCachedRow(options: queryOptions): Data | null {
|
|
83
|
-
let m = this.itemMap.get(options.tableName);
|
|
84
|
-
if (!m) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
const key = this.getkey(options);
|
|
88
|
-
let row = m.get(key);
|
|
89
|
-
if (row) {
|
|
90
|
-
log("cache", {
|
|
91
|
-
"cache-hit": key,
|
|
92
|
-
"tableName": options.tableName,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
return row || null;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
primeCache(options: queryOptions, rows: Data[]): void;
|
|
99
|
-
primeCache(options: queryOptions, rows: Data): void;
|
|
100
|
-
primeCache(options: queryOptions, rows: Data[] | Data): void {
|
|
101
|
-
if (Array.isArray(rows)) {
|
|
102
|
-
let m = this.listMap.get(options.tableName) || new Map();
|
|
103
|
-
m.set(this.getkey(options), rows);
|
|
104
|
-
this.listMap.set(options.tableName, m);
|
|
105
|
-
} else {
|
|
106
|
-
let m = this.itemMap.get(options.tableName) || new Map();
|
|
107
|
-
m.set(this.getkey(options), rows);
|
|
108
|
-
this.itemMap.set(options.tableName, m);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
clearCache(): void {
|
|
113
|
-
for (const [_key, loader] of this.loaders) {
|
|
114
|
-
// may not need this since we're clearing the loaders themselves...
|
|
115
|
-
// but may have some benefits by explicitily doing so?
|
|
116
|
-
loader.clearAll();
|
|
117
|
-
}
|
|
118
|
-
for (const [_key, loader] of this.loaderWithLoadMany) {
|
|
119
|
-
// may not need this since we're clearing the loaders themselves...
|
|
120
|
-
// but may have some benefits by explicitily doing so?
|
|
121
|
-
loader.clearAll();
|
|
122
|
-
}
|
|
123
|
-
this.loaders.clear();
|
|
124
|
-
this.loaderWithLoadMany.clear();
|
|
125
|
-
this.itemMap.clear();
|
|
126
|
-
this.listMap.clear();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
interface queryOptions {
|
|
131
|
-
fields: string[];
|
|
132
|
-
tableName: string;
|
|
133
|
-
clause: clause.Clause;
|
|
134
|
-
orderby?: OrderBy;
|
|
135
|
-
}
|
package/src/core/convert.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { DateTime } from "luxon";
|
|
2
|
-
// these are needed to deal with SQLite having different types stored in the db vs the representation
|
|
3
|
-
// gotten back from the db/needed in ent land
|
|
4
|
-
// see Sqlite.execSync
|
|
5
|
-
export function convertDate(val: any): Date {
|
|
6
|
-
if (typeof val === "string") {
|
|
7
|
-
// try luxon first if in ISO format. If that doesn't work, fall back to Date.prse
|
|
8
|
-
const dt = DateTime.fromISO(val);
|
|
9
|
-
if (dt.isValid) {
|
|
10
|
-
return dt.toJSDate();
|
|
11
|
-
}
|
|
12
|
-
return new Date(Date.parse(val));
|
|
13
|
-
}
|
|
14
|
-
// assume date
|
|
15
|
-
return val;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function convertNullableDate(val: any): Date | null {
|
|
19
|
-
if (val === null) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
return convertDate(val);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function convertBool(val: any): boolean {
|
|
26
|
-
if (typeof val === "number") {
|
|
27
|
-
// assume 1 or 0
|
|
28
|
-
return val != 0;
|
|
29
|
-
}
|
|
30
|
-
// assume boolean
|
|
31
|
-
return val;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function convertNullableBool(val: any): boolean | null {
|
|
35
|
-
if (val === null) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
return convertBool(val);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function convertList<T>(val: any, conv?: (val: any) => T): T[] {
|
|
42
|
-
if (Array.isArray(val)) {
|
|
43
|
-
return val;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
let res = JSON.parse(val);
|
|
47
|
-
if (!conv) {
|
|
48
|
-
return res;
|
|
49
|
-
}
|
|
50
|
-
if (!Array.isArray(res)) {
|
|
51
|
-
throw new Error(`got a non-array from the db: ${val}`);
|
|
52
|
-
}
|
|
53
|
-
for (let i = 0; i < res.length; i++) {
|
|
54
|
-
res[i] = conv(res[i]);
|
|
55
|
-
}
|
|
56
|
-
return res;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function convertNullableList<T>(
|
|
60
|
-
val: any,
|
|
61
|
-
conv?: (val: any) => T,
|
|
62
|
-
): T[] | null {
|
|
63
|
-
// undefined can happen with unsafe ents
|
|
64
|
-
if (val === null || val === undefined) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
return convertList(val, conv);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function convertDateList(val: any): Date[] {
|
|
71
|
-
return convertList(val, convertDate);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function convertNullableDateList(val: any): Date[] | null {
|
|
75
|
-
return convertNullableList(val, convertDate);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function convertBoolList(val: any): boolean[] {
|
|
79
|
-
return convertList(val, convertBool);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function convertNullableBoolList(val: any): boolean[] | null {
|
|
83
|
-
return convertNullableList(val, convertBool);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function convertJSON(val: any): any {
|
|
87
|
-
if (typeof val === "string") {
|
|
88
|
-
return JSON.parse(val);
|
|
89
|
-
}
|
|
90
|
-
return val;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function convertNullableJSON(val: any): any | null {
|
|
94
|
-
if (val === null) {
|
|
95
|
-
return val;
|
|
96
|
-
}
|
|
97
|
-
return convertJSON(val);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function convertJSONList(val: any): any[] {
|
|
101
|
-
return convertList(val, convertJSON);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function convertNullableJSONList(val: any): any[] | null {
|
|
105
|
-
return convertNullableList(val, convertJSON);
|
|
106
|
-
}
|
package/src/core/date.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { DateTime } from "luxon";
|
|
2
|
-
|
|
3
|
-
export function parseDate(val: any, throwErr: (s: string) => Error): DateTime {
|
|
4
|
-
let dt: DateTime;
|
|
5
|
-
if (typeof val === "number") {
|
|
6
|
-
dt = DateTime.fromMillis(val);
|
|
7
|
-
} else if (typeof val === "string") {
|
|
8
|
-
dt = DateTime.fromISO(val);
|
|
9
|
-
if (!dt.isValid) {
|
|
10
|
-
dt = DateTime.fromMillis(Date.parse(val));
|
|
11
|
-
}
|
|
12
|
-
} else if (val instanceof Date) {
|
|
13
|
-
dt = DateTime.fromJSDate(val);
|
|
14
|
-
} else if (val instanceof DateTime) {
|
|
15
|
-
dt = val;
|
|
16
|
-
} else {
|
|
17
|
-
throw throwErr(`invalid input for type Time ${val}`);
|
|
18
|
-
}
|
|
19
|
-
if (!dt.isValid) {
|
|
20
|
-
throw throwErr(`invalid input for type Time ${val}`);
|
|
21
|
-
}
|
|
22
|
-
return dt;
|
|
23
|
-
}
|