geniebox-shared-lib 1.0.43 → 1.0.45

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.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { SharedModule } from "./shared.module";
2
2
  export { UsersClient } from "./user/user.client";
3
3
  export { AuthClient } from "./auth/auth.client";
4
+ export { OpenAIClient } from "./openai/openai.client";
4
5
  export { MessageFns as UserMessageFns, protobufPackage as UserProtobufPackage, User, CreateUserRequest, CreateUserPersonal, UpdateUserRequest, GetByIdRequest, UserResponse, UsersResponse, FindByEmailRequest, FindByPhoneRequest, UpdateUserPersonal, UpdatePasswordRequest, UpdateEmailVerificationRequest, ResetPasswordData, GetEmailVerificationStatusRequest, EmailVerificationStatusResponse, UserServiceService as UserService, } from "./user/user.interface";
5
6
  export { MessageFns as AuthMessageFns, protobufPackage as AuthProtobufPackage, LoginCredentials, RegisterCredentials, LogoutRequest, RefreshRequest, AuthResponse, RefreshTokenResponse, RecoverRequest, ResetPasswordRequest, ConfirmEmailRequest, ConfirmEmailResponse, CheckEmailVerifiedRequest, CheckEmailVerifiedResponse, } from "./auth/auth.interface";
7
+ export { MessageFns as OpenAIMessageFns, protobufPackage as OpenAIProtobufPackage, CreateRequest as OpenAICreateRequest, CreateResponse as OpenAICreateResponse, OpenAIServiceService as OpenAIService, } from "./openai/openai.interface";
package/dist/index.js CHANGED
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CheckEmailVerifiedResponse = exports.CheckEmailVerifiedRequest = exports.ConfirmEmailResponse = exports.ConfirmEmailRequest = exports.ResetPasswordRequest = exports.RecoverRequest = exports.RefreshTokenResponse = exports.AuthResponse = exports.RefreshRequest = exports.LogoutRequest = exports.RegisterCredentials = exports.LoginCredentials = exports.AuthProtobufPackage = exports.UserService = exports.EmailVerificationStatusResponse = exports.GetEmailVerificationStatusRequest = exports.ResetPasswordData = exports.UpdateEmailVerificationRequest = exports.UpdatePasswordRequest = exports.UpdateUserPersonal = exports.FindByPhoneRequest = exports.FindByEmailRequest = exports.UsersResponse = exports.UserResponse = exports.GetByIdRequest = exports.UpdateUserRequest = exports.CreateUserPersonal = exports.CreateUserRequest = exports.User = exports.UserProtobufPackage = exports.AuthClient = exports.UsersClient = exports.SharedModule = void 0;
3
+ exports.OpenAIService = exports.OpenAICreateResponse = exports.OpenAICreateRequest = exports.OpenAIProtobufPackage = exports.CheckEmailVerifiedResponse = exports.CheckEmailVerifiedRequest = exports.ConfirmEmailResponse = exports.ConfirmEmailRequest = exports.ResetPasswordRequest = exports.RecoverRequest = exports.RefreshTokenResponse = exports.AuthResponse = exports.RefreshRequest = exports.LogoutRequest = exports.RegisterCredentials = exports.LoginCredentials = exports.AuthProtobufPackage = exports.UserService = exports.EmailVerificationStatusResponse = exports.GetEmailVerificationStatusRequest = exports.ResetPasswordData = exports.UpdateEmailVerificationRequest = exports.UpdatePasswordRequest = exports.UpdateUserPersonal = exports.FindByPhoneRequest = exports.FindByEmailRequest = exports.UsersResponse = exports.UserResponse = exports.GetByIdRequest = exports.UpdateUserRequest = exports.CreateUserPersonal = exports.CreateUserRequest = exports.User = exports.UserProtobufPackage = exports.OpenAIClient = exports.AuthClient = exports.UsersClient = exports.SharedModule = void 0;
4
4
  var shared_module_1 = require("./shared.module");
5
5
  Object.defineProperty(exports, "SharedModule", { enumerable: true, get: function () { return shared_module_1.SharedModule; } });
6
6
  var user_client_1 = require("./user/user.client");
7
7
  Object.defineProperty(exports, "UsersClient", { enumerable: true, get: function () { return user_client_1.UsersClient; } });
8
8
  var auth_client_1 = require("./auth/auth.client");
9
9
  Object.defineProperty(exports, "AuthClient", { enumerable: true, get: function () { return auth_client_1.AuthClient; } });
10
+ var openai_client_1 = require("./openai/openai.client");
11
+ Object.defineProperty(exports, "OpenAIClient", { enumerable: true, get: function () { return openai_client_1.OpenAIClient; } });
12
+ // ============================
13
+ // User exports
14
+ // ============================
10
15
  var user_interface_1 = require("./user/user.interface");
