@steedos/service-package-registry 3.0.0-beta.30 → 3.0.0-beta.33

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.
@@ -71,6 +71,7 @@ const getAllPackages = async ()=>{
71
71
  _package.instance_id = packageInfo.instanceID
72
72
  _package.version = packageInfo.version
73
73
  _package.homepage = packageInfo.homepage
74
+ _package.isUnmanaged = packageInfo.isUnmanaged
74
75
  }else{
75
76
  packages.push({
76
77
  label: packageInfo.label || packageName,
@@ -84,7 +85,8 @@ const getAllPackages = async ()=>{
84
85
  instance_id: packageInfo.instanceID,
85
86
  status : 'enable',
86
87
  version : packageInfo.version,
87
- local: false
88
+ local: false,
89
+ isUnmanaged: packageInfo.isUnmanaged
88
90
  })
89
91
  }
90
92
  })
@@ -282,10 +282,17 @@ async function yarnAddPackage(yarnPackage){
282
282
  paths: [path.join(installDir, 'node_modules')]
283
283
  }))
284
284
  if(fs.existsSync(path.join(packagePath, 'package.service.js'))){
285
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, no-undef
286
+ const schema = require(path.join(packagePath, 'package.service.js'));
287
+ schema.settings.packageInfo = {
288
+ ...schema.settings.packageInfo,
289
+ ...(schema.metadata && schema.metadata.$package ? schema.metadata.$package : {}),
290
+ }
285
291
  steedosPackages.push({
286
292
  name: parsed.name,
287
293
  version: parsed.rawSpec,
288
- path: packagePath
294
+ path: packagePath,
295
+ isUnmanaged: schema.settings.packageInfo.isUnmanaged
289
296
  })
290
297
  }
291
298
  })
@@ -40,6 +40,9 @@ module.exports = {
40
40
  return false;
41
41
  }
42
42
  const record = data?.record || {};
43
+ if(record.isUnmanaged){
44
+ return false
45
+ }
43
46
  if (record.status === 'enable') {
44
47
  return true;
45
48
  }
@@ -41,6 +41,9 @@ module.exports = {
41
41
  return false;
42
42
  }
43
43
  const record = data?.record || {};
44
+ if(record.isUnmanaged){
45
+ return false
46
+ }
44
47
  if(record.status !== 'enable'){
45
48
  return true;
46
49
  }
@@ -23,6 +23,9 @@ module.exports = {
23
23
  return false;
24
24
  }
25
25
  const record = data?.record;
26
+ if(record.isUnmanaged){
27
+ return false
28
+ }
26
29
  if(record.status === 'enable'){
27
30
  return true;
28
31
  }
