@stemy/backend 4.0.5 → 5.0.1
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/common-types.d.ts +4 -2
- package/esm2020/common-types.mjs +1 -1
- package/esm2020/public_api.mjs +2 -2
- package/esm2020/rest-controllers/terminal.controller.mjs +1 -8
- package/esm2020/services/mongo-connector.mjs +3 -3
- package/esm2020/services/open-api.mjs +4 -3
- package/esm2020/socket-controllers/progress.controller.mjs +2 -2
- package/esm2020/socket-middlewares/compression.middleware.mjs +2 -2
- package/esm2020/utilities/base-doc.mjs +4 -4
- package/esm2020/utilities/decorators.mjs +4 -5
- package/esm2020/utilities/mongoose.mjs +4 -4
- package/esm2020/utils.mjs +12 -6
- package/fesm2015/stemy-backend.mjs +27 -25
- package/fesm2015/stemy-backend.mjs.map +1 -1
- package/fesm2020/stemy-backend.mjs +24 -25
- package/fesm2020/stemy-backend.mjs.map +1 -1
- package/package.json +45 -38
- package/public_api.d.ts +2 -2
- package/services/mongo-connector.d.ts +3 -3
- package/utilities/base-doc.d.ts +7 -6
- package/utils.d.ts +1 -0
|
@@ -16,9 +16,9 @@ import { createHash } from 'crypto';
|
|
|
16
16
|
import { Subscription, Observable, Subject, from, BehaviorSubject } from 'rxjs';
|
|
17
17
|
import { canReportError } from 'rxjs/internal/util/canReportError';
|
|
18
18
|
import { ObjectId, GridFSBucket } from 'mongodb';
|
|
19
|
-
import
|
|
19
|
+
import mongoose from 'mongoose';
|
|
20
20
|
import { Readable, PassThrough } from 'stream';
|
|
21
|
-
import
|
|
21
|
+
import fileType from 'file-type/core';
|
|
22
22
|
import dotenv from 'dotenv';
|
|
23
23
|
import cron from 'node-cron';
|
|
24
24
|
import { socket } from 'zeromq';
|
|
@@ -538,7 +538,7 @@ function idToString(value) {
|
|
|
538
538
|
if (Array.isArray(value)) {
|
|
539
539
|
return value.map(idToString);
|
|
540
540
|
}
|
|
541
|
-
return value instanceof ObjectId || value instanceof Types.ObjectId
|
|
541
|
+
return value instanceof ObjectId || value instanceof mongoose.Types.ObjectId
|
|
542
542
|
? value.toHexString()
|
|
543
543
|
: (isString(value) ? value : value || null);
|
|
544
544
|
}
|
|
@@ -554,7 +554,9 @@ function createTransformer(transform) {
|
|
|
554
554
|
};
|
|
555
555
|
}
|
|
556
556
|
function broadcast(socketServer, cb) {
|
|
557
|
-
|
|
557
|
+
socketServer.sockets.sockets.forEach((client) => {
|
|
558
|
+
cb(client);
|
|
559
|
+
});
|
|
558
560
|
}
|
|
559
561
|
function rand(min, max) {
|
|
560
562
|
return Math.round(random(min, max));
|
|
@@ -830,12 +832,19 @@ function fileTypeFromBuffer(buffer) {
|
|
|
830
832
|
var _a;
|
|
831
833
|
return __awaiter(this, void 0, void 0, function* () {
|
|
832
834
|
const stream = bufferToStream(buffer);
|
|
833
|
-
const type = ((_a = yield
|
|
835
|
+
const type = ((_a = yield fileType.fromStream(stream)) !== null && _a !== void 0 ? _a : { ext: "txt", mime: "text/plain" });
|
|
834
836
|
if (checkTextFileType(type)) {
|
|
835
837
|
return fixTextFileType(type, buffer);
|
|
836
838
|
}
|
|
837
839
|
return type;
|
|
838
840
|
});
|
|
841
|
+
}
|
|
842
|
+
function fileTypeFromStream(buffer) {
|
|
843
|
+
var _a;
|
|
844
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
845
|
+
const stream = bufferToStream(buffer);
|
|
846
|
+
return ((_a = yield fileType.fromStream(stream)) !== null && _a !== void 0 ? _a : { ext: "txt", mime: "text/plain" });
|
|
847
|
+
});
|
|
839
848
|
}
|
|
840
849
|
|
|
841
850
|
let Configuration = class Configuration {
|
|
@@ -918,7 +927,7 @@ let MongoConnector = class MongoConnector {
|
|
|
918
927
|
return __awaiter(this, void 0, void 0, function* () {
|
|
919
928
|
if (this.db)
|
|
920
929
|
return this.db;
|
|
921
|
-
this.conn = (yield connect(this.configuration.resolve("mongoUri"), {
|
|
930
|
+
this.conn = (yield mongoose.connect(this.configuration.resolve("mongoUri"), {
|
|
922
931
|
dbName: this.configuration.resolve("mongoDb"),
|
|
923
932
|
user: this.configuration.resolve("mongoUser"),
|
|
924
933
|
pass: this.configuration.resolve("mongoPassword")
|
|
@@ -2554,9 +2563,10 @@ let OpenApi = class OpenApi {
|
|
|
2554
2563
|
schemaToExample(src, req) {
|
|
2555
2564
|
var _a, _b, _c;
|
|
2556
2565
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2557
|
-
|
|
2566
|
+
const maybeRef = src;
|
|
2567
|
+
if (maybeRef.$ref) {
|
|
2558
2568
|
const schemas = this.apiDocs.components.schemas;
|
|
2559
|
-
const schema =
|
|
2569
|
+
const schema = maybeRef.$ref
|
|
2560
2570
|
.replace("#/components/schemas/", "")
|
|
2561
2571
|
.replace("#/definitions/", "");
|
|
2562
2572
|
return this.schemaToExample(schemas[schema], req);
|
|
@@ -3281,13 +3291,6 @@ __decorate([
|
|
|
3281
3291
|
__metadata("design:paramtypes", []),
|
|
3282
3292
|
__metadata("design:returntype", void 0)
|
|
3283
3293
|
], TerminalController$1.prototype, "console", null);
|
|
3284
|
-
__decorate([
|
|
3285
|
-
Get(),
|
|
3286
|
-
Header("Content-Type", "text/html"),
|
|
3287
|
-
__metadata("design:type", Function),
|
|
3288
|
-
__metadata("design:paramtypes", [String]),
|
|
3289
|
-
__metadata("design:returntype", String)
|
|
3290
|
-
], TerminalController$1.prototype, "generateClient", null);
|
|
3291
3294
|
TerminalController$1 = __decorate([
|
|
3292
3295
|
injectable(),
|
|
3293
3296
|
Controller(),
|
|
@@ -3645,7 +3648,7 @@ let CompressionMiddleware = class CompressionMiddleware {
|
|
|
3645
3648
|
};
|
|
3646
3649
|
CompressionMiddleware = __decorate([
|
|
3647
3650
|
injectable(),
|
|
3648
|
-
Middleware$1()
|
|
3651
|
+
Middleware$1({})
|
|
3649
3652
|
], CompressionMiddleware);
|
|
3650
3653
|
|
|
3651
3654
|
class Tree {
|
|
@@ -3931,8 +3934,8 @@ class BaseDoc {
|
|
|
3931
3934
|
return getModelForClass(type);
|
|
3932
3935
|
}
|
|
3933
3936
|
}
|
|
3934
|
-
const PrimitiveArray = Types.Array;
|
|
3935
|
-
const DocumentArray = Types.DocumentArray;
|
|
3937
|
+
const PrimitiveArray = mongoose.Types.Array;
|
|
3938
|
+
const DocumentArray = mongoose.Types.DocumentArray;
|
|
3936
3939
|
|
|
3937
3940
|
function IsDocumented(summary = null, paramDescriptions = {}) {
|
|
3938
3941
|
return OpenAPI(op => {
|
|
@@ -3971,15 +3974,14 @@ function ResponseType(type, options = {}) {
|
|
|
3971
3974
|
const reference = {
|
|
3972
3975
|
$ref: `#/components/schemas/${type.name}`,
|
|
3973
3976
|
};
|
|
3974
|
-
const schema = options.isArray
|
|
3975
|
-
? { items: reference, type: "array" }
|
|
3976
|
-
: reference;
|
|
3977
3977
|
op.responses = op.responses || {};
|
|
3978
3978
|
op.responses[statusCode] = {
|
|
3979
3979
|
description: options.description || "Success",
|
|
3980
3980
|
content: {
|
|
3981
3981
|
[contentType]: {
|
|
3982
|
-
schema
|
|
3982
|
+
schema: options.isArray
|
|
3983
|
+
? { items: reference, type: "array" }
|
|
3984
|
+
: reference
|
|
3983
3985
|
}
|
|
3984
3986
|
}
|
|
3985
3987
|
};
|
|
@@ -4154,9 +4156,9 @@ function hydratePopulated(modelType, json) {
|
|
|
4154
4156
|
continue;
|
|
4155
4157
|
const value = getValue$1(path, json);
|
|
4156
4158
|
const hydrateVal = val => {
|
|
4157
|
-
if (val == null || val instanceof Types.ObjectId)
|
|
4159
|
+
if (val == null || val instanceof mongoose.Types.ObjectId)
|
|
4158
4160
|
return val;
|
|
4159
|
-
return hydratePopulated(model(ref), val);
|
|
4161
|
+
return hydratePopulated(mongoose.model(ref), val);
|
|
4160
4162
|
};
|
|
4161
4163
|
if (Array.isArray(value)) {
|
|
4162
4164
|
setValue(path, value.map(hydrateVal), object);
|
|
@@ -4524,5 +4526,5 @@ function setupBackend(config, providers, parent) {
|
|
|
4524
4526
|
* Generated bundle index. Do not edit.
|
|
4525
4527
|
*/
|
|
4526
4528
|
|
|
4527
|
-
export { AssetImageParams, AssetProcessor, AssetResolver, Assets, AuthController, BackendProvider, BaseDoc, Cache, CacheProcessor, Configuration, ConsoleColor, DI_CONTAINER, DocumentArray, EXPRESS, EndpointProvider, ErrorHandlerMiddleware, FIXTURE, Fixtures, Gallery, GalleryCache, GalleryController, HTTP_SERVER, IdGenerator, IsDocumented, IsFile, IsObjectId, JOB, JobManager, JsonResponse, LanguageMiddleware, LazyAssetGenerator, LazyAssets, Logger, MailSender, MemoryCache, MongoConnector, OPENAPI_VALIDATION, OpenApi, PARAMETER, Parameter, PrimitiveArray, Progresses, ResolveEntity, ResponseType, SOCKET_CONTROLLERS, SOCKET_SERVER, TERMINAL_COMMAND, TemplateRenderer, TerminalManager, TokenGenerator, TranslationProvider, Translator, Type, UserManager, assign, broadcast, bufferToStream, camelCaseToDash, colorize, convertValue, copy, copyStream, createIdString, createServices, createTransformer, deleteFile, deleteFromBucket, fileTypeFromBuffer, filter, firstItem, flatten, getConstructorName, getDirName, getExtension, getFileName, getFunctionParams, getType, getValue, groupBy, hydratePopulated, idToString, injectServices, isArray, isBoolean, isBuffer, isConstructor, isDate, isDefined, isFunction, isInterface, isNullOrUndefined, isObject, isObjectId, isPrimitive, isString, isType, jsonHighlight, lastItem, lcFirst, letsLookupStage, lookupStages, matchField, matchFieldStages, matchStage, md5, mkdirRecursive, multiSubscription, observableFromFunction, padLeft, padRight, paginate, paginateAggregations, prepareUrl, prepareUrlEmpty, prepareUrlSlash, projectStage, promiseTimeout, rand, random, readAndDeleteFile, readFile, regexEscape, regroup, replaceSpecialChars, resolveUser, runCommand, service, setupBackend, streamToBuffer, toImage, ucFirst, uniqueItems, unwindStage, valueToPromise, wrapError, writeFile };
|
|
4529
|
+
export { AssetImageParams, AssetProcessor, AssetResolver, Assets, AuthController, BackendProvider, BaseDoc, Cache, CacheProcessor, Configuration, ConsoleColor, DI_CONTAINER, DocumentArray, EXPRESS, EndpointProvider, ErrorHandlerMiddleware, FIXTURE, Fixtures, Gallery, GalleryCache, GalleryController, HTTP_SERVER, IdGenerator, IsDocumented, IsFile, IsObjectId, JOB, JobManager, JsonResponse, LanguageMiddleware, LazyAssetGenerator, LazyAssets, Logger, MailSender, MemoryCache, MongoConnector, OPENAPI_VALIDATION, OpenApi, PARAMETER, Parameter, PrimitiveArray, Progresses, ResolveEntity, ResponseType, SOCKET_CONTROLLERS, SOCKET_SERVER, TERMINAL_COMMAND, TemplateRenderer, TerminalManager, TokenGenerator, TranslationProvider, Translator, Type, UserManager, assign, broadcast, bufferToStream, camelCaseToDash, colorize, convertValue, copy, copyStream, createIdString, createServices, createTransformer, deleteFile, deleteFromBucket, fileTypeFromBuffer, fileTypeFromStream, filter, firstItem, flatten, getConstructorName, getDirName, getExtension, getFileName, getFunctionParams, getType, getValue, groupBy, hydratePopulated, idToString, injectServices, isArray, isBoolean, isBuffer, isConstructor, isDate, isDefined, isFunction, isInterface, isNullOrUndefined, isObject, isObjectId, isPrimitive, isString, isType, jsonHighlight, lastItem, lcFirst, letsLookupStage, lookupStages, matchField, matchFieldStages, matchStage, md5, mkdirRecursive, multiSubscription, observableFromFunction, padLeft, padRight, paginate, paginateAggregations, prepareUrl, prepareUrlEmpty, prepareUrlSlash, projectStage, promiseTimeout, rand, random, readAndDeleteFile, readFile, regexEscape, regroup, replaceSpecialChars, resolveUser, runCommand, service, setupBackend, streamToBuffer, toImage, ucFirst, uniqueItems, unwindStage, valueToPromise, wrapError, writeFile };
|
|
4528
4530
|
//# sourceMappingURL=stemy-backend.mjs.map
|