@samesake/core 1.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 +9 -0
- package/dist/chunk-6F4PWJZI.js +0 -0
- package/dist/index.cjs +243 -0
- package/dist/index.d.cts +153 -0
- package/dist/index.d.ts +153 -0
- package/dist/index.js +206 -0
- package/dist/schemas.cjs +80 -0
- package/dist/schemas.d.cts +77 -0
- package/dist/schemas.d.ts +77 -0
- package/dist/schemas.js +50 -0
- package/dist/types.cjs +18 -0
- package/dist/types.d.cts +316 -0
- package/dist/types.d.ts +316 -0
- package/dist/types.js +1 -0
- package/package.json +68 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import "./chunk-6F4PWJZI.js";
|
|
2
|
+
|
|
3
|
+
// src/ident.ts
|
|
4
|
+
var IDENT_RE = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
5
|
+
var IDENT_MAX = 63;
|
|
6
|
+
var IdentError = class extends Error {
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "IdentError";
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
function assertIdent(name, kind) {
|
|
13
|
+
if (name.length > IDENT_MAX) {
|
|
14
|
+
throw new IdentError(
|
|
15
|
+
`${kind} name "${name}" exceeds max length ${IDENT_MAX}`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
if (!IDENT_RE.test(name)) {
|
|
19
|
+
throw new IdentError(
|
|
20
|
+
`${kind} name "${name}" is invalid: use letters, digits, underscores; must start with a letter (no hyphens)`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function assertNoIdentCollisions(names, kind) {
|
|
25
|
+
const seen = /* @__PURE__ */ new Map();
|
|
26
|
+
for (const name of names) {
|
|
27
|
+
const key = name.toLowerCase();
|
|
28
|
+
const prev = seen.get(key);
|
|
29
|
+
if (prev && prev !== name) {
|
|
30
|
+
throw new IdentError(
|
|
31
|
+
`${kind} names "${prev}" and "${name}" collide (case-insensitive)`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
seen.set(key, name);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/index.ts
|
|
39
|
+
var fields = {
|
|
40
|
+
text(opts = {}) {
|
|
41
|
+
return { type: "text", ...opts };
|
|
42
|
+
},
|
|
43
|
+
number(opts = {}) {
|
|
44
|
+
return { type: "number", ...opts };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var Scorers = {
|
|
48
|
+
cosine(opts) {
|
|
49
|
+
return { kind: "cosine", ...opts };
|
|
50
|
+
},
|
|
51
|
+
trigram(opts) {
|
|
52
|
+
return { kind: "trigram", ...opts };
|
|
53
|
+
},
|
|
54
|
+
phoneticEq(opts) {
|
|
55
|
+
return { kind: "phoneticEq", ...opts };
|
|
56
|
+
},
|
|
57
|
+
phoneExact(opts) {
|
|
58
|
+
return { kind: "phoneExact", ...opts };
|
|
59
|
+
},
|
|
60
|
+
aliasHit(opts) {
|
|
61
|
+
return { kind: "aliasHit", ...opts };
|
|
62
|
+
},
|
|
63
|
+
internalCodeExact(opts) {
|
|
64
|
+
return { kind: "internalCodeExact", ...opts };
|
|
65
|
+
},
|
|
66
|
+
sizeUnitGate(opts) {
|
|
67
|
+
return { kind: "sizeUnitGate", ...opts };
|
|
68
|
+
},
|
|
69
|
+
brandGate(opts) {
|
|
70
|
+
return { kind: "brandGate", ...opts };
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
function entity(name, def) {
|
|
74
|
+
assertIdent(name, "entity");
|
|
75
|
+
for (const s2 of def.scopes ?? []) assertIdent(s2, "scope");
|
|
76
|
+
assertNoIdentCollisions(Object.keys(def.fields ?? {}), "field");
|
|
77
|
+
return { ...def, name };
|
|
78
|
+
}
|
|
79
|
+
var f = {
|
|
80
|
+
text(opts = {}) {
|
|
81
|
+
return { type: "text", ...opts };
|
|
82
|
+
},
|
|
83
|
+
number(opts = {}) {
|
|
84
|
+
return { type: "number", ...opts };
|
|
85
|
+
},
|
|
86
|
+
boolean(opts = {}) {
|
|
87
|
+
return { type: "boolean", ...opts };
|
|
88
|
+
},
|
|
89
|
+
enum(values, opts = {}) {
|
|
90
|
+
return { type: "enum", values, ...opts };
|
|
91
|
+
},
|
|
92
|
+
array(item, opts = {}) {
|
|
93
|
+
if (item.type === "enum") {
|
|
94
|
+
return { type: "array", itemType: "enum", values: item.values, ...opts };
|
|
95
|
+
}
|
|
96
|
+
return { type: "array", itemType: "text", ...opts };
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
var Channels = {
|
|
100
|
+
fts(opts) {
|
|
101
|
+
return { kind: "fts", ...opts };
|
|
102
|
+
},
|
|
103
|
+
cosine(opts) {
|
|
104
|
+
return { kind: "cosine", ...opts };
|
|
105
|
+
},
|
|
106
|
+
recency(opts) {
|
|
107
|
+
return { kind: "recency", ...opts };
|
|
108
|
+
},
|
|
109
|
+
spaces(opts) {
|
|
110
|
+
return { kind: "spaces", ...opts };
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var PGVECTOR_HNSW_MAX_DIMS = 2e3;
|
|
114
|
+
function spaceDim(def) {
|
|
115
|
+
return def.kind === "text" || def.kind === "image" ? def.dim : def.dims;
|
|
116
|
+
}
|
|
117
|
+
function validateSpaceDims(spaces) {
|
|
118
|
+
let total = 0;
|
|
119
|
+
for (const def of Object.values(spaces)) {
|
|
120
|
+
total += spaceDim(def);
|
|
121
|
+
}
|
|
122
|
+
if (total > PGVECTOR_HNSW_MAX_DIMS) {
|
|
123
|
+
throw new Error(
|
|
124
|
+
`spaces total dimension ${total} exceeds pgvector HNSW limit of ${PGVECTOR_HNSW_MAX_DIMS} for vector columns. Reduce space dims or split spaces across collections. Future escape hatch: halfvec (up to 4000 dims).`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
var s = {
|
|
129
|
+
text(opts) {
|
|
130
|
+
return { kind: "text", ...opts };
|
|
131
|
+
},
|
|
132
|
+
image(opts) {
|
|
133
|
+
return { kind: "image", ...opts };
|
|
134
|
+
},
|
|
135
|
+
number(opts) {
|
|
136
|
+
return { kind: "number", ...opts };
|
|
137
|
+
},
|
|
138
|
+
recency(opts) {
|
|
139
|
+
return { kind: "recency", ...opts };
|
|
140
|
+
},
|
|
141
|
+
categorical(opts) {
|
|
142
|
+
return { kind: "categorical", ...opts };
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
function collection(name, def) {
|
|
146
|
+
assertIdent(name, "collection");
|
|
147
|
+
assertNoIdentCollisions(Object.keys(def.fields ?? {}), "field");
|
|
148
|
+
if (def.spaces) assertNoIdentCollisions(Object.keys(def.spaces), "space");
|
|
149
|
+
if (def.embeddings) assertNoIdentCollisions(Object.keys(def.embeddings), "embedding");
|
|
150
|
+
if (def.spaces && Object.keys(def.spaces).length > 0) {
|
|
151
|
+
validateSpaceDims(def.spaces);
|
|
152
|
+
}
|
|
153
|
+
return { ...def, name };
|
|
154
|
+
}
|
|
155
|
+
function stage(name, def) {
|
|
156
|
+
return { name, ...def };
|
|
157
|
+
}
|
|
158
|
+
function pipeline(...stages) {
|
|
159
|
+
return { stages };
|
|
160
|
+
}
|
|
161
|
+
var sources = {
|
|
162
|
+
shopifyFeed(opts) {
|
|
163
|
+
return {
|
|
164
|
+
name: opts.name ?? `shopify:${opts.domain}`,
|
|
165
|
+
kind: "shopify",
|
|
166
|
+
options: {
|
|
167
|
+
domain: opts.domain,
|
|
168
|
+
currency: opts.currency ?? "LKR",
|
|
169
|
+
maxPages: opts.maxPages ?? 8
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
wooStoreFeed(opts) {
|
|
174
|
+
return {
|
|
175
|
+
name: opts.name ?? `woo:${opts.domain}`,
|
|
176
|
+
kind: "woocommerce",
|
|
177
|
+
options: {
|
|
178
|
+
domain: opts.domain,
|
|
179
|
+
currency: opts.currency ?? "LKR",
|
|
180
|
+
maxPages: opts.maxPages ?? 8
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
},
|
|
184
|
+
jsonl(opts) {
|
|
185
|
+
return {
|
|
186
|
+
name: opts.name ?? `jsonl:${opts.path}`,
|
|
187
|
+
kind: "jsonl",
|
|
188
|
+
options: { path: opts.path }
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
export {
|
|
193
|
+
Channels,
|
|
194
|
+
IdentError,
|
|
195
|
+
Scorers,
|
|
196
|
+
assertIdent,
|
|
197
|
+
assertNoIdentCollisions,
|
|
198
|
+
collection,
|
|
199
|
+
entity,
|
|
200
|
+
f,
|
|
201
|
+
fields,
|
|
202
|
+
pipeline,
|
|
203
|
+
s,
|
|
204
|
+
sources,
|
|
205
|
+
stage
|
|
206
|
+
};
|
package/dist/schemas.cjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/schemas.ts
|
|
21
|
+
var schemas_exports = {};
|
|
22
|
+
__export(schemas_exports, {
|
|
23
|
+
CalibrateResultSchema: () => CalibrateResultSchema,
|
|
24
|
+
CalibrationCurvePointSchema: () => CalibrationCurvePointSchema,
|
|
25
|
+
MatchCandidateSchema: () => MatchCandidateSchema,
|
|
26
|
+
MatchComponentsSchema: () => MatchComponentsSchema,
|
|
27
|
+
MatchResultSchema: () => MatchResultSchema,
|
|
28
|
+
ResolvedMatchSchema: () => ResolvedMatchSchema
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(schemas_exports);
|
|
31
|
+
var import_zod = require("zod");
|
|
32
|
+
var MatchComponentsSchema = import_zod.z.object({
|
|
33
|
+
cosSim: import_zod.z.number().nullable(),
|
|
34
|
+
trgmSim: import_zod.z.number(),
|
|
35
|
+
phonEq: import_zod.z.boolean(),
|
|
36
|
+
phoneEq: import_zod.z.boolean(),
|
|
37
|
+
aliasHit: import_zod.z.boolean()
|
|
38
|
+
});
|
|
39
|
+
var MatchCandidateSchema = import_zod.z.object({
|
|
40
|
+
entityId: import_zod.z.string(),
|
|
41
|
+
name: import_zod.z.string(),
|
|
42
|
+
combined: import_zod.z.number(),
|
|
43
|
+
rrfScore: import_zod.z.number(),
|
|
44
|
+
components: MatchComponentsSchema
|
|
45
|
+
});
|
|
46
|
+
var ResolvedMatchSchema = import_zod.z.object({
|
|
47
|
+
entityId: import_zod.z.string(),
|
|
48
|
+
confidence: import_zod.z.number(),
|
|
49
|
+
source: import_zod.z.literal("autolink")
|
|
50
|
+
});
|
|
51
|
+
var MatchResultSchema = import_zod.z.object({
|
|
52
|
+
candidates: import_zod.z.array(MatchCandidateSchema),
|
|
53
|
+
queryTextNormalised: import_zod.z.string(),
|
|
54
|
+
resolved: ResolvedMatchSchema.optional()
|
|
55
|
+
});
|
|
56
|
+
var CalibrationCurvePointSchema = import_zod.z.object({
|
|
57
|
+
threshold: import_zod.z.number(),
|
|
58
|
+
f1: import_zod.z.number(),
|
|
59
|
+
precision: import_zod.z.number(),
|
|
60
|
+
recall: import_zod.z.number()
|
|
61
|
+
});
|
|
62
|
+
var CalibrateResultSchema = import_zod.z.object({
|
|
63
|
+
threshold: import_zod.z.number(),
|
|
64
|
+
f1: import_zod.z.number(),
|
|
65
|
+
precision: import_zod.z.number(),
|
|
66
|
+
recall: import_zod.z.number(),
|
|
67
|
+
sampleSize: import_zod.z.number().int(),
|
|
68
|
+
positives: import_zod.z.number().int(),
|
|
69
|
+
negatives: import_zod.z.number().int(),
|
|
70
|
+
curve: import_zod.z.array(CalibrationCurvePointSchema)
|
|
71
|
+
});
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
CalibrateResultSchema,
|
|
75
|
+
CalibrationCurvePointSchema,
|
|
76
|
+
MatchCandidateSchema,
|
|
77
|
+
MatchComponentsSchema,
|
|
78
|
+
MatchResultSchema,
|
|
79
|
+
ResolvedMatchSchema
|
|
80
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const MatchComponentsSchema: z.ZodObject<{
|
|
4
|
+
cosSim: z.ZodNullable<z.ZodNumber>;
|
|
5
|
+
trgmSim: z.ZodNumber;
|
|
6
|
+
phonEq: z.ZodBoolean;
|
|
7
|
+
phoneEq: z.ZodBoolean;
|
|
8
|
+
aliasHit: z.ZodBoolean;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
type MatchComponents = z.infer<typeof MatchComponentsSchema>;
|
|
11
|
+
declare const MatchCandidateSchema: z.ZodObject<{
|
|
12
|
+
entityId: z.ZodString;
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
combined: z.ZodNumber;
|
|
15
|
+
rrfScore: z.ZodNumber;
|
|
16
|
+
components: z.ZodObject<{
|
|
17
|
+
cosSim: z.ZodNullable<z.ZodNumber>;
|
|
18
|
+
trgmSim: z.ZodNumber;
|
|
19
|
+
phonEq: z.ZodBoolean;
|
|
20
|
+
phoneEq: z.ZodBoolean;
|
|
21
|
+
aliasHit: z.ZodBoolean;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
type MatchCandidate = z.infer<typeof MatchCandidateSchema>;
|
|
25
|
+
declare const ResolvedMatchSchema: z.ZodObject<{
|
|
26
|
+
entityId: z.ZodString;
|
|
27
|
+
confidence: z.ZodNumber;
|
|
28
|
+
source: z.ZodLiteral<"autolink">;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
type ResolvedMatch = z.infer<typeof ResolvedMatchSchema>;
|
|
31
|
+
declare const MatchResultSchema: z.ZodObject<{
|
|
32
|
+
candidates: z.ZodArray<z.ZodObject<{
|
|
33
|
+
entityId: z.ZodString;
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
combined: z.ZodNumber;
|
|
36
|
+
rrfScore: z.ZodNumber;
|
|
37
|
+
components: z.ZodObject<{
|
|
38
|
+
cosSim: z.ZodNullable<z.ZodNumber>;
|
|
39
|
+
trgmSim: z.ZodNumber;
|
|
40
|
+
phonEq: z.ZodBoolean;
|
|
41
|
+
phoneEq: z.ZodBoolean;
|
|
42
|
+
aliasHit: z.ZodBoolean;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
queryTextNormalised: z.ZodString;
|
|
46
|
+
resolved: z.ZodOptional<z.ZodObject<{
|
|
47
|
+
entityId: z.ZodString;
|
|
48
|
+
confidence: z.ZodNumber;
|
|
49
|
+
source: z.ZodLiteral<"autolink">;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
type MatchResult = z.infer<typeof MatchResultSchema>;
|
|
53
|
+
declare const CalibrationCurvePointSchema: z.ZodObject<{
|
|
54
|
+
threshold: z.ZodNumber;
|
|
55
|
+
f1: z.ZodNumber;
|
|
56
|
+
precision: z.ZodNumber;
|
|
57
|
+
recall: z.ZodNumber;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
type CalibrationCurvePoint = z.infer<typeof CalibrationCurvePointSchema>;
|
|
60
|
+
declare const CalibrateResultSchema: z.ZodObject<{
|
|
61
|
+
threshold: z.ZodNumber;
|
|
62
|
+
f1: z.ZodNumber;
|
|
63
|
+
precision: z.ZodNumber;
|
|
64
|
+
recall: z.ZodNumber;
|
|
65
|
+
sampleSize: z.ZodNumber;
|
|
66
|
+
positives: z.ZodNumber;
|
|
67
|
+
negatives: z.ZodNumber;
|
|
68
|
+
curve: z.ZodArray<z.ZodObject<{
|
|
69
|
+
threshold: z.ZodNumber;
|
|
70
|
+
f1: z.ZodNumber;
|
|
71
|
+
precision: z.ZodNumber;
|
|
72
|
+
recall: z.ZodNumber;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
type CalibrateResult = z.infer<typeof CalibrateResultSchema>;
|
|
76
|
+
|
|
77
|
+
export { type CalibrateResult, CalibrateResultSchema, type CalibrationCurvePoint, CalibrationCurvePointSchema, type MatchCandidate, MatchCandidateSchema, type MatchComponents, MatchComponentsSchema, type MatchResult, MatchResultSchema, type ResolvedMatch, ResolvedMatchSchema };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const MatchComponentsSchema: z.ZodObject<{
|
|
4
|
+
cosSim: z.ZodNullable<z.ZodNumber>;
|
|
5
|
+
trgmSim: z.ZodNumber;
|
|
6
|
+
phonEq: z.ZodBoolean;
|
|
7
|
+
phoneEq: z.ZodBoolean;
|
|
8
|
+
aliasHit: z.ZodBoolean;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
type MatchComponents = z.infer<typeof MatchComponentsSchema>;
|
|
11
|
+
declare const MatchCandidateSchema: z.ZodObject<{
|
|
12
|
+
entityId: z.ZodString;
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
combined: z.ZodNumber;
|
|
15
|
+
rrfScore: z.ZodNumber;
|
|
16
|
+
components: z.ZodObject<{
|
|
17
|
+
cosSim: z.ZodNullable<z.ZodNumber>;
|
|
18
|
+
trgmSim: z.ZodNumber;
|
|
19
|
+
phonEq: z.ZodBoolean;
|
|
20
|
+
phoneEq: z.ZodBoolean;
|
|
21
|
+
aliasHit: z.ZodBoolean;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
type MatchCandidate = z.infer<typeof MatchCandidateSchema>;
|
|
25
|
+
declare const ResolvedMatchSchema: z.ZodObject<{
|
|
26
|
+
entityId: z.ZodString;
|
|
27
|
+
confidence: z.ZodNumber;
|
|
28
|
+
source: z.ZodLiteral<"autolink">;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
type ResolvedMatch = z.infer<typeof ResolvedMatchSchema>;
|
|
31
|
+
declare const MatchResultSchema: z.ZodObject<{
|
|
32
|
+
candidates: z.ZodArray<z.ZodObject<{
|
|
33
|
+
entityId: z.ZodString;
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
combined: z.ZodNumber;
|
|
36
|
+
rrfScore: z.ZodNumber;
|
|
37
|
+
components: z.ZodObject<{
|
|
38
|
+
cosSim: z.ZodNullable<z.ZodNumber>;
|
|
39
|
+
trgmSim: z.ZodNumber;
|
|
40
|
+
phonEq: z.ZodBoolean;
|
|
41
|
+
phoneEq: z.ZodBoolean;
|
|
42
|
+
aliasHit: z.ZodBoolean;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
queryTextNormalised: z.ZodString;
|
|
46
|
+
resolved: z.ZodOptional<z.ZodObject<{
|
|
47
|
+
entityId: z.ZodString;
|
|
48
|
+
confidence: z.ZodNumber;
|
|
49
|
+
source: z.ZodLiteral<"autolink">;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
type MatchResult = z.infer<typeof MatchResultSchema>;
|
|
53
|
+
declare const CalibrationCurvePointSchema: z.ZodObject<{
|
|
54
|
+
threshold: z.ZodNumber;
|
|
55
|
+
f1: z.ZodNumber;
|
|
56
|
+
precision: z.ZodNumber;
|
|
57
|
+
recall: z.ZodNumber;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
type CalibrationCurvePoint = z.infer<typeof CalibrationCurvePointSchema>;
|
|
60
|
+
declare const CalibrateResultSchema: z.ZodObject<{
|
|
61
|
+
threshold: z.ZodNumber;
|
|
62
|
+
f1: z.ZodNumber;
|
|
63
|
+
precision: z.ZodNumber;
|
|
64
|
+
recall: z.ZodNumber;
|
|
65
|
+
sampleSize: z.ZodNumber;
|
|
66
|
+
positives: z.ZodNumber;
|
|
67
|
+
negatives: z.ZodNumber;
|
|
68
|
+
curve: z.ZodArray<z.ZodObject<{
|
|
69
|
+
threshold: z.ZodNumber;
|
|
70
|
+
f1: z.ZodNumber;
|
|
71
|
+
precision: z.ZodNumber;
|
|
72
|
+
recall: z.ZodNumber;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
type CalibrateResult = z.infer<typeof CalibrateResultSchema>;
|
|
76
|
+
|
|
77
|
+
export { type CalibrateResult, CalibrateResultSchema, type CalibrationCurvePoint, CalibrationCurvePointSchema, type MatchCandidate, MatchCandidateSchema, type MatchComponents, MatchComponentsSchema, type MatchResult, MatchResultSchema, type ResolvedMatch, ResolvedMatchSchema };
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// src/schemas.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var MatchComponentsSchema = z.object({
|
|
4
|
+
cosSim: z.number().nullable(),
|
|
5
|
+
trgmSim: z.number(),
|
|
6
|
+
phonEq: z.boolean(),
|
|
7
|
+
phoneEq: z.boolean(),
|
|
8
|
+
aliasHit: z.boolean()
|
|
9
|
+
});
|
|
10
|
+
var MatchCandidateSchema = z.object({
|
|
11
|
+
entityId: z.string(),
|
|
12
|
+
name: z.string(),
|
|
13
|
+
combined: z.number(),
|
|
14
|
+
rrfScore: z.number(),
|
|
15
|
+
components: MatchComponentsSchema
|
|
16
|
+
});
|
|
17
|
+
var ResolvedMatchSchema = z.object({
|
|
18
|
+
entityId: z.string(),
|
|
19
|
+
confidence: z.number(),
|
|
20
|
+
source: z.literal("autolink")
|
|
21
|
+
});
|
|
22
|
+
var MatchResultSchema = z.object({
|
|
23
|
+
candidates: z.array(MatchCandidateSchema),
|
|
24
|
+
queryTextNormalised: z.string(),
|
|
25
|
+
resolved: ResolvedMatchSchema.optional()
|
|
26
|
+
});
|
|
27
|
+
var CalibrationCurvePointSchema = z.object({
|
|
28
|
+
threshold: z.number(),
|
|
29
|
+
f1: z.number(),
|
|
30
|
+
precision: z.number(),
|
|
31
|
+
recall: z.number()
|
|
32
|
+
});
|
|
33
|
+
var CalibrateResultSchema = z.object({
|
|
34
|
+
threshold: z.number(),
|
|
35
|
+
f1: z.number(),
|
|
36
|
+
precision: z.number(),
|
|
37
|
+
recall: z.number(),
|
|
38
|
+
sampleSize: z.number().int(),
|
|
39
|
+
positives: z.number().int(),
|
|
40
|
+
negatives: z.number().int(),
|
|
41
|
+
curve: z.array(CalibrationCurvePointSchema)
|
|
42
|
+
});
|
|
43
|
+
export {
|
|
44
|
+
CalibrateResultSchema,
|
|
45
|
+
CalibrationCurvePointSchema,
|
|
46
|
+
MatchCandidateSchema,
|
|
47
|
+
MatchComponentsSchema,
|
|
48
|
+
MatchResultSchema,
|
|
49
|
+
ResolvedMatchSchema
|
|
50
|
+
};
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|