@ccci/micro-server 1.1.3 → 1.1.6

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.
Files changed (37) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +104100 -66614
  3. package/dist/types/RedisTypes.d.ts +48 -0
  4. package/package.json +8 -3
  5. package/dist/decorators/Endpoints.d.ts +0 -12
  6. package/dist/types/ApplicationOptionType.d.ts +0 -36
  7. package/dist/types/AttachmentMetadataTypes.d.ts +0 -23
  8. package/dist/types/BaseControllerTypes.d.ts +0 -42
  9. package/dist/types/BaseModelTypes.d.ts +0 -41
  10. package/dist/types/BaseRouterTypes.d.ts +0 -9
  11. package/dist/types/BaseSocketType.d.ts +0 -6
  12. package/dist/types/BrokerType.d.ts +0 -13
  13. package/dist/types/NotificationTypes.d.ts +0 -9
  14. package/dist/types/UploadedFileType.d.ts +0 -11
  15. package/dist/utils/ApplicationServer.d.ts +0 -30
  16. package/dist/utils/BaseAuthenticatorModel.d.ts +0 -7
  17. package/dist/utils/BaseConsumer.d.ts +0 -44
  18. package/dist/utils/BaseController.d.ts +0 -97
  19. package/dist/utils/BaseControllerHelper.d.ts +0 -27
  20. package/dist/utils/BaseKafka.d.ts +0 -37
  21. package/dist/utils/BaseModel.d.ts +0 -44
  22. package/dist/utils/BaseProducer.d.ts +0 -42
  23. package/dist/utils/BaseRouter.d.ts +0 -91
  24. package/dist/utils/BaseSocketHandler.d.ts +0 -37
  25. package/dist/utils/DatabaseConnector.d.ts +0 -26
  26. package/dist/utils/ErrorHandler.d.ts +0 -5
  27. package/dist/utils/IBaseModel.d.ts +0 -9
  28. package/dist/utils/Logger.d.ts +0 -8
  29. package/dist/utils/Mailer.d.ts +0 -23
  30. package/dist/utils/Mixins.d.ts +0 -39
  31. package/dist/utils/PushNotifier.d.ts +0 -19
  32. package/dist/utils/RouterFactory.d.ts +0 -12
  33. package/dist/utils/ServeKafka.d.ts +0 -16
  34. package/dist/utils/TokenGenerator.d.ts +0 -11
  35. package/dist/utils/Uploader.d.ts +0 -33
  36. package/dist/utils/WebSocketServer.d.ts +0 -29
  37. package/dist/utils/uploader-s3.d.ts +0 -68
