@forklaunch/core 0.19.5 → 1.0.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.
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Type representing a TTL (Time-To-Live) cache record.
3
+ *
4
+ * @typedef {Object} TtlCacheRecord
5
+ * @property {string} key - The key of the cache record.
6
+ * @property {any} value - The value of the cache record.
7
+ * @property {number} ttlMilliseconds - The time-to-live of the cache record in milliseconds.
8
+ */
9
+ type TtlCacheRecord<T> = {
10
+ key: string;
11
+ value: T;
12
+ ttlMilliseconds: number;
13
+ };
14
+
15
+ /**
16
+ * Interface representing a TTL (Time-To-Live) cache.
17
+ */
18
+ interface TtlCache {
19
+ /**
20
+ * Puts a record into the cache.
21
+ *
22
+ * @param {TtlCacheRecord} cacheRecord - The cache record to put into the cache.
23
+ * @returns {Promise<void>} - A promise that resolves when the record is put into the cache.
24
+ */
25
+ putRecord<T>(cacheRecord: TtlCacheRecord<T>): Promise<void>;
26
+ /**
27
+ * Puts a batch of records into the cache.
28
+ *
29
+ * @param {TtlCacheRecord<T>[]} cacheRecords - The cache records to put into the cache.
30
+ * @returns {Promise<void>} - A promise that resolves when the records are put into the cache.
31
+ */
32
+ putBatchRecords<T>(cacheRecords: TtlCacheRecord<T>[]): Promise<void>;
33
+ /**
34
+ * Enqueues a record into the cache.
35
+ *
36
+ * @param {string} cacheRecordKey - The key of the cache record to enqueue.
37
+ * @returns {Promise<void>} - A promise that resolves when the record is enqueued into the cache.
38
+ */
39
+ enqueueRecord<T>(queueName: string, cacheRecord: T): Promise<void>;
40
+ /**
41
+ *
42
+ * Enqueues a batch of records into the cache.
43
+ *
44
+ * @param {string[]} cacheRecordKeys - The keys of the cache records to enqueue.
45
+ * @returns {Promise<void>} - A promise that resolves when the records are enqueued into the cache.
46
+ */
47
+ enqueueBatchRecords<T>(queueName: string, cacheRecords: T[]): Promise<void>;
48
+ /**
49
+ * Deletes a record from the cache.
50
+ *
51
+ * @param {string} cacheRecordKey - The key of the cache record to delete.
52
+ * @returns {Promise<void>} - A promise that resolves when the record is deleted from the cache.
53
+ */
54
+ deleteRecord(cacheRecordKey: string): Promise<void>;
55
+ /**
56
+ * Deletes a batch of records from the cache.
57
+ *
58
+ * @param {string[]} cacheRecordKeys - The keys of the cache records to delete.
59
+ * @returns {Promise<void>} - A promise that resolves when the records are deleted from the cache.
60
+ */
61
+ deleteBatchRecords(cacheRecordKeys: string[]): Promise<void>;
62
+ /**
63
+ * Dequeues a record from the cache.
64
+ *
65
+ * @param {string} cacheRecordKey - The key of the cache record to dequeue.
66
+ * @returns {Promise<void>} - A promise that resolves when the record is dequeued from the cache.
67
+ */
68
+ dequeueRecord<T>(queueName: string): Promise<T>;
69
+ /**
70
+ * Dequeues a batch of records from the cache.
71
+ *
72
+ * @param {string[]} cacheRecordKeys - The keys of the cache records to dequeue.
73
+ * @returns {Promise<void>} - A promise that resolves when the records are dequeued from the cache.
74
+ */
75
+ dequeueBatchRecords<T>(queueName: string, pageSize: number): Promise<T[]>;
76
+ /**
77
+ * Reads a record from the cache.
78
+ *
79
+ * @param {string} cacheRecordKey - The key of the cache record to read.
80
+ * @returns {Promise<TtlCacheRecord>} - A promise that resolves with the cache record.
81
+ */
82
+ readRecord<T>(cacheRecordKey: string): Promise<TtlCacheRecord<T>>;
83
+ /**
84
+ * Reads a batch of records from the cache.
85
+ *
86
+ * @param {string[] | string} cacheRecordKeysOrPrefix - The keys of the cache records to read or a prefix to match.
87
+ * @returns {Promise<TtlCacheRecord<T>[]>} - A promise that resolves with the cache records.
88
+ */
89
+ readBatchRecords<T>(cacheRecordKeysOrPrefix: string[] | string): Promise<TtlCacheRecord<T>[]>;
90
+ /**
91
+ * Peeks at a record in the cache to check if it exists.
92
+ *
93
+ * @param {string} cacheRecordKey - The key of the cache record to peek at.
94
+ * @returns {Promise<boolean>} - A promise that resolves with a boolean indicating if the record exists.
95
+ */
96
+ peekRecord(cacheRecordKey: string): Promise<boolean>;
97
+ /**
98
+ * Peeks at a batch of records in the cache to check if they exist.
99
+ *
100
+ * @param {string[] | string} cacheRecordKeysOrPrefix - The keys of the cache records to peek at or a prefix to match.
101
+ * @returns {Promise<boolean[]>} - A promise that resolves with an array of booleans indicating if the records exist.
102
+ */
103
+ peekBatchRecords(cacheRecordKeysOrPrefix: string[] | string): Promise<boolean[]>;
104
+ /**
105
+ * Peeks at a record in the cache to check if it exists.
106
+ *
107
+ * @param {string} queueName - The name of the queue to peek at.
108
+ * @returns {Promise<T>} - A promise that resolves with the record.
109
+ */
110
+ peekQueueRecord<T>(queueName: string): Promise<T>;
111
+ /**
112
+ * Peeks at a batch of records in the cache to check if they exist.
113
+ *
114
+ * @param {string} queueName - The name of the queue to peek at.
115
+ * @returns {Promise<T[]>} - A promise that resolves with the records.
116
+ */
117
+ peekQueueRecords<T>(queueName: string, pageSize: number): Promise<T[]>;
118
+ /**
119
+ * Gets the TTL (Time-To-Live) in milliseconds.
120
+ *
121
+ * @returns {number} - The TTL in milliseconds.
122
+ */
123
+ getTtlMilliseconds(): number;
124
+ /**
125
+ * Lists the keys in the cache that match a pattern prefix.
126
+ *
127
+ * @param {string} pattern_prefix - The pattern prefix to match.
128
+ * @returns {Promise<string[]>} - A promise that resolves with an array of keys matching the pattern prefix.
129
+ */
130
+ listKeys(pattern_prefix: string): Promise<string[]>;
131
+ }
132
+
133
+ export type { TtlCache as T, TtlCacheRecord as a };
@@ -1,6 +1,6 @@
1
1
  import { AsyncAPIObject } from '@asyncapi/parser/esm/spec-types/v3';
