@webexatech/plugin-collection-transfer 0.1.2 → 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.
- package/CHANGELOG.md +40 -33
- package/README.md +158 -150
- package/dist/client/{949.3230de7f57066bc7.js → 949.72b7b97eaf5473f5.js} +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client-v2/{907.bed81d14270e80c6.js → 907.b7c707602a2b4e6c.js} +1 -1
- package/dist/client-v2/CollectionTransferSettings.d.ts +1 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/externalVersion.js +6 -6
- package/dist/locale/en-US.json +70 -70
- package/dist/locale/zh-CN.json +70 -70
- package/dist/node_modules/archiver/package.json +1 -1
- package/dist/node_modules/yauzl/index.js +1 -1
- package/dist/node_modules/yauzl/package.json +1 -1
- package/dist/server/resourcer.d.ts +2 -0
- package/dist/server/resourcer.js +47 -4
- package/package.json +1 -1
- package/dist/node_modules/yauzl/fd-slicer.js +0 -314
package/CHANGELOG.md
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this plugin are documented here. Versions follow [semver](https://semver.org/).
|
|
4
|
-
|
|
5
|
-
## 0.1.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this plugin are documented here. Versions follow [semver](https://semver.org/).
|
|
4
|
+
|
|
5
|
+
## 0.1.3
|
|
6
|
+
|
|
7
|
+
- Fixed: **Export failed with 502 behind a reverse proxy** (e.g. nginx). The export summary was sent in a response
|
|
8
|
+
header that outgrew the proxy's header buffer; exporting is now two requests (prepare, then download) and no data
|
|
9
|
+
travels in headers.
|
|
10
|
+
- Builds for each NocoBase line: `0.1.3-nocobase.2.1` (2.1.x), `0.1.3` (2.2.x), `0.1.3-nocobase.2.3` (2.3.x beta).
|
|
11
|
+
|
|
12
|
+
## 0.1.2 – NocoBase 2.2.x
|
|
13
|
+
|
|
14
|
+
Security hardening of the import (upgrade recommended):
|
|
15
|
+
|
|
16
|
+
- Raw `options` objects in collections, fields and relations are refused; they would otherwise bypass the checks on
|
|
17
|
+
top-level keys (for example `options.tableName`).
|
|
18
|
+
- Relation fields among a collection's plain fields are recognised by their registered field class, so relation types
|
|
19
|
+
added by plugins are refused there too.
|
|
20
|
+
- Reading data rows costs linear time up to the row size limit.
|
|
21
|
+
|
|
22
|
+
## 0.1.1 – NocoBase 2.2.x
|
|
23
|
+
|
|
24
|
+
Security hardening of the import (upgrade recommended):
|
|
25
|
+
|
|
26
|
+
- Relation fields are only accepted from `associations.json`; a relation hidden among a collection's plain fields is
|
|
27
|
+
refused, so a package cannot add fields or key columns to collections outside it.
|
|
28
|
+
- Archives are extracted by streaming each allowed entry to disk with per-entry and total size limits instead of
|
|
29
|
+
decompressing into memory; the compression-ratio check now applies from 10 MB.
|
|
30
|
+
- Data rows have a size limit (16 MB per row), so one oversized row cannot exhaust memory.
|
|
31
|
+
|
|
32
|
+
## 0.1.0 – NocoBase 2.2.x
|
|
33
|
+
|
|
34
|
+
- Export one or more general collections, with or without data, to a `.zip` package.
|
|
35
|
+
- Import with a preview that blocks unsupported or unsafe packages (missing dependencies, unknown field types or
|
|
36
|
+
field kinds, collections or tables outside the package, unsafe expressions).
|
|
37
|
+
- Per-collection conflict handling for existing collections: skip collection and import data, skip collection and
|
|
38
|
+
data, override without data, override with data (default), with a confirmation before deleting anything.
|
|
39
|
+
- *Created by* / *Updated by* of imported rows set to the importing user.
|
|
40
|
+
- Settings page in both the classic (`/admin`) and the new (`/v/admin`) admin UI; English and Chinese.
|
package/README.md
CHANGED
|
@@ -1,150 +1,158 @@
|
|
|
1
|
-
# @webexatech/plugin-collection-transfer
|
|
2
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
NocoBase
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
**
|
|
40
|
-
|
|
41
|
-
1.
|
|
42
|
-
2.
|
|
43
|
-
3.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
- a
|
|
73
|
-
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
1
|
+
# @webexatech/plugin-collection-transfer
|
|
2
|
+
|
|
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
|
+
NocoBase checks a plugin against the versions it was **built** with, per minor release, and shows a "dependency
|
|
10
|
+
version mismatch" warning otherwise. Each NocoBase minor therefore has its own build — install the one for your
|
|
11
|
+
NocoBase version:
|
|
12
|
+
|
|
13
|
+
| NocoBase | Plugin version | npm tag | Tested on |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| 2.1.x | `0.1.3-nocobase.2.1` | `nocobase-2.1` | 2.1.39 |
|
|
16
|
+
| 2.2.x | `0.1.3` | `nocobase-2.2`, `latest` | 2.2.50 |
|
|
17
|
+
| 2.3.x (beta) | `0.1.3-nocobase.2.3` | `nocobase-2.3` | 2.3.0-beta.26 |
|
|
18
|
+
|
|
19
|
+
All builds: PostgreSQL; settings page in the classic (`/admin`) and the new (`/v/admin`) admin UI. Source and target
|
|
20
|
+
must run the same database type.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
- **Plugin manager:** *Plugin manager → Add & update → npm registry*, package name
|
|
25
|
+
`@webexatech/plugin-collection-transfer`, registry `https://registry.npmjs.org`, and the plugin version from the
|
|
26
|
+
table above for your NocoBase version. Then enable it.
|
|
27
|
+
- **Upload:** *Plugin manager → Add & update → Upload*, choose the `.tgz` for your NocoBase version from the GitHub
|
|
28
|
+
release. Then enable it.
|
|
29
|
+
- **CLI:** `yarn pm add @webexatech/plugin-collection-transfer --registry=https://registry.npmjs.org --version=<version>`,
|
|
30
|
+
then `yarn pm enable @webexatech/plugin-collection-transfer`.
|
|
31
|
+
|
|
32
|
+
Updating works the same way (*Add & update*, or `yarn pm update … --registry=…`). The plugin stores no data of its
|
|
33
|
+
own, so updates need no migration.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
Open **Settings → Collection transfer** (admins only; ACL snippet `pm.collection-transfer`).
|
|
38
|
+
|
|
39
|
+
**Export tab**
|
|
40
|
+
|
|
41
|
+
1. Select the collections. Collection types that cannot be transferred are shown but disabled.
|
|
42
|
+
2. Turn on **Include data** to carry the rows as well.
|
|
43
|
+
3. Click **Export**. The result lists the join tables that were added automatically and the collections that must
|
|
44
|
+
already exist in the target (for example `users`, the target of *Created by*).
|
|
45
|
+
|
|
46
|
+
**Import tab**
|
|
47
|
+
|
|
48
|
+
1. Drop the `.zip`. Nothing is written yet.
|
|
49
|
+
2. The preview shows what will be created (fields and rows per collection) and every blocking problem.
|
|
50
|
+
3. For each collection that **already exists** in the target, choose:
|
|
51
|
+
|
|
52
|
+
| Option | Fields | Existing rows | Rows from the file |
|
|
53
|
+
| --- | --- | --- | --- |
|
|
54
|
+
| Skip collection, import data | kept | kept | added; rows whose id already exists are skipped |
|
|
55
|
+
| Skip collection and data | kept | kept | not imported |
|
|
56
|
+
| Override collection, without data | replaced | **deleted** | not imported |
|
|
57
|
+
| **Override collection and data** (default) | replaced | **deleted** | imported |
|
|
58
|
+
|
|
59
|
+
*Skip collection, import data* is only offered when the existing table has every column from the file.
|
|
60
|
+
Overriding a collection makes NocoBase remove the relation fields that point at it from other collections;
|
|
61
|
+
fields the file defines are re-created, and the preview lists any other field that would be lost.
|
|
62
|
+
4. Click **Import**. If anything is overridden, a confirmation lists what will be deleted. Everything runs in one
|
|
63
|
+
transaction and is rolled back completely on any error.
|
|
64
|
+
|
|
65
|
+
**Created by / Updated by** of every imported row is set to the admin who runs the import. User ids from the source
|
|
66
|
+
environment do not identify the same people in the target.
|
|
67
|
+
|
|
68
|
+
## What is checked before importing
|
|
69
|
+
|
|
70
|
+
The import is blocked when:
|
|
71
|
+
|
|
72
|
+
- a relation points at a collection that is neither in the file nor in the target
|
|
73
|
+
- a field type is not available in the target (a plugin that adds a server-side type is missing)
|
|
74
|
+
- a field kind is not available in the target UI (e.g. the *Code* field without `plugin-field-code`); the plugins
|
|
75
|
+
enabled in the source but not in the target are listed as a hint
|
|
76
|
+
- a database table with the same name exists without a collection, or a collection uses an unsupported template
|
|
77
|
+
- the file comes from a different database type or format version, or a name is too long for the database
|
|
78
|
+
- the file tries to change anything outside its own collections (other tables, fields on other collections)
|
|
79
|
+
- a title or UI schema contains a `{{ }}` expression other than a plain `{{t("…")}}` translation
|
|
80
|
+
- the file is not a valid package
|
|
81
|
+
|
|
82
|
+
The same checks run again when you click **Import**, in case the target changed after the preview.
|
|
83
|
+
|
|
84
|
+
## What it does not transfer
|
|
85
|
+
|
|
86
|
+
By design, the plugin moves **collection definitions and their rows only**. It does not transfer:
|
|
87
|
+
|
|
88
|
+
- pages, blocks and menus (UI schemas), workflows, role permissions, collection categories
|
|
89
|
+
- files behind attachment fields (the attachment records reference storage that differs per environment)
|
|
90
|
+
- relation fields that live on collections outside the file
|
|
91
|
+
|
|
92
|
+
Recreate those in the target, or use NocoBase's own tools for them.
|
|
93
|
+
|
|
94
|
+
**Collection types:** this edition transfers **general collections**. Tree, file, calendar, SQL, view, inherited,
|
|
95
|
+
FDW and expression collections are listed but cannot be selected.
|
|
96
|
+
|
|
97
|
+
## Known limitations
|
|
98
|
+
|
|
99
|
+
- Only the main data source; source and target must use the same database type (PostgreSQL tested).
|
|
100
|
+
- Primary-key conflicts are resolved per collection (skip or override), not per row; rows are not merged.
|
|
101
|
+
- Sequence counters, encrypted fields, sort scopes, custom primary keys and indexes defined in collection options are
|
|
102
|
+
not specially handled. A key column created by hand before its relation comes back with default display settings.
|
|
103
|
+
- Whole tables are read into memory on export, and there is no progress reporting for very large imports.
|
|
104
|
+
- Only import files from environments you trust.
|
|
105
|
+
|
|
106
|
+
## How it works
|
|
107
|
+
|
|
108
|
+
- **Export** reads the definitions from the `collections` / `fields` tables. Each collection is written in the shape
|
|
109
|
+
the UI sends to `collections:create`: scalar fields nested, relation fields stored once per pair with the other side
|
|
110
|
+
as `reverseField`, generated join-table and key-column names kept so the rows still line up. Rows are dumped per
|
|
111
|
+
table as NDJSON.
|
|
112
|
+
- **Import** creates the collections, then the relation fields; NocoBase's own hooks build tables, key columns, join
|
|
113
|
+
tables and reverse fields. The importer then verifies every expected join table, key field and column, inserts rows
|
|
114
|
+
in batches and moves serial id sequences past the imported ids.
|
|
115
|
+
|
|
116
|
+
### File format
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
manifest.json versions, dialect, collections, dependencies, source plugins
|
|
120
|
+
schema/collections.json collections (collections:create shape, scalar fields nested)
|
|
121
|
+
schema/associations.json relation fields (collections.fields:create shape, reverseField nested)
|
|
122
|
+
schema/through.json auto-created join tables recreated by NocoBase on import
|
|
123
|
+
data/<collection>/meta columns, row count, auto-increment column
|
|
124
|
+
data/<collection>/data one JSON array of column values per row (only with "Include data")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### API
|
|
128
|
+
|
|
129
|
+
| Action | Request | Response |
|
|
130
|
+
| --- | --- | --- |
|
|
131
|
+
| `collectionTransfer:listCollections` | `GET` | collections that can be selected |
|
|
132
|
+
| `collectionTransfer:export` | `POST { collections: string[], includeData: boolean }` | `{ token, fileName, manifest }`; the file is prepared for download |
|
|
133
|
+
| `collectionTransfer:download` | `GET ?token=…` | the `.zip`, once; prepared files expire after an hour |
|
|
134
|
+
| `collectionTransfer:preview` | `POST` multipart, field `file` | `token`, `problems`, `conflicts`, `interfaces` |
|
|
135
|
+
| `collectionTransfer:import` | `POST { token, resolutions: { [collection]: mode } }` | created / overridden / skipped, `rowCounts`; `409 { errors, problems }` when blocked |
|
|
136
|
+
|
|
137
|
+
Modes: `skipCollectionImportData`, `skipAll`, `overrideSchema`, `overrideAll`. Uploads are kept in
|
|
138
|
+
`<storage>/tmp/collection-transfer/` for one hour, and after a failed import so it can be retried with the same token.
|
|
139
|
+
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
The plugin lives at `packages/plugins/@webexatech/plugin-collection-transfer` inside a NocoBase source checkout.
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
yarn test packages/plugins/@webexatech/plugin-collection-transfer # server tests (separate DB via .env.test)
|
|
146
|
+
yarn eslint --fix packages/plugins/@webexatech/plugin-collection-transfer/src
|
|
147
|
+
bash scripts/check-plugin-peer-deps.sh packages/plugins/@webexa
|
|
148
|
+
yarn build @webexatech/plugin-collection-transfer --tar # storage/tar/@webexatech/…tgz
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The settings page is written once in `src/client-v2/CollectionTransferSettings.tsx` (no runtime imports) and mounted
|
|
152
|
+
by both the v2 client (`src/client-v2/SettingsPage.tsx`) and the classic client (`src/client/SettingsPage.tsx`).
|
|
153
|
+
The data dump logic and `FieldValueWriter` are adapted from `@nocobase/plugin-backup-restore`, which does not export
|
|
154
|
+
them.
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
Apache-2.0
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
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})}}}]);
|
|
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],N=D[1],R=(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(){R()},[R]);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")))}}],q=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),N(void 0),l.label=1;case 1:return l.trys.push([1,4,6,7]),[4,n.request({url:"collectionTransfer:export",method:"post",data:{collections:v,includeData:k}})];case 2:return r=null==(t=l.sent().data)?void 0:t.data,[4,n.request({url:"collectionTransfer:download",method:"get",params:{token:r.token},responseType:"blob"})];case 3:var o,i,c,s,u,d;return c=(a=l.sent()).data,s=r.fileName||(o=null==(e=a.headers)?void 0:e["content-disposition"],(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),N(r.manifest),[3,7];case 4:return[4,S(l.sent())];case 5:return P.apply(void 0,[l.sent()]),[3,7];case 6:return O(!1),[7];case 7: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},q.length>0&&l().createElement("span",null,e("Added because they are needed: {{names}}",{names:q.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],N=D[1],R=y((0,a.useState)(),2),F=R[0],q=R[1],M=y((0,a.useState)(),2),U=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(_)),K=!!(null==A?void 0:A.manifest.includeData),J=(null==A?void 0:A.conflicts)||[],G=J.filter(function(e){return C.includes(z[e.name])}),V=new Set(v(((null==A?void 0:A.manifest.collections)||[]).filter(function(e){return!J.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),N({}),q(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}}N(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 q(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 K?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=K&&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 N(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=!K&&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}),U&&l().createElement(i.Alert,{type:"error",showIcon:!0,message:U,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")},K?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}),J.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:J,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})}}}]);
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
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+".
|
|
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+".72b7b97eaf5473f5.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}()});
|