@steedos/standard-object-database 3.0.0-beta.9 → 3.0.0-beta.92

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.
@@ -6,6 +6,7 @@
6
6
  * @Description:
7
7
  */
8
8
  var objectql = require('@steedos/objectql');
9
+ const _ = require('underscore');
9
10
 
10
11
  async function insertParentAndChildrenFieldForTreeObject(doc, needToCheckExists){
11
12
  const baseProps = {
@@ -1,23 +1,32 @@
1
1
  /*
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2024-04-23 14:35:03
4
- * @LastEditors: 孙浩林 sunhaolin@steedos.com
5
- * @LastEditTime: 2024-09-14 11:24:08
4
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
5
+ * @LastEditTime: 2025-05-06 16:19:19
6
6
  * @Description:
7
7
  */
8
-
8
+ const { parseURL } = require('ioredis/built/utils');
9
9
  const BullMqMixin = require('moleculer-bullmq');
10
10
  const axios = require('axios');
11
11
  const { evaluate } = require("amis-formula")
12
12
  const serviceObjectMixin = require('@steedos/service-object-mixin');
13
13
  const _ = require("lodash");
14
+ const { getAmisGlobalVariables } = require('@steedos/objectql');
15
+
16
+ let client;
17
+ if(process.env.STEEDOS_BULLMQ_REDIS){
18
+ client = parseURL(process.env.STEEDOS_BULLMQ_REDIS);
19
+ }else{
20
+ client = parseURL(process.env.CACHER);
21
+ client.db = 9;
22
+ }
14
23
 
15
24
  module.exports = {
16
25
  name: "object_webhooks",
17
26
  mixins: [serviceObjectMixin, BullMqMixin],
18
27
  settings: {
19
28
  bullmq: {
20
- client: process.env.QUEUE_BACKEND,
29
+ client: client,
21
30
  worker: { concurrency: 50 }
22
31
  }
23
32
  },
@@ -73,8 +82,9 @@ module.exports = {
73
82
  }
74
83
  let sender;
75
84
  let space;
85
+ let userSession;
76
86
  if(userId && spaceId){
77
- const userSession = await ctx.call('@steedos/service-accounts.getUserSession', {userId, spaceId})
87
+ userSession = await ctx.call('@steedos/service-accounts.getUserSession', {userId, spaceId})
78
88
  if(userSession){
79
89
  sender = {
80
90
  _id: userSession.userId,
@@ -108,14 +118,31 @@ module.exports = {
108
118
 
109
119
  if(condition){
110
120
 
121
+ const globalVariables = getAmisGlobalVariables(userSession);
111
122
  if(actionName == 'update' && execute_when === 'trueOnChangeOnly'){
112
- const oldResult = evaluate(condition, previousDoc);
123
+ let oldResult;
124
+ if (/\$\{.+\}/.test(condition)) {
125
+ // 有${}包裹的表达式
126
+ oldResult = evaluate(condition, Object.assign({}, globalVariables, previousDoc), { evalMode: false });
127
+ }
128
+ else {
129
+ // 老版本没有${}包裹的表达式
130
+ oldResult = evaluate(condition, Object.assign({}, globalVariables, previousDoc), { evalMode: true });
131
+ }
113
132
  if(oldResult){
114
133
  continue;
115
134
  }
116
135
  }
117
136
 
118
- const result = evaluate(condition, newDoc);
137
+ let result;
138
+ if (/\$\{.+\}/.test(condition)) {
139
+ // 有${}包裹的表达式
140
+ result = evaluate(condition, Object.assign({}, globalVariables, newDoc), { evalMode: false });
141
+ }
142
+ else {
143
+ // 老版本没有${}包裹的表达式
144
+ result = evaluate(condition, Object.assign({}, globalVariables, newDoc), { evalMode: true });
145
+ }
119
146
  if(!result){
120
147
  continue;
121
148
  }
@@ -28,7 +28,7 @@ module.exports = {
28
28
  },
29
29
  afterFind: async function(){
30
30
  const { spaceId } = this;
31
- let lng = Steedos.locale(this.userId, true);
31
+ let lng = "zh-CN";
32
32
  let dataList = [{_id: 'default', name: 'default', label: t(`objects_field_datasource_defaultValue`, {}, lng), ...BASERECORD}];
33
33
  let filters = InternalData.parserFilters(this.query.filters)
34
34
  if(filters._id === 'meteor'){
@@ -61,7 +61,7 @@ module.exports = {
61
61
  if(this.id){
62
62
  if(this.id === 'default'){
63
63
  try {
64
- let lng = Steedos.locale(this.userId, true)
64
+ let lng = "zh-CN"
65
65
  this.data.values = {_id: 'default', name: 'default', label: t(`objects_field_datasource_defaultValue`, {}, lng), ...BASERECORD};
66
66
  } catch (error) {
67
67
 
@@ -69,7 +69,7 @@ module.exports = {
69
69
  }
70
70
  if(this.id === 'meteor'){
71
71
  try {
72
- let lng = Steedos.locale(this.userId, true)
72
+ let lng = "zh-CN"
73
73
  this.data.values = {_id: 'meteor', name: 'meteor', label: t(`objects_field_datasource_meteor`, {}, lng), ...BASERECORD};
74
74
  } catch (error) {
75
75
 
@@ -199,8 +199,6 @@ module.exports = {
199
199
  }else{
200
200
  doc.name = getFieldName(doc.object,doc._name,doc.space);
201
201
  }
202
-
203
-
204
202
  validateDoc(doc);
205
203
  await checkFormulaInfiniteLoop(doc);
206
204
  await checkMasterDetailTypeField(doc);
@@ -2,7 +2,6 @@ const _ = require('underscore');
2
2
  const objectql = require('@steedos/objectql');
3
3
  const objectTree = require('../server/objects.tree.js');
4
4
  const sleep = async (ms) => new Promise(resolve => setTimeout(resolve, ms));
5
-
6
5
  module.exports = {
7
6
  beforeFind: async function () {
8
7
  delete this.query.fields;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-object-database",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.0-beta.92",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -11,13 +11,13 @@
11
11
  ],
12
12
  "description": "steedos package",
13
13
  "dependencies": {
14
- "@steedos/metadata-core": "3.0.0-beta.9",
15
- "@steedos/service-object-mixin": "3.0.0-beta.9",
14
+ "@steedos/metadata-core": "3.0.0-beta.92",
15
+ "@steedos/service-object-mixin": "3.0.0-beta.92",
16
16
  "amis-formula": "~6.3.0",
17
17
  "clone": "^2.1.2",
18
18
  "moleculer-bullmq": "3.0.0"
19
19
  },
20
20
  "repository": {},
21
21
  "license": "MIT",
22
- "gitHead": "9111ae9e9ce7c57c67c6bd670706f4344c28d69d"
22
+ "gitHead": "16a684ff645d0a9b745e4b49309f2c63d6a41395"
23
23
  }
@@ -1,537 +0,0 @@
1
- <!--
2
- * @Author: baozhoutao@steedos.com
3
- * @Date: 2022-06-02 17:45:15
4
- * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2024-10-17 12:02:21
6
- * @Description:
7
- -->
8
- <html>
9
- <head>
10
- <script src="/unpkg.com/@steedos-builder/fiddle@0.0.5/dist/builder-fiddle.umd.js"></script>
11
- <script src="/unpkg.com/axios@0.26.1/dist/axios.min.js"></script>
12
- <script src="https://unpkg.steedos.cn/flowbite@2.3.0/dist/flowbite.min.js"></script>
13
- <script src="https://cdn.tailwindcss.com"></script>
14
- <link href="/toast/toastr.min.css" rel="stylesheet" />
15
- <script src="/jquery.min.js" ></script>
16
- <script src="/toast/toastr.min.js"></script>
17
- <style>
18
- #toast-container.toast-bottom-center>div, #toast-container.toast-top-center>div {
19
- width: 450px;
20
- opacity: 1;
21
- }
22
- </style>
23
- </head>
24
-
25
- <body>
26
- <!-- Main modal -->
27
- <div id="fieldLayoutModal" tabindex="-1" aria-hidden="true" class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
28
- <div class="relative p-4 w-full max-w-2xl max-h-full">
29
- <!-- Modal content -->
30
- <div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
31
- <!-- Modal header -->
32
- <div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t dark:border-gray-600">
33
- <h3 class="text-xl font-semibold text-gray-900 dark:text-white">
34
- 字段保存结果
35
- </h3>
36
- <button type="button" class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" data-modal-hide="fieldLayoutModal">
37
- <svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
38
- <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
39
- </svg>
40
- <span class="sr-only">Close modal</span>
41
- </button>
42
- </div>
43
- <!-- Modal body -->
44
- <div class="p-4 md:p-5 space-y-4">
45
- <ul class="space-y-4 text-gray-500 list-disc list-inside dark:text-gray-400" id="fieldLayoutList">
46
- </ul>
47
- </div>
48
- </div>
49
- </div>
50
- </div>
51
- <builder-fiddle host="<%=builderHost%>"></builder-fiddle>
52
- <script>
53
- const useOpenAPI= <%=(useOpenAPI === "true" || useOpenAPI === true)%>;
54
- const settings = {
55
- assetUrls: "<%=assetUrls%>",
56
- rootUrl: "<%=rootUrl%>",
57
- userId: "<%=userId%>",
58
- tenantId: "<%=tenantId%>",
59
- authToken: "<%=authToken%>",
60
- messageOnly: true,
61
- useOpenAPI: useOpenAPI,
62
- oid: "<%=id%>",
63
- pageId: "<%=id%>",
64
- hiddenDeploy: true
65
- };
66
-
67
- let comp = document.querySelector("builder-fiddle");
68
-
69
- // set the modal menu element
70
- const $targetEl = document.getElementById('fieldLayoutModal');
71
- // options with default values
72
- const options = {
73
- placement: 'top-center',
74
- backdrop: 'dynamic',
75
- backdropClasses:
76
- 'bg-gray-900/50 dark:bg-gray-900/80 fixed inset-0 z-40',
77
- closable: true,
78
- onHide: () => {
79
- console.log('modal is hidden');
80
- },
81
- onShow: () => {
82
- console.log('modal is shown');
83
- },
84
- onToggle: () => {
85
- console.log('modal has been toggled');
86
- },
87
- };
88
- // instance options object
89
- const instanceOptions = {
90
- id: 'fieldLayoutModal',
91
- override: true
92
- };
93
- const modal = new Flowbite.default.Modal($targetEl, options, instanceOptions);
94
-
95
- const loadPage = async () => {
96
- const { assetUrls, rootUrl, userId, tenantId, authToken, oid } = settings;
97
-
98
- // 如果传入 steedos rooturl
99
- if (rootUrl && !authToken) return;
100
-
101
- const initialContent = {
102
- type: "page",
103
- title: "Welcome to Steedos",
104
- body: [],
105
- regions: ["body"],
106
- data: {
107
- objectName: "space_users",
108
- recordId: "",
109
- initialValues: {},
110
- appId: "builder",
111
- title: "",
112
- context: {
113
- rootUrl,
114
- userId,
115
- tenantId,
116
- authToken,
117
- },
118
- },
119
- };
120
-
121
- if (oid) {
122
- const result = await axios.get(
123
- `${rootUrl}/service/api/object_fields/amis/design/schema?oid=${oid}`,
124
- {
125
- withCredentials: true,
126
- headers: { Authorization: `Bearer ${tenantId},${authToken}` },
127
- }
128
- );
129
- if (result?.data) {
130
- let schema = result.data.schema || initialContent;
131
-
132
- // let objectName = result.data.object_name;
133
- // let pageType = result.data.type;
134
- if (typeof schema === "string") {
135
- schema = JSON.parse(schema);
136
- }
137
-
138
- if (!schema.data) {
139
- schema.data = {};
140
- }
141
-
142
- if (!schema.data.context) {
143
- schema.data.context = {};
144
- }
145
-
146
- // schema.data.objectName = objectName;
147
-
148
- schema.data.context.rootUrl = rootUrl;
149
- schema.data.context.tenantId = tenantId;
150
- schema.data.context.userId = userId;
151
- schema.data.context.authToken = authToken;
152
- schema.data.context.user = <%- JSON.stringify(userSession) %>;
153
-
154
- // if (objectName && pageType === "record") {
155
- // const record = await axios.get(
156
- // `${rootUrl}/api/v4/${objectName}?$orderby=modified&$top=1`,
157
- // {
158
- // withCredentials: true,
159
- // headers: { Authorization: `Bearer ${tenantId},${authToken}` },
160
- // }
161
- // );
162
- // const value = record?.data?.value;
163
- // if (value?.length > 0) {
164
- // schema.data.recordId = value[0]._id;
165
- // }
166
- // }
167
-
168
- return schema || initialContent
169
- }
170
- } else {
171
- return initialContent
172
- }
173
- };
174
-
175
- const savePage = async (data) => {
176
- const { rootUrl, userId, tenantId, authToken, oid } = settings;
177
-
178
- if (!oid) {
179
- return;
180
- }
181
-
182
- // 保存schema时,清理context下的认证信息
183
- const schema = JSON.parse(
184
- JSON.stringify(data.data.AmisSchema, null, 4)
185
- );
186
- if (schema.data && typeof schema.data.context === 'object' ) {
187
- delete schema.data.context
188
- }
189
-
190
- try {
191
- delete schema.data.recordId;
192
- delete schema.data.objectName;
193
- } catch (error) {
194
-
195
- }
196
-
197
- const result = await axios.post(
198
- `${rootUrl}/service/api/object_fields/amis/design/schema?oid=${oid}`,
199
- {
200
- withCredentials: true,
201
- schema: schema,
202
- },
203
- {
204
- headers: { Authorization: `Bearer ${tenantId},${authToken}` },
205
- }
206
- )
207
- .catch(function (error) {
208
- // handle error
209
- console.log(error);
210
- });
211
- const actionNames = ['insert', 'update', 'delete'];
212
-
213
- toastr.options = {
214
- "closeButton": true,
215
- "debug": false,
216
- "newestOnTop": false,
217
- "progressBar": false,
218
- "positionClass": "toast-top-center",
219
- "preventDuplicates": false,
220
- "onclick": null,
221
- "showDuration": "300",
222
- "hideDuration": "1000",
223
- "timeOut": "5000",
224
- "extendedTimeOut": "1000",
225
- "showEasing": "swing",
226
- "hideEasing": "linear",
227
- "showMethod": "fadeIn",
228
- "hideMethod": "fadeOut"
229
- }
230
-
231
- actionNames.forEach(function(actionName){
232
- const actionData = result.data.data[actionName];
233
- let actionLabel = '';
234
- if(actionName === 'insert'){
235
- actionLabel = '新增';
236
- }else if(actionName === 'update'){
237
- actionLabel = '更新';
238
- }else if(actionName === 'delete'){
239
- actionLabel = '删除';
240
- }
241
- if(actionData.error && actionData.error.length > 0){
242
- actionData.error.forEach((error)=>{
243
- toastr.warning(error.message, `${actionLabel}字段「${error.fieldLabel}(${error.fieldName})」失败:`);
244
- })
245
- }
246
- })
247
- return result;
248
- };
249
- window.addEventListener('message', function (event) {
250
- const { data } = event;
251
- if (data) {
252
- if(data.type === 'builder.loaded'){
253
- comp.messageFrame('builder.EditorPropsChanged', { editorProps : JSON.stringify({
254
- onChange: function(value){
255
- const fields = [];
256
- _.each(value.body, (bodyItem)=>{
257
- if(bodyItem.type === 'steedos-field-group'){
258
- let groupName = bodyItem.title;
259
- _.each(bodyItem.body, (field)=>{
260
- if(_.startsWith(field.type, 'sfield-')){
261
-
262
- if(field.config && field.config.amis){
263
- delete field.config.amis.name
264
- delete field.config.amis.mode
265
- }
266
-
267
- fields.push(Object.assign({}, field.config, {group: groupName}));
268
- }
269
- })
270
- }else if(_.startsWith(bodyItem.type, 'sfield-')){
271
- if(bodyItem.config && bodyItem.config.amis){
272
- delete bodyItem.config.amis.name
273
- delete bodyItem.config.amis.mode
274
- }
275
- fields.push(Object.assign({}, bodyItem.config, {group: '通用'}));
276
- }
277
- })
278
-
279
-
280
- const variables = [];
281
-
282
- _.each(_.groupBy(fields, 'group'), (v, k)=>{
283
- if(k=== '通用'){
284
- _.each(v, (field)=>{
285
- variables.push({
286
- label: field.label,
287
- value: field.name
288
- })
289
- })
290
- }else{
291
- variables.push({
292
- label: k,
293
- children: _.map(v, (field)=>{
294
- return {
295
- label: field.label,
296
- value: field.name
297
- }
298
- })
299
- })
300
- }
301
- })
302
- window._objectFieldsVariables = variables;
303
- },
304
- onDndAccept: function(event){
305
- return true;
306
- },
307
- beforeDelete: function(event){
308
- const toastConfig = {
309
- "closeButton": true,
310
- "debug": false,
311
- "newestOnTop": false,
312
- "progressBar": false,
313
- "positionClass": "toast-top-center",
314
- "preventDuplicates": false,
315
- "onclick": null,
316
- "showDuration": "300",
317
- "hideDuration": "1000",
318
- "timeOut": "5000",
319
- "extendedTimeOut": "1000",
320
- "showEasing": "swing",
321
- "hideEasing": "linear",
322
- "showMethod": "fadeIn",
323
- "hideMethod": "fadeOut"
324
- }
325
- if(event.context.schema.type.startsWith('sfield') && event.context.schema.config.is_system){
326
- parent.toastr.warning('禁止删除系统字段', '', toastConfig)
327
- return event.preventDefault();
328
- };
329
-
330
- if(event.context.schema.type.startsWith('sfield') && event.context.schema.config.name === 'name'){
331
- parent.toastr.warning('禁止删除名称字段', '', toastConfig)
332
- return event.preventDefault();
333
- }
334
- },
335
- onInit: function(){
336
- // 创建一个新的 style 元素
337
- var style = document.createElement('style');
338
- style.type="text/css";
339
- style.media="screen";
340
- // 将 CSS 样式写入 style 元素
341
- style.innerHTML = `
342
- .ae-RendererList-groupWrap .ae-RendererList-group:nth-child(n+3) {
343
- display: none;
344
- }
345
- .ae-RendererList-groupWrap .ae-RendererList-head:nth-child(n+2) {
346
- display: none !important;
347
- }
348
- .ae-RendererList-tabs-header .antd-Tabs-link:nth-child(n+2) {
349
- display: none !important;
350
- }
351
- .ae-RendererList-groupWrap .ae-RendererList-group.collapse-content .ae-RendererList-item:hover .ae-RendererIcon{
352
- display: none !important;
353
- }
354
- `;
355
-
356
- // 将 style 元素插入到 head 中
357
- document.head.appendChild(style);
358
- },
359
- disableBultinPlugin: false,
360
- disablePluginList2: function(id, plugin){
361
- if(lodash.includes([
362
- "FlexPlugin",
363
- "GridPlugin",
364
- "ContainerPlugin",
365
- "Layout_free_container",
366
- "Layout_fixed_top",
367
- "Layout_fixed",
368
- "CollapseGroupPlugin",
369
- "PanelPlugin",
370
- "TabsPlugin",
371
- "SwitchContainerPlugin",
372
- "CRUDPlugin",
373
- "Table2Plugin",
374
- "TableCRUDPlugin",
375
- "FormPlugin",
376
- "ServicePlugin",
377
- // "TextControlPlugin",
378
- // "TextareaControlPlugin",
379
- // "NumberControlPlugin",
380
- // "SelectControlPlugin",
381
- // "NestedSelectControlPlugin",
382
- // "ChainedSelectControlPlugin",
383
- // "DropDownButtonPlugin",
384
- // "CheckboxesControlPlugin",
385
- // "RadiosControlPlugin",
386
- // "CheckboxControlPlugin",
387
- // "DateControlPlugin",
388
- // "DateRangeControlPlugin",
389
- // "FileControlPlugin",
390
- // "ImageControlPlugin",
391
- // "ExcelControlPlugin",
392
- // "TreeControlPlugin",
393
- // "TagControlPlugin",
394
- // "ListControlPlugin",
395
- // "ButtonGroupControlPlugin",
396
- // "ButtonToolbarControlPlugin",
397
- // "PickerControlPlugin",
398
- // "SwitchControlPlugin",
399
- // "RangeControlPlugin",
400
- // "RateControlPlugin",
401
- // "CityControlPlugin",
402
- // "TransferPlugin",
403
- // "TabsTransferPlugin",
404
- // "ColorControlPlugin",
405
- // "ConditionBilderPlugin",
406
- // "FieldSetControlPlugin",
407
- // "ComboControlPlugin",
408
- // "InputGroupControlPlugin",
409
- // "TableControlPlugin",
410
- // "MatrixControlPlugin",
411
- // "RichTextControlPlugin",
412
- // "DiffEditorControlPlugin",
413
- // "CodeEditorControlPlugin",
414
- // "SearchBoxPlugin",
415
- // "KVControlPlugin",
416
- // "RepeatControlPlugin",
417
- // "UUIDControlPlugin",
418
- // "LocationControlPlugin",
419
- // "SubFormControlPlugin",
420
- // "HiddenControlPlugin",
421
- // "SignaturePlugin",
422
- // "StaticControlPlugin",
423
- "ButtonPlugin",
424
- "ButtonGroupPlugin",
425
- "NavPlugin",
426
- "AnchorNavPlugin",
427
- "TooltipWrapperPlugin",
428
- "AlertPlugin",
429
- "WizardPlugin",
430
- "TableViewPlugin",
431
- "WebComponentPlugin",
432
- "AudioPlugin",
433
- "VideoPlugin",
434
- "CustomPlugin",
435
- "TasksPlugin",
436
- "EachPlugin",
437
- "PropertyPlugin",
438
- "IFramePlugin",
439
- "QRCodePlugin",
440
- "TplPlugin",
441
- "IconPlugin",
442
- "LinkPlugin",
443
- "ListPlugin",
444
- "List2Plugin",
445
- "MappingPlugin",
446
- "AvatarPlugin",
447
- "CardPlugin",
448
- "Card2Plugin",
449
- "CardsPlugin",
450
- "TablePlugin",
451
- "TableCell2Plugin",
452
- "ChartPlugin",
453
- "SparklinePlugin",
454
- "CarouselPlugin",
455
- "ImagePlugin",
456
- "ImagesPlugin",
457
- "DatePlugin",
458
- "TimePlugin",
459
- "DatetimePlugin",
460
- "CalendarPlugin",
461
- "TagPlugin",
462
- "JsonPlugin",
463
- "ProgressPlugin",
464
- "StatusPlugin",
465
- "StepsPlugin",
466
- "TimelinePlugin",
467
- // "DividerPlugin",
468
- // "CodeViewPlugin",
469
- // "MarkdownPlugin",
470
- // "CollapsePlugin",
471
- "OfficeViewerPlugin",
472
- "PdfViewerPlugin",
473
- "LogPlugin",
474
- "ActionPlugin",
475
- "TableCellPlugin",
476
- "ArrayControlPlugin",
477
- "ControlPlugin",
478
- "DateTimeControlPlugin",
479
- "DateTimeRangeControlPlugin",
480
- "EmailControlPlugin",
481
- "FormulaControlPlugin",
482
- "GroupControlPlugin",
483
- "ItemPlugin",
484
- "MonthControlPlugin",
485
- "MonthRangeControlPlugin",
486
- "PasswordControlPlugin",
487
- "InputQuarterPlugin",
488
- "QuarterRangePlugin",
489
- "TimeControlPlugin",
490
- "TimeRangeControlPlugin",
491
- "TreeSelectControlPlugin",
492
- "URLControlPlugin",
493
- "YearControlPlugin",
494
- "YearRangeControlPlugin",
495
- "BreadcrumbPlugin",
496
- "CustomRegionPlugin",
497
- "DialogPlugin",
498
- "DrawerPlugin",
499
- "HBoxPlugin",
500
- "ListItemPlugin",
501
- "OperationPlugin",
502
- // "PagePlugin",
503
- "PaginationPlugin",
504
- "PlainPlugin",
505
- "ResetPlugin",
506
- "SubmitPlugin",
507
- "WrapperPlugin",
508
- "ColumnToggler"
509
- ]
510
- ,id)){
511
- return true;
512
- }
513
- return false
514
- }
515
- }, (key, value) => {
516
- if (typeof value === 'function') {
517
- return value.toString();
518
- }
519
- return value;
520
- })} )
521
- }
522
- if (data.type === 'builder.loadContent') {
523
- loadPage().then((content)=>{
524
- comp.messageFrame('builder.contentChanged', { AmisSchema : content } )
525
- })
526
- }
527
- if (data.type === 'builder.saveContent') {
528
- savePage(data.data).then(()=>{
529
- comp.messageFrame('builder.contentSaved')
530
- })
531
- }
532
- }
533
- })
534
- comp.settings = settings;
535
- </script>
536
- </body>
537
- </html>
@@ -1,76 +0,0 @@
1
- /*
2
- * @Author: baozhoutao@steedos.com
3
- * @Date: 2022-04-04 16:34:28
4
- * @Description:
5
- */
6
- const express = require('express');
7
- const router = express.Router();
8
- const auth = require('@steedos/auth');
9
- const ejs = require('ejs');
10
- const fs = require('fs');
11
- const _ = require('lodash');
12
- const path = require('path');
13
- const objectql = require('@steedos/objectql');
14
-
15
- const getPublicAssetUrls = function(assetUrls){
16
- const values = _.map(_.split(assetUrls), (item)=>{
17
- if(_.startsWith(item, '/')){
18
- return Meteor.absoluteUrl(item) ;
19
- }else{
20
- return item;
21
- }
22
- })
23
- return _.join(values, ',')
24
- }
25
-
26
- router.get('/api/amisObjectFieldsDesign', auth.requireAuthentication, async function (req, res) {
27
- try {
28
- res.set('Content-Type', 'text/html');
29
- const userSession = req.user;
30
- let assetUrls = getPublicAssetUrls(req.query.assetUrls);
31
- const assetUrl = `assetUrl=${assetUrls.split(',').join("&assetUrl=")}&`;
32
-
33
- // const dataContext = {
34
- // rootUrl: process.env.ROOT_URL,
35
- // tenantId: userSession.spaceId,
36
- // userId: userSession.userId,
37
- // authToken: userSession.authToken
38
- // }
39
- let locale = "zh-CN";
40
- if (req.query.locale == "en-us") {
41
- locale = "en-US";
42
- } else if (req.query.locale == "zh-cn") {
43
- locale = "zh-CN";
44
- }
45
- const retUrl = req.query.retUrl || process.env.ROOT_URL + '/app/admin/objects/view/' + req.query.oid
46
- const steedosBuilderUrl = process.env.STEEDOS_BUILDER_URL || 'https://builder.steedos.cn';
47
- const builderHost = `${steedosBuilderUrl}/object?${assetUrl}retUrl=${retUrl}&locale=${locale}&isObjectDesign=1&pType=objectDesign`;
48
-
49
- const filename = __dirname+'/object_fields_design.ejs'
50
- const data = {
51
- builderHost,
52
- assetUrls,
53
- rootUrl: process.env.ROOT_URL,
54
- tenantId: userSession.spaceId,
55
- userId: userSession.userId,
56
- authToken: userSession.authToken,
57
- userSession: userSession,
58
- id: req.query.oid,
59
- useOpenAPI: process.env.STEEDOS_PUBLIC_USE_OPEN_API
60
- }
61
- const options = {}
62
- ejs.renderFile(filename, data, options, function(err, str){
63
- if(err){
64
- console.log(`err`, err)
65
- }
66
- // str => Rendered HTML string
67
- res.send(str);
68
- });
69
-
70
- } catch (error) {
71
- console.log(error)
72
- res.status(500).send({ message: error.message });
73
- }
74
-
75
- });
76
- exports.default = router;