mandarina-server 2.1.51 → 2.1.53

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.
@@ -18,7 +18,7 @@ export declare class CustomAction {
18
18
  */
19
19
  constructor(schema: Schema | string, actionOptions: ActionOptions);
20
20
  static getInstance(name: string): CustomAction;
21
- getFields(): any;
21
+ getFields(): string[] | undefined;
22
22
  getActions(): {};
23
23
  }
24
24
  export interface ActionOptions {
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -39,6 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.CustomAction = void 0;
42
43
  var Schema_1 = require("mandarina/build/Schema/Schema");
43
44
  var TableInstanceNotFound_1 = require("../Errors/TableInstanceNotFound");
44
45
  var UniqueActionError_1 = require("../Errors/UniqueActionError");
@@ -92,7 +93,7 @@ var CustomAction = /** @class */ (function () {
92
93
  throw new Error('Action not allowed');
93
94
  }
94
95
  if (permissions.includes('everybody') || permissions.some(function (permission) { return roles.includes(permission); })) {
95
- console.log('***************', "Action \"" + action + "\" not allowed for this user", '***************');
96
+ console.log('***************', "Action \"".concat(action, "\" not allowed for this user"), '***************');
96
97
  console.warn(user && user.id, action);
97
98
  console.warn(user && user.roles, permissions);
98
99
  console.log('*****************************************************************************');
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
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]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -16,11 +18,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
17
19
  };
18
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.TableInstanceNotFound = void 0;
19
22
  var BaseError_1 = __importDefault(require("mandarina/build/Errors/BaseError"));
20
23
  var TableInstanceNotFound = /** @class */ (function (_super) {
21
24
  __extends(TableInstanceNotFound, _super);
22
25
  function TableInstanceNotFound(schemaName) {
23
- return _super.call(this, "The table " + schemaName + " was not instantiated") || this;
26
+ return _super.call(this, "The table ".concat(schemaName, " was not instantiated")) || this;
24
27
  }
25
28
  return TableInstanceNotFound;
26
29
  }(BaseError_1.default));
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
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]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -16,14 +18,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
17
19
  };
18
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.UniqueActionError = void 0;
19
22
  var BaseError_1 = __importDefault(require("mandarina/build/Errors/BaseError"));
20
23
  var UniqueActionError = /** @class */ (function (_super) {
21
24
  __extends(UniqueActionError, _super);
22
25
  function UniqueActionError(schemaName) {
23
- var _this = this;
24
26
  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
+ return _super.call(this, "The action \"".concat(name, "\" already exists, action name should be unique.")) || this;
27
28
  }
28
29
  return UniqueActionError;
29
30
  }(BaseError_1.default));
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
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]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -16,11 +18,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
17
19
  };
18
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.UniqueTableError = void 0;
19
22
  var BaseError_1 = __importDefault(require("mandarina/build/Errors/BaseError"));
20
23
  var UniqueTableError = /** @class */ (function (_super) {
21
24
  __extends(UniqueTableError, _super);
22
25
  function UniqueTableError(schemaName) {
23
- return _super.call(this, "The table \"" + schemaName + "\" already exists, table name should be unique") || this;
26
+ return _super.call(this, "The table \"".concat(schemaName, "\" already exists, table name should be unique")) || this;
24
27
  }
25
28
  return UniqueTableError;
26
29
  }(BaseError_1.default));
@@ -6,14 +6,14 @@ export default class Mandarina {
6
6
  static getQuery(): {};
7
7
  static getMutation(): {};
8
8
  }
9
- declare type GetUser = (context: Context) => Promise<UserType | null | undefined> | UserType | null | undefined;
9
+ type GetUser = (context: Context) => Promise<UserType | null | undefined> | UserType | null | undefined;
10
10
  export interface MandarinaConfigOptions {
11
11
  getUser?: GetUser;
12
12
  }
13
13
  export interface MandarinaConfigDefault extends MandarinaConfigOptions {
14
14
  getUser: GetUser;
15
15
  }
