@donotdev/firebase 0.0.7 → 0.0.9
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.
|
@@ -72,7 +72,8 @@ export declare function convertISOStringsToDates<T = any>(data: T): T;
|
|
|
72
72
|
*/
|
|
73
73
|
export declare function transformFirestoreData<T = any>(data: T, includeDocumentIds?: boolean): T;
|
|
74
74
|
/**
|
|
75
|
-
* Recursively prepares data for Firestore by converting
|
|
75
|
+
* Recursively prepares data for Firestore by converting Date objects to ISO strings.
|
|
76
|
+
* ISO strings are kept as-is (no conversion needed).
|
|
76
77
|
* @param data - The data to prepare
|
|
77
78
|
* @param removeFields - Optional array of field names to remove
|
|
78
79
|
* @returns The prepared data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/shared/transform.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpE;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAY9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,kBAAkB,CAyBnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAoC5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,kBAAkB,CASnE;AAmBD;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAoB5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAC5C,IAAI,EAAE,CAAC,EACP,kBAAkB,GAAE,OAAe,GAClC,CAAC,CA0CH;AAED
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/shared/transform.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpE;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,kBAAkB,CAY9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,kBAAkB,CAyBnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAoC5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,kBAAkB,CASnE;AAmBD;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAoB5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAC5C,IAAI,EAAE,CAAC,EACP,kBAAkB,GAAE,OAAe,GAClC,CAAC,CA0CH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EACzC,IAAI,EAAE,CAAC,EACP,YAAY,GAAE,MAAM,EAAO,GAC1B,CAAC,CAsCH;AAED;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxE,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,CAAC,CAAC,CAsBZ"}
|
package/dist/shared/transform.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{handleError as i}from"@donotdev/core";function s(e){return{seconds:Math.floor(e.getTime()/1e3),nanoseconds:e.getTime()%1e3*1e6,toDate:()=>new Date(e),toMillis:()=>e.getTime(),isEqual:
|
|
1
|
+
import{handleError as i}from"@donotdev/core";function s(e){return{seconds:Math.floor(e.getTime()/1e3),nanoseconds:e.getTime()%1e3*1e6,toDate:()=>new Date(e),toMillis:()=>e.getTime(),isEqual:t=>t.seconds===Math.floor(e.getTime()/1e3)&&t.nanoseconds===e.getTime()%1e3*1e6,valueOf:()=>`Timestamp(seconds=${Math.floor(e.getTime()/1e3)}, nanoseconds=${e.getTime()%1e3*1e6})`}}function g(e){try{if(typeof e=="string"){const t=new Date(e);if(isNaN(t.getTime()))throw i(new Error("Invalid date string format"),{context:{value:e}});return s(t)}if(e instanceof Date){if(isNaN(e.getTime()))throw i(new Error("Invalid Date object"),{context:{value:e}});return s(e)}throw i(new Error("Invalid date value type"),{context:{valueType:typeof e}})}catch(t){throw i(t,"Failed to convert to Timestamp")}}function p(e){try{if(e instanceof Date){if(isNaN(e.getTime()))throw i(new Error("Invalid Date object"),{context:{value:e}});return e.toISOString()}if(typeof e=="object"&&e!==null&&"toDate"in e&&typeof e.toDate=="function")return e.toDate().toISOString();if(typeof e=="string"){const t=new Date(e);if(isNaN(t.getTime()))throw i(new Error("Invalid date string format"),{context:{value:e}});return t.toISOString()}throw i(new Error("Invalid date value type"),{context:{valueType:typeof e}})}catch(t){throw i(t,"Failed to convert to ISO string")}}function l(e){return typeof e=="object"&&e!==null&&"toDate"in e&&typeof e.toDate=="function"&&"seconds"in e&&"nanoseconds"in e}function y(e){if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/.test(e))return!1;const r=new Date(e);return!isNaN(r.getTime())}function c(e){if(!e)return e;if(Array.isArray(e))return e.map(t=>c(t));if(typeof e=="string"&&y(e))return new Date(e);if(typeof e=="object"&&e!==null){const t={};for(const[r,n]of Object.entries(e))t[r]=c(n);return t}return e}function f(e,t=!1){if(!e)return e;if(t&&typeof e=="object"&&e!==null&&"id"in e&&"ref"in e&&"data"in e&&typeof e.data=="function"){const r=e,n=r.data();return{id:r.id,...f(n)}}if(Array.isArray(e))return e.map(r=>f(r));if(l(e))return p(e);if(typeof e=="object"&&e!==null){const r={};for(const[n,o]of Object.entries(e))r[n]=f(o);return r}return e}function u(e,t=[]){if(!e)return e;if(Array.isArray(e))return e.map(r=>u(r,t));if(e instanceof Date)return e.toISOString();if(typeof e=="object"&&e!==null){const r={};for(const[n,o]of Object.entries(e))t.includes(n)||o!==void 0&&(r[n]=u(o,t));return r}return e}function D(e,t){const r={};for(const[n,o]of Object.entries(t)){if(!(n in e)){r[n]=o;continue}JSON.stringify(e[n])!==JSON.stringify(o)&&(r[n]=o)}return{...r,updatedAt:new Date().toISOString()}}export{c as convertISOStringsToDates,D as createFirestorePartialUpdate,s as createTimestamp,p as firestoreToISOString,l as isTimestamp,u as prepareForFirestore,g as toTimestamp,f as transformFirestoreData};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@donotdev/firebase",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"valibot": "^1.2.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@donotdev/core": "^0.0.
|
|
33
|
-
"firebase": "^12.
|
|
32
|
+
"@donotdev/core": "^0.0.19",
|
|
33
|
+
"firebase": "^12.8.0",
|
|
34
34
|
"firebase-admin": "^13.6.0"
|
|
35
35
|
},
|
|
36
36
|
"files": [
|