@snowtop/ent 0.1.0-alpha14 → 0.1.0-alpha141
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 +27 -16
- package/action/action.js +22 -7
- package/action/executor.d.ts +16 -3
- package/action/executor.js +88 -21
- package/action/experimental_action.d.ts +25 -16
- package/action/experimental_action.js +35 -9
- package/action/index.d.ts +3 -1
- package/action/index.js +7 -1
- package/action/operations.d.ts +125 -0
- package/action/operations.js +684 -0
- package/action/orchestrator.d.ts +34 -11
- package/action/orchestrator.js +355 -92
- 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 +51 -21
- package/core/base.js +7 -1
- package/core/clause.d.ts +85 -40
- package/core/clause.js +375 -64
- package/core/config.d.ts +12 -1
- package/core/config.js +7 -1
- package/core/const.d.ts +3 -0
- package/core/const.js +6 -0
- package/core/context.d.ts +4 -2
- package/core/context.js +20 -2
- package/core/convert.d.ts +1 -1
- package/core/date.js +1 -5
- package/core/db.d.ts +12 -8
- package/core/db.js +18 -8
- package/core/ent.d.ts +66 -93
- package/core/ent.js +517 -577
- package/core/global_schema.d.ts +7 -0
- package/core/global_schema.js +51 -0
- package/core/loaders/assoc_count_loader.d.ts +1 -0
- package/core/loaders/assoc_count_loader.js +10 -2
- package/core/loaders/assoc_edge_loader.d.ts +1 -1
- package/core/loaders/assoc_edge_loader.js +8 -11
- package/core/loaders/index.d.ts +1 -1
- package/core/loaders/index.js +1 -3
- package/core/loaders/index_loader.d.ts +3 -3
- package/core/loaders/loader.d.ts +2 -2
- package/core/loaders/loader.js +5 -5
- package/core/loaders/object_loader.d.ts +30 -9
- package/core/loaders/object_loader.js +225 -78
- package/core/loaders/query_loader.d.ts +6 -12
- package/core/loaders/query_loader.js +52 -11
- 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 +7 -6
- package/core/privacy.js +21 -25
- package/core/query/assoc_query.d.ts +3 -2
- package/core/query/assoc_query.js +9 -1
- package/core/query/custom_clause_query.d.ts +27 -0
- package/core/query/custom_clause_query.js +84 -0
- package/core/query/custom_query.d.ts +17 -2
- 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 +7 -3
- 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 +470 -236
- package/core/viewer.js +1 -1
- package/graphql/graphql.d.ts +52 -19
- package/graphql/graphql.js +174 -136
- package/graphql/graphql_field_helpers.d.ts +7 -1
- package/graphql/graphql_field_helpers.js +21 -1
- package/graphql/index.d.ts +2 -2
- package/graphql/index.js +3 -5
- package/graphql/query/connection_type.d.ts +9 -9
- package/graphql/query/shared_assoc_test.js +1 -1
- package/graphql/query/shared_edge_connection.js +1 -19
- package/graphql/scalars/orderby_direction.d.ts +2 -0
- package/graphql/scalars/orderby_direction.js +15 -0
- package/imports/dataz/example1/_auth.js +128 -47
- package/imports/dataz/example1/_viewer.js +87 -39
- package/imports/index.d.ts +6 -1
- package/imports/index.js +19 -4
- package/index.d.ts +14 -5
- package/index.js +26 -10
- package/package.json +18 -17
- package/parse_schema/parse.d.ts +31 -9
- package/parse_schema/parse.js +156 -13
- package/schema/base_schema.d.ts +9 -3
- package/schema/base_schema.js +12 -0
- package/schema/field.d.ts +78 -21
- package/schema/field.js +231 -71
- package/schema/index.d.ts +2 -2
- package/schema/index.js +5 -1
- package/schema/json_field.d.ts +16 -4
- package/schema/json_field.js +32 -2
- package/schema/schema.d.ts +96 -19
- package/schema/schema.js +11 -13
- package/schema/struct_field.d.ts +15 -3
- package/schema/struct_field.js +117 -22
- package/schema/union_field.d.ts +1 -1
- package/scripts/custom_compiler.js +10 -6
- package/scripts/custom_graphql.js +142 -31
- package/scripts/migrate_v0.1.js +36 -0
- package/scripts/move_types.js +120 -0
- package/scripts/read_schema.js +20 -5
- package/testutils/action/complex_schemas.d.ts +69 -0
- package/testutils/action/complex_schemas.js +405 -0
- package/testutils/builder.d.ts +39 -43
- package/testutils/builder.js +75 -49
- 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} +25 -8
- package/testutils/db/{test_db.js → temp_db.js} +224 -47
- package/testutils/db/value.d.ts +7 -0
- package/testutils/db/value.js +251 -0
- package/testutils/db_mock.d.ts +16 -4
- package/testutils/db_mock.js +52 -7
- package/testutils/db_time_zone.d.ts +4 -0
- package/testutils/db_time_zone.js +41 -0
- package/testutils/ent-graphql-tests/index.d.ts +7 -1
- package/testutils/ent-graphql-tests/index.js +52 -23
- package/testutils/fake_comms.js +1 -1
- package/testutils/fake_data/const.d.ts +2 -1
- package/testutils/fake_data/const.js +3 -0
- package/testutils/fake_data/fake_contact.d.ts +7 -3
- package/testutils/fake_data/fake_contact.js +13 -7
- package/testutils/fake_data/fake_event.d.ts +4 -1
- package/testutils/fake_data/fake_event.js +7 -6
- package/testutils/fake_data/fake_tag.d.ts +36 -0
- package/testutils/fake_data/fake_tag.js +89 -0
- package/testutils/fake_data/fake_user.d.ts +8 -5
- package/testutils/fake_data/fake_user.js +16 -15
- 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 +28 -12
- package/testutils/fake_data/user_query.d.ts +11 -4
- package/testutils/fake_data/user_query.js +54 -22
- package/testutils/fake_log.js +1 -1
- package/testutils/parse_sql.d.ts +6 -0
- package/testutils/parse_sql.js +16 -2
- package/testutils/test_edge_global_schema.d.ts +15 -0
- package/testutils/test_edge_global_schema.js +62 -0
- package/testutils/write.d.ts +2 -2
- package/testutils/write.js +33 -7
- package/tsc/ast.d.ts +25 -2
- package/tsc/ast.js +141 -17
- package/tsc/compilerOptions.js +5 -1
- package/tsc/move_generated.d.ts +1 -0
- package/tsc/move_generated.js +164 -0
- package/tsc/transform.d.ts +22 -0
- package/tsc/transform.js +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 +60 -0
- package/tsc/transform_schema.d.ts +27 -0
- package/{scripts → tsc}/transform_schema.js +146 -117
- package/graphql/enums.d.ts +0 -3
- package/graphql/enums.js +0 -25
- package/scripts/move_generated.js +0 -142
- package/scripts/transform_code.js +0 -113
- package/scripts/transform_schema.d.ts +0 -1
- /package/scripts/{move_generated.d.ts → migrate_v0.1.d.ts} +0 -0
- /package/scripts/{transform_code.d.ts → move_types.d.ts} +0 -0
package/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./core/base";
|
|
2
|
-
export { loadEnt, loadCustomData, loadCustomEnts, loadEntX, loadEnts, CustomQuery, loadDerivedEnt, loadDerivedEntX, loadEntViaKey, loadEntXViaKey, performRawQuery, loadRowX, loadRow, loadRows,
|
|
2
|
+
export { loadEnt, loadCustomData, loadCustomEnts, loadCustomCount, loadEntX, loadEnts, CustomQuery, loadDerivedEnt, loadDerivedEntX, loadEntViaKey, loadEntXViaKey, performRawQuery, loadRowX, loadRow, loadRows, AssocEdge, AssocEdgeData, loadEdgeData, loadEdgeDatas, loadEdges, loadUniqueEdge, loadUniqueNode, loadRawEdgeCountX, loadEdgeForID2, loadNodesByEdge, getEdgeTypeInGroup, } from "./core/ent";
|
|
3
|
+
export { DataOperation, EditNodeOptions, EditNodeOperation, RawQueryOperation, EdgeOperation, DeleteNodeOperation, AssocEdgeInputOptions, AssocEdgeInput, } from "./action/operations";
|
|
4
|
+
export { setGlobalSchema } from "./core/global_schema";
|
|
3
5
|
import DB from "./core/db";
|
|
4
6
|
export * from "./core/loaders";
|
|
5
7
|
export { DB };
|
|
@@ -7,12 +9,14 @@ export { EntPrivacyError, AlwaysAllowRule, AlwaysDenyRule, DenyIfLoggedInRule, D
|
|
|
7
9
|
export * from "./core/query";
|
|
8
10
|
export * from "./schema/";
|
|
9
11
|
import * as q from "./core/clause";
|
|
12
|
+
export { Clause } from "./core/clause";
|
|
10
13
|
declare const query: {
|
|
11
14
|
Eq: typeof q.Eq;
|
|
12
15
|
NotEq: typeof q.NotEq;
|
|
13
16
|
And: typeof q.And;
|
|
14
17
|
AndOptional: typeof q.AndOptional;
|
|
15
18
|
Or: typeof q.Or;
|
|
19
|
+
OrOptional: typeof q.OrOptional;
|
|
16
20
|
In: typeof q.In;
|
|
17
21
|
Greater: typeof q.Greater;
|
|
18
22
|
Less: typeof q.Less;
|
|
@@ -20,10 +24,15 @@ declare const query: {
|
|
|
20
24
|
LessEq: typeof q.LessEq;
|
|
21
25
|
ArrayEq: typeof q.ArrayEq;
|
|
22
26
|
ArrayNotEq: typeof q.ArrayNotEq;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
PostgresArrayContainsValue: typeof q.PostgresArrayContainsValue;
|
|
28
|
+
PostgresArrayContains: typeof q.PostgresArrayContains;
|
|
29
|
+
PostgresArrayNotContainsValue: typeof q.PostgresArrayNotContainsValue;
|
|
30
|
+
PostgresArrayNotContains: typeof q.PostgresArrayNotContains;
|
|
31
|
+
PostgresArrayOverlaps: typeof q.PostgresArrayOverlaps;
|
|
32
|
+
PostgresArrayNotOverlaps: typeof q.PostgresArrayNotOverlaps;
|
|
33
|
+
JSONPathValuePredicate: typeof q.JSONPathValuePredicate;
|
|
34
|
+
JSONObjectFieldKeyASJSON: typeof q.JSONObjectFieldKeyASJSON;
|
|
35
|
+
JSONObjectFieldKeyAsText: typeof q.JSONObjectFieldKeyAsText;
|
|
27
36
|
TsQuery: typeof q.TsQuery;
|
|
28
37
|
PlainToTsQuery: typeof q.PlainToTsQuery;
|
|
29
38
|
PhraseToTsQuery: typeof q.PhraseToTsQuery;
|
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,13 +29,14 @@ 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 = 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.DeleteNodeOperation = exports.EdgeOperation = exports.RawQueryOperation = exports.EditNodeOperation = exports.getEdgeTypeInGroup = exports.loadNodesByEdge = exports.loadEdgeForID2 = exports.loadRawEdgeCountX = exports.loadUniqueNode = exports.loadUniqueEdge = exports.loadEdges = exports.loadEdgeDatas = exports.loadEdgeData = exports.AssocEdgeData = exports.AssocEdge = 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; } });
|
|
@@ -43,9 +48,6 @@ Object.defineProperty(exports, "performRawQuery", { enumerable: true, get: funct
|
|
|
43
48
|
Object.defineProperty(exports, "loadRowX", { enumerable: true, get: function () { return ent_1.loadRowX; } });
|
|
44
49
|
Object.defineProperty(exports, "loadRow", { enumerable: true, get: function () { return ent_1.loadRow; } });
|
|
45
50
|
Object.defineProperty(exports, "loadRows", { enumerable: true, get: function () { return ent_1.loadRows; } });
|
|
46
|
-
Object.defineProperty(exports, "EditNodeOperation", { enumerable: true, get: function () { return ent_1.EditNodeOperation; } });
|
|
47
|
-
Object.defineProperty(exports, "EdgeOperation", { enumerable: true, get: function () { return ent_1.EdgeOperation; } });
|
|
48
|
-
Object.defineProperty(exports, "DeleteNodeOperation", { enumerable: true, get: function () { return ent_1.DeleteNodeOperation; } });
|
|
49
51
|
Object.defineProperty(exports, "AssocEdge", { enumerable: true, get: function () { return ent_1.AssocEdge; } });
|
|
50
52
|
Object.defineProperty(exports, "AssocEdgeData", { enumerable: true, get: function () { return ent_1.AssocEdgeData; } });
|
|
51
53
|
Object.defineProperty(exports, "loadEdgeData", { enumerable: true, get: function () { return ent_1.loadEdgeData; } });
|
|
@@ -57,6 +59,14 @@ Object.defineProperty(exports, "loadRawEdgeCountX", { enumerable: true, get: fun
|
|
|
57
59
|
Object.defineProperty(exports, "loadEdgeForID2", { enumerable: true, get: function () { return ent_1.loadEdgeForID2; } });
|
|
58
60
|
Object.defineProperty(exports, "loadNodesByEdge", { enumerable: true, get: function () { return ent_1.loadNodesByEdge; } });
|
|
59
61
|
Object.defineProperty(exports, "getEdgeTypeInGroup", { enumerable: true, get: function () { return ent_1.getEdgeTypeInGroup; } });
|
|
62
|
+
// TODO should these even be exported from the root?
|
|
63
|
+
var operations_1 = require("./action/operations");
|
|
64
|
+
Object.defineProperty(exports, "EditNodeOperation", { enumerable: true, get: function () { return operations_1.EditNodeOperation; } });
|
|
65
|
+
Object.defineProperty(exports, "RawQueryOperation", { enumerable: true, get: function () { return operations_1.RawQueryOperation; } });
|
|
66
|
+
Object.defineProperty(exports, "EdgeOperation", { enumerable: true, get: function () { return operations_1.EdgeOperation; } });
|
|
67
|
+
Object.defineProperty(exports, "DeleteNodeOperation", { enumerable: true, get: function () { return operations_1.DeleteNodeOperation; } });
|
|
68
|
+
var global_schema_1 = require("./core/global_schema");
|
|
69
|
+
Object.defineProperty(exports, "setGlobalSchema", { enumerable: true, get: function () { return global_schema_1.setGlobalSchema; } });
|
|
60
70
|
const db_1 = __importDefault(require("./core/db"));
|
|
61
71
|
exports.DB = db_1.default;
|
|
62
72
|
__exportStar(require("./core/loaders"), exports);
|
|
@@ -109,6 +119,7 @@ const query = {
|
|
|
109
119
|
And: q.And,
|
|
110
120
|
AndOptional: q.AndOptional,
|
|
111
121
|
Or: q.Or,
|
|
122
|
+
OrOptional: q.OrOptional,
|
|
112
123
|
In: q.In,
|
|
113
124
|
Greater: q.Greater,
|
|
114
125
|
Less: q.Less,
|
|
@@ -116,10 +127,15 @@ const query = {
|
|
|
116
127
|
LessEq: q.LessEq,
|
|
117
128
|
ArrayEq: q.ArrayEq,
|
|
118
129
|
ArrayNotEq: q.ArrayNotEq,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
130
|
+
PostgresArrayContainsValue: q.PostgresArrayContainsValue,
|
|
131
|
+
PostgresArrayContains: q.PostgresArrayContains,
|
|
132
|
+
PostgresArrayNotContainsValue: q.PostgresArrayNotContainsValue,
|
|
133
|
+
PostgresArrayNotContains: q.PostgresArrayNotContains,
|
|
134
|
+
PostgresArrayOverlaps: q.PostgresArrayOverlaps,
|
|
135
|
+
PostgresArrayNotOverlaps: q.PostgresArrayNotOverlaps,
|
|
136
|
+
JSONPathValuePredicate: q.JSONPathValuePredicate,
|
|
137
|
+
JSONObjectFieldKeyASJSON: q.JSONObjectFieldKeyASJSON,
|
|
138
|
+
JSONObjectFieldKeyAsText: q.JSONObjectFieldKeyAsText,
|
|
123
139
|
TsQuery: q.TsQuery,
|
|
124
140
|
PlainToTsQuery: q.PlainToTsQuery,
|
|
125
141
|
PhraseToTsQuery: q.PhraseToTsQuery,
|
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-alpha141",
|
|
4
4
|
"description": "snowtop ent framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -8,26 +8,27 @@
|
|
|
8
8
|
"example": "examples"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@
|
|
11
|
+
"@swc-node/register": "^1.6.5",
|
|
12
|
+
"@types/node": "^18.11.18",
|
|
12
13
|
"camel-case": "^4.1.2",
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
14
|
+
"cosmiconfig": "^8.0.0",
|
|
15
|
+
"dataloader": "^2.1.0",
|
|
16
|
+
"glob": "^8.0.3",
|
|
17
|
+
"graph-data-structure": "^2.0.0",
|
|
16
18
|
"js-yaml": "^4.1.0",
|
|
17
|
-
"json5": "^2.
|
|
18
|
-
"luxon": "^1.
|
|
19
|
+
"json5": "^2.2.2",
|
|
20
|
+
"luxon": "^3.1.1",
|
|
19
21
|
"memoizee": "^0.4.15",
|
|
20
|
-
"minimist": "^1.2.
|
|
22
|
+
"minimist": "^1.2.7",
|
|
21
23
|
"pascal-case": "^3.1.2",
|
|
22
|
-
"pg": "^8.0
|
|
23
|
-
"prettier": "^2.
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"uuid": "^8.3.2"
|
|
24
|
+
"pg": "^8.11.0",
|
|
25
|
+
"prettier": "^2.8.1",
|
|
26
|
+
"snake-case": "^3.0.4",
|
|
27
|
+
"ts-node": "^10.9.1",
|
|
28
|
+
"tsconfig-paths": "^4.2.0",
|
|
29
|
+
"tslib": "^2.5.0",
|
|
30
|
+
"typescript": "^5.0.4",
|
|
31
|
+
"uuid": "^9.0.0"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
34
|
"better-sqlite3": "^7.4.1",
|
package/parse_schema/parse.d.ts
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
import { Schema, Field, AssocEdge, AssocEdgeGroup, Action } from "../schema";
|
|
2
|
-
import { ActionField, Type } from "../schema/schema";
|
|
2
|
+
import { ActionField, Type, GlobalSchema, TransformReadBetaResult } 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
16
|
transformsSelect?: boolean;
|
|
17
17
|
transformsDelete?: boolean;
|
|
18
|
+
transformsLoaderCodegen?: TransformReadBetaResult;
|
|
18
19
|
transformsInsert?: boolean;
|
|
19
20
|
transformsUpdate?: boolean;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
+
type ProcessedSchema = Omit<Schema, "edges" | "actions" | "edgeGroups" | "fields"> & TransformFlags & {
|
|
22
23
|
actions: OutputAction[];
|
|
23
24
|
assocEdges: ProcessedAssocEdge[];
|
|
24
25
|
assocEdgeGroups: ProcessedAssocEdgeGroup[];
|
|
25
26
|
fields: ProcessedField[];
|
|
26
27
|
schemaPath?: string;
|
|
28
|
+
patternNames?: string[];
|
|
27
29
|
};
|
|
28
|
-
|
|
30
|
+
type ProcessedAssocEdgeGroup = Omit<AssocEdgeGroup, "edgeAction"> & {
|
|
29
31
|
edgeAction?: OutputAction;
|
|
30
32
|
};
|
|
31
|
-
|
|
33
|
+
type OutputAction = Omit<Action, "actionOnlyFields"> & {
|
|
32
34
|
actionOnlyFields?: ProcessedActionField[];
|
|
33
35
|
};
|
|
34
36
|
interface schemasDict {
|
|
@@ -38,13 +40,14 @@ interface ProcessedPattern {
|
|
|
38
40
|
name: string;
|
|
39
41
|
assocEdges: ProcessedAssocEdge[];
|
|
40
42
|
fields: ProcessedField[];
|
|
43
|
+
disableMixin?: boolean;
|
|
41
44
|
}
|
|
42
|
-
|
|
45
|
+
type ProcessedType = Omit<Type, "subFields" | "listElemType" | "unionFields"> & {
|
|
43
46
|
subFields?: ProcessedField[];
|
|
44
47
|
listElemType?: ProcessedType;
|
|
45
48
|
unionFields?: ProcessedField[];
|
|
46
49
|
};
|
|
47
|
-
|
|
50
|
+
type ProcessedField = Omit<Field, "defaultValueOnEdit" | "defaultValueOnCreate" | "privacyPolicy" | "type" | "serverDefault"> & {
|
|
48
51
|
name: string;
|
|
49
52
|
hasDefaultValueOnCreate?: boolean;
|
|
50
53
|
hasDefaultValueOnEdit?: boolean;
|
|
@@ -52,6 +55,7 @@ declare type ProcessedField = Omit<Field, "defaultValueOnEdit" | "defaultValueOn
|
|
|
52
55
|
hasFieldPrivacy?: boolean;
|
|
53
56
|
derivedFields?: ProcessedField[];
|
|
54
57
|
type: ProcessedType;
|
|
58
|
+
serverDefault?: string;
|
|
55
59
|
};
|
|
56
60
|
interface patternsDict {
|
|
57
61
|
[key: string]: ProcessedPattern;
|
|
@@ -59,9 +63,27 @@ interface patternsDict {
|
|
|
59
63
|
interface Result {
|
|
60
64
|
schemas: schemasDict;
|
|
61
65
|
patterns: patternsDict;
|
|
66
|
+
globalSchema?: ProcessedGlobalSchema;
|
|
67
|
+
config?: {
|
|
68
|
+
rome?: RomeConfig;
|
|
69
|
+
};
|
|
62
70
|
}
|
|
63
71
|
declare type PotentialSchemas = {
|
|
64
72
|
[key: string]: any;
|
|
65
73
|
};
|
|
66
|
-
export declare function parseSchema(potentialSchemas: PotentialSchemas): Result
|
|
74
|
+
export declare function parseSchema(potentialSchemas: PotentialSchemas, globalSchema?: GlobalSchema): Promise<Result>;
|
|
75
|
+
interface RomeConfig {
|
|
76
|
+
indentStyle?: string;
|
|
77
|
+
lineWidth?: number;
|
|
78
|
+
indentSize?: number;
|
|
79
|
+
quoteStyle?: string;
|
|
80
|
+
quoteProperties?: string;
|
|
81
|
+
trailingComma?: string;
|
|
82
|
+
}
|
|
83
|
+
interface ProcessedGlobalSchema {
|
|
84
|
+
globalEdges: ProcessedAssocEdge[];
|
|
85
|
+
extraEdgeFields: ProcessedField[];
|
|
86
|
+
init?: boolean;
|
|
87
|
+
globalFields?: ProcessedField[];
|
|
88
|
+
}
|
|
67
89
|
export {};
|
package/parse_schema/parse.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
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
|
+
const const_1 = require("../core/const");
|
|
6
|
+
const global_schema_1 = require("../core/global_schema");
|
|
7
|
+
async function processFields(src, patternName) {
|
|
5
8
|
const ret = [];
|
|
6
9
|
let m = {};
|
|
7
10
|
if (Array.isArray(src)) {
|
|
@@ -19,7 +22,7 @@ function processFields(src, patternName) {
|
|
|
19
22
|
for (const name in m) {
|
|
20
23
|
const field = m[name];
|
|
21
24
|
//@ts-ignore type and other changed fields with different type in ProcessedField vs Field
|
|
22
|
-
let f = {
|
|
25
|
+
let f = { ...field, name };
|
|
23
26
|
f.hasDefaultValueOnCreate = field.defaultValueOnCreate != undefined;
|
|
24
27
|
f.hasDefaultValueOnEdit = field.defaultValueOnEdit != undefined;
|
|
25
28
|
f.hasFieldPrivacy = field.privacyPolicy !== undefined;
|
|
@@ -36,6 +39,19 @@ function processFields(src, patternName) {
|
|
|
36
39
|
else {
|
|
37
40
|
delete f.polymorphic;
|
|
38
41
|
}
|
|
42
|
+
if (field.private) {
|
|
43
|
+
// convert boolean into object
|
|
44
|
+
// we keep boolean as an option to keep API simple
|
|
45
|
+
if (typeof field.private === "boolean") {
|
|
46
|
+
f.private = {};
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
f.private = field.private;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
delete f.private;
|
|
54
|
+
}
|
|
39
55
|
// convert string to object to make API consumed by go simple
|
|
40
56
|
if (f.fieldEdge && f.fieldEdge.inverseEdge) {
|
|
41
57
|
if (typeof f.fieldEdge.inverseEdge === "string") {
|
|
@@ -47,26 +63,48 @@ function processFields(src, patternName) {
|
|
|
47
63
|
if (patternName) {
|
|
48
64
|
f.patternName = patternName;
|
|
49
65
|
}
|
|
66
|
+
if (field.serverDefault !== undefined) {
|
|
67
|
+
f.serverDefault = await transformServerDefault(name, field, field.serverDefault);
|
|
68
|
+
}
|
|
50
69
|
transformType(field.type);
|
|
51
70
|
if (field.getDerivedFields) {
|
|
52
|
-
f.derivedFields = processFields(field.getDerivedFields(name));
|
|
71
|
+
f.derivedFields = await processFields(field.getDerivedFields(name));
|
|
53
72
|
}
|
|
54
73
|
if (field.type.subFields) {
|
|
55
|
-
f.type.subFields = processFields(field.type.subFields);
|
|
74
|
+
f.type.subFields = await processFields(field.type.subFields);
|
|
56
75
|
}
|
|
57
76
|
if (field.type.unionFields) {
|
|
58
|
-
f.type.unionFields = processFields(field.type.unionFields);
|
|
77
|
+
f.type.unionFields = await processFields(field.type.unionFields);
|
|
59
78
|
}
|
|
60
79
|
if (field.type.listElemType &&
|
|
61
80
|
field.type.listElemType.subFields &&
|
|
62
81
|
// check to avoid ts-ignore below. exists just for tsc
|
|
63
82
|
f.type.listElemType) {
|
|
64
|
-
f.type.listElemType.subFields = processFields(field.type.listElemType.subFields);
|
|
83
|
+
f.type.listElemType.subFields = await processFields(field.type.listElemType.subFields);
|
|
65
84
|
}
|
|
66
85
|
ret.push(f);
|
|
67
86
|
}
|
|
68
87
|
return ret;
|
|
69
88
|
}
|
|
89
|
+
async function transformServerDefault(name, f, value) {
|
|
90
|
+
if (f.valid) {
|
|
91
|
+
if (!(await f.valid(value))) {
|
|
92
|
+
throw new Error(`invalid value ${value} passed to field ${name}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (f.format) {
|
|
96
|
+
value = await f.format(value);
|
|
97
|
+
}
|
|
98
|
+
switch (typeof value) {
|
|
99
|
+
case "boolean":
|
|
100
|
+
case "number":
|
|
101
|
+
case "bigint":
|
|
102
|
+
case "string":
|
|
103
|
+
return `${value}`;
|
|
104
|
+
default:
|
|
105
|
+
throw new Error(`invalid value ${value} passed to field ${name}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
70
108
|
function transformImportType(typ) {
|
|
71
109
|
if (!typ.importType) {
|
|
72
110
|
return;
|
|
@@ -108,12 +146,12 @@ function processEdgeGroups(processedSchema, edgeGroups) {
|
|
|
108
146
|
processedSchema.assocEdgeGroups.push(group2);
|
|
109
147
|
}
|
|
110
148
|
}
|
|
111
|
-
function processPattern(patterns, pattern, processedSchema) {
|
|
149
|
+
async function processPattern(patterns, pattern, processedSchema) {
|
|
112
150
|
let ret = {
|
|
113
151
|
...pattern,
|
|
114
152
|
};
|
|
115
153
|
const name = pattern.name;
|
|
116
|
-
const fields = processFields(pattern.fields, pattern.name);
|
|
154
|
+
const fields = await processFields(pattern.fields, pattern.name);
|
|
117
155
|
processedSchema.fields.push(...fields);
|
|
118
156
|
if (pattern.edges) {
|
|
119
157
|
const edges = processEdges(pattern.edges, pattern.name);
|
|
@@ -122,6 +160,23 @@ function processPattern(patterns, pattern, processedSchema) {
|
|
|
122
160
|
// flag transformsSelect
|
|
123
161
|
if (pattern.transformRead) {
|
|
124
162
|
ret.transformsSelect = true;
|
|
163
|
+
if (pattern.transformReadCodegen_BETA) {
|
|
164
|
+
const r = pattern.transformReadCodegen_BETA();
|
|
165
|
+
if (typeof r === "string") {
|
|
166
|
+
ret.transformsLoaderCodegen = {
|
|
167
|
+
code: r,
|
|
168
|
+
imports: [
|
|
169
|
+
{
|
|
170
|
+
importPath: const_1.PACKAGE,
|
|
171
|
+
import: "query",
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
ret.transformsLoaderCodegen = r;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
125
180
|
}
|
|
126
181
|
if (patterns[name] === undefined) {
|
|
127
182
|
// intentionally processing separately and not passing pattern.name
|
|
@@ -130,6 +185,7 @@ function processPattern(patterns, pattern, processedSchema) {
|
|
|
130
185
|
name: pattern.name,
|
|
131
186
|
assocEdges: edges,
|
|
132
187
|
fields: fields,
|
|
188
|
+
disableMixin: pattern.disableMixin,
|
|
133
189
|
};
|
|
134
190
|
}
|
|
135
191
|
else {
|
|
@@ -162,18 +218,29 @@ function processAction(action) {
|
|
|
162
218
|
if (f.nullable === "contentsAndList") {
|
|
163
219
|
f2.nullable = NullableResult.CONTENTS_AND_LIST;
|
|
164
220
|
}
|
|
165
|
-
else {
|
|
221
|
+
else if (f.nullable === "contents") {
|
|
166
222
|
f2.nullable = NullableResult.CONTENTS;
|
|
167
223
|
}
|
|
224
|
+
else if (f.nullable === "true") {
|
|
225
|
+
// shouldn't happen but ran into weirdness where it did...
|
|
226
|
+
f2.nullable = NullableResult.ITEM;
|
|
227
|
+
}
|
|
168
228
|
}
|
|
169
229
|
return f2;
|
|
170
230
|
});
|
|
171
231
|
ret.actionOnlyFields = actionOnlyFields;
|
|
172
232
|
return ret;
|
|
173
233
|
}
|
|
174
|
-
function parseSchema(potentialSchemas) {
|
|
234
|
+
async function parseSchema(potentialSchemas, globalSchema) {
|
|
175
235
|
let schemas = {};
|
|
176
236
|
let patterns = {};
|
|
237
|
+
let parsedGlobalSchema;
|
|
238
|
+
if (globalSchema) {
|
|
239
|
+
parsedGlobalSchema = await parseGlobalSchema(globalSchema);
|
|
240
|
+
// set this so that we can use it, if we're trying to process server default or anything
|
|
241
|
+
// that ends up parsing,validating and formatting fields
|
|
242
|
+
(0, global_schema_1.setGlobalSchema)(globalSchema);
|
|
243
|
+
}
|
|
177
244
|
for (const key in potentialSchemas) {
|
|
178
245
|
const value = potentialSchemas[key];
|
|
179
246
|
let schema;
|
|
@@ -189,6 +256,7 @@ function parseSchema(potentialSchemas) {
|
|
|
189
256
|
}
|
|
190
257
|
let processedSchema = {
|
|
191
258
|
fields: [],
|
|
259
|
+
fieldOverrides: schema.fieldOverrides,
|
|
192
260
|
schemaPath: schema.schemaPath,
|
|
193
261
|
tableName: schema.tableName,
|
|
194
262
|
enumTable: schema.enumTable,
|
|
@@ -199,17 +267,25 @@ function parseSchema(potentialSchemas) {
|
|
|
199
267
|
actions: schema.actions?.map((action) => processAction(action)) || [],
|
|
200
268
|
assocEdges: [],
|
|
201
269
|
assocEdgeGroups: [],
|
|
270
|
+
customGraphQLInterfaces: schema.customGraphQLInterfaces,
|
|
271
|
+
supportUpsert: schema.supportUpsert,
|
|
202
272
|
};
|
|
203
273
|
// let's put patterns first just so we have id, created_at, updated_at first
|
|
204
274
|
// ¯\_(ツ)_/¯
|
|
275
|
+
let patternNames = [];
|
|
205
276
|
if (schema.patterns) {
|
|
206
277
|
for (const pattern of schema.patterns) {
|
|
207
|
-
const ret = processPattern(patterns, pattern, processedSchema);
|
|
278
|
+
const ret = await processPattern(patterns, pattern, processedSchema);
|
|
279
|
+
patternNames.push(pattern.name);
|
|
208
280
|
if (ret.transformsSelect) {
|
|
209
281
|
if (processedSchema.transformsSelect) {
|
|
210
282
|
throw new Error(`can only have one pattern which transforms default querying behavior`);
|
|
211
283
|
}
|
|
212
284
|
processedSchema.transformsSelect = true;
|
|
285
|
+
if (ret.transformsLoaderCodegen) {
|
|
286
|
+
processedSchema.transformsLoaderCodegen =
|
|
287
|
+
ret.transformsLoaderCodegen;
|
|
288
|
+
}
|
|
213
289
|
}
|
|
214
290
|
if (ret.transformsDelete) {
|
|
215
291
|
if (processedSchema.transformsDelete) {
|
|
@@ -219,8 +295,9 @@ function parseSchema(potentialSchemas) {
|
|
|
219
295
|
}
|
|
220
296
|
}
|
|
221
297
|
}
|
|
222
|
-
const fields = processFields(schema.fields);
|
|
298
|
+
const fields = await processFields(schema.fields);
|
|
223
299
|
processedSchema.fields.push(...fields);
|
|
300
|
+
processedSchema.patternNames = patternNames;
|
|
224
301
|
if (schema.edges) {
|
|
225
302
|
const edges = processEdges(schema.edges);
|
|
226
303
|
processedSchema.assocEdges.push(...edges);
|
|
@@ -230,6 +307,72 @@ function parseSchema(potentialSchemas) {
|
|
|
230
307
|
}
|
|
231
308
|
schemas[key] = processedSchema;
|
|
232
309
|
}
|
|
233
|
-
|
|
310
|
+
const rome = translatePrettier();
|
|
311
|
+
return {
|
|
312
|
+
schemas,
|
|
313
|
+
patterns,
|
|
314
|
+
globalSchema: parsedGlobalSchema,
|
|
315
|
+
config: {
|
|
316
|
+
rome,
|
|
317
|
+
},
|
|
318
|
+
};
|
|
234
319
|
}
|
|
235
320
|
exports.parseSchema = parseSchema;
|
|
321
|
+
function translatePrettier() {
|
|
322
|
+
const r = (0, cosmiconfig_1.cosmiconfigSync)("prettier").search();
|
|
323
|
+
if (!r) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const ret = {};
|
|
327
|
+
if (r.config.printWidth !== undefined) {
|
|
328
|
+
ret.lineWidth = parseInt(r.config.printWidth);
|
|
329
|
+
}
|
|
330
|
+
if (r.config.useTabs) {
|
|
331
|
+
ret.indentStyle = "tab";
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
ret.indentStyle = "space";
|
|
335
|
+
}
|
|
336
|
+
if (r.config.tabWidth !== undefined) {
|
|
337
|
+
ret.indentSize = parseInt(r.config.tabWidth);
|
|
338
|
+
}
|
|
339
|
+
if (r.config.singleQuote) {
|
|
340
|
+
ret.quoteStyle = "single";
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
ret.quoteStyle = "double";
|
|
344
|
+
}
|
|
345
|
+
if (r.config.quoteProps !== undefined) {
|
|
346
|
+
if (r.config.quoteProps === "consistent") {
|
|
347
|
+
// rome doesn't support this
|
|
348
|
+
ret.quoteProperties = "as-needed";
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
ret.quoteProperties = r.config.quoteProps;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
if (r.config.trailingComma !== undefined) {
|
|
355
|
+
ret.trailingComma = r.config.trailingComma;
|
|
356
|
+
}
|
|
357
|
+
return ret;
|
|
358
|
+
}
|
|
359
|
+
async function parseGlobalSchema(s) {
|
|
360
|
+
const ret = {
|
|
361
|
+
globalEdges: [],
|
|
362
|
+
extraEdgeFields: [],
|
|
363
|
+
init: !!s.extraEdgeFields ||
|
|
364
|
+
s.transformEdgeRead !== undefined ||
|
|
365
|
+
s.transformEdgeWrite !== undefined ||
|
|
366
|
+
s.fields !== undefined,
|
|
367
|
+
};
|
|
368
|
+
if (s.extraEdgeFields) {
|
|
369
|
+
ret.extraEdgeFields = await processFields(s.extraEdgeFields);
|
|
370
|
+
}
|
|
371
|
+
if (s.edges) {
|
|
372
|
+
ret.globalEdges = processEdges(s.edges);
|
|
373
|
+
}
|
|
374
|
+
if (s.fields) {
|
|
375
|
+
ret.globalFields = await processFields(s.fields);
|
|
376
|
+
}
|
|
377
|
+
return ret;
|
|
378
|
+
}
|
package/schema/base_schema.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FieldMap, Pattern, FieldOverrideMap } from "./schema";
|
|
2
2
|
import { Action, AssocEdgeGroup, Constraint, Edge, Index, Schema } from ".";
|
|
3
3
|
export declare const Timestamps: Pattern;
|
|
4
4
|
export declare const Node: Pattern;
|
|
5
5
|
export interface SchemaConfig extends Schema {
|
|
6
6
|
}
|
|
7
7
|
export declare class EntSchema implements Schema {
|
|
8
|
-
fields: FieldMap
|
|
8
|
+
fields: FieldMap;
|
|
9
|
+
fieldOverrides: FieldOverrideMap | undefined;
|
|
9
10
|
tableName: string | undefined;
|
|
10
11
|
patterns: Pattern[];
|
|
11
12
|
edges: Edge[] | undefined;
|
|
@@ -18,10 +19,13 @@ export declare class EntSchema implements Schema {
|
|
|
18
19
|
constraints: Constraint[] | undefined;
|
|
19
20
|
indices: Index[] | undefined;
|
|
20
21
|
hideFromGraphQL?: boolean;
|
|
22
|
+
customGraphQLInterfaces?: string[] | undefined;
|
|
23
|
+
supportUpsert?: boolean | undefined;
|
|
21
24
|
constructor(cfg: SchemaConfig);
|
|
22
25
|
}
|
|
23
26
|
export declare class EntSchemaWithTZ implements Schema {
|
|
24
|
-
fields: FieldMap
|
|
27
|
+
fields: FieldMap;
|
|
28
|
+
fieldOverrides: FieldOverrideMap | undefined;
|
|
25
29
|
tableName: string | undefined;
|
|
26
30
|
patterns: Pattern[];
|
|
27
31
|
edges: Edge[] | undefined;
|
|
@@ -34,6 +38,8 @@ export declare class EntSchemaWithTZ implements Schema {
|
|
|
34
38
|
constraints: Constraint[] | undefined;
|
|
35
39
|
indices: Index[] | undefined;
|
|
36
40
|
hideFromGraphQL?: boolean;
|
|
41
|
+
customGraphQLInterfaces?: string[] | undefined;
|
|
42
|
+
supportUpsert?: boolean | undefined;
|
|
37
43
|
constructor(cfg: SchemaConfig);
|
|
38
44
|
}
|
|
39
45
|
export declare abstract class BaseEntSchema {
|
package/schema/base_schema.js
CHANGED
|
@@ -17,6 +17,7 @@ let tsFields = {
|
|
|
17
17
|
defaultValueOnCreate: () => {
|
|
18
18
|
return new Date();
|
|
19
19
|
},
|
|
20
|
+
onlyUpdateIfOtherFieldsBeingSet_BETA: true,
|
|
20
21
|
defaultValueOnEdit: () => {
|
|
21
22
|
return new Date();
|
|
22
23
|
},
|
|
@@ -66,6 +67,7 @@ let nodeFieldsWithTZ = {
|
|
|
66
67
|
exports.Node = {
|
|
67
68
|
name: "node",
|
|
68
69
|
fields: nodeFields,
|
|
70
|
+
disableMixin: true,
|
|
69
71
|
};
|
|
70
72
|
// Ent schema. has Node Pattern by default.
|
|
71
73
|
// exists just to have less typing and easier for clients to implement
|
|
@@ -73,6 +75,7 @@ class EntSchema {
|
|
|
73
75
|
constructor(cfg) {
|
|
74
76
|
this.patterns = [exports.Node];
|
|
75
77
|
this.fields = cfg.fields;
|
|
78
|
+
this.fieldOverrides = cfg.fieldOverrides;
|
|
76
79
|
this.tableName = cfg.tableName;
|
|
77
80
|
if (cfg.patterns) {
|
|
78
81
|
this.patterns.push(...cfg.patterns);
|
|
@@ -85,6 +88,9 @@ class EntSchema {
|
|
|
85
88
|
this.constraints = cfg.constraints;
|
|
86
89
|
this.indices = cfg.indices;
|
|
87
90
|
this.hideFromGraphQL = cfg.hideFromGraphQL;
|
|
91
|
+
// TODO annoying that have to list these...
|
|
92
|
+
this.customGraphQLInterfaces = cfg.customGraphQLInterfaces;
|
|
93
|
+
this.supportUpsert = cfg.supportUpsert;
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
96
|
exports.EntSchema = EntSchema;
|
|
@@ -95,9 +101,11 @@ class EntSchemaWithTZ {
|
|
|
95
101
|
// default schema added
|
|
96
102
|
name: "nodeWithTZ",
|
|
97
103
|
fields: nodeFieldsWithTZ,
|
|
104
|
+
disableMixin: true,
|
|
98
105
|
},
|
|
99
106
|
];
|
|
100
107
|
this.fields = cfg.fields;
|
|
108
|
+
this.fieldOverrides = cfg.fieldOverrides;
|
|
101
109
|
this.tableName = cfg.tableName;
|
|
102
110
|
if (cfg.patterns) {
|
|
103
111
|
this.patterns.push(...cfg.patterns);
|
|
@@ -110,6 +118,9 @@ class EntSchemaWithTZ {
|
|
|
110
118
|
this.constraints = cfg.constraints;
|
|
111
119
|
this.indices = cfg.indices;
|
|
112
120
|
this.hideFromGraphQL = cfg.hideFromGraphQL;
|
|
121
|
+
// TODO annoying that have to list these...
|
|
122
|
+
this.customGraphQLInterfaces = cfg.customGraphQLInterfaces;
|
|
123
|
+
this.supportUpsert = cfg.supportUpsert;
|
|
113
124
|
}
|
|
114
125
|
}
|
|
115
126
|
exports.EntSchemaWithTZ = EntSchemaWithTZ;
|
|
@@ -131,6 +142,7 @@ class BaseEntSchemaWithTZ {
|
|
|
131
142
|
// default schema added
|
|
132
143
|
name: "nodeWithTZ",
|
|
133
144
|
fields: nodeFieldsWithTZ,
|
|
145
|
+
disableMixin: true,
|
|
134
146
|
},
|
|
135
147
|
];
|
|
136
148
|
}
|