@shadowob/sdk 0.2.2 → 0.2.3
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 +661 -0
- package/package.json +1 -1
- package/src/client.ts +619 -17
- package/src/index.ts +17 -0
- package/src/socket.ts +23 -1
- package/src/types.ts +186 -0
package/src/index.ts
CHANGED
|
@@ -29,19 +29,36 @@ export type {
|
|
|
29
29
|
ReactionPayload,
|
|
30
30
|
ServerEventMap,
|
|
31
31
|
ServerJoinedPayload,
|
|
32
|
+
ShadowApp,
|
|
32
33
|
ShadowAttachment,
|
|
34
|
+
ShadowCartItem,
|
|
35
|
+
ShadowCategory,
|
|
33
36
|
ShadowChannel,
|
|
34
37
|
ShadowChannelPolicy,
|
|
38
|
+
ShadowContract,
|
|
35
39
|
ShadowDmChannel,
|
|
40
|
+
ShadowFriendship,
|
|
36
41
|
ShadowInviteCode,
|
|
42
|
+
ShadowListing,
|
|
37
43
|
ShadowMember,
|
|
38
44
|
ShadowMessage,
|
|
39
45
|
ShadowNotification,
|
|
46
|
+
ShadowNotificationPreferences,
|
|
47
|
+
ShadowOAuthApp,
|
|
48
|
+
ShadowOAuthConsent,
|
|
49
|
+
ShadowOAuthToken,
|
|
50
|
+
ShadowOrder,
|
|
51
|
+
ShadowProduct,
|
|
40
52
|
ShadowRemoteChannel,
|
|
41
53
|
ShadowRemoteConfig,
|
|
42
54
|
ShadowRemoteServer,
|
|
55
|
+
ShadowReview,
|
|
43
56
|
ShadowServer,
|
|
57
|
+
ShadowShop,
|
|
58
|
+
ShadowTask,
|
|
44
59
|
ShadowThread,
|
|
60
|
+
ShadowTransaction,
|
|
45
61
|
ShadowUser,
|
|
62
|
+
ShadowWallet,
|
|
46
63
|
TypingPayload,
|
|
47
64
|
} from './types'
|
package/src/socket.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { io, type Socket } from 'socket.io-client'
|
|
|
2
2
|
import type { ClientEventMap, ServerEventMap } from './types'
|
|
3
3
|
|
|
4
4
|
export interface ShadowSocketOptions {
|
|
5
|
-
/** Shadow server base URL (e.g. "https://
|
|
5
|
+
/** Shadow server base URL (e.g. "https://shadowob.shadowob.com") */
|
|
6
6
|
serverUrl: string
|
|
7
7
|
/** JWT token for authentication */
|
|
8
8
|
token: string
|
|
@@ -177,4 +177,26 @@ export class ShadowSocket {
|
|
|
177
177
|
updateActivity(channelId: string, activity: string | null): void {
|
|
178
178
|
this.socket.emit('presence:activity' satisfies keyof ClientEventMap, { channelId, activity })
|
|
179
179
|
}
|
|
180
|
+
|
|
181
|
+
// ── DM actions ────────────────────────────────────────────────────────
|
|
182
|
+
|
|
183
|
+
/** Join a DM channel room */
|
|
184
|
+
joinDmChannel(dmChannelId: string): void {
|
|
185
|
+
this.socket.emit('dm:join' as string, { dmChannelId })
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** Leave a DM channel room */
|
|
189
|
+
leaveDmChannel(dmChannelId: string): void {
|
|
190
|
+
this.socket.emit('dm:leave' as string, { dmChannelId })
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Send a DM message via WebSocket */
|
|
194
|
+
sendDmMessage(data: { dmChannelId: string; content: string; replyToId?: string }): void {
|
|
195
|
+
this.socket.emit('dm:send' as string, data)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Send a DM typing indicator */
|
|
199
|
+
sendDmTyping(dmChannelId: string): void {
|
|
200
|
+
this.socket.emit('dm:typing' as string, { dmChannelId })
|
|
201
|
+
}
|
|
180
202
|
}
|
package/src/types.ts
CHANGED
|
@@ -209,9 +209,195 @@ export interface DmMessage {
|
|
|
209
209
|
content: string
|
|
210
210
|
senderId: string
|
|
211
211
|
receiverId: string
|
|
212
|
+
dmChannelId: string
|
|
213
|
+
channelId: string
|
|
214
|
+
authorId: string
|
|
215
|
+
author?: {
|
|
216
|
+
id: string
|
|
217
|
+
username: string
|
|
218
|
+
displayName?: string
|
|
219
|
+
avatarUrl?: string
|
|
220
|
+
isBot?: boolean
|
|
221
|
+
}
|
|
222
|
+
createdAt: string
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// ─── Friendship Types ───────────────────────────────────────────────────────
|
|
226
|
+
|
|
227
|
+
export interface ShadowFriendship {
|
|
228
|
+
id: string
|
|
229
|
+
userId: string
|
|
230
|
+
friendId: string
|
|
231
|
+
status: 'pending' | 'accepted' | 'rejected'
|
|
232
|
+
createdAt: string
|
|
233
|
+
user?: ShadowUser
|
|
234
|
+
friend?: ShadowUser
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// ─── OAuth App Types ────────────────────────────────────────────────────────
|
|
238
|
+
|
|
239
|
+
export interface ShadowOAuthApp {
|
|
240
|
+
id: string
|
|
241
|
+
name: string
|
|
242
|
+
clientId: string
|
|
243
|
+
clientSecret?: string
|
|
244
|
+
redirectUris: string[]
|
|
245
|
+
scopes: string[]
|
|
246
|
+
createdAt: string
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface ShadowOAuthConsent {
|
|
250
|
+
id: string
|
|
251
|
+
appId: string
|
|
252
|
+
appName: string
|
|
253
|
+
scopes: string[]
|
|
212
254
|
createdAt: string
|
|
213
255
|
}
|
|
214
256
|
|
|
257
|
+
export interface ShadowOAuthToken {
|
|
258
|
+
access_token: string
|
|
259
|
+
token_type: string
|
|
260
|
+
expires_in: number
|
|
261
|
+
refresh_token?: string
|
|
262
|
+
scope: string
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ─── Marketplace / Rental Types ─────────────────────────────────────────────
|
|
266
|
+
|
|
267
|
+
export interface ShadowListing {
|
|
268
|
+
id: string
|
|
269
|
+
agentId: string
|
|
270
|
+
title: string
|
|
271
|
+
description: string
|
|
272
|
+
pricePerHour: number
|
|
273
|
+
currency: string
|
|
274
|
+
tags: string[]
|
|
275
|
+
isActive: boolean
|
|
276
|
+
createdAt: string
|
|
277
|
+
agent?: { id: string; name: string; status: string }
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export interface ShadowContract {
|
|
281
|
+
id: string
|
|
282
|
+
listingId: string
|
|
283
|
+
tenantId: string
|
|
284
|
+
ownerId: string
|
|
285
|
+
status: string
|
|
286
|
+
startedAt: string
|
|
287
|
+
expiresAt: string
|
|
288
|
+
totalCost: number
|
|
289
|
+
createdAt: string
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// ─── Shop Types ─────────────────────────────────────────────────────────────
|
|
293
|
+
|
|
294
|
+
export interface ShadowShop {
|
|
295
|
+
id: string
|
|
296
|
+
serverId: string
|
|
297
|
+
name: string
|
|
298
|
+
description?: string | null
|
|
299
|
+
isEnabled: boolean
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface ShadowCategory {
|
|
303
|
+
id: string
|
|
304
|
+
shopId: string
|
|
305
|
+
name: string
|
|
306
|
+
description?: string | null
|
|
307
|
+
position: number
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export interface ShadowProduct {
|
|
311
|
+
id: string
|
|
312
|
+
shopId: string
|
|
313
|
+
categoryId?: string | null
|
|
314
|
+
name: string
|
|
315
|
+
description?: string | null
|
|
316
|
+
price: number
|
|
317
|
+
currency: string
|
|
318
|
+
stock: number
|
|
319
|
+
status: string
|
|
320
|
+
images: string[]
|
|
321
|
+
createdAt: string
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export interface ShadowCartItem {
|
|
325
|
+
id: string
|
|
326
|
+
productId: string
|
|
327
|
+
quantity: number
|
|
328
|
+
product?: ShadowProduct
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export interface ShadowOrder {
|
|
332
|
+
id: string
|
|
333
|
+
shopId: string
|
|
334
|
+
buyerId: string
|
|
335
|
+
status: string
|
|
336
|
+
totalAmount: number
|
|
337
|
+
currency: string
|
|
338
|
+
items: { productId: string; quantity: number; price: number }[]
|
|
339
|
+
createdAt: string
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export interface ShadowReview {
|
|
343
|
+
id: string
|
|
344
|
+
orderId: string
|
|
345
|
+
productId: string
|
|
346
|
+
userId: string
|
|
347
|
+
rating: number
|
|
348
|
+
content: string
|
|
349
|
+
reply?: string | null
|
|
350
|
+
createdAt: string
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export interface ShadowWallet {
|
|
354
|
+
id: string
|
|
355
|
+
userId: string
|
|
356
|
+
balance: number
|
|
357
|
+
currency: string
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export interface ShadowTransaction {
|
|
361
|
+
id: string
|
|
362
|
+
walletId: string
|
|
363
|
+
type: string
|
|
364
|
+
amount: number
|
|
365
|
+
description?: string | null
|
|
366
|
+
createdAt: string
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// ─── Task Center Types ──────────────────────────────────────────────────────
|
|
370
|
+
|
|
371
|
+
export interface ShadowTask {
|
|
372
|
+
key: string
|
|
373
|
+
title: string
|
|
374
|
+
description: string
|
|
375
|
+
reward: number
|
|
376
|
+
status: string
|
|
377
|
+
claimedAt?: string | null
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// ─── App Types ──────────────────────────────────────────────────────────────
|
|
381
|
+
|
|
382
|
+
export interface ShadowApp {
|
|
383
|
+
id: string
|
|
384
|
+
serverId: string
|
|
385
|
+
name: string
|
|
386
|
+
slug: string
|
|
387
|
+
type: string
|
|
388
|
+
url?: string | null
|
|
389
|
+
status: string
|
|
390
|
+
createdAt: string
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// ─── Notification Preferences ───────────────────────────────────────────────
|
|
394
|
+
|
|
395
|
+
export interface ShadowNotificationPreferences {
|
|
396
|
+
strategy: 'all' | 'mention_only' | 'none'
|
|
397
|
+
mutedServerIds: string[]
|
|
398
|
+
mutedChannelIds: string[]
|
|
399
|
+
}
|
|
400
|
+
|
|
215
401
|
// ─── Socket Event Map ───────────────────────────────────────────────────────
|
|
216
402
|
|
|
217
403
|
/** Events the server pushes to the client */
|