promidas 2.0.0
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/LICENSE +21 -0
- package/README.md +179 -0
- package/dist/builder.d.ts +158 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +255 -0
- package/dist/builder.js.map +1 -0
- package/dist/factory.d.ts +154 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +243 -0
- package/dist/factory.js.map +1 -0
- package/dist/fetcher/client/config.d.ts +140 -0
- package/dist/fetcher/client/config.d.ts.map +1 -0
- package/dist/fetcher/client/config.js +2 -0
- package/dist/fetcher/client/config.js.map +1 -0
- package/dist/fetcher/client/fetch-with-progress.d.ts +156 -0
- package/dist/fetcher/client/fetch-with-progress.d.ts.map +1 -0
- package/dist/fetcher/client/fetch-with-progress.js +313 -0
- package/dist/fetcher/client/fetch-with-progress.js.map +1 -0
- package/dist/fetcher/client/fetch-with-timeout.d.ts +6 -0
- package/dist/fetcher/client/fetch-with-timeout.d.ts.map +1 -0
- package/dist/fetcher/client/fetch-with-timeout.js +48 -0
- package/dist/fetcher/client/fetch-with-timeout.js.map +1 -0
- package/dist/fetcher/client/protopedia-api-custom-client.d.ts +141 -0
- package/dist/fetcher/client/protopedia-api-custom-client.d.ts.map +1 -0
- package/dist/fetcher/client/protopedia-api-custom-client.js +268 -0
- package/dist/fetcher/client/protopedia-api-custom-client.js.map +1 -0
- package/dist/fetcher/client/select-custom-fetch.d.ts +58 -0
- package/dist/fetcher/client/select-custom-fetch.d.ts.map +1 -0
- package/dist/fetcher/client/select-custom-fetch.js +58 -0
- package/dist/fetcher/client/select-custom-fetch.js.map +1 -0
- package/dist/fetcher/errors/fetcher-error.d.ts +10 -0
- package/dist/fetcher/errors/fetcher-error.d.ts.map +1 -0
- package/dist/fetcher/errors/fetcher-error.js +15 -0
- package/dist/fetcher/errors/fetcher-error.js.map +1 -0
- package/dist/fetcher/index.d.ts +73 -0
- package/dist/fetcher/index.d.ts.map +1 -0
- package/dist/fetcher/index.js +70 -0
- package/dist/fetcher/index.js.map +1 -0
- package/dist/fetcher/types/index.d.ts +9 -0
- package/dist/fetcher/types/index.d.ts.map +1 -0
- package/dist/fetcher/types/index.js +7 -0
- package/dist/fetcher/types/index.js.map +1 -0
- package/dist/fetcher/types/progress-event.types.d.ts +221 -0
- package/dist/fetcher/types/progress-event.types.d.ts.map +1 -0
- package/dist/fetcher/types/progress-event.types.js +10 -0
- package/dist/fetcher/types/progress-event.types.js.map +1 -0
- package/dist/fetcher/types/prototype-api.types.d.ts +106 -0
- package/dist/fetcher/types/prototype-api.types.d.ts.map +1 -0
- package/dist/fetcher/types/prototype-api.types.js +2 -0
- package/dist/fetcher/types/prototype-api.types.js.map +1 -0
- package/dist/fetcher/types/result.types.d.ts +75 -0
- package/dist/fetcher/types/result.types.d.ts.map +1 -0
- package/dist/fetcher/types/result.types.js +2 -0
- package/dist/fetcher/types/result.types.js.map +1 -0
- package/dist/fetcher/utils/create-client-fetch.d.ts +63 -0
- package/dist/fetcher/utils/create-client-fetch.d.ts.map +1 -0
- package/dist/fetcher/utils/create-client-fetch.js +89 -0
- package/dist/fetcher/utils/create-client-fetch.js.map +1 -0
- package/dist/fetcher/utils/create-fetch-with-stripped-headers.d.ts +6 -0
- package/dist/fetcher/utils/create-fetch-with-stripped-headers.d.ts.map +1 -0
- package/dist/fetcher/utils/create-fetch-with-stripped-headers.js +40 -0
- package/dist/fetcher/utils/create-fetch-with-stripped-headers.js.map +1 -0
- package/dist/fetcher/utils/errors/handler.d.ts +58 -0
- package/dist/fetcher/utils/errors/handler.d.ts.map +1 -0
- package/dist/fetcher/utils/errors/handler.js +243 -0
- package/dist/fetcher/utils/errors/handler.js.map +1 -0
- package/dist/fetcher/utils/errors/messages.d.ts +75 -0
- package/dist/fetcher/utils/errors/messages.d.ts.map +1 -0
- package/dist/fetcher/utils/errors/messages.js +88 -0
- package/dist/fetcher/utils/errors/messages.js.map +1 -0
- package/dist/fetcher/utils/index.d.ts +13 -0
- package/dist/fetcher/utils/index.d.ts.map +1 -0
- package/dist/fetcher/utils/index.js +12 -0
- package/dist/fetcher/utils/index.js.map +1 -0
- package/dist/fetcher/utils/log-timestamp-normalization-warnings.d.ts +10 -0
- package/dist/fetcher/utils/log-timestamp-normalization-warnings.d.ts.map +1 -0
- package/dist/fetcher/utils/log-timestamp-normalization-warnings.js +32 -0
- package/dist/fetcher/utils/log-timestamp-normalization-warnings.js.map +1 -0
- package/dist/fetcher/utils/normalize-protopedia-timestamp.d.ts +59 -0
- package/dist/fetcher/utils/normalize-protopedia-timestamp.d.ts.map +1 -0
- package/dist/fetcher/utils/normalize-protopedia-timestamp.js +81 -0
- package/dist/fetcher/utils/normalize-protopedia-timestamp.js.map +1 -0
- package/dist/fetcher/utils/normalize-prototype.d.ts +56 -0
- package/dist/fetcher/utils/normalize-prototype.d.ts.map +1 -0
- package/dist/fetcher/utils/normalize-prototype.js +113 -0
- package/dist/fetcher/utils/normalize-prototype.js.map +1 -0
- package/dist/fetcher/utils/sanitize-options.d.ts +14 -0
- package/dist/fetcher/utils/sanitize-options.d.ts.map +1 -0
- package/dist/fetcher/utils/sanitize-options.js +16 -0
- package/dist/fetcher/utils/sanitize-options.js.map +1 -0
- package/dist/fetcher/utils/string-parsers.d.ts +45 -0
- package/dist/fetcher/utils/string-parsers.d.ts.map +1 -0
- package/dist/fetcher/utils/string-parsers.js +53 -0
- package/dist/fetcher/utils/string-parsers.js.map +1 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/console-logger.d.ts +74 -0
- package/dist/logger/console-logger.d.ts.map +1 -0
- package/dist/logger/console-logger.js +113 -0
- package/dist/logger/console-logger.js.map +1 -0
- package/dist/logger/factory.d.ts +88 -0
- package/dist/logger/factory.d.ts.map +1 -0
- package/dist/logger/factory.js +94 -0
- package/dist/logger/factory.js.map +1 -0
- package/dist/logger/index.d.ts +42 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +41 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/logger.types.d.ts +49 -0
- package/dist/logger/logger.types.d.ts.map +1 -0
- package/dist/logger/logger.types.js +2 -0
- package/dist/logger/logger.types.js.map +1 -0
- package/dist/repository/errors/validation-error.d.ts +24 -0
- package/dist/repository/errors/validation-error.d.ts.map +1 -0
- package/dist/repository/errors/validation-error.js +26 -0
- package/dist/repository/errors/validation-error.js.map +1 -0
- package/dist/repository/index.d.ts +122 -0
- package/dist/repository/index.d.ts.map +1 -0
- package/dist/repository/index.js +44 -0
- package/dist/repository/index.js.map +1 -0
- package/dist/repository/protopedia-in-memory-repository.d.ts +560 -0
- package/dist/repository/protopedia-in-memory-repository.d.ts.map +1 -0
- package/dist/repository/protopedia-in-memory-repository.js +929 -0
- package/dist/repository/protopedia-in-memory-repository.js.map +1 -0
- package/dist/repository/schemas/index.d.ts +9 -0
- package/dist/repository/schemas/index.d.ts.map +1 -0
- package/dist/repository/schemas/index.js +11 -0
- package/dist/repository/schemas/index.js.map +1 -0
- package/dist/repository/schemas/params.d.ts +44 -0
- package/dist/repository/schemas/params.d.ts.map +1 -0
- package/dist/repository/schemas/params.js +44 -0
- package/dist/repository/schemas/params.js.map +1 -0
- package/dist/repository/schemas/serializable-snapshot.d.ts +33 -0
- package/dist/repository/schemas/serializable-snapshot.d.ts.map +1 -0
- package/dist/repository/schemas/serializable-snapshot.js +45 -0
- package/dist/repository/schemas/serializable-snapshot.js.map +1 -0
- package/dist/repository/types/analysis.types.d.ts +89 -0
- package/dist/repository/types/analysis.types.d.ts.map +1 -0
- package/dist/repository/types/analysis.types.js +2 -0
- package/dist/repository/types/analysis.types.js.map +1 -0
- package/dist/repository/types/index.d.ts +12 -0
- package/dist/repository/types/index.d.ts.map +1 -0
- package/dist/repository/types/index.js +7 -0
- package/dist/repository/types/index.js.map +1 -0
- package/dist/repository/types/repository-events.types.d.ts +110 -0
- package/dist/repository/types/repository-events.types.d.ts.map +1 -0
- package/dist/repository/types/repository-events.types.js +2 -0
- package/dist/repository/types/repository-events.types.js.map +1 -0
- package/dist/repository/types/repository.types.d.ts +330 -0
- package/dist/repository/types/repository.types.d.ts.map +1 -0
- package/dist/repository/types/repository.types.js +2 -0
- package/dist/repository/types/repository.types.js.map +1 -0
- package/dist/repository/types/result.types.d.ts +55 -0
- package/dist/repository/types/result.types.d.ts.map +1 -0
- package/dist/repository/types/result.types.js +2 -0
- package/dist/repository/types/result.types.js.map +1 -0
- package/dist/repository/types/serialization.types.d.ts +61 -0
- package/dist/repository/types/serialization.types.d.ts.map +1 -0
- package/dist/repository/types/serialization.types.js +2 -0
- package/dist/repository/types/serialization.types.js.map +1 -0
- package/dist/repository/types/snapshot-operation.types.d.ts +140 -0
- package/dist/repository/types/snapshot-operation.types.d.ts.map +1 -0
- package/dist/repository/types/snapshot-operation.types.js +2 -0
- package/dist/repository/types/snapshot-operation.types.js.map +1 -0
- package/dist/repository/utils/convert-fetch-result.d.ts +46 -0
- package/dist/repository/utils/convert-fetch-result.d.ts.map +1 -0
- package/dist/repository/utils/convert-fetch-result.js +59 -0
- package/dist/repository/utils/convert-fetch-result.js.map +1 -0
- package/dist/repository/utils/convert-store-result.d.ts +36 -0
- package/dist/repository/utils/convert-store-result.d.ts.map +1 -0
- package/dist/repository/utils/convert-store-result.js +36 -0
- package/dist/repository/utils/convert-store-result.js.map +1 -0
- package/dist/repository/utils/emit-repository-event-safely.d.ts +5 -0
- package/dist/repository/utils/emit-repository-event-safely.d.ts.map +1 -0
- package/dist/repository/utils/emit-repository-event-safely.js +17 -0
- package/dist/repository/utils/emit-repository-event-safely.js.map +1 -0
- package/dist/repository/utils/index.d.ts +3 -0
- package/dist/repository/utils/index.d.ts.map +1 -0
- package/dist/repository/utils/index.js +3 -0
- package/dist/repository/utils/index.js.map +1 -0
- package/dist/repository/validation/index.d.ts +9 -0
- package/dist/repository/validation/index.d.ts.map +1 -0
- package/dist/repository/validation/index.js +10 -0
- package/dist/repository/validation/index.js.map +1 -0
- package/dist/repository/validation/params-validators.d.ts +46 -0
- package/dist/repository/validation/params-validators.d.ts.map +1 -0
- package/dist/repository/validation/params-validators.js +68 -0
- package/dist/repository/validation/params-validators.js.map +1 -0
- package/dist/repository/validation/serializable-snapshot.d.ts +47 -0
- package/dist/repository/validation/serializable-snapshot.d.ts.map +1 -0
- package/dist/repository/validation/serializable-snapshot.js +104 -0
- package/dist/repository/validation/serializable-snapshot.js.map +1 -0
- package/dist/schemas/index.d.ts +8 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +8 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/normalized-prototype.d.ts +56 -0
- package/dist/schemas/normalized-prototype.d.ts.map +1 -0
- package/dist/schemas/normalized-prototype.js +123 -0
- package/dist/schemas/normalized-prototype.js.map +1 -0
- package/dist/store/errors/store-error.d.ts +148 -0
- package/dist/store/errors/store-error.d.ts.map +1 -0
- package/dist/store/errors/store-error.js +156 -0
- package/dist/store/errors/store-error.js.map +1 -0
- package/dist/store/index.d.ts +84 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +83 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/store.d.ts +295 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +411 -0
- package/dist/store/store.js.map +1 -0
- package/dist/store/types/index.d.ts +2 -0
- package/dist/store/types/index.d.ts.map +1 -0
- package/dist/store/types/index.js +2 -0
- package/dist/store/types/index.js.map +1 -0
- package/dist/store/types/result.types.d.ts +67 -0
- package/dist/store/types/result.types.d.ts.map +1 -0
- package/dist/store/types/result.types.js +2 -0
- package/dist/store/types/result.types.js.map +1 -0
- package/dist/types/codes.d.ts +44 -0
- package/dist/types/codes.d.ts.map +1 -0
- package/dist/types/codes.js +9 -0
- package/dist/types/codes.js.map +1 -0
- package/dist/types/index.d.ts +61 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +60 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/normalized-prototype.d.ts +95 -0
- package/dist/types/normalized-prototype.d.ts.map +1 -0
- package/dist/types/normalized-prototype.js +2 -0
- package/dist/types/normalized-prototype.js.map +1 -0
- package/dist/utils/converters/index.d.ts +15 -0
- package/dist/utils/converters/index.d.ts.map +1 -0
- package/dist/utils/converters/index.js +15 -0
- package/dist/utils/converters/index.js.map +1 -0
- package/dist/utils/converters/license-type.d.ts +23 -0
- package/dist/utils/converters/license-type.d.ts.map +1 -0
- package/dist/utils/converters/license-type.js +38 -0
- package/dist/utils/converters/license-type.js.map +1 -0
- package/dist/utils/converters/release-flag.d.ts +24 -0
- package/dist/utils/converters/release-flag.d.ts.map +1 -0
- package/dist/utils/converters/release-flag.js +40 -0
- package/dist/utils/converters/release-flag.js.map +1 -0
- package/dist/utils/converters/status.d.ts +23 -0
- package/dist/utils/converters/status.d.ts.map +1 -0
- package/dist/utils/converters/status.js +40 -0
- package/dist/utils/converters/status.js.map +1 -0
- package/dist/utils/converters/thanks-flag.d.ts +25 -0
- package/dist/utils/converters/thanks-flag.d.ts.map +1 -0
- package/dist/utils/converters/thanks-flag.js +41 -0
- package/dist/utils/converters/thanks-flag.js.map +1 -0
- package/dist/utils/deep-merge.d.ts +38 -0
- package/dist/utils/deep-merge.d.ts.map +1 -0
- package/dist/utils/deep-merge.js +85 -0
- package/dist/utils/deep-merge.js.map +1 -0
- package/dist/utils/index.d.ts +80 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +85 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger-utils.d.ts +100 -0
- package/dist/utils/logger-utils.d.ts.map +1 -0
- package/dist/utils/logger-utils.js +265 -0
- package/dist/utils/logger-utils.js.map +1 -0
- package/dist/utils/time/constants.d.ts +14 -0
- package/dist/utils/time/constants.d.ts.map +1 -0
- package/dist/utils/time/constants.js +14 -0
- package/dist/utils/time/constants.js.map +1 -0
- package/dist/utils/time/index.d.ts +28 -0
- package/dist/utils/time/index.d.ts.map +1 -0
- package/dist/utils/time/index.js +28 -0
- package/dist/utils/time/index.js.map +1 -0
- package/dist/utils/time/parser.d.ts +91 -0
- package/dist/utils/time/parser.d.ts.map +1 -0
- package/dist/utils/time/parser.js +143 -0
- package/dist/utils/time/parser.js.map +1 -0
- package/dist/utils/validation/index.d.ts +8 -0
- package/dist/utils/validation/index.d.ts.map +1 -0
- package/dist/utils/validation/index.js +7 -0
- package/dist/utils/validation/index.js.map +1 -0
- package/dist/utils/validation/normalized-prototype.d.ts +64 -0
- package/dist/utils/validation/normalized-prototype.d.ts.map +1 -0
- package/dist/utils/validation/normalized-prototype.js +97 -0
- package/dist/utils/validation/normalized-prototype.js.map +1 -0
- package/dist/utils/validation/types.d.ts +62 -0
- package/dist/utils/validation/types.d.ts.map +1 -0
- package/dist/utils/validation/types.js +8 -0
- package/dist/utils/validation/types.js.map +1 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +138 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type definitions for the library.
|
|
3
|
+
*
|
|
4
|
+
* This module provides the core data structures used throughout the library.
|
|
5
|
+
* It serves as the single source of truth for type definitions, ensuring
|
|
6
|
+
* consistency across all layers (Fetcher, Store, Repository).
|
|
7
|
+
*
|
|
8
|
+
* ## Main Exports
|
|
9
|
+
*
|
|
10
|
+
* - {@link NormalizedPrototype} — The standardized shape of a prototype
|
|
11
|
+
* after normalization from ProtoPedia API responses.
|
|
12
|
+
* - {@link StatusCode} — Type for prototype status codes (1-4)
|
|
13
|
+
* - {@link ReleaseFlagCode} — Type for release flag codes (1-3)
|
|
14
|
+
* - {@link LicenseTypeCode} — Type for license type codes (0-1)
|
|
15
|
+
* - {@link ThanksFlagCode} — Type for thanks flag codes (0, 1, or undefined)
|
|
16
|
+
*
|
|
17
|
+
* ## Type Characteristics
|
|
18
|
+
*
|
|
19
|
+
* - **Type Safety**: Strongly typed with clear required/optional field distinction
|
|
20
|
+
* - **Normalization**: Pipe-separated strings converted to arrays, timestamps to UTC ISO 8601
|
|
21
|
+
* - **Strict Typing**: Compatible with TypeScript's `exactOptionalPropertyTypes: true`
|
|
22
|
+
* - **Cross-Layer Consistency**: Used uniformly across Fetcher, Store, and Repository
|
|
23
|
+
*
|
|
24
|
+
* ## Usage
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import type { NormalizedPrototype, StatusCode } from 'promidas/types';
|
|
29
|
+
*
|
|
30
|
+
* function processPrototype(prototype: NormalizedPrototype) {
|
|
31
|
+
* // Required fields are always accessible
|
|
32
|
+
* console.log(prototype.id, prototype.prototypeNm);
|
|
33
|
+
*
|
|
34
|
+
* // Array fields are type-safe
|
|
35
|
+
* prototype.tags.forEach(tag => console.log(tag)); // tag is string
|
|
36
|
+
*
|
|
37
|
+
* // Optional fields require undefined checks
|
|
38
|
+
* if (prototype.releaseDate !== undefined) {
|
|
39
|
+
* console.log(new Date(prototype.releaseDate));
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* // Code types are available
|
|
43
|
+
* const status: StatusCode = prototype.status as StatusCode;
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* ## Data Transformation
|
|
48
|
+
*
|
|
49
|
+
* This type represents data after normalization:
|
|
50
|
+
*
|
|
51
|
+
* - **Raw API data** (`UpstreamPrototype`) → `normalizePrototype()` → **Normalized data** (`NormalizedPrototype`)
|
|
52
|
+
* - Pipe-separated strings (`"tag1|tag2"`) → Arrays (`["tag1", "tag2"]`)
|
|
53
|
+
* - JST timestamps (`"2025-12-12 09:00:00.0"`) → UTC ISO 8601 (`"2025-12-12T00:00:00.000Z"`)
|
|
54
|
+
*
|
|
55
|
+
* @module
|
|
56
|
+
* @see {@link NormalizedPrototype} for detailed field documentation
|
|
57
|
+
* @see {@link ../fetcher/index.js} for normalization utilities
|
|
58
|
+
*/
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalized prototype type definition.
|
|
3
|
+
*
|
|
4
|
+
* This module defines the canonical {@link NormalizedPrototype} type used
|
|
5
|
+
* throughout the library to represent ProtoPedia prototype data in a
|
|
6
|
+
* standardized, type-safe format.
|
|
7
|
+
*
|
|
8
|
+
* ## Purpose
|
|
9
|
+
*
|
|
10
|
+
* The {@link NormalizedPrototype} type serves as the universal data model
|
|
11
|
+
* for prototype information across all layers of this library:
|
|
12
|
+
*
|
|
13
|
+
* - **Fetcher layer** - Normalizes raw API responses into this type
|
|
14
|
+
* - **Store layer** - Manages snapshots of this type in memory
|
|
15
|
+
* - **Repository layer** - Provides access methods returning this type
|
|
16
|
+
*
|
|
17
|
+
* ## Key Features
|
|
18
|
+
*
|
|
19
|
+
* - **Type safety** - All fields are strongly typed with appropriate nullability
|
|
20
|
+
* - **Consistency** - Ensures uniform data structure across the application
|
|
21
|
+
* - **API compatibility** - Handles optional fields from protopedia-api-v2-client v3.0.0+
|
|
22
|
+
* - **Strict typing** - Uses `exactOptionalPropertyTypes: true` for maximum safety
|
|
23
|
+
*
|
|
24
|
+
* ## Related Components
|
|
25
|
+
*
|
|
26
|
+
* - {@link normalizePrototype} - Function that transforms raw API data into this type
|
|
27
|
+
* - {@link PrototypeInMemoryStore} - Store implementation using this type
|
|
28
|
+
* - {@link ProtopediaApiCustomClient.fetchPrototypes} - Method that fetches and returns this type
|
|
29
|
+
*
|
|
30
|
+
* @module
|
|
31
|
+
*/
|
|
32
|
+
import type { StatusCode, ReleaseFlagCode, LicenseTypeCode, ThanksFlagCode } from './codes.js';
|
|
33
|
+
/**
|
|
34
|
+
* Normalized prototype data structure.
|
|
35
|
+
*
|
|
36
|
+
* This type represents a ProtoPedia prototype in a standardized format,
|
|
37
|
+
* with all upstream API fields normalized and transformed for consistent
|
|
38
|
+
* use throughout the library.
|
|
39
|
+
*
|
|
40
|
+
* ## Field Transformations
|
|
41
|
+
*
|
|
42
|
+
* - **Pipe-separated strings** (tags, users, awards, events, materials)
|
|
43
|
+
* are converted to arrays
|
|
44
|
+
* - **Date strings** (createDate, updateDate, releaseDate) are converted
|
|
45
|
+
* from JST to UTC ISO 8601 format
|
|
46
|
+
* - **Optional fields** have appropriate default values applied when missing
|
|
47
|
+
*
|
|
48
|
+
* ## Type Safety
|
|
49
|
+
*
|
|
50
|
+
* This type uses TypeScript's `exactOptionalPropertyTypes: true` setting.
|
|
51
|
+
* Optional properties are explicitly typed as `Type?: undefined | Type`
|
|
52
|
+
* to ensure proper handling of undefined values.
|
|
53
|
+
*
|
|
54
|
+
* @see {@link normalizePrototype} for the transformation logic
|
|
55
|
+
*/
|
|
56
|
+
export type NormalizedPrototype = {
|
|
57
|
+
id: number;
|
|
58
|
+
createDate: string;
|
|
59
|
+
updateDate?: undefined | string;
|
|
60
|
+
releaseDate?: undefined | string;
|
|
61
|
+
createId?: undefined | number;
|
|
62
|
+
updateId?: undefined | number;
|
|
63
|
+
releaseFlg: ReleaseFlagCode;
|
|
64
|
+
status: StatusCode;
|
|
65
|
+
prototypeNm: string;
|
|
66
|
+
summary: string;
|
|
67
|
+
freeComment: string;
|
|
68
|
+
systemDescription: string;
|
|
69
|
+
/** Users and Team */
|
|
70
|
+
users: string[];
|
|
71
|
+
teamNm: string;
|
|
72
|
+
/** Tags, Materials, Events, and Awards */
|
|
73
|
+
tags: string[];
|
|
74
|
+
materials: string[];
|
|
75
|
+
events: string[];
|
|
76
|
+
awards: string[];
|
|
77
|
+
officialLink?: undefined | string;
|
|
78
|
+
videoUrl?: undefined | string;
|
|
79
|
+
mainUrl: string;
|
|
80
|
+
relatedLink?: undefined | string;
|
|
81
|
+
relatedLink2?: undefined | string;
|
|
82
|
+
relatedLink3?: undefined | string;
|
|
83
|
+
relatedLink4?: undefined | string;
|
|
84
|
+
relatedLink5?: undefined | string;
|
|
85
|
+
viewCount: number;
|
|
86
|
+
goodCount: number;
|
|
87
|
+
commentCount: number;
|
|
88
|
+
uuid?: undefined | string;
|
|
89
|
+
nid?: undefined | string;
|
|
90
|
+
revision?: undefined | number;
|
|
91
|
+
licenseType?: undefined | LicenseTypeCode;
|
|
92
|
+
thanksFlg?: undefined | ThanksFlagCode;
|
|
93
|
+
slideMode?: undefined | number;
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=normalized-prototype.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalized-prototype.d.ts","sourceRoot":"","sources":["../../lib/types/normalized-prototype.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,eAAe,EACf,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAEhC,EAAE,EAAE,MAAM,CAAC;IAGX,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAChC,WAAW,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9B,UAAU,EAAE,eAAe,CAAC;IAG5B,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAE1B,qBAAqB;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IAEf,0CAA0C;IAC1C,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IAIjB,YAAY,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAElC,QAAQ,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAE9B,OAAO,EAAE,MAAM,CAAC;IAEhB,WAAW,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACjC,YAAY,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAClC,YAAY,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAClC,YAAY,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAClC,YAAY,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAElC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IAGrB,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC1B,GAAG,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,SAAS,GAAG,eAAe,CAAC;IAC1C,SAAS,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC;IACvC,SAAS,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;CAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalized-prototype.js","sourceRoot":"","sources":["../../lib/types/normalized-prototype.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value-to-label converters for ProtoPedia fields.
|
|
3
|
+
*
|
|
4
|
+
* These converters transform numeric codes from the ProtoPedia API
|
|
5
|
+
* into human-readable labels.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/converters
|
|
8
|
+
*
|
|
9
|
+
* @see https://protopedia.gitbook.io/helpcenter/info/2022.05.23
|
|
10
|
+
*/
|
|
11
|
+
export * from './status.js';
|
|
12
|
+
export * from './release-flag.js';
|
|
13
|
+
export * from './thanks-flag.js';
|
|
14
|
+
export * from './license-type.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/utils/converters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value-to-label converters for ProtoPedia fields.
|
|
3
|
+
*
|
|
4
|
+
* These converters transform numeric codes from the ProtoPedia API
|
|
5
|
+
* into human-readable labels.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/converters
|
|
8
|
+
*
|
|
9
|
+
* @see https://protopedia.gitbook.io/helpcenter/info/2022.05.23
|
|
10
|
+
*/
|
|
11
|
+
export * from './status.js';
|
|
12
|
+
export * from './release-flag.js';
|
|
13
|
+
export * from './thanks-flag.js';
|
|
14
|
+
export * from './license-type.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/utils/converters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* License type value to label converter.
|
|
3
|
+
*
|
|
4
|
+
* Converts numeric license type codes from the ProtoPedia API to Japanese labels.
|
|
5
|
+
*
|
|
6
|
+
* @module utils/converters/license-type
|
|
7
|
+
*/
|
|
8
|
+
import type { LicenseTypeCode } from '../../types/codes.js';
|
|
9
|
+
/**
|
|
10
|
+
* Convert license type code to label.
|
|
11
|
+
*
|
|
12
|
+
* @param licenseType - License type from NormalizedPrototype.licenseType
|
|
13
|
+
* @returns Japanese label or the numeric value as string if unknown
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* getPrototypeLicenseTypeLabel(0); // => 'なし'
|
|
18
|
+
* getPrototypeLicenseTypeLabel(1); // => '表示(CC:BY)'
|
|
19
|
+
* getPrototypeLicenseTypeLabel(99); // => '99'
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const getPrototypeLicenseTypeLabel: (licenseType: LicenseTypeCode) => string;
|
|
23
|
+
//# sourceMappingURL=license-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"license-type.d.ts","sourceRoot":"","sources":["../../../lib/utils/converters/license-type.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAiB5D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,GACvC,aAAa,eAAe,KAC3B,MAEF,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* License type value to label converter.
|
|
3
|
+
*
|
|
4
|
+
* Converts numeric license type codes from the ProtoPedia API to Japanese labels.
|
|
5
|
+
*
|
|
6
|
+
* @module utils/converters/license-type
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* License type labels mapping.
|
|
10
|
+
*
|
|
11
|
+
* - 0: 'なし' (None) - **Not observed in API responses**
|
|
12
|
+
* - 1: '表示(CC:BY)' (Display with Creative Commons Attribution license) - **All API responses have this value**
|
|
13
|
+
*
|
|
14
|
+
* Note: In practice, all prototypes accessible via the public API have licenseType=1.
|
|
15
|
+
*
|
|
16
|
+
* @see https://protopedia.gitbook.io/helpcenter/info/2022.05.23
|
|
17
|
+
*/
|
|
18
|
+
const LICENSE_TYPE_LABELS = {
|
|
19
|
+
0: 'なし',
|
|
20
|
+
1: '表示(CC:BY)',
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Convert license type code to label.
|
|
24
|
+
*
|
|
25
|
+
* @param licenseType - License type from NormalizedPrototype.licenseType
|
|
26
|
+
* @returns Japanese label or the numeric value as string if unknown
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* getPrototypeLicenseTypeLabel(0); // => 'なし'
|
|
31
|
+
* getPrototypeLicenseTypeLabel(1); // => '表示(CC:BY)'
|
|
32
|
+
* getPrototypeLicenseTypeLabel(99); // => '99'
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export const getPrototypeLicenseTypeLabel = (licenseType) => {
|
|
36
|
+
return LICENSE_TYPE_LABELS[licenseType] ?? `${licenseType}`;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=license-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"license-type.js","sourceRoot":"","sources":["../../../lib/utils/converters/license-type.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;;;GASG;AACH,MAAM,mBAAmB,GAAoC;IAC3D,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,WAAW;CACf,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,WAA4B,EACpB,EAAE;IACV,OAAO,mBAAmB,CAAC,WAAW,CAAC,IAAI,GAAG,WAAW,EAAE,CAAC;AAC9D,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Release flag value to label converter.
|
|
3
|
+
*
|
|
4
|
+
* Converts numeric release flag codes from the ProtoPedia API to Japanese labels.
|
|
5
|
+
*
|
|
6
|
+
* **Note**: API typically only returns prototypes with `releaseFlg: 2` (publicly released).
|
|
7
|
+
*
|
|
8
|
+
* @module utils/converters/release-flag
|
|
9
|
+
*/
|
|
10
|
+
import type { ReleaseFlagCode } from '../../types/codes.js';
|
|
11
|
+
/**
|
|
12
|
+
* Convert release flag code to label.
|
|
13
|
+
*
|
|
14
|
+
* @param releaseFlag - Release flag from NormalizedPrototype.releaseFlg
|
|
15
|
+
* @returns Japanese label or the numeric value as string if unknown
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* getPrototypeReleaseFlagLabel(2); // => '一般公開'
|
|
20
|
+
* getPrototypeReleaseFlagLabel(0); // => '0'
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const getPrototypeReleaseFlagLabel: (releaseFlag: ReleaseFlagCode) => string;
|
|
24
|
+
//# sourceMappingURL=release-flag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release-flag.d.ts","sourceRoot":"","sources":["../../../lib/utils/converters/release-flag.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAkB5D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,4BAA4B,GACvC,aAAa,eAAe,KAC3B,MAEF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Release flag value to label converter.
|
|
3
|
+
*
|
|
4
|
+
* Converts numeric release flag codes from the ProtoPedia API to Japanese labels.
|
|
5
|
+
*
|
|
6
|
+
* **Note**: API typically only returns prototypes with `releaseFlg: 2` (publicly released).
|
|
7
|
+
*
|
|
8
|
+
* @module utils/converters/release-flag
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Release flag labels mapping.
|
|
12
|
+
*
|
|
13
|
+
* - 1: '下書き保存' (Draft) - **Not accessible via public API**
|
|
14
|
+
* - 2: '一般公開' (Public) - **Only this value appears in API responses**
|
|
15
|
+
* - 3: '限定共有' (Limited Sharing) - **Not accessible via public API**
|
|
16
|
+
*
|
|
17
|
+
* Note: The public API only returns publicly released prototypes (releaseFlg=2).
|
|
18
|
+
* Draft and limited sharing prototypes are not included in API responses.
|
|
19
|
+
*/
|
|
20
|
+
const RELEASE_FLAG_LABELS = {
|
|
21
|
+
1: '下書き保存',
|
|
22
|
+
2: '一般公開',
|
|
23
|
+
3: '限定共有',
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Convert release flag code to label.
|
|
27
|
+
*
|
|
28
|
+
* @param releaseFlag - Release flag from NormalizedPrototype.releaseFlg
|
|
29
|
+
* @returns Japanese label or the numeric value as string if unknown
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* getPrototypeReleaseFlagLabel(2); // => '一般公開'
|
|
34
|
+
* getPrototypeReleaseFlagLabel(0); // => '0'
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export const getPrototypeReleaseFlagLabel = (releaseFlag) => {
|
|
38
|
+
return RELEASE_FLAG_LABELS[releaseFlag] ?? `${releaseFlag}`;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=release-flag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release-flag.js","sourceRoot":"","sources":["../../../lib/utils/converters/release-flag.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;;;;;GASG;AACH,MAAM,mBAAmB,GAAoC;IAC3D,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;CACV,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,WAA4B,EACpB,EAAE;IACV,OAAO,mBAAmB,CAAC,WAAW,CAAC,IAAI,GAAG,WAAW,EAAE,CAAC;AAC9D,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status value to label converter.
|
|
3
|
+
*
|
|
4
|
+
* Converts numeric status codes from the ProtoPedia API to Japanese labels.
|
|
5
|
+
*
|
|
6
|
+
* @module utils/converters/status
|
|
7
|
+
*/
|
|
8
|
+
import type { StatusCode } from '../../types/codes.js';
|
|
9
|
+
/**
|
|
10
|
+
* Convert status code to label.
|
|
11
|
+
*
|
|
12
|
+
* @param status - Status code from NormalizedPrototype.status
|
|
13
|
+
* @returns Japanese label or the numeric value as string if unknown
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* getPrototypeStatusLabel(1); // => 'アイデア'
|
|
18
|
+
* getPrototypeStatusLabel(3); // => '完成'
|
|
19
|
+
* getPrototypeStatusLabel(99); // => '99'
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const getPrototypeStatusLabel: (status: StatusCode) => string;
|
|
23
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../lib/utils/converters/status.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAmBvD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,UAAU,KAAG,MAE5D,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status value to label converter.
|
|
3
|
+
*
|
|
4
|
+
* Converts numeric status codes from the ProtoPedia API to Japanese labels.
|
|
5
|
+
*
|
|
6
|
+
* @module utils/converters/status
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Status labels mapping.
|
|
10
|
+
*
|
|
11
|
+
* - 1: 'アイデア' (Idea) - ~6% of API responses
|
|
12
|
+
* - 2: '開発中' (In Development) - ~35% of API responses
|
|
13
|
+
* - 3: '完成' (Completed) - ~57% of API responses (most common)
|
|
14
|
+
* - 4: '供養' (Retired/Memorial) - ~2% of API responses
|
|
15
|
+
*
|
|
16
|
+
* All four status values appear in public API responses.
|
|
17
|
+
*/
|
|
18
|
+
const STATUS_LABELS = {
|
|
19
|
+
1: 'アイデア',
|
|
20
|
+
2: '開発中',
|
|
21
|
+
3: '完成',
|
|
22
|
+
4: '供養',
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Convert status code to label.
|
|
26
|
+
*
|
|
27
|
+
* @param status - Status code from NormalizedPrototype.status
|
|
28
|
+
* @returns Japanese label or the numeric value as string if unknown
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* getPrototypeStatusLabel(1); // => 'アイデア'
|
|
33
|
+
* getPrototypeStatusLabel(3); // => '完成'
|
|
34
|
+
* getPrototypeStatusLabel(99); // => '99'
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export const getPrototypeStatusLabel = (status) => {
|
|
38
|
+
return STATUS_LABELS[status] ?? `${status}`;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../lib/utils/converters/status.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;;;GASG;AACH,MAAM,aAAa,GAA+B;IAChD,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;CACR,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,MAAkB,EAAU,EAAE;IACpE,OAAO,aAAa,CAAC,MAAM,CAAC,IAAI,GAAG,MAAM,EAAE,CAAC;AAC9C,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thanks flag value to label converter.
|
|
3
|
+
*
|
|
4
|
+
* Converts numeric thanks flag codes from the ProtoPedia API to labels.
|
|
5
|
+
*
|
|
6
|
+
* This flag controls whether the "Thank you for posting" message has been shown.
|
|
7
|
+
*
|
|
8
|
+
* @module utils/converters/thanks-flag
|
|
9
|
+
*/
|
|
10
|
+
import type { ThanksFlagCode } from '../../types/codes.js';
|
|
11
|
+
/**
|
|
12
|
+
* Convert thanks flag code to label.
|
|
13
|
+
*
|
|
14
|
+
* @param thanksFlag - Thanks flag from NormalizedPrototype.thanksFlg (may be undefined for old data)
|
|
15
|
+
* @returns Label or the numeric value as string, or '不明' for undefined
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* getPrototypeThanksFlagLabel(1); // => '初回表示済'
|
|
20
|
+
* getPrototypeThanksFlagLabel(0); // => '0'
|
|
21
|
+
* getPrototypeThanksFlagLabel(undefined); // => '不明'
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const getPrototypeThanksFlagLabel: (thanksFlag: ThanksFlagCode) => string;
|
|
25
|
+
//# sourceMappingURL=thanks-flag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thanks-flag.d.ts","sourceRoot":"","sources":["../../../lib/utils/converters/thanks-flag.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAe3D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,2BAA2B,GACtC,YAAY,cAAc,KACzB,MAKF,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thanks flag value to label converter.
|
|
3
|
+
*
|
|
4
|
+
* Converts numeric thanks flag codes from the ProtoPedia API to labels.
|
|
5
|
+
*
|
|
6
|
+
* This flag controls whether the "Thank you for posting" message has been shown.
|
|
7
|
+
*
|
|
8
|
+
* @module utils/converters/thanks-flag
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Thanks flag labels mapping.
|
|
12
|
+
*
|
|
13
|
+
* - 0: (Implicit) Message not yet shown - **Rarely or never seen in API responses**
|
|
14
|
+
* - 1: '初回表示済' ("Thank you for posting" message already shown) - **Most common value in API**
|
|
15
|
+
*
|
|
16
|
+
* Note: Almost all prototypes in API responses have thanksFlg=1.
|
|
17
|
+
* Historical data (~3.26%) may have undefined thanksFlg.
|
|
18
|
+
*/
|
|
19
|
+
const THANKS_FLAG_LABELS = {
|
|
20
|
+
1: '初回表示済',
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Convert thanks flag code to label.
|
|
24
|
+
*
|
|
25
|
+
* @param thanksFlag - Thanks flag from NormalizedPrototype.thanksFlg (may be undefined for old data)
|
|
26
|
+
* @returns Label or the numeric value as string, or '不明' for undefined
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* getPrototypeThanksFlagLabel(1); // => '初回表示済'
|
|
31
|
+
* getPrototypeThanksFlagLabel(0); // => '0'
|
|
32
|
+
* getPrototypeThanksFlagLabel(undefined); // => '不明'
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export const getPrototypeThanksFlagLabel = (thanksFlag) => {
|
|
36
|
+
if (thanksFlag === undefined) {
|
|
37
|
+
return '不明';
|
|
38
|
+
}
|
|
39
|
+
return THANKS_FLAG_LABELS[thanksFlag] ?? `${thanksFlag}`;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=thanks-flag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thanks-flag.js","sourceRoot":"","sources":["../../../lib/utils/converters/thanks-flag.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;;;;GAQG;AACH,MAAM,kBAAkB,GAA2B;IACjD,CAAC,EAAE,OAAO;CACX,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,UAA0B,EAClB,EAAE;IACV,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,kBAAkB,CAAC,UAAU,CAAC,IAAI,GAAG,UAAU,EAAE,CAAC;AAC3D,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is a plain object.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The value to check
|
|
5
|
+
* @returns True if the value is a plain object
|
|
6
|
+
*/
|
|
7
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Deep merge utility for configuration objects.
|
|
10
|
+
* Recursively merges nested objects while preserving function references.
|
|
11
|
+
*
|
|
12
|
+
* This implementation includes protections against:
|
|
13
|
+
* - Circular references (using path-based WeakSet tracking)
|
|
14
|
+
* - Prototype pollution (skipping dangerous keys)
|
|
15
|
+
* - Non-plain object corruption (only merging plain objects)
|
|
16
|
+
* - Stack overflow from deep nesting (depth limit)
|
|
17
|
+
* - Array reference sharing (shallow copying arrays)
|
|
18
|
+
*
|
|
19
|
+
* Note on Arrays:
|
|
20
|
+
* Arrays are shallow copied. Objects inside arrays are shared by reference.
|
|
21
|
+
* If you need deep cloning of array elements, this utility does not support it.
|
|
22
|
+
*
|
|
23
|
+
* Note on null/undefined:
|
|
24
|
+
* - `undefined` values in source are skipped (target value preserved).
|
|
25
|
+
* - `null` values in source overwrite target values.
|
|
26
|
+
*
|
|
27
|
+
* Note on Special Objects:
|
|
28
|
+
* - `Object.create(null)` objects are treated as plain objects and merged.
|
|
29
|
+
* - Symbol properties are ignored (as Object.keys is used).
|
|
30
|
+
*
|
|
31
|
+
* @param target - Target object
|
|
32
|
+
* @param source - Source object to merge from
|
|
33
|
+
* @param seen - Set of objects in the current recursion path to detect cycles
|
|
34
|
+
* @param depth - Current recursion depth
|
|
35
|
+
* @returns Merged object
|
|
36
|
+
*/
|
|
37
|
+
export declare function deepMerge<T extends Record<string, unknown>>(target: T, source: Partial<T>, seen?: WeakSet<object>, depth?: number): T;
|
|
38
|
+
//# sourceMappingURL=deep-merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-merge.d.ts","sourceRoot":"","sources":["../../lib/utils/deep-merge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMlC;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzD,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAClB,IAAI,kBAAwB,EAC5B,KAAK,SAAI,GACR,CAAC,CAmDH"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is a plain object.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The value to check
|
|
5
|
+
* @returns True if the value is a plain object
|
|
6
|
+
*/
|
|
7
|
+
export function isPlainObject(value) {
|
|
8
|
+
if (typeof value !== 'object' || value === null) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const proto = Object.getPrototypeOf(value);
|
|
12
|
+
return proto === null || proto === Object.prototype;
|
|
13
|
+
}
|
|
14
|
+
const MAX_MERGE_DEPTH = 100;
|
|
15
|
+
/**
|
|
16
|
+
* Deep merge utility for configuration objects.
|
|
17
|
+
* Recursively merges nested objects while preserving function references.
|
|
18
|
+
*
|
|
19
|
+
* This implementation includes protections against:
|
|
20
|
+
* - Circular references (using path-based WeakSet tracking)
|
|
21
|
+
* - Prototype pollution (skipping dangerous keys)
|
|
22
|
+
* - Non-plain object corruption (only merging plain objects)
|
|
23
|
+
* - Stack overflow from deep nesting (depth limit)
|
|
24
|
+
* - Array reference sharing (shallow copying arrays)
|
|
25
|
+
*
|
|
26
|
+
* Note on Arrays:
|
|
27
|
+
* Arrays are shallow copied. Objects inside arrays are shared by reference.
|
|
28
|
+
* If you need deep cloning of array elements, this utility does not support it.
|
|
29
|
+
*
|
|
30
|
+
* Note on null/undefined:
|
|
31
|
+
* - `undefined` values in source are skipped (target value preserved).
|
|
32
|
+
* - `null` values in source overwrite target values.
|
|
33
|
+
*
|
|
34
|
+
* Note on Special Objects:
|
|
35
|
+
* - `Object.create(null)` objects are treated as plain objects and merged.
|
|
36
|
+
* - Symbol properties are ignored (as Object.keys is used).
|
|
37
|
+
*
|
|
38
|
+
* @param target - Target object
|
|
39
|
+
* @param source - Source object to merge from
|
|
40
|
+
* @param seen - Set of objects in the current recursion path to detect cycles
|
|
41
|
+
* @param depth - Current recursion depth
|
|
42
|
+
* @returns Merged object
|
|
43
|
+
*/
|
|
44
|
+
export function deepMerge(target, source, seen = new WeakSet(), depth = 0) {
|
|
45
|
+
// Prevent stack overflow from excessively deep objects
|
|
46
|
+
if (depth > MAX_MERGE_DEPTH) {
|
|
47
|
+
console.warn(`deepMerge: Maximum depth (${MAX_MERGE_DEPTH}) exceeded`);
|
|
48
|
+
return target;
|
|
49
|
+
}
|
|
50
|
+
const result = { ...target };
|
|
51
|
+
for (const key of Object.keys(source)) {
|
|
52
|
+
// Prevent prototype pollution
|
|
53
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const sourceValue = source[key];
|
|
57
|
+
const targetValue = target[key];
|
|
58
|
+
if (isPlainObject(sourceValue)) {
|
|
59
|
+
// Circular reference check (path-based)
|
|
60
|
+
if (seen.has(sourceValue)) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
seen.add(sourceValue);
|
|
64
|
+
// Recursively merge nested objects
|
|
65
|
+
// If targetValue is not a plain object, use an empty object as the base
|
|
66
|
+
const nextTarget = isPlainObject(targetValue) ? targetValue : {};
|
|
67
|
+
result[key] = deepMerge(nextTarget, sourceValue, seen, depth + 1);
|
|
68
|
+
// Remove from seen set after processing (backtracking)
|
|
69
|
+
// This ensures we only detect cycles in the current path, allowing shared references
|
|
70
|
+
seen.delete(sourceValue);
|
|
71
|
+
}
|
|
72
|
+
else if (sourceValue !== undefined) {
|
|
73
|
+
// Handle Arrays: Create shallow copy to prevent reference sharing
|
|
74
|
+
if (Array.isArray(sourceValue)) {
|
|
75
|
+
result[key] = [...sourceValue];
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// Directly assign primitives, functions, etc.
|
|
79
|
+
result[key] = sourceValue;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=deep-merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-merge.js","sourceRoot":"","sources":["../../lib/utils/deep-merge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,CAAC,SAAS,CAAC;AACtD,CAAC;AAED,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,SAAS,CACvB,MAAS,EACT,MAAkB,EAClB,OAAO,IAAI,OAAO,EAAU,EAC5B,KAAK,GAAG,CAAC;IAET,uDAAuD;IACvD,IAAI,KAAK,GAAG,eAAe,EAAE,CAAC;QAC5B,OAAO,CAAC,IAAI,CAAC,6BAA6B,eAAe,YAAY,CAAC,CAAC;QACvE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,MAAM,GAA4B,EAAE,GAAG,MAAM,EAAE,CAAC;IAEtD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,8BAA8B;QAC9B,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,aAAa,IAAI,GAAG,KAAK,WAAW,EAAE,CAAC;YACxE,SAAS;QACX,CAAC;QAED,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAEhC,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/B,wCAAwC;YACxC,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC1B,SAAS;YACX,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YAEtB,mCAAmC;YACnC,wEAAwE;YACxE,MAAM,UAAU,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;YAEjE,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CACrB,UAAqC,EACrC,WAAW,EACX,IAAI,EACJ,KAAK,GAAG,CAAC,CACV,CAAC;YAEF,uDAAuD;YACvD,qFAAqF;YACrF,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC3B,CAAC;aAAM,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YACrC,kEAAkE;YAClE,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC;YACjC,CAAC;iBAAM,CAAC;gBACN,8CAA8C;gBAC9C,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAW,CAAC;AACrB,CAAC"}
|