@mody-park-cha-raja/finance_common 4.38.1-beta.0 → 4.38.1-beta.2

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.mts CHANGED
@@ -1311,6 +1311,74 @@ interface IVendorUpdateDto extends IEntityUpdateDto<EntityType<EntityList.VENDOR
1311
1311
  interface IVendorSearchDto extends IEntityFilterData<EntityType<EntityList.VENDOR>> {
1312
1312
  }
1313
1313
 
1314
+ type RealtimeEntityType = EntityList.DONATION | EntityList.EXPENSE | EntityList.SPONSOR | EntityList.TRANSACTION;
1315
+ declare enum RealtimeEventAction {
1316
+ CREATED = "created",
1317
+ UPDATED = "updated",
1318
+ DELETED = "deleted",
1319
+ REFRESH = "refresh"
1320
+ }
1321
+ type RealtimeEventByType = {
1322
+ [K in RealtimeEntityType]: {
1323
+ type: K;
1324
+ action: RealtimeEventAction.CREATED | RealtimeEventAction.UPDATED;
1325
+ organizationId: number;
1326
+ data: EntityType<K>;
1327
+ };
1328
+ };
1329
+ type RealtimeEventDeleted = {
1330
+ [K in RealtimeEntityType]: {
1331
+ type: K;
1332
+ action: RealtimeEventAction.DELETED;
1333
+ organizationId: number;
1334
+ data: {
1335
+ id: number;
1336
+ };
1337
+ };
1338
+ };
1339
+ type RealtimeEventRefresh = {
1340
+ [K in RealtimeEntityType]: {
1341
+ type: K;
1342
+ action: RealtimeEventAction.REFRESH;
1343
+ organizationId: number;
1344
+ };
1345
+ };
1346
+ type RealtimeEvent = RealtimeEventByType[RealtimeEntityType] | RealtimeEventDeleted[RealtimeEntityType] | RealtimeEventRefresh[RealtimeEntityType];
1347
+ type StorePatchCallbacks = {
1348
+ [K in RealtimeEntityType]: {
1349
+ upsert: (entity: EntityType<K>) => void;
1350
+ remove: (id: number) => void;
1351
+ };
1352
+ };
1353
+
1354
+ interface RealtimeSocketOptions {
1355
+ url: string;
1356
+ token: string;
1357
+ onConnect?: () => void;
1358
+ onDisconnect?: (reason: string) => void;
1359
+ onError?: (error: Error) => void;
1360
+ }
1361
+ type SocketInstance = {
1362
+ on: (event: string, cb: (...args: any[]) => void) => void;
1363
+ off: (event: string, cb: (...args: any[]) => void) => void;
1364
+ emit: (event: string, ...args: any[]) => void;
1365
+ disconnect: () => void;
1366
+ connected: boolean;
1367
+ };
1368
+ type SocketFactory = (url: string, opts: any) => SocketInstance;
1369
+ declare function registerSocketFactory(f: SocketFactory): void;
1370
+ declare function connectSocket(options: RealtimeSocketOptions): SocketInstance;
1371
+ declare function disconnectSocket(): void;
1372
+ declare function getSocket(): SocketInstance | null;
1373
+
1374
+ type VersionMap = Map<string, number>;
1375
+ type RealtimeSync = {
1376
+ bind: () => void;
1377
+ unbind: () => void;
1378
+ versions: VersionMap;
1379
+ };
1380
+ declare function createRealtimeSync(callbacks: StorePatchCallbacks): RealtimeSync;
1381
+
1314
1382
  declare const FLAT_WING_PATTERN: RegExp;
1315
1383
  declare const SHOP_WING = "SH";
1316
1384
  declare const SPECIAL_FLAT_LABELS: readonly ["Devotee", "Ex-Member Devotee", "Others"];
@@ -1325,4 +1393,4 @@ declare function isSpecialFlatLabel(label: string): boolean;
1325
1393
  declare function getFlatValidationErrors(input: Partial<IFlatEntity>): FlatValidationError[];
1326
1394
  declare function validateFlatOrThrow(input: Partial<IFlatEntity>): void;
1327
1395
 
