@cristian-israel/giganet_lib_conecta 1.0.93 → 1.0.95

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
@@ -38314,6 +38314,21 @@ declare class GigacenterMongoService {
38314
38314
  getCollection<K extends keyof GigacenterMongoCollectionsModels>(key: K): GigacenterMongoCollectionsModels[K];
38315
38315
  }
38316
38316
 
38317
+ declare const MonitoringPonsRowSchema: z.ZodObject<{
38318
+ id: z.ZodNumber;
38319
+ interface: z.ZodString;
38320
+ transmissor: z.ZodString;
38321
+ slot: z.ZodNumber;
38322
+ numero: z.ZodNumber;
38323
+ vlan: z.ZodString;
38324
+ onus_vinculadas: z.ZodNumber;
38325
+ onus_autorizadas: z.ZodNumber;
38326
+ sinal_alto: z.ZodNumber;
38327
+ os_pendentes: z.ZodNumber;
38328
+ os_recolha: z.ZodNumber;
38329
+ rompimentos: z.ZodNumber;
38330
+ offlines_menos_3_meses: z.ZodNumber;
38331
+ }, z.core.$strict>;
38317
38332
  declare const MonitoringPonsSnapshotSchema: z.ZodObject<{
38318
38333
  rows: z.ZodArray<z.ZodObject<{
38319
38334
  id: z.ZodNumber;
@@ -38335,14 +38350,44 @@ declare const MonitoringPonsSnapshotSchema: z.ZodObject<{
38335
38350
  }, z.core.$strict>;
38336
38351
  declare const MonitoringPonsUpdateMetaSchema: z.ZodObject<{
38337
38352
  updatedAt: z.ZodString;
38353
+ changedIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
38354
+ rows: z.ZodOptional<z.ZodArray<z.ZodObject<{
38355
+ id: z.ZodNumber;
38356
+ interface: z.ZodString;
38357
+ transmissor: z.ZodString;
38358
+ slot: z.ZodNumber;
38359
+ numero: z.ZodNumber;
38360
+ vlan: z.ZodString;
38361
+ onus_vinculadas: z.ZodNumber;
38362
+ onus_autorizadas: z.ZodNumber;
38363
+ sinal_alto: z.ZodNumber;
38364
+ os_pendentes: z.ZodNumber;
38365
+ os_recolha: z.ZodNumber;
38366
+ rompimentos: z.ZodNumber;
38367
+ offlines_menos_3_meses: z.ZodNumber;
38368
+ }, z.core.$strict>>>;
38369
+ removedIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
38370
+ kind: z.ZodOptional<z.ZodEnum<{
38371
+ dynamic: "dynamic";
38372
+ static: "static";
38373
+ full: "full";
38374
+ }>>;
38338
38375
  }, z.core.$strict>;
38376
+ type MonitoringPonsRow = z.infer<typeof MonitoringPonsRowSchema>;
38339
38377
  type MonitoringPonsSnapshot = z.infer<typeof MonitoringPonsSnapshotSchema>;
38340
38378
  type MonitoringPonsUpdateMeta = z.infer<typeof MonitoringPonsUpdateMetaSchema>;
38341
38379
 
38380
+ type MonitoringPonsPatchOptions = {
38381
+ updatedAt?: string;
38382
+ updatedAtStatic?: string;
38383
+ removedIds?: number[];
38384
+ };
38342
38385
  type MonitoringPonsStore = {
38343
38386
  getSnapshot(): Promise<MonitoringPonsSnapshot | null>;
38344
38387
  setSnapshot(snapshot: MonitoringPonsSnapshot): Promise<void>;
38388
+ patchRows(rows: MonitoringPonsRow[], options?: MonitoringPonsPatchOptions): Promise<MonitoringPonsRow[]>;
38345
38389
  publishUpdate(meta: MonitoringPonsUpdateMeta): Promise<void>;
38390
+ publishDelta(meta: MonitoringPonsUpdateMeta): Promise<void>;
38346
38391
  subscribe(onUpdate: (meta: MonitoringPonsUpdateMeta) => void): () => void;
38347
38392
  };
38348
38393
 
package/dist/index.d.ts CHANGED
@@ -38314,6 +38314,21 @@ declare class GigacenterMongoService {
38314
38314
  getCollection<K extends keyof GigacenterMongoCollectionsModels>(key: K): GigacenterMongoCollectionsModels[K];
38315
38315
  }
38316
38316
 
38317
+ declare const MonitoringPonsRowSchema: z.ZodObject<{
38318
+ id: z.ZodNumber;
38319
+ interface: z.ZodString;
38320
+ transmissor: z.ZodString;
38321
+ slot: z.ZodNumber;
38322
+ numero: z.ZodNumber;
38323
+ vlan: z.ZodString;
38324
+ onus_vinculadas: z.ZodNumber;
38325
+ onus_autorizadas: z.ZodNumber;
38326
+ sinal_alto: z.ZodNumber;
38327
+ os_pendentes: z.ZodNumber;
38328
+ os_recolha: z.ZodNumber;
38329
+ rompimentos: z.ZodNumber;
38330
+ offlines_menos_3_meses: z.ZodNumber;
38331
+ }, z.core.$strict>;
38317
38332
  declare const MonitoringPonsSnapshotSchema: z.ZodObject<{
38318
38333
  rows: z.ZodArray<z.ZodObject<{
38319
38334
  id: z.ZodNumber;
@@ -38335,14 +38350,44 @@ declare const MonitoringPonsSnapshotSchema: z.ZodObject<{
38335
38350
  }, z.core.$strict>;
38336
38351
  declare const MonitoringPonsUpdateMetaSchema: z.ZodObject<{
38337
38352
  updatedAt: z.ZodString;
38353
+ changedIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
38354
+ rows: z.ZodOptional<z.ZodArray<z.ZodObject<{
38355
+ id: z.ZodNumber;
38356
+ interface: z.ZodString;
38357
+ transmissor: z.ZodString;
38358
+ slot: z.ZodNumber;
38359
+ numero: z.ZodNumber;
38360
+ vlan: z.ZodString;
38361
+ onus_vinculadas: z.ZodNumber;
38362
+ onus_autorizadas: z.ZodNumber;
38363
+ sinal_alto: z.ZodNumber;
38364
+ os_pendentes: z.ZodNumber;
38365
+ os_recolha: z.ZodNumber;
38366
+ rompimentos: z.ZodNumber;
38367
+ offlines_menos_3_meses: z.ZodNumber;
38368
+ }, z.core.$strict>>>;
38369
+ removedIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
38370
+ kind: z.ZodOptional<z.ZodEnum<{
38371
+ dynamic: "dynamic";
38372
+ static: "static";
38373
+ full: "full";
38374
+ }>>;
38338
38375
  }, z.core.$strict>;
38376
+ type MonitoringPonsRow = z.infer<typeof MonitoringPonsRowSchema>;
38339
38377
  type MonitoringPonsSnapshot = z.infer<typeof MonitoringPonsSnapshotSchema>;
38340
38378
  type MonitoringPonsUpdateMeta = z.infer<typeof MonitoringPonsUpdateMetaSchema>;
38341
38379
 
38380
+ type MonitoringPonsPatchOptions = {
38381
+ updatedAt?: string;
38382
+ updatedAtStatic?: string;
38383
+ removedIds?: number[];
38384
+ };
38342
38385
  type MonitoringPonsStore = {
38343
38386
  getSnapshot(): Promise<MonitoringPonsSnapshot | null>;
38344
38387
  setSnapshot(snapshot: MonitoringPonsSnapshot): Promise<void>;
38388
+ patchRows(rows: MonitoringPonsRow[], options?: MonitoringPonsPatchOptions): Promise<MonitoringPonsRow[]>;
38345
38389
  publishUpdate(meta: MonitoringPonsUpdateMeta): Promise<void>;
38390
+ publishDelta(meta: MonitoringPonsUpdateMeta): Promise<void>;
38346
38391
  subscribe(onUpdate: (meta: MonitoringPonsUpdateMeta) => void): () => void;
38347
38392
  };
38348
38393
 
package/dist/index.js CHANGED
@@ -92917,17 +92917,33 @@ var MonitoringPonsSnapshotSchema = import_zod4.z.object({
92917
92917
  updatedAt: import_zod4.z.string(),
92918
92918
  updatedAtStatic: import_zod4.z.string().optional()
92919
92919
  }).strict();
92920
+ var MonitoringPonsUpdateKindSchema = import_zod4.z.enum([
92921
+ "dynamic",
92922
+ "static",
92923
+ "full"
92924
+ ]);
92920
92925
  var MonitoringPonsUpdateMetaSchema = import_zod4.z.object({
92921
- updatedAt: import_zod4.z.string()
92926
+ updatedAt: import_zod4.z.string(),
92927
+ changedIds: import_zod4.z.array(import_zod4.z.number()).optional(),
92928
+ rows: import_zod4.z.array(MonitoringPonsRowSchema).optional(),
92929
+ removedIds: import_zod4.z.array(import_zod4.z.number()).optional(),
92930
+ kind: MonitoringPonsUpdateKindSchema.optional()
92922
92931
  }).strict();
92923
92932
 
92924
92933
  // src/databases/redis/routines/stores/monitoring-pons/monitoring-pons.ts
92925
92934
  var SNAPSHOT_KEY = "snapshot";
92926
92935
  var UPDATES_CHANNEL = "updates";
92936
+ function rowsEqual(a, b) {
92937
+ return JSON.stringify(a) === JSON.stringify(b);
92938
+ }
92927
92939
  function createMonitoringPonsStore(client, basePrefix) {
92928
92940
  const prefix = `${basePrefix}pons:`;
92929
92941
  const snapshotKey = `${prefix}${SNAPSHOT_KEY}`;
92930
92942
  const updatesChannel = `${client.options.keyPrefix ?? ""}${prefix}${UPDATES_CHANNEL}`;
92943
+ const publishValidated = async (meta) => {
92944
+ const validated = MonitoringPonsUpdateMetaSchema.parse(meta);
92945
+ await client.publish(updatesChannel, JSON.stringify(validated));
92946
+ };
92931
92947
  return {
92932
92948
  async getSnapshot() {
92933
92949
  const value = await client.get(snapshotKey);
@@ -92938,9 +92954,50 @@ function createMonitoringPonsStore(client, basePrefix) {
92938
92954
  const validated = MonitoringPonsSnapshotSchema.parse(snapshot);
92939
92955
  await client.set(snapshotKey, JSON.stringify(validated));
92940
92956
  },
92957
+ async patchRows(rows, options) {
92958
+ const validatedRows = rows.map(
92959
+ (row) => MonitoringPonsRowSchema.parse(row)
92960
+ );
92961
+ const removedIds = options?.removedIds ?? [];
92962
+ const current = await this.getSnapshot();
92963
+ const updatedAt = options?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
92964
+ if (!current) {
92965
+ const snapshot2 = MonitoringPonsSnapshotSchema.parse({
92966
+ rows: validatedRows,
92967
+ updatedAt,
92968
+ updatedAtStatic: options?.updatedAtStatic
92969
+ });
92970
+ await client.set(snapshotKey, JSON.stringify(snapshot2));
92971
+ return validatedRows;
92972
+ }
92973
+ const rowMap = new Map(current.rows.map((row) => [row.id, row]));
92974
+ const changed = [];
92975
+ for (const row of validatedRows) {
92976
+ const existing = rowMap.get(row.id);
92977
+ if (!existing || !rowsEqual(existing, row)) {
92978
+ changed.push(row);
92979
+ }
92980
+ rowMap.set(row.id, row);
92981
+ }
92982
+ for (const id of removedIds) {
92983
+ rowMap.delete(id);
92984
+ }
92985
+ if (changed.length === 0 && removedIds.length === 0) {
92986
+ return [];
92987
+ }
92988
+ const snapshot = MonitoringPonsSnapshotSchema.parse({
92989
+ rows: Array.from(rowMap.values()),
92990
+ updatedAt,
92991
+ updatedAtStatic: options?.updatedAtStatic ?? current.updatedAtStatic
92992
+ });
92993
+ await client.set(snapshotKey, JSON.stringify(snapshot));
92994
+ return changed;
92995
+ },
92941
92996
  async publishUpdate(meta) {
92942
- const validated = MonitoringPonsUpdateMetaSchema.parse(meta);
92943
- await client.publish(updatesChannel, JSON.stringify(validated));
92997
+ await publishValidated(meta);
92998
+ },
92999
+ async publishDelta(meta) {
93000
+ await publishValidated(meta);
92944
93001
  },
92945
93002
  subscribe(onUpdate) {
92946
93003
  const subscriber = client.duplicate();
@@ -92953,9 +93010,9 @@ function createMonitoringPonsStore(client, basePrefix) {
92953
93010
  if (!parsed.success) {
92954
93011
  loger({
92955
93012
  level: "WARN",
92956
- context: "PonsStore",
93013
+ context: "MonitoringPonsStore",
92957
93014
  domain: "REDIS",
92958
- message: `Ignoring invalid pons update message: ${parsed.error.message}`
93015
+ message: `Ignoring invalid monitoring pons update message: ${parsed.error.message}`
92959
93016
  });
92960
93017
  return;
92961
93018
  }
package/dist/index.mjs CHANGED
@@ -92869,17 +92869,33 @@ var MonitoringPonsSnapshotSchema = z4.object({
92869
92869
  updatedAt: z4.string(),
92870
92870
  updatedAtStatic: z4.string().optional()
92871
92871
  }).strict();
92872
+ var MonitoringPonsUpdateKindSchema = z4.enum([
92873
+ "dynamic",
92874
+ "static",
92875
+ "full"
92876
+ ]);
92872
92877
  var MonitoringPonsUpdateMetaSchema = z4.object({
92873
- updatedAt: z4.string()
92878
+ updatedAt: z4.string(),
92879
+ changedIds: z4.array(z4.number()).optional(),
92880
+ rows: z4.array(MonitoringPonsRowSchema).optional(),
92881
+ removedIds: z4.array(z4.number()).optional(),
92882
+ kind: MonitoringPonsUpdateKindSchema.optional()
92874
92883
  }).strict();
92875
92884
 
92876
92885
  // src/databases/redis/routines/stores/monitoring-pons/monitoring-pons.ts
92877
92886
  var SNAPSHOT_KEY = "snapshot";
92878
92887
  var UPDATES_CHANNEL = "updates";
92888
+ function rowsEqual(a, b) {
92889
+ return JSON.stringify(a) === JSON.stringify(b);
92890
+ }
92879
92891
  function createMonitoringPonsStore(client, basePrefix) {
92880
92892
  const prefix = `${basePrefix}pons:`;
92881
92893
  const snapshotKey = `${prefix}${SNAPSHOT_KEY}`;
92882
92894
  const updatesChannel = `${client.options.keyPrefix ?? ""}${prefix}${UPDATES_CHANNEL}`;
92895
+ const publishValidated = async (meta) => {
92896
+ const validated = MonitoringPonsUpdateMetaSchema.parse(meta);
92897
+ await client.publish(updatesChannel, JSON.stringify(validated));
92898
+ };
92883
92899
  return {
92884
92900
  async getSnapshot() {
92885
92901
  const value = await client.get(snapshotKey);
@@ -92890,9 +92906,50 @@ function createMonitoringPonsStore(client, basePrefix) {
92890
92906
  const validated = MonitoringPonsSnapshotSchema.parse(snapshot);
92891
92907
  await client.set(snapshotKey, JSON.stringify(validated));
92892
92908
  },
92909
+ async patchRows(rows, options) {
92910
+ const validatedRows = rows.map(
92911
+ (row) => MonitoringPonsRowSchema.parse(row)
92912
+ );
92913
+ const removedIds = options?.removedIds ?? [];
92914
+ const current = await this.getSnapshot();
92915
+ const updatedAt = options?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
92916
+ if (!current) {
92917
+ const snapshot2 = MonitoringPonsSnapshotSchema.parse({
92918
+ rows: validatedRows,
92919
+ updatedAt,
92920
+ updatedAtStatic: options?.updatedAtStatic
92921
+ });
92922
+ await client.set(snapshotKey, JSON.stringify(snapshot2));
92923
+ return validatedRows;
92924
+ }
92925
+ const rowMap = new Map(current.rows.map((row) => [row.id, row]));
92926
+ const changed = [];
92927
+ for (const row of validatedRows) {
92928
+ const existing = rowMap.get(row.id);
92929
+ if (!existing || !rowsEqual(existing, row)) {
92930
+ changed.push(row);
92931
+ }
92932
+ rowMap.set(row.id, row);
92933
+ }
92934
+ for (const id of removedIds) {
92935
+ rowMap.delete(id);
92936
+ }
92937
+ if (changed.length === 0 && removedIds.length === 0) {
92938
+ return [];
92939
+ }
92940
+ const snapshot = MonitoringPonsSnapshotSchema.parse({
92941
+ rows: Array.from(rowMap.values()),
92942
+ updatedAt,
92943
+ updatedAtStatic: options?.updatedAtStatic ?? current.updatedAtStatic
92944
+ });
92945
+ await client.set(snapshotKey, JSON.stringify(snapshot));
92946
+ return changed;
92947
+ },
92893
92948
  async publishUpdate(meta) {
92894
- const validated = MonitoringPonsUpdateMetaSchema.parse(meta);
92895
- await client.publish(updatesChannel, JSON.stringify(validated));
92949
+ await publishValidated(meta);
92950
+ },
92951
+ async publishDelta(meta) {
92952
+ await publishValidated(meta);
92896
92953
  },
92897
92954
  subscribe(onUpdate) {
92898
92955
  const subscriber = client.duplicate();
@@ -92905,9 +92962,9 @@ function createMonitoringPonsStore(client, basePrefix) {
92905
92962
  if (!parsed.success) {
92906
92963
  loger({
92907
92964
  level: "WARN",
92908
- context: "PonsStore",
92965
+ context: "MonitoringPonsStore",
92909
92966
  domain: "REDIS",
92910
- message: `Ignoring invalid pons update message: ${parsed.error.message}`
92967
+ message: `Ignoring invalid monitoring pons update message: ${parsed.error.message}`
92911
92968
  });
92912
92969
  return;
92913
92970
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cristian-israel/giganet_lib_conecta",
3
- "version": "1.0.93",
3
+ "version": "1.0.95",
4
4
  "description": "Database Connector Layer",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",