@nocobase/plugin-ui-schema-storage 0.14.0-alpha.7 → 0.14.0-alpha.8

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.
@@ -1,11 +1,11 @@
1
1
  module.exports = {
2
- "@nocobase/client": "0.14.0-alpha.7",
3
- "@nocobase/database": "0.14.0-alpha.7",
4
- "@nocobase/cache": "0.14.0-alpha.7",
5
- "@nocobase/utils": "0.14.0-alpha.7",
2
+ "@nocobase/client": "0.14.0-alpha.8",
3
+ "@nocobase/database": "0.14.0-alpha.8",
4
+ "@nocobase/cache": "0.14.0-alpha.8",
5
+ "@nocobase/utils": "0.14.0-alpha.8",
6
6
  "lodash": "4.17.21",
7
- "@nocobase/server": "0.14.0-alpha.7",
8
- "@nocobase/actions": "0.14.0-alpha.7",
9
- "@nocobase/resourcer": "0.14.0-alpha.7",
7
+ "@nocobase/server": "0.14.0-alpha.8",
8
+ "@nocobase/actions": "0.14.0-alpha.8",
9
+ "@nocobase/resourcer": "0.14.0-alpha.8",
10
10
  "@formily/json-schema": "2.2.27"
11
11
  };
@@ -0,0 +1,4 @@
1
+ import { Migration } from '@nocobase/server';
2
+ export default class extends Migration {
3
+ up(): Promise<void>;
4
+ }
@@ -0,0 +1,44 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var support_filter_blocks_in_select_record_drawer_exports = {};
19
+ __export(support_filter_blocks_in_select_record_drawer_exports, {
20
+ default: () => support_filter_blocks_in_select_record_drawer_default
21
+ });
22
+ module.exports = __toCommonJS(support_filter_blocks_in_select_record_drawer_exports);
23
+ var import_server = require("@nocobase/server");
24
+ class support_filter_blocks_in_select_record_drawer_default extends import_server.Migration {
25
+ async up() {
26
+ const result = await this.app.version.satisfies("<=0.14.0-alpha.7");
27
+ if (!result) {
28
+ return;
29
+ }
30
+ const r = this.db.getRepository("uiSchemas");
31
+ const items = await r.find({
32
+ filter: {
33
+ "schema.x-designer": "TableSelectorDesigner"
34
+ }
35
+ });
36
+ await this.db.sequelize.transaction(async (transaction) => {
37
+ for (const item of items) {
38
+ const schema = item.schema;
39
+ schema["x-component"] = "CardItem";
40
+ await item.save({ transaction });
41
+ }
42
+ });
43
+ }
44
+ }
@@ -78,6 +78,8 @@ export declare class UiSchemaRepository extends Repository {
78
78
  protected insertBeforeBegin(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
79
79
  protected insertAfterEnd(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
80
80
  protected insertNodes(nodes: SchemaNode[], options?: Transactionable): Promise<any[]>;
81
+ private regenerateUid;
82
+ duplicate(uid: string, options?: Transactionable): Promise<any>;
81
83
  insert(schema: any, options?: Transactionable): Promise<any>;
82
84
  insertNewSchema(schema: any, options?: Transactionable & {
83
85
  returnNode?: boolean;
@@ -586,6 +586,17 @@ const _UiSchemaRepository = class _UiSchemaRepository extends import_database.Re
586
586
  }
587
587
  return insertedNodes;
588
588
  }
589
+ regenerateUid(s) {
590
+ s["x-uid"] = (0, import_utils.uid)();
591
+ Object.keys(s.properties || {}).forEach((key) => {
592
+ this.regenerateUid(s.properties[key]);
593
+ });
594
+ }
595
+ async duplicate(uid2, options) {
596
+ const s = await this.getJsonSchema(uid2, { ...options, includeAsyncNode: true });
597
+ this.regenerateUid(s);
598
+ return this.insert(s, options);
599
+ }
589
600
  async insert(schema, options) {
590
601
  const nodes = _UiSchemaRepository.schemaToSingleNodes(schema);
591
602
  const insertedNodes = await this.insertNodes(nodes, options);
@@ -926,6 +937,9 @@ __decorateClass([
926
937
  __decorateClass([
927
938
  transaction()
928
939
  ], _UiSchemaRepository.prototype, "insertNodes", 1);
940
+ __decorateClass([
941
+ transaction()
942
+ ], _UiSchemaRepository.prototype, "duplicate", 1);
929
943
  __decorateClass([
930
944
  transaction()
931
945
  ], _UiSchemaRepository.prototype, "insert", 1);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "UI schema 存储服务",
5
5
  "description": "Provides centralized UI schema storage service",
6
6
  "description.zh-CN": "提供中心化的 UI schema 存储服务",
7
- "version": "0.14.0-alpha.7",
7
+ "version": "0.14.0-alpha.8",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "devDependencies": {
@@ -22,5 +22,5 @@
22
22
  "@nocobase/test": "0.x",
23
23
  "@nocobase/utils": "0.x"
24
24
  },
25
- "gitHead": "dc958417d27ed0753439bcef192be91a03dfc30f"
25
+ "gitHead": "59c82fef6e34707802b5841f5ec4d9b3b6b68abb"
26
26
  }