@company-semantics/contracts 0.47.2 → 0.48.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/package.json +3 -1
- package/src/index.ts +5 -0
- package/src/rate-limit/README.md +51 -0
- package/src/rate-limit/index.ts +23 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@company-semantics/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -67,6 +67,8 @@
|
|
|
67
67
|
"guard:version-tag:json": "npx tsx scripts/ci/version-tag-guard.ts --json",
|
|
68
68
|
"guard:decisions-deprecation": "npx tsx scripts/ci/decisions-deprecation-guard.ts",
|
|
69
69
|
"guard:decisions-deprecation:json": "npx tsx scripts/ci/decisions-deprecation-guard.ts --json",
|
|
70
|
+
"guard:quick": "pnpm guard:export && pnpm guard:vocabulary && pnpm guard:scripts-deps",
|
|
71
|
+
"guard": "pnpm guard:export && pnpm guard:vocabulary && pnpm guard:scripts-deps && pnpm guard:decision && pnpm guard:decisions-deprecation",
|
|
70
72
|
"guard:test": "vitest run scripts/ci/__tests__",
|
|
71
73
|
"release": "npx tsx scripts/release.ts",
|
|
72
74
|
"prepublishOnly": "echo 'ERROR: Publishing is CI-only via tag push. Use pnpm release instead.' && exit 1",
|
package/src/index.ts
CHANGED
|
@@ -346,3 +346,8 @@ export type {
|
|
|
346
346
|
|
|
347
347
|
// Ralph constants (cross-repo support)
|
|
348
348
|
export { REPO_PRECEDENCE } from './ralph/index'
|
|
349
|
+
|
|
350
|
+
// Rate limit domain types
|
|
351
|
+
// @see PRD-00013 for contracts integration
|
|
352
|
+
export type { RateLimitConfig, RateLimitResult } from './rate-limit/index'
|
|
353
|
+
export { RateLimitTier } from './rate-limit/index'
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Rate Limit Domain
|
|
2
|
+
|
|
3
|
+
Shared vocabulary types for rate limiting across Company Semantics codebases.
|
|
4
|
+
|
|
5
|
+
## Types
|
|
6
|
+
|
|
7
|
+
### RateLimitTier
|
|
8
|
+
|
|
9
|
+
Enum defining the rate limit tiers available to users:
|
|
10
|
+
|
|
11
|
+
- `FREE` - Default tier for free users
|
|
12
|
+
- `PRO` - Elevated limits for pro subscribers
|
|
13
|
+
- `ENTERPRISE` - Custom limits for enterprise customers
|
|
14
|
+
|
|
15
|
+
### RateLimitConfig
|
|
16
|
+
|
|
17
|
+
Configuration for rate limit windows:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
interface RateLimitConfig {
|
|
21
|
+
maxRequests: number; // Maximum requests allowed in window
|
|
22
|
+
windowMs: number; // Window duration in milliseconds
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### RateLimitResult
|
|
27
|
+
|
|
28
|
+
Result of a rate limit check:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
interface RateLimitResult {
|
|
32
|
+
allowed: boolean; // true = permitted, false = rate limited
|
|
33
|
+
remaining: number; // Requests remaining in current window
|
|
34
|
+
resetAt: number; // Unix timestamp when window resets
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Semantic Convention
|
|
39
|
+
|
|
40
|
+
This domain uses `allowed: boolean` where `true` means the request is permitted.
|
|
41
|
+
This is the canonical semantic across all Company Semantics repos.
|
|
42
|
+
|
|
43
|
+
## Consumers
|
|
44
|
+
|
|
45
|
+
- `company-semantics-edge` - Rate limiter implementation
|
|
46
|
+
- `company-semantics-backend` - Rate limit service
|
|
47
|
+
|
|
48
|
+
## See Also
|
|
49
|
+
|
|
50
|
+
- PRD-00012: Foundational rate limiting implementation
|
|
51
|
+
- PRD-00013: Contracts integration (this promotion)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rate limiting vocabulary types.
|
|
3
|
+
* @see PRD-00012 for foundational implementation
|
|
4
|
+
* @see PRD-00013 for contracts integration
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export enum RateLimitTier {
|
|
8
|
+
FREE = 'free',
|
|
9
|
+
PRO = 'pro',
|
|
10
|
+
ENTERPRISE = 'enterprise',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface RateLimitConfig {
|
|
14
|
+
maxRequests: number;
|
|
15
|
+
windowMs: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface RateLimitResult {
|
|
19
|
+
/** Whether the request is allowed (true = permitted, false = rate limited) */
|
|
20
|
+
allowed: boolean;
|
|
21
|
+
remaining: number;
|
|
22
|
+
resetAt: number;
|
|
23
|
+
}
|