@lark-apaas/fullstack-nestjs-core 1.1.17-alpha.4 → 1.1.17-alpha.6
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/index.cjs +49 -6
- package/dist/index.d.cts +20 -8
- package/dist/index.d.ts +20 -8
- package/dist/index.js +50 -7
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -797,11 +797,11 @@ var FileService = class {
|
|
|
797
797
|
}
|
|
798
798
|
requestContextService;
|
|
799
799
|
httpClient;
|
|
800
|
-
|
|
800
|
+
fileServiceCore;
|
|
801
801
|
constructor(requestContextService, httpClient) {
|
|
802
802
|
this.requestContextService = requestContextService;
|
|
803
803
|
this.httpClient = httpClient;
|
|
804
|
-
this.
|
|
804
|
+
this.fileServiceCore = new import_file_service.FileService(this.httpClient);
|
|
805
805
|
}
|
|
806
806
|
from(bucket) {
|
|
807
807
|
this.requestContextService.setContext({
|
|
@@ -809,18 +809,61 @@ var FileService = class {
|
|
|
809
809
|
});
|
|
810
810
|
return this;
|
|
811
811
|
}
|
|
812
|
+
async upload(file, options) {
|
|
813
|
+
return this.fileServiceCore.upload({
|
|
814
|
+
appId: this.getAppId(),
|
|
815
|
+
bucketId: await this.getDefaultBucket(),
|
|
816
|
+
fileBody: file,
|
|
817
|
+
options
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
download(path) {
|
|
821
|
+
const downloadFn = /* @__PURE__ */ __name(async () => this.fileServiceCore.downloadInner({
|
|
822
|
+
appId: this.getAppId(),
|
|
823
|
+
bucketId: await this.getDefaultBucket(),
|
|
824
|
+
filePath: path
|
|
825
|
+
}), "downloadFn");
|
|
826
|
+
return new import_file_service.FileDownloadBuilder(downloadFn);
|
|
827
|
+
}
|
|
828
|
+
async list(prefix, searchOptions) {
|
|
829
|
+
return this.fileServiceCore.list({
|
|
830
|
+
appId: this.getAppId(),
|
|
831
|
+
bucketId: await this.getDefaultBucket(),
|
|
832
|
+
prefix,
|
|
833
|
+
searchOptions
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
async remove(filePaths) {
|
|
837
|
+
return this.fileServiceCore.remove({
|
|
838
|
+
appId: this.getAppId(),
|
|
839
|
+
bucketId: await this.getDefaultBucket(),
|
|
840
|
+
filePaths
|
|
841
|
+
});
|
|
842
|
+
}
|
|
812
843
|
async createSignedUrl(path, expiresIn) {
|
|
813
|
-
|
|
814
|
-
return this.fileService.createSignedUrl({
|
|
844
|
+
return this.fileServiceCore.createSignedUrl({
|
|
815
845
|
appId: this.getAppId(),
|
|
816
|
-
bucketId,
|
|
846
|
+
bucketId: await this.getDefaultBucket(),
|
|
817
847
|
filePath: path,
|
|
818
848
|
expiresIn
|
|
819
849
|
});
|
|
820
850
|
}
|
|
851
|
+
async getFileMetadata(filePath) {
|
|
852
|
+
return this.fileServiceCore.getFileMetadata({
|
|
853
|
+
appId: this.getAppId(),
|
|
854
|
+
bucketId: await this.getDefaultBucket(),
|
|
855
|
+
filePath
|
|
856
|
+
});
|
|
857
|
+
}
|
|
821
858
|
async getDefaultBucket() {
|
|
859
|
+
const reqContext = this.requestContextService.getContext();
|
|
860
|
+
const bucketFromContext = reqContext?.bucket;
|
|
861
|
+
if (bucketFromContext) {
|
|
862
|
+
return bucketFromContext;
|
|
863
|
+
}
|
|
822
864
|
const appId = this.getAppId();
|
|
823
|
-
|
|
865
|
+
const bucket = await this.fileServiceCore.getDefaultBucket(appId);
|
|
866
|
+
return bucket;
|
|
824
867
|
}
|
|
825
868
|
getAppId() {
|
|
826
869
|
const requestCtx = this.requestContextService.getContext();
|
package/dist/index.d.cts
CHANGED
|
@@ -2,15 +2,17 @@ import { NestModule, DynamicModule, MiddlewareConsumer, NestMiddleware } from '@
|
|
|
2
2
|
import { HttpClientConfig, PlatformPluginOptions } from '@lark-apaas/http-client';
|
|
3
3
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
|
4
4
|
export { DevToolsModule, DevToolsOptions, DevToolsV2Module, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
|
|
5
|
-
import { Request, Response
|
|
5
|
+
import { Request, Response, NextFunction } from 'express';
|
|
6
6
|
import { PlatformHttpClient, RequestContextService } from '@lark-apaas/nestjs-common';
|
|
7
7
|
export { AutoTrace } from '@lark-apaas/nestjs-common';
|
|
8
|
+
import * as _lark_apaas_file_service from '@lark-apaas/file-service';
|
|
9
|
+
import { FileBody, UploadOptions, FileDownloadBuilder, SearchOptions } from '@lark-apaas/file-service';
|
|
10
|
+
export * from '@lark-apaas/file-service';
|
|
8
11
|
export * from '@lark-apaas/nestjs-authnpaas';
|
|
9
12
|
export * from '@lark-apaas/nestjs-capability';
|
|
10
13
|
export * from '@lark-apaas/nestjs-datapaas';
|
|
11
14
|
export * from '@lark-apaas/nestjs-observable';
|
|
12
15
|
export * from '@lark-apaas/nestjs-trigger';
|
|
13
|
-
export * from '@lark-apaas/file-service';
|
|
14
16
|
|
|
15
17
|
declare global {
|
|
16
18
|
namespace Express {
|
|
@@ -99,7 +101,7 @@ interface CsrfTokenOptions {
|
|
|
99
101
|
declare class CsrfTokenMiddleware implements NestMiddleware {
|
|
100
102
|
private static options;
|
|
101
103
|
static configure(opts: CsrfTokenOptions): void;
|
|
102
|
-
use(req: Request, res: Response
|
|
104
|
+
use(req: Request, res: Response, next: NextFunction): void;
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
interface CsrfOptions {
|
|
@@ -110,11 +112,11 @@ interface CsrfOptions {
|
|
|
110
112
|
declare class CsrfMiddleware implements NestMiddleware {
|
|
111
113
|
private static options;
|
|
112
114
|
static configure(opts: CsrfOptions): void;
|
|
113
|
-
use(req: Request, res: Response
|
|
115
|
+
use(req: Request, res: Response, next: NextFunction): void;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
declare class UserContextMiddleware implements NestMiddleware {
|
|
117
|
-
use(req: Request, _res: Response
|
|
119
|
+
use(req: Request, _res: Response, next: NextFunction): void;
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
declare class ViewContextMiddleware implements NestMiddleware {
|
|
@@ -122,7 +124,7 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
122
124
|
private readonly logger;
|
|
123
125
|
constructor(client: PlatformHttpClient);
|
|
124
126
|
private getAppInfo;
|
|
125
|
-
use(req: Request, res: Response
|
|
127
|
+
use(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
/**
|
|
@@ -139,10 +141,20 @@ interface ApiNotFoundResponse {
|
|
|
139
141
|
declare class FileService {
|
|
140
142
|
private readonly requestContextService;
|
|
141
143
|
private readonly httpClient;
|
|
142
|
-
private readonly
|
|
144
|
+
private readonly fileServiceCore;
|
|
143
145
|
constructor(requestContextService: RequestContextService, httpClient: PlatformHttpClient);
|
|
144
146
|
from(bucket: string): this;
|
|
145
|
-
|
|
147
|
+
upload(file: FileBody, options?: UploadOptions): Promise<{
|
|
148
|
+
bucketID: string;
|
|
149
|
+
filePath: string;
|
|
150
|
+
downloadURL: string;
|
|
151
|
+
fileName: string;
|
|
152
|
+
} | undefined>;
|
|
153
|
+
download(path: string): FileDownloadBuilder;
|
|
154
|
+
list(prefix: string, searchOptions?: SearchOptions): Promise<_lark_apaas_file_service.ListResponse>;
|
|
155
|
+
remove(filePaths: string[]): Promise<_lark_apaas_file_service.FileMeta[]>;
|
|
156
|
+
createSignedUrl(path: string, expiresIn: number): Promise<string>;
|
|
157
|
+
getFileMetadata(filePath: string): Promise<_lark_apaas_file_service.FileMeta | null>;
|
|
146
158
|
getDefaultBucket(): Promise<string>;
|
|
147
159
|
private getAppId;
|
|
148
160
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,15 +2,17 @@ import { NestModule, DynamicModule, MiddlewareConsumer, NestMiddleware } from '@
|
|
|
2
2
|
import { HttpClientConfig, PlatformPluginOptions } from '@lark-apaas/http-client';
|
|
3
3
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
|
4
4
|
export { DevToolsModule, DevToolsOptions, DevToolsV2Module, DevToolsV2Options } from '@lark-apaas/nestjs-openapi-devtools';
|
|
5
|
-
import { Request, Response
|
|
5
|
+
import { Request, Response, NextFunction } from 'express';
|
|
6
6
|
import { PlatformHttpClient, RequestContextService } from '@lark-apaas/nestjs-common';
|
|
7
7
|
export { AutoTrace } from '@lark-apaas/nestjs-common';
|
|
8
|
+
import * as _lark_apaas_file_service from '@lark-apaas/file-service';
|
|
9
|
+
import { FileBody, UploadOptions, FileDownloadBuilder, SearchOptions } from '@lark-apaas/file-service';
|
|
10
|
+
export * from '@lark-apaas/file-service';
|
|
8
11
|
export * from '@lark-apaas/nestjs-authnpaas';
|
|
9
12
|
export * from '@lark-apaas/nestjs-capability';
|
|
10
13
|
export * from '@lark-apaas/nestjs-datapaas';
|
|
11
14
|
export * from '@lark-apaas/nestjs-observable';
|
|
12
15
|
export * from '@lark-apaas/nestjs-trigger';
|
|
13
|
-
export * from '@lark-apaas/file-service';
|
|
14
16
|
|
|
15
17
|
declare global {
|
|
16
18
|
namespace Express {
|
|
@@ -99,7 +101,7 @@ interface CsrfTokenOptions {
|
|
|
99
101
|
declare class CsrfTokenMiddleware implements NestMiddleware {
|
|
100
102
|
private static options;
|
|
101
103
|
static configure(opts: CsrfTokenOptions): void;
|
|
102
|
-
use(req: Request, res: Response
|
|
104
|
+
use(req: Request, res: Response, next: NextFunction): void;
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
interface CsrfOptions {
|
|
@@ -110,11 +112,11 @@ interface CsrfOptions {
|
|
|
110
112
|
declare class CsrfMiddleware implements NestMiddleware {
|
|
111
113
|
private static options;
|
|
112
114
|
static configure(opts: CsrfOptions): void;
|
|
113
|
-
use(req: Request, res: Response
|
|
115
|
+
use(req: Request, res: Response, next: NextFunction): void;
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
declare class UserContextMiddleware implements NestMiddleware {
|
|
117
|
-
use(req: Request, _res: Response
|
|
119
|
+
use(req: Request, _res: Response, next: NextFunction): void;
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
declare class ViewContextMiddleware implements NestMiddleware {
|
|
@@ -122,7 +124,7 @@ declare class ViewContextMiddleware implements NestMiddleware {
|
|
|
122
124
|
private readonly logger;
|
|
123
125
|
constructor(client: PlatformHttpClient);
|
|
124
126
|
private getAppInfo;
|
|
125
|
-
use(req: Request, res: Response
|
|
127
|
+
use(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
/**
|
|
@@ -139,10 +141,20 @@ interface ApiNotFoundResponse {
|
|
|
139
141
|
declare class FileService {
|
|
140
142
|
private readonly requestContextService;
|
|
141
143
|
private readonly httpClient;
|
|
142
|
-
private readonly
|
|
144
|
+
private readonly fileServiceCore;
|
|
143
145
|
constructor(requestContextService: RequestContextService, httpClient: PlatformHttpClient);
|
|
144
146
|
from(bucket: string): this;
|
|
145
|
-
|
|
147
|
+
upload(file: FileBody, options?: UploadOptions): Promise<{
|
|
148
|
+
bucketID: string;
|
|
149
|
+
filePath: string;
|
|
150
|
+
downloadURL: string;
|
|
151
|
+
fileName: string;
|
|
152
|
+
} | undefined>;
|
|
153
|
+
download(path: string): FileDownloadBuilder;
|
|
154
|
+
list(prefix: string, searchOptions?: SearchOptions): Promise<_lark_apaas_file_service.ListResponse>;
|
|
155
|
+
remove(filePaths: string[]): Promise<_lark_apaas_file_service.FileMeta[]>;
|
|
156
|
+
createSignedUrl(path: string, expiresIn: number): Promise<string>;
|
|
157
|
+
getFileMetadata(filePath: string): Promise<_lark_apaas_file_service.FileMeta | null>;
|
|
146
158
|
getDefaultBucket(): Promise<string>;
|
|
147
159
|
private getAppId;
|
|
148
160
|
}
|
package/dist/index.js
CHANGED
|
@@ -729,7 +729,7 @@ var DISABLE_DATAPASS = process.env.FORCE_FRAMEWORK_DISABLE_DATAPASS === "true";
|
|
|
729
729
|
// src/services/file.service.ts
|
|
730
730
|
import { Injectable as Injectable9, Inject as Inject2 } from "@nestjs/common";
|
|
731
731
|
import { RequestContextService as RequestContextService2, PLATFORM_HTTP_CLIENT as PLATFORM_HTTP_CLIENT2 } from "@lark-apaas/nestjs-common";
|
|
732
|
-
import { FileService as FileServiceCore } from "@lark-apaas/file-service";
|
|
732
|
+
import { FileService as FileServiceCore, FileDownloadBuilder } from "@lark-apaas/file-service";
|
|
733
733
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
734
734
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
735
735
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -753,11 +753,11 @@ var FileService = class {
|
|
|
753
753
|
}
|
|
754
754
|
requestContextService;
|
|
755
755
|
httpClient;
|
|
756
|
-
|
|
756
|
+
fileServiceCore;
|
|
757
757
|
constructor(requestContextService, httpClient) {
|
|
758
758
|
this.requestContextService = requestContextService;
|
|
759
759
|
this.httpClient = httpClient;
|
|
760
|
-
this.
|
|
760
|
+
this.fileServiceCore = new FileServiceCore(this.httpClient);
|
|
761
761
|
}
|
|
762
762
|
from(bucket) {
|
|
763
763
|
this.requestContextService.setContext({
|
|
@@ -765,18 +765,61 @@ var FileService = class {
|
|
|
765
765
|
});
|
|
766
766
|
return this;
|
|
767
767
|
}
|
|
768
|
+
async upload(file, options) {
|
|
769
|
+
return this.fileServiceCore.upload({
|
|
770
|
+
appId: this.getAppId(),
|
|
771
|
+
bucketId: await this.getDefaultBucket(),
|
|
772
|
+
fileBody: file,
|
|
773
|
+
options
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
download(path) {
|
|
777
|
+
const downloadFn = /* @__PURE__ */ __name(async () => this.fileServiceCore.downloadInner({
|
|
778
|
+
appId: this.getAppId(),
|
|
779
|
+
bucketId: await this.getDefaultBucket(),
|
|
780
|
+
filePath: path
|
|
781
|
+
}), "downloadFn");
|
|
782
|
+
return new FileDownloadBuilder(downloadFn);
|
|
783
|
+
}
|
|
784
|
+
async list(prefix, searchOptions) {
|
|
785
|
+
return this.fileServiceCore.list({
|
|
786
|
+
appId: this.getAppId(),
|
|
787
|
+
bucketId: await this.getDefaultBucket(),
|
|
788
|
+
prefix,
|
|
789
|
+
searchOptions
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
async remove(filePaths) {
|
|
793
|
+
return this.fileServiceCore.remove({
|
|
794
|
+
appId: this.getAppId(),
|
|
795
|
+
bucketId: await this.getDefaultBucket(),
|
|
796
|
+
filePaths
|
|
797
|
+
});
|
|
798
|
+
}
|
|
768
799
|
async createSignedUrl(path, expiresIn) {
|
|
769
|
-
|
|
770
|
-
return this.fileService.createSignedUrl({
|
|
800
|
+
return this.fileServiceCore.createSignedUrl({
|
|
771
801
|
appId: this.getAppId(),
|
|
772
|
-
bucketId,
|
|
802
|
+
bucketId: await this.getDefaultBucket(),
|
|
773
803
|
filePath: path,
|
|
774
804
|
expiresIn
|
|
775
805
|
});
|
|
776
806
|
}
|
|
807
|
+
async getFileMetadata(filePath) {
|
|
808
|
+
return this.fileServiceCore.getFileMetadata({
|
|
809
|
+
appId: this.getAppId(),
|
|
810
|
+
bucketId: await this.getDefaultBucket(),
|
|
811
|
+
filePath
|
|
812
|
+
});
|
|
813
|
+
}
|
|
777
814
|
async getDefaultBucket() {
|
|
815
|
+
const reqContext = this.requestContextService.getContext();
|
|
816
|
+
const bucketFromContext = reqContext?.bucket;
|
|
817
|
+
if (bucketFromContext) {
|
|
818
|
+
return bucketFromContext;
|
|
819
|
+
}
|
|
778
820
|
const appId = this.getAppId();
|
|
779
|
-
|
|
821
|
+
const bucket = await this.fileServiceCore.getDefaultBucket(appId);
|
|
822
|
+
return bucket;
|
|
780
823
|
}
|
|
781
824
|
getAppId() {
|
|
782
825
|
const requestCtx = this.requestContextService.getContext();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-nestjs-core",
|
|
3
|
-
"version": "1.1.17-alpha.
|
|
3
|
+
"version": "1.1.17-alpha.6",
|
|
4
4
|
"description": "FullStack Nestjs Core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"prepublishOnly": "npm run build"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@lark-apaas/file-service": "0.0.1-alpha.
|
|
42
|
+
"@lark-apaas/file-service": "0.0.1-alpha.8",
|
|
43
43
|
"@lark-apaas/http-client": "^0.1.2",
|
|
44
44
|
"@lark-apaas/nestjs-authnpaas": "^1.0.2",
|
|
45
45
|
"@lark-apaas/nestjs-capability": "^0.1.2",
|