@agnocon/piece-bika 0.1.7

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.
Files changed (52) hide show
  1. package/LICENSE.MIT-AP +24 -0
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +44 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/actions/create-record.d.ts +14 -0
  7. package/dist/lib/actions/create-record.d.ts.map +1 -0
  8. package/dist/lib/actions/create-record.js +51 -0
  9. package/dist/lib/actions/create-record.js.map +1 -0
  10. package/dist/lib/actions/delete-record.d.ts +12 -0
  11. package/dist/lib/actions/delete-record.d.ts.map +1 -0
  12. package/dist/lib/actions/delete-record.js +40 -0
  13. package/dist/lib/actions/delete-record.js.map +1 -0
  14. package/dist/lib/actions/find-record.d.ts +12 -0
  15. package/dist/lib/actions/find-record.d.ts.map +1 -0
  16. package/dist/lib/actions/find-record.js +39 -0
  17. package/dist/lib/actions/find-record.js.map +1 -0
  18. package/dist/lib/actions/find-records.d.ts +14 -0
  19. package/dist/lib/actions/find-records.d.ts.map +1 -0
  20. package/dist/lib/actions/find-records.js +58 -0
  21. package/dist/lib/actions/find-records.js.map +1 -0
  22. package/dist/lib/actions/update-record.d.ts +15 -0
  23. package/dist/lib/actions/update-record.d.ts.map +1 -0
  24. package/dist/lib/actions/update-record.js +53 -0
  25. package/dist/lib/actions/update-record.js.map +1 -0
  26. package/dist/lib/auth.d.ts +4 -0
  27. package/dist/lib/auth.d.ts.map +1 -0
  28. package/dist/lib/auth.js +45 -0
  29. package/dist/lib/auth.js.map +1 -0
  30. package/dist/lib/common/client.d.ts +63 -0
  31. package/dist/lib/common/client.d.ts.map +1 -0
  32. package/dist/lib/common/client.js +91 -0
  33. package/dist/lib/common/client.js.map +1 -0
  34. package/dist/lib/common/constants.d.ts +28 -0
  35. package/dist/lib/common/constants.d.ts.map +1 -0
  36. package/dist/lib/common/constants.js +10 -0
  37. package/dist/lib/common/constants.js.map +1 -0
  38. package/dist/lib/common/index.d.ts +17 -0
  39. package/dist/lib/common/index.d.ts.map +1 -0
  40. package/dist/lib/common/index.js +235 -0
  41. package/dist/lib/common/index.js.map +1 -0
  42. package/package.json +46 -0
  43. package/src/index.ts +41 -0
  44. package/src/lib/actions/create-record.ts +61 -0
  45. package/src/lib/actions/delete-record.ts +44 -0
  46. package/src/lib/actions/find-record.ts +44 -0
  47. package/src/lib/actions/find-records.ts +62 -0
  48. package/src/lib/actions/update-record.ts +65 -0
  49. package/src/lib/auth.ts +40 -0
  50. package/src/lib/common/client.ts +147 -0
  51. package/src/lib/common/constants.ts +33 -0
  52. package/src/lib/common/index.ts +250 -0
