@snowtop/ent 0.1.0-alpha1 → 0.1.0-alpha100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/action/action.d.ts +38 -30
- package/action/action.js +22 -7
- package/action/executor.d.ts +4 -4
- package/action/executor.js +8 -3
- package/action/experimental_action.d.ts +32 -22
- package/action/experimental_action.js +35 -9
- package/action/index.d.ts +2 -0
- package/action/index.js +7 -1
- package/action/orchestrator.d.ts +48 -16
- package/action/orchestrator.js +343 -81
- package/action/privacy.d.ts +2 -2
- package/action/relative_value.d.ts +47 -0
- package/action/relative_value.js +125 -0
- package/action/transaction.d.ts +10 -0
- package/action/transaction.js +23 -0
- package/auth/auth.d.ts +1 -1
- package/core/base.d.ts +54 -27
- package/core/base.js +23 -1
- package/core/clause.d.ts +105 -3
- package/core/clause.js +563 -30
- package/core/config.d.ts +30 -1
- package/core/config.js +24 -1
- package/core/context.d.ts +5 -3
- package/core/context.js +20 -2
- package/core/convert.d.ts +1 -1
- package/core/date.js +1 -5
- package/core/db.d.ts +14 -11
- package/core/db.js +22 -8
- package/core/ent.d.ts +82 -28
- package/core/ent.js +692 -202
- package/core/loaders/assoc_count_loader.d.ts +3 -2
- package/core/loaders/assoc_count_loader.js +10 -2
- package/core/loaders/assoc_edge_loader.d.ts +3 -3
- package/core/loaders/assoc_edge_loader.js +13 -15
- package/core/loaders/index.d.ts +1 -1
- package/core/loaders/index.js +1 -3
- package/core/loaders/index_loader.d.ts +2 -2
- package/core/loaders/index_loader.js +1 -0
- package/core/loaders/loader.js +5 -5
- package/core/loaders/object_loader.d.ts +13 -7
- package/core/loaders/object_loader.js +95 -32
- package/core/loaders/query_loader.d.ts +6 -12
- package/core/loaders/query_loader.js +52 -11
- package/core/loaders/raw_count_loader.d.ts +2 -2
- package/core/loaders/raw_count_loader.js +5 -1
- package/core/logger.d.ts +1 -1
- package/core/logger.js +1 -0
- package/core/privacy.d.ts +26 -25
- package/core/privacy.js +23 -24
- package/core/query/assoc_query.d.ts +7 -6
- package/core/query/assoc_query.js +9 -1
- package/core/query/custom_clause_query.d.ts +26 -0
- package/core/query/custom_clause_query.js +78 -0
- package/core/query/custom_query.d.ts +20 -5
- package/core/query/custom_query.js +87 -12
- package/core/query/index.d.ts +1 -0
- package/core/query/index.js +3 -1
- package/core/query/query.d.ts +8 -4
- package/core/query/query.js +101 -53
- package/core/query/shared_assoc_test.d.ts +2 -1
- package/core/query/shared_assoc_test.js +35 -45
- package/core/query/shared_test.d.ts +8 -1
- package/core/query/shared_test.js +469 -236
- package/core/viewer.d.ts +4 -3
- package/core/viewer.js +5 -1
- package/graphql/builtins/connection.js +3 -3
- package/graphql/builtins/edge.js +2 -2
- package/graphql/builtins/node.js +1 -1
- package/graphql/graphql.d.ts +17 -9
- package/graphql/graphql.js +47 -30
- package/graphql/index.d.ts +1 -1
- package/graphql/index.js +3 -4
- package/graphql/mutations/union.d.ts +2 -0
- package/graphql/mutations/union.js +35 -0
- package/graphql/node_resolver.d.ts +0 -1
- package/graphql/query/connection_type.d.ts +9 -9
- package/graphql/query/connection_type.js +6 -6
- package/graphql/query/edge_connection.d.ts +9 -9
- package/graphql/query/page_info.d.ts +1 -1
- package/graphql/query/page_info.js +4 -4
- package/graphql/query/shared_assoc_test.js +3 -3
- package/graphql/query/shared_edge_connection.js +1 -19
- package/graphql/scalars/time.d.ts +1 -1
- package/imports/index.d.ts +6 -1
- package/imports/index.js +19 -4
- package/index.d.ts +23 -1
- package/index.js +32 -6
- package/package.json +18 -17
- package/parse_schema/parse.d.ts +45 -8
- package/parse_schema/parse.js +193 -15
- package/schema/base_schema.d.ts +38 -1
- package/schema/base_schema.js +53 -2
- package/schema/field.d.ts +75 -21
- package/schema/field.js +185 -72
- package/schema/index.d.ts +4 -2
- package/schema/index.js +15 -2
- package/schema/json_field.d.ts +13 -1
- package/schema/json_field.js +28 -1
- package/schema/schema.d.ts +125 -10
- package/schema/schema.js +133 -5
- package/schema/struct_field.d.ts +27 -0
- package/schema/struct_field.js +138 -0
- package/schema/union_field.d.ts +23 -0
- package/schema/union_field.js +79 -0
- package/scripts/custom_compiler.js +10 -6
- package/scripts/custom_graphql.js +224 -36
- package/scripts/{transform_schema.d.ts → migrate_v0.1.d.ts} +0 -0
- package/scripts/migrate_v0.1.js +36 -0
- package/scripts/move_types.d.ts +1 -0
- package/scripts/move_types.js +117 -0
- package/scripts/read_schema.js +35 -6
- package/testutils/action/complex_schemas.d.ts +69 -0
- package/testutils/action/complex_schemas.js +398 -0
- package/testutils/builder.d.ts +52 -49
- package/testutils/builder.js +143 -44
- package/testutils/context/test_context.d.ts +2 -2
- package/testutils/context/test_context.js +7 -1
- package/testutils/db/fixture.d.ts +10 -0
- package/testutils/db/fixture.js +26 -0
- package/testutils/db/{test_db.d.ts → temp_db.d.ts} +26 -9
- package/testutils/db/{test_db.js → temp_db.js} +190 -46
- package/testutils/db/value.d.ts +7 -0
- package/testutils/db/value.js +251 -0
- package/testutils/db_mock.d.ts +16 -4
- package/testutils/db_mock.js +51 -6
- package/testutils/db_time_zone.d.ts +4 -0
- package/testutils/db_time_zone.js +41 -0
- package/testutils/ent-graphql-tests/index.d.ts +9 -1
- package/testutils/ent-graphql-tests/index.js +53 -25
- package/testutils/fake_data/const.d.ts +2 -1
- package/testutils/fake_data/const.js +3 -0
- package/testutils/fake_data/fake_contact.d.ts +10 -10
- package/testutils/fake_data/fake_contact.js +23 -21
- package/testutils/fake_data/fake_event.d.ts +8 -9
- package/testutils/fake_data/fake_event.js +25 -28
- package/testutils/fake_data/fake_tag.d.ts +36 -0
- package/testutils/fake_data/fake_tag.js +89 -0
- package/testutils/fake_data/fake_user.d.ts +10 -11
- package/testutils/fake_data/fake_user.js +20 -23
- package/testutils/fake_data/index.js +5 -1
- package/testutils/fake_data/internal.d.ts +2 -0
- package/testutils/fake_data/internal.js +7 -1
- package/testutils/fake_data/tag_query.d.ts +13 -0
- package/testutils/fake_data/tag_query.js +43 -0
- package/testutils/fake_data/test_helpers.d.ts +11 -4
- package/testutils/fake_data/test_helpers.js +29 -13
- package/testutils/fake_data/user_query.d.ts +13 -6
- package/testutils/fake_data/user_query.js +54 -22
- package/testutils/fake_log.d.ts +3 -3
- package/testutils/parse_sql.d.ts +6 -0
- package/testutils/parse_sql.js +16 -2
- package/testutils/test_edge_global_schema.d.ts +15 -0
- package/testutils/test_edge_global_schema.js +62 -0
- package/testutils/write.d.ts +2 -2
- package/testutils/write.js +33 -7
- package/tsc/ast.d.ts +44 -0
- package/tsc/ast.js +277 -0
- package/tsc/compilerOptions.d.ts +6 -0
- package/tsc/compilerOptions.js +45 -2
- package/tsc/move_generated.d.ts +1 -0
- package/tsc/move_generated.js +164 -0
- package/tsc/transform.d.ts +22 -0
- package/tsc/transform.js +181 -0
- package/tsc/transform_action.d.ts +22 -0
- package/tsc/transform_action.js +183 -0
- package/tsc/transform_ent.d.ts +17 -0
- package/tsc/transform_ent.js +59 -0
- package/tsc/transform_schema.d.ts +27 -0
- package/tsc/transform_schema.js +383 -0
- package/graphql/enums.d.ts +0 -3
- package/graphql/enums.js +0 -25
- package/scripts/transform_schema.js +0 -288
package/imports/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -34,7 +38,11 @@ function getFiles(filePath, opts) {
|
|
|
34
38
|
}
|
|
35
39
|
// graphql path should be passed to this
|
|
36
40
|
// this is more agnostic about what it expect here
|
|
37
|
-
let
|
|
41
|
+
let pattern = `${filePath}/**/*.ts`;
|
|
42
|
+
if (opts?.justCurrentDir) {
|
|
43
|
+
pattern = `${filePath}/**.ts`;
|
|
44
|
+
}
|
|
45
|
+
let files = glob_1.default.sync(pattern, {
|
|
38
46
|
ignore: opts?.ignore,
|
|
39
47
|
});
|
|
40
48
|
if (opts?.filter) {
|
|
@@ -42,8 +50,15 @@ function getFiles(filePath, opts) {
|
|
|
42
50
|
}
|
|
43
51
|
return files;
|
|
44
52
|
}
|
|
45
|
-
function parseCustomImports(filePath,
|
|
46
|
-
const files =
|
|
53
|
+
function parseCustomImports(filePath, inputs) {
|
|
54
|
+
const files = [];
|
|
55
|
+
// simplifies tests and other simple callsites
|
|
56
|
+
if (inputs.length === 0) {
|
|
57
|
+
inputs.push({ root: filePath });
|
|
58
|
+
}
|
|
59
|
+
for (const input of inputs) {
|
|
60
|
+
files.push(...getFiles(input.root, input.opts));
|
|
61
|
+
}
|
|
47
62
|
const options = (0, compilerOptions_1.readCompilerOptions)(filePath);
|
|
48
63
|
let classMap = new Map();
|
|
49
64
|
files.forEach((file) => {
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./core/base";
|
|
2
|
-
export { loadEnt, loadCustomData, loadCustomEnts, loadEntX, loadEnts, CustomQuery, loadDerivedEnt, loadDerivedEntX, loadEntViaKey, loadEntXViaKey,
|
|
2
|
+
export { loadEnt, loadCustomData, loadCustomEnts, loadCustomCount, loadEntX, loadEnts, CustomQuery, loadDerivedEnt, loadDerivedEntX, loadEntViaKey, loadEntXViaKey, performRawQuery, loadRowX, loadRow, loadRows, DataOperation, EditNodeOptions, EditNodeOperation, RawQueryOperation, EdgeOperation, DeleteNodeOperation, AssocEdge, AssocEdgeInputOptions, AssocEdgeInput, AssocEdgeData, loadEdgeData, loadEdgeDatas, loadEdges, loadUniqueEdge, loadUniqueNode, loadRawEdgeCountX, loadEdgeForID2, loadNodesByEdge, getEdgeTypeInGroup, setGlobalSchema, } from "./core/ent";
|
|
3
3
|
import DB from "./core/db";
|
|
4
4
|
export * from "./core/loaders";
|
|
5
5
|
export { DB };
|
|
@@ -7,16 +7,38 @@ export { EntPrivacyError, AlwaysAllowRule, AlwaysDenyRule, DenyIfLoggedInRule, D
|
|
|
7
7
|
export * from "./core/query";
|
|
8
8
|
export * from "./schema/";
|
|
9
9
|
import * as q from "./core/clause";
|
|
10
|
+
export { Clause } from "./core/clause";
|
|
10
11
|
declare const query: {
|
|
11
12
|
Eq: typeof q.Eq;
|
|
12
13
|
NotEq: typeof q.NotEq;
|
|
13
14
|
And: typeof q.And;
|
|
15
|
+
AndOptional: typeof q.AndOptional;
|
|
14
16
|
Or: typeof q.Or;
|
|
17
|
+
OrOptional: typeof q.OrOptional;
|
|
15
18
|
In: typeof q.In;
|
|
16
19
|
Greater: typeof q.Greater;
|
|
17
20
|
Less: typeof q.Less;
|
|
18
21
|
GreaterEq: typeof q.GreaterEq;
|
|
19
22
|
LessEq: typeof q.LessEq;
|
|
23
|
+
ArrayEq: typeof q.ArrayEq;
|
|
24
|
+
ArrayNotEq: typeof q.ArrayNotEq;
|
|
25
|
+
PostgresArrayContainsValue: typeof q.PostgresArrayContainsValue;
|
|
26
|
+
PostgresArrayContains: typeof q.PostgresArrayContains;
|
|
27
|
+
PostgresArrayNotContainsValue: typeof q.PostgresArrayNotContainsValue;
|
|
28
|
+
PostgresArrayNotContains: typeof q.PostgresArrayNotContains;
|
|
29
|
+
PostgresArrayOverlaps: typeof q.PostgresArrayOverlaps;
|
|
30
|
+
PostgresArrayNotOverlaps: typeof q.PostgresArrayNotOverlaps;
|
|
31
|
+
JSONPathValuePredicate: typeof q.JSONPathValuePredicate;
|
|
32
|
+
JSONObjectFieldKeyASJSON: typeof q.JSONObjectFieldKeyASJSON;
|
|
33
|
+
JSONObjectFieldKeyAsText: typeof q.JSONObjectFieldKeyAsText;
|
|
34
|
+
TsQuery: typeof q.TsQuery;
|
|
35
|
+
PlainToTsQuery: typeof q.PlainToTsQuery;
|
|
36
|
+
PhraseToTsQuery: typeof q.PhraseToTsQuery;
|
|
37
|
+
WebsearchToTsQuery: typeof q.WebsearchToTsQuery;
|
|
38
|
+
TsVectorColTsQuery: typeof q.TsVectorColTsQuery;
|
|
39
|
+
TsVectorPlainToTsQuery: typeof q.TsVectorPlainToTsQuery;
|
|
40
|
+
TsVectorPhraseToTsQuery: typeof q.TsVectorPhraseToTsQuery;
|
|
41
|
+
TsVectorWebsearchToTsQuery: typeof q.TsVectorWebsearchToTsQuery;
|
|
20
42
|
};
|
|
21
43
|
export { query };
|
|
22
44
|
export { RequestContext, ContextCache } from "./core/context";
|
package/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -25,27 +29,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
30
|
};
|
|
27
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.
|
|
29
|
-
exports.setLogLevels = exports.loadConfig = exports.LoggedOutViewer = exports.IDViewer = exports.ContextCache = exports.query = exports.AllowIfViewerHasIdentityPrivacyPolicy = exports.AllowIfViewerPrivacyPolicy = exports.AllowIfSubPolicyAllowsRule = exports.AllowIfConditionAppliesRule = exports.AlwaysDenyPrivacyPolicy = exports.AlwaysAllowPrivacyPolicy = exports.applyPrivacyPolicyX = exports.applyPrivacyPolicy = exports.DelayedResultRule = exports.DenyIfEntIsVisiblePolicy = exports.AllowIfEntIsVisiblePolicy = exports.DenyIfEntIsNotVisibleRule = exports.DenyIfEntIsVisibleRule = exports.AllowIfEntIsNotVisibleRule = exports.AllowIfEntIsVisibleRule = exports.DenyIfViewerOutboundEdgeDoesNotExistRule = exports.DenyIfViewerInboundEdgeDoesNotExistRule = exports.DenyIfEdgeDoesNotExistRule = void 0;
|
|
32
|
+
exports.DenyIfViewerInboundEdgeExistsRule = exports.DenyIfEdgeExistsRule = exports.AllowIfViewerOutboundEdgeExistsRule = exports.AllowIfViewerInboundEdgeExistsRule = exports.AllowIfEdgeExistsRule = exports.DenyIfViewerEqualsRule = exports.AllowIfViewerEqualsRule = exports.DenyIfEntPropertyIsRule = exports.AllowIfEntPropertyIsRule = exports.AllowIfViewerIsEntPropertyRule = exports.AllowIfViewerIsRule = exports.AllowIfFuncRule = exports.AllowIfViewerRule = exports.AllowIfHasIdentity = exports.DenyIfLoggedOutRule = exports.DenyIfLoggedInRule = exports.AlwaysDenyRule = exports.AlwaysAllowRule = exports.EntPrivacyError = exports.DB = exports.setGlobalSchema = exports.getEdgeTypeInGroup = exports.loadNodesByEdge = exports.loadEdgeForID2 = exports.loadRawEdgeCountX = exports.loadUniqueNode = exports.loadUniqueEdge = exports.loadEdges = exports.loadEdgeDatas = exports.loadEdgeData = exports.AssocEdgeData = exports.AssocEdge = exports.DeleteNodeOperation = exports.EdgeOperation = exports.RawQueryOperation = exports.EditNodeOperation = exports.loadRows = exports.loadRow = exports.loadRowX = exports.performRawQuery = exports.loadEntXViaKey = exports.loadEntViaKey = exports.loadDerivedEntX = exports.loadDerivedEnt = exports.loadEnts = exports.loadEntX = exports.loadCustomCount = exports.loadCustomEnts = exports.loadCustomData = exports.loadEnt = void 0;
|
|
33
|
+
exports.setLogLevels = exports.loadConfig = exports.LoggedOutViewer = exports.IDViewer = exports.ContextCache = exports.query = exports.AllowIfViewerHasIdentityPrivacyPolicy = exports.AllowIfViewerPrivacyPolicy = exports.AllowIfSubPolicyAllowsRule = exports.AllowIfConditionAppliesRule = exports.AlwaysDenyPrivacyPolicy = exports.AlwaysAllowPrivacyPolicy = exports.applyPrivacyPolicyX = exports.applyPrivacyPolicy = exports.DelayedResultRule = exports.DenyIfEntIsVisiblePolicy = exports.AllowIfEntIsVisiblePolicy = exports.DenyIfEntIsNotVisibleRule = exports.DenyIfEntIsVisibleRule = exports.AllowIfEntIsNotVisibleRule = exports.AllowIfEntIsVisibleRule = exports.DenyIfViewerOutboundEdgeDoesNotExistRule = exports.DenyIfViewerInboundEdgeDoesNotExistRule = exports.DenyIfEdgeDoesNotExistRule = exports.DenyIfViewerOutboundEdgeExistsRule = void 0;
|
|
30
34
|
__exportStar(require("./core/base"), exports);
|
|
31
35
|
var ent_1 = require("./core/ent");
|
|
32
36
|
Object.defineProperty(exports, "loadEnt", { enumerable: true, get: function () { return ent_1.loadEnt; } });
|
|
33
37
|
Object.defineProperty(exports, "loadCustomData", { enumerable: true, get: function () { return ent_1.loadCustomData; } });
|
|
34
38
|
Object.defineProperty(exports, "loadCustomEnts", { enumerable: true, get: function () { return ent_1.loadCustomEnts; } });
|
|
39
|
+
Object.defineProperty(exports, "loadCustomCount", { enumerable: true, get: function () { return ent_1.loadCustomCount; } });
|
|
35
40
|
Object.defineProperty(exports, "loadEntX", { enumerable: true, get: function () { return ent_1.loadEntX; } });
|
|
36
41
|
Object.defineProperty(exports, "loadEnts", { enumerable: true, get: function () { return ent_1.loadEnts; } });
|
|
37
42
|
Object.defineProperty(exports, "loadDerivedEnt", { enumerable: true, get: function () { return ent_1.loadDerivedEnt; } });
|
|
38
43
|
Object.defineProperty(exports, "loadDerivedEntX", { enumerable: true, get: function () { return ent_1.loadDerivedEntX; } });
|
|
39
44
|
Object.defineProperty(exports, "loadEntViaKey", { enumerable: true, get: function () { return ent_1.loadEntViaKey; } });
|
|
40
45
|
Object.defineProperty(exports, "loadEntXViaKey", { enumerable: true, get: function () { return ent_1.loadEntXViaKey; } });
|
|
41
|
-
Object.defineProperty(exports, "applyPrivacyPolicyForEnt", { enumerable: true, get: function () { return ent_1.applyPrivacyPolicyForEnt; } });
|
|
42
|
-
Object.defineProperty(exports, "applyPrivacyPolicyForEntX", { enumerable: true, get: function () { return ent_1.applyPrivacyPolicyForEntX; } });
|
|
43
46
|
Object.defineProperty(exports, "performRawQuery", { enumerable: true, get: function () { return ent_1.performRawQuery; } });
|
|
44
47
|
// even these 3 need to change...
|
|
45
48
|
Object.defineProperty(exports, "loadRowX", { enumerable: true, get: function () { return ent_1.loadRowX; } });
|
|
46
49
|
Object.defineProperty(exports, "loadRow", { enumerable: true, get: function () { return ent_1.loadRow; } });
|
|
47
50
|
Object.defineProperty(exports, "loadRows", { enumerable: true, get: function () { return ent_1.loadRows; } });
|
|
48
51
|
Object.defineProperty(exports, "EditNodeOperation", { enumerable: true, get: function () { return ent_1.EditNodeOperation; } });
|
|
52
|
+
Object.defineProperty(exports, "RawQueryOperation", { enumerable: true, get: function () { return ent_1.RawQueryOperation; } });
|
|
49
53
|
Object.defineProperty(exports, "EdgeOperation", { enumerable: true, get: function () { return ent_1.EdgeOperation; } });
|
|
50
54
|
Object.defineProperty(exports, "DeleteNodeOperation", { enumerable: true, get: function () { return ent_1.DeleteNodeOperation; } });
|
|
51
55
|
Object.defineProperty(exports, "AssocEdge", { enumerable: true, get: function () { return ent_1.AssocEdge; } });
|
|
@@ -59,10 +63,11 @@ Object.defineProperty(exports, "loadRawEdgeCountX", { enumerable: true, get: fun
|
|
|
59
63
|
Object.defineProperty(exports, "loadEdgeForID2", { enumerable: true, get: function () { return ent_1.loadEdgeForID2; } });
|
|
60
64
|
Object.defineProperty(exports, "loadNodesByEdge", { enumerable: true, get: function () { return ent_1.loadNodesByEdge; } });
|
|
61
65
|
Object.defineProperty(exports, "getEdgeTypeInGroup", { enumerable: true, get: function () { return ent_1.getEdgeTypeInGroup; } });
|
|
66
|
+
Object.defineProperty(exports, "setGlobalSchema", { enumerable: true, get: function () { return ent_1.setGlobalSchema; } });
|
|
62
67
|
const db_1 = __importDefault(require("./core/db"));
|
|
63
68
|
exports.DB = db_1.default;
|
|
64
69
|
__exportStar(require("./core/loaders"), exports);
|
|
65
|
-
// TODO figure out if this should be its own
|
|
70
|
+
// TODO figure out if this should be its own import path e.g. @snowtop/ent/privacy
|
|
66
71
|
var privacy_1 = require("./core/privacy");
|
|
67
72
|
Object.defineProperty(exports, "EntPrivacyError", { enumerable: true, get: function () { return privacy_1.EntPrivacyError; } });
|
|
68
73
|
Object.defineProperty(exports, "AlwaysAllowRule", { enumerable: true, get: function () { return privacy_1.AlwaysAllowRule; } });
|
|
@@ -109,12 +114,33 @@ const query = {
|
|
|
109
114
|
Eq: q.Eq,
|
|
110
115
|
NotEq: q.NotEq,
|
|
111
116
|
And: q.And,
|
|
117
|
+
AndOptional: q.AndOptional,
|
|
112
118
|
Or: q.Or,
|
|
119
|
+
OrOptional: q.OrOptional,
|
|
113
120
|
In: q.In,
|
|
114
121
|
Greater: q.Greater,
|
|
115
122
|
Less: q.Less,
|
|
116
123
|
GreaterEq: q.GreaterEq,
|
|
117
124
|
LessEq: q.LessEq,
|
|
125
|
+
ArrayEq: q.ArrayEq,
|
|
126
|
+
ArrayNotEq: q.ArrayNotEq,
|
|
127
|
+
PostgresArrayContainsValue: q.PostgresArrayContainsValue,
|
|
128
|
+
PostgresArrayContains: q.PostgresArrayContains,
|
|
129
|
+
PostgresArrayNotContainsValue: q.PostgresArrayNotContainsValue,
|
|
130
|
+
PostgresArrayNotContains: q.PostgresArrayNotContains,
|
|
131
|
+
PostgresArrayOverlaps: q.PostgresArrayOverlaps,
|
|
132
|
+
PostgresArrayNotOverlaps: q.PostgresArrayNotOverlaps,
|
|
133
|
+
JSONPathValuePredicate: q.JSONPathValuePredicate,
|
|
134
|
+
JSONObjectFieldKeyASJSON: q.JSONObjectFieldKeyASJSON,
|
|
135
|
+
JSONObjectFieldKeyAsText: q.JSONObjectFieldKeyAsText,
|
|
136
|
+
TsQuery: q.TsQuery,
|
|
137
|
+
PlainToTsQuery: q.PlainToTsQuery,
|
|
138
|
+
PhraseToTsQuery: q.PhraseToTsQuery,
|
|
139
|
+
WebsearchToTsQuery: q.WebsearchToTsQuery,
|
|
140
|
+
TsVectorColTsQuery: q.TsVectorColTsQuery,
|
|
141
|
+
TsVectorPlainToTsQuery: q.TsVectorPlainToTsQuery,
|
|
142
|
+
TsVectorPhraseToTsQuery: q.TsVectorPhraseToTsQuery,
|
|
143
|
+
TsVectorWebsearchToTsQuery: q.TsVectorWebsearchToTsQuery,
|
|
118
144
|
};
|
|
119
145
|
exports.query = query;
|
|
120
146
|
var context_1 = require("./core/context");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snowtop/ent",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-alpha100",
|
|
4
4
|
"description": "snowtop ent framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -8,30 +8,31 @@
|
|
|
8
8
|
"example": "examples"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@types/node": "^
|
|
11
|
+
"@types/node": "^18.11.18",
|
|
12
12
|
"camel-case": "^4.1.2",
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
13
|
+
"cosmiconfig": "^8.0.0",
|
|
14
|
+
"dataloader": "^2.1.0",
|
|
15
|
+
"glob": "^8.0.3",
|
|
16
|
+
"graph-data-structure": "^2.0.0",
|
|
16
17
|
"js-yaml": "^4.1.0",
|
|
17
|
-
"json5": "^2.
|
|
18
|
-
"luxon": "^1.
|
|
18
|
+
"json5": "^2.2.2",
|
|
19
|
+
"luxon": "^3.1.1",
|
|
19
20
|
"memoizee": "^0.4.15",
|
|
20
|
-
"minimist": "^1.2.
|
|
21
|
+
"minimist": "^1.2.7",
|
|
21
22
|
"pascal-case": "^3.1.2",
|
|
22
|
-
"pg": "^8.0
|
|
23
|
-
"prettier": "^2.
|
|
23
|
+
"pg": "^8.8.0",
|
|
24
|
+
"prettier": "^2.8.1",
|
|
24
25
|
"reflect-metadata": "^0.1.13",
|
|
25
|
-
"snake-case": "^3.0.
|
|
26
|
-
"ts-node": "^10.
|
|
27
|
-
"tsconfig-paths": "^
|
|
28
|
-
"tslib": "^2.
|
|
29
|
-
"typescript": "^4.4
|
|
30
|
-
"uuid": "^
|
|
26
|
+
"snake-case": "^3.0.4",
|
|
27
|
+
"ts-node": "^10.9.1",
|
|
28
|
+
"tsconfig-paths": "^4.1.1",
|
|
29
|
+
"tslib": "^2.4.1",
|
|
30
|
+
"typescript": "^4.9.4",
|
|
31
|
+
"uuid": "^9.0.0"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
34
|
"better-sqlite3": "^7.4.1",
|
|
34
|
-
"graphql": "^
|
|
35
|
+
"graphql": "^16.5.0"
|
|
35
36
|
},
|
|
36
37
|
"peerDependenciesMeta": {
|
|
37
38
|
"better-sqlite3": {
|
package/parse_schema/parse.d.ts
CHANGED
|
@@ -1,27 +1,35 @@
|
|
|
1
1
|
import { Schema, Field, AssocEdge, AssocEdgeGroup, Action } from "../schema";
|
|
2
|
-
import { ActionField } from "../schema/schema";
|
|
2
|
+
import { ActionField, Type, GlobalSchema } from "../schema/schema";
|
|
3
3
|
declare enum NullableResult {
|
|
4
4
|
CONTENTS = "contents",
|
|
5
5
|
CONTENTS_AND_LIST = "contentsAndList",
|
|
6
6
|
ITEM = "true"
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
type ProcessedActionField = Omit<ActionField, "nullable"> & {
|
|
9
9
|
nullable?: NullableResult;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type ProcessedAssocEdge = Omit<AssocEdge, "actionOnlyFields" | "edgeActions"> & {
|
|
12
12
|
patternName?: string;
|
|
13
13
|
edgeActions?: OutputAction[];
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
interface TransformFlags {
|
|
16
|
+
transformsSelect?: boolean;
|
|
17
|
+
transformsDelete?: boolean;
|
|
18
|
+
transformsInsert?: boolean;
|
|
19
|
+
transformsUpdate?: boolean;
|
|
20
|
+
}
|
|
21
|
+
type ProcessedSchema = Omit<Schema, "edges" | "actions" | "edgeGroups" | "fields"> & TransformFlags & {
|
|
16
22
|
actions: OutputAction[];
|
|
17
23
|
assocEdges: ProcessedAssocEdge[];
|
|
18
24
|
assocEdgeGroups: ProcessedAssocEdgeGroup[];
|
|
19
25
|
fields: ProcessedField[];
|
|
26
|
+
schemaPath?: string;
|
|
27
|
+
patternNames?: string[];
|
|
20
28
|
};
|
|
21
|
-
|
|
29
|
+
type ProcessedAssocEdgeGroup = Omit<AssocEdgeGroup, "edgeAction"> & {
|
|
22
30
|
edgeAction?: OutputAction;
|
|
23
31
|
};
|
|
24
|
-
|
|
32
|
+
type OutputAction = Omit<Action, "actionOnlyFields"> & {
|
|
25
33
|
actionOnlyFields?: ProcessedActionField[];
|
|
26
34
|
};
|
|
27
35
|
interface schemasDict {
|
|
@@ -31,13 +39,22 @@ interface ProcessedPattern {
|
|
|
31
39
|
name: string;
|
|
32
40
|
assocEdges: ProcessedAssocEdge[];
|
|
33
41
|
fields: ProcessedField[];
|
|
42
|
+
disableMixin?: boolean;
|
|
34
43
|
}
|
|
35
|
-
|
|
44
|
+
type ProcessedType = Omit<Type, "subFields" | "listElemType" | "unionFields"> & {
|
|
45
|
+
subFields?: ProcessedField[];
|
|
46
|
+
listElemType?: ProcessedType;
|
|
47
|
+
unionFields?: ProcessedField[];
|
|
48
|
+
};
|
|
49
|
+
type ProcessedField = Omit<Field, "defaultValueOnEdit" | "defaultValueOnCreate" | "privacyPolicy" | "type" | "serverDefault"> & {
|
|
36
50
|
name: string;
|
|
37
51
|
hasDefaultValueOnCreate?: boolean;
|
|
38
52
|
hasDefaultValueOnEdit?: boolean;
|
|
39
53
|
patternName?: string;
|
|
54
|
+
hasFieldPrivacy?: boolean;
|
|
40
55
|
derivedFields?: ProcessedField[];
|
|
56
|
+
type: ProcessedType;
|
|
57
|
+
serverDefault?: string;
|
|
41
58
|
};
|
|
42
59
|
interface patternsDict {
|
|
43
60
|
[key: string]: ProcessedPattern;
|
|
@@ -45,6 +62,26 @@ interface patternsDict {
|
|
|
45
62
|
interface Result {
|
|
46
63
|
schemas: schemasDict;
|
|
47
64
|
patterns: patternsDict;
|
|
65
|
+
globalSchema?: ProcessedGlobalSchema;
|
|
66
|
+
config?: {
|
|
67
|
+
rome?: RomeConfig;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
declare type PotentialSchemas = {
|
|
71
|
+
[key: string]: any;
|
|
72
|
+
};
|
|
73
|
+
export declare function parseSchema(potentialSchemas: PotentialSchemas, globalSchema?: GlobalSchema): Promise<Result>;
|
|
74
|
+
interface RomeConfig {
|
|
75
|
+
indentStyle?: string;
|
|
76
|
+
lineWidth?: number;
|
|
77
|
+
indentSize?: number;
|
|
78
|
+
quoteStyle?: string;
|
|
79
|
+
quoteProperties?: string;
|
|
80
|
+
trailingComma?: string;
|
|
81
|
+
}
|
|
82
|
+
interface ProcessedGlobalSchema {
|
|
83
|
+
globalEdges: ProcessedAssocEdge[];
|
|
84
|
+
extraEdgeFields: ProcessedField[];
|
|
85
|
+
initForEdges?: boolean;
|
|
48
86
|
}
|
|
49
|
-
export declare function parseSchema(potentialSchemas: {}): Result;
|
|
50
87
|
export {};
|
package/parse_schema/parse.js
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseSchema = void 0;
|
|
4
|
-
|
|
4
|
+
const cosmiconfig_1 = require("cosmiconfig");
|
|
5
|
+
async function processFields(src, patternName) {
|
|
5
6
|
const ret = [];
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
let m = {};
|
|
8
|
+
if (Array.isArray(src)) {
|
|
9
|
+
for (const field of src) {
|
|
10
|
+
const name = field.name;
|
|
11
|
+
if (!name) {
|
|
12
|
+
throw new Error(`name is required`);
|
|
13
|
+
}
|
|
14
|
+
m[name] = field;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
m = src;
|
|
19
|
+
}
|
|
20
|
+
for (const name in m) {
|
|
21
|
+
const field = m[name];
|
|
22
|
+
//@ts-ignore type and other changed fields with different type in ProcessedField vs Field
|
|
8
23
|
let f = { name, ...field };
|
|
9
24
|
f.hasDefaultValueOnCreate = field.defaultValueOnCreate != undefined;
|
|
10
25
|
f.hasDefaultValueOnEdit = field.defaultValueOnEdit != undefined;
|
|
26
|
+
f.hasFieldPrivacy = field.privacyPolicy !== undefined;
|
|
11
27
|
if (field.polymorphic) {
|
|
12
28
|
// convert boolean into object
|
|
13
29
|
// we keep boolean as an option to keep API simple
|
|
@@ -21,6 +37,19 @@ function processFields(src, patternName) {
|
|
|
21
37
|
else {
|
|
22
38
|
delete f.polymorphic;
|
|
23
39
|
}
|
|
40
|
+
if (field.private) {
|
|
41
|
+
// convert boolean into object
|
|
42
|
+
// we keep boolean as an option to keep API simple
|
|
43
|
+
if (typeof field.private === "boolean") {
|
|
44
|
+
f.private = {};
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
f.private = field.private;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
delete f.private;
|
|
52
|
+
}
|
|
24
53
|
// convert string to object to make API consumed by go simple
|
|
25
54
|
if (f.fieldEdge && f.fieldEdge.inverseEdge) {
|
|
26
55
|
if (typeof f.fieldEdge.inverseEdge === "string") {
|
|
@@ -32,13 +61,66 @@ function processFields(src, patternName) {
|
|
|
32
61
|
if (patternName) {
|
|
33
62
|
f.patternName = patternName;
|
|
34
63
|
}
|
|
64
|
+
if (field.serverDefault !== undefined) {
|
|
65
|
+
f.serverDefault = await transformServerDefault(name, field, field.serverDefault);
|
|
66
|
+
}
|
|
67
|
+
transformType(field.type);
|
|
35
68
|
if (field.getDerivedFields) {
|
|
36
|
-
f.derivedFields = processFields(field.getDerivedFields(name));
|
|
69
|
+
f.derivedFields = await processFields(field.getDerivedFields(name));
|
|
70
|
+
}
|
|
71
|
+
if (field.type.subFields) {
|
|
72
|
+
f.type.subFields = await processFields(field.type.subFields);
|
|
73
|
+
}
|
|
74
|
+
if (field.type.unionFields) {
|
|
75
|
+
f.type.unionFields = await processFields(field.type.unionFields);
|
|
76
|
+
}
|
|
77
|
+
if (field.type.listElemType &&
|
|
78
|
+
field.type.listElemType.subFields &&
|
|
79
|
+
// check to avoid ts-ignore below. exists just for tsc
|
|
80
|
+
f.type.listElemType) {
|
|
81
|
+
f.type.listElemType.subFields = await processFields(field.type.listElemType.subFields);
|
|
37
82
|
}
|
|
38
83
|
ret.push(f);
|
|
39
84
|
}
|
|
40
85
|
return ret;
|
|
41
86
|
}
|
|
87
|
+
async function transformServerDefault(name, f, value) {
|
|
88
|
+
if (f.valid) {
|
|
89
|
+
if (!(await f.valid(value))) {
|
|
90
|
+
throw new Error(`invalid value ${value} passed to field ${name}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (f.format) {
|
|
94
|
+
value = await f.format(value);
|
|
95
|
+
}
|
|
96
|
+
switch (typeof value) {
|
|
97
|
+
case "boolean":
|
|
98
|
+
case "number":
|
|
99
|
+
case "bigint":
|
|
100
|
+
case "string":
|
|
101
|
+
return `${value}`;
|
|
102
|
+
default:
|
|
103
|
+
throw new Error(`invalid value ${value} passed to field ${name}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function transformImportType(typ) {
|
|
107
|
+
if (!typ.importType) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
typ.importType = {
|
|
111
|
+
...typ.importType,
|
|
112
|
+
// these 2 needed for forwards compatibility with new go schema
|
|
113
|
+
importPath: typ.importType.path,
|
|
114
|
+
import: typ.importType.type,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function transformType(typ) {
|
|
118
|
+
if (!typ) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
transformImportType(typ);
|
|
122
|
+
transformType(typ.listElemType);
|
|
123
|
+
}
|
|
42
124
|
function processEdges(src, patternName) {
|
|
43
125
|
const ret = [];
|
|
44
126
|
for (const edge of src) {
|
|
@@ -62,14 +144,21 @@ function processEdgeGroups(processedSchema, edgeGroups) {
|
|
|
62
144
|
processedSchema.assocEdgeGroups.push(group2);
|
|
63
145
|
}
|
|
64
146
|
}
|
|
65
|
-
function processPattern(patterns, pattern, processedSchema) {
|
|
147
|
+
async function processPattern(patterns, pattern, processedSchema) {
|
|
148
|
+
let ret = {
|
|
149
|
+
...pattern,
|
|
150
|
+
};
|
|
66
151
|
const name = pattern.name;
|
|
67
|
-
const fields = processFields(pattern.fields, pattern.name);
|
|
152
|
+
const fields = await processFields(pattern.fields, pattern.name);
|
|
68
153
|
processedSchema.fields.push(...fields);
|
|
69
154
|
if (pattern.edges) {
|
|
70
155
|
const edges = processEdges(pattern.edges, pattern.name);
|
|
71
156
|
processedSchema.assocEdges.push(...edges);
|
|
72
157
|
}
|
|
158
|
+
// flag transformsSelect
|
|
159
|
+
if (pattern.transformRead) {
|
|
160
|
+
ret.transformsSelect = true;
|
|
161
|
+
}
|
|
73
162
|
if (patterns[name] === undefined) {
|
|
74
163
|
// intentionally processing separately and not passing pattern.name
|
|
75
164
|
const edges = processEdges(pattern.edges || []);
|
|
@@ -77,12 +166,14 @@ function processPattern(patterns, pattern, processedSchema) {
|
|
|
77
166
|
name: pattern.name,
|
|
78
167
|
assocEdges: edges,
|
|
79
168
|
fields: fields,
|
|
169
|
+
disableMixin: pattern.disableMixin,
|
|
80
170
|
};
|
|
81
171
|
}
|
|
82
172
|
else {
|
|
83
173
|
// TODO ideally we want to make sure that different patterns don't have the same name
|
|
84
174
|
// can't do a deepEqual check because function calls and therefore different instances in fields
|
|
85
175
|
}
|
|
176
|
+
return ret;
|
|
86
177
|
}
|
|
87
178
|
var NullableResult;
|
|
88
179
|
(function (NullableResult) {
|
|
@@ -117,20 +208,30 @@ function processAction(action) {
|
|
|
117
208
|
ret.actionOnlyFields = actionOnlyFields;
|
|
118
209
|
return ret;
|
|
119
210
|
}
|
|
120
|
-
function parseSchema(potentialSchemas) {
|
|
211
|
+
async function parseSchema(potentialSchemas, globalSchema) {
|
|
121
212
|
let schemas = {};
|
|
122
213
|
let patterns = {};
|
|
214
|
+
let parsedGlobalSchema;
|
|
215
|
+
if (globalSchema) {
|
|
216
|
+
parsedGlobalSchema = await parseGlobalSchema(globalSchema);
|
|
217
|
+
}
|
|
123
218
|
for (const key in potentialSchemas) {
|
|
124
219
|
const value = potentialSchemas[key];
|
|
125
220
|
let schema;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
221
|
+
const name = value.constructor.name;
|
|
222
|
+
// named class e.g. new BaseEntSchema
|
|
223
|
+
switch (name) {
|
|
224
|
+
case "Function":
|
|
225
|
+
schema = new value();
|
|
226
|
+
break;
|
|
227
|
+
default:
|
|
228
|
+
// implicit schema or named class
|
|
229
|
+
schema = value;
|
|
131
230
|
}
|
|
132
231
|
let processedSchema = {
|
|
133
232
|
fields: [],
|
|
233
|
+
fieldOverrides: schema.fieldOverrides,
|
|
234
|
+
schemaPath: schema.schemaPath,
|
|
134
235
|
tableName: schema.tableName,
|
|
135
236
|
enumTable: schema.enumTable,
|
|
136
237
|
dbRows: schema.dbRows,
|
|
@@ -143,13 +244,28 @@ function parseSchema(potentialSchemas) {
|
|
|
143
244
|
};
|
|
144
245
|
// let's put patterns first just so we have id, created_at, updated_at first
|
|
145
246
|
// ¯\_(ツ)_/¯
|
|
247
|
+
let patternNames = [];
|
|
146
248
|
if (schema.patterns) {
|
|
147
249
|
for (const pattern of schema.patterns) {
|
|
148
|
-
processPattern(patterns, pattern, processedSchema);
|
|
250
|
+
const ret = await processPattern(patterns, pattern, processedSchema);
|
|
251
|
+
patternNames.push(pattern.name);
|
|
252
|
+
if (ret.transformsSelect) {
|
|
253
|
+
if (processedSchema.transformsSelect) {
|
|
254
|
+
throw new Error(`can only have one pattern which transforms default querying behavior`);
|
|
255
|
+
}
|
|
256
|
+
processedSchema.transformsSelect = true;
|
|
257
|
+
}
|
|
258
|
+
if (ret.transformsDelete) {
|
|
259
|
+
if (processedSchema.transformsDelete) {
|
|
260
|
+
throw new Error(`can only have one pattern which transforms default deletion behavior`);
|
|
261
|
+
}
|
|
262
|
+
processedSchema.transformsDelete = true;
|
|
263
|
+
}
|
|
149
264
|
}
|
|
150
265
|
}
|
|
151
|
-
const fields = processFields(schema.fields);
|
|
266
|
+
const fields = await processFields(schema.fields);
|
|
152
267
|
processedSchema.fields.push(...fields);
|
|
268
|
+
processedSchema.patternNames = patternNames;
|
|
153
269
|
if (schema.edges) {
|
|
154
270
|
const edges = processEdges(schema.edges);
|
|
155
271
|
processedSchema.assocEdges.push(...edges);
|
|
@@ -159,6 +275,68 @@ function parseSchema(potentialSchemas) {
|
|
|
159
275
|
}
|
|
160
276
|
schemas[key] = processedSchema;
|
|
161
277
|
}
|
|
162
|
-
|
|
278
|
+
const rome = translatePrettier();
|
|
279
|
+
return {
|
|
280
|
+
schemas,
|
|
281
|
+
patterns,
|
|
282
|
+
globalSchema: parsedGlobalSchema,
|
|
283
|
+
config: {
|
|
284
|
+
rome,
|
|
285
|
+
},
|
|
286
|
+
};
|
|
163
287
|
}
|
|
164
288
|
exports.parseSchema = parseSchema;
|
|
289
|
+
function translatePrettier() {
|
|
290
|
+
const r = (0, cosmiconfig_1.cosmiconfigSync)("prettier").search();
|
|
291
|
+
if (!r) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
const ret = {};
|
|
295
|
+
if (r.config.printWidth !== undefined) {
|
|
296
|
+
ret.lineWidth = parseInt(r.config.printWidth);
|
|
297
|
+
}
|
|
298
|
+
if (r.config.useTabs) {
|
|
299
|
+
ret.indentStyle = "tab";
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
ret.indentStyle = "space";
|
|
303
|
+
}
|
|
304
|
+
if (r.config.tabWidth !== undefined) {
|
|
305
|
+
ret.indentSize = parseInt(r.config.tabWidth);
|
|
306
|
+
}
|
|
307
|
+
if (r.config.singleQuote) {
|
|
308
|
+
ret.quoteStyle = "single";
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
ret.quoteStyle = "double";
|
|
312
|
+
}
|
|
313
|
+
if (r.config.quoteProps !== undefined) {
|
|
314
|
+
if (r.config.quoteProps === "consistent") {
|
|
315
|
+
// rome doesn't support this
|
|
316
|
+
ret.quoteProperties = "as-needed";
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
ret.quoteProperties = r.config.quoteProps;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (r.config.trailingComma !== undefined) {
|
|
323
|
+
ret.trailingComma = r.config.trailingComma;
|
|
324
|
+
}
|
|
325
|
+
return ret;
|
|
326
|
+
}
|
|
327
|
+
async function parseGlobalSchema(s) {
|
|
328
|
+
const ret = {
|
|
329
|
+
globalEdges: [],
|
|
330
|
+
extraEdgeFields: [],
|
|
331
|
+
initForEdges: !!s.extraEdgeFields ||
|
|
332
|
+
s.transformEdgeRead !== undefined ||
|
|
333
|
+
s.transformEdgeWrite !== undefined,
|
|
334
|
+
};
|
|
335
|
+
if (s.extraEdgeFields) {
|
|
336
|
+
ret.extraEdgeFields = await processFields(s.extraEdgeFields);
|
|
337
|
+
}
|
|
338
|
+
if (s.edges) {
|
|
339
|
+
ret.globalEdges = processEdges(s.edges);
|
|
340
|
+
}
|
|
341
|
+
return ret;
|
|
342
|
+
}
|