laplace-api 3.1.0 → 4.1.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/.github/workflows/publish.yml +37 -0
- package/.github/workflows/test.yml +25 -0
- package/README.md +461 -2
- package/package.json +1 -1
- package/src/client/broker.ts +79 -99
- package/src/client/capital_increase.ts +17 -22
- package/src/client/collections.ts +61 -40
- package/src/client/financial_fundamentals.ts +40 -35
- package/src/client/financial_ratios.ts +168 -128
- package/src/client/funds.ts +139 -0
- package/src/client/key-insights.ts +17 -0
- package/src/client/live-price-web-socket.ts +84 -11
- package/src/client/live-price.ts +210 -58
- package/src/client/politician.ts +75 -0
- package/src/client/stocks.ts +85 -2
- package/src/test/broker.test.ts +581 -170
- package/src/test/capital_increase.test.ts +266 -15
- package/src/test/collections.test.ts +460 -17
- package/src/test/custom_theme.test.ts +256 -65
- package/src/test/financial_fundamentals.test.ts +301 -45
- package/src/test/financial_ratios.test.ts +376 -75
- package/src/test/funds.test.ts +317 -0
- package/src/test/helpers.ts +58 -0
- package/src/test/key-insight.test.ts +110 -0
- package/src/test/live-price.test.ts +427 -67
- package/src/test/politician.test.ts +253 -0
- package/src/test/readme.test.ts +483 -0
- package/src/test/search.test.ts +308 -23
- package/src/test/stocks.test.ts +800 -70
- package/src/utilities/configuration.ts +23 -10
- package/src/utilities/test.env +2 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as dotenv from
|
|
2
|
-
import * as envalid from
|
|
1
|
+
import * as dotenv from "dotenv";
|
|
2
|
+
import * as envalid from "envalid";
|
|
3
3
|
const { str } = envalid;
|
|
4
4
|
|
|
5
5
|
export interface LaplaceConfigurationInterface {
|
|
6
|
-
baseURL
|
|
6
|
+
baseURL?: string;
|
|
7
7
|
apiKey: string;
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -11,18 +11,28 @@ export class LaplaceConfiguration implements LaplaceConfigurationInterface {
|
|
|
11
11
|
baseURL: string;
|
|
12
12
|
apiKey: string;
|
|
13
13
|
|
|
14
|
-
constructor({
|
|
15
|
-
|
|
14
|
+
constructor({
|
|
15
|
+
baseURL = "https://api.finfree.app",
|
|
16
|
+
apiKey,
|
|
17
|
+
}: LaplaceConfigurationInterface) {
|
|
18
|
+
this.baseURL = baseURL || "https://api.finfree.app";
|
|
16
19
|
this.apiKey = apiKey;
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
validate(): null | Error {
|
|
20
|
-
|
|
23
|
+
if (!this.apiKey) {
|
|
24
|
+
return new Error("API key is required");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Remove baseURL validation since it's now optional
|
|
21
28
|
return null;
|
|
22
29
|
}
|
|
23
30
|
|
|
24
31
|
applyDefaults(): null | Error {
|
|
25
|
-
|
|
32
|
+
if (!this.baseURL) {
|
|
33
|
+
this.baseURL = "https://api.finfree.app";
|
|
34
|
+
}
|
|
35
|
+
|
|
26
36
|
return null;
|
|
27
37
|
}
|
|
28
38
|
}
|
|
@@ -41,14 +51,17 @@ function validationFuncRegular(config: LaplaceConfiguration): null | Error {
|
|
|
41
51
|
return config.validate();
|
|
42
52
|
}
|
|
43
53
|
|
|
44
|
-
export function loadGlobal(
|
|
54
|
+
export function loadGlobal(
|
|
55
|
+
filename?: string,
|
|
56
|
+
validationFunc: ValidationFunc = validationFuncRegular
|
|
57
|
+
): LaplaceConfiguration {
|
|
45
58
|
const envLoadResult = loadEnvironment(filename);
|
|
46
59
|
if (envLoadResult.error) {
|
|
47
60
|
throw envLoadResult.error;
|
|
48
61
|
}
|
|
49
62
|
|
|
50
63
|
const env = envalid.cleanEnv(process.env, {
|
|
51
|
-
BASE_URL: str(),
|
|
64
|
+
BASE_URL: str({ default: "https://api.finfree.app" }),
|
|
52
65
|
API_KEY: str(),
|
|
53
66
|
});
|
|
54
67
|
|
|
@@ -70,4 +83,4 @@ export function loadGlobal(filename?: string, validationFunc: ValidationFunc = v
|
|
|
70
83
|
}
|
|
71
84
|
|
|
72
85
|
return config;
|
|
73
|
-
}
|
|
86
|
+
}
|
package/src/utilities/test.env
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
BASE_URL=
|
|
2
|
-
API_KEY=api-
|
|
1
|
+
BASE_URL=http://localhost:8010
|
|
2
|
+
API_KEY=test-api-key
|