mandarina-server 1.7.5 → 1.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mandarina-server",
3
- "version": "1.7.5",
3
+ "version": "1.7.6",
4
4
  "description": "Mandarina for server side",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const Schema_1 = require("mandarina/build/Schema/Schema");
16
+ const TableInstanceNotFound_1 = require("../Errors/TableInstanceNotFound");
17
+ const UniqueActionError_1 = require("../Errors/UniqueActionError");
18
+ const Mandarina_1 = __importDefault(require("../Mandarina"));
19
+ class CustomAction {
20
+ /**
21
+ *
22
+ *
23
+ * @param schema
24
+ * @param actionOptions
25
+ */
26
+ constructor(schema, actionOptions) {
27
+ CustomAction.instances = CustomAction.instances || {};
28
+ if (schema instanceof Schema_1.Schema) {
29
+ this.schema = schema;
30
+ this.name = actionOptions.name || this.schema.name;
31
+ }
32
+ else {
33
+ this.name = schema;
34
+ }
35
+ if (CustomAction.instances[this.name]) {
36
+ throw new UniqueActionError_1.UniqueActionError(this.name);
37
+ }
38
+ this.actions = actionOptions.actions;
39
+ CustomAction.instances[this.name] = this;
40
+ }
41
+ static getInstance(name) {
42
+ if (!CustomAction.instances[name]) {
43
+ throw new TableInstanceNotFound_1.TableInstanceNotFound(name);
44
+ }
45
+ return CustomAction.instances[name];
46
+ }
47
+ getFields() {
48
+ return this.schema && this.schema.getFields();
49
+ }
50
+ getActions() {
51
+ const actions = this.actions || {};
52
+ let result = {};
53
+ Object.keys(actions).forEach((action) => {
54
+ result[action] = (_, args, context, info) => __awaiter(this, void 0, void 0, function* () {
55
+ const user = yield Mandarina_1.default.config.getUser(context);
56
+ const roles = (user && user.roles) || [];
57
+ const permissions = actions[action].permission || [];
58
+ if (permissions.includes('nobody')) {
59
+ throw new Error('Action not allowed');
60
+ }
61
+ if (permissions.includes('everybody') || permissions.some(permission => roles.includes(permission))) {
62
+ console.log('***************', `Action "${action}" not allowed for this user`, '***************');
63
+ console.warn(user && user.id, action);
64
+ console.warn(user && user.roles, permissions);
65
+ console.log('*****************************************************************************');
66
+ //throw new Error(`Action "${action}" not allowed for this user`)
67
+ }
68
+ const result = yield actions[action].action(_, args, context, info);
69
+ context.result = result;
70
+ if (CustomAction.hook) {
71
+ context.schemaName = this.name;
72
+ context.name = action;
73
+ yield CustomAction.hook(_, args, context, info);
74
+ }
75
+ return result;
76
+ });
77
+ });
78
+ return result;
79
+ }
80
+ }
81
+ exports.CustomAction = CustomAction;
82
+ CustomAction.setGlobalHook = (hook) => {
83
+ CustomAction.hook = hook;
84
+ };
85
+ //# sourceMappingURL=CustomAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomAction.js","sourceRoot":"","sources":["CustomAction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,0DAAwF;AACxF,2EAAsE;AACtE,mEAA8D;AAC9D,6DAAqC;AAIrC,MAAa,YAAY;IAarB;;;;;OAKG;IACH,YAAY,MAAuB,EAAE,aAA4B;QAC7D,YAAY,CAAC,SAAS,GAAG,YAAY,CAAC,SAAS,IAAI,EAAE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AEH,OAAO,MAAM,CAAC;IAClB,CAAC;;AAlFL,oCAmFC;AA1EU,0BAAa,GAAG,CAAC,IAAU,EAAE,EAAE;IAClC,YAAY,CAAC,IAAI,GAAG,IAAI,CAAA;AAC5B,CAAC,CAAA"}
@@ -0,0 +1,13 @@
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
+ const BaseError_1 = __importDefault(require("mandarina/build/Errors/BaseError"));
7
+ class TableInstanceNotFound extends BaseError_1.default {
8
+ constructor(schemaName) {
9
+ super(`The table ${schemaName} was not instantiated`);
10
+ }
11
+ }
12
+ exports.TableInstanceNotFound = TableInstanceNotFound;
13
+ //# sourceMappingURL=TableInstanceNotFound.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableInstanceNotFound.js","sourceRoot":"","sources":["TableInstanceNotFound.ts"],"names":[],"mappings":";;;;;AAAA,iFAAyD;AAEzD,MAAa,qBAAsB,SAAQ,mBAAS;IACnD,YAAY,UAAkB;QAC7B,KAAK,CAAC,aAAa,UAAU,uBAAuB,CAAC,CAAC;IACvD,CAAC;CACD;AAJD,sDAIC"}
@@ -0,0 +1,14 @@
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
+ const BaseError_1 = __importDefault(require("mandarina/build/Errors/BaseError"));
7
+ class UniqueActionError extends BaseError_1.default {
8
+ constructor(schemaName) {
9
+ const name = typeof schemaName === "string" ? schemaName : schemaName.name;
10
+ super(`The action "${name}" already exists, action name should be unique.`);
11
+ }
12
+ }
13
+ exports.UniqueActionError = UniqueActionError;
14
+ //# sourceMappingURL=UniqueActionError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UniqueActionError.js","sourceRoot":"","sources":["UniqueActionError.ts"],"names":[],"mappings":";;;;;AAAA,iFAAyD;AAGzD,MAAa,iBAAkB,SAAQ,mBAAS;IAC/C,YAAY,UAA2B;QACtC,MAAM,IAAI,GAAG,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAA;QAC1E,KAAK,CAAC,eAAe,IAAI,iDAAiD,CAAC,CAAC;IAC7E,CAAC;CACD;AALD,8CAKC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Table_1 = require("./Table/Table");
4
+ const CustomAction_1 = require("./Action/CustomAction");
5
+ const utils_1 = require("./cli/utils");
6
+ class Mandarina {
7
+ static load() {
8
+ const config = utils_1.getConfig();
9
+ utils_1.loadSchemas(config.dir);
10
+ }
11
+ static getQuery() {
12
+ let Query = {};
13
+ for (const tableName in Table_1.Table.instances) {
14
+ const table = Table_1.Table.getInstance(tableName);
15
+ Query = Object.assign(Object.assign({}, Query), table.getDefaultActions('query'));
16
+ }
17
+ return Query;
18
+ }
19
+ static getMutation() {
20
+ let Mutation = {};
21
+ for (const tableName in Table_1.Table.instances) {
22
+ const table = Table_1.Table.getInstance(tableName);
23
+ Mutation = Object.assign(Object.assign({}, Mutation), table.getDefaultActions('mutation'));
24
+ }
25
+ for (const actionName in CustomAction_1.CustomAction.instances) {
26
+ const action = CustomAction_1.CustomAction.getInstance(actionName);
27
+ Mutation = Object.assign(Object.assign({}, Mutation), action.getActions());
28
+ }
29
+ return Mutation;
30
+ }
31
+ }
32
+ exports.default = Mandarina;
33
+ Mandarina.config = {
34
+ getUser: ({ user }) => user,
35
+ };
36
+ Mandarina.configure = (options) => {
37
+ if (options.getUser) {
38
+ Mandarina.config.getUser = options.getUser;
39
+ }
40
+ };
41
+ //# sourceMappingURL=Mandarina.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Mandarina.js","sourceRoot":"","sources":["Mandarina.ts"],"names":[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AM,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;KAC9C;AACL,CAAC,CAAA"}
@@ -0,0 +1,340 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const mandarina_1 = require("mandarina");
16
+ const UniqueSchemaError_1 = require("mandarina/build/Errors/UniqueSchemaError");
17
+ const SchemaInstanceNotFound_1 = require("mandarina/build/Errors/SchemaInstanceNotFound");
18
+ const utils_1 = require("mandarina/build/Schema/utils");
19
+ const MissingIDTableError_1 = require("mandarina/build/Errors/MissingIDTableError");
20
+ const Mandarina_1 = __importDefault(require("../Mandarina"));
21
+ const Mutate_1 = require("mandarina/build/Operations/Mutate");
22
+ const language_1 = require("graphql/language");
23
+ const stringify_object_1 = __importDefault(require("stringify-object"));
24
+ const lodash_1 = require("lodash");
25
+ // import {flatten, unflatten} from "flat";
26
+ /**
27
+ *
28
+ * A Table instance is the representation of the one of several of the followings:
29
+ * Physic table in the data base
30
+ * Form
31
+ * List of results
32
+ */
33
+ class Table {
34
+ constructor(schema, tableOptions) {
35
+ this.insertWhereIntoInfo = (info, user, isSingleMutation = false, action, operationName) => {
36
+ var _a, _b;
37
+ const field = [];
38
+ const fields = new Set();
39
+ let required = false;
40
+ const allowedVariables = ((_b = (_a = info.fieldNodes[0]) === null || _a === void 0 ? void 0 : _a.arguments) === null || _b === void 0 ? void 0 : _b.map(({ name: { value } }) => value)) || [];
41
+ const query = language_1.visit(info.operation, {
42
+ enter: (node, key, parent, path, ancestors) => {
43
+ if (node.kind === 'VariableDefinition') {
44
+ if (!allowedVariables.includes(node === null || node === void 0 ? void 0 : node.variable.name.value)) {
45
+ return null;
46
+ }
47
+ }
48
+ if (node.kind === 'Field' && ancestors.length === 2 && node !== info.fieldNodes[0]) {
49
+ return null;
50
+ }
51
+ if (node.kind === 'Field' && node.name.value !== '__typename') {
52
+ field.push(node.name.value);
53
+ const internalField = field.slice(1).join('.');
54
+ let table;
55
+ if (internalField) {
56
+ fields.add(internalField);
57
+ const def = this.schema.getPathDefinition(internalField);
58
+ if (def.isTable && def.isArray) {
59
+ table = Table.instances[def.type];
60
+ }
61
+ }
62
+ else {
63
+ table = this;
64
+ }
65
+ if (table && table.options.where && (!isSingleMutation && table === this)) {
66
+ const where = table.options.where(user, action, operationName);
67
+ if (!where || lodash_1.isEmpty(where))
68
+ return;
69
+ const clone = Mutate_1.deepClone(node);
70
+ const originalWhereObj = clone.arguments ? clone.arguments.find((a) => a.name.value === 'where') : null;
71
+ let originalWhereString = '';
72
+ if (originalWhereObj && table === this) {
73
+ originalWhereString = language_1.print(originalWhereObj.value);
74
+ required = true;
75
+ }
76
+ const newWhereString = stringify_object_1.default(where, { singleQuotes: false });
77
+ let finalWhereString = originalWhereString ? `{AND:[${originalWhereString},${newWhereString}]}` : newWhereString;
78
+ if (originalWhereObj) {
79
+ originalWhereObj.value = language_1.parseValue(new language_1.Source(finalWhereString));
80
+ }
81
+ else {
82
+ clone.arguments.push({
83
+ kind: 'Argument',
84
+ name: { kind: 'Name', value: 'where' },
85
+ value: language_1.parseValue(new language_1.Source(finalWhereString))
86
+ });
87
+ }
88
+ return clone;
89
+ }
90
+ }
91
+ return;
92
+ },
93
+ leave(node) {
94
+ if (node.kind === 'Field' && node.name.value !== '__typename') {
95
+ field.pop();
96
+ }
97
+ }
98
+ });
99
+ let queryString = language_1.print(query);
100
+ if (required) {
101
+ queryString = queryString.replace(/\$where: (\w*)Input(,| |\))/, '$where: $1Input!$2');
102
+ }
103
+ return { fields: Array.from(fields), queryString };
104
+ };
105
+ Table.instances = Table.instances || {};
106
+ this.schema = schema;
107
+ this.name = this.schema.name;
108
+ if (!this.schema.keys.includes('id')) {
109
+ throw new MissingIDTableError_1.MissingIdTableError(this.name);
110
+ }
111
+ if (Table.instances[this.name]) {
112
+ throw new UniqueSchemaError_1.UniqueSchemaError(this.name);
113
+ }
114
+ this.options = Object.assign({}, tableOptions);
115
+ Table.instances[this.name] = this;
116
+ }
117
+ static getInstance(name) {
118
+ if (!Table.instances[name]) {
119
+ throw new SchemaInstanceNotFound_1.SchemaInstanceNotFound(name);
120
+ }
121
+ return Table.instances[name];
122
+ }
123
+ getFields() {
124
+ return this.schema.getFields();
125
+ }
126
+ /*
127
+ * It apply the fields permissions policy by action and roles, throw an exception if is not a valid request
128
+ *
129
+ * @param action
130
+ * @param role
131
+ * @param model
132
+
133
+ validatePermissions(action: ActionType, role: string | string[] | null | undefined, model: string[] | any): void {
134
+ const fields = this.getFields();
135
+ const allowedFields = Object.keys(this.getSchema(action, role));
136
+ const modelFields = (Array.isArray(model) ? model : Object.keys(model)).filter(f => fields.includes(f));
137
+ const intersection = allowedFields.filter(af => modelFields.includes(af));
138
+
139
+ if (modelFields.length > intersection.length) {
140
+ const invalidFields = modelFields.filter(mf => !intersection.includes(mf));
141
+ throw new FieldsPermissionsError(action, invalidFields);
142
+ }
143
+ }
144
+ */
145
+ shouldHasManyUpdate() {
146
+ const fields = this.schema.getFields().filter(f => f !== 'createdAt' && f !== 'createdAt');
147
+ return fields.length > 0;
148
+ }
149
+ //Insert where option in to the query
150
+ // static dotConcat = (a: string | undefined, b: string) => a ? `${a}.${b}` : b;
151
+ getDefaultActions(type) {
152
+ // OperationName for query is user or users, for mutation are createUser, updateUser ....
153
+ const operationNames = Object.values(this.schema.names[type]);
154
+ const resultResolvers = {};
155
+ operationNames.forEach((operationName) => {
156
+ if (!this.shouldHasManyUpdate())
157
+ return;
158
+ resultResolvers[operationName] = (_, args = {}, context, info) => __awaiter(this, void 0, void 0, function* () {
159
+ context.originalArgs = args;
160
+ const user = yield Mandarina_1.default.config.getUser(context);
161
+ const subOperationName = operationName.substr(0, 6);
162
+ const action = (['create', 'update', 'delete'].includes(subOperationName) ? subOperationName : 'read');
163
+ context.action = action;
164
+ let result;
165
+ const capitalizedAction = utils_1.capitalize(action);
166
+ context.operationName = operationName;
167
+ yield this.callHook(this.name, 'beforeValidate', _, args, context, info);
168
+ const isSingleMutation = operationName === this.schema.names.mutation.update || operationName === this.schema.names.mutation.create;
169
+ let { queryString, fields } = this.insertWhereIntoInfo(info, user, isSingleMutation, action, operationName);
170
+ if (type === 'mutation') {
171
+ // if (errors.length > 0) {
172
+ // await this.callHook('validationFailed', action, _, args, context, info);
173
+ // } else {
174
+ // await this.callHook('afterValidate', action, _, args, context, info);
175
+ // }
176
+ if (isSingleMutation && (action === 'update' || action === 'delete')) {
177
+ const where = this.options.where && this.options.where(user, action, operationName);
178
+ if (where) {
179
+ let finalWhere = args.where ? { AND: [args.where, where] } : where;
180
+ const exists = (yield context.prisma.exists[this.name](finalWhere));
181
+ if (!exists) {
182
+ throw new Error(`${action} on ${this.schema.name} not found for ${JSON.stringify(where)}`);
183
+ }
184
+ }
185
+ }
186
+ //VALIDATE IF USER CAN MUTATE THOSE FIELDS
187
+ this.schema.validateMutation(action, Mutate_1.deepClone(args), user && user.roles || []);
188
+ yield this.callHook(this.name, `before${capitalizedAction}`, _, args, context, info);
189
+ /*
190
+ HACK https://github.com/prisma/prisma/issues/4327
191
+ */
192
+ // if (`before${capitalizedAction}` === 'beforeUpdate' || `before${capitalizedAction}` === 'beforeCreate') {
193
+ // const flat = flatten(args.data)
194
+ // const where = args.where
195
+ // let run = false
196
+ // let withDeleteMany: any = {}
197
+ // let withoutDeleteMany: any = {}
198
+ // Object.keys(flat).forEach((key) => {
199
+ // if (key.match(/\.deleteMany\.0$/)) {
200
+ // run = true
201
+ // withDeleteMany[key] = flat[key]
202
+ // } else {
203
+ // withoutDeleteMany[key] = flat[key]
204
+ // }
205
+ // })
206
+ // if (run) {
207
+ // await prismamethod({where, data: unflatten(withdeletemany)}, info);
208
+ // args.data = unflatten(withoutDeleteMany)
209
+ // }
210
+ // }
211
+ const data = (yield context.prisma.request(queryString, args));
212
+ if (data.errors) {
213
+ console.error(data.errors);
214
+ }
215
+ result = Object.values(data.data)[0];
216
+ context.result = result;
217
+ yield this.callHook(this.name, `after${capitalizedAction}`, _, args, context, info);
218
+ this.schema.validateQuery(fields, user && user.roles || []);
219
+ }
220
+ if (type === 'query') {
221
+ // console.dir(JSON.parse(JSON.stringify(info)),{depth:1})
222
+ yield this.callHook(this.name, 'beforeQuery', _, args, context, info);
223
+ if (!!info.fieldName.match(/Connection$/)) {
224
+ this.schema.validateConnection(user && user.roles || []);
225
+ }
226
+ else {
227
+ this.schema.validateQuery(fields, user && user.roles || []);
228
+ }
229
+ //Validate if the roles is able to read those fields
230
+ if (operationName === this.schema.names.query.single) {
231
+ queryString = queryString.replace(operationName, this.schema.names.query.plural);
232
+ queryString = queryString.replace(new RegExp(`${this.schema.names.input.where.single}!?`), this.schema.names.input.where.plural + '!');
233
+ }
234
+ const data = (yield context.prisma.request(queryString, args));
235
+ if (data.errors) {
236
+ console.error(data.errors);
237
+ }
238
+ result = Object.values(data.data)[0];
239
+ if (operationName === this.schema.names.query.single) {
240
+ result = data.data[this.schema.names.query.plural];
241
+ result = result && result.length === 1 ? result[0] : null;
242
+ }
243
+ context.result = result;
244
+ yield this.callHook(this.name, 'afterQuery', _, args, context, info);
245
+ }
246
+ return result;
247
+ });
248
+ });
249
+ return resultResolvers;
250
+ }
251
+ /**
252
+ * Go back a mutation object to the original object
253
+ */
254
+ /**
255
+ * Simple wrapper to execute the table hook if exists and sub hook (nested hooks)
256
+ *
257
+ * @param name
258
+ * @param actionType
259
+ * @param _
260
+ * @param args
261
+ * @param context
262
+ * @param info
263
+ */
264
+ callHook(schemaName, name, _, args, context, info) {
265
+ return __awaiter(this, void 0, void 0, function* () {
266
+ try {
267
+ let prefix = '';
268
+ if (name.indexOf('before') === 0)
269
+ prefix = 'before';
270
+ if (name.indexOf('after') === 0)
271
+ prefix = 'after';
272
+ const globalHookHandler = Table.hooks[name];
273
+ const hookHandler = this.options.hooks && this.options.hooks[name];
274
+ if (args.data && prefix) {
275
+ const fields = Object.keys(args.data);
276
+ const schema = mandarina_1.Schema.getInstance(schemaName);
277
+ for (const field of fields) {
278
+ const def = schema.getPathDefinition(field);
279
+ const inline = !!(def.table && def.table.relation && def.table.relation.link === 'INLINE');
280
+ if (def.isTable) {
281
+ const operations = Object.keys(args.data[field]);
282
+ if (!Table.instances[def.type]) {
283
+ //console.warn(`No table for ${def.type} no neasted hooks applied`)
284
+ continue;
285
+ }
286
+ const table = Table.getInstance(def.type);
287
+ for (const operation of operations) {
288
+ const hookName = `${prefix}${utils_1.capitalize(operation)}`;
289
+ const args2 = args.data[field][operation];
290
+ if (Array.isArray(args2)) {
291
+ for (const arg2 of args2) {
292
+ if (inline) {
293
+ yield table.callHook(def.type, hookName, _, arg2.data ? arg2 : { data: arg2 }, context, info);
294
+ }
295
+ else {
296
+ yield table.callHook(def.type, hookName, _, arg2.data ? arg2 : { data: arg2 }, context, info);
297
+ }
298
+ }
299
+ }
300
+ else {
301
+ if (inline) {
302
+ yield table.callHook(def.type, hookName, _, args2.data ? args2 : { data: args2 }, context, info);
303
+ }
304
+ else {
305
+ yield table.callHook(def.type, hookName, _, args2.data ? args2 : { data: args2 }, context, info);
306
+ }
307
+ }
308
+ }
309
+ }
310
+ }
311
+ }
312
+ if (globalHookHandler) {
313
+ context.schemaName = schemaName;
314
+ context.name = name;
315
+ yield globalHookHandler(_, args, context, info);
316
+ }
317
+ if (hookHandler) {
318
+ yield hookHandler(_, args, context, info);
319
+ }
320
+ }
321
+ catch (e) {
322
+ console.error(`Error executing hook: "${name}" in Table: ${schemaName}"`);
323
+ console.error(e);
324
+ throw e;
325
+ }
326
+ });
327
+ }
328
+ }
329
+ exports.Table = Table;
330
+ Table.hooks = {};
331
+ Table.setGlobalHooks = (hooks) => {
332
+ Table.hooks = hooks;
333
+ };
334
+ // let time = new Date().getTime()
335
+ // export function bm(description = '',...args:any) {
336
+ // description && console.info(description,...args, new Date().getTime() - time)
337
+ // time = new Date().getTime()
338
+ //
339
+ // }
340
+ //# sourceMappingURL=Table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Table.js","sourceRoot":"","sources":["Table.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,yCAAiC;AACjC,gFAA2E;AAC3E,0FAAqF;AACrF,wDAAwD;AACxD,oFAA+E;AAE/E,6DAAiD;AACjD,8DAA4D;AAC5D,+CAAiE;AAEjE,wEAA8C;AAC9C,mCAA+B;AAE/B,2CAA2C;AAC3C;;;;;;GAMG;AACH,MAAa,KAAK;IAYd,YAAY,MAAc,EAAE,YAAgC;QA6J5D,wBAAmB,GAAG,CAAC,IAAwB,EAAE,IAAgC,EAAE,gBAAgB,GAAG,KAAK,EAAE,MAAkB,EAAE,aAAqB,EAAE,EAAE;;YACtJ,MAAM,KAAK,GAAa,EAAE,CAAA;YAC1B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAA;YAChC,IAAI,QAAQ,GAAG,KAAK,CAAA;YACpB,MAAM,gBAAgB,GAAC,aAAA,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,0CAAE,SAAS,0CAAE,GAAG,CAAC,CAAC,EAAC,IAAI,EAAC,EAAC,KAAK,EAAC,EAAC,EAAC,EAAE,CAAA,KAAK,MAAK,EAAE,CAAA;YAExF,MAAM,KAAK,GAAG,gBAAK,CAAC,IAAI,CAAC,SAAS,EAAE;gBAChC,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;oB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O,EAAE,IAAI,CAAC,CAAC;iBACnD;gBACD,IAAI,WAAW,EAAE;oBACb,MAAM,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;iBAC7C;aACJ;YAAC,OAAO,CAAC,EAAE;gBACR,OAAO,CAAC,KAAK,CAAC,0BAA0B,IAAI,eAAe,UAAU,GAAG,CAAC,CAAA;gBACzE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;gBAChB,MAAM,CAAC,CAAA;aACV;QACL,CAAC;KAAA;;AA1TL,sBAwVC;AAlVoB,WAAK,GAAS,EAAE,CAAA;AAE1B,oBAAc,GAAG,CAAC,KAAY,EAAE,EAAE;IACrC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAA;AACvB,CAAC,CAAA;AA2YL,kCAAkC;AAElC,qDAAqD;AACrD,oFAAoF;AACpF,kCAAkC;AAClC,EAAE;AACF,IAAI"}
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
+ const CustomAction_1 = require("./Action/CustomAction");
7
+ exports.CustomAction = CustomAction_1.CustomAction;
8
+ const Table_1 = require("./Table/Table");
9
+ exports.Table = Table_1.Table;
10
+ const Mandarina_1 = __importDefault(require("./Mandarina"));
11
+ const utils_1 = require("./cli/utils");
12
+ exports.getConfig = utils_1.getConfig;
13
+ const Action = CustomAction_1.CustomAction; //for backward compatibility
14
+ exports.Action = Action;
15
+ exports.default = Mandarina_1.default;
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AAAA,wDAAkD;AAW9C,uBAXI,2BAAY,CAWJ;AAVhB,yCAAmC;AAY/B,gBAZI,aAAK,CAYJ;AAXT,4DAAmC;AACnC,uCAAqC;AAOjC,oBAPI,iBAAS,CAOJ;AAJb,MAAM,MAAM,GAAC,2BAAY,CAAA,CAAC,4BAA4B;AAMlD,wBAAM;AAJV,kBAAe,mBAAS,CAAA"}