@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/dist/index.cjs CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ ADAPTER_CATEGORY_IDS: () => ADAPTER_CATEGORY_IDS,
33
34
  ALL_AGGREGATION_OPS: () => ALL_AGGREGATION_OPS,
34
35
  AdapterError: () => AdapterError,
35
36
  BASE_FIELD_SPECS: () => BASE_FIELD_SPECS,
@@ -55,6 +56,7 @@ __export(index_exports, {
55
56
  allCategories: () => allCategories,
56
57
  applyAggregation: () => applyAggregation,
57
58
  applyDynamicTitles: () => applyDynamicTitles,
59
+ assertAdapterCategory: () => assertAdapterCategory,
58
60
  buildFileFieldTables: () => buildFileFieldTables,
59
61
  categoryFieldsOf: () => categoryFieldsOf,
60
62
  categoryForField: () => categoryForField,
@@ -79,6 +81,7 @@ __export(index_exports, {
79
81
  groupDetailsByCategory: () => groupDetailsByCategory,
80
82
  groupFieldsByCategory: () => groupFieldsByCategory,
81
83
  groupFieldsByPattern: () => groupFieldsByPattern,
84
+ isAdapterCategory: () => isAdapterCategory,
82
85
  isFailureIhsStatus: () => isFailureIhsStatus,
83
86
  isTerminalIhsStatus: () => isTerminalIhsStatus,
84
87
  isValidIhsStatus: () => isValidIhsStatus,
@@ -102,7 +105,7 @@ function getPastYearLabel(yearsAgo) {
102
105
  const date = /* @__PURE__ */ new Date();
103
106
  return (date.getFullYear() - yearsAgo).toString();
104
107
  }
105
- function evaluateExpression(expression, data2) {
108
+ function evaluateExpression(expression, data) {
106
109
  if (!expression) return true;
107
110
  try {
108
111
  let jsExpression = expression.replace(/\{([^}]+)\}/g, (_, key) => {
@@ -126,7 +129,7 @@ function evaluateExpression(expression, data2) {
126
129
  (_, ref, val) => `!(${ref} || []).includes('${val}')`
127
130
  );
128
131
  const func = new Function(`return ${jsExpression};`);
129
- return !!func.call(data2 || {});
132
+ return !!func.call(data || {});
130
133
  } catch (e) {
131
134
  return false;
132
135
  }
@@ -272,16 +275,16 @@ function groupFieldsByCategory(fields, categories) {
272
275
  // src/rhf-generator.ts
273
276
  var import_zod = require("zod");
274
277
  function applyVisibilityValidation(baseObject, fields) {
275
- return baseObject.superRefine((data2, ctx) => {
278
+ return baseObject.superRefine((data, ctx) => {
276
279
  fields.forEach((field) => {
277
280
  const isRequired = field.isRequired !== false && field.required !== false && field.type !== "html";
278
281
  if (!isRequired) return;
279
282
  let isVisible = field.visible !== false;
280
283
  if (isVisible && field.visibleIf) {
281
- isVisible = evaluateExpression(field.visibleIf, data2);
284
+ isVisible = evaluateExpression(field.visibleIf, data);
282
285
  }
283
286
  if (isVisible) {
284
- const value = data2[field.name];
287
+ const value = data[field.name];
285
288
  const isEmpty = value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
286
289
  if (isEmpty) {
287
290
  ctx.addIssue({
@@ -742,22 +745,22 @@ var ajv = new Ajv({ allErrors: true, strict: false });
742
745
  var addFormatsFn = import_ajv_formats.default.default || import_ajv_formats.default;
743
746
  addFormatsFn(ajv);
744
747
  ajv.addSchema(unified_form_schema_default, "unified-form.schema.json");
745
- function validateFormConfig(data2) {
748
+ function validateFormConfig(data) {
746
749
  const validate = ajv.getSchema("unified-form.schema.json");
747
750
  if (!validate) {
748
751
  return { valid: false, message: "Could not load unified form schema" };
749
752
  }
750
- const valid = validate(data2);
753
+ const valid = validate(data);
751
754
  return {
752
755
  valid: !!valid,
753
756
  errors: validate.errors || void 0
754
757
  };
755
758
  }
756
- function validateFormSpec(data2) {
757
- return validateFormConfig(data2);
759
+ function validateFormSpec(data) {
760
+ return validateFormConfig(data);
758
761
  }
759
- function validatePagesConfig(data2) {
760
- return validateFormConfig(data2);
762
+ function validatePagesConfig(data) {
763
+ return validateFormConfig(data);
761
764
  }
762
765
 
763
766
  // src/form-field-category.ts
@@ -1214,10 +1217,10 @@ var _FormSpec = class _FormSpec {
1214
1217
  if (Array.isArray(jsonData.fields)) {
1215
1218
  fieldObjects = jsonData.fields;
1216
1219
  } else if (typeof jsonData.fields === "object" && jsonData.fields !== null) {
1217
- fieldObjects = Object.entries(jsonData.fields).map(([name, data2]) => {
1220
+ fieldObjects = Object.entries(jsonData.fields).map(([name, data]) => {
1218
1221
  return {
1219
1222
  name,
1220
- ...data2
1223
+ ...data
1221
1224
  };
1222
1225
  });
1223
1226
  }
@@ -9475,18 +9478,18 @@ function buildTableForGroup(groupName, fields, ihsData) {
9475
9478
  const items = [];
9476
9479
  for (const [baseName, periodMap] of Object.entries(columnGroups)) {
9477
9480
  const numeric = isNumericField(baseName);
9478
- const data2 = {};
9481
+ const data = {};
9479
9482
  const formattedData = {};
9480
9483
  for (const period of periods) {
9481
9484
  const colName = periodMap[period];
9482
9485
  const value = colName ? ihsData[colName] ?? null : null;
9483
- data2[period] = value;
9486
+ data[period] = value;
9484
9487
  formattedData[period] = formatValue(value, numeric);
9485
9488
  }
9486
9489
  items.push({
9487
9490
  displayName: getDisplayName(baseName),
9488
9491
  timePeriods: periods,
9489
- data: data2,
9492
+ data,
9490
9493
  formattedData,
9491
9494
  type: tableType,
9492
9495
  isNumeric: numeric
@@ -9907,7 +9910,7 @@ var adapter_categories_default = {
9907
9910
  {
9908
9911
  id: "telco-carrier",
9909
9912
  displayName: "Telco Carrier",
9910
- description: "Mobile carrier bill-payment + account-history signals. Any telco vendor (Celcom, Maxis, DiGi, U-Mobile, etc.) implementing this category produces the same canonical field set.",
9913
+ description: "Mobile carrier bill-payment + account-history signals. Any mobile carrier implementing this category produces the same canonical field set.",
9911
9914
  canonicalTable: "ihs_alt_data_telco",
9912
9915
  fields: [
9913
9916
  {
@@ -9960,7 +9963,7 @@ var adapter_categories_default = {
9960
9963
  {
9961
9964
  id: "payment-network",
9962
9965
  displayName: "Payment Network",
9963
- description: "Merchant-side payment-flow signals from POS / gateway networks (iPay88, GHL, etc.). Captures actual transaction velocity rather than self-reported revenue.",
9966
+ description: "Merchant-side payment-flow signals from POS / payment-gateway networks. Captures actual transaction velocity rather than self-reported revenue.",
9964
9967
  canonicalTable: "ihs_alt_data_payments",
9965
9968
  fields: [
9966
9969
  {
@@ -10054,17 +10057,352 @@ var adapter_categories_default = {
10054
10057
  description: "Bounced / returned transactions in the period. Distress signal at counts > 0."
10055
10058
  }
10056
10059
  ]
10060
+ },
10061
+ {
10062
+ id: "social-media",
10063
+ displayName: "Social Media Presence",
10064
+ 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.",
10065
+ canonicalTable: "ihs_alt_data_social_media",
10066
+ fields: [
10067
+ {
10068
+ name: "socialAccountTenureMonths",
10069
+ type: "number",
10070
+ unit: "months",
10071
+ range: [0, 600],
10072
+ description: "Age of the oldest verified public business presence across linked profiles. Establishment / continuity proxy, parallel to telco + payment-network tenure."
10073
+ },
10074
+ {
10075
+ name: "socialFollowerCount",
10076
+ type: "number",
10077
+ unit: "count",
10078
+ range: [0, 1e8],
10079
+ description: "Aggregate audience size across linked public profiles. Coarse reach / scale proxy \u2014 gameable on its own, so read alongside socialEngagementRate90d."
10080
+ },
10081
+ {
10082
+ name: "socialEngagementRate90d",
10083
+ type: "number",
10084
+ unit: "ratio",
10085
+ range: [0, 1],
10086
+ 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."
10087
+ },
10088
+ {
10089
+ name: "socialPostingConsistency12m",
10090
+ type: "number",
10091
+ unit: "ratio",
10092
+ range: [0, 1],
10093
+ 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."
10094
+ },
10095
+ {
10096
+ name: "socialVerifiedBusinessAccount",
10097
+ type: "boolean",
10098
+ description: "Has at least one platform-verified business / commerce profile. Legitimacy signal \u2014 the platform has performed its own business-identity check."
10099
+ },
10100
+ {
10101
+ name: "socialCustomerRatingAvg",
10102
+ type: "number",
10103
+ unit: "rating",
10104
+ range: [0, 5],
10105
+ description: "Mean public customer rating (normalised to a 0\u20135 scale) across review-bearing profiles. Reputation signal; especially predictive for consumer-facing SMEs."
10106
+ },
10107
+ {
10108
+ name: "socialNegativeSentimentRatio90d",
10109
+ type: "number",
10110
+ unit: "ratio",
10111
+ range: [0, 1],
10112
+ description: "Fraction of public mentions / reviews classified as negative over the trailing 90 days. Reputation-risk / distress signal independent of overall rating volume."
10113
+ },
10114
+ {
10115
+ name: "socialAccountFlags24m",
10116
+ type: "number",
10117
+ unit: "count",
10118
+ range: [0, 100],
10119
+ description: "Policy strikes, suspensions, or content takedowns across linked profiles in the last 24 months. Distress signal, parallel to telcoSuspensionsCount24m."
10120
+ }
10121
+ ]
10122
+ },
10123
+ {
10124
+ id: "trade-credit",
10125
+ displayName: "Trade Credit (Accounting)",
10126
+ 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.",
10127
+ canonicalTable: "ihs_alt_data_trade_credit",
10128
+ fields: [
10129
+ {
10130
+ name: "arDaysSalesOutstanding",
10131
+ type: "number",
10132
+ unit: "days",
10133
+ range: [0, 400],
10134
+ 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."
10135
+ },
10136
+ {
10137
+ name: "apDaysPayableOutstanding",
10138
+ type: "number",
10139
+ unit: "days",
10140
+ range: [0, 400],
10141
+ 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."
10142
+ },
10143
+ {
10144
+ name: "arTotalOutstandingMyr",
10145
+ type: "number",
10146
+ unit: "MYR",
10147
+ range: [0, 1e9],
10148
+ description: "Total accounts-receivable balance outstanding (RM). The size of the debtor book the business is carrying."
10149
+ },
10150
+ {
10151
+ name: "arCurrentRatio",
10152
+ type: "number",
10153
+ unit: "ratio",
10154
+ range: [0, 1],
10155
+ 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."
10156
+ },
10157
+ {
10158
+ name: "arOverdue90PlusRatio",
10159
+ type: "number",
10160
+ unit: "ratio",
10161
+ range: [0, 1],
10162
+ 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."
10163
+ },
10164
+ {
10165
+ name: "debtorConcentrationTop5Ratio",
10166
+ type: "number",
10167
+ unit: "ratio",
10168
+ range: [0, 1],
10169
+ 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."
10170
+ },
10171
+ {
10172
+ name: "tradeReferenceDefaults12m",
10173
+ type: "number",
10174
+ unit: "count",
10175
+ range: [0, 1e3],
10176
+ 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."
10177
+ },
10178
+ {
10179
+ name: "accountingRevenue12mMyr",
10180
+ type: "number",
10181
+ unit: "MYR",
10182
+ range: [0, 1e9],
10183
+ 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."
10184
+ },
10185
+ {
10186
+ name: "grossMarginPct",
10187
+ type: "number",
10188
+ unit: "ratio",
10189
+ range: [0, 1],
10190
+ 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."
10191
+ },
10192
+ {
10193
+ name: "cashConversionCycleDays",
10194
+ type: "number",
10195
+ unit: "days",
10196
+ range: [-200, 600],
10197
+ 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."
10198
+ }
10199
+ ]
10200
+ },
10201
+ {
10202
+ id: "geolocation",
10203
+ displayName: "Geolocation",
10204
+ 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.",
10205
+ canonicalTable: "ihs_alt_data_geolocation",
10206
+ fields: [
10207
+ {
10208
+ name: "geoLatitude",
10209
+ type: "number",
10210
+ unit: "deg",
10211
+ range: [-90, 90],
10212
+ description: "Observed latitude for this hourly bucket (point instances only)."
10213
+ },
10214
+ {
10215
+ name: "geoLongitude",
10216
+ type: "number",
10217
+ unit: "deg",
10218
+ range: [-180, 180],
10219
+ description: "Observed longitude for this hourly bucket (point instances only)."
10220
+ },
10221
+ {
10222
+ name: "geoAccuracyM",
10223
+ type: "number",
10224
+ unit: "meters",
10225
+ range: [0, 1e5],
10226
+ description: "Source-reported horizontal accuracy radius of the observation. Cell-tower fixes are typically hundreds of meters; GPS fixes tens."
10227
+ },
10228
+ {
10229
+ name: "geoBucket",
10230
+ type: "string",
10231
+ 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."
10232
+ },
10233
+ {
10234
+ name: "geoPlaceLabel",
10235
+ type: "string",
10236
+ 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."
10237
+ },
10238
+ {
10239
+ name: "geoWorkAttendanceRatio30d",
10240
+ type: "number",
10241
+ unit: "ratio",
10242
+ range: [0, 1],
10243
+ 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)."
10244
+ },
10245
+ {
10246
+ name: "geoWorkDailyHoursAvg30d",
10247
+ type: "number",
10248
+ unit: "hours",
10249
+ range: [0, 24],
10250
+ description: "Mean daily hours of work-anchor dwell across the last 30 weekdays (summary instance only)."
10251
+ },
10252
+ {
10253
+ name: "geoLocationStabilityScore",
10254
+ type: "number",
10255
+ unit: "score",
10256
+ range: [0, 1],
10257
+ description: "Residential stability: share of nights spent at the primary home anchor over the observation window. 1 = every night at home (summary instance only)."
10258
+ },
10259
+ {
10260
+ name: "geoCommuteRegularityRatio",
10261
+ type: "number",
10262
+ unit: "ratio",
10263
+ range: [0, 1],
10264
+ 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)."
10265
+ },
10266
+ {
10267
+ name: "geoVacationDays90d",
10268
+ type: "number",
10269
+ unit: "days",
10270
+ range: [0, 90],
10271
+ description: "Days in the last 90 spent fully away from both home and work anchors (contiguous travel windows; summary instance only)."
10272
+ },
10273
+ {
10274
+ name: "geoHotspotDwellRatio",
10275
+ type: "number",
10276
+ unit: "ratio",
10277
+ range: [0, 1],
10278
+ 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)."
10279
+ },
10280
+ {
10281
+ name: "geoPrimaryStateCode",
10282
+ type: "string",
10283
+ description: "Malaysian state / federal-territory code of the primary home anchor, e.g. PNG, KUL, JHR (summary instance only)."
10284
+ },
10285
+ {
10286
+ name: "geoAddressMatchScore",
10287
+ type: "number",
10288
+ unit: "score",
10289
+ range: [0, 1],
10290
+ description: "Agreement between the inferred home anchor and the applicant's registered residential address. 1 = same premises, 0 = different state (summary instance only)."
10291
+ }
10292
+ ]
10057
10293
  }
10058
10294
  ]
10059
10295
  };
10060
10296
 
10061
10297
  // src/adapter-categories.ts
10062
- var data = adapter_categories_default;
10298
+ var VALID_FIELD_TYPES = [
10299
+ "number",
10300
+ "boolean",
10301
+ "string"
10302
+ ];
10303
+ function buildCategoryRegistry(raw) {
10304
+ if (!raw || typeof raw !== "object") {
10305
+ throw new Error("adapter category data: expected an object");
10306
+ }
10307
+ if (typeof raw.schemaVersion !== "string" || raw.schemaVersion.length === 0) {
10308
+ throw new Error("adapter category data: missing schemaVersion");
10309
+ }
10310
+ if (!Array.isArray(raw.categories) || raw.categories.length === 0) {
10311
+ throw new Error("adapter category data: categories must be a non-empty array");
10312
+ }
10313
+ const byId = /* @__PURE__ */ new Map();
10314
+ const fieldToCategory = /* @__PURE__ */ new Map();
10315
+ const tables = /* @__PURE__ */ new Set();
10316
+ const all = [];
10317
+ for (const cat of raw.categories) {
10318
+ const where = `category "${cat?.id ?? "<unknown>"}"`;
10319
+ if (typeof cat.id !== "string" || cat.id.length === 0) {
10320
+ throw new Error("adapter category data: every category needs a non-empty id");
10321
+ }
10322
+ if (byId.has(cat.id)) {
10323
+ throw new Error(`adapter category data: duplicate category id "${cat.id}"`);
10324
+ }
10325
+ if (typeof cat.displayName !== "string" || cat.displayName.length === 0) {
10326
+ throw new Error(`adapter category data: ${where} needs a non-empty displayName`);
10327
+ }
10328
+ if (typeof cat.description !== "string" || cat.description.length === 0) {
10329
+ throw new Error(`adapter category data: ${where} needs a non-empty description`);
10330
+ }
10331
+ if (typeof cat.canonicalTable !== "string" || !/^ihs_alt_data_/.test(cat.canonicalTable)) {
10332
+ throw new Error(
10333
+ `adapter category data: ${where} canonicalTable must start with "ihs_alt_data_" (got "${cat.canonicalTable}")`
10334
+ );
10335
+ }
10336
+ if (tables.has(cat.canonicalTable)) {
10337
+ throw new Error(
10338
+ `adapter category data: duplicate canonicalTable "${cat.canonicalTable}" (${where})`
10339
+ );
10340
+ }
10341
+ if (!Array.isArray(cat.fields) || cat.fields.length === 0) {
10342
+ throw new Error(`adapter category data: ${where} must declare at least one field`);
10343
+ }
10344
+ const fields = [];
10345
+ for (const f of cat.fields) {
10346
+ if (typeof f.name !== "string" || f.name.length === 0) {
10347
+ throw new Error(`adapter category data: ${where} has a field with no name`);
10348
+ }
10349
+ if (fieldToCategory.has(f.name)) {
10350
+ throw new Error(
10351
+ `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`
10352
+ );
10353
+ }
10354
+ if (!VALID_FIELD_TYPES.includes(f.type)) {
10355
+ throw new Error(
10356
+ `adapter category data: field "${f.name}" (${where}) has invalid type "${f.type}"`
10357
+ );
10358
+ }
10359
+ if (typeof f.description !== "string" || f.description.length === 0) {
10360
+ throw new Error(
10361
+ `adapter category data: field "${f.name}" (${where}) needs a non-empty description`
10362
+ );
10363
+ }
10364
+ if (f.range !== void 0) {
10365
+ 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]) {
10366
+ throw new Error(
10367
+ `adapter category data: field "${f.name}" (${where}) has an invalid range \u2014 expected [lo, hi] with finite lo <= hi`
10368
+ );
10369
+ }
10370
+ }
10371
+ const spec = Object.freeze({
10372
+ name: f.name,
10373
+ type: f.type,
10374
+ ...f.unit !== void 0 ? { unit: f.unit } : {},
10375
+ ...f.range !== void 0 ? { range: Object.freeze([f.range[0], f.range[1]]) } : {},
10376
+ description: f.description
10377
+ });
10378
+ fields.push(spec);
10379
+ fieldToCategory.set(f.name, cat.id);
10380
+ }
10381
+ const schema = Object.freeze({
10382
+ id: cat.id,
10383
+ displayName: cat.displayName,
10384
+ description: cat.description,
10385
+ canonicalTable: cat.canonicalTable,
10386
+ fields: Object.freeze(fields)
10387
+ });
10388
+ byId.set(cat.id, schema);
10389
+ tables.add(cat.canonicalTable);
10390
+ all.push(schema);
10391
+ }
10392
+ return Object.freeze({
10393
+ all: Object.freeze(all),
10394
+ ids: Object.freeze(all.map((c) => c.id)),
10395
+ byId,
10396
+ fieldToCategory
10397
+ });
10398
+ }
10399
+ var registry = buildCategoryRegistry(adapter_categories_default);
10400
+ var ADAPTER_CATEGORY_IDS = registry.ids;
10063
10401
  function categorySchemaOf(id) {
10064
- const found = data.categories.find((c) => c.id === id);
10402
+ const found = registry.byId.get(id);
10065
10403
  if (!found) {
10066
10404
  throw new Error(
10067
- `Unknown adapter category: ${id}. Available: ${data.categories.map((c) => c.id).join(", ")}`
10405
+ `Unknown adapter category: ${id}. Available: ${registry.ids.join(", ")}`
10068
10406
  );
10069
10407
  }
10070
10408
  return found;
@@ -10073,22 +10411,25 @@ function categoryFieldsOf(id) {
10073
10411
  return categorySchemaOf(id).fields.map((f) => f.name);
10074
10412
  }
10075
10413
  function allCategories() {
10076
- return data.categories;
10414
+ return registry.all;
10077
10415
  }
10078
- var fieldToCategory = (() => {
10079
- const m = /* @__PURE__ */ new Map();
10080
- for (const cat of data.categories) {
10081
- for (const f of cat.fields) {
10082
- m.set(f.name, cat.id);
10083
- }
10084
- }
10085
- return m;
10086
- })();
10087
10416
  function categoryForField(field) {
10088
- return fieldToCategory.get(field) ?? null;
10417
+ return registry.fieldToCategory.get(field) ?? null;
10418
+ }
10419
+ function isAdapterCategory(id) {
10420
+ return registry.byId.has(id);
10421
+ }
10422
+ function assertAdapterCategory(id) {
10423
+ if (!registry.byId.has(id)) {
10424
+ throw new Error(
10425
+ `Unknown adapter category: ${id}. Available: ${registry.ids.join(", ")}`
10426
+ );
10427
+ }
10428
+ return id;
10089
10429
  }
10090
10430
  // Annotate the CommonJS export names for ESM import in node:
10091
10431
  0 && (module.exports = {
10432
+ ADAPTER_CATEGORY_IDS,
10092
10433
  ALL_AGGREGATION_OPS,
10093
10434
  AdapterError,
10094
10435
  BASE_FIELD_SPECS,
@@ -10114,6 +10455,7 @@ function categoryForField(field) {
10114
10455
  allCategories,
10115
10456
  applyAggregation,
10116
10457
  applyDynamicTitles,
10458
+ assertAdapterCategory,
10117
10459
  buildFileFieldTables,
10118
10460
  categoryFieldsOf,
10119
10461
  categoryForField,
@@ -10138,6 +10480,7 @@ function categoryForField(field) {
10138
10480
  groupDetailsByCategory,
10139
10481
  groupFieldsByCategory,
10140
10482
  groupFieldsByPattern,
10483
+ isAdapterCategory,
10141
10484
  isFailureIhsStatus,
10142
10485
  isTerminalIhsStatus,
10143
10486
  isValidIhsStatus,