@nocobase/plugin-field-sort 1.5.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.
Files changed (142) hide show
  1. package/LICENSE.txt +159 -0
  2. package/README.md +1 -0
  3. package/client.d.ts +2 -0
  4. package/client.js +1 -0
  5. package/dist/client/index.d.ts +15 -0
  6. package/dist/client/index.js +10 -0
  7. package/dist/client/locale.d.ts +10 -0
  8. package/dist/client/sort-interface.d.ts +131 -0
  9. package/dist/externalVersion.js +18 -0
  10. package/dist/index.d.ts +10 -0
  11. package/dist/index.js +48 -0
  12. package/dist/locale/en-US.json +1 -0
  13. package/dist/locale/zh-CN.json +1 -0
  14. package/dist/node_modules/@nocobase/lock-manager/LICENSE +661 -0
  15. package/dist/node_modules/@nocobase/lock-manager/lib/index.d.ts +10 -0
  16. package/dist/node_modules/@nocobase/lock-manager/lib/index.js +1 -0
  17. package/dist/node_modules/@nocobase/lock-manager/lib/lock-manager.d.ts +46 -0
  18. package/dist/node_modules/@nocobase/lock-manager/lib/lock-manager.js +171 -0
  19. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/client.js +12 -0
  20. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/assign.d.ts +17 -0
  21. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/assign.js +143 -0
  22. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/client.d.ts +30 -0
  23. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/client.js +88 -0
  24. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/collections-graph.d.ts +24 -0
  25. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/collections-graph.js +107 -0
  26. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/common.d.ts +14 -0
  27. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/common.js +87 -0
  28. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/date.d.ts +38 -0
  29. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/date.js +214 -0
  30. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/dayjs.d.ts +10 -0
  31. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/dayjs.js +72 -0
  32. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/forEach.d.ts +9 -0
  33. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/forEach.js +45 -0
  34. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/fs-exists.d.ts +9 -0
  35. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/fs-exists.js +46 -0
  36. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/getValuesByPath.d.ts +9 -0
  37. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/getValuesByPath.js +71 -0
  38. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/handlebars.d.ts +10 -0
  39. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/handlebars.js +73 -0
  40. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/i18n.d.ts +10 -0
  41. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/i18n.js +43 -0
  42. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/index.d.ts +38 -0
  43. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/index.js +105 -0
  44. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/isPortalInBody.d.ts +13 -0
  45. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/isPortalInBody.js +54 -0
  46. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/isValidFilter.d.ts +9 -0
  47. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/isValidFilter.js +63 -0
  48. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/json-templates.d.ts +9 -0
  49. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/json-templates.js +141 -0
  50. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/koa-multer.d.ts +15 -0
  51. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/koa-multer.js +92 -0
  52. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/log.d.ts +9 -0
  53. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/log.js +39 -0
  54. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/measure-execution-time.d.ts +9 -0
  55. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/measure-execution-time.js +44 -0
  56. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/merge.d.ts +9 -0
  57. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/merge.js +55 -0
  58. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/mixin/AsyncEmitter.d.ts +11 -0
  59. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/mixin/AsyncEmitter.js +80 -0
  60. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/mixin/index.d.ts +9 -0
  61. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/mixin/index.js +48 -0
  62. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/notification.d.ts +9 -0
  63. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/notification.js +43 -0
  64. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/number.d.ts +9 -0
  65. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/number.js +45 -0
  66. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parse-date.d.ts +15 -0
  67. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parse-date.js +262 -0
  68. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parse-filter.d.ts +67 -0
  69. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parse-filter.js +320 -0
  70. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parseHTML.d.ts +15 -0
  71. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/parseHTML.js +42 -0
  72. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/perf-hooks.d.ts +14 -0
  73. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/perf-hooks.js +69 -0
  74. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/registry.d.ts +22 -0
  75. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/registry.js +69 -0
  76. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/requireModule.d.ts +12 -0
  77. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/requireModule.js +90 -0
  78. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/server.d.ts +19 -0
  79. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/server.js +50 -0
  80. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/toposort.d.ts +18 -0
  81. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/toposort.js +83 -0
  82. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/uid.d.ts +9 -0
  83. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/uid.js +44 -0
  84. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/url.d.ts +14 -0
  85. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/url.js +46 -0
  86. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/wrap-middleware.d.ts +1 -0
  87. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/lib/wrap-middleware.js +63 -0
  88. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/package.json +20 -0
  89. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/plugin-symlink.d.ts +6 -0
  90. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/plugin-symlink.js +102 -0
  91. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/server.d.ts +2 -0
  92. package/dist/node_modules/@nocobase/lock-manager/node_modules/@nocobase/utils/server.js +12 -0
  93. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/.eslintrc.js +5 -0
  94. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/.github/workflows/ci.yml +24 -0
  95. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/.github/workflows/lint.yml +23 -0
  96. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-multipart-fields-100mb-big.js +149 -0
  97. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-multipart-fields-100mb-small.js +143 -0
  98. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-multipart-files-100mb-big.js +154 -0
  99. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-multipart-files-100mb-small.js +148 -0
  100. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-urlencoded-fields-100pairs-small.js +101 -0
  101. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/bench/bench-urlencoded-fields-900pairs-small-alt.js +84 -0
  102. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/lib/index.js +57 -0
  103. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/lib/types/multipart.js +653 -0
  104. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/lib/types/urlencoded.js +350 -0
  105. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/lib/utils.js +596 -0
  106. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/package.json +22 -0
  107. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/common.js +109 -0
  108. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test-types-multipart-charsets.js +94 -0
  109. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test-types-multipart-stream-pause.js +102 -0
  110. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test-types-multipart.js +1053 -0
  111. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test-types-urlencoded.js +488 -0
  112. package/dist/node_modules/@nocobase/lock-manager/node_modules/busboy/test/test.js +20 -0
  113. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/index.js +104 -0
  114. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/counter.js +28 -0
  115. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/file-appender.js +67 -0
  116. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/make-middleware.js +173 -0
  117. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/multer-error.js +24 -0
  118. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/lib/remove-uploaded-files.js +28 -0
  119. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/package.json +52 -0
  120. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/storage/disk.js +66 -0
  121. package/dist/node_modules/@nocobase/lock-manager/node_modules/multer/storage/memory.js +21 -0
  122. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/.eslintrc.js +5 -0
  123. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/.github/workflows/ci.yml +24 -0
  124. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/.github/workflows/lint.yml +23 -0
  125. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/lib/sbmh.js +267 -0
  126. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/package.json +34 -0
  127. package/dist/node_modules/@nocobase/lock-manager/node_modules/streamsearch/test/test.js +70 -0
  128. package/dist/node_modules/@nocobase/lock-manager/package.json +1 -0
  129. package/dist/node_modules/@nocobase/lock-manager/src/__tests__/lock-manager.test.ts +169 -0
  130. package/dist/node_modules/@nocobase/lock-manager/src/index.ts +11 -0
  131. package/dist/node_modules/@nocobase/lock-manager/src/lock-manager.ts +169 -0
  132. package/dist/server/action.d.ts +26 -0
  133. package/dist/server/action.js +168 -0
  134. package/dist/server/index.d.ts +10 -0
  135. package/dist/server/index.js +48 -0
  136. package/dist/server/plugin.d.ts +19 -0
  137. package/dist/server/plugin.js +69 -0
  138. package/dist/server/sort-field.d.ts +24 -0
  139. package/dist/server/sort-field.js +197 -0
  140. package/package.json +16 -0
  141. package/server.d.ts +2 -0
  142. package/server.js +1 -0
