@activepieces/piece-knack 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-knack
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-knack` to build the library.
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@activepieces/piece-knack",
3
+ "version": "0.0.1",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "@ai-sdk/anthropic": "1.2.12",
9
+ "@ai-sdk/google": "1.2.19",
10
+ "@ai-sdk/openai": "1.3.22",
11
+ "@ai-sdk/replicate": "0.2.8",
12
+ "@sinclair/typebox": "0.34.11",
13
+ "ai": "4.3.16",
14
+ "axios": "1.8.3",
15
+ "axios-retry": "4.4.1",
16
+ "deepmerge-ts": "7.1.0",
17
+ "fast-glob": "3.3.3",
18
+ "mime-types": "2.1.35",
19
+ "nanoid": "3.3.8",
20
+ "semver": "7.6.0",
21
+ "tslib": "^2.3.0",
22
+ "zod": "3.25.76",
23
+ "@activepieces/pieces-common": "0.6.1",
24
+ "@activepieces/pieces-framework": "0.15.0",
25
+ "@activepieces/shared": "0.17.5"
26
+ },
27
+ "overrides": {
28
+ "@tryfabric/martian": {
29
+ "@notionhq/client": "$@notionhq/client"
30
+ },
31
+ "vite": {
32
+ "rollup": "npm:@rollup/wasm-node"
33
+ },
34
+ "stylus": "0.0.1-security"
35
+ },
36
+ "resolutions": {
37
+ "rollup": "npm:@rollup/wasm-node"
38
+ }
39
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare const knack: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
+ applicationId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ }>>;
package/src/index.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.knack = 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 auth_1 = require("./lib/common/auth");
8
+ const create_record_1 = require("./lib/actions/create-record");
9
+ const delete_record_1 = require("./lib/actions/delete-record");
10
+ const find_record_1 = require("./lib/actions/find-record");
11
+ const update_record_1 = require("./lib/actions/update-record");
12
+ const shared_1 = require("@activepieces/shared");
13
+ exports.knack = (0, pieces_framework_1.createPiece)({
14
+ displayName: 'Knack',
15
+ auth: auth_1.knackAuth,
16
+ minimumSupportedRelease: '0.20.0',
17
+ logoUrl: 'https://cdn.activepieces.com/pieces/knack.png',
18
+ categories: [shared_1.PieceCategory.CONTENT_AND_FILES],
19
+ authors: ['aryel780'],
20
+ actions: [
21
+ create_record_1.createRecordAction,
22
+ delete_record_1.deleteRecordAction,
23
+ find_record_1.findRecordAction,
24
+ update_record_1.updateRecordAction,
25
+ (0, pieces_common_1.createCustomApiCallAction)({
26
+ auth: auth_1.knackAuth,
27
+ baseUrl: () => 'https://api.knack.com/v1',
28
+ authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
29
+ const { apiKey, applicationId } = auth;
30
+ return {
31
+ 'X-Knack-Application-ID': applicationId,
32
+ 'X-Knack-REST-API-Key': apiKey,
33
+ };
34
+ }),
35
+ }),
36
+ ],
37
+ triggers: [],
38
+ });
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/knack/src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAA6D;AAC7D,4CAA8C;AAC9C,+DAAiE;AACjE,+DAAiE;AACjE,2DAA6D;AAC7D,+DAAiE;AACjE,iDAAqD;AAExC,QAAA,KAAK,GAAG,IAAA,8BAAW,EAAC;IAC/B,WAAW,EAAE,OAAO;IACpB,IAAI,EAAE,gBAAS;IACf,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,+CAA+C;IACxD,UAAU,EAAC,CAAC,sBAAa,CAAC,iBAAiB,CAAC;IAC5C,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,OAAO,EAAE;QACP,kCAAkB;QAClB,kCAAkB;QAClB,8BAAgB;QAChB,kCAAkB;QAClB,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,gBAAS;YACf,OAAO,EAAE,GAAG,EAAE,CAAC,0BAA0B;YACzC,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAiD,CAAC;gBACpF,OAAO;oBACL,wBAAwB,EAAE,aAAa;oBACvC,sBAAsB,EAAE,MAAM;iBAC/B,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const createRecordAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
+ applicationId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ }>, {
5
+ object: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
6
+ recordFields: import("@activepieces/pieces-framework").DynamicProperties<true>;
7
+ }>;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRecordAction = 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 client_1 = require("../common/client");
8
+ const auth_1 = require("../common/auth");
9
+ const props_1 = require("../common/props");
10
+ exports.createRecordAction = (0, pieces_framework_1.createAction)({
11
+ auth: auth_1.knackAuth,
12
+ name: 'create_record',
13
+ displayName: 'Create Record',
14
+ description: 'Creates a new record into a specified object/table.',
15
+ props: {
16
+ object: props_1.objectDropdown,
17
+ recordFields: props_1.recordFields,
18
+ },
19
+ run(_a) {
20
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ propsValue, auth }) {
21
+ const { object: objectKey, recordFields: recordData } = propsValue;
22
+ try {
23
+ const response = yield (0, client_1.knackApiCall)({
24
+ method: pieces_common_1.HttpMethod.POST,
25
+ auth: auth,
26
+ resourceUri: `/objects/${objectKey}/records`,
27
+ body: recordData,
28
+ });
29
+ const objectDetails = yield (0, client_1.knackApiCall)({
30
+ method: pieces_common_1.HttpMethod.GET,
31
+ auth,
32
+ resourceUri: `/objects/${objectKey}`,
33
+ });
34
+ const transformedRecord = (0, props_1.knackTransformFields)(objectDetails, response);
35
+ return transformedRecord;
36
+ }
37
+ catch (error) {
38
+ if (error.message.includes('409')) {
39
+ throw new Error('Conflict: The record could not be created due to a conflict, such as a duplicate unique value.');
40
+ }
41
+ if (error.message.includes('400')) {
42
+ throw new Error('Bad Request: Invalid request parameters. Please check your Record Data JSON and field values.');
43
+ }
44
+ if (error.message.includes('401') || error.message.includes('403')) {
45
+ throw new Error('Authentication Failed: Please check your API Key, Application ID, and user permissions.');
46
+ }
47
+ if (error.message.includes('429')) {
48
+ throw new Error('Rate Limit Exceeded: Too many requests. Please wait a moment before trying again.');
49
+ }
50
+ throw new Error(`Failed to create Knack record: ${error.message}`);
51
+ }
52
+ });
53
+ },
54
+ });
55
+ //# sourceMappingURL=create-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-record.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/knack/src/lib/actions/create-record.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAA8D;AAC9D,6CAAgD;AAChD,yCAA2C;AAC3C,2CAKyB;AAEZ,QAAA,kBAAkB,GAAG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CAAC,KAAK,CAAC,EAAE,CAAC;oBACnE,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;gBACJ,CAAC;gBAED,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;oBAClC,MAAM,IAAI,KAAK,CACb,mFAAmF,CACpF,CAAC;gBACJ,CAAC;gBAED,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const deleteRecordAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
+ applicationId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ }>, {
5
+ object: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
6
+ recordId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
7
+ }>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteRecordAction = 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 client_1 = require("../common/client");
8
+ const auth_1 = require("../common/auth");
9
+ const props_1 = require("../common/props");
10
+ exports.deleteRecordAction = (0, pieces_framework_1.createAction)({
11
+ auth: auth_1.knackAuth,
12
+ name: 'delete_record',
13
+ displayName: 'Delete Record',
14
+ description: 'Deletes an existing record from a table.',
15
+ props: {
16
+ object: props_1.objectDropdown,
17
+ recordId: pieces_framework_1.Property.ShortText({
18
+ displayName: 'Record ID',
19
+ required: true,
20
+ description: 'The ID of the record to delete.',
21
+ }),
22
+ },
23
+ run(_a) {
24
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ propsValue, auth }) {
25
+ const { object: objectKey, recordId } = propsValue;
26
+ try {
27
+ const response = yield (0, client_1.knackApiCall)({
28
+ method: pieces_common_1.HttpMethod.DELETE,
29
+ auth: auth,
30
+ resourceUri: `/objects/${objectKey}/records/${recordId}`,
31
+ });
32
+ return response;
33
+ }
34
+ catch (error) {
35
+ if (error.message.includes('404')) {
36
+ throw new Error('Not Found: The record ID was not found in the specified object. Please verify the ID is correct.');
37
+ }
38
+ if (error.message.includes('400')) {
39
+ throw new Error('Bad Request: The request was invalid. Please ensure the Record ID is formatted correctly.');
40
+ }
41
+ if (error.message.includes('401') || error.message.includes('403')) {
42
+ throw new Error('Authentication Failed: Please check your API Key, Application ID, and user permissions.');
43
+ }
44
+ if (error.message.includes('429')) {
45
+ throw new Error('Rate Limit Exceeded: Too many requests. Please wait a moment before trying again.');
46
+ }
47
+ throw new Error(`Failed to delete Knack record: ${error.message}`);
48
+ }
49
+ });
50
+ },
51
+ });
52
+ //# sourceMappingURL=delete-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-record.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/knack/src/lib/actions/delete-record.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,6CAAgE;AAChE,yCAA2C;AAC3C,2CAAiD;AAEpC,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,gBAAS;IACf,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,0CAA0C;IACvD,KAAK,EAAE;QACL,MAAM,EAAE,sBAAc;QACtB,QAAQ,EAAG,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,WAAW;YACxB,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,iCAAiC;SAC/C,CAAC;KACH;IACK,GAAG;qEAAC,EAAE,UAAU,EAAE,IAAI,EAAE;YAC5B,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC;YAEnD,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAY,EAAC;oBAClC,MAAM,EAAE,0BAAU,CAAC,MAAM;oBACzB,IAAI,EAAE,IAAI;oBACV,WAAW,EAAE,YAAY,SAAS,YAAY,QAAQ,EAAE;iBACzD,CAAC,CAAC;gBACH,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;oBAClC,MAAM,IAAI,KAAK,CACb,kGAAkG,CACnG,CAAC;gBACJ,CAAC;gBAED,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;oBAClC,MAAM,IAAI,KAAK,CACb,2FAA2F,CAC5F,CAAC;gBACJ,CAAC;gBAED,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnE,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;gBACJ,CAAC;gBAED,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;oBAClC,MAAM,IAAI,KAAK,CACb,mFAAmF,CACpF,CAAC;gBACJ,CAAC;gBAED,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const findRecordAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
+ applicationId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ }>, {
5
+ object: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
6
+ fieldId: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
7
+ fieldValue: import("@activepieces/pieces-framework").ShortTextProperty<true>;
8
+ }>;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findRecordAction = 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 client_1 = require("../common/client");
8
+ const auth_1 = require("../common/auth");
9
+ const props_1 = require("../common/props");
10
+ exports.findRecordAction = (0, pieces_framework_1.createAction)({
11
+ auth: auth_1.knackAuth,
12
+ name: 'find_record',
13
+ displayName: 'Find Record',
14
+ description: 'Finds a single record using field value.',
15
+ props: {
16
+ object: props_1.objectDropdown,
17
+ fieldId: props_1.fieldIdDropdown,
18
+ fieldValue: pieces_framework_1.Property.ShortText({
19
+ displayName: 'Field Value',
20
+ required: true,
21
+ description: 'The value to search for in the specified field.',
22
+ }),
23
+ },
24
+ run(_a) {
25
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ propsValue, auth }) {
26
+ const { object: objectKey, fieldId, fieldValue } = propsValue;
27
+ try {
28
+ const response = yield (0, client_1.knackApiCall)({
29
+ method: pieces_common_1.HttpMethod.GET,
30
+ auth: auth,
31
+ resourceUri: `/objects/${objectKey}/records`,
32
+ query: {
33
+ filters: JSON.stringify([
34
+ {
35
+ field: fieldId,
36
+ operator: 'is',
37
+ value: fieldValue,
38
+ },
39
+ ]),
40
+ rows_per_page: '1',
41
+ },
42
+ });
43
+ if (response.records && response.records.length > 0) {
44
+ const objectDetails = yield (0, client_1.knackApiCall)({
45
+ method: pieces_common_1.HttpMethod.GET,
46
+ auth,
47
+ resourceUri: `/objects/${objectKey}`,
48
+ });
49
+ const transformedRecord = (0, props_1.knackTransformFields)(objectDetails, response.records[0]);
50
+ return {
51
+ found: true,
52
+ record: transformedRecord,
53
+ };
54
+ }
55
+ return {
56
+ found: false,
57
+ record: null,
58
+ message: 'No record found matching the provided filters.',
59
+ };
60
+ }
61
+ catch (error) {
62
+ if (error.message.includes('400')) {
63
+ throw new Error('Bad Request: The filter rules are invalid. Please check the JSON format and field/operator values.');
64
+ }
65
+ if (error.message.includes('401') || error.message.includes('403')) {
66
+ throw new Error('Authentication Failed: Please check your API Key, Application ID, and user permissions.');
67
+ }
68
+ if (error.message.includes('429')) {
69
+ throw new Error('Rate Limit Exceeded: Too many requests. Please wait a moment before trying again.');
70
+ }
71
+ throw new Error(`Failed to find Knack record: ${error.message}`);
72
+ }
73
+ });
74
+ },
75
+ });
76
+ //# sourceMappingURL=find-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-record.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/knack/src/lib/actions/find-record.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,6CAAgD;AAChD,yCAA2C;AAC3C,2CAKyB;AAEZ,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,gBAAS;IACf,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,0CAA0C;IACvD,KAAK,EAAE;QACL,MAAM,EAAE,sBAAc;QACtB,OAAO,EAAE,uBAAe;QACxB,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,iDAAiD;SAC/D,CAAC;KACH;IACK,GAAG;qEAAC,EAAE,UAAU,EAAE,IAAI,EAAE;YAC5B,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC;YAE9D,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAY,EAAqC;oBACtE,MAAM,EAAE,0BAAU,CAAC,GAAG;oBACtB,IAAI,EAAE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AAC,KAAK,CAAC,EAAE,CAAC;oBAClC,MAAM,IAAI,KAAK,CACb,mFAAmF,CACpF,CAAC;gBACJ,CAAC;gBAED,MAAM,IAAI,KAAK,CAAC,gCAAgC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const updateRecordAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
+ applicationId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ }>, {
5
+ object: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
6
+ recordId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
7
+ recordFields: import("@activepieces/pieces-framework").DynamicProperties<true>;
8
+ }>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateRecordAction = 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 client_1 = require("../common/client");
8
+ const auth_1 = require("../common/auth");
9
+ const props_1 = require("../common/props");
10
+ exports.updateRecordAction = (0, pieces_framework_1.createAction)({
11
+ auth: auth_1.knackAuth,
12
+ name: 'update_record',
13
+ displayName: 'Update Record',
14
+ description: 'Updates an existing record.',
15
+ props: {
16
+ object: props_1.objectDropdown,
17
+ recordId: pieces_framework_1.Property.ShortText({
18
+ displayName: 'Record ID',
19
+ required: true,
20
+ description: 'The ID of the record to update.',
21
+ }),
22
+ recordFields: props_1.recordFields,
23
+ },
24
+ run(_a) {
25
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ propsValue, auth }) {
26
+ const { object: objectKey, recordId, recordFields } = propsValue;
27
+ try {
28
+ const response = yield (0, client_1.knackApiCall)({
29
+ method: pieces_common_1.HttpMethod.PUT,
30
+ auth: auth,
31
+ resourceUri: `/objects/${objectKey}/records/${recordId}`,
32
+ body: recordFields,
33
+ });
34
+ const objectDetails = yield (0, client_1.knackApiCall)({
35
+ method: pieces_common_1.HttpMethod.GET,
36
+ auth,
37
+ resourceUri: `/objects/${objectKey}`,
38
+ });
39
+ const transformedRecord = (0, props_1.knackTransformFields)(objectDetails, response);
40
+ return transformedRecord;
41
+ }
42
+ catch (error) {
43
+ if (error.message.includes('404')) {
44
+ throw new Error('Not Found: The record ID was not found in the specified object. Please verify the ID is correct.');
45
+ }
46
+ if (error.message.includes('409')) {
47
+ throw new Error('Conflict: The record could not be updated due to a conflict, such as a duplicate unique value.');
48
+ }
49
+ if (error.message.includes('400')) {
50
+ throw new Error('Bad Request: Invalid request parameters. Please check your Data to Update JSON and field values.');
51
+ }
52
+ if (error.message.includes('401') || error.message.includes('403')) {
53
+ throw new Error('Authentication Failed: Please check your API Key, Application ID, and user permissions.');
54
+ }
55
+ if (error.message.includes('429')) {
56
+ throw new Error('Rate Limit Exceeded: Too many requests. Please wait a moment before trying again.');
57
+ }
58
+ throw new Error(`Failed to update Knack record: ${error.message}`);
59
+ }
60
+ });
61
+ },
62
+ });
63
+ //# sourceMappingURL=update-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-record.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/knack/src/lib/actions/update-record.ts"],"names":[],"mappings":";;;;AAAA,+DAAyD;AACzD,qEAAwE;AACxE,6CAAgD;AAChD,yCAA2C;AAC3C,2CAKyB;AAEZ,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,gBAAS;IACf,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,6BAA6B;IAC1C,KAAK,EAAE;QACL,MAAM,EAAE,sBAAc;QACtB,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,WAAW;YACxB,Q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AC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnE,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;gBACJ,CAAC;gBAED,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;oBAClC,MAAM,IAAI,KAAK,CACb,mFAAmF,CACpF,CAAC;gBACJ,CAAC;gBAED,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const knackAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
3
+ applicationId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
+ }>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.knackAuth = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const client_1 = require("./client");
7
+ const pieces_common_1 = require("@activepieces/pieces-common");
8
+ exports.knackAuth = pieces_framework_1.PieceAuth.CustomAuth({
9
+ props: {
10
+ apiKey: pieces_framework_1.PieceAuth.SecretText({
11
+ displayName: 'API Key',
12
+ description: 'Your Knack API Key available in the Settings section of the Builder.',
13
+ required: true,
14
+ }),
15
+ applicationId: pieces_framework_1.Property.ShortText({
16
+ displayName: 'Application ID',
17
+ description: 'Your Application ID available in the Settings section of the Builder.',
18
+ required: true,
19
+ }),
20
+ },
21
+ validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
22
+ try {
23
+ yield (0, client_1.knackApiCall)({
24
+ method: pieces_common_1.HttpMethod.GET,
25
+ auth,
26
+ resourceUri: '/objects',
27
+ });
28
+ return { valid: true };
29
+ }
30
+ catch (e) {
31
+ return {
32
+ valid: false,
33
+ error: 'Invalid API Key or Application ID',
34
+ };
35
+ }
36
+ }),
37
+ required: true,
38
+ });
39
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/knack/src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAAqE;AACrE,qCAAwC;AACxC,+DAAyD;AAE5C,QAAA,SAAS,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC5C,KAAK,EAAE;QACL,MAAM,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC3B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,sEAAsE;YACnF,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,aAAa,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAChC,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,uEAAuE;YACpF,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACD,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,IAAA,qBAAY,EAAC;gBACjB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI;gBACJ,WAAW,EAAE,UAAU;aACxB,CAAC,CAAC;YACH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,mCAAmC;aAC3C,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;IACD,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { HttpMethod, HttpMessageBody } from '@activepieces/pieces-common';
2
+ export type KnackAuthProps = {
3
+ apiKey: string;
4
+ applicationId: string;
5
+ };
6
+ export type KnackApiCallParams = {
7
+ method: HttpMethod;
8
+ resourceUri: string;
9
+ query?: Record<string, string | number | string[] | undefined>;
10
+ body?: any;
11
+ auth: KnackAuthProps;
12
+ };
13
+ export declare function knackApiCall<T extends HttpMessageBody>({ method, resourceUri, query, body, auth, }: KnackApiCallParams): Promise<T>;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.knackApiCall = knackApiCall;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ function knackApiCall(_a) {
7
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ method, resourceUri, query, body, auth, }) {
8
+ var _b, _c;
9
+ const { apiKey, applicationId } = auth;
10
+ if (!apiKey || !applicationId) {
11
+ throw new Error('Knack API key and Application ID are required for authentication');
12
+ }
13
+ const queryParams = {};
14
+ if (query) {
15
+ for (const [key, value] of Object.entries(query)) {
16
+ if (value !== null && value !== undefined) {
17
+ queryParams[key] = String(value);
18
+ }
19
+ }
20
+ }
21
+ const baseUrl = 'https://api.knack.com/v1';
22
+ const request = {
23
+ method,
24
+ url: `${baseUrl}${resourceUri}`,
25
+ headers: {
26
+ 'X-Knack-Application-ID': applicationId,
27
+ 'X-Knack-REST-API-Key': apiKey,
28
+ 'Content-Type': 'application/json',
29
+ },
30
+ queryParams,
31
+ body,
32
+ };
33
+ try {
34
+ const response = yield pieces_common_1.httpClient.sendRequest(request);
35
+ return response.body;
36
+ }
37
+ catch (error) {
38
+ const statusCode = (_b = error.response) === null || _b === void 0 ? void 0 : _b.status;
39
+ const errorData = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data;
40
+ switch (statusCode) {
41
+ case 400:
42
+ throw new Error(`Bad Request: ${(errorData === null || errorData === void 0 ? void 0 : errorData.message) || 'Invalid request parameters'}. Please check your data and field values.`);
43
+ case 401:
44
+ throw new Error('Authentication Failed: Invalid API key or Application ID. Please verify your Knack credentials in the connection settings.');
45
+ case 403:
46
+ throw new Error('Access Forbidden: You do not have permission to access this resource. Please check your Knack account permissions.');
47
+ case 404:
48
+ throw new Error('Resource Not Found: The requested object or resource does not exist. Please verify the identifier is correct.');
49
+ case 429:
50
+ throw new Error('Rate Limit Exceeded: Too many requests in a short time period. Please wait before trying again.');
51
+ case 500:
52
+ throw new Error('Internal Server Error: Knack is experiencing technical difficulties. Please try again later or contact Knack support.');
53
+ case 502:
54
+ case 503:
55
+ case 504:
56
+ throw new Error('Service Unavailable: Knack service is temporarily unavailable. Please try again in a few minutes.');
57
+ default:
58
+ {
59
+ const errorMessage = (errorData === null || errorData === void 0 ? void 0 : errorData.message) ||
60
+ error.message ||
61
+ 'Unknown error occurred';
62
+ throw new Error(`Knack API Error (${statusCode || 'Unknown'}): ${errorMessage}`);
63
+ }
64
+ }
65
+ }
66
+ });
67
+ }
68
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/knack/src/lib/common/client.ts"],"names":[],"mappings":";;AAqBA,oCAgGC;;AArHD,+DAMqC;AAerC,SAAsB,YAAY;iEAA4B,EAC5D,MAAM,EACN,WAAW,EACX,KAAK,EACL,IAAI,EACJ,IAAI,GACe;;QACnB,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;QAEvC,IAAI,CAAC,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;QACtF,CAAC;QAED,MAAM,WAAW,GAAgB,EAAE,CAAC;QAEpC,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;oBAC1C,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;gBACnC,CAAC;YACH,CAA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BAEJ;oBACE,CAAC;wBACS,MAAM,YAAY,GAAG,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO;4BAC5B,KAAK,CAAC,OAAO;4BACb,wBAAwB,CAAC;wBAE9C,MAAM,IAAI,KAAK,CACb,oBAAoB,UAAU,IAAI,SAAS,MAAM,YAAY,EAAE,CAChE,CAAC;oBACF,CAAC;YAGL,CAAC;QACH,CAAC;IACH,CAAC;CAAA"}
@@ -0,0 +1,17 @@
1
+ export interface KnackGetObjectResponse {
2
+ object: {
3
+ fields: {
4
+ type: string;
5
+ key: string;
6
+ name: string;
7
+ format: {
8
+ type: string;
9
+ options: string[];
10
+ };
11
+ }[];
12
+ };
13
+ }
14
+ export declare const objectDropdown: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
15
+ export declare const fieldIdDropdown: import("@activepieces/pieces-framework").DropdownProperty<string, true>;
16
+ export declare const recordFields: import("@activepieces/pieces-framework").DynamicProperties<true>;
17
+ export declare function knackTransformFields(objectDetails: KnackGetObjectResponse, recordFields: Record<string, any>): Record<string, any>;
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.recordFields = exports.fieldIdDropdown = exports.objectDropdown = void 0;
4
+ exports.knackTransformFields = knackTransformFields;
5
+ const tslib_1 = require("tslib");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const pieces_common_1 = require("@activepieces/pieces-common");
8
+ const client_1 = require("./client");
9
+ exports.objectDropdown = pieces_framework_1.Property.Dropdown({
10
+ displayName: 'Object',
11
+ required: true,
12
+ refreshers: [],
13
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
14
+ if (!auth) {
15
+ return {
16
+ disabled: true,
17
+ placeholder: 'Please authenticate first.',
18
+ options: [],
19
+ };
20
+ }
21
+ const typedAuth = auth;
22
+ try {
23
+ const response = yield (0, client_1.knackApiCall)({
24
+ method: pieces_common_1.HttpMethod.GET,
25
+ auth: typedAuth,
26
+ resourceUri: '/objects',
27
+ });
28
+ return {
29
+ disabled: false,
30
+ options: response.objects.map((object) => ({
31
+ label: object.name,
32
+ value: object.key,
33
+ })),
34
+ };
35
+ }
36
+ catch (error) {
37
+ return {
38
+ disabled: true,
39
+ placeholder: `Error loading objects: ${error.message}`,
40
+ options: [],
41
+ };
42
+ }
43
+ }),
44
+ });
45
+ exports.fieldIdDropdown = pieces_framework_1.Property.Dropdown({
46
+ displayName: 'Field ID',
47
+ required: true,
48
+ description: 'Field to find the record by',
49
+ refreshers: ['object'],
50
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, object }) {
51
+ if (!auth || !object) {
52
+ return {
53
+ disabled: true,
54
+ placeholder: 'Please select an object first.',
55
+ options: [],
56
+ };
57
+ }
58
+ const typedAuth = auth;
59
+ try {
60
+ const response = yield (0, client_1.knackApiCall)({
61
+ method: pieces_common_1.HttpMethod.GET,
62
+ auth: typedAuth,
63
+ resourceUri: `/objects/${object}`,
64
+ });
65
+ return {
66
+ disabled: false,
67
+ options: response.object.fields.map((field) => ({
68
+ label: field.name,
69
+ value: field.key,
70
+ })),
71
+ };
72
+ }
73
+ catch (error) {
74
+ return {
75
+ disabled: true,
76
+ placeholder: `Error loading objects: ${error.message}`,
77
+ options: [],
78
+ };
79
+ }
80
+ }),
81
+ });
82
+ exports.recordFields = pieces_framework_1.Property.DynamicProperties({
83
+ displayName: 'Record Fields',
84
+ refreshers: ['object'],
85
+ required: true,
86
+ props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, object }) {
87
+ if (!auth || !object) {
88
+ return {};
89
+ }
90
+ const props = {};
91
+ const typedAuth = auth;
92
+ const response = yield (0, client_1.knackApiCall)({
93
+ method: pieces_common_1.HttpMethod.GET,
94
+ auth: typedAuth,
95
+ resourceUri: `/objects/${object}`,
96
+ });
97
+ for (const field of response.object.fields) {
98
+ switch (field.type) {
99
+ case 'short_text':
100
+ case 'email':
101
+ case 'phone':
102
+ case 'link':
103
+ props[field.key] = pieces_framework_1.Property.ShortText({
104
+ displayName: field.name,
105
+ required: false,
106
+ });
107
+ break;
108
+ case 'paragraph_text':
109
+ case 'address':
110
+ case 'rich_text':
111
+ props[field.key] = pieces_framework_1.Property.LongText({
112
+ displayName: field.name,
113
+ required: false,
114
+ });
115
+ break;
116
+ case 'number':
117
+ case 'rating':
118
+ case 'currency':
119
+ props[field.key] = pieces_framework_1.Property.Number({
120
+ displayName: field.name,
121
+ required: false,
122
+ });
123
+ break;
124
+ case 'multiple_choice': {
125
+ const options = field.format.options.map((option) => ({
126
+ label: option,
127
+ value: option,
128
+ }));
129
+ props[field.key] =
130
+ field.format.type === 'multi'
131
+ ? pieces_framework_1.Property.StaticMultiSelectDropdown({
132
+ displayName: field.name,
133
+ required: false,
134
+ options: {
135
+ options,
136
+ },
137
+ })
138
+ : pieces_framework_1.Property.StaticDropdown({
139
+ displayName: field.name,
140
+ required: false,
141
+ options: { options },
142
+ });
143
+ break;
144
+ }
145
+ case 'boolean':
146
+ props[field.key] = pieces_framework_1.Property.Checkbox({
147
+ displayName: field.name,
148
+ required: false,
149
+ });
150
+ break;
151
+ }
152
+ }
153
+ return props;
154
+ }),
155
+ });
156
+ function knackTransformFields(objectDetails, recordFields) {
157
+ const fields = objectDetails.object.fields;
158
+ const keyToNameMap = {};
159
+ for (const field of fields) {
160
+ if (field && field.key && field.name) {
161
+ keyToNameMap[field.key] = field.name;
162
+ }
163
+ }
164
+ const transformed = {};
165
+ for (const [key, value] of Object.entries(recordFields)) {
166
+ const isRaw = key.endsWith('_raw');
167
+ const baseKey = isRaw ? key.slice(0, -4) : key;
168
+ const fieldName = keyToNameMap[baseKey];
169
+ if (fieldName) {
170
+ const transformedKey = isRaw ? `${fieldName} raw` : fieldName;
171
+ transformed[transformedKey] = value;
172
+ }
173
+ else {
174
+ transformed[key] = value;
175
+ }
176
+ }
177
+ return transformed;
178
+ }
179
+ //# sourceMappingURL=props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/knack/src/lib/common/props.ts"],"names":[],"mappings":";;;AAoLA,oDA6BC;;AAjND,qEAA6E;AAC7E,+DAAyD;AACzD,qCAAwD;AAqB3C,QAAA,cAAc,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IAC9C,WAAW,EAAE,QAAQ;IACrB,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACtB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,4BAA4B;gBACzC,OAAO,EAAE,EAAE;aACZ,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAG,IAAsB,CAAC;QAEzC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAY,EAA6B;gBAC9D,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,UAAU;aACxB,CAAC,CAAC;YAEH,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;oBACzC,KAAK,EAAE,MAAM,CAAC,IAAI;oBAClB,KAAK,EAAE,MAAM,CAAC,GAAG;iBAClB,CAAC,CAAC;aACJ,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,0BAA0B,KAAK,CAAC,OAAO,EAAE;gBACtD,OAAO,EAAE,EAAE;aACZ,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC;AAEU,QAAA,eAAe,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IAC/C,WAAW,EAAE,U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