n8n-nodes-substack 1.6.0 → 1.7.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/dist/credentials/SubstackApi.credentials.js +1 -1
- package/dist/credentials/SubstackApi.credentials.js.map +1 -1
- package/dist/nodes/Substack/Comment.fields.js +0 -14
- package/dist/nodes/Substack/Comment.fields.js.map +1 -1
- package/dist/nodes/Substack/Comment.operations.d.ts +1 -2
- package/dist/nodes/Substack/Comment.operations.js +2 -29
- package/dist/nodes/Substack/Comment.operations.js.map +1 -1
- package/dist/nodes/Substack/Note.fields.js +2 -57
- package/dist/nodes/Substack/Note.fields.js.map +1 -1
- package/dist/nodes/Substack/Note.operations.d.ts +0 -1
- package/dist/nodes/Substack/Note.operations.js +9 -107
- package/dist/nodes/Substack/Note.operations.js.map +1 -1
- package/dist/nodes/Substack/Post.fields.js +0 -30
- package/dist/nodes/Substack/Post.fields.js.map +1 -1
- package/dist/nodes/Substack/Post.operations.d.ts +0 -1
- package/dist/nodes/Substack/Post.operations.js +2 -32
- package/dist/nodes/Substack/Post.operations.js.map +1 -1
- package/dist/nodes/Substack/Profile.fields.js +0 -14
- package/dist/nodes/Substack/Profile.fields.js.map +1 -1
- package/dist/nodes/Substack/Profile.operations.d.ts +0 -1
- package/dist/nodes/Substack/Profile.operations.js +1 -30
- package/dist/nodes/Substack/Profile.operations.js.map +1 -1
- package/dist/nodes/Substack/SubstackUtils.d.ts +0 -8
- package/dist/nodes/Substack/SubstackUtils.js +0 -30
- package/dist/nodes/Substack/SubstackUtils.js.map +1 -1
- package/dist/nodes/Substack/shared/DataFormatters.js +17 -29
- package/dist/nodes/Substack/shared/DataFormatters.js.map +1 -1
- package/dist/nodes/Substack/types.d.ts +1 -15
- package/dist/package.json +5 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/dist/nodes/Substack/MarkdownParser.d.ts +0 -11
- package/dist/nodes/Substack/MarkdownParser.js +0 -228
- package/dist/nodes/Substack/MarkdownParser.js.map +0 -1
- package/dist/nodes/Substack/shared/ResourceOperations.d.ts +0 -25
- package/dist/nodes/Substack/shared/ResourceOperations.js +0 -59
- package/dist/nodes/Substack/shared/ResourceOperations.js.map +0 -1
|
@@ -8,7 +8,6 @@ var ProfileOperation;
|
|
|
8
8
|
(function (ProfileOperation) {
|
|
9
9
|
ProfileOperation["GetOwnProfile"] = "getOwnProfile";
|
|
10
10
|
ProfileOperation["GetProfileBySlug"] = "getProfileBySlug";
|
|
11
|
-
ProfileOperation["GetProfileById"] = "getProfileById";
|
|
12
11
|
ProfileOperation["GetFollowees"] = "getFollowees";
|
|
13
12
|
})(ProfileOperation || (exports.ProfileOperation = ProfileOperation = {}));
|
|
14
13
|
exports.profileOperations = [
|
|
@@ -36,12 +35,6 @@ exports.profileOperations = [
|
|
|
36
35
|
description: 'Get a profile by its publication slug',
|
|
37
36
|
action: 'Get profile by slug',
|
|
38
37
|
},
|
|
39
|
-
{
|
|
40
|
-
name: 'Get Profile by ID',
|
|
41
|
-
value: ProfileOperation.GetProfileById,
|
|
42
|
-
description: 'Get a profile by its user ID',
|
|
43
|
-
action: 'Get profile by ID',
|
|
44
|
-
},
|
|
45
38
|
{
|
|
46
39
|
name: 'Get Followees',
|
|
47
40
|
value: ProfileOperation.GetFollowees,
|
|
@@ -92,34 +85,13 @@ async function getProfileBySlug(executeFunctions, client, publicationAddress, it
|
|
|
92
85
|
});
|
|
93
86
|
}
|
|
94
87
|
}
|
|
95
|
-
async function getProfileById(executeFunctions, client, publicationAddress, itemIndex) {
|
|
96
|
-
try {
|
|
97
|
-
const userId = OperationUtils_1.OperationUtils.parseNumericParam(executeFunctions.getNodeParameter('userId', itemIndex), 'userId');
|
|
98
|
-
const profile = await client.profileForId(userId);
|
|
99
|
-
const profileData = DataFormatters_1.DataFormatters.formatProfile(profile);
|
|
100
|
-
return {
|
|
101
|
-
success: true,
|
|
102
|
-
data: profileData,
|
|
103
|
-
metadata: {
|
|
104
|
-
status: 'success',
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
109
|
-
return SubstackUtils_1.SubstackUtils.formatErrorResponse({
|
|
110
|
-
message: error.message,
|
|
111
|
-
node: executeFunctions.getNode(),
|
|
112
|
-
itemIndex,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
88
|
async function getFollowees(executeFunctions, client, publicationAddress, itemIndex) {
|
|
117
89
|
try {
|
|
118
90
|
const returnType = executeFunctions.getNodeParameter('returnType', itemIndex, 'profiles');
|
|
119
91
|
const limitParam = executeFunctions.getNodeParameter('limit', itemIndex, '');
|
|
120
92
|
const limit = OperationUtils_1.OperationUtils.parseLimit(limitParam);
|
|
121
93
|
const ownProfile = await client.ownProfile();
|
|
122
|
-
const followingIterable =
|
|
94
|
+
const followingIterable = ownProfile.following();
|
|
123
95
|
const results = await OperationUtils_1.OperationUtils.executeAsyncIterable(followingIterable, limit, (followee) => DataFormatters_1.DataFormatters.formatFollowing(followee, returnType));
|
|
124
96
|
return {
|
|
125
97
|
success: true,
|
|
@@ -140,7 +112,6 @@ async function getFollowees(executeFunctions, client, publicationAddress, itemIn
|
|
|
140
112
|
exports.profileOperationHandlers = {
|
|
141
113
|
[ProfileOperation.GetOwnProfile]: getOwnProfile,
|
|
142
114
|
[ProfileOperation.GetProfileBySlug]: getProfileBySlug,
|
|
143
|
-
[ProfileOperation.GetProfileById]: getProfileById,
|
|
144
115
|
[ProfileOperation.GetFollowees]: getFollowees,
|
|
145
116
|
};
|
|
146
117
|
//# sourceMappingURL=Profile.operations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Profile.operations.js","sourceRoot":"","sources":["../../../nodes/Substack/Profile.operations.ts"],"names":[],"mappings":";;;AAGA,mDAAgD;AAChD,4DAAyD;AACzD,4DAAyD;AAEzD,IAAY,
|
|
1
|
+
{"version":3,"file":"Profile.operations.js","sourceRoot":"","sources":["../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,CAAC,UAAU,CAAC,CAAC;QAEpD,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;QAC7C,MAAM,iBAAiB,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;QACjD,MAAM,OAAO,GAAG,MAAM,+BAAc,CAAC,oBAAoB,CACxD,iBAAiB,EACjB,KAAK,EACL,CAAC,QAAa,EAAE,EAAE,CAAC,+BAAc,CAAC,eAAe,CAAC,QAAQ,EAAE,UAAU,CAAC,CACvE,CAAC;QAEF,OAAO;YACN,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE;gBACT,MAAM,EAAE,SAAS;aACjB;SACD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,6BAAa,CAAC,mBAAmB,CAAC;YACxC,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE;YAChC,SAAS;SACT,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAEY,QAAA,wBAAwB,GAQjC;IACH,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,aAAa;IAC/C,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,EAAE,gBAAgB;IACrD,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE,YAAY;CAC7C,CAAC"}
|
|
@@ -2,8 +2,6 @@ import { IExecuteFunctions } from 'n8n-workflow';
|
|
|
2
2
|
import { SubstackClient } from 'substack-api';
|
|
3
3
|
import { IErrorResponse, IStandardResponse } from './types';
|
|
4
4
|
export declare class SubstackUtils {
|
|
5
|
-
private static readonly DEFAULT_CACHE_TTL;
|
|
6
|
-
private static clientCache;
|
|
7
5
|
static initializeClient(executeFunctions: IExecuteFunctions): Promise<{
|
|
8
6
|
client: SubstackClient;
|
|
9
7
|
publicationAddress: string;
|
|
@@ -11,10 +9,4 @@ export declare class SubstackUtils {
|
|
|
11
9
|
static formatUrl(publicationAddress: string, path: string): string;
|
|
12
10
|
static formatErrorResponse({ message, node, itemIndex }: IErrorResponse): IStandardResponse;
|
|
13
11
|
private static extractHostname;
|
|
14
|
-
private static isCacheValid;
|
|
15
|
-
static clearExpiredCache(): void;
|
|
16
|
-
static getCacheStats(): {
|
|
17
|
-
size: number;
|
|
18
|
-
entries: string[];
|
|
19
|
-
};
|
|
20
12
|
}
|
|
@@ -11,22 +11,10 @@ class SubstackUtils {
|
|
|
11
11
|
throw new n8n_workflow_1.NodeOperationError(executeFunctions.getNode(), 'API key is required');
|
|
12
12
|
}
|
|
13
13
|
const hostname = this.extractHostname(publicationAddress, executeFunctions);
|
|
14
|
-
const cacheKey = `${hostname}:${apiKey}`;
|
|
15
|
-
const cached = this.clientCache.get(cacheKey);
|
|
16
|
-
if (cached && this.isCacheValid(cached.timestamp)) {
|
|
17
|
-
return {
|
|
18
|
-
client: cached.client,
|
|
19
|
-
publicationAddress: publicationAddress,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
14
|
const client = new substack_api_1.SubstackClient({
|
|
23
15
|
publicationUrl: hostname,
|
|
24
16
|
token: apiKey,
|
|
25
17
|
});
|
|
26
|
-
this.clientCache.set(cacheKey, {
|
|
27
|
-
client,
|
|
28
|
-
timestamp: Date.now(),
|
|
29
|
-
});
|
|
30
18
|
return {
|
|
31
19
|
client,
|
|
32
20
|
publicationAddress: publicationAddress,
|
|
@@ -65,24 +53,6 @@ class SubstackUtils {
|
|
|
65
53
|
throw new n8n_workflow_1.NodeOperationError(executeFunctions.getNode(), `Invalid publication URL provided: ${url}`);
|
|
66
54
|
}
|
|
67
55
|
}
|
|
68
|
-
static isCacheValid(timestamp) {
|
|
69
|
-
return Date.now() - timestamp < this.DEFAULT_CACHE_TTL;
|
|
70
|
-
}
|
|
71
|
-
static clearExpiredCache() {
|
|
72
|
-
for (const [key, cached] of this.clientCache.entries()) {
|
|
73
|
-
if (!this.isCacheValid(cached.timestamp)) {
|
|
74
|
-
this.clientCache.delete(key);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
static getCacheStats() {
|
|
79
|
-
return {
|
|
80
|
-
size: this.clientCache.size,
|
|
81
|
-
entries: Array.from(this.clientCache.keys()),
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
56
|
}
|
|
85
57
|
exports.SubstackUtils = SubstackUtils;
|
|
86
|
-
SubstackUtils.DEFAULT_CACHE_TTL = 5 * 60 * 1000;
|
|
87
|
-
SubstackUtils.clientCache = new Map();
|
|
88
58
|
//# sourceMappingURL=SubstackUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubstackUtils.js","sourceRoot":"","sources":["../../../nodes/Substack/SubstackUtils.ts"],"names":[],"mappings":";;;AAAA,+CAAqE;AACrE,+CAA8C;
|
|
1
|
+
{"version":3,"file":"SubstackUtils.js","sourceRoot":"","sources":["../../../nodes/Substack/SubstackUtils.ts"],"names":[],"mappings":";;;AAAA,+CAAqE;AACrE,+CAA8C;AAG9C,MAAa,aAAa;IACzB,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,gBAAmC;QAChE,MAAM,WAAW,GAAG,MAAM,gBAAgB,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QACzE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC;QAEnD,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,MAAM,IAAI,iCAAkB,CAAC,gBAAgB,CAAC,OAAO,EAAE,EAAE,qBAAqB,CAAC,CAAC;QACjF,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,kBAA4B,EAAE,gBAAgB,CAAC,CAAC;QAEtF,MAAM,MAAM,GAAG,IAAI,6BAAc,CAAC;YACjC,cAAc,EAAE,QAAQ;YACxB,KAAK,EAAE,MAAgB;SACvB,CAAC,CAAC;QAEH,OAAO;YACN,MAAM;YACN,kBAAkB,EAAE,kBAA4B;SAChD,CAAC;IACH,C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;YAED,OAAO,QAAQ,CAAC;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,iCAAkB,CAC3B,gBAAgB,CAAC,OAAO,EAAE,EAC1B,qCAAqC,GAAG,EAAE,CAC1C,CAAC;QACH,CAAC;IACF,CAAC;CAED;AArED,sCAqEC"}
|
|
@@ -8,59 +8,50 @@ const SubstackUtils_1 = require("../SubstackUtils");
|
|
|
8
8
|
const turndown_1 = __importDefault(require("turndown"));
|
|
9
9
|
class DataFormatters {
|
|
10
10
|
static formatNote(note, publicationAddress) {
|
|
11
|
-
var _a, _b, _c
|
|
11
|
+
var _a, _b, _c;
|
|
12
12
|
return {
|
|
13
|
-
noteId: ((
|
|
13
|
+
noteId: ((_a = note.id) === null || _a === void 0 ? void 0 : _a.toString()) || 'unknown',
|
|
14
14
|
body: note.body || '',
|
|
15
|
-
url: SubstackUtils_1.SubstackUtils.formatUrl(publicationAddress, `/p/${
|
|
16
|
-
date: DataFormatters.formatDate(
|
|
15
|
+
url: SubstackUtils_1.SubstackUtils.formatUrl(publicationAddress, `/p/${note.id || 'unknown'}`),
|
|
16
|
+
date: DataFormatters.formatDate(note.publishedAt || new Date()),
|
|
17
17
|
status: 'published',
|
|
18
|
-
userId: ((
|
|
18
|
+
userId: ((_c = (_b = note.author) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.toString()) || 'unknown',
|
|
19
19
|
likes: note.likesCount || 0,
|
|
20
|
-
restacks: ((_m = (_l = note.rawData) === null || _l === void 0 ? void 0 : _l.comment) === null || _m === void 0 ? void 0 : _m.restacks) || 0,
|
|
21
20
|
type: 'note',
|
|
22
|
-
entityKey: ((_o = note.rawData) === null || _o === void 0 ? void 0 : _o.entity_key) || note.id,
|
|
23
21
|
};
|
|
24
22
|
}
|
|
25
23
|
static formatPost(post, publicationAddress) {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
27
24
|
const htmlBody = post.htmlBody || '';
|
|
28
25
|
const turndownService = new turndown_1.default();
|
|
29
26
|
const markdown = htmlBody ? turndownService.turndown(htmlBody) : '';
|
|
30
27
|
return {
|
|
31
28
|
id: post.id,
|
|
32
29
|
title: post.title || '',
|
|
33
|
-
subtitle:
|
|
34
|
-
slug:
|
|
35
|
-
url: SubstackUtils_1.SubstackUtils.formatUrl(publicationAddress, `/p/${
|
|
36
|
-
postDate: DataFormatters.formatDate(
|
|
37
|
-
type:
|
|
38
|
-
published:
|
|
39
|
-
paywalled:
|
|
40
|
-
description:
|
|
30
|
+
subtitle: post.subtitle || '',
|
|
31
|
+
slug: post.slug,
|
|
32
|
+
url: post.url || SubstackUtils_1.SubstackUtils.formatUrl(publicationAddress, `/p/${post.slug || post.id}`),
|
|
33
|
+
postDate: DataFormatters.formatDate(post.publishedAt || new Date()),
|
|
34
|
+
type: 'newsletter',
|
|
35
|
+
published: true,
|
|
36
|
+
paywalled: false,
|
|
37
|
+
description: post.truncatedBody || post.body || '',
|
|
41
38
|
htmlBody: htmlBody,
|
|
42
39
|
markdown: markdown,
|
|
43
40
|
};
|
|
44
41
|
}
|
|
45
42
|
static formatComment(comment, parentPostId) {
|
|
46
|
-
var _a, _b;
|
|
47
43
|
return {
|
|
48
44
|
id: comment.id,
|
|
49
45
|
body: comment.body,
|
|
50
|
-
|
|
51
|
-
parentPostId: parentPostId ||
|
|
52
|
-
author: {
|
|
53
|
-
id: comment.author.id,
|
|
54
|
-
name: comment.author.name,
|
|
55
|
-
isAdmin: comment.author.isAdmin || false,
|
|
56
|
-
},
|
|
46
|
+
isAdmin: comment.isAdmin || false,
|
|
47
|
+
parentPostId: parentPostId || 0,
|
|
57
48
|
};
|
|
58
49
|
}
|
|
59
50
|
static formatProfile(profile) {
|
|
60
51
|
return {
|
|
61
52
|
id: profile.id,
|
|
62
53
|
name: profile.name,
|
|
63
|
-
handle: profile.slug,
|
|
54
|
+
handle: profile.handle || profile.slug,
|
|
64
55
|
bio: profile.bio,
|
|
65
56
|
};
|
|
66
57
|
}
|
|
@@ -73,11 +64,8 @@ class DataFormatters {
|
|
|
73
64
|
return {
|
|
74
65
|
id: followee.id,
|
|
75
66
|
name: followee.name,
|
|
76
|
-
handle: followee.slug,
|
|
67
|
+
handle: followee.handle || followee.slug,
|
|
77
68
|
bio: followee.bio,
|
|
78
|
-
subscriberCount: 0,
|
|
79
|
-
subscriberCountString: '',
|
|
80
|
-
primaryPublication: undefined,
|
|
81
69
|
};
|
|
82
70
|
}
|
|
83
71
|
static formatDate(date) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataFormatters.js","sourceRoot":"","sources":["../../../../nodes/Substack/shared/DataFormatters.ts"],"names":[],"mappings":";;;;;;AACA,oDAAiD;AACjD,wDAAuC;AAEvC,MAAa,cAAc;IAI1B,MAAM,CAAC,UAAU,CAAC,IAAS,EAAE,kBAA0B;;QACtD,OAAO;YACN,MAAM,EAAE,CAAA,MAAA,
|
|
1
|
+
{"version":3,"file":"DataFormatters.js","sourceRoot":"","sources":["../../../../nodes/Substack/shared/DataFormatters.ts"],"names":[],"mappings":";;;;;;AACA,oDAAiD;AACjD,wDAAuC;AAEvC,MAAa,cAAc;IAI1B,MAAM,CAAC,UAAU,CAAC,IAAS,EAAE,kBAA0B;;QACtD,OAAO;YACN,MAAM,EAAE,CAAA,MAAA,IAAI,CAAC,EAAE,0CAAE,QAAQ,EAAE,KAAI,SAAS;YACxC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;YACrB,GAAG,EAAE,6BAAa,CAAC,SAAS,CAAC,kBAAkB,EAAE,MAAM,IAAI,CAAC,EAAE,IAAI,SAAS,EAAE,CAAC;YAC9E,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,IAAI,EAAE,CAAC;YAC/D,MAAM,EAAE,WAAW;YACnB,MAAM,EAAE,CAAA,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,EAAE,0CAAE,QA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E,YAAY,IAAI,CAAC;SAC/B,CAAC;IACH,CAAC;IAKD,MAAM,CAAC,aAAa,CAAC,OAAY;QAChC,OAAO;YACN,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI;YACtC,GAAG,EAAE,OAAO,CAAC,GAAG;SAChB,CAAC;IACH,CAAC;IAKD,MAAM,CAAC,eAAe,CAAC,QAAa,EAAE,UAAkB;QACvD,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO;gBACN,EAAE,EAAE,QAAQ,CAAC,EAAE;aACf,CAAC;QACH,CAAC;QAED,OAAO;YACN,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,MAAM,EAAE,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,IAAI;YACxC,GAAG,EAAE,QAAQ,CAAC,GAAG;SACjB,CAAC;IACH,CAAC;IAKD,MAAM,CAAC,UAAU,CAAC,IAAS;QAC1B,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;YAC9C,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACjC,CAAC;CACD;AA5FD,wCA4FC"}
|
|
@@ -17,9 +17,7 @@ export interface ISubstackNote {
|
|
|
17
17
|
status: string;
|
|
18
18
|
userId: string;
|
|
19
19
|
likes?: number;
|
|
20
|
-
restacks?: number;
|
|
21
20
|
type?: string;
|
|
22
|
-
entityKey?: string;
|
|
23
21
|
}
|
|
24
22
|
export interface ISubstackPost {
|
|
25
23
|
id: number;
|
|
@@ -38,26 +36,14 @@ export interface ISubstackPost {
|
|
|
38
36
|
export interface ISubstackComment {
|
|
39
37
|
id: number;
|
|
40
38
|
body: string;
|
|
41
|
-
|
|
39
|
+
isAdmin?: boolean;
|
|
42
40
|
parentPostId: number;
|
|
43
|
-
author: {
|
|
44
|
-
id: number;
|
|
45
|
-
name: string;
|
|
46
|
-
isAdmin?: boolean;
|
|
47
|
-
};
|
|
48
41
|
}
|
|
49
42
|
export interface ISubstackFollowing {
|
|
50
43
|
id: number;
|
|
51
44
|
name?: string;
|
|
52
45
|
handle?: string;
|
|
53
46
|
bio?: string;
|
|
54
|
-
subscriberCount?: number;
|
|
55
|
-
subscriberCountString?: string;
|
|
56
|
-
primaryPublication?: {
|
|
57
|
-
id: number;
|
|
58
|
-
name: string;
|
|
59
|
-
subdomain: string;
|
|
60
|
-
};
|
|
61
47
|
}
|
|
62
48
|
export interface IErrorResponse {
|
|
63
49
|
message: string;
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-substack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "n8n community node for Substack API integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"format": "prettier nodes credentials --write",
|
|
26
26
|
"lint": "eslint nodes credentials package.json",
|
|
27
27
|
"lintfix": "eslint nodes credentials package.json --fix",
|
|
28
|
-
"prepublishOnly": "pnpm run build &&
|
|
28
|
+
"prepublishOnly": "pnpm run build && eslint -c eslint.prepublish.config.js nodes credentials package.json",
|
|
29
29
|
"test": "jest",
|
|
30
30
|
"test:watch": "jest --watch",
|
|
31
31
|
"test:unit": "jest",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"@types/jest": "^30.0.0",
|
|
48
48
|
"@types/marked": "^4.3.2",
|
|
49
49
|
"@types/turndown": "^5.0.5",
|
|
50
|
-
"@typescript-eslint/parser": "~8.
|
|
51
|
-
"eslint": "
|
|
50
|
+
"@typescript-eslint/parser": "~8.56.0",
|
|
51
|
+
"eslint": ">=9.29.0 <10",
|
|
52
52
|
"eslint-plugin-n8n-nodes-base": "^1.16.3",
|
|
53
53
|
"gulp": "^5.0.0",
|
|
54
54
|
"jest": "^30.0.3",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"marked": "^4.3.0",
|
|
64
|
-
"substack-api": "^
|
|
64
|
+
"substack-api": "^3.1.0",
|
|
65
65
|
"turndown": "^7.2.0"
|
|
66
66
|
}
|
|
67
67
|
}
|