fmp-node-api 0.1.0 → 0.1.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/dist/chunk-RM7ETDL3.mjs +1 -0
- package/dist/common-COsxpVBY.d.mts +18 -0
- package/dist/common-COsxpVBY.d.ts +18 -0
- package/dist/index.d.mts +35 -1575
- package/dist/index.d.ts +35 -1575
- package/dist/index.js +2 -4182
- package/dist/index.mjs +2 -4137
- package/dist/types-only-DjnrpNZm.d.ts +1086 -0
- package/dist/types-only-v3B1TqXe.d.mts +1086 -0
- package/dist/types-only.d.mts +2 -0
- package/dist/types-only.d.ts +2 -0
- package/dist/types-only.js +1 -0
- package/dist/types-only.mjs +0 -0
- package/dist/utils/validation.d.mts +88 -0
- package/dist/utils/validation.d.ts +88 -0
- package/dist/utils/validation.js +1 -0
- package/dist/utils/validation.mjs +1 -0
- package/package.json +11 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=class{static isValidSymbol(t){return !t||typeof t!="string"?false:/^[A-Z]{1,5}$/.test(t)}static isValidCryptoSymbol(t){return !t||typeof t!="string"?false:/^[A-Z]{2,10}(USD|EUR|GBP|JPY|CAD|AUD|CHF|CNY)$/.test(t)}static isValidForexPair(t){return !t||typeof t!="string"?false:/^[A-Z]{3}[A-Z]{3}$/.test(t)}static isValidDate(t){if(!t||typeof t!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(t))return false;let i=new Date(t);return !isNaN(i.getTime())&&i.toISOString().split("T")[0]===t}static isValidDateRange(t,e){if(!this.isValidDate(t)||!this.isValidDate(e))return false;let i=new Date(t),r=new Date(e);return i<=r}static isValidResponse(t){return !!(t&&typeof t=="object"&&typeof t.success=="boolean")}static isValidApiKey(t){return !t||typeof t!="string"?false:/^[a-zA-Z0-9]{32,}$/.test(t)}static isValidPeriod(t){return !t||typeof t!="string"?false:["annual","quarter","fy"].includes(t.toLowerCase())}static isValidLimit(t){return typeof t=="number"&&Number.isInteger(t)&&t>0&&t<=1e3}static validateQuoteParams(t){let e=[];return t?(t.symbol?!this.isValidSymbol(t.symbol)&&!this.isValidCryptoSymbol(t.symbol)&&!this.isValidForexPair(t.symbol)&&e.push("Invalid symbol format"):e.push("Symbol is required"),t.from&&!this.isValidDate(t.from)&&e.push("Invalid from date format (expected YYYY-MM-DD)"),t.to&&!this.isValidDate(t.to)&&e.push("Invalid to date format (expected YYYY-MM-DD)"),t.from&&t.to&&!this.isValidDateRange(t.from,t.to)&&e.push("From date must be before or equal to to date"),e):(e.push("Parameters object is required"),e)}static validateFinancialParams(t){let e=[];return t?(t.symbol?this.isValidSymbol(t.symbol)||e.push("Invalid symbol format"):e.push("Symbol is required"),t.period&&!this.isValidPeriod(t.period)&&e.push('Invalid period (must be "annual", "quarter", or "FY")'),t.limit&&!this.isValidLimit(t.limit)&&e.push("Invalid limit (must be a positive integer <= 1000)"),e):(e.push("Parameters object is required"),e)}static validateDateRangeParams(t){let e=[];return t?(t.from&&!this.isValidDate(t.from)&&e.push("Invalid from date format (expected YYYY-MM-DD)"),t.to&&!this.isValidDate(t.to)&&e.push("Invalid to date format (expected YYYY-MM-DD)"),t.from&&t.to&&!this.isValidDateRange(t.from,t.to)&&e.push("From date must be before or equal to to date"),e):(e.push("Parameters object is required"),e)}static throwIfInvalid(t,e="Validation"){if(t.length>0)throw new Error(`${e} failed: ${t.join(", ")}`)}};export{s as a};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface APIResponse<T = unknown> {
|
|
2
|
+
success: boolean;
|
|
3
|
+
data: T | null;
|
|
4
|
+
error: string | null;
|
|
5
|
+
status: number;
|
|
6
|
+
}
|
|
7
|
+
interface FMPConfig {
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
11
|
+
interface SymbolParams {
|
|
12
|
+
symbol: string;
|
|
13
|
+
}
|
|
14
|
+
interface PeriodParams {
|
|
15
|
+
period?: 'annual' | 'quarter';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type { APIResponse as A, FMPConfig as F, PeriodParams as P, SymbolParams as S };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface APIResponse<T = unknown> {
|
|
2
|
+
success: boolean;
|
|
3
|
+
data: T | null;
|
|
4
|
+
error: string | null;
|
|
5
|
+
status: number;
|
|
6
|
+
}
|
|
7
|
+
interface FMPConfig {
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
11
|
+
interface SymbolParams {
|
|
12
|
+
symbol: string;
|
|
13
|
+
}
|
|
14
|
+
interface PeriodParams {
|
|
15
|
+
period?: 'annual' | 'quarter';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type { APIResponse as A, FMPConfig as F, PeriodParams as P, SymbolParams as S };
|