@jars-lt/sdk 1.0.1 β 1.0.3
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/index.d.ts +119 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -1
- package/example.ts +55 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Company, SubscriptionPlan } from '@jars-lt/types';
|
|
1
|
+
import { Company, SubscriptionPlan, WorkdayCheckResponse, AddWorkdaysResponse, NormalizeAddressResponse } from '@jars-lt/types';
|
|
2
2
|
/**
|
|
3
3
|
* Configuration options for JARS.LT client
|
|
4
4
|
*/
|
|
@@ -94,6 +94,44 @@ export interface UsageResponse {
|
|
|
94
94
|
rateLimit: number;
|
|
95
95
|
webhooksEnabled: boolean;
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Company financial report data
|
|
99
|
+
*/
|
|
100
|
+
export interface CompanyFinancialsData {
|
|
101
|
+
companyCode: string;
|
|
102
|
+
year: number;
|
|
103
|
+
periodStart: string;
|
|
104
|
+
periodEnd: string;
|
|
105
|
+
reportDate?: string;
|
|
106
|
+
balance?: {
|
|
107
|
+
equity?: number;
|
|
108
|
+
longTermAssets?: number;
|
|
109
|
+
shortTermAssets?: number;
|
|
110
|
+
liabilities?: number;
|
|
111
|
+
totalAssets?: number;
|
|
112
|
+
};
|
|
113
|
+
profitLoss?: {
|
|
114
|
+
revenue?: number;
|
|
115
|
+
profitBeforeTax?: number;
|
|
116
|
+
netProfit?: number;
|
|
117
|
+
};
|
|
118
|
+
templateId?: string;
|
|
119
|
+
templateName?: string;
|
|
120
|
+
standardId?: string;
|
|
121
|
+
standardName?: string;
|
|
122
|
+
dataDate: string;
|
|
123
|
+
createdAt: string;
|
|
124
|
+
updatedAt: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Company financials response
|
|
128
|
+
*/
|
|
129
|
+
export interface CompanyFinancialsResponse {
|
|
130
|
+
companyCode: string;
|
|
131
|
+
companyName: string;
|
|
132
|
+
financials: CompanyFinancialsData[];
|
|
133
|
+
availableYears: number[];
|
|
134
|
+
}
|
|
97
135
|
/**
|
|
98
136
|
* API Error
|
|
99
137
|
*/
|
|
@@ -161,6 +199,31 @@ export declare class JarsClient {
|
|
|
161
199
|
* ```
|
|
162
200
|
*/
|
|
163
201
|
getCompany(code: string): Promise<Company>;
|
|
202
|
+
/**
|
|
203
|
+
* Get company financial reports (balance sheet + P&L)
|
|
204
|
+
*
|
|
205
|
+
* @param code - Company code (9 digits)
|
|
206
|
+
* @param params - Optional parameters
|
|
207
|
+
* @param params.year - Specific year to fetch (optional, returns all years if not specified)
|
|
208
|
+
* @param params.limit - Maximum number of years to return (default: 10, max: 50)
|
|
209
|
+
* @returns Financial reports with balance sheet and P&L data
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* // Get all available financial reports
|
|
214
|
+
* const financials = await client.getCompanyFinancials('111111111');
|
|
215
|
+
* console.log(financials.availableYears); // [2024, 2023, 2022]
|
|
216
|
+
* console.log(financials.financials[0].profitLoss?.revenue); // Revenue for latest year
|
|
217
|
+
*
|
|
218
|
+
* // Get specific year
|
|
219
|
+
* const financials2024 = await client.getCompanyFinancials('111111111', { year: 2024 });
|
|
220
|
+
* console.log(financials2024.financials[0].balance?.equity); // Equity for 2024
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
getCompanyFinancials(code: string, params?: {
|
|
224
|
+
year?: number;
|
|
225
|
+
limit?: number;
|
|
226
|
+
}): Promise<CompanyFinancialsResponse>;
|
|
164
227
|
/**
|
|
165
228
|
* Search for addresses (streets, settlements, municipalities)
|
|
166
229
|
* Supports multi-word search (e.g., "kaunas basanavi")
|
|
@@ -214,6 +277,61 @@ export declare class JarsClient {
|
|
|
214
277
|
* ```
|
|
215
278
|
*/
|
|
216
279
|
getUsage(): Promise<UsageResponse>;
|
|
280
|
+
/**
|
|
281
|
+
* Check if a specific date is a workday in Lithuania
|
|
282
|
+
*
|
|
283
|
+
* @param date - Date in YYYY-MM-DD format
|
|
284
|
+
* @returns Workday information including holiday details
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* const result = await client.checkWorkday('2024-12-25');
|
|
289
|
+
* console.log(result.isWorkday); // false
|
|
290
|
+
* console.log(result.isHoliday); // true
|
|
291
|
+
* console.log(result.holidayName); // "KalΔdos" (Christmas)
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
checkWorkday(date: string): Promise<WorkdayCheckResponse>;
|
|
295
|
+
/**
|
|
296
|
+
* Add workdays to a date, skipping weekends and Lithuanian holidays
|
|
297
|
+
*
|
|
298
|
+
* @param date - Start date in YYYY-MM-DD format
|
|
299
|
+
* @param days - Number of workdays to add (can be negative)
|
|
300
|
+
* @returns Result with the calculated date
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```typescript
|
|
304
|
+
* // Add 5 workdays to a date
|
|
305
|
+
* const result = await client.addWorkdays('2024-01-15', 5);
|
|
306
|
+
* console.log(result.resultDate); // The date after adding 5 workdays
|
|
307
|
+
*
|
|
308
|
+
* // Subtract 3 workdays
|
|
309
|
+
* const result2 = await client.addWorkdays('2024-01-15', -3);
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
addWorkdays(date: string, days: number): Promise<AddWorkdaysResponse>;
|
|
313
|
+
/**
|
|
314
|
+
* Normalize an arbitrary address string to structured components
|
|
315
|
+
* Supports fuzzy matching for typos (1-2 character edits)
|
|
316
|
+
*
|
|
317
|
+
* @param address - Address string in any format (e.g., "vilnus gedimino 15")
|
|
318
|
+
* @param limit - Maximum number of results (default: 5, max: 20)
|
|
319
|
+
* @returns Normalized address results with confidence scores
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```typescript
|
|
323
|
+
* // Normalize with typos
|
|
324
|
+
* const result = await client.normalizeAddress('gedimno pr 28 vilnus');
|
|
325
|
+
* console.log(result.results[0].formatted); // "Gedimino pr. 28, Vilnius, Vilniaus m. sav., LT-01103"
|
|
326
|
+
* console.log(result.results[0].confidence); // 0.87
|
|
327
|
+
* console.log(result.results[0].components.street); // { code: 105641, name: "Gedimino", ... }
|
|
328
|
+
*
|
|
329
|
+
* // With building number
|
|
330
|
+
* const result2 = await client.normalizeAddress('kaunas laisves al 20a');
|
|
331
|
+
* console.log(result2.results[0].components.building); // { number: "20A", postalCode: "LT-44291" }
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
normalizeAddress(address: string, limit?: number): Promise<NormalizeAddressResponse>;
|
|
217
335
|
}
|
|
218
336
|
export * from '@jars-lt/types';
|
|
219
337
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAEhI;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IAC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C,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAKpC;;;;;;;;;;;;OAYG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAKhE;;;;;;;;;;;;OAYG;IACG,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC;IAKxC;;;;;;;;;;;;;OAaG;IACG,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAK/D;;;;;;;;;;;;;;;;OAgBG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAK3E;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAI3F;AAGD,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -111,6 +111,31 @@ class JarsClient {
|
|
|
111
111
|
const response = await this.client.get(`/companies/${code}`);
|
|
112
112
|
return response.data;
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Get company financial reports (balance sheet + P&L)
|
|
116
|
+
*
|
|
117
|
+
* @param code - Company code (9 digits)
|
|
118
|
+
* @param params - Optional parameters
|
|
119
|
+
* @param params.year - Specific year to fetch (optional, returns all years if not specified)
|
|
120
|
+
* @param params.limit - Maximum number of years to return (default: 10, max: 50)
|
|
121
|
+
* @returns Financial reports with balance sheet and P&L data
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* // Get all available financial reports
|
|
126
|
+
* const financials = await client.getCompanyFinancials('111111111');
|
|
127
|
+
* console.log(financials.availableYears); // [2024, 2023, 2022]
|
|
128
|
+
* console.log(financials.financials[0].profitLoss?.revenue); // Revenue for latest year
|
|
129
|
+
*
|
|
130
|
+
* // Get specific year
|
|
131
|
+
* const financials2024 = await client.getCompanyFinancials('111111111', { year: 2024 });
|
|
132
|
+
* console.log(financials2024.financials[0].balance?.equity); // Equity for 2024
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
async getCompanyFinancials(code, params) {
|
|
136
|
+
const response = await this.client.get(`/companies/${code}/financials`, { params });
|
|
137
|
+
return response.data;
|
|
138
|
+
}
|
|
114
139
|
/**
|
|
115
140
|
* Search for addresses (streets, settlements, municipalities)
|
|
116
141
|
* Supports multi-word search (e.g., "kaunas basanavi")
|
|
@@ -169,6 +194,70 @@ class JarsClient {
|
|
|
169
194
|
const response = await this.client.get('/usage');
|
|
170
195
|
return response.data;
|
|
171
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Check if a specific date is a workday in Lithuania
|
|
199
|
+
*
|
|
200
|
+
* @param date - Date in YYYY-MM-DD format
|
|
201
|
+
* @returns Workday information including holiday details
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* const result = await client.checkWorkday('2024-12-25');
|
|
206
|
+
* console.log(result.isWorkday); // false
|
|
207
|
+
* console.log(result.isHoliday); // true
|
|
208
|
+
* console.log(result.holidayName); // "KalΔdos" (Christmas)
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
async checkWorkday(date) {
|
|
212
|
+
const response = await this.client.get('/workdays/check', { params: { date } });
|
|
213
|
+
return response.data;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Add workdays to a date, skipping weekends and Lithuanian holidays
|
|
217
|
+
*
|
|
218
|
+
* @param date - Start date in YYYY-MM-DD format
|
|
219
|
+
* @param days - Number of workdays to add (can be negative)
|
|
220
|
+
* @returns Result with the calculated date
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* // Add 5 workdays to a date
|
|
225
|
+
* const result = await client.addWorkdays('2024-01-15', 5);
|
|
226
|
+
* console.log(result.resultDate); // The date after adding 5 workdays
|
|
227
|
+
*
|
|
228
|
+
* // Subtract 3 workdays
|
|
229
|
+
* const result2 = await client.addWorkdays('2024-01-15', -3);
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
async addWorkdays(date, days) {
|
|
233
|
+
const response = await this.client.get('/workdays/add', { params: { date, days } });
|
|
234
|
+
return response.data;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Normalize an arbitrary address string to structured components
|
|
238
|
+
* Supports fuzzy matching for typos (1-2 character edits)
|
|
239
|
+
*
|
|
240
|
+
* @param address - Address string in any format (e.g., "vilnus gedimino 15")
|
|
241
|
+
* @param limit - Maximum number of results (default: 5, max: 20)
|
|
242
|
+
* @returns Normalized address results with confidence scores
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* // Normalize with typos
|
|
247
|
+
* const result = await client.normalizeAddress('gedimno pr 28 vilnus');
|
|
248
|
+
* console.log(result.results[0].formatted); // "Gedimino pr. 28, Vilnius, Vilniaus m. sav., LT-01103"
|
|
249
|
+
* console.log(result.results[0].confidence); // 0.87
|
|
250
|
+
* console.log(result.results[0].components.street); // { code: 105641, name: "Gedimino", ... }
|
|
251
|
+
*
|
|
252
|
+
* // With building number
|
|
253
|
+
* const result2 = await client.normalizeAddress('kaunas laisves al 20a');
|
|
254
|
+
* console.log(result2.results[0].components.building); // { number: "20A", postalCode: "LT-44291" }
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
async normalizeAddress(address, limit) {
|
|
258
|
+
const response = await this.client.post('/addresses/normalize', { address, limit });
|
|
259
|
+
return response.data;
|
|
260
|
+
}
|
|
172
261
|
}
|
|
173
262
|
exports.JarsClient = JarsClient;
|
|
174
263
|
// Re-export types from @jars-lt/types for convenience
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],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src/index';
|
|
9
|
+
import { JarsClient, JarsAPIError, NormalizedAddress } from './src/index';
|
|
10
10
|
|
|
11
11
|
async function main() {
|
|
12
12
|
// Initialize client with API key from environment
|
|
@@ -78,6 +78,60 @@ async function main() {
|
|
|
78
78
|
console.log(` ... and ${location.streets.length - 3} more`);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
console.log();
|
|
82
|
+
|
|
83
|
+
// Example 6: Check if a date is a workday
|
|
84
|
+
console.log('π
Checking workdays...');
|
|
85
|
+
const today = new Date().toISOString().split('T')[0];
|
|
86
|
+
const workdayCheck = await client.checkWorkday(today);
|
|
87
|
+
console.log(`Date: ${workdayCheck.date} (${workdayCheck.dayOfWeek})`);
|
|
88
|
+
console.log(`Is workday: ${workdayCheck.isWorkday}`);
|
|
89
|
+
console.log(`Is weekend: ${workdayCheck.isWeekend}`);
|
|
90
|
+
console.log(`Is holiday: ${workdayCheck.isHoliday}`);
|
|
91
|
+
if (workdayCheck.holidayName) {
|
|
92
|
+
console.log(`Holiday: ${workdayCheck.holidayName}`);
|
|
93
|
+
}
|
|
94
|
+
console.log();
|
|
95
|
+
|
|
96
|
+
// Example 7: Check a Lithuanian holiday (Christmas)
|
|
97
|
+
console.log('π Checking Christmas 2024...');
|
|
98
|
+
const christmas = await client.checkWorkday('2024-12-25');
|
|
99
|
+
console.log(`Date: ${christmas.date} (${christmas.dayOfWeek})`);
|
|
100
|
+
console.log(`Is workday: ${christmas.isWorkday}`);
|
|
101
|
+
console.log(`Is holiday: ${christmas.isHoliday}`);
|
|
102
|
+
if (christmas.holidayName) {
|
|
103
|
+
console.log(`Holiday: ${christmas.holidayName}`);
|
|
104
|
+
}
|
|
105
|
+
console.log();
|
|
106
|
+
|
|
107
|
+
// Example 8: Add workdays to a date
|
|
108
|
+
console.log('β Adding workdays...');
|
|
109
|
+
const addResult = await client.addWorkdays(today, 5);
|
|
110
|
+
console.log(`Start date: ${addResult.startDate}`);
|
|
111
|
+
console.log(`Workdays added: ${addResult.workdaysAdded}`);
|
|
112
|
+
console.log(`Result date: ${addResult.resultDate}`);
|
|
113
|
+
console.log(`Result is workday: ${addResult.resultIsWorkday}`);
|
|
114
|
+
console.log();
|
|
115
|
+
|
|
116
|
+
// Example 9: Normalize address with fuzzy matching
|
|
117
|
+
console.log('π Normalizing address (with typos)...');
|
|
118
|
+
const normalized = await client.normalizeAddress('gedimno pr 28 vilnus', 3);
|
|
119
|
+
console.log(`Query: "${normalized.query}"`);
|
|
120
|
+
console.log(`Parsed tokens: ${normalized.parsed.tokens.join(', ')}`);
|
|
121
|
+
if (normalized.parsed.building) {
|
|
122
|
+
console.log(`Detected building: ${normalized.parsed.building}`);
|
|
123
|
+
}
|
|
124
|
+
console.log(`Found ${normalized.results.length} results:`);
|
|
125
|
+
normalized.results.forEach((result: NormalizedAddress, i: number) => {
|
|
126
|
+
console.log(` ${i + 1}. ${result.formatted}`);
|
|
127
|
+
console.log(` Confidence: ${(result.confidence * 100).toFixed(0)}%`);
|
|
128
|
+
if (result.components.building) {
|
|
129
|
+
console.log(` Building: ${result.components.building.number}`);
|
|
130
|
+
}
|
|
131
|
+
if (result.components.postalCode) {
|
|
132
|
+
console.log(` Postal: ${result.components.postalCode}`);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
81
135
|
} catch (error) {
|
|
82
136
|
if (error instanceof JarsAPIError) {
|
|
83
137
|
console.error('β API Error:', error.message);
|