@stemy/backend 4.0.4 → 5.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/esm2020/public_api.mjs +2 -2
- package/esm2020/services/mongo-connector.mjs +3 -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/mongoose.mjs +4 -4
- package/esm2020/utils.mjs +20 -16
- package/fesm2015/stemy-backend.mjs +29 -22
- package/fesm2015/stemy-backend.mjs.map +1 -1
- package/fesm2020/stemy-backend.mjs +26 -22
- package/fesm2020/stemy-backend.mjs.map +1 -1
- package/package.json +45 -38
- package/public_api.d.ts +1 -1
- 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
|
}
|
|
@@ -622,17 +622,6 @@ function copyRecursive(target, source, predicate) {
|
|
|
622
622
|
}
|
|
623
623
|
if (isBuffer(source))
|
|
624
624
|
return Buffer.from(source);
|
|
625
|
-
// Copy map entries
|
|
626
|
-
if (target instanceof Map) {
|
|
627
|
-
if (source instanceof Map) {
|
|
628
|
-
for (let [key, value] of source.entries()) {
|
|
629
|
-
if (!predicate(value, key, target, source))
|
|
630
|
-
continue;
|
|
631
|
-
target.set(key, copyRecursive(target.get(key), value, predicate));
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
return target;
|
|
635
|
-
}
|
|
636
625
|
// If object defines __shouldCopy as false, then don't copy it
|
|
637
626
|
if (source.__shouldCopy === false)
|
|
638
627
|
return source;
|
|
@@ -652,6 +641,17 @@ function copyRecursive(target, source, predicate) {
|
|
|
652
641
|
else {
|
|
653
642
|
target = Object.assign({}, target || {});
|
|
654
643
|
}
|
|
644
|
+
// Copy map entries
|
|
645
|
+
if (target instanceof Map) {
|
|
646
|
+
if (source instanceof Map) {
|
|
647
|
+
for (let [key, value] of source.entries()) {
|
|
648
|
+
if (!predicate(value, key, target, source))
|
|
649
|
+
continue;
|
|
650
|
+
target.set(key, !shouldCopy(key, value) ? value : copyRecursive(target.get(key), value, predicate));
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return target;
|
|
654
|
+
}
|
|
655
655
|
// Copy object members
|
|
656
656
|
let keys = Object.keys(source);
|
|
657
657
|
target = keys.reduce((result, key) => {
|
|
@@ -818,11 +818,15 @@ function fixTextFileType(type, buffer) {
|
|
|
818
818
|
}
|
|
819
819
|
async function fileTypeFromBuffer(buffer) {
|
|
820
820
|
const stream = bufferToStream(buffer);
|
|
821
|
-
const type = (await
|
|
821
|
+
const type = (await fileType.fromStream(stream) ?? { ext: "txt", mime: "text/plain" });
|
|
822
822
|
if (checkTextFileType(type)) {
|
|
823
823
|
return fixTextFileType(type, buffer);
|
|
824
824
|
}
|
|
825
825
|
return type;
|
|
826
|
+
}
|
|
827
|
+
async function fileTypeFromStream(buffer) {
|
|
828
|
+
const stream = bufferToStream(buffer);
|
|
829
|
+
return (await fileType.fromStream(stream) ?? { ext: "txt", mime: "text/plain" });
|
|
826
830
|
}
|
|
827
831
|
|
|
828
832
|
let Configuration = class Configuration {
|
|
@@ -904,7 +908,7 @@ let MongoConnector = class MongoConnector {
|
|
|
904
908
|
async connect() {
|
|
905
909
|
if (this.db)
|
|
906
910
|
return this.db;
|
|
907
|
-
this.conn = (await connect(this.configuration.resolve("mongoUri"), {
|
|
911
|
+
this.conn = (await mongoose.connect(this.configuration.resolve("mongoUri"), {
|
|
908
912
|
dbName: this.configuration.resolve("mongoDb"),
|
|
909
913
|
user: this.configuration.resolve("mongoUser"),
|
|
910
914
|
pass: this.configuration.resolve("mongoPassword")
|
|
@@ -3435,7 +3439,7 @@ let CompressionMiddleware = class CompressionMiddleware {
|
|
|
3435
3439
|
};
|
|
3436
3440
|
CompressionMiddleware = __decorate([
|
|
3437
3441
|
injectable(),
|
|
3438
|
-
Middleware$1()
|
|
3442
|
+
Middleware$1({})
|
|
3439
3443
|
], CompressionMiddleware);
|
|
3440
3444
|
|
|
3441
3445
|
class Tree {
|
|
@@ -3712,8 +3716,8 @@ class BaseDoc {
|
|
|
3712
3716
|
return getModelForClass(type);
|
|
3713
3717
|
}
|
|
3714
3718
|
}
|
|
3715
|
-
const PrimitiveArray = Types.Array;
|
|
3716
|
-
const DocumentArray = Types.DocumentArray;
|
|
3719
|
+
const PrimitiveArray = mongoose.Types.Array;
|
|
3720
|
+
const DocumentArray = mongoose.Types.DocumentArray;
|
|
3717
3721
|
|
|
3718
3722
|
function IsDocumented(summary = null, paramDescriptions = {}) {
|
|
3719
3723
|
return OpenAPI(op => {
|
|
@@ -3930,9 +3934,9 @@ function hydratePopulated(modelType, json) {
|
|
|
3930
3934
|
continue;
|
|
3931
3935
|
const value = getValue$1(path, json);
|
|
3932
3936
|
const hydrateVal = val => {
|
|
3933
|
-
if (val == null || val instanceof Types.ObjectId)
|
|
3937
|
+
if (val == null || val instanceof mongoose.Types.ObjectId)
|
|
3934
3938
|
return val;
|
|
3935
|
-
return hydratePopulated(model(ref), val);
|
|
3939
|
+
return hydratePopulated(mongoose.model(ref), val);
|
|
3936
3940
|
};
|
|
3937
3941
|
if (Array.isArray(value)) {
|
|
3938
3942
|
setValue(path, value.map(hydrateVal), object);
|
|
@@ -4307,5 +4311,5 @@ async function setupBackend(config, providers, parent) {
|
|
|
4307
4311
|
* Generated bundle index. Do not edit.
|
|
4308
4312
|
*/
|
|
4309
4313
|
|
|
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 };
|
|
4314
|
+
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
4315
|
//# sourceMappingURL=stemy-backend.mjs.map
|