@shivaedev/rate-limit 0.2.1 → 0.3.1
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 +13 -0
- package/README.md +4 -0
- package/dist/postgresTestDatabase.d.ts +6 -0
- package/dist/postgresTestDatabase.d.ts.map +1 -0
- package/dist/postgresTestDatabase.js +9 -0
- package/dist/postgresTestDatabase.js.map +1 -0
- package/package.json +7 -7
- package/src/postgresTestDatabase.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.1 - 2026-11-03
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Update `@shivaedev/errors` from 0.6.0 to 0.7.0.
|
|
8
|
+
- Update `@shivaedev/sql` from 0.34.0 to 0.35.0.
|
|
9
|
+
|
|
10
|
+
## 0.3.0 - 2026-11-03
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Expose `postgresTestDatabase` with an `expireWindows` fixture for isolated PostgreSQL stories exercising expired budgets.
|
|
15
|
+
|
|
3
16
|
## 0.2.1 - 2026-11-02
|
|
4
17
|
|
|
5
18
|
### Changed
|
package/README.md
CHANGED
|
@@ -44,6 +44,10 @@ The migration creates `rate_limit_windows`. PostgreSQL retains one row per key;
|
|
|
44
44
|
|
|
45
45
|
A custom store implements `Store.consume` from `@shivaedev/rate-limit/Store.ts`, atomically consuming a `WindowRequest` or failing with `TooManyRequests` or `StoreError`. A store owns its clock and consistency boundary.
|
|
46
46
|
|
|
47
|
+
### PostgreSQL story fixtures
|
|
48
|
+
|
|
49
|
+
`postgresTestDatabase` from `@shivaedev/rate-limit/postgresTestDatabase.ts` provides `expireWindows`, an Effect that expires all stored windows in an isolated test database. Use it to establish expired windows before exercising the production limiter; it does not advance the PostgreSQL clock.
|
|
50
|
+
|
|
47
51
|
### Install
|
|
48
52
|
|
|
49
53
|
```sh
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/sql";
|
|
3
|
+
export declare const postgresTestDatabase: Effect.Effect<{
|
|
4
|
+
expireWindows: Effect.Effect<void, import("effect/sql/SqlError").SqlError, never>;
|
|
5
|
+
}, never, SqlClient.SqlClient>;
|
|
6
|
+
//# sourceMappingURL=postgresTestDatabase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgresTestDatabase.d.ts","sourceRoot":"","sources":["../src/postgresTestDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,eAAO,MAAM,oBAAoB;;8BAK/B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/sql";
|
|
3
|
+
export const postgresTestDatabase = Effect.gen(function* () {
|
|
4
|
+
const sql = (yield* SqlClient.SqlClient).withoutTransforms();
|
|
5
|
+
return {
|
|
6
|
+
expireWindows: sql `update rate_limit_windows set expires_at = 0`.pipe(Effect.asVoid),
|
|
7
|
+
};
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=postgresTestDatabase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgresTestDatabase.js","sourceRoot":"","sources":["../src/postgresTestDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACvD,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAC7D,OAAO;QACN,aAAa,EAAE,GAAG,CAAA,8CAA8C,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;KACpF,CAAC;AACH,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/rate-limit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Per-key rate limits with memory and PostgreSQL stores for Effect applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect"
|
|
@@ -45,20 +45,20 @@
|
|
|
45
45
|
"README.md"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@shivaedev/errors": "0.
|
|
48
|
+
"@shivaedev/errors": "0.7.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@shivaedev/quality": "0.
|
|
52
|
-
"@shivaedev/sql": "0.
|
|
53
|
-
"@shivaedev/test-sql": "0.
|
|
54
|
-
"@shivaedev/test-story": "0.
|
|
51
|
+
"@shivaedev/quality": "0.57.1",
|
|
52
|
+
"@shivaedev/sql": "0.35.0",
|
|
53
|
+
"@shivaedev/test-sql": "0.18.0",
|
|
54
|
+
"@shivaedev/test-story": "0.36.0",
|
|
55
55
|
"@types/node": "24.19.2",
|
|
56
56
|
"effect": "4.0.6",
|
|
57
57
|
"typescript": "7.0.2",
|
|
58
58
|
"vitest": "5.0.5"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@shivaedev/sql": "0.
|
|
61
|
+
"@shivaedev/sql": "0.35.0",
|
|
62
62
|
"effect": "4.0.6"
|
|
63
63
|
},
|
|
64
64
|
"peerDependenciesMeta": {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { SqlClient } from "effect/sql";
|
|
3
|
+
|
|
4
|
+
export const postgresTestDatabase = Effect.gen(function* () {
|
|
5
|
+
const sql = (yield* SqlClient.SqlClient).withoutTransforms();
|
|
6
|
+
return {
|
|
7
|
+
expireWindows: sql`update rate_limit_windows set expires_at = 0`.pipe(Effect.asVoid),
|
|
8
|
+
};
|
|
9
|
+
});
|