@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';
|
|
@@ -528,7 +528,7 @@ function idToString(value) {
|
|
|
528
528
|
if (Array.isArray(value)) {
|
|
529
529
|
return value.map(idToString);
|
|
530
530
|
}
|
|
531
|
-
return value instanceof ObjectId || value instanceof Types.ObjectId
|
|
531
|
+
return value instanceof ObjectId || value instanceof mongoose.Types.ObjectId
|
|
532
532
|
? value.toHexString()
|
|
533
533
|
: (isString(value) ? value : value || null);
|
|
534
534
|
}
|
|
@@ -544,7 +544,9 @@ function createTransformer(transform) {
|
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
546
|
function broadcast(socketServer, cb) {
|
|
547
|
-
|
|
547
|
+
socketServer.sockets.sockets.forEach((client) => {
|
|
548
|
+
cb(client);
|
|
549
|
+
});
|
|
548
550
|
}
|
|
549
551
|
function rand(min, max) {
|
|
550
552
|
return Math.round(random(min, max));
|
|
@@ -818,11 +820,15 @@ function fixTextFileType(type, buffer) {
|
|
|
818
820
|
}
|
|
819
821
|
async function fileTypeFromBuffer(buffer) {
|
|
820
822
|
const stream = bufferToStream(buffer);
|
|
821
|
-
const type = (await
|
|
823
|
+
const type = (await fileType.fromStream(stream) ?? { ext: "txt", mime: "text/plain" });
|
|
822
824
|
if (checkTextFileType(type)) {
|
|
823
825
|
return fixTextFileType(type, buffer);
|
|
824
826
|
}
|
|
825
827
|
return type;
|
|
828
|
+
}
|
|
829
|
+
async function fileTypeFromStream(buffer) {
|
|
830
|
+
const stream = bufferToStream(buffer);
|
|
831
|
+
return (await fileType.fromStream(stream) ?? { ext: "txt", mime: "text/plain" });
|
|
826
832
|
}
|
|
827
833
|
|
|
828
834
|
let Configuration = class Configuration {
|
|
@@ -904,7 +910,7 @@ let MongoConnector = class MongoConnector {
|
|
|
904
910
|
async connect() {
|
|
905
911
|
if (this.db)
|
|
906
912
|
return this.db;
|
|
907
|
-
this.conn = (await connect(this.configuration.resolve("mongoUri"), {
|
|
913
|
+
this.conn = (await mongoose.connect(this.configuration.resolve("mongoUri"), {
|
|
908
914
|
dbName: this.configuration.resolve("mongoDb"),
|
|
909
915
|
user: this.configuration.resolve("mongoUser"),
|
|
910
916
|
pass: this.configuration.resolve("mongoPassword")
|
|
@@ -2388,9 +2394,10 @@ let OpenApi = class OpenApi {
|
|
|
2388
2394
|
return this.docsStr;
|
|
2389
2395
|
}
|
|
2390
2396
|
async schemaToExample(src, req) {
|
|
2391
|
-
|
|
2397
|
+
const maybeRef = src;
|
|
2398
|
+
if (maybeRef.$ref) {
|
|
2392
2399
|
const schemas = this.apiDocs.components.schemas;
|
|
2393
|
-
const schema =
|
|
2400
|
+
const schema = maybeRef.$ref
|
|
2394
2401
|
.replace("#/components/schemas/", "")
|
|
2395
2402
|
.replace("#/definitions/", "");
|
|
2396
2403
|
return this.schemaToExample(schemas[schema], req);
|
|
@@ -3090,13 +3097,6 @@ __decorate([
|
|
|
3090
3097
|
__metadata("design:paramtypes", []),
|
|
3091
3098
|
__metadata("design:returntype", void 0)
|
|
3092
3099
|
], TerminalController$1.prototype, "console", null);
|
|
3093
|
-
__decorate([
|
|
3094
|
-
Get(),
|
|
3095
|
-
Header("Content-Type", "text/html"),
|
|
3096
|
-
__metadata("design:type", Function),
|
|
3097
|
-
__metadata("design:paramtypes", [String]),
|
|
3098
|
-
__metadata("design:returntype", String)
|
|
3099
|
-
], TerminalController$1.prototype, "generateClient", null);
|
|
3100
3100
|
TerminalController$1 = __decorate([
|
|
3101
3101
|
injectable(),
|
|
3102
3102
|
Controller(),
|
|
@@ -3435,7 +3435,7 @@ let CompressionMiddleware = class CompressionMiddleware {
|
|
|
3435
3435
|
};
|
|
3436
3436
|
CompressionMiddleware = __decorate([
|
|
3437
3437
|
injectable(),
|
|
3438
|
-
Middleware$1()
|
|
3438
|
+
Middleware$1({})
|
|
3439
3439
|
], CompressionMiddleware);
|
|
3440
3440
|
|
|
3441
3441
|
class Tree {
|
|
@@ -3712,8 +3712,8 @@ class BaseDoc {
|
|
|
3712
3712
|
return getModelForClass(type);
|
|
3713
3713
|
}
|
|
3714
3714
|
}
|
|
3715
|
-
const PrimitiveArray = Types.Array;
|
|
3716
|
-
const DocumentArray = Types.DocumentArray;
|
|
3715
|
+
const PrimitiveArray = mongoose.Types.Array;
|
|
3716
|
+
const DocumentArray = mongoose.Types.DocumentArray;
|
|
3717
3717
|
|
|
3718
3718
|
function IsDocumented(summary = null, paramDescriptions = {}) {
|
|
3719
3719
|
return OpenAPI(op => {
|
|
@@ -3750,15 +3750,14 @@ function ResponseType(type, options = {}) {
|
|
|
3750
3750
|
const reference = {
|
|
3751
3751
|
$ref: `#/components/schemas/${type.name}`,
|
|
3752
3752
|
};
|
|
3753
|
-
const schema = options.isArray
|
|
3754
|
-
? { items: reference, type: "array" }
|
|
3755
|
-
: reference;
|
|
3756
3753
|
op.responses = op.responses || {};
|
|
3757
3754
|
op.responses[statusCode] = {
|
|
3758
3755
|
description: options.description || "Success",
|
|
3759
3756
|
content: {
|
|
3760
3757
|
[contentType]: {
|
|
3761
|
-
schema
|
|
3758
|
+
schema: options.isArray
|
|
3759
|
+
? { items: reference, type: "array" }
|
|
3760
|
+
: reference
|
|
3762
3761
|
}
|
|
3763
3762
|
}
|
|
3764
3763
|
};
|
|
@@ -3930,9 +3929,9 @@ function hydratePopulated(modelType, json) {
|
|
|
3930
3929
|
continue;
|
|
3931
3930
|
const value = getValue$1(path, json);
|
|
3932
3931
|
const hydrateVal = val => {
|
|
3933
|
-
if (val == null || val instanceof Types.ObjectId)
|
|
3932
|
+
if (val == null || val instanceof mongoose.Types.ObjectId)
|
|
3934
3933
|
return val;
|
|
3935
|
-
return hydratePopulated(model(ref), val);
|
|
3934
|
+
return hydratePopulated(mongoose.model(ref), val);
|
|
3936
3935
|
};
|
|
3937
3936
|
if (Array.isArray(value)) {
|
|
3938
3937
|
setValue(path, value.map(hydrateVal), object);
|
|
@@ -4307,5 +4306,5 @@ async function setupBackend(config, providers, parent) {
|
|
|
4307
4306
|
* Generated bundle index. Do not edit.
|
|
4308
4307
|
*/
|
|
4309
4308
|
|
|
4310
|
-
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 };
|
|
4309
|
+
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 };
|
|
4311
4310
|
//# sourceMappingURL=stemy-backend.mjs.map
|