@particle-academy/hubspot-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,70 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@particle-academy/hubspot-ui`, `@particle-academy/hubspot-js`,
4
+ `particle-academy/hubspot-php` and `fancy-hubspot`.
5
+
6
+ The four packages share one version, because they are generated from one
7
+ `provider/` definition and a version that meant something different in each
8
+ would be a version nobody could reason about.
9
+
10
+ ## [0.1.0] — 2026-08-20
11
+
12
+ First release. Provider four, and the first that is not a static credential.
13
+
14
+ ### Added
15
+
16
+ - `contact_create` — create a contact. `POST /crm/v3/objects/contacts`.
17
+ - A faker for it, so the node runs on a canvas with no app, no consent screen
18
+ and no HubSpot account.
19
+ - `HUBSPOT_OAUTH` — the OAuth2 exchange, declared for a host to perform.
20
+
21
+ ### Why HubSpot, and not the next name on the list
22
+
23
+ Stripe, Resend and Telegram are all static-credential providers. Three of those
24
+ prove the generator handles that shape three times; they say nothing about the
25
+ shape it has never met. HubSpot is **OAuth2**, and it broke five assumptions —
26
+ four caught by the strict key check on the way in, and one that could not be,
27
+ because the spelling was already legal.
28
+
29
+ **Every fact here is read from HubSpot's own published OpenAPI document**
30
+ (`https://api.hubspot.com/public/api/spec/v1/specs` → Contacts v3), not from
31
+ memory: the base URL, the path, the request schema, the response schema and the
32
+ OAuth2 URLs and scope.
33
+
34
+ ### The shape of the credential is the point
35
+
36
+ An OAuth app's client id and secret are **one value for the whole
37
+ installation** — the same app serves every connected account. The access and
38
+ refresh tokens are **one per account**. The connector runtime has always had a
39
+ word for this (`CredentialScope`); nothing in the generator did, so every
40
+ credential was implicitly per-account. Getting it wrong in the other direction
41
+ is not untidy, it is one account's token reaching another's.
42
+
43
+ `accessToken` is the only credential in `requires`. `clientId` and
44
+ `clientSecret` are needed to OBTAIN a token and to refresh it; they are never
45
+ sent with a request, and listing them would make every call refuse without an
46
+ app secret it does not use.
47
+
48
+ ### The package declares the dance and does not perform it
49
+
50
+ A consent screen needs a browser, a redirect URI and somewhere to persist the
51
+ result. All three belong to the host — a package that ran the exchange itself
52
+ would have to own a web server. So `HUBSPOT_OAUTH` says precisely enough for a
53
+ host to do it, including the part that is easy to miss: **an access token lasts
54
+ 30 minutes**. A host that never refreshes works all afternoon and is broken by
55
+ morning, and nothing in the request says why.
56
+
57
+ ### Not here yet
58
+
59
+ No trigger. HubSpot signs webhooks with `X-HubSpot-Signature-v3`, an HMAC over
60
+ `method + uri + body + timestamp` — and `{method}` and `{uri}` are not payload
61
+ slots the verification vocabulary has. That is the same shape as Resend's Svix
62
+ problem, and the two of them together are what the next round of webhook work
63
+ should be driven by.
64
+
65
+ `sideEffects` is `unsafe-to-replay`. HubSpot has no idempotency header, so a
66
+ retry creates a second contact; it de-duplicates on email at the account level,
67
+ which softens the common case and does nothing for a contact created without
68
+ one.
69
+
70
+ [0.1.0]: https://github.com/Fancy-Friends/hubspot/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,51 @@
1
+ # HubSpot
2
+
3
+ HubSpot 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/hubspot-ui` | `npm install @particle-academy/hubspot-ui` |
12
+ | Node | `@particle-academy/hubspot-js` | `npm install @particle-academy/hubspot-js` |
13
+ | PHP 8.4+ | `particle-academy/hubspot-php` | `composer require particle-academy/hubspot-php` |
14
+ | Python 3.11+ | `fancy-hubspot` | `pip install fancy-hubspot` |
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 HubSpot 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
+ ## Run it before you have credentials
31
+
32
+ Every operation ships a **faker**, whether or not HubSpot has a sandbox. Set a
33
+ node's mode to `fake` and it returns the shape HubSpot actually publishes — the
34
+ same field names, deterministically — so you can wire the downstream nodes before
35
+ touching an account, a key, or a network.
36
+
37
+ ## This repository is generated
38
+
39
+ `provider/` is the source. Everything under `packages/` is emitted from it and
40
+ **must not be hand-edited** — CI regenerates and diffs on every push, and the
41
+ next protocol sync destroys anything it finds. See [`AGENTS.md`](AGENTS.md).
42
+
43
+ ## Two namespaces, which do not match on purpose
44
+
45
+ The repo is `github.com/Fancy-Friends/hubspot`; the packages publish under
46
+ `particle-academy`. Nothing derives one from the other — the names come from
47
+ weaver's `friends.json` and nowhere else.
48
+
49
+ ## Licence
50
+
51
+ MIT.
@@ -0,0 +1,103 @@
1
+ import { callConnector } from '@particle-academy/fancy-connector-core';
2
+
3
+ // src/faker.ts
4
+ function fakeContactCreate({ config, fake }) {
5
+ const boundContactId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
6
+ return {
7
+ "id": boundContactId,
8
+ "properties": {
9
+ "email": config.email !== void 0 && config.email !== null && config.email !== "" ? String(config.email) : null,
10
+ "firstname": config.firstName !== void 0 && config.firstName !== null && config.firstName !== "" ? String(config.firstName) : null,
11
+ "lastname": config.lastName !== void 0 && config.lastName !== null && config.lastName !== "" ? String(config.lastName) : null,
12
+ "company": config.company !== void 0 && config.company !== null && config.company !== "" ? String(config.company) : null,
13
+ "phone": config.phone !== void 0 && config.phone !== null && config.phone !== "" ? String(config.phone) : null,
14
+ "lifecyclestage": config.lifecycleStage !== void 0 && config.lifecycleStage !== null && config.lifecycleStage !== "" ? String(config.lifecycleStage) : "lead",
15
+ "createdate": "2026-01-01T00:00:00.000Z",
16
+ "lastmodifieddate": "2026-01-01T00:00:00.000Z",
17
+ "hs_object_id": boundContactId
18
+ },
19
+ "createdAt": "2026-01-01T00:00:00.000Z",
20
+ "updatedAt": "2026-01-01T00:00:00.000Z",
21
+ "archived": false
22
+ };
23
+ }
24
+ var hubspotFaker = (operation, request) => {
25
+ switch (operation) {
26
+ case "contact_create":
27
+ return fakeContactCreate(request);
28
+ default:
29
+ throw new Error(
30
+ `hubspot: 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 CONNECTOR_API_VERSION = 1;
37
+ var HUBSPOT_BASE_URLS = {
38
+ "live": "https://api.hubapi.com",
39
+ "sandbox": "https://api.hubapi.com"
40
+ };
41
+ var HUBSPOT_REQUIRES = [
42
+ "accessToken"
43
+ ];
44
+ function hubspotAuthorize(credentials, request, _mode) {
45
+ request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
46
+ }
47
+ var HUBSPOT = {
48
+ service: "hubspot",
49
+ title: "HubSpot",
50
+ sandbox: "separate-account",
51
+ baseUrls: { ...HUBSPOT_BASE_URLS },
52
+ requires: [...HUBSPOT_REQUIRES],
53
+ authorize: hubspotAuthorize,
54
+ faker: hubspotFaker
55
+ };
56
+ var CONTACT_CREATE_OPERATION = "contact_create";
57
+ async function hubspotContactCreate(options) {
58
+ const config = options.config ?? {};
59
+ if (config.email === void 0 || config.email === null || config.email === "") {
60
+ throw new Error(`contact_create: "email" is required (Email).`);
61
+ }
62
+ return callConnector(HUBSPOT, {
63
+ operation: CONTACT_CREATE_OPERATION,
64
+ config,
65
+ input: options.input,
66
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
67
+ ...options.mode === void 0 ? {} : { mode: options.mode },
68
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
69
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
70
+ ...options.transport === void 0 ? {} : { transport: options.transport },
71
+ request: {
72
+ method: "POST",
73
+ path: "/crm/v3/objects/contacts",
74
+ json: nestFields({
75
+ "properties.email": String(config.email).trim(),
76
+ ...config.firstName !== void 0 && config.firstName !== null && config.firstName !== "" ? { "properties.firstname": String(config.firstName) } : {},
77
+ ...config.lastName !== void 0 && config.lastName !== null && config.lastName !== "" ? { "properties.lastname": String(config.lastName) } : {},
78
+ ...config.company !== void 0 && config.company !== null && config.company !== "" ? { "properties.company": String(config.company) } : {},
79
+ ...config.phone !== void 0 && config.phone !== null && config.phone !== "" ? { "properties.phone": String(config.phone) } : {},
80
+ ...config.lifecycleStage !== void 0 && config.lifecycleStage !== null && config.lifecycleStage !== "" ? { "properties.lifecyclestage": String(config.lifecycleStage) } : {},
81
+ "associations": []
82
+ })
83
+ }
84
+ });
85
+ }
86
+ function nestFields(flat) {
87
+ const out = {};
88
+ for (const [path, value] of Object.entries(flat)) {
89
+ const parts = path.split(".");
90
+ let node = out;
91
+ while (parts.length > 1) {
92
+ const key = parts.shift();
93
+ if (typeof node[key] !== "object" || node[key] === null) node[key] = {};
94
+ node = node[key];
95
+ }
96
+ node[parts[0]] = value;
97
+ }
98
+ return out;
99
+ }
100
+
101
+ export { CONNECTOR_API_VERSION, CONTACT_CREATE_OPERATION, HUBSPOT, HUBSPOT_BASE_URLS, HUBSPOT_REQUIRES, hubspotAuthorize, hubspotContactCreate, hubspotFaker };
102
+ //# sourceMappingURL=chunk-Q7XEYLRH.js.map
103
+ //# sourceMappingURL=chunk-Q7XEYLRH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/contact-create.ts"],"names":[],"mappings":";;;AAyBA,SAAS,iBAAA,CAAkB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AACjE,EAAA,MAAM,cAAA,GAAiB,KAAA,CAAM,IAAA,CAAK,EAAE,QAAQ,CAAA,EAAE,EAAG,MAAM,IAAA,CAAK,IAAI,CAAA,EAAG,CAAC,CAAC,CAAA,CAAE,KAAK,EAAE,CAAA;AAE9E,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,cAAA;AAAA,IACN,YAAA,EAAc;AAAA,MACZ,OAAA,EAAU,MAAA,CAAO,KAAA,KAAU,MAAA,IAAa,MAAA,CAAO,KAAA,KAAU,IAAA,IAAQ,MAAA,CAAO,KAAA,KAAU,EAAA,GAAK,MAAA,CAAO,MAAA,CAAO,KAAK,CAAA,GAAI,IAAA;AAAA,MAC9G,WAAA,EAAc,MAAA,CAAO,SAAA,KAAc,MAAA,IAAa,MAAA,CAAO,SAAA,KAAc,IAAA,IAAQ,MAAA,CAAO,SAAA,KAAc,EAAA,GAAK,MAAA,CAAO,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KAAM,EAAC;AAAA,QACjI,GAAI,MAAA,CAAO,cAAA,KAAmB,MAAA,IAAa,MAAA,CAAO,mBAAmB,IAAA,IAAQ,MAAA,CAAO,cAAA,KAAmB,EAAA,GAAK,EAAE,2BAAA,EAA6B,MAAA,CAAO,OAAO,cAAc,CAAA,KAAM,EAAC;AAAA,QAC9K,gBAAgB;AAAC,OAClB;AAAA;AACH,GACD,CAAA;AACH;AASA,SAAS,WAAW,IAAA,EAAwD;AAC1E,EAAA,MAAM,MAA+B,EAAC;AAEtC,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,EAAG;AAChD,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAC5B,IAAA,IAAI,IAAA,GAAO,GAAA;AAEX,IAAA,OAAO,KAAA,CAAM,SAAS,CAAA,EAAG;AACvB,MAAA,MAAM,GAAA,GAAM,MAAM,KAAA,EAAM;AAExB,MAAA,IAAI,OAAO,IAAA,CAAK,GAAG,CAAA,KAAM,QAAA,IAAY,IAAA,CAAK,GAAG,CAAA,KAAM,IAAA,EAAM,IAAA,CAAK,GAAG,CAAA,GAAI,EAAC;AACtE,MAAA,IAAA,GAAO,KAAK,GAAG,CAAA;AAAA,IACjB;AAEA,IAAA,IAAA,CAAK,KAAA,CAAM,CAAC,CAAW,CAAA,GAAI,KAAA;AAAA,EAC7B;AAEA,EAAA,OAAO,GAAA;AACT","file":"chunk-Q7XEYLRH.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 -- hubspot\n */\n\n/**\n * The HubSpot faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES HubSpot 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 fakeContactCreate({ config, fake }: FakeRequest): unknown {\n const boundContactId = Array.from({ length: 9 }, () => fake.int(0, 9)).join(\"\");\n\n return {\n \"id\": boundContactId,\n \"properties\": {\n \"email\": (config.email !== undefined && config.email !== null && config.email !== \"\" ? String(config.email) : null),\n \"firstname\": (config.firstName !== undefined && config.firstName !== null && config.firstName !== \"\" ? String(config.firstName) : null),\n \"lastname\": (config.lastName !== undefined && config.lastName !== null && config.lastName !== \"\" ? String(config.lastName) : null),\n \"company\": (config.company !== undefined && config.company !== null && config.company !== \"\" ? String(config.company) : null),\n \"phone\": (config.phone !== undefined && config.phone !== null && config.phone !== \"\" ? String(config.phone) : null),\n \"lifecyclestage\": (config.lifecycleStage !== undefined && config.lifecycleStage !== null && config.lifecycleStage !== \"\" ? String(config.lifecycleStage) : \"lead\"),\n \"createdate\": \"2026-01-01T00:00:00.000Z\",\n \"lastmodifieddate\": \"2026-01-01T00:00:00.000Z\",\n \"hs_object_id\": boundContactId,\n },\n \"createdAt\": \"2026-01-01T00:00:00.000Z\",\n \"updatedAt\": \"2026-01-01T00:00:00.000Z\",\n \"archived\": false,\n };\n}\n\nexport const hubspotFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"contact_create\":\n return fakeContactCreate(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 `hubspot: 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 -- hubspot\n */\n\n/**\n * HubSpot, as one service descriptor shared by every HubSpot operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of HubSpot: 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 * HubSpot's test estate is a DEVELOPER TEST ACCOUNT: a separate portal you\n * create from the developer account, with its own portal id, its own data and\n * its own OAuth install. Same API host, different account -- so the credential\n * is different and the URL is not. Test accounts expire if unused and carry\n * reduced limits, which is why they are a place to test rather than a place to\n * build against.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { hubspotFaker } 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 HUBSPOT_BASE_URLS = {\n \"live\": \"https://api.hubapi.com\",\n \"sandbox\": \"https://api.hubapi.com\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const HUBSPOT_REQUIRES = [\n \"accessToken\"\n] as const;\n\n/**\n * Apply HubSpot's auth scheme to an outgoing request.\n *\n * An OAuth2 access token is presented exactly like a static bearer token. The\n * difference is not in the request -- it is that this one EXPIRES, and\n * something has to refresh it. That is the host's job, and `oauth` below is\n * what tells it how.\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 hubspotAuthorize(\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 HubSpot service, for the TypeScript runtime. */\nexport const HUBSPOT: ServiceDescriptor = {\n service: \"hubspot\",\n title: \"HubSpot\",\n sandbox: \"separate-account\",\n baseUrls: { ...HUBSPOT_BASE_URLS },\n requires: [...HUBSPOT_REQUIRES],\n authorize: hubspotAuthorize,\n faker: hubspotFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/contact-create.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/contact-create.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- hubspot\n */\n\n/**\n * Create a contact in HubSpot.\n *\n * POST /crm/v3/objects/contacts —\n * https://developers.hubspot.com/docs/reference/api/crm/objects/contacts\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 HubSpot 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 { HUBSPOT } from \"../service.js\";\n\nexport const CONTACT_CREATE_OPERATION = \"contact_create\";\n\nexport type ContactCreateOptions = {\n /** The node's resolved config. Keys: email, firstName, lastName, company, phone, lifecycleStage. */\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 hubspotContactCreate(options: ContactCreateOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.email === undefined || config.email === null || config.email === \"\") {\n throw new Error(`contact_create: \"email\" is required (Email).`);\n }\n\n return callConnector(HUBSPOT, {\n operation: CONTACT_CREATE_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: \"/crm/v3/objects/contacts\",\n json: nestFields({\n \"properties.email\": String(config.email).trim(),\n ...(config.firstName !== undefined && config.firstName !== null && config.firstName !== \"\" ? { \"properties.firstname\": String(config.firstName) } : {}),\n ...(config.lastName !== undefined && config.lastName !== null && config.lastName !== \"\" ? { \"properties.lastname\": String(config.lastName) } : {}),\n ...(config.company !== undefined && config.company !== null && config.company !== \"\" ? { \"properties.company\": String(config.company) } : {}),\n ...(config.phone !== undefined && config.phone !== null && config.phone !== \"\" ? { \"properties.phone\": String(config.phone) } : {}),\n ...(config.lifecycleStage !== undefined && config.lifecycleStage !== null && config.lifecycleStage !== \"\" ? { \"properties.lifecyclestage\": String(config.lifecycleStage) } : {}),\n \"associations\": [],\n }),\n },\n });\n}\n\n/**\n * `{\"properties.email\": x}` -> `{properties: {email: x}}`.\n *\n * A dotted `as` means NESTING, and only a JSON body can nest. The validator\n * refuses that spelling anywhere else, because in a form body it already means\n * something different — a literal dotted key.\n */\nfunction nestFields(flat: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n\n for (const [path, value] of Object.entries(flat)) {\n const parts = path.split(\".\");\n let node = out;\n\n while (parts.length > 1) {\n const key = parts.shift() as string;\n\n if (typeof node[key] !== \"object\" || node[key] === null) node[key] = {};\n node = node[key] as Record<string, unknown>;\n }\n\n node[parts[0] as string] = value;\n }\n\n return out;\n}\n"]}
package/dist/flow.cjs ADDED
@@ -0,0 +1,127 @@
1
+ 'use strict';
2
+
3
+ var fancyConnectorCore = require('@particle-academy/fancy-connector-core');
4
+ var hubspotUi = require('@particle-academy/hubspot-ui');
5
+
6
+ // src/flow.ts
7
+
8
+ // src/faker.ts
9
+ function fakeContactCreate({ config, fake }) {
10
+ const boundContactId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
11
+ return {
12
+ "id": boundContactId,
13
+ "properties": {
14
+ "email": config.email !== void 0 && config.email !== null && config.email !== "" ? String(config.email) : null,
15
+ "firstname": config.firstName !== void 0 && config.firstName !== null && config.firstName !== "" ? String(config.firstName) : null,
16
+ "lastname": config.lastName !== void 0 && config.lastName !== null && config.lastName !== "" ? String(config.lastName) : null,
17
+ "company": config.company !== void 0 && config.company !== null && config.company !== "" ? String(config.company) : null,
18
+ "phone": config.phone !== void 0 && config.phone !== null && config.phone !== "" ? String(config.phone) : null,
19
+ "lifecyclestage": config.lifecycleStage !== void 0 && config.lifecycleStage !== null && config.lifecycleStage !== "" ? String(config.lifecycleStage) : "lead",
20
+ "createdate": "2026-01-01T00:00:00.000Z",
21
+ "lastmodifieddate": "2026-01-01T00:00:00.000Z",
22
+ "hs_object_id": boundContactId
23
+ },
24
+ "createdAt": "2026-01-01T00:00:00.000Z",
25
+ "updatedAt": "2026-01-01T00:00:00.000Z",
26
+ "archived": false
27
+ };
28
+ }
29
+ var hubspotFaker = (operation, request) => {
30
+ switch (operation) {
31
+ case "contact_create":
32
+ return fakeContactCreate(request);
33
+ default:
34
+ throw new Error(
35
+ `hubspot: 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.`
36
+ );
37
+ }
38
+ };
39
+
40
+ // src/service.ts
41
+ var HUBSPOT_BASE_URLS = {
42
+ "live": "https://api.hubapi.com",
43
+ "sandbox": "https://api.hubapi.com"
44
+ };
45
+ var HUBSPOT_REQUIRES = [
46
+ "accessToken"
47
+ ];
48
+ function hubspotAuthorize(credentials, request, _mode) {
49
+ request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
50
+ }
51
+ var HUBSPOT = {
52
+ service: "hubspot",
53
+ title: "HubSpot",
54
+ sandbox: "separate-account",
55
+ baseUrls: { ...HUBSPOT_BASE_URLS },
56
+ requires: [...HUBSPOT_REQUIRES],
57
+ authorize: hubspotAuthorize,
58
+ faker: hubspotFaker
59
+ };
60
+ var CONTACT_CREATE_OPERATION = "contact_create";
61
+ async function hubspotContactCreate(options) {
62
+ const config = options.config ?? {};
63
+ if (config.email === void 0 || config.email === null || config.email === "") {
64
+ throw new Error(`contact_create: "email" is required (Email).`);
65
+ }
66
+ return fancyConnectorCore.callConnector(HUBSPOT, {
67
+ operation: CONTACT_CREATE_OPERATION,
68
+ config,
69
+ input: options.input,
70
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
71
+ ...options.mode === void 0 ? {} : { mode: options.mode },
72
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
73
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
74
+ ...options.transport === void 0 ? {} : { transport: options.transport },
75
+ request: {
76
+ method: "POST",
77
+ path: "/crm/v3/objects/contacts",
78
+ json: nestFields({
79
+ "properties.email": String(config.email).trim(),
80
+ ...config.firstName !== void 0 && config.firstName !== null && config.firstName !== "" ? { "properties.firstname": String(config.firstName) } : {},
81
+ ...config.lastName !== void 0 && config.lastName !== null && config.lastName !== "" ? { "properties.lastname": String(config.lastName) } : {},
82
+ ...config.company !== void 0 && config.company !== null && config.company !== "" ? { "properties.company": String(config.company) } : {},
83
+ ...config.phone !== void 0 && config.phone !== null && config.phone !== "" ? { "properties.phone": String(config.phone) } : {},
84
+ ...config.lifecycleStage !== void 0 && config.lifecycleStage !== null && config.lifecycleStage !== "" ? { "properties.lifecyclestage": String(config.lifecycleStage) } : {},
85
+ "associations": []
86
+ })
87
+ }
88
+ });
89
+ }
90
+ function nestFields(flat) {
91
+ const out = {};
92
+ for (const [path, value] of Object.entries(flat)) {
93
+ const parts = path.split(".");
94
+ let node = out;
95
+ while (parts.length > 1) {
96
+ const key = parts.shift();
97
+ if (typeof node[key] !== "object" || node[key] === null) node[key] = {};
98
+ node = node[key];
99
+ }
100
+ node[parts[0]] = value;
101
+ }
102
+ return out;
103
+ }
104
+
105
+ // src/flow.ts
106
+ var hubspotContactCreateExecutor = async (ctx) => {
107
+ const config = ctx.node.data?.config ?? {};
108
+ const result = await hubspotContactCreate({
109
+ config,
110
+ input: ctx.inputs?.in
111
+ });
112
+ ctx.emit({
113
+ type: "log",
114
+ level: "info",
115
+ nodeId: ctx.node.id,
116
+ message: `hubspot contact_create ${result.data?.id} (${result.mode})`
117
+ });
118
+ return { __port: "out", value: result };
119
+ };
120
+ var HUBSPOT_RUNNABLE_KINDS = [
121
+ { ...hubspotUi.hubspotContactCreateKind, executor: hubspotContactCreateExecutor }
122
+ ];
123
+
124
+ exports.HUBSPOT_RUNNABLE_KINDS = HUBSPOT_RUNNABLE_KINDS;
125
+ exports.hubspotContactCreateExecutor = hubspotContactCreateExecutor;
126
+ //# sourceMappingURL=flow.cjs.map
127
+ //# sourceMappingURL=flow.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/contact-create.ts","../src/flow.ts"],"names":["callConnector","hubspotContactCreateKind"],"mappings":";;;;;;;;AAyBA,SAAS,iBAAA,CAAkB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AACjE,EAAA,MAAM,cAAA,GAAiB,KAAA,CAAM,IAAA,CAAK,EAAE,QAAQ,CAAA,EAAE,EAAG,MAAM,IAAA,CAAK,IAAI,CAAA,EAAG,CAAC,CAAC,CAAA,CAAE,KAAK,EAAE,CAAA;AAE9E,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,cAAA;AAAA,IACN,YAAA,EAAc;AAAA,MACZ,OAAA,EAAU,MAAA,CAAO,KAAA,KAAU,MAAA,IAAa,MAAA,CAAO,KAAA,KAAU,IAAA,IAAQ,MAAA,CAAO,KAAA,KAAU,EAAA,GAAK,MAAA,CAAO,MAAA,CAAO,KAAK,CAAA,GAAI,IAAA;AAAA,MAC9G,WAAA,EAAc,MAAA,CAAO,SAAA,KAAc,MAAA,IAAa,MAAA,CAAO,SAAA,KAAc,IAAA,IAAQ,MAAA,CAAO,SAAA,KAAc,EAAA,GAAK,MAAA,CAAO,MAA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IACP,IAAA,EAAM,KAAA;AAAA,IACN,KAAA,EAAO,MAAA;AAAA,IACP,MAAA,EAAQ,IAAI,IAAA,CAAK,EAAA;AAAA,IACjB,SAAS,CAAA,uBAAA,EAA2B,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GACxF,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO;AACxC;AAGO,IAAM,sBAAA,GAA+C;AAAA,EAC1D,EAAE,GAAGC,kCAAA,EAA0B,QAAA,EAAU,4BAAA;AAC3C","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 -- hubspot\n */\n\n/**\n * The HubSpot faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES HubSpot 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 fakeContactCreate({ config, fake }: FakeRequest): unknown {\n const boundContactId = Array.from({ length: 9 }, () => fake.int(0, 9)).join(\"\");\n\n return {\n \"id\": boundContactId,\n \"properties\": {\n \"email\": (config.email !== undefined && config.email !== null && config.email !== \"\" ? String(config.email) : null),\n \"firstname\": (config.firstName !== undefined && config.firstName !== null && config.firstName !== \"\" ? String(config.firstName) : null),\n \"lastname\": (config.lastName !== undefined && config.lastName !== null && config.lastName !== \"\" ? String(config.lastName) : null),\n \"company\": (config.company !== undefined && config.company !== null && config.company !== \"\" ? String(config.company) : null),\n \"phone\": (config.phone !== undefined && config.phone !== null && config.phone !== \"\" ? String(config.phone) : null),\n \"lifecyclestage\": (config.lifecycleStage !== undefined && config.lifecycleStage !== null && config.lifecycleStage !== \"\" ? String(config.lifecycleStage) : \"lead\"),\n \"createdate\": \"2026-01-01T00:00:00.000Z\",\n \"lastmodifieddate\": \"2026-01-01T00:00:00.000Z\",\n \"hs_object_id\": boundContactId,\n },\n \"createdAt\": \"2026-01-01T00:00:00.000Z\",\n \"updatedAt\": \"2026-01-01T00:00:00.000Z\",\n \"archived\": false,\n };\n}\n\nexport const hubspotFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"contact_create\":\n return fakeContactCreate(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 `hubspot: 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 -- hubspot\n */\n\n/**\n * HubSpot, as one service descriptor shared by every HubSpot operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of HubSpot: 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 * HubSpot's test estate is a DEVELOPER TEST ACCOUNT: a separate portal you\n * create from the developer account, with its own portal id, its own data and\n * its own OAuth install. Same API host, different account -- so the credential\n * is different and the URL is not. Test accounts expire if unused and carry\n * reduced limits, which is why they are a place to test rather than a place to\n * build against.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { hubspotFaker } 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 HUBSPOT_BASE_URLS = {\n \"live\": \"https://api.hubapi.com\",\n \"sandbox\": \"https://api.hubapi.com\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const HUBSPOT_REQUIRES = [\n \"accessToken\"\n] as const;\n\n/**\n * Apply HubSpot's auth scheme to an outgoing request.\n *\n * An OAuth2 access token is presented exactly like a static bearer token. The\n * difference is not in the request -- it is that this one EXPIRES, and\n * something has to refresh it. That is the host's job, and `oauth` below is\n * what tells it how.\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 hubspotAuthorize(\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 HubSpot service, for the TypeScript runtime. */\nexport const HUBSPOT: ServiceDescriptor = {\n service: \"hubspot\",\n title: \"HubSpot\",\n sandbox: \"separate-account\",\n baseUrls: { ...HUBSPOT_BASE_URLS },\n requires: [...HUBSPOT_REQUIRES],\n authorize: hubspotAuthorize,\n faker: hubspotFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/contact-create.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/contact-create.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- hubspot\n */\n\n/**\n * Create a contact in HubSpot.\n *\n * POST /crm/v3/objects/contacts —\n * https://developers.hubspot.com/docs/reference/api/crm/objects/contacts\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 HubSpot 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 { HUBSPOT } from \"../service.js\";\n\nexport const CONTACT_CREATE_OPERATION = \"contact_create\";\n\nexport type ContactCreateOptions = {\n /** The node's resolved config. Keys: email, firstName, lastName, company, phone, lifecycleStage. */\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 hubspotContactCreate(options: ContactCreateOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.email === undefined || config.email === null || config.email === \"\") {\n throw new Error(`contact_create: \"email\" is required (Email).`);\n }\n\n return callConnector(HUBSPOT, {\n operation: CONTACT_CREATE_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: \"/crm/v3/objects/contacts\",\n json: nestFields({\n \"properties.email\": String(config.email).trim(),\n ...(config.firstName !== undefined && config.firstName !== null && config.firstName !== \"\" ? { \"properties.firstname\": String(config.firstName) } : {}),\n ...(config.lastName !== undefined && config.lastName !== null && config.lastName !== \"\" ? { \"properties.lastname\": String(config.lastName) } : {}),\n ...(config.company !== undefined && config.company !== null && config.company !== \"\" ? { \"properties.company\": String(config.company) } : {}),\n ...(config.phone !== undefined && config.phone !== null && config.phone !== \"\" ? { \"properties.phone\": String(config.phone) } : {}),\n ...(config.lifecycleStage !== undefined && config.lifecycleStage !== null && config.lifecycleStage !== \"\" ? { \"properties.lifecyclestage\": String(config.lifecycleStage) } : {}),\n \"associations\": [],\n }),\n },\n });\n}\n\n/**\n * `{\"properties.email\": x}` -> `{properties: {email: x}}`.\n *\n * A dotted `as` means NESTING, and only a JSON body can nest. The validator\n * refuses that spelling anywhere else, because in a form body it already means\n * something different — a literal dotted key.\n */\nfunction nestFields(flat: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n\n for (const [path, value] of Object.entries(flat)) {\n const parts = path.split(\".\");\n let node = out;\n\n while (parts.length > 1) {\n const key = parts.shift() as string;\n\n if (typeof node[key] !== \"object\" || node[key] === null) node[key] = {};\n node = node[key] as Record<string, unknown>;\n }\n\n node[parts[0] as string] = value;\n }\n\n return out;\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 -- hubspot\n */\n\n/**\n * HubSpot's node kinds with their TypeScript executors attached — for hosts\n * that EXECUTE on TS.\n *\n * The authoring surface in @particle-academy/hubspot-ui carries no executor:\n * the editor is React on every host, so a PHP or Python project installs the\n * ui 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 { HUBSPOT } from \"./service.js\";\n\nimport {\n hubspotContactCreateKind,\n} from \"@particle-academy/hubspot-ui\";\n\nimport { hubspotContactCreate } from \"./actions/contact-create.js\";\n\nexport const hubspotContactCreateExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await hubspotContactCreate({\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: `hubspot contact_create ${(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 HUBSPOT_RUNNABLE_KINDS: NodeKindDefinition[] = [\n { ...hubspotContactCreateKind, executor: hubspotContactCreateExecutor },\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 -- hubspot
12
+ */
13
+ /**
14
+ * HubSpot's node kinds with their TypeScript executors attached — for hosts
15
+ * that EXECUTE on TS.
16
+ *
17
+ * The authoring surface in @particle-academy/hubspot-ui carries no executor:
18
+ * the editor is React on every host, so a PHP or Python project installs the
19
+ * ui package and never this one.
20
+ */
21
+
22
+ declare const hubspotContactCreateExecutor: NodeExecutor;
23
+ /** The kinds a TypeScript host registers. */
24
+ declare const HUBSPOT_RUNNABLE_KINDS: NodeKindDefinition[];
25
+
26
+ export { HUBSPOT_RUNNABLE_KINDS, hubspotContactCreateExecutor };
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 -- hubspot
12
+ */
13
+ /**
14
+ * HubSpot's node kinds with their TypeScript executors attached — for hosts
15
+ * that EXECUTE on TS.
16
+ *
17
+ * The authoring surface in @particle-academy/hubspot-ui carries no executor:
18
+ * the editor is React on every host, so a PHP or Python project installs the
19
+ * ui package and never this one.
20
+ */
21
+
22
+ declare const hubspotContactCreateExecutor: NodeExecutor;
23
+ /** The kinds a TypeScript host registers. */
24
+ declare const HUBSPOT_RUNNABLE_KINDS: NodeKindDefinition[];
25
+
26
+ export { HUBSPOT_RUNNABLE_KINDS, hubspotContactCreateExecutor };
package/dist/flow.js ADDED
@@ -0,0 +1,25 @@
1
+ import { hubspotContactCreate } from './chunk-Q7XEYLRH.js';
2
+ import '@particle-academy/fancy-connector-core';
3
+ import { hubspotContactCreateKind } from '@particle-academy/hubspot-ui';
4
+
5
+ var hubspotContactCreateExecutor = async (ctx) => {
6
+ const config = ctx.node.data?.config ?? {};
7
+ const result = await hubspotContactCreate({
8
+ config,
9
+ input: ctx.inputs?.in
10
+ });
11
+ ctx.emit({
12
+ type: "log",
13
+ level: "info",
14
+ nodeId: ctx.node.id,
15
+ message: `hubspot contact_create ${result.data?.id} (${result.mode})`
16
+ });
17
+ return { __port: "out", value: result };
18
+ };
19
+ var HUBSPOT_RUNNABLE_KINDS = [
20
+ { ...hubspotContactCreateKind, executor: hubspotContactCreateExecutor }
21
+ ];
22
+
23
+ export { HUBSPOT_RUNNABLE_KINDS, hubspotContactCreateExecutor };
24
+ //# sourceMappingURL=flow.js.map
25
+ //# sourceMappingURL=flow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/flow.ts"],"names":[],"mappings":";;;;AAoCO,IAAM,4BAAA,GAA6C,OAAO,GAAA,KAAQ;AACvE,EAAA,MAAM,MAAA,GAAW,GAAA,CAAI,IAAA,CAAK,IAAA,EAA+C,UAAU,EAAC;AAEpF,EAAA,MAAM,MAAA,GAAS,MAAM,oBAAA,CAAqB;AAAA,IACxC,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,uBAAA,EAA2B,MAAA,CAAO,MAA0B,EAAE,CAAA,EAAA,EAAK,OAAO,IAAI,CAAA,CAAA;AAAA,GACxF,CAAA;AAED,EAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,KAAA,EAAO,MAAA,EAAO;AACxC;AAGO,IAAM,sBAAA,GAA+C;AAAA,EAC1D,EAAE,GAAG,wBAAA,EAA0B,QAAA,EAAU,4BAAA;AAC3C","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 -- hubspot\n */\n\n/**\n * HubSpot's node kinds with their TypeScript executors attached — for hosts\n * that EXECUTE on TS.\n *\n * The authoring surface in @particle-academy/hubspot-ui carries no executor:\n * the editor is React on every host, so a PHP or Python project installs the\n * ui 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 { HUBSPOT } from \"./service.js\";\n\nimport {\n hubspotContactCreateKind,\n} from \"@particle-academy/hubspot-ui\";\n\nimport { hubspotContactCreate } from \"./actions/contact-create.js\";\n\nexport const hubspotContactCreateExecutor: NodeExecutor = async (ctx) => {\n const config = ((ctx.node.data as { config?: Record<string, unknown> })?.config ?? {});\n\n const result = await hubspotContactCreate({\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: `hubspot contact_create ${(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 HUBSPOT_RUNNABLE_KINDS: NodeKindDefinition[] = [\n { ...hubspotContactCreateKind, executor: hubspotContactCreateExecutor },\n];\n"]}
package/dist/index.cjs ADDED
@@ -0,0 +1,112 @@
1
+ 'use strict';
2
+
3
+ var fancyConnectorCore = require('@particle-academy/fancy-connector-core');
4
+
5
+ // src/faker.ts
6
+ function fakeContactCreate({ config, fake }) {
7
+ const boundContactId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
8
+ return {
9
+ "id": boundContactId,
10
+ "properties": {
11
+ "email": config.email !== void 0 && config.email !== null && config.email !== "" ? String(config.email) : null,
12
+ "firstname": config.firstName !== void 0 && config.firstName !== null && config.firstName !== "" ? String(config.firstName) : null,
13
+ "lastname": config.lastName !== void 0 && config.lastName !== null && config.lastName !== "" ? String(config.lastName) : null,
14
+ "company": config.company !== void 0 && config.company !== null && config.company !== "" ? String(config.company) : null,
15
+ "phone": config.phone !== void 0 && config.phone !== null && config.phone !== "" ? String(config.phone) : null,
16
+ "lifecyclestage": config.lifecycleStage !== void 0 && config.lifecycleStage !== null && config.lifecycleStage !== "" ? String(config.lifecycleStage) : "lead",
17
+ "createdate": "2026-01-01T00:00:00.000Z",
18
+ "lastmodifieddate": "2026-01-01T00:00:00.000Z",
19
+ "hs_object_id": boundContactId
20
+ },
21
+ "createdAt": "2026-01-01T00:00:00.000Z",
22
+ "updatedAt": "2026-01-01T00:00:00.000Z",
23
+ "archived": false
24
+ };
25
+ }
26
+ var hubspotFaker = (operation, request) => {
27
+ switch (operation) {
28
+ case "contact_create":
29
+ return fakeContactCreate(request);
30
+ default:
31
+ throw new Error(
32
+ `hubspot: 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.`
33
+ );
34
+ }
35
+ };
36
+
37
+ // src/service.ts
38
+ var CONNECTOR_API_VERSION = 1;
39
+ var HUBSPOT_BASE_URLS = {
40
+ "live": "https://api.hubapi.com",
41
+ "sandbox": "https://api.hubapi.com"
42
+ };
43
+ var HUBSPOT_REQUIRES = [
44
+ "accessToken"
45
+ ];
46
+ function hubspotAuthorize(credentials, request, _mode) {
47
+ request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
48
+ }
49
+ var HUBSPOT = {
50
+ service: "hubspot",
51
+ title: "HubSpot",
52
+ sandbox: "separate-account",
53
+ baseUrls: { ...HUBSPOT_BASE_URLS },
54
+ requires: [...HUBSPOT_REQUIRES],
55
+ authorize: hubspotAuthorize,
56
+ faker: hubspotFaker
57
+ };
58
+ var CONTACT_CREATE_OPERATION = "contact_create";
59
+ async function hubspotContactCreate(options) {
60
+ const config = options.config ?? {};
61
+ if (config.email === void 0 || config.email === null || config.email === "") {
62
+ throw new Error(`contact_create: "email" is required (Email).`);
63
+ }
64
+ return fancyConnectorCore.callConnector(HUBSPOT, {
65
+ operation: CONTACT_CREATE_OPERATION,
66
+ config,
67
+ input: options.input,
68
+ ...options.credentials === void 0 ? {} : { credentials: options.credentials },
69
+ ...options.mode === void 0 ? {} : { mode: options.mode },
70
+ ...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
71
+ ...options.attempts === void 0 ? {} : { attempts: options.attempts },
72
+ ...options.transport === void 0 ? {} : { transport: options.transport },
73
+ request: {
74
+ method: "POST",
75
+ path: "/crm/v3/objects/contacts",
76
+ json: nestFields({
77
+ "properties.email": String(config.email).trim(),
78
+ ...config.firstName !== void 0 && config.firstName !== null && config.firstName !== "" ? { "properties.firstname": String(config.firstName) } : {},
79
+ ...config.lastName !== void 0 && config.lastName !== null && config.lastName !== "" ? { "properties.lastname": String(config.lastName) } : {},
80
+ ...config.company !== void 0 && config.company !== null && config.company !== "" ? { "properties.company": String(config.company) } : {},
81
+ ...config.phone !== void 0 && config.phone !== null && config.phone !== "" ? { "properties.phone": String(config.phone) } : {},
82
+ ...config.lifecycleStage !== void 0 && config.lifecycleStage !== null && config.lifecycleStage !== "" ? { "properties.lifecyclestage": String(config.lifecycleStage) } : {},
83
+ "associations": []
84
+ })
85
+ }
86
+ });
87
+ }
88
+ function nestFields(flat) {
89
+ const out = {};
90
+ for (const [path, value] of Object.entries(flat)) {
91
+ const parts = path.split(".");
92
+ let node = out;
93
+ while (parts.length > 1) {
94
+ const key = parts.shift();
95
+ if (typeof node[key] !== "object" || node[key] === null) node[key] = {};
96
+ node = node[key];
97
+ }
98
+ node[parts[0]] = value;
99
+ }
100
+ return out;
101
+ }
102
+
103
+ exports.CONNECTOR_API_VERSION = CONNECTOR_API_VERSION;
104
+ exports.CONTACT_CREATE_OPERATION = CONTACT_CREATE_OPERATION;
105
+ exports.HUBSPOT = HUBSPOT;
106
+ exports.HUBSPOT_BASE_URLS = HUBSPOT_BASE_URLS;
107
+ exports.HUBSPOT_REQUIRES = HUBSPOT_REQUIRES;
108
+ exports.hubspotAuthorize = hubspotAuthorize;
109
+ exports.hubspotContactCreate = hubspotContactCreate;
110
+ exports.hubspotFaker = hubspotFaker;
111
+ //# sourceMappingURL=index.cjs.map
112
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/faker.ts","../src/service.ts","../src/actions/contact-create.ts"],"names":["callConnector"],"mappings":";;;;;AAyBA,SAAS,iBAAA,CAAkB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAyB;AACjE,EAAA,MAAM,cAAA,GAAiB,KAAA,CAAM,IAAA,CAAK,EAAE,QAAQ,CAAA,EAAE,EAAG,MAAM,IAAA,CAAK,IAAI,CAAA,EAAG,CAAC,CAAC,CAAA,CAAE,KAAK,EAAE,CAAA;AAE9E,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,cAAA;AAAA,IACN,YAAA,EAAc;AAAA,MACZ,OAAA,EAAU,MAAA,CAAO,KAAA,KAAU,MAAA,IAAa,MAAA,CAAO,KAAA,KAAU,IAAA,IAAQ,MAAA,CAAO,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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 -- hubspot\n */\n\n/**\n * The HubSpot faker.\n *\n * Shapes, not behaviour: the goal is that a downstream node sees the field\n * NAMES HubSpot 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 fakeContactCreate({ config, fake }: FakeRequest): unknown {\n const boundContactId = Array.from({ length: 9 }, () => fake.int(0, 9)).join(\"\");\n\n return {\n \"id\": boundContactId,\n \"properties\": {\n \"email\": (config.email !== undefined && config.email !== null && config.email !== \"\" ? String(config.email) : null),\n \"firstname\": (config.firstName !== undefined && config.firstName !== null && config.firstName !== \"\" ? String(config.firstName) : null),\n \"lastname\": (config.lastName !== undefined && config.lastName !== null && config.lastName !== \"\" ? String(config.lastName) : null),\n \"company\": (config.company !== undefined && config.company !== null && config.company !== \"\" ? String(config.company) : null),\n \"phone\": (config.phone !== undefined && config.phone !== null && config.phone !== \"\" ? String(config.phone) : null),\n \"lifecyclestage\": (config.lifecycleStage !== undefined && config.lifecycleStage !== null && config.lifecycleStage !== \"\" ? String(config.lifecycleStage) : \"lead\"),\n \"createdate\": \"2026-01-01T00:00:00.000Z\",\n \"lastmodifieddate\": \"2026-01-01T00:00:00.000Z\",\n \"hs_object_id\": boundContactId,\n },\n \"createdAt\": \"2026-01-01T00:00:00.000Z\",\n \"updatedAt\": \"2026-01-01T00:00:00.000Z\",\n \"archived\": false,\n };\n}\n\nexport const hubspotFaker: ConnectorFaker = (operation, request) => {\n switch (operation) {\n case \"contact_create\":\n return fakeContactCreate(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 `hubspot: 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 -- hubspot\n */\n\n/**\n * HubSpot, as one service descriptor shared by every HubSpot operation.\n *\n * @particle-academy/fancy-connector-core carries what is true of ALL\n * connectors. This carries what is true of HubSpot: 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 * HubSpot's test estate is a DEVELOPER TEST ACCOUNT: a separate portal you\n * create from the developer account, with its own portal id, its own data and\n * its own OAuth install. Same API host, different account -- so the credential\n * is different and the URL is not. Test accounts expire if unused and carry\n * reduced limits, which is why they are a place to test rather than a place to\n * build against.\n */\n\nimport type { ConnectorMode, PreparedRequest, ServiceDescriptor } from \"@particle-academy/fancy-connector-core\";\n\nimport { hubspotFaker } 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 HUBSPOT_BASE_URLS = {\n \"live\": \"https://api.hubapi.com\",\n \"sandbox\": \"https://api.hubapi.com\"\n} as const;\n\n/** Credential keys a remote call cannot proceed without. */\nexport const HUBSPOT_REQUIRES = [\n \"accessToken\"\n] as const;\n\n/**\n * Apply HubSpot's auth scheme to an outgoing request.\n *\n * An OAuth2 access token is presented exactly like a static bearer token. The\n * difference is not in the request -- it is that this one EXPIRES, and\n * something has to refresh it. That is the host's job, and `oauth` below is\n * what tells it how.\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 hubspotAuthorize(\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 HubSpot service, for the TypeScript runtime. */\nexport const HUBSPOT: ServiceDescriptor = {\n service: \"hubspot\",\n title: \"HubSpot\",\n sandbox: \"separate-account\",\n baseUrls: { ...HUBSPOT_BASE_URLS },\n requires: [...HUBSPOT_REQUIRES],\n authorize: hubspotAuthorize,\n faker: hubspotFaker,\n};\n","/**\n * GENERATED FILE — do not edit.\n *\n * Emitted from provider/actions/contact-create.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/contact-create.json (or weaver's template/) and regenerate:\n *\n * npm run provider -- hubspot\n */\n\n/**\n * Create a contact in HubSpot.\n *\n * POST /crm/v3/objects/contacts —\n * https://developers.hubspot.com/docs/reference/api/crm/objects/contacts\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 HubSpot 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 { HUBSPOT } from \"../service.js\";\n\nexport const CONTACT_CREATE_OPERATION = \"contact_create\";\n\nexport type ContactCreateOptions = {\n /** The node's resolved config. Keys: email, firstName, lastName, company, phone, lifecycleStage. */\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 hubspotContactCreate(options: ContactCreateOptions): Promise<ConnectorResult> {\n const config = options.config ?? {};\n\n if (config.email === undefined || config.email === null || config.email === \"\") {\n throw new Error(`contact_create: \"email\" is required (Email).`);\n }\n\n return callConnector(HUBSPOT, {\n operation: CONTACT_CREATE_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: \"/crm/v3/objects/contacts\",\n json: nestFields({\n \"properties.email\": String(config.email).trim(),\n ...(config.firstName !== undefined && config.firstName !== null && config.firstName !== \"\" ? { \"properties.firstname\": String(config.firstName) } : {}),\n ...(config.lastName !== undefined && config.lastName !== null && config.lastName !== \"\" ? { \"properties.lastname\": String(config.lastName) } : {}),\n ...(config.company !== undefined && config.company !== null && config.company !== \"\" ? { \"properties.company\": String(config.company) } : {}),\n ...(config.phone !== undefined && config.phone !== null && config.phone !== \"\" ? { \"properties.phone\": String(config.phone) } : {}),\n ...(config.lifecycleStage !== undefined && config.lifecycleStage !== null && config.lifecycleStage !== \"\" ? { \"properties.lifecyclestage\": String(config.lifecycleStage) } : {}),\n \"associations\": [],\n }),\n },\n });\n}\n\n/**\n * `{\"properties.email\": x}` -> `{properties: {email: x}}`.\n *\n * A dotted `as` means NESTING, and only a JSON body can nest. The validator\n * refuses that spelling anywhere else, because in a form body it already means\n * something different — a literal dotted key.\n */\nfunction nestFields(flat: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n\n for (const [path, value] of Object.entries(flat)) {\n const parts = path.split(\".\");\n let node = out;\n\n while (parts.length > 1) {\n const key = parts.shift() as string;\n\n if (typeof node[key] !== \"object\" || node[key] === null) node[key] = {};\n node = node[key] as Record<string, unknown>;\n }\n\n node[parts[0] as string] = value;\n }\n\n return out;\n}\n"]}
@@ -0,0 +1,121 @@
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 -- hubspot
12
+ */
13
+ /**
14
+ * HubSpot, as one service descriptor shared by every HubSpot operation.
15
+ *
16
+ * @particle-academy/fancy-connector-core carries what is true of ALL
17
+ * connectors. This carries what is true of HubSpot: 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
+ * HubSpot's test estate is a DEVELOPER TEST ACCOUNT: a separate portal you
23
+ * create from the developer account, with its own portal id, its own data and
24
+ * its own OAuth install. Same API host, different account -- so the credential
25
+ * is different and the URL is not. Test accounts expire if unused and carry
26
+ * reduced limits, which is why they are a place to test rather than a place to
27
+ * build against.
28
+ */
29
+
30
+ /**
31
+ * The connector API version this package was GENERATED against.
32
+ *
33
+ * A literal, never imported. An imported constant lets an upgrade rewrite the
34
+ * very claim it exists to detect, after which the copy agrees with itself
35
+ * forever.
36
+ */
37
+ declare const CONNECTOR_API_VERSION = 1;
38
+ declare const HUBSPOT_BASE_URLS: {
39
+ readonly live: "https://api.hubapi.com";
40
+ readonly sandbox: "https://api.hubapi.com";
41
+ };
42
+ /** Credential keys a remote call cannot proceed without. */
43
+ declare const HUBSPOT_REQUIRES: readonly ["accessToken"];
44
+ /**
45
+ * Apply HubSpot's auth scheme to an outgoing request.
46
+ *
47
+ * An OAuth2 access token is presented exactly like a static bearer token. The
48
+ * difference is not in the request -- it is that this one EXPIRES, and
49
+ * something has to refresh it. That is the host's job, and `oauth` below is
50
+ * what tells it how.
51
+ *
52
+ * The mode is passed in because for some providers auth and estate are the
53
+ * same decision expressed in the URL; here it is unused, and saying so is
54
+ * cheaper than wondering later whether it was forgotten.
55
+ */
56
+ declare function hubspotAuthorize(credentials: Record<string, string | undefined>, request: PreparedRequest, _mode: ConnectorMode): void;
57
+ /** The HubSpot service, for the TypeScript runtime. */
58
+ declare const HUBSPOT: ServiceDescriptor;
59
+
60
+ /**
61
+ * GENERATED FILE — do not edit.
62
+ *
63
+ * Emitted from provider/fixtures/ by weaver's generator.
64
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
65
+ * being rejected, because it works until it silently does not. Fix
66
+ * provider/fixtures/ (or weaver's template/) and regenerate:
67
+ *
68
+ * npm run provider -- hubspot
69
+ */
70
+ /**
71
+ * The HubSpot faker.
72
+ *
73
+ * Shapes, not behaviour: the goal is that a downstream node sees the field
74
+ * NAMES HubSpot actually publishes, so an author can wire {{ $json.data.id }}
75
+ * against a fake and have it keep working against the real thing.
76
+ *
77
+ * Deterministic — same inputs, same output. A faker returning a fresh uuid
78
+ * every call cannot be asserted on, so its fixtures degrade to "it did not
79
+ * throw", which is the assertion that catches nothing.
80
+ */
81
+
82
+ declare const hubspotFaker: ConnectorFaker;
83
+
84
+ /**
85
+ * GENERATED FILE — do not edit.
86
+ *
87
+ * Emitted from provider/actions/contact-create.json by weaver's generator.
88
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
89
+ * being rejected, because it works until it silently does not. Fix
90
+ * provider/actions/contact-create.json (or weaver's template/) and regenerate:
91
+ *
92
+ * npm run provider -- hubspot
93
+ */
94
+ /**
95
+ * Create a contact in HubSpot.
96
+ *
97
+ * POST /crm/v3/objects/contacts —
98
+ * https://developers.hubspot.com/docs/reference/api/crm/objects/contacts
99
+ *
100
+ * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
101
+ * no fake/real branch. This describes the request; callConnector resolves the
102
+ * connection, picks the estate, and either calls HubSpot or calls the faker.
103
+ *
104
+ * sideEffects: unsafe-to-replay.
105
+ */
106
+
107
+ declare const CONTACT_CREATE_OPERATION = "contact_create";
108
+ type ContactCreateOptions = {
109
+ /** The node's resolved config. Keys: email, firstName, lastName, company, phone, lifecycleStage. */
110
+ config: Record<string, unknown>;
111
+ credentials?: Record<string, string | undefined>;
112
+ mode?: RequestedMode;
113
+ connectionId?: string | null;
114
+ input?: unknown;
115
+ attempts?: number;
116
+ /** Override the transport. The only way to exercise this without a network. */
117
+ transport?: Transport;
118
+ };
119
+ declare function hubspotContactCreate(options: ContactCreateOptions): Promise<ConnectorResult>;
120
+
121
+ export { CONNECTOR_API_VERSION, CONTACT_CREATE_OPERATION, type ContactCreateOptions, HUBSPOT, HUBSPOT_BASE_URLS, HUBSPOT_REQUIRES, hubspotAuthorize, hubspotContactCreate, hubspotFaker };
@@ -0,0 +1,121 @@
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 -- hubspot
12
+ */
13
+ /**
14
+ * HubSpot, as one service descriptor shared by every HubSpot operation.
15
+ *
16
+ * @particle-academy/fancy-connector-core carries what is true of ALL
17
+ * connectors. This carries what is true of HubSpot: 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
+ * HubSpot's test estate is a DEVELOPER TEST ACCOUNT: a separate portal you
23
+ * create from the developer account, with its own portal id, its own data and
24
+ * its own OAuth install. Same API host, different account -- so the credential
25
+ * is different and the URL is not. Test accounts expire if unused and carry
26
+ * reduced limits, which is why they are a place to test rather than a place to
27
+ * build against.
28
+ */
29
+
30
+ /**
31
+ * The connector API version this package was GENERATED against.
32
+ *
33
+ * A literal, never imported. An imported constant lets an upgrade rewrite the
34
+ * very claim it exists to detect, after which the copy agrees with itself
35
+ * forever.
36
+ */
37
+ declare const CONNECTOR_API_VERSION = 1;
38
+ declare const HUBSPOT_BASE_URLS: {
39
+ readonly live: "https://api.hubapi.com";
40
+ readonly sandbox: "https://api.hubapi.com";
41
+ };
42
+ /** Credential keys a remote call cannot proceed without. */
43
+ declare const HUBSPOT_REQUIRES: readonly ["accessToken"];
44
+ /**
45
+ * Apply HubSpot's auth scheme to an outgoing request.
46
+ *
47
+ * An OAuth2 access token is presented exactly like a static bearer token. The
48
+ * difference is not in the request -- it is that this one EXPIRES, and
49
+ * something has to refresh it. That is the host's job, and `oauth` below is
50
+ * what tells it how.
51
+ *
52
+ * The mode is passed in because for some providers auth and estate are the
53
+ * same decision expressed in the URL; here it is unused, and saying so is
54
+ * cheaper than wondering later whether it was forgotten.
55
+ */
56
+ declare function hubspotAuthorize(credentials: Record<string, string | undefined>, request: PreparedRequest, _mode: ConnectorMode): void;
57
+ /** The HubSpot service, for the TypeScript runtime. */
58
+ declare const HUBSPOT: ServiceDescriptor;
59
+
60
+ /**
61
+ * GENERATED FILE — do not edit.
62
+ *
63
+ * Emitted from provider/fixtures/ by weaver's generator.
64
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
65
+ * being rejected, because it works until it silently does not. Fix
66
+ * provider/fixtures/ (or weaver's template/) and regenerate:
67
+ *
68
+ * npm run provider -- hubspot
69
+ */
70
+ /**
71
+ * The HubSpot faker.
72
+ *
73
+ * Shapes, not behaviour: the goal is that a downstream node sees the field
74
+ * NAMES HubSpot actually publishes, so an author can wire {{ $json.data.id }}
75
+ * against a fake and have it keep working against the real thing.
76
+ *
77
+ * Deterministic — same inputs, same output. A faker returning a fresh uuid
78
+ * every call cannot be asserted on, so its fixtures degrade to "it did not
79
+ * throw", which is the assertion that catches nothing.
80
+ */
81
+
82
+ declare const hubspotFaker: ConnectorFaker;
83
+
84
+ /**
85
+ * GENERATED FILE — do not edit.
86
+ *
87
+ * Emitted from provider/actions/contact-create.json by weaver's generator.
88
+ * A hand-edit here is destroyed by the next protocol sync, which is worse than
89
+ * being rejected, because it works until it silently does not. Fix
90
+ * provider/actions/contact-create.json (or weaver's template/) and regenerate:
91
+ *
92
+ * npm run provider -- hubspot
93
+ */
94
+ /**
95
+ * Create a contact in HubSpot.
96
+ *
97
+ * POST /crm/v3/objects/contacts —
98
+ * https://developers.hubspot.com/docs/reference/api/crm/objects/contacts
99
+ *
100
+ * Notice what is NOT here: no key, no base URL, no mode check, no retry loop,
101
+ * no fake/real branch. This describes the request; callConnector resolves the
102
+ * connection, picks the estate, and either calls HubSpot or calls the faker.
103
+ *
104
+ * sideEffects: unsafe-to-replay.
105
+ */
106
+
107
+ declare const CONTACT_CREATE_OPERATION = "contact_create";
108
+ type ContactCreateOptions = {
109
+ /** The node's resolved config. Keys: email, firstName, lastName, company, phone, lifecycleStage. */
110
+ config: Record<string, unknown>;
111
+ credentials?: Record<string, string | undefined>;
112
+ mode?: RequestedMode;
113
+ connectionId?: string | null;
114
+ input?: unknown;
115
+ attempts?: number;
116
+ /** Override the transport. The only way to exercise this without a network. */
117
+ transport?: Transport;
118
+ };
119
+ declare function hubspotContactCreate(options: ContactCreateOptions): Promise<ConnectorResult>;
120
+
121
+ export { CONNECTOR_API_VERSION, CONTACT_CREATE_OPERATION, type ContactCreateOptions, HUBSPOT, HUBSPOT_BASE_URLS, HUBSPOT_REQUIRES, hubspotAuthorize, hubspotContactCreate, hubspotFaker };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { CONNECTOR_API_VERSION, CONTACT_CREATE_OPERATION, HUBSPOT, HUBSPOT_BASE_URLS, HUBSPOT_REQUIRES, hubspotAuthorize, hubspotContactCreate, hubspotFaker } from './chunk-Q7XEYLRH.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,85 @@
1
+ {
2
+ "name": "@particle-academy/hubspot-js",
3
+ "version": "0.1.0",
4
+ "description": "HubSpot 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/hubspot.git"
8
+ },
9
+ "homepage": "https://github.com/Fancy-Friends/hubspot#readme",
10
+ "bugs": "https://github.com/Fancy-Friends/hubspot/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
+ "@particle-academy/hubspot-ui": "0.1.0"
53
+ },
54
+ "peerDependencies": {
55
+ "@particle-academy/fancy-flow": ">=0.47.1 <2.0"
56
+ },
57
+ "peerDependenciesMeta": {
58
+ "@particle-academy/fancy-flow": {
59
+ "optional": true
60
+ }
61
+ },
62
+ "devDependencies": {
63
+ "@particle-academy/fancy-flow": ">=0.47.1 <2.0",
64
+ "@types/node": "^26.2.0",
65
+ "tsup": "^8.5.0",
66
+ "tsx": "^4.19.0",
67
+ "typescript": "^5.8.0"
68
+ },
69
+ "publishConfig": {
70
+ "access": "public"
71
+ },
72
+ "keywords": [
73
+ "hubspot",
74
+ "crm",
75
+ "connector",
76
+ "api",
77
+ "fancy-ui",
78
+ "particle-academy"
79
+ ],
80
+ "license": "MIT",
81
+ "sideEffects": false,
82
+ "engines": {
83
+ "node": ">=22"
84
+ }
85
+ }