@twasik4/pocket-service 1.0.4 → 1.1.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/CHANGELOG.md +34 -0
- package/LICENSE +21 -0
- package/README.md +637 -297
- package/dist/index.d.mts +747 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -0
- package/dist/runtime/worker-thread.d.mts +1 -0
- package/dist/runtime/worker-thread.mjs +2 -0
- package/dist/runtime/worker-thread.mjs.map +1 -0
- package/package.json +53 -10
- package/dist/index.d.ts +0 -734
- package/dist/index.js +0 -6
- package/dist/index.js.map +0 -1
- package/dist/worker-thread.d.ts +0 -2
- package/dist/worker-thread.js +0 -2
- package/dist/worker-thread.js.map +0 -1
- package/src/index.ts +0 -1
- package/src/worker-thread.ts +0 -159
- package/src/workers/auth/strategies.ts +0 -304
- package/src/workers/db/clickhouse/index.ts +0 -76
- package/src/workers/db/mongo/collection.ts +0 -293
- package/src/workers/db/mongo/mongo.ts +0 -401
- package/src/workers/express-types.ts +0 -442
- package/src/workers/index.ts +0 -7
- package/src/workers/logger.ts +0 -19
- package/src/workers/service.ts +0 -1015
- package/src/workers/stream-handler.ts +0 -25
- package/src/workers/types.ts +0 -59
- package/src/workers/utils.ts +0 -19
- package/tests/auth-strategies.spec.ts +0 -150
- package/tests/clickhouse.spec.ts +0 -102
- package/tests/express-types.spec.ts +0 -232
- package/tests/mongo-advanced.spec.ts +0 -172
- package/tests/mongo.spec.ts +0 -141
- package/tests/redis.spec.ts +0 -36
- package/tests/service.spec.ts +0 -82
- package/tests/utils.spec.ts +0 -30
- package/tsconfig.json +0 -12
- package/tsup.config.ts +0 -11
- package/vitest.config.ts +0 -8
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/// <reference types="vitest/globals" />
|
|
2
|
-
import { MongoMemoryServer } from "mongodb-memory-server";
|
|
3
|
-
import { ObjectId } from "mongodb";
|
|
4
|
-
import z from "zod";
|
|
5
|
-
import {
|
|
6
|
-
createMongo,
|
|
7
|
-
defineMongoCollection,
|
|
8
|
-
type MongoCollectionsConfig,
|
|
9
|
-
} from "../src/workers/db/mongo/mongo";
|
|
10
|
-
|
|
11
|
-
describe("Mongo abstraction advanced behaviors", () => {
|
|
12
|
-
let mongoServer: MongoMemoryServer;
|
|
13
|
-
|
|
14
|
-
beforeAll(async () => {
|
|
15
|
-
mongoServer = await MongoMemoryServer.create();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
afterAll(async () => {
|
|
19
|
-
await mongoServer.stop();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("supports soft delete filtering and deletedBy attribution", async () => {
|
|
23
|
-
const mongo = createMongo(
|
|
24
|
-
"soft_delete_db",
|
|
25
|
-
{
|
|
26
|
-
users: defineMongoCollection({
|
|
27
|
-
schema: z.object({
|
|
28
|
-
name: z.string(),
|
|
29
|
-
deletedAt: z.date().optional(),
|
|
30
|
-
deletedBy: z.string().optional(),
|
|
31
|
-
}),
|
|
32
|
-
}),
|
|
33
|
-
},
|
|
34
|
-
{ uri: mongoServer.getUri() },
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
await mongo.connect();
|
|
38
|
-
|
|
39
|
-
await mongo.users.insert({ name: "Ada" });
|
|
40
|
-
await mongo.users.delete({ name: "Ada" });
|
|
41
|
-
|
|
42
|
-
await mongo.users.insert({ name: "Grace" });
|
|
43
|
-
await mongo.users.delete({ name: "Grace" }, "admin-user");
|
|
44
|
-
|
|
45
|
-
const visible = await mongo.users.get({ name: "Ada" });
|
|
46
|
-
const rawAda = await mongo.db.collection("users").findOne({ name: "Ada" });
|
|
47
|
-
const rawGrace = await mongo.db.collection("users").findOne({
|
|
48
|
-
name: "Grace",
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
expect(visible).toEqual([]);
|
|
52
|
-
expect(rawAda?.deletedAt).toBeInstanceOf(Date);
|
|
53
|
-
expect(rawAda?.deletedBy).toBe("system");
|
|
54
|
-
expect(rawGrace?.deletedBy).toBe("admin-user");
|
|
55
|
-
|
|
56
|
-
await mongo.disconnect();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("tracks revisions and updates updatedAt/revision on updateOne", async () => {
|
|
60
|
-
const config = {
|
|
61
|
-
records: {
|
|
62
|
-
...defineMongoCollection({
|
|
63
|
-
schema: z.object({
|
|
64
|
-
key: z.string(),
|
|
65
|
-
value: z.string(),
|
|
66
|
-
revision: z.number().default(0),
|
|
67
|
-
updatedAt: z.date().optional(),
|
|
68
|
-
}),
|
|
69
|
-
}),
|
|
70
|
-
trackRevisions: true,
|
|
71
|
-
},
|
|
72
|
-
} satisfies MongoCollectionsConfig;
|
|
73
|
-
|
|
74
|
-
const mongo = createMongo("revisions_db", config, {
|
|
75
|
-
uri: mongoServer.getUri(),
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
await mongo.connect();
|
|
79
|
-
|
|
80
|
-
await mongo.records.insert({
|
|
81
|
-
key: "k1",
|
|
82
|
-
value: "v1",
|
|
83
|
-
revision: 0,
|
|
84
|
-
updatedAt: new Date("2020-01-01T00:00:00.000Z"),
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
await mongo.records.updateOne({ key: "k1" }, { value: "v2" });
|
|
88
|
-
|
|
89
|
-
const current = await mongo.records.getOne({ key: "k1" });
|
|
90
|
-
const revisions = await mongo.records.getRevisions({ key: "k1" });
|
|
91
|
-
const mostRecent = await mongo.records.getMostRecentRevision();
|
|
92
|
-
|
|
93
|
-
expect(current?.value).toBe("v2");
|
|
94
|
-
expect(current?.revision).toBe(1);
|
|
95
|
-
expect(current?.updatedAt).toBeInstanceOf(Date);
|
|
96
|
-
expect(revisions.length).toBeGreaterThanOrEqual(2);
|
|
97
|
-
expect(mostRecent?.value).toBe("v2");
|
|
98
|
-
|
|
99
|
-
await mongo.disconnect();
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("creates configured indexes during setup", async () => {
|
|
103
|
-
const mongo = createMongo(
|
|
104
|
-
"index_setup_db",
|
|
105
|
-
{
|
|
106
|
-
users: defineMongoCollection({
|
|
107
|
-
schema: z.object({
|
|
108
|
-
email: z.string(),
|
|
109
|
-
createdAt: z.date(),
|
|
110
|
-
}),
|
|
111
|
-
indexes: [
|
|
112
|
-
{ key: { email: 1 }, unique: true, name: "users_email_unique" },
|
|
113
|
-
{ key: { createdAt: 1 }, name: "users_created_at" },
|
|
114
|
-
],
|
|
115
|
-
}),
|
|
116
|
-
},
|
|
117
|
-
{ uri: mongoServer.getUri() },
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
await mongo.connect();
|
|
121
|
-
|
|
122
|
-
const indexes = await mongo.db.collection("users").indexes();
|
|
123
|
-
|
|
124
|
-
expect(indexes.some((idx) => idx.name === "users_email_unique")).toBe(true);
|
|
125
|
-
expect(indexes.some((idx) => idx.name === "users_created_at")).toBe(true);
|
|
126
|
-
|
|
127
|
-
await mongo.disconnect();
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("fails when enabling timeSeries on an existing non-time-series collection", async () => {
|
|
131
|
-
const dbName = `timeseries_mismatch_${new ObjectId().toHexString()}`;
|
|
132
|
-
|
|
133
|
-
const initial = createMongo(
|
|
134
|
-
dbName,
|
|
135
|
-
{
|
|
136
|
-
metrics: defineMongoCollection({
|
|
137
|
-
schema: z.object({
|
|
138
|
-
timestamp: z.date(),
|
|
139
|
-
value: z.number(),
|
|
140
|
-
}),
|
|
141
|
-
}),
|
|
142
|
-
},
|
|
143
|
-
{ uri: mongoServer.getUri() },
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
await initial.connect();
|
|
147
|
-
await initial.db.createCollection("legacy_metrics");
|
|
148
|
-
await initial.disconnect();
|
|
149
|
-
|
|
150
|
-
const withTimeSeries = createMongo(
|
|
151
|
-
dbName,
|
|
152
|
-
{
|
|
153
|
-
legacy_metrics: defineMongoCollection({
|
|
154
|
-
schema: z.object({
|
|
155
|
-
timestamp: z.date(),
|
|
156
|
-
value: z.number(),
|
|
157
|
-
}),
|
|
158
|
-
timeSeries: {
|
|
159
|
-
timeField: "timestamp",
|
|
160
|
-
},
|
|
161
|
-
}),
|
|
162
|
-
},
|
|
163
|
-
{ uri: mongoServer.getUri() },
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
await expect(withTimeSeries.connect()).rejects.toThrow(
|
|
167
|
-
"already exists and is not a time-series collection",
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
await withTimeSeries.disconnect();
|
|
171
|
-
});
|
|
172
|
-
});
|
package/tests/mongo.spec.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/// <reference types="vitest/globals" />
|
|
2
|
-
import z from "zod";
|
|
3
|
-
import {
|
|
4
|
-
defineMongoCollection,
|
|
5
|
-
MongoCollectionDefinition,
|
|
6
|
-
} from "../src/workers/db/mongo/mongo";
|
|
7
|
-
import { MongoMemoryServer } from "mongodb-memory-server";
|
|
8
|
-
import { Service } from "../src/workers/service";
|
|
9
|
-
|
|
10
|
-
describe("MongoDB Dependency", () => {
|
|
11
|
-
let service: Service<{
|
|
12
|
-
testCollection: MongoCollectionDefinition<
|
|
13
|
-
{
|
|
14
|
-
name: string;
|
|
15
|
-
},
|
|
16
|
-
{}
|
|
17
|
-
>;
|
|
18
|
-
}>;
|
|
19
|
-
let mongoServer: MongoMemoryServer;
|
|
20
|
-
|
|
21
|
-
beforeAll(async () => {
|
|
22
|
-
mongoServer = await MongoMemoryServer.create();
|
|
23
|
-
const uri = mongoServer.getUri();
|
|
24
|
-
service = new Service()
|
|
25
|
-
.withName("admin-service")
|
|
26
|
-
.withPort(4120)
|
|
27
|
-
.withRedis("redis://localhost:6379")
|
|
28
|
-
.withMongo({
|
|
29
|
-
dbName: "test",
|
|
30
|
-
uri,
|
|
31
|
-
collections: {
|
|
32
|
-
testCollection: defineMongoCollection({
|
|
33
|
-
schema: z.object({
|
|
34
|
-
name: z.string(),
|
|
35
|
-
}),
|
|
36
|
-
}),
|
|
37
|
-
},
|
|
38
|
-
})
|
|
39
|
-
.build();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
afterEach(async () => {
|
|
43
|
-
await service.db.testCollection.delete({});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
afterAll(async () => {
|
|
47
|
-
await mongoServer.stop();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("Should contain the custom collection", () => {
|
|
51
|
-
expect(service.db).toHaveProperty("testCollection");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("Should not contain undefined collection", () => {
|
|
55
|
-
expect(() => service.db).not.toHaveProperty("undefinedCollection");
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("Should be initialized", () => {
|
|
59
|
-
expect(() => service.mongo).not.toThrow();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("Should return an empty array when getting from an empty collection", async () => {
|
|
63
|
-
const res = await service.db.testCollection.get();
|
|
64
|
-
expect(res).toEqual([]);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("Should insert and retrieve documents correctly", async () => {
|
|
68
|
-
await service.db.testCollection.insert({ name: "test" });
|
|
69
|
-
const res = await service.db.testCollection.get({});
|
|
70
|
-
expect(res.length).toBe(1);
|
|
71
|
-
expect(res[0].name).toEqual("test");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("Should delete documents correctly", async () => {
|
|
75
|
-
await service.db.testCollection.insert({ name: "toDelete" });
|
|
76
|
-
await service.db.testCollection.delete({ name: "toDelete" });
|
|
77
|
-
const res = await service.db.testCollection.get({ name: "toDelete" });
|
|
78
|
-
expect(res).toEqual([]);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("Should update documents correctly", async () => {
|
|
82
|
-
await service.db.testCollection.insert({ name: "toUpdate" });
|
|
83
|
-
await service.db.testCollection.updateOne(
|
|
84
|
-
{ name: "toUpdate" },
|
|
85
|
-
{ name: "updated" },
|
|
86
|
-
);
|
|
87
|
-
const res = await service.db.testCollection.get({ name: "updated" });
|
|
88
|
-
expect(res.length).toBe(1);
|
|
89
|
-
expect(res[0].name).toEqual("updated");
|
|
90
|
-
console.log("Updated document:", res[0]);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("Should support creating and using time-series collections", async () => {
|
|
94
|
-
const tsService = new Service()
|
|
95
|
-
.withName("admin-service")
|
|
96
|
-
.withPort(4121)
|
|
97
|
-
.withRedis("redis://localhost:6379")
|
|
98
|
-
.withMongo({
|
|
99
|
-
dbName: "test_timeseries",
|
|
100
|
-
uri: mongoServer.getUri(),
|
|
101
|
-
collections: {
|
|
102
|
-
metrics: defineMongoCollection({
|
|
103
|
-
schema: z.object({
|
|
104
|
-
timestamp: z.date(),
|
|
105
|
-
host: z.string(),
|
|
106
|
-
value: z.number(),
|
|
107
|
-
}),
|
|
108
|
-
timeSeries: {
|
|
109
|
-
timeField: "timestamp",
|
|
110
|
-
metaField: "host",
|
|
111
|
-
granularity: "seconds",
|
|
112
|
-
},
|
|
113
|
-
}),
|
|
114
|
-
},
|
|
115
|
-
})
|
|
116
|
-
.build();
|
|
117
|
-
|
|
118
|
-
await tsService.mongo.connect();
|
|
119
|
-
|
|
120
|
-
const collectionInfo = await tsService.mongo.db
|
|
121
|
-
.listCollections({ name: "metrics" }, { nameOnly: false })
|
|
122
|
-
.next();
|
|
123
|
-
|
|
124
|
-
expect(
|
|
125
|
-
collectionInfo?.type === "timeseries" ||
|
|
126
|
-
Boolean((collectionInfo?.options as any)?.timeseries),
|
|
127
|
-
).toBe(true);
|
|
128
|
-
|
|
129
|
-
await tsService.db.metrics.insert({
|
|
130
|
-
timestamp: new Date(),
|
|
131
|
-
host: "app-1",
|
|
132
|
-
value: 42,
|
|
133
|
-
});
|
|
134
|
-
const values = await tsService.db.metrics.get({ host: "app-1" });
|
|
135
|
-
|
|
136
|
-
expect(values.length).toBe(1);
|
|
137
|
-
expect(values[0].value).toBe(42);
|
|
138
|
-
|
|
139
|
-
await tsService.mongo.disconnect();
|
|
140
|
-
});
|
|
141
|
-
});
|
package/tests/redis.spec.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/// <reference types="vitest/globals" />
|
|
2
|
-
import { Service } from "../src/workers/service";
|
|
3
|
-
|
|
4
|
-
describe("Redis Dependency", () => {
|
|
5
|
-
let service: Service<{}>;
|
|
6
|
-
|
|
7
|
-
beforeAll(async () => {
|
|
8
|
-
service = new Service()
|
|
9
|
-
.withName("admin-service")
|
|
10
|
-
.withPort(3103)
|
|
11
|
-
.withRedis("redis://localhost:6379")
|
|
12
|
-
.build();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("Should not throw an error when accessing redis", () => {
|
|
16
|
-
expect(() => service.redis).not.toThrow();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it.skip("Should automatically register the service to redis", async () => {
|
|
20
|
-
const value = await service.redis.get("services:registry:admin-service");
|
|
21
|
-
expect(value).toBeDefined();
|
|
22
|
-
const parsedValue = JSON.parse(value!);
|
|
23
|
-
expect(parsedValue.name).equal("admin-service");
|
|
24
|
-
expect(parsedValue.streamKey).equal("admin:events");
|
|
25
|
-
expect(parsedValue.url).equal("http://admin-service:3103");
|
|
26
|
-
expect(parsedValue.dependencies).toEqual([]);
|
|
27
|
-
expect(parsedValue.routes).toBeInstanceOf(Array);
|
|
28
|
-
expect(
|
|
29
|
-
parsedValue.routes.some(
|
|
30
|
-
(s: any) => s.method === "GET" && s.path === "/health",
|
|
31
|
-
),
|
|
32
|
-
).toBeTruthy();
|
|
33
|
-
expect(parsedValue.routes.length).toBeGreaterThan(0);
|
|
34
|
-
expect(parsedValue.lastHeartbeat).toBeDefined();
|
|
35
|
-
});
|
|
36
|
-
});
|
package/tests/service.spec.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/// <reference types="vitest/globals" />
|
|
2
|
-
import z from "zod";
|
|
3
|
-
import { defineMongoCollection } from "../src/workers/db/mongo/mongo";
|
|
4
|
-
import { MongoMemoryServer } from "mongodb-memory-server";
|
|
5
|
-
import { Service } from "../src/workers/service";
|
|
6
|
-
import { CustomDependencies } from "../src/workers/types";
|
|
7
|
-
|
|
8
|
-
describe("Service Class", () => {
|
|
9
|
-
it("Should be able to be initialized", async () => {
|
|
10
|
-
const service = new Service()
|
|
11
|
-
.withName("admin-service")
|
|
12
|
-
.withPort(3000)
|
|
13
|
-
.build();
|
|
14
|
-
expect(service.simpleName).toBe("admin");
|
|
15
|
-
expect(() => service.log.info("Service initialized")).not.toThrow();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("Should throw error if accessing uninitialized dependencies", async () => {
|
|
19
|
-
const service = new Service().withName("admin-service").build();
|
|
20
|
-
expect(() => service.redis).toThrow("Redis module has not been added.");
|
|
21
|
-
expect(() => service.clickhouse).toThrow(
|
|
22
|
-
"Clickhouse module has not been added.",
|
|
23
|
-
);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("Should initialize Redis dependency", async () => {
|
|
27
|
-
const service = new Service()
|
|
28
|
-
.withName("admin-service")
|
|
29
|
-
.withRedis("redis://localhost:6379")
|
|
30
|
-
.build();
|
|
31
|
-
expect(() => service.redis).not.toThrow();
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("Should initialize MongoDB dependency", async () => {
|
|
35
|
-
const mongoServer = await MongoMemoryServer.create();
|
|
36
|
-
const uri = mongoServer.getUri();
|
|
37
|
-
const service = new Service()
|
|
38
|
-
.withName("admin-service")
|
|
39
|
-
.withPort(4120)
|
|
40
|
-
.withRedis("redis://localhost:6379")
|
|
41
|
-
.withMongo({
|
|
42
|
-
dbName: "test",
|
|
43
|
-
uri,
|
|
44
|
-
collections: {
|
|
45
|
-
testCollection: defineMongoCollection({
|
|
46
|
-
schema: z.object({
|
|
47
|
-
name: z.string(),
|
|
48
|
-
}),
|
|
49
|
-
}),
|
|
50
|
-
},
|
|
51
|
-
})
|
|
52
|
-
.build();
|
|
53
|
-
|
|
54
|
-
expect(() => service.mongo).not.toThrow();
|
|
55
|
-
await mongoServer.stop();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("Should allow custom dependencies", async () => {
|
|
59
|
-
const service = new Service()
|
|
60
|
-
.withName("admin-service")
|
|
61
|
-
.withPort(4120)
|
|
62
|
-
.withModules([
|
|
63
|
-
{
|
|
64
|
-
name: "doSomething",
|
|
65
|
-
init: async (log) => {
|
|
66
|
-
log.info("Initializing custom dependency");
|
|
67
|
-
return true;
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
])
|
|
71
|
-
.withRedis("redis://localhost:6379")
|
|
72
|
-
.build();
|
|
73
|
-
expect(service["dependencies"].has("customDependencies")).toBe(true);
|
|
74
|
-
const customDeps = service["dependencies"].get(
|
|
75
|
-
"customDependencies",
|
|
76
|
-
) as CustomDependencies;
|
|
77
|
-
expect(customDeps).toBeDefined();
|
|
78
|
-
expect(customDeps[0].name).toBe("doSomething");
|
|
79
|
-
expect(await customDeps[0].init(service.log)).toBe(true);
|
|
80
|
-
expect(customDeps[0].shutdown).toBeUndefined();
|
|
81
|
-
});
|
|
82
|
-
});
|
package/tests/utils.spec.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/// <reference types="vitest/globals" />
|
|
2
|
-
import {
|
|
3
|
-
generateRandomHexString,
|
|
4
|
-
getUseableDatesFromMs,
|
|
5
|
-
} from "../src/workers/utils";
|
|
6
|
-
|
|
7
|
-
describe("Utils", () => {
|
|
8
|
-
it("generates a hex string of the requested length", () => {
|
|
9
|
-
const value = generateRandomHexString(16);
|
|
10
|
-
expect(value).toHaveLength(16);
|
|
11
|
-
expect(value).toMatch(/^[0-9a-f]+$/);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("throws when requested length is odd", () => {
|
|
15
|
-
expect(() => generateRandomHexString(3)).toThrow(
|
|
16
|
-
"Length must be an even number",
|
|
17
|
-
);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("converts milliseconds to day/hour/minute/second parts", () => {
|
|
21
|
-
const ms =
|
|
22
|
-
2 * 24 * 60 * 60 * 1000 + 3 * 60 * 60 * 1000 + 4 * 60 * 1000 + 5 * 1000;
|
|
23
|
-
expect(getUseableDatesFromMs(ms)).toEqual({
|
|
24
|
-
days: 2,
|
|
25
|
-
hours: 3,
|
|
26
|
-
minutes: 4,
|
|
27
|
-
seconds: 5,
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "src",
|
|
5
|
-
"outDir": "dist",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"emitDeclarationOnly": false
|
|
9
|
-
},
|
|
10
|
-
"include": ["src"],
|
|
11
|
-
"exclude": ["node_modules", "dist"]
|
|
12
|
-
}
|
package/tsup.config.ts
DELETED