11
16
  Object.defineProperty(exports, "UserProtobufPackage", { enumerable: true, get: function () { return user_interface_1.protobufPackage; } });
12
17
  Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_interface_1.User; } });
@@ -25,6 +30,9 @@ Object.defineProperty(exports, "ResetPasswordData", { enumerable: true, get: fun
25
30
  Object.defineProperty(exports, "GetEmailVerificationStatusRequest", { enumerable: true, get: function () { return user_interface_1.GetEmailVerificationStatusRequest; } });
26
31
  Object.defineProperty(exports, "EmailVerificationStatusResponse", { enumerable: true, get: function () { return user_interface_1.EmailVerificationStatusResponse; } });
27
32
  Object.defineProperty(exports, "UserService", { enumerable: true, get: function () { return user_interface_1.UserServiceService; } });
33
+ // ============================
34
+ // Auth exports
35
+ // ============================
28
36
  var auth_interface_1 = require("./auth/auth.interface");
29
37
  Object.defineProperty(exports, "AuthProtobufPackage", { enumerable: true, get: function () { return auth_interface_1.protobufPackage; } });
30
38
  Object.defineProperty(exports, "LoginCredentials", { enumerable: true, get: function () { return auth_interface_1.LoginCredentials; } });
@@ -39,3 +47,11 @@ Object.defineProperty(exports, "ConfirmEmailRequest", { enumerable: true, get: f
39
47
  Object.defineProperty(exports, "ConfirmEmailResponse", { enumerable: true, get: function () { return auth_interface_1.ConfirmEmailResponse; } });
40
48
  Object.defineProperty(exports, "CheckEmailVerifiedRequest", { enumerable: true, get: function () { return auth_interface_1.CheckEmailVerifiedRequest; } });
41
49
  Object.defineProperty(exports, "CheckEmailVerifiedResponse", { enumerable: true, get: function () { return auth_interface_1.CheckEmailVerifiedResponse; } });
50
+ // ============================
51
+ // OpenAI exports
52
+ // ============================
53
+ var openai_interface_1 = require("./openai/openai.interface");
54
+ Object.defineProperty(exports, "OpenAIProtobufPackage", { enumerable: true, get: function () { return openai_interface_1.protobufPackage; } });
55
+ Object.defineProperty(exports, "OpenAICreateRequest", { enumerable: true, get: function () { return openai_interface_1.CreateRequest; } });
56
+ Object.defineProperty(exports, "OpenAICreateResponse", { enumerable: true, get: function () { return openai_interface_1.CreateResponse; } });
57
+ Object.defineProperty(exports, "OpenAIService", { enumerable: true, get: function () { return openai_interface_1.OpenAIServiceService; } });
@@ -0,0 +1,91 @@
1
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
+ export declare const protobufPackage = "google.protobuf";
3
+ /**
4
+ * `NullValue` is a singleton enumeration to represent the null value for the
5
+ * `Value` type union.
6
+ *
7
+ * The JSON representation for `NullValue` is JSON `null`.
8
+ */
9
+ export declare enum NullValue {
10
+ /** NULL_VALUE - Null value. */
11
+ NULL_VALUE = 0,
12
+ UNRECOGNIZED = -1
13
+ }
14
+ /**
15
+ * `Struct` represents a structured data value, consisting of fields
16
+ * which map to dynamically typed values. In some languages, `Struct`
17
+ * might be supported by a native representation. For example, in
18
+ * scripting languages like JS a struct is represented as an
19
+ * object. The details of that representation are described together
20
+ * with the proto support for the language.
21
+ *
22
+ * The JSON representation for `Struct` is JSON object.
23
+ */
24
+ export interface Struct {
25
+ /** Unordered map of dynamically typed values. */
26
+ fields: {
27
+ [key: string]: any | undefined;
28
+ };
29
+ }
30
+ export interface Struct_FieldsEntry {
31
+ key: string;
32
+ value?: any | undefined;
33
+ }
34
+ /**
35
+ * `Value` represents a dynamically typed value which can be either
36
+ * null, a number, a string, a boolean, a recursive struct value, or a
37
+ * list of values. A producer of value is expected to set one of these
38
+ * variants. Absence of any variant indicates an error.
39
+ *
40
+ * The JSON representation for `Value` is JSON value.
41
+ */
42
+ export interface Value {
43
+ /** Represents a null value. */
44
+ nullValue?: NullValue | undefined;
45
+ /** Represents a double value. */
46
+ numberValue?: number | undefined;
47
+ /** Represents a string value. */
48
+ stringValue?: string | undefined;
49
+ /** Represents a boolean value. */
50
+ boolValue?: boolean | undefined;
51
+ /** Represents a structured value. */
52
+ structValue?: {
53
+ [key: string]: any;
54
+ } | undefined;
55
+ /** Represents a repeated `Value`. */
56
+ listValue?: Array<any> | undefined;
57
+ }
58
+ /**
59
+ * `ListValue` is a wrapper around a repeated field of values.
60
+ *
61
+ * The JSON representation for `ListValue` is JSON array.
62
+ */
63
+ export interface ListValue {
64
+ /** Repeated field of dynamically typed values. */
65
+ values: any[];
66
+ }
67
+ export declare const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
68
+ export declare const Struct: MessageFns<Struct> & StructWrapperFns;
69
+ export declare const Struct_FieldsEntry: MessageFns<Struct_FieldsEntry>;
70
+ export declare const Value: MessageFns<Value> & AnyValueWrapperFns;
71
+ export declare const ListValue: MessageFns<ListValue> & ListValueWrapperFns;
72
+ export interface MessageFns<T> {
73
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
74
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
75
+ }
76
+ export interface StructWrapperFns {
77
+ wrap(object: {
78
+ [key: string]: any;
79
+ } | undefined): Struct;
80
+ unwrap(message: Struct): {
81
+ [key: string]: any;
82
+ };
83
+ }
84
+ export interface AnyValueWrapperFns {
85
+ wrap(value: any): Value;
86
+ unwrap(message: any): string | number | boolean | Object | null | Array<any> | undefined;
87
+ }
88
+ export interface ListValueWrapperFns {
89
+ wrap(array: Array<any> | undefined): ListValue;
90
+ unwrap(message: ListValue): Array<any>;
91
+ }
@@ -0,0 +1,300 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.7.7
5
+ // protoc v5.28.2
6
+ // source: google/protobuf/struct.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ListValue = exports.Value = exports.Struct_FieldsEntry = exports.Struct = exports.GOOGLE_PROTOBUF_PACKAGE_NAME = exports.NullValue = exports.protobufPackage = void 0;
9
+ /* eslint-disable */
10
+ const wire_1 = require("@bufbuild/protobuf/wire");
11
+ const protobufjs_1 = require("protobufjs");
12
+ exports.protobufPackage = "google.protobuf";
13
+ /**
14
+ * `NullValue` is a singleton enumeration to represent the null value for the
15
+ * `Value` type union.
16
+ *
17
+ * The JSON representation for `NullValue` is JSON `null`.
18
+ */
19
+ var NullValue;
20
+ (function (NullValue) {
21
+ /** NULL_VALUE - Null value. */
22
+ NullValue[NullValue["NULL_VALUE"] = 0] = "NULL_VALUE";
23
+ NullValue[NullValue["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
24
+ })(NullValue || (exports.NullValue = NullValue = {}));
25
+ exports.GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf";
26
+ function createBaseStruct() {
27
+ return { fields: {} };
28
+ }
29
+ exports.Struct = {
30
+ encode(message, writer = new wire_1.BinaryWriter()) {
31
+ Object.entries(message.fields).forEach(([key, value]) => {
32
+ if (value !== undefined) {
33
+ exports.Struct_FieldsEntry.encode({ key: key, value }, writer.uint32(10).fork()).join();
34
+ }
35
+ });
36
+ return writer;
37
+ },
38
+ decode(input, length) {
39
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
40
+ const end = length === undefined ? reader.len : reader.pos + length;
41
+ const message = createBaseStruct();
42
+ while (reader.pos < end) {
43
+ const tag = reader.uint32();
44
+ switch (tag >>> 3) {
45
+ case 1: {
46
+ if (tag !== 10) {
47
+ break;
48
+ }
49
+ const entry1 = exports.Struct_FieldsEntry.decode(reader, reader.uint32());
50
+ if (entry1.value !== undefined) {
51
+ message.fields[entry1.key] = entry1.value;
52
+ }
53
+ continue;
54
+ }
55
+ }
56
+ if ((tag & 7) === 4 || tag === 0) {
57
+ break;
58
+ }
59
+ reader.skip(tag & 7);
60
+ }
61
+ return message;
62
+ },
63
+ wrap(object) {
64
+ const struct = createBaseStruct();
65
+ if (object !== undefined) {
66
+ for (const key of Object.keys(object)) {
67
+ struct.fields[key] = exports.Value.wrap(object[key]);
68
+ }
69
+ }
70
+ return struct;
71
+ },
72
+ unwrap(message) {
73
+ const object = {};
74
+ if (message.fields) {
75
+ for (const key of Object.keys(message.fields)) {
76
+ object[key] = exports.Value.unwrap(message.fields[key]);
77
+ }
78
+ }
79
+ return object;
80
+ },
81
+ };
82
+ function createBaseStruct_FieldsEntry() {
83
+ return { key: "" };
84
+ }
85
+ exports.Struct_FieldsEntry = {
86
+ encode(message, writer = new wire_1.BinaryWriter()) {
87
+ if (message.key !== "") {
88
+ writer.uint32(10).string(message.key);
89
+ }
90
+ if (message.value !== undefined) {
91
+ exports.Value.encode(exports.Value.wrap(message.value), writer.uint32(18).fork()).join();
92
+ }
93
+ return writer;
94
+ },
95
+ decode(input, length) {
96
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
97
+ const end = length === undefined ? reader.len : reader.pos + length;
98
+ const message = createBaseStruct_FieldsEntry();
99
+ while (reader.pos < end) {
100
+ const tag = reader.uint32();
101
+ switch (tag >>> 3) {
102
+ case 1: {
103
+ if (tag !== 10) {
104
+ break;
105
+ }
106
+ message.key = reader.string();
107
+ continue;
108
+ }
109
+ case 2: {
110
+ if (tag !== 18) {
111
+ break;
112
+ }
113
+ message.value = exports.Value.unwrap(exports.Value.decode(reader, reader.uint32()));
114
+ continue;
115
+ }
116
+ }
117
+ if ((tag & 7) === 4 || tag === 0) {
118
+ break;
119
+ }
120
+ reader.skip(tag & 7);
121
+ }
122
+ return message;
123
+ },
124
+ };
125
+ function createBaseValue() {
126
+ return {};
127
+ }
128
+ exports.Value = {
129
+ encode(message, writer = new wire_1.BinaryWriter()) {
130
+ if (message.nullValue !== undefined) {
131
+ writer.uint32(8).int32(message.nullValue);
132
+ }
133
+ if (message.numberValue !== undefined) {
134
+ writer.uint32(17).double(message.numberValue);
135
+ }
136
+ if (message.stringValue !== undefined) {
137
+ writer.uint32(26).string(message.stringValue);
138
+ }
139
+ if (message.boolValue !== undefined) {
140
+ writer.uint32(32).bool(message.boolValue);
141
+ }
142
+ if (message.structValue !== undefined) {
143
+ exports.Struct.encode(exports.Struct.wrap(message.structValue), writer.uint32(42).fork()).join();
144
+ }
145
+ if (message.listValue !== undefined) {
146
+ exports.ListValue.encode(exports.ListValue.wrap(message.listValue), writer.uint32(50).fork()).join();
147
+ }
148
+ return writer;
149
+ },
150
+ decode(input, length) {
151
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
152
+ const end = length === undefined ? reader.len : reader.pos + length;
153
+ const message = createBaseValue();
154
+ while (reader.pos < end) {
155
+ const tag = reader.uint32();
156
+ switch (tag >>> 3) {
157
+ case 1: {
158
+ if (tag !== 8) {
159
+ break;
160
+ }
161
+ message.nullValue = reader.int32();
162
+ continue;
163
+ }
164
+ case 2: {
165
+ if (tag !== 17) {
166
+ break;
167
+ }
168
+ message.numberValue = reader.double();
169
+ continue;
170
+ }
171
+ case 3: {
172
+ if (tag !== 26) {
173
+ break;
174
+ }
175
+ message.stringValue = reader.string();
176
+ continue;
177
+ }
178
+ case 4: {
179
+ if (tag !== 32) {
180
+ break;
181
+ }
182
+ message.boolValue = reader.bool();
183
+ continue;
184
+ }
185
+ case 5: {
186
+ if (tag !== 42) {
187
+ break;
188
+ }
189
+ message.structValue = exports.Struct.unwrap(exports.Struct.decode(reader, reader.uint32()));
190
+ continue;
191
+ }
192
+ case 6: {
193
+ if (tag !== 50) {
194
+ break;
195
+ }
196
+ message.listValue = exports.ListValue.unwrap(exports.ListValue.decode(reader, reader.uint32()));
197
+ continue;
198
+ }
199
+ }
200
+ if ((tag & 7) === 4 || tag === 0) {
201
+ break;
202
+ }
203
+ reader.skip(tag & 7);
204
+ }
205
+ return message;
206
+ },
207
+ wrap(value) {
208
+ const result = {};
209
+ if (value === null) {
210
+ result.nullValue = NullValue.NULL_VALUE;
211
+ }
212
+ else if (typeof value === "boolean") {
213
+ result.boolValue = value;
214
+ }
215
+ else if (typeof value === "number") {
216
+ result.numberValue = value;
217
+ }
218
+ else if (typeof value === "string") {
219
+ result.stringValue = value;
220
+ }
221
+ else if (globalThis.Array.isArray(value)) {
222
+ result.listValue = exports.ListValue.wrap(value);
223
+ }
224
+ else if (typeof value === "object") {
225
+ result.structValue = exports.Struct.wrap(value);
226
+ }
227
+ else if (typeof value !== "undefined") {
228
+ throw new globalThis.Error("Unsupported any value type: " + typeof value);
229
+ }
230
+ return result;
231
+ },
232
+ unwrap(message) {
233
+ if (message?.hasOwnProperty("stringValue") && message.stringValue !== undefined) {
234
+ return message.stringValue;
235
+ }
236
+ else if (message?.hasOwnProperty("numberValue") && message?.numberValue !== undefined) {
237
+ return message.numberValue;
238
+ }
239
+ else if (message?.hasOwnProperty("boolValue") && message?.boolValue !== undefined) {
240
+ return message.boolValue;
241
+ }
242
+ else if (message?.hasOwnProperty("structValue") && message?.structValue !== undefined) {
243
+ return exports.Struct.unwrap(message.structValue);
244
+ }
245
+ else if (message?.hasOwnProperty("listValue") && message?.listValue !== undefined) {
246
+ return exports.ListValue.unwrap(message.listValue);
247
+ }
248
+ else if (message?.hasOwnProperty("nullValue") && message?.nullValue !== undefined) {
249
+ return null;
250
+ }
251
+ return undefined;
252
+ },
253
+ };
254
+ function createBaseListValue() {
255
+ return { values: [] };
256
+ }
257
+ exports.ListValue = {
258
+ encode(message, writer = new wire_1.BinaryWriter()) {
259
+ for (const v of message.values) {
260
+ exports.Value.encode(exports.Value.wrap(v), writer.uint32(10).fork()).join();
261
+ }
262
+ return writer;
263
+ },
264
+ decode(input, length) {
265
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
266
+ const end = length === undefined ? reader.len : reader.pos + length;
267
+ const message = createBaseListValue();
268
+ while (reader.pos < end) {
269
+ const tag = reader.uint32();
270
+ switch (tag >>> 3) {
271
+ case 1: {
272
+ if (tag !== 10) {
273
+ break;
274
+ }
275
+ message.values.push(exports.Value.unwrap(exports.Value.decode(reader, reader.uint32())));
276
+ continue;
277
+ }
278
+ }
279
+ if ((tag & 7) === 4 || tag === 0) {
280
+ break;
281
+ }
282
+ reader.skip(tag & 7);
283
+ }
284
+ return message;
285
+ },
286
+ wrap(array) {
287
+ const result = createBaseListValue();
288
+ result.values = (array ?? []).map(exports.Value.wrap);
289
+ return result;
290
+ },
291
+ unwrap(message) {
292
+ if (message?.hasOwnProperty("values") && globalThis.Array.isArray(message.values)) {
293
+ return message.values.map(exports.Value.unwrap);
294
+ }
295
+ else {
296
+ return message;
297
+ }
298
+ },
299
+ };
300
+ protobufjs_1.wrappers[".google.protobuf.Struct"] = { fromObject: exports.Struct.wrap, toObject: exports.Struct.unwrap };
@@ -0,0 +1,12 @@
1
+ import { OnModuleInit } from "@nestjs/common";
2
+ import { ClientGrpc } from "@nestjs/microservices";
3
+ import { OpenAIServiceClient } from "./openai.interface";
4
+ export declare class OpenAIClient implements OnModuleInit {
5
+ private readonly client;
6
+ private readonly logger;
7
+ private openAIClient?;
8
+ constructor(client: ClientGrpc);
9
+ onModuleInit(): void;
10
+ get service(): OpenAIServiceClient;
11
+ isReady(): boolean;
12
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var OpenAIClient_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.OpenAIClient = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ let OpenAIClient = OpenAIClient_1 = class OpenAIClient {
19
+ constructor(client) {
20
+ this.client = client;
21
+ this.logger = new common_1.Logger(OpenAIClient_1.name);
22
+ }
23
+ onModuleInit() {
24
+ this.openAIClient =
25
+ this.client.getService("OpenAIService");
26
+ this.logger.log("OpenAIServiceClient initialized");
27
+ }
28
+ get service() {
29
+ if (!this.openAIClient) {
30
+ throw new common_1.InternalServerErrorException("OpenAIService is not initialized yet");
31
+ }
32
+ return this.openAIClient;
33
+ }
34
+ isReady() {
35
+ return !!this.openAIClient;
36
+ }
37
+ };
38
+ exports.OpenAIClient = OpenAIClient;
39
+ exports.OpenAIClient = OpenAIClient = OpenAIClient_1 = __decorate([
40
+ (0, common_1.Injectable)(),
41
+ __param(0, (0, common_1.Inject)("OPENAI_PACKAGE")),
42
+ __metadata("design:paramtypes", [Object])
43
+ ], OpenAIClient);
@@ -0,0 +1,50 @@
1
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
+ import type { handleUnaryCall, Metadata, UntypedServiceImplementation } from "@grpc/grpc-js";
3
+ import { Observable } from "rxjs";
4
+ export declare const protobufPackage = "openai";
5
+ export interface CreateRequest {
6
+ /** Параметры для OpenAI (model, input, reasoning и т.п.) */
7
+ body?: {
8
+ [key: string]: any;
9
+ } | undefined;
10
+ /** Дополнительные опции (timeout, headers и т.п.) */
11
+ options?: {
12
+ [key: string]: any;
13
+ } | undefined;
14
+ }
15
+ export interface CreateResponse {
16
+ /** Сырой JSON-ответ от OpenAI */
17
+ data?: {
18
+ [key: string]: any;
19
+ } | undefined;
20
+ }
21
+ export declare const OPENAI_PACKAGE_NAME = "openai";
22
+ export declare const CreateRequest: MessageFns<CreateRequest>;
23
+ export declare const CreateResponse: MessageFns<CreateResponse>;
24
+ export interface OpenAIServiceClient {
25
+ create(request: CreateRequest, metadata?: Metadata): Observable<CreateResponse>;
26
+ }
27
+ export interface OpenAIServiceController {
28
+ create(request: CreateRequest, metadata?: Metadata): Promise<CreateResponse> | Observable<CreateResponse> | CreateResponse;
29
+ }
30
+ export declare function OpenAIServiceControllerMethods(): (constructor: Function) => void;
31
+ export declare const OPEN_AI_SERVICE_NAME = "OpenAIService";
32
+ export type OpenAIServiceService = typeof OpenAIServiceService;
33
+ export declare const OpenAIServiceService: {
34
+ readonly create: {
35
+ readonly path: "/openai.OpenAIService/create";
36
+ readonly requestStream: false;
37
+ readonly responseStream: false;
38
+ readonly requestSerialize: (value: CreateRequest) => Buffer;
39
+ readonly requestDeserialize: (value: Buffer) => CreateRequest;
40
+ readonly responseSerialize: (value: CreateResponse) => Buffer;
41
+ readonly responseDeserialize: (value: Buffer) => CreateResponse;
42
+ };
43
+ };
44
+ export interface OpenAIServiceServer extends UntypedServiceImplementation {
45
+ create: handleUnaryCall<CreateRequest, CreateResponse>;
46
+ }
47
+ export interface MessageFns<T> {
48
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
49
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
50
+ }
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
+ // versions:
4
+ // protoc-gen-ts_proto v2.7.7
5
+ // protoc v5.28.2
6
+ // source: openai.proto
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.OpenAIServiceService = exports.OPEN_AI_SERVICE_NAME = exports.CreateResponse = exports.CreateRequest = exports.OPENAI_PACKAGE_NAME = exports.protobufPackage = void 0;
9
+ exports.OpenAIServiceControllerMethods = OpenAIServiceControllerMethods;
10
+ /* eslint-disable */
11
+ const wire_1 = require("@bufbuild/protobuf/wire");
12
+ const microservices_1 = require("@nestjs/microservices");
13
+ const protobufjs_1 = require("protobufjs");
14
+ const struct_interface_1 = require("./google/protobuf/struct.interface");
15
+ exports.protobufPackage = "openai";
16
+ exports.OPENAI_PACKAGE_NAME = "openai";
17
+ function createBaseCreateRequest() {
18
+ return {};
19
+ }
20
+ exports.CreateRequest = {
21
+ encode(message, writer = new wire_1.BinaryWriter()) {
22
+ if (message.body !== undefined) {
23
+ struct_interface_1.Struct.encode(struct_interface_1.Struct.wrap(message.body), writer.uint32(10).fork()).join();
24
+ }
25
+ if (message.options !== undefined) {
26
+ struct_interface_1.Struct.encode(struct_interface_1.Struct.wrap(message.options), writer.uint32(18).fork()).join();
27
+ }
28
+ return writer;
29
+ },
30
+ decode(input, length) {
31
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
32
+ const end = length === undefined ? reader.len : reader.pos + length;
33
+ const message = createBaseCreateRequest();
34
+ while (reader.pos < end) {
35
+ const tag = reader.uint32();
36
+ switch (tag >>> 3) {
37
+ case 1: {
38
+ if (tag !== 10) {
39
+ break;
40
+ }
41
+ message.body = struct_interface_1.Struct.unwrap(struct_interface_1.Struct.decode(reader, reader.uint32()));
42
+ continue;
43
+ }
44
+ case 2: {
45
+ if (tag !== 18) {
46
+ break;
47
+ }
48
+ message.options = struct_interface_1.Struct.unwrap(struct_interface_1.Struct.decode(reader, reader.uint32()));
49
+ continue;
50
+ }
51
+ }
52
+ if ((tag & 7) === 4 || tag === 0) {
53
+ break;
54
+ }
55
+ reader.skip(tag & 7);
56
+ }
57
+ return message;
58
+ },
59
+ };
60
+ function createBaseCreateResponse() {
61
+ return {};
62
+ }
63
+ exports.CreateResponse = {
64
+ encode(message, writer = new wire_1.BinaryWriter()) {
65
+ if (message.data !== undefined) {
66
+ struct_interface_1.Struct.encode(struct_interface_1.Struct.wrap(message.data), writer.uint32(10).fork()).join();
67
+ }
68
+ return writer;
69
+ },
70
+ decode(input, length) {
71
+ const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
72
+ const end = length === undefined ? reader.len : reader.pos + length;
73
+ const message = createBaseCreateResponse();
74
+ while (reader.pos < end) {
75
+ const tag = reader.uint32();
76
+ switch (tag >>> 3) {
77
+ case 1: {
78
+ if (tag !== 10) {
79
+ break;
80
+ }
81
+ message.data = struct_interface_1.Struct.unwrap(struct_interface_1.Struct.decode(reader, reader.uint32()));
82
+ continue;
83
+ }
84
+ }
85
+ if ((tag & 7) === 4 || tag === 0) {
86
+ break;
87
+ }
88
+ reader.skip(tag & 7);
89
+ }
90
+ return message;
91
+ },
92
+ };
93
+ protobufjs_1.wrappers[".google.protobuf.Struct"] = { fromObject: struct_interface_1.Struct.wrap, toObject: struct_interface_1.Struct.unwrap };
94
+ function OpenAIServiceControllerMethods() {
95
+ return function (constructor) {
96
+ const grpcMethods = ["create"];
97
+ for (const method of grpcMethods) {
98
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
99
+ (0, microservices_1.GrpcMethod)("OpenAIService", method)(constructor.prototype[method], method, descriptor);
100
+ }
101
+ const grpcStreamMethods = [];
102
+ for (const method of grpcStreamMethods) {
103
+ const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
104
+ (0, microservices_1.GrpcStreamMethod)("OpenAIService", method)(constructor.prototype[method], method, descriptor);
105
+ }
106
+ };
107
+ }
108
+ exports.OPEN_AI_SERVICE_NAME = "OpenAIService";
109
+ exports.OpenAIServiceService = {
110
+ create: {
111
+ path: "/openai.OpenAIService/create",
112
+ requestStream: false,
113
+ responseStream: false,
114
+ requestSerialize: (value) => Buffer.from(exports.CreateRequest.encode(value).finish()),
115
+ requestDeserialize: (value) => exports.CreateRequest.decode(value),
116
+ responseSerialize: (value) => Buffer.from(exports.CreateResponse.encode(value).finish()),
117
+ responseDeserialize: (value) => exports.CreateResponse.decode(value),
118
+ },
119
+ };
@@ -8,6 +8,10 @@ export interface SharedModuleOptions {
8
8
  protoPath: string;
9
9
  url: string;
10
10
  };
11
+ openai?: {
12
+ protoPath: string;
13
+ url: string;
14
+ };
11
15
  }
12
16
  export declare class SharedModule {
13
17
  private static readonly logger;
@@ -13,10 +13,12 @@ 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");
16
17
  let SharedModule = SharedModule_1 = class SharedModule {
17
18
  static forRoot(options = {}) {
18
19
  const clients = [];
19
20
  const providers = [];
21
+ // USER
20
22
  if (options.user) {
21
23
  clients.push({
22
24
  name: "USER_PACKAGE",
@@ -32,7 +34,6 @@ let SharedModule = SharedModule_1 = class SharedModule {
32
34
  useFactory: (client) => {
33
35
  const svc = new user_client_1.UsersClient(client);
34
36
  try {
35
- // Проверяем готовность сервиса
36
37
  svc.onModuleInit();
37
38
  SharedModule_1.logger.log("UsersClient initialized successfully");
38
39
  }
@@ -45,11 +46,9 @@ let SharedModule = SharedModule_1 = class SharedModule {
45
46
  });
46
47
  }
47
48
  else {
48
- providers.push({
49
- provide: user_client_1.UsersClient,
50
- useValue: null,
51
- });
49
+ providers.push({ provide: user_client_1.UsersClient, useValue: null });
52
50
  }
51
+ // AUTH
53
52
  if (options.auth) {
54
53
  clients.push({
55
54
  name: "AUTH_PACKAGE",
@@ -77,11 +76,38 @@ let SharedModule = SharedModule_1 = class SharedModule {
77
76
  });
78
77
  }
79
78
  else {
79
+ providers.push({ provide: auth_client_1.AuthClient, useValue: null });
80
+ }
81
+ // OPENAI
82
+ if (options.openai) {
83
+ clients.push({
84
+ name: "OPENAI_PACKAGE",
85
+ transport: microservices_1.Transport.GRPC,
86
+ options: {
87
+ package: "openai",
88
+ protoPath: (0, path_1.resolve)(process.cwd(), options.openai.protoPath),
89
+ url: options.openai.url,
90
+ },
91
+ });
80
92
  providers.push({
81
- provide: auth_client_1.AuthClient,
82
- useValue: null,
93
+ provide: openai_client_1.OpenAIClient,
94
+ useFactory: (client) => {
95
+ const svc = new openai_client_1.OpenAIClient(client);
96
+ try {
97
+ svc.onModuleInit();
98
+ SharedModule_1.logger.log("OpenAIClient initialized successfully");
99
+ }
100
+ catch (err) {
101
+ SharedModule_1.logger.error("OpenAIClient initialization failed", err);
102
+ }
103
+ return svc;
104
+ },
105
+ inject: ["OPENAI_PACKAGE"],
83
106
  });
84
107
  }
108
+ else {
109
+ providers.push({ provide: openai_client_1.OpenAIClient, useValue: null });
110
+ }
85
111
  return {
86
112
  module: SharedModule_1,
87
113
  imports: clients.length ? [microservices_1.ClientsModule.register(clients)] : [],
@@ -61,9 +61,9 @@ export interface UpdateUserRequest {
61
61
  authentication?: UserAuthentication | undefined;
62
62
  }
63
63
  export interface UpdateUserPersonal {
64
- uuid: string;
64
+ uuid?: string | undefined;
65
65
  photoUrl?: string | undefined;
66
- firstName?: string | undefined;
66
+ firstName: string;
67
67
  lastName?: string | undefined;
68
68
  birthday?: string | undefined;
69
69
  gender?: string | undefined;
@@ -71,7 +71,7 @@ export interface UpdateUserPersonal {
71
71
  phoneNumber?: string | undefined;
72
72
  }
73
73
  export interface UpdatePasswordRequest {
74
- uuid: string;
74
+ uuid?: string | undefined;
75
75
  oldPassword: string;
76
76
  newPassword: string;
77
77
  }
@@ -607,17 +607,17 @@ exports.UpdateUserRequest = {
607
607
  },
608
608
  };
609
609
  function createBaseUpdateUserPersonal() {
610
- return { uuid: "" };
610
+ return { firstName: "" };
611
611
  }
612
612
  exports.UpdateUserPersonal = {
613
613
  encode(message, writer = new wire_1.BinaryWriter()) {
614
- if (message.uuid !== "") {
614
+ if (message.uuid !== undefined) {
615
615
  writer.uint32(10).string(message.uuid);
616
616
  }
617
617
  if (message.photoUrl !== undefined) {
618
618
  writer.uint32(18).string(message.photoUrl);
619
619
  }
620
- if (message.firstName !== undefined) {
620
+ if (message.firstName !== "") {
621
621
  writer.uint32(26).string(message.firstName);
622
622
  }
623
623
  if (message.lastName !== undefined) {
@@ -710,11 +710,11 @@ exports.UpdateUserPersonal = {
710
710
  },
711
711
  };
712
712
  function createBaseUpdatePasswordRequest() {
713
- return { uuid: "", oldPassword: "", newPassword: "" };
713
+ return { oldPassword: "", newPassword: "" };
714
714
  }
715
715
  exports.UpdatePasswordRequest = {
716
716
  encode(message, writer = new wire_1.BinaryWriter()) {
717
- if (message.uuid !== "") {
717
+ if (message.uuid !== undefined) {
718
718
  writer.uint32(10).string(message.uuid);
719
719
  }
720
720
  if (message.oldPassword !== "") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geniebox-shared-lib",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
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,9 @@
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": "npm run proto:gen:user && npm run proto:gen:auth",
14
+ "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",
15
+ "proto:gen": "npm run proto:gen:user && npm run proto:gen:auth && npm run proto:gen:openai",
16
+ "generate": "npm run proto:gen && npm run build",
15
17
  "prepublishOnly": "npm run build"
16
18
  },
17
19
  "author": "Viktor Kanishchev",