@seaverse/data-service-sdk 0.10.2 → 0.11.0
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/README.md +48 -1
- package/dist/browser.js +62 -16
- package/dist/browser.js.map +1 -1
- package/dist/browser.umd.js +62 -16
- package/dist/browser.umd.js.map +1 -1
- package/dist/index.cjs +62 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +45 -5
- package/dist/index.js +62 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/browser.umd.js
CHANGED
|
@@ -4786,6 +4786,7 @@
|
|
|
4786
4786
|
*
|
|
4787
4787
|
* @param collectionName - Collection name
|
|
4788
4788
|
* @param includeDeleted - Include soft-deleted documents (default: false)
|
|
4789
|
+
* @param options - Pagination options (limit and startAfter)
|
|
4789
4790
|
* @returns QuerySnapshot with documents
|
|
4790
4791
|
*
|
|
4791
4792
|
* @example
|
|
@@ -4798,11 +4799,21 @@
|
|
|
4798
4799
|
*
|
|
4799
4800
|
* // Include deleted posts (admin use case)
|
|
4800
4801
|
* const allPosts = await helper.getPublicData('posts', true);
|
|
4802
|
+
*
|
|
4803
|
+
* // Pagination: Get first 10 posts
|
|
4804
|
+
* const firstPage = await helper.getPublicData('posts', false, { limit: 10 });
|
|
4805
|
+
*
|
|
4806
|
+
* // Get next 10 posts (start after last document)
|
|
4807
|
+
* const lastDoc = firstPage.docs[firstPage.docs.length - 1];
|
|
4808
|
+
* const nextPage = await helper.getPublicData('posts', false, {
|
|
4809
|
+
* limit: 10,
|
|
4810
|
+
* startAfter: lastDoc
|
|
4811
|
+
* });
|
|
4801
4812
|
* ```
|
|
4802
4813
|
*/
|
|
4803
|
-
async getPublicData(collectionName, includeDeleted = false) {
|
|
4814
|
+
async getPublicData(collectionName, includeDeleted = false, options) {
|
|
4804
4815
|
const path = getPublicDataPath(this.appId, collectionName);
|
|
4805
|
-
return this.getDocs(path, includeDeleted);
|
|
4816
|
+
return this.getDocs(path, includeDeleted, options);
|
|
4806
4817
|
}
|
|
4807
4818
|
/**
|
|
4808
4819
|
* Get all documents from userData collection (user's private data)
|
|
@@ -4811,6 +4822,7 @@
|
|
|
4811
4822
|
*
|
|
4812
4823
|
* @param collectionName - Collection name
|
|
4813
4824
|
* @param includeDeleted - Include soft-deleted documents (default: false)
|
|
4825
|
+
* @param options - Pagination options (limit and startAfter)
|
|
4814
4826
|
* @returns QuerySnapshot with documents
|
|
4815
4827
|
*
|
|
4816
4828
|
* @example
|
|
@@ -4819,26 +4831,45 @@
|
|
|
4819
4831
|
* snapshot.forEach(doc => {
|
|
4820
4832
|
* console.log('My note:', doc.data());
|
|
4821
4833
|
* });
|
|
4834
|
+
*
|
|
4835
|
+
* // Pagination: Get first 20 notes
|
|
4836
|
+
* const firstPage = await helper.getUserData('notes', false, { limit: 20 });
|
|
4837
|
+
*
|
|
4838
|
+
* // Get next page
|
|
4839
|
+
* const lastDoc = firstPage.docs[firstPage.docs.length - 1];
|
|
4840
|
+
* const nextPage = await helper.getUserData('notes', false, {
|
|
4841
|
+
* limit: 20,
|
|
4842
|
+
* startAfter: lastDoc
|
|
4843
|
+
* });
|
|
4822
4844
|
* ```
|
|
4823
4845
|
*/
|
|
4824
|
-
async getUserData(collectionName, includeDeleted = false) {
|
|
4846
|
+
async getUserData(collectionName, includeDeleted = false, options) {
|
|
4825
4847
|
const path = getUserDataPath(this.appId, this.userId, collectionName);
|
|
4826
|
-
return this.getDocs(path, includeDeleted);
|
|
4848
|
+
return this.getDocs(path, includeDeleted, options);
|
|
4827
4849
|
}
|
|
4828
4850
|
/**
|
|
4829
4851
|
* Get all documents from publicRead collection (read-only for users)
|
|
4830
4852
|
*
|
|
4831
4853
|
* @param collectionName - Collection name
|
|
4854
|
+
* @param options - Pagination options (limit and startAfter)
|
|
4832
4855
|
* @returns QuerySnapshot with documents
|
|
4833
4856
|
*
|
|
4834
4857
|
* @example
|
|
4835
4858
|
* ```typescript
|
|
4836
4859
|
* const configs = await helper.getPublicRead('config');
|
|
4860
|
+
*
|
|
4861
|
+
* // Pagination
|
|
4862
|
+
* const firstPage = await helper.getPublicRead('config', { limit: 10 });
|
|
4863
|
+
* const lastDoc = firstPage.docs[firstPage.docs.length - 1];
|
|
4864
|
+
* const nextPage = await helper.getPublicRead('config', {
|
|
4865
|
+
* limit: 10,
|
|
4866
|
+
* startAfter: lastDoc
|
|
4867
|
+
* });
|
|
4837
4868
|
* ```
|
|
4838
4869
|
*/
|
|
4839
|
-
async getPublicRead(collectionName) {
|
|
4870
|
+
async getPublicRead(collectionName, options) {
|
|
4840
4871
|
const path = getPublicReadPath(this.appId, collectionName);
|
|
4841
|
-
return this.getDocs(path);
|
|
4872
|
+
return this.getDocs(path, false, options);
|
|
4842
4873
|
}
|
|
4843
4874
|
/**
|
|
4844
4875
|
* Get collection reference for publicData
|
|
@@ -5007,22 +5038,36 @@
|
|
|
5007
5038
|
}
|
|
5008
5039
|
/**
|
|
5009
5040
|
* Internal: Get all documents from collection
|
|
5010
|
-
* Optionally filter out soft-deleted documents
|
|
5041
|
+
* Optionally filter out soft-deleted documents and support pagination
|
|
5011
5042
|
*/
|
|
5012
|
-
async getDocs(collectionPath, includeDeleted = false) {
|
|
5013
|
-
const { getDocs, collection, query, where } = await this.loadFirestore();
|
|
5043
|
+
async getDocs(collectionPath, includeDeleted = false, options) {
|
|
5044
|
+
const { getDocs, collection, query, where, limit, startAfter } = await this.loadFirestore();
|
|
5014
5045
|
const colRef = collection(this.db, collectionPath);
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
else {
|
|
5046
|
+
// Build query constraints
|
|
5047
|
+
const constraints = [];
|
|
5048
|
+
// Add soft-delete filter if needed
|
|
5049
|
+
if (!includeDeleted) {
|
|
5020
5050
|
// Filter out soft-deleted documents
|
|
5021
5051
|
// Use '!=' to include documents without _deleted field (new documents)
|
|
5022
5052
|
// This will return documents where _deleted is missing, null, undefined, or false
|
|
5023
|
-
|
|
5053
|
+
constraints.push(where('_deleted', '!=', true));
|
|
5054
|
+
}
|
|
5055
|
+
// Add pagination constraints if provided
|
|
5056
|
+
if (options?.limit) {
|
|
5057
|
+
constraints.push(limit(options.limit));
|
|
5058
|
+
}
|
|
5059
|
+
if (options?.startAfter) {
|
|
5060
|
+
constraints.push(startAfter(options.startAfter));
|
|
5061
|
+
}
|
|
5062
|
+
// Execute query
|
|
5063
|
+
if (constraints.length > 0) {
|
|
5064
|
+
const q = query(colRef, ...constraints);
|
|
5024
5065
|
return getDocs(q);
|
|
5025
5066
|
}
|
|
5067
|
+
else {
|
|
5068
|
+
// No constraints, return all documents
|
|
5069
|
+
return getDocs(colRef);
|
|
5070
|
+
}
|
|
5026
5071
|
}
|
|
5027
5072
|
/**
|
|
5028
5073
|
* Internal: Get collection reference
|
|
@@ -5051,7 +5096,8 @@
|
|
|
5051
5096
|
query: firestore.query,
|
|
5052
5097
|
where: firestore.where,
|
|
5053
5098
|
orderBy: firestore.orderBy,
|
|
5054
|
-
limit: firestore.limit
|
|
5099
|
+
limit: firestore.limit,
|
|
5100
|
+
startAfter: firestore.startAfter
|
|
5055
5101
|
};
|
|
5056
5102
|
}
|
|
5057
5103
|
}
|