@@ -0,0 +1,91 @@
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
+ // Vendored from Activepieces packages/pieces/community/bika/src/lib/common/client.ts (MIT).
7
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
8
+ const pieces_common_1 = require("@agnocon/pieces-common");
9
+ function emptyValueFilter(accessor) {
10
+ return (key) => {
11
+ const val = accessor(key);
12
+ return (val !== null &&
13
+ val !== undefined &&
14
+ (typeof val != 'string' || 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
+ params[k] = request[k].toString();
25
+ });
26
+ return params;
27
+ }
28
+ class BikaClient {
29
+ constructor(token, bikaUrl = "https://bika.ai") {
30
+ this.token = token;
31
+ this.bikaUrl = bikaUrl;
32
+ }
33
+ makeRequest(method_1, resourceUri_1, query_1) {
34
+ return tslib_1.__awaiter(this, arguments, void 0, function* (method, resourceUri, query, body = undefined) {
35
+ const baseUrl = this.bikaUrl.replace(/\/$/, '');
36
+ const res = yield pieces_common_1.httpClient.sendRequest({
37
+ method: method,
38
+ url: `${baseUrl}/api/openapi/bika` + 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
+ listSpaces() {
50
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
51
+ return yield this.makeRequest(pieces_common_1.HttpMethod.GET, '/v1/spaces');
52
+ });
53
+ }
54
+ listDatabases(space_id) {
55
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
56
+ return yield this.makeRequest(pieces_common_1.HttpMethod.GET, `/v1/spaces/${space_id}/nodes`);
57
+ });
58
+ }
59
+ getDatabaseFields(space_id, database_id) {
60
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
61
+ return yield this.makeRequest(pieces_common_1.HttpMethod.GET, `/v1/spaces/${space_id}/resources/databases/${database_id}/fields`);
62
+ });
63
+ }
64
+ createRecord(space_id, database_id, request) {
65
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
66
+ return yield this.makeRequest(pieces_common_1.HttpMethod.POST, `/v2/spaces/${space_id}/resources/databases/${database_id}/records`, undefined, request);
67
+ });
68
+ }
69
+ deleteRecord(space_id, database_id, record_id) {
70
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
71
+ return yield this.makeRequest(pieces_common_1.HttpMethod.DELETE, `/v2/spaces/${space_id}/resources/databases/${database_id}/records/${record_id}`);
72
+ });
73
+ }
74
+ updateRecord(space_id, database_id, record_id, request) {
75
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
76
+ return yield this.makeRequest(pieces_common_1.HttpMethod.PUT, `/v2/spaces/${space_id}/resources/databases/${database_id}/records/${record_id}`, undefined, request);
77
+ });
78
+ }
79
+ findRecord(space_id, database_id, record_id, query) {
80
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
81
+ return yield this.makeRequest(pieces_common_1.HttpMethod.GET, `/v2/spaces/${space_id}/resources/databases/${database_id}/records/${record_id}`, query);
82
+ });
83
+ }
84
+ listRecords(space_id, database_id, query) {
85
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
86
+ return yield this.makeRequest(pieces_common_1.HttpMethod.GET, `/v2/spaces/${space_id}/resources/databases/${database_id}/records`, query);
87
+ });
88
+ }
89
+ }
90
+ exports.BikaClient = BikaClient;
91
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/lib/common/client.ts"],"names":[],"mappings":";;;AAwBA,oCASC;;AAjCD,4FAA4F;AAC5F,qEAAqE;AACrE,0DAMgC;AAGhC,SAAS,gBAAgB,CACvB,QAA8B;IAE9B,OAAO,CAAC,GAAW,EAAE,EAAE;QACrB,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,CACL,GAAG,KAAK,IAAI;YACZ,GAAG,KAAK,SAAS;YACjB,CAAC,OAAO,GAAG,IAAI,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAC3C,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,YAAY,CAAC,OAA6B;IACxD,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,IAAI,CAAC,OAAO;QAAE,OAAO,MAAM,CAAC;IAC5B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;SACjB,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3C,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE;QACrB,MAAM,CAAC,CAAC,CAAC,GAAI,OAA+B,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC7D,CAAC,CAAC,CAAC;IACL,OAAO,MAAM,CAAC;AAChB,CAAC;AAGD,MAAa,UAAU;IACrB,YAAqB,KAAa,EAAU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;QACJ,CAAC;KAAA;IACO,YAAY,CAAC,QAAgB,EAAE,WAAmB,EAAE,SAAiB;;YAC3E,OAAO,MAAM,IAAI,CAAC,WAAW,CAC3B,0BAAU,CAAC,MAAM,EACjB,cAAc,QAAQ,wBAAwB,WAAW,YAAY,SAAS,EAAE,CACjF,CAAC;QACJ,CAAC;KAAA;IACK,YAAY,CAAC,QAAgB,EAAE,WAAmB,EAAE,SAAiB,EAAE,OAAe;;YAC1F,OAAO,MAAM,IAAI,CAAC,WAAW,CAC3B,0BAAU,CAAC,GAAG,EACd,cAAc,QAAQ,wBAAwB,WAAW,YAAY,SAAS,EAAE,EAChF,SAAS,EACT,OAAO,CACR,CAAC;QACJ,CAAC;KAAA;IAEO,UAAU,CAAC,QAAgB,EAAE,WAAmB,EAAE,SAAiB,EAAE,KAAmB;;YAC9F,OAAO,MAAM,IAAI,CAAC,WAAW,CAU1B,0BAAU,CAAC,GAAG,EAAE,cAAc,QAAQ,wBAAwB,WAAW,YAAY,SAAS,EAAE,EAAE,KAAK,CAAC,CAAC;QAC9G,CAAC;KAAA;IAGK,WAAW,CAAC,QAAgB,EAAE,WAAmB,EAAE,KAAmB;;YAC1E,OAAO,MAAM,IAAI,CAAC,WAAW,CAU1B,0BAAU,CAAC,GAAG,EAAE,cAAc,QAAQ,wBAAwB,WAAW,UAAU,EAAE,KAAK,CAAC,CAAC;QACjG,CAAC;KAAA;CACF;AAhHD,gCAgHC"}
@@ -0,0 +1,28 @@
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[];
28
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/common/constants.ts"],"names":[],"mappings":"AAEA,0BAAkB,aAAa;IAC9B,WAAW,gBAAgB;IAC3B,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,aAAa,kBAAkB;IAC/B,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,KAAK,UAAU;IACf,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,gBAAgB,qBAAqB;IACrC,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,kBAAkB,uBAAuB;IACzC,UAAU,eAAe;CACzB;AAED,eAAO,MAAM,qBAAqB,iBAKjC,CAAC"}
@@ -0,0 +1,10 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/common/constants.ts"],"names":[],"mappings":";;;AA6Ba,QAAA,qBAAqB,GAAG;;;;;CAKpC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { AppConnectionValueForAuthProperty, PiecePropValueSchema } from '@agnocon/pieces-framework';
2
+ import { BikaAuth } from '../auth';
3
+ import { BikaClient } from './client';
4
+ export declare function makeClient(auth: PiecePropValueSchema<typeof BikaAuth>): BikaClient;
5
+ export declare const BikaCommon: {
6
+ space_id: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").CustomAuthProperty<{
7
+ token: import("@agnocon/pieces-framework").SecretTextProperty<true>;
8
+ }>>;
9
+ database_id: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").CustomAuthProperty<{
10
+ token: import("@agnocon/pieces-framework").SecretTextProperty<true>;
11
+ }>>;
12
+ fields: import("@agnocon/pieces-framework").DynamicProperties<true, import("@agnocon/pieces-framework").CustomAuthProperty<{
13
+ token: import("@agnocon/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>>;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/common/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iCAAiC,EAAqB,oBAAoB,EAAY,MAAM,2BAA2B,CAAC;AACjI,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,wBAAgB,UAAU,CAAC,IAAI,EAAE,oBAAoB,CAAC,OAAO,QAAQ,CAAC,cAGrE;AAED,eAAO,MAAM,UAAU;;;;;;;;;;CA+KtB,CAAC;AAEF,wBAAsB,eAAe,CACpC,IAAI,EAAE,iCAAiC,CAAC,OAAO,QAAQ,CAAC,EACxD,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,oCA0D/B"}
@@ -0,0 +1,235 @@
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
+ // Vendored from Activepieces packages/pieces/community/bika/src/lib/common/index.ts (MIT).
8
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
9
+ const pieces_framework_1 = require("@agnocon/pieces-framework");
10
+ const auth_1 = require("../auth");
11
+ const client_1 = require("./client");
12
+ const constants_1 = require("./constants");
13
+ function makeClient(auth) {
14
+ const client = new client_1.BikaClient(auth.token);
15
+ return client;
16
+ }
17
+ exports.BikaCommon = {
18
+ space_id: pieces_framework_1.Property.Dropdown({
19
+ auth: auth_1.BikaAuth,
20
+ displayName: 'Space',
21
+ required: true,
22
+ refreshers: [],
23
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
24
+ if (!auth) {
25
+ return {
26
+ disabled: true,
27
+ options: [],
28
+ placeholder: 'Connect your account first.',
29
+ };
30
+ }
31
+ const client = makeClient(auth.props);
32
+ const res = yield client.listSpaces();
33
+ return {
34
+ disabled: false,
35
+ options: res.data.map((space) => {
36
+ return {
37
+ label: space.name,
38
+ value: space.id,
39
+ };
40
+ }),
41
+ };
42
+ }),
43
+ }),
44
+ database_id: pieces_framework_1.Property.Dropdown({
45
+ auth: auth_1.BikaAuth,
46
+ displayName: 'Database',
47
+ required: true,
48
+ refreshers: ['space_id'],
49
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, space_id }) {
50
+ if (!auth || !space_id) {
51
+ return {
52
+ disabled: true,
53
+ options: [],
54
+ placeholder: 'Connect your account first and select space.',
55
+ };
56
+ }
57
+ const client = makeClient(auth.props);
58
+ const res = yield client.listDatabases(space_id);
59
+ return {
60
+ disabled: false,
61
+ options: res.data.map((database) => {
62
+ return {
63
+ label: database.name,
64
+ value: database.id,
65
+ };
66
+ }),
67
+ };
68
+ }),
69
+ }),
70
+ fields: pieces_framework_1.Property.DynamicProperties({
71
+ auth: auth_1.BikaAuth,
72
+ displayName: 'Fields',
73
+ description: 'The fields to add to the record.',
74
+ required: true,
75
+ refreshers: ['auth', 'space_id', 'database_id'],
76
+ props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, space_id, database_id }) {
77
+ var _b, _c, _d, _e, _f, _g;
78
+ if (!auth || !space_id || !database_id)
79
+ return {};
80
+ const client = makeClient(auth.props);
81
+ const res = yield client.getDatabaseFields(space_id, database_id);
82
+ const props = {};
83
+ for (const field of res.data) {
84
+ if (![
85
+ "AUTONUMBER" /* BikaFieldType.AUTONUMBER */,
86
+ "CASCADER" /* BikaFieldType.CASCADER */,
87
+ "CREATED_BY" /* BikaFieldType.CREATED_BY */,
88
+ "CREATED_TIME" /* BikaFieldType.CREATED_TIME */,
89
+ "FORMULA" /* BikaFieldType.FORMULA */,
90
+ "LAST_MODIFIED_BY" /* BikaFieldType.LAST_MODIFIED_BY */,
91
+ "LAST_MODIFIED_TIME" /* BikaFieldType.LAST_MODIFIED_TIME */,
92
+ "LOOKUP" /* BikaFieldType.LOOKUP */,
93
+ ].includes(field.type)) {
94
+ switch (field.type) {
95
+ case "ATTACHMENT" /* BikaFieldType.ATTACHMENT */:
96
+ props[field.name] = pieces_framework_1.Property.File({
97
+ displayName: field.name,
98
+ required: false,
99
+ });
100
+ break;
101
+ case "CHECKBOX" /* BikaFieldType.CHECKBOX */:
102
+ props[field.name] = pieces_framework_1.Property.Checkbox({
103
+ displayName: field.name,
104
+ required: false,
105
+ });
106
+ break;
107
+ case "CURRENCY" /* BikaFieldType.CURRENCY */:
108
+ case "NUMBER" /* BikaFieldType.NUMBER */:
109
+ case "PERCENT" /* BikaFieldType.PERCENT */:
110
+ case "RATING" /* BikaFieldType.RATING */:
111
+ props[field.name] = pieces_framework_1.Property.Number({
112
+ displayName: field.name,
113
+ required: false,
114
+ });
115
+ break;
116
+ case "DATETIME" /* BikaFieldType.DATETIME */:
117
+ props[field.name] = pieces_framework_1.Property.DateTime({
118
+ displayName: field.name,
119
+ required: false,
120
+ });
121
+ break;
122
+ case "EMAIL" /* BikaFieldType.EMAIL */:
123
+ case "PHONE" /* BikaFieldType.PHONE */:
124
+ case "SINGLE_TEXT" /* BikaFieldType.SINGLE_TEXT */:
125
+ case "URL" /* BikaFieldType.URL */:
126
+ props[field.name] = pieces_framework_1.Property.ShortText({
127
+ displayName: field.name,
128
+ required: false,
129
+ });
130
+ break;
131
+ case "LONG_TEXT" /* BikaFieldType.LONG_TEXT */:
132
+ props[field.name] = pieces_framework_1.Property.LongText({
133
+ displayName: field.name,
134
+ required: false,
135
+ });
136
+ break;
137
+ case "MULTI_SELECT" /* BikaFieldType.MULTI_SELECT */:
138
+ props[field.name] = pieces_framework_1.Property.StaticMultiSelectDropdown({
139
+ displayName: field.name,
140
+ required: false,
141
+ options: {
142
+ options: ((_c = (_b = field.property) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.map((option) => ({
143
+ label: option.name,
144
+ value: option.name,
145
+ }))) || [],
146
+ },
147
+ });
148
+ break;
149
+ case "SINGLE_SELECT" /* BikaFieldType.SINGLE_SELECT */:
150
+ props[field.name] = pieces_framework_1.Property.StaticDropdown({
151
+ displayName: field.name,
152
+ required: false,
153
+ options: {
154
+ options: ((_e = (_d = field.property) === null || _d === void 0 ? void 0 : _d.options) === null || _e === void 0 ? void 0 : _e.map((option) => ({
155
+ label: option.name,
156
+ value: option.name,
157
+ }))) || [],
158
+ },
159
+ });
160
+ break;
161
+ case "MEMBER" /* BikaFieldType.MEMBER */:
162
+ props[field.name] = pieces_framework_1.Property.StaticMultiSelectDropdown({
163
+ displayName: field.name,
164
+ required: false,
165
+ options: {
166
+ options: ((_g = (_f = field.property) === null || _f === void 0 ? void 0 : _f.options) === null || _g === void 0 ? void 0 : _g.map((option) => {
167
+ return {
168
+ label: option.name,
169
+ value: option.id,
170
+ };
171
+ })) || [],
172
+ },
173
+ });
174
+ break;
175
+ case "LINK" /* BikaFieldType.LINK */:
176
+ props[field.name] = pieces_framework_1.Property.Array({
177
+ displayName: field.name,
178
+ required: false,
179
+ });
180
+ break;
181
+ }
182
+ }
183
+ }
184
+ return props;
185
+ }),
186
+ }),
187
+ };
188
+ function createNewFields(auth, space_id, database_id, fields) {
189
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
190
+ var _a, _b;
191
+ if (!auth)
192
+ return fields;
193
+ if (!database_id)
194
+ return fields;
195
+ const newFields = {};
196
+ const client = makeClient(auth.props);
197
+ const res = yield client.getDatabaseFields(space_id, database_id);
198
+ for (const field of res.data) {
199
+ if ([
200
+ "AUTONUMBER" /* BikaFieldType.AUTONUMBER */,
201
+ "CASCADER" /* BikaFieldType.CASCADER */,
202
+ "CREATED_BY" /* BikaFieldType.CREATED_BY */,
203
+ "CREATED_TIME" /* BikaFieldType.CREATED_TIME */,
204
+ "FORMULA" /* BikaFieldType.FORMULA */,
205
+ "LAST_MODIFIED_TIME" /* BikaFieldType.LAST_MODIFIED_TIME */,
206
+ "LAST_MODIFIED_BY" /* BikaFieldType.LAST_MODIFIED_BY */,
207
+ "LOOKUP" /* BikaFieldType.LOOKUP */,
208
+ ].includes(field.type) || !(field.name in fields)) {
209
+ continue; // Skip irrelevant or missing fields
210
+ }
211
+ const key = field.name;
212
+ // Handle numeric fields
213
+ if (constants_1.BikaNumericFieldTypes.includes(field.type)) {
214
+ newFields[key] = Number(fields[key]);
215
+ }
216
+ // Handle member fields
217
+ else if (field.type === "MEMBER" /* BikaFieldType.MEMBER */) {
218
+ 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]}`);
219
+ }
220
+ // Handle multi-select and two-way-link fields
221
+ else if (["MULTI_SELECT" /* BikaFieldType.MULTI_SELECT */].includes(field.type)) {
222
+ if (!Array.isArray(fields[key]) || fields[key].length === 0) {
223
+ continue; // Skip empty fields
224
+ }
225
+ newFields[key] = fields[key];
226
+ }
227
+ // Handle all other fields
228
+ else {
229
+ newFields[key] = fields[key];
230
+ }
231
+ }
232
+ return newFields;
233
+ });
234
+ }
235
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/common/index.ts"],"names":[],"mappings":";;;AAOA,gCAGC;AAmLD,0CA8DC;;AA3PD,2FAA2F;AAC3F,qEAAqE;AACrE,gEAAiI;AACjI,kCAAmC;AACnC,qCAAsC;AACtC,2CAAmE;AAEnE,SAAgB,UAAU,CAAC,IAA2C;IACrE,MAAM,MAAM,GAAG,IAAI,mBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC;AACf,CAAC;AAEY,QAAA,UAAU,GAAG;IACzB,QAAQ,EAAE,2BAAQ,CAAC,QAAQ,CAAC;QAC3B,IAAI,EAAE,eAAQ;QACd,WAAW,EAAE,OAAO;QACpB,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,EAAE;QACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;YACvB,IAAI,CAAC,IAAI,EAAE,CAAC;gBACX,OAAO;oBACN,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,EAAE;oBACX,WAAW,EAAE,6BAA6B;iBAC1C,CAAC;YACH,CAAC;YACD,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACt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C,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAC9B,CAAC;QAGF,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC;CAAA"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@agnocon/piece-bika",
3
+ "version": "0.1.7",
4
+ "description": "AgnoCon bika connector",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "require": "./dist/index.js",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "src",
17
+ "LICENSE.MIT-AP"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json",
21
+ "vendor": "node ../scripts/vendor-ap.mjs piece-bika"
22
+ },
23
+ "dependencies": {
24
+ "@agnocon/core-utils": "0.2.0",
25
+ "@agnocon/piece-types": "0.3.1",
26
+ "@agnocon/pieces-common": "0.12.8",
27
+ "@agnocon/pieces-framework": "0.36.0",
28
+ "tslib": "2.6.2"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "20.17.6",
32
+ "typescript": "5.5.4"
33
+ },
34
+ "license": "MIT",
35
+ "agnocon": {
36
+ "originVersion": "0.1.7"
37
+ },
38
+ "publishConfig": {
39
+ "access": "restricted",
40
+ "tag": "latest"
41
+ },
42
+ "keywords": [
43
+ "agnocon",
44
+ "connector"
45
+ ]
46
+ }
package/src/index.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { createCustomApiCallAction } from '@agnocon/pieces-common';
2
+ import {
3
+ createPiece,
4
+ PieceAuth,
5
+ PiecePropValueSchema,
6
+ } from '@agnocon/pieces-framework';
7
+ import { PieceCategory } from '@agnocon/pieces-framework';
8
+ import { createRecordAction } from './lib/actions/create-record';
9
+ import { findRecordsAction } from './lib/actions/find-records';
10
+ import { findRecordAction} from './lib/actions/find-record';
11
+ import {deleteRecordAction } from './lib/actions/delete-record';
12
+ import { updateRecordAction } from './lib/actions/update-record';
13
+ import { makeClient } from './lib/common';
14
+ import { BikaAuth } from './lib/auth';
15
+
16
+ export const bika = createPiece({
17
+ displayName: 'Bika.ai',
18
+ auth: BikaAuth,
19
+ description: `Interactive spreadsheets with collaboration`,
20
+ minimumSupportedRelease: '0.30.0',
21
+ logoUrl: 'https://cdn.activepieces.com/pieces/bika.png',
22
+ categories: [PieceCategory.PRODUCTIVITY],
23
+ authors: [
24
+ 'codegino'
25
+ ],
26
+ actions: [
27
+ createRecordAction,
28
+ findRecordsAction,
29
+ findRecordAction,
30
+ updateRecordAction,
31
+ deleteRecordAction,
32
+ createCustomApiCallAction({
33
+ baseUrl: () => 'https://bika.ai/api/openapi/bika',
34
+ auth: BikaAuth,
35
+ authMapping: async (auth) => ({
36
+ Authorization: `Bearer ${(auth).props.token}`,
37
+ }),
38
+ }),
39
+ ],
40
+ triggers: [],
41
+ });
@@ -0,0 +1,61 @@
1
+ import {
2
+ DynamicPropsValue,
3
+ createAction,
4
+ } from '@agnocon/pieces-framework';
5
+ import { BikaCommon, createNewFields, makeClient } from '../common';
6
+ import { BikaAuth } from '../auth';
7
+
8
+ export const createRecordAction = createAction({
9
+ auth: BikaAuth,
10
+ name: 'bika_create_record',
11
+ displayName: 'Create Record',
12
+ description: 'Creates a new record in database.',
13
+ audience: 'both',
14
+ aiMetadata: { description: 'Creates a new record in a Bika.ai database table, populating its fields. Requires a space and database (table) to target; field values must match the database schema (read-only field types like formulas and autonumber are ignored). Not idempotent: each call appends a new record.', idempotent: false },
15
+ props: {
16
+ space_id: BikaCommon.space_id,
17
+ database_id: BikaCommon.database_id,
18
+ fields: BikaCommon.fields,
19
+ },
20
+ async run(context) {
21
+ const auth = context.auth;
22
+ const databaseId = context.propsValue.database_id;
23
+ const spaceId = context.propsValue.space_id;
24
+ const dynamicFields: DynamicPropsValue = context.propsValue.fields;
25
+ const fields: {
26
+ [n: string]: any;
27
+ } = {};
28
+
29
+ const props = Object.entries(dynamicFields);
30
+ for (const [propertyKey, propertyValue] of props) {
31
+ if (propertyValue !== undefined && propertyValue !== '') {
32
+ fields[propertyKey] = propertyValue;
33
+ }
34
+ }
35
+
36
+ const newFields: Record<string, unknown> = await createNewFields(
37
+ auth,
38
+ spaceId,
39
+ databaseId,
40
+ fields
41
+ );
42
+
43
+ const client = makeClient(
44
+ context.auth.props,
45
+ );
46
+ const response: any = await client.createRecord(spaceId, databaseId , {
47
+ records: [
48
+ {
49
+ fields: {
50
+ ...newFields,
51
+ },
52
+ },
53
+ ],
54
+ });
55
+
56
+ if (!response.success) {
57
+ throw new Error(JSON.stringify(response, undefined, 2));
58
+ }
59
+ return response;
60
+ },
61
+ });
@@ -0,0 +1,44 @@
1
+ import {
2
+ Property,
3
+ createAction,
4
+ } from '@agnocon/pieces-framework';
5
+ import { BikaCommon, makeClient } from '../common';
6
+ import { BikaAuth } from '../auth';
7
+
8
+ export const deleteRecordAction = createAction({
9
+ auth: BikaAuth,
10
+ name: 'bika_delete_record',
11
+ displayName: 'Delete Record',
12
+ description: 'Deletes a record in database by ID.',
13
+ audience: 'both',
14
+ aiMetadata: { description: 'Deletes a single record from a Bika.ai database by its record ID, within a given space and database. Use to permanently remove a known record. Idempotent in effect: once removed, repeating the call leaves the record absent.', idempotent: true },
15
+ props: {
16
+ space_id: BikaCommon.space_id,
17
+ database_id: BikaCommon.database_id,
18
+ recordId: Property.ShortText({
19
+ displayName: 'Record ID',
20
+ description: 'The ID of the record to delete.',
21
+ required: true,
22
+ }),
23
+ },
24
+ async run(context) {
25
+ const databaseId = context.propsValue.database_id;
26
+ const spaceId = context.propsValue.space_id;
27
+ const recordId = context.propsValue.recordId;
28
+
29
+ const client = makeClient(
30
+ context.auth.props,
31
+ );
32
+
33
+ const response: any = await client.deleteRecord(
34
+ spaceId,
35
+ databaseId,
36
+ recordId,
37
+ );
38
+
39
+ if (!response.success) {
40
+ throw new Error(JSON.stringify(response, undefined, 2));
41
+ }
42
+ return response;
43
+ },
44
+ });
@@ -0,0 +1,44 @@
1
+ import {
2
+ PiecePropValueSchema,
3
+ Property,
4
+ createAction,
5
+ } from '@agnocon/pieces-framework';
6
+ import { BikaCommon, makeClient } from '../common';
7
+ import { BikaAuth } from '../auth';
8
+
9
+ export const findRecordAction = createAction({
10
+ auth: BikaAuth,
11
+ name: 'bika_find_record',
12
+ displayName: 'Get Record',
13
+ description: 'Retrieves a record in database by ID.',
14
+ audience: 'both',
15
+ aiMetadata: { description: 'Retrieves a single record from a Bika.ai database by its record ID. Use when you already know the exact record ID; to search by field values or fetch multiple rows use Find Records instead. Read-only and idempotent.', idempotent: true },
16
+ props: {
17
+ space_id: BikaCommon.space_id,
18
+ database_id: BikaCommon.database_id,
19
+ recordId: Property.ShortText({
20
+ displayName: 'Record ID',
21
+ required: true,
22
+ }),
23
+ },
24
+ async run(context) {
25
+ const databaseId = context.propsValue.database_id;
26
+ const spaceId = context.propsValue.space_id;
27
+ const recordId = context.propsValue.recordId;
28
+
29
+ const client = makeClient(
30
+ context.auth.props,
31
+ );
32
+
33
+ const response: any = await client.findRecord(
34
+ spaceId,
35
+ databaseId,
36
+ recordId,
37
+ );
38
+
39
+ if (!response.success) {
40
+ throw new Error(JSON.stringify(response, undefined, 2));
41
+ }
42
+ return response;
43
+ },
44
+ });