@magda/org-tree 2.3.2 → 3.0.0-alpha.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.
@@ -1,197 +0,0 @@
1
- #!/usr/bin/env node
2
- (function webpackUniversalModuleDefinition(root, factory) {
3
- if(typeof exports === 'object' && typeof module === 'object')
4
- module.exports = factory();
5
- else if(typeof define === 'function' && define.amd)
6
- define([], factory);
7
- else {
8
- var a = factory();
9
- for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
10
- }
11
- })(global, function() {
12
- return /******/ (function(modules) { // webpackBootstrap
13
- /******/ // The module cache
14
- /******/ var installedModules = {};
15
- /******/
16
- /******/ // The require function
17
- /******/ function __webpack_require__(moduleId) {
18
- /******/
19
- /******/ // Check if module is in cache
20
- /******/ if(installedModules[moduleId]) {
21
- /******/ return installedModules[moduleId].exports;
22
- /******/ }
23
- /******/ // Create a new module (and put it into the cache)
24
- /******/ var module = installedModules[moduleId] = {
25
- /******/ i: moduleId,
26
- /******/ l: false,
27
- /******/ exports: {}
28
- /******/ };
29
- /******/
30
- /******/ // Execute the module function
31
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
32
- /******/
33
- /******/ // Flag the module as loaded
34
- /******/ module.l = true;
35
- /******/
36
- /******/ // Return the exports of the module
37
- /******/ return module.exports;
38
- /******/ }
39
- /******/
40
- /******/
41
- /******/ // expose the modules object (__webpack_modules__)
42
- /******/ __webpack_require__.m = modules;
43
- /******/
44
- /******/ // expose the module cache
45
- /******/ __webpack_require__.c = installedModules;
46
- /******/
47
- /******/ // define getter function for harmony exports
48
- /******/ __webpack_require__.d = function(exports, name, getter) {
49
- /******/ if(!__webpack_require__.o(exports, name)) {
50
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
51
- /******/ }
52
- /******/ };
53
- /******/
54
- /******/ // define __esModule on exports
55
- /******/ __webpack_require__.r = function(exports) {
56
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
57
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
58
- /******/ }
59
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
60
- /******/ };
61
- /******/
62
- /******/ // create a fake namespace object
63
- /******/ // mode & 1: value is a module id, require it
64
- /******/ // mode & 2: merge all properties of value into the ns
65
- /******/ // mode & 4: return value when already ns object
66
- /******/ // mode & 8|1: behave like require
67
- /******/ __webpack_require__.t = function(value, mode) {
68
- /******/ if(mode & 1) value = __webpack_require__(value);
69
- /******/ if(mode & 8) return value;
70
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
71
- /******/ var ns = Object.create(null);
72
- /******/ __webpack_require__.r(ns);
73
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
74
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
75
- /******/ return ns;
76
- /******/ };
77
- /******/
78
- /******/ // getDefaultExport function for compatibility with non-harmony modules
79
- /******/ __webpack_require__.n = function(module) {
80
- /******/ var getter = module && module.__esModule ?
81
- /******/ function getDefault() { return module['default']; } :
82
- /******/ function getModuleExports() { return module; };
83
- /******/ __webpack_require__.d(getter, 'a', getter);
84
- /******/ return getter;
85
- /******/ };
86
- /******/
87
- /******/ // Object.prototype.hasOwnProperty.call
88
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
89
- /******/
90
- /******/ // __webpack_public_path__
91
- /******/ __webpack_require__.p = "";
92
- /******/
93
- /******/
94
- /******/ // Load entry module and return exports
95
- /******/ return __webpack_require__(__webpack_require__.s = 26);
96
- /******/ })
97
- /************************************************************************/
98
- /******/ ({
99
-
100
- /***/ 0:
101
- /***/ (function(module, exports) {
102
-
103
- module.exports = require("../../package.json");
104
-
105
- /***/ }),
106
-
107
- /***/ 1:
108
- /***/ (function(module, exports) {
109
-
110
- module.exports = require("commander");
111
-
112
- /***/ }),
113
-
114
- /***/ 2:
115
- /***/ (function(module, exports) {
116
-
117
- module.exports = require("chalk");
118
-
119
- /***/ }),
120
-
121
- /***/ 26:
122
- /***/ (function(module, exports, __webpack_require__) {
123
-
124
-
125
- const pkg = __webpack_require__(0);
126
- const program = __webpack_require__(1);
127
- const chalk = __webpack_require__(2);
128
- const NestedSetModelQueryer = __webpack_require__(3)
129
- .default;
130
- const getDBPool = __webpack_require__(4);
131
- const getNodeIdFromNameOrId = __webpack_require__(5);
132
- const getUserIdFromNameOrId = __webpack_require__(8);
133
-
134
- program
135
- .description("Remove the specified user to from any org unit.")
136
- .option("<userNameOrId>", "user name or id")
137
- .version(pkg.version)
138
- .action(async (userNameOrId) => {
139
- try {
140
- if (process.argv.slice(2).length < 1) {
141
- program.help();
142
- }
143
- userNameOrId = userNameOrId ? userNameOrId.trim() : "";
144
- if (userNameOrId === "")
145
- throw new Error("User Name or Id can't be empty!");
146
- const pool = getDBPool();
147
-
148
- const userId = await getUserIdFromNameOrId(userNameOrId, pool);
149
-
150
- await pool.query(
151
- `UPDATE "users" SET "orgUnitId" = NULL WHERE "id" = $1`,
152
- [userId]
153
- );
154
-
155
- console.log(
156
- chalk.green(`The user (id: ${userId}) has been unassigned.`)
157
- );
158
- } catch (e) {
159
- console.error(chalk.red(`Error: ${e}`));
160
- }
161
- process.exit(0);
162
- })
163
- .parse(process.argv);
164
-
165
-
166
- /***/ }),
167
-
168
- /***/ 3:
169
- /***/ (function(module, exports) {
170
-
171
- module.exports = require("./NestedSetModelQueryer");
172
-
173
- /***/ }),
174
-
175
- /***/ 4:
176
- /***/ (function(module, exports) {
177
-
178
- module.exports = require("../db/getDBPool");
179
-
180
- /***/ }),
181
-
182
- /***/ 5:
183
- /***/ (function(module, exports) {
184
-
185
- module.exports = require("./getNodeIdFromNameOrId");
186
-
187
- /***/ }),
188
-
189
- /***/ 8:
190
- /***/ (function(module, exports) {
191
-
192
- module.exports = require("./getUserIdFromNameOrId");
193
-
194
- /***/ })
195
-
196
- /******/ });
197
- });
@@ -1,168 +0,0 @@
1
- #!/usr/bin/env node
2
- (function webpackUniversalModuleDefinition(root, factory) {
3
- if(typeof exports === 'object' && typeof module === 'object')
4
- module.exports = factory();
5
- else if(typeof define === 'function' && define.amd)
6
- define([], factory);
7
- else {
8
- var a = factory();
9
- for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
10
- }
11
- })(global, function() {
12
- return /******/ (function(modules) { // webpackBootstrap
13
- /******/ // The module cache
14
- /******/ var installedModules = {};
15
- /******/
16
- /******/ // The require function
17
- /******/ function __webpack_require__(moduleId) {
18
- /******/
19
- /******/ // Check if module is in cache
20
- /******/ if(installedModules[moduleId]) {
21
- /******/ return installedModules[moduleId].exports;
22
- /******/ }
23
- /******/ // Create a new module (and put it into the cache)
24
- /******/ var module = installedModules[moduleId] = {
25
- /******/ i: moduleId,
26
- /******/ l: false,
27
- /******/ exports: {}
28
- /******/ };
29
- /******/
30
- /******/ // Execute the module function
31
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
32
- /******/
33
- /******/ // Flag the module as loaded
34
- /******/ module.l = true;
35
- /******/
36
- /******/ // Return the exports of the module
37
- /******/ return module.exports;
38
- /******/ }
39
- /******/
40
- /******/
41
- /******/ // expose the modules object (__webpack_modules__)
42
- /******/ __webpack_require__.m = modules;
43
- /******/
44
- /******/ // expose the module cache
45
- /******/ __webpack_require__.c = installedModules;
46
- /******/
47
- /******/ // define getter function for harmony exports
48
- /******/ __webpack_require__.d = function(exports, name, getter) {
49
- /******/ if(!__webpack_require__.o(exports, name)) {
50
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
51
- /******/ }
52
- /******/ };
53
- /******/
54
- /******/ // define __esModule on exports
55
- /******/ __webpack_require__.r = function(exports) {
56
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
57
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
58
- /******/ }
59
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
60
- /******/ };
61
- /******/
62
- /******/ // create a fake namespace object
63
- /******/ // mode & 1: value is a module id, require it
64
- /******/ // mode & 2: merge all properties of value into the ns
65
- /******/ // mode & 4: return value when already ns object
66
- /******/ // mode & 8|1: behave like require
67
- /******/ __webpack_require__.t = function(value, mode) {
68
- /******/ if(mode & 1) value = __webpack_require__(value);
69
- /******/ if(mode & 8) return value;
70
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
71
- /******/ var ns = Object.create(null);
72
- /******/ __webpack_require__.r(ns);
73
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
74
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
75
- /******/ return ns;
76
- /******/ };
77
- /******/
78
- /******/ // getDefaultExport function for compatibility with non-harmony modules
79
- /******/ __webpack_require__.n = function(module) {
80
- /******/ var getter = module && module.__esModule ?
81
- /******/ function getDefault() { return module['default']; } :
82
- /******/ function getModuleExports() { return module; };
83
- /******/ __webpack_require__.d(getter, 'a', getter);
84
- /******/ return getter;
85
- /******/ };
86
- /******/
87
- /******/ // Object.prototype.hasOwnProperty.call
88
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
89
- /******/
90
- /******/ // __webpack_public_path__
91
- /******/ __webpack_require__.p = "";
92
- /******/
93
- /******/
94
- /******/ // Load entry module and return exports
95
- /******/ return __webpack_require__(__webpack_require__.s = 27);
96
- /******/ })
97
- /************************************************************************/
98
- /******/ ({
99
-
100
- /***/ 0:
101
- /***/ (function(module, exports) {
102
-
103
- module.exports = require("../../package.json");
104
-
105
- /***/ }),
106
-
107
- /***/ 1:
108
- /***/ (function(module, exports) {
109
-
110
- module.exports = require("commander");
111
-
112
- /***/ }),
113
-
114
- /***/ 2:
115
- /***/ (function(module, exports) {
116
-
117
- module.exports = require("chalk");
118
-
119
- /***/ }),
120
-
121
- /***/ 27:
122
- /***/ (function(module, exports, __webpack_require__) {
123
-
124
-
125
- const pkg = __webpack_require__(0);
126
- const program = __webpack_require__(1);
127
- const chalk = __webpack_require__(2);
128
- const NestedSetModelQueryer = __webpack_require__(3)
129
- .default;
130
- const getDBPool = __webpack_require__(4);
131
-
132
- program
133
- .version(pkg.version)
134
- .description(`Display the entire tree in text.`)
135
- .parse(process.argv);
136
-
137
- const pool = getDBPool();
138
- const queryer = new NestedSetModelQueryer(pool, "org_units");
139
- (async () => {
140
- try {
141
- const textTree = await queryer.getTreeTextView();
142
- console.log("\n");
143
- console.log(chalk.green(textTree));
144
- } catch (e) {
145
- console.error(chalk.red(`Error: ${e}`));
146
- }
147
- process.exit(0);
148
- })();
149
-
150
-
151
- /***/ }),
152
-
153
- /***/ 3:
154
- /***/ (function(module, exports) {
155
-
156
- module.exports = require("./NestedSetModelQueryer");
157
-
158
- /***/ }),
159
-
160
- /***/ 4:
161
- /***/ (function(module, exports) {
162
-
163
- module.exports = require("../db/getDBPool");
164
-
165
- /***/ })
166
-
167
- /******/ });
168
- });
@@ -1,199 +0,0 @@
1
- #!/usr/bin/env node
2
- (function webpackUniversalModuleDefinition(root, factory) {
3
- if(typeof exports === 'object' && typeof module === 'object')
4
- module.exports = factory();
5
- else if(typeof define === 'function' && define.amd)
6
- define([], factory);
7
- else {
8
- var a = factory();
9
- for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
10
- }
11
- })(global, function() {
12
- return /******/ (function(modules) { // webpackBootstrap
13
- /******/ // The module cache
14
- /******/ var installedModules = {};
15
- /******/
16
- /******/ // The require function
17
- /******/ function __webpack_require__(moduleId) {
18
- /******/
19
- /******/ // Check if module is in cache
20
- /******/ if(installedModules[moduleId]) {
21
- /******/ return installedModules[moduleId].exports;
22
- /******/ }
23
- /******/ // Create a new module (and put it into the cache)
24
- /******/ var module = installedModules[moduleId] = {
25
- /******/ i: moduleId,
26
- /******/ l: false,
27
- /******/ exports: {}
28
- /******/ };
29
- /******/
30
- /******/ // Execute the module function
31
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
32
- /******/
33
- /******/ // Flag the module as loaded
34
- /******/ module.l = true;
35
- /******/
36
- /******/ // Return the exports of the module
37
- /******/ return module.exports;
38
- /******/ }
39
- /******/
40
- /******/
41
- /******/ // expose the modules object (__webpack_modules__)
42
- /******/ __webpack_require__.m = modules;
43
- /******/
44
- /******/ // expose the module cache
45
- /******/ __webpack_require__.c = installedModules;
46
- /******/
47
- /******/ // define getter function for harmony exports
48
- /******/ __webpack_require__.d = function(exports, name, getter) {
49
- /******/ if(!__webpack_require__.o(exports, name)) {
50
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
51
- /******/ }
52
- /******/ };
53
- /******/
54
- /******/ // define __esModule on exports
55
- /******/ __webpack_require__.r = function(exports) {
56
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
57
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
58
- /******/ }
59
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
60
- /******/ };
61
- /******/
62
- /******/ // create a fake namespace object
63
- /******/ // mode & 1: value is a module id, require it
64
- /******/ // mode & 2: merge all properties of value into the ns
65
- /******/ // mode & 4: return value when already ns object
66
- /******/ // mode & 8|1: behave like require
67
- /******/ __webpack_require__.t = function(value, mode) {
68
- /******/ if(mode & 1) value = __webpack_require__(value);
69
- /******/ if(mode & 8) return value;
70
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
71
- /******/ var ns = Object.create(null);
72
- /******/ __webpack_require__.r(ns);
73
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
74
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
75
- /******/ return ns;
76
- /******/ };
77
- /******/
78
- /******/ // getDefaultExport function for compatibility with non-harmony modules
79
- /******/ __webpack_require__.n = function(module) {
80
- /******/ var getter = module && module.__esModule ?
81
- /******/ function getDefault() { return module['default']; } :
82
- /******/ function getModuleExports() { return module; };
83
- /******/ __webpack_require__.d(getter, 'a', getter);
84
- /******/ return getter;
85
- /******/ };
86
- /******/
87
- /******/ // Object.prototype.hasOwnProperty.call
88
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
89
- /******/
90
- /******/ // __webpack_public_path__
91
- /******/ __webpack_require__.p = "";
92
- /******/
93
- /******/
94
- /******/ // Load entry module and return exports
95
- /******/ return __webpack_require__(__webpack_require__.s = 12);
96
- /******/ })
97
- /************************************************************************/
98
- /******/ ({
99
-
100
- /***/ 0:
101
- /***/ (function(module, exports) {
102
-
103
- module.exports = require("../../package.json");
104
-
105
- /***/ }),
106
-
107
- /***/ 1:
108
- /***/ (function(module, exports) {
109
-
110
- module.exports = require("commander");
111
-
112
- /***/ }),
113
-
114
- /***/ 12:
115
- /***/ (function(module, exports, __webpack_require__) {
116
-
117
-
118
- const pkg = __webpack_require__(0);
119
- const program = __webpack_require__(1);
120
- const chalk = __webpack_require__(2);
121
-
122
- program
123
- .version(pkg.version)
124
- .description(
125
- `A tool for managing magda authentication & access control data. Version: ${pkg.version}\n\n` +
126
- `If a database connection is required, the following environment variables will be used to create a connection:\n` +
127
- ` POSTGRES_HOST: database host; If not available in env var, 'localhost' will be used.\n` +
128
- ` POSTGRES_DB: database name; If not available in env var, 'auth' will be used.\n` +
129
- ` POSTGRES_PORT: database port; If not available in env var, 5432 will be used.\n` +
130
- ` POSTGRES_USER: database username; If not available in env var, 'postgres' will be used.\n` +
131
- ` POSTGRES_PASSWORD: database password; If not available in env var, '' will be used.`
132
- )
133
- .command("view", "\n\tDisplay the entire tree in text .\n")
134
- .command(
135
- "create <rootNodeName>",
136
- "\n\tCreate a root tree node with specified name.\n"
137
- )
138
- .command(
139
- "insert <parentNodeNameOrId> <nodeName>",
140
- "\n\tInsert a node as a child node of the specified the parent node with specified name. \n" +
141
- "\tIf the parent node name is given instead of the parent node Id, the newly created child node will be inserted to the first located parent node.\n"
142
- )
143
- .command(
144
- "delete <nodeNameOrId> -o, --only",
145
- "\n\tDelete the node specified and all its dependents from the tree. \n" +
146
- "\tIf the node name is given instead of the node Id, the first located node (and its dependents) will be removed.\n"
147
- )
148
- .command(
149
- "move <nodeNameOrId> <parentNodeNameOrId>",
150
- "\n\tMove the node specified and all its dependents to the specified parent node. \n" +
151
- "\tIf the node name is given instead of the node Id, the first located node (and its dependents) will be moved.\n" +
152
- "\tIf the parent node name is given instead of the parent node Id, the specifed node will be moved to the first located parent node.\n"
153
- )
154
- .command(
155
- "assign <userNameOrId> <nodeNameOrId>",
156
- "\n\tAssign the specified user to the nominated node. \n" +
157
- "\tBoth `userNameOrId` & `nodeNameOrId` can be either entity name or Id.\n" +
158
- "\tIf more than one entities are located by entity name, the first one will be used."
159
- )
160
- .command(
161
- "unassign <userNameOrId>",
162
- "\n\tAssign the specified user from any node"
163
- )
164
- .on("command:*", function (cmds) {
165
- if (
166
- [
167
- "view",
168
- "create",
169
- "insert",
170
- "delete",
171
- "move",
172
- "assign",
173
- "unassign"
174
- ].indexOf(cmds[0]) === -1
175
- ) {
176
- console.error(
177
- chalk.red(
178
- `Invalid command: ${program.args.join(
179
- " "
180
- )}\nSee --help for a list of available commands.`
181
- )
182
- );
183
- process.exit(1);
184
- }
185
- })
186
- .parse(process.argv);
187
-
188
-
189
- /***/ }),
190
-
191
- /***/ 2:
192
- /***/ (function(module, exports) {
193
-
194
- module.exports = require("chalk");
195
-
196
- /***/ })
197
-
198
- /******/ });
199
- });