@nocobase/data-source-manager 0.20.0-alpha.8 → 0.21.0-alpha.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.
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import { ACL } from '@nocobase/acl';
3
+ import EventEmitter from 'events';
3
4
  import { ResourceManager } from './resource-manager';
4
5
  import { ICollectionManager } from './types';
5
- import EventEmitter from 'events';
6
6
  export type DataSourceOptions = any;
7
7
  export declare abstract class DataSource extends EventEmitter {
8
8
  protected options: DataSourceOptions;
@@ -33,10 +33,10 @@ __export(data_source_exports, {
33
33
  module.exports = __toCommonJS(data_source_exports);
34
34
  var import_acl = require("@nocobase/acl");
35
35
  var import_resourcer = require("@nocobase/resourcer");
36
+ var import_events = __toESM(require("events"));
36
37
  var import_koa_compose = __toESM(require("koa-compose"));
37
- var import_resource_manager = require("./resource-manager");
38
38
  var import_load_default_actions = require("./load-default-actions");
39
- var import_events = __toESM(require("events"));
39
+ var import_resource_manager = require("./resource-manager");
40
40
  const _DataSource = class _DataSource extends import_events.default {
41
41
  constructor(options) {
42
42
  super();
@@ -55,7 +55,7 @@ const _DataSource = class _DataSource extends import_events.default {
55
55
  init(options = {}) {
56
56
  this.acl = this.createACL();
57
57
  this.resourceManager = this.createResourceManager({
58
- prefix: "/api",
58
+ prefix: process.env.API_BASE_PATH,
59
59
  ...options.resourceManager
60
60
  });
61
61
  this.collectionManager = this.createCollectionManager(options);
package/lib/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export * from './sequelize-data-source';
7
7
  export * from './load-default-actions';
8
8
  export * from './types';
9
9
  export * from './data-source-with-database';
10
+ export * from './utils';
package/lib/index.js CHANGED
@@ -23,6 +23,7 @@ __reExport(src_exports, require("./sequelize-data-source"), module.exports);
23
23
  __reExport(src_exports, require("./load-default-actions"), module.exports);
24
24
  __reExport(src_exports, require("./types"), module.exports);
25
25
  __reExport(src_exports, require("./data-source-with-database"), module.exports);
26
+ __reExport(src_exports, require("./utils"), module.exports);
26
27
  // Annotate the CommonJS export names for ESM import in node:
27
28
  0 && (module.exports = {
28
29
  ...require("./collection-manager"),
@@ -33,5 +34,6 @@ __reExport(src_exports, require("./data-source-with-database"), module.exports);
33
34
  ...require("./sequelize-data-source"),
34
35
  ...require("./load-default-actions"),
35
36
  ...require("./types"),
36
- ...require("./data-source-with-database")
37
+ ...require("./data-source-with-database"),
38
+ ...require("./utils")
37
39
  });
package/lib/utils.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function parseCollectionName(collection: string): string[];
2
+ export declare function joinCollectionName(dataSourceName: string, collectionName: string): string;
package/lib/utils.js ADDED
@@ -0,0 +1,46 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var utils_exports = {};
20
+ __export(utils_exports, {
21
+ joinCollectionName: () => joinCollectionName,
22
+ parseCollectionName: () => parseCollectionName
23
+ });
24
+ module.exports = __toCommonJS(utils_exports);
25
+ function parseCollectionName(collection) {
26
+ if (!collection) {
27
+ return [];
28
+ }
29
+ const dataSourceCollection = collection.split(":");
30
+ const collectionName = dataSourceCollection.pop();
31
+ const dataSourceName = dataSourceCollection[0] ?? "main";
32
+ return [dataSourceName, collectionName];
33
+ }
34
+ __name(parseCollectionName, "parseCollectionName");
35
+ function joinCollectionName(dataSourceName, collectionName) {
36
+ if (!dataSourceName || dataSourceName === "main") {
37
+ return collectionName;
38
+ }
39
+ return `${dataSourceName}:${collectionName}`;
40
+ }
41
+ __name(joinCollectionName, "joinCollectionName");
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ joinCollectionName,
45
+ parseCollectionName
46
+ });
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@nocobase/data-source-manager",
3
- "version": "0.20.0-alpha.8",
3
+ "version": "0.21.0-alpha.1",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./lib/index.js",
7
7
  "types": "./lib/index.d.ts",
8
8
  "dependencies": {
9
- "@nocobase/actions": "0.20.0-alpha.8",
10
- "@nocobase/cache": "0.20.0-alpha.8",
11
- "@nocobase/database": "0.20.0-alpha.8",
12
- "@nocobase/resourcer": "0.20.0-alpha.8",
13
- "@nocobase/utils": "0.20.0-alpha.8",
9
+ "@nocobase/actions": "0.21.0-alpha.1",
10
+ "@nocobase/cache": "0.21.0-alpha.1",
11
+ "@nocobase/database": "0.21.0-alpha.1",
12
+ "@nocobase/resourcer": "0.21.0-alpha.1",
13
+ "@nocobase/utils": "0.21.0-alpha.1",
14
14
  "@types/jsonwebtoken": "^8.5.8",
15
15
  "jsonwebtoken": "^8.5.1"
16
16
  },
@@ -19,5 +19,5 @@
19
19
  "url": "git+https://github.com/nocobase/nocobase.git",
20
20
  "directory": "packages/auth"
21
21
  },
22
- "gitHead": "39ebc1cefe5a826aecf0b14d73530dfa5f9c2b1c"
22
+ "gitHead": "afd2f3d1341b85ea9daa7b2667dd4ace1fafb7ff"
23
23
  }