@crombolo/transfer 0.24.1 → 0.26.0
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/package.json +3 -3
- package/src/check.ts +11 -3
- package/src/load.ts +14 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/transfer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Content transfer for crombolo: bundles of content moved between environments.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@crombolo/core": "0.
|
|
32
|
-
"@crombolo/data": "0.
|
|
31
|
+
"@crombolo/core": "0.26.0",
|
|
32
|
+
"@crombolo/data": "0.26.0"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/check.ts
CHANGED
|
@@ -193,6 +193,8 @@ export interface CheckOptions {
|
|
|
193
193
|
backOfficePath?: string
|
|
194
194
|
/** Users here the bundle's may take over by e-mail or username: a site this boot created. */
|
|
195
195
|
adoptUsers?: boolean
|
|
196
|
+
/** The bundle's members, member groups, users and user groups are left out entirely. */
|
|
197
|
+
excludePeople?: boolean
|
|
196
198
|
}
|
|
197
199
|
|
|
198
200
|
/** What the import would do to one node. */
|
|
@@ -218,6 +220,8 @@ export interface TransferCheck {
|
|
|
218
220
|
counts: { create: number; update: number; unchanged: number; skip: number }
|
|
219
221
|
/** What the bundle's people would do here, when it carries any. */
|
|
220
222
|
people?: PeoplePlan
|
|
223
|
+
/** What the bundle carried of people and `excludePeople` left out, by count. */
|
|
224
|
+
peopleExcluded?: { memberGroups: number; members: number; userGroups: number; users: number }
|
|
221
225
|
}
|
|
222
226
|
|
|
223
227
|
const documentLink = (backOfficePath: string | undefined, key: string): string | null =>
|
|
@@ -700,7 +704,8 @@ export async function checkBundle(
|
|
|
700
704
|
])
|
|
701
705
|
).map((row) => String(row.text)),
|
|
702
706
|
)
|
|
703
|
-
|
|
707
|
+
const carriedPeople = options.excludePeople ? undefined : set.people
|
|
708
|
+
for (const group of carriedPeople?.memberGroups ?? []) groupsHere.add(group.name)
|
|
704
709
|
const skipped = new Set(plan.filter((p) => p.action === 'skip').map((p) => p.key))
|
|
705
710
|
for (const node of set.nodes) {
|
|
706
711
|
if (!node.access || skipped.has(node.key)) continue
|
|
@@ -735,8 +740,8 @@ export async function checkBundle(
|
|
|
735
740
|
})
|
|
736
741
|
}
|
|
737
742
|
|
|
738
|
-
const people =
|
|
739
|
-
? await planPeople(db,
|
|
743
|
+
const people = carriedPeople
|
|
744
|
+
? await planPeople(db, carriedPeople, {
|
|
740
745
|
resolutions,
|
|
741
746
|
resolveAll: options.resolveAll,
|
|
742
747
|
adoptUsers: options.adoptUsers,
|
|
@@ -752,5 +757,8 @@ export async function checkBundle(
|
|
|
752
757
|
plan,
|
|
753
758
|
counts,
|
|
754
759
|
...(people ? { people } : {}),
|
|
760
|
+
...(options.excludePeople && set.manifest.people
|
|
761
|
+
? { peopleExcluded: { ...set.manifest.people.counts } }
|
|
762
|
+
: {}),
|
|
755
763
|
}
|
|
756
764
|
}
|
package/src/load.ts
CHANGED
|
@@ -501,11 +501,20 @@ export interface OpenedBundle {
|
|
|
501
501
|
* passphrase and `SealedFileError` for a file altered or moved; a bundle with
|
|
502
502
|
* nothing sealed opens without one.
|
|
503
503
|
*/
|
|
504
|
-
export function openBundle(
|
|
504
|
+
export function openBundle(
|
|
505
|
+
loaded: LoadedBundle,
|
|
506
|
+
passphrase: string | undefined,
|
|
507
|
+
options: { withoutPeople?: boolean } = {},
|
|
508
|
+
): OpenedBundle {
|
|
505
509
|
const set = loaded.set
|
|
506
510
|
if (!set) throw new Error('The bundle could not be read, so there is nothing to open.')
|
|
507
511
|
const params = set.manifest.seal
|
|
508
512
|
if (!set.sealed || !params) return { set, people: undefined, openBlob: (_key, bytes) => bytes }
|
|
513
|
+
// People left behind need no passphrase when nothing else is sealed.
|
|
514
|
+
if (options.withoutPeople && set.manifest.content !== 'sealed') {
|
|
515
|
+
const { sealed: _sealed, ...open } = set
|
|
516
|
+
return { set: open, people: undefined, openBlob: (_key, bytes) => bytes }
|
|
517
|
+
}
|
|
509
518
|
const key = unlock(passphrase ?? '', params)
|
|
510
519
|
const nodes = set.nodes.map((node) => {
|
|
511
520
|
const path = valuesPath(node.key)
|
|
@@ -523,9 +532,10 @@ export function openBundle(loaded: LoadedBundle, passphrase: string | undefined)
|
|
|
523
532
|
: {}),
|
|
524
533
|
}
|
|
525
534
|
})
|
|
526
|
-
const people =
|
|
527
|
-
|
|
528
|
-
|
|
535
|
+
const people =
|
|
536
|
+
loaded.people && !options.withoutPeople
|
|
537
|
+
? openPeople(loaded.people.block, loaded.people.files, key)
|
|
538
|
+
: undefined
|
|
529
539
|
const sealedBlobs = set.manifest.content === 'sealed'
|
|
530
540
|
const { sealed: _sealed, ...rest } = set
|
|
531
541
|
return {
|