@remit/config-transfer 0.0.1 → 0.0.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/package.json +1 -1
- package/src/binder.ts +184 -0
- package/src/import-repositories.ts +97 -0
- package/src/import.test.ts +1178 -0
- package/src/import.ts +1165 -0
- package/src/index.ts +29 -0
- package/src/report.ts +69 -0
package/src/index.ts
CHANGED
|
@@ -1,4 +1,33 @@
|
|
|
1
|
+
export {
|
|
2
|
+
type BindResult,
|
|
3
|
+
bindImportedFolders,
|
|
4
|
+
type ConfigBinderDeps,
|
|
5
|
+
type ConfigBinderRepositories,
|
|
6
|
+
pendingImportOf,
|
|
7
|
+
} from "./binder.js";
|
|
1
8
|
export { carriesUserFlag, readConfigForExport } from "./export.js";
|
|
9
|
+
export {
|
|
10
|
+
ANCHOR_EMBEDDING_PENDING,
|
|
11
|
+
type ImportConfigInput,
|
|
12
|
+
importConfig,
|
|
13
|
+
} from "./import.js";
|
|
14
|
+
export type {
|
|
15
|
+
AppointFolderRole,
|
|
16
|
+
ConfigImportDeps,
|
|
17
|
+
ConfigImportRepositories,
|
|
18
|
+
EmbedAnchor,
|
|
19
|
+
} from "./import-repositories.js";
|
|
20
|
+
export {
|
|
21
|
+
type ConfigImportConflict,
|
|
22
|
+
type ConfigImportItemReport,
|
|
23
|
+
type ConfigImportOutcome,
|
|
24
|
+
type ConfigImportProblem,
|
|
25
|
+
type ConfigImportReport,
|
|
26
|
+
ConfigImportSection,
|
|
27
|
+
type ConfigImportSectionValue,
|
|
28
|
+
ConfigImportVerdict,
|
|
29
|
+
type ConfigImportVerdictValue,
|
|
30
|
+
} from "./report.js";
|
|
2
31
|
export type {
|
|
3
32
|
ConfigExportIdentity,
|
|
4
33
|
ConfigExportRepositories,
|
package/src/report.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which part of the document an item came from. The wire model spells these as
|
|
3
|
+
* a plain string, so the closed set lives here rather than in the API contract.
|
|
4
|
+
*/
|
|
5
|
+
export const ConfigImportSection = {
|
|
6
|
+
Accounts: "accounts",
|
|
7
|
+
Labels: "labels",
|
|
8
|
+
Filters: "filters",
|
|
9
|
+
AddressFlags: "addressFlags",
|
|
10
|
+
Settings: "settings",
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
13
|
+
export type ConfigImportSectionValue =
|
|
14
|
+
(typeof ConfigImportSection)[keyof typeof ConfigImportSection];
|
|
15
|
+
|
|
16
|
+
export const ConfigImportVerdict = {
|
|
17
|
+
Created: "created",
|
|
18
|
+
Updated: "updated",
|
|
19
|
+
Unchanged: "unchanged",
|
|
20
|
+
Skipped: "skipped",
|
|
21
|
+
Rejected: "rejected",
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
export type ConfigImportVerdictValue =
|
|
25
|
+
(typeof ConfigImportVerdict)[keyof typeof ConfigImportVerdict];
|
|
26
|
+
|
|
27
|
+
export interface ConfigImportItemReport {
|
|
28
|
+
section: ConfigImportSectionValue;
|
|
29
|
+
key: string;
|
|
30
|
+
verdict: ConfigImportVerdictValue;
|
|
31
|
+
reason?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The flat error shape the API emits: a code a client branches on, and text. */
|
|
35
|
+
export interface ConfigImportProblem {
|
|
36
|
+
code: string;
|
|
37
|
+
message: string;
|
|
38
|
+
details?: Record<string, string>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ConfigImportReport {
|
|
42
|
+
importId?: string;
|
|
43
|
+
valid: boolean;
|
|
44
|
+
schemaVersion: number;
|
|
45
|
+
applied: boolean;
|
|
46
|
+
items: ConfigImportItemReport[];
|
|
47
|
+
errors: ConfigImportProblem[];
|
|
48
|
+
warnings: ConfigImportProblem[];
|
|
49
|
+
accountsNeedingCredentials: string[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The refusal a non-empty configuration answers with under `onExisting: abort`.
|
|
54
|
+
* Separate from the report because it is a different status code, not a
|
|
55
|
+
* different verdict: nothing about the document was wrong.
|
|
56
|
+
*/
|
|
57
|
+
export interface ConfigImportConflict {
|
|
58
|
+
code: "config_not_empty";
|
|
59
|
+
message: string;
|
|
60
|
+
details: Record<string, string>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A rejected document is an answer, not a fault, so the import returns which
|
|
65
|
+
* of the two it produced rather than throwing one of them.
|
|
66
|
+
*/
|
|
67
|
+
export type ConfigImportOutcome =
|
|
68
|
+
| { outcome: "report"; report: ConfigImportReport }
|
|
69
|
+
| { outcome: "conflict"; conflict: ConfigImportConflict };
|