@fulmenhq/tsfulmen 0.3.3 → 0.4.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/CHANGELOG.md +51 -1
- package/README.md +30 -1
- package/config/crucible-ts/taxonomy/metrics.yaml +1 -1
- package/dist/appidentity/index.js +9 -2209
- package/dist/appidentity/index.js.map +1 -1
- package/dist/assets/index.d.ts +179 -0
- package/dist/assets/index.js +4 -0
- package/dist/assets/index.js.map +1 -0
- package/dist/bin/prometheus-cli.js +15 -9139
- package/dist/bin/prometheus-cli.js.map +1 -1
- package/dist/bin/schema-cli.js +4 -6098
- package/dist/bin/schema-cli.js.map +1 -1
- package/dist/bin/signals-cli.js +15 -1910
- package/dist/bin/signals-cli.js.map +1 -1
- package/dist/chunk-3HISR2XI.js +36 -0
- package/dist/chunk-3HISR2XI.js.map +1 -0
- package/dist/chunk-5HZEJGZ5.js +725 -0
- package/dist/chunk-5HZEJGZ5.js.map +1 -0
- package/dist/chunk-7SVYOPJ3.js +9412 -0
- package/dist/chunk-7SVYOPJ3.js.map +1 -0
- package/dist/chunk-BCO3FUUO.js +682 -0
- package/dist/chunk-BCO3FUUO.js.map +1 -0
- package/dist/chunk-BJDL6JEX.js +208 -0
- package/dist/chunk-BJDL6JEX.js.map +1 -0
- package/dist/chunk-BTUS6PZZ.js +302 -0
- package/dist/chunk-BTUS6PZZ.js.map +1 -0
- package/dist/chunk-CW4CSNVF.js +410 -0
- package/dist/chunk-CW4CSNVF.js.map +1 -0
- package/dist/chunk-HIBZ2AY7.js +194 -0
- package/dist/chunk-HIBZ2AY7.js.map +1 -0
- package/dist/chunk-HS4F3BRR.js +985 -0
- package/dist/chunk-HS4F3BRR.js.map +1 -0
- package/dist/chunk-HY6JQOFN.js +32 -0
- package/dist/chunk-HY6JQOFN.js.map +1 -0
- package/dist/chunk-K2FYT43R.js +837 -0
- package/dist/chunk-K2FYT43R.js.map +1 -0
- package/dist/chunk-K7BMFGQP.js +43 -0
- package/dist/chunk-K7BMFGQP.js.map +1 -0
- package/dist/chunk-LWAH2UG7.js +103 -0
- package/dist/chunk-LWAH2UG7.js.map +1 -0
- package/dist/chunk-OHE2AOH4.js +273 -0
- package/dist/chunk-OHE2AOH4.js.map +1 -0
- package/dist/chunk-P3DNOZOG.js +1488 -0
- package/dist/chunk-P3DNOZOG.js.map +1 -0
- package/dist/chunk-PQ6TKPUN.js +27 -0
- package/dist/chunk-PQ6TKPUN.js.map +1 -0
- package/dist/chunk-QCCN6POA.js +211 -0
- package/dist/chunk-QCCN6POA.js.map +1 -0
- package/dist/chunk-RSLFR4TO.js +631 -0
- package/dist/chunk-RSLFR4TO.js.map +1 -0
- package/dist/chunk-UP2VWCW5.js +33 -0
- package/dist/chunk-UP2VWCW5.js.map +1 -0
- package/dist/chunk-W6TQFTTY.js +130 -0
- package/dist/chunk-W6TQFTTY.js.map +1 -0
- package/dist/chunk-WSMVLWLB.js +269 -0
- package/dist/chunk-WSMVLWLB.js.map +1 -0
- package/dist/config/index.js +6 -1220
- package/dist/config/index.js.map +1 -1
- package/dist/crucible/fulpack/index.js +2 -25
- package/dist/crucible/fulpack/index.js.map +1 -1
- package/dist/crucible/index.js +13 -1129
- package/dist/crucible/index.js.map +1 -1
- package/dist/docscribe/index.js +2 -680
- package/dist/docscribe/index.js.map +1 -1
- package/dist/errors/index.js +5 -1831
- package/dist/errors/index.js.map +1 -1
- package/dist/errors-D7KXV3QW.js +4 -0
- package/dist/errors-D7KXV3QW.js.map +1 -0
- package/dist/errors-RBJX6ETJ.js +8 -0
- package/dist/errors-RBJX6ETJ.js.map +1 -0
- package/dist/export-BWRETGYS.js +6 -0
- package/dist/export-BWRETGYS.js.map +1 -0
- package/dist/foundry/index.js +340 -3949
- package/dist/foundry/index.js.map +1 -1
- package/dist/foundry/similarity/index.js +3 -134
- package/dist/foundry/similarity/index.js.map +1 -1
- package/dist/fulencode/index.js +3 -319
- package/dist/fulencode/index.js.map +1 -1
- package/dist/fulhash/index.js +3 -611
- package/dist/fulhash/index.js.map +1 -1
- package/dist/fulpack/index.js +3 -1515
- package/dist/fulpack/index.js.map +1 -1
- package/dist/hash-YOJYVOWH.js +4 -0
- package/dist/hash-YOJYVOWH.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -4395
- package/dist/index.js.map +1 -1
- package/dist/loader-H5K7HSO5.js +9 -0
- package/dist/loader-H5K7HSO5.js.map +1 -0
- package/dist/logging/index.js +2 -723
- package/dist/logging/index.js.map +1 -1
- package/dist/pathfinder/index.js +18 -2341
- package/dist/pathfinder/index.js.map +1 -1
- package/dist/prom-client-PNEBGD3G.js +4801 -0
- package/dist/prom-client-PNEBGD3G.js.map +1 -0
- package/dist/reports/license-inventory.csv +1 -1
- package/dist/schema/index.d.ts +19 -6
- package/dist/schema/index.js +4 -6148
- package/dist/schema/index.js.map +1 -1
- package/dist/signals/index.js +8 -2767
- package/dist/signals/index.js.map +1 -1
- package/dist/similarity/index.js +3 -134
- package/dist/similarity/index.js.map +1 -1
- package/dist/telemetry/http/index.js +9 -930
- package/dist/telemetry/http/index.js.map +1 -1
- package/dist/telemetry/index.js +4 -1561
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/prometheus/index.js +7 -8422
- package/dist/telemetry/prometheus/index.js.map +1 -1
- package/dist/validator-U4CKD2Y3.js +6 -0
- package/dist/validator-U4CKD2Y3.js.map +1 -0
- package/package.json +5 -1
- package/schemas/crucible-ts/library/module-manifest/v1.0.0/module-manifest.schema.json +1 -1
- package/schemas/crucible-ts/observability/logging/v1.0.0/definitions.schema.json +1 -1
- package/schemas/crucible-ts/observability/logging/v1.0.0/log-event.schema.json +13 -13
- package/schemas/crucible-ts/observability/logging/v1.0.0/logger-config.schema.json +2 -2
- package/schemas/crucible-ts/observability/logging/v1.0.0/logging-policy.schema.json +1 -1
- package/schemas/crucible-ts/observability/logging/v1.0.0/middleware-config.schema.json +2 -2
- package/schemas/crucible-ts/observability/logging/v1.0.0/severity-filter.schema.json +3 -3
- package/schemas/crucible-ts/upstream/3leaps/crucible/PROVENANCE.md +3 -3
- package/schemas/crucible-ts/upstream/3leaps/crucible/docs/catalog/classifiers/README.md +1 -1
- package/schemas/crucible-ts/upstream/3leaps/crucible/docs/standards/classifiers-framework.md +1 -1
- package/schemas/crucible-ts/upstream/3leaps/crucible/docs/standards/data-sensitivity-classification.md +1 -1
|
@@ -1,136 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function distance(a, b, metric = "levenshtein") {
|
|
5
|
-
switch (metric) {
|
|
6
|
-
case "levenshtein":
|
|
7
|
-
return levenshtein(a, b);
|
|
8
|
-
case "damerau_osa":
|
|
9
|
-
return osa_distance(a, b);
|
|
10
|
-
case "damerau_unrestricted":
|
|
11
|
-
return damerau_levenshtein(a, b);
|
|
12
|
-
case "jaro_winkler":
|
|
13
|
-
return jaro_winkler(a, b);
|
|
14
|
-
case "substring":
|
|
15
|
-
return substringSimilarity(a, b).score;
|
|
16
|
-
default:
|
|
17
|
-
throw new Error(
|
|
18
|
-
`Invalid metric '${metric}': must be one of: levenshtein, damerau_osa, damerau_unrestricted, jaro_winkler, substring`
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// src/foundry/errors.ts
|
|
24
|
-
var FoundryCatalogError = class _FoundryCatalogError extends Error {
|
|
25
|
-
constructor(message, catalog, cause) {
|
|
26
|
-
super(message);
|
|
27
|
-
this.catalog = catalog;
|
|
28
|
-
this.cause = cause;
|
|
29
|
-
this.name = "FoundryCatalogError";
|
|
30
|
-
if (Error.captureStackTrace) {
|
|
31
|
-
Error.captureStackTrace(this, _FoundryCatalogError);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
static invalidSchema(catalog, details, cause) {
|
|
35
|
-
return new _FoundryCatalogError(
|
|
36
|
-
`Invalid schema in ${catalog} catalog: ${details}`,
|
|
37
|
-
catalog,
|
|
38
|
-
cause
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
static missingCatalog(catalog) {
|
|
42
|
-
return new _FoundryCatalogError(`Catalog ${catalog} not found or could not be loaded`, catalog);
|
|
43
|
-
}
|
|
44
|
-
static invalidPattern(patternId, details) {
|
|
45
|
-
return new _FoundryCatalogError(`Invalid pattern ${patternId}: ${details}`, "patterns");
|
|
46
|
-
}
|
|
47
|
-
static compilationError(patternId, details, cause) {
|
|
48
|
-
return new _FoundryCatalogError(
|
|
49
|
-
`Failed to compile pattern ${patternId}: ${details}`,
|
|
50
|
-
"patterns",
|
|
51
|
-
cause
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// src/foundry/similarity/errors.ts
|
|
57
|
-
var SimilarityError = class extends FoundryCatalogError {
|
|
58
|
-
constructor(message, cause) {
|
|
59
|
-
super(message, "similarity", cause);
|
|
60
|
-
this.name = "SimilarityError";
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
function toNormalizationLocale(locale) {
|
|
64
|
-
if (!locale) {
|
|
65
|
-
return void 0;
|
|
66
|
-
}
|
|
67
|
-
if (locale === "tr" || locale === "az" || locale === "lt") {
|
|
68
|
-
return locale;
|
|
69
|
-
}
|
|
70
|
-
return void 0;
|
|
71
|
-
}
|
|
72
|
-
function normalize(value, preset = "default", locale) {
|
|
73
|
-
if (typeof preset === "object") {
|
|
74
|
-
const targetPreset = preset.stripAccents ? "aggressive" : "default";
|
|
75
|
-
const targetLocale = toNormalizationLocale(preset.locale ?? locale);
|
|
76
|
-
return normalize$1(value, targetPreset, targetLocale);
|
|
77
|
-
}
|
|
78
|
-
return normalize$1(value, preset, toNormalizationLocale(locale));
|
|
79
|
-
}
|
|
80
|
-
function casefold(value, locale) {
|
|
81
|
-
if (locale === "tr") {
|
|
82
|
-
return value.toLocaleLowerCase("tr-TR");
|
|
83
|
-
}
|
|
84
|
-
return value.toLowerCase();
|
|
85
|
-
}
|
|
86
|
-
function stripAccents(value) {
|
|
87
|
-
return value.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
88
|
-
}
|
|
89
|
-
function equalsIgnoreCase(a, b, options) {
|
|
90
|
-
return normalize(a, options) === normalize(b, options);
|
|
91
|
-
}
|
|
92
|
-
function score(a, b, metric = "levenshtein") {
|
|
93
|
-
if (metric === "substring") {
|
|
94
|
-
return substringSimilarity(a, b).score;
|
|
95
|
-
}
|
|
96
|
-
return score$1(a, b, metric);
|
|
97
|
-
}
|
|
98
|
-
var DEFAULT_MIN_SCORE = 0.6;
|
|
99
|
-
var DEFAULT_MAX_SUGGESTIONS = 3;
|
|
100
|
-
var DEFAULT_METRIC = "levenshtein";
|
|
101
|
-
var DEFAULT_NORMALIZE_PRESET = "default";
|
|
102
|
-
function suggest(input, candidates, options) {
|
|
103
|
-
const metric = options?.metric ?? DEFAULT_METRIC;
|
|
104
|
-
const minScore = options?.minScore ?? DEFAULT_MIN_SCORE;
|
|
105
|
-
const maxSuggestions = options?.maxSuggestions ?? DEFAULT_MAX_SUGGESTIONS;
|
|
106
|
-
let normalizePreset = options?.normalizePreset ?? DEFAULT_NORMALIZE_PRESET;
|
|
107
|
-
if (options?.normalize === false) {
|
|
108
|
-
normalizePreset = "none";
|
|
109
|
-
} else if (options?.normalize === true && !options?.normalizePreset) {
|
|
110
|
-
normalizePreset = "default";
|
|
111
|
-
}
|
|
112
|
-
const wasmOptions = {
|
|
113
|
-
metric,
|
|
114
|
-
normalizePreset,
|
|
115
|
-
minScore,
|
|
116
|
-
maxSuggestions,
|
|
117
|
-
preferPrefix: options?.preferPrefix,
|
|
118
|
-
jaroPrefixScale: options?.jaroPrefixScale,
|
|
119
|
-
jaroMaxPrefix: options?.jaroMaxPrefix
|
|
120
|
-
};
|
|
121
|
-
const results = suggest$1(input, candidates, wasmOptions);
|
|
122
|
-
return results.map((r) => ({
|
|
123
|
-
value: r.value,
|
|
124
|
-
score: r.score,
|
|
125
|
-
matchedRange: r.matchedRange,
|
|
126
|
-
reason: r.reason,
|
|
127
|
-
normalizedValue: r.normalizedValue
|
|
128
|
-
}));
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// src/foundry/similarity/index.ts
|
|
132
|
-
var VERSION = "2.0.0";
|
|
133
|
-
|
|
134
|
-
export { SimilarityError, VERSION, casefold, distance, equalsIgnoreCase, normalize, score, stripAccents, suggest };
|
|
1
|
+
export { SimilarityError, VERSION, casefold, distance, equalsIgnoreCase, normalize, score, stripAccents, suggest } from '../../chunk-LWAH2UG7.js';
|
|
2
|
+
import '../../chunk-3HISR2XI.js';
|
|
3
|
+
import '../../chunk-UP2VWCW5.js';
|
|
135
4
|
//# sourceMappingURL=index.js.map
|
|
136
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/foundry/similarity/distance.ts","../../../src/foundry/errors.ts","../../../src/foundry/similarity/errors.ts","../../../src/foundry/similarity/normalization.ts","../../../src/foundry/similarity/score.ts","../../../src/foundry/similarity/suggest.ts","../../../src/foundry/similarity/index.ts"],"names":["wasmNormalize","substringSimilarity","wasmScore","wasmSuggest"],"mappings":";;;AA+BO,SAAS,QAAA,CAAS,CAAA,EAAW,CAAA,EAAW,MAAA,GAAqB,aAAA,EAAuB;AACzF,EAAA,QAAQ,MAAA;AAAQ,IACd,KAAK,aAAA;AACH,MAAA,OAAO,WAAA,CAAY,GAAG,CAAC,CAAA;AAAA,IACzB,KAAK,aAAA;AACH,MAAA,OAAO,YAAA,CAAa,GAAG,CAAC,CAAA;AAAA,IAC1B,KAAK,sBAAA;AACH,MAAA,OAAO,mBAAA,CAAoB,GAAG,CAAC,CAAA;AAAA,IACjC,KAAK,cAAA;AACH,MAAA,OAAO,YAAA,CAAa,GAAG,CAAC,CAAA;AAAA,IAC1B,KAAK,WAAA;AAEH,MAAA,OAAO,mBAAA,CAAoB,CAAA,EAAG,CAAC,CAAA,CAAE,KAAA;AAAA,IACnC;AACE,MAAA,MAAM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IAC1B,eAAe,OAAA,EAAS;AAAA,GAC1B;AAEA,EAAA,MAAM,OAAA,GAAUC,SAAA,CAAY,KAAA,EAAO,UAAA,EAAwB,WAAW,CAAA;AAGtE,EAAA,OAAO,OAAA,CAAQ,GAAA,CAAI,CAAC,CAAA,MAAO;AAAA,IACzB,OAAO,CAAA,CAAE,KAAA;AAAA,IACT,OAAO,CAAA,CAAE,KAAA;AAAA,IACT,cAAc,CAAA,CAAE,YAAA;AAAA,IAChB,QAAQ,CAAA,CAAE,MAAA;AAAA,IACV,iBAAiB,CAAA,CAAE;AAAA,GACrB,CAAE,CAAA;AACJ;;;AC1DO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["/**\n * Distance calculation with multiple metric support.\n *\n * Implements Crucible Foundry Similarity Standard v2.0.0 with WASM-backed metrics.\n *\n * @module foundry/similarity/distance\n */\n\nimport {\n damerau_levenshtein,\n jaro_winkler,\n levenshtein,\n osa_distance,\n substringSimilarity,\n} from \"@3leaps/string-metrics-wasm\";\nimport type { MetricType } from \"./types.js\";\n\n/**\n * Calculate edit distance between two strings using specified metric.\n *\n * @param a - First string\n * @param b - Second string\n * @param metric - Distance metric (default: \"levenshtein\")\n * @returns Edit distance as non-negative integer (or similarity score for jaro_winkler/substring)\n *\n * @example\n * distance(\"kitten\", \"sitting\") // 3\n * distance(\"abcd\", \"abdc\", \"damerau_osa\") // 1\n * distance(\"CA\", \"ABC\", \"damerau_unrestricted\") // 2\n * distance(\"hello world\", \"world\", \"substring\") // 0.625 (as score, not distance)\n */\nexport function distance(a: string, b: string, metric: MetricType = \"levenshtein\"): number {\n switch (metric) {\n case \"levenshtein\":\n return levenshtein(a, b);\n case \"damerau_osa\":\n return osa_distance(a, b);\n case \"damerau_unrestricted\":\n return damerau_levenshtein(a, b);\n case \"jaro_winkler\":\n return jaro_winkler(a, b);\n case \"substring\":\n // Returns similarity score (not distance) with longest common substring\n return substringSimilarity(a, b).score;\n default:\n throw new Error(\n `Invalid metric '${metric}': must be one of: levenshtein, damerau_osa, damerau_unrestricted, jaro_winkler, substring`,\n );\n }\n}\n","/**\n * Foundry module - Error handling\n *\n * Custom error classes for Foundry catalog operations with fail-fast validation.\n */\n\nexport class FoundryCatalogError extends Error {\n constructor(\n message: string,\n public readonly catalog?: string,\n public readonly cause?: Error,\n ) {\n super(message);\n this.name = \"FoundryCatalogError\";\n\n // Maintain proper stack trace for V8\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, FoundryCatalogError);\n }\n }\n\n static invalidSchema(catalog: string, details: string, cause?: Error): FoundryCatalogError {\n return new FoundryCatalogError(\n `Invalid schema in ${catalog} catalog: ${details}`,\n catalog,\n cause,\n );\n }\n\n static missingCatalog(catalog: string): FoundryCatalogError {\n return new FoundryCatalogError(`Catalog ${catalog} not found or could not be loaded`, catalog);\n }\n\n static invalidPattern(patternId: string, details: string): FoundryCatalogError {\n return new FoundryCatalogError(`Invalid pattern ${patternId}: ${details}`, \"patterns\");\n }\n\n static compilationError(patternId: string, details: string, cause?: Error): FoundryCatalogError {\n return new FoundryCatalogError(\n `Failed to compile pattern ${patternId}: ${details}`,\n \"patterns\",\n cause,\n );\n }\n}\n","import { FoundryCatalogError } from \"../errors.js\";\n\nexport class SimilarityError extends FoundryCatalogError {\n constructor(message: string, cause?: Error) {\n super(message, \"similarity\", cause);\n this.name = \"SimilarityError\";\n }\n}\n","/**\n * Unicode-aware text normalization utilities.\n *\n * Implements Crucible Foundry Similarity Standard v2.0.0 with normalization presets.\n *\n * @module foundry/similarity/normalization\n */\n\nimport {\n type NormalizationLocale,\n type NormalizationPreset as WasmNormalizationPreset,\n normalize as wasmNormalize,\n} from \"@3leaps/string-metrics-wasm\";\nimport type { NormalizationPreset, NormalizeOptions } from \"./types.js\";\n\nfunction toNormalizationLocale(locale?: string): NormalizationLocale | undefined {\n if (!locale) {\n return undefined;\n }\n\n if (locale === \"tr\" || locale === \"az\" || locale === \"lt\") {\n return locale;\n }\n\n return undefined;\n}\n\n/**\n * Apply normalization preset to text.\n *\n * @param value - Text to normalize\n * @param preset - Normalization preset (\"none\" | \"minimal\" | \"default\" | \"aggressive\")\n * @param locale - Optional locale for locale-aware casefolding (e.g., \"tr\" for Turkish)\n * @returns Normalized text\n *\n * @example\n * normalize(\" Café-Zürich! \", \"aggressive\") // \"cafezurich\"\n * normalize(\" Hello \", \"minimal\") // \"Hello\"\n * normalize(\"İstanbul\", \"default\", \"tr\") // \"istanbul\"\n */\nexport function normalize(\n value: string,\n preset: NormalizationPreset | NormalizeOptions = \"default\",\n locale?: string,\n): string {\n // Handle legacy NormalizeOptions interface for backward compatibility\n if (typeof preset === \"object\") {\n // Map old options to preset and extract locale\n const targetPreset = preset.stripAccents ? \"aggressive\" : \"default\";\n const targetLocale = toNormalizationLocale(preset.locale ?? locale);\n return wasmNormalize(value, targetPreset, targetLocale);\n }\n\n return wasmNormalize(value, preset as WasmNormalizationPreset, toNormalizationLocale(locale));\n}\n\n/**\n * Unicode-aware case folding.\n *\n * @param value - Text to casefold\n * @param locale - Optional locale (e.g., \"tr\" for Turkish)\n * @returns Lowercase text\n */\nexport function casefold(value: string, locale?: string): string {\n if (locale === \"tr\") {\n return value.toLocaleLowerCase(\"tr-TR\");\n }\n return value.toLowerCase();\n}\n\n/**\n * Strip diacritical marks from text.\n *\n * @param value - Text to process\n * @returns Text with accents removed\n */\nexport function stripAccents(value: string): string {\n return value.normalize(\"NFD\").replace(/[\\u0300-\\u036f]/g, \"\");\n}\n\n/**\n * Compare strings ignoring case and optionally accents.\n *\n * @param a - First string\n * @param b - Second string\n * @param options - Normalization options\n * @returns True if strings are equal after normalization\n */\nexport function equalsIgnoreCase(a: string, b: string, options?: NormalizeOptions): boolean {\n return normalize(a, options) === normalize(b, options);\n}\n","/**\n * Normalized similarity score with metric selection.\n *\n * Implements Crucible Foundry Similarity Standard v2.0.0.\n *\n * @module foundry/similarity/score\n */\n\nimport {\n type SimilarityMetric,\n substringSimilarity,\n score as wasmScore,\n} from \"@3leaps/string-metrics-wasm\";\nimport type { MetricType } from \"./types.js\";\n\n/**\n * Calculate normalized similarity score between two strings.\n *\n * Returns a value between 0.0 (completely different) and 1.0 (identical).\n * For distance-based metrics: 1 - distance / max(len(a), len(b))\n * For jaro_winkler and substring: direct similarity score\n *\n * @param a - First string\n * @param b - Second string\n * @param metric - Similarity metric (default: \"levenshtein\")\n * @returns Similarity score in range [0.0, 1.0]\n *\n * @example\n * score(\"kitten\", \"sitting\") // 0.5714...\n * score(\"hello\", \"hallo\", \"jaro_winkler\") // 0.88\n * score(\"hello world\", \"world\", \"substring\") // 0.625\n */\nexport function score(a: string, b: string, metric: MetricType = \"levenshtein\"): number {\n // Special case: substring uses different API to get proper longest common substring\n if (metric === \"substring\") {\n return substringSimilarity(a, b).score;\n }\n\n // All other metrics supported directly by WASM score function\n return wasmScore(a, b, metric as SimilarityMetric);\n}\n","/**\n * Suggestion API with fuzzy matching and configurable metrics.\n *\n * Implements Crucible Foundry Similarity Standard v2.0.0.\n *\n * @module foundry/similarity/suggest\n */\n\nimport { type SuggestMetric, suggest as wasmSuggest } from \"@3leaps/string-metrics-wasm\";\nimport type { Suggestion, SuggestOptions } from \"./types.js\";\n\nconst DEFAULT_MIN_SCORE = 0.6;\nconst DEFAULT_MAX_SUGGESTIONS = 3;\nconst DEFAULT_METRIC = \"levenshtein\";\nconst DEFAULT_NORMALIZE_PRESET = \"default\";\n\n/**\n * Generate ranked suggestions from candidate list based on similarity.\n *\n * @param input - Input string to match against\n * @param candidates - List of candidate strings\n * @param options - Suggestion options (metric, thresholds, normalization)\n * @returns Array of suggestions sorted by score (descending)\n *\n * @example\n * suggest(\"docscrib\", [\"docscribe\", \"crucible\"], { metric: \"levenshtein\" })\n * // [{ value: \"docscribe\", score: 0.889, ... }]\n */\nexport function suggest(\n input: string,\n candidates: readonly string[],\n options?: SuggestOptions,\n): Suggestion[] {\n const metric = options?.metric ?? DEFAULT_METRIC;\n const minScore = options?.minScore ?? DEFAULT_MIN_SCORE;\n const maxSuggestions = options?.maxSuggestions ?? DEFAULT_MAX_SUGGESTIONS;\n\n // Handle legacy 'normalize' boolean option\n let normalizePreset = options?.normalizePreset ?? DEFAULT_NORMALIZE_PRESET;\n if (options?.normalize === false) {\n normalizePreset = \"none\";\n } else if (options?.normalize === true && !options?.normalizePreset) {\n normalizePreset = \"default\";\n }\n\n // Pass metric name directly to WASM library (it handles \"substring\" correctly)\n const wasmOptions = {\n metric: metric as SuggestMetric,\n normalizePreset,\n minScore,\n maxSuggestions,\n preferPrefix: options?.preferPrefix,\n jaroPrefixScale: options?.jaroPrefixScale,\n jaroMaxPrefix: options?.jaroMaxPrefix,\n };\n\n const results = wasmSuggest(input, candidates as string[], wasmOptions);\n\n // Map WASM results to our Suggestion interface\n return results.map((r) => ({\n value: r.value,\n score: r.score,\n matchedRange: r.matchedRange as [number, number] | undefined,\n reason: r.reason,\n normalizedValue: r.normalizedValue,\n }));\n}\n","/**\n * Foundry similarity module - Text similarity and normalization utilities\n *\n * Implements the Crucible Foundry Text Similarity & Normalization Standard v2.0.0 (2025.10.3).\n *\n * @module foundry/similarity\n */\n\nexport const VERSION = \"2.0.0\";\n\nexport { distance } from \"./distance.js\";\nexport { SimilarityError } from \"./errors.js\";\nexport {\n casefold,\n equalsIgnoreCase,\n normalize,\n stripAccents,\n} from \"./normalization.js\";\nexport { score } from \"./score.js\";\nexport { suggest } from \"./suggest.js\";\n\nexport type {\n MetricType,\n NormalizationPreset,\n NormalizeOptions,\n Suggestion,\n SuggestOptions,\n} from \"./types.js\";\n"]}
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/dist/fulencode/index.js
CHANGED
|
@@ -1,317 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __esm = (fn, res) => function __init() {
|
|
7
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
-
};
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// src/crucible/fulhash/types.ts
|
|
15
|
-
var Algorithm;
|
|
16
|
-
var init_types = __esm({
|
|
17
|
-
"src/crucible/fulhash/types.ts"() {
|
|
18
|
-
Algorithm = /* @__PURE__ */ ((Algorithm2) => {
|
|
19
|
-
Algorithm2["XXH3_128"] = "xxh3-128";
|
|
20
|
-
Algorithm2["SHA256"] = "sha256";
|
|
21
|
-
Algorithm2["CRC32"] = "crc32";
|
|
22
|
-
Algorithm2["CRC32C"] = "crc32c";
|
|
23
|
-
return Algorithm2;
|
|
24
|
-
})(Algorithm || {});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
function hexToBytes(hex) {
|
|
28
|
-
const bytes = new Uint8Array(4);
|
|
29
|
-
for (let i = 0; i < 4; i++) {
|
|
30
|
-
bytes[i] = Number.parseInt(hex.substr(i * 2, 2), 16);
|
|
31
|
-
}
|
|
32
|
-
return bytes;
|
|
33
|
-
}
|
|
34
|
-
async function hashBytes(data) {
|
|
35
|
-
const hex = await crc32(data);
|
|
36
|
-
return hexToBytes(hex);
|
|
37
|
-
}
|
|
38
|
-
async function hashString(str, encoding = "utf8") {
|
|
39
|
-
if (encoding !== "utf8") {
|
|
40
|
-
const buf = Buffer.from(str, encoding);
|
|
41
|
-
const hex2 = await crc32(buf);
|
|
42
|
-
return hexToBytes(hex2);
|
|
43
|
-
}
|
|
44
|
-
const hex = await crc32(str);
|
|
45
|
-
return hexToBytes(hex);
|
|
46
|
-
}
|
|
47
|
-
var init_crc32 = __esm({
|
|
48
|
-
"src/fulhash/algorithms/crc32.ts"() {
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
function hexToBytes2(hex) {
|
|
52
|
-
const bytes = new Uint8Array(4);
|
|
53
|
-
for (let i = 0; i < 4; i++) {
|
|
54
|
-
bytes[i] = Number.parseInt(hex.substr(i * 2, 2), 16);
|
|
55
|
-
}
|
|
56
|
-
return bytes;
|
|
57
|
-
}
|
|
58
|
-
async function hashBytes2(data) {
|
|
59
|
-
const hex = await crc32(data, CRC32C_POLYNOMIAL);
|
|
60
|
-
return hexToBytes2(hex);
|
|
61
|
-
}
|
|
62
|
-
async function hashString2(str, encoding = "utf8") {
|
|
63
|
-
if (encoding !== "utf8") {
|
|
64
|
-
const buf = Buffer.from(str, encoding);
|
|
65
|
-
const hex2 = await crc32(buf, CRC32C_POLYNOMIAL);
|
|
66
|
-
return hexToBytes2(hex2);
|
|
67
|
-
}
|
|
68
|
-
const hex = await crc32(str, CRC32C_POLYNOMIAL);
|
|
69
|
-
return hexToBytes2(hex);
|
|
70
|
-
}
|
|
71
|
-
var CRC32C_POLYNOMIAL;
|
|
72
|
-
var init_crc32c = __esm({
|
|
73
|
-
"src/fulhash/algorithms/crc32c.ts"() {
|
|
74
|
-
CRC32C_POLYNOMIAL = 2197175160;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
function hashBytes3(data) {
|
|
78
|
-
const hash2 = createHash("sha256");
|
|
79
|
-
hash2.update(data);
|
|
80
|
-
return new Uint8Array(hash2.digest());
|
|
81
|
-
}
|
|
82
|
-
function hashString3(str, encoding = "utf8") {
|
|
83
|
-
const hash2 = createHash("sha256");
|
|
84
|
-
hash2.update(str, encoding);
|
|
85
|
-
return new Uint8Array(hash2.digest());
|
|
86
|
-
}
|
|
87
|
-
var init_sha256 = __esm({
|
|
88
|
-
"src/fulhash/algorithms/sha256.ts"() {
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// src/fulhash/errors.ts
|
|
93
|
-
var FulHashError, UnsupportedAlgorithmError, InvalidChecksumError, InvalidChecksumFormatError;
|
|
94
|
-
var init_errors = __esm({
|
|
95
|
-
"src/fulhash/errors.ts"() {
|
|
96
|
-
FulHashError = class _FulHashError extends Error {
|
|
97
|
-
constructor(message) {
|
|
98
|
-
super(message);
|
|
99
|
-
this.name = "FulHashError";
|
|
100
|
-
Object.setPrototypeOf(this, _FulHashError.prototype);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
UnsupportedAlgorithmError = class _UnsupportedAlgorithmError extends FulHashError {
|
|
104
|
-
constructor(algorithm, supportedAlgorithms) {
|
|
105
|
-
super(
|
|
106
|
-
`Unsupported algorithm "${algorithm}". Supported algorithms: ${supportedAlgorithms.join(", ")}`
|
|
107
|
-
);
|
|
108
|
-
this.name = "UnsupportedAlgorithmError";
|
|
109
|
-
Object.setPrototypeOf(this, _UnsupportedAlgorithmError.prototype);
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
InvalidChecksumError = class _InvalidChecksumError extends FulHashError {
|
|
113
|
-
constructor(checksum, reason) {
|
|
114
|
-
super(`Invalid checksum "${checksum}": ${reason}. Expected format: algorithm:hex`);
|
|
115
|
-
this.name = "InvalidChecksumError";
|
|
116
|
-
Object.setPrototypeOf(this, _InvalidChecksumError.prototype);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
InvalidChecksumFormatError = class _InvalidChecksumFormatError extends InvalidChecksumError {
|
|
120
|
-
constructor(checksum, reason) {
|
|
121
|
-
super(checksum, reason);
|
|
122
|
-
this.name = "InvalidChecksumFormatError";
|
|
123
|
-
Object.setPrototypeOf(this, _InvalidChecksumFormatError.prototype);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
function hexToBytes3(hex) {
|
|
129
|
-
const bytes = new Uint8Array(16);
|
|
130
|
-
for (let i = 0; i < 16; i++) {
|
|
131
|
-
bytes[i] = Number.parseInt(hex.substr(i * 2, 2), 16);
|
|
132
|
-
}
|
|
133
|
-
return bytes;
|
|
134
|
-
}
|
|
135
|
-
async function hashBytes4(data) {
|
|
136
|
-
const hex = await xxhash128(data);
|
|
137
|
-
return hexToBytes3(hex);
|
|
138
|
-
}
|
|
139
|
-
async function hashString4(str, encoding = "utf8") {
|
|
140
|
-
if (encoding !== "utf8") {
|
|
141
|
-
throw new FulHashError(
|
|
142
|
-
"XXH3-128 only supports UTF-8 encoding. Use utf8 encoding or convert data to Uint8Array."
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
const hex = await xxhash128(str);
|
|
146
|
-
return hexToBytes3(hex);
|
|
147
|
-
}
|
|
148
|
-
var init_xxh3 = __esm({
|
|
149
|
-
"src/fulhash/algorithms/xxh3.ts"() {
|
|
150
|
-
init_errors();
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// src/fulhash/digest.ts
|
|
155
|
-
var Digest;
|
|
156
|
-
var init_digest = __esm({
|
|
157
|
-
"src/fulhash/digest.ts"() {
|
|
158
|
-
init_types();
|
|
159
|
-
init_errors();
|
|
160
|
-
Digest = class _Digest {
|
|
161
|
-
algorithm;
|
|
162
|
-
_bytes;
|
|
163
|
-
hex;
|
|
164
|
-
formatted;
|
|
165
|
-
constructor(algorithm, bytes) {
|
|
166
|
-
this.algorithm = algorithm;
|
|
167
|
-
this._bytes = new Uint8Array(bytes);
|
|
168
|
-
this.hex = Array.from(this._bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
169
|
-
this.formatted = `${this.algorithm}:${this.hex}`;
|
|
170
|
-
Object.freeze(this);
|
|
171
|
-
}
|
|
172
|
-
get bytes() {
|
|
173
|
-
return Array.from(this._bytes);
|
|
174
|
-
}
|
|
175
|
-
toJSON() {
|
|
176
|
-
return {
|
|
177
|
-
algorithm: this.algorithm,
|
|
178
|
-
hex: this.hex,
|
|
179
|
-
formatted: this.formatted
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
toString() {
|
|
183
|
-
return this.formatted;
|
|
184
|
-
}
|
|
185
|
-
static parse(formatted) {
|
|
186
|
-
if (!formatted.includes(":")) {
|
|
187
|
-
throw new InvalidChecksumFormatError(formatted, "missing separator");
|
|
188
|
-
}
|
|
189
|
-
const [algorithmStr, hex] = formatted.split(":", 2);
|
|
190
|
-
if (!algorithmStr || !hex) {
|
|
191
|
-
throw new InvalidChecksumFormatError(formatted, "invalid format");
|
|
192
|
-
}
|
|
193
|
-
const algorithm = algorithmStr;
|
|
194
|
-
if (!Object.values(Algorithm).includes(algorithm)) {
|
|
195
|
-
throw new UnsupportedAlgorithmError(algorithm, Object.values(Algorithm));
|
|
196
|
-
}
|
|
197
|
-
if (!/^[0-9a-f]+$/.test(hex)) {
|
|
198
|
-
throw new InvalidChecksumError(
|
|
199
|
-
formatted,
|
|
200
|
-
"hex must contain only lowercase hexadecimal characters"
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
let expectedLength;
|
|
204
|
-
switch (algorithm) {
|
|
205
|
-
case "xxh3-128" /* XXH3_128 */:
|
|
206
|
-
expectedLength = 32;
|
|
207
|
-
break;
|
|
208
|
-
case "sha256" /* SHA256 */:
|
|
209
|
-
expectedLength = 64;
|
|
210
|
-
break;
|
|
211
|
-
case "crc32" /* CRC32 */:
|
|
212
|
-
case "crc32c" /* CRC32C */:
|
|
213
|
-
expectedLength = 8;
|
|
214
|
-
break;
|
|
215
|
-
default:
|
|
216
|
-
throw new UnsupportedAlgorithmError(algorithm, Object.values(Algorithm));
|
|
217
|
-
}
|
|
218
|
-
if (hex.length !== expectedLength) {
|
|
219
|
-
throw new InvalidChecksumError(
|
|
220
|
-
formatted,
|
|
221
|
-
`invalid hex length for ${algorithm}: expected ${expectedLength}, got ${hex.length}`
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
const bytes = new Uint8Array(hex.length / 2);
|
|
225
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
226
|
-
bytes[i / 2] = Number.parseInt(hex.slice(i, i + 2), 16);
|
|
227
|
-
}
|
|
228
|
-
return new _Digest(algorithm, bytes);
|
|
229
|
-
}
|
|
230
|
-
equals(other) {
|
|
231
|
-
if (this.algorithm !== other.algorithm) {
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
if (this.hex !== other.hex) {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
static async verify(data, checksum) {
|
|
240
|
-
const expected = _Digest.parse(checksum);
|
|
241
|
-
const { hash: hash2 } = await Promise.resolve().then(() => (init_hash(), hash_exports));
|
|
242
|
-
const actual = await hash2(data, { algorithm: expected.algorithm });
|
|
243
|
-
return actual.equals(expected);
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
// src/fulhash/hash.ts
|
|
250
|
-
var hash_exports = {};
|
|
251
|
-
__export(hash_exports, {
|
|
252
|
-
hash: () => hash,
|
|
253
|
-
hashBytes: () => hashBytes5,
|
|
254
|
-
hashString: () => hashString5
|
|
255
|
-
});
|
|
256
|
-
async function hash(input, options) {
|
|
257
|
-
const algorithm = options?.algorithm ?? "xxh3-128" /* XXH3_128 */;
|
|
258
|
-
const encoding = options?.encoding ?? "utf8";
|
|
259
|
-
let bytes;
|
|
260
|
-
switch (algorithm) {
|
|
261
|
-
case "sha256" /* SHA256 */:
|
|
262
|
-
if (typeof input === "string") {
|
|
263
|
-
bytes = hashString3(input, encoding);
|
|
264
|
-
} else {
|
|
265
|
-
bytes = hashBytes3(input);
|
|
266
|
-
}
|
|
267
|
-
break;
|
|
268
|
-
case "xxh3-128" /* XXH3_128 */:
|
|
269
|
-
if (typeof input === "string") {
|
|
270
|
-
if (encoding !== "utf8") {
|
|
271
|
-
bytes = await hashBytes4(Buffer.from(input, encoding));
|
|
272
|
-
} else {
|
|
273
|
-
bytes = await hashString4(input, "utf8");
|
|
274
|
-
}
|
|
275
|
-
} else {
|
|
276
|
-
bytes = await hashBytes4(input);
|
|
277
|
-
}
|
|
278
|
-
break;
|
|
279
|
-
case "crc32" /* CRC32 */:
|
|
280
|
-
if (typeof input === "string") {
|
|
281
|
-
bytes = await hashString(input, encoding);
|
|
282
|
-
} else {
|
|
283
|
-
bytes = await hashBytes(input);
|
|
284
|
-
}
|
|
285
|
-
break;
|
|
286
|
-
case "crc32c" /* CRC32C */:
|
|
287
|
-
if (typeof input === "string") {
|
|
288
|
-
bytes = await hashString2(input, encoding);
|
|
289
|
-
} else {
|
|
290
|
-
bytes = await hashBytes2(input);
|
|
291
|
-
}
|
|
292
|
-
break;
|
|
293
|
-
default:
|
|
294
|
-
throw new UnsupportedAlgorithmError(algorithm, Object.values(Algorithm));
|
|
295
|
-
}
|
|
296
|
-
return new Digest(algorithm, bytes);
|
|
297
|
-
}
|
|
298
|
-
async function hashString5(str, options) {
|
|
299
|
-
return hash(str, options);
|
|
300
|
-
}
|
|
301
|
-
async function hashBytes5(data, options) {
|
|
302
|
-
return hash(data, options);
|
|
303
|
-
}
|
|
304
|
-
var init_hash = __esm({
|
|
305
|
-
"src/fulhash/hash.ts"() {
|
|
306
|
-
init_types();
|
|
307
|
-
init_crc32();
|
|
308
|
-
init_crc32c();
|
|
309
|
-
init_sha256();
|
|
310
|
-
init_xxh3();
|
|
311
|
-
init_digest();
|
|
312
|
-
init_errors();
|
|
313
|
-
}
|
|
314
|
-
});
|
|
1
|
+
import { hashBytes } from '../chunk-OHE2AOH4.js';
|
|
2
|
+
import '../chunk-UP2VWCW5.js';
|
|
315
3
|
|
|
316
4
|
// src/fulencode/errors.ts
|
|
317
5
|
var FulencodeError = class extends Error {
|
|
@@ -350,10 +38,6 @@ var EncodingFormat = {
|
|
|
350
38
|
ASCII: "ascii"
|
|
351
39
|
};
|
|
352
40
|
|
|
353
|
-
// src/fulencode/fulencode.ts
|
|
354
|
-
init_types();
|
|
355
|
-
init_hash();
|
|
356
|
-
|
|
357
41
|
// src/fulencode/base32.ts
|
|
358
42
|
var RFC4648_BASE32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
359
43
|
var RFC4648_BASE32HEX_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
|
|
@@ -497,7 +181,7 @@ async function computeChecksumIfRequested(data, algorithm) {
|
|
|
497
181
|
details: { algorithm }
|
|
498
182
|
});
|
|
499
183
|
}
|
|
500
|
-
const digest = await
|
|
184
|
+
const digest = await hashBytes(data, {
|
|
501
185
|
algorithm: algorithm === "sha256" ? "sha256" /* SHA256 */ : "xxh3-128" /* XXH3_128 */
|
|
502
186
|
});
|
|
503
187
|
return { checksum: digest.toString(), checksumAlgorithm: algorithm };
|