n8n-nodes-substack 0.6.0 → 0.7.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 +1 -1
- package/dist/nodes/Substack/Comment.fields.d.ts +2 -0
- package/dist/nodes/Substack/Comment.fields.js +50 -0
- package/dist/nodes/Substack/Comment.fields.js.map +1 -0
- package/dist/nodes/Substack/Comment.operations.d.ts +9 -0
- package/dist/nodes/Substack/Comment.operations.js +119 -0
- package/dist/nodes/Substack/Comment.operations.js.map +1 -0
- package/dist/nodes/Substack/Note.fields.d.ts +2 -0
- package/dist/nodes/Substack/Note.fields.js +96 -0
- package/dist/nodes/Substack/Note.fields.js.map +1 -0
- package/dist/nodes/Substack/Note.operations.d.ts +11 -0
- package/dist/nodes/Substack/Note.operations.js +244 -0
- package/dist/nodes/Substack/Note.operations.js.map +1 -0
- package/dist/nodes/Substack/Post.fields.d.ts +2 -0
- package/dist/nodes/Substack/Post.fields.js +96 -0
- package/dist/nodes/Substack/Post.fields.js.map +1 -0
- package/dist/nodes/Substack/Post.operations.d.ts +11 -0
- package/dist/nodes/Substack/Post.operations.js +248 -0
- package/dist/nodes/Substack/Post.operations.js.map +1 -0
- package/dist/nodes/Substack/Profile.fields.d.ts +2 -0
- package/dist/nodes/Substack/Profile.fields.js +75 -0
- package/dist/nodes/Substack/Profile.fields.js.map +1 -0
- package/dist/nodes/Substack/Profile.operations.d.ts +11 -0
- package/dist/nodes/Substack/Profile.operations.js +184 -0
- package/dist/nodes/Substack/Profile.operations.js.map +1 -0
- package/dist/nodes/Substack/Substack.node.d.ts +6 -0
- package/dist/nodes/Substack/Substack.node.js +46 -66
- package/dist/nodes/Substack/Substack.node.js.map +1 -1
- package/dist/nodes/Substack/Substack.node.json +22 -0
- package/dist/package.json +3 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -6
- package/dist/nodes/Substack/CommentOperations.d.ts +0 -6
- package/dist/nodes/Substack/CommentOperations.js +0 -53
- package/dist/nodes/Substack/CommentOperations.js.map +0 -1
- package/dist/nodes/Substack/FollowOperations.d.ts +0 -6
- package/dist/nodes/Substack/FollowOperations.js +0 -57
- package/dist/nodes/Substack/FollowOperations.js.map +0 -1
- package/dist/nodes/Substack/NoteOperations.d.ts +0 -7
- package/dist/nodes/Substack/NoteOperations.js +0 -90
- package/dist/nodes/Substack/NoteOperations.js.map +0 -1
- package/dist/nodes/Substack/PostOperations.d.ts +0 -6
- package/dist/nodes/Substack/PostOperations.js +0 -57
- package/dist/nodes/Substack/PostOperations.js.map +0 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postFields = void 0;
|
|
4
|
+
exports.postFields = [
|
|
5
|
+
{
|
|
6
|
+
displayName: 'Limit',
|
|
7
|
+
name: 'limit',
|
|
8
|
+
type: 'number',
|
|
9
|
+
default: 50,
|
|
10
|
+
description: 'Max number of results to return',
|
|
11
|
+
displayOptions: {
|
|
12
|
+
show: {
|
|
13
|
+
resource: ['post'],
|
|
14
|
+
operation: ['getAll'],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
typeOptions: {
|
|
18
|
+
minValue: 1,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
displayName: 'Slug',
|
|
23
|
+
name: 'slug',
|
|
24
|
+
type: 'string',
|
|
25
|
+
default: '',
|
|
26
|
+
description: 'The publication slug (subdomain)',
|
|
27
|
+
displayOptions: {
|
|
28
|
+
show: {
|
|
29
|
+
resource: ['post'],
|
|
30
|
+
operation: ['getPostsBySlug'],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
displayName: 'Limit',
|
|
37
|
+
name: 'limit',
|
|
38
|
+
type: 'number',
|
|
39
|
+
default: 50,
|
|
40
|
+
description: 'Max number of results to return',
|
|
41
|
+
displayOptions: {
|
|
42
|
+
show: {
|
|
43
|
+
resource: ['post'],
|
|
44
|
+
operation: ['getPostsBySlug'],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
typeOptions: {
|
|
48
|
+
minValue: 1,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
displayName: 'User ID',
|
|
53
|
+
name: 'userId',
|
|
54
|
+
type: 'number',
|
|
55
|
+
default: 0,
|
|
56
|
+
description: 'The user ID to get posts for',
|
|
57
|
+
displayOptions: {
|
|
58
|
+
show: {
|
|
59
|
+
resource: ['post'],
|
|
60
|
+
operation: ['getPostsById'],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
required: true,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
displayName: 'Limit',
|
|
67
|
+
name: 'limit',
|
|
68
|
+
type: 'number',
|
|
69
|
+
default: 50,
|
|
70
|
+
description: 'Max number of results to return',
|
|
71
|
+
displayOptions: {
|
|
72
|
+
show: {
|
|
73
|
+
resource: ['post'],
|
|
74
|
+
operation: ['getPostsById'],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
typeOptions: {
|
|
78
|
+
minValue: 1,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
displayName: 'Post ID',
|
|
83
|
+
name: 'postId',
|
|
84
|
+
type: 'string',
|
|
85
|
+
default: '',
|
|
86
|
+
description: 'The ID of the post to retrieve',
|
|
87
|
+
displayOptions: {
|
|
88
|
+
show: {
|
|
89
|
+
resource: ['post'],
|
|
90
|
+
operation: ['getPostById'],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
required: true,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
//# sourceMappingURL=Post.fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Post.fields.js","sourceRoot":"","sources":["../../../nodes/Substack/Post.fields.ts"],"names":[],"mapp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E,OAAO;QACb,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,iCAAiC;QAC9C,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,QAAQ,EAAE,CAAC,MAAM,CAAC;gBAClB,SAAS,EAAE,CAAC,cAAc,CAAC;aAC3B;SACD;QACD,WAAW,EAAE;YACZ,QAAQ,EAAE,CAAC;SACX;KACD;IAID;QACC,WAAW,EAAE,SAAS;QACtB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,gCAAgC;QAC7C,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,QAAQ,EAAE,CAAC,MAAM,CAAC;gBAClB,SAAS,EAAE,CAAC,aAAa,CAAC;aAC1B;SACD;QACD,QAAQ,EAAE,IAAI;KACd;CACD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
import { SubstackClient } from 'substack-api';
|
|
3
|
+
import { IStandardResponse } from './types';
|
|
4
|
+
export declare enum PostOperation {
|
|
5
|
+
GetAll = "getAll",
|
|
6
|
+
GetPostsBySlug = "getPostsBySlug",
|
|
7
|
+
GetPostsById = "getPostsById",
|
|
8
|
+
GetPostById = "getPostById"
|
|
9
|
+
}
|
|
10
|
+
export declare const postOperations: INodeProperties[];
|
|
11
|
+
export declare const postOperationHandlers: Record<PostOperation, (executeFunctions: IExecuteFunctions, client: SubstackClient, publicationAddress: string, itemIndex: number) => Promise<IStandardResponse>>;
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postOperationHandlers = exports.postOperations = exports.PostOperation = void 0;
|
|
4
|
+
const SubstackUtils_1 = require("./SubstackUtils");
|
|
5
|
+
var PostOperation;
|
|
6
|
+
(function (PostOperation) {
|
|
7
|
+
PostOperation["GetAll"] = "getAll";
|
|
8
|
+
PostOperation["GetPostsBySlug"] = "getPostsBySlug";
|
|
9
|
+
PostOperation["GetPostsById"] = "getPostsById";
|
|
10
|
+
PostOperation["GetPostById"] = "getPostById";
|
|
11
|
+
})(PostOperation || (exports.PostOperation = PostOperation = {}));
|
|
12
|
+
exports.postOperations = [
|
|
13
|
+
{
|
|
14
|
+
displayName: 'Operation',
|
|
15
|
+
name: 'operation',
|
|
16
|
+
type: 'options',
|
|
17
|
+
default: 'getAll',
|
|
18
|
+
noDataExpression: true,
|
|
19
|
+
displayOptions: {
|
|
20
|
+
show: {
|
|
21
|
+
resource: ['post'],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
options: [
|
|
25
|
+
{
|
|
26
|
+
name: 'Get All Posts',
|
|
27
|
+
value: PostOperation.GetAll,
|
|
28
|
+
description: 'Get all posts from own profile',
|
|
29
|
+
action: 'Get all posts',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'Get Posts From Profile by Slug',
|
|
33
|
+
value: PostOperation.GetPostsBySlug,
|
|
34
|
+
description: 'Get posts from a profile by its publication slug',
|
|
35
|
+
action: 'Get posts by slug',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'Get Posts From Profile by ID',
|
|
39
|
+
value: PostOperation.GetPostsById,
|
|
40
|
+
description: 'Get posts from a profile by its user ID',
|
|
41
|
+
action: 'Get posts by ID',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Get Post by ID',
|
|
45
|
+
value: PostOperation.GetPostById,
|
|
46
|
+
description: 'Get a specific post by its ID',
|
|
47
|
+
action: 'Get post by ID',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
async function getAll(executeFunctions, client, publicationAddress, itemIndex) {
|
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
54
|
+
try {
|
|
55
|
+
const limitParam = executeFunctions.getNodeParameter('limit', itemIndex, '');
|
|
56
|
+
let limit = 100;
|
|
57
|
+
if (limitParam !== '' && limitParam !== null && limitParam !== undefined) {
|
|
58
|
+
limit = Number(limitParam);
|
|
59
|
+
}
|
|
60
|
+
const ownProfile = await client.ownProfile();
|
|
61
|
+
const postsIterable = await ownProfile.posts();
|
|
62
|
+
const formattedPosts = [];
|
|
63
|
+
let count = 0;
|
|
64
|
+
for await (const post of postsIterable) {
|
|
65
|
+
if (count >= limit)
|
|
66
|
+
break;
|
|
67
|
+
try {
|
|
68
|
+
formattedPosts.push({
|
|
69
|
+
id: post.id,
|
|
70
|
+
title: post.title || '',
|
|
71
|
+
subtitle: ((_a = post.rawData) === null || _a === void 0 ? void 0 : _a.subtitle) || '',
|
|
72
|
+
url: SubstackUtils_1.SubstackUtils.formatUrl(publicationAddress, `/p/${post.id}`),
|
|
73
|
+
postDate: ((_b = post.rawData) === null || _b === void 0 ? void 0 : _b.post_date) ||
|
|
74
|
+
(post.publishedAt && !isNaN(post.publishedAt.getTime())
|
|
75
|
+
? post.publishedAt.toISOString()
|
|
76
|
+
: new Date().toISOString()),
|
|
77
|
+
type: ((_c = post.rawData) === null || _c === void 0 ? void 0 : _c.type) || 'newsletter',
|
|
78
|
+
published: (_e = (_d = post.rawData) === null || _d === void 0 ? void 0 : _d.published) !== null && _e !== void 0 ? _e : true,
|
|
79
|
+
paywalled: (_g = (_f = post.rawData) === null || _f === void 0 ? void 0 : _f.paywalled) !== null && _g !== void 0 ? _g : false,
|
|
80
|
+
description: ((_h = post.rawData) === null || _h === void 0 ? void 0 : _h.description) || post.body || '',
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
}
|
|
85
|
+
count++;
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
success: true,
|
|
89
|
+
data: formattedPosts,
|
|
90
|
+
metadata: {
|
|
91
|
+
status: 'success',
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
return SubstackUtils_1.SubstackUtils.formatErrorResponse({
|
|
97
|
+
message: error.message,
|
|
98
|
+
node: executeFunctions.getNode(),
|
|
99
|
+
itemIndex,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function getPostsBySlug(executeFunctions, client, publicationAddress, itemIndex) {
|
|
104
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
105
|
+
try {
|
|
106
|
+
const slug = executeFunctions.getNodeParameter('slug', itemIndex);
|
|
107
|
+
const limitParam = executeFunctions.getNodeParameter('limit', itemIndex, '');
|
|
108
|
+
let limit = 100;
|
|
109
|
+
if (limitParam !== '' && limitParam !== null && limitParam !== undefined) {
|
|
110
|
+
limit = Number(limitParam);
|
|
111
|
+
}
|
|
112
|
+
const profile = await client.profileForSlug(slug);
|
|
113
|
+
const postsIterable = await profile.posts();
|
|
114
|
+
const formattedPosts = [];
|
|
115
|
+
let count = 0;
|
|
116
|
+
for await (const post of postsIterable) {
|
|
117
|
+
if (count >= limit)
|
|
118
|
+
break;
|
|
119
|
+
try {
|
|
120
|
+
formattedPosts.push({
|
|
121
|
+
id: post.id,
|
|
122
|
+
title: post.title || '',
|
|
123
|
+
subtitle: ((_a = post.rawData) === null || _a === void 0 ? void 0 : _a.subtitle) || '',
|
|
124
|
+
url: SubstackUtils_1.SubstackUtils.formatUrl(publicationAddress, `/p/${post.id}`),
|
|
125
|
+
postDate: ((_b = post.rawData) === null || _b === void 0 ? void 0 : _b.post_date) ||
|
|
126
|
+
(post.publishedAt && !isNaN(post.publishedAt.getTime())
|
|
127
|
+
? post.publishedAt.toISOString()
|
|
128
|
+
: new Date().toISOString()),
|
|
129
|
+
type: ((_c = post.rawData) === null || _c === void 0 ? void 0 : _c.type) || 'newsletter',
|
|
130
|
+
published: (_e = (_d = post.rawData) === null || _d === void 0 ? void 0 : _d.published) !== null && _e !== void 0 ? _e : true,
|
|
131
|
+
paywalled: (_g = (_f = post.rawData) === null || _f === void 0 ? void 0 : _f.paywalled) !== null && _g !== void 0 ? _g : false,
|
|
132
|
+
description: ((_h = post.rawData) === null || _h === void 0 ? void 0 : _h.description) || post.body || '',
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
}
|
|
137
|
+
count++;
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
success: true,
|
|
141
|
+
data: formattedPosts,
|
|
142
|
+
metadata: {
|
|
143
|
+
status: 'success',
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
return SubstackUtils_1.SubstackUtils.formatErrorResponse({
|
|
149
|
+
message: error.message,
|
|
150
|
+
node: executeFunctions.getNode(),
|
|
151
|
+
itemIndex,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async function getPostsById(executeFunctions, client, publicationAddress, itemIndex) {
|
|
156
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
157
|
+
try {
|
|
158
|
+
const userId = executeFunctions.getNodeParameter('userId', itemIndex);
|
|
159
|
+
const limitParam = executeFunctions.getNodeParameter('limit', itemIndex, '');
|
|
160
|
+
let limit = 100;
|
|
161
|
+
if (limitParam !== '' && limitParam !== null && limitParam !== undefined) {
|
|
162
|
+
limit = Number(limitParam);
|
|
163
|
+
}
|
|
164
|
+
const profile = await client.profileForId(userId);
|
|
165
|
+
const postsIterable = await profile.posts();
|
|
166
|
+
const formattedPosts = [];
|
|
167
|
+
let count = 0;
|
|
168
|
+
for await (const post of postsIterable) {
|
|
169
|
+
if (count >= limit)
|
|
170
|
+
break;
|
|
171
|
+
try {
|
|
172
|
+
formattedPosts.push({
|
|
173
|
+
id: post.id,
|
|
174
|
+
title: post.title || '',
|
|
175
|
+
subtitle: ((_a = post.rawData) === null || _a === void 0 ? void 0 : _a.subtitle) || '',
|
|
176
|
+
url: SubstackUtils_1.SubstackUtils.formatUrl(publicationAddress, `/p/${post.id}`),
|
|
177
|
+
postDate: ((_b = post.rawData) === null || _b === void 0 ? void 0 : _b.post_date) ||
|
|
178
|
+
(post.publishedAt && !isNaN(post.publishedAt.getTime())
|
|
179
|
+
? post.publishedAt.toISOString()
|
|
180
|
+
: new Date().toISOString()),
|
|
181
|
+
type: ((_c = post.rawData) === null || _c === void 0 ? void 0 : _c.type) || 'newsletter',
|
|
182
|
+
published: (_e = (_d = post.rawData) === null || _d === void 0 ? void 0 : _d.published) !== null && _e !== void 0 ? _e : true,
|
|
183
|
+
paywalled: (_g = (_f = post.rawData) === null || _f === void 0 ? void 0 : _f.paywalled) !== null && _g !== void 0 ? _g : false,
|
|
184
|
+
description: ((_h = post.rawData) === null || _h === void 0 ? void 0 : _h.description) || post.body || '',
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
}
|
|
189
|
+
count++;
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
success: true,
|
|
193
|
+
data: formattedPosts,
|
|
194
|
+
metadata: {
|
|
195
|
+
status: 'success',
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
return SubstackUtils_1.SubstackUtils.formatErrorResponse({
|
|
201
|
+
message: error.message,
|
|
202
|
+
node: executeFunctions.getNode(),
|
|
203
|
+
itemIndex,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
async function getPostById(executeFunctions, client, publicationAddress, itemIndex) {
|
|
208
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
209
|
+
try {
|
|
210
|
+
const postId = executeFunctions.getNodeParameter('postId', itemIndex);
|
|
211
|
+
const post = await client.postForId(postId);
|
|
212
|
+
const formattedPost = {
|
|
213
|
+
id: post.id,
|
|
214
|
+
title: post.title || '',
|
|
215
|
+
subtitle: ((_a = post.rawData) === null || _a === void 0 ? void 0 : _a.subtitle) || '',
|
|
216
|
+
url: SubstackUtils_1.SubstackUtils.formatUrl(publicationAddress, `/p/${post.id}`),
|
|
217
|
+
postDate: ((_b = post.rawData) === null || _b === void 0 ? void 0 : _b.post_date) ||
|
|
218
|
+
(post.publishedAt && !isNaN(post.publishedAt.getTime())
|
|
219
|
+
? post.publishedAt.toISOString()
|
|
220
|
+
: new Date().toISOString()),
|
|
221
|
+
type: ((_c = post.rawData) === null || _c === void 0 ? void 0 : _c.type) || 'newsletter',
|
|
222
|
+
published: (_e = (_d = post.rawData) === null || _d === void 0 ? void 0 : _d.published) !== null && _e !== void 0 ? _e : true,
|
|
223
|
+
paywalled: (_g = (_f = post.rawData) === null || _f === void 0 ? void 0 : _f.paywalled) !== null && _g !== void 0 ? _g : false,
|
|
224
|
+
description: ((_h = post.rawData) === null || _h === void 0 ? void 0 : _h.description) || post.body || '',
|
|
225
|
+
};
|
|
226
|
+
return {
|
|
227
|
+
success: true,
|
|
228
|
+
data: formattedPost,
|
|
229
|
+
metadata: {
|
|
230
|
+
status: 'success',
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
return SubstackUtils_1.SubstackUtils.formatErrorResponse({
|
|
236
|
+
message: error.message,
|
|
237
|
+
node: executeFunctions.getNode(),
|
|
238
|
+
itemIndex,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
exports.postOperationHandlers = {
|
|
243
|
+
[PostOperation.GetAll]: getAll,
|
|
244
|
+
[PostOperation.GetPostsBySlug]: getPostsBySlug,
|
|
245
|
+
[PostOperation.GetPostsById]: getPostsById,
|
|
246
|
+
[PostOperation.GetPostById]: getPostById,
|
|
247
|
+
};
|
|
248
|
+
//# sourceMappingURL=Post.operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Post.operations.js","sourceRoot":"","sources":["../../../nodes/Substack/Post.operations.ts"],"names":[],"mappings":";;;AAGA,mDAAgD;AAEhD,IAAY,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O;YACtB,IAAI,EAAE,gBAAgB,CAAC,OAAO,EAAE;YAChC,SAAS;SACT,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAEY,QAAA,qBAAqB,GAQ9B;IACH,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM;IAC9B,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,cAAc;IAC9C,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,YAAY;IAC1C,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,WAAW;CACxC,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.profileFields = void 0;
|
|
4
|
+
exports.profileFields = [
|
|
5
|
+
{
|
|
6
|
+
displayName: 'Slug',
|
|
7
|
+
name: 'slug',
|
|
8
|
+
type: 'string',
|
|
9
|
+
default: '',
|
|
10
|
+
description: 'The publication slug (subdomain)',
|
|
11
|
+
displayOptions: {
|
|
12
|
+
show: {
|
|
13
|
+
resource: ['profile'],
|
|
14
|
+
operation: ['getProfileBySlug'],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
displayName: 'User ID',
|
|
21
|
+
name: 'userId',
|
|
22
|
+
type: 'number',
|
|
23
|
+
default: 0,
|
|
24
|
+
description: 'The user ID to get profile for',
|
|
25
|
+
displayOptions: {
|
|
26
|
+
show: {
|
|
27
|
+
resource: ['profile'],
|
|
28
|
+
operation: ['getProfileById'],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: true,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
displayName: 'Return Type',
|
|
35
|
+
name: 'returnType',
|
|
36
|
+
type: 'options',
|
|
37
|
+
options: [
|
|
38
|
+
{
|
|
39
|
+
name: 'Full Profiles',
|
|
40
|
+
value: 'profiles',
|
|
41
|
+
description: 'Return complete profile information',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'User IDs Only',
|
|
45
|
+
value: 'ids',
|
|
46
|
+
description: 'Return only user IDs',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
default: 'profiles',
|
|
50
|
+
description: 'Choose what information to return about the users you follow',
|
|
51
|
+
displayOptions: {
|
|
52
|
+
show: {
|
|
53
|
+
resource: ['profile'],
|
|
54
|
+
operation: ['getFollowees'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
displayName: 'Limit',
|
|
60
|
+
name: 'limit',
|
|
61
|
+
type: 'number',
|
|
62
|
+
default: 50,
|
|
63
|
+
description: 'Max number of results to return',
|
|
64
|
+
displayOptions: {
|
|
65
|
+
show: {
|
|
66
|
+
resource: ['profile'],
|
|
67
|
+
operation: ['getFollowees'],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
typeOptions: {
|
|
71
|
+
minValue: 1,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
//# sourceMappingURL=Profile.fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Profile.fields.js","sourceRoot":"","sources":["../../../nodes/Substack/Profile.fields.ts"],"names":[],"mappings":";;;AAEa,QAAA,aAAa,GAAsB;IAI/C;QACC,WAAW,EAAE,MAAM;QACnB,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,kCAAkC;QAC/C,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,QAAQ,EAAE,CAAC,SAAS,CAAC;gBACrB,SAAS,EAAE,CAAC,kBAAkB,CAAC;aAC/B;SACD;QACD,QAAQ,EAAE,IAAI;KACd;IAID;QACC,WAAW,EAAE,SAAS;QACtB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,CAAC;QACV,WAAW,EAAE,gCAAgC;QAC7C,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,QAAQ,EAAE,CAAC,SAAS,CAAC;gBACrB,SAAS,EAAE,CAAC,gBAAgB,CAAC;aAC7B;SACD;QACD,QAAQ,EAAE,IAAI;KACd;IAID;QACC,WAAW,EAAE,aAAa;QAC1B,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,eAAe;gBACrB,KAAK,EAAE,UAAU;gBACjB,WAAW,EAAE,qCAAqC;aAClD;YACD;gBACC,IAAI,EAAE,eAAe;gBACrB,KAAK,EAAE,KAAK;gBACZ,WAAW,EAAE,sBAAsB;aACnC;SACD;QACD,OAAO,EAAE,UAAU;QACnB,WAAW,EAAE,8DAA8D;QAC3E,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,QAAQ,EAAE,CAAC,SAAS,CAAC;gBACrB,SAAS,EAAE,CAAC,cAAc,CAAC;aAC3B;SACD;KACD;IACD;QACC,WAAW,EAAE,OAAO;QACpB,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,iCAAiC;QAC9C,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,QAAQ,EAAE,CAAC,SAAS,CAAC;gBACrB,SAAS,EAAE,CAAC,cAAc,CAAC;aAC3B;SACD;QACD,WAAW,EAAE;YACZ,QAAQ,EAAE,CAAC;SACX;KACD;CACD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
import { SubstackClient } from 'substack-api';
|
|
3
|
+
import { IStandardResponse } from './types';
|
|
4
|
+
export declare enum ProfileOperation {
|
|
5
|
+
GetOwnProfile = "getOwnProfile",
|
|
6
|
+
GetProfileBySlug = "getProfileBySlug",
|
|
7
|
+
GetProfileById = "getProfileById",
|
|
8
|
+
GetFollowees = "getFollowees"
|
|
9
|
+
}
|
|
10
|
+
export declare const profileOperations: INodeProperties[];
|
|
11
|
+
export declare const profileOperationHandlers: Record<ProfileOperation, (executeFunctions: IExecuteFunctions, client: SubstackClient, publicationAddress: string, itemIndex: number) => Promise<IStandardResponse>>;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.profileOperationHandlers = exports.profileOperations = exports.ProfileOperation = void 0;
|
|
4
|
+
const SubstackUtils_1 = require("./SubstackUtils");
|
|
5
|
+
var ProfileOperation;
|
|
6
|
+
(function (ProfileOperation) {
|
|
7
|
+
ProfileOperation["GetOwnProfile"] = "getOwnProfile";
|
|
8
|
+
ProfileOperation["GetProfileBySlug"] = "getProfileBySlug";
|
|
9
|
+
ProfileOperation["GetProfileById"] = "getProfileById";
|
|
10
|
+
ProfileOperation["GetFollowees"] = "getFollowees";
|
|
11
|
+
})(ProfileOperation || (exports.ProfileOperation = ProfileOperation = {}));
|
|
12
|
+
exports.profileOperations = [
|
|
13
|
+
{
|
|
14
|
+
displayName: 'Operation',
|
|
15
|
+
name: 'operation',
|
|
16
|
+
type: 'options',
|
|
17
|
+
default: 'getOwnProfile',
|
|
18
|
+
noDataExpression: true,
|
|
19
|
+
displayOptions: {
|
|
20
|
+
show: {
|
|
21
|
+
resource: ['profile'],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
options: [
|
|
25
|
+
{
|
|
26
|
+
name: 'Get Own Profile',
|
|
27
|
+
value: ProfileOperation.GetOwnProfile,
|
|
28
|
+
description: 'Get your own profile information',
|
|
29
|
+
action: 'Get own profile',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'Get Profile by Slug',
|
|
33
|
+
value: ProfileOperation.GetProfileBySlug,
|
|
34
|
+
description: 'Get a profile by its publication slug',
|
|
35
|
+
action: 'Get profile by slug',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'Get Profile by ID',
|
|
39
|
+
value: ProfileOperation.GetProfileById,
|
|
40
|
+
description: 'Get a profile by its user ID',
|
|
41
|
+
action: 'Get profile by ID',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Get Followees',
|
|
45
|
+
value: ProfileOperation.GetFollowees,
|
|
46
|
+
description: 'Get users that you follow',
|
|
47
|
+
action: 'Get followees',
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
async function getOwnProfile(executeFunctions, client, publicationAddress, itemIndex) {
|
|
53
|
+
try {
|
|
54
|
+
const profile = await client.ownProfile();
|
|
55
|
+
const profileData = {
|
|
56
|
+
id: profile.id,
|
|
57
|
+
name: profile.name,
|
|
58
|
+
handle: profile.slug,
|
|
59
|
+
bio: profile.bio,
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
success: true,
|
|
63
|
+
data: profileData,
|
|
64
|
+
metadata: {
|
|
65
|
+
status: 'success',
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
return SubstackUtils_1.SubstackUtils.formatErrorResponse({
|
|
71
|
+
message: error.message,
|
|
72
|
+
node: executeFunctions.getNode(),
|
|
73
|
+
itemIndex,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function getProfileBySlug(executeFunctions, client, publicationAddress, itemIndex) {
|
|
78
|
+
try {
|
|
79
|
+
const slug = executeFunctions.getNodeParameter('slug', itemIndex);
|
|
80
|
+
const profile = await client.profileForSlug(slug);
|
|
81
|
+
const profileData = {
|
|
82
|
+
id: profile.id,
|
|
83
|
+
name: profile.name,
|
|
84
|
+
handle: profile.slug,
|
|
85
|
+
bio: profile.bio,
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
success: true,
|
|
89
|
+
data: profileData,
|
|
90
|
+
metadata: {
|
|
91
|
+
status: 'success',
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
return SubstackUtils_1.SubstackUtils.formatErrorResponse({
|
|
97
|
+
message: error.message,
|
|
98
|
+
node: executeFunctions.getNode(),
|
|
99
|
+
itemIndex,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function getProfileById(executeFunctions, client, publicationAddress, itemIndex) {
|
|
104
|
+
try {
|
|
105
|
+
const userId = executeFunctions.getNodeParameter('userId', itemIndex);
|
|
106
|
+
const profile = await client.profileForId(userId);
|
|
107
|
+
const profileData = {
|
|
108
|
+
id: profile.id,
|
|
109
|
+
name: profile.name,
|
|
110
|
+
handle: profile.slug,
|
|
111
|
+
bio: profile.bio,
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
success: true,
|
|
115
|
+
data: profileData,
|
|
116
|
+
metadata: {
|
|
117
|
+
status: 'success',
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
return SubstackUtils_1.SubstackUtils.formatErrorResponse({
|
|
123
|
+
message: error.message,
|
|
124
|
+
node: executeFunctions.getNode(),
|
|
125
|
+
itemIndex,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function getFollowees(executeFunctions, client, publicationAddress, itemIndex) {
|
|
130
|
+
try {
|
|
131
|
+
const returnType = executeFunctions.getNodeParameter('returnType', itemIndex, 'profiles');
|
|
132
|
+
const limitParam = executeFunctions.getNodeParameter('limit', itemIndex, '');
|
|
133
|
+
let limit = 100;
|
|
134
|
+
if (limitParam !== '' && limitParam !== null && limitParam !== undefined) {
|
|
135
|
+
limit = Number(limitParam);
|
|
136
|
+
}
|
|
137
|
+
let followingData = [];
|
|
138
|
+
const ownProfile = await client.ownProfile();
|
|
139
|
+
const followeesIterable = await ownProfile.followees();
|
|
140
|
+
let count = 0;
|
|
141
|
+
for await (const followee of followeesIterable) {
|
|
142
|
+
if (count >= limit)
|
|
143
|
+
break;
|
|
144
|
+
if (returnType === 'ids') {
|
|
145
|
+
followingData.push({
|
|
146
|
+
id: followee.id,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
followingData.push({
|
|
151
|
+
id: followee.id,
|
|
152
|
+
name: followee.name,
|
|
153
|
+
handle: followee.slug,
|
|
154
|
+
bio: followee.bio,
|
|
155
|
+
subscriberCount: 0,
|
|
156
|
+
subscriberCountString: '',
|
|
157
|
+
primaryPublication: undefined,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
count++;
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
success: true,
|
|
164
|
+
data: followingData,
|
|
165
|
+
metadata: {
|
|
166
|
+
status: 'success',
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
return SubstackUtils_1.SubstackUtils.formatErrorResponse({
|
|
172
|
+
message: error.message,
|
|
173
|
+
node: executeFunctions.getNode(),
|
|
174
|
+
itemIndex,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.profileOperationHandlers = {
|
|
179
|
+
[ProfileOperation.GetOwnProfile]: getOwnProfile,
|
|
180
|
+
[ProfileOperation.GetProfileBySlug]: getProfileBySlug,
|
|
181
|
+
[ProfileOperation.GetProfileById]: getProfileById,
|
|
182
|
+
[ProfileOperation.GetFollowees]: getFollowees,
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingURL=Profile.operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Profile.operations.js","sourceRoot":"","sources":["../../../nodes/Substack/Profile.operations.ts"],"names":[],"mappings":";;;AAGA,mDAAgD;AAEhD,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,mDAA+B,CAAA;IAC/B,yDAAqC,CAAA;IACrC,qDAAiC,CAAA;IACjC,iDAA6B,CA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