legispro-cli 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +696 -0
  3. package/bin/dev +17 -0
  4. package/bin/dev.cmd +3 -0
  5. package/bin/run +5 -0
  6. package/bin/run.cmd +3 -0
  7. package/dist/commands/backup/create.d.ts +7 -0
  8. package/dist/commands/backup/create.js +26 -0
  9. package/dist/commands/backup/list.d.ts +7 -0
  10. package/dist/commands/backup/list.js +38 -0
  11. package/dist/commands/collection/add.d.ts +12 -0
  12. package/dist/commands/collection/add.js +108 -0
  13. package/dist/commands/collection/create.d.ts +14 -0
  14. package/dist/commands/collection/create.js +132 -0
  15. package/dist/commands/collection/delete.d.ts +10 -0
  16. package/dist/commands/collection/delete.js +53 -0
  17. package/dist/commands/collection/download.d.ts +11 -0
  18. package/dist/commands/collection/download.js +87 -0
  19. package/dist/commands/collection/get.d.ts +10 -0
  20. package/dist/commands/collection/get.js +54 -0
  21. package/dist/commands/collection/list.d.ts +7 -0
  22. package/dist/commands/collection/list.js +25 -0
  23. package/dist/commands/collection/perms.d.ts +12 -0
  24. package/dist/commands/collection/perms.js +82 -0
  25. package/dist/commands/collection/update.d.ts +16 -0
  26. package/dist/commands/collection/update.js +174 -0
  27. package/dist/commands/collection/upload.d.ts +12 -0
  28. package/dist/commands/collection/upload.js +127 -0
  29. package/dist/commands/config/get.d.ts +1 -0
  30. package/dist/commands/config/get.js +19 -0
  31. package/dist/commands/config/set.d.ts +1 -0
  32. package/dist/commands/config/set.js +125 -0
  33. package/dist/commands/db/init.d.ts +7 -0
  34. package/dist/commands/db/init.js +90 -0
  35. package/dist/commands/db/memory.d.ts +7 -0
  36. package/dist/commands/db/memory.js +27 -0
  37. package/dist/commands/db/uptime.d.ts +7 -0
  38. package/dist/commands/db/uptime.js +17 -0
  39. package/dist/commands/db/version.d.ts +7 -0
  40. package/dist/commands/db/version.js +17 -0
  41. package/dist/commands/document/copy.d.ts +7 -0
  42. package/dist/commands/document/copy.js +35 -0
  43. package/dist/commands/document/list.d.ts +7 -0
  44. package/dist/commands/document/list.js +34 -0
  45. package/dist/commands/group/create.d.ts +14 -0
  46. package/dist/commands/group/create.js +132 -0
  47. package/dist/commands/group/delete.d.ts +10 -0
  48. package/dist/commands/group/delete.js +50 -0
  49. package/dist/commands/group/get.d.ts +10 -0
  50. package/dist/commands/group/get.js +51 -0
  51. package/dist/commands/group/list.d.ts +7 -0
  52. package/dist/commands/group/list.js +20 -0
  53. package/dist/commands/group/update.d.ts +14 -0
  54. package/dist/commands/group/update.js +132 -0
  55. package/dist/commands/locks/add.d.ts +7 -0
  56. package/dist/commands/locks/add.js +80 -0
  57. package/dist/commands/locks/clear.d.ts +7 -0
  58. package/dist/commands/locks/clear.js +23 -0
  59. package/dist/commands/locks/list.d.ts +7 -0
  60. package/dist/commands/locks/list.js +86 -0
  61. package/dist/commands/services/health.d.ts +8 -0
  62. package/dist/commands/services/health.js +66 -0
  63. package/dist/commands/user/create.d.ts +26 -0
  64. package/dist/commands/user/create.js +374 -0
  65. package/dist/commands/user/delete.d.ts +10 -0
  66. package/dist/commands/user/delete.js +58 -0
  67. package/dist/commands/user/get.d.ts +10 -0
  68. package/dist/commands/user/get.js +53 -0
  69. package/dist/commands/user/list.d.ts +7 -0
  70. package/dist/commands/user/list.js +24 -0
  71. package/dist/commands/user/login.d.ts +13 -0
  72. package/dist/commands/user/login.js +93 -0
  73. package/dist/commands/user/update.d.ts +25 -0
  74. package/dist/commands/user/update.js +267 -0
  75. package/dist/index.d.ts +1 -0
  76. package/dist/index.js +5 -0
  77. package/dist/lib/fusiondb-client.d.ts +52 -0
  78. package/dist/lib/fusiondb-client.js +655 -0
  79. package/dist/lib/rclone-client.d.ts +11 -0
  80. package/dist/lib/rclone-client.js +41 -0
  81. package/dist/lib/types.d.ts +79 -0
  82. package/dist/lib/types.js +2 -0
  83. package/dist/lib/utils.d.ts +4 -0
  84. package/dist/lib/utils.js +7 -0
  85. package/dist/lib/xml-templates.d.ts +6 -0
  86. package/dist/lib/xml-templates.js +66 -0
  87. package/oclif.manifest.json +1063 -0
  88. package/package.json +98 -0
