@webexatech/plugin-collection-transfer 0.0.0-stage → 0.1.3-nocobase.2.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 (212) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/LICENSE +201 -0
  3. package/README.md +158 -3
  4. package/client-v2.d.ts +2 -0
  5. package/client-v2.js +1 -0
  6. package/client.d.ts +2 -0
  7. package/client.js +1 -0
  8. package/dist/client/949.72b7b97eaf5473f5.js +10 -0
  9. package/dist/client/SettingsPage.d.ts +3 -0
  10. package/dist/client/index.d.ts +1 -0
  11. package/dist/client/index.js +10 -0
  12. package/dist/client/plugin.d.ts +5 -0
  13. package/dist/client-v2/907.b7c707602a2b4e6c.js +10 -0
  14. package/dist/client-v2/CollectionTransferSettings.d.ts +22 -0
  15. package/dist/client-v2/SettingsPage.d.ts +4 -0
  16. package/dist/client-v2/index.d.ts +1 -0
  17. package/dist/client-v2/index.js +10 -0
  18. package/dist/client-v2/locale.d.ts +7 -0
  19. package/dist/client-v2/plugin.d.ts +7 -0
  20. package/dist/externalVersion.js +24 -0
  21. package/dist/index.d.ts +2 -0
  22. package/dist/index.js +48 -0
  23. package/dist/locale/en-US.json +70 -0
  24. package/dist/locale/zh-CN.json +70 -0
  25. package/dist/node_modules/archiver/LICENSE +22 -0
  26. package/dist/node_modules/archiver/index.js +68 -0
  27. package/dist/node_modules/archiver/lib/core.js +974 -0
  28. package/dist/node_modules/archiver/lib/error.js +40 -0
  29. package/dist/node_modules/archiver/lib/plugins/json.js +110 -0
  30. package/dist/node_modules/archiver/lib/plugins/tar.js +167 -0
  31. package/dist/node_modules/archiver/lib/plugins/zip.js +120 -0
  32. package/dist/node_modules/archiver/node_modules/async/all.js +119 -0
  33. package/dist/node_modules/archiver/node_modules/async/allLimit.js +46 -0
  34. package/dist/node_modules/archiver/node_modules/async/allSeries.js +45 -0
  35. package/dist/node_modules/archiver/node_modules/async/any.js +122 -0
  36. package/dist/node_modules/archiver/node_modules/async/anyLimit.js +47 -0
  37. package/dist/node_modules/archiver/node_modules/async/anySeries.js +46 -0
  38. package/dist/node_modules/archiver/node_modules/async/apply.js +11 -0
  39. package/dist/node_modules/archiver/node_modules/async/applyEach.js +57 -0
  40. package/dist/node_modules/archiver/node_modules/async/applyEachSeries.js +37 -0
  41. package/dist/node_modules/archiver/node_modules/async/asyncify.js +118 -0
  42. package/dist/node_modules/archiver/node_modules/async/auto.js +333 -0
  43. package/dist/node_modules/archiver/node_modules/async/autoInject.js +182 -0
  44. package/dist/node_modules/archiver/node_modules/async/bower.json +17 -0
  45. package/dist/node_modules/archiver/node_modules/async/cargo.js +63 -0
  46. package/dist/node_modules/archiver/node_modules/async/cargoQueue.js +71 -0
  47. package/dist/node_modules/archiver/node_modules/async/compose.js +55 -0
  48. package/dist/node_modules/archiver/node_modules/async/concat.js +115 -0
  49. package/dist/node_modules/archiver/node_modules/async/concatLimit.js +60 -0
  50. package/dist/node_modules/archiver/node_modules/async/concatSeries.js +41 -0
  51. package/dist/node_modules/archiver/node_modules/async/constant.js +14 -0
  52. package/dist/node_modules/archiver/node_modules/async/detect.js +96 -0
  53. package/dist/node_modules/archiver/node_modules/async/detectLimit.js +48 -0
  54. package/dist/node_modules/archiver/node_modules/async/detectSeries.js +47 -0
  55. package/dist/node_modules/archiver/node_modules/async/dir.js +43 -0
  56. package/dist/node_modules/archiver/node_modules/async/dist/async.js +6062 -0
  57. package/dist/node_modules/archiver/node_modules/async/dist/async.min.js +1 -0
  58. package/dist/node_modules/archiver/node_modules/async/doDuring.js +68 -0
  59. package/dist/node_modules/archiver/node_modules/async/doUntil.js +46 -0
  60. package/dist/node_modules/archiver/node_modules/async/doWhilst.js +68 -0
  61. package/dist/node_modules/archiver/node_modules/async/during.js +78 -0
  62. package/dist/node_modules/archiver/node_modules/async/each.js +129 -0
  63. package/dist/node_modules/archiver/node_modules/async/eachLimit.js +50 -0
  64. package/dist/node_modules/archiver/node_modules/async/eachOf.js +185 -0
  65. package/dist/node_modules/archiver/node_modules/async/eachOfLimit.js +47 -0
  66. package/dist/node_modules/archiver/node_modules/async/eachOfSeries.js +39 -0
  67. package/dist/node_modules/archiver/node_modules/async/eachSeries.js +44 -0
  68. package/dist/node_modules/archiver/node_modules/async/ensureAsync.js +67 -0
  69. package/dist/node_modules/archiver/node_modules/async/every.js +119 -0
  70. package/dist/node_modules/archiver/node_modules/async/everyLimit.js +46 -0
  71. package/dist/node_modules/archiver/node_modules/async/everySeries.js +45 -0
  72. package/dist/node_modules/archiver/node_modules/async/filter.js +93 -0
  73. package/dist/node_modules/archiver/node_modules/async/filterLimit.js +45 -0
  74. package/dist/node_modules/archiver/node_modules/async/filterSeries.js +43 -0
  75. package/dist/node_modules/archiver/node_modules/async/find.js +96 -0
  76. package/dist/node_modules/archiver/node_modules/async/findLimit.js +48 -0
  77. package/dist/node_modules/archiver/node_modules/async/findSeries.js +47 -0
  78. package/dist/node_modules/archiver/node_modules/async/flatMap.js +115 -0
  79. package/dist/node_modules/archiver/node_modules/async/flatMapLimit.js +60 -0
  80. package/dist/node_modules/archiver/node_modules/async/flatMapSeries.js +41 -0
  81. package/dist/node_modules/archiver/node_modules/async/foldl.js +153 -0
  82. package/dist/node_modules/archiver/node_modules/async/foldr.js +41 -0
  83. package/dist/node_modules/archiver/node_modules/async/forEach.js +129 -0
  84. package/dist/node_modules/archiver/node_modules/async/forEachLimit.js +50 -0
  85. package/dist/node_modules/archiver/node_modules/async/forEachOf.js +185 -0
  86. package/dist/node_modules/archiver/node_modules/async/forEachOfLimit.js +47 -0
  87. package/dist/node_modules/archiver/node_modules/async/forEachOfSeries.js +39 -0
  88. package/dist/node_modules/archiver/node_modules/async/forEachSeries.js +44 -0
  89. package/dist/node_modules/archiver/node_modules/async/forever.js +68 -0
  90. package/dist/node_modules/archiver/node_modules/async/groupBy.js +108 -0
  91. package/dist/node_modules/archiver/node_modules/async/groupByLimit.js +71 -0
  92. package/dist/node_modules/archiver/node_modules/async/groupBySeries.js +36 -0
  93. package/dist/node_modules/archiver/node_modules/async/index.js +588 -0
  94. package/dist/node_modules/archiver/node_modules/async/inject.js +153 -0
  95. package/dist/node_modules/archiver/node_modules/async/internal/DoublyLinkedList.js +92 -0
  96. package/dist/node_modules/archiver/node_modules/async/internal/Heap.js +120 -0
  97. package/dist/node_modules/archiver/node_modules/async/internal/applyEach.js +29 -0
  98. package/dist/node_modules/archiver/node_modules/async/internal/asyncEachOfLimit.js +75 -0
  99. package/dist/node_modules/archiver/node_modules/async/internal/awaitify.js +28 -0
  100. package/dist/node_modules/archiver/node_modules/async/internal/breakLoop.js +10 -0
  101. package/dist/node_modules/archiver/node_modules/async/internal/consoleFunc.js +31 -0
  102. package/dist/node_modules/archiver/node_modules/async/internal/createTester.js +40 -0
  103. package/dist/node_modules/archiver/node_modules/async/internal/eachOfLimit.js +90 -0
  104. package/dist/node_modules/archiver/node_modules/async/internal/filter.js +55 -0
  105. package/dist/node_modules/archiver/node_modules/async/internal/getIterator.js +11 -0
  106. package/dist/node_modules/archiver/node_modules/async/internal/initialParams.js +14 -0
  107. package/dist/node_modules/archiver/node_modules/async/internal/isArrayLike.js +10 -0
  108. package/dist/node_modules/archiver/node_modules/async/internal/iterator.js +57 -0
  109. package/dist/node_modules/archiver/node_modules/async/internal/map.js +30 -0
  110. package/dist/node_modules/archiver/node_modules/async/internal/once.js +17 -0
  111. package/dist/node_modules/archiver/node_modules/async/internal/onlyOnce.js +15 -0
  112. package/dist/node_modules/archiver/node_modules/async/internal/parallel.js +34 -0
  113. package/dist/node_modules/archiver/node_modules/async/internal/promiseCallback.js +23 -0
  114. package/dist/node_modules/archiver/node_modules/async/internal/queue.js +294 -0
  115. package/dist/node_modules/archiver/node_modules/async/internal/range.js +14 -0
  116. package/dist/node_modules/archiver/node_modules/async/internal/reject.js +26 -0
  117. package/dist/node_modules/archiver/node_modules/async/internal/setImmediate.js +34 -0
  118. package/dist/node_modules/archiver/node_modules/async/internal/withoutIndex.js +10 -0
  119. package/dist/node_modules/archiver/node_modules/async/internal/wrapAsync.js +34 -0
  120. package/dist/node_modules/archiver/node_modules/async/log.js +41 -0
  121. package/dist/node_modules/archiver/node_modules/async/map.js +142 -0
  122. package/dist/node_modules/archiver/node_modules/async/mapLimit.js +45 -0
  123. package/dist/node_modules/archiver/node_modules/async/mapSeries.js +44 -0
  124. package/dist/node_modules/archiver/node_modules/async/mapValues.js +152 -0
  125. package/dist/node_modules/archiver/node_modules/async/mapValuesLimit.js +61 -0
  126. package/dist/node_modules/archiver/node_modules/async/mapValuesSeries.js +37 -0
  127. package/dist/node_modules/archiver/node_modules/async/memoize.js +91 -0
  128. package/dist/node_modules/archiver/node_modules/async/nextTick.js +52 -0
  129. package/dist/node_modules/archiver/node_modules/async/package.json +75 -0
  130. package/dist/node_modules/archiver/node_modules/async/parallel.js +180 -0
  131. package/dist/node_modules/archiver/node_modules/async/parallelLimit.js +41 -0
  132. package/dist/node_modules/archiver/node_modules/async/priorityQueue.js +60 -0
  133. package/dist/node_modules/archiver/node_modules/async/queue.js +24 -0
  134. package/dist/node_modules/archiver/node_modules/async/race.js +67 -0
  135. package/dist/node_modules/archiver/node_modules/async/reduce.js +153 -0
  136. package/dist/node_modules/archiver/node_modules/async/reduceRight.js +41 -0
  137. package/dist/node_modules/archiver/node_modules/async/reflect.js +78 -0
  138. package/dist/node_modules/archiver/node_modules/async/reflectAll.js +93 -0
  139. package/dist/node_modules/archiver/node_modules/async/reject.js +87 -0
  140. package/dist/node_modules/archiver/node_modules/async/rejectLimit.js +45 -0
  141. package/dist/node_modules/archiver/node_modules/async/rejectSeries.js +43 -0
  142. package/dist/node_modules/archiver/node_modules/async/retry.js +159 -0
  143. package/dist/node_modules/archiver/node_modules/async/retryable.js +77 -0
  144. package/dist/node_modules/archiver/node_modules/async/select.js +93 -0
  145. package/dist/node_modules/archiver/node_modules/async/selectLimit.js +45 -0
  146. package/dist/node_modules/archiver/node_modules/async/selectSeries.js +43 -0
  147. package/dist/node_modules/archiver/node_modules/async/seq.js +79 -0
  148. package/dist/node_modules/archiver/node_modules/async/series.js +186 -0
  149. package/dist/node_modules/archiver/node_modules/async/setImmediate.js +45 -0
  150. package/dist/node_modules/archiver/node_modules/async/some.js +122 -0
  151. package/dist/node_modules/archiver/node_modules/async/someLimit.js +47 -0
  152. package/dist/node_modules/archiver/node_modules/async/someSeries.js +46 -0
  153. package/dist/node_modules/archiver/node_modules/async/sortBy.js +190 -0
  154. package/dist/node_modules/archiver/node_modules/async/timeout.js +89 -0
  155. package/dist/node_modules/archiver/node_modules/async/times.js +50 -0
  156. package/dist/node_modules/archiver/node_modules/async/timesLimit.js +43 -0
  157. package/dist/node_modules/archiver/node_modules/async/timesSeries.js +32 -0
  158. package/dist/node_modules/archiver/node_modules/async/transform.js +173 -0
  159. package/dist/node_modules/archiver/node_modules/async/tryEach.js +78 -0
  160. package/dist/node_modules/archiver/node_modules/async/unmemoize.js +25 -0
  161. package/dist/node_modules/archiver/node_modules/async/until.js +61 -0
  162. package/dist/node_modules/archiver/node_modules/async/waterfall.js +105 -0
  163. package/dist/node_modules/archiver/node_modules/async/whilst.js +78 -0
  164. package/dist/node_modules/archiver/node_modules/async/wrapSync.js +118 -0
  165. package/dist/node_modules/archiver/node_modules/readable-stream/errors-browser.js +127 -0
  166. package/dist/node_modules/archiver/node_modules/readable-stream/errors.js +116 -0
  167. package/dist/node_modules/archiver/node_modules/readable-stream/experimentalWarning.js +17 -0
  168. package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_duplex.js +126 -0
  169. package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_passthrough.js +37 -0
  170. package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_readable.js +1027 -0
  171. package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_transform.js +190 -0
  172. package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_writable.js +641 -0
  173. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/async_iterator.js +180 -0
  174. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/buffer_list.js +183 -0
  175. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/destroy.js +96 -0
  176. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +86 -0
  177. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
  178. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/from.js +52 -0
  179. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/pipeline.js +86 -0
  180. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/state.js +22 -0
  181. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
  182. package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
  183. package/dist/node_modules/archiver/node_modules/readable-stream/package.json +68 -0
  184. package/dist/node_modules/archiver/node_modules/readable-stream/readable-browser.js +9 -0
  185. package/dist/node_modules/archiver/node_modules/readable-stream/readable.js +16 -0
  186. package/dist/node_modules/archiver/node_modules/tar-stream/extract.js +257 -0
  187. package/dist/node_modules/archiver/node_modules/tar-stream/headers.js +295 -0
  188. package/dist/node_modules/archiver/node_modules/tar-stream/index.js +2 -0
  189. package/dist/node_modules/archiver/node_modules/tar-stream/pack.js +255 -0
  190. package/dist/node_modules/archiver/node_modules/tar-stream/package.json +58 -0
  191. package/dist/node_modules/archiver/node_modules/tar-stream/sandbox.js +11 -0
  192. package/dist/node_modules/archiver/package.json +1 -0
  193. package/dist/node_modules/yauzl/LICENSE +21 -0
  194. package/dist/node_modules/yauzl/index.js +1 -0
  195. package/dist/node_modules/yauzl/package.json +1 -0
  196. package/dist/server/exporter.d.ts +42 -0
  197. package/dist/server/exporter.js +311 -0
  198. package/dist/server/field-value-writer.d.ts +9 -0
  199. package/dist/server/field-value-writer.js +107 -0
  200. package/dist/server/importer.d.ts +138 -0
  201. package/dist/server/importer.js +842 -0
  202. package/dist/server/index.d.ts +1 -0
  203. package/dist/server/index.js +42 -0
  204. package/dist/server/package-format.d.ts +50 -0
  205. package/dist/server/package-format.js +115 -0
  206. package/dist/server/plugin.d.ts +6 -0
  207. package/dist/server/plugin.js +61 -0
  208. package/dist/server/resourcer.d.ts +16 -0
  209. package/dist/server/resourcer.js +187 -0
  210. package/package.json +54 -4
  211. package/server.d.ts +2 -0
  212. package/server.js +1 -0
