@sublay/js 7.0.0 → 7.1.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/dist/index.d.mts +126 -23
- package/dist/index.d.ts +8 -0
- package/dist/index.js +123 -0
- package/dist/index.mjs +123 -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/chat/listReactions.d.ts +2 -6
- package/dist/modules/comments/fetchReactions.d.ts +2 -7
- package/dist/modules/entities/fetchReactions.d.ts +2 -7
- 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 +11 -7
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 {
|
|
@@ -975,13 +1002,7 @@ interface FetchEntityReactionsProps {
|
|
|
975
1002
|
}
|
|
976
1003
|
interface FetchEntityReactionsResponse {
|
|
977
1004
|
data: Reaction[];
|
|
978
|
-
pagination:
|
|
979
|
-
page: number;
|
|
980
|
-
limit: number;
|
|
981
|
-
total: number;
|
|
982
|
-
totalPages: number;
|
|
983
|
-
hasMore: boolean;
|
|
984
|
-
};
|
|
1005
|
+
pagination: PaginationMetadata;
|
|
985
1006
|
}
|
|
986
1007
|
declare function fetchReactions$1(client: SublayHttpClient, data: FetchEntityReactionsProps): Promise<FetchEntityReactionsResponse>;
|
|
987
1008
|
|
|
@@ -1127,13 +1148,7 @@ interface FetchCommentReactionsProps {
|
|
|
1127
1148
|
}
|
|
1128
1149
|
interface FetchCommentReactionsResponse {
|
|
1129
1150
|
data: Reaction[];
|
|
1130
|
-
pagination:
|
|
1131
|
-
page: number;
|
|
1132
|
-
limit: number;
|
|
1133
|
-
total: number;
|
|
1134
|
-
totalPages: number;
|
|
1135
|
-
hasMore: boolean;
|
|
1136
|
-
};
|
|
1151
|
+
pagination: PaginationMetadata;
|
|
1137
1152
|
}
|
|
1138
1153
|
declare function fetchReactions(client: SublayHttpClient, data: FetchCommentReactionsProps): Promise<FetchCommentReactionsResponse>;
|
|
1139
1154
|
|
|
@@ -1210,6 +1225,15 @@ interface FetchUserSpacesProps {
|
|
|
1210
1225
|
}
|
|
1211
1226
|
declare function fetchUserSpaces(client: SublayHttpClient, data: FetchUserSpacesProps): Promise<UserSpacesResponse>;
|
|
1212
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
|
+
|
|
1213
1237
|
interface CheckSlugAvailabilityProps {
|
|
1214
1238
|
slug: string;
|
|
1215
1239
|
}
|
|
@@ -1582,6 +1606,7 @@ declare const Spaces_fetchChildSpaces: typeof fetchChildSpaces;
|
|
|
1582
1606
|
declare const Spaces_fetchDigestConfig: typeof fetchDigestConfig;
|
|
1583
1607
|
declare const Spaces_fetchManyRules: typeof fetchManyRules;
|
|
1584
1608
|
declare const Spaces_fetchManySpaces: typeof fetchManySpaces;
|
|
1609
|
+
declare const Spaces_fetchMutualSpaces: typeof fetchMutualSpaces;
|
|
1585
1610
|
declare const Spaces_fetchRule: typeof fetchRule;
|
|
1586
1611
|
declare const Spaces_fetchSpace: typeof fetchSpace;
|
|
1587
1612
|
declare const Spaces_fetchSpaceBreadcrumb: typeof fetchSpaceBreadcrumb;
|
|
@@ -1606,7 +1631,7 @@ declare const Spaces_updateMemberRole: typeof updateMemberRole;
|
|
|
1606
1631
|
declare const Spaces_updateRule: typeof updateRule;
|
|
1607
1632
|
declare const Spaces_updateSpace: typeof updateSpace;
|
|
1608
1633
|
declare namespace Spaces {
|
|
1609
|
-
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 };
|
|
1634
|
+
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 };
|
|
1610
1635
|
}
|
|
1611
1636
|
|
|
1612
1637
|
interface Collection {
|
|
@@ -2486,6 +2511,14 @@ interface ChangeMemberRoleProps {
|
|
|
2486
2511
|
}
|
|
2487
2512
|
declare function changeMemberRole(client: SublayHttpClient, data: ChangeMemberRoleProps): Promise<ConversationMember>;
|
|
2488
2513
|
|
|
2514
|
+
interface MessageFilters {
|
|
2515
|
+
/**
|
|
2516
|
+
* Filter to messages that have thread replies (not quotings). `true` returns
|
|
2517
|
+
* only messages with at least one thread reply; `false` returns only messages
|
|
2518
|
+
* with none. Omit for no reply-count filtering.
|
|
2519
|
+
*/
|
|
2520
|
+
hasReplies?: boolean;
|
|
2521
|
+
}
|
|
2489
2522
|
interface ListMessagesProps {
|
|
2490
2523
|
conversationId: string;
|
|
2491
2524
|
/** Restrict to replies of this message (thread view). */
|
|
@@ -2499,12 +2532,20 @@ interface ListMessagesProps {
|
|
|
2499
2532
|
sort?: "asc" | "desc";
|
|
2500
2533
|
/** Comma-separated associations to populate, e.g. "files". */
|
|
2501
2534
|
include?: string;
|
|
2535
|
+
/** Optional filters, e.g. `{ hasReplies: true }`. */
|
|
2536
|
+
filters?: MessageFilters;
|
|
2502
2537
|
}
|
|
2503
2538
|
interface ListMessagesResponse {
|
|
2504
2539
|
messages: ChatMessage[];
|
|
2505
2540
|
hasMore: boolean;
|
|
2506
2541
|
oldestCreatedAt: string | null;
|
|
2507
2542
|
newestCreatedAt: string | null;
|
|
2543
|
+
/**
|
|
2544
|
+
* Present only when a filter combination can't return results — e.g.
|
|
2545
|
+
* `hasReplies: true` together with `parentId` (thread replies are one level
|
|
2546
|
+
* deep and never have their own replies).
|
|
2547
|
+
*/
|
|
2548
|
+
notice?: string;
|
|
2508
2549
|
}
|
|
2509
2550
|
declare function listMessages(client: SublayHttpClient, data: ListMessagesProps): Promise<ListMessagesResponse>;
|
|
2510
2551
|
|
|
@@ -2587,12 +2628,7 @@ interface MessageReaction {
|
|
|
2587
2628
|
}
|
|
2588
2629
|
interface ListReactionsResponse {
|
|
2589
2630
|
data: MessageReaction[];
|
|
2590
|
-
pagination:
|
|
2591
|
-
page: number;
|
|
2592
|
-
limit: number;
|
|
2593
|
-
total: number;
|
|
2594
|
-
hasMore: boolean;
|
|
2595
|
-
};
|
|
2631
|
+
pagination: PaginationMetadata;
|
|
2596
2632
|
}
|
|
2597
2633
|
declare function listReactions(client: SublayHttpClient, data: ListReactionsProps): Promise<ListReactionsResponse>;
|
|
2598
2634
|
|
|
@@ -2642,6 +2678,67 @@ declare namespace Chat {
|
|
|
2642
2678
|
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 };
|
|
2643
2679
|
}
|
|
2644
2680
|
|
|
2681
|
+
/**
|
|
2682
|
+
* Custom-table types for the `/db` surface (row ops only — the js-sdk holds no
|
|
2683
|
+
* service key, so it carries no table-management/DDL surface).
|
|
2684
|
+
*
|
|
2685
|
+
* Names mirror the server's `/db` contract exactly.
|
|
2686
|
+
*/
|
|
2687
|
+
type DbFilterOperator = "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in" | "contains" | "like" | "isNull";
|
|
2688
|
+
interface DbFilter {
|
|
2689
|
+
column: string;
|
|
2690
|
+
operator: DbFilterOperator;
|
|
2691
|
+
value?: unknown;
|
|
2692
|
+
}
|
|
2693
|
+
interface TableQuery {
|
|
2694
|
+
page?: number;
|
|
2695
|
+
limit?: number;
|
|
2696
|
+
sortBy?: string;
|
|
2697
|
+
sortDir?: "asc" | "desc";
|
|
2698
|
+
/** AND-combined filter clauses. Serialized to a JSON query param. */
|
|
2699
|
+
filters?: DbFilter[];
|
|
2700
|
+
/** Surface soft-deleted rows on a paranoid table. */
|
|
2701
|
+
includeDeleted?: boolean;
|
|
2702
|
+
}
|
|
2703
|
+
/** Shape every custom-table row shares (managed columns). */
|
|
2704
|
+
interface TableRow {
|
|
2705
|
+
id: string;
|
|
2706
|
+
createdAt?: string;
|
|
2707
|
+
updatedAt?: string;
|
|
2708
|
+
deletedAt?: string | null;
|
|
2709
|
+
[column: string]: unknown;
|
|
2710
|
+
}
|
|
2711
|
+
interface DeleteResult {
|
|
2712
|
+
deleted: boolean;
|
|
2713
|
+
soft: boolean;
|
|
2714
|
+
}
|
|
2715
|
+
interface BulkDeleteResult {
|
|
2716
|
+
deletedCount: number;
|
|
2717
|
+
soft: boolean;
|
|
2718
|
+
}
|
|
2719
|
+
interface BulkDeleteProps {
|
|
2720
|
+
rowIds?: string[];
|
|
2721
|
+
filters?: DbFilter[];
|
|
2722
|
+
force?: boolean;
|
|
2723
|
+
}
|
|
2724
|
+
/**
|
|
2725
|
+
* Per-table row-operations accessor returned by `client.table<T>(name)`.
|
|
2726
|
+
* The actor is derived server-side from the user token (js-sdk Rule A) — no
|
|
2727
|
+
* actor params here. No DDL surface (no service key).
|
|
2728
|
+
*/
|
|
2729
|
+
interface TableAccessor<T = TableRow> {
|
|
2730
|
+
find(query?: TableQuery): Promise<PaginatedResponse<T>>;
|
|
2731
|
+
findOne(rowId: string): Promise<T>;
|
|
2732
|
+
create(data: Partial<T> | Record<string, unknown>): Promise<T>;
|
|
2733
|
+
bulkCreate(rows: Array<Partial<T> | Record<string, unknown>>): Promise<T[]>;
|
|
2734
|
+
update(rowId: string, data: Partial<T> | Record<string, unknown>): Promise<T>;
|
|
2735
|
+
delete(rowId: string, opts?: {
|
|
2736
|
+
force?: boolean;
|
|
2737
|
+
}): Promise<DeleteResult>;
|
|
2738
|
+
bulkDelete(params: BulkDeleteProps): Promise<BulkDeleteResult>;
|
|
2739
|
+
restore(rowId: string): Promise<T>;
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2645
2742
|
type BoundModule<T extends Record<string, (client: SublayHttpClient, ...args: any[]) => any>> = {
|
|
2646
2743
|
[K in keyof T]: (...args: Parameters<T[K]> extends [any, ...infer R] ? R : never) => ReturnType<T[K]>;
|
|
2647
2744
|
};
|
|
@@ -2663,10 +2760,16 @@ declare class SublayClient {
|
|
|
2663
2760
|
chat: BoundModule<typeof Chat>;
|
|
2664
2761
|
private constructor();
|
|
2665
2762
|
static init(config: ClientConfig): Promise<SublayClient>;
|
|
2763
|
+
/**
|
|
2764
|
+
* Callable row-operations accessor for a custom table:
|
|
2765
|
+
* `client.table<EventRow>("Events").find(...)`. Row ops only — the js-sdk
|
|
2766
|
+
* holds no service key, so there is no table-management/DDL surface.
|
|
2767
|
+
*/
|
|
2768
|
+
table<T = TableRow>(name: string): TableAccessor<T>;
|
|
2666
2769
|
/** Imperatively set the session tokens (SDK-managed mode). */
|
|
2667
2770
|
setTokens(tokens: AuthTokens): void;
|
|
2668
2771
|
/** Imperatively clear the session tokens, e.g. on logout (SDK-managed mode). */
|
|
2669
2772
|
clearTokens(): void;
|
|
2670
2773
|
}
|
|
2671
2774
|
|
|
2672
|
-
export { type AuthTokens, type ClientConfig, type PaginatedResponse, type PaginationMetadata, SublayClient };
|
|
2775
|
+
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);
|
|
@@ -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>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SublayHttpClient } from "../../core/client";
|
|
2
2
|
import { User } from "../../interfaces/User";
|
|
3
|
+
import { PaginationMetadata } from "../../interfaces/IPaginatedResponse";
|
|
3
4
|
export interface ListReactionsProps {
|
|
4
5
|
conversationId: string;
|
|
5
6
|
messageId: string;
|
|
@@ -17,11 +18,6 @@ export interface MessageReaction {
|
|
|
17
18
|
}
|
|
18
19
|
export interface ListReactionsResponse {
|
|
19
20
|
data: MessageReaction[];
|
|
20
|
-
pagination:
|
|
21
|
-
page: number;
|
|
22
|
-
limit: number;
|
|
23
|
-
total: number;
|
|
24
|
-
hasMore: boolean;
|
|
25
|
-
};
|
|
21
|
+
pagination: PaginationMetadata;
|
|
26
22
|
}
|
|
27
23
|
export declare function listReactions(client: SublayHttpClient, data: ListReactionsProps): Promise<ListReactionsResponse>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SublayHttpClient } from "../../core/client";
|
|
2
2
|
import { Reaction, ReactionType } from "../../interfaces/Reaction";
|
|
3
|
+
import { PaginationMetadata } from "../../interfaces/IPaginatedResponse";
|
|
3
4
|
export interface FetchCommentReactionsProps {
|
|
4
5
|
commentId: string;
|
|
5
6
|
reactionType?: ReactionType;
|
|
@@ -9,12 +10,6 @@ export interface FetchCommentReactionsProps {
|
|
|
9
10
|
}
|
|
10
11
|
export interface FetchCommentReactionsResponse {
|
|
11
12
|
data: Reaction[];
|
|
12
|
-
pagination:
|
|
13
|
-
page: number;
|
|
14
|
-
limit: number;
|
|
15
|
-
total: number;
|
|
16
|
-
totalPages: number;
|
|
17
|
-
hasMore: boolean;
|
|
18
|
-
};
|
|
13
|
+
pagination: PaginationMetadata;
|
|
19
14
|
}
|
|
20
15
|
export declare function fetchReactions(client: SublayHttpClient, data: FetchCommentReactionsProps): Promise<FetchCommentReactionsResponse>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SublayHttpClient } from "../../core/client";
|
|
2
2
|
import { Reaction, ReactionType } from "../../interfaces/Reaction";
|
|
3
|
+
import { PaginationMetadata } from "../../interfaces/IPaginatedResponse";
|
|
3
4
|
export interface FetchEntityReactionsProps {
|
|
4
5
|
entityId: string;
|
|
5
6
|
reactionType?: ReactionType;
|
|
@@ -9,12 +10,6 @@ export interface FetchEntityReactionsProps {
|
|
|
9
10
|
}
|
|
10
11
|
export interface FetchEntityReactionsResponse {
|
|
11
12
|
data: Reaction[];
|
|
12
|
-
pagination:
|
|
13
|
-
page: number;
|
|
14
|
-
limit: number;
|
|
15
|
-
total: number;
|
|
16
|
-
totalPages: number;
|
|
17
|
-
hasMore: boolean;
|
|
18
|
-
};
|
|
13
|
+
pagination: PaginationMetadata;
|
|
19
14
|
}
|
|
20
15
|
export declare function fetchReactions(client: SublayHttpClient, data: FetchEntityReactionsProps): Promise<FetchEntityReactionsResponse>;
|
|
@@ -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.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -20,17 +20,21 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"axios": "^1.
|
|
23
|
+
"axios": "^1.15.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/
|
|
27
|
-
"
|
|
28
|
-
"
|
|
26
|
+
"@types/jest": "^29.5.14",
|
|
27
|
+
"@types/node": "^25.9.2",
|
|
28
|
+
"jest": "^29.7.0",
|
|
29
|
+
"ts-jest": "^29.2.5",
|
|
30
|
+
"tsup": "^8.5.1",
|
|
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
|
-
"publish-
|
|
36
|
+
"test": "jest",
|
|
37
|
+
"publish-beta": "pnpm publish --tag beta --no-git-checks",
|
|
38
|
+
"publish-prod": "pnpm publish --no-git-checks"
|
|
35
39
|
}
|
|
36
40
|
}
|