@donotdev/firebase 0.0.5 → 0.0.6
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.
|
@@ -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;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EACzC,IAAI,EAAE,CAAC,EACP,YAAY,GAAE,MAAM,EAAO,GAC1B,CAAC,
|
|
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;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EACzC,IAAI,EAAE,CAAC,EACP,YAAY,GAAE,MAAM,EAAO,GAC1B,CAAC,CAsDH;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
|
|
1
|
+
import{handleError as i}from"@donotdev/core/server";function s(e){return{seconds:Math.floor(e.getTime()/1e3),nanoseconds:e.getTime()%1e3*1e6,toDate:()=>new Date(e),toMillis:()=>e.getTime(),isEqual:r=>r.seconds===Math.floor(e.getTime()/1e3)&&r.nanoseconds===e.getTime()%1e3*1e6,valueOf:()=>`Timestamp(seconds=${Math.floor(e.getTime()/1e3)}, nanoseconds=${e.getTime()%1e3*1e6})`}}function c(e){try{if(typeof e=="string"){const r=new Date(e);if(isNaN(r.getTime()))throw i(new Error("Invalid date string format"),{context:{value:e}});return s(r)}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(r){throw i(r,"Failed to convert to Timestamp")}}function l(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 r=new Date(e);if(isNaN(r.getTime()))throw i(new Error("Invalid date string format"),{context:{value:e}});return r.toISOString()}throw i(new Error("Invalid date value type"),{context:{valueType:typeof e}})}catch(r){throw i(r,"Failed to convert to ISO string")}}function y(e){return typeof e=="object"&&e!==null&&"toDate"in e&&typeof e.toDate=="function"&&"seconds"in e&&"nanoseconds"in e}function m(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 t=new Date(e);return!isNaN(t.getTime())}function u(e){if(!e)return e;if(Array.isArray(e))return e.map(r=>u(r));if(typeof e=="string"&&m(e))return new Date(e);if(typeof e=="object"&&e!==null){const r={};for(const[t,n]of Object.entries(e))r[t]=u(n);return r}return e}function f(e,r=!1){if(!e)return e;if(r&&typeof e=="object"&&e!==null&&"id"in e&&"ref"in e&&"data"in e&&typeof e.data=="function"){const t=e,n=t.data();return{id:t.id,...f(n)}}if(Array.isArray(e))return e.map(t=>f(t));if(y(e))return l(e);if(typeof e=="object"&&e!==null){const t={};for(const[n,o]of Object.entries(e))t[n]=f(o);return t}return e}function p(e,r=[]){if(!e)return e;if(Array.isArray(e))return e.map(t=>p(t,r));if(typeof e=="string"&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/.test(e))try{return c(e)}catch{return e}if(e instanceof Date)try{return c(e)}catch{return e}if(typeof e=="object"&&e!==null){const t={};for(const[n,o]of Object.entries(e))r.includes(n)||o!==void 0&&(t[n]=p(o,r));return t}return e}function D(e,r){const t={};for(const[n,o]of Object.entries(r)){if(!(n in e)){t[n]=o;continue}JSON.stringify(e[n])!==JSON.stringify(o)&&(t[n]=o)}return{...t,updatedAt:new Date().toISOString()}}export{u as convertISOStringsToDates,D as createFirestorePartialUpdate,s as createTimestamp,l as firestoreToISOString,y as isTimestamp,p as prepareForFirestore,c as toTimestamp,f as transformFirestoreData};
|