@plyaz/core 1.22.6 → 1.22.7

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.mjs CHANGED
@@ -28,7 +28,7 @@ import { StorageService as StorageService$1 } from '@plyaz/storage';
28
28
  import { NotificationService as NotificationService$1, verifyToken } from '@plyaz/notifications';
29
29
  import { createRequire } from 'module';
30
30
  import * as ServerErrorMiddleware from '@plyaz/errors/middleware/backend';
31
- import { Get, Param, Post, HttpCode, HttpStatus, Body, Patch, Delete, Controller, Inject, Module, Req, Res, Global, Query, Put, Injectable, Headers as Headers$1, SetMetadata } from '@nestjs/common';
31
+ import { Get, Param, Post, HttpCode, HttpStatus, Body, Patch, Delete, Controller, Inject, Module, Query, Res, Put, Global, Injectable, Headers as Headers$1, Req, SetMetadata } from '@nestjs/common';
32
32
  import { z } from 'zod';
33
33
  import { tap, of } from 'rxjs';
34
34
  import { catchError } from 'rxjs/operators';
@@ -21051,224 +21051,10 @@ new Proxy(
21051
21051
  }
21052
21052
  }
21053
21053
  );
21054
- var STREAM_SERVER = Symbol("STREAM_SERVER");
21055
- var StreamingController = class {
21056
- constructor(streamServer) {
21057
- this.streamServer = streamServer;
21058
- }
21059
- async stream(req, res) {
21060
- const handler = this.streamServer.getHandler("nestjs");
21061
- await handler(req, res);
21062
- }
21063
- };
21064
- __name(StreamingController, "StreamingController");
21065
- __decorateClass([
21066
- Get("stream"),
21067
- __decorateParam(0, Req()),
21068
- __decorateParam(1, Res())
21069
- ], StreamingController.prototype, "stream", 1);
21070
- StreamingController = __decorateClass([
21071
- Controller("events"),
21072
- __decorateParam(0, Inject(STREAM_SERVER))
21073
- ], StreamingController);
21074
-
21075
- // src/init/nestjs/CoreModule.ts
21076
- var CORE_OPTIONS = Symbol("CORE_OPTIONS");
21077
- var DB_SERVICE = Symbol("DB_SERVICE");
21078
- var CoreModule = class {
21079
- /**
21080
- * Register CoreModule with static configuration
21081
- */
21082
- static forRoot(options = {}) {
21083
- const streamingEnabled = options.streaming?.enabled === true;
21084
- const controllers = streamingEnabled ? [StreamingController] : [];
21085
- const moduleExports = [DB_SERVICE, CORE_OPTIONS];
21086
- const providers = [
21087
- {
21088
- provide: CORE_OPTIONS,
21089
- useValue: options
21090
- },
21091
- {
21092
- provide: DbService,
21093
- useFactory: /* @__PURE__ */ __name(async () => {
21094
- await Core.initialize(options);
21095
- return Core.db;
21096
- }, "useFactory")
21097
- },
21098
- {
21099
- provide: DB_SERVICE,
21100
- useFactory: /* @__PURE__ */ __name(async () => {
21101
- await Core.initialize(options);
21102
- return Core.db;
21103
- }, "useFactory")
21104
- }
21105
- ];
21106
- if (streamingEnabled) {
21107
- providers.push({
21108
- provide: STREAM_SERVER,
21109
- useFactory: /* @__PURE__ */ __name(async () => {
21110
- await Core.initialize(options);
21111
- return Core.streamServer;
21112
- }, "useFactory")
21113
- });
21114
- moduleExports.push(STREAM_SERVER);
21115
- }
21116
- return {
21117
- module: CoreModule,
21118
- global: true,
21119
- controllers,
21120
- providers,
21121
- exports: moduleExports
21122
- };
21123
- }
21124
- /**
21125
- * Register CoreModule with async configuration
21126
- */
21127
- static forRootAsync(options) {
21128
- const providers = [
21129
- {
21130
- provide: CORE_OPTIONS,
21131
- useFactory: options.useFactory,
21132
- inject: options.inject ?? []
21133
- },
21134
- {
21135
- provide: DbService,
21136
- useFactory: /* @__PURE__ */ __name(async (coreOptions) => {
21137
- await Core.initialize(coreOptions);
21138
- return Core.db;
21139
- }, "useFactory"),
21140
- inject: [CORE_OPTIONS]
21141
- },
21142
- {
21143
- provide: DB_SERVICE,
21144
- useFactory: /* @__PURE__ */ __name(async (coreOptions) => {
21145
- await Core.initialize(coreOptions);
21146
- return Core.db;
21147
- }, "useFactory"),
21148
- inject: [CORE_OPTIONS]
21149
- },
21150
- // Add streaming provider for async (will be null if not configured)
21151
- {
21152
- provide: STREAM_SERVER,
21153
- useFactory: /* @__PURE__ */ __name(async (coreOptions) => {
21154
- await Core.initialize(coreOptions);
21155
- return Core.streamServer;
21156
- }, "useFactory"),
21157
- inject: [CORE_OPTIONS]
21158
- }
21159
- ];
21160
- return {
21161
- module: CoreModule,
21162
- global: true,
21163
- imports: options.imports ?? [],
21164
- providers,
21165
- exports: [DB_SERVICE, CORE_OPTIONS, STREAM_SERVER]
21166
- };
21167
- }
21168
- };
21169
- __name(CoreModule, "CoreModule");
21170
- CoreModule = __decorateClass([
21171
- Global()
21172
- ], CoreModule);
21173
- (class _StreamingModule {
21174
- static {
21175
- __name(this, "StreamingModule");
21176
- }
21177
- static {
21178
- this.streamServer = null;
21179
- }
21180
- async onModuleDestroy() {
21181
- if (_StreamingModule.streamServer) {
21182
- _StreamingModule.streamServer.dispose();
21183
- _StreamingModule.streamServer = null;
21184
- }
21185
- StreamRegistry.dispose();
21186
- }
21187
- /**
21188
- * Register StreamingModule with static configuration
21189
- */
21190
- static forRoot(config = {}) {
21191
- const includeController = config.includeController !== false;
21192
- const providers = [
21193
- {
21194
- provide: STREAM_SERVER,
21195
- useFactory: /* @__PURE__ */ __name(async () => {
21196
- return _StreamingModule.initializeStreamServer(config);
21197
- }, "useFactory")
21198
- }
21199
- ];
21200
- return {
21201
- module: _StreamingModule,
21202
- global: config.isGlobal !== false,
21203
- controllers: includeController ? [StreamingController] : [],
21204
- providers,
21205
- exports: [STREAM_SERVER]
21206
- };
21207
- }
21208
- /**
21209
- * Register StreamingModule with async configuration
21210
- */
21211
- static forRootAsync(options) {
21212
- const includeController = options.includeController !== false;
21213
- const configProvider = {
21214
- provide: "STREAMING_MODULE_CONFIG",
21215
- useFactory: options.useFactory,
21216
- inject: options.inject ?? []
21217
- };
21218
- const streamServerProvider = {
21219
- provide: STREAM_SERVER,
21220
- useFactory: /* @__PURE__ */ __name(async (config) => {
21221
- return _StreamingModule.initializeStreamServer(config);
21222
- }, "useFactory"),
21223
- inject: ["STREAMING_MODULE_CONFIG"]
21224
- };
21225
- return {
21226
- module: _StreamingModule,
21227
- global: options.isGlobal !== false,
21228
- imports: options.imports ?? [],
21229
- controllers: includeController ? [StreamingController] : [],
21230
- providers: [configProvider, streamServerProvider],
21231
- exports: [STREAM_SERVER]
21232
- };
21233
- }
21234
- /**
21235
- * Initialize StreamServer with configuration
21236
- */
21237
- // eslint-disable-next-line complexity
21238
- static async initializeStreamServer(config) {
21239
- if (_StreamingModule.streamServer) {
21240
- _StreamingModule.streamServer.dispose();
21241
- }
21242
- const builder = StreamServer.create().withSSE({
21243
- heartbeatInterval: config.server?.broadcaster?.heartbeatInterval ?? STREAMING_DEFAULTS.HEARTBEAT_INTERVAL_MS
21244
- });
21245
- const defaultChannels = config.server?.defaultChannels ?? STREAMING_DEFAULTS.DEFAULT_CHANNELS;
21246
- builder.withDefaultChannels(defaultChannels);
21247
- const streamServer = builder.build();
21248
- streamServer.initialize();
21249
- _StreamingModule.streamServer = streamServer;
21250
- if (config.endpoints?.length) {
21251
- await StreamRegistry.initialize({
21252
- broadcaster: streamServer.getBroadcaster(),
21253
- endpoints: config.endpoints
21254
- });
21255
- }
21256
- return streamServer;
21257
- }
21258
- /**
21259
- * Get the current StreamServer instance (for testing/debugging)
21260
- */
21261
- static getStreamServer() {
21262
- return _StreamingModule.streamServer;
21263
- }
21264
- });
21265
-
21266
- // src/backend/notifications/notifications.controller.ts
21267
21054
  var BACKEND_NOTIFICATIONS_DOMAIN_SERVICE = "BACKEND_NOTIFICATIONS_DOMAIN_SERVICE";