1328
- export { ALL_WINGS_SELECTION, AartiModel, BadRequestException, BaseEntityModel, ConfigurationKey, ConfigurationModel, ConfigurationType, DateCodeUtils, DateUtil, DonationHistoryModel, DonationModel, EntityFilterDataHelper, EntityHistoryOperation, EntityList, type EntityListEntityModelMap, type EntityModelType, EntityStatus, type EntityType, ExpenseHeadHistoryModel, ExpenseHeadModel, ExpenseHistoryModel, ExpenseModel, FLATS_BY_WING, FLAT_DONATION_RELATION_CONFIG, FLAT_NUMBERS, FLAT_UNIT_NUMBER_PATTERN, FLAT_WING_PATTERN, type FlatCollectionEntry, type FlatCollectionStatus, type FlatDonationLike, FlatHistoryModel, type FlatIdDonationLike, FlatModel, type FlatOption, type FlatParseResult, type FlatValidationError, ForbiddenException, HttpException, type IAartiCreateDto, type IAartiEntity, type IAartiSearchDto, type IAartiUpdateDto, type IAuditColumnEntity, type IBaseHistoryEntity, type ICashBookEntry, type IConfigurationCreateDto, type IConfigurationEntity, type IConfigurationSearchDto, type IConfigurationUpdateDto, type IDonationCreateDto, type IDonationEntity, type IDonationHistoryEntity, type IDonationSearchDto, type IDonationUpdateDto, type IDtoValidationError, type IEntityCreateDto, type IEntityFilterData, type IEntityFilterSearchData, type IEntityFilterSearchDataV2, type IEntityUpdateDto, type IExpenseCreateDto, type IExpenseEntity, type IExpenseHeadCreateDto, type IExpenseHeadEntity, type IExpenseHeadHistoryEntity, type IExpenseHeadSearchDto, type IExpenseHeadUpdateDto, type IExpenseHistoryEntity, type IExpenseSearchDto, type IExpenseUpdateDto, type IFlatCreateDto, type IFlatEntity, type IFlatHistoryEntity, type IFlatSearchDto, type IFlatUpdateDto, type IMappingPropertyEntry, type IModelRelationConfig, type IOrganizationCreateDto, type IOrganizationEntity, type IOrganizationUpdateDto, type ISearchV2Response, type ISponsorCreateDto, type ISponsorEntity, type ISponsorHistoryEntity, type ISponsorSearchDto, type ISponsorUpdateDto, type ITransactionCreateDto, type ITransactionEntity, type ITransactionHistoryEntity, type ITransactionSearchDto, type ITransactionUpdateDto, type IUserCreateDto, type IUserEntity, type IUserHistoryEntity, type IUserSearchDto, type IUserUpdateDto, type IVendorBillCreateDto, type IVendorBillEntity, type IVendorBillHistoryEntity, type IVendorBillSearchDto, type IVendorBillUpdateDto, type IVendorCreateDto, type IVendorEntity, type IVendorHistoryEntity, type IVendorSearchDto, type IVendorUpdateDto, NotFoundException, type Nullable, OrderByDirection, OrganizationModel, PAYMENT_OPTIONS, PaymentType, ReferenceIdPrefix, RelationType, SHOP_UNIT_NUMBER_PATTERN, SHOP_WING, SPECIAL_FLATS, SPECIAL_FLAT_LABELS, SponsorHistoryModel, SponsorModel, SponsorTier, TransactionEntityType, TransactionHistoryModel, TransactionModel, TransactionType, USER_RELATION_CONFIG, UnauthorizedException, type UserExpenseReport, type UserExpenseReportTotals, type UserExpenseRow, UserHistoryModel, UserModel, VendorBillHistoryModel, VendorBillModel, VendorBillStatus, VendorHistoryModel, VendorModel, VendorType, WINGS, WING_ALPHABETS, type WingCollectionDonationByIdLike, type WingCollectionDonationLike, type WingCollectionReport, type WingCollectionRow, type WingCollectionTotals, type XlsxCellAddress, type XlsxMergeRange, type XlsxSerializationType, type XlsxSheetInput, type XlsxSheetOptions, buildUserExpenseReport, buildUserExpenseWorkbook, buildWingWiseCollectionReport, buildWingWiseCollectionReportByFlatId, buildWingWiseCollectionWorkbook, buildXlsxWorkbook, convertNumberToWords, definedValues, diffArrays, entityListEntityModelMap, epochToReadableDate, getFlatValidationErrors, getObjectDiffingKeys, getWingSelectionLabel, getWingSelectionSlug, groupBy, isSpecialFlatLabel, isValidFlatWing, roundToTwoDecimals, serializeXlsx, validateFlatOrThrow };
1396
+ export { ALL_WINGS_SELECTION, AartiModel, BadRequestException, BaseEntityModel, ConfigurationKey, ConfigurationModel, ConfigurationType, DateCodeUtils, DateUtil, DonationHistoryModel, DonationModel, EntityFilterDataHelper, EntityHistoryOperation, EntityList, type EntityListEntityModelMap, type EntityModelType, EntityStatus, type EntityType, ExpenseHeadHistoryModel, ExpenseHeadModel, ExpenseHistoryModel, ExpenseModel, FLATS_BY_WING, FLAT_DONATION_RELATION_CONFIG, FLAT_NUMBERS, FLAT_UNIT_NUMBER_PATTERN, FLAT_WING_PATTERN, type FlatCollectionEntry, type FlatCollectionStatus, type FlatDonationLike, FlatHistoryModel, type FlatIdDonationLike, FlatModel, type FlatOption, type FlatParseResult, type FlatValidationError, ForbiddenException, HttpException, type IAartiCreateDto, type IAartiEntity, type IAartiSearchDto, type IAartiUpdateDto, type IAuditColumnEntity, type IBaseHistoryEntity, type ICashBookEntry, type IConfigurationCreateDto, type IConfigurationEntity, type IConfigurationSearchDto, type IConfigurationUpdateDto, type IDonationCreateDto, type IDonationEntity, type IDonationHistoryEntity, type IDonationSearchDto, type IDonationUpdateDto, type IDtoValidationError, type IEntityCreateDto, type IEntityFilterData, type IEntityFilterSearchData, type IEntityFilterSearchDataV2, type IEntityUpdateDto, type IExpenseCreateDto, type IExpenseEntity, type IExpenseHeadCreateDto, type IExpenseHeadEntity, type IExpenseHeadHistoryEntity, type IExpenseHeadSearchDto, type IExpenseHeadUpdateDto, type IExpenseHistoryEntity, type IExpenseSearchDto, type IExpenseUpdateDto, type IFlatCreateDto, type IFlatEntity, type IFlatHistoryEntity, type IFlatSearchDto, type IFlatUpdateDto, type IMappingPropertyEntry, type IModelRelationConfig, type IOrganizationCreateDto, type IOrganizationEntity, type IOrganizationUpdateDto, type ISearchV2Response, type ISponsorCreateDto, type ISponsorEntity, type ISponsorHistoryEntity, type ISponsorSearchDto, type ISponsorUpdateDto, type ITransactionCreateDto, type ITransactionEntity, type ITransactionHistoryEntity, type ITransactionSearchDto, type ITransactionUpdateDto, type IUserCreateDto, type IUserEntity, type IUserHistoryEntity, type IUserSearchDto, type IUserUpdateDto, type IVendorBillCreateDto, type IVendorBillEntity, type IVendorBillHistoryEntity, type IVendorBillSearchDto, type IVendorBillUpdateDto, type IVendorCreateDto, type IVendorEntity, type IVendorHistoryEntity, type IVendorSearchDto, type IVendorUpdateDto, NotFoundException, type Nullable, OrderByDirection, OrganizationModel, PAYMENT_OPTIONS, PaymentType, type RealtimeEntityType, type RealtimeEvent, RealtimeEventAction, type RealtimeSocketOptions, type RealtimeSync, ReferenceIdPrefix, RelationType, SHOP_UNIT_NUMBER_PATTERN, SHOP_WING, SPECIAL_FLATS, SPECIAL_FLAT_LABELS, type SocketFactory, type SocketInstance, SponsorHistoryModel, SponsorModel, SponsorTier, type StorePatchCallbacks, TransactionEntityType, TransactionHistoryModel, TransactionModel, TransactionType, USER_RELATION_CONFIG, UnauthorizedException, type UserExpenseReport, type UserExpenseReportTotals, type UserExpenseRow, UserHistoryModel, UserModel, VendorBillHistoryModel, VendorBillModel, VendorBillStatus, VendorHistoryModel, VendorModel, VendorType, type VersionMap, WINGS, WING_ALPHABETS, type WingCollectionDonationByIdLike, type WingCollectionDonationLike, type WingCollectionReport, type WingCollectionRow, type WingCollectionTotals, type XlsxCellAddress, type XlsxMergeRange, type XlsxSerializationType, type XlsxSheetInput, type XlsxSheetOptions, buildUserExpenseReport, buildUserExpenseWorkbook, buildWingWiseCollectionReport, buildWingWiseCollectionReportByFlatId, buildWingWiseCollectionWorkbook, buildXlsxWorkbook, connectSocket, convertNumberToWords, createRealtimeSync, definedValues, diffArrays, disconnectSocket, entityListEntityModelMap, epochToReadableDate, getFlatValidationErrors, getObjectDiffingKeys, getSocket, getWingSelectionLabel, getWingSelectionSlug, groupBy, isSpecialFlatLabel, isValidFlatWing, registerSocketFactory, roundToTwoDecimals, serializeXlsx, validateFlatOrThrow };
package/dist/index.d.ts CHANGED
@@ -1311,6 +1311,74 @@ interface IVendorUpdateDto extends IEntityUpdateDto<EntityType<EntityList.VENDOR
1311
1311
  interface IVendorSearchDto extends IEntityFilterData<EntityType<EntityList.VENDOR>> {
1312
1312
  }
