izmir-open-data-js 1.1.1 → 1.2.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/dist/client.d.ts +16 -1
- package/dist/client.js +58 -1
- package/dist/endpoints/eshot.d.ts +25 -4
- package/dist/endpoints/eshot.js +20 -9
- package/dist/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export declare class IzmirClient {
|
|
2
2
|
private readonly baseUrl;
|
|
3
3
|
private readonly ckanBaseUrl;
|
|
4
|
+
private readonly ckanDumpBaseUrl;
|
|
4
5
|
private fetchJsonp;
|
|
5
|
-
constructor(baseUrl?: string, ckanBaseUrl?: string);
|
|
6
|
+
constructor(baseUrl?: string, ckanBaseUrl?: string, ckanDumpBaseUrl?: string);
|
|
6
7
|
get(path: string): Promise<any>;
|
|
7
8
|
/**
|
|
8
9
|
* CKAN API'den veri çeker.
|
|
@@ -17,4 +18,18 @@ export declare class IzmirClient {
|
|
|
17
18
|
* Normal fetch ile CKAN API çağrısı (Node.js için)
|
|
18
19
|
*/
|
|
19
20
|
private getCKANWithFetch;
|
|
21
|
+
/**
|
|
22
|
+
* CKAN dump endpoint'inden veri çeker.
|
|
23
|
+
* Tüm veriyi JSON formatında döndürür.
|
|
24
|
+
* @param resourceId Kaynak ID'si
|
|
25
|
+
*/
|
|
26
|
+
getCKANDump<T = any>(resourceId: string): Promise<T>;
|
|
27
|
+
/**
|
|
28
|
+
* JSONP ile CKAN dump API çağrısı (tarayıcı için)
|
|
29
|
+
*/
|
|
30
|
+
private getCKANDumpWithJsonp;
|
|
31
|
+
/**
|
|
32
|
+
* Normal fetch ile CKAN dump API çağrısı (Node.js için)
|
|
33
|
+
*/
|
|
34
|
+
private getCKANDumpWithFetch;
|
|
20
35
|
}
|
package/dist/client.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// Node.js ortamında window yoktur, tarayıcıda JSONP kullanılır
|
|
2
2
|
const isBrowser = typeof window !== 'undefined';
|
|
3
3
|
export class IzmirClient {
|
|
4
|
-
constructor(baseUrl = "https://openapi.izmir.bel.tr/api/", ckanBaseUrl = "https://acikveri.bizizmir.com/api/3/action/") {
|
|
4
|
+
constructor(baseUrl = "https://openapi.izmir.bel.tr/api/", ckanBaseUrl = "https://acikveri.bizizmir.com/api/3/action/", ckanDumpBaseUrl = "https://acikveri.bizizmir.com/datastore/dump/") {
|
|
5
5
|
this.fetchJsonp = null;
|
|
6
6
|
this.baseUrl = baseUrl;
|
|
7
7
|
this.ckanBaseUrl = ckanBaseUrl;
|
|
8
|
+
this.ckanDumpBaseUrl = ckanDumpBaseUrl;
|
|
8
9
|
}
|
|
9
10
|
async get(path) {
|
|
10
11
|
const res = await fetch(this.baseUrl + path);
|
|
@@ -83,4 +84,60 @@ export class IzmirClient {
|
|
|
83
84
|
throw new Error("Bilinmeyen CKAN hatası");
|
|
84
85
|
}
|
|
85
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* CKAN dump endpoint'inden veri çeker.
|
|
89
|
+
* Tüm veriyi JSON formatında döndürür.
|
|
90
|
+
* @param resourceId Kaynak ID'si
|
|
91
|
+
*/
|
|
92
|
+
async getCKANDump(resourceId) {
|
|
93
|
+
const url = `${this.ckanDumpBaseUrl}${resourceId}?format=json`;
|
|
94
|
+
if (isBrowser) {
|
|
95
|
+
return this.getCKANDumpWithJsonp(url);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return this.getCKANDumpWithFetch(url);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* JSONP ile CKAN dump API çağrısı (tarayıcı için)
|
|
103
|
+
*/
|
|
104
|
+
async getCKANDumpWithJsonp(url) {
|
|
105
|
+
try {
|
|
106
|
+
if (!this.fetchJsonp) {
|
|
107
|
+
const module = await import('fetch-jsonp');
|
|
108
|
+
this.fetchJsonp = module.default;
|
|
109
|
+
}
|
|
110
|
+
const response = await this.fetchJsonp(url, {
|
|
111
|
+
jsonpCallback: 'callback',
|
|
112
|
+
timeout: 30000, // Dump daha büyük olabilir
|
|
113
|
+
});
|
|
114
|
+
const data = await response.json();
|
|
115
|
+
return data;
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (error instanceof Error) {
|
|
119
|
+
throw new Error(`JSONP Hatası: ${error.message}`);
|
|
120
|
+
}
|
|
121
|
+
throw new Error("Bilinmeyen JSONP hatası");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Normal fetch ile CKAN dump API çağrısı (Node.js için)
|
|
126
|
+
*/
|
|
127
|
+
async getCKANDumpWithFetch(url) {
|
|
128
|
+
try {
|
|
129
|
+
const res = await fetch(url);
|
|
130
|
+
if (!res.ok) {
|
|
131
|
+
throw new Error(`CKAN Dump API response error: ${res.status}`);
|
|
132
|
+
}
|
|
133
|
+
const data = await res.json();
|
|
134
|
+
return data;
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
if (error instanceof Error) {
|
|
138
|
+
throw new Error(`CKAN Dump Hatası: ${error.message}`);
|
|
139
|
+
}
|
|
140
|
+
throw new Error("Bilinmeyen CKAN Dump hatası");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
86
143
|
}
|
|
@@ -99,6 +99,21 @@ export interface CKANDatastoreResponse<T> {
|
|
|
99
99
|
limit: number;
|
|
100
100
|
total: number;
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* CKAN dump response tipi (array formatında kayıtlar)
|
|
104
|
+
*/
|
|
105
|
+
export interface CKANDumpResponse {
|
|
106
|
+
fields: {
|
|
107
|
+
type: string;
|
|
108
|
+
id: string;
|
|
109
|
+
info?: {
|
|
110
|
+
notes?: string;
|
|
111
|
+
type_override?: string;
|
|
112
|
+
label?: string;
|
|
113
|
+
};
|
|
114
|
+
}[];
|
|
115
|
+
records: (number | string | null)[][];
|
|
116
|
+
}
|
|
102
117
|
export declare function eshot(client: IzmirClient): {
|
|
103
118
|
/**
|
|
104
119
|
* ESHOT hatlarının listesini içeren web servisi (CKAN).
|
|
@@ -125,14 +140,20 @@ export declare function eshot(client: IzmirClient): {
|
|
|
125
140
|
*/
|
|
126
141
|
getDuraklar(limit?: number, offset?: number): Promise<CKANDatastoreResponse<EshotDurakCKAN>>;
|
|
127
142
|
/**
|
|
128
|
-
* ESHOT hat güzergahlarını içeren web servisi (CKAN).
|
|
143
|
+
* ESHOT hat güzergahlarını içeren web servisi (CKAN Dump).
|
|
129
144
|
* Her hat için gidiş (YON=1) ve dönüş (YON=2) koordinat noktalarını içerir.
|
|
145
|
+
* Tüm güzergah verilerini tek seferde döndürür.
|
|
146
|
+
*
|
|
147
|
+
* Kaynak: https://acikveri.bizizmir.com/dataset/eshot-hat-guzergahlari
|
|
148
|
+
*/
|
|
149
|
+
getHatGuzergahlari(): Promise<CKANDumpResponse>;
|
|
150
|
+
/**
|
|
151
|
+
* ESHOT hat güzergahlarını nesne formatında döndürür.
|
|
152
|
+
* Raw dump verisini EshotHatGuzergah nesnelerine dönüştürür.
|
|
130
153
|
*
|
|
131
154
|
* Kaynak: https://acikveri.bizizmir.com/dataset/eshot-hat-guzergahlari
|
|
132
|
-
* @param limit Döndürülecek kayıt sayısı (varsayılan: 100)
|
|
133
|
-
* @param offset Atlanacak kayıt sayısı (sayfalama için)
|
|
134
155
|
*/
|
|
135
|
-
|
|
156
|
+
getHatGuzergahlariParsed(): Promise<EshotHatGuzergah[]>;
|
|
136
157
|
/**
|
|
137
158
|
* Otobüs hatlarının diğer ulaşım araçları ile bağlantı tiplerini içeren web servisi (CKAN).
|
|
138
159
|
* Metro, İzban, Vapur, Tramvay gibi bağlantı tiplerini listeler.
|
package/dist/endpoints/eshot.js
CHANGED
|
@@ -43,19 +43,30 @@ export function eshot(client) {
|
|
|
43
43
|
});
|
|
44
44
|
},
|
|
45
45
|
/**
|
|
46
|
-
* ESHOT hat güzergahlarını içeren web servisi (CKAN).
|
|
46
|
+
* ESHOT hat güzergahlarını içeren web servisi (CKAN Dump).
|
|
47
47
|
* Her hat için gidiş (YON=1) ve dönüş (YON=2) koordinat noktalarını içerir.
|
|
48
|
+
* Tüm güzergah verilerini tek seferde döndürür.
|
|
48
49
|
*
|
|
49
50
|
* Kaynak: https://acikveri.bizizmir.com/dataset/eshot-hat-guzergahlari
|
|
50
|
-
* @param limit Döndürülecek kayıt sayısı (varsayılan: 100)
|
|
51
|
-
* @param offset Atlanacak kayıt sayısı (sayfalama için)
|
|
52
51
|
*/
|
|
53
|
-
getHatGuzergahlari(
|
|
54
|
-
return client.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
getHatGuzergahlari() {
|
|
53
|
+
return client.getCKANDump('543f2249-c734-48e4-8739-72efbbfc843c');
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* ESHOT hat güzergahlarını nesne formatında döndürür.
|
|
57
|
+
* Raw dump verisini EshotHatGuzergah nesnelerine dönüştürür.
|
|
58
|
+
*
|
|
59
|
+
* Kaynak: https://acikveri.bizizmir.com/dataset/eshot-hat-guzergahlari
|
|
60
|
+
*/
|
|
61
|
+
async getHatGuzergahlariParsed() {
|
|
62
|
+
const dump = await client.getCKANDump('543f2249-c734-48e4-8739-72efbbfc843c');
|
|
63
|
+
return dump.records.map(record => ({
|
|
64
|
+
_id: record[0],
|
|
65
|
+
HAT_NO: record[1],
|
|
66
|
+
YON: record[2],
|
|
67
|
+
BOYLAM: record[3],
|
|
68
|
+
ENLEM: record[4]
|
|
69
|
+
}));
|
|
59
70
|
},
|
|
60
71
|
/**
|
|
61
72
|
* Otobüs hatlarının diğer ulaşım araçları ile bağlantı tiplerini içeren web servisi (CKAN).
|
package/dist/index.d.ts
CHANGED
|
@@ -43,7 +43,8 @@ export declare class IzmirAPI {
|
|
|
43
43
|
getHatlar(limit?: number, offset?: number): Promise<import("./endpoints/eshot").CKANDatastoreResponse<import("./endpoints/eshot").EshotHat>>;
|
|
44
44
|
getHareketSaatleri(limit?: number, offset?: number): Promise<import("./endpoints/eshot").CKANDatastoreResponse<import("./endpoints/eshot").EshotHareketSaati>>;
|
|
45
45
|
getDuraklar(limit?: number, offset?: number): Promise<import("./endpoints/eshot").CKANDatastoreResponse<import("./endpoints/eshot").EshotDurakCKAN>>;
|
|
46
|
-
getHatGuzergahlari(
|
|
46
|
+
getHatGuzergahlari(): Promise<import("./endpoints/eshot").CKANDumpResponse>;
|
|
47
|
+
getHatGuzergahlariParsed(): Promise<import("./endpoints/eshot").EshotHatGuzergah[]>;
|
|
47
48
|
getBaglantiTipleri(limit?: number, offset?: number): Promise<import("./endpoints/eshot").CKANDatastoreResponse<import("./endpoints/eshot").EshotBaglantiTipi>>;
|
|
48
49
|
getYakinDurakList(enlem: number, boylam: number): Promise<import("./common/types/onemliYer.js").OnemliYerWrapper<import("./endpoints/eshot").EshotDurak>>;
|
|
49
50
|
getDuragaYaklasanOtobusList(durakId: number): Promise<import("./endpoints/eshot").YaklasanOtobus[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "izmir-open-data-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Izmir Open Data API wrapper - İzmir Büyükşehir Belediyesi Açık Veri API'leri için TypeScript/JavaScript kütüphanesi",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|