@prmichaelsen/firebase-admin-sdk-v8 2.0.6 → 2.0.8

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
@@ -91,6 +91,15 @@ interface FirestoreDocument {
91
91
  * Generic data object
92
92
  */
93
93
  type DataObject = Record<string, any>;
94
+ /**
95
+ * Document reference (simplified version for REST API)
96
+ */
97
+ interface DocumentReference {
98
+ /** Document ID */
99
+ id: string;
100
+ /** Collection path */
101
+ path: string;
102
+ }
94
103
  /**
95
104
  * Set options for document writes
96
105
  */
@@ -311,19 +320,20 @@ declare function setDocument(collectionPath: string, documentId: string, data: D
311
320
  * @param {string} collectionPath - Collection path (e.g., 'users' or 'users/uid/posts')
312
321
  * @param {DataObject} data - Document data
313
322
  * @param {string} [documentId] - Optional document ID (auto-generated if not provided)
314
- * @returns {Promise<string>} Created document ID
323
+ * @returns {Promise<DocumentReference>} Document reference with id and path
315
324
  * @throws {Error} If the operation fails
316
325
  *
317
326
  * @example
318
327
  * ```typescript
319
- * const docId = await addDocument('users', {
328
+ * const docRef = await addDocument('users', {
320
329
  * name: 'John Doe',
321
330
  * email: 'john@example.com',
322
331
  * createdAt: new Date()
323
332
  * });
333
+ * console.log('Created document:', docRef.id);
324
334
  * ```
325
335
  */
326
- declare function addDocument(collectionPath: string, data: DataObject, documentId?: string): Promise<string>;
336
+ declare function addDocument(collectionPath: string, data: DataObject, documentId?: string): Promise<DocumentReference>;
327
337
  /**
328
338
  * Get a document from Firestore
329
339
  *
@@ -512,4 +522,4 @@ declare function getAdminAccessToken(): Promise<string>;
512
522
  */
513
523
  declare function clearTokenCache(): void;
514
524
 
515
- export { type BatchWrite, type BatchWriteResult, type DataObject, type DecodedIdToken, FieldValue, type FieldValue$1 as FieldValueSentinel, FieldValueType, type FirestoreDocument, type FirestoreValue, type QueryFilter, type QueryOptions, type QueryOrder, type ServiceAccount, type SetOptions, type TokenResponse, type UpdateOptions, type UserInfo, type WhereFilterOp, addDocument, batchWrite, clearConfig, clearTokenCache, deleteDocument, getAdminAccessToken, getAuth, getConfig, getDocument, getProjectId, getServiceAccount, getUserFromToken, initializeApp, queryDocuments, setDocument, updateDocument, verifyIdToken };
525
+ export { type BatchWrite, type BatchWriteResult, type DataObject, type DecodedIdToken, type DocumentReference, FieldValue, type FieldValue$1 as FieldValueSentinel, FieldValueType, type FirestoreDocument, type FirestoreValue, type QueryFilter, type QueryOptions, type QueryOrder, type ServiceAccount, type SetOptions, type TokenResponse, type UpdateOptions, type UserInfo, type WhereFilterOp, addDocument, batchWrite, clearConfig, clearTokenCache, deleteDocument, getAdminAccessToken, getAuth, getConfig, getDocument, getProjectId, getServiceAccount, getUserFromToken, initializeApp, queryDocuments, setDocument, updateDocument, verifyIdToken };
package/dist/index.d.ts CHANGED
@@ -91,6 +91,15 @@ interface FirestoreDocument {
91
91
  * Generic data object
92
92
  */
93
93
  type DataObject = Record<string, any>;
94
+ /**
95
+ * Document reference (simplified version for REST API)
96
+ */
97
+ interface DocumentReference {
98
+ /** Document ID */
99
+ id: string;
100
+ /** Collection path */
101
+ path: string;
102
+ }
94
103
  /**
95
104
  * Set options for document writes
96
105
  */
@@ -311,19 +320,20 @@ declare function setDocument(collectionPath: string, documentId: string, data: D
311
320
  * @param {string} collectionPath - Collection path (e.g., 'users' or 'users/uid/posts')
312
321
  * @param {DataObject} data - Document data
313
322
  * @param {string} [documentId] - Optional document ID (auto-generated if not provided)
314
- * @returns {Promise<string>} Created document ID
323
+ * @returns {Promise<DocumentReference>} Document reference with id and path
315
324
  * @throws {Error} If the operation fails
316
325
  *
317
326
  * @example
318
327
  * ```typescript
319
- * const docId = await addDocument('users', {
328
+ * const docRef = await addDocument('users', {
320
329
  * name: 'John Doe',
321
330
  * email: 'john@example.com',
322
331
  * createdAt: new Date()
323
332
  * });
333
+ * console.log('Created document:', docRef.id);
324
334
  * ```
325
335
  */
326
- declare function addDocument(collectionPath: string, data: DataObject, documentId?: string): Promise<string>;
336
+ declare function addDocument(collectionPath: string, data: DataObject, documentId?: string): Promise<DocumentReference>;
327
337
  /**
328
338
  * Get a document from Firestore
329
339
  *
@@ -512,4 +522,4 @@ declare function getAdminAccessToken(): Promise<string>;
512
522
  */
513
523
  declare function clearTokenCache(): void;
514
524
 
515
- export { type BatchWrite, type BatchWriteResult, type DataObject, type DecodedIdToken, FieldValue, type FieldValue$1 as FieldValueSentinel, FieldValueType, type FirestoreDocument, type FirestoreValue, type QueryFilter, type QueryOptions, type QueryOrder, type ServiceAccount, type SetOptions, type TokenResponse, type UpdateOptions, type UserInfo, type WhereFilterOp, addDocument, batchWrite, clearConfig, clearTokenCache, deleteDocument, getAdminAccessToken, getAuth, getConfig, getDocument, getProjectId, getServiceAccount, getUserFromToken, initializeApp, queryDocuments, setDocument, updateDocument, verifyIdToken };
525
+ export { type BatchWrite, type BatchWriteResult, type DataObject, type DecodedIdToken, type DocumentReference, FieldValue, type FieldValue$1 as FieldValueSentinel, FieldValueType, type FirestoreDocument, type FirestoreValue, type QueryFilter, type QueryOptions, type QueryOrder, type ServiceAccount, type SetOptions, type TokenResponse, type UpdateOptions, type UserInfo, type WhereFilterOp, addDocument, batchWrite, clearConfig, clearTokenCache, deleteDocument, getAdminAccessToken, getAuth, getConfig, getDocument, getProjectId, getServiceAccount, getUserFromToken, initializeApp, queryDocuments, setDocument, updateDocument, verifyIdToken };
package/dist/index.js CHANGED
@@ -722,7 +722,11 @@ async function addDocument(collectionPath, data, documentId) {
722
722
  throw new Error(`Failed to add document: ${errorText}`);
723
723
  }
724
724
  const result = await response.json();
725
- return result.name.split("/").pop();
725
+ const docId = result.name.split("/").pop();
726
+ return {
727
+ id: docId,
728
+ path: `${collectionPath}/${docId}`
729
+ };
726
730
  }
727
731
  async function getDocument(collectionPath, documentId) {
728
732
  const accessToken = await getAdminAccessToken();
package/dist/index.mjs CHANGED
@@ -679,7 +679,11 @@ async function addDocument(collectionPath, data, documentId) {
679
679
  throw new Error(`Failed to add document: ${errorText}`);
680
680
  }
681
681
  const result = await response.json();
682
- return result.name.split("/").pop();
682
+ const docId = result.name.split("/").pop();
683
+ return {
684
+ id: docId,
685
+ path: `${collectionPath}/${docId}`
686
+ };
683
687
  }
684
688
  async function getDocument(collectionPath, documentId) {
685
689
  const accessToken = await getAdminAccessToken();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prmichaelsen/firebase-admin-sdk-v8",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "Firebase Admin SDK for Cloudflare Workers and edge runtimes using REST APIs",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",