@wzyjs/utils 0.2.13 → 0.2.14
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/cjs/browser/element.d.ts +0 -1
- package/dist/cjs/browser/index.d.ts +1 -1
- package/dist/cjs/browser/index.js +3 -1
- package/dist/cjs/browser/initHttpClient.d.ts +4 -0
- package/dist/cjs/browser/initHttpClient.js +62 -0
- package/dist/cjs/browser/other.d.ts +0 -1
- package/dist/cjs/browser/style.d.ts +0 -1
- package/dist/cjs/browser.d.ts +0 -1
- package/dist/cjs/common/classs.d.ts +0 -1
- package/dist/cjs/common/dayjs.d.ts +13 -2
- package/dist/cjs/common/dayjs.js +1 -0
- package/dist/cjs/common/index.d.ts +0 -1
- package/dist/cjs/common/number.d.ts +1 -1
- package/dist/cjs/common/number.js +14 -0
- package/dist/cjs/common/object.d.ts +0 -1
- package/dist/cjs/common/other.d.ts +0 -1
- package/dist/cjs/common/string.d.ts +2 -5
- package/dist/cjs/common/string.js +5 -0
- package/dist/cjs/node/file/index.d.ts +1 -0
- package/dist/cjs/node/file/index.js +58 -0
- package/dist/cjs/node/index.d.ts +1 -1
- package/dist/cjs/node/index.js +3 -1
- package/dist/cjs/node/jsonFile/index.d.ts +3 -3
- package/dist/cjs/node/jsonFile/index.js +37 -13
- package/dist/cjs/node/mail/index.d.ts +0 -1
- package/dist/cjs/node.d.ts +0 -1
- package/dist/esm/browser/element.d.ts +0 -1
- package/dist/esm/browser/index.d.ts +1 -1
- package/dist/esm/browser/index.js +2 -1
- package/dist/esm/browser/initHttpClient.d.ts +4 -0
- package/dist/esm/{node/database/Collection.js → browser/initHttpClient.js} +51 -340
- package/dist/esm/browser/other.d.ts +0 -1
- package/dist/esm/browser/style.d.ts +0 -1
- package/dist/esm/browser.d.ts +0 -1
- package/dist/esm/common/classs.d.ts +0 -1
- package/dist/esm/common/dayjs.d.ts +13 -2
- package/dist/esm/common/dayjs.js +1 -0
- package/dist/esm/common/index.d.ts +0 -1
- package/dist/esm/common/number.d.ts +1 -1
- package/dist/esm/common/number.js +21 -0
- package/dist/esm/common/object.d.ts +0 -1
- package/dist/esm/common/other.d.ts +0 -1
- package/dist/esm/common/string.d.ts +2 -5
- package/dist/esm/common/string.js +9 -0
- package/dist/esm/node/file/index.d.ts +1 -0
- package/dist/esm/node/file/index.js +52 -0
- package/dist/esm/node/index.d.ts +1 -1
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/node/jsonFile/index.d.ts +3 -3
- package/dist/esm/node/jsonFile/index.js +79 -21
- package/dist/esm/node/mail/index.d.ts +0 -1
- package/dist/esm/node.d.ts +0 -1
- package/package.json +8 -8
- package/dist/cjs/browser/element.d.ts.map +0 -1
- package/dist/cjs/browser/index.d.ts.map +0 -1
- package/dist/cjs/browser/other.d.ts.map +0 -1
- package/dist/cjs/browser/style.d.ts.map +0 -1
- package/dist/cjs/browser.d.ts.map +0 -1
- package/dist/cjs/common/classs.d.ts.map +0 -1
- package/dist/cjs/common/dayjs.d.ts.map +0 -1
- package/dist/cjs/common/index.d.ts.map +0 -1
- package/dist/cjs/common/number.d.ts.map +0 -1
- package/dist/cjs/common/object.d.ts.map +0 -1
- package/dist/cjs/common/other.d.ts.map +0 -1
- package/dist/cjs/common/string.d.ts.map +0 -1
- package/dist/cjs/node/database/Collection.d.ts +0 -23
- package/dist/cjs/node/database/Collection.d.ts.map +0 -1
- package/dist/cjs/node/database/Collection.js +0 -219
- package/dist/cjs/node/database/Database.d.ts +0 -11
- package/dist/cjs/node/database/Database.d.ts.map +0 -1
- package/dist/cjs/node/database/Database.js +0 -47
- package/dist/cjs/node/database/index.d.ts +0 -3
- package/dist/cjs/node/database/index.d.ts.map +0 -1
- package/dist/cjs/node/database/index.js +0 -38
- package/dist/cjs/node/database/types.d.ts +0 -152
- package/dist/cjs/node/database/types.d.ts.map +0 -1
- package/dist/cjs/node/database/types.js +0 -51
- package/dist/cjs/node/database/utils.d.ts +0 -4
- package/dist/cjs/node/database/utils.d.ts.map +0 -1
- package/dist/cjs/node/database/utils.js +0 -53
- package/dist/cjs/node/index.d.ts.map +0 -1
- package/dist/cjs/node/jsonFile/index.d.ts.map +0 -1
- package/dist/cjs/node/mail/index.d.ts.map +0 -1
- package/dist/cjs/node.d.ts.map +0 -1
- package/dist/esm/browser/element.d.ts.map +0 -1
- package/dist/esm/browser/index.d.ts.map +0 -1
- package/dist/esm/browser/other.d.ts.map +0 -1
- package/dist/esm/browser/style.d.ts.map +0 -1
- package/dist/esm/browser.d.ts.map +0 -1
- package/dist/esm/common/classs.d.ts.map +0 -1
- package/dist/esm/common/dayjs.d.ts.map +0 -1
- package/dist/esm/common/index.d.ts.map +0 -1
- package/dist/esm/common/number.d.ts.map +0 -1
- package/dist/esm/common/object.d.ts.map +0 -1
- package/dist/esm/common/other.d.ts.map +0 -1
- package/dist/esm/common/string.d.ts.map +0 -1
- package/dist/esm/node/database/Collection.d.ts +0 -23
- package/dist/esm/node/database/Collection.d.ts.map +0 -1
- package/dist/esm/node/database/Database.d.ts +0 -11
- package/dist/esm/node/database/Database.d.ts.map +0 -1
- package/dist/esm/node/database/Database.js +0 -36
- package/dist/esm/node/database/index.d.ts +0 -3
- package/dist/esm/node/database/index.d.ts.map +0 -1
- package/dist/esm/node/database/index.js +0 -2
- package/dist/esm/node/database/types.d.ts +0 -152
- package/dist/esm/node/database/types.d.ts.map +0 -1
- package/dist/esm/node/database/types.js +0 -55
- package/dist/esm/node/database/utils.d.ts +0 -4
- package/dist/esm/node/database/utils.d.ts.map +0 -1
- package/dist/esm/node/database/utils.js +0 -29
- package/dist/esm/node/index.d.ts.map +0 -1
- package/dist/esm/node/jsonFile/index.d.ts.map +0 -1
- package/dist/esm/node/mail/index.d.ts.map +0 -1
- package/dist/esm/node.d.ts.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
3
|
+
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); } }
|
|
4
|
+
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); }); }; }
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
export var replaceContentInFile = /*#__PURE__*/function () {
|
|
7
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(filePath, targetContent, replacement) {
|
|
8
|
+
var data, updatedData;
|
|
9
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
10
|
+
while (1) switch (_context.prev = _context.next) {
|
|
11
|
+
case 0:
|
|
12
|
+
_context.prev = 0;
|
|
13
|
+
_context.next = 3;
|
|
14
|
+
return fs.readFile(filePath, 'utf8');
|
|
15
|
+
case 3:
|
|
16
|
+
data = _context.sent;
|
|
17
|
+
if (!(replacement && data.includes(replacement))) {
|
|
18
|
+
_context.next = 7;
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
console.error("\u5DF2\u66FF\u6362\u8FC7\uFF1A".concat(filePath));
|
|
22
|
+
return _context.abrupt("return");
|
|
23
|
+
case 7:
|
|
24
|
+
if (data.includes(targetContent)) {
|
|
25
|
+
_context.next = 10;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
console.error("\u4E0D\u5305\u542B\u76EE\u6807\u5185\u5BB9\uFF1A".concat(targetContent));
|
|
29
|
+
throw new Error("\u4E0D\u5305\u542B\u76EE\u6807\u5185\u5BB9\uFF1A".concat(targetContent));
|
|
30
|
+
case 10:
|
|
31
|
+
updatedData = data.replace(new RegExp(targetContent, 'g'), replacement);
|
|
32
|
+
_context.next = 13;
|
|
33
|
+
return fs.writeFile(filePath, updatedData, 'utf8');
|
|
34
|
+
case 13:
|
|
35
|
+
console.log("\u6210\u529F\u66FF\u6362\u6587\u4EF6\u4E2D\u7684\u5185\u5BB9\uFF01");
|
|
36
|
+
_context.next = 20;
|
|
37
|
+
break;
|
|
38
|
+
case 16:
|
|
39
|
+
_context.prev = 16;
|
|
40
|
+
_context.t0 = _context["catch"](0);
|
|
41
|
+
console.error("\u5904\u7406\u6587\u4EF6\u65F6\u53D1\u751F\u9519\u8BEF\uFF1A".concat(_context.t0));
|
|
42
|
+
throw _context.t0;
|
|
43
|
+
case 20:
|
|
44
|
+
case "end":
|
|
45
|
+
return _context.stop();
|
|
46
|
+
}
|
|
47
|
+
}, _callee, null, [[0, 16]]);
|
|
48
|
+
}));
|
|
49
|
+
return function replaceContentInFile(_x, _x2, _x3) {
|
|
50
|
+
return _ref.apply(this, arguments);
|
|
51
|
+
};
|
|
52
|
+
}();
|
package/dist/esm/node/index.d.ts
CHANGED
package/dist/esm/node/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare class JsonFile {
|
|
2
2
|
filePath: string;
|
|
3
3
|
constructor(filePath: string);
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
private ensureFileExists;
|
|
5
|
+
get(key: string): Promise<any>;
|
|
6
|
+
set(key: string, value: any): Promise<void>;
|
|
6
7
|
}
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,43 +1,101 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
3
|
+
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); } }
|
|
4
|
+
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); }); }; }
|
|
2
5
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
6
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
7
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
8
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
9
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
10
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
-
|
|
11
|
+
import fs from 'fs-extra';
|
|
9
12
|
var path = require('path');
|
|
10
13
|
|
|
11
|
-
//
|
|
14
|
+
// 通过 JSON 文件来存储和读取键值对数据
|
|
12
15
|
export var JsonFile = /*#__PURE__*/function () {
|
|
13
16
|
function JsonFile(filePath) {
|
|
14
17
|
_classCallCheck(this, JsonFile);
|
|
15
18
|
_defineProperty(this, "filePath", void 0);
|
|
16
19
|
this.filePath = path.resolve(__dirname, filePath);
|
|
20
|
+
this.ensureFileExists();
|
|
17
21
|
}
|
|
18
22
|
_createClass(JsonFile, [{
|
|
19
|
-
key: "
|
|
20
|
-
value: function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
23
|
+
key: "ensureFileExists",
|
|
24
|
+
value: function ensureFileExists() {
|
|
25
|
+
try {
|
|
26
|
+
if (!fs.existsSync(this.filePath)) {
|
|
27
|
+
fs.writeFileSync(this.filePath, '{}', 'utf-8');
|
|
28
|
+
}
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('Error ensuring file exists:', error);
|
|
31
|
+
}
|
|
28
32
|
}
|
|
33
|
+
}, {
|
|
34
|
+
key: "get",
|
|
35
|
+
value: function () {
|
|
36
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key) {
|
|
37
|
+
var data, json;
|
|
38
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
39
|
+
while (1) switch (_context.prev = _context.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
_context.prev = 0;
|
|
42
|
+
_context.next = 3;
|
|
43
|
+
return fs.readFile(this.filePath, 'utf-8');
|
|
44
|
+
case 3:
|
|
45
|
+
data = _context.sent;
|
|
46
|
+
json = data ? JSON.parse(data) : {};
|
|
47
|
+
return _context.abrupt("return", json[key]);
|
|
48
|
+
case 8:
|
|
49
|
+
_context.prev = 8;
|
|
50
|
+
_context.t0 = _context["catch"](0);
|
|
51
|
+
console.error('Error reading file:', _context.t0);
|
|
52
|
+
return _context.abrupt("return", null);
|
|
53
|
+
case 12:
|
|
54
|
+
case "end":
|
|
55
|
+
return _context.stop();
|
|
56
|
+
}
|
|
57
|
+
}, _callee, this, [[0, 8]]);
|
|
58
|
+
}));
|
|
59
|
+
function get(_x) {
|
|
60
|
+
return _get.apply(this, arguments);
|
|
61
|
+
}
|
|
62
|
+
return get;
|
|
63
|
+
}()
|
|
29
64
|
}, {
|
|
30
65
|
key: "set",
|
|
31
|
-
value: function
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
66
|
+
value: function () {
|
|
67
|
+
var _set = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
|
|
68
|
+
var data, json;
|
|
69
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
70
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
71
|
+
case 0:
|
|
72
|
+
_context2.prev = 0;
|
|
73
|
+
_context2.next = 3;
|
|
74
|
+
return fs.readFile(this.filePath, 'utf-8');
|
|
75
|
+
case 3:
|
|
76
|
+
data = _context2.sent;
|
|
77
|
+
json = data ? JSON.parse(data || '{}') : {};
|
|
78
|
+
json[key] = value;
|
|
79
|
+
_context2.next = 8;
|
|
80
|
+
return fs.writeFile(this.filePath, JSON.stringify(json, null, 2));
|
|
81
|
+
case 8:
|
|
82
|
+
_context2.next = 13;
|
|
83
|
+
break;
|
|
84
|
+
case 10:
|
|
85
|
+
_context2.prev = 10;
|
|
86
|
+
_context2.t0 = _context2["catch"](0);
|
|
87
|
+
console.error('Error writing file:', _context2.t0);
|
|
88
|
+
case 13:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context2.stop();
|
|
91
|
+
}
|
|
92
|
+
}, _callee2, this, [[0, 10]]);
|
|
93
|
+
}));
|
|
94
|
+
function set(_x2, _x3) {
|
|
95
|
+
return _set.apply(this, arguments);
|
|
96
|
+
}
|
|
97
|
+
return set;
|
|
98
|
+
}()
|
|
41
99
|
}]);
|
|
42
100
|
return JsonFile;
|
|
43
101
|
}();
|
package/dist/esm/node.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wzyjs/utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"description": "description",
|
|
5
5
|
"author": "wzy",
|
|
6
6
|
"scripts": {
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"typesVersions": {
|
|
21
21
|
"*": {
|
|
22
22
|
"*": [
|
|
23
|
-
"./dist/esm/browser.d.
|
|
23
|
+
"./dist/esm/browser.d.ts"
|
|
24
24
|
],
|
|
25
25
|
"node": [
|
|
26
|
-
"./dist/esm/node.d.
|
|
26
|
+
"./dist/esm/node.d.ts"
|
|
27
27
|
]
|
|
28
28
|
}
|
|
29
29
|
},
|
|
@@ -31,29 +31,29 @@
|
|
|
31
31
|
"dist"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@cloudbase/node-sdk": "^2.9.1",
|
|
35
|
-
"@types/nedb": "^1.8.16",
|
|
36
34
|
"animejs": "^3.2.1",
|
|
37
35
|
"axios": "^1.6.2",
|
|
38
36
|
"classnames": "^2.3.2",
|
|
39
37
|
"consola": "^2.15.3",
|
|
40
38
|
"copy-to-clipboard": "^3.3.3",
|
|
41
39
|
"dayjs": "^1.11.6",
|
|
40
|
+
"fs-extra": "^11.2.0",
|
|
42
41
|
"localforage": "^1.10.0",
|
|
43
42
|
"lodash": "^4.17.21",
|
|
44
43
|
"md5": "^2.3.0",
|
|
45
44
|
"nedb": "^1.8.0",
|
|
46
45
|
"nodemailer": "^6.9.1",
|
|
47
|
-
"tslib": "^2.4.1",
|
|
48
46
|
"zod": "^3.21.4"
|
|
49
47
|
},
|
|
50
48
|
"devDependencies": {
|
|
51
49
|
"@types/animejs": "^3.1.6",
|
|
50
|
+
"@types/fs-extra": "^11.0.4",
|
|
52
51
|
"@types/lodash": "^4.14.189",
|
|
53
52
|
"@types/md5": "^2.3.2",
|
|
53
|
+
"@types/nedb": "^1.8.16",
|
|
54
54
|
"@types/node": "^18.11.11",
|
|
55
55
|
"@types/nodemailer": "^6.4.7",
|
|
56
|
-
"@wzyjs/types": "^0.2.
|
|
56
|
+
"@wzyjs/types": "^0.2.14",
|
|
57
57
|
"father": "^4.2.3",
|
|
58
58
|
"typescript": "^4.9.3"
|
|
59
59
|
},
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"type": "git",
|
|
65
65
|
"url": "https://gitee.com/wang-zhenyu/app.git"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "4debf634852c7e5375d4dc5616e4e607005761c2"
|
|
68
68
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["element.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,cAAc,OAAQ,OAAO,WAAW,qBAAqB,SAKzE,CAAA;AAGD,eAAO,MAAM,UAAU,OAAQ,MAAM,GAAG,OAAO;;;;;;CAa9C,CAAA;AAGD,eAAO,MAAM,mBAAmB,OAAQ,MAAM,GAAG,OAAO,wBAYvD,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,IAAI,MAAM,mBAAmB,CAAA;AAGpC,OAAO,KAAK,MAAM,SAAS,CAAA;AAE3B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;AAEvC,eAAO,MAAM,WAAW;;;;;;;;;CAKvB,CAAA;AAED,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"other.d.ts","sourceRoot":"","sources":["other.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,uBAMzB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["style.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,SAAS,aAAc,MAAM;;;;;;;CAQzC,CAAA;AAGD,eAAO,MAAM,eAAe,OAAQ,MAAM,GAAG,OAAO,SAAS,MAAM,qBAclE,CAAA;AAGD,eAAO,MAAM,WAAW,OAAQ,MAAM,GAAG,OAAO,SAAS,MAAM,qBAc9D,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["browser.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"classs.d.ts","sourceRoot":"","sources":["classs.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,GAAG,CAAA;gBAEE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;CAMvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dayjs.d.ts","sourceRoot":"","sources":["dayjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,OAAO,oBAAoB,CAAA;AAgB3B,oBAAY,QAAQ;IAClB,YAAY,kBAAkB;CAC/B;AAED,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAE7B,eAAe,KAAK,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,EACJ,OAAO,EACP,IAAI,EACL,MAAM,QAAQ,CAAA;AAEf,OAAO,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,EACJ,OAAO,EACP,IAAI,GACL,CAAA;AAED,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAE3D,cAAc,KAAK,CAAA;AAEnB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AAExB,OAAO,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAErC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,OAAO,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["number.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,YAAY,QAAS,MAAM,OAAO,MAAM,WAEpD,CAAA;AAGD,eAAO,MAAM,aAAa,MAAO,MAAM,oCAAoB,OAAO,KAAG,MAUpE,CAAA;AAGD,eAAO,MAAM,WAAW,SAAU,MAAM,WASvC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["object.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,gFAEpB,CAAA;AAiCD,eAAO,MAAM,YAAY;;SAOxB,CAAA;AAGD,eAAO,MAAM,KAAK;;;YAC0B,MAAM,oBAAoB,GAAG,OAAO,GAAG,KAAK,SAAS;;CAuBhG,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"other.d.ts","sourceRoot":"","sources":["other.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAGjF,eAAO,MAAM,YAAY,oCAEjB,UAAU,UACR,YAAY,eACP,KAAK;;;;CAgCnB,CAAA;AAGD,eAAO,MAAM,cAAc,kBAAyB,GAAG,KAAG,QAAQ;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAMnG,CAAA;AAGD,eAAO,MAAM,cAAc,YAAmB,QAAQ,GAAG,CAAC;;;EAQzD,CAAA;AAGD,eAAO,MAAM,UAAU;;;;;;;wBA2BD,MAAM,SAAS,GAAG,YAAY,MAAM;;CAiCzD,CAAA;AAGD,eAAO,MAAM,KAAK,qCAEjB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["string.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,QAAS,MAAM,KAAG,MAW7C,CAAA;AAGD,eAAO,MAAM,YAAY,UAAW,MAAM,KAAG,MAM5C,CAAA;AAGD,eAAO,MAAM,UAAU,QAAS,MAAM,eAAe,MAAM,gBAAgB,MAAM,KAAG,MAYnF,CAAA;AAGD,eAAO,MAAM,cAAc,QAAS,MAAM,SAAS;IAAC,MAAM;IAAE,MAAM;CAAC,EAAE,WAKpE,CAAA;AAGD,eAAO,MAAM,OAAO,UAAW,GAAG,WAEjC,CAAA;AAGD,eAAO,MAAM,MAAM,QAAS,MAAM,WAGjC,CAAA;AAGD,eAAO,MAAM,SAAS,UAAW,MAAM,GAAG,MAAM,KAAG,MASlD,CAAA;AAGD,eAAO,MAAM,MAAM,QAAS,MAAM,YAQjC,CAAA;AAGD,eAAO,MAAM,QAAQ,UAAW,GAAG,WAElC,CAAA;AAGD,eAAO,MAAM,cAAc,QAAO,MAOjC,CAAA;AAGD,eAAO,MAAM,eAAe,uBAAiB,MAE5C,CAAA;AAGD,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,MAWxC,CAAA;AAGD,eAAO,MAAM,WAAW,QAAS,MAAM,UAAU,MAAM,SAAS,MAAM,WAErE,CAAA;AAGD,eAAO,MAAM,WAAW,QAAS,MAAM,WAGtC,CAAA;AAGD,eAAO,MAAM,SAAS,UAAW,MAAM,WAGtC,CAAA;AAGD,eAAO,MAAM,SAAS,SAAU,MAAM,kBAIrC,CAAA"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Database, IKeyValue } from '@cloudbase/node-sdk';
|
|
2
|
-
import { Add, Conditions, Count, Delete, Find, FindList, IdConditions, MethodParams, Update, WhereConditions } from './types';
|
|
3
|
-
export declare class Collection<D extends IKeyValue> {
|
|
4
|
-
private readonly db;
|
|
5
|
-
private readonly collection;
|
|
6
|
-
constructor(db: Database.Db, name: string);
|
|
7
|
-
private joinConditions;
|
|
8
|
-
private request;
|
|
9
|
-
private handleRes;
|
|
10
|
-
private handleData;
|
|
11
|
-
handleConditions(params: MethodParams<D>): MethodParams<D>;
|
|
12
|
-
private exec;
|
|
13
|
-
add(data: Add.Params<D>['data']): Promise<Add.Res>;
|
|
14
|
-
add(data: Add.Params<D>['data'], isReturn: true, conditions?: Pick<IdConditions, 'field'>): Promise<Find.Res<D>>;
|
|
15
|
-
delete(conditions: Conditions): Promise<Delete.Res>;
|
|
16
|
-
update(conditions: Conditions, data: Update.Params<D>['data'], isSet?: true): Promise<Update.Res<D>>;
|
|
17
|
-
update(conditions: IdConditions, data: Update.Params<D>['data'], isSet?: true): Promise<Update.Res<D>>;
|
|
18
|
-
update(conditions: IdConditions, data: Update.Params<D>['data'], isReturn: true, isSet?: true): Promise<Find.Res<D>>;
|
|
19
|
-
find(conditions?: Conditions): Promise<Find.Res<D>>;
|
|
20
|
-
findList(conditions?: WhereConditions): Promise<FindList.Res<D>>;
|
|
21
|
-
count(conditions: Conditions): Promise<Count.Res>;
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=Collection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["Collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAGpE,OAAO,EACL,GAAG,EACH,UAAU,EACV,KAAK,EACL,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,YAAY,EAKZ,YAAY,EAEZ,MAAM,EACN,eAAe,EAChB,MAAM,SAAS,CAAA;AAEhB,qBAAa,UAAU,CAAC,CAAC,SAAS,SAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAA;IACnB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAA;gBAEf,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM;IAMzC,OAAO,CAAC,cAAc;IAiDtB,OAAO,CAAC,OAAO;YA6BD,SAAS;YA4CT,UAAU;IAkBxB,gBAAgB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC;YAqD5C,IAAI;IAclB,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;IAClD,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAMhH,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC;IAKnD,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACpG,MAAM,CAAC,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACtG,MAAM,CAAC,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAMpH,IAAI,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAKnD,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAKhE,KAAK,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;CAGlD"}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/node/database/Collection.ts
|
|
20
|
-
var Collection_exports = {};
|
|
21
|
-
__export(Collection_exports, {
|
|
22
|
-
Collection: () => Collection
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(Collection_exports);
|
|
25
|
-
var import_lodash = require("lodash");
|
|
26
|
-
var import_utils = require("./utils");
|
|
27
|
-
var import_types = require("./types");
|
|
28
|
-
var Collection = class {
|
|
29
|
-
constructor(db, name) {
|
|
30
|
-
this.db = db;
|
|
31
|
-
this.collection = db.collection(name);
|
|
32
|
-
}
|
|
33
|
-
joinConditions(conditions) {
|
|
34
|
-
let record = this.collection;
|
|
35
|
-
if (!conditions) {
|
|
36
|
-
return record;
|
|
37
|
-
}
|
|
38
|
-
if ("_id" in conditions) {
|
|
39
|
-
record = record.doc(conditions._id);
|
|
40
|
-
} else {
|
|
41
|
-
const { page, order, where, options } = conditions;
|
|
42
|
-
if (options) {
|
|
43
|
-
record = record.options(options);
|
|
44
|
-
}
|
|
45
|
-
if (where) {
|
|
46
|
-
record = record.where(where);
|
|
47
|
-
}
|
|
48
|
-
if (order) {
|
|
49
|
-
record = record.orderBy(order.field, order.type || "desc");
|
|
50
|
-
}
|
|
51
|
-
if ((page == null ? void 0 : page.current) && (page == null ? void 0 : page.size)) {
|
|
52
|
-
record = record.skip((page.current - 1) * page.size);
|
|
53
|
-
}
|
|
54
|
-
if (page == null ? void 0 : page.size) {
|
|
55
|
-
record = record.limit(page.size);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (Array.isArray(conditions.field)) {
|
|
59
|
-
record = record.field(conditions.field.reduce((o, i) => ({ ...o, [i]: true }), {}));
|
|
60
|
-
} else if (conditions.field) {
|
|
61
|
-
record = record.field(conditions.field);
|
|
62
|
-
}
|
|
63
|
-
return record;
|
|
64
|
-
}
|
|
65
|
-
request(params) {
|
|
66
|
-
switch (params.method) {
|
|
67
|
-
case import_types.Method.Add:
|
|
68
|
-
return this.joinConditions().add(params.data);
|
|
69
|
-
case import_types.Method.Find:
|
|
70
|
-
case import_types.Method.FindList:
|
|
71
|
-
return this.joinConditions(params.conditions).get();
|
|
72
|
-
case import_types.Method.Delete:
|
|
73
|
-
return this.joinConditions(params.conditions).remove();
|
|
74
|
-
case import_types.Method.Update:
|
|
75
|
-
if (params.isSet && "_id" in params.conditions) {
|
|
76
|
-
return this.joinConditions(params.conditions).set(params.data);
|
|
77
|
-
}
|
|
78
|
-
return this.joinConditions(params.conditions).update(params.data);
|
|
79
|
-
case import_types.Method.Count:
|
|
80
|
-
return this.joinConditions(params.conditions).count();
|
|
81
|
-
default:
|
|
82
|
-
throw new Error("method is not exist");
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
// 处理出参
|
|
86
|
-
async handleRes(params, res) {
|
|
87
|
-
var _a, _b;
|
|
88
|
-
if (res) {
|
|
89
|
-
delete res.requestId;
|
|
90
|
-
}
|
|
91
|
-
let data = res;
|
|
92
|
-
switch (params.method) {
|
|
93
|
-
case import_types.Method.Add:
|
|
94
|
-
const addRes = res;
|
|
95
|
-
if (addRes.id && params.isReturn) {
|
|
96
|
-
data = await this.find({ _id: addRes.id, field: (_a = params.conditions) == null ? void 0 : _a.field });
|
|
97
|
-
}
|
|
98
|
-
break;
|
|
99
|
-
case import_types.Method.Update:
|
|
100
|
-
const updateRes = res;
|
|
101
|
-
if (updateRes.updated && params.isReturn && "_id" in params.conditions) {
|
|
102
|
-
data = await this.find({ _id: params.conditions._id, field: (_b = params.conditions) == null ? void 0 : _b.field });
|
|
103
|
-
}
|
|
104
|
-
break;
|
|
105
|
-
case import_types.Method.Find:
|
|
106
|
-
const getRes = res;
|
|
107
|
-
data = (getRes == null ? void 0 : getRes.data[0]) || null;
|
|
108
|
-
break;
|
|
109
|
-
case import_types.Method.FindList:
|
|
110
|
-
const getListRes = res;
|
|
111
|
-
const countRes = await this.request({
|
|
112
|
-
method: import_types.Method.Count,
|
|
113
|
-
conditions: params.conditions
|
|
114
|
-
});
|
|
115
|
-
data = {
|
|
116
|
-
list: getListRes.data,
|
|
117
|
-
total: countRes.total
|
|
118
|
-
};
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
return data;
|
|
122
|
-
}
|
|
123
|
-
// 处理数据
|
|
124
|
-
async handleData(params) {
|
|
125
|
-
switch (params.method) {
|
|
126
|
-
case import_types.Method.Add:
|
|
127
|
-
params.data = (0, import_utils.appendTime)(params.data, "create");
|
|
128
|
-
params.data = (0, import_utils.appendTime)(params.data, "update");
|
|
129
|
-
break;
|
|
130
|
-
case import_types.Method.Update:
|
|
131
|
-
if ("_id" in params.data) {
|
|
132
|
-
delete params.data._id;
|
|
133
|
-
}
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
return params;
|
|
137
|
-
}
|
|
138
|
-
// 处理条件
|
|
139
|
-
handleConditions(params) {
|
|
140
|
-
if (params.method !== import_types.Method.Add) {
|
|
141
|
-
params.conditions = (0, import_lodash.merge)((0, import_lodash.cloneDeep)(import_utils.defaultConditions), params.conditions);
|
|
142
|
-
}
|
|
143
|
-
if (params.conditions && "where" in params.conditions) {
|
|
144
|
-
const { command: _ } = this.db;
|
|
145
|
-
for (const key in params.conditions.where) {
|
|
146
|
-
const whereValue = params.conditions.where[key];
|
|
147
|
-
if ((0, import_lodash.isObject)(whereValue)) {
|
|
148
|
-
const { type, value } = whereValue;
|
|
149
|
-
switch (type) {
|
|
150
|
-
case import_types.Command.In:
|
|
151
|
-
params.conditions.where[key] = _.in(value);
|
|
152
|
-
break;
|
|
153
|
-
case import_types.Command.Nin:
|
|
154
|
-
params.conditions.where[key] = _.nin(value);
|
|
155
|
-
break;
|
|
156
|
-
case import_types.Command.Gt:
|
|
157
|
-
params.conditions.where[key] = _.gt(value);
|
|
158
|
-
break;
|
|
159
|
-
case import_types.Command.Gte:
|
|
160
|
-
params.conditions.where[key] = _.gte(value);
|
|
161
|
-
break;
|
|
162
|
-
case import_types.Command.Lt:
|
|
163
|
-
params.conditions.where[key] = _.lt(value);
|
|
164
|
-
break;
|
|
165
|
-
case import_types.Command.Lte:
|
|
166
|
-
params.conditions.where[key] = _.lte(value);
|
|
167
|
-
break;
|
|
168
|
-
case import_types.Command.Eq:
|
|
169
|
-
params.conditions.where[key] = _.eq(value);
|
|
170
|
-
break;
|
|
171
|
-
case import_types.Command.Neq:
|
|
172
|
-
params.conditions.where[key] = _.neq(value);
|
|
173
|
-
break;
|
|
174
|
-
case import_types.Command.Gtlt:
|
|
175
|
-
params.conditions.where[key] = _.and(_.gt(value[0]), _.lt(value[1]));
|
|
176
|
-
break;
|
|
177
|
-
default:
|
|
178
|
-
const check = type;
|
|
179
|
-
console.error(666, "处理 where 条件 出现未定义的情况", check);
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return params;
|
|
186
|
-
}
|
|
187
|
-
async exec(params) {
|
|
188
|
-
params = await this.handleData(params);
|
|
189
|
-
params = await this.handleConditions(params);
|
|
190
|
-
const res = await this.request(params);
|
|
191
|
-
return this.handleRes(params, res);
|
|
192
|
-
}
|
|
193
|
-
add(data, isReturn, conditions) {
|
|
194
|
-
return this.exec({ method: import_types.Method.Add, conditions, data, isReturn });
|
|
195
|
-
}
|
|
196
|
-
// 删
|
|
197
|
-
delete(conditions) {
|
|
198
|
-
return this.exec({ method: import_types.Method.Delete, conditions });
|
|
199
|
-
}
|
|
200
|
-
update(conditions, data, isReturn, isSet) {
|
|
201
|
-
return this.exec({ method: import_types.Method.Update, conditions, data, isReturn, isSet });
|
|
202
|
-
}
|
|
203
|
-
// 查
|
|
204
|
-
find(conditions) {
|
|
205
|
-
return this.exec({ method: import_types.Method.Find, conditions });
|
|
206
|
-
}
|
|
207
|
-
// 查列表
|
|
208
|
-
findList(conditions) {
|
|
209
|
-
return this.exec({ method: import_types.Method.FindList, conditions });
|
|
210
|
-
}
|
|
211
|
-
// 查
|
|
212
|
-
count(conditions) {
|
|
213
|
-
return this.exec({ method: import_types.Method.Count, conditions });
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
217
|
-
0 && (module.exports = {
|
|
218
|
-
Collection
|
|
219
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import tcb, { IKeyValue } from '@cloudbase/node-sdk';
|
|
2
|
-
import { Config } from './types';
|
|
3
|
-
import { Collection } from './Collection';
|
|
4
|
-
export declare class Database {
|
|
5
|
-
private readonly db;
|
|
6
|
-
private readonly instance;
|
|
7
|
-
constructor(config: Config);
|
|
8
|
-
collection<D extends IKeyValue>(name: string): Collection<D>;
|
|
9
|
-
createCollection(name: string): tcb.IBaseRes;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=Database.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["Database.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,EAAE,EAAQ,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAiB;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+C;gBAE5D,MAAM,EAAE,MAAM;IAKnB,UAAU,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC;IAQ5D,gBAAgB,CAAC,IAAI,EAAE,MAAM;CAGrC"}
|