commit 309f88d19ebf55620d258806e45172244fd3c325
parent 506e62d91ef6886de051721b44cbb6f358044c6d
Author: Florian Dold <florian@dold.me>
Date: Wed, 22 May 2024 19:54:21 +0200
-fix bug in type extraction
Some type declarations were omitted
Diffstat:
2 files changed, 105 insertions(+), 9 deletions(-)
diff --git a/extract-tsdefs/extract.ts b/extract-tsdefs/extract.ts
@@ -107,7 +107,7 @@ function gatherDecls(
console.log("string!");
break;
}
- const symbol = type.symbol || type.aliasSymbol;
+ const symbol = type.aliasSymbol || type.symbol;
if (!symbol) {
console.log(`no type symbol for ${node.getText()}`);
break;
@@ -116,7 +116,7 @@ function gatherDecls(
console.log(`symbol name: ${type.symbol?.name}`);
console.log(`alias symbol name: ${type.aliasSymbol?.name}`);
if (perOpState.nameSet.has(name)) {
- console.log("already found!");
+ console.log(`already found ${name}`);
break;
}
perOpState.nameSet.add(name);
@@ -148,6 +148,20 @@ function gatherDecls(
console.log(declText);
break;
}
+ case ts.SyntaxKind.TypeLiteral:
+ if (!type.aliasSymbol) {
+ // Just free-standing type literal, no need to emit!
+ break;
+ }
+ console.log(`got TypeLiteral for ${name}`);
+ const declText = printer.printNode(
+ ts.EmitHint.Unspecified,
+ decl,
+ decl.getSourceFile()!
+ );
+ gatherState.declTexts.set(name, `type ${name} = ${declText};`);
+ console.log(declText);
+ break;
default:
console.log(`unknown decl kind ${ts.SyntaxKind[decl.kind]}`);
break;
@@ -160,20 +174,22 @@ function gatherDecls(
default:
break;
}
- console.log(`syntax children for ${node.getText()}`);
+ console.log(`start syntax children for ${node.getText()}`);
node.forEachChild((child) => {
console.log(`syntax child: ${ts.SyntaxKind[child.kind]}`);
gatherDecls(child, gatherState, perOpState);
});
+ console.log(`end syntax children for ${node.getText()}`);
//console.log(`// unknown node kind ${ts.SyntaxKind[node.kind]}`);
return;
}
function getOpEnumDecl(decl: ts.Declaration): string | undefined {
+ console.log("getting OpEnumDecl")
let enumMemberDecl: undefined | string = undefined;
- function walk(node: ts.Node) {
+ function walk(node: ts.Node, level: number = 0) {
node.forEachChild((x) => {
- console.log(`child kind: ${ts.SyntaxKind[x.kind]}`);
+ console.log(`child kind [${level}]: ${ts.SyntaxKind[x.kind]}`);
console.log(x.getText());
switch (x.kind) {
case ts.SyntaxKind.PropertySignature: {
@@ -185,7 +201,7 @@ function getOpEnumDecl(decl: ts.Declaration): string | undefined {
break;
}
}
- walk(x);
+ walk(x, level + 1);
});
}
walk(decl);
@@ -205,8 +221,13 @@ const main = async () => {
if (!v.name.endsWith("Op")) {
return;
}
+ console.log(`gathering documentation for export ${v.name}`);
const decls = v.getDeclarations();
- decls?.forEach((decl) => {
+ if (!decls) {
+ return;
+ }
+ console.log(`has ${decls.length} declarations`);
+ decls.forEach((decl) => {
console.log(`export decl, kind ${ts.SyntaxKind[decl.kind]}`);
const commentRanges = ts.getLeadingCommentRanges(
diff --git a/wallet/wallet-core.md b/wallet/wallet-core.md
@@ -959,7 +959,8 @@ export interface CheckPayTemplateRequest {
```
```typescript
-export type CheckPayTemplateReponse = TalerMerchantApi.WalletTemplateDetails & {
+export type CheckPayTemplateReponse = {
+ templateDetails: TalerMerchantApi.WalletTemplateDetails;
supportedCurrencies: string[];
};
@@ -990,7 +991,6 @@ export interface TemplateContractDetailsDefaults {
* Amount *or* a plain currency string.
*/
amount?: string;
- minimum_age?: Integer;
}
```
@@ -1015,6 +1015,13 @@ export interface PreparePayTemplateRequest {
}
```
+```typescript
+export type TemplateParams = {
+ amount?: string;
+ summary?: string;
+};
+
+```
### GetContractTermsDetailsOp
```typescript
@@ -1667,6 +1674,40 @@ export interface WireInfo {
```
```typescript
+export type WireFeeMap = {
+ [wireMethod: string]: WireFee[];
+};
+
+```
+```typescript
+/**
+ * Wire fee for one wire method
+ */
+export interface WireFee {
+ /**
+ * Fee for wire transfers.
+ */
+ wireFee: AmountString;
+ /**
+ * Fees to close and refund a reserve.
+ */
+ closingFee: AmountString;
+ /**
+ * Start date of the fee.
+ */
+ startStamp: TalerProtocolTimestamp;
+ /**
+ * End date of the fee.
+ */
+ endStamp: TalerProtocolTimestamp;
+ /**
+ * Signature made by the exchange master key.
+ */
+ sig: string;
+}
+
+```
+```typescript
export interface ExchangeWireAccount {
payto_uri: string;
conversion_url?: string;
@@ -1679,6 +1720,16 @@ export interface ExchangeWireAccount {
```
```typescript
+export type DenomOperationMap<T> = {
+ [op in DenomOperation]: T;
+};
+
+```
+```typescript
+export type DenomOperation = "deposit" | "withdraw" | "refresh" | "refund";
+
+```
+```typescript
export interface FeeDescription {
group: string;
from: AbsoluteTime;
@@ -3251,9 +3302,33 @@ export interface WalletCoreVersion {
}
```
```typescript
+// group: Initialization
+type EmptyObject = Record<string, never>;
+```
+```typescript
export type ScopeInfo = ScopeInfoGlobal | ScopeInfoExchange | ScopeInfoAuditor;
```
```typescript
+export type ScopeInfoGlobal = {
+ type: ScopeType.Global;
+ currency: string;
+};
+```
+```typescript
+export type ScopeInfoExchange = {
+ type: ScopeType.Exchange;
+ currency: string;
+ url: string;
+};
+```
+```typescript
+export type ScopeInfoAuditor = {
+ type: ScopeType.Auditor;
+ currency: string;
+ url: string;
+};
+```
+```typescript
export type AmountString =
| (string & {
[__amount_str]: true;