@vintr/node-sdk 1.0.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/README.md +70 -0
- package/dist/alias.d.ts +7 -0
- package/dist/alias.js +8 -0
- package/dist/client.d.ts +8 -0
- package/dist/client.js +44 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/types.d.ts +38 -0
- package/dist/types.js +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @vintr/node-sdk
|
|
2
|
+
|
|
3
|
+
A minimal, elegant Node.js SDK for the Vintr Alias Resolution API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @vintr/node-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Vintr } from '@vintr/node-sdk';
|
|
15
|
+
|
|
16
|
+
const vintr = new Vintr('vintr_secret_key');
|
|
17
|
+
|
|
18
|
+
const location = await vintr.alias.resolve({ alias: 'apple#vintr' });
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
### `vintr.alias.resolve({ alias })`
|
|
24
|
+
|
|
25
|
+
Resolves an alias to its associated location and metadata.
|
|
26
|
+
|
|
27
|
+
**Parameters:**
|
|
28
|
+
- `alias` (string): The alias to resolve in full format with suffix (e.g., `apple#vintr`, `asteik#vintr`, `sushi#vintr`)
|
|
29
|
+
|
|
30
|
+
**Returns:** `AliasResponse` with location details, coordinates, and delivery instructions.
|
|
31
|
+
|
|
32
|
+
**Sample Response:**
|
|
33
|
+
```typescript
|
|
34
|
+
{
|
|
35
|
+
alias: "apple#vintr",
|
|
36
|
+
type: "business",
|
|
37
|
+
location: {
|
|
38
|
+
address: {
|
|
39
|
+
line1: "1 Apple Park Way",
|
|
40
|
+
line2: "",
|
|
41
|
+
line3: "",
|
|
42
|
+
city: "Cupertino",
|
|
43
|
+
state: "California",
|
|
44
|
+
postal_code: "95014",
|
|
45
|
+
country: "US"
|
|
46
|
+
},
|
|
47
|
+
geo: {
|
|
48
|
+
latitude: 37.335,
|
|
49
|
+
longitude: -122.0092,
|
|
50
|
+
altitude: null,
|
|
51
|
+
precision_meters: 5
|
|
52
|
+
},
|
|
53
|
+
instructions: {
|
|
54
|
+
general: "Enter through the main visitor entrance.",
|
|
55
|
+
delivery: "Use the designated delivery entrance.",
|
|
56
|
+
autonomous: "Approach from the east access road."
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
createdAt: "2026-08-18T20:39:52.671Z",
|
|
60
|
+
updatedAt: "2026-08-18T20:39:52.671Z"
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## TypeScript Support
|
|
65
|
+
|
|
66
|
+
Full TypeScript support included with exported types:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import type { AliasResponse, Location, Address, Geo, Instructions } from '@vintr/node-sdk';
|
|
70
|
+
```
|
package/dist/alias.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { VintrClient } from './client.js';
|
|
2
|
+
import type { AliasResponse, ResolveAliasParams } from './types.js';
|
|
3
|
+
export declare class AliasAPI {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: VintrClient);
|
|
6
|
+
resolve(params: ResolveAliasParams): Promise<AliasResponse>;
|
|
7
|
+
}
|
package/dist/alias.js
ADDED
package/dist/client.d.ts
ADDED
package/dist/client.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import https from 'https';
|
|
2
|
+
export class VintrClient {
|
|
3
|
+
constructor(apiKey) {
|
|
4
|
+
this.baseUrl = 'https://api.vintr.xyz';
|
|
5
|
+
this.apiKey = apiKey;
|
|
6
|
+
}
|
|
7
|
+
async request(path) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const url = new URL(path, this.baseUrl);
|
|
10
|
+
const options = {
|
|
11
|
+
hostname: url.hostname,
|
|
12
|
+
port: url.port || 443,
|
|
13
|
+
path: url.pathname,
|
|
14
|
+
method: 'GET',
|
|
15
|
+
headers: {
|
|
16
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
17
|
+
'Content-Type': 'application/json',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
const req = https.request(options, (res) => {
|
|
21
|
+
let data = '';
|
|
22
|
+
res.on('data', (chunk) => data += chunk);
|
|
23
|
+
res.on('end', () => {
|
|
24
|
+
try {
|
|
25
|
+
if (res.statusCode === 200) {
|
|
26
|
+
resolve(JSON.parse(data));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
reject(new Error(`HTTP ${res.statusCode}: ${data}`));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
reject(new Error(`Failed to parse response: ${data}`));
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
req.on('error', reject);
|
|
38
|
+
req.end();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async resolveAlias(alias) {
|
|
42
|
+
return this.request(`/${alias}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AliasAPI } from './alias.js';
|
|
2
|
+
export declare class Vintr {
|
|
3
|
+
readonly alias: AliasAPI;
|
|
4
|
+
private client;
|
|
5
|
+
constructor(apiKey: string);
|
|
6
|
+
}
|
|
7
|
+
export type { Address, Geo, Instructions, Location, AliasResponse, ErrorResponse, ResolveAliasParams } from './types.js';
|
package/dist/index.js
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface Address {
|
|
2
|
+
line1: string;
|
|
3
|
+
line2?: string;
|
|
4
|
+
line3?: string;
|
|
5
|
+
city: string;
|
|
6
|
+
state: string;
|
|
7
|
+
postal_code: string;
|
|
8
|
+
country: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Geo {
|
|
11
|
+
latitude: number;
|
|
12
|
+
longitude: number;
|
|
13
|
+
altitude: number | null;
|
|
14
|
+
precision_meters: number;
|
|
15
|
+
}
|
|
16
|
+
export interface Instructions {
|
|
17
|
+
general: string;
|
|
18
|
+
delivery: string;
|
|
19
|
+
autonomous: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Location {
|
|
22
|
+
address: Address;
|
|
23
|
+
geo: Geo;
|
|
24
|
+
instructions: Instructions;
|
|
25
|
+
}
|
|
26
|
+
export interface AliasResponse {
|
|
27
|
+
alias: string;
|
|
28
|
+
type: 'business' | 'individual';
|
|
29
|
+
location: Location;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ErrorResponse {
|
|
34
|
+
error: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ResolveAliasParams {
|
|
37
|
+
alias: string;
|
|
38
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vintr/node-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Minimal, elegant Vintr API SDK for Node.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"vintr",
|
|
23
|
+
"api",
|
|
24
|
+
"sdk",
|
|
25
|
+
"alias",
|
|
26
|
+
"location"
|
|
27
|
+
],
|
|
28
|
+
"author": "",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^20.0.0",
|
|
32
|
+
"typescript": "^5.0.0"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@zelkea/node-sdk": "^1.0.2"
|
|
36
|
+
}
|
|
37
|
+
}
|