📄 src/cc/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 CCProps extends Record<string, string | null> { ccNotation: string | null; }
19
20type CCApis = Record<string, never>;
21
22export const CCAdapter: StandardAdapter<CCProps, CCApis> = {
23  standardId: 'cc',
24  uriScheme:  'CC',
25
26  normalize(value: string): string {
27    return value.trim();
28  },
29
30  display(value: string): string {
31    return CCAdapter.normalize(value);
32  },
33
34  validate(value: string | null | undefined): ValidationResult {
35    if (!value) return { valid: false, error: 'CC notation is absent' };
36    const normalized = CCAdapter.normalize(value);
37    if (!/^[A-Za-z0-9\:\,\;\-\.\'\s]+$/.test(normalized))
38      return { valid: false, error: `CC notation does not match pattern: ${normalized}` };
39    return { valid: true };
40  },
41
42  toLinkedDataUri(value: string): string {
43    return `https://isko.org/cc/${CCAdapter.normalize(value)}`;
44  },
45
46  apis: {},
47};
48