@@ -0,0 +1,63 @@
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 __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
15
+ var __export = (target, all) => {
16
+ for (var name in all)
17
+ __defProp(target, name, { get: all[name], enumerable: true });
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var wrap_middleware_exports = {};
29
+ __export(wrap_middleware_exports, {
30
+ wrapMiddlewareWithLogging: () => wrapMiddlewareWithLogging
31
+ });
32
+ module.exports = __toCommonJS(wrap_middleware_exports);
33
+ function wrapMiddlewareWithLogging(fn, logger) {
34
+ if (process.env["LOGGER_LEVEL"] !== "trace") {
35
+ return fn;
36
+ }
37
+ const name = fn.name || fn.toString().slice(0, 100);
38
+ return async (ctx, next) => {
39
+ const reqId = ctx.reqId;
40
+ if (!logger && !ctx.logger) {
41
+ return await fn(ctx, next);
42
+ }
43
+ if (!logger && ctx.logger) {
44
+ logger = ctx.logger;
45
+ }
46
+ logger.trace(`--> Entering middleware: ${name}`, { reqId });
47
+ const start = Date.now();
48
+ await fn(ctx, async () => {
49
+ const beforeNext = Date.now();
50
+ logger.trace(`--> Before next middleware: ${name} - ${beforeNext - start}ms`, { reqId });
51
+ await next();
52
+ const afterNext = Date.now();
53
+ logger.trace(`<-- After next middleware: ${name} - ${afterNext - beforeNext}ms`, { reqId });
54
+ });
55
+ const ms = Date.now() - start;
56
+ logger.trace(`<-- Exiting middleware: ${name} - ${ms}ms`, { reqId });
57
+ };
58
+ }
59
+ __name(wrapMiddlewareWithLogging, "wrapMiddlewareWithLogging");
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ wrapMiddlewareWithLogging
63
+ });
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@nocobase/utils",
3
+ "version": "1.4.0-alpha.11",
4
+ "main": "lib/index.js",
5
+ "types": "./lib/index.d.ts",
6
+ "license": "AGPL-3.0",
7
+ "dependencies": {
8
+ "@budibase/handlebars-helpers": "^0.14.0",
9
+ "@hapi/topo": "^6.0.0",
10
+ "@rc-component/mini-decimal": "^1.1.0",
11
+ "dayjs": "^1.11.9",
12
+ "deepmerge": "^4.2.2",
13
+ "flat-to-nested": "^1.1.1",
14
+ "graphlib": "^2.1.8",
15
+ "handlebars": "^4.7.8",
16
+ "multer": "^1.4.5-lts.1",
17
+ "object-path": "^0.11.8"
18
+ },
19
+ "gitHead": "621ac1788ae0622813b98c2f82f5f524067a792c"
20
+ }
@@ -0,0 +1,6 @@
1
+ export declare function getStoragePluginNames(target: any): Promise<any[]>;
2
+ export declare function fsExists(path: any): Promise<boolean>;
3
+ export declare function createStoragePluginSymLink(pluginName: any): Promise<void>;
4
+ export declare function createStoragePluginsSymlink(): Promise<void>;
5
+ export declare function createDevPluginSymLink(pluginName: any): Promise<void>;
6
+ export declare function createDevPluginsSymlink(): Promise<void>;
@@ -0,0 +1,102 @@
1
+ const { dirname, resolve } = require('path');
2
+ const { realpath, readFile, writeFile, readdir, symlink, unlink, mkdir, stat } = require('fs').promises;
3
+
4
+ async function getStoragePluginNames(target) {
5
+ const plugins = [];
6
+ const items = await readdir(target);
7
+ for (const item of items) {
8
+ if (item.startsWith('@')) {
9
+ const children = await getStoragePluginNames(resolve(target, item));
10
+ plugins.push(
11
+ ...children.map((child) => {
12
+ return `${item}/${child}`;
13
+ }),
14
+ );
15
+ } else if (await fsExists(resolve(target, item, 'package.json'))) {
16
+ plugins.push(item);
17
+ }
18
+ }
19
+ return plugins;
20
+ }
21
+
22
+ async function fsExists(path) {
23
+ try {
24
+ await stat(path);
25
+ return true;
26
+ } catch (error) {
27
+ return false;
28
+ }
29
+ }
30
+
31
+ exports.fsExists = fsExists;
32
+
33
+ async function createStoragePluginSymLink(pluginName) {
34
+ const storagePluginsPath = resolve(process.cwd(), 'storage/plugins');
35
+ const nodeModulesPath = process.env.NODE_MODULES_PATH; // resolve(dirname(require.resolve('@nocobase/server/package.json')), 'node_modules');
36
+ // const nodeModulesPath = resolve(process.cwd(), 'node_modules');
37
+ try {
38
+ if (pluginName.startsWith('@')) {
39
+ const [orgName] = pluginName.split('/');
40
+ if (!(await fsExists(resolve(nodeModulesPath, orgName)))) {
41
+ await mkdir(resolve(nodeModulesPath, orgName), { recursive: true });
42
+ }
43
+ }
44
+ const link = resolve(nodeModulesPath, pluginName);
45
+ if (await fsExists(link)) {
46
+ await unlink(link);
47
+ }
48
+ await symlink(resolve(storagePluginsPath, pluginName), link, 'dir');
49
+ } catch (error) {
50
+ console.error(error);
51
+ }
52
+ }
53
+
54
+ exports.createStoragePluginSymLink = createStoragePluginSymLink;
55
+
56
+ async function createStoragePluginsSymlink() {
57
+ const storagePluginsPath = resolve(process.cwd(), 'storage/plugins');
58
+ if (!(await fsExists(storagePluginsPath))) {
59
+ return;
60
+ }
61
+ const pluginNames = await getStoragePluginNames(storagePluginsPath);
62
+ await Promise.all(pluginNames.map((pluginName) => createStoragePluginSymLink(pluginName)));
63
+ }
64
+
65
+ exports.createStoragePluginsSymlink = createStoragePluginsSymlink;
66
+
67
+ async function createDevPluginSymLink(pluginName) {
68
+ const packagePluginsPath = resolve(process.cwd(), 'packages/plugins');
69
+ const nodeModulesPath = process.env.NODE_MODULES_PATH; // resolve(dirname(require.resolve('@nocobase/server/package.json')), 'node_modules');
70
+ try {
71
+ if (pluginName.startsWith('@')) {
72
+ const [orgName] = pluginName.split('/');
73
+ if (!(await fsExists(resolve(nodeModulesPath, orgName)))) {
74
+ await mkdir(resolve(nodeModulesPath, orgName), { recursive: true });
75
+ }
76
+ }
77
+ const link = resolve(nodeModulesPath, pluginName);
78
+ if (await fsExists(link)) {
79
+ const real = await realpath(link);
80
+ if (real === resolve(packagePluginsPath, pluginName)) {
81
+ return;
82
+ }
83
+ await unlink(link);
84
+ }
85
+ await symlink(resolve(packagePluginsPath, pluginName), link, 'dir');
86
+ } catch (error) {
87
+ console.error(error);
88
+ }
89
+ }
90
+
91
+ exports.createDevPluginSymLink = createDevPluginSymLink;
92
+
93
+ async function createDevPluginsSymlink() {
94
+ const storagePluginsPath = resolve(process.cwd(), 'packages/plugins');
95
+ if (!(await fsExists(storagePluginsPath))) {
96
+ return;
97
+ }
98
+ const pluginNames = await getStoragePluginNames(storagePluginsPath);
99
+ await Promise.all(pluginNames.map((pluginName) => createDevPluginSymLink(pluginName)));
100
+ }
101
+
102
+ exports.createDevPluginsSymlink = createDevPluginsSymlink;
@@ -0,0 +1,2 @@
1
+ // @ts-nocheck
2
+ export * from './lib/server';
@@ -0,0 +1,12 @@
1
+ var _useExportServer = require("./lib/server");
2
+
3
+ Object.keys(_useExportServer).forEach(function (key) {
4
+ if (key === "default" || key === "__esModule") return;
5
+ if (key in exports && exports[key] === _useExportServer[key]) return;
6
+ Object.defineProperty(exports, key, {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _useExportServer[key];
10
+ }
11
+ });
12
+ });
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ extends: '@mscdex/eslint-config',
5
+ };
@@ -0,0 +1,24 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [ master ]
7
+
8
+ jobs:
9
+ tests-linux:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ node-version: [10.16.0, 10.x, 12.x, 14.x, 16.x]
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Use Node.js ${{ matrix.node-version }}
18
+ uses: actions/setup-node@v1
19
+ with:
20
+ node-version: ${{ matrix.node-version }}
21
+ - name: Install module
22
+ run: npm install
23
+ - name: Run tests
24
+ run: npm test
@@ -0,0 +1,23 @@
1
+ name: lint
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [ master ]
7
+
8
+ env:
9
+ NODE_VERSION: 16.x
10
+
11
+ jobs:
12
+ lint-js:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Use Node.js ${{ env.NODE_VERSION }}
17
+ uses: actions/setup-node@v1
18
+ with:
19
+ node-version: ${{ env.NODE_VERSION }}
20
+ - name: Install ESLint + ESLint configs/plugins
21
+ run: npm install --only=dev
22
+ - name: Lint files
23
+ run: npm run lint
@@ -0,0 +1,149 @@
1
+ 'use strict';
2
+
3
+ function createMultipartBuffers(boundary, sizes) {
4
+ const bufs = [];
5
+ for (let i = 0; i < sizes.length; ++i) {
6
+ const mb = sizes[i] * 1024 * 1024;
7
+ bufs.push(Buffer.from([
8
+ `--${boundary}`,
9
+ `content-disposition: form-data; name="field${i + 1}"`,
10
+ '',
11
+ '0'.repeat(mb),
12
+ '',
13
+ ].join('\r\n')));
14
+ }
15
+ bufs.push(Buffer.from([
16
+ `--${boundary}--`,
17
+ '',
18
+ ].join('\r\n')));
19
+ return bufs;
20
+ }
21
+
22
+ const boundary = '-----------------------------168072824752491622650073';
23
+ const buffers = createMultipartBuffers(boundary, [
24
+ 10,
25
+ 10,
26
+ 10,
27
+ 20,
28
+ 50,
29
+ ]);
30
+ const calls = {
31
+ partBegin: 0,
32
+ headerField: 0,
33
+ headerValue: 0,
34
+ headerEnd: 0,
35
+ headersEnd: 0,
36
+ partData: 0,
37
+ partEnd: 0,
38
+ end: 0,
39
+ };
40
+
41
+ const moduleName = process.argv[2];
42
+ switch (moduleName) {
43
+ case 'busboy': {
44
+ const busboy = require('busboy');
45
+
46
+ const parser = busboy({
47
+ limits: {
48
+ fieldSizeLimit: Infinity,
49
+ },
50
+ headers: {
51
+ 'content-type': `multipart/form-data; boundary=${boundary}`,
52
+ },
53
+ });
54
+ parser.on('field', (name, val, info) => {
55
+ ++calls.partBegin;
56
+ ++calls.partData;
57
+ ++calls.partEnd;
58
+ }).on('close', () => {
59
+ ++calls.end;
60
+ console.timeEnd(moduleName);
61
+ });
62
+
63
+ console.time(moduleName);
64
+ for (const buf of buffers)
65
+ parser.write(buf);
66
+ break;
67
+ }
68
+
69
+ case 'formidable': {
70
+ const { MultipartParser } = require('formidable');
71
+
72
+ const parser = new MultipartParser();
73
+ parser.initWithBoundary(boundary);
74
+ parser.on('data', ({ name }) => {
75
+ ++calls[name];
76
+ if (name === 'end')
77
+ console.timeEnd(moduleName);
78
+ });
79
+
80
+ console.time(moduleName);
81
+ for (const buf of buffers)
82
+ parser.write(buf);
83
+
84
+ break;
85
+ }
86
+
87
+ case 'multiparty': {
88
+ const { Readable } = require('stream');
89
+
90
+ const { Form } = require('multiparty');
91
+
92
+ const form = new Form({
93
+ maxFieldsSize: Infinity,
94
+ maxFields: Infinity,
95
+ maxFilesSize: Infinity,
96
+ autoFields: false,
97
+ autoFiles: false,
98
+ });
99
+
100
+ const req = new Readable({ read: () => {} });
101
+ req.headers = {
102
+ 'content-type': `multipart/form-data; boundary=${boundary}`,
103
+ };
104
+
105
+ function hijack(name, fn) {
106
+ const oldFn = form[name];
107
+ form[name] = function() {
108
+ fn();
109
+ return oldFn.apply(this, arguments);
110
+ };
111
+ }
112
+
113
+ hijack('onParseHeaderField', () => {
114
+ ++calls.headerField;
115
+ });
116
+ hijack('onParseHeaderValue', () => {
117
+ ++calls.headerValue;
118
+ });
119
+ hijack('onParsePartBegin', () => {
120
+ ++calls.partBegin;
121
+ });
122
+ hijack('onParsePartData', () => {
123
+ ++calls.partData;
124
+ });
125
+ hijack('onParsePartEnd', () => {
126
+ ++calls.partEnd;
127
+ });
128
+
129
+ form.on('close', () => {
130
+ ++calls.end;
131
+ console.timeEnd(moduleName);
132
+ }).on('part', (p) => p.resume());
133
+
134
+ console.time(moduleName);
135
+ form.parse(req);
136
+ for (const buf of buffers)
137
+ req.push(buf);
138
+ req.push(null);
139
+
140
+ break;
141
+ }
142
+
143
+ default:
144
+ if (moduleName === undefined)
145
+ console.error('Missing parser module name');
146
+ else
147
+ console.error(`Invalid parser module name: ${moduleName}`);
148
+ process.exit(1);
149
+ }
@@ -0,0 +1,143 @@
1
+ 'use strict';
2
+
3
+ function createMultipartBuffers(boundary, sizes) {
4
+ const bufs = [];
5
+ for (let i = 0; i < sizes.length; ++i) {
6
+ const mb = sizes[i] * 1024 * 1024;
7
+ bufs.push(Buffer.from([
8
+ `--${boundary}`,
9
+ `content-disposition: form-data; name="field${i + 1}"`,
10
+ '',
11
+ '0'.repeat(mb),
12
+ '',
13
+ ].join('\r\n')));
14
+ }
15
+ bufs.push(Buffer.from([
16
+ `--${boundary}--`,
17
+ '',
18
+ ].join('\r\n')));
19
+ return bufs;
20
+ }
21
+
22
+ const boundary = '-----------------------------168072824752491622650073';
23
+ const buffers = createMultipartBuffers(boundary, (new Array(100)).fill(1));
24
+ const calls = {
25
+ partBegin: 0,
26
+ headerField: 0,
27
+ headerValue: 0,
28
+ headerEnd: 0,
29
+ headersEnd: 0,
30
+ partData: 0,
31
+ partEnd: 0,
32
+ end: 0,
33
+ };
34
+
35
+ const moduleName = process.argv[2];
36
+ switch (moduleName) {
37
+ case 'busboy': {
38
+ const busboy = require('busboy');
39
+
40
+ const parser = busboy({
41
+ limits: {
42
+ fieldSizeLimit: Infinity,
43
+ },
44
+ headers: {
45
+ 'content-type': `multipart/form-data; boundary=${boundary}`,
46
+ },
47
+ });
48
+ parser.on('field', (name, val, info) => {
49
+ ++calls.partBegin;
50
+ ++calls.partData;
51
+ ++calls.partEnd;
52
+ }).on('close', () => {
53
+ ++calls.end;
54
+ console.timeEnd(moduleName);
55
+ });
56
+
57
+ console.time(moduleName);
58
+ for (const buf of buffers)
59
+ parser.write(buf);
60
+ break;
61
+ }
62
+
63
+ case 'formidable': {
64
+ const { MultipartParser } = require('formidable');
65
+
66
+ const parser = new MultipartParser();
67
+ parser.initWithBoundary(boundary);
68
+ parser.on('data', ({ name }) => {
69
+ ++calls[name];
70
+ if (name === 'end')
71
+ console.timeEnd(moduleName);
72
+ });
73
+
74
+ console.time(moduleName);
75
+ for (const buf of buffers)
76
+ parser.write(buf);
77
+
78
+ break;
79
+ }
80
+
81
+ case 'multiparty': {
82
+ const { Readable } = require('stream');
83
+
84
+ const { Form } = require('multiparty');
85
+
86
+ const form = new Form({
87
+ maxFieldsSize: Infinity,
88
+ maxFields: Infinity,
89
+ maxFilesSize: Infinity,
90
+ autoFields: false,
91
+ autoFiles: false,
92
+ });
93
+
94
+ const req = new Readable({ read: () => {} });
95
+ req.headers = {
96
+ 'content-type': `multipart/form-data; boundary=${boundary}`,
97
+ };
98
+
99
+ function hijack(name, fn) {
100
+ const oldFn = form[name];
101
+ form[name] = function() {
102
+ fn();
103
+ return oldFn.apply(this, arguments);
104
+ };
105
+ }
106
+
107
+ hijack('onParseHeaderField', () => {
108
+ ++calls.headerField;
109
+ });
110
+ hijack('onParseHeaderValue', () => {
111
+ ++calls.headerValue;
112
+ });
113
+ hijack('onParsePartBegin', () => {
114
+ ++calls.partBegin;
115
+ });
116
+ hijack('onParsePartData', () => {
117
+ ++calls.partData;
118
+ });
119
+ hijack('onParsePartEnd', () => {
120
+ ++calls.partEnd;
121
+ });
122
+
123
+ form.on('close', () => {
124
+ ++calls.end;
125
+ console.timeEnd(moduleName);
126
+ }).on('part', (p) => p.resume());
127
+
128
+ console.time(moduleName);
129
+ form.parse(req);
130
+ for (const buf of buffers)
131
+ req.push(buf);
132
+ req.push(null);
133
+
134
+ break;
135
+ }
136
+
137
+ default:
138
+ if (moduleName === undefined)
139
+ console.error('Missing parser module name');
140
+ else
141
+ console.error(`Invalid parser module name: ${moduleName}`);
142
+ process.exit(1);
143
+ }