@k03mad/ip2geo 20.1.5 β†’ 21.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/api.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ export interface ReqOutput {
2
+ ip?: string;
3
+ continent?: string;
4
+ continentCode?: string;
5
+ country?: string;
6
+ countryCode?: string;
7
+ countryEmoji?: string;
8
+ region?: string;
9
+ regionCode?: string;
10
+ city?: string;
11
+ connectionAsn?: number;
12
+ connectionOrg?: string;
13
+ connectionIsp?: string;
14
+ connectionDomain?: string;
15
+ }
16
+
17
+ export interface ReqInput {
18
+ ip?: string;
19
+ cacheDir?: string;
20
+ cacheFileName?: string;
21
+ cacheFileSeparator?: string;
22
+ cacheFileNewline?: string;
23
+ cacheMap?: Map<string, ReqOutput>;
24
+ cacheMapMaxEntries?: number;
25
+ }
26
+
27
+ export const cacheStorage: Map<string, ReqOutput>;
28
+
29
+ export const DEFAULT_CACHE_FILE_DIR: string;
30
+ export const DEFAULT_CACHE_FILE_NAME: string;
31
+ export const DEFAULT_CACHE_FILE_SEPARATOR: string;
32
+ export const DEFAULT_CACHE_FILE_NEWLINE: string;
33
+ export const DEFAULT_CACHE_MAP_MAX_ENTRIES: number;
34
+
35
+ export const ip2geo: (opts?: ReqInput) => Promise<ReqOutput>;
package/app/api.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import os from 'node:os';
2
2
  import path from 'node:path';
3
3
 