@@ -0,0 +1,48 @@
1
+ import { RediSearchSchema } from "redis";
2
+ export interface QueryOptions {
3
+ page?: number;
4
+ limit?: number;
5
+ sort?: string;
6
+ withCount?: boolean;
7
+ paginate?: boolean;
8
+ search?: string;
9
+ }
10
+ export type RediSearchFieldValue = string | number | boolean | Date | null | undefined | Array<string | number | boolean>;
11
+ export interface RediSearchCreateOptions {
12
+ ON?: "HASH" | "JSON";
13
+ PREFIX?: string | string[];
14
+ FILTER?: string;
15
+ LANGUAGE?: string;
16
+ LANGUAGE_FIELD?: string;
17
+ SCORE?: number;
18
+ SCORE_FIELD?: string;
19
+ MAXTEXTFIELDS?: boolean;
20
+ TEMPORARY?: number;
21
+ NOOFFSETS?: boolean;
22
+ NOHL?: boolean;
23
+ NOFIELDS?: boolean;
24
+ NOFREQS?: boolean;
25
+ SKIPINITIALSCAN?: boolean;
26
+ STOPWORDS?: string[] | "OFF";
27
+ }
28
+ export interface RediSearchIndexConfig<T = unknown> {
29
+ indexKey: string;
30
+ schema: RediSearchSchema;
31
+ options?: RediSearchCreateOptions;
32
+ fields?: (item: T, score: number) => Record<string, RediSearchFieldValue>;
33
+ }
34
+ export interface RediSearchQueryConfig {
35
+ indexKey: string;
36
+ query?: string;
37
+ sortBy?: string;
38
+ returnFields?: string[];
39
+ dialect?: number;
40
+ }
41
+ export interface RedisResult<T> {
42
+ rows: T[];
43
+ count?: number;
44
+ page: number;
45
+ limit: number;
46
+ hasNextPage: boolean;
47
+ }
48
+ //# sourceMappingURL=RedisTypes.d.ts.map
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@ccci/micro-server",
3
- "version": "1.1.3",
3
+ "version": "1.1.6",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "description": "A collection of Commom Backend Utility Classes",
9
9
  "scripts": {
10
- "build": "bun build --target=node ./src/index.ts --outfile=dist/index.js && bun run build:declaration",
10
+ "build": "bun build --target=node ./src/index.ts --outfile=dist/index.js",
11
11
  "build:declaration": "tsc --emitDeclarationOnly --project tsconfig.types.json",
12
12
  "postbuild": "rimraf tsconfig.types.tsbuildinfo",
13
13
  "release": "bun run build && git add . && git commit -m 'release' && git push && npm version patch && npm publish"
@@ -23,7 +23,10 @@
23
23
  "@types/nodemailer": "^6.4.15",
24
24
  "prettier": "^3.0.3",
25
25
  "rimraf": "^5.0.5",
26
- "typescript": "^5.2.2"
26
+ "typescript": "^5.2.2",
27
+ "vite": "^5.0.10",
28
+ "vite-tsconfig-paths": "^6.1.0",
29
+ "vitest": "^1.1.0"
27
30
  },
