@fonderie/config 1.0.1 → 1.0.3
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/brain/outcomes.md +25 -0
- package/brain/signatures.md +56 -0
- package/dist/migrations/sql/001_config.sql +13 -0
- package/package.json +5 -4
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!-- GENERATED — do not edit. Regenerate with: npm run docs:signatures -->
|
|
2
|
+
|
|
3
|
+
# @fonderie/config — outcomes
|
|
4
|
+
|
|
5
|
+
What this package does to a running app: tables its migrations create,
|
|
6
|
+
rows it seeds, routes it registers. Generated from the migration SQL and
|
|
7
|
+
route tables in source — trust this file instead of reading `dist/` or
|
|
8
|
+
downloading tarballs.
|
|
9
|
+
|
|
10
|
+
## Database tables (after all migrations)
|
|
11
|
+
|
|
12
|
+
### `fonderie_config`
|
|
13
|
+
|
|
14
|
+
```sql
|
|
15
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid()
|
|
16
|
+
key TEXT NOT NULL
|
|
17
|
+
value TEXT NOT NULL
|
|
18
|
+
environment TEXT NOT NULL DEFAULT 'all'
|
|
19
|
+
description TEXT
|
|
20
|
+
active BOOLEAN NOT NULL DEFAULT true
|
|
21
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
22
|
+
-- UNIQUE (key, environment)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Raw SQL ships in `node_modules/@fonderie/config/dist/migrations/sql/` — read it there if you must; never download tarballs.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!-- GENERATED — do not edit. Regenerate with: npm run docs:signatures -->
|
|
2
|
+
|
|
3
|
+
# @fonderie/config — signatures
|
|
4
|
+
|
|
5
|
+
## @fonderie/config
|
|
6
|
+
|
|
7
|
+
Subpath exports: `@fonderie/config/types`, `@fonderie/config/middleware`, `@fonderie/config/migrations`
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
new RemoteConfigModule(store: IStoreAdapter, options?: IRemoteConfigOptions): RemoteConfigModule
|
|
11
|
+
.name: "@fonderie/config"
|
|
12
|
+
.manager: RemoteConfigManager
|
|
13
|
+
.install(app: IFonderieApp): Promise<void>
|
|
14
|
+
|
|
15
|
+
new RemoteConfigManager(store: IStoreAdapter, options?: IRemoteConfigOptions): RemoteConfigManager
|
|
16
|
+
.boot(): Promise<void>
|
|
17
|
+
.stop(): void
|
|
18
|
+
.get<T>(key: string, fallback: T): T
|
|
19
|
+
.all(): Record<string, unknown>
|
|
20
|
+
.refresh(): Promise<void>
|
|
21
|
+
.isStale(): boolean
|
|
22
|
+
|
|
23
|
+
const CONFIG_MANAGER_KEY: "fonderie.config.snapshot"
|
|
24
|
+
|
|
25
|
+
function configContextMiddleware(manager: RemoteConfigManager): Middleware
|
|
26
|
+
|
|
27
|
+
function getConfig(ctx: { meta: Record<string, unknown>; }, key: string, fallback?: unknown): unknown
|
|
28
|
+
|
|
29
|
+
function listConfigEntries(environment: string | null, store: IStoreAdapter): Promise<IConfigEntry[]>
|
|
30
|
+
|
|
31
|
+
function getConfigEntry(key: string, environment: string, store: IStoreAdapter): Promise<IConfigEntry | null>
|
|
32
|
+
|
|
33
|
+
function setConfigEntry(opts: { key: string; value: unknown; environment?: string; description?: string; active?: boolean; }, store: IStoreAdapter): Promise<IConfigEntry>
|
|
34
|
+
|
|
35
|
+
function deleteConfigEntry(key: string, environment: string, store: IStoreAdapter): Promise<boolean>
|
|
36
|
+
|
|
37
|
+
interface IConfigEntry {
|
|
38
|
+
key: string;
|
|
39
|
+
value: unknown;
|
|
40
|
+
environment: string;
|
|
41
|
+
description: string | null;
|
|
42
|
+
active: boolean;
|
|
43
|
+
updatedAt: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface IConfigSnapshot {
|
|
47
|
+
entries: Record<string, unknown>;
|
|
48
|
+
fetchedAt: Date;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface IRemoteConfigOptions {
|
|
52
|
+
ttl?: number;
|
|
53
|
+
environment?: string;
|
|
54
|
+
table?: string;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS fonderie_config (
|
|
2
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
3
|
+
key TEXT NOT NULL,
|
|
4
|
+
value TEXT NOT NULL,
|
|
5
|
+
environment TEXT NOT NULL DEFAULT 'all',
|
|
6
|
+
description TEXT,
|
|
7
|
+
active BOOLEAN NOT NULL DEFAULT true,
|
|
8
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
9
|
+
UNIQUE (key, environment)
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE INDEX IF NOT EXISTS fonderie_config_env_active_idx
|
|
13
|
+
ON fonderie_config (environment, active);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonderie/config",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "DB-backed feature flags and remote config — per-environment overrides, TTL-based hot reload, and a typed getConfig helper usable inside any middleware.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fonderie-js",
|
|
@@ -65,16 +65,17 @@
|
|
|
65
65
|
},
|
|
66
66
|
"files": [
|
|
67
67
|
"dist",
|
|
68
|
+
"brain",
|
|
68
69
|
"LICENSE",
|
|
69
70
|
"README.md"
|
|
70
71
|
],
|
|
71
72
|
"repository": {
|
|
72
73
|
"type": "git",
|
|
73
|
-
"url": "git+https://github.com/
|
|
74
|
+
"url": "git+https://github.com/fonderiejs/sdk.git",
|
|
74
75
|
"directory": "packages/config"
|
|
75
76
|
},
|
|
76
|
-
"homepage": "https://github.com/
|
|
77
|
+
"homepage": "https://github.com/fonderiejs/sdk/tree/main/packages/config#readme",
|
|
77
78
|
"bugs": {
|
|
78
|
-
"url": "https://github.com/
|
|
79
|
+
"url": "https://github.com/fonderiejs/sdk/issues"
|
|
79
80
|
}
|
|
80
81
|
}
|