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
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const utils_1 = require("../../lib/utils");
5
+ class LocksAdd extends core_1.Command {
6
+ async run() {
7
+ utils_1.client.setConfig(this);
8
+ let etc_uri = '/db/etc';
9
+ let etc_coll_mode = 'rwxrws--T';
10
+ let etc_file_mode = 'rw-rw----';
11
+ const locksCollectionExists = await utils_1.client.existsCollection(etc_uri);
12
+ if (!locksCollectionExists) {
13
+ // Create etc collection
14
+ let collection = {
15
+ uri: etc_uri,
16
+ owner: 'admin',
17
+ group: 'users',
18
+ mode: etc_coll_mode,
19
+ };
20
+ let create_response = await utils_1.client.createCollection(collection);
21
+ let modify_response = await utils_1.client.modifyCollection(collection);
22
+ // Mods.xml
23
+ let modsExists = await utils_1.client.existsCollection(`${etc_uri}/Mods.xml`);
24
+ if (!modsExists) {
25
+ let mods_uri = `${etc_uri}/Mods.xml`;
26
+ let mods_xml = '<mods xmlns="http://www.xcential.com/schemas/mods/1.0" xmlns:d="DAV:" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></mods>';
27
+ const mods_buffer = Buffer.from(mods_xml, "utf-8");
28
+ let mods_xml_document = {
29
+ uri: mods_uri,
30
+ mediaType: "application/xml",
31
+ binaryDoc: false,
32
+ owner: 'admin',
33
+ group: 'users',
34
+ mode: etc_file_mode
35
+ };
36
+ let mods_xml_response = await utils_1.client.createDocument(mods_uri, mods_buffer);
37
+ let update_mods_xml_props_response = await utils_1.client.updateDocumentProperties(mods_xml_document);
38
+ // this.log(update_mods_xml_props_response);
39
+ if (update_mods_xml_props_response.status == 204) {
40
+ this.log('Mods.xml added');
41
+ }
42
+ else {
43
+ this.log('Error adding Mods.xml');
44
+ }
45
+ }
46
+ // Locks.xml
47
+ let locksExists = await utils_1.client.existsCollection(`${etc_uri}/Locks.xml`);
48
+ if (!locksExists) {
49
+ let locks_uri = `${etc_uri}/Locks.xml`;
50
+ let locks_xml = '<locks xmlns="http://www.xcential.com/schemas/locks/1.0" xmlns:d="DAV:" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></locks>';
51
+ const locks_buffer = Buffer.from(locks_xml, "utf-8");
52
+ let locks_xml_document = {
53
+ uri: locks_uri,
54
+ mediaType: "application/xml",
55
+ binaryDoc: false,
56
+ owner: 'admin',
57
+ group: 'users',
58
+ mode: etc_file_mode
59
+ };
60
+ let locks_xml_response = await utils_1.client.createDocument(locks_uri, locks_buffer);
61
+ let update_locks_xml_props_response = await utils_1.client.updateDocumentProperties(locks_xml_document);
62
+ // this.log(update_locks_xml_props_response);
63
+ if (update_locks_xml_props_response.status == 204) {
64
+ this.log('Locks.xml added');
65
+ }
66
+ else {
67
+ this.log('Error adding Locks.xml');
68
+ }
69
+ }
70
+ this.exit();
71
+ }
72
+ else {
73
+ this.log('Locks already exist.');
74
+ this.exit();
75
+ }
76
+ }
77
+ }
78
+ LocksAdd.description = "Add Locks and Mods XML files";
79
+ LocksAdd.examples = [`$ legispro locks:add`,];
80
+ exports.default = LocksAdd;
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class LocksClear extends Command {
3
+ run(): Promise<void>;
4
+ static description: string;
5
+ static examples: string[];
6
+ }
7
+ export default LocksClear;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const utils_1 = require("../../lib/utils");
5
+ const xpath = require('xpath');
6
+ const dom = require('xmldom').DOMParser;
7
+ class LocksClear extends core_1.Command {
8
+ async run() {
9
+ utils_1.client.setConfig(this);
10
+ let response = await utils_1.client.clearExpiredLocks();
11
+ if (response.status == 200) {
12
+ // this.log(response.data);
13
+ let doc = new dom().parseFromString(response.data, "application/xml");
14
+ let select = xpath.useNamespaces({ "exist": "http://exist.sourceforge.net/NS/exist" });
15
+ let count = select("string(/exist:result/@exist:count)", doc);
16
+ this.log(`${count} locks were cleared.`);
17
+ this.exit();
18
+ }
19
+ }
20
+ }
21
+ LocksClear.description = "Clear expired locks";
22
+ LocksClear.examples = [`$ legispro locks:clear`,];
23
+ exports.default = LocksClear;
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class LocksList extends Command {
3
+ run(): Promise<void>;
4
+ static description: string;
5
+ static examples: string[];
6
+ }
7
+ export default LocksList;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const utils_1 = require("../../lib/utils");
5
+ const AsciiTable = require('ascii-table');
6
+ const xpath = require('xpath');
7
+ const dom = require('xmldom').DOMParser;
8
+ class LocksList extends core_1.Command {
9
+ async run() {
10
+ utils_1.client.setConfig(this);
11
+ // [1] EXPIRED LOCKS
12
+ let response_expired = await utils_1.client.listExpiredLocks();
13
+ if (response_expired.status == 200) {
14
+ // this.log(response_expired.data);
15
+ let doc = new dom().parseFromString(response_expired.data, "application/xml");
16
+ let select = xpath.useNamespaces({
17
+ exist: "http://exist.sourceforge.net/NS/exist",
18
+ d: "DAV:",
19
+ locks: "http://www.xcential.com/schemas/locks/1.0"
20
+ });
21
+ let locks = [];
22
+ let table = new AsciiTable();
23
+ table.setHeading('URI', 'OWNER', 'EXPIRES');
24
+ let expired_count = 0;
25
+ for (let i = 0; i < doc.documentElement.childNodes.length; i++) {
26
+ let owner = select("string(/exist:result/locks:context[" + i + "]/d:activelock/d:owner/text())", doc)[0].toString();
27
+ let expires = select("string(/exist:result/locks:context[" + i + "]/@lockExpires)", doc)[0].toString();
28
+ let uri = select("string(/exist:result/locks:context[" + i + "]/@uri)", doc)[0].toString();
29
+ if (owner.length > 0) {
30
+ expired_count++;
31
+ let lock = {
32
+ uri: uri,
33
+ owner: owner,
34
+ expires: expires
35
+ };
36
+ locks.push(lock);
37
+ table.addRow(uri, owner, expires);
38
+ }
39
+ }
40
+ if (expired_count == 0) {
41
+ table.addRow("", "", "");
42
+ }
43
+ table.setTitle('Expired Locks (' + expired_count + ')');
44
+ this.log(table.toString());
45
+ }
46
+ // [2] ACTIVE LOCKS
47
+ let response_active = await utils_1.client.listActiveLocks();
48
+ if (response_active.status == 200) {
49
+ let doc = new dom().parseFromString(response_active.data, "application/xml");
50
+ let select = xpath.useNamespaces({
51
+ exist: "http://exist.sourceforge.net/NS/exist",
52
+ d: "DAV:",
53
+ locks: "http://www.xcential.com/schemas/locks/1.0"
54
+ });
55
+ let locks = [];
56
+ let table = new AsciiTable();
57
+ table.setHeading('URI', 'OWNER', 'EXPIRES');
58
+ let active_count = 0;
59
+ for (let i = 0; i < doc.documentElement.childNodes.length; i++) {
60
+ let owner = select("string(/exist:result/locks:context[" + i + "]/d:activelock/d:owner/text())", doc)[0].toString();
61
+ let expires = select("string(/exist:result/locks:context[" + i + "]/@lockExpires)", doc)[0].toString();
62
+ let uri = select("string(/exist:result/locks:context[" + i + "]/@uri)", doc)[0].toString();
63
+ if (owner.length > 0) {
64
+ active_count++;
65
+ let lock = {
66
+ uri: uri,
67
+ owner: owner,
68
+ expires: expires
69
+ };
70
+ locks.push(lock);
71
+ table.addRow(uri, owner, expires);
72
+ }
73
+ }
74
+ // empty table
75
+ if (active_count == 0) {
76
+ table.addRow("", "", "");
77
+ }
78
+ table.setTitle('Active Locks (' + active_count + ')');
79
+ this.log(table.toString());
80
+ }
81
+ this.exit();
82
+ }
83
+ }
84
+ LocksList.description = "List active and expired locks";
85
+ LocksList.examples = [`$ legispro locks:list`,];
86
+ exports.default = LocksList;
@@ -0,0 +1,8 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class ServicesHealth extends Command {
3
+ run(): Promise<void>;
4
+ get(url: string): Promise<import("axios").AxiosResponse<any, any>>;
5
+ static description: string;
6
+ static examples: string[];
7
+ }
8
+ export default ServicesHealth;
@@ -0,0 +1,66 @@
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 axios_1 = tslib_1.__importDefault(require("axios"));
6
+ const utils_1 = require("../../lib/utils");
7
+ const path_1 = tslib_1.__importDefault(require("path"));
8
+ class ServicesHealth extends core_1.Command {
9
+ async run() {
10
+ const configFile = path_1.default.join(this.config.configDir, 'config.json');
11
+ const env = require(configFile);
12
+ utils_1.client.setConfig(this);
13
+ const services = [
14
+ {
15
+ name: "Resolver",
16
+ port: 8026,
17
+ src: "/Resolver/Index.html"
18
+ },
19
+ {
20
+ name: "DocXServices",
21
+ port: 8026,
22
+ src: "/DocXServices/Index.html"
23
+ },
24
+ {
25
+ name: "XmlServices",
26
+ port: 8026,
27
+ src: "/XmlServices/Index.html"
28
+ },
29
+ {
30
+ name: "DocSynth",
31
+ port: 8026,
32
+ src: "/DocSynth/Index.html"
33
+ },
34
+ {
35
+ name: "XML Database",
36
+ port: env.port,
37
+ src: "/exist/restxq/fusiondb/version"
38
+ },
39
+ {
40
+ name: "Spellcheck",
41
+ port: 8060,
42
+ src: "/wscservice/api?cmd=check&text=sampl"
43
+ }
44
+ ];
45
+ this.log("Checking: " + env.protocol + "://" + env.hostname);
46
+ for (const i in services) {
47
+ // this.log(services[i]);
48
+ let service = services[i];
49
+ let response = await this.get(env.protocol + "://" + env.hostname + ":" + service.port + service.src);
50
+ if (response.status == 200) {
51
+ // this.log(JSON.stringify(response.data, null, 2));
52
+ this.log(`${service.name} is up and running at: ${env.protocol}://${env.hostname}:${service.port}${service.src}`);
53
+ }
54
+ }
55
+ this.exit();
56
+ }
57
+ get(url) {
58
+ return (0, axios_1.default)({
59
+ method: 'GET',
60
+ url: url
61
+ });
62
+ }
63
+ }
64
+ ServicesHealth.description = "Perform services health check";
65
+ ServicesHealth.examples = [`$ legispro services:health`,];
66
+ exports.default = ServicesHealth;
@@ -0,0 +1,26 @@
1
+ import { Command } from '@oclif/core';
2
+ declare class UserCreate extends Command {
3
+ run(): Promise<void>;
4
+ static flags: {
5
+ username: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
+ groups: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
7
+ email: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ language: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
+ description: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
10
+ password: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
+ primaryGroup: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
12
+ alias: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
+ timezone: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
14
+ firstName: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
15
+ lastName: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
16
+ country: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
17
+ fullName: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
18
+ enabled: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
19
+ expired: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
20
+ umask: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
21
+ scratchpad: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
22
+ };
23
+ static description: string;
24
+ static examples: string[];
25
+ }
26
+ export default UserCreate;