@lssm/app.registry-server 0.0.0-canary-20251221132705 → 0.0.0-canary-20251221153314

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @lssm/app.registry-server
2
2
 
3
- ## 0.0.0-canary-20251221132705
3
+ ## 0.0.0-canary-20251221153314
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -9,5 +9,5 @@
9
9
  ### Patch Changes
10
10
 
11
11
  - Updated dependencies [66a5dfd]
12
- - @lssm/lib.contracts@0.0.0-canary-20251221132705
13
- - @lssm/lib.logger@0.0.0-canary-20251221132705
12
+ - @lssm/lib.contracts@0.0.0-canary-20251221153314
13
+ - @lssm/lib.logger@0.0.0-canary-20251221153314
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lssm/app.registry-server",
3
- "version": "0.0.0-canary-20251221132705",
3
+ "version": "0.0.0-canary-20251221153314",
4
4
  "type": "module",
5
5
  "module": "src/index.ts",
6
6
  "scripts": {
@@ -15,10 +15,10 @@
15
15
  "start": "./server"
16
16
  },
17
17
  "dependencies": {
18
- "@lssm/lib.contracts": "0.0.0-canary-20251221132705",
18
+ "@lssm/lib.contracts": "0.0.0-canary-20251221153314",
19
19
  "@elysiajs/cors": "^1.4.0",
20
20
  "@elysiajs/server-timing": "^1.4.0",
21
- "@lssm/lib.logger": "0.0.0-canary-20251221132705",
21
+ "@lssm/lib.logger": "0.0.0-canary-20251221153314",
22
22
  "elysia": "^1.4.19"
23
23
  },
24
24
  "license": "MIT",
package/server ADDED
Binary file
@@ -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
- }
@@ -1,9 +0,0 @@
1
- import path from 'node:path';
2
-
3
- export function repoRoot(): string {
4
- return process.env.CONTRACTSPEC_REPO_ROOT ?? process.cwd();
5
- }
6
-
7
- export function fromRepoRoot(...segments: string[]): string {
8
- return path.join(repoRoot(), ...segments);
9
- }
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "@lssm/tool.typescript/base.json",
3
- "include": ["src"],
4
- "exclude": ["node_modules"],
5
- "compilerOptions": {
6
- "noEmit": true
7
- }
8
- }
9
-
10
-