@finsys/core 2.7.0 → 3.2.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/README.md +1 -1
- package/dist/data/adapter-categories.json +235 -2
- package/dist/index.cjs +375 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -22
- package/dist/index.d.ts +44 -22
- package/dist/index.js +372 -32
- package/dist/index.js.map +1 -1
- package/dist/schema/adapter-manifest.schema.json +2 -2
- package/package.json +9 -2
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ function getPastYearLabel(yearsAgo) {
|
|
|
9
9
|
const date = /* @__PURE__ */ new Date();
|
|
10
10
|
return (date.getFullYear() - yearsAgo).toString();
|
|
11
11
|
}
|
|
12
|
-
function evaluateExpression(expression,
|
|
12
|
+
function evaluateExpression(expression, data) {
|
|
13
13
|
if (!expression) return true;
|
|
14
14
|
try {
|
|
15
15
|
let jsExpression = expression.replace(/\{([^}]+)\}/g, (_, key) => {
|
|
@@ -33,7 +33,7 @@ function evaluateExpression(expression, data2) {
|
|
|
33
33
|
(_, ref, val) => `!(${ref} || []).includes('${val}')`
|
|
34
34
|
);
|
|
35
35
|
const func = new Function(`return ${jsExpression};`);
|
|
36
|
-
return !!func.call(
|
|
36
|
+
return !!func.call(data || {});
|
|
37
37
|
} catch (e) {
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
@@ -179,16 +179,16 @@ function groupFieldsByCategory(fields, categories) {
|
|
|
179
179
|
// src/rhf-generator.ts
|
|
180
180
|
import { z } from "zod";
|
|
181
181
|
function applyVisibilityValidation(baseObject, fields) {
|
|
182
|
-
return baseObject.superRefine((
|
|
182
|
+
return baseObject.superRefine((data, ctx) => {
|
|
183
183
|
fields.forEach((field) => {
|
|
184
184
|
const isRequired = field.isRequired !== false && field.required !== false && field.type !== "html";
|
|
185
185
|
if (!isRequired) return;
|
|
186
186
|
let isVisible = field.visible !== false;
|
|
187
187
|
if (isVisible && field.visibleIf) {
|
|
188
|
-
isVisible = evaluateExpression(field.visibleIf,
|
|
188
|
+
isVisible = evaluateExpression(field.visibleIf, data);
|
|
189
189
|
}
|
|
190
190
|
if (isVisible) {
|
|
191
|
-
const value =
|
|
191
|
+
const value = data[field.name];
|
|
192
192
|
const isEmpty = value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
|
|
193
193
|
if (isEmpty) {
|
|
194
194
|
ctx.addIssue({
|
|
@@ -649,22 +649,22 @@ var ajv = new Ajv({ allErrors: true, strict: false });
|
|
|
649
649
|
var addFormatsFn = addFormats.default || addFormats;
|
|
650
650
|
addFormatsFn(ajv);
|
|
651
651
|
ajv.addSchema(unified_form_schema_default, "unified-form.schema.json");
|
|
652
|
-
function validateFormConfig(
|
|
652
|
+
function validateFormConfig(data) {
|
|
653
653
|
const validate = ajv.getSchema("unified-form.schema.json");
|
|
654
654
|
if (!validate) {
|
|
655
655
|
return { valid: false, message: "Could not load unified form schema" };
|
|
656
656
|
}
|
|
657
|
-
const valid = validate(
|
|
657
|
+
const valid = validate(data);
|
|
658
658
|
return {
|
|
659
659
|
valid: !!valid,
|
|
660
660
|
errors: validate.errors || void 0
|
|
661
661
|
};
|
|
662
662
|
}
|
|
663
|
-
function validateFormSpec(
|
|
664
|
-
return validateFormConfig(
|
|
663
|
+
function validateFormSpec(data) {
|
|
664
|
+
return validateFormConfig(data);
|
|
665
665
|
}
|
|
666
|
-
function validatePagesConfig(
|
|
667
|
-
return validateFormConfig(
|
|
666
|
+
function validatePagesConfig(data) {
|
|
667
|
+
return validateFormConfig(data);
|
|
668
668
|
}
|
|
669
669
|
|
|
670
670
|
// src/form-field-category.ts
|
|
@@ -1121,10 +1121,10 @@ var _FormSpec = class _FormSpec {
|
|
|
1121
1121
|
if (Array.isArray(jsonData.fields)) {
|
|
1122
1122
|
fieldObjects = jsonData.fields;
|
|
1123
1123
|
} else if (typeof jsonData.fields === "object" && jsonData.fields !== null) {
|
|
1124
|
-
fieldObjects = Object.entries(jsonData.fields).map(([name,
|
|
1124
|
+
fieldObjects = Object.entries(jsonData.fields).map(([name, data]) => {
|
|
1125
1125
|
return {
|
|
1126
1126
|
name,
|
|
1127
|
-
...
|
|
1127
|
+
...data
|
|
1128
1128
|
};
|
|
1129
1129
|
});
|
|
1130
1130
|
}
|
|
@@ -9382,18 +9382,18 @@ function buildTableForGroup(groupName, fields, ihsData) {
|
|
|
9382
9382
|
const items = [];
|
|
9383
9383
|
for (const [baseName, periodMap] of Object.entries(columnGroups)) {
|
|
9384
9384
|
const numeric = isNumericField(baseName);
|
|
9385
|
-
const
|
|
9385
|
+
const data = {};
|
|
9386
9386
|
const formattedData = {};
|
|
9387
9387
|
for (const period of periods) {
|
|
9388
9388
|
const colName = periodMap[period];
|
|
9389
9389
|
const value = colName ? ihsData[colName] ?? null : null;
|
|
9390
|
-
|
|
9390
|
+
data[period] = value;
|
|
9391
9391
|
formattedData[period] = formatValue(value, numeric);
|
|
9392
9392
|
}
|
|
9393
9393
|
items.push({
|
|
9394
9394
|
displayName: getDisplayName(baseName),
|
|
9395
9395
|
timePeriods: periods,
|
|
9396
|
-
data
|
|
9396
|
+
data,
|
|
9397
9397
|
formattedData,
|
|
9398
9398
|
type: tableType,
|
|
9399
9399
|
isNumeric: numeric
|
|
@@ -9814,7 +9814,7 @@ var adapter_categories_default = {
|
|
|
9814
9814
|
{
|
|
9815
9815
|
id: "telco-carrier",
|
|
9816
9816
|
displayName: "Telco Carrier",
|
|
9817
|
-
description: "Mobile carrier bill-payment + account-history signals. Any
|
|
9817
|
+
description: "Mobile carrier bill-payment + account-history signals. Any mobile carrier implementing this category produces the same canonical field set.",
|
|
9818
9818
|
canonicalTable: "ihs_alt_data_telco",
|
|
9819
9819
|
fields: [
|
|
9820
9820
|
{
|
|
@@ -9867,7 +9867,7 @@ var adapter_categories_default = {
|
|
|
9867
9867
|
{
|
|
9868
9868
|
id: "payment-network",
|
|
9869
9869
|
displayName: "Payment Network",
|
|
9870
|
-
description: "Merchant-side payment-flow signals from POS / gateway networks
|
|
9870
|
+
description: "Merchant-side payment-flow signals from POS / payment-gateway networks. Captures actual transaction velocity rather than self-reported revenue.",
|
|
9871
9871
|
canonicalTable: "ihs_alt_data_payments",
|
|
9872
9872
|
fields: [
|
|
9873
9873
|
{
|
|
@@ -9961,17 +9961,352 @@ var adapter_categories_default = {
|
|
|
9961
9961
|
description: "Bounced / returned transactions in the period. Distress signal at counts > 0."
|
|
9962
9962
|
}
|
|
9963
9963
|
]
|
|
9964
|
+
},
|
|
9965
|
+
{
|
|
9966
|
+
id: "social-media",
|
|
9967
|
+
displayName: "Social Media Presence",
|
|
9968
|
+
description: "Public business-presence signals from social / commerce platforms \u2014 establishment, reach, engagement authenticity, customer reputation, and account standing. Vendor-agnostic: any platform exposing a public business profile maps its data to this canonical field set. Useful as thin-file corroboration of a borrower's operating reality where formal financials are sparse.",
|
|
9969
|
+
canonicalTable: "ihs_alt_data_social_media",
|
|
9970
|
+
fields: [
|
|
9971
|
+
{
|
|
9972
|
+
name: "socialAccountTenureMonths",
|
|
9973
|
+
type: "number",
|
|
9974
|
+
unit: "months",
|
|
9975
|
+
range: [0, 600],
|
|
9976
|
+
description: "Age of the oldest verified public business presence across linked profiles. Establishment / continuity proxy, parallel to telco + payment-network tenure."
|
|
9977
|
+
},
|
|
9978
|
+
{
|
|
9979
|
+
name: "socialFollowerCount",
|
|
9980
|
+
type: "number",
|
|
9981
|
+
unit: "count",
|
|
9982
|
+
range: [0, 1e8],
|
|
9983
|
+
description: "Aggregate audience size across linked public profiles. Coarse reach / scale proxy \u2014 gameable on its own, so read alongside socialEngagementRate90d."
|
|
9984
|
+
},
|
|
9985
|
+
{
|
|
9986
|
+
name: "socialEngagementRate90d",
|
|
9987
|
+
type: "number",
|
|
9988
|
+
unit: "ratio",
|
|
9989
|
+
range: [0, 1],
|
|
9990
|
+
description: "Mean interactions per impression over the trailing 90 days. Authenticity signal: a large follower count with near-zero engagement indicates a bought or dormant audience."
|
|
9991
|
+
},
|
|
9992
|
+
{
|
|
9993
|
+
name: "socialPostingConsistency12m",
|
|
9994
|
+
type: "number",
|
|
9995
|
+
unit: "ratio",
|
|
9996
|
+
range: [0, 1],
|
|
9997
|
+
description: "Fraction of weeks in the trailing 12 months with at least one public post. Ongoing-operation signal \u2014 distinguishes an active business from a stale listing."
|
|
9998
|
+
},
|
|
9999
|
+
{
|
|
10000
|
+
name: "socialVerifiedBusinessAccount",
|
|
10001
|
+
type: "boolean",
|
|
10002
|
+
description: "Has at least one platform-verified business / commerce profile. Legitimacy signal \u2014 the platform has performed its own business-identity check."
|
|
10003
|
+
},
|
|
10004
|
+
{
|
|
10005
|
+
name: "socialCustomerRatingAvg",
|
|
10006
|
+
type: "number",
|
|
10007
|
+
unit: "rating",
|
|
10008
|
+
range: [0, 5],
|
|
10009
|
+
description: "Mean public customer rating (normalised to a 0\u20135 scale) across review-bearing profiles. Reputation signal; especially predictive for consumer-facing SMEs."
|
|
10010
|
+
},
|
|
10011
|
+
{
|
|
10012
|
+
name: "socialNegativeSentimentRatio90d",
|
|
10013
|
+
type: "number",
|
|
10014
|
+
unit: "ratio",
|
|
10015
|
+
range: [0, 1],
|
|
10016
|
+
description: "Fraction of public mentions / reviews classified as negative over the trailing 90 days. Reputation-risk / distress signal independent of overall rating volume."
|
|
10017
|
+
},
|
|
10018
|
+
{
|
|
10019
|
+
name: "socialAccountFlags24m",
|
|
10020
|
+
type: "number",
|
|
10021
|
+
unit: "count",
|
|
10022
|
+
range: [0, 100],
|
|
10023
|
+
description: "Policy strikes, suspensions, or content takedowns across linked profiles in the last 24 months. Distress signal, parallel to telcoSuspensionsCount24m."
|
|
10024
|
+
}
|
|
10025
|
+
]
|
|
10026
|
+
},
|
|
10027
|
+
{
|
|
10028
|
+
id: "trade-credit",
|
|
10029
|
+
displayName: "Trade Credit (Accounting)",
|
|
10030
|
+
description: "Accounts-receivable / accounts-payable aging and ledger-derived working-capital signals sourced from a business's accounting / ERP system. Captures how promptly the business collects from its debtors and pays its creditors, the aging profile and concentration of its receivables, and P&L / cash-conversion efficiency. Vendor-agnostic: any accounting or ERP system that exposes an AR/AP aging report plus a P&L summary maps its data to this canonical field set. A direct, high-signal view of trade-obligation behaviour \u2014 closer to formal credit history than most alternative data \u2014 and the anchor for cross-referencing self-reported accounting figures against bank-statement reality.",
|
|
10031
|
+
canonicalTable: "ihs_alt_data_trade_credit",
|
|
10032
|
+
fields: [
|
|
10033
|
+
{
|
|
10034
|
+
name: "arDaysSalesOutstanding",
|
|
10035
|
+
type: "number",
|
|
10036
|
+
unit: "days",
|
|
10037
|
+
range: [0, 400],
|
|
10038
|
+
description: "Days Sales Outstanding \u2014 average days to collect a receivable. The headline collection-efficiency metric; lower is healthier, and a rising DSO is an early liquidity-stress signal."
|
|
10039
|
+
},
|
|
10040
|
+
{
|
|
10041
|
+
name: "apDaysPayableOutstanding",
|
|
10042
|
+
type: "number",
|
|
10043
|
+
unit: "days",
|
|
10044
|
+
range: [0, 400],
|
|
10045
|
+
description: "Days Payable Outstanding \u2014 average days the business takes to pay its suppliers. Context for DSO; a very high DPO can indicate the business is stretching its creditors to fund operations."
|
|
10046
|
+
},
|
|
10047
|
+
{
|
|
10048
|
+
name: "arTotalOutstandingMyr",
|
|
10049
|
+
type: "number",
|
|
10050
|
+
unit: "MYR",
|
|
10051
|
+
range: [0, 1e9],
|
|
10052
|
+
description: "Total accounts-receivable balance outstanding (RM). The size of the debtor book the business is carrying."
|
|
10053
|
+
},
|
|
10054
|
+
{
|
|
10055
|
+
name: "arCurrentRatio",
|
|
10056
|
+
type: "number",
|
|
10057
|
+
unit: "ratio",
|
|
10058
|
+
range: [0, 1],
|
|
10059
|
+
description: "Fraction of the receivables book that is current (within payment terms, not yet overdue). Higher is healthier; the complement is the overdue share across all aging buckets."
|
|
10060
|
+
},
|
|
10061
|
+
{
|
|
10062
|
+
name: "arOverdue90PlusRatio",
|
|
10063
|
+
type: "number",
|
|
10064
|
+
unit: "ratio",
|
|
10065
|
+
range: [0, 1],
|
|
10066
|
+
description: "Fraction of the receivables book aged more than 90 days past terms. The key impairment / bad-debt risk signal from the AR aging report; elevated values indicate collection difficulty."
|
|
10067
|
+
},
|
|
10068
|
+
{
|
|
10069
|
+
name: "debtorConcentrationTop5Ratio",
|
|
10070
|
+
type: "number",
|
|
10071
|
+
unit: "ratio",
|
|
10072
|
+
range: [0, 1],
|
|
10073
|
+
description: "Share of total receivables owed by the top-5 debtors. Above ~0.6 is single-customer concentration risk \u2014 one debtor default would materially impair cash flow."
|
|
10074
|
+
},
|
|
10075
|
+
{
|
|
10076
|
+
name: "tradeReferenceDefaults12m",
|
|
10077
|
+
type: "number",
|
|
10078
|
+
unit: "count",
|
|
10079
|
+
range: [0, 1e3],
|
|
10080
|
+
description: "Count of supplier-reported defaults or dishonoured / returned payments against the business in the trailing 12 months. Direct distress signal, parallel to a bureau default record."
|
|
10081
|
+
},
|
|
10082
|
+
{
|
|
10083
|
+
name: "accountingRevenue12mMyr",
|
|
10084
|
+
type: "number",
|
|
10085
|
+
unit: "MYR",
|
|
10086
|
+
range: [0, 1e9],
|
|
10087
|
+
description: "Trailing-12-month turnover per the general ledger (RM). The cross-reference anchor: comparing this self-reported accounting revenue against payment-network volume and bank-statement inflows surfaces book-vs-reality inconsistencies."
|
|
10088
|
+
},
|
|
10089
|
+
{
|
|
10090
|
+
name: "grossMarginPct",
|
|
10091
|
+
type: "number",
|
|
10092
|
+
unit: "ratio",
|
|
10093
|
+
range: [0, 1],
|
|
10094
|
+
description: "Gross margin from the P&L (gross profit / revenue). Profitability-quality signal; a thin or declining margin constrains debt-service capacity even at healthy revenue."
|
|
10095
|
+
},
|
|
10096
|
+
{
|
|
10097
|
+
name: "cashConversionCycleDays",
|
|
10098
|
+
type: "number",
|
|
10099
|
+
unit: "days",
|
|
10100
|
+
range: [-200, 600],
|
|
10101
|
+
description: "Cash Conversion Cycle (DSO + days-inventory-outstanding \u2212 DPO). Working-capital efficiency; negative values (collect before paying suppliers) are strongest, very high values indicate cash tied up in operations."
|
|
10102
|
+
}
|
|
10103
|
+
]
|
|
10104
|
+
},
|
|
10105
|
+
{
|
|
10106
|
+
id: "geolocation",
|
|
10107
|
+
displayName: "Geolocation",
|
|
10108
|
+
description: "Hourly-granularity movement track plus derived mobility signals for an applicant, sourced from any location-capable provider (telco network location, mobile-SDK GPS, GIS / address-verification services). Two instance kinds share this category: point instances (instanceKey 'pt:<ISO-hour>') carry one observed position per hourly bucket, mirroring the bank-statement multi-instance pattern; a single summary instance (instanceKey 'summary') carries adapter-derived behaviour signals \u2014 most importantly work-pattern regularity (sustained weekday dwell at a stable work anchor corroborates income reliability), residential stability, vacation windows, and dwell in operator-flagged hotspot zones. Vendor-agnostic: the source classifies or the adapter infers place labels; no provider-specific semantics leak into the field set. Raw coordinates are sensitive personal data \u2014 product-plane persistence is gated on PDPA consent + CRA Act 710 s25 retention review.",
|
|
10109
|
+
canonicalTable: "ihs_alt_data_geolocation",
|
|
10110
|
+
fields: [
|
|
10111
|
+
{
|
|
10112
|
+
name: "geoLatitude",
|
|
10113
|
+
type: "number",
|
|
10114
|
+
unit: "deg",
|
|
10115
|
+
range: [-90, 90],
|
|
10116
|
+
description: "Observed latitude for this hourly bucket (point instances only)."
|
|
10117
|
+
},
|
|
10118
|
+
{
|
|
10119
|
+
name: "geoLongitude",
|
|
10120
|
+
type: "number",
|
|
10121
|
+
unit: "deg",
|
|
10122
|
+
range: [-180, 180],
|
|
10123
|
+
description: "Observed longitude for this hourly bucket (point instances only)."
|
|
10124
|
+
},
|
|
10125
|
+
{
|
|
10126
|
+
name: "geoAccuracyM",
|
|
10127
|
+
type: "number",
|
|
10128
|
+
unit: "meters",
|
|
10129
|
+
range: [0, 1e5],
|
|
10130
|
+
description: "Source-reported horizontal accuracy radius of the observation. Cell-tower fixes are typically hundreds of meters; GPS fixes tens."
|
|
10131
|
+
},
|
|
10132
|
+
{
|
|
10133
|
+
name: "geoBucket",
|
|
10134
|
+
type: "string",
|
|
10135
|
+
description: "ISO-8601 hour bucket of the observation, e.g. '2026-06-01T08'. Redundant with the instance key (pt:<bucket>) so consumers can query without parsing keys."
|
|
10136
|
+
},
|
|
10137
|
+
{
|
|
10138
|
+
name: "geoPlaceLabel",
|
|
10139
|
+
type: "string",
|
|
10140
|
+
description: "Classified place for the bucket: home | work | commute | leisure | travel | hotspot | other. Classified by the source or inferred by the adapter from anchor dwell."
|
|
10141
|
+
},
|
|
10142
|
+
{
|
|
10143
|
+
name: "geoWorkAttendanceRatio30d",
|
|
10144
|
+
type: "number",
|
|
10145
|
+
unit: "ratio",
|
|
10146
|
+
range: [0, 1],
|
|
10147
|
+
description: "Fraction of the last 30 weekdays with >= 6 hours of dwell at the inferred work anchor. The income-reliability headline: regular full-time work patterns corroborate declared employment income (summary instance only)."
|
|
10148
|
+
},
|
|
10149
|
+
{
|
|
10150
|
+
name: "geoWorkDailyHoursAvg30d",
|
|
10151
|
+
type: "number",
|
|
10152
|
+
unit: "hours",
|
|
10153
|
+
range: [0, 24],
|
|
10154
|
+
description: "Mean daily hours of work-anchor dwell across the last 30 weekdays (summary instance only)."
|
|
10155
|
+
},
|
|
10156
|
+
{
|
|
10157
|
+
name: "geoLocationStabilityScore",
|
|
10158
|
+
type: "number",
|
|
10159
|
+
unit: "score",
|
|
10160
|
+
range: [0, 1],
|
|
10161
|
+
description: "Residential stability: share of nights spent at the primary home anchor over the observation window. 1 = every night at home (summary instance only)."
|
|
10162
|
+
},
|
|
10163
|
+
{
|
|
10164
|
+
name: "geoCommuteRegularityRatio",
|
|
10165
|
+
type: "number",
|
|
10166
|
+
unit: "ratio",
|
|
10167
|
+
range: [0, 1],
|
|
10168
|
+
description: "Consistency of the weekday home->work->home rhythm: fraction of weekdays matching the dominant commute pattern within an hour's tolerance (summary instance only)."
|
|
10169
|
+
},
|
|
10170
|
+
{
|
|
10171
|
+
name: "geoVacationDays90d",
|
|
10172
|
+
type: "number",
|
|
10173
|
+
unit: "days",
|
|
10174
|
+
range: [0, 90],
|
|
10175
|
+
description: "Days in the last 90 spent fully away from both home and work anchors (contiguous travel windows; summary instance only)."
|
|
10176
|
+
},
|
|
10177
|
+
{
|
|
10178
|
+
name: "geoHotspotDwellRatio",
|
|
10179
|
+
type: "number",
|
|
10180
|
+
unit: "ratio",
|
|
10181
|
+
range: [0, 1],
|
|
10182
|
+
description: "Share of observed buckets spent inside operator-flagged hotspot zones (known fraud / illicit-activity locations supplied to the adapter). Non-zero values warrant review, not automatic decline (summary instance only)."
|
|
10183
|
+
},
|
|
10184
|
+
{
|
|
10185
|
+
name: "geoPrimaryStateCode",
|
|
10186
|
+
type: "string",
|
|
10187
|
+
description: "Malaysian state / federal-territory code of the primary home anchor, e.g. PNG, KUL, JHR (summary instance only)."
|
|
10188
|
+
},
|
|
10189
|
+
{
|
|
10190
|
+
name: "geoAddressMatchScore",
|
|
10191
|
+
type: "number",
|
|
10192
|
+
unit: "score",
|
|
10193
|
+
range: [0, 1],
|
|
10194
|
+
description: "Agreement between the inferred home anchor and the applicant's registered residential address. 1 = same premises, 0 = different state (summary instance only)."
|
|
10195
|
+
}
|
|
10196
|
+
]
|
|
9964
10197
|
}
|
|
9965
10198
|
]
|
|
9966
10199
|
};
|
|
9967
10200
|
|
|
9968
10201
|
// src/adapter-categories.ts
|
|
9969
|
-
var
|
|
10202
|
+
var VALID_FIELD_TYPES = [
|
|
10203
|
+
"number",
|
|
10204
|
+
"boolean",
|
|
10205
|
+
"string"
|
|
10206
|
+
];
|
|
10207
|
+
function buildCategoryRegistry(raw) {
|
|
10208
|
+
if (!raw || typeof raw !== "object") {
|
|
10209
|
+
throw new Error("adapter category data: expected an object");
|
|
10210
|
+
}
|
|
10211
|
+
if (typeof raw.schemaVersion !== "string" || raw.schemaVersion.length === 0) {
|
|
10212
|
+
throw new Error("adapter category data: missing schemaVersion");
|
|
10213
|
+
}
|
|
10214
|
+
if (!Array.isArray(raw.categories) || raw.categories.length === 0) {
|
|
10215
|
+
throw new Error("adapter category data: categories must be a non-empty array");
|
|
10216
|
+
}
|
|
10217
|
+
const byId = /* @__PURE__ */ new Map();
|
|
10218
|
+
const fieldToCategory = /* @__PURE__ */ new Map();
|
|
10219
|
+
const tables = /* @__PURE__ */ new Set();
|
|
10220
|
+
const all = [];
|
|
10221
|
+
for (const cat of raw.categories) {
|
|
10222
|
+
const where = `category "${cat?.id ?? "<unknown>"}"`;
|
|
10223
|
+
if (typeof cat.id !== "string" || cat.id.length === 0) {
|
|
10224
|
+
throw new Error("adapter category data: every category needs a non-empty id");
|
|
10225
|
+
}
|
|
10226
|
+
if (byId.has(cat.id)) {
|
|
10227
|
+
throw new Error(`adapter category data: duplicate category id "${cat.id}"`);
|
|
10228
|
+
}
|
|
10229
|
+
if (typeof cat.displayName !== "string" || cat.displayName.length === 0) {
|
|
10230
|
+
throw new Error(`adapter category data: ${where} needs a non-empty displayName`);
|
|
10231
|
+
}
|
|
10232
|
+
if (typeof cat.description !== "string" || cat.description.length === 0) {
|
|
10233
|
+
throw new Error(`adapter category data: ${where} needs a non-empty description`);
|
|
10234
|
+
}
|
|
10235
|
+
if (typeof cat.canonicalTable !== "string" || !/^ihs_alt_data_/.test(cat.canonicalTable)) {
|
|
10236
|
+
throw new Error(
|
|
10237
|
+
`adapter category data: ${where} canonicalTable must start with "ihs_alt_data_" (got "${cat.canonicalTable}")`
|
|
10238
|
+
);
|
|
10239
|
+
}
|
|
10240
|
+
if (tables.has(cat.canonicalTable)) {
|
|
10241
|
+
throw new Error(
|
|
10242
|
+
`adapter category data: duplicate canonicalTable "${cat.canonicalTable}" (${where})`
|
|
10243
|
+
);
|
|
10244
|
+
}
|
|
10245
|
+
if (!Array.isArray(cat.fields) || cat.fields.length === 0) {
|
|
10246
|
+
throw new Error(`adapter category data: ${where} must declare at least one field`);
|
|
10247
|
+
}
|
|
10248
|
+
const fields = [];
|
|
10249
|
+
for (const f of cat.fields) {
|
|
10250
|
+
if (typeof f.name !== "string" || f.name.length === 0) {
|
|
10251
|
+
throw new Error(`adapter category data: ${where} has a field with no name`);
|
|
10252
|
+
}
|
|
10253
|
+
if (fieldToCategory.has(f.name)) {
|
|
10254
|
+
throw new Error(
|
|
10255
|
+
`adapter category data: canonical field "${f.name}" declared by more than one category (${fieldToCategory.get(f.name)} + ${cat.id}) \u2014 field names must be globally unique`
|
|
10256
|
+
);
|
|
10257
|
+
}
|
|
10258
|
+
if (!VALID_FIELD_TYPES.includes(f.type)) {
|
|
10259
|
+
throw new Error(
|
|
10260
|
+
`adapter category data: field "${f.name}" (${where}) has invalid type "${f.type}"`
|
|
10261
|
+
);
|
|
10262
|
+
}
|
|
10263
|
+
if (typeof f.description !== "string" || f.description.length === 0) {
|
|
10264
|
+
throw new Error(
|
|
10265
|
+
`adapter category data: field "${f.name}" (${where}) needs a non-empty description`
|
|
10266
|
+
);
|
|
10267
|
+
}
|
|
10268
|
+
if (f.range !== void 0) {
|
|
10269
|
+
if (!Array.isArray(f.range) || f.range.length !== 2 || !Number.isFinite(f.range[0]) || !Number.isFinite(f.range[1]) || f.range[0] > f.range[1]) {
|
|
10270
|
+
throw new Error(
|
|
10271
|
+
`adapter category data: field "${f.name}" (${where}) has an invalid range \u2014 expected [lo, hi] with finite lo <= hi`
|
|
10272
|
+
);
|
|
10273
|
+
}
|
|
10274
|
+
}
|
|
10275
|
+
const spec = Object.freeze({
|
|
10276
|
+
name: f.name,
|
|
10277
|
+
type: f.type,
|
|
10278
|
+
...f.unit !== void 0 ? { unit: f.unit } : {},
|
|
10279
|
+
...f.range !== void 0 ? { range: Object.freeze([f.range[0], f.range[1]]) } : {},
|
|
10280
|
+
description: f.description
|
|
10281
|
+
});
|
|
10282
|
+
fields.push(spec);
|
|
10283
|
+
fieldToCategory.set(f.name, cat.id);
|
|
10284
|
+
}
|
|
10285
|
+
const schema = Object.freeze({
|
|
10286
|
+
id: cat.id,
|
|
10287
|
+
displayName: cat.displayName,
|
|
10288
|
+
description: cat.description,
|
|
10289
|
+
canonicalTable: cat.canonicalTable,
|
|
10290
|
+
fields: Object.freeze(fields)
|
|
10291
|
+
});
|
|
10292
|
+
byId.set(cat.id, schema);
|
|
10293
|
+
tables.add(cat.canonicalTable);
|
|
10294
|
+
all.push(schema);
|
|
10295
|
+
}
|
|
10296
|
+
return Object.freeze({
|
|
10297
|
+
all: Object.freeze(all),
|
|
10298
|
+
ids: Object.freeze(all.map((c) => c.id)),
|
|
10299
|
+
byId,
|
|
10300
|
+
fieldToCategory
|
|
10301
|
+
});
|
|
10302
|
+
}
|
|
10303
|
+
var registry = buildCategoryRegistry(adapter_categories_default);
|
|
10304
|
+
var ADAPTER_CATEGORY_IDS = registry.ids;
|
|
9970
10305
|
function categorySchemaOf(id) {
|
|
9971
|
-
const found =
|
|
10306
|
+
const found = registry.byId.get(id);
|
|
9972
10307
|
if (!found) {
|
|
9973
10308
|
throw new Error(
|
|
9974
|
-
`Unknown adapter category: ${id}. Available: ${
|
|
10309
|
+
`Unknown adapter category: ${id}. Available: ${registry.ids.join(", ")}`
|
|
9975
10310
|
);
|
|
9976
10311
|
}
|
|
9977
10312
|
return found;
|
|
@@ -9980,21 +10315,24 @@ function categoryFieldsOf(id) {
|
|
|
9980
10315
|
return categorySchemaOf(id).fields.map((f) => f.name);
|
|
9981
10316
|
}
|
|
9982
10317
|
function allCategories() {
|
|
9983
|
-
return
|
|
10318
|
+
return registry.all;
|
|
9984
10319
|
}
|
|
9985
|
-
var fieldToCategory = (() => {
|
|
9986
|
-
const m = /* @__PURE__ */ new Map();
|
|
9987
|
-
for (const cat of data.categories) {
|
|
9988
|
-
for (const f of cat.fields) {
|
|
9989
|
-
m.set(f.name, cat.id);
|
|
9990
|
-
}
|
|
9991
|
-
}
|
|
9992
|
-
return m;
|
|
9993
|
-
})();
|
|
9994
10320
|
function categoryForField(field) {
|
|
9995
|
-
return fieldToCategory.get(field) ?? null;
|
|
10321
|
+
return registry.fieldToCategory.get(field) ?? null;
|
|
10322
|
+
}
|
|
10323
|
+
function isAdapterCategory(id) {
|
|
10324
|
+
return registry.byId.has(id);
|
|
10325
|
+
}
|
|
10326
|
+
function assertAdapterCategory(id) {
|
|
10327
|
+
if (!registry.byId.has(id)) {
|
|
10328
|
+
throw new Error(
|
|
10329
|
+
`Unknown adapter category: ${id}. Available: ${registry.ids.join(", ")}`
|
|
10330
|
+
);
|
|
10331
|
+
}
|
|
10332
|
+
return id;
|
|
9996
10333
|
}
|
|
9997
10334
|
export {
|
|
10335
|
+
ADAPTER_CATEGORY_IDS,
|
|
9998
10336
|
ALL_AGGREGATION_OPS,
|
|
9999
10337
|
AdapterError,
|
|
10000
10338
|
BASE_FIELD_SPECS,
|
|
@@ -10020,6 +10358,7 @@ export {
|
|
|
10020
10358
|
allCategories,
|
|
10021
10359
|
applyAggregation,
|
|
10022
10360
|
applyDynamicTitles,
|
|
10361
|
+
assertAdapterCategory,
|
|
10023
10362
|
buildFileFieldTables,
|
|
10024
10363
|
categoryFieldsOf,
|
|
10025
10364
|
categoryForField,
|
|
@@ -10044,6 +10383,7 @@ export {
|
|
|
10044
10383
|
groupDetailsByCategory,
|
|
10045
10384
|
groupFieldsByCategory,
|
|
10046
10385
|
groupFieldsByPattern,
|
|
10386
|
+
isAdapterCategory,
|
|
10047
10387
|
isFailureIhsStatus,
|
|
10048
10388
|
isTerminalIhsStatus,
|
|
10049
10389
|
isValidIhsStatus,
|