2
2
  import { AnySchemaValidator, IdiomaticSchema, SchemaValidator } from '@forklaunch/validator';
3
- import { S as StringOnlyObject } from '../apiDefinition.types-DnUkFmfT.mjs';
3
+ import { S as StringOnlyObject } from '../apiDefinition.types-Br0fDuBQ.mjs';
4
4
  import '@forklaunch/common';
5
5
  import '@opentelemetry/api';
6
6
  import 'jose';
package/lib/ws/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AsyncAPIObject } from '@asyncapi/parser/esm/spec-types/v3';
2
2
  import { AnySchemaValidator, IdiomaticSchema, SchemaValidator } from '@forklaunch/validator';
3
- import { S as StringOnlyObject } from '../apiDefinition.types-DnUkFmfT.js';
3
+ import { S as StringOnlyObject } from '../apiDefinition.types-Br0fDuBQ.js';
4
4
  import '@forklaunch/common';
5
5
  import '@opentelemetry/api';
6
6
  import 'jose';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/core",
3
- "version": "0.19.5",
3
+ "version": "1.0.2",
4
4
  "description": "forklaunch-js core package. Contains useful building blocks.",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -78,8 +78,8 @@
78
78
  "dependencies": {
79
79
  "@asyncapi/parser": "^3.6.0",
80
80
  "@forklaunch/opentelemetry-instrumentation-hyper-express": "0.0.5",
81
- "@mikro-orm/core": "7.0.4",
82
- "@mikro-orm/mongodb": "7.0.4",
81
+ "@mikro-orm/core": "7.0.5",
82
+ "@mikro-orm/mongodb": "7.0.5",
83
83
  "@opentelemetry/api": "^1.9.0",
84
84
  "@opentelemetry/api-logs": "^0.213.0",
85
85
  "@opentelemetry/exporter-logs-otlp-http": "^0.213.0",
@@ -105,8 +105,8 @@
105
105
  "redis": "^5.11.0",
106
106
  "uuid": "^13.0.0",
107
107
  "zod": "^4.3.6",
108
- "@forklaunch/validator": "0.11.5",
109
- "@forklaunch/common": "0.7.5"
108
+ "@forklaunch/validator": "1.0.2",
109
+ "@forklaunch/common": "1.0.2"
110
110
  },
111
111
  "devDependencies": {
112
112
  "@eslint/js": "^10.0.1",
@@ -115,7 +115,7 @@
115
115
  "@types/jest": "^30.0.0",
116
116
  "@types/qs": "^6.15.0",
117
117
  "@types/uuid": "^11.0.0",
118
- "@typescript/native-preview": "7.0.0-dev.20260320.1",
118
+ "@typescript/native-preview": "7.0.0-dev.20260323.1",
119
119
  "globals": "^17.4.0",
120
120
  "jest": "^30.3.0",
121
121
  "jose": "6.1.3",
@@ -124,9 +124,9 @@
124
124
  "ts-jest": "^29.4.6",
125
125
  "ts-node": "^10.9.2",
126
126
  "tsup": "^8.5.1",
127
- "typedoc": "^0.28.17",
128
- "typescript": "^5.9.3",
129
- "typescript-eslint": "^8.57.1"
127
+ "typedoc": "^0.28.18",
128
+ "typescript": "^6.0.2",
129
+ "typescript-eslint": "^8.57.2"
130
130
  },
131
131
  "scripts": {
132
132
  "build": "tsgo --noEmit && tsup ./src/cache/index.ts ./src/controllers/index.ts ./src/mappers/index.ts ./src/objectstore/index.ts ./src/persistence/index.ts ./src/http/index.ts ./src/services/index.ts ./src/environment/index.ts ./src/ws/index.ts --format cjs,esm --no-splitting --dts --tsconfig tsconfig.json --out-dir lib --clean --sourcemap",