firetender 0.11.1 → 0.11.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.
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/timestamps.d.ts +14 -5
- package/dist/timestamps.js +22 -8
- package/dist/timestamps.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -2
- package/src/timestamps.ts +21 -6
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ import { Timestamp, where } from "./firestore-deps";
|
|
|
3
3
|
import { FiretenderCollection } from "./FiretenderCollection";
|
|
4
4
|
import type { FiretenderDocOptions } from "./FiretenderDoc";
|
|
5
5
|
import { FiretenderDoc } from "./FiretenderDoc";
|
|
6
|
-
import {
|
|
7
|
-
export { FiretenderCollection, FiretenderDoc, FiretenderDocOptions, FiretenderError, FiretenderInternalError, FiretenderIOError, FiretenderUsageError,
|
|
6
|
+
import { futureTimestamp, serverTimestamp, serverTimestampWithClientTime, timestampSchema } from "./timestamps";
|
|
7
|
+
export { FiretenderCollection, FiretenderDoc, FiretenderDocOptions, FiretenderError, FiretenderInternalError, FiretenderIOError, FiretenderUsageError, futureTimestamp, serverTimestamp, serverTimestampWithClientTime, Timestamp, timestampSchema, where, };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.where = exports.timestampSchema = exports.Timestamp = exports.serverTimestampWithClientTime = exports.serverTimestamp = exports.
|
|
3
|
+
exports.where = exports.timestampSchema = exports.Timestamp = exports.serverTimestampWithClientTime = exports.serverTimestamp = exports.futureTimestamp = exports.FiretenderUsageError = exports.FiretenderIOError = exports.FiretenderInternalError = exports.FiretenderError = exports.FiretenderDoc = exports.FiretenderCollection = void 0;
|
|
4
4
|
const errors_1 = require("./errors");
|
|
5
5
|
Object.defineProperty(exports, "FiretenderError", { enumerable: true, get: function () { return errors_1.FiretenderError; } });
|
|
6
6
|
Object.defineProperty(exports, "FiretenderInternalError", { enumerable: true, get: function () { return errors_1.FiretenderInternalError; } });
|
|
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "FiretenderCollection", { enumerable: true, get:
|
|
|
14
14
|
const FiretenderDoc_1 = require("./FiretenderDoc");
|
|
15
15
|
Object.defineProperty(exports, "FiretenderDoc", { enumerable: true, get: function () { return FiretenderDoc_1.FiretenderDoc; } });
|
|
16
16
|
const timestamps_1 = require("./timestamps");
|
|
17
|
-
Object.defineProperty(exports, "
|
|
17
|
+
Object.defineProperty(exports, "futureTimestamp", { enumerable: true, get: function () { return timestamps_1.futureTimestamp; } });
|
|
18
18
|
Object.defineProperty(exports, "serverTimestamp", { enumerable: true, get: function () { return timestamps_1.serverTimestamp; } });
|
|
19
19
|
Object.defineProperty(exports, "serverTimestampWithClientTime", { enumerable: true, get: function () { return timestamps_1.serverTimestampWithClientTime; } });
|
|
20
20
|
Object.defineProperty(exports, "timestampSchema", { enumerable: true, get: function () { return timestamps_1.timestampSchema; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAKkB;AAgBhB,gGApBA,wBAAe,OAoBA;AACf,wGApBA,gCAAuB,OAoBA;AACvB,kGApBA,0BAAiB,OAoBA;AACjB,qGApBA,6BAAoB,OAoBA;AAlBtB,qDAAoD;AAsBlD,0FAtBO,0BAAS,OAsBP;AAET,sFAxBkB,sBAAK,OAwBlB;AAvBP,iEAA8D;AAW5D,qGAXO,2CAAoB,OAWP;AATtB,mDAAgD;AAU9C,8FAVO,6BAAa,OAUP;AATf,6CAKsB;AAUpB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAKkB;AAgBhB,gGApBA,wBAAe,OAoBA;AACf,wGApBA,gCAAuB,OAoBA;AACvB,kGApBA,0BAAiB,OAoBA;AACjB,qGApBA,6BAAoB,OAoBA;AAlBtB,qDAAoD;AAsBlD,0FAtBO,0BAAS,OAsBP;AAET,sFAxBkB,sBAAK,OAwBlB;AAvBP,iEAA8D;AAW5D,qGAXO,2CAAoB,OAWP;AATtB,mDAAgD;AAU9C,8FAVO,6BAAa,OAUP;AATf,6CAKsB;AAUpB,gGAdA,4BAAe,OAcA;AACf,gGAdA,4BAAe,OAcA;AACf,8GAdA,0CAA6B,OAcA;AAE7B,gGAfA,4BAAe,OAeA"}
|
package/dist/timestamps.d.ts
CHANGED
|
@@ -9,13 +9,22 @@ export declare const timestampSchema: z.ZodType<Timestamp, z.ZodTypeDef, Timesta
|
|
|
9
9
|
* Returns a Firestore Timestamp for some future date. The result is typically
|
|
10
10
|
* used for writing TTLs.
|
|
11
11
|
*
|
|
12
|
-
* The client's clock
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* The client's clock is used to generate the timestamp. For TTLs days in the
|
|
13
|
+
* future, this is generally not a concern. However, this function should not
|
|
14
|
+
* be depended on for short offsets.
|
|
15
15
|
*
|
|
16
|
-
* @param
|
|
16
|
+
* @param interval how far in the future to set the timestamp. It can be any
|
|
17
|
+
* combination of `days`, `hours`, `minutes`, `seconds`, and `millis`.
|
|
18
|
+
*
|
|
19
|
+
* @example const timestamp = futureTimestamp({days: 30});
|
|
17
20
|
*/
|
|
18
|
-
export declare function
|
|
21
|
+
export declare function futureTimestamp(interval: {
|
|
22
|
+
days?: number;
|
|
23
|
+
hours?: number;
|
|
24
|
+
minutes?: number;
|
|
25
|
+
seconds?: number;
|
|
26
|
+
millis?: number;
|
|
27
|
+
}): Timestamp;
|
|
19
28
|
/**
|
|
20
29
|
* Returns a sentinel to include a server-generated timestamp in the written
|
|
21
30
|
* data.
|
package/dist/timestamps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serverTimestampWithClientTime = exports.serverTimestamp = exports.
|
|
3
|
+
exports.serverTimestampWithClientTime = exports.serverTimestamp = exports.futureTimestamp = exports.timestampSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const firestore_deps_1 = require("./firestore-deps");
|
|
6
6
|
/**
|
|
@@ -12,16 +12,30 @@ exports.timestampSchema = zod_1.z.custom((data) => data instanceof firestore_dep
|
|
|
12
12
|
* Returns a Firestore Timestamp for some future date. The result is typically
|
|
13
13
|
* used for writing TTLs.
|
|
14
14
|
*
|
|
15
|
-
* The client's clock
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* The client's clock is used to generate the timestamp. For TTLs days in the
|
|
16
|
+
* future, this is generally not a concern. However, this function should not
|
|
17
|
+
* be depended on for short offsets.
|
|
18
18
|
*
|
|
19
|
-
* @param
|
|
19
|
+
* @param interval how far in the future to set the timestamp. It can be any
|
|
20
|
+
* combination of `days`, `hours`, `minutes`, `seconds`, and `millis`.
|
|
21
|
+
*
|
|
22
|
+
* @example const timestamp = futureTimestamp({days: 30});
|
|
20
23
|
*/
|
|
21
|
-
function
|
|
22
|
-
|
|
24
|
+
function futureTimestamp(interval) {
|
|
25
|
+
let utcMillis = Date.now();
|
|
26
|
+
if (interval.days)
|
|
27
|
+
utcMillis += interval.days * 24 * 60 * 60 * 1000;
|
|
28
|
+
if (interval.hours)
|
|
29
|
+
utcMillis += interval.hours * 60 * 60 * 1000;
|
|
30
|
+
if (interval.minutes)
|
|
31
|
+
utcMillis += interval.minutes * 60 * 1000;
|
|
32
|
+
if (interval.seconds)
|
|
33
|
+
utcMillis += interval.seconds * 1000;
|
|
34
|
+
if (interval.millis)
|
|
35
|
+
utcMillis += interval.millis;
|
|
36
|
+
return firestore_deps_1.Timestamp.fromMillis(utcMillis);
|
|
23
37
|
}
|
|
24
|
-
exports.
|
|
38
|
+
exports.futureTimestamp = futureTimestamp;
|
|
25
39
|
/**
|
|
26
40
|
* Returns a sentinel to include a server-generated timestamp in the written
|
|
27
41
|
* data.
|
package/dist/timestamps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timestamps.js","sourceRoot":"","sources":["../src/timestamps.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,qDAI0B;AAE1B;;;GAGG;AACU,QAAA,eAAe,GAAG,OAAC,CAAC,MAAM,CACrC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,YAAY,0BAAS,IAAI,IAAA,kCAAiB,EAAC,IAAI,CAAC,CACpE,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"timestamps.js","sourceRoot":"","sources":["../src/timestamps.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,qDAI0B;AAE1B;;;GAGG;AACU,QAAA,eAAe,GAAG,OAAC,CAAC,MAAM,CACrC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,YAAY,0BAAS,IAAI,IAAA,kCAAiB,EAAC,IAAI,CAAC,CACpE,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,SAAgB,eAAe,CAAC,QAM/B;IACC,IAAI,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAI,QAAQ,CAAC,IAAI;QAAE,SAAS,IAAI,QAAQ,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACpE,IAAI,QAAQ,CAAC,KAAK;QAAE,SAAS,IAAI,QAAQ,CAAC,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACjE,IAAI,QAAQ,CAAC,OAAO;QAAE,SAAS,IAAI,QAAQ,CAAC,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC;IAChE,IAAI,QAAQ,CAAC,OAAO;QAAE,SAAS,IAAI,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;IAC3D,IAAI,QAAQ,CAAC,MAAM;QAAE,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC;IAClD,OAAO,0BAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC;AAdD,0CAcC;AAED;;;;;;;GAOG;AACH,SAAgB,eAAe;IAC7B,OAAO,IAAA,gCAAwB,GAAe,CAAC;AACjD,CAAC;AAFD,0CAEC;AAED;;;;;;;;GAQG;AACH,SAAgB,6BAA6B;IAC3C,MAAM,QAAQ,GAAG,IAAA,gCAAwB,GAAE,CAAC;IAC5C,MAAM,SAAS,GAAG,0BAAS,CAAC,GAAG,EAAE,CAAC;IAClC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAClC,QAAgB,CAAC,OAAO,GAAG,CAAC,KAAgB,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1E,QAAgB,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IACnD,QAAgB,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACvD,QAAgB,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACvD,QAAgB,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IACtD,+DAA+D;IAC/D,iFAAiF;IACjF,sEAAsE;IACtE,OAAO,QAAqB,CAAC;AAC/B,CAAC;AAbD,sEAaC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "firetender",
|
|
3
3
|
"displayName": "Firetender",
|
|
4
4
|
"description": "Typescript wrapper for Firestore documents",
|
|
5
|
-
"version": "0.11.
|
|
5
|
+
"version": "0.11.2",
|
|
6
6
|
"author": "Jake Hartman",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/jakes-space/firetender",
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { FiretenderCollection } from "./FiretenderCollection";
|
|
|
9
9
|
import type { FiretenderDocOptions } from "./FiretenderDoc";
|
|
10
10
|
import { FiretenderDoc } from "./FiretenderDoc";
|
|
11
11
|
import {
|
|
12
|
-
|
|
12
|
+
futureTimestamp,
|
|
13
13
|
serverTimestamp,
|
|
14
14
|
serverTimestampWithClientTime,
|
|
15
15
|
timestampSchema,
|
|
@@ -23,7 +23,7 @@ export {
|
|
|
23
23
|
FiretenderInternalError,
|
|
24
24
|
FiretenderIOError,
|
|
25
25
|
FiretenderUsageError,
|
|
26
|
-
|
|
26
|
+
futureTimestamp,
|
|
27
27
|
serverTimestamp,
|
|
28
28
|
serverTimestampWithClientTime,
|
|
29
29
|
Timestamp,
|
package/src/timestamps.ts
CHANGED
|
@@ -18,14 +18,29 @@ export const timestampSchema = z.custom<Timestamp>(
|
|
|
18
18
|
* Returns a Firestore Timestamp for some future date. The result is typically
|
|
19
19
|
* used for writing TTLs.
|
|
20
20
|
*
|
|
21
|
-
* The client's clock
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* The client's clock is used to generate the timestamp. For TTLs days in the
|
|
22
|
+
* future, this is generally not a concern. However, this function should not
|
|
23
|
+
* be depended on for short offsets.
|
|
24
24
|
*
|
|
25
|
-
* @param
|
|
25
|
+
* @param interval how far in the future to set the timestamp. It can be any
|
|
26
|
+
* combination of `days`, `hours`, `minutes`, `seconds`, and `millis`.
|
|
27
|
+
*
|
|
28
|
+
* @example const timestamp = futureTimestamp({days: 30});
|
|
26
29
|
*/
|
|
27
|
-
export function
|
|
28
|
-
|
|
30
|
+
export function futureTimestamp(interval: {
|
|
31
|
+
days?: number;
|
|
32
|
+
hours?: number;
|
|
33
|
+
minutes?: number;
|
|
34
|
+
seconds?: number;
|
|
35
|
+
millis?: number;
|
|
36
|
+
}) {
|
|
37
|
+
let utcMillis = Date.now();
|
|
38
|
+
if (interval.days) utcMillis += interval.days * 24 * 60 * 60 * 1000;
|
|
39
|
+
if (interval.hours) utcMillis += interval.hours * 60 * 60 * 1000;
|
|
40
|
+
if (interval.minutes) utcMillis += interval.minutes * 60 * 1000;
|
|
41
|
+
if (interval.seconds) utcMillis += interval.seconds * 1000;
|
|
42
|
+
if (interval.millis) utcMillis += interval.millis;
|
|
43
|
+
return Timestamp.fromMillis(utcMillis);
|
|
29
44
|
}
|
|
30
45
|
|
|
31
46
|
/**
|