package/bin/run ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ const oclif = require('@oclif/core')
4
+
5
+ oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class BackupCreate extends Command {
3
+ run(): Promise<void>;
4
+ static description: string;
5
+ static examples: string[];
6
+ }
7
+ export default BackupCreate;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const utils_1 = require("../../lib/utils");
6
+ const ora_1 = tslib_1.__importDefault(require("ora"));
7
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ class BackupCreate extends core_1.Command {
9
+ async run() {
10
+ utils_1.client.setConfig(this);
11
+ const Spinner = (0, ora_1.default)({
12
+ text: `${chalk_1.default.bold.blue('Creating backup...')}`
13
+ }).start();
14
+ let response = await utils_1.client.backupDatabase();
15
+ if (response.status == 200) {
16
+ Spinner.stopAndPersist({
17
+ symbol: "✨",
18
+ text: `${chalk_1.default.bold.green('Backup complete!')}`
19
+ });
20
+ this.exit();
21
+ }
22
+ }
23
+ }
24
+ BackupCreate.description = "Create a database backup";
25
+ BackupCreate.examples = [`$ legispro backup:create`,];
26
+ exports.default = BackupCreate;
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class BackupList extends Command {
3
+ run(): Promise<void>;
4
+ static description: string;
5
+ static examples: string[];
6
+ }
7
+ export default BackupList;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const utils_1 = require("../../lib/utils");
6
+ const ora_1 = tslib_1.__importDefault(require("ora"));
7
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ const xml2js = require('xml2js');
9
+ const stripNS = require('xml2js').processors.stripPrefix;
10
+ class BackupList extends core_1.Command {
11
+ async run() {
12
+ utils_1.client.setConfig(this);
13
+ const Spinner = (0, ora_1.default)({
14
+ text: `${chalk_1.default.bold.blue('Looking for backups...')}`
15
+ }).start();
16
+ let response = await utils_1.client.listBackups();
17
+ if (response.status == 200) {
18
+ // convert xml response to json
19
+ xml2js.parseString(response.data.results, { mergeAttrs: true,
20
+ explicitArray: false,
21
+ tagNameProcessors: [stripNS] }, (err, result) => {
22
+ if (err) {
23
+ throw err;
24
+ }
25
+ const json = JSON.stringify(result.directory.backup, null, 4);
26
+ this.log(json);
27
+ });
28
+ Spinner.stopAndPersist({
29
+ symbol: "✨",
30
+ text: `${chalk_1.default.bold.green('Done')}`
31
+ });
32
+ this.exit();
33
+ }
34
+ }
35
+ }
36
+ BackupList.description = "List all database backups";
37
+ BackupList.examples = [`$ legispro backup:list`,];
38
+ exports.default = BackupList;
@@ -0,0 +1,12 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class CollectionAdd extends Command {
3
+ run(): Promise<void>;
4
+ static flags: {
5
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
+ file: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ mediaType: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ };
9
+ static description: string;
10
+ static examples: string[];
11
+ }
12
+ export default CollectionAdd;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const utils_1 = require("../../lib/utils");
6
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
+ const enquirer_1 = require("enquirer");
8
+ const path_1 = tslib_1.__importDefault(require("path"));
9
+ class CollectionAdd extends core_1.Command {
10
+ async run() {
11
+ const configFile = path_1.default.join(this.config.configDir, 'config.json');
12
+ const env = require(configFile);
13
+ utils_1.client.setConfig(this);
14
+ const { flags } = await this.parse(CollectionAdd);
15
+ let modes = {
16
+ "shared": 'rwxrwsr-T',
17
+ 'library': 'rwxr-sr-T',
18
+ 'user': 'rwxrwsr-T',
19
+ };
20
+ let projectObject = {};
21
+ let collection_uri = '';
22
+ let collection_type = 'user';
23
+ if (Object.keys(flags).length == 0) {
24
+ const res = await (0, enquirer_1.prompt)([
25
+ {
26
+ type: 'input',
27
+ name: 'name',
28
+ message: 'Name',
29
+ required: true
30
+ },
31
+ {
32
+ type: 'input',
33
+ name: 'file',
34
+ message: 'File',
35
+ required: true
36
+ },
37
+ {
38
+ type: 'select',
39
+ name: 'mediaType',
40
+ message: 'Media type',
41
+ required: true,
42
+ choices: ['application/xml', 'application/text'],
43
+ skip: false
44
+ },
45
+ ]);
46
+ for (const key in res) {
47
+ if (res.hasOwnProperty(key)) {
48
+ // @ts-ignore
49
+ flags[key] = res[key];
50
+ }
51
+ }
52
+ }
53
+ if (flags.name && flags.file && flags.mediaType) {
54
+ collection_uri = '/db/repository/' + flags.name;
55
+ // check if collection exists
56
+ let exists = await utils_1.client.existsCollection(collection_uri);
57
+ if (!exists) {
58
+ this.log(`Collection: ${chalk_1.default.magenta(flags.name)} not found.`);
59
+ this.exit();
60
+ }
61
+ // determine collection type so you can apply the correct mode
62
+ projectObject = await utils_1.client.getCollectionProject(collection_uri);
63
+ if (projectObject != null) {
64
+ collection_type = projectObject.type;
65
+ }
66
+ const path = require("path");
67
+ const fs = require("fs");
68
+ const file = path.basename(flags.file);
69
+ const buffer = fs.readFileSync(flags.file);
70
+ let document = {
71
+ uri: collection_uri + "/" + file,
72
+ mediaType: flags.mediaType,
73
+ binaryDoc: false,
74
+ owner: (collection_type == 'user') ? flags.name : 'admin',
75
+ group: env.group,
76
+ mode: modes[collection_type]
77
+ };
78
+ let response = await utils_1.client.createDocument(collection_uri + "/" + file, buffer);
79
+ if (response.status == 201) {
80
+ let update_doc_props_response = await utils_1.client.updateDocumentProperties(document);
81
+ //console.log(update_doc_props_response);
82
+ this.log("File added: " + flags.file);
83
+ this.exit();
84
+ }
85
+ else {
86
+ this.log(`Error: (${response.status}) - ${response.statusText}`);
87
+ this.exit();
88
+ }
89
+ }
90
+ }
91
+ }
92
+ CollectionAdd.flags = {
93
+ name: core_1.Flags.string({
94
+ description: 'Name',
95
+ required: false
96
+ }),
97
+ file: core_1.Flags.string({
98
+ description: 'File',
99
+ required: false
100
+ }),
101
+ mediaType: core_1.Flags.string({
102
+ description: 'Media type',
103
+ required: false
104
+ }),
105
+ };
106
+ CollectionAdd.description = "Add document to collection";
107
+ CollectionAdd.examples = [`$ legispro collection:add`,];
108
+ exports.default = CollectionAdd;
@@ -0,0 +1,14 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class CollectionCreate extends Command {
3
+ run(): Promise<void>;
4
+ static flags: {
5
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
+ title: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ baseURI: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ defaultExt: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ type: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ };
11
+ static description: string;
12
+ static examples: string[];
13
+ }
14
+ export default CollectionCreate;
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const utils_1 = require("../../lib/utils");
6
+ const enquirer_1 = require("enquirer");
7
+ const path_1 = tslib_1.__importDefault(require("path"));
8
+ const treeify = require('treeify');
9
+ class CollectionCreate extends core_1.Command {
10
+ async run() {
11
+ const configFile = path_1.default.join(this.config.configDir, 'config.json');
12
+ const env = require(configFile);
13
+ utils_1.client.setConfig(this);
14
+ const { flags } = await this.parse(CollectionCreate);
15
+ // prompts
16
+ if (Object.keys(flags).length == 0) {
17
+ const res = await (0, enquirer_1.prompt)([
18
+ {
19
+ type: 'input',
20
+ name: 'name',
21
+ message: 'Name',
22
+ required: true
23
+ },
24
+ {
25
+ type: 'input',
26
+ name: 'title',
27
+ message: 'Title',
28
+ required: true
29
+ },
30
+ {
31
+ type: 'input',
32
+ name: 'baseURI',
33
+ message: 'Base URI',
34
+ initial: '/akn/' + env.group,
35
+ required: true
36
+ },
37
+ {
38
+ type: 'input',
39
+ name: 'defaultExt',
40
+ message: 'Default Extension',
41
+ initial: 'akn',
42
+ required: true
43
+ },
44
+ {
45
+ type: 'select',
46
+ name: 'type',
47
+ message: 'Type',
48
+ required: true,
49
+ choices: ['shared', 'library', 'user']
50
+ },
51
+ ]);
52
+ for (const key in res) {
53
+ if (res.hasOwnProperty(key)) {
54
+ // @ts-ignore
55
+ flags[key] = res[key];
56
+ }
57
+ }
58
+ }
59
+ // mode types
60
+ let mode = '';
61
+ if (flags.type == 'shared') {
62
+ mode = 'rwxrwsr-T';
63
+ }
64
+ if (flags.type == 'library') {
65
+ mode = 'rwxr-sr-T';
66
+ }
67
+ if (flags.type == 'user') {
68
+ mode = 'rwxrwsr-T';
69
+ }
70
+ let collection = {
71
+ uri: '/db/repository/' + flags.name,
72
+ owner: 'admin',
73
+ group: env.group,
74
+ mode: mode,
75
+ };
76
+ // 1. Create collection
77
+ let create_response = await utils_1.client.createCollection(collection);
78
+ let modify_response = await utils_1.client.modifyCollection(collection);
79
+ // 2. Add a .project.xml file to it
80
+ let project_uri = '/db/repository/' + flags.name + '/.project.xml';
81
+ let project_xml_mode = 'rw-r--r--';
82
+ let projectXml = `<project xmlns="http://www.xcential.com/schemas/docs">
83
+ <name>${flags.name}</name>
84
+ <title>${flags.title}</title>
85
+ <baseURI>${flags.baseURI}</baseURI>
86
+ <defaultExt>${flags.defaultExt}</defaultExt>
87
+ <type>${flags.type}</type>
88
+ </project>`;
89
+ const buffer = Buffer.from(projectXml, "utf-8");
90
+ let project_xml_document = {
91
+ uri: project_uri,
92
+ mediaType: "application/xml",
93
+ binaryDoc: false,
94
+ owner: 'admin',
95
+ group: env.group,
96
+ mode: project_xml_mode
97
+ };
98
+ let project_xml_response = await utils_1.client.createDocument(project_uri, buffer);
99
+ let update_doc_props_response = await utils_1.client.updateDocumentProperties(project_xml_document);
100
+ let list_response = await utils_1.client.getCollection(collection.uri);
101
+ this.log(treeify.asTree(list_response, true));
102
+ if (list_response.status == 200) {
103
+ this.log(`Collection: ${flags.name} created`);
104
+ }
105
+ this.exit();
106
+ }
107
+ }
108
+ CollectionCreate.flags = {
109
+ name: core_1.Flags.string({
110
+ description: 'Name',
111
+ required: false
112
+ }),
113
+ title: core_1.Flags.string({
114
+ description: 'Title',
115
+ required: false
116
+ }),
117
+ baseURI: core_1.Flags.string({
118
+ description: 'Base URI',
119
+ required: false
120
+ }),
121
+ defaultExt: core_1.Flags.string({
122
+ description: 'Default extension',
123
+ required: false
124
+ }),
125
+ type: core_1.Flags.string({
126
+ description: 'Collection type',
127
+ required: false
128
+ }),
129
+ };
130
+ CollectionCreate.description = "Create a collection";
131
+ CollectionCreate.examples = [`$ legispro collection:create`,];
132
+ exports.default = CollectionCreate;
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class CollectionDelete extends Command {
3
+ run(): Promise<void>;
4
+ static flags: {
5
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
+ };
7
+ static description: string;
8
+ static examples: string[];
9
+ }
10
+ export default CollectionDelete;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const utils_1 = require("../../lib/utils");
6
+ const enquirer_1 = require("enquirer");
7
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ class CollectionDelete extends core_1.Command {
9
+ async run() {
10
+ utils_1.client.setConfig(this);
11
+ const { flags } = await this.parse(CollectionDelete);
12
+ // prompts
13
+ if (Object.keys(flags).length == 0) {
14
+ const res = await (0, enquirer_1.prompt)([
15
+ {
16
+ type: 'input',
17
+ name: 'name',
18
+ message: 'Name',
19
+ required: true
20
+ },
21
+ ]);
22
+ for (const key in res) {
23
+ if (res.hasOwnProperty(key)) {
24
+ // @ts-ignore
25
+ flags[key] = res[key];
26
+ }
27
+ }
28
+ }
29
+ if (flags.name) {
30
+ let collection_uri = '/db/repository/' + flags.name;
31
+ // check if collection exists
32
+ let exists = await utils_1.client.existsCollection(collection_uri);
33
+ if (!exists) {
34
+ this.log(`Collection: ${chalk_1.default.magenta(flags.name)} not found.`);
35
+ this.exit();
36
+ }
37
+ let response = await utils_1.client.deleteCollection(collection_uri);
38
+ if (response.status == 204) {
39
+ this.log(`Collection: ${chalk_1.default.magenta(flags.name)} deleted.`);
40
+ this.exit();
41
+ }
42
+ }
43
+ }
44
+ }
45
+ CollectionDelete.flags = {
46
+ name: core_1.Flags.string({
47
+ description: 'Name',
48
+ required: false
49
+ }),
50
+ };
51
+ CollectionDelete.description = "Delete a collection";
52
+ CollectionDelete.examples = [`$ legispro collection:delete`,];
53
+ exports.default = CollectionDelete;
@@ -0,0 +1,11 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class CollectionDownload extends Command {
3
+ run(): Promise<void>;
4
+ static flags: {
5
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
+ dest: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ };
8
+ static description: string;
9
+ static examples: string[];
10
+ }
11
+ export default CollectionDownload;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const utils_1 = require("../../lib/utils");
6
+ const enquirer_1 = require("enquirer");
7
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ const path_1 = tslib_1.__importDefault(require("path"));
9
+ const rclone = require("rclone.js").promises;
10
+ const fs = require('fs');
11
+ class CollectionDownload extends core_1.Command {
12
+ async run() {
13
+ const configFile = path_1.default.join(this.config.configDir, 'config.json');
14
+ const env = require(configFile);
15
+ utils_1.client.setConfig(this);
16
+ const { flags } = await this.parse(CollectionDownload);
17
+ // prompts
18
+ if (Object.keys(flags).length == 0) {
19
+ const res = await (0, enquirer_1.prompt)([
20
+ {
21
+ type: 'input',
22
+ name: 'name',
23
+ message: 'Name',
24
+ required: true
25
+ },
26
+ {
27
+ type: 'input',
28
+ name: 'dest',
29
+ message: 'Destination folder',
30
+ required: true
31
+ },
32
+ ]);
33
+ for (const key in res) {
34
+ if (res.hasOwnProperty(key)) {
35
+ // @ts-ignore
36
+ flags[key] = res[key];
37
+ }
38
+ }
39
+ }
40
+ if (flags.name && flags.dest) {
41
+ let collection_uri = '/db/repository/' + flags.name;
42
+ // check if collection exists
43
+ let exists = await utils_1.client.existsCollection(collection_uri);
44
+ if (!exists) {
45
+ this.log(`Collection: ${chalk_1.default.magenta(flags.name)} not found.`);
46
+ this.exit();
47
+ }
48
+ // check if local folder exists
49
+ fs.access(flags.dest, (err) => {
50
+ if (err) {
51
+ this.log(`Destination folder: ${flags.dest} not found.`);
52
+ //this.exit();
53
+ process.exit();
54
+ }
55
+ });
56
+ let obscured_password = (await rclone.obscure(env.password)).toString().trim();
57
+ let copy_response;
58
+ try {
59
+ copy_response = await rclone.copy(":webdav:" + collection_uri, flags.dest, {
60
+ "webdav-url": env.protocol + "://" + env.hostname + ":" + env.port + "/exist/webdav/",
61
+ "webdav-user": env.user,
62
+ "webdav-pass": obscured_password
63
+ });
64
+ }
65
+ catch (error) {
66
+ console.log('\r\n');
67
+ console.log(error.toString());
68
+ }
69
+ console.log(JSON.stringify(copy_response, null, '\t'));
70
+ //console.log(copy_response.toString());
71
+ this.exit();
72
+ }
73
+ }
74
+ }
75
+ CollectionDownload.flags = {
76
+ name: core_1.Flags.string({
77
+ description: 'Name',
78
+ required: false
79
+ }),
80
+ dest: core_1.Flags.string({
81
+ description: 'Destination folder',
82
+ required: false
83
+ }),
84
+ };
85
+ CollectionDownload.description = "Download files from collection";
86
+ CollectionDownload.examples = [`$ legispro collection:download`,];
87
+ exports.default = CollectionDownload;
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class CollectionGet extends Command {
3
+ run(): Promise<void>;
4
+ static flags: {
5
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
+ };
7
+ static description: string;
8
+ static examples: string[];
9
+ }
10
+ export default CollectionGet;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const utils_1 = require("../../lib/utils");
6
+ const enquirer_1 = require("enquirer");
7
+ const treeify = require('treeify');
8
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
9
+ class CollectionGet extends core_1.Command {
10
+ async run() {
11
+ utils_1.client.setConfig(this);
12
+ const { flags } = await this.parse(CollectionGet);
13
+ // prompts
14
+ if (Object.keys(flags).length == 0) {
15
+ const res = await (0, enquirer_1.prompt)([
16
+ {
17
+ type: 'input',
18
+ name: 'name',
19
+ message: 'Name',
20
+ required: true
21
+ },
22
+ ]);
23
+ for (const key in res) {
24
+ if (res.hasOwnProperty(key)) {
25
+ // @ts-ignore
26
+ flags[key] = res[key];
27
+ }
28
+ }
29
+ }
30
+ if (flags.name) {
31
+ let collection_uri = '/db/repository/' + flags.name;
32
+ // check if collection exists
33
+ let exists = await utils_1.client.existsCollection(collection_uri);
34
+ if (!exists) {
35
+ this.log(`Collection: ${chalk_1.default.magenta(flags.name)} not found.`);
36
+ this.exit();
37
+ }
38
+ let list_response = await utils_1.client.getCollection(collection_uri);
39
+ //if (list_response.status == 200) {
40
+ this.log(treeify.asTree(list_response, true));
41
+ this.exit();
42
+ //}
43
+ }
44
+ }
45
+ }
46
+ CollectionGet.flags = {
47
+ name: core_1.Flags.string({
48
+ description: 'Name',
49
+ required: false
50
+ }),
51
+ };
52
+ CollectionGet.description = "Get collection info & contents";
53
+ CollectionGet.examples = [`$ legispro collection:get`,];
54
+ exports.default = CollectionGet;
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class CollectionList extends Command {
3
+ run(): Promise<void>;
4
+ static description: string;
5
+ static examples: string[];
6
+ }
7
+ export default CollectionList;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const utils_1 = require("../../lib/utils");
6
+ const treeify = require('treeify');
7
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
+ class CollectionList extends core_1.Command {
9
+ async run() {
10
+ utils_1.client.setConfig(this);
11
+ let collection_uri = '/db/repository';
12
+ // check if collection exists
13
+ let exists = await utils_1.client.existsCollection(collection_uri);
14
+ if (!exists) {
15
+ this.log(`Collection: ${chalk_1.default.magenta("repository")} not found.`);
16
+ this.exit();
17
+ }
18
+ let list_response = await utils_1.client.getCollection(collection_uri);
19
+ this.log(treeify.asTree(list_response, true));
20
+ this.exit();
21
+ }
22
+ }
23
+ CollectionList.description = "List collections";
24
+ CollectionList.examples = [`$ legispro collection:list`,];
25
+ exports.default = CollectionList;
@@ -0,0 +1,12 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class CollectionPerms extends Command {
3
+ run(): Promise<void>;
4
+ static flags: {
5
+ name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
+ source: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ type: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ };
9
+ static description: string;
10
+ static examples: string[];
11
+ }
12
+ export default CollectionPerms;