@steedos/objectql 2.5.0-beta.8 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/lib/driver/driver.d.ts +1 -0
  2. package/lib/driver/field-encrytion/mongosharedconst.js +2 -2
  3. package/lib/driver/field-encrytion/mongosharedconst.js.map +1 -1
  4. package/lib/driver/meteorMongo.js +2 -2
  5. package/lib/driver/meteorMongo.js.map +1 -1
  6. package/lib/driver/mongo.d.ts +1 -0
  7. package/lib/driver/mongo.js +17 -0
  8. package/lib/driver/mongo.js.map +1 -1
  9. package/lib/dynamic-load/package.js +0 -1
  10. package/lib/dynamic-load/package.js.map +1 -1
  11. package/lib/index.d.ts +1 -1
  12. package/lib/index.js +2 -3
  13. package/lib/index.js.map +1 -1
  14. package/lib/services/datasourceServiceFactory.js +32 -2
  15. package/lib/services/datasourceServiceFactory.js.map +1 -1
  16. package/lib/services/index.d.ts +0 -3
  17. package/lib/services/index.js +0 -3
  18. package/lib/services/index.js.map +1 -1
  19. package/lib/triggers/trigger.d.ts +1 -0
  20. package/lib/triggers/trigger.js +51 -0
  21. package/lib/triggers/trigger.js.map +1 -0
  22. package/lib/ts-types/triggerActionParams.d.ts +2 -2
  23. package/lib/types/datasource.d.ts +2 -1
  24. package/lib/types/datasource.js +21 -29
  25. package/lib/types/datasource.js.map +1 -1
  26. package/lib/types/index.d.ts +1 -1
  27. package/lib/types/index.js.map +1 -1
  28. package/lib/types/object.d.ts +7 -0
  29. package/lib/types/object.js +257 -55
  30. package/lib/types/object.js.map +1 -1
  31. package/lib/types/object_dynamic_load.d.ts +1 -0
  32. package/lib/types/object_dynamic_load.js +4 -3
  33. package/lib/types/object_dynamic_load.js.map +1 -1
  34. package/lib/types/object_events.js +2 -1
  35. package/lib/types/object_events.js.map +1 -1
  36. package/lib/util/transform.js +3 -18
  37. package/lib/util/transform.js.map +1 -1
  38. package/package.json +16 -15
  39. package/lib/services/helpers/graphql/consts.d.ts +0 -21
  40. package/lib/services/helpers/graphql/consts.js +0 -25
  41. package/lib/services/helpers/graphql/consts.js.map +0 -1
  42. package/lib/services/helpers/graphql/dealWithRelatedFields.d.ts +0 -16
  43. package/lib/services/helpers/graphql/dealWithRelatedFields.js +0 -73
  44. package/lib/services/helpers/graphql/dealWithRelatedFields.js.map +0 -1
  45. package/lib/services/helpers/graphql/generateActionGraphqlProp.d.ts +0 -2
  46. package/lib/services/helpers/graphql/generateActionGraphqlProp.js +0 -38
  47. package/lib/services/helpers/graphql/generateActionGraphqlProp.js.map +0 -1
  48. package/lib/services/helpers/graphql/generateSettingsGraphql.d.ts +0 -5
  49. package/lib/services/helpers/graphql/generateSettingsGraphql.js +0 -216
  50. package/lib/services/helpers/graphql/generateSettingsGraphql.js.map +0 -1
  51. package/lib/services/helpers/graphql/getGraphqlActions.d.ts +0 -2
  52. package/lib/services/helpers/graphql/getGraphqlActions.js +0 -930
  53. package/lib/services/helpers/graphql/getGraphqlActions.js.map +0 -1
  54. package/lib/services/helpers/graphql/getPrimaryFieldType.d.ts +0 -2
  55. package/lib/services/helpers/graphql/getPrimaryFieldType.js +0 -39
  56. package/lib/services/helpers/graphql/getPrimaryFieldType.js.map +0 -1
  57. package/lib/services/helpers/graphql/getQueryFields.d.ts +0 -2
  58. package/lib/services/helpers/graphql/getQueryFields.js +0 -32
  59. package/lib/services/helpers/graphql/getQueryFields.js.map +0 -1
  60. package/lib/services/helpers/graphql/index.d.ts +0 -7
  61. package/lib/services/helpers/graphql/index.js +0 -21
  62. package/lib/services/helpers/graphql/index.js.map +0 -1
  63. package/lib/services/helpers/graphql/utils.d.ts +0 -8
  64. package/lib/services/helpers/graphql/utils.js +0 -128
  65. package/lib/services/helpers/graphql/utils.js.map +0 -1
  66. package/lib/services/helpers/rest.d.ts +0 -4
  67. package/lib/services/helpers/rest.js +0 -61
  68. package/lib/services/helpers/rest.js.map +0 -1
  69. package/lib/services/objectService.d.ts +0 -230
  70. package/lib/services/objectService.js +0 -1078
  71. package/lib/services/objectService.js.map +0 -1
  72. package/lib/services/objectServiceDispatcher.d.ts +0 -1
  73. package/lib/services/objectServiceDispatcher.js +0 -484
  74. package/lib/services/objectServiceDispatcher.js.map +0 -1
  75. package/lib/services/objectServiceFactory.d.ts +0 -1
  76. package/lib/services/objectServiceFactory.js +0 -29
  77. package/lib/services/objectServiceFactory.js.map +0 -1
