@stemy/backend 5.1.0 → 5.2.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/common-types.d.ts +37 -17
- package/esm2020/common-types.mjs +3 -1
- package/esm2020/public_api.mjs +10 -3
- package/esm2020/rest-middlewares/error-handler.middleware.mjs +4 -4
- package/esm2020/services/assets.mjs +19 -12
- package/esm2020/services/backend-provider.mjs +5 -5
- package/esm2020/services/drivers/asset-grid.driver.mjs +25 -0
- package/esm2020/services/entities/asset.mjs +23 -10
- package/esm2020/services/entities/base-entity.mjs +8 -8
- package/esm2020/services/entities/lazy-asset.mjs +11 -12
- package/esm2020/services/entities/progress.mjs +17 -17
- package/esm2020/services/entities/temp-asset.mjs +4 -4
- package/esm2020/services/mail-sender.mjs +4 -4
- package/esm2020/services/mongo-connector.mjs +5 -11
- package/esm2020/services/open-api.mjs +6 -6
- package/esm2020/utilities/base-doc.mjs +1 -1
- package/esm2020/utilities/di-container.mjs +7 -7
- package/esm2020/utilities/lazy-asset-generator.mjs +6 -6
- package/esm2020/utilities/tree.mjs +4 -4
- package/fesm2015/stemy-backend.mjs +134 -91
- package/fesm2015/stemy-backend.mjs.map +1 -1
- package/fesm2020/stemy-backend.mjs +133 -90
- package/fesm2020/stemy-backend.mjs.map +1 -1
- package/package.json +1 -1
- package/public_api.d.ts +1 -1
- package/services/assets.d.ts +4 -4
- package/services/drivers/asset-grid.driver.d.ts +11 -0
- package/services/entities/asset.d.ts +4 -4
- package/services/entities/base-entity.d.ts +2 -2
- package/services/mongo-connector.d.ts +1 -3
- package/utilities/base-doc.d.ts +3 -3
- package/utils.d.ts +1 -1
package/package.json
CHANGED
package/public_api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IBackendConfig, IDependencyContainer, IRequest, IUser, Provider } from "./common-types";
|
|
2
2
|
export { FilterPredicate, isNullOrUndefined, isDefined, getType, isObject, isArray, isBuffer, isBoolean, isDate, isPrimitive, isString, isFunction, isConstructor, isType, isInterface, ucFirst, lcFirst, isObjectId, firstItem, lastItem, regroup, uniqueItems, getValue, groupBy, convertValue, toImage, bufferToStream, streamToBuffer, copyStream, mkdirRecursive, deleteFile, readFile, readAndDeleteFile, writeFile, valueToPromise, promiseTimeout, getConstructorName, getFunctionParams, getFileName, getExtension, createIdString, idToString, createTransformer, broadcast, rand, random, multiSubscription, observableFromFunction, padLeft, padRight, camelCaseToDash, gzipPromised, gunzipPromised, deleteFromBucket, filter, copy, assign, md5, runCommand, ConsoleColor, IJsonColors, colorize, jsonHighlight, replaceSpecialChars, regexEscape, flatten, wrapError, getDirName, prepareUrl, prepareUrlSlash, prepareUrlEmpty, fileTypeFromBuffer, fileTypeFromStream } from "./utils";
|
|
3
3
|
export { IsFile, IsObjectId } from "./validators";
|
|
4
|
-
export { FIXTURE, JOB, TERMINAL_COMMAND, EXPRESS, HTTP_SERVER, SOCKET_SERVER, SOCKET_CONTROLLERS, PARAMETER, DI_CONTAINER, OPENAPI_VALIDATION, Type, FactoryProvider, IDependencyContainer, ClassBasedProvider, ValueBasedProvider, FactoryBasedProvider, TokenBasedProvider, SyringeProvider, Provider, Constructor, InferGeneric, PickMatching, OmitFirstArg, IMatchField, IProjectOptions, IUnwindOptions, IFixture, IFixtureOutput, SchemaConverter, OpenApiValidation, ParamResolver, Parameter, SocketParam, SocketParams, ISocketMessage, IMessageBridge, IJob, IJobTask, JobParams, JobScheduleRange, JobScheduleTime, ITerminalFile, ITerminal, ITerminalCommand, IProgress, IAssetCropInfo, IAssetMeta, IAssetImageParams, IAsset, ILazyAsset, IUser, IClientSocket, IRequestBase, IRequest, IGalleryImage, IGallerySize, IGalleryImageHandler, ITranslations, IPaginationMeta, IPaginationBase, IPagination, IPaginationParams, FontFormat, IFileType, RoutingOptions, SocketOptions, IBackendConfig } from "./common-types";
|
|
4
|
+
export { FIXTURE, JOB, TERMINAL_COMMAND, EXPRESS, HTTP_SERVER, SOCKET_SERVER, SOCKET_CONTROLLERS, PARAMETER, DI_CONTAINER, OPENAPI_VALIDATION, Type, FactoryProvider, IDependencyContainer, ClassBasedProvider, ValueBasedProvider, FactoryBasedProvider, TokenBasedProvider, SyringeProvider, Provider, Constructor, InferGeneric, PickMatching, OmitFirstArg, IMatchField, IProjectOptions, IUnwindOptions, IFixture, IFixtureOutput, SchemaConverter, OpenApiValidation, ParamResolver, Parameter, SocketParam, SocketParams, ISocketMessage, IMessageBridge, IJob, IJobTask, JobParams, JobScheduleRange, JobScheduleTime, ITerminalFile, ITerminal, ITerminalCommand, IProgress, IAssetCropInfo, IAssetMeta, IAssetImageParams, IAsset, IAssetUploadStream, IAssetUploadOpts, IAssetDriver, ILazyAsset, IUser, IClientSocket, IRequestBase, IRequest, IGalleryImage, IGallerySize, IGalleryImageHandler, ITranslations, IPaginationMeta, IPaginationBase, IPagination, IPaginationParams, FontFormat, IFileType, RoutingOptions, SocketOptions, IBackendConfig } from "./common-types";
|
|
5
5
|
export { AssetProcessor } from "./services/asset-processor";
|
|
6
6
|
export { AssetResolver } from "./services/asset-resolver";
|
|
7
7
|
export { Assets } from "./services/assets";
|
package/services/assets.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { Readable } from "stream";
|
|
4
|
-
import { Collection
|
|
4
|
+
import { Collection } from "mongodb";
|
|
5
5
|
import { FilterQuery } from "mongoose";
|
|
6
|
-
import { IAsset, IAssetMeta, IFileType } from "../common-types";
|
|
6
|
+
import { IAsset, IAssetDriver, IAssetMeta, IFileType } from "../common-types";
|
|
7
7
|
import { MongoConnector } from "./mongo-connector";
|
|
8
8
|
import { AssetProcessor } from "./asset-processor";
|
|
9
9
|
export declare class Assets {
|
|
10
10
|
readonly connector: MongoConnector;
|
|
11
11
|
readonly assetProcessor: AssetProcessor;
|
|
12
|
-
readonly
|
|
12
|
+
readonly driver: IAssetDriver;
|
|
13
13
|
readonly collection: Collection<Partial<IAsset>>;
|
|
14
|
-
constructor(connector: MongoConnector, assetProcessor: AssetProcessor);
|
|
14
|
+
constructor(connector: MongoConnector, assetProcessor: AssetProcessor, driver: IAssetDriver);
|
|
15
15
|
write(stream: Readable, contentType?: string, metadata?: IAssetMeta): Promise<IAsset>;
|
|
16
16
|
writeBuffer(buffer: Buffer, metadata?: IAssetMeta, contentType?: string): Promise<IAsset>;
|
|
17
17
|
writeUrl(url: string, metadata?: IAssetMeta): Promise<IAsset>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GridFSBucket, ObjectId } from 'mongodb';
|
|
2
|
+
import { IAssetDriver, IAssetUploadOpts } from '../../common-types';
|
|
3
|
+
import { MongoConnector } from "../mongo-connector";
|
|
4
|
+
export declare class AssetGridDriver implements IAssetDriver {
|
|
5
|
+
readonly metaCollection: string;
|
|
6
|
+
protected bucket: GridFSBucket;
|
|
7
|
+
constructor(connector: MongoConnector);
|
|
8
|
+
openUploadStream(filename: string, opts?: IAssetUploadOpts): import("mongodb").GridFSBucketWriteStream;
|
|
9
|
+
openDownloadStream(id: ObjectId): import("mongodb").GridFSBucketReadStream;
|
|
10
|
+
delete(id: ObjectId): Promise<void>;
|
|
11
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { Readable } from "stream";
|
|
4
|
-
import { Collection
|
|
4
|
+
import { Collection } from "mongodb";
|
|
5
5
|
import { ObjectId } from "bson";
|
|
6
|
-
import { IAsset, IAssetImageParams, IAssetMeta } from "../../common-types";
|
|
6
|
+
import { IAsset, IAssetDriver, IAssetImageParams, IAssetMeta } from "../../common-types";
|
|
7
7
|
import { BaseEntity } from "./base-entity";
|
|
8
8
|
export declare class Asset extends BaseEntity<IAsset> implements IAsset {
|
|
9
|
-
protected
|
|
9
|
+
protected driver: IAssetDriver;
|
|
10
10
|
get filename(): string;
|
|
11
11
|
get contentType(): string;
|
|
12
12
|
get metadata(): IAssetMeta;
|
|
13
13
|
get stream(): Readable;
|
|
14
|
-
constructor(id: ObjectId, data: Partial<IAsset>, collection: Collection,
|
|
14
|
+
constructor(id: ObjectId, data: Partial<IAsset>, collection: Collection, driver: IAssetDriver);
|
|
15
15
|
unlink(): Promise<string>;
|
|
16
16
|
setMeta(metadata: Partial<IAssetMeta>): Promise<any>;
|
|
17
17
|
getBuffer(): Promise<Buffer>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Collection } from "mongodb";
|
|
2
2
|
import { ObjectId } from "bson";
|
|
3
3
|
export declare class BaseEntity<T> {
|
|
4
|
-
readonly
|
|
4
|
+
readonly oid: ObjectId;
|
|
5
5
|
protected data: Partial<T>;
|
|
6
6
|
protected collection: Collection<any>;
|
|
7
7
|
get id(): string;
|
|
8
8
|
protected deleted: boolean;
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(oid: ObjectId, data: Partial<T>, collection: Collection<any>);
|
|
10
10
|
save(): Promise<any>;
|
|
11
11
|
load(): Promise<this>;
|
|
12
12
|
toJSON(): any;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { Db
|
|
1
|
+
import { Db } from "mongodb";
|
|
2
2
|
import mongoose from "mongoose";
|
|
3
3
|
import { Configuration } from "./configuration";
|
|
4
4
|
export declare class MongoConnector {
|
|
5
5
|
readonly configuration: Configuration;
|
|
6
6
|
get connection(): mongoose.Connection;
|
|
7
7
|
get database(): Db;
|
|
8
|
-
get bucket(): GridFSBucket;
|
|
9
8
|
protected conn: mongoose.Connection;
|
|
10
9
|
protected db: Db;
|
|
11
|
-
protected fsBucket: GridFSBucket;
|
|
12
10
|
constructor(configuration: Configuration);
|
|
13
11
|
connect(): Promise<Db>;
|
|
14
12
|
}
|
package/utilities/base-doc.d.ts
CHANGED
|
@@ -27,14 +27,14 @@ export declare abstract class BaseDoc<IDType extends RefType = mongoose.Types.Ob
|
|
|
27
27
|
/**
|
|
28
28
|
* Casts this to DocumentType<this> to allow using document methods in get/set-s
|
|
29
29
|
*/
|
|
30
|
-
cast(): DocumentType<
|
|
30
|
+
cast<ImplType = this>(): DocumentType<ImplType>;
|
|
31
31
|
/**
|
|
32
32
|
* Gets a pre-compiled model from typegoose cache by its class type
|
|
33
33
|
* @param type
|
|
34
34
|
*/
|
|
35
35
|
model<T extends Constructor<any>>(type: T): ReturnModelType<T>;
|
|
36
36
|
}
|
|
37
|
-
export
|
|
37
|
+
export type PrimitiveArray<T> = mongoose.Types.Array<T>;
|
|
38
38
|
export declare const PrimitiveArray: typeof mongoose.Types.Array;
|
|
39
|
-
export
|
|
39
|
+
export type DocumentArray<T extends BaseDoc> = mongoose.Types.DocumentArray<DocumentType<T>>;
|
|
40
40
|
export declare const DocumentArray: typeof mongoose.Types.DocumentArray;
|
package/utils.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface IDIContainers {
|
|
|
13
13
|
appContainer: DependencyContainer;
|
|
14
14
|
}
|
|
15
15
|
export declare const diContainers: IDIContainers;
|
|
16
|
-
export
|
|
16
|
+
export type FilterPredicate = (value: any, key?: any, target?: any, source?: any) => boolean;
|
|
17
17
|
export declare function isNullOrUndefined(value: any): boolean;
|
|
18
18
|
export declare function isDefined(value: any): boolean;
|
|
19
19
|
export declare function getType(obj: any): string;
|