lunartools-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/LICENSE +16 -0
- package/README.md +179 -0
- package/dist/index.d.mts +72 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.js +18 -0
- package/dist/index.mjs +0 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Copyright (c) 2025 Lunar Tools. All rights reserved.
|
|
2
|
+
|
|
3
|
+
This software and associated documentation files (the "Software") are proprietary
|
|
4
|
+
and confidential to Lunar Tools.
|
|
5
|
+
|
|
6
|
+
Unauthorized copying, modification, distribution, or use of this Software,
|
|
7
|
+
via any medium, is strictly prohibited without the express written permission
|
|
8
|
+
of Lunar Tools.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
11
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
12
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
13
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
14
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Lunar Tools SDK
|
|
2
|
+
|
|
3
|
+
Official TypeScript/JavaScript SDK for the Lunar Tools API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
```bash
|
|
7
|
+
npm install @lunartools/sdk
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
```typescript
|
|
12
|
+
import { Client } from '@lunartools/sdk';
|
|
13
|
+
|
|
14
|
+
// Initialize with your client credentials
|
|
15
|
+
const client = new Client({
|
|
16
|
+
clientId: 'your-client-id',
|
|
17
|
+
accessToken: 'your-access-token'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Add product to inventory
|
|
21
|
+
await client.addProduct({
|
|
22
|
+
name: 'Charizard VMAX',
|
|
23
|
+
sku: 'SWSH-074',
|
|
24
|
+
qty: 5,
|
|
25
|
+
value: 150.00,
|
|
26
|
+
spent: 120.00,
|
|
27
|
+
size: 'Standard',
|
|
28
|
+
store: 'TCGPlayer'
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
await client.addOrder({
|
|
32
|
+
name: 'Pokemon Booster Box',
|
|
33
|
+
status: 'shipped',
|
|
34
|
+
orderNumber: 'ORD-12345',
|
|
35
|
+
price: '120.00',
|
|
36
|
+
orderTotal: '132.00',
|
|
37
|
+
retailer: 'Amazon',
|
|
38
|
+
tracking: '1Z999AA10123456784'
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Forward webhook to Discord
|
|
42
|
+
const response = await client.webhook('https://www.lunartools.co/api/webhooks/YOUR_TOKEN_HERE',
|
|
43
|
+
{
|
|
44
|
+
content: 'New product in stock!',
|
|
45
|
+
embeds: [{
|
|
46
|
+
title: 'Product Alert',
|
|
47
|
+
description: 'Charizard VMAX is now available',
|
|
48
|
+
color: 0x5865F2,
|
|
49
|
+
fields: [
|
|
50
|
+
{ name: 'Price', value: '$150.00', inline: true },
|
|
51
|
+
{ name: 'Quantity', value: '5', inline: true }
|
|
52
|
+
],
|
|
53
|
+
timestamp: new Date().toISOString()
|
|
54
|
+
}]
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
console.log(response); // { status: 'queued', queueLength: 1 }
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## API Reference
|
|
62
|
+
|
|
63
|
+
### Constructor
|
|
64
|
+
```typescript
|
|
65
|
+
new Client(config: Config)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Config:**
|
|
69
|
+
- `clientId` (string, required) - Your client ID from Lunar Tools
|
|
70
|
+
- `accessToken` (string, required) - Your access token from Lunar Tools
|
|
71
|
+
- `baseUrl` (string, optional) - Custom API base URL (defaults to https://www.lunartools.co)
|
|
72
|
+
|
|
73
|
+
### Methods
|
|
74
|
+
|
|
75
|
+
#### `addProduct(product: AddProduct): Promise<void>`
|
|
76
|
+
|
|
77
|
+
Add a new product to inventory.
|
|
78
|
+
|
|
79
|
+
**Required fields:**
|
|
80
|
+
- `name` (string) - Product name
|
|
81
|
+
- `sku` (string) - Product SKU
|
|
82
|
+
- `qty` (number) - Quantity
|
|
83
|
+
|
|
84
|
+
**Optional fields:**
|
|
85
|
+
- `size` (string) - Product size
|
|
86
|
+
- `store` (string) - Store name
|
|
87
|
+
- `value` (number) - Product value
|
|
88
|
+
- `spent` (number) - Amount spent
|
|
89
|
+
|
|
90
|
+
**Example:**
|
|
91
|
+
```typescript
|
|
92
|
+
await client.addProduct({
|
|
93
|
+
name: 'Product Name',
|
|
94
|
+
sku: 'SKU-123',
|
|
95
|
+
qty: 10,
|
|
96
|
+
value: 50.00
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### `addOrder(order: AddOrder): Promise<void>`
|
|
101
|
+
|
|
102
|
+
Add a new order.
|
|
103
|
+
|
|
104
|
+
**Required fields:**
|
|
105
|
+
- `name` (string) - Order name
|
|
106
|
+
- `status` (string) - Order status
|
|
107
|
+
- `orderNumber` (string) - Order number
|
|
108
|
+
|
|
109
|
+
**Optional fields:**
|
|
110
|
+
- `image` (string) - Product image URL
|
|
111
|
+
- `tracking` (string) - Tracking number
|
|
112
|
+
- `date` (string) - Order date
|
|
113
|
+
- `qty` (string) - Quantity
|
|
114
|
+
- `price` (string) - Item price
|
|
115
|
+
- `orderTotal` (string) - Total order amount
|
|
116
|
+
- `account` (string) - Account name
|
|
117
|
+
- `retailer` (string) - Retailer name
|
|
118
|
+
- `tags` (string) - Order tags
|
|
119
|
+
|
|
120
|
+
**Example:**
|
|
121
|
+
```typescript
|
|
122
|
+
await client.addOrder({
|
|
123
|
+
name: 'Pokemon Cards',
|
|
124
|
+
status: 'delivered',
|
|
125
|
+
orderNumber: 'ORD-456',
|
|
126
|
+
price: '99.99',
|
|
127
|
+
retailer: 'eBay'
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### `forwardWebhook(webhookUrl: string, payload: DiscordWebhookPayload): Promise<WebhookResponse>`
|
|
132
|
+
|
|
133
|
+
Forward a webhook payload to Discord.
|
|
134
|
+
|
|
135
|
+
**Parameters:**
|
|
136
|
+
- `webhookUrl` (string) - Full Lunar Tools webhook URL
|
|
137
|
+
- `payload` (DiscordWebhookPayload) - Discord webhook payload
|
|
138
|
+
|
|
139
|
+
**Payload structure:**
|
|
140
|
+
- `content` (string, optional) - Message content
|
|
141
|
+
- `username` (string, optional) - Override webhook username
|
|
142
|
+
- `avatarUrl` (string, optional) - Override webhook avatar
|
|
143
|
+
- `embeds` (Embed[], optional) - Array of embeds (max 10)
|
|
144
|
+
|
|
145
|
+
**Example:**
|
|
146
|
+
```typescript
|
|
147
|
+
const response = await client.webhook('https://www.lunartools.co/api/webhooks/TOKEN',
|
|
148
|
+
{
|
|
149
|
+
content: 'Hello!',
|
|
150
|
+
embeds: [{
|
|
151
|
+
title: 'Alert',
|
|
152
|
+
description: 'Something happened',
|
|
153
|
+
color: 0xFF0000,
|
|
154
|
+
fields: [
|
|
155
|
+
{ name: 'Field 1', value: 'Value 1', inline: true }
|
|
156
|
+
]
|
|
157
|
+
}]
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Error Handling
|
|
163
|
+
|
|
164
|
+
The SDK validates all inputs and throws descriptive errors:
|
|
165
|
+
```typescript
|
|
166
|
+
try {
|
|
167
|
+
await client.addProduct({
|
|
168
|
+
name: '',
|
|
169
|
+
sku: 'SKU-123',
|
|
170
|
+
qty: 5
|
|
171
|
+
});
|
|
172
|
+
} catch (error) {
|
|
173
|
+
console.error(error.message);
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
interface Config {
|
|
2
|
+
clientId: string;
|
|
3
|
+
accessToken: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
interface Thumbnail {
|
|
7
|
+
url?: string;
|
|
8
|
+
}
|
|
9
|
+
interface Image {
|
|
10
|
+
url?: string;
|
|
11
|
+
}
|
|
12
|
+
interface Footer {
|
|
13
|
+
text?: string;
|
|
14
|
+
iconUrl?: string;
|
|
15
|
+
}
|
|
16
|
+
interface Author {
|
|
17
|
+
name?: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
iconUrl?: string;
|
|
20
|
+
}
|
|
21
|
+
interface Field {
|
|
22
|
+
name: string;
|
|
23
|
+
value: string;
|
|
24
|
+
inline?: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface Embed {
|
|
27
|
+
author?: Author;
|
|
28
|
+
title?: string;
|
|
29
|
+
url?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
color?: number;
|
|
32
|
+
fields?: Field[];
|
|
33
|
+
thumbnail?: Thumbnail;
|
|
34
|
+
image?: Image;
|
|
35
|
+
footer?: Footer;
|
|
36
|
+
timestamp?: string;
|
|
37
|
+
}
|
|
38
|
+
interface Webhook {
|
|
39
|
+
username?: string;
|
|
40
|
+
avatarUrl?: string;
|
|
41
|
+
content?: string;
|
|
42
|
+
embeds?: Embed[];
|
|
43
|
+
}
|
|
44
|
+
interface WebhookResponse {
|
|
45
|
+
status: string;
|
|
46
|
+
queueLength: number;
|
|
47
|
+
}
|
|
48
|
+
interface AddProduct {
|
|
49
|
+
name: string;
|
|
50
|
+
sku: string;
|
|
51
|
+
qty: number;
|
|
52
|
+
size?: string;
|
|
53
|
+
store?: string;
|
|
54
|
+
value?: number;
|
|
55
|
+
spent?: number;
|
|
56
|
+
}
|
|
57
|
+
interface AddOrder {
|
|
58
|
+
name: string;
|
|
59
|
+
status: string;
|
|
60
|
+
orderNumber: string;
|
|
61
|
+
image?: string;
|
|
62
|
+
tracking?: string;
|
|
63
|
+
date?: string;
|
|
64
|
+
qty?: string;
|
|
65
|
+
price?: string;
|
|
66
|
+
orderTotal?: string;
|
|
67
|
+
account?: string;
|
|
68
|
+
retailer?: string;
|
|
69
|
+
tags?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type { AddOrder, AddProduct, Author, Config, Embed, Field, Footer, Image, Thumbnail, Webhook, WebhookResponse };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
interface Config {
|
|
2
|
+
clientId: string;
|
|
3
|
+
accessToken: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
interface Thumbnail {
|
|
7
|
+
url?: string;
|
|
8
|
+
}
|
|
9
|
+
interface Image {
|
|
10
|
+
url?: string;
|
|
11
|
+
}
|
|
12
|
+
interface Footer {
|
|
13
|
+
text?: string;
|
|
14
|
+
iconUrl?: string;
|
|
15
|
+
}
|
|
16
|
+
interface Author {
|
|
17
|
+
name?: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
iconUrl?: string;
|
|
20
|
+
}
|
|
21
|
+
interface Field {
|
|
22
|
+
name: string;
|
|
23
|
+
value: string;
|
|
24
|
+
inline?: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface Embed {
|
|
27
|
+
author?: Author;
|
|
28
|
+
title?: string;
|
|
29
|
+
url?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
color?: number;
|
|
32
|
+
fields?: Field[];
|
|
33
|
+
thumbnail?: Thumbnail;
|
|
34
|
+
image?: Image;
|
|
35
|
+
footer?: Footer;
|
|
36
|
+
timestamp?: string;
|
|
37
|
+
}
|
|
38
|
+
interface Webhook {
|
|
39
|
+
username?: string;
|
|
40
|
+
avatarUrl?: string;
|
|
41
|
+
content?: string;
|
|
42
|
+
embeds?: Embed[];
|
|
43
|
+
}
|
|
44
|
+
interface WebhookResponse {
|
|
45
|
+
status: string;
|
|
46
|
+
queueLength: number;
|
|
47
|
+
}
|
|
48
|
+
interface AddProduct {
|
|
49
|
+
name: string;
|
|
50
|
+
sku: string;
|
|
51
|
+
qty: number;
|
|
52
|
+
size?: string;
|
|
53
|
+
store?: string;
|
|
54
|
+
value?: number;
|
|
55
|
+
spent?: number;
|
|
56
|
+
}
|
|
57
|
+
interface AddOrder {
|
|
58
|
+
name: string;
|
|
59
|
+
status: string;
|
|
60
|
+
orderNumber: string;
|
|
61
|
+
image?: string;
|
|
62
|
+
tracking?: string;
|
|
63
|
+
date?: string;
|
|
64
|
+
qty?: string;
|
|
65
|
+
price?: string;
|
|
66
|
+
orderTotal?: string;
|
|
67
|
+
account?: string;
|
|
68
|
+
retailer?: string;
|
|
69
|
+
tags?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type { AddOrder, AddProduct, Author, Config, Embed, Field, Footer, Image, Thumbnail, Webhook, WebhookResponse };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var index_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(index_exports);
|
package/dist/index.mjs
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lunartools-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Official SDK for Lunar Tools API",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"license": "UNLICENSED",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/senpai0807/lunartools-sdk-js.git"
|
|
12
|
+
},
|
|
13
|
+
"author": "Lunar Tools",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.mjs",
|
|
18
|
+
"require": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
23
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
24
|
+
"prepublishOnly": "npm run build"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"lunar",
|
|
28
|
+
"tools",
|
|
29
|
+
"sdk",
|
|
30
|
+
"api",
|
|
31
|
+
"inventory",
|
|
32
|
+
"orders"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"axios": "^1.6.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^24.10.0",
|
|
39
|
+
"tsup": "^8.0.0",
|
|
40
|
+
"typescript": "^5.0.0"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist"
|
|
44
|
+
]
|
|
45
|
+
}
|