@primebrick/sdk 0.1.0 → 0.1.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/LICENSE +21 -21
- package/README.md +21 -21
- package/dist/migrations/patch-registry.js +7 -7
- package/package.json +47 -47
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Michael Sogos
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Michael Sogos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
# @primebrick/sdk
|
|
2
|
-
|
|
3
|
-
Shared microservice infrastructure for Primebrick v3 — config loading, migration runner, service registration, graceful shutdown, NATS client, health checks, env validation. DB-agnostic via port interfaces.
|
|
4
|
-
|
|
5
|
-
## What the SDK provides
|
|
6
|
-
|
|
7
|
-
- **Port interfaces** — `ConfigRepositoryPort`, `DatabasePort`, `ServiceRegistryPort`, `HealthCheckPort`. Abstract contracts the consumer implements using their DAL.
|
|
8
|
-
- **ConfigLoader** — load config from a DB config table at startup, cache in memory, `get(key)` on hot path, `invalidate()` for refresh.
|
|
9
|
-
- **IConfigEntity** — self-contained interface for dictionary-style config rows.
|
|
10
|
-
- **Migration runner** — SHA256-based patch tracking, idempotent re-runs.
|
|
11
|
-
- **ServiceRegistrar** — register microservice in `service_registry`, maintain heartbeat.
|
|
12
|
-
- **IServiceRegistry** — self-contained interface for `service_registry` rows.
|
|
13
|
-
- **GracefulShutdown** — re-entrancy guard, `Promise.allSettled` for parallel resource cleanup, signal handlers.
|
|
14
|
-
- **NatsClient** — singleton NATS connection management.
|
|
15
|
-
- **HttpServer** — minimal HTTP server with health endpoint.
|
|
16
|
-
- **HealthCheck** — DB health check utility.
|
|
17
|
-
- **EnvValidator** — centralized env var validation.
|
|
18
|
-
|
|
19
|
-
## License
|
|
20
|
-
|
|
21
|
-
MIT — Copyright (c) 2026 Michael Sogos
|
|
1
|
+
# @primebrick/sdk
|
|
2
|
+
|
|
3
|
+
Shared microservice infrastructure for Primebrick v3 — config loading, migration runner, service registration, graceful shutdown, NATS client, health checks, env validation. DB-agnostic via port interfaces.
|
|
4
|
+
|
|
5
|
+
## What the SDK provides
|
|
6
|
+
|
|
7
|
+
- **Port interfaces** — `ConfigRepositoryPort`, `DatabasePort`, `ServiceRegistryPort`, `HealthCheckPort`. Abstract contracts the consumer implements using their DAL.
|
|
8
|
+
- **ConfigLoader** — load config from a DB config table at startup, cache in memory, `get(key)` on hot path, `invalidate()` for refresh.
|
|
9
|
+
- **IConfigEntity** — self-contained interface for dictionary-style config rows.
|
|
10
|
+
- **Migration runner** — SHA256-based patch tracking, idempotent re-runs.
|
|
11
|
+
- **ServiceRegistrar** — register microservice in `service_registry`, maintain heartbeat.
|
|
12
|
+
- **IServiceRegistry** — self-contained interface for `service_registry` rows.
|
|
13
|
+
- **GracefulShutdown** — re-entrancy guard, `Promise.allSettled` for parallel resource cleanup, signal handlers.
|
|
14
|
+
- **NatsClient** — singleton NATS connection management.
|
|
15
|
+
- **HttpServer** — minimal HTTP server with health endpoint.
|
|
16
|
+
- **HealthCheck** — DB health check utility.
|
|
17
|
+
- **EnvValidator** — centralized env var validation.
|
|
18
|
+
|
|
19
|
+
## License
|
|
20
|
+
|
|
21
|
+
MIT — Copyright (c) 2026 Michael Sogos
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export const PATCH_REGISTRY_FQNAME = "public.primebrick_database_patches";
|
|
2
|
-
export const PATCH_REGISTRY_DDL = `CREATE TABLE IF NOT EXISTS public.primebrick_database_patches (
|
|
3
|
-
patch_id text PRIMARY KEY,
|
|
4
|
-
content_sha256 text NOT NULL,
|
|
5
|
-
applied_at timestamptz NOT NULL DEFAULT now()
|
|
6
|
-
);
|
|
7
|
-
CREATE INDEX IF NOT EXISTS primebrick_database_patches_sha_idx
|
|
8
|
-
ON public.primebrick_database_patches (content_sha256);
|
|
2
|
+
export const PATCH_REGISTRY_DDL = `CREATE TABLE IF NOT EXISTS public.primebrick_database_patches (
|
|
3
|
+
patch_id text PRIMARY KEY,
|
|
4
|
+
content_sha256 text NOT NULL,
|
|
5
|
+
applied_at timestamptz NOT NULL DEFAULT now()
|
|
6
|
+
);
|
|
7
|
+
CREATE INDEX IF NOT EXISTS primebrick_database_patches_sha_idx
|
|
8
|
+
ON public.primebrick_database_patches (content_sha256);
|
|
9
9
|
`;
|
|
10
10
|
export async function isPatchBodyAlreadyRecorded(db, contentSha256) {
|
|
11
11
|
const reg = await db.query(`SELECT to_regclass('${PATCH_REGISTRY_FQNAME}')::text AS oid`);
|
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@primebrick/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"private": false,
|
|
5
|
-
"type": "module",
|
|
6
|
-
"description": "Shared microservice infrastructure for Primebrick v3 — config loading, migration runner, service registration, graceful shutdown, NATS client, health checks, env validation. DB-agnostic via port interfaces.",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"author": "Michael Sogos",
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "https://github.com/michaelsogos/primebrick-v3-sdk"
|
|
12
|
-
},
|
|
13
|
-
"homepage": "https://github.com/michaelsogos/primebrick-v3-sdk#readme",
|
|
14
|
-
"bugs": {
|
|
15
|
-
"url": "https://github.com/michaelsogos/primebrick-v3-sdk/issues"
|
|
16
|
-
},
|
|
17
|
-
"main": "./dist/index.js",
|
|
18
|
-
"types": "./dist/index.d.ts",
|
|
19
|
-
"exports": {
|
|
20
|
-
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" }
|
|
21
|
-
},
|
|
22
|
-
"files": ["dist/"],
|
|
23
|
-
"scripts": {
|
|
24
|
-
"build": "tsc",
|
|
25
|
-
"prepare": "tsc",
|
|
26
|
-
"test": "vitest run",
|
|
27
|
-
"test:watch": "vitest"
|
|
28
|
-
},
|
|
29
|
-
"publishConfig": {
|
|
30
|
-
"access": "public",
|
|
31
|
-
"registry": "https://registry.npmjs.org"
|
|
32
|
-
},
|
|
33
|
-
"dependencies": {},
|
|
34
|
-
"peerDependencies": {
|
|
35
|
-
"nats": "^2.28.1"
|
|
36
|
-
},
|
|
37
|
-
"peerDependenciesMeta": {
|
|
38
|
-
"nats": { "optional": true }
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"@types/node": "^24.12.4",
|
|
42
|
-
"nats": "^2.28.1",
|
|
43
|
-
"typescript": "^5.7.2",
|
|
44
|
-
"vitest": "^2.1.0"
|
|
45
|
-
},
|
|
46
|
-
"packageManager": "pnpm@9.15.9"
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@primebrick/sdk",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Shared microservice infrastructure for Primebrick v3 — config loading, migration runner, service registration, graceful shutdown, NATS client, health checks, env validation. DB-agnostic via port interfaces.",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "Michael Sogos",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/michaelsogos/primebrick-v3-sdk"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/michaelsogos/primebrick-v3-sdk#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/michaelsogos/primebrick-v3-sdk/issues"
|
|
16
|
+
},
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" }
|
|
21
|
+
},
|
|
22
|
+
"files": ["dist/"],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc",
|
|
25
|
+
"prepare": "tsc",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:watch": "vitest"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public",
|
|
31
|
+
"registry": "https://registry.npmjs.org"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"nats": "^2.28.1"
|
|
36
|
+
},
|
|
37
|
+
"peerDependenciesMeta": {
|
|
38
|
+
"nats": { "optional": true }
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^24.12.4",
|
|
42
|
+
"nats": "^2.28.1",
|
|
43
|
+
"typescript": "^5.7.2",
|
|
44
|
+
"vitest": "^2.1.0"
|
|
45
|
+
},
|
|
46
|
+
"packageManager": "pnpm@9.15.9"
|
|
47
|
+
}
|