geniebox-shared-lib 1.0.44 → 1.0.46
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/ai/ai.client.d.ts +12 -0
- package/dist/ai/ai.client.js +42 -0
- package/dist/ai/ai.interface.d.ts +46 -0
- package/dist/ai/ai.interface.js +129 -0
- package/dist/ai/google/protobuf/empty.interface.d.ts +19 -0
- package/dist/ai/google/protobuf/empty.interface.js +35 -0
- package/dist/ai/google/protobuf/struct.interface.d.ts +91 -0
- package/dist/ai/google/protobuf/struct.interface.js +300 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +25 -1
- package/dist/openai/google/protobuf/struct.interface.d.ts +91 -0
- package/dist/openai/google/protobuf/struct.interface.js +300 -0
- package/dist/openai/openai.client.d.ts +12 -0
- package/dist/openai/openai.client.js +43 -0
- package/dist/openai/openai.interface.d.ts +50 -0
- package/dist/openai/openai.interface.js +119 -0
- package/dist/shared.module.d.ts +8 -0
- package/dist/shared.module.js +64 -7
- package/package.json +5 -2
package/dist/shared.module.d.ts
CHANGED
|
@@ -8,6 +8,14 @@ export interface SharedModuleOptions {
|
|
|
8
8
|
protoPath: string;
|
|
9
9
|
url: string;
|
|
10
10
|
};
|
|
11
|
+
openai?: {
|
|
12
|
+
protoPath: string;
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
ai?: {
|
|
16
|
+
protoPath: string;
|
|
17
|
+
url: string;
|
|
18
|
+
};
|
|
11
19
|
}
|
|
12
20
|
export declare class SharedModule {
|
|
13
21
|
private static readonly logger;
|
package/dist/shared.module.js
CHANGED
|
@@ -13,10 +13,13 @@ const microservices_1 = require("@nestjs/microservices");
|
|
|
13
13
|
const path_1 = require("path");
|
|
14
14
|
const user_client_1 = require("./user/user.client");
|
|
15
15
|
const auth_client_1 = require("./auth/auth.client");
|
|
16
|
+
const openai_client_1 = require("./openai/openai.client");
|
|
17
|
+
const ai_client_1 = require("./ai/ai.client");
|
|
16
18
|
let SharedModule = SharedModule_1 = class SharedModule {
|
|
17
19
|
static forRoot(options = {}) {
|
|
18
20
|
const clients = [];
|
|
19
21
|
const providers = [];
|
|
22
|
+
// USER
|
|
20
23
|
if (options.user) {
|
|
21
24
|
clients.push({
|
|
22
25
|
name: "USER_PACKAGE",
|
|
@@ -32,7 +35,6 @@ let SharedModule = SharedModule_1 = class SharedModule {
|
|
|
32
35
|
useFactory: (client) => {
|
|
33
36
|
const svc = new user_client_1.UsersClient(client);
|
|
34
37
|
try {
|
|
35
|
-
// Проверяем готовность сервиса
|
|
36
38
|
svc.onModuleInit();
|
|
37
39
|
SharedModule_1.logger.log("UsersClient initialized successfully");
|
|
38
40
|
}
|
|
@@ -45,11 +47,9 @@ let SharedModule = SharedModule_1 = class SharedModule {
|
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
else {
|
|
48
|
-
providers.push({
|
|
49
|
-
provide: user_client_1.UsersClient,
|
|
50
|
-
useValue: null,
|
|
51
|
-
});
|
|
50
|
+
providers.push({ provide: user_client_1.UsersClient, useValue: null });
|
|
52
51
|
}
|
|
52
|
+
// AUTH
|
|
53
53
|
if (options.auth) {
|
|
54
54
|
clients.push({
|
|
55
55
|
name: "AUTH_PACKAGE",
|
|
@@ -77,10 +77,67 @@ let SharedModule = SharedModule_1 = class SharedModule {
|
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
|
+
providers.push({ provide: auth_client_1.AuthClient, useValue: null });
|
|
81
|
+
}
|
|
82
|
+
// AI
|
|
83
|
+
if (options.ai) {
|
|
84
|
+
clients.push({
|
|
85
|
+
name: "AI_PACKAGE",
|
|
86
|
+
transport: microservices_1.Transport.GRPC,
|
|
87
|
+
options: {
|
|
88
|
+
package: "ai",
|
|
89
|
+
protoPath: (0, path_1.resolve)(process.cwd(), options.ai.protoPath),
|
|
90
|
+
url: options.ai.url,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
80
93
|
providers.push({
|
|
81
|
-
provide:
|
|
82
|
-
|
|
94
|
+
provide: ai_client_1.AIClient,
|
|
95
|
+
useFactory: (client) => {
|
|
96
|
+
const svc = new ai_client_1.AIClient(client);
|
|
97
|
+
try {
|
|
98
|
+
svc.onModuleInit();
|
|
99
|
+
SharedModule_1.logger.log("AIClient initialized successfully");
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
SharedModule_1.logger.error("AIClient initialization failed", err);
|
|
103
|
+
}
|
|
104
|
+
return svc;
|
|
105
|
+
},
|
|
106
|
+
inject: ["AI_PACKAGE"],
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
providers.push({ provide: ai_client_1.AIClient, useValue: null });
|
|
111
|
+
}
|
|
112
|
+
// OPENAI
|
|
113
|
+
if (options.openai) {
|
|
114
|
+
clients.push({
|
|
115
|
+
name: "OPENAI_PACKAGE",
|
|
116
|
+
transport: microservices_1.Transport.GRPC,
|
|
117
|
+
options: {
|
|
118
|
+
package: "openai",
|
|
119
|
+
protoPath: (0, path_1.resolve)(process.cwd(), options.openai.protoPath),
|
|
120
|
+
url: options.openai.url,
|
|
121
|
+
},
|
|
83
122
|
});
|
|
123
|
+
providers.push({
|
|
124
|
+
provide: openai_client_1.OpenAIClient,
|
|
125
|
+
useFactory: (client) => {
|
|
126
|
+
const svc = new openai_client_1.OpenAIClient(client);
|
|
127
|
+
try {
|
|
128
|
+
svc.onModuleInit();
|
|
129
|
+
SharedModule_1.logger.log("OpenAIClient initialized successfully");
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
SharedModule_1.logger.error("OpenAIClient initialization failed", err);
|
|
133
|
+
}
|
|
134
|
+
return svc;
|
|
135
|
+
},
|
|
136
|
+
inject: ["OPENAI_PACKAGE"],
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
providers.push({ provide: openai_client_1.OpenAIClient, useValue: null });
|
|
84
141
|
}
|
|
85
142
|
return {
|
|
86
143
|
module: SharedModule_1,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geniebox-shared-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.46",
|
|
4
4
|
"description": "Shared NestJS library with gRPC clients",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
"build": "tsc",
|
|
12
12
|
"proto:gen:user": "mkdir -p src/user && protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=src/user --ts_proto_opt=nestJs=true,outputServices=grpc-js,returnObservable=false,addGrpcMetadata=true,fileSuffix=.interface,esModuleInterop=true,useOptionals=true -I=../../libs/protos ../../libs/protos/user.proto",
|
|
13
13
|
"proto:gen:auth": "mkdir -p src/auth && protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=src/auth --ts_proto_opt=nestJs=true,outputServices=grpc-js,returnObservable=false,addGrpcMetadata=true,fileSuffix=.interface,esModuleInterop=true,useOptionals=true -I=../../libs/protos ../../libs/protos/auth.proto",
|
|
14
|
-
"proto:gen": "
|
|
14
|
+
"proto:gen:ai": "mkdir -p src/ai && protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=src/ai --ts_proto_opt=nestJs=true,outputServices=grpc-js,returnObservable=false,addGrpcMetadata=true,fileSuffix=.interface,esModuleInterop=true,useOptionals=true -I=../../libs/protos ../../libs/protos/ai.proto",
|
|
15
|
+
"proto:gen:openai": "mkdir -p src/openai && protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=src/openai --ts_proto_opt=nestJs=true,outputServices=grpc-js,returnObservable=false,addGrpcMetadata=true,fileSuffix=.interface,esModuleInterop=true,useOptionals=true -I=../../libs/protos ../../libs/protos/openai.proto",
|
|
16
|
+
"proto:gen": "npm run proto:gen:user && npm run proto:gen:auth && npm run proto:gen:openai && npm run proto:gen:ai",
|
|
17
|
+
"generate": "npm run proto:gen && npm run build",
|
|
15
18
|
"prepublishOnly": "npm run build"
|
|
16
19
|
},
|
|
17
20
|
"author": "Viktor Kanishchev",
|