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