@@ -1,1078 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.objectBaseService = exports.getObjectServiceSchema = void 0;
4
- var tslib_1 = require("tslib");
5
- var object_1 = require("../types/object");
6
- var datasource_1 = require("../types/datasource");
7
- var object_dynamic_load_1 = require("../types/object_dynamic_load");
8
- var _ = require("underscore");
9
- var graphql_1 = require("./helpers/graphql");
10
- var filters_1 = require("@steedos/filters");
11
- var Future = require('fibers/future');
12
- function getObjectServiceMethodsSchema() {
13
- var methods = {
14
- aggregate: {
15
- handler: function (query, externalPipeline, userSession) {
16
- return tslib_1.__awaiter(this, void 0, void 0, function () {
17
- return tslib_1.__generator(this, function (_a) {
18
- switch (_a.label) {
19
- case 0: return [4, this.object.aggregate(query, externalPipeline, userSession)];
20
- case 1: return [2, _a.sent()];
21
- }
22
- });
23
- });
24
- }
25
- },
26
- find: {
27
- handler: function (query, userSession) {
28
- return tslib_1.__awaiter(this, void 0, void 0, function () {
29
- return tslib_1.__generator(this, function (_a) {
30
- switch (_a.label) {
31
- case 0:
32
- if (!(this.object.name == 'users')) return [3, 2];
33
- return [4, this.object.find(query)];
34
- case 1: return [2, _a.sent()];
35
- case 2: return [4, this.object.find(query, userSession)];
36
- case 3: return [2, _a.sent()];
37
- }
38
- });
39
- });
40
- }
41
- },
42
- findOne: {
43
- handler: function (id, query, userSession) {
44
- return tslib_1.__awaiter(this, void 0, void 0, function () {
45
- return tslib_1.__generator(this, function (_a) {
46
- switch (_a.label) {
47
- case 0:
48
- if (!(this.object.name == 'users')) return [3, 2];
49
- return [4, this.object.findOne(id, query)];
50
- case 1: return [2, _a.sent()];
51
- case 2: return [4, this.object.findOne(id, query, userSession)];
52
- case 3: return [2, _a.sent()];
53
- }
54
- });
55
- });
56
- }
57
- },
58
- insert: {
59
- handler: function (doc, userSession) {
60
- return tslib_1.__awaiter(this, void 0, void 0, function () {
61
- return tslib_1.__generator(this, function (_a) {
62
- switch (_a.label) {
63
- case 0: return [4, this.object.insert(doc, userSession)];
64
- case 1: return [2, _a.sent()];
65
- }
66
- });
67
- });
68
- }
69
- },
70
- update: {
71
- handler: function (id, doc, userSession) {
72
- return tslib_1.__awaiter(this, void 0, void 0, function () {
73
- return tslib_1.__generator(this, function (_a) {
74
- switch (_a.label) {
75
- case 0: return [4, this.object.update(id, doc, userSession)];
76
- case 1: return [2, _a.sent()];
77
- }
78
- });
79
- });
80
- }
81
- },
82
- updateOne: {
83
- handler: function (id, doc, userSession) {
84
- return tslib_1.__awaiter(this, void 0, void 0, function () {
85
- return tslib_1.__generator(this, function (_a) {
86
- switch (_a.label) {
87
- case 0: return [4, this.object.updateOne(id, doc, userSession)];
88
- case 1: return [2, _a.sent()];
89
- }
90
- });
91
- });
92
- }
93
- },
94
- updateMany: {
95
- handler: function (queryFilters, doc, userSession) {
96
- return tslib_1.__awaiter(this, void 0, void 0, function () {
97
- return tslib_1.__generator(this, function (_a) {
98
- switch (_a.label) {
99
- case 0: return [4, this.object.updateMany(queryFilters, doc, userSession)];
100
- case 1: return [2, _a.sent()];
101
- }
102
- });
103
- });
104
- }
105
- },
106
- delete: {
107
- handler: function (id, userSession) {
108
- return tslib_1.__awaiter(this, void 0, void 0, function () {
109
- return tslib_1.__generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0: return [4, this.object.delete(id, userSession)];
112
- case 1: return [2, _a.sent()];
113
- }
114
- });
115
- });
116
- }
117
- },
118
- directAggregate: {
119
- handler: function (query, externalPipeline, userSession) {
120
- return tslib_1.__awaiter(this, void 0, void 0, function () {
121
- return tslib_1.__generator(this, function (_a) {
122
- switch (_a.label) {
123
- case 0: return [4, this.object.directAggregate(query, externalPipeline, userSession)];
124
- case 1: return [2, _a.sent()];
125
- }
126
- });
127
- });
128
- }
129
- },
130
- directAggregatePrefixalPipeline: {
131
- handler: function (query, externalPipeline, userSession) {
132
- return tslib_1.__awaiter(this, void 0, void 0, function () {
133
- return tslib_1.__generator(this, function (_a) {
134
- switch (_a.label) {
135
- case 0: return [4, this.object.directAggregatePrefixalPipeline(query, externalPipeline, userSession)];
136
- case 1: return [2, _a.sent()];
137
- }
138
- });
139
- });
140
- }
141
- },
142
- directFind: {
143
- handler: function (query, userSession) {
144
- return tslib_1.__awaiter(this, void 0, void 0, function () {
145
- return tslib_1.__generator(this, function (_a) {
146
- switch (_a.label) {
147
- case 0: return [4, this.object.directFind(query, userSession)];
148
- case 1: return [2, _a.sent()];
149
- }
150
- });
151
- });
152
- }
153
- },
154
- directInsert: {
155
- handler: function (doc, userSession) {
156
- return tslib_1.__awaiter(this, void 0, void 0, function () {
157
- return tslib_1.__generator(this, function (_a) {
158
- switch (_a.label) {
159
- case 0: return [4, this.object.directInsert(doc, userSession)];
160
- case 1: return [2, _a.sent()];
161
- }
162
- });
163
- });
164
- }
165
- },
166
- directUpdate: {
167
- handler: function (id, doc, userSession) {
168
- return tslib_1.__awaiter(this, void 0, void 0, function () {
169
- return tslib_1.__generator(this, function (_a) {
170
- switch (_a.label) {
171
- case 0: return [4, this.object.directUpdate(id, doc, userSession)];
172
- case 1: return [2, _a.sent()];
173
- }
174
- });
175
- });
176
- }
177
- },
178
- directDelete: {
179
- handler: function (id, userSession) {
180
- return tslib_1.__awaiter(this, void 0, void 0, function () {
181
- return tslib_1.__generator(this, function (_a) {
182
- switch (_a.label) {
183
- case 0: return [4, this.object.directDelete(id, userSession)];
184
- case 1: return [2, _a.sent()];
185
- }
186
- });
187
- });
188
- }
189
- },
190
- count: {
191
- handler: function (query, userSession) {
192
- return tslib_1.__awaiter(this, void 0, void 0, function () {
193
- return tslib_1.__generator(this, function (_a) {
194
- switch (_a.label) {
195
- case 0: return [4, this.object.count(query, userSession)];
196
- case 1: return [2, _a.sent()];
197
- }
198
- });
199
- });
200
- }
201
- },
202
- getField: {
203
- handler: function (fieldName) {
204
- return this.object.getField(fieldName).toConfig();
205
- }
206
- },
207
- getFields: {
208
- handler: function () {
209
- return this.object.toConfig().fields;
210
- }
211
- },
212
- getNameFieldKey: {
213
- handler: function () {
214
- return this.object.getNameFieldKey();
215
- }
216
- },
217
- toConfig: {
218
- handler: function () {
219
- return this.object.toConfig();
220
- }
221
- },
222
- getConfig: {
223
- handler: function () {
224
- return this.object.getConfig();
225
- }
226
- },
227
- getUserObjectPermission: {
228
- handler: function (userSession) {
229
- return this.object.getUserObjectPermission(userSession);
230
- }
231
- },
232
- isEnableAudit: {
233
- handler: function () {
234
- return this.object.isEnableAudit();
235
- }
236
- },
237
- _makeNewID: {
238
- handler: function () {
239
- return tslib_1.__awaiter(this, void 0, void 0, function () {
240
- return tslib_1.__generator(this, function (_a) {
241
- switch (_a.label) {
242
- case 0: return [4, this.object._makeNewID()];
243
- case 1: return [2, _a.sent()];
244
- }
245
- });
246
- });
247
- }
248
- },
249
- getRecordAbsoluteUrl: {
250
- handler: function () {
251
- return tslib_1.__awaiter(this, void 0, void 0, function () {
252
- return tslib_1.__generator(this, function (_a) {
253
- return [2, this.object.getRecordAbsoluteUrl()];
254
- });
255
- });
256
- }
257
- },
258
- getGridAbsoluteUrl: {
259
- handler: function () {
260
- return tslib_1.__awaiter(this, void 0, void 0, function () {
261
- return tslib_1.__generator(this, function (_a) {
262
- return [2, this.object.getGridAbsoluteUrl()];
263
- });
264
- });
265
- }
266
- },
267
- getRecordPermissions: {
268
- handler: function (record, userSession) {
269
- return tslib_1.__awaiter(this, void 0, void 0, function () {
270
- return tslib_1.__generator(this, function (_a) {
271
- return [2, this.object.getRecordPermissions(record, userSession)];
272
- });
273
- });
274
- }
275
- },
276
- getRecordView: {
277
- handler: function (userSession, context) {
278
- return tslib_1.__awaiter(this, void 0, void 0, function () {
279
- return tslib_1.__generator(this, function (_a) {
280
- switch (_a.label) {
281
- case 0: return [4, this.object.getRecordView(userSession, context)];
282
- case 1: return [2, _a.sent()];
283
- }
284
- });
285
- });
286
- }
287
- },
288
- createDefaultRecordView: {
289
- handler: function (userSession) {
290
- return tslib_1.__awaiter(this, void 0, void 0, function () {
291
- return tslib_1.__generator(this, function (_a) {
292
- switch (_a.label) {
293
- case 0: return [4, this.object.createDefaultRecordView(userSession)];
294
- case 1: return [2, _a.sent()];
295
- }
296
- });
297
- });
298
- }
299
- },
300
- getDefaultRecordView: {
301
- handler: function (userSession) {
302
- return tslib_1.__awaiter(this, void 0, void 0, function () {
303
- return tslib_1.__generator(this, function (_a) {
304
- switch (_a.label) {
305
- case 0: return [4, this.object.getDefaultRecordView(userSession)];
306
- case 1: return [2, _a.sent()];
307
- }
308
- });
309
- });
310
- }
311
- },
312
- getRelateds: {
313
- handler: function () {
314
- return tslib_1.__awaiter(this, void 0, void 0, function () {
315
- return tslib_1.__generator(this, function (_a) {
316
- switch (_a.label) {
317
- case 0: return [4, this.object.getRelateds()];
318
- case 1: return [2, _a.sent()];
319
- }
320
- });
321
- });
322
- }
323
- },
324
- refreshIndexes: {
325
- handler: function () {
326
- return tslib_1.__awaiter(this, void 0, void 0, function () {
327
- return tslib_1.__generator(this, function (_a) {
328
- switch (_a.label) {
329
- case 0: return [4, this.object.refreshIndexes()];
330
- case 1: return [2, _a.sent()];
331
- }
332
- });
333
- });
334
- }
335
- },
336
- allowRead: {
337
- handler: function (userSession) {
338
- return tslib_1.__awaiter(this, void 0, void 0, function () {
339
- return tslib_1.__generator(this, function (_a) {
340
- switch (_a.label) {
341
- case 0: return [4, this.object.allowRead(userSession)];
342
- case 1: return [2, _a.sent()];
343
- }
344
- });
345
- });
346
- }
347
- },
348
- allowInsert: {
349
- handler: function (userSession) {
350
- return tslib_1.__awaiter(this, void 0, void 0, function () {
351
- return tslib_1.__generator(this, function (_a) {
352
- switch (_a.label) {
353
- case 0: return [4, this.object.allowInsert(userSession)];
354
- case 1: return [2, _a.sent()];
355
- }
356
- });
357
- });
358
- }
359
- },
360
- allowUpdate: {
361
- handler: function (userSession) {
362
- return tslib_1.__awaiter(this, void 0, void 0, function () {
363
- return tslib_1.__generator(this, function (_a) {
364
- switch (_a.label) {
365
- case 0: return [4, this.object.allowUpdate(userSession)];
366
- case 1: return [2, _a.sent()];
367
- }
368
- });
369
- });
370
- }
371
- },
372
- allowDelete: {
373
- handler: function (userSession) {
374
- return tslib_1.__awaiter(this, void 0, void 0, function () {
375
- return tslib_1.__generator(this, function (_a) {
376
- switch (_a.label) {
377
- case 0: return [4, this.object.allowDelete(userSession)];
378
- case 1: return [2, _a.sent()];
379
- }
380
- });
381
- });
382
- }
383
- }
384
- };
385
- return methods;
386
- }
387
- function getObjectServiceActionsSchema() {
388
- var actions = {
389
- aggregate: {
390
- params: {
391
- query: { type: "object" },
392
- externalPipeline: { type: "array", items: "object" }
393
- },
394
- handler: function (ctx) {
395
- return tslib_1.__awaiter(this, void 0, void 0, function () {
396
- var userSession, _a, query, externalPipeline;
397
- return tslib_1.__generator(this, function (_b) {
398
- switch (_b.label) {
399
- case 0:
400
- userSession = ctx.meta.user;
401
- _a = ctx.params, query = _a.query, externalPipeline = _a.externalPipeline;
402
- return [4, this.aggregate(query, externalPipeline, userSession)];
403
- case 1: return [2, _b.sent()];
404
- }
405
- });
406
- });
407
- }
408
- },
409
- graphqlFind: {
410
- params: {
411
- fields: { type: 'array', items: "string", optional: true },
412
- filters: [{ type: 'array', optional: true }, { type: 'string', optional: true }],
413
- top: { type: 'number', optional: true },
414
- skip: { type: 'number', optional: true },
415
- sort: { type: 'string', optional: true }
416
- },
417
- handler: function (ctx) {
418
- return tslib_1.__awaiter(this, void 0, void 0, function () {
419
- var filters, filtersStr, resolveInfo, fieldNames, userSession;
420
- return tslib_1.__generator(this, function (_a) {
421
- if (this.object.datasource.driver === datasource_1.SteedosDatabaseDriverType.MeteorMongo || this.object.datasource.driver === datasource_1.SteedosDatabaseDriverType.Mongo) {
422
- filters = ctx.params.filters;
423
- if (filters) {
424
- if (_.isString(filters)) {
425
- if (filters.indexOf('(is_deleted eq true)') < 0) {
426
- ctx.params.filters = "(".concat(filters, ") and (is_deleted ne true)");
427
- }
428
- }
429
- if (_.isArray(filters)) {
430
- filtersStr = (0, filters_1.formatFiltersToODataQuery)(filters);
431
- if (filtersStr.indexOf('(is_deleted eq true)') < 0) {
432
- ctx.params.filters = [ctx.params.filters, ['is_deleted', '!=', true]];
433
- }
434
- }
435
- }
436
- else {
437
- ctx.params.filters = '(is_deleted ne true)';
438
- }
439
- }
440
- if (_.isEmpty(ctx.params.fields)) {
441
- resolveInfo = ctx.meta.resolveInfo;
442
- fieldNames = (0, graphql_1.getQueryFields)(resolveInfo);
443
- if (!_.isEmpty(fieldNames)) {
444
- ctx.params.fields = fieldNames;
445
- }
446
- }
447
- userSession = ctx.meta.user;
448
- return [2, this.find(ctx.params, userSession)];
449
- });
450
- });
451
- }
452
- },
453
- graphqlCount: {
454
- params: {
455
- fields: { type: 'array', items: "string", optional: true },
456
- filters: [{ type: 'array', optional: true }, { type: 'string', optional: true }],
457
- top: { type: 'number', optional: true },
458
- skip: { type: 'number', optional: true },
459
- sort: { type: 'string', optional: true }
460
- },
461
- handler: function (ctx) {
462
- return tslib_1.__awaiter(this, void 0, void 0, function () {
463
- var filters, filtersStr, userSession;
464
- return tslib_1.__generator(this, function (_a) {
465
- if (this.object.datasource.driver === datasource_1.SteedosDatabaseDriverType.MeteorMongo || this.object.datasource.driver === datasource_1.SteedosDatabaseDriverType.Mongo) {
466
- filters = ctx.params.filters;
467
- if (filters) {
468
- if (_.isString(filters)) {
469
- if (filters.indexOf('(is_deleted eq true)') < 0) {
470
- ctx.params.filters = "(".concat(filters, ") and (is_deleted ne true)");
471
- }
472
- }
473
- if (_.isArray(filters)) {
474
- filtersStr = (0, filters_1.formatFiltersToODataQuery)(filters);
475
- if (filtersStr.indexOf('(is_deleted eq true)') < 0) {
476
- ctx.params.filters = [ctx.params.filters, ['is_deleted', '!=', true]];
477
- }
478
- }
479
- }
480
- else {
481
- ctx.params.filters = '(is_deleted ne true)';
482
- }
483
- }
484
- userSession = ctx.meta.user;
485
- return [2, this.count(ctx.params, userSession)];
486
- });
487
- });
488
- }
489
- },
490
- find: {
491
- params: {
492
- fields: { type: 'array', items: "string", optional: true },
493
- filters: [{ type: 'array', optional: true }, { type: 'string', optional: true }],
494
- top: { type: 'number', optional: true },
495
- skip: { type: 'number', optional: true },
496
- sort: { type: 'string', optional: true }
497
- },
498
- handler: function (ctx) {
499
- return tslib_1.__awaiter(this, void 0, void 0, function () {
500
- var userSession;
501
- return tslib_1.__generator(this, function (_a) {
502
- userSession = ctx.meta.user;
503
- return [2, this.find(ctx.params, userSession)];
504
- });
505
- });
506
- }
507
- },
508
- findOne: {
509
- params: {
510
- id: { type: "any" },
511
- query: { type: "object", optional: true }
512
- },
513
- handler: function (ctx) {
514
- return tslib_1.__awaiter(this, void 0, void 0, function () {
515
- var userSession, _a, id, query;
516
- return tslib_1.__generator(this, function (_b) {
517
- userSession = ctx.meta.user;
518
- _a = ctx.params, id = _a.id, query = _a.query;
519
- return [2, this.findOne(id, query, userSession)];
520
- });
521
- });
522
- }
523
- },
524
- insert: {
525
- params: {
526
- doc: { type: "object" }
527
- },
528
- handler: function (ctx) {
529
- return tslib_1.__awaiter(this, void 0, void 0, function () {
530
- var userSession, doc, data, object;
531
- return tslib_1.__generator(this, function (_a) {
532
- userSession = ctx.meta.user;
533
- doc = ctx.params.doc;
534
- data = '';
535
- if (_.isString(doc)) {
536
- data = JSON.parse(doc);
537
- }
538
- else {
539
- data = JSON.parse(JSON.stringify(doc));
540
- }
541
- object = this.object;
542
- if (userSession && object.getField('space')) {
543
- data.space = userSession.spaceId;
544
- }
545
- return [2, this.insert(data, userSession)];
546
- });
547
- });
548
- }
549
- },
550
- update: {
551
- params: {
552
- id: { type: "any" },
553
- doc: { type: "object" }
554
- },
555
- handler: function (ctx) {
556
- return tslib_1.__awaiter(this, void 0, void 0, function () {
557
- var userSession, _a, id, doc, data;
558
- return tslib_1.__generator(this, function (_b) {
559
- userSession = ctx.meta.user;
560
- _a = ctx.params, id = _a.id, doc = _a.doc;
561
- data = '';
562
- if (_.isString(doc)) {
563
- data = JSON.parse(doc);
564
- }
565
- else {
566
- data = JSON.parse(JSON.stringify(doc));
567
- }
568
- delete data.space;
569
- return [2, this.update(id, data, userSession)];
570
- });
571
- });
572
- }
573
- },
574
- updateOne: {
575
- params: {
576
- id: { type: "any" },
577
- doc: { type: "object" }
578
- },
579
- handler: function (ctx) {
580
- return tslib_1.__awaiter(this, void 0, void 0, function () {
581
- var userSession, _a, id, doc, data;
582
- return tslib_1.__generator(this, function (_b) {
583
- userSession = ctx.meta.user;
584
- _a = ctx.params, id = _a.id, doc = _a.doc;
585
- data = '';
586
- if (_.isString(doc)) {
587
- data = JSON.parse(doc);
588
- }
589
- else {
590
- data = JSON.parse(JSON.stringify(doc));
591
- }
592
- delete data.space;
593
- return [2, this.updateOne(id, data, userSession)];
594
- });
595
- });
596
- }
597
- },
598
- updateMany: {
599
- params: {
600
- queryFilters: { type: "array", items: "any" },
601
- doc: { type: "object" }
602
- },
603
- handler: function (ctx) {
604
- return tslib_1.__awaiter(this, void 0, void 0, function () {
605
- var userSession, _a, queryFilters, doc, data;
606
- return tslib_1.__generator(this, function (_b) {
607
- switch (_b.label) {
608
- case 0:
609
- userSession = ctx.meta.user;
610
- _a = ctx.params, queryFilters = _a.queryFilters, doc = _a.doc;
611
- data = '';
612
- if (_.isString(doc)) {
613
- data = JSON.parse(doc);
614
- }
615
- else {
616
- data = JSON.parse(JSON.stringify(doc));
617
- }
618
- delete data.space;
619
- return [4, this.updateMany(queryFilters, data, userSession)];
620
- case 1: return [2, _b.sent()];
621
- }
622
- });
623
- });
624
- }
625
- },
626
- delete: {
627
- params: {
628
- id: { type: "any" }
629
- },
630
- handler: function (ctx) {
631
- return tslib_1.__awaiter(this, void 0, void 0, function () {
632
- var userSession, id, object, enableTrash, data;
633
- return tslib_1.__generator(this, function (_a) {
634
- userSession = ctx.meta.user;
635
- id = ctx.params.id;
636
- object = this.object;
637
- enableTrash = object.enable_trash;
638
- if (!enableTrash) {
639
- return [2, this.delete(id, userSession)];
640
- }
641
- else {
642
- data = {
643
- is_deleted: true,
644
- deleted: new Date(),
645
- deleted_by: userSession ? userSession.userId : null
646
- };
647
- return [2, this.update(id, data, userSession)];
648
- }
649
- return [2];
650
- });
651
- });
652
- }
653
- },
654
- directAggregate: {
655
- params: {
656
- query: { type: "object" },
657
- externalPipeline: { type: "array", items: "object" }
658
- },
659
- handler: function (ctx) {
660
- return tslib_1.__awaiter(this, void 0, void 0, function () {
661
- var userSession, _a, query, externalPipeline;
662
- return tslib_1.__generator(this, function (_b) {
663
- userSession = ctx.meta.user;
664
- _a = ctx.params, query = _a.query, externalPipeline = _a.externalPipeline;
665
- return [2, this.directAggregate(query, externalPipeline, userSession)];
666
- });
667
- });
668
- }
669
- },
670
- directAggregatePrefixalPipeline: {
671
- params: {
672
- query: { type: "object" },
673
- prefixalPipeline: { type: "array", items: "object" }
674
- },
675
- handler: function (ctx) {
676
- return tslib_1.__awaiter(this, void 0, void 0, function () {
677
- var userSession, _a, query, prefixalPipeline;
678
- return tslib_1.__generator(this, function (_b) {
679
- userSession = ctx.meta.user;
680
- _a = ctx.params, query = _a.query, prefixalPipeline = _a.prefixalPipeline;
681
- return [2, this.directAggregatePrefixalPipeline(query, prefixalPipeline, userSession)];
682
- });
683
- });
684
- }
685
- },
686
- directFind: {
687
- params: {
688
- fields: { type: 'array', items: "string", optional: true },
689
- filters: [{ type: 'array', optional: true }, { type: 'string', optional: true }],
690
- top: { type: 'number', optional: true },
691
- skip: { type: 'number', optional: true },
692
- sort: { type: 'string', optional: true }
693
- },
694
- handler: function (ctx) {
695
- return tslib_1.__awaiter(this, void 0, void 0, function () {
696
- var userSession;
697
- return tslib_1.__generator(this, function (_a) {
698
- userSession = ctx.meta.user;
699
- return [2, this.directFind(ctx.params, userSession)];
700
- });
701
- });
702
- }
703
- },
704
- directInsert: {
705
- params: {
706
- doc: { type: "object" }
707
- },
708
- handler: function (ctx) {
709
- return tslib_1.__awaiter(this, void 0, void 0, function () {
710
- var userSession, doc;
711
- return tslib_1.__generator(this, function (_a) {
712
- userSession = ctx.meta.user;
713
- doc = ctx.params.doc;
714
- return [2, this.directInsert(doc, userSession)];
715
- });
716
- });
717
- }
718
- },
719
- directUpdate: {
720
- params: {
721
- id: { type: "any" },
722
- doc: { type: "object" }
723
- },
724
- handler: function (ctx) {
725
- return tslib_1.__awaiter(this, void 0, void 0, function () {
726
- var userSession, _a, id, doc;
727
- return tslib_1.__generator(this, function (_b) {
728
- userSession = ctx.meta.user;
729
- _a = ctx.params, id = _a.id, doc = _a.doc;
730
- return [2, this.directUpdate(id, doc, userSession)];
731
- });
732
- });
733
- }
734
- },
735
- directDelete: {
736
- params: {
737
- id: { type: "any" },
738
- },
739
- handler: function (ctx) {
740
- return tslib_1.__awaiter(this, void 0, void 0, function () {
741
- var userSession, id;
742
- return tslib_1.__generator(this, function (_a) {
743
- userSession = ctx.meta.user;
744
- id = ctx.params.id;
745
- return [2, this.directDelete(id, userSession)];
746
- });
747
- });
748
- }
749
- },
750
- count: {
751
- params: {
752
- fields: { type: 'array', items: "string", optional: true },
753
- filters: [{ type: 'array', optional: true }, { type: 'string', optional: true }],
754
- top: { type: 'number', optional: true },
755
- skip: { type: 'number', optional: true },
756
- sort: { type: 'string', optional: true }
757
- },
758
- handler: function (ctx) {
759
- return tslib_1.__awaiter(this, void 0, void 0, function () {
760
- var userSession;
761
- return tslib_1.__generator(this, function (_a) {
762
- userSession = ctx.meta.user;
763
- return [2, this.count(ctx.params, userSession)];
764
- });
765
- });
766
- }
767
- },
768
- getField: {
769
- params: {
770
- fieldApiName: { type: "string" },
771
- },
772
- handler: function (ctx) {
773
- return tslib_1.__awaiter(this, void 0, void 0, function () {
774
- var fieldApiName;
775
- return tslib_1.__generator(this, function (_a) {
776
- fieldApiName = ctx.params.fieldApiName;
777
- return [2, this.getField(fieldApiName)];
778
- });
779
- });
780
- }
781
- },
782
- getFields: {
783
- handler: function (ctx) {
784
- return tslib_1.__awaiter(this, void 0, void 0, function () {
785
- return tslib_1.__generator(this, function (_a) {
786
- return [2, this.getFields()];
787
- });
788
- });
789
- }
790
- },
791
- getNameFieldKey: {
792
- handler: function (ctx) {
793
- return tslib_1.__awaiter(this, void 0, void 0, function () {
794
- return tslib_1.__generator(this, function (_a) {
795
- return [2, this.getNameFieldKey()];
796
- });
797
- });
798
- }
799
- },
800
- toConfig: {
801
- handler: function (ctx) {
802
- return tslib_1.__awaiter(this, void 0, void 0, function () {
803
- return tslib_1.__generator(this, function (_a) {
804
- return [2, this.toConfig()];
805
- });
806
- });
807
- }
808
- },
809
- getConfig: {
810
- handler: function (ctx) {
811
- return tslib_1.__awaiter(this, void 0, void 0, function () {
812
- return tslib_1.__generator(this, function (_a) {
813
- return [2, this.getConfig()];
814
- });
815
- });
816
- }
817
- },
818
- getUserObjectPermission: {
819
- handler: function (ctx) {
820
- return tslib_1.__awaiter(this, void 0, void 0, function () {
821
- var userSession;
822
- return tslib_1.__generator(this, function (_a) {
823
- userSession = ctx.meta.user;
824
- return [2, this.getUserObjectPermission(userSession)];
825
- });
826
- });
827
- }
828
- },
829
- isEnableAudit: {
830
- handler: function () {
831
- return tslib_1.__awaiter(this, void 0, void 0, function () {
832
- return tslib_1.__generator(this, function (_a) {
833
- return [2, this.isEnableAudit()];
834
- });
835
- });
836
- }
837
- },
838
- _makeNewID: {
839
- handler: function () {
840
- return tslib_1.__awaiter(this, void 0, void 0, function () {
841
- return tslib_1.__generator(this, function (_a) {
842
- switch (_a.label) {
843
- case 0: return [4, this._makeNewID()];
844
- case 1: return [2, _a.sent()];
845
- }
846
- });
847
- });
848
- }
849
- },
850
- getRecordAbsoluteUrl: {
851
- handler: function () {
852
- return tslib_1.__awaiter(this, void 0, void 0, function () {
853
- return tslib_1.__generator(this, function (_a) {
854
- return [2, this.getRecordAbsoluteUrl()];
855
- });
856
- });
857
- }
858
- },
859
- getGridAbsoluteUrl: {
860
- handler: function () {
861
- return tslib_1.__awaiter(this, void 0, void 0, function () {
862
- return tslib_1.__generator(this, function (_a) {
863
- return [2, this.getGridAbsoluteUrl()];
864
- });
865
- });
866
- }
867
- },
868
- getRecordPermissionsById: {
869
- handler: function (ctx) {
870
- return tslib_1.__awaiter(this, void 0, void 0, function () {
871
- var userSession, recordId, record;
872
- return tslib_1.__generator(this, function (_a) {
873
- switch (_a.label) {
874
- case 0:
875
- userSession = ctx.meta.user;
876
- recordId = ctx.params.recordId;
877
- return [4, this.findOne(recordId)];
878
- case 1:
879
- record = _a.sent();
880
- return [2, this.getRecordPermissions(record, userSession)];
881
- }
882
- });
883
- });
884
- }
885
- },
886
- getRecordPermissions: {
887
- handler: function (ctx) {
888
- return tslib_1.__awaiter(this, void 0, void 0, function () {
889
- var userSession, record;
890
- return tslib_1.__generator(this, function (_a) {
891
- userSession = ctx.meta.user;
892
- record = ctx.params.record;
893
- return [2, this.getRecordPermissions(record, userSession)];
894
- });
895
- });
896
- }
897
- },
898
- getRecordView: {
899
- handler: function (ctx) {
900
- return tslib_1.__awaiter(this, void 0, void 0, function () {
901
- var userSession, context;
902
- return tslib_1.__generator(this, function (_a) {
903
- switch (_a.label) {
904
- case 0:
905
- userSession = ctx.meta.user;
906
- context = ctx.params.context;
907
- return [4, this.getRecordView(userSession, context)];
908
- case 1: return [2, _a.sent()];
909
- }
910
- });
911
- });
912
- }
913
- },
914
- createDefaultRecordView: {
915
- handler: function (ctx) {
916
- return tslib_1.__awaiter(this, void 0, void 0, function () {
917
- var userSession;
918
- return tslib_1.__generator(this, function (_a) {
919
- switch (_a.label) {
920
- case 0:
921
- userSession = ctx.meta.user;
922
- if (!userSession.is_space_admin) {
923
- throw new Error('no permission.');
924
- }
925
- return [4, this.createDefaultRecordView(userSession)];
926
- case 1: return [2, _a.sent()];
927
- }
928
- });
929
- });
930
- }
931
- },
932
- getDefaultRecordView: {
933
- handler: function (ctx) {
934
- return tslib_1.__awaiter(this, void 0, void 0, function () {
935
- var userSession;
936
- return tslib_1.__generator(this, function (_a) {
937
- switch (_a.label) {
938
- case 0:
939
- userSession = ctx.meta.user;
940
- if (!userSession.is_space_admin) {
941
- throw new Error('no permission.');
942
- }
943
- return [4, this.getDefaultRecordView(userSession)];
944
- case 1: return [2, _a.sent()];
945
- }
946
- });
947
- });
948
- }
949
- },
950
- getRelateds: {
951
- handler: function (ctx) {
952
- return tslib_1.__awaiter(this, void 0, void 0, function () {
953
- return tslib_1.__generator(this, function (_a) {
954
- switch (_a.label) {
955
- case 0: return [4, this.getRelateds()];
956
- case 1: return [2, _a.sent()];
957
- }
958
- });
959
- });
960
- }
961
- },
962
- refreshIndexes: {
963
- handler: function (ctx) {
964
- return tslib_1.__awaiter(this, void 0, void 0, function () {
965
- return tslib_1.__generator(this, function (_a) {
966
- switch (_a.label) {
967
- case 0: return [4, this.refreshIndexes()];
968
- case 1: return [2, _a.sent()];
969
- }
970
- });
971
- });
972
- }
973
- },
974
- allowRead: {
975
- handler: function (ctx) {
976
- return tslib_1.__awaiter(this, void 0, void 0, function () {
977
- var userSession;
978
- return tslib_1.__generator(this, function (_a) {
979
- switch (_a.label) {
980
- case 0:
981
- userSession = ctx.meta.user;
982
- return [4, this.allowRead(userSession)];
983
- case 1: return [2, _a.sent()];
984
- }
985
- });
986
- });
987
- }
988
- },
989
- allowInsert: {
990
- handler: function (ctx) {
991
- return tslib_1.__awaiter(this, void 0, void 0, function () {
992
- var userSession;
993
- return tslib_1.__generator(this, function (_a) {
994
- switch (_a.label) {
995
- case 0:
996
- userSession = ctx.meta.user;
997
- return [4, this.allowInsert(userSession)];
998
- case 1: return [2, _a.sent()];
999
- }
1000
- });
1001
- });
1002
- }
1003
- },
1004
- allowUpdate: {
1005
- handler: function (ctx) {
1006
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1007
- var userSession;
1008
- return tslib_1.__generator(this, function (_a) {
1009
- switch (_a.label) {
1010
- case 0:
1011
- userSession = ctx.meta.user;
1012
- return [4, this.allowUpdate(userSession)];
1013
- case 1: return [2, _a.sent()];
1014
- }
1015
- });
1016
- });
1017
- }
1018
- },
1019
- allowDelete: {
1020
- handler: function (ctx) {
1021
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1022
- var userSession;
1023
- return tslib_1.__generator(this, function (_a) {
1024
- switch (_a.label) {
1025
- case 0:
1026
- userSession = ctx.meta.user;
1027
- return [4, this.allowDelete(userSession)];
1028
- case 1: return [2, _a.sent()];
1029
- }
1030
- });
1031
- });
1032
- }
1033
- }
1034
- };
1035
- _.each(actions, function (action) {
1036
- delete action.params;
1037
- });
1038
- return actions;
1039
- }
1040
- function getObjectServiceSchema(serviceName, objectConfig) {
1041
- return {
1042
- name: serviceName,
1043
- actions: getObjectServiceActionsSchema(),
1044
- methods: getObjectServiceMethodsSchema(),
1045
- created: function () {
1046
- this.object = new object_1.SteedosObjectType(objectConfig.name, (0, datasource_1.getDataSource)(objectConfig.datasource), objectConfig);
1047
- }
1048
- };
1049
- }
1050
- exports.getObjectServiceSchema = getObjectServiceSchema;
1051
- exports.objectBaseService = {
1052
- name: '#_objectBaseService',
1053
- settings: {},
1054
- actions: getObjectServiceActionsSchema(),
1055
- methods: getObjectServiceMethodsSchema(),
1056
- created: function (broker) {
1057
- if (!this.getObjectConfig && !this.settings.objectApiName && !this.settings.objectConfig) {
1058
- throw new Error('Please set the settings.objectApiName.');
1059
- }
1060
- var objectConfig = this.getObjectConfig() || this.settings.objectConfig || (0, object_dynamic_load_1.getObjectConfig)(this.settings.objectApiName);
1061
- if (!objectConfig) {
1062
- throw new Error('Not found object config by objectApiName.');
1063
- }
1064
- var datasource = (0, datasource_1.getDataSource)(objectConfig.datasource);
1065
- if (datasource) {
1066
- this.object = datasource.getLocalObject(objectConfig.name);
1067
- this.objectApiName = objectConfig.name;
1068
- }
1069
- },
1070
- started: function () {
1071
- return tslib_1.__awaiter(this, void 0, void 0, function () {
1072
- return tslib_1.__generator(this, function (_a) {
1073
- return [2];
1074
- });
1075
- });
1076
- },
1077
- };
1078
- //# sourceMappingURL=objectService.js.map