@atls/nestjs-gcs-client 0.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/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+
2
+
3
+ ## 0.0.1 (2025-03-15)
4
+
5
+
6
+ ### Features
7
+
8
+
9
+ * **nestjs-gcs-client:** init ([167725e](https://github.com/atls/nestjs/commit/167725ec09109e7015db1af5c3e9011eca67716f))
10
+
11
+
@@ -0,0 +1,2 @@
1
+ export * from '@google-cloud/storage';
2
+ export * from './module/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "@google-cloud/storage";
2
+ export * from "./module/index.js";
@@ -0,0 +1,7 @@
1
+ import type { StorageOptions } from '@google-cloud/storage';
2
+ import type { GcsClientModuleOptions } from './gcs-client.module.interfaces.js';
3
+ export declare class GcsClientConfigFactory {
4
+ private readonly options;
5
+ constructor(options: GcsClientModuleOptions);
6
+ createGcsClientOptions(options?: GcsClientModuleOptions): StorageOptions;
7
+ }
@@ -0,0 +1,33 @@
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
+ import { Injectable } from '@nestjs/common';
14
+ import { Inject } from '@nestjs/common';
15
+ import { GCS_CLIENT_MODULE_OPTIONS } from './gcs-client.module.constants.js';
16
+ let GcsClientConfigFactory = class GcsClientConfigFactory {
17
+ options;
18
+ constructor(options) {
19
+ this.options = options;
20
+ }
21
+ createGcsClientOptions(options = {}) {
22
+ return {
23
+ apiEndpoint: options.apiEndpoint || this.options.apiEndpoint || process.env.GCS_API_ENDPOINT,
24
+ keyFilename: options.keyFilename || this.options.keyFilename || process.env.GCS_KEY_FILENAME,
25
+ };
26
+ }
27
+ };
28
+ GcsClientConfigFactory = __decorate([
29
+ Injectable(),
30
+ __param(0, Inject(GCS_CLIENT_MODULE_OPTIONS)),
31
+ __metadata("design:paramtypes", [Object])
32
+ ], GcsClientConfigFactory);
33
+ export { GcsClientConfigFactory };
@@ -0,0 +1,8 @@
1
+ import type { GcsClientModuleOptions } from './gcs-client.module.interfaces.js';
2
+ import { Storage } from '@google-cloud/storage';
3
+ import { GcsClientConfigFactory } from './gcs-client.config-factory.js';
4
+ export declare class GcsClientFactory {
5
+ private readonly configFactory;
6
+ constructor(configFactory: GcsClientConfigFactory);
7
+ create(options?: GcsClientModuleOptions): Storage;
8
+ }
@@ -0,0 +1,26 @@
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
+ import { Storage } from '@google-cloud/storage';
11
+ import { Injectable } from '@nestjs/common';
12
+ import { GcsClientConfigFactory } from './gcs-client.config-factory.js';
13
+ let GcsClientFactory = class GcsClientFactory {
14
+ configFactory;
15
+ constructor(configFactory) {
16
+ this.configFactory = configFactory;
17
+ }
18
+ create(options = {}) {
19
+ return new Storage(this.configFactory.createGcsClientOptions(options));
20
+ }
21
+ };
22
+ GcsClientFactory = __decorate([
23
+ Injectable(),
24
+ __metadata("design:paramtypes", [GcsClientConfigFactory])
25
+ ], GcsClientFactory);
26
+ export { GcsClientFactory };
@@ -0,0 +1 @@
1
+ export declare const GCS_CLIENT_MODULE_OPTIONS: unique symbol;
@@ -0,0 +1 @@
1
+ export const GCS_CLIENT_MODULE_OPTIONS = Symbol('gcs-client-module-options');
@@ -0,0 +1,9 @@
1
+ import type { DynamicModule } from '@nestjs/common';
2
+ import type { GcsClientModuleOptions } from './gcs-client.module.interfaces.js';
3
+ import type { GcsClientModuleAsyncOptions } from './gcs-client.module.interfaces.js';
4
+ export declare class GcsClientModule {
5
+ static register(options?: GcsClientModuleOptions): DynamicModule;
6
+ static registerAsync(options: GcsClientModuleAsyncOptions): DynamicModule;
7
+ private static createAsyncProviders;
8
+ private static createAsyncOptionsProvider;
9
+ }
@@ -0,0 +1,15 @@
1
+ import type { ModuleMetadata } from '@nestjs/common/interfaces';
2
+ import type { Type } from '@nestjs/common/interfaces';
3
+ export interface GcsClientModuleOptions {
4
+ apiEndpoint?: string;
5
+ keyFilename?: string;
6
+ }
7
+ export interface GcsClientOptionsFactory {
8
+ createGcsClientOptions: () => GcsClientModuleOptions | Promise<GcsClientModuleOptions>;
9
+ }
10
+ export interface GcsClientModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
11
+ useExisting?: Type<GcsClientOptionsFactory>;
12
+ useClass?: Type<GcsClientOptionsFactory>;
13
+ useFactory?: (...args: Array<any>) => GcsClientModuleOptions | Promise<GcsClientModuleOptions>;
14
+ inject?: Array<any>;
15
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,65 @@
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 GcsClientModule_1;
8
+ import { Module } from '@nestjs/common';
9
+ import { GcsClientConfigFactory } from './gcs-client.config-factory.js';
10
+ import { GcsClientFactory } from './gcs-client.factory.js';
11
+ import { GCS_CLIENT_MODULE_OPTIONS } from './gcs-client.module.constants.js';
12
+ let GcsClientModule = GcsClientModule_1 = class GcsClientModule {
13
+ static register(options = {}) {
14
+ return {
15
+ module: GcsClientModule_1,
16
+ providers: [
17
+ GcsClientConfigFactory,
18
+ GcsClientFactory,
19
+ {
20
+ provide: GCS_CLIENT_MODULE_OPTIONS,
21
+ useValue: options,
22
+ },
23
+ ],
24
+ exports: [GcsClientConfigFactory, GcsClientFactory],
25
+ };
26
+ }
27
+ static registerAsync(options) {
28
+ return {
29
+ module: GcsClientModule_1,
30
+ imports: options.imports || [],
31
+ providers: [...this.createAsyncProviders(options), GcsClientConfigFactory, GcsClientFactory],
32
+ exports: [GcsClientConfigFactory, GcsClientFactory],
33
+ };
34
+ }
35
+ static createAsyncProviders(options) {
36
+ if (options.useExisting || options.useFactory) {
37
+ return [this.createAsyncOptionsProvider(options)];
38
+ }
39
+ return [
40
+ this.createAsyncOptionsProvider(options),
41
+ {
42
+ provide: options.useClass,
43
+ useClass: options.useClass,
44
+ },
45
+ ];
46
+ }
47
+ static createAsyncOptionsProvider(options) {
48
+ if (options.useFactory) {
49
+ return {
50
+ provide: GCS_CLIENT_MODULE_OPTIONS,
51
+ useFactory: options.useFactory,
52
+ inject: options.inject || [],
53
+ };
54
+ }
55
+ return {
56
+ provide: GCS_CLIENT_MODULE_OPTIONS,
57
+ useFactory: (optionsFactory) => optionsFactory.createGcsClientOptions(),
58
+ inject: [options.useExisting || options.useClass],
59
+ };
60
+ }
61
+ };
62
+ GcsClientModule = GcsClientModule_1 = __decorate([
63
+ Module({})
64
+ ], GcsClientModule);
65
+ export { GcsClientModule };
@@ -0,0 +1,5 @@
1
+ export * from './gcs-client.module.interfaces.js';
2
+ export * from './gcs-client.module.constants.js';
3
+ export * from './gcs-client.config-factory.js';
4
+ export * from './gcs-client.factory.js';
5
+ export * from './gcs-client.module.js';
@@ -0,0 +1,5 @@
1
+ export * from "./gcs-client.module.interfaces.js";
2
+ export * from "./gcs-client.module.constants.js";
3
+ export * from "./gcs-client.config-factory.js";
4
+ export * from "./gcs-client.factory.js";
5
+ export * from "./gcs-client.module.js";
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@atls/nestjs-gcs-client",
3
+ "version": "0.0.1",
4
+ "license": "BSD-3-Clause",
5
+ "type": "module",
6
+ "exports": {
7
+ "./package.json": "./package.json",
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "main": "dist/index.js",
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "yarn library build",
20
+ "prepack": "yarn run build",
21
+ "postpack": "rm -rf dist"
22
+ },
23
+ "dependencies": {
24
+ "@google-cloud/storage": "7.0.1"
25
+ },
26
+ "devDependencies": {
27
+ "@nestjs/common": "10.4.15",
28
+ "@nestjs/core": "10.4.15",
29
+ "reflect-metadata": "0.2.2",
30
+ "rxjs": "7.8.1"
31
+ },
32
+ "peerDependencies": {
33
+ "@nestjs/common": "^10",
34
+ "@nestjs/core": "^10",
35
+ "reflect-metadata": "^0.2",
36
+ "rxjs": "^7"
37
+ },
38
+ "publishConfig": {
39
+ "exports": {
40
+ "./package.json": "./package.json",
41
+ ".": {
42
+ "import": "./dist/index.js",
43
+ "types": "./dist/index.d.ts",
44
+ "default": "./dist/index.js"
45
+ }
46
+ },
47
+ "main": "dist/index.js",
48
+ "typings": "dist/index.d.ts"
49
+ },
50
+ "typings": "dist/index.d.ts"
51
+ }