@tapstack/db 1.0.6 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +655 -0
- package/dist/adapters/index.d.ts +6 -0
- package/dist/adapters/index.js +22 -0
- package/dist/adapters/nodejs.adapter.d.ts +63 -0
- package/dist/adapters/nodejs.adapter.js +204 -0
- package/dist/adapters/types.d.ts +77 -0
- package/dist/adapters/types.js +19 -0
- package/dist/index.d.ts +101 -21
- package/dist/index.js +114 -41
- package/dist/modules/automations.d.ts +109 -0
- package/dist/modules/automations.js +59 -0
- package/dist/modules/conversations.d.ts +82 -0
- package/dist/modules/conversations.js +54 -0
- package/dist/modules/fields.d.ts +30 -9
- package/dist/modules/fields.js +31 -13
- package/dist/modules/files.d.ts +68 -0
- package/dist/modules/files.js +115 -0
- package/dist/modules/index.d.ts +12 -0
- package/dist/modules/index.js +28 -0
- package/dist/modules/objects.d.ts +30 -9
- package/dist/modules/objects.js +35 -13
- package/dist/modules/organizations.d.ts +69 -0
- package/dist/modules/organizations.js +83 -0
- package/dist/modules/records.d.ts +47 -5
- package/dist/modules/records.js +70 -5
- package/dist/modules/workspaces.d.ts +44 -0
- package/dist/modules/workspaces.js +57 -0
- package/dist/types.d.ts +159 -10
- package/dist/types.js +19 -0
- package/package.json +16 -7
- package/src/__tests__/client.test.ts +305 -49
- package/src/adapters/index.ts +13 -0
- package/src/adapters/nodejs.adapter.ts +298 -0
- package/src/adapters/types.ts +108 -0
- package/src/index.ts +132 -44
- package/src/modules/automations.ts +157 -0
- package/src/modules/conversations.ts +134 -0
- package/src/modules/fields.ts +64 -14
- package/src/modules/files.ts +144 -0
- package/src/modules/index.ts +19 -0
- package/src/modules/objects.ts +46 -14
- package/src/modules/organizations.ts +137 -0
- package/src/modules/records.ts +119 -6
- package/src/modules/workspaces.ts +95 -0
- package/src/types.ts +229 -9
- package/dist/request.d.ts +0 -2
- package/dist/request.js +0 -20
- package/src/request.ts +0 -14
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automations Module
|
|
3
|
+
* CRUD operations for workflow automations
|
|
4
|
+
*/
|
|
5
|
+
import { IInstanceAdapter } from '../adapters/types';
|
|
6
|
+
export interface TriggerCondition {
|
|
7
|
+
field: string;
|
|
8
|
+
operator: string;
|
|
9
|
+
value: unknown;
|
|
10
|
+
}
|
|
11
|
+
export interface FieldMapping {
|
|
12
|
+
type: 'static' | 'trigger_field';
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AutomationAction {
|
|
16
|
+
id: string;
|
|
17
|
+
type: 'create_record' | 'update_record' | 'delete_record' | 'webhook';
|
|
18
|
+
config: {
|
|
19
|
+
targetObjectId?: string;
|
|
20
|
+
fieldMappings?: Record<string, FieldMapping>;
|
|
21
|
+
url?: string;
|
|
22
|
+
method?: 'POST' | 'PUT' | 'PATCH';
|
|
23
|
+
headers?: Record<string, string>;
|
|
24
|
+
body?: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export interface Automation {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
workspaceId: string;
|
|
32
|
+
triggerObjectId: string;
|
|
33
|
+
triggerType: 'record.created' | 'record.updated' | 'record.deleted';
|
|
34
|
+
triggerConditions: TriggerCondition[];
|
|
35
|
+
actions: AutomationAction[];
|
|
36
|
+
isEnabled: boolean;
|
|
37
|
+
lastRunAt?: number;
|
|
38
|
+
runCount: number;
|
|
39
|
+
createdAt: number;
|
|
40
|
+
updatedAt: number;
|
|
41
|
+
deletedAt?: number;
|
|
42
|
+
triggerObject?: {
|
|
43
|
+
id: string;
|
|
44
|
+
singleName: string;
|
|
45
|
+
pluralName: string;
|
|
46
|
+
slug: string;
|
|
47
|
+
icon?: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface CreateAutomationPayload {
|
|
51
|
+
name: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
triggerObjectId: string;
|
|
54
|
+
triggerType: 'record.created' | 'record.updated' | 'record.deleted';
|
|
55
|
+
triggerConditions?: TriggerCondition[];
|
|
56
|
+
actions: Omit<AutomationAction, 'id'>[];
|
|
57
|
+
}
|
|
58
|
+
export interface UpdateAutomationPayload {
|
|
59
|
+
name?: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
triggerConditions?: TriggerCondition[];
|
|
62
|
+
actions?: AutomationAction[];
|
|
63
|
+
isEnabled?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface ExecuteAutomationResult {
|
|
66
|
+
success: boolean;
|
|
67
|
+
results: Array<{
|
|
68
|
+
actionId: string;
|
|
69
|
+
success: boolean;
|
|
70
|
+
error?: string;
|
|
71
|
+
}>;
|
|
72
|
+
message: string;
|
|
73
|
+
}
|
|
74
|
+
export declare class AutomationModule {
|
|
75
|
+
private adapter;
|
|
76
|
+
constructor(adapter: IInstanceAdapter);
|
|
77
|
+
/**
|
|
78
|
+
* List all automations for the current workspace
|
|
79
|
+
*/
|
|
80
|
+
list(): Promise<{
|
|
81
|
+
automations: Automation[];
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Get a single automation by ID
|
|
85
|
+
*/
|
|
86
|
+
get(id: string): Promise<Automation>;
|
|
87
|
+
/**
|
|
88
|
+
* Create a new automation
|
|
89
|
+
*/
|
|
90
|
+
create(data: CreateAutomationPayload): Promise<Automation>;
|
|
91
|
+
/**
|
|
92
|
+
* Update an existing automation
|
|
93
|
+
*/
|
|
94
|
+
update(id: string, data: UpdateAutomationPayload): Promise<Automation>;
|
|
95
|
+
/**
|
|
96
|
+
* Delete an automation
|
|
97
|
+
*/
|
|
98
|
+
delete(id: string, soft?: boolean): Promise<{
|
|
99
|
+
deleted: boolean;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* Toggle automation enabled/disabled
|
|
103
|
+
*/
|
|
104
|
+
toggle(id: string): Promise<Automation>;
|
|
105
|
+
/**
|
|
106
|
+
* Execute an automation manually (for testing)
|
|
107
|
+
*/
|
|
108
|
+
execute(id: string, testData?: Record<string, unknown>): Promise<ExecuteAutomationResult>;
|
|
109
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Automations Module
|
|
4
|
+
* CRUD operations for workflow automations
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.AutomationModule = void 0;
|
|
8
|
+
class AutomationModule {
|
|
9
|
+
constructor(adapter) {
|
|
10
|
+
this.adapter = adapter;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* List all automations for the current workspace
|
|
14
|
+
*/
|
|
15
|
+
async list() {
|
|
16
|
+
return this.adapter.request('GET', 'automations');
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get a single automation by ID
|
|
20
|
+
*/
|
|
21
|
+
async get(id) {
|
|
22
|
+
return this.adapter.request('GET', `automations/${id}`);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a new automation
|
|
26
|
+
*/
|
|
27
|
+
async create(data) {
|
|
28
|
+
return this.adapter.request('POST', 'automations', {
|
|
29
|
+
body: data,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Update an existing automation
|
|
34
|
+
*/
|
|
35
|
+
async update(id, data) {
|
|
36
|
+
return this.adapter.request('PUT', `automations/${id}`, {
|
|
37
|
+
body: data,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Delete an automation
|
|
42
|
+
*/
|
|
43
|
+
async delete(id, soft = true) {
|
|
44
|
+
return this.adapter.request('DELETE', `automations/${id}`, { params: { soft: String(soft) } });
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Toggle automation enabled/disabled
|
|
48
|
+
*/
|
|
49
|
+
async toggle(id) {
|
|
50
|
+
return this.adapter.request('POST', `automations/${id}/toggle`);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Execute an automation manually (for testing)
|
|
54
|
+
*/
|
|
55
|
+
async execute(id, testData) {
|
|
56
|
+
return this.adapter.request('POST', `automations/${id}/execute`, { body: testData });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.AutomationModule = AutomationModule;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversations Module
|
|
3
|
+
* AI chat conversation management
|
|
4
|
+
*/
|
|
5
|
+
import { IInstanceAdapter } from '../adapters/types';
|
|
6
|
+
export interface ToolCall {
|
|
7
|
+
name: string;
|
|
8
|
+
arguments?: Record<string, unknown>;
|
|
9
|
+
result?: unknown;
|
|
10
|
+
error?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface Message {
|
|
13
|
+
id: string;
|
|
14
|
+
role: 'user' | 'assistant' | 'system';
|
|
15
|
+
content: string;
|
|
16
|
+
toolCalls?: ToolCall[];
|
|
17
|
+
createdAt: number;
|
|
18
|
+
}
|
|
19
|
+
export interface Conversation {
|
|
20
|
+
id: string;
|
|
21
|
+
workspaceId: string;
|
|
22
|
+
userId?: string;
|
|
23
|
+
title: string;
|
|
24
|
+
lastMessage?: string;
|
|
25
|
+
messageCount: number;
|
|
26
|
+
createdAt: number;
|
|
27
|
+
updatedAt: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ConversationWithMessages extends Conversation {
|
|
30
|
+
messages: Message[];
|
|
31
|
+
}
|
|
32
|
+
export interface CreateConversationPayload {
|
|
33
|
+
title?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface AddMessagePayload {
|
|
36
|
+
role: 'user' | 'assistant' | 'system';
|
|
37
|
+
content: string;
|
|
38
|
+
toolCalls?: ToolCall[];
|
|
39
|
+
}
|
|
40
|
+
export interface ConversationListResponse {
|
|
41
|
+
conversations: Conversation[];
|
|
42
|
+
total: number;
|
|
43
|
+
}
|
|
44
|
+
export declare class ConversationModule {
|
|
45
|
+
private adapter;
|
|
46
|
+
constructor(adapter: IInstanceAdapter);
|
|
47
|
+
/**
|
|
48
|
+
* List conversations for the current user/workspace
|
|
49
|
+
*/
|
|
50
|
+
list(options?: {
|
|
51
|
+
limit?: number;
|
|
52
|
+
offset?: number;
|
|
53
|
+
}): Promise<ConversationListResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Get a single conversation with messages
|
|
56
|
+
*/
|
|
57
|
+
get(id: string): Promise<ConversationWithMessages>;
|
|
58
|
+
/**
|
|
59
|
+
* Create a new conversation
|
|
60
|
+
*/
|
|
61
|
+
create(data?: CreateConversationPayload): Promise<{
|
|
62
|
+
conversation: ConversationWithMessages;
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Update a conversation (title)
|
|
66
|
+
*/
|
|
67
|
+
update(id: string, title: string): Promise<{
|
|
68
|
+
conversation: Conversation;
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Delete a conversation
|
|
72
|
+
*/
|
|
73
|
+
delete(id: string): Promise<{
|
|
74
|
+
deleted: boolean;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Add a message to a conversation
|
|
78
|
+
*/
|
|
79
|
+
addMessage(conversationId: string, message: AddMessagePayload): Promise<{
|
|
80
|
+
message: Message;
|
|
81
|
+
}>;
|
|
82
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Conversations Module
|
|
4
|
+
* AI chat conversation management
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ConversationModule = void 0;
|
|
8
|
+
class ConversationModule {
|
|
9
|
+
constructor(adapter) {
|
|
10
|
+
this.adapter = adapter;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* List conversations for the current user/workspace
|
|
14
|
+
*/
|
|
15
|
+
async list(options) {
|
|
16
|
+
const params = {};
|
|
17
|
+
if (options?.limit)
|
|
18
|
+
params.limit = String(options.limit);
|
|
19
|
+
if (options?.offset)
|
|
20
|
+
params.offset = String(options.offset);
|
|
21
|
+
return this.adapter.request('GET', 'conversations', { params });
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get a single conversation with messages
|
|
25
|
+
*/
|
|
26
|
+
async get(id) {
|
|
27
|
+
return this.adapter.request('GET', `conversations/${id}`);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a new conversation
|
|
31
|
+
*/
|
|
32
|
+
async create(data) {
|
|
33
|
+
return this.adapter.request('POST', 'conversations', { body: data || {} });
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Update a conversation (title)
|
|
37
|
+
*/
|
|
38
|
+
async update(id, title) {
|
|
39
|
+
return this.adapter.request('PATCH', `conversations/${id}`, { body: { title } });
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Delete a conversation
|
|
43
|
+
*/
|
|
44
|
+
async delete(id) {
|
|
45
|
+
return this.adapter.request('DELETE', `conversations/${id}`);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Add a message to a conversation
|
|
49
|
+
*/
|
|
50
|
+
async addMessage(conversationId, message) {
|
|
51
|
+
return this.adapter.request('POST', `conversations/${conversationId}/messages`, { body: message });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.ConversationModule = ConversationModule;
|
package/dist/modules/fields.d.ts
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Fields Module
|
|
3
|
+
* CRUD operations for Tapstack fields (object schema)
|
|
4
|
+
*/
|
|
5
|
+
import { IInstanceAdapter } from '../adapters/types';
|
|
6
|
+
import { TapstackField, CreateFieldPayload, UpdateFieldPayload, FieldListResponse } from '../types';
|
|
3
7
|
export declare class FieldModule {
|
|
4
|
-
private
|
|
5
|
-
constructor(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
private adapter;
|
|
9
|
+
constructor(adapter: IInstanceAdapter);
|
|
10
|
+
/**
|
|
11
|
+
* List all fields for an object
|
|
12
|
+
*/
|
|
13
|
+
list(objectSlug: string): Promise<FieldListResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Get a single field by ID
|
|
16
|
+
*/
|
|
17
|
+
get(objectSlug: string, fieldId: string): Promise<TapstackField>;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new field
|
|
20
|
+
*/
|
|
21
|
+
create(objectSlug: string, data: CreateFieldPayload): Promise<TapstackField>;
|
|
22
|
+
/**
|
|
23
|
+
* Update an existing field
|
|
24
|
+
*/
|
|
25
|
+
update(objectSlug: string, fieldId: string, data: UpdateFieldPayload): Promise<TapstackField>;
|
|
26
|
+
/**
|
|
27
|
+
* Delete a field (soft delete by default)
|
|
28
|
+
*/
|
|
29
|
+
delete(objectSlug: string, fieldId: string, soft?: boolean): Promise<{
|
|
30
|
+
deleted: boolean;
|
|
31
|
+
}>;
|
|
11
32
|
}
|
package/dist/modules/fields.js
CHANGED
|
@@ -1,25 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Fields Module
|
|
4
|
+
* CRUD operations for Tapstack fields (object schema)
|
|
5
|
+
*/
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
7
|
exports.FieldModule = void 0;
|
|
4
|
-
const request_1 = require("../request");
|
|
5
8
|
class FieldModule {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
9
|
+
constructor(adapter) {
|
|
10
|
+
this.adapter = adapter;
|
|
8
11
|
}
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
/**
|
|
13
|
+
* List all fields for an object
|
|
14
|
+
*/
|
|
15
|
+
async list(objectSlug) {
|
|
16
|
+
return this.adapter.request('GET', `schema/objects/${objectSlug}/fields`);
|
|
11
17
|
}
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Get a single field by ID
|
|
20
|
+
*/
|
|
21
|
+
async get(objectSlug, fieldId) {
|
|
22
|
+
return this.adapter.request('GET', `schema/objects/${objectSlug}/fields/${fieldId}`);
|
|
14
23
|
}
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Create a new field
|
|
26
|
+
*/
|
|
27
|
+
async create(objectSlug, data) {
|
|
28
|
+
return this.adapter.request('POST', `schema/objects/${objectSlug}/fields`, { body: data });
|
|
17
29
|
}
|
|
18
|
-
|
|
19
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Update an existing field
|
|
32
|
+
*/
|
|
33
|
+
async update(objectSlug, fieldId, data) {
|
|
34
|
+
return this.adapter.request('PATCH', `schema/objects/${objectSlug}/fields/${fieldId}`, { body: data });
|
|
20
35
|
}
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Delete a field (soft delete by default)
|
|
38
|
+
*/
|
|
39
|
+
async delete(objectSlug, fieldId, soft = true) {
|
|
40
|
+
return this.adapter.request('DELETE', `schema/objects/${objectSlug}/fields/${fieldId}`, { params: { soft: String(soft) } });
|
|
23
41
|
}
|
|
24
42
|
}
|
|
25
43
|
exports.FieldModule = FieldModule;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Files Module
|
|
3
|
+
* File and folder operations using Supabase Storage
|
|
4
|
+
*/
|
|
5
|
+
import { IInstanceAdapter } from '../adapters/types';
|
|
6
|
+
import { TapstackFile, TapstackFolder, FileUploadOptions, FileListResponse, FolderListResponse } from '../types';
|
|
7
|
+
export declare class FileModule {
|
|
8
|
+
private adapter;
|
|
9
|
+
constructor(adapter: IInstanceAdapter);
|
|
10
|
+
/**
|
|
11
|
+
* List files in the workspace (optionally filtered by folder)
|
|
12
|
+
*/
|
|
13
|
+
list(folderId?: string): Promise<FileListResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Get a single file by ID
|
|
16
|
+
*/
|
|
17
|
+
get(fileId: string): Promise<TapstackFile>;
|
|
18
|
+
/**
|
|
19
|
+
* Upload a file
|
|
20
|
+
*/
|
|
21
|
+
upload(file: File | Blob, options?: FileUploadOptions): Promise<TapstackFile>;
|
|
22
|
+
/**
|
|
23
|
+
* Delete a file
|
|
24
|
+
*/
|
|
25
|
+
delete(fileId: string): Promise<{
|
|
26
|
+
deleted: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Get a signed download URL for a file
|
|
30
|
+
*/
|
|
31
|
+
getDownloadUrl(fileId: string, expiresIn?: number): Promise<{
|
|
32
|
+
url: string;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Move a file to a different folder
|
|
36
|
+
*/
|
|
37
|
+
move(fileId: string, targetFolderId: string | null): Promise<TapstackFile>;
|
|
38
|
+
/**
|
|
39
|
+
* Rename a file
|
|
40
|
+
*/
|
|
41
|
+
rename(fileId: string, newName: string): Promise<TapstackFile>;
|
|
42
|
+
/**
|
|
43
|
+
* List folders (optionally filtered by parent)
|
|
44
|
+
*/
|
|
45
|
+
listFolders(parentId?: string | null): Promise<FolderListResponse>;
|
|
46
|
+
/**
|
|
47
|
+
* Get a single folder by ID
|
|
48
|
+
*/
|
|
49
|
+
getFolder(folderId: string): Promise<TapstackFolder>;
|
|
50
|
+
/**
|
|
51
|
+
* Create a new folder
|
|
52
|
+
*/
|
|
53
|
+
createFolder(name: string, parentId?: string): Promise<TapstackFolder>;
|
|
54
|
+
/**
|
|
55
|
+
* Rename a folder
|
|
56
|
+
*/
|
|
57
|
+
renameFolder(folderId: string, newName: string): Promise<TapstackFolder>;
|
|
58
|
+
/**
|
|
59
|
+
* Move a folder to a different parent
|
|
60
|
+
*/
|
|
61
|
+
moveFolder(folderId: string, targetParentId: string | null): Promise<TapstackFolder>;
|
|
62
|
+
/**
|
|
63
|
+
* Delete a folder (and all contents)
|
|
64
|
+
*/
|
|
65
|
+
deleteFolder(folderId: string): Promise<{
|
|
66
|
+
deleted: boolean;
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Files Module
|
|
4
|
+
* File and folder operations using Supabase Storage
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.FileModule = void 0;
|
|
8
|
+
class FileModule {
|
|
9
|
+
constructor(adapter) {
|
|
10
|
+
this.adapter = adapter;
|
|
11
|
+
}
|
|
12
|
+
// ==================== Files ====================
|
|
13
|
+
/**
|
|
14
|
+
* List files in the workspace (optionally filtered by folder)
|
|
15
|
+
*/
|
|
16
|
+
async list(folderId) {
|
|
17
|
+
const params = {};
|
|
18
|
+
if (folderId)
|
|
19
|
+
params.folderId = folderId;
|
|
20
|
+
return this.adapter.request('GET', 'files/list', { params });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get a single file by ID
|
|
24
|
+
*/
|
|
25
|
+
async get(fileId) {
|
|
26
|
+
return this.adapter.request('GET', `files/${fileId}`);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Upload a file
|
|
30
|
+
*/
|
|
31
|
+
async upload(file, options) {
|
|
32
|
+
const metadata = {};
|
|
33
|
+
if (options?.folderId)
|
|
34
|
+
metadata.folderId = options.folderId;
|
|
35
|
+
if (options?.folder)
|
|
36
|
+
metadata.folder = options.folder;
|
|
37
|
+
return this.adapter.upload('files/upload', file, metadata);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Delete a file
|
|
41
|
+
*/
|
|
42
|
+
async delete(fileId) {
|
|
43
|
+
return this.adapter.request('DELETE', `files/${fileId}`);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get a signed download URL for a file
|
|
47
|
+
*/
|
|
48
|
+
async getDownloadUrl(fileId, expiresIn = 3600) {
|
|
49
|
+
return this.adapter.request('GET', `files/${fileId}/download`, { params: { expiresIn: String(expiresIn) } });
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Move a file to a different folder
|
|
53
|
+
*/
|
|
54
|
+
async move(fileId, targetFolderId) {
|
|
55
|
+
return this.adapter.request('PATCH', `files/${fileId}/move`, {
|
|
56
|
+
body: { folderId: targetFolderId },
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Rename a file
|
|
61
|
+
*/
|
|
62
|
+
async rename(fileId, newName) {
|
|
63
|
+
return this.adapter.request('PATCH', `files/${fileId}`, {
|
|
64
|
+
body: { name: newName },
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// ==================== Folders ====================
|
|
68
|
+
/**
|
|
69
|
+
* List folders (optionally filtered by parent)
|
|
70
|
+
*/
|
|
71
|
+
async listFolders(parentId) {
|
|
72
|
+
const params = {};
|
|
73
|
+
if (parentId !== undefined) {
|
|
74
|
+
params.parentId = parentId ?? 'null';
|
|
75
|
+
}
|
|
76
|
+
return this.adapter.request('GET', 'files/folders', { params });
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get a single folder by ID
|
|
80
|
+
*/
|
|
81
|
+
async getFolder(folderId) {
|
|
82
|
+
return this.adapter.request('GET', `files/folders/${folderId}`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Create a new folder
|
|
86
|
+
*/
|
|
87
|
+
async createFolder(name, parentId) {
|
|
88
|
+
return this.adapter.request('POST', 'files/folders', {
|
|
89
|
+
body: { name, parentId },
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Rename a folder
|
|
94
|
+
*/
|
|
95
|
+
async renameFolder(folderId, newName) {
|
|
96
|
+
return this.adapter.request('PATCH', `files/folders/${folderId}`, {
|
|
97
|
+
body: { name: newName },
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Move a folder to a different parent
|
|
102
|
+
*/
|
|
103
|
+
async moveFolder(folderId, targetParentId) {
|
|
104
|
+
return this.adapter.request('PATCH', `files/folders/${folderId}/move`, {
|
|
105
|
+
body: { parentId: targetParentId },
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Delete a folder (and all contents)
|
|
110
|
+
*/
|
|
111
|
+
async deleteFolder(folderId) {
|
|
112
|
+
return this.adapter.request('DELETE', `files/folders/${folderId}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.FileModule = FileModule;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modules Index
|
|
3
|
+
* Export all module classes
|
|
4
|
+
*/
|
|
5
|
+
export * from './objects';
|
|
6
|
+
export * from './fields';
|
|
7
|
+
export * from './records';
|
|
8
|
+
export * from './organizations';
|
|
9
|
+
export * from './workspaces';
|
|
10
|
+
export * from './files';
|
|
11
|
+
export * from './automations';
|
|
12
|
+
export * from './conversations';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Modules Index
|
|
4
|
+
* Export all module classes
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
__exportStar(require("./objects"), exports);
|
|
22
|
+
__exportStar(require("./fields"), exports);
|
|
23
|
+
__exportStar(require("./records"), exports);
|
|
24
|
+
__exportStar(require("./organizations"), exports);
|
|
25
|
+
__exportStar(require("./workspaces"), exports);
|
|
26
|
+
__exportStar(require("./files"), exports);
|
|
27
|
+
__exportStar(require("./automations"), exports);
|
|
28
|
+
__exportStar(require("./conversations"), exports);
|
|
@@ -1,11 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Objects Module
|
|
3
|
+
* CRUD operations for Tapstack objects (data models)
|
|
4
|
+
*/
|
|
5
|
+
import { IInstanceAdapter } from '../adapters/types';
|
|
6
|
+
import { TapstackObject, CreateObjectPayload, UpdateObjectPayload, ObjectListResponse } from '../types';
|
|
3
7
|
export declare class ObjectModule {
|
|
4
|
-
private
|
|
5
|
-
constructor(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
private adapter;
|
|
9
|
+
constructor(adapter: IInstanceAdapter);
|
|
10
|
+
/**
|
|
11
|
+
* List all objects in the workspace
|
|
12
|
+
*/
|
|
13
|
+
list(): Promise<ObjectListResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Get a single object by slug
|
|
16
|
+
*/
|
|
17
|
+
get(slug: string): Promise<TapstackObject>;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new object
|
|
20
|
+
*/
|
|
21
|
+
create(data: CreateObjectPayload): Promise<TapstackObject>;
|
|
22
|
+
/**
|
|
23
|
+
* Update an existing object
|
|
24
|
+
*/
|
|
25
|
+
update(slug: string, data: UpdateObjectPayload): Promise<TapstackObject>;
|
|
26
|
+
/**
|
|
27
|
+
* Delete an object (soft delete by default)
|
|
28
|
+
*/
|
|
29
|
+
delete(slug: string, soft?: boolean): Promise<{
|
|
30
|
+
deleted: boolean;
|
|
31
|
+
}>;
|
|
11
32
|
}
|