mandarina-server 1.3.2 → 1.3.5
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/build/Action/CustomAction.js +21 -24
- package/build/Action/CustomAction.js.map +1 -1
- package/build/Prisma2/Prisma2.d.ts +0 -0
- package/build/Prisma2/Prisma2.js +1 -0
- package/build/Prisma2/Prisma2.js.map +1 -0
- package/build/Table/Table.js +16 -2
- package/build/Table/Table.js.map +1 -1
- package/build/cli/gen-files/prisma2.d.ts +1 -0
- package/build/cli/gen-files/prisma2.js +220 -0
- package/build/cli/gen-files/prisma2.js.map +1 -0
- package/build/cli/index.js +5 -0
- package/build/cli/index.js.map +1 -1
- package/build/cli/utils.d.ts +1 -0
- package/build/cli/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/Action/CustomAction.js +108 -0
- package/src/Action/CustomAction.js.map +1 -0
- package/src/Action/CustomAction.ts +17 -13
- package/src/Errors/TableInstanceNotFound.js +28 -0
- package/src/Errors/TableInstanceNotFound.js.map +1 -0
- package/src/Errors/UniqueActionError.js +31 -0
- package/src/Errors/UniqueActionError.js.map +1 -0
- package/src/Mandarina.js +58 -0
- package/src/Mandarina.js.map +1 -0
- package/src/Prisma2/Prisma2.ts +0 -0
- package/src/Table/Table.js.map +1 -0
- package/src/Table/Table.ts +12 -2
- package/src/cli/gen-files/prisma2.ts +220 -0
- package/src/cli/index.ts +24 -18
- package/src/cli/utils.js +91 -0
- package/src/cli/utils.js.map +1 -0
- package/src/cli/utils.ts +1 -0
- package/src/index.js +16 -0
- package/src/index.js.map +1 -0
|
@@ -3,6 +3,7 @@ import {TableInstanceNotFound} from "../Errors/TableInstanceNotFound";
|
|
|
3
3
|
import {UniqueActionError} from "../Errors/UniqueActionError";
|
|
4
4
|
|
|
5
5
|
import {Permission} from "mandarina/build/Schema/Schema";
|
|
6
|
+
import Mandarina from "../Mandarina";
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
@@ -58,19 +59,22 @@ export class CustomAction {
|
|
|
58
59
|
|
|
59
60
|
Object.keys(actions).forEach((action) => {
|
|
60
61
|
result[action] = async (_: any, args: any, context: any, info: any): Promise<any> => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
62
|
+
const user = await Mandarina.config.getUser(context)
|
|
63
|
+
const roles=(user && user.roles ) || []
|
|
64
|
+
if (roles.includes('nobody')){
|
|
65
|
+
throw new Error('Action not allowed')
|
|
66
|
+
}
|
|
67
|
+
const permissions: string[]= actions[action].permission || []
|
|
68
|
+
if (permissions.includes('everybody') || permissions.some(permission=>roles.includes(permission))){
|
|
69
|
+
console.log('***************111***************')
|
|
70
|
+
console.warn(user && user.id,action)
|
|
71
|
+
console.warn(user && user.roles,permissions)
|
|
72
|
+
console.log('***************222***************')
|
|
73
|
+
|
|
74
|
+
// return await actions[action].action(_, args, context, info)
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`Action "${action}" not allowed for this user`)
|
|
77
|
+
};
|
|
74
78
|
});
|
|
75
79
|
|
|
76
80
|
return result;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
var BaseError_1 = __importDefault(require("mandarina/build/Errors/BaseError"));
|
|
20
|
+
var TableInstanceNotFound = /** @class */ (function (_super) {
|
|
21
|
+
__extends(TableInstanceNotFound, _super);
|
|
22
|
+
function TableInstanceNotFound(schemaName) {
|
|
23
|
+
return _super.call(this, "The table " + schemaName + " was not instantiated") || this;
|
|
24
|
+
}
|
|
25
|
+
return TableInstanceNotFound;
|
|
26
|
+
}(BaseError_1.default));
|
|
27
|
+
exports.TableInstanceNotFound = TableInstanceNotFound;
|
|
28
|
+
//# sourceMappingURL=TableInstanceNotFound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableInstanceNotFound.js","sourceRoot":"","sources":["TableInstanceNotFound.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+EAAyD;AAEzD;IAA2C,yCAAS;IACnD,+BAAY,UAAkB;eAC7B,kBAAM,eAAa,UAAU,0BAAuB,CAAC;IACtD,CAAC;IACF,4BAAC;AAAD,CAAC,AAJD,CAA2C,mBAAS,GAInD;AAJY,sDAAqB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
var BaseError_1 = __importDefault(require("mandarina/build/Errors/BaseError"));
|
|
20
|
+
var UniqueActionError = /** @class */ (function (_super) {
|
|
21
|
+
__extends(UniqueActionError, _super);
|
|
22
|
+
function UniqueActionError(schemaName) {
|
|
23
|
+
var _this = this;
|
|
24
|
+
var name = typeof schemaName === "string" ? schemaName : schemaName.name;
|
|
25
|
+
_this = _super.call(this, "The action \"" + name + "\" already exists, action name should be unique.") || this;
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
return UniqueActionError;
|
|
29
|
+
}(BaseError_1.default));
|
|
30
|
+
exports.UniqueActionError = UniqueActionError;
|
|
31
|
+
//# sourceMappingURL=UniqueActionError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UniqueActionError.js","sourceRoot":"","sources":["UniqueActionError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+EAAyD;AAGzD;IAAuC,qCAAS;IAC/C,2BAAY,UAA2B;QAAvC,iBAGC;QAFA,IAAM,IAAI,GAAG,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAA;QAC1E,QAAA,kBAAM,kBAAe,IAAI,qDAAiD,CAAC,SAAC;;IAC7E,CAAC;IACF,wBAAC;AAAD,CAAC,AALD,CAAuC,mBAAS,GAK/C;AALY,8CAAiB"}
|
package/src/Mandarina.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var Table_1 = require("./Table/Table");
|
|
15
|
+
var CustomAction_1 = require("./Action/CustomAction");
|
|
16
|
+
var utils_1 = require("./cli/utils");
|
|
17
|
+
var Mandarina = /** @class */ (function () {
|
|
18
|
+
function Mandarina() {
|
|
19
|
+
}
|
|
20
|
+
Mandarina.load = function () {
|
|
21
|
+
var config = utils_1.getConfig();
|
|
22
|
+
utils_1.loadSchemas(config.dir);
|
|
23
|
+
};
|
|
24
|
+
Mandarina.getQuery = function () {
|
|
25
|
+
var Query = {};
|
|
26
|
+
for (var tableName in Table_1.Table.instances) {
|
|
27
|
+
var table = Table_1.Table.getInstance(tableName);
|
|
28
|
+
Query = __assign(__assign({}, Query), table.getDefaultActions('query'));
|
|
29
|
+
}
|
|
30
|
+
return Query;
|
|
31
|
+
};
|
|
32
|
+
Mandarina.getMutation = function () {
|
|
33
|
+
var Mutation = {};
|
|
34
|
+
for (var tableName in Table_1.Table.instances) {
|
|
35
|
+
var table = Table_1.Table.getInstance(tableName);
|
|
36
|
+
Mutation = __assign(__assign({}, Mutation), table.getDefaultActions('mutation'));
|
|
37
|
+
}
|
|
38
|
+
for (var actionName in CustomAction_1.CustomAction.instances) {
|
|
39
|
+
var action = CustomAction_1.CustomAction.getInstance(actionName);
|
|
40
|
+
Mutation = __assign(__assign({}, Mutation), action.getActions());
|
|
41
|
+
}
|
|
42
|
+
return Mutation;
|
|
43
|
+
};
|
|
44
|
+
Mandarina.config = {
|
|
45
|
+
getUser: function (_a) {
|
|
46
|
+
var user = _a.user;
|
|
47
|
+
return user;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
Mandarina.configure = function (options) {
|
|
51
|
+
if (options.getUser) {
|
|
52
|
+
Mandarina.config.getUser = options.getUser;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return Mandarina;
|
|
56
|
+
}());
|
|
57
|
+
exports.default = Mandarina;
|
|
58
|
+
//# sourceMappingURL=Mandarina.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Mandarina.js","sourceRoot":"","sources":["Mandarina.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,uCAA6C;AAC7C,sDAAmD;AACnD,qCAAmD;AAGnD;IAAA;IAsCA,CAAC;IArCU,cAAI,GAAX;QACI,IAAM,MAAM,GAAC,iBAAS,EAAE,CAAA;QACxB,mBAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC3B,CAAC;IAaM,kBAAQ,GAAf;QACI,IAAI,KAAK,GAAG,EAAE,CAAA;QACd,KAAK,IAAM,SAAS,IAAI,aAAK,CAAC,SAAS,EAAE;YACrC,IAAM,KAAK,GAAG,aAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;YAC1C,KAAK,yBAAO,KAAK,GAAK,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAA;SAC1D;QACD,OAAO,KAAK,CAAA;IAChB,CAAC;IAEM,qBAAW,GAAlB;QACI,IAAI,QAAQ,GAAG,EAAE,CAAA;QACjB,KAAK,IAAM,SAAS,IAAI,aAAK,CAAC,SAAS,EAAE;YACrC,IAAM,KAAK,GAAG,aAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;YAC1C,QAAQ,yBAAO,QAAQ,GAAK,KAAK,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAA;SACnE;QACD,KAAK,IAAM,UAAU,IAAI,2BAAY,CAAC,SAAS,EAAE;YAC7C,IAAM,MAAM,GAAG,2BAAY,CAAC,WAAW,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,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;AAE/B,CAAC;AAJD,gBAIC"}
|
package/src/Table/Table.ts
CHANGED
|
@@ -151,7 +151,7 @@ export class Table {
|
|
|
151
151
|
if (data.errors){
|
|
152
152
|
console.error(data.errors)
|
|
153
153
|
}
|
|
154
|
-
result =
|
|
154
|
+
result =Object.values(data.data)[0]
|
|
155
155
|
context.result = result
|
|
156
156
|
await this.callHook(this.name, <HookName>`after${capitalizedAction}`, _, args, context, query);
|
|
157
157
|
this.schema.validateQuery(fields, user && user.roles || []);
|
|
@@ -174,7 +174,7 @@ export class Table {
|
|
|
174
174
|
if (data.errors){
|
|
175
175
|
console.error(data.errors)
|
|
176
176
|
}
|
|
177
|
-
result = data.data[
|
|
177
|
+
result = Object.values(data.data)[0]
|
|
178
178
|
if (operationName===this.schema.names.query.single){
|
|
179
179
|
result = data.data[this.schema.names.query.plural]
|
|
180
180
|
result=result && result.length===1 ? result[0] : null
|
|
@@ -193,8 +193,18 @@ export class Table {
|
|
|
193
193
|
const field: string[] = []
|
|
194
194
|
const fields = new Set<string>()
|
|
195
195
|
let required = false
|
|
196
|
+
const allowedVariables=info.fieldNodes[0]?.arguments?.map(({name:{value}})=>value) || []
|
|
197
|
+
console.log(allowedVariables)
|
|
196
198
|
const query = visit(info.operation, {
|
|
197
199
|
enter: (node, key, parent, path, ancestors) => {
|
|
200
|
+
if (node.kind==='VariableDefinition'){
|
|
201
|
+
if (!allowedVariables.includes(node?.variable.name.value)){
|
|
202
|
+
return null
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (node.kind === 'Field' && ancestors.length===2 && node!==info.fieldNodes[0]){
|
|
206
|
+
return null
|
|
207
|
+
}
|
|
198
208
|
if (node.kind === 'Field' && node.name.value !== '__typename') {
|
|
199
209
|
field.push(node.name.value)
|
|
200
210
|
const internalField = field.slice(1).join('.')
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import {getConfig, loadSchemas} from "../utils";
|
|
2
|
+
import {createDir, resetDir} from "./genFilesUtils";
|
|
3
|
+
import {Table} from "../..";
|
|
4
|
+
import {Schema} from "mandarina";
|
|
5
|
+
import {capitalize, isRequired} from "mandarina/build/Schema/utils";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import {FieldDefinition} from "mandarina/build/Schema/Schema";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
const prisma2Models: { [schemaName: string]: { [fieldName: string]: string } } = {}
|
|
12
|
+
const proccesed: string[] = []
|
|
13
|
+
let c = 0
|
|
14
|
+
export const genFile = () => {
|
|
15
|
+
const config = getConfig()
|
|
16
|
+
loadSchemas(config.dir)
|
|
17
|
+
createDir(config.dir.prisma2)
|
|
18
|
+
resetDir(config.dir.prisma2)
|
|
19
|
+
for (const schemaName in Table.instances) {
|
|
20
|
+
const schema = Schema.getInstance(schemaName)
|
|
21
|
+
getPrisma2Model(schema)
|
|
22
|
+
}
|
|
23
|
+
let prisma = `generator client {
|
|
24
|
+
provider = "prisma-client-js"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
datasource db {
|
|
28
|
+
provider = "postgresql"
|
|
29
|
+
url = env("DATABASE_URL")
|
|
30
|
+
}
|
|
31
|
+
`
|
|
32
|
+
Object.keys(prisma2Models).forEach(modelName => {
|
|
33
|
+
const model = prisma2Models[modelName]
|
|
34
|
+
prisma += `model ${modelName} {\n `
|
|
35
|
+
Object.keys(model).forEach(fieldName => {
|
|
36
|
+
const field = model[fieldName]
|
|
37
|
+
prisma += `\t${fieldName} ${field}\n`
|
|
38
|
+
})
|
|
39
|
+
prisma += `}\n\n`
|
|
40
|
+
})
|
|
41
|
+
const prismaDir = path.join(process.cwd(), config.dir.prisma2,)
|
|
42
|
+
const fileAbs = `${prismaDir}/schema.prisma`;
|
|
43
|
+
fs.writeFileSync(fileAbs, prisma);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getRelationName(parentDef: FieldDefinition) {
|
|
47
|
+
if (!parentDef.table.relation) return ''
|
|
48
|
+
if (typeof parentDef.table.relation === 'string') {
|
|
49
|
+
return parentDef.table.relation
|
|
50
|
+
}
|
|
51
|
+
return parentDef.table.relation.name || ''
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const getPrisma2Model = (schema: Schema, parent?: Schema, parentName?: string) => {
|
|
55
|
+
prisma2Models[schema.name] = prisma2Models[schema.name] || {}
|
|
56
|
+
let selfDef: FieldDefinition | null = null
|
|
57
|
+
for (const key of schema.keys) {
|
|
58
|
+
if (key === 'id') {
|
|
59
|
+
c++
|
|
60
|
+
prisma2Models[schema.name].id = `String @id @default(cuid()) //${c}`;
|
|
61
|
+
} else {
|
|
62
|
+
const fieldDefinition = schema.getPathDefinition(key)
|
|
63
|
+
let required = fieldDefinition.isArray || isRequired(fieldDefinition)
|
|
64
|
+
const fieldType = getGraphQLType(fieldDefinition, key, required);
|
|
65
|
+
const unique = fieldDefinition.table.unique ? '@unique' : ''
|
|
66
|
+
let defaultValue = ''
|
|
67
|
+
if (fieldDefinition.table.default !== undefined) {
|
|
68
|
+
const wrapper = (fieldDefinition.type === String) ? '"' : ''
|
|
69
|
+
defaultValue = `@default(${wrapper}${fieldDefinition.table.default}${wrapper})`
|
|
70
|
+
}
|
|
71
|
+
let relation: string = ''
|
|
72
|
+
if (fieldDefinition.isTable) {
|
|
73
|
+
|
|
74
|
+
const processedName = [schema.name, key].join('-')
|
|
75
|
+
let relationName = getRelationName(fieldDefinition)
|
|
76
|
+
let childExists=false
|
|
77
|
+
if (parent && parentName) {
|
|
78
|
+
const parentDef = parent.getPathDefinition(parentName)
|
|
79
|
+
let parentRelationName = getRelationName(parentDef)
|
|
80
|
+
if (parent && (fieldDefinition.type === parent.name ) && (parentRelationName === relationName)) { //child exists
|
|
81
|
+
selfDef = fieldDefinition
|
|
82
|
+
childExists=true
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!proccesed.includes(processedName)) {
|
|
86
|
+
proccesed.push(processedName)
|
|
87
|
+
if (!childExists) {
|
|
88
|
+
getPrisma2Model(Schema.getInstance(fieldDefinition.type), schema, key)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
|
|
93
|
+
let createdAt = '', updatedAt = ''
|
|
94
|
+
if ((fieldDefinition.table.createdAt === true || (fieldDefinition.table.createdAt !== false && key === 'createdAt'))) {
|
|
95
|
+
createdAt = `@default(now())`
|
|
96
|
+
}
|
|
97
|
+
if ((fieldDefinition.table.updatedAt === true || (fieldDefinition.table.updatedAt !== false && key === 'updatedAt'))) {
|
|
98
|
+
createdAt = `@default(now())`
|
|
99
|
+
}
|
|
100
|
+
if (!fieldType) {
|
|
101
|
+
throw new Error('no type')
|
|
102
|
+
}
|
|
103
|
+
prisma2Models[schema.name][key] = `${fieldType} ${unique} ${createdAt} ${updatedAt} ${defaultValue} ${relation} `;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}// end for
|
|
107
|
+
if (parent && parentName) {
|
|
108
|
+
const parentDef = parent.getPathDefinition(parentName)
|
|
109
|
+
let parentRelationName = getRelationName(parentDef)
|
|
110
|
+
const parentArray = parentDef.isArray
|
|
111
|
+
if (selfDef) {
|
|
112
|
+
if (selfDef.key==='visitStaff'){
|
|
113
|
+
console.log('visitStaff')
|
|
114
|
+
}
|
|
115
|
+
let childRelationName = getRelationName(selfDef)
|
|
116
|
+
const childArray = selfDef.isArray
|
|
117
|
+
if (childRelationName !== parentRelationName) {
|
|
118
|
+
throw new Error(`${childRelationName}-parentRelationName`)
|
|
119
|
+
}
|
|
120
|
+
if (!parentArray && !childArray) { //1 - 1
|
|
121
|
+
const relation = getRelationName(parentDef) || `${[parent.name, `${selfDef.type}_${selfDef.key}`].join('_Exist_')}`
|
|
122
|
+
if (typeof parentDef.table?.relation !== 'string' && parentDef.table?.relation?.link) {
|
|
123
|
+
prisma2Models[parent.name][parentDef.key] = `${parentDef.type}? @relation(fields: [${parentDef.key}Id], references: [id],name: "${relation}") // 1`
|
|
124
|
+
prisma2Models[parent.name][`${parentDef.key}Id`] = `String?`
|
|
125
|
+
prisma2Models[schema.name][`${selfDef.key}`] = `${selfDef.type}? @relation(name: "${relation}") // 2`
|
|
126
|
+
} else {
|
|
127
|
+
if (schema.name===parent.name){
|
|
128
|
+
prisma2Models[schema.name][`${relation}`] = `${parentDef.type}? @relation(name: "${relation}") // 3.1 `
|
|
129
|
+
prisma2Models[schema.name][`${selfDef.key}`] = `${selfDef.type}? @relation(fields: [${selfDef.key}Id], references: [id], name: "${relation}") // 4.1 ${parentDef.key} ${selfDef.key}`
|
|
130
|
+
prisma2Models[schema.name][`${selfDef.key}Id`] = `String?`
|
|
131
|
+
}else{
|
|
132
|
+
prisma2Models[parent.name][parentDef.key] = `${parentDef.type}? @relation(name: "${relation}") // 3`
|
|
133
|
+
prisma2Models[schema.name][`${selfDef.key}`] = `${selfDef.type}? @relation(fields: [${selfDef.key}Id], references: [id], name: "${relation}") // 4`
|
|
134
|
+
prisma2Models[schema.name][`${selfDef.key}Id`] = `String?`
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (parentArray && !childArray) { // n - 1
|
|
140
|
+
const relation = getRelationName(parentDef) || `${[parent.name, `${schema.name}_${selfDef.key}`].join('_Exist_')}`
|
|
141
|
+
prisma2Models[parent.name][parentDef.key] = `${parentDef.type}[] @relation(name: "${relation}") //5 `
|
|
142
|
+
prisma2Models[schema.name][selfDef.key] = `${selfDef.type}? @relation(fields: [${selfDef.key}Id], references: [id], name: "${relation}") // 6`
|
|
143
|
+
prisma2Models[schema.name][`${selfDef.key}Id`] = `String?`
|
|
144
|
+
|
|
145
|
+
}
|
|
146
|
+
if (!parentArray && childArray) { // 1 - n
|
|
147
|
+
const relation = getRelationName(parentDef) || `${[parent.name, `${schema.name}_${selfDef.key}`].join('_Exist_')}`
|
|
148
|
+
prisma2Models[schema.name][selfDef.key] = `${selfDef.type}[] @relation(name: "${relation}") //7`
|
|
149
|
+
prisma2Models[parent.name][parentDef.key] = `${parentDef.type}? @relation(fields: [${parentDef.key}Id], references: [id], name: "${relation}") //7.1`
|
|
150
|
+
prisma2Models[parent.name][`${parentDef.key}Id`] = `String?`
|
|
151
|
+
}
|
|
152
|
+
if (parentArray && childArray) { // n - n
|
|
153
|
+
const relation = getRelationName(parentDef) || `${[parent.name, `${schema.name}_${selfDef.key}`].join('_Exist_')}`
|
|
154
|
+
if (schema.name===parent.name){
|
|
155
|
+
prisma2Models[parent.name][parentDef.key] = `${parentDef.type}[] @relation(name: "${relation}", references: [id]) // 8 self1`
|
|
156
|
+
prisma2Models[schema.name][`${selfDef.key}2`] = `${selfDef.type}[] @relation(name: "${relation}", references: [id]) // 9 self2`
|
|
157
|
+
}else{
|
|
158
|
+
prisma2Models[parent.name][parentDef.key] = `${parentDef.type}[] @relation(name: "${relation}") // 8`
|
|
159
|
+
prisma2Models[schema.name][selfDef.key] = `${selfDef.type}[] @relation(name: "${relation}") // 9`
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
const parentRelationName= getRelationName(parentDef)
|
|
165
|
+
|
|
166
|
+
if (!parentArray) { //1 - n
|
|
167
|
+
const relation =parentRelationName || `${[parent.name, `${schema.name}_${parentDef.key}`].join('_Exist_')}`
|
|
168
|
+
prisma2Models[parent.name][parentDef.key] = `${parentDef.type}? @relation(name: "${relation}") //10`
|
|
169
|
+
prisma2Models[schema.name][`${parentRelationName || parent.name}${parent.names.query.single}`] = `${parent.name}? @relation(fields: [${parentRelationName ||parent.name}${parent.names.query.single}Id], references: [id], name: "${relation}") // 11`
|
|
170
|
+
prisma2Models[schema.name][`${parentRelationName || parent.name}${parent.names.query.single}Id`] = `String?`
|
|
171
|
+
|
|
172
|
+
}
|
|
173
|
+
if (parentArray) { // n - 1
|
|
174
|
+
const name = parent.names.query.single
|
|
175
|
+
const relation =parentRelationName || `${[parent.name, `${schema.name}_${name}`].join('_Exist_')}`
|
|
176
|
+
prisma2Models[parent.name][parentDef.key] = `${parentDef.type}[] @relation(name: "${relation}") // 12 `
|
|
177
|
+
prisma2Models[schema.name][`${parentRelationName || parent.name}${capitalize(parentDef.key)}`] = `${parent.name}? @relation(fields: [${parentRelationName || parent.name}${capitalize(parentDef.key)}Id], references: [id], name: "${relation}") // 13`
|
|
178
|
+
prisma2Models[schema.name][`${parentRelationName || parent.name}${capitalize(parentDef.key)}Id`] = `String?`
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// if (typeof fieldDefinition.table?.relation !== 'string' && fieldDefinition.table?.relation?.link) {
|
|
185
|
+
// const nameId = `${key}Id`
|
|
186
|
+
// prisma2Models[schema.name][nameId] = `String //id with link`;
|
|
187
|
+
// relations.push(`fields: [${nameId}]`)
|
|
188
|
+
// relations.push(`references: [id]`)
|
|
189
|
+
// }
|
|
190
|
+
// if (relations.length > 0) {
|
|
191
|
+
// relation = `@relation(${relations.join(', ')})`
|
|
192
|
+
// }
|
|
193
|
+
// prisma2Models[schema.name][key] = `${fieldType} ${unique} ${defaultValue} ${relation} //deeping call=> ${fieldDefinition.type}`;
|
|
194
|
+
const getGraphQLType = (def: FieldDefinition, key: string, required: boolean): string => {
|
|
195
|
+
const optional = !def.isArray && !required ? '?' : ''
|
|
196
|
+
switch (true) {
|
|
197
|
+
case (!def.isArray && !def.isTable && def.type.name === 'String'):
|
|
198
|
+
return `String${optional}`;
|
|
199
|
+
|
|
200
|
+
case (!def.isArray && !def.isTable && def.type.name === 'Boolean'):
|
|
201
|
+
return `Boolean${optional}`;
|
|
202
|
+
|
|
203
|
+
case (!def.isArray && !def.isTable && def.type.name === 'Number'):
|
|
204
|
+
return `Float${optional}`;
|
|
205
|
+
|
|
206
|
+
case (!def.isArray && !def.isTable && def.type.name === 'Integer'):
|
|
207
|
+
return `Int${optional}`;
|
|
208
|
+
case (!def.isArray && !def.isTable && def.type.name === 'Date'):
|
|
209
|
+
return `DateTime${optional}`;
|
|
210
|
+
case (def.isArray && def.isTable):
|
|
211
|
+
return `${def.type}[]`
|
|
212
|
+
case (def.isArray && !def.isTable):
|
|
213
|
+
const scalarName = getGraphQLType({...def, isArray: false}, key, def.isArray && required)
|
|
214
|
+
return `${scalarName}[]`
|
|
215
|
+
default:
|
|
216
|
+
return def.type + optional;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
package/src/cli/index.ts
CHANGED
|
@@ -3,29 +3,35 @@ import {createProject} from "./createProject";
|
|
|
3
3
|
import {watch} from "./watch";
|
|
4
4
|
import {deploy} from "./deploy";
|
|
5
5
|
import {genFile} from "./gen-files/genFiles";
|
|
6
|
+
import {genFile as genPrisma2} from "./gen-files/prisma2";
|
|
7
|
+
|
|
8
|
+
console.log('cesar')
|
|
6
9
|
|
|
7
10
|
//@ts-ignore
|
|
8
11
|
const [nodeDir, dir, cmd, ...args] = process.argv
|
|
9
12
|
|
|
10
13
|
switch (cmd) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
case "create":
|
|
15
|
+
const project = args && args[0] || 'mandarina'
|
|
16
|
+
createProject(project)
|
|
17
|
+
break
|
|
18
|
+
case 'gen-files':
|
|
19
|
+
genFile()
|
|
20
|
+
break;
|
|
21
|
+
case 'gen-prisma2':
|
|
22
|
+
genPrisma2()
|
|
23
|
+
break;
|
|
24
|
+
case 'deploy':
|
|
25
|
+
deploy()
|
|
26
|
+
break;
|
|
27
|
+
case 'watch':
|
|
28
|
+
watch()
|
|
29
|
+
break;
|
|
30
|
+
case undefined:
|
|
31
|
+
console.info(`You need to pass a command at first argument`)
|
|
32
|
+
break
|
|
33
|
+
default:
|
|
34
|
+
console.info(`command ${cmd} not found, available commands: "create","gen-files","deploy","watch`)
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
/*
|
package/src/cli/utils.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var fs_1 = __importDefault(require("fs"));
|
|
7
|
+
var path_1 = __importDefault(require("path"));
|
|
8
|
+
exports.getConfig = function () {
|
|
9
|
+
var rawData;
|
|
10
|
+
try {
|
|
11
|
+
rawData = fs_1.default.readFileSync(path_1.default.join(process.cwd(), 'mandarina.json'), 'utf8');
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
throw Error('Error: Be sure you are running your server from the root (where mandarina.json file is located');
|
|
15
|
+
}
|
|
16
|
+
var config = JSON.parse(rawData);
|
|
17
|
+
if (!config.dir) {
|
|
18
|
+
throw Error('Error: please set "dir" in madarina.json file');
|
|
19
|
+
}
|
|
20
|
+
if (!config.dir.schemas || !Array.isArray(config.dir.schemas) || config.dir.schemas.length === 0) {
|
|
21
|
+
throw Error('Error: please set "dir.schemas" in madarina.json file. Make sure it is a array');
|
|
22
|
+
}
|
|
23
|
+
if (config.dir.actions && !Array.isArray(config.dir.actions)) {
|
|
24
|
+
throw Error('Error: please make sure "dir.actions" is a array');
|
|
25
|
+
}
|
|
26
|
+
if (config.dir.tables && !Array.isArray(config.dir.tables)) {
|
|
27
|
+
throw Error('Error: please make sure "dir.tables" is a array');
|
|
28
|
+
}
|
|
29
|
+
if (!config.dir.prisma) {
|
|
30
|
+
throw Error('Error: please set "dir.prisma" in madarina.json file');
|
|
31
|
+
}
|
|
32
|
+
if (!config.dir.generated) {
|
|
33
|
+
throw Error('Error: please set "dir.generated" in madarina.json file');
|
|
34
|
+
}
|
|
35
|
+
return (config);
|
|
36
|
+
};
|
|
37
|
+
var walkSync = function (dir, fileList) {
|
|
38
|
+
var files = fs_1.default.readdirSync(dir);
|
|
39
|
+
fileList = fileList || [];
|
|
40
|
+
files.forEach(function (file) {
|
|
41
|
+
var pathFile = path_1.default.join(dir, file);
|
|
42
|
+
if (fs_1.default.statSync(pathFile).isDirectory()) {
|
|
43
|
+
fileList = walkSync(pathFile, fileList);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
if (path_1.default.extname(file) === '.js')
|
|
47
|
+
fileList.push(pathFile);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return fileList;
|
|
51
|
+
};
|
|
52
|
+
exports.loadSchemas = function (dir) {
|
|
53
|
+
var tables = [];
|
|
54
|
+
var schemas = [];
|
|
55
|
+
var actions = [];
|
|
56
|
+
dir.schemas.forEach(function (dir) {
|
|
57
|
+
schemas = walkSync(path_1.default.join(process.cwd(), dir), schemas);
|
|
58
|
+
});
|
|
59
|
+
if (dir.actions) {
|
|
60
|
+
dir.actions.forEach(function (dir) {
|
|
61
|
+
actions = walkSync(path_1.default.join(process.cwd(), dir), actions);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (dir.tables) {
|
|
65
|
+
dir.tables.forEach(function (dir) {
|
|
66
|
+
tables = walkSync(path_1.default.join(process.cwd(), dir), tables);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
schemas.forEach(function (schema) {
|
|
70
|
+
var content = fs_1.default.readFileSync(schema, 'utf8');
|
|
71
|
+
if (true || content.match(/new *Schema/)) {
|
|
72
|
+
console.info('loading schema: ', schema);
|
|
73
|
+
require(schema);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
tables.forEach(function (table) {
|
|
77
|
+
var content = fs_1.default.readFileSync(table, 'utf8');
|
|
78
|
+
if (true || content.match(/new *Table/)) {
|
|
79
|
+
console.info('loading table: ', table);
|
|
80
|
+
require(table);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
actions.forEach(function (action) {
|
|
84
|
+
var content = fs_1.default.readFileSync(action, 'utf8');
|
|
85
|
+
if (true || content.match(/new *Table/)) {
|
|
86
|
+
console.info('loading action: ', action);
|
|
87
|
+
require(action);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":";;;;;AAAA,0CAAoB;AACpB,8CAAwB;AAEX,QAAA,SAAS,GAAG;IACrB,IAAI,OAAO,CAAA;IACX,IAAI;QACA,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC,CAAA;KAChF;IAAC,OAAO,CAAC,EAAE;QACR,MAAM,KAAK,CAAC,gGAAgG,CAAC,CAAA;KAChH;IACD,IAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAElC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;QACb,MAAM,KAAK,CAAC,gDAAgD,CAAC,CAAA;KAChE;IACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QAC9F,MAAM,KAAK,CAAC,iFAAiF,CAAC,CAAA;KACjG;IACD,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QAC1D,MAAM,KAAK,CAAC,kDAAkD,CA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AAO,CAAC,KAAK,CAAC,CAAA;SACjB;IACL,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,OAAO,CAAC,UAAC,MAAM;QACnB,IAAM,OAAO,GAAW,YAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxD,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE;YACrC,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAA;YACxC,OAAO,CAAC,MAAM,CAAC,CAAA;SAClB;IACL,CAAC,CAAC,CAAA;AACN,CAAC,CAAA"}
|
package/src/cli/utils.ts
CHANGED
package/src/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var CustomAction_1 = require("./Action/CustomAction");
|
|
7
|
+
exports.CustomAction = CustomAction_1.CustomAction;
|
|
8
|
+
var Table_1 = require("./Table/Table");
|
|
9
|
+
exports.Table = Table_1.Table;
|
|
10
|
+
var Mandarina_1 = __importDefault(require("./Mandarina"));
|
|
11
|
+
var utils_1 = require("./cli/utils");
|
|
12
|
+
exports.getConfig = utils_1.getConfig;
|
|
13
|
+
var Action = CustomAction_1.CustomAction; //for backward compatibility
|
|
14
|
+
exports.Action = Action;
|
|
15
|
+
exports.default = Mandarina_1.default;
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AAAA,sDAAkD;AAW9C,uBAXI,2BAAY,CAWJ;AAVhB,uCAAmC;AAY/B,gBAZI,aAAK,CAYJ;AAXT,0DAAmC;AACnC,qCAAqC;AAOjC,oBAPI,iBAAS,CAOJ;AAJb,IAAM,MAAM,GAAC,2BAAY,CAAA,CAAC,4BAA4B;AAMlD,wBAAM;AAJV,kBAAe,mBAAS,CAAA"}
|