16
- export declare type UserType = {
16
+ export type UserType = {
17
17
  id: string;
18
18
  roles: string[];
19
19
  [otherProperties: string]: any;
@@ -18,8 +18,8 @@ var Mandarina = /** @class */ (function () {
18
18
  function Mandarina() {
19
19
  }
20
20
  Mandarina.load = function () {
21
- var config = utils_1.getConfig();
22
- utils_1.loadSchemas(config.dir);
21
+ var config = (0, utils_1.getConfig)();
22
+ (0, utils_1.loadSchemas)(config.dir);
23
23
  };
24
24
  Mandarina.getQuery = function () {
25
25
  var Query = {};
@@ -23,12 +23,12 @@ export declare class Table {
23
23
  static setGlobalHooks: (hooks: Hooks) => void;
24
24
  constructor(schema: Schema, tableOptions?: TableShapeOptions);
25
25
  static getInstance(name: string): Table;
26
- getFields(): any;
26
+ getFields(): string[];
27
27
  shouldHasManyUpdate(): boolean;
28
28
  getDefaultActions(type: operationType): {
29
29
  [resolverName: string]: (_: any, args: any, context: Context, info: any) => void;
30
30
  };
31
- insertWhereIntoInfo: (info: GraphQLResolveInfo, user: UserType | null | undefined, isSingleMutation: boolean | undefined, action: any, operationName: string) => {
31
+ insertWhereIntoInfo: (info: GraphQLResolveInfo, user: UserType | null | undefined, isSingleMutation: boolean | undefined, action: ActionType, operationName: string) => {
32
32
  fields: string[];
33
33
  queryString: string;
34
34
  };
@@ -54,8 +54,8 @@ export interface Context extends ContextParameters {
54
54
  export interface Hook {
55
55
  (_: any, args: any, context: any, info: any): Promise<any> | void | any;
56
56
  }
57
- export declare type operationType = "mutation" | "query";
58
- export declare type Hooks = {
57
+ export type operationType = "mutation" | "query";
58
+ export type Hooks = {
59
59
  beforeValidate?: Hook;
60
60
  afterValidate?: Hook;
61
61
  validationFailed?: Hook;
@@ -74,7 +74,7 @@ export interface TableSchemaOptions {
74
74
  hooks?: Hooks;
75
75
  filters?: Filter[];
76
76
  }
77
- export declare type Filter = {
77
+ export type Filter = {
78
78
  [field: string]: {
79
79
  roles: string[];
80
80
  operator: string;
@@ -85,4 +85,4 @@ export interface TableShapeOptions extends TableSchemaOptions {
85
85
  errorFromServerMapper?: ErrorFromServerMapper;
86
86
  where?: (user: UserType | null | undefined, action: ActionType, operationName: string) => any;
87
87
  }
88
- export declare type HookName = 'beforeValidate' | 'afterValidate' | 'validationFailed' | 'beforeCreate' | 'beforeDelete' | 'beforeUpdate' | 'afterCreate' | 'afterDelete' | 'afterUpdate' | 'beforeQuery' | 'afterQuery';
88
+ export type HookName = 'beforeValidate' | 'afterValidate' | 'validationFailed' | 'beforeCreate' | 'beforeDelete' | 'beforeUpdate' | 'afterCreate' | 'afterDelete' | 'afterUpdate' | 'beforeQuery' | 'afterQuery';
@@ -25,7 +25,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -50,6 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.Table = void 0;
53
54
  var mandarina_1 = require("mandarina");
54
55
  var UniqueSchemaError_1 = require("mandarina/build/Errors/UniqueSchemaError");
55
56
  var SchemaInstanceNotFound_1 = require("mandarina/build/Errors/SchemaInstanceNotFound");
@@ -72,8 +73,8 @@ var Table = /** @class */ (function () {
72
73
  function Table(schema, tableOptions) {
73
74
  var _this = this;
74
75
  this.insertWhereIntoInfo = function (info, user, isSingleMutation, action, operationName) {
75
- if (isSingleMutation === void 0) { isSingleMutation = false; }
76
76
  var _a, _b;
77
+ if (isSingleMutation === void 0) { isSingleMutation = false; }
77
78
  var field = [];
78
79
  var fields = new Set();
79
80
  var required = false;
@@ -81,7 +82,7 @@ var Table = /** @class */ (function () {
81
82
  var value = _a.name.value;
82
83
  return value;
83
84
  })) || [];
84
- var query = language_1.visit(info.operation, {
85
+ var query = (0, language_1.visit)(info.operation, {
85
86
  enter: function (node, key, parent, path, ancestors) {
86
87
  if (node.kind === 'VariableDefinition') {
87
88
  if (!allowedVariables.includes(node === null || node === void 0 ? void 0 : node.variable.name.value)) {
@@ -107,25 +108,25 @@ var Table = /** @class */ (function () {
107
108
  }
108
109
  if (table && table.options.where && (!isSingleMutation && table === _this)) {
109
110
  var where = table.options.where(user, action, operationName);
110
- if (!where || lodash_1.isEmpty(where))
111
+ if (!where || (0, lodash_1.isEmpty)(where))
111
112
  return;
112
- var clone = Mutate_1.deepClone(node);
113
+ var clone = (0, Mutate_1.deepClone)(node);
113
114
  var originalWhereObj = clone.arguments ? clone.arguments.find(function (a) { return a.name.value === 'where'; }) : null;
114
115
  var originalWhereString = '';
115
116
  if (originalWhereObj && table === _this) {
116
- originalWhereString = language_1.print(originalWhereObj.value);
117
+ originalWhereString = (0, language_1.print)(originalWhereObj.value);
117
118
  required = true;
118
119
  }
119
- var newWhereString = stringify_object_1.default(where, { singleQuotes: false });
120
- var finalWhereString = originalWhereString ? "{AND:[" + originalWhereString + "," + newWhereString + "]}" : newWhereString;
120
+ var newWhereString = (0, stringify_object_1.default)(where, { singleQuotes: false });
121
+ var finalWhereString = originalWhereString ? "{AND:[".concat(originalWhereString, ",").concat(newWhereString, "]}") : newWhereString;
121
122
  if (originalWhereObj) {
122
- originalWhereObj.value = language_1.parseValue(new language_1.Source(finalWhereString));
123
+ originalWhereObj.value = (0, language_1.parseValue)(new language_1.Source(finalWhereString));
123
124
  }
124
125
  else {
125
126
  clone.arguments.push({
126
127
  kind: 'Argument',
127
128
  name: { kind: 'Name', value: 'where' },
128
- value: language_1.parseValue(new language_1.Source(finalWhereString))
129
+ value: (0, language_1.parseValue)(new language_1.Source(finalWhereString))
129
130
  });
130
131
  }
131
132
  return clone;
@@ -139,7 +140,7 @@ var Table = /** @class */ (function () {
139
140
  }
140
141
  }
141
142
  });
142
- var queryString = language_1.print(query);
143
+ var queryString = (0, language_1.print)(query);
143
144
  if (required) {
144
145
  queryString = queryString.replace(/\$where: (\w*)Input(,| |\))/, '$where: $1Input!$2');
145
146
  }
@@ -213,7 +214,7 @@ var Table = /** @class */ (function () {
213
214
  subOperationName = operationName.substr(0, 6);
214
215
  action = (['create', 'update', 'delete'].includes(subOperationName) ? subOperationName : 'read');
215
216
  context.action = action;
216
- capitalizedAction = utils_1.capitalize(action);
217
+ capitalizedAction = (0, utils_1.capitalize)(action);
217
218
  context.operationName = operationName;
218
219
  return [4 /*yield*/, this.callHook(this.name, 'beforeValidate', _, args, context, info)];
219
220
  case 2:
@@ -229,13 +230,13 @@ var Table = /** @class */ (function () {
229
230
  case 3:
230
231
  exists = (_b.sent());
231
232
  if (!exists) {
232
- throw new Error(action + " on " + this.schema.name + " not found for " + JSON.stringify(where));
233
+ throw new Error("".concat(action, " on ").concat(this.schema.name, " not found for ").concat(JSON.stringify(where)));
233
234
  }
234
235
  _b.label = 4;
235
236
  case 4:
236
237
  //VALIDATE IF USER CAN MUTATE THOSE FIELDS
237
- this.schema.validateMutation(action, Mutate_1.deepClone(args), user && user.roles || []);
238
- return [4 /*yield*/, this.callHook(this.name, "before" + capitalizedAction, _, args, context, info)];
238
+ this.schema.validateMutation(action, (0, Mutate_1.deepClone)(args), user && user.roles || []);
239
+ return [4 /*yield*/, this.callHook(this.name, "before".concat(capitalizedAction), _, args, context, info)];
239
240
  case 5:
240
241
  _b.sent();
241
242
  return [4 /*yield*/, context.prisma.request(queryString, args)];
@@ -246,7 +247,7 @@ var Table = /** @class */ (function () {
246
247
  }
247
248
  result = Object.values(data.data)[0];
248
249
  context.result = result;
249
- return [4 /*yield*/, this.callHook(this.name, "after" + capitalizedAction, _, args, context, info)];
250
+ return [4 /*yield*/, this.callHook(this.name, "after".concat(capitalizedAction), _, args, context, info)];
250
251
  case 7:
251
252
  _b.sent();
252
253
  this.schema.validateQuery(fields, user && user.roles || []);
@@ -267,7 +268,7 @@ var Table = /** @class */ (function () {
267
268
  //Validate if the roles is able to read those fields
268
269
  if (operationName === this.schema.names.query.single) {
269
270
  queryString = queryString.replace(operationName, this.schema.names.query.plural);
270
- queryString = queryString.replace(new RegExp(this.schema.names.input.where.single + "!?"), this.schema.names.input.where.plural + '!');
271
+ queryString = queryString.replace(new RegExp("".concat(this.schema.names.input.where.single, "!?")), this.schema.names.input.where.plural + '!');
271
272
  }
272
273
  return [4 /*yield*/, context.prisma.request(queryString, args)];
273
274
  case 10:
@@ -342,7 +343,7 @@ var Table = /** @class */ (function () {
342
343
  case 2:
343
344
  if (!(_a < operations_1.length)) return [3 /*break*/, 14];
344
345
  operation = operations_1[_a];
345
- hookName = "" + prefix + utils_1.capitalize(operation);
346
+ hookName = "".concat(prefix).concat((0, utils_1.capitalize)(operation));
346
347
  args2 = args.data[field][operation];
347
348
  if (!Array.isArray(args2)) return [3 /*break*/, 9];
348
349
  _b = 0, args2_1 = args2;
@@ -396,7 +397,7 @@ var Table = /** @class */ (function () {
396
397
  case 19: return [3 /*break*/, 21];
397
398
  case 20:
398
399
  e_1 = _c.sent();
399
- console.error("Error executing hook: \"" + name + "\" in Table: " + schemaName + "\"");
400
+ console.error("Error executing hook: \"".concat(name, "\" in Table: ").concat(schemaName, "\""));
400
401
  console.error(e_1);
401
402
  throw e_1;
402
403
  case 21: return [2 /*return*/];
@@ -29,7 +29,7 @@ function isExcludedByDirective(info, ast) {
29
29
  }
30
30
  // @ts-ignore
31
31
  function dotConcat(a, b) {
32
- return a ? a + "." + b : b;
32
+ return a ? "".concat(a, ".").concat(b) : b;
33
33
  }
34
34
  // @ts-ignore
35
35
  function getFieldSet(info, asts, prefix) {
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createProject = void 0;
3
4
  var exec = require('child_process').execSync;
4
- exports.createProject = function (name) {
5
- console.info("creating project " + name);
6
- exec("git clone git@github.com:cesarve77/mandarina-boilerplate.git " + name);
7
- exec("cd " + name + " && npm i");
5
+ var createProject = function (name) {
6
+ console.info("creating project ".concat(name));
7
+ exec("git clone git@github.com:cesarve77/mandarina-boilerplate.git ".concat(name));
8
+ exec("cd ".concat(name, " && npm i"));
8
9
  console.info("done!");
9
10
  };
11
+ exports.createProject = createProject;
10
12
  //# sourceMappingURL=createProject.js.map
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deploy = void 0;
3
4
  var utils_1 = require("./utils");
4
5
  var exec = require('child_process').execSync;
5
- exports.deploy = function () {
6
- var config = utils_1.getConfig();
6
+ var deploy = function () {
7
+ var config = (0, utils_1.getConfig)();
7
8
  if (!config)
8
9
  return;
9
10
  console.info('deploying');
10
- exec("cd prisma && PRISMA_MANAGEMENT_API_SECRET=" + config.secret + " prisma deploy");
11
+ exec("cd prisma && PRISMA_MANAGEMENT_API_SECRET=".concat(config.secret, " prisma deploy"));
11
12
  console.info('done!');
12
13
  };
14
+ exports.deploy = deploy;
13
15
  //# sourceMappingURL=deploy.js.map
@@ -1,24 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.genFile = void 0;
3
4
  var utils_1 = require("../utils");
4
5
  var mandarina_1 = require("mandarina");
5
6
  var genFilesUtils_1 = require("./genFilesUtils");
6
7
  var CustomAction_1 = require("../../Action/CustomAction");
7
8
  var __1 = require("../..");
8
- exports.genFile = function () {
9
- var config = utils_1.getConfig();
10
- utils_1.loadSchemas(config.dir);
11
- genFilesUtils_1.createDir(config.dir.prisma);
12
- genFilesUtils_1.resetDir(config.dir.prisma);
9
+ var genFile = function () {
10
+ var config = (0, utils_1.getConfig)();
11
+ (0, utils_1.loadSchemas)(config.dir);
12
+ (0, genFilesUtils_1.createDir)(config.dir.prisma);
13
+ (0, genFilesUtils_1.resetDir)(config.dir.prisma);
13
14
  var models = new Set();
14
15
  var processedSubSchemas = [];
15
16
  for (var schemaName in __1.Table.instances) {
16
17
  var schema = mandarina_1.Schema.getInstance(schemaName);
17
18
  var fileName = schema.name.toLowerCase();
18
- var graphql = genFilesUtils_1.getGraphQLModel(schema);
19
- genFilesUtils_1.saveFile(config.dir.prisma, fileName, graphql, 'model');
20
- models.add("datamodel/" + fileName + ".model.graphql");
21
- var subSchemas = genFilesUtils_1.getSubSchemas(schema);
19
+ var graphql = (0, genFilesUtils_1.getGraphQLModel)(schema);
20
+ (0, genFilesUtils_1.saveFile)(config.dir.prisma, fileName, graphql, 'model');
21
+ models.add("datamodel/".concat(fileName, ".model.graphql"));
22
+ var subSchemas = (0, genFilesUtils_1.getSubSchemas)(schema);
22
23
  for (var _i = 0, subSchemas_1 = subSchemas; _i < subSchemas_1.length; _i++) {
23
24
  var subsSchema = subSchemas_1[_i];
24
25
  if (processedSubSchemas.includes(subsSchema)) {
@@ -26,43 +27,44 @@ exports.genFile = function () {
26
27
  }
27
28
  processedSubSchemas.push(schemaName);
28
29
  var schema_1 = mandarina_1.Schema.getInstance(subsSchema);
29
- var graphql_1 = genFilesUtils_1.getGraphQLModel(schema_1);
30
+ var graphql_1 = (0, genFilesUtils_1.getGraphQLModel)(schema_1);
30
31
  var fileName_1 = getFileName(schema_1);
31
- models.add("datamodel/" + fileName_1 + ".model.graphql");
32
- genFilesUtils_1.saveFile(config.dir.prisma, fileName_1, graphql_1, 'model');
32
+ models.add("datamodel/".concat(fileName_1, ".model.graphql"));
33
+ (0, genFilesUtils_1.saveFile)(config.dir.prisma, fileName_1, graphql_1, 'model');
33
34
  }
34
35
  }
35
36
  var database = config.prisma.database || 'default';
36
37
  var stage = config.prisma.stage || 'default';
37
- genFilesUtils_1.savePrismaYaml(models, config.dir.prisma, config.prisma.host + ":" + config.prisma.port + "/" + database + "/" + stage, config.secret);
38
+ (0, genFilesUtils_1.savePrismaYaml)(models, config.dir.prisma, "".concat(config.prisma.host, ":").concat(config.prisma.port, "/").concat(database, "/").concat(stage), config.secret);
38
39
  //saveDockerComposeYaml(config.dir.prisma, config.prisma.port)
39
40
  processedSubSchemas = [];
40
41
  for (var schemaName in CustomAction_1.CustomAction.instances) {
41
42
  var fileName = schemaName.toLowerCase();
42
43
  var action = CustomAction_1.CustomAction.getInstance(schemaName);
43
44
  var schema = mandarina_1.Schema.instances[schemaName];
44
- var operation = genFilesUtils_1.getGraphQLOperation(action, schema);
45
- genFilesUtils_1.saveFile(config.dir.prisma, fileName, operation, 'operation');
45
+ var operation = (0, genFilesUtils_1.getGraphQLOperation)(action, schema);
46
+ (0, genFilesUtils_1.saveFile)(config.dir.prisma, fileName, operation, 'operation');
46
47
  if (!schema)
47
48
  continue;
48
- var graphql = genFilesUtils_1.getGraphQLInput(schema);
49
- genFilesUtils_1.saveFile(config.dir.prisma, fileName, graphql, 'input');
50
- var subSchemas = genFilesUtils_1.getSubSchemas(schema);
49
+ var graphql = (0, genFilesUtils_1.getGraphQLInput)(schema);
50
+ (0, genFilesUtils_1.saveFile)(config.dir.prisma, fileName, graphql, 'input');
51
+ var subSchemas = (0, genFilesUtils_1.getSubSchemas)(schema);
51
52
  for (var _a = 0, subSchemas_2 = subSchemas; _a < subSchemas_2.length; _a++) {
52
53
  var subsSchema = subSchemas_2[_a];
53
54
  if (processedSubSchemas.includes(subsSchema))
54
55
  continue;
55
56
  processedSubSchemas.push(schemaName);
56
57
  var schema_2 = mandarina_1.Schema.getInstance(subsSchema);
57
- var graphql_2 = genFilesUtils_1.getGraphQLInput(schema_2);
58
+ var graphql_2 = (0, genFilesUtils_1.getGraphQLInput)(schema_2);
58
59
  var fileName_2 = getFileName(schema_2);
59
- genFilesUtils_1.saveFile(config.dir.prisma, fileName_2, graphql_2, 'input');
60
+ (0, genFilesUtils_1.saveFile)(config.dir.prisma, fileName_2, graphql_2, 'input');
60
61
  }
61
62
  }
62
63
  if (config.options && config.options.auth) {
63
- var authOperation = genFilesUtils_1.getAuthOperation();
64
- genFilesUtils_1.saveFile(config.dir.prisma, 'mandarinaauth', authOperation, 'operation');
64
+ var authOperation = (0, genFilesUtils_1.getAuthOperation)();
65
+ (0, genFilesUtils_1.saveFile)(config.dir.prisma, 'mandarinaauth', authOperation, 'operation');
65
66
  }
66
67
  };
68
+ exports.genFile = genFile;
67
69
  var getFileName = function (schema) { return schema.name.toLowerCase(); };
68
70
  //# sourceMappingURL=genFiles.js.map
@@ -1,13 +1,15 @@
1
+ import { Schema } from "mandarina";
1
2
  import { CustomAction } from "../../";
2
- export declare const getGraphQLType: (def: any, key: string, required?: "" | "!", isInput?: boolean) => string;
3
- export declare const getGraphQLModel: (schema: any) => string;
4
- export declare const getGraphQLInput: (schema: any) => string;
3
+ import { FieldDefinition } from "mandarina/build/Schema/Schema";
4
+ export declare const getGraphQLType: (def: FieldDefinition, key: string, required?: '' | '!', isInput?: boolean) => string;
5
+ export declare const getGraphQLModel: (schema: Schema) => string;
6
+ export declare const getGraphQLInput: (schema: Schema) => string;
5
7
  export declare const sleep: (ms: number) => Promise<unknown>;
6
8
  export declare const createDir: (dir: string) => void;
7
- export declare const saveFile: (dir: string, fileName: string, content: string, fileType: "input" | "model" | "operation") => void;
9
+ export declare const saveFile: (dir: string, fileName: string, content: string, fileType: 'model' | 'input' | 'operation') => void;
8
10
  export declare const resetDir: (dir: string) => void;
9
- export declare const savePrismaYaml: (datamodel: Set<string>, dir: string, endpoint: string, secret?: string | undefined) => void;
11
+ export declare const savePrismaYaml: (datamodel: Set<string>, dir: string, endpoint: string, secret?: string) => void;
10
12
  export declare const saveDockerComposeYaml: (dir: string, port: string) => void;
11
- export declare const getSubSchemas: (schema: any, processedSchemas?: string[]) => string[];
12
- export declare const getGraphQLOperation: (action: CustomAction, schema: any) => string;
13
+ export declare const getSubSchemas: (schema: Schema, processedSchemas?: string[]) => string[];
14
+ export declare const getGraphQLOperation: (action: CustomAction, schema: Schema) => string;
13
15
  export declare const getAuthOperation: () => string;
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.getAuthOperation = exports.getGraphQLOperation = exports.getSubSchemas = exports.saveDockerComposeYaml = exports.savePrismaYaml = exports.resetDir = exports.saveFile = exports.createDir = exports.sleep = exports.getGraphQLInput = exports.getGraphQLModel = exports.getGraphQLType = void 0;
17
18
  var mandarina_1 = require("mandarina");
18
19
  var utils_1 = require("mandarina/build/Schema/utils");
19
20
  var path_1 = __importDefault(require("path"));
@@ -61,35 +62,36 @@ var lodash_1 = require("lodash");
61
62
  // throw new Error(`Error in field definition ${key}. Fields Table definitions do not accept objects, please use composite tables`)
62
63
  // }
63
64
  // }
64
- exports.getGraphQLType = function (def, key, required, isInput) {
65
+ var getGraphQLType = function (def, key, required, isInput) {
65
66
  if (required === void 0) { required = ''; }
66
67
  if (isInput === void 0) { isInput = false; }
67
68
  //if (isBrowser) throw new Error('_functionCreator is not avaiblabe on browser')
68
69
  var input = isInput ? 'Input' : '';
69
70
  switch (true) {
70
71
  case (!def.isArray && !def.isTable && def.type.name === 'String'):
71
- return "String" + required;
72
+ return "String".concat(required);
72
73
  case (!def.isArray && !def.isTable && def.type.name === 'Boolean'):
73
- return "Boolean" + required;
74
+ return "Boolean".concat(required);
74
75
  case (!def.isArray && !def.isTable && def.type.name === 'Number'):
75
- return "Float" + required;
76
+ return "Float".concat(required);
76
77
  case (!def.isArray && !def.isTable && def.type.name === 'Integer'):
77
- return "Int" + required;
78
+ return "Int".concat(required);
78
79
  case (!def.isArray && !def.isTable && def.type.name === 'Date'):
79
- return "DateTime" + required;
80
+ return "DateTime".concat(required);
80
81
  case (def.isArray && def.isTable):
81
- return "[" + def.type + input + "!]" + required;
82
+ return "[".concat(def.type).concat(input, "!]").concat(required);
82
83
  case (def.isArray && !def.isTable):
83
- var scalarName = exports.getGraphQLType(__assign(__assign({}, def), { isArray: false }), key);
84
- return "[" + scalarName + "!]" + required;
84
+ var scalarName = (0, exports.getGraphQLType)(__assign(__assign({}, def), { isArray: false }), key);
85
+ return "[".concat(scalarName, "!]").concat(required);
85
86
  default:
86
87
  var schemaName = def.type;
87
88
  if (isInput && def.isTable && def.form && def.form.props && def.form.props.query) {
88
- return schemaName + "WhereUnique" + input + required;
89
+ return "".concat(schemaName, "WhereUnique").concat(input).concat(required);
89
90
  }
90
91
  return def.type + input + required;
91
92
  }
92
93
  };
94
+ exports.getGraphQLType = getGraphQLType;
93
95
  // export const buildInterfaceName = (schema: Schema | string): string => schema instanceof Schema ? `${schema.name}Interface` : `${schema}Interface`
94
96
  var getMainSchema = function (schema, type) {
95
97
  var mainSchema = [];
@@ -100,38 +102,38 @@ var getMainSchema = function (schema, type) {
100
102
  continue;
101
103
  }
102
104
  var fieldDefinition = schema.getPathDefinition(key);
103
- var required = utils_1.isRequired(fieldDefinition) ? '!' : '';
105
+ var required = (0, utils_1.isRequired)(fieldDefinition) ? '!' : '';
104
106
  var unique = type === 'type' && fieldDefinition.table.unique ? '@unique' : '';
105
107
  var defaultValue = '';
106
108
  if (type === 'type' && fieldDefinition.table.default !== undefined) {
107
109
  var wrapper = (fieldDefinition.type === String) ? '"' : '';
108
- defaultValue = "@default(value: " + wrapper + fieldDefinition.table.default + wrapper + ")";
110
+ defaultValue = "@default(value: ".concat(wrapper).concat(fieldDefinition.table.default).concat(wrapper, ")");
109
111
  }
110
- var rename = (type === 'type' && fieldDefinition.table.rename !== undefined) ? "@rename(oldName: \"" + fieldDefinition.table.default + "\")" : '';
112
+ var rename = (type === 'type' && fieldDefinition.table.rename !== undefined) ? "@rename(oldName: \"".concat(fieldDefinition.table.default, "\")") : '';
111
113
  var relations = [];
112
114
  var relation = '';
113
115
  if (type === 'type' && fieldDefinition.table.relation !== undefined) {
114
116
  if (typeof fieldDefinition.table.relation === "string") {
115
- relations.push("name: \"" + fieldDefinition.table.relation + "\"");
117
+ relations.push("name: \"".concat(fieldDefinition.table.relation, "\""));
116
118
  }
117
119
  else {
118
120
  if (fieldDefinition.table.relation.link) {
119
- relations.push("link: " + fieldDefinition.table.relation.link);
121
+ relations.push("link: ".concat(fieldDefinition.table.relation.link));
120
122
  }
121
123
  if (fieldDefinition.table.relation.name) {
122
- relations.push("name: \"" + fieldDefinition.table.relation.name + "\"");
124
+ relations.push("name: \"".concat(fieldDefinition.table.relation.name, "\""));
123
125
  }
124
126
  if (fieldDefinition.table.relation.onDelete) {
125
- relations.push("onDelete: " + fieldDefinition.table.relation.onDelete);
127
+ relations.push("onDelete: ".concat(fieldDefinition.table.relation.onDelete));
126
128
  }
127
129
  }
128
130
  if (relations.length > 0) {
129
- relation = "@relation(" + relations.join(', ') + ")";
131
+ relation = "@relation(".concat(relations.join(', '), ")");
130
132
  }
131
133
  }
132
134
  var scalarList = '', createdAt = '', updatedAt = '';
133
135
  if (type === 'type' && fieldDefinition.table.scalarList) {
134
- scalarList = "@scalarList(strategy: " + fieldDefinition.table.scalarList.strategy + ")";
136
+ scalarList = "@scalarList(strategy: ".concat(fieldDefinition.table.scalarList.strategy, ")");
135
137
  }
136
138
  if (type === 'type' && (fieldDefinition.table.createdAt === true || (fieldDefinition.table.createdAt !== false && key === 'createdAt'))) {
137
139
  createdAt = "@createdAt";
@@ -142,9 +144,9 @@ var getMainSchema = function (schema, type) {
142
144
  if (!scalarList && type === 'type' && fieldDefinition.isArray && !fieldDefinition.isTable) {
143
145
  scalarList = "@scalarList(strategy: RELATION)";
144
146
  }
145
- var fieldType = exports.getGraphQLType(fieldDefinition, key, required, type === 'input');
146
- fieldDefinition.description && mainSchema.push("# " + fieldDefinition.description);
147
- mainSchema.push(key + ": " + fieldType + " " + unique + " " + createdAt + " " + updatedAt + " " + defaultValue + " " + relation + " " + scalarList + " " + rename);
147
+ var fieldType = (0, exports.getGraphQLType)(fieldDefinition, key, required, type === 'input');
148
+ fieldDefinition.description && mainSchema.push("# ".concat(fieldDefinition.description));
149
+ mainSchema.push("".concat(key, ": ").concat(fieldType, " ").concat(unique, " ").concat(createdAt, " ").concat(updatedAt, " ").concat(defaultValue, " ").concat(relation, " ").concat(scalarList, " ").concat(rename));
148
150
  }
149
151
  return mainSchema;
150
152
  };
@@ -152,38 +154,44 @@ var getGraphQL = function (type, schema) {
152
154
  var name = schema.name;
153
155
  //if (isBrowser) throw new Error('getGraphQLSchema is not available on browser')
154
156
  var mainSchema = getMainSchema(schema, type), graphQLSchema = '';
155
- var description = utils_1.capitalize(type) + " for " + name;
157
+ var description = "".concat((0, utils_1.capitalize)(type), " for ").concat(name);
156
158
  if (mainSchema.length) {
157
- graphQLSchema += "# " + description + "\n";
158
- graphQLSchema += type + " " + name + (type === 'input' ? 'Input' : '') + " {\n";
159
- graphQLSchema += "\t" + mainSchema.join('\n\t') + "\n";
159
+ graphQLSchema += "# ".concat(description, "\n");
160
+ graphQLSchema += "".concat(type, " ").concat(name).concat(type === 'input' ? 'Input' : '', " {\n");
161
+ graphQLSchema += "\t".concat(mainSchema.join('\n\t'), "\n");
160
162
  graphQLSchema += "}";
161
163
  }
162
164
  return graphQLSchema;
163
165
  };
164
- exports.getGraphQLModel = function (schema) { return getGraphQL('type', schema); };
165
- exports.getGraphQLInput = function (schema) { return getGraphQL('input', schema); };
166
- exports.sleep = function (ms) {
166
+ var getGraphQLModel = function (schema) { return getGraphQL('type', schema); };
167
+ exports.getGraphQLModel = getGraphQLModel;
168
+ var getGraphQLInput = function (schema) { return getGraphQL('input', schema); };
169
+ exports.getGraphQLInput = getGraphQLInput;
170
+ var sleep = function (ms) {
167
171
  return new Promise(function (resolve) { return setTimeout(resolve, ms); });
168
172
  };
169
- exports.createDir = function (dir) {
173
+ exports.sleep = sleep;
174
+ var createDir = function (dir) {
170
175
  var prismaDir = path_1.default.join(process.cwd(), dir);
171
- if (!fs_1.default.existsSync(prismaDir + "/datamodel")) {
172
- fs_1.default.mkdirSync(prismaDir + "/datamodel");
176
+ if (!fs_1.default.existsSync("".concat(prismaDir, "/datamodel"))) {
177
+ fs_1.default.mkdirSync("".concat(prismaDir, "/datamodel"));
173
178
  }
174
179
  };
175
- exports.saveFile = function (dir, fileName, content, fileType) {
180
+ exports.createDir = createDir;
181
+ var saveFile = function (dir, fileName, content, fileType) {
176
182
  var prismaDir = path_1.default.join(process.cwd(), dir);
177
- var fileAbs = prismaDir + "/datamodel/" + fileName + "." + fileType + ".graphql";
183
+ var fileAbs = "".concat(prismaDir, "/datamodel/").concat(fileName, ".").concat(fileType, ".graphql");
178
184
  fs_1.default.writeFileSync(fileAbs, content);
179
- console.info("saving " + fileType + ": " + fileName);
185
+ console.info("saving ".concat(fileType, ": ").concat(fileName));
180
186
  };
181
- exports.resetDir = function (dir) {
187
+ exports.saveFile = saveFile;
188
+ var resetDir = function (dir) {
182
189
  var prismaDir = path_1.default.join(process.cwd(), dir);
183
190
  var datamodelDir = path_1.default.join(prismaDir, 'datamodel');
184
191
  fs_1.default.readdirSync(datamodelDir).forEach(function (file) { return fs_1.default.unlinkSync(path_1.default.join(datamodelDir, file)); });
185
192
  };
186
- exports.savePrismaYaml = function (datamodel, dir, endpoint, secret) {
193
+ exports.resetDir = resetDir;
194
+ var savePrismaYaml = function (datamodel, dir, endpoint, secret) {
187
195
  var prismaDir = path_1.default.join(process.cwd(), dir);
188
196
  var prismaYaml = path_1.default.join(prismaDir, "prisma.yml");
189
197
  var data = { endpoint: endpoint, datamodel: datamodel, };
@@ -191,15 +199,16 @@ exports.savePrismaYaml = function (datamodel, dir, endpoint, secret) {
191
199
  data.secret = secret;
192
200
  saveYaml(prismaYaml, data);
193
201
  };
194
- exports.saveDockerComposeYaml = function (dir, port) {
202
+ exports.savePrismaYaml = savePrismaYaml;
203
+ var saveDockerComposeYaml = function (dir, port) {
195
204
  var prismaDir = path_1.default.join(process.cwd(), dir);
196
205
  var dcYaml = path_1.default.join(prismaDir, "docker-compose.yml");
197
206
  if (!fs_1.default.existsSync(dcYaml))
198
- return console.warn("\"" + dcYaml + "\" file does not exists");
207
+ return console.warn("\"".concat(dcYaml, "\" file does not exists"));
199
208
  saveYaml(dcYaml, {
200
209
  services: {
201
210
  prisma: {
202
- ports: [port + ":" + port],
211
+ ports: ["".concat(port, ":").concat(port)],
203
212
  environment: {
204
213
  PRISMA_CONFIG: {
205
214
  port: port,
@@ -209,6 +218,7 @@ exports.saveDockerComposeYaml = function (dir, port) {
209
218
  }
210
219
  });
211
220
  };
221
+ exports.saveDockerComposeYaml = saveDockerComposeYaml;
212
222
  var saveYaml = function (file, data) {
213
223
  var yaml = require("yaml");
214
224
  var contentFile = fs_1.default.readFileSync(file, { encoding: 'utf8' }).replace(/([\t ]*)PRISMA_CONFIG *: *(\||>)?\n/, '$1PRISMA_CONFIG:\n');
@@ -217,12 +227,12 @@ var saveYaml = function (file, data) {
217
227
  var newData = data;
218
228
  if (data.datamodel) {
219
229
  data.datamodel = Array.from(data.datamodel);
220
- newData = lodash_1.merge(originalData, data);
230
+ newData = (0, lodash_1.merge)(originalData, data);
221
231
  }
222
232
  var str = yaml.stringify(newData).replace(/([\t ]*)PRISMA_CONFIG *: *\n/, '$1PRISMA_CONFIG: |\n');
223
233
  fs_1.default.writeFileSync(file, str);
224
234
  };
225
- exports.getSubSchemas = function (schema, processedSchemas) {
235
+ var getSubSchemas = function (schema, processedSchemas) {
226
236
  if (processedSchemas === void 0) { processedSchemas = []; }
227
237
  var subSchemas = [];
228
238
  if (processedSchemas.includes(schema.name))
@@ -235,29 +245,32 @@ exports.getSubSchemas = function (schema, processedSchemas) {
235
245
  if (!(fieldDefinition.form && fieldDefinition.form.props && fieldDefinition.form.props.query)) {
236
246
  var schemaName = fieldDefinition.type;
237
247
  subSchemas.push(schemaName);
238
- subSchemas.push.apply(subSchemas, exports.getSubSchemas(mandarina_1.Schema.getInstance(schemaName), processedSchemas));
248
+ subSchemas.push.apply(subSchemas, (0, exports.getSubSchemas)(mandarina_1.Schema.getInstance(schemaName), processedSchemas));
239
249
  }
240
250
  });
241
251
  return subSchemas;
242
252
  };
243
- exports.getGraphQLOperation = function (action, schema) {
253
+ exports.getSubSchemas = getSubSchemas;
254
+ var getGraphQLOperation = function (action, schema) {
244
255
  var response = '', input = '';
245
256
  var actions = action.actions;
246
257
  if (action.schema) {
247
258
  var actionName = action.schema.name;
248
- input = schema ? "(data: " + utils_1.capitalize(actionName) + "Input!)" : '';
259
+ input = schema ? "(data: ".concat((0, utils_1.capitalize)(actionName), "Input!)") : '';
249
260
  }
250
261
  if (actions) {
251
262
  Object.keys(actions).forEach(function (actionName) {
252
263
  var action = actions[actionName];
253
- response += "extend type Mutation {\n\t" + actionName + " " + input + ": " + action.result + "\n}";
264
+ response += "extend type Mutation {\n\t".concat(actionName, " ").concat(input, ": ").concat(action.result, "\n}");
254
265
  });
255
266
  }
256
267
  return response;
257
268
  };
258
- exports.getAuthOperation = function () {
269
+ exports.getGraphQLOperation = getGraphQLOperation;
270
+ var getAuthOperation = function () {
259
271
  return "extend type Query {\n\tAuthFields(action: String!, table: String!) : [String!]\n}";
260
272
  };
273
+ exports.getAuthOperation = getAuthOperation;
261
274
  /*
262
275
 
263
276
  export const getDeclarations = (schema: Schema): string => {
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.genFile = void 0;
17
18
  var utils_1 = require("../utils");
18
19
  var genFilesUtils_1 = require("./genFilesUtils");
19
20
  var __1 = require("../..");
@@ -24,10 +25,10 @@ var fs_1 = __importDefault(require("fs"));
24
25
  var prisma2Models = {};
25
26
  var processed = {};
26
27
  var processedSubSchemas = [];
27
- exports.genFile = function () {
28
- var config = utils_1.getConfig();
29
- utils_1.loadSchemas(config.dir);
30
- genFilesUtils_1.createDir(config.dir.prisma2);
28
+ var genFile = function () {
29
+ var config = (0, utils_1.getConfig)();
30
+ (0, utils_1.loadSchemas)(config.dir);
31
+ (0, genFilesUtils_1.createDir)(config.dir.prisma2);
31
32
  for (var schemaName in __1.Table.instances) {
32
33
  var schema = mandarina_1.Schema.getInstance(schemaName);
33
34
  getPrisma2Model(schema);
@@ -35,25 +36,26 @@ exports.genFile = function () {
35
36
  var prisma = "generator client {\n provider = \"prisma-client-js\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n";
36
37
  Object.keys(prisma2Models).forEach(function (modelName) {
37
38
  var model = prisma2Models[modelName];
38
- prisma += "model " + modelName + " {\n ";
39
+ prisma += "model ".concat(modelName, " {\n ");
39
40
  Object.keys(model).forEach(function (fieldName) {
40
41
  var field = model[fieldName];
41
- prisma += "\t" + fieldName + " " + field + "\n";
42
+ prisma += "\t".concat(fieldName, " ").concat(field, "\n");
42
43
  });
43
44
  var schema = mandarina_1.Schema.getInstance(modelName);
44
45
  schema.indexes.forEach(function (_a) {
45
46
  var fields = _a.fields, type = _a.type;
46
- prisma += "\t@@" + type.toLowerCase() + "([" + fields.map(function (_a) {
47
+ prisma += "\t@@".concat(type.toLowerCase(), "([").concat(fields.map(function (_a) {
47
48
  var name = _a.name, options = _a.options;
48
- return "" + name + (options ? "(" + options + ")" : "");
49
- }).join(',') + "])\n";
49
+ return "".concat(name).concat(options ? "(".concat(options, ")") : "");
50
+ }).join(','), "])\n");
50
51
  });
51
52
  prisma += "}\n\n";
52
53
  });
53
54
  var prismaDir = path_1.default.join(process.cwd(), config.dir.prisma2);
54
- var fileAbs = prismaDir + "/schema.prisma";
55
+ var fileAbs = "".concat(prismaDir, "/schema.prisma");
55
56
  fs_1.default.writeFileSync(fileAbs, prisma);
56
57
  };
58
+ exports.genFile = genFile;
57
59
  var getPrisma2Model = function (schema) {
58
60
  prisma2Models[schema.name] = prisma2Models[schema.name] || {};
59
61
  for (var _i = 0, _a = schema.keys; _i < _a.length; _i++) {
@@ -64,14 +66,14 @@ var getPrisma2Model = function (schema) {
64
66
  }
65
67
  else {
66
68
  var fieldDefinition = schema.getPathDefinition(key);
67
- var required = fieldDefinition.isArray || utils_2.isRequired(fieldDefinition);
69
+ var required = fieldDefinition.isArray || (0, utils_2.isRequired)(fieldDefinition);
68
70
  var fieldType = getGraphQLType(fieldDefinition, key, required);
69
71
  var unique = fieldDefinition.table.unique ? '@unique' : '';
70
72
  var createdAt = '', updatedAt = '';
71
73
  var defaultValue = '';
72
74
  if (fieldDefinition.table.default !== undefined) {
73
75
  var wrapper = (fieldDefinition.type === String) ? '"' : '';
74
- defaultValue = "@default(" + wrapper + fieldDefinition.table.default + wrapper + ")";
76
+ defaultValue = "@default(".concat(wrapper).concat(fieldDefinition.table.default).concat(wrapper, ")");
75
77
  }
76
78
  if ((fieldDefinition.table.createdAt === true || (fieldDefinition.table.createdAt !== false && key === 'createdAt'))) {
77
79
  createdAt = "@default(now())";
@@ -81,7 +83,7 @@ var getPrisma2Model = function (schema) {
81
83
  }
82
84
  if (fieldDefinition.table.default !== undefined) {
83
85
  var wrapper = (fieldDefinition.type === String) ? '"' : '';
84
- defaultValue = "@default(" + wrapper + fieldDefinition.table.default + wrapper + ")";
86
+ defaultValue = "@default(".concat(wrapper).concat(fieldDefinition.table.default).concat(wrapper, ")");
85
87
  }
86
88
  if (fieldDefinition.isTable) {
87
89
  getPrismaModelAModelB(schema, fieldDefinition);
@@ -91,7 +93,7 @@ var getPrisma2Model = function (schema) {
91
93
  }
92
94
  }
93
95
  else {
94
- prisma2Models[schema.name][key] = fieldType + " " + unique + " " + createdAt + " " + updatedAt + " " + defaultValue;
96
+ prisma2Models[schema.name][key] = "".concat(fieldType, " ").concat(unique, " ").concat(createdAt, " ").concat(updatedAt, " ").concat(defaultValue);
95
97
  }
96
98
  }
97
99
  } // end for
@@ -123,11 +125,11 @@ var getPrismaModelAModelB = function (schema, fieldDefinition) {
123
125
  if (getRelation(fieldDefinition) !== getRelation(child)) {
124
126
  throw new Error("Relation must be the same");
125
127
  }
126
- var relation = getRelationName(fieldDefinition, child) || schema.name + "To" + schema.name;
127
- var fields = "p2" + fieldDefinition.key + "Id";
128
- prisma2Models[schema.name][fieldDefinition.key] = schema.name + "? " + buildRelation(relation, fields) + " //SELF: 1 - 1 ((" + c + "))";
129
- prisma2Models[schema.name][fields] = "String? @unique //SELF: 1 - 1 ((" + c + "))";
130
- prisma2Models[schema.name]["p2Predecessor" + schema.name] = schema.name + "? " + buildRelation(relation) + "//SELF: 1 - 1 ((" + c + "))";
128
+ var relation = getRelationName(fieldDefinition, child) || "".concat(schema.name, "To").concat(schema.name);
129
+ var fields = "p2".concat(fieldDefinition.key, "Id");
130
+ prisma2Models[schema.name][fieldDefinition.key] = "".concat(schema.name, "? ").concat(buildRelation(relation, fields), " //SELF: 1 - 1 ((").concat(c, "))");
131
+ prisma2Models[schema.name][fields] = "String? @unique //SELF: 1 - 1 ((".concat(c, "))");
132
+ prisma2Models[schema.name]["p2Predecessor".concat(schema.name)] = "".concat(schema.name, "? ").concat(buildRelation(relation), "//SELF: 1 - 1 ((").concat(c, "))");
131
133
  }
132
134
  }
133
135
  }
@@ -136,39 +138,39 @@ var getPrismaModelAModelB = function (schema, fieldDefinition) {
136
138
  var relation = getRelationName(fieldDefinition);
137
139
  if (fieldDefinition.isArray) {
138
140
  if (!((_b = (_a = fieldDefinition.table) === null || _a === void 0 ? void 0 : _a.relation) === null || _b === void 0 ? void 0 : _b.type) || !['MANY_TO_MANY', 'ONE_TO_MANY'].includes((_d = (_c = fieldDefinition.table) === null || _c === void 0 ? void 0 : _c.relation) === null || _d === void 0 ? void 0 : _d.type)) {
139
- throw new Error("Relation must be defined MANY_TO_MANY || ONE_TO_MANY- " + schema.name + "." + fieldDefinition.key);
141
+ throw new Error("Relation must be defined MANY_TO_MANY || ONE_TO_MANY- ".concat(schema.name, ".").concat(fieldDefinition.key));
140
142
  }
141
143
  if (((_f = (_e = fieldDefinition.table) === null || _e === void 0 ? void 0 : _e.relation) === null || _f === void 0 ? void 0 : _f.type) === 'ONE_TO_MANY') {
142
144
  //relation many to one
143
- prisma2Models[schema.name][fieldDefinition.key] = fieldDefinition.type + "[] " + buildRelation(relation) + "//CREATE: n - 1 ((" + c + "))";
144
- var fields = "p2" + relation + schema.name + "Id";
145
- prisma2Models[fieldDefinition.type]["p2" + relation + schema.name] = schema.name + "? " + buildRelation(relation, fields) + " //=>CREATE: n - 1 ((" + c + "))";
146
- prisma2Models[fieldDefinition.type][fields] = "String? //=>CREATE:n - n no children ((" + c + "))";
145
+ prisma2Models[schema.name][fieldDefinition.key] = "".concat(fieldDefinition.type, "[] ").concat(buildRelation(relation), "//CREATE: n - 1 ((").concat(c, "))");
146
+ var fields = "p2".concat(relation).concat(schema.name, "Id");
147
+ prisma2Models[fieldDefinition.type]["p2".concat(relation).concat(schema.name)] = "".concat(schema.name, "? ").concat(buildRelation(relation, fields), " //=>CREATE: n - 1 ((").concat(c, "))");
148
+ prisma2Models[fieldDefinition.type][fields] = "String? //=>CREATE:n - n no children ((".concat(c, "))");
147
149
  }
148
150
  else if (((_h = (_g = fieldDefinition.table) === null || _g === void 0 ? void 0 : _g.relation) === null || _h === void 0 ? void 0 : _h.type) === 'MANY_TO_MANY') {
149
151
  //relation many to many
150
- prisma2Models[schema.name][fieldDefinition.key] = fieldDefinition.type + "[] " + buildRelation(relation) + "//CREATE: n - 1 ((" + c + "))";
151
- prisma2Models[fieldDefinition.type]["p2" + relation + schema.name] = schema.name + "[] //=>CREATE: n - n no children((" + c + "))";
152
+ prisma2Models[schema.name][fieldDefinition.key] = "".concat(fieldDefinition.type, "[] ").concat(buildRelation(relation), "//CREATE: n - 1 ((").concat(c, "))");
153
+ prisma2Models[fieldDefinition.type]["p2".concat(relation).concat(schema.name)] = "".concat(schema.name, "[] //=>CREATE: n - n no children((").concat(c, "))");
152
154
  }
153
155
  }
154
156
  else {
155
157
  if (!((_k = (_j = fieldDefinition.table) === null || _j === void 0 ? void 0 : _j.relation) === null || _k === void 0 ? void 0 : _k.type)) {
156
- throw new Error("Relation must be defined ONE_TO_ONE || ONE_TO_MANY- " + schema.name + "." + fieldDefinition.key);
158
+ throw new Error("Relation must be defined ONE_TO_ONE || ONE_TO_MANY- ".concat(schema.name, ".").concat(fieldDefinition.key));
157
159
  }
158
160
  if (((_m = (_l = fieldDefinition.table) === null || _l === void 0 ? void 0 : _l.relation) === null || _m === void 0 ? void 0 : _m.type) === 'ONE_TO_ONE') {
159
- var fields = "p2" + relation + schema.name + "Id";
160
- prisma2Models[schema.name][fieldDefinition.key] = fieldDefinition.type + "? " + buildRelation(relation) + "//INLINE : 1 - 1 ((" + c + "))";
161
- prisma2Models[fieldDefinition.type]["p2" + relation + schema.name] = schema.name + "? " + buildRelation(relation, fields) + " //=>INLINE: 1 - 1 ((" + c + "))";
162
- prisma2Models[fieldDefinition.type][fields] = "String? @unique //=>INLINE: 1 - 1 ((" + c + "))";
161
+ var fields = "p2".concat(relation).concat(schema.name, "Id");
162
+ prisma2Models[schema.name][fieldDefinition.key] = "".concat(fieldDefinition.type, "? ").concat(buildRelation(relation), "//INLINE : 1 - 1 ((").concat(c, "))");
163
+ prisma2Models[fieldDefinition.type]["p2".concat(relation).concat(schema.name)] = "".concat(schema.name, "? ").concat(buildRelation(relation, fields), " //=>INLINE: 1 - 1 ((").concat(c, "))");
164
+ prisma2Models[fieldDefinition.type][fields] = "String? @unique //=>INLINE: 1 - 1 ((".concat(c, "))");
163
165
  }
164
166
  else if (((_p = (_o = fieldDefinition.table) === null || _o === void 0 ? void 0 : _o.relation) === null || _p === void 0 ? void 0 : _p.type) === 'ONE_TO_MANY') {
165
- var fields = "p2" + relation + fieldDefinition.type + "Id";
166
- prisma2Models[schema.name][fieldDefinition.key] = fieldDefinition.type + "? " + buildRelation(relation, fields) + "//CREATE: 1 - n ((" + c + "))";
167
- prisma2Models[schema.name][fields] = "String? //=>CREATE: 1 - n ((" + c + "))";
168
- prisma2Models[fieldDefinition.type]["p2" + relation + schema.name] = schema.name + "[] " + buildRelation(relation) + " //=>CREATE: 1 - n ((" + c + "))";
167
+ var fields = "p2".concat(relation).concat(fieldDefinition.type, "Id");
168
+ prisma2Models[schema.name][fieldDefinition.key] = "".concat(fieldDefinition.type, "? ").concat(buildRelation(relation, fields), "//CREATE: 1 - n ((").concat(c, "))");
169
+ prisma2Models[schema.name][fields] = "String? //=>CREATE: 1 - n ((".concat(c, "))");
170
+ prisma2Models[fieldDefinition.type]["p2".concat(relation).concat(schema.name)] = "".concat(schema.name, "[] ").concat(buildRelation(relation), " //=>CREATE: 1 - n ((").concat(c, "))");
169
171
  }
170
172
  else {
171
- throw new Error("many to one does no exists for create - " + schema.name + "." + fieldDefinition.key);
173
+ throw new Error("many to one does no exists for create - ".concat(schema.name, ".").concat(fieldDefinition.key));
172
174
  }
173
175
  }
174
176
  }
@@ -191,45 +193,45 @@ var getPrismaModelAModelB = function (schema, fieldDefinition) {
191
193
  var relation = getRelationName(fieldDefinition, child);
192
194
  if (fieldDefinition.isArray) {
193
195
  //relation many to many
194
- prisma2Models[schema.name][fieldDefinition.key] = fieldDefinition.type + "[] " + buildRelation(relation) + " //n - n ((" + c + "))";
195
- prisma2Models[fieldDefinition.type][child.key] = child.type + "[] " + buildRelation(relation) + " //=>n - n ((" + c + "))";
196
+ prisma2Models[schema.name][fieldDefinition.key] = "".concat(fieldDefinition.type, "[] ").concat(buildRelation(relation), " //n - n ((").concat(c, "))");
197
+ prisma2Models[fieldDefinition.type][child.key] = "".concat(child.type, "[] ").concat(buildRelation(relation), " //=>n - n ((").concat(c, "))");
196
198
  }
197
199
  else {
198
200
  //relation one to many
199
201
  var relation_1 = getRelationName(fieldDefinition, child);
200
- var fields = "p2" + relation_1 + fieldDefinition.type + "Id";
201
- prisma2Models[schema.name][fieldDefinition.key] = fieldDefinition.type + "? " + buildRelation(relation_1, fields) + " //n - 1 ((" + c + "))";
202
- prisma2Models[schema.name][fields] = "String? //n - 1 ((" + c + "))";
203
- prisma2Models[fieldDefinition.type][child.key] = schema.name + " [] " + buildRelation(relation_1) + "//=>n - 1 ((" + c + "))";
202
+ var fields = "p2".concat(relation_1).concat(fieldDefinition.type, "Id");
203
+ prisma2Models[schema.name][fieldDefinition.key] = "".concat(fieldDefinition.type, "? ").concat(buildRelation(relation_1, fields), " //n - 1 ((").concat(c, "))");
204
+ prisma2Models[schema.name][fields] = "String? //n - 1 ((".concat(c, "))");
205
+ prisma2Models[fieldDefinition.type][child.key] = "".concat(schema.name, " [] ").concat(buildRelation(relation_1), "//=>n - 1 ((").concat(c, "))");
204
206
  }
205
207
  }
206
208
  else {
207
209
  var relation = getRelationName(fieldDefinition, child);
208
210
  if (fieldDefinition.isArray) {
209
211
  //relation many to many
210
- var fields = "p2" + relation + schema.name + "Id";
211
- prisma2Models[schema.name][fieldDefinition.key] = fieldDefinition.type + "[] " + buildRelation(relation) + "//1 - n ((" + c + "))";
212
- prisma2Models[fieldDefinition.type][child.key] = schema.name + "? " + buildRelation(relation, fields) + " //=>n - 1 ((" + c + "))";
213
- prisma2Models[fieldDefinition.type][fields] = "String? //=>n - 1 ((" + c + "))";
212
+ var fields = "p2".concat(relation).concat(schema.name, "Id");
213
+ prisma2Models[schema.name][fieldDefinition.key] = "".concat(fieldDefinition.type, "[] ").concat(buildRelation(relation), "//1 - n ((").concat(c, "))");
214
+ prisma2Models[fieldDefinition.type][child.key] = "".concat(schema.name, "? ").concat(buildRelation(relation, fields), " //=>n - 1 ((").concat(c, "))");
215
+ prisma2Models[fieldDefinition.type][fields] = "String? //=>n - 1 ((".concat(c, "))");
214
216
  }
215
217
  else {
216
218
  if (!((_r = (_q = fieldDefinition.table) === null || _q === void 0 ? void 0 : _q.relation) === null || _r === void 0 ? void 0 : _r.owner) && !((_t = (_s = child.table) === null || _s === void 0 ? void 0 : _s.relation) === null || _t === void 0 ? void 0 : _t.owner)) {
217
- throw new Error("Relation must be defined a owner - " + schema.name + "." + fieldDefinition.key);
219
+ throw new Error("Relation must be defined a owner - ".concat(schema.name, ".").concat(fieldDefinition.key));
218
220
  }
219
221
  if (((_v = (_u = fieldDefinition.table) === null || _u === void 0 ? void 0 : _u.relation) === null || _v === void 0 ? void 0 : _v.owner) && ((_x = (_w = child.table) === null || _w === void 0 ? void 0 : _w.relation) === null || _x === void 0 ? void 0 : _x.owner)) {
220
- throw new Error("Relation booth can not be a owner - " + schema.name + "." + fieldDefinition.key);
222
+ throw new Error("Relation booth can not be a owner - ".concat(schema.name, ".").concat(fieldDefinition.key));
221
223
  }
222
224
  if ((_z = (_y = fieldDefinition.table) === null || _y === void 0 ? void 0 : _y.relation) === null || _z === void 0 ? void 0 : _z.owner) {
223
- var fields = "p2" + relation + schema.name + "Id";
224
- prisma2Models[schema.name][fieldDefinition.key] = fieldDefinition.type + "? " + buildRelation(relation) + "//OWNER 1 - 1 ((" + c + "))";
225
- prisma2Models[fieldDefinition.type][child.key] = schema.name + "? " + buildRelation(relation, fields) + " //OWNER =>1 - 1 ((" + c + "))";
226
- prisma2Models[fieldDefinition.type][fields] = "String? @unique //OWNER =>1 - 1 ((" + c + "))";
225
+ var fields = "p2".concat(relation).concat(schema.name, "Id");
226
+ prisma2Models[schema.name][fieldDefinition.key] = "".concat(fieldDefinition.type, "? ").concat(buildRelation(relation), "//OWNER 1 - 1 ((").concat(c, "))");
227
+ prisma2Models[fieldDefinition.type][child.key] = "".concat(schema.name, "? ").concat(buildRelation(relation, fields), " //OWNER =>1 - 1 ((").concat(c, "))");
228
+ prisma2Models[fieldDefinition.type][fields] = "String? @unique //OWNER =>1 - 1 ((".concat(c, "))");
227
229
  }
228
230
  else {
229
- var fields = "p2" + relation + fieldDefinition.type + "Id";
230
- prisma2Models[schema.name][fieldDefinition.key] = fieldDefinition.type + "? " + buildRelation(relation, fields) + "//OWNED 1 - 1 ((" + c + "))";
231
- prisma2Models[schema.name][fields] = "String? @unique //OWNED =>1 - 1 ((" + c + "))";
232
- prisma2Models[fieldDefinition.type][child.key] = child.type + "? " + buildRelation(relation) + " //OWNED =>1 - 1 ((" + c + "))";
231
+ var fields = "p2".concat(relation).concat(fieldDefinition.type, "Id");
232
+ prisma2Models[schema.name][fieldDefinition.key] = "".concat(fieldDefinition.type, "? ").concat(buildRelation(relation, fields), "//OWNED 1 - 1 ((").concat(c, "))");
233
+ prisma2Models[schema.name][fields] = "String? @unique //OWNED =>1 - 1 ((".concat(c, "))");
234
+ prisma2Models[fieldDefinition.type][child.key] = "".concat(child.type, "? ").concat(buildRelation(relation), " //OWNED =>1 - 1 ((").concat(c, "))");
233
235
  }
234
236
  }
235
237
  }
@@ -255,20 +257,20 @@ var getGraphQLType = function (def, key, required) {
255
257
  var optional = !def.isArray && !required ? '?' : '';
256
258
  switch (true) {
257
259
  case (!def.isArray && !def.isTable && def.type.name === 'String'):
258
- return "String" + optional;
260
+ return "String".concat(optional);
259
261
  case (!def.isArray && !def.isTable && def.type.name === 'Boolean'):
260
- return "Boolean" + optional;
262
+ return "Boolean".concat(optional);
261
263
  case (!def.isArray && !def.isTable && def.type.name === 'Number'):
262
- return "Float" + optional;
264
+ return "Float".concat(optional);
263
265
  case (!def.isArray && !def.isTable && def.type.name === 'Integer'):
264
- return "Int" + optional;
266
+ return "Int".concat(optional);
265
267
  case (!def.isArray && !def.isTable && def.type.name === 'Date'):
266
- return "DateTime" + optional;
268
+ return "DateTime".concat(optional);
267
269
  case (def.isArray && def.isTable):
268
- return def.type + "[]";
270
+ return "".concat(def.type, "[]");
269
271
  case (def.isArray && !def.isTable):
270
272
  var scalarName = getGraphQLType(__assign(__assign({}, def), { isArray: false }), key, def.isArray && required);
271
- return scalarName + "[]";
273
+ return "".concat(scalarName, "[]");
272
274
  default:
273
275
  return def.type + optional;
274
276
  }
@@ -277,11 +279,11 @@ function buildRelation(relation, fields) {
277
279
  if (!relation && !fields)
278
280
  return '';
279
281
  if (!relation)
280
- return "@relation(fields: [" + fields + "], references: [id])";
282
+ return "@relation(fields: [".concat(fields, "], references: [id])");
281
283
  if (fields) {
282
- return "@relation(\"" + relation + "\", fields: [" + fields + "], references: [id])";
284
+ return "@relation(\"".concat(relation, "\", fields: [").concat(fields, "], references: [id])");
283
285
  }
284
- return "@relation(\"" + relation + "\")";
286
+ return "@relation(\"".concat(relation, "\")");
285
287
  }
286
288
  var getRelationName = function (def1, def2) {
287
289
  var n1 = getRelation(def1);
@@ -293,7 +295,7 @@ var getRelationName = function (def1, def2) {
293
295
  }
294
296
  var n2 = getRelation(def2);
295
297
  if (n1 !== n2) {
296
- throw new Error("Relation name must be equal " + n1 + " " + n2);
298
+ throw new Error("Relation name must be equal ".concat(n1, " ").concat(n2));
297
299
  }
298
300
  if (!n1)
299
301
  return "";
@@ -11,25 +11,25 @@ var _a = process.argv, nodeDir = _a[0], dir = _a[1], cmd = _a[2], args = _a.slic
11
11
  switch (cmd) {
12
12
  case "create":
13
13
  var project = args && args[0] || 'mandarina';
14
- createProject_1.createProject(project);
14
+ (0, createProject_1.createProject)(project);
15
15
  break;
16
16
  case 'gen-files':
17
- genFiles_1.genFile();
17
+ (0, genFiles_1.genFile)();
18
18
  break;
19
19
  case 'gen-prisma2':
20
- prisma2_1.genFile();
20
+ (0, prisma2_1.genFile)();
21
21
  break;
22
22
  case 'deploy':
23
- deploy_1.deploy();
23
+ (0, deploy_1.deploy)();
24
24
  break;
25
25
  case 'watch':
26
- watch_1.watch();
26
+ (0, watch_1.watch)();
27
27
  break;
28
28
  case undefined:
29
29
  console.info("You need to pass a command at first argument");
30
30
  break;
31
31
  default:
32
- console.info("command " + cmd + " not found, available commands: \"create\",\"gen-files\",\"deploy\",\"watch");
32
+ console.info("command ".concat(cmd, " not found, available commands: \"create\",\"gen-files\",\"deploy\",\"watch"));
33
33
  }
34
34
  /*
35
35
  const Mandarina = require("../mandarina/build/Mandarina").Mandarina
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.loadSchemas = exports.getConfig = void 0;
6
7
  var fs_1 = __importDefault(require("fs"));
7
8
  var path_1 = __importDefault(require("path"));
8
- exports.getConfig = function () {
9
+ var getConfig = function () {
9
10
  var rawData;
10
11
  try {
11
12
  rawData = fs_1.default.readFileSync(path_1.default.join(process.cwd(), 'mandarina.json'), 'utf8');
@@ -34,6 +35,7 @@ exports.getConfig = function () {
34
35
  }
35
36
  return (config);
36
37
  };
38
+ exports.getConfig = getConfig;
37
39
  var walkSync = function (dir, fileList) {
38
40
  var files = fs_1.default.readdirSync(dir);
39
41
  fileList = fileList || [];
@@ -49,7 +51,7 @@ var walkSync = function (dir, fileList) {
49
51
  });
50
52
  return fileList;
51
53
  };
52
- exports.loadSchemas = function (dir) {
54
+ var loadSchemas = function (dir) {
53
55
  var tables = [];
54
56
  var schemas = [];
55
57
  var actions = [];
@@ -88,4 +90,5 @@ exports.loadSchemas = function (dir) {
88
90
  }
89
91
  });
90
92
  };
93
+ exports.loadSchemas = loadSchemas;
91
94
  //# sourceMappingURL=utils.js.map
@@ -3,11 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.watch = void 0;
6
7
  var genFiles_1 = require("./gen-files/genFiles");
7
8
  var fs_1 = __importDefault(require("fs"));
8
9
  var utils_1 = require("./utils");
9
- exports.watch = function () {
10
- var config = utils_1.getConfig();
10
+ var watch = function () {
11
+ var config = (0, utils_1.getConfig)();
11
12
  if (!config)
12
13
  return;
13
14
  var dir = config.dir;
@@ -20,4 +21,5 @@ exports.watch = function () {
20
21
  });
21
22
  }
22
23
  };
24
+ exports.watch = watch;
23
25
  //# sourceMappingURL=watch.js.map
package/build/index.js CHANGED
@@ -3,13 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Table = exports.Action = exports.CustomAction = exports.getConfig = void 0;
6
7
  var CustomAction_1 = require("./Action/CustomAction");
7
- exports.CustomAction = CustomAction_1.CustomAction;
8
+ Object.defineProperty(exports, "CustomAction", { enumerable: true, get: function () { return CustomAction_1.CustomAction; } });
8
9
  var Table_1 = require("./Table/Table");
9
- exports.Table = Table_1.Table;
10
+ Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return Table_1.Table; } });
10
11
  var Mandarina_1 = __importDefault(require("./Mandarina"));
11
12
  var utils_1 = require("./cli/utils");
12
- exports.getConfig = utils_1.getConfig;
13
+ Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return utils_1.getConfig; } });
13
14
  var Action = CustomAction_1.CustomAction; //for backward compatibility
14
15
  exports.Action = Action;
15
16
  exports.default = Mandarina_1.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mandarina-server",
3
- "version": "2.1.51",
3
+ "version": "2.1.53",
4
4
  "description": "Mandarina for server side",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",