📄 src/clc/index.ts
D-OPEN SOVEREIGN
1/*
2 * Copyright (c) 2026 DataPond D-Library Pty Ltd. ("The Sanctuary")
3 * Non-Profit Public Library — The World Library
4 *
5 * D-SAFE Certification issued by POND Enterprise.
6 * Published under the D-Open Code Sovereign Licence v1.0 framework
7 * DataPond D-Library All exclusive Right reserved on modifiying the code - CC Attribution to data pond, Non modifiable, Non Commercial.
8 * https://registry.world.bibliotech.com/licence
9 * Source code donated to DataPond D-Library by it's author: data pond.
10 *
11 * Technical Guardian ("The Shield"): Pond Enterprise Pty Ltd. (ACN 694 747 987)
12 * All liability claims about D-SAFE certification issues coming from the published D-Safe direction must be addressed with Pond Enterprise Pty Ltd.
13 * Code Modification automatically voids the certified liability protection provided by Pond Enterprise.
14 */
15import type { StandardAdapter, ValidationResult }
16 from '@the_library/canonical-schemas/types/StandardAdapter';
17
18interface CLCProps extends Record<string, string | null> { clcNotation: string | null; }
19
20type CLCApis = Record<string, never>;
21
22export const CLCAdapter: StandardAdapter<CLCProps, CLCApis> = {
23 standardId: 'clc',
24 uriScheme: 'CLC',
25
26 normalize(value: string): string {
27 return value.trim();
28 },
29
30 display(value: string): string {
31 return CLCAdapter.normalize(value);
32 },
33
34 validate(value: string | null | undefined): ValidationResult {
35 if (!value) return { valid: false, error: 'CLC notation is absent' };
36 const normalized = CLCAdapter.normalize(value);
37 if (!/^[A-Z0-9\.\-\+\=\s]+$/.test(normalized))
38 return { valid: false, error: `CLC notation does not match pattern: ${normalized}` };
39 return { valid: true };
40 },
41
42 toLinkedDataUri(value: string): string {
43 return `https://clc.nlc.cn/${CLCAdapter.normalize(value)}`;
44 },
45
46 apis: {},
47};
48