@sublay/js 7.0.1 → 7.1.1
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/dist/index.d.mts +124 -3
- package/dist/index.d.ts +8 -0
- package/dist/index.js +123 -0
- package/dist/index.mjs +123 -0
- package/dist/interfaces/Conversation.d.ts +2 -0
- package/dist/interfaces/Table.d.ts +63 -0
- package/dist/modules/auth/confirmAccountDeletion.d.ts +11 -0
- package/dist/modules/auth/index.d.ts +2 -0
- package/dist/modules/auth/requestAccountDeletion.d.ts +14 -0
- package/dist/modules/chat/listMessages.d.ts +16 -0
- package/dist/modules/spaces/fetchMutualSpaces.d.ts +11 -0
- package/dist/modules/spaces/index.d.ts +1 -0
- package/dist/modules/tables/bulkCreate.d.ts +4 -0
- package/dist/modules/tables/bulkDelete.d.ts +7 -0
- package/dist/modules/tables/create.d.ts +4 -0
- package/dist/modules/tables/createTableAccessor.d.ts +9 -0
- package/dist/modules/tables/deleteRow.d.ts +9 -0
- package/dist/modules/tables/find.d.ts +8 -0
- package/dist/modules/tables/findOne.d.ts +7 -0
- package/dist/modules/tables/index.d.ts +9 -0
- package/dist/modules/tables/restore.d.ts +6 -0
- package/dist/modules/tables/update.d.ts +4 -0
- package/package.json +13 -3
package/dist/index.d.mts
CHANGED
|
@@ -252,7 +252,34 @@ interface SendVerificationEmailResponse {
|
|
|
252
252
|
}
|
|
253
253
|
declare function sendVerificationEmail(client: SublayHttpClient, data?: SendVerificationEmailProps): Promise<SendVerificationEmailResponse>;
|
|
254
254
|
|
|
255
|
+
interface RequestAccountDeletionResponse {
|
|
256
|
+
success: boolean;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Step 1 of self-service account deletion. Emails the signed-in user a one-time
|
|
260
|
+
* confirmation code. Pass that code to {@link confirmAccountDeletion} to
|
|
261
|
+
* permanently delete the account.
|
|
262
|
+
*
|
|
263
|
+
* Requires the account to have an email on file — accounts without one (e.g.
|
|
264
|
+
* anonymous or foreign-id users) must be deleted server-side with a service key
|
|
265
|
+
* via the node SDK (`client.users.deleteUser`).
|
|
266
|
+
*/
|
|
267
|
+
declare function requestAccountDeletion(client: SublayHttpClient): Promise<RequestAccountDeletionResponse>;
|
|
268
|
+
|
|
269
|
+
interface ConfirmAccountDeletionProps {
|
|
270
|
+
/** The one-time code emailed by {@link requestAccountDeletion}. */
|
|
271
|
+
code: string;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Step 2 of self-service account deletion. Verifies the emailed code and then
|
|
275
|
+
* permanently deletes the signed-in user's account (same cascade as the
|
|
276
|
+
* admin/service delete). This is immediate and cannot be undone.
|
|
277
|
+
*/
|
|
278
|
+
declare function confirmAccountDeletion(client: SublayHttpClient, data: ConfirmAccountDeletionProps): Promise<void>;
|
|
279
|
+
|
|
255
280
|
declare const Auth_changePassword: typeof changePassword;
|
|
281
|
+
declare const Auth_confirmAccountDeletion: typeof confirmAccountDeletion;
|
|
282
|
+
declare const Auth_requestAccountDeletion: typeof requestAccountDeletion;
|
|
256
283
|
declare const Auth_requestNewAccessToken: typeof requestNewAccessToken;
|
|
257
284
|
declare const Auth_requestPasswordReset: typeof requestPasswordReset;
|
|
258
285
|
declare const Auth_resetPassword: typeof resetPassword;
|
|
@@ -263,7 +290,7 @@ declare const Auth_signUp: typeof signUp;
|
|
|
263
290
|
declare const Auth_verifyEmail: typeof verifyEmail;
|
|
264
291
|
declare const Auth_verifyExternalUser: typeof verifyExternalUser;
|
|
265
292
|
declare namespace Auth {
|
|
266
|
-
export { Auth_changePassword as changePassword, Auth_requestNewAccessToken as requestNewAccessToken, Auth_requestPasswordReset as requestPasswordReset, Auth_resetPassword as resetPassword, Auth_sendVerificationEmail as sendVerificationEmail, Auth_signIn as signIn, Auth_signOut as signOut, Auth_signUp as signUp, Auth_verifyEmail as verifyEmail, Auth_verifyExternalUser as verifyExternalUser };
|
|
293
|
+
export { Auth_changePassword as changePassword, Auth_confirmAccountDeletion as confirmAccountDeletion, Auth_requestAccountDeletion as requestAccountDeletion, Auth_requestNewAccessToken as requestNewAccessToken, Auth_requestPasswordReset as requestPasswordReset, Auth_resetPassword as resetPassword, Auth_sendVerificationEmail as sendVerificationEmail, Auth_signIn as signIn, Auth_signOut as signOut, Auth_signUp as signUp, Auth_verifyEmail as verifyEmail, Auth_verifyExternalUser as verifyExternalUser };
|
|
267
294
|
}
|
|
268
295
|
|
|
269
296
|
interface FetchUserByIdProps {
|
|
@@ -1198,6 +1225,15 @@ interface FetchUserSpacesProps {
|
|
|
1198
1225
|
}
|
|
1199
1226
|
declare function fetchUserSpaces(client: SublayHttpClient, data: FetchUserSpacesProps): Promise<UserSpacesResponse>;
|
|
1200
1227
|
|
|
1228
|
+
interface FetchMutualSpacesProps {
|
|
1229
|
+
/** The OTHER user — spaces shared with this user are returned. */
|
|
1230
|
+
userId: string;
|
|
1231
|
+
page?: number;
|
|
1232
|
+
limit?: number;
|
|
1233
|
+
include?: string;
|
|
1234
|
+
}
|
|
1235
|
+
declare function fetchMutualSpaces(client: SublayHttpClient, { userId, ...params }: FetchMutualSpacesProps): Promise<PaginatedResponse<Space>>;
|
|
1236
|
+
|
|
1201
1237
|
interface CheckSlugAvailabilityProps {
|
|
1202
1238
|
slug: string;
|
|
1203
1239
|
}
|
|
@@ -1520,6 +1556,7 @@ interface Conversation {
|
|
|
1520
1556
|
interface ConversationPreview extends Conversation {
|
|
1521
1557
|
unreadCount: number;
|
|
1522
1558
|
lastMessage: ChatMessage | null;
|
|
1559
|
+
otherMembers?: Pick<User, "id" | "name" | "username" | "avatar">[];
|
|
1523
1560
|
}
|
|
1524
1561
|
|
|
1525
1562
|
interface GetSpaceConversationProps {
|
|
@@ -1570,6 +1607,7 @@ declare const Spaces_fetchChildSpaces: typeof fetchChildSpaces;
|
|
|
1570
1607
|
declare const Spaces_fetchDigestConfig: typeof fetchDigestConfig;
|
|
1571
1608
|
declare const Spaces_fetchManyRules: typeof fetchManyRules;
|
|
1572
1609
|
declare const Spaces_fetchManySpaces: typeof fetchManySpaces;
|
|
1610
|
+
declare const Spaces_fetchMutualSpaces: typeof fetchMutualSpaces;
|
|
1573
1611
|
declare const Spaces_fetchRule: typeof fetchRule;
|
|
1574
1612
|
declare const Spaces_fetchSpace: typeof fetchSpace;
|
|
1575
1613
|
declare const Spaces_fetchSpaceBreadcrumb: typeof fetchSpaceBreadcrumb;
|
|
@@ -1594,7 +1632,7 @@ declare const Spaces_updateMemberRole: typeof updateMemberRole;
|
|
|
1594
1632
|
declare const Spaces_updateRule: typeof updateRule;
|
|
1595
1633
|
declare const Spaces_updateSpace: typeof updateSpace;
|
|
1596
1634
|
declare namespace Spaces {
|
|
1597
|
-
export { Spaces_approveMembership as approveMembership, Spaces_banMember as banMember, Spaces_checkMyMembership as checkMyMembership, Spaces_checkSlugAvailability as checkSlugAvailability, Spaces_createRule as createRule, Spaces_createSpace as createSpace, Spaces_declineMembership as declineMembership, Spaces_deleteRule as deleteRule, Spaces_deleteSpace as deleteSpace, Spaces_fetchChildSpaces as fetchChildSpaces, Spaces_fetchDigestConfig as fetchDigestConfig, Spaces_fetchManyRules as fetchManyRules, Spaces_fetchManySpaces as fetchManySpaces, Spaces_fetchRule as fetchRule, Spaces_fetchSpace as fetchSpace, Spaces_fetchSpaceBreadcrumb as fetchSpaceBreadcrumb, Spaces_fetchSpaceByShortId as fetchSpaceByShortId, Spaces_fetchSpaceBySlug as fetchSpaceBySlug, Spaces_fetchSpaceMembers as fetchSpaceMembers, Spaces_fetchSpaceTeam as fetchSpaceTeam, Spaces_fetchUserSpaces as fetchUserSpaces, Spaces_getSpaceConversation as getSpaceConversation, Spaces_handleCommentReport as handleCommentReport, Spaces_handleEntityReport as handleEntityReport, Spaces_handleSpaceChatReport as handleSpaceChatReport, Spaces_joinSpace as joinSpace, Spaces_leaveSpace as leaveSpace, Spaces_moderateSpaceChatMessage as moderateSpaceChatMessage, Spaces_moderateSpaceComment as moderateSpaceComment, Spaces_moderateSpaceEntity as moderateSpaceEntity, Spaces_reorderRules as reorderRules, Spaces_unbanMember as unbanMember, Spaces_updateDigestConfig as updateDigestConfig, Spaces_updateMemberRole as updateMemberRole, Spaces_updateRule as updateRule, Spaces_updateSpace as updateSpace };
|
|
1635
|
+
export { Spaces_approveMembership as approveMembership, Spaces_banMember as banMember, Spaces_checkMyMembership as checkMyMembership, Spaces_checkSlugAvailability as checkSlugAvailability, Spaces_createRule as createRule, Spaces_createSpace as createSpace, Spaces_declineMembership as declineMembership, Spaces_deleteRule as deleteRule, Spaces_deleteSpace as deleteSpace, Spaces_fetchChildSpaces as fetchChildSpaces, Spaces_fetchDigestConfig as fetchDigestConfig, Spaces_fetchManyRules as fetchManyRules, Spaces_fetchManySpaces as fetchManySpaces, Spaces_fetchMutualSpaces as fetchMutualSpaces, Spaces_fetchRule as fetchRule, Spaces_fetchSpace as fetchSpace, Spaces_fetchSpaceBreadcrumb as fetchSpaceBreadcrumb, Spaces_fetchSpaceByShortId as fetchSpaceByShortId, Spaces_fetchSpaceBySlug as fetchSpaceBySlug, Spaces_fetchSpaceMembers as fetchSpaceMembers, Spaces_fetchSpaceTeam as fetchSpaceTeam, Spaces_fetchUserSpaces as fetchUserSpaces, Spaces_getSpaceConversation as getSpaceConversation, Spaces_handleCommentReport as handleCommentReport, Spaces_handleEntityReport as handleEntityReport, Spaces_handleSpaceChatReport as handleSpaceChatReport, Spaces_joinSpace as joinSpace, Spaces_leaveSpace as leaveSpace, Spaces_moderateSpaceChatMessage as moderateSpaceChatMessage, Spaces_moderateSpaceComment as moderateSpaceComment, Spaces_moderateSpaceEntity as moderateSpaceEntity, Spaces_reorderRules as reorderRules, Spaces_unbanMember as unbanMember, Spaces_updateDigestConfig as updateDigestConfig, Spaces_updateMemberRole as updateMemberRole, Spaces_updateRule as updateRule, Spaces_updateSpace as updateSpace };
|
|
1598
1636
|
}
|
|
1599
1637
|
|
|
1600
1638
|
interface Collection {
|
|
@@ -2474,6 +2512,14 @@ interface ChangeMemberRoleProps {
|
|
|
2474
2512
|
}
|
|
2475
2513
|
declare function changeMemberRole(client: SublayHttpClient, data: ChangeMemberRoleProps): Promise<ConversationMember>;
|
|
2476
2514
|
|
|
2515
|
+
interface MessageFilters {
|
|
2516
|
+
/**
|
|
2517
|
+
* Filter to messages that have thread replies (not quotings). `true` returns
|
|
2518
|
+
* only messages with at least one thread reply; `false` returns only messages
|
|
2519
|
+
* with none. Omit for no reply-count filtering.
|
|
2520
|
+
*/
|
|
2521
|
+
hasReplies?: boolean;
|
|
2522
|
+
}
|
|
2477
2523
|
interface ListMessagesProps {
|
|
2478
2524
|
conversationId: string;
|
|
2479
2525
|
/** Restrict to replies of this message (thread view). */
|
|
@@ -2487,12 +2533,20 @@ interface ListMessagesProps {
|
|
|
2487
2533
|
sort?: "asc" | "desc";
|
|
2488
2534
|
/** Comma-separated associations to populate, e.g. "files". */
|
|
2489
2535
|
include?: string;
|
|
2536
|
+
/** Optional filters, e.g. `{ hasReplies: true }`. */
|
|
2537
|
+
filters?: MessageFilters;
|
|
2490
2538
|
}
|
|
2491
2539
|
interface ListMessagesResponse {
|
|
2492
2540
|
messages: ChatMessage[];
|
|
2493
2541
|
hasMore: boolean;
|
|
2494
2542
|
oldestCreatedAt: string | null;
|
|
2495
2543
|
newestCreatedAt: string | null;
|
|
2544
|
+
/**
|
|
2545
|
+
* Present only when a filter combination can't return results — e.g.
|
|
2546
|
+
* `hasReplies: true` together with `parentId` (thread replies are one level
|
|
2547
|
+
* deep and never have their own replies).
|
|
2548
|
+
*/
|
|
2549
|
+
notice?: string;
|
|
2496
2550
|
}
|
|
2497
2551
|
declare function listMessages(client: SublayHttpClient, data: ListMessagesProps): Promise<ListMessagesResponse>;
|
|
2498
2552
|
|
|
@@ -2625,6 +2679,67 @@ declare namespace Chat {
|
|
|
2625
2679
|
export { Chat_addMember as addMember, Chat_changeMemberRole as changeMemberRole, Chat_createDirectConversation as createDirectConversation, Chat_createGroupConversation as createGroupConversation, Chat_deleteConversation as deleteConversation, Chat_deleteMessage as deleteMessage, Chat_editMessage as editMessage, Chat_getConversation as getConversation, Chat_getMessage as getMessage, Chat_getUnreadCount as getUnreadCount, Chat_leaveConversation as leaveConversation, Chat_listConversations as listConversations, Chat_listMembers as listMembers, Chat_listMessages as listMessages, Chat_listReactions as listReactions, Chat_markAsRead as markAsRead, Chat_removeMember as removeMember, Chat_reportMessage as reportMessage, Chat_sendMessage as sendMessage, Chat_toggleReaction as toggleReaction, Chat_updateConversation as updateConversation };
|
|
2626
2680
|
}
|
|
2627
2681
|
|
|
2682
|
+
/**
|
|
2683
|
+
* Custom-table types for the `/db` surface (row ops only — the js-sdk holds no
|
|
2684
|
+
* service key, so it carries no table-management/DDL surface).
|
|
2685
|
+
*
|
|
2686
|
+
* Names mirror the server's `/db` contract exactly.
|
|
2687
|
+
*/
|
|
2688
|
+
type DbFilterOperator = "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in" | "contains" | "like" | "isNull";
|
|
2689
|
+
interface DbFilter {
|
|
2690
|
+
column: string;
|
|
2691
|
+
operator: DbFilterOperator;
|
|
2692
|
+
value?: unknown;
|
|
2693
|
+
}
|
|
2694
|
+
interface TableQuery {
|
|
2695
|
+
page?: number;
|
|
2696
|
+
limit?: number;
|
|
2697
|
+
sortBy?: string;
|
|
2698
|
+
sortDir?: "asc" | "desc";
|
|
2699
|
+
/** AND-combined filter clauses. Serialized to a JSON query param. */
|
|
2700
|
+
filters?: DbFilter[];
|
|
2701
|
+
/** Surface soft-deleted rows on a paranoid table. */
|
|
2702
|
+
includeDeleted?: boolean;
|
|
2703
|
+
}
|
|
2704
|
+
/** Shape every custom-table row shares (managed columns). */
|
|
2705
|
+
interface TableRow {
|
|
2706
|
+
id: string;
|
|
2707
|
+
createdAt?: string;
|
|
2708
|
+
updatedAt?: string;
|
|
2709
|
+
deletedAt?: string | null;
|
|
2710
|
+
[column: string]: unknown;
|
|
2711
|
+
}
|
|
2712
|
+
interface DeleteResult {
|
|
2713
|
+
deleted: boolean;
|
|
2714
|
+
soft: boolean;
|
|
2715
|
+
}
|
|
2716
|
+
interface BulkDeleteResult {
|
|
2717
|
+
deletedCount: number;
|
|
2718
|
+
soft: boolean;
|
|
2719
|
+
}
|
|
2720
|
+
interface BulkDeleteProps {
|
|
2721
|
+
rowIds?: string[];
|
|
2722
|
+
filters?: DbFilter[];
|
|
2723
|
+
force?: boolean;
|
|
2724
|
+
}
|
|
2725
|
+
/**
|
|
2726
|
+
* Per-table row-operations accessor returned by `client.table<T>(name)`.
|
|
2727
|
+
* The actor is derived server-side from the user token (js-sdk Rule A) — no
|
|
2728
|
+
* actor params here. No DDL surface (no service key).
|
|
2729
|
+
*/
|
|
2730
|
+
interface TableAccessor<T = TableRow> {
|
|
2731
|
+
find(query?: TableQuery): Promise<PaginatedResponse<T>>;
|
|
2732
|
+
findOne(rowId: string): Promise<T>;
|
|
2733
|
+
create(data: Partial<T> | Record<string, unknown>): Promise<T>;
|
|
2734
|
+
bulkCreate(rows: Array<Partial<T> | Record<string, unknown>>): Promise<T[]>;
|
|
2735
|
+
update(rowId: string, data: Partial<T> | Record<string, unknown>): Promise<T>;
|
|
2736
|
+
delete(rowId: string, opts?: {
|
|
2737
|
+
force?: boolean;
|
|
2738
|
+
}): Promise<DeleteResult>;
|
|
2739
|
+
bulkDelete(params: BulkDeleteProps): Promise<BulkDeleteResult>;
|
|
2740
|
+
restore(rowId: string): Promise<T>;
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2628
2743
|
type BoundModule<T extends Record<string, (client: SublayHttpClient, ...args: any[]) => any>> = {
|
|
2629
2744
|
[K in keyof T]: (...args: Parameters<T[K]> extends [any, ...infer R] ? R : never) => ReturnType<T[K]>;
|
|
2630
2745
|
};
|
|
@@ -2646,10 +2761,16 @@ declare class SublayClient {
|
|
|
2646
2761
|
chat: BoundModule<typeof Chat>;
|
|
2647
2762
|
private constructor();
|
|
2648
2763
|
static init(config: ClientConfig): Promise<SublayClient>;
|
|
2764
|
+
/**
|
|
2765
|
+
* Callable row-operations accessor for a custom table:
|
|
2766
|
+
* `client.table<EventRow>("Events").find(...)`. Row ops only — the js-sdk
|
|
2767
|
+
* holds no service key, so there is no table-management/DDL surface.
|
|
2768
|
+
*/
|
|
2769
|
+
table<T = TableRow>(name: string): TableAccessor<T>;
|
|
2649
2770
|
/** Imperatively set the session tokens (SDK-managed mode). */
|
|
2650
2771
|
setTokens(tokens: AuthTokens): void;
|
|
2651
2772
|
/** Imperatively clear the session tokens, e.g. on logout (SDK-managed mode). */
|
|
2652
2773
|
clearTokens(): void;
|
|
2653
2774
|
}
|
|
2654
2775
|
|
|
2655
|
-
export { type AuthTokens, type ClientConfig, type PaginatedResponse, type PaginationMetadata, SublayClient };
|
|
2776
|
+
export { type AuthTokens, type BulkDeleteProps, type BulkDeleteResult, type ClientConfig, type DbFilter, type DbFilterOperator, type DeleteResult, type PaginatedResponse, type PaginationMetadata, SublayClient, type TableAccessor, type TableQuery, type TableRow };
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import * as Search from "./modules/search";
|
|
|
13
13
|
import * as Storage from "./modules/storage";
|
|
14
14
|
import * as OAuth from "./modules/oauth";
|
|
15
15
|
import * as Chat from "./modules/chat";
|
|
16
|
+
import { TableAccessor, TableRow } from "./interfaces/Table";
|
|
16
17
|
type BoundModule<T extends Record<string, (client: SublayHttpClient, ...args: any[]) => any>> = {
|
|
17
18
|
[K in keyof T]: (...args: Parameters<T[K]> extends [any, ...infer R] ? R : never) => ReturnType<T[K]>;
|
|
18
19
|
};
|
|
@@ -34,6 +35,12 @@ export declare class SublayClient {
|
|
|
34
35
|
chat: BoundModule<typeof Chat>;
|
|
35
36
|
private constructor();
|
|
36
37
|
static init(config: ClientConfig): Promise<SublayClient>;
|
|
38
|
+
/**
|
|
39
|
+
* Callable row-operations accessor for a custom table:
|
|
40
|
+
* `client.table<EventRow>("Events").find(...)`. Row ops only — the js-sdk
|
|
41
|
+
* holds no service key, so there is no table-management/DDL surface.
|
|
42
|
+
*/
|
|
43
|
+
table<T = TableRow>(name: string): TableAccessor<T>;
|
|
37
44
|
/** Imperatively set the session tokens (SDK-managed mode). */
|
|
38
45
|
setTokens(tokens: AuthTokens): void;
|
|
39
46
|
/** Imperatively clear the session tokens, e.g. on logout (SDK-managed mode). */
|
|
@@ -41,3 +48,4 @@ export declare class SublayClient {
|
|
|
41
48
|
}
|
|
42
49
|
export type { ClientConfig, AuthTokens } from "./core/client";
|
|
43
50
|
export type { PaginatedResponse, PaginationMetadata, } from "./interfaces/IPaginatedResponse";
|
|
51
|
+
export type { TableAccessor, TableRow, TableQuery, DbFilter, DbFilterOperator, BulkDeleteProps, DeleteResult, BulkDeleteResult, } from "./interfaces/Table";
|
package/dist/index.js
CHANGED
|
@@ -169,6 +169,8 @@ var SublayHttpClient = class {
|
|
|
169
169
|
var auth_exports = {};
|
|
170
170
|
__export(auth_exports, {
|
|
171
171
|
changePassword: () => changePassword,
|
|
172
|
+
confirmAccountDeletion: () => confirmAccountDeletion,
|
|
173
|
+
requestAccountDeletion: () => requestAccountDeletion,
|
|
172
174
|
requestNewAccessToken: () => requestNewAccessToken,
|
|
173
175
|
requestPasswordReset: () => requestPasswordReset,
|
|
174
176
|
resetPassword: () => resetPassword,
|
|
@@ -280,6 +282,20 @@ async function sendVerificationEmail(client, data) {
|
|
|
280
282
|
return response.data;
|
|
281
283
|
}
|
|
282
284
|
|
|
285
|
+
// src/modules/auth/requestAccountDeletion.ts
|
|
286
|
+
async function requestAccountDeletion(client) {
|
|
287
|
+
const response = await client.projectInstance.post(
|
|
288
|
+
"/auth/request-account-deletion",
|
|
289
|
+
{}
|
|
290
|
+
);
|
|
291
|
+
return response.data;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// src/modules/auth/confirmAccountDeletion.ts
|
|
295
|
+
async function confirmAccountDeletion(client, data) {
|
|
296
|
+
await client.projectInstance.post("/auth/confirm-account-deletion", data);
|
|
297
|
+
}
|
|
298
|
+
|
|
283
299
|
// src/modules/users/index.ts
|
|
284
300
|
var users_exports = {};
|
|
285
301
|
__export(users_exports, {
|
|
@@ -775,6 +791,7 @@ __export(spaces_exports, {
|
|
|
775
791
|
fetchDigestConfig: () => fetchDigestConfig,
|
|
776
792
|
fetchManyRules: () => fetchManyRules,
|
|
777
793
|
fetchManySpaces: () => fetchManySpaces,
|
|
794
|
+
fetchMutualSpaces: () => fetchMutualSpaces,
|
|
778
795
|
fetchRule: () => fetchRule,
|
|
779
796
|
fetchSpace: () => fetchSpace,
|
|
780
797
|
fetchSpaceBreadcrumb: () => fetchSpaceBreadcrumb,
|
|
@@ -851,6 +868,15 @@ async function fetchUserSpaces(client, data) {
|
|
|
851
868
|
return response.data;
|
|
852
869
|
}
|
|
853
870
|
|
|
871
|
+
// src/modules/spaces/fetchMutualSpaces.ts
|
|
872
|
+
async function fetchMutualSpaces(client, { userId, ...params }) {
|
|
873
|
+
const response = await client.projectInstance.get(
|
|
874
|
+
`/spaces/mutual/${userId}`,
|
|
875
|
+
{ params }
|
|
876
|
+
);
|
|
877
|
+
return response.data;
|
|
878
|
+
}
|
|
879
|
+
|
|
854
880
|
// src/modules/spaces/checkSlugAvailability.ts
|
|
855
881
|
async function checkSlugAvailability(client, data) {
|
|
856
882
|
const response = await client.projectInstance.get(
|
|
@@ -1843,6 +1869,95 @@ async function reportMessage(client, data) {
|
|
|
1843
1869
|
return response.data;
|
|
1844
1870
|
}
|
|
1845
1871
|
|
|
1872
|
+
// src/modules/tables/find.ts
|
|
1873
|
+
async function find(client, tableName, query = {}) {
|
|
1874
|
+
const { filters, includeDeleted, ...rest } = query;
|
|
1875
|
+
const params = { ...rest };
|
|
1876
|
+
if (filters && filters.length > 0) params.filters = JSON.stringify(filters);
|
|
1877
|
+
if (includeDeleted !== void 0)
|
|
1878
|
+
params.includeDeleted = includeDeleted ? "true" : "false";
|
|
1879
|
+
const response = await client.projectInstance.get(
|
|
1880
|
+
`/db/${tableName}`,
|
|
1881
|
+
{ params }
|
|
1882
|
+
);
|
|
1883
|
+
return response.data;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
// src/modules/tables/findOne.ts
|
|
1887
|
+
async function findOne(client, tableName, rowId) {
|
|
1888
|
+
const response = await client.projectInstance.get(
|
|
1889
|
+
`/db/${tableName}/${rowId}`
|
|
1890
|
+
);
|
|
1891
|
+
return response.data.row;
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
// src/modules/tables/create.ts
|
|
1895
|
+
async function create(client, tableName, data) {
|
|
1896
|
+
const response = await client.projectInstance.post(
|
|
1897
|
+
`/db/${tableName}`,
|
|
1898
|
+
data
|
|
1899
|
+
);
|
|
1900
|
+
return response.data.row;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
// src/modules/tables/bulkCreate.ts
|
|
1904
|
+
async function bulkCreate(client, tableName, rows) {
|
|
1905
|
+
const response = await client.projectInstance.post(
|
|
1906
|
+
`/db/${tableName}/bulk`,
|
|
1907
|
+
{ rows }
|
|
1908
|
+
);
|
|
1909
|
+
return response.data.rows;
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
// src/modules/tables/update.ts
|
|
1913
|
+
async function update(client, tableName, rowId, data) {
|
|
1914
|
+
const response = await client.projectInstance.patch(
|
|
1915
|
+
`/db/${tableName}/${rowId}`,
|
|
1916
|
+
data
|
|
1917
|
+
);
|
|
1918
|
+
return response.data.row;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
// src/modules/tables/deleteRow.ts
|
|
1922
|
+
async function deleteRow(client, tableName, rowId, opts = {}) {
|
|
1923
|
+
const response = await client.projectInstance.delete(
|
|
1924
|
+
`/db/${tableName}/${rowId}`,
|
|
1925
|
+
{ params: opts.force ? { force: "true" } : {} }
|
|
1926
|
+
);
|
|
1927
|
+
return response.data;
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
// src/modules/tables/bulkDelete.ts
|
|
1931
|
+
async function bulkDelete(client, tableName, params) {
|
|
1932
|
+
const response = await client.projectInstance.delete(
|
|
1933
|
+
`/db/${tableName}`,
|
|
1934
|
+
{ data: params }
|
|
1935
|
+
);
|
|
1936
|
+
return response.data;
|
|
1937
|
+
}
|
|
1938
|
+
|
|
1939
|
+
// src/modules/tables/restore.ts
|
|
1940
|
+
async function restore(client, tableName, rowId) {
|
|
1941
|
+
const response = await client.projectInstance.post(
|
|
1942
|
+
`/db/${tableName}/${rowId}/restore`
|
|
1943
|
+
);
|
|
1944
|
+
return response.data.row;
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
// src/modules/tables/createTableAccessor.ts
|
|
1948
|
+
function createTableAccessor(client, tableName) {
|
|
1949
|
+
return {
|
|
1950
|
+
find: (query) => find(client, tableName, query),
|
|
1951
|
+
findOne: (rowId) => findOne(client, tableName, rowId),
|
|
1952
|
+
create: (data) => create(client, tableName, data),
|
|
1953
|
+
bulkCreate: (rows) => bulkCreate(client, tableName, rows),
|
|
1954
|
+
update: (rowId, data) => update(client, tableName, rowId, data),
|
|
1955
|
+
delete: (rowId, opts) => deleteRow(client, tableName, rowId, opts),
|
|
1956
|
+
bulkDelete: (params) => bulkDelete(client, tableName, params),
|
|
1957
|
+
restore: (rowId) => restore(client, tableName, rowId)
|
|
1958
|
+
};
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1846
1961
|
// src/index.ts
|
|
1847
1962
|
var SublayClient = class _SublayClient {
|
|
1848
1963
|
http;
|
|
@@ -1881,6 +1996,14 @@ var SublayClient = class _SublayClient {
|
|
|
1881
1996
|
const http = new SublayHttpClient(config);
|
|
1882
1997
|
return new _SublayClient(http);
|
|
1883
1998
|
}
|
|
1999
|
+
/**
|
|
2000
|
+
* Callable row-operations accessor for a custom table:
|
|
2001
|
+
* `client.table<EventRow>("Events").find(...)`. Row ops only — the js-sdk
|
|
2002
|
+
* holds no service key, so there is no table-management/DDL surface.
|
|
2003
|
+
*/
|
|
2004
|
+
table(name) {
|
|
2005
|
+
return createTableAccessor(this.http, name);
|
|
2006
|
+
}
|
|
1884
2007
|
/** Imperatively set the session tokens (SDK-managed mode). */
|
|
1885
2008
|
setTokens(tokens) {
|
|
1886
2009
|
this.http.setTokens(tokens);
|
package/dist/index.mjs
CHANGED
|
@@ -139,6 +139,8 @@ var SublayHttpClient = class {
|
|
|
139
139
|
var auth_exports = {};
|
|
140
140
|
__export(auth_exports, {
|
|
141
141
|
changePassword: () => changePassword,
|
|
142
|
+
confirmAccountDeletion: () => confirmAccountDeletion,
|
|
143
|
+
requestAccountDeletion: () => requestAccountDeletion,
|
|
142
144
|
requestNewAccessToken: () => requestNewAccessToken,
|
|
143
145
|
requestPasswordReset: () => requestPasswordReset,
|
|
144
146
|
resetPassword: () => resetPassword,
|
|
@@ -250,6 +252,20 @@ async function sendVerificationEmail(client, data) {
|
|
|
250
252
|
return response.data;
|
|
251
253
|
}
|
|
252
254
|
|
|
255
|
+
// src/modules/auth/requestAccountDeletion.ts
|
|
256
|
+
async function requestAccountDeletion(client) {
|
|
257
|
+
const response = await client.projectInstance.post(
|
|
258
|
+
"/auth/request-account-deletion",
|
|
259
|
+
{}
|
|
260
|
+
);
|
|
261
|
+
return response.data;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// src/modules/auth/confirmAccountDeletion.ts
|
|
265
|
+
async function confirmAccountDeletion(client, data) {
|
|
266
|
+
await client.projectInstance.post("/auth/confirm-account-deletion", data);
|
|
267
|
+
}
|
|
268
|
+
|
|
253
269
|
// src/modules/users/index.ts
|
|
254
270
|
var users_exports = {};
|
|
255
271
|
__export(users_exports, {
|
|
@@ -745,6 +761,7 @@ __export(spaces_exports, {
|
|
|
745
761
|
fetchDigestConfig: () => fetchDigestConfig,
|
|
746
762
|
fetchManyRules: () => fetchManyRules,
|
|
747
763
|
fetchManySpaces: () => fetchManySpaces,
|
|
764
|
+
fetchMutualSpaces: () => fetchMutualSpaces,
|
|
748
765
|
fetchRule: () => fetchRule,
|
|
749
766
|
fetchSpace: () => fetchSpace,
|
|
750
767
|
fetchSpaceBreadcrumb: () => fetchSpaceBreadcrumb,
|
|
@@ -821,6 +838,15 @@ async function fetchUserSpaces(client, data) {
|
|
|
821
838
|
return response.data;
|
|
822
839
|
}
|
|
823
840
|
|
|
841
|
+
// src/modules/spaces/fetchMutualSpaces.ts
|
|
842
|
+
async function fetchMutualSpaces(client, { userId, ...params }) {
|
|
843
|
+
const response = await client.projectInstance.get(
|
|
844
|
+
`/spaces/mutual/${userId}`,
|
|
845
|
+
{ params }
|
|
846
|
+
);
|
|
847
|
+
return response.data;
|
|
848
|
+
}
|
|
849
|
+
|
|
824
850
|
// src/modules/spaces/checkSlugAvailability.ts
|
|
825
851
|
async function checkSlugAvailability(client, data) {
|
|
826
852
|
const response = await client.projectInstance.get(
|
|
@@ -1813,6 +1839,95 @@ async function reportMessage(client, data) {
|
|
|
1813
1839
|
return response.data;
|
|
1814
1840
|
}
|
|
1815
1841
|
|
|
1842
|
+
// src/modules/tables/find.ts
|
|
1843
|
+
async function find(client, tableName, query = {}) {
|
|
1844
|
+
const { filters, includeDeleted, ...rest } = query;
|
|
1845
|
+
const params = { ...rest };
|
|
1846
|
+
if (filters && filters.length > 0) params.filters = JSON.stringify(filters);
|
|
1847
|
+
if (includeDeleted !== void 0)
|
|
1848
|
+
params.includeDeleted = includeDeleted ? "true" : "false";
|
|
1849
|
+
const response = await client.projectInstance.get(
|
|
1850
|
+
`/db/${tableName}`,
|
|
1851
|
+
{ params }
|
|
1852
|
+
);
|
|
1853
|
+
return response.data;
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
// src/modules/tables/findOne.ts
|
|
1857
|
+
async function findOne(client, tableName, rowId) {
|
|
1858
|
+
const response = await client.projectInstance.get(
|
|
1859
|
+
`/db/${tableName}/${rowId}`
|
|
1860
|
+
);
|
|
1861
|
+
return response.data.row;
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
// src/modules/tables/create.ts
|
|
1865
|
+
async function create(client, tableName, data) {
|
|
1866
|
+
const response = await client.projectInstance.post(
|
|
1867
|
+
`/db/${tableName}`,
|
|
1868
|
+
data
|
|
1869
|
+
);
|
|
1870
|
+
return response.data.row;
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
// src/modules/tables/bulkCreate.ts
|
|
1874
|
+
async function bulkCreate(client, tableName, rows) {
|
|
1875
|
+
const response = await client.projectInstance.post(
|
|
1876
|
+
`/db/${tableName}/bulk`,
|
|
1877
|
+
{ rows }
|
|
1878
|
+
);
|
|
1879
|
+
return response.data.rows;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
// src/modules/tables/update.ts
|
|
1883
|
+
async function update(client, tableName, rowId, data) {
|
|
1884
|
+
const response = await client.projectInstance.patch(
|
|
1885
|
+
`/db/${tableName}/${rowId}`,
|
|
1886
|
+
data
|
|
1887
|
+
);
|
|
1888
|
+
return response.data.row;
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
// src/modules/tables/deleteRow.ts
|
|
1892
|
+
async function deleteRow(client, tableName, rowId, opts = {}) {
|
|
1893
|
+
const response = await client.projectInstance.delete(
|
|
1894
|
+
`/db/${tableName}/${rowId}`,
|
|
1895
|
+
{ params: opts.force ? { force: "true" } : {} }
|
|
1896
|
+
);
|
|
1897
|
+
return response.data;
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
// src/modules/tables/bulkDelete.ts
|
|
1901
|
+
async function bulkDelete(client, tableName, params) {
|
|
1902
|
+
const response = await client.projectInstance.delete(
|
|
1903
|
+
`/db/${tableName}`,
|
|
1904
|
+
{ data: params }
|
|
1905
|
+
);
|
|
1906
|
+
return response.data;
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
// src/modules/tables/restore.ts
|
|
1910
|
+
async function restore(client, tableName, rowId) {
|
|
1911
|
+
const response = await client.projectInstance.post(
|
|
1912
|
+
`/db/${tableName}/${rowId}/restore`
|
|
1913
|
+
);
|
|
1914
|
+
return response.data.row;
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
// src/modules/tables/createTableAccessor.ts
|
|
1918
|
+
function createTableAccessor(client, tableName) {
|
|
1919
|
+
return {
|
|
1920
|
+
find: (query) => find(client, tableName, query),
|
|
1921
|
+
findOne: (rowId) => findOne(client, tableName, rowId),
|
|
1922
|
+
create: (data) => create(client, tableName, data),
|
|
1923
|
+
bulkCreate: (rows) => bulkCreate(client, tableName, rows),
|
|
1924
|
+
update: (rowId, data) => update(client, tableName, rowId, data),
|
|
1925
|
+
delete: (rowId, opts) => deleteRow(client, tableName, rowId, opts),
|
|
1926
|
+
bulkDelete: (params) => bulkDelete(client, tableName, params),
|
|
1927
|
+
restore: (rowId) => restore(client, tableName, rowId)
|
|
1928
|
+
};
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1816
1931
|
// src/index.ts
|
|
1817
1932
|
var SublayClient = class _SublayClient {
|
|
1818
1933
|
http;
|
|
@@ -1851,6 +1966,14 @@ var SublayClient = class _SublayClient {
|
|
|
1851
1966
|
const http = new SublayHttpClient(config);
|
|
1852
1967
|
return new _SublayClient(http);
|
|
1853
1968
|
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Callable row-operations accessor for a custom table:
|
|
1971
|
+
* `client.table<EventRow>("Events").find(...)`. Row ops only — the js-sdk
|
|
1972
|
+
* holds no service key, so there is no table-management/DDL surface.
|
|
1973
|
+
*/
|
|
1974
|
+
table(name) {
|
|
1975
|
+
return createTableAccessor(this.http, name);
|
|
1976
|
+
}
|
|
1854
1977
|
/** Imperatively set the session tokens (SDK-managed mode). */
|
|
1855
1978
|
setTokens(tokens) {
|
|
1856
1979
|
this.http.setTokens(tokens);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { File } from "./File";
|
|
2
2
|
import { ChatMessage } from "./ChatMessage";
|
|
3
3
|
import { ConversationMember } from "./ConversationMember";
|
|
4
|
+
import { User } from "./User";
|
|
4
5
|
export interface Conversation {
|
|
5
6
|
id: string;
|
|
6
7
|
projectId: string;
|
|
@@ -22,4 +23,5 @@ export interface Conversation {
|
|
|
22
23
|
export interface ConversationPreview extends Conversation {
|
|
23
24
|
unreadCount: number;
|
|
24
25
|
lastMessage: ChatMessage | null;
|
|
26
|
+
otherMembers?: Pick<User, "id" | "name" | "username" | "avatar">[];
|
|
25
27
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { SublayHttpClient } from "../core/client";
|
|
2
|
+
import { PaginatedResponse } from "./IPaginatedResponse";
|
|
3
|
+
/**
|
|
4
|
+
* Custom-table types for the `/db` surface (row ops only — the js-sdk holds no
|
|
5
|
+
* service key, so it carries no table-management/DDL surface).
|
|
6
|
+
*
|
|
7
|
+
* Names mirror the server's `/db` contract exactly.
|
|
8
|
+
*/
|
|
9
|
+
export type DbFilterOperator = "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in" | "contains" | "like" | "isNull";
|
|
10
|
+
export interface DbFilter {
|
|
11
|
+
column: string;
|
|
12
|
+
operator: DbFilterOperator;
|
|
13
|
+
value?: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface TableQuery {
|
|
16
|
+
page?: number;
|
|
17
|
+
limit?: number;
|
|
18
|
+
sortBy?: string;
|
|
19
|
+
sortDir?: "asc" | "desc";
|
|
20
|
+
/** AND-combined filter clauses. Serialized to a JSON query param. */
|
|
21
|
+
filters?: DbFilter[];
|
|
22
|
+
/** Surface soft-deleted rows on a paranoid table. */
|
|
23
|
+
includeDeleted?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Shape every custom-table row shares (managed columns). */
|
|
26
|
+
export interface TableRow {
|
|
27
|
+
id: string;
|
|
28
|
+
createdAt?: string;
|
|
29
|
+
updatedAt?: string;
|
|
30
|
+
deletedAt?: string | null;
|
|
31
|
+
[column: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
export interface DeleteResult {
|
|
34
|
+
deleted: boolean;
|
|
35
|
+
soft: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface BulkDeleteResult {
|
|
38
|
+
deletedCount: number;
|
|
39
|
+
soft: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface BulkDeleteProps {
|
|
42
|
+
rowIds?: string[];
|
|
43
|
+
filters?: DbFilter[];
|
|
44
|
+
force?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Per-table row-operations accessor returned by `client.table<T>(name)`.
|
|
48
|
+
* The actor is derived server-side from the user token (js-sdk Rule A) — no
|
|
49
|
+
* actor params here. No DDL surface (no service key).
|
|
50
|
+
*/
|
|
51
|
+
export interface TableAccessor<T = TableRow> {
|
|
52
|
+
find(query?: TableQuery): Promise<PaginatedResponse<T>>;
|
|
53
|
+
findOne(rowId: string): Promise<T>;
|
|
54
|
+
create(data: Partial<T> | Record<string, unknown>): Promise<T>;
|
|
55
|
+
bulkCreate(rows: Array<Partial<T> | Record<string, unknown>>): Promise<T[]>;
|
|
56
|
+
update(rowId: string, data: Partial<T> | Record<string, unknown>): Promise<T>;
|
|
57
|
+
delete(rowId: string, opts?: {
|
|
58
|
+
force?: boolean;
|
|
59
|
+
}): Promise<DeleteResult>;
|
|
60
|
+
bulkDelete(params: BulkDeleteProps): Promise<BulkDeleteResult>;
|
|
61
|
+
restore(rowId: string): Promise<T>;
|
|
62
|
+
}
|
|
63
|
+
export type TableAccessorFactory = <T = TableRow>(client: SublayHttpClient, tableName: string) => TableAccessor<T>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SublayHttpClient } from "../../core/client";
|
|
2
|
+
export interface ConfirmAccountDeletionProps {
|
|
3
|
+
/** The one-time code emailed by {@link requestAccountDeletion}. */
|
|
4
|
+
code: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Step 2 of self-service account deletion. Verifies the emailed code and then
|
|
8
|
+
* permanently deletes the signed-in user's account (same cascade as the
|
|
9
|
+
* admin/service delete). This is immediate and cannot be undone.
|
|
10
|
+
*/
|
|
11
|
+
export declare function confirmAccountDeletion(client: SublayHttpClient, data: ConfirmAccountDeletionProps): Promise<void>;
|
|
@@ -8,3 +8,5 @@ export { resetPassword } from "./resetPassword";
|
|
|
8
8
|
export { changePassword } from "./changePassword";
|
|
9
9
|
export { verifyEmail } from "./verifyEmail";
|
|
10
10
|
export { sendVerificationEmail } from "./sendVerificationEmail";
|
|
11
|
+
export { requestAccountDeletion } from "./requestAccountDeletion";
|
|
12
|
+
export { confirmAccountDeletion } from "./confirmAccountDeletion";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SublayHttpClient } from "../../core/client";
|
|
2
|
+
export interface RequestAccountDeletionResponse {
|
|
3
|
+
success: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Step 1 of self-service account deletion. Emails the signed-in user a one-time
|
|
7
|
+
* confirmation code. Pass that code to {@link confirmAccountDeletion} to
|
|
8
|
+
* permanently delete the account.
|
|
9
|
+
*
|
|
10
|
+
* Requires the account to have an email on file — accounts without one (e.g.
|
|
11
|
+
* anonymous or foreign-id users) must be deleted server-side with a service key
|
|
12
|
+
* via the node SDK (`client.users.deleteUser`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function requestAccountDeletion(client: SublayHttpClient): Promise<RequestAccountDeletionResponse>;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { SublayHttpClient } from "../../core/client";
|
|
2
2
|
import { ChatMessage } from "../../interfaces/ChatMessage";
|
|
3
|
+
export interface MessageFilters {
|
|
4
|
+
/**
|
|
5
|
+
* Filter to messages that have thread replies (not quotings). `true` returns
|
|
6
|
+
* only messages with at least one thread reply; `false` returns only messages
|
|
7
|
+
* with none. Omit for no reply-count filtering.
|
|
8
|
+
*/
|
|
9
|
+
hasReplies?: boolean;
|
|
10
|
+
}
|
|
3
11
|
export interface ListMessagesProps {
|
|
4
12
|
conversationId: string;
|
|
5
13
|
/** Restrict to replies of this message (thread view). */
|
|
@@ -13,11 +21,19 @@ export interface ListMessagesProps {
|
|
|
13
21
|
sort?: "asc" | "desc";
|
|
14
22
|
/** Comma-separated associations to populate, e.g. "files". */
|
|
15
23
|
include?: string;
|
|
24
|
+
/** Optional filters, e.g. `{ hasReplies: true }`. */
|
|
25
|
+
filters?: MessageFilters;
|
|
16
26
|
}
|
|
17
27
|
export interface ListMessagesResponse {
|
|
18
28
|
messages: ChatMessage[];
|
|
19
29
|
hasMore: boolean;
|
|
20
30
|
oldestCreatedAt: string | null;
|
|
21
31
|
newestCreatedAt: string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Present only when a filter combination can't return results — e.g.
|
|
34
|
+
* `hasReplies: true` together with `parentId` (thread replies are one level
|
|
35
|
+
* deep and never have their own replies).
|
|
36
|
+
*/
|
|
37
|
+
notice?: string;
|
|
22
38
|
}
|
|
23
39
|
export declare function listMessages(client: SublayHttpClient, data: ListMessagesProps): Promise<ListMessagesResponse>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SublayHttpClient } from "../../core/client";
|
|
2
|
+
import { Space } from "../../interfaces/Space";
|
|
3
|
+
import { PaginatedResponse } from "../../interfaces/IPaginatedResponse";
|
|
4
|
+
export interface FetchMutualSpacesProps {
|
|
5
|
+
/** The OTHER user — spaces shared with this user are returned. */
|
|
6
|
+
userId: string;
|
|
7
|
+
page?: number;
|
|
8
|
+
limit?: number;
|
|
9
|
+
include?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function fetchMutualSpaces(client: SublayHttpClient, { userId, ...params }: FetchMutualSpacesProps): Promise<PaginatedResponse<Space>>;
|
|
@@ -4,6 +4,7 @@ export { fetchSpace } from "./fetchSpace";
|
|
|
4
4
|
export { fetchSpaceByShortId } from "./fetchSpaceByShortId";
|
|
5
5
|
export { fetchSpaceBySlug } from "./fetchSpaceBySlug";
|
|
6
6
|
export { fetchUserSpaces } from "./fetchUserSpaces";
|
|
7
|
+
export { fetchMutualSpaces } from "./fetchMutualSpaces";
|
|
7
8
|
export { checkSlugAvailability } from "./checkSlugAvailability";
|
|
8
9
|
export { updateSpace } from "./updateSpace";
|
|
9
10
|
export { deleteSpace } from "./deleteSpace";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SublayHttpClient } from "../../core/client";
|
|
2
|
+
import { TableRow } from "../../interfaces/Table";
|
|
3
|
+
/** POST /db/:tableName/bulk — insert many rows (capped at 100 server-side). */
|
|
4
|
+
export declare function bulkCreate<T = TableRow>(client: SublayHttpClient, tableName: string, rows: Array<Partial<T> | Record<string, unknown>>): Promise<T[]>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SublayHttpClient } from "../../core/client";
|
|
2
|
+
import { BulkDeleteProps, BulkDeleteResult } from "../../interfaces/Table";
|
|
3
|
+
/**
|
|
4
|
+
* DELETE /db/:tableName — bulk delete by id list and/or `filters` predicate
|
|
5
|
+
* (at least one required). Paranoid tables soft-delete unless `force: true`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function bulkDelete(client: SublayHttpClient, tableName: string, params: BulkDeleteProps): Promise<BulkDeleteResult>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SublayHttpClient } from "../../core/client";
|
|
2
|
+
import { TableRow } from "../../interfaces/Table";
|
|
3
|
+
/** POST /db/:tableName — insert one row. */
|
|
4
|
+
export declare function create<T = TableRow>(client: SublayHttpClient, tableName: string, data: Partial<T> | Record<string, unknown>): Promise<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SublayHttpClient } from "../../core/client";
|
|
2
|
+
import { TableAccessor, TableRow } from "../../interfaces/Table";
|
|
3
|
+
/**
|
|
4
|
+
* Build the per-table row-operations accessor returned by
|
|
5
|
+
* `client.table<T>(name)`. A thin factory that closes over the HTTP client and
|
|
6
|
+
* the table name — the one structural novelty over the flat `bindModule`
|
|
7
|
+
* namespace, which can't capture a per-call table name.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createTableAccessor<T = TableRow>(client: SublayHttpClient, tableName: string): TableAccessor<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SublayHttpClient } from "../../core/client";
|
|
2
|
+
import { DeleteResult } from "../../interfaces/Table";
|
|
3
|
+
/**
|
|
4
|
+
* DELETE /db/:tableName/:rowId — soft-delete on a paranoid table by default;
|
|
5
|
+
* `force: true` hard-deletes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function deleteRow(client: SublayHttpClient, tableName: string, rowId: string, opts?: {
|
|
8
|
+
force?: boolean;
|
|
9
|
+
}): Promise<DeleteResult>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SublayHttpClient } from "../../core/client";
|
|
2
|
+
import { PaginatedResponse } from "../../interfaces/IPaginatedResponse";
|
|
3
|
+
import { TableQuery, TableRow } from "../../interfaces/Table";
|
|
4
|
+
/**
|
|
5
|
+
* GET /db/:tableName — paginated rows with the `{ data, pagination }` envelope.
|
|
6
|
+
* `filters` is serialized to a JSON query param; `includeDeleted` to "true"/"false".
|
|
7
|
+
*/
|
|
8
|
+
export declare function find<T = TableRow>(client: SublayHttpClient, tableName: string, query?: TableQuery): Promise<PaginatedResponse<T>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SublayHttpClient } from "../../core/client";
|
|
2
|
+
import { TableRow } from "../../interfaces/Table";
|
|
3
|
+
/**
|
|
4
|
+
* GET /db/:tableName/:rowId — a single row (soft-deleted rows 404). Throws on
|
|
5
|
+
* 404 (axios), consistent with the other fetch-one methods in the SDK.
|
|
6
|
+
*/
|
|
7
|
+
export declare function findOne<T = TableRow>(client: SublayHttpClient, tableName: string, rowId: string): Promise<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { find } from "./find";
|
|
2
|
+
export { findOne } from "./findOne";
|
|
3
|
+
export { create } from "./create";
|
|
4
|
+
export { bulkCreate } from "./bulkCreate";
|
|
5
|
+
export { update } from "./update";
|
|
6
|
+
export { deleteRow } from "./deleteRow";
|
|
7
|
+
export { bulkDelete } from "./bulkDelete";
|
|
8
|
+
export { restore } from "./restore";
|
|
9
|
+
export { createTableAccessor } from "./createTableAccessor";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SublayHttpClient } from "../../core/client";
|
|
2
|
+
import { TableRow } from "../../interfaces/Table";
|
|
3
|
+
/**
|
|
4
|
+
* POST /db/:tableName/:rowId/restore — clear `deletedAt` on a paranoid table.
|
|
5
|
+
*/
|
|
6
|
+
export declare function restore<T = TableRow>(client: SublayHttpClient, tableName: string, rowId: string): Promise<T>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SublayHttpClient } from "../../core/client";
|
|
2
|
+
import { TableRow } from "../../interfaces/Table";
|
|
3
|
+
/** PATCH /db/:tableName/:rowId — update a row (server bumps updatedAt). */
|
|
4
|
+
export declare function update<T = TableRow>(client: SublayHttpClient, tableName: string, rowId: string, data: Partial<T> | Record<string, unknown>): Promise<T>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sublay/js",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -23,14 +23,24 @@
|
|
|
23
23
|
"axios": "^1.15.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
+
"@types/jest": "^29.5.14",
|
|
26
27
|
"@types/node": "^25.9.2",
|
|
28
|
+
"jest": "^29.7.0",
|
|
29
|
+
"ts-jest": "^29.2.5",
|
|
27
30
|
"tsup": "^8.5.1",
|
|
28
31
|
"typescript": "^6.0.3"
|
|
29
32
|
},
|
|
30
33
|
"scripts": {
|
|
31
34
|
"build": "tsup src/index.ts --dts --format cjs,esm",
|
|
32
35
|
"build:types": "tsc --emitDeclarationOnly",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
36
|
+
"test": "jest",
|
|
37
|
+
"version:patch": "pnpm version patch --no-git-tag-version --no-git-checks",
|
|
38
|
+
"version:minor": "pnpm version minor --no-git-tag-version --no-git-checks",
|
|
39
|
+
"publish-beta": "pnpm publish --tag beta --no-git-checks",
|
|
40
|
+
"publish-prod": "pnpm publish --no-git-checks",
|
|
41
|
+
"publish-beta:patch": "pnpm version:patch && pnpm publish-beta",
|
|
42
|
+
"publish-beta:minor": "pnpm version:minor && pnpm publish-beta",
|
|
43
|
+
"publish-prod:patch": "pnpm version:patch && pnpm publish-prod",
|
|
44
|
+
"publish-prod:minor": "pnpm version:minor && pnpm publish-prod"
|
|
35
45
|
}
|
|
36
46
|
}
|