@telestack/db-sdk 1.0.1 → 1.0.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.
Files changed (2) hide show
  1. package/dist/index.js +11 -23
  2. package/package.json +3 -1
package/dist/index.js CHANGED
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Transaction = exports.DocumentSnapshot = exports.WriteBatch = exports.DocumentReference = exports.CollectionReference = exports.Query = exports.TelestackClient = exports.TelestackError = exports.IndexedDBPersistence = void 0;
4
- const centrifuge_1 = require("centrifuge");
1
+ import { Centrifuge } from 'centrifuge';
5
2
  /**
6
3
  * IndexedDB implementation of PersistenceEngine
7
4
  */
8
- class IndexedDBPersistence {
5
+ export class IndexedDBPersistence {
9
6
  db = null;
10
7
  dbName = 'TelestackDB_Cache';
11
8
  async init() {
@@ -80,9 +77,8 @@ class IndexedDBPersistence {
80
77
  });
81
78
  }
82
79
  }
83
- exports.IndexedDBPersistence = IndexedDBPersistence;
84
80
  /** Custom Error class for Telestack operations */
85
- class TelestackError extends Error {
81
+ export class TelestackError extends Error {
86
82
  message;
87
83
  code;
88
84
  constructor(message, code) {
@@ -92,11 +88,10 @@ class TelestackError extends Error {
92
88
  this.name = 'TelestackError';
93
89
  }
94
90
  }
95
- exports.TelestackError = TelestackError;
96
91
  /**
97
92
  * Main Telestack Client
98
93
  */
99
- class TelestackClient {
94
+ export class TelestackClient {
100
95
  config;
101
96
  centrifuge = null;
102
97
  isProcessingQueue = false;
@@ -113,7 +108,7 @@ class TelestackClient {
113
108
  this.persistence = new IndexedDBPersistence();
114
109
  }
115
110
  if (config.centrifugoUrl) {
116
- this.centrifuge = new centrifuge_1.Centrifuge(config.centrifugoUrl, {
111
+ this.centrifuge = new Centrifuge(config.centrifugoUrl, {
117
112
  getToken: () => this.getToken()
118
113
  });
119
114
  this.centrifuge.on('connected', () => {
@@ -284,11 +279,10 @@ class TelestackClient {
284
279
  setInterval(() => this.processQueue(), 5000); // Process queue every 5s
285
280
  }
286
281
  }
287
- exports.TelestackClient = TelestackClient;
288
282
  /**
289
283
  * Query class for collection-level queries
290
284
  */
291
- class Query {
285
+ export class Query {
292
286
  client;
293
287
  path;
294
288
  filters = [];
@@ -518,11 +512,10 @@ class Query {
518
512
  };
519
513
  }
520
514
  }
521
- exports.Query = Query;
522
515
  /**
523
516
  * CollectionReference extends Query with add() and doc() methods
524
517
  */
525
- class CollectionReference extends Query {
518
+ export class CollectionReference extends Query {
526
519
  doc(id) {
527
520
  return new DocumentReference(this.client, this.path, id);
528
521
  }
@@ -547,11 +540,10 @@ class CollectionReference extends Query {
547
540
  return result;
548
541
  }
549
542
  }
550
- exports.CollectionReference = CollectionReference;
551
543
  /**
552
544
  * DocumentReference allows CRUD operations and realtime subscription on a single document
553
545
  */
554
- class DocumentReference {
546
+ export class DocumentReference {
555
547
  client;
556
548
  collectionPath;
557
549
  id;
@@ -731,11 +723,10 @@ class DocumentReference {
731
723
  };
732
724
  }
733
725
  }
734
- exports.DocumentReference = DocumentReference;
735
726
  /**
736
727
  * WriteBatch allows multiple write operations to be committed atomically
737
728
  */
738
- class WriteBatch {
729
+ export class WriteBatch {
739
730
  client;
740
731
  operations = [];
741
732
  constructor(client) {
@@ -767,11 +758,10 @@ class WriteBatch {
767
758
  this.client.updateLastVersion(result.version);
768
759
  }
769
760
  }
770
- exports.WriteBatch = WriteBatch;
771
761
  /**
772
762
  * DocumentSnapshot contains document data and its database version
773
763
  */
774
- class DocumentSnapshot {
764
+ export class DocumentSnapshot {
775
765
  id;
776
766
  path;
777
767
  _data;
@@ -787,11 +777,10 @@ class DocumentSnapshot {
787
777
  exists() { return this._data !== null; }
788
778
  data() { return this._data; }
789
779
  }
790
- exports.DocumentSnapshot = DocumentSnapshot;
791
780
  /**
792
781
  * Transaction allows read-modify-write operations with OCC
793
782
  */
794
- class Transaction {
783
+ export class Transaction {
795
784
  client;
796
785
  operations = [];
797
786
  constructor(client) {
@@ -845,4 +834,3 @@ class Transaction {
845
834
  this.client.updateLastVersion(result.version);
846
835
  }
847
836
  }
848
- exports.Transaction = Transaction;
package/package.json CHANGED
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "name": "@telestack/db-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Fluent, real-time SDK for Telestack DB",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
7
+ "module": "dist/index.js",
6
8
  "types": "dist/index.d.ts",
7
9
  "files": [
8
10
  "dist",