@steedos/service-object-mixin 2.4.11-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 +21 -0
- package/package.json +17 -0
- package/package.service.js +410 -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/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
### Summary 摘要
|
|
2
|
+
|
|
3
|
+
为微服务提供一个 this.getObject 函数,返回一个对象,其中包括 objectql 中的所有函数。
|
|
4
|
+
|
|
5
|
+
例如
|
|
6
|
+
```
|
|
7
|
+
methods: {
|
|
8
|
+
getObject: (objectName)=> {
|
|
9
|
+
return {
|
|
10
|
+
find: async (params) => {
|
|
11
|
+
return await this.broker.call('objectql.find', {objectName, ...params})
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Why should this be worked on? 此需求的应用场景?
|
|
20
|
+
|
|
21
|
+
解决在微服务中用简化语法调用 objectql 的问题。
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@steedos/service-object-mixin",
|
|
3
|
+
"version": "2.4.11-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": "94de71d5fb570d39a0e367ee944d9fdc55246fb1"
|
|
17
|
+
}
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: sunhaolin@hotoa.com
|
|
3
|
+
* @Date: 2023-03-23 15:12:14
|
|
4
|
+
* @LastEditors: sunhaolin@hotoa.com
|
|
5
|
+
* @LastEditTime: 2023-04-06 17:22:03
|
|
6
|
+
* @Description:
|
|
7
|
+
*/
|
|
8
|
+
"use strict";
|
|
9
|
+
// @ts-check
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {import('moleculer').Context} Context Moleculer's Context
|
|
14
|
+
*/
|
|
15
|
+
module.exports = {
|
|
16
|
+
name: 'object-mixin',
|
|
17
|
+
namespace: "steedos",
|
|
18
|
+
mixins: [],
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Settings
|
|
22
|
+
*/
|
|
23
|
+
settings: {
|
|
24
|
+
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Dependencies
|
|
29
|
+
*/
|
|
30
|
+
dependencies: [],
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Actions
|
|
34
|
+
*/
|
|
35
|
+
actions: {
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Events
|
|
42
|
+
*/
|
|
43
|
+
events: {
|
|
44
|
+
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Methods
|
|
49
|
+
*/
|
|
50
|
+
methods: {
|
|
51
|
+
getObject: {
|
|
52
|
+
handler: function (objectName) {
|
|
53
|
+
return {
|
|
54
|
+
aggregate: async (query, externalPipeline, userSession) => {
|
|
55
|
+
return await this.broker.call("objectql.aggregate", {
|
|
56
|
+
objectName,
|
|
57
|
+
query,
|
|
58
|
+
externalPipeline
|
|
59
|
+
}, {
|
|
60
|
+
meta: {
|
|
61
|
+
user: userSession
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
},
|
|
65
|
+
find: async (query, userSession) => {
|
|
66
|
+
return await this.broker.call("objectql.find", {
|
|
67
|
+
objectName,
|
|
68
|
+
query
|
|
69
|
+
}, {
|
|
70
|
+
meta: {
|
|
71
|
+
user: userSession
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
},
|
|
75
|
+
count: async (query, userSession) => {
|
|
76
|
+
return await this.broker.call("objectql.count", {
|
|
77
|
+
objectName,
|
|
78
|
+
query
|
|
79
|
+
}, {
|
|
80
|
+
meta: {
|
|
81
|
+
user: userSession
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
},
|
|
85
|
+
findOne: async (id, query, userSession) => {
|
|
86
|
+
return await this.broker.call("objectql.findOne", {
|
|
87
|
+
objectName,
|
|
88
|
+
id,
|
|
89
|
+
query,
|
|
90
|
+
}, {
|
|
91
|
+
meta: {
|
|
92
|
+
user: userSession
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
},
|
|
96
|
+
insert: async (doc, userSession) => {
|
|
97
|
+
return await this.broker.call("objectql.insert", {
|
|
98
|
+
objectName,
|
|
99
|
+
doc,
|
|
100
|
+
}, {
|
|
101
|
+
meta: {
|
|
102
|
+
user: userSession
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
},
|
|
106
|
+
update: async (id, doc, userSession) => {
|
|
107
|
+
return await this.broker.call("objectql.update", {
|
|
108
|
+
objectName,
|
|
109
|
+
id,
|
|
110
|
+
doc,
|
|
111
|
+
}, {
|
|
112
|
+
meta: {
|
|
113
|
+
user: userSession
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
},
|
|
117
|
+
updateOne: async (id, doc, userSession) => {
|
|
118
|
+
return await this.broker.call("objectql.updateOne", {
|
|
119
|
+
objectName,
|
|
120
|
+
id,
|
|
121
|
+
doc,
|
|
122
|
+
}, {
|
|
123
|
+
meta: {
|
|
124
|
+
user: userSession
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
},
|
|
128
|
+
updateMany: async (queryFilters, doc, userSession) => {
|
|
129
|
+
return await this.broker.call("objectql.updateMany", {
|
|
130
|
+
objectName,
|
|
131
|
+
queryFilters,
|
|
132
|
+
doc,
|
|
133
|
+
}, {
|
|
134
|
+
meta: {
|
|
135
|
+
user: userSession
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
},
|
|
139
|
+
delete: async (id, userSession) => {
|
|
140
|
+
return await this.broker.call("objectql.delete", {
|
|
141
|
+
objectName: objectName,
|
|
142
|
+
id: id,
|
|
143
|
+
}, {
|
|
144
|
+
meta: {
|
|
145
|
+
user: userSession
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
},
|
|
149
|
+
directAggregate: async (query, externalPipeline, userSession) => {
|
|
150
|
+
return await this.broker.call("objectql.directAggregate", {
|
|
151
|
+
objectName,
|
|
152
|
+
query,
|
|
153
|
+
externalPipeline
|
|
154
|
+
}, {
|
|
155
|
+
meta: {
|
|
156
|
+
user: userSession
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
},
|
|
160
|
+
directAggregatePrefixalPipeline: async (query, externalPipeline, userSession) => {
|
|
161
|
+
return await this.broker.call("objectql.directAggregatePrefixalPipeline", {
|
|
162
|
+
objectName,
|
|
163
|
+
query,
|
|
164
|
+
externalPipeline
|
|
165
|
+
}, {
|
|
166
|
+
meta: {
|
|
167
|
+
user: userSession
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
},
|
|
171
|
+
directFind: async (query, userSession) => {
|
|
172
|
+
return await this.broker.call("objectql.directFind", {
|
|
173
|
+
objectName,
|
|
174
|
+
query
|
|
175
|
+
}, {
|
|
176
|
+
meta: {
|
|
177
|
+
user: userSession
|
|
178
|
+
}
|
|
179
|
+
})
|
|
180
|
+
},
|
|
181
|
+
directInsert: async (doc, userSession) => {
|
|
182
|
+
return await this.broker.call("objectql.directInsert", {
|
|
183
|
+
objectName,
|
|
184
|
+
doc,
|
|
185
|
+
}, {
|
|
186
|
+
meta: {
|
|
187
|
+
user: userSession
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
},
|
|
191
|
+
directUpdate: async (id, doc, userSession) => {
|
|
192
|
+
return await this.broker.call("objectql.directUpdate", {
|
|
193
|
+
objectName,
|
|
194
|
+
id,
|
|
195
|
+
doc,
|
|
196
|
+
}, {
|
|
197
|
+
meta: {
|
|
198
|
+
user: userSession
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
},
|
|
202
|
+
directDelete: async (id, userSession) => {
|
|
203
|
+
return await this.broker.call("objectql.directDelete", {
|
|
204
|
+
objectName,
|
|
205
|
+
id,
|
|
206
|
+
}, {
|
|
207
|
+
meta: {
|
|
208
|
+
user: userSession
|
|
209
|
+
}
|
|
210
|
+
})
|
|
211
|
+
},
|
|
212
|
+
getField: async (fieldApiName, userSession) => {
|
|
213
|
+
return await this.broker.call("objectql.getField", {
|
|
214
|
+
objectName,
|
|
215
|
+
fieldApiName,
|
|
216
|
+
}, {
|
|
217
|
+
meta: {
|
|
218
|
+
user: userSession
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
},
|
|
222
|
+
getFields: async (userSession) => {
|
|
223
|
+
return await this.broker.call("objectql.getFields", {
|
|
224
|
+
objectName,
|
|
225
|
+
}, {
|
|
226
|
+
meta: {
|
|
227
|
+
user: userSession
|
|
228
|
+
}
|
|
229
|
+
})
|
|
230
|
+
},
|
|
231
|
+
getNameFieldKey: async (userSession) => {
|
|
232
|
+
return await this.broker.call("objectql.getNameFieldKey", {
|
|
233
|
+
objectName,
|
|
234
|
+
}, {
|
|
235
|
+
meta: {
|
|
236
|
+
user: userSession
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
},
|
|
240
|
+
toConfig: async (userSession) => {
|
|
241
|
+
return await this.broker.call("objectql.toConfig", {
|
|
242
|
+
objectName,
|
|
243
|
+
}, {
|
|
244
|
+
meta: {
|
|
245
|
+
user: userSession
|
|
246
|
+
}
|
|
247
|
+
})
|
|
248
|
+
},
|
|
249
|
+
getConfig: async (userSession) => {
|
|
250
|
+
return await this.broker.call("objectql.getConfig", {
|
|
251
|
+
objectName,
|
|
252
|
+
}, {
|
|
253
|
+
meta: {
|
|
254
|
+
user: userSession
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
},
|
|
258
|
+
getUserObjectPermissions: async (userSession) => {
|
|
259
|
+
return await this.broker.call("objectql.getUserObjectPermissions", {
|
|
260
|
+
objectName,
|
|
261
|
+
}, {
|
|
262
|
+
meta: {
|
|
263
|
+
user: userSession
|
|
264
|
+
}
|
|
265
|
+
})
|
|
266
|
+
},
|
|
267
|
+
isEnableAudit: async () => {
|
|
268
|
+
return await this.broker.call("objectql.isEnableAudit", {
|
|
269
|
+
objectName,
|
|
270
|
+
})
|
|
271
|
+
},
|
|
272
|
+
_makeNewID: async () => {
|
|
273
|
+
return await this.broker.call("objectql._makeNewID", {
|
|
274
|
+
objectName,
|
|
275
|
+
})
|
|
276
|
+
},
|
|
277
|
+
getRecordAbsoluteUrl: async () => {
|
|
278
|
+
return await this.broker.call("objectql.getRecordAbsoluteUrl", {
|
|
279
|
+
objectName,
|
|
280
|
+
})
|
|
281
|
+
},
|
|
282
|
+
getGridAbsoluteUrl: async () => {
|
|
283
|
+
return await this.broker.call("objectql.getGridAbsoluteUrl", {
|
|
284
|
+
objectName,
|
|
285
|
+
})
|
|
286
|
+
},
|
|
287
|
+
getRecordPermissionsById: async (recordId, userSession) => {
|
|
288
|
+
return await this.broker.call("objectql.getRecordPermissionsById", {
|
|
289
|
+
objectName,
|
|
290
|
+
recordId,
|
|
291
|
+
}, {
|
|
292
|
+
meta: {
|
|
293
|
+
user: userSession
|
|
294
|
+
}
|
|
295
|
+
})
|
|
296
|
+
},
|
|
297
|
+
getRecordPermissions: async (record, userSession) => {
|
|
298
|
+
return await this.broker.call("objectql.getRecordPermissions", {
|
|
299
|
+
objectName,
|
|
300
|
+
record,
|
|
301
|
+
}, {
|
|
302
|
+
meta: {
|
|
303
|
+
user: userSession
|
|
304
|
+
}
|
|
305
|
+
})
|
|
306
|
+
},
|
|
307
|
+
getRecordView: async (context, userSession) => {
|
|
308
|
+
return await this.broker.call("objectql.getRecordView", {
|
|
309
|
+
objectName,
|
|
310
|
+
context,
|
|
311
|
+
}, {
|
|
312
|
+
meta: {
|
|
313
|
+
user: userSession
|
|
314
|
+
}
|
|
315
|
+
})
|
|
316
|
+
},
|
|
317
|
+
createDefaultRecordView: async (userSession) => {
|
|
318
|
+
return await this.broker.call("objectql.createDefaultRecordView", {
|
|
319
|
+
objectName,
|
|
320
|
+
}, {
|
|
321
|
+
meta: {
|
|
322
|
+
user: userSession
|
|
323
|
+
}
|
|
324
|
+
})
|
|
325
|
+
},
|
|
326
|
+
getDefaultRecordView: async (userSession) => {
|
|
327
|
+
return await this.broker.call("objectql.getDefaultRecordView", {
|
|
328
|
+
objectName,
|
|
329
|
+
}, {
|
|
330
|
+
meta: {
|
|
331
|
+
user: userSession
|
|
332
|
+
}
|
|
333
|
+
})
|
|
334
|
+
},
|
|
335
|
+
getRelateds: async () => {
|
|
336
|
+
return await this.broker.call("objectql.getRelateds", {
|
|
337
|
+
objectName,
|
|
338
|
+
})
|
|
339
|
+
},
|
|
340
|
+
refreshIndexes: async () => {
|
|
341
|
+
return await this.broker.call("objectql.refreshIndexes", {
|
|
342
|
+
objectName,
|
|
343
|
+
})
|
|
344
|
+
},
|
|
345
|
+
allowRead: async (userSession) => {
|
|
346
|
+
return await this.broker.call("objectql.allowRead", {
|
|
347
|
+
objectName,
|
|
348
|
+
}, {
|
|
349
|
+
meta: {
|
|
350
|
+
user: userSession
|
|
351
|
+
}
|
|
352
|
+
})
|
|
353
|
+
},
|
|
354
|
+
allowInsert: async (userSession) => {
|
|
355
|
+
return await this.broker.call("objectql.allowInsert", {
|
|
356
|
+
objectName,
|
|
357
|
+
}, {
|
|
358
|
+
meta: {
|
|
359
|
+
user: userSession
|
|
360
|
+
}
|
|
361
|
+
})
|
|
362
|
+
},
|
|
363
|
+
allowUpdate: async (userSession) => {
|
|
364
|
+
return await this.broker.call("objectql.allowUpdate", {
|
|
365
|
+
objectName,
|
|
366
|
+
}, {
|
|
367
|
+
meta: {
|
|
368
|
+
user: userSession
|
|
369
|
+
}
|
|
370
|
+
})
|
|
371
|
+
},
|
|
372
|
+
allowDelete: async (userSession) => {
|
|
373
|
+
return await this.broker.call("objectql.allowDelete", {
|
|
374
|
+
objectName,
|
|
375
|
+
}, {
|
|
376
|
+
meta: {
|
|
377
|
+
user: userSession
|
|
378
|
+
}
|
|
379
|
+
})
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
},
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Service created lifecycle event handler
|
|
390
|
+
*/
|
|
391
|
+
created() {
|
|
392
|
+
},
|
|
393
|
+
|
|
394
|
+
merged(schema) {
|
|
395
|
+
},
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Service started lifecycle event handler
|
|
399
|
+
*/
|
|
400
|
+
async started() {
|
|
401
|
+
|
|
402
|
+
},
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Service stopped lifecycle event handler
|
|
406
|
+
*/
|
|
407
|
+
async stopped() {
|
|
408
|
+
|
|
409
|
+
}
|
|
410
|
+
};
|