21268
21055
  var NotificationsController = class {
21269
- constructor(notificationsService, coreOptions) {
21056
+ constructor(notificationsService) {
21270
21057
  this.notificationsService = notificationsService;
21271
- this.coreOptions = coreOptions;
21272
21058
  }
21273
21059
  health() {
21274
21060
  return SuccessResponseStandard("Service is healthy", {
@@ -21320,7 +21106,7 @@ var NotificationsController = class {
21320
21106
  context: { field: "token" }
21321
21107
  });
21322
21108
  }
21323
- const encryptionKey = this.coreOptions.env?.ENCRYPTION_KEY;
21109
+ const encryptionKey = Core.initOptions.env?.ENCRYPTION_KEY;
21324
21110
  if (!encryptionKey) {
21325
21111
  throw new CorePackageError(
21326
21112
  "Unsubscribe feature not configured",
@@ -21370,8 +21156,7 @@ __decorateClass([
21370
21156
  ], NotificationsController.prototype, "unsubscribe", 1);
21371
21157
  NotificationsController = __decorateClass([
21372
21158
  Controller("notifications"),
21373
- __decorateParam(0, Inject(BACKEND_NOTIFICATIONS_DOMAIN_SERVICE)),
21374
- __decorateParam(1, Inject(CORE_OPTIONS))
21159
+ __decorateParam(0, Inject(BACKEND_NOTIFICATIONS_DOMAIN_SERVICE))
21375
21160
  ], NotificationsController);
21376
21161
 
21377
21162
  // src/backend/notifications/notifications.module.ts