@sublay/js 5.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/CLAUDE.md +339 -0
- package/README.md +93 -0
- package/dist/core/client.d.ts +8 -0
- package/dist/index.d.mts +189 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +194 -0
- package/dist/index.mjs +163 -0
- package/dist/interfaces/IPaginatedResponse.d.ts +11 -0
- package/dist/modules/comments/fetchComment.d.ts +5 -0
- package/dist/modules/comments/fetchCommentByForeignId.d.ts +5 -0
- package/dist/modules/comments/index.d.ts +3 -0
- package/dist/modules/entities/createEntity.d.ts +17 -0
- package/dist/modules/entities/deleteEntity.d.ts +5 -0
- package/dist/modules/entities/fetchEntity.d.ts +5 -0
- package/dist/modules/entities/fetchEntityByForeignId.d.ts +6 -0
- package/dist/modules/entities/fetchEntityByShortId.d.ts +5 -0
- package/dist/modules/entities/fetchManyEntities.d.ts +50 -0
- package/dist/modules/entities/index.d.ts +8 -0
- package/dist/modules/entities/updateEntity.d.ts +18 -0
- package/dist/modules/users/fetchUserByForeignId.d.ts +11 -0
- package/dist/modules/users/fetchUserById.d.ts +5 -0
- package/dist/modules/users/index.d.ts +3 -0
- package/package.json +33 -0
- package/pnpm-workspace.yaml +2 -0
- package/src/core/client.ts +15 -0
- package/src/index.ts +45 -0
- package/src/interfaces/IPaginatedResponse.ts +12 -0
- package/src/modules/comments/fetchComment.ts +14 -0
- package/src/modules/comments/fetchCommentByForeignId.ts +14 -0
- package/src/modules/comments/index.ts +4 -0
- package/src/modules/entities/createEntity.ts +27 -0
- package/src/modules/entities/deleteEntity.ts +14 -0
- package/src/modules/entities/fetchEntity.ts +14 -0
- package/src/modules/entities/fetchEntityByForeignId.ts +15 -0
- package/src/modules/entities/fetchEntityByShortId.ts +14 -0
- package/src/modules/entities/fetchManyEntities.ts +79 -0
- package/src/modules/entities/index.ts +17 -0
- package/src/modules/entities/updateEntity.ts +28 -0
- package/src/modules/users/fetchUserByForeignId.ts +40 -0
- package/src/modules/users/fetchUserById.ts +15 -0
- package/src/modules/users/index.ts +4 -0
- package/tsconfig.json +14 -0
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
This is the **@sublay/js** package - the official JavaScript SDK for Sublay. It's a lightweight, framework-agnostic SDK designed for JavaScript/TypeScript projects that don't use React or don't need the full React setup from the monorepo packages.
|
|
8
|
+
|
|
9
|
+
**Package Name**: @sublay/js
|
|
10
|
+
**Version**: 5.0.0
|
|
11
|
+
**Type**: JavaScript SDK library (published to npm)
|
|
12
|
+
|
|
13
|
+
## Development Commands
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Build the package (TypeScript compilation + bundling)
|
|
17
|
+
pnpm build
|
|
18
|
+
|
|
19
|
+
# Generate TypeScript declaration files
|
|
20
|
+
pnpm build:types
|
|
21
|
+
|
|
22
|
+
# Build both (runs before publishing)
|
|
23
|
+
pnpm prepare
|
|
24
|
+
|
|
25
|
+
# Publish to npm with beta tag
|
|
26
|
+
pnpm publish-beta
|
|
27
|
+
|
|
28
|
+
# Publish to npm production
|
|
29
|
+
pnpm publish-prod
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Core Architecture
|
|
33
|
+
|
|
34
|
+
### Module Structure
|
|
35
|
+
|
|
36
|
+
The SDK is organized into 3 main API modules:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
src/
|
|
40
|
+
├── core/
|
|
41
|
+
│ └── client.ts # HTTP client wrapper using axios
|
|
42
|
+
├── modules/
|
|
43
|
+
│ ├── users/ # User operations (2 functions)
|
|
44
|
+
│ │ ├── index.ts
|
|
45
|
+
│ │ ├── fetchUserById.ts
|
|
46
|
+
│ │ └── fetchUserByForeignId.ts
|
|
47
|
+
│ ├── entities/ # Entity CRUD operations (7 functions)
|
|
48
|
+
│ │ ├── index.ts
|
|
49
|
+
│ │ ├── createEntity.ts
|
|
50
|
+
│ │ ├── fetchEntity.ts
|
|
51
|
+
│ │ ├── fetchEntityByForeignId.ts
|
|
52
|
+
│ │ ├── fetchEntityByShortId.ts
|
|
53
|
+
│ │ ├── fetchManyEntities.ts
|
|
54
|
+
│ │ ├── updateEntity.ts
|
|
55
|
+
│ │ └── deleteEntity.ts
|
|
56
|
+
│ └── comments/ # Comment operations (2 functions)
|
|
57
|
+
│ ├── index.ts
|
|
58
|
+
│ ├── fetchComment.ts
|
|
59
|
+
│ └── fetchCommentByForeignId.ts
|
|
60
|
+
└── index.ts # Main entry point with SublayClient class
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### HTTP Client
|
|
64
|
+
|
|
65
|
+
Uses a custom `SublayHttpClient` class that wraps axios with pre-configured base URL:
|
|
66
|
+
- **Base URL**: `https://api.sublay.io/api/v5/{projectId}`
|
|
67
|
+
- **Headers**: Standard axios configuration
|
|
68
|
+
- **Method**: GET/POST/PUT/DELETE operations
|
|
69
|
+
|
|
70
|
+
### Initialization Pattern
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { SublayClient } from '@sublay/js';
|
|
74
|
+
|
|
75
|
+
const client = await SublayClient.init({
|
|
76
|
+
projectId: "your-project-id"
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Client initializes and returns bound module functions
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Factory Pattern**: Uses `SublayClient.init()` for initialization, which:
|
|
83
|
+
1. Creates an HTTP client instance with the project ID
|
|
84
|
+
2. Binds all module functions to the client
|
|
85
|
+
3. Returns the client with namespaced API methods
|
|
86
|
+
|
|
87
|
+
## API Modules & Features
|
|
88
|
+
|
|
89
|
+
### 1. Users Module (2 functions)
|
|
90
|
+
|
|
91
|
+
**Functions**:
|
|
92
|
+
- `client.users.fetchUserById({ userId })` - Fetch user by Sublay ID
|
|
93
|
+
- `client.users.fetchUserByForeignId({ foreignId, name?, username?, avatar?, bio?, metadata?, secureMetadata? })` - Fetch user by external ID with optional user data
|
|
94
|
+
|
|
95
|
+
**Features**:
|
|
96
|
+
- Foreign ID support for external system integration
|
|
97
|
+
- Optional user data creation on first fetch
|
|
98
|
+
- Support for public and secure metadata
|
|
99
|
+
|
|
100
|
+
### 2. Entities Module (7 functions)
|
|
101
|
+
|
|
102
|
+
Entities are the core content objects (posts, articles, products, listings, etc.).
|
|
103
|
+
|
|
104
|
+
**Functions**:
|
|
105
|
+
- `client.entities.createEntity(data)` - Create a new entity
|
|
106
|
+
- `client.entities.fetchEntity({ entityId })` - Fetch by Sublay ID
|
|
107
|
+
- `client.entities.fetchEntityByForeignId({ foreignId })` - Fetch by external system ID
|
|
108
|
+
- `client.entities.fetchEntityByShortId({ shortId })` - Fetch by short/shareable ID
|
|
109
|
+
- `client.entities.fetchManyEntities(filters)` - Advanced querying with extensive filters
|
|
110
|
+
- `client.entities.updateEntity(data)` - Update entity
|
|
111
|
+
- `client.entities.deleteEntity({ entityId })` - Delete entity
|
|
112
|
+
|
|
113
|
+
**Create Entity Parameters**:
|
|
114
|
+
- `foreignId` - External system ID for integration
|
|
115
|
+
- `sourceId` - Source identifier (e.g., "blog", "shop")
|
|
116
|
+
- `title` - Entity title
|
|
117
|
+
- `content` - Main content/body
|
|
118
|
+
- `attachments` - Media attachments (flexible structure)
|
|
119
|
+
- `keywords` - Tags/categories
|
|
120
|
+
- `location` - Geo-location (lat/lng or GeoJSON Point)
|
|
121
|
+
- `metadata` - Custom metadata (up to 10KB)
|
|
122
|
+
- `userId` - Author/creator ID
|
|
123
|
+
|
|
124
|
+
**Advanced Filtering** (fetchManyEntities):
|
|
125
|
+
Supports extensive filtering options:
|
|
126
|
+
- **Sorting**: `hot`, `top`, `controversial`
|
|
127
|
+
- **Timeframes**: `hour`, `day`, `week`, `month`, `year`, `all`
|
|
128
|
+
- **Pagination**: `page`, `limit`
|
|
129
|
+
- **Keywords**:
|
|
130
|
+
- `keywords.includes` - Array of required tags
|
|
131
|
+
- `keywords.excludes` - Array of excluded tags
|
|
132
|
+
- **Metadata Filters**:
|
|
133
|
+
- `metadata.includes` - Object of required key-value pairs
|
|
134
|
+
- `metadata.excludes` - Object of excluded key-value pairs
|
|
135
|
+
- `metadata.exists` - Array of required metadata keys
|
|
136
|
+
- **Content Filters**:
|
|
137
|
+
- `title.includes` / `title.excludes` - Title text filtering
|
|
138
|
+
- `content.includes` / `content.excludes` - Content text filtering
|
|
139
|
+
- **Attachment Filters**:
|
|
140
|
+
- `attachments.has` - Entities with attachments
|
|
141
|
+
- `attachments.hasNot` - Entities without attachments
|
|
142
|
+
- **Location Filters**:
|
|
143
|
+
- `location.latitude` / `location.longitude` - Geo-coordinates
|
|
144
|
+
- `location.radius` - Radius in kilometers
|
|
145
|
+
- **User Filters**:
|
|
146
|
+
- `userId` - Filter by specific user
|
|
147
|
+
- `followedOnly` - Only from users the current user follows
|
|
148
|
+
|
|
149
|
+
### 3. Comments Module (2 functions)
|
|
150
|
+
|
|
151
|
+
**Functions**:
|
|
152
|
+
- `client.comments.fetchComment({ commentId })` - Fetch comment by Sublay ID
|
|
153
|
+
- `client.comments.fetchCommentByForeignId({ foreignId })` - Fetch comment by external ID
|
|
154
|
+
|
|
155
|
+
**Note**: This module currently provides read-only access. Comment creation/updates are available in other SDK packages (@sublay/node) or through direct API calls.
|
|
156
|
+
|
|
157
|
+
## Key Design Patterns
|
|
158
|
+
|
|
159
|
+
### 1. Framework-Agnostic
|
|
160
|
+
No dependencies on React, Vue, Angular, or any specific framework. Works with vanilla JavaScript, TypeScript, or any JavaScript framework.
|
|
161
|
+
|
|
162
|
+
### 2. Type Safety
|
|
163
|
+
Full TypeScript support with type definitions, though return types are currently `any` with TODOs to add proper entity types in future versions.
|
|
164
|
+
|
|
165
|
+
### 3. Function Binding
|
|
166
|
+
Module functions are bound to the HTTP client at initialization, providing a clean API without manually passing the client.
|
|
167
|
+
|
|
168
|
+
### 4. Foreign ID Support
|
|
169
|
+
Seamless integration with existing systems through foreign ID mapping on all major resources.
|
|
170
|
+
|
|
171
|
+
### 5. Location Flexibility
|
|
172
|
+
Supports both simple `{ lat, lng }` objects and GeoJSON Point format for geo-location data.
|
|
173
|
+
|
|
174
|
+
## Usage Examples
|
|
175
|
+
|
|
176
|
+
### Basic Initialization
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { SublayClient } from '@sublay/js';
|
|
180
|
+
|
|
181
|
+
const client = await SublayClient.init({
|
|
182
|
+
projectId: 'your-project-id'
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Fetching Entities
|
|
187
|
+
|
|
188
|
+
```javascript
|
|
189
|
+
// Fetch single entity
|
|
190
|
+
const entity = await client.entities.fetchEntity({
|
|
191
|
+
entityId: 'entity-123'
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Fetch by foreign ID
|
|
195
|
+
const post = await client.entities.fetchEntityByForeignId({
|
|
196
|
+
foreignId: 'blog-post-456'
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Fetch with advanced filters
|
|
200
|
+
const trendingPosts = await client.entities.fetchManyEntities({
|
|
201
|
+
sort: 'hot',
|
|
202
|
+
timeframe: 'week',
|
|
203
|
+
keywords: { includes: ['javascript', 'tutorial'] },
|
|
204
|
+
attachments: { has: true },
|
|
205
|
+
limit: 20,
|
|
206
|
+
page: 1
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Creating Entities
|
|
211
|
+
|
|
212
|
+
```javascript
|
|
213
|
+
const newEntity = await client.entities.createEntity({
|
|
214
|
+
foreignId: 'my-post-789',
|
|
215
|
+
sourceId: 'blog',
|
|
216
|
+
title: 'Getting Started with JavaScript',
|
|
217
|
+
content: 'In this tutorial, we will learn...',
|
|
218
|
+
keywords: ['javascript', 'tutorial', 'beginner'],
|
|
219
|
+
userId: 'user-123',
|
|
220
|
+
metadata: {
|
|
221
|
+
category: 'programming',
|
|
222
|
+
difficulty: 'beginner',
|
|
223
|
+
readTime: 5
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Updating Entities
|
|
229
|
+
|
|
230
|
+
```javascript
|
|
231
|
+
await client.entities.updateEntity({
|
|
232
|
+
entityId: 'entity-123',
|
|
233
|
+
title: 'Updated Title',
|
|
234
|
+
content: 'Updated content...',
|
|
235
|
+
keywords: ['updated', 'tags']
|
|
236
|
+
});
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Geo-Location Filtering
|
|
240
|
+
|
|
241
|
+
```javascript
|
|
242
|
+
// Find entities near a location
|
|
243
|
+
const nearbyPosts = await client.entities.fetchManyEntities({
|
|
244
|
+
location: {
|
|
245
|
+
latitude: 40.7128,
|
|
246
|
+
longitude: -74.0060,
|
|
247
|
+
radius: 10 // 10km radius
|
|
248
|
+
},
|
|
249
|
+
limit: 50
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Working with Users
|
|
254
|
+
|
|
255
|
+
```javascript
|
|
256
|
+
// Fetch user by ID
|
|
257
|
+
const user = await client.users.fetchUserById({
|
|
258
|
+
userId: 'user-123'
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// Fetch or create user by foreign ID
|
|
262
|
+
const externalUser = await client.users.fetchUserByForeignId({
|
|
263
|
+
foreignId: 'external-user-456',
|
|
264
|
+
name: 'John Doe',
|
|
265
|
+
username: 'johndoe',
|
|
266
|
+
avatar: 'https://example.com/avatar.jpg',
|
|
267
|
+
metadata: {
|
|
268
|
+
source: 'external-system'
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Build & Publishing
|
|
274
|
+
|
|
275
|
+
### Build Configuration
|
|
276
|
+
- **Build Tool**: tsup
|
|
277
|
+
- **Output Formats**: CommonJS and ESM (dual package)
|
|
278
|
+
- **Type Declarations**: Generated via TypeScript compiler
|
|
279
|
+
- **Target**: Modern JavaScript (ES modules)
|
|
280
|
+
- **Entry Point**: `src/index.ts`
|
|
281
|
+
|
|
282
|
+
### Output Structure
|
|
283
|
+
```
|
|
284
|
+
dist/
|
|
285
|
+
├── index.js # Main bundle (CJS/ESM)
|
|
286
|
+
└── index.d.ts # TypeScript declarations
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Publishing
|
|
290
|
+
```bash
|
|
291
|
+
# Beta release
|
|
292
|
+
pnpm publish-beta
|
|
293
|
+
|
|
294
|
+
# Production release
|
|
295
|
+
pnpm publish-prod
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Package Exports**:
|
|
299
|
+
- Main: `dist/index.js`
|
|
300
|
+
- Types: `dist/index.d.ts`
|
|
301
|
+
|
|
302
|
+
## Use Cases
|
|
303
|
+
|
|
304
|
+
This SDK is ideal for:
|
|
305
|
+
|
|
306
|
+
1. **Vanilla JavaScript Projects** - Plain JS applications without frameworks
|
|
307
|
+
2. **Non-React Frameworks** - Vue, Svelte, Angular, Solid, etc.
|
|
308
|
+
3. **Server-Side Rendering** - SSR applications without React
|
|
309
|
+
4. **Static Site Generators** - Eleventy, Hugo (with JavaScript), Astro (non-React)
|
|
310
|
+
5. **Chrome Extensions** - Browser extensions built with vanilla JS
|
|
311
|
+
6. **Electron Apps** - Desktop applications using web technologies
|
|
312
|
+
7. **Web Workers** - Background scripts and service workers
|
|
313
|
+
8. **Lightweight Integrations** - When you don't need the full React SDK overhead
|
|
314
|
+
|
|
315
|
+
Essentially any JavaScript/TypeScript project that needs Sublay integration without React dependencies.
|
|
316
|
+
|
|
317
|
+
## Technical Details
|
|
318
|
+
|
|
319
|
+
- **TypeScript**: Strict mode enabled
|
|
320
|
+
- **Dependencies**: Only axios for HTTP requests
|
|
321
|
+
- **API Version**: Uses v5 API endpoints
|
|
322
|
+
- **Bundle Size**: Lightweight (no framework dependencies)
|
|
323
|
+
- **Browser Support**: Modern browsers (ES6+)
|
|
324
|
+
- **Node.js Support**: Yes (v14+)
|
|
325
|
+
|
|
326
|
+
## Important Notes
|
|
327
|
+
|
|
328
|
+
- This SDK is **production-ready** (v5.0.0)
|
|
329
|
+
- Requires a valid project ID from Sublay dashboard
|
|
330
|
+
- Currently uses v5 API endpoints
|
|
331
|
+
- Return types are typed as `any` (TODOs exist to add proper types)
|
|
332
|
+
- No README.md file exists yet (documentation pending)
|
|
333
|
+
- Comment module has limited functionality (read-only)
|
|
334
|
+
|
|
335
|
+
## Comparison with Other SDKs
|
|
336
|
+
|
|
337
|
+
- **vs @sublay/node**: This SDK is lighter weight and framework-agnostic, while @sublay/node is optimized for Node.js server environments with more comprehensive API coverage
|
|
338
|
+
- **vs @sublay/react-js**: This SDK has no React dependencies, making it suitable for non-React projects or when you don't need React hooks and components
|
|
339
|
+
- **vs monorepo packages**: This SDK is standalone and simpler, while monorepo packages provide full React/React Native integration with hooks, contexts, and UI components
|
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @sublay/js
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@sublay/js)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
> **Backend infrastructure for user-powered products.** Pre-modeled bundles for the layers every app ends up rebuilding — comments, notifications, files, search, chat, and more. Install what you need, call through one SDK. Build the part that's actually yours.
|
|
7
|
+
|
|
8
|
+
Framework-agnostic JavaScript SDK for Sublay. For browser apps and JS runtimes that don't use React, or don't want the React provider tree.
|
|
9
|
+
|
|
10
|
+
Exposes a single `SublayClient` with module namespaces for `users`, `entities`, and `comments`.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @sublay/js
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { SublayClient } from "@sublay/js";
|
|
18
|
+
|
|
19
|
+
const sublay = await SublayClient.init({
|
|
20
|
+
projectId: "your-project-id",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const entities = await sublay.entities.list({ ... });
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
See [docs.sublay.io](https://docs.sublay.io) for the full reference.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## What is Sublay
|
|
31
|
+
|
|
32
|
+
Every user-powered product runs into the same engineering problems — content modeling, threaded discussions, permission graphs, ranking pipelines, search indexing, notification fan-out, social graphs, and moderation queues. Sublay solves them, so you don't have to.
|
|
33
|
+
|
|
34
|
+
Sublay ships these layers as **pre-modeled bundles** that attach to one shared entity model. You install the bundles you need from the dashboard, call them through any Sublay SDK, and build the part that's actually yours on top.
|
|
35
|
+
|
|
36
|
+
## Bundles you can install
|
|
37
|
+
|
|
38
|
+
- **Comments & Threads** — threaded discussions with mentions, replies, sorting
|
|
39
|
+
- **Reactions & Votes** — upvotes, downvotes, multi-emoji reactions
|
|
40
|
+
- **Spaces & Communities** — groups, sub-forums, membership
|
|
41
|
+
- **Notifications** — in-app notification fan-out with optional webhook delivery
|
|
42
|
+
- **Feeds & Discovery** — hot / top / new / controversial, filtered by tag, geography, timeframe, or follow graph
|
|
43
|
+
- **Real-Time Chat** — direct messages and group threads
|
|
44
|
+
- **Follows & Connections** — one-way follows, mutual connections
|
|
45
|
+
- **Files & Storage** — file blob storage with managed upload URLs
|
|
46
|
+
- **AI-Powered Search** — semantic search across your entity tree
|
|
47
|
+
- **Moderation** — report queues and content-removal workflows
|
|
48
|
+
|
|
49
|
+
Every bundle attaches to the same model. No mismatches, no extra databases. One schema for everything.
|
|
50
|
+
|
|
51
|
+
## How it works
|
|
52
|
+
|
|
53
|
+
1. Create a project at [dash.sublay.io](https://dash.sublay.io) and install the bundles you need.
|
|
54
|
+
2. Install a Sublay SDK in your app — this one, or one of its siblings (see below).
|
|
55
|
+
3. Optionally drop in the open-source [`@sublay/ui-core-*`](https://github.com/sublay/ui-core) primitives, or install full components via the Sublay CLI registry.
|
|
56
|
+
|
|
57
|
+
## The Sublay dashboard
|
|
58
|
+
|
|
59
|
+
The dashboard at [dash.sublay.io](https://dash.sublay.io) is a database/backend console for your project:
|
|
60
|
+
|
|
61
|
+
- **Overview** — usage metrics and project health
|
|
62
|
+
- **Authentication** — end users and OAuth providers
|
|
63
|
+
- **Database** — schema browser (tables, relationships) and a table editor for browsing rows
|
|
64
|
+
- **Storage** — file blobs uploaded through the Files bundle
|
|
65
|
+
- **Reports** — moderation queue across entity and comment reports
|
|
66
|
+
- **Broadcast** — send notifications to your users
|
|
67
|
+
- **Settings** — domains, webhooks, integrations, members, secrets, billing
|
|
68
|
+
|
|
69
|
+
## The Sublay SDK family
|
|
70
|
+
|
|
71
|
+
- [`@sublay/core`](https://www.npmjs.com/package/@sublay/core) — platform-agnostic hooks and utilities
|
|
72
|
+
- [`@sublay/react-js`](https://www.npmjs.com/package/@sublay/react-js) — React (web)
|
|
73
|
+
- [`@sublay/react-native`](https://www.npmjs.com/package/@sublay/react-native) — React Native
|
|
74
|
+
- [`@sublay/expo`](https://www.npmjs.com/package/@sublay/expo) — Expo with SecureStore token storage
|
|
75
|
+
- [`@sublay/node`](https://www.npmjs.com/package/@sublay/node) — server-side Node.js (backends, server actions, webhook handlers)
|
|
76
|
+
- [`@sublay/js`](https://www.npmjs.com/package/@sublay/js) — framework-agnostic JavaScript (browser apps without React)
|
|
77
|
+
- [`@sublay/ui-core-react-js`](https://www.npmjs.com/package/@sublay/ui-core-react-js) / [`@sublay/ui-core-react-native`](https://www.npmjs.com/package/@sublay/ui-core-react-native) — open-source UI primitives
|
|
78
|
+
|
|
79
|
+
## Documentation
|
|
80
|
+
|
|
81
|
+
Full API reference, SDK guides, and recipes: **[docs.sublay.io](https://docs.sublay.io)**
|
|
82
|
+
|
|
83
|
+
## Community & support
|
|
84
|
+
|
|
85
|
+
- **Discord** — [discord.gg/REKxnCJzPz](https://discord.gg/REKxnCJzPz)
|
|
86
|
+
- **Blog** — [blog.sublay.io](https://blog.sublay.io)
|
|
87
|
+
- **X** — [@yantsab](https://x.com/yantsab)
|
|
88
|
+
- **LinkedIn** — [linkedin.com/company/sublay](https://www.linkedin.com/company/sublay)
|
|
89
|
+
- **Email** — [support@sublay.io](mailto:support@sublay.io)
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
Apache 2.0
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
|
|
3
|
+
interface ClientConfig {
|
|
4
|
+
projectId: string;
|
|
5
|
+
}
|
|
6
|
+
declare class SublayHttpClient {
|
|
7
|
+
instance: AxiosInstance;
|
|
8
|
+
constructor({ projectId }: ClientConfig);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface FetchUserByIdProps {
|
|
12
|
+
userId: string;
|
|
13
|
+
}
|
|
14
|
+
declare function fetchUserById(client: SublayHttpClient, data: FetchUserByIdProps): Promise<any>;
|
|
15
|
+
|
|
16
|
+
interface FetchUserByForeignIdProps {
|
|
17
|
+
foreignId: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
username?: string;
|
|
20
|
+
avatar?: string;
|
|
21
|
+
bio?: string;
|
|
22
|
+
metadata?: Record<string, any>;
|
|
23
|
+
secureMetadata?: Record<string, any>;
|
|
24
|
+
}
|
|
25
|
+
declare function fetchUserByForeignId(client: SublayHttpClient, data: FetchUserByForeignIdProps): Promise<any>;
|
|
26
|
+
|
|
27
|
+
declare const Users_fetchUserByForeignId: typeof fetchUserByForeignId;
|
|
28
|
+
declare const Users_fetchUserById: typeof fetchUserById;
|
|
29
|
+
declare namespace Users {
|
|
30
|
+
export { Users_fetchUserByForeignId as fetchUserByForeignId, Users_fetchUserById as fetchUserById };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface CreateEntityProps {
|
|
34
|
+
foreignId?: string;
|
|
35
|
+
sourceId?: string;
|
|
36
|
+
spaceId?: string;
|
|
37
|
+
title?: string;
|
|
38
|
+
content?: string;
|
|
39
|
+
attachments?: Record<string, any>[];
|
|
40
|
+
keywords?: string[];
|
|
41
|
+
location?: {
|
|
42
|
+
latitude: number;
|
|
43
|
+
longitude: number;
|
|
44
|
+
};
|
|
45
|
+
metadata?: Record<string, any>;
|
|
46
|
+
userId?: string;
|
|
47
|
+
}
|
|
48
|
+
declare function createEntity(client: SublayHttpClient, data: CreateEntityProps): Promise<any>;
|
|
49
|
+
|
|
50
|
+
interface FetchEntityProps {
|
|
51
|
+
entityId: string;
|
|
52
|
+
}
|
|
53
|
+
declare function fetchEntity(client: SublayHttpClient, data: FetchEntityProps): Promise<any>;
|
|
54
|
+
|
|
55
|
+
interface FetchEntityByForeignIdProps {
|
|
56
|
+
foreignId: string;
|
|
57
|
+
createIfNotFound?: boolean;
|
|
58
|
+
}
|
|
59
|
+
declare function fetchEntityByForeignId(client: SublayHttpClient, data: FetchEntityByForeignIdProps): Promise<any>;
|
|
60
|
+
|
|
61
|
+
interface FetchEntityByShortIdProps {
|
|
62
|
+
shortId: string;
|
|
63
|
+
}
|
|
64
|
+
declare function fetchEntityByShortId(client: SublayHttpClient, data: FetchEntityByShortIdProps): Promise<any>;
|
|
65
|
+
|
|
66
|
+
interface PaginationMetadata {
|
|
67
|
+
page: number;
|
|
68
|
+
pageSize: number;
|
|
69
|
+
totalPages: number;
|
|
70
|
+
totalItems: number;
|
|
71
|
+
hasMore: boolean;
|
|
72
|
+
}
|
|
73
|
+
interface PaginatedResponse<T> {
|
|
74
|
+
data: T[];
|
|
75
|
+
pagination: PaginationMetadata;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface KeywordsFilters {
|
|
79
|
+
includes?: string[];
|
|
80
|
+
doesNotInclude?: string[];
|
|
81
|
+
}
|
|
82
|
+
interface MetadataFilters {
|
|
83
|
+
includes?: {
|
|
84
|
+
[key: string]: any;
|
|
85
|
+
};
|
|
86
|
+
doesNotInclude?: {
|
|
87
|
+
[key: string]: any;
|
|
88
|
+
};
|
|
89
|
+
exists?: string[];
|
|
90
|
+
doesNotExist?: string[];
|
|
91
|
+
}
|
|
92
|
+
interface TextFilters {
|
|
93
|
+
hasTitle?: "true" | "false";
|
|
94
|
+
includes?: string | string[];
|
|
95
|
+
doesNotInclude?: string | string[];
|
|
96
|
+
}
|
|
97
|
+
interface AttachmentsFilters {
|
|
98
|
+
hasAttachments?: "true" | "false";
|
|
99
|
+
}
|
|
100
|
+
interface LocationFilters {
|
|
101
|
+
latitude: string;
|
|
102
|
+
longitude: string;
|
|
103
|
+
radius: string;
|
|
104
|
+
}
|
|
105
|
+
interface FetchManyEntitiesProps {
|
|
106
|
+
sourceId?: string;
|
|
107
|
+
spaceId?: string;
|
|
108
|
+
sortBy?: "hot" | "top" | "controversial";
|
|
109
|
+
page?: number;
|
|
110
|
+
limit?: number;
|
|
111
|
+
timeFrame?: "hour" | "day" | "week" | "month" | "year";
|
|
112
|
+
userId?: string;
|
|
113
|
+
followedOnly?: "true";
|
|
114
|
+
keywordsFilters?: KeywordsFilters;
|
|
115
|
+
metadataFilters?: MetadataFilters;
|
|
116
|
+
titleFilters?: TextFilters;
|
|
117
|
+
contentFilters?: {
|
|
118
|
+
hasContent?: "true" | "false";
|
|
119
|
+
includes?: string | string[];
|
|
120
|
+
doesNotInclude?: string | string[];
|
|
121
|
+
};
|
|
122
|
+
attachmentsFilters?: AttachmentsFilters;
|
|
123
|
+
locationFilters?: LocationFilters;
|
|
124
|
+
}
|
|
125
|
+
declare function fetchManyEntities(client: SublayHttpClient, data: FetchManyEntitiesProps): Promise<PaginatedResponse<any>>;
|
|
126
|
+
|
|
127
|
+
interface UpdateEntityProps {
|
|
128
|
+
entityId: string;
|
|
129
|
+
title?: string;
|
|
130
|
+
content?: string;
|
|
131
|
+
attachments?: Record<string, any>[];
|
|
132
|
+
keywords?: string[];
|
|
133
|
+
location?: {
|
|
134
|
+
type: "Point";
|
|
135
|
+
coordinates: [number, number];
|
|
136
|
+
};
|
|
137
|
+
metadata?: Record<string, any>;
|
|
138
|
+
mentions?: {
|
|
139
|
+
id: string;
|
|
140
|
+
username: string;
|
|
141
|
+
}[];
|
|
142
|
+
}
|
|
143
|
+
declare function updateEntity(client: SublayHttpClient, data: UpdateEntityProps): Promise<any>;
|
|
144
|
+
|
|
145
|
+
interface DeleteEntityProps {
|
|
146
|
+
entityId: string;
|
|
147
|
+
}
|
|
148
|
+
declare function deleteEntity(client: SublayHttpClient, data: DeleteEntityProps): Promise<any>;
|
|
149
|
+
|
|
150
|
+
declare const Entities_createEntity: typeof createEntity;
|
|
151
|
+
declare const Entities_deleteEntity: typeof deleteEntity;
|
|
152
|
+
declare const Entities_fetchEntity: typeof fetchEntity;
|
|
153
|
+
declare const Entities_fetchEntityByForeignId: typeof fetchEntityByForeignId;
|
|
154
|
+
declare const Entities_fetchEntityByShortId: typeof fetchEntityByShortId;
|
|
155
|
+
declare const Entities_fetchManyEntities: typeof fetchManyEntities;
|
|
156
|
+
declare const Entities_updateEntity: typeof updateEntity;
|
|
157
|
+
declare namespace Entities {
|
|
158
|
+
export { Entities_createEntity as createEntity, Entities_deleteEntity as deleteEntity, Entities_fetchEntity as fetchEntity, Entities_fetchEntityByForeignId as fetchEntityByForeignId, Entities_fetchEntityByShortId as fetchEntityByShortId, Entities_fetchManyEntities as fetchManyEntities, Entities_updateEntity as updateEntity };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface FetchCommentProps {
|
|
162
|
+
commentId: string;
|
|
163
|
+
}
|
|
164
|
+
declare function fetchComment(client: SublayHttpClient, data: FetchCommentProps): Promise<any>;
|
|
165
|
+
|
|
166
|
+
interface FetchCommentByForeignIdProps {
|
|
167
|
+
foreignId: string;
|
|
168
|
+
}
|
|
169
|
+
declare function fetchCommentByForeignId(client: SublayHttpClient, data: FetchCommentByForeignIdProps): Promise<any>;
|
|
170
|
+
|
|
171
|
+
declare const Comments_fetchComment: typeof fetchComment;
|
|
172
|
+
declare const Comments_fetchCommentByForeignId: typeof fetchCommentByForeignId;
|
|
173
|
+
declare namespace Comments {
|
|
174
|
+
export { Comments_fetchComment as fetchComment, Comments_fetchCommentByForeignId as fetchCommentByForeignId };
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
type BoundModule<T extends Record<string, (client: SublayHttpClient, ...args: any[]) => any>> = {
|
|
178
|
+
[K in keyof T]: (...args: Parameters<T[K]> extends [any, ...infer R] ? R : never) => ReturnType<T[K]>;
|
|
179
|
+
};
|
|
180
|
+
declare class SublayClient {
|
|
181
|
+
private http;
|
|
182
|
+
users: BoundModule<typeof Users>;
|
|
183
|
+
entities: BoundModule<typeof Entities>;
|
|
184
|
+
comments: BoundModule<typeof Comments>;
|
|
185
|
+
private constructor();
|
|
186
|
+
static init(config: ClientConfig): Promise<SublayClient>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export { type PaginatedResponse, type PaginationMetadata, SublayClient };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SublayHttpClient, ClientConfig } from "./core/client";
|
|
2
|
+
import * as Users from "./modules/users";
|
|
3
|
+
import * as Entities from "./modules/entities";
|
|
4
|
+
import * as Comments from "./modules/comments";
|
|
5
|
+
type BoundModule<T extends Record<string, (client: SublayHttpClient, ...args: any[]) => any>> = {
|
|
6
|
+
[K in keyof T]: (...args: Parameters<T[K]> extends [any, ...infer R] ? R : never) => ReturnType<T[K]>;
|
|
7
|
+
};
|
|
8
|
+
export declare class SublayClient {
|
|
9
|
+
private http;
|
|
10
|
+
users: BoundModule<typeof Users>;
|
|
11
|
+
entities: BoundModule<typeof Entities>;
|
|
12
|
+
comments: BoundModule<typeof Comments>;
|
|
13
|
+
private constructor();
|
|
14
|
+
static init(config: ClientConfig): Promise<SublayClient>;
|
|
15
|
+
}
|
|
16
|
+
export type { PaginatedResponse, PaginationMetadata } from "./interfaces/IPaginatedResponse";
|