@zerotal/cache 1.6.3 → 1.7.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.
Files changed (2) hide show
  1. package/api-surface.md +188 -0
  2. package/package.json +3 -2
package/api-surface.md ADDED
@@ -0,0 +1,188 @@
1
+ # @zerotal/cache — public API surface
2
+
3
+ <!-- AUTO-GENERATED by scripts/api-surface.ts. Do not edit by hand.
4
+ Run `bun run api:surface` to regenerate after an intentional API change. -->
5
+
6
+ ## . `(./src/index.ts)`
7
+
8
+ class CacheDeserializationError = {
9
+ new (key: string, cause: unknown): CacheDeserializationError
10
+ readonly code: string
11
+ readonly context?: Record<string, unknown> | undefined
12
+ readonly status: number
13
+ }
14
+
15
+ class CacheError = {
16
+ new (message: string, code?: string, status?: number, context?: Record<string, unknown>): CacheError
17
+ readonly code: string
18
+ readonly context?: Record<string, unknown> | undefined
19
+ readonly status: number
20
+ }
21
+
22
+ class CacheEvicted = {
23
+ new (key: string, reason: 'ttl' | 'capacity' | 'manual'): CacheEvicted
24
+ readonly key: string
25
+ readonly reason: 'ttl' | 'capacity' | 'manual'
26
+ }
27
+
28
+ class CacheManager = {
29
+ new (_driver: CacheDriver, _prefix?: string, _defaultTtl?: number | undefined, _lock?: LockManager | null, _stampedeProtection?: boolean): CacheManager
30
+ dispose: () => void
31
+ flush: () => Promise<void>
32
+ forever: (key: string, value: unknown) => Promise<void>
33
+ forget: (key: string) => Promise<void>
34
+ get: <T>(key: string) => Promise<T | null>
35
+ has: (key: string) => Promise<boolean>
36
+ remember: <T>(key: string, ttl: number, fn: () => Promise<T> | T) => Promise<T>
37
+ set: (key: string, value: unknown, ttl?: number) => Promise<void>
38
+ tags: (tagNames: string[]) => TaggedCache
39
+ }
40
+
41
+ class CacheProvider = {
42
+ new (app: Application): CacheProvider
43
+ static dependsOn?: (new (app: Application) => ServiceProvider)[]
44
+ static environments: AppEnvironment[]
45
+ static priority?: number
46
+ static provides: readonly ['cache']
47
+ devProcesses: () => DevProcessDefinition[]
48
+ doctorChecks: () => DoctorCheck[]
49
+ onBooted: () => Promise<void>
50
+ onBooting: () => Promise<void>
51
+ onRegister: () => void
52
+ onRequestProcessed: (_ctx: HttpContext) => Promise<void>
53
+ onRequestReceived: (_ctx: HttpContext) => Promise<void>
54
+ onResponseSent: (_ctx: HttpContext) => Promise<void>
55
+ onStarted: () => Promise<void>
56
+ onStarting: () => Promise<void>
57
+ onStopped: () => Promise<void>
58
+ onStopping: () => Promise<void>
59
+ replContext: () => Record<string, unknown>
60
+ }
61
+
62
+ class CacheQueried = {
63
+ new (op: 'hit' | 'miss' | 'write' | 'forget' | 'flush' | 'has', key: string, ttl: number | undefined, durationMs: number): CacheQueried
64
+ readonly durationMs: number
65
+ readonly key: string
66
+ readonly op: 'hit' | 'miss' | 'write' | 'forget' | 'flush' | 'has'
67
+ readonly ttl: number | undefined
68
+ }
69
+
70
+ class CacheSerializationError = {
71
+ new (key: string, cause: unknown): CacheSerializationError
72
+ readonly code: string
73
+ readonly context?: Record<string, unknown> | undefined
74
+ readonly status: number
75
+ }
76
+
77
+ class IdempotencyMiddleware = {
78
+ new (): IdempotencyMiddleware
79
+ static _clearInFlight: () => void
80
+ static with: <T extends new (...args: any[]) => BaseMiddleware<any>, Opts = T extends new (...args: any[]) => BaseMiddleware<infer U> ? U : object>(this: T, options: DeepPartial<NoInfer<Opts>>) => new () => InstanceType<T>
81
+ afterResponse?: (ctx: HttpContext) => Promise<void>
82
+ handle: (http: HttpContext, next: NextFn) => Promise<Response | void>
83
+ onError?: (ctx: HttpContext, error: Error) => Promise<void>
84
+ }
85
+
86
+ class MemoryDriver = {
87
+ new (sweepMs?: number): MemoryDriver
88
+ dispose: () => void
89
+ flush: (prefix?: string) => Promise<void>
90
+ forget: (key: string) => Promise<void>
91
+ get: (key: string) => Promise<string | null>
92
+ has: (key: string) => Promise<boolean>
93
+ set: (key: string, value: string, ttl?: number) => Promise<void>
94
+ size: number
95
+ sweep: () => void
96
+ }
97
+
98
+ class RedisDriver = {
99
+ new (prefix?: string): RedisDriver
100
+ flush: (prefix?: string) => Promise<void>
101
+ forget: (key: string) => Promise<void>
102
+ get: (key: string) => Promise<string | null>
103
+ has: (key: string) => Promise<boolean>
104
+ set: (key: string, value: string, ttl?: number) => Promise<void>
105
+ }
106
+
107
+ class SqliteDriver = {
108
+ new (sqlInstance: SqlConnection): SqliteDriver
109
+ flush: (prefix?: string) => Promise<void>
110
+ forget: (key: string) => Promise<void>
111
+ get: (key: string) => Promise<string | null>
112
+ has: (key: string) => Promise<boolean>
113
+ set: (key: string, value: string, ttl?: number) => Promise<void>
114
+ }
115
+
116
+ class TaggedCache = {
117
+ new (_driver: CacheDriver, _prefix?: string, _defaultTtl?: number | undefined, _lock?: LockManager | null, _stampedeProtection?: boolean): TaggedCache
118
+ dispose: () => void
119
+ flush: () => Promise<void>
120
+ forever: (key: string, value: unknown) => Promise<void>
121
+ forget: (key: string) => Promise<void>
122
+ get: <T>(key: string) => Promise<T | null>
123
+ has: (key: string) => Promise<boolean>
124
+ remember: <T>(key: string, ttl: number, fn: () => Promise<T> | T) => Promise<T>
125
+ set: (key: string, value: unknown, ttl?: number) => Promise<void>
126
+ tags: (tagNames: string[]) => TaggedCache
127
+ }
128
+
129
+ const Cache = CacheManager
130
+
131
+ function CacheConfig = (options?: Partial<CacheConfigShape>) => CacheConfigShape
132
+
133
+ interface CacheConfigShape = {
134
+ driver: 'sqlite' | 'redis' | 'memory'
135
+ prefix: string
136
+ sqlite: { path: string;}
137
+ stampedeProtection: boolean
138
+ ttl: number
139
+ }
140
+
141
+ interface CacheDriver = {
142
+ dispose?: () => void
143
+ flush: (prefix?: string) => Promise<void>
144
+ forget: (key: string) => Promise<void>
145
+ get: (key: string) => Promise<string | null>
146
+ has: (key: string) => Promise<boolean>
147
+ set: (key: string, value: string, ttl?: number) => Promise<void>
148
+ }
149
+
150
+ interface IdempotencyOptions = {
151
+ cache: CacheManager | undefined
152
+ header: string
153
+ lock?: LockManager
154
+ methods: string[]
155
+ ttl: number
156
+ useLock: boolean
157
+ validateBody: boolean
158
+ }
159
+
160
+ ## ./commands `(./src/commands/index.ts)`
161
+
162
+ class CacheClearCommand = {
163
+ new (): CacheClearCommand
164
+ static args: ArgDef[]
165
+ static commandName: string
166
+ static description: string
167
+ static flags: { name: string; type: 'string'; description: string;}[]
168
+ static needsApp: boolean
169
+ _readLine: () => Promise<string>
170
+ _writer: OutputWriter
171
+ app: unknown
172
+ args: Record<string, string>
173
+ ask: (question: string, defaultValue?: string) => Promise<string>
174
+ choice: (question: string, options: string[]) => Promise<string>
175
+ confirm: (question: string, defaultValue?: boolean) => Promise<boolean>
176
+ dim: (msg: string) => void
177
+ error: (msg: string) => void
178
+ flags: Record<string, string | number | boolean>
179
+ info: (msg: string) => void
180
+ line: (msg: string) => void
181
+ newLine: () => void
182
+ run: () => Promise<void>
183
+ secret: (question: string) => Promise<string>
184
+ section: (title: string) => void
185
+ table: (rows: [string, string][], indent?: number) => void
186
+ warn: (msg: string) => void
187
+ write: (msg: string) => void
188
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerotal/cache",
3
- "version": "1.6.3",
3
+ "version": "1.7.2",
4
4
  "license": "MIT",
5
5
  "maturity": "stable",
6
6
  "private": false,
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "files": [
15
15
  "CHANGELOG.md",
16
+ "api-surface.md",
16
17
  "src",
17
18
  "!src/**/*.test.ts",
18
19
  "!src/**/*.test.tsx",
@@ -30,7 +31,7 @@
30
31
  "typecheck": "tsc --noEmit"
31
32
  },
32
33
  "dependencies": {
33
- "@zerotal/core": "1.6.3"
34
+ "@zerotal/core": "1.7.2"
34
35
  },
35
36
  "devDependencies": {
36
37
  "typescript": "^5.8.0"