@nocobase/resourcer 0.7.0-alpha.4 → 0.7.0-alpha.58
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/lib/action.js +176 -112
- package/lib/assign.js +126 -91
- package/lib/index.js +83 -22
- package/lib/middleware.js +74 -46
- package/lib/resource.js +103 -42
- package/lib/resourcer.js +288 -183
- package/lib/utils.js +312 -225
- package/package.json +2 -7
- package/esm/action.d.ts +0 -191
- package/esm/action.js +0 -111
- package/esm/action.js.map +0 -1
- package/esm/assign.d.ts +0 -10
- package/esm/assign.js +0 -98
- package/esm/assign.js.map +0 -1
- package/esm/index.d.ts +0 -7
- package/esm/index.js +0 -8
- package/esm/index.js.map +0 -1
- package/esm/middleware.d.ts +0 -23
- package/esm/middleware.js +0 -50
- package/esm/middleware.js.map +0 -1
- package/esm/resource.d.ts +0 -52
- package/esm/resource.js +0 -44
- package/esm/resource.js.map +0 -1
- package/esm/resourcer.d.ts +0 -179
- package/esm/resourcer.js +0 -189
- package/esm/resourcer.js.map +0 -1
- package/esm/utils.d.ts +0 -31
- package/esm/utils.js +0 -234
- package/esm/utils.js.map +0 -1
- package/lib/action.js.map +0 -1
- package/lib/assign.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/middleware.js.map +0 -1
- package/lib/resource.js.map +0 -1
- package/lib/resourcer.js.map +0 -1
- package/lib/utils.js.map +0 -1
- package/tsconfig.build.json +0 -9
package/lib/action.js
CHANGED
|
@@ -1,118 +1,182 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Action = void 0;
|
|
7
|
+
|
|
8
|
+
function _lodash() {
|
|
9
|
+
const data = _interopRequireDefault(require("lodash"));
|
|
10
|
+
|
|
11
|
+
_lodash = function _lodash() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _koaCompose() {
|
|
19
|
+
const data = _interopRequireDefault(require("koa-compose"));
|
|
20
|
+
|
|
21
|
+
_koaCompose = function _koaCompose() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var _utils = require("./utils");
|
|
29
|
+
|
|
30
|
+
var _middleware = _interopRequireDefault(require("./middleware"));
|
|
31
|
+
|
|
32
|
+
var _assign = require("./assign");
|
|
33
|
+
|
|
34
|
+
const _excluded = ["middleware", "middlewares", "handler"];
|
|
35
|
+
|
|
36
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
|
+
|
|
38
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
39
|
+
|
|
40
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
41
|
+
|
|
42
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
43
|
+
|
|
44
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
45
|
+
|
|
46
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
47
|
+
|
|
48
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
49
|
+
|
|
50
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
51
|
+
|
|
32
52
|
class Action {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
delete options.middlewares;
|
|
51
|
-
const action = new Action(options);
|
|
52
|
-
action.setName(this.name);
|
|
53
|
-
action.setResource(this.resource);
|
|
54
|
-
action.middlewares.push(...this.middlewares);
|
|
55
|
-
return action;
|
|
56
|
-
}
|
|
57
|
-
setContext(context) {
|
|
58
|
-
this.context = context;
|
|
59
|
-
}
|
|
60
|
-
mergeParams(params, strategies = {}) {
|
|
61
|
-
(0, assign_1.assign)(this.params, params, Object.assign({ filter: 'andMerge', fields: 'intersect', appends: 'union', except: 'union', whitelist: 'intersect', blacklist: 'intersect', sort: 'overwrite' }, strategies));
|
|
62
|
-
}
|
|
63
|
-
setResource(resource) {
|
|
64
|
-
this.resource = resource;
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
getResource() {
|
|
68
|
-
return this.resource;
|
|
69
|
-
}
|
|
70
|
-
getOptions() {
|
|
71
|
-
return this.options;
|
|
72
|
-
}
|
|
73
|
-
setName(name) {
|
|
74
|
-
this.name = name;
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
getName() {
|
|
78
|
-
return this.name;
|
|
79
|
-
}
|
|
80
|
-
getMiddlewareHandlers() {
|
|
81
|
-
return this.middlewares
|
|
82
|
-
.filter((middleware) => middleware.canAccess(this.name))
|
|
83
|
-
.map((middleware) => middleware.getHandler());
|
|
84
|
-
}
|
|
85
|
-
getHandler() {
|
|
86
|
-
const handler = (0, utils_1.requireModule)(this.handler || this.resource.resourcer.getRegisteredHandler(this.name));
|
|
87
|
-
if (typeof handler !== 'function') {
|
|
88
|
-
throw new Error('Handler must be a function!');
|
|
89
|
-
}
|
|
90
|
-
return handler;
|
|
91
|
-
}
|
|
92
|
-
getHandlers() {
|
|
93
|
-
return [...this.resource.resourcer.getMiddlewares(), ...this.getMiddlewareHandlers(), this.getHandler()].filter(Boolean);
|
|
94
|
-
}
|
|
95
|
-
execute(context, next) {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
return yield (0, koa_compose_1.default)(this.getHandlers())(context, next);
|
|
98
|
-
});
|
|
53
|
+
constructor(options) {
|
|
54
|
+
this.handler = void 0;
|
|
55
|
+
this.resource = void 0;
|
|
56
|
+
this.name = void 0;
|
|
57
|
+
this.options = void 0;
|
|
58
|
+
this.context = {};
|
|
59
|
+
this.params = {};
|
|
60
|
+
this.actionName = void 0;
|
|
61
|
+
this.resourceName = void 0;
|
|
62
|
+
this.resourceOf = void 0;
|
|
63
|
+
this.middlewares = [];
|
|
64
|
+
options = (0, _utils.requireModule)(options);
|
|
65
|
+
|
|
66
|
+
if (typeof options === 'function') {
|
|
67
|
+
options = {
|
|
68
|
+
handler: options
|
|
69
|
+
};
|
|
99
70
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
71
|
+
|
|
72
|
+
const _options = options,
|
|
73
|
+
middleware = _options.middleware,
|
|
74
|
+
_options$middlewares = _options.middlewares,
|
|
75
|
+
middlewares = _options$middlewares === void 0 ? [] : _options$middlewares,
|
|
76
|
+
handler = _options.handler,
|
|
77
|
+
params = _objectWithoutProperties(_options, _excluded);
|
|
78
|
+
|
|
79
|
+
this.middlewares = _middleware.default.toInstanceArray(middleware || middlewares);
|
|
80
|
+
this.handler = handler;
|
|
81
|
+
this.options = options;
|
|
82
|
+
this.mergeParams(params);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
clone() {
|
|
86
|
+
const options = _lodash().default.cloneDeep(this.options);
|
|
87
|
+
|
|
88
|
+
delete options.middleware;
|
|
89
|
+
delete options.middlewares;
|
|
90
|
+
const action = new Action(options);
|
|
91
|
+
action.setName(this.name);
|
|
92
|
+
action.setResource(this.resource);
|
|
93
|
+
action.middlewares.push(...this.middlewares);
|
|
94
|
+
return action;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
setContext(context) {
|
|
98
|
+
this.context = context;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
mergeParams(params, strategies = {}) {
|
|
102
|
+
(0, _assign.assign)(this.params, params, _objectSpread({
|
|
103
|
+
filter: 'andMerge',
|
|
104
|
+
fields: 'intersect',
|
|
105
|
+
appends: 'union',
|
|
106
|
+
except: 'union',
|
|
107
|
+
whitelist: 'intersect',
|
|
108
|
+
blacklist: 'intersect',
|
|
109
|
+
sort: 'overwrite'
|
|
110
|
+
}, strategies));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
setResource(resource) {
|
|
114
|
+
this.resource = resource;
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
getResource() {
|
|
119
|
+
return this.resource;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
getOptions() {
|
|
123
|
+
return this.options;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
setName(name) {
|
|
127
|
+
this.name = name;
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
getName() {
|
|
132
|
+
return this.name;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
getMiddlewareHandlers() {
|
|
136
|
+
return this.middlewares.filter(middleware => middleware.canAccess(this.name)).map(middleware => middleware.getHandler());
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
getHandler() {
|
|
140
|
+
const handler = (0, _utils.requireModule)(this.handler || this.resource.resourcer.getRegisteredHandler(this.name));
|
|
141
|
+
|
|
142
|
+
if (typeof handler !== 'function') {
|
|
143
|
+
throw new Error('Handler must be a function!');
|
|
114
144
|
}
|
|
145
|
+
|
|
146
|
+
return handler;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
getHandlers() {
|
|
150
|
+
return [...this.resource.resourcer.getMiddlewares(), ...this.getMiddlewareHandlers(), this.getHandler()].filter(Boolean);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
execute(context, next) {
|
|
154
|
+
var _this = this;
|
|
155
|
+
|
|
156
|
+
return _asyncToGenerator(function* () {
|
|
157
|
+
return yield (0, _koaCompose().default)(_this.getHandlers())(context, next);
|
|
158
|
+
})();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static toInstanceMap(actions, resource) {
|
|
162
|
+
return new Map(Object.entries(actions).map(([key, options]) => {
|
|
163
|
+
let action;
|
|
164
|
+
|
|
165
|
+
if (options instanceof Action) {
|
|
166
|
+
action = options;
|
|
167
|
+
} else {
|
|
168
|
+
action = new Action(options);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
action.setName(key);
|
|
172
|
+
action.setResource(resource);
|
|
173
|
+
resource && action.middlewares.unshift(...resource.middlewares);
|
|
174
|
+
return [key, action];
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
|
|
115
178
|
}
|
|
179
|
+
|
|
116
180
|
exports.Action = Action;
|
|
117
|
-
|
|
118
|
-
|
|
181
|
+
var _default = Action;
|
|
182
|
+
exports.default = _default;
|
package/lib/assign.js
CHANGED
|
@@ -1,106 +1,141 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.assign =
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.assign = assign;
|
|
7
|
+
exports.default = isPlainObject;
|
|
8
|
+
exports.mergeStrategies = void 0;
|
|
9
|
+
|
|
10
|
+
function _lodash() {
|
|
11
|
+
const data = _interopRequireDefault(require("lodash"));
|
|
12
|
+
|
|
13
|
+
_lodash = function _lodash() {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function _deepmerge() {
|
|
21
|
+
const data = _interopRequireDefault(require("deepmerge"));
|
|
22
|
+
|
|
23
|
+
_deepmerge = function _deepmerge() {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
|
|
9
32
|
function isPlainObject(value) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
33
|
+
if (Object.prototype.toString.call(value) !== '[object Object]') {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const prototype = Object.getPrototypeOf(value);
|
|
38
|
+
return prototype === null || prototype === Object.prototype;
|
|
15
39
|
}
|
|
16
|
-
|
|
40
|
+
|
|
17
41
|
function getEnumerableOwnPropertySymbols(target) {
|
|
18
|
-
|
|
19
|
-
? Object.getOwnPropertySymbols(target).filter((symbol) => target.propertyIsEnumerable(symbol))
|
|
20
|
-
: [];
|
|
42
|
+
return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(symbol => target.propertyIsEnumerable(symbol)) : [];
|
|
21
43
|
}
|
|
44
|
+
|
|
22
45
|
function getKeys(target) {
|
|
23
|
-
|
|
46
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
|
|
24
47
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
48
|
+
|
|
49
|
+
const mergeStrategies = new Map();
|
|
50
|
+
exports.mergeStrategies = mergeStrategies;
|
|
51
|
+
mergeStrategies.set('overwrite', (_, y) => {
|
|
52
|
+
return y;
|
|
28
53
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
54
|
+
mergeStrategies.set('andMerge', (x, y) => {
|
|
55
|
+
if (!x && !y) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!x) {
|
|
60
|
+
return y;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!y) {
|
|
64
|
+
return x;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
$and: [x, y]
|
|
69
|
+
};
|
|
42
70
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
71
|
+
mergeStrategies.set('orMerge', (x, y) => {
|
|
72
|
+
if (!x && !y) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!x) {
|
|
77
|
+
return y;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!y) {
|
|
81
|
+
return x;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
$or: [x, y]
|
|
86
|
+
};
|
|
56
87
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})
|
|
62
|
-
: y;
|
|
88
|
+
mergeStrategies.set('deepMerge', (x, y) => {
|
|
89
|
+
return isPlainObject(x) && isPlainObject(y) ? (0, _deepmerge().default)(x, y, {
|
|
90
|
+
arrayMerge: (x, y) => y
|
|
91
|
+
}) : y;
|
|
63
92
|
});
|
|
64
|
-
|
|
65
|
-
|
|
93
|
+
mergeStrategies.set('merge', (x, y) => {
|
|
94
|
+
return isPlainObject(x) && isPlainObject(y) ? Object.assign(x, y) : y;
|
|
66
95
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
96
|
+
mergeStrategies.set('union', (x, y) => {
|
|
97
|
+
if (typeof x === 'string') {
|
|
98
|
+
x = x.split(',');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (typeof y === 'string') {
|
|
102
|
+
y = y.split(',');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return _lodash().default.uniq((x || []).concat(y || []));
|
|
75
106
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
107
|
+
mergeStrategies.set('intersect', (x, y) => {
|
|
108
|
+
if (typeof x === 'string') {
|
|
109
|
+
x = x.split(',');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (typeof y === 'string') {
|
|
113
|
+
y = y.split(',');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!Array.isArray(x) || x.length === 0) {
|
|
117
|
+
return y || [];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!Array.isArray(y) || y.length === 0) {
|
|
121
|
+
return x || [];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return x.filter(v => y.includes(v));
|
|
90
125
|
});
|
|
126
|
+
|
|
91
127
|
function assign(target, source, strategies = {}) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
//# sourceMappingURL=assign.js.map
|
|
128
|
+
getKeys(source).forEach(sourceKey => {
|
|
129
|
+
const strategy = strategies[sourceKey];
|
|
130
|
+
let func = mergeStrategies.get('deepMerge');
|
|
131
|
+
|
|
132
|
+
if (typeof strategy === 'function') {
|
|
133
|
+
func = strategy;
|
|
134
|
+
} else if (typeof strategy === 'string' && mergeStrategies.has(strategy)) {
|
|
135
|
+
func = mergeStrategies.get(strategy);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
target[sourceKey] = func(target[sourceKey], source[sourceKey]);
|
|
139
|
+
});
|
|
140
|
+
return target;
|
|
141
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -1,23 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(exports,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {};
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
|
|
9
|
+
var _resourcer = _interopRequireWildcard(require("./resourcer"));
|
|
10
|
+
|
|
11
|
+
Object.keys(_resourcer).forEach(function (key) {
|
|
12
|
+
if (key === "default" || key === "__esModule") return;
|
|
13
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
14
|
+
if (key in exports && exports[key] === _resourcer[key]) return;
|
|
15
|
+
Object.defineProperty(exports, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function get() {
|
|
18
|
+
return _resourcer[key];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
var _utils = require("./utils");
|
|
24
|
+
|
|
25
|
+
Object.keys(_utils).forEach(function (key) {
|
|
26
|
+
if (key === "default" || key === "__esModule") return;
|
|
27
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
28
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
29
|
+
Object.defineProperty(exports, key, {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function get() {
|
|
32
|
+
return _utils[key];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
var _middleware = require("./middleware");
|
|
38
|
+
|
|
39
|
+
Object.keys(_middleware).forEach(function (key) {
|
|
40
|
+
if (key === "default" || key === "__esModule") return;
|
|
41
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
42
|
+
if (key in exports && exports[key] === _middleware[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _middleware[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
var _action = require("./action");
|
|
52
|
+
|
|
53
|
+
Object.keys(_action).forEach(function (key) {
|
|
54
|
+
if (key === "default" || key === "__esModule") return;
|
|
55
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
56
|
+
if (key in exports && exports[key] === _action[key]) return;
|
|
57
|
+
Object.defineProperty(exports, key, {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function get() {
|
|
60
|
+
return _action[key];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
var _resource = require("./resource");
|
|
66
|
+
|
|
67
|
+
Object.keys(_resource).forEach(function (key) {
|
|
68
|
+
if (key === "default" || key === "__esModule") return;
|
|
69
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
70
|
+
if (key in exports && exports[key] === _resource[key]) return;
|
|
71
|
+
Object.defineProperty(exports, key, {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function get() {
|
|
74
|
+
return _resource[key];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
80
|
+
|
|
81
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
82
|
+
|
|
83
|
+
var _default = _resourcer.default;
|
|
84
|
+
exports.default = _default;
|