firetender 0.8.6 → 0.9.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/dist/index.d.ts +2 -2
- package/dist/index.js +4 -18
- package/dist/index.js.map +1 -1
- package/dist/timestamps.d.ts +30 -0
- package/dist/timestamps.js +33 -0
- package/dist/timestamps.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +3 -4
- package/src/timestamps.ts +32 -0
- package/dist/Timestamps.d.ts +0 -27
- package/dist/Timestamps.js +0 -38
- package/dist/Timestamps.js.map +0 -1
- package/src/Timestamps.ts +0 -38
package/dist/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import { FiretenderError, FiretenderInternalError, FiretenderIOError, Firetender
|
|
|
2
2
|
import { FiretenderCollection } from "./FiretenderCollection";
|
|
3
3
|
import type { FiretenderDocOptions } from "./FiretenderDoc";
|
|
4
4
|
import { FiretenderDoc } from "./FiretenderDoc";
|
|
5
|
-
|
|
6
|
-
export
|
|
5
|
+
import { futureTimestampDays, timestampSchema } from "./timestamps";
|
|
6
|
+
export { FiretenderCollection, FiretenderDoc, FiretenderDocOptions, FiretenderError, FiretenderInternalError, FiretenderIOError, FiretenderUsageError, futureTimestampDays, timestampSchema, };
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.FiretenderUsageError = exports.FiretenderIOError = exports.FiretenderInternalError = exports.FiretenderError = exports.FiretenderDoc = exports.FiretenderCollection = void 0;
|
|
3
|
+
exports.timestampSchema = exports.futureTimestampDays = exports.FiretenderUsageError = exports.FiretenderIOError = exports.FiretenderInternalError = exports.FiretenderError = exports.FiretenderDoc = exports.FiretenderCollection = void 0;
|
|
18
4
|
const errors_1 = require("./errors");
|
|
19
5
|
Object.defineProperty(exports, "FiretenderError", { enumerable: true, get: function () { return errors_1.FiretenderError; } });
|
|
20
6
|
Object.defineProperty(exports, "FiretenderInternalError", { enumerable: true, get: function () { return errors_1.FiretenderInternalError; } });
|
|
@@ -24,7 +10,7 @@ const FiretenderCollection_1 = require("./FiretenderCollection");
|
|
|
24
10
|
Object.defineProperty(exports, "FiretenderCollection", { enumerable: true, get: function () { return FiretenderCollection_1.FiretenderCollection; } });
|
|
25
11
|
const FiretenderDoc_1 = require("./FiretenderDoc");
|
|
26
12
|
Object.defineProperty(exports, "FiretenderDoc", { enumerable: true, get: function () { return FiretenderDoc_1.FiretenderDoc; } });
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
const timestamps_1 = require("./timestamps");
|
|
14
|
+
Object.defineProperty(exports, "futureTimestampDays", { enumerable: true, get: function () { return timestamps_1.futureTimestampDays; } });
|
|
15
|
+
Object.defineProperty(exports, "timestampSchema", { enumerable: true, get: function () { return timestamps_1.timestampSchema; } });
|
|
30
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qCAKkB;AAUhB,gGAdA,wBAAe,OAcA;AACf,wGAdA,gCAAuB,OAcA;AACvB,kGAdA,0BAAiB,OAcA;AACjB,qGAdA,6BAAoB,OAcA;AAZtB,iEAA8D;AAM5D,qGANO,2CAAoB,OAMP;AAJtB,mDAAgD;AAK9C,8FALO,6BAAa,OAKP;AAJf,6CAAoE;AAUlE,oGAVO,gCAAmB,OAUP;AACnB,gGAX4B,4BAAe,OAW5B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FieldValue, Timestamp } from "firebase/firestore";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Timestamp representation used by Firestore: seconds and nanoseconds since the
|
|
5
|
+
* epoch.
|
|
6
|
+
*/
|
|
7
|
+
export declare const timestampSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
8
|
+
seconds: z.ZodNumber;
|
|
9
|
+
nanoseconds: z.ZodNumber;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
seconds: number;
|
|
12
|
+
nanoseconds: number;
|
|
13
|
+
}, {
|
|
14
|
+
seconds: number;
|
|
15
|
+
nanoseconds: number;
|
|
16
|
+
}>, Timestamp, {
|
|
17
|
+
seconds: number;
|
|
18
|
+
nanoseconds: number;
|
|
19
|
+
}>, z.ZodType<FieldValue, z.ZodTypeDef, FieldValue>]>;
|
|
20
|
+
/**
|
|
21
|
+
* Returns a Firestore Timestamp for some future date. The result is typically
|
|
22
|
+
* used for writing TTLs.
|
|
23
|
+
*
|
|
24
|
+
* The client's clock (specifically `Date.now()`) is used to generate the
|
|
25
|
+
* timestamp. For TTLs days in the future, this is generally not a concern.
|
|
26
|
+
* However, this function should not be depended on for short offsets.
|
|
27
|
+
*
|
|
28
|
+
* @param daysFromNow days in the future to set this Timestamp.
|
|
29
|
+
*/
|
|
30
|
+
export declare function futureTimestampDays(daysFromNow: number): Timestamp;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.futureTimestampDays = exports.timestampSchema = void 0;
|
|
4
|
+
const firestore_1 = require("firebase/firestore");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
/**
|
|
7
|
+
* Timestamp representation used by Firestore: seconds and nanoseconds since the
|
|
8
|
+
* epoch.
|
|
9
|
+
*/
|
|
10
|
+
exports.timestampSchema = zod_1.z.union([
|
|
11
|
+
zod_1.z
|
|
12
|
+
.object({
|
|
13
|
+
seconds: zod_1.z.number().positive().int(),
|
|
14
|
+
nanoseconds: zod_1.z.number().nonnegative().int(),
|
|
15
|
+
})
|
|
16
|
+
.transform(({ seconds, nanoseconds }) => new firestore_1.Timestamp(seconds, nanoseconds)),
|
|
17
|
+
zod_1.z.custom((value) => value._methodName === "serverTimestamp"),
|
|
18
|
+
]);
|
|
19
|
+
/**
|
|
20
|
+
* Returns a Firestore Timestamp for some future date. The result is typically
|
|
21
|
+
* used for writing TTLs.
|
|
22
|
+
*
|
|
23
|
+
* The client's clock (specifically `Date.now()`) is used to generate the
|
|
24
|
+
* timestamp. For TTLs days in the future, this is generally not a concern.
|
|
25
|
+
* However, this function should not be depended on for short offsets.
|
|
26
|
+
*
|
|
27
|
+
* @param daysFromNow days in the future to set this Timestamp.
|
|
28
|
+
*/
|
|
29
|
+
function futureTimestampDays(daysFromNow) {
|
|
30
|
+
return firestore_1.Timestamp.fromMillis(Date.now() + daysFromNow * 24 * 60 * 60 * 1000);
|
|
31
|
+
}
|
|
32
|
+
exports.futureTimestampDays = futureTimestampDays;
|
|
33
|
+
//# sourceMappingURL=timestamps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamps.js","sourceRoot":"","sources":["../src/timestamps.ts"],"names":[],"mappings":";;;AAAA,kDAA2D;AAC3D,6BAAwB;AAExB;;;GAGG;AACU,QAAA,eAAe,GAAG,OAAC,CAAC,KAAK,CAAC;IACrC,OAAC;SACE,MAAM,CAAC;QACN,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE;QACpC,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE;KAC5C,CAAC;SACD,SAAS,CACR,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,IAAI,qBAAS,CAAC,OAAO,EAAE,WAAW,CAAC,CAClE;IACH,OAAC,CAAC,MAAM,CAAa,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,iBAAiB,CAAC;CAC9E,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CAAC,WAAmB;IACrD,OAAO,qBAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AAC9E,CAAC;AAFD,kDAEC"}
|
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.
|
|
5
|
+
"version": "0.9.0",
|
|
6
6
|
"author": "Jake Hartman",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/jakes-space/firetender",
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { FiretenderCollection } from "./FiretenderCollection";
|
|
8
8
|
import type { FiretenderDocOptions } from "./FiretenderDoc";
|
|
9
9
|
import { FiretenderDoc } from "./FiretenderDoc";
|
|
10
|
+
import { futureTimestampDays, timestampSchema } from "./timestamps";
|
|
10
11
|
|
|
11
12
|
export {
|
|
12
13
|
FiretenderCollection,
|
|
@@ -16,8 +17,6 @@ export {
|
|
|
16
17
|
FiretenderInternalError,
|
|
17
18
|
FiretenderIOError,
|
|
18
19
|
FiretenderUsageError,
|
|
20
|
+
futureTimestampDays,
|
|
21
|
+
timestampSchema,
|
|
19
22
|
};
|
|
20
|
-
|
|
21
|
-
// TODO #6, #9, #10: stop using a direct export after the timestamp module gets
|
|
22
|
-
// cleaned up.
|
|
23
|
-
export * from "./Timestamps";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FieldValue, Timestamp } from "firebase/firestore";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Timestamp representation used by Firestore: seconds and nanoseconds since the
|
|
6
|
+
* epoch.
|
|
7
|
+
*/
|
|
8
|
+
export const timestampSchema = z.union([
|
|
9
|
+
z
|
|
10
|
+
.object({
|
|
11
|
+
seconds: z.number().positive().int(),
|
|
12
|
+
nanoseconds: z.number().nonnegative().int(),
|
|
13
|
+
})
|
|
14
|
+
.transform(
|
|
15
|
+
({ seconds, nanoseconds }) => new Timestamp(seconds, nanoseconds)
|
|
16
|
+
),
|
|
17
|
+
z.custom<FieldValue>((value: any) => value._methodName === "serverTimestamp"),
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns a Firestore Timestamp for some future date. The result is typically
|
|
22
|
+
* used for writing TTLs.
|
|
23
|
+
*
|
|
24
|
+
* The client's clock (specifically `Date.now()`) is used to generate the
|
|
25
|
+
* timestamp. For TTLs days in the future, this is generally not a concern.
|
|
26
|
+
* However, this function should not be depended on for short offsets.
|
|
27
|
+
*
|
|
28
|
+
* @param daysFromNow days in the future to set this Timestamp.
|
|
29
|
+
*/
|
|
30
|
+
export function futureTimestampDays(daysFromNow: number) {
|
|
31
|
+
return Timestamp.fromMillis(Date.now() + daysFromNow * 24 * 60 * 60 * 1000);
|
|
32
|
+
}
|
package/dist/Timestamps.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* Timestamp representation used by Firestore: seconds and nanoseconds since the
|
|
4
|
-
* epoch.
|
|
5
|
-
*/
|
|
6
|
-
export declare const timestampSchema: z.ZodObject<{
|
|
7
|
-
seconds: z.ZodNumber;
|
|
8
|
-
nanoseconds: z.ZodNumber;
|
|
9
|
-
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
seconds: number;
|
|
11
|
-
nanoseconds: number;
|
|
12
|
-
}, {
|
|
13
|
-
seconds: number;
|
|
14
|
-
nanoseconds: number;
|
|
15
|
-
}>;
|
|
16
|
-
export type TimestampData = z.infer<typeof timestampSchema>;
|
|
17
|
-
export declare function dateFromTimestamp(timestamp: TimestampData): Date;
|
|
18
|
-
export declare function makeTTL(daysFromNow?: number): {
|
|
19
|
-
seconds: number;
|
|
20
|
-
nanoseconds: number;
|
|
21
|
-
};
|
|
22
|
-
export declare function timestampFromDate(date: Date): TimestampData;
|
|
23
|
-
export declare function timestampFromUnixMillis(msSinceEpoch: number): TimestampData;
|
|
24
|
-
export declare function nowTimestamp(): {
|
|
25
|
-
seconds: number;
|
|
26
|
-
nanoseconds: number;
|
|
27
|
-
};
|
package/dist/Timestamps.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.nowTimestamp = exports.timestampFromUnixMillis = exports.timestampFromDate = exports.makeTTL = exports.dateFromTimestamp = exports.timestampSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
/**
|
|
6
|
-
* Timestamp representation used by Firestore: seconds and nanoseconds since the
|
|
7
|
-
* epoch.
|
|
8
|
-
*/
|
|
9
|
-
exports.timestampSchema = zod_1.z.object({
|
|
10
|
-
seconds: zod_1.z.number().positive().int(),
|
|
11
|
-
nanoseconds: zod_1.z.number().nonnegative().int(),
|
|
12
|
-
});
|
|
13
|
-
function dateFromTimestamp(timestamp) {
|
|
14
|
-
return new Date(timestamp.seconds * 1e3 + timestamp.nanoseconds / 1e6);
|
|
15
|
-
}
|
|
16
|
-
exports.dateFromTimestamp = dateFromTimestamp;
|
|
17
|
-
function makeTTL(daysFromNow = 30) {
|
|
18
|
-
// TODO: #10 is there a way to use the server time rather than Date.now()?
|
|
19
|
-
return timestampFromUnixMillis(Date.now() + daysFromNow * 24 * 60 * 60 * 1000);
|
|
20
|
-
}
|
|
21
|
-
exports.makeTTL = makeTTL;
|
|
22
|
-
function timestampFromDate(date) {
|
|
23
|
-
return timestampFromUnixMillis(date.getTime());
|
|
24
|
-
}
|
|
25
|
-
exports.timestampFromDate = timestampFromDate;
|
|
26
|
-
function timestampFromUnixMillis(msSinceEpoch) {
|
|
27
|
-
return {
|
|
28
|
-
seconds: Math.floor(msSinceEpoch / 1000),
|
|
29
|
-
nanoseconds: Math.floor((msSinceEpoch % 1000) * 1000000),
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
exports.timestampFromUnixMillis = timestampFromUnixMillis;
|
|
33
|
-
function nowTimestamp() {
|
|
34
|
-
// TODO: #9 is there a way to use the server time rather than Date.now()?
|
|
35
|
-
return timestampFromUnixMillis(Date.now());
|
|
36
|
-
}
|
|
37
|
-
exports.nowTimestamp = nowTimestamp;
|
|
38
|
-
//# sourceMappingURL=Timestamps.js.map
|
package/dist/Timestamps.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Timestamps.js","sourceRoot":"","sources":["../src/Timestamps.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB;;;GAGG;AACU,QAAA,eAAe,GAAG,OAAC,CAAC,MAAM,CAAC;IACtC,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE;IACpC,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE;CAC5C,CAAC,CAAC;AAGH,SAAgB,iBAAiB,CAAC,SAAwB;IACxD,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,GAAG,GAAG,SAAS,CAAC,WAAW,GAAG,GAAG,CAAC,CAAC;AACzE,CAAC;AAFD,8CAEC;AAED,SAAgB,OAAO,CAAC,WAAW,GAAG,EAAE;IACtC,0EAA0E;IAC1E,OAAO,uBAAuB,CAC5B,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAC/C,CAAC;AACJ,CAAC;AALD,0BAKC;AAED,SAAgB,iBAAiB,CAAC,IAAU;IAC1C,OAAO,uBAAuB,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;AACjD,CAAC;AAFD,8CAEC;AAED,SAAgB,uBAAuB,CAAC,YAAoB;IAC1D,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;QACxC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC;KACzD,CAAC;AACJ,CAAC;AALD,0DAKC;AAED,SAAgB,YAAY;IAC1B,yEAAyE;IACzE,OAAO,uBAAuB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;AAC7C,CAAC;AAHD,oCAGC"}
|
package/src/Timestamps.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Timestamp representation used by Firestore: seconds and nanoseconds since the
|
|
5
|
-
* epoch.
|
|
6
|
-
*/
|
|
7
|
-
export const timestampSchema = z.object({
|
|
8
|
-
seconds: z.number().positive().int(),
|
|
9
|
-
nanoseconds: z.number().nonnegative().int(),
|
|
10
|
-
});
|
|
11
|
-
export type TimestampData = z.infer<typeof timestampSchema>;
|
|
12
|
-
|
|
13
|
-
export function dateFromTimestamp(timestamp: TimestampData): Date {
|
|
14
|
-
return new Date(timestamp.seconds * 1e3 + timestamp.nanoseconds / 1e6);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function makeTTL(daysFromNow = 30) {
|
|
18
|
-
// TODO: #10 is there a way to use the server time rather than Date.now()?
|
|
19
|
-
return timestampFromUnixMillis(
|
|
20
|
-
Date.now() + daysFromNow * 24 * 60 * 60 * 1000
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function timestampFromDate(date: Date): TimestampData {
|
|
25
|
-
return timestampFromUnixMillis(date.getTime());
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function timestampFromUnixMillis(msSinceEpoch: number): TimestampData {
|
|
29
|
-
return {
|
|
30
|
-
seconds: Math.floor(msSinceEpoch / 1000),
|
|
31
|
-
nanoseconds: Math.floor((msSinceEpoch % 1000) * 1000000),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function nowTimestamp() {
|
|
36
|
-
// TODO: #9 is there a way to use the server time rather than Date.now()?
|
|
37
|
-
return timestampFromUnixMillis(Date.now());
|
|
38
|
-
}
|