@maschinenlesbar.org/bundeshaushalt-cli 0.0.1
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/CONTRIBUTING.md +25 -0
- package/LICENSE +661 -0
- package/LICENSING.md +47 -0
- package/README.md +203 -0
- package/dist/src/cli/commands/budget.d.ts +4 -0
- package/dist/src/cli/commands/budget.d.ts.map +1 -0
- package/dist/src/cli/commands/budget.js +86 -0
- package/dist/src/cli/commands/budget.js.map +1 -0
- package/dist/src/cli/index.d.ts +3 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/cli/index.js +6 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/cli/io.d.ts +13 -0
- package/dist/src/cli/io.d.ts.map +1 -0
- package/dist/src/cli/io.js +7 -0
- package/dist/src/cli/io.js.map +1 -0
- package/dist/src/cli/program.d.ts +7 -0
- package/dist/src/cli/program.d.ts.map +1 -0
- package/dist/src/cli/program.js +54 -0
- package/dist/src/cli/program.js.map +1 -0
- package/dist/src/cli/run.d.ts +3 -0
- package/dist/src/cli/run.d.ts.map +1 -0
- package/dist/src/cli/run.js +48 -0
- package/dist/src/cli/run.js.map +1 -0
- package/dist/src/cli/shared.d.ts +51 -0
- package/dist/src/cli/shared.d.ts.map +1 -0
- package/dist/src/cli/shared.js +81 -0
- package/dist/src/cli/shared.js.map +1 -0
- package/dist/src/client/client.d.ts +9 -0
- package/dist/src/client/client.d.ts.map +1 -0
- package/dist/src/client/client.js +32 -0
- package/dist/src/client/client.js.map +1 -0
- package/dist/src/client/engine.d.ts +56 -0
- package/dist/src/client/engine.d.ts.map +1 -0
- package/dist/src/client/engine.js +159 -0
- package/dist/src/client/engine.js.map +1 -0
- package/dist/src/client/enums.d.ts +17 -0
- package/dist/src/client/enums.d.ts.map +1 -0
- package/dist/src/client/enums.js +16 -0
- package/dist/src/client/enums.js.map +1 -0
- package/dist/src/client/errors.d.ts +33 -0
- package/dist/src/client/errors.d.ts.map +1 -0
- package/dist/src/client/errors.js +40 -0
- package/dist/src/client/errors.js.map +1 -0
- package/dist/src/client/http.d.ts +26 -0
- package/dist/src/client/http.d.ts.map +1 -0
- package/dist/src/client/http.js +89 -0
- package/dist/src/client/http.js.map +1 -0
- package/dist/src/client/index.d.ts +11 -0
- package/dist/src/client/index.d.ts.map +1 -0
- package/dist/src/client/index.js +9 -0
- package/dist/src/client/index.js.map +1 -0
- package/dist/src/client/query.d.ts +9 -0
- package/dist/src/client/query.d.ts.map +1 -0
- package/dist/src/client/query.js +33 -0
- package/dist/src/client/query.js.map +1 -0
- package/dist/src/client/types.d.ts +66 -0
- package/dist/src/client/types.d.ts.map +1 -0
- package/dist/src/client/types.js +4 -0
- package/dist/src/client/types.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC9D,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Public entry point for the API client library.
|
|
2
|
+
export { BundeshaushaltClient } from "./client.js";
|
|
3
|
+
export { RequestEngine, DEFAULT_BASE_URL } from "./engine.js";
|
|
4
|
+
export { nodeHttpTransport } from "./http.js";
|
|
5
|
+
export { buildQueryString } from "./query.js";
|
|
6
|
+
export { HaushaltError, HaushaltApiError, HaushaltNetworkError, HaushaltParseError, } from "./errors.js";
|
|
7
|
+
export * from "./enums.js";
|
|
8
|
+
export * from "./types.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type QueryPrimitive = string | number | boolean | Date | null | undefined;
|
|
2
|
+
export type QueryValue = QueryPrimitive | QueryPrimitive[];
|
|
3
|
+
export type QueryParams = Record<string, QueryValue>;
|
|
4
|
+
/**
|
|
5
|
+
* Build a query string (without a leading `?`) from a params object.
|
|
6
|
+
* Returns an empty string when no parameters survive filtering.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildQueryString(params: QueryParams): string;
|
|
9
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/client/query.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;AACjF,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,cAAc,EAAE,CAAC;AAC3D,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAQrD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAe5D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Tiny, dependency-free query-string builder.
|
|
2
|
+
// - `undefined` / `null` values are omitted entirely
|
|
3
|
+
// - arrays are serialised as repeated keys (`?id=a&id=b`)
|
|
4
|
+
// - booleans become the strings "true"/"false"
|
|
5
|
+
// - Date values become full ISO-8601 strings
|
|
6
|
+
// - everything else is coerced with String()
|
|
7
|
+
function serializeScalar(value) {
|
|
8
|
+
if (value instanceof Date)
|
|
9
|
+
return value.toISOString();
|
|
10
|
+
if (typeof value === "boolean")
|
|
11
|
+
return value ? "true" : "false";
|
|
12
|
+
return String(value);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Build a query string (without a leading `?`) from a params object.
|
|
16
|
+
* Returns an empty string when no parameters survive filtering.
|
|
17
|
+
*/
|
|
18
|
+
export function buildQueryString(params) {
|
|
19
|
+
const search = new URLSearchParams();
|
|
20
|
+
for (const [key, raw] of Object.entries(params)) {
|
|
21
|
+
if (raw === undefined || raw === null)
|
|
22
|
+
continue;
|
|
23
|
+
const values = Array.isArray(raw) ? raw : [raw];
|
|
24
|
+
for (const value of values) {
|
|
25
|
+
if (value === undefined || value === null)
|
|
26
|
+
continue;
|
|
27
|
+
search.append(key, serializeScalar(value));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// URLSearchParams encodes spaces as "+"; "%20" is more broadly interoperable.
|
|
31
|
+
return search.toString().replace(/\+/g, "%20");
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/client/query.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,uDAAuD;AACvD,4DAA4D;AAC5D,iDAAiD;AACjD,+CAA+C;AAC/C,+CAA+C;AAM/C,SAAS,eAAe,CAAC,KAAgD;IACvE,IAAI,KAAK,YAAY,IAAI;QAAE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IACtD,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAChE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAmB;IAClD,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IAErC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAChD,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI;YAAE,SAAS;QAEhD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAChD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;gBAAE,SAAS;YACpD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,8EAA8E;IAC9E,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Account, Quota, Unit } from "./enums.js";
|
|
2
|
+
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
3
|
+
[key: string]: JsonValue;
|
|
4
|
+
};
|
|
5
|
+
export type JsonObject = {
|
|
6
|
+
[key: string]: JsonValue;
|
|
7
|
+
};
|
|
8
|
+
/** Metadata describing the current view. */
|
|
9
|
+
export interface BudgetMeta {
|
|
10
|
+
account: Account;
|
|
11
|
+
year: number;
|
|
12
|
+
quota: Quota;
|
|
13
|
+
unit: Unit;
|
|
14
|
+
entity?: string;
|
|
15
|
+
levelCur?: number;
|
|
16
|
+
levelMax?: number;
|
|
17
|
+
modifyDate?: string;
|
|
18
|
+
timestamp?: number;
|
|
19
|
+
/** Human-readable label of the active table/dimension (e.g. "Einzelplan"). */
|
|
20
|
+
tableLabel?: string;
|
|
21
|
+
/** Human-readable label of the active selection (e.g. "Alle Einzelpläne"). */
|
|
22
|
+
selectionLabel?: string;
|
|
23
|
+
}
|
|
24
|
+
/** A single budget element (a line, group or function). */
|
|
25
|
+
export interface BudgetElement {
|
|
26
|
+
budgetNumber: string;
|
|
27
|
+
id?: string;
|
|
28
|
+
label: string;
|
|
29
|
+
/** Value in euros. */
|
|
30
|
+
value: number;
|
|
31
|
+
relativeValue: number;
|
|
32
|
+
relativeToParentValue: number;
|
|
33
|
+
/** Human-readable label of the table/dimension this element belongs to. */
|
|
34
|
+
tableLabel?: string;
|
|
35
|
+
/** Human-readable label of the selection this element belongs to. */
|
|
36
|
+
selectionLabel?: string;
|
|
37
|
+
}
|
|
38
|
+
/** An id/label pair used in `parents` and `related`. */
|
|
39
|
+
export interface LabeledElement {
|
|
40
|
+
id?: string;
|
|
41
|
+
label?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Response of `/internalapi/budgetData`. */
|
|
44
|
+
export interface BudgetData {
|
|
45
|
+
meta: BudgetMeta;
|
|
46
|
+
/** The selected element. NB: the wire field is `detail` (singular). */
|
|
47
|
+
detail: BudgetElement | JsonObject;
|
|
48
|
+
children: (BudgetElement | JsonObject)[];
|
|
49
|
+
parents?: LabeledElement[][];
|
|
50
|
+
related?: {
|
|
51
|
+
agency?: LabeledElement[][];
|
|
52
|
+
function?: LabeledElement[][];
|
|
53
|
+
group?: LabeledElement[][];
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Parameters for `/internalapi/budgetData`. */
|
|
57
|
+
export interface BudgetParams {
|
|
58
|
+
/** Four-digit year (>= 2012). */
|
|
59
|
+
year: number;
|
|
60
|
+
account: Account;
|
|
61
|
+
quota?: Quota;
|
|
62
|
+
unit?: Unit;
|
|
63
|
+
/** Budget number id; `G-` prefix for groups, `F-` for functions. */
|
|
64
|
+
id?: string;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvD,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AACjC,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtD,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MA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ACd,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,oEAAoE;IACpE,EAAE,CAAC,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,uBAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,cAAc,mBAAmB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maschinenlesbar.org/bundeshaushalt-cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "TypeScript API client and CLI for the open German federal budget API (bundeshaushalt.de)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"bundeshaushalt": "dist/src/cli/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/src/index.js",
|
|
10
|
+
"types": "dist/src/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/src/index.d.ts",
|
|
14
|
+
"import": "./dist/src/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist/src",
|
|
19
|
+
"LICENSING.md",
|
|
20
|
+
"CONTRIBUTING.md"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=20"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
27
|
+
"build": "tsc -p tsconfig.json",
|
|
28
|
+
"prepack": "npm run build",
|
|
29
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
30
|
+
"pretest": "npm run build",
|
|
31
|
+
"test": "node --test dist/test/*.test.js",
|
|
32
|
+
"docs": "typedoc src/index.ts --out out",
|
|
33
|
+
"start": "node dist/src/cli/index.js"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"bundeshaushalt",
|
|
37
|
+
"bmf",
|
|
38
|
+
"budget",
|
|
39
|
+
"haushalt",
|
|
40
|
+
"finance",
|
|
41
|
+
"germany",
|
|
42
|
+
"cli",
|
|
43
|
+
"api-client"
|
|
44
|
+
],
|
|
45
|
+
"author": "Sebastian Schürmann <sebs@2xs.org>",
|
|
46
|
+
"license": "AGPL-3.0-or-later",
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "git+https://github.com/maschinenlesbar-org/bundeshaushalt-cli.git"
|
|
50
|
+
},
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/maschinenlesbar-org/bundeshaushalt-cli/issues"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/maschinenlesbar-org/bundeshaushalt-cli#readme",
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"commander": "15.0.0"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/node": "^22.19.19",
|
|
63
|
+
"typedoc": "0.28.19",
|
|
64
|
+
"typescript": "6.0.3"
|
|
65
|
+
}
|
|
66
|
+
}
|