@proposit/shared 0.30.0 → 0.31.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/api-client/argument/batch.d.ts +10 -4
- package/dist/api-client/argument/batch.d.ts.map +1 -1
- package/dist/api-client/argument/index.d.ts +70 -28
- package/dist/api-client/argument/index.d.ts.map +1 -1
- package/dist/api-client/argument/logic/index.d.ts +10 -4
- package/dist/api-client/argument/logic/index.d.ts.map +1 -1
- package/dist/api-client/argument/logic/repair.d.ts +5 -2
- package/dist/api-client/argument/logic/repair.d.ts.map +1 -1
- package/dist/api-client/user/delete-user.d.ts +1 -0
- package/dist/api-client/user/delete-user.d.ts.map +1 -1
- package/dist/fixtures/argument-yaml/digest.d.ts +3 -0
- package/dist/fixtures/argument-yaml/digest.d.ts.map +1 -0
- package/dist/fixtures/argument-yaml/digest.js +40 -0
- package/dist/fixtures/argument-yaml/digest.js.map +1 -0
- package/dist/fixtures/argument-yaml/index.d.ts +6 -0
- package/dist/fixtures/argument-yaml/index.d.ts.map +1 -0
- package/dist/fixtures/argument-yaml/index.js +9 -0
- package/dist/fixtures/argument-yaml/index.js.map +1 -0
- package/dist/fixtures/argument-yaml/lower.d.ts +13 -0
- package/dist/fixtures/argument-yaml/lower.d.ts.map +1 -0
- package/dist/fixtures/argument-yaml/lower.js +141 -0
- package/dist/fixtures/argument-yaml/lower.js.map +1 -0
- package/dist/fixtures/argument-yaml/schema.d.ts +74 -0
- package/dist/fixtures/argument-yaml/schema.d.ts.map +1 -0
- package/dist/fixtures/argument-yaml/schema.js +70 -0
- package/dist/fixtures/argument-yaml/schema.js.map +1 -0
- package/dist/fixtures/argument-yaml/serialize.d.ts +4 -0
- package/dist/fixtures/argument-yaml/serialize.d.ts.map +1 -0
- package/dist/fixtures/argument-yaml/serialize.js +31 -0
- package/dist/fixtures/argument-yaml/serialize.js.map +1 -0
- package/dist/fixtures/argument-yaml/sha256.d.ts +2 -0
- package/dist/fixtures/argument-yaml/sha256.d.ts.map +1 -0
- package/dist/fixtures/argument-yaml/sha256.js +122 -0
- package/dist/fixtures/argument-yaml/sha256.js.map +1 -0
- package/dist/fixtures/curated-argument/index.d.ts +35 -0
- package/dist/fixtures/curated-argument/index.d.ts.map +1 -0
- package/dist/fixtures/curated-argument/index.js +51 -0
- package/dist/fixtures/curated-argument/index.js.map +1 -0
- package/dist/fixtures/historical-figures/content.generated.d.ts +6 -0
- package/dist/fixtures/historical-figures/content.generated.d.ts.map +1 -0
- package/dist/fixtures/historical-figures/content.generated.js +654 -0
- package/dist/fixtures/historical-figures/content.generated.js.map +1 -0
- package/dist/fixtures/historical-figures/index.d.ts +29 -0
- package/dist/fixtures/historical-figures/index.d.ts.map +1 -0
- package/dist/fixtures/historical-figures/index.js +49 -0
- package/dist/fixtures/historical-figures/index.js.map +1 -0
- package/dist/schemas/api/argument/batch/change-edge-operator.d.ts +5 -2
- package/dist/schemas/api/argument/batch/change-edge-operator.d.ts.map +1 -1
- package/dist/schemas/api/argument/batch/create-expression-with-operator.d.ts +5 -2
- package/dist/schemas/api/argument/batch/create-expression-with-operator.d.ts.map +1 -1
- package/dist/schemas/api/argument/index.d.ts +35 -14
- package/dist/schemas/api/argument/index.d.ts.map +1 -1
- package/dist/schemas/api/argument/repair.d.ts +5 -2
- package/dist/schemas/api/argument/repair.d.ts.map +1 -1
- package/dist/schemas/integrations/index.d.ts +9 -0
- package/dist/schemas/integrations/index.d.ts.map +1 -1
- package/dist/schemas/integrations/index.js +27 -0
- package/dist/schemas/integrations/index.js.map +1 -1
- package/dist/schemas/model/arguments.d.ts +10 -4
- package/dist/schemas/model/arguments.d.ts.map +1 -1
- package/dist/schemas/model/arguments.js +3 -3
- package/dist/schemas/model/arguments.js.map +1 -1
- package/dist/schemas/model/users.d.ts +1 -0
- package/dist/schemas/model/users.d.ts.map +1 -1
- package/dist/schemas/model/users.js +4 -0
- package/dist/schemas/model/users.js.map +1 -1
- package/dist/schemas/snapshot.d.ts +5 -2
- package/dist/schemas/snapshot.d.ts.map +1 -1
- package/package.json +21 -3
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Reconstruct the AUTHORED curated argument from the persisted shared-schema
|
|
2
|
+
// pieces of a stored argument. This is the inverse of the server seed recipe's
|
|
3
|
+
// `materializeExprTree` (proposit-server `database/seeds/lib/build-argument.ts`):
|
|
4
|
+
// it walks the flat persisted variables / premises / expressions back into the
|
|
5
|
+
// `{symbol,title,body}` claims and `ExprNode` premise trees a human authored,
|
|
6
|
+
// while dropping everything the engine synthesized.
|
|
7
|
+
//
|
|
8
|
+
// Three classes of synthesized structure are excluded:
|
|
9
|
+
// - Derivation premises — the per-claim hidden premises `addClaim` mints. They
|
|
10
|
+
// carry `type: "derivation"` (vs `"freeform"` for authored premises); we keep
|
|
11
|
+
// only freeform premises.
|
|
12
|
+
// - Premise-bound / auto variables — only CLAIM-bound variables (those that
|
|
13
|
+
// reference a claim) become curated claims; premise-bound variables (which
|
|
14
|
+
// have no `claimId`) are skipped.
|
|
15
|
+
// - Derivation-only claim-bound variables — each claim is persisted with both
|
|
16
|
+
// an authored claim-bound variable AND an engine-synthesized one bound to the
|
|
17
|
+
// same claim but referenced solely by the derivation premise. Only the
|
|
18
|
+
// authored variable becomes a curated claim (see the dedup below).
|
|
19
|
+
// AN-normalization expression nodes (formula buffers, etc.) are NOT stripped:
|
|
20
|
+
// the curated form mirrors the persisted, normalized tree, so reconstructing the
|
|
21
|
+
// stored expression tree verbatim reproduces the authored structure.
|
|
22
|
+
import { isNormalClaim } from "../../schemas/model/claims.js";
|
|
23
|
+
function isClaimBoundVariable(variable) {
|
|
24
|
+
return "claimId" in variable;
|
|
25
|
+
}
|
|
26
|
+
function buildExprNode(expression, childrenByParentId, variablesById) {
|
|
27
|
+
if (expression.type === "variable") {
|
|
28
|
+
const variable = variablesById.get(expression.variableId);
|
|
29
|
+
if (!variable) {
|
|
30
|
+
throw new Error(`Variable expression ${expression.id} references missing variable ${expression.variableId}`);
|
|
31
|
+
}
|
|
32
|
+
return { type: "variable", symbol: variable.symbol };
|
|
33
|
+
}
|
|
34
|
+
const children = (childrenByParentId.get(expression.id) ?? [])
|
|
35
|
+
.slice()
|
|
36
|
+
.sort((left, right) => left.position - right.position)
|
|
37
|
+
.map((child) => buildExprNode(child, childrenByParentId, variablesById));
|
|
38
|
+
if (expression.type === "operator") {
|
|
39
|
+
return { type: "operator", operator: expression.operator, children };
|
|
40
|
+
}
|
|
41
|
+
return { type: "formula", children };
|
|
42
|
+
}
|
|
43
|
+
function buildPremiseTree(premiseId, expressionsByPremiseId, variablesById) {
|
|
44
|
+
const expressions = expressionsByPremiseId.get(premiseId) ?? [];
|
|
45
|
+
const childrenByParentId = new Map();
|
|
46
|
+
let root;
|
|
47
|
+
for (const expression of expressions) {
|
|
48
|
+
if (expression.parentId === null) {
|
|
49
|
+
root = expression;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const siblings = childrenByParentId.get(expression.parentId) ?? [];
|
|
53
|
+
siblings.push(expression);
|
|
54
|
+
childrenByParentId.set(expression.parentId, siblings);
|
|
55
|
+
}
|
|
56
|
+
if (!root) {
|
|
57
|
+
throw new Error(`Premise ${premiseId} has no root expression (parentId === null)`);
|
|
58
|
+
}
|
|
59
|
+
return buildExprNode(root, childrenByParentId, variablesById);
|
|
60
|
+
}
|
|
61
|
+
export function lowerArgumentToCurated(input) {
|
|
62
|
+
const { argument, claims, variables, premises, expressions } = input;
|
|
63
|
+
const claimsById = new Map(claims.map((claim) => [claim.id, claim]));
|
|
64
|
+
const variablesById = new Map(variables.map((variable) => [variable.id, variable]));
|
|
65
|
+
// A persisted claim carries TWO claim-bound variables: the authored one
|
|
66
|
+
// (descriptive symbol, referenced by the freeform premises) and an
|
|
67
|
+
// engine-synthesized one (auto symbol) that lives in the per-claim hidden
|
|
68
|
+
// derivation premise `addClaim` mints. Recover only the authored claims by
|
|
69
|
+
// dropping every claim-bound variable referenced ONLY by derivation-premise
|
|
70
|
+
// expressions — that also drops engine-added axiomatic background claims,
|
|
71
|
+
// whose variable likewise appears solely in a derivation premise. An
|
|
72
|
+
// authored variable that no freeform premise happens to reference (an
|
|
73
|
+
// "orphan" claim) is referenced by neither set and is therefore kept.
|
|
74
|
+
const derivationPremiseIds = new Set(premises
|
|
75
|
+
.filter((premise) => premise.type === "derivation")
|
|
76
|
+
.map((premise) => premise.id));
|
|
77
|
+
const referencedByFreeform = new Set();
|
|
78
|
+
const referencedByDerivation = new Set();
|
|
79
|
+
for (const expression of expressions) {
|
|
80
|
+
if (expression.type !== "variable") {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (derivationPremiseIds.has(expression.premiseId)) {
|
|
84
|
+
referencedByDerivation.add(expression.variableId);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
referencedByFreeform.add(expression.variableId);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// One curated claim per AUTHORED claim-bound variable, in input order.
|
|
91
|
+
const curatedClaims = [];
|
|
92
|
+
for (const variable of variables) {
|
|
93
|
+
if (!isClaimBoundVariable(variable)) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (referencedByDerivation.has(variable.id) &&
|
|
97
|
+
!referencedByFreeform.has(variable.id)) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const claim = claimsById.get(variable.claimId);
|
|
101
|
+
if (!claim) {
|
|
102
|
+
throw new Error(`Claim-bound variable "${variable.symbol}" references missing claim ${variable.claimId}`);
|
|
103
|
+
}
|
|
104
|
+
if (!isNormalClaim(claim)) {
|
|
105
|
+
throw new Error(`Claim-bound variable "${variable.symbol}" references a non-normal claim ${claim.id}; curated arguments only represent normal claims`);
|
|
106
|
+
}
|
|
107
|
+
curatedClaims.push({
|
|
108
|
+
symbol: variable.symbol,
|
|
109
|
+
title: claim.title,
|
|
110
|
+
body: claim.body,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
// Group expressions by their owning premise once.
|
|
114
|
+
const expressionsByPremiseId = new Map();
|
|
115
|
+
for (const expression of expressions) {
|
|
116
|
+
const list = expressionsByPremiseId.get(expression.premiseId) ?? [];
|
|
117
|
+
list.push(expression);
|
|
118
|
+
expressionsByPremiseId.set(expression.premiseId, list);
|
|
119
|
+
}
|
|
120
|
+
// One curated premise per AUTHORED freeform premise, in input order.
|
|
121
|
+
// Derivation premises (`type === "derivation"`) are engine-synthesized and
|
|
122
|
+
// excluded.
|
|
123
|
+
const curatedPremises = [];
|
|
124
|
+
for (const premise of premises) {
|
|
125
|
+
if (premise.type === "derivation") {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
curatedPremises.push({
|
|
129
|
+
title: premise.title ?? null,
|
|
130
|
+
role: premise.role,
|
|
131
|
+
tree: buildPremiseTree(premise.id, expressionsByPremiseId, variablesById),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
title: argument.title,
|
|
136
|
+
description: argument.description ?? "",
|
|
137
|
+
claims: curatedClaims,
|
|
138
|
+
premises: curatedPremises,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=lower.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lower.js","sourceRoot":"","sources":["../../../src/fixtures/argument-yaml/lower.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,+EAA+E;AAC/E,kFAAkF;AAClF,+EAA+E;AAC/E,8EAA8E;AAC9E,oDAAoD;AACpD,EAAE;AACF,uDAAuD;AACvD,iFAAiF;AACjF,kFAAkF;AAClF,8BAA8B;AAC9B,8EAA8E;AAC9E,+EAA+E;AAC/E,sCAAsC;AACtC,gFAAgF;AAChF,kFAAkF;AAClF,2EAA2E;AAC3E,uEAAuE;AACvE,8EAA8E;AAC9E,iFAAiF;AACjF,qEAAqE;AAErE,OAAO,EAAE,aAAa,EAAe,MAAM,+BAA+B,CAAA;AA0B1E,SAAS,oBAAoB,CAC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AE;QACvC,MAAM,EAAE,aAAa;QACrB,QAAQ,EAAE,eAAe;KAC5B,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import Type from "typebox";
|
|
2
|
+
import type { CuratedArgument } from "../curated-argument/index.js";
|
|
3
|
+
import type { HistoricalFigureProvenance } from "../historical-figures/index.js";
|
|
4
|
+
export declare const ExprNodeYamlSchema: Type.TCyclic<{
|
|
5
|
+
ExprNode: Type.TUnion<[Type.TObject<{
|
|
6
|
+
type: Type.TLiteral<"variable">;
|
|
7
|
+
symbol: Type.TString;
|
|
8
|
+
}>, Type.TObject<{
|
|
9
|
+
type: Type.TLiteral<"operator">;
|
|
10
|
+
operator: Type.TUnion<[Type.TLiteral<"and">, Type.TLiteral<"or">, Type.TLiteral<"not">, Type.TLiteral<"implies">, Type.TLiteral<"iff">]>;
|
|
11
|
+
children: Type.TArray<Type.TRef<"ExprNode">>;
|
|
12
|
+
}>, Type.TObject<{
|
|
13
|
+
type: Type.TLiteral<"formula">;
|
|
14
|
+
children: Type.TArray<Type.TRef<"ExprNode">>;
|
|
15
|
+
}>]>;
|
|
16
|
+
}, "ExprNode">;
|
|
17
|
+
export declare const ArgumentYamlProvenanceSchema: Type.TObject<{
|
|
18
|
+
provider: Type.TString;
|
|
19
|
+
model: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
20
|
+
pipeline: Type.TString;
|
|
21
|
+
pipelineVersion: Type.TString;
|
|
22
|
+
mode: Type.TString;
|
|
23
|
+
runAt: Type.TString;
|
|
24
|
+
sourceFile: Type.TString;
|
|
25
|
+
sourcePath: Type.TString;
|
|
26
|
+
coreVersion: Type.TString;
|
|
27
|
+
sharedVersion: Type.TString;
|
|
28
|
+
serverVersion: Type.TString;
|
|
29
|
+
}>;
|
|
30
|
+
export declare const CuratedArgumentYamlSchema: Type.TObject<{
|
|
31
|
+
title: Type.TString;
|
|
32
|
+
description: Type.TString;
|
|
33
|
+
claims: Type.TArray<Type.TObject<{
|
|
34
|
+
symbol: Type.TString;
|
|
35
|
+
title: Type.TString;
|
|
36
|
+
body: Type.TString;
|
|
37
|
+
}>>;
|
|
38
|
+
premises: Type.TArray<Type.TObject<{
|
|
39
|
+
title: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
40
|
+
role: Type.TUnion<[Type.TLiteral<"conclusion">, Type.TLiteral<"supporting">]>;
|
|
41
|
+
tree: Type.TCyclic<{
|
|
42
|
+
ExprNode: Type.TUnion<[Type.TObject<{
|
|
43
|
+
type: Type.TLiteral<"variable">;
|
|
44
|
+
symbol: Type.TString;
|
|
45
|
+
}>, Type.TObject<{
|
|
46
|
+
type: Type.TLiteral<"operator">;
|
|
47
|
+
operator: Type.TUnion<[Type.TLiteral<"and">, Type.TLiteral<"or">, Type.TLiteral<"not">, Type.TLiteral<"implies">, Type.TLiteral<"iff">]>;
|
|
48
|
+
children: Type.TArray<Type.TRef<"ExprNode">>;
|
|
49
|
+
}>, Type.TObject<{
|
|
50
|
+
type: Type.TLiteral<"formula">;
|
|
51
|
+
children: Type.TArray<Type.TRef<"ExprNode">>;
|
|
52
|
+
}>]>;
|
|
53
|
+
}, "ExprNode">;
|
|
54
|
+
}>>;
|
|
55
|
+
documentCurationId: Type.TOptional<Type.TString>;
|
|
56
|
+
provenance: Type.TOptional<Type.TObject<{
|
|
57
|
+
provider: Type.TString;
|
|
58
|
+
model: Type.TUnion<[Type.TString, Type.TNull]>;
|
|
59
|
+
pipeline: Type.TString;
|
|
60
|
+
pipelineVersion: Type.TString;
|
|
61
|
+
mode: Type.TString;
|
|
62
|
+
runAt: Type.TString;
|
|
63
|
+
sourceFile: Type.TString;
|
|
64
|
+
sourcePath: Type.TString;
|
|
65
|
+
coreVersion: Type.TString;
|
|
66
|
+
sharedVersion: Type.TString;
|
|
67
|
+
serverVersion: Type.TString;
|
|
68
|
+
}>>;
|
|
69
|
+
}>;
|
|
70
|
+
export type TCuratedArgumentYaml = CuratedArgument & {
|
|
71
|
+
documentCurationId?: string;
|
|
72
|
+
provenance?: HistoricalFigureProvenance;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/fixtures/argument-yaml/schema.ts"],"names":[],"mappings":"AAQA,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AACnE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAA;AAIhF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;cAyB9B,CAAA;AAID,eAAO,MAAM,4BAA4B;;;;;;;;;;;;EAYvC,CAAA;AAeF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASpC,CAAA;AAMF,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAAG;IACjD,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,UAAU,CAAC,EAAE,0BAA0B,CAAA;CAC1C,CAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// On-disk YAML contract for a curated argument.
|
|
2
|
+
//
|
|
3
|
+
// This TypeBox schema mirrors `../curated-argument`'s `CuratedArgument` /
|
|
4
|
+
// `ExprNode` authoring shape, plus the optional `documentCurationId` and
|
|
5
|
+
// `provenance` carried by `../historical-figures`'s `HistoricalFigureArgument`.
|
|
6
|
+
// It is the canonical, PR-editable representation a curated argument serializes
|
|
7
|
+
// to and is validated against on parse — NOT core's lossy snapshot YAML.
|
|
8
|
+
import Type from "typebox";
|
|
9
|
+
// Recursive `ExprNode` union. Declared as a cyclic schema so the `operator` /
|
|
10
|
+
// `formula` branches can reference the same node type for their children.
|
|
11
|
+
export const ExprNodeYamlSchema = Type.Cyclic({
|
|
12
|
+
ExprNode: Type.Union([
|
|
13
|
+
Type.Object({
|
|
14
|
+
type: Type.Literal("variable"),
|
|
15
|
+
symbol: Type.String(),
|
|
16
|
+
}),
|
|
17
|
+
Type.Object({
|
|
18
|
+
type: Type.Literal("operator"),
|
|
19
|
+
operator: Type.Union([
|
|
20
|
+
Type.Literal("and"),
|
|
21
|
+
Type.Literal("or"),
|
|
22
|
+
Type.Literal("not"),
|
|
23
|
+
Type.Literal("implies"),
|
|
24
|
+
Type.Literal("iff"),
|
|
25
|
+
]),
|
|
26
|
+
children: Type.Array(Type.Ref("ExprNode")),
|
|
27
|
+
}),
|
|
28
|
+
Type.Object({
|
|
29
|
+
type: Type.Literal("formula"),
|
|
30
|
+
children: Type.Array(Type.Ref("ExprNode")),
|
|
31
|
+
}),
|
|
32
|
+
]),
|
|
33
|
+
}, "ExprNode");
|
|
34
|
+
// Provenance block — mirrors `HistoricalFigureProvenance`. `model` is the only
|
|
35
|
+
// nullable field (some ingestion runs do not pin a concrete model id).
|
|
36
|
+
export const ArgumentYamlProvenanceSchema = Type.Object({
|
|
37
|
+
provider: Type.String(),
|
|
38
|
+
model: Type.Union([Type.String(), Type.Null()]),
|
|
39
|
+
pipeline: Type.String(),
|
|
40
|
+
pipelineVersion: Type.String(),
|
|
41
|
+
mode: Type.String(),
|
|
42
|
+
runAt: Type.String(),
|
|
43
|
+
sourceFile: Type.String(),
|
|
44
|
+
sourcePath: Type.String(),
|
|
45
|
+
coreVersion: Type.String(),
|
|
46
|
+
sharedVersion: Type.String(),
|
|
47
|
+
serverVersion: Type.String(),
|
|
48
|
+
});
|
|
49
|
+
const CuratedClaimYamlSchema = Type.Object({
|
|
50
|
+
symbol: Type.String(),
|
|
51
|
+
title: Type.String(),
|
|
52
|
+
body: Type.String(),
|
|
53
|
+
});
|
|
54
|
+
const CuratedPremiseYamlSchema = Type.Object({
|
|
55
|
+
// Title-less premises persist `title: null`.
|
|
56
|
+
title: Type.Union([Type.String(), Type.Null()]),
|
|
57
|
+
role: Type.Union([Type.Literal("conclusion"), Type.Literal("supporting")]),
|
|
58
|
+
tree: ExprNodeYamlSchema,
|
|
59
|
+
});
|
|
60
|
+
export const CuratedArgumentYamlSchema = Type.Object({
|
|
61
|
+
title: Type.String(),
|
|
62
|
+
description: Type.String(),
|
|
63
|
+
claims: Type.Array(CuratedClaimYamlSchema),
|
|
64
|
+
premises: Type.Array(CuratedPremiseYamlSchema),
|
|
65
|
+
// Stable id of the source document this argument was ingested from. Optional
|
|
66
|
+
// because a freshly-authored argument may not have one yet.
|
|
67
|
+
documentCurationId: Type.Optional(Type.String()),
|
|
68
|
+
provenance: Type.Optional(ArgumentYamlProvenanceSchema),
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/fixtures/argument-yaml/schema.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,yEAAyE;AAEzE,OAAO,IAAI,MAAM,SAAS,CAAA;AAI1B,8EAA8E;AAC9E,0EAA0E;AAC1E,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CACzC;IACI,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC;QACjB,IAAI,CAAC,MAAM,CAAC;YACR,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;YAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;SACxB,CAAC;QACF,IAAI,CAAC,MAAM,CAAC;YACR,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;YAC9B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC;gBACjB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;gBACnB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;gBAClB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;gBACnB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;gBACvB,IAAI,CA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AAI,CAAC,MAAM,CAAC;IACzC,6CAA6C;IAC7C,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;IAC1E,IAAI,EAAE,kBAAkB;CAC3B,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC,MAAM,CAAC;IACjD,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE;IACpB,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE;IAC1B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC;IAC1C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC;IAC9C,6EAA6E;IAC7E,4DAA4D;IAC5D,kBAAkB,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IAChD,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,4BAA4B,CAAC;CAC1D,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../src/fixtures/argument-yaml/serialize.ts"],"names":[],"mappings":"AAMA,OAAO,EAEH,KAAK,oBAAoB,EAC5B,MAAM,aAAa,CAAA;AAOpB,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAS3E;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB,CAgB1E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// YAML serialize / parse for curated arguments. Thin wrappers over the `yaml`
|
|
2
|
+
// package plus TypeBox validation against `CuratedArgumentYamlSchema`, so a
|
|
3
|
+
// malformed argument never round-trips silently.
|
|
4
|
+
import { Value } from "typebox/value";
|
|
5
|
+
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
6
|
+
import { CuratedArgumentYamlSchema, } from "./schema.js";
|
|
7
|
+
function firstError(value) {
|
|
8
|
+
const [error] = [...Value.Errors(CuratedArgumentYamlSchema, value)];
|
|
9
|
+
return error?.message ?? "unknown validation error";
|
|
10
|
+
}
|
|
11
|
+
export function serializeArgumentYaml(curated) {
|
|
12
|
+
if (!Value.Check(CuratedArgumentYamlSchema, curated)) {
|
|
13
|
+
throw new Error(`Cannot serialize curated argument — does not match the YAML schema: ${firstError(curated)}`);
|
|
14
|
+
}
|
|
15
|
+
return stringifyYaml(curated);
|
|
16
|
+
}
|
|
17
|
+
export function parseArgumentYaml(yamlString) {
|
|
18
|
+
let raw;
|
|
19
|
+
try {
|
|
20
|
+
raw = parseYaml(yamlString);
|
|
21
|
+
}
|
|
22
|
+
catch (cause) {
|
|
23
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
24
|
+
throw new Error(`Invalid YAML: ${message}`);
|
|
25
|
+
}
|
|
26
|
+
if (!Value.Check(CuratedArgumentYamlSchema, raw)) {
|
|
27
|
+
throw new Error(`Parsed YAML does not match the curated-argument schema: ${firstError(raw)}`);
|
|
28
|
+
}
|
|
29
|
+
return raw;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=serialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../../src/fixtures/argument-yaml/serialize.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,4EAA4E;AAC5E,iDAAiD;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,MAAM,CAAA;AACrE,OAAO,EACH,yBAAyB,GAE5B,MAAM,aAAa,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F/C"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Pure-JS SHA-256 (FIPS 180-4) over a UTF-8 string, returning lowercase hex.
|
|
2
|
+
//
|
|
3
|
+
// Dependency-free and runtime-agnostic on purpose: no Node `crypto`, no Web
|
|
4
|
+
// `crypto.subtle`, not even `TextEncoder`. UTF-8 encoding is done by hand so the
|
|
5
|
+
// whole module ships safely to `dist/` under this package's no-DOM/no-Node rule.
|
|
6
|
+
// `@proposit/proposit-core`'s checksum helper is FNV-1a (32-bit, non-crypto), so
|
|
7
|
+
// it cannot be reused where a real SHA-256 content digest is wanted.
|
|
8
|
+
// Round constants: first 32 bits of the fractional parts of the cube roots of
|
|
9
|
+
// the first 64 primes.
|
|
10
|
+
const K = [
|
|
11
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
|
|
12
|
+
0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
|
13
|
+
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
|
|
14
|
+
0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
15
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
|
|
16
|
+
0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
|
17
|
+
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
|
|
18
|
+
0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
19
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
|
|
20
|
+
0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
|
21
|
+
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
22
|
+
];
|
|
23
|
+
function rotateRight(value, bits) {
|
|
24
|
+
return (value >>> bits) | (value << (32 - bits));
|
|
25
|
+
}
|
|
26
|
+
// Encode a JS (UTF-16) string as UTF-8 bytes, handling surrogate pairs.
|
|
27
|
+
function utf8Bytes(input) {
|
|
28
|
+
const bytes = [];
|
|
29
|
+
for (let i = 0; i < input.length; i++) {
|
|
30
|
+
let code = input.charCodeAt(i);
|
|
31
|
+
if (code < 0x80) {
|
|
32
|
+
bytes.push(code);
|
|
33
|
+
}
|
|
34
|
+
else if (code < 0x800) {
|
|
35
|
+
bytes.push(0xc0 | (code >> 6), 0x80 | (code & 0x3f));
|
|
36
|
+
}
|
|
37
|
+
else if (code >= 0xd800 && code <= 0xdbff && i + 1 < input.length) {
|
|
38
|
+
// High surrogate followed by a low surrogate → one code point.
|
|
39
|
+
const low = input.charCodeAt(i + 1);
|
|
40
|
+
code = 0x10000 + ((code - 0xd800) << 10) + (low - 0xdc00);
|
|
41
|
+
i++;
|
|
42
|
+
bytes.push(0xf0 | (code >> 18), 0x80 | ((code >> 12) & 0x3f), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
bytes.push(0xe0 | (code >> 12), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return bytes;
|
|
49
|
+
}
|
|
50
|
+
export function sha256Hex(input) {
|
|
51
|
+
const hash = new Uint32Array([
|
|
52
|
+
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c,
|
|
53
|
+
0x1f83d9ab, 0x5be0cd19,
|
|
54
|
+
]);
|
|
55
|
+
const bytes = utf8Bytes(input);
|
|
56
|
+
const bitLength = bytes.length * 8;
|
|
57
|
+
// Pad: append 0x80, then zero bytes until length ≡ 56 (mod 64).
|
|
58
|
+
bytes.push(0x80);
|
|
59
|
+
while (bytes.length % 64 !== 56) {
|
|
60
|
+
bytes.push(0);
|
|
61
|
+
}
|
|
62
|
+
// Append the original message length as a 64-bit big-endian integer.
|
|
63
|
+
const high = Math.floor(bitLength / 0x100000000);
|
|
64
|
+
const low = bitLength >>> 0;
|
|
65
|
+
bytes.push((high >>> 24) & 0xff, (high >>> 16) & 0xff, (high >>> 8) & 0xff, high & 0xff, (low >>> 24) & 0xff, (low >>> 16) & 0xff, (low >>> 8) & 0xff, low & 0xff);
|
|
66
|
+
const schedule = new Uint32Array(64);
|
|
67
|
+
for (let offset = 0; offset < bytes.length; offset += 64) {
|
|
68
|
+
for (let i = 0; i < 16; i++) {
|
|
69
|
+
const j = offset + i * 4;
|
|
70
|
+
schedule[i] =
|
|
71
|
+
(bytes[j] << 24) |
|
|
72
|
+
(bytes[j + 1] << 16) |
|
|
73
|
+
(bytes[j + 2] << 8) |
|
|
74
|
+
bytes[j + 3];
|
|
75
|
+
}
|
|
76
|
+
for (let i = 16; i < 64; i++) {
|
|
77
|
+
const w15 = schedule[i - 15];
|
|
78
|
+
const w2 = schedule[i - 2];
|
|
79
|
+
const s0 = rotateRight(w15, 7) ^ rotateRight(w15, 18) ^ (w15 >>> 3);
|
|
80
|
+
const s1 = rotateRight(w2, 17) ^ rotateRight(w2, 19) ^ (w2 >>> 10);
|
|
81
|
+
schedule[i] = (schedule[i - 16] + s0 + schedule[i - 7] + s1) >>> 0;
|
|
82
|
+
}
|
|
83
|
+
let a = hash[0];
|
|
84
|
+
let b = hash[1];
|
|
85
|
+
let c = hash[2];
|
|
86
|
+
let d = hash[3];
|
|
87
|
+
let e = hash[4];
|
|
88
|
+
let f = hash[5];
|
|
89
|
+
let g = hash[6];
|
|
90
|
+
let h = hash[7];
|
|
91
|
+
for (let i = 0; i < 64; i++) {
|
|
92
|
+
const bigS1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
|
|
93
|
+
const choice = (e & f) ^ (~e & g);
|
|
94
|
+
const temp1 = (h + bigS1 + choice + K[i] + schedule[i]) >>> 0;
|
|
95
|
+
const bigS0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22);
|
|
96
|
+
const majority = (a & b) ^ (a & c) ^ (b & c);
|
|
97
|
+
const temp2 = (bigS0 + majority) >>> 0;
|
|
98
|
+
h = g;
|
|
99
|
+
g = f;
|
|
100
|
+
f = e;
|
|
101
|
+
e = (d + temp1) >>> 0;
|
|
102
|
+
d = c;
|
|
103
|
+
c = b;
|
|
104
|
+
b = a;
|
|
105
|
+
a = (temp1 + temp2) >>> 0;
|
|
106
|
+
}
|
|
107
|
+
hash[0] = (hash[0] + a) >>> 0;
|
|
108
|
+
hash[1] = (hash[1] + b) >>> 0;
|
|
109
|
+
hash[2] = (hash[2] + c) >>> 0;
|
|
110
|
+
hash[3] = (hash[3] + d) >>> 0;
|
|
111
|
+
hash[4] = (hash[4] + e) >>> 0;
|
|
112
|
+
hash[5] = (hash[5] + f) >>> 0;
|
|
113
|
+
hash[6] = (hash[6] + g) >>> 0;
|
|
114
|
+
hash[7] = (hash[7] + h) >>> 0;
|
|
115
|
+
}
|
|
116
|
+
let hex = "";
|
|
117
|
+
for (let i = 0; i < 8; i++) {
|
|
118
|
+
hex += hash[i].toString(16).padStart(8, "0");
|
|
119
|
+
}
|
|
120
|
+
return hex;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=sha256.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha256.js","sourceRoot":"","sources":["../../../src/fixtures/argument-yaml/sha256.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,4EAA4E;AAC5E,iFAAiF;AACjF,iFAAiF;AACjF,iFAAiF;AACjF,qEAAqE;AAErE,8EAA8E;AAC9E,uBAAuB;AACvB,MAAM,CAAC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AA;IAChD,CAAC;IACD,OAAO,GAAG,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type ExprNode = {
|
|
2
|
+
type: "variable";
|
|
3
|
+
symbol: string;
|
|
4
|
+
} | {
|
|
5
|
+
type: "operator";
|
|
6
|
+
operator: "and" | "or" | "not" | "implies" | "iff";
|
|
7
|
+
children: ExprNode[];
|
|
8
|
+
} | {
|
|
9
|
+
type: "formula";
|
|
10
|
+
children: ExprNode[];
|
|
11
|
+
};
|
|
12
|
+
export interface CuratedClaim {
|
|
13
|
+
symbol: string;
|
|
14
|
+
title: string;
|
|
15
|
+
body: string;
|
|
16
|
+
}
|
|
17
|
+
export interface CuratedPremise {
|
|
18
|
+
title: string | null;
|
|
19
|
+
role: "conclusion" | "supporting";
|
|
20
|
+
tree: ExprNode;
|
|
21
|
+
}
|
|
22
|
+
export interface CuratedArgument {
|
|
23
|
+
title: string;
|
|
24
|
+
description: string;
|
|
25
|
+
claims: CuratedClaim[];
|
|
26
|
+
premises: CuratedPremise[];
|
|
27
|
+
}
|
|
28
|
+
export declare const v: (symbol: string) => ExprNode;
|
|
29
|
+
export declare const formula: (child: ExprNode) => ExprNode;
|
|
30
|
+
export declare const and: (...children: ExprNode[]) => ExprNode;
|
|
31
|
+
export declare const or: (...children: ExprNode[]) => ExprNode;
|
|
32
|
+
export declare const not: (child: ExprNode) => ExprNode;
|
|
33
|
+
export declare const implies: (antecedent: ExprNode, consequent: ExprNode) => ExprNode;
|
|
34
|
+
export declare const iff: (left: ExprNode, right: ExprNode) => ExprNode;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fixtures/curated-argument/index.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,QAAQ,GACd;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACpC;I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2
|
+
//
|
|
3
|
+
// This is a pure data module — no DOM, Node, or runtime dependencies. It defines
|
|
4
|
+
// the shape of a hand-authorable argument (claims + premises whose logical form
|
|
5
|
+
// is an `ExprNode` abstract syntax tree) plus the shorthand constructors used to
|
|
6
|
+
// build those trees by hand. Datasets such as `../historical-figures` store
|
|
7
|
+
// arguments as already-built `ExprNode` trees, so the constructors are not
|
|
8
|
+
// required to express the data — they are the documented vocabulary for anyone
|
|
9
|
+
// hand-editing or contributing a revised argument.
|
|
10
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Shorthand constructors
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
export const v = (symbol) => ({ type: "variable", symbol });
|
|
15
|
+
// A `formula` node must sit between non-NOT operators (e.g. `and(or(...), x)` is
|
|
16
|
+
// invalid; it must be `and(formula(or(...)), x)`). Auto-wrap non-NOT operator
|
|
17
|
+
// children below so call sites stay readable without manual `formula(...)`
|
|
18
|
+
// wrappers everywhere.
|
|
19
|
+
const wrapForFormula = (n) => n.type === "operator" && n.operator !== "not"
|
|
20
|
+
? { type: "formula", children: [n] }
|
|
21
|
+
: n;
|
|
22
|
+
export const formula = (child) => ({
|
|
23
|
+
type: "formula",
|
|
24
|
+
children: [child],
|
|
25
|
+
});
|
|
26
|
+
export const and = (...children) => ({
|
|
27
|
+
type: "operator",
|
|
28
|
+
operator: "and",
|
|
29
|
+
children: children.map(wrapForFormula),
|
|
30
|
+
});
|
|
31
|
+
export const or = (...children) => ({
|
|
32
|
+
type: "operator",
|
|
33
|
+
operator: "or",
|
|
34
|
+
children: children.map(wrapForFormula),
|
|
35
|
+
});
|
|
36
|
+
export const not = (child) => ({
|
|
37
|
+
type: "operator",
|
|
38
|
+
operator: "not",
|
|
39
|
+
children: [child],
|
|
40
|
+
});
|
|
41
|
+
export const implies = (antecedent, consequent) => ({
|
|
42
|
+
type: "operator",
|
|
43
|
+
operator: "implies",
|
|
44
|
+
children: [wrapForFormula(antecedent), wrapForFormula(consequent)],
|
|
45
|
+
});
|
|
46
|
+
export const iff = (left, right) => ({
|
|
47
|
+
type: "operator",
|
|
48
|
+
operator: "iff",
|
|
49
|
+
children: [wrapForFormula(left), wrapForFormula(right)],
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fixtures/curated-argument/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,iFAAiF;AACjF,gFAAgF;AAChF,iFAAiF;AACjF,4EAA4E;AAC5E,2EAA2E;AAC3E,+EAA+E;AAC/E,mDAAmD;AAoCnD,wDAAwD;AAExD,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAc,EAAY,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;AAE7E,iFAAiF;AACjF,8EAA8E;AAC9E,2EAA2E;AAC3E,uBAAuB;AACvB,MAAM,cAAc,GAAG,CAAC,CAAW,EAAY,EAAE,CAC7C,CAAC,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,CAAC,QAAQ,KAAK,KAAK;IACzC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE;IACpC,CAAC,CAAC,CAAC,CAAA;AAEX,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAe,EAAY,EAAE,CAAC,CAAC;IACnD,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,CAAC,KAAK,CAAC;CACpB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,QAAoB,EAAY,EAAE,CAAC,CAAC;IACvD,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC;CACzC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,QAAoB,EAAY,EAAE,CAAC,CAAC;IACtD,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC;CACzC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,KAAe,EAAY,EAAE,CAAC,CAAC;IAC/C,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,CAAC,KAAK,CAAC;CACpB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CACnB,UAAoB,EACpB,UAAoB,EACZ,EAAE,CAAC,CAAC;IACZ,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;CACrE,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,IAAc,EAAE,KAAe,EAAY,EAAE,CAAC,CAAC;IAC/D,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;CAC1D,CAAC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HistoricalFigureArgument } from "./index.js";
|
|
2
|
+
export declare const figureAboutByCurationId: Record<string, string>;
|
|
3
|
+
export declare const documentMarkdownByCurationId: Record<string, string>;
|
|
4
|
+
export declare const documentAboutByCurationId: Record<string, string>;
|
|
5
|
+
export declare const argumentsByFigureCurationId: Record<string, HistoricalFigureArgument[]>;
|
|
6
|
+
//# sourceMappingURL=content.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.generated.d.ts","sourceRoot":"","sources":["../../../src/fixtures/historical-figures/content.generated.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAA;AAE1D,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAG1D,CAAA;AAED,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAG/D,CAAA;AAED,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAG5D,CAAA;AAED,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAC5C,MAAM,EACN,wBAAwB,EAAE,CA6nB7B,CAAA"}
|