@activepieces/piece-teable 0.1.4
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/package.json +17 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +42 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/create-record.d.ts +17 -0
- package/src/lib/actions/create-record.js +35 -0
- package/src/lib/actions/create-record.js.map +1 -0
- package/src/lib/actions/delete-record.d.ts +17 -0
- package/src/lib/actions/delete-record.js +26 -0
- package/src/lib/actions/delete-record.js.map +1 -0
- package/src/lib/actions/find-record.d.ts +18 -0
- package/src/lib/actions/find-record.js +39 -0
- package/src/lib/actions/find-record.js.map +1 -0
- package/src/lib/actions/find-records.d.ts +18 -0
- package/src/lib/actions/find-records.js +66 -0
- package/src/lib/actions/find-records.js.map +1 -0
- package/src/lib/actions/update-record.d.ts +21 -0
- package/src/lib/actions/update-record.js +34 -0
- package/src/lib/actions/update-record.js.map +1 -0
- package/src/lib/actions/upload-attachment.d.ts +22 -0
- package/src/lib/actions/upload-attachment.js +62 -0
- package/src/lib/actions/upload-attachment.js.map +1 -0
- package/src/lib/auth.d.ts +17 -0
- package/src/lib/auth.js +79 -0
- package/src/lib/auth.js.map +1 -0
- package/src/lib/common/client.d.ts +101 -0
- package/src/lib/common/client.js +146 -0
- package/src/lib/common/client.js.map +1 -0
- package/src/lib/common/constants.d.ts +25 -0
- package/src/lib/common/constants.js +47 -0
- package/src/lib/common/constants.js.map +1 -0
- package/src/lib/common/index.d.ts +23 -0
- package/src/lib/common/index.js +136 -0
- package/src/lib/common/index.js.map +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-teable",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"type": "commonjs",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@activepieces/pieces-common": "0.12.0",
|
|
9
|
+
"@activepieces/pieces-framework": "0.26.0",
|
|
10
|
+
"@activepieces/shared": "0.42.0",
|
|
11
|
+
"tslib": "^2.3.0"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc -p tsconfig.lib.json && cp package.json dist/",
|
|
15
|
+
"lint": "eslint 'src/**/*.ts'"
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const teable: import("@activepieces/pieces-framework").Piece<(import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>)[]>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.teable = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const shared_1 = require("@activepieces/shared");
|
|
8
|
+
const create_record_1 = require("./lib/actions/create-record");
|
|
9
|
+
const find_records_1 = require("./lib/actions/find-records");
|
|
10
|
+
const find_record_1 = require("./lib/actions/find-record");
|
|
11
|
+
const delete_record_1 = require("./lib/actions/delete-record");
|
|
12
|
+
const update_record_1 = require("./lib/actions/update-record");
|
|
13
|
+
const upload_attachment_1 = require("./lib/actions/upload-attachment");
|
|
14
|
+
const auth_1 = require("./lib/auth");
|
|
15
|
+
exports.teable = (0, pieces_framework_1.createPiece)({
|
|
16
|
+
displayName: 'Teable',
|
|
17
|
+
auth: auth_1.TeableAuth,
|
|
18
|
+
description: 'No-code database built on PostgreSQL',
|
|
19
|
+
minimumSupportedRelease: '0.30.0',
|
|
20
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/teable.png',
|
|
21
|
+
categories: [shared_1.PieceCategory.PRODUCTIVITY],
|
|
22
|
+
authors: ['codegino', 'onyedikachi-david'],
|
|
23
|
+
actions: [
|
|
24
|
+
create_record_1.createRecordAction,
|
|
25
|
+
find_records_1.findRecordsAction,
|
|
26
|
+
find_record_1.findRecordAction,
|
|
27
|
+
update_record_1.updateRecordAction,
|
|
28
|
+
delete_record_1.deleteRecordAction,
|
|
29
|
+
upload_attachment_1.uploadAttachmentAction,
|
|
30
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
31
|
+
auth: auth_1.TeableAuth,
|
|
32
|
+
baseUrl: (auth) => `${(0, auth_1.getTeableBaseUrl)(auth)}/api`,
|
|
33
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
return ({
|
|
35
|
+
Authorization: `Bearer ${(0, auth_1.getTeableToken)(auth)}`,
|
|
36
|
+
});
|
|
37
|
+
}),
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
|
+
triggers: [],
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAA6D;AAC7D,iDAAqD;AACrD,+DAAiE;AACjE,6DAA+D;AAC/D,2DAA6D;AAC7D,+DAAiE;AACjE,+DAAiE;AACjE,uEAAyE;AACzE,qCAKoB;AAEP,QAAA,MAAM,GAAG,IAAA,8BAAW,EAAC;IAChC,WAAW,EAAE,QAAQ;IACrB,IAAI,EAAE,iBAAU;IAChB,WAAW,EAAE,sCAAsC;IACnD,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,gDAAgD;IACzD,UAAU,EAAE,CAAC,sBAAa,CAAC,YAAY,CAAC;IACxC,OAAO,EAAE,CAAC,UAAU,EAAE,mBAAmB,CAAC;IAC1C,OAAO,EAAE;QACP,kCAAkB;QAClB,gCAAiB;QACjB,8BAAgB;QAChB,kCAAkB;QAClB,kCAAkB;QAClB,0CAAsB;QACtB,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,iBAAU;YAChB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAA,uBAAgB,EAAC,IAAuB,CAAC,MAAM;YACrE,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,UAAU,IAAA,qBAAc,EAAC,IAAuB,CAAC,EAAE;iBACnE,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const createRecordAction: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>)[], {
|
|
5
|
+
base_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
6
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
}>)[]>;
|
|
9
|
+
table_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
10
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
11
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
12
|
+
}>)[]>;
|
|
13
|
+
fields: import("@activepieces/pieces-framework").DynamicProperties<true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
14
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
15
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
16
|
+
}>)[]>;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRecordAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
exports.createRecordAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.TeableAuth,
|
|
10
|
+
name: 'teable_create_record',
|
|
11
|
+
displayName: 'Create Record',
|
|
12
|
+
description: 'Creates a new record in a Teable table.',
|
|
13
|
+
props: {
|
|
14
|
+
base_id: common_1.TeableCommon.base_id,
|
|
15
|
+
table_id: common_1.TeableCommon.table_id,
|
|
16
|
+
fields: common_1.TeableCommon.fields,
|
|
17
|
+
},
|
|
18
|
+
run(context) {
|
|
19
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const { table_id } = context.propsValue;
|
|
21
|
+
const dynamicFields = context.propsValue.fields;
|
|
22
|
+
const fields = {};
|
|
23
|
+
for (const [key, value] of Object.entries(dynamicFields)) {
|
|
24
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
25
|
+
fields[key] = value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const client = (0, common_1.makeClient)(context.auth);
|
|
29
|
+
return yield client.createRecord(table_id, {
|
|
30
|
+
records: [{ fields }],
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=create-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-record.js","sourceRoot":"","sources":["../../../../src/lib/actions/create-record.ts"],"names":[],"mappings":";;;;AAAA,qEAGwC;AACxC,sCAAqD;AACrD,kCAAsD;AAEzC,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,yCAAyC;IACtD,KAAK,EAAE;QACL,OAAO,EAAE,qBAAY,CAAC,OAAO;QAC7B,QAAQ,EAAE,qBAAY,CAAC,QAAQ;QAC/B,MAAM,EAAE,qBAAY,CAAC,MAAM;KAC5B;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YACxC,MAAM,aAAa,GAAsB,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;YAEnE,MAAM,MAAM,GAA4B,EAAE,CAAC;YAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;gBACzD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;oBAC1D,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBACtB,CAAC;YACH,CAAC;YAED,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,OAAO,CAAC,IAAuB,CAAC,CAAC;YAC3D,OAAO,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE;gBACzC,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;aACtB,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const deleteRecordAction: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>)[], {
|
|
5
|
+
base_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
6
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
}>)[]>;
|
|
9
|
+
table_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
10
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
11
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
12
|
+
}>)[]>;
|
|
13
|
+
record_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
14
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
15
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
16
|
+
}>)[]>;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteRecordAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
exports.deleteRecordAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.TeableAuth,
|
|
10
|
+
name: 'teable_delete_record',
|
|
11
|
+
displayName: 'Delete Record',
|
|
12
|
+
description: 'Deletes a record from a Teable table by its ID.',
|
|
13
|
+
props: {
|
|
14
|
+
base_id: common_1.TeableCommon.base_id,
|
|
15
|
+
table_id: common_1.TeableCommon.table_id,
|
|
16
|
+
record_id: common_1.TeableCommon.record_id,
|
|
17
|
+
},
|
|
18
|
+
run(context) {
|
|
19
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const { table_id, record_id } = context.propsValue;
|
|
21
|
+
const client = (0, common_1.makeClient)(context.auth);
|
|
22
|
+
return yield client.deleteRecord(table_id, record_id);
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=delete-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-record.js","sourceRoot":"","sources":["../../../../src/lib/actions/delete-record.ts"],"names":[],"mappings":";;;;AAAA,qEAA8D;AAC9D,sCAAqD;AACrD,kCAAsD;AAEzC,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,iDAAiD;IAC9D,KAAK,EAAE;QACL,OAAO,EAAE,qBAAY,CAAC,OAAO;QAC7B,QAAQ,EAAE,qBAAY,CAAC,QAAQ;QAC/B,SAAS,EAAE,qBAAY,CAAC,SAAS;KAClC;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YACnD,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,OAAO,CAAC,IAAuB,CAAC,CAAC;YAC3D,OAAO,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACxD,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const findRecordAction: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>)[], {
|
|
5
|
+
base_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
6
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
}>)[]>;
|
|
9
|
+
table_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
10
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
11
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
12
|
+
}>)[]>;
|
|
13
|
+
record_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
14
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
15
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
16
|
+
}>)[]>;
|
|
17
|
+
cellFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findRecordAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
exports.findRecordAction = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.TeableAuth,
|
|
11
|
+
name: 'teable_get_record',
|
|
12
|
+
displayName: 'Get Record',
|
|
13
|
+
description: 'Retrieves a single record from a table by its ID.',
|
|
14
|
+
props: {
|
|
15
|
+
base_id: common_1.TeableCommon.base_id,
|
|
16
|
+
table_id: common_1.TeableCommon.table_id,
|
|
17
|
+
record_id: common_1.TeableCommon.record_id,
|
|
18
|
+
cellFormat: pieces_framework_1.Property.StaticDropdown({
|
|
19
|
+
displayName: 'Cell Format',
|
|
20
|
+
description: 'The format of the cell values in the response.',
|
|
21
|
+
required: false,
|
|
22
|
+
defaultValue: 'json',
|
|
23
|
+
options: {
|
|
24
|
+
options: [
|
|
25
|
+
{ label: 'JSON', value: 'json' },
|
|
26
|
+
{ label: 'Text', value: 'text' },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
run(context) {
|
|
32
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const { table_id, record_id, cellFormat } = context.propsValue;
|
|
34
|
+
const client = (0, common_1.makeClient)(context.auth);
|
|
35
|
+
return yield client.getRecord(table_id, record_id, (0, client_1.prepareQuery)({ cellFormat }));
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=find-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-record.js","sourceRoot":"","sources":["../../../../src/lib/actions/find-record.ts"],"names":[],"mappings":";;;;AAAA,qEAGwC;AACxC,sCAAqD;AACrD,kCAAsD;AACtD,6CAAgD;AAEnC,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,mDAAmD;IAChE,KAAK,EAAE;QACL,OAAO,EAAE,qBAAY,CAAC,OAAO;QAC7B,QAAQ,EAAE,qBAAY,CAAC,QAAQ;QAC/B,SAAS,EAAE,qBAAY,CAAC,SAAS;QACjC,UAAU,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAClC,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,gDAAgD;YAC7D,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,MAAM;YACpB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;oBAChC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;iBACjC;aACF;SACF,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAC/D,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,OAAO,CAAC,IAAuB,CAAC,CAAC;YAC3D,OAAO,MAAM,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAA,qBAAY,EAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;QACnF,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const findRecordsAction: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>)[], {
|
|
5
|
+
base_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
6
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
}>)[]>;
|
|
9
|
+
table_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
10
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
11
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
12
|
+
}>)[]>;
|
|
13
|
+
filter: import("@activepieces/pieces-framework").LongTextProperty<false>;
|
|
14
|
+
cellFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
|
|
15
|
+
take: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
16
|
+
skip: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
17
|
+
selectedRecordIds: import("@activepieces/pieces-framework").ArrayProperty<false>;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findRecordsAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
exports.findRecordsAction = (0, pieces_framework_1.createAction)({
|
|
10
|
+
auth: auth_1.TeableAuth,
|
|
11
|
+
name: 'teable_list_records',
|
|
12
|
+
displayName: 'List Records',
|
|
13
|
+
description: 'Retrieves a list of records from a table with optional filtering, sorting, and pagination.',
|
|
14
|
+
props: {
|
|
15
|
+
base_id: common_1.TeableCommon.base_id,
|
|
16
|
+
table_id: common_1.TeableCommon.table_id,
|
|
17
|
+
filter: pieces_framework_1.Property.LongText({
|
|
18
|
+
displayName: 'Filter',
|
|
19
|
+
description: 'A filter expression for the records. Use the visual query builder at https://app.teable.ai/developer/tool/query-builder to build one.',
|
|
20
|
+
required: false,
|
|
21
|
+
}),
|
|
22
|
+
cellFormat: pieces_framework_1.Property.StaticDropdown({
|
|
23
|
+
displayName: 'Cell Format',
|
|
24
|
+
description: 'The format of the cell values in the response.',
|
|
25
|
+
required: false,
|
|
26
|
+
defaultValue: 'json',
|
|
27
|
+
options: {
|
|
28
|
+
options: [
|
|
29
|
+
{ label: 'JSON', value: 'json' },
|
|
30
|
+
{ label: 'Text', value: 'text' },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
take: pieces_framework_1.Property.Number({
|
|
35
|
+
displayName: 'Take',
|
|
36
|
+
description: 'The record count you want to take, maximum is 1000.',
|
|
37
|
+
required: false,
|
|
38
|
+
defaultValue: 100,
|
|
39
|
+
}),
|
|
40
|
+
skip: pieces_framework_1.Property.Number({
|
|
41
|
+
displayName: 'Skip',
|
|
42
|
+
description: 'The records count you want to skip.',
|
|
43
|
+
required: false,
|
|
44
|
+
defaultValue: 0,
|
|
45
|
+
}),
|
|
46
|
+
selectedRecordIds: pieces_framework_1.Property.Array({
|
|
47
|
+
displayName: 'Selected Record IDs',
|
|
48
|
+
description: 'Filter selected records by record ids.',
|
|
49
|
+
required: false,
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
run(context) {
|
|
53
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const { table_id, filter, cellFormat, take, skip, selectedRecordIds } = context.propsValue;
|
|
55
|
+
const client = (0, common_1.makeClient)(context.auth);
|
|
56
|
+
return yield client.listRecords(table_id, (0, client_1.prepareQuery)({
|
|
57
|
+
filter,
|
|
58
|
+
cellFormat,
|
|
59
|
+
take,
|
|
60
|
+
skip,
|
|
61
|
+
selectedRecordIds,
|
|
62
|
+
}));
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=find-records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-records.js","sourceRoot":"","sources":["../../../../src/lib/actions/find-records.ts"],"names":[],"mappings":";;;;AAAA,qEAGwC;AACxC,sCAAqD;AACrD,kCAAsD;AACtD,6CAAgD;AAEnC,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,4FAA4F;IACzG,KAAK,EAAE;QACL,OAAO,EAAE,qBAAY,CAAC,OAAO;QAC7B,QAAQ,EAAE,qBAAY,CAAC,QAAQ;QAC/B,MAAM,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACxB,WAAW,EAAE,QAAQ;YACrB,WAAW,EACT,uIAAuI;YACzI,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAClC,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,gDAAgD;YAC7D,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,MAAM;YACpB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;oBAChC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;iBACjC;aACF;SACF,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,qDAAqD;YAClE,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,GAAG;SAClB,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,qCAAqC;YAClD,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,CAAC;SAChB,CAAC;QACF,iBAAiB,EAAE,2BAAQ,CAAC,KAAK,CAAC;YAChC,WAAW,EAAE,qBAAqB;YAClC,WAAW,EAAE,wCAAwC;YACrD,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YAE3F,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,OAAO,CAAC,IAAuB,CAAC,CAAC;YAE3D,OAAO,MAAM,MAAM,CAAC,WAAW,CAC7B,QAAQ,EACR,IAAA,qBAAY,EAAC;gBACX,MAAM;gBACN,UAAU;gBACV,IAAI;gBACJ,IAAI;gBACJ,iBAAiB;aAClB,CAAC,CACH,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const updateRecordAction: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>)[], {
|
|
5
|
+
base_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
6
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
}>)[]>;
|
|
9
|
+
table_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
10
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
11
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
12
|
+
}>)[]>;
|
|
13
|
+
record_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
14
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
15
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
16
|
+
}>)[]>;
|
|
17
|
+
fields: import("@activepieces/pieces-framework").DynamicProperties<true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
18
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
19
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
20
|
+
}>)[]>;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateRecordAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
exports.updateRecordAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.TeableAuth,
|
|
10
|
+
name: 'teable_update_record',
|
|
11
|
+
displayName: 'Update Record',
|
|
12
|
+
description: 'Updates an existing record in a Teable table.',
|
|
13
|
+
props: {
|
|
14
|
+
base_id: common_1.TeableCommon.base_id,
|
|
15
|
+
table_id: common_1.TeableCommon.table_id,
|
|
16
|
+
record_id: common_1.TeableCommon.record_id,
|
|
17
|
+
fields: common_1.TeableCommon.fields,
|
|
18
|
+
},
|
|
19
|
+
run(context) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const { table_id, record_id } = context.propsValue;
|
|
22
|
+
const dynamicFields = context.propsValue.fields;
|
|
23
|
+
const fields = {};
|
|
24
|
+
for (const [key, value] of Object.entries(dynamicFields)) {
|
|
25
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
26
|
+
fields[key] = value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const client = (0, common_1.makeClient)(context.auth);
|
|
30
|
+
return yield client.updateRecord(table_id, record_id, { record: { fields } });
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=update-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-record.js","sourceRoot":"","sources":["../../../../src/lib/actions/update-record.ts"],"names":[],"mappings":";;;;AAAA,qEAGwC;AACxC,sCAAqD;AACrD,kCAAsD;AAEzC,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,+CAA+C;IAC5D,KAAK,EAAE;QACN,OAAO,EAAE,qBAAY,CAAC,OAAO;QAC7B,QAAQ,EAAE,qBAAY,CAAC,QAAQ;QAC/B,SAAS,EAAE,qBAAY,CAAC,SAAS;QACjC,MAAM,EAAE,qBAAY,CAAC,MAAM;KAC3B;IACK,GAAG,CAAC,OAAO;;YAChB,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YACnD,MAAM,aAAa,GAAsB,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;YAEnE,MAAM,MAAM,GAA4B,EAAE,CAAC;YAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;gBAC1D,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;oBAC3D,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBACrB,CAAC;YACF,CAAC;YAED,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,OAAO,CAAC,IAAuB,CAAC,CAAC;YAC3D,OAAO,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QAC/E,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const uploadAttachmentAction: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
3
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
}>)[], {
|
|
5
|
+
base_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
6
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
|
+
}>)[]>;
|
|
9
|
+
table_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
10
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
11
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
12
|
+
}>)[]>;
|
|
13
|
+
record_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
14
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
15
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
16
|
+
}>)[]>;
|
|
17
|
+
field_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
18
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
19
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
20
|
+
}>)[]>;
|
|
21
|
+
file: import("@activepieces/pieces-framework").FileProperty<true>;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uploadAttachmentAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
exports.uploadAttachmentAction = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: auth_1.TeableAuth,
|
|
10
|
+
name: 'teable_upload_attachment',
|
|
11
|
+
displayName: 'Upload Attachment',
|
|
12
|
+
description: 'Uploads a file as an attachment to a field in a Teable record.',
|
|
13
|
+
props: {
|
|
14
|
+
base_id: common_1.TeableCommon.base_id,
|
|
15
|
+
table_id: common_1.TeableCommon.table_id,
|
|
16
|
+
record_id: common_1.TeableCommon.record_id,
|
|
17
|
+
field_id: pieces_framework_1.Property.Dropdown({
|
|
18
|
+
auth: auth_1.TeableAuth,
|
|
19
|
+
displayName: 'Attachment Field',
|
|
20
|
+
description: 'The attachment field to upload the file to.',
|
|
21
|
+
required: true,
|
|
22
|
+
refreshers: ['table_id'],
|
|
23
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, table_id }) {
|
|
24
|
+
if (!auth || !table_id) {
|
|
25
|
+
return { disabled: true, options: [], placeholder: 'Select a table first.' };
|
|
26
|
+
}
|
|
27
|
+
const client = (0, common_1.makeClient)(auth);
|
|
28
|
+
const fields = yield client.listFields(table_id);
|
|
29
|
+
const attachmentFields = fields.filter((f) => f.type === 'attachment');
|
|
30
|
+
return {
|
|
31
|
+
disabled: false,
|
|
32
|
+
options: attachmentFields.map((f) => ({ label: f.name, value: f.id })),
|
|
33
|
+
};
|
|
34
|
+
}),
|
|
35
|
+
}),
|
|
36
|
+
file: pieces_framework_1.Property.File({
|
|
37
|
+
displayName: 'File',
|
|
38
|
+
description: 'The file to upload. Accepts a URL or a binary file.',
|
|
39
|
+
required: true,
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
42
|
+
run(context) {
|
|
43
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const { table_id, record_id, field_id } = context.propsValue;
|
|
45
|
+
const client = (0, common_1.makeClient)(context.auth);
|
|
46
|
+
const file = context.propsValue.file;
|
|
47
|
+
const form = new FormData();
|
|
48
|
+
if (typeof file === 'string' && /^https?:\/\//i.test(file)) {
|
|
49
|
+
form.append('fileUrl', file);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const apFile = file;
|
|
53
|
+
const mimeType = apFile.extension
|
|
54
|
+
? `application/${apFile.extension.replace(/^\./, '')}`
|
|
55
|
+
: 'application/octet-stream';
|
|
56
|
+
form.append('file', new Blob([new Uint8Array(apFile.data)], { type: mimeType }), apFile.filename);
|
|
57
|
+
}
|
|
58
|
+
return yield client.uploadAttachment(table_id, record_id, field_id, form);
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=upload-attachment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-attachment.js","sourceRoot":"","sources":["../../../../src/lib/actions/upload-attachment.ts"],"names":[],"mappings":";;;;AAAA,qEAAgF;AAChF,kCAAsD;AACtD,sCAAqD;AAExC,QAAA,sBAAsB,GAAG,IAAA,+BAAY,EAAC;IACjD,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,0BAA0B;IAChC,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,gEAAgE;IAC7E,KAAK,EAAE;QACL,OAAO,EAAE,qBAAY,CAAC,OAAO;QAC7B,QAAQ,EAAE,qBAAY,CAAC,QAAQ;QAC/B,SAAS,EAAE,qBAAY,CAAC,SAAS;QACjC,QAAQ,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC1B,IAAI,EAAE,iBAAU;YAChB,WAAW,EAAE,kBAAkB;YAC/B,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,CAAC,UAAU,CAAC;YACxB,OAAO,EAAE,KAA2B,EAAE,oDAAtB,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAChC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AAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,MAAM,MAAM,GAAG,IAAc,CAAC;gBAC9B,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS;oBAC/B,CAAC,CAAC,eAAe,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE;oBACtD,CAAC,CAAC,0BAA0B,CAAC;gBAC/B,IAAI,CAAC,MAAM,CACT,MAAM,EACN,IAAI,IAAI,CAAC,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAC3D,MAAM,CAAC,QAAQ,CAChB,CAAC;YACJ,CAAC;YAED,OAAO,MAAM,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC5E,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AppConnectionType } from '@activepieces/shared';
|
|
2
|
+
export declare const TeableAuth: (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
3
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
}>)[];
|
|
6
|
+
export type TeableAuthValue = {
|
|
7
|
+
type: AppConnectionType.OAUTH2;
|
|
8
|
+
access_token: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: AppConnectionType.CUSTOM_AUTH;
|
|
11
|
+
props: {
|
|
12
|
+
token: string;
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare function getTeableToken(auth: TeableAuthValue): string;
|
|
17
|
+
export declare function getTeableBaseUrl(auth: TeableAuthValue): string;
|
package/src/lib/auth.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TeableAuth = void 0;
|
|
4
|
+
exports.getTeableToken = getTeableToken;
|
|
5
|
+
exports.getTeableBaseUrl = getTeableBaseUrl;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
8
|
+
const shared_1 = require("@activepieces/shared");
|
|
9
|
+
const client_1 = require("./common/client");
|
|
10
|
+
const constants_1 = require("./common/constants");
|
|
11
|
+
exports.TeableAuth = [
|
|
12
|
+
pieces_framework_1.PieceAuth.OAuth2({
|
|
13
|
+
description: 'Connect your Teable account using OAuth2 (Teable Cloud only).',
|
|
14
|
+
authUrl: 'https://app.teable.ai/api/oauth/authorize',
|
|
15
|
+
tokenUrl: 'https://app.teable.ai/api/oauth/access_token',
|
|
16
|
+
required: true,
|
|
17
|
+
scope: [
|
|
18
|
+
'base|read',
|
|
19
|
+
'table|read',
|
|
20
|
+
'field|read',
|
|
21
|
+
'record|read',
|
|
22
|
+
'record|create',
|
|
23
|
+
'record|update',
|
|
24
|
+
'record|delete',
|
|
25
|
+
],
|
|
26
|
+
}),
|
|
27
|
+
pieces_framework_1.PieceAuth.CustomAuth({
|
|
28
|
+
displayName: 'Personal Access Token',
|
|
29
|
+
description: `
|
|
30
|
+
Authenticate using a Teable Personal Access Token. Also use this option for self-hosted instances.
|
|
31
|
+
|
|
32
|
+
To obtain your token:
|
|
33
|
+
1. Log in to your Teable account.
|
|
34
|
+
2. Click your profile icon (top-right corner).
|
|
35
|
+
3. Go to **Settings** > **Personal Access Token**.
|
|
36
|
+
4. Click **New Token**, set a name and the required scopes.
|
|
37
|
+
5. Copy and save the generated token.
|
|
38
|
+
`,
|
|
39
|
+
required: true,
|
|
40
|
+
props: {
|
|
41
|
+
token: pieces_framework_1.PieceAuth.SecretText({
|
|
42
|
+
displayName: 'Personal Access Token',
|
|
43
|
+
description: 'Your Teable personal access token.',
|
|
44
|
+
required: true,
|
|
45
|
+
}),
|
|
46
|
+
baseUrl: pieces_framework_1.Property.ShortText({
|
|
47
|
+
displayName: 'Base URL',
|
|
48
|
+
description: 'Teable Cloud: https://app.teable.ai — for self-hosted, enter your own domain.',
|
|
49
|
+
required: false,
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
53
|
+
try {
|
|
54
|
+
const client = new client_1.TeableClient(auth.token, auth.baseUrl || constants_1.TEABLE_CLOUD_URL);
|
|
55
|
+
yield client.listBases();
|
|
56
|
+
return { valid: true };
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
return {
|
|
60
|
+
valid: false,
|
|
61
|
+
error: e instanceof Error ? e.message : 'Invalid credentials. Check your token and Base URL.',
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
}),
|
|
66
|
+
];
|
|
67
|
+
function getTeableToken(auth) {
|
|
68
|
+
if (auth.type === shared_1.AppConnectionType.OAUTH2) {
|
|
69
|
+
return auth.access_token;
|
|
70
|
+
}
|
|
71
|
+
return auth.props.token;
|
|
72
|
+
}
|
|
73
|
+
function getTeableBaseUrl(auth) {
|
|
74
|
+
if (auth.type === shared_1.AppConnectionType.OAUTH2) {
|
|
75
|
+
return constants_1.TEABLE_CLOUD_URL;
|
|
76
|
+
}
|
|
77
|
+
return auth.props.baseUrl || constants_1.TEABLE_CLOUD_URL;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":";;;AAyEA,wCAKC;AAED,4CAKC;;AArFD,qEAAqE;AACrE,iDAAyD;AACzD,4CAA+C;AAC/C,kDAAsD;AA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;IAClD,IAAI,IAAI,CAAC,IAAI,KAAK,0BAAiB,CAAC,MAAM,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;AAC1B,CAAC;AAED,SAAgB,gBAAgB,CAAC,IAAqB;IACpD,IAAI,IAAI,CAAC,IAAI,KAAK,0BAAiB,CAAC,MAAM,EAAE,CAAC;QAC3C,OAAO,4BAAgB,CAAC;IAC1B,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,4BAAgB,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { HttpMessageBody, HttpMethod, QueryParams } from '@activepieces/pieces-common';
|
|
2
|
+
export declare function prepareQuery(request?: Record<string, any>): QueryParams;
|
|
3
|
+
export declare class TeableClient {
|
|
4
|
+
private token;
|
|
5
|
+
private readonly apiBase;
|
|
6
|
+
constructor(token: string, teableUrl?: string);
|
|
7
|
+
makeRequest<T extends HttpMessageBody>(method: HttpMethod, resourceUri: string, query?: QueryParams, body?: any | undefined): Promise<T>;
|
|
8
|
+
/**
|
|
9
|
+
* GET /api/base/access/all
|
|
10
|
+
* Returns all bases the token has access to.
|
|
11
|
+
* @see https://help.teable.ai/en/api-reference/base/get-baseaccessall
|
|
12
|
+
*/
|
|
13
|
+
listBases(): Promise<{
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
spaceId: string;
|
|
17
|
+
icon: string | null;
|
|
18
|
+
role: string;
|
|
19
|
+
}[]>;
|
|
20
|
+
/**
|
|
21
|
+
* GET /api/base/{baseId}/table
|
|
22
|
+
* Returns all tables in the given base.
|
|
23
|
+
* @see https://help.teable.ai/en/api-reference/table/list-tables
|
|
24
|
+
*/
|
|
25
|
+
listTables(baseId: string): Promise<{
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
dbTableName: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
icon?: string;
|
|
31
|
+
order: number;
|
|
32
|
+
defaultViewId?: string;
|
|
33
|
+
}[]>;
|
|
34
|
+
/**
|
|
35
|
+
* GET /api/table/{tableId}/field
|
|
36
|
+
* Returns all fields in the given table.
|
|
37
|
+
* @see https://help.teable.ai/en/api-reference/field/list-fields
|
|
38
|
+
*/
|
|
39
|
+
listFields(tableId: string): Promise<{
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
type: string;
|
|
43
|
+
isComputed?: boolean;
|
|
44
|
+
isPrimary?: boolean;
|
|
45
|
+
options?: {
|
|
46
|
+
choices?: {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
color?: string;
|
|
50
|
+
}[];
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
};
|
|
53
|
+
}[]>;
|
|
54
|
+
/**
|
|
55
|
+
* GET /api/table/{tableId}/record/{recordId}
|
|
56
|
+
* Retrieves a single record by its ID.
|
|
57
|
+
* @see https://help.teable.ai/en/api-reference/record/get-record
|
|
58
|
+
*/
|
|
59
|
+
getRecord(tableId: string, recordId: string, query?: QueryParams): Promise<{
|
|
60
|
+
id: string;
|
|
61
|
+
fields: Record<string, unknown>;
|
|
62
|
+
name: string;
|
|
63
|
+
autoNumber: number;
|
|
64
|
+
createdTime: string;
|
|
65
|
+
lastModifiedTime: string;
|
|
66
|
+
createdBy: string;
|
|
67
|
+
lastModifiedBy: string;
|
|
68
|
+
permissions: Record<string, unknown>;
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* GET /api/table/{tableId}/record
|
|
72
|
+
* Retrieves a list of records with support for filtering, sorting, and pagination.
|
|
73
|
+
* @see https://help.teable.ai/en/api-reference/record/list-records
|
|
74
|
+
*/
|
|
75
|
+
listRecords(tableId: string, query?: QueryParams): Promise<{
|
|
76
|
+
records: {
|
|
77
|
+
id: string;
|
|
78
|
+
fields: Record<string, unknown>;
|
|
79
|
+
}[];
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* POST /api/table/{tableId}/record
|
|
83
|
+
* Creates one or more records.
|
|
84
|
+
*/
|
|
85
|
+
createRecord(tableId: string, request: object): Promise<unknown>;
|
|
86
|
+
/**
|
|
87
|
+
* DELETE /api/table/{tableId}/record/{recordId}
|
|
88
|
+
* Deletes a single record.
|
|
89
|
+
*/
|
|
90
|
+
deleteRecord(tableId: string, recordId: string): Promise<unknown>;
|
|
91
|
+
/**
|
|
92
|
+
* PATCH /api/table/{tableId}/record/{recordId}
|
|
93
|
+
* Updates a single record.
|
|
94
|
+
*/
|
|
95
|
+
updateRecord(tableId: string, recordId: string, request: object): Promise<unknown>;
|
|
96
|
+
/**
|
|
97
|
+
* POST /api/table/{tableId}/record/{recordId}/{fieldId}/uploadAttachment
|
|
98
|
+
* Uploads a file as an attachment to a specific field in a record.
|
|
99
|
+
*/
|
|
100
|
+
uploadAttachment(tableId: string, recordId: string, fieldId: string, form: FormData): Promise<any>;
|
|
101
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TeableClient = void 0;
|
|
4
|
+
exports.prepareQuery = prepareQuery;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
function emptyValueFilter(accessor) {
|
|
9
|
+
return (key) => {
|
|
10
|
+
const val = accessor(key);
|
|
11
|
+
return (val !== null &&
|
|
12
|
+
val !== undefined &&
|
|
13
|
+
(typeof val !== 'string' || val.length > 0) &&
|
|
14
|
+
(!Array.isArray(val) || val.length > 0));
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function prepareQuery(request) {
|
|
18
|
+
const params = {};
|
|
19
|
+
if (!request)
|
|
20
|
+
return params;
|
|
21
|
+
Object.keys(request)
|
|
22
|
+
.filter(emptyValueFilter((k) => request[k]))
|
|
23
|
+
.forEach((k) => {
|
|
24
|
+
const val = request[k];
|
|
25
|
+
params[k] = Array.isArray(val) ? val : val.toString();
|
|
26
|
+
});
|
|
27
|
+
return params;
|
|
28
|
+
}
|
|
29
|
+
class TeableClient {
|
|
30
|
+
constructor(token, teableUrl = constants_1.TEABLE_CLOUD_URL) {
|
|
31
|
+
this.token = token;
|
|
32
|
+
this.apiBase = `${teableUrl}/api`;
|
|
33
|
+
}
|
|
34
|
+
makeRequest(method_1, resourceUri_1, query_1) {
|
|
35
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (method, resourceUri, query, body = undefined) {
|
|
36
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
37
|
+
method,
|
|
38
|
+
url: this.apiBase + resourceUri,
|
|
39
|
+
authentication: {
|
|
40
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
41
|
+
token: this.token,
|
|
42
|
+
},
|
|
43
|
+
queryParams: query,
|
|
44
|
+
body: body,
|
|
45
|
+
});
|
|
46
|
+
return res.body;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* GET /api/base/access/all
|
|
51
|
+
* Returns all bases the token has access to.
|
|
52
|
+
* @see https://help.teable.ai/en/api-reference/base/get-baseaccessall
|
|
53
|
+
*/
|
|
54
|
+
listBases() {
|
|
55
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
return yield this.makeRequest(pieces_common_1.HttpMethod.GET, '/base/access/all');
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* GET /api/base/{baseId}/table
|
|
61
|
+
* Returns all tables in the given base.
|
|
62
|
+
* @see https://help.teable.ai/en/api-reference/table/list-tables
|
|
63
|
+
*/
|
|
64
|
+
listTables(baseId) {
|
|
65
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
return yield this.makeRequest(pieces_common_1.HttpMethod.GET, `/base/${baseId}/table`);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* GET /api/table/{tableId}/field
|
|
71
|
+
* Returns all fields in the given table.
|
|
72
|
+
* @see https://help.teable.ai/en/api-reference/field/list-fields
|
|
73
|
+
*/
|
|
74
|
+
listFields(tableId) {
|
|
75
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
return yield this.makeRequest(pieces_common_1.HttpMethod.GET, `/table/${tableId}/field`);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* GET /api/table/{tableId}/record/{recordId}
|
|
81
|
+
* Retrieves a single record by its ID.
|
|
82
|
+
* @see https://help.teable.ai/en/api-reference/record/get-record
|
|
83
|
+
*/
|
|
84
|
+
getRecord(tableId, recordId, query) {
|
|
85
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
return yield this.makeRequest(pieces_common_1.HttpMethod.GET, `/table/${tableId}/record/${recordId}`, query);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* GET /api/table/{tableId}/record
|
|
91
|
+
* Retrieves a list of records with support for filtering, sorting, and pagination.
|
|
92
|
+
* @see https://help.teable.ai/en/api-reference/record/list-records
|
|
93
|
+
*/
|
|
94
|
+
listRecords(tableId, query) {
|
|
95
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
return yield this.makeRequest(pieces_common_1.HttpMethod.GET, `/table/${tableId}/record`, query);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* POST /api/table/{tableId}/record
|
|
101
|
+
* Creates one or more records.
|
|
102
|
+
*/
|
|
103
|
+
createRecord(tableId, request) {
|
|
104
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
return yield this.makeRequest(pieces_common_1.HttpMethod.POST, `/table/${tableId}/record`, undefined, request);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* DELETE /api/table/{tableId}/record/{recordId}
|
|
110
|
+
* Deletes a single record.
|
|
111
|
+
*/
|
|
112
|
+
deleteRecord(tableId, recordId) {
|
|
113
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
return yield this.makeRequest(pieces_common_1.HttpMethod.DELETE, `/table/${tableId}/record/${recordId}`);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* PATCH /api/table/{tableId}/record/{recordId}
|
|
119
|
+
* Updates a single record.
|
|
120
|
+
*/
|
|
121
|
+
updateRecord(tableId, recordId, request) {
|
|
122
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
return yield this.makeRequest(pieces_common_1.HttpMethod.PATCH, `/table/${tableId}/record/${recordId}`, undefined, request);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* POST /api/table/{tableId}/record/{recordId}/{fieldId}/uploadAttachment
|
|
128
|
+
* Uploads a file as an attachment to a specific field in a record.
|
|
129
|
+
*/
|
|
130
|
+
uploadAttachment(tableId, recordId, fieldId, form) {
|
|
131
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
133
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
134
|
+
url: `${this.apiBase}/table/${tableId}/record/${recordId}/${fieldId}/uploadAttachment`,
|
|
135
|
+
authentication: {
|
|
136
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
137
|
+
token: this.token,
|
|
138
|
+
},
|
|
139
|
+
body: form,
|
|
140
|
+
});
|
|
141
|
+
return res.body;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.TeableClient = TeableClient;
|
|
146
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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user",
|
|
5
|
+
CHECKBOX = "checkbox",
|
|
6
|
+
MULTIPLE_SELECT = "multipleSelect",
|
|
7
|
+
SINGLE_SELECT = "singleSelect",
|
|
8
|
+
DATE = "date",
|
|
9
|
+
NUMBER = "number",
|
|
10
|
+
RATING = "rating",
|
|
11
|
+
LINK = "link",
|
|
12
|
+
ATTACHMENT = "attachment",
|
|
13
|
+
FORMULA = "formula",
|
|
14
|
+
ROLLUP = "rollup",
|
|
15
|
+
CONDITIONAL_ROLLUP = "conditionalRollup",
|
|
16
|
+
CREATED_TIME = "createdTime",
|
|
17
|
+
LAST_MODIFIED_TIME = "lastModifiedTime",
|
|
18
|
+
CREATED_BY = "createdBy",
|
|
19
|
+
LAST_MODIFIED_BY = "lastModifiedBy",
|
|
20
|
+
AUTO_NUMBER = "autoNumber",
|
|
21
|
+
BUTTON = "button"
|
|
22
|
+
}
|
|
23
|
+
export declare const TeableNumericFieldTypes: string[];
|
|
24
|
+
export declare const TeableComputedFieldTypes: string[];
|
|
25
|
+
export declare const TEABLE_CLOUD_URL = "https://app.teable.ai";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TEABLE_CLOUD_URL = exports.TeableComputedFieldTypes = exports.TeableNumericFieldTypes = exports.TeableFieldType = void 0;
|
|
4
|
+
// Teable field types as returned by GET /api/table/{tableId}/field
|
|
5
|
+
// @see https://help.teable.ai/en/api-reference/field/list-fields
|
|
6
|
+
var TeableFieldType;
|
|
7
|
+
(function (TeableFieldType) {
|
|
8
|
+
TeableFieldType["SINGLE_LINE_TEXT"] = "singleLineText";
|
|
9
|
+
TeableFieldType["LONG_TEXT"] = "longText";
|
|
10
|
+
TeableFieldType["USER"] = "user";
|
|
11
|
+
TeableFieldType["CHECKBOX"] = "checkbox";
|
|
12
|
+
TeableFieldType["MULTIPLE_SELECT"] = "multipleSelect";
|
|
13
|
+
TeableFieldType["SINGLE_SELECT"] = "singleSelect";
|
|
14
|
+
TeableFieldType["DATE"] = "date";
|
|
15
|
+
TeableFieldType["NUMBER"] = "number";
|
|
16
|
+
TeableFieldType["RATING"] = "rating";
|
|
17
|
+
TeableFieldType["LINK"] = "link";
|
|
18
|
+
// Computed — read-only, excluded from create/update
|
|
19
|
+
TeableFieldType["ATTACHMENT"] = "attachment";
|
|
20
|
+
TeableFieldType["FORMULA"] = "formula";
|
|
21
|
+
TeableFieldType["ROLLUP"] = "rollup";
|
|
22
|
+
TeableFieldType["CONDITIONAL_ROLLUP"] = "conditionalRollup";
|
|
23
|
+
TeableFieldType["CREATED_TIME"] = "createdTime";
|
|
24
|
+
TeableFieldType["LAST_MODIFIED_TIME"] = "lastModifiedTime";
|
|
25
|
+
TeableFieldType["CREATED_BY"] = "createdBy";
|
|
26
|
+
TeableFieldType["LAST_MODIFIED_BY"] = "lastModifiedBy";
|
|
27
|
+
TeableFieldType["AUTO_NUMBER"] = "autoNumber";
|
|
28
|
+
TeableFieldType["BUTTON"] = "button";
|
|
29
|
+
})(TeableFieldType || (exports.TeableFieldType = TeableFieldType = {}));
|
|
30
|
+
exports.TeableNumericFieldTypes = [
|
|
31
|
+
TeableFieldType.NUMBER,
|
|
32
|
+
TeableFieldType.RATING,
|
|
33
|
+
];
|
|
34
|
+
exports.TeableComputedFieldTypes = [
|
|
35
|
+
TeableFieldType.ATTACHMENT,
|
|
36
|
+
TeableFieldType.FORMULA,
|
|
37
|
+
TeableFieldType.ROLLUP,
|
|
38
|
+
TeableFieldType.CONDITIONAL_ROLLUP,
|
|
39
|
+
TeableFieldType.CREATED_TIME,
|
|
40
|
+
TeableFieldType.LAST_MODIFIED_TIME,
|
|
41
|
+
TeableFieldType.CREATED_BY,
|
|
42
|
+
TeableFieldType.LAST_MODIFIED_BY,
|
|
43
|
+
TeableFieldType.AUTO_NUMBER,
|
|
44
|
+
TeableFieldType.BUTTON,
|
|
45
|
+
];
|
|
46
|
+
exports.TEABLE_CLOUD_URL = 'https://app.teable.ai';
|
|
47
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/lib/common/constants.ts"],"names":[],"mappings":";;;AAAA,mEAAmE;AACnE,iEAAiE;AACjE,IAAY,eAsBX;AAtBD,WAAY,eAAe;IAC1B,sDAAmC,CAAA;IACnC,yCAAsB,CAAA;IACtB,gCAAa,CAAA;IACb,wCAAqB,CAAA;IACrB,qDAAkC,CAAA;IAClC,iDAA8B,CAAA;IAC9B,gCAAa,CAAA;IACb,oCAAiB,CAAA;IACjB,oCAAiB,CAAA;IACjB,gCAAa,CAAA;IACb,oDAAoD;IACpD,4CAAyB,CAAA;IACzB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;IACjB,2DAAwC,CAAA;IACxC,+CAA4B,CAAA;IAC5B,0DAAuC,CAAA;IACvC,2CAAwB,CAAA;IACxB,sDAAmC,CAAA;IACnC,6CAA0B,CAAA;IAC1B,oCAAiB,CAAA;AAClB,CAAC,EAtBW,eAAe,+BAAf,eAAe,QAsB1B;AAEY,QAAA,uBAAuB,GAAa;IAChD,eAAe,CAAC,MAAM;IACtB,eAAe,CAAC,MAAM;CACtB,CAAC;AAEW,QAAA,wBAAwB,GAAa;IACjD,eAAe,CAAC,UAAU;IAC1B,eAAe,CAAC,OAAO;IACvB,eAAe,CAAC,MAAM;IACtB,eAAe,CAAC,kBAAkB;IAClC,eAAe,CAAC,YAAY;IAC5B,eAAe,CAAC,kBAAkB;IAClC,eAAe,CAAC,UAAU;IAC1B,eAAe,CAAC,gBAAgB;IAChC,eAAe,CAAC,WAAW;IAC3B,eAAe,CAAC,MAAM;CACtB,CAAC;AAEW,QAAA,gBAAgB,GAAG,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TeableAuthValue } from '../auth';
|
|
2
|
+
import { TeableClient } from './client';
|
|
3
|
+
import { TeableComputedFieldTypes, TeableFieldType } from './constants';
|
|
4
|
+
export declare function makeClient(auth: TeableAuthValue): TeableClient;
|
|
5
|
+
export declare const TeableCommon: {
|
|
6
|
+
base_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
7
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
8
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
}>)[]>;
|
|
10
|
+
table_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
11
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
12
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
13
|
+
}>)[]>;
|
|
14
|
+
record_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
15
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
16
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
17
|
+
}>)[]>;
|
|
18
|
+
fields: import("@activepieces/pieces-framework").DynamicProperties<true, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
19
|
+
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
20
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
21
|
+
}>)[]>;
|
|
22
|
+
};
|
|
23
|
+
export { TeableFieldType, TeableComputedFieldTypes };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TeableComputedFieldTypes = exports.TeableFieldType = exports.TeableCommon = void 0;
|
|
4
|
+
exports.makeClient = makeClient;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const auth_1 = require("../auth");
|
|
8
|
+
const client_1 = require("./client");
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
Object.defineProperty(exports, "TeableComputedFieldTypes", { enumerable: true, get: function () { return constants_1.TeableComputedFieldTypes; } });
|
|
11
|
+
Object.defineProperty(exports, "TeableFieldType", { enumerable: true, get: function () { return constants_1.TeableFieldType; } });
|
|
12
|
+
function makeClient(auth) {
|
|
13
|
+
return new client_1.TeableClient((0, auth_1.getTeableToken)(auth), (0, auth_1.getTeableBaseUrl)(auth));
|
|
14
|
+
}
|
|
15
|
+
exports.TeableCommon = {
|
|
16
|
+
base_id: pieces_framework_1.Property.Dropdown({
|
|
17
|
+
auth: auth_1.TeableAuth,
|
|
18
|
+
displayName: 'Base',
|
|
19
|
+
required: true,
|
|
20
|
+
refreshers: [],
|
|
21
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
22
|
+
if (!auth) {
|
|
23
|
+
return { disabled: true, options: [], placeholder: 'Connect your account first.' };
|
|
24
|
+
}
|
|
25
|
+
const client = makeClient(auth);
|
|
26
|
+
const bases = yield client.listBases();
|
|
27
|
+
return {
|
|
28
|
+
disabled: false,
|
|
29
|
+
options: bases.map((b) => ({ label: b.name, value: b.id })),
|
|
30
|
+
};
|
|
31
|
+
}),
|
|
32
|
+
}),
|
|
33
|
+
table_id: pieces_framework_1.Property.Dropdown({
|
|
34
|
+
auth: auth_1.TeableAuth,
|
|
35
|
+
displayName: 'Table',
|
|
36
|
+
description: 'The table inside the selected base.',
|
|
37
|
+
required: true,
|
|
38
|
+
refreshers: ['base_id'],
|
|
39
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, base_id }) {
|
|
40
|
+
if (!auth || !base_id) {
|
|
41
|
+
return { disabled: true, options: [], placeholder: 'Select a base first.' };
|
|
42
|
+
}
|
|
43
|
+
const client = makeClient(auth);
|
|
44
|
+
const tables = yield client.listTables(base_id);
|
|
45
|
+
return {
|
|
46
|
+
disabled: false,
|
|
47
|
+
options: tables.map((t) => ({ label: t.name, value: t.id })),
|
|
48
|
+
};
|
|
49
|
+
}),
|
|
50
|
+
}),
|
|
51
|
+
record_id: pieces_framework_1.Property.Dropdown({
|
|
52
|
+
auth: auth_1.TeableAuth,
|
|
53
|
+
displayName: 'Record',
|
|
54
|
+
description: 'The record to act on.',
|
|
55
|
+
required: true,
|
|
56
|
+
refreshers: ['table_id'],
|
|
57
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, table_id }) {
|
|
58
|
+
if (!auth || !table_id) {
|
|
59
|
+
return { disabled: true, options: [], placeholder: 'Select a table first.' };
|
|
60
|
+
}
|
|
61
|
+
const client = makeClient(auth);
|
|
62
|
+
const response = yield client.listRecords(table_id);
|
|
63
|
+
return {
|
|
64
|
+
disabled: false,
|
|
65
|
+
options: response.records.map((r) => {
|
|
66
|
+
const primaryValue = Object.values(r.fields)[0];
|
|
67
|
+
const label = primaryValue !== undefined && primaryValue !== null && primaryValue !== ''
|
|
68
|
+
? String(primaryValue)
|
|
69
|
+
: r.id;
|
|
70
|
+
return { label, value: r.id };
|
|
71
|
+
}),
|
|
72
|
+
};
|
|
73
|
+
}),
|
|
74
|
+
}),
|
|
75
|
+
fields: pieces_framework_1.Property.DynamicProperties({
|
|
76
|
+
auth: auth_1.TeableAuth,
|
|
77
|
+
displayName: 'Fields',
|
|
78
|
+
description: 'The fields to add to the record.',
|
|
79
|
+
required: true,
|
|
80
|
+
refreshers: ['auth', 'table_id'],
|
|
81
|
+
props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, table_id }) {
|
|
82
|
+
var _b, _c;
|
|
83
|
+
if (!auth || !table_id)
|
|
84
|
+
return {};
|
|
85
|
+
const client = makeClient(auth);
|
|
86
|
+
const fields = yield client.listFields(table_id);
|
|
87
|
+
const props = {};
|
|
88
|
+
for (const field of fields) {
|
|
89
|
+
// Skip computed / read-only fields
|
|
90
|
+
if (field.isComputed || constants_1.TeableComputedFieldTypes.includes(field.type)) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const choices = (_c = (_b = field.options) === null || _b === void 0 ? void 0 : _b.choices) !== null && _c !== void 0 ? _c : [];
|
|
94
|
+
switch (field.type) {
|
|
95
|
+
case constants_1.TeableFieldType.CHECKBOX:
|
|
96
|
+
props[field.name] = pieces_framework_1.Property.Checkbox({ displayName: field.name, required: false });
|
|
97
|
+
break;
|
|
98
|
+
case constants_1.TeableFieldType.NUMBER:
|
|
99
|
+
case constants_1.TeableFieldType.RATING:
|
|
100
|
+
props[field.name] = pieces_framework_1.Property.Number({ displayName: field.name, required: false });
|
|
101
|
+
break;
|
|
102
|
+
case constants_1.TeableFieldType.DATE:
|
|
103
|
+
props[field.name] = pieces_framework_1.Property.DateTime({ displayName: field.name, required: false });
|
|
104
|
+
break;
|
|
105
|
+
case constants_1.TeableFieldType.LONG_TEXT:
|
|
106
|
+
props[field.name] = pieces_framework_1.Property.LongText({ displayName: field.name, required: false });
|
|
107
|
+
break;
|
|
108
|
+
case constants_1.TeableFieldType.MULTIPLE_SELECT:
|
|
109
|
+
props[field.name] = pieces_framework_1.Property.StaticMultiSelectDropdown({
|
|
110
|
+
displayName: field.name,
|
|
111
|
+
required: false,
|
|
112
|
+
options: { options: choices.map((c) => ({ label: c.name, value: c.name })) },
|
|
113
|
+
});
|
|
114
|
+
break;
|
|
115
|
+
case constants_1.TeableFieldType.SINGLE_SELECT:
|
|
116
|
+
props[field.name] = pieces_framework_1.Property.StaticDropdown({
|
|
117
|
+
displayName: field.name,
|
|
118
|
+
required: false,
|
|
119
|
+
options: { options: choices.map((c) => ({ label: c.name, value: c.name })) },
|
|
120
|
+
});
|
|
121
|
+
break;
|
|
122
|
+
case constants_1.TeableFieldType.LINK:
|
|
123
|
+
case constants_1.TeableFieldType.USER:
|
|
124
|
+
props[field.name] = pieces_framework_1.Property.Array({ displayName: field.name, required: false });
|
|
125
|
+
break;
|
|
126
|
+
case constants_1.TeableFieldType.SINGLE_LINE_TEXT:
|
|
127
|
+
default:
|
|
128
|
+
props[field.name] = pieces_framework_1.Property.ShortText({ displayName: field.name, required: false });
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return props;
|
|
133
|
+
}),
|
|
134
|
+
}),
|
|
135
|
+
};
|
|
136
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/common/index.ts"],"names":[],"mappings":";;;AAKA,gCAKC;;AAVD,qEAA6E;AAC7E,kCAAwF;AACxF,qCAAwC;AACxC,2CAAwE;AAuI9C,yGAvIjB,oCAAwB,OAuIiB;AAAzC,gGAvI0B,2BAAe,OAuI1B;AArIxB,SAAgB,UAAU,CAAC,IAAqB;IAC/C,OAAO,IAAI,qBAAY,CACtB,IAAA,qBAAc,EAAC,IAAI,CAAC,EACpB,IAAA,uBAAgB,EAAC,IAAI,CAAC,CACtB,CAAC;AACH,CAAC;AAEY,QAAA,YAAY,GAAG;IAC3B,OAAO,EAAE,2BAAQ,CAAC,QAAQ,CAAC;QAC1B,IAAI,EAAE,iBAAU;QAChB,WAAW,EAAE,MAAM;QACnB,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,EAAE;QACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;YACvB,IAAI,CAAC,IAAI,EAAE,CAAC;gBACX,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,6BAA6B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