@webexatech/plugin-collection-transfer 0.0.0-stage → 0.1.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/CHANGELOG.md +33 -0
- package/LICENSE +201 -0
- package/README.md +149 -2
- package/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/949.3230de7f57066bc7.js +10 -0
- package/dist/client/SettingsPage.d.ts +3 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +10 -0
- package/dist/client/plugin.d.ts +5 -0
- package/dist/client-v2/907.bed81d14270e80c6.js +10 -0
- package/dist/client-v2/CollectionTransferSettings.d.ts +21 -0
- package/dist/client-v2/SettingsPage.d.ts +4 -0
- package/dist/client-v2/index.d.ts +1 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/locale.d.ts +7 -0
- package/dist/client-v2/plugin.d.ts +7 -0
- package/dist/externalVersion.js +24 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +70 -0
- package/dist/locale/zh-CN.json +70 -0
- package/dist/node_modules/archiver/LICENSE +22 -0
- package/dist/node_modules/archiver/index.js +68 -0
- package/dist/node_modules/archiver/lib/core.js +974 -0
- package/dist/node_modules/archiver/lib/error.js +40 -0
- package/dist/node_modules/archiver/lib/plugins/json.js +110 -0
- package/dist/node_modules/archiver/lib/plugins/tar.js +167 -0
- package/dist/node_modules/archiver/lib/plugins/zip.js +120 -0
- package/dist/node_modules/archiver/node_modules/async/all.js +119 -0
- package/dist/node_modules/archiver/node_modules/async/allLimit.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/allSeries.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/any.js +122 -0
- package/dist/node_modules/archiver/node_modules/async/anyLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/anySeries.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/apply.js +11 -0
- package/dist/node_modules/archiver/node_modules/async/applyEach.js +57 -0
- package/dist/node_modules/archiver/node_modules/async/applyEachSeries.js +37 -0
- package/dist/node_modules/archiver/node_modules/async/asyncify.js +118 -0
- package/dist/node_modules/archiver/node_modules/async/auto.js +333 -0
- package/dist/node_modules/archiver/node_modules/async/autoInject.js +182 -0
- package/dist/node_modules/archiver/node_modules/async/bower.json +17 -0
- package/dist/node_modules/archiver/node_modules/async/cargo.js +63 -0
- package/dist/node_modules/archiver/node_modules/async/cargoQueue.js +71 -0
- package/dist/node_modules/archiver/node_modules/async/compose.js +55 -0
- package/dist/node_modules/archiver/node_modules/async/concat.js +115 -0
- package/dist/node_modules/archiver/node_modules/async/concatLimit.js +60 -0
- package/dist/node_modules/archiver/node_modules/async/concatSeries.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/constant.js +14 -0
- package/dist/node_modules/archiver/node_modules/async/detect.js +96 -0
- package/dist/node_modules/archiver/node_modules/async/detectLimit.js +48 -0
- package/dist/node_modules/archiver/node_modules/async/detectSeries.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/dir.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/dist/async.js +6062 -0
- package/dist/node_modules/archiver/node_modules/async/dist/async.min.js +1 -0
- package/dist/node_modules/archiver/node_modules/async/doDuring.js +68 -0
- package/dist/node_modules/archiver/node_modules/async/doUntil.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/doWhilst.js +68 -0
- package/dist/node_modules/archiver/node_modules/async/during.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/each.js +129 -0
- package/dist/node_modules/archiver/node_modules/async/eachLimit.js +50 -0
- package/dist/node_modules/archiver/node_modules/async/eachOf.js +185 -0
- package/dist/node_modules/archiver/node_modules/async/eachOfLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/eachOfSeries.js +39 -0
- package/dist/node_modules/archiver/node_modules/async/eachSeries.js +44 -0
- package/dist/node_modules/archiver/node_modules/async/ensureAsync.js +67 -0
- package/dist/node_modules/archiver/node_modules/async/every.js +119 -0
- package/dist/node_modules/archiver/node_modules/async/everyLimit.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/everySeries.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/filter.js +93 -0
- package/dist/node_modules/archiver/node_modules/async/filterLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/filterSeries.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/find.js +96 -0
- package/dist/node_modules/archiver/node_modules/async/findLimit.js +48 -0
- package/dist/node_modules/archiver/node_modules/async/findSeries.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/flatMap.js +115 -0
- package/dist/node_modules/archiver/node_modules/async/flatMapLimit.js +60 -0
- package/dist/node_modules/archiver/node_modules/async/flatMapSeries.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/foldl.js +153 -0
- package/dist/node_modules/archiver/node_modules/async/foldr.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/forEach.js +129 -0
- package/dist/node_modules/archiver/node_modules/async/forEachLimit.js +50 -0
- package/dist/node_modules/archiver/node_modules/async/forEachOf.js +185 -0
- package/dist/node_modules/archiver/node_modules/async/forEachOfLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/forEachOfSeries.js +39 -0
- package/dist/node_modules/archiver/node_modules/async/forEachSeries.js +44 -0
- package/dist/node_modules/archiver/node_modules/async/forever.js +68 -0
- package/dist/node_modules/archiver/node_modules/async/groupBy.js +108 -0
- package/dist/node_modules/archiver/node_modules/async/groupByLimit.js +71 -0
- package/dist/node_modules/archiver/node_modules/async/groupBySeries.js +36 -0
- package/dist/node_modules/archiver/node_modules/async/index.js +588 -0
- package/dist/node_modules/archiver/node_modules/async/inject.js +153 -0
- package/dist/node_modules/archiver/node_modules/async/internal/DoublyLinkedList.js +92 -0
- package/dist/node_modules/archiver/node_modules/async/internal/Heap.js +120 -0
- package/dist/node_modules/archiver/node_modules/async/internal/applyEach.js +29 -0
- package/dist/node_modules/archiver/node_modules/async/internal/asyncEachOfLimit.js +75 -0
- package/dist/node_modules/archiver/node_modules/async/internal/awaitify.js +28 -0
- package/dist/node_modules/archiver/node_modules/async/internal/breakLoop.js +10 -0
- package/dist/node_modules/archiver/node_modules/async/internal/consoleFunc.js +31 -0
- package/dist/node_modules/archiver/node_modules/async/internal/createTester.js +40 -0
- package/dist/node_modules/archiver/node_modules/async/internal/eachOfLimit.js +90 -0
- package/dist/node_modules/archiver/node_modules/async/internal/filter.js +55 -0
- package/dist/node_modules/archiver/node_modules/async/internal/getIterator.js +11 -0
- package/dist/node_modules/archiver/node_modules/async/internal/initialParams.js +14 -0
- package/dist/node_modules/archiver/node_modules/async/internal/isArrayLike.js +10 -0
- package/dist/node_modules/archiver/node_modules/async/internal/iterator.js +57 -0
- package/dist/node_modules/archiver/node_modules/async/internal/map.js +30 -0
- package/dist/node_modules/archiver/node_modules/async/internal/once.js +17 -0
- package/dist/node_modules/archiver/node_modules/async/internal/onlyOnce.js +15 -0
- package/dist/node_modules/archiver/node_modules/async/internal/parallel.js +34 -0
- package/dist/node_modules/archiver/node_modules/async/internal/promiseCallback.js +23 -0
- package/dist/node_modules/archiver/node_modules/async/internal/queue.js +294 -0
- package/dist/node_modules/archiver/node_modules/async/internal/range.js +14 -0
- package/dist/node_modules/archiver/node_modules/async/internal/reject.js +26 -0
- package/dist/node_modules/archiver/node_modules/async/internal/setImmediate.js +34 -0
- package/dist/node_modules/archiver/node_modules/async/internal/withoutIndex.js +10 -0
- package/dist/node_modules/archiver/node_modules/async/internal/wrapAsync.js +34 -0
- package/dist/node_modules/archiver/node_modules/async/log.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/map.js +142 -0
- package/dist/node_modules/archiver/node_modules/async/mapLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/mapSeries.js +44 -0
- package/dist/node_modules/archiver/node_modules/async/mapValues.js +152 -0
- package/dist/node_modules/archiver/node_modules/async/mapValuesLimit.js +61 -0
- package/dist/node_modules/archiver/node_modules/async/mapValuesSeries.js +37 -0
- package/dist/node_modules/archiver/node_modules/async/memoize.js +91 -0
- package/dist/node_modules/archiver/node_modules/async/nextTick.js +52 -0
- package/dist/node_modules/archiver/node_modules/async/package.json +75 -0
- package/dist/node_modules/archiver/node_modules/async/parallel.js +180 -0
- package/dist/node_modules/archiver/node_modules/async/parallelLimit.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/priorityQueue.js +60 -0
- package/dist/node_modules/archiver/node_modules/async/queue.js +24 -0
- package/dist/node_modules/archiver/node_modules/async/race.js +67 -0
- package/dist/node_modules/archiver/node_modules/async/reduce.js +153 -0
- package/dist/node_modules/archiver/node_modules/async/reduceRight.js +41 -0
- package/dist/node_modules/archiver/node_modules/async/reflect.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/reflectAll.js +93 -0
- package/dist/node_modules/archiver/node_modules/async/reject.js +87 -0
- package/dist/node_modules/archiver/node_modules/async/rejectLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/rejectSeries.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/retry.js +159 -0
- package/dist/node_modules/archiver/node_modules/async/retryable.js +77 -0
- package/dist/node_modules/archiver/node_modules/async/select.js +93 -0
- package/dist/node_modules/archiver/node_modules/async/selectLimit.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/selectSeries.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/seq.js +79 -0
- package/dist/node_modules/archiver/node_modules/async/series.js +186 -0
- package/dist/node_modules/archiver/node_modules/async/setImmediate.js +45 -0
- package/dist/node_modules/archiver/node_modules/async/some.js +122 -0
- package/dist/node_modules/archiver/node_modules/async/someLimit.js +47 -0
- package/dist/node_modules/archiver/node_modules/async/someSeries.js +46 -0
- package/dist/node_modules/archiver/node_modules/async/sortBy.js +190 -0
- package/dist/node_modules/archiver/node_modules/async/timeout.js +89 -0
- package/dist/node_modules/archiver/node_modules/async/times.js +50 -0
- package/dist/node_modules/archiver/node_modules/async/timesLimit.js +43 -0
- package/dist/node_modules/archiver/node_modules/async/timesSeries.js +32 -0
- package/dist/node_modules/archiver/node_modules/async/transform.js +173 -0
- package/dist/node_modules/archiver/node_modules/async/tryEach.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/unmemoize.js +25 -0
- package/dist/node_modules/archiver/node_modules/async/until.js +61 -0
- package/dist/node_modules/archiver/node_modules/async/waterfall.js +105 -0
- package/dist/node_modules/archiver/node_modules/async/whilst.js +78 -0
- package/dist/node_modules/archiver/node_modules/async/wrapSync.js +118 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/errors-browser.js +127 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/errors.js +116 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/experimentalWarning.js +17 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_duplex.js +126 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_passthrough.js +37 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_readable.js +1027 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_transform.js +190 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/_stream_writable.js +641 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/async_iterator.js +180 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/buffer_list.js +183 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/destroy.js +96 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +86 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/from-browser.js +3 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/from.js +52 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/pipeline.js +86 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/state.js +22 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/package.json +68 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/readable-browser.js +9 -0
- package/dist/node_modules/archiver/node_modules/readable-stream/readable.js +16 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/extract.js +257 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/headers.js +295 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/index.js +2 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/pack.js +255 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/package.json +58 -0
- package/dist/node_modules/archiver/node_modules/tar-stream/sandbox.js +11 -0
- package/dist/node_modules/archiver/package.json +1 -0
- package/dist/node_modules/yauzl/LICENSE +21 -0
- package/dist/node_modules/yauzl/fd-slicer.js +314 -0
- package/dist/node_modules/yauzl/index.js +1 -0
- package/dist/node_modules/yauzl/package.json +1 -0
- package/dist/server/exporter.d.ts +42 -0
- package/dist/server/exporter.js +311 -0
- package/dist/server/field-value-writer.d.ts +9 -0
- package/dist/server/field-value-writer.js +107 -0
- package/dist/server/importer.d.ts +138 -0
- package/dist/server/importer.js +842 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +42 -0
- package/dist/server/package-format.d.ts +50 -0
- package/dist/server/package-format.js +115 -0
- package/dist/server/plugin.d.ts +6 -0
- package/dist/server/plugin.js +61 -0
- package/dist/server/resourcer.d.ts +14 -0
- package/dist/server/resourcer.js +144 -0
- package/package.json +54 -4
- package/server.d.ts +2 -0
- package/server.js +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this plugin are documented here. Versions follow [semver](https://semver.org/).
|
|
4
|
+
|
|
5
|
+
## 0.1.2 – NocoBase 2.2.x
|
|
6
|
+
|
|
7
|
+
Security hardening of the import (upgrade recommended):
|
|
8
|
+
|
|
9
|
+
- Raw `options` objects in collections, fields and relations are refused; they would otherwise bypass the checks on
|
|
10
|
+
top-level keys (for example `options.tableName`).
|
|
11
|
+
- Relation fields among a collection's plain fields are recognised by their registered field class, so relation types
|
|
12
|
+
added by plugins are refused there too.
|
|
13
|
+
- Reading data rows costs linear time up to the row size limit.
|
|
14
|
+
|
|
15
|
+
## 0.1.1 – NocoBase 2.2.x
|
|
16
|
+
|
|
17
|
+
Security hardening of the import (upgrade recommended):
|
|
18
|
+
|
|
19
|
+
- Relation fields are only accepted from `associations.json`; a relation hidden among a collection's plain fields is
|
|
20
|
+
refused, so a package cannot add fields or key columns to collections outside it.
|
|
21
|
+
- Archives are extracted by streaming each allowed entry to disk with per-entry and total size limits instead of
|
|
22
|
+
decompressing into memory; the compression-ratio check now applies from 10 MB.
|
|
23
|
+
- Data rows have a size limit (16 MB per row), so one oversized row cannot exhaust memory.
|
|
24
|
+
|
|
25
|
+
## 0.1.0 – NocoBase 2.2.x
|
|
26
|
+
|
|
27
|
+
- Export one or more general collections, with or without data, to a `.zip` package.
|
|
28
|
+
- Import with a preview that blocks unsupported or unsafe packages (missing dependencies, unknown field types or
|
|
29
|
+
field kinds, collections or tables outside the package, unsafe expressions).
|
|
30
|
+
- Per-collection conflict handling for existing collections: skip collection and import data, skip collection and
|
|
31
|
+
data, override without data, override with data (default), with a confirmation before deleting anything.
|
|
32
|
+
- *Created by* / *Updated by* of imported rows set to the importing user.
|
|
33
|
+
- Settings page in both the classic (`/admin`) and the new (`/v/admin`) admin UI; English and Chinese.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,150 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @webexatech/plugin-collection-transfer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Move collections between NocoBase environments (for example dev → prod) without rebuilding them by hand.
|
|
4
|
+
Export one or more collections, with or without their data, to a `.zip` file, then import that file into
|
|
5
|
+
another environment or back into the same one.
|
|
6
|
+
|
|
7
|
+
## Compatibility
|
|
8
|
+
|
|
9
|
+
| Plugin version | NocoBase | Database | Admin UI |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| 0.1.x | 2.2.x (tested on 2.2.50) | PostgreSQL | classic (`/admin`) and new (`/v/admin`) |
|
|
12
|
+
|
|
13
|
+
NocoBase checks a plugin against the versions it was **built** with, per minor release (`2.2.x`). A build for
|
|
14
|
+
2.2.x shows a "dependency version mismatch" warning on 2.3.x, so each NocoBase minor gets its own plugin build;
|
|
15
|
+
install the plugin version listed for your NocoBase version. Source and target must run the same database type.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
- **Plugin manager:** *Plugin manager → Add & update → npm registry*, package name
|
|
20
|
+
`@webexatech/plugin-collection-transfer`, registry `https://registry.npmjs.org`. Then enable it.
|
|
21
|
+
- **Upload:** *Plugin manager → Add & update → Upload*, choose the `.tgz` from the GitHub release. Then enable it.
|
|
22
|
+
- **CLI:** `yarn pm add @webexatech/plugin-collection-transfer --registry=https://registry.npmjs.org`, then
|
|
23
|
+
`yarn pm enable @webexatech/plugin-collection-transfer`.
|
|
24
|
+
|
|
25
|
+
Updating works the same way (*Add & update*, or `yarn pm update … --registry=…`). The plugin stores no data of its
|
|
26
|
+
own, so updates need no migration.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Open **Settings → Collection transfer** (admins only; ACL snippet `pm.collection-transfer`).
|
|
31
|
+
|
|
32
|
+
**Export tab**
|
|
33
|
+
|
|
34
|
+
1. Select the collections. Collection types that cannot be transferred are shown but disabled.
|
|
35
|
+
2. Turn on **Include data** to carry the rows as well.
|
|
36
|
+
3. Click **Export**. The result lists the join tables that were added automatically and the collections that must
|
|
37
|
+
already exist in the target (for example `users`, the target of *Created by*).
|
|
38
|
+
|
|
39
|
+
**Import tab**
|
|
40
|
+
|
|
41
|
+
1. Drop the `.zip`. Nothing is written yet.
|
|
42
|
+
2. The preview shows what will be created (fields and rows per collection) and every blocking problem.
|
|
43
|
+
3. For each collection that **already exists** in the target, choose:
|
|
44
|
+
|
|
45
|
+
| Option | Fields | Existing rows | Rows from the file |
|
|
46
|
+
| --- | --- | --- | --- |
|
|
47
|
+
| Skip collection, import data | kept | kept | added; rows whose id already exists are skipped |
|
|
48
|
+
| Skip collection and data | kept | kept | not imported |
|
|
49
|
+
| Override collection, without data | replaced | **deleted** | not imported |
|
|
50
|
+
| **Override collection and data** (default) | replaced | **deleted** | imported |
|
|
51
|
+
|
|
52
|
+
*Skip collection, import data* is only offered when the existing table has every column from the file.
|
|
53
|
+
Overriding a collection makes NocoBase remove the relation fields that point at it from other collections;
|
|
54
|
+
fields the file defines are re-created, and the preview lists any other field that would be lost.
|
|
55
|
+
4. Click **Import**. If anything is overridden, a confirmation lists what will be deleted. Everything runs in one
|
|
56
|
+
transaction and is rolled back completely on any error.
|
|
57
|
+
|
|
58
|
+
**Created by / Updated by** of every imported row is set to the admin who runs the import. User ids from the source
|
|
59
|
+
environment do not identify the same people in the target.
|
|
60
|
+
|
|
61
|
+
## What is checked before importing
|
|
62
|
+
|
|
63
|
+
The import is blocked when:
|
|
64
|
+
|
|
65
|
+
- a relation points at a collection that is neither in the file nor in the target
|
|
66
|
+
- a field type is not available in the target (a plugin that adds a server-side type is missing)
|
|
67
|
+
- a field kind is not available in the target UI (e.g. the *Code* field without `plugin-field-code`); the plugins
|
|
68
|
+
enabled in the source but not in the target are listed as a hint
|
|
69
|
+
- a database table with the same name exists without a collection, or a collection uses an unsupported template
|
|
70
|
+
- the file comes from a different database type or format version, or a name is too long for the database
|
|
71
|
+
- the file tries to change anything outside its own collections (other tables, fields on other collections)
|
|
72
|
+
- a title or UI schema contains a `{{ }}` expression other than a plain `{{t("…")}}` translation
|
|
73
|
+
- the file is not a valid package
|
|
74
|
+
|
|
75
|
+
The same checks run again when you click **Import**, in case the target changed after the preview.
|
|
76
|
+
|
|
77
|
+
## What it does not transfer
|
|
78
|
+
|
|
79
|
+
By design, the plugin moves **collection definitions and their rows only**. It does not transfer:
|
|
80
|
+
|
|
81
|
+
- pages, blocks and menus (UI schemas), workflows, role permissions, collection categories
|
|
82
|
+
- files behind attachment fields (the attachment records reference storage that differs per environment)
|
|
83
|
+
- relation fields that live on collections outside the file
|
|
84
|
+
|
|
85
|
+
Recreate those in the target, or use NocoBase's own tools for them.
|
|
86
|
+
|
|
87
|
+
**Collection types:** this edition transfers **general collections**. Tree, file, calendar, SQL, view, inherited,
|
|
88
|
+
FDW and expression collections are listed but cannot be selected.
|
|
89
|
+
|
|
90
|
+
## Known limitations
|
|
91
|
+
|
|
92
|
+
- Only the main data source; source and target must use the same database type (PostgreSQL tested).
|
|
93
|
+
- Primary-key conflicts are resolved per collection (skip or override), not per row; rows are not merged.
|
|
94
|
+
- Sequence counters, encrypted fields, sort scopes, custom primary keys and indexes defined in collection options are
|
|
95
|
+
not specially handled. A key column created by hand before its relation comes back with default display settings.
|
|
96
|
+
- Whole tables are read into memory on export, and there is no progress reporting for very large imports.
|
|
97
|
+
- Only import files from environments you trust.
|
|
98
|
+
|
|
99
|
+
## How it works
|
|
100
|
+
|
|
101
|
+
- **Export** reads the definitions from the `collections` / `fields` tables. Each collection is written in the shape
|
|
102
|
+
the UI sends to `collections:create`: scalar fields nested, relation fields stored once per pair with the other side
|
|
103
|
+
as `reverseField`, generated join-table and key-column names kept so the rows still line up. Rows are dumped per
|
|
104
|
+
table as NDJSON.
|
|
105
|
+
- **Import** creates the collections, then the relation fields; NocoBase's own hooks build tables, key columns, join
|
|
106
|
+
tables and reverse fields. The importer then verifies every expected join table, key field and column, inserts rows
|
|
107
|
+
in batches and moves serial id sequences past the imported ids.
|
|
108
|
+
|
|
109
|
+
### File format
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
manifest.json versions, dialect, collections, dependencies, source plugins
|
|
113
|
+
schema/collections.json collections (collections:create shape, scalar fields nested)
|
|
114
|
+
schema/associations.json relation fields (collections.fields:create shape, reverseField nested)
|
|
115
|
+
schema/through.json auto-created join tables recreated by NocoBase on import
|
|
116
|
+
data/<collection>/meta columns, row count, auto-increment column
|
|
117
|
+
data/<collection>/data one JSON array of column values per row (only with "Include data")
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### API
|
|
121
|
+
|
|
122
|
+
| Action | Request | Response |
|
|
123
|
+
| --- | --- | --- |
|
|
124
|
+
| `collectionTransfer:listCollections` | `GET` | collections that can be selected |
|
|
125
|
+
| `collectionTransfer:export` | `POST { collections: string[], includeData: boolean }` | the `.zip` download |
|
|
126
|
+
| `collectionTransfer:preview` | `POST` multipart, field `file` | `token`, `problems`, `conflicts`, `interfaces` |
|
|
127
|
+
| `collectionTransfer:import` | `POST { token, resolutions: { [collection]: mode } }` | created / overridden / skipped, `rowCounts`; `409 { errors, problems }` when blocked |
|
|
128
|
+
|
|
129
|
+
Modes: `skipCollectionImportData`, `skipAll`, `overrideSchema`, `overrideAll`. Uploads are kept in
|
|
130
|
+
`<storage>/tmp/collection-transfer/` for one hour, and after a failed import so it can be retried with the same token.
|
|
131
|
+
|
|
132
|
+
## Development
|
|
133
|
+
|
|
134
|
+
The plugin lives at `packages/plugins/@webexatech/plugin-collection-transfer` inside a NocoBase source checkout.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
yarn test packages/plugins/@webexatech/plugin-collection-transfer # server tests (separate DB via .env.test)
|
|
138
|
+
yarn eslint --fix packages/plugins/@webexatech/plugin-collection-transfer/src
|
|
139
|
+
bash scripts/check-plugin-peer-deps.sh packages/plugins/@webexa
|
|
140
|
+
yarn build @webexatech/plugin-collection-transfer --tar # storage/tar/@webexatech/…tgz
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The settings page is written once in `src/client-v2/CollectionTransferSettings.tsx` (no runtime imports) and mounted
|
|
144
|
+
by both the v2 client (`src/client-v2/SettingsPage.tsx`) and the classic client (`src/client/SettingsPage.tsx`).
|
|
145
|
+
The data dump logic and `FieldValueWriter` are adapted from `@nocobase/plugin-backup-restore`, which does not export
|
|
146
|
+
them.
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
Apache-2.0
|
package/client-v2.d.ts
ADDED
package/client-v2.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client-v2/index.js');
|
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/client/index.js');
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
"use strict";(self.webpackChunk_webexatech_plugin_collection_transfer=self.webpackChunk_webexatech_plugin_collection_transfer||[]).push([["949"],{140:function(e,t,n){n.r(t),n.d(t,{SettingsPage:function(){return P}});var r=n(342),a=n(155),l=n.n(a),o=n(375),i=n(59),c=n(953),s=n(143);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function m(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){d(l,r,a,o,i,"next",e)}function i(e){d(l,r,a,o,i,"throw",e)}o(void 0)})}}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){p(e,t,n[t])})}return e}function h(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||g(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}}function b(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var s=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return l.label++,{value:s[1],done:!1};case 5:l.label++,r=s[1],s=[0];continue;case 7:s=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){l=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){l.label=s[1];break}if(6===s[0]&&l.label<a[1]){l.label=a[1],a=s;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(s);break}a[2]&&l.ops.pop(),l.trys.pop();continue}s=t.call(e,l)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}var E=(0,a.createContext)(null);function w(){var e=(0,a.useContext)(E);if(!e)throw Error("CollectionTransferSettings needs TransferServices");return e}function S(e){return m(function(){var t,n,r,a,l,o,i;return b(this,function(c){switch(c.label){case 0:var s,u;if(r=(n=e||{}).response,a=n.message,s=l=null==r?void 0:r.data,null!=(u=Blob)&&"u">typeof Symbol&&u[Symbol.hasInstance]?!u[Symbol.hasInstance](s):!(s instanceof u))return[3,4];c.label=1;case 1:return c.trys.push([1,3,,4]),o=JSON.parse,[4,l.text()];case 2:return l=o.apply(JSON,[c.sent()]),[3,4];case 3:return c.sent(),l=void 0,[3,4];case 4:return[2,(null==(i=null==l?void 0:l.errors)||null==(t=i[0])?void 0:t.message)||a||String(e)]}})})()}var k=/^\{\{\s*t\(\s*(["'])([^"'{}]*)\1\s*\)\s*\}\}$/;function x(){var e=(0,c.useTranslation)("client").t;return function(t){var n=k.exec(t||"");return n?e(n[2]):t}}var I=function(){var e=(0,s.k)(),t=x(),n=w(),r=(0,a.useId)(),o=y((0,a.useState)([]),2),c=o[0],u=o[1],d=y((0,a.useState)(!0),2),p=d[0],f=d[1],h=y((0,a.useState)([]),2),v=h[0],g=h[1],E=y((0,a.useState)(!1),2),k=E[0],I=E[1],T=y((0,a.useState)(!1),2),C=T[0],O=T[1],j=y((0,a.useState)(),2),A=j[0],P=j[1],D=y((0,a.useState)(),2),z=D[0],R=D[1],N=(0,a.useCallback)(function(){return m(function(){var e;return b(this,function(t){switch(t.label){case 0:f(!0),P(void 0),t.label=1;case 1:return t.trys.push([1,3,5,6]),[4,n.request({url:"collectionTransfer:listCollections",method:"get"})];case 2:return u((null==(e=t.sent().data)?void 0:e.data)||[]),[3,6];case 3:return[4,S(t.sent())];case 4:return P.apply(void 0,[t.sent()]),[3,6];case 5:return f(!1),[7];case 6:return[2]}})})()},[n]);(0,a.useEffect)(function(){N()},[N]);var F=[{title:e("Title"),dataIndex:"title",render:function(e){return t(e)}},{title:e("Name"),dataIndex:"name",render:function(e){return l().createElement(i.Typography.Text,{code:!0},e)}},{title:e("Template"),dataIndex:"template",render:function(t,n){return n.supported?l().createElement(i.Tag,null,t):l().createElement(i.Tooltip,{title:e("Only general collections can be transferred in this version")},l().createElement(i.Tag,{color:"warning"},e("Not supported")))}}],U=z?z.collections.filter(function(e){return!z.selected.includes(e)}):[];return l().createElement(i.Space,{direction:"vertical",size:"middle",style:{width:"100%"}},l().createElement(i.Typography.Paragraph,{type:"secondary",style:{marginBottom:0}},e("Select the collections to export. The file can be imported into another environment.")),A&&l().createElement(i.Alert,{type:"error",showIcon:!0,message:A,role:"alert"}),l().createElement(i.Table,{rowKey:"name",size:"middle",loading:p,columns:F,dataSource:c,pagination:!1,rowSelection:{selectedRowKeys:v,onChange:g,getCheckboxProps:function(e){return{disabled:!e.supported,"aria-label":t(e.title)}}},locale:{emptyText:e("No collections to export")}}),l().createElement(i.Space,{align:"center",wrap:!0},l().createElement(i.Switch,{id:r,checked:k,onChange:I}),l().createElement("label",{htmlFor:r},e("Include data")),l().createElement(i.Button,{type:"primary",onClick:function(){return m(function(){var e,t,r,a;return b(this,function(l){switch(l.label){case 0:O(!0),P(void 0),R(void 0),l.label=1;case 1:return l.trys.push([1,3,5,6]),[4,n.request({url:"collectionTransfer:export",method:"post",data:{collections:v,includeData:k},responseType:"blob"})];case 2:var o,i,c,s,u,d;return c=(r=l.sent()).data,o=null==(e=r.headers)?void 0:e["content-disposition"],s=(i=/filename\*?=(?:UTF-8'')?"?([^";]+)"?/i.exec(o||""))?decodeURIComponent(i[1]):"collections.zip",u=URL.createObjectURL(new Blob([c],{type:"application/zip"})),(d=document.createElement("a")).href=u,d.download=s,document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(u),(a=null==(t=r.headers)?void 0:t["x-collection-transfer-manifest"])&&R(JSON.parse(decodeURIComponent(a))),[3,6];case 3:return[4,S(l.sent())];case 4:return P.apply(void 0,[l.sent()]),[3,6];case 5:return O(!1),[7];case 6:return[2]}})})()},loading:C,disabled:!v.length},e("Export"))),z&&l().createElement(i.Alert,{type:"success",showIcon:!0,role:"status",message:e("Exported {{count}} collection(s)",{count:z.collections.length}),description:l().createElement(i.Space,{direction:"vertical",size:4},U.length>0&&l().createElement("span",null,e("Added because they are needed: {{names}}",{names:U.join(", ")})),z.dependencies.length>0&&l().createElement("span",null,e("Must already exist in the target environment: {{names}}",{names:z.dependencies.join(", ")})))}))},T=["skipCollectionImportData","overrideAll"],C=["overrideSchema","overrideAll"],O=function(){var e=(0,s.k)(),t=x(),n=w(),r=y((0,a.useState)(!1),2),c=r[0],u=r[1],d=y((0,a.useState)(!1),2),g=d[0],E=d[1],k=y((0,a.useState)(!1),2),I=k[0],O=k[1],j=y((0,a.useState)(),2),A=j[0],P=j[1],D=y((0,a.useState)({}),2),z=D[0],R=D[1],N=y((0,a.useState)(),2),F=N[0],U=N[1],M=y((0,a.useState)(),2),q=M[0],B=M[1],_=((null==A?void 0:A.interfaces)||[]).filter(function(e){return!n.hasFieldInterface(e.interface)}).map(function(e){return{code:"unknownInterface",collection:e.collection,field:e.field,detail:e.interface}}),L=v((null==A?void 0:A.problems)||[]).concat(v(_)),J=!!(null==A?void 0:A.manifest.includeData),K=(null==A?void 0:A.conflicts)||[],G=K.filter(function(e){return C.includes(z[e.name])}),V=new Set(v(((null==A?void 0:A.manifest.collections)||[]).filter(function(e){return!K.some(function(t){return t.name===e})})).concat(v(G.map(function(e){return e.name})))),W=G.flatMap(function(e){return e.referencedBy.filter(function(e){return!V.has(e.collection)&&!e.restored}).map(function(e){return"".concat(e.collection,".").concat(e.field)})}),$=function(){P(void 0),R({}),U(void 0),B(void 0)},Y=function(e){P(e);var t={},n=!0,r=!1,a=void 0;try{for(var l,o=(e.conflicts||[])[Symbol.iterator]();!(n=(l=o.next()).done);n=!0)t[l.value.name]=e.manifest.includeData?"overrideAll":"overrideSchema"}catch(e){r=!0,a=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw a}}R(t)},H=function(){return m(function(){var e,t,r,a,l;return b(this,function(o){switch(o.label){case 0:if(!A)return[2];O(!1),E(!0),B(void 0),o.label=1;case 1:return o.trys.push([1,3,5,6]),[4,n.request({url:"collectionTransfer:import",method:"post",data:{token:A.token,resolutions:z}})];case 2:return U(null==(e=o.sent().data)?void 0:e.data),P(void 0),[3,6];case 3:return(null==(l=null==(t=o.sent())||null==(a=t.response)||null==(r=a.data)?void 0:r.problems)?void 0:l.length)&&P(h(f({},A),{problems:l})),[4,S(t)];case 4:return B.apply(void 0,[o.sent()]),[3,6];case 5:return E(!1),[7];case 6:return[2]}})})()},Q=[{title:e("Collection"),dataIndex:"title",render:function(n,r){return l().createElement(i.Space,{size:4},l().createElement("span",null,t(n)),l().createElement(i.Typography.Text,{type:"secondary",code:!0},r.name),r.isThrough&&l().createElement(i.Tag,null,e("Junction table")))}},{title:e("Fields"),dataIndex:"fieldCount",width:100,render:function(e,t){return t.isThrough?"–":e}},{title:e("Rows"),dataIndex:"rowCount",width:100,render:function(e){return J?e:"–"}}],X={skipCollectionImportData:e("Skip collection, import data"),skipAll:e("Skip collection and data"),overrideSchema:e("Override collection, without data"),overrideAll:e("Override collection and data")},Z=[{title:e("Collection"),dataIndex:"title",width:"35%",render:function(e,n){return l().createElement(i.Space,{size:4,wrap:!0},l().createElement("span",null,t(e)),l().createElement(i.Typography.Text,{type:"secondary",code:!0},n.name))}},{title:e("What to do"),dataIndex:"name",render:function(t,n){var r=J&&n.missingColumns.length>0;return l().createElement(i.Radio.Group,{"aria-label":e('What to do with "{{name}}"',{name:t}),value:z[t],onChange:function(e){return R(function(n){return h(f({},n),p({},t,e.target.value))})}},l().createElement(i.Space,{direction:"vertical",size:2},Object.keys(X).map(function(t){var a=!J&&T.includes(t),o=a||"skipCollectionImportData"===t&&r,c=a?e("The file contains no data"):"skipCollectionImportData"===t&&r?e("Missing columns here: {{columns}}",{columns:n.missingColumns.join(", ")}):void 0;return l().createElement(i.Radio,{key:t,value:t,disabled:o},X[t],c&&l().createElement(i.Typography.Text,{type:"secondary",style:{marginInlineStart:8}},"(",c,")"))})))}}];return l().createElement(i.Space,{direction:"vertical",size:"middle",style:{width:"100%"}},l().createElement(i.Upload.Dragger,{accept:".zip",maxCount:1,showUploadList:!1,customRequest:function(e){var t=e.file,r=e.onSuccess,a=e.onError;return m(function(){var e,l,o;return b(this,function(i){switch(i.label){case 0:$(),u(!0),(e=new FormData).append("file",t),i.label=1;case 1:return i.trys.push([1,3,5,6]),[4,n.request({url:"collectionTransfer:preview",method:"post",data:e})];case 2:return Y(null==(l=i.sent().data)?void 0:l.data),null==r||r(l),[3,6];case 3:return[4,S(o=i.sent())];case 4:return B.apply(void 0,[i.sent()]),null==a||a(o),[3,6];case 5:return u(!1),[7];case 6:return[2]}})})()},disabled:c||g},l().createElement("p",{className:"ant-upload-drag-icon"},l().createElement(o.InboxOutlined,{"aria-hidden":!0})),l().createElement("p",{className:"ant-upload-text"},e("Click or drag a collection package (.zip) here")),l().createElement("p",{className:"ant-upload-hint"},e("Nothing is changed until you confirm the import."))),c&&l().createElement(i.Alert,{type:"info",showIcon:!0,message:e("Checking package…"),role:"status","aria-busy":!0}),q&&l().createElement(i.Alert,{type:"error",showIcon:!0,message:q,role:"alert"}),A&&l().createElement(i.Card,{size:"small",title:e("Preview")},l().createElement(i.Space,{direction:"vertical",size:"middle",style:{width:"100%"}},l().createElement(i.Descriptions,{size:"small",column:{xs:1,sm:2}},l().createElement(i.Descriptions.Item,{label:e("Exported at")},new Date(A.manifest.exportedAt).toLocaleString()),l().createElement(i.Descriptions.Item,{label:e("Source version")},A.manifest.sourceAppVersion),l().createElement(i.Descriptions.Item,{label:e("Includes data")},J?e("Yes"):e("No")),l().createElement(i.Descriptions.Item,{label:e("Requires")},A.manifest.dependencies.join(", ")||"–")),l().createElement(i.Table,{rowKey:"name",size:"small",columns:Q,dataSource:A.collections,pagination:!1}),K.length>0&&l().createElement(i.Space,{direction:"vertical",size:"small",style:{width:"100%"}},l().createElement(i.Typography.Title,{level:5,style:{margin:0}},e("Already exists here")),l().createElement(i.Table,{rowKey:"name",size:"small",columns:Z,dataSource:K,pagination:!1}),W.length>0&&l().createElement(i.Alert,{type:"warning",showIcon:!0,message:e("Overriding also removes these fields from other collections: {{fields}}",{fields:W.join(", ")})})),L.length>0?l().createElement(i.Alert,{type:"error",showIcon:!0,role:"alert",message:e("This package cannot be imported here"),description:l().createElement(i.Space,{direction:"vertical",size:4},l().createElement("ul",{style:{margin:0,paddingInlineStart:20}},L.map(function(t){return l().createElement("li",{key:"".concat(t.code,"-").concat(t.collection,"-").concat(t.field,"-").concat(t.detail)},function(e,t){var n={collection:t.collection,field:t.field,detail:t.detail};switch(t.code){case"collectionExists":return e('Collection "{{collection}}" already exists in this environment',n);case"tableExists":return e('A database table for "{{collection}}" already exists in this environment',n);case"missingDependency":return e('Collection "{{collection}}" is referenced by a relation but does not exist in this environment',n);case"unknownFieldType":return e('Field "{{collection}}.{{field}}" uses type "{{detail}}", which is not available here',n);case"unsupportedTemplate":return e('Collection "{{collection}}" uses template "{{detail}}", which cannot be transferred yet',n);case"identifierTooLong":return e('Name "{{detail}}" in "{{collection}}" is too long for the database',h(f({},n),{detail:t.detail||t.collection}));case"dialect":return e("The package was exported from a different database type ({{detail}})",n);case"formatVersion":return e("The package format version {{detail}} is not supported",n);case"unknownInterface":return e('Field "{{collection}}.{{field}}" uses the "{{detail}}" field kind, which is not available here',n);case"systemCollection":return e('"{{collection}}" is a system or plugin collection here and cannot be replaced by an import',n);case"unresolvedConflict":return e('Choose what to do with the existing collection "{{collection}}"',n);case"columnsMismatch":return e('"{{collection}}" here lacks columns from the file ({{detail}}), so its data cannot be added',n);case"outsidePackage":return e('"{{collection}}" would change something outside the package: {{detail}}',n);case"unsafeExpression":return e('"{{collection}}" contains an expression that is not allowed in a package: {{detail}}',n);case"invalidName":return e('Collection name "{{collection}}" is not valid',n);default:return e("The package is incomplete or damaged ({{detail}})",h(f({},n),{detail:t.detail||t.code}))}}(e,t))})),_.length>0&&A.missingPlugins.length>0&&l().createElement("span",null,e("Enabled in the source environment but not here: {{names}}",{names:A.missingPlugins.join(", ")})))}):l().createElement(i.Alert,{type:"success",showIcon:!0,message:e("Ready to import. All collections are created in a single step and rolled back on error.")}),l().createElement(i.Space,null,l().createElement(i.Button,{type:"primary",onClick:function(){G.length?O(!0):H()},loading:g,disabled:L.length>0},e("Import")),l().createElement(i.Button,{onClick:$,disabled:g},e("Cancel"))))),l().createElement(i.Modal,{open:I,title:e("Replace existing collections?"),okText:e("Replace and import"),okButtonProps:{danger:!0},cancelText:e("Cancel"),onOk:H,onCancel:function(){return O(!1)}},l().createElement(i.Space,{direction:"vertical",size:"small"},l().createElement("span",null,e("The existing data of these collections will be permanently deleted:")),l().createElement("ul",{style:{margin:0,paddingInlineStart:20}},G.map(function(e){return l().createElement("li",{key:e.name},t(e.title)," ",l().createElement(i.Typography.Text,{code:!0},e.name)," –"," ",X[z[e.name]])})),W.length>0&&l().createElement(i.Alert,{type:"warning",showIcon:!0,message:e("Overriding also removes these fields from other collections: {{fields}}",{fields:W.join(", ")})}))),F&&l().createElement(i.Alert,{type:"success",showIcon:!0,role:"status",message:e("Imported {{count}} collection(s)",{count:F.collections.length}),description:l().createElement(i.Space,{direction:"vertical",size:4},F.overridden.length>0&&l().createElement("span",null,e("Overridden: {{names}}",{names:F.overridden.join(", ")})),F.skipped.length>0&&l().createElement("span",null,e("Skipped: {{names}}",{names:F.skipped.join(", ")})),Object.keys(F.rowCounts).length>0?l().createElement("ul",{style:{margin:0,paddingInlineStart:20}},Object.entries(F.rowCounts).map(function(t){var n=y(t,2),r=n[0],a=n[1];return l().createElement("li",{key:r},e("{{name}}: {{count}} row(s)",{name:r,count:a}))})):l().createElement("span",null,e("No rows were imported.")))}))},j=function(){var e=(0,s.k)();return l().createElement(i.Card,{variant:"borderless"},l().createElement(i.Tabs,{items:[{key:"export",label:e("Export"),children:l().createElement(I,null)},{key:"import",label:e("Import"),children:l().createElement(O,null)}]}))},A=function(e){var t=e.services;return l().createElement(E.Provider,{value:t},l().createElement(j,null))},P=function(){var e=(0,r.useAPIClient)(),t=(0,r.useDataSourceManager)(),n=(0,a.useMemo)(function(){return{request:function(t){return e.request(t)},hasFieldInterface:function(e){return!!(null==t?void 0:t.collectionFieldInterfaceManager.getFieldInterface(e))}}},[e,t]);return l().createElement(A,{services:n})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './plugin';
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("react"),require("antd"),require("@nocobase/client"),require("@ant-design/icons")):"function"==typeof define&&define.amd?define("@webexatech/plugin-collection-transfer",["react-i18next","react","antd","@nocobase/client","@ant-design/icons"],t):"object"==typeof exports?exports["@webexatech/plugin-collection-transfer"]=t(require("react-i18next"),require("react"),require("antd"),require("@nocobase/client"),require("@ant-design/icons")):e["@webexatech/plugin-collection-transfer"]=t(e["react-i18next"],e.react,e.antd,e["@nocobase/client"],e["@ant-design/icons"])}(self,function(e,t,n,r,o){return function(){"use strict";var i,c,a,u={143:function(e,t,n){n.d(t,{C:function(){return c},k:function(){return a}});var r=n(155),o=n(953);function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}var c=JSON.parse('{"UU":"@webexatech/plugin-collection-transfer"}').UU;function a(){var e=(0,o.useTranslation)([c,"client"],{nsMode:"fallback"}).t;return(0,r.useCallback)(function(t,n){var r,o;return e(t,(r=i({},n),o=o={interpolation:i({escapeValue:!1},null==n?void 0:n.interpolation)},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r))},[e])}},375:function(e){e.exports=o},342:function(e){e.exports=r},59:function(e){e.exports=n},155:function(e){e.exports=t},953:function(t){t.exports=e}},l={};function f(e){var t=l[e];if(void 0!==t)return t.exports;var n=l[e]={exports:{}};return u[e](n,n.exports,f),n.exports}f.m=u,f.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(t,{a:t}),t},f.d=function(e,t){for(var n in t)f.o(t,n)&&!f.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},f.f={},f.e=function(e){return Promise.all(Object.keys(f.f).reduce(function(t,n){return f.f[n](e,t),t},[]))},f.u=function(e){return""+e+".3230de7f57066bc7.js"},f.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),f.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},p={},f.l=function(e,t,n,r){if(p[e])return void p[e].push(t);if(void 0!==n)for(var o,i,c=document.getElementsByTagName("script"),a=0;a<c.length;a++){var u=c[a];if(u.getAttribute("src")==e||u.getAttribute("data-rspack")=="@webexatech/plugin-collection-transfer:"+n){o=u;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,f.nc&&o.setAttribute("nonce",f.nc),o.setAttribute("data-rspack","@webexatech/plugin-collection-transfer:"+n),o.src=e),p[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=p[e];if(delete p[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},f.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.g.importScripts&&(s=f.g.location+"");var p,s,b=f.g.document;if(!s&&b&&(b.currentScript&&"SCRIPT"===b.currentScript.tagName.toUpperCase()&&(s=b.currentScript.src),!s)){var d=b.getElementsByTagName("script");if(d.length)for(var h=d.length-1;h>-1&&(!s||!/^http(s?):/.test(s));)s=d[h--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");f.p=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i={889:0},f.f.j=function(e,t){var n=f.o(i,e)?i[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=i[e]=[t,r]});t.push(n[2]=r);var o=f.p+f.u(e),c=Error();f.l(o,function(t){if(f.o(i,e)&&(0!==(n=i[e])&&(i[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;c.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",c.name="ChunkLoadError",c.type=r,c.request=o,n[1](c)}},"chunk-"+e,e)}},c=function(e,t){var n,r,o=t[0],c=t[1],a=t[2],u=0;if(o.some(function(e){return 0!==i[e]})){for(n in c)f.o(c,n)&&(f.m[n]=c[n]);a&&a(f)}for(e&&e(t);u<o.length;u++)r=o[u],f.o(i,r)&&i[r]&&i[r][0](),i[r]=0},(a=self.webpackChunk_webexatech_plugin_collection_transfer=self.webpackChunk_webexatech_plugin_collection_transfer||[]).forEach(c.bind(null,0)),a.push=c.bind(null,a.push.bind(a));var y={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@webexatech/plugin-collection-transfer/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@webexatech/plugin-collection-transfer/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var c=window.location.pathname||"/",a=c.indexOf(i);e=a>=0?c.slice(0,a+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@webexatech/plugin-collection-transfer/dist/client/"}f.p=e}(),!function(){f.r(y),f.d(y,{default:function(){return l}});var e=f(342),t=f(143);function n(e,t,n,r,o,i,c){try{var a=e[i](c),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function r(e,t,n){return(r=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&i(o,n.prototype),o}).apply(null,arguments)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return r(e,arguments,o(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),i(n,e)})(e)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var u=(0,e.lazy)(function(){return f.e("949").then(f.bind(f,140))},"SettingsPage").SettingsPage,l=function(e){var r;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function c(){var e,t;if(!(this instanceof c))throw TypeError("Cannot call a class as a function");return e=c,t=arguments,e=o(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,a()?Reflect.construct(e,t||[],o(this).constructor):e.apply(this,t))}return c.prototype=Object.create(e&&e.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),e&&i(c,e),r=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(c,"next",{value:u(0)}),a(c,"throw",{value:u(1)}),a(c,"return",{value:u(2)}),"function"==typeof Symbol&&a(c,Symbol.iterator,{value:function(){return this}}),c;function u(a){return function(u){var l=[a,u];if(n)throw TypeError("Generator is already executing.");for(;c&&(c=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return this.app.pluginSettingsManager.add("collection-transfer",{title:this.t("Collection transfer",{ns:t.C}),icon:"SwapOutlined",Component:u,aclSnippet:"pm.collection-transfer"}),[2]})},function(){var t=this,r=arguments;return new Promise(function(o,i){var c=e.apply(t,r);function a(e){n(c,o,i,a,u,"next",e)}function u(e){n(c,o,i,a,u,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(c.prototype,r),c}(c(e.Plugin))}(),y}()});
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
"use strict";(self.webpackChunk_webexatech_plugin_collection_transfer_client_v2=self.webpackChunk_webexatech_plugin_collection_transfer_client_v2||[]).push([["907"],{598:function(e,t,n){n.r(t),n.d(t,{default:function(){return P}});var r=n(485),a=n(155),l=n.n(a),o=n(375),i=n(59),c=n(953),s=n(143);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(e,t,n,r,a,l,o){try{var i=e[l](o),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(r,a)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){d(l,r,a,o,i,"next",e)}function i(e){d(l,r,a,o,i,"throw",e)}o(void 0)})}}function m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){m(e,t,n[t])})}return e}function h(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,i=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(i)throw r}}return l}}(e,t)||g(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||g(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}}function b(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var s=[i,c];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return l.label++,{value:s[1],done:!1};case 5:l.label++,r=s[1],s=[0];continue;case 7:s=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){l=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){l.label=s[1];break}if(6===s[0]&&l.label<a[1]){l.label=a[1],a=s;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(s);break}a[2]&&l.ops.pop(),l.trys.pop();continue}s=t.call(e,l)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}var E=(0,a.createContext)(null);function w(){var e=(0,a.useContext)(E);if(!e)throw Error("CollectionTransferSettings needs TransferServices");return e}function S(e){return p(function(){var t,n,r,a,l,o,i;return b(this,function(c){switch(c.label){case 0:var s,u;if(r=(n=e||{}).response,a=n.message,s=l=null==r?void 0:r.data,null!=(u=Blob)&&"u">typeof Symbol&&u[Symbol.hasInstance]?!u[Symbol.hasInstance](s):!(s instanceof u))return[3,4];c.label=1;case 1:return c.trys.push([1,3,,4]),o=JSON.parse,[4,l.text()];case 2:return l=o.apply(JSON,[c.sent()]),[3,4];case 3:return c.sent(),l=void 0,[3,4];case 4:return[2,(null==(i=null==l?void 0:l.errors)||null==(t=i[0])?void 0:t.message)||a||String(e)]}})})()}var k=/^\{\{\s*t\(\s*(["'])([^"'{}]*)\1\s*\)\s*\}\}$/;function x(){var e=(0,c.useTranslation)("client").t;return function(t){var n=k.exec(t||"");return n?e(n[2]):t}}var I=function(){var e=(0,s.k)(),t=x(),n=w(),r=(0,a.useId)(),o=y((0,a.useState)([]),2),c=o[0],u=o[1],d=y((0,a.useState)(!0),2),m=d[0],f=d[1],h=y((0,a.useState)([]),2),v=h[0],g=h[1],E=y((0,a.useState)(!1),2),k=E[0],I=E[1],T=y((0,a.useState)(!1),2),C=T[0],O=T[1],j=y((0,a.useState)(),2),A=j[0],P=j[1],z=y((0,a.useState)(),2),D=z[0],R=z[1],N=(0,a.useCallback)(function(){return p(function(){var e;return b(this,function(t){switch(t.label){case 0:f(!0),P(void 0),t.label=1;case 1:return t.trys.push([1,3,5,6]),[4,n.request({url:"collectionTransfer:listCollections",method:"get"})];case 2:return u((null==(e=t.sent().data)?void 0:e.data)||[]),[3,6];case 3:return[4,S(t.sent())];case 4:return P.apply(void 0,[t.sent()]),[3,6];case 5:return f(!1),[7];case 6:return[2]}})})()},[n]);(0,a.useEffect)(function(){N()},[N]);var _=[{title:e("Title"),dataIndex:"title",render:function(e){return t(e)}},{title:e("Name"),dataIndex:"name",render:function(e){return l().createElement(i.Typography.Text,{code:!0},e)}},{title:e("Template"),dataIndex:"template",render:function(t,n){return n.supported?l().createElement(i.Tag,null,t):l().createElement(i.Tooltip,{title:e("Only general collections can be transferred in this version")},l().createElement(i.Tag,{color:"warning"},e("Not supported")))}}],F=D?D.collections.filter(function(e){return!D.selected.includes(e)}):[];return l().createElement(i.Space,{direction:"vertical",size:"middle",style:{width:"100%"}},l().createElement(i.Typography.Paragraph,{type:"secondary",style:{marginBottom:0}},e("Select the collections to export. The file can be imported into another environment.")),A&&l().createElement(i.Alert,{type:"error",showIcon:!0,message:A,role:"alert"}),l().createElement(i.Table,{rowKey:"name",size:"middle",loading:m,columns:_,dataSource:c,pagination:!1,rowSelection:{selectedRowKeys:v,onChange:g,getCheckboxProps:function(e){return{disabled:!e.supported,"aria-label":t(e.title)}}},locale:{emptyText:e("No collections to export")}}),l().createElement(i.Space,{align:"center",wrap:!0},l().createElement(i.Switch,{id:r,checked:k,onChange:I}),l().createElement("label",{htmlFor:r},e("Include data")),l().createElement(i.Button,{type:"primary",onClick:function(){return p(function(){var e,t,r,a;return b(this,function(l){switch(l.label){case 0:O(!0),P(void 0),R(void 0),l.label=1;case 1:return l.trys.push([1,3,5,6]),[4,n.request({url:"collectionTransfer:export",method:"post",data:{collections:v,includeData:k},responseType:"blob"})];case 2:var o,i,c,s,u,d;return c=(r=l.sent()).data,o=null==(e=r.headers)?void 0:e["content-disposition"],s=(i=/filename\*?=(?:UTF-8'')?"?([^";]+)"?/i.exec(o||""))?decodeURIComponent(i[1]):"collections.zip",u=URL.createObjectURL(new Blob([c],{type:"application/zip"})),(d=document.createElement("a")).href=u,d.download=s,document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(u),(a=null==(t=r.headers)?void 0:t["x-collection-transfer-manifest"])&&R(JSON.parse(decodeURIComponent(a))),[3,6];case 3:return[4,S(l.sent())];case 4:return P.apply(void 0,[l.sent()]),[3,6];case 5:return O(!1),[7];case 6:return[2]}})})()},loading:C,disabled:!v.length},e("Export"))),D&&l().createElement(i.Alert,{type:"success",showIcon:!0,role:"status",message:e("Exported {{count}} collection(s)",{count:D.collections.length}),description:l().createElement(i.Space,{direction:"vertical",size:4},F.length>0&&l().createElement("span",null,e("Added because they are needed: {{names}}",{names:F.join(", ")})),D.dependencies.length>0&&l().createElement("span",null,e("Must already exist in the target environment: {{names}}",{names:D.dependencies.join(", ")})))}))},T=["skipCollectionImportData","overrideAll"],C=["overrideSchema","overrideAll"],O=function(){var e=(0,s.k)(),t=x(),n=w(),r=y((0,a.useState)(!1),2),c=r[0],u=r[1],d=y((0,a.useState)(!1),2),g=d[0],E=d[1],k=y((0,a.useState)(!1),2),I=k[0],O=k[1],j=y((0,a.useState)(),2),A=j[0],P=j[1],z=y((0,a.useState)({}),2),D=z[0],R=z[1],N=y((0,a.useState)(),2),_=N[0],F=N[1],U=y((0,a.useState)(),2),M=U[0],q=U[1],B=((null==A?void 0:A.interfaces)||[]).filter(function(e){return!n.hasFieldInterface(e.interface)}).map(function(e){return{code:"unknownInterface",collection:e.collection,field:e.field,detail:e.interface}}),L=v((null==A?void 0:A.problems)||[]).concat(v(B)),J=!!(null==A?void 0:A.manifest.includeData),K=(null==A?void 0:A.conflicts)||[],G=K.filter(function(e){return C.includes(D[e.name])}),V=new Set(v(((null==A?void 0:A.manifest.collections)||[]).filter(function(e){return!K.some(function(t){return t.name===e})})).concat(v(G.map(function(e){return e.name})))),W=G.flatMap(function(e){return e.referencedBy.filter(function(e){return!V.has(e.collection)&&!e.restored}).map(function(e){return"".concat(e.collection,".").concat(e.field)})}),$=function(){P(void 0),R({}),F(void 0),q(void 0)},Y=function(e){P(e);var t={},n=!0,r=!1,a=void 0;try{for(var l,o=(e.conflicts||[])[Symbol.iterator]();!(n=(l=o.next()).done);n=!0)t[l.value.name]=e.manifest.includeData?"overrideAll":"overrideSchema"}catch(e){r=!0,a=e}finally{try{n||null==o.return||o.return()}finally{if(r)throw a}}R(t)},H=function(){return p(function(){var e,t,r,a,l;return b(this,function(o){switch(o.label){case 0:if(!A)return[2];O(!1),E(!0),q(void 0),o.label=1;case 1:return o.trys.push([1,3,5,6]),[4,n.request({url:"collectionTransfer:import",method:"post",data:{token:A.token,resolutions:D}})];case 2:return F(null==(e=o.sent().data)?void 0:e.data),P(void 0),[3,6];case 3:return(null==(l=null==(t=o.sent())||null==(a=t.response)||null==(r=a.data)?void 0:r.problems)?void 0:l.length)&&P(h(f({},A),{problems:l})),[4,S(t)];case 4:return q.apply(void 0,[o.sent()]),[3,6];case 5:return E(!1),[7];case 6:return[2]}})})()},Q=[{title:e("Collection"),dataIndex:"title",render:function(n,r){return l().createElement(i.Space,{size:4},l().createElement("span",null,t(n)),l().createElement(i.Typography.Text,{type:"secondary",code:!0},r.name),r.isThrough&&l().createElement(i.Tag,null,e("Junction table")))}},{title:e("Fields"),dataIndex:"fieldCount",width:100,render:function(e,t){return t.isThrough?"–":e}},{title:e("Rows"),dataIndex:"rowCount",width:100,render:function(e){return J?e:"–"}}],X={skipCollectionImportData:e("Skip collection, import data"),skipAll:e("Skip collection and data"),overrideSchema:e("Override collection, without data"),overrideAll:e("Override collection and data")},Z=[{title:e("Collection"),dataIndex:"title",width:"35%",render:function(e,n){return l().createElement(i.Space,{size:4,wrap:!0},l().createElement("span",null,t(e)),l().createElement(i.Typography.Text,{type:"secondary",code:!0},n.name))}},{title:e("What to do"),dataIndex:"name",render:function(t,n){var r=J&&n.missingColumns.length>0;return l().createElement(i.Radio.Group,{"aria-label":e('What to do with "{{name}}"',{name:t}),value:D[t],onChange:function(e){return R(function(n){return h(f({},n),m({},t,e.target.value))})}},l().createElement(i.Space,{direction:"vertical",size:2},Object.keys(X).map(function(t){var a=!J&&T.includes(t),o=a||"skipCollectionImportData"===t&&r,c=a?e("The file contains no data"):"skipCollectionImportData"===t&&r?e("Missing columns here: {{columns}}",{columns:n.missingColumns.join(", ")}):void 0;return l().createElement(i.Radio,{key:t,value:t,disabled:o},X[t],c&&l().createElement(i.Typography.Text,{type:"secondary",style:{marginInlineStart:8}},"(",c,")"))})))}}];return l().createElement(i.Space,{direction:"vertical",size:"middle",style:{width:"100%"}},l().createElement(i.Upload.Dragger,{accept:".zip",maxCount:1,showUploadList:!1,customRequest:function(e){var t=e.file,r=e.onSuccess,a=e.onError;return p(function(){var e,l,o;return b(this,function(i){switch(i.label){case 0:$(),u(!0),(e=new FormData).append("file",t),i.label=1;case 1:return i.trys.push([1,3,5,6]),[4,n.request({url:"collectionTransfer:preview",method:"post",data:e})];case 2:return Y(null==(l=i.sent().data)?void 0:l.data),null==r||r(l),[3,6];case 3:return[4,S(o=i.sent())];case 4:return q.apply(void 0,[i.sent()]),null==a||a(o),[3,6];case 5:return u(!1),[7];case 6:return[2]}})})()},disabled:c||g},l().createElement("p",{className:"ant-upload-drag-icon"},l().createElement(o.InboxOutlined,{"aria-hidden":!0})),l().createElement("p",{className:"ant-upload-text"},e("Click or drag a collection package (.zip) here")),l().createElement("p",{className:"ant-upload-hint"},e("Nothing is changed until you confirm the import."))),c&&l().createElement(i.Alert,{type:"info",showIcon:!0,message:e("Checking package…"),role:"status","aria-busy":!0}),M&&l().createElement(i.Alert,{type:"error",showIcon:!0,message:M,role:"alert"}),A&&l().createElement(i.Card,{size:"small",title:e("Preview")},l().createElement(i.Space,{direction:"vertical",size:"middle",style:{width:"100%"}},l().createElement(i.Descriptions,{size:"small",column:{xs:1,sm:2}},l().createElement(i.Descriptions.Item,{label:e("Exported at")},new Date(A.manifest.exportedAt).toLocaleString()),l().createElement(i.Descriptions.Item,{label:e("Source version")},A.manifest.sourceAppVersion),l().createElement(i.Descriptions.Item,{label:e("Includes data")},J?e("Yes"):e("No")),l().createElement(i.Descriptions.Item,{label:e("Requires")},A.manifest.dependencies.join(", ")||"–")),l().createElement(i.Table,{rowKey:"name",size:"small",columns:Q,dataSource:A.collections,pagination:!1}),K.length>0&&l().createElement(i.Space,{direction:"vertical",size:"small",style:{width:"100%"}},l().createElement(i.Typography.Title,{level:5,style:{margin:0}},e("Already exists here")),l().createElement(i.Table,{rowKey:"name",size:"small",columns:Z,dataSource:K,pagination:!1}),W.length>0&&l().createElement(i.Alert,{type:"warning",showIcon:!0,message:e("Overriding also removes these fields from other collections: {{fields}}",{fields:W.join(", ")})})),L.length>0?l().createElement(i.Alert,{type:"error",showIcon:!0,role:"alert",message:e("This package cannot be imported here"),description:l().createElement(i.Space,{direction:"vertical",size:4},l().createElement("ul",{style:{margin:0,paddingInlineStart:20}},L.map(function(t){return l().createElement("li",{key:"".concat(t.code,"-").concat(t.collection,"-").concat(t.field,"-").concat(t.detail)},function(e,t){var n={collection:t.collection,field:t.field,detail:t.detail};switch(t.code){case"collectionExists":return e('Collection "{{collection}}" already exists in this environment',n);case"tableExists":return e('A database table for "{{collection}}" already exists in this environment',n);case"missingDependency":return e('Collection "{{collection}}" is referenced by a relation but does not exist in this environment',n);case"unknownFieldType":return e('Field "{{collection}}.{{field}}" uses type "{{detail}}", which is not available here',n);case"unsupportedTemplate":return e('Collection "{{collection}}" uses template "{{detail}}", which cannot be transferred yet',n);case"identifierTooLong":return e('Name "{{detail}}" in "{{collection}}" is too long for the database',h(f({},n),{detail:t.detail||t.collection}));case"dialect":return e("The package was exported from a different database type ({{detail}})",n);case"formatVersion":return e("The package format version {{detail}} is not supported",n);case"unknownInterface":return e('Field "{{collection}}.{{field}}" uses the "{{detail}}" field kind, which is not available here',n);case"systemCollection":return e('"{{collection}}" is a system or plugin collection here and cannot be replaced by an import',n);case"unresolvedConflict":return e('Choose what to do with the existing collection "{{collection}}"',n);case"columnsMismatch":return e('"{{collection}}" here lacks columns from the file ({{detail}}), so its data cannot be added',n);case"outsidePackage":return e('"{{collection}}" would change something outside the package: {{detail}}',n);case"unsafeExpression":return e('"{{collection}}" contains an expression that is not allowed in a package: {{detail}}',n);case"invalidName":return e('Collection name "{{collection}}" is not valid',n);default:return e("The package is incomplete or damaged ({{detail}})",h(f({},n),{detail:t.detail||t.code}))}}(e,t))})),B.length>0&&A.missingPlugins.length>0&&l().createElement("span",null,e("Enabled in the source environment but not here: {{names}}",{names:A.missingPlugins.join(", ")})))}):l().createElement(i.Alert,{type:"success",showIcon:!0,message:e("Ready to import. All collections are created in a single step and rolled back on error.")}),l().createElement(i.Space,null,l().createElement(i.Button,{type:"primary",onClick:function(){G.length?O(!0):H()},loading:g,disabled:L.length>0},e("Import")),l().createElement(i.Button,{onClick:$,disabled:g},e("Cancel"))))),l().createElement(i.Modal,{open:I,title:e("Replace existing collections?"),okText:e("Replace and import"),okButtonProps:{danger:!0},cancelText:e("Cancel"),onOk:H,onCancel:function(){return O(!1)}},l().createElement(i.Space,{direction:"vertical",size:"small"},l().createElement("span",null,e("The existing data of these collections will be permanently deleted:")),l().createElement("ul",{style:{margin:0,paddingInlineStart:20}},G.map(function(e){return l().createElement("li",{key:e.name},t(e.title)," ",l().createElement(i.Typography.Text,{code:!0},e.name)," –"," ",X[D[e.name]])})),W.length>0&&l().createElement(i.Alert,{type:"warning",showIcon:!0,message:e("Overriding also removes these fields from other collections: {{fields}}",{fields:W.join(", ")})}))),_&&l().createElement(i.Alert,{type:"success",showIcon:!0,role:"status",message:e("Imported {{count}} collection(s)",{count:_.collections.length}),description:l().createElement(i.Space,{direction:"vertical",size:4},_.overridden.length>0&&l().createElement("span",null,e("Overridden: {{names}}",{names:_.overridden.join(", ")})),_.skipped.length>0&&l().createElement("span",null,e("Skipped: {{names}}",{names:_.skipped.join(", ")})),Object.keys(_.rowCounts).length>0?l().createElement("ul",{style:{margin:0,paddingInlineStart:20}},Object.entries(_.rowCounts).map(function(t){var n=y(t,2),r=n[0],a=n[1];return l().createElement("li",{key:r},e("{{name}}: {{count}} row(s)",{name:r,count:a}))})):l().createElement("span",null,e("No rows were imported.")))}))},j=function(){var e=(0,s.k)();return l().createElement(i.Card,{variant:"borderless"},l().createElement(i.Tabs,{items:[{key:"export",label:e("Export"),children:l().createElement(I,null)},{key:"import",label:e("Import"),children:l().createElement(O,null)}]}))},A=function(e){var t=e.services;return l().createElement(E.Provider,{value:t},l().createElement(j,null))},P=function(){var e=(0,r.useApp)(),t=(0,a.useMemo)(function(){return{request:function(t){return e.apiClient.request(t)},hasFieldInterface:function(t){var n,r;return!!(null==(r=e.dataSourceManager)||null==(n=r.collectionFieldInterfaceManager)?void 0:n.getFieldInterface(t))}}},[e]);return l().createElement(A,{services:t})}}}]);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* What the page needs from the host client. The v1 (`@nocobase/client`) and v2 (`@nocobase/client-v2`) settings
|
|
4
|
+
* pages each pass their own implementation, so this component imports neither runtime.
|
|
5
|
+
*/
|
|
6
|
+
export interface TransferServices {
|
|
7
|
+
request: (config: {
|
|
8
|
+
url: string;
|
|
9
|
+
method: 'get' | 'post';
|
|
10
|
+
data?: unknown;
|
|
11
|
+
responseType?: 'blob' | 'json';
|
|
12
|
+
}) => Promise<{
|
|
13
|
+
data: any;
|
|
14
|
+
headers?: Record<string, string>;
|
|
15
|
+
}>;
|
|
16
|
+
/** Whether the host UI knows a field interface (some plugins register interfaces only in the browser). */
|
|
17
|
+
hasFieldInterface: (name: string) => boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const CollectionTransferSettings: React.FC<{
|
|
20
|
+
services: TransferServices;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './plugin';
|