/** * Prototype normalization utilities for ProtoPedia API responses. * * @module fetcher/utils/normalize-prototype */ import type { NormalizedPrototype } from '../../types/index.js'; import type { UpstreamPrototype } from '../types/prototype-api.types.js'; /** * Transform an upstream prototype object into the normalized shape. * * This function maps all fields from {@link UpstreamPrototype} to * {@link NormalizedPrototype}, applying the following transformations: * * **Pipe-separated fields** (split into trimmed arrays): * - tags, awards, events, materials * - Uses {@link splitPipeSeparatedString} * - Empty segments filtered out * - null/undefined → empty array * * **Users field** (`users`): * - Uses {@link splitPipeSeparatedUsers} (not the plain pipe splitter) * - Each username is `displayName@profileId`, and a `displayName` may contain an * un-escaped `|`; the `@`-aware split keeps such a username whole (issue #112) * - **Not trimmed** — whitespace is part of the display name * - null/undefined → empty array * * **Timestamp fields** (normalized to UTC ISO strings): * - createDate, updateDate: ProtoPedia JST format → UTC * - releaseDate: ProtoPedia JST format → UTC, null/undefined → undefined * - Uses {@link normalizeProtoPediaTimestamp} * - Fallback to original string if parsing fails * * **Optional fields** (default values when null/undefined): * - releaseFlg: 2 (Released) * - revision: 0 * - licenseType: 1 * - thanksFlg: 0 * - String fields (summary, freeComment, etc.): '' * * **Other fields**: Copied as-is * * @param prototype - The raw prototype object from the ProtoPedia API. * @returns A {@link NormalizedPrototype} instance with all fields normalized. * * @example * ```ts * const upstream: UpstreamPrototype = { * id: 123, * prototypeNm: 'My Project', * tags: 'IoT | AI | Robotics', * users: 'user1@id1|user2@id2', * createDate: '2024-01-01 12:00:00.0', * // ...other fields * }; * * const normalized = normalizePrototype(upstream); * // normalized.tags => ['IoT', 'AI', 'Robotics'] * // normalized.users => ['user1@id1', 'user2@id2'] * // normalized.createDate => '2024-01-01T03:00:00.000Z' (JST → UTC) * ``` */ export declare function normalizePrototype(p: UpstreamPrototype): NormalizedPrototype; //# sourceMappingURL=normalize-prototype.d.ts.map