@steedos/service-objectql 2.4.8-beta.1
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/LICENSE.txt +22 -0
- package/README.md +6 -0
- package/package.json +20 -0
- package/package.service.js +565 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Steedos Licensing
|
|
2
|
+
|
|
3
|
+
SOFTWARE LICENSING
|
|
4
|
+
|
|
5
|
+
To determine under which license you may use a file from the Steedos source code,
|
|
6
|
+
please resort to the header of that file.
|
|
7
|
+
|
|
8
|
+
If the file has no header, the following rules apply
|
|
9
|
+
1. enterprise features are licensed under Steedos Enterprise Terms, see License.enterprise.txt
|
|
10
|
+
2. source code that is neither (1) is licensed under MIT, see https://opensource.org/licenses/MIT
|
|
11
|
+
|
|
12
|
+
On request, licenses under different terms are available.
|
|
13
|
+
|
|
14
|
+
Source code of enterprise features are files that
|
|
15
|
+
* are in folders named "ee" or start with "ee_", or in subfolders of such folders.
|
|
16
|
+
* contain the strings "ee_" in its filename name.
|
|
17
|
+
The files can be found by running the command `find . -iname ee -or -iname "*_ee*" -or -iname "*ee_*"`
|
|
18
|
+
|
|
19
|
+
STEEDOS TRADEMARK GUIDELINES
|
|
20
|
+
|
|
21
|
+
Your use of the mark Steedos is subject to Steedos, Inc's prior written approval. For trademark approval or any questions
|
|
22
|
+
you have about using these trademarks, please email zhuangjianguo@steedos.com
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@steedos/service-objectql",
|
|
3
|
+
"version": "2.4.8-beta.1",
|
|
4
|
+
"main": "package.service.js",
|
|
5
|
+
"private": false,
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"steedos"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {},
|
|
13
|
+
"description": "steedos package",
|
|
14
|
+
"repository": {},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"gitHead": "f35130770cfb86468309f8f9a8ce21a3bbb5b2f6",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@steedos/objectql": "2.4.6"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: sunhaolin@hotoa.com
|
|
3
|
+
* @Date: 2023-03-23 15:12:14
|
|
4
|
+
* @LastEditors: sunhaolin@hotoa.com
|
|
5
|
+
* @LastEditTime: 2023-03-27 17:15:39
|
|
6
|
+
* @Description:
|
|
7
|
+
*/
|
|
8
|
+
"use strict";
|
|
9
|
+
// @ts-check
|
|
10
|
+
|
|
11
|
+
const { getObject } = require('@steedos/objectql');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {import('moleculer').Context} Context Moleculer's Context
|
|
15
|
+
*/
|
|
16
|
+
module.exports = {
|
|
17
|
+
name: 'objectql',
|
|
18
|
+
namespace: "steedos",
|
|
19
|
+
mixins: [],
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Settings
|
|
23
|
+
*/
|
|
24
|
+
settings: {
|
|
25
|
+
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Dependencies
|
|
30
|
+
*/
|
|
31
|
+
dependencies: [],
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Actions
|
|
35
|
+
*/
|
|
36
|
+
actions: {
|
|
37
|
+
aggregate: {
|
|
38
|
+
params: {
|
|
39
|
+
objectName: { type: "string" },
|
|
40
|
+
query: { type: "object" },
|
|
41
|
+
externalPipeline: { type: "array", items: "object" }
|
|
42
|
+
},
|
|
43
|
+
async handler(ctx) {
|
|
44
|
+
const userSession = ctx.meta.user;
|
|
45
|
+
const { objectName, query, externalPipeline } = ctx.params;
|
|
46
|
+
const obj = getObject(objectName)
|
|
47
|
+
return await obj.aggregate(query, externalPipeline, userSession)
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
find: {
|
|
51
|
+
params: {
|
|
52
|
+
objectName: { type: "string" },
|
|
53
|
+
query: {
|
|
54
|
+
type: "object",
|
|
55
|
+
props: {
|
|
56
|
+
fields: { type: 'array', items: "string", optional: true },
|
|
57
|
+
filters: [{ type: 'array', optional: true }, { type: 'string', optional: true }],
|
|
58
|
+
top: { type: 'number', optional: true },
|
|
59
|
+
skip: { type: 'number', optional: true },
|
|
60
|
+
sort: { type: 'string', optional: true }
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
async handler(ctx) {
|
|
65
|
+
this.broker.logger.info('objectql.find', ctx.params)
|
|
66
|
+
const { objectName, query } = ctx.params
|
|
67
|
+
const obj = getObject(objectName)
|
|
68
|
+
const userSession = ctx.meta.user;
|
|
69
|
+
return await obj.find(query, userSession)
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
count: {
|
|
73
|
+
params: {
|
|
74
|
+
objectName: { type: "string" },
|
|
75
|
+
query: {
|
|
76
|
+
type: "object",
|
|
77
|
+
props: {
|
|
78
|
+
fields: { type: 'array', items: "string", optional: true },
|
|
79
|
+
filters: [{ type: 'array', optional: true }, { type: 'string', optional: true }],
|
|
80
|
+
top: { type: 'number', optional: true },
|
|
81
|
+
skip: { type: 'number', optional: true },
|
|
82
|
+
sort: { type: 'string', optional: true }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
async handler(ctx) {
|
|
87
|
+
this.broker.logger.info('objectql.count', ctx.params)
|
|
88
|
+
const { objectName, query } = ctx.params
|
|
89
|
+
const obj = getObject(objectName)
|
|
90
|
+
const userSession = ctx.meta.user;
|
|
91
|
+
return await obj.count(query, userSession)
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
findOne: {
|
|
95
|
+
params: {
|
|
96
|
+
objectName: { type: "string" },
|
|
97
|
+
id: { type: "any" },
|
|
98
|
+
query: { type: "object", optional: true }
|
|
99
|
+
},
|
|
100
|
+
async handler(ctx) {
|
|
101
|
+
const userSession = ctx.meta.user;
|
|
102
|
+
const { objectName, id, query } = ctx.params;
|
|
103
|
+
const obj = getObject(objectName)
|
|
104
|
+
return await obj.findOne(id, query, userSession)
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
insert: {
|
|
108
|
+
params: {
|
|
109
|
+
objectName: { type: "string" },
|
|
110
|
+
doc: { type: "object" }
|
|
111
|
+
},
|
|
112
|
+
async handler(ctx) {
|
|
113
|
+
const userSession = ctx.meta.user;
|
|
114
|
+
const { objectName, doc } = ctx.params;
|
|
115
|
+
const obj = getObject(objectName)
|
|
116
|
+
let data = '';
|
|
117
|
+
if (_.isString(doc)) {
|
|
118
|
+
data = JSON.parse(doc);
|
|
119
|
+
} else {
|
|
120
|
+
data = JSON.parse(JSON.stringify(doc));
|
|
121
|
+
}
|
|
122
|
+
if (userSession && obj.getField('space')) {
|
|
123
|
+
data.space = userSession.spaceId;
|
|
124
|
+
}
|
|
125
|
+
return await obj.insert(data, userSession)
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
update: {
|
|
129
|
+
params: {
|
|
130
|
+
objectName: { type: "string" },
|
|
131
|
+
id: { type: "any" },
|
|
132
|
+
doc: { type: "object" }
|
|
133
|
+
},
|
|
134
|
+
async handler(ctx) {
|
|
135
|
+
const userSession = ctx.meta.user;
|
|
136
|
+
const { objectName, id, doc } = ctx.params;
|
|
137
|
+
const obj = getObject(objectName)
|
|
138
|
+
let data = '';
|
|
139
|
+
if (_.isString(doc)) {
|
|
140
|
+
data = JSON.parse(doc);
|
|
141
|
+
} else {
|
|
142
|
+
data = JSON.parse(JSON.stringify(doc));
|
|
143
|
+
}
|
|
144
|
+
delete data.space;
|
|
145
|
+
return await obj.update(id, data, userSession)
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
updateOne: {
|
|
149
|
+
params: {
|
|
150
|
+
objectName: { type: "string" },
|
|
151
|
+
id: { type: "any" },
|
|
152
|
+
doc: { type: "object" }
|
|
153
|
+
},
|
|
154
|
+
async handler(ctx) {
|
|
155
|
+
const userSession = ctx.meta.user;
|
|
156
|
+
const { objectName, id, doc } = ctx.params;
|
|
157
|
+
const obj = getObject(objectName)
|
|
158
|
+
let data = '';
|
|
159
|
+
if (_.isString(doc)) {
|
|
160
|
+
data = JSON.parse(doc);
|
|
161
|
+
} else {
|
|
162
|
+
data = JSON.parse(JSON.stringify(doc));
|
|
163
|
+
}
|
|
164
|
+
delete data.space;
|
|
165
|
+
return await obj.updateOne(id, data, userSession)
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
updateMany: {
|
|
169
|
+
params: {
|
|
170
|
+
objectName: { type: "string" },
|
|
171
|
+
queryFilters: { type: "array", items: "any" },
|
|
172
|
+
doc: { type: "object" }
|
|
173
|
+
},
|
|
174
|
+
async handler(ctx) {
|
|
175
|
+
const userSession = ctx.meta.user;
|
|
176
|
+
const { objectName, queryFilters, doc } = ctx.params;
|
|
177
|
+
const obj = getObject(objectName)
|
|
178
|
+
let data = '';
|
|
179
|
+
if (_.isString(doc)) {
|
|
180
|
+
data = JSON.parse(doc);
|
|
181
|
+
} else {
|
|
182
|
+
data = JSON.parse(JSON.stringify(doc));
|
|
183
|
+
}
|
|
184
|
+
delete data.space;
|
|
185
|
+
return await obj.updateMany(queryFilters, data, userSession)
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
delete: {
|
|
189
|
+
params: {
|
|
190
|
+
objectName: { type: "string" },
|
|
191
|
+
id: { type: "any" }
|
|
192
|
+
},
|
|
193
|
+
async handler(ctx) {
|
|
194
|
+
const userSession = ctx.meta.user;
|
|
195
|
+
const { objectName, id } = ctx.params;
|
|
196
|
+
const obj = getObject(objectName)
|
|
197
|
+
const enableTrash = obj.enable_trash
|
|
198
|
+
if (!enableTrash) {
|
|
199
|
+
return await obj.delete(id, userSession)
|
|
200
|
+
} else {
|
|
201
|
+
const data = {
|
|
202
|
+
is_deleted: true,
|
|
203
|
+
deleted: new Date(),
|
|
204
|
+
deleted_by: userSession ? userSession.userId : null
|
|
205
|
+
}
|
|
206
|
+
return await obj.update(id, data, userSession)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
directAggregate: {
|
|
211
|
+
params: {
|
|
212
|
+
objectName: { type: "string" },
|
|
213
|
+
query: { type: "object" },
|
|
214
|
+
externalPipeline: { type: "array", items: "object" }
|
|
215
|
+
},
|
|
216
|
+
async handler(ctx) {
|
|
217
|
+
const userSession = ctx.meta.user;
|
|
218
|
+
const { objectName, query, externalPipeline } = ctx.params;
|
|
219
|
+
const obj = getObject(objectName)
|
|
220
|
+
return await obj.directAggregate(query, externalPipeline, userSession)
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
directAggregatePrefixalPipeline: {
|
|
224
|
+
params: {
|
|
225
|
+
objectName: { type: "string" },
|
|
226
|
+
query: { type: "object" },
|
|
227
|
+
prefixalPipeline: { type: "array", items: "object" }
|
|
228
|
+
},
|
|
229
|
+
async handler(ctx) {
|
|
230
|
+
const userSession = ctx.meta.user;
|
|
231
|
+
const { objectName, query, prefixalPipeline } = ctx.params;
|
|
232
|
+
const obj = getObject(objectName)
|
|
233
|
+
return await obj.directAggregatePrefixalPipeline(query, prefixalPipeline, userSession)
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
directFind: {
|
|
237
|
+
params: {
|
|
238
|
+
objectName: { type: "string" },
|
|
239
|
+
query: {
|
|
240
|
+
type: "object",
|
|
241
|
+
props: {
|
|
242
|
+
fields: { type: 'array', items: "string", optional: true },
|
|
243
|
+
filters: [{ type: 'array', optional: true }, { type: 'string', optional: true }],
|
|
244
|
+
top: { type: 'number', optional: true },
|
|
245
|
+
skip: { type: 'number', optional: true },
|
|
246
|
+
sort: { type: 'string', optional: true }
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
async handler(ctx) {
|
|
251
|
+
const userSession = ctx.meta.user;
|
|
252
|
+
const { objectName, query } = ctx.params;
|
|
253
|
+
const obj = getObject(objectName)
|
|
254
|
+
return await obj.directFind(query, userSession)
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
directInsert: {
|
|
258
|
+
params: {
|
|
259
|
+
objectName: { type: "string" },
|
|
260
|
+
doc: { type: "object" }
|
|
261
|
+
},
|
|
262
|
+
async handler(ctx) {
|
|
263
|
+
const userSession = ctx.meta.user;
|
|
264
|
+
const { objectName, doc } = ctx.params;
|
|
265
|
+
const obj = getObject(objectName)
|
|
266
|
+
return await obj.directInsert(doc, userSession)
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
directUpdate: {
|
|
270
|
+
params: {
|
|
271
|
+
objectName: { type: "string" },
|
|
272
|
+
id: { type: "any" },
|
|
273
|
+
doc: { type: "object" }
|
|
274
|
+
},
|
|
275
|
+
async handler(ctx) {
|
|
276
|
+
const userSession = ctx.meta.user;
|
|
277
|
+
const { objectName, id, doc } = ctx.params;
|
|
278
|
+
const obj = getObject(objectName)
|
|
279
|
+
return await obj.directUpdate(id, doc, userSession)
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
directDelete: {
|
|
283
|
+
params: {
|
|
284
|
+
objectName: { type: "string" },
|
|
285
|
+
id: { type: "any" },
|
|
286
|
+
},
|
|
287
|
+
async handler(ctx) {
|
|
288
|
+
const userSession = ctx.meta.user;
|
|
289
|
+
const { objectName, id } = ctx.params;
|
|
290
|
+
const obj = getObject(objectName)
|
|
291
|
+
return await obj.directDelete(id, userSession)
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
getField: {
|
|
295
|
+
params: {
|
|
296
|
+
objectName: { type: "string" },
|
|
297
|
+
fieldApiName: { type: "string" },
|
|
298
|
+
},
|
|
299
|
+
async handler(ctx) {
|
|
300
|
+
const { objectName, fieldApiName } = ctx.params;
|
|
301
|
+
const obj = getObject(objectName)
|
|
302
|
+
return obj.getField(fieldApiName).toConfig()
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
getFields: {
|
|
306
|
+
params: {
|
|
307
|
+
objectName: { type: "string" },
|
|
308
|
+
},
|
|
309
|
+
async handler(ctx) {
|
|
310
|
+
const { objectName } = ctx.params;
|
|
311
|
+
const obj = getObject(objectName)
|
|
312
|
+
return obj.toConfig().fields
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
getNameFieldKey: {
|
|
316
|
+
params: {
|
|
317
|
+
objectName: { type: "string" },
|
|
318
|
+
},
|
|
319
|
+
async handler(ctx) {
|
|
320
|
+
const { objectName } = ctx.params;
|
|
321
|
+
const obj = getObject(objectName)
|
|
322
|
+
return obj.getNameFieldKey()
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
toConfig: {
|
|
326
|
+
params: {
|
|
327
|
+
objectName: { type: "string" },
|
|
328
|
+
},
|
|
329
|
+
async handler(ctx) {
|
|
330
|
+
const { objectName } = ctx.params;
|
|
331
|
+
const obj = getObject(objectName)
|
|
332
|
+
return obj.toConfig()
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
getConfig: {
|
|
336
|
+
params: {
|
|
337
|
+
objectName: { type: "string" },
|
|
338
|
+
},
|
|
339
|
+
async handler(ctx) {
|
|
340
|
+
const { objectName } = ctx.params;
|
|
341
|
+
const obj = getObject(objectName)
|
|
342
|
+
return obj.getConfig()
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
getUserObjectPermission: {
|
|
346
|
+
params: {
|
|
347
|
+
objectName: { type: "string" },
|
|
348
|
+
},
|
|
349
|
+
async handler(ctx) {
|
|
350
|
+
const userSession = ctx.meta.user;
|
|
351
|
+
const { objectName } = ctx.params;
|
|
352
|
+
const obj = getObject(objectName)
|
|
353
|
+
return obj.getUserObjectPermission(userSession)
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
isEnableAudit: {
|
|
357
|
+
params: {
|
|
358
|
+
objectName: { type: "string" },
|
|
359
|
+
},
|
|
360
|
+
async handler() {
|
|
361
|
+
const { objectName } = ctx.params;
|
|
362
|
+
const obj = getObject(objectName)
|
|
363
|
+
return obj.isEnableAudit();
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
_makeNewID: {
|
|
367
|
+
params: {
|
|
368
|
+
objectName: { type: "string" },
|
|
369
|
+
},
|
|
370
|
+
async handler() {
|
|
371
|
+
const { objectName } = ctx.params;
|
|
372
|
+
const obj = getObject(objectName)
|
|
373
|
+
return await obj._makeNewID();
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
getRecordAbsoluteUrl: {
|
|
377
|
+
params: {
|
|
378
|
+
objectName: { type: "string" },
|
|
379
|
+
},
|
|
380
|
+
async handler() {
|
|
381
|
+
const { objectName } = ctx.params;
|
|
382
|
+
const obj = getObject(objectName)
|
|
383
|
+
return obj.getRecordAbsoluteUrl();
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
getGridAbsoluteUrl: {
|
|
387
|
+
params: {
|
|
388
|
+
objectName: { type: "string" },
|
|
389
|
+
},
|
|
390
|
+
async handler() {
|
|
391
|
+
const { objectName } = ctx.params;
|
|
392
|
+
const obj = getObject(objectName)
|
|
393
|
+
return obj.getGridAbsoluteUrl();
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
getRecordPermissionsById: {
|
|
397
|
+
params: {
|
|
398
|
+
objectName: { type: "string" },
|
|
399
|
+
recordId: { type: "string" },
|
|
400
|
+
},
|
|
401
|
+
async handler(ctx) {
|
|
402
|
+
const userSession = ctx.meta.user;
|
|
403
|
+
const { objectName, recordId } = ctx.params;
|
|
404
|
+
const obj = getObject(objectName)
|
|
405
|
+
const record = await obj.findOne(recordId)
|
|
406
|
+
return obj.getRecordPermissions(record, userSession);
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
getRecordPermissions: {
|
|
410
|
+
params: {
|
|
411
|
+
objectName: { type: "string" },
|
|
412
|
+
record: { type: "object" },
|
|
413
|
+
},
|
|
414
|
+
async handler(ctx) {
|
|
415
|
+
const userSession = ctx.meta.user;
|
|
416
|
+
const { objectName, record } = ctx.params;
|
|
417
|
+
const obj = getObject(objectName)
|
|
418
|
+
return obj.getRecordPermissions(record, userSession);
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
getRecordView: {
|
|
422
|
+
params: {
|
|
423
|
+
objectName: { type: "string" },
|
|
424
|
+
context: { type: "object", optional: true },
|
|
425
|
+
},
|
|
426
|
+
async handler(ctx) {
|
|
427
|
+
const userSession = ctx.meta.user;
|
|
428
|
+
const { objectName, context } = ctx.params;
|
|
429
|
+
const obj = getObject(objectName)
|
|
430
|
+
return await obj.getRecordView(userSession, context);
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
createDefaultRecordView: {
|
|
434
|
+
params: {
|
|
435
|
+
objectName: { type: "string" },
|
|
436
|
+
},
|
|
437
|
+
async handler(ctx) {
|
|
438
|
+
const userSession = ctx.meta.user;
|
|
439
|
+
if (!userSession.is_space_admin) {
|
|
440
|
+
throw new Error('no permission.')
|
|
441
|
+
}
|
|
442
|
+
const { objectName } = ctx.params;
|
|
443
|
+
const obj = getObject(objectName)
|
|
444
|
+
return await obj.createDefaultRecordView(userSession);
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
getDefaultRecordView: {
|
|
448
|
+
params: {
|
|
449
|
+
objectName: { type: "string" },
|
|
450
|
+
},
|
|
451
|
+
async handler(ctx) {
|
|
452
|
+
const userSession = ctx.meta.user;
|
|
453
|
+
if (!userSession.is_space_admin) {
|
|
454
|
+
throw new Error('no permission.')
|
|
455
|
+
}
|
|
456
|
+
const { objectName } = ctx.params;
|
|
457
|
+
const obj = getObject(objectName)
|
|
458
|
+
return await obj.getDefaultRecordView(userSession);
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
getRelateds: {
|
|
462
|
+
params: {
|
|
463
|
+
objectName: { type: "string" },
|
|
464
|
+
},
|
|
465
|
+
async handler(ctx) {
|
|
466
|
+
const { objectName } = ctx.params;
|
|
467
|
+
const obj = getObject(objectName)
|
|
468
|
+
return await obj.getRelateds();
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
refreshIndexes: {
|
|
472
|
+
params: {
|
|
473
|
+
objectName: { type: "string" },
|
|
474
|
+
},
|
|
475
|
+
async handler(ctx) {
|
|
476
|
+
const { objectName } = ctx.params;
|
|
477
|
+
const obj = getObject(objectName)
|
|
478
|
+
return await obj.refreshIndexes();
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
allowRead: {
|
|
482
|
+
params: {
|
|
483
|
+
objectName: { type: "string" },
|
|
484
|
+
},
|
|
485
|
+
async handler(ctx) {
|
|
486
|
+
const userSession = ctx.meta.user;
|
|
487
|
+
const { objectName } = ctx.params;
|
|
488
|
+
const obj = getObject(objectName)
|
|
489
|
+
return await obj.allowRead(userSession);
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
allowInsert: {
|
|
493
|
+
params: {
|
|
494
|
+
objectName: { type: "string" },
|
|
495
|
+
},
|
|
496
|
+
async handler(ctx) {
|
|
497
|
+
const userSession = ctx.meta.user;
|
|
498
|
+
const { objectName } = ctx.params;
|
|
499
|
+
const obj = getObject(objectName)
|
|
500
|
+
return await obj.allowInsert(userSession);
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
allowUpdate: {
|
|
504
|
+
params: {
|
|
505
|
+
objectName: { type: "string" },
|
|
506
|
+
},
|
|
507
|
+
async handler(ctx) {
|
|
508
|
+
const userSession = ctx.meta.user;
|
|
509
|
+
const { objectName } = ctx.params;
|
|
510
|
+
const obj = getObject(objectName)
|
|
511
|
+
return await obj.allowUpdate(userSession);
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
allowDelete: {
|
|
515
|
+
params: {
|
|
516
|
+
objectName: { type: "string" },
|
|
517
|
+
},
|
|
518
|
+
async handler(ctx) {
|
|
519
|
+
const userSession = ctx.meta.user;
|
|
520
|
+
const { objectName } = ctx.params;
|
|
521
|
+
const obj = getObject(objectName)
|
|
522
|
+
return await obj.allowDelete(userSession);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
},
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Events
|
|
530
|
+
*/
|
|
531
|
+
events: {
|
|
532
|
+
|
|
533
|
+
},
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Methods
|
|
537
|
+
*/
|
|
538
|
+
methods: {
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
},
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Service created lifecycle event handler
|
|
545
|
+
*/
|
|
546
|
+
created() {
|
|
547
|
+
},
|
|
548
|
+
|
|
549
|
+
merged(schema) {
|
|
550
|
+
},
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Service started lifecycle event handler
|
|
554
|
+
*/
|
|
555
|
+
async started() {
|
|
556
|
+
|
|
557
|
+
},
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Service stopped lifecycle event handler
|
|
561
|
+
*/
|
|
562
|
+
async stopped() {
|
|
563
|
+
|
|
564
|
+
}
|
|
565
|
+
};
|