@nocobase/server 0.13.0-alpha.9 → 0.14.0-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.
Files changed (37) hide show
  1. package/lib/app-supervisor.js +3 -1
  2. package/lib/application.d.ts +3 -1
  3. package/lib/application.js +16 -2
  4. package/lib/commands/pm.js +28 -2
  5. package/lib/gateway/index.d.ts +1 -0
  6. package/lib/gateway/index.js +33 -10
  7. package/lib/helper.d.ts +1 -0
  8. package/lib/helper.js +11 -2
  9. package/lib/migrations/20230912193824-package-name-unique.d.ts +4 -0
  10. package/lib/migrations/20230912193824-package-name-unique.js +66 -0
  11. package/lib/plugin-manager/clientStaticUtils.d.ts +23 -0
  12. package/lib/plugin-manager/clientStaticUtils.js +119 -0
  13. package/lib/plugin-manager/constants.d.ts +7 -0
  14. package/lib/plugin-manager/constants.js +126 -0
  15. package/lib/plugin-manager/deps.d.ts +2 -0
  16. package/lib/plugin-manager/deps.js +74 -0
  17. package/lib/plugin-manager/index.d.ts +1 -1
  18. package/lib/plugin-manager/index.js +2 -2
  19. package/lib/plugin-manager/middleware.d.ts +2 -0
  20. package/lib/plugin-manager/{clientStaticMiddleware.js → middleware.js} +14 -9
  21. package/lib/plugin-manager/options/collection.js +1 -0
  22. package/lib/plugin-manager/options/resource.d.ts +5 -1
  23. package/lib/plugin-manager/options/resource.js +116 -10
  24. package/lib/plugin-manager/plugin-manager-repository.d.ts +2 -0
  25. package/lib/plugin-manager/plugin-manager-repository.js +9 -0
  26. package/lib/plugin-manager/plugin-manager.d.ts +33 -3
  27. package/lib/plugin-manager/plugin-manager.js +226 -40
  28. package/lib/plugin-manager/types.d.ts +15 -0
  29. package/lib/plugin-manager/types.js +15 -0
  30. package/lib/plugin-manager/utils.d.ts +102 -0
  31. package/lib/plugin-manager/utils.js +523 -0
  32. package/lib/plugin.d.ts +1 -0
  33. package/lib/plugin.js +37 -0
  34. package/package.json +17 -12
  35. package/lib/gateway/handle-plugin-static-file.d.ts +0 -3
  36. package/lib/gateway/handle-plugin-static-file.js +0 -85
  37. package/lib/plugin-manager/clientStaticMiddleware.d.ts +0 -8
@@ -1,85 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var handle_plugin_static_file_exports = {};
30
- __export(handle_plugin_static_file_exports, {
31
- handlePluginStaticFile: () => handlePluginStaticFile
32
- });
33
- module.exports = __toCommonJS(handle_plugin_static_file_exports);
34
- var import_path = __toESM(require("path"));
35
- var import_fs = __toESM(require("fs"));
36
- const cwd = process.cwd();
37
- const NODE_MODULES = import_path.default.join(cwd, "node_modules");
38
- const PREFIX = "/api/plugins/client/";
39
- const isMatchClientStaticUrl = /* @__PURE__ */ __name((url) => {
40
- return url.startsWith(PREFIX);
41
- }, "isMatchClientStaticUrl");
42
- const getPackageName = /* @__PURE__ */ __name((url) => {
43
- const urlArr = url.split("/");
44
- return urlArr[4].startsWith("@") ? `${urlArr[4]}/${urlArr[5]}` : urlArr[4];
45
- }, "getPackageName");
46
- const getRealPath = /* @__PURE__ */ __name((packageName, url) => {
47
- const ext = import_path.default.extname(url);
48
- const filePath = url.replace(`${PREFIX}${packageName}/`, "");
49
- if (ext.toLowerCase() === ".md") {
50
- return import_path.default.join(NODE_MODULES, packageName, filePath);
51
- } else {
52
- return import_path.default.join(NODE_MODULES, packageName, "dist", "client", filePath);
53
- }
54
- }, "getRealPath");
55
- async function handlePluginStaticFile(req, res) {
56
- if (isMatchClientStaticUrl(req.url)) {
57
- const packageName = getPackageName(req.url);
58
- const realPath = getRealPath(packageName, req.url);
59
- try {
60
- const stats = await import_fs.default.promises.stat(realPath);
61
- const ifModifiedSince = req.headers["if-modified-since"];
62
- const lastModified = stats.mtime.toUTCString();
63
- if (ifModifiedSince === lastModified) {
64
- res.statusCode = 304;
65
- return true;
66
- }
67
- const relativePath = import_path.default.relative(cwd, realPath);
68
- res.writeHead(200, {
69
- "Content-Length": stats.size
70
- });
71
- const readStream = import_fs.default.createReadStream(relativePath);
72
- readStream.pipe(res);
73
- } catch (e) {
74
- res.writeHead(404);
75
- res.end();
76
- }
77
- return true;
78
- }
79
- return false;
80
- }
81
- __name(handlePluginStaticFile, "handlePluginStaticFile");
82
- // Annotate the CommonJS export names for ESM import in node:
83
- 0 && (module.exports = {
84
- handlePluginStaticFile
85
- });
@@ -1,8 +0,0 @@
1
- /**
2
- * get plugin client static file url
3
- *
4
- * @example
5
- * @nocobase/plugin-acl, index.js => /api/plugins/client/@nocobase/plugin-acl/index.js
6
- * my-plugin, README.md => /api/plugins/client/my-plugin/README.md
7
- */
8
- export declare const getPackageClientStaticUrl: (packageName: string, filePath: string) => string;