cgserver 13.3.3 → 14.0.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/lib/Framework/Database/Mongo/MongoBaseService.js +4 -37
- package/dist/lib/Framework/Database/Mongo/MongoManager.js +8 -9
- package/dist/lib/Framework/Server/WebServer/Engine/Response.js +1 -1
- package/dist/lib/Framework/ThirdParty/AlipayTool.js +1 -1
- package/dist/lib/Framework/ThirdParty/WechatTool.js +0 -8
- package/dist/lib/Framework/global.js +0 -2
- package/dist/types/Framework/Core/Core.d.ts +2 -2
- package/dist/types/Framework/Database/Mongo/MongoBaseService.d.ts +16 -13
- package/dist/types/Framework/Database/Mongo/MongoManager.d.ts +12 -13
- package/dist/types/Framework/Database/Redis/RedisManager.d.ts +302 -282
- package/dist/types/Framework/ThirdParty/AppleTool.d.ts +1 -1
- package/dist/types/Framework/ThirdParty/QiniuTool.d.ts +1 -1
- package/dist/types/Framework/global.d.ts +0 -1
- package/package.json +25 -37
|
@@ -1,49 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
7
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
8
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
42
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
10
|
};
|
|
44
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
12
|
exports.GMongoAutoIdsSer = exports.MongoBaseService = void 0;
|
|
46
|
-
const mongoose_1 =
|
|
13
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
47
14
|
const Log_1 = require("../../Logic/Log");
|
|
48
15
|
const MongoManager_1 = require("./MongoManager");
|
|
49
16
|
const SyncCall_1 = require("../../Decorator/SyncCall");
|
|
@@ -103,8 +70,8 @@ class MongoBaseService {
|
|
|
103
70
|
let ret = await this.mongo.create(this.model, doc);
|
|
104
71
|
return ret;
|
|
105
72
|
}
|
|
106
|
-
async insert(doc) {
|
|
107
|
-
let ret = await this.mongo.insert(this.model, doc);
|
|
73
|
+
async insert(doc, options) {
|
|
74
|
+
let ret = await this.mongo.insert(this.model, doc, options);
|
|
108
75
|
return ret;
|
|
109
76
|
}
|
|
110
77
|
async updateOne(filter, update, options) {
|
|
@@ -147,7 +114,7 @@ class MongoBaseService {
|
|
|
147
114
|
}
|
|
148
115
|
}
|
|
149
116
|
exports.MongoBaseService = MongoBaseService;
|
|
150
|
-
const autoIdSchema = new mongoose_1.Schema({
|
|
117
|
+
const autoIdSchema = new mongoose_1.default.Schema({
|
|
151
118
|
_id: { type: String },
|
|
152
119
|
autoid: { type: Number, required: true, default: 0 }
|
|
153
120
|
}, { id: false });
|
|
@@ -10,10 +10,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.gMongoMgr = exports.MongoExt = exports.MongoManager = exports.MgReturn = exports.MrResult = exports.MongoConfig = void 0;
|
|
13
|
-
const mongoose_1 = require("mongoose");
|
|
14
13
|
const Core_1 = require("../../Core/Core");
|
|
15
14
|
const Log_1 = require("../../Logic/Log");
|
|
16
|
-
const
|
|
15
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
17
16
|
const MongoActionCheck_1 = require("../../Decorator/MongoActionCheck");
|
|
18
17
|
class MongoConfig {
|
|
19
18
|
open = false;
|
|
@@ -141,15 +140,15 @@ class MongoExt {
|
|
|
141
140
|
this._inited = true;
|
|
142
141
|
Log_1.gLog.info("mongo config=" + JSON.stringify(this._mongocfg));
|
|
143
142
|
this._mongocfg.options.dbName = this._mongocfg.database;
|
|
144
|
-
this._connection =
|
|
143
|
+
this._connection = mongoose_1.default.createConnection("mongodb://" + this._mongocfg.host + ":" + this._mongocfg.port, this._mongocfg.options);
|
|
145
144
|
this._connection = this._connection.useDb(this._mongocfg.database);
|
|
146
145
|
this._connection.once("open", this.onOpen.bind(this));
|
|
147
146
|
this._connection.on("close", this.onClose.bind(this));
|
|
148
147
|
this._connection.on("connectionCreated", this.onConnect.bind(this));
|
|
149
148
|
this._connection.on("connectionClosed", this.onDisconnect.bind(this));
|
|
150
149
|
await this._connection.asPromise();
|
|
151
|
-
while (this._connection.readyState != mongoose_1.ConnectionStates.connected) {
|
|
152
|
-
if (this._connection.readyState != mongoose_1.ConnectionStates.connecting) {
|
|
150
|
+
while (this._connection.readyState != mongoose_1.default.ConnectionStates.connected) {
|
|
151
|
+
if (this._connection.readyState != mongoose_1.default.ConnectionStates.connecting) {
|
|
153
152
|
Log_1.gLog.error("MongoDB connection is not ready, please check the connection settings. Current state: " + this._connection.readyState);
|
|
154
153
|
return false;
|
|
155
154
|
}
|
|
@@ -236,12 +235,12 @@ class MongoExt {
|
|
|
236
235
|
let one = await newDoc.save();
|
|
237
236
|
return one;
|
|
238
237
|
}
|
|
239
|
-
async insert(model, doc) {
|
|
238
|
+
async insert(model, doc, options) {
|
|
240
239
|
if (!model) {
|
|
241
240
|
Log_1.gLog.error("Model is not defined");
|
|
242
241
|
return null;
|
|
243
242
|
}
|
|
244
|
-
const newDoc = await model.insertOne(doc);
|
|
243
|
+
const newDoc = await model.insertOne(doc, options);
|
|
245
244
|
return newDoc;
|
|
246
245
|
}
|
|
247
246
|
async updateOne(model, filter, update, options) {
|
|
@@ -322,7 +321,7 @@ class MongoExt {
|
|
|
322
321
|
return {};
|
|
323
322
|
}
|
|
324
323
|
if (filter.id && typeof filter.id === 'string') {
|
|
325
|
-
filter._id = new mongoose_1.Types.ObjectId(filter.id);
|
|
324
|
+
filter._id = new mongoose_1.default.Types.ObjectId(filter.id);
|
|
326
325
|
delete filter.id;
|
|
327
326
|
}
|
|
328
327
|
else if (filter.id) {
|
|
@@ -335,7 +334,7 @@ class MongoExt {
|
|
|
335
334
|
if (!one) {
|
|
336
335
|
return one;
|
|
337
336
|
}
|
|
338
|
-
if (typeof one._id === 'object' && one._id instanceof mongoose_1.Types.ObjectId) {
|
|
337
|
+
if (typeof one._id === 'object' && one._id instanceof mongoose_1.default.Types.ObjectId) {
|
|
339
338
|
one.id = one._id.toString();
|
|
340
339
|
}
|
|
341
340
|
else {
|
|
@@ -103,7 +103,7 @@ class Response {
|
|
|
103
103
|
let size = stats.size;
|
|
104
104
|
var f = fs.createReadStream(fullPath);
|
|
105
105
|
this._res.writeHead(200, {
|
|
106
|
-
'Content-Type': mime.getType(fullPath) || 'application/octet-stream',
|
|
106
|
+
'Content-Type': mime.default.getType(fullPath) || 'application/octet-stream',
|
|
107
107
|
'Content-Disposition': 'attachment; filename=' + fileName,
|
|
108
108
|
'Content-Length': size
|
|
109
109
|
});
|
|
@@ -40,14 +40,6 @@ const IServerConfig_1 = require("../Config/IServerConfig");
|
|
|
40
40
|
const Log_1 = require("../Logic/Log");
|
|
41
41
|
const HttpTool_1 = require("../Logic/HttpTool");
|
|
42
42
|
class WechatOAMsg {
|
|
43
|
-
// <xml>
|
|
44
|
-
// <ToUserName><![CDATA[toUser]]></ToUserName>
|
|
45
|
-
// <FromUserName><![CDATA[fromUser]]></FromUserName>
|
|
46
|
-
// <CreateTime>1348831860</CreateTime>
|
|
47
|
-
// <MsgType><![CDATA[text]]></MsgType>
|
|
48
|
-
// <Content><![CDATA[this is a test]]></Content>
|
|
49
|
-
// <MsgId>1234567890123456</MsgId>
|
|
50
|
-
// </xml>
|
|
51
43
|
toUserName = "";
|
|
52
44
|
fromUserName = ""; //其实是一个userid
|
|
53
45
|
createTime = -1;
|
|
@@ -19,7 +19,6 @@ const Alisms_1 = require("./ThirdParty/Alisms");
|
|
|
19
19
|
const AppleTool_1 = require("./ThirdParty/AppleTool");
|
|
20
20
|
const EmailTool_1 = require("./ThirdParty/EmailTool");
|
|
21
21
|
const QQTool_1 = require("./ThirdParty/QQTool");
|
|
22
|
-
const QiniuTool_1 = require("./ThirdParty/QiniuTool");
|
|
23
22
|
const WechatTool_1 = require("./ThirdParty/WechatTool");
|
|
24
23
|
const ControllerManager_1 = require("./Server/WebServer/Engine/ControllerManager");
|
|
25
24
|
const cgserver_1 = require("./cgserver");
|
|
@@ -45,7 +44,6 @@ class global {
|
|
|
45
44
|
static gByteTool = ByteTool_1.gByteTool;
|
|
46
45
|
static gSmsTool = Alisms_1.gSMSTool;
|
|
47
46
|
static gEmailTool = EmailTool_1.gEmailTool;
|
|
48
|
-
static gQiniuTool = QiniuTool_1.gQiniuTool;
|
|
49
47
|
static gQQTool = QQTool_1.gQQTool;
|
|
50
48
|
static gWechatTool = WechatTool_1.gWechatTool;
|
|
51
49
|
static gWechatOATool = WechatTool_1.gWechatTool;
|
|
@@ -113,6 +113,6 @@ export declare class core {
|
|
|
113
113
|
static aesEncode(content: string, key: string, iv: string): string;
|
|
114
114
|
static aesDecode(base64_str: string, key: string, iv: string): string;
|
|
115
115
|
static getUuid(): string;
|
|
116
|
-
static signatureBase64(private_key: string, rsa_name: string, payload: string):
|
|
117
|
-
static signatureVerifyBase64(signature: string, private_key: string, rsa_name: string, payload: string):
|
|
116
|
+
static signatureBase64(private_key: string, rsa_name: string, payload: string): NonSharedBuffer;
|
|
117
|
+
static signatureVerifyBase64(signature: string, private_key: string, rsa_name: string, payload: string): boolean;
|
|
118
118
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import mongoose
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
2
|
import { IMongoBaseModel, MongoExt } from './MongoManager';
|
|
3
|
+
export type PartialModel<T> = Partial<mongoose.ApplyBasicCreateCasting<T>>;
|
|
3
4
|
export declare class MongoBaseService<T extends IMongoBaseModel> {
|
|
4
5
|
protected _model: mongoose.Model<T>;
|
|
5
6
|
protected _schema: mongoose.Schema<T>;
|
|
@@ -7,21 +8,23 @@ export declare class MongoBaseService<T extends IMongoBaseModel> {
|
|
|
7
8
|
protected _dbname: string;
|
|
8
9
|
protected _mongo: MongoExt;
|
|
9
10
|
get mongo(): MongoExt;
|
|
10
|
-
get model(): mongoose.Model<T, {}, {}, {}, mongoose.IfAny<T, any, mongoose.Document<unknown, {}, T, {}> & mongoose.
|
|
11
|
+
get model(): mongoose.Model<T, {}, {}, {}, mongoose.IfAny<T, any, mongoose.Document<unknown, {}, T, {}, mongoose.DefaultSchemaOptions> & mongoose.Require_id<T> & {
|
|
12
|
+
__v: number;
|
|
13
|
+
}>, any, T>;
|
|
11
14
|
constructor(collection_name: string, schema: mongoose.Schema<T>, dbname?: string);
|
|
12
|
-
findOne(filter?:
|
|
13
|
-
find(filter?:
|
|
14
|
-
findById(id:
|
|
15
|
+
findOne(filter?: mongoose.QueryFilter<T>, projection?: any, options?: any): Promise<T | null>;
|
|
16
|
+
find(filter?: mongoose.QueryFilter<T>, projection?: mongoose.ProjectionType<T>, options?: mongoose.QueryOptions): Promise<T[]>;
|
|
17
|
+
findById(id: any, projection?: mongoose.ProjectionType<T>, options?: mongoose.QueryOptions): Promise<T>;
|
|
15
18
|
create(doc: Partial<T>): Promise<T>;
|
|
16
|
-
insert(doc: Partial<T
|
|
17
|
-
updateOne(filter:
|
|
18
|
-
updateMany(filter:
|
|
19
|
-
deleteOne(filter:
|
|
20
|
-
deleteMany(filter:
|
|
21
|
-
exists(filter:
|
|
19
|
+
insert(doc: Partial<T>, options?: mongoose.SaveOptions): Promise<T>;
|
|
20
|
+
updateOne(filter: mongoose.QueryFilter<T>, update: mongoose.UpdateQuery<T>, options?: mongoose.mongo.UpdateOptions): Promise<mongoose.UpdateWriteOpResult>;
|
|
21
|
+
updateMany(filter: mongoose.QueryFilter<T>, update: mongoose.UpdateQuery<T> | mongoose.UpdateWithAggregationPipeline, options?: (mongoose.mongo.UpdateOptions & mongoose.MongooseUpdateQueryOptions<T>) | null): Promise<mongoose.UpdateWriteOpResult>;
|
|
22
|
+
deleteOne(filter: mongoose.QueryFilter<T>): Promise<number>;
|
|
23
|
+
deleteMany(filter: mongoose.QueryFilter<T>): Promise<number>;
|
|
24
|
+
exists(filter: mongoose.QueryFilter<T>): Promise<boolean>;
|
|
22
25
|
aggregate(pipeline?: any[]): mongoose.Aggregate<any[]>;
|
|
23
|
-
findOneAndUpdate(filter:
|
|
24
|
-
countDocuments(filter?:
|
|
26
|
+
findOneAndUpdate(filter: mongoose.QueryFilter<T>, update: mongoose.UpdateQuery<T> | mongoose.UpdateWithAggregationPipeline, options?: mongoose.QueryOptions<T> | null): Promise<T>;
|
|
27
|
+
countDocuments(filter?: mongoose.QueryFilter<T>): Promise<number>;
|
|
25
28
|
getAutoIds(): Promise<number>;
|
|
26
29
|
}
|
|
27
30
|
export interface IAutoIdModel extends IMongoBaseModel {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import mongoose, { FilterQuery, MongooseQueryOptions } from 'mongoose';
|
|
1
|
+
import mongoose from 'mongoose';
|
|
3
2
|
export interface IMongoBaseModel {
|
|
4
3
|
_id: any;
|
|
5
4
|
id: any;
|
|
@@ -75,19 +74,19 @@ export declare class MongoExt {
|
|
|
75
74
|
available: any;
|
|
76
75
|
}>;
|
|
77
76
|
onError(err: Error): void;
|
|
78
|
-
findOne<T>(model: mongoose.Model<T>, filter?:
|
|
79
|
-
find<T>(model: mongoose.Model<T>, filter?:
|
|
80
|
-
findById<T>(model: mongoose.Model<T>, id: any, projection?: mongoose.ProjectionType<T>, options?:
|
|
77
|
+
findOne<T>(model: mongoose.Model<T>, filter?: mongoose.QueryFilter<T>, projection?: any, options?: any): Promise<T | null>;
|
|
78
|
+
find<T>(model: mongoose.Model<T>, filter?: mongoose.QueryFilter<T>, projection?: mongoose.ProjectionType<T>, options?: mongoose.QueryOptions): Promise<T[]>;
|
|
79
|
+
findById<T>(model: mongoose.Model<T>, id: any, projection?: mongoose.ProjectionType<T>, options?: mongoose.QueryOptions): Promise<T | null>;
|
|
81
80
|
create<T>(model: mongoose.Model<T>, doc: Partial<T>): Promise<T>;
|
|
82
|
-
insert<T>(model: mongoose.Model<T>, doc: Partial<T
|
|
83
|
-
updateOne<T>(model: mongoose.Model<T>, filter:
|
|
84
|
-
updateMany<T>(model: mongoose.Model<T>, filter:
|
|
85
|
-
deleteOne<T>(model: mongoose.Model<T>, filter:
|
|
86
|
-
deleteMany<T>(model: mongoose.Model<T>, filter:
|
|
87
|
-
exists<T>(model: mongoose.Model<T>, filter:
|
|
81
|
+
insert<T>(model: mongoose.Model<T>, doc: Partial<T>, options?: mongoose.SaveOptions): Promise<T>;
|
|
82
|
+
updateOne<T>(model: mongoose.Model<T>, filter: mongoose.QueryFilter<T>, update: mongoose.UpdateQuery<T> | mongoose.UpdateWithAggregationPipeline, options?: (mongoose.mongo.UpdateOptions & mongoose.MongooseUpdateQueryOptions<T>) | null): Promise<mongoose.UpdateWriteOpResult>;
|
|
83
|
+
updateMany<T>(model: mongoose.Model<T>, filter: mongoose.UpdateQuery<T> | mongoose.UpdateWithAggregationPipeline, update: mongoose.UpdateQuery<T> | mongoose.UpdateWithAggregationPipeline, options?: (mongoose.mongo.UpdateOptions & mongoose.MongooseUpdateQueryOptions<T>) | null): Promise<mongoose.UpdateWriteOpResult>;
|
|
84
|
+
deleteOne<T>(model: mongoose.Model<T>, filter: mongoose.QueryFilter<T>): Promise<number>;
|
|
85
|
+
deleteMany<T>(model: mongoose.Model<T>, filter: mongoose.QueryFilter<T>): Promise<number>;
|
|
86
|
+
exists<T>(model: mongoose.Model<T>, filter: mongoose.QueryFilter<T>): Promise<boolean>;
|
|
88
87
|
aggregate<T>(model: mongoose.Model<T>, pipeline?: any[]): mongoose.Aggregate<any[]>;
|
|
89
|
-
findOneAndUpdate<T>(model: mongoose.Model<T>, filter:
|
|
90
|
-
countDocuments<T>(model: mongoose.Model<T>, filter?:
|
|
88
|
+
findOneAndUpdate<T>(model: mongoose.Model<T>, filter: mongoose.QueryFilter<T>, update: mongoose.UpdateQuery<T> | mongoose.UpdateWithAggregationPipeline, options?: mongoose.QueryOptions<T> | null): Promise<T>;
|
|
89
|
+
countDocuments<T>(model: mongoose.Model<T>, filter?: mongoose.QueryFilter<T>): Promise<number>;
|
|
91
90
|
protected _convertFilter(filter: any): any;
|
|
92
91
|
protected _convertId(one: any): any;
|
|
93
92
|
}
|