@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.
- package/dist/getNodeIdFromNameOrId.js +21 -0
- package/dist/getUserIdFromNameOrId.js +24 -0
- package/dist/index.js +4466 -0
- package/dist/org-tree-assign.js +13563 -0
- package/dist/org-tree-create.js +13524 -0
- package/dist/org-tree-delete.js +13549 -0
- package/dist/org-tree-insert.js +13545 -0
- package/dist/org-tree-move.js +13543 -0
- package/dist/org-tree-unassign.js +4495 -0
- package/dist/org-tree-view.js +13511 -0
- package/package.json +23 -19
- package/bin/db/getDBConfig.js +0 -19
- package/bin/db/getDBPool.js +0 -13
- package/bin/org-tree/NestedSetModelQueryer.js +0 -19718
- package/bin/org-tree/getNodeIdFromNameOrId.js +0 -134
- package/bin/org-tree/getUserIdFromNameOrId.js +0 -137
- package/bin/org-tree/org-tree-assign.js +0 -220
- package/bin/org-tree/org-tree-create.js +0 -180
- package/bin/org-tree/org-tree-delete.js +0 -206
- package/bin/org-tree/org-tree-insert.js +0 -200
- package/bin/org-tree/org-tree-move.js +0 -202
- package/bin/org-tree/org-tree-unassign.js +0 -197
- package/bin/org-tree/org-tree-view.js +0 -168
- package/bin/org-tree/org-tree.js +0 -199
|
@@ -1,134 +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 = 19);
|
|
96
|
-
/******/ })
|
|
97
|
-
/************************************************************************/
|
|
98
|
-
/******/ ({
|
|
99
|
-
|
|
100
|
-
/***/ 19:
|
|
101
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
102
|
-
|
|
103
|
-
const isUuid = __webpack_require__(6).default;
|
|
104
|
-
async function getNodeIdByNameOrId(nameOrId, queryer) {
|
|
105
|
-
if (isUuid(nameOrId)) {
|
|
106
|
-
return nameOrId;
|
|
107
|
-
} else {
|
|
108
|
-
const nodes = await queryer.getNodes({ name: nameOrId }, ["id"]);
|
|
109
|
-
if (!nodes || !nodes.length) {
|
|
110
|
-
throw new Error(`Cannot locate node record with name: ${nameOrId}`);
|
|
111
|
-
}
|
|
112
|
-
return nodes[0].id;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
module.exports = getNodeIdByNameOrId;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
/***/ }),
|
|
119
|
-
|
|
120
|
-
/***/ 6:
|
|
121
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
122
|
-
|
|
123
|
-
"use strict";
|
|
124
|
-
|
|
125
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
126
|
-
const uuidRegEx = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
127
|
-
const isUuid = (id) => typeof id === "string" && uuidRegEx.test(id);
|
|
128
|
-
exports.default = isUuid;
|
|
129
|
-
//# sourceMappingURL=isUuid.js.map
|
|
130
|
-
|
|
131
|
-
/***/ })
|
|
132
|
-
|
|
133
|
-
/******/ });
|
|
134
|
-
});
|
|
@@ -1,137 +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 = 20);
|
|
96
|
-
/******/ })
|
|
97
|
-
/************************************************************************/
|
|
98
|
-
/******/ ({
|
|
99
|
-
|
|
100
|
-
/***/ 20:
|
|
101
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
102
|
-
|
|
103
|
-
const isUuid = __webpack_require__(6).default;
|
|
104
|
-
async function getUserIdFromNameOrId(nameOrId, pool) {
|
|
105
|
-
if (isUuid(nameOrId)) {
|
|
106
|
-
return nameOrId;
|
|
107
|
-
} else {
|
|
108
|
-
const result = await pool.query(
|
|
109
|
-
`SELECT "id" FROM "users" WHERE "displayName" = $1`,
|
|
110
|
-
[nameOrId]
|
|
111
|
-
);
|
|
112
|
-
if (!result || !result.rows || !result.rows.length) {
|
|
113
|
-
throw new Error(`Cannot locate node record with name: ${nameOrId}`);
|
|
114
|
-
}
|
|
115
|
-
return result.rows[0].id;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
module.exports = getUserIdFromNameOrId;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
/***/ }),
|
|
122
|
-
|
|
123
|
-
/***/ 6:
|
|
124
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
125
|
-
|
|
126
|
-
"use strict";
|
|
127
|
-
|
|
128
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
129
|
-
const uuidRegEx = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
130
|
-
const isUuid = (id) => typeof id === "string" && uuidRegEx.test(id);
|
|
131
|
-
exports.default = isUuid;
|
|
132
|
-
//# sourceMappingURL=isUuid.js.map
|
|
133
|
-
|
|
134
|
-
/***/ })
|
|
135
|
-
|
|
136
|
-
/******/ });
|
|
137
|
-
});
|
|
@@ -1,220 +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 = 21);
|
|
96
|
-
/******/ })
|
|
97
|
-
/************************************************************************/
|
|
98
|
-
/******/ ([
|
|
99
|
-
/* 0 */
|
|
100
|
-
/***/ (function(module, exports) {
|
|
101
|
-
|
|
102
|
-
module.exports = require("../../package.json");
|
|
103
|
-
|
|
104
|
-
/***/ }),
|
|
105
|
-
/* 1 */
|
|
106
|
-
/***/ (function(module, exports) {
|
|
107
|
-
|
|
108
|
-
module.exports = require("commander");
|
|
109
|
-
|
|
110
|
-
/***/ }),
|
|
111
|
-
/* 2 */
|
|
112
|
-
/***/ (function(module, exports) {
|
|
113
|
-
|
|
114
|
-
module.exports = require("chalk");
|
|
115
|
-
|
|
116
|
-
/***/ }),
|
|
117
|
-
/* 3 */
|
|
118
|
-
/***/ (function(module, exports) {
|
|
119
|
-
|
|
120
|
-
module.exports = require("./NestedSetModelQueryer");
|
|
121
|
-
|
|
122
|
-
/***/ }),
|
|
123
|
-
/* 4 */
|
|
124
|
-
/***/ (function(module, exports) {
|
|
125
|
-
|
|
126
|
-
module.exports = require("../db/getDBPool");
|
|
127
|
-
|
|
128
|
-
/***/ }),
|
|
129
|
-
/* 5 */
|
|
130
|
-
/***/ (function(module, exports) {
|
|
131
|
-
|
|
132
|
-
module.exports = require("./getNodeIdFromNameOrId");
|
|
133
|
-
|
|
134
|
-
/***/ }),
|
|
135
|
-
/* 6 */,
|
|
136
|
-
/* 7 */,
|
|
137
|
-
/* 8 */
|
|
138
|
-
/***/ (function(module, exports) {
|
|
139
|
-
|
|
140
|
-
module.exports = require("./getUserIdFromNameOrId");
|
|
141
|
-
|
|
142
|
-
/***/ }),
|
|
143
|
-
/* 9 */,
|
|
144
|
-
/* 10 */,
|
|
145
|
-
/* 11 */,
|
|
146
|
-
/* 12 */,
|
|
147
|
-
/* 13 */,
|
|
148
|
-
/* 14 */,
|
|
149
|
-
/* 15 */,
|
|
150
|
-
/* 16 */,
|
|
151
|
-
/* 17 */,
|
|
152
|
-
/* 18 */,
|
|
153
|
-
/* 19 */,
|
|
154
|
-
/* 20 */,
|
|
155
|
-
/* 21 */
|
|
156
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const pkg = __webpack_require__(0);
|
|
160
|
-
const program = __webpack_require__(1);
|
|
161
|
-
const chalk = __webpack_require__(2);
|
|
162
|
-
const NestedSetModelQueryer = __webpack_require__(3)
|
|
163
|
-
.default;
|
|
164
|
-
const getDBPool = __webpack_require__(4);
|
|
165
|
-
const getNodeIdFromNameOrId = __webpack_require__(5);
|
|
166
|
-
const getUserIdFromNameOrId = __webpack_require__(8);
|
|
167
|
-
|
|
168
|
-
program
|
|
169
|
-
.description(
|
|
170
|
-
"Assign the specified user to the nominated node." +
|
|
171
|
-
"\nBoth `userNameOrId` & `nodeNameOrId` can be either entity name or Id. \n" +
|
|
172
|
-
"\tIf more than one entities are located by entity name, the first one will be used."
|
|
173
|
-
)
|
|
174
|
-
.option("<userNameOrId>", "user name or id")
|
|
175
|
-
.option("<nodeNameOrId>", "org unit node id or name")
|
|
176
|
-
.version(pkg.version)
|
|
177
|
-
.action(async (userNameOrId, parentNodeNameOrId) => {
|
|
178
|
-
try {
|
|
179
|
-
if (process.argv.slice(2).length < 2) {
|
|
180
|
-
program.help();
|
|
181
|
-
}
|
|
182
|
-
userNameOrId = userNameOrId ? userNameOrId.trim() : "";
|
|
183
|
-
if (userNameOrId === "")
|
|
184
|
-
throw new Error("User Name or Id can't be empty!");
|
|
185
|
-
parentNodeNameOrId = parentNodeNameOrId
|
|
186
|
-
? parentNodeNameOrId.trim()
|
|
187
|
-
: "";
|
|
188
|
-
if (parentNodeNameOrId === "")
|
|
189
|
-
throw new Error("Parent Org Node Name or Id can't be empty!");
|
|
190
|
-
const pool = getDBPool();
|
|
191
|
-
const queryer = new NestedSetModelQueryer(pool, "org_units");
|
|
192
|
-
|
|
193
|
-
const parentNodeId = await getNodeIdFromNameOrId(
|
|
194
|
-
parentNodeNameOrId,
|
|
195
|
-
queryer
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
const userId = await getUserIdFromNameOrId(userNameOrId, pool);
|
|
199
|
-
|
|
200
|
-
await pool.query(
|
|
201
|
-
`UPDATE "users" SET "orgUnitId" = $2 WHERE "id" = $1`,
|
|
202
|
-
[userId, parentNodeId]
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
console.log(
|
|
206
|
-
chalk.green(
|
|
207
|
-
`The user (id: ${userId}) has been assigned to org unit node id: ${parentNodeId}.`
|
|
208
|
-
)
|
|
209
|
-
);
|
|
210
|
-
} catch (e) {
|
|
211
|
-
console.error(chalk.red(`Error: ${e}`));
|
|
212
|
-
}
|
|
213
|
-
process.exit(0);
|
|
214
|
-
})
|
|
215
|
-
.parse(process.argv);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
/***/ })
|
|
219
|
-
/******/ ]);
|
|
220
|
-
});
|
|
@@ -1,180 +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 = 22);
|
|
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
|
-
/***/ 22:
|
|
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
|
-
.description(
|
|
134
|
-
`Create a root tree node with specified name. You can then complete other node fields using other DB admin tools.`
|
|
135
|
-
)
|
|
136
|
-
.option("<nodeName>", "Root node name")
|
|
137
|
-
.version(pkg.version)
|
|
138
|
-
.action(async (nodeName) => {
|
|
139
|
-
try {
|
|
140
|
-
if (!process.argv.slice(2).length) {
|
|
141
|
-
program.help();
|
|
142
|
-
}
|
|
143
|
-
nodeName = nodeName.trim();
|
|
144
|
-
if (nodeName === "") throw new Error("Node Name can't be empty!");
|
|
145
|
-
const pool = getDBPool();
|
|
146
|
-
const queryer = new NestedSetModelQueryer(pool, "org_units");
|
|
147
|
-
const nodeId = await queryer.createRootNode({
|
|
148
|
-
name: nodeName
|
|
149
|
-
});
|
|
150
|
-
console.log(
|
|
151
|
-
chalk.green(
|
|
152
|
-
`Root node with name: ${nodeName} created. \nId: ${nodeId}`
|
|
153
|
-
)
|
|
154
|
-
);
|
|
155
|
-
} catch (e) {
|
|
156
|
-
console.error(chalk.red(`Error: ${e}`));
|
|
157
|
-
}
|
|
158
|
-
process.exit(0);
|
|
159
|
-
})
|
|
160
|
-
.parse(process.argv);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
/***/ }),
|
|
164
|
-
|
|
165
|
-
/***/ 3:
|
|
166
|
-
/***/ (function(module, exports) {
|
|
167
|
-
|
|
168
|
-
module.exports = require("./NestedSetModelQueryer");
|
|
169
|
-
|
|
170
|
-
/***/ }),
|
|
171
|
-
|
|
172
|
-
/***/ 4:
|
|
173
|
-
/***/ (function(module, exports) {
|
|
174
|
-
|
|
175
|
-
module.exports = require("../db/getDBPool");
|
|
176
|
-
|
|
177
|
-
/***/ })
|
|
178
|
-
|
|
179
|
-
/******/ });
|
|
180
|
-
});
|