1313
1313
 
1314
+ type RealtimeEntityType = EntityList.DONATION | EntityList.EXPENSE | EntityList.SPONSOR | EntityList.TRANSACTION;
1315
+ declare enum RealtimeEventAction {
1316
+ CREATED = "created",
1317
+ UPDATED = "updated",
1318
+ DELETED = "deleted",
1319
+ REFRESH = "refresh"
1320
+ }
1321
+ type RealtimeEventByType = {
1322
+ [K in RealtimeEntityType]: {
1323
+ type: K;
1324
+ action: RealtimeEventAction.CREATED | RealtimeEventAction.UPDATED;
1325
+ organizationId: number;
1326
+ data: EntityType<K>;
1327
+ };
1328
+ };
1329
+ type RealtimeEventDeleted = {
1330
+ [K in RealtimeEntityType]: {
1331
+ type: K;
1332
+ action: RealtimeEventAction.DELETED;
1333
+ organizationId: number;
1334
+ data: {
1335
+ id: number;
1336
+ };
1337
+ };
1338
+ };
1339
+ type RealtimeEventRefresh = {
1340
+ [K in RealtimeEntityType]: {
1341
+ type: K;
1342
+ action: RealtimeEventAction.REFRESH;
1343
+ organizationId: number;
1344
+ };
1345
+ };
1346
+ type RealtimeEvent = RealtimeEventByType[RealtimeEntityType] | RealtimeEventDeleted[RealtimeEntityType] | RealtimeEventRefresh[RealtimeEntityType];
1347
+ type StorePatchCallbacks = {
1348
+ [K in RealtimeEntityType]: {
1349
+ upsert: (entity: EntityType<K>) => void;
1350
+ remove: (id: number) => void;
1351
+ };
1352
+ };
1353
+
1354
+ interface RealtimeSocketOptions {
1355
+ url: string;
1356
+ token: string;
1357
+ onConnect?: () => void;
1358
+ onDisconnect?: (reason: string) => void;
1359
+ onError?: (error: Error) => void;
1360
+ }
1361
+ type SocketInstance = {
1362
+ on: (event: string, cb: (...args: any[]) => void) => void;
1363
+ off: (event: string, cb: (...args: any[]) => void) => void;
1364
+ emit: (event: string, ...args: any[]) => void;
1365
+ disconnect: () => void;
1366
+ connected: boolean;
1367
+ };
1368
+ type SocketFactory = (url: string, opts: any) => SocketInstance;
1369
+ declare function registerSocketFactory(f: SocketFactory): void;
1370
+ declare function connectSocket(options: RealtimeSocketOptions): SocketInstance;
1371
+ declare function disconnectSocket(): void;
1372
+ declare function getSocket(): SocketInstance | null;
1373
+
1374
+ type VersionMap = Map<string, number>;
1375
+ type RealtimeSync = {
1376
+ bind: () => void;
1377
+ unbind: () => void;
1378
+ versions: VersionMap;
1379
+ };
1380
+ declare function createRealtimeSync(callbacks: StorePatchCallbacks): RealtimeSync;
1381
+
1314
1382
  declare const FLAT_WING_PATTERN: RegExp;
