sos-data-utils-ts 0.1.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/CHANGELOG.md +8 -0
- package/README.md +24 -0
- package/dist/bff-api.d.ts +12 -0
- package/dist/bff-api.js +32 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +43 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# sos-data-utils-ts
|
|
2
|
+
|
|
3
|
+
Product-neutral contracts shared outward from SOS channel infrastructure into
|
|
4
|
+
human-health and animal products. This package has no dependency on GW CORE,
|
|
5
|
+
`gdc-*`, `uhc-*` or `vet-*` packages.
|
|
6
|
+
|
|
7
|
+
The first contract defines capability-based BFF route roots. Public products
|
|
8
|
+
use `/api/assistant/*`; `/api/internal/*` is reserved for authenticated
|
|
9
|
+
service-to-service adapters. Product-name prefixes such as `/api/unid`,
|
|
10
|
+
`/api/uhc`, `/api/vetchain` and `/api/petchain` are not public API surfaces.
|
|
11
|
+
|
|
12
|
+
Sector behavior remains in its owner:
|
|
13
|
+
|
|
14
|
+
- `sos-*`: reusable channel, BFF and emergency primitives;
|
|
15
|
+
- `uhc-*`: human-health extensions;
|
|
16
|
+
- `vet-*`: animal/veterinary extensions;
|
|
17
|
+
- the terminology service: international terminology and regional catalogs.
|
|
18
|
+
|
|
19
|
+
## Verify
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm ci
|
|
23
|
+
npm run check
|
|
24
|
+
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Capability-first route roots shared by SOS, human-health and animal BFFs. */
|
|
2
|
+
export declare const SharedBffApiRoutes: Readonly<{
|
|
3
|
+
readonly assistant: "/api/assistant";
|
|
4
|
+
readonly internal: "/api/internal";
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* Validates one public BFF pathname against the shared capability surface.
|
|
8
|
+
* Product and sector names belong in the deploying adapter, never in the URL.
|
|
9
|
+
*/
|
|
10
|
+
export declare function assertSharedPublicBffRoute(pathname: string): string;
|
|
11
|
+
/** Returns true only for the explicitly non-public service-to-service surface. */
|
|
12
|
+
export declare function isSharedInternalBffRoute(pathname: string): boolean;
|
package/dist/bff-api.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Capability-first route roots shared by SOS, human-health and animal BFFs. */
|
|
2
|
+
export const SharedBffApiRoutes = Object.freeze({
|
|
3
|
+
assistant: '/api/assistant',
|
|
4
|
+
internal: '/api/internal',
|
|
5
|
+
});
|
|
6
|
+
const PUBLIC_ROUTE_ROOTS = Object.freeze([
|
|
7
|
+
SharedBffApiRoutes.assistant,
|
|
8
|
+
]);
|
|
9
|
+
/**
|
|
10
|
+
* Validates one public BFF pathname against the shared capability surface.
|
|
11
|
+
* Product and sector names belong in the deploying adapter, never in the URL.
|
|
12
|
+
*/
|
|
13
|
+
export function assertSharedPublicBffRoute(pathname) {
|
|
14
|
+
const route = normalizedPathname(pathname);
|
|
15
|
+
if (!PUBLIC_ROUTE_ROOTS.some((root) => route === root || route.startsWith(`${root}/`))) {
|
|
16
|
+
throw new Error('shared_public_bff_route_required');
|
|
17
|
+
}
|
|
18
|
+
return route;
|
|
19
|
+
}
|
|
20
|
+
/** Returns true only for the explicitly non-public service-to-service surface. */
|
|
21
|
+
export function isSharedInternalBffRoute(pathname) {
|
|
22
|
+
const route = normalizedPathname(pathname);
|
|
23
|
+
const root = SharedBffApiRoutes.internal;
|
|
24
|
+
return route === root || route.startsWith(`${root}/`);
|
|
25
|
+
}
|
|
26
|
+
function normalizedPathname(value) {
|
|
27
|
+
const route = String(value || '').trim();
|
|
28
|
+
if (!route.startsWith('/') || route.includes('?') || route.includes('#')) {
|
|
29
|
+
throw new Error('shared_public_bff_route_required');
|
|
30
|
+
}
|
|
31
|
+
return route.length > 1 ? route.replace(/\/+$/, '') : route;
|
|
32
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './bff-api.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './bff-api.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sos-data-utils-ts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Product-neutral SOS channel and BFF contract utilities",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./bff-api": {
|
|
15
|
+
"types": "./dist/bff-api.d.ts",
|
|
16
|
+
"default": "./dist/bff-api.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md",
|
|
22
|
+
"CHANGELOG.md"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
26
|
+
"build": "npm run clean && tsc -p tsconfig.json",
|
|
27
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
28
|
+
"test": "npm run build && node --test tests/*.test.mjs",
|
|
29
|
+
"check": "npm run typecheck && npm test",
|
|
30
|
+
"prepack": "npm run check"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^24.10.0",
|
|
34
|
+
"typescript": "^5.9.3"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=24"
|
|
38
|
+
},
|
|
39
|
+
"private": false,
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
}
|
|
43
|
+
}
|