@nocobase/sdk 0.11.0-alpha.1 → 0.11.1-alpha.2

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.
package/es/APIClient.d.ts CHANGED
@@ -24,6 +24,7 @@ export declare class Auth {
24
24
  role: string;
25
25
  token: string;
26
26
  authenticator: string;
27
+ theme: string;
27
28
  };
28
29
  protected options: {
29
30
  locale: any;
package/es/APIClient.js CHANGED
@@ -11,6 +11,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
11
11
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
12
12
  import axios from 'axios';
13
13
  import qs from 'qs';
14
+ import getSubAppName from './getSubAppName';
14
15
  export class Auth {
15
16
  constructor(api) {
16
17
  this.api = void 0;
@@ -18,7 +19,8 @@ export class Auth {
18
19
  locale: 'NOCOBASE_LOCALE',
19
20
  role: 'NOCOBASE_ROLE',
20
21
  token: 'NOCOBASE_TOKEN',
21
- authenticator: 'NOCOBASE_AUTH'
22
+ authenticator: 'NOCOBASE_AUTH',
23
+ theme: 'NOCOBASE_THEME'
22
24
  };
23
25
  this.options = {
24
26
  locale: null,
@@ -34,11 +36,10 @@ export class Auth {
34
36
  if (!window) {
35
37
  return;
36
38
  }
37
- const match = window.location.pathname.match(/^\/apps\/([^/]*)\//);
38
- if (!match) {
39
+ const appName = getSubAppName();
40
+ if (!appName) {
39
41
  return;
40
42
  }
41
- const appName = match[1];
42
43
  this.KEYS['role'] = `${appName.toUpperCase()}_` + this.KEYS['role'];
43
44
  this.KEYS['locale'] = `${appName.toUpperCase()}_` + this.KEYS['locale'];
44
45
  }
@@ -0,0 +1,2 @@
1
+ declare const getSubAppName: () => string;
2
+ export default getSubAppName;
@@ -0,0 +1,8 @@
1
+ const getSubAppName = () => {
2
+ const match = window.location.pathname.match(/^\/apps\/([^/]*)\//);
3
+ if (!match) {
4
+ return '';
5
+ }
6
+ return match[1].toUpperCase();
7
+ };
8
+ export default getSubAppName;
package/es/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './APIClient';
2
+ export { default as getSubAppName } from './getSubAppName';
package/es/index.js CHANGED
@@ -1 +1,2 @@
1
- export * from './APIClient';
1
+ export * from './APIClient';
2
+ export { default as getSubAppName } from './getSubAppName';
@@ -24,6 +24,7 @@ export declare class Auth {
24
24
  role: string;
25
25
  token: string;
26
26
  authenticator: string;
27
+ theme: string;
27
28
  };
28
29
  protected options: {
29
30
  locale: any;
package/lib/APIClient.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.Storage = exports.MemoryStorage = exports.Auth = exports.APIClient = void 0;
7
7
  var _axios = _interopRequireDefault(require("axios"));
8
8
  var _qs = _interopRequireDefault(require("qs"));
9
+ var _getSubAppName = _interopRequireDefault(require("./getSubAppName"));
9
10
  const _excluded = ["authClass", "storageClass"],
10
11
  _excluded2 = ["values", "filter"];
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -25,7 +26,8 @@ class Auth {
25
26
  locale: 'NOCOBASE_LOCALE',
26
27
  role: 'NOCOBASE_ROLE',
27
28
  token: 'NOCOBASE_TOKEN',
28
- authenticator: 'NOCOBASE_AUTH'
29
+ authenticator: 'NOCOBASE_AUTH',
30
+ theme: 'NOCOBASE_THEME'
29
31
  };
30
32
  this.options = {
31
33
  locale: null,
@@ -41,11 +43,10 @@ class Auth {
41
43
  if (!window) {
42
44
  return;
43
45
  }
44
- const match = window.location.pathname.match(/^\/apps\/([^/]*)\//);
45
- if (!match) {
46
+ const appName = (0, _getSubAppName.default)();
47
+ if (!appName) {
46
48
  return;
47
49
  }
48
- const appName = match[1];
49
50
  this.KEYS['role'] = `${appName.toUpperCase()}_` + this.KEYS['role'];
50
51
  this.KEYS['locale'] = `${appName.toUpperCase()}_` + this.KEYS['locale'];
51
52
  }
@@ -0,0 +1,2 @@
1
+ declare const getSubAppName: () => string;
2
+ export default getSubAppName;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const getSubAppName = () => {
8
+ const match = window.location.pathname.match(/^\/apps\/([^/]*)\//);
9
+ if (!match) {
10
+ return '';
11
+ }
12
+ return match[1].toUpperCase();
13
+ };
14
+ var _default = getSubAppName;
15
+ exports.default = _default;
package/lib/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './APIClient';
2
+ export { default as getSubAppName } from './getSubAppName';
package/lib/index.js CHANGED
@@ -3,9 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _exportNames = {
7
+ getSubAppName: true
8
+ };
9
+ Object.defineProperty(exports, "getSubAppName", {
10
+ enumerable: true,
11
+ get: function get() {
12
+ return _getSubAppName.default;
13
+ }
14
+ });
6
15
  var _APIClient = require("./APIClient");
7
16
  Object.keys(_APIClient).forEach(function (key) {
8
17
  if (key === "default" || key === "__esModule") return;
18
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
9
19
  if (key in exports && exports[key] === _APIClient[key]) return;
10
20
  Object.defineProperty(exports, key, {
11
21
  enumerable: true,
@@ -13,4 +23,6 @@ Object.keys(_APIClient).forEach(function (key) {
13
23
  return _APIClient[key];
14
24
  }
15
25
  });
16
- });
26
+ });
27
+ var _getSubAppName = _interopRequireDefault(require("./getSubAppName"));
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/sdk",
3
- "version": "0.11.0-alpha.1",
3
+ "version": "0.11.1-alpha.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib",
6
6
  "module": "es/index.js",
@@ -12,5 +12,5 @@
12
12
  "devDependencies": {
13
13
  "axios-mock-adapter": "^1.20.0"
14
14
  },
15
- "gitHead": "7581b6d3a3a54f09f06a9effb7e3e65328281b2b"
15
+ "gitHead": "8482aa720ea1c3abbbb9fe1208e73778bd63f1cf"
16
16
  }
package/src/APIClient.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
2
2
  import qs from 'qs';
3
+ import getSubAppName from './getSubAppName';
3
4
 
4
5
  export interface ActionParams {
5
6
  filterByTk?: any;
@@ -30,6 +31,7 @@ export class Auth {
30
31
  role: 'NOCOBASE_ROLE',
31
32
  token: 'NOCOBASE_TOKEN',
32
33
  authenticator: 'NOCOBASE_AUTH',
34
+ theme: 'NOCOBASE_THEME',
33
35
  };
34
36
 
35
37
  protected options = {
@@ -49,11 +51,10 @@ export class Auth {
49
51
  if (!window) {
50
52
  return;
51
53
  }
52
- const match = window.location.pathname.match(/^\/apps\/([^/]*)\//);
53
- if (!match) {
54
+ const appName = getSubAppName();
55
+ if (!appName) {
54
56
  return;
55
57
  }
56
- const appName = match[1];
57
58
  this.KEYS['role'] = `${appName.toUpperCase()}_` + this.KEYS['role'];
58
59
  this.KEYS['locale'] = `${appName.toUpperCase()}_` + this.KEYS['locale'];
59
60
  }
@@ -0,0 +1,9 @@
1
+ const getSubAppName = () => {
2
+ const match = window.location.pathname.match(/^\/apps\/([^/]*)\//);
3
+ if (!match) {
4
+ return '';
5
+ }
6
+ return match[1].toUpperCase();
7
+ };
8
+
9
+ export default getSubAppName;
package/src/index.ts CHANGED
@@ -1 +1,3 @@
1
1
  export * from './APIClient';
2
+ export { default as getSubAppName } from './getSubAppName';
3
+