@nocobase/plugin-collection-tree 1.3.35-beta → 1.3.37-beta

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.
@@ -8,11 +8,11 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.3.35-beta",
11
+ "@nocobase/client": "1.3.37-beta",
12
12
  "lodash": "4.17.21",
13
- "@nocobase/database": "1.3.35-beta",
14
- "@nocobase/utils": "1.3.35-beta",
15
- "@nocobase/data-source-manager": "1.3.35-beta",
16
- "@nocobase/server": "1.3.35-beta",
13
+ "@nocobase/database": "1.3.37-beta",
14
+ "@nocobase/utils": "1.3.37-beta",
15
+ "@nocobase/data-source-manager": "1.3.37-beta",
16
+ "@nocobase/server": "1.3.37-beta",
17
17
  "sequelize": "6.35.2"
18
18
  };
@@ -12,6 +12,9 @@ import { Transaction } from 'sequelize';
12
12
  export default class extends Migration {
13
13
  on: string;
14
14
  appVersion: string;
15
+ getTreeCollections({ transaction }: {
16
+ transaction: any;
17
+ }): Promise<any>;
15
18
  up(): Promise<void>;
16
19
  getTreePath(model: Model, path: string, collection: Model, pathCollectionName: string, transaction: Transaction): Promise<string>;
17
20
  }
@@ -45,15 +45,19 @@ class collection_tree_default extends import_server.Migration {
45
45
  on = "afterLoad";
46
46
  // 'beforeLoad' or 'afterLoad'
47
47
  appVersion = "<=1.3.0-beta";
48
+ async getTreeCollections({ transaction }) {
49
+ const treeCollections = await this.app.db.getRepository("collections").find({
50
+ appends: ["fields"],
51
+ filter: {
52
+ "options.tree": "adjacencyList"
53
+ },
54
+ transaction
55
+ });
56
+ return treeCollections;
57
+ }
48
58
  async up() {
49
59
  await this.db.sequelize.transaction(async (transaction) => {
50
- const treeCollections = await this.app.db.getRepository("collections").find({
51
- appends: ["fields"],
52
- filter: {
53
- "options.tree": "adjacencyList"
54
- },
55
- transaction
56
- });
60
+ const treeCollections = await this.getTreeCollections({ transaction });
57
61
  for (const treeCollection of treeCollections) {
58
62
  const name = `main_${treeCollection.name}_path`;
59
63
  const collectionOptions = {
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import Migration from './20240802141435-collection-tree';
10
+ export default class extends Migration {
11
+ on: string;
12
+ appVersion: string;
13
+ getTreeCollections({ transaction }: {
14
+ transaction: any;
15
+ }): Promise<any>;
16
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var inherit_collection_tree_exports = {};
38
+ __export(inherit_collection_tree_exports, {
39
+ default: () => inherit_collection_tree_default
40
+ });
41
+ module.exports = __toCommonJS(inherit_collection_tree_exports);
42
+ var import_collection_tree = __toESM(require("./20240802141435-collection-tree"));
43
+ class inherit_collection_tree_default extends import_collection_tree.default {
44
+ on = "afterLoad";
45
+ // 'beforeLoad' or 'afterLoad'
46
+ appVersion = "<=1.3.36-beta";
47
+ async getTreeCollections({ transaction }) {
48
+ const treeCollections = await this.app.db.getRepository("collections").find({
49
+ appends: ["fields"],
50
+ filter: {
51
+ "options.tree": "adjacencyList"
52
+ },
53
+ transaction
54
+ });
55
+ return treeCollections.filter((collection) => {
56
+ var _a;
57
+ return ((_a = collection.options.inherits) == null ? void 0 : _a.length) > 0;
58
+ });
59
+ }
60
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-collection-tree",
3
- "version": "1.3.35-beta",
3
+ "version": "1.3.37-beta",
4
4
  "displayName": "Collection: Tree",
5
5
  "displayName.zh-CN": "数据表:树",
6
6
  "description": "Provides tree collection template",
@@ -14,5 +14,5 @@
14
14
  "@nocobase/server": "1.x",
15
15
  "@nocobase/test": "1.x"
16
16
  },
17
- "gitHead": "e76f371c232ed038d8a82a39f84c74aeb788e21c"
17
+ "gitHead": "979596f6003bcc860dc9ef32d3d78a294a80944b"
18
18
  }