4
+ import type {ReqInput, ReqOutput} from '../api.d.ts';
5
+
4
6
  import {
5
7
  collectOutputData,
6
8
  readFromFsCache,
@@ -8,7 +10,6 @@ import {
8
10
  writeToFsCache,
9
11
  writeToMapCache,
10
12
  } from './helpers/cache.ts';
11
- import type {ReqOutput} from './types.ts';
12
13
 
13
14
  const API = 'https://ipwho.is/';
14
15
 
@@ -18,16 +19,6 @@ export const DEFAULT_CACHE_FILE_SEPARATOR = ';;';
18
19
  export const DEFAULT_CACHE_FILE_NEWLINE = '\n';
19
20
  export const DEFAULT_CACHE_MAP_MAX_ENTRIES = Number.POSITIVE_INFINITY;
20
21
 
21
- export interface ReqInput {
22
- ip?: string;
23
- cacheDir?: string;
24
- cacheFileName?: string;
25
- cacheFileSeparator?: string;
26
- cacheFileNewline?: string;
27
- cacheMap?: Map<string, ReqOutput>;
28
- cacheMapMaxEntries?: number;
29
- }
30
-
31
22
  interface ApiResponseBody {
32
23
  ip?: string;
33
24
  continent?: string;
@@ -4,7 +4,7 @@ import path from 'node:path';
4
4
  import _debug from 'debug';
5
5
  import {isIP} from 'is-ip';
6
6
 
7
- import type {ReqOutput} from '../types.ts';
7
+ import type {ReqOutput} from '../../api.d.ts';
8
8
 
9
9
  import {getArrayDups} from './utils.ts';
10
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k03mad/ip2geo",
3
- "version": "20.1.5",
3
+ "version": "21.0.1",
4
4
  "description": "GeoIP library",
5
5
  "license": "MIT",
6
6
  "maintainers": [
@@ -15,28 +15,33 @@
15
15
  },
16
16
  "type": "module",
17
17
  "main": "api.js",
18
+ "types": "api.d.ts",
18
19
  "scripts": {
19
20
  "lint": "oxlint && oxfmt -c node_modules/@k03mad/oxlint-config/.oxfmtrc.json --check && tsc --noEmit",
20
21
  "test": "rm -rfv ./.geoip && node --test tests/*.ts",
21
22
  "prepare": "husky || true"
22
23
  },
23
24
  "dependencies": {
24
- "chalk": "5.6.2",
25
+ "chalk": "6.0.0",
25
26
  "debug": "4.4.3",
26
27
  "is-ip": "5.0.1",
27
- "tsx": "4.23.1"
28
+ "tsx": "4.23.8"
28
29
  },
29
30
  "devDependencies": {
30
- "@k03mad/oxlint-config": "0.11.1",
31
+ "@k03mad/oxlint-config": "0.12.1",
31
32
  "@tsconfig/strictest": "2.0.8",
32
33
  "@types/debug": "4.1.13",
33
- "@types/node": "26.1.1",
34
+ "@types/node": "26.1.2",
34
35
  "husky": "9.1.7",
35
- "oxfmt": "0.59.0",
36
- "oxlint": "1.74.0",
36
+ "oxfmt": "0.62.0",
37
+ "oxlint": "1.77.0",
37
38
  "typescript": "7.0.2"
38
39
  },
39
40
  "engines": {
40
41
  "node": ">=24"
42
+ },
43
+ "allowScripts": {
44
+ "esbuild@0.28.1": true,
45
+ "fsevents@2.3.3": true
41
46
  }
42
47
  }
@@ -1,8 +1,8 @@
1
1
  import assert from 'node:assert/strict';
2
2
  import {describe, it} from 'node:test';
3
3
 
4
+ import type {ReqOutput} from '../api.d.ts';
4
5
  import {ip2geo} from '../app/api.ts';
5
- import type {ReqOutput} from '../app/types.ts';
6
6
 
7
7
  import {getCurrentFilename, getTestFolder} from './helpers/path.ts';
8
8
  import {REQUEST_IPV4} from './shared/consts.ts';
@@ -1,8 +1,8 @@
1
1
  import assert from 'node:assert/strict';
2
2
  import {describe, it} from 'node:test';
3
3
 
4
+ import type {ReqOutput} from '../api.d.ts';
4
5
  import {ip2geo} from '../app/api.ts';
5
- import type {ReqOutput} from '../app/types.ts';
6
6
 
7
7
  import {getCurrentFilename, getTestFolder} from './helpers/path.ts';
8
8
  import {REQUEST_IPV4} from './shared/consts.ts';
@@ -2,8 +2,8 @@ import assert from 'node:assert/strict';
2
2
  import path from 'node:path';
3
3
  import {describe, it} from 'node:test';
4
4
 
5
+ import type {ReqOutput} from '../api.d.ts';
5
6
  import {ip2geo} from '../app/api.ts';
6
- import type {ReqOutput} from '../app/types.ts';
7
7
 
8
8
  import {getCurrentFilename, getTestFolder} from './helpers/path.ts';
9
9
  import {REQUEST_IPV4} from './shared/consts.ts';
@@ -1,8 +1,8 @@
1
1
  import assert from 'node:assert/strict';
2
2
  import {describe, it} from 'node:test';
3
3
 
4
+ import type {ReqOutput} from '../api.d.ts';
4
5
  import {ip2geo} from '../app/api.ts';
5
- import type {ReqOutput} from '../app/types.ts';
6
6
 
7
7
  import {getCurrentFilename, getTestFolder} from './helpers/path.ts';
8
8
  import {REQUEST_IPV4, REQUEST_IPV6} from './shared/consts.ts';
@@ -28,12 +28,12 @@ describe(testName, () => {
28
28
  assert.deepEqual(opts.cacheMap.get(REQUEST_IPV4.ip ?? ''), REQUEST_IPV4);
29
29
  });
30
30
 
31
- it.skip(`should return correct response for IP: "${REQUEST_IPV6.ip}"`, async () => {
31
+ it(`should return correct response for IP: "${REQUEST_IPV6.ip}"`, async () => {
32
32
  const data = await ip2geo({ip: REQUEST_IPV6.ip ?? '', ...opts});
33
33
  assert.deepEqual(data, REQUEST_IPV6);
34
34
  });
35
35
 
36
- it.skip('should have 2 correct cache entries', () => {
36
+ it('should have 2 correct cache entries', () => {
37
37
  assert.equal(opts.cacheMap.size, 2);
38
38
  assert.deepEqual(opts.cacheMap.get(REQUEST_IPV4.ip ?? ''), REQUEST_IPV4);
39
39
  assert.deepEqual(opts.cacheMap.get(REQUEST_IPV6.ip ?? ''), REQUEST_IPV6);
@@ -1,8 +1,8 @@
1
1
  import assert from 'node:assert/strict';
2
2
  import {describe, it} from 'node:test';
3
3
 
4
+ import type {ReqOutput} from '../api.d.ts';
4
5
  import {ip2geo} from '../app/api.ts';
5
- import type {ReqOutput} from '../app/types.ts';
6
6
 
7
7
  import {getCurrentFilename, getTestFolder} from './helpers/path.ts';
8
8
  import {removeCacheFolder} from './shared/fs.ts';
package/tests/default.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import assert from 'node:assert/strict';
2
2
  import {describe, it} from 'node:test';
3
3
 
4
+ import type {ReqOutput} from '../api.d.ts';
4
5
  import {cacheStorage, ip2geo} from '../app/api.ts';
5
- import type {ReqOutput} from '../app/types.ts';
6
6
 
7
7
  import {getCurrentFilename} from './helpers/path.ts';
8
8
  import {REQUEST_IPV4} from './shared/consts.ts';
@@ -1,8 +1,8 @@
1
1
  import assert from 'node:assert/strict';
2
2
  import {describe, it} from 'node:test';
3
3
 
4
+ import type {ReqOutput} from '../api.d.ts';
4
5
  import {ip2geo} from '../app/api.ts';
5
- import type {ReqOutput} from '../app/types.ts';
6
6
 
7
7
  import {getCurrentFilename, getTestFolder} from './helpers/path.ts';
8
8
  import {REQUEST_IPV4} from './shared/consts.ts';
@@ -1,8 +1,8 @@
1
1
  import assert from 'node:assert/strict';
2
2
  import {describe, it} from 'node:test';
3
3
 
4
+ import type {ReqOutput} from '../api.d.ts';
4
5
  import {ip2geo} from '../app/api.ts';
5
- import type {ReqOutput} from '../app/types.ts';
6
6
 
7
7
  import {getCurrentFilename, getTestFolder} from './helpers/path.ts';
8
8
  import {REQUEST_IPV4} from './shared/consts.ts';
package/tests/ip-v6.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import assert from 'node:assert/strict';
2
2
  import {describe, it} from 'node:test';
3
3
 
4
+ import type {ReqOutput} from '../api.d.ts';
4
5
  import {ip2geo} from '../app/api.ts';
5
- import type {ReqOutput} from '../app/types.ts';
6
6
 
7
7
  import {getCurrentFilename, getTestFolder} from './helpers/path.ts';
8
8
  import {REQUEST_IPV6} from './shared/consts.ts';
@@ -10,7 +10,7 @@ import {checkCacheFile, removeCacheFolder} from './shared/fs.ts';
10
10
 
11
11
  const testName = getCurrentFilename(import.meta.url);
12
12
 
13
- describe.skip(testName, () => {
13
+ describe(testName, () => {
14
14
  const opts = {
15
15
  cacheDir: getTestFolder(testName),
16
16
  cacheMap: new Map<string, ReqOutput>(),
@@ -1,4 +1,4 @@
1
- import type {ReqOutput} from '../../app/types.ts';
1
+ import type {ReqOutput} from '../../api.d.ts';
2
2
 
3
3
  export const REQUEST_IPV4: ReqOutput = {
4
4
  ip: '8.8.8.8',
@@ -9,7 +9,7 @@ export const REQUEST_IPV4: ReqOutput = {
9
9
  countryEmoji: 'πŸ‡ΊπŸ‡Έ',
10
10
  region: 'California',
11
11
  regionCode: 'CA',
12
- city: 'Mountain View',
12
+ city: 'San Jose',
13
13
  connectionAsn: 15_169,
14
14
  connectionOrg: 'Google LLC',
15
15
  connectionIsp: 'Google LLC',
@@ -25,7 +25,7 @@ export const REQUEST_IPV4_MAP_OFF_ONLY: ReqOutput = {
25
25
  countryEmoji: 'πŸ‡ΊπŸ‡Έ',
26
26
  region: 'California',
27
27
  regionCode: 'CA',
28
- city: 'Berkeley',
28
+ city: 'San Francisco',
29
29
  connectionAsn: 19_281,
30
30
  connectionOrg: 'Quad9',
31
31
  connectionIsp: 'Quad9',
@@ -34,16 +34,16 @@ export const REQUEST_IPV4_MAP_OFF_ONLY: ReqOutput = {
34
34
 
35
35
  export const REQUEST_IPV6: ReqOutput = {
36
36
  ip: '2a00:dd80:40:100::',
37
- continent: 'North America',
38
- continentCode: 'NA',
39
- country: 'United States',
40
- countryCode: 'US',
41
- countryEmoji: 'πŸ‡ΊπŸ‡Έ',
42
- region: 'District of Columbia',
43
- regionCode: 'DC',
44
- city: 'Washington',
37
+ continent: 'Europe',
38
+ continentCode: 'EU',
39
+ country: 'Poland',
40
+ countryCode: 'PL',
41
+ countryEmoji: 'πŸ‡΅πŸ‡±',
42
+ region: 'Masovian Voivodeship',
43
+ regionCode: '14',
44
+ city: 'Warsaw',
45
45
  connectionAsn: 36_236,
46
- connectionOrg: 'Netactuate INC',
47
- connectionIsp: 'Netactuate, INC',
46
+ connectionOrg: 'NetActuate Inc',
47
+ connectionIsp: 'NetActuate, Inc',
48
48
  connectionDomain: 'netactuate.com',
49
49
  };
@@ -2,13 +2,13 @@ import assert from 'node:assert/strict';
2
2
  import fs from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
 
5
+ import type {ReqOutput} from '../../api.d.ts';
5
6
  import {
6
7
  DEFAULT_CACHE_FILE_DIR,
7
8
  DEFAULT_CACHE_FILE_NAME,
8
9
  DEFAULT_CACHE_FILE_NEWLINE,
9
10
  DEFAULT_CACHE_FILE_SEPARATOR,
10
11
  } from '../../app/api.ts';
11
- import type {ReqOutput} from '../../app/types.ts';
12
12
 
13
13
  interface CheckCacheFileOpts {
14
14
  cacheDir?: string;
package/app/types.ts DELETED
@@ -1,15 +0,0 @@
1
- export interface ReqOutput {
2
- ip?: string;
3
- continent?: string;
4
- continentCode?: string;
5
- country?: string;
6
- countryCode?: string;
7
- countryEmoji?: string;
8
- region?: string;
9
- regionCode?: string;
10
- city?: string;
11
- connectionAsn?: number;
12
- connectionOrg?: string;
13
- connectionIsp?: string;
14
- connectionDomain?: string;
15
- }