oradm-to-gql 33.3.0 → 34.0.0
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/package.json +5 -4
- package/src/cli.js +0 -0
- package/src/data-lib-generator/core-files/getResultsCursor.js +1 -1
- package/src/datamodel-csv-parser/Utils.js +0 -1
- package/src/datamodel-csv-parser/extendTableMap.js +33 -18
- package/src/graphql-generator/convertTableToTypeDef.js +4 -0
- package/src/index.js +2 -1
- package/src/knex-tools/createTables.js +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "oradm-to-gql",
|
3
|
-
"version": "
|
3
|
+
"version": "34.0.0",
|
4
4
|
"description": "Oracle Data Modeler CSV Export to Apollo GraphQL Endpoint Generator",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -31,14 +31,14 @@
|
|
31
31
|
"nunjucks": "^3.0.1",
|
32
32
|
"pluralize": "^5.0.0",
|
33
33
|
"sql-formatter": "^1.2.2",
|
34
|
-
"tg-knex-query-resolver": "^2.5.0",
|
35
34
|
"uuid": "^3.3.2"
|
36
35
|
},
|
37
36
|
"peerDependencies": {
|
38
37
|
"graphql": "^0.10.3",
|
39
38
|
"graphql-server-express": "^0.8.5",
|
40
39
|
"graphql-tools": "^1.0.0",
|
41
|
-
"knex": "^0.13.0"
|
40
|
+
"knex": "^0.13.0",
|
41
|
+
"tg-knex-query-resolver": "^4.0.0"
|
42
42
|
},
|
43
43
|
"repository": "https://github.com/TeselaGen/oradm-to-gql",
|
44
44
|
"devDependencies": {
|
@@ -54,6 +54,7 @@
|
|
54
54
|
"knex": "^0.95.11",
|
55
55
|
"pg": "^6.4.0",
|
56
56
|
"require-from-string": "^1.2.1",
|
57
|
-
"tg-client-query-builder": "^2.2.0"
|
57
|
+
"tg-client-query-builder": "^2.2.0",
|
58
|
+
"tg-knex-query-resolver": "^4.0.0"
|
58
59
|
}
|
59
60
|
}
|
package/src/cli.js
CHANGED
File without changes
|
@@ -3,7 +3,7 @@ const graphqlFields = require('graphql-fields');
|
|
3
3
|
|
4
4
|
|
5
5
|
function getResultsCursor(tableName, primaryKeyField, filter, sort, pageNumber, pageSize, info, dataLib, opts) {
|
6
|
-
sort = sort || [
|
6
|
+
sort = sort || ["nid"];
|
7
7
|
pageNumber = pageNumber || 1;
|
8
8
|
pageSize = pageSize || 100;
|
9
9
|
|
@@ -1,6 +1,21 @@
|
|
1
1
|
const _ = require("lodash");
|
2
2
|
const clone = require("../graphql-generator/clone");
|
3
3
|
|
4
|
+
const nidTemplate = {
|
5
|
+
name: "nid",
|
6
|
+
dataType: "NUMERIC",
|
7
|
+
isPrimaryKey: false,
|
8
|
+
isForeignKey: false,
|
9
|
+
isReadOnly: true,
|
10
|
+
size: "",
|
11
|
+
precision: "",
|
12
|
+
scale: "",
|
13
|
+
nullable: true,
|
14
|
+
defaultValue: "",
|
15
|
+
autoIncrement: true,
|
16
|
+
columnName: "nid",
|
17
|
+
};
|
18
|
+
|
4
19
|
module.exports = function extendTableMap(tableMap, opts) {
|
5
20
|
opts = opts || {};
|
6
21
|
var tableMapExtender = opts.extendTableMap;
|
@@ -42,16 +57,14 @@ function addCidFields(tableMap, opts) {
|
|
42
57
|
}
|
43
58
|
function convertNumericIdsToUUIDs(tableMap, opts) {
|
44
59
|
_.each(tableMap, (table, tableName) => {
|
45
|
-
let
|
60
|
+
let hasNumericId = false;
|
46
61
|
_.each(table.attributes, (attr, attrName) => {
|
47
62
|
if (
|
48
63
|
(attr.isPrimaryKey || attr.isForeignKey) &&
|
49
64
|
attr.dataType === "NUMERIC"
|
50
65
|
) {
|
51
66
|
if (attr.isPrimaryKey) {
|
52
|
-
|
53
|
-
nid.isPrimaryKey = false;
|
54
|
-
nid.nullable = true;
|
67
|
+
hasNumericId = true;
|
55
68
|
attr.defaultRawValue = "gen_random_uuid()";
|
56
69
|
delete attr.defaultValue;
|
57
70
|
delete attr.autoIncrement;
|
@@ -59,20 +72,22 @@ function convertNumericIdsToUUIDs(tableMap, opts) {
|
|
59
72
|
attr.dataType = "UUID";
|
60
73
|
}
|
61
74
|
});
|
62
|
-
if (
|
63
|
-
table.attributes["nid"] =
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
75
|
+
if (table.attributes) {
|
76
|
+
table.attributes["nid"] = clone(nidTemplate);
|
77
|
+
if (hasNumericId) {
|
78
|
+
table.attributes["legacy_id"] = {
|
79
|
+
name: "legacy_id",
|
80
|
+
dataType: "NUMERIC",
|
81
|
+
isPrimaryKey: false,
|
82
|
+
isForeignKey: false,
|
83
|
+
size: "",
|
84
|
+
precision: "",
|
85
|
+
scale: "",
|
86
|
+
nullable: true,
|
87
|
+
defaultValue: "",
|
88
|
+
columnName: "legacy_id",
|
89
|
+
};
|
90
|
+
}
|
76
91
|
}
|
77
92
|
});
|
78
93
|
return tableMap;
|
@@ -31,6 +31,10 @@ module.exports = function convertTableToTypeDef(
|
|
31
31
|
isKey: attrDef.isPrimaryKey,
|
32
32
|
};
|
33
33
|
|
34
|
+
if (attrDef.isReadOnly) {
|
35
|
+
typeAttrs[attrName].isReadOnly = true;
|
36
|
+
}
|
37
|
+
|
34
38
|
if (attrDef.isForeignKey || attrDef.isRelatedKey) {
|
35
39
|
typeAttrs[attrName].required = false;
|
36
40
|
|
package/src/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
const Promise = require("bluebird");
|
2
|
-
const { shortenName } = require("./datamodel-csv-parser/Utils");
|
2
|
+
const { shortenName, maxLength } = require("./datamodel-csv-parser/Utils");
|
3
3
|
const {
|
4
4
|
loadResolvers,
|
5
5
|
loadMockResolvers,
|
@@ -27,6 +27,7 @@ module.exports = (function () {
|
|
27
27
|
knexTools,
|
28
28
|
graphqlGenerators,
|
29
29
|
shortenName,
|
30
|
+
maxLength
|
30
31
|
};
|
31
32
|
|
32
33
|
function mockPromise() {
|
@@ -71,7 +71,7 @@ function createTables(db, tableSpecs, opts = {}) {
|
|
71
71
|
.map((c) => `"${c}"`)
|
72
72
|
.join(", ")}) WHERE ${indexSpec.columns
|
73
73
|
.map((c) => `"${c}" IS NOT NULL `)
|
74
|
-
.join("
|
74
|
+
.join(" AND ")}`;
|
75
75
|
rawCommands.push(sparseIndexCmd);
|
76
76
|
// console.log(`Adding sparse index cmd: `, sparseIndexCmd);
|
77
77
|
} else {
|