@taskmagic/apps-readwise 0.1.2
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 +7 -0
- package/package.json +47 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +37 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/create-highlight.d.ts +14 -0
- package/src/lib/actions/create-highlight.js +132 -0
- package/src/lib/actions/create-highlight.js.map +1 -0
- package/src/lib/actions/get-highlights.d.ts +6 -0
- package/src/lib/actions/get-highlights.js +59 -0
- package/src/lib/actions/get-highlights.js.map +1 -0
- package/src/lib/common/auth.d.ts +1 -0
- package/src/lib/common/auth.js +26 -0
- package/src/lib/common/auth.js.map +1 -0
- package/src/lib/common/client.d.ts +75 -0
- package/src/lib/common/client.js +26 -0
- package/src/lib/common/client.js.map +1 -0
- package/src/lib/common/props.d.ts +5 -0
- package/src/lib/common/props.js +55 -0
- package/src/lib/common/props.js.map +1 -0
- package/src/lib/triggers/new-highlight.d.ts +2 -0
- package/src/lib/triggers/new-highlight.js +91 -0
- package/src/lib/triggers/new-highlight.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taskmagic/apps-readwise",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@anthropic-ai/sdk": "0.33.1",
|
|
6
|
+
"@sinclair/typebox": "0.34.11",
|
|
7
|
+
"axios": "1.17.0",
|
|
8
|
+
"axios-retry": "4.4.1",
|
|
9
|
+
"deepmerge-ts": "7.1.0",
|
|
10
|
+
"mime-types": "2.1.35",
|
|
11
|
+
"nanoid": "3.3.8",
|
|
12
|
+
"openai": "4.67.1",
|
|
13
|
+
"replicate": "0.34.1",
|
|
14
|
+
"semver": "7.6.0",
|
|
15
|
+
"zod": "3.25.76",
|
|
16
|
+
"@taskmagic/pieces-common": "0.4.4",
|
|
17
|
+
"@taskmagic/pieces-framework": "0.7.46",
|
|
18
|
+
"@taskmagic/shared": "0.10.171",
|
|
19
|
+
"tslib": "1.14.1"
|
|
20
|
+
},
|
|
21
|
+
"overrides": {
|
|
22
|
+
"cross-spawn": "7.0.6",
|
|
23
|
+
"elliptic": "^6.6.1",
|
|
24
|
+
"fast-xml-parser": "^4.4.1",
|
|
25
|
+
"protobufjs": "^7.5.5",
|
|
26
|
+
"tmp": "^0.2.4",
|
|
27
|
+
"koa": "^2.16.4",
|
|
28
|
+
"picomatch": "^4.0.4",
|
|
29
|
+
"langsmith": "^0.6.0",
|
|
30
|
+
"serialize-javascript": "^6.0.2",
|
|
31
|
+
"elevenlabs": {
|
|
32
|
+
"form-data": "^4.0.4"
|
|
33
|
+
},
|
|
34
|
+
"@tryfabric/martian": {
|
|
35
|
+
"@notionhq/client": "$@notionhq/client"
|
|
36
|
+
},
|
|
37
|
+
"vite": {
|
|
38
|
+
"rollup": "npm:@rollup/wasm-node@^4.61.1"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"resolutions": {
|
|
42
|
+
"rollup": "npm:@rollup/wasm-node@^4.61.1"
|
|
43
|
+
},
|
|
44
|
+
"types": "./src/index.d.ts",
|
|
45
|
+
"main": "./src/index.js",
|
|
46
|
+
"type": "commonjs"
|
|
47
|
+
}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readwiseAuth = exports.readwise = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const shared_1 = require("@taskmagic/shared");
|
|
8
|
+
const auth_1 = require("./lib/common/auth");
|
|
9
|
+
Object.defineProperty(exports, "readwiseAuth", { enumerable: true, get: function () { return auth_1.readwiseAuth; } });
|
|
10
|
+
const client_1 = require("./lib/common/client");
|
|
11
|
+
const get_highlights_1 = require("./lib/actions/get-highlights");
|
|
12
|
+
const create_highlight_1 = require("./lib/actions/create-highlight");
|
|
13
|
+
const new_highlight_1 = require("./lib/triggers/new-highlight");
|
|
14
|
+
exports.readwise = (0, pieces_framework_1.createPiece)({
|
|
15
|
+
displayName: 'Readwise',
|
|
16
|
+
description: 'Save and retrieve your highlights from Readwise — your reading notes, all in one place.',
|
|
17
|
+
minimumSupportedRelease: '0.30.0',
|
|
18
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/readwise.png',
|
|
19
|
+
categories: [shared_1.PieceCategory.PRODUCTIVITY],
|
|
20
|
+
authors: ['tosh2308'],
|
|
21
|
+
auth: auth_1.readwiseAuth,
|
|
22
|
+
actions: [
|
|
23
|
+
get_highlights_1.getHighlights,
|
|
24
|
+
create_highlight_1.createHighlight,
|
|
25
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
26
|
+
baseUrl: () => client_1.READWISE_BASE_URL,
|
|
27
|
+
auth: auth_1.readwiseAuth,
|
|
28
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
return ({
|
|
30
|
+
Authorization: `Token ${auth}`,
|
|
31
|
+
});
|
|
32
|
+
}),
|
|
33
|
+
}),
|
|
34
|
+
],
|
|
35
|
+
triggers: [new_highlight_1.newHighlight],
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/readwise/src/index.ts"],"names":[],"mappings":";;;;AAAA,kEAA0D;AAC1D,4DAAqE;AACrE,8CAAkD;AAClD,4CAAiD;AA6BxC,6FA7BA,mBAAY,OA6BA;AA5BrB,gDAAwD;AACxD,iEAA6D;AAC7D,qEAAiE;AACjE,gEAA4D;AAE/C,QAAA,QAAQ,GAAG,IAAA,8BAAW,EAAC;IAClC,WAAW,EAAE,UAAU;IACvB,WAAW,EACT,yFAAyF;IAC3F,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,kDAAkD;IAC3D,UAAU,EAAE,CAAC,sBAAa,CAAC,YAAY,CAAC;IACxC,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,IAAI,EAAE,mBAAY;IAClB,OAAO,EAAE;QACP,8BAAa;QACb,kCAAe;QACf,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,0BAAiB;YAChC,IAAI,EAAE,mBAAY;YAClB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,aAAa,EAAE,SAAS,IAAI,EAAE;iBAC/B,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,4BAAY,CAAC;CACzB,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const createHighlight: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
text: import("@taskmagic/pieces-framework").LongTextProperty<true>;
|
|
3
|
+
title: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
4
|
+
author: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
source_url: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
source_type: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
7
|
+
category: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
8
|
+
note: import("@taskmagic/pieces-framework").LongTextProperty<false>;
|
|
9
|
+
location: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
10
|
+
location_type: import("@taskmagic/pieces-framework").StaticDropdownProperty<string, false>;
|
|
11
|
+
image_url: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
12
|
+
highlight_url: import("@taskmagic/pieces-framework").ShortTextProperty<false>;
|
|
13
|
+
highlighted_at: import("@taskmagic/pieces-framework").DateTimeProperty<false>;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createHighlight = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const auth_1 = require("../common/auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
exports.createHighlight = (0, pieces_framework_1.createAction)({
|
|
10
|
+
name: 'create_highlight',
|
|
11
|
+
displayName: 'Create Highlight',
|
|
12
|
+
description: 'Save a new highlight to Readwise.',
|
|
13
|
+
auth: auth_1.readwiseAuth,
|
|
14
|
+
props: {
|
|
15
|
+
text: pieces_framework_1.Property.LongText({
|
|
16
|
+
displayName: 'Highlight Text',
|
|
17
|
+
description: 'The text you want to save as a highlight.',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
title: pieces_framework_1.Property.ShortText({
|
|
21
|
+
displayName: 'Source Title',
|
|
22
|
+
description: 'Title of the book, article, or source.',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
25
|
+
author: pieces_framework_1.Property.ShortText({
|
|
26
|
+
displayName: 'Author',
|
|
27
|
+
description: 'Author of the source.',
|
|
28
|
+
required: false,
|
|
29
|
+
}),
|
|
30
|
+
source_url: pieces_framework_1.Property.ShortText({
|
|
31
|
+
displayName: 'Source URL',
|
|
32
|
+
description: 'URL of the article or webpage.',
|
|
33
|
+
required: false,
|
|
34
|
+
}),
|
|
35
|
+
source_type: pieces_framework_1.Property.ShortText({
|
|
36
|
+
displayName: 'Source Type',
|
|
37
|
+
description: 'An identifier for your app/source, e.g. "my_app" (3–64 chars, no spaces).',
|
|
38
|
+
required: false,
|
|
39
|
+
}),
|
|
40
|
+
category: pieces_framework_1.Property.StaticDropdown({
|
|
41
|
+
displayName: 'Category',
|
|
42
|
+
description: 'Type of source.',
|
|
43
|
+
required: false,
|
|
44
|
+
defaultValue: 'articles',
|
|
45
|
+
options: {
|
|
46
|
+
options: [
|
|
47
|
+
{ label: 'Articles', value: 'articles' },
|
|
48
|
+
{ label: 'Books', value: 'books' },
|
|
49
|
+
{ label: 'Tweets', value: 'tweets' },
|
|
50
|
+
{ label: 'Podcasts', value: 'podcasts' },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
note: pieces_framework_1.Property.LongText({
|
|
55
|
+
displayName: 'Note',
|
|
56
|
+
description: 'Optional note to attach to the highlight.',
|
|
57
|
+
required: false,
|
|
58
|
+
}),
|
|
59
|
+
location: pieces_framework_1.Property.Number({
|
|
60
|
+
displayName: 'Location',
|
|
61
|
+
description: 'Position of the highlight in the source.',
|
|
62
|
+
required: false,
|
|
63
|
+
}),
|
|
64
|
+
location_type: pieces_framework_1.Property.StaticDropdown({
|
|
65
|
+
displayName: 'Location Type',
|
|
66
|
+
description: 'How the location above is measured.',
|
|
67
|
+
required: false,
|
|
68
|
+
options: {
|
|
69
|
+
options: [
|
|
70
|
+
{ label: 'Page', value: 'page' },
|
|
71
|
+
{ label: 'Location', value: 'location' },
|
|
72
|
+
{ label: 'Order', value: 'order' },
|
|
73
|
+
{ label: 'Offset', value: 'offset' },
|
|
74
|
+
{ label: 'Time Offset', value: 'time_offset' },
|
|
75
|
+
{ label: 'None', value: 'none' },
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
image_url: pieces_framework_1.Property.ShortText({
|
|
80
|
+
displayName: 'Image URL',
|
|
81
|
+
description: 'Cover image for the source.',
|
|
82
|
+
required: false,
|
|
83
|
+
}),
|
|
84
|
+
highlight_url: pieces_framework_1.Property.ShortText({
|
|
85
|
+
displayName: 'Highlight URL',
|
|
86
|
+
description: 'A unique URL that links directly to this highlight.',
|
|
87
|
+
required: false,
|
|
88
|
+
}),
|
|
89
|
+
highlighted_at: pieces_framework_1.Property.DateTime({
|
|
90
|
+
displayName: 'Highlighted At',
|
|
91
|
+
description: 'Date when the highlight was made (defaults to now).',
|
|
92
|
+
required: false,
|
|
93
|
+
}),
|
|
94
|
+
},
|
|
95
|
+
run(context) {
|
|
96
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const p = context.propsValue;
|
|
98
|
+
const highlight = { text: p.text };
|
|
99
|
+
if (p.title)
|
|
100
|
+
highlight['title'] = p.title;
|
|
101
|
+
if (p.author)
|
|
102
|
+
highlight['author'] = p.author;
|
|
103
|
+
if (p.source_url)
|
|
104
|
+
highlight['source_url'] = p.source_url;
|
|
105
|
+
if (p.source_type)
|
|
106
|
+
highlight['source_type'] = p.source_type;
|
|
107
|
+
if (p.category)
|
|
108
|
+
highlight['category'] = p.category;
|
|
109
|
+
if (p.note)
|
|
110
|
+
highlight['note'] = p.note;
|
|
111
|
+
if (p.location !== undefined && p.location !== null) {
|
|
112
|
+
highlight['location'] = p.location;
|
|
113
|
+
}
|
|
114
|
+
if (p.location_type)
|
|
115
|
+
highlight['location_type'] = p.location_type;
|
|
116
|
+
if (p.image_url)
|
|
117
|
+
highlight['image_url'] = p.image_url;
|
|
118
|
+
if (p.highlight_url)
|
|
119
|
+
highlight['highlight_url'] = p.highlight_url;
|
|
120
|
+
if (p.highlighted_at) {
|
|
121
|
+
highlight['highlighted_at'] = new Date(p.highlighted_at).toISOString();
|
|
122
|
+
}
|
|
123
|
+
return (0, client_1.makeReadwiseRequest)({
|
|
124
|
+
token: context.auth,
|
|
125
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
126
|
+
endpoint: '/highlights/',
|
|
127
|
+
body: { highlights: [highlight] },
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
//# sourceMappingURL=create-highlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-highlight.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/readwise/src/lib/actions/create-highlight.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,4DAAsD;AACtD,yCAA8C;AAC9C,6CAA8E;AAEjE,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,mCAAmC;IAChD,IAAI,EAAE,mBAAY;IAClB,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACtB,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,2CAA2C;YACxD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,wCAAwC;YACrD,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,uBAAuB;YACpC,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,gCAAgC;YAC7C,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC9B,WAAW,EAAE,aAAa;YAC1B,WAAW,EACT,2EAA2E;YAC7E,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAChC,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,iBAAiB;YAC9B,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,UAAU;YACxB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,UAAU,E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AC,WAAW,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC;YACtD,IAAI,CAAC,CAAC,aAAa;gBAAE,SAAS,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC;YAClE,IAAI,CAAC,CAAC,cAAc,EAAE,CAAC;gBACrB,SAAS,CAAC,gBAAgB,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,WAAW,EAAE,CAAC;YACzE,CAAC;YACD,OAAO,IAAA,4BAAmB,EAA0B;gBAClD,KAAK,EAAE,OAAO,CAAC,IAAc;gBAC7B,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,QAAQ,EAAE,cAAc;gBACxB,IAAI,EAAE,EAAE,UAAU,EAAE,CAAC,SAAS,CAAC,EAAE;aAClC,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const getHighlights: import("@taskmagic/pieces-framework").IAction<import("@taskmagic/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
book_id: import("@taskmagic/pieces-framework").DropdownProperty<string, false> | import("@taskmagic/pieces-framework").DropdownProperty<string, true>;
|
|
3
|
+
updated_after: import("@taskmagic/pieces-framework").DateTimeProperty<false>;
|
|
4
|
+
page_size: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
5
|
+
page: import("@taskmagic/pieces-framework").NumberProperty<false>;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHighlights = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const auth_1 = require("../common/auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
const props_1 = require("../common/props");
|
|
10
|
+
exports.getHighlights = (0, pieces_framework_1.createAction)({
|
|
11
|
+
name: 'get_highlights',
|
|
12
|
+
displayName: 'Get Highlights',
|
|
13
|
+
description: 'Retrieve your Readwise highlights, optionally filtered by book or date.',
|
|
14
|
+
auth: auth_1.readwiseAuth,
|
|
15
|
+
props: {
|
|
16
|
+
book_id: props_1.readwiseProps.bookId({ required: false }),
|
|
17
|
+
updated_after: pieces_framework_1.Property.DateTime({
|
|
18
|
+
displayName: 'Updated After',
|
|
19
|
+
description: 'Return only highlights updated after this date.',
|
|
20
|
+
required: false,
|
|
21
|
+
}),
|
|
22
|
+
page_size: pieces_framework_1.Property.Number({
|
|
23
|
+
displayName: 'Page Size',
|
|
24
|
+
description: 'Number of highlights to return per page (max 1000).',
|
|
25
|
+
required: false,
|
|
26
|
+
defaultValue: 100,
|
|
27
|
+
}),
|
|
28
|
+
page: pieces_framework_1.Property.Number({
|
|
29
|
+
displayName: 'Page',
|
|
30
|
+
description: 'Which page of results to return (starts at 1).',
|
|
31
|
+
required: false,
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
run(context) {
|
|
35
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const token = context.auth;
|
|
37
|
+
const { book_id, updated_after, page_size, page } = context.propsValue;
|
|
38
|
+
const params = {
|
|
39
|
+
page_size: String(page_size !== null && page_size !== void 0 ? page_size : 100),
|
|
40
|
+
};
|
|
41
|
+
if (book_id) {
|
|
42
|
+
params['book_id'] = book_id;
|
|
43
|
+
}
|
|
44
|
+
if (updated_after) {
|
|
45
|
+
params['updated__gt'] = new Date(updated_after).toISOString();
|
|
46
|
+
}
|
|
47
|
+
if (page) {
|
|
48
|
+
params['page'] = String(page);
|
|
49
|
+
}
|
|
50
|
+
return (0, client_1.makeReadwiseRequest)({
|
|
51
|
+
token,
|
|
52
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
53
|
+
endpoint: '/highlights/',
|
|
54
|
+
params,
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=get-highlights.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-highlights.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/readwise/src/lib/actions/get-highlights.ts"],"names":[],"mappings":";;;;AAAA,kEAAqE;AACrE,4DAAsD;AACtD,yCAA8C;AAC9C,6CAI0B;AAC1B,2CAAgD;AAEnC,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACxC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EACT,yEAAyE;IAC3E,IAAI,EAAE,mBAAY;IAClB,KAAK,EAAE;QACL,OAAO,EAAE,qBAAa,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAClD,aAAa,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC/B,WAAW,EAAE,eAAe;YAC5B,WAAW,EAAE,iDAAiD;YAC9D,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACzB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,qDAAqD;YAClE,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,GAAG;SAClB,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,gDAAgD;YAC7D,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,KAAK,GAAG,OAAO,CAAC,IAAc,CAAC;YACrC,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YACvE,MAAM,MAAM,GAA2B;gBACrC,SAAS,EAAE,MAAM,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,GAAG,CAAC;aACpC,CAAC;YACF,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;YAC9B,CAAC;YACD,IAAI,aAAa,EAAE,CAAC;gBAClB,MAAM,CAAC,aAAa,CAAC,GAAG,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,CAAC;YAChE,CAAC;YACD,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YAChC,CAAC;YACD,OAAO,IAAA,4BAAmB,EAA+C;gBACvE,KAAK;gBACL,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,QAAQ,EAAE,cAAc;gBACxB,MAAM;aACP,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const readwiseAuth: import("@taskmagic/pieces-framework").SecretTextProperty<true>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readwiseAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const client_1 = require("./client");
|
|
8
|
+
exports.readwiseAuth = pieces_framework_1.PieceAuth.SecretText({
|
|
9
|
+
displayName: 'Access Token',
|
|
10
|
+
description: 'Your Readwise access token. Get it at https://readwise.io/access_token',
|
|
11
|
+
required: true,
|
|
12
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
13
|
+
try {
|
|
14
|
+
yield (0, client_1.makeReadwiseRequest)({
|
|
15
|
+
token: auth,
|
|
16
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
17
|
+
endpoint: '/auth/',
|
|
18
|
+
});
|
|
19
|
+
return { valid: true };
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
return { valid: false, error: 'Invalid Readwise access token.' };
|
|
23
|
+
}
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/readwise/src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,kEAAwD;AACxD,4DAAsD;AACtD,qCAA+C;AAElC,QAAA,YAAY,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC/C,WAAW,EAAE,cAAc;IAC3B,WAAW,EACT,wEAAwE;IAC1E,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,CAAC;YACH,MAAM,IAAA,4BAAmB,EAAC;gBACxB,KAAK,EAAE,IAAc;gBACrB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,QAAQ,EAAE,QAAQ;aACnB,CAAC,CAAC;YACH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,gCAAgC,EAAE,CAAC;QACnE,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { HttpMethod } from '@taskmagic/pieces-common';
|
|
2
|
+
export declare const READWISE_BASE_URL = "https://readwise.io/api/v2";
|
|
3
|
+
export interface ReadwiseRequestParams {
|
|
4
|
+
token: string;
|
|
5
|
+
method: HttpMethod;
|
|
6
|
+
endpoint: string;
|
|
7
|
+
body?: object;
|
|
8
|
+
params?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export declare function makeReadwiseRequest<T>({ token, method, endpoint, body, params, }: ReadwiseRequestParams): Promise<T>;
|
|
11
|
+
export interface ReadwiseHighlight {
|
|
12
|
+
id: number;
|
|
13
|
+
text: string;
|
|
14
|
+
note: string;
|
|
15
|
+
location: number;
|
|
16
|
+
location_type: string;
|
|
17
|
+
color: string;
|
|
18
|
+
highlighted_at: string | null;
|
|
19
|
+
created_at: string;
|
|
20
|
+
updated: string;
|
|
21
|
+
external_id: string | null;
|
|
22
|
+
end_location: number | null;
|
|
23
|
+
url: string | null;
|
|
24
|
+
book_id: number;
|
|
25
|
+
tags: {
|
|
26
|
+
id: number;
|
|
27
|
+
name: string;
|
|
28
|
+
}[];
|
|
29
|
+
readwise_url: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ReadwiseBook {
|
|
32
|
+
id: number;
|
|
33
|
+
title: string;
|
|
34
|
+
author: string;
|
|
35
|
+
category: string;
|
|
36
|
+
source: string;
|
|
37
|
+
num_highlights: number;
|
|
38
|
+
last_highlight_at: string | null;
|
|
39
|
+
updated: string;
|
|
40
|
+
cover_image_url: string;
|
|
41
|
+
highlights_url: string;
|
|
42
|
+
source_url: string | null;
|
|
43
|
+
asin: string | null;
|
|
44
|
+
tags: {
|
|
45
|
+
id: number;
|
|
46
|
+
name: string;
|
|
47
|
+
}[];
|
|
48
|
+
document_note: string;
|
|
49
|
+
}
|
|
50
|
+
export interface ReadwiseCreatedSource {
|
|
51
|
+
id: number;
|
|
52
|
+
title: string;
|
|
53
|
+
author: string;
|
|
54
|
+
category: string;
|
|
55
|
+
source: string;
|
|
56
|
+
num_highlights: number;
|
|
57
|
+
last_highlight_at: string | null;
|
|
58
|
+
updated: string;
|
|
59
|
+
cover_image_url: string;
|
|
60
|
+
highlights_url: string;
|
|
61
|
+
source_url: string | null;
|
|
62
|
+
asin: string | null;
|
|
63
|
+
tags: {
|
|
64
|
+
id: number;
|
|
65
|
+
name: string;
|
|
66
|
+
}[];
|
|
67
|
+
document_note: string;
|
|
68
|
+
modified_highlights: number[];
|
|
69
|
+
}
|
|
70
|
+
export interface ReadwisePaginatedResponse<T> {
|
|
71
|
+
count: number;
|
|
72
|
+
next: string | null;
|
|
73
|
+
previous: string | null;
|
|
74
|
+
results: T[];
|
|
75
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.READWISE_BASE_URL = void 0;
|
|
4
|
+
exports.makeReadwiseRequest = makeReadwiseRequest;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
exports.READWISE_BASE_URL = 'https://readwise.io/api/v2';
|
|
8
|
+
function makeReadwiseRequest(_a) {
|
|
9
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ token, method, endpoint, body, params, }) {
|
|
10
|
+
const url = new URL(`${exports.READWISE_BASE_URL}${endpoint}`);
|
|
11
|
+
if (params) {
|
|
12
|
+
Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));
|
|
13
|
+
}
|
|
14
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
15
|
+
method,
|
|
16
|
+
url: url.toString(),
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `Token ${token}`,
|
|
19
|
+
'Content-Type': 'application/json',
|
|
20
|
+
},
|
|
21
|
+
body,
|
|
22
|
+
});
|
|
23
|
+
return response.body;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/readwise/src/lib/common/client.ts"],"names":[],"mappings":";;;AAYA,kDAqBC;;AAjCD,4DAAkE;AAErD,QAAA,iBAAiB,GAAG,4BAA4B,CAAC;AAU9D,SAAsB,mBAAmB;iEAAI,EAC3C,KAAK,EACL,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,MAAM,GACgB;QACtB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,yBAAiB,GAAG,QAAQ,EAAE,CAAC,CAAC;QACvD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACzE,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAI;YAC/C,MAAM;YACN,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE;YACnB,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS,KAAK,EAAE;gBAC/B,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI;SACL,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readwiseProps = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
7
|
+
const client_1 = require("./client");
|
|
8
|
+
const bookId = ({ required = false } = {}) => pieces_framework_1.Property.Dropdown({
|
|
9
|
+
displayName: 'Book',
|
|
10
|
+
description: 'The book or article to filter highlights by.',
|
|
11
|
+
required,
|
|
12
|
+
refreshers: [],
|
|
13
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
14
|
+
if (!auth) {
|
|
15
|
+
return {
|
|
16
|
+
disabled: true,
|
|
17
|
+
options: [],
|
|
18
|
+
placeholder: 'Please connect your Readwise account first.',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const response = yield (0, client_1.makeReadwiseRequest)({
|
|
23
|
+
token: auth,
|
|
24
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
25
|
+
endpoint: '/books/',
|
|
26
|
+
params: { page_size: '1000' },
|
|
27
|
+
});
|
|
28
|
+
if (response.results.length === 0) {
|
|
29
|
+
return {
|
|
30
|
+
disabled: false,
|
|
31
|
+
options: [],
|
|
32
|
+
placeholder: 'No books found in your Readwise library.',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
disabled: false,
|
|
37
|
+
options: response.results.map((book) => ({
|
|
38
|
+
label: book.author ? `${book.title} — ${book.author}` : book.title,
|
|
39
|
+
value: String(book.id),
|
|
40
|
+
})),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
return {
|
|
45
|
+
disabled: true,
|
|
46
|
+
options: [],
|
|
47
|
+
placeholder: 'Could not load books. Check your connection.',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}),
|
|
51
|
+
});
|
|
52
|
+
exports.readwiseProps = {
|
|
53
|
+
bookId,
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/readwise/src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,4DAAsD;AACtD,kEAAuD;AACvD,qCAIkB;AAElB,MAAM,MAAM,GAAG,CAAC,EAAE,QAAQ,GAAG,KAAK,KAA6B,EAAE,EAAE,EAAE,CACnE,2BAAQ,CAAC,QAAQ,CAAC;IAChB,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,8CAA8C;IAC3D,QAAQ;IACR,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,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,6CAA6C;aAC3D,CAAC;QACJ,CAAC;QACD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAmB,EAExC;gBACA,KAAK,EAAE,IAAc;gBACrB,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,QAAQ,EAAE,SAAS;gBACnB,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;aAC9B,CAAC,CAAC;YACH,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAClC,OAAO;oBACL,QAAQ,EAAE,KAAK;oBACf,OAAO,EAAE,EAAE;oBACX,WAAW,EAAE,0CAA0C;iBACxD,CAAC;YACJ,CAAC;YACD,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;oBACvC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK;oBAClE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;iBACvB,CAAC,CAAC;aACJ,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,8CAA8C;aAC5D,CAAC;QACJ,CAAC;IACH,CAAC,CAAA;CACF,CAAC,CAAC;AAEQ,QAAA,aAAa,GAAG;IAC3B,MAAM;CACP,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@taskmagic/pieces-framework';
|
|
2
|
+
export declare const newHighlight: import("@taskmagic/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@taskmagic/pieces-framework").SecretTextProperty<true>, {}> | import("@taskmagic/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@taskmagic/pieces-framework").SecretTextProperty<true>, {}> | import("@taskmagic/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@taskmagic/pieces-framework").SecretTextProperty<true>, {}>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newHighlight = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@taskmagic/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@taskmagic/pieces-common");
|
|
7
|
+
const auth_1 = require("../common/auth");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
const polling = {
|
|
10
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
11
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, lastFetchEpochMS }) {
|
|
12
|
+
const params = { page_size: '1000' };
|
|
13
|
+
if (lastFetchEpochMS) {
|
|
14
|
+
params['updated__gt'] = new Date(lastFetchEpochMS).toISOString();
|
|
15
|
+
}
|
|
16
|
+
const response = yield (0, client_1.makeReadwiseRequest)({
|
|
17
|
+
token: auth,
|
|
18
|
+
method: pieces_common_1.HttpMethod.GET,
|
|
19
|
+
endpoint: '/highlights/',
|
|
20
|
+
params,
|
|
21
|
+
});
|
|
22
|
+
return response.results.map((highlight) => ({
|
|
23
|
+
epochMilliSeconds: new Date(highlight.created_at).getTime(),
|
|
24
|
+
data: highlight,
|
|
25
|
+
}));
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
exports.newHighlight = (0, pieces_framework_1.createTrigger)({
|
|
29
|
+
name: 'new_highlight',
|
|
30
|
+
displayName: 'New Highlight',
|
|
31
|
+
description: 'Fires when a new highlight is saved to Readwise.',
|
|
32
|
+
auth: auth_1.readwiseAuth,
|
|
33
|
+
props: {},
|
|
34
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
35
|
+
sampleData: {
|
|
36
|
+
id: 12345678,
|
|
37
|
+
text: 'The best investment you can make is in yourself.',
|
|
38
|
+
note: '',
|
|
39
|
+
location: 1,
|
|
40
|
+
location_type: 'order',
|
|
41
|
+
color: 'yellow',
|
|
42
|
+
highlighted_at: '2026-04-17T00:00:00.000Z',
|
|
43
|
+
created_at: '2026-04-17T00:00:00.000Z',
|
|
44
|
+
updated: '2026-04-17T00:00:00.000Z',
|
|
45
|
+
external_id: null,
|
|
46
|
+
end_location: null,
|
|
47
|
+
url: null,
|
|
48
|
+
book_id: 9876543,
|
|
49
|
+
tags: [],
|
|
50
|
+
readwise_url: 'https://readwise.io/open/12345678',
|
|
51
|
+
},
|
|
52
|
+
onEnable(context) {
|
|
53
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
55
|
+
store: context.store,
|
|
56
|
+
auth: context.auth,
|
|
57
|
+
propsValue: context.propsValue,
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
onDisable(context) {
|
|
62
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
64
|
+
store: context.store,
|
|
65
|
+
auth: context.auth,
|
|
66
|
+
propsValue: context.propsValue,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
test(context) {
|
|
71
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
return yield pieces_common_1.pollingHelper.test(polling, {
|
|
73
|
+
store: context.store,
|
|
74
|
+
auth: context.auth,
|
|
75
|
+
propsValue: context.propsValue,
|
|
76
|
+
files: context.files,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
run(context) {
|
|
81
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
return yield pieces_common_1.pollingHelper.poll(polling, {
|
|
83
|
+
store: context.store,
|
|
84
|
+
auth: context.auth,
|
|
85
|
+
propsValue: context.propsValue,
|
|
86
|
+
files: context.files,
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=new-highlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-highlight.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/readwise/src/lib/triggers/new-highlight.ts"],"names":[],"mappings":";;;;AAAA,kEAIqC;AACrC,4DAKkC;AAClC,yCAA8C;AAC9C,6CAI0B;AAE1B,MAAM,OAAO,GAGT;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAAmC,EAAE,oDAA9B,EAAE,IAAI,EAAE,gBAAgB,EAAE;QACtC,MAAM,MAAM,GAA2B,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;QAC7D,IAAI,gBAAgB,EAAE,CAAC;YACrB,MAAM,CAAC,aAAa,CAAC,GAAG,IAAI,IAAI,CAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC;QACnE,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,IAAA,4BAAmB,EAExC;YACA,KAAK,EAAE,IAAc;YACrB,MAAM,EAAE,0BAAU,CAAC,GAAG;YACtB,QAAQ,EAAE,cAAc;YACxB,MAAM;SACP,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YAC1C,iBAAiB,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE;YAC3D,IAAI,EAAE,SAAS;SAChB,CAAC,CAAC,CAAC;IACN,CAAC,CAAA;CACF,CAAC;AAEW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