@lssm/app.registry-server 1.41.0 → 1.42.2
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 +31 -0
- package/LICENSE +21 -0
- package/package.json +16 -3
- package/src/handlers/contractspec-handler.ts +0 -74
- package/src/handlers/lssm-handler.ts +0 -89
- package/src/index.ts +0 -1
- package/src/server.ts +0 -109
- package/src/utils/fs.ts +0 -10
- package/src/utils/paths.ts +0 -9
- package/tsconfig.json +0 -10
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @lssm/app.registry-server
|
|
2
|
+
|
|
3
|
+
## 1.42.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1f9ac4c: fix
|
|
8
|
+
- Updated dependencies [1f9ac4c]
|
|
9
|
+
- @lssm/lib.contracts@1.42.2
|
|
10
|
+
- @lssm/lib.logger@1.42.2
|
|
11
|
+
|
|
12
|
+
## 1.42.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- f043995: Fix release
|
|
17
|
+
- Updated dependencies [f043995]
|
|
18
|
+
- @lssm/lib.contracts@1.42.1
|
|
19
|
+
- @lssm/lib.logger@1.42.1
|
|
20
|
+
|
|
21
|
+
## 1.42.0
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- 8eefd9c: initial release
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [8eefd9c]
|
|
30
|
+
- @lssm/lib.contracts@1.42.0
|
|
31
|
+
- @lssm/lib.logger@1.42.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Chaman Ventures, SASU
|
|
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/package.json
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/app.registry-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
8
|
+
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
7
9
|
"clean": "rm -rf dist server",
|
|
8
10
|
"lint": "bun run lint:fix",
|
|
9
11
|
"lint:fix": "eslint src --fix",
|
|
10
12
|
"lint:check": "eslint src",
|
|
11
13
|
"dev": "bun run --watch src/server.ts",
|
|
12
|
-
"build": "bun build --compile --minify-whitespace --minify-syntax --target bun --outfile server src/index.ts",
|
|
14
|
+
"build": "bun build --compile --minify-whitespace --minify-syntax --target bun --outfile dist/server src/index.ts",
|
|
13
15
|
"start": "./server"
|
|
14
16
|
},
|
|
15
17
|
"dependencies": {
|
|
18
|
+
"@lssm/lib.contracts": "1.42.2",
|
|
16
19
|
"@elysiajs/cors": "^1.4.0",
|
|
17
20
|
"@elysiajs/server-timing": "^1.4.0",
|
|
18
|
-
"@lssm/lib.logger": "
|
|
21
|
+
"@lssm/lib.logger": "1.42.2",
|
|
19
22
|
"elysia": "^1.4.19"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/lssm-tech/contractspec.git",
|
|
28
|
+
"directory": "packages/apps/registry-server"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"registry": "https://registry.npmjs.org/",
|
|
32
|
+
"access": "public"
|
|
20
33
|
}
|
|
21
34
|
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import type { Logger } from '@lssm/lib.logger';
|
|
3
|
-
import {
|
|
4
|
-
ContractRegistryItemTypeSchema,
|
|
5
|
-
ContractRegistryManifestSchema,
|
|
6
|
-
type ContractRegistryItem,
|
|
7
|
-
type ContractRegistryItemType,
|
|
8
|
-
type ContractRegistryManifest,
|
|
9
|
-
} from '@lssm/lib.contracts';
|
|
10
|
-
import { readJsonFile, readTextFile } from '../utils/fs';
|
|
11
|
-
import { fromRepoRoot } from '../utils/paths';
|
|
12
|
-
|
|
13
|
-
function stripJsonSuffix(nameOrNameJson: string): string {
|
|
14
|
-
return nameOrNameJson.endsWith('.json')
|
|
15
|
-
? nameOrNameJson.slice(0, -'.json'.length)
|
|
16
|
-
: nameOrNameJson;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function getContractSpecRegistryPaths() {
|
|
20
|
-
const manifestPath = fromRepoRoot(
|
|
21
|
-
'packages/libs/contracts/registry/registry.json'
|
|
22
|
-
);
|
|
23
|
-
const contractsRoot = fromRepoRoot('packages/libs/contracts');
|
|
24
|
-
return { manifestPath, contractsRoot };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export async function readContractSpecManifest(
|
|
28
|
-
logger: Logger
|
|
29
|
-
): Promise<ContractRegistryManifest> {
|
|
30
|
-
const { manifestPath } = getContractSpecRegistryPaths();
|
|
31
|
-
const raw = await readJsonFile<unknown>(manifestPath);
|
|
32
|
-
const parsed = ContractRegistryManifestSchema.parse(raw);
|
|
33
|
-
logger.info('contractspec.registry.manifest_loaded', {
|
|
34
|
-
itemCount: parsed.items.length,
|
|
35
|
-
});
|
|
36
|
-
return parsed;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function normalizeType(typeSegment: string): ContractRegistryItemType {
|
|
40
|
-
const candidate = `contractspec:${typeSegment}` as const;
|
|
41
|
-
return ContractRegistryItemTypeSchema.parse(candidate);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export async function buildContractSpecItemJson(
|
|
45
|
-
typeSegment: string,
|
|
46
|
-
nameOrNameJson: string,
|
|
47
|
-
logger: Logger
|
|
48
|
-
): Promise<ContractRegistryItem> {
|
|
49
|
-
const type = normalizeType(typeSegment);
|
|
50
|
-
const name = stripJsonSuffix(nameOrNameJson);
|
|
51
|
-
|
|
52
|
-
const manifest = await readContractSpecManifest(logger);
|
|
53
|
-
const item = manifest.items.find((i) => i.type === type && i.name === name);
|
|
54
|
-
if (!item) {
|
|
55
|
-
throw new Error(`ContractSpec registry item not found: ${type}/${name}`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const { contractsRoot } = getContractSpecRegistryPaths();
|
|
59
|
-
const files = await Promise.all(
|
|
60
|
-
item.files.map(async (f) => {
|
|
61
|
-
const abs = path.join(contractsRoot, f.path);
|
|
62
|
-
const content = await readTextFile(abs);
|
|
63
|
-
return { ...f, content };
|
|
64
|
-
})
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
logger.info('contractspec.registry.item_built', {
|
|
68
|
-
type,
|
|
69
|
-
name,
|
|
70
|
-
fileCount: files.length,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
return { ...item, files };
|
|
74
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import type { Logger } from '@lssm/lib.logger';
|
|
3
|
-
import { readJsonFile, readTextFile } from '../utils/fs';
|
|
4
|
-
import { fromRepoRoot } from '../utils/paths';
|
|
5
|
-
|
|
6
|
-
interface ShadcnRegistryManifest {
|
|
7
|
-
$schema?: string;
|
|
8
|
-
name: string;
|
|
9
|
-
homepage?: string;
|
|
10
|
-
items: {
|
|
11
|
-
name: string;
|
|
12
|
-
type: string;
|
|
13
|
-
title?: string;
|
|
14
|
-
description: string;
|
|
15
|
-
files: { path: string; type: string; target?: string }[];
|
|
16
|
-
dependencies?: string[];
|
|
17
|
-
registryDependencies?: string[];
|
|
18
|
-
}[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type ShadcnRegistryItemJson = ShadcnRegistryManifest['items'][number] & {
|
|
22
|
-
files: {
|
|
23
|
-
path: string;
|
|
24
|
-
type: string;
|
|
25
|
-
target?: string;
|
|
26
|
-
content: string;
|
|
27
|
-
}[];
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function stripJsonSuffix(nameOrNameJson: string): string {
|
|
31
|
-
return nameOrNameJson.endsWith('.json')
|
|
32
|
-
? nameOrNameJson.slice(0, -'.json'.length)
|
|
33
|
-
: nameOrNameJson;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function getLssmRegistryPaths() {
|
|
37
|
-
const manifestPath = fromRepoRoot(
|
|
38
|
-
'packages/libs/design-system/registry/registry.json'
|
|
39
|
-
);
|
|
40
|
-
const designSystemRoot = fromRepoRoot('packages/libs/design-system');
|
|
41
|
-
return { manifestPath, designSystemRoot };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export async function readLssmManifest(): Promise<ShadcnRegistryManifest> {
|
|
45
|
-
const { manifestPath } = getLssmRegistryPaths();
|
|
46
|
-
return await readJsonFile<ShadcnRegistryManifest>(manifestPath);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export async function buildLssmItemJson(
|
|
50
|
-
nameOrNameJson: string,
|
|
51
|
-
logger: Logger
|
|
52
|
-
): Promise<ShadcnRegistryItemJson> {
|
|
53
|
-
const name = stripJsonSuffix(nameOrNameJson);
|
|
54
|
-
const manifest = await readLssmManifest();
|
|
55
|
-
const item = manifest.items.find((i) => i.name === name);
|
|
56
|
-
if (!item) {
|
|
57
|
-
throw new Error(`LSSM registry item not found: ${name}`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const { designSystemRoot } = getLssmRegistryPaths();
|
|
61
|
-
const files = await Promise.all(
|
|
62
|
-
item.files.map(async (f) => {
|
|
63
|
-
const abs = path.join(designSystemRoot, f.path);
|
|
64
|
-
const content = await readTextFile(abs);
|
|
65
|
-
return { ...f, content };
|
|
66
|
-
})
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
logger.info('lssm.registry.item_built', {
|
|
70
|
-
name: item.name,
|
|
71
|
-
fileCount: files.length,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
...item,
|
|
76
|
-
files,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export async function buildLssmManifestJson(
|
|
81
|
-
logger: Logger
|
|
82
|
-
): Promise<ShadcnRegistryManifest> {
|
|
83
|
-
const manifest = await readLssmManifest();
|
|
84
|
-
logger.info('lssm.registry.manifest_loaded', {
|
|
85
|
-
itemCount: manifest.items.length,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
return manifest;
|
|
89
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './server';
|
package/src/server.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { Elysia } from 'elysia';
|
|
2
|
-
import { cors } from '@elysiajs/cors';
|
|
3
|
-
import { serverTiming } from '@elysiajs/server-timing';
|
|
4
|
-
import { elysiaLogger, Logger, LogLevel } from '@lssm/lib.logger';
|
|
5
|
-
import {
|
|
6
|
-
buildLssmItemJson,
|
|
7
|
-
buildLssmManifestJson,
|
|
8
|
-
} from './handlers/lssm-handler';
|
|
9
|
-
import {
|
|
10
|
-
buildContractSpecItemJson,
|
|
11
|
-
readContractSpecManifest,
|
|
12
|
-
} from './handlers/contractspec-handler';
|
|
13
|
-
|
|
14
|
-
const PORT = Number(process.env.PORT ?? 8090);
|
|
15
|
-
|
|
16
|
-
const logger = new Logger({
|
|
17
|
-
level: process.env.NODE_ENV === 'production' ? LogLevel.INFO : LogLevel.DEBUG,
|
|
18
|
-
environment: process.env.NODE_ENV || 'development',
|
|
19
|
-
enableTracing: true,
|
|
20
|
-
enableTiming: true,
|
|
21
|
-
enableContext: true,
|
|
22
|
-
enableColors: process.env.NODE_ENV !== 'production',
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export const app = new Elysia()
|
|
26
|
-
.use(cors())
|
|
27
|
-
.use(
|
|
28
|
-
elysiaLogger({
|
|
29
|
-
logger,
|
|
30
|
-
logRequests: true,
|
|
31
|
-
logResponses: true,
|
|
32
|
-
excludePaths: ['/health', '/healthz', '/favicon.ico'],
|
|
33
|
-
})
|
|
34
|
-
)
|
|
35
|
-
.use(serverTiming())
|
|
36
|
-
.get('/health', () => ({ status: 'healthy' }))
|
|
37
|
-
.get('/healthz', () => ({ status: 'healthy' }))
|
|
38
|
-
.get('/', () => ({
|
|
39
|
-
name: 'lssm-registry-server',
|
|
40
|
-
routes: {
|
|
41
|
-
lssmManifest: '/r/lssm.json',
|
|
42
|
-
lssmItem: '/r/lssm/:name',
|
|
43
|
-
contractspecManifest: '/r/contractspec.json',
|
|
44
|
-
contractspecItem: '/r/contractspec/:type/:name',
|
|
45
|
-
},
|
|
46
|
-
}))
|
|
47
|
-
.get('/r/lssm.json', async ({ set }) => {
|
|
48
|
-
try {
|
|
49
|
-
return await buildLssmManifestJson(logger);
|
|
50
|
-
} catch (error) {
|
|
51
|
-
set.status = 500;
|
|
52
|
-
return {
|
|
53
|
-
error: 'Failed to load LSSM registry manifest',
|
|
54
|
-
message: error instanceof Error ? error.message : String(error),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
.get('/r/lssm/:name', async ({ params, set }) => {
|
|
59
|
-
try {
|
|
60
|
-
return await buildLssmItemJson(params.name, logger);
|
|
61
|
-
} catch (error) {
|
|
62
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
63
|
-
set.status = msg.includes('not found') ? 404 : 500;
|
|
64
|
-
return {
|
|
65
|
-
error: 'Failed to build LSSM registry item',
|
|
66
|
-
message: msg,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
.get('/r/contractspec.json', async ({ set }) => {
|
|
71
|
-
try {
|
|
72
|
-
return await readContractSpecManifest(logger);
|
|
73
|
-
} catch (error) {
|
|
74
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
75
|
-
set.status = msg.includes('ENOENT') ? 404 : 500;
|
|
76
|
-
return {
|
|
77
|
-
error: 'Failed to load ContractSpec registry manifest',
|
|
78
|
-
message: msg,
|
|
79
|
-
hint: 'Run the contracts registry build step to generate packages/libs/contracts/registry/registry.json',
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
.get('/r/contractspec/:type/:name', async ({ params, set }) => {
|
|
84
|
-
try {
|
|
85
|
-
return await buildContractSpecItemJson(params.type, params.name, logger);
|
|
86
|
-
} catch (error) {
|
|
87
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
88
|
-
set.status = msg.includes('not found') ? 404 : 500;
|
|
89
|
-
return {
|
|
90
|
-
error: 'Failed to build ContractSpec registry item',
|
|
91
|
-
message: msg,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
.listen(PORT);
|
|
96
|
-
|
|
97
|
-
logger.info('registry-server.started', {
|
|
98
|
-
port: PORT,
|
|
99
|
-
endpoints: {
|
|
100
|
-
health: '/health',
|
|
101
|
-
lssm: { manifest: '/r/lssm.json', item: '/r/lssm/:name' },
|
|
102
|
-
contractspec: {
|
|
103
|
-
manifest: '/r/contractspec.json',
|
|
104
|
-
item: '/r/contractspec/:type/:name',
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
export type App = typeof app;
|
package/src/utils/fs.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
|
|
3
|
-
export async function readJsonFile<T>(absolutePath: string): Promise<T> {
|
|
4
|
-
const raw = await readFile(absolutePath, 'utf8');
|
|
5
|
-
return JSON.parse(raw) as T;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export async function readTextFile(absolutePath: string): Promise<string> {
|
|
9
|
-
return await readFile(absolutePath, 'utf8');
|
|
10
|
-
}
|
package/src/utils/paths.ts
DELETED