n8n-nodes-postdaily 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +125 -2
- package/dist/credentials/PostDailyApi.credentials.d.ts +10 -0
- package/dist/credentials/PostDailyApi.credentials.js +51 -0
- package/dist/credentials/PostDailyApi.credentials.js.map +1 -0
- package/dist/nodes/PostDaily/GenericFunctions.d.ts +7 -0
- package/dist/nodes/PostDaily/GenericFunctions.js +103 -0
- package/dist/nodes/PostDaily/GenericFunctions.js.map +1 -0
- package/dist/nodes/PostDaily/PostDaily.node.d.ts +11 -0
- package/dist/nodes/PostDaily/PostDaily.node.js +302 -0
- package/dist/nodes/PostDaily/PostDaily.node.js.map +1 -0
- package/dist/nodes/PostDaily/PostDaily.node.json +18 -0
- package/dist/nodes/PostDaily/descriptions/ChannelDescription.d.ts +3 -0
- package/dist/nodes/PostDaily/descriptions/ChannelDescription.js +35 -0
- package/dist/nodes/PostDaily/descriptions/ChannelDescription.js.map +1 -0
- package/dist/nodes/PostDaily/descriptions/MediaDescription.d.ts +3 -0
- package/dist/nodes/PostDaily/descriptions/MediaDescription.js +62 -0
- package/dist/nodes/PostDaily/descriptions/MediaDescription.js.map +1 -0
- package/dist/nodes/PostDaily/descriptions/PostDescription.d.ts +3 -0
- package/dist/nodes/PostDaily/descriptions/PostDescription.js +362 -0
- package/dist/nodes/PostDaily/descriptions/PostDescription.js.map +1 -0
- package/dist/nodes/PostDaily/descriptions/shared.d.ts +2 -0
- package/dist/nodes/PostDaily/descriptions/shared.js +12 -0
- package/dist/nodes/PostDaily/descriptions/shared.js.map +1 -0
- package/dist/nodes/PostDaily/postdaily.dark.svg +29 -0
- package/dist/nodes/PostDaily/postdaily.svg +29 -0
- package/dist/package.json +66 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +64 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mehedihasan2810
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,126 @@
|
|
|
1
|
-
#
|
|
1
|
+
# n8n-nodes-postdaily
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An [n8n](https://n8n.io) community node for [PostDaily](https://www.postdaily.app).
|
|
4
|
+
Use it to draft, queue and schedule social media posts from your workflows.
|
|
5
|
+
It posts to Instagram, Facebook, TikTok, YouTube, LinkedIn, X, Threads,
|
|
6
|
+
Pinterest, Bluesky and Mastodon.
|
|
7
|
+
|
|
8
|
+
PostDaily checks each post against each network's rules before it goes out. It
|
|
9
|
+
retries failed publishes and tells you when a channel needs reconnecting.
|
|
10
|
+
|
|
11
|
+
[Installation](#installation) · [Credentials](#credentials) · [Operations](#operations) · [Using it safely](#using-it-safely) · [Example workflows](#example-workflows) · [Compatibility](#compatibility) · [Resources](#resources)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Follow the [community nodes installation guide](https://docs.n8n.io/integrations/community-nodes/installation/)
|
|
16
|
+
and install `n8n-nodes-postdaily`.
|
|
17
|
+
|
|
18
|
+
## Credentials
|
|
19
|
+
|
|
20
|
+
The node uses a **PostDaily API key**.
|
|
21
|
+
|
|
22
|
+
1. In PostDaily, open **Settings → AI agents** and select **API key**.
|
|
23
|
+
2. Name the key after the workflow, for example "n8n blog to drafts".
|
|
24
|
+
3. Choose what the key can do:
|
|
25
|
+
- **Drafts only**: create and edit drafts. It can never schedule or
|
|
26
|
+
publish. Best for anything that runs with nobody watching.
|
|
27
|
+
- **Full access**: also add to the queue, schedule, publish, delete and
|
|
28
|
+
retry.
|
|
29
|
+
- **Read only**: list channels and posts.
|
|
30
|
+
4. Pick the workspace the workflow should use.
|
|
31
|
+
5. Copy the key. PostDaily shows it only once.
|
|
32
|
+
6. In n8n, create a **PostDaily API** credential and paste the key. Leave
|
|
33
|
+
**Base URL** as it is.
|
|
34
|
+
|
|
35
|
+
When you save the credential, n8n tests it by listing your workspaces. To
|
|
36
|
+
revoke a key, go to **Settings → AI agents** in PostDaily. A key also stops
|
|
37
|
+
working when it expires, or when you change your PostDaily password.
|
|
38
|
+
|
|
39
|
+
## Operations
|
|
40
|
+
|
|
41
|
+
| Resource | Operation | What it does |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| Post | Create | Creates a post on one or more channels: as a draft, added to the queue, scheduled, or published now. Each channel becomes its own post. |
|
|
44
|
+
| Post | Get | Gets a post with each channel's status and link. |
|
|
45
|
+
| Post | Get Many | Finds posts by status, channel, text or date. |
|
|
46
|
+
| Post | Update | Edits a draft's text, title, media, channels or tags. |
|
|
47
|
+
| Post | Delete | Deletes a post from PostDaily. A published post stays live on the network. |
|
|
48
|
+
| Post | Retry | Publishes the failed channels of a post again. |
|
|
49
|
+
| Media | Upload | Uploads a file from an earlier step (binary data) to your media library. |
|
|
50
|
+
| Media | Import From URL | Adds an image, video or PDF from a public URL. |
|
|
51
|
+
| Channel | Get Many | Lists connected channels, their limits, and whether each can post now. |
|
|
52
|
+
|
|
53
|
+
To attach media to a post, use either way:
|
|
54
|
+
- put the `media.mediaId` from **Upload** or **Import From URL** in **Media IDs**;
|
|
55
|
+
- put public URLs in **Media URLs**.
|
|
56
|
+
|
|
57
|
+
## Using it safely
|
|
58
|
+
|
|
59
|
+
A workflow runs with nobody checking each post, so the node is careful by
|
|
60
|
+
default:
|
|
61
|
+
|
|
62
|
+
- **Mode** defaults to **Draft**.
|
|
63
|
+
- **Publish Now** does nothing unless you also turn on **Confirm Publish
|
|
64
|
+
Now**.
|
|
65
|
+
- **Retry** publishes again only with **Confirm Retry** on. Without it, it
|
|
66
|
+
lists the channels it would retry.
|
|
67
|
+
- **Problems keep the post as a draft.**
|
|
68
|
+
- With Add to Queue, Schedule or Publish Now, a post is kept as a draft
|
|
69
|
+
when it breaks a network rule (for example text over X's limit), or when
|
|
70
|
+
PostDaily asks for its warnings to be accepted. The item fails with
|
|
71
|
+
PostDaily's message.
|
|
72
|
+
- To go ahead despite warnings, turn on **Continue Despite Warnings**.
|
|
73
|
+
- Draft mode always saves. Its warnings are listed in `validation.warnings`.
|
|
74
|
+
- **No double posts.** Every create sends an idempotency key. By default the
|
|
75
|
+
key is built from the execution, node and item, so a retried step returns
|
|
76
|
+
the first result. For a key that holds across executions, set
|
|
77
|
+
**Idempotency Key** to something stable, such as an article URL.
|
|
78
|
+
- **Use one key per workflow, for one workspace.** A key that covers several
|
|
79
|
+
workspaces may be asked to confirm before it writes in a second one. The
|
|
80
|
+
node never sends that confirmation itself.
|
|
81
|
+
|
|
82
|
+
To keep going past a failed item, use n8n's **On Error → Continue** setting.
|
|
83
|
+
PostDaily's message ends up in the item's `error` field.
|
|
84
|
+
|
|
85
|
+
## Example workflows
|
|
86
|
+
|
|
87
|
+
- **Blog post to drafts:**
|
|
88
|
+
1. **RSS Feed Trigger**.
|
|
89
|
+
2. **PostDaily: Post → Create**, with **Mode** set to Draft.
|
|
90
|
+
3. In the Create step, set **Media URLs** to the article image and
|
|
91
|
+
**Idempotency Key** to `{{ $json.link }}`.
|
|
92
|
+
|
|
93
|
+
A ready-made version of this workflow, with images and duplicate checks, is
|
|
94
|
+
linked from [PostDaily's n8n guide](https://www.postdaily.app/help/connect-with-an-api-key#start-from-a-ready-made-n8n-workflow).
|
|
95
|
+
- **Video folder to TikTok and YouTube:**
|
|
96
|
+
1. **Google Drive Trigger**, then **Google Drive: Download**.
|
|
97
|
+
2. **PostDaily: Media → Upload**.
|
|
98
|
+
3. **PostDaily: Post → Create** with **Media IDs** set to `{{ $json.media.mediaId }}`.
|
|
99
|
+
- **Spreadsheet to queue:**
|
|
100
|
+
1. **Google Sheets** rows.
|
|
101
|
+
2. **PostDaily: Post → Create**, with **Mode** set to Add to Queue. This
|
|
102
|
+
needs a Full access key.
|
|
103
|
+
- **Failed post alert:**
|
|
104
|
+
1. **Schedule Trigger**.
|
|
105
|
+
2. **PostDaily: Post → Get Many**, with Statuses set to Failed.
|
|
106
|
+
3. **Slack**.
|
|
107
|
+
|
|
108
|
+
## Compatibility
|
|
109
|
+
|
|
110
|
+
Tested with n8n 2.48.7, the current stable release.
|
|
111
|
+
|
|
112
|
+
How it talks to PostDaily:
|
|
113
|
+
- It calls PostDaily's REST API at `https://api.postdaily.app/v1`, one
|
|
114
|
+
request per action, with your API key as a Bearer token.
|
|
115
|
+
- It has no runtime dependencies.
|
|
116
|
+
- It sends `User-Agent: n8n-nodes-postdaily/<version>`.
|
|
117
|
+
|
|
118
|
+
## Resources
|
|
119
|
+
|
|
120
|
+
- [PostDaily](https://www.postdaily.app)
|
|
121
|
+
- [Connect n8n with an API key](https://www.postdaily.app/help/connect-with-an-api-key)
|
|
122
|
+
- [n8n community nodes documentation](https://docs.n8n.io/integrations/#community-nodes)
|
|
123
|
+
|
|
124
|
+
## Licence
|
|
125
|
+
|
|
126
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IAuthenticateGeneric, Icon, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class PostDailyApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
icon: Icon;
|
|
6
|
+
documentationUrl: string;
|
|
7
|
+
properties: INodeProperties[];
|
|
8
|
+
authenticate: IAuthenticateGeneric;
|
|
9
|
+
test: ICredentialTestRequest;
|
|
10
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostDailyApi = void 0;
|
|
4
|
+
class PostDailyApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'postDailyApi';
|
|
7
|
+
this.displayName = 'PostDaily API';
|
|
8
|
+
this.icon = {
|
|
9
|
+
light: 'file:../nodes/PostDaily/postdaily.svg',
|
|
10
|
+
dark: 'file:../nodes/PostDaily/postdaily.dark.svg',
|
|
11
|
+
};
|
|
12
|
+
this.documentationUrl = 'https://www.postdaily.app/help/connect-with-an-api-key';
|
|
13
|
+
this.properties = [
|
|
14
|
+
{
|
|
15
|
+
displayName: 'API Key',
|
|
16
|
+
name: 'apiKey',
|
|
17
|
+
type: 'string',
|
|
18
|
+
typeOptions: { password: true },
|
|
19
|
+
required: true,
|
|
20
|
+
default: '',
|
|
21
|
+
placeholder: 'pd_live_...',
|
|
22
|
+
description: 'Create one in PostDaily under Settings → AI agents → API key. A Drafts only key can create and edit drafts but never schedule or publish.',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
displayName: 'Base URL',
|
|
26
|
+
name: 'baseUrl',
|
|
27
|
+
type: 'string',
|
|
28
|
+
required: true,
|
|
29
|
+
default: 'https://api.postdaily.app/v1',
|
|
30
|
+
description: 'Leave as it is unless PostDaily support gives you another address',
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
this.authenticate = {
|
|
34
|
+
type: 'generic',
|
|
35
|
+
properties: {
|
|
36
|
+
headers: {
|
|
37
|
+
Authorization: '=Bearer {{$credentials.apiKey}}',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
this.test = {
|
|
42
|
+
request: {
|
|
43
|
+
method: 'GET',
|
|
44
|
+
baseURL: '={{$credentials.baseUrl}}',
|
|
45
|
+
url: '/workspaces',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.PostDailyApi = PostDailyApi;
|
|
51
|
+
//# sourceMappingURL=PostDailyApi.credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostDailyApi.credentials.js","sourceRoot":"","sources":["../../credentials/PostDailyApi.credentials.ts"],"names":[],"mappings":";;;AAQA,MAAa,YAAY;IAAzB;QACC,SAAI,GAAG,cAAc,CAAC;QAEtB,gBAAW,GAAG,eAAe,CAAC;QAE9B,SAAI,GAAS;YACZ,KAAK,EAAE,uCAAuC;YAC9C,IAAI,EAAE,4CAA4C;SAClD,CAAC;QAEF,qBAAgB,GAAG,wDAAwD,CAAC;QAE5E,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,aAAa;gBAC1B,WAAW,EACV,2IAA2I;aAC5I;YACD;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,8BAA8B;gBACvC,WAAW,EAAE,mEAAmE;aAChF;SACD,CAAC;QAEF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,OAAO,EAAE;oBACR,aAAa,EAAE,iCAAiC;iBAChD;aACD;SACD,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,2BAA2B;gBACpC,GAAG,EAAE,aAAa;aAClB;SACD,CAAC;IACH,CAAC;CAAA;AAlDD,oCAkDC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IDataObject, IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-workflow';
|
|
2
|
+
export declare const NODE_VERSION = "0.2.0";
|
|
3
|
+
type PostDailyContext = IExecuteFunctions | ILoadOptionsFunctions;
|
|
4
|
+
export declare function callPostDaily(this: PostDailyContext, operation: string, args: IDataObject, itemIndex?: number): Promise<IDataObject>;
|
|
5
|
+
export declare function splitList(value: unknown): string[];
|
|
6
|
+
export declare function defaultIdempotencyKey(executionId: string, nodeId: string, args: IDataObject): string;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NODE_VERSION = void 0;
|
|
4
|
+
exports.callPostDaily = callPostDaily;
|
|
5
|
+
exports.splitList = splitList;
|
|
6
|
+
exports.defaultIdempotencyKey = defaultIdempotencyKey;
|
|
7
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
8
|
+
exports.NODE_VERSION = '0.2.0';
|
|
9
|
+
const ROUTES = {
|
|
10
|
+
list_workspaces: { method: 'GET', path: '/workspaces', query: true },
|
|
11
|
+
list_channels: { method: 'GET', path: '/channels', query: true },
|
|
12
|
+
list_posts: { method: 'GET', path: '/posts', query: true },
|
|
13
|
+
get_post: { method: 'GET', path: '/posts/{postId}' },
|
|
14
|
+
create_post: { method: 'POST', path: '/posts' },
|
|
15
|
+
update_post: { method: 'PATCH', path: '/posts/{postId}' },
|
|
16
|
+
delete_post: { method: 'DELETE', path: '/posts/{postId}' },
|
|
17
|
+
retry_post: { method: 'POST', path: '/posts/{postId}/retry' },
|
|
18
|
+
import_media: { method: 'POST', path: '/media/imports' },
|
|
19
|
+
create_media_upload: { method: 'POST', path: '/media/uploads' },
|
|
20
|
+
complete_media_upload: { method: 'POST', path: '/media/uploads/{mediaId}/complete' },
|
|
21
|
+
};
|
|
22
|
+
function toQuery(args) {
|
|
23
|
+
return Object.fromEntries(Object.entries(args).map(([name, value]) => [
|
|
24
|
+
name,
|
|
25
|
+
Array.isArray(value) ? value.join(',') : String(value),
|
|
26
|
+
]));
|
|
27
|
+
}
|
|
28
|
+
async function callPostDaily(operation, args, itemIndex = 0) {
|
|
29
|
+
var _a, _b, _c, _d, _e;
|
|
30
|
+
const route = ROUTES[operation];
|
|
31
|
+
if (!route) {
|
|
32
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: `Unknown operation ${operation}` }, { itemIndex });
|
|
33
|
+
}
|
|
34
|
+
const rest = { ...args };
|
|
35
|
+
const missing = [...route.path.matchAll(/\{(\w+)\}/g)]
|
|
36
|
+
.map((match) => { var _a; return (_a = match[1]) !== null && _a !== void 0 ? _a : ''; })
|
|
37
|
+
.find((name) => { var _a; return String((_a = rest[name]) !== null && _a !== void 0 ? _a : '').trim() === ''; });
|
|
38
|
+
if (missing) {
|
|
39
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `${missing === 'postId' ? 'Post ID' : 'Media ID'} is required`, {
|
|
40
|
+
itemIndex,
|
|
41
|
+
description: 'It is empty for this item. Check the expression, or the step that should have produced it.',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const credentials = await this.getCredentials('postDailyApi');
|
|
45
|
+
const path = route.path.replace(/\{(\w+)\}/g, (_match, name) => {
|
|
46
|
+
var _a;
|
|
47
|
+
const value = encodeURIComponent(String((_a = rest[name]) !== null && _a !== void 0 ? _a : ''));
|
|
48
|
+
delete rest[name];
|
|
49
|
+
return value;
|
|
50
|
+
});
|
|
51
|
+
const options = {
|
|
52
|
+
method: route.method,
|
|
53
|
+
url: `${String(credentials.baseUrl).replace(/\/+$/, '')}${path}`,
|
|
54
|
+
headers: { 'User-Agent': `n8n-nodes-postdaily/${exports.NODE_VERSION}` },
|
|
55
|
+
json: true,
|
|
56
|
+
returnFullResponse: true,
|
|
57
|
+
ignoreHttpStatusErrors: true,
|
|
58
|
+
};
|
|
59
|
+
if (route.query) {
|
|
60
|
+
options.qs = toQuery(rest);
|
|
61
|
+
}
|
|
62
|
+
else if (route.method !== 'GET' && route.method !== 'DELETE') {
|
|
63
|
+
options.body = rest;
|
|
64
|
+
}
|
|
65
|
+
let response;
|
|
66
|
+
try {
|
|
67
|
+
response = await this.helpers.httpRequestWithAuthentication.call(this, 'postDailyApi', options);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), error, { itemIndex });
|
|
71
|
+
}
|
|
72
|
+
if (response.statusCode >= 400) {
|
|
73
|
+
const failure = (_a = response.body) === null || _a === void 0 ? void 0 : _a.error;
|
|
74
|
+
const message = (_b = failure === null || failure === void 0 ? void 0 : failure.message) !== null && _b !== void 0 ? _b : `PostDaily answered HTTP ${response.statusCode}`;
|
|
75
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), ((_c = response.body) !== null && _c !== void 0 ? _c : {}), {
|
|
76
|
+
itemIndex,
|
|
77
|
+
httpCode: String(response.statusCode),
|
|
78
|
+
message: (failure === null || failure === void 0 ? void 0 : failure.code) ? `${failure.code}: ${message}` : message,
|
|
79
|
+
description: (_d = failure === null || failure === void 0 ? void 0 : failure.hint) !== null && _d !== void 0 ? _d : undefined,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return ((_e = response.body) !== null && _e !== void 0 ? _e : {});
|
|
83
|
+
}
|
|
84
|
+
function splitList(value) {
|
|
85
|
+
return String(value !== null && value !== void 0 ? value : '')
|
|
86
|
+
.split(',')
|
|
87
|
+
.map((part) => part.trim())
|
|
88
|
+
.filter(Boolean);
|
|
89
|
+
}
|
|
90
|
+
function fingerprint(text) {
|
|
91
|
+
let a = 0x811c9dc5;
|
|
92
|
+
let b = 0x01000193 ^ text.length;
|
|
93
|
+
for (let index = 0; index < text.length; index++) {
|
|
94
|
+
const code = text.charCodeAt(index);
|
|
95
|
+
a = Math.imul(a ^ code, 0x01000193) >>> 0;
|
|
96
|
+
b = Math.imul(b ^ code, 0x5bd1e995) >>> 0;
|
|
97
|
+
}
|
|
98
|
+
return a.toString(16).padStart(8, '0') + b.toString(16).padStart(8, '0');
|
|
99
|
+
}
|
|
100
|
+
function defaultIdempotencyKey(executionId, nodeId, args) {
|
|
101
|
+
return `n8n-${executionId}-${nodeId}-${fingerprint(JSON.stringify(args))}`.slice(0, 200);
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=GenericFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenericFunctions.js","sourceRoot":"","sources":["../../../nodes/PostDaily/GenericFunctions.ts"],"names":[],"mappings":";;;AAwDA,sCA2EC;AAGD,8BAKC;AAuBD,sDAMC;AAhKD,+CAAgE;AAGnD,QAAA,YAAY,GAAG,OAAO,CAAC;AAapC,MAAM,MAAM,GAA0B;IACrC,eAAe,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE;IACpE,aAAa,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE;IAChE,UAAU,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE;IAC1D,Q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AAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC1E,CAAC;AASD,SAAgB,qBAAqB,CACpC,WAAmB,EACnB,MAAc,EACd,IAAiB;IAEjB,OAAO,OAAO,WAAW,IAAI,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class PostDaily implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
methods: {
|
|
5
|
+
loadOptions: {
|
|
6
|
+
getWorkspaces(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
7
|
+
getChannels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostDaily = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const ChannelDescription_1 = require("./descriptions/ChannelDescription");
|
|
6
|
+
const MediaDescription_1 = require("./descriptions/MediaDescription");
|
|
7
|
+
const PostDescription_1 = require("./descriptions/PostDescription");
|
|
8
|
+
const GenericFunctions_1 = require("./GenericFunctions");
|
|
9
|
+
const PAGE_SIZE = 50;
|
|
10
|
+
function mediaArg(fields) {
|
|
11
|
+
const media = [
|
|
12
|
+
...(0, GenericFunctions_1.splitList)(fields.mediaIds).map((mediaId) => ({ mediaId })),
|
|
13
|
+
...(0, GenericFunctions_1.splitList)(fields.mediaUrls).map((url) => ({ url })),
|
|
14
|
+
];
|
|
15
|
+
return media.length > 0 ? media : undefined;
|
|
16
|
+
}
|
|
17
|
+
function channelSettingsArg(value, itemIndex) {
|
|
18
|
+
if (value === undefined || value === '' || value === '[]') {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
let parsed = value;
|
|
22
|
+
if (typeof value === 'string') {
|
|
23
|
+
try {
|
|
24
|
+
parsed = JSON.parse(value);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
parsed = undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (!Array.isArray(parsed)) {
|
|
31
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Network Options must be a JSON list', {
|
|
32
|
+
itemIndex,
|
|
33
|
+
description: 'For example: [{"channel": "youtube", "options": {"youtube": {"title": "My video"}}}]',
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return parsed.length > 0 ? parsed : undefined;
|
|
37
|
+
}
|
|
38
|
+
function compact(args) {
|
|
39
|
+
return Object.fromEntries(Object.entries(args).filter(([, value]) => value !== undefined && value !== ''));
|
|
40
|
+
}
|
|
41
|
+
class PostDaily {
|
|
42
|
+
constructor() {
|
|
43
|
+
this.description = {
|
|
44
|
+
displayName: 'PostDaily',
|
|
45
|
+
name: 'postDaily',
|
|
46
|
+
icon: { light: 'file:postdaily.svg', dark: 'file:postdaily.dark.svg' },
|
|
47
|
+
group: ['output'],
|
|
48
|
+
version: 1,
|
|
49
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
50
|
+
description: 'Draft, queue and schedule social media posts to Instagram, Facebook, TikTok, YouTube, LinkedIn, X and more',
|
|
51
|
+
defaults: { name: 'PostDaily' },
|
|
52
|
+
usableAsTool: true,
|
|
53
|
+
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
54
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
|
|
55
|
+
credentials: [{ name: 'postDailyApi', required: true }],
|
|
56
|
+
properties: [
|
|
57
|
+
{
|
|
58
|
+
displayName: 'Resource',
|
|
59
|
+
name: 'resource',
|
|
60
|
+
type: 'options',
|
|
61
|
+
noDataExpression: true,
|
|
62
|
+
options: [
|
|
63
|
+
{ name: 'Channel', value: 'channel' },
|
|
64
|
+
{ name: 'Media', value: 'media' },
|
|
65
|
+
{ name: 'Post', value: 'post' },
|
|
66
|
+
],
|
|
67
|
+
default: 'post',
|
|
68
|
+
},
|
|
69
|
+
...PostDescription_1.postOperations,
|
|
70
|
+
...PostDescription_1.postFields,
|
|
71
|
+
...MediaDescription_1.mediaOperations,
|
|
72
|
+
...MediaDescription_1.mediaFields,
|
|
73
|
+
...ChannelDescription_1.channelOperations,
|
|
74
|
+
...ChannelDescription_1.channelFields,
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
this.methods = {
|
|
78
|
+
loadOptions: {
|
|
79
|
+
async getWorkspaces() {
|
|
80
|
+
var _a;
|
|
81
|
+
const data = await GenericFunctions_1.callPostDaily.call(this, 'list_workspaces', {});
|
|
82
|
+
const workspaces = (_a = data.workspaces) !== null && _a !== void 0 ? _a : [];
|
|
83
|
+
return [
|
|
84
|
+
{
|
|
85
|
+
name: "Key's Workspace (Default)",
|
|
86
|
+
value: '',
|
|
87
|
+
description: 'Use this when the API key covers one workspace',
|
|
88
|
+
},
|
|
89
|
+
...workspaces.map((workspace) => ({
|
|
90
|
+
name: String(workspace.name),
|
|
91
|
+
value: String(workspace.id),
|
|
92
|
+
})),
|
|
93
|
+
];
|
|
94
|
+
},
|
|
95
|
+
async getChannels() {
|
|
96
|
+
var _a;
|
|
97
|
+
const workspaceId = this.getCurrentNodeParameter('workspaceId');
|
|
98
|
+
const data = await GenericFunctions_1.callPostDaily.call(this, 'list_channels', compact({ workspaceId: workspaceId || undefined }));
|
|
99
|
+
const channels = (_a = data.channels) !== null && _a !== void 0 ? _a : [];
|
|
100
|
+
return channels.map((channel) => {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
return ({
|
|
103
|
+
name: `${String((_a = channel.networkName) !== null && _a !== void 0 ? _a : channel.network)} · ${String((_b = channel.handle) !== null && _b !== void 0 ? _b : channel.name)}`,
|
|
104
|
+
value: String(channel.id),
|
|
105
|
+
description: channel.status === 'ok' ? undefined : 'Needs reconnecting in PostDaily',
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
async execute() {
|
|
113
|
+
var _a, _b;
|
|
114
|
+
const items = this.getInputData();
|
|
115
|
+
const returnData = [];
|
|
116
|
+
for (let i = 0; i < items.length; i++) {
|
|
117
|
+
try {
|
|
118
|
+
const resource = this.getNodeParameter('resource', i);
|
|
119
|
+
const operation = this.getNodeParameter('operation', i);
|
|
120
|
+
const results = await runOperation.call(this, resource, operation, i);
|
|
121
|
+
for (const json of results) {
|
|
122
|
+
returnData.push({ json, pairedItem: { item: i } });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (this.continueOnFail()) {
|
|
127
|
+
returnData.push({
|
|
128
|
+
json: { error: error.message },
|
|
129
|
+
pairedItem: { item: i },
|
|
130
|
+
});
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (error instanceof n8n_workflow_1.NodeOperationError) {
|
|
134
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
|
|
135
|
+
itemIndex: i,
|
|
136
|
+
description: (_a = error.description) !== null && _a !== void 0 ? _a : undefined,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
|
|
140
|
+
itemIndex: i,
|
|
141
|
+
message: error.message,
|
|
142
|
+
description: error instanceof n8n_workflow_1.NodeApiError ? ((_b = error.description) !== null && _b !== void 0 ? _b : undefined) : undefined,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return [returnData];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.PostDaily = PostDaily;
|
|
150
|
+
async function runOperation(resource, operation, i) {
|
|
151
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
152
|
+
const workspace = () => this.getNodeParameter('workspaceId', i, '') || undefined;
|
|
153
|
+
const withKey = (args, userKey) => ({
|
|
154
|
+
...args,
|
|
155
|
+
idempotencyKey: userKey || (0, GenericFunctions_1.defaultIdempotencyKey)(this.getExecutionId(), this.getNode().id, args),
|
|
156
|
+
});
|
|
157
|
+
if (resource === 'post') {
|
|
158
|
+
if (operation === 'create') {
|
|
159
|
+
const mode = this.getNodeParameter('mode', i);
|
|
160
|
+
const fields = this.getNodeParameter('additionalFields', i);
|
|
161
|
+
if (mode === 'now' && !this.getNodeParameter('confirmPublishNow', i, false)) {
|
|
162
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Publish Now needs Confirm Publish Now', {
|
|
163
|
+
itemIndex: i,
|
|
164
|
+
description: 'Turn on Confirm Publish Now to let this workflow publish with no person checking the post, or choose Draft, Add to Queue or Schedule.',
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
const result = await GenericFunctions_1.callPostDaily.call(this, 'create_post', withKey(compact({
|
|
168
|
+
workspaceId: workspace(),
|
|
169
|
+
channels: this.getNodeParameter('channels', i),
|
|
170
|
+
text: this.getNodeParameter('text', i),
|
|
171
|
+
mode,
|
|
172
|
+
scheduledAt: mode === 'scheduled'
|
|
173
|
+
? this.getNodeParameter('scheduledAt', i)
|
|
174
|
+
: undefined,
|
|
175
|
+
confirmPublish: mode === 'now' ? true : undefined,
|
|
176
|
+
confirmWarnings: fields.continueDespiteWarnings === true ? true : undefined,
|
|
177
|
+
firstComment: fields.firstComment,
|
|
178
|
+
media: mediaArg(fields),
|
|
179
|
+
channelSettings: channelSettingsArg.call(this, fields.channelSettings, i),
|
|
180
|
+
requestApproval: fields.requestApproval === true ? true : undefined,
|
|
181
|
+
tags: (0, GenericFunctions_1.splitList)(fields.tags).length > 0 ? (0, GenericFunctions_1.splitList)(fields.tags) : undefined,
|
|
182
|
+
timezone: fields.timezone,
|
|
183
|
+
title: fields.title,
|
|
184
|
+
}), fields.idempotencyKey), i);
|
|
185
|
+
if (result.outcome === 'invalid' || result.outcome === 'needs_confirmation') {
|
|
186
|
+
const draft = result.draftPostId ? ` (draft ${String(result.draftPostId)})` : '';
|
|
187
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), String((_a = result.summary) !== null && _a !== void 0 ? _a : 'PostDaily kept the post as a draft'), {
|
|
188
|
+
itemIndex: i,
|
|
189
|
+
description: result.outcome === 'invalid'
|
|
190
|
+
? `PostDaily saved it as a draft${draft} but did not ${mode === 'now' ? 'publish' : 'schedule'} it. Fix the errors, then try again.`
|
|
191
|
+
: `PostDaily saved it as a draft${draft} and is waiting for the warnings to be accepted. Fix the post, or turn on Continue Despite Warnings.`,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return [result];
|
|
195
|
+
}
|
|
196
|
+
if (operation === 'get') {
|
|
197
|
+
return [
|
|
198
|
+
await GenericFunctions_1.callPostDaily.call(this, 'get_post', { postId: this.getNodeParameter('postId', i) }, i),
|
|
199
|
+
];
|
|
200
|
+
}
|
|
201
|
+
if (operation === 'getAll') {
|
|
202
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
203
|
+
const limit = returnAll ? Infinity : this.getNodeParameter('limit', i);
|
|
204
|
+
const filters = this.getNodeParameter('filters', i);
|
|
205
|
+
const posts = [];
|
|
206
|
+
let cursor;
|
|
207
|
+
do {
|
|
208
|
+
const page = await GenericFunctions_1.callPostDaily.call(this, 'list_posts', compact({
|
|
209
|
+
workspaceId: workspace(),
|
|
210
|
+
channels: (0, GenericFunctions_1.splitList)(filters.channels).length > 0 ? (0, GenericFunctions_1.splitList)(filters.channels) : undefined,
|
|
211
|
+
statuses: ((_b = filters.statuses) === null || _b === void 0 ? void 0 : _b.length)
|
|
212
|
+
? filters.statuses
|
|
213
|
+
: undefined,
|
|
214
|
+
search: filters.search,
|
|
215
|
+
from: filters.from,
|
|
216
|
+
to: filters.to,
|
|
217
|
+
limit: Math.min(PAGE_SIZE, limit - posts.length),
|
|
218
|
+
cursor,
|
|
219
|
+
}), i);
|
|
220
|
+
posts.push(...((_c = page.posts) !== null && _c !== void 0 ? _c : []));
|
|
221
|
+
cursor = (_d = page.nextCursor) !== null && _d !== void 0 ? _d : undefined;
|
|
222
|
+
} while (cursor && posts.length < limit);
|
|
223
|
+
return posts.slice(0, limit);
|
|
224
|
+
}
|
|
225
|
+
if (operation === 'update') {
|
|
226
|
+
const fields = this.getNodeParameter('updateFields', i);
|
|
227
|
+
return [
|
|
228
|
+
await GenericFunctions_1.callPostDaily.call(this, 'update_post', compact({
|
|
229
|
+
postId: this.getNodeParameter('postId', i),
|
|
230
|
+
text: fields.text,
|
|
231
|
+
title: fields.title,
|
|
232
|
+
firstComment: fields.firstComment,
|
|
233
|
+
channels: (0, GenericFunctions_1.splitList)(fields.channels).length > 0 ? (0, GenericFunctions_1.splitList)(fields.channels) : undefined,
|
|
234
|
+
tags: (0, GenericFunctions_1.splitList)(fields.tags).length > 0 ? (0, GenericFunctions_1.splitList)(fields.tags) : undefined,
|
|
235
|
+
media: mediaArg(fields),
|
|
236
|
+
channelSettings: channelSettingsArg.call(this, fields.channelSettings, i),
|
|
237
|
+
expectedVersion: fields.expectedVersion || undefined,
|
|
238
|
+
}), i),
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
if (operation === 'delete') {
|
|
242
|
+
return [
|
|
243
|
+
await GenericFunctions_1.callPostDaily.call(this, 'delete_post', { postId: this.getNodeParameter('postId', i) }, i),
|
|
244
|
+
];
|
|
245
|
+
}
|
|
246
|
+
if (operation === 'retry') {
|
|
247
|
+
return [
|
|
248
|
+
await GenericFunctions_1.callPostDaily.call(this, 'retry_post', compact({
|
|
249
|
+
postId: this.getNodeParameter('postId', i),
|
|
250
|
+
channel: this.getNodeParameter('channel', i, '') || undefined,
|
|
251
|
+
confirmPublish: this.getNodeParameter('confirmRetry', i, false) ? true : undefined,
|
|
252
|
+
}), i),
|
|
253
|
+
];
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (resource === 'media') {
|
|
257
|
+
const filename = this.getNodeParameter('filename', i, '') || undefined;
|
|
258
|
+
if (operation === 'import') {
|
|
259
|
+
return [
|
|
260
|
+
await GenericFunctions_1.callPostDaily.call(this, 'import_media', withKey(compact({
|
|
261
|
+
workspaceId: workspace(),
|
|
262
|
+
url: this.getNodeParameter('url', i),
|
|
263
|
+
filename,
|
|
264
|
+
})), i),
|
|
265
|
+
];
|
|
266
|
+
}
|
|
267
|
+
if (operation === 'upload') {
|
|
268
|
+
const property = this.getNodeParameter('binaryPropertyName', i);
|
|
269
|
+
const binary = this.helpers.assertBinaryData(i, property);
|
|
270
|
+
const bytes = await this.helpers.getBinaryDataBuffer(i, property);
|
|
271
|
+
const started = await GenericFunctions_1.callPostDaily.call(this, 'create_media_upload', compact({
|
|
272
|
+
workspaceId: workspace(),
|
|
273
|
+
contentType: binary.mimeType,
|
|
274
|
+
filename: (_e = filename !== null && filename !== void 0 ? filename : binary.fileName) !== null && _e !== void 0 ? _e : 'upload',
|
|
275
|
+
sizeBytes: bytes.length,
|
|
276
|
+
}), i);
|
|
277
|
+
await this.helpers.httpRequest({
|
|
278
|
+
method: 'PUT',
|
|
279
|
+
url: String(started.uploadUrl),
|
|
280
|
+
headers: (_f = started.headers) !== null && _f !== void 0 ? _f : {
|
|
281
|
+
'Content-Type': binary.mimeType,
|
|
282
|
+
},
|
|
283
|
+
body: bytes,
|
|
284
|
+
json: false,
|
|
285
|
+
});
|
|
286
|
+
return [
|
|
287
|
+
await GenericFunctions_1.callPostDaily.call(this, 'complete_media_upload', compact({ workspaceId: workspace(), mediaId: String(started.mediaId) }), i),
|
|
288
|
+
];
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (resource === 'channel' && operation === 'getAll') {
|
|
292
|
+
const data = await GenericFunctions_1.callPostDaily.call(this, 'list_channels', compact({
|
|
293
|
+
workspaceId: workspace(),
|
|
294
|
+
network: this.getNodeParameter('network', i, '') || undefined,
|
|
295
|
+
}), i);
|
|
296
|
+
return (_g = data.channels) !== null && _g !== void 0 ? _g : [];
|
|
297
|
+
}
|
|
298
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unsupported operation: ${resource} ${operation}`, {
|
|
299
|
+
itemIndex: i,
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=PostDaily.node.js.map
|