28
31
  "peerDependencies": {
29
32
  "typescript": "^5.0.0"
@@ -45,6 +48,7 @@
45
48
  "express": "^4.19.2",
46
49
  "express-fileupload": "^1.5.0",
47
50
  "express-list-endpoints": "^7.1.1",
51
+ "fast-xml-parser": "^5.3.4",
48
52
  "firebase": "^10.13.1",
49
53
  "firebase-admin": "^12.4.0",
50
54
  "handlebars": "^4.7.8",
@@ -55,6 +59,7 @@
55
59
  "nodemailer": "^6.9.13",
56
60
  "pg": "^8.11.5",
57
61
  "pg-hstore": "^2.3.4",
62
+ "redis": "^5.11.0",
58
63
  "sequelize": "^6.37.3",
59
64
  "socket.io": "^4.7.5",
60
65
  "winston": "^3.13.0"
@@ -1,12 +0,0 @@
1
- export declare const endpoint: (target: any, methodName: string, descriptor: PropertyDescriptor) => void;
2
- export declare const PublicAccess: <T extends new (...args: any[]) => {}>(constructor: T) => {
3
- new (...args: any[]): {
4
- grantPublicAccess: boolean;
5
- };
6
- } & T;
7
- export declare const PrivateAccess: <T extends new (...args: any[]) => {}>(constructor: T) => {
8
- new (...args: any[]): {
9
- grantPublicAccess: boolean;
10
- };
11
- } & T;
12
- //# sourceMappingURL=Endpoints.d.ts.map
@@ -1,36 +0,0 @@
1
- export type ApplicationOptionType = {
2
- routeContext?: string;
3
- configDir?: string;
4
- modelDir?: string;
5
- controllerDir?: string;
6
- routeDir?: string;
7
- websocketPort?: number;
8
- websocketDir?: string;
9
- enableRedis?: boolean;
10
- enableMinio?: boolean;
11
- enableKafka?: boolean;
12
- enableS3?: boolean;
13
- enableWebSocket?: boolean;
14
- enableFirebase?: boolean;
15
- enableEmail?: boolean;
16
- clientId?: string;
17
- brokers?: string[];
18
- consumersPath?: string;
19
- producersPath?: string;
20
- minioHost?: string;
21
- minioPort?: number;
22
- minioAccessKey?: string;
23
- minioSecretKey?: string;
24
- minioUseSSL?: boolean;
25
- smtpService?: string;
26
- smtpHost?: string;
27
- smtpUser?: string;
28
- smtpPassword?: string;
29
- enablePushNotifications?: boolean;
30
- s3ForcePathStyle?: boolean;
31
- s3Endpoint?: string;
32
- s3region?: string;
33
- s3AccessKeyId?: string;
34
- s3SecretAccessKey?: string;
35
- };
36
- //# sourceMappingURL=ApplicationOptionType.d.ts.map
@@ -1,23 +0,0 @@
1
- export type AttachmentMetadataType = {
2
- Bucket?: string;
3
- Etag?: string;
4
- Key?: string;
5
- Location?: string;
6
- MimeType?: string;
7
- Thumbnail?: string;
8
- isHls?: boolean;
9
- };
10
- export type DeleteObjectRequest = {
11
- Bucket: string;
12
- Key: string;
13
- MFA?: string;
14
- VersionId?: string;
15
- RequestPayer?: 'requester';
16
- BypassGovernanceRetention?: boolean;
17
- ExpectedBucketOwner?: string;
18
- IfMatch?: string;
19
- IfMatchLastModifiedTime?: Date;
20
- IfMatchSize?: number;
21
- };
22
- export declare const mimeTypes: Record<string, string>;
23
- //# sourceMappingURL=AttachmentMetadataTypes.d.ts.map
@@ -1,42 +0,0 @@
1
- import { Order, WhereOptions } from "sequelize";
2
- export type RequestQuery = {
3
- search?: string;
4
- limit?: number;
5
- page?: number;
6
- includes?: string;
7
- fields?: string;
8
- paranoid?: string;
9
- sort?: string;
10
- paginate?: string;
11
- date_range?: string;
12
- others?: any;
13
- scan?: string;
14
- groupBy?: string;
15
- };
16
- export type QueryOptions = {
17
- where?: WhereOptions<any>;
18
- limit?: number;
19
- offset?: number;
20
- attributes?: Array<string>;
21
- order?: Order;
22
- paranoid?: boolean;
23
- includes?: Array<string | IncludeType>;
24
- };
25
- export type ResponseType = {
26
- success: boolean;
27
- error?: number;
28
- statusCode?: number;
29
- errorMessage?: string;
30
- errorDescription?: string;
31
- response?: object;
32
- version?: string;
33
- errors?: string[];
34
- };
35
- export type IncludeType = {
36
- association?: string;
37
- include?: Array<IncludeType>;
38
- };
39
- export type CommonType = {
40
- [x: string | symbol]: any;
41
- };
42
- //# sourceMappingURL=BaseControllerTypes.d.ts.map
@@ -1,41 +0,0 @@
1
- export declare enum FindTypeEnum {
2
- FIND_ALL = "findAndCountAll",
3
- FIND_PK = "findByPk",
4
- FIND_ONE = "findOne",
5
- COUNT = "count"
6
- }
7
- export type IncludesType = {
8
- path?: string;
9
- association?: AssociationType;
10
- };
11
- export type AssociationType = {
12
- include: Array<string> | Array<object>;
13
- association?: string;
14
- where?: object;
15
- };
16
- export type QueryType = {
17
- where?: object;
18
- limit?: number;
19
- offset?: number;
20
- select?: object;
21
- order?: object;
22
- attributes?: object;
23
- returning?: boolean;
24
- raw?: boolean;
25
- nest?: boolean;
26
- distinct?: string;
27
- include?: object;
28
- };
29
- export type RequestUserType = {
30
- id?: number;
31
- email?: string;
32
- clientSecret?: string;
33
- };
34
- export type ModelOptions = {
35
- tableName: string;
36
- schema?: string;
37
- paranoid?: boolean;
38
- defaultAttributes?: boolean;
39
- comment?: string;
40
- };
41
- //# sourceMappingURL=BaseModelTypes.d.ts.map
@@ -1,9 +0,0 @@
1
- import { Request, Response, NextFunction } from 'express';
2
- import { ResponseType } from './BaseControllerTypes';
3
- export type Mappings = {
4
- path: string;
5
- method: string;
6
- function: (req: Request, res: Response, next: NextFunction) => Promise<void | ResponseType>;
7
- middleware?: (req: Request, res: Response, next: NextFunction) => Promise<void>;
8
- };
9
- //# sourceMappingURL=BaseRouterTypes.d.ts.map
@@ -1,6 +0,0 @@
1
- export type WebSocketData = {
2
- userId?: number;
3
- channel?: string;
4
- room?: string;
5
- };
6
- //# sourceMappingURL=BaseSocketType.d.ts.map
@@ -1,13 +0,0 @@
1
- export type PublishType = {
2
- topic: string;
3
- headers?: Record<string, string>;
4
- event: string;
5
- message: Record<string, any>;
6
- };
7
- export type MessageType = {
8
- headers?: Record<string, string>;
9
- event: string;
10
- data: any;
11
- };
12
- export type MessageHandler = (message: MessageType) => Promise<void>;
13
- //# sourceMappingURL=BrokerType.d.ts.map
@@ -1,9 +0,0 @@
1
- export type NotificationType = {
2
- title: string;
3
- body: string;
4
- imageUrl?: string;
5
- };
6
- export type NotificationOptions = {
7
- isBroadcast?: Boolean;
8
- };
9
- //# sourceMappingURL=NotificationTypes.d.ts.map
@@ -1,11 +0,0 @@
1
- export type UploadedFileType = {
2
- etag?: string;
3
- path?: string;
4
- bucket?: string;
5
- directory?: string;
6
- objectName?: string;
7
- mimeType?: string;
8
- location?: string;
9
- filesize?: number;
10
- };
11
- //# sourceMappingURL=UploadedFileType.d.ts.map
@@ -1,30 +0,0 @@
1
- import { Application } from 'express';
2
- import Mailer from './Mailer';
3
- import BaseSocketHandler from './BaseSocketHandler';
4
- import { ApplicationOptionType } from '@/types/ApplicationOptionType';
5
- /**
6
- * Application Sever class
7
- */
8
- export default class ApplicationServer {
9
- static app: Application;
10
- static mailer: Mailer;
11
- static socketHandlers: Array<{
12
- path: string;
13
- handler: BaseSocketHandler;
14
- }>;
15
- /**
16
- * Initializes the application server
17
- * @param {number} port port for the micro service
18
- * @param {ApplicationOptionType} options additional server configuration
19
- * @param {Array<String>} sync models to be sync to the database
20
- *
21
- */
22
- static bootstrap(port: number, options?: ApplicationOptionType, sync?: Array<string> | Boolean): Promise<void>;
23
- static getInstance(): Application;
24
- static getWebsocketHandlers(): Array<{
25
- path: string;
26
- handler: any;
27
- }>;
28
- static getMailer(): Mailer;
29
- }
30
- //# sourceMappingURL=ApplicationServer.d.ts.map
@@ -1,7 +0,0 @@
1
- import BaseModel from "./BaseModel";
2
- export default class BaseAuthenticatorModel extends BaseModel {
3
- password?: string;
4
- authenticate(password: string): boolean;
5
- updatePassword(password?: string): string | undefined;
6
- }
7
- //# sourceMappingURL=BaseAuthenticatorModel.d.ts.map
@@ -1,44 +0,0 @@
1
- import { ConsumerRunConfig, type Consumer, type ConsumerConfig } from "kafkajs";
2
- import { BaseKafka } from "./BaseKafka";
3
- import type { MessageHandler } from "../types/BrokerType";
4
- /**
5
- * BaseConsumer class provides basic functionality for consuming messages from a Kafka topic.
6
- * It manages the connection, subscription, and message handling logic for Kafka consumers.
7
- */
8
- export declare class BaseConsumer {
9
- consumer: Consumer | null;
10
- private kafka;
11
- /**
12
- * Creates an instance of BaseConsumer using a BaseKafka instance.
13
- *
14
- * @param {BaseKafka} baseKafka - The instance of the BaseKafka class which provides access to the Kafka client.
15
- */
16
- constructor(baseKafka: BaseKafka);
17
- /**
18
- * Connects the consumer to the Kafka cluster with the specified group ID and optional consumer configuration.
19
- * If the consumer is already connected, it logs a message and does nothing.
20
- *
21
- * @param {string} groupId - The consumer group ID to join.
22
- * @param {ConsumerConfig} [config] - Optional additional configuration for the consumer.
23
- * @returns {Promise<void>} - A promise that resolves once the consumer is connected.
24
- */
25
- connect(groupId: string, config?: ConsumerConfig): Promise<void>;
26
- /**
27
- * Disconnects the consumer from the Kafka cluster.
28
- * If the consumer is already disconnected, it logs a message and does nothing.
29
- *
30
- * @returns {Promise<void>} - A promise that resolves once the consumer is disconnected.
31
- */
32
- disconnect(): Promise<void>;
33
- /**
34
- * Subscribes the consumer to a Kafka topic and starts processing messages from the topic.
35
- * The consumer runs the provided message handler for each received message.
36
- *
37
- * @param {string} topic - The Kafka topic to subscribe to.
38
- * @param {MessageHandler} messageHandler - A function to handle the processed messages.
39
- * @returns {Promise<void>} - A promise that resolves once the consumer has successfully subscribed and started processing messages.
40
- * @throws {Error} - Throws an error if the consumer is not connected before subscribing.
41
- */
42
- subscribe(topic: string, messageHandler: MessageHandler, consumerRunConfig?: ConsumerRunConfig): Promise<void>;
43
- }
44
- //# sourceMappingURL=BaseConsumer.d.ts.map
@@ -1,97 +0,0 @@
1
- import { Request, Response, NextFunction } from 'express';
2
- import { ResponseType } from '../types/BaseControllerTypes';
3
- export default class BaseController {
4
- protected _model: import("sequelize").ModelCtor<import("sequelize").Model<any, any>> | undefined;
5
- _modelName: string | undefined;
6
- protected broadcastOnCreate: boolean;
7
- protected broadcastOnUpdate: boolean;
8
- protected broadcastOnDelete: boolean;
9
- constructor(model?: string);
10
- /**
11
- * Find all the rows matching your query, within a specified offset / limit,
12
- * and get the total number of rows matching your query.
13
- * -- added distinct:true
14
- * ```js
15
- * Controller.find(req, res, next)
16
- * ```
17
- * @param req
18
- * @param res
19
- * @param next
20
- */
21
- find(req: Request, res: Response, next?: NextFunction): Promise<ResponseType>;
22
- /**
23
- * Search for a single instance by its primary key.
24
- * This applies LIMIT 1, so the listener will always be called with a single instance.
25
- * @param req
26
- * @param res
27
- * @param next
28
- */
29
- findById(req: Request, res: Response, next?: NextFunction): Promise<ResponseType>;
30
- /**
31
- *
32
- * @param req
33
- * @param res
34
- * @param next
35
- */
36
- create(req: Request, res: Response, next?: NextFunction): Promise<ResponseType>;
37
- /**
38
- * Update multiple instances that match the where options. The promise returns an array with one or two elements. The first element is always the number of affected rows, while the second element is the actual affected rows (only supported in postgres and mssql with options.returning true.)
39
- * @param req
40
- * @param res
41
- * @param next
42
- */
43
- update(req: Request, res: Response, next?: NextFunction): Promise<ResponseType>;
44
- /**
45
- * Delete multiple instances, or set their deletedAt timestamp to the current time if paranoid is enabled.
46
- * @param req
47
- * @param res
48
- * @param next
49
- */
50
- delete(req: Request, res: Response, next?: NextFunction): Promise<ResponseType>;
51
- /**
52
- * Find all the rows matching your query, within a specified offset / limit,
53
- * and get the total number of rows matching your query.
54
- * ```js
55
- * Controller.find(req, res, next)
56
- * ```
57
- * @param req
58
- * @param res
59
- * @param next
60
- */
61
- archives(req: Request, res: Response, next?: NextFunction): Promise<ResponseType>;
62
- restore(req: Request, res: Response, next?: NextFunction): Promise<ResponseType>;
63
- /**
64
- * count total number of records
65
- * @param req
66
- * @param res
67
- * @param next
68
- * @returns
69
- */
70
- count(req: Request, res: Response, next?: NextFunction): Promise<{
71
- count: number;
72
- }>;
73
- /**
74
- * Return a basic statistics based on the query and group provided.
75
- * ```js
76
- * Controller.find(req, res, next)
77
- * ```
78
- * @param req
79
- * @param res
80
- * @param next
81
- */
82
- stats(req: Request, res: Response, next?: NextFunction): Promise<any>;
83
- /**
84
- * ###############################################################
85
- * ###################### LIFE CYCLE HOOKS #######################
86
- * ###############################################################
87
- */
88
- beforeCreate(req: Request): Promise<void>;
89
- afterCreate(req: Request, rec: any): Promise<void>;
90
- beforeUpdate(req: Request): Promise<void>;
91
- afterUpdate(req: Request, rec: any, orig: any): Promise<void>;
92
- beforeDelete(req: Request): Promise<void>;
93
- afterDelete(req: Request, rec: any): Promise<void>;
94
- beforeFind(req: Request): Promise<void>;
95
- afterFind(req: Request): Promise<void>;
96
- }
97
- //# sourceMappingURL=BaseController.d.ts.map
@@ -1,27 +0,0 @@
1
- import { BaseError, UniqueConstraintError } from "sequelize";
2
- import { RequestQuery, QueryOptions, ResponseType } from "../types/BaseControllerTypes";
3
- /**
4
- * Constructs a Sequelize query object based on the provided request query.
5
- * This function dynamically builds the `where` clause, allows for sorting,
6
- * pagination, field selection, and includes related models.
7
- *
8
- * @param {RequestQuery} query - The incoming request query parameters.
9
- * @returns {QueryOptions} - Returns a Sequelize query options object to be used for querying the database.
10
- */
11
- export declare function ConstructQuery(query: RequestQuery): QueryOptions;
12
- /**
13
- * A helper function to structure a successful response.
14
- *
15
- * @param {any} response - Data to include in the response.
16
- * @returns {ResponseType} - An object with success status and response data.
17
- */
18
- export declare function ResponseHelper(response?: any): ResponseType;
19
- /**
20
- * Handles errors and constructs an error response based on the type of error (Sequelize, database, or validation).
21
- *
22
- * @param {UniqueConstraintError | BaseError | Error | any} error - The error encountered during execution.
23
- * @returns {ResponseType} - Returns a structured error response with error codes and messages.
24
- */
25
- export declare function ErrorResponseHandler(error: UniqueConstraintError | BaseError | Error | any): ResponseType;
26
- export { ResponseType };
27
- //# sourceMappingURL=BaseControllerHelper.d.ts.map
@@ -1,37 +0,0 @@
1
- import { Kafka, type KafkaConfig } from "kafkajs";
2
- /**
3
- * BaseKafka class provides basic functionality for interacting with a Kafka cluster.
4
- * It allows creating Kafka topics and fetching the Kafka instance for producing/consuming messages.
5
- */
6
- export declare class BaseKafka {
7
- private kafka;
8
- private consumerPath;
9
- private producerPath;
10
- /**
11
- * Creates an instance of BaseKafka with the provided Kafka configuration.
12
- *
13
- * @param {KafkaConfig} config - Kafka configuration object containing client settings.
14
- */
15
- constructor(config: KafkaConfig);
16
- /**
17
- * Returns the Kafka instance to be used for producing and consuming messages.
18
- *
19
- * @returns {Kafka} - Kafka instance.
20
- */
21
- getKafka(): Kafka;
22
- /**
23
- * Creates Kafka topics if they don't already exist.
24
- *
25
- * This method checks if the specified topics exist, and if not, it creates them with the given
26
- * number of partitions and replication factor.
27
- *
28
- * @param {Array<{ topic: string; partitions: number; replicationFactor: number }>} topics - List of topics to be created with their partitions and replication factor.
29
- * @returns {Promise<void>} - A promise that resolves once the topics are created (or skipped if they already exist).
30
- */
31
- createTopics(topics: {
32
- topic: string;
33
- partitions: number;
34
- replicationFactor: number;
35
- }[]): Promise<void>;
36
- }
37
- //# sourceMappingURL=BaseKafka.d.ts.map
@@ -1,44 +0,0 @@
1
- import { DataTypes, Model } from 'sequelize';
2
- import type { ModelAttributes } from "sequelize";
3
- import type IBaseModel from './IBaseModel';
4
- import { ModelOptions } from '@/types/BaseModelTypes';
5
- export default class BaseModel extends Model implements IBaseModel {
6
- id?: number;
7
- /**
8
- * Sets common model attributes
9
- * @returns
10
- */
11
- static getCommonAttributes(defaultAttributes: boolean): {
12
- createdById: {
13
- type: DataTypes.IntegerDataType;
14
- comment: string;
15
- };
16
- updatedById: {
17
- type: DataTypes.IntegerDataType;
18
- comment: string;
19
- };
20
- isActive: {
21
- type: DataTypes.AbstractDataType;
22
- comment: string;
23
- allowNull: boolean;
24
- defaultValue: boolean;
25
- };
26
- } | null;
27
- static getCommonAssociations(): void;
28
- /**
29
- *
30
- * @param {ModelAttributes} fields table columns
31
- * @param {string} tableName name of the table
32
- * @param {string} schema this will overwrite the default schema
33
- * @param {boolean} paranoid paranoid option. defaults to true
34
- * @param {boolean} defaultAttributes need to inherit default attributes. defaults to true
35
- */
36
- static initialize(fields: ModelAttributes, tableName: string, schema?: string, paranoid?: boolean, defaultAttributes?: boolean, comment?: string): void;
37
- /**
38
- *
39
- * @param {ModelAttributes} fields table columns
40
- * @param {string} options Model Options
41
- */
42
- static initialize(fields: ModelAttributes, options: ModelOptions): void;
43
- }
44
- //# sourceMappingURL=BaseModel.d.ts.map
@@ -1,42 +0,0 @@
1
- import { type ProducerConfig } from "kafkajs";
2
- import { BaseKafka } from "./BaseKafka";
3
- import type { PublishType } from "../types/BrokerType";
4
- /**
5
- * BaseProducer class provides basic functionality for producing messages to a Kafka topic.
6
- * It manages the connection, disconnection, and message publishing logic for Kafka producers.
7
- */
8
- export declare class BaseProducer {
9
- private producer;
10
- private kafka;
11
- /**
12
- * Creates an instance of BaseProducer using a BaseKafka instance.
13
- *
14
- * @param {BaseKafka} baseKafka - The instance of the BaseKafka class which provides access to the Kafka client.
15
- */
16
- constructor(baseKafka: BaseKafka);
17
- /**
18
- * Connects the producer to the Kafka cluster with the specified optional configuration.
19
- * If the producer is already connected, it logs a message and does nothing.
20
- *
21
- * @param {ProducerConfig} [config] - Optional additional configuration for the producer.
22
- * @returns {Promise<void>} - A promise that resolves once the producer is connected.
23
- */
24
- connect(config?: ProducerConfig): Promise<void>;
25
- /**
26
- * Disconnects the producer from the Kafka cluster.
27
- * If the producer is already disconnected, it logs a message and does nothing.
28
- *
29
- * @returns {Promise<void>} - A promise that resolves once the producer is disconnected.
30
- */
31
- disconnect(): Promise<void>;
32
- /**
33
- * Publishes a message to a Kafka topic.
34
- * If the producer is not connected, it throws an error.
35
- *
36
- * @param {PublishType} data - The data to publish, including the topic, event, headers, and message content.
37
- * @returns {Promise<boolean>} - A promise that resolves to true if the message was successfully sent, false otherwise.
38
- * @throws {Error} - Throws an error if the producer is not connected.
39
- */
40
- publish(data: PublishType): Promise<boolean>;
41
- }
42
- //# sourceMappingURL=BaseProducer.d.ts.map