@@ -0,0 +1 @@
1
+ export { default } from './plugin';
@@ -0,0 +1,42 @@
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 server_exports = {};
38
+ __export(server_exports, {
39
+ default: () => import_plugin.default
40
+ });
41
+ module.exports = __toCommonJS(server_exports);
42
+ var import_plugin = __toESM(require("./plugin"));
@@ -0,0 +1,50 @@
1
+ export declare const FORMAT_VERSION = 1;
2
+ export declare const MANIFEST_FILE = "manifest.json";
3
+ export declare const COLLECTIONS_FILE = "schema/collections.json";
4
+ export declare const ASSOCIATIONS_FILE = "schema/associations.json";
5
+ export declare const THROUGH_FILE = "schema/through.json";
6
+ export declare const ASSOCIATION_TYPES: string[];
7
+ export declare const SUPPORTED_TEMPLATES: string[];
8
+ export declare const MIRRORED_ORIGINS: string[];
9
+ export declare const COLLECTION_BOOKKEEPING_KEYS: string[];
10
+ export declare const FIELD_BOOKKEEPING_KEYS: string[];
11
+ export declare const MAX_IDENTIFIER_LENGTH = 63;
12
+ export type FieldPayload = Record<string, unknown> & {
13
+ name: string;
14
+ type: string;
15
+ interface?: string;
16
+ };
17
+ export type CollectionPayload = Record<string, unknown> & {
18
+ name: string;
19
+ title?: string;
20
+ template?: string;
21
+ fields: FieldPayload[];
22
+ };
23
+ export type AssociationPayload = FieldPayload & {
24
+ collectionName: string;
25
+ target: string;
26
+ reverseField?: FieldPayload;
27
+ };
28
+ export interface DataMeta {
29
+ name: string;
30
+ columns: string[];
31
+ count: number;
32
+ autoIncrementColumn: string | null;
33
+ }
34
+ export interface Manifest {
35
+ formatVersion: number;
36
+ pluginVersion: string;
37
+ sourceAppVersion: string;
38
+ dialect: string;
39
+ exportedAt: string;
40
+ includeData: boolean;
41
+ selected: string[];
42
+ collections: string[];
43
+ through: string[];
44
+ dependencies: string[];
45
+ plugins?: string[];
46
+ }
47
+ /** Returns the first unsafe expression found anywhere in a JSON value, or undefined. */
48
+ export declare function findUnsafeExpression(value: unknown): string | undefined;
49
+ export declare function isValidName(name: unknown): name is string;
50
+ export declare function dataDir(collectionName: string): string;
@@ -0,0 +1,115 @@
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 __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var package_format_exports = {};
28
+ __export(package_format_exports, {
29
+ ASSOCIATIONS_FILE: () => ASSOCIATIONS_FILE,
30
+ ASSOCIATION_TYPES: () => ASSOCIATION_TYPES,
31
+ COLLECTIONS_FILE: () => COLLECTIONS_FILE,
32
+ COLLECTION_BOOKKEEPING_KEYS: () => COLLECTION_BOOKKEEPING_KEYS,
33
+ FIELD_BOOKKEEPING_KEYS: () => FIELD_BOOKKEEPING_KEYS,
34
+ FORMAT_VERSION: () => FORMAT_VERSION,
35
+ MANIFEST_FILE: () => MANIFEST_FILE,
36
+ MAX_IDENTIFIER_LENGTH: () => MAX_IDENTIFIER_LENGTH,
37
+ MIRRORED_ORIGINS: () => MIRRORED_ORIGINS,
38
+ SUPPORTED_TEMPLATES: () => SUPPORTED_TEMPLATES,
39
+ THROUGH_FILE: () => THROUGH_FILE,
40
+ dataDir: () => dataDir,
41
+ findUnsafeExpression: () => findUnsafeExpression,
42
+ isValidName: () => isValidName
43
+ });
44
+ module.exports = __toCommonJS(package_format_exports);
45
+ const FORMAT_VERSION = 1;
46
+ const MANIFEST_FILE = "manifest.json";
47
+ const COLLECTIONS_FILE = "schema/collections.json";
48
+ const ASSOCIATIONS_FILE = "schema/associations.json";
49
+ const THROUGH_FILE = "schema/through.json";
50
+ const ASSOCIATION_TYPES = ["belongsTo", "hasOne", "hasMany", "belongsToMany"];
51
+ const SUPPORTED_TEMPLATES = ["general"];
52
+ const MIRRORED_ORIGINS = ["db2cm", "dbsync"];
53
+ const COLLECTION_BOOKKEEPING_KEYS = ["key", "sort", "fields", "category"];
54
+ const FIELD_BOOKKEEPING_KEYS = [
55
+ "key",
56
+ "sort",
57
+ "collectionName",
58
+ "parentKey",
59
+ "reverseKey",
60
+ "reverseField",
61
+ "children"
62
+ ];
63
+ const NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
64
+ const MAX_IDENTIFIER_LENGTH = 63;
65
+ const EXPRESSION = /\{\{[\s\S]*?\}\}/g;
66
+ const SAFE_EXPRESSION = /^\{\{\s*t\(\s*(["'])[^"'{}]*\1\s*(,\s*\{\s*ns\s*:\s*(["'])[^"'{}]*\3\s*\})?\s*\)\s*\}\}$/;
67
+ function findUnsafeExpression(value) {
68
+ if (typeof value === "string") {
69
+ if (!value.includes("{{")) return void 0;
70
+ const expressions = value.match(EXPRESSION) || [];
71
+ const unsafe = expressions.find((expression) => !SAFE_EXPRESSION.test(expression));
72
+ if (unsafe) return unsafe;
73
+ return value.replace(EXPRESSION, "").includes("{{") ? value : void 0;
74
+ }
75
+ if (Array.isArray(value)) {
76
+ for (const item of value) {
77
+ const found = findUnsafeExpression(item);
78
+ if (found) return found;
79
+ }
80
+ return void 0;
81
+ }
82
+ if (value && typeof value === "object") {
83
+ for (const item of Object.values(value)) {
84
+ const found = findUnsafeExpression(item);
85
+ if (found) return found;
86
+ }
87
+ }
88
+ return void 0;
89
+ }
90
+ function isValidName(name) {
91
+ return typeof name === "string" && NAME_PATTERN.test(name);
92
+ }
93
+ function dataDir(collectionName) {
94
+ if (!isValidName(collectionName)) {
95
+ throw new Error(`Invalid collection name: ${String(collectionName)}`);
96
+ }
97
+ return `data/${collectionName}`;
98
+ }
99
+ // Annotate the CommonJS export names for ESM import in node:
100
+ 0 && (module.exports = {
101
+ ASSOCIATIONS_FILE,
102
+ ASSOCIATION_TYPES,
103
+ COLLECTIONS_FILE,
104
+ COLLECTION_BOOKKEEPING_KEYS,
105
+ FIELD_BOOKKEEPING_KEYS,
106
+ FORMAT_VERSION,
107
+ MANIFEST_FILE,
108
+ MAX_IDENTIFIER_LENGTH,
109
+ MIRRORED_ORIGINS,
110
+ SUPPORTED_TEMPLATES,
111
+ THROUGH_FILE,
112
+ dataDir,
113
+ findUnsafeExpression,
114
+ isValidName
115
+ });
@@ -0,0 +1,6 @@
1
+ import { Plugin } from '@nocobase/server';
2
+ export declare const ACL_SNIPPET = "pm.collection-transfer";
3
+ export declare class PluginCollectionTransferServer extends Plugin {
4
+ load(): Promise<void>;
5
+ }
6
+ export default PluginCollectionTransferServer;
@@ -0,0 +1,61 @@
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 plugin_exports = {};
38
+ __export(plugin_exports, {
39
+ ACL_SNIPPET: () => ACL_SNIPPET,
40
+ PluginCollectionTransferServer: () => PluginCollectionTransferServer,
41
+ default: () => plugin_default
42
+ });
43
+ module.exports = __toCommonJS(plugin_exports);
44
+ var import_server = require("@nocobase/server");
45
+ var import_resourcer = __toESM(require("./resourcer"));
46
+ const ACL_SNIPPET = "pm.collection-transfer";
47
+ class PluginCollectionTransferServer extends import_server.Plugin {
48
+ async load() {
49
+ this.app.acl.registerSnippet({
50
+ name: ACL_SNIPPET,
51
+ actions: ["collectionTransfer:*"]
52
+ });
53
+ this.app.resourceManager.define(import_resourcer.default);
54
+ }
55
+ }
56
+ var plugin_default = PluginCollectionTransferServer;
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ ACL_SNIPPET,
60
+ PluginCollectionTransferServer
61
+ });
@@ -0,0 +1,16 @@
1
+ import { Context, Next } from '@nocobase/actions';
2
+ export declare const RESOURCE_NAME = "collectionTransfer";
3
+ declare const _default: {
4
+ name: string;
5
+ middleware: (ctx: Context, next: Next) => Promise<any>;
6
+ actions: {
7
+ listCollections(ctx: Context, next: Next): Promise<void>;
8
+ export(ctx: Context, next: Next): Promise<void>;
9
+ /** Streams a file prepared by `export` once, then deletes it. */
10
+ download(ctx: Context, next: Next): Promise<void>;
11
+ /** Multipart upload of a package; returns what would be created and any blocking problems. No writes. */
12
+ preview(ctx: Context, next: Next): Promise<void>;
13
+ import(ctx: Context, next: Next): Promise<void>;
14
+ };
15
+ };
16
+ export default _default;
@@ -0,0 +1,187 @@
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 resourcer_exports = {};
38
+ __export(resourcer_exports, {
39
+ RESOURCE_NAME: () => RESOURCE_NAME,
40
+ default: () => resourcer_default
41
+ });
42
+ module.exports = __toCommonJS(resourcer_exports);
43
+ var import_utils = require("@nocobase/utils");
44
+ var import_crypto = __toESM(require("crypto"));
45
+ var import_fs = __toESM(require("fs"));
46
+ var import_promises = __toESM(require("fs/promises"));
47
+ var import_os = __toESM(require("os"));
48
+ var import_path = __toESM(require("path"));
49
+ var import_exporter = require("./exporter");
50
+ var import_importer = require("./importer");
51
+ var import_package = __toESM(require("../../package.json"));
52
+ const RESOURCE_NAME = "collectionTransfer";
53
+ const NS = import_package.default.name;
54
+ const MAX_UPLOAD_BYTES = 200 * 1024 * 1024;
55
+ const EXPORT_TOKEN = /^[0-9a-f-]{36}$/;
56
+ const EXPORT_TTL_MS = 60 * 60 * 1e3;
57
+ function errorMessage(error) {
58
+ return error instanceof Error ? error.message : String(error);
59
+ }
60
+ function exportsDir() {
61
+ return (0, import_utils.storagePathJoin)("tmp", "collection-transfer-exports");
62
+ }
63
+ async function removeExpiredExports() {
64
+ const root = exportsDir();
65
+ const entries = await import_promises.default.readdir(root).catch(() => []);
66
+ const now = Date.now();
67
+ for (const entry of entries) {
68
+ const entryPath = import_path.default.join(root, entry);
69
+ const stat = await import_promises.default.stat(entryPath).catch(() => null);
70
+ if (stat && now - stat.mtimeMs > EXPORT_TTL_MS) {
71
+ await import_promises.default.rm(entryPath, { recursive: true, force: true });
72
+ }
73
+ }
74
+ }
75
+ var resourcer_default = {
76
+ name: RESOURCE_NAME,
77
+ middleware: async (ctx, next) => {
78
+ if (ctx.action.actionName !== "preview") {
79
+ return next();
80
+ }
81
+ const upload = (0, import_utils.koaMulter)({ dest: import_os.default.tmpdir(), limits: { fileSize: MAX_UPLOAD_BYTES } }).single("file");
82
+ return upload(ctx, next);
83
+ },
84
+ actions: {
85
+ async listCollections(ctx, next) {
86
+ ctx.body = await new import_exporter.CollectionExporter(ctx.app).listCollections();
87
+ await next();
88
+ },
89
+ async export(ctx, next) {
90
+ const { collections, includeData } = ctx.action.params.values || {};
91
+ if (!Array.isArray(collections) || !collections.length) {
92
+ ctx.throw(400, ctx.t("Select at least one collection", { ns: NS }));
93
+ }
94
+ let result;
95
+ try {
96
+ result = await new import_exporter.CollectionExporter(ctx.app).export({ collections, includeData: !!includeData });
97
+ } catch (error) {
98
+ ctx.throw(400, errorMessage(error));
99
+ }
100
+ await removeExpiredExports();
101
+ const token = import_crypto.default.randomUUID();
102
+ const dir = import_path.default.join(exportsDir(), token);
103
+ await import_promises.default.mkdir(dir, { recursive: true });
104
+ await import_promises.default.rename(result.filePath, import_path.default.join(dir, result.fileName)).catch(async () => {
105
+ await import_promises.default.copyFile(result.filePath, import_path.default.join(dir, result.fileName));
106
+ await import_promises.default.rm(result.filePath, { force: true });
107
+ });
108
+ const { plugins, ...summary } = result.manifest;
109
+ ctx.body = { token, fileName: result.fileName, manifest: summary };
110
+ await next();
111
+ },
112
+ /** Streams a file prepared by `export` once, then deletes it. */
113
+ async download(ctx, next) {
114
+ const { token } = ctx.action.params;
115
+ if (typeof token !== "string" || !EXPORT_TOKEN.test(token)) {
116
+ ctx.throw(400, "Invalid download token");
117
+ }
118
+ const dir = import_path.default.join(exportsDir(), token);
119
+ const claimed = `${dir}.sending-${import_crypto.default.randomUUID()}`;
120
+ const owned = await import_promises.default.rename(dir, claimed).then(() => true).catch(() => false);
121
+ const [fileName] = owned ? await import_promises.default.readdir(claimed).catch(() => []) : [];
122
+ if (!fileName) {
123
+ ctx.throw(404, "Export not found or already downloaded");
124
+ }
125
+ const stream = import_fs.default.createReadStream(import_path.default.join(claimed, fileName));
126
+ stream.on("close", () => {
127
+ import_promises.default.rm(claimed, { recursive: true, force: true }).catch((error) => ctx.app.log.warn(error));
128
+ });
129
+ ctx.attachment(fileName);
130
+ ctx.body = stream;
131
+ await next();
132
+ },
133
+ /** Multipart upload of a package; returns what would be created and any blocking problems. No writes. */
134
+ async preview(ctx, next) {
135
+ const file = ctx.file;
136
+ if (!file) {
137
+ ctx.throw(400, ctx.t("Upload a package file", { ns: NS }));
138
+ }
139
+ const importer = new import_importer.CollectionImporter(ctx.app);
140
+ let token;
141
+ try {
142
+ token = await importer.receive(file.path);
143
+ } catch (error) {
144
+ ctx.throw(400, errorMessage(error));
145
+ } finally {
146
+ await import_promises.default.rm(file.path, { force: true });
147
+ }
148
+ try {
149
+ ctx.body = await importer.preview(token);
150
+ } catch (error) {
151
+ await importer.discard(token);
152
+ ctx.throw(400, errorMessage(error));
153
+ }
154
+ await next();
155
+ },
156
+ async import(ctx, next) {
157
+ var _a;
158
+ const { token, resolutions: rawResolutions } = ctx.action.params.values || {};
159
+ const resolutions = {};
160
+ if (rawResolutions && typeof rawResolutions === "object" && !Array.isArray(rawResolutions)) {
161
+ for (const [name, mode] of Object.entries(rawResolutions)) {
162
+ if (import_importer.CONFLICT_MODES.includes(mode)) resolutions[name] = mode;
163
+ }
164
+ }
165
+ if (typeof token !== "string") {
166
+ ctx.throw(400, ctx.t("Upload a package file", { ns: NS }));
167
+ }
168
+ try {
169
+ const userId = ((_a = ctx.state.currentUser) == null ? void 0 : _a.id) ?? null;
170
+ ctx.body = await new import_importer.CollectionImporter(ctx.app).import(token, { userId, resolutions });
171
+ } catch (error) {
172
+ if (error instanceof import_importer.ImportBlockedError) {
173
+ ctx.status = 409;
174
+ ctx.withoutDataWrapping = true;
175
+ ctx.body = { errors: [{ message: error.message }], problems: error.problems };
176
+ return;
177
+ }
178
+ ctx.throw(400, errorMessage(error));
179
+ }
180
+ await next();
181
+ }
182
+ }
183
+ };
184
+ // Annotate the CommonJS export names for ESM import in node:
185
+ 0 && (module.exports = {
186
+ RESOURCE_NAME
187
+ });
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "@webexatech/plugin-collection-transfer",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "displayName": "Collection transfer",
4
+ "displayName.zh-CN": "数据表迁移",
5
+ "description": "Move collections between NocoBase environments: export one or more collections (schema, optionally data) to a file and import it elsewhere, with per-collection conflict handling.",
6
+ "description.zh-CN": "在 NocoBase 环境之间迁移数据表:将一个或多个数据表(结构,可选包含数据)导出为文件并导入到其他环境,支持逐表冲突处理。",
7
+ "version": "0.1.3-nocobase.2.1",
8
+ "license": "Apache-2.0",
9
+ "author": "Webexa Technologies LLP",
10
+ "homepage": "https://github.com/webexatech/plugin-collection-transfer#readme",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/webexatech/plugin-collection-transfer.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/webexatech/plugin-collection-transfer/issues"
17
+ },
18
+ "main": "dist/server/index.js",
19
+ "files": [
20
+ "dist",
21
+ "dist/node_modules/**",
22
+ "client.js",
23
+ "client.d.ts",
24
+ "client-v2.js",
25
+ "client-v2.d.ts",
26
+ "server.js",
27
+ "server.d.ts",
28
+ "README.md",
29
+ "CHANGELOG.md",
30
+ "LICENSE"
31
+ ],
32
+ "nocobase": {
33
+ "supportedVersions": [
34
+ "2.x"
35
+ ]
36
+ },
37
+ "devDependencies": {
38
+ "@types/archiver": "^5.3.1",
39
+ "archiver": "^5.3.1",
40
+ "@types/yauzl": "^2.10.3",
41
+ "yauzl": "^3.3.0"
42
+ },
43
+ "peerDependencies": {
44
+ "@nocobase/actions": "2.x",
45
+ "@nocobase/client": "2.x",
46
+ "@nocobase/client-v2": "2.x",
47
+ "@nocobase/database": "2.x",
48
+ "@nocobase/plugin-data-source-main": "2.x",
49
+ "@nocobase/server": "2.x",
50
+ "@nocobase/test": "2.x",
51
+ "@nocobase/utils": "2.x"
52
+ },
53
+ "keywords": [
54
+ "System management"
55
+ ]
56
+ }
package/server.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/server';
2
+ export { default } from './dist/server';
package/server.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/server/index.js');