@particle-academy/slack-js 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@particle-academy/slack-ui`,
4
+ `@particle-academy/slack-js`, `particle-academy/slack-php` and `fancy-slack`.
5
+
6
+ ## [0.1.0] - 2026-08-26
7
+
8
+ ### Added
9
+
10
+ - Post text messages through Slack's JSON Web API.
11
+ - Reject HTTP-success responses whose body reports `ok: false`.
12
+ - OAuth V2 with required single-use refresh-token rotation.
13
+ - Dedicated development-workspace sandbox guidance.
14
+ - A deterministic fixture matching Slack's top-level success response.
15
+
16
+ [0.1.0]: https://github.com/Fancy-Friends/slack/releases/tag/v0.1.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Particle Academy
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 ADDED
@@ -0,0 +1,107 @@
1
+ # Slack
2
+
3
+ Slack for [fancy-flow][flow] — as **four imported, versioned packages**, one
4
+ per runtime. Not vendored source: a copy cannot be upgraded, and third-party APIs
5
+ change.
6
+
7
+ [flow]: https://github.com/Particle-Academy/fancy-flow
8
+
9
+ | Runtime | Package | Install |
10
+ |---|---|---|
11
+ | Authoring surface (every host) | `@particle-academy/slack-ui` | `npm install @particle-academy/slack-ui` |
12
+ | Node | `@particle-academy/slack-js` | `npm install @particle-academy/slack-js` |
13
+ | PHP 8.4+ | `particle-academy/slack-php` | `composer require particle-academy/slack-php` |
14
+ | Python 3.11+ | `fancy-slack` | `pip install fancy-slack` |
15
+
16
+ The `ui` package is the editor surface and is React on every host — a PHP or
17
+ Python project installs it *and* its own runtime package, and never the `js` one.
18
+
19
+ ## What it costs you
20
+
21
+ One dependency: `@particle-academy/fancy-connector-core` (or
22
+ `particle-academy/fancy-connector-core` on Composer), which the `js` and `php`
23
+ packages pull in themselves. The Python package has **zero** runtime
24
+ dependencies.
25
+
26
+ **No Slack SDK.** Plain HTTP, deliberately: a vendor SDK is third-party code
27
+ subject to the kit's full approval bar, and one per provider is hundreds of
28
+ dependencies nobody is tracking.
29
+
30
+ ## Setting it up
31
+
32
+ Everything below is generated from `provider/manifest.json`, so it cannot disagree with what the packages do.
33
+
34
+ ### Credentials
35
+
36
+ A Slack connection holds 4 values.
37
+
38
+ **Two kinds of value, and mixing them up matters.** A `provider` credential is ONE value for the whole installation — an OAuth app's client secret serves every connected account. An `account` credential is one per connected account. A host that stores the second where it stores the first lets one account's credentials reach another's.
39
+
40
+ | Field | Scope | Secret | Where it comes from |
41
+ |---|---|---|---|
42
+ | **Client ID** | per installation | not secret | The Slack app client ID shared by the installation. |
43
+ | **Client secret** | per installation | **secret** | The matching Slack app client secret used by OAuth V2. |
44
+ | **Bot access token** | per connected account | **secret** | The workspace installation's rotating bot token. Token rotation must be enabled; the token expires after 12 hours. |
45
+ | **Refresh token** | per connected account | **secret** | The workspace installation's single-use refresh token. Persist Slack's replacement after every refresh. |
46
+
47
+ ### Authorising
48
+
49
+ Slack uses OAuth2 (authorization_code). The package DECLARES the exchange; the HOST performs it — a consent screen needs a browser, a redirect URI and somewhere to persist the result, and all three belong to the host.
50
+
51
+ - **Authorize URL** — https://slack.com/oauth/v2/authorize
52
+ - **Token URL** — https://slack.com/api/oauth.v2.access
53
+ - **Scopes** — `chat:write`
54
+ - **Access token lifetime** — 43200 seconds (12 hours). A host that never refreshes works all afternoon and is broken by morning.
55
+
56
+ **The refresh tokens ROTATE, and they are single use.** Every refresh returns a new one and spends the one submitted, so replaying a spent token revokes the ENTIRE grant — the user is signed out, with nothing in the failure that says why.
57
+
58
+ Two consequences, both of which a host gets wrong by default:
59
+
60
+ 1. **Do not RETRY a failed refresh with the same token.** A response that arrived but was not persisted — a crash between the reply and the write — turns the reflexive retry into a replay.
61
+ 2. **Do not refresh CONCURRENTLY.** Two workers refreshing at once means one of them replays.
62
+
63
+ Persist the returned token before using the access token it came with.
64
+
65
+ ### The estate
66
+
67
+ Slack has a test estate on the same host, reached with credentials from a SEPARATE test account you register. Selecting sandbox mode uses those credentials.
68
+
69
+ > Install the app into a dedicated development workspace or Slack developer sandbox. Messages are real inside that workspace, but its users and data are separate from production. Developer sandboxes expire by default and have feature and integration limits.
70
+
71
+ ## What it can do
72
+
73
+ ### Actions
74
+
75
+ #### `message_post` — Slack message
76
+
77
+ Post a text message to a Slack channel or conversation.
78
+
79
+ `POST /api/chat.postMessage` · **unsafe to replay** — a retried durable run does it TWICE
80
+
81
+ | Input | Required | What it is |
82
+ |---|---|---|
83
+ | `channel` | yes | The encoded channel, private group, direct-message or group-message conversation ID visible to the installed app. |
84
+ | `text` | yes | The message's top-level text. Keeping meaningful text here also gives screen readers a complete fallback when richer blocks are added elsewhere. |
85
+
86
+ ## Run it before you have credentials
87
+
88
+ Every operation ships a **faker**, whether or not Slack has a sandbox. Set a
89
+ node's mode to `fake` and it returns the shape Slack actually publishes — the
90
+ same field names, deterministically — so you can wire the downstream nodes before
91
+ touching an account, a key, or a network.
92
+
93
+ ## This repository is generated
94
+
95
+ `provider/` is the source. Everything under `packages/` is emitted from it and
96
+ **must not be hand-edited** — CI regenerates and diffs on every push, and the
97
+ next protocol sync destroys anything it finds. See [`AGENTS.md`](AGENTS.md).
98
+
99
+ ## Two namespaces, which do not match on purpose
100
+
101
+ The repo is `github.com/Fancy-Friends/slack`; the packages publish under
102
+ `particle-academy`. Nothing derives one from the other — the names come from
103
+ weaver's `friends.json` and nowhere else.
104
+
105
+ ## Licence
106
+
107
+ MIT.
@@ -0,0 +1,92 @@
1
+ import { callConnector } from '@particle-academy/fancy-connector-core';
2
+
3
+ // src/faker.ts
4
+ function fakeMessagePost({ config, fake }) {
5
+ return {
6
+ "ok": true,
7
+ "channel": "C123ABC456",
8
+ "ts": "1787719200.000100",
9
+ "message": {
10
+ "user": "U012AB3CDE",
11
+ "type": "message",
12
+ "ts": "1787719200.000100",
13
+ "text": "Deployment finished successfully.",
14
+ "app_id": "A012BC3DEF",
15
+ "bot_id": "B012AB3CD"
16
+ }
17
+ };
18
+ }
19
+ var slackFaker = (operation, request) => {
20
+ switch (operation) {
21
+ case "message_post":
22
+ return fakeMessagePost(request);
23
+ default:
24
+ throw new Error(
25
+ `slack: no fake response is defined for "${operation}". Add a fixture under provider/fixtures/ and regenerate \u2014 a connector without a faker cannot be developed against, tested, or demonstrated.`
26
+ );
27
+ }
28
+ };
29
+
30
+ // src/service.ts
31
+ var CONNECTOR_API_VERSION = 1;
32
+ var SLACK_BASE_URLS = {
33
+ "live": "https://slack.com",
34
+ "sandbox": "https://slack.com"
35
+ };
36
+ var SLACK_REQUIRES = [
37
+ "accessToken",
38
+ "refreshToken",
39
+ "clientId",
40
+ "clientSecret"
41
+ ];
42
+ function slackAuthorize(credentials, request, _mode) {
43
+ request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
44
+ }
45
+ var SLACK = {
46
+ service: "slack",
47
+ title: "Slack",
48
+ sandbox: "separate-account",
49
+ baseUrls: { ...SLACK_BASE_URLS },
50
+ requires: [...SLACK_REQUIRES],
51
+ authorize: slackAuthorize,
52
+ faker: slackFaker
53
+ };
54
+ var MESSAGE_POST_OPERATION = "message_post";
55
+ async function slackMessagePost(options) {
56
+ const config = options.config ?? {};
57
+ if (config.channel === void 0 || config.channel === null || config.channel === "") {
58
+ throw new Error(`message_post: "channel" is required (Channel).`);
59
+ }
60
+ if (config.text === void 0 || config.text === null || config.text === "") {
61
+ throw new Error(`message_post: "text" is required (Message).`);
62
+ }
63
+ const result = await callConnector(SLACK, {
64
+ operation: MESSAGE_POST_OPERATION,
65
+ config,
66
+ input: options.input,
67
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
68
+ ...options.mode === void 0 ? {} : { mode: options.mode },
69
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
70
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
71
+ ...options.transport === void 0 ? {} : { transport: options.transport },
72
+ request: {
73
+ method: "POST",
74
+ path: "/api/chat.postMessage",
75
+ json: {
76
+ "channel": String(config.channel),
77
+ "text": String(config.text)
78
+ }
79
+ }
80
+ });
81
+ const data = result.data;
82
+ if (data?.ok === false) {
83
+ throw new Error(
84
+ `message_post: Slack rejected chat.postMessage \u2014 ` + String(data.error ?? "no reason given")
85
+ );
86
+ }
87
+ return result;
88
+ }
89
+
90
+ export { CONNECTOR_API_VERSION, MESSAGE_POST_OPERATION, SLACK, SLACK_BASE_URLS, SLACK_REQUIRES, slackAuthorize, slackFaker, slackMessagePost };
91
+ //# sourceMappingURL=chunk-SWUB2VUX.js.map
92
+ //# sourceMappingURL=chunk-SWUB2VUX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/message-post.ts"],"names":[],"mappings":";;;AAyBA,SAAS,eAAA,CAAgB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAA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AAAA,MACN,IAAA,EAAM;AAAA,QACJ,SAAA,EAAW,MAAA,CAAO,MAAA,CAAO,OAAO,CAAA;AAAA,QAChC,MAAA,EAAQ,MAAA,CAAO,MAAA,CAAO,IAAI;AAAA;AAC5B;AACF,GACD,CAAA;AAMD,EAAA,MAAM,OAAO,MAAA,CAAO,IAAA;AAEpB,EAAA,IAAI,IAAA,EAAM,OAAO,KAAA,EAAO;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,qDAAA,CAAA,GACE,MAAA,CAAO,IAAA,CAAK,KAAA,IAAS,iBAAiB;AAAA,KAC1C;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT","file":"chunk-SWUB2VUX.js","sourcesContent":["/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/fixtures/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/fixtures/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- slack\n */\n\n/**\n * The Slack faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES Slack actually publishes, so an author can wire {{ $json.data.id }}\n * against a fake and have it keep working against the real thing.\n *\n * Deterministic — same inputs, same output. A faker returning a fresh uuid\n * every call cannot be asserted on, so its fixtures degrade to \"it did not\n * throw\", which is the assertion that catches nothing.\n */\n\nimport type { ConnectorFaker, FakeRequest } from \"@particle-academy/fancy-connector-core\";\n\nfunction fakeMessagePost({ config, fake }: FakeRequest): unknown {\n return {\n \"ok\": true,\n \"channel\": \"C123ABC456\",\n \"ts\": \"1787719200.000100\",\n \"message\": {\n \"user\": \"U012AB3CDE\",\n \"type\": \"message\",\n \"ts\": \"1787719200.000100\",\n \"text\": \"Deployment finished successfully.\",\n \"app_id\": \"A012BC3DEF\",\n \"bot_id\": \"B012AB3CD\",\n },\n };\n}\n\nexport const slackFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"message_post\":\n return fakeMessagePost(request);\n\n default:\n // A faker asked for an operation it has no shape for must SAY so. Making\n // something up would produce a green run whose output silently has none\n // of the fields the author is about to reference.\n throw new Error(\n `slack: no fake response is defined for \"${operation}\". ` +\n \"Add a fixture under provider/fixtures/ and regenerate — a connector without a faker \" +\n \"cannot be developed against, tested, or demonstrated.\",\n );\n }\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/manifest.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/manifest.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- slack\n */\n\n/**\n * Slack, as one service descriptor shared by every Slack operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of Slack: its base URL, its auth\n * scheme, its idempotency header, and its faker.\n *\n * ## The sandbox trap, written down where it is used\n *\n * Install the app into a dedicated development workspace or Slack developer\n * sandbox. Messages are real inside that workspace, but its users and data are\n * separate from production. Developer sandboxes expire by default and have\n * feature and integration limits.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { slackFaker } from \"./faker.js\";\n\n/**\n * The connector API version this package was GENERATED against.\n *\n * A literal, never imported. An imported constant lets an upgrade rewrite the\n * very claim it exists to detect, after which the copy agrees with itself\n * forever.\n */\nexport const CONNECTOR_API_VERSION = 1;\n\nexport const SLACK_BASE_URLS = {\n \"live\": \"https://slack.com\",\n \"sandbox\": \"https://slack.com\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const SLACK_REQUIRES = [\n \"accessToken\",\n \"refreshToken\",\n \"clientId\",\n \"clientSecret\"\n] as const;\n\n/**\n * Apply Slack's auth scheme to an outgoing request.\n *\n *\n *\n * The mode is passed in because for some providers auth and estate are the\n * same decision expressed in the URL; here it is unused, and saying so is\n * cheaper than wondering later whether it was forgotten.\n */\nexport function slackAuthorize(\n credentials: Record<string, string | undefined>,\n request: PreparedRequest,\n _mode: ConnectorMode,\n): void {\n request.headers.Authorization = `Bearer ${credentials.accessToken ?? \"\"}`;\n}\n\n/** The Slack service, for the TypeScript runtime. */\nexport const SLACK: ServiceDescriptor = {\n service: \"slack\",\n title: \"Slack\",\n sandbox: \"separate-account\",\n baseUrls: { ...SLACK_BASE_URLS },\n requires: [...SLACK_REQUIRES],\n authorize: slackAuthorize,\n faker: slackFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/message-post.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/message-post.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- slack\n */\n\n/**\n * Post a text message to a Slack channel or conversation.\n *\n * POST /api/chat.postMessage —\n * https://docs.slack.dev/reference/methods/chat.postMessage\n *\n * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,\n * no fake/real branch. This describes the request; callConnector resolves the\n * connection, picks the estate, and either calls Slack or calls the faker.\n *\n * sideEffects: unsafe-to-replay.\n */\n\nimport {\n callConnector,\n type ConnectorResult,\n type RequestedMode,\n type Transport,\n} from \"@particle-academy/fancy-connector-core\";\nimport { SLACK } from \"../service.js\";\n\nexport const MESSAGE_POST_OPERATION = \"message_post\";\n\nexport type MessagePostOptions = {\n /** The node's resolved config. Keys: channel, text. */\n config: Record<string, unknown>;\n credentials?: Record<string, string | undefined>;\n mode?: RequestedMode;\n connectionId?: string | null;\n input?: unknown;\n attempts?: number;\n /** Override the transport. The only way to exercise this without a network. */\n transport?: Transport;\n};\n\nexport async function slackMessagePost(options: MessagePostOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.channel === undefined || config.channel === null || config.channel === \"\") {\n throw new Error(`message_post: \"channel\" is required (Channel).`);\n }\n\n if (config.text === undefined || config.text === null || config.text === \"\") {\n throw new Error(`message_post: \"text\" is required (Message).`);\n }\n\n const result = await callConnector(SLACK, {\n operation: MESSAGE_POST_OPERATION,\n config,\n input: options.input,\n ...(options.credentials === undefined ? {} : { credentials: options.credentials }),\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n ...(options.connectionId === undefined ? {} : { connectionId: options.connectionId }),\n ...(options.attempts === undefined ? {} : { attempts: options.attempts }),\n ...(options.transport === undefined ? {} : { transport: options.transport }),\n request: {\n method: \"POST\",\n path: \"/api/chat.postMessage\",\n json: {\n \"channel\": String(config.channel),\n \"text\": String(config.text),\n },\n },\n });\n\n // Slack answers HTTP 200 with `{ok: false}` for an application-level\n // failure. A status check alone reads that as success, so the call is\n // reported as having worked and the next node receives a body that says\n // otherwise.\n const data = result.data as Record<string, unknown> | undefined;\n\n if (data?.ok === false) {\n throw new Error(\n `message_post: Slack rejected chat.postMessage — ` +\n String(data.error ?? \"no reason given\"),\n );\n }\n\n return result;\n}\n"]}
package/dist/flow.cjs ADDED
@@ -0,0 +1,116 @@
1
+ 'use strict';
2
+
3
+ var fancyConnectorCore = require('@particle-academy/fancy-connector-core');
4
+ var slackUi = require('@particle-academy/slack-ui');
5
+
6
+ // src/flow.ts
7
+
8
+ // src/faker.ts
9
+ function fakeMessagePost({ config, fake }) {
10
+ return {
11
+ "ok": true,
12
+ "channel": "C123ABC456",
13
+ "ts": "1787719200.000100",
14
+ "message": {
15
+ "user": "U012AB3CDE",
16
+ "type": "message",
17
+ "ts": "1787719200.000100",
18
+ "text": "Deployment finished successfully.",
19
+ "app_id": "A012BC3DEF",
20
+ "bot_id": "B012AB3CD"
21
+ }
22
+ };
23
+ }
24
+ var slackFaker = (operation, request) => {
25
+ switch (operation) {
26
+ case "message_post":
27
+ return fakeMessagePost(request);
28
+ default:
29
+ throw new Error(
30
+ `slack: no fake response is defined for "${operation}". Add a fixture under provider/fixtures/ and regenerate \u2014 a connector without a faker cannot be developed against, tested, or demonstrated.`
31
+ );
32
+ }
33
+ };
34
+
35
+ // src/service.ts
36
+ var SLACK_BASE_URLS = {
37
+ "live": "https://slack.com",
38
+ "sandbox": "https://slack.com"
39
+ };
40
+ var SLACK_REQUIRES = [
41
+ "accessToken",
42
+ "refreshToken",
43
+ "clientId",
44
+ "clientSecret"
45
+ ];
46
+ function slackAuthorize(credentials, request, _mode) {
47
+ request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
48
+ }
49
+ var SLACK = {
50
+ service: "slack",
51
+ title: "Slack",
52
+ sandbox: "separate-account",
53
+ baseUrls: { ...SLACK_BASE_URLS },
54
+ requires: [...SLACK_REQUIRES],
55
+ authorize: slackAuthorize,
56
+ faker: slackFaker
57
+ };
58
+ var MESSAGE_POST_OPERATION = "message_post";
59
+ async function slackMessagePost(options) {
60
+ const config = options.config ?? {};
61
+ if (config.channel === void 0 || config.channel === null || config.channel === "") {
62
+ throw new Error(`message_post: "channel" is required (Channel).`);
63
+ }
64
+ if (config.text === void 0 || config.text === null || config.text === "") {
65
+ throw new Error(`message_post: "text" is required (Message).`);
66
+ }
67
+ const result = await fancyConnectorCore.callConnector(SLACK, {
68
+ operation: MESSAGE_POST_OPERATION,
69
+ config,
70
+ input: options.input,
71
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
72
+ ...options.mode === void 0 ? {} : { mode: options.mode },
73
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
74
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
75
+ ...options.transport === void 0 ? {} : { transport: options.transport },
76
+ request: {
77
+ method: "POST",
78
+ path: "/api/chat.postMessage",
79
+ json: {
80
+ "channel": String(config.channel),
81
+ "text": String(config.text)
82
+ }
83
+ }
84
+ });
85
+ const data = result.data;
86
+ if (data?.ok === false) {
87
+ throw new Error(
88
+ `message_post: Slack rejected chat.postMessage \u2014 ` + String(data.error ?? "no reason given")
89
+ );
90
+ }
91
+ return result;
92
+ }
93
+
94
+ // src/flow.ts
95
+ var slackMessageExecutor = async (ctx) => {
96
+ const config = ctx.node.data?.config ?? {};
97
+ const result = await slackMessagePost({
98
+ config,
99
+ input: ctx.inputs?.in
100
+ });
101
+ ctx.emit({
102
+ type: "log",
103
+ level: "info",
104
+ nodeId: ctx.node.id,
105
+ message: `slack message_post ${result.data?.id} (${result.mode})`
106
+ });
107
+ return { __port: "out", value: result };
108
+ };
109
+ var SLACK_RUNNABLE_KINDS = [
110
+ { ...slackUi.slackMessageKind, executor: slackMessageExecutor }
111
+ ];
112
+
113
+ exports.SLACK_RUNNABLE_KINDS = SLACK_RUNNABLE_KINDS;
114
+ exports.slackMessageExecutor = slackMessageExecutor;
115
+ //# sourceMappingURL=flow.cjs.map
116
+ //# sourceMappingURL=flow.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/message-post.ts","../src/flow.ts"],"names":["callConnector","slackMessageKind"],"mappings":";;;;;;;;AAyBA,SAAS,eAAA,CAAgB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAC/D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,IAAA;AAAA,IACN,SAAA,EAAW,YAAA;AAAA,IACX,IAAA,EAAM,mBAAA;AAAA,IACN,SAAA,EAAW;AAAA,MACT,MAAA,EAAQ,YAAA;AAAA,MACR,MAAA,EAAQ,SAAA;AAAA,MACR,IAAA,EAAM,mBAAA;AAAA,MACN,MAAA,EAAQ,mCAAA;AAAA,MACR,QAAA,EAAU,YAAA;AAAA,MACV,QAAA,EAAU;AAAA;AACZ,GACF;AACF;AAEO,IAAM,UAAA,GAA6B,CAAC,SAAA,EAAW,OAAA,KAAY;AAChE,EAAA,QAAQ,SAAA;AAAW,IACjB,KAAK,cAAA;AACH,MAAA,OAAO,gBAAgB,OAAO,CAAA;AAAA,IAEhC;AAIE,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,2CAA2C,SAAS,CAAA,iJAAA;AAAA,OAGtD;AAAA;AAEN,CAAA;;;ACjBO,IAAM,eAAA,GAAkB;AAAA,EAC7B,MAAA,EAAQ,mBAAA;AAAA,EACR,SAAA,EAAW;AACb,CAAA;AAGO,IAAM,cAAA,GAAiB;AA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,IAAA,CAAK;AAAA,IACP,IAAA,EAAM,KAAA;AAAA,IACN,KAAA,EAAO,MAAA;AAAA,IACP,MAAA,EAAQ,IAAI,IAAA,CAAK,EAAA;AAAA,IACjB,SAAS,CAAA,mBAAA,EAAuB,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GACpF,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO;AACxC;AAGO,IAAM,oBAAA,GAA6C;AAAA,EACxD,EAAE,GAAGC,wBAAA,EAAkB,QAAA,EAAU,oBAAA;AACnC","file":"flow.cjs","sourcesContent":["/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/fixtures/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/fixtures/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- slack\n */\n\n/**\n * The Slack faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES Slack actually publishes, so an author can wire {{ $json.data.id }}\n * against a fake and have it keep working against the real thing.\n *\n * Deterministic — same inputs, same output. A faker returning a fresh uuid\n * every call cannot be asserted on, so its fixtures degrade to \"it did not\n * throw\", which is the assertion that catches nothing.\n */\n\nimport type { ConnectorFaker, FakeRequest } from \"@particle-academy/fancy-connector-core\";\n\nfunction fakeMessagePost({ config, fake }: FakeRequest): unknown {\n return {\n \"ok\": true,\n \"channel\": \"C123ABC456\",\n \"ts\": \"1787719200.000100\",\n \"message\": {\n \"user\": \"U012AB3CDE\",\n \"type\": \"message\",\n \"ts\": \"1787719200.000100\",\n \"text\": \"Deployment finished successfully.\",\n \"app_id\": \"A012BC3DEF\",\n \"bot_id\": \"B012AB3CD\",\n },\n };\n}\n\nexport const slackFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"message_post\":\n return fakeMessagePost(request);\n\n default:\n // A faker asked for an operation it has no shape for must SAY so. Making\n // something up would produce a green run whose output silently has none\n // of the fields the author is about to reference.\n throw new Error(\n `slack: no fake response is defined for \"${operation}\". ` +\n \"Add a fixture under provider/fixtures/ and regenerate — a connector without a faker \" +\n \"cannot be developed against, tested, or demonstrated.\",\n );\n }\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/manifest.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/manifest.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- slack\n */\n\n/**\n * Slack, as one service descriptor shared by every Slack operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of Slack: its base URL, its auth\n * scheme, its idempotency header, and its faker.\n *\n * ## The sandbox trap, written down where it is used\n *\n * Install the app into a dedicated development workspace or Slack developer\n * sandbox. Messages are real inside that workspace, but its users and data are\n * separate from production. Developer sandboxes expire by default and have\n * feature and integration limits.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { slackFaker } from \"./faker.js\";\n\n/**\n * The connector API version this package was GENERATED against.\n *\n * A literal, never imported. An imported constant lets an upgrade rewrite the\n * very claim it exists to detect, after which the copy agrees with itself\n * forever.\n */\nexport const CONNECTOR_API_VERSION = 1;\n\nexport const SLACK_BASE_URLS = {\n \"live\": \"https://slack.com\",\n \"sandbox\": \"https://slack.com\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const SLACK_REQUIRES = [\n \"accessToken\",\n \"refreshToken\",\n \"clientId\",\n \"clientSecret\"\n] as const;\n\n/**\n * Apply Slack's auth scheme to an outgoing request.\n *\n *\n *\n * The mode is passed in because for some providers auth and estate are the\n * same decision expressed in the URL; here it is unused, and saying so is\n * cheaper than wondering later whether it was forgotten.\n */\nexport function slackAuthorize(\n credentials: Record<string, string | undefined>,\n request: PreparedRequest,\n _mode: ConnectorMode,\n): void {\n request.headers.Authorization = `Bearer ${credentials.accessToken ?? \"\"}`;\n}\n\n/** The Slack service, for the TypeScript runtime. */\nexport const SLACK: ServiceDescriptor = {\n service: \"slack\",\n title: \"Slack\",\n sandbox: \"separate-account\",\n baseUrls: { ...SLACK_BASE_URLS },\n requires: [...SLACK_REQUIRES],\n authorize: slackAuthorize,\n faker: slackFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/message-post.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/message-post.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- slack\n */\n\n/**\n * Post a text message to a Slack channel or conversation.\n *\n * POST /api/chat.postMessage —\n * https://docs.slack.dev/reference/methods/chat.postMessage\n *\n * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,\n * no fake/real branch. This describes the request; callConnector resolves the\n * connection, picks the estate, and either calls Slack or calls the faker.\n *\n * sideEffects: unsafe-to-replay.\n */\n\nimport {\n callConnector,\n type ConnectorResult,\n type RequestedMode,\n type Transport,\n} from \"@particle-academy/fancy-connector-core\";\nimport { SLACK } from \"../service.js\";\n\nexport const MESSAGE_POST_OPERATION = \"message_post\";\n\nexport type MessagePostOptions = {\n /** The node's resolved config. Keys: channel, text. */\n config: Record<string, unknown>;\n credentials?: Record<string, string | undefined>;\n mode?: RequestedMode;\n connectionId?: string | null;\n input?: unknown;\n attempts?: number;\n /** Override the transport. The only way to exercise this without a network. */\n transport?: Transport;\n};\n\nexport async function slackMessagePost(options: MessagePostOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.channel === undefined || config.channel === null || config.channel === \"\") {\n throw new Error(`message_post: \"channel\" is required (Channel).`);\n }\n\n if (config.text === undefined || config.text === null || config.text === \"\") {\n throw new Error(`message_post: \"text\" is required (Message).`);\n }\n\n const result = await callConnector(SLACK, {\n operation: MESSAGE_POST_OPERATION,\n config,\n input: options.input,\n ...(options.credentials === undefined ? {} : { credentials: options.credentials }),\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n ...(options.connectionId === undefined ? {} : { connectionId: options.connectionId }),\n ...(options.attempts === undefined ? {} : { attempts: options.attempts }),\n ...(options.transport === undefined ? {} : { transport: options.transport }),\n request: {\n method: \"POST\",\n path: \"/api/chat.postMessage\",\n json: {\n \"channel\": String(config.channel),\n \"text\": String(config.text),\n },\n },\n });\n\n // Slack answers HTTP 200 with `{ok: false}` for an application-level\n // failure. A status check alone reads that as success, so the call is\n // reported as having worked and the next node receives a body that says\n // otherwise.\n const data = result.data as Record<string, unknown> | undefined;\n\n if (data?.ok === false) {\n throw new Error(\n `message_post: Slack rejected chat.postMessage — ` +\n String(data.error ?? \"no reason given\"),\n );\n }\n\n return result;\n}\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/ + triggers/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/ + triggers/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- slack\n */\n\n/**\n * Slack's node kinds with their TypeScript executors attached — for hosts that\n * EXECUTE on TS.\n *\n * The authoring surface in @particle-academy/slack-ui carries no executor: the\n * editor is React on every host, so a PHP or Python project installs the ui\n * package and never this one.\n */\n\nimport type { NodeExecutor, NodeKindDefinition } from \"@particle-academy/fancy-flow/engine\";\nimport {\n idempotencyKeyFor,\n NO_IDEMPOTENCY_KEY_WARNING,\n resolveConnection,\n triggerEvent,\n type RequestedMode,\n} from \"@particle-academy/fancy-connector-core\";\nimport { SLACK } from \"./service.js\";\n\nimport {\n slackMessageKind,\n} from \"@particle-academy/slack-ui\";\n\nimport { slackMessagePost } from \"./actions/message-post.js\";\n\nexport const slackMessageExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await slackMessagePost({\n config,\n input: ctx.inputs?.in,\n });\n\n ctx.emit({\n type: \"log\",\n level: \"info\",\n nodeId: ctx.node.id,\n message: `slack message_post ${(result.data as { id?: string })?.id} (${result.mode})`,\n });\n\n return { __port: \"out\", value: result };\n};\n\n/** The kinds a TypeScript host registers. */\nexport const SLACK_RUNNABLE_KINDS: NodeKindDefinition[] = [\n { ...slackMessageKind, executor: slackMessageExecutor },\n];\n"]}
@@ -0,0 +1,26 @@
1
+ import { NodeKindDefinition, NodeExecutor } from '@particle-academy/fancy-flow/engine';
2
+
3
+ /**
4
+ * GENERATED FILE — do not edit.
5
+ *
6
+ * Emitted from provider/actions/ + triggers/ by weaver's generator.
7
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
8
+ * being rejected, because it works until it silently does not. Fix
9
+ * provider/actions/ + triggers/ (or weaver's template/) and regenerate:
10
+ *
11
+ * npm run provider -- slack
12
+ */
13
+ /**
14
+ * Slack's node kinds with their TypeScript executors attached — for hosts that
15
+ * EXECUTE on TS.
16
+ *
17
+ * The authoring surface in @particle-academy/slack-ui carries no executor: the
18
+ * editor is React on every host, so a PHP or Python project installs the ui
19
+ * package and never this one.
20
+ */
21
+
22
+ declare const slackMessageExecutor: NodeExecutor;
23
+ /** The kinds a TypeScript host registers. */
24
+ declare const SLACK_RUNNABLE_KINDS: NodeKindDefinition[];
25
+
26
+ export { SLACK_RUNNABLE_KINDS, slackMessageExecutor };
package/dist/flow.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { NodeKindDefinition, NodeExecutor } from '@particle-academy/fancy-flow/engine';
2
+
3
+ /**
4
+ * GENERATED FILE — do not edit.
5
+ *
6
+ * Emitted from provider/actions/ + triggers/ by weaver's generator.
7
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
8
+ * being rejected, because it works until it silently does not. Fix
9
+ * provider/actions/ + triggers/ (or weaver's template/) and regenerate:
10
+ *
11
+ * npm run provider -- slack
12
+ */
13
+ /**
14
+ * Slack's node kinds with their TypeScript executors attached — for hosts that
15
+ * EXECUTE on TS.
16
+ *
17
+ * The authoring surface in @particle-academy/slack-ui carries no executor: the
18
+ * editor is React on every host, so a PHP or Python project installs the ui
19
+ * package and never this one.
20
+ */
21
+
22
+ declare const slackMessageExecutor: NodeExecutor;
23
+ /** The kinds a TypeScript host registers. */
24
+ declare const SLACK_RUNNABLE_KINDS: NodeKindDefinition[];
25
+
26
+ export { SLACK_RUNNABLE_KINDS, slackMessageExecutor };
package/dist/flow.js ADDED
@@ -0,0 +1,25 @@
1
+ import { slackMessagePost } from './chunk-SWUB2VUX.js';
2
+ import '@particle-academy/fancy-connector-core';
3
+ import { slackMessageKind } from '@particle-academy/slack-ui';
4
+
5
+ var slackMessageExecutor = async (ctx) => {
6
+ const config = ctx.node.data?.config ?? {};
7
+ const result = await slackMessagePost({
8
+ config,
9
+ input: ctx.inputs?.in
10
+ });
11
+ ctx.emit({
12
+ type: "log",
13
+ level: "info",
14
+ nodeId: ctx.node.id,
15
+ message: `slack message_post ${result.data?.id} (${result.mode})`
16
+ });
17
+ return { __port: "out", value: result };
18
+ };
19
+ var SLACK_RUNNABLE_KINDS = [
20
+ { ...slackMessageKind, executor: slackMessageExecutor }
21
+ ];
22
+
23
+ export { SLACK_RUNNABLE_KINDS, slackMessageExecutor };
24
+ //# sourceMappingURL=flow.js.map
25
+ //# sourceMappingURL=flow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flow.ts"],"names":[],"mappings":";;;;AAoCO,IAAM,oBAAA,GAAqC,OAAO,GAAA,KAAQ;AAC/D,EAAA,MAAM,MAAA,GAAW,GAAA,CAAI,IAAA,CAAK,IAAA,EAA+C,UAAU,EAAC;AAEpF,EAAA,MAAM,MAAA,GAAS,MAAM,gBAAA,CAAiB;AAAA,IACpC,MAAA;AAAA,IACA,KAAA,EAAO,IAAI,MAAA,EAAQ;AAAA,GACpB,CAAA;AAED,EAAA,GAAA,CAAI,IAAA,CAAK;AAAA,IACP,IAAA,EAAM,KAAA;AAAA,IACN,KAAA,EAAO,MAAA;AAAA,IACP,MAAA,EAAQ,IAAI,IAAA,CAAK,EAAA;AAAA,IACjB,SAAS,CAAA,mBAAA,EAAuB,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GACpF,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO;AACxC;AAGO,IAAM,oBAAA,GAA6C;AAAA,EACxD,EAAE,GAAG,gBAAA,EAAkB,QAAA,EAAU,oBAAA;AACnC","file":"flow.js","sourcesContent":["/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/ + triggers/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/ + triggers/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- slack\n */\n\n/**\n * Slack's node kinds with their TypeScript executors attached — for hosts that\n * EXECUTE on TS.\n *\n * The authoring surface in @particle-academy/slack-ui carries no executor: the\n * editor is React on every host, so a PHP or Python project installs the ui\n * package and never this one.\n */\n\nimport type { NodeExecutor, NodeKindDefinition } from \"@particle-academy/fancy-flow/engine\";\nimport {\n idempotencyKeyFor,\n NO_IDEMPOTENCY_KEY_WARNING,\n resolveConnection,\n triggerEvent,\n type RequestedMode,\n} from \"@particle-academy/fancy-connector-core\";\nimport { SLACK } from \"./service.js\";\n\nimport {\n slackMessageKind,\n} from \"@particle-academy/slack-ui\";\n\nimport { slackMessagePost } from \"./actions/message-post.js\";\n\nexport const slackMessageExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await slackMessagePost({\n config,\n input: ctx.inputs?.in,\n });\n\n ctx.emit({\n type: \"log\",\n level: \"info\",\n nodeId: ctx.node.id,\n message: `slack message_post ${(result.data as { id?: string })?.id} (${result.mode})`,\n });\n\n return { __port: \"out\", value: result };\n};\n\n/** The kinds a TypeScript host registers. */\nexport const SLACK_RUNNABLE_KINDS: NodeKindDefinition[] = [\n { ...slackMessageKind, executor: slackMessageExecutor },\n];\n"]}
package/dist/index.cjs ADDED
@@ -0,0 +1,101 @@
1
+ 'use strict';
2
+
3
+ var fancyConnectorCore = require('@particle-academy/fancy-connector-core');
4
+
5
+ // src/faker.ts
6
+ function fakeMessagePost({ config, fake }) {
7
+ return {
8
+ "ok": true,
9
+ "channel": "C123ABC456",
10
+ "ts": "1787719200.000100",
11
+ "message": {
12
+ "user": "U012AB3CDE",
13
+ "type": "message",
14
+ "ts": "1787719200.000100",
15
+ "text": "Deployment finished successfully.",
16
+ "app_id": "A012BC3DEF",
17
+ "bot_id": "B012AB3CD"
18
+ }
19
+ };
20
+ }
21
+ var slackFaker = (operation, request) => {
22
+ switch (operation) {
23
+ case "message_post":
24
+ return fakeMessagePost(request);
25
+ default:
26
+ throw new Error(
27
+ `slack: no fake response is defined for "${operation}". Add a fixture under provider/fixtures/ and regenerate \u2014 a connector without a faker cannot be developed against, tested, or demonstrated.`
28
+ );
29
+ }
30
+ };
31
+
32
+ // src/service.ts
33
+ var CONNECTOR_API_VERSION = 1;
34
+ var SLACK_BASE_URLS = {
35
+ "live": "https://slack.com",
36
+ "sandbox": "https://slack.com"
37
+ };
38
+ var SLACK_REQUIRES = [
39
+ "accessToken",
40
+ "refreshToken",
41
+ "clientId",
42
+ "clientSecret"
43
+ ];
44
+ function slackAuthorize(credentials, request, _mode) {
45
+ request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
46
+ }
47
+ var SLACK = {
48
+ service: "slack",
49
+ title: "Slack",
50
+ sandbox: "separate-account",
51
+ baseUrls: { ...SLACK_BASE_URLS },
52
+ requires: [...SLACK_REQUIRES],
53
+ authorize: slackAuthorize,
54
+ faker: slackFaker
55
+ };
56
+ var MESSAGE_POST_OPERATION = "message_post";
57
+ async function slackMessagePost(options) {
58
+ const config = options.config ?? {};
59
+ if (config.channel === void 0 || config.channel === null || config.channel === "") {
60
+ throw new Error(`message_post: "channel" is required (Channel).`);
61
+ }
62
+ if (config.text === void 0 || config.text === null || config.text === "") {
63
+ throw new Error(`message_post: "text" is required (Message).`);
64
+ }
65
+ const result = await fancyConnectorCore.callConnector(SLACK, {
66
+ operation: MESSAGE_POST_OPERATION,
67
+ config,
68
+ input: options.input,
69
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
70
+ ...options.mode === void 0 ? {} : { mode: options.mode },
71
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
72
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
73
+ ...options.transport === void 0 ? {} : { transport: options.transport },
74
+ request: {
75
+ method: "POST",
76
+ path: "/api/chat.postMessage",
77
+ json: {
78
+ "channel": String(config.channel),
79
+ "text": String(config.text)
80
+ }
81
+ }
82
+ });
83
+ const data = result.data;
84
+ if (data?.ok === false) {
85
+ throw new Error(
86
+ `message_post: Slack rejected chat.postMessage \u2014 ` + String(data.error ?? "no reason given")
87
+ );
88
+ }
89
+ return result;
90
+ }
91
+
92
+ exports.CONNECTOR_API_VERSION = CONNECTOR_API_VERSION;
93
+ exports.MESSAGE_POST_OPERATION = MESSAGE_POST_OPERATION;
94
+ exports.SLACK = SLACK;
95
+ exports.SLACK_BASE_URLS = SLACK_BASE_URLS;
96
+ exports.SLACK_REQUIRES = SLACK_REQUIRES;
97
+ exports.slackAuthorize = slackAuthorize;
98
+ exports.slackFaker = slackFaker;
99
+ exports.slackMessagePost = slackMessagePost;
100
+ //# sourceMappingURL=index.cjs.map
101
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/message-post.ts"],"names":["callConnector"],"mappings":";;;;;AAyBA,SAAS,eAAA,CAAgB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AAC/D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,IAAA;AAAA,IACN,SAAA,EAAW,YAAA;AAAA,IACX,IAAA,EAAM,mBAAA;AAAA,IACN,SAAA,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,CAAO,IAAI;AAAA;AAC5B;AACF,GACD,CAAA;AAMD,EAAA,MAAM,OAAO,MAAA,CAAO,IAAA;AAEpB,EAAA,IAAI,IAAA,EAAM,OAAO,KAAA,EAAO;AACtB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,qDAAA,CAAA,GACE,MAAA,CAAO,IAAA,CAAK,KAAA,IAAS,iBAAiB;AAAA,KAC1C;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT","file":"index.cjs","sourcesContent":["/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/fixtures/ by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/fixtures/ (or weaver's template/) and regenerate:\n *\n * npm run provider -- slack\n */\n\n/**\n * The Slack faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES Slack actually publishes, so an author can wire {{ $json.data.id }}\n * against a fake and have it keep working against the real thing.\n *\n * Deterministic — same inputs, same output. A faker returning a fresh uuid\n * every call cannot be asserted on, so its fixtures degrade to \"it did not\n * throw\", which is the assertion that catches nothing.\n */\n\nimport type { ConnectorFaker, FakeRequest } from \"@particle-academy/fancy-connector-core\";\n\nfunction fakeMessagePost({ config, fake }: FakeRequest): unknown {\n return {\n \"ok\": true,\n \"channel\": \"C123ABC456\",\n \"ts\": \"1787719200.000100\",\n \"message\": {\n \"user\": \"U012AB3CDE\",\n \"type\": \"message\",\n \"ts\": \"1787719200.000100\",\n \"text\": \"Deployment finished successfully.\",\n \"app_id\": \"A012BC3DEF\",\n \"bot_id\": \"B012AB3CD\",\n },\n };\n}\n\nexport const slackFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"message_post\":\n return fakeMessagePost(request);\n\n default:\n // A faker asked for an operation it has no shape for must SAY so. Making\n // something up would produce a green run whose output silently has none\n // of the fields the author is about to reference.\n throw new Error(\n `slack: no fake response is defined for \"${operation}\". ` +\n \"Add a fixture under provider/fixtures/ and regenerate — a connector without a faker \" +\n \"cannot be developed against, tested, or demonstrated.\",\n );\n }\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/manifest.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/manifest.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- slack\n */\n\n/**\n * Slack, as one service descriptor shared by every Slack operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of Slack: its base URL, its auth\n * scheme, its idempotency header, and its faker.\n *\n * ## The sandbox trap, written down where it is used\n *\n * Install the app into a dedicated development workspace or Slack developer\n * sandbox. Messages are real inside that workspace, but its users and data are\n * separate from production. Developer sandboxes expire by default and have\n * feature and integration limits.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { slackFaker } from \"./faker.js\";\n\n/**\n * The connector API version this package was GENERATED against.\n *\n * A literal, never imported. An imported constant lets an upgrade rewrite the\n * very claim it exists to detect, after which the copy agrees with itself\n * forever.\n */\nexport const CONNECTOR_API_VERSION = 1;\n\nexport const SLACK_BASE_URLS = {\n \"live\": \"https://slack.com\",\n \"sandbox\": \"https://slack.com\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const SLACK_REQUIRES = [\n \"accessToken\",\n \"refreshToken\",\n \"clientId\",\n \"clientSecret\"\n] as const;\n\n/**\n * Apply Slack's auth scheme to an outgoing request.\n *\n *\n *\n * The mode is passed in because for some providers auth and estate are the\n * same decision expressed in the URL; here it is unused, and saying so is\n * cheaper than wondering later whether it was forgotten.\n */\nexport function slackAuthorize(\n credentials: Record<string, string | undefined>,\n request: PreparedRequest,\n _mode: ConnectorMode,\n): void {\n request.headers.Authorization = `Bearer ${credentials.accessToken ?? \"\"}`;\n}\n\n/** The Slack service, for the TypeScript runtime. */\nexport const SLACK: ServiceDescriptor = {\n service: \"slack\",\n title: \"Slack\",\n sandbox: \"separate-account\",\n baseUrls: { ...SLACK_BASE_URLS },\n requires: [...SLACK_REQUIRES],\n authorize: slackAuthorize,\n faker: slackFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/message-post.json by weaver's generator.\n * A hand-edit here is destroyed by the next protocol sync, which is worse than\n * being rejected, because it works until it silently does not. Fix\n * provider/actions/message-post.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- slack\n */\n\n/**\n * Post a text message to a Slack channel or conversation.\n *\n * POST /api/chat.postMessage —\n * https://docs.slack.dev/reference/methods/chat.postMessage\n *\n * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,\n * no fake/real branch. This describes the request; callConnector resolves the\n * connection, picks the estate, and either calls Slack or calls the faker.\n *\n * sideEffects: unsafe-to-replay.\n */\n\nimport {\n callConnector,\n type ConnectorResult,\n type RequestedMode,\n type Transport,\n} from \"@particle-academy/fancy-connector-core\";\nimport { SLACK } from \"../service.js\";\n\nexport const MESSAGE_POST_OPERATION = \"message_post\";\n\nexport type MessagePostOptions = {\n /** The node's resolved config. Keys: channel, text. */\n config: Record<string, unknown>;\n credentials?: Record<string, string | undefined>;\n mode?: RequestedMode;\n connectionId?: string | null;\n input?: unknown;\n attempts?: number;\n /** Override the transport. The only way to exercise this without a network. */\n transport?: Transport;\n};\n\nexport async function slackMessagePost(options: MessagePostOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.channel === undefined || config.channel === null || config.channel === \"\") {\n throw new Error(`message_post: \"channel\" is required (Channel).`);\n }\n\n if (config.text === undefined || config.text === null || config.text === \"\") {\n throw new Error(`message_post: \"text\" is required (Message).`);\n }\n\n const result = await callConnector(SLACK, {\n operation: MESSAGE_POST_OPERATION,\n config,\n input: options.input,\n ...(options.credentials === undefined ? {} : { credentials: options.credentials }),\n ...(options.mode === undefined ? {} : { mode: options.mode }),\n ...(options.connectionId === undefined ? {} : { connectionId: options.connectionId }),\n ...(options.attempts === undefined ? {} : { attempts: options.attempts }),\n ...(options.transport === undefined ? {} : { transport: options.transport }),\n request: {\n method: \"POST\",\n path: \"/api/chat.postMessage\",\n json: {\n \"channel\": String(config.channel),\n \"text\": String(config.text),\n },\n },\n });\n\n // Slack answers HTTP 200 with `{ok: false}` for an application-level\n // failure. A status check alone reads that as success, so the call is\n // reported as having worked and the next node receives a body that says\n // otherwise.\n const data = result.data as Record<string, unknown> | undefined;\n\n if (data?.ok === false) {\n throw new Error(\n `message_post: Slack rejected chat.postMessage — ` +\n String(data.error ?? \"no reason given\"),\n );\n }\n\n return result;\n}\n"]}
@@ -0,0 +1,116 @@
1
+ import { ServiceDescriptor, PreparedRequest, ConnectorMode, ConnectorFaker, RequestedMode, Transport, ConnectorResult } from '@particle-academy/fancy-connector-core';
2
+
3
+ /**
4
+ * GENERATED FILE — do not edit.
5
+ *
6
+ * Emitted from provider/manifest.json by weaver's generator.
7
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
8
+ * being rejected, because it works until it silently does not. Fix
9
+ * provider/manifest.json (or weaver's template/) and regenerate:
10
+ *
11
+ * npm run provider -- slack
12
+ */
13
+ /**
14
+ * Slack, as one service descriptor shared by every Slack operation.
15
+ *
16
+ * @particle-academy/fancy-connector-core carries what is true of ALL
17
+ * connectors. This carries what is true of Slack: its base URL, its auth
18
+ * scheme, its idempotency header, and its faker.
19
+ *
20
+ * ## The sandbox trap, written down where it is used
21
+ *
22
+ * Install the app into a dedicated development workspace or Slack developer
23
+ * sandbox. Messages are real inside that workspace, but its users and data are
24
+ * separate from production. Developer sandboxes expire by default and have
25
+ * feature and integration limits.
26
+ */
27
+
28
+ /**
29
+ * The connector API version this package was GENERATED against.
30
+ *
31
+ * A literal, never imported. An imported constant lets an upgrade rewrite the
32
+ * very claim it exists to detect, after which the copy agrees with itself
33
+ * forever.
34
+ */
35
+ declare const CONNECTOR_API_VERSION = 1;
36
+ declare const SLACK_BASE_URLS: {
37
+ readonly live: "https://slack.com";
38
+ readonly sandbox: "https://slack.com";
39
+ };
40
+ /** Credential keys a remote call cannot proceed without. */
41
+ declare const SLACK_REQUIRES: readonly ["accessToken", "refreshToken", "clientId", "clientSecret"];
42
+ /**
43
+ * Apply Slack's auth scheme to an outgoing request.
44
+ *
45
+ *
46
+ *
47
+ * The mode is passed in because for some providers auth and estate are the
48
+ * same decision expressed in the URL; here it is unused, and saying so is
49
+ * cheaper than wondering later whether it was forgotten.
50
+ */
51
+ declare function slackAuthorize(credentials: Record<string, string | undefined>, request: PreparedRequest, _mode: ConnectorMode): void;
52
+ /** The Slack service, for the TypeScript runtime. */
53
+ declare const SLACK: ServiceDescriptor;
54
+
55
+ /**
56
+ * GENERATED FILE — do not edit.
57
+ *
58
+ * Emitted from provider/fixtures/ by weaver's generator.
59
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
60
+ * being rejected, because it works until it silently does not. Fix
61
+ * provider/fixtures/ (or weaver's template/) and regenerate:
62
+ *
63
+ * npm run provider -- slack
64
+ */
65
+ /**
66
+ * The Slack faker.
67
+ *
68
+ * Shapes, not behaviour: the goal is that a downstream node sees the field
69
+ * NAMES Slack actually publishes, so an author can wire {{ $json.data.id }}
70
+ * against a fake and have it keep working against the real thing.
71
+ *
72
+ * Deterministic — same inputs, same output. A faker returning a fresh uuid
73
+ * every call cannot be asserted on, so its fixtures degrade to "it did not
74
+ * throw", which is the assertion that catches nothing.
75
+ */
76
+
77
+ declare const slackFaker: ConnectorFaker;
78
+
79
+ /**
80
+ * GENERATED FILE — do not edit.
81
+ *
82
+ * Emitted from provider/actions/message-post.json by weaver's generator.
83
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
84
+ * being rejected, because it works until it silently does not. Fix
85
+ * provider/actions/message-post.json (or weaver's template/) and regenerate:
86
+ *
87
+ * npm run provider -- slack
88
+ */
89
+ /**
90
+ * Post a text message to a Slack channel or conversation.
91
+ *
92
+ * POST /api/chat.postMessage —
93
+ * https://docs.slack.dev/reference/methods/chat.postMessage
94
+ *
95
+ * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
96
+ * no fake/real branch. This describes the request; callConnector resolves the
97
+ * connection, picks the estate, and either calls Slack or calls the faker.
98
+ *
99
+ * sideEffects: unsafe-to-replay.
100
+ */
101
+
102
+ declare const MESSAGE_POST_OPERATION = "message_post";
103
+ type MessagePostOptions = {
104
+ /** The node's resolved config. Keys: channel, text. */
105
+ config: Record<string, unknown>;
106
+ credentials?: Record<string, string | undefined>;
107
+ mode?: RequestedMode;
108
+ connectionId?: string | null;
109
+ input?: unknown;
110
+ attempts?: number;
111
+ /** Override the transport. The only way to exercise this without a network. */
112
+ transport?: Transport;
113
+ };
114
+ declare function slackMessagePost(options: MessagePostOptions): Promise<ConnectorResult>;
115
+
116
+ export { CONNECTOR_API_VERSION, MESSAGE_POST_OPERATION, type MessagePostOptions, SLACK, SLACK_BASE_URLS, SLACK_REQUIRES, slackAuthorize, slackFaker, slackMessagePost };
@@ -0,0 +1,116 @@
1
+ import { ServiceDescriptor, PreparedRequest, ConnectorMode, ConnectorFaker, RequestedMode, Transport, ConnectorResult } from '@particle-academy/fancy-connector-core';
2
+
3
+ /**
4
+ * GENERATED FILE — do not edit.
5
+ *
6
+ * Emitted from provider/manifest.json by weaver's generator.
7
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
8
+ * being rejected, because it works until it silently does not. Fix
9
+ * provider/manifest.json (or weaver's template/) and regenerate:
10
+ *
11
+ * npm run provider -- slack
12
+ */
13
+ /**
14
+ * Slack, as one service descriptor shared by every Slack operation.
15
+ *
16
+ * @particle-academy/fancy-connector-core carries what is true of ALL
17
+ * connectors. This carries what is true of Slack: its base URL, its auth
18
+ * scheme, its idempotency header, and its faker.
19
+ *
20
+ * ## The sandbox trap, written down where it is used
21
+ *
22
+ * Install the app into a dedicated development workspace or Slack developer
23
+ * sandbox. Messages are real inside that workspace, but its users and data are
24
+ * separate from production. Developer sandboxes expire by default and have
25
+ * feature and integration limits.
26
+ */
27
+
28
+ /**
29
+ * The connector API version this package was GENERATED against.
30
+ *
31
+ * A literal, never imported. An imported constant lets an upgrade rewrite the
32
+ * very claim it exists to detect, after which the copy agrees with itself
33
+ * forever.
34
+ */
35
+ declare const CONNECTOR_API_VERSION = 1;
36
+ declare const SLACK_BASE_URLS: {
37
+ readonly live: "https://slack.com";
38
+ readonly sandbox: "https://slack.com";
39
+ };
40
+ /** Credential keys a remote call cannot proceed without. */
41
+ declare const SLACK_REQUIRES: readonly ["accessToken", "refreshToken", "clientId", "clientSecret"];
42
+ /**
43
+ * Apply Slack's auth scheme to an outgoing request.
44
+ *
45
+ *
46
+ *
47
+ * The mode is passed in because for some providers auth and estate are the
48
+ * same decision expressed in the URL; here it is unused, and saying so is
49
+ * cheaper than wondering later whether it was forgotten.
50
+ */
51
+ declare function slackAuthorize(credentials: Record<string, string | undefined>, request: PreparedRequest, _mode: ConnectorMode): void;
52
+ /** The Slack service, for the TypeScript runtime. */
53
+ declare const SLACK: ServiceDescriptor;
54
+
55
+ /**
56
+ * GENERATED FILE — do not edit.
57
+ *
58
+ * Emitted from provider/fixtures/ by weaver's generator.
59
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
60
+ * being rejected, because it works until it silently does not. Fix
61
+ * provider/fixtures/ (or weaver's template/) and regenerate:
62
+ *
63
+ * npm run provider -- slack
64
+ */
65
+ /**
66
+ * The Slack faker.
67
+ *
68
+ * Shapes, not behaviour: the goal is that a downstream node sees the field
69
+ * NAMES Slack actually publishes, so an author can wire {{ $json.data.id }}
70
+ * against a fake and have it keep working against the real thing.
71
+ *
72
+ * Deterministic — same inputs, same output. A faker returning a fresh uuid
73
+ * every call cannot be asserted on, so its fixtures degrade to "it did not
74
+ * throw", which is the assertion that catches nothing.
75
+ */
76
+
77
+ declare const slackFaker: ConnectorFaker;
78
+
79
+ /**
80
+ * GENERATED FILE — do not edit.
81
+ *
82
+ * Emitted from provider/actions/message-post.json by weaver's generator.
83
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
84
+ * being rejected, because it works until it silently does not. Fix
85
+ * provider/actions/message-post.json (or weaver's template/) and regenerate:
86
+ *
87
+ * npm run provider -- slack
88
+ */
89
+ /**
90
+ * Post a text message to a Slack channel or conversation.
91
+ *
92
+ * POST /api/chat.postMessage —
93
+ * https://docs.slack.dev/reference/methods/chat.postMessage
94
+ *
95
+ * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
96
+ * no fake/real branch. This describes the request; callConnector resolves the
97
+ * connection, picks the estate, and either calls Slack or calls the faker.
98
+ *
99
+ * sideEffects: unsafe-to-replay.
100
+ */
101
+
102
+ declare const MESSAGE_POST_OPERATION = "message_post";
103
+ type MessagePostOptions = {
104
+ /** The node's resolved config. Keys: channel, text. */
105
+ config: Record<string, unknown>;
106
+ credentials?: Record<string, string | undefined>;
107
+ mode?: RequestedMode;
108
+ connectionId?: string | null;
109
+ input?: unknown;
110
+ attempts?: number;
111
+ /** Override the transport. The only way to exercise this without a network. */
112
+ transport?: Transport;
113
+ };
114
+ declare function slackMessagePost(options: MessagePostOptions): Promise<ConnectorResult>;
115
+
116
+ export { CONNECTOR_API_VERSION, MESSAGE_POST_OPERATION, type MessagePostOptions, SLACK, SLACK_BASE_URLS, SLACK_REQUIRES, slackAuthorize, slackFaker, slackMessagePost };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { CONNECTOR_API_VERSION, MESSAGE_POST_OPERATION, SLACK, SLACK_BASE_URLS, SLACK_REQUIRES, slackAuthorize, slackFaker, slackMessagePost } from './chunk-SWUB2VUX.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "@particle-academy/slack-js",
3
+ "version": "0.1.0",
4
+ "description": "Slack for Node — the service descriptor, its faker, its webhook verification, and one function per operation. Plain HTTP on @particle-academy/fancy-connector-core; no vendor SDK.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Fancy-Friends/slack.git"
8
+ },
9
+ "homepage": "https://github.com/Fancy-Friends/slack#readme",
10
+ "bugs": "https://github.com/Fancy-Friends/slack/issues",
11
+ "type": "module",
12
+ "main": "./dist/index.cjs",
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "import": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "require": {
22
+ "types": "./dist/index.d.cts",
23
+ "default": "./dist/index.cjs"
24
+ }
25
+ },
26
+ "./flow": {
27
+ "import": {
28
+ "types": "./dist/flow.d.ts",
29
+ "default": "./dist/flow.js"
30
+ },
31
+ "require": {
32
+ "types": "./dist/flow.d.cts",
33
+ "default": "./dist/flow.cjs"
34
+ }
35
+ },
36
+ "./package.json": "./package.json"
37
+ },
38
+ "files": [
39
+ "dist",
40
+ "README.md",
41
+ "CHANGELOG.md",
42
+ "LICENSE"
43
+ ],
44
+ "scripts": {
45
+ "build": "tsup",
46
+ "lint": "tsc --noEmit",
47
+ "test": "node --import tsx --test tests/*.test.ts",
48
+ "prepublishOnly": "tsup"
49
+ },
50
+ "dependencies": {
51
+ "@particle-academy/fancy-connector-core": ">=0.3.1 <2.0"
52
+ },
53
+ "peerDependencies": {
54
+ "@particle-academy/fancy-flow": ">=0.47.1 <2.0",
55
+ "@particle-academy/slack-ui": ">=0.1.0 <0.2.0"
56
+ },
57
+ "peerDependenciesMeta": {
58
+ "@particle-academy/fancy-flow": {
59
+ "optional": true
60
+ },
61
+ "@particle-academy/slack-ui": {
62
+ "optional": true
63
+ }
64
+ },
65
+ "devDependencies": {
66
+ "@particle-academy/fancy-flow": ">=0.47.1 <2.0",
67
+ "@types/node": "^26.2.0",
68
+ "tsup": "^8.5.0",
69
+ "tsx": "^4.19.0",
70
+ "typescript": "^5.8.0"
71
+ },
72
+ "publishConfig": {
73
+ "access": "public"
74
+ },
75
+ "keywords": [
76
+ "slack",
77
+ "messaging",
78
+ "connector",
79
+ "api",
80
+ "fancy-ui",
81
+ "particle-academy"
82
+ ],
83
+ "license": "MIT",
84
+ "sideEffects": false,
85
+ "engines": {
86
+ "node": ">=22"
87
+ }
88
+ }