@@ -1,38 +1,41 @@
1
1
  module.exports = {
2
2
  uninstall: function (object_name, record_id) {
3
-
4
-
5
3
  Steedos.sobject(object_name).retrieve(record_id).then((record)=>{
6
4
  if(!record){
7
5
  return SteedosUI.notification.error({message: '未找到软件包'})
8
6
  }
9
- console.log('record.....',record)
10
7
 
11
8
  SteedosUI.Modal.confirm({
12
- title: t('steedos_packages.uninstall.title'),
13
- content: t('steedos_packages.uninstall.text') + ` ${record.name}`,
9
+ title: t('steedos_packages.uninstall.text') + ` ${record.name} 吗?` ,
10
+ content: `卸载后,该软件包中的所有组件将被永久删除且无法恢复`,
14
11
  okText: t('steedos_packages.uninstall.title'),
15
12
  cancelText: t('Cancel'),
13
+ width: 480,
16
14
  onOk: function(){
17
- Steedos.authRequest(Steedos.absoluteUrl('/api/nodes/uninstall'), {type: 'post', async: false, data: JSON.stringify({
18
- module: record.name,
19
- nodeID: window.$("#steedos_package_main_node").val()
20
- }),
21
- success: function(data){
22
- if(data.status == 1){
23
- SteedosUI.notification.error({message: data.msg});
24
- return;
15
+ return new Promise((resolve, reject) => {
16
+ Steedos.authRequest(Steedos.absoluteUrl('/api/nodes/uninstall'), {type: 'post', async: false, data: JSON.stringify({
17
+ module: record.name,
18
+ nodeID: window.$("#steedos_package_main_node").val()
19
+ }),
20
+ success: function(data){
21
+ if(data.status == 1){
22
+ SteedosUI.notification.error({message: data.msg});
23
+ resolve(data);
24
+ return;
25
+ }
26
+ setTimeout(function(){
27
+ SteedosUI.notification.success({
28
+ message: t('steedos_packages.uninstall.toastr_success')
29
+ });
30
+ resolve(data);
31
+ navigate("/app/admin/steedos_packages")
32
+ }, 1000 * 2)
33
+ },
34
+ error: function(XMLHttpRequest){
35
+ SteedosUI.notification.error({message: XMLHttpRequest.responseJSON.msg});
36
+ reject()
25
37
  }
26
- setTimeout(function(){
27
- SteedosUI.notification.success({
28
- message: t('steedos_packages.uninstall.toastr_success')
29
- });
30
- navigate("/app/admin/steedos_packages")
31
- }, 1000 * 2)
32
- },
33
- error: function(XMLHttpRequest){
34
- SteedosUI.notification.error({message: XMLHttpRequest.responseJSON.msg});
35
- }
38
+ })
36
39
  })
37
40
  }
38
41
  });
@@ -11,6 +11,9 @@ module.exports = {
11
11
  return false;
12
12
  }
13
13
  const record = data?.record;
14
+ if(record.isUnmanaged){
15
+ return false
16
+ }
14
17
  if (record.status === 'enable' && !record.local && !record.static) {
15
18
  return true;
16
19
  }
@@ -0,0 +1,4 @@
1
+ name: isUnmanaged
2
+ type: boolean
3
+ label: 模板
4
+ visible_on: "{{false}}"
@@ -9,6 +9,7 @@ columns:
9
9
  - field: status
10
10
  - field: static
11
11
  - field: icon
12
+ - field: isUnmanaged
12
13
  filter_scope: space
13
14
  label: 所有软件包
14
15
  scrolling_mode: standard
@@ -75,35 +75,6 @@
75
75
  ],
76
76
  "className": "p-0",
77
77
  "id": "u:5d4e7e3f6ecc"
78
- },
79
- {
80
- "title": "依赖服务",
81
- "body": [
82
- {
83
- "type": "steedos-object-form",
84
- "label": "对象表单",
85
- "objectApiName": "${objectName}",
86
- "recordId": "${recordId}",
87
- "appId": "${appId}",
88
- "id": "u:fec578db3278",
89
- "mode": "read",
90
- "className": "mb-4",
91
- "fields": [
92
- "dependencies"
93
- ],
94
- "fieldsExtend": {
95
- "dependencies": {
96
- "label": false,
97
- "amis": {
98
- "type": "tpl",
99
- "tpl": "${dependencies | join: }"
100
- }
101
- }
102
- }
103
- }
104
- ],
105
- "className": "p-0",
106
- "id": "u:5d4e7e3f6ecc"
107
78
  }
108
79
  ],
109
80
  "id": "u:148cf8e840eb"
@@ -32,7 +32,7 @@
32
32
  "actions": [
33
33
  {
34
34
  "label": "${uiSchema.actions.enable.label}",
35
- "disabledOn": "${status === 'enable' || window:Steedos.settings.public.enable_saas}",
35
+ "disabledOn": "${status === 'enable' || window:Steedos.settings.public.enable_saas || isUnmanaged === true}",
36
36
  "className": "mr-4",
37
37
  "onEvent": {
38
38
  "click": {
@@ -48,7 +48,7 @@
48
48
  },
49
49
  {
50
50
  "label": "${uiSchema.actions.disable.label}",
51
- "disabledOn": "${status !== 'enable' || window:Steedos.settings.public.enable_saas}",
51
+ "disabledOn": "${status !== 'enable' || window:Steedos.settings.public.enable_saas || isUnmanaged === true}",
52
52
  "onEvent": {
53
53
  "click": {
54
54
  "actions": [
@@ -50,7 +50,10 @@ router.post('/api/nodes/uninstall', disabledChangePackageWithSaas, auth.requireA
50
50
  const result = await broker.call(`@steedos/service-project.uninstallPackage`, {
51
51
  module
52
52
  },{
53
- nodeID: nodeID
53
+ nodeID: nodeID,
54
+ meta: {
55
+ user: userSession
56
+ }
54
57
  })
55
58
  res.status(200).send(result); //TODO 完善返回信息
56
59
  } catch (error) {
@@ -18,13 +18,9 @@ module.exports = {
18
18
  const { spaceId } = this;
19
19
  let dataList = await packages.getAllPackages();
20
20
  if (!_.isEmpty(dataList)) {
21
- const cloneValues = clone(this.data.values, false);
21
+ const cloneValues = [];
22
22
  dataList.forEach((doc) => {
23
- if (!_.find(this.data.values, (value) => {
24
- return value.name === doc.name
25
- })) {
26
- cloneValues.push(doc);
27
- }
23
+ cloneValues.push(doc)
28
24
  })
29
25
  const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId);
30
26
  if (records.length > 0) {
@@ -42,12 +38,10 @@ module.exports = {
42
38
  this.data.values = result.length;
43
39
  },
44
40
  afterFindOne: async function(){
45
- if(_.isEmpty(this.data.values)){
46
- const all = await packages.getAllPackages();
47
- const id = this.id;
48
- this.data.values = _.find(all, function(item){
49
- return item._id === id
50
- });
51
- }
41
+ const all = await packages.getAllPackages();
42
+ const id = this.id;
43
+ this.data.values = _.find(all, function(item){
44
+ return item._id === id
45
+ });
52
46
  }
53
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-package-registry",
3
- "version": "3.0.0-beta.30",
3
+ "version": "3.0.0-beta.33",
4
4
  "description": "",
5
5
  "main": "package.service.js",
6
6
  "scripts": {
@@ -9,10 +9,10 @@
9
9
  "author": "",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
- "@steedos/auth": "3.0.0-beta.30",
13
- "@steedos/metadata-core": "3.0.0-beta.30",
14
- "@steedos/objectql": "3.0.0-beta.30",
15
- "@steedos/service-package-loader": "3.0.0-beta.30",
12
+ "@steedos/auth": "3.0.0-beta.33",
13
+ "@steedos/metadata-core": "3.0.0-beta.33",
14
+ "@steedos/objectql": "3.0.0-beta.33",
15
+ "@steedos/service-package-loader": "3.0.0-beta.33",
16
16
  "clone": "^2.1.2",
17
17
  "fs-extra": "8.1.0",
18
18
  "i18next": "20.3.2",
@@ -31,5 +31,5 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "179adc36b9bc560bad5673f0a068600f5af4848f"
34
+ "gitHead": "240a409b40d5e5e25cf2451b63e611ba7b8e4533"
35
35
  }
@@ -76,6 +76,11 @@ module.exports = {
76
76
  uninstallPackage:{
77
77
  async handler(ctx) {
78
78
  const { module } = ctx.params
79
+ const packages = loader.loadPackagesConfig();
80
+ let packageConfig = _.find(packages, (_p, pname) => {
81
+ _p.name = pname;
82
+ return pname === module;
83
+ })
79
84
  await loader.removePackage(module);
80
85
  await registry.uninstallModule(module)
81
86
  await ctx.broker.call(`@steedos/service-packages.uninstall`, {
@@ -85,6 +90,17 @@ module.exports = {
85
90
  instanceID: ctx.broker.instanceID,
86
91
  }
87
92
  })
93
+ if(packageConfig.isUnmanaged){
94
+ await ctx.broker.call(`~packages-@steedos/metadata-api.remove`, {
95
+ name: module
96
+ }, {
97
+ timeout: 0,
98
+ meta: {
99
+ user: ctx.meta.user
100
+ }
101
+ })
102
+ }
103
+
88
104
  return {};
89
105
  }
90
106
  },
@@ -557,7 +573,8 @@ module.exports = {
557
573
  description: _packageInfo.description,
558
574
  metadata: metadata,
559
575
  static: _packageInfo.static,
560
- homepage: _packageInfo.homepage
576
+ homepage: _packageInfo.homepage,
577
+ isUnmanaged: _packageInfo.isUnmanaged
561
578
  }
562
579
  })
563
580
  }
@@ -569,24 +586,34 @@ module.exports = {
569
586
  const packages = await registry.yarnAddPackage(yarnPackage);
570
587
  for (const packageInfo of packages) {
571
588
  const packagePath = packageInfo.path;
589
+ let enable = false;
590
+ if(packageInfo.isUnmanaged){
591
+ enable = true;
592
+ }
572
593
  loader.appendToPackagesConfig(packageInfo.name, {
573
594
  version: packageInfo.version,
574
595
  path: util.getPackageRelativePath(process.cwd(), packagePath),
575
- enable: false
596
+ enable: enable,
597
+ isUnmanaged: packageInfo.isUnmanaged || false
576
598
  });
599
+ if(enable){
600
+ await this.broker.call('@steedos/service-project.enablePackage', {module: packageInfo.name})
601
+ }
602
+
577
603
  const metadata = await loader.getPackageMetadata(util.getPackageRelativePath(process.cwd(), packagePath));
578
604
  const packageYmlData = loader.getPackageYmlData(packagePath);
579
605
  await this.broker.call(`@steedos/service-packages.install`, {
580
606
  serviceInfo: Object.assign({}, {
581
607
  version: packageInfo.version,
582
- path: packageInfo.path
608
+ path: packageInfo.path,
609
+ isUnmanaged: packageInfo.isUnmanaged || false
583
610
  }, {
584
611
  packageYmlData: packageYmlData,
585
612
  name: packageInfo.name,
586
613
  enable: false,
587
614
  nodeID: broker.nodeID,
588
615
  instanceID: broker.instanceID,
589
- metadata: metadata
616
+ metadata: metadata,
590
617
  })
591
618
  })
592
619
  }