1315
1383
  declare const SHOP_WING = "SH";
1316
1384
  declare const SPECIAL_FLAT_LABELS: readonly ["Devotee", "Ex-Member Devotee", "Others"];
@@ -1325,4 +1393,4 @@ declare function isSpecialFlatLabel(label: string): boolean;
1325
1393
  declare function getFlatValidationErrors(input: Partial<IFlatEntity>): FlatValidationError[];
1326
1394
  declare function validateFlatOrThrow(input: Partial<IFlatEntity>): void;
1327
1395
 
1328
- export { ALL_WINGS_SELECTION, AartiModel, BadRequestException, BaseEntityModel, ConfigurationKey, ConfigurationModel, ConfigurationType, DateCodeUtils, DateUtil, DonationHistoryModel, DonationModel, EntityFilterDataHelper, EntityHistoryOperation, EntityList, type EntityListEntityModelMap, type EntityModelType, EntityStatus, type EntityType, ExpenseHeadHistoryModel, ExpenseHeadModel, ExpenseHistoryModel, ExpenseModel, FLATS_BY_WING, FLAT_DONATION_RELATION_CONFIG, FLAT_NUMBERS, FLAT_UNIT_NUMBER_PATTERN, FLAT_WING_PATTERN, type FlatCollectionEntry, type FlatCollectionStatus, type FlatDonationLike, FlatHistoryModel, type FlatIdDonationLike, FlatModel, type FlatOption, type FlatParseResult, type FlatValidationError, ForbiddenException, HttpException, type IAartiCreateDto, type IAartiEntity, type IAartiSearchDto, type IAartiUpdateDto, type IAuditColumnEntity, type IBaseHistoryEntity, type ICashBookEntry, type IConfigurationCreateDto, type IConfigurationEntity, type IConfigurationSearchDto, type IConfigurationUpdateDto, type IDonationCreateDto, type IDonationEntity, type IDonationHistoryEntity, type IDonationSearchDto, type IDonationUpdateDto, type IDtoValidationError, type IEntityCreateDto, type IEntityFilterData, type IEntityFilterSearchData, type IEntityFilterSearchDataV2, type IEntityUpdateDto, type IExpenseCreateDto, type IExpenseEntity, type IExpenseHeadCreateDto, type IExpenseHeadEntity, type IExpenseHeadHistoryEntity, type IExpenseHeadSearchDto, type IExpenseHeadUpdateDto, type IExpenseHistoryEntity, type IExpenseSearchDto, type IExpenseUpdateDto, type IFlatCreateDto, type IFlatEntity, type IFlatHistoryEntity, type IFlatSearchDto, type IFlatUpdateDto, type IMappingPropertyEntry, type IModelRelationConfig, type IOrganizationCreateDto, type IOrganizationEntity, type IOrganizationUpdateDto, type ISearchV2Response, type ISponsorCreateDto, type ISponsorEntity, type ISponsorHistoryEntity, type ISponsorSearchDto, type ISponsorUpdateDto, type ITransactionCreateDto, type ITransactionEntity, type ITransactionHistoryEntity, type ITransactionSearchDto, type ITransactionUpdateDto, type IUserCreateDto, type IUserEntity, type IUserHistoryEntity, type IUserSearchDto, type IUserUpdateDto, type IVendorBillCreateDto, type IVendorBillEntity, type IVendorBillHistoryEntity, type IVendorBillSearchDto, type IVendorBillUpdateDto, type IVendorCreateDto, type IVendorEntity, type IVendorHistoryEntity, type IVendorSearchDto, type IVendorUpdateDto, NotFoundException, type Nullable, OrderByDirection, OrganizationModel, PAYMENT_OPTIONS, PaymentType, ReferenceIdPrefix, RelationType, SHOP_UNIT_NUMBER_PATTERN, SHOP_WING, SPECIAL_FLATS, SPECIAL_FLAT_LABELS, SponsorHistoryModel, SponsorModel, SponsorTier, TransactionEntityType, TransactionHistoryModel, TransactionModel, TransactionType, USER_RELATION_CONFIG, UnauthorizedException, type UserExpenseReport, type UserExpenseReportTotals, type UserExpenseRow, UserHistoryModel, UserModel, VendorBillHistoryModel, VendorBillModel, VendorBillStatus, VendorHistoryModel, VendorModel, VendorType, WINGS, WING_ALPHABETS, type WingCollectionDonationByIdLike, type WingCollectionDonationLike, type WingCollectionReport, type WingCollectionRow, type WingCollectionTotals, type XlsxCellAddress, type XlsxMergeRange, type XlsxSerializationType, type XlsxSheetInput, type XlsxSheetOptions, buildUserExpenseReport, buildUserExpenseWorkbook, buildWingWiseCollectionReport, buildWingWiseCollectionReportByFlatId, buildWingWiseCollectionWorkbook, buildXlsxWorkbook, convertNumberToWords, definedValues, diffArrays, entityListEntityModelMap, epochToReadableDate, getFlatValidationErrors, getObjectDiffingKeys, getWingSelectionLabel, getWingSelectionSlug, groupBy, isSpecialFlatLabel, isValidFlatWing, roundToTwoDecimals, serializeXlsx, validateFlatOrThrow };
1396
+ export { ALL_WINGS_SELECTION, AartiModel, BadRequestException, BaseEntityModel, ConfigurationKey, ConfigurationModel, ConfigurationType, DateCodeUtils, DateUtil, DonationHistoryModel, DonationModel, EntityFilterDataHelper, EntityHistoryOperation, EntityList, type EntityListEntityModelMap, type EntityModelType, EntityStatus, type EntityType, ExpenseHeadHistoryModel, ExpenseHeadModel, ExpenseHistoryModel, ExpenseModel, FLATS_BY_WING, FLAT_DONATION_RELATION_CONFIG, FLAT_NUMBERS, FLAT_UNIT_NUMBER_PATTERN, FLAT_WING_PATTERN, type FlatCollectionEntry, type FlatCollectionStatus, type FlatDonationLike, FlatHistoryModel, type FlatIdDonationLike, FlatModel, type FlatOption, type FlatParseResult, type FlatValidationError, ForbiddenException, HttpException, type IAartiCreateDto, type IAartiEntity, type IAartiSearchDto, type IAartiUpdateDto, type IAuditColumnEntity, type IBaseHistoryEntity, type ICashBookEntry, type IConfigurationCreateDto, type IConfigurationEntity, type IConfigurationSearchDto, type IConfigurationUpdateDto, type IDonationCreateDto, type IDonationEntity, type IDonationHistoryEntity, type IDonationSearchDto, type IDonationUpdateDto, type IDtoValidationError, type IEntityCreateDto, type IEntityFilterData, type IEntityFilterSearchData, type IEntityFilterSearchDataV2, type IEntityUpdateDto, type IExpenseCreateDto, type IExpenseEntity, type IExpenseHeadCreateDto, type IExpenseHeadEntity, type IExpenseHeadHistoryEntity, type IExpenseHeadSearchDto, type IExpenseHeadUpdateDto, type IExpenseHistoryEntity, type IExpenseSearchDto, type IExpenseUpdateDto, type IFlatCreateDto, type IFlatEntity, type IFlatHistoryEntity, type IFlatSearchDto, type IFlatUpdateDto, type IMappingPropertyEntry, type IModelRelationConfig, type IOrganizationCreateDto, type IOrganizationEntity, type IOrganizationUpdateDto, type ISearchV2Response, type ISponsorCreateDto, type ISponsorEntity, type ISponsorHistoryEntity, type ISponsorSearchDto, type ISponsorUpdateDto, type ITransactionCreateDto, type ITransactionEntity, type ITransactionHistoryEntity, type ITransactionSearchDto, type ITransactionUpdateDto, type IUserCreateDto, type IUserEntity, type IUserHistoryEntity, type IUserSearchDto, type IUserUpdateDto, type IVendorBillCreateDto, type IVendorBillEntity, type IVendorBillHistoryEntity, type IVendorBillSearchDto, type IVendorBillUpdateDto, type IVendorCreateDto, type IVendorEntity, type IVendorHistoryEntity, type IVendorSearchDto, type IVendorUpdateDto, NotFoundException, type Nullable, OrderByDirection, OrganizationModel, PAYMENT_OPTIONS, PaymentType, type RealtimeEntityType, type RealtimeEvent, RealtimeEventAction, type RealtimeSocketOptions, type RealtimeSync, ReferenceIdPrefix, RelationType, SHOP_UNIT_NUMBER_PATTERN, SHOP_WING, SPECIAL_FLATS, SPECIAL_FLAT_LABELS, type SocketFactory, type SocketInstance, SponsorHistoryModel, SponsorModel, SponsorTier, type StorePatchCallbacks, TransactionEntityType, TransactionHistoryModel, TransactionModel, TransactionType, USER_RELATION_CONFIG, UnauthorizedException, type UserExpenseReport, type UserExpenseReportTotals, type UserExpenseRow, UserHistoryModel, UserModel, VendorBillHistoryModel, VendorBillModel, VendorBillStatus, VendorHistoryModel, VendorModel, VendorType, type VersionMap, WINGS, WING_ALPHABETS, type WingCollectionDonationByIdLike, type WingCollectionDonationLike, type WingCollectionReport, type WingCollectionRow, type WingCollectionTotals, type XlsxCellAddress, type XlsxMergeRange, type XlsxSerializationType, type XlsxSheetInput, type XlsxSheetOptions, buildUserExpenseReport, buildUserExpenseWorkbook, buildWingWiseCollectionReport, buildWingWiseCollectionReportByFlatId, buildWingWiseCollectionWorkbook, buildXlsxWorkbook, connectSocket, convertNumberToWords, createRealtimeSync, definedValues, diffArrays, disconnectSocket, entityListEntityModelMap, epochToReadableDate, getFlatValidationErrors, getObjectDiffingKeys, getSocket, getWingSelectionLabel, getWingSelectionSlug, groupBy, isSpecialFlatLabel, isValidFlatWing, registerSocketFactory, roundToTwoDecimals, serializeXlsx, validateFlatOrThrow };
package/dist/index.js CHANGED
@@ -63,6 +63,7 @@ __export(index_exports, {
63
63
  OrganizationModel: () => OrganizationModel,
64
64
  PAYMENT_OPTIONS: () => PAYMENT_OPTIONS,
65
65
  PaymentType: () => PaymentType,
66
+ RealtimeEventAction: () => RealtimeEventAction,
66
67
  ReferenceIdPrefix: () => ReferenceIdPrefix,
67
68
  RelationType: () => RelationType,
68
69
  SHOP_UNIT_NUMBER_PATTERN: () => SHOP_UNIT_NUMBER_PATTERN,
@@ -94,18 +95,23 @@ __export(index_exports, {
94
95
  buildWingWiseCollectionReportByFlatId: () => buildWingWiseCollectionReportByFlatId,
95
96
  buildWingWiseCollectionWorkbook: () => buildWingWiseCollectionWorkbook,
96
97
  buildXlsxWorkbook: () => buildXlsxWorkbook,
98
+ connectSocket: () => connectSocket,
97
99
  convertNumberToWords: () => convertNumberToWords,
100
+ createRealtimeSync: () => createRealtimeSync,
98
101
  definedValues: () => definedValues,
99
102
  diffArrays: () => diffArrays,
103
+ disconnectSocket: () => disconnectSocket,
100
104
  entityListEntityModelMap: () => entityListEntityModelMap,
101
105
  epochToReadableDate: () => epochToReadableDate,
102
106
  getFlatValidationErrors: () => getFlatValidationErrors,
103
107
  getObjectDiffingKeys: () => getObjectDiffingKeys,
108
+ getSocket: () => getSocket,
104
109
  getWingSelectionLabel: () => getWingSelectionLabel,
105
110
  getWingSelectionSlug: () => getWingSelectionSlug,
106
111
  groupBy: () => groupBy,
107
112
  isSpecialFlatLabel: () => isSpecialFlatLabel,
108
113
  isValidFlatWing: () => isValidFlatWing,
114
+ registerSocketFactory: () => registerSocketFactory,
109
115
  roundToTwoDecimals: () => roundToTwoDecimals,
110
116
  serializeXlsx: () => serializeXlsx,
111
117
  validateFlatOrThrow: () => validateFlatOrThrow
@@ -2417,6 +2423,110 @@ var USER_RELATION_CONFIG = {
2417
2423
  columnKeys: ["id", "name"]
2418
2424
  };
2419
2425
 
2426
+ // src/realtime/realtime.types.ts
2427
+ var RealtimeEventAction = /* @__PURE__ */ ((RealtimeEventAction2) => {
2428
+ RealtimeEventAction2["CREATED"] = "created";
2429
+ RealtimeEventAction2["UPDATED"] = "updated";
2430
+ RealtimeEventAction2["DELETED"] = "deleted";
2431
+ RealtimeEventAction2["REFRESH"] = "refresh";
2432
+ return RealtimeEventAction2;
2433
+ })(RealtimeEventAction || {});
2434
+
2435
+ // src/realtime/realtime.socket.ts
2436
+ var socket = null;
2437
+ var factory = null;
2438
+ function registerSocketFactory(f) {
2439
+ factory = f;
2440
+ }
2441
+ function connectSocket(options) {
2442
+ if (socket?.connected) return socket;
2443
+ if (!factory)
2444
+ throw new Error(
2445
+ "Socket factory not registered. Call registerSocketFactory() first."
2446
+ );
2447
+ socket = factory(options.url, {
2448
+ auth: { token: options.token },
2449
+ reconnection: true,
2450
+ reconnectionAttempts: Infinity,
2451
+ reconnectionDelay: 1e3,
2452
+ reconnectionDelayMax: 5e3,
2453
+ timeout: 1e4
2454
+ });
2455
+ if (options.onConnect) socket.on("connect", options.onConnect);
2456
+ if (options.onDisconnect) socket.on("disconnect", options.onDisconnect);
2457
+ if (options.onError) socket.on("connect_error", options.onError);
2458
+ return socket;
2459
+ }
2460
+ function disconnectSocket() {
2461
+ if (socket) {
2462
+ socket.disconnect();
2463
+ socket = null;
2464
+ }
2465
+ }
2466
+ function getSocket() {
2467
+ return socket;
2468
+ }
2469
+
2470
+ // src/realtime/realtime.sync.ts
2471
+ var EVENT_NAME = "realtime-event";
2472
+ function createRealtimeSync(callbacks) {
2473
+ const versions = /* @__PURE__ */ new Map();
2474
+ let bound = false;
2475
+ function keyFor(type, id) {
2476
+ return `${type}:${id}`;
2477
+ }
2478
+ function applyUpsert(type, entity) {
2479
+ const entityId = entity.id;
2480
+ const entityVersion = entity.updatedOn;
2481
+ const key = keyFor(type, entityId);
2482
+ const currentVersion = versions.get(key);
2483
+ if (currentVersion !== void 0 && currentVersion >= entityVersion) {
2484
+ return;
2485
+ }
2486
+ versions.set(key, entityVersion);
2487
+ callbacks[type].upsert(entity);
2488
+ }
2489
+ function handleEvent(event) {
2490
+ if (event.action === "refresh" /* REFRESH */) {
2491
+ return;
2492
+ }
2493
+ if (event.action === "deleted" /* DELETED */) {
2494
+ callbacks[event.type].remove(event.data.id);
2495
+ versions.delete(keyFor(event.type, event.data.id));
2496
+ return;
2497
+ }
2498
+ switch (event.type) {
2499
+ case "donation" /* DONATION */:
2500
+ applyUpsert(event.type, event.data);
2501
+ break;
2502
+ case "expense" /* EXPENSE */:
2503
+ applyUpsert(event.type, event.data);
2504
+ break;
2505
+ case "sponsor" /* SPONSOR */:
2506
+ applyUpsert(event.type, event.data);
2507
+ break;
2508
+ case "transaction" /* TRANSACTION */:
2509
+ applyUpsert(event.type, event.data);
2510
+ break;
2511
+ }
2512
+ }
2513
+ function bind() {
2514
+ if (bound) return;
2515
+ const socket2 = getSocket();
2516
+ if (!socket2) return;
2517
+ socket2.on(EVENT_NAME, handleEvent);
2518
+ bound = true;
2519
+ }
2520
+ function unbind() {
2521
+ if (!bound) return;
2522
+ const socket2 = getSocket();
2523
+ if (!socket2) return;
2524
+ socket2.off(EVENT_NAME, handleEvent);
2525
+ bound = false;
2526
+ }
2527
+ return { bind, unbind, versions };
2528
+ }
2529
+
2420
2530
  // src/validators/flat.validator.ts
2421
2531
  var FLAT_WING_PATTERN = /^[A-Z]$/;
2422
2532
  var SHOP_WING = "SH";
@@ -2524,6 +2634,7 @@ function validateFlatOrThrow(input) {
2524
2634
  OrganizationModel,
2525
2635
  PAYMENT_OPTIONS,
2526
2636
  PaymentType,
2637
+ RealtimeEventAction,
2527
2638
  ReferenceIdPrefix,
2528
2639
  RelationType,
2529
2640
  SHOP_UNIT_NUMBER_PATTERN,
@@ -2555,18 +2666,23 @@ function validateFlatOrThrow(input) {
2555
2666
  buildWingWiseCollectionReportByFlatId,
2556
2667
  buildWingWiseCollectionWorkbook,
2557
2668
  buildXlsxWorkbook,
2669
+ connectSocket,
2558
2670
  convertNumberToWords,
2671
+ createRealtimeSync,
2559
2672
  definedValues,
2560
2673
  diffArrays,
2674
+ disconnectSocket,
2561
2675
  entityListEntityModelMap,
2562
2676
  epochToReadableDate,
2563
2677
  getFlatValidationErrors,
2564
2678
  getObjectDiffingKeys,
2679
+ getSocket,
2565
2680
  getWingSelectionLabel,
2566
2681
  getWingSelectionSlug,
2567
2682
  groupBy,
2568
2683
  isSpecialFlatLabel,
2569
2684
  isValidFlatWing,
2685
+ registerSocketFactory,
2570
2686
  roundToTwoDecimals,
2571
2687
  serializeXlsx,
2572
2688
  validateFlatOrThrow