@activepieces/piece-bika 0.1.4 → 0.1.6
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 +7 -22
- package/src/index.js +14 -69
- package/README.md +0 -7
- package/src/index.d.ts +0 -6
- package/src/index.js.map +0 -1
- package/src/lib/actions/create-record.d.ts +0 -13
- package/src/lib/actions/create-record.js +0 -47
- package/src/lib/actions/create-record.js.map +0 -1
- package/src/lib/actions/delete-record.d.ts +0 -11
- package/src/lib/actions/delete-record.js +0 -36
- package/src/lib/actions/delete-record.js.map +0 -1
- package/src/lib/actions/find-record.d.ts +0 -11
- package/src/lib/actions/find-record.js +0 -35
- package/src/lib/actions/find-record.js.map +0 -1
- package/src/lib/actions/find-records.d.ts +0 -13
- package/src/lib/actions/find-records.js +0 -54
- package/src/lib/actions/find-records.js.map +0 -1
- package/src/lib/actions/update-record.d.ts +0 -14
- package/src/lib/actions/update-record.js +0 -49
- package/src/lib/actions/update-record.js.map +0 -1
- package/src/lib/common/client.d.ts +0 -62
- package/src/lib/common/client.js +0 -89
- package/src/lib/common/client.js.map +0 -1
- package/src/lib/common/constants.d.ts +0 -27
- package/src/lib/common/constants.js +0 -10
- package/src/lib/common/constants.js.map +0 -1
- package/src/lib/common/index.d.ts +0 -16
- package/src/lib/common/index.js +0 -233
- package/src/lib/common/index.js.map +0 -1
|
@@ -1,35 +0,0 @@
|
|
|
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 index_1 = require("../../index");
|
|
8
|
-
exports.findRecordAction = (0, pieces_framework_1.createAction)({
|
|
9
|
-
auth: index_1.BikaAuth,
|
|
10
|
-
name: 'bika_find_record',
|
|
11
|
-
displayName: 'Get Record',
|
|
12
|
-
description: 'Retrieves a record in database by ID.',
|
|
13
|
-
props: {
|
|
14
|
-
space_id: common_1.BikaCommon.space_id,
|
|
15
|
-
database_id: common_1.BikaCommon.database_id,
|
|
16
|
-
recordId: pieces_framework_1.Property.ShortText({
|
|
17
|
-
displayName: 'Record ID',
|
|
18
|
-
required: true,
|
|
19
|
-
}),
|
|
20
|
-
},
|
|
21
|
-
run(context) {
|
|
22
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const databaseId = context.propsValue.database_id;
|
|
24
|
-
const spaceId = context.propsValue.space_id;
|
|
25
|
-
const recordId = context.propsValue.recordId;
|
|
26
|
-
const client = (0, common_1.makeClient)(context.auth.props);
|
|
27
|
-
const response = yield client.findRecord(spaceId, databaseId, recordId);
|
|
28
|
-
if (!response.success) {
|
|
29
|
-
throw new Error(JSON.stringify(response, undefined, 2));
|
|
30
|
-
}
|
|
31
|
-
return response;
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
//# sourceMappingURL=find-record.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-record.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bika/src/lib/actions/find-record.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,sCAAmD;AACnD,uCAAuC;AAE1B,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,gBAAQ;IACd,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,uCAAuC;IACpD,KAAK,EAAE;QACL,QAAQ,EAAE,mBAAU,CAAC,QAAQ;QAC7B,WAAW,EAAE,mBAAU,CAAC,WAAW;QACjC,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,WAAW;YACxB,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC;YAClD,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC5C,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;YAE7C,MAAM,MAAM,GAAG,IAAA,mBAAU,EACvB,OAAO,CAAC,IAAI,CAAC,KAAK,CACnB,CAAC;YAEF,MAAM,QAAQ,GAAQ,MAAM,MAAM,CAAC,UAAU,CAC3C,OAAO,EACP,UAAU,EACV,QAAQ,CACT,CAAC;YAEF,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;YAC1D,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const findRecordsAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
-
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
3
|
-
}>, {
|
|
4
|
-
space_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
5
|
-
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
6
|
-
}>>;
|
|
7
|
-
database_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
8
|
-
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
9
|
-
}>>;
|
|
10
|
-
maxRecords: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
11
|
-
pageSize: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
12
|
-
filter: import("@activepieces/pieces-framework").LongTextProperty<false>;
|
|
13
|
-
}>;
|
|
@@ -1,54 +0,0 @@
|
|
|
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 index_1 = require("../../index");
|
|
8
|
-
const client_1 = require("../common/client");
|
|
9
|
-
exports.findRecordsAction = (0, pieces_framework_1.createAction)({
|
|
10
|
-
auth: index_1.BikaAuth,
|
|
11
|
-
name: 'bika_find_records',
|
|
12
|
-
displayName: 'Find Records',
|
|
13
|
-
description: 'Finds records in database.',
|
|
14
|
-
props: {
|
|
15
|
-
space_id: common_1.BikaCommon.space_id,
|
|
16
|
-
database_id: common_1.BikaCommon.database_id,
|
|
17
|
-
maxRecords: pieces_framework_1.Property.Number({
|
|
18
|
-
displayName: 'Max Records',
|
|
19
|
-
description: 'How many records are returned in total.',
|
|
20
|
-
required: false,
|
|
21
|
-
}),
|
|
22
|
-
pageSize: pieces_framework_1.Property.Number({
|
|
23
|
-
displayName: 'Page Size',
|
|
24
|
-
description: 'How many records are returned per page (max 1000).',
|
|
25
|
-
required: false,
|
|
26
|
-
}),
|
|
27
|
-
filter: pieces_framework_1.Property.LongText({
|
|
28
|
-
displayName: 'Filter',
|
|
29
|
-
description: 'The filter to apply to the records (see https://bika.ai/help/guide/developer/filter-query-language).',
|
|
30
|
-
required: false,
|
|
31
|
-
}),
|
|
32
|
-
},
|
|
33
|
-
run(context) {
|
|
34
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
var _a;
|
|
36
|
-
const databaseId = context.propsValue.database_id;
|
|
37
|
-
const spaceId = context.propsValue.space_id;
|
|
38
|
-
const maxRecords = context.propsValue.maxRecords;
|
|
39
|
-
const pageSize = (_a = context.propsValue.pageSize) !== null && _a !== void 0 ? _a : 100;
|
|
40
|
-
const filter = context.propsValue.filter;
|
|
41
|
-
const client = (0, common_1.makeClient)(context.auth.props);
|
|
42
|
-
const response = yield client.listRecords(spaceId, databaseId, (0, client_1.prepareQuery)({
|
|
43
|
-
pageSize,
|
|
44
|
-
maxRecords,
|
|
45
|
-
filter,
|
|
46
|
-
}));
|
|
47
|
-
if (!response.success) {
|
|
48
|
-
throw new Error(JSON.stringify(response, undefined, 2));
|
|
49
|
-
}
|
|
50
|
-
return response;
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
//# sourceMappingURL=find-records.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-records.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bika/src/lib/actions/find-records.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,sCAAmD;AACnD,uCAAuC;AACvC,6CAAgD;AAEnC,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,gBAAQ;IACd,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,4BAA4B;IACzC,KAAK,EAAE;QACL,QAAQ,EAAE,mBAAU,CAAC,QAAQ;QAC7B,WAAW,EAAE,mBAAU,CAAC,WAAW;QACnC,UAAU,EAAE,2BAAQ,CAAC,MAAM,CAAC;YAC1B,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,yCAAyC;YACtD,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACxB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,oDAAoD;YACjE,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACxB,WAAW,EAAE,QAAQ;YACrB,WAAW,EACT,sGAAsG;YACxG,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC;YAClD,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC5C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC;YACjD,MAAM,QAAQ,GAAG,MAAA,OAAO,CAAC,UAAU,CAAC,QAAQ,mCAAI,GAAG,CAAC;YACpD,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;YAEzC,MAAM,MAAM,GAAG,IAAA,mBAAU,EACvB,OAAO,CAAC,IAAI,CAAC,KAAK,CACnB,CAAC;YACF,MAAM,QAAQ,GAAQ,MAAM,MAAM,CAAC,WAAW,CAC5C,OAAO,EACP,UAAU,EACV,IAAA,qBAAY,EAAC;gBACX,QAAQ;gBACR,UAAU;gBACV,MAAM;aACP,CAAC,CACH,CAAC;YAEF,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;YAC1D,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare const updateRecordAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
-
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
3
|
-
}>, {
|
|
4
|
-
space_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
5
|
-
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
6
|
-
}>>;
|
|
7
|
-
database_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
8
|
-
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
9
|
-
}>>;
|
|
10
|
-
recordId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
11
|
-
fields: import("@activepieces/pieces-framework").DynamicProperties<true, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
12
|
-
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
13
|
-
}>>;
|
|
14
|
-
}>;
|
|
@@ -1,49 +0,0 @@
|
|
|
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 index_1 = require("../../index");
|
|
8
|
-
exports.updateRecordAction = (0, pieces_framework_1.createAction)({
|
|
9
|
-
auth: index_1.BikaAuth,
|
|
10
|
-
name: 'bika_update_record',
|
|
11
|
-
displayName: 'Update Record',
|
|
12
|
-
description: 'Updates an existing record in database.',
|
|
13
|
-
props: {
|
|
14
|
-
space_id: common_1.BikaCommon.space_id,
|
|
15
|
-
database_id: common_1.BikaCommon.database_id,
|
|
16
|
-
recordId: pieces_framework_1.Property.ShortText({
|
|
17
|
-
displayName: 'Record ID',
|
|
18
|
-
description: 'The ID of the record to update.',
|
|
19
|
-
required: true,
|
|
20
|
-
}),
|
|
21
|
-
fields: common_1.BikaCommon.fields,
|
|
22
|
-
},
|
|
23
|
-
run(context) {
|
|
24
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const auth = context.auth;
|
|
26
|
-
const databaseId = context.propsValue.database_id;
|
|
27
|
-
const spaceId = context.propsValue.space_id;
|
|
28
|
-
const recordId = context.propsValue.recordId;
|
|
29
|
-
const dynamicFields = context.propsValue.fields;
|
|
30
|
-
const fields = {};
|
|
31
|
-
const props = Object.entries(dynamicFields);
|
|
32
|
-
for (const [propertyKey, propertyValue] of props) {
|
|
33
|
-
if (propertyValue !== undefined && propertyValue !== '') {
|
|
34
|
-
fields[propertyKey] = propertyValue;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const newFields = yield (0, common_1.createNewFields)(auth, spaceId, databaseId, fields);
|
|
38
|
-
const client = (0, common_1.makeClient)(context.auth.props);
|
|
39
|
-
const response = yield client.updateRecord(spaceId, databaseId, recordId, {
|
|
40
|
-
fields: Object.assign({}, newFields),
|
|
41
|
-
});
|
|
42
|
-
if (!response.success) {
|
|
43
|
-
throw new Error(JSON.stringify(response, undefined, 2));
|
|
44
|
-
}
|
|
45
|
-
return response;
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
//# sourceMappingURL=update-record.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-record.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bika/src/lib/actions/update-record.ts"],"names":[],"mappings":";;;;AAAA,qEAKwC;AACxC,sCAAoE;AACpE,uCAAuC;AAE1B,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,gBAAQ;IACd,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,yCAAyC;IACtD,KAAK,EAAE;QACN,QAAQ,EAAE,mBAAU,CAAC,QAAQ;QAC7B,WAAW,EAAE,mBAAU,CAAC,WAAW;QACnC,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,iCAAiC;YAC9C,QAAQ,EAAE,IAAI;SACd,CAAC;QACF,MAAM,EAAE,mBAAU,CAAC,MAAM;KACzB;IACK,GAAG,CAAC,OAAO;;YAChB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YAC1B,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC;YAClD,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC5C,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC7C,MAAM,aAAa,GAAsB,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;YACnE,MAAM,MAAM,GAER,EAAE,CAAC;YAEP,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;YAC5C,KAAK,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,IAAI,KAAK,EAAE,CAAC;gBAClD,IAAI,aAAa,KAAK,SAAS,IAAI,aAAa,KAAK,EAAE,EAAE,CAAC;oBACzD,MAAM,CAAC,WAAW,CAAC,GAAG,aAAa,CAAC;gBACrC,CAAC;YACF,CAAC;YAED,MAAM,SAAS,GAA4B,MAAM,IAAA,wBAAe,EAC/D,IAAI,EACJ,OAAO,EACP,UAAU,EACV,MAAM,CACN,CAAC;YAEF,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAE9C,MAAM,QAAQ,GAAQ,MAAM,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE;gBAC5E,MAAM,oBACF,SAAS,CACZ;aACH,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;YACzD,CAAC;YAED,OAAO,QAAQ,CAAC;QACjB,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { HttpMessageBody, HttpMethod, QueryParams } from '@activepieces/pieces-common';
|
|
2
|
-
import { BikaFieldType } from './constants';
|
|
3
|
-
export declare function prepareQuery(request?: Record<string, any>): QueryParams;
|
|
4
|
-
export declare class BikaClient {
|
|
5
|
-
private token;
|
|
6
|
-
private bikaUrl;
|
|
7
|
-
constructor(token: string, bikaUrl?: string);
|
|
8
|
-
makeRequest<T extends HttpMessageBody>(method: HttpMethod, resourceUri: string, query?: QueryParams, body?: any | undefined): Promise<T>;
|
|
9
|
-
listSpaces(): Promise<{
|
|
10
|
-
data: {
|
|
11
|
-
id: string;
|
|
12
|
-
name: string;
|
|
13
|
-
}[];
|
|
14
|
-
}>;
|
|
15
|
-
listDatabases(space_id: string): Promise<{
|
|
16
|
-
data: {
|
|
17
|
-
id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
}[];
|
|
20
|
-
}>;
|
|
21
|
-
getDatabaseFields(space_id: string, database_id: string): Promise<{
|
|
22
|
-
data: {
|
|
23
|
-
id: string;
|
|
24
|
-
name: string;
|
|
25
|
-
type: BikaFieldType;
|
|
26
|
-
desc: string;
|
|
27
|
-
property?: {
|
|
28
|
-
format?: string;
|
|
29
|
-
defaultValue?: string;
|
|
30
|
-
options?: {
|
|
31
|
-
name: string;
|
|
32
|
-
id?: string;
|
|
33
|
-
}[];
|
|
34
|
-
};
|
|
35
|
-
}[];
|
|
36
|
-
}>;
|
|
37
|
-
createRecord(space_id: string, database_id: string, request: object): Promise<unknown>;
|
|
38
|
-
deleteRecord(space_id: string, database_id: string, record_id: string): Promise<unknown>;
|
|
39
|
-
updateRecord(space_id: string, database_id: string, record_id: string, request: object): Promise<unknown>;
|
|
40
|
-
findRecord(space_id: string, database_id: string, record_id: string, query?: QueryParams): Promise<{
|
|
41
|
-
data: {
|
|
42
|
-
total: number;
|
|
43
|
-
records: {
|
|
44
|
-
recordId: string;
|
|
45
|
-
createdAt: number;
|
|
46
|
-
updatedAt: number;
|
|
47
|
-
fields: Record<string, unknown>;
|
|
48
|
-
}[];
|
|
49
|
-
};
|
|
50
|
-
}>;
|
|
51
|
-
listRecords(space_id: string, database_id: string, query?: QueryParams): Promise<{
|
|
52
|
-
data: {
|
|
53
|
-
total: number;
|
|
54
|
-
records: {
|
|
55
|
-
recordId: string;
|
|
56
|
-
createdAt: number;
|
|
57
|
-
updatedAt: number;
|
|
58
|
-
fields: Record<string, unknown>;
|
|
59
|
-
}[];
|
|
60
|
-
};
|
|
61
|
-
}>;
|
|
62
|
-
}
|
package/src/lib/common/client.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BikaClient = void 0;
|
|
4
|
-
exports.prepareQuery = prepareQuery;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
-
function emptyValueFilter(accessor) {
|
|
8
|
-
return (key) => {
|
|
9
|
-
const val = accessor(key);
|
|
10
|
-
return (val !== null &&
|
|
11
|
-
val !== undefined &&
|
|
12
|
-
(typeof val != 'string' || val.length > 0));
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function prepareQuery(request) {
|
|
16
|
-
const params = {};
|
|
17
|
-
if (!request)
|
|
18
|
-
return params;
|
|
19
|
-
Object.keys(request)
|
|
20
|
-
.filter(emptyValueFilter((k) => request[k]))
|
|
21
|
-
.forEach((k) => {
|
|
22
|
-
params[k] = request[k].toString();
|
|
23
|
-
});
|
|
24
|
-
return params;
|
|
25
|
-
}
|
|
26
|
-
class BikaClient {
|
|
27
|
-
constructor(token, bikaUrl = "https://bika.ai") {
|
|
28
|
-
this.token = token;
|
|
29
|
-
this.bikaUrl = bikaUrl;
|
|
30
|
-
}
|
|
31
|
-
makeRequest(method_1, resourceUri_1, query_1) {
|
|
32
|
-
return tslib_1.__awaiter(this, arguments, void 0, function* (method, resourceUri, query, body = undefined) {
|
|
33
|
-
const baseUrl = this.bikaUrl.replace(/\/$/, '');
|
|
34
|
-
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
35
|
-
method: method,
|
|
36
|
-
url: `${baseUrl}/api/openapi/bika` + resourceUri,
|
|
37
|
-
authentication: {
|
|
38
|
-
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
39
|
-
token: this.token,
|
|
40
|
-
},
|
|
41
|
-
queryParams: query,
|
|
42
|
-
body: body,
|
|
43
|
-
});
|
|
44
|
-
return res.body;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
listSpaces() {
|
|
48
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
return yield this.makeRequest(pieces_common_1.HttpMethod.GET, '/v1/spaces');
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
listDatabases(space_id) {
|
|
53
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
return yield this.makeRequest(pieces_common_1.HttpMethod.GET, `/v1/spaces/${space_id}/nodes`);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
getDatabaseFields(space_id, database_id) {
|
|
58
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
return yield this.makeRequest(pieces_common_1.HttpMethod.GET, `/v1/spaces/${space_id}/resources/databases/${database_id}/fields`);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
createRecord(space_id, database_id, request) {
|
|
63
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
return yield this.makeRequest(pieces_common_1.HttpMethod.POST, `/v2/spaces/${space_id}/resources/databases/${database_id}/records`, undefined, request);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
deleteRecord(space_id, database_id, record_id) {
|
|
68
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
return yield this.makeRequest(pieces_common_1.HttpMethod.DELETE, `/v2/spaces/${space_id}/resources/databases/${database_id}/records/${record_id}`);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
updateRecord(space_id, database_id, record_id, request) {
|
|
73
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
return yield this.makeRequest(pieces_common_1.HttpMethod.PUT, `/v2/spaces/${space_id}/resources/databases/${database_id}/records/${record_id}`, undefined, request);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
findRecord(space_id, database_id, record_id, query) {
|
|
78
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
return yield this.makeRequest(pieces_common_1.HttpMethod.GET, `/v2/spaces/${space_id}/resources/databases/${database_id}/records/${record_id}`, query);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
listRecords(space_id, database_id, query) {
|
|
83
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
return yield this.makeRequest(pieces_common_1.HttpMethod.GET, `/v2/spaces/${space_id}/resources/databases/${database_id}/records`, query);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.BikaClient = BikaClient;
|
|
89
|
-
//# sourceMappingURL=client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bika/src/lib/common/client.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export declare const enum BikaFieldType {
|
|
2
|
-
SINGLE_TEXT = "SINGLE_TEXT",
|
|
3
|
-
LINK = "LINK",
|
|
4
|
-
LOOKUP = "LOOKUP",
|
|
5
|
-
SINGLE_SELECT = "SINGLE_SELECT",
|
|
6
|
-
MEMBER = "MEMBER",
|
|
7
|
-
DATETIME = "DATETIME",
|
|
8
|
-
NUMBER = "NUMBER",
|
|
9
|
-
FORMULA = "FORMULA",
|
|
10
|
-
LONG_TEXT = "LONG_TEXT",
|
|
11
|
-
MULTI_SELECT = "MULTI_SELECT",
|
|
12
|
-
CURRENCY = "CURRENCY",
|
|
13
|
-
PERCENT = "PERCENT",
|
|
14
|
-
RATING = "RATING",
|
|
15
|
-
CHECKBOX = "CHECKBOX",
|
|
16
|
-
URL = "URL",
|
|
17
|
-
PHONE = "PHONE",
|
|
18
|
-
EMAIL = "EMAIL",
|
|
19
|
-
AUTONUMBER = "AUTONUMBER",
|
|
20
|
-
CREATED_BY = "CREATED_BY",
|
|
21
|
-
LAST_MODIFIED_BY = "LAST_MODIFIED_BY",
|
|
22
|
-
CASCADER = "CASCADER",
|
|
23
|
-
CREATED_TIME = "CREATED_TIME",
|
|
24
|
-
LAST_MODIFIED_TIME = "LAST_MODIFIED_TIME",
|
|
25
|
-
ATTACHMENT = "ATTACHMENT"
|
|
26
|
-
}
|
|
27
|
-
export declare const BikaNumericFieldTypes: BikaFieldType[];
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BikaNumericFieldTypes = void 0;
|
|
4
|
-
exports.BikaNumericFieldTypes = [
|
|
5
|
-
"NUMBER" /* BikaFieldType.NUMBER */,
|
|
6
|
-
"RATING" /* BikaFieldType.RATING */,
|
|
7
|
-
"CURRENCY" /* BikaFieldType.CURRENCY */,
|
|
8
|
-
"PERCENT" /* BikaFieldType.PERCENT */,
|
|
9
|
-
];
|
|
10
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bika/src/lib/common/constants.ts"],"names":[],"mappings":";;;AA2Ba,QAAA,qBAAqB,GAAG;;;;;CAKpC,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AppConnectionValueForAuthProperty, PiecePropValueSchema } from '@activepieces/pieces-framework';
|
|
2
|
-
import { BikaAuth } from '../..';
|
|
3
|
-
import { BikaClient } from './client';
|
|
4
|
-
export declare function makeClient(auth: PiecePropValueSchema<typeof BikaAuth>): BikaClient;
|
|
5
|
-
export declare const BikaCommon: {
|
|
6
|
-
space_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
7
|
-
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
8
|
-
}>>;
|
|
9
|
-
database_id: import("@activepieces/pieces-framework").DropdownProperty<string, true, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
10
|
-
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
11
|
-
}>>;
|
|
12
|
-
fields: import("@activepieces/pieces-framework").DynamicProperties<true, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
13
|
-
token: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
14
|
-
}>>;
|
|
15
|
-
};
|
|
16
|
-
export declare function createNewFields(auth: AppConnectionValueForAuthProperty<typeof BikaAuth>, space_id: string, database_id: string, fields: Record<string, unknown>): Promise<Record<string, unknown>>;
|
package/src/lib/common/index.js
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BikaCommon = void 0;
|
|
4
|
-
exports.makeClient = makeClient;
|
|
5
|
-
exports.createNewFields = createNewFields;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
8
|
-
const __1 = require("../..");
|
|
9
|
-
const client_1 = require("./client");
|
|
10
|
-
const constants_1 = require("./constants");
|
|
11
|
-
function makeClient(auth) {
|
|
12
|
-
const client = new client_1.BikaClient(auth.token);
|
|
13
|
-
return client;
|
|
14
|
-
}
|
|
15
|
-
exports.BikaCommon = {
|
|
16
|
-
space_id: pieces_framework_1.Property.Dropdown({
|
|
17
|
-
auth: __1.BikaAuth,
|
|
18
|
-
displayName: 'Space',
|
|
19
|
-
required: true,
|
|
20
|
-
refreshers: [],
|
|
21
|
-
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
22
|
-
if (!auth) {
|
|
23
|
-
return {
|
|
24
|
-
disabled: true,
|
|
25
|
-
options: [],
|
|
26
|
-
placeholder: 'Connect your account first.',
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
const client = makeClient(auth.props);
|
|
30
|
-
const res = yield client.listSpaces();
|
|
31
|
-
return {
|
|
32
|
-
disabled: false,
|
|
33
|
-
options: res.data.map((space) => {
|
|
34
|
-
return {
|
|
35
|
-
label: space.name,
|
|
36
|
-
value: space.id,
|
|
37
|
-
};
|
|
38
|
-
}),
|
|
39
|
-
};
|
|
40
|
-
}),
|
|
41
|
-
}),
|
|
42
|
-
database_id: pieces_framework_1.Property.Dropdown({
|
|
43
|
-
auth: __1.BikaAuth,
|
|
44
|
-
displayName: 'Database',
|
|
45
|
-
required: true,
|
|
46
|
-
refreshers: ['space_id'],
|
|
47
|
-
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, space_id }) {
|
|
48
|
-
if (!auth || !space_id) {
|
|
49
|
-
return {
|
|
50
|
-
disabled: true,
|
|
51
|
-
options: [],
|
|
52
|
-
placeholder: 'Connect your account first and select space.',
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
const client = makeClient(auth.props);
|
|
56
|
-
const res = yield client.listDatabases(space_id);
|
|
57
|
-
return {
|
|
58
|
-
disabled: false,
|
|
59
|
-
options: res.data.map((database) => {
|
|
60
|
-
return {
|
|
61
|
-
label: database.name,
|
|
62
|
-
value: database.id,
|
|
63
|
-
};
|
|
64
|
-
}),
|
|
65
|
-
};
|
|
66
|
-
}),
|
|
67
|
-
}),
|
|
68
|
-
fields: pieces_framework_1.Property.DynamicProperties({
|
|
69
|
-
auth: __1.BikaAuth,
|
|
70
|
-
displayName: 'Fields',
|
|
71
|
-
description: 'The fields to add to the record.',
|
|
72
|
-
required: true,
|
|
73
|
-
refreshers: ['auth', 'space_id', 'database_id'],
|
|
74
|
-
props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, space_id, database_id }) {
|
|
75
|
-
var _b, _c, _d, _e, _f, _g;
|
|
76
|
-
if (!auth || !space_id || !database_id)
|
|
77
|
-
return {};
|
|
78
|
-
const client = makeClient(auth.props);
|
|
79
|
-
const res = yield client.getDatabaseFields(space_id, database_id);
|
|
80
|
-
const props = {};
|
|
81
|
-
for (const field of res.data) {
|
|
82
|
-
if (![
|
|
83
|
-
"AUTONUMBER" /* BikaFieldType.AUTONUMBER */,
|
|
84
|
-
"CASCADER" /* BikaFieldType.CASCADER */,
|
|
85
|
-
"CREATED_BY" /* BikaFieldType.CREATED_BY */,
|
|
86
|
-
"CREATED_TIME" /* BikaFieldType.CREATED_TIME */,
|
|
87
|
-
"FORMULA" /* BikaFieldType.FORMULA */,
|
|
88
|
-
"LAST_MODIFIED_BY" /* BikaFieldType.LAST_MODIFIED_BY */,
|
|
89
|
-
"LAST_MODIFIED_TIME" /* BikaFieldType.LAST_MODIFIED_TIME */,
|
|
90
|
-
"LOOKUP" /* BikaFieldType.LOOKUP */,
|
|
91
|
-
].includes(field.type)) {
|
|
92
|
-
switch (field.type) {
|
|
93
|
-
case "ATTACHMENT" /* BikaFieldType.ATTACHMENT */:
|
|
94
|
-
props[field.name] = pieces_framework_1.Property.File({
|
|
95
|
-
displayName: field.name,
|
|
96
|
-
required: false,
|
|
97
|
-
});
|
|
98
|
-
break;
|
|
99
|
-
case "CHECKBOX" /* BikaFieldType.CHECKBOX */:
|
|
100
|
-
props[field.name] = pieces_framework_1.Property.Checkbox({
|
|
101
|
-
displayName: field.name,
|
|
102
|
-
required: false,
|
|
103
|
-
});
|
|
104
|
-
break;
|
|
105
|
-
case "CURRENCY" /* BikaFieldType.CURRENCY */:
|
|
106
|
-
case "NUMBER" /* BikaFieldType.NUMBER */:
|
|
107
|
-
case "PERCENT" /* BikaFieldType.PERCENT */:
|
|
108
|
-
case "RATING" /* BikaFieldType.RATING */:
|
|
109
|
-
props[field.name] = pieces_framework_1.Property.Number({
|
|
110
|
-
displayName: field.name,
|
|
111
|
-
required: false,
|
|
112
|
-
});
|
|
113
|
-
break;
|
|
114
|
-
case "DATETIME" /* BikaFieldType.DATETIME */:
|
|
115
|
-
props[field.name] = pieces_framework_1.Property.DateTime({
|
|
116
|
-
displayName: field.name,
|
|
117
|
-
required: false,
|
|
118
|
-
});
|
|
119
|
-
break;
|
|
120
|
-
case "EMAIL" /* BikaFieldType.EMAIL */:
|
|
121
|
-
case "PHONE" /* BikaFieldType.PHONE */:
|
|
122
|
-
case "SINGLE_TEXT" /* BikaFieldType.SINGLE_TEXT */:
|
|
123
|
-
case "URL" /* BikaFieldType.URL */:
|
|
124
|
-
props[field.name] = pieces_framework_1.Property.ShortText({
|
|
125
|
-
displayName: field.name,
|
|
126
|
-
required: false,
|
|
127
|
-
});
|
|
128
|
-
break;
|
|
129
|
-
case "LONG_TEXT" /* BikaFieldType.LONG_TEXT */:
|
|
130
|
-
props[field.name] = pieces_framework_1.Property.LongText({
|
|
131
|
-
displayName: field.name,
|
|
132
|
-
required: false,
|
|
133
|
-
});
|
|
134
|
-
break;
|
|
135
|
-
case "MULTI_SELECT" /* BikaFieldType.MULTI_SELECT */:
|
|
136
|
-
props[field.name] = pieces_framework_1.Property.StaticMultiSelectDropdown({
|
|
137
|
-
displayName: field.name,
|
|
138
|
-
required: false,
|
|
139
|
-
options: {
|
|
140
|
-
options: ((_c = (_b = field.property) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.map((option) => ({
|
|
141
|
-
label: option.name,
|
|
142
|
-
value: option.name,
|
|
143
|
-
}))) || [],
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
break;
|
|
147
|
-
case "SINGLE_SELECT" /* BikaFieldType.SINGLE_SELECT */:
|
|
148
|
-
props[field.name] = pieces_framework_1.Property.StaticDropdown({
|
|
149
|
-
displayName: field.name,
|
|
150
|
-
required: false,
|
|
151
|
-
options: {
|
|
152
|
-
options: ((_e = (_d = field.property) === null || _d === void 0 ? void 0 : _d.options) === null || _e === void 0 ? void 0 : _e.map((option) => ({
|
|
153
|
-
label: option.name,
|
|
154
|
-
value: option.name,
|
|
155
|
-
}))) || [],
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
break;
|
|
159
|
-
case "MEMBER" /* BikaFieldType.MEMBER */:
|
|
160
|
-
props[field.name] = pieces_framework_1.Property.StaticMultiSelectDropdown({
|
|
161
|
-
displayName: field.name,
|
|
162
|
-
required: false,
|
|
163
|
-
options: {
|
|
164
|
-
options: ((_g = (_f = field.property) === null || _f === void 0 ? void 0 : _f.options) === null || _g === void 0 ? void 0 : _g.map((option) => {
|
|
165
|
-
return {
|
|
166
|
-
label: option.name,
|
|
167
|
-
value: option.id,
|
|
168
|
-
};
|
|
169
|
-
})) || [],
|
|
170
|
-
},
|
|
171
|
-
});
|
|
172
|
-
break;
|
|
173
|
-
case "LINK" /* BikaFieldType.LINK */:
|
|
174
|
-
props[field.name] = pieces_framework_1.Property.Array({
|
|
175
|
-
displayName: field.name,
|
|
176
|
-
required: false,
|
|
177
|
-
});
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return props;
|
|
183
|
-
}),
|
|
184
|
-
}),
|
|
185
|
-
};
|
|
186
|
-
function createNewFields(auth, space_id, database_id, fields) {
|
|
187
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
188
|
-
var _a, _b;
|
|
189
|
-
if (!auth)
|
|
190
|
-
return fields;
|
|
191
|
-
if (!database_id)
|
|
192
|
-
return fields;
|
|
193
|
-
const newFields = {};
|
|
194
|
-
const client = makeClient(auth.props);
|
|
195
|
-
const res = yield client.getDatabaseFields(space_id, database_id);
|
|
196
|
-
for (const field of res.data) {
|
|
197
|
-
if ([
|
|
198
|
-
"AUTONUMBER" /* BikaFieldType.AUTONUMBER */,
|
|
199
|
-
"CASCADER" /* BikaFieldType.CASCADER */,
|
|
200
|
-
"CREATED_BY" /* BikaFieldType.CREATED_BY */,
|
|
201
|
-
"CREATED_TIME" /* BikaFieldType.CREATED_TIME */,
|
|
202
|
-
"FORMULA" /* BikaFieldType.FORMULA */,
|
|
203
|
-
"LAST_MODIFIED_TIME" /* BikaFieldType.LAST_MODIFIED_TIME */,
|
|
204
|
-
"LAST_MODIFIED_BY" /* BikaFieldType.LAST_MODIFIED_BY */,
|
|
205
|
-
"LOOKUP" /* BikaFieldType.LOOKUP */,
|
|
206
|
-
].includes(field.type) || !(field.name in fields)) {
|
|
207
|
-
continue; // Skip irrelevant or missing fields
|
|
208
|
-
}
|
|
209
|
-
const key = field.name;
|
|
210
|
-
// Handle numeric fields
|
|
211
|
-
if (constants_1.BikaNumericFieldTypes.includes(field.type)) {
|
|
212
|
-
newFields[key] = Number(fields[key]);
|
|
213
|
-
}
|
|
214
|
-
// Handle member fields
|
|
215
|
-
else if (field.type === "MEMBER" /* BikaFieldType.MEMBER */) {
|
|
216
|
-
newFields[key] = (_b = (_a = field.property) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.filter((member) => member.id === `${fields[key]}`);
|
|
217
|
-
}
|
|
218
|
-
// Handle multi-select and two-way-link fields
|
|
219
|
-
else if (["MULTI_SELECT" /* BikaFieldType.MULTI_SELECT */].includes(field.type)) {
|
|
220
|
-
if (!Array.isArray(fields[key]) || fields[key].length === 0) {
|
|
221
|
-
continue; // Skip empty fields
|
|
222
|
-
}
|
|
223
|
-
newFields[key] = fields[key];
|
|
224
|
-
}
|
|
225
|
-
// Handle all other fields
|
|
226
|
-
else {
|
|
227
|
-
newFields[key] = fields[key];
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return newFields;
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
//# sourceMappingURL=index.js.map
|