@volontariapp/storage-client 0.0.0-stage → 0.2.0-snap-5aae3b8
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/CHANGELOG.md +26 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +3 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors/index.d.ts +11 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +27 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/index.d.ts +31 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +2 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/services/storage-client.service.d.ts +18 -0
- package/dist/services/storage-client.service.d.ts.map +1 -0
- package/dist/services/storage-client.service.js +96 -0
- package/dist/services/storage-client.service.js.map +1 -0
- package/dist/storage-client.module.d.ts +8 -0
- package/dist/storage-client.module.d.ts.map +1 -0
- package/dist/storage-client.module.js +80 -0
- package/dist/storage-client.module.js.map +1 -0
- package/dist/test/storage-client.service.unit.spec.d.ts +2 -0
- package/dist/test/storage-client.service.unit.spec.d.ts.map +1 -0
- package/dist/test/storage-client.service.unit.spec.js +166 -0
- package/dist/test/storage-client.service.unit.spec.js.map +1 -0
- package/package.json +61 -3
- package/README.md +0 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Storage Wave 2 implementation:
|
|
8
|
+
- shared: add StorageStream enum (outbox success/failure, file scanned/rejected, attachment rejected) and event/user replacement streams
|
|
9
|
+
- domain-post: add post_media entity & model, PostMediaStatus, PostMediaScanStatus, reader visibility filtering, and updateMediaScanStatus
|
|
10
|
+
- domain-event: add cover_file_id & cover_status (CoverStatus enum), idempotent creation, and updateCover with event.cover_replaced outbox emission
|
|
11
|
+
- domain-user: add avatar_file_id, updateAvatar with user.avatar_replaced outbox emission, and deprecate logoPath
|
|
12
|
+
- errors-nest: add storage domain errors (FILE_NOT_FOUND, STORAGE_ATTACHMENT_FAILED, STORAGE_TIMEOUT, INVALID_FILE_ATTACHMENT)
|
|
13
|
+
- storage-client: new package providing NestJS StorageClientService, StorageClientModule, WithMetadata typing, and ConfirmFileAttachment helper
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies []:
|
|
18
|
+
- @volontariapp/errors-nest@0.14.0
|
|
19
|
+
|
|
20
|
+
All notable changes to this project will be documented in this file.
|
|
21
|
+
|
|
22
|
+
## 0.1.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- Initial package release for NestJS storage gRPC client with ConfirmFileAttachment helper.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,eAAmC,CAAC;AACvE,eAAO,MAAM,0BAA0B,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class StorageClientError extends Error {
|
|
2
|
+
readonly code?: string | number | undefined;
|
|
3
|
+
readonly details?: unknown | undefined;
|
|
4
|
+
constructor(message: string, code?: string | number | undefined, details?: unknown | undefined);
|
|
5
|
+
}
|
|
6
|
+
export declare class StorageClientTimeoutError extends StorageClientError {
|
|
7
|
+
constructor(message?: string);
|
|
8
|
+
}
|
|
9
|
+
import type { GrpcStatusError } from '../interfaces/index.js';
|
|
10
|
+
export declare function isGrpcError(error: unknown): error is GrpcStatusError;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;aAGzB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;aACtB,OAAO,CAAC,EAAE,OAAO;gBAFjC,OAAO,EAAE,MAAM,EACC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,YAAA,EACtB,OAAO,CAAC,EAAE,OAAO,YAAA;CAMpC;AAED,qBAAa,yBAA0B,SAAQ,kBAAkB;gBACnD,OAAO,SAAgC;CAKpD;AAED,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CASpE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class StorageClientError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
details;
|
|
4
|
+
constructor(message, code, details) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.details = details;
|
|
8
|
+
this.name = 'StorageClientError';
|
|
9
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class StorageClientTimeoutError extends StorageClientError {
|
|
13
|
+
constructor(message = 'Storage gRPC call timed out') {
|
|
14
|
+
super(message, 'DEADLINE_EXCEEDED');
|
|
15
|
+
this.name = 'StorageClientTimeoutError';
|
|
16
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function isGrpcError(error) {
|
|
20
|
+
return (typeof error === 'object' &&
|
|
21
|
+
error !== null &&
|
|
22
|
+
'code' in error &&
|
|
23
|
+
typeof error.code === 'number' &&
|
|
24
|
+
'details' in error &&
|
|
25
|
+
typeof error.details === 'string');
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAGzB;IACA;IAHlB,YACE,OAAe,EACC,IAAsB,EACtB,OAAiB;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAkB;QACtB,YAAO,GAAP,OAAO,CAAU;QAGjC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,kBAAkB;IAC/D,YAAY,OAAO,GAAG,6BAA6B;QACjD,KAAK,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAID,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,MAAM,IAAI,KAAK;QACf,OAAQ,KAA2B,CAAC,IAAI,KAAK,QAAQ;QACrD,SAAS,IAAI,KAAK;QAClB,OAAQ,KAA8B,CAAC,OAAO,KAAK,QAAQ,CAC5D,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './constants.js';
|
|
2
|
+
export * from './interfaces/index.js';
|
|
3
|
+
export * from './errors/index.js';
|
|
4
|
+
export * from './services/storage-client.service.js';
|
|
5
|
+
export * from './storage-client.module.js';
|
|
6
|
+
export { STORAGE_SERVICE_NAME, EntityType, FileStatus, ScanStatus, type ConfirmFileAttachmentCommand, type ConfirmFileAttachmentResponse, type FileMetadata, type StorageServiceClient, } from '@volontariapp/contracts-nest';
|
|
7
|
+
export { FILE_NOT_FOUND, STORAGE_ATTACHMENT_FAILED, STORAGE_TIMEOUT, INVALID_FILE_ATTACHMENT, } from '@volontariapp/errors-nest';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAG3C,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,UAAU,EACV,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,YAAY,EACjB,KAAK,oBAAoB,GAC1B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,eAAe,EACf,uBAAuB,GACxB,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './constants.js';
|
|
2
|
+
export * from './interfaces/index.js';
|
|
3
|
+
export * from './errors/index.js';
|
|
4
|
+
export * from './services/storage-client.service.js';
|
|
5
|
+
export * from './storage-client.module.js';
|
|
6
|
+
export { STORAGE_SERVICE_NAME, EntityType, FileStatus, ScanStatus, } from '@volontariapp/contracts-nest';
|
|
7
|
+
export { FILE_NOT_FOUND, STORAGE_ATTACHMENT_FAILED, STORAGE_TIMEOUT, INVALID_FILE_ATTACHMENT, } from '@volontariapp/errors-nest';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAG3C,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,UAAU,GAKX,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,eAAe,EACf,uBAAuB,GACxB,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { InjectionToken, ModuleMetadata, OptionalFactoryDependency, Type } from '@nestjs/common';
|
|
2
|
+
import type { Metadata } from '@grpc/grpc-js';
|
|
3
|
+
import type { Observable } from 'rxjs';
|
|
4
|
+
export type WithMetadata<T> = {
|
|
5
|
+
[K in keyof T]: T[K] extends (request: infer R) => Observable<infer Res> ? (request: R, metadata?: Metadata) => Observable<Res> : T[K];
|
|
6
|
+
};
|
|
7
|
+
export interface GrpcStatusError {
|
|
8
|
+
code: number;
|
|
9
|
+
details: string;
|
|
10
|
+
message: string;
|
|
11
|
+
metadata?: Metadata;
|
|
12
|
+
}
|
|
13
|
+
export interface StorageClientOptions {
|
|
14
|
+
url?: string;
|
|
15
|
+
internalToken?: string;
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface StorageClientOptionsFactory {
|
|
19
|
+
createStorageClientOptions(): Promise<StorageClientOptions> | StorageClientOptions;
|
|
20
|
+
}
|
|
21
|
+
export interface StorageClientAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
22
|
+
useExisting?: Type<StorageClientOptionsFactory>;
|
|
23
|
+
useClass?: Type<StorageClientOptionsFactory>;
|
|
24
|
+
useFactory?: (...args: unknown[]) => Promise<StorageClientOptions> | StorageClientOptions;
|
|
25
|
+
inject?: Array<InjectionToken | OptionalFactoryDependency>;
|
|
26
|
+
}
|
|
27
|
+
export interface ConfirmAttachmentOptions {
|
|
28
|
+
internalToken?: string;
|
|
29
|
+
timeoutMs?: number;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,IAAI,EACL,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;KAC3B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,UAAU,CAAC,MAAM,GAAG,CAAC,GACpE,CAAC,OAAO,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,QAAQ,KAAK,UAAU,CAAC,GAAG,CAAC,GACpD,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IAEnC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,2BAA2B;IAC1C,0BAA0B,IAAI,OAAO,CAAC,oBAAoB,CAAC,GAAG,oBAAoB,CAAC;CACpF;AAED,MAAM,WAAW,yBAA0B,SAAQ,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC;IAChF,WAAW,CAAC,EAAE,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAC7C,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,oBAAoB,CAAC,GAAG,oBAAoB,CAAC;IAC1F,MAAM,CAAC,EAAE,KAAK,CAAC,cAAc,GAAG,yBAAyB,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,wBAAwB;IAEvC,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import type { ClientGrpc } from '@nestjs/microservices';
|
|
3
|
+
import { type ConfirmFileAttachmentCommand, type ConfirmFileAttachmentResponse } from '@volontariapp/contracts-nest';
|
|
4
|
+
import type { ConfirmAttachmentOptions, StorageClientOptions } from '../interfaces/index.js';
|
|
5
|
+
export declare class StorageClientService implements OnModuleInit {
|
|
6
|
+
private readonly clientGrpc;
|
|
7
|
+
private readonly defaultOptions?;
|
|
8
|
+
private readonly logger;
|
|
9
|
+
private storageService;
|
|
10
|
+
constructor(clientGrpc: ClientGrpc, defaultOptions?: StorageClientOptions | undefined);
|
|
11
|
+
onModuleInit(): void;
|
|
12
|
+
confirmFileAttachment(command: ConfirmFileAttachmentCommand, options?: ConfirmAttachmentOptions): Promise<ConfirmFileAttachmentResponse>;
|
|
13
|
+
confirmPostAttachment(postId: string, fileIds: string[], options?: ConfirmAttachmentOptions): Promise<ConfirmFileAttachmentResponse>;
|
|
14
|
+
confirmEventCoverAttachment(eventId: string, fileId: string, options?: ConfirmAttachmentOptions): Promise<ConfirmFileAttachmentResponse>;
|
|
15
|
+
confirmUserAvatarAttachment(userId: string, fileId: string, options?: ConfirmAttachmentOptions): Promise<ConfirmFileAttachmentResponse>;
|
|
16
|
+
confirmBadgeIconAttachment(badgeId: string, fileId: string, options?: ConfirmAttachmentOptions): Promise<ConfirmFileAttachmentResponse>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=storage-client.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-client.service.d.ts","sourceRoot":"","sources":["../../src/services/storage-client.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAY,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EAGL,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAEnC,MAAM,8BAA8B,CAAC;AAKtC,OAAO,KAAK,EACV,wBAAwB,EACxB,oBAAoB,EAErB,MAAM,wBAAwB,CAAC;AAGhC,qBACa,oBAAqB,YAAW,YAAY;IAMrD,OAAO,CAAC,QAAQ,CAAC,UAAU;IAG3B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IARlC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsD;IAC7E,OAAO,CAAC,cAAc,CAAsC;gBAIzC,UAAU,EAAE,UAAU,EAGtB,cAAc,CAAC,EAAE,oBAAoB,YAAA;IAGxD,YAAY;IAKN,qBAAqB,CACzB,OAAO,EAAE,4BAA4B,EACrC,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,6BAA6B,CAAC;IA8BnC,qBAAqB,CACzB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,6BAA6B,CAAC;IAWnC,2BAA2B,CAC/B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,6BAA6B,CAAC;IAWnC,2BAA2B,CAC/B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,6BAA6B,CAAC;IAWnC,0BAA0B,CAC9B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,6BAA6B,CAAC;CAU1C"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var StorageClientService_1;
|
|
14
|
+
import { Inject, Injectable, Optional } from '@nestjs/common';
|
|
15
|
+
import { Metadata } from '@grpc/grpc-js';
|
|
16
|
+
import { firstValueFrom, throwError, timeout } from 'rxjs';
|
|
17
|
+
import { STORAGE_SERVICE_NAME, EntityType, } from '@volontariapp/contracts-nest';
|
|
18
|
+
import { Logger } from '@volontariapp/logger';
|
|
19
|
+
import { isBaseError } from '@volontariapp/errors';
|
|
20
|
+
import { STORAGE_ATTACHMENT_FAILED, STORAGE_TIMEOUT } from '@volontariapp/errors-nest';
|
|
21
|
+
import { DEFAULT_STORAGE_TIMEOUT_MS, STORAGE_CLIENT_OPTIONS } from '../constants.js';
|
|
22
|
+
import { isGrpcError } from '../errors/index.js';
|
|
23
|
+
let StorageClientService = StorageClientService_1 = class StorageClientService {
|
|
24
|
+
clientGrpc;
|
|
25
|
+
defaultOptions;
|
|
26
|
+
logger = new Logger({ context: StorageClientService_1.name });
|
|
27
|
+
storageService;
|
|
28
|
+
constructor(clientGrpc, defaultOptions) {
|
|
29
|
+
this.clientGrpc = clientGrpc;
|
|
30
|
+
this.defaultOptions = defaultOptions;
|
|
31
|
+
}
|
|
32
|
+
onModuleInit() {
|
|
33
|
+
this.storageService =
|
|
34
|
+
this.clientGrpc.getService(STORAGE_SERVICE_NAME);
|
|
35
|
+
}
|
|
36
|
+
async confirmFileAttachment(command, options) {
|
|
37
|
+
const timeoutMs = options?.timeoutMs ?? this.defaultOptions?.timeoutMs ?? DEFAULT_STORAGE_TIMEOUT_MS;
|
|
38
|
+
const internalToken = options?.internalToken ?? this.defaultOptions?.internalToken;
|
|
39
|
+
const metadata = new Metadata();
|
|
40
|
+
if (internalToken) {
|
|
41
|
+
metadata.set('x-internal-token', internalToken);
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
return await firstValueFrom(this.storageService.confirmFileAttachment(command, metadata).pipe(timeout({
|
|
45
|
+
first: timeoutMs,
|
|
46
|
+
with: () => throwError(() => STORAGE_TIMEOUT(command.entityId, timeoutMs)),
|
|
47
|
+
})));
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (isBaseError(error)) {
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
const grpcErr = isGrpcError(error) ? error : undefined;
|
|
54
|
+
const message = grpcErr?.details ?? (error instanceof Error ? error.message : String(error));
|
|
55
|
+
this.logger.error(`ConfirmFileAttachment failed for entity ${command.entityId}: ${message}`);
|
|
56
|
+
throw STORAGE_ATTACHMENT_FAILED(command.entityId, message);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async confirmPostAttachment(postId, fileIds, options) {
|
|
60
|
+
return this.confirmFileAttachment({
|
|
61
|
+
entityId: postId,
|
|
62
|
+
entityType: EntityType.ENTITY_TYPE_POST,
|
|
63
|
+
fileIds,
|
|
64
|
+
}, options);
|
|
65
|
+
}
|
|
66
|
+
async confirmEventCoverAttachment(eventId, fileId, options) {
|
|
67
|
+
return this.confirmFileAttachment({
|
|
68
|
+
entityId: eventId,
|
|
69
|
+
entityType: EntityType.ENTITY_TYPE_EVENT_COVER,
|
|
70
|
+
fileIds: [fileId],
|
|
71
|
+
}, options);
|
|
72
|
+
}
|
|
73
|
+
async confirmUserAvatarAttachment(userId, fileId, options) {
|
|
74
|
+
return this.confirmFileAttachment({
|
|
75
|
+
entityId: userId,
|
|
76
|
+
entityType: EntityType.ENTITY_TYPE_USER_AVATAR,
|
|
77
|
+
fileIds: [fileId],
|
|
78
|
+
}, options);
|
|
79
|
+
}
|
|
80
|
+
async confirmBadgeIconAttachment(badgeId, fileId, options) {
|
|
81
|
+
return this.confirmFileAttachment({
|
|
82
|
+
entityId: badgeId,
|
|
83
|
+
entityType: EntityType.ENTITY_TYPE_BADGE_ICON,
|
|
84
|
+
fileIds: [fileId],
|
|
85
|
+
}, options);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
StorageClientService = StorageClientService_1 = __decorate([
|
|
89
|
+
Injectable(),
|
|
90
|
+
__param(0, Inject(STORAGE_SERVICE_NAME)),
|
|
91
|
+
__param(1, Optional()),
|
|
92
|
+
__param(1, Inject(STORAGE_CLIENT_OPTIONS)),
|
|
93
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
94
|
+
], StorageClientService);
|
|
95
|
+
export { StorageClientService };
|
|
96
|
+
//# sourceMappingURL=storage-client.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-client.service.js","sourceRoot":"","sources":["../../src/services/storage-client.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAgB,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC3D,OAAO,EACL,oBAAoB,EAIpB,UAAU,GACX,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAMrF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAG1C,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAMZ;IAGA;IARF,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,OAAO,EAAE,sBAAoB,CAAC,IAAI,EAAE,CAAC,CAAC;IACrE,cAAc,CAAsC;IAE5D,YAEmB,UAAsB,EAGtB,cAAqC;QAHrC,eAAU,GAAV,UAAU,CAAY;QAGtB,mBAAc,GAAd,cAAc,CAAuB;IACrD,CAAC;IAEJ,YAAY;QACV,IAAI,CAAC,cAAc;YACjB,IAAI,CAAC,UAAU,CAAC,UAAU,CAAqC,oBAAoB,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,qBAAqB,CACzB,OAAqC,EACrC,OAAkC;QAElC,MAAM,SAAS,GACb,OAAO,EAAE,SAAS,IAAI,IAAI,CAAC,cAA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,OAAkC;QAElC,OAAO,IAAI,CAAC,qBAAqB,CAC/B;YACE,QAAQ,EAAE,MAAM;YAChB,UAAU,EAAE,UAAU,CAAC,gBAAgB;YACvC,OAAO;SACR,EACD,OAAO,CACR,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,2BAA2B,CAC/B,OAAe,EACf,MAAc,EACd,OAAkC;QAElC,OAAO,IAAI,CAAC,qBAAqB,CAC/B;YACE,QAAQ,EAAE,OAAO;YACjB,UAAU,EAAE,UAAU,CAAC,uBAAuB;YAC9C,OAAO,EAAE,CAAC,MAAM,CAAC;SAClB,EACD,OAAO,CACR,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,2BAA2B,CAC/B,MAAc,EACd,MAAc,EACd,OAAkC;QAElC,OAAO,IAAI,CAAC,qBAAqB,CAC/B;YACE,QAAQ,EAAE,MAAM;YAChB,UAAU,EAAE,UAAU,CAAC,uBAAuB;YAC9C,OAAO,EAAE,CAAC,MAAM,CAAC;SAClB,EACD,OAAO,CACR,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,0BAA0B,CAC9B,OAAe,EACf,MAAc,EACd,OAAkC;QAElC,OAAO,IAAI,CAAC,qBAAqB,CAC/B;YACE,QAAQ,EAAE,OAAO;YACjB,UAAU,EAAE,UAAU,CAAC,sBAAsB;YAC7C,OAAO,EAAE,CAAC,MAAM,CAAC;SAClB,EACD,OAAO,CACR,CAAC;IACJ,CAAC;CACF,CAAA;AA7GY,oBAAoB;IADhC,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAE5B,WAAA,QAAQ,EAAE,CAAA;IACV,WAAA,MAAM,CAAC,sBAAsB,CAAC,CAAA;;GARtB,oBAAoB,CA6GhC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type DynamicModule } from '@nestjs/common';
|
|
2
|
+
import type { StorageClientAsyncOptions, StorageClientOptions } from './interfaces/index.js';
|
|
3
|
+
export declare class StorageClientModule {
|
|
4
|
+
static register(options?: StorageClientOptions): DynamicModule;
|
|
5
|
+
static registerAsync(asyncOptions: StorageClientAsyncOptions): DynamicModule;
|
|
6
|
+
private static createAsyncOptionsProvider;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=storage-client.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-client.module.d.ts","sourceRoot":"","sources":["../src/storage-client.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAyB,MAAM,gBAAgB,CAAC;AAI3E,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EAErB,MAAM,uBAAuB,CAAC;AAG/B,qBACa,mBAAmB;IAC9B,MAAM,CAAC,QAAQ,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa;IAwBlE,MAAM,CAAC,aAAa,CAAC,YAAY,EAAE,yBAAyB,GAAG,aAAa;IAuB5E,OAAO,CAAC,MAAM,CAAC,0BAA0B;CAqB1C"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var StorageClientModule_1;
|
|
8
|
+
import { Module } from '@nestjs/common';
|
|
9
|
+
import { ClientsModule } from '@nestjs/microservices';
|
|
10
|
+
import { getGrpcOptions, STORAGE_SERVICE_NAME } from '@volontariapp/contracts-nest';
|
|
11
|
+
import { STORAGE_CLIENT_OPTIONS } from './constants.js';
|
|
12
|
+
import { StorageClientService } from './services/storage-client.service.js';
|
|
13
|
+
let StorageClientModule = StorageClientModule_1 = class StorageClientModule {
|
|
14
|
+
static register(options = {}) {
|
|
15
|
+
const url = options.url ?? 'localhost:50055';
|
|
16
|
+
return {
|
|
17
|
+
module: StorageClientModule_1,
|
|
18
|
+
imports: [
|
|
19
|
+
ClientsModule.register([
|
|
20
|
+
{
|
|
21
|
+
name: STORAGE_SERVICE_NAME,
|
|
22
|
+
...getGrpcOptions('STORAGE', url),
|
|
23
|
+
},
|
|
24
|
+
]),
|
|
25
|
+
],
|
|
26
|
+
providers: [
|
|
27
|
+
{
|
|
28
|
+
provide: STORAGE_CLIENT_OPTIONS,
|
|
29
|
+
useValue: options,
|
|
30
|
+
},
|
|
31
|
+
StorageClientService,
|
|
32
|
+
],
|
|
33
|
+
exports: [StorageClientService, ClientsModule],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
static registerAsync(asyncOptions) {
|
|
37
|
+
const clientsModuleAsync = ClientsModule.registerAsync([
|
|
38
|
+
{
|
|
39
|
+
name: STORAGE_SERVICE_NAME,
|
|
40
|
+
imports: asyncOptions.imports ?? [],
|
|
41
|
+
inject: [STORAGE_CLIENT_OPTIONS],
|
|
42
|
+
useFactory: (options) => {
|
|
43
|
+
const url = options.url ?? 'localhost:50055';
|
|
44
|
+
return getGrpcOptions('STORAGE', url);
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
const optionsProvider = this.createAsyncOptionsProvider(asyncOptions);
|
|
49
|
+
return {
|
|
50
|
+
module: StorageClientModule_1,
|
|
51
|
+
imports: [...(asyncOptions.imports ?? []), clientsModuleAsync],
|
|
52
|
+
providers: [optionsProvider, StorageClientService],
|
|
53
|
+
exports: [StorageClientService, ClientsModule],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
static createAsyncOptionsProvider(asyncOptions) {
|
|
57
|
+
if (asyncOptions.useFactory) {
|
|
58
|
+
return {
|
|
59
|
+
provide: STORAGE_CLIENT_OPTIONS,
|
|
60
|
+
useFactory: asyncOptions.useFactory,
|
|
61
|
+
inject: asyncOptions.inject ?? [],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const inject = asyncOptions.useExisting
|
|
65
|
+
? [asyncOptions.useExisting]
|
|
66
|
+
: asyncOptions.useClass
|
|
67
|
+
? [asyncOptions.useClass]
|
|
68
|
+
: [];
|
|
69
|
+
return {
|
|
70
|
+
provide: STORAGE_CLIENT_OPTIONS,
|
|
71
|
+
useFactory: async (factory) => factory.createStorageClientOptions(),
|
|
72
|
+
inject,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
StorageClientModule = StorageClientModule_1 = __decorate([
|
|
77
|
+
Module({})
|
|
78
|
+
], StorageClientModule);
|
|
79
|
+
export { StorageClientModule };
|
|
80
|
+
//# sourceMappingURL=storage-client.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-client.module.js","sourceRoot":"","sources":["../src/storage-client.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAsB,MAAM,EAAiB,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAMxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAGrE,IAAM,mBAAmB,2BAAzB,MAAM,mBAAmB;IAC9B,MAAM,CAAC,QAAQ,CAAC,UAAgC,EAAE;QAChD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,iBAAiB,CAAC;QAE7C,OAAO;YACL,MAAM,EAAE,qBAAmB;YAC3B,OAAO,EAAE;gBACP,aAAa,CAAC,QAAQ,CAAC;oBACrB;wBACE,IAAI,EAAE,oBAAoB;wBAC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M,MAAM,GAAG,YAAY,CAAC,WAAW;YACrC,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC;YAC5B,CAAC,CAAC,YAAY,CAAC,QAAQ;gBACrB,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC;gBACzB,CAAC,CAAC,EAAE,CAAC;QACT,OAAO;YACL,OAAO,EAAE,sBAAsB;YAC/B,UAAU,EAAE,KAAK,EAAE,OAAoC,EAAE,EAAE,CACzD,OAAO,CAAC,0BAA0B,EAAE;YACtC,MAAM;SACP,CAAC;IACJ,CAAC;CACF,CAAA;AArEY,mBAAmB;IAD/B,MAAM,CAAC,EAAE,CAAC;GACE,mBAAmB,CAqE/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-client.service.unit.spec.d.ts","sourceRoot":"","sources":["../../src/test/storage-client.service.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { jest, describe, it, expect, beforeEach } from '@jest/globals';
|
|
3
|
+
import { of, throwError, timer } from 'rxjs';
|
|
4
|
+
import { map } from 'rxjs/operators';
|
|
5
|
+
import { StorageClientService, isGrpcError, EntityType, STORAGE_SERVICE_NAME, } from '../index.js';
|
|
6
|
+
describe('StorageClientService (Unit)', () => {
|
|
7
|
+
let service;
|
|
8
|
+
let mockClientGrpc;
|
|
9
|
+
let mockStorageService;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
mockStorageService = {
|
|
12
|
+
confirmFileAttachment: jest.fn(),
|
|
13
|
+
};
|
|
14
|
+
mockClientGrpc = {
|
|
15
|
+
getService: jest.fn().mockReturnValue(mockStorageService),
|
|
16
|
+
getClientByServiceName: jest.fn(),
|
|
17
|
+
};
|
|
18
|
+
service = new StorageClientService(mockClientGrpc, {
|
|
19
|
+
internalToken: 'default-secret-token',
|
|
20
|
+
timeoutMs: 1000,
|
|
21
|
+
});
|
|
22
|
+
service.onModuleInit();
|
|
23
|
+
});
|
|
24
|
+
describe('onModuleInit', () => {
|
|
25
|
+
it('should acquire StorageService from ClientGrpc', () => {
|
|
26
|
+
const spyService = jest.spyOn(mockClientGrpc, 'getService');
|
|
27
|
+
service.onModuleInit();
|
|
28
|
+
expect(spyService).toHaveBeenCalledWith(STORAGE_SERVICE_NAME);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('confirmFileAttachment', () => {
|
|
32
|
+
it('should call gRPC client with command and metadata, returning response', async () => {
|
|
33
|
+
const mockResponse = {
|
|
34
|
+
success: true,
|
|
35
|
+
updatedCount: 1,
|
|
36
|
+
files: [],
|
|
37
|
+
};
|
|
38
|
+
mockStorageService.confirmFileAttachment.mockReturnValue(of(mockResponse));
|
|
39
|
+
const result = await service.confirmFileAttachment({
|
|
40
|
+
entityId: 'post-1',
|
|
41
|
+
entityType: EntityType.ENTITY_TYPE_POST,
|
|
42
|
+
fileIds: ['file-1'],
|
|
43
|
+
});
|
|
44
|
+
expect(result).toEqual(mockResponse);
|
|
45
|
+
expect(mockStorageService.confirmFileAttachment).toHaveBeenCalledTimes(1);
|
|
46
|
+
const [command, rawMeta] = mockStorageService.confirmFileAttachment.mock.calls[0];
|
|
47
|
+
const metadata = rawMeta;
|
|
48
|
+
expect(command).toEqual({
|
|
49
|
+
entityId: 'post-1',
|
|
50
|
+
entityType: EntityType.ENTITY_TYPE_POST,
|
|
51
|
+
fileIds: ['file-1'],
|
|
52
|
+
});
|
|
53
|
+
expect(metadata.get('x-internal-token')).toEqual(['default-secret-token']);
|
|
54
|
+
});
|
|
55
|
+
it('should allow overriding internalToken and timeoutMs in call options', async () => {
|
|
56
|
+
const mockResponse = {
|
|
57
|
+
success: true,
|
|
58
|
+
updatedCount: 1,
|
|
59
|
+
files: [],
|
|
60
|
+
};
|
|
61
|
+
mockStorageService.confirmFileAttachment.mockReturnValue(of(mockResponse));
|
|
62
|
+
await service.confirmFileAttachment({
|
|
63
|
+
entityId: 'post-1',
|
|
64
|
+
entityType: EntityType.ENTITY_TYPE_POST,
|
|
65
|
+
fileIds: ['file-1'],
|
|
66
|
+
}, { internalToken: 'custom-token', timeoutMs: 500 });
|
|
67
|
+
const [, rawMeta] = mockStorageService.confirmFileAttachment.mock.calls[0];
|
|
68
|
+
const metadata = rawMeta;
|
|
69
|
+
expect(metadata.get('x-internal-token')).toEqual(['custom-token']);
|
|
70
|
+
});
|
|
71
|
+
it('should throw StorageClientTimeoutError when call exceeds timeout', async () => {
|
|
72
|
+
mockStorageService.confirmFileAttachment.mockReturnValue(timer(200).pipe(map(() => ({
|
|
73
|
+
success: true,
|
|
74
|
+
updatedCount: 1,
|
|
75
|
+
files: [],
|
|
76
|
+
}))));
|
|
77
|
+
await expect(service.confirmFileAttachment({
|
|
78
|
+
entityId: 'event-1',
|
|
79
|
+
entityType: EntityType.ENTITY_TYPE_EVENT_COVER,
|
|
80
|
+
fileIds: ['cover-file-1'],
|
|
81
|
+
}, { timeoutMs: 50 })).rejects.toMatchObject({
|
|
82
|
+
code: 'STORAGE_TIMEOUT',
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
it('should throw STORAGE_ATTACHMENT_FAILED when gRPC call throws', async () => {
|
|
86
|
+
const grpcError = {
|
|
87
|
+
code: 5,
|
|
88
|
+
details: 'File not found',
|
|
89
|
+
message: '5 NOT_FOUND: File not found',
|
|
90
|
+
};
|
|
91
|
+
mockStorageService.confirmFileAttachment.mockReturnValue(throwError(() => grpcError));
|
|
92
|
+
await expect(service.confirmFileAttachment({
|
|
93
|
+
entityId: 'user-1',
|
|
94
|
+
entityType: EntityType.ENTITY_TYPE_USER_AVATAR,
|
|
95
|
+
fileIds: ['avatar-file-1'],
|
|
96
|
+
})).rejects.toMatchObject({
|
|
97
|
+
code: 'STORAGE_ATTACHMENT_FAILED',
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
describe('convenience methods', () => {
|
|
102
|
+
it('confirmPostAttachment should call confirmFileAttachment with ENTITY_TYPE_POST', async () => {
|
|
103
|
+
const spy = jest.spyOn(service, 'confirmFileAttachment').mockResolvedValue({
|
|
104
|
+
success: true,
|
|
105
|
+
updatedCount: 2,
|
|
106
|
+
files: [],
|
|
107
|
+
});
|
|
108
|
+
await service.confirmPostAttachment('p-123', ['f-1', 'f-2']);
|
|
109
|
+
expect(spy).toHaveBeenCalledWith({
|
|
110
|
+
entityId: 'p-123',
|
|
111
|
+
entityType: EntityType.ENTITY_TYPE_POST,
|
|
112
|
+
fileIds: ['f-1', 'f-2'],
|
|
113
|
+
}, undefined);
|
|
114
|
+
});
|
|
115
|
+
it('confirmEventCoverAttachment should call confirmFileAttachment with ENTITY_TYPE_EVENT_COVER', async () => {
|
|
116
|
+
const spy = jest.spyOn(service, 'confirmFileAttachment').mockResolvedValue({
|
|
117
|
+
success: true,
|
|
118
|
+
updatedCount: 1,
|
|
119
|
+
files: [],
|
|
120
|
+
});
|
|
121
|
+
await service.confirmEventCoverAttachment('e-123', 'cov-1');
|
|
122
|
+
expect(spy).toHaveBeenCalledWith({
|
|
123
|
+
entityId: 'e-123',
|
|
124
|
+
entityType: EntityType.ENTITY_TYPE_EVENT_COVER,
|
|
125
|
+
fileIds: ['cov-1'],
|
|
126
|
+
}, undefined);
|
|
127
|
+
});
|
|
128
|
+
it('confirmUserAvatarAttachment should call confirmFileAttachment with ENTITY_TYPE_USER_AVATAR', async () => {
|
|
129
|
+
const spy = jest.spyOn(service, 'confirmFileAttachment').mockResolvedValue({
|
|
130
|
+
success: true,
|
|
131
|
+
updatedCount: 1,
|
|
132
|
+
files: [],
|
|
133
|
+
});
|
|
134
|
+
await service.confirmUserAvatarAttachment('u-123', 'av-1');
|
|
135
|
+
expect(spy).toHaveBeenCalledWith({
|
|
136
|
+
entityId: 'u-123',
|
|
137
|
+
entityType: EntityType.ENTITY_TYPE_USER_AVATAR,
|
|
138
|
+
fileIds: ['av-1'],
|
|
139
|
+
}, undefined);
|
|
140
|
+
});
|
|
141
|
+
it('confirmBadgeIconAttachment should call confirmFileAttachment with ENTITY_TYPE_BADGE_ICON', async () => {
|
|
142
|
+
const spy = jest.spyOn(service, 'confirmFileAttachment').mockResolvedValue({
|
|
143
|
+
success: true,
|
|
144
|
+
updatedCount: 1,
|
|
145
|
+
files: [],
|
|
146
|
+
});
|
|
147
|
+
await service.confirmBadgeIconAttachment('b-123', 'icon-1');
|
|
148
|
+
expect(spy).toHaveBeenCalledWith({
|
|
149
|
+
entityId: 'b-123',
|
|
150
|
+
entityType: EntityType.ENTITY_TYPE_BADGE_ICON,
|
|
151
|
+
fileIds: ['icon-1'],
|
|
152
|
+
}, undefined);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
describe('isGrpcError', () => {
|
|
156
|
+
it('should return true for valid gRPC error structure', () => {
|
|
157
|
+
expect(isGrpcError({ code: 14, details: 'Unavailable', message: '14 UNAVAILABLE' })).toBe(true);
|
|
158
|
+
});
|
|
159
|
+
it('should return false for non-grpc errors', () => {
|
|
160
|
+
expect(isGrpcError(new Error('general error'))).toBe(false);
|
|
161
|
+
expect(isGrpcError(null)).toBe(false);
|
|
162
|
+
expect(isGrpcError('string error')).toBe(false);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
//# sourceMappingURL=storage-client.service.unit.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-client.service.unit.spec.js","sourceRoot":"","sources":["../../src/test/storage-client.service.unit.spec.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OA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EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;YAC3D,MAAM,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,IAAI,CACvF,IAAI,CACL,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;YACjD,MAAM,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5D,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACtC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volontariapp/storage-client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"version": "0.2.0-snap-5aae3b8",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public",
|
|
6
|
+
"provenance": true
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Volontariapp/npm-packages.git"
|
|
11
|
+
},
|
|
12
|
+
"description": "NestJS gRPC client for ms-storage ConfirmFileAttachment and storage operations",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=24.14.0"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"prepublishOnly": "yarn build",
|
|
31
|
+
"build": "tsc -p tsconfig.json",
|
|
32
|
+
"lint": "eslint src/",
|
|
33
|
+
"test": "node --experimental-vm-modules $(yarn bin jest)",
|
|
34
|
+
"test:coverage": "node --experimental-vm-modules $(yarn bin jest) --coverage"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@grpc/grpc-js": "^1.12.0",
|
|
38
|
+
"@jest/globals": "^30.3.0",
|
|
39
|
+
"@nestjs/common": "^11.1.18",
|
|
40
|
+
"@nestjs/core": "^11.1.18",
|
|
41
|
+
"@nestjs/microservices": "^11.1.14",
|
|
42
|
+
"@nestjs/testing": "^11.1.18",
|
|
43
|
+
"@types/jest": "^30.0.0",
|
|
44
|
+
"jest": "^30.3.0",
|
|
45
|
+
"reflect-metadata": "^0.2.2",
|
|
46
|
+
"rxjs": "^7.8.2",
|
|
47
|
+
"ts-jest": "^29.4.9",
|
|
48
|
+
"typescript": "5.7.3"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@grpc/grpc-js": "^1.12.0",
|
|
52
|
+
"@nestjs/common": "^11.0.0",
|
|
53
|
+
"@nestjs/core": "^11.0.0",
|
|
54
|
+
"@nestjs/microservices": "^11.0.0",
|
|
55
|
+
"rxjs": "^7.8.2"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@volontariapp/contracts": "4.3.16",
|
|
59
|
+
"@volontariapp/contracts-nest": "3.3.8",
|
|
60
|
+
"@volontariapp/errors": "0.6.5",
|
|
61
|
+
"@volontariapp/errors-nest": "0.14.0-snap-5aae3b8",
|
|
62
|
+
"@volontariapp/logger": "0.4.0"
|
|
63
|
+
}
|
|
6
64
|
}
|
package/README.md
DELETED