@k03mad/ip2geo 21.0.0 → 21.0.2

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": "21.0.0",
3
+ "version": "21.0.2",
4
4
  "description": "GeoIP library",
5
5
  "license": "MIT",
6
6
  "maintainers": [
@@ -15,6 +15,7 @@
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",
@@ -27,7 +28,7 @@
27
28
  "tsx": "4.23.8"
28
29
  },
29
30
  "devDependencies": {
30
- "@k03mad/oxlint-config": "0.12.1",
31
+ "@k03mad/oxlint-config": "0.12.2",
31
32
  "@tsconfig/strictest": "2.0.8",
32
33
  "@types/debug": "4.1.13",
33
34
  "@types/node": "26.1.2",
@@ -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';
@@ -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';
@